From ad5527663ef5d01f531b4d4b23390c7566c93ee2 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Sat, 17 Aug 2002 05:19:18 +0000 Subject: 2002-08-17 Jeff Johnston * 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 . (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. --- newlib/libc/sys/linux/brk.c | 2 +- newlib/libc/sys/linux/include/time.h | 19 +-- newlib/libc/sys/linux/sys/cdefs.h | 315 +++++++++++++++++++++++------------ newlib/libc/sys/linux/sys/features.h | 16 ++ newlib/libc/sys/linux/sys/unistd.h | 24 --- 5 files changed, 230 insertions(+), 146 deletions(-) create mode 100644 newlib/libc/sys/linux/sys/features.h (limited to 'newlib/libc/sys/linux') 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 +#include #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 +#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 + +/* 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 )); -- cgit v1.2.3