2002-04-18 05:23:31 +08:00
|
|
|
/*
|
|
|
|
FUNCTION
|
2005-10-29 05:21:08 +08:00
|
|
|
<<__tz_lock>>, <<__tz_unlock>>---lock time zone global variables
|
2002-04-18 05:23:31 +08:00
|
|
|
|
|
|
|
INDEX
|
|
|
|
__tz_lock
|
|
|
|
INDEX
|
|
|
|
__tz_unlock
|
|
|
|
|
2017-11-30 16:22:31 +08:00
|
|
|
SYNOPSIS
|
2002-04-18 05:23:31 +08:00
|
|
|
#include "local.h"
|
|
|
|
void __tz_lock (void);
|
|
|
|
void __tz_unlock (void);
|
|
|
|
|
|
|
|
DESCRIPTION
|
2004-09-17 05:16:59 +08:00
|
|
|
The <<tzset>> facility functions call these functions when they need to
|
|
|
|
ensure the values of global variables. The version of these routines
|
|
|
|
supplied in the library use the lock API defined in sys/lock.h. If multiple
|
|
|
|
threads of execution can call the time functions and give up scheduling in
|
|
|
|
the middle, then you you need to define your own versions of these functions
|
|
|
|
in order to safely lock the time zone variables during a call. If you do
|
|
|
|
not, the results of <<localtime>>, <<mktime>>, <<ctime>>, and <<strftime>>
|
|
|
|
are undefined.
|
2002-04-18 05:23:31 +08:00
|
|
|
|
|
|
|
The lock <<__tz_lock>> may not be called recursively; that is,
|
|
|
|
a call <<__tz_lock>> will always lock all subsequent <<__tz_lock>> calls
|
|
|
|
until the corresponding <<__tz_unlock>> call on the same thread is made.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <_ansi.h>
|
|
|
|
#include "local.h"
|
2004-09-17 05:16:59 +08:00
|
|
|
#include <sys/lock.h>
|
|
|
|
|
|
|
|
#ifndef __SINGLE_THREAD__
|
2017-01-29 17:27:17 +08:00
|
|
|
__LOCK_INIT(static, __tz_mutex);
|
2004-09-17 05:16:59 +08:00
|
|
|
#endif
|
2002-04-18 05:23:31 +08:00
|
|
|
|
2017-12-04 11:12:33 +08:00
|
|
|
void
|
2017-12-04 11:00:43 +08:00
|
|
|
__tz_lock (void)
|
2002-04-18 05:23:31 +08:00
|
|
|
{
|
2004-09-17 05:16:59 +08:00
|
|
|
#ifndef __SINGLE_THREAD__
|
2017-01-29 17:27:17 +08:00
|
|
|
__lock_acquire(__tz_mutex);
|
2004-09-17 05:16:59 +08:00
|
|
|
#endif
|
2002-04-18 05:23:31 +08:00
|
|
|
}
|
|
|
|
|
2017-12-04 11:12:33 +08:00
|
|
|
void
|
2017-12-04 11:00:43 +08:00
|
|
|
__tz_unlock (void)
|
2002-04-18 05:23:31 +08:00
|
|
|
{
|
2004-09-17 05:16:59 +08:00
|
|
|
#ifndef __SINGLE_THREAD__
|
2017-01-29 17:27:17 +08:00
|
|
|
__lock_release(__tz_mutex);
|
2004-09-17 05:16:59 +08:00
|
|
|
#endif
|
2002-04-18 05:23:31 +08:00
|
|
|
}
|