From dd801fdabd7e6d80e69cbde473b723a6ef7cff86 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 17 Mar 2005 20:11:23 +0000 Subject: [PATCH] 2005-03-17 Jeff Johnston * configure.in: Add new check to see if compiler supports aliasing of arrays and define _HAVE_ARRAY_ALIASING if true. * configure: Regenerated. * Makefile.in: Ditto. * newlib.hin: Add _HAVE_ARRAY_ALIASING. * libc/ctype/ctype_.c: Check for _HAVE_ARRAY_ALIASING before aliasing the _ctype_ array to _ctype_b. * libc/include/ctype.h: Change macros to use __ctype_ptr. Mark _ctype_ as deprecated. --- newlib/ChangeLog | 12 ++++++++++++ newlib/Makefile.in | 1 + newlib/configure | 29 +++++++++++++++++++++++++++++ newlib/configure.in | 19 +++++++++++++++++++ newlib/libc/ctype/ctype_.c | 35 +++++++++++++++++++++++++++-------- newlib/libc/include/ctype.h | 27 +++++++++++++++------------ newlib/newlib.hin | 3 +++ 7 files changed, 106 insertions(+), 20 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 71fba5d6c..34986d349 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,15 @@ +2005-03-17 Jeff Johnston + + * configure.in: Add new check to see if compiler supports + aliasing of arrays and define _HAVE_ARRAY_ALIASING if true. + * configure: Regenerated. + * Makefile.in: Ditto. + * newlib.hin: Add _HAVE_ARRAY_ALIASING. + * libc/ctype/ctype_.c: Check for _HAVE_ARRAY_ALIASING before + aliasing the _ctype_ array to _ctype_b. + * libc/include/ctype.h: Change macros to use __ctype_ptr. Mark + _ctype_ as deprecated. + 2005-03-17 Hans-Peter Nilsson * configure.host (newlib_cflags) : Add diff --git a/newlib/Makefile.in b/newlib/Makefile.in index c4fa86e2b..caaa6f767 100644 --- a/newlib/Makefile.in +++ b/newlib/Makefile.in @@ -103,6 +103,7 @@ SYS_OBJECTLIST = @SYS_OBJECTLIST@ UNIX_OBJECTLIST = @UNIX_OBJECTLIST@ VERSION = @VERSION@ aext = @aext@ +libc_cv_array_aliasing = @libc_cv_array_aliasing@ libc_cv_initfinit_array = @libc_cv_initfinit_array@ libm_machine_dir = @libm_machine_dir@ machine_dir = @machine_dir@ diff --git a/newlib/configure b/newlib/configure index 48ce0d37c..f43bcb115 100755 --- a/newlib/configure +++ b/newlib/configure @@ -3459,6 +3459,34 @@ EOF fi +echo $ac_n "checking for array aliasing support""... $ac_c" 1>&6 +echo "configure:3464: checking for array aliasing support" >&5 +if eval "test \"`echo '$''{'libc_cv_array_aliasing'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } +then + libc_cv_array_aliasing=yes +else + libc_cv_array_aliasing=no +fi +rm -f conftest* +fi + +echo "$ac_t""$libc_cv_array_aliasing" 1>&6 + +if test $libc_cv_array_aliasing = yes; then + cat >> confdefs.h < confcache <<\EOF # This file is a shell script that caches the results of configure @@ -3676,6 +3704,7 @@ s%@UNIX_OBJECTLIST@%$UNIX_OBJECTLIST%g s%@STDIO64_OBJECTLIST@%$STDIO64_OBJECTLIST%g s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g s%@libc_cv_initfinit_array@%$libc_cv_initfinit_array%g +s%@libc_cv_array_aliasing@%$libc_cv_array_aliasing%g CEOF EOF diff --git a/newlib/configure.in b/newlib/configure.in index d666136a1..84e1f745a 100644 --- a/newlib/configure.in +++ b/newlib/configure.in @@ -354,6 +354,25 @@ if test $libc_cv_initfinit_array = yes; then AC_DEFINE_UNQUOTED(HAVE_INITFINI_ARRAY) fi +AC_CACHE_CHECK(for array aliasing support, + libc_cv_array_aliasing, [dnl +cat > conftest.c <&AS_MESSAGE_LOG_FD]) +then + libc_cv_array_aliasing=yes +else + libc_cv_array_aliasing=no +fi +rm -f conftest*]) +AC_SUBST(libc_cv_array_aliasing) +if test $libc_cv_array_aliasing = yes; then + AC_DEFINE_UNQUOTED(_HAVE_ARRAY_ALIASING) +fi + AC_OUTPUT(Makefile, [if test -n "$CONFIG_FILES"; then unset ac_file diff --git a/newlib/libc/ctype/ctype_.c b/newlib/libc/ctype/ctype_.c index 9991dd222..5551dbdc9 100644 --- a/newlib/libc/ctype/ctype_.c +++ b/newlib/libc/ctype/ctype_.c @@ -84,21 +84,40 @@ static _CONST char _ctype_b[128 + 256] = { _CTYPE_DATA_128_256 }; -#if defined(__CYGWIN__) -extern _CONST char __declspec(dllexport) _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127"))); +# if defined(__CYGWIN__) _CONST char __declspec(dllexport) *__ctype_ptr = _ctype_b + 128; -#else -extern _CONST char _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127"))); +# else _CONST char *__ctype_ptr = _ctype_b + 128; -#endif +# endif + +# if defined(_HAVE_ARRAY_ALIASING) + +# if defined(__CYGWIN__) +extern _CONST char __declspec(dllexport) _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127"))); +# else +extern _CONST char _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127"))); +# endif + +# else /* !_HAVE_ARRAY_ALIASING */ + +# if defined(__CYGWIN__) +_CONST char __declspec(dllexport) _ctype_[1 + 256] = { +# else +_CONST char _ctype_[1 + 256] = { +# endif + 0, + _CTYPE_DATA_0_127, + _CTYPE_DATA_128_256 +}; +# endif /* !_HAVE_ARRAY_ALIASING */ #else /* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */ -#if defined(__CYGWIN__) +# if defined(__CYGWIN__) _CONST char __declspec(dllexport) _ctype_[1 + 256] = { -#else +# else _CONST char _ctype_[1 + 256] = { -#endif +# endif 0, _CTYPE_DATA_0_127, _CTYPE_DATA_128_256 diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h index a3581df1b..9dccac319 100644 --- a/newlib/libc/include/ctype.h +++ b/newlib/libc/include/ctype.h @@ -36,20 +36,23 @@ int _EXFUN(_toupper, (int __c)); #define _X 0100 #define _B 0200 -extern __IMPORT _CONST char _ctype_[]; +extern __IMPORT _CONST char *__ctype_ptr; #ifndef __cplusplus -#define isalpha(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L)) -#define isupper(c) ((_ctype_+1)[(unsigned)(c)]&_U) -#define islower(c) ((_ctype_+1)[(unsigned)(c)]&_L) -#define isdigit(c) ((_ctype_+1)[(unsigned)(c)]&_N) -#define isxdigit(c) ((_ctype_+1)[(unsigned)(c)]&(_X|_N)) -#define isspace(c) ((_ctype_+1)[(unsigned)(c)]&_S) -#define ispunct(c) ((_ctype_+1)[(unsigned)(c)]&_P) -#define isalnum(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L|_N)) -#define isprint(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N|_B)) -#define isgraph(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N)) -#define iscntrl(c) ((_ctype_+1)[(unsigned)(c)]&_C) +#define isalpha(c) ((__ctype_ptr+1)[(unsigned)(c)]&(_U|_L)) +#define isupper(c) ((__ctype_ptr+1)[(unsigned)(c)]&_U) +#define islower(c) ((__ctype_ptr+1)[(unsigned)(c)]&_L) +#define isdigit(c) ((__ctype_ptr+1)[(unsigned)(c)]&_N) +#define isxdigit(c) ((__ctype_ptr+1)[(unsigned)(c)]&(_X|_N)) +#define isspace(c) ((__ctype_ptr+1)[(unsigned)(c)]&_S) +#define ispunct(c) ((__ctype_ptr+1)[(unsigned)(c)]&_P) +#define isalnum(c) ((__ctype_ptr+1)[(unsigned)(c)]&(_U|_L|_N)) +#define isprint(c) ((__ctype_ptr+1)[(unsigned)(c)]&(_P|_U|_L|_N|_B)) +#define isgraph(c) ((__ctype_ptr+1)[(unsigned)(c)]&(_P|_U|_L|_N)) +#define iscntrl(c) ((__ctype_ptr+1)[(unsigned)(c)]&_C) + +extern __IMPORT _CONST char _ctype_[]; /* Deprecated. */ + /* Non-gcc versions will get the library versions, and will be slightly slower */ #ifdef __GNUC__ diff --git a/newlib/newlib.hin b/newlib/newlib.hin index b1b6f051d..b08160cdb 100644 --- a/newlib/newlib.hin +++ b/newlib/newlib.hin @@ -141,5 +141,8 @@ * sections. */ #undef HAVE_INITFINI_ARRAY +/* Define if the compiler supports aliasing an array to an address. */ +#undef _HAVE_ARRAY_ALIASING + #endif /* !__NEWLIB_H__ */