選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

174 行
4.1KB

  1. /* malloc.h -- header file for memory routines. */
  2. #ifndef _INCLUDE_MALLOC_H_
  3. #define _INCLUDE_MALLOC_H_
  4. #include <_ansi.h>
  5. #include <sys/reent.h>
  6. #define __need_size_t
  7. #include <stddef.h>
  8. /* include any machine-specific extensions */
  9. #include <machine/malloc.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /* This version of struct mallinfo must match the one in
  14. libc/stdlib/mallocr.c. */
  15. struct mallinfo {
  16. size_t arena; /* total space allocated from system */
  17. size_t ordblks; /* number of non-inuse chunks */
  18. size_t smblks; /* unused -- always zero */
  19. size_t hblks; /* number of mmapped regions */
  20. size_t hblkhd; /* total space in mmapped regions */
  21. size_t usmblks; /* unused -- always zero */
  22. size_t fsmblks; /* unused -- always zero */
  23. size_t uordblks; /* total allocated space */
  24. size_t fordblks; /* total non-inuse space */
  25. size_t keepcost; /* top-most, releasable (via malloc_trim) space */
  26. };
  27. /* The routines. */
  28. extern void *malloc (size_t);
  29. #ifdef __CYGWIN__
  30. #undef _malloc_r
  31. #define _malloc_r(r, s) malloc (s)
  32. #else
  33. extern void *_malloc_r (struct _reent *, size_t);
  34. #endif
  35. extern void free (void *);
  36. #ifdef __CYGWIN__
  37. #undef _free_r
  38. #define _free_r(r, p) free (p)
  39. #else
  40. extern void _free_r (struct _reent *, void *);
  41. #endif
  42. extern void *realloc (void *, size_t);
  43. #ifdef __CYGWIN__
  44. #undef _realloc_r
  45. #define _realloc_r(r, p, s) realloc (p, s)
  46. #else
  47. extern void *_realloc_r (struct _reent *, void *, size_t);
  48. #endif
  49. extern void *calloc (size_t, size_t);
  50. #ifdef __CYGWIN__
  51. #undef _calloc_r
  52. #define _calloc_r(r, s1, s2) calloc (s1, s2);
  53. #else
  54. extern void *_calloc_r (struct _reent *, size_t, size_t);
  55. #endif
  56. extern void *memalign (size_t, size_t);
  57. #ifdef __CYGWIN__
  58. #undef _memalign_r
  59. #define _memalign_r(r, s1, s2) memalign (s1, s2);
  60. #else
  61. extern void *_memalign_r (struct _reent *, size_t, size_t);
  62. #endif
  63. extern struct mallinfo mallinfo (void);
  64. #ifdef __CYGWIN__
  65. #undef _mallinfo_r
  66. #define _mallinfo_r(r) mallinfo ()
  67. #else
  68. extern struct mallinfo _mallinfo_r (struct _reent *);
  69. #endif
  70. extern void malloc_stats (void);
  71. #ifdef __CYGWIN__
  72. #undef _malloc_stats_r
  73. #define _malloc_stats_r(r) malloc_stats ()
  74. #else
  75. extern void _malloc_stats_r (struct _reent *);
  76. #endif
  77. extern int mallopt (int, int);
  78. #ifdef __CYGWIN__
  79. #undef _mallopt_r
  80. #define _mallopt_r(i1, i2) mallopt (i1, i2)
  81. #else
  82. extern int _mallopt_r (struct _reent *, int, int);
  83. #endif
  84. extern size_t malloc_usable_size (void *);
  85. #ifdef __CYGWIN__
  86. #undef _malloc_usable_size_r
  87. #define _malloc_usable_size_r(r, p) malloc_usable_size (p)
  88. #else
  89. extern size_t _malloc_usable_size_r (struct _reent *, void *);
  90. #endif
  91. /* These aren't too useful on an embedded system, but we define them
  92. anyhow. */
  93. extern void *valloc (size_t);
  94. #ifdef __CYGWIN__
  95. #undef _valloc_r
  96. #define _valloc_r(r, s) valloc (s)
  97. #else
  98. extern void *_valloc_r (struct _reent *, size_t);
  99. #endif
  100. extern void *pvalloc (size_t);
  101. #ifdef __CYGWIN__
  102. #undef _pvalloc_r
  103. #define _pvalloc_r(r, s) pvalloc (s)
  104. #else
  105. extern void *_pvalloc_r (struct _reent *, size_t);
  106. #endif
  107. extern int malloc_trim (size_t);
  108. #ifdef __CYGWIN__
  109. #undef _malloc_trim_r
  110. #define _malloc_trim_r(r, s) malloc_trim (s)
  111. #else
  112. extern int _malloc_trim_r (struct _reent *, size_t);
  113. #endif
  114. extern void __malloc_lock(struct _reent *);
  115. extern void __malloc_unlock(struct _reent *);
  116. /* A compatibility routine for an earlier version of the allocator. */
  117. extern void mstats (char *);
  118. #ifdef __CYGWIN__
  119. #undef _mstats_r
  120. #define _mstats_r(r, p) mstats (p)
  121. #else
  122. extern void _mstats_r (struct _reent *, char *);
  123. #endif
  124. /* SVID2/XPG mallopt options */
  125. #define M_MXFAST 1 /* UNUSED in this malloc */
  126. #define M_NLBLKS 2 /* UNUSED in this malloc */
  127. #define M_GRAIN 3 /* UNUSED in this malloc */
  128. #define M_KEEP 4 /* UNUSED in this malloc */
  129. /* mallopt options that actually do something */
  130. #define M_TRIM_THRESHOLD -1
  131. #define M_TOP_PAD -2
  132. #define M_MMAP_THRESHOLD -3
  133. #define M_MMAP_MAX -4
  134. #ifndef __CYGWIN__
  135. /* Some systems provide this, so do too for compatibility. */
  136. extern void cfree (void *);
  137. #endif /* __CYGWIN__ */
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. #endif /* _INCLUDE_MALLOC_H_ */