Esempio n. 1
0
struct tm *
gmtime(const time_t * const timep)
{
	static pthread_mutex_t gmtime_mutex = PTHREAD_MUTEX_INITIALIZER;
	static pthread_key_t gmtime_key = -1;
	struct tm *p_tm;

	if (__isthreaded != 0) {
		if (gmtime_key < 0) {
			_pthread_mutex_lock(&gmtime_mutex);
			if (gmtime_key < 0) {
				if (_pthread_key_create(&gmtime_key, free) < 0) {
					_pthread_mutex_unlock(&gmtime_mutex);
					return(NULL);
				}
			}
			_pthread_mutex_unlock(&gmtime_mutex);
		}
		/*
		 * Changed to follow POSIX.1 threads standard, which
		 * is what BSD currently has.
		 */
		if ((p_tm = _pthread_getspecific(gmtime_key)) == NULL) {
			if ((p_tm = (struct tm *)malloc(sizeof(struct tm)))
			    == NULL) {
				return(NULL);
			}
			_pthread_setspecific(gmtime_key, p_tm);
		}
		return gmtsub(timep, 0L, p_tm);
	} else {
		return gmtsub(timep, 0L, &tm);
	}
}
Esempio n. 2
0
struct pg_tm *
pg_gmtime(const pg_time_t *timep)
{
	return gmtsub(timep, 0L, &tm);
}
Esempio n. 3
0
struct pg_tm *
pg_gmtime_r(const pg_time_t *timep, struct pg_tm *tm)
{
	return gmtsub(timep, 0L, tm);
}
Esempio n. 4
0
struct tm *
offtime(const time_t * const timep, const long offset)
{
	return gmtsub(timep, offset, &tm);
}
Esempio n. 5
0
struct tm *
gmtime_r(const time_t * timep, struct tm * tmp)
{
	return gmtsub(timep, 0L, tmp);
}