These types are available in SVID as well.
* libc/include/sys/types.h (u_char,u_short,u_int,u_long): Replace
__BSD_VISIBLE with __MISC_VISIBLE.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
_LARGEFILE_SOURCE, which controls only these two functions, is implicitly
defined by _XOPEN_SOURCE >= 500. However, they are also later added to
POSIX.1-2001 (and therefore available by default).
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
GCC 6.0+ asserts that the memptr argument to the builtin function
posix_memalign is nonnull.
Add the necessary annotation to the prototype and
remove the now unnecessary check to fix a warning.
newlib/Changelog
newlib/libc/include/stdlib.h: Annotate arg to posix_memalign as
non-null.
winsup/cygwin/ChangeLog
malloc_wrapper.cc (posix_memalign): Remove always true nonnull check.
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
Move the sig*set macros following the functions inside their feature
test macro conditional.
This fixes the build on bare-metal targets following
commit 5c78499ae2.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Acked-by: Corinna Vinschen <vinschen@redhat.com>
According to the OpenBSD man page, "A Replacement Call for Random". It
offers high quality random numbers derived from input data obtained by
the OpenBSD specific getentropy() system call which is declared in
<unistd.h> and must be implemented for each Newlib port externally. The
arc4random() functions are used for example in LibreSSL and OpenSSH.
Cygwin provides currently its own implementation of the arc4random
family. Maybe it makes sense to use this getentropy() implementation:
http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/lib/libcrypto/crypto/getentropy_win.c?rev=1.4&content-type=text/x-cvsweb-markup
* libc/include/stdlib.h (arc4random): Declare if __BSD_VISIBLE.
(arc4random_buf): Likewise.
(arc4random_uniform): Likewise.
* libc/include/sys/unistd.h (getentropy): Likewise.
* libc/include/machine/_arc4random.h: New file.
* libc/stdlib/arc4random.c: Likewise.
* libc/stdlib/arc4random.h: Likewise.
* libc/stdlib/arc4random_uniform.c: Likewise.
* libc/stdlib/chacha_private.h: Likewise.
* libc/sys/rtems/include/machine/_arc4random.h: Likewise.
* libc/stdlib/Makefile.am (EXTENDED_SOURCES): Add arc4random.c
and arc4random_uniform.c.
* libc/stdlib/Makefile.in: Regenerate.
This function is used by LibreSSL and OpenSSH and is provided by the
OpenBSD libc.
* libc/include/string.h (timingsafe_memcmp): Declare.
* libc/string/timingsafe_memcmp.c: New file.
* libc/string/Makefile.am: Add new file.
* libc/string/Makefile.in: Regenerate.
This function is used by LibreSSL and OpenSSH and is provided by the
OpenBSD libc.
* libc/include/string.h (timingsafe_bcmp): Declare.
* libc/string/timingsafe_bcmp.c: New file.
* libc/string/Makefile.am: Add new file.
* libc/string/Makefile.in: Regenerate.
This function is used by LibreSSL and OpenSSH and is provided by the
OpenBSD libc.
* libc/include/string.h (explicit_bzero): Declare.
* libc/string/explicit_bzero.c: New file.
* libc/string/Makefile.am: Add new file.
* libc/string/Makefile.in: Regenerate.
This guard is used by FreeBSD <sys/socket.h> for example. The FreeBSD
network stack is used in RTEMS.
* newlib/libc/include/sys/types.h (ssize_t): Guard by
_SSIZE_T_DECLARED.
The u_int/u_char/etc. BSD types are needed by Cygwin's netinet/*.h
headers, so they always need to be available.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
The inclusion of <sys/select.h> is required also by POSIX.1-2001.
setitimer is XSI, and futimesat is GNU.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Replace all !_POSIX_SOURCE with BSD. All *at functions depend on
ATFILE; futimens is POSIX.1-2008.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Throughout, use proper internal macros for functions, including those
marked as target-specific. Use ATFILE for all *at functions.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Throughout, remove __STRICT_ANSI__ and use the proper internal macros.
bcmp, bcopy, bzero, index, and rindex were in POSIX prior to 2008.
memrchr is GNU.
strdup and strndup are POSIX.1-2008.
The int-returning form of strerror_r is POSIX.1-2001.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Throughout, simplify the C99/C11 conditionals, and replace
__STRICT_ANSI__ with the proper internal POSIX macros. The _*_r
reentrant functions need not be guarded (and most haven't been) because
such names in the global scope are reserved to the implementation.
atoff is unique to newlib.
dtoa is not actually exported (_dtoa_r is used internally), is
nonstandard, and the declaration conflicts with the code included in
MySQL, NSPR, and SpiderMonkey.
mktemp was removed in POSIX.1-2001.
The qsort_r declarations are reordered so that the GNU version retains
precedence.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Throughout, remove references to __STRICT_ANSI__ and use the proper
internal macros and versions for C99, POSIX, ATFILE for the various *at
functions, or LARGEFILE for fseeko and ftello.
[v]asprintf are GNU extensions, but the *iprintf, *iscanf, and
*asnprintf functions are unique to newlib.
getw and putw were removed from POSIX.1-2001. funopen is BSD, and
fopencookie is GNU.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Use proper internal macros for BSD sig_t and GNU sighandler_t.
sigaltstack and friends are XSI even in SUSv4 but in glibc are
nonetheless handled as POSIX.1-2008 (not 2001).
The requirement for the ucontext_t typedef in signal.h was XSI prior to
POSIX.1-2008.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Simplify the C99 conditionals. Mark the drem and gamma functions as
BSD|SVID, the Bessel double functions also XSI and the floats also SUSv3.
signgam is BSD|SVID|XSI, and matherr is SVID. Finally, use the internal
macros to control the symbolic constants.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
_PATH_GROUP is a BSDism. getgr*_r are BSD|SVID|POSIX, and the *grent
functions are BSD|SVID|XPG4v2.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Most of the !_POSIX_SOURCE code is BSD, although ironically some were
added to POSIX.1-2001.
Use the ATFILE conditional for most of the *at functions, except
futimesat which is GNU.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
MAXNAMLEN is a BSDism.
Use the proper internal macros instead of !_POSIX_SOURCE. telldir and
seekdir are XSI, scandir and alphasort are POSIX.1-2008, and scandirat
is GNU.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
This is the complete rework of the feature tests macros for better
compatibility with GNU libc, primarily based on the Linux man pages
documentation:
http://man7.org/linux/man-pages/man7/feature_test_macros.7.html
The previous implementation was flawed in its approach that macros were
often used to hide symbols if defined (e.g. !defined __STRICT_ANSI__ or
!defined _POSIX_SOURCE), whereas the approach of glibc is that these macros
make symbols available when defined (e.g. defined _BSD_SOURCE, or as used
internally, #if __BSD_VISIBLE). As much open-source software is written
with glibc in mind, this necessitated patching numerous packages just to
compile.
In particular, __STRICT_ANSI__ (which is defined by gcc -ansi or -std=c*)
was given too much importance. This implementation limits the influence
of __STRICT_ANSI__ to controlling the default when no other feature test
macros are defined, and to the inclusion of <alloca.h> in <stdlib.h> as
documented. These are the only places where __STRICT_ANSI__ should be
tested.
The following macros are now accepted: _ATFILE_SOURCE, _BSD_SOURCE,
_DEFAULT_SOURCE, _ISOC99_SOURCE, _ISOC11_SOURCE, _LARGEFILE_SOURCE,
_SVID_SOURCE, _XOPEN_SOURCE_EXTENDED.
The existing __*_VISIBLE internal macros have been kept mostly
compatible with the original BSD implementation, with some changes to
the criteria which controls them. Several more macros in this style
have been added where needed for concision or accuracy.
Enabling C++11 or newer in the compiler also enables C99 and C11
functions. Doing so should help move away from the need to define
_GNU_SOURCE in g++ for _GLIBCXX_USE_C99 support as on Linux:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51749
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Per the preceeding comment this inline code is disabled since 1993(!)
because of a bug in GCC at the time. This is long gone and the equivalent
inline code is used in the BSDs for quite some time. Enable this code for
newlib as well.
* libc/include/stdio.h (__sputc_r): Enable GCC inline code. Add
handling for targets defining __SCLE.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* pthread.h: Add prototypes for pthread_condattr_getclock(),
pthread_condattr_setclock(), pthread_setschedpri(),
pthread_getcpuclockid(), pthread_getconcurrency(), and
pthread_setconcurrency(). Also cleaned up file header to
remove CVS Id string.
* sys/types.h: Add clock ID to pthread_condattr_t.
* libc/include/sys/features.h: Set POSIX option macros from 200112L
to 200809L for Cygwin.
(_POSIX_SPAWN): Set to 200809L for Cygwin.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Currently, the newlib version information needs to be updated in two places:
- newlib/acinclude.m4
- newlib/libc/include/sys/features.h
The goal of this patch is to:
- supply a single location for defining the newlib version
information: newlib/acinclude.m4
- define __NEWLIB__, __NEWLIB_MINOR__ and __NEWLIB_PATCHLEVEL__
This is in line with what gcc does for its version macros. See:
https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
This patch moves the definition of the _NEWLIB_VERSION, __NEWLIB__
and __NEWLIB_MINOR__ macros from newlib/libc/include/sys/features.h,
to the newly generated newlib/_newlib_version.h file. Additionally,
the __NEWLIB_PATCHLEVEL__ macro was created, for completeness.
In order to stay backwards compatible, newlib/_newlib_version.h gets
included by newlib/newlib.h and newlib/libc/include/sys/features.h.
Note: This patch does _not_ include the modifications to the following
files, as these should all be generated any way.
*Makefile.in,
*aclocal.m4,
*configure
stamp-* files
Signed-off-by: Pieter du Preez <pdupreez@gmail.com>
Any attempt to use isnanf, isinff, or finitef from <ieeefp.h> with
GCC 5 on platforms other than SPU result in a "lvalue required as
unary '&' operand" error.
newlib/libc/
* include/ieeefp.h (__ieeefp_isnanf): Remove broken macro.
(__ieeefp_isinff, __ieeefp_finitef): Ditto.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Current mesa expects stdio.h to prototype fileno() when compiling with gcc
-std=c99 -D_XOPEN_SOURCE
Fix the 'POSIX 1003.1:2001' block in stdio.h to prototype functions if not
__STRICT_ANSI__, or _BSD_SOURCE, _POSIX_C_SOURCE or _XOPEN_SOURCE are defined
appropriately
As far as I can tell, despite being in this block, setbuffer() and setlinebuf()
are BSDisms which aren't in POSIX 1003.1:2001
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
This fixes the build of krb5 and other packages on Cygwin.
* libc/include/grp.h: Use __BSD_VISIBLE and __XSI_VISIBLE guards.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Provide a _REENT_INIT_PTR_ZEROED() macro to initialize an already
zero-initialized struct _reent.
* libc/include/sys/reent.h (_REENT_INIT_PTR_ZEROED): New.
(_REENT_INIT_PTR): Define only once and use _REENT_INIT_PTR_ZEROED().
* libc/include/sys/_sigset.h: New.
* libc/include/sys/select.h: Do not include <sys/types.h> and
<sys/time.h> to avoid cyclic header file dependencies. Include
specialized header files instead.
(sigset_t): Conditionally define.
* libc/include/sys/signal.h (sigset_t): Likewise.
* libc/include/sys/time.h: Include <sys/select.h> if
__BSD_VISIBLE.
* libc/include/sys/types.h: Likewise.
* libc/include/sys/types.h: Move definitions of NBBY and howmany to
sys/param.h. Move definitions of select(2) macros to sys/select.h.
* libc/include/sys/param.h: See above.
* libc/include/sys/select.h: Move Cygwin's sys/select.h here.
* include/sys/select.h: Move select(2) macros from newlib's sys/types.h
here. Rename howmany to _howmany to unclutter namespace. Move file to
newlib.
* libc/rexex.cc: Add declaration for cygwin_gethostname.
* poll.cc: Include sys/param.h and locale select.h.
* select.h (cygwin_select): Declare.
* uname.cc: Declare cygwin_gethostname.
* winsup.h: Drop declarations of cygwin_select and cygwin_gethostname.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>