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>2005-03-17 23:11:23 +0300
committerJeff Johnston <jjohnstn@redhat.com>2005-03-17 23:11:23 +0300
commitdd801fdabd7e6d80e69cbde473b723a6ef7cff86 (patch)
tree6927d01de5dcee48cb0966fd11a634b4ba399195 /newlib
parent993317d0ed9a7bee9b461e63a762b6df249ef867 (diff)
2005-03-17 Jeff Johnston <jjohnstn@redhat.com>
* 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.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog12
-rw-r--r--newlib/Makefile.in1
-rwxr-xr-xnewlib/configure29
-rw-r--r--newlib/configure.in19
-rw-r--r--newlib/libc/ctype/ctype_.c35
-rw-r--r--newlib/libc/include/ctype.h27
-rw-r--r--newlib/newlib.hin3
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 <jjohnstn@redhat.com>
+
+ * 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 <hp@axis.com>
* configure.host (newlib_cflags) <cris-*-*, crisv32-*-*>: 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 <<EOF
+char x3 = { 'a', 'b', 'c' };
+extern char y2 __attribute__((alias ("x+1")));
+EOF
+if { ac_try='${CC} $CFLAGS $CPPFLAGS -c conftest.c
+ 1>&AS_MESSAGE_LOG_FD'; { (eval echo configure:3473: \"$ac_try\") 1>&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 <<EOF
+#define _HAVE_ARRAY_ALIASING 1
+EOF
+
+fi
+
trap '' 1 2 15
cat > 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 <<EOF
+char x[3] = { 'a', 'b', 'c' };
+extern char y[2] __attribute__((alias ("x+1")));
+EOF
+if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c conftest.c
+ 1>&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__ */