Rev 4921 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6607 | serge | 1 | #ifndef MALLOC_PROVIDED |
2 | /* |
||
3 | FUNCTION |
||
4 | <<__malloc_lock>>, <<__malloc_unlock>>---lock malloc pool |
||
5 | |||
6 | INDEX |
||
7 | __malloc_lock |
||
8 | INDEX |
||
9 | __malloc_unlock |
||
10 | |||
11 | ANSI_SYNOPSIS |
||
12 | #include |
||
13 | void __malloc_lock (struct _reent *<[reent]>); |
||
14 | void __malloc_unlock (struct _reent *<[reent]>); |
||
15 | |||
16 | TRAD_SYNOPSIS |
||
17 | void __malloc_lock(<[reent]>) |
||
18 | struct _reent *<[reent]>; |
||
19 | |||
20 | void __malloc_unlock(<[reent]>) |
||
21 | struct _reent *<[reent]>; |
||
22 | |||
23 | DESCRIPTION |
||
24 | The < |
||
25 | the memory pool. The version of these routines supplied in the library use |
||
26 | the lock API defined in sys/lock.h. If multiple threads of execution can |
||
27 | call < |
||
28 | define your own versions of these functions in order to safely lock the |
||
29 | memory pool during a call. If you do not, the memory pool may become |
||
30 | corrupted. |
||
31 | |||
32 | A call to < |
||
33 | the sequence of calls may go <<__malloc_lock>>, <<__malloc_lock>>, |
||
34 | <<__malloc_unlock>>, <<__malloc_unlock>>. Any implementation of these |
||
35 | routines must be careful to avoid causing a thread to wait for a lock |
||
36 | that it already holds. |
||
37 | */ |
||
38 | |||
39 | #include |
||
40 | #include |
||
41 | |||
42 | #ifndef __SINGLE_THREAD__ |
||
43 | __LOCK_INIT_RECURSIVE(static, __malloc_lock_object); |
||
44 | #endif |
||
45 | |||
46 | void |
||
47 | __malloc_lock (ptr) |
||
48 | struct _reent *ptr; |
||
49 | { |
||
50 | #ifndef __SINGLE_THREAD__ |
||
51 | __lock_acquire_recursive (__malloc_lock_object); |
||
52 | #endif |
||
53 | } |
||
54 | |||
55 | void |
||
56 | __malloc_unlock (ptr) |
||
57 | struct _reent *ptr; |
||
58 | { |
||
59 | #ifndef __SINGLE_THREAD__ |
||
60 | __lock_release_recursive (__malloc_lock_object); |
||
61 | #endif |
||
62 | } |
||
63 | |||
64 | #endif<__malloc_unlock><__malloc_unlock><__malloc_lock><__malloc_lock><__malloc_lock> |