From 97b9e901b2718c216129d228c41970a3f4692a74 Mon Sep 17 00:00:00 2001 From: Erwin Janssen Date: Wed, 14 Sep 2016 17:16:24 +0200 Subject: [PATCH] Removed old-style function defintions from vmalloc The functions definitions in vmalloc are all surrounded by an `#if __STD_C`, if __STD_C is not defined than the old style function definition is used. These days STD C is the standard and the old style function defintions are obsolete. They have been removed from lib/vmalloc and its subprojects, comments have been preserved by converting them to a Doxygen style. --- lib/vmalloc/malloc.c | 85 ++------------------------- lib/vmalloc/vmbest.c | 127 ++++++++++------------------------------ lib/vmalloc/vmclear.c | 5 -- lib/vmalloc/vmclose.c | 5 -- lib/vmalloc/vmdcheap.c | 16 +++-- lib/vmalloc/vmdebug.c | 113 ++++++++--------------------------- lib/vmalloc/vmdisc.c | 6 -- lib/vmalloc/vmexit.c | 15 ----- lib/vmalloc/vmlast.c | 44 -------------- lib/vmalloc/vmopen.c | 12 ++-- lib/vmalloc/vmpool.c | 44 -------------- lib/vmalloc/vmprivate.c | 32 +++++----- lib/vmalloc/vmprofile.c | 92 ++--------------------------- lib/vmalloc/vmregion.c | 5 -- lib/vmalloc/vmsegment.c | 10 ++-- lib/vmalloc/vmset.c | 12 ++-- lib/vmalloc/vmstat.c | 6 -- lib/vmalloc/vmtrace.c | 48 +++++---------- lib/vmalloc/vmwalk.c | 6 -- 19 files changed, 114 insertions(+), 569 deletions(-) diff --git a/lib/vmalloc/malloc.c b/lib/vmalloc/malloc.c index 018e569df..d535d66b3 100644 --- a/lib/vmalloc/malloc.c +++ b/lib/vmalloc/malloc.c @@ -55,12 +55,7 @@ int _STUB_malloc; #undef memalign #undef valloc -#if __STD_C static Vmulong_t atou(char **sp) -#else -static Vmulong_t atou(sp) -char **sp; -#endif { char *s = *sp; Vmulong_t v = 0; @@ -100,13 +95,7 @@ static int _Vmpffd = -1; vmdbcheck(Vmregion); \ } -#if __STD_C static char *insertpid(char *begs, char *ends) -#else -static char *insertpid(begs, ends) -char *begs; -char *ends; -#endif { int pid; char *s; @@ -126,12 +115,7 @@ char *ends; return begs; } -#if __STD_C static int createfile(char *file) -#else -static int createfile(file) -char *file; -#endif { char buf[1024]; char *next, *endb; @@ -166,21 +150,13 @@ char *file; #endif } -#if __STD_C static void pfprint(void) -#else -static void pfprint() -#endif { if (Vmregion->meth.meth == VM_MTPROFILE) vmprofile(Vmregion, _Vmpffd); } -#if __STD_C static int vmflinit(void) -#else -static int vmflinit() -#endif { char *env; Vmalloc_t *vm; @@ -268,83 +244,49 @@ static int vmflinit() return 0; } -#if __STD_C Void_t *malloc(reg size_t size) -#else -Void_t *malloc(size) -reg size_t size; -#endif { VMFLINIT(); return (*Vmregion->meth.allocf) (Vmregion, size); } -#if __STD_C +/** + * @param data block to be reallocated + * @param size new size + */ Void_t *realloc(reg Void_t * data, reg size_t size) -#else -Void_t *realloc(data, size) -reg Void_t *data; /* block to be reallocated */ -reg size_t size; /* new size */ -#endif { VMFLINIT(); return (*Vmregion->meth.resizef) (Vmregion, data, size, VM_RSCOPY | VM_RSMOVE); } -#if __STD_C void free(reg Void_t * data) -#else -void free(data) -reg Void_t *data; -#endif { VMFLINIT(); (void) (*Vmregion->meth.freef) (Vmregion, data); } -#if __STD_C Void_t *calloc(reg size_t n_obj, reg size_t s_obj) -#else -Void_t *calloc(n_obj, s_obj) -reg size_t n_obj; -reg size_t s_obj; -#endif { VMFLINIT(); return (*Vmregion->meth.resizef) (Vmregion, NIL(Void_t *), n_obj * s_obj, VM_RSZERO); } -#if __STD_C void cfree(reg Void_t * data) -#else -void cfree(data) -reg Void_t *data; -#endif { VMFLINIT(); (void) (*Vmregion->meth.freef) (Vmregion, data); } -#if __STD_C Void_t *memalign(reg size_t align, reg size_t size) -#else -Void_t *memalign(align, size) -reg size_t align; -reg size_t size; -#endif { VMFLINIT(); return (*Vmregion->meth.alignf) (Vmregion, size, align); } -#if __STD_C Void_t *valloc(reg size_t size) -#else -Void_t *valloc(size) -reg size_t size; -#endif { VMFLINIT(); GETPAGESIZE(_Vmpagesize); @@ -364,13 +306,7 @@ reg size_t size; #undef alloca #if _lib_mallopt -#if __STD_C int mallopt(int cmd, int value) -#else -int mallopt(cmd, value) -int cmd; -int value; -#endif { VMFLINIT(); return 0; @@ -378,11 +314,7 @@ int value; #endif #if _lib_mallinfo -#if __STD_C struct mallinfo mallinfo(void) -#else -struct mallinfo mallinfo() -#endif { Vmstat_t sb; struct mallinfo mi; @@ -400,11 +332,7 @@ struct mallinfo mallinfo() #endif #if _lib_mstats -#if __STD_C struct mstats mstats(void) -#else -struct mstats mstats() -#endif { Vmstat_t sb; struct mstats ms; @@ -441,12 +369,7 @@ struct _alloca_s { Vmuchar_t data[1]; }; -#if __STD_C Void_t *alloca(size_t size) -#else -Void_t *alloca(size) -size_t size; -#endif { char array[ALIGN]; char *file; diff --git a/lib/vmalloc/vmbest.c b/lib/vmalloc/vmbest.c index 608a71319..7cff84123 100644 --- a/lib/vmalloc/vmbest.c +++ b/lib/vmalloc/vmbest.c @@ -43,13 +43,7 @@ static size_t S_junk; /* total junk space */ static int Vmcheck = 0; /* 1 if checking */ /* Check to see if a block is in the free tree */ -#if __STD_C static int vmintree(Block_t * node, Block_t * b) -#else -static int vmintree(node, b) -Block_t *node; -Block_t *b; -#endif { Block_t *t; @@ -64,13 +58,7 @@ Block_t *b; } /* Check to see if a block is known to be free */ -#if __STD_C static int vmisfree(Vmdata_t * vd, Block_t * b) -#else -static int vmisfree(vd, b) -Vmdata_t *vd; -Block_t *b; -#endif { Block_t *t; size_t s; @@ -88,12 +76,7 @@ Block_t *b; } /* check to see if the tree is in good shape */ -#if __STD_C static int vmchktree(Block_t * node) -#else -static int vmchktree(node) -Block_t *node; -#endif { Block_t *t; @@ -114,13 +97,7 @@ Block_t *node; return 1; } -#if __STD_C static int vmonlist(Block_t * list, Block_t * b) -#else -static int vmonlist(list, b) -Block_t *list; -Block_t *b; -#endif { for (; list; list = LINK(list)) if (list == b) @@ -128,14 +105,12 @@ Block_t *b; return 0; } -#if __STD_C +/** + * @param vd + * @param size if > 0, checking that no large free block >size + * @param wild if != 0, do above but allow wild to be >size + */ static int vmcheck(Vmdata_t * vd, size_t size, int wild) -#else -static int vmcheck(vd, size, wild) -Vmdata_t *vd; -size_t size; /* if > 0, checking that no large free block >size */ -int wild; /* if != 0, do above but allow wild to be >size */ -#endif { reg Seg_t *seg; reg Block_t *b, *endb, *t, *np; @@ -226,15 +201,8 @@ int wild; /* if != 0, do above but allow wild to be >size */ #define RLINK(s,x) ((s) = LEFT(s) = (x)) #define LLINK(s,x) ((s) = RIGHT(s) = (x)) /* Find and delete a suitable element in the free tree. */ -#if __STD_C static Block_t *bestsearch(Vmdata_t * vd, reg size_t size, Block_t * wanted) -#else -static Block_t *bestsearch(vd, size, wanted) -Vmdata_t *vd; -reg size_t size; -Block_t *wanted; -#endif { reg size_t s; reg Block_t *t, *root, *l, *r; @@ -339,14 +307,7 @@ Block_t *wanted; } /* Reclaim all delayed free blocks into the free tree */ -#if __STD_C static int bestreclaim(reg Vmdata_t * vd, Block_t * wanted, int c) -#else -static int bestreclaim(vd, wanted, c) -reg Vmdata_t *vd; -Block_t *wanted; -int c; -#endif { reg size_t size, s; reg Block_t *fp, *np, *t, *list, **cache; @@ -520,13 +481,11 @@ int c; return count; } -#if __STD_C +/** + * @param vm region allocating from + * @param size desired block size + */ static Void_t *bestalloc(Vmalloc_t * vm, reg size_t size) -#else -static Void_t *bestalloc(vm, size) -Vmalloc_t *vm; /* region allocating from */ -reg size_t size; /* desired block size */ -#endif { reg Vmdata_t *vd = vm->data; reg size_t s; @@ -664,13 +623,11 @@ reg size_t size; /* desired block size */ return DATA(tp); } -#if __STD_C +/** + * @param vm region allocating from + * @param addr address to check + */ static long bestaddr(Vmalloc_t * vm, Void_t * addr) -#else -static long bestaddr(vm, addr) -Vmalloc_t *vm; /* region allocating from */ -Void_t *addr; /* address to check */ -#endif { reg Seg_t *seg; reg Block_t *b, *endb; @@ -725,13 +682,7 @@ Void_t *addr; /* address to check */ return offset; } -#if __STD_C static int bestfree(Vmalloc_t * vm, Void_t * data) -#else -static int bestfree(vm, data) -Vmalloc_t *vm; -Void_t *data; -#endif { reg Vmdata_t *vd = vm->data; reg Block_t *bp, **cache; @@ -781,16 +732,14 @@ Void_t *data; return 0; } -#if __STD_C +/** + * @param vm region allocation from + * @param data old block of data + * @param size new size + * @param type !=0 to move, <0 for not copy + */ static Void_t *bestresize(Vmalloc_t * vm, Void_t * data, reg size_t size, int type) -#else -static Void_t *bestresize(vm, data, size, type) -Vmalloc_t *vm; /* region allocating from */ -Void_t *data; /* old block of data */ -reg size_t size; /* new size */ -int type; /* !=0 to move, <0 for not copy */ -#endif { reg Vmdata_t *vd = vm->data; reg Block_t *rp, *np, *t, **cache; @@ -932,13 +881,11 @@ int type; /* !=0 to move, <0 for not copy */ return data; } -#if __STD_C +/** + * @param vm region allocating from + * @param addr address to check + */ static long bestsize(Vmalloc_t * vm, Void_t * addr) -#else -static long bestsize(vm, addr) -Vmalloc_t *vm; /* region allocating from */ -Void_t *addr; /* address to check */ -#endif { reg Seg_t *seg; reg Block_t *b, *endb; @@ -977,12 +924,7 @@ Void_t *addr; /* address to check */ return size; } -#if __STD_C static int bestcompact(Vmalloc_t * vm) -#else -static int bestcompact(vm) -Vmalloc_t *vm; -#endif { reg Seg_t *seg, *next; reg Block_t *bp, *t; @@ -1049,14 +991,7 @@ Vmalloc_t *vm; return 0; } -#if __STD_C static Void_t *bestalign(Vmalloc_t * vm, size_t size, size_t align) -#else -static Void_t *bestalign(vm, size, align) -Vmalloc_t *vm; -size_t size; -size_t align; -#endif { reg Vmuchar_t *data; reg Block_t *tp, *np; @@ -1150,17 +1085,15 @@ size_t align; } /* A discipline to get memory using sbrk() or VirtualAlloc on win32 */ -#if __STD_C +/** + * @param vm region doing allocation from + * @param caddr current address + * @param csize current size + * @param nsize new size + * @param disc discipline structure + */ static Void_t *sbrkmem(Vmalloc_t * vm, Void_t * caddr, size_t csize, size_t nsize, Vmdisc_t * disc) -#else -static Void_t *sbrkmem(vm, caddr, csize, nsize, disc) -Vmalloc_t *vm; /* region doing allocation from */ -Void_t *caddr; /* current address */ -size_t csize; /* current size */ -size_t nsize; /* new size */ -Vmdisc_t *disc; /* discipline structure */ -#endif { #if _std_malloc || _BLD_INSTRUMENT || cray NOTUSED(vm); diff --git a/lib/vmalloc/vmclear.c b/lib/vmalloc/vmclear.c index 0791a793a..cc9d9e51e 100644 --- a/lib/vmalloc/vmclear.c +++ b/lib/vmalloc/vmclear.c @@ -17,12 +17,7 @@ ** ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C int vmclear(Vmalloc_t * vm) -#else -int vmclear(vm) -Vmalloc_t *vm; -#endif { reg Seg_t *seg; reg Seg_t *next; diff --git a/lib/vmalloc/vmclose.c b/lib/vmalloc/vmclose.c index 5afec3958..673dc805e 100644 --- a/lib/vmalloc/vmclose.c +++ b/lib/vmalloc/vmclose.c @@ -17,12 +17,7 @@ ** ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C int vmclose(Vmalloc_t * vm) -#else -int vmclose(vm) -Vmalloc_t *vm; -#endif { reg Seg_t *seg, *vmseg; reg Vmemory_f memoryf; diff --git a/lib/vmalloc/vmdcheap.c b/lib/vmalloc/vmdcheap.c index 1891a3b98..6967999a0 100644 --- a/lib/vmalloc/vmdcheap.c +++ b/lib/vmalloc/vmdcheap.c @@ -17,17 +17,15 @@ ** ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C +/** + * @param vm region doing allocation from + * @param caddr current low address + * @param csize current size + * @param nsize new size + * @param disc discipline structure + */ static Void_t *heapmem(Vmalloc_t * vm, Void_t * caddr, size_t csize, size_t nsize, Vmdisc_t * disc) -#else -static Void_t *heapmem(vm, caddr, csize, nsize, disc) -Vmalloc_t *vm; /* region doing allocation from */ -Void_t *caddr; /* current low address */ -size_t csize; /* current size */ -size_t nsize; /* new size */ -Vmdisc_t *disc; /* discipline structure */ -#endif { NOTUSED(vm); NOTUSED(disc); diff --git a/lib/vmalloc/vmdebug.c b/lib/vmalloc/vmdebug.c index 533f39639..b8e0f11c3 100644 --- a/lib/vmalloc/vmdebug.c +++ b/lib/vmalloc/vmdebug.c @@ -63,14 +63,7 @@ static void dbinit(void) } /* just an entry point to make it easy to set break point */ -#if __STD_C static void vmdbwarn(Vmalloc_t * vm, char *mesg, int n) -#else -static void vmdbwarn(vm, mesg, n) -Vmalloc_t *vm; -char *mesg; -int n; -#endif { reg Vmdata_t *vd = vm->data; @@ -80,18 +73,16 @@ int n; } /* issue a warning of some type */ -#if __STD_C +/** + * @param vm region holding the block + * @param data data block + * @param where byte that was corrupted + * @param file file where call originates + * @param line line number of call + * @param type operation being done + */ static void dbwarn(Vmalloc_t * vm, Void_t * data, int where, char *file, int line, int type) -#else -static void dbwarn(vm, data, where, file, line, type) -Vmalloc_t *vm; /* region holding the block */ -Void_t *data; /* data block */ -int where; /* byte that was corrupted */ -char *file; /* file where call originates */ -int line; /* line number of call */ -int type; /* operation being done */ -#endif { char buf[1024], *bufp, *endbuf, *s; #define SLOP 64 /* enough for a message and an int */ @@ -177,17 +168,8 @@ int type; /* operation being done */ } /* check for watched address and issue warnings */ -#if __STD_C static void dbwatch(Vmalloc_t * vm, Void_t * data, char *file, int line, int type) -#else -static void dbwatch(vm, data, file, line, type) -Vmalloc_t *vm; -Void_t *data; -char *file; -int line; -int type; -#endif { reg int n; @@ -200,15 +182,13 @@ int type; } /* record information about the block */ -#if __STD_C +/** + * @param data real address not the one from Vmbest + * @param size the actual requested size + * @param file file where the request came from + * @param line and line number + */ static void dbsetinfo(Vmuchar_t * data, size_t size, char *file, int line) -#else -static void dbsetinfo(data, size, file, line) -Vmuchar_t *data; /* real address not the one from Vmbest */ -size_t size; /* the actual requested size */ -char *file; /* file where the request came from */ -int line; /* and line number */ -#endif { reg Vmuchar_t *begp, *endp; reg Dbfile_t *last, *db; @@ -254,13 +234,7 @@ int line; /* and line number */ ** This returns -(offset+1) if block is already freed, +(offset+1) ** if block is live, 0 if no match. */ -#if __STD_C static long dbaddr(Vmalloc_t * vm, Void_t * addr) -#else -static long dbaddr(vm, addr) -Vmalloc_t *vm; -Void_t *addr; -#endif { reg Block_t *b = NULL, *endb = NULL; reg Seg_t *seg; @@ -317,13 +291,7 @@ Void_t *addr; } -#if __STD_C static long dbsize(Vmalloc_t * vm, Void_t * addr) -#else -static long dbsize(vm, addr) -Vmalloc_t *vm; -Void_t *addr; -#endif { reg Block_t *b, *endb; reg Seg_t *seg; @@ -356,13 +324,7 @@ Void_t *addr; return size; } -#if __STD_C static Void_t *dballoc(Vmalloc_t * vm, size_t size) -#else -static Void_t *dballoc(vm, size) -Vmalloc_t *vm; -size_t size; -#endif { reg size_t s; reg Vmuchar_t *data; @@ -408,13 +370,7 @@ size_t size; } -#if __STD_C static int dbfree(Vmalloc_t * vm, Void_t * data) -#else -static int dbfree(vm, data) -Vmalloc_t *vm; -Void_t *data; -#endif { char *file; int line; @@ -466,16 +422,14 @@ Void_t *data; } /* Resizing an existing block */ -#if __STD_C +/** + * @param vm region allocating from + * @param addr old block of data + * @param size new size + * @param type !=0 for movable, >0 for copy + */ static Void_t *dbresize(Vmalloc_t * vm, Void_t * addr, reg size_t size, int type) -#else -static Void_t *dbresize(vm, addr, size, type) -Vmalloc_t *vm; /* region allocating from */ -Void_t *addr; /* old block of data */ -reg size_t size; /* new size */ -int type; /* !=0 for movable, >0 for copy */ -#endif { reg Vmuchar_t *data; reg size_t s, oldsize; @@ -558,23 +512,13 @@ int type; /* !=0 for movable, >0 for copy */ } /* compact any residual free space */ -#if __STD_C static int dbcompact(Vmalloc_t * vm) -#else -static int dbcompact(vm) -Vmalloc_t *vm; -#endif { return (*(Vmbest->compactf)) (vm); } /* check for memory overwrites over all live blocks */ -#if __STD_C int vmdbcheck(Vmalloc_t * vm) -#else -int vmdbcheck(vm) -Vmalloc_t *vm; -#endif { reg Block_t *b, *endb; reg Seg_t *seg; @@ -625,12 +569,12 @@ Vmalloc_t *vm; } /* set/delete an address to watch */ -#if __STD_C +/** + * set/delete an address to watch + * + * @param addr address to insert + */ Void_t *vmdbwatch(Void_t * addr) -#else -Void_t *vmdbwatch(addr) -Void_t *addr; /* address to insert */ -#endif { reg int n; reg Void_t *out; @@ -656,14 +600,7 @@ Void_t *addr; /* address to insert */ return out; } -#if __STD_C static Void_t *dbalign(Vmalloc_t * vm, size_t size, size_t align) -#else -static Void_t *dbalign(vm, size, align) -Vmalloc_t *vm; -size_t size; -size_t align; -#endif { reg Vmuchar_t *data; reg size_t s; diff --git a/lib/vmalloc/vmdisc.c b/lib/vmalloc/vmdisc.c index 1d3d154a9..adfcd2fc7 100644 --- a/lib/vmalloc/vmdisc.c +++ b/lib/vmalloc/vmdisc.c @@ -19,13 +19,7 @@ ** ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C Vmdisc_t *vmdisc(Vmalloc_t * vm, Vmdisc_t * disc) -#else -Vmdisc_t *vmdisc(vm, disc) -Vmalloc_t *vm; -Vmdisc_t *disc; -#endif { Vmdisc_t *old = vm->disc; diff --git a/lib/vmalloc/vmexit.c b/lib/vmalloc/vmexit.c index 0861dcfe2..b63b1f8d4 100644 --- a/lib/vmalloc/vmexit.c +++ b/lib/vmalloc/vmexit.c @@ -23,12 +23,7 @@ int Vm_atexit_already_defined; #if _lib_onexit -#if __STD_C int atexit(void (*exitf) (void)) -#else -int atexit(exitf) -void (*exitf) (); -#endif { return onexit(exitf); } @@ -41,12 +36,7 @@ typedef struct _exit_s { } Exit_t; static Exit_t *Exit; -#if __STD_C atexit(void (*exitf) (void)) -#else -atexit(exitf) -void (*exitf) (); -#endif { Exit_t *e; @@ -58,12 +48,7 @@ void (*exitf) (); return 0; } -#if __STD_C void exit(int type) -#else -void exit(type) -int type; -#endif { Exit_t *e; diff --git a/lib/vmalloc/vmlast.c b/lib/vmalloc/vmlast.c index 3232225be..bd6b376e8 100644 --- a/lib/vmalloc/vmlast.c +++ b/lib/vmalloc/vmlast.c @@ -18,13 +18,7 @@ ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C static Void_t *lastalloc(Vmalloc_t * vm, size_t size) -#else -static Void_t *lastalloc(vm, size) -Vmalloc_t *vm; -size_t size; -#endif { reg Block_t *tp, *next; reg Seg_t *seg, *last; @@ -84,13 +78,7 @@ size_t size; return (Void_t *) tp; } -#if __STD_C static int lastfree(Vmalloc_t * vm, reg Void_t * data) -#else -static int lastfree(vm, data) -Vmalloc_t *vm; -reg Void_t *data; -#endif { reg Seg_t *seg; reg Block_t *fp; @@ -134,16 +122,8 @@ reg Void_t *data; return 0; } -#if __STD_C static Void_t *lastresize(Vmalloc_t * vm, reg Void_t * data, size_t size, int type) -#else -static Void_t *lastresize(vm, data, size, type) -Vmalloc_t *vm; -reg Void_t *data; -size_t size; -int type; -#endif { reg Block_t *tp; reg Seg_t *seg; @@ -281,13 +261,7 @@ int type; } -#if __STD_C static long lastaddr(Vmalloc_t * vm, Void_t * addr) -#else -static long lastaddr(vm, addr) -Vmalloc_t *vm; -Void_t *addr; -#endif { reg Vmdata_t *vd = vm->data; @@ -300,13 +274,7 @@ Void_t *addr; return (Vmuchar_t *) addr - (Vmuchar_t *) vd->free; } -#if __STD_C static long lastsize(Vmalloc_t * vm, Void_t * addr) -#else -static long lastsize(vm, addr) -Vmalloc_t *vm; -Void_t *addr; -#endif { reg Vmdata_t *vd = vm->data; @@ -321,12 +289,7 @@ Void_t *addr; sizeof(Head_t); } -#if __STD_C static int lastcompact(Vmalloc_t * vm) -#else -static int lastcompact(vm) -Vmalloc_t *vm; -#endif { reg Block_t *fp; reg Seg_t *seg, *next; @@ -362,14 +325,7 @@ Vmalloc_t *vm; return 0; } -#if __STD_C static Void_t *lastalign(Vmalloc_t * vm, size_t size, size_t align) -#else -static Void_t *lastalign(vm, size, align) -Vmalloc_t *vm; -size_t size; -size_t align; -#endif { reg Vmuchar_t *data; reg size_t s, orgsize = 0, orgalign = 0; diff --git a/lib/vmalloc/vmopen.c b/lib/vmalloc/vmopen.c index 81b162ab2..bec6f1f71 100644 --- a/lib/vmalloc/vmopen.c +++ b/lib/vmalloc/vmopen.c @@ -29,14 +29,12 @@ typedef struct _vminit_ { char a[3 * ALIGN]; /* extra to fuss with alignment */ } Vminit_t; -#if __STD_C +/** + * @param disc discipline to get segments + * @param meth method to manage space + * @param mode type of region + */ Vmalloc_t *vmopen(Vmdisc_t * disc, Vmethod_t * meth, int mode) -#else -Vmalloc_t *vmopen(disc, meth, mode) -Vmdisc_t *disc; /* discipline to get segments */ -Vmethod_t *meth; /* method to manage space */ -int mode; /* type of region */ -#endif { reg Vmalloc_t *vm; reg Vmdata_t *vd; diff --git a/lib/vmalloc/vmpool.c b/lib/vmalloc/vmpool.c index 8021fc2e3..133e57212 100644 --- a/lib/vmalloc/vmpool.c +++ b/lib/vmalloc/vmpool.c @@ -24,13 +24,7 @@ ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C static Void_t *poolalloc(Vmalloc_t * vm, reg size_t size) -#else -static Void_t *poolalloc(vm, size) -Vmalloc_t *vm; -reg size_t size; -#endif { reg Vmdata_t *vd = vm->data; reg Block_t *tp, *next; @@ -103,13 +97,7 @@ reg size_t size; return (Void_t *) tp; } -#if __STD_C static long pooladdr(Vmalloc_t * vm, reg Void_t * addr) -#else -static long pooladdr(vm, addr) -Vmalloc_t *vm; -reg Void_t *addr; -#endif { reg Block_t *bp, *tp; reg Vmuchar_t *laddr, *baddr; @@ -153,13 +141,7 @@ reg Void_t *addr; return offset; } -#if __STD_C static int poolfree(reg Vmalloc_t * vm, reg Void_t * data) -#else -static int poolfree(vm, data) -reg Vmalloc_t *vm; -reg Void_t *data; -#endif { reg Block_t *bp; reg Vmdata_t *vd = vm->data; @@ -195,16 +177,8 @@ reg Void_t *data; return 0; } -#if __STD_C static Void_t *poolresize(Vmalloc_t * vm, Void_t * data, size_t size, int type) -#else -static Void_t *poolresize(vm, data, size, type) -Vmalloc_t *vm; -Void_t *data; -size_t size; -int type; -#endif { reg Vmdata_t *vd = vm->data; @@ -244,23 +218,12 @@ int type; return data; } -#if __STD_C static long poolsize(Vmalloc_t * vm, Void_t * addr) -#else -static long poolsize(vm, addr) -Vmalloc_t *vm; -Void_t *addr; -#endif { return pooladdr(vm, addr) == 0 ? (long) vm->data->pool : -1L; } -#if __STD_C static int poolcompact(Vmalloc_t * vm) -#else -static int poolcompact(vm) -Vmalloc_t *vm; -#endif { reg Block_t *fp; reg Seg_t *seg, *next; @@ -296,14 +259,7 @@ Vmalloc_t *vm; return 0; } -#if __STD_C static Void_t *poolalign(Vmalloc_t * vm, size_t size, size_t align) -#else -static Void_t *poolalign(vm, size, align) -Vmalloc_t *vm; -size_t size; -size_t align; -#endif { NOTUSED(vm); NOTUSED(size); diff --git a/lib/vmalloc/vmprivate.c b/lib/vmalloc/vmprivate.c index c07dddbad..0f3ad4c27 100644 --- a/lib/vmalloc/vmprivate.c +++ b/lib/vmalloc/vmprivate.c @@ -23,16 +23,15 @@ static char *Version = "\n@(#)Vmalloc (AT&T Labs - kpv) 1999-08-05\0\n"; ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -/* Get more memory for a region */ -#if __STD_C +/** + * Get more memory for a region + * + * @param vm region to increase in size + * @param size desired amount of space + * @param searchf tree search function + */ static Block_t *vmextend(reg Vmalloc_t * vm, size_t size, Vmsearch_f searchf) -#else -static Block_t *vmextend(vm, size, searchf) -reg Vmalloc_t *vm; /* region to increase in size */ -size_t size; /* desired amount of space */ -Vmsearch_f searchf; /* tree search function */ -#endif { reg size_t s; reg Seg_t *seg; @@ -185,16 +184,15 @@ Vmsearch_f searchf; /* tree search function */ return bp; } -/* Truncate a segment if possible */ -#if __STD_C +/** + * Truncate a segment if possible + * + * @param vm containing region + * @param seg the one to be truncated + * @param size amount of free space + * @param exact amount given was exact + */ static int vmtruncate(Vmalloc_t * vm, Seg_t * seg, size_t size, int exact) -#else -static int vmtruncate(vm, seg, size, exact) -Vmalloc_t *vm; /* containing region */ -Seg_t *seg; /* the one to be truncated */ -size_t size; /* amount of free space */ -int exact; /* amount given was exact */ -#endif { reg Void_t *caddr; reg Seg_t *last; diff --git a/lib/vmalloc/vmprofile.c b/lib/vmalloc/vmprofile.c index 1bb6756a4..8d8a8b657 100644 --- a/lib/vmalloc/vmprofile.c +++ b/lib/vmalloc/vmprofile.c @@ -57,14 +57,12 @@ static Pfobj_t **Pftable; /* hash table */ #define PFTABLE 1019 /* table size */ static Vmalloc_t *Vmpf; /* heap for our own use */ -#if __STD_C +/** + * @param vm region allocating from + * @param file the file issuing the allocation request + * @param line line number + */ static Pfobj_t *pfsearch(Vmalloc_t * vm, char *file, int line) -#else -static Pfobj_t *pfsearch(vm, file, line) -Vmalloc_t *vm; /* region allocating from */ -char *file; /* the file issuing the allocation request */ -int line; /* line number */ -#endif { reg Pfobj_t *pf, *last; reg Vmulong_t h; @@ -166,12 +164,7 @@ int line; /* line number */ return pf; } -#if __STD_C static void pfclose(Vmalloc_t * vm) -#else -static void pfclose(vm) -Vmalloc_t *vm; -#endif { reg int n; reg Pfobj_t *pf, *next, *last; @@ -195,17 +188,8 @@ Vmalloc_t *vm; } } -#if __STD_C static void pfsetinfo(Vmalloc_t * vm, Vmuchar_t * data, size_t size, char *file, int line) -#else -static void pfsetinfo(vm, data, size, file, line) -Vmalloc_t *vm; -Vmuchar_t *data; -size_t size; -char *file; -int line; -#endif { reg Pfobj_t *pf; reg Vmulong_t s; @@ -235,12 +219,7 @@ int line; } /* sort by file names and line numbers */ -#if __STD_C static Pfobj_t *pfsort(Pfobj_t * pf) -#else -static Pfobj_t *pfsort(pf) -Pfobj_t *pf; -#endif { reg Pfobj_t *one, *two, *next; reg int cmp; @@ -305,20 +284,9 @@ Pfobj_t *pf; } } -#if __STD_C static char *pfsummary(char *buf, Vmulong_t na, Vmulong_t sa, Vmulong_t nf, Vmulong_t sf, Vmulong_t max, Vmulong_t size) -#else -static char *pfsummary(buf, na, sa, nf, sf, max, size) -char *buf; -Vmulong_t na; -Vmulong_t sa; -Vmulong_t nf; -Vmulong_t sf; -Vmulong_t max; -Vmulong_t size; -#endif { buf = (*_Vmstrcpy) (buf, "n_alloc", '='); buf = (*_Vmstrcpy) (buf, (*_Vmitoa) (na, -1), ':'); @@ -340,13 +308,7 @@ Vmulong_t size; } /* print profile data */ -#if __STD_C int vmprofile(Vmalloc_t * vm, int fd) -#else -int vmprofile(vm, fd) -Vmalloc_t *vm; -int fd; -#endif { reg Pfobj_t *pf, *list, *next, *last; reg int n; @@ -452,13 +414,7 @@ int fd; return 0; } -#if __STD_C static Void_t *pfalloc(Vmalloc_t * vm, size_t size) -#else -static Void_t *pfalloc(vm, size) -Vmalloc_t *vm; -size_t size; -#endif { reg size_t s; reg Void_t *data; @@ -487,13 +443,7 @@ size_t size; return data; } -#if __STD_C static int pffree(Vmalloc_t * vm, Void_t * data) -#else -static int pffree(vm, data) -Vmalloc_t *vm; -Void_t *data; -#endif { reg Pfobj_t *pf; reg size_t s; @@ -539,16 +489,8 @@ Void_t *data; return (*(Vmbest->freef)) (vm, data); } -#if __STD_C static Void_t *pfresize(Vmalloc_t * vm, Void_t * data, size_t size, int type) -#else -static Void_t *pfresize(vm, data, size, type) -Vmalloc_t *vm; -Void_t *data; -size_t size; -int type; -#endif { reg Pfobj_t *pf; reg size_t s, news; @@ -628,46 +570,22 @@ int type; return addr; } -#if __STD_C static long pfsize(Vmalloc_t * vm, Void_t * addr) -#else -static long pfsize(vm, addr) -Vmalloc_t *vm; -Void_t *addr; -#endif { return (*Vmbest->addrf) (vm, addr) != 0 ? -1L : (long) PFSIZE(addr); } -#if __STD_C static long pfaddr(Vmalloc_t * vm, Void_t * addr) -#else -static long pfaddr(vm, addr) -Vmalloc_t *vm; -Void_t *addr; -#endif { return (*Vmbest->addrf) (vm, addr); } -#if __STD_C static int pfcompact(Vmalloc_t * vm) -#else -static int pfcompact(vm) -Vmalloc_t *vm; -#endif { return (*Vmbest->compactf) (vm); } -#if __STD_C static Void_t *pfalign(Vmalloc_t * vm, size_t size, size_t align) -#else -static Void_t *pfalign(vm, size, align) -Vmalloc_t *vm; -size_t size; -size_t align; -#endif { reg size_t s; reg Void_t *data; diff --git a/lib/vmalloc/vmregion.c b/lib/vmalloc/vmregion.c index e34edc0b0..1f7d8c46a 100644 --- a/lib/vmalloc/vmregion.c +++ b/lib/vmalloc/vmregion.c @@ -18,12 +18,7 @@ ** ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C Vmalloc_t *vmregion(reg Void_t * addr) -#else -Vmalloc_t *vmregion(addr) -reg Void_t *addr; -#endif { return addr ? VM(BLOCK(addr)) : NIL(Vmalloc_t *); } diff --git a/lib/vmalloc/vmsegment.c b/lib/vmalloc/vmsegment.c index ff5624a40..8e11db263 100644 --- a/lib/vmalloc/vmsegment.c +++ b/lib/vmalloc/vmsegment.c @@ -18,13 +18,11 @@ ** Written by Kiem-Phong Vo, kpv@research.att.com, 02/07/95 */ -#if __STD_C +/** + * @param vm region + * @param addr address + */ Void_t *vmsegment(Vmalloc_t * vm, Void_t * addr) -#else -Void_t *vmsegment(vm, addr) -Vmalloc_t *vm; /* region */ -Void_t *addr; /* address */ -#endif { reg Seg_t *seg; reg Vmdata_t *vd = vm->data; diff --git a/lib/vmalloc/vmset.c b/lib/vmalloc/vmset.c index 53e23abf9..9751a1636 100644 --- a/lib/vmalloc/vmset.c +++ b/lib/vmalloc/vmset.c @@ -18,14 +18,12 @@ ** ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C +/** + * @param vm region being worked on + * @param flags flags must be in VM_FLAGS + * @param on !=0 if turning on, else turning off + */ int vmset(reg Vmalloc_t * vm, int flags, int on) -#else -int vmset(vm, flags, on) -reg Vmalloc_t *vm; /* region being worked on */ -int flags; /* flags must be in VM_FLAGS */ -int on; /* !=0 if turning on, else turning off */ -#endif { reg int mode; reg Vmdata_t *vd = vm->data; diff --git a/lib/vmalloc/vmstat.c b/lib/vmalloc/vmstat.c index 8d42b4c70..6f68d22d7 100644 --- a/lib/vmalloc/vmstat.c +++ b/lib/vmalloc/vmstat.c @@ -18,13 +18,7 @@ ** Written by Kiem-Phong Vo, kpv@research.att.com, 01/16/94. */ -#if __STD_C int vmstat(Vmalloc_t * vm, Vmstat_t * st) -#else -int vmstat(vm, st) -Vmalloc_t *vm; -Vmstat_t *st; -#endif { reg Seg_t *seg; reg Block_t *b, *endb; diff --git a/lib/vmalloc/vmtrace.c b/lib/vmalloc/vmtrace.c index ddf70e19d..e6cc29c60 100644 --- a/lib/vmalloc/vmtrace.c +++ b/lib/vmalloc/vmtrace.c @@ -21,14 +21,7 @@ static int Trfile = -1; static char Trbuf[128]; -#if __STD_C static char *trstrcpy(char *to, char *from, int endc) -#else -static char *trstrcpy(to, from, endc) -char *to; -char *from; -int endc; -#endif { reg int n; @@ -40,14 +33,13 @@ int endc; return to; } -/* convert a long value to an ascii representation */ -#if __STD_C +/* + * convert a long value to an ascii representation + * + * @param v value to convert + * @param type =0 base-16, >0: unsigned base-10, <0: signed base-10 + */ static char *tritoa(Vmulong_t v, int type) -#else -static char *tritoa(v, type) -Vmulong_t v; /* value to convert */ -int type; /* =0 base-16, >0: unsigned base-10, <0: signed base-10 */ -#endif { char *s; @@ -82,19 +74,17 @@ int type; /* =0 base-16, >0: unsigned base-10, <0: signed base-10 */ return s + 1; } -/* generate a trace of some call */ -#if __STD_C +/** + * generate a trace of some call + * @param vm region call was made from + * @param newaddr old data address + * @param newaddr new data address + * @param size size of piece + * @param align alignment + */ static void trtrace(Vmalloc_t * vm, Vmuchar_t * oldaddr, Vmuchar_t * newaddr, size_t size, size_t align) -#else -static void trtrace(vm, oldaddr, newaddr, size, align) -Vmalloc_t *vm; /* region call was made from */ -Vmuchar_t *oldaddr; /* old data address */ -Vmuchar_t *newaddr; /* new data address */ -size_t size; /* size of piece */ -size_t align; /* alignment */ -#endif { char buf[1024], *bufp, *endbuf; reg Vmdata_t *vd = vm->data; @@ -144,12 +134,7 @@ size_t align; /* alignment */ write(Trfile, buf, (bufp - buf)); } -#if __STD_C int vmtrace(int file) -#else -int vmtrace(file) -int file; -#endif { int fd; @@ -162,12 +147,7 @@ int file; return fd; } -#if __STD_C int vmtrbusy(Vmalloc_t * vm) -#else -int vmtrbusy(vm) -Vmalloc_t *vm; -#endif { Seg_t *seg; Vmdata_t *vd = vm->data; diff --git a/lib/vmalloc/vmwalk.c b/lib/vmalloc/vmwalk.c index 61929a6da..a07dbce25 100644 --- a/lib/vmalloc/vmwalk.c +++ b/lib/vmalloc/vmwalk.c @@ -18,14 +18,8 @@ ** Written by Kiem-Phong Vo, kpv@research.att.com (02/08/96) */ -#if __STD_C int vmwalk(Vmalloc_t * vm, int (*segf) (Vmalloc_t *, Void_t *, size_t, Vmdisc_t *)) -#else -int vmwalk(vm, segf) -Vmalloc_t *vm; -int (*segf) ( /* Vmalloc_t*, Void_t*, size_t, Vmdisc_t* */ ); -#endif { reg Seg_t *seg; reg int rv; -- 2.50.0