source: trunk/libs/newlib/src/newlib/libc/time/tzlock.c @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.2 KB
Line 
1/*
2FUNCTION
3<<__tz_lock>>, <<__tz_unlock>>---lock time zone global variables
4
5INDEX
6        __tz_lock
7INDEX
8        __tz_unlock
9
10SYNOPSIS
11        #include "local.h"
12        void __tz_lock (void);
13        void __tz_unlock (void);
14
15DESCRIPTION
16The <<tzset>> facility functions call these functions when they need to
17ensure the values of global variables.  The version of these routines
18supplied in the library use the lock API defined in sys/lock.h.  If multiple
19threads of execution can call the time functions and give up scheduling in
20the middle, then you you need to define your own versions of these functions
21in order to safely lock the time zone variables during a call.  If you do
22not, the results of <<localtime>>, <<mktime>>, <<ctime>>, and <<strftime>>
23are undefined.
24
25The lock <<__tz_lock>> may not be called recursively; that is,
26a call <<__tz_lock>> will always lock all subsequent <<__tz_lock>> calls
27until the corresponding <<__tz_unlock>> call on the same thread is made.
28*/
29
30#include <_ansi.h>
31#include "local.h"
32#include <sys/lock.h>
33
34#ifndef __SINGLE_THREAD__
35__LOCK_INIT(static, __tz_mutex);
36#endif
37
38void
39__tz_lock (void)
40{
41#ifndef __SINGLE_THREAD__
42  __lock_acquire(__tz_mutex);
43#endif
44}
45
46void
47__tz_unlock (void)
48{
49#ifndef __SINGLE_THREAD__
50  __lock_release(__tz_mutex);
51#endif
52}
Note: See TracBrowser for help on using the repository browser.