commit: r371 - in vendor/stdutil/current: . src src/stdutil src/stdutil/private
[email protected] Sun, 19 Nov 2006 10:17:13 -0500
| Newsgroups | gmane.network.spread.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: jonathan Date: 2006-11-19 10:17:12 -0500 (Sun, 19 Nov 2006) New Revision: 371 Added: vendor/stdutil/current/src/stdtest/ vendor/stdutil/current/src/stdutil/private/stdarch_autoconf.h.in vendor/stdutil/current/src/stdutil/private/stdarch_wintel32.h Removed: vendor/stdutil/current/src/stdutil/private/stdarch.h.in Modified: vendor/stdutil/current/README vendor/stdutil/current/configure vendor/stdutil/current/configure.in vendor/stdutil/current/src/Makefile.in vendor/stdutil/current/src/stdarr.c vendor/stdutil/current/src/stdcarr.c vendor/stdutil/current/src/stddll.c vendor/stdutil/current/src/stderror.c vendor/stdutil/current/src/stdfd.c vendor/stdutil/current/src/stdhash.c vendor/stdutil/current/src/stdit.c vendor/stdutil/current/src/stdskl.c vendor/stdutil/current/src/stdthread.c vendor/stdutil/current/src/stdtime.c vendor/stdutil/current/src/stdutil.c vendor/stdutil/current/src/stdutil/private/stdarch.h vendor/stdutil/current/src/stdutil/private/stdarr_p.h vendor/stdutil/current/src/stdutil/private/stdcarr_p.h vendor/stdutil/current/src/stdutil/private/stddll_p.h vendor/stdutil/current/src/stdutil/private/stdhash_p.h vendor/stdutil/current/src/stdutil/private/stdit_p.h vendor/stdutil/current/src/stdutil/private/stdskl_p.h vendor/stdutil/current/src/stdutil/private/stdthread_p.h vendor/stdutil/current/src/stdutil/stdarr.h vendor/stdutil/current/src/stdutil/stdcarr.h vendor/stdutil/current/src/stdutil/stddefines.h vendor/stdutil/current/src/stdutil/stddll.h vendor/stdutil/current/src/stdutil/stderror.h vendor/stdutil/current/src/stdutil/stdfd.h vendor/stdutil/current/src/stdutil/stdhash.h vendor/stdutil/current/src/stdutil/stdit.h vendor/stdutil/current/src/stdutil/stdskl.h vendor/stdutil/current/src/stdutil/stdthread.h vendor/stdutil/current/src/stdutil/stdtime.h vendor/stdutil/current/src/stdutil/stdutil.h Log: Update to stdutil release 1.0.0-beta6 November 2006 Modified: vendor/stdutil/current/README =================================================================== --- vendor/stdutil/current/README 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/README 2006-11-19 15:17:12 UTC (rev 371) @@ -1,4 +1,4 @@ -This is the v1.0.0 (January 2006) distribution of the StdUtil library. +This is the v1.0.0 (November 2006) distribution of the StdUtil library. DESCRIPTION: @@ -6,13 +6,16 @@ LICENSE: -The license for use of the StdUtil library or its code is contained in -the file STDUTIL_LICENSE found in the root of this distribution. +The license for use of the StdUtil library and/or its code is +contained in the file STDUTIL_LICENSE found in the root of this +distribution. DOCUMENTATION: -HTML documentaiton is contained within the docs directory or can be -accessed on the web at http://www.cnds.jhu.edu/software/stdutil/docs +Documentation is currently incomplete but will be available in a +subsequent release in HTML format in the docs directory. The +documentation will also be available at +http://www.cnds.jhu.edu/software/stdutil/docs BUILDING: @@ -23,8 +26,8 @@ Please report bugs and/or bug fixes to [email protected] with a gdb compatible core (if possible) and any information that could help -me fix the problem. +fix the problem. Enjoy, John Schultz <[email protected]> -January 2006 +November 2006 Modified: vendor/stdutil/current/configure =================================================================== --- vendor/stdutil/current/configure 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/configure 2006-11-19 15:17:12 UTC (rev 371) @@ -1314,7 +1314,7 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. - ac_config_headers="$ac_config_headers src/stdutil/private/stdarch.h" + ac_config_headers="$ac_config_headers src/stdutil/private/stdarch_autoconf.h" ac_ext=c @@ -8030,7 +8030,7 @@ case "$ac_config_target" in # Handling of arguments. "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; - "src/stdutil/private/stdarch.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/stdutil/private/stdarch.h" ;; + "src/stdutil/private/stdarch_autoconf.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/stdutil/private/stdarch_autoconf.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; Modified: vendor/stdutil/current/configure.in =================================================================== --- vendor/stdutil/current/configure.in 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/configure.in 2006-11-19 15:17:12 UTC (rev 371) @@ -1,7 +1,7 @@ AC_INIT(src/stdutil/stddefines.h) AC_CONFIG_AUX_DIR(buildtools) -AC_CONFIG_HEADER(src/stdutil/private/stdarch.h) +AC_CONFIG_HEADER(src/stdutil/private/stdarch_autoconf.h) AC_LANG_C Modified: vendor/stdutil/current/src/Makefile.in =================================================================== --- vendor/stdutil/current/src/Makefile.in 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/Makefile.in 2006-11-19 15:17:12 UTC (rev 371) @@ -1,4 +1,5 @@ .SUFFIXES: .do .to .tdo .lo .ldo .lto .ltdo +.PHONY: all standard libdir clean distclean uberclean LIBVERSION=1.0 @@ -13,15 +14,20 @@ SOFTLINK=@LN_S@ INSTALL=@INSTALL@ +srcdir=@srcdir@ +top_srcdir=@top_srcdir@ +VPATH=@srcdir@ +buildtoolsdir=$(top_srcdir)/buildtools + ############################################# FLAGS ########################################### CFLAGS=@CFLAGS@ -CPPFLAGS=@CPPFLAGS@ -I./ +CPPFLAGS=@CPPFLAGS@ -I./ -I$(srcdir) LDFLAGS=@LDFLAGS@ LIBS=@LIBS@ SHCFLAGS=@SHCFLAGS@ -SHCPPFLAGS=@SHCPPFLAGS@ -I./ +SHCPPFLAGS=@SHCPPFLAGS@ -I./ -I$(srcdir) SHLDFLAGS=@SHLDFLAGS@ SHLIBS=@SHLIBS@ @@ -60,14 +66,17 @@ STATIC_LIBS=$(STATIC_NOTHREAD_RELEASE_LIB) $(STATIC_NOTHREAD_DEBUG_LIB) $(STATIC_THREADED_RELEASE_LIB) $(STATIC_THREADED_DEBUG_LIB) SHARED_LIBS=$(SHARED_NOTHREAD_RELEASE_LIB) $(SHARED_NOTHREAD_DEBUG_LIB) $(SHARED_THREADED_RELEASE_LIB) $(SHARED_THREADED_DEBUG_LIB) -ALLTARGETS=$(STATIC_LIBS) @SHARED_LIBS@ +ALLTARGETS=$(STATIC_LIBS) $(SHARED_LIBS) ########################################### BUILD RULES ######################################## -standard: @STANDARD_LIBS@ +standard: libdir @STANDARD_LIBS@ -all: $(ALLTARGETS) +all: libdir $(ALLTARGETS) +libdir: + $(buildtoolsdir)/mkinstalldirs $(LIBDIR) + $(STATIC_NOTHREAD_RELEASE_LIB): $(STATIC_NOTHREAD_RELEASE_OBJS) $(AR) rvs $@ $(STATIC_NOTHREAD_RELEASE_OBJS) @@ -95,10 +104,10 @@ $(SHLD) $(SHLDFLAGS) -o $@ $(SHARED_THREADED_DEBUG_OBJS) $(SHLIBS) $(THLIBS) clean: - rm -f *.o *.do *.to *.tdo *.lo *.ldo *.lto *.ltdo core* *~ $(ALLTARGETS) $(LIBDIR)/stdutil.a $(LIBDIR)/stdutil.@DYNLIBEXT@ + rm -f *.o *.do *.to *.tdo *.lo *.ldo *.lto *.ltdo core* *~ $(ALLTARGETS) $(LIBDIR)/libstdutil.a $(LIBDIR)/libstdutil.@DYNLIBEXT@ distclean: clean - rm -f Makefile + rm -f Makefile stdutil/private/stdarch_autoconf.h uberclean: distclean Modified: vendor/stdutil/current/src/stdarr.c =================================================================== --- vendor/stdutil/current/src/stdarr.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdarr.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -26,6 +25,10 @@ #include <stdutil/stderror.h> #include <stdutil/stdarr.h> +#ifdef __cplusplus +extern "C" { +#endif + #define STDARR_IS_LEGAL(arr) ((arr)->begin <= (arr)->end && \ (arr)->begin + (arr)->size * (arr)->vsize == (arr)->end && \ ( ((arr)->cap != 0 && (arr)->begin != NULL) || ((arr)->cap == 0 && (arr)->begin == NULL) ) && \ @@ -50,9 +53,11 @@ stdsize delta = num_insert * arr->vsize; stdsize after = (stdsize) (arr->end - it->val); - if (nsize > arr->cap) { /* nsize > arr->cap -> nsize > 0 */ - stdsize ncap = (nsize << 1); /* nsize > 0 -> ncap > 0 */ - stdsize prior = (stdsize) (it->val - arr->begin); + /* reallocate if current capacity is not big enough */ + + if (nsize > stdarr_high_capacity(arr)) { /* nsize > X -> nsize > 0 */ + stdsize ncap; + stdsize prior; stdsize asize; char * mem; @@ -61,8 +66,10 @@ goto stdarr_low_insert_space_end; } + ncap = (nsize << 1); /* nsize > 0 -> ncap > 0 */ ncap = STDMAX(ncap, STDARR_MIN_AUTO_ALLOC); /* ensure minimum allocation */ asize = ncap * arr->vsize; /* calc. alloc size in bytes */ + prior = (stdsize) (it->val - arr->begin); if ((mem = (char*) realloc(arr->begin, asize)) == NULL) { ret = STDENOMEM; @@ -76,8 +83,10 @@ it->val = mem + prior; /* relocate 'it' to insertion point */ } - memmove(it->val + delta, it->val, after); /* shift mem */ + /* shift memory to create space */ + memmove(it->val + delta, it->val, after); + arr->end += delta; arr->size = nsize; @@ -98,13 +107,17 @@ char * it_end = it->val + delta; stdsize after = (stdsize) (arr->end - it_end); - memmove(it->val, it_end, after); /* shift mem */ + /* shift memory to remove space */ + memmove(it->val, it_end, after); + arr->end -= delta; arr->size = nsize; - if ((arr->opts & STDARR_OPTS_NO_AUTO_SHRINK) == 0 && /* shrinking wanted */ - nsize <= stdarr_low_capacity(arr) && /* shrinking necessary */ + /* reallocate if current capacity is too big */ + + if ((arr->opts & STDARR_OPTS_NO_AUTO_SHRINK) == 0 && /* shrinking allowed */ + nsize <= stdarr_low_capacity(arr) && /* shrinking needed */ arr->cap != STDARR_MIN_AUTO_ALLOC) { /* cap not at min alloc */ stdsize ncap = (nsize << 1); @@ -122,7 +135,6 @@ arr->begin = mem; /* fill in new values for 'arr' */ arr->end = mem + prior + after; - arr->size = nsize; arr->cap = ncap; } else { /* ncap == 0 -> go to zero */ @@ -133,11 +145,10 @@ arr->begin = NULL; arr->end = NULL; - arr->size = 0; /* implicitly already 0 */ arr->cap = 0; } - it->val = arr->begin + prior; /* relocate 'it' to new position */ + it->val = arr->begin + prior; /* relocate 'it' to erasure point */ } } @@ -474,7 +485,7 @@ arr->size = STDMIN(arr->size, num_elems); arr->begin = mem; - arr->end = mem + arr->size * num_elems; + arr->end = mem + arr->size * arr->vsize; } else { @@ -880,3 +891,7 @@ return it; } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stdcarr.c =================================================================== --- vendor/stdutil/current/src/stdcarr.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdcarr.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -26,6 +25,10 @@ #include <stdutil/stderror.h> #include <stdutil/stdcarr.h> +#ifdef __cplusplus +extern "C" { +#endif + #define STDCARR_IS_LEGAL(carr) (( ((carr)->cap != 0 && (carr)->base != NULL) || ((carr)->cap == 0 && (carr)->base == NULL) ) && \ (stdsize) ((carr)->endbase - (carr)->base) == (carr)->cap * (carr)->vsize && \ (carr)->begin >= (carr)->base && (carr)->begin <= (carr)->endbase && \ @@ -1447,3 +1450,7 @@ { return (offset >= 0 ? stdcarr_it_advance(it, (stdsize) offset) : stdcarr_it_retreat(it, (stdsize) -offset)); } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stddll.c =================================================================== --- vendor/stdutil/current/src/stddll.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stddll.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -26,6 +25,10 @@ #include <stdutil/stderror.h> #include <stdutil/stddll.h> +#ifdef __cplusplus +extern "C" { +#endif + #define STDDLL_IS_LEGAL(l) ((l)->end_node != NULL && (l)->vsize != 0) #define STDDLL_IT_IS_LEGAL(l, it) ((it)->end_node == (l)->end_node && (it)->vsize == (l)->vsize) #define STDDLL_IT_IS_LEGAL2(it) ((it)->node != NULL && (it)->end_node != NULL && (it)->vsize != 0) @@ -863,3 +866,7 @@ return it; } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stderror.c =================================================================== --- vendor/stdutil/current/src/stderror.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stderror.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -28,132 +27,67 @@ #include <stdutil/stddefines.h> #include <stdutil/stderror.h> -/************************************************************************************************ - * stderr_doit: Print a message to stderr and flush it. If errnoflag - * is non-zero, also print error msg from errno. Return # of - * characters written. - * - * NOTE: I'd prefer to use snprintf and vsnprintf but they aren't part of C89. - ***********************************************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif -STDINLINE static int stderr_doit(int errno_copy, const char *fmt, va_list ap) -{ - char buf[STDERR_MAX_ERR_MSG_LEN + 1]; - int ret1; - int ret2 = 0; - - ret1 = vsprintf(buf, fmt, ap); /* write the msg */ - ret1 = STDMAX(ret1, 0); /* zero out any error */ - buf[ret1] = 0; /* ensure termination */ - - if (errno_copy != 0) { - ret2 = sprintf(buf + ret1, ": %s", strerror(errno_copy)); /* write errno msg */ - ret2 = STDMAX(ret2, 0); /* zero out any error */ - buf[ret1 + ret2] = 0; /* ensure termination */ - } - - fprintf(stderr, "%s\r\n", buf); - fflush(stderr); - - return ret1 + ret2; -} - /************************************************************************************************ - * stderr_msg: Nonfatal error unrelated to a system call. Print a - * message and return. + * stdutil_output: Output stream used for all library error msgs. ***********************************************************************************************/ -int stderr_msg(const char *fmt, ...) -{ - int ret; - va_list ap; +FILE * stdutil_output = (FILE*) 0x1; /* magic number because stderr is not a constant */ - va_start(ap, fmt); - ret = stderr_doit(0, fmt, ap); - va_end(ap); - - return ret; -} - /************************************************************************************************ - * stderr_ret: Nonfatal error related to a system call. Print a - * message and return. + * stderr_output: Print a message to stdutil_output and flush it. If + * errno_copy is non-zero, also print error msg from strerror. Return + * # of characters written to output stream. + * + * NOTE: I'd prefer to use snprintf and vsnprintf but they aren't part of C89. ***********************************************************************************************/ -int stderr_ret(const char *fmt, ...) +STDINLINE int stderr_output(stderr_action act, int errno_copy, const char *fmt, ...) { - int ret; + char buf[STDERR_MAX_ERR_MSG_LEN + 1]; + int ret1 = 0; + int ret2 = 0; va_list ap; - va_start(ap, fmt); - ret = stderr_doit(errno, fmt, ap); - va_end(ap); + if (stdutil_output != NULL) { + va_start(ap, fmt); - return ret; -} + ret1 = vsprintf(buf, fmt, ap); /* write the msg */ + ret1 = STDMAX(ret1, 0); /* zero out any error */ + buf[ret1] = 0; /* ensure termination */ -/************************************************************************************************ - * stderr_quit: Fatal error unrelated to a system call. Print a - * message and terminate. - ***********************************************************************************************/ + if (errno_copy != 0) { + ret2 = sprintf(buf + ret1, ": %s", strerror(errno_copy)); /* errno msg */ + ret2 = STDMAX(ret2, 0); /* zero out */ + buf[ret1 + ret2] = 0; /* termination */ + } -void stderr_quit(const char *fmt, ...) -{ - va_list ap; + if (stdutil_output == (FILE*) 0x1) { + stdutil_output = stderr; + } - va_start(ap, fmt); - stderr_doit(0, fmt, ap); - va_end(ap); - exit(-1); -} + fprintf(stdutil_output, "%s\r\n", buf); + fflush(stdutil_output); -/************************************************************************************************ - * stderr_abort: Fatal error unrelated to a system call. Print a - * message and abort. - ***********************************************************************************************/ + ret1 += 2; /* +2 for \r\n */ + va_end(ap); + } -void stderr_abort(const char *fmt, ...) -{ - va_list ap; + if (act == STDERR_EXIT) { + exit(-1); + } - va_start(ap, fmt); - stderr_doit(0, fmt, ap); - va_end(ap); - abort(); -} + if (act == STDERR_ABORT) { + abort(); + } -/************************************************************************************************ - * stderr_sys: Fatal error related to a system call. Print a message - * and terminate. - ***********************************************************************************************/ - -void stderr_sys(const char *fmt, ...) -{ - int errno_cpy = errno; - va_list ap; - - va_start(ap, fmt); - stderr_doit(errno_cpy, fmt, ap); - va_end(ap); - exit(errno_cpy != 0 ? errno_cpy : -1); + return ret1 + ret2; } /************************************************************************************************ - * stderr_dump: Fatal error related to a system call. Print a message - * and abort. - ***********************************************************************************************/ - -void stderr_dump(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - stderr_doit(errno, fmt, ap); - va_end(ap); - abort(); -} - -/************************************************************************************************ * 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 Code (system @@ -209,3 +143,7 @@ return ret; } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stdfd.c =================================================================== --- vendor/stdutil/current/src/stdfd.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdfd.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -27,6 +26,10 @@ #include <stdutil/stderror.h> #include <stdutil/stdfd.h> +#ifdef __cplusplus +extern "C" { +#endif + #if defined(_WIN32) # include <io.h> # include <sys/locking.h> @@ -195,7 +198,7 @@ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0); - if (stdfd_flush(fd) != 0 || STDFSYNC(fd->fd) != 0) { + if (fflush(fd->stream) != 0 || STDFSYNC(fd->fd) != 0) { ret = errno; STDSAFETY_CHECK(ret != STDESUCCESS); } @@ -278,26 +281,34 @@ ***********************************************************************************************/ STDINLINE stdcode stdfd_trylock(stdfd *fd) +#if defined(_WIN32) { stdcode ret = STDESUCCESS; STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0); -#if defined(_WIN32) if (_locking(fd->fd, _LK_NBLCK, 1) != 0) { + ret = errno; + STDSAFETY_CHECK(ret != STDESUCCESS); + } + + return ret; +} #else +{ struct flock lock = { 0 }; + stdcode ret = STDESUCCESS; lock.l_type = F_WRLCK; if (fcntl(fd->fd, F_SETLK, &lock) != 0) { -#endif ret = errno; - STDSAFETY_CHECK(ret != STDESUCCESS); + STDSAFETY_CHECK(ret != STDESUCCESS); } return ret; } +#endif /************************************************************************************************ * stdfd_unlock: Release an advisory lock on a file descriptor's @@ -305,26 +316,34 @@ ***********************************************************************************************/ STDINLINE stdcode stdfd_unlock(stdfd *fd) +#if defined(_WIN32) { stdcode ret = STDESUCCESS; STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0); -#if defined(_WIN32) if (_locking(fd->fd, _LK_UNLCK, 1) != 0) { + ret = errno; + STDSAFETY_CHECK(ret != STDESUCCESS); + } + + return ret; +} #else +{ struct flock lock = { 0 }; + stdcode ret = STDESUCCESS; lock.l_type = F_UNLCK; - + if (fcntl(fd->fd, F_SETLK, &lock) != 0) { -#endif ret = errno; STDSAFETY_CHECK(ret != STDESUCCESS); - } + } return ret; -} + } +#endif /************************************************************************************************ * stdfile_unlink: Erase a file. @@ -341,3 +360,7 @@ return ret; } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stdhash.c =================================================================== --- vendor/stdutil/current/src/stdhash.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdhash.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -27,6 +26,10 @@ #include <stdutil/stderror.h> #include <stdutil/stdhash.h> +#ifdef __cplusplus +extern "C" { +#endif + /* stdhash is a table based implementation of a dictionary data structure. In particular, it is an open-address, double hashing hashtable (ref: Sedgewick: Algorithms in C, 3rd Ed.) that maps @@ -1390,3 +1393,7 @@ return it; } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stdit.c =================================================================== --- vendor/stdutil/current/src/stdit.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdit.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -28,6 +27,10 @@ #include <stdutil/stdhash.h> #include <stdutil/stdskl.h> +#ifdef __cplusplus +extern "C" { +#endif + /************************************************************************************************ * stdit_get_type: Get the functional type of an iterator. ***********************************************************************************************/ @@ -53,7 +56,7 @@ break; default: - ret = 0; + ret = (stdit_type) 0; STDEXCEPTION(uninitialized or corrupted iterator); break; } @@ -628,3 +631,7 @@ return it; } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stdskl.c =================================================================== --- vendor/stdutil/current/src/stdskl.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdskl.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -28,6 +27,10 @@ #include <stdutil/stdtime.h> #include <stdutil/stdskl.h> +#ifdef __cplusplus +extern "C" { +#endif + /* 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 @@ -61,6 +64,12 @@ /************************************************************************************************ * stdskl_low_create_node: Create a node to be inserted into 'l.' + * + * For random height generation, a node is promoted to a higher height + * w/ 25% chance. The optimum promotion chance for a skiplist is + * somewhere between 28% and 37% depending on the analysis used. 25% + * gives nearly optimal performance while using less memory and not + * requiring excessive random bit generation. ***********************************************************************************************/ STDINLINE static stdskl_node *stdskl_low_create_node(stdskl *l, stdint8 height, const void *key, const void *val) @@ -75,17 +84,16 @@ if (height == -1) { /* height generation requested */ stdbool keep_going = STDTRUE; - for (; keep_going && height < STDSKL_MAX_HEIGHT; ++height) { /* count how many random "on" bits we get in a row */ + for (; keep_going && height < STDSKL_MAX_HEIGHT; ++height) { /* loop while random height increases */ if (l->bits_left == 0) { /* out of random bits */ l->rand_bits = stdrand32(l->seed); /* generate 32 new ones */ l->bits_left = 32; } - keep_going = ((l->rand_bits & 0x1) == 0x1); /* break loop on a "off" bit */ - - --l->bits_left; /* remove used bit */ - l->rand_bits >>= 1; + keep_going = ((l->rand_bits & 0x3) == 0x3); /* continue loop w/ 25% chance */ + l->bits_left -= 2; /* remove used bits */ + l->rand_bits >>= 2; } } @@ -101,8 +109,6 @@ 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; @@ -1180,3 +1186,7 @@ return it; } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stdthread.c =================================================================== --- vendor/stdutil/current/src/stdthread.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdthread.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -36,6 +35,10 @@ # include <stdutil/stderror.h> # include <stdutil/stdthread.h> +#ifdef __cplusplus +extern "C" { +#endif + /************************************************************************************************ * stdthread_spawn: Create a new thread and start its execution. ***********************************************************************************************/ @@ -49,6 +52,7 @@ if ((thr = (HANDLE) _beginthreadex(NULL, 0, (unsigned(STDTHREAD_FCN*)(void*)) thr_fcn, fcn_arg, 0, &tid)) == NULL) { ret = errno; + STDSAFETY_CHECK(ret != STDESUCCESS); goto stdthread_spawn_end; } @@ -88,6 +92,7 @@ if (CloseHandle(thr) == 0) { ret = (stdcode) GetLastError(); + STDSAFETY_CHECK(ret != STDESUCCESS); } return ret; @@ -135,6 +140,7 @@ stdthread_join_fail: ret = (stdcode) GetLastError(); + STDSAFETY_CHECK(ret != STDESUCCESS); stdthread_join_end: return ret; @@ -314,7 +320,7 @@ woke_one = STDFALSE; - for (loop_cnt = 20; loop_cnt != 0; --loop_cnt) { /* don't try to wake sleeper more than a constant # of times */ + for (loop_cnt = 10; loop_cnt != 0; --loop_cnt) { /* don't try to wake sleeper more than a constant # of times */ err = ResumeThread(sleeper); if (err == 1) { @@ -326,6 +332,7 @@ } else if (err == (DWORD) -1) { /* error */ ret = (stdcode) GetLastError(); + STDSAFETY_CHECK(ret != STDESUCCESS); break; } else if (err > MAXIMUM_SUSPEND_COUNT || (err > loop_cnt && inf_loop)) { @@ -543,7 +550,7 @@ 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(); @@ -573,6 +580,7 @@ stdmutex_fast_cond_wait_malloc: CloseHandle(dup_handle); + STDSAFETY_CHECK(ret != STDESUCCESS); stdmutex_fast_cond_wait_end: if (reacquire) { @@ -1181,6 +1189,10 @@ # endif #endif +#ifdef __cplusplus +} +#endif + #else int stdthread_trnsl_dummy; /* avoids empty translation unit error #if !defined(_REENTRANT) */ #endif Modified: vendor/stdutil/current/src/stdtime.c =================================================================== --- vendor/stdutil/current/src/stdtime.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdtime.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -32,6 +31,10 @@ #include <stdutil/stderror.h> #include <stdutil/stdtime.h> +#ifdef __cplusplus +extern "C" { +#endif + /* stdtime: sec == STDINT64_MIN -> nano == 0 sec < 0 -> -STD1BILLION < nano <= 0 sec == 0 -> -STD1BILLION < nano < STD1BILLION @@ -234,7 +237,8 @@ } /************************************************************************************************ - * stdsleep: Sleep for a period of time. + * stdsleep: Sleep for a period of time. On error, remndr will be + * filled if non-NULL. ***********************************************************************************************/ STDINLINE stdcode stdsleep(stdtime delta, stdtime *remndr) @@ -324,3 +328,7 @@ return ret; } + +#ifdef __cplusplus +} +#endif Modified: vendor/stdutil/current/src/stdutil/private/stdarch.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdarch.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stdarch.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,9 +1,7 @@ -/* src/stdutil/private/stdarch.h. Generated by configure. */ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -24,136 +22,10 @@ #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 -#ifdef __cplusplus -extern "C" { -#endif - -/* the following defines are filled in by the configure script */ - -#define SIZEOF_CHAR 1 -#define SIZEOF_SHORT 2 -#define SIZEOF_INT 4 -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_SIZE_T 4 -#define SIZEOF_VOID_P 4 - -/* STDARCH_MAX_BYTE_ALIGNMENT must be a power of 2 (e.g. - 1, 2, 4, 8, - etc.) and must be the most stringent byte alignment that your - architecture requires for any basic type; 4 should be good enough - for any 32 bit or smaller architectures, 8 should be good enough - for any 64 bit or smaller architectures, etc. -*/ - -#define STDARCH_MAX_BYTE_ALIGNMENT 4 - -/* check if NULL is represented as all zero in memory for "all" types of pointers */ - -#define STDARCH_NULL_IS_ZERO 1 - -/* endian byte reordering mapping */ - -#define STDENDIAN16_SWAP 1 - -#define STDENDIAN32_NET0_FROM_HOST 3 -#define STDENDIAN32_NET1_FROM_HOST 2 -#define STDENDIAN32_NET2_FROM_HOST 1 -#define STDENDIAN32_NET3_FROM_HOST 0 - -#define STDENDIAN32_HOST0_FROM_NET 3 -#define STDENDIAN32_HOST1_FROM_NET 2 -#define STDENDIAN32_HOST2_FROM_NET 1 -#define STDENDIAN32_HOST3_FROM_NET 0 - -#define STDENDIAN64_NET0_FROM_HOST 7 -#define STDENDIAN64_NET1_FROM_HOST 6 -#define STDENDIAN64_NET2_FROM_HOST 5 -#define STDENDIAN64_NET3_FROM_HOST 4 -#define STDENDIAN64_NET4_FROM_HOST 3 -#define STDENDIAN64_NET5_FROM_HOST 2 -#define STDENDIAN64_NET6_FROM_HOST 1 -#define STDENDIAN64_NET7_FROM_HOST 0 - -#define STDENDIAN64_HOST0_FROM_NET 7 -#define STDENDIAN64_HOST1_FROM_NET 6 -#define STDENDIAN64_HOST2_FROM_NET 5 -#define STDENDIAN64_HOST3_FROM_NET 4 -#define STDENDIAN64_HOST4_FROM_NET 3 -#define STDENDIAN64_HOST5_FROM_NET 2 -#define STDENDIAN64_HOST6_FROM_NET 1 -#define STDENDIAN64_HOST7_FROM_NET 0 - -/* do architecture specific integer typedefs 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 stdarch_int32; -typedef unsigned int stdarch_uint32; - -#elif (SIZEOF_LONG == 4) - -typedef long stdarch_int32; -typedef unsigned long stdarch_uint32; - +#ifdef _WIN32 +# include <stdutil/private/stdarch_wintel32.h> #else -# error No 4 byte integer type found! +# include <stdutil/private/stdarch_autoconf.h> #endif -/* figure out which type is 8 bytes long */ - -#if (SIZEOF_LONG == 8) - -typedef long stdarch_int64; -typedef unsigned long stdarch_uint64; - -#elif defined(_MSC_VER) - -typedef __int64 stdarch_int64; -typedef unsigned __int64 stdarch_uint64; - -#elif (SIZEOF_LONG_LONG == 8) - -typedef long long stdarch_int64; -typedef unsigned long long stdarch_uint64; - -#else -# error No 8 byte integeral type found! #endif - -/* figure out which type is the same size as size_t */ - -#if (SIZEOF_SIZE_T == 2) - -typedef short stdarch_ssize; - -#elif (SIZEOF_SIZE_T == 4) - -typedef stdarch_int32 stdarch_ssize; - -#elif (SIZEOF_SIZE_T == 8) - -typedef stdarch_int64 stdarch_ssize; - -#else -# error No integral type of same size as size_t! -#endif - -#ifdef __cplusplus -} -#endif - -#endif Deleted: vendor/stdutil/current/src/stdutil/private/stdarch.h.in =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdarch.h.in 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stdarch.h.in 2006-11-19 15:17:12 UTC (rev 371) @@ -1,158 +0,0 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University - * All rights reserved. - * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. - * You may not use this file except in compliance with the License. The - * specific language governing the rights and limitations of the License - * can be found in the file ``STDUTIL_LICENSE'' found in this - * distribution. - * - * Software distributed under the License is distributed on an AS IS - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. - * - * The Original Software is: - * The Stdutil Library - * - * Contributors: - * Creator - John Lane Schultz ([email protected]) - * The Center for Networking and Distributed Systems - * (CNDS - http://www.cnds.jhu.edu) - */ - -#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 - -#ifdef __cplusplus -extern "C" { -#endif - -/* the following defines are filled in by the configure script */ - -#undef SIZEOF_CHAR -#undef SIZEOF_SHORT -#undef SIZEOF_INT -#undef SIZEOF_LONG -#undef SIZEOF_LONG_LONG -#undef SIZEOF_SIZE_T -#undef SIZEOF_VOID_P - -/* STDARCH_MAX_BYTE_ALIGNMENT must be a power of 2 (e.g. - 1, 2, 4, 8, - etc.) and must be the most stringent byte alignment that your - architecture requires for any basic type; 4 should be good enough - for any 32 bit or smaller architectures, 8 should be good enough - for any 64 bit or smaller architectures, etc. -*/ - -#undef STDARCH_MAX_BYTE_ALIGNMENT - -/* check if NULL is represented as all zero in memory for "all" types of pointers */ - -#undef STDARCH_NULL_IS_ZERO - -/* endian byte reordering mapping */ - -#undef STDENDIAN16_SWAP - -#undef STDENDIAN32_NET0_FROM_HOST -#undef STDENDIAN32_NET1_FROM_HOST -#undef STDENDIAN32_NET2_FROM_HOST -#undef STDENDIAN32_NET3_FROM_HOST - -#undef STDENDIAN32_HOST0_FROM_NET -#undef STDENDIAN32_HOST1_FROM_NET -#undef STDENDIAN32_HOST2_FROM_NET -#undef STDENDIAN32_HOST3_FROM_NET - -#undef STDENDIAN64_NET0_FROM_HOST -#undef STDENDIAN64_NET1_FROM_HOST -#undef STDENDIAN64_NET2_FROM_HOST -#undef STDENDIAN64_NET3_FROM_HOST -#undef STDENDIAN64_NET4_FROM_HOST -#undef STDENDIAN64_NET5_FROM_HOST -#undef STDENDIAN64_NET6_FROM_HOST -#undef STDENDIAN64_NET7_FROM_HOST - -#undef STDENDIAN64_HOST0_FROM_NET -#undef STDENDIAN64_HOST1_FROM_NET -#undef STDENDIAN64_HOST2_FROM_NET -#undef STDENDIAN64_HOST3_FROM_NET -#undef STDENDIAN64_HOST4_FROM_NET -#undef STDENDIAN64_HOST5_FROM_NET -#undef STDENDIAN64_HOST6_FROM_NET -#undef STDENDIAN64_HOST7_FROM_NET - -/* do architecture specific integer typedefs 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 stdarch_int32; -typedef unsigned int stdarch_uint32; - -#elif (SIZEOF_LONG == 4) - -typedef long stdarch_int32; -typedef unsigned long stdarch_uint32; - -#else -# error No 4 byte integer type found! -#endif - -/* figure out which type is 8 bytes long */ - -#if (SIZEOF_LONG == 8) - -typedef long stdarch_int64; -typedef unsigned long stdarch_uint64; - -#elif defined(_MSC_VER) - -typedef __int64 stdarch_int64; -typedef unsigned __int64 stdarch_uint64; - -#elif (SIZEOF_LONG_LONG == 8) - -typedef long long stdarch_int64; -typedef unsigned long long stdarch_uint64; - -#else -# error No 8 byte integeral type found! -#endif - -/* figure out which type is the same size as size_t */ - -#if (SIZEOF_SIZE_T == 2) - -typedef short stdarch_ssize; - -#elif (SIZEOF_SIZE_T == 4) - -typedef stdarch_int32 stdarch_ssize; - -#elif (SIZEOF_SIZE_T == 8) - -typedef stdarch_int64 stdarch_ssize; - -#else -# error No integral type of same size as size_t! -#endif - -#ifdef __cplusplus -} -#endif - -#endif Added: vendor/stdutil/current/src/stdutil/private/stdarch_autoconf.h.in =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdarch_autoconf.h.in (rev 0) +++ vendor/stdutil/current/src/stdutil/private/stdarch_autoconf.h.in 2006-11-19 15:17:12 UTC (rev 371) @@ -0,0 +1,157 @@ +/* Copyright (c) 2000-2006, The Johns Hopkins University + * All rights reserved. + * + * The contents of this file are subject to a license (the ``License''). + * You may not use this file except in compliance with the License. The + * specific language governing the rights and limitations of the License + * can be found in the file ``STDUTIL_LICENSE'' found in this + * distribution. + * + * Software distributed under the License is distributed on an AS IS + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. + * + * The Original Software is: + * The Stdutil Library + * + * Contributors: + * Creator - John Lane Schultz ([email protected]) + * The Center for Networking and Distributed Systems + * (CNDS - http://www.cnds.jhu.edu) + */ + +#ifndef stdarch_autoconf_h_2006_03_13_17_44_12_jschultz_at_cnds_jhu_edu +#define stdarch_autoconf_h_2006_03_13_17_44_12_jschultz_at_cnds_jhu_edu + +#ifdef __cplusplus +extern "C" { +#endif + +/* the following defines are filled in by the configure script */ + +#undef SIZEOF_CHAR +#undef SIZEOF_SHORT +#undef SIZEOF_INT +#undef SIZEOF_LONG +#undef SIZEOF_LONG_LONG +#undef SIZEOF_SIZE_T +#undef SIZEOF_VOID_P + +/* STDARCH_MAX_BYTE_ALIGNMENT must be a power of 2 (e.g. - 1, 2, 4, 8, + etc.) and must be the most stringent byte alignment that your + architecture requires for any basic type; 4 should be good enough + for any 32 bit or smaller architectures, 8 should be good enough + for any 64 bit or smaller architectures, etc. +*/ + +#undef STDARCH_MAX_BYTE_ALIGNMENT + +/* check if NULL is represented as all zero in memory for "all" types of pointers */ + +#undef STDARCH_NULL_IS_ZERO + +/* endian byte reordering mapping */ + +#undef STDENDIAN16_SWAP + +#undef STDENDIAN32_NET0_FROM_HOST +#undef STDENDIAN32_NET1_FROM_HOST +#undef STDENDIAN32_NET2_FROM_HOST +#undef STDENDIAN32_NET3_FROM_HOST + +#undef STDENDIAN32_HOST0_FROM_NET +#undef STDENDIAN32_HOST1_FROM_NET +#undef STDENDIAN32_HOST2_FROM_NET +#undef STDENDIAN32_HOST3_FROM_NET + +#undef STDENDIAN64_NET0_FROM_HOST +#undef STDENDIAN64_NET1_FROM_HOST +#undef STDENDIAN64_NET2_FROM_HOST +#undef STDENDIAN64_NET3_FROM_HOST +#undef STDENDIAN64_NET4_FROM_HOST +#undef STDENDIAN64_NET5_FROM_HOST +#undef STDENDIAN64_NET6_FROM_HOST +#undef STDENDIAN64_NET7_FROM_HOST + +#undef STDENDIAN64_HOST0_FROM_NET +#undef STDENDIAN64_HOST1_FROM_NET +#undef STDENDIAN64_HOST2_FROM_NET +#undef STDENDIAN64_HOST3_FROM_NET +#undef STDENDIAN64_HOST4_FROM_NET +#undef STDENDIAN64_HOST5_FROM_NET +#undef STDENDIAN64_HOST6_FROM_NET +#undef STDENDIAN64_HOST7_FROM_NET + +/* do architecture specific integer typedefs 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 stdarch_int32; +typedef unsigned int stdarch_uint32; + +#elif (SIZEOF_LONG == 4) + +typedef long stdarch_int32; +typedef unsigned long stdarch_uint32; + +#else +# error No 4 byte integer type found! +#endif + +/* figure out which type is 8 bytes long */ + +#if (SIZEOF_LONG == 8) + +typedef long stdarch_int64; +typedef unsigned long stdarch_uint64; + +#elif defined(_MSC_VER) + +typedef __int64 stdarch_int64; +typedef unsigned __int64 stdarch_uint64; + +#elif (SIZEOF_LONG_LONG == 8) + +typedef long long stdarch_int64; +typedef unsigned long long stdarch_uint64; + +#else +# error No 8 byte integeral type found! +#endif + +/* figure out which type is the same size as size_t */ + +#if (SIZEOF_SIZE_T == 2) + +typedef short stdarch_ssize; + +#elif (SIZEOF_SIZE_T == 4) + +typedef stdarch_int32 stdarch_ssize; + +#elif (SIZEOF_SIZE_T == 8) + +typedef stdarch_int64 stdarch_ssize; + +#else +# error No integral type of same size as size_t! +#endif + +#ifdef __cplusplus +} +#endif + +#endif Added: vendor/stdutil/current/src/stdutil/private/stdarch_wintel32.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdarch_wintel32.h (rev 0) +++ vendor/stdutil/current/src/stdutil/private/stdarch_wintel32.h 2006-11-19 15:17:12 UTC (rev 371) @@ -0,0 +1,157 @@ +/* Copyright (c) 2000-2006, The Johns Hopkins University + * All rights reserved. + * + * The contents of this file are subject to a license (the ``License''). + * You may not use this file except in compliance with the License. The + * specific language governing the rights and limitations of the License + * can be found in the file ``STDUTIL_LICENSE'' found in this + * distribution. + * + * Software distributed under the License is distributed on an AS IS + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. + * + * The Original Software is: + * The Stdutil Library + * + * Contributors: + * Creator - John Lane Schultz ([email protected]) + * The Center for Networking and Distributed Systems + * (CNDS - http://www.cnds.jhu.edu) + */ + +#ifndef stdarch_wintel32_h_2006_03_13_17_43_22_jschultz_at_cnds_jhu_edu +#define stdarch_wintel32_h_2006_03_13_17_43_22_jschultz_at_cnds_jhu_edu + +#ifdef __cplusplus +extern "C" { +#endif + +/* the following defines are filled in by the configure script */ + +#define SIZEOF_CHAR 1 +#define SIZEOF_SHORT 2 +#define SIZEOF_INT 4 +#define SIZEOF_LONG 4 +#undef SIZEOF_LONG_LONG +#define SIZEOF_SIZE_T 4 +#define SIZEOF_VOID_P 4 + +/* STDARCH_MAX_BYTE_ALIGNMENT must be a power of 2 (e.g. - 1, 2, 4, 8, + etc.) and must be the most stringent byte alignment that your + architecture requires for any basic type; 4 should be good enough + for any 32 bit or smaller architectures, 8 should be good enough + for any 64 bit or smaller architectures, etc. +*/ + +#define STDARCH_MAX_BYTE_ALIGNMENT 4 + +/* check if NULL is represented as all zero in memory for "all" types of pointers */ + +#define STDARCH_NULL_IS_ZERO 1 + +/* endian byte reordering mapping */ + +#define STDENDIAN16_SWAP 1 + +#define STDENDIAN32_NET0_FROM_HOST 3 +#define STDENDIAN32_NET1_FROM_HOST 2 +#define STDENDIAN32_NET2_FROM_HOST 1 +#define STDENDIAN32_NET3_FROM_HOST 0 + +#define STDENDIAN32_HOST0_FROM_NET 3 +#define STDENDIAN32_HOST1_FROM_NET 2 +#define STDENDIAN32_HOST2_FROM_NET 1 +#define STDENDIAN32_HOST3_FROM_NET 0 + +#define STDENDIAN64_NET0_FROM_HOST 7 +#define STDENDIAN64_NET1_FROM_HOST 6 +#define STDENDIAN64_NET2_FROM_HOST 5 +#define STDENDIAN64_NET3_FROM_HOST 4 +#define STDENDIAN64_NET4_FROM_HOST 3 +#define STDENDIAN64_NET5_FROM_HOST 2 +#define STDENDIAN64_NET6_FROM_HOST 1 +#define STDENDIAN64_NET7_FROM_HOST 0 + +#define STDENDIAN64_HOST0_FROM_NET 7 +#define STDENDIAN64_HOST1_FROM_NET 6 +#define STDENDIAN64_HOST2_FROM_NET 5 +#define STDENDIAN64_HOST3_FROM_NET 4 +#define STDENDIAN64_HOST4_FROM_NET 3 +#define STDENDIAN64_HOST5_FROM_NET 2 +#define STDENDIAN64_HOST6_FROM_NET 1 +#define STDENDIAN64_HOST7_FROM_NET 0 + +/* do architecture specific integer typedefs 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 stdarch_int32; +typedef unsigned int stdarch_uint32; + +#elif (SIZEOF_LONG == 4) + +typedef long stdarch_int32; +typedef unsigned long stdarch_uint32; + +#else +# error No 4 byte integer type found! +#endif + +/* figure out which type is 8 bytes long */ + +#if (SIZEOF_LONG == 8) + +typedef long stdarch_int64; +typedef unsigned long stdarch_uint64; + +#elif defined(_MSC_VER) + +typedef __int64 stdarch_int64; +typedef unsigned __int64 stdarch_uint64; + +#elif (SIZEOF_LONG_LONG == 8) + +typedef long long stdarch_int64; +typedef unsigned long long stdarch_uint64; + +#else +# error No 8 byte integeral type found! +#endif + +/* figure out which type is the same size as size_t */ + +#if (SIZEOF_SIZE_T == 2) + +typedef short stdarch_ssize; + +#elif (SIZEOF_SIZE_T == 4) + +typedef stdarch_int32 stdarch_ssize; + +#elif (SIZEOF_SIZE_T == 8) + +typedef stdarch_int64 stdarch_ssize; + +#else +# error No integral type of same size as size_t! +#endif + +#ifdef __cplusplus +} +#endif + +#endif Modified: vendor/stdutil/current/src/stdutil/private/stdarr_p.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdarr_p.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stdarr_p.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -29,7 +28,7 @@ begin - address of the lowest byte of the array's alloc'ed memory, NULL if none alloc'ed end - address of the first byte past the last value stored in the array, same as begin if empty - size - number of values this array is storing + size - number of values this array is storing [(end - begin) / vsize] cap - number of values that can legally fit in alloc'ed memory vsize - size, in bytes, of the type of values this array is storing opts - user flags affecting default operation Modified: vendor/stdutil/current/src/stdutil/private/stdcarr_p.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdcarr_p.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stdcarr_p.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -27,7 +26,7 @@ or vector. Stores element by value, contiguously in memory modulo the size of the array. Always maintains at least one empty element in a non-empty array to act as a - sentinel position and to remove the amibiguous of case + sentinel position and to remove the amibiguous case of when begin == end -- Is the array full or empty? In particular, this allows for the test begin <= end ? (data doesn't wrap around) : (data wraps around) Modified: vendor/stdutil/current/src/stdutil/private/stddll_p.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stddll_p.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stddll_p.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/private/stdhash_p.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdhash_p.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stdhash_p.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/private/stdit_p.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdit_p.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stdit_p.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/private/stdskl_p.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdskl_p.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stdskl_p.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/private/stdthread_p.h =================================================================== --- vendor/stdutil/current/src/stdutil/private/stdthread_p.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/private/stdthread_p.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stdarr.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdarr.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdarr.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stdcarr.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdcarr.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdcarr.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stddefines.h =================================================================== --- vendor/stdutil/current/src/stdutil/stddefines.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stddefines.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stddll.h =================================================================== --- vendor/stdutil/current/src/stdutil/stddll.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stddll.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stderror.h =================================================================== --- vendor/stdutil/current/src/stdutil/stderror.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stderror.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -32,25 +31,33 @@ extern "C" { #endif +/* NOTE: redefining this limit only has an effect at compile time of the stdutil library */ + #ifndef STDERR_MAX_ERR_MSG_LEN -/* NOTE: redefining this variable only has an effect at compile time of the stdutil library */ # define STDERR_MAX_ERR_MSG_LEN 1024 #endif +/* stderr output stream (can be set to NULL to squelch all stdutil output) */ + +extern FILE * stdutil_output /* = stderr */; + /* stderr error routines */ -int stderr_msg(const char *fmt, ...); -int stderr_ret(const char *fmt, ...); -void stderr_quit(const char *fmt, ...); -void stderr_abort(const char *fmt, ...); -void stderr_sys(const char *fmt, ...); -void stderr_dump(const char *fmt, ...); +typedef enum +{ + STDERR_RETURN, + STDERR_EXIT, + STDERR_ABORT +} stderr_action; + +int stderr_output(stderr_action act, int errno_cpy, const char *fmt, ...); + STDINLINE const char *stderr_strerr(stdcode code); /* error macros */ -#define STDEXCEPTION(x) stderr_abort("STDEXCEPTION: File: %s; Line: %d: %s", __FILE__, __LINE__, #x) +#define STDEXCEPTION(x) stderr_output(STDERR_ABORT, 0, "STDEXCEPTION: File: %s; Line: %d: %s", __FILE__, __LINE__, #x) #if defined(STDSAFETY_CHECKS) # define STDSAFETY_CHECK(x) { if (!(x)) { STDEXCEPTION(safety check (x) failed); } } Modified: vendor/stdutil/current/src/stdutil/stdfd.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdfd.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdfd.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stdhash.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdhash.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdhash.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stdit.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdit.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdit.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stdskl.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdskl.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdskl.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stdthread.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdthread.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdthread.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stdtime.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdtime.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdtime.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil/stdutil.h =================================================================== --- vendor/stdutil/current/src/stdutil/stdutil.h 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil/stdutil.h 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this Modified: vendor/stdutil/current/src/stdutil.c =================================================================== --- vendor/stdutil/current/src/stdutil.c 2006-11-17 19:31:06 UTC (rev 370) +++ vendor/stdutil/current/src/stdutil.c 2006-11-19 15:17:12 UTC (rev 371) @@ -1,8 +1,7 @@ -/* Copyright (c) 2000-2005, The Johns Hopkins University +/* Copyright (c) 2000-2006, The Johns Hopkins University * All rights reserved. * - * The contents of this file are subject to a license (the ``License'') - * that is the exact equivalent of the BSD license as of July 23, 1999. + * The contents of this file are subject to a license (the ``License''). * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this @@ -29,6 +28,10 @@ #include <stdutil/stdtime.h> #include <stdutil/stdutil.h> +#ifdef __cplusplus +extern "C" { +#endif + /************************************************************************************************ * stdstrcpy: Like C's strcpy, but returns strlen(dst) instead. ***********************************************************************************************/ @@ -159,7 +162,7 @@ * span several buffers. Preferably, but not required, tot_len would * 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 + * consistently use the same arbitrary constant (e.g. - 0x1) when * computing the hcode for those objects. ***********************************************************************************************/ @@ -216,7 +219,7 @@ defined (__BORLANDC__) || defined (__TURBOC__)) # 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) ( ((stduint32) *((const stduint8 *)(d) + 1) << 8) | *(const stduint32 *)(d) ) #endif STDINLINE stduint32 stdhcode_sfh(const void * buf, stdsize buf_len) @@ -263,9 +266,10 @@ ret ^= ret << 3; ret += ret >> 5; - ret ^= ret << 2; - ret += ret >> 15; - ret ^= ret << 10; + ret ^= ret << 4; + ret += ret >> 17; + ret ^= ret << 25; + ret += ret >> 6; return ret; } @@ -275,7 +279,7 @@ * span several buffers. Preferably, but not required, tot_len would * 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 + * consistently use the same arbitrary constant (e.g. - 0x1) when * computing the hcode for those objects. * * NOTE: The incremental versions of sfh depend on how you partition @@ -351,10 +355,11 @@ ret ^= ret << 3; ret += ret >> 5; - ret ^= ret << 2; - ret += ret >> 15; - ret ^= ret << 10; - + ret ^= ret << 4; + ret += ret >> 17; + ret ^= ret << 25; + ret += ret >> 6; + *hsh = ret; } @@ -1047,3 +1052,7 @@ return up_pow2; /* up_pow2 in range [1.5x, 3x) */ } + +#ifdef __cplusplus +} +#endif