2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* gmtime.c
|
|
|
|
* Original Author: G. Haley
|
|
|
|
*
|
|
|
|
* Converts the calendar time pointed to by tim_p into a broken-down time
|
|
|
|
* expressed as Greenwich Mean Time (GMT). Returns a pointer to a structure
|
|
|
|
* containing the broken-down time, or a null pointer if GMT is not
|
|
|
|
* available.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
<<gmtime>>---convert time to UTC traditional form
|
|
|
|
|
|
|
|
INDEX
|
|
|
|
gmtime
|
2008-11-01 05:08:03 +08:00
|
|
|
INDEX
|
|
|
|
gmtime_r
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2017-11-30 16:22:31 +08:00
|
|
|
SYNOPSIS
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <time.h>
|
|
|
|
struct tm *gmtime(const time_t *<[clock]>);
|
|
|
|
struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>);
|
|
|
|
|
|
|
|
DESCRIPTION
|
2006-08-17 23:53:15 +08:00
|
|
|
<<gmtime>> takes the time at <[clock]> representing the number
|
|
|
|
of elapsed seconds since 00:00:00 on January 1, 1970, Universal
|
|
|
|
Coordinated Time (UTC, also known in some countries as GMT,
|
|
|
|
Greenwich Mean time) and converts it to a <<struct tm>>
|
|
|
|
representation.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
<<gmtime>> constructs the traditional time representation in static
|
|
|
|
storage; each call to <<gmtime>> or <<localtime>> will overwrite the
|
|
|
|
information generated by previous calls to either function.
|
|
|
|
|
|
|
|
RETURNS
|
|
|
|
A pointer to the traditional time representation (<<struct tm>>).
|
|
|
|
|
|
|
|
PORTABILITY
|
|
|
|
ANSI C requires <<gmtime>>.
|
|
|
|
|
|
|
|
<<gmtime>> requires no supporting OS subroutines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#define _GMT_OFFSET 0
|
|
|
|
|
Add --enable-newlib-reent-thread-local option
By default, Newlib uses a huge object of type struct _reent to store
thread-specific data. This object is returned by __getreent() if the
__DYNAMIC_REENT__ Newlib configuration option is defined.
The reentrancy structure contains for example errno and the standard input,
output, and error file streams. This means that if an application only uses
errno it has a dependency on the file stream support even if it does not use
it. This is an issue for lower end targets and applications which need to
qualify the software according to safety standards (for example ECSS-E-ST-40C,
ECSS-Q-ST-80C, IEC 61508, ISO 26262, DO-178, DO-330, DO-333).
If the new _REENT_THREAD_LOCAL configuration option is enabled, then struct
_reent is replaced by dedicated thread-local objects for each struct _reent
member. The thread-local objects are defined in translation units which use
the corresponding object.
2022-05-16 17:51:54 +08:00
|
|
|
#ifdef _REENT_THREAD_LOCAL
|
|
|
|
_Thread_local struct __tm _tls_localtime_buf;
|
|
|
|
#endif
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifndef _REENT_ONLY
|
|
|
|
|
|
|
|
struct tm *
|
2017-12-04 11:43:30 +08:00
|
|
|
gmtime (const time_t * tim_p)
|
2000-02-18 03:39:52 +08:00
|
|
|
{
|
2013-04-30 05:06:23 +08:00
|
|
|
struct _reent *reent = _REENT;
|
|
|
|
|
|
|
|
_REENT_CHECK_TM(reent);
|
|
|
|
return gmtime_r (tim_p, (struct tm *)_REENT_TM(reent));
|
2000-02-18 03:39:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|