[Spread-cvs] commit: r423 - in trunk/stdutil: . src src/stdutil src/stdutil/private
jonathan at spread.org
jonathan at spread.org
Thu Jun 4 17:22:26 EDT 2009
Author: jonathan
Date: 2009-06-04 17:22:26 -0400 (Thu, 04 Jun 2009)
New Revision: 423
Added:
trunk/stdutil/CHANGELOG
Modified:
trunk/stdutil/Makefile
trunk/stdutil/README
trunk/stdutil/STDUTIL_LICENSE
trunk/stdutil/configure
trunk/stdutil/configure.in
trunk/stdutil/src/Makefile.in
trunk/stdutil/src/stdarr.c
trunk/stdutil/src/stdcarr.c
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/stdtime.c
trunk/stdutil/src/stdutil.c
trunk/stdutil/src/stdutil/private/stdarch.h
trunk/stdutil/src/stdutil/private/stdarch_autoconf.h.in
trunk/stdutil/src/stdutil/private/stdarch_wintel32.h
trunk/stdutil/src/stdutil/private/stdarr_p.h
trunk/stdutil/src/stdutil/private/stdcarr_p.h
trunk/stdutil/src/stdutil/private/stddll_p.h
trunk/stdutil/src/stdutil/private/stdhash_p.h
trunk/stdutil/src/stdutil/private/stdit_p.h
trunk/stdutil/src/stdutil/private/stdskl_p.h
trunk/stdutil/src/stdutil/private/stdthread_p.h
trunk/stdutil/src/stdutil/stdarr.h
trunk/stdutil/src/stdutil/stdcarr.h
trunk/stdutil/src/stdutil/stddefines.h
trunk/stdutil/src/stdutil/stddll.h
trunk/stdutil/src/stdutil/stderror.h
trunk/stdutil/src/stdutil/stdfd.h
trunk/stdutil/src/stdutil/stdhash.h
trunk/stdutil/src/stdutil/stdit.h
trunk/stdutil/src/stdutil/stdskl.h
trunk/stdutil/src/stdutil/stdthread.h
trunk/stdutil/src/stdutil/stdtime.h
trunk/stdutil/src/stdutil/stdutil.h
Log:
Merge Stdutil 1.1.0 release into Spread trunk
Copied: trunk/stdutil/CHANGELOG (from rev 422, vendor/stdutil/current/CHANGELOG)
===================================================================
--- trunk/stdutil/CHANGELOG (rev 0)
+++ trunk/stdutil/CHANGELOG 2009-06-04 21:22:26 UTC (rev 423)
@@ -0,0 +1,14 @@
+v1.1.0, May 2009
+
+Changed the build so that the functions in stdthread.h are always defined, but most will simply
+return error codes when not built in a reentrant manner. Added a "null mutex" that does nothing
+to allow user programs to always successfully call at least the mutex functions even in a
+non-reentrant build.
+
+v1.0.1, November 2007
+
+Fixed a few minor bugs.
+
+v1.0.0, November 2006
+
+First major release of StdUtil library.
Modified: trunk/stdutil/Makefile
===================================================================
--- trunk/stdutil/Makefile 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/Makefile 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,5 +1,5 @@
all:
- cd src; $(MAKE)
+ cd src; $(MAKE) all
clean:
rm -f *~ core*
Modified: trunk/stdutil/README
===================================================================
--- trunk/stdutil/README 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/README 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-This is the v1.0.0 (November 2006) distribution of the StdUtil library.
+This is the v1.1.0 (May 2009) distribution of the StdUtil library.
DESCRIPTION:
@@ -14,13 +14,15 @@
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
+documentation will also be available at:
+
http://www.cnds.jhu.edu/software/stdutil/docs
BUILDING:
StdUtil uses the standard configure/make process for building on unix
-type systems.
+type systems, although it builds in place and does not have a make install
+option.
PROBLEMS:
@@ -30,4 +32,4 @@
Enjoy,
John Schultz <jschultz at cnds.jhu.edu>
-November 2006
+May 2009
Modified: trunk/stdutil/STDUTIL_LICENSE
===================================================================
--- trunk/stdutil/STDUTIL_LICENSE 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/STDUTIL_LICENSE 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The Original Software is:
Modified: trunk/stdutil/configure
===================================================================
--- trunk/stdutil/configure 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/configure 2009-06-04 21:22:26 UTC (rev 423)
@@ -3496,14 +3496,14 @@
SHLDFLAGS="$SHLDFLAGS $LDFLAGS"
SHLIBS=$LIBS
DYNLIBEXT=dylib
- STANDARD_LIBS="\$(STATIC_THREADED_RELEASE_LIB) \$(SHARED_THREADED_RELEASE_LIB)"
+ STANDARD_LIBS="\$(STATIC_THREADED_DEBUG_LIB) \$(STATIC_THREADED_RELEASE_LIB) \$(SHARED_THREADED_DEBUG_LIB) \$(SHARED_THREADED_RELEASE_LIB)"
SHARED_LIBS="\$(SHARED_LIBS)"
;;
mips-sgi-irix*)
CC=cc
CFLAGS="-n32 -signed"
DYNLIBEXT=
- STANDARD_LIBS="\$(STATIC_THREADED_RELEASE_LIB)"
+ STANDARD_LIBS="\$(STATIC_THREADED_DEBUG_LIB) \$(STATIC_THREADED_RELEASE_LIB)"
SHARED_LIBS=
;;
*-*-*)
@@ -3514,7 +3514,7 @@
SHLDFLAGS="$SHLDFLAGS $LDFLAGS"
SHLIBS=$LIBS
DYNLIBEXT=so
- STANDARD_LIBS="\$(STATIC_THREADED_RELEASE_LIB) \$(SHARED_THREADED_RELEASE_LIB)"
+ STANDARD_LIBS="\$(STATIC_THREADED_DEBUG_LIB) \$(STATIC_THREADED_RELEASE_LIB) \$(SHARED_THREADED_DEBUG_LIB) \$(SHARED_THREADED_RELEASE_LIB)"
SHARED_LIBS="\$(SHARED_LIBS)"
;;
esac
Modified: trunk/stdutil/configure.in
===================================================================
--- trunk/stdutil/configure.in 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/configure.in 2009-06-04 21:22:26 UTC (rev 423)
@@ -57,14 +57,14 @@
SHLDFLAGS="$SHLDFLAGS $LDFLAGS"
SHLIBS=$LIBS
DYNLIBEXT=dylib
- STANDARD_LIBS="\$(STATIC_THREADED_RELEASE_LIB) \$(SHARED_THREADED_RELEASE_LIB)"
+ STANDARD_LIBS="\$(STATIC_THREADED_DEBUG_LIB) \$(STATIC_THREADED_RELEASE_LIB) \$(SHARED_THREADED_DEBUG_LIB) \$(SHARED_THREADED_RELEASE_LIB)"
SHARED_LIBS="\$(SHARED_LIBS)"
;;
mips-sgi-irix*)
CC=cc
CFLAGS="-n32 -signed"
DYNLIBEXT=
- STANDARD_LIBS="\$(STATIC_THREADED_RELEASE_LIB)"
+ STANDARD_LIBS="\$(STATIC_THREADED_DEBUG_LIB) \$(STATIC_THREADED_RELEASE_LIB)"
SHARED_LIBS=
;;
*-*-*)
@@ -75,7 +75,7 @@
SHLDFLAGS="$SHLDFLAGS $LDFLAGS"
SHLIBS=$LIBS
DYNLIBEXT=so
- STANDARD_LIBS="\$(STATIC_THREADED_RELEASE_LIB) \$(SHARED_THREADED_RELEASE_LIB)"
+ STANDARD_LIBS="\$(STATIC_THREADED_DEBUG_LIB) \$(STATIC_THREADED_RELEASE_LIB) \$(SHARED_THREADED_DEBUG_LIB) \$(SHARED_THREADED_RELEASE_LIB)"
SHARED_LIBS="\$(SHARED_LIBS)"
;;
esac
Modified: trunk/stdutil/src/Makefile.in
===================================================================
--- trunk/stdutil/src/Makefile.in 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/Makefile.in 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,7 +1,7 @@
.SUFFIXES: .do .to .tdo .lo .ldo .lto .ltdo
.PHONY: all standard libdir clean distclean uberclean
-LIBVERSION=1.0
+LIBVERSION=1.1
############################################ PROGRAMS #########################################
@@ -89,6 +89,7 @@
$(STATIC_THREADED_DEBUG_LIB): $(STATIC_THREADED_DEBUG_OBJS)
$(AR) rvs $@ $(STATIC_THREADED_DEBUG_OBJS)
+ $(SOFTLINK) -f $@ $(LIBDIR)/libstdutil-debug.a
$(SHARED_NOTHREAD_RELEASE_LIB): $(SHARED_NOTHREAD_RELEASE_OBJS)
$(SHLD) $(SHLDFLAGS) -o $@ $(SHARED_NOTHREAD_RELEASE_OBJS) $(SHLIBS)
@@ -102,9 +103,10 @@
$(SHARED_THREADED_DEBUG_LIB): $(SHARED_THREADED_DEBUG_OBJS)
$(SHLD) $(SHLDFLAGS) -o $@ $(SHARED_THREADED_DEBUG_OBJS) $(SHLIBS) $(THLIBS)
+ $(SOFTLINK) -f $@ $(LIBDIR)/libstdutil-debug. at DYNLIBEXT@
clean:
- rm -f *.o *.do *.to *.tdo *.lo *.ldo *.lto *.ltdo core* *~ $(ALLTARGETS) $(LIBDIR)/libstdutil.a $(LIBDIR)/libstdutil. at DYNLIBEXT@
+ rm -f *.o *.do *.to *.tdo *.lo *.ldo *.lto *.ltdo core* *~ stdutil/*~ stdutil/private/*~ $(ALLTARGETS) $(LIBDIR)/libstdutil.a $(LIBDIR)/libstdutil. at DYNLIBEXT@ $(LIBDIR)/libstdutil-debug.a $(LIBDIR)/libstdutil-debug. at DYNLIBEXT@
distclean: clean
rm -f Makefile stdutil/private/stdarch_autoconf.h
Modified: trunk/stdutil/src/stdarr.c
===================================================================
--- trunk/stdutil/src/stdarr.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdarr.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdcarr.c
===================================================================
--- trunk/stdutil/src/stdcarr.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdcarr.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stddll.c
===================================================================
--- trunk/stdutil/src/stddll.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stddll.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
@@ -216,8 +216,9 @@
{
stddll_node * curr = erase_end->prev;
stddll_node * prev;
+ stdsize ne = num_erase;
- while (num_erase-- != 0) {
+ while (ne-- != 0) {
STDBOUNDS_CHECK(curr != STDDLL_LEND(l)); /* check for an illegal erasure */
prev = curr;
curr = curr->prev;
Modified: trunk/stdutil/src/stderror.c
===================================================================
--- trunk/stdutil/src/stderror.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stderror.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdfd.c
===================================================================
--- trunk/stdutil/src/stdfd.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdfd.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,366 +1,366 @@
-/* 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 (jschultz at cnds.jhu.edu)
- * The Center for Networking and Distributed Systems
- * (CNDS - http://www.cnds.jhu.edu)
- */
-
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <stdutil/stderror.h>
-#include <stdutil/stdfd.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if defined(_WIN32)
-# include <io.h>
-# include <sys/locking.h>
-# define STDFILENO(s) _fileno(s)
-# define STDFSYNC(fd) _commit(fd)
-#else
-# include <unistd.h>
-# define STDFILENO(s) fileno(s)
-# define STDFSYNC(fd) fsync(fd)
-#endif
-
-/************************************************************************************************
- * stdfd_open: Open a file descriptor.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfd_open(stdfd *fd, const char *path, stdfd_access_type mode)
-{
- stdcode ret = STDESUCCESS;
- const char * fopen_mode;
-
- 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;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- stdfd_open_end:
- return ret;
-}
-
-/************************************************************************************************
- * stdfd_close: Close a file descriptor.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfd_close(stdfd *fd)
-{
- stdcode ret = STDESUCCESS;
-
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- if (fclose(fd->stream) != 0) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- fd->stream = NULL;
- fd->fd = -1;
-
- return ret;
-}
-
-/************************************************************************************************
- * stdfd_read: Read 'nmemb' entries of 'nsize' bytes each from a file
- * descriptor into 'ptr.'
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfd_read(stdfd *fd, void *ptr, stdsize nsize, stdsize nmemb, stdsize *num)
-{
- stdcode ret;
-
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- if ((*num = fread(ptr, nsize, nmemb, fd->stream)) == nmemb) {
- ret = STDESUCCESS;
-
- } else if (feof(fd->stream)) {
- ret = STDEOF;
-
- } else if (ferror(fd->stream)) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
-
- } else {
- ret = STDEINTR; /* wrong count but not EOF or error? alert user! */
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdfd_write: Write 'nmemb' entries of 'nsize' bytes each from 'ptr'
- * to a file descriptor.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfd_write(stdfd *fd, const void *ptr, stdsize nsize, stdsize nmemb, stdsize *num)
-{
- stdcode ret;
-
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- if ((*num = fwrite(ptr, nsize, nmemb, fd->stream)) == nmemb) {
- ret = STDESUCCESS;
-
- } else if (feof(fd->stream)) {
- ret = STDEOF;
-
- } else if (ferror(fd->stream)) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
-
- } else {
- ret = STDEINTR; /* wrong count but not EOF or error? alert user! */
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdfd_flush: Flush any user space data on a file descriptor to the OS.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfd_flush(stdfd *fd)
-{
- stdcode ret = STDESUCCESS;
-
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- if (fflush(fd->stream) != 0) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdfd_sync: Flush user space data to the OS and force the OS to
- * flush all data to disk.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfd_sync(stdfd *fd)
-{
- stdcode ret = STDESUCCESS;
-
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- if (fflush(fd->stream) != 0 || STDFSYNC(fd->fd) != 0) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdfd_seek: Move the read/write head position of a file descriptor.
- ***********************************************************************************************/
-
-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;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdfd_tell: Get the read/write head position of a file descriptor.
- ***********************************************************************************************/
-
-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;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdfd_eof: Return whether or not the EOF indicator on a file descriptor is set.
- ***********************************************************************************************/
-
-STDINLINE stdbool stdfd_eof(stdfd *fd)
-{
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- return (feof(fd->stream) != 0);
-}
-
-/************************************************************************************************
- * stdfd_err: Return whether or not an error indicator on a file descriptor is set.
- ***********************************************************************************************/
-
-STDINLINE stdbool stdfd_err(stdfd *fd)
-{
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- return (ferror(fd->stream) != 0);
-}
-
-/************************************************************************************************
- * stdfd_clr_err: Clear any error indicator on a file descriptor.
- ***********************************************************************************************/
-
-STDINLINE void stdfd_clr_err(stdfd *fd)
-{
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- clearerr(fd->stream);
-}
-
-/************************************************************************************************
- * stdfd_trylock: Try to acquire an advisory lock on a file
- * descriptor's underlying file.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfd_trylock(stdfd *fd)
-#if defined(_WIN32)
-{
- stdcode ret = STDESUCCESS;
-
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- 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) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- return ret;
-}
-#endif
-
-/************************************************************************************************
- * stdfd_unlock: Release an advisory lock on a file descriptor's
- * underlying file.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfd_unlock(stdfd *fd)
-#if defined(_WIN32)
-{
- stdcode ret = STDESUCCESS;
-
- STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-
- 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) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- return ret;
- }
-#endif
-
-/************************************************************************************************
- * stdfile_unlink: Erase a file.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdfile_unlink(const char *path)
-{
- stdcode ret = STDESUCCESS;
-
- if (remove(path) != 0) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- }
-
- return ret;
-}
-
-#ifdef __cplusplus
-}
-#endif
+/* Copyright (c) 2000-2009, 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 (jschultz at cnds.jhu.edu)
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <stdutil/stderror.h>
+#include <stdutil/stdfd.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32)
+# include <io.h>
+# include <sys/locking.h>
+# define STDFILENO(s) _fileno(s)
+# define STDFSYNC(fd) _commit(fd)
+#else
+# include <unistd.h>
+# define STDFILENO(s) fileno(s)
+# define STDFSYNC(fd) fsync(fd)
+#endif
+
+/************************************************************************************************
+ * stdfd_open: Open a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_open(stdfd *fd, const char *path, stdfd_access_type mode)
+{
+ stdcode ret = STDESUCCESS;
+ const char * fopen_mode;
+
+ 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;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ stdfd_open_end:
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_close: Close a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_close(stdfd *fd)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ if (fclose(fd->stream) != 0) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ fd->stream = NULL;
+ fd->fd = -1;
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_read: Read 'nmemb' entries of 'nsize' bytes each from a file
+ * descriptor into 'ptr.'
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_read(stdfd *fd, void *ptr, stdsize nsize, stdsize nmemb, stdsize *num)
+{
+ stdcode ret;
+
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ if ((*num = fread(ptr, nsize, nmemb, fd->stream)) == nmemb) {
+ ret = STDESUCCESS;
+
+ } else if (feof(fd->stream)) {
+ ret = STDEOF;
+
+ } else if (ferror(fd->stream)) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+
+ } else {
+ ret = STDEINTR; /* wrong count but not EOF or error? alert user! */
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_write: Write 'nmemb' entries of 'nsize' bytes each from 'ptr'
+ * to a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_write(stdfd *fd, const void *ptr, stdsize nsize, stdsize nmemb, stdsize *num)
+{
+ stdcode ret;
+
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ if ((*num = fwrite(ptr, nsize, nmemb, fd->stream)) == nmemb) {
+ ret = STDESUCCESS;
+
+ } else if (feof(fd->stream)) {
+ ret = STDEOF;
+
+ } else if (ferror(fd->stream)) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+
+ } else {
+ ret = STDEINTR; /* wrong count but not EOF or error? alert user! */
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_flush: Flush any user space data on a file descriptor to the OS.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_flush(stdfd *fd)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ if (fflush(fd->stream) != 0) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_sync: Flush user space data to the OS and force the OS to
+ * flush all data to disk.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_sync(stdfd *fd)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ if (fflush(fd->stream) != 0 || STDFSYNC(fd->fd) != 0) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_seek: Move the read/write head position of a file descriptor.
+ ***********************************************************************************************/
+
+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;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_tell: Get the read/write head position of a file descriptor.
+ ***********************************************************************************************/
+
+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;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdfd_eof: Return whether or not the EOF indicator on a file descriptor is set.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdfd_eof(stdfd *fd)
+{
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ return (feof(fd->stream) != 0);
+}
+
+/************************************************************************************************
+ * stdfd_err: Return whether or not an error indicator on a file descriptor is set.
+ ***********************************************************************************************/
+
+STDINLINE stdbool stdfd_err(stdfd *fd)
+{
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ return (ferror(fd->stream) != 0);
+}
+
+/************************************************************************************************
+ * stdfd_clr_err: Clear any error indicator on a file descriptor.
+ ***********************************************************************************************/
+
+STDINLINE void stdfd_clr_err(stdfd *fd)
+{
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ clearerr(fd->stream);
+}
+
+/************************************************************************************************
+ * stdfd_trylock: Try to acquire an advisory lock on a file
+ * descriptor's underlying file.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_trylock(stdfd *fd)
+#if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ 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) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+}
+#endif
+
+/************************************************************************************************
+ * stdfd_unlock: Release an advisory lock on a file descriptor's
+ * underlying file.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfd_unlock(stdfd *fd)
+#if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+
+ STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
+
+ 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) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+ }
+#endif
+
+/************************************************************************************************
+ * stdfile_unlink: Erase a file.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdfile_unlink(const char *path)
+{
+ stdcode ret = STDESUCCESS;
+
+ if (remove(path) != 0) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stdhash.c
===================================================================
--- trunk/stdutil/src/stdhash.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdhash.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdit.c
===================================================================
--- trunk/stdutil/src/stdit.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdit.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdskl.c
===================================================================
--- trunk/stdutil/src/stdskl.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdskl.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
@@ -481,7 +481,7 @@
* erase.
***********************************************************************************************/
-STDINLINE static void stdskl_low_erase(stdskl *l, stdit *b, stdit *e, stdsize num_erase)
+STDINLINE static stdsize stdskl_low_erase(stdskl *l, stdit *b, stdit *e, stdsize num_erase)
{
stdskl_node * ers;
stdskl_node * prev = b->impl.skl.node->prevs[0];
@@ -509,7 +509,7 @@
/* update list size */
- l->size -= num_erase;
+ l->size -= erased;
/* stitch together the left and right portions of the list */
@@ -539,6 +539,8 @@
if (e != NULL) {
e->impl.skl.node = ers;
}
+
+ return erased;
}
/************************************************************************************************
@@ -1038,28 +1040,31 @@
* stdskl_erase_seq: Erase a sequence from a list.
***********************************************************************************************/
-STDINLINE void stdskl_erase_seq(stdskl *l, stdit *b, stdit *e)
+STDINLINE stdsize stdskl_erase_seq(stdskl *l, stdit *b, stdit *e)
{
STDSAFETY_CHECK(STDSKL_IS_LEGAL(l) && STDIT_SKL_IS_LEGAL(b) && STDSKL_IT_IS_LEGAL(l, &b->impl.skl) && (stdit_eq(b, e) || STDTRUE));
- stdskl_low_erase(l, b, e, (stdsize) -1);
+ return stdskl_low_erase(l, b, e, (stdsize) -1);
}
/************************************************************************************************
* stdskl_erase_key: Erase all entries of a key from a list.
***********************************************************************************************/
-STDINLINE void stdskl_erase_key(stdskl *l, const void *key)
+STDINLINE stdsize stdskl_erase_key(stdskl *l, const void *key)
{
- stdit it;
+ stdsize ret = 0;
+ stdit it;
STDSAFETY_CHECK(STDSKL_IS_LEGAL(l));
stdskl_lowerb(l, &it, key);
- while (it.impl.skl.node != l->end_node && stdskl_low_key_cmp(l, key, STDSKL_NKEY(it.impl.skl.node)) == 0) {
+ for (; it.impl.skl.node != l->end_node && stdskl_low_key_cmp(l, key, STDSKL_NKEY(it.impl.skl.node)) == 0; ++ret) {
stdskl_erase(l, &it); /* advances 'it' */
}
+
+ return ret;
}
/************************************************************************************************
Modified: trunk/stdutil/src/stdthread.c
===================================================================
--- trunk/stdutil/src/stdthread.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdthread.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
@@ -19,10 +19,115 @@
* (CNDS - http://www.cnds.jhu.edu)
*/
-#if defined(_REENTRANT)
+#include <stdlib.h>
+#include <stdutil/stderror.h>
+#include <stdutil/stdthread.h>
-# include <stdlib.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* TODO: Need to implement code for STDMUTEX_NULL for threaded versions */
+/* TODO: Need to implement code for STDCOND_NULL */
+/* TODO: Need to break out the different implementations into their
+ own sections of code (i.e. - multiple implementations of each
+ function) like we did for !defined(_REENTRANT)
+*/
+
+#if !defined(_REENTRANT)
+
+STDINLINE stdcode stdthread_spawn(stdthread * thr_ptr, stdthread_id * id,
+ stdthread_fcn thr_fcn, void * fcn_arg)
+{
+ return STDENOSYS;
+}
+
+STDINLINE stdcode stdthread_detach(stdthread thr)
+{
+ return STDENOSYS;
+}
+
+STDINLINE stdcode stdthread_join(stdthread thr, void ** exitval_ptr)
+{
+ return STDENOSYS;
+}
+
+STDINLINE void stdthread_exit(void * exitval)
+{
+ exit(0);
+}
+
+STDINLINE stdthread_id stdthread_self(void)
+{
+ return STDENOSYS;
+}
+
+STDINLINE stdbool stdthread_eq(stdthread_id id1, stdthread_id id2)
+{
+ return STDENOSYS;
+}
+
+STDINLINE stdcode stdmutex_construct(stdmutex *mut, stdmutex_type t)
+{
+ return (t == STDMUTEX_NULL ? STDESUCCESS : STDENOSYS);
+}
+
+STDINLINE stdcode stdmutex_destruct(stdmutex *mut)
+{
+ return STDESUCCESS;
+}
+
+STDINLINE stdcode stdmutex_grab(stdmutex *mut)
+{
+ return STDESUCCESS;
+}
+
+STDINLINE stdcode stdmutex_trygrab(stdmutex *mut)
+{
+ return STDESUCCESS;
+}
+
+STDINLINE stdcode stdmutex_drop(stdmutex *mut)
+{
+ return STDESUCCESS;
+}
+
+STDINLINE stdcode stdmutex_is_owner(stdmutex *mut, unsigned * grab_cnt)
+{
+ *grab_cnt = (unsigned) -1;
+
+ return STDESUCCESS;
+}
+
+STDINLINE stdcode stdcond_construct(stdcond *cond)
+{
+ return STDENOSYS;
+}
+
+STDINLINE stdcode stdcond_destruct(stdcond *cond)
+{
+ return STDENOSYS;
+}
+
+STDINLINE stdcode stdcond_wake_one(stdcond *cond)
+{
+ return STDENOSYS;
+}
+
+STDINLINE stdcode stdcond_wake_all(stdcond *cond)
+{
+ return STDENOSYS;
+}
+
+STDINLINE stdcode stdcond_wait(stdcond *cond, stdmutex *mut)
+{
+ return STDENOSYS;
+}
+
+/*STDINLINE stdcode stdcond_timedwait(stdcond *cond, stdmutex *mut, long ns);*/
+
+#else
+
# if defined(_WIN32)
# include <process.h>
# define STDSLEEPERS_BEGIN(cond) ((cond)->sleepers_end.next)
@@ -32,13 +137,6 @@
# include <sys/time.h>
# endif
-# include <stdutil/stderror.h>
-# include <stdutil/stdthread.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/************************************************************************************************
* stdthread_spawn: Create a new thread and start its execution.
***********************************************************************************************/
@@ -439,7 +537,7 @@
* stdmutex_fast_cond_wait: Wait on a condition protected by a fast mutex.
***********************************************************************************************/
-STDINLINE stdcode stdmutex_fast_cond_wait(stdmutex *mut, stdcond *cond)
+STDINLINE static stdcode stdmutex_fast_cond_wait(stdmutex *mut, stdcond *cond)
# if defined(_WIN32)
{
/* NOTE: this WIN32 code works for both fast and recursive mutexes:
@@ -799,8 +897,7 @@
* stdmutex_rcrsv_cond_wait: Atomically unlock a 'mut' and wait on 'cond.'
***********************************************************************************************/
-STDINLINE stdcode stdmutex_rcrsv_cond_wait(stdmutex *mut, stdcond *cond)
-
+STDINLINE static stdcode stdmutex_rcrsv_cond_wait(stdmutex *mut, stdcond *cond)
# if defined(_WIN32)
{
/* NOTE: the WIN32 code works for both fast and recursive mutexes:
@@ -863,6 +960,7 @@
stdcode ret = STDEINVAL;
switch (t) {
+
case STDMUTEX_FAST:
ret = stdmutex_fast_init(mut);
break;
@@ -870,6 +968,10 @@
case STDMUTEX_RCRSV:
ret = stdmutex_rcrsv_init(mut);
break;
+
+ case STDMUTEX_NULL:
+ ret = STDESUCCESS;
+ break;
}
return ret;
@@ -884,6 +986,7 @@
stdcode ret = STDEINVAL;
switch (mut->mut_type) {
+
case STDMUTEX_FAST:
ret = stdmutex_fast_fini(mut);
break;
@@ -891,6 +994,10 @@
case STDMUTEX_RCRSV:
ret = stdmutex_rcrsv_fini(mut);
break;
+
+ case STDMUTEX_NULL:
+ ret = STDESUCCESS;
+ break;
}
return ret;
@@ -905,6 +1012,7 @@
stdcode ret = STDEINVAL;
switch (mut->mut_type) {
+
case STDMUTEX_FAST:
ret = stdmutex_fast_grab(mut, STDTRUE);
break;
@@ -912,6 +1020,10 @@
case STDMUTEX_RCRSV:
ret = stdmutex_rcrsv_grab(mut, STDTRUE);
break;
+
+ case STDMUTEX_NULL:
+ ret = STDESUCCESS;
+ break;
}
return ret;
@@ -926,6 +1038,7 @@
stdcode ret = STDEINVAL;
switch (mut->mut_type) {
+
case STDMUTEX_FAST:
ret = stdmutex_fast_grab(mut, STDFALSE);
break;
@@ -933,6 +1046,10 @@
case STDMUTEX_RCRSV:
ret = stdmutex_rcrsv_grab(mut, STDFALSE);
break;
+
+ case STDMUTEX_NULL:
+ ret = STDESUCCESS;
+ break;
}
return ret;
@@ -947,6 +1064,7 @@
stdcode ret = STDEINVAL;
switch (mut->mut_type) {
+
case STDMUTEX_FAST:
ret = stdmutex_fast_drop(mut);
break;
@@ -954,6 +1072,10 @@
case STDMUTEX_RCRSV:
ret = stdmutex_rcrsv_drop(mut);
break;
+
+ case STDMUTEX_NULL:
+ ret = STDESUCCESS;
+ break;
}
return ret;
@@ -968,6 +1090,7 @@
stdcode ret = STDEINVAL;
switch (mut->mut_type) {
+
case STDMUTEX_FAST:
ret = STDENOSYS;
break;
@@ -975,6 +1098,11 @@
case STDMUTEX_RCRSV:
ret = stdmutex_rcrsv_is_owner(mut, grab_cnt);
break;
+
+ case STDMUTEX_NULL:
+ *grab_cnt = (unsigned) -1;
+ ret = STDESUCCESS;
+ break;
}
return ret;
@@ -1070,6 +1198,7 @@
stdcode ret = STDEINVAL;
switch (mut->mut_type) {
+
case STDMUTEX_FAST:
ret = stdmutex_fast_cond_wait(mut, cond);
break;
@@ -1077,6 +1206,10 @@
case STDMUTEX_RCRSV:
ret = stdmutex_rcrsv_cond_wait(mut, cond);
break;
+
+ case STDMUTEX_NULL:
+ ret = STDESUCCESS;
+ break;
}
return ret;
@@ -1094,6 +1227,7 @@
stdcode ret = STDEINVAL;
switch (mut->mut_type) {
+
case STDMUTEX_FAST:
ret = stdmutex_fast_cond_wait_timed(mut, cond);
break;
@@ -1101,6 +1235,10 @@
case STDMUTEX_RCRSV:
ret = stdmutex_rcrsv_cond_wait_timed(mut, cond);
break;
+
+ case STDMUTEX_NULL:
+ ret = STDESUCCESS;
+ break;
}
return ret;
@@ -1189,10 +1327,8 @@
# endif
#endif
+#endif
+
#ifdef __cplusplus
}
#endif
-
-#else
-int stdthread_trnsl_dummy; /* avoids empty translation unit error #if !defined(_REENTRANT) */
-#endif
Modified: trunk/stdutil/src/stdtime.c
===================================================================
--- trunk/stdutil/src/stdtime.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdtime.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,334 +1,334 @@
-/* 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 (jschultz at cnds.jhu.edu)
- * The Center for Networking and Distributed Systems
- * (CNDS - http://www.cnds.jhu.edu)
- */
-
-#if defined(_WIN32)
-# include <windows.h>
-# include <sys/types.h>
-# include <sys/timeb.h>
-#else
-# include <time.h>
-# include <sys/time.h>
-#endif
-
-#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
- sec > 0 -> 0 <= nano < STD1BILLION
-*/
-
-#define STDTIME_IS_LEGAL(t) ( ((t).sec != STDINT64_MIN || (t).nano == 0) && \
- (((t).sec >= 0 && (t).nano >= 0 && (t).nano < STD1BILLION) || \
- ((t).sec <= 0 && (t).nano <= 0 && (t).nano > -STD1BILLION)) )
-
-/************************************************************************************************
- * stdtime: Get the current system time since UTC 00:00:00, Jan 1, 1970.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdtime_now(stdtime *abs_time)
-#if defined(_WIN32)
-{
- struct _timeb t;
-
- _ftime(&t);
-
- abs_time->sec = t.time;
- abs_time->nano = t.millitm * STD1MILLION;
-
- return STDESUCCESS;
-}
-#else
-{
- stdcode ret = STDESUCCESS;
- struct timeval t;
-
- if (gettimeofday(&t, NULL) != STDESUCCESS) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
- goto stdtime_now_end;
- }
-
- abs_time->sec = t.tv_sec;
- abs_time->nano = t.tv_usec * STD1THOUSAND;
-
-stdtime_now_end:
- return ret;
-}
-#endif
-
-/************************************************************************************************
- * stdtime_time64: Return a stdtime created from a stdtime_time64.
- *
- * NOTE: '/' and '%' aren't uniformly defined for negative operands so we negate as needed
- ***********************************************************************************************/
-
-STDINLINE stdtime stdtime_time64(stdtime64 src)
-{
- stdtime64 cpy = (src >= 0 ? src : -src);
- stdtime ret;
-
- ret.sec = cpy / STD1BILLION;
- ret.nano = (stdint32) cpy % (stdint32) STD1BILLION;
-
- if (src < 0) {
- ret.sec = -ret.sec;
- ret.nano = -ret.nano;
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdtime_cmp: Compare two stdtimes.
- ***********************************************************************************************/
-
-STDINLINE int stdtime_cmp(stdtime ls, stdtime rs)
-{
- STDSAFETY_CHECK(STDTIME_IS_LEGAL(ls) && STDTIME_IS_LEGAL(rs));
-
- if (ls.sec == rs.sec) {
-
- if (ls.nano == rs.nano) {
- return 0;
- }
-
- return (ls.nano < rs.nano ? -1 : 1);
- }
-
- return (ls.sec < rs.sec ? -1 : 1);
-}
-
-/************************************************************************************************
- * stdtime_sign: Get the sign (-1: negative, 0: none, 1: positive) of a stdtime.
- ***********************************************************************************************/
-
-STDINLINE int stdtime_sign(stdtime t)
-{
- stdtime t2 = { 0, 0 };
-
- return stdtime_cmp(t, t2);
-}
-
-/************************************************************************************************
- * stdtime_neg: Return the negation of a stdtime.
- ***********************************************************************************************/
-
-STDINLINE stdtime stdtime_neg(stdtime t)
-{
- STDSAFETY_CHECK(STDTIME_IS_LEGAL(t));
-
- t.sec = -t.sec;
- t.nano = -t.nano;
-
- return t;
-}
-
-/************************************************************************************************
- * stdtime_add: Return the addition of two stdtimes.
- ***********************************************************************************************/
-
-STDINLINE stdtime stdtime_add(stdtime ls, stdtime rs)
-{
- stdtime ret;
-
- STDSAFETY_CHECK(STDTIME_IS_LEGAL(ls) && STDTIME_IS_LEGAL(rs));
-
- /* do the addition */
-
- ret.sec = ls.sec + rs.sec;
- ret.nano = ls.nano + rs.nano;
-
- /* ensure -STD1BILLION < nano < STD1BILLION */
-
- if (ret.nano >= STD1BILLION) {
- ++ret.sec;
- ret.nano -= STD1BILLION;
-
- } else if (ret.nano <= -STD1BILLION) {
- --ret.sec;
- ret.nano += STD1BILLION;
- }
-
- /* check for non-agreement in signs */
-
- if (ret.sec > 0) {
-
- if (ret.nano < 0) {
- --ret.sec;
- ret.nano += STD1BILLION;
- }
-
- } else if (ret.sec != 0) {
-
- if (ret.nano > 0) {
- ++ret.sec;
- ret.nano -= STD1BILLION;
- }
- }
-
- /* check for nasty edge case and wrap around if not exactly minimum representation */
-
- if (ret.sec == STDINT64_MIN && ret.nano != 0) {
- --ret.sec;
- ret.nano += STD1BILLION;
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdtime_sub: Return the difference of two stdtimes.
- ***********************************************************************************************/
-
-STDINLINE stdtime stdtime_sub(stdtime ls, stdtime rs)
-{
- return stdtime_add(ls, stdtime_neg(rs));
-}
-
-/************************************************************************************************
- * stdtime64_now: Get the current system time since UTC 00:00:00, Jan 1, 1970.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdtime64_now(stdtime64 *abs_time)
-{
- stdtime t;
- stdcode ret = stdtime_now(&t);
-
- if (ret == STDESUCCESS) {
- *abs_time = stdtime64_time(t);
- }
-
- return ret;
-}
-
-/************************************************************************************************
- * stdtime64_time: Return a stdtime64 from a stdtime.
- ***********************************************************************************************/
-
-STDINLINE stdtime64 stdtime64_time(stdtime t)
-{
- STDSAFETY_CHECK(STDTIME_IS_LEGAL(t));
-
- return (stdtime64) t.sec * STD1BILLION + t.nano;
-}
-
-/************************************************************************************************
- * stdsleep: Sleep for a period of time. On error, remndr will be
- * filled if non-NULL.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdsleep(stdtime delta, stdtime *remndr)
-# if defined(_WIN32)
-{
- stdcode ret = STDESUCCESS;
- stdtime start_time = { 0, 0 };
- stdtime end_time = { 0, 0 };
- DWORD milli_sleep;
-
- if (delta.sec < 0 || delta.nano < 0 || delta.nano >= STD1BILLION) {
- ret = STDEINVAL;
- goto stdsleep_fail;
- }
-
- /* conditional +1 for possible nanosecond division trunctation */
-
- milli_sleep = (DWORD) (delta.sec * STD1THOUSAND + delta.nano / STD1MILLION) + (delta.nano != 0 ? 1 : 0);
-
- Sleep(milli_sleep);
-
- goto stdsleep_end;
-
- /* error handling and return */
-
- stdsleep_fail:
- if (remndr != NULL) {
- *remndr = delta;
- }
-
- stdsleep_end:
- return ret;
-}
-#else
-{
- stdcode ret;
- struct timespec d;
- struct timespec r;
-
- if (delta.sec < 0 || delta.nano < 0 || delta.nano >= STD1BILLION) {
- ret = STDEINVAL;
- goto stdsleep_fail;
- }
-
- d.tv_sec = (time_t) delta.sec;
- d.tv_nsec = delta.nano;
-
- if ((ret = nanosleep(&d, &r)) != STDESUCCESS) {
- ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
-
- if (remndr != NULL) {
- remndr->sec = r.tv_sec;
- remndr->nano = r.tv_nsec;
- }
- }
-
- goto stdsleep_end;
-
- /* error handling and return */
-
- stdsleep_fail:
- if (remndr != NULL) {
- *remndr = delta;
- }
-
- stdsleep_end:
- return ret;
-}
-#endif
-
-/************************************************************************************************
- * stdsleep64: Sleep for a number of nanoseconds.
- ***********************************************************************************************/
-
-STDINLINE stdcode stdsleep64(stdtime64 delta, stdtime64 *remndr)
-{
- stdcode ret;
- stdtime t_delta = stdtime_time64(delta);
- stdtime t_remndr;
-
- ret = stdsleep(t_delta, (remndr != NULL ? &t_remndr : NULL));
-
- if (ret != STDESUCCESS && remndr != NULL) {
- *remndr = stdtime64_time(t_remndr);
- }
-
- return ret;
-}
-
-#ifdef __cplusplus
-}
-#endif
+/* Copyright (c) 2000-2009, 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 (jschultz at cnds.jhu.edu)
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#if defined(_WIN32)
+# include <windows.h>
+# include <sys/types.h>
+# include <sys/timeb.h>
+#else
+# include <time.h>
+# include <sys/time.h>
+#endif
+
+#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
+ sec > 0 -> 0 <= nano < STD1BILLION
+*/
+
+#define STDTIME_IS_LEGAL(t) ( ((t).sec != STDINT64_MIN || (t).nano == 0) && \
+ (((t).sec >= 0 && (t).nano >= 0 && (t).nano < STD1BILLION) || \
+ ((t).sec <= 0 && (t).nano <= 0 && (t).nano > -STD1BILLION)) )
+
+/************************************************************************************************
+ * stdtime: Get the current system time since UTC 00:00:00, Jan 1, 1970.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdtime_now(stdtime *abs_time)
+#if defined(_WIN32)
+{
+ struct _timeb t;
+
+ _ftime(&t);
+
+ abs_time->sec = t.time;
+ abs_time->nano = t.millitm * STD1MILLION;
+
+ return STDESUCCESS;
+}
+#else
+{
+ stdcode ret = STDESUCCESS;
+ struct timeval t;
+
+ if (gettimeofday(&t, NULL) != STDESUCCESS) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ goto stdtime_now_end;
+ }
+
+ abs_time->sec = t.tv_sec;
+ abs_time->nano = t.tv_usec * STD1THOUSAND;
+
+stdtime_now_end:
+ return ret;
+}
+#endif
+
+/************************************************************************************************
+ * stdtime_time64: Return a stdtime created from a stdtime_time64.
+ *
+ * NOTE: '/' and '%' aren't uniformly defined for negative operands so we negate as needed
+ ***********************************************************************************************/
+
+STDINLINE stdtime stdtime_time64(stdtime64 src)
+{
+ stdtime64 cpy = (src >= 0 ? src : -src);
+ stdtime ret;
+
+ ret.sec = cpy / STD1BILLION;
+ ret.nano = (stdint32) (cpy % STD1BILLION);
+
+ if (src < 0) {
+ ret.sec = -ret.sec;
+ ret.nano = -ret.nano;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdtime_cmp: Compare two stdtimes.
+ ***********************************************************************************************/
+
+STDINLINE int stdtime_cmp(stdtime ls, stdtime rs)
+{
+ STDSAFETY_CHECK(STDTIME_IS_LEGAL(ls) && STDTIME_IS_LEGAL(rs));
+
+ if (ls.sec == rs.sec) {
+
+ if (ls.nano == rs.nano) {
+ return 0;
+ }
+
+ return (ls.nano < rs.nano ? -1 : 1);
+ }
+
+ return (ls.sec < rs.sec ? -1 : 1);
+}
+
+/************************************************************************************************
+ * stdtime_sign: Get the sign (-1: negative, 0: none, 1: positive) of a stdtime.
+ ***********************************************************************************************/
+
+STDINLINE int stdtime_sign(stdtime t)
+{
+ stdtime t2 = { 0, 0 };
+
+ return stdtime_cmp(t, t2);
+}
+
+/************************************************************************************************
+ * stdtime_neg: Return the negation of a stdtime.
+ ***********************************************************************************************/
+
+STDINLINE stdtime stdtime_neg(stdtime t)
+{
+ STDSAFETY_CHECK(STDTIME_IS_LEGAL(t));
+
+ t.sec = -t.sec;
+ t.nano = -t.nano;
+
+ return t;
+}
+
+/************************************************************************************************
+ * stdtime_add: Return the addition of two stdtimes.
+ ***********************************************************************************************/
+
+STDINLINE stdtime stdtime_add(stdtime ls, stdtime rs)
+{
+ stdtime ret;
+
+ STDSAFETY_CHECK(STDTIME_IS_LEGAL(ls) && STDTIME_IS_LEGAL(rs));
+
+ /* do the addition */
+
+ ret.sec = ls.sec + rs.sec;
+ ret.nano = ls.nano + rs.nano;
+
+ /* ensure -STD1BILLION < nano < STD1BILLION */
+
+ if (ret.nano >= STD1BILLION) {
+ ++ret.sec;
+ ret.nano -= STD1BILLION;
+
+ } else if (ret.nano <= -STD1BILLION) {
+ --ret.sec;
+ ret.nano += STD1BILLION;
+ }
+
+ /* check for non-agreement in signs */
+
+ if (ret.sec > 0) {
+
+ if (ret.nano < 0) {
+ --ret.sec;
+ ret.nano += STD1BILLION;
+ }
+
+ } else if (ret.sec != 0) {
+
+ if (ret.nano > 0) {
+ ++ret.sec;
+ ret.nano -= STD1BILLION;
+ }
+ }
+
+ /* check for nasty edge case and wrap around if not exactly minimum representation */
+
+ if (ret.sec == STDINT64_MIN && ret.nano != 0) {
+ --ret.sec;
+ ret.nano += STD1BILLION;
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdtime_sub: Return the difference of two stdtimes.
+ ***********************************************************************************************/
+
+STDINLINE stdtime stdtime_sub(stdtime ls, stdtime rs)
+{
+ return stdtime_add(ls, stdtime_neg(rs));
+}
+
+/************************************************************************************************
+ * stdtime64_now: Get the current system time since UTC 00:00:00, Jan 1, 1970.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdtime64_now(stdtime64 *abs_time)
+{
+ stdtime t;
+ stdcode ret = stdtime_now(&t);
+
+ if (ret == STDESUCCESS) {
+ *abs_time = stdtime64_time(t);
+ }
+
+ return ret;
+}
+
+/************************************************************************************************
+ * stdtime64_time: Return a stdtime64 from a stdtime.
+ ***********************************************************************************************/
+
+STDINLINE stdtime64 stdtime64_time(stdtime t)
+{
+ STDSAFETY_CHECK(STDTIME_IS_LEGAL(t));
+
+ return (stdtime64) t.sec * STD1BILLION + t.nano;
+}
+
+/************************************************************************************************
+ * stdsleep: Sleep for a period of time. On error, remndr will be
+ * filled if non-NULL.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdsleep(stdtime delta, stdtime *remndr)
+# if defined(_WIN32)
+{
+ stdcode ret = STDESUCCESS;
+ stdtime start_time = { 0, 0 };
+ stdtime end_time = { 0, 0 };
+ DWORD milli_sleep;
+
+ if (delta.sec < 0 || delta.nano < 0 || delta.nano >= STD1BILLION) {
+ ret = STDEINVAL;
+ goto stdsleep_fail;
+ }
+
+ /* conditional +1 for possible nanosecond division trunctation */
+
+ milli_sleep = (DWORD) (delta.sec * STD1THOUSAND + delta.nano / STD1MILLION) + (delta.nano != 0 ? 1 : 0);
+
+ Sleep(milli_sleep);
+
+ goto stdsleep_end;
+
+ /* error handling and return */
+
+ stdsleep_fail:
+ if (remndr != NULL) {
+ *remndr = delta;
+ }
+
+ stdsleep_end:
+ return ret;
+}
+#else
+{
+ stdcode ret;
+ struct timespec d;
+ struct timespec r;
+
+ if (delta.sec < 0 || delta.nano < 0 || delta.nano >= STD1BILLION) {
+ ret = STDEINVAL;
+ goto stdsleep_fail;
+ }
+
+ d.tv_sec = (time_t) delta.sec;
+ d.tv_nsec = delta.nano;
+
+ if ((ret = nanosleep(&d, &r)) != STDESUCCESS) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+
+ if (remndr != NULL) {
+ remndr->sec = r.tv_sec;
+ remndr->nano = r.tv_nsec;
+ }
+ }
+
+ goto stdsleep_end;
+
+ /* error handling and return */
+
+ stdsleep_fail:
+ if (remndr != NULL) {
+ *remndr = delta;
+ }
+
+ stdsleep_end:
+ return ret;
+}
+#endif
+
+/************************************************************************************************
+ * stdsleep64: Sleep for a number of nanoseconds.
+ ***********************************************************************************************/
+
+STDINLINE stdcode stdsleep64(stdtime64 delta, stdtime64 *remndr)
+{
+ stdcode ret;
+ stdtime t_delta = stdtime_time64(delta);
+ stdtime t_remndr;
+
+ ret = stdsleep(t_delta, (remndr != NULL ? &t_remndr : NULL));
+
+ if (ret != STDESUCCESS && remndr != NULL) {
+ *remndr = stdtime64_time(t_remndr);
+ }
+
+ return ret;
+}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stdutil/private/stdarch.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarch.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdarch.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/private/stdarch_autoconf.h.in
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarch_autoconf.h.in 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdarch_autoconf.h.in 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/private/stdarch_wintel32.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarch_wintel32.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdarch_wintel32.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/private/stdarr_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarr_p.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdarr_p.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/private/stdcarr_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdcarr_p.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdcarr_p.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/private/stddll_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stddll_p.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stddll_p.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/private/stdhash_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdhash_p.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdhash_p.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/private/stdit_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdit_p.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdit_p.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/private/stdskl_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdskl_p.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdskl_p.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,95 +1,95 @@
-/* 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 (jschultz at cnds.jhu.edu)
- * The Center for Networking and Distributed Systems
- * (CNDS - http://www.cnds.jhu.edu)
- */
-
-#ifndef stdskl_p_h_2005_06_07_15_09_42_jschultz_at_cnds_jhu_edu
-#define stdskl_p_h_2005_06_07_15_09_42_jschultz_at_cnds_jhu_edu
-
-/* stdskl_node: A type that contains a key-value pair and node linking information.
-
- height - 0 based height of this node; size of (prevs, nexts) arrays minus 1
- prevs - an array of pointers to previous elements in the list
- nexts - an array of pointers to later elements in the list
- key - pointer to the node's key
- val - pointer to the node's val
-
- NOTE: The prevs and nexts arrays are appended onto the end of the
- node in memory.
-
- NOTE: The key and value are then appended onto the end of this node in
- memory after the prevs and nexts arrays (w/ padding as necessary).
-*/
-
-typedef struct stdskl_node
-{
- stdint8 height;
- struct stdskl_node ** prevs;
- struct stdskl_node ** nexts;
-
- const void * key;
- void * val;
-
-} stdskl_node;
-
-/* 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
- ksize - size in bytes of key type contained
- vsize - size in bytes of value type contained
- cmp_fcn - user defined key comparison function
- seed - state used to generate pseudo-random numbers
- rand_bits - a random number that contains random bits
- bits_left - how many unused bits remain in rand_bits
-*/
-
-typedef struct stdskl
-{
- stdskl_node * end_node;
-
- stdsize size;
-
- stdsize ksize;
- stdsize vsize;
-
- stdcmp_fcn cmp_fcn;
-
- stduint16 seed[3];
- stduint32 rand_bits;
- stdint8 bits_left;
-
-} stdskl;
-
-/* stdskl_it: An iterator for a stdskl.
-
- node - pointer to the reference node in the list
- ksize - size in bytes of referenced key type
- vsize - size in bytes of referenced value type
-*/
-
-typedef struct
-{
- stdskl_node * node;
- stdsize ksize;
- stdsize vsize;
-
-} stdskl_it;
-
-#endif
+/* Copyright (c) 2000-2009, 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 (jschultz at cnds.jhu.edu)
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdskl_p_h_2005_06_07_15_09_42_jschultz_at_cnds_jhu_edu
+#define stdskl_p_h_2005_06_07_15_09_42_jschultz_at_cnds_jhu_edu
+
+/* stdskl_node: A type that contains a key-value pair and node linking information.
+
+ height - 0 based height of this node; size of (prevs, nexts) arrays minus 1
+ prevs - an array of pointers to previous elements in the list
+ nexts - an array of pointers to later elements in the list
+ key - pointer to the node's key
+ val - pointer to the node's val
+
+ NOTE: The prevs and nexts arrays are appended onto the end of the
+ node in memory.
+
+ NOTE: The key and value are then appended onto the end of this node in
+ memory after the prevs and nexts arrays (w/ padding as necessary).
+*/
+
+typedef struct stdskl_node
+{
+ stdint8 height;
+ struct stdskl_node ** prevs;
+ struct stdskl_node ** nexts;
+
+ const void * key;
+ void * val;
+
+} stdskl_node;
+
+/* 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
+ ksize - size in bytes of key type contained
+ vsize - size in bytes of value type contained
+ cmp_fcn - user defined key comparison function
+ seed - state used to generate pseudo-random numbers
+ rand_bits - a random number that contains random bits
+ bits_left - how many unused bits remain in rand_bits
+*/
+
+typedef struct stdskl
+{
+ stdskl_node * end_node;
+
+ stdsize size;
+
+ stdsize ksize;
+ stdsize vsize;
+
+ stdcmp_fcn cmp_fcn;
+
+ stduint16 seed[3];
+ stduint32 rand_bits;
+ stdint8 bits_left;
+
+} stdskl;
+
+/* stdskl_it: An iterator for a stdskl.
+
+ node - pointer to the reference node in the list
+ ksize - size in bytes of referenced key type
+ vsize - size in bytes of referenced value type
+*/
+
+typedef struct
+{
+ stdskl_node * node;
+ stdsize ksize;
+ stdsize vsize;
+
+} stdskl_it;
+
+#endif
Modified: trunk/stdutil/src/stdutil/private/stdthread_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdthread_p.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/private/stdthread_p.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
@@ -22,7 +22,16 @@
#ifndef stdthread_p_h_2000_05_18_12_57_48_jschultz_at_cnds_jhu_edu
#define stdthread_p_h_2000_05_18_12_57_48_jschultz_at_cnds_jhu_edu
-#if defined(_WIN32)
+#if !defined(_REENTRANT)
+
+# define STDTHREAD_FCN
+
+typedef int stdthread;
+typedef int stdthread_id;
+typedef int stdmutex_impl;
+typedef int stdcond_impl;
+
+#elif defined(_WIN32)
# include <windows.h>
# define STDTHREAD_FCN __stdcall
@@ -97,4 +106,4 @@
typedef stdcond_impl stdcond;
-# endif
+#endif
Modified: trunk/stdutil/src/stdutil/stdarr.h
===================================================================
--- trunk/stdutil/src/stdutil/stdarr.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdarr.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/stdcarr.h
===================================================================
--- trunk/stdutil/src/stdutil/stdcarr.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdcarr.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/stddefines.h
===================================================================
--- trunk/stdutil/src/stdutil/stddefines.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stddefines.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
@@ -69,21 +69,21 @@
typedef stdarch_int32 stdint32;
typedef stdarch_uint32 stduint32;
-#define STDINT32_MAX (STDINT32_MIN - 1)
+#define STDINT32_MAX ((stdint32) ((stduint32) 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_MAX ((stdint64) ((stduint64) 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_MAX ((stdssize) ((stdsize) STDSSIZE_MIN - 1))
#define STDSSIZE_MIN ((stdssize) ((stdsize) 0x1 << (sizeof(stdssize) * 8 - 1))
#define STDSIZE_MAX ((stdsize) -1)
Modified: trunk/stdutil/src/stdutil/stddll.h
===================================================================
--- trunk/stdutil/src/stdutil/stddll.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stddll.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/stderror.h
===================================================================
--- trunk/stdutil/src/stdutil/stderror.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stderror.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
@@ -124,6 +124,12 @@
# define STDEINTR 507
#endif
+#if defined(ETIMEDOUT)
+# define STDETIMEDOUT ETIMEDOUT
+#else
+# define STDETIMEDOUT 508
+#endif
+
#ifdef __cplusplus
}
#endif
Modified: trunk/stdutil/src/stdutil/stdfd.h
===================================================================
--- trunk/stdutil/src/stdutil/stdfd.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdfd.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,89 +1,89 @@
-/* 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 (jschultz at cnds.jhu.edu)
- * The Center for Networking and Distributed Systems
- * (CNDS - http://www.cnds.jhu.edu)
- */
-
-#ifndef stdfd_h_2003_10_20_13_49_08_jschultz_at_cnds_jhu_edu
-#define stdfd_h_2003_10_20_13_49_08_jschultz_at_cnds_jhu_edu
-
-#include <stdio.h>
-#include <stdutil/stddefines.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct
-{
- int fd;
- FILE * stream;
-
-} 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 */
-
-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);
-STDINLINE stdcode stdfd_write(stdfd *fd, const void *ptr, stdsize nsize, stdsize nmemb, stdsize *num);
-
-STDINLINE stdcode stdfd_flush(stdfd *fd);
-STDINLINE stdcode stdfd_sync(stdfd *fd);
-
-STDINLINE stdcode stdfd_seek(stdfd *fd, long offset, stdfd_whence whence);
-STDINLINE stdcode stdfd_tell(stdfd *fd, long *pos);
-
-STDINLINE stdbool stdfd_eof(stdfd *fd);
-STDINLINE stdbool stdfd_err(stdfd *fd);
-STDINLINE void stdfd_clr_err(stdfd *fd);
-
-STDINLINE stdcode stdfd_trylock(stdfd *fd);
-STDINLINE stdcode stdfd_unlock(stdfd *fd);
-
-/* File Operations */
-
-STDINLINE stdcode stdfile_unlink(const char * path);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/* Copyright (c) 2000-2009, 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 (jschultz at cnds.jhu.edu)
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdfd_h_2003_10_20_13_49_08_jschultz_at_cnds_jhu_edu
+#define stdfd_h_2003_10_20_13_49_08_jschultz_at_cnds_jhu_edu
+
+#include <stdio.h>
+#include <stdutil/stddefines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ int fd;
+ FILE * stream;
+
+} 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 */
+
+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);
+STDINLINE stdcode stdfd_write(stdfd *fd, const void *ptr, stdsize nsize, stdsize nmemb, stdsize *num);
+
+STDINLINE stdcode stdfd_flush(stdfd *fd);
+STDINLINE stdcode stdfd_sync(stdfd *fd);
+
+STDINLINE stdcode stdfd_seek(stdfd *fd, long offset, stdfd_whence whence);
+STDINLINE stdcode stdfd_tell(stdfd *fd, long *pos);
+
+STDINLINE stdbool stdfd_eof(stdfd *fd);
+STDINLINE stdbool stdfd_err(stdfd *fd);
+STDINLINE void stdfd_clr_err(stdfd *fd);
+
+STDINLINE stdcode stdfd_trylock(stdfd *fd);
+STDINLINE stdcode stdfd_unlock(stdfd *fd);
+
+/* File Operations */
+
+STDINLINE stdcode stdfile_unlink(const char * path);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Modified: trunk/stdutil/src/stdutil/stdhash.h
===================================================================
--- trunk/stdutil/src/stdutil/stdhash.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdhash.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/stdit.h
===================================================================
--- trunk/stdutil/src/stdutil/stdit.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdit.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil/stdskl.h
===================================================================
--- trunk/stdutil/src/stdutil/stdskl.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdskl.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,105 +1,105 @@
-/* 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 (jschultz at cnds.jhu.edu)
- * The Center for Networking and Distributed Systems
- * (CNDS - http://www.cnds.jhu.edu)
- */
-
-#ifndef stdskl_h_2004_07_24_13_13_49_jschultz_at_cnds_jhu_edu
-#define stdskl_h_2004_07_24_13_13_49_jschultz_at_cnds_jhu_edu
-
-#include <stdutil/stdit.h>
-
-# ifdef __cplusplus
-extern "C" {
-# endif
-
-/* Structors */
-
-STDINLINE stdcode stdskl_construct(stdskl *l, stdsize ksize, stdsize vsize, stdcmp_fcn kcmp);
-STDINLINE stdcode stdskl_copy_construct(stdskl *dst, const stdskl *src);
-STDINLINE void stdskl_destruct(stdskl *l);
-
-/* Assigners */
-
-STDINLINE stdcode stdskl_set_eq(stdskl *dst, const stdskl *src);
-STDINLINE void stdskl_swap(stdskl *l1, stdskl *l2);
-
-/* Iterators */
-
-STDINLINE stdit * stdskl_begin(const stdskl *l, stdit *it);
-STDINLINE stdit * stdskl_last(const stdskl *l, stdit *it);
-STDINLINE stdit * stdskl_end(const stdskl *l, stdit *it);
-STDINLINE stdit * stdskl_get(const stdskl *l, stdit *it, size_t elem_num); /* O(n) */
-
-STDINLINE stdbool stdskl_is_begin(const stdskl *l, const stdit *it);
-STDINLINE stdbool stdskl_is_end(const stdskl *l, const stdit *it);
-
-/* Size Information */
-
-STDINLINE stdsize stdskl_size(const stdskl *l);
-STDINLINE stdbool stdskl_empty(const stdskl *l);
-
-/* Size Operations */
-
-STDINLINE void stdskl_clear(stdskl *l);
-
-/* Dictionary Operations: O(lg n) */
-
-STDINLINE stdit * stdskl_find(const stdskl *l, stdit *it, const void *key);
-STDINLINE stdit * stdskl_lowerb(const stdskl *l, stdit *it, const void *key);
-STDINLINE stdit * stdskl_upperb(const stdskl *l, stdit *it, const void *key);
-STDINLINE stdbool stdskl_contains(const stdskl *l, const void *key);
-
-STDINLINE stdcode stdskl_put(stdskl *l, stdit *it, const void *key, const void *val, stdbool hint);
-STDINLINE stdcode stdskl_put_n(stdskl *l, stdit *it, const void *keys, const void *vals, stdsize num_put, stdbool hint);
-STDINLINE stdcode stdskl_put_seq(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdbool hint);
-STDINLINE stdcode stdskl_put_seq_n(stdskl *l, stdit *it, const stdit *b, stdsize num_put, stdbool hint);
-
-STDINLINE stdcode stdskl_insert(stdskl *l, stdit *it, const void *key, const void *val, stdbool hint);
-STDINLINE stdcode stdskl_insert_n(stdskl *l, stdit *it, const void *keys, const void *vals, stdsize num_insert, stdbool hint);
-STDINLINE stdcode stdskl_insert_seq(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdbool hint);
-STDINLINE stdcode stdskl_insert_seq_n(stdskl *l, stdit *it, const stdit *b, stdsize num_insert, stdbool hint);
-STDINLINE stdcode stdskl_insert_rep(stdskl *l, stdit *it, const void *key, const void *val, stdsize num_times, stdbool hint);
-
-STDINLINE void stdskl_erase(stdskl *l, stdit *it);
-STDINLINE void stdskl_erase_n(stdskl *l, stdit *it, stdsize num_erase);
-STDINLINE void stdskl_erase_seq(stdskl *l, stdit *b, stdit *e);
-STDINLINE void stdskl_erase_key(stdskl *l, const void *key);
-
-/* Randomization */
-
-STDINLINE void stdskl_dseed(stdskl *l, const void *seed, stdsize sizeof_seed);
-
-/* Iterator Fcns */
-
-STDINLINE const void * stdskl_it_key(const stdit *it);
-STDINLINE stdsize stdskl_it_key_size(const stdit *it);
-STDINLINE void * stdskl_it_val(const stdit *it);
-STDINLINE stdsize stdskl_it_val_size(const stdit *it);
-STDINLINE stdbool stdskl_it_eq(const stdit *it1, const stdit *it2);
-
-STDINLINE stdit * stdskl_it_next(stdit *it);
-STDINLINE stdit * stdskl_it_advance(stdit *it, stdsize num_advance);
-STDINLINE stdit * stdskl_it_prev(stdit *it);
-STDINLINE stdit * stdskl_it_retreat(stdit *it, stdsize num_retreat);
-
-# ifdef __cplusplus
-}
-# endif
-
-#endif
+/* Copyright (c) 2000-2009, 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 (jschultz at cnds.jhu.edu)
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdskl_h_2004_07_24_13_13_49_jschultz_at_cnds_jhu_edu
+#define stdskl_h_2004_07_24_13_13_49_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stdit.h>
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* Structors */
+
+STDINLINE stdcode stdskl_construct(stdskl *l, stdsize ksize, stdsize vsize, stdcmp_fcn kcmp);
+STDINLINE stdcode stdskl_copy_construct(stdskl *dst, const stdskl *src);
+STDINLINE void stdskl_destruct(stdskl *l);
+
+/* Assigners */
+
+STDINLINE stdcode stdskl_set_eq(stdskl *dst, const stdskl *src);
+STDINLINE void stdskl_swap(stdskl *l1, stdskl *l2);
+
+/* Iterators */
+
+STDINLINE stdit * stdskl_begin(const stdskl *l, stdit *it);
+STDINLINE stdit * stdskl_last(const stdskl *l, stdit *it);
+STDINLINE stdit * stdskl_end(const stdskl *l, stdit *it);
+STDINLINE stdit * stdskl_get(const stdskl *l, stdit *it, size_t elem_num); /* O(n) */
+
+STDINLINE stdbool stdskl_is_begin(const stdskl *l, const stdit *it);
+STDINLINE stdbool stdskl_is_end(const stdskl *l, const stdit *it);
+
+/* Size Information */
+
+STDINLINE stdsize stdskl_size(const stdskl *l);
+STDINLINE stdbool stdskl_empty(const stdskl *l);
+
+/* Size Operations */
+
+STDINLINE void stdskl_clear(stdskl *l);
+
+/* Dictionary Operations: O(lg n) */
+
+STDINLINE stdit * stdskl_find(const stdskl *l, stdit *it, const void *key);
+STDINLINE stdit * stdskl_lowerb(const stdskl *l, stdit *it, const void *key);
+STDINLINE stdit * stdskl_upperb(const stdskl *l, stdit *it, const void *key);
+STDINLINE stdbool stdskl_contains(const stdskl *l, const void *key);
+
+STDINLINE stdcode stdskl_put(stdskl *l, stdit *it, const void *key, const void *val, stdbool hint);
+STDINLINE stdcode stdskl_put_n(stdskl *l, stdit *it, const void *keys, const void *vals, stdsize num_put, stdbool hint);
+STDINLINE stdcode stdskl_put_seq(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdbool hint);
+STDINLINE stdcode stdskl_put_seq_n(stdskl *l, stdit *it, const stdit *b, stdsize num_put, stdbool hint);
+
+STDINLINE stdcode stdskl_insert(stdskl *l, stdit *it, const void *key, const void *val, stdbool hint);
+STDINLINE stdcode stdskl_insert_n(stdskl *l, stdit *it, const void *keys, const void *vals, stdsize num_insert, stdbool hint);
+STDINLINE stdcode stdskl_insert_seq(stdskl *l, stdit *it, const stdit *b, const stdit *e, stdbool hint);
+STDINLINE stdcode stdskl_insert_seq_n(stdskl *l, stdit *it, const stdit *b, stdsize num_insert, stdbool hint);
+STDINLINE stdcode stdskl_insert_rep(stdskl *l, stdit *it, const void *key, const void *val, stdsize num_times, stdbool hint);
+
+STDINLINE void stdskl_erase(stdskl *l, stdit *it);
+STDINLINE void stdskl_erase_n(stdskl *l, stdit *it, stdsize num_erase);
+STDINLINE stdsize stdskl_erase_seq(stdskl *l, stdit *b, stdit *e);
+STDINLINE stdsize stdskl_erase_key(stdskl *l, const void *key);
+
+/* Randomization */
+
+STDINLINE void stdskl_dseed(stdskl *l, const void *seed, stdsize sizeof_seed);
+
+/* Iterator Fcns */
+
+STDINLINE const void * stdskl_it_key(const stdit *it);
+STDINLINE stdsize stdskl_it_key_size(const stdit *it);
+STDINLINE void * stdskl_it_val(const stdit *it);
+STDINLINE stdsize stdskl_it_val_size(const stdit *it);
+STDINLINE stdbool stdskl_it_eq(const stdit *it1, const stdit *it2);
+
+STDINLINE stdit * stdskl_it_next(stdit *it);
+STDINLINE stdit * stdskl_it_advance(stdit *it, stdsize num_advance);
+STDINLINE stdit * stdskl_it_prev(stdit *it);
+STDINLINE stdit * stdskl_it_retreat(stdit *it, stdsize num_retreat);
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
Modified: trunk/stdutil/src/stdutil/stdthread.h
===================================================================
--- trunk/stdutil/src/stdutil/stdthread.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdthread.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
@@ -22,22 +22,21 @@
#ifndef stdthread_h_2000_03_14_12_28_17_jschultz_at_cnds_jhu_edu
#define stdthread_h_2000_03_14_12_28_17_jschultz_at_cnds_jhu_edu
-#if defined(_REENTRANT) /* NOTE: these types and functions are only declared+defined when _REENTRANT is defined */
+#include <stdutil/stddefines.h>
-# include <stdutil/stddefines.h>
-
-# ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
-# endif
+#endif
typedef enum
{
+ STDMUTEX_NULL = (int) 0xe38a690cUL,
STDMUTEX_FAST = (int) 0xa720c831UL,
STDMUTEX_RCRSV = (int) 0x3f6c20deUL
} stdmutex_type;
-# include <stdutil/private/stdthread_p.h>
+#include <stdutil/private/stdthread_p.h>
/* Declare thread entry functions like this: void * STDTHREAD_FCN foo(void * arg); */
@@ -80,4 +79,3 @@
# endif
#endif
-#endif
Modified: trunk/stdutil/src/stdutil/stdtime.h
===================================================================
--- trunk/stdutil/src/stdutil/stdtime.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdtime.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,62 +1,62 @@
-/* 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 (jschultz at cnds.jhu.edu)
- * The Center for Networking and Distributed Systems
- * (CNDS - http://www.cnds.jhu.edu)
- */
-
-#ifndef stdtime_h_2003_12_18_18_09_56_jschultz_at_cnds_jhu_edu
-#define stdtime_h_2003_12_18_18_09_56_jschultz_at_cnds_jhu_edu
-
-#include <stdutil/stddefines.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct
-{
- stdint64 sec;
- stdint32 nano;
-
-} stdtime;
-
-typedef stdint64 stdtime64; /* time represented in nanoseconds */
-
-STDINLINE stdcode stdtime_now(stdtime *abs_time);
-STDINLINE stdtime stdtime_time64(stdtime64 src);
-
-STDINLINE int stdtime_cmp(stdtime ls, stdtime rs);
-STDINLINE int stdtime_sign(stdtime t);
-
-STDINLINE stdtime stdtime_neg(stdtime t);
-STDINLINE stdtime stdtime_add(stdtime ls, stdtime rs);
-STDINLINE stdtime stdtime_sub(stdtime ls, stdtime rs);
-
-STDINLINE stdcode stdtime64_now(stdtime64 *abs_time);
-STDINLINE stdtime64 stdtime64_time(stdtime t); /* conversion can silently over/under flow */
-
-/* sleep fcns */
-
-STDINLINE stdcode stdsleep(stdtime delta, stdtime * rem);
-STDINLINE stdcode stdsleep64(stdtime64 delta, stdtime64 * rem);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+/* Copyright (c) 2000-2009, 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 (jschultz at cnds.jhu.edu)
+ * The Center for Networking and Distributed Systems
+ * (CNDS - http://www.cnds.jhu.edu)
+ */
+
+#ifndef stdtime_h_2003_12_18_18_09_56_jschultz_at_cnds_jhu_edu
+#define stdtime_h_2003_12_18_18_09_56_jschultz_at_cnds_jhu_edu
+
+#include <stdutil/stddefines.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ stdint64 sec;
+ stdint32 nano;
+
+} stdtime;
+
+typedef stdint64 stdtime64; /* time represented in nanoseconds */
+
+STDINLINE stdcode stdtime_now(stdtime *abs_time);
+STDINLINE stdtime stdtime_time64(stdtime64 src);
+
+STDINLINE int stdtime_cmp(stdtime ls, stdtime rs);
+STDINLINE int stdtime_sign(stdtime t);
+
+STDINLINE stdtime stdtime_neg(stdtime t);
+STDINLINE stdtime stdtime_add(stdtime ls, stdtime rs);
+STDINLINE stdtime stdtime_sub(stdtime ls, stdtime rs);
+
+STDINLINE stdcode stdtime64_now(stdtime64 *abs_time);
+STDINLINE stdtime64 stdtime64_time(stdtime t); /* conversion can silently over/under flow */
+
+/* sleep fcns */
+
+STDINLINE stdcode stdsleep(stdtime delta, stdtime * rem);
+STDINLINE stdcode stdsleep64(stdtime64 delta, stdtime64 * rem);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Modified: trunk/stdutil/src/stdutil/stdutil.h
===================================================================
--- trunk/stdutil/src/stdutil/stdutil.h 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil/stdutil.h 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
Modified: trunk/stdutil/src/stdutil.c
===================================================================
--- trunk/stdutil/src/stdutil.c 2009-06-04 20:39:44 UTC (rev 422)
+++ trunk/stdutil/src/stdutil.c 2009-06-04 21:22:26 UTC (rev 423)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2000-2006, The Johns Hopkins University
+/* Copyright (c) 2000-2009, The Johns Hopkins University
* All rights reserved.
*
* The contents of this file are subject to a license (the ``License'').
@@ -219,8 +219,7 @@
defined (__BORLANDC__) || defined (__TURBOC__))
# define stdhcode_sfh_get16bits(d) ( *((const stduint16*)(d)) )
#else
-# define stdhcode_sfh_get16bits(d) ( ((stduint32) *((const stduint8 *)(d) + 1) << 8) | \
- (stduint32) *(const stduint8 *)(d) )
+# define stdhcode_sfh_get16bits(d) ( ((stduint32) *((const stduint8 *)(d) + 1) << 8) | (stduint32) *(const stduint8 *)(d) )
#endif
STDINLINE stduint32 stdhcode_sfh(const void * buf, stdsize buf_len)
More information about the Spread-cvs
mailing list