commit: r257 - in trunk/stdutil/src: . stdtest stdutil stdutil/private

[email protected]
Newsgroups gmane.network.spread.cvs
Message-ID <[email protected]>
Author: jonathan
Date: 2005-08-06 08:58:02 -0400 (Sat, 06 Aug 2005)
New Revision: 257

Added:
   trunk/stdutil/src/stdtest/stdskl_test.cpp
Modified:
   trunk/stdutil/src/Makefile.in
   trunk/stdutil/src/configure
   trunk/stdutil/src/configure.in
   trunk/stdutil/src/stddll.c
   trunk/stdutil/src/stderror.c
   trunk/stdutil/src/stdfd.c
   trunk/stdutil/src/stdhash.c
   trunk/stdutil/src/stdit.c
   trunk/stdutil/src/stdskl.c
   trunk/stdutil/src/stdthread.c
   trunk/stdutil/src/stdutil.c
   trunk/stdutil/src/stdutil/private/stdarch.h.in
   trunk/stdutil/src/stdutil/private/stdskl_p.h
   trunk/stdutil/src/stdutil/private/stdthread_p.h
   trunk/stdutil/src/stdutil/stddefines.h
   trunk/stdutil/src/stdutil/stderror.h
   trunk/stdutil/src/stdutil/stdfd.h
   trunk/stdutil/src/stdutil/stdit.h
   trunk/stdutil/src/stdutil/stdthread.h
   trunk/stdutil/src/stdutil/stdtime.h
   trunk/stdutil/src/stdutil/stdutil.h
Log:
Merged stdutil 1.0.0-beta1 to 1.0.0-beta2 changes into Spread stdutil.


Modified: trunk/stdutil/src/Makefile.in
===================================================================
--- trunk/stdutil/src/Makefile.in	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/Makefile.in	2005-08-06 12:58:02 UTC (rev 257)
@@ -15,7 +15,7 @@
 CFLAGS += -DSTDBOUNDS_CHECKS 
 
 # other flags
-CFLAGS += -fPIC -Wall -O2 -I ./ 
+CFLAGS += -fPIC -g -Wall -O2 -I ./ 
 
 # add pthreads library if necessary
 LIBS = @LIBS@

Modified: trunk/stdutil/src/configure
===================================================================
--- trunk/stdutil/src/configure	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/configure	2005-08-06 12:58:02 UTC (rev 257)
@@ -5725,15 +5725,12 @@
 
 
 
-echo "$as_me:$LINENO: checking checking all necessary integer types are defined" >&5
-echo $ECHO_N "checking checking all necessary integer types are defined... $ECHO_C" >&6
+echo "$as_me:$LINENO: checking checking all necessary integer types are available and appropriate" >&5
+echo $ECHO_N "checking checking all necessary integer types are available and appropriate... $ECHO_C" >&6
 
 if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
-   { (exit 1); exit 1; }; }
+  { echo "$as_me:$LINENO: WARNING: Unable to check due to cross compiling!  ASSUMING NECESSARY INTEGER TYPES EXIST!  Please check that stdutil/private/stdarch.h is correct for your target platform!" >&5
+echo "$as_me: WARNING: Unable to check due to cross compiling!  ASSUMING NECESSARY INTEGER TYPES EXIST!  Please check that stdutil/private/stdarch.h is correct for your target platform!" >&2;}
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -5742,6 +5739,8 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
+#include <stdlib.h>
+
 #if (SIZEOF_CHAR != 1)
 #  error No 1 byte integer type found!
 #endif
@@ -5754,7 +5753,7 @@
 #  error No 4 byte integer type found!
 #endif
 
-#if (!defined(_WIN32) && SIZEOF_LONG != 8 && SIZEOF_LONG_LONG != 8)
+#if (!defined(_MSC_VER) && SIZEOF_LONG != 8 && SIZEOF_LONG_LONG != 8)
 #  error No 8 byte integeral type found!
 #endif
 
@@ -5762,7 +5761,7 @@
 #  error No integral type of same size as size_t!
 #endif
 
-int main() { return 0; }
+int main() { exit(0); return 0; }
 
 
 _ACEOF
@@ -5785,13 +5784,227 @@
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-{ { echo "$as_me:$LINENO: error: one or more required integer sizes not found or of really unexpected size please fix stdutil/private/stdarch.h.in!" >&5
-echo "$as_me: error: one or more required integer sizes not found or of really unexpected size please fix stdutil/private/stdarch.h.in!" >&2;}
+{ { echo "$as_me:$LINENO: error: test failed!  Please fix stdutil/private/stdarch.h.in for your platform!  Please note platform must have a built in 64b integer type! Alternatively, configure.in could be broken!" >&5
+echo "$as_me: error: test failed!  Please fix stdutil/private/stdarch.h.in for your platform!  Please note platform must have a built in 64b integer type! Alternatively, configure.in could be broken!" >&2;}
    { (exit 1); exit 1; }; }
 fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
+echo "$as_me:$LINENO: checking if NULL pointers are zeroes in memory" >&5
+echo $ECHO_N "checking if NULL pointers are zeroes in memory... $ECHO_C" >&6
+
+if test "$cross_compiling" = yes; then
+  { echo "$as_me:$LINENO: WARNING: Unable to check due to cross compiling!  ASSUMING NULL IS ZERO IN MEMORY! To change this please correct stdutil/private/stdarch.h!" >&5
+echo "$as_me: WARNING: Unable to check due to cross compiling!  ASSUMING NULL IS ZERO IN MEMORY! To change this please correct stdutil/private/stdarch.h!" >&2;}
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct test_struct {
+  void *               r;
+  int                  y;
+  double               x;
+  long                 z;
+  char                 str[348];
+  struct test_struct * next;
+  struct test_struct * prev;
+
+} test_struct;
+
+int main()
+{
+  void *        voidp   = NULL;
+  char *        charp   = NULL;
+  short *       shortp  = NULL;
+  int *         intp    = NULL;
+  long *        longp   = NULL;
+  float *       floatp  = NULL;
+  double *      doublep = NULL;
+  test_struct * structp = NULL;
+  char          zeroes[sizeof(test_struct)];
+
+  memset(zeroes, 0, sizeof(zeroes));
+
+  if (memcmp(&voidp, zeroes, sizeof(voidp))     != 0 ||
+      memcmp(&charp, zeroes, sizeof(charp))     != 0 ||
+      memcmp(&shortp, zeroes, sizeof(shortp))   != 0 ||
+      memcmp(&intp, zeroes, sizeof(intp))       != 0 ||
+      memcmp(&longp, zeroes, sizeof(longp))     != 0 ||
+      memcmp(&floatp, zeroes, sizeof(floatp))   != 0 ||
+      memcmp(&doublep, zeroes, sizeof(doublep)) != 0 ||
+      memcmp(&structp, zeroes, sizeof(structp)) != 0) {
+    exit(100);
+  }
+
+  exit(0);
+  return 0;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  cat >>confdefs.h <<\_ACEOF
+#define STDARCH_NULL_IS_ZERO 1
+_ACEOF
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+
+if test $? -eq 100; then
+  echo "$as_me:$LINENO: result: no ... weird platform" >&5
+echo "${ECHO_T}no ... weird platform" >&6
+else
+  { { echo "$as_me:$LINENO: error: failed! Please fix configure.in!" >&5
+echo "$as_me: error: failed! Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
+echo "$as_me:$LINENO: checking byte alignment requirements" >&5
+echo $ECHO_N "checking byte alignment requirements... $ECHO_C" >&6
+
+if test "$cross_compiling" = yes; then
+  cat >>confdefs.h <<\_ACEOF
+#define STDARCH_MAX_BYTE_ALIGNMENT 4
+_ACEOF
+
+ { echo "$as_me:$LINENO: WARNING: Unable to check due to cross compiling!  ASSUMING ALIGNMENT TO 4 BYTE BOUNDARY IS GOOD ENOUGH! To change this please correct stdutil/private/stdarch.h!" >&5
+echo "$as_me: WARNING: Unable to check due to cross compiling!  ASSUMING ALIGNMENT TO 4 BYTE BOUNDARY IS GOOD ENOUGH! To change this please correct stdutil/private/stdarch.h!" >&2;}
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <stdlib.h>
+#include <stddef.h>
+
+struct {
+  char x;
+  long y;
+
+} long_test;
+
+struct {
+  char x;
+#if defined(_MSC_VER)
+  __int64 y;
+#elif (SIZEOF_LONG == 8)
+  long y;
+#elif (SIZEOF_LONG_LONG == 8)
+  long long y;
+#endif
+
+} int64_test;
+
+struct {
+  char        x;
+  long double y;
+
+} long_double_test;
+
+struct {
+  char   x;
+  void * y;
+
+} voidp_test;
+
+int main()
+{
+  ptrdiff_t max = (char*) &long_test.y - (char*) &long_test.x;
+  ptrdiff_t tmp;
+
+  tmp = (char*) &int64_test.y - (char*) &int64_test.x;
+
+  if (tmp > max) {
+    max = tmp;
+  }
+
+  tmp = (char*) &voidp_test.y - (char*) &voidp_test.x;
+
+  if (tmp > max) {
+    max = tmp;
+  }
+
+  tmp = (char*) &long_double_test.y - (char*) &long_double_test.x;
+
+  if (tmp > max) {
+    max = tmp;
+  }
+
+  exit(100 + (int) max);
+  return 100 + (int) max;
+}
+
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)! Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)! Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+
+tmp=$?
+if test $tmp -gt 100 && test $tmp -le 116; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDARCH_MAX_BYTE_ALIGNMENT $tmp
+_ACEOF
+
+  echo "$as_me:$LINENO: result: $tmp" >&5
+echo "${ECHO_T}$tmp" >&6
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid/unexpected return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid/unexpected return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+
 echo "$as_me:$LINENO: checking endianness of architecture" >&5
 echo $ECHO_N "checking endianness of architecture... $ECHO_C" >&6
 
@@ -5815,8 +6028,8 @@
   short  x    = 0x1;
   char * xptr = (char*) &x;
 
-  exit(xptr[0] == 1);  /* return 1 if bytes are opposite of network order, else 0 */
-  return xptr[0] == 1;
+  exit(100 + (xptr[0] == 1));  /* return 101 if bytes are opposite of network order, else 100 */
+  return 100 + (xptr[0] == 1);
 }
 
 _ACEOF
@@ -5831,21 +6044,30 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<\_ACEOF
-#define STDENDIAN16_SWAP 0
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-cat >>confdefs.h <<\_ACEOF
-#define STDENDIAN16_SWAP 1
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 101; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN16_SWAP $tmp
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -5853,7 +6075,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN32_NET0_FROM_HOST 3
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN32_HOST3_FROM_NET 0
 _ACEOF
 
@@ -5881,8 +6103,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -5897,28 +6119,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_NET0_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_HOST0_FROM_NET 0
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_NET0_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 103; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET0_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_HOST${temp}_FROM_NET 0
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST${tmp}_FROM_NET 0
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -5926,7 +6154,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN32_NET1_FROM_HOST 2
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN32_HOST2_FROM_NET 1
 _ACEOF
 
@@ -5954,8 +6182,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -5970,28 +6198,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_NET1_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_HOST0_FROM_NET 1
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_NET1_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 103; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET1_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_HOST${temp}_FROM_NET 1
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST${tmp}_FROM_NET 1
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -5999,7 +6233,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN32_NET2_FROM_HOST 1
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN32_HOST1_FROM_NET 2
 _ACEOF
 
@@ -6027,8 +6261,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6043,28 +6277,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_NET2_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_HOST0_FROM_NET 2
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_NET2_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 103; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET2_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_HOST${temp}_FROM_NET 2
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST${tmp}_FROM_NET 2
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6072,7 +6312,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN32_NET3_FROM_HOST 0
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN32_HOST0_FROM_NET 3
 _ACEOF
 
@@ -6100,8 +6340,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6116,28 +6356,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_NET3_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_HOST0_FROM_NET 3
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_NET3_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 103; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_NET3_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN32_HOST${temp}_FROM_NET 3
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN32_HOST${tmp}_FROM_NET 3
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6145,7 +6391,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_NET0_FROM_HOST 7
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_HOST7_FROM_NET 0
 _ACEOF
 
@@ -6161,7 +6407,7 @@
 
 int main()
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -6175,8 +6421,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6191,28 +6437,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET0_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST0_FROM_NET 0
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET0_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET0_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST${temp}_FROM_NET 0
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${tmp}_FROM_NET 0
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6220,7 +6472,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_NET1_FROM_HOST 6
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_HOST6_FROM_NET 1
 _ACEOF
 
@@ -6236,7 +6488,7 @@
 
 int main()
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -6250,8 +6502,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6266,28 +6518,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET1_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST0_FROM_NET 1
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET1_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET1_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST${temp}_FROM_NET 1
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${tmp}_FROM_NET 1
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6295,7 +6553,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_NET2_FROM_HOST 5
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_HOST5_FROM_NET 2
 _ACEOF
 
@@ -6311,7 +6569,7 @@
 
 int main()
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -6325,8 +6583,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6341,28 +6599,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET2_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST0_FROM_NET 2
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET2_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET2_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST${temp}_FROM_NET 2
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${tmp}_FROM_NET 2
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6370,7 +6634,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_NET3_FROM_HOST 4
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_HOST4_FROM_NET 3
 _ACEOF
 
@@ -6386,7 +6650,7 @@
 
 int main()
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -6400,8 +6664,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6416,28 +6680,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET3_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST0_FROM_NET 3
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET3_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET3_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST${temp}_FROM_NET 3
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${tmp}_FROM_NET 3
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6445,7 +6715,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_NET4_FROM_HOST 3
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_HOST3_FROM_NET 4
 _ACEOF
 
@@ -6461,7 +6731,7 @@
 
 int main()
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -6475,8 +6745,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6491,28 +6761,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET4_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST0_FROM_NET 4
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET4_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET4_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST${temp}_FROM_NET 4
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${tmp}_FROM_NET 4
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6520,7 +6796,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_NET5_FROM_HOST 2
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_HOST2_FROM_NET 5
 _ACEOF
 
@@ -6536,7 +6812,7 @@
 
 int main()
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -6550,8 +6826,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6566,28 +6842,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET5_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST0_FROM_NET 5
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET5_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET5_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST${temp}_FROM_NET 5
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${tmp}_FROM_NET 5
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6595,7 +6877,7 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_NET6_FROM_HOST 1
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_HOST1_FROM_NET 6
 _ACEOF
 
@@ -6611,7 +6893,7 @@
 
 int main()
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -6625,8 +6907,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6641,28 +6923,34 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET6_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST0_FROM_NET 6
-_ACEOF
-
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET6_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET6_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST${temp}_FROM_NET 6
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${tmp}_FROM_NET 6
 _ACEOF
 
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 
@@ -6670,11 +6958,11 @@
   cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_NET7_FROM_HOST 0
 _ACEOF
-     cat >>confdefs.h <<_ACEOF
+ cat >>confdefs.h <<_ACEOF
 #define STDENDIAN64_HOST0_FROM_NET 7
 _ACEOF
- { echo "$as_me:$LINENO: WARNING: Unable to check due to cross compiling!  ASSUMING LITTLE ENDIAN ARCHITECTURE! To change this please see stdutil.c!" >&5
-echo "$as_me: WARNING: Unable to check due to cross compiling!  ASSUMING LITTLE ENDIAN ARCHITECTURE! To change this please see stdutil.c!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: Unable to check due to cross compiling!  ASSUMING LITTLE ENDIAN ARCHITECTURE! To change please fix stdutil/private/stdarch.h!" >&5
+echo "$as_me: WARNING: Unable to check due to cross compiling!  ASSUMING LITTLE ENDIAN ARCHITECTURE! To change please fix stdutil/private/stdarch.h!" >&2;}
 else
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -6687,7 +6975,7 @@
 
 int main()
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -6701,8 +6989,8 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
 
 _ACEOF
@@ -6717,30 +7005,36 @@
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET7_FROM_HOST 0
-_ACEOF
-     cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST0_FROM_NET 7
-_ACEOF
- echo "$as_me:$LINENO: result: done" >&5
-echo "${ECHO_T}done" >&6
+  { { echo "$as_me:$LINENO: error: test failed (returned 0)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (returned 0)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 else
   echo "$as_me: program exited with status $ac_status" >&5
 echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
 ( exit $ac_status )
-temp=$?;
-   cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_NET7_FROM_HOST $temp
+
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_NET7_FROM_HOST $tmp
 _ACEOF
- cat >>confdefs.h <<_ACEOF
-#define STDENDIAN64_HOST${temp}_FROM_NET 7
+
+  cat >>confdefs.h <<_ACEOF
+#define STDENDIAN64_HOST${tmp}_FROM_NET 7
 _ACEOF
- echo "$as_me:$LINENO: result: done" >&5
+
+  echo "$as_me:$LINENO: result: done" >&5
 echo "${ECHO_T}done" >&6
+else
+  { { echo "$as_me:$LINENO: error: test failed (invalid return value)!  Please fix configure.in!" >&5
+echo "$as_me: error: test failed (invalid return value)!  Please fix configure.in!" >&2;}
+   { (exit 1); exit 1; }; }
 fi
+
+fi
 rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
 

Modified: trunk/stdutil/src/configure.in
===================================================================
--- trunk/stdutil/src/configure.in	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/configure.in	2005-08-06 12:58:02 UTC (rev 257)
@@ -9,13 +9,15 @@
 AC_CHECK_SIZEOF(short, 2)
 AC_CHECK_SIZEOF(int, 4)
 AC_CHECK_SIZEOF(long, 4)
-AC_CHECK_SIZEOF(long long, 8)
+AC_CHECK_SIZEOF([long long], 8)
 AC_CHECK_SIZEOF(size_t, 4)
-AC_CHECK_SIZEOF(void *, 4)
+AC_CHECK_SIZEOF([void *], 4)
 
-AC_MSG_CHECKING(checking all necessary integer types are defined)
+AC_MSG_CHECKING([[checking all necessary integer types are available and appropriate]])
 
 AC_TRY_RUN([
+#include <stdlib.h>
+
 #if (SIZEOF_CHAR != 1)
 #  error No 1 byte integer type found!
 #endif
@@ -28,7 +30,7 @@
 #  error No 4 byte integer type found!
 #endif
 
-#if (!defined(_WIN32) && SIZEOF_LONG != 8 && SIZEOF_LONG_LONG != 8)
+#if (!defined(_MSC_VER) && SIZEOF_LONG != 8 && SIZEOF_LONG_LONG != 8)
 #  error No 8 byte integeral type found!
 #endif
 
@@ -36,10 +38,146 @@
 #  error No integral type of same size as size_t!
 #endif
 
-int main() { return 0; }
+int main() { exit(0); return 0; }
 
-], AC_MSG_RESULT(yes), AC_MSG_ERROR(one or more required integer sizes not found or of really unexpected size please fix stdutil/private/stdarch.h.in!))
+], AC_MSG_RESULT(yes), 
+   AC_MSG_ERROR([[test failed!  Please fix stdutil/private/stdarch.h.in for your platform!  Please note platform must have a built in 64b integer type! Alternatively, configure.in could be broken!]]),
+   AC_MSG_WARN([[Unable to check due to cross compiling!  ASSUMING NECESSARY INTEGER TYPES EXIST!  Please check that stdutil/private/stdarch.h is correct for your target platform!]]))
 
+AC_MSG_CHECKING([[if NULL pointers are zeroes in memory]])
+
+AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+typedef struct test_struct {
+  void *               r;
+  int                  y;
+  double               x;
+  long                 z;
+  char                 str[348];
+  struct test_struct * next;
+  struct test_struct * prev;
+
+} test_struct;
+
+int main()
+{
+  void *        voidp   = NULL;
+  char *        charp   = NULL;
+  short *       shortp  = NULL;
+  int *         intp    = NULL;
+  long *        longp   = NULL;  
+  float *       floatp  = NULL;
+  double *      doublep = NULL;
+  test_struct * structp = NULL;
+  char          zeroes[sizeof(test_struct)];
+
+  memset(zeroes, 0, sizeof(zeroes));
+
+  if (memcmp(&voidp, zeroes, sizeof(voidp))     != 0 ||
+      memcmp(&charp, zeroes, sizeof(charp))     != 0 ||
+      memcmp(&shortp, zeroes, sizeof(shortp))   != 0 ||
+      memcmp(&intp, zeroes, sizeof(intp))       != 0 ||
+      memcmp(&longp, zeroes, sizeof(longp))     != 0 ||
+      memcmp(&floatp, zeroes, sizeof(floatp))   != 0 ||
+      memcmp(&doublep, zeroes, sizeof(doublep)) != 0 ||
+      memcmp(&structp, zeroes, sizeof(structp)) != 0) {
+    exit(100);
+  }
+
+  exit(0);
+  return 0;
+}
+],
+[AC_DEFINE(STDARCH_NULL_IS_ZERO) AC_MSG_RESULT(yes)],
+[
+if test $? -eq 100; then 
+  AC_MSG_RESULT([[no ... weird platform]])
+else
+  AC_MSG_ERROR([[failed! Please fix configure.in!]])
+fi
+],
+AC_MSG_WARN([[Unable to check due to cross compiling!  ASSUMING NULL IS ZERO IN MEMORY! To change this please correct stdutil/private/stdarch.h!]]))
+
+AC_MSG_CHECKING([[byte alignment requirements]])
+
+AC_TRY_RUN([
+#include <stdlib.h>
+#include <stddef.h>
+
+struct {
+  char x;
+  long y;
+
+} long_test;
+
+struct {
+  char x;
+#if defined(_MSC_VER)
+  __int64 y;
+#elif (SIZEOF_LONG == 8)
+  long y;
+#elif (SIZEOF_LONG_LONG == 8)
+  long long y;
+#endif
+
+} int64_test;
+
+struct {
+  char        x;
+  long double y;
+
+} long_double_test;
+
+struct {
+  char   x;
+  void * y;
+
+} voidp_test;
+
+int main()
+{
+  ptrdiff_t max = (char*) &long_test.y - (char*) &long_test.x;
+  ptrdiff_t tmp;
+
+  tmp = (char*) &int64_test.y - (char*) &int64_test.x;
+
+  if (tmp > max) {
+    max = tmp;
+  }
+
+  tmp = (char*) &voidp_test.y - (char*) &voidp_test.x;
+
+  if (tmp > max) {
+    max = tmp;
+  }
+
+  tmp = (char*) &long_double_test.y - (char*) &long_double_test.x;
+
+  if (tmp > max) {
+    max = tmp;
+  }
+
+  exit(100 + (int) max);
+  return 100 + (int) max;
+}
+],
+AC_MSG_ERROR([[test failed (returned 0)! Please fix configure.in!]]), 
+[
+tmp=$?
+if test $tmp -gt 100 && test $tmp -le 116; then 
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDARCH_MAX_BYTE_ALIGNMENT, $tmp)
+  AC_MSG_RESULT($tmp)
+else
+  AC_MSG_ERROR([[test failed (invalid/unexpected return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE(STDARCH_MAX_BYTE_ALIGNMENT, 4)
+ AC_MSG_WARN([[Unable to check due to cross compiling!  ASSUMING ALIGNMENT TO 4 BYTE BOUNDARY IS GOOD ENOUGH! To change this please correct stdutil/private/stdarch.h!]])])
+
 AC_MSG_CHECKING(endianness of architecture)
 
 AC_TRY_RUN([
@@ -50,10 +188,21 @@
   short  x    = 0x1;
   char * xptr = (char*) &x;
 
-  exit(xptr[0] == 1);  /* return 1 if bytes are opposite of network order, else 0 */
-  return xptr[0] == 1;
+  exit(100 + (xptr[0] == 1));  /* return 101 if bytes are opposite of network order, else 100 */
+  return 100 + (xptr[0] == 1);
 }
-], AC_DEFINE(STDENDIAN16_SWAP, 0), AC_DEFINE(STDENDIAN16_SWAP, 1), AC_DEFINE(STDENDIAN16_SWAP, 1))
+], 
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 101; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN16_SWAP, $tmp)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+AC_DEFINE(STDENDIAN16_SWAP, 1))
 
 AC_TRY_RUN([
 #include <stdlib.h>
@@ -72,12 +221,22 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN32_NET0_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 0), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN32_NET0_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${temp}_FROM_NET, 0),
-   AC_DEFINE_UNQUOTED(STDENDIAN32_NET0_FROM_HOST, 3)     AC_DEFINE_UNQUOTED(STDENDIAN32_HOST3_FROM_NET, 0))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 103; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN32_NET0_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${tmp}_FROM_NET, 0)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN32_NET0_FROM_HOST, 3) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST3_FROM_NET, 0)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
@@ -96,12 +255,22 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN32_NET1_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 1), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN32_NET1_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${temp}_FROM_NET, 1),
-   AC_DEFINE_UNQUOTED(STDENDIAN32_NET1_FROM_HOST, 2)     AC_DEFINE_UNQUOTED(STDENDIAN32_HOST2_FROM_NET, 1))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 103; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN32_NET1_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${tmp}_FROM_NET, 1)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN32_NET1_FROM_HOST, 2) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST2_FROM_NET, 1)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
@@ -120,12 +289,22 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN32_NET2_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 2), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN32_NET2_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${temp}_FROM_NET, 2),
-   AC_DEFINE_UNQUOTED(STDENDIAN32_NET2_FROM_HOST, 1)     AC_DEFINE_UNQUOTED(STDENDIAN32_HOST1_FROM_NET, 2))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 103; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN32_NET2_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${tmp}_FROM_NET, 2)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN32_NET2_FROM_HOST, 1) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST1_FROM_NET, 2)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
@@ -144,19 +323,29 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN32_NET3_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 3), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN32_NET3_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${temp}_FROM_NET, 3),
-   AC_DEFINE_UNQUOTED(STDENDIAN32_NET3_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 3))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 103; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN32_NET3_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN32_HOST${tmp}_FROM_NET, 3)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN32_NET3_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN32_HOST0_FROM_NET, 3)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
 
 int main() 
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -170,19 +359,29 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN64_NET0_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 0), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET0_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 0),
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET0_FROM_HOST, 7)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST7_FROM_NET, 0))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN64_NET0_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${tmp}_FROM_NET, 0)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN64_NET0_FROM_HOST, 7) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST7_FROM_NET, 0)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
 
 int main() 
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -196,19 +395,29 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN64_NET1_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 1), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET1_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 1),
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET1_FROM_HOST, 6)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST6_FROM_NET, 1))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN64_NET1_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${tmp}_FROM_NET, 1)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN64_NET1_FROM_HOST, 6) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST6_FROM_NET, 1)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
 
 int main() 
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -222,19 +431,29 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN64_NET2_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 2), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET2_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 2),
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET2_FROM_HOST, 5)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST5_FROM_NET, 2))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN64_NET2_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${tmp}_FROM_NET, 2)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN64_NET2_FROM_HOST, 5) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST5_FROM_NET, 2)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
 
 int main() 
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -248,19 +467,29 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN64_NET3_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 3), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET3_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 3),
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET3_FROM_HOST, 4)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST4_FROM_NET, 3))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN64_NET3_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${tmp}_FROM_NET, 3)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN64_NET3_FROM_HOST, 4) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST4_FROM_NET, 3)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
 
 int main() 
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -274,19 +503,29 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN64_NET4_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 4), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET4_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 4),
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET4_FROM_HOST, 3)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST3_FROM_NET, 4))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN64_NET4_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${tmp}_FROM_NET, 4)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN64_NET4_FROM_HOST, 3) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST3_FROM_NET, 4)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
 
 int main() 
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -300,19 +539,29 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN64_NET5_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 5), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET5_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 5),
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET5_FROM_HOST, 2)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST2_FROM_NET, 5))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN64_NET5_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${tmp}_FROM_NET, 5)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN64_NET5_FROM_HOST, 2) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST2_FROM_NET, 5)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
 
 int main() 
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -326,19 +575,29 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN64_NET6_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 6), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET6_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 6),
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET6_FROM_HOST, 1)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST1_FROM_NET, 6))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN64_NET6_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${tmp}_FROM_NET, 6)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN64_NET6_FROM_HOST, 1) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST1_FROM_NET, 6)])
 
 AC_TRY_RUN([
 #include <stdlib.h>
 
 int main() 
 {
-#if defined(_WIN32)
+#if defined(_MSC_VER)
   __int64 x = 0x1;
 #elif (SIZEOF_LONG == 8)
   long x = 0x1;
@@ -352,11 +611,22 @@
 
   for (i = 0; i < sizeof(x) && xptr[i] == 0; ++i);
 
-  exit(i);
-  return i;
+  exit(100 + i);
+  return 100 + i;
 }
-], AC_DEFINE_UNQUOTED(STDENDIAN64_NET7_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 7) AC_MSG_RESULT(done), temp=$?;
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET7_FROM_HOST, $temp) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${temp}_FROM_NET, 7) AC_MSG_RESULT(done),
-   AC_DEFINE_UNQUOTED(STDENDIAN64_NET7_FROM_HOST, 0)     AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 7) AC_MSG_WARN(Unable to check due to cross compiling!  ASSUMING LITTLE ENDIAN ARCHITECTURE! To change this please see stdutil.c!))
+],
+AC_MSG_ERROR([[test failed (returned 0)!  Please fix configure.in!]]),
+[
+tmp=$?
+if test $tmp -ge 100 && test $tmp -le 107; then
+  tmp=$(($tmp - 100))
+  AC_DEFINE_UNQUOTED(STDENDIAN64_NET7_FROM_HOST, $tmp) 
+  AC_DEFINE_UNQUOTED(STDENDIAN64_HOST${tmp}_FROM_NET, 7) 
+  AC_MSG_RESULT(done)
+else
+  AC_MSG_ERROR([[test failed (invalid return value)!  Please fix configure.in!]])
+fi
+],
+[AC_DEFINE_UNQUOTED(STDENDIAN64_NET7_FROM_HOST, 0) AC_DEFINE_UNQUOTED(STDENDIAN64_HOST0_FROM_NET, 7) AC_MSG_WARN([[Unable to check due to cross compiling!  ASSUMING LITTLE ENDIAN ARCHITECTURE! To change please fix stdutil/private/stdarch.h!]])])
 
 AC_OUTPUT(Makefile)

Modified: trunk/stdutil/src/stddll.c
===================================================================
--- trunk/stdutil/src/stddll.c	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stddll.c	2005-08-06 12:58:02 UTC (rev 257)
@@ -766,10 +766,10 @@
 }
 
 /************************************************************************************************
- * stdit_val: Return a pointer to an element from an iterator. 
+ * stddll_it_val: Return a pointer to an element from an iterator. 
  ***********************************************************************************************/
 
-STDINLINE void *stdit_val(const stdit *it) 
+STDINLINE void *stddll_it_val(const stdit *it) 
 {
   STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
 
@@ -777,11 +777,22 @@
 }
 
 /************************************************************************************************
- * stdit_eq: Compare to iterators for equality (refer to the same element).
+ * stddll_it_val_size: Return the size of the referenced type from an iterator. 
  ***********************************************************************************************/
 
-STDINLINE stdbool stdit_eq(const stdit *it1, const stdit *it2) 
+STDINLINE stdsize stddll_it_val_size(const stdit *it) 
 {
+  STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
+
+  return it->impl.dll.vsize;
+}
+
+/************************************************************************************************
+ * stddll_it_eq: Compare to iterators for equality (refer to the same element).
+ ***********************************************************************************************/
+
+STDINLINE stdbool stddll_it_eq(const stdit *it1, const stdit *it2) 
+{
   STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it1) && STDIT_DLL_IS_LEGAL(it2) &&
 		  it1->impl.dll.end_node == it2->impl.dll.end_node && 
 		  it1->impl.dll.vsize == it2->impl.dll.vsize);
@@ -790,10 +801,10 @@
 }
 
 /************************************************************************************************
- * stdit_next: Advance an iterator one position towards the end.
+ * stddll_it_next: Advance an iterator one position towards the end.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_next(stdit *it) 
+STDINLINE stdit *stddll_it_next(stdit *it) 
 {
   STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
   STDBOUNDS_CHECK(it->impl.dll.node != it->impl.dll.end_node);
@@ -804,10 +815,10 @@
 }
 
 /************************************************************************************************
- * stdit_advance: Advance an iterator 'num_advance' positions towards the end.
+ * stddll_it_advance: Advance an iterator 'num_advance' positions towards the end.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_advance(stdit *it, stdsize num_advance) 
+STDINLINE stdit *stddll_it_advance(stdit *it, stdsize num_advance) 
 {
   STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
 
@@ -820,10 +831,10 @@
 }
 
 /************************************************************************************************
- * stdit_prev: Advance an iterator one postion towards the beginning.
+ * stddll_it_prev: Advance an iterator one postion towards the beginning.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_prev(stdit *it) 
+STDINLINE stdit *stddll_it_prev(stdit *it) 
 {
   STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
   STDBOUNDS_CHECK(it->impl.dll.node->prev != it->impl.dll.end_node);
@@ -834,10 +845,10 @@
 }
 
 /************************************************************************************************
- * stdit_retreat: Advance an iterator 'num_retreat' positions towards the beginning.
+ * stddll_it_retreat: Advance an iterator 'num_retreat' positions towards the beginning.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_retreat(stdit *it, stdsize num_retreat) 
+STDINLINE stdit *stddll_it_retreat(stdit *it, stdsize num_retreat) 
 {
   STDSAFETY_CHECK(STDIT_DLL_IS_LEGAL(it));
 

Modified: trunk/stdutil/src/stderror.c
===================================================================
--- trunk/stdutil/src/stderror.c	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stderror.c	2005-08-06 12:58:02 UTC (rev 257)
@@ -156,8 +156,9 @@
 /************************************************************************************************
  * stderr_strerr: Returns a constant string in response to a StdUtil
  * error code.  Some StdUtil fcns can return system specific codes.
- * In that case this fcn will return a "Unknown Error" string and you
- * should consult your system specific error lookup service.
+ * In that case this fcn will return a "Unknown Error Code (system
+ * error code)" string and you should consult your system specific
+ * error lookup service.
  ***********************************************************************************************/
 
 STDINLINE const char *stderr_strerr(stdcode code)
@@ -193,6 +194,10 @@
     ret = "Functionality Not Implemented";
     break;
 
+  case STDEINTR:
+    ret = "Operation Interrupted";
+    break;
+
   default:
     ret = "Unknown Error Code (system error code)";
     break;

Modified: trunk/stdutil/src/stdfd.c
===================================================================
--- trunk/stdutil/src/stdfd.c	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdfd.c	2005-08-06 12:58:02 UTC (rev 257)
@@ -31,7 +31,7 @@
 #  include <io.h>
 #  include <sys/locking.h>
 #  define STDFILENO(s) _fileno(s)
-#  define STDFSYNC(fd) _commit(fd)   
+#  define STDFSYNC(fd) _commit(fd)
 #else
 #  include <unistd.h>
 #  define STDFILENO(s) fileno(s)
@@ -42,17 +42,49 @@
  * stdfd_open: Open a file descriptor.
  ***********************************************************************************************/
 
-STDINLINE stdcode stdfd_open(stdfd *fd, const char *path, const char *mode)
+STDINLINE stdcode stdfd_open(stdfd *fd, const char *path, stdfd_access_type mode)
 {
-  stdcode ret = STDESUCCESS;
+  stdcode      ret = STDESUCCESS;
+  const char * fopen_mode;
 
-  if ((fd->stream = fopen(path, mode)) != NULL) {
+  switch (mode) {
+  case STDFD_READ_ONLY:
+    fopen_mode = "rb";
+    break;
+
+  case STDFD_READ_WRITE_EXISTING:
+    fopen_mode = "rb+";
+    break;
+
+  case STDFD_WRITE_ONLY:
+    fopen_mode = "wb";
+    break;
+
+  case STDFD_READ_WRITE_NEW:
+    fopen_mode = "wb+";
+    break;
+
+  case STDFD_APPEND_ONLY:
+    fopen_mode = "ab";
+    break;
+
+  case STDFD_READ_APPEND:
+    fopen_mode = "ab+";
+    break;
+
+  default:
+    ret = STDEINVAL;
+    goto stdfd_open_end;
+  }
+
+  if ((fd->stream = fopen(path, fopen_mode)) != NULL) {
     fd->fd = STDFILENO(fd->stream);
 
   } else {
     ret = errno;
   }
 
+ stdfd_open_end:
   return ret;
 }
 
@@ -64,13 +96,14 @@
 {
   stdcode ret = STDESUCCESS;
 
-  STDSAFETY_CHECK(fd->stream != NULL);
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
 
-  if ((ret = fclose(fd->stream)) != 0) {
+  if (fclose(fd->stream) != 0) {
     ret = errno;
   }
 
   fd->stream = NULL;
+  fd->fd     = -1;
 
   return ret;
 }
@@ -84,6 +117,8 @@
 {
   stdcode ret;
 
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   if ((*num = fread(ptr, nsize, nmemb, fd->stream)) == nmemb) {
     ret = STDESUCCESS;
 
@@ -93,8 +128,8 @@
   } else if (ferror(fd->stream)) {
     ret = errno;
 
-  } else {
-    ret = STDESUCCESS;
+  } else {  
+    ret = STDEINTR;  /* wrong count but not EOF or error? alert user! */
   }
 
   return ret;
@@ -109,6 +144,8 @@
 {
   stdcode ret;
 
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   if ((*num = fwrite(ptr, nsize, nmemb, fd->stream)) == nmemb) {
     ret = STDESUCCESS;
 
@@ -118,8 +155,8 @@
   } else if (ferror(fd->stream)) {
     ret = errno;
 
-  } else {
-    ret = STDESUCCESS;
+  } else {  
+    ret = STDEINTR;  /* wrong count but not EOF or error? alert user! */
   }
 
   return ret;
@@ -133,6 +170,8 @@
 {
   stdcode ret = STDESUCCESS;
 
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   if (fflush(fd->stream) != 0) {
     ret = errno;
   }
@@ -145,10 +184,12 @@
  * flush all data to disk.
  ***********************************************************************************************/
 
-STDINLINE stdcode stdfd_sync(stdfd * fd)
+STDINLINE stdcode stdfd_sync(stdfd *fd)
 {
   stdcode ret = STDESUCCESS;
 
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   if (stdfd_flush(fd) != 0 || STDFSYNC(fd->fd) != 0) {
     ret = errno;
   }
@@ -160,10 +201,12 @@
  * stdfd_seek: Move the read/write head position of a file descriptor.
  ***********************************************************************************************/
 
-STDINLINE stdcode stdfd_seek(stdfd *fd, stdfd_pos offset, stdfd_whence whence)
+STDINLINE stdcode stdfd_seek(stdfd *fd, long offset, stdfd_whence whence)
 {
   stdcode ret = STDESUCCESS;
 
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   if (fseek(fd->stream, offset, whence) != 0) {
     ret = errno;
   }
@@ -172,13 +215,15 @@
 }
 
 /************************************************************************************************
- * stdfd_get_pos: Get the read/write head position of a file descriptor.
+ * stdfd_tell: Get the read/write head position of a file descriptor.
  ***********************************************************************************************/
 
-STDINLINE stdcode stdfd_get_pos(stdfd *fd, stdfd_pos *pos)
+STDINLINE stdcode stdfd_tell(stdfd *fd, long *pos)
 {
   stdcode ret = STDESUCCESS;
 
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   if ((*pos = ftell(fd->stream)) == -1) {
     ret = errno;
   }
@@ -190,8 +235,10 @@
  * stdfd_eof: Return whether or not the EOF indicator on a file descriptor is set.
  ***********************************************************************************************/
 
-STDINLINE stdbool stdfd_eof(stdfd * fd)
+STDINLINE stdbool stdfd_eof(stdfd *fd)
 {
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   return (feof(fd->stream) != 0);
 }
 
@@ -199,8 +246,10 @@
  * stdfd_err: Return whether or not an error indicator on a file descriptor is set.
  ***********************************************************************************************/
 
-STDINLINE stdbool stdfd_err(stdfd * fd)
+STDINLINE stdbool stdfd_err(stdfd *fd)
 {
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   return (ferror(fd->stream) != 0);
 }
 
@@ -208,8 +257,10 @@
  * stdfd_clr_err: Clear any error indicator on a file descriptor.
  ***********************************************************************************************/
 
-STDINLINE void stdfd_clr_err(stdfd * fd)
+STDINLINE void stdfd_clr_err(stdfd *fd)
 {
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
   clearerr(fd->stream);
 }
 
@@ -218,10 +269,12 @@
  * descriptor's underlying file.
  ***********************************************************************************************/
 
-STDINLINE stdcode stdfd_trylock(stdfd * fd)
+STDINLINE stdcode stdfd_trylock(stdfd *fd)
 {
   stdcode ret = STDESUCCESS;
 
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
 #if defined(_WIN32)
   if (_locking(fd->fd, _LK_NBLCK, 1) != 0) {
 #else
@@ -242,10 +295,12 @@
  * underlying file.
  ***********************************************************************************************/
 
-STDINLINE stdcode stdfd_unlock(stdfd * fd)
+STDINLINE stdcode stdfd_unlock(stdfd *fd)
 {
   stdcode ret = STDESUCCESS;
 
+  STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
 #if defined(_WIN32)
   if (_locking(fd->fd, _LK_UNLCK, 1) != 0) {
 #else

Modified: trunk/stdutil/src/stdhash.c
===================================================================
--- trunk/stdutil/src/stdhash.c	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdhash.c	2005-08-06 12:58:02 UTC (rev 257)
@@ -694,25 +694,23 @@
 STDINLINE stdcode stdhash_set_eq(stdhash *dst, const stdhash *src)
 {
   stdcode ret = STDESUCCESS;
+  stdhash cpy;
 
   STDSAFETY_CHECK(STDHASH_IS_LEGAL(dst) && STDHASH_IS_LEGAL(src) && 
 		  dst->ksize == src->ksize && dst->vsize == src->vsize &&
 		  dst->cmp_fcn == src->cmp_fcn && dst->hcode_fcn == src->hcode_fcn);
 
-  if (src->size != 0) {
-    stdhash cpy;
+  if (dst == src) {
+    goto stdhash_set_eq_end;
+  }
 
-    if ((ret = stdhash_copy_construct(&cpy, src)) != STDESUCCESS) {  /* make a copy */
-      goto stdhash_set_eq_end;
-    }
-
-    stdhash_swap(dst, &cpy);                                         /* swap the hashes */
-    stdhash_destruct(&cpy);                                          /* destroy the old hash */
-
-  } else {
-    stdhash_clear(dst);
+  if ((ret = stdhash_copy_construct(&cpy, src)) != STDESUCCESS) {  /* make a copy */
+    goto stdhash_set_eq_end;
   }
 
+  stdhash_swap(dst, &cpy);                                         /* swap the hashes */
+  stdhash_destruct(&cpy);                                          /* destroy the old hash */
+
  stdhash_set_eq_end:
   return ret;
 }
@@ -1219,10 +1217,10 @@
 }
 
 /************************************************************************************************
- * stdit_key: Return a pointer to the key of the key-value pair 'it' references.
+ * stdhash_it_key: Return a pointer to the key of the key-value pair 'it' references.
  ***********************************************************************************************/
 
-STDINLINE const void *stdit_key(const stdit *it) 
+STDINLINE const void *stdhash_it_key(const stdit *it) 
 {
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
 
@@ -1230,10 +1228,10 @@
 }
 
 /************************************************************************************************
- * stdit_key_size: Return the size in bytes of keys 'it' references.
+ * stdhash_it_key_size: Return the size in bytes of keys 'it' references.
  ***********************************************************************************************/
 
-STDINLINE stdsize stdit_key_size(const stdit *it) 
+STDINLINE stdsize stdhash_it_key_size(const stdit *it) 
 {
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
 
@@ -1241,10 +1239,10 @@
 }
 
 /************************************************************************************************
- * stdit_val: Return a pointer to the key of the key-value pair 'it' references.
+ * stdhash_it_val: Return a pointer to the key of the key-value pair 'it' references.
  ***********************************************************************************************/
 
-STDINLINE void *stdit_val(const stdit *it) 
+STDINLINE void *stdhash_it_val(const stdit *it) 
 {  
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
 
@@ -1252,10 +1250,10 @@
 }
 
 /************************************************************************************************
- * stdit_val_size: Return the size in bytes of the values 'it' references.
+ * stdhash_it_val_size: Return the size in bytes of the values 'it' references.
  ***********************************************************************************************/
 
-STDINLINE stdsize stdit_val_size(const stdit *it) 
+STDINLINE stdsize stdhash_it_val_size(const stdit *it) 
 {  
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
 
@@ -1263,10 +1261,10 @@
 }
 
 /************************************************************************************************
- * stdit_eq: Compare two iterators for equality (same pair).
+ * stdhash_it_eq: Compare two iterators for equality (same pair).
  ***********************************************************************************************/
 
-STDINLINE stdbool stdit_eq(const stdit *it1, const stdit *it2) 
+STDINLINE stdbool stdhash_it_eq(const stdit *it1, const stdit *it2) 
 {
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it1) && STDIT_HASH_IS_LEGAL(it2) && 
 		  it1->impl.hash.table     == it2->impl.hash.table && 
@@ -1278,10 +1276,10 @@
 }
 
 /************************************************************************************************
- * stdit_next: Advance an iterator towards end by 1 position.
+ * stdhash_it_next: Advance an iterator towards end by 1 position.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_next(stdit *it) 
+STDINLINE stdit *stdhash_it_next(stdit *it) 
 {
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
   STDBOUNDS_CHECK(it->impl.hash.node_pos != it->impl.hash.table_end);
@@ -1292,10 +1290,10 @@
 }
 
 /************************************************************************************************
- * stdit_advance: Advance an iterator towards end by 'num_advance' positions.
+ * stdhash_it_advance: Advance an iterator towards end by 'num_advance' positions.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_advance(stdit *it, stdsize num_advance) 
+STDINLINE stdit *stdhash_it_advance(stdit *it, stdsize num_advance) 
 {
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
 
@@ -1308,10 +1306,10 @@
 }
 
 /************************************************************************************************
- * stdit_prev: Advance an iterator towards begin by 1 position.
+ * stdhash_it_prev: Advance an iterator towards begin by 1 position.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_prev(stdit *it) 
+STDINLINE stdit *stdhash_it_prev(stdit *it) 
 {
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
   STDBOUNDS_CHECK(it->impl.hash.node_pos != it->impl.hash.table);      /* should be begin, but we don't track that */
@@ -1322,10 +1320,10 @@
 }
 
 /************************************************************************************************
- * stdit_retreat: Advance an iterator towards begin by 'num_retreat' positions.
+ * stdhash_it_retreat: Advance an iterator towards begin by 'num_retreat' positions.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_retreat(stdit *it, stdsize num_retreat) 
+STDINLINE stdit *stdhash_it_retreat(stdit *it, stdsize num_retreat) 
 {
   STDSAFETY_CHECK(STDIT_HASH_IS_LEGAL(it));
 

Modified: trunk/stdutil/src/stdit.c
===================================================================
--- trunk/stdutil/src/stdit.c	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdit.c	2005-08-06 12:58:02 UTC (rev 257)
@@ -53,7 +53,7 @@
     break;
 
   default:
-    ret = STDIT_FORWARD;
+    ret = 0;
     STDEXCEPTION(uninitialized or corrupted iterator);
     break;
   }
@@ -169,21 +169,15 @@
     break;
 
   case STDHASH_IT_ID:
+  case STDHASH_IT_KEY_ID:
     ret = stdhash_it_val(it);
     break;
 
-  case STDHASH_IT_KEY_ID:
-    ret = (void*) stdhash_it_key(it);
-    break;
-
   case STDSKL_IT_ID:
+  case STDSKL_IT_KEY_ID:
     ret = stdskl_it_val(it);
     break;
 
-  case STDSKL_IT_KEY_ID:
-    ret = (void*) stdskl_it_key(it);
-    break;
-
   default:
     ret = NULL;
     STDEXCEPTION(uninitialized or corrupted iterator);
@@ -223,21 +217,15 @@
     break;
 
   case STDHASH_IT_ID:
+  case STDHASH_IT_KEY_ID:
     ret = stdhash_it_val_size(it);
     break;
 
-  case STDHASH_IT_KEY_ID:
-    ret = stdhash_it_key_size(it);
-    break;
-
   case STDSKL_IT_ID:
+  case STDSKL_IT_KEY_ID:
     ret = stdskl_it_val_size(it);
     break;
 
-  case STDSKL_IT_KEY_ID:
-    ret = stdskl_it_key_size(it);
-    break;
-
   default:
     ret = 0;
     STDEXCEPTION(uninitialized or corrupted iterator);

Modified: trunk/stdutil/src/stdskl.c
===================================================================
--- trunk/stdutil/src/stdskl.c	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdskl.c	2005-08-06 12:58:02 UTC (rev 257)
@@ -28,9 +28,21 @@
 #include <stdutil/stdtime.h>
 #include <stdutil/stdskl.h>
 
+/* TODO: consider shrinking end_node's arrays when the top level
+   becomes empty (down to some minimum height like 4 or 5); this is
+   easy to detect: if the node being removed has the same height as
+   the end_node and his top level prev and next are the end node then
+   the level is about to become empty; alternatively after removal you
+   can just check the top levels for self reference; also might not
+   want to make end_node taller than the tallest node on insert --
+   don't know how big an effect on find this will have as find as it
+   will simply run down end_node's nexts array while next equals
+   end_node not doing any real work
+*/
+
 #define STDSKL_MAX_HEIGHT 31
 
-#define STDSKL_IS_LEGAL(l)       ((l)->end_node != NULL && (l)->ksize != 0 && (l)->bits_left < 32)
+#define STDSKL_IS_LEGAL(l)       ((l)->end_node != NULL && (l)->ksize != 0 && (l)->bits_left >= 0 && (l)->bits_left < 32)
 #define STDSKL_IT_IS_LEGAL(l, i) ((i)->ksize == (l)->ksize && (i)->vsize == (l)->vsize)
 #define STDIT_SKL_IS_LEGAL(i)    (((i)->type_id == STDSKL_IT_ID || (i)->type_id == STDSKL_IT_KEY_ID) && \
 				  (i)->impl.skl.node != NULL && (i)->impl.skl.ksize != 0)
@@ -72,7 +84,7 @@
 
       keep_going = ((l->rand_bits & 0x1) == 0x1);                 /* break loop on a "off" bit */
 
-      --l->bits_left;                                             /* consume a bit */
+      --l->bits_left;                                             /* remove used bit */
       l->rand_bits >>= 1;
     }
   }
@@ -80,15 +92,17 @@
   /* calculate memory needed for node and pointer arrays and the offsets for the pointers in the node */
 
   mem_tot   = sizeof(stdskl_node);                  /* memory for node structure */
-  prevs_off = mem_tot;
+  prevs_off = mem_tot;                              /* structure is already aligned for void*'s -> good enough alignment */
 
   mem_tot  += (height + 1) * sizeof(stdskl_node*);  /* memory for prevs array */
-  nexts_off = mem_tot;
+  nexts_off = mem_tot;                              /* structure is already aligned for void*'s -> good enough alignment */
 
   mem_tot  += (height + 1) * sizeof(stdskl_node*);  /* memory for nexts array */
   mem_tot   = STDARCH_PADDED_SIZE(mem_tot);         /* pad memory for key */
   key_off   = mem_tot;
 
+  /* TODO: might only pad the key size if vsize != 0 */
+
   mem_tot  += STDARCH_PADDED_SIZE(l->ksize);        /* memory for key and padding for value */
   val_off   = mem_tot;
 
@@ -125,7 +139,7 @@
  * If (find_any) immediately return on any match. Otherwise if 'key'
  * exists in 'l' return the "leftmost" (least) match if multiple
  * matches exist.  On no match, returns the "leftmost" (least) entry
- * in 'l' with a greater key, or end if no such entry.
+ * in 'l' with a greater key, or end if no such entry exists.
  ***********************************************************************************************/
 
 STDINLINE static stdbool stdskl_low_find_right(const stdskl *l, const void *key, 
@@ -136,7 +150,7 @@
   stdint8             lvl  = l->end_node->height;
   int                 cmp  = -1;  /* get rid of compiler warning */
 
-  /* run down to bottom level */
+  /* run down to bottom level list */
 
   while (lvl > 0) {
     next = curr->nexts[lvl];
@@ -156,12 +170,12 @@
       return STDTRUE;
     }
 
-    /* run down curr's nexts levels while they equal next */
+    /* run down curr's levels while they equal next */
 
     for (--lvl; lvl > 0 && curr->nexts[lvl] == next; --lvl);
   }
 
-  /* lvl is zero: run right on bottom level trying to match key */
+  /* lvl is zero: run right on bottom level list trying to match key */
 
   curr = curr->nexts[0];
 
@@ -184,7 +198,7 @@
  * If (find_any) immediately return on any match. Otherwise if 'key'
  * exists in 'l' return the "rightmost" (greatest) match if multiple
  * matches exist.  On no match, returns the "rightmost" (greatest)
- * entry in 'l' with a lesser key, or end if no such entry.
+ * entry in 'l' with a lesser key, or end if no such entry exists.
  ***********************************************************************************************/
 
 STDINLINE static stdbool stdskl_low_find_left(const stdskl *l, const void *key, 
@@ -195,7 +209,7 @@
   stdint8             lvl  = l->end_node->height;
   int                 cmp  = -1;  /* get rid of compiler warning */
 
-  /* run down to bottom level */
+  /* run down to bottom level list */
 
   while (lvl > 0) {
     prev = curr->prevs[lvl];
@@ -220,7 +234,7 @@
     for (--lvl; lvl > 0 && curr->prevs[lvl] == prev; --lvl);
   }
 
-  /* run left on bottom level trying to match key */
+  /* run left on bottom level list trying to match key */
 
   curr = curr->prevs[0];
 
@@ -272,7 +286,7 @@
 
 STDINLINE static void stdskl_low_link_left(const stdskl *l, stdskl_node *ins_pos, stdskl_node *node)
 {
-  stdskl_node * prev   = ins_pos->prevs[0];  /* NOTE: this is why we must link_left b4 link_right */
+  stdskl_node * prev   = ins_pos->prevs[0];  /* NOTE: this is why we must link_left b4 link_right in insert! */
   stdint8       height = node->height;
   stdint8       lvl    = 0;
 
@@ -323,7 +337,7 @@
     key = (keyed ? stdit_key(&src_it) : val);
     cmp = -1;
 
-    /* get insertion position for this key */
+    /* get insertion position for this key: next */
 
     if (hint) {                 /* 'next' is a potential insertion point -> verify! */
       prev = next->prevs[0];
@@ -347,6 +361,8 @@
     }
 
     hint = STDTRUE;             /* use next as a hint for following iteration (optimize for nearly contiguous, sorted inserts) */
+
+    /* create + insert new node; or overwrite pre-existing match if so instructed and appropriate */
     
     if (!overwrite || next == l->end_node || cmp != 0) {               /* create new node to insert */
 
@@ -360,9 +376,9 @@
       if (node->height > l->end_node->height) {
 	stdskl_node * new_end;
 
-	/* ratchet up new end_node's height to be at least 2 levels higher than before if not already at max height */
+	/* ratchet up new end_node's height to be at least 1 level higher (usually 2) than before */
 
-	lvl = node->height;
+	lvl = node->height;  /* 0 <= node->height <= STDSKL_MAX_HEIGHT */
 
 	if (lvl < STDSKL_MAX_HEIGHT) {
 	  ++lvl;
@@ -373,27 +389,33 @@
 	  goto stdskl_low_insert_fail;
 	}
 
-	/* set new_end's nexts and prevs and correct nodes ref'ing end to new_end */
+	/* set new_end's nexts and prevs and update nodes ref'ing end_node to now point to new_end */
+	/* loop while we haven't updated all levels of the lists AND end_node is NOT self-referring */
 
 	lvl = 0;
 	do {
-	  new_end->prevs[lvl]             = l->end_node->prevs[lvl];
-	  new_end->prevs[lvl]->nexts[lvl] = new_end;
 
-	  new_end->nexts[lvl]             = l->end_node->nexts[lvl];
-	  new_end->nexts[lvl]->prevs[lvl] = new_end;
+	  if (l->end_node->prevs[lvl] == l->end_node) {  /* break on end_node referring to itself -> */ 
+	    break;                                       /* all prevs, nexts of this and higher lvls are self-referring */
+	  }
 
-	} while (lvl++ != l->end_node->height);    
+	  new_end->prevs[lvl]                 = l->end_node->prevs[lvl];
+	  l->end_node->prevs[lvl]->nexts[lvl] = new_end;
 
-	/* set additional lvls in new_end to be self-referencing */
+	  new_end->nexts[lvl]                 = l->end_node->nexts[lvl];
+	  l->end_node->nexts[lvl]->prevs[lvl] = new_end;
 
+	} while (lvl++ != l->end_node->height);
+
+	/* set additional lvls in new_end to be self-referencing.  NOTE: new_end is at least 1 lvl taller than end_node */
+
 	do {
 	  new_end->prevs[lvl] = new_end;
 	  new_end->nexts[lvl] = new_end;
 
 	} while (lvl++ != new_end->height);
 
-	/* correct next if it referenced the old end */
+	/* correct next if it referenced the end_node */
     
 	if (next == l->end_node) {
 	  next = new_end;
@@ -406,7 +428,7 @@
       /* link 'node' into list before next */
 
       stdskl_low_link_left(l, next, node);                  /* NOTE: we must link_left before we link_right due to loss of information */
-      stdskl_low_link_right(l, next, node); 
+      stdskl_low_link_right(l, next, node);
 
       ++l->size;
       
@@ -416,7 +438,7 @@
       memcpy(STDSKL_NVAL(node), val, l->vsize);
     }
 
-    /* remember first insertion */
+    /* remember first insertion/overwrite */
 
     if (first_ins == NULL) {
       first_ins = node;
@@ -429,10 +451,6 @@
     }
   }
 
-  if (first_ins == NULL) {  /* empty input sequence, set 'it' to end */
-    first_ins = l->end_node;
-  }
-
   goto stdskl_low_insert_end;
 
   /* error handling and return */
@@ -441,9 +459,9 @@
   free(node);
 
  stdskl_low_insert_end:
-  if (first_ins != NULL && it != NULL) {  /* at least one insertion succeeded or empty input sequence */
+  if (it != NULL) {
     it->type_id        = STDSKL_IT_ID;
-    it->impl.skl.node  = first_ins;
+    it->impl.skl.node  = (first_ins != NULL ? first_ins : l->end_node);  /* point to end if no insert/overwrite occurred */
     it->impl.skl.ksize = l->ksize;
     it->impl.skl.vsize = l->vsize;
   }
@@ -527,13 +545,24 @@
   stdint8 lvl;
   stdtime t;
 
-  if (ksize != 0) {
+  if (ksize == 0) {
     ret = STDEINVAL;
     goto stdskl_construct_fail;
   }
 
-  /* allocate and init end_node */
+  l->size    = 0;
+  l->ksize   = ksize;
+  l->vsize   = vsize;
+  l->cmp_fcn = kcmp;
 
+  /* initialize randomization using current system time w/ subsecond precision */
+
+  stdtime_now(&t);  
+  stdrand32_dseed(l->seed, stdhcode_sfh(&t, sizeof(t)));
+  l->bits_left = 0;
+
+  /* allocate and init end_node -- NOTE: rest of list must be initialized b4 calling this fcn */
+
   if ((l->end_node = stdskl_low_create_node(l, 4, NULL, NULL)) == NULL) {
     ret = STDENOMEM;
     goto stdskl_construct_fail;
@@ -549,16 +578,6 @@
 
   } while (lvl-- != 0);
 
-  l->size    = 0;
-  l->ksize   = ksize;
-  l->vsize   = vsize;
-  l->cmp_fcn = kcmp;
-
-  /* initialize randomization using current system time w/ subsecond precision */
-
-  stdtime_now(&t);  
-  stdskl_dseed(l, &t, sizeof(t));
-
   goto stdskl_construct_end;
 
   /* error handling and return */
@@ -579,7 +598,6 @@
 {
   stdcode ret;
   stdit   it;
-  stdit   dend;
 
   STDSAFETY_CHECK(STDSKL_IS_LEGAL(src));
 
@@ -587,7 +605,7 @@
     goto stdskl_copy_construct_fail;
   }
 
-  if ((ret = stdskl_insert_seq_n(dst, stdskl_end(dst, &dend), stdskl_begin(src, &it), src->size, STDTRUE)) != STDESUCCESS) {
+  if ((ret = stdskl_insert_seq_n(dst, NULL, stdskl_begin(src, &it), src->size, STDFALSE)) != STDESUCCESS) {
     goto stdskl_copy_construct_fail2;
   }
 
@@ -627,11 +645,24 @@
 
 STDINLINE stdcode stdskl_set_eq(stdskl *dst, const stdskl *src)
 {
-  stdcode ret;
+  stdcode ret = STDESUCCESS;
   stdskl  cpy;
 
-  STDSAFETY_CHECK(STDSKL_IS_LEGAL(dst) && STDSKL_IS_LEGAL(src));
+  STDSAFETY_CHECK(STDSKL_IS_LEGAL(dst) && STDSKL_IS_LEGAL(src) &&
+		  dst->ksize == src->ksize && dst->vsize == src->vsize &&
+		  dst->cmp_fcn == src->cmp_fcn);
 
+  /* TODO: an improvement would be to resize the number of nodes in
+     the table as needed: just slice off or splice on an appropriate
+     sequence of nodes to the begin or end of the list and overwrite
+     all nodes: this would cut down on "unnecessary" memory
+     allocs/frees
+  */
+
+  if (dst == src) {
+    goto stdskl_set_eq_end;
+  }
+
   if ((ret = stdskl_copy_construct(&cpy, src)) != STDESUCCESS) {
     goto stdskl_set_eq_end;
   }
@@ -781,7 +812,7 @@
     free(prev);
   }
 
-  /* fix list entries: end_node and size */
+  /* fix list entries: end_node needs to self reference at all levels and size */
 
   curr = l->end_node;
   lvl  = l->end_node->height;
@@ -971,7 +1002,8 @@
 {
   stdit b;
 
-  STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && (!hint || (it != NULL && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl))));
+  STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && 
+		  (!hint || (it != NULL && STDIT_SKL_IS_LEGAL(it) && STDSKL_IT_IS_LEGAL(l, &it->impl.skl))));
 
   return stdskl_low_insert(l, it, stdit_pptr(&b, key, val, l->ksize, l->vsize), NULL, num_times, hint, STDFALSE, STDFALSE);
 }
@@ -1019,7 +1051,7 @@
 
   stdskl_lowerb(l, &it, key);
 
-  for (; !stdskl_is_end(l, &it) && stdskl_low_key_cmp(l, key, STDSKL_NKEY(it.impl.skl.node)) == 0;) {
+  while (it.impl.skl.node != l->end_node && stdskl_low_key_cmp(l, key, STDSKL_NKEY(it.impl.skl.node)) == 0) {
     stdskl_erase(l, &it);  /* advances 'it' */
   }
 }
@@ -1033,14 +1065,14 @@
   STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
 
   stdrand32_dseed(l->seed, stdhcode_sfh(seed, sizeof_seed));
-  l->bits_left = 0;
+  l->bits_left = 0;  /* NOTE: initialization depends on this */
 }
 
 /************************************************************************************************
- * stdit_key: Get a key from an iterator.
+ * stdskl_it_key: Get a key from an iterator.
  ***********************************************************************************************/
 
-STDINLINE const void *stdit_key(const stdit *it)
+STDINLINE const void *stdskl_it_key(const stdit *it)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
 
@@ -1048,10 +1080,10 @@
 }
 
 /************************************************************************************************
- * stdit_key_size: Get the size in bytes of the keys to which 'it' refers.
+ * stdskl_it_key_size: Get the size in bytes of the keys to which 'it' refers.
  ***********************************************************************************************/
 
-STDINLINE stdsize stdit_key_size(const stdit *it)
+STDINLINE stdsize stdskl_it_key_size(const stdit *it)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
 
@@ -1059,32 +1091,32 @@
 }
 
 /************************************************************************************************
- * stdit_val: Get a value from an iterator.
+ * stdskl_it_val: Get a value from an iterator.
  ***********************************************************************************************/
 
-STDINLINE void *stdit_val(const stdit *it)
+STDINLINE void *stdskl_it_val(const stdit *it)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
 
-  return STDSKL_NVAL(it->impl.skl.node);
+  return (void*) (it->type_id == STDSKL_IT_ID ? STDSKL_NVAL(it->impl.skl.node) : STDSKL_NKEY(it->impl.skl.node));
 }
 
 /************************************************************************************************
- * stdit_val_size: Get the size in bytes of the values to which 'it' refers.
+ * stdskl_it_val_size: Get the size in bytes of the values to which 'it' refers.
  ***********************************************************************************************/
 
-STDINLINE stdsize stdit_val_size(const stdit *it)
+STDINLINE stdsize stdskl_it_val_size(const stdit *it)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
 
-  return it->impl.skl.vsize;
+  return (it->type_id == STDSKL_IT_ID ? it->impl.skl.vsize : it->impl.skl.ksize);
 }
 
 /************************************************************************************************
- * stdit_eq: Compare two iterators for equality (refer to the same element).
+ * stdskl_it_eq: Compare two iterators for equality (refer to the same element).
  ***********************************************************************************************/
 
-STDINLINE stdbool stdit_eq(const stdit *it1, const stdit *it2)
+STDINLINE stdbool stdskl_it_eq(const stdit *it1, const stdit *it2)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it1) && STDIT_SKL_IS_LEGAL(it2) &&
 		  it1->impl.skl.ksize == it2->impl.skl.ksize &&
@@ -1094,10 +1126,10 @@
 }
 
 /************************************************************************************************
- * stdit_next: Advance 'it' towards end by one position.
+ * stdskl_it_next: Advance 'it' towards end by one position.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_next(stdit *it)
+STDINLINE stdit *stdskl_it_next(stdit *it)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
 
@@ -1107,10 +1139,10 @@
 }
 
 /************************************************************************************************
- * stdit_advance: Advance 'it' towards end by 'num_advance' positions.
+ * stdskl_it_advance: Advance 'it' towards end by 'num_advance' positions.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_advance(stdit *it, stdsize num_advance)
+STDINLINE stdit *stdskl_it_advance(stdit *it, stdsize num_advance)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
 
@@ -1122,10 +1154,10 @@
 }
 
 /************************************************************************************************
- * stdit_prev: Advance 'it' towards begin by one position.
+ * stdskl_it_prev: Advance 'it' towards begin by one position.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_prev(stdit *it)
+STDINLINE stdit *stdskl_it_prev(stdit *it)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
 
@@ -1135,10 +1167,10 @@
 }
 
 /************************************************************************************************
- * stdit_retreat: Advance 'it' towards end by 'num_retreat' positions.
+ * stdskl_it_retreat: Advance 'it' towards end by 'num_retreat' positions.
  ***********************************************************************************************/
 
-STDINLINE stdit *stdit_retreat(stdit *it, stdsize num_retreat)
+STDINLINE stdit *stdskl_it_retreat(stdit *it, stdsize num_retreat)
 {
   STDSAFETY_CHECK(STDIT_SKL_IS_LEGAL(it));
 

Copied: trunk/stdutil/src/stdtest/stdskl_test.cpp (from rev 256, vendor/stdutil/current/src/stdtest/stdskl_test.cpp)

Modified: trunk/stdutil/src/stdthread.c
===================================================================
--- trunk/stdutil/src/stdthread.c	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdthread.c	2005-08-06 12:58:02 UTC (rev 257)
@@ -112,12 +112,17 @@
     goto stdthread_join_fail;
   }
 
-  if (GetExitCodeThread(thr, &term_status) == 0) {
-    goto stdthread_join_fail;
-  }
+  if (exitval_ptr != NULL) {
+#    if (SIZEOF_VOID_P <= 4 && SIZEOF_VOID_P <= SIZEOF_INT)
 
-  if (exitval_ptr != NULL) {
-    *exitval_ptr = (void*) term_status;  /* TODO: broken if sizeof(void*) != sizeof(DWORD) */
+    if (GetExitCodeThread(thr, &term_status) == 0) {
+      goto stdthread_join_fail;
+    }
+
+    *exitval_ptr = (void*) term_status;
+#    else
+    *exitval_ptr = NULL;               /* can't pass a larger pointer through a 4 byte DWORD */
+#    endif
   }
 
   if (CloseHandle(thr) == 0) {
@@ -147,7 +152,11 @@
 STDINLINE void stdthread_exit(void *exitval) 
 #  if defined(_WIN32)
 {
-  _endthreadex((unsigned) exitval);  /* TODO: broken if sizeof(void*) != sizeof(DWORD) */
+#    if (SIZEOF_VOID_P <= 4 && SIZEOF_VOID_P <= SIZEOF_INT)
+  _endthreadex((unsigned) exitval);
+#    else
+  _endthreadex(0);                     /* can't pass a larger pointer through a 4 byte DWORD */
+#    endif
 }
 #  else
 {
@@ -243,8 +252,8 @@
       ret = STDEBUSY;
     }
 
-  } __except (GetExceptionCode() == STATUS_NO_MEMORY ||
-	      GetExceptionCode() == STATUS_INVALID_HANDLE ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
+  } __except ((GetExceptionCode() == STATUS_NO_MEMORY ||
+	       GetExceptionCode() == STATUS_INVALID_HANDLE) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) {
     ret = STDENOMEM;
   }
 
@@ -282,40 +291,55 @@
 {
   stdcode  ret;
   stdbool  woke_one = STDFALSE;
-  DWORD    err      = 0;
-  int      loop_cnt;
 
   if ((ret = stdmutex_impl_grab(&cond->lock, STDTRUE)) != STDESUCCESS) {
     goto stdcond_wake_impl_end;
   }
 
-  while ((wake_all || !woke_one) && STDSLEEPERS_BEGIN(cond) != STDSLEEPERS_END(cond)) {
-    stdcond_link * curr    = STDSLEEPERS_BEGIN(cond);
-    stdcond_link * next    = curr->next;
-    HANDLE         sleeper = curr->sleeper;
+  while (ret == STDESUCCESS && (wake_all || !woke_one) && STDSLEEPERS_BEGIN(cond) != STDSLEEPERS_END(cond)) {
+    stdcond_link * curr     = STDSLEEPERS_BEGIN(cond);
+    stdcond_link * next     = curr->next;
+    HANDLE         sleeper  = curr->sleeper;
+    stdbool        inf_loop = STDFALSE;
+    DWORD          loop_cnt;
+    DWORD          err;
 
-    /* wake sleeper */
+    /* wake sleeper at front of sleepers list */
 
     woke_one = STDFALSE;
 
-    for (loop_cnt = 0; loop_cnt < 1000 && err != 1 && err != -1; ++loop_cnt) {
+    for (loop_cnt = 20; loop_cnt != 0; --loop_cnt) {  /* don't try to wake sleeper more than a constant # of times */
       err = ResumeThread(sleeper);
 
       if (err == 1) {
-	woke_one = STDTRUE;    /* THE SLEEPER HAS AWOKEN! */
+	woke_one = STDTRUE;            /* THE SLEEPER HAS AWOKEN! */
+	break;
 
-      } else if (err == 0) {   /* sleeper wasn't sleeping yet */
-	Sleep(0);              /* yield time slice to give sleeper a chance to hit Suspend() */
+      } else if (err == 0) {
+	Sleep(0);                      /* sleeper hasn't suspended yet: yield time slice and try again */
 
-      } else if (err == -1) {  /* error: remove from list + try next sleeper */
+      } else if (err == (DWORD) -1) {  /* error */
 	ret = (stdcode) GetLastError();
+	break;
+
+      } else if (err > MAXIMUM_SUSPEND_COUNT || (err > loop_cnt && inf_loop)) {
+	ret = STDEUNKNOWN;             /* suspend count acting weird: either invalid or not decrementing! */
+	break;
+
+      } else {
+	inf_loop = STDTRUE;            /* only allow setting loop_cnt one time to prevent infinite loops */
+	loop_cnt = err;                /* set loop_cnt to number of ResumeThreads needed */
       }
-      
-      /* else suspended multiple times -> keep waking him */
     }
 
-    /* NOTE: if loop_cnt gets to 1000; we treat it as an error: remove from list + try next sleeper */
+    /* if ResumeThread returns 0 on the last iteration of the loop,
+       then we treat it as a (semi) success: he's already been awoken
+    */
 
+    if (loop_cnt == 0) {
+      woke_one = STDTRUE;
+    }
+
     /* unlink curr from beginning of sleepers; reclaim handle and stdcond_link */
 
     next->prev                  = STDSLEEPERS_END(cond);
@@ -353,7 +377,7 @@
   /* error handling and return */
 
  stdmutex_fast_init_fail:
-  mut->mut_type = STDMUTEX_INVAL;
+  mut->mut_type = (stdmutex_type) 0;
 
  stdmutex_fast_init_end:
   return ret;
@@ -370,7 +394,7 @@
   STDSAFETY_CHECK(mut->mut_type == STDMUTEX_FAST);
   
   if ((ret = stdmutex_impl_fini(&mut->mut.fast)) == STDESUCCESS) {
-    mut->mut_type = STDMUTEX_INVAL;
+    mut->mut_type = (stdmutex_type) 0;
   }
 
   return ret;    
@@ -408,6 +432,7 @@
   /* NOTE: this WIN32 code works for both fast and recursive mutexes:
      the WIN32 stdmutex_rcrsv_cond_wait is a call through to this fcn
   */
+
   stdcode        ret = STDESUCCESS;
   HANDLE         curr_proc;
   HANDLE         curr_thread;
@@ -418,6 +443,8 @@
   stdcond_link * my_link;
   stdbool        reacquire = STDFALSE;
 
+  STDSAFETY_CHECK(mut->mut_type == STDMUTEX_FAST || mut->mut_type == STDMUTEX_RCRSV);
+
   /* check for recursive mutexes that owner only has one lock */
 
   if (mut->mut_type == STDMUTEX_RCRSV) {
@@ -435,14 +462,10 @@
       ret = STDEBUSY;
       goto stdmutex_fast_cond_wait_end;
     }
-
-  } else if (mut->mut_type != STDMUTEX_FAST) {
-    ret = STDEINVAL;
-    goto stdmutex_fast_cond_wait_end;
   }
 
   /* NOTE: we DuplicateHandle because only this thread is allowed to
-     use a handle from GetCurrentThread() and other threads will need
+     use a handle from GetCurrentThread() and another thread will need
      to resume this thread
   */ 
 
@@ -505,16 +528,16 @@
     abort();
   }
 
-  /* This gap between releasing the lock and suspending is why we
+  /* This gap between releasing cond->lock and suspending is why we
      bumped up the priority to the highest level -- waker will fail to
      wake us if his attempt occurs while this thread is in this gap
-     and he is a higher priority thread.  We need to bump to
+     and waker is a higher priority thread.  We need to bump to
      THREAD_PRIORITY_HIGHEST to ensure that this thread will have
      equal or better capability to run as a waker.  If a waker was of
      higher priority, then he would just loop forever waiting for this
      thread to Suspend, which would never happen due to its lower
      priority.
-  */
+x  */
 
   if (SuspendThread(curr_thread) == -1) {
     abort();
@@ -589,7 +612,7 @@
   stdmutex_impl_fini(&rmut->outer_lock);
   
  stdmutex_rcrsv_init_fail:
-  mut->mut_type = STDMUTEX_INVAL;
+  mut->mut_type = (stdmutex_type) 0;
 
  stdmutex_rcrsv_init_end:
   return ret;
@@ -620,7 +643,7 @@
     goto stdmutex_rcrsv_fini_fail;
   }
 
-  mut->mut_type     = STDMUTEX_INVAL;
+  mut->mut_type     = (stdmutex_type) 0;
   rmut->owner_cnt   = -666;              
   rmut->num_waiting = -666;
 

Modified: trunk/stdutil/src/stdutil/private/stdarch.h.in
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarch.h.in	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/private/stdarch.h.in	2005-08-06 12:58:02 UTC (rev 257)
@@ -23,10 +23,11 @@
 #ifndef stdarch_h_2005_07_12_00_51_28_jschultz_at_cnds_jhu_edu
 #define stdarch_h_2005_07_12_00_51_28_jschultz_at_cnds_jhu_edu
 
-#include <stddef.h>
-#include <limits.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-/* the following #undef's are filled in by the configure script */
+/* the following defines are filled in by the configure script */
 
 #undef SIZEOF_CHAR
 #undef SIZEOF_SHORT
@@ -44,14 +45,12 @@
 */
 
 #undef STDARCH_MAX_BYTE_ALIGNMENT
-#define STDARCH_MAX_BYTE_ALIGNMENT 4
 
-/* check if a NULL char * is all zero in memory */
+/* check if NULL is all zero in memory for "all" types of pointers */
 
 #undef STDARCH_NULL_IS_ZERO
-#define STDARCH_NULL_IS_ZERO 1
 
-/* endian reorder mapping */
+/* endian byte reordering mapping */
 
 #undef STDENDIAN16_SWAP
 
@@ -83,91 +82,77 @@
 #undef STDENDIAN64_HOST6_FROM_NET
 #undef STDENDIAN64_HOST7_FROM_NET
 
-/* define std(u)int32, std(u)int64 and min/max constants */
+/* do architecture specific integer type defs and checks */
 
+/* ensure char's are 1 byte long */
+
 #if (SIZEOF_CHAR != 1)
 #  error No 1 byte integer type found!
 #endif
 
+/* ensure short's are 2 bytes long */
+
 #if (SIZEOF_SHORT != 2)
 #  error No 2 byte integer type found!
 #endif
 
+/* figure out which type is 4 bytes long */
+
 #if (SIZEOF_INT == 4) 
 
-typedef int          stdint32;
-typedef unsigned int stduint32;
+typedef int                stdarch_int32;
+typedef unsigned int       stdarch_uint32;
 
-#  define STDINT32_MAX       INT_MAX
-#  define STDINT32_MIN       INT_MIN
-#  define STDUINT32_MAX      UINT_MAX
-
 #elif (SIZEOF_LONG == 4)
 
-typedef long               stdint32;
-typedef unsigned long      stduint32;
+typedef long               stdarch_int32;
+typedef unsigned long      stdarch_uint32;
 
-#define STDINT32_MAX       LONG_MAX
-#define STDINT32_MIN       LONG_MIN
-#define STDUINT32_MAX      ULONG_MAX
-
 #else
 #  error No 4 byte integer type found!
 #endif
 
-#if defined(_WIN32)
+/* figure out which type is 8 bytes long */
 
-typedef __int64            stdint64;
-typedef unsigned __int64   stduint64;
+#if (SIZEOF_LONG == 8)
 
-#elif (SIZEOF_LONG == 8)
+typedef long               stdarch_int64;
+typedef unsigned long      stdarch_uint64;
 
-typedef long          stdint64;
-typedef unsigned long stduint64;
-
 #elif (SIZEOF_LONG_LONG == 8)
 
-typedef long long          stdint64;
-typedef unsigned long long stduint64;
+typedef long long          stdarch_int64;
+typedef unsigned long long stdarch_uint64;
 
+#elif defined(_MSC_VER)
+
+typedef __int64            stdarch_int64;
+typedef unsigned __int64   stdarch_uint64;
+
 #else
 #  error No 8 byte integeral type found!
 #endif
 
-#define STDINT64_MAX  (~STDINT64_MIN)
-#define STDINT64_MIN  ((stdint64) 0x1 << 63)
-#define STDUINT64_MAX ((stduint64) -1)
+/* figure out which type is the same size as size_t */
 
-/* define stdssize type and min/max constants */
-
 #if (SIZEOF_SIZE_T == 2)
 
-typedef short stdssize;
+typedef short stdarch_ssize;
 
-#  define STDSSIZE_MAX SHRT_MAX
-#  define STDSSIZE_MIN SHRT_MIN
-
 #elif (SIZEOF_SIZE_T == 4)
 
-typedef stdint32 stdssize;
+typedef stdarch_int32 stdarch_ssize;
 
-#  define STDSSIZE_MAX STDINT32_MAX
-#  define STDSSIZE_MIN STDINT32_MIN
-
 #elif (SIZEOF_SIZE_T == 8)
 
-typedef stdint64 stdssize;
+typedef stdarch_int64 stdarch_ssize;
 
-#  define STDSSIZE_MAX STDINT64_MAX
-#  define STDSSIZE_MIN STDINT64_MIN
-
 #else
 #  error No integral type of same size as size_t!
 #endif
 
-/* macros used for ensuring proper byte alignment of types in memory */
+#ifdef __cplusplus
+}
+#endif
 
-#define STDARCH_PADDING(x)     ((STDARCH_MAX_BYTE_ALIGNMENT - ((x) & (STDARCH_MAX_BYTE_ALIGNMENT - 1))) & (STDARCH_MAX_BYTE_ALIGNMENT - 1))
-#define STDARCH_PADDED_SIZE(x) ((x) + STDARCH_PADDING(x))
-
 #endif

Modified: trunk/stdutil/src/stdutil/private/stdskl_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdskl_p.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/private/stdskl_p.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -49,7 +49,7 @@
 
 } stdskl_node;
 
-/* stdskl: A tree based dictionary that maps non-unique keys to values.
+/* stdskl: A skiplist based dictionary that maps non-unique keys to values.
 
    end_node  - pointer to sentinel end node of list
    size      - number of key-value pairs contained
@@ -74,7 +74,7 @@
 
   stduint16     seed[3];
   stduint32     rand_bits;
-  stduint8      bits_left;
+  stdint8       bits_left;
 
 } stdskl;
 

Modified: trunk/stdutil/src/stdutil/private/stdthread_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdthread_p.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/private/stdthread_p.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -56,7 +56,9 @@
    semantics is to have an auto-reset EVENT that you PulseEvent N
    times for each sleeping thread for wake all.  If you do that you
    can have a timed sleep, whereas we can't easily do that with
-   SuspendThread and ResumeThread.
+   SuspendThread and ResumeThread.  (Might be able to do this with a
+   dedicated 'waker' thread who manages waking up sleeping threads
+   based on timeouts)
 */
 
 #else
@@ -70,9 +72,6 @@
 
 #endif
 
-#define STDMUTEX_INVAL -1UL
-
-typedef stdulong stdmutex_type;
 typedef stdmutex_impl stdmutex_fast;
 
 typedef struct
@@ -87,7 +86,7 @@
 
 typedef struct stdmutex
 {
-  volatile stdmutex_type mut_type;
+  stdmutex_type mut_type;
 
   union {
     stdmutex_fast  fast;

Modified: trunk/stdutil/src/stdutil/stddefines.h
===================================================================
--- trunk/stdutil/src/stdutil/stddefines.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/stddefines.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -23,13 +23,18 @@
 #ifndef stddefines_h_2000_10_22_18_20_30_jschultz_at_cnds_jhu_edu
 #define stddefines_h_2000_10_22_18_20_30_jschultz_at_cnds_jhu_edu
 
+#include <stddef.h>
+#include <limits.h>
+
+/* include basic, architecture-specific types and constants */
+
 #include <stdutil/private/stdarch.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* define some useful basic types */
+/* define some useful basic types and constants */
 
 typedef int                stdbool;
 
@@ -62,13 +67,27 @@
 #define STDINT16_MIN       SHRT_MIN
 #define STDUINT16_MAX      USHRT_MAX
 
+typedef stdarch_int32      stdint32;
+typedef stdarch_uint32     stduint32;
+
+#define STDINT32_MAX       (STDINT32_MIN - 1)
+#define STDINT32_MIN       ((stdint32) ((stduint32) 0x1 << 31))
+#define STDUINT32_MAX      ((stduint32) -1)
+
+typedef stdarch_int64      stdint64;
+typedef stdarch_uint64     stduint64;
+
+#define STDINT64_MAX       (STDINT64_MIN - 1)
+#define STDINT64_MIN       ((stdint64) ((stduint64) 0x1 << 63))
+#define STDUINT64_MAX      ((stduint64) -1)
+
 typedef size_t             stdsize;
+typedef stdarch_ssize      stdssize;  /* a signed version of size_t */
+
+#define STDSSIZE_MAX       (STDSSIZE_MIN - 1)
+#define STDSSIZE_MIN       ((stdssize) ((stdsize) 0x1 << (sizeof(stdssize) * 8 - 1))
 #define STDSIZE_MAX        ((stdsize) -1)
 
-/* stdarch.h similiarly defines std(u)int32, std(u)int64, stdssize (a
-   signed verion of stdsize) and associated min and max constants
-*/
-
 /* define comparison fcn types */
 
 typedef stduint32 stdhcode;
@@ -78,30 +97,37 @@
 
 /* define some common, if dangerous, macros */
 
-#define STDSWAP(x, y, t) ((t) = (x), (x) = (y), (y) = (t))
-#define STDMAX(x, y) ((x) > (y) ? (x) : (y))
-#define STDMIN(x, y) ((x) < (y) ? (x) : (y))
+#define STDSWAP(x, y, t)   ((t) = (x), (x) = (y), (y) = (t))
+#define STDMAX(x, y)       ((x) > (y) ? (x) : (y))
+#define STDMIN(x, y)       ((x) < (y) ? (x) : (y))
 
 /* define some useful constants */
 
-#define STD1THOUSAND 1000
-#define STD1MILLION  1000000L
-#define STD1BILLION  1000000000L
+#define STD1THOUSAND       1000
+#define STD1MILLION        1000000L
+#define STD1BILLION        1000000000L
 
 /* inline rules vary too much from language to language (C89, C99,
    C++) and compiler to compiler (gcc, .NET, etc.) in non-standard
    usage (i.e. - inline in C89) for stdutil to use any one inline
-   syntax.  The way to get inline to work as expected with stdutil is
-   to have one translation unit that first #includes all of stdutil's
-   .c files and then all of your app's .c files.  Then #define or -D
-   STDINLINE as the appropriate value for your compiler/language combo
-   to get fcn inlining to work.
+   syntax.  The way to get inline to work as it should with stdutil is
+   to compile all of your project in one translation unit, either
+   #define or -D an appropriate value for STDINLINE and THEN #include
+   <stdutil/> which properly includes ALL of stdutil's code.  Because
+   all of your code will be in a single translation unit, the compiler
+   can then do a good job of inline'ing stdutil fcn calls, which it
+   can't do well if stdutil is a library.
 */
 
 #ifndef STDINLINE
 #  define STDINLINE
 #endif
 
+/* macros used for ensuring proper byte alignment of dynamic types in memory */
+
+#define STDARCH_PADDING(x)     ((STDARCH_MAX_BYTE_ALIGNMENT - ((x) & (STDARCH_MAX_BYTE_ALIGNMENT - 1))) & (STDARCH_MAX_BYTE_ALIGNMENT - 1))
+#define STDARCH_PADDED_SIZE(x) ((x) + STDARCH_PADDING(x))
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/stdutil/src/stdutil/stderror.h
===================================================================
--- trunk/stdutil/src/stdutil/stderror.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/stderror.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -35,6 +35,7 @@
 /* stderr error routines */
 
 #ifndef STDERR_MAX_ERR_MSG_LEN 
+/* NOTE: redefining this variable only has an effect at compile time of the stdutil LIBRARY; not app. code */
 #  define STDERR_MAX_ERR_MSG_LEN 1024
 #endif
 
@@ -108,6 +109,12 @@
 #  define STDENOSYS 506
 #endif
 
+#if defined(EINTR)
+#  define STDEINTR EINTR
+#else
+#  define STDEINTR 507
+#endif
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/stdutil/src/stdutil/stdfd.h
===================================================================
--- trunk/stdutil/src/stdutil/stdfd.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/stdfd.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -37,11 +37,30 @@
 
 } stdfd;
 
+#define STDFD_INIT() { -1, NULL }
+
+typedef enum 
+{
+  STDFD_READ_ONLY = 2000,     /* rb  */
+  STDFD_READ_WRITE_EXISTING,  /* rb+ */
+  STDFD_WRITE_ONLY,           /* wb  */
+  STDFD_READ_WRITE_NEW,       /* wb+ */
+  STDFD_APPEND_ONLY,          /* ab  */
+  STDFD_READ_APPEND           /* ab+ */
+
+} stdfd_access_type;          /* as per fopen(): redefined for static enum check warnings */
+
+typedef enum 
+{
+  STDSEEK_SET = SEEK_SET,
+  STDSEEK_CUR = SEEK_CUR,
+  STDSEEK_END = SEEK_END
+
+} stdfd_whence;               /* as per fseek(): redefined for static enum check warnings */
+
 /* File Descriptor Operations */
 
-#define STDFD_STATIC_CONSTRUCT { -1, NULL }
-
-STDINLINE stdcode stdfd_open(stdfd *fd, const char *path, const char *mode);
+STDINLINE stdcode stdfd_open(stdfd *fd, const char *path, stdfd_access_type mode);
 STDINLINE stdcode stdfd_close(stdfd *fd);
 
 STDINLINE stdcode stdfd_read(stdfd *fd, void *ptr, stdsize nsize, stdsize nmemb, stdsize *num);
@@ -50,19 +69,9 @@
 STDINLINE stdcode stdfd_flush(stdfd *fd);
 STDINLINE stdcode stdfd_sync(stdfd *fd);
 
-typedef long stdfd_pos;
+STDINLINE stdcode stdfd_seek(stdfd *fd, long offset, stdfd_whence whence);
+STDINLINE stdcode stdfd_tell(stdfd *fd, long *pos);
 
-typedef enum 
-{
-  STDSEEK_SET = SEEK_SET,
-  STDSEEK_CUR = SEEK_CUR,
-  STDSEEK_END = SEEK_END
-
-} stdfd_whence;
-
-STDINLINE stdcode stdfd_seek(stdfd *fd, stdfd_pos offset, stdfd_whence whence);
-STDINLINE stdcode stdfd_get_pos(stdfd *fd, stdfd_pos *pos);
-
 STDINLINE stdbool stdfd_eof(stdfd *fd);
 STDINLINE stdbool stdfd_err(stdfd *fd);
 STDINLINE void    stdfd_clr_err(stdfd *fd);

Modified: trunk/stdutil/src/stdutil/stdit.h
===================================================================
--- trunk/stdutil/src/stdutil/stdit.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/stdit.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -44,7 +44,7 @@
 STDINLINE stdit_type   stdit_get_type(const stdit *it);
 
 STDINLINE const void * stdit_key(const stdit *it);       /* returns NULL for non-dictionary iterators */
-STDINLINE stdsize      stdit_key_size(const stdit *it);  /* returns zero for non-dictionary iterators */
+STDINLINE stdsize      stdit_key_size(const stdit *it);  /* returns 0 for non-dictionary iterators */
 
 STDINLINE void *       stdit_val(const stdit *it);
 STDINLINE stdsize      stdit_val_size(const stdit *it);
@@ -68,11 +68,11 @@
 
 /* Pointer/C-Array Iterator Constructor */
 
-STDINLINE stdit *      stdit_ptr(stdit *it, const void * val, stdsize vsize);
+STDINLINE stdit *      stdit_ptr(stdit *it, const void * vals, stdsize vsize);
 
 /* Parallel Pointer/C-Array Constructor */
 
-STDINLINE stdit *      stdit_pptr(stdit *it, const void *key, const void *val, stdsize ksize, stdsize vsize);
+STDINLINE stdit *      stdit_pptr(stdit *it, const void *keys, const void *vals, stdsize ksize, stdsize vsize);
 
 #ifdef __cplusplus
 }

Modified: trunk/stdutil/src/stdutil/stdthread.h
===================================================================
--- trunk/stdutil/src/stdutil/stdthread.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/stdthread.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -31,6 +31,13 @@
 extern "C" {
 #  endif
 
+typedef enum
+{
+  STDMUTEX_FAST  = (int) 0xa720c831UL,
+  STDMUTEX_RCRSV = (int) 0x3f6c20deUL
+
+} stdmutex_type;
+
 #  include <stdutil/private/stdthread_p.h>
 
 /* Declare thread entry functions like this: void * STDTHREAD_FCN foo(void * arg); */
@@ -50,9 +57,6 @@
 
 /* Mutual Exclusion Locks */
 
-#  define STDMUTEX_FAST  0xa720c831UL
-#  define STDMUTEX_RCRSV 0x3f6c20deUL
-
 STDINLINE stdcode      stdmutex_construct(stdmutex *mut, stdmutex_type t);
 STDINLINE stdcode      stdmutex_destruct(stdmutex *mut);
 

Modified: trunk/stdutil/src/stdutil/stdtime.h
===================================================================
--- trunk/stdutil/src/stdutil/stdtime.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/stdtime.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -49,7 +49,7 @@
 STDINLINE stdtime   stdtime_sub(stdtime ls, stdtime rs);
 
 STDINLINE stdcode   stdtime64_now(stdtime64 *abs_time);
-STDINLINE stdtime64 stdtime64_time(stdtime t);  /* conversion can over/under flow */
+STDINLINE stdtime64 stdtime64_time(stdtime t);  /* conversion can silently over/under flow */
 
 /* sleep fcns */
 

Modified: trunk/stdutil/src/stdutil/stdutil.h
===================================================================
--- trunk/stdutil/src/stdutil/stdutil.h	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil/stdutil.h	2005-08-06 12:58:02 UTC (rev 257)
@@ -39,7 +39,7 @@
 
 STDINLINE void *    stdmemdup(const void *dupme, stdsize n);
 
-/* hcode fcns */
+/* 32b hcode fcns */
 
 STDINLINE stduint32 stdhcode_oaat(const void * buf, stdsize buf_len);
 

Modified: trunk/stdutil/src/stdutil.c
===================================================================
--- trunk/stdutil/src/stdutil.c	2005-08-06 12:47:04 UTC (rev 256)
+++ trunk/stdutil/src/stdutil.c	2005-08-06 12:58:02 UTC (rev 257)
@@ -67,13 +67,15 @@
 }
 
 /************************************************************************************************
- * stdstrdup: Return a malloc'ed copy of 'dupme.'
+ * stdstrdup: Return a malloc'ed copy of 'dupme.'  Returns NULL on
+ * allocation failure.  If len_ptr is not NULL, then strlen(dupme)
+ * will always be placed there regardless of success or failure.
  ***********************************************************************************************/
 
 STDINLINE char *stdstrdup(const char *dupme, stdsize *len_ptr)
 {
   stdsize len = strlen(dupme);
-  char *  ret = malloc(len + 1);
+  char *  ret = (char*) malloc(len + 1);
   
   if (len_ptr != NULL) {
     *len_ptr = len;
@@ -83,9 +85,9 @@
 }
 
 /************************************************************************************************
- * stdstrdup_n: Like stdstrdup, but only copies up through the first
- * min('n', strlen('src')) bytes of 'src' and then adds a NUL
- * termination.
+ * stdstrdup_n: Like stdstrdup, but only allocates and copies up
+ * through the first min('n', strlen('src')) bytes of 'src' and then
+ * adds a NUL termination.
  ***********************************************************************************************/
 
 STDINLINE char *stdstrdup_n(const char *src, stdsize *len_ptr, size_t n)
@@ -113,13 +115,14 @@
 }
 
 /************************************************************************************************
- * stdmemdup: Allocates a new block of memory 'n' bytes long and
- * copies the first 'n' bytes of 'src' to the new block.
+ * stdmemdup: Allocates and returns a new block of memory 'n' bytes
+ * long and copies the first 'n' bytes of 'src' to the new block.  If
+ * n is zero this fcn will return NULL.
  ***********************************************************************************************/
 
 STDINLINE void *stdmemdup(const void *src, size_t n)
 {
-  void * ret = malloc(n);
+  void * ret = (n != 0 ? malloc(n) : NULL);
 
   if (ret != NULL) {
     memcpy(ret, src, n);
@@ -139,7 +142,7 @@
 {
   const char * kit  = (const char*) buf;
   const char * kend = (const char*) buf + buf_len;
-  stduint32    ret  = (stduint32) buf_len;
+  stduint32    ret  = ~((stduint32) buf_len);
 
   for (; kit != kend; ++kit) {
     ret += *kit;
@@ -157,14 +160,15 @@
 /************************************************************************************************
  * stdhcode_oaat_start: Begin computing a One-at-a-Time hash that will
  * span several buffers.  Preferably, but not required, tot_len would
- * equal the total length of the buffers to be hcoded.  For least
- * collisions, if the total length is unknown but non-zero,
- * consistently use the same arbitrary non-zero constant (e.g. -1).
+ * equal the total length of the buffers to be hcoded.  If the total
+ * length is unknown (or you simply don't want to compute it), then
+ * consistently use the same arbitrary constant (e.g. - 0) when
+ * computing the hcode for those objects.
  ***********************************************************************************************/
 
 STDINLINE void stdhcode_oaat_start(stduint32 *hsh, stdsize tot_len)
 {
-  *hsh = (stduint32) tot_len;
+  *hsh = ~((stduint32) tot_len);
 }
 
 /************************************************************************************************
@@ -207,22 +211,22 @@
  * stdhcode_sfh: Paul Hsieh's Super Fast Hash hash code function.
  * Computes a 32 bit integer based on all 'buf_len' bytes of 'buf.'
  * Every input bit can affect every bit of the result with about 50%
- * probability per output bit -- has no funnels.  Paul Hsieh alleges
+ * probability per output bit -- has no funnels.  Paul Hsieh claims
  * superior speed and distribution compared to One-at-a-Time.
  ***********************************************************************************************/
 
 #if ((defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) || defined(_MSC_VER) || \
      defined (__BORLANDC__) || defined (__TURBOC__))
-#  define stdhcode_sfh_get16bits(d) (*((const stduint16*) (d)))
+#  define stdhcode_sfh_get16bits(d) ( *((const stduint16*)(d)) )
 #else
-#  define stdhcode_sfh_get16bits(d) ( (stduint16) (*((const stduint8 *)(d) + 1) << 8) + *((const stduint8 *)(d)) )
+#  define stdhcode_sfh_get16bits(d) ( ((stduint16) *((const stduint8 *)(d) + 1) << 8) + *(const stduint8 *)(d) )
 #endif
 
 STDINLINE stduint32 stdhcode_sfh(const void * buf, stdsize buf_len) 
 {
   const stduint8 * kit  = (const stduint8*) buf;
-  const stduint8 * kend = (const stduint8*) buf + (buf_len & ~0x3);
-  stduint32        ret  = (stduint32) buf_len;
+  const stduint8 * kend = (const stduint8*) buf + (buf_len & ~0x3);  /* leave remainder modulo 4 */
+  stduint32        ret  = ~((stduint32) buf_len);
   stduint32        tmp;
 
   /* main mixing loop */
@@ -235,7 +239,7 @@
     ret += ret >> 11;
   }
 
-  /* handle remainder not handled by loop */
+  /* handle remainder modulo 4 not handled by loop */
 
   switch (buf_len & 0x3) {
   case 3: 
@@ -272,14 +276,15 @@
 /************************************************************************************************
  * stdhcode_sfh_start: Begin computing a SuperFastHash hash that will
  * span several buffers.  Preferably, but not required, tot_len would
- * equal the total length of the buffers to be hash coded.  For least
- * collisions, if the total length is unknown but non-zero,
- * consistently use an arbitrary constant instead of zero (e.g. -1).
+ * equal the total length of the buffers to be hash coded.  If the total
+ * length is unknown (or you simply don't want to compute it), then
+ * consistently use the same arbitrary constant (e.g. - 0) when
+ * computing the hcode for those objects.
  ***********************************************************************************************/
 
 STDINLINE void stdhcode_sfh_start(stduint32 *hsh, stdsize tot_len)
 {
-  *hsh = tot_len;
+  *hsh = ~((stduint32) tot_len);
 }
 
 /************************************************************************************************
@@ -290,7 +295,7 @@
 STDINLINE void stdhcode_sfh_churn(stduint32 *hsh, const void * buf, stdsize buf_len)
 {
   const stduint8 * kit  = (const stduint8*) buf;
-  const stduint8 * kend = (const stduint8*) buf + (buf_len & ~3);
+  const stduint8 * kend = (const stduint8*) buf + (buf_len & ~0x3);  /* leave remainder modulo 4 */
   stduint32        ret  = *hsh;
   stduint32        tmp;
 
@@ -304,7 +309,7 @@
     ret += ret >> 11;
   }
 
-  /* handle remainder not handled by loop */
+  /* handle modulo 4 remainder not handled by loop */
 
   switch (buf_len & 3) {
   case 3: 
@@ -350,8 +355,8 @@
   *hsh = ret;
 }
 
-/*
- * Copyright (c) 1993 Martin Birgmeier
+
+/* Copyright (c) 1993 Martin Birgmeier
  * All rights reserved.
  *
  * You may redistribute unmodified or modified versions of this source
@@ -467,14 +472,14 @@
 
 /************************************************************************************************
  * For the following endian flipping code, I have defined in
- * stdutil/stdutil_p.h a mapping from network byte order to host byte
- * order and the reverse mapping for several size integers.
+ * stdutil/private/stdarch.h a mapping from network byte order to host
+ * byte order and the reverse mapping for 16, 32 and 64 bit integers.
  *
  * For example, in a 64b integer on little endian architectures, the
- * most significant byte is the highest byte in memory (7), while on a
- * big endian architecture it is the lowest byte in memory (0).  We
- * represent this information in stdutil/stdutil_p.h as, on the
- * respective architectures,
+ * most significant byte is the highest byte in memory (byte 7), while
+ * on a big endian architecture it is the lowest byte in memory (byte
+ * 0).  We represent this information in stdutil/stdutil_p.h as, on
+ * the respective architectures,
  *
  * (#define STDENDIAN64_NET0_FROM_HOST 7, #define STDENDIAN64_HOST7_FROM_NET 0) 
  *
@@ -663,14 +668,15 @@
 
 /************************************************************************************************
  * stdhton_n: Rearranges the 'n' bytes at which 'io' points from host
- * into network byte ordering.  If n is one of (1, 2, 4, 8), then the fcn
- * succeeds, returning zero.  Otherwise it fails with no side effects,
+ * into network byte ordering.  If n is one of (0, 1, 2, 4, 8), then
+ * the fcn succeeds.  Otherwise it fails with no side effects,
  * returning STDEINVAL.
  ***********************************************************************************************/
 
 STDINLINE stdcode stdhton_n(void *io, size_t n)
 {
   switch (n) {
+  case 0:
   case 1:
     break;
 
@@ -869,14 +875,15 @@
 
 /************************************************************************************************
  * stdntoh_n: Rearranges the 'n' bytes at which 'io' points from
- * network to host byte ordering.  If n is one of (1, 2, 4, 8), then the
- * fcn succeeds, returning zero.  Otherwise it fails with no side
- * effects, returning STDEINVAL.
+ * network to host byte ordering.  If n is one of (0, 1, 2, 4, 8),
+ * then the fcn succeeds.  Otherwise it fails with no side effects,
+ * returning STDEINVAL.
  ***********************************************************************************************/
 
 STDINLINE stdcode stdntoh_n(void *io, size_t n)
 {
   switch (n) {
+  case 0:
   case 1:
     break;
 
@@ -960,20 +967,20 @@
 /************************************************************************************************
  * stdlg_down: Returns the log base 2 of 'x' rounded down to the
  * closest integer (i.e. - floor(lg(x))).  Returns (stduint32) -1 if
- * 'x' 0.
+ * 'x' is 0.
  ***********************************************************************************************/
 
 STDINLINE stduint32 stdlg_down(stduint64 x) 
 {
-  stduint32 shift;
+  stduint32 ret;
 
   if (x == 0) {
     return (stduint32) -1;
   }
 
-  for (shift = 0; x != 0x1; x >>= 1, ++shift);
+  for (ret = 0; x != 0x1; x >>= 1, ++ret);
 
-  return shift;
+  return ret;
 }
 
 /************************************************************************************************
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.