httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf S. Engelschall" <...@engelschall.com>
Subject Re: Err... Expat and XML_BYTE_ORDER!
Date Wed, 02 Jun 1999 13:50:32 GMT

In article <19990602151218.A84394@engelschall.com> you wrote:
 
> Err.. friends: I've recognized that for the expat-lite stuff no byte order
> determination was added to our Configure stuff.
> 
> rse@en1:/e/apache/SRC/apache-1.3/src/lib/expat-lite
> :> grep XML_BYTE_ORDER *.c
> xmltok.c:#if XML_BYTE_ORDER == 12
> xmltok.c:#if XML_BYTE_ORDER == 12
> xmltok.c:#if XML_BYTE_ORDER != 21
> xmltok.c:#if XML_BYTE_ORDER == 21
> xmltok.c:#if XML_BYTE_ORDER == 21
> xmltok.c:#if XML_BYTE_ORDER != 12
> xmltok_ns.c:#if XML_BYTE_ORDER == 12
> xmltok_ns.c:#elif XML_BYTE_ORDER == 21
> 
> So, we've to add this byte order stuff or Expat will fail on some platforms,
> of course. The old way of James Clark (just saying in the Makefile the user
> should specify the byte odering) isn't acceptable, of ocurse.
> 
> For details on how this can be achieved look at the AC_C_BIGENDIAN macro of
> Autoconf. In short: It checks some headers for endian macros and if all fails
> it compiles a little test program to find it out.
> 
> Or can we fix this more easily?

When we can't fix this more easily I propose the appended patch.  The
information is then available as AP_BYTE_ORDER and this way can be at least
useful also for other code beside Expat in the future.

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Index: Configure
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/Configure,v
retrieving revision 1.351
diff -u -r1.351 Configure
--- Configure	1999/05/31 11:57:57	1.351
+++ Configure	1999/06/02 13:45:34
@@ -1888,6 +1888,25 @@
 echo "#define AP_LONGEST_LONG $AP_LONGEST_LONG" >>$AP_CONFIG_AUTO_H
 echo "#endif" >>$AP_CONFIG_AUTO_H
 
+####################################################################
+## More building ap_config_auto.h
+##
+## We check for the endianess of the machine
+##
+echo " + checking for machine byte order"
+AP_BYTE_ORDER=`./helpers/TestCompile -r byteorder`
+if [ "x$AP_BYTE_ORDER" = "x21" ]; then
+    AP_BYTE_ORDER="21" # big endian
+else
+    AP_BYTE_ORDER="12" # little endian
+fi
+
+echo "" >>$AP_CONFIG_AUTO_H
+echo "/* determine: byte order of machine (12: little endian, 21: big endian) */" >>$AP_CONFIG_AUTO_H
+echo "#ifndef AP_BYTE_ORDER" >>$AP_CONFIG_AUTO_H
+echo "#define AP_BYTE_ORDER $AP_BYTE_ORDER" >>$AP_CONFIG_AUTO_H
+echo "#endif" >>$AP_CONFIG_AUTO_H
+
 ##
 ## Now compare the sizes of off_t to long
 ##
Index: helpers/TestCompile
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/helpers/TestCompile,v
retrieving revision 1.30
diff -u -r1.30 TestCompile
--- helpers/TestCompile	1999/06/02 07:02:59	1.30
+++ helpers/TestCompile	1999/06/02 13:42:16
@@ -26,6 +26,10 @@
 #    Which prints out the sizeof <type> (sure would be nice
 #    if sizeof could be use in preprocessor if's)
 #
+# ./helpers/TestCompile byteorder
+#    Which prints out the byte order of the machine
+#    (little or big endian)
+#
 # It does these by creating a small mini-makefile, based on
 # ../Makefile.config and trying to compile a small dummy
 # program. If the compilation succeeds, we assume the test
@@ -102,6 +106,29 @@
 #include <sys/types.h>
 int main(void) {
     printf("%d\n", sizeof($2));
+    return(0);
+}
+EOF
+	;;
+    "byteorder")
+	TLIB=""
+	if [ "x$VERBOSE" = "xyes" ]; then
+	    ERRDIR=""
+	else
+	    ERRDIR='2>/dev/null'
+	fi
+	TARGET='testfunc'
+	cat <<EOF >testfunc.c
+#include <stdio.h>
+#include <sys/types.h>
+int main(void) {
+    /* Are we little or big endian? From Harbison & Steele */
+    union {
+        long l;
+        char c[sizeof(long)];
+    } u;
+    u.l = 1;
+    printf("%s\n", u.c[sizeof(long)-1] == 1 ? "21" : "12");
     return(0);
 }
 EOF
Index: lib/expat-lite//Makefile.tmpl
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/lib/expat-lite/Makefile.tmpl,v
retrieving revision 1.1
diff -u -r1.1 Makefile.tmpl
--- lib/expat-lite//Makefile.tmpl	1999/05/31 10:56:24	1.1
+++ lib/expat-lite//Makefile.tmpl	1999/06/02 13:45:02
@@ -2,13 +2,8 @@
 # default definition of these two. dunno how to get it prepended when the
 # Makefile is built, so we do it manually
 #
-CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
+CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS) -DAPACHE
 INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
-
-# If you know what your system's byte order is, define BYTE_ORDER:
-# use -DBYTE_ORDER=12 for little-endian byte order;
-# use -DBYTE_ORDER=21 for big-endian (network) byte order.
-#CFLAGS=-O2
 
 OBJS=xmltok.o xmlrole.o xmlparse.o hashtable.o
 
Index: lib/expat-lite//xmldef.h
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/lib/expat-lite/xmldef.h,v
retrieving revision 1.1
diff -u -r1.1 xmldef.h
--- lib/expat-lite//xmldef.h	1999/05/31 10:56:25	1.1
+++ lib/expat-lite//xmldef.h	1999/06/02 13:44:46
@@ -61,3 +61,10 @@
 #define int int32
 
 #endif /* MOZILLA */
+
+#ifdef APACHE
+
+#include "ap_config.h"
+#define XML_BYTE_ORDER AP_BYTE_ORDER
+
+#endif /* APACHE */

Mime
View raw message