Report S2EVENT_CONNECT when a new SSID is selected.
[AROS.git] / arch / all-linux / bootstrap / malloc.c
blob82b7181bf8673ec331f35ef5891a551194facbf5
1 /*
2 * AROS-thread-safe versions of libc memory allocation routines
3 * This does not work with Android's bionic.
4 */
6 /* TODO:
7 This code is compiled with the kernel compiler but calls code
8 from exec.library. This can only work if function calling
9 convention for kernel and target compiler are the same.
10 Up to now this seems to be the case for all linux hosted ports
11 as UNIX calling is often taken as reference for the AROS
12 implementation.
15 #ifndef __ANDROID__
17 #include <proto/exec.h>
18 #include <sys/types.h>
20 static int memnest;
21 #define MEMLOCK if (SysBase != NULL) Forbid();
22 #define MEMUNLOCK if (SysBase != NULL) Permit();
24 extern struct ExecBase *SysBase;
25 extern void * __libc_malloc(size_t);
26 extern void __libc_free(void *);
27 extern void * __libc_calloc(size_t, size_t);
28 extern void * __libc_realloc(void * mem, size_t newsize);
30 void * malloc(size_t size)
32 void *res;
34 MEMLOCK
35 memnest++;
36 res = __libc_malloc(size);
37 memnest--;
38 MEMUNLOCK
40 return res;
43 void free(void * addr)
45 MEMLOCK
46 memnest++;
47 __libc_free(addr);
48 memnest--;
49 MEMUNLOCK
52 void * calloc(size_t n, size_t size)
54 void *res;
56 MEMLOCK
57 memnest++;
58 res = __libc_calloc(n, size);
59 memnest--;
60 MEMUNLOCK
62 return res;
65 void *realloc(void *ptr, size_t size)
67 void *res;
69 MEMLOCK
70 memnest++;
71 res = __libc_realloc(ptr, size);
72 memnest--;
73 MEMUNLOCK;
75 return res;
78 #endif