mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-19 21:16:55 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
04a24db27a | ||
![]() |
b62f36f305 | ||
![]() |
2a3d521318 | ||
![]() |
149aafe198 | ||
![]() |
435825784f | ||
![]() |
31e9396bf2 | ||
![]() |
3b8416acab | ||
![]() |
94d0fb3c53 | ||
![]() |
e848f5aa29 | ||
![]() |
ee63bca525 | ||
![]() |
9cbd935d92 |
21
configure.ac
21
configure.ac
@@ -18,7 +18,7 @@ AM_SILENT_RULES([yes])
|
||||
|
||||
SOVERSION_MAJOR=0
|
||||
SOVERSION_MINOR=12
|
||||
SOVERSION_PATCH=1
|
||||
SOVERSION_PATCH=2
|
||||
|
||||
SOVERSION="$SOVERSION_MAJOR:$SOVERSION_MINOR:$SOVERSION_PATCH"
|
||||
AC_SUBST([SOVERSION])
|
||||
@@ -42,6 +42,8 @@ LIBBSD_LINKER_VERSION_SCRIPT
|
||||
|
||||
is_windows=no
|
||||
|
||||
api_time_macros=unknown
|
||||
|
||||
abi_accmode=unknown
|
||||
abi_arc4random=unknown
|
||||
abi_arc4random_stir=unknown
|
||||
@@ -85,7 +87,9 @@ abi_vis=unknown
|
||||
abi_wcsl=unknown
|
||||
|
||||
AS_CASE([$host_os],
|
||||
[*-gnu*], [
|
||||
[*-gnu* | gnu*], [
|
||||
api_time_macros=no
|
||||
|
||||
abi_accmode=yes
|
||||
# DROP: On glibc >= 2.36.
|
||||
#abi_arc4random=no
|
||||
@@ -145,6 +149,8 @@ AS_CASE([$host_os],
|
||||
abi_wcsl=yes
|
||||
],
|
||||
[*-musl*], [
|
||||
api_time_macros=no
|
||||
|
||||
abi_accmode=yes
|
||||
abi_arc4random=yes
|
||||
abi_arc4random_stir=yes
|
||||
@@ -209,6 +215,8 @@ AS_CASE([$host_os],
|
||||
abi_wcsl=yes
|
||||
],
|
||||
[darwin*], [
|
||||
api_time_macros=no
|
||||
|
||||
abi_accmode=no
|
||||
abi_arc4random=no
|
||||
abi_arc4random_stir=no
|
||||
@@ -255,6 +263,8 @@ AS_CASE([$host_os],
|
||||
abi_wcsl=no
|
||||
],
|
||||
[solaris2*], [
|
||||
api_time_macros=yes
|
||||
|
||||
abi_accmode=yes
|
||||
abi_arc4random=no
|
||||
abi_arc4random_stir=no
|
||||
@@ -301,6 +311,8 @@ AS_CASE([$host_os],
|
||||
abi_wcsl=yes
|
||||
],
|
||||
[aix*], [
|
||||
api_time_macros=yes
|
||||
|
||||
abi_accmode=yes
|
||||
abi_arc4random=yes
|
||||
abi_arc4random_stir=yes
|
||||
@@ -545,6 +557,9 @@ AC_CHECK_FUNCS([\
|
||||
|
||||
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = "xyes"])
|
||||
|
||||
# API selection
|
||||
LIBBSD_SELECT_API([time_macros], [time struct conversion macros])
|
||||
|
||||
# ABI selection
|
||||
LIBBSD_SELECT_ABI([accmode], [setmode()/getmode()])
|
||||
LIBBSD_SELECT_ABI([arc4random], [arc4random() API])
|
||||
@@ -586,7 +601,7 @@ LIBBSD_SELECT_ABI([strmode], [strmode()])
|
||||
LIBBSD_SELECT_ABI([strnstr], [strnstr()])
|
||||
LIBBSD_SELECT_ABI([strtonum], [strtonum()])
|
||||
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([vis], [vis API])
|
||||
LIBBSD_SELECT_ABI([wcsl], [wcslcpy()/wcslcat()])
|
||||
|
@@ -71,6 +71,22 @@ int main() { return rc; }
|
||||
[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)
|
||||
# -----------------
|
||||
AC_DEFUN([LIBBSD_SELECT_ABI], [
|
||||
|
@@ -9,7 +9,7 @@ AC_DEFUN([LIBBSD_SYS_TIME64], [
|
||||
#undef _TIME_BITS
|
||||
#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=32
|
||||
@@ -26,7 +26,7 @@ AC_DEFUN([LIBBSD_SYS_TIME64], [
|
||||
#define _TIME_BITS 64
|
||||
#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=0
|
||||
@@ -35,7 +35,7 @@ AC_DEFUN([LIBBSD_SYS_TIME64], [
|
||||
[Enable if the system supports 64-bit time_t])
|
||||
AC_SUBST([LIBBSD_SYS_HAS_TIME64], [$libbsd_sys_has_time64])
|
||||
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], [
|
||||
abi_time64=yes
|
||||
], [
|
||||
@@ -43,9 +43,19 @@ AC_DEFUN([LIBBSD_SYS_TIME64], [
|
||||
])
|
||||
LIBBSD_SELECT_ABI([time64], [explicit time64 time_t support])
|
||||
|
||||
AS_IF([test $ac_cv_sys_file_offset_bits = 64 && \
|
||||
test $libbsd_sys_time_bits = 32 && \
|
||||
test $ac_cv_sizeof_time_t = 8], [
|
||||
AC_CHECK_SIZEOF([off_t], [], [[
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#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])
|
||||
])
|
||||
])
|
||||
|
@@ -141,8 +141,6 @@ dist_man_MANS = \
|
||||
TAILQ_PREV.3bsd \
|
||||
TAILQ_REMOVE.3bsd \
|
||||
TAILQ_SWAP.3bsd \
|
||||
TIMESPEC_TO_TIMEVAL.3bsd \
|
||||
TIMEVAL_TO_TIMESPEC.3bsd \
|
||||
be16dec.3bsd \
|
||||
be16enc.3bsd \
|
||||
be32dec.3bsd \
|
||||
@@ -174,16 +172,21 @@ dist_man_MANS = \
|
||||
timercmp.3bsd \
|
||||
timerisset.3bsd \
|
||||
timersub.3bsd \
|
||||
timespec.3bsd \
|
||||
timespecadd.3bsd \
|
||||
timespecclear.3bsd \
|
||||
timespeccmp.3bsd \
|
||||
timespecisset.3bsd \
|
||||
timespecsub.3bsd \
|
||||
timeval.3bsd \
|
||||
tree.3bsd \
|
||||
# EOL
|
||||
|
||||
if API_TIME_MACROS
|
||||
dist_man_MANS += \
|
||||
TIMESPEC_TO_TIMEVAL.3bsd \
|
||||
TIMEVAL_TO_TIMESPEC.3bsd \
|
||||
# EOL
|
||||
endif
|
||||
|
||||
if ABI_ACCMODE
|
||||
dist_man_MANS += \
|
||||
getmode.3bsd \
|
||||
@@ -210,6 +213,9 @@ endif
|
||||
if ABI_ERRC
|
||||
dist_man_MANS += \
|
||||
errc.3bsd \
|
||||
verrc.3bsd \
|
||||
vwarnc.3bsd \
|
||||
warnc.3bsd \
|
||||
# EOL
|
||||
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
|
@@ -153,6 +153,9 @@ closefrom_procfs(int lowfd)
|
||||
const char *errstr;
|
||||
int fd;
|
||||
|
||||
if (dent->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
fd = strtonum(dent->d_name, lowfd, INT_MAX, &errstr);
|
||||
if (errstr != NULL || fd == dirfd(dirp))
|
||||
continue;
|
||||
|
@@ -58,6 +58,7 @@ strtonum(const char *nptr, long long minval, long long maxval,
|
||||
return rv;
|
||||
case ECANCELED:
|
||||
case ENOTSUP:
|
||||
case EINVAL:
|
||||
goto out;
|
||||
case ERANGE:
|
||||
if (*eptr)
|
||||
|
18
test/nlist.c
18
test/nlist.c
@@ -33,17 +33,29 @@
|
||||
#include <fcntl.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;
|
||||
extern int data_pub_init;
|
||||
extern int data_pub_uninit[2048];
|
||||
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_init __attribute__((__used__)) = 10;
|
||||
int data_pub_uninit[2048] __attribute__((__used__));
|
||||
int data_pub_init ATTRIBUTE_RETAIN __attribute__((__used__)) = 10;
|
||||
int data_pub_uninit[2048] ATTRIBUTE_RETAIN __attribute__((__used__));
|
||||
|
||||
extern int
|
||||
func_pub(void) __attribute__((__used__)) ;
|
||||
func_pub(void) ATTRIBUTE_RETAIN __attribute__((__used__));
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
int
|
||||
func_pub(void)
|
||||
|
Reference in New Issue
Block a user