This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Newlib _ctype_ alias kludge now invalid due to PR middle-end/15700 fix.


On Mar 21 17:06, Jeff Johnston wrote:
> This is introducing machine-specific code into a shared file.  I would 
> rather see you add a new ctype_.c file in libc/machine/i386 which uses the 
> .asm method and avoids the array aliasing altogether.  That should solve 
> your problem and remove the need for Cygwin flag checks in the shared 
> ctype_.c file.

Ok, I've prepared a patch along these lines.  The special handling for
Cygwin was useless anyway (no need for "__declspec(dllexport)"), so it's
just special handling for i386.

Ok to apply?


Corinna

	* libc/ctype/ctype_.c: Remove all Cygwin handling.
	* libc/machine/i386/Makefile.am (LIB_SOURCES): Add ctype_.c.
	* libc/machine/i386/Makefile.in: Regenerated.
	* libc/machine/i386/ctype_.c: New file.

Index: libc/ctype/ctype_.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/ctype/ctype_.c,v
retrieving revision 1.4
diff -u -p -r1.4 ctype_.c
--- libc/ctype/ctype_.c	17 Mar 2005 20:11:22 -0000	1.4
+++ libc/ctype/ctype_.c	22 Mar 2005 10:50:19 -0000
@@ -84,44 +84,26 @@ static _CONST char _ctype_b[128 + 256] =
 	_CTYPE_DATA_128_256
 };
 
-#  if defined(__CYGWIN__)
-_CONST char __declspec(dllexport) *__ctype_ptr = _ctype_b + 128;
-#  else
 _CONST char *__ctype_ptr = _ctype_b + 128;
-#  endif
 
-#  if defined(_HAVE_ARRAY_ALIASING)
-
-#    if defined(__CYGWIN__)
-extern _CONST char __declspec(dllexport) _ctype_[1 + 256] __attribute__ ((alias ("_ctype_b+127")));
-#    else
+# if defined(_HAVE_ARRAY_ALIASING)
 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
+# else /* !_HAVE_ARRAY_ALIASING */
 _CONST char _ctype_[1 + 256] = {
-#    endif
 	0,
 	_CTYPE_DATA_0_127,
 	_CTYPE_DATA_128_256
 };
-#  endif /* !_HAVE_ARRAY_ALIASING */
+# endif /* !_HAVE_ARRAY_ALIASING */
 
 #else	/* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */
 
-# 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
 };
 
 _CONST char *__ctype_ptr = _ctype_ + 1;
+
 #endif
Index: libc/machine/i386/Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/i386/Makefile.am,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile.am
--- libc/machine/i386/Makefile.am	6 Mar 2002 23:14:17 -0000	1.6
+++ libc/machine/i386/Makefile.am	22 Mar 2005 10:50:19 -0000
@@ -11,7 +11,7 @@ mach_add_obj=
 endif
 
 LIB_SOURCES = \
-	memchr.S memcmp.S memcpy.S memset.S strchr.S \
+	ctype_.c memchr.S memcmp.S memcpy.S memset.S strchr.S \
 	memmove.S strlen.S i386mach.h
 
 libi386_la_LDFLAGS = -Xcompiler -nostdlib
Index: libc/machine/i386/Makefile.in
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/i386/Makefile.in,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile.in
--- libc/machine/i386/Makefile.in	23 Jan 2004 21:37:31 -0000	1.10
+++ libc/machine/i386/Makefile.in	22 Mar 2005 10:50:19 -0000
@@ -99,7 +99,7 @@ INCLUDES = -I $(newlib_basedir)/libm/com
 @MACH_ADD_SETJMP_TRUE@mach_add_obj = setjmp.$(oext)
 @MACH_ADD_SETJMP_FALSE@mach_add_obj = 
 
-LIB_SOURCES =  	memchr.S memcmp.S memcpy.S memset.S strchr.S 	memmove.S strlen.S i386mach.h
+LIB_SOURCES =  	ctype_.c memchr.S memcmp.S memcpy.S memset.S strchr.S 	memmove.S strlen.S i386mach.h
 
 
 libi386_la_LDFLAGS = -Xcompiler -nostdlib
@@ -128,13 +128,13 @@ LIBRARIES =  $(noinst_LIBRARIES)
 DEFS = @DEFS@ -I. -I$(srcdir) 
 CPPFLAGS = @CPPFLAGS@
 LIBS = @LIBS@
-@USE_LIBTOOL_FALSE@lib_a_OBJECTS =  memchr.$(OBJEXT) memcmp.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@memcpy.$(OBJEXT) memset.$(OBJEXT) strchr.$(OBJEXT) \
-@USE_LIBTOOL_FALSE@memmove.$(OBJEXT) strlen.$(OBJEXT)
+@USE_LIBTOOL_FALSE@lib_a_OBJECTS =  ctype_.$(OBJEXT) memchr.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@memcmp.$(OBJEXT) memcpy.$(OBJEXT) memset.$(OBJEXT) \
+@USE_LIBTOOL_FALSE@strchr.$(OBJEXT) memmove.$(OBJEXT) strlen.$(OBJEXT)
 LTLIBRARIES =  $(noinst_LTLIBRARIES)
 
-@USE_LIBTOOL_TRUE@libi386_la_OBJECTS =  memchr.lo memcmp.lo memcpy.lo \
-@USE_LIBTOOL_TRUE@memset.lo strchr.lo memmove.lo strlen.lo
+@USE_LIBTOOL_TRUE@libi386_la_OBJECTS =  ctype_.lo memchr.lo memcmp.lo \
+@USE_LIBTOOL_TRUE@memcpy.lo memset.lo strchr.lo memmove.lo strlen.lo
 CFLAGS = @CFLAGS@
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
Index: libc/machine/i386/ctype_.c
===================================================================
RCS file: libc/machine/i386/ctype_.c
diff -N libc/machine/i386/ctype_.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libc/machine/i386/ctype_.c	22 Mar 2005 10:50:19 -0000
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#if defined(LIBC_SCCS)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0,	0,	0,	0, \
+	0,	0,	0,	0,	0,	0,	0,	0, \
+	0,	0,	0,	0,	0,	0,	0,	0, \
+	0,	0,	0,	0,	0,	0,	0,	0, \
+	0,	0,	0,	0,	0,	0,	0,	0, \
+	0,	0,	0,	0,	0,	0,	0,	0
+
+#if defined(__GNUC__) && !defined(__CHAR_UNSIGNED__) && !defined(COMPACT_CTYPE)
+#define ALLOW_NEGATIVE_CTYPE_INDEX
+#endif
+
+#if defined(ALLOW_NEGATIVE_CTYPE_INDEX)
+static _CONST char _ctype_b[128 + 256] = {
+	_CTYPE_DATA_128_256,
+	_CTYPE_DATA_0_127,
+	_CTYPE_DATA_128_256
+};
+
+_CONST char *__ctype_ptr = _ctype_b + 128;
+
+__asm__ (
+    ".data \n\t"
+    ".globl  __ctype_ \n\t"
+    ".set    __ctype_,__ctype_b+127");
+
+#else	/* !defined(ALLOW_NEGATIVE_CTYPE_INDEX) */
+
+_CONST char *__ctype_ptr = _ctype_ + 1;
+
+_CONST char _ctype_[1 + 256] = {
+	0,
+	_CTYPE_DATA_0_127,
+	_CTYPE_DATA_128_256
+};
+
+#endif

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat, Inc.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]