Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-08-17 09:19:18 +0400
committerJeff Johnston <jjohnstn@redhat.com>2002-08-17 09:19:18 +0400
commitad5527663ef5d01f531b4d4b23390c7566c93ee2 (patch)
treeeaffc628056b9323b965c0e309656b4dfb19215d /newlib
parent9e0f101fa9f301ceaa8c6c5152b320ce7d535eb3 (diff)
2002-08-17 Jeff Johnston <jjohnstn@redhat.com>
* Makefile.am: Move cmath stuff into libc/sys/linux. * Makefile.in: Regenerated. * configure.host: Default -DMB_CAPABLE for x86-linux. * libc/include/reent.h: Define _sbrk to take signed int argument. * libc/include/sys/unistd.h: Ditto for _sbrk_r and sbrk. * libc/locale/locale.c[MB_CAPABLE]: Add LC_MESSAGES support and make locale name checking more efficient. Also allow "C-ISO-8859-1" locale for LC_CTYPE and LC_MESSAGES. * libc/reent/sbrkr.c: Change prototype to take ptrdiff_t. * libc/sys/linux/brk.c: Change sbrk prototype. * libc/sys/linux/include/time.h: Remove Cygwin stuff and include <sys/features.h>. (CLOCK_THREAD_CPUTIME): Renamed to CLOCK_THREAD_CPUTIME_ID. (CLOCK_PROCESS_CPUTIME): Renamed to CLOCK_PROCESS_CPUTIME_ID. * libc/sys/linux/sys/cdefs.h: Replace with glibc sys/cdefs.h with a few local additions. * libc/sys/linux/sys/features.h: New file. * libc/sys/linux/sys/unistd.h: Change _sbrk_r and sbrk prototypes to take signed argument. * libc/syscalls/syssbrk.c: Change sbrk, _sbrk_r, and _sbrk prototypes to take signed size argument.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog24
-rw-r--r--newlib/Makefile.am1
-rw-r--r--newlib/Makefile.in1
-rw-r--r--newlib/configure.host2
-rw-r--r--newlib/libc/include/reent.h3
-rw-r--r--newlib/libc/include/sys/unistd.h6
-rw-r--r--newlib/libc/locale/locale.c136
-rw-r--r--newlib/libc/reent/sbrkr.c8
-rw-r--r--newlib/libc/sys/linux/brk.c2
-rw-r--r--newlib/libc/sys/linux/include/time.h19
-rw-r--r--newlib/libc/sys/linux/sys/cdefs.h315
-rw-r--r--newlib/libc/sys/linux/sys/features.h16
-rw-r--r--newlib/libc/sys/linux/sys/unistd.h24
-rw-r--r--newlib/libc/syscalls/syssbrk.c6
14 files changed, 380 insertions, 183 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 6f6f681f9..48d7cc8d0 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,27 @@
+2002-08-17 Jeff Johnston <jjohnstn@redhat.com>
+
+ * Makefile.am: Move cmath stuff into libc/sys/linux.
+ * Makefile.in: Regenerated.
+ * configure.host: Default -DMB_CAPABLE for x86-linux.
+ * libc/include/reent.h: Define _sbrk to take signed int argument.
+ * libc/include/sys/unistd.h: Ditto for _sbrk_r and sbrk.
+ * libc/locale/locale.c[MB_CAPABLE]: Add LC_MESSAGES support and
+ make locale name checking more efficient. Also allow "C-ISO-8859-1"
+ locale for LC_CTYPE and LC_MESSAGES.
+ * libc/reent/sbrkr.c: Change prototype to take ptrdiff_t.
+ * libc/sys/linux/brk.c: Change sbrk prototype.
+ * libc/sys/linux/include/time.h: Remove Cygwin stuff and
+ include <sys/features.h>.
+ (CLOCK_THREAD_CPUTIME): Renamed to CLOCK_THREAD_CPUTIME_ID.
+ (CLOCK_PROCESS_CPUTIME): Renamed to CLOCK_PROCESS_CPUTIME_ID.
+ * libc/sys/linux/sys/cdefs.h: Replace with glibc sys/cdefs.h
+ with a few local additions.
+ * libc/sys/linux/sys/features.h: New file.
+ * libc/sys/linux/sys/unistd.h: Change _sbrk_r and sbrk prototypes
+ to take signed argument.
+ * libc/syscalls/syssbrk.c: Change sbrk, _sbrk_r, and _sbrk
+ prototypes to take signed size argument.
+
2002-08-16 Thomas Fitzsimmons <fitzsim@redhat.com>
* libc/sys/linux/cmath: New directory.
diff --git a/newlib/Makefile.am b/newlib/Makefile.am
index 26c46dfdb..6f3a217d1 100644
--- a/newlib/Makefile.am
+++ b/newlib/Makefile.am
@@ -114,7 +114,6 @@ LIBC_OBJECTLISTS = \
libc/reent/objectlist.awk.in \
libc/errno/objectlist.awk.in \
libc/stdio/objectlist.awk.in \
- libc/sys/linux/cmath/objectlist.awk.in \
$(MACHINE_OBJECTLIST) \
$(SYS_OBJECTLIST) \
$(SYS_MACH_OBJECTLIST)
diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index d2572a828..a8ad97bf8 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -212,7 +212,6 @@ LIBC_OBJECTLISTS = \
libc/reent/objectlist.awk.in \
libc/errno/objectlist.awk.in \
libc/stdio/objectlist.awk.in \
- libc/sys/linux/cmath/objectlist.awk.in \
$(MACHINE_OBJECTLIST) \
$(SYS_OBJECTLIST) \
$(SYS_MACH_OBJECTLIST)
diff --git a/newlib/configure.host b/newlib/configure.host
index 6e1e94715..63c636d6b 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -330,7 +330,7 @@ case "${host}" in
newlib_cflags="${newlib_cflags} -Wall"
newlib_cflags="${newlib_cflags} -D_I386MACH_ALLOW_HW_INTERRUPTS"
newlib_cflags="${newlib_cflags} -D_LOOSE_KERNEL_NAMES -DHAVE_FCNTL"
- newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS"
+ newlib_cflags="${newlib_cflags} -DWANT_IO_POS_ARGS -DMB_CAPABLE"
# --- Required when building a shared library ------------------------
newlib_cflags="${newlib_cflags} -fPIC -D_I386MACH_NEED_SOTYPE_FUNCTION"
# --- The three lines below are optional ------------------------------
diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h
index b54e4cbb8..8f1077920 100644
--- a/newlib/libc/include/reent.h
+++ b/newlib/libc/include/reent.h
@@ -50,6 +50,7 @@ extern "C" {
#include <machine/types.h>
#define __need_size_t
+#define __need_ptrdiff_t
#include <stddef.h>
/* FIXME: not namespace clean */
@@ -71,7 +72,7 @@ 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 *, 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 *));
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
index 1565bf0f8..d6ff2500a 100644
--- a/newlib/libc/include/sys/unistd.h
+++ b/newlib/libc/include/sys/unistd.h
@@ -91,11 +91,7 @@ int _EXFUN(rmdir, (const char *__path ));
#if defined(__CYGWIN__)
int _EXFUN(ruserok, (const char *rhost, int superuser, const char *ruser, const char *luser));
#endif
-#if defined(__rtems__)
void * _EXFUN(sbrk, (ptrdiff_t __incr));
-#else
-void * _EXFUN(sbrk, (size_t __incr));
-#endif
#if defined(__CYGWIN__)
int _EXFUN(setegid, (gid_t __gid ));
int _EXFUN(seteuid, (uid_t __uid ));
@@ -141,7 +137,7 @@ 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 ));
_READ_WRITE_RETURN_TYPE _EXFUN(_read, (int __fd, void *__buf, size_t __nbyte ));
-void * _EXFUN(_sbrk, (size_t __incr));
+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[] ));
diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
index 4487f7d47..7a4db069c 100644
--- a/newlib/libc/locale/locale.c
+++ b/newlib/libc/locale/locale.c
@@ -45,8 +45,9 @@ locale.
This is a minimal implementation, supporting only the required <<``C''>>
value for <[locale]>; strings representing other locales are not
honored unless MB_CAPABLE is defined in which case three new
-extensions are allowed for LC_CTYPE only: <<''C-JIS''>>, <<''C-EUCJP''>>,
-and <<''C-SJIS''>>. (<<``''>> is also accepted; it represents the default locale
+extensions are allowed for LC_CTYPE or LC_MESSAGES only: <<''C-JIS''>>,
+<<''C-EUCJP''>>, <<''C-SJIS''>>, or <<''C-ISO-8859-1''>>. (<<``''>> is
+also accepted; it represents the default locale
for an implementation, here equivalent to <<``C''>>.)
If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns
@@ -96,6 +97,10 @@ int __declspec(dllexport) __mb_cur_max = 1;
int __mb_cur_max = 1;
#endif
+int __nlocale_changed = 0;
+int __mlocale_changed = 0;
+char *_PathLocale = NULL;
+
static _CONST struct lconv lconv =
{
".", "", "", "", "", "", "", "", "", "",
@@ -104,6 +109,10 @@ static _CONST struct lconv lconv =
};
+char * _EXFUN(__locale_charset,(_VOID));
+
+static char *charset = "ISO-8859-1";
+
char *
_DEFUN(_setlocale_r, (p, category, locale),
struct _reent *p _AND
@@ -120,12 +129,14 @@ _DEFUN(_setlocale_r, (p, category, locale),
}
return "C";
#else
- static char lc_ctype[8] = "C";
- static char last_lc_ctype[8] = "C";
+ static char lc_ctype[12] = "C";
+ static char last_lc_ctype[12] = "C";
+ static char lc_messages[12] = "C";
+ static char last_lc_messages[12] = "C";
if (locale)
{
- if (category != LC_CTYPE)
+ if (category != LC_CTYPE && category != LC_MESSAGES)
{
if (strcmp (locale, "C") && strcmp (locale, ""))
return 0;
@@ -133,39 +144,117 @@ _DEFUN(_setlocale_r, (p, category, locale),
{
strcpy (last_lc_ctype, lc_ctype);
strcpy (lc_ctype, locale);
+ strcpy (last_lc_messages, lc_messages);
+ strcpy (lc_messages, locale);
__mb_cur_max = 1;
}
}
else
- {
- if (strcmp (locale, "C") && strcmp (locale, "") &&
- strcmp (locale, "C") && strcmp (locale, "C-JIS") &&
- strcmp (locale, "C-EUCJP") && strcmp (locale, "C-SJIS") &&
- strcmp (locale, "UTF-8"))
- return 0;
-
- strcpy (last_lc_ctype, lc_ctype);
- strcpy (lc_ctype, locale);
+ {
+ if (locale[0] != 'C')
+ return 0;
+ if (locale[1] == '-')
+ {
+ switch (locale[2])
+ {
+ case 'U':
+ if (strcmp (locale, "C-UTF-8"))
+ return 0;
+ break;
+ case 'J':
+ if (strcmp (locale, "C-JIS"))
+ return 0;
+ break;
+ case 'E':
+ if (strcmp (locale, "C-EUCJP"))
+ return 0;
+ break;
+ case 'S':
+ if (strcmp (locale, "C-SJIS"))
+ return 0;
+ break;
+ case 'I':
+ if (strcmp (locale, "C-ISO-8859-1"))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ if (category == LC_CTYPE)
+ {
+ strcpy (last_lc_ctype, lc_ctype);
+ strcpy (lc_ctype, locale);
- if (!strcmp (locale, "UTF-8"))
- __mb_cur_max = 6;
- else if (!strcmp (locale, "C-JIS"))
- __mb_cur_max = 8;
- else if (strlen (locale) > 1)
- __mb_cur_max = 2;
+ __mb_cur_max = 1;
+ if (locale[1] == '-')
+ {
+ switch (locale[2])
+ {
+ case 'U':
+ __mb_cur_max = 6;
+ break;
+ case 'J':
+ __mb_cur_max = 8;
+ break;
+ case 'E':
+ __mb_cur_max = 2;
+ break;
+ case 'S':
+ __mb_cur_max = 2;
+ break;
+ case 'I':
+ default:
+ __mb_cur_max = 1;
+ }
+ }
+ }
else
- __mb_cur_max = 1;
+ {
+ strcpy (last_lc_messages, lc_messages);
+ strcpy (lc_messages, locale);
+
+ charset = "ISO-8859-1";
+ if (locale[1] == '-')
+ {
+ switch (locale[2])
+ {
+ case 'U':
+ charset = "UTF-8";
+ break;
+ case 'J':
+ charset = "JIS";
+ break;
+ case 'E':
+ charset = "EUCJP";
+ break;
+ case 'S':
+ charset = "SJIS";
+ break;
+ case 'I':
+ charset = "ISO-8859-1";
+ break;
+ default:
+ return 0;
+ }
+ }
+ }
}
p->_current_category = category;
p->_current_locale = locale;
if (category == LC_CTYPE)
return last_lc_ctype;
+ else if (category == LC_MESSAGES)
+ return last_lc_messages;
}
else
{
if (category == LC_CTYPE)
return lc_ctype;
+ else if (category == LC_MESSAGES)
+ return lc_messages;
}
return "C";
@@ -173,6 +262,11 @@ _DEFUN(_setlocale_r, (p, category, locale),
}
+char *
+_DEFUN_VOID(__locale_charset)
+{
+ return charset;
+}
struct lconv *
_DEFUN(_localeconv_r, (data),
diff --git a/newlib/libc/reent/sbrkr.c b/newlib/libc/reent/sbrkr.c
index 31c9de3d5..8be82ddb1 100644
--- a/newlib/libc/reent/sbrkr.c
+++ b/newlib/libc/reent/sbrkr.c
@@ -34,13 +34,13 @@ INDEX
ANSI_SYNOPSIS
#include <reent.h>
- void *_sbrk_r(struct _reent *<[ptr]>, size_t <[incr]>);
+ void *_sbrk_r(struct _reent *<[ptr]>, ptrdiff_t <[incr]>);
TRAD_SYNOPSIS
#include <reent.h>
void *_sbrk_r(<[ptr]>, <[incr]>)
struct _reent *<[ptr]>;
- size_t <[incr]>;
+ ptrdiff_t <[incr]>;
DESCRIPTION
This is a reentrant version of <<sbrk>>. It
@@ -51,10 +51,10 @@ DESCRIPTION
void *
_sbrk_r (ptr, incr)
struct _reent *ptr;
- size_t incr;
+ ptrdiff_t incr;
{
char *ret;
- void *_sbrk(size_t);
+ void *_sbrk(ptrdiff_t);
errno = 0;
if ((ret = (char *)(_sbrk (incr))) == (void *) -1 && errno != 0)
diff --git a/newlib/libc/sys/linux/brk.c b/newlib/libc/sys/linux/brk.c
index 87ebfe0e7..91bb367e7 100644
--- a/newlib/libc/sys/linux/brk.c
+++ b/newlib/libc/sys/linux/brk.c
@@ -28,7 +28,7 @@ int brk(void *end_data_segment)
}
-void *sbrk(size_t increment) /* SHOULD be ptrdiff_t */
+void *sbrk(ptrdiff_t increment) /* SHOULD be ptrdiff_t */
{
char *old_brk,*new_brk;
diff --git a/newlib/libc/sys/linux/include/time.h b/newlib/libc/sys/linux/include/time.h
index c27e502e6..2db33242e 100644
--- a/newlib/libc/sys/linux/include/time.h
+++ b/newlib/libc/sys/linux/include/time.h
@@ -104,22 +104,9 @@ extern __IMPORT char *_tzname[2];
#define tzname _tzname
#endif
-/* CYGWIN also exposes daylight and timezone in the name space */
-#ifdef __CYGWIN__
-#ifndef daylight
-#define daylight _daylight
-#endif
-#if timezonevar
-#ifndef timezone
-#define timezone ((long int) _timezone)
-#endif
-#else
-char *_EXFUN(timezone, (void));
-#endif
-#endif /* __CYGWIN__ */
#endif /* !__STRICT_ANSI__ */
-#include <bits/posix_opt.h>
+#include <sys/features.h>
#if defined(_POSIX_TIMERS)
@@ -187,7 +174,7 @@ int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp));
the identifier of the CPU_time clock associated with the PROCESS
making the function call. */
-#define CLOCK_PROCESS_CPUTIME (clockid_t)2
+#define CLOCK_PROCESS_CPUTIME_ID (clockid_t)2
#endif
@@ -197,7 +184,7 @@ int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp));
the identifier of the CPU_time clock associated with the THREAD
making the function call. */
-#define CLOCK_THREAD_CPUTIME (clockid_t)3
+#define CLOCK_THREAD_CPUTIME_ID (clockid_t)3
#endif
diff --git a/newlib/libc/sys/linux/sys/cdefs.h b/newlib/libc/sys/linux/sys/cdefs.h
index 1108a7dab..459785bcb 100644
--- a/newlib/libc/sys/linux/sys/cdefs.h
+++ b/newlib/libc/sys/linux/sys/cdefs.h
@@ -1,125 +1,230 @@
-/* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */
+/* Copyright (C) 1992,93,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-/* Written 2000 by Werner Almesberger */
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Berkeley Software Design, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/sys/cdefs.h,v 1.54 2002/05/11 03:58:24 alfred Exp $
- */
-
-#ifndef _SYS_CDEFS_H
-#define _SYS_CDEFS_H
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_CDEFS_H
+#define _SYS_CDEFS_H 1
+
+/* We are almost always included from features.h. */
+#ifndef _FEATURES_H
+# include <features.h>
+#endif
+
+/* The GNU libc does not support any K&R compilers or the traditional mode
+ of ISO C compilers anymore. Check for some of the combinations not
+ anymore supported. */
+#if defined __GNUC__ && !defined __STDC__
+# error "You need a ISO C conforming compiler to use the glibc headers"
+#endif
#define __FBSDID(x) /* nothing */
-/*
- * Note: the goal here is not compatibility to K&R C. Since we know that we
- * have GCC which understands ANSI C perfectly well, we make use of this.
- */
-
-#define __P(args) args
-#define __PMT(args) args
-#define __const const
-#define __signed signed
-#define __volatile volatile
-#define __DOTS , ...
-#define __THROW
+/* Some user header file might have defined this before. */
+#undef __P
+#undef __PMT
+
+#ifdef __GNUC__
+
+/* GCC can always grok prototypes. For C++ programs we add throw()
+ to help it optimize the function calls. But this works only with
+ gcc 2.8.x and egcs. */
+# if defined __cplusplus && __GNUC_PREREQ (2,8)
+# define __THROW throw ()
+# else
+# define __THROW
+# endif
+# define __P(args) args __THROW
+/* This macro will be used for functions which might take C++ callback
+ functions. */
+# define __PMT(args) args
+
+#else /* Not GCC. */
+
+# define __inline /* No inline functions. */
+
+# define __THROW
+# define __P(args) args
+# define __PMT(args) args
+
+# define __const const
+# define __signed signed
+# define __volatile volatile
+
+#endif /* GCC. */
+
+/* For these things, GCC behaves the ANSI way normally,
+ and the non-ANSI way under -traditional. */
+
+#define __CONCAT(x,y) x ## y
+#define __STRING(x) #x
+
+/* This is not a typedef so `const __ptr_t' does the right thing. */
#define __ptr_t void *
#define __long_double_t long double
-#define __attribute_malloc__
-#define __attribute_pure__
-#define __attribute_format_strfmon__(a,b)
-#define __flexarr [0]
-#define __restrict_arr
-#ifdef __cplusplus
-# define __BEGIN_DECLS extern "C" {
-# define __END_DECLS }
+/* C++ needs to know that types and declarations are C, not C++. */
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
#else
# define __BEGIN_DECLS
# define __END_DECLS
#endif
+
+/* Support for bounded pointers. */
#ifndef __BOUNDED_POINTERS__
-# define __bounded /* nothing */
-# define __unbounded /* nothing */
-# define __ptrvalue /* nothing */
+# define __bounded /* nothing */
+# define __unbounded /* nothing */
+# define __ptrvalue /* nothing */
#endif
-#ifdef __GNUC__
-#define __strong_reference(sym,aliassym) \
- extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
-#ifdef __ELF__
-#ifdef __STDC__
-#define __weak_reference(sym,alias) \
- __asm__(".weak " #alias); \
- __asm__(".equ " #alias ", " #sym)
-#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning." #sym); \
- __asm__(".asciz \"" msg "\""); \
- __asm__(".previous")
+/* Support for flexible arrays. */
+#if __GNUC_PREREQ (2,97)
+/* GCC 2.97 supports C99 flexible array members. */
+# define __flexarr []
#else
-#define __weak_reference(sym,alias) \
- __asm__(".weak alias"); \
- __asm__(".equ alias, sym")
-#define __warn_references(sym,msg) \
- __asm__(".section .gnu.warning.sym"); \
- __asm__(".asciz \"msg\""); \
- __asm__(".previous")
-#endif /* __STDC__ */
-#else /* !__ELF__ */
-#ifdef __STDC__
-#define __weak_reference(sym,alias) \
- __asm__(".stabs \"_" #alias "\",11,0,0,0"); \
- __asm__(".stabs \"_" #sym "\",1,0,0,0")
-#define __warn_references(sym,msg) \
- __asm__(".stabs \"" msg "\",30,0,0,0"); \
- __asm__(".stabs \"_" #sym "\",1,0,0,0")
+# ifdef __GNUC__
+# define __flexarr [0]
+# else
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __flexarr []
+# else
+/* Some other non-C99 compiler. Approximate with [1]. */
+# define __flexarr [1]
+# endif
+# endif
+#endif
+
+
+/* __asm__ ("xyz") is used throughout the headers to rename functions
+ at the assembly language level. This is wrapped by the __REDIRECT
+ macro, in order to support compilers that can do this some other
+ way. When compilers don't support asm-names at all, we have to do
+ preprocessor tricks instead (which don't have exactly the right
+ semantics, but it's the best we can do).
+
+ Example:
+ int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
+
+#if defined __GNUC__ && __GNUC__ >= 2
+
+# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
+# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
+
+/*
+#elif __SOME_OTHER_COMPILER__
+
+# define __REDIRECT(name, proto, alias) name proto; \
+ _Pragma("let " #name " = " #alias)
+*/
+#endif
+
+/* GCC has various useful declarations that can be made with the
+ `__attribute__' syntax. All of the ways we use this do fine if
+ they are omitted for compilers that don't understand it. */
+#if !defined __GNUC__ || __GNUC__ < 2
+# define __attribute__(xyz) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.96 development the `malloc' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_malloc__ __attribute__ ((__malloc__))
+#else
+# define __attribute_malloc__ /* Ignore */
+#endif
+
+/* At some point during the gcc 2.96 development the `pure' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (2,96)
+# define __attribute_pure__ __attribute__ ((__pure__))
#else
-#define __weak_reference(sym,alias) \
- __asm__(".stabs \"_/**/alias\",11,0,0,0"); \
- __asm__(".stabs \"_/**/sym\",1,0,0,0")
-#define __warn_references(sym,msg) \
- __asm__(".stabs msg,30,0,0,0"); \
- __asm__(".stabs \"_/**/sym\",1,0,0,0")
-#endif /* __STDC__ */
-#endif /* __ELF__ */
-#endif /* __GNUC__ */
-
-#endif /* _SYS_CDEFS_H */
+# define __attribute_pure__ /* Ignore */
+#endif
+
+/* At some point during the gcc 3.1 development the `used' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings. */
+#if __GNUC_PREREQ (3,1)
+# define __attribute_used__ __attribute__ ((__used__))
+# define __attribute_noinline__ __attribute__ ((__noinline__))
+#else
+# define __attribute_used__ __attribute__ ((__unused__))
+# define __attribute_noinline__ /* Ignore */
+#endif
+
+/* At some point during the gcc 2.8 development the `format_arg' attribute
+ for functions was introduced. We don't want to use it unconditionally
+ (although this would be possible) since it generates warnings.
+ If several `format_arg' attributes are given for the same function, in
+ gcc-3.0 and older, all but the last one are ignored. In newer gccs,
+ all designated arguments are considered. */
+#if __GNUC_PREREQ (2,8)
+# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
+#else
+# define __attribute_format_arg__(x) /* Ignore */
+#endif
+
+/* At some point during the gcc 2.97 development the `strfmon' format
+ attribute for functions was introduced. We don't want to use it
+ unconditionally (although this would be possible) since it
+ generates warnings. */
+#if __GNUC_PREREQ (2,97)
+# define __attribute_format_strfmon__(a,b) \
+ __attribute__ ((__format__ (__strfmon__, a, b)))
+#else
+# define __attribute_format_strfmon__(a,b) /* Ignore */
+#endif
+
+/* It is possible to compile containing GCC extensions even if GCC is
+ run in pedantic mode if the uses are carefully marked using the
+ `__extension__' keyword. But this is not generally available before
+ version 2.8. */
+#if !__GNUC_PREREQ (2,8)
+# define __extension__ /* Ignore */
+#endif
+
+/* __restrict is known in EGCS 1.2 and above. */
+#if !__GNUC_PREREQ (2,92)
+# define __restrict /* Ignore */
+#endif
+
+/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
+ array_name[restrict]
+ GCC 3.1 supports this. */
+#if __GNUC_PREREQ (3,1) && !defined __GNUG__
+# define __restrict_arr __restrict
+#else
+# ifdef __GNUC__
+# define __restrict_arr /* Not supported in old GCC. */
+# else
+# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __restrict_arr restrict
+# else
+/* Some other non-C99 compiler. */
+# define __restrict_arr /* Not supported. */
+# endif
+# endif
+#endif
+
+#endif /* sys/cdefs.h */
diff --git a/newlib/libc/sys/linux/sys/features.h b/newlib/libc/sys/linux/sys/features.h
new file mode 100644
index 000000000..34cd0eb80
--- /dev/null
+++ b/newlib/libc/sys/linux/sys/features.h
@@ -0,0 +1,16 @@
+#ifndef _SYS_FEATURES_H
+#define _SYS_FEATURES_H
+
+#include <bits/posix_opt.h>
+
+/* We do not support asynchronous I/O. */
+#undef _POSIX_ASYNCHRONOUS_IO
+#undef _POSIX_ASYNC_IO
+#undef _LFS_ASYNCHRONOUS_IO
+#undef _LFS64_ASYNCHRONOUS_IO
+
+/* POSIX message queues are supported. */
+#undef _POSIX_MESSAGE_PASSING
+#define _POSIX_MESSAGE_PASSING 1
+
+#endif /* _SYS_FEATURES_H */
diff --git a/newlib/libc/sys/linux/sys/unistd.h b/newlib/libc/sys/linux/sys/unistd.h
index 062a16282..dd3f0f7ea 100644
--- a/newlib/libc/sys/linux/sys/unistd.h
+++ b/newlib/libc/sys/linux/sys/unistd.h
@@ -23,9 +23,7 @@ unsigned _EXFUN(alarm, (unsigned __secs ));
int _EXFUN(chdir, (const char *__path ));
int _EXFUN(chmod, (const char *__path, mode_t __mode ));
int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group ));
-#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 ));
@@ -40,18 +38,14 @@ 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 ));
int _EXFUN(fchown, (int __fildes, uid_t __owner, gid_t __group ));
pid_t _EXFUN(fork, (void ));
long _EXFUN(fpathconf, (int __fd, int __name ));
int _EXFUN(fsync, (int __fd));
char _EXFUN(*getcwd, (char *__buf, size_t __size ));
-#if defined(__CYGWIN__)
int _EXFUN(getdomainname ,(char *__name, size_t __len));
-#endif
gid_t _EXFUN(getegid, (void ));
uid_t _EXFUN(geteuid, (void ));
gid_t _EXFUN(getgid, (void ));
@@ -67,11 +61,8 @@ pid_t _EXFUN(getpgrp, (void ));
pid_t _EXFUN(getpid, (void ));
pid_t _EXFUN(getppid, (void ));
uid_t _EXFUN(getuid, (void ));
-#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 ));
int _EXFUN(lchown, (const char *__path, uid_t __owner, gid_t __group ));
int _EXFUN(link, (const char *__path1, const char *__path2 ));
@@ -86,30 +77,15 @@ 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(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
-#if defined(__rtems__)
void * _EXFUN(sbrk, (ptrdiff_t __incr));
-#else
-void * _EXFUN(sbrk, (size_t __incr));
-#endif
-#if defined(__CYGWIN__)
int _EXFUN(setegid, (gid_t __gid ));
int _EXFUN(seteuid, (uid_t __uid ));
-#endif
int _EXFUN(setgid, (gid_t __gid ));
int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid ));
int _EXFUN(setpgrp, (void ));
pid_t _EXFUN(setsid, (void ));
int _EXFUN(setuid, (uid_t __uid ));
-#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 ));
diff --git a/newlib/libc/syscalls/syssbrk.c b/newlib/libc/syscalls/syssbrk.c
index cee7ee13e..91673c960 100644
--- a/newlib/libc/syscalls/syssbrk.c
+++ b/newlib/libc/syscalls/syssbrk.c
@@ -3,12 +3,12 @@
#include <reent.h>
#include <unistd.h>
-extern void *_sbrk_r (struct _reent *, size_t);
-extern void *_sbrk (size_t);
+extern void *_sbrk_r (struct _reent *, ptrdiff_t);
+extern void *_sbrk (ptrdiff_t);
void *
sbrk (incr)
- size_t incr;
+ ptrdiff_t incr;
{
#ifdef REENTRANT_SYSCALLS_PROVIDED
return _sbrk_r (_REENT, incr);