summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <vinschen@redhat.com>2007-11-12 15:25:48 +0000
committerCorinna Vinschen <vinschen@redhat.com>2007-11-12 15:25:48 +0000
commit27623abee554fb5ec9a2a1ecf57a2b391e02460f (patch)
tree7cd85faca23380ea6df7731956bc578c75ee341f
parente23cf487a68e3b84e9ab2c67e6aacacb2524c0d7 (diff)
downloadgdb-27623abee554fb5ec9a2a1ecf57a2b391e02460f.tar.gz
2007-07-06 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/sys/time.h (gettimeofday): Change to proper prototype where second parameter is void *. * libc/include/reent.h: Fix prototype for _gettimeofday_r. * libc/time/timer.c (_gettimeofday_r): Change prototype accordingly. 2007-06-13 Patrick Mansfield <patmans@us.ibm.com> * libc/include/sys/unistd.h: Change usleep prototype to Posix. 2007-01-05 Brian Ford <Brian.Ford@FlightSafety.com> * configure.host (*-*-cygwin*): Define HAVE_BLKSIZE.
-rw-r--r--newlib/ChangeLog15
-rw-r--r--newlib/configure.host745
-rw-r--r--newlib/libc/include/reent.h101
-rw-r--r--newlib/libc/include/sys/time.h83
-rw-r--r--newlib/libc/include/sys/unistd.h340
-rw-r--r--newlib/libc/reent/timer.c113
6 files changed, 1397 insertions, 0 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 1433fbe7305..7f3dfb99dcb 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,18 @@
+2007-07-06 Jeff Johnston <jjohnstn@redhat.com>
+
+ * libc/include/sys/time.h (gettimeofday): Change to proper
+ prototype where second parameter is void *.
+ * libc/include/reent.h: Fix prototype for _gettimeofday_r.
+ * libc/time/timer.c (_gettimeofday_r): Change prototype accordingly.
+
+2007-06-13 Patrick Mansfield <patmans@us.ibm.com>
+
+ * libc/include/sys/unistd.h: Change usleep prototype to Posix.
+
+2007-01-05 Brian Ford <Brian.Ford@FlightSafety.com>
+
+ * configure.host (*-*-cygwin*): Define HAVE_BLKSIZE.
+
2006-12-14 Jeff Johnston <jjohnstn@redhat.com>
Eric Blake <ebb9@byu.net>
diff --git a/newlib/configure.host b/newlib/configure.host
new file mode 100644
index 00000000000..487a140464f
--- /dev/null
+++ b/newlib/configure.host
@@ -0,0 +1,745 @@
+# configure.host
+
+# This shell script handles all host based configuration for newlib.
+# It sets various shell variables based on the the host and the
+# configuration options. You can modify this shell script without
+# needing to rerun autoconf.
+
+# This shell script should be invoked as
+# . configure.host
+# If it encounters an error, it will exit with a message.
+
+# FIXME: This script is too complicated. It does things in too many
+# different ways. This was taken from the old Cygnus configure script
+# with only minor changes. It should be cleaned up.
+
+# FIXME: The general approach of picking and choosing which
+# directories to configure, other than machine_dir and sys_dir, is
+# potentially confusing.
+
+# It uses the following shell variables:
+# host The configuration host
+# host_cpu The configuration host CPU
+# newlib_mb --enable-newlib-mb ("yes", "no")
+# target_optspace --enable-target-optspace ("yes", "no", "")
+# newlib_multithread --enable-newlib-multithread ("yes", "no", "yes")
+# newlib_elix_level --enable-newlib-elix-level ("1","2","3","4") ("4")
+# newlib_io_long_long --enable-newlib-io-long-long ("yes", "no", "")
+# newlib_io_long_double --enable-newlib-io-long-double ("yes", "no", "")
+
+# It sets the following shell variables:
+# newlib_cflags Special CFLAGS to use when building
+# machine_dir Subdirectory of libc/machine to configure
+# sys_dir Subdirectory of libc/sys to configure
+# have_sys_mach_dir Is there a machine subdirectory in sys subdirectory
+# posix_dir "posix" to build libc/posix, "" otherwise
+# signal_dir "signal" to build libc/signal, "" otherwise
+# stdio64_dir "stdio64" to build libc/stdio64, "" otherwise
+# syscall_dir "syscalls" to build libc/syscalls, "" otherwise
+# unix_dir "unix" to build libc/unix, "" otherwise
+# use_libtool flag: use libtool to build newlib?
+# aext library extension - needed for libtool support
+# oext object file extension - needed for libtool support
+# lpfx library object prefix - generated when no libtool
+# crt1 name of crt1 object if one is provided
+# crt1_dir directory where crt1 object is found
+# have_crt0 "yes"/"no" if crt0 is/isn't provided.
+# "" if crt0 is provided when sys_dir is set
+
+newlib_cflags=
+libm_machine_dir=
+machine_dir=
+sys_dir=
+posix_dir=
+signal_dir=signal
+stdio64_dir=
+syscall_dir=
+unix_dir=
+mach_add_setjmp=
+crt1=
+crt1_dir=
+have_crt0=
+use_libtool=no
+have_sys_mach_dir=no
+default_newlib_io_long_long=no
+default_newlib_io_long_double=no
+default_newlib_io_pos_args=no
+default_newlib_atexit_dynamic_alloc=yes
+aext=a
+oext=o
+lpfx="lib_a-"
+
+case "${target_optspace}:${host}" in
+ yes:*)
+ newlib_cflags="${newlib_cflags} -Os"
+ ;;
+ :m32r-* | :d10v-* | :d30v-* | :avr-* | :m32c-* )
+ newlib_cflags="${newlib_cflags} -Os"
+ ;;
+ no:* | :*)
+ newlib_cflags="${newlib_cflags} -O2"
+ ;;
+esac
+
+# Get the source directories to use for the CPU type.
+# machine_dir should supply CPU dependent routines, such as setjmp.
+# newlib_cflags is passed to gcc when compiling.
+# THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
+
+case "${host_cpu}" in
+ a29k)
+ machine_dir=a29k
+ ;;
+ arc)
+ machine_dir=
+ ;;
+ arm)
+ machine_dir=arm
+ ;;
+ avr*)
+ newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
+ ;;
+ cris | crisv32)
+ machine_dir=cris
+ ;;
+ crx*)
+ machine_dir=crx
+ ;;
+ d10v*)
+ machine_dir=d10v
+ ;;
+ d30v*)
+ machine_dir=d30v
+ ;;
+ ep9312)
+ machine_dir=arm
+ ;;
+ fr30)
+ machine_dir=fr30
+ ;;
+ frv)
+ machine_dir=frv
+ ;;
+ h8300)
+ machine_dir=h8300
+ ;;
+ h8500)
+ machine_dir=h8500
+ ;;
+ hppa*)
+ machine_dir=hppa
+ ;;
+ i960)
+ machine_dir=i960
+ ;;
+ i[34567]86)
+ # Don't use for these since they provide their own setjmp.
+ case ${host} in
+ *-*-sco* | *-*-cygwin*)
+ libm_machine_dir=i386
+ machine_dir=i386
+ ;;
+ *)
+ libm_machine_dir=i386
+ machine_dir=i386
+ mach_add_setjmp=true
+ ;;
+ esac
+ ;;
+ ia64*)
+ ;;
+ iq2000)
+ machine_dir=iq2000
+ ;;
+ m32c)
+ machine_dir=m32c
+ newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -DABORT_PROVIDED -DSMALL_MEMORY"
+ ;;
+
+ m32r*)
+ machine_dir=m32r
+ ;;
+
+ m68hc11|m6811|m68hc12|m6812)
+ machine_dir=m68hc11
+ newlib_cflags="-DPREFER_SIZE_OVER_SPEED -Os -mrelax"
+ CFLAGS="-g -Os"
+ ;;
+
+ m68*)
+ machine_dir=m68k
+ newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
+ ;;
+ m88k)
+ machine_dir=m88k
+ newlib_cflags="${newlib_cflags} -m88000"
+ ;;
+ m88110)
+ machine_dir=m88k
+ newlib_cflags="${newlib_cflags} -m88110"
+ ;;
+ mcore)
+ ;;
+ mips*)
+ machine_dir=mips
+ ;;
+ mmix)
+ ;;
+ mn10200)
+ machine_dir=mn10200
+ ;;
+ mn10300)
+ default_newlib_io_long_long="yes"
+ machine_dir=mn10300
+ ;;
+ mt*)
+ machine_dir=mt
+ ;;
+ or16)
+ ;;
+ or32)
+ ;;
+ powerpc*)
+ machine_dir=powerpc
+ ;;
+ sh | sh64)
+ machine_dir=sh
+ ;;
+ sparc*)
+ machine_dir=sparc
+ # FIXME: Might wish to make MALLOC_ALIGNMENT more generic.
+ newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"
+ ;;
+ strongarm)
+ machine_dir=arm
+ ;;
+ xscale)
+ machine_dir=xscale
+ ;;
+ thumb)
+ machine_dir=arm
+ ;;
+ tic4x|c4x)
+ machine_dir=tic4x
+ ;;
+ tic80*)
+ machine_dir=tic80
+ ;;
+ v70)
+ ;;
+ v810)
+ ;;
+ v850)
+ machine_dir=v850
+ newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mv850 "
+ ;;
+ v850e)
+ machine_dir=v850
+ newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED "
+ ;;
+ w65*)
+ machine_dir=w65
+ ;;
+ xstormy16)
+ machine_dir=xstormy16
+ newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED"
+ newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED"
+ ;;
+ z8k)
+ machine_dir=z8k
+ ;;
+ *)
+ echo '***' "Newlib does not support CPU ${host_cpu}" 1>&2
+ exit 1
+ ;;
+esac
+
+# Disable thread support if requested.
+
+if [ "${newlib_multithread}" = "no" ] ; then
+ newlib_cflags="${newlib_cflags} -D__SINGLE_THREAD__"
+fi
+
+# Disable syscall support if requested.
+
+if [ "${newlib_may_supply_syscalls}" = "no" ] ; then
+ newlib_cflags="${newlib_cflags} -D__NO_SYSCALLS__"
+fi
+
+# Enable multibyte support if requested or it is defaulted
+# for target.
+
+if [ "x${newlib_mb}" = "x" ]; then
+ case "${host}" in
+ i[34567]86-pc-linux-*|*-*-cygwin*)
+ newlib_mb=yes
+ ;;
+ esac
+fi
+
+# Disable printf/scanf floating-point support if requested.
+
+if [ "${newlib_io_float}" = "no" ] ; then
+ newlib_cflags="${newlib_cflags} -DNO_FLOATING_POINT"
+fi
+
+# Verify if shared newlib support is allowed and set appropriate variables
+# We don't want to use libtool for platforms that we are not going to
+# support shared libraries. This is because it adds executable tests which
+# we don't want for most embedded platforms.
+case "${host}" in
+ i[34567]86-pc-linux-*)
+ use_libtool=yes
+ have_sys_mach_dir=yes
+ stdio64_dir=stdio64
+ oext=lo
+ lpfx=
+ aext=la ;;
+ *) ;; #shared library not supported for ${host}
+esac
+
+# Get the source directories to use for the host. unix_dir is set
+# to unix to get some standard Unix routines. posix_dir is set to get some
+# standard Posix routines. sys_dir should supply system dependent routines
+# including crt0.
+# THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
+
+case "${host}" in
+ *-*-cygwin*)
+ posix_dir=posix
+ stdio64_dir=stdio64
+ ;;
+ *-*-netware*)
+ signal_dir=
+ sys_dir=netware
+ ;;
+ *-*-rtems*) # generic RTEMS support
+ sys_dir=rtems
+ # RTEMS POSIX support is all inside RTEMS
+ ;;
+ a29k-*-*)
+ sys_dir=a29khif
+ signal_dir=
+ ;;
+ arc-*-*)
+ sys_dir=arc
+ ;;
+ arm-*-*)
+ sys_dir=arm
+ if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
+ have_crt0="no"
+ fi
+ ;;
+ crx*)
+ sys_dir=
+ ;;
+ d10v*)
+ sys_dir=d10v
+ ;;
+ d30v*)
+ sys_dir=
+ ;;
+ ep9312-*-*)
+ sys_dir=arm
+ if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
+ have_crt0="no"
+ fi
+ ;;
+ frv*)
+ sys_dir=
+ ;;
+ h8300-*-hms*)
+ sys_dir=h8300hms
+ ;;
+ h8300-*-elf*)
+ sys_dir=h8300hms
+ ;;
+ h8300-*-coff*)
+ sys_dir=h8300hms
+ ;;
+ h8300-*-xray*)
+ sys_dir=h8300xray
+ ;;
+ h8500-*-hms*)
+ sys_dir=h8500hms
+ ;;
+ h8500-*-elf*)
+ sys_dir=h8500hms
+ ;;
+ i[34567]86-*-rdos*)
+ sys_dir=rdos
+ newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
+ ;;
+ i[34567]86-*-sco*)
+ sys_dir=sysvi386
+ unix_dir=unix
+ ;;
+ i[34567]86-pc-linux-*)
+ sys_dir=linux
+ unix_dir=unix
+ posix_dir=posix
+ crt1=crt1.o
+ crt1_dir=libc/sys/${sys_dir}
+ gcc_dir=`gcc -print-search-dirs | awk '/^install:/{print $2}'`
+ default_newlib_io_long_double="yes"
+ default_newlib_io_long_long="yes"
+ default_newlib_io_pos_args="yes"
+ #newlib_cflags="${newlib_cflags} -Werror" # DEBUGGING ONLY;BREAKS BUILD
+ newlib_cflags="${newlib_cflags} -Wall"
+ newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
+ newlib_cflags="${newlib_cflags} -DHAVE_FCNTL"
+ # --- Required when building a shared library ------------------------
+ newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
+ # --- The three lines below are optional ------------------------------
+ ##newlib_cflags="${newlib_cflags} -nostdinc"
+ ##newlib_cflags="${newlib_cflags} -I`newlib-flags --kernel-dir`/include"
+ ##newlib_cflags="${newlib_cflags} -idirafter ${gcc_dir}include"
+ ;;
+
+ m68hc11-*-*|m6811-*-*|m6812-*-*|m68hc12-*-*)
+ ;;
+
+ m68k-sun-sunos*)
+ unix_dir=unix
+ ;;
+ m8*-bug-*)
+ sys_dir=m88kbug
+ ;;
+ mips*-dec-*)
+ sys_dir=decstation
+ ;;
+ mmix-knuth-mmixware)
+ sys_dir=mmixware
+ ;;
+ powerpcle-*-pe)
+ posix_dir=posix
+ ;;
+ sh*-*)
+ sys_dir=sh
+ ;;
+ sparc-sun-sunos*)
+ sys_dir=sun4
+ unix_dir=unix
+ ;;
+ sparc64*)
+ sys_dir=sparc64
+ unix_dir=unix
+ ;;
+ strongarm-*-*)
+ sys_dir=arm
+ if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
+ have_crt0="no"
+ fi
+ ;;
+ thumb-*-*)
+ sys_dir=arm
+ if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
+ have_crt0="no"
+ fi
+ ;;
+ tic80*)
+ sys_dir=tic80
+ ;;
+ v70-nec-*)
+ sys_dir=sysvnecv70
+ ;;
+ v810-*-*)
+ sys_dir=sysnec810
+ ;;
+ v850-*-*)
+ sys_dir=sysnecv850
+ ;;
+ v850e-*-*)
+ sys_dir=sysnecv850
+ ;;
+ v850ea-*-*)
+ sys_dir=sysnecv850
+ ;;
+ w65-*-*)
+ sys_dir=w65
+ ;;
+ xscale-*-*)
+ sys_dir=arm
+ if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
+ have_crt0="no"
+ fi
+ ;;
+ z8k-*-coff)
+ sys_dir=z8ksim
+ ;;
+esac
+
+# Host specific flag settings -- usually for features that are not
+# general enough or broad enough to be handled above.
+# THIS TABLE IS ALPHA SORTED. KEEP IT THAT WAY.
+
+case "${host}" in
+ *-*-cygwin*)
+ test -z "$cygwin_srcdir" && cygwin_srcdir=`cd ${srcdir}/../winsup/cygwin; pwd`
+ export cygwin_srcdir
+ default_newlib_io_long_long="yes"
+ default_newlib_io_long_double="yes"
+ default_newlib_io_pos_args="yes"
+ CC="${CC} -I${cygwin_srcdir}/include"
+ newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -D_COMPILING_NEWLIB -DHAVE_BLKSIZE -DHAVE_FCNTL -DMALLOC_PROVIDED"
+ syscall_dir=syscalls
+ ;;
+# RTEMS supplies its own versions of some routines:
+# malloc() (reentrant version)
+# exit() RTEMS has a "global" reent to flush
+# signal()/raise() RTEMS has its own including pthread signals
+# _XYZ_r() RTEMS has its own reentrant routines
+#
+# NOTE: When newlib malloc uses a semaphore, RTEMS will switch to that.
+ *-*-rtems*)
+ default_newlib_io_long_long="yes"
+ newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DEXIT_PROVIDED -DMISSING_SYSCALL_NAMES -DSIGNAL_PROVIDED -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_OPENDIR -DNO_EXEC -DHAVE_FCNTL"
+ ;;
+# VxWorks supplies its own version of malloc, and the newlib one
+# doesn't work because VxWorks does not have sbrk.
+ *-wrs-vxworks*)
+ newlib_cflags="${newlib_cflags} -DMALLOC_PROVIDED -DMISSING_SYSCALL_NAMES -DHAVE_FCNTL"
+ ;;
+# UDI doesn't have exec, so system() should fail the right way
+ a29k-amd-udi)
+ newlib_cflags="${newlib_cflags} -DNO_EXEC"
+ syscall_dir=syscalls
+ ;;
+ arc-*-*)
+ syscall_dir=syscalls
+ ;;
+ arm-*-pe)
+ syscall_dir=syscalls
+ ;;
+ arm-*-*)
+ syscall_dir=syscalls
+# If newlib is supplying syscalls, select which debug protocol is being used.
+# ARM_RDP_MONITOR selects the Demon monitor.
+# ARM_RDI_MONITOR selects the Angel monitor.
+# If neither are defined, then hard coded defaults will be used
+# to create the program's environment.
+# If --disable-newlib-supplied-syscalls is specified, then the end-user
+# may specify the protocol via gcc spec files supplied by libgloss.
+# See also thumb below.
+ if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
+# newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
+ newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
+ fi
+ ;;
+ arc*)
+ newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED"
+ ;;
+ avr*)
+ newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
+ ;;
+ cris-*-* | crisv32-*-*)
+ default_newlib_io_long_long="yes"
+ newlib_cflags="${newlib_cflags} -DHAVE_RENAME -D_USE_WRITE -DCOMPACT_CTYPE"
+ syscall_dir=syscalls
+ ;;
+ crx-*-*)
+ newlib_cflags="${newlib_cflags} -DHAVE_RENAME -DMISSING_SYSCALL_NAMES"
+ syscall_dir=
+ ;;
+ d10v*)
+ newlib_cflags="${newlib_cflags} -DSMALL_MEMORY"
+ syscall_dir=syscalls
+ ;;
+ d30v*)
+ newlib_cflags="${newlib_cflags} -DABORT_MESSAGE -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
+ syscall_dir=
+ ;;
+ ep9312-*-*)
+ syscall_dir=syscalls
+ if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
+ newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
+ fi
+ ;;
+ fr30-*-*)
+ syscall_dir=syscalls
+ ;;
+ frv-*-*)
+ syscall_dir=syscalls
+ default_newlib_io_long_long="yes"
+ ;;
+ h8300*-*-*)
+ syscall_dir=syscalls
+ default_newlib_io_long_long="yes"
+ newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
+ # Simulator only extensions for H8300.
+ # Uncomment the next line to enable them.
+ # newlib_cflags="${newlib_cflags} -D__SIMULATOR__"
+ ;;
+ h8500-*-*)
+ syscall_dir=syscalls
+ newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
+ ;;
+ i[34567]86-*-sco*)
+ newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED -DHAVE_FCNTL"
+ ;;
+ i[34567]86-*-netware*)
+ newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES -DNO_EXEC -DABORT_PROVIDED -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DHAVE_FCNTL"
+ ;;
+ iq2000*)
+ syscall_dir=syscalls
+ default_newlib_io_long_long="yes"
+ ;;
+ m32r-*-*)
+ # Pass -msdata=sdata so _impure_ptr goes in .sdata.
+ # We don't generate sda relocs however for upward compatibility.
+ # FIXME: This is necessary because the default multilib doesn't
+ # use --print-multi-lib.
+ newlib_cflags="${newlib_cflags} -msdata=sdata"
+ syscall_dir=syscalls
+ ;;
+ m68hc11-*-*|m6811-*-*|m68hc12-*-*|m6812-*-*)
+ newlib_cflags="${newlib_cflags} -DNO_EXEC -DABORT_PROVIDED -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
+ ;;
+ mcore-*-*)
+ syscall_dir=syscalls
+ ;;
+ mips64vr*-*-*)
+ default_newlib_io_long_long="yes"
+ newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
+ ;;
+ mips*-*-elf*)
+ default_newlib_io_long_long="yes"
+ newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
+ ;;
+ mmix-*)
+ syscall_dir=syscalls
+ # We need every symbol 32-bit aligned, so the invalid
+ # construct with attribute ((alias ("_ctype_b+127"))) breaks.
+ newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
+ ;;
+ mn10?00-*-*)
+ syscall_dir=syscalls
+ ;;
+ powerpc*-*-eabialtivec*)
+ default_newlib_io_long_long="yes"
+ newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
+ ;;
+ powerpc*-*-eabispe*)
+ default_newlib_io_long_long="yes"
+ newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
+ ;;
+ powerpc*-*-eabi* | \
+ powerpc*-*-elf* | \
+ powerpc*-*-linux* | \
+ powerpc*-*-rtem* | \
+ powerpc*-*-sysv* | \
+ powerpc*-*-solaris*)
+ default_newlib_io_long_long="yes"
+ newlib_cflags="${newlib_cflags} -mrelocatable-lib -mno-eabi -mstrict-align -DMISSING_SYSCALL_NAMES"
+ ;;
+ powerpcle-*-pe)
+ newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DHAVE_FCNTL"
+ syscall_dir=syscalls
+ ;;
+ sh*-*-*)
+ default_newlib_io_long_long="yes"
+ syscall_dir=syscalls
+ ;;
+ sparc-sun-sunos*)
+ newlib_cflags="${newlib_cflags} -DSIGNAL_PROVIDED"
+ ;;
+ sparc64-*-*)
+ newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED -DHAVE_BLKSIZE -DHAVE_FCNTL"
+ # This either belongs elsewhere or nowhere. But I need *something*,
+ # so for now it's here ...
+ case "${host_os}" in
+ aoutv8 | *32p)
+ newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=32" ;;
+ *)
+ newlib_cflags="${newlib_cflags} -DTARGET_PTR_SIZE=64" ;;
+ esac
+ ;;
+ strongarm-*-*)
+ syscall_dir=syscalls
+ ;;
+ thumb-*-pe)
+ syscall_dir=syscalls
+# Don't use the debugging protocols just yet.
+ ;;
+ thumb-*-*)
+ syscall_dir=syscalls
+# If newlib is supplying syscalls, select which debug protocol is being used.
+# ARM_RDP_MONITOR selects the Demon monitor.
+# ARM_RDI_MONITOR selects the Angel monitor.
+# If neither are defined, then hard coded defaults will be used
+# to create the program's environment.
+# If --disable-newlib-supplied-syscalls is specified, then the end-user
+# may specify the protocol via gcc spec files supplied by libgloss.
+ if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
+# newlib_cflags="${newlib_cflags} -DARM_RDP_MONITOR"
+ newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
+ fi
+ ;;
+ tic80*)
+ syscall_dir=syscalls
+ ;;
+ v850-*-*)
+ syscall_dir=syscalls
+ ;;
+ v850e-*-*)
+ syscall_dir=syscalls
+ ;;
+ v850ea-*-*)
+ syscall_dir=syscalls
+ ;;
+ w65-*-*)
+ syscall_dir=syscalls
+ newlib_cflags="${newlib_cflags} -DSMALL_DTOA -DSMALL_MEMORY"
+ ;;
+ xscale-*-*)
+ syscall_dir=syscalls
+ newlib_cflags="${newlib_cflags} -DHAVE_SYSTEM -DHAVE_RENAME"
+ if [ "x${newlib_may_supply_syscalls}" = "xyes" ] ; then
+ newlib_cflags="${newlib_cflags} -DARM_RDI_MONITOR"
+ fi
+ ;;
+ xstormy16-*-*)
+ syscall_dir=syscalls
+ ;;
+ z8k-*-*)
+ syscall_dir=syscalls
+ ;;
+ *)
+ newlib_cflags="${newlib_cflags} -DMISSING_SYSCALL_NAMES"
+ syscall_dir=
+ ;;
+esac
+
+# Use defaults for certain settings if not specified by user
+
+# Enable long long support in I/O routines if requested.
+if [ "x${newlib_io_long_long}" = "x" ]; then
+ if [ ${default_newlib_io_long_long} = "yes" ]; then
+ newlib_io_long_long="yes";
+ fi
+fi
+
+# Enable long double support in I/O routines if requested.
+if [ "x${newlib_io_long_double}" = "x" ]; then
+ if [ ${default_newlib_io_long_double} = "yes" ]; then
+ newlib_io_long_double="yes";
+ fi
+fi
+
+# Enable printf positional argument support if requested.
+if [ "x${newlib_io_pos_args}" = "x" ]; then
+ if [ ${default_newlib_io_pos_args} = "yes" ]; then
+ newlib_io_pos_args="yes";
+ fi
+fi
+
+# Disable atexit dynamic allocation if requested.
+if [ "x${newlib_atexit_dynamic_alloc}" = "x" ]; then
+ if [ ${default_newlib_atexit_dynamic_alloc} = "yes" ]; then
+ newlib_atexit_dynamic_alloc="yes";
+ fi
+fi
+
+if test -z "${have_crt0}" && test -n "${sys_dir}"; then
+ have_crt0="yes"
+fi
diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h
new file mode 100644
index 00000000000..639789e7105
--- /dev/null
+++ b/newlib/libc/include/reent.h
@@ -0,0 +1,101 @@
+/* This header file provides the reentrancy. */
+
+/* The reentrant system calls here serve two purposes:
+
+ 1) Provide reentrant versions of the system calls the ANSI C library
+ requires.
+ 2) Provide these system calls in a namespace clean way.
+
+ It is intended that *all* system calls that the ANSI C library needs
+ be declared here. It documents them all in one place. All library access
+ to the system is via some form of these functions.
+
+ There are three ways a target may provide the needed syscalls.
+
+ 1) Define the reentrant versions of the syscalls directly.
+ (eg: _open_r, _close_r, etc.). Please keep the namespace clean.
+ When you do this, set "syscall_dir" to "syscalls" and add
+ -DREENTRANT_SYSCALLS_PROVIDED to newlib_cflags in configure.host.
+
+ 2) Define namespace clean versions of the system calls by prefixing
+ them with '_' (eg: _open, _close, etc.). Technically, there won't be
+ true reentrancy at the syscall level, but the library will be namespace
+ clean.
+ When you do this, set "syscall_dir" to "syscalls" in configure.host.
+
+ 3) Define or otherwise provide the regular versions of the syscalls
+ (eg: open, close, etc.). The library won't be reentrant nor namespace
+ clean, but at least it will work.
+ When you do this, add -DMISSING_SYSCALL_NAMES to newlib_cflags in
+ configure.host.
+
+ Stubs of the reentrant versions of the syscalls exist in the libc/reent
+ source directory and are used if REENTRANT_SYSCALLS_PROVIDED isn't defined.
+ They use the native system calls: _open, _close, etc. if they're available
+ (MISSING_SYSCALL_NAMES is *not* defined), otherwise open, close, etc.
+ (MISSING_SYSCALL_NAMES *is* defined). */
+
+/* WARNING: All identifiers here must begin with an underscore. This file is
+ included by stdio.h and others and we therefore must only use identifiers
+ in the namespace allotted to us. */
+
+#ifndef _REENT_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define _REENT_H_
+
+#include <sys/reent.h>
+#include <sys/_types.h>
+#include <machine/types.h>
+
+#define __need_size_t
+#define __need_ptrdiff_t
+#include <stddef.h>
+
+/* FIXME: not namespace clean */
+struct stat;
+struct tms;
+struct timeval;
+struct timezone;
+
+/* Reentrant versions of system calls. */
+
+extern int _close_r _PARAMS ((struct _reent *, int));
+extern int _execve_r _PARAMS ((struct _reent *, char *, char **, char **));
+extern int _fcntl_r _PARAMS ((struct _reent *, int, int, int));
+extern int _fork_r _PARAMS ((struct _reent *));
+extern int _fstat_r _PARAMS ((struct _reent *, int, struct stat *));
+extern int _getpid_r _PARAMS ((struct _reent *));
+extern int _kill_r _PARAMS ((struct _reent *, int, int));
+extern int _link_r _PARAMS ((struct _reent *, const char *, const char *));
+extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int));
+extern int _open_r _PARAMS ((struct _reent *, const char *, int, int));
+extern _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t));
+extern void *_sbrk_r _PARAMS ((struct _reent *, ptrdiff_t));
+extern int _stat_r _PARAMS ((struct _reent *, const char *, struct stat *));
+extern _CLOCK_T_ _times_r _PARAMS ((struct _reent *, struct tms *));
+extern int _unlink_r _PARAMS ((struct _reent *, const char *));
+extern int _wait_r _PARAMS ((struct _reent *, int *));
+extern _ssize_t _write_r _PARAMS ((struct _reent *, int, const void *, size_t));
+
+/* This one is not guaranteed to be available on all targets. */
+extern int _gettimeofday_r _PARAMS ((struct _reent *, struct timeval *__tp, void *__tzp));
+
+#ifdef __LARGE64_FILES
+
+#if defined(__CYGWIN__) && defined(_COMPILING_NEWLIB)
+#define stat64 __stat64
+#endif
+
+struct stat64;
+
+extern _off64_t _lseek64_r _PARAMS ((struct _reent *, int, _off64_t, int));
+extern int _fstat64_r _PARAMS ((struct _reent *, int, struct stat64 *));
+extern int _open64_r _PARAMS ((struct _reent *, const char *, int, int));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _REENT_H_ */
diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h
new file mode 100644
index 00000000000..9881d33cfe1
--- /dev/null
+++ b/newlib/libc/include/sys/time.h
@@ -0,0 +1,83 @@
+/* time.h -- An implementation of the standard Unix <sys/time.h> file.
+ Written by Geoffrey Noer <noer@cygnus.com>
+ Public domain; no rights reserved. */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#include <_ansi.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _WINSOCK_H
+struct timeval {
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
+
+struct timezone {
+ int tz_minuteswest;
+ int tz_dsttime;
+};
+
+#ifdef __CYGWIN__
+#include <cygwin/sys_time.h>
+#endif /* __CYGWIN__ */
+
+#endif /* _WINSOCK_H */
+
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+struct itimerval {
+ struct timeval it_interval;
+ struct timeval it_value;
+};
+
+/* BSD time macros used by RTEMS code */
+#if defined (__rtems__) || defined (__CYGWIN__)
+
+/* Convenience macros for operations on timevals.
+ NOTE: `timercmp' does not work for >= or <=. */
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+#define timercmp(a, b, CMP) \
+ (((a)->tv_sec == (b)->tv_sec) ? \
+ ((a)->tv_usec CMP (b)->tv_usec) : \
+ ((a)->tv_sec CMP (b)->tv_sec))
+#define timeradd(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
+ if ((result)->tv_usec >= 1000000) \
+ { \
+ ++(result)->tv_sec; \
+ (result)->tv_usec -= 1000000; \
+ } \
+ } while (0)
+#define timersub(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif /* defined (__rtems__) || defined (__CYGWIN__) */
+
+int _EXFUN(gettimeofday, (struct timeval *__p, void *__z));
+int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
+int _EXFUN(utimes, (const char *__path, const struct timeval *__tvp));
+int _EXFUN(getitimer, (int __which, struct itimerval *__value));
+int _EXFUN(setitimer, (int __which, const struct itimerval *__value,
+ struct itimerval *__ovalue));
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _SYS_TIME_H_ */
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
new file mode 100644
index 00000000000..dd309998a2a
--- /dev/null
+++ b/newlib/libc/include/sys/unistd.h
@@ -0,0 +1,340 @@
+#ifndef _SYS_UNISTD_H
+#define _SYS_UNISTD_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <_ansi.h>
+#include <sys/types.h>
+#include <sys/_types.h>
+#define __need_size_t
+#define __need_ptrdiff_t
+#include <stddef.h>
+
+extern char **environ;
+
+void _EXFUN(_exit, (int __status ) _ATTRIBUTE ((noreturn)));
+
+int _EXFUN(access,(const char *__path, int __amode ));
+unsigned _EXFUN(alarm, (unsigned __secs ));
+int _EXFUN(chdir, (const char *__path ));
+int _EXFUN(chmod, (const char *__path, mode_t __mode ));
+#if !defined(__INSIDE_CYGWIN__)
+int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
+#endif
+#if defined(__CYGWIN__) || defined(__rtems__)
+int _EXFUN(chroot, (const char *__path ));
+#endif
+int _EXFUN(close, (int __fildes ));
+char _EXFUN(*ctermid, (char *__s ));
+char _EXFUN(*cuserid, (char *__s ));
+#if defined(__CYGWIN__)
+int _EXFUN(daemon, (int nochdir, int noclose));
+#endif
+int _EXFUN(dup, (int __fildes ));
+int _EXFUN(dup2, (int __fildes, int __fildes2 ));
+#if defined(__CYGWIN__)
+void _EXFUN(endusershell, (void));
+#endif
+int _EXFUN(execl, (const char *__path, const char *, ... ));
+int _EXFUN(execle, (const char *__path, const char *, ... ));
+int _EXFUN(execlp, (const char *__file, const char *, ... ));
+int _EXFUN(execv, (const char *__path, char * const __argv[] ));
+int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[] ));
+int _EXFUN(execvp, (const char *__file, char * const __argv[] ));
+#if defined(__CYGWIN__) || defined(__rtems__)
+int _EXFUN(fchdir, (int __fildes));
+#endif
+int _EXFUN(fchmod, (int __fildes, mode_t __mode ));
+#if !defined(__INSIDE_CYGWIN__)
+int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
+#endif
+pid_t _EXFUN(fork, (void ));
+long _EXFUN(fpathconf, (int __fd, int __name ));
+int _EXFUN(fsync, (int __fd));
+int _EXFUN(fdatasync, (int __fd));
+char _EXFUN(*getcwd, (char *__buf, size_t __size ));
+#if defined(__CYGWIN__)
+int _EXFUN(getdomainname ,(char *__name, size_t __len));
+#endif
+#if !defined(__INSIDE_CYGWIN__)
+gid_t _EXFUN(getegid, (void ));
+uid_t _EXFUN(geteuid, (void ));
+gid_t _EXFUN(getgid, (void ));
+#endif
+int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[] ));
+#if defined(__CYGWIN__)
+long _EXFUN(gethostid, (void));
+#endif
+char _EXFUN(*getlogin, (void ));
+#if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+int _EXFUN(getlogin_r, (char *name, size_t namesize) );
+#endif
+char _EXFUN(*getpass, (const char *__prompt));
+size_t _EXFUN(getpagesize, (void));
+#if defined(__CYGWIN__)
+int _EXFUN(getpeereid, (int, uid_t *, gid_t *));
+#endif
+pid_t _EXFUN(getpgid, (pid_t));
+pid_t _EXFUN(getpgrp, (void ));
+pid_t _EXFUN(getpid, (void ));
+pid_t _EXFUN(getppid, (void ));
+#ifdef __CYGWIN__
+pid_t _EXFUN(getsid, (pid_t));
+#endif
+#if !defined(__INSIDE_CYGWIN__)
+uid_t _EXFUN(getuid, (void ));
+#endif
+#ifdef __CYGWIN__
+char * _EXFUN(getusershell, (void));
+char _EXFUN(*getwd, (char *__buf ));
+int _EXFUN(iruserok, (unsigned long raddr, int superuser, const char *ruser, const char *luser));
+#endif
+int _EXFUN(isatty, (int __fildes ));
+#if !defined(__INSIDE_CYGWIN__)
+int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
+#endif
+int _EXFUN(link, (const char *__path1, const char *__path2 ));
+int _EXFUN(nice, (int __nice_value ));
+#if !defined(__INSIDE_CYGWIN__)
+off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence ));
+#endif
+long _EXFUN(pathconf, (const char *__path, int __name ));
+int _EXFUN(pause, (void ));
+#ifdef __CYGWIN__
+int _EXFUN(pthread_atfork, (void (*)(void), void (*)(void), void (*)(void)));
+#endif
+int _EXFUN(pipe, (int __fildes[2] ));
+ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset));
+ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset));
+_READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte ));
+#if defined(__CYGWIN__)
+int _EXFUN(rresvport, (int *__alport));
+int _EXFUN(revoke, (char *__path));
+#endif
+int _EXFUN(rmdir, (const char *__path ));
+#if defined(__CYGWIN__)
+int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
+#endif
+void * _EXFUN(sbrk, (ptrdiff_t __incr));
+#if !defined(__INSIDE_CYGWIN__)
+#if defined(__CYGWIN__)
+int _EXFUN(setegid, (gid_t __gid ));
+int _EXFUN(seteuid, (uid_t __uid ));
+#endif
+int _EXFUN(setgid, (gid_t __gid ));
+#endif
+#if defined(__CYGWIN__)
+int _EXFUN(setgroups, (int ngroups, const gid_t *grouplist ));
+#endif
+int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
+int _EXFUN(setpgrp, (void ));
+#if defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
+int _EXFUN(setregid, (gid_t __rgid, gid_t __egid));
+int _EXFUN(setreuid, (uid_t __ruid, uid_t __euid));
+#endif
+pid_t _EXFUN(setsid, (void ));
+#if !defined(__INSIDE_CYGWIN__)
+int _EXFUN(setuid, (uid_t __uid ));
+#endif
+#if defined(__CYGWIN__)
+void _EXFUN(setusershell, (void));
+#endif
+unsigned _EXFUN(sleep, (unsigned int __seconds ));
+void _EXFUN(swab, (const void *, void *, ssize_t));
+long _EXFUN(sysconf, (int __name ));
+pid_t _EXFUN(tcgetpgrp, (int __fildes ));
+int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
+char _EXFUN(*ttyname, (int __fildes ));
+#if defined(__CYGWIN__)
+int _EXFUN(ttyname_r, (int, char *, size_t));
+#endif
+int _EXFUN(unlink, (const char *__path ));
+int _EXFUN(vhangup, (void ));
+_READ_WRITE_RETURN_TYPE _EXFUN(write, (int __fd, const void *__buf, size_t __nbyte ));
+
+#ifdef __CYGWIN__
+# define __UNISTD_GETOPT__
+# include <getopt.h>
+# undef __UNISTD_GETOPT__
+#else
+extern char *optarg; /* getopt(3) external variables */
+extern int optind, opterr, optopt;
+int getopt(int, char * const [], const char *);
+extern int optreset; /* getopt(3) external variable */
+#endif
+
+#ifndef _POSIX_SOURCE
+pid_t _EXFUN(vfork, (void ));
+
+extern char *suboptarg; /* getsubopt(3) external variable */
+int getsubopt(char **, char * const *, char **);
+#endif /* _POSIX_SOURCE */
+
+#ifdef _COMPILING_NEWLIB
+/* Provide prototypes for most of the _<systemcall> names that are
+ provided in newlib for some compilers. */
+int _EXFUN(_close, (int __fildes ));
+pid_t _EXFUN(_fork, (void ));
+pid_t _EXFUN(_getpid, (void ));
+int _EXFUN(_link, (const char *__path1, const char *__path2 ));
+_off_t _EXFUN(_lseek, (int __fildes, _off_t __offset, int __whence ));
+#ifdef __LARGE64_FILES
+_off64_t _EXFUN(_lseek64, (int __filedes, _off64_t __offset, int __whence ));
+#endif
+_READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte ));
+void * _EXFUN(_sbrk, (ptrdiff_t __incr));
+int _EXFUN(_unlink, (const char *__path ));
+_READ_WRITE_RETURN_TYPE _EXFUN(_write, (int __fd, const void *__buf, size_t __nbyte ));
+int _EXFUN(_execve, (const char *__path, char * const __argv[], char * const __envp[] ));
+#endif
+
+#if defined(__CYGWIN__) || defined(__rtems__) || defined(__sh__)
+#if !defined(__INSIDE_CYGWIN__)
+int _EXFUN(ftruncate, (int __fd, off_t __length));
+int _EXFUN(truncate, (const char *, off_t __length));
+#endif
+#endif
+#if defined(__CYGWIN__) || defined(__rtems__)
+int _EXFUN(getdtablesize, (void));
+int _EXFUN(setdtablesize, (int));
+useconds_t _EXFUN(ualarm, (useconds_t __useconds, useconds_t __interval));
+int _EXFUN(usleep, (useconds_t __useconds));
+#if !(defined (_WINSOCK_H) || defined (__USE_W32_SOCKETS))
+/* winsock[2].h defines as __stdcall, and with int as 2nd arg */
+ int _EXFUN(gethostname, (char *__name, size_t __len));
+#endif
+char * _EXFUN(mktemp, (char *));
+#if defined(__CYGWIN__)
+void _EXFUN(sync, (void));
+#else /* defined(__rtems__) */
+int _EXFUN(sync, (void));
+#endif
+#endif
+int _EXFUN(readlink, (const char *__path, char *__buf, int __buflen));
+int _EXFUN(symlink, (const char *__name1, const char *__name2));
+
+#define F_OK 0
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+
+# define SEEK_SET 0
+# define SEEK_CUR 1
+# define SEEK_END 2
+
+#include <sys/features.h>
+
+#define STDIN_FILENO 0 /* standard input file descriptor */
+#define STDOUT_FILENO 1 /* standard output file descriptor */
+#define STDERR_FILENO 2 /* standard error file descriptor */
+
+/*
+ * 4.8.1 Get Configurable System Variables, P1003.1b-1993, p. 96
+ *
+ * NOTE: Table 4-2, Configurable System Variables, p. 96
+ */
+
+#define _SC_ARG_MAX 0
+#define _SC_CHILD_MAX 1
+#define _SC_CLK_TCK 2
+#define _SC_NGROUPS_MAX 3
+#define _SC_OPEN_MAX 4
+ /* no _SC_STREAM_MAX */
+#define _SC_JOB_CONTROL 5
+#define _SC_SAVED_IDS 6
+#define _SC_VERSION 7
+#define _SC_PAGESIZE 8
+/* CYGWIN-specific values .. do not touch */
+#define _SC_NPROCESSORS_CONF 9
+#define _SC_NPROCESSORS_ONLN 10
+#define _SC_PHYS_PAGES 11
+#define _SC_AVPHYS_PAGES 12
+/* end of CYGWIN-specific values */
+#define _SC_MQ_OPEN_MAX 13
+#define _SC_MQ_PRIO_MAX 14
+#define _SC_RTSIG_MAX 15
+#define _SC_SEM_NSEMS_MAX 16
+#define _SC_SEM_VALUE_MAX 17
+#define _SC_SIGQUEUE_MAX 18
+#define _SC_TIMER_MAX 19
+#define _SC_TZNAME_MAX 20
+
+#define _SC_ASYNCHRONOUS_IO 21
+#define _SC_FSYNC 22
+#define _SC_MAPPED_FILES 23
+#define _SC_MEMLOCK 24
+#define _SC_MEMLOCK_RANGE 25
+#define _SC_MEMORY_PROTECTION 26
+#define _SC_MESSAGE_PASSING 27
+#define _SC_PRIORITIZED_IO 28
+#define _SC_REALTIME_SIGNALS 29
+#define _SC_SEMAPHORES 30
+#define _SC_SHARED_MEMORY_OBJECTS 31
+#define _SC_SYNCHRONIZED_IO 32
+#define _SC_TIMERS 33
+#define _SC_AIO_LISTIO_MAX 34
+#define _SC_AIO_MAX 35
+#define _SC_AIO_PRIO_DELTA_MAX 36
+#define _SC_DELAYTIMER_MAX 37
+
+/*
+ * P1003.1c/D10, p. 52 adds the following.
+ */
+
+#define _SC_THREAD_KEYS_MAX 38
+#define _SC_THREAD_STACK_MIN 39
+#define _SC_THREAD_THREADS_MAX 40
+#define _SC_TTY_NAME_MAX 41
+
+#define _SC_THREADS 42
+#define _SC_THREAD_ATTR_STACKADDR 43
+#define _SC_THREAD_ATTR_STACKSIZE 44
+#define _SC_THREAD_PRIORITY_SCHEDULING 45
+#define _SC_THREAD_PRIO_INHERIT 46
+/* _SC_THREAD_PRIO_PROTECT was _SC_THREAD_PRIO_CEILING in early drafts */
+#define _SC_THREAD_PRIO_PROTECT 47
+#define _SC_THREAD_PRIO_CEILING _SC_THREAD_PRIO_PROTECT
+#define _SC_THREAD_PROCESS_SHARED 48
+#define _SC_THREAD_SAFE_FUNCTIONS 49
+#define _SC_GETGR_R_SIZE_MAX 50
+#define _SC_GETPW_R_SIZE_MAX 51
+#define _SC_LOGIN_NAME_MAX 52
+#define _SC_THREAD_DESTRUCTOR_ITERATIONS 53
+
+#if !defined(__CYGWIN__) && !defined(__rtems__)
+#define _SC_STREAM_MAX 100
+#define _SC_PRIORITY_SCHEDULING 101
+#endif
+
+# define _PC_LINK_MAX 0
+# define _PC_MAX_CANON 1
+# define _PC_MAX_INPUT 2
+# define _PC_NAME_MAX 3
+# define _PC_PATH_MAX 4
+# define _PC_PIPE_BUF 5
+# define _PC_CHOWN_RESTRICTED 6
+# define _PC_NO_TRUNC 7
+# define _PC_VDISABLE 8
+# define _PC_ASYNC_IO 9
+# define _PC_PRIO_IO 10
+# define _PC_SYNC_IO 11
+#ifdef __CYGWIN__
+/* Ask for POSIX permission bits support. */
+# define _PC_POSIX_PERMISSIONS 90
+/* Ask for full POSIX permission support including uid/gid settings. */
+# define _PC_POSIX_SECURITY 91
+#endif
+
+/* FIXME: This is temporary until winsup gets sorted out. */
+#ifdef __CYGWIN__
+#define MAXPATHLEN (260 - 1 /* NUL */)
+#else
+# define MAXPATHLEN 1024
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _SYS_UNISTD_H */
diff --git a/newlib/libc/reent/timer.c b/newlib/libc/reent/timer.c
new file mode 100644
index 00000000000..6aa4e02f3f1
--- /dev/null
+++ b/newlib/libc/reent/timer.c
@@ -0,0 +1,113 @@
+/* Reentrant versions of times and gettimeofday system calls for the
+ clock and time ANSI C routines.
+ This implementation just calls the times/gettimeofday system calls.
+ Gettimeofday may not be available on all targets. It's presence
+ here is dubious. Consider it for internal use only. */
+
+#include <reent.h>
+#include <time.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <_syslist.h>
+
+/* Some targets provides their own versions of these functions. Those
+ targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
+
+#ifdef _REENT_ONLY
+#ifndef REENTRANT_SYSCALLS_PROVIDED
+#define REENTRANT_SYSCALLS_PROVIDED
+#endif
+#endif
+
+#ifdef REENTRANT_SYSCALLS_PROVIDED
+
+int _dummy_time_syscalls = 1;
+
+#else
+
+/* We use the errno variable used by the system dependent layer. */
+#undef errno
+extern int errno;
+
+/*
+FUNCTION
+ <<_times_r>>---Reentrant version of times
+
+INDEX
+ _times_r
+
+ANSI_SYNOPSIS
+ #include <reent.h>
+ #include <sys/times.h>
+ clock_t _times_r(struct _reent *<[ptr]>, struct tms *<[ptms]>);
+
+TRAD_SYNOPSIS
+ #include <reent.h>
+ #include <sys/times.h>
+ clock_t _times_r(<[ptr]>, <[ptms]>)
+ struct _reent *<[ptr]>;
+ struct tms *<[ptms]>;
+
+DESCRIPTION
+ This is a reentrant version of <<times>>. It
+ takes a pointer to the global data block, which holds
+ <<errno>>.
+*/
+
+clock_t
+_DEFUN (_times_r, (ptr, ptms),
+ struct _reent *ptr _AND
+ struct tms *ptms)
+{
+ clock_t ret;
+
+ ret = _times (ptms);
+ return ret;
+}
+
+/*
+FUNCTION
+ <<_gettimeofday_r>>---Reentrant version of gettimeofday
+
+INDEX
+ _gettimeofday_r
+
+ANSI_SYNOPSIS
+ #include <reent.h>
+ #include <time.h>
+ int _gettimeofday_r(struct _reent *<[ptr]>,
+ struct timeval *<[ptimeval]>,
+ void *<[ptimezone]>);
+
+TRAD_SYNOPSIS
+ #include <reent.h>
+ #include <time.h>
+ int _gettimeofday_r(<[ptr]>, <[ptimeval]>, <[ptimezone]>)
+ struct _reent *<[ptr]>;
+ struct timeval *<[ptimeval]>;
+ void *<[ptimezone]>;
+
+DESCRIPTION
+ This is a reentrant version of <<gettimeofday>>. It
+ takes a pointer to the global data block, which holds
+ <<errno>>.
+
+ This function is only available for a few targets.
+ Check libc.a to see if its available on yours.
+*/
+
+int
+_DEFUN (_gettimeofday_r, (ptr, ptimeval, ptimezone),
+ struct _reent *ptr _AND
+ struct timeval *ptimeval _AND
+ void *ptimezone)
+{
+ int ret;
+
+ errno = 0;
+ if ((ret = _gettimeofday (ptimeval, ptimezone)) == -1 && errno != 0)
+ ptr->_errno = errno;
+ return ret;
+}
+
+#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */