diff options
author | downsj <> | 1996-08-20 17:30:49 +0000 |
---|---|---|
committer | downsj <> | 1996-08-20 17:30:49 +0000 |
commit | 566fa275649c9583a8062bb3ae131477a80cd306 (patch) | |
tree | 02ad7190839c5f41bd815346b79cb505ac707405 /src | |
parent | 31648f1b070719b9bd7faecf2a0a4637777029b3 (diff) | |
download | openbsd-566fa275649c9583a8062bb3ae131477a80cd306.tar.gz openbsd-566fa275649c9583a8062bb3ae131477a80cd306.tar.bz2 openbsd-566fa275649c9583a8062bb3ae131477a80cd306.zip |
Remove ANSI function delcarations and add a cfree() stub function.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libc/stdlib/malloc.c | 89 |
1 files changed, 67 insertions, 22 deletions
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c index 66da09ff31..47059a8388 100644 --- a/src/lib/libc/stdlib/malloc.c +++ b/src/lib/libc/stdlib/malloc.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #if defined(LIBC_SCCS) && !defined(lint) | 10 | #if defined(LIBC_SCCS) && !defined(lint) |
11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.5 1996/08/19 08:33:37 tholo Exp $"; | 11 | static char rcsid[] = "$OpenBSD: malloc.c,v 1.6 1996/08/20 17:30:49 downsj Exp $"; |
12 | #endif /* LIBC_SCCS and not lint */ | 12 | #endif /* LIBC_SCCS and not lint */ |
13 | 13 | ||
14 | /* | 14 | /* |
@@ -24,6 +24,11 @@ static char rcsid[] = "$OpenBSD: malloc.c,v 1.5 1996/08/19 08:33:37 tholo Exp $" | |||
24 | */ | 24 | */ |
25 | #define MALLOC_STATS | 25 | #define MALLOC_STATS |
26 | 26 | ||
27 | /* | ||
28 | * Defining CFREE_STUB will include a cfree() stub that just calls free(). | ||
29 | */ | ||
30 | #define CFREE_STUB | ||
31 | |||
27 | #if defined(EXTRA_SANITY) && !defined(MALLOC_STATS) | 32 | #if defined(EXTRA_SANITY) && !defined(MALLOC_STATS) |
28 | # define MALLOC_STATS /* required for EXTRA_SANITY */ | 33 | # define MALLOC_STATS /* required for EXTRA_SANITY */ |
29 | #endif | 34 | #endif |
@@ -111,7 +116,8 @@ struct pgfree { | |||
111 | #ifdef __i386__ | 116 | #ifdef __i386__ |
112 | #define ffs _ffs | 117 | #define ffs _ffs |
113 | static __inline int | 118 | static __inline int |
114 | _ffs(unsigned input) | 119 | _ffs(input) |
120 | unsigned input; | ||
115 | { | 121 | { |
116 | int result; | 122 | int result; |
117 | asm("bsfl %1,%0" : "=r" (result) : "r" (input)); | 123 | asm("bsfl %1,%0" : "=r" (result) : "r" (input)); |
@@ -120,7 +126,8 @@ _ffs(unsigned input) | |||
120 | 126 | ||
121 | #define fls _fls | 127 | #define fls _fls |
122 | static __inline int | 128 | static __inline int |
123 | _fls(unsigned input) | 129 | _fls(input) |
130 | unsigned input; | ||
124 | { | 131 | { |
125 | int result; | 132 | int result; |
126 | asm("bsrl %1,%0" : "=r" (result) : "r" (input)); | 133 | asm("bsrl %1,%0" : "=r" (result) : "r" (input)); |
@@ -129,7 +136,9 @@ _fls(unsigned input) | |||
129 | 136 | ||
130 | #define set_bit _set_bit | 137 | #define set_bit _set_bit |
131 | static __inline void | 138 | static __inline void |
132 | _set_bit(struct pginfo *pi, int bit) | 139 | _set_bit(pi, bit) |
140 | struct pginfo *pi; | ||
141 | int bit; | ||
133 | { | 142 | { |
134 | asm("btsl %0,(%1)" : | 143 | asm("btsl %0,(%1)" : |
135 | : "r" (bit & (MALLOC_BITS-1)), "r" (pi->bits+(bit/MALLOC_BITS))); | 144 | : "r" (bit & (MALLOC_BITS-1)), "r" (pi->bits+(bit/MALLOC_BITS))); |
@@ -137,7 +146,9 @@ _set_bit(struct pginfo *pi, int bit) | |||
137 | 146 | ||
138 | #define clr_bit _clr_bit | 147 | #define clr_bit _clr_bit |
139 | static __inline void | 148 | static __inline void |
140 | _clr_bit(struct pginfo *pi, int bit) | 149 | _clr_bit(pi, bit) |
150 | struct pginfo *pi; | ||
151 | int bit; | ||
141 | { | 152 | { |
142 | asm("btcl %0,(%1)" : | 153 | asm("btcl %0,(%1)" : |
143 | : "r" (bit & (MALLOC_BITS-1)), "r" (pi->bits+(bit/MALLOC_BITS))); | 154 | : "r" (bit & (MALLOC_BITS-1)), "r" (pi->bits+(bit/MALLOC_BITS))); |
@@ -273,7 +284,8 @@ static int extend_pgdir(u_long index); | |||
273 | 284 | ||
274 | #ifdef MALLOC_STATS | 285 | #ifdef MALLOC_STATS |
275 | void | 286 | void |
276 | malloc_dump(FILE *fd) | 287 | malloc_dump(fd) |
288 | FILE *fd; | ||
277 | { | 289 | { |
278 | struct pginfo **pd; | 290 | struct pginfo **pd; |
279 | struct pgfree *pf; | 291 | struct pgfree *pf; |
@@ -330,7 +342,8 @@ malloc_dump(FILE *fd) | |||
330 | #endif /* MALLOC_STATS */ | 342 | #endif /* MALLOC_STATS */ |
331 | 343 | ||
332 | static void | 344 | static void |
333 | wrterror(char *p) | 345 | wrterror(p) |
346 | char *p; | ||
334 | { | 347 | { |
335 | char *q = "Malloc error: "; | 348 | char *q = "Malloc error: "; |
336 | suicide = 1; | 349 | suicide = 1; |
@@ -344,7 +357,8 @@ wrterror(char *p) | |||
344 | } | 357 | } |
345 | 358 | ||
346 | static void | 359 | static void |
347 | wrtwarning(char *p) | 360 | wrtwarning(p) |
361 | char *p; | ||
348 | { | 362 | { |
349 | char *q = "Malloc warning: "; | 363 | char *q = "Malloc warning: "; |
350 | if (malloc_abort) | 364 | if (malloc_abort) |
@@ -372,7 +386,8 @@ malloc_exit() | |||
372 | * Allocate a number of pages from the OS | 386 | * Allocate a number of pages from the OS |
373 | */ | 387 | */ |
374 | static caddr_t | 388 | static caddr_t |
375 | map_pages(int pages) | 389 | map_pages(pages) |
390 | int pages; | ||
376 | { | 391 | { |
377 | caddr_t result,tail; | 392 | caddr_t result,tail; |
378 | 393 | ||
@@ -400,7 +415,9 @@ map_pages(int pages) | |||
400 | */ | 415 | */ |
401 | #ifndef set_bit | 416 | #ifndef set_bit |
402 | static __inline void | 417 | static __inline void |
403 | set_bit(struct pginfo *pi, int bit) | 418 | set_bit(pi, bit) |
419 | struct pginfo *pi; | ||
420 | int bit; | ||
404 | { | 421 | { |
405 | pi->bits[bit/MALLOC_BITS] |= 1<<(bit%MALLOC_BITS); | 422 | pi->bits[bit/MALLOC_BITS] |= 1<<(bit%MALLOC_BITS); |
406 | } | 423 | } |
@@ -411,7 +428,9 @@ set_bit(struct pginfo *pi, int bit) | |||
411 | */ | 428 | */ |
412 | #ifndef clr_bit | 429 | #ifndef clr_bit |
413 | static __inline void | 430 | static __inline void |
414 | clr_bit(struct pginfo *pi, int bit) | 431 | clr_bit(pi, bit) |
432 | struct pginfo *pi; | ||
433 | int bit; | ||
415 | { | 434 | { |
416 | pi->bits[bit/MALLOC_BITS] &= ~(1<<(bit%MALLOC_BITS)); | 435 | pi->bits[bit/MALLOC_BITS] &= ~(1<<(bit%MALLOC_BITS)); |
417 | } | 436 | } |
@@ -422,7 +441,9 @@ clr_bit(struct pginfo *pi, int bit) | |||
422 | * Test a bit in the bitmap | 441 | * Test a bit in the bitmap |
423 | */ | 442 | */ |
424 | static __inline int | 443 | static __inline int |
425 | tst_bit(struct pginfo *pi, int bit) | 444 | tst_bit(pi, bit) |
445 | struct pginfo *pi; | ||
446 | int bit; | ||
426 | { | 447 | { |
427 | return pi->bits[bit/MALLOC_BITS] & (1<<(bit%MALLOC_BITS)); | 448 | return pi->bits[bit/MALLOC_BITS] & (1<<(bit%MALLOC_BITS)); |
428 | } | 449 | } |
@@ -433,7 +454,8 @@ tst_bit(struct pginfo *pi, int bit) | |||
433 | */ | 454 | */ |
434 | #ifndef fls | 455 | #ifndef fls |
435 | static __inline int | 456 | static __inline int |
436 | fls(int size) | 457 | fls(size) |
458 | int size; | ||
437 | { | 459 | { |
438 | int i = 1; | 460 | int i = 1; |
439 | while (size >>= 1) | 461 | while (size >>= 1) |
@@ -446,7 +468,8 @@ fls(int size) | |||
446 | * Extend page directory | 468 | * Extend page directory |
447 | */ | 469 | */ |
448 | static int | 470 | static int |
449 | extend_pgdir(u_long index) | 471 | extend_pgdir(index) |
472 | u_long index; | ||
450 | { | 473 | { |
451 | struct pginfo **new,**old; | 474 | struct pginfo **new,**old; |
452 | int i, oldlen; | 475 | int i, oldlen; |
@@ -617,7 +640,8 @@ malloc_init () | |||
617 | * Allocate a number of complete pages | 640 | * Allocate a number of complete pages |
618 | */ | 641 | */ |
619 | void * | 642 | void * |
620 | malloc_pages(size_t size) | 643 | malloc_pages(size) |
644 | size_t size; | ||
621 | { | 645 | { |
622 | void *p,*delay_free = 0; | 646 | void *p,*delay_free = 0; |
623 | int i; | 647 | int i; |
@@ -702,7 +726,8 @@ malloc_pages(size_t size) | |||
702 | */ | 726 | */ |
703 | 727 | ||
704 | static __inline int | 728 | static __inline int |
705 | malloc_make_chunks(int bits) | 729 | malloc_make_chunks(bits) |
730 | int bits; | ||
706 | { | 731 | { |
707 | struct pginfo *bp; | 732 | struct pginfo *bp; |
708 | void *pp; | 733 | void *pp; |
@@ -765,7 +790,8 @@ malloc_make_chunks(int bits) | |||
765 | * Allocate a fragment | 790 | * Allocate a fragment |
766 | */ | 791 | */ |
767 | static void * | 792 | static void * |
768 | malloc_bytes(size_t size) | 793 | malloc_bytes(size) |
794 | size_t size; | ||
769 | { | 795 | { |
770 | int j; | 796 | int j; |
771 | struct pginfo *bp; | 797 | struct pginfo *bp; |
@@ -813,7 +839,8 @@ malloc_bytes(size_t size) | |||
813 | * Allocate a piece of memory | 839 | * Allocate a piece of memory |
814 | */ | 840 | */ |
815 | void * | 841 | void * |
816 | malloc(size_t size) | 842 | malloc(size) |
843 | size_t size; | ||
817 | { | 844 | { |
818 | void *result; | 845 | void *result; |
819 | #ifdef _THREAD_SAFE | 846 | #ifdef _THREAD_SAFE |
@@ -850,7 +877,9 @@ malloc(size_t size) | |||
850 | * Change the size of an allocation. | 877 | * Change the size of an allocation. |
851 | */ | 878 | */ |
852 | void * | 879 | void * |
853 | realloc(void *ptr, size_t size) | 880 | realloc(ptr, size) |
881 | void *ptr; | ||
882 | size_t size; | ||
854 | { | 883 | { |
855 | void *p; | 884 | void *p; |
856 | u_long osize,index; | 885 | u_long osize,index; |
@@ -987,7 +1016,10 @@ realloc(void *ptr, size_t size) | |||
987 | */ | 1016 | */ |
988 | 1017 | ||
989 | static __inline void | 1018 | static __inline void |
990 | free_pages(void *ptr, int index, struct pginfo *info) | 1019 | free_pages(ptr, index, info) |
1020 | void *ptr; | ||
1021 | int index; | ||
1022 | struct pginfo *info; | ||
991 | { | 1023 | { |
992 | int i; | 1024 | int i; |
993 | struct pgfree *pf,*pt; | 1025 | struct pgfree *pf,*pt; |
@@ -1110,7 +1142,10 @@ free_pages(void *ptr, int index, struct pginfo *info) | |||
1110 | */ | 1142 | */ |
1111 | 1143 | ||
1112 | static __inline void | 1144 | static __inline void |
1113 | free_bytes(void *ptr, int index, struct pginfo *info) | 1145 | free_bytes(ptr, index, info) |
1146 | void *ptr; | ||
1147 | int index; | ||
1148 | struct pginfo *info; | ||
1114 | { | 1149 | { |
1115 | int i; | 1150 | int i; |
1116 | struct pginfo **mp; | 1151 | struct pginfo **mp; |
@@ -1169,7 +1204,8 @@ free_bytes(void *ptr, int index, struct pginfo *info) | |||
1169 | } | 1204 | } |
1170 | 1205 | ||
1171 | void | 1206 | void |
1172 | free(void *ptr) | 1207 | free(ptr) |
1208 | void *ptr; | ||
1173 | { | 1209 | { |
1174 | struct pginfo *info; | 1210 | struct pginfo *info; |
1175 | int index; | 1211 | int index; |
@@ -1222,3 +1258,12 @@ free(void *ptr) | |||
1222 | #endif | 1258 | #endif |
1223 | return; | 1259 | return; |
1224 | } | 1260 | } |
1261 | |||
1262 | #ifdef CFREE_STUB | ||
1263 | void | ||
1264 | cfree(ptr) | ||
1265 | void *ptr; | ||
1266 | { | ||
1267 | free(ptr); | ||
1268 | } | ||
1269 | #endif | ||