Commit Graph

47 Commits

Author SHA1 Message Date
kamil 7f4b5eb156 Add timespec_get(3) in <time.h> and enable unconditionally struct timespec
These changes conforms to the C11 standard
References:
 - 7.27.1/3 Components of time (struct timespec)
 - 7.27.2.5 The timespec_get function

According to ISO/IEC 9899:201x (draft) <time.h> defines the timespec
structure and declares the timespec_get(3) function with TIME_UTC
definition.

According to a C++17 standard draft <ctime> offers the same interface in
the std:: namespace.

The timespec_get function modifies the timespec object pointed by ts
to hold the current calendar time in the given base. The standard notes
only the TIME_UTC base with implementation defined value, set it to 1
as zero is reserved for error handling. Once operation was successful this
function returns passed base, otherwise exits with zero.

The timespec struct was already part of the POSIX standard in <time.h>.

Enable this interface unconditionally in the header to allow to use it
in a code prior C11 and C++17 as an extension.

Review notes from <christos>
2016-10-04 09:41:40 +00:00
christos ac892fb52b add clock_cpugetclockid{2,} 2016-04-23 23:10:10 +00:00
christos 1136c97c1c add tzgetgmtoff 2015-10-29 17:48:55 +00:00
christos 3a0f0eb646 sync function signatures with tzcode 2014-10-07 21:50:36 +00:00
joerg e91cf89069 strftime_l is part of POSIX2008. 2013-04-21 17:54:56 +00:00
joerg 99fac95b50 Store time-specific locale data directly in the locale.
Ad dstrftime_l, strftime_lz and strptime_l.
2013-04-21 17:45:46 +00:00
christos 71bbc99990 add clock_nanosleep 2012-10-02 01:42:06 +00:00
christos 5a87b22ec6 Provide a re-entrant and thread-safe set of timezone API's that
don't require locking and can operate on user-specified timezones
as opposed to having to alter the environment to change a timezone.
This work was presented to the tzcode folks and it was generally
accepted, but there seems to be a lot of inertia.
2010-12-16 18:36:47 +00:00
ginsbach c8da0e5fef Add the getdate(3) function and getdate_err value, conforming to IEEE
Std 1003.1 (``POSIX.1'') and the Open Group Base Specifications X/Open
System Interfaces extension (``XSI'').
2009-05-14 02:37:35 +00:00
christos 50728e7823 merge christos-time_t 2009-01-11 02:57:17 +00:00
christos 9fa41d7348 add missing attributes to the remaining calls, even the ones that gcc has
builtin attributes for (for symmetry and consistency). In the future this
might change to use compiler-neutral macros. On the other hand I don't
know of any other compiler that provides other macros with similar
functionality, so why bother?
2008-09-21 16:59:46 +00:00
drochner 7cc98087b6 everyone else assumes that defining "_XOPEN_SOURCE" means XPG4.2,
so remove comparisions against the numerical values "3" or "4"
2008-04-01 19:23:28 +00:00
christos 66412e7240 compat code reorg 2005-09-13 01:44:32 +00:00
perry 19b7469a00 de-__P -- the hack is long since useless. Discussed with christos,
matt, kleink, others. Approved by christos.
2005-02-03 04:39:32 +00:00
kleink 413b3367fe Do a little const cleanup, for consistency with std interfaces. 2003-12-21 23:19:02 +00:00
kleink 9865e7ff1d Sprinkle restrict into timer_{create,settime}(2). 2003-09-13 22:31:04 +00:00
agc 039cc95684 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22270, verified by myself.
2003-08-07 09:44:09 +00:00
bjh21 4be7a2dcf3 Add a new feature-test macro, _NETBSD_SOURCE. If this is defined
by the application, all NetBSD interfaces are made visible, even
if some other feature-test macro (like _POSIX_C_SOURCE) is defined.
<sys/featuretest.h> defined _NETBSD_SOURCE if none of _ANSI_SOURCE,
_POSIX_C_SOURCE and _XOPEN_SOURCE is defined, so as to preserve
existing behaviour.

This has two major advantages:
+ Programs that require non-POSIX facilities but define _POSIX_C_SOURCE
  can trivially be overruled by putting -D_NETBSD_SOURCE in their CFLAGS.
+ It makes most of the #ifs simpler, in that they're all now ORs of the
  various macros, rather than having checks for (!defined(_ANSI_SOURCE) ||
  !defined(_POSIX_C_SOURCE) || !defined(_XOPEN_SOURCE)) all over the place.

I've tried not to change the semantics of the headers in any case where
_NETBSD_SOURCE wasn't defined, but there were some places where the
current semantics were clearly mad, and retaining them was harder than
correcting them.  In particular, I've mostly normalised things so that
_ANSI_SOURCE gets you the smallest set of stuff, then _POSIX_C_SOURCE,
_XOPEN_SOURCE and _NETBSD_SOURCE in that order.

Tested by building for vax, encouraged by thorpej, and uncontested in
tech-userlevel for a week.
2003-04-28 23:16:11 +00:00
bjh21 c1ba727b47 Version times() so that programs compiled before the recent change to make
sysconf(_SC_CLK_TCK) return hz will work.

In detail:
__times13() returns values scaled by hz.
times() returns values scaled by 100.
<sys/times.h> renames times() to __times13().

_SC_CLK_TCK has changed from 3 to 39.
sysconf(3) returns 100.
sysconf(39) returns hz.
CLK_TCK is defined as sysconf(39).
2002-06-30 09:45:39 +00:00
perry 25e1b60346 In the manner of Solaris and other OSes, we now define CLK_TCK to
expand to a call to __sysconf(_SC_CLK_TCK), rather than hard coding it
as a constant.
2002-06-23 19:41:04 +00:00
kleink a495a577a0 Finally deprecate the old timezone() interface in favor of an XSH5
timezone/daytime pair; as proposed by J.T. in September, 1996.
Fixes PR standards/11807 by Nick Hudson.
2001-03-31 18:29:20 +00:00
kleink 8ca649a389 Sprinkle some restrict. 2001-03-29 19:06:39 +00:00
hubertf 770f687519 Fix typo in comment: CUT -> UTC 2000-07-06 12:46:48 +00:00
kleink 1bba558e50 Move <null.h> to <sys/null.h> for the purpose of avoiding conflicts due to
std C headers including it, and a kernel module written in C++ would benfit
as well.
2000-01-10 16:58:38 +00:00
kleink c07f17e8d9 For the benefit of G++'s null pointer constant implementation, #define NULL
as __null with egcs 1.0 (GCC 2.90) and above.  As several headers are affected
by this change, move the definition into a new header file, <null.h>, to ease
maintenance.
1999-12-22 21:26:15 +00:00
kleink 866c9e7b5d Remove the public declaration of gtime(), which is shipped with tzcode but is
not compiled into our libc since it is intended for use with Mach only.
1998-09-15 12:24:28 +00:00
kleink 9db5e6b9bf Declare asctime_r(), ctime_r(), gmtime_r() and localtime_r(), and rearrange
name space protection a bit.
1998-09-10 18:37:28 +00:00
mycroft 29916a94a6 Slight rearrangement. 1998-07-27 11:09:19 +00:00
mycroft b8f6f58d3b Need cdefs.h. 1998-07-27 11:08:38 +00:00
mycroft 633b8f45a9 Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software.  *sigh*
1998-07-27 09:09:03 +00:00
mycroft bb96d7f5ba const poisoning. 1998-07-26 12:58:15 +00:00
mycroft 79788fe0d2 const poisoning. 1998-07-26 12:47:38 +00:00
perry b7b7322c68 merge lite-2 1998-02-02 21:07:13 +00:00
kleink d7a71d0ef9 * Move prototypes of clock_getres(), clock_gettime() and clock_settime() from
<sys/time.h> to this file.
* Update range comment wrt. the tm_sec member of struct tm to [0-61] (double
  leap seconds are supported).
1997-11-02 18:31:38 +00:00
kleink 7ebb8314c4 Per 1003.1b-93, move nanosleep() prototype from <sys/time.h> to <time.h>
and add appropriate namespace protection.  Also protect timer_*() prototypes.
1997-10-04 15:00:42 +00:00
christos 8115e016aa Add typedefs for clockid_t and timer_t 1997-07-13 18:32:18 +00:00
christos 34eb75ff52 - Added prototypes for non POSIX that are marked STD inspired:
offtime, timelocal, timegm, timeoff, gtime, time2posix, posix2time.
- Added prototypes for the currently stubbed out timer functions:
    timer_{create,delete,getoverrun,gettime,settime}
1997-07-13 18:09:51 +00:00
kleink 936cbaf003 Add strptime(3) prototype. 1997-05-26 16:03:58 +00:00
cgd 4d2cbfce0a new RCS ID format. 1994-10-26 00:55:40 +00:00
cgd 2922de7461 add _BSD's to ansi types 1994-05-21 09:41:59 +00:00
cgd e6b5ddd91e update all but ctype.h, dumprestore.h, time.h to 4.4-Lite versions.
USL copyright additions on those.  Kill varargs.h, because it can simply
be a link to the machine-dependent version.
1994-05-16 10:58:53 +00:00
jtc d5956614c6 Declare tzname[] extern, so compiler won't include it in object files. 1994-01-20 02:54:36 +00:00
jtc 7050b3fd65 declare char *tzname[2]; 1993-10-11 18:45:05 +00:00
jtc ed37f93ef0 As per Chris Torek's suggestion, define CLOCKS_PER_SEC and CLK_TCK to 100.
When we get sysconf, we can define them in terms of the kernel's notion of
interrupts per second if we so choose.  Until then, the constant value
seems to satisfy the requirements presented by ISO C and POSIX, even if it
may lie about the true number of clocks per second.
1993-08-18 01:02:58 +00:00
jtc d4cfab9dd1 Define CLOCKS_PER_SEC. 1993-08-17 20:33:56 +00:00
mycroft e9d867ef50 Add RCS identifiers. 1993-08-01 17:54:45 +00:00
cgd 61f282557f initial import of 386bsd-0.1 sources 1993-03-21 09:45:37 +00:00