|
|
1.1 root 1: /*
2: * stdlib.h --
3: *
4: * Declares facilities exported by the "stdlib" portion of
5: * the C library.
6: *
7: * Copyright 1988 Regents of the University of California
8: * Permission to use, copy, modify, and distribute this
9: * software and its documentation for any purpose and without
10: * fee is hereby granted, provided that the above copyright
11: * notice appear in all copies. The University of California
12: * makes no representations about the suitability of this
13: * software for any purpose. It is provided "as is" without
14: * express or implied warranty.
15: *
16: * $Header: /sprite/src/lib/include/RCS/stdlib.h,v 1.12 90/01/06 13:45:29 rab Exp $ SPRITE (Berkeley)
17: */
18:
19: #ifndef _STDLIB
20: #define _STDLIB
21:
22: #define EXIT_SUCCESS 0
23: #define EXIT_FAILURE 1
24:
25: /*
26: *----------------------------
27: * String conversion routines:
28: *----------------------------
29: */
30:
31: extern double atof();
32: extern int atoi();
33: extern long int atol();
34: extern double strtod();
35: extern long int strtol();
36: extern unsigned long strtoul();
37:
38: /*
39: *------------------
40: * Memory allocator:
41: *------------------
42: */
43:
44: extern char * alloca();
45: extern char * calloc();
46: extern char * malloc();
47: extern char * realloc();
48: extern void Mem_Bin();
49: extern char * Mem_CallerPC();
50: extern void Mem_DumpTrace();
51: extern void Mem_PrintConfig();
52: extern void Mem_PrintInUse();
53: extern void Mem_PrintStats();
54: extern void Mem_PrintStatsInt();
55: extern void Mem_SetPrintProc();
56: extern void Mem_SetTraceSizes();
57: extern int Mem_Size();
58:
59: /*
60: * The mips compiler cannot handle some coercions on the left hand side
61: */
62: #if defined(KERNEL) && !defined(mips)
63: extern _free();
64:
65: #ifdef lint
66: #define free(ptr) _free(ptr)
67: #else
68: #define free(ptr) {_free(ptr); (ptr) = (char *) NIL; }
69: #endif /* lint */
70:
71: #else
72: extern free();
73: #endif /* KERNEL */
74:
75: /*
76: * Structure used to set up memory allocation traces.
77: */
78:
79: typedef struct {
80: int size; /* Size of block to trace. */
81: int flags; /* Flags defined below */
82: } Mem_TraceInfo;
83:
84: /*
85: * Flags to determine what type of tracing to do.
86: *
87: * MEM_PRINT_TRACE A trace record will be printed each time that
88: * an object of this size is alloc'd or freed.
89: * MEM_STORE_TRACE The number of blocks in use by each caller
90: * up to a predefined maximum number of callers
91: * is kept in a trace array .
92: * MEM_DONT_USE_ORIG_SIZE Don't use the original size for tracing, but use
93: * the modified size used by malloc.
94: * MEM_TRACE_NOT_INIT The trace records stored for MEM_STORE_TRACE
95: * have not been initialized yet.
96: */
97:
98: #define MEM_PRINT_TRACE 0x1
99: #define MEM_STORE_TRACE 0x2
100: #define MEM_DONT_USE_ORIG_SIZE 0x4
101: #define MEM_TRACE_NOT_INIT 0x8
102:
103: extern int mem_SmallMinNum;
104: extern int mem_LargeMinNum;
105: extern int mem_LargeMaxSize;
106:
107: /*
108: * Statistics counters; only incremented when tracing is enabled.
109: */
110:
111: extern int mem_NumAllocs;
112: extern int mem_NumFrees;
113:
114: /*
115: *----------------------------------------------------------------
116: * Additional integer math routines, plus structures for returning
117: * results from them:
118: *----------------------------------------------------------------
119: */
120:
121: typedef struct div_t {
122: int quot;
123: int rem;
124: } div_t;
125:
126: typedef struct {
127: long int quot;
128: long int rem;
129: } ldiv_t;
130:
131: extern int abs();
132: extern div_t div();
133: extern long int labs();
134: extern ldiv_t ldiv();
135:
136: /*
137: *-----------------------------------
138: * Miscellaneous additional routines:
139: *-----------------------------------
140: */
141:
142: extern void abort();
143: extern int atexit();
144: extern char * bsearch();
145: extern exit();
146: extern char * getenv();
147: extern void qsort();
148: extern int rand();
149: extern long random();
150: extern void setenv();
151: extern srand();
152: extern srandom();
153: extern int system();
154:
155: #endif /* _STDLIB */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.