(more) inn dieing

Alex Kiernan alexk at demon.net
Wed Jun 13 09:56:22 UTC 2001


Hmm, last mail hasn't come through on the mailing list, but ignore the
patch in it...

Somehow I can't have cut/paste the right compiler flags whilst testing
that patch, so the entire alignment test was still being optimised out
of existence when I built it for real, here's a new one to try:

Index: lib/endian.c
===================================================================
RCS file: /cvsroot/upstream/inn/lib/endian.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 endian.c
--- lib/endian.c	2001/05/02 14:52:46	1.1.1.1
+++ lib/endian.c	2001/06/13 09:55:47
@@ -47,12 +47,12 @@
  * some compiler recognize the code unwantedly
  * to avoid this the code is separated and call store() and load_and_store()
  */
-void
+static void
 store(unsigned long *p, unsigned long val)
 {
     *p = val;
 }
-void
+static void
 load_and_store(unsigned long *p, unsigned long val)
 {
     *p += val;
@@ -67,7 +67,7 @@
 {
     /* pointers into the byte order array */
     int *intp = (int *)byte;
-    char byte[2*sizeof(unsigned long)];	/* mis-alignment buffer */
+    char byte[4*sizeof(unsigned long)];	/* mis-alignment buffer */
     unsigned long *p;	/* mis-alignment pointer */
     int i;
 
@@ -93,11 +93,13 @@
     signal(SIGSEGV, buserr);	/* some systems will generate SEGV instead! */
 
     /* mis-align our long fetches */
-    for (i=0; i < sizeof(long); ++i) {
+    for (i=0; i < sizeof byte - sizeof(long); ++i) {
 	p = (unsigned long *)(byte+i);
 	store(p, i);
 	load_and_store(p, 1);
     }
+    /* simply here so the compiler can't optimise everything away */
+    memchr(byte, '\0', sizeof byte);
 
     /* if we got here, then we can mis-align longs */
     printf("#undef INN_MUST_ALIGN\n");

-- 
Alex Kiernan, Principal Engineer, Development, Thus PLC


More information about the inn-workers mailing list