ndk_cruft.cpp revision cfd5a46b092536905ffe45a19cfe1b9e35aa8d10
1744f5739019d1fd917f981e740b353c3d73fd1a8David Smith/*
2744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * Copyright (C) 2013 The Android Open Source Project
3744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * All rights reserved.
4744f5739019d1fd917f981e740b353c3d73fd1a8David Smith *
5744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * Redistribution and use in source and binary forms, with or without
6744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * modification, are permitted provided that the following conditions
7744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * are met:
8744f5739019d1fd917f981e740b353c3d73fd1a8David Smith *  * Redistributions of source code must retain the above copyright
9744f5739019d1fd917f981e740b353c3d73fd1a8David Smith *    notice, this list of conditions and the following disclaimer.
10744f5739019d1fd917f981e740b353c3d73fd1a8David Smith *  * Redistributions in binary form must reproduce the above copyright
11744f5739019d1fd917f981e740b353c3d73fd1a8David Smith *    notice, this list of conditions and the following disclaimer in
12744f5739019d1fd917f981e740b353c3d73fd1a8David Smith *    the documentation and/or other materials provided with the
13744f5739019d1fd917f981e740b353c3d73fd1a8David Smith *    distribution.
14744f5739019d1fd917f981e740b353c3d73fd1a8David Smith *
15744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25e7f4e676bb88b17241d71731f9ea50c18cfcb039David Smith * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26744f5739019d1fd917f981e740b353c3d73fd1a8David Smith * SUCH DAMAGE.
27744f5739019d1fd917f981e740b353c3d73fd1a8David Smith */
28744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
29744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// This file perpetuates the mistakes of the past.
30744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
31744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <ctype.h>
32744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <dirent.h>
33744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <errno.h>
34744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <inttypes.h>
35744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <pthread.h>
36744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <signal.h>
378f469e18c307cb9dc0d16ed9225972aa8be4516fChong Zhang#include <stdio.h>
38d291c222357303b9611cab89d0c3b047584ef377Chong Zhang#include <stdlib.h>
39744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <string.h>
40744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <sys/resource.h>
41744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <sys/syscall.h>
42744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <sys/time.h>
43744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <sys/types.h>
44744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <sys/wait.h>
45744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <unistd.h>
46744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include <wchar.h>
47744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
48744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include "private/libc_logging.h"
49744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
50744f5739019d1fd917f981e740b353c3d73fd1a8David Smithextern "C" {
51744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
52744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// Brillo doesn't need to support any legacy cruft.
53744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#if !defined(__BRILLO__)
54744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
55744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// Most of the cruft is only for 32-bit Android targets.
56744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#if !defined(__LP64__)
57744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
58744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// These were accidentally declared in <unistd.h> because we stupidly used to inline
59744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// getpagesize() and __getpageshift(). Needed for backwards compatibility with old NDK apps.
60744f5739019d1fd917f981e740b353c3d73fd1a8David Smithunsigned int __page_size = PAGE_SIZE;
61744f5739019d1fd917f981e740b353c3d73fd1a8David Smithunsigned int __page_shift = 12;
62744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
63744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// TODO: remove this backward compatibility hack (for jb-mr1 strace binaries).
64744f5739019d1fd917f981e740b353c3d73fd1a8David Smithpid_t __wait4(pid_t pid, int* status, int options, struct rusage* rusage) {
65744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  return wait4(pid, status, options, rusage);
66744f5739019d1fd917f981e740b353c3d73fd1a8David Smith}
67744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
68744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// TODO: does anything still need this?
69744f5739019d1fd917f981e740b353c3d73fd1a8David Smithint __open() {
70744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  abort();
71744f5739019d1fd917f981e740b353c3d73fd1a8David Smith}
72744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
73744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// TODO: does anything still need this?
74744f5739019d1fd917f981e740b353c3d73fd1a8David Smithvoid** __get_tls() {
75744f5739019d1fd917f981e740b353c3d73fd1a8David Smith#include "private/__get_tls.h"
76744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  return __get_tls();
77744f5739019d1fd917f981e740b353c3d73fd1a8David Smith}
78744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
79744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// This non-standard function was in our <string.h> for some reason.
80744f5739019d1fd917f981e740b353c3d73fd1a8David Smithvoid memswap(void* m1, void* m2, size_t n) {
81744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  char* p = reinterpret_cast<char*>(m1);
82744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  char* p_end = p + n;
83744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  char* q = reinterpret_cast<char*>(m2);
84744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  while (p < p_end) {
85744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    char tmp = *p;
86744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    *p = *q;
87744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    *q = tmp;
88744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    p++;
89744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    q++;
90744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  }
91744f5739019d1fd917f981e740b353c3d73fd1a8David Smith}
92744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
93744f5739019d1fd917f981e740b353c3d73fd1a8David Smithint pthread_attr_setstackaddr(pthread_attr_t*, void*) {
94744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  // This was removed from POSIX.1-2008, and is not implemented on bionic.
95744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  // Needed for ABI compatibility with the NDK.
96744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  return ENOSYS;
97744f5739019d1fd917f981e740b353c3d73fd1a8David Smith}
98744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
99744f5739019d1fd917f981e740b353c3d73fd1a8David Smithint pthread_attr_getstackaddr(const pthread_attr_t* attr, void** stack_addr) {
100744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  // This was removed from POSIX.1-2008.
101744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  // Needed for ABI compatibility with the NDK.
102744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  *stack_addr = (char*)attr->stack_base + attr->stack_size;
103744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  return 0;
104744f5739019d1fd917f981e740b353c3d73fd1a8David Smith}
105744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
106744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// Non-standard cruft that should only ever have been in system/core/toolbox.
107744f5739019d1fd917f981e740b353c3d73fd1a8David Smithchar* strtotimeval(const char* str, struct timeval* ts) {
108744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  char* s;
109744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  ts->tv_sec = strtoumax(str, &s, 10);
110744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
111744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  long fractional_seconds = 0;
112744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  if (*s == '.') {
113744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    s++;
114744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    int count = 0;
115744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
116744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    // Read up to 6 digits (microseconds).
117744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    while (*s && isdigit(*s)) {
118744f5739019d1fd917f981e740b353c3d73fd1a8David Smith      if (++count < 7) {
119744f5739019d1fd917f981e740b353c3d73fd1a8David Smith        fractional_seconds = fractional_seconds*10 + (*s - '0');
120744f5739019d1fd917f981e740b353c3d73fd1a8David Smith      }
121744f5739019d1fd917f981e740b353c3d73fd1a8David Smith      s++;
122744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    }
123744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
124744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    for (; count < 6; count++) {
125744f5739019d1fd917f981e740b353c3d73fd1a8David Smith      fractional_seconds *= 10;
126744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    }
127744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  }
128744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
129744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  ts->tv_usec = fractional_seconds;
130744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  return s;
131744f5739019d1fd917f981e740b353c3d73fd1a8David Smith}
132744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
133744f5739019d1fd917f981e740b353c3d73fd1a8David Smithstatic inline int digitval(int ch) {
134744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  unsigned d;
135e7f4e676bb88b17241d71731f9ea50c18cfcb039David Smith
136744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  d = (unsigned)(ch - '0');
137744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  if (d < 10) return (int)d;
138744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
139744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  d = (unsigned)(ch - 'a');
140744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  if (d < 6) return (int)(d+10);
141744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
142744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  d = (unsigned)(ch - 'A');
143744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  if (d < 6) return (int)(d+10);
144744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
145744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  return -1;
146744f5739019d1fd917f981e740b353c3d73fd1a8David Smith}
147744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
148744f5739019d1fd917f981e740b353c3d73fd1a8David Smith// This non-standard function was in our <inttypes.h> for some reason.
149744f5739019d1fd917f981e740b353c3d73fd1a8David Smithuintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n) {
150744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  const unsigned char*  p   = (const unsigned char *)nptr;
151744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  const unsigned char*  end = p + n;
152744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  int                   minus = 0;
153744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  uintmax_t             v = 0;
154744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  int                   d;
155744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
156744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  while (p < end && isspace(*p)) {
157744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    p++;
158744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  }
159744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
160e7f4e676bb88b17241d71731f9ea50c18cfcb039David Smith  if (p < end) {
161e7f4e676bb88b17241d71731f9ea50c18cfcb039David Smith    char c = p[0];
162e7f4e676bb88b17241d71731f9ea50c18cfcb039David Smith    if (c == '-' || c == '+') {
163744f5739019d1fd917f981e740b353c3d73fd1a8David Smith      minus = (c == '-');
164744f5739019d1fd917f981e740b353c3d73fd1a8David Smith      p++;
165744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    }
166744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  }
167744f5739019d1fd917f981e740b353c3d73fd1a8David Smith
168744f5739019d1fd917f981e740b353c3d73fd1a8David Smith  if (base == 0) {
169744f5739019d1fd917f981e740b353c3d73fd1a8David Smith    if (p+2 < end && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
170      p += 2;
171      base = 16;
172    } else if (p+1 < end && p[0] == '0') {
173      p   += 1;
174      base = 8;
175    } else {
176      base = 10;
177    }
178  } else if (base == 16) {
179    if (p+2 < end && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) {
180      p += 2;
181    }
182  }
183
184  while (p < end && (d = digitval(*p)) >= 0 && d < base) {
185    v = v*base + d;
186    p += 1;
187  }
188
189  if (endptr) {
190    *endptr = (char*) p;
191  }
192
193  return minus ? -v : v;
194}
195
196// This non-standard function was in our <inttypes.h> for some reason.
197intmax_t strntoimax(const char* nptr, char** endptr, int base, size_t n) {
198  return (intmax_t) strntoumax(nptr, endptr, base, n);
199}
200
201// POSIX calls this dprintf, but LP32 Android had fdprintf instead.
202int fdprintf(int fd, const char* fmt, ...) {
203  va_list ap;
204  va_start(ap, fmt);
205  int rc = vdprintf(fd, fmt, ap);
206  va_end(ap);
207  return rc;
208}
209
210// POSIX calls this vdprintf, but LP32 Android had fdprintf instead.
211int vfdprintf(int fd, const char* fmt, va_list ap) {
212  return vdprintf(fd, fmt, ap);
213}
214
215#define __futex_wake __real_futex_wake
216#define __futex_wait __real_futex_wait
217#include "private/bionic_futex.h"
218#undef __futex_wake
219#undef __futex_wait
220
221// This used to be in <sys/atomics.h>.
222int __futex_wake(volatile void* ftx, int count) {
223  return __real_futex_wake(ftx, count);
224}
225
226// This used to be in <sys/atomics.h>.
227int __futex_wait(volatile void* ftx, int value, const struct timespec* timeout) {
228  return __real_futex_wait(ftx, value, timeout);
229}
230
231// Unity's libmono uses this.
232int tkill(pid_t tid, int sig) {
233  return syscall(__NR_tkill, tid, sig);
234}
235
236// This was removed from POSIX 2008.
237wchar_t* wcswcs(wchar_t* haystack, wchar_t* needle) {
238  return wcsstr(haystack, needle);
239}
240
241// This was removed from POSIX 2008.
242sighandler_t bsd_signal(int signum, sighandler_t handler) {
243  return signal(signum, handler);
244}
245
246#if !defined(__i386__)
247// This was removed from POSIX 2008.
248#undef bcopy
249void bcopy(const void* src, void* dst, size_t n) {
250  memcpy(dst, src, n);
251}
252#else
253// x86 has an assembler implementation.
254#endif
255
256// sysv_signal() was never in POSIX.
257extern "C++" sighandler_t _signal(int signum, sighandler_t handler, int flags);
258sighandler_t sysv_signal(int signum, sighandler_t handler) {
259  return _signal(signum, handler, SA_RESETHAND);
260}
261
262// This is a system call that was never in POSIX. Use readdir(3) instead.
263int __getdents64(unsigned int, dirent*, unsigned int);
264int getdents(unsigned int fd, dirent* dirp, unsigned int count) {
265  return __getdents64(fd, dirp, count);
266}
267
268// This is a BSDism that we never implemented correctly. Used by Firefox.
269int issetugid() {
270  return 0;
271}
272
273// This was removed from POSIX 2004.
274pid_t wait3(int* status, int options, struct rusage* rusage) {
275  return wait4(-1, status, options, rusage);
276}
277
278// This was removed from POSIX 2004.
279int getdtablesize() {
280  struct rlimit r;
281
282  if (getrlimit(RLIMIT_NOFILE, &r) < 0) {
283    return sysconf(_SC_OPEN_MAX);
284  }
285
286  return r.rlim_cur;
287}
288
289// A leaked BSD stdio implementation detail that's now a no-op.
290void __sinit() {}
291int __sdidinit = 1;
292
293// Only used by ftime, which was removed from POSIX 2008.
294struct timeb {
295  time_t          time;
296  unsigned short  millitm;
297  short           timezone;
298  short           dstflag;
299};
300
301// This was removed from POSIX 2008.
302int ftime(struct timeb* tb) {
303  struct timeval  tv;
304  struct timezone tz;
305
306  if (gettimeofday(&tv, &tz) < 0)
307    return -1;
308
309  tb->time    = tv.tv_sec;
310  tb->millitm = (tv.tv_usec + 500) / 1000;
311
312  if (tb->millitm == 1000) {
313    ++tb->time;
314    tb->millitm = 0;
315  }
316
317  tb->timezone = tz.tz_minuteswest;
318  tb->dstflag  = tz.tz_dsttime;
319
320  return 0;
321}
322
323// This was removed from POSIX 2008.
324char* index(const char* str, int ch) {
325  return strchr(str, ch);
326}
327
328// This was removed from BSD.
329void arc4random_stir(void) {
330  // The current implementation stirs itself as needed.
331}
332
333// This was removed from BSD.
334void arc4random_addrandom(unsigned char*, int) {
335  // The current implementation adds randomness as needed.
336}
337
338// Old versions of the NDK did not export malloc_usable_size, but did
339// export dlmalloc_usable_size. We are moving away from dlmalloc in L
340// so make this call malloc_usable_size.
341size_t dlmalloc_usable_size(void* ptr) {
342  return malloc_usable_size(ptr);
343}
344
345// In L we added a public pthread_gettid_np, but some apps were using the private API.
346pid_t __pthread_gettid(pthread_t t) {
347  return pthread_gettid_np(t);
348}
349
350// Older versions of apportable used dlmalloc directly instead of malloc,
351// so export this compatibility shim that simply calls malloc.
352void* dlmalloc(size_t size) {
353  return malloc(size);
354}
355
356#define __get_thread __real_get_thread
357#include "pthread_internal.h"
358#undef __get_thread
359// Various third-party apps contain a backport of our pthread_rwlock implementation that uses this.
360pthread_internal_t* __get_thread() {
361  return __real_get_thread();
362}
363
364// This one exists only for the LP32 NDK and is not present anywhere else.
365extern long __set_errno_internal(int);
366long __set_errno(int n) {
367  return __set_errno_internal(n);
368}
369
370#endif // !defined(__LP64__)
371
372// This was never implemented in bionic, only needed for ABI compatibility with the NDK.
373// In the M time frame, over 1000 apps have a reference to this!
374void endpwent() { }
375
376// Since dlmalloc_inspect_all and dlmalloc_trim are exported for systems
377// that use dlmalloc, be consistent and export them everywhere.
378#if defined(USE_JEMALLOC)
379void dlmalloc_inspect_all(void (*)(void*, void*, size_t, void*), void*) {
380}
381int dlmalloc_trim(size_t) {
382    return 0;
383}
384#else
385void dlmalloc_inspect_all_real(void (*)(void*, void*, size_t, void*), void*);
386void dlmalloc_inspect_all(void (*handler)(void*, void*, size_t, void*), void* arg) {
387  dlmalloc_inspect_all_real(handler, arg);
388}
389int dlmalloc_trim_real(size_t);
390int dlmalloc_trim(size_t pad) {
391  return dlmalloc_trim_real(pad);
392}
393#endif
394
395#endif // !defined(__BRILLO__)
396
397} // extern "C"
398