]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * $Source$ | |
3 | * $Author$ | |
4 | * $Header$ | |
5 | * | |
6 | * Copyright (C) 1987 by the Massachusetts Institute of Technology | |
7 | * For copying and distribution information, please see the file | |
8 | * <mit-copyright.h>. | |
9 | * | |
10 | * This code is a reverse-engineered version of | |
11 | * ~rtingres/lib/compatlib(meinitlst.o) with a better malloc and | |
12 | * free. It only works with Ingres version 5 on the vax. | |
13 | */ | |
14 | ||
15 | #ifndef lint | |
16 | static char *rcsid_meinitlst_c = "$Header$"; | |
17 | #endif lint | |
18 | ||
19 | #include <mit-copyright.h> | |
20 | #include <sys/errno.h> | |
21 | #include <sys/types.h> | |
22 | #include <moira_site.h> | |
23 | ||
24 | #if INGRESVER == 5 && defined(vax) | |
25 | ||
26 | /* | |
27 | * entry points: | |
28 | * MEinitLists() | |
29 | * calloc() | |
30 | * free() | |
31 | * malloc() | |
32 | * memalign() | |
33 | * realloc() | |
34 | * valloc() | |
35 | */ | |
36 | ||
37 | struct cons { | |
38 | char *car; | |
39 | char *cdr; | |
40 | }; | |
41 | extern int Status; | |
42 | extern char MEsetup; | |
43 | extern struct cons MElist, MEfreelist; | |
44 | extern short ME_pid; | |
45 | extern char *MElistHead, *MEfreeHead; | |
46 | ||
47 | MEinitLists() | |
48 | { | |
49 | Status = 0; | |
50 | MEsetup = 1; | |
51 | MElist.car = 0; | |
52 | MElist.cdr = MElistHead; | |
53 | MEfreelist.car = 0; | |
54 | MEfreelist.cdr = MEfreeHead; | |
55 | ME_pid = getpid() & 0x7fff; | |
56 | return 0; | |
57 | } | |
58 | #ifdef notdef | |
59 | free(addr) | |
60 | { | |
61 | return MEfree(addr); | |
62 | } | |
63 | ||
64 | caddr_t malloc(size) | |
65 | u_int size; | |
66 | { | |
67 | char *temp; | |
68 | if(MEalloc(1, size, &temp)) return 0; | |
69 | else return temp; | |
70 | } | |
71 | ||
72 | caddr_t calloc(a1, a2) | |
73 | int a1, a2; | |
74 | { | |
75 | char *temp; | |
76 | if (MEcalloc(a1, a2, &temp)) return 0; | |
77 | else return temp; | |
78 | } | |
79 | ||
80 | caddr_t realloc(adr, nsize) | |
81 | char *adr; | |
82 | u_int nsize; | |
83 | { | |
84 | char *new_addr; | |
85 | u_int cur_size; | |
86 | if (MEsize(adr, &cur_size)) return 0; | |
87 | if (cur_size >= nsize) return adr; | |
88 | if ( (new_addr = malloc(nsize)) == 0) return 0; | |
89 | (void) MEcopy(adr, cur_size, new_addr); | |
90 | (void) free(adr); | |
91 | return new_addr; | |
92 | } | |
93 | ||
94 | valloc(size) | |
95 | int size; | |
96 | { | |
97 | static int pagesize; | |
98 | if (pagesize == 0) pagesize = getpagesize(); | |
99 | return memalign(pagesize, size); | |
100 | } | |
101 | ||
102 | memalign(alignment, size) | |
103 | { | |
104 | int temp1; | |
105 | int temp2; | |
106 | int temp3; | |
107 | int temp4; | |
108 | if (!size || alignment & 1) { | |
109 | errno = EINVAL; | |
110 | return 0; | |
111 | } | |
112 | if (alignment < 4) alignment = 4; | |
113 | ||
114 | /* | |
115 | _memalign: fc0 | |
116 | _memalign+2: subl2 $10,sp | |
117 | _memalign+5: tstl 8(ap) | |
118 | _memalign+8: beql _memalign+e | |
119 | _memalign+a: blbc 4(ap),_memalign+18 | |
120 | >_memalign+e: movl $16,_errno | |
121 | >_memalign+15: clrf r0 | |
122 | _memalign+17: ret | |
123 | >_memalign+18: cmpl 4(ap),$4 | |
124 | _memalign+1c: bgequ _memalign+22 | |
125 | _memalign+1e: movl $4,4(ap) | |
126 | >_memalign+22: pushl $4 | |
127 | _memalign+24: addl3 $3,8(ap),-(sp) | |
128 | _memalign+29: calls $2,udiv | |
129 | _memalign+30: ashl $2,r0,8(ap) | |
130 | _memalign+35: addl3 4(ap),8(ap),r0 | |
131 | _memalign+3b: addl3 $20,r0,-4(fp) | |
132 | _memalign+40: pushl -4(fp) | |
133 | _memalign+43: calls $1,_malloc | |
134 | _memalign+4a: movl r0,r11 | |
135 | _memalign+4d: beql _memalign+15 | |
136 | _memalign+4f: subl3 $10,r11,r10 | |
137 | _memalign+53: ashl $0,4(r10),r8 | |
138 | _memalign+58: pushl 4(ap) | |
139 | _memalign+5b: subl3 $1,4(ap),r0 | |
140 | _memalign+60: addl3 r11,r0,-(sp) | |
141 | _memalign+64: calls $2,udiv | |
142 | _memalign+6b: mull3 4(ap),r0,-c(fp) | |
143 | _memalign+71: movl -c(fp),r7 | |
144 | _memalign+75: subl3 $10,r7,r6 | |
145 | _memalign+79: subl3 r10,r6,-8(fp) | |
146 | _memalign+7e: subl2 -8(fp),r8 | |
147 | _memalign+82: cmpl -8(fp),$10 | |
148 | _memalign+86: bgequ _memalign+a7 | |
149 | _memalign+88: pushl 8(ap) | |
150 | _memalign+8b: pushl 4(ap) | |
151 | _memalign+8e: calls $2,_memalign | |
152 | _memalign+95: movl r0,-10(fp) | |
153 | _memalign+99: pushl r11 | |
154 | _memalign+9b: calls $1,_free | |
155 | _memalign+a2: movl -10(fp),r0 | |
156 | _memalign+a6: ret | |
157 | >_memalign+a7: movl -8(fp),r0 | |
158 | _memalign+ab: extzv $0,$20,r0,4(r10) | |
159 | _memalign+b1: extzv $0,$20,r8,4(r6) | |
160 | _memalign+b7: movl (r10),(r6) | |
161 | _memalign+ba: movw 8(r10),8(r6) | |
162 | _memalign+bf: movl r6,_MElist | |
163 | _memalign+c6: cmpl _MElist+4,r10 | |
164 | _memalign+cd: bneq _memalign+d6 | |
165 | _memalign+cf: movl r6,_MElist+4 | |
166 | >_memalign+d6: pushl r10 | |
167 | _memalign+d8: calls $1,_MEf_add | |
168 | _memalign+df: addl3 $10,r6,r0 | |
169 | _memalign+e3: ret | |
170 | */ | |
171 | #endif notdef | |
172 | #endif /* INGRESVER == 5 && defined(vax) */ |