/usr/lib/ats2-postiats-0.2.6/libats/CATS/deqarray.cats is in ats2-lang 0.2.6-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | /* ******************************************************************* */
/* */
/* Applied Type System */
/* */
/* ******************************************************************* */
/*
** ATS/Postiats - Unleashing the Potential of Types!
** Copyright (C) 2011-20?? Hongwei Xi, ATS Trustful Software, Inc.
** All rights reserved
**
** ATS is free software; you can redistribute it and/or modify it under
** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** ATS is distributed in the hope that it will be useful, but WITHOUT ANY
** WARRANTY; without even the implied warranty of MERCHANTABILITY or
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
** for more details.
**
** You should have received a copy of the GNU General Public License
** along with ATS; see the file COPYING. If not, please write to the
** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
** 02110-1301, USA.
*/
/* ****** ****** */
/*
(* Author: Hongwei Xi *)
(* Authoremail: hwxi AT cs DOT bu DOT edu *)
(* Start time: October, 2013 *)
*/
/* ****** ****** */
#ifndef ATSHOME_LIBATS_CATS_DEQARRAY
#define ATSHOME_LIBATS_CATS_DEQARRAY
/* ****** ****** */
typedef
struct {
atstype_ptr deqarray_beg ; // the beg pointer
atstype_ptr deqarray_end ; // the end pointer
atstype_ref deqarray_frnt ; // the frontal pointer
atstype_ref deqarray_rear ; // the rear pointer
} atslib_deqarray_struct ;
/* ****** ****** */
ATSinline()
atstype_ptr
atslib_deqarray_make_ngc__tsz
(
atstype_ptr p
, atstype_ptr A
, atstype_size m
, atstype_size tsz
) {
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
//
p_deq->deqarray_beg = A ;
p_deq->deqarray_end = (char*)A + (m+1) * tsz ;
p_deq->deqarray_frnt = A ;
p_deq->deqarray_rear = A ;
//
return p_deq ;
//
} // end of [atslib_deqarray_make_ngc__tsz]
/* ****** ****** */
ATSinline()
atstype_size
atslib_deqarray_get_size__tsz
(
atstype_ptr p, atstype_size tsz
) {
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
//
void *p_frnt = p_deq->deqarray_frnt ;
void *p_rear = p_deq->deqarray_rear ;
//
if (p_frnt >= p_rear)
{
return ((char*)p_frnt-(char*)p_rear)/tsz ;
} else {
return ((char*)p_frnt-(char*)p_deq->deqarray_beg+(char*)p_deq->deqarray_end-(char*)p_rear)/tsz ;
} /* end of [if] */
} // end of [atslib_deqarray_get_size__tsz]
/* ****** ****** */
ATSinline()
atstype_size
atslib_deqarray_get_capacity__tsz
(
atstype_ptr p, atstype_size tsz
) {
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
return (((char*)(p_deq->deqarray_end)-(char*)(p_deq->deqarray_beg))/tsz)-1;
} // end of [atslib_deqarray_get_capacity__tsz]
/* ****** ****** */
ATSinline()
atstype_ptr
atslib_deqarray_get_ptrbeg
(atstype_ptr p)
{
return ((atslib_deqarray_struct*)p)->deqarray_beg ;
} // end of [atslib_deqarray_get_ptrbeg]
ATSinline()
atstype_ptr
atslib_deqarray_get_ptrend
(atstype_ptr p)
{
return ((atslib_deqarray_struct*)p)->deqarray_end ;
} // end of [atslib_deqarray_get_ptrend]
/* ****** ****** */
ATSinline()
atstype_ptr
atslib_deqarray_get_ptrfrnt
(atstype_ptr p)
{
return ((atslib_deqarray_struct*)p)->deqarray_frnt ;
} // end of [atslib_deqarray_get_ptrfrnt]
ATSinline()
atsvoid_t0ype
atslib_deqarray_set_ptrfrnt
(atstype_ptr p, atstype_ptr p2)
{
((atslib_deqarray_struct*)p)->deqarray_frnt = p2 ; return ;
} // end of [atslib_deqarray_set_ptrfrnt]
/* ****** ****** */
ATSinline()
atstype_ptr
atslib_deqarray_get_ptrrear
(atstype_ptr p)
{
return ((atslib_deqarray_struct*)p)->deqarray_rear ;
} // end of [atslib_deqarray_get_ptrrear]
ATSinline()
atsvoid_t0ype
atslib_deqarray_set_ptrrear
(atstype_ptr p, atstype_ptr p2)
{
((atslib_deqarray_struct*)p)->deqarray_rear = p2 ; return ;
} // end of [atslib_deqarray_set_ptrrear]
/* ****** ****** */
ATSinline()
atsvoid_t0ype
atslib_deqarray_free_nil
(atstype_ptr p)
{
atstype_ptr p_beg ;
p_beg = ((atslib_deqarray_struct*)p)->deqarray_beg ;
ATS_MFREE(p) ; ATS_MFREE(p_beg) ;
return ;
} // end of [atslib_deqarray_free_nil]
/* ****** ****** */
ATSinline()
atstype_bool
atslib_deqarray_is_nil
(atstype_ptr p)
{
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
return (p_deq->deqarray_frnt == p_deq->deqarray_rear ? atsbool_true : atsbool_false) ;
} // end of [atslib_deqarray_is_nil]
ATSinline()
atstype_bool
atslib_deqarray_isnot_nil
(atstype_ptr p)
{
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
return (p_deq->deqarray_frnt != p_deq->deqarray_rear ? atsbool_true : atsbool_false) ;
} // end of [atslib_deqarray_isnot_nil]
/* ****** ****** */
ATSinline()
atstype_ptr
atslib_deqarray_ptr_succ__tsz
(
atstype_ptr p
, atstype_ptr p_elt, atstype_size tsz
) {
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
char *p1_elt = (char*)p_elt+tsz ;
return (p1_elt < (char*)p_deq->deqarray_end) ? p1_elt : p_deq->deqarray_beg ;
} // end of [atslib_deqarray_ptr_succ__tsz]
/* ****** ****** */
ATSinline()
atstype_ptr
atslib_deqarray_ptr_pred__tsz
(
atstype_ptr p
, atstype_ptr p_elt, atstype_size tsz
) {
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
char *p_beg = (char*)p_deq->deqarray_beg ;
return ((char*)p_elt > p_beg) ? (char*)p_elt-tsz : (char*)p_deq->deqarray_end-tsz ;
} // end of [atslib_deqarray_ptr_pred__tsz]
/* ****** ****** */
ATSinline()
atstype_bool
atslib_deqarray_is_full__tsz
(atstype_ptr p, atstype_size tsz)
{
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
//
void *p_frnt = p_deq->deqarray_frnt ;
void *p_rear = p_deq->deqarray_rear ;
//
void *p1_frnt =
atslib_deqarray_ptr_succ__tsz(p_deq, p_frnt, tsz) ;
//
return (p1_frnt==p_rear ? atsbool_true : atsbool_false) ;
} // end of [atslib_deqarray_is_full__tsz]
#if(0)
ATSinline()
atstype_bool
atslib_deqarray_isnot_full__tsz
(atstype_ptr p, atstype_size tsz)
{
return (atslib_deqarray_is_full__tsz(p, tsz)) ? atsbool_false : atsbool_true ;
} // end of [atslib_deqarray_isnot_full__tsz]
#endif
/* ****** ****** */
ATSinline()
atstype_ptr
atslib_deqarray_getref_at__tsz
(
atstype_ptr p
, atstype_size i, atstype_size tsz
)
{
atslib_deqarray_struct *p_deq ;
p_deq = (atslib_deqarray_struct*)p ;
//
void *p_rear_i = (char*)p_deq->deqarray_rear + i * tsz ;
//
if (p_rear_i >= p_deq->deqarray_end)
p_rear_i = (char*)p_deq->deqarray_beg + (p_rear_i - p_deq->deqarray_end) ;
//
return p_rear_i ;
//
} // end of [atslib_deqarray_getref_at__tsz]
/* ****** ****** */
#endif // ifndef ATSHOME_LIBATS_CATS_DEQARRAY
/* ****** ****** */
/* end of [deqarray.cats] */
|