Rev 5129 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5129 | Rev 5131 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ |
3 | /* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */ |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | #include |
5 | #include |
6 | #include |
6 | #include |
7 | #include |
- | |
Line 8... | Line 7... | ||
8 | #include |
7 | #include |
9 | 8 | ||
10 | typedef struct BLOCK { |
9 | typedef struct BLOCK { |
11 | size_t size; |
10 | size_t size; |
Line 21... | Line 20... | ||
21 | 20 | ||
22 | #define NUMSMALL 0 |
21 | #define NUMSMALL 0 |
23 | #define ALIGN 8 |
22 | #define ALIGN 8 |
Line 24... | Line 23... | ||
24 | #define SMALL (NUMSMALL*ALIGN) |
23 | #define SMALL (NUMSMALL*ALIGN) |
Line 25... | Line 24... | ||
25 | 24 | ||
26 | DECLARE_STATIC_SEM(malloc_mutex) |
25 | static int malloc_mutex = 0; |
27 | 26 | ||
28 | static BLOCK *slop = 0; |
27 | static BLOCK *slop = 0; |
29 | static BLOCK *freelist[30]; |
28 | static BLOCK *freelist[30]; |
Line 30... | Line 29... | ||
30 | #if NUMSMALL |
29 | #if NUMSMALL |
31 | static BLOCK *smallblocks[NUMSMALL]; |
30 | static BLOCK *smallblocks[NUMSMALL]; |
32 | #endif |
31 | #endif |
- | 32 | ||
33 | 33 | static inline void malloc_lock(void) |
|
Line 34... | Line 34... | ||
34 | static inline void malloc_lock(void) |
34 | { |
35 | { |
35 | while (__sync_lock_test_and_set(&malloc_mutex, 1)) |
36 | sem_lock(&malloc_mutex); |
36 | __menuet__delay100(1); |
37 | } |
37 | } |
Line 38... | Line 38... | ||
38 | 38 | ||
39 | static inline void malloc_unlock(void) |
39 | static inline void malloc_unlock(void) |