1 /***** tl_spin: tl_mem.c *****/
4 * This file is part of the public release of Spin. It is subject to the
5 * terms in the LICENSE file that is included in this source directory.
6 * Tool documentation is available at http://spinroot.com
8 * Based on the translation algorithm by Gerth, Peled, Vardi, and Wolper,
9 * presented at the PSTV Conference, held in 1995, Warsaw, Poland 1995.
15 #define log(e, u, d) event[e][(int) u] += (long) d;
21 #define A_USER 0x55000000
22 #define NOTOOBIG 32768
29 extern unsigned long All_Mem;
30 extern int tl_verbose;
37 static union M *freelist[A_LARGE];
38 static long req[A_LARGE];
39 static long event[NREVENT][A_LARGE];
47 u = (long) ((U-1)/sizeof(union M) + 2);
52 printf("tl_spin: memalloc %ld bytes\n", u);
53 m = (union M *) emalloc((int) u*sizeof(union M));
54 All_Mem += (unsigned long) u*sizeof(union M);
57 { r = req[u] += req[u] ? req[u] : 1;
59 r = req[u] = NOTOOBIG;
61 freelist[u] = (union M *)
62 emalloc((int) r*u*sizeof(union M));
63 All_Mem += (unsigned long) r*u*sizeof(union M);
64 m = freelist[u] + (r-2)*u;
65 for ( ; m >= freelist[u]; m -= u)
70 freelist[u] = m->link;
84 { union M *m = (union M *) v;
88 if ((m->size&0xFF000000) != A_USER)
89 Fatal("releasing a free block", (char *)0);
91 u = (m->size &= 0xFFFFFF);
97 m->link = freelist[u];
107 printf(" size\t pool\tallocs\t frees\n");
108 for (i = 0; i < A_LARGE; i++)
109 { p = event[POOL][i];
114 printf("%5d\t%6ld\t%6ld\t%6ld\n",