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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [stdlib/] [envlock.c] - Blame information for rev 455

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
<<__env_lock>>, <<__env_unlock>>---lock environ variable
4
 
5
INDEX
6
        __env_lock
7
INDEX
8
        __env_unlock
9
 
10
ANSI_SYNOPSIS
11
        #include <envlock.h>
12
        void __env_lock (struct _reent *<[reent]>);
13
        void __env_unlock (struct _reent *<[reent]>);
14
 
15
TRAD_SYNOPSIS
16
        void __env_lock(<[reent]>)
17
        struct _reent *<[reent]>;
18
 
19
        void __env_unlock(<[reent]>)
20
        struct _reent *<[reent]>;
21
 
22
DESCRIPTION
23
The <<setenv>> family of routines call these functions when they need to
24
modify the environ variable.  The version of these routines supplied in the
25
library use the lock API defined in sys/lock.h.  If multiple threads of
26
execution can call <<setenv>>, or if <<setenv>> can be called reentrantly,
27
then you need to define your own versions of these functions in order to
28
safely lock the memory pool during a call.  If you do not, the memory pool
29
may become corrupted.
30
 
31
A call to <<setenv>> may call <<__env_lock>> recursively; that is,
32
the sequence of calls may go <<__env_lock>>, <<__env_lock>>,
33
<<__env_unlock>>, <<__env_unlock>>.  Any implementation of these
34
routines must be careful to avoid causing a thread to wait for a lock
35
that it already holds.
36
*/
37
 
38
#include "envlock.h"
39
#include <sys/lock.h>
40
 
41
#ifndef __SINGLE_THREAD__
42
__LOCK_INIT_RECURSIVE(static, __env_lock_object);
43
#endif
44
 
45
void
46
__env_lock (ptr)
47
     struct _reent *ptr;
48
{
49
#ifndef __SINGLE_THREAD__
50
  __lock_acquire_recursive (__env_lock_object);
51
#endif
52
}
53
 
54
void
55
__env_unlock (ptr)
56
     struct _reent *ptr;
57
{
58
#ifndef __SINGLE_THREAD__
59
  __lock_release_recursive (__env_lock_object);
60
#endif
61
}

powered by: WebSVN 2.1.0

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