1 /*
2 Copyright (c) 1991, 1993
3 The Regents of the University of California.  All rights reserved.
4 c) UNIX System Laboratories, Inc.
5 All or some portions of this file are derived from material licensed
6 to the University of California by American Telephone and Telegraph
7 Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 the permission of UNIX System Laboratories, Inc.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions
12 are met:
13 1. Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15 2. Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in the
17 documentation and/or other materials provided with the distribution.
18 3. Neither the name of the University nor the names of its contributors
19 may be used to endorse or promote products derived from this software
20 without specific prior written permission.
21 
22 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 SUCH DAMAGE.
33  */
34 /* malloc.h -- header file for memory routines.  */
35 
36 #ifndef _INCLUDE_MALLOC_H_
37 #define _INCLUDE_MALLOC_H_
38 
39 #include <sys/cdefs.h>
40 #define __need_size_t
41 #include <stddef.h>
42 
43 /* include any machine-specific extensions */
44 #include <machine/malloc.h>
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /* This version of struct mallinfo must match the one in
51    libc/stdlib/mallocr.c.  */
52 
53 struct mallinfo {
54   size_t arena;    /* total space allocated from system */
55   size_t ordblks;  /* number of non-inuse chunks */
56   size_t smblks;   /* unused -- always zero */
57   size_t hblks;    /* number of mmapped regions */
58   size_t hblkhd;   /* total space in mmapped regions */
59   size_t usmblks;  /* unused -- always zero */
60   size_t fsmblks;  /* unused -- always zero */
61   size_t uordblks; /* total allocated space */
62   size_t fordblks; /* total non-inuse space */
63   size_t keepcost; /* top-most, releasable (via malloc_trim) space */
64 };
65 
66 /* The routines.  */
67 
68 void	free (void *) _NOTHROW;
69 void	*malloc(size_t) __malloc_like __result_use_check __alloc_size(1) _NOTHROW;
70 void	*calloc(size_t, size_t) __malloc_like __result_use_check
71     __alloc_size2(1, 2) _NOTHROW;
72 void	*realloc(void *, size_t) __result_use_check __alloc_size(2) _NOTHROW;
73 void    *memalign (size_t __alignment, size_t __size)  __malloc_like
74     __result_use_check __alloc_size(2) _NOTHROW;
75 
76 struct mallinfo mallinfo (void);
77 void malloc_stats (void);
78 int mallopt (int, int);
79 size_t malloc_usable_size (void *);
80 /* These aren't too useful on an embedded system, but we define them
81    anyhow.  */
82 
83 void *pvalloc (size_t);
84 int malloc_trim (size_t);
85 void __malloc_lock(void);
86 void __malloc_unlock(void);
87 
88 /* A compatibility routine for an earlier version of the allocator.  */
89 
90 void mstats (char *);
91 
92 /* SVID2/XPG mallopt options */
93 
94 #define M_MXFAST  1    /* UNUSED in this malloc */
95 #define M_NLBLKS  2    /* UNUSED in this malloc */
96 #define M_GRAIN   3    /* UNUSED in this malloc */
97 #define M_KEEP    4    /* UNUSED in this malloc */
98 
99 /* mallopt options that actually do something */
100 
101 #define M_TRIM_THRESHOLD    -1
102 #define M_TOP_PAD           -2
103 #define M_MMAP_THRESHOLD    -3
104 #define M_MMAP_MAX          -4
105 
106 /* Some systems provide this, so do too for compatibility.  */
107 void cfree (void *);
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif /* _INCLUDE_MALLOC_H_ */
114