OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [stdlib/] [mlock.c] - Blame information for rev 326

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
#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 <malloc.h>
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 <<malloc>> family of routines call these functions when they need to lock
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 <<malloc>>, or if <<malloc>> can be called reentrantly, then you need to
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 <<malloc>> may call <<__malloc_lock>> recursively; that is,
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 <malloc.h>
40
#include <sys/lock.h>
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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.