| 1 | static char adBid[]="$Id: adBuffer.c $";
|
|---|
| 2 |
|
|---|
| 3 | #include <stdlib.h>
|
|---|
| 4 | #include <stdio.h>
|
|---|
| 5 | #include <string.h>
|
|---|
| 6 |
|
|---|
| 7 | #include "adStack.h"
|
|---|
| 8 |
|
|---|
| 9 | /************ MEASUREMENT OF PUSH/POP TRAFFIC *************/
|
|---|
| 10 |
|
|---|
| 11 | static int mmftraffic = 0 ;
|
|---|
| 12 | static int mmftrafficM = 0 ;
|
|---|
| 13 |
|
|---|
| 14 | void addftraffic(int n) {
|
|---|
| 15 | mmftraffic = mmftraffic+n ;
|
|---|
| 16 | while (mmftraffic >= 1000000) {
|
|---|
| 17 | mmftraffic = mmftraffic-1000000 ;
|
|---|
| 18 | ++mmftrafficM ;
|
|---|
| 19 | }
|
|---|
| 20 | while (mmftraffic < 0) {
|
|---|
| 21 | mmftraffic = mmftraffic+1000000 ;
|
|---|
| 22 | --mmftraffic ;
|
|---|
| 23 | }
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | void printtraffic() {
|
|---|
| 27 | printctraffic_() ;
|
|---|
| 28 | printf(" F Traffic: ") ;
|
|---|
| 29 | printbigbytes(mmftrafficM, 1000000, mmftraffic) ;
|
|---|
| 30 | printf(" bytes\n") ;
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | /************************** integer*4 ************************/
|
|---|
| 34 | static int adi4buf[512] ;
|
|---|
| 35 | static int adi4ibuf = 0 ;
|
|---|
| 36 | static int adi4lbuf[512] ;
|
|---|
| 37 | static int adi4ilbuf = -1 ;
|
|---|
| 38 | static int adi4inlbuf = 0 ; /*=FALSE*/
|
|---|
| 39 |
|
|---|
| 40 | void pushinteger4(int x) {
|
|---|
| 41 | addftraffic(4) ;
|
|---|
| 42 | if (adi4ilbuf != -1) {
|
|---|
| 43 | adi4ilbuf = -1 ;
|
|---|
| 44 | adi4inlbuf = 0 ; /*=FALSE*/
|
|---|
| 45 | }
|
|---|
| 46 | if (adi4ibuf >= 511) {
|
|---|
| 47 | adi4buf[511] = x ;
|
|---|
| 48 | pushNarray((void *)adi4buf, 512*4) ;
|
|---|
| 49 | addftraffic(-512*4) ;
|
|---|
| 50 | adi4ibuf = 0 ;
|
|---|
| 51 | } else {
|
|---|
| 52 | adi4buf[adi4ibuf] = x ;
|
|---|
| 53 | ++adi4ibuf ;
|
|---|
| 54 | }
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | void lookinteger4(int *x) {
|
|---|
| 58 | if (adi4ilbuf == -1) {
|
|---|
| 59 | adi4ilbuf = adi4ibuf ;
|
|---|
| 60 | resetadlookstack_() ;
|
|---|
| 61 | }
|
|---|
| 62 | if (adi4ilbuf <= 0) {
|
|---|
| 63 | lookNarray((void *)adi4lbuf, 512*4) ;
|
|---|
| 64 | adi4inlbuf = 1 ; /*=TRUE*/
|
|---|
| 65 | adi4ilbuf = 511 ;
|
|---|
| 66 | *x = adi4lbuf[511] ;
|
|---|
| 67 | } else {
|
|---|
| 68 | --adi4ilbuf ;
|
|---|
| 69 | if (adi4inlbuf)
|
|---|
| 70 | *x = adi4lbuf[adi4ilbuf] ;
|
|---|
| 71 | else
|
|---|
| 72 | *x = adi4buf[adi4ilbuf] ;
|
|---|
| 73 | }
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | void popinteger4(int *x) {
|
|---|
| 77 | if (adi4ilbuf != -1) {
|
|---|
| 78 | adi4ilbuf = -1 ;
|
|---|
| 79 | adi4inlbuf = 0 ; /*=FALSE*/
|
|---|
| 80 | }
|
|---|
| 81 | if (adi4ibuf <= 0) {
|
|---|
| 82 | popNarray((void *)adi4buf, 512*4) ;
|
|---|
| 83 | adi4ibuf = 511 ;
|
|---|
| 84 | *x = adi4buf[511] ;
|
|---|
| 85 | } else {
|
|---|
| 86 | --adi4ibuf ;
|
|---|
| 87 | *x = adi4buf[adi4ibuf] ;
|
|---|
| 88 | }
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | /*************************** bits *************************/
|
|---|
| 92 | static unsigned int adbitbuf = 0 ;
|
|---|
| 93 | static int adbitibuf = 1 ;
|
|---|
| 94 | static unsigned int adbitlbuf = 0 ;
|
|---|
| 95 | static int adbitilbuf = -1 ;
|
|---|
| 96 | static int adbitinlbuf = 0 ; /*=FALSE*/
|
|---|
| 97 |
|
|---|
| 98 | void pushbit(int bit) {
|
|---|
| 99 | if (adbitilbuf != -1) {
|
|---|
| 100 | adbitilbuf = -1 ;
|
|---|
| 101 | adbitinlbuf = 0 ; /*=FALSE*/
|
|---|
| 102 | }
|
|---|
| 103 | adbitbuf<<=1 ;
|
|---|
| 104 | if (bit) adbitbuf++ ;
|
|---|
| 105 | if (adbitibuf>=32) {
|
|---|
| 106 | pushinteger4(adbitbuf) ;
|
|---|
| 107 | adbitbuf = 0 ;
|
|---|
| 108 | adbitibuf = 1 ;
|
|---|
| 109 | } else
|
|---|
| 110 | adbitibuf++ ;
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | int lookbit() {
|
|---|
| 114 | int bit ;
|
|---|
| 115 | if (adbitilbuf==-1) {
|
|---|
| 116 | adbitilbuf=adbitibuf ;
|
|---|
| 117 | resetadlookstack_() ;
|
|---|
| 118 | adbitlbuf = adbitbuf ;
|
|---|
| 119 | adbitinlbuf = 1 ; /*=TRUE*/
|
|---|
| 120 | }
|
|---|
| 121 | if (adbitilbuf<=1) {
|
|---|
| 122 | lookinteger4((int*)&adbitlbuf) ;
|
|---|
| 123 | adbitilbuf = 32 ;
|
|---|
| 124 | } else
|
|---|
| 125 | adbitilbuf-- ;
|
|---|
| 126 | bit = adbitlbuf%2 ;
|
|---|
| 127 | adbitlbuf>>=1 ;
|
|---|
| 128 | return bit ;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | int popbit() {
|
|---|
| 132 | int bit ;
|
|---|
| 133 | if (adbitilbuf != -1) {
|
|---|
| 134 | adbitilbuf = -1 ;
|
|---|
| 135 | adbitinlbuf = 0 ; /*=FALSE*/
|
|---|
| 136 | }
|
|---|
| 137 | if (adbitibuf<=1) {
|
|---|
| 138 | popinteger4((int*)&adbitbuf) ;
|
|---|
| 139 | adbitibuf = 32 ;
|
|---|
| 140 | } else
|
|---|
| 141 | adbitibuf-- ;
|
|---|
| 142 | bit = adbitbuf%2 ;
|
|---|
| 143 | adbitbuf>>=1 ;
|
|---|
| 144 | return bit ;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | /************************* controls ***********************/
|
|---|
| 148 |
|
|---|
| 149 | void pushcontrol1b(int cc) {
|
|---|
| 150 | pushbit(cc) ;
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | void popcontrol1b(int *cc) {
|
|---|
| 154 | *cc = (popbit()?1:0) ;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | void lookcontrol1b(int *cc) {
|
|---|
| 158 | *cc = (lookbit()?1:0) ;
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | void pushcontrol2b(int cc) {
|
|---|
| 162 | pushbit(cc%2) ;
|
|---|
| 163 | cc >>= 1 ;
|
|---|
| 164 | pushbit(cc) ;
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | void popcontrol2b(int *cc) {
|
|---|
| 168 | *cc = (popbit()?2:0) ;
|
|---|
| 169 | if (popbit()) (*cc)++ ;
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | void lookcontrol2b(int *cc) {
|
|---|
| 173 | *cc = (lookbit()?2:0) ;
|
|---|
| 174 | if (lookbit()) (*cc)++ ;
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | void pushcontrol3b(int cc) {
|
|---|
| 178 | pushbit(cc%2) ;
|
|---|
| 179 | cc >>= 1 ;
|
|---|
| 180 | pushbit(cc%2) ;
|
|---|
| 181 | cc >>= 1 ;
|
|---|
| 182 | pushbit(cc) ;
|
|---|
| 183 | }
|
|---|
| 184 |
|
|---|
| 185 | void popcontrol3b(int *cc) {
|
|---|
| 186 | *cc = (popbit()?2:0) ;
|
|---|
| 187 | if (popbit()) (*cc)++ ;
|
|---|
| 188 | (*cc) <<= 1 ;
|
|---|
| 189 | if (popbit()) (*cc)++ ;
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 | void lookcontrol3b(int *cc) {
|
|---|
| 193 | *cc = (lookbit()?2:0) ;
|
|---|
| 194 | if (lookbit()) (*cc)++ ;
|
|---|
| 195 | (*cc) <<= 1 ;
|
|---|
| 196 | if (lookbit()) (*cc)++ ;
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | void pushcontrol4b(int cc) {
|
|---|
| 200 | pushbit(cc%2) ;
|
|---|
| 201 | cc >>= 1 ;
|
|---|
| 202 | pushbit(cc%2) ;
|
|---|
| 203 | cc >>= 1 ;
|
|---|
| 204 | pushbit(cc%2) ;
|
|---|
| 205 | cc >>= 1 ;
|
|---|
| 206 | pushbit(cc) ;
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | void popcontrol4b(int *cc) {
|
|---|
| 210 | *cc = (popbit()?2:0) ;
|
|---|
| 211 | if (popbit()) (*cc)++ ;
|
|---|
| 212 | (*cc) <<= 1 ;
|
|---|
| 213 | if (popbit()) (*cc)++ ;
|
|---|
| 214 | (*cc) <<= 1 ;
|
|---|
| 215 | if (popbit()) (*cc)++ ;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | void lookcontrol4b(int *cc) {
|
|---|
| 219 | *cc = (lookbit()?2:0) ;
|
|---|
| 220 | if (lookbit()) (*cc)++ ;
|
|---|
| 221 | (*cc) <<= 1 ;
|
|---|
| 222 | if (lookbit()) (*cc)++ ;
|
|---|
| 223 | (*cc) <<= 1 ;
|
|---|
| 224 | if (lookbit()) (*cc)++ ;
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | void pushcontrol5b(int cc) {
|
|---|
| 228 | pushbit(cc%2) ;
|
|---|
| 229 | cc >>= 1 ;
|
|---|
| 230 | pushbit(cc%2) ;
|
|---|
| 231 | cc >>= 1 ;
|
|---|
| 232 | pushbit(cc%2) ;
|
|---|
| 233 | cc >>= 1 ;
|
|---|
| 234 | pushbit(cc%2) ;
|
|---|
| 235 | cc >>= 1 ;
|
|---|
| 236 | pushbit(cc) ;
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | void popcontrol5b(int *cc) {
|
|---|
| 240 | *cc = (popbit()?2:0) ;
|
|---|
| 241 | if (popbit()) (*cc)++ ;
|
|---|
| 242 | (*cc) <<= 1 ;
|
|---|
| 243 | if (popbit()) (*cc)++ ;
|
|---|
| 244 | (*cc) <<= 1 ;
|
|---|
| 245 | if (popbit()) (*cc)++ ;
|
|---|
| 246 | (*cc) <<= 1 ;
|
|---|
| 247 | if (popbit()) (*cc)++ ;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | void lookcontrol5b(int *cc) {
|
|---|
| 251 | *cc = (lookbit()?2:0) ;
|
|---|
| 252 | if (lookbit()) (*cc)++ ;
|
|---|
| 253 | (*cc) <<= 1 ;
|
|---|
| 254 | if (lookbit()) (*cc)++ ;
|
|---|
| 255 | (*cc) <<= 1 ;
|
|---|
| 256 | if (lookbit()) (*cc)++ ;
|
|---|
| 257 | (*cc) <<= 1 ;
|
|---|
| 258 | if (lookbit()) (*cc)++ ;
|
|---|
| 259 | }
|
|---|
| 260 |
|
|---|
| 261 | /************************** real*4 ************************/
|
|---|
| 262 | static float adr4buf[512] ;
|
|---|
| 263 | static int adr4ibuf = 0 ;
|
|---|
| 264 | static float adr4lbuf[512] ;
|
|---|
| 265 | static int adr4ilbuf = -1 ;
|
|---|
| 266 | static int adr4inlbuf = 0 ;
|
|---|
| 267 |
|
|---|
| 268 | void pushreal4(float x) {
|
|---|
| 269 | addftraffic(4) ;
|
|---|
| 270 | if (adr4ilbuf != -1) {
|
|---|
| 271 | adr4ilbuf = -1 ;
|
|---|
| 272 | adr4inlbuf = 0 ;
|
|---|
| 273 | }
|
|---|
| 274 | if (adr4ibuf >= 511) {
|
|---|
| 275 | adr4buf[511] = x ;
|
|---|
| 276 | pushNarray((void *)adr4buf, 512*4) ;
|
|---|
| 277 | addftraffic(-512*4) ;
|
|---|
| 278 | adr4ibuf = 0 ;
|
|---|
| 279 | } else {
|
|---|
| 280 | adr4buf[adr4ibuf] = x ;
|
|---|
| 281 | ++adr4ibuf ;
|
|---|
| 282 | }
|
|---|
| 283 | }
|
|---|
| 284 |
|
|---|
| 285 | void lookreal4(float *x) {
|
|---|
| 286 | if (adr4ilbuf == -1) {
|
|---|
| 287 | adr4ilbuf = adr4ibuf ;
|
|---|
| 288 | resetadlookstack_() ;
|
|---|
| 289 | }
|
|---|
| 290 | if (adr4ilbuf <= 0) {
|
|---|
| 291 | lookNarray((void *)adr4lbuf, 512*4) ;
|
|---|
| 292 | adr4inlbuf = 1 ;
|
|---|
| 293 | adr4ilbuf = 511 ;
|
|---|
| 294 | *x = adr4lbuf[511] ;
|
|---|
| 295 | } else {
|
|---|
| 296 | --adr4ilbuf ;
|
|---|
| 297 | if (adr4inlbuf)
|
|---|
| 298 | *x = adr4lbuf[adr4ilbuf] ;
|
|---|
| 299 | else
|
|---|
| 300 | *x = adr4buf[adr4ilbuf] ;
|
|---|
| 301 | }
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | void popreal4(float *x) {
|
|---|
| 305 | if (adr4ilbuf != -1) {
|
|---|
| 306 | adr4ilbuf = -1 ;
|
|---|
| 307 | adr4inlbuf = 0 ;
|
|---|
| 308 | }
|
|---|
| 309 | if (adr4ibuf <= 0) {
|
|---|
| 310 | popNarray((void *)adr4buf, 512*4) ;
|
|---|
| 311 | adr4ibuf = 511 ;
|
|---|
| 312 | *x = adr4buf[511] ;
|
|---|
| 313 | } else {
|
|---|
| 314 | --adr4ibuf ;
|
|---|
| 315 | *x = adr4buf[adr4ibuf] ;
|
|---|
| 316 | }
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | /************************** real*8 ************************/
|
|---|
| 320 | static double adr8buf[512] ;
|
|---|
| 321 | static int adr8ibuf = 0 ;
|
|---|
| 322 | static double adr8lbuf[512] ;
|
|---|
| 323 | static int adr8ilbuf = -1 ;
|
|---|
| 324 | static int adr8inlbuf = 0 ;
|
|---|
| 325 |
|
|---|
| 326 | void pushreal8(double x) {
|
|---|
| 327 | addftraffic(8) ;
|
|---|
| 328 | if (adr8ilbuf != -1) {
|
|---|
| 329 | adr8ilbuf = -1 ;
|
|---|
| 330 | adr8inlbuf = 0 ;
|
|---|
| 331 | }
|
|---|
| 332 | if (adr8ibuf >= 511) {
|
|---|
| 333 | adr8buf[511] = x ;
|
|---|
| 334 | pushNarray((void *)adr8buf, 512*8) ;
|
|---|
| 335 | addftraffic(-4096) ;
|
|---|
| 336 | adr8ibuf = 0 ;
|
|---|
| 337 | } else {
|
|---|
| 338 | adr8buf[adr8ibuf] = x ;
|
|---|
| 339 | ++adr8ibuf ;
|
|---|
| 340 | }
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | void lookreal8(double *x) {
|
|---|
| 344 | if (adr8ilbuf == -1) {
|
|---|
| 345 | adr8ilbuf = adr8ibuf ;
|
|---|
| 346 | resetadlookstack_() ;
|
|---|
| 347 | }
|
|---|
| 348 | if (adr8ilbuf <= 0) {
|
|---|
| 349 | lookNarray((void *)adr8lbuf, 512*8) ;
|
|---|
| 350 | adr8inlbuf = 1 ;
|
|---|
| 351 | adr8ilbuf = 511 ;
|
|---|
| 352 | *x = adr8lbuf[511] ;
|
|---|
| 353 | } else {
|
|---|
| 354 | --adr8ilbuf ;
|
|---|
| 355 | if (adr8inlbuf)
|
|---|
| 356 | *x = adr8lbuf[adr8ilbuf] ;
|
|---|
| 357 | else
|
|---|
| 358 | *x = adr8buf[adr8ilbuf] ;
|
|---|
| 359 | }
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|
| 362 | void popreal8(double *x) {
|
|---|
| 363 | if (adr8ilbuf != -1) {
|
|---|
| 364 | adr8ilbuf = -1 ;
|
|---|
| 365 | adr8inlbuf = 0 ;
|
|---|
| 366 | }
|
|---|
| 367 | if (adr8ibuf <= 0) {
|
|---|
| 368 | popNarray((void *)adr8buf, 512*8) ;
|
|---|
| 369 | adr8ibuf = 511 ;
|
|---|
| 370 | *x = adr8buf[511] ;
|
|---|
| 371 | } else {
|
|---|
| 372 | --adr8ibuf ;
|
|---|
| 373 | *x = adr8buf[adr8ibuf] ;
|
|---|
| 374 | }
|
|---|
| 375 | }
|
|---|
| 376 |
|
|---|
| 377 | /************************** character ************************/
|
|---|
| 378 | static char ads1buf[512] ;
|
|---|
| 379 | static int ads1ibuf = 0 ;
|
|---|
| 380 | static char ads1lbuf[512] ;
|
|---|
| 381 | static int ads1ilbuf = -1 ;
|
|---|
| 382 | static int ads1inlbuf = 0 ;
|
|---|
| 383 |
|
|---|
| 384 | void pushcharacter(char x) {
|
|---|
| 385 | addftraffic(1) ;
|
|---|
| 386 | if (ads1ilbuf != -1) {
|
|---|
| 387 | ads1ilbuf = -1 ;
|
|---|
| 388 | ads1inlbuf = 0 ;
|
|---|
| 389 | }
|
|---|
| 390 | if (ads1ibuf >= 511) {
|
|---|
| 391 | ads1buf[511] = x ;
|
|---|
| 392 | pushNarray((void *)ads1buf, 512) ;
|
|---|
| 393 | addftraffic(-512) ;
|
|---|
| 394 | ads1ibuf = 0 ;
|
|---|
| 395 | } else {
|
|---|
| 396 | ads1buf[ads1ibuf] = x ;
|
|---|
| 397 | ++ads1ibuf ;
|
|---|
| 398 | }
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | void lookcharacter(char *x) {
|
|---|
| 402 | if (ads1ilbuf == -1) {
|
|---|
| 403 | ads1ilbuf = ads1ibuf ;
|
|---|
| 404 | resetadlookstack_() ;
|
|---|
| 405 | }
|
|---|
| 406 | if (ads1ilbuf <= 0) {
|
|---|
| 407 | lookNarray((void *)ads1lbuf, 512) ;
|
|---|
| 408 | ads1inlbuf = 1 ;
|
|---|
| 409 | ads1ilbuf = 511 ;
|
|---|
| 410 | *x = ads1lbuf[511] ;
|
|---|
| 411 | } else {
|
|---|
| 412 | --ads1ilbuf ;
|
|---|
| 413 | if (ads1inlbuf)
|
|---|
| 414 | *x = ads1lbuf[ads1ilbuf] ;
|
|---|
| 415 | else
|
|---|
| 416 | *x = ads1buf[ads1ilbuf] ;
|
|---|
| 417 | }
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | void popcharacter(char *x) {
|
|---|
| 421 | if (ads1ilbuf != -1) {
|
|---|
| 422 | ads1ilbuf = -1 ;
|
|---|
| 423 | ads1inlbuf = 0 ;
|
|---|
| 424 | }
|
|---|
| 425 | if (ads1ibuf <= 0) {
|
|---|
| 426 | popNarray((void *)ads1buf, 512) ;
|
|---|
| 427 | ads1ibuf = 511 ;
|
|---|
| 428 | *x = ads1buf[511] ;
|
|---|
| 429 | } else {
|
|---|
| 430 | --ads1ibuf ;
|
|---|
| 431 | *x = ads1buf[ads1ibuf] ;
|
|---|
| 432 | }
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | /******************* POINTERS (old short 32 bits) ******************/
|
|---|
| 436 | static void *adp4buf[512] ;
|
|---|
| 437 | static int adp4ibuf = 0 ;
|
|---|
| 438 | static void *adp4lbuf[512] ;
|
|---|
| 439 | static int adp4ilbuf = -1 ;
|
|---|
| 440 | static int adp4inlbuf = 0 ;
|
|---|
| 441 |
|
|---|
| 442 | void pushpointer4(void *x) {
|
|---|
| 443 | addftraffic(4) ;
|
|---|
| 444 | if (adp4ilbuf != -1) {
|
|---|
| 445 | adp4ilbuf = -1 ;
|
|---|
| 446 | adp4inlbuf = 0 ;
|
|---|
| 447 | }
|
|---|
| 448 | if (adp4ibuf >= 511) {
|
|---|
| 449 | adp4buf[511] = x ;
|
|---|
| 450 | pushNarray((void *)adp4buf, 512*4) ;
|
|---|
| 451 | addftraffic(-512*4) ;
|
|---|
| 452 | adp4ibuf = 0 ;
|
|---|
| 453 | } else {
|
|---|
| 454 | adp4buf[adp4ibuf] = x ;
|
|---|
| 455 | ++adp4ibuf ;
|
|---|
| 456 | }
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | void lookpointer4(void **x) {
|
|---|
| 460 | if (adp4ilbuf == -1) {
|
|---|
| 461 | adp4ilbuf = adp4ibuf ;
|
|---|
| 462 | resetadlookstack_() ;
|
|---|
| 463 | }
|
|---|
| 464 | if (adp4ilbuf <= 0) {
|
|---|
| 465 | lookNarray((void *)adp4lbuf, 512*4) ;
|
|---|
| 466 | adp4inlbuf = 1 ;
|
|---|
| 467 | adp4ilbuf = 511 ;
|
|---|
| 468 | *x = adp4lbuf[511] ;
|
|---|
| 469 | } else {
|
|---|
| 470 | --adp4ilbuf ;
|
|---|
| 471 | if (adp4inlbuf)
|
|---|
| 472 | *x = adp4lbuf[adp4ilbuf] ;
|
|---|
| 473 | else
|
|---|
| 474 | *x = adp4buf[adp4ilbuf] ;
|
|---|
| 475 | }
|
|---|
| 476 | }
|
|---|
| 477 |
|
|---|
| 478 | void poppointer4(void **x) {
|
|---|
| 479 | if (adp4ilbuf != -1) {
|
|---|
| 480 | adp4ilbuf = -1 ;
|
|---|
| 481 | adp4inlbuf = 0 ;
|
|---|
| 482 | }
|
|---|
| 483 | if (adp4ibuf <= 0) {
|
|---|
| 484 | popNarray((void *)adp4buf, 512*4) ;
|
|---|
| 485 | adp4ibuf = 511 ;
|
|---|
| 486 | *x = adp4buf[511] ;
|
|---|
| 487 | } else {
|
|---|
| 488 | --adp4ibuf ;
|
|---|
| 489 | *x = adp4buf[adp4ibuf] ;
|
|---|
| 490 | }
|
|---|
| 491 | }
|
|---|
| 492 |
|
|---|
| 493 | /********************** POINTERS (new long 64 bits) *****************/
|
|---|
| 494 | static void *adp8buf[512] ;
|
|---|
| 495 | static int adp8ibuf = 0 ;
|
|---|
| 496 | static void *adp8lbuf[512] ;
|
|---|
| 497 | static int adp8ilbuf = -1 ;
|
|---|
| 498 | static int adp8inlbuf = 0 ;
|
|---|
| 499 |
|
|---|
| 500 | void pushpointer8(void *x) {
|
|---|
| 501 | addftraffic(8) ;
|
|---|
| 502 | if (adp8ilbuf != -1) {
|
|---|
| 503 | adp8ilbuf = -1 ;
|
|---|
| 504 | adp8inlbuf = 0 ;
|
|---|
| 505 | }
|
|---|
| 506 | if (adp8ibuf >= 511) {
|
|---|
| 507 | adp8buf[511] = x ;
|
|---|
| 508 | pushNarray((void *)adp8buf, 512*8) ;
|
|---|
| 509 | addftraffic(-512*8) ;
|
|---|
| 510 | adp8ibuf = 0 ;
|
|---|
| 511 | } else {
|
|---|
| 512 | adp8buf[adp8ibuf] = x ;
|
|---|
| 513 | ++adp8ibuf ;
|
|---|
| 514 | }
|
|---|
| 515 | }
|
|---|
| 516 |
|
|---|
| 517 | void lookpointer8(void **x) {
|
|---|
| 518 | if (adp8ilbuf == -1) {
|
|---|
| 519 | adp8ilbuf = adp8ibuf ;
|
|---|
| 520 | resetadlookstack_() ;
|
|---|
| 521 | }
|
|---|
| 522 | if (adp8ilbuf <= 0) {
|
|---|
| 523 | lookNarray((void *)adp8lbuf, 512*8) ;
|
|---|
| 524 | adp8inlbuf = 1 ;
|
|---|
| 525 | adp8ilbuf = 511 ;
|
|---|
| 526 | *x = adp8lbuf[511] ;
|
|---|
| 527 | } else {
|
|---|
| 528 | --adp8ilbuf ;
|
|---|
| 529 | if (adp8inlbuf)
|
|---|
| 530 | *x = adp8lbuf[adp8ilbuf] ;
|
|---|
| 531 | else
|
|---|
| 532 | *x = adp8buf[adp8ilbuf] ;
|
|---|
| 533 | }
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | void poppointer8(void **x) {
|
|---|
| 537 | if (adp8ilbuf != -1) {
|
|---|
| 538 | adp8ilbuf = -1 ;
|
|---|
| 539 | adp8inlbuf = 0 ;
|
|---|
| 540 | }
|
|---|
| 541 | if (adp8ibuf <= 0) {
|
|---|
| 542 | popNarray((void *)adp8buf, 512*8) ;
|
|---|
| 543 | adp8ibuf = 511 ;
|
|---|
| 544 | *x = adp8buf[511] ;
|
|---|
| 545 | } else {
|
|---|
| 546 | --adp8ibuf ;
|
|---|
| 547 | *x = adp8buf[adp8ibuf] ;
|
|---|
| 548 | }
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 | /********* PRINTING THE SIZE OF STACKS AND BUFFERS ********/
|
|---|
| 552 |
|
|---|
| 553 | /** Very complete display of the current size in bytes of
|
|---|
| 554 | * the global C stack followed by the auxiliary stacks.
|
|---|
| 555 | * Also shows the "looking" stack position if relevant,
|
|---|
| 556 | * and -999 if not relevant. */
|
|---|
| 557 | void printallbuffers() {
|
|---|
| 558 | int cblocks,csize,lookcblocks,lookcsize,lookbufsize ;
|
|---|
| 559 | getbigcsizes_(&cblocks,&csize,&lookcblocks,&lookcsize) ;
|
|---|
| 560 | printf("MAIN C stack size :%8iB +%5i bytes (looking:%8iB +%5i)\n",
|
|---|
| 561 | cblocks,csize,lookcblocks,lookcsize) ;
|
|---|
| 562 | lookbufsize = ((adi4inlbuf&&adi4ilbuf>=0)?adi4ilbuf*4:-999) ;
|
|---|
| 563 | printf(" plus INTs4 :%4i bytes (looking:%4i)\n", adi4ibuf*4, lookbufsize) ;
|
|---|
| 564 | lookbufsize = ((adr4inlbuf&&adr4ilbuf>=0)?adr4ilbuf*4:-999) ;
|
|---|
| 565 | printf(" plus REALs4 :%4i bytes (looking:%4i)\n", adr4ibuf*4, lookbufsize) ;
|
|---|
| 566 | lookbufsize = ((adr8inlbuf&&adr8ilbuf>=0)?adr8ilbuf*8:-999) ;
|
|---|
| 567 | printf(" plus REALs8 :%4i bytes (looking:%4i)\n", adr8ibuf*8, lookbufsize) ;
|
|---|
| 568 | lookbufsize = ((adp4inlbuf&&adp4ilbuf>=0)?adp4ilbuf*4:-999) ;
|
|---|
| 569 | printf(" plus POINTERs4:%4i bytes (looking:%4i)\n", adp4ibuf*4, lookbufsize) ;
|
|---|
| 570 | lookbufsize = ((adp8inlbuf&&adp8ilbuf>=0)?adp8ilbuf*8:-999) ;
|
|---|
| 571 | printf(" plus POINTERs8:%4i bytes (looking:%4i)\n", adp8ibuf*8, lookbufsize) ;
|
|---|
| 572 | }
|
|---|
| 573 |
|
|---|
| 574 | void printbuffertop() {
|
|---|
| 575 | int size = 0 ;
|
|---|
| 576 | size += adi4ibuf*4 ;
|
|---|
| 577 | size += adr4ibuf*4 ;
|
|---|
| 578 | size += adr8ibuf*8 ;
|
|---|
| 579 | size += adp4ibuf*4 ;
|
|---|
| 580 | size += adp8ibuf*8 ;
|
|---|
| 581 | size += ads1ibuf ;
|
|---|
| 582 | printf("Buffer size:%i bytes i.e. %f Kbytes\n",
|
|---|
| 583 | size, ((float)size)/1024.0) ;
|
|---|
| 584 | }
|
|---|
| 585 |
|
|---|
| 586 | void showallstacks() {
|
|---|
| 587 | int i ;
|
|---|
| 588 | printf("BIT STACK : %x == %i\n",adbitbuf,adbitbuf) ;
|
|---|
| 589 | printf("INTEGER*4 BUFFER[%i]:",adi4ibuf) ;
|
|---|
| 590 | for (i=0 ; i<adi4ibuf ; ++i) printf(" %i",adi4buf[i]) ;
|
|---|
| 591 | printf("\n") ;
|
|---|
| 592 | printf("REAL*8 BUFFER[%i]:",adr8ibuf) ;
|
|---|
| 593 | for (i=0 ; i<adr8ibuf ; ++i) printf(" %d",adr8buf[i]) ;
|
|---|
| 594 | printf("\n") ;
|
|---|
| 595 | printf("REAL*4 BUFFER[%i]:",adr4ibuf) ;
|
|---|
| 596 | for (i=0 ; i<adr4ibuf ; ++i) printf(" %f",adr4buf[i]) ;
|
|---|
| 597 | printf("\n") ;
|
|---|
| 598 | printf("POINTER*8 BUFFER[%i]:",adp8ibuf) ;
|
|---|
| 599 | for (i=0 ; i<adp8ibuf ; ++i) printf(" %x",adp8buf[i]) ;
|
|---|
| 600 | printf("\n") ;
|
|---|
| 601 | showrecentcstack_() ;
|
|---|
| 602 | }
|
|---|
| 603 |
|
|---|
| 604 | /**********************************************************
|
|---|
| 605 | * HOW TO CREATE PUSH* LOOK* POP* SUBROUTINES
|
|---|
| 606 | * YET FOR OTHER DATA TYPES
|
|---|
| 607 | * Duplicate and uncomment the commented code below.
|
|---|
| 608 | * In the duplicated and uncommented code, replace:
|
|---|
| 609 | * ctct -> C type name (e.g. float double, int...)
|
|---|
| 610 | * TTTT -> BASIC TAPENADE TYPE NAME
|
|---|
| 611 | * (in character, boolean, integer, real, complex, pointer,...)
|
|---|
| 612 | * z7 -> LETTER-SIZE FOR TYPE
|
|---|
| 613 | * (in s, b, i, r, c, p, ...)
|
|---|
| 614 | * 7 -> TYPE SIZE IN BYTES
|
|---|
| 615 | * Don't forget to insert the corresponding lines in
|
|---|
| 616 | * procedure printbuffertop(), otherwise the contribution of
|
|---|
| 617 | * this new type to buffer occupation will not be seen.
|
|---|
| 618 | * (not very important anyway...)
|
|---|
| 619 | **********************************************************/
|
|---|
| 620 |
|
|---|
| 621 | /************************** TTTT*7 ************************/
|
|---|
| 622 | /*
|
|---|
| 623 | static ctct adz7buf[512] ;
|
|---|
| 624 | static int adz7ibuf = 0 ;
|
|---|
| 625 | static ctct adz7lbuf[512] ;
|
|---|
| 626 | static int adz7ilbuf = -1 ;
|
|---|
| 627 | static int adz7inlbuf = 0 ;
|
|---|
| 628 |
|
|---|
| 629 | void pushTTTT7(ctct x) {
|
|---|
| 630 | addftraffic(7) ;
|
|---|
| 631 | if (adz7ilbuf != -1) {
|
|---|
| 632 | adz7ilbuf = -1 ;
|
|---|
| 633 | adz7inlbuf = 0 ;
|
|---|
| 634 | }
|
|---|
| 635 | if (adz7ibuf >= 511) {
|
|---|
| 636 | adz7buf[511] = x ;
|
|---|
| 637 | pushNarray((void *)adz7buf, 512*7) ;
|
|---|
| 638 | addftraffic(-512*7) ;
|
|---|
| 639 | adz7ibuf = 0 ;
|
|---|
| 640 | } else {
|
|---|
| 641 | adz7buf[adz7ibuf] = x ;
|
|---|
| 642 | ++adz7ibuf ;
|
|---|
| 643 | }
|
|---|
| 644 | }
|
|---|
| 645 |
|
|---|
| 646 | void lookTTTT7(ctct *x) {
|
|---|
| 647 | if (adz7ilbuf == -1) {
|
|---|
| 648 | adz7ilbuf = adz7ibuf ;
|
|---|
| 649 | resetadlookstack_() ;
|
|---|
| 650 | }
|
|---|
| 651 | if (adz7ilbuf <= 0) {
|
|---|
| 652 | lookNarray((void *)adz7lbuf, 512*7) ;
|
|---|
| 653 | adz7inlbuf = 1 ;
|
|---|
| 654 | adz7ilbuf = 511 ;
|
|---|
| 655 | *x = adz7lbuf[511] ;
|
|---|
| 656 | } else {
|
|---|
| 657 | --adz7ilbuf ;
|
|---|
| 658 | if (adz7inlbuf)
|
|---|
| 659 | *x = adz7lbuf[adz7ilbuf] ;
|
|---|
| 660 | else
|
|---|
| 661 | *x = adz7buf[adz7ilbuf] ;
|
|---|
| 662 | }
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|
| 665 | void popTTTT7(ctct *x) {
|
|---|
| 666 | if (adz7ilbuf != -1) {
|
|---|
| 667 | adz7ilbuf = -1 ;
|
|---|
| 668 | adz7inlbuf = 0 ;
|
|---|
| 669 | }
|
|---|
| 670 | if (adz7ibuf <= 0) {
|
|---|
| 671 | popNarray((void *)adz7buf, 512*7) ;
|
|---|
| 672 | adz7ibuf = 511 ;
|
|---|
| 673 | *x = adz7buf[511] ;
|
|---|
| 674 | } else {
|
|---|
| 675 | --adz7ibuf ;
|
|---|
| 676 | *x = adz7buf[adz7ibuf] ;
|
|---|
| 677 | }
|
|---|
| 678 | }
|
|---|
| 679 | */
|
|---|
| 680 |
|
|---|
| 681 | /**********************************************************/
|
|---|