mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-20 05:49:08 +02:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
22fddb16f8 | ||
![]() |
abe3c8c332 | ||
![]() |
1d711a2ced | ||
![]() |
aff40cae08 | ||
![]() |
04a24db27a | ||
![]() |
b62f36f305 | ||
![]() |
2a3d521318 | ||
![]() |
149aafe198 | ||
![]() |
435825784f | ||
![]() |
31e9396bf2 | ||
![]() |
3b8416acab | ||
![]() |
94d0fb3c53 | ||
![]() |
e848f5aa29 | ||
![]() |
ee63bca525 | ||
![]() |
9cbd935d92 |
4
README
4
README
@@ -33,11 +33,11 @@ Source Repository
|
|||||||
|
|
||||||
The primary repository can be browsed at:
|
The primary repository can be browsed at:
|
||||||
|
|
||||||
<https://cgit.freedesktop.org/libbsd>
|
<https://gitlab.freedesktop.org/libbsd/libbsd>
|
||||||
|
|
||||||
and cloned from:
|
and cloned from:
|
||||||
|
|
||||||
<https://anongit.freedesktop.org/git/libbsd>
|
<https://gitlab.freedesktop.org/libbsd/libbsd.git>
|
||||||
|
|
||||||
|
|
||||||
Building from git source
|
Building from git source
|
||||||
|
21
configure.ac
21
configure.ac
@@ -18,7 +18,7 @@ AM_SILENT_RULES([yes])
|
|||||||
|
|
||||||
SOVERSION_MAJOR=0
|
SOVERSION_MAJOR=0
|
||||||
SOVERSION_MINOR=12
|
SOVERSION_MINOR=12
|
||||||
SOVERSION_PATCH=1
|
SOVERSION_PATCH=2
|
||||||
|
|
||||||
SOVERSION="$SOVERSION_MAJOR:$SOVERSION_MINOR:$SOVERSION_PATCH"
|
SOVERSION="$SOVERSION_MAJOR:$SOVERSION_MINOR:$SOVERSION_PATCH"
|
||||||
AC_SUBST([SOVERSION])
|
AC_SUBST([SOVERSION])
|
||||||
@@ -42,6 +42,8 @@ LIBBSD_LINKER_VERSION_SCRIPT
|
|||||||
|
|
||||||
is_windows=no
|
is_windows=no
|
||||||
|
|
||||||
|
api_time_macros=unknown
|
||||||
|
|
||||||
abi_accmode=unknown
|
abi_accmode=unknown
|
||||||
abi_arc4random=unknown
|
abi_arc4random=unknown
|
||||||
abi_arc4random_stir=unknown
|
abi_arc4random_stir=unknown
|
||||||
@@ -85,7 +87,9 @@ abi_vis=unknown
|
|||||||
abi_wcsl=unknown
|
abi_wcsl=unknown
|
||||||
|
|
||||||
AS_CASE([$host_os],
|
AS_CASE([$host_os],
|
||||||
[*-gnu*], [
|
[*-gnu* | gnu*], [
|
||||||
|
api_time_macros=no
|
||||||
|
|
||||||
abi_accmode=yes
|
abi_accmode=yes
|
||||||
# DROP: On glibc >= 2.36.
|
# DROP: On glibc >= 2.36.
|
||||||
#abi_arc4random=no
|
#abi_arc4random=no
|
||||||
@@ -145,6 +149,8 @@ AS_CASE([$host_os],
|
|||||||
abi_wcsl=yes
|
abi_wcsl=yes
|
||||||
],
|
],
|
||||||
[*-musl*], [
|
[*-musl*], [
|
||||||
|
api_time_macros=no
|
||||||
|
|
||||||
abi_accmode=yes
|
abi_accmode=yes
|
||||||
abi_arc4random=yes
|
abi_arc4random=yes
|
||||||
abi_arc4random_stir=yes
|
abi_arc4random_stir=yes
|
||||||
@@ -209,6 +215,8 @@ AS_CASE([$host_os],
|
|||||||
abi_wcsl=yes
|
abi_wcsl=yes
|
||||||
],
|
],
|
||||||
[darwin*], [
|
[darwin*], [
|
||||||
|
api_time_macros=no
|
||||||
|
|
||||||
abi_accmode=no
|
abi_accmode=no
|
||||||
abi_arc4random=no
|
abi_arc4random=no
|
||||||
abi_arc4random_stir=no
|
abi_arc4random_stir=no
|
||||||
@@ -255,6 +263,8 @@ AS_CASE([$host_os],
|
|||||||
abi_wcsl=no
|
abi_wcsl=no
|
||||||
],
|
],
|
||||||
[solaris2*], [
|
[solaris2*], [
|
||||||
|
api_time_macros=yes
|
||||||
|
|
||||||
abi_accmode=yes
|
abi_accmode=yes
|
||||||
abi_arc4random=no
|
abi_arc4random=no
|
||||||
abi_arc4random_stir=no
|
abi_arc4random_stir=no
|
||||||
@@ -301,6 +311,8 @@ AS_CASE([$host_os],
|
|||||||
abi_wcsl=yes
|
abi_wcsl=yes
|
||||||
],
|
],
|
||||||
[aix*], [
|
[aix*], [
|
||||||
|
api_time_macros=yes
|
||||||
|
|
||||||
abi_accmode=yes
|
abi_accmode=yes
|
||||||
abi_arc4random=yes
|
abi_arc4random=yes
|
||||||
abi_arc4random_stir=yes
|
abi_arc4random_stir=yes
|
||||||
@@ -545,6 +557,9 @@ AC_CHECK_FUNCS([\
|
|||||||
|
|
||||||
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
|
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
|
||||||
|
|
||||||
|
# API selection
|
||||||
|
LIBBSD_SELECT_API([time_macros], [time struct conversion macros])
|
||||||
|
|
||||||
# ABI selection
|
# ABI selection
|
||||||
LIBBSD_SELECT_ABI([accmode], [setmode()/getmode()])
|
LIBBSD_SELECT_ABI([accmode], [setmode()/getmode()])
|
||||||
LIBBSD_SELECT_ABI([arc4random], [arc4random() API])
|
LIBBSD_SELECT_ABI([arc4random], [arc4random() API])
|
||||||
@@ -586,7 +601,7 @@ LIBBSD_SELECT_ABI([strmode], [strmode()])
|
|||||||
LIBBSD_SELECT_ABI([strnstr], [strnstr()])
|
LIBBSD_SELECT_ABI([strnstr], [strnstr()])
|
||||||
LIBBSD_SELECT_ABI([strtonum], [strtonum()])
|
LIBBSD_SELECT_ABI([strtonum], [strtonum()])
|
||||||
LIBBSD_SELECT_ABI([strtox], [strtoi()/strtou()])
|
LIBBSD_SELECT_ABI([strtox], [strtoi()/strtou()])
|
||||||
LIBBSD_SELECT_ABI([timeconv], [timeconf.h API])
|
LIBBSD_SELECT_ABI([timeconv], [timeconv.h API])
|
||||||
LIBBSD_SELECT_ABI([transparent_libmd], [transparent libmd support])
|
LIBBSD_SELECT_ABI([transparent_libmd], [transparent libmd support])
|
||||||
LIBBSD_SELECT_ABI([vis], [vis API])
|
LIBBSD_SELECT_ABI([vis], [vis API])
|
||||||
LIBBSD_SELECT_ABI([wcsl], [wcslcpy()/wcslcat()])
|
LIBBSD_SELECT_ABI([wcsl], [wcslcpy()/wcslcat()])
|
||||||
|
@@ -99,6 +99,12 @@
|
|||||||
#define LIBBSD_GCC_VERSION 0
|
#define LIBBSD_GCC_VERSION 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LIBBSD_GCC_VERSION >= 0x0300 || __has_attribute(__unused__)
|
||||||
|
# define LIBBSD_UNUSED __attribute__((__unused__))
|
||||||
|
#else
|
||||||
|
# define LIBBSD_UNUSED
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LIBBSD_GCC_VERSION >= 0x0405 || __has_attribute(__deprecated__)
|
#if LIBBSD_GCC_VERSION >= 0x0405 || __has_attribute(__deprecated__)
|
||||||
#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x)))
|
#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x)))
|
||||||
#elif LIBBSD_GCC_VERSION >= 0x0301
|
#elif LIBBSD_GCC_VERSION >= 0x0301
|
||||||
@@ -150,11 +156,7 @@
|
|||||||
* Disable for now. */
|
* Disable for now. */
|
||||||
#if 0
|
#if 0
|
||||||
#ifndef __unused
|
#ifndef __unused
|
||||||
# if LIBBSD_GCC_VERSION >= 0x0300
|
# define __unused LIBBSD_UNUSED
|
||||||
# define __unused __attribute__((__unused__))
|
|
||||||
# else
|
|
||||||
# define __unused
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -385,7 +385,7 @@ struct { \
|
|||||||
#define RB_PROTOTYPE(name, type, field, cmp) \
|
#define RB_PROTOTYPE(name, type, field, cmp) \
|
||||||
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
|
RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
|
||||||
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \
|
#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \
|
||||||
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
|
RB_PROTOTYPE_INTERNAL(name, type, field, cmp, LIBBSD_UNUSED static)
|
||||||
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
|
#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \
|
||||||
attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \
|
attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \
|
||||||
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
|
attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
|
||||||
@@ -404,7 +404,7 @@ attr struct type *name##_RB_MINMAX(struct name *, int); \
|
|||||||
#define RB_GENERATE(name, type, field, cmp) \
|
#define RB_GENERATE(name, type, field, cmp) \
|
||||||
RB_GENERATE_INTERNAL(name, type, field, cmp,)
|
RB_GENERATE_INTERNAL(name, type, field, cmp,)
|
||||||
#define RB_GENERATE_STATIC(name, type, field, cmp) \
|
#define RB_GENERATE_STATIC(name, type, field, cmp) \
|
||||||
RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
|
RB_GENERATE_INTERNAL(name, type, field, cmp, LIBBSD_UNUSED static)
|
||||||
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
|
#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \
|
||||||
attr void \
|
attr void \
|
||||||
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
|
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
|
||||||
|
@@ -71,6 +71,22 @@ int main() { return rc; }
|
|||||||
[test "$libbsd_cv_gnu_init_array_support" = yes])
|
[test "$libbsd_cv_gnu_init_array_support" = yes])
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# LIBBSD_SELECT_API(name, desc)
|
||||||
|
# -----------------
|
||||||
|
AC_DEFUN([LIBBSD_SELECT_API], [
|
||||||
|
AS_IF([test -z "$AS_TR_SH([api_$1])"], [
|
||||||
|
AC_MSG_ERROR([missing API selection for $1])
|
||||||
|
], [test "$AS_TR_SH([api_$1])" = "unknown"], [
|
||||||
|
AC_MSG_ERROR([unknown ABI selection for $1])
|
||||||
|
], [test "$AS_TR_SH([api_$1])" = "yes"], [
|
||||||
|
AC_DEFINE(AS_TR_CPP([LIBBSD_API_$1]), [1], [Provide API for $2])
|
||||||
|
], [
|
||||||
|
AC_DEFINE(AS_TR_CPP([LIBBSD_API_$1]), [0])
|
||||||
|
])
|
||||||
|
AM_CONDITIONAL(AS_TR_CPP([API_$1]),
|
||||||
|
[test "x$AS_TR_SH([api_$1])" = "xyes"])
|
||||||
|
])
|
||||||
|
|
||||||
# LIBBSD_SELECT_ABI(name, desc)
|
# LIBBSD_SELECT_ABI(name, desc)
|
||||||
# -----------------
|
# -----------------
|
||||||
AC_DEFUN([LIBBSD_SELECT_ABI], [
|
AC_DEFUN([LIBBSD_SELECT_ABI], [
|
||||||
|
@@ -9,7 +9,7 @@ AC_DEFUN([LIBBSD_SYS_TIME64], [
|
|||||||
#undef _TIME_BITS
|
#undef _TIME_BITS
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
]])
|
]])
|
||||||
AS_IF([test $ac_cv_sizeof_time_t = 8], [
|
AS_IF([test $ac_cv_sizeof_time_t -eq 8], [
|
||||||
libbsd_sys_time_bits=64
|
libbsd_sys_time_bits=64
|
||||||
], [
|
], [
|
||||||
libbsd_sys_time_bits=32
|
libbsd_sys_time_bits=32
|
||||||
@@ -26,7 +26,7 @@ AC_DEFUN([LIBBSD_SYS_TIME64], [
|
|||||||
#define _TIME_BITS 64
|
#define _TIME_BITS 64
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
]])
|
]])
|
||||||
AS_IF([test $ac_cv_sizeof_time_t = 8], [
|
AS_IF([test $ac_cv_sizeof_time_t -eq 8], [
|
||||||
libbsd_sys_has_time64=1
|
libbsd_sys_has_time64=1
|
||||||
], [
|
], [
|
||||||
libbsd_sys_has_time64=0
|
libbsd_sys_has_time64=0
|
||||||
@@ -35,7 +35,7 @@ AC_DEFUN([LIBBSD_SYS_TIME64], [
|
|||||||
[Enable if the system supports 64-bit time_t])
|
[Enable if the system supports 64-bit time_t])
|
||||||
AC_SUBST([LIBBSD_SYS_HAS_TIME64], [$libbsd_sys_has_time64])
|
AC_SUBST([LIBBSD_SYS_HAS_TIME64], [$libbsd_sys_has_time64])
|
||||||
AM_CONDITIONAL([LIBBSD_SYS_HAS_TIME64], [test "$libbsd_sys_has_time64" -eq 1])
|
AM_CONDITIONAL([LIBBSD_SYS_HAS_TIME64], [test "$libbsd_sys_has_time64" -eq 1])
|
||||||
AS_IF([test "$libbsd_sys_time_bits" = 32 && \
|
AS_IF([test "$libbsd_sys_time_bits" -eq 32 && \
|
||||||
test "$libbsd_sys_has_time64" -eq 1], [
|
test "$libbsd_sys_has_time64" -eq 1], [
|
||||||
abi_time64=yes
|
abi_time64=yes
|
||||||
], [
|
], [
|
||||||
@@ -43,9 +43,19 @@ AC_DEFUN([LIBBSD_SYS_TIME64], [
|
|||||||
])
|
])
|
||||||
LIBBSD_SELECT_ABI([time64], [explicit time64 time_t support])
|
LIBBSD_SELECT_ABI([time64], [explicit time64 time_t support])
|
||||||
|
|
||||||
AS_IF([test $ac_cv_sys_file_offset_bits = 64 && \
|
AC_CHECK_SIZEOF([off_t], [], [[
|
||||||
test $libbsd_sys_time_bits = 32 && \
|
#define _FILE_OFFSET_BITS 64
|
||||||
test $ac_cv_sizeof_time_t = 8], [
|
#include <sys/types.h>
|
||||||
|
]])
|
||||||
|
AS_IF([test $ac_cv_sizeof_off_t = 8], [
|
||||||
|
libbsd_sys_has_lfs=1
|
||||||
|
], [
|
||||||
|
libbsd_sys_has_lfs=0
|
||||||
|
])
|
||||||
|
|
||||||
|
AS_IF([test $libbsd_sys_has_lfs -eq 1 && \
|
||||||
|
test $libbsd_sys_time_bits -eq 32 && \
|
||||||
|
test $ac_cv_sizeof_time_t -eq 8], [
|
||||||
AC_DEFINE([_TIME_BITS], [64], [Enable 64-bit time_t support])
|
AC_DEFINE([_TIME_BITS], [64], [Enable 64-bit time_t support])
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
|
@@ -141,8 +141,6 @@ dist_man_MANS = \
|
|||||||
TAILQ_PREV.3bsd \
|
TAILQ_PREV.3bsd \
|
||||||
TAILQ_REMOVE.3bsd \
|
TAILQ_REMOVE.3bsd \
|
||||||
TAILQ_SWAP.3bsd \
|
TAILQ_SWAP.3bsd \
|
||||||
TIMESPEC_TO_TIMEVAL.3bsd \
|
|
||||||
TIMEVAL_TO_TIMESPEC.3bsd \
|
|
||||||
be16dec.3bsd \
|
be16dec.3bsd \
|
||||||
be16enc.3bsd \
|
be16enc.3bsd \
|
||||||
be32dec.3bsd \
|
be32dec.3bsd \
|
||||||
@@ -174,16 +172,21 @@ dist_man_MANS = \
|
|||||||
timercmp.3bsd \
|
timercmp.3bsd \
|
||||||
timerisset.3bsd \
|
timerisset.3bsd \
|
||||||
timersub.3bsd \
|
timersub.3bsd \
|
||||||
timespec.3bsd \
|
|
||||||
timespecadd.3bsd \
|
timespecadd.3bsd \
|
||||||
timespecclear.3bsd \
|
timespecclear.3bsd \
|
||||||
timespeccmp.3bsd \
|
timespeccmp.3bsd \
|
||||||
timespecisset.3bsd \
|
timespecisset.3bsd \
|
||||||
timespecsub.3bsd \
|
timespecsub.3bsd \
|
||||||
timeval.3bsd \
|
|
||||||
tree.3bsd \
|
tree.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
|
|
||||||
|
if API_TIME_MACROS
|
||||||
|
dist_man_MANS += \
|
||||||
|
TIMESPEC_TO_TIMEVAL.3bsd \
|
||||||
|
TIMEVAL_TO_TIMESPEC.3bsd \
|
||||||
|
# EOL
|
||||||
|
endif
|
||||||
|
|
||||||
if ABI_ACCMODE
|
if ABI_ACCMODE
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
getmode.3bsd \
|
getmode.3bsd \
|
||||||
@@ -210,6 +213,9 @@ endif
|
|||||||
if ABI_ERRC
|
if ABI_ERRC
|
||||||
dist_man_MANS += \
|
dist_man_MANS += \
|
||||||
errc.3bsd \
|
errc.3bsd \
|
||||||
|
verrc.3bsd \
|
||||||
|
vwarnc.3bsd \
|
||||||
|
warnc.3bsd \
|
||||||
# EOL
|
# EOL
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@@ -1 +1,100 @@
|
|||||||
.so man3/timeval.3bsd
|
.\" $NetBSD: timeval.3,v 1.12 2011/04/12 08:39:26 jruoho Exp $
|
||||||
|
.\"
|
||||||
|
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
|
||||||
|
.\" All rights reserved.
|
||||||
|
.\"
|
||||||
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
.\" by Jukka Ruohonen.
|
||||||
|
.\"
|
||||||
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
|
.\" modification, are permitted provided that the following conditions
|
||||||
|
.\" are met:
|
||||||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer.
|
||||||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||||||
|
.\" documentation and/or other materials provided with the distribution.
|
||||||
|
.\"
|
||||||
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
.\"
|
||||||
|
.Dd April 12, 2011
|
||||||
|
.Dt TIMEVAL_TO_TIMESPEC 3bsd
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm TIMEVAL_TO_TIMESPEC ,
|
||||||
|
.Nm TIMESPEC_TO_TIMEVAL
|
||||||
|
.Nd time structures conversion macros
|
||||||
|
.Sh LIBRARY
|
||||||
|
.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
|
||||||
|
.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
|
||||||
|
.Lb libbsd
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.In sys/time.h
|
||||||
|
(See
|
||||||
|
.Xr libbsd 7
|
||||||
|
for include usage.)
|
||||||
|
.Ft void
|
||||||
|
.Fn TIMEVAL_TO_TIMESPEC "struct timeval *tv" "struct timespec *ts"
|
||||||
|
.Ft void
|
||||||
|
.Fn TIMESPEC_TO_TIMEVAL "struct timeval *tv" "struct timespec *ts"
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
|
.Va timeval
|
||||||
|
structure represents elapsed time, in whole seconds,
|
||||||
|
and the rest of the elapsed time in microseconds.
|
||||||
|
.Pp
|
||||||
|
The
|
||||||
|
.Va timespec
|
||||||
|
structure represents elapsed time, in whole seconds,
|
||||||
|
and the rest of the elapsed time in nanoseconds.
|
||||||
|
.Pp
|
||||||
|
A microsecond is equal to one millionth of a second,
|
||||||
|
1000 nanoseconds, or 1/1000 milliseconds.
|
||||||
|
To ease the conversions, the macros
|
||||||
|
.Fn TIMEVAL_TO_TIMESPEC
|
||||||
|
and
|
||||||
|
.Fn TIMESPEC_TO_TIMEVAL
|
||||||
|
can be used to convert between
|
||||||
|
.Em struct timeval
|
||||||
|
and
|
||||||
|
.Em struct timespec .
|
||||||
|
.Sh EXAMPLES
|
||||||
|
It can be stressed that the traditional
|
||||||
|
.Tn UNIX
|
||||||
|
.Va timeval
|
||||||
|
and
|
||||||
|
.Va timespec
|
||||||
|
structures represent elapsed time, measured by the system clock.
|
||||||
|
The following sketch implements a function suitable
|
||||||
|
for use in a context where the
|
||||||
|
.Va timespec
|
||||||
|
structure is required for a conditional timeout:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
static void
|
||||||
|
example(struct timespec *spec, time_t minutes)
|
||||||
|
{
|
||||||
|
struct timeval elapsed;
|
||||||
|
|
||||||
|
(void)gettimeofday(&elapsed, NULL);
|
||||||
|
|
||||||
|
TIMEVAL_TO_TIMESPEC(&elapsed, spec);
|
||||||
|
|
||||||
|
/* Add the offset for timeout in minutes. */
|
||||||
|
spec->tv_sec = spec->tv_sec + minutes * 60;
|
||||||
|
}
|
||||||
|
.Ed
|
||||||
|
.Pp
|
||||||
|
A better alternative would use the more precise
|
||||||
|
.Xr clock_gettime 2 .
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr timeradd 3bsd
|
||||||
|
@@ -1 +1 @@
|
|||||||
.so man3/timeval.3bsd
|
.so man3/TIMESPEC_TO_TIMEVAL.3bsd
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
.so man3/timeval.3bsd
|
|
134
man/timeval.3bsd
134
man/timeval.3bsd
@@ -1,134 +0,0 @@
|
|||||||
.\" $NetBSD: timeval.3,v 1.12 2011/04/12 08:39:26 jruoho Exp $
|
|
||||||
.\"
|
|
||||||
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
|
|
||||||
.\" All rights reserved.
|
|
||||||
.\"
|
|
||||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
||||||
.\" by Jukka Ruohonen.
|
|
||||||
.\"
|
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
|
||||||
.\" modification, are permitted provided that the following conditions
|
|
||||||
.\" are met:
|
|
||||||
.\" 1. Redistributions of source code must retain the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer.
|
|
||||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
.\" notice, this list of conditions and the following disclaimer in the
|
|
||||||
.\" documentation and/or other materials provided with the distribution.
|
|
||||||
.\"
|
|
||||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
||||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
||||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
||||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
.\"
|
|
||||||
.Dd April 12, 2011
|
|
||||||
.Dt timeval 3bsd
|
|
||||||
.Os
|
|
||||||
.Sh NAME
|
|
||||||
.Nm timeval ,
|
|
||||||
.Nm timespec
|
|
||||||
.Nd time structures
|
|
||||||
.Sh LIBRARY
|
|
||||||
.ds str-Lb-libbsd Utility functions from BSD systems (libbsd, \-lbsd)
|
|
||||||
.ds doc-str-Lb-libbsd \*[str-Lb-libbsd]
|
|
||||||
.Lb libbsd
|
|
||||||
.Sh SYNOPSIS
|
|
||||||
.In sys/time.h
|
|
||||||
(See
|
|
||||||
.Xr libbsd 7
|
|
||||||
for include usage.)
|
|
||||||
.Ft void
|
|
||||||
.Fn TIMEVAL_TO_TIMESPEC "struct timeval *tv" "struct timespec *ts"
|
|
||||||
.Ft void
|
|
||||||
.Fn TIMESPEC_TO_TIMEVAL "struct timeval *tv" "struct timespec *ts"
|
|
||||||
.Sh DESCRIPTION
|
|
||||||
The
|
|
||||||
.In sys/time.h
|
|
||||||
header, included by
|
|
||||||
.In time.h ,
|
|
||||||
defines various structures related to time and timers.
|
|
||||||
.Bl -enum -offset 1n
|
|
||||||
.It
|
|
||||||
The following structure is used by
|
|
||||||
.Xr gettimeofday 2 ,
|
|
||||||
among others:
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
struct timeval {
|
|
||||||
time_t tv_sec;
|
|
||||||
suseconds_t tv_usec;
|
|
||||||
};
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Va tv_sec
|
|
||||||
member represents the elapsed time, in whole seconds.
|
|
||||||
The
|
|
||||||
.Va tv_usec
|
|
||||||
member captures rest of the elapsed time,
|
|
||||||
represented as the number of microseconds.
|
|
||||||
.It
|
|
||||||
The following structure is used by
|
|
||||||
.Xr nanosleep 2 ,
|
|
||||||
among others:
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
struct timespec {
|
|
||||||
time_t tv_sec;
|
|
||||||
long tv_nsec;
|
|
||||||
};
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
The
|
|
||||||
.Va tv_sec
|
|
||||||
member is again the elapsed time in whole seconds.
|
|
||||||
The
|
|
||||||
.Va tv_nsec
|
|
||||||
member represents the rest of the elapsed time in nanoseconds.
|
|
||||||
.Pp
|
|
||||||
A microsecond is equal to one millionth of a second,
|
|
||||||
1000 nanoseconds, or 1/1000 milliseconds.
|
|
||||||
To ease the conversions, the macros
|
|
||||||
.Fn TIMEVAL_TO_TIMESPEC
|
|
||||||
and
|
|
||||||
.Fn TIMESPEC_TO_TIMEVAL
|
|
||||||
can be used to convert between
|
|
||||||
.Em struct timeval
|
|
||||||
and
|
|
||||||
.Em struct timespec .
|
|
||||||
.El
|
|
||||||
.Sh EXAMPLES
|
|
||||||
It can be stressed that the traditional
|
|
||||||
.Tn UNIX
|
|
||||||
.Va timeval
|
|
||||||
and
|
|
||||||
.Va timespec
|
|
||||||
structures represent elapsed time, measured by the system clock.
|
|
||||||
The following sketch implements a function suitable
|
|
||||||
for use in a context where the
|
|
||||||
.Va timespec
|
|
||||||
structure is required for a conditional timeout:
|
|
||||||
.Bd -literal -offset indent
|
|
||||||
static void
|
|
||||||
example(struct timespec *spec, time_t minutes)
|
|
||||||
{
|
|
||||||
struct timeval elapsed;
|
|
||||||
|
|
||||||
(void)gettimeofday(&elapsed, NULL);
|
|
||||||
|
|
||||||
_DIAGASSERT(spec != NULL);
|
|
||||||
TIMEVAL_TO_TIMESPEC(&elapsed, spec);
|
|
||||||
|
|
||||||
/* Add the offset for timeout in minutes. */
|
|
||||||
spec->tv_sec = spec->tv_sec + minutes * 60;
|
|
||||||
}
|
|
||||||
.Ed
|
|
||||||
.Pp
|
|
||||||
A better alternative would use the more precise
|
|
||||||
.Xr clock_gettime 2 .
|
|
||||||
.Sh SEE ALSO
|
|
||||||
.Xr timeradd 3bsd
|
|
1
man/verrc.3bsd
Normal file
1
man/verrc.3bsd
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.so man3/errc.3bsd
|
1
man/vwarnc.3bsd
Normal file
1
man/vwarnc.3bsd
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.so man3/errc.3bsd
|
1
man/warnc.3bsd
Normal file
1
man/warnc.3bsd
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.so man3/errc.3bsd
|
@@ -48,8 +48,16 @@ typedef struct
|
|||||||
a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
|
a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \
|
||||||
c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
|
c = PLUS(c,d); b = ROTATE(XOR(b,c), 7);
|
||||||
|
|
||||||
static const char sigma[16] = "expand 32-byte k";
|
#if defined(__has_attribute)
|
||||||
static const char tau[16] = "expand 16-byte k";
|
#if __has_attribute(__nonstring__)
|
||||||
|
#define ATTRIBUTE_NONSTRING __attribute__((__nonstring__))
|
||||||
|
#else
|
||||||
|
#define ATTRIBUTE_NONSTRING
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char sigma[16] ATTRIBUTE_NONSTRING = "expand 32-byte k";
|
||||||
|
static const char tau[16] ATTRIBUTE_NONSTRING = "expand 16-byte k";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits)
|
chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits)
|
||||||
|
@@ -153,6 +153,9 @@ closefrom_procfs(int lowfd)
|
|||||||
const char *errstr;
|
const char *errstr;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
if (dent->d_name[0] == '.')
|
||||||
|
continue;
|
||||||
|
|
||||||
fd = strtonum(dent->d_name, lowfd, INT_MAX, &errstr);
|
fd = strtonum(dent->d_name, lowfd, INT_MAX, &errstr);
|
||||||
if (errstr != NULL || fd == dirfd(dirp))
|
if (errstr != NULL || fd == dirfd(dirp))
|
||||||
continue;
|
continue;
|
||||||
|
@@ -58,6 +58,7 @@ strtonum(const char *nptr, long long minval, long long maxval,
|
|||||||
return rv;
|
return rv;
|
||||||
case ECANCELED:
|
case ECANCELED:
|
||||||
case ENOTSUP:
|
case ENOTSUP:
|
||||||
|
case EINVAL:
|
||||||
goto out;
|
goto out;
|
||||||
case ERANGE:
|
case ERANGE:
|
||||||
if (*eptr)
|
if (*eptr)
|
||||||
|
18
test/nlist.c
18
test/nlist.c
@@ -33,17 +33,29 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <nlist.h>
|
#include <nlist.h>
|
||||||
|
|
||||||
|
#if defined(__has_attribute)
|
||||||
|
#if __has_attribute(__retain__)
|
||||||
|
#define ATTRIBUTE_RETAIN __attribute__((__retain__))
|
||||||
|
#else
|
||||||
|
#define ATTRIBUTE_RETAIN
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
static int data_prv_init = 50;
|
static int data_prv_init = 50;
|
||||||
extern int data_pub_init;
|
extern int data_pub_init;
|
||||||
extern int data_pub_uninit[2048];
|
extern int data_pub_uninit[2048];
|
||||||
extern int *data_pub_ptr;
|
extern int *data_pub_ptr;
|
||||||
|
|
||||||
|
/* GCC's __has_attribute has odd behavior for retain: https://gcc.gnu.org/PR99587 */
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wattributes"
|
||||||
int *data_pub_ptr = &data_prv_init;
|
int *data_pub_ptr = &data_prv_init;
|
||||||
int data_pub_init __attribute__((__used__)) = 10;
|
int data_pub_init ATTRIBUTE_RETAIN __attribute__((__used__)) = 10;
|
||||||
int data_pub_uninit[2048] __attribute__((__used__));
|
int data_pub_uninit[2048] ATTRIBUTE_RETAIN __attribute__((__used__));
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
func_pub(void) __attribute__((__used__)) ;
|
func_pub(void) ATTRIBUTE_RETAIN __attribute__((__used__));
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
|
||||||
int
|
int
|
||||||
func_pub(void)
|
func_pub(void)
|
||||||
|
Reference in New Issue
Block a user