4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-21 05:49:19 +08:00
Matt Joyce ea99f21ce6 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-07-13 06:55:46 +02:00

66 lines
1.5 KiB
C

/*
* 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
INDEX
gmtime_r
SYNOPSIS
#include <time.h>
struct tm *gmtime(const time_t *<[clock]>);
struct tm *gmtime_r(const time_t *<[clock]>, struct tm *<[res]>);
DESCRIPTION
<<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.
<<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
#ifdef _REENT_THREAD_LOCAL
_Thread_local struct __tm _tls_localtime_buf;
#endif
#ifndef _REENT_ONLY
struct tm *
gmtime (const time_t * tim_p)
{
struct _reent *reent = _REENT;
_REENT_CHECK_TM(reent);
return gmtime_r (tim_p, (struct tm *)_REENT_TM(reent));
}
#endif