Commit Graph

2269 Commits

Author SHA1 Message Date
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
Jeff Johnston 182e2502c8 Also fix libm/machine generated files. 2016-02-17 17:08:54 -05:00
Jeff Johnston 8d40d78ae0 Fix libm regenerated files again. 2016-02-17 17:06:46 -05:00
Jeff Johnston 0e03371dbf Fix regeneration of libm autotool files. 2016-02-17 16:49:59 -05:00
Pieter du Preez 264b817b8e Define the newlib version macros in one place: _newlib_version.h.
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>
2016-02-17 16:04:09 -05:00
Václav Haisman 813da84442 POSIX barrier implementation, take 3
The attached patch should address all of the review comments.

Modifed change log:

Newlib:

	* libc/include/sys/features.h (_POSIX_BARRIERS): Define for Cygwin.
	* libc/include/sys/types.h (pthread_barrier_t)
	(pthread_barrierattr_t): Do not define for Cygwin.

Cygwin:

	* common.din (pthread_barrierattr_init)
	(pthread_barrierattr_setpshared, pthread_barrierattr_getpshared)
	(pthread_barrierattr_destroy, pthread_barrier_init)
	(pthread_barrier_destroy, pthread_barrier_wait): Export.
	* include/cygwin/types.h (pthread_barrierattr_t)
	(pthread_barrier_t): Declare.
	* include/pthread.h (PTHREAD_BARRIER_SERIAL_THREAD)
	(pthread_barrierattr_init, pthread_barrierattr_setpshared)
	(pthread_barrierattr_getpshared, pthread_barrierattr_destroy)
	(pthread_barrier_init, pthread_barrier_destroy)
	(pthread_barrier_wait): Declare.
	* thread.h (PTHREAD_BARRIER_MAGIC)
	(PTHREAD_BARRIERATTR_MAGIC): Define.
	(class pthread_barrierattr, class pthread_barrier): Declare.
	* thread.cc (delete_and_clear): New local helper function.
	(class pthread_barrierattr, class pthread_barrier): Implement.
	* miscfuncs.h (likely, unlikely): New macros.

--
VH
2016-02-13 16:03:15 +01:00
Yaakov Selkowitz ac2f9e23ec Remove broken ieeefp.h macros
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>
2016-02-12 11:35:56 -06:00
Yaakov Selkowitz 8b8952064c Fix compile with GCC 5 -Werror
newlib/libc/
	* stdio64/freopen64.c: Include <string.h> for memset().
	* stdlib/quick_exit.c: Include <unistd.h> for _exit().
	* string/gnu_basename.c (__gnu_basename): Fix discarded const
	qualifier warning.
	* stdlib/strtold.c: Include "mprec.h" for _strtorx_r().

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-12 10:16:06 -06:00
Corinna Vinschen c4dcfc1bda printf(3): Handle multibyte decimal point in field size computation
This patch fixes the problem reported in
  https://cygwin.com/ml/cygwin/2016-02/msg00014.html

  The 2009 changes to handle multibyte decimal point and thousands
  separator missed to take the length of a multibyte decimal point into
  account when computing the field size.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-08 13:33:17 +01:00
Jon Turney c5fee55606 stdio.h: Use __POSIX_VISIBLE etc. guards for POSIX 1003.1:2001 functions
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>
2016-02-08 10:39:31 +01:00
Игорь Веневцев 352cdbb012 Newlib build is broken if configured with nano-malloc and non-reentrant system calls
Non-reentrant system calls version implies both MISSING_SYSCALL_NAMES
and REENTRANT_SYSCALL_PROVIDED macros to be defined.
Being coupled with --enable-newlib-nano-malloc knob it breaks the build:

bash-4.3$ ../newlib-2.3.0.20160104/configure CC_FOR_TARGET=gcc
AR_FOR_TARGET=ar RANLIB_FOR_TARGET=ranlib CFLAGS_FOR_TARGET="-m32
-DMISSING_SYSCALL_NAMES -DREENTRANT_SYSCALLS_PROVIDED"
--target=i386-elf --enable-newlib-nano-malloc && make

<...omitted output...>

../../../../../../newlib-2.3.0.20160104/newlib/libc/stdlib/nano-mallocr.c:
In function ‘_mallinfo_r’:
../../../../../../newlib-2.3.0.20160104/newlib/libc/stdlib/nano-mallocr.c:489:35:
error: macro "_sbrk_r" requires 2 arguments, but only 1 given
         sbrk_now = _sbrk_r(RCALL 0);
                                   ^
../../../../../../newlib-2.3.0.20160104/newlib/libc/stdlib/nano-mallocr.c:489:20:
error: ‘_sbrk_r’ undeclared (first use in this function)
         sbrk_now = _sbrk_r(RCALL 0);
                    ^
../../../../../../newlib-2.3.0.20160104/newlib/libc/stdlib/nano-mallocr.c:489:20:
note: each undeclared identifier is reported only once for each
function it appears in
Makefile:1512: recipe for target 'lib_a-nano-mallinfor.o' failed
make[8]: *** [lib_a-nano-mallinfor.o] Error 1

In case of non-reentrant system calls _sbrk_r became a macro with TWO
args (defined in reent.h):

#define _sbrk_r(__reent, __incr)  sbrk(__incr)

But in our case only one argument is present. (RCALL 0) is considered
as a single argument despite RCALL itself is a macro:)

So intermediate one-arg macro will be enough to expand args before
final _sbrk_r expansion:

#define _SBRK_R(X) _sbrk_r(X)

Here is a patch:
2016-02-08 10:33:07 +01:00
Igor Venevtsev 7c9651e3cc * newlib/libc/stdio/nano-vfscanf.c: Fix '%X' specifier procesing 2016-02-08 10:24:31 +01:00
Igor Venevtsev fa08ba8b23 * newlib/libc/stdio/nano-vfscanf.c: Fix '%F', '%G' and '%E' specifiers processing 2016-02-08 10:22:17 +01:00
Jeff Johnston c2a27453c6 Change if_nameindex() to use unsigned int i variable.
- i variable used in loop that shifts to right so use
  unsigned int instead
2016-02-04 13:30:14 -05:00
Corinna Vinschen ba4433e47f include/grp.h: Remove prototypes of non-standard functions
* libc/include/grp.h (group_from_gid): Remove prototype.
	(setgrfile): Ditto.
	(setgroupent): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-29 13:39:57 +01:00
Steve Ellcey 4792146a0f Fix memcpy bug that reads past end of buffer.
* libc/machine/mips/memcpy.S (memcpy): Fix read past end of
	input.
2016-01-28 14:08:35 -08:00
Yaakov Selkowitz a710c89dcb grp.h: use __BSD_VISIBLE and __XSI_VISIBLE guards
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>
2016-01-28 15:41:59 -06:00
Thomas Preud'homme 69f4c40291 Make macro checks ARMv8-M baseline proof
libgloss:

        * arm/Makefile.in: Add newlib/libc/machine/arm to the include path if
        newlib is present.
        * arm/arm.h: Include acle-compat.h.
        (THUMB_V7_V6M): Rename to ...
        (PREFER_THUMB): This.  Use ACLE macros __ARM_ARCH_ISA_ARM instead of
        __ARM_ARCH_6M__ to decide whether to define it.
        (THUMB1_ONLY): Define for Thumb-1 only targets.
        (THUMB_V7M_V6M): Rename to ...
        (THUMB_VXM): This.  Defined based on __ARM_ARCH_ISA_ARM, excluding
        ARMv7.
        * arm/crt0.S: Use THUMB1_ONLY rather than __ARM_ARCH_6M__,
        !__ARM_ARCH_ISA_ARM rather than THUMB_V7M_V6M for fp enabling, and
        PREFER_THUMB rather than THUMB_V7_V6M.  Rename other occurences of
        THUMB_V7M_V6M to THUMB_VXM.
        * arm/linux-crt0.c: Likewise.
        * arm/redboot-crt0.S: Likewise.
        * arm/swi.h: Likewise.
        * arm/trap.S: Likewise.

newlib:

        * libc/machine/arm/memcpy-stub.c: Use ACLE macros __ARM_ARCH_ISA_THUMB
        and __ARM_ARCH_ISA_ARM to check for Thumb-2 only targets rather than
        __ARM_ARCH and __ARM_ARCH_PROFILE.
        * libc/machine/arm/memcpy.S: Likewise.
        * libc/machine/arm/setjmp.S: Likewise for Thumb-1 only target and
        include acle-compat.h.
        * libc/machine/arm/strcmp.S: Likewise for Thumb-1 and Thumb-2 only
        target and include acle-compat.h.
        * libc/sys/arm/arm.h: Include acle-compat.h.
        (THUMB_V7_V6M): Rename to ...
        (PREFER_THUMB): This.  Use ACLE macro __ARM_ARCH_ISA_ARM instead of
        __ARM_ARCH_6M__ to decide whether to define it.
        (THUMB1_ONLY): Define for Thumb-1 only targets.
        (THUMB_V7M_V6M): Rename to ...
        (THUMB_VXM): This.  Defined based on __ARM_ARCH_ISA_ARM, excluding
        ARMv7.
        * libc/sys/arm/crt0.S: Use PREFER_THUMB rather than THUMB_V7_V6M and
        rename THUMB_V7M_V6M into THUMB_VXM.
        * libc/sys/arm/swi.h: Likewise.
2016-01-28 11:26:37 +01:00
Corinna Vinschen 0b42ea7960 Deprecate newlib and winsup ChangeLog files
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-28 11:15:33 +01:00
Jeff Johnston 06cd7127e3 Fix up errors in regenerated files for 2.3.0 release. 2016-01-04 12:57:31 -05:00
Jeff Johnston ad7b3cde9c Regenerate files for newlib 2.3.0. 2015-12-21 21:32:11 -05:00
Jeff Johnston c2bbc54a62 Fix atexit logic to honor _ATEXIT_DYNAMIC_ALLOC setting.
If small reent is enabled (_REENT_SMALL is defined) then malloc() was
used in __register_exitproc() even if user requested it to be disabled
(_ATEXIT_DYNAMIC_ALLOC is defined). With this fix, function fails when
_ATEXIT_DYNAMIC_ALLOC is defined and whole static storage is already
used.

2015-12-21  Freddie Chopin  <freddie.chopin@gmail.com>

        * libc/stdlib/__atexit.c (__register_exitproc): Fix for
        _ATEXIT_DYNAMIC_ALLOC.
2015-12-21 11:53:14 -05:00
Jeff Johnston d2bb300b9b Add static instance of _on_exit_args for _REENT_SMALL platforms.
2015-12-21  Freddie Chopin  <freddie.chopin@gmail.com>

        * libc/stdlib/on_exit_args.{c,h}: New files.
        * libc/stdlib/Makefile.am: Add new source file.
        * libc/stdlib/Makefile.in: Regenerate.
        * libc/stdlib/__atexit.c (__register_exitproc): Initialize
        _on_exit_args_ptr field of _GLOBAL_ATEXIT on first run.
        * libc/stdlib/on_exit.c: Force linking of static instance of
        _on_exit_args.
        * libc/stdlib/cxa_atexit.c: Likewise.
2015-12-21 11:49:28 -05:00
Anton Kolesov 06537f05d4 ARC: Use new definitions for optional ARC CPU features
GCC for ARC has been updated to provide consistent naming of preprocessor
definitions for different optional architecture features:

    * __ARC_BARREL_SHIFTER__ instead of __Xbarrel_shifter for
      -mbarrel-shifter
    * __ARC_LL64__ instead of __LL64__ for -mll64
    * __ARCEM__ instead of __EM__ for -mcpu=arcem
    * __ARCHS__ instead of __HS__ for -mcpu=archs
    * etc (not used in newlib)

This patch updates assembly routines for ARC to use new definitions instead
of a deprecated ones. To ensure compatibility with older compiler new
definitions are also defined in asm.h if needed, based on deprecated
preprocessor definitions.

*** newlib/ChangeLog ***
2015-12-15  Anton Kolesov  <Anton.Kolesov@synopsys.com>

	* libc/machine/arc/asm.h: Define new GCC definition for old compiler.
	* libc/machine/arc/memcmp-bs-norm.S: Use new GCC defines to detect
	  processor features.
	* libc/machine/arc/memcmp.S: Likewise.
	* libc/machine/arc/memcpy-archs.S: Likewise.
	* libc/machine/arc/memcpy-bs.S: Likewise.
	* libc/machine/arc/memcpy.S: Likewise.
	* libc/machine/arc/memset-archs.S: Likewise.
	* libc/machine/arc/memset-bs.S: Likewise.
	* libc/machine/arc/memset.S: Likewise.
	* libc/machine/arc/setjmp.S: Likewise.
	* libc/machine/arc/strchr-bs-norm.S: Likewise.
	* libc/machine/arc/strchr-bs.S: Likewise.
	* libc/machine/arc/strchr.S: Likewise.
	* libc/machine/arc/strcmp-archs.S: Likewise.
	* libc/machine/arc/strcmp.S: Likewise.
	* libc/machine/arc/strcpy-bs-arc600.S: Likewise.
	* libc/machine/arc/strcpy-bs.S: Likewise.
	* libc/machine/arc/strcpy.S: Likewise.
	* libc/machine/arc/strlen-bs-norm.S: Likewise.
	* libc/machine/arc/strlen-bs.S: Likewise.
	* libc/machine/arc/strlen.S: Likewise.
	* libc/machine/arc/strncpy-bs.S: Likewise.
	* libc/machine/arc/strncpy.S: Likewise.

Signed-off-by: Anton Kolesov <Anton.Kolesov@synopsys.com>
2015-12-17 22:48:16 +01:00
Corinna Vinschen 088f7a7239 Remove inclusion of sys/select.h in sys/types.h for backward compat
* libc/include/sys/types.h: Remove including <sys/select.h>.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-17 22:45:19 +01:00
Sebastian Huber f376e4f93b Add _REENT_INIT_PTR_ZEROED()
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().
2015-12-14 15:44:28 +01:00
Sebastian Huber 01885f533d FreeBSD compatibility for <sys/select.h>
* 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.
2015-12-14 15:39:44 +01:00
Freddie Chopin c39ad27d9e Add missing lock releases in __register_exitproc().
In some code paths the __atexit_lock held by this function was not
released when returning with an error.

        * libc/stdlib/__atexit.c (__register_exitproc): Always release
        lock before return.
2015-12-14 14:31:36 +01:00
Thomas Preud'homme 5b9873fa72 Check for 64 FP instructions availability in libm before using them
Currently, double precision math functions in newlib/libm/machine/arm detect whether neon instructions can be used for double precision computation by checking the architecture version (>= 8) and the availability of floating-point instructions. However, these instructions would not be available if targeting fpv5-sp-d16 as the FPU, which by definition does not have 64bit float instructions. This patch adds a check that __ARM_FP advertises 64bit float instructions.

        * libm/machine/arm/s_ceil.c: Also check that 64bit FP instructions are
        available in the guard.
        * libm/machine/arm/s_floor.c: Likewise.
        * libm/machine/arm/s_nearbyint.c: Likewise.
        * libm/machine/arm/s_rint.c: Likewise.
        * libm/machine/arm/s_round.c: Likewise.
        * libm/machine/arm/s_trunc.c: Likewise.
2015-12-09 10:30:31 +01:00
Corinna Vinschen 91a8eacec6 Add missing checks for __SNLK flag
* libc/stdio/fclose.c (_fclose_r): Make _flockfile/_funlockfile calls
        dependent on __SNLK flag.
        * libc/stdio/findfp.c (__fp_lock): Ditto.
        (__fp_unlock): Ditto.
        * libc/stdio/freopen.c (_freopen_r): Ditto.
        * libc/stdio64/freopen64.c (_freopen64_r): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-08 21:23:22 +01:00
Corinna Vinschen 414e794811 Fix re-initialization of FILE flags and mbstate in freopen
* libc/stdio/freopen.c (_freopen_r): Only reset __SWID bit per SUSv4.
        * libc/stdio64/freopen64.c (_freopen64_r): Add missing resetting of
        flag values and _mbstate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-08 18:44:23 +01:00
Nick Withers 5644f71428 Add definitions for NBBY to arm and rtems targets
* libc/sys/arm/sys/param.h (NBBY): Define if not already defined.
	* libc/sys/rtems/include/sys/param.h (NBBY): Define.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 16:31:00 +01:00
Corinna Vinschen 08184b362e Move fd_stuff from sys/types.h to sys/select.h
* 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>
2015-12-07 16:28:22 +01:00
Corinna Vinschen 1628bb8995 Only build _strtodg_r on targets supporting a distinct long double type
* libc/stdlib/strtodg.c: Add ifdef to check _HAVE_LONG_DOUBLE and
	_LDBL_EQ_DBL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-26 10:13:53 +01:00
Steve Ellcey 10677229b9 libc/stdlib/strtorx.c: Fix ifdef to check _LDBL_EQ_DBL. 2015-11-24 13:59:31 -08:00
Marcus Shawcroft 8e62ab4ccc [ARM] Adjust strcmp-armv7.S selection logic.
Reformulate the strcmp-armv7.S selection logic around the architecture
features required by the implementation code rather (some) version of
the architecture that expose those features.
2015-11-23 15:22:26 +00:00
Marcus Shawcroft dc38827570 [ARM] Factor out the thumb2 -Os implementation.
The patch moves the inline ASM thumb2 -Os implementation out into its
own .S file.

Tested by building newlib and comparing libc.a binaries before and
after for all permutations of:

      Architectures:
        armv4 armv4t armv5 armv5t armv5te armv6 armv6j armv6k
        armv6z armv6kz armv6t2 armv6-m armv6s-m armv7 armv7-a
        armv7ve armv7-r armv7-m armv7e-m armv8-a iwmmxt iwmmxt2

      ISAs:
        thumb arm

      Optimization Levels:
        Os O2

      Excluding:
        armv6s-m -mthumb
        armv6-m -mthumb

        armv6zk -mthumb
        armv6z -mthumb
        armv6k -mthumb
        armv6j -mthumb
2015-11-23 15:21:47 +00:00
Corinna Vinschen 666a3482a5 Handle multibyte decimapl point in strtold.
* libc/stdlib/strtodg.c: Define USE_LOCALE.
	(_strtodg_r): Handle multibyte decimal point.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-21 16:40:21 +01:00
Corinna Vinschen fbace81684 Import correctly working strtold from David M. Gay.
* libc/stdlib/Makefile.am (GENERAL_SOURCES): Add strtodg.c and
	strtorx.c.
	* libc/stdlib/Makefile.in: Regenerate.
	* libc/stdlib/strtodg.c: New file implementing generic string to long
	double conversion.
	* libc/stdlib/strtorx.c: New file, implementing IEEE format string to
	long double conversion.
	* libc/stdlib/mprec.h (_strtodg_r): Declare.
	(_strtorx_r): Declare.
	* libc/stdlib/gdtoa.h (__UShort): Define.
	* libc/stdlib/strtold.c (__flt_rounds): Define for i386 and x86_64
	target.
	(FLT_ROUNDS): Define, as 0 on platforms missing a __flt_rounds
	function.
	(_strtold_r): Converted from strtold.  Call _strtorx_r on targets
	supporting distinct long doubles.
	(strtold): Just call _strtold_r.
	* libc/include/stdlib.h (_strtold_r): Declare.
	* libc/stdlib/ldtoa.c (_strtold): Comment out.  Explain why.
	* libc/stdio/vfscanf.c (__SVFSCANF_R): Call _strtold_r instead of
	_strtold.
	* libc/machine/powerpc/vfscanf.c (__svfscanf_r): Ditto.

	* common.din (strtold): Drop redirection to _strtold.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-20 18:14:58 +01:00
Corinna Vinschen 51bf1b81f3 Make match function globally available to stdlib functions.
* libc/stdlib/strtod.c (match): Move from here...
	* libc/stdlib/gdtoa-hexnan.c (match): ...to here.
	* libc/stdlib/mprec.h (match): Declare and add __match define.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-11-20 18:03:05 +01:00