This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
PATCH: allow libc/string to compile on a 24-bit arch
- From: Adrian Prantl <e0025274 at stud3 dot tuwien dot ac dot at>
- To: newlib at sources dot redhat dot com
- Date: Wed, 22 Mar 2006 13:24:07 +0100
- Subject: PATCH: allow libc/string to compile on a 24-bit arch
Hello Maintainers,
attached is a trivial patch to allow all of the functions in libc/string to
compile on an architecture where sizeof(long) != 4 or 8.
Regards,
Adrian Prantl
diff -Naur newlib-cvs/src/newlib/libc/string/memccpy.c newlib/src/newlib/libc/string/memccpy.c
--- newlib-cvs/src/newlib/libc/string/memccpy.c 2002-07-23 23:38:00.000000000 +0200
+++ newlib/src/newlib/libc/string/memccpy.c 2006-03-22 11:16:34.000000000 +0100
@@ -56,11 +56,12 @@
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
+#error long int is not a 32bit or 64bit byte
+#endif
_PTR
_DEFUN (memccpy, (dst0, src0, endchar, len0),
diff -Naur newlib-cvs/src/newlib/libc/string/memchr.c newlib/src/newlib/libc/string/memchr.c
--- newlib-cvs/src/newlib/libc/string/memchr.c 2005-10-28 23:21:07.000000000 +0200
+++ newlib/src/newlib/libc/string/memchr.c 2006-03-22 13:01:28.000000000 +0100
@@ -55,12 +55,10 @@
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
-#ifndef DETECTNULL
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
#error long int is not a 32bit or 64bit byte
#endif
diff -Naur newlib-cvs/src/newlib/libc/string/strcat.c newlib/src/newlib/libc/string/strcat.c
--- newlib-cvs/src/newlib/libc/string/strcat.c 2000-02-17 20:39:48.000000000 +0100
+++ newlib/src/newlib/libc/string/strcat.c 2006-03-22 12:52:44.000000000 +0100
@@ -46,16 +46,13 @@
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
-#ifndef DETECTNULL
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
#error long int is not a 32bit or 64bit byte
#endif
-
/*SUPPRESS 560*/
/*SUPPRESS 530*/
diff -Naur newlib-cvs/src/newlib/libc/string/strchr.c newlib/src/newlib/libc/string/strchr.c
--- newlib-cvs/src/newlib/libc/string/strchr.c 2002-05-10 19:51:18.000000000 +0200
+++ newlib/src/newlib/libc/string/strchr.c 2006-03-22 11:13:43.000000000 +0100
@@ -48,11 +48,13 @@
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
+#error long int is not a 32bit or 64bit byte
+#endif
+
/* DETECTCHAR returns nonzero if (long)X contains the byte used
to fill (long)MASK. */
#define DETECTCHAR(X,MASK) (DETECTNULL(X ^ MASK))
diff -Naur newlib-cvs/src/newlib/libc/string/strcmp.c newlib/src/newlib/libc/string/strcmp.c
--- newlib-cvs/src/newlib/libc/string/strcmp.c 2000-02-17 20:39:48.000000000 +0100
+++ newlib/src/newlib/libc/string/strcmp.c 2006-03-22 11:14:02.000000000 +0100
@@ -48,12 +48,10 @@
#else
#if LONG_MAX == 9223372036854775807L
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
-#ifndef DETECTNULL
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
#error long int is not a 32bit or 64bit byte
#endif
diff -Naur newlib-cvs/src/newlib/libc/string/strcpy.c newlib/src/newlib/libc/string/strcpy.c
--- newlib-cvs/src/newlib/libc/string/strcpy.c 2000-02-17 20:39:48.000000000 +0100
+++ newlib/src/newlib/libc/string/strcpy.c 2006-03-22 13:05:37.000000000 +0100
@@ -48,12 +48,10 @@
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
-#ifndef DETECTNULL
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
#error long int is not a 32bit or 64bit byte
#endif
diff -Naur newlib-cvs/src/newlib/libc/string/strlen.c newlib/src/newlib/libc/string/strlen.c
--- newlib-cvs/src/newlib/libc/string/strlen.c 2000-02-17 20:39:48.000000000 +0100
+++ newlib/src/newlib/libc/string/strlen.c 2006-03-22 11:13:38.000000000 +0100
@@ -44,12 +44,10 @@
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
-#endif
#endif
+#endif
-#ifndef DETECTNULL
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
#error long int is not a 32bit or 64bit byte
#endif
diff -Naur newlib-cvs/src/newlib/libc/string/strncat.c newlib/src/newlib/libc/string/strncat.c
--- newlib-cvs/src/newlib/libc/string/strncat.c 2005-10-28 23:21:07.000000000 +0200
+++ newlib/src/newlib/libc/string/strncat.c 2006-03-22 13:09:22.000000000 +0100
@@ -54,12 +54,10 @@
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
-#ifndef DETECTNULL
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
#error long int is not a 32bit or 64bit byte
#endif
diff -Naur newlib-cvs/src/newlib/libc/string/strncmp.c newlib/src/newlib/libc/string/strncmp.c
--- newlib-cvs/src/newlib/libc/string/strncmp.c 2000-02-17 20:39:48.000000000 +0100
+++ newlib/src/newlib/libc/string/strncmp.c 2006-03-22 11:15:19.000000000 +0100
@@ -49,12 +49,10 @@
#else
#if LONG_MAX == 9223372036854775807L
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
-#ifndef DETECTNULL
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
#error long int is not a 32bit or 64bit byte
#endif
diff -Naur newlib-cvs/src/newlib/libc/string/strncpy.c newlib/src/newlib/libc/string/strncpy.c
--- newlib-cvs/src/newlib/libc/string/strncpy.c 2000-02-17 20:39:48.000000000 +0100
+++ newlib/src/newlib/libc/string/strncpy.c 2006-03-22 11:15:40.000000000 +0100
@@ -53,12 +53,10 @@
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
-#else
-#error long int is not a 32bit or 64bit type.
#endif
#endif
-#ifndef DETECTNULL
+#if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) && !defined(DETECTNULL)
#error long int is not a 32bit or 64bit byte
#endif