Commit Graph

2308 Commits

Author SHA1 Message Date
Peter Foley 3ba2c39fb2 Add nonnull annotation to posix_memalign.
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>
2016-03-21 20:27:16 +01:00
Sebastian Huber 08537d88f6 Move arc4random Cygwin only code to Cygwin
Keep the Newlib arc4random.c identical to the OpenBSD upstream version.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>.
2016-03-21 11:12:19 +01:00
Corinna Vinschen f7f26f65ab Allow machine-dependent arc4 locking
newlib:
	* libc/stdlib/arc4random.h: Remove Cygwin-specific locking code.
	Conditionalize arc4 locking.  Check for _ARC4_LOCK_INIT being
	undefined to fall back to default implementation.

cygwin:
	* include/machine/_arc4random.h: New file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-20 21:30:08 +01:00
Jeff Johnston d17977ccc7 Regenerate configure script. 2016-03-19 00:27:59 -04:00
Yaakov Selkowitz 97d1536d17 sparc64: move struct timeval to <sys/_timeval.h>
commit bb01594897 moved the struct timeval
declaration from <sys/time.h> to <sys/_timeval.h>, and commit
01885f533d changed <sys/select.h> to include
<sys/_timeval.h>.  Therefore, sparc64's own struct timeval needs to be
moved accordingly in order to avoid a conflict from the generic type.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Acked-by: Corinna Vinschen <vinschen@redhat.com>
2016-03-18 15:29:13 -05:00
Yaakov Selkowitz f049607eb0 Feature test macros overhaul: sparc64
sparc64 has a number of its own headers which override the generic ones.
These too need to use feature test macros properly.

These changes correspond to the generic fcntl.h and sys/stat.h changes
in commit d2df6d381b and
commit 069e400c91.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Acked-by: Corinna Vinschen <vinschen@redhat.com>
2016-03-18 15:29:05 -05:00
Howland, Craig D 19879c03c5 Cleanup macros in chacha_private.h to be target-type independent
* libc/stdlib/chacha_private.h (U8C, U32C): Remove un-necessary macros.
	(U8V, U32V): Drop masking.
2016-03-18 21:20:06 +01:00
Corinna Vinschen 8e2b2adb3d Only export arc4random_stir and arc4random_addrandom on Cygwin
Export to maintain backward compatibility, but don't let
	them do anything useful.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18 21:12:12 +01:00
Yaakov Selkowitz d3f203d091 Feature test macros overhaul: signal.h (part 2)
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>
2016-03-18 11:22:32 -05:00
Yaakov Selkowitz f3ec63771b arm: fix build with newlib supplied syscalls enabled
In file included from libc/sys/arm/crt0.S:2:0:
libc/sys/arm/arm.h:32:25: fatal error: acle-compat.h: No such file or directory

acle-compat.h is libc/machine/arm.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-18 11:22:32 -05:00
Corinna Vinschen 7c96d6059c Arc4random locking: Check for threaded application on Cygwin
libc/stdlib/arc4random.h (_ARC4_LOCK): Special case Cygwin.
        (_ARC4_UNLOCK): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18 14:40:26 +01:00
Corinna Vinschen 5ccdcf0219 Add arc4random_stir and arc4random_addrandom for OpenBSD compatibility
* libc/stdlib/arc4random.c (arc4random_stir): New function.
        (arc4random_addrandom): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18 14:39:58 +01:00
Sebastian Huber f74cf1350e Add arc4random() etc. from OpenBSD 5.8
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.
2016-03-18 12:33:41 +01:00
Sebastian Huber 55c239d834 Add timingsafe_memcmp()
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.
2016-03-18 12:33:40 +01:00
Sebastian Huber 559fd77dda Add timingsafe_bcmp()
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.
2016-03-18 12:33:40 +01:00
Sebastian Huber 8740fa7fd0 Add explicit_bzero()
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.
2016-03-18 12:33:40 +01:00
Sebastian Huber a10dacbdac Guard ssize_t definition by _SSIZE_T_DECLARED
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.
2016-03-18 12:28:55 +01:00
Yaakov Selkowitz 396942b0b5 Feature test macros overhaul: sys/types.h
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>
2016-03-17 21:09:21 -05:00
Yaakov Selkowitz ee97c4b224 Revert "Remove inclusion of sys/select.h in sys/types.h for backward compat"
This BSDism is still in use (e.g. putty).

This reverts commit 088f7a7239.
2016-03-17 21:09:19 -05:00
Yaakov Selkowitz 04f288851a Feature test macros overhaul: sys/time.h
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>
2016-03-17 21:09:18 -05:00
Yaakov Selkowitz 069e400c91 Feature test macros overhaul: sys/stat.h
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>
2016-03-17 21:09:16 -05:00
Yaakov Selkowitz 03c4ef1c51 Feature test macros overhaul: sys/select.h
Remove !_POSIX_SOURCE conditional; pselect is POSIX.1-2001.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:15 -05:00
Yaakov Selkowitz 73e2f46419 Feature test macros overhaul: wchar.h
open_wmemstream is POSIX.1-2008.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:13 -05:00
Yaakov Selkowitz be657151f1 Feature test macros overhaul: unistd.h
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>
2016-03-17 21:09:12 -05:00
Yaakov Selkowitz 43e5ee83fe Feature test macros overhaul: time.h
Throughout, replace __STRICT_ANSI__ with the proper internal macros.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:10 -05:00
Yaakov Selkowitz 6fe6a822ee Feature test macros overhaul: strings.h
Replace __STRICT_ANSI__ with the proper internal macros for bcmp etc.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:09 -05:00
Yaakov Selkowitz 615d63599b Feature test macros overhaul: string.h
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>
2016-03-17 21:09:07 -05:00
Yaakov Selkowitz 84ba25226c Feature test macros overhaul: stdlib.h
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>
2016-03-17 21:09:06 -05:00
Yaakov Selkowitz feec81e571 Feature test macros overhaul: stdio.h
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>
2016-03-17 21:09:04 -05:00
Yaakov Selkowitz 5c78499ae2 Feature test macros overhaul: signal.h
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>
2016-03-17 21:09:03 -05:00
Yaakov Selkowitz 25507f80a2 Feature test macros overhaul: pwd.h
getpw*_r dates back to POSIX.1c, and *pwent to XPG4v2.  Both are also BSD.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:01 -05:00
Yaakov Selkowitz 96972e7198 Feature test macros overhaul: pthread.h
Use internal macros for GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:00 -05:00
Yaakov Selkowitz 4e8291b8b0 Feature test macros overhaul: math.h
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>
2016-03-17 21:08:59 -05:00
Yaakov Selkowitz 86a724b8c0 Feature test macros overhaul: limits.h
Simplify the C99 conditional, and use the internal macro for GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:57 -05:00
Yaakov Selkowitz ec4fe40b23 Feature test macros overhaul: grp.h
_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>
2016-03-17 21:08:56 -05:00
Yaakov Selkowitz d94d983d1b Feature test macros overhaul: fnmatch.h
Use the proper internal macro for GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:54 -05:00
Yaakov Selkowitz d2df6d381b Feature test macros overhaul: fcntl.h
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>
2016-03-17 21:08:53 -05:00
Yaakov Selkowitz d2937299fa Feature test macros overhaul: dirent.h
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>
2016-03-17 21:08:51 -05:00
Yaakov Selkowitz 575608b202 Feature test macros overhaul: ctype.h
Simplify C99 test for isblank.  isascii and toascii are BSD|SVID|XSI.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:50 -05:00
Yaakov Selkowitz 6ba26630e0 Feature test macros overhaul: sys/features.h
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>
2016-03-17 21:06:40 -05:00
Corinna Vinschen 8c5911b37c setvbuf: Drop setting reent->__cleanup
The __sinit call added with 1eb6db6 already sets reent->__cleanup.

	* libc/stdio/setvbuf.c (setvbuf): Drop setting reent->__cleanup.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-13 12:03:03 +01:00
Corinna Vinschen 1eb6db6efb Update setvbuf to latest OpenBSD implementation
Newlib's setvbuf function is very old and has two bugs:
- It sets the SRD/SWR flags incorrectly in case of files opened for
  reading and writing.
  See https://cygwin.com/ml/cygwin/2016-03/msg00180.html
  for a desription of the effect.
- It always sets the buffer size to BUFSIZ if it's not provided by
  the application, independent of the optimal blocksize for the
  underlying IO device.

Update setvbuf to latest code from OpenBSD to fix both problems.

	* libc/stdio/setvbuf.c (setvbuf): Import latest OpenBSD
	implementation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 23:41:21 +01:00
Corinna Vinschen 99d0e2341d Add __swhatbuf function from OpenBSD
To fix a long-standing setvbuf bug, import __swhatbuf function from
OpenBSD and only slightly rearrange for newlib.

	* libc/stdio/local.h (__swhatbuf_r): Declare.
	* libc/stdio/makebuf (__smakebuf_r): New function.
	(__smakebuf_r): Drop file handling code and call __smakebuf_r.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 23:37:01 +01:00
Corinna Vinschen 6b97fabf1b Use __sputc_r inline code when building with gcc
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>
2016-03-12 23:25:11 +01:00
Corinna Vinschen b9217601f8 Enable HW interrupt setup on x86/x86_64 systems by default
* configure.host: Define _I386MACH_DISABLE_HW_INTERRUPTS on rdos.
	Remove setting _I386MACH_ALLOW_HW_INTERRUPTS anywhere else.
	* libc/machine/i386/i386mach.h: Replace test for
	_I386MACH_ALLOW_HW_INTERRUPTS with test for
	!_I386MACH_DISABLE_HW_INTERRUPTS.
	* libc/machine/x86_64/x86_64mach.h: Ditto.
	* libc/sys/linux/machine/i386/i386mach.h: Ditto.
	* libm/machine/i386/i386mach.h: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-26 18:52:46 +01:00
Joel Sherrill 678f774727 newlib/configure.host: Turn off sti/cli for i386 setjmp for i386-rtems* 2016-02-25 14:11:27 -06:00
Jeff Johnston b8a88d0b04 Fix _newlib_version.h logic to support building gcc with newlib. 2016-02-25 15:04:19 -05:00
Yaakov Selkowitz a9ab09dfa9 libm/complex: add clog10, clog10f
newlib/
	* libc/include/complex.h (clog10, clog10f): Declare.
	* libm/complex/Makefile.am (src): Add clog10.c.
	(fsrc): Add clog10f.c.
	(CHEWOUT_FILES): Add clog10.def.
	* libm/complex/Makefile.in: Regenerate.
	* libm/complex/clog10.c: New file.
	* libm/complex/clog10f.c: New file.
	* libm/complex/complex.tex: Add references to clog10 docs.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-22 14:43:41 -06:00
Joel Sherrill 4fa84f10ec pthread.h, sys/types.h Add missing pthread methods
* 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.
2016-02-22 10:05:17 -06:00
Corinna Vinschen c716affcef sys/features.h: Update Cygwin POSIX option macros
* 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>
2016-02-18 13:10:28 +01:00