[Spread-cvs] commit: r373 - in trunk: libspread stdutil stdutil/src
stdutil/src/stdutil stdutil/src/stdutil/private
jonathan at spread.org
jonathan at spread.org
Sun Nov 19 14:38:50 EST 2006
Author: jonathan
Date: 2006-11-19 14:38:49 -0500 (Sun, 19 Nov 2006)
New Revision: 373
Added:
trunk/stdutil/src/stdtest/
Modified:
trunk/libspread/fl.c
trunk/stdutil/README
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:
Update spread's stdutil to 1.0.0 beta6.
Fixup flush library to work with new stdutil library (changed error reporting functions)
Modified: trunk/libspread/fl.c
===================================================================
--- trunk/libspread/fl.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/libspread/fl.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -63,13 +63,13 @@
if (entering < 0) {
if ((tab_in -= INDENT) < 0)
- stderr_abort("popped off of top of empty trace print stack!\n");
+ stderr_output(STDERR_ABORT, 0,"popped off of top of empty trace print stack!\n");
memset(tab + tab_in, 0, INDENT);
fprintf(stream, "%sST Leave: ", tab);
} else if (entering > 0) {
fprintf(stream, "%sST Enter: ", tab);
if (tab_in + INDENT >= MAX_TAB_IN)
- stderr_abort("execution stack depth exceded MAX_TAB_IN: %d\n", MAX_TAB_IN);
+ stderr_output(STDERR_ABORT, 0,"execution stack depth exceded MAX_TAB_IN: %d\n", MAX_TAB_IN);
memset(tab + tab_in, ' ', INDENT);
tab_in += INDENT;
} else
@@ -121,7 +121,7 @@
DEBUG(std_stkfprintf(stderr, 0, "mbox %d, private '%s'\n", *mbox, private));
if ((conn = (fl_conn*) calloc(1, sizeof(fl_conn))) == 0)
- stderr_abort("(%s, %d): calloc(1, %u)\n", __FILE__, __LINE__, sizeof(fl_conn));
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): calloc(1, %u)\n", __FILE__, __LINE__, sizeof(fl_conn));
FL_MUTEX_construct(&conn->reserve_lock, STDMUTEX_FAST);
conn->reservations = 0;
@@ -225,7 +225,7 @@
if (ret == CONNECTION_CLOSED || ret == ILLEGAL_SESSION)
FL_disconnect(mbox);
else if (ret != ILLEGAL_GROUP)
- stderr_abort("(%s, %d): mbox %d: group %s: SP_join: unexpected error %d\n",
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): mbox %d: group %s: SP_join: unexpected error %d\n",
__FILE__, __LINE__, mbox, grp, ret);
}
} else {
@@ -258,10 +258,10 @@
if (ret == CONNECTION_CLOSED || ret == ILLEGAL_SESSION)
FL_disconnect(mbox);
else if (ret == ILLEGAL_GROUP)
- stderr_abort("(%s, %d): mbox %d: group %s: SP_leave: ILLEGAL_GROUP\n",
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): mbox %d: group %s: SP_leave: ILLEGAL_GROUP\n",
__FILE__, __LINE__, mbox, grp);
else
- stderr_abort("(%s, %d): mbox %d: group %s: SP_leave: unexpected error %d\n",
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): mbox %d: group %s: SP_leave: unexpected error %d\n",
__FILE__, __LINE__, mbox, grp, ret);
}
} else {
@@ -568,7 +568,7 @@
conn_name, group_name));
if ((group = (fl_group*) calloc(1, sizeof(fl_group))) == 0)
- stderr_abort("(%s, %d): calloc(1, %u)\n", __FILE__, __LINE__, sizeof(fl_group));
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): calloc(1, %u)\n", __FILE__, __LINE__, sizeof(fl_group));
strncpy(group->group, group_name, MAX_GROUP_NAME);
group->mstate = JOINING; /* not a JOINED member yet */
@@ -628,7 +628,7 @@
gid.id[0], gid.id[1], gid.id[2]));
if ((spc = (sp_memb_change*) calloc(1, sizeof(sp_memb_change))) == 0)
- stderr_abort("(%s, %d): calloc(1, %u)\n", __FILE__, __LINE__, sizeof(sp_memb_change));
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): calloc(1, %u)\n", __FILE__, __LINE__, sizeof(sp_memb_change));
spc->memb_info = create_view(gid);
spc->memb_mess_recvd = 0;
@@ -665,7 +665,7 @@
gid.id[0], gid.id[1], gid.id[2]));
if ((v = (view*) calloc(1, sizeof(view))) == 0)
- stderr_abort("(%s, %d): calloc(1, %u)\n", sizeof(view));
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): calloc(1, %u)\n", sizeof(view));
v->gid = gid;
v->memb_type = 0;
@@ -707,7 +707,7 @@
v->orig_num_membs = num_membs;
if ((v->membs_names = (char(*)[MAX_GROUP_NAME]) malloc(byte_size)) == 0)
- stderr_abort("(%s, %d): malloc (%d)\n", __FILE__, __LINE__, byte_size);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc (%d)\n", __FILE__, __LINE__, byte_size);
memcpy(v->membs_names, membs, byte_size);
for (membs = v->membs_names; num_membs--; ++membs) /* I set membs = v->membs_names!!! */
@@ -905,7 +905,7 @@
DEBUG(std_stkfprintf(stderr, 0, "UNABLE to deliver to user's parameters: BUFFERING!\n"));
if (bm == 0 || !bm_alloced) { /* if I need to alloc a gc_buff_mess */
if ((ret = (gc_buff_mess*) malloc(sizeof(gc_buff_mess))) == 0)
- stderr_abort("(%s, %d): malloc(%u)\n", __FILE__, __LINE__, sizeof(gc_buff_mess));
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%u)\n", __FILE__, __LINE__, sizeof(gc_buff_mess));
if (bm == 0) { /* if data was contained in user parameters */
DEBUG(std_stkfprintf(stderr, 0, "data was in user's parameters copying to buff mess\n"));
@@ -1045,7 +1045,7 @@
if ((groups_size = bm->num_groups * MAX_GROUP_NAME) != 0) {
if ((bm->groups = (char(*)[MAX_GROUP_NAME]) malloc(groups_size)) == 0)
- stderr_abort("(%s, %d): malloc(%u)\n", __FILE__, __LINE__, groups_size);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%u)\n", __FILE__, __LINE__, groups_size);
memcpy(bm->groups, groups, groups_size);
} else
bm->groups = 0;
@@ -1054,7 +1054,7 @@
get_scat_info(um, &bm->mess_len, &scat);
if (bm->mess_len != 0) {
if ((bm->mess = (char*) malloc(bm->mess_len)) == 0)
- stderr_abort("(%s, %d): malloc(%d)\n", __FILE__, __LINE__, bm->mess_len);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%d)\n", __FILE__, __LINE__, bm->mess_len);
err = scatp_begin(&um_pos, scat);
assert(err == 0);
@@ -1063,7 +1063,7 @@
} else
bm->mess = 0;
} else {
- stderr_abort("not sure about this path: if ever triggered think about it\n");
+ stderr_output(STDERR_ABORT, 0,"not sure about this path: if ever triggered think about it\n");
DEBUG(std_stkfprintf(stderr, 0, "copying an error message to a buffm: ret %d\n", um->ret));
bm->num_groups = 0;
bm->groups = 0;
@@ -1089,7 +1089,7 @@
if (ret != sizeof(group_id)) {
if (ret != CONNECTION_CLOSED && ret != ILLEGAL_SESSION)
- stderr_abort("(%s, %d): mbox %d: group %s: SP_multicast: unexpected error(%d)\n",
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): mbox %d: group %s: SP_multicast: unexpected error(%d)\n",
__FILE__, __LINE__, conn->mbox, group->group, ret);
} else
ret = 0; /* set to zero -> success */
@@ -1211,7 +1211,7 @@
if (ret >= scat->elements[scat->num_elements].len)
ret -= scat->elements[scat->num_elements].len;
else
- stderr_abort("(%s, %d): mbox %d: serv 0x%X: group '%s': SP_multicast returned %d\n",
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): mbox %d: serv 0x%X: group '%s': SP_multicast returned %d\n",
__FILE__, __LINE__, mbox, serv_type, grp, ret);
}
scat->elements[scat->num_elements] = senders_elem; /* restore modified elem */
@@ -1300,7 +1300,7 @@
/* actually allocate a new groups array to be used in re-receive */
if ((groups = m->new_grps = (char(*)[MAX_GROUP_NAME]) malloc(byte_size)) == 0)
- stderr_abort("(%s, %d): malloc(%u)\n", __FILE__, __LINE__, byte_size);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%u)\n", __FILE__, __LINE__, byte_size);
} else {
DEBUG(std_stkfprintf(stderr, 0, "User's GROUPS buff was big enough %d >= %d\n",
orig_max_groups, -*m->num_groups));
@@ -1323,7 +1323,7 @@
/* actually allocate the new mess buffer */
if ((scat->elements[0].buf = (char*) malloc(scat->elements[0].len)) == 0)
- stderr_abort("(%s, %d): malloc(%d)\n", __FILE__, __LINE__, scat->elements[0].len);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%d)\n", __FILE__, __LINE__, scat->elements[0].len);
} else
DEBUG(std_stkfprintf(stderr, 0, "No msg buffer error reported\n"));
@@ -1339,7 +1339,7 @@
/* if we had a buffer problem then code above or SP is buggy -> abort */
if (m->ret == GROUPS_TOO_SHORT || m->ret == BUFFER_TOO_SHORT)
- stderr_abort("(%s, %d): mbox %d: buggy SP_recv DROP_RECV ret %d: "
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): mbox %d: buggy SP_recv DROP_RECV ret %d: "
"max_groups %d: num_groups %d: scat_cap %ld: endian_mismatch %d\n",
__FILE__, __LINE__, m->mbox, m->ret, max_groups, *m->num_groups,
scat_capacity(scat), *m->endian_mismatch);
@@ -1532,7 +1532,7 @@
DEBUG(std_stkfprintf(stderr, 0, "Mess is addressed to my private group! Deliver!\n"));
deliver(conn, m, 0, 0); /* deliver msg immediately */
} else
- stderr_msg("(%s, %d): WARNING: a regular msg for a group of which I'm not a member!\n"
+ stderr_output(STDERR_RETURN, 0,"(%s, %d): WARNING: a regular msg for a group of which I'm not a member!\n"
"mbox %d: serv 0x%X: sender '%s': dst_grp '%s': mess_type %d\n", __FILE__,
__LINE__, m->mbox, *m->serv_type, m->sender, dst_grp, *m->mess_type);
} else if (Is_membership_mess(*m->serv_type)) { /* SP membership message */
@@ -1547,10 +1547,10 @@
else if (Is_caused_leave_mess(*m->serv_type))
handle_recv_self_leave_memb_mess(conn, group, m);
else
- stderr_abort("(%s, %d): mbox %d: recv_and_handle: unexpected membership 0x%X: "
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): mbox %d: recv_and_handle: unexpected membership 0x%X: "
"group '%s'\n", __FILE__, __LINE__, conn->mbox, *m->serv_type, m->sender);
} else
- stderr_abort("(%s, %d): mbox %d: recv_and_handle: unexpected service 0x%X: "
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): mbox %d: recv_and_handle: unexpected service 0x%X: "
"sender '%s'\n", __FILE__, __LINE__, conn->mbox, *m->serv_type, m->sender);
DEBUG(std_stkfprintf(stderr, -1, "recv_and_handle: ret %d (have_conn_lock)\n", (int) ret));
@@ -1611,7 +1611,7 @@
m->ret = (int) err;
break;
} else if (err != sizeof(group_id))
- stderr_abort("(%s, %d): SP_multicast unexpected return %d\n", __FILE__, __LINE__, err);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): SP_multicast unexpected return %d\n", __FILE__, __LINE__, err);
} else { /* buffer a FLUSH_REQ mess, update curr_change, etc. */
DEBUG(std_stkfprintf(stderr, 0, "Cascading Memberships(%lu) to handle!\n",
stddll_size(&group->memb_queue)));
@@ -1645,7 +1645,7 @@
assert(!spc->memb_mess_recvd ||
stdhash_size(&spc->flok_senders) < spc->memb_info->orig_num_membs);
break;
- default: stderr_abort("(%s, %d): impossible vstate %d\n", __FILE__, __LINE__, group->vstate);
+ default: stderr_output(STDERR_ABORT, 0,"(%s, %d): impossible vstate %d\n", __FILE__, __LINE__, group->vstate);
}
DEBUG(std_stkfprintf(stderr, -1, "handle_recv_flush_ok: mbox(%d, %p), group('%s', %p), %s\n",
conn->mbox, conn, group->group, group, state_str(group->vstate)));
@@ -1689,7 +1689,7 @@
DEBUG(std_stkfprintf(stderr, 0, "Ignoring FLUSH_RECV for vid %d %d %d while in AUTHORIZE!\n",
m->dst_gid.id[0], m->dst_gid.id[1], m->dst_gid.id[2]));
break;
- default: stderr_abort("(%s, %d): impossible vstate %d\n", __FILE__, __LINE__, group->vstate);
+ default: stderr_output(STDERR_ABORT, 0,"(%s, %d): impossible vstate %d\n", __FILE__, __LINE__, group->vstate);
}
DEBUG(std_stkfprintf(stderr, -1, "handle_recv_flush_recv: mbox(%d, %p), group('%s', %p), %s\n",
conn->mbox, conn, group->group, group, state_str(group->vstate)));
@@ -1713,13 +1713,13 @@
&hit, &um->sender))) {
DEBUG(std_stkfprintf(stderr, 0, "Recvd a vuln msg that needs to be POSTPONED!\n"));
if ((bm = (gc_buff_mess*) malloc(sizeof(gc_buff_mess))) == 0)
- stderr_abort("(%s, %d): malloc(%u)\n", __FILE__, __LINE__, sizeof(gc_buff_mess));
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%u)\n", __FILE__, __LINE__, sizeof(gc_buff_mess));
userm_to_buffm(bm, um);
stddll_push_back(&group->mess_queue, &bm);
break;
} else
- stderr_abort("'%s' Not in my next FL curr membs!\n", um->sender);
+ stderr_output(STDERR_ABORT, 0,"'%s' Not in my next FL curr membs!\n", um->sender);
} else
DEBUG(std_stkfprintf(stderr, 0, "Vuln msg not to next FL vid: should ignore below\n"));
} /* ELSE FALL THROUGH TO NORMAL CASES, BELOW (other case statements)!!!! */
@@ -1731,7 +1731,7 @@
} else
DEBUG(std_stkfprintf(stderr, 0, "Ignore reg mess from non group memb '%s'\n", um->sender));
break;
- default: stderr_abort("(%s, %d): impossible vstate %d\n", __FILE__, __LINE__, group->vstate);
+ default: stderr_output(STDERR_ABORT, 0,"(%s, %d): impossible vstate %d\n", __FILE__, __LINE__, group->vstate);
}
DEBUG(std_stkfprintf(stderr, -1, "handle_recv_reg_mess: mbox(%d, %p), group('%s', %p), %s\n",
conn->mbox, conn, group->group, group, state_str(group->vstate)));
@@ -1849,7 +1849,7 @@
m->delivered = 1;
}
break;
- default: stderr_abort("(%s, %d): impossible vstate %d\n", __FILE__, __LINE__, group->vstate);
+ default: stderr_output(STDERR_ABORT, 0,"(%s, %d): impossible vstate %d\n", __FILE__, __LINE__, group->vstate);
}
DEBUG(std_stkfprintf(stderr, -1, "handle_next_memb_change: mbox(%d, %p), group('%s', %p), "
"%s\n", conn->mbox, conn, group->group, group, state_str(group->vstate)));
@@ -1893,7 +1893,7 @@
/* I create a gc_buff_mess and then deliver it to the user for to simplify msg construction */
if ((memb_mess = (gc_buff_mess*) malloc(sizeof(gc_buff_mess))) == 0)
- stderr_abort("(%s, %d): malloc(%u)\n", sizeof(gc_buff_mess));
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%u)\n", sizeof(gc_buff_mess));
memb_mess->mbox = conn->mbox; /* set mbox, service type, group, and num_groups */
memb_mess->serv_type = new_fl_view->memb_type;
@@ -1903,7 +1903,7 @@
byte_size = memb_mess->num_groups * MAX_GROUP_NAME; /* fill in the groups array */
if ((memb_mess->groups = (char(*)[MAX_GROUP_NAME]) malloc(byte_size)) == 0)
- stderr_abort("(%s, %d): malloc(%u)\n", byte_size);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%u)\n", byte_size);
memcpy(memb_mess->groups, new_fl_view->membs_names, byte_size);
memb_mess->mess_type = new_fl_view->my_index; /* set mess_type and endian_mismatch */
@@ -1918,7 +1918,7 @@
memb_mess->mess_len = sizeof(group_id) + sizeof(int) + byte_size;
}
if ((memb_mess->mess = (char*) malloc(memb_mess->mess_len)) == 0) /* allocate body of msg */
- stderr_abort("(%s, %d): malloc(%u)\n", byte_size);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%u)\n", byte_size);
memcpy(memb_mess->mess, &new_fl_view->gid, sizeof(group_id)); /* fill in body: gid, num_vs */
memcpy(memb_mess->mess + sizeof(group_id), &size, sizeof(int));
@@ -2002,7 +2002,7 @@
if ((ret = (char*) malloc(MAX_GROUP_NAME)) == 0)
- stderr_abort("(%s, %d): malloc(%d)\n", __FILE__, __LINE__, MAX_GROUP_NAME);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%d)\n", __FILE__, __LINE__, MAX_GROUP_NAME);
memcpy( ret, m_info.changed_member, MAX_GROUP_NAME); /* read out joiner/leaver/disconnector */
ret[MAX_GROUP_NAME - 1] = 0; /* ensure null termination */
@@ -2018,7 +2018,7 @@
DEBUG(std_stkfprintf(stderr, 0, "Num_membs %u\n", num_membs));
if ((members = (char (*)[MAX_GROUP_NAME])malloc(num_membs * sizeof( *members ) ) ) == 0)
- stderr_abort("(%s, %d): malloc(%d)\n", __FILE__, __LINE__, num_membs * MAX_GROUP_NAME);
+ stderr_output(STDERR_ABORT, 0,"(%s, %d): malloc(%d)\n", __FILE__, __LINE__, num_membs * MAX_GROUP_NAME);
err = SP_scat_get_vs_set_members( m->scat_mess, &m_info.my_vs_set, members, num_membs);
assert(err == num_membs);
for (i = 0; i < num_membs; ++i) { /* remove members that came with me: leaves who left */
Modified: trunk/stdutil/README
===================================================================
--- trunk/stdutil/README 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/README 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,4 +1,4 @@
-This is the v1.0.0 (January 2006) distribution of the StdUtil library.
+This is the v1.0.0 (November 2006) distribution of the StdUtil library.
DESCRIPTION:
@@ -6,13 +6,16 @@
LICENSE:
-The license for use of the StdUtil library or its code is contained in
-the file STDUTIL_LICENSE found in the root of this distribution.
+The license for use of the StdUtil library and/or its code is
+contained in the file STDUTIL_LICENSE found in the root of this
+distribution.
DOCUMENTATION:
-HTML documentaiton is contained within the docs directory or can be
-accessed on the web at http://www.cnds.jhu.edu/software/stdutil/docs
+Documentation is currently incomplete but will be available in a
+subsequent release in HTML format in the docs directory. The
+documentation will also be available at
+http://www.cnds.jhu.edu/software/stdutil/docs
BUILDING:
@@ -23,8 +26,8 @@
Please report bugs and/or bug fixes to jschultz at cnds.jhu.edu with a
gdb compatible core (if possible) and any information that could help
-me fix the problem.
+fix the problem.
Enjoy,
John Schultz <jschultz at cnds.jhu.edu>
-January 2006
+November 2006
Modified: trunk/stdutil/src/Makefile.in
===================================================================
--- trunk/stdutil/src/Makefile.in 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/Makefile.in 2006-11-19 19:38:49 UTC (rev 373)
@@ -66,9 +66,10 @@
STATIC_LIBS=$(STATIC_NOTHREAD_RELEASE_LIB) $(STATIC_NOTHREAD_DEBUG_LIB) $(STATIC_THREADED_RELEASE_LIB) $(STATIC_THREADED_DEBUG_LIB)
SHARED_LIBS=$(SHARED_NOTHREAD_RELEASE_LIB) $(SHARED_NOTHREAD_DEBUG_LIB) $(SHARED_THREADED_RELEASE_LIB) $(SHARED_THREADED_DEBUG_LIB)
-ALLTARGETS=$(STATIC_LIBS) @SHARED_LIBS@
+ALLTARGETS=$(STATIC_LIBS) $(SHARED_LIBS)
########################################### BUILD RULES ########################################
+
standard: libdir @STANDARD_LIBS@
all: libdir $(ALLTARGETS)
@@ -106,8 +107,7 @@
rm -f *.o *.do *.to *.tdo *.lo *.ldo *.lto *.ltdo core* *~ $(ALLTARGETS) $(LIBDIR)/libstdutil.a $(LIBDIR)/libstdutil. at DYNLIBEXT@
distclean: clean
- rm -f stdutil/private/stdarch_autoconf.h
- rm -f Makefile
+ rm -f Makefile stdutil/private/stdarch_autoconf.h
uberclean: distclean
Modified: trunk/stdutil/src/stdarr.c
===================================================================
--- trunk/stdutil/src/stdarr.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdarr.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -26,6 +25,10 @@
#include <stdutil/stderror.h>
#include <stdutil/stdarr.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define STDARR_IS_LEGAL(arr) ((arr)->begin <= (arr)->end && \
(arr)->begin + (arr)->size * (arr)->vsize == (arr)->end && \
( ((arr)->cap != 0 && (arr)->begin != NULL) || ((arr)->cap == 0 && (arr)->begin == NULL) ) && \
@@ -50,9 +53,11 @@
stdsize delta = num_insert * arr->vsize;
stdsize after = (stdsize) (arr->end - it->val);
- if (nsize > arr->cap) { /* nsize > arr->cap -> nsize > 0 */
- stdsize ncap = (nsize << 1); /* nsize > 0 -> ncap > 0 */
- stdsize prior = (stdsize) (it->val - arr->begin);
+ /* reallocate if current capacity is not big enough */
+
+ if (nsize > stdarr_high_capacity(arr)) { /* nsize > X -> nsize > 0 */
+ stdsize ncap;
+ stdsize prior;
stdsize asize;
char * mem;
@@ -61,8 +66,10 @@
goto stdarr_low_insert_space_end;
}
+ ncap = (nsize << 1); /* nsize > 0 -> ncap > 0 */
ncap = STDMAX(ncap, STDARR_MIN_AUTO_ALLOC); /* ensure minimum allocation */
asize = ncap * arr->vsize; /* calc. alloc size in bytes */
+ prior = (stdsize) (it->val - arr->begin);
if ((mem = (char*) realloc(arr->begin, asize)) == NULL) {
ret = STDENOMEM;
@@ -76,8 +83,10 @@
it->val = mem + prior; /* relocate 'it' to insertion point */
}
- memmove(it->val + delta, it->val, after); /* shift mem */
+ /* shift memory to create space */
+ memmove(it->val + delta, it->val, after);
+
arr->end += delta;
arr->size = nsize;
@@ -98,13 +107,17 @@
char * it_end = it->val + delta;
stdsize after = (stdsize) (arr->end - it_end);
- memmove(it->val, it_end, after); /* shift mem */
+ /* shift memory to remove space */
+ memmove(it->val, it_end, after);
+
arr->end -= delta;
arr->size = nsize;
- if ((arr->opts & STDARR_OPTS_NO_AUTO_SHRINK) == 0 && /* shrinking wanted */
- nsize <= stdarr_low_capacity(arr) && /* shrinking necessary */
+ /* reallocate if current capacity is too big */
+
+ if ((arr->opts & STDARR_OPTS_NO_AUTO_SHRINK) == 0 && /* shrinking allowed */
+ nsize <= stdarr_low_capacity(arr) && /* shrinking needed */
arr->cap != STDARR_MIN_AUTO_ALLOC) { /* cap not at min alloc */
stdsize ncap = (nsize << 1);
@@ -122,7 +135,6 @@
arr->begin = mem; /* fill in new values for 'arr' */
arr->end = mem + prior + after;
- arr->size = nsize;
arr->cap = ncap;
} else { /* ncap == 0 -> go to zero */
@@ -133,11 +145,10 @@
arr->begin = NULL;
arr->end = NULL;
- arr->size = 0; /* implicitly already 0 */
arr->cap = 0;
}
- it->val = arr->begin + prior; /* relocate 'it' to new position */
+ it->val = arr->begin + prior; /* relocate 'it' to erasure point */
}
}
@@ -474,7 +485,7 @@
arr->size = STDMIN(arr->size, num_elems);
arr->begin = mem;
- arr->end = mem + arr->size * num_elems;
+ arr->end = mem + arr->size * arr->vsize;
} else {
@@ -880,3 +891,7 @@
return it;
}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stdcarr.c
===================================================================
--- trunk/stdutil/src/stdcarr.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdcarr.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -26,6 +25,10 @@
#include <stdutil/stderror.h>
#include <stdutil/stdcarr.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define STDCARR_IS_LEGAL(carr) (( ((carr)->cap != 0 && (carr)->base != NULL) || ((carr)->cap == 0 && (carr)->base == NULL) ) && \
(stdsize) ((carr)->endbase - (carr)->base) == (carr)->cap * (carr)->vsize && \
(carr)->begin >= (carr)->base && (carr)->begin <= (carr)->endbase && \
@@ -1447,3 +1450,7 @@
{
return (offset >= 0 ? stdcarr_it_advance(it, (stdsize) offset) : stdcarr_it_retreat(it, (stdsize) -offset));
}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stddll.c
===================================================================
--- trunk/stdutil/src/stddll.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stddll.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -26,6 +25,10 @@
#include <stdutil/stderror.h>
#include <stdutil/stddll.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define STDDLL_IS_LEGAL(l) ((l)->end_node != NULL && (l)->vsize != 0)
#define STDDLL_IT_IS_LEGAL(l, it) ((it)->end_node == (l)->end_node && (it)->vsize == (l)->vsize)
#define STDDLL_IT_IS_LEGAL2(it) ((it)->node != NULL && (it)->end_node != NULL && (it)->vsize != 0)
@@ -863,3 +866,7 @@
return it;
}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stderror.c
===================================================================
--- trunk/stdutil/src/stderror.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stderror.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -28,132 +27,67 @@
#include <stdutil/stddefines.h>
#include <stdutil/stderror.h>
-/************************************************************************************************
- * stderr_doit: Print a message to stderr and flush it. If errnoflag
- * is non-zero, also print error msg from errno. Return # of
- * characters written.
- *
- * NOTE: I'd prefer to use snprintf and vsnprintf but they aren't part of C89.
- ***********************************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
-STDINLINE static int stderr_doit(int errno_copy, const char *fmt, va_list ap)
-{
- char buf[STDERR_MAX_ERR_MSG_LEN + 1];
- int ret1;
- int ret2 = 0;
-
- ret1 = vsprintf(buf, fmt, ap); /* write the msg */
- ret1 = STDMAX(ret1, 0); /* zero out any error */
- buf[ret1] = 0; /* ensure termination */
-
- if (errno_copy != 0) {
- ret2 = sprintf(buf + ret1, ": %s", strerror(errno_copy)); /* write errno msg */
- ret2 = STDMAX(ret2, 0); /* zero out any error */
- buf[ret1 + ret2] = 0; /* ensure termination */
- }
-
- fprintf(stderr, "%s\r\n", buf);
- fflush(stderr);
-
- return ret1 + ret2;
-}
-
/************************************************************************************************
- * stderr_msg: Nonfatal error unrelated to a system call. Print a
- * message and return.
+ * stdutil_output: Output stream used for all library error msgs.
***********************************************************************************************/
-int stderr_msg(const char *fmt, ...)
-{
- int ret;
- va_list ap;
+FILE * stdutil_output = (FILE*) 0x1; /* magic number because stderr is not a constant */
- va_start(ap, fmt);
- ret = stderr_doit(0, fmt, ap);
- va_end(ap);
-
- return ret;
-}
-
/************************************************************************************************
- * stderr_ret: Nonfatal error related to a system call. Print a
- * message and return.
+ * stderr_output: Print a message to stdutil_output and flush it. If
+ * errno_copy is non-zero, also print error msg from strerror. Return
+ * # of characters written to output stream.
+ *
+ * NOTE: I'd prefer to use snprintf and vsnprintf but they aren't part of C89.
***********************************************************************************************/
-int stderr_ret(const char *fmt, ...)
+STDINLINE int stderr_output(stderr_action act, int errno_copy, const char *fmt, ...)
{
- int ret;
+ char buf[STDERR_MAX_ERR_MSG_LEN + 1];
+ int ret1 = 0;
+ int ret2 = 0;
va_list ap;
- va_start(ap, fmt);
- ret = stderr_doit(errno, fmt, ap);
- va_end(ap);
+ if (stdutil_output != NULL) {
+ va_start(ap, fmt);
- return ret;
-}
+ ret1 = vsprintf(buf, fmt, ap); /* write the msg */
+ ret1 = STDMAX(ret1, 0); /* zero out any error */
+ buf[ret1] = 0; /* ensure termination */
-/************************************************************************************************
- * stderr_quit: Fatal error unrelated to a system call. Print a
- * message and terminate.
- ***********************************************************************************************/
+ if (errno_copy != 0) {
+ ret2 = sprintf(buf + ret1, ": %s", strerror(errno_copy)); /* errno msg */
+ ret2 = STDMAX(ret2, 0); /* zero out */
+ buf[ret1 + ret2] = 0; /* termination */
+ }
-void stderr_quit(const char *fmt, ...)
-{
- va_list ap;
+ if (stdutil_output == (FILE*) 0x1) {
+ stdutil_output = stderr;
+ }
- va_start(ap, fmt);
- stderr_doit(0, fmt, ap);
- va_end(ap);
- exit(-1);
-}
+ fprintf(stdutil_output, "%s\r\n", buf);
+ fflush(stdutil_output);
-/************************************************************************************************
- * stderr_abort: Fatal error unrelated to a system call. Print a
- * message and abort.
- ***********************************************************************************************/
+ ret1 += 2; /* +2 for \r\n */
+ va_end(ap);
+ }
-void stderr_abort(const char *fmt, ...)
-{
- va_list ap;
+ if (act == STDERR_EXIT) {
+ exit(-1);
+ }
- va_start(ap, fmt);
- stderr_doit(0, fmt, ap);
- va_end(ap);
- abort();
-}
+ if (act == STDERR_ABORT) {
+ abort();
+ }
-/************************************************************************************************
- * stderr_sys: Fatal error related to a system call. Print a message
- * and terminate.
- ***********************************************************************************************/
-
-void stderr_sys(const char *fmt, ...)
-{
- int errno_cpy = errno;
- va_list ap;
-
- va_start(ap, fmt);
- stderr_doit(errno_cpy, fmt, ap);
- va_end(ap);
- exit(errno_cpy != 0 ? errno_cpy : -1);
+ return ret1 + ret2;
}
/************************************************************************************************
- * stderr_dump: Fatal error related to a system call. Print a message
- * and abort.
- ***********************************************************************************************/
-
-void stderr_dump(const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- stderr_doit(errno, fmt, ap);
- va_end(ap);
- abort();
-}
-
-/************************************************************************************************
* stderr_strerr: Returns a constant string in response to a StdUtil
* error code. Some StdUtil fcns can return system specific codes.
* In that case this fcn will return a "Unknown Error Code (system
@@ -209,3 +143,7 @@
return ret;
}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stdfd.c
===================================================================
--- trunk/stdutil/src/stdfd.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdfd.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -27,6 +26,10 @@
#include <stdutil/stderror.h>
#include <stdutil/stdfd.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if defined(_WIN32)
# include <io.h>
# include <sys/locking.h>
@@ -195,7 +198,7 @@
STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
- if (stdfd_flush(fd) != 0 || STDFSYNC(fd->fd) != 0) {
+ if (fflush(fd->stream) != 0 || STDFSYNC(fd->fd) != 0) {
ret = errno;
STDSAFETY_CHECK(ret != STDESUCCESS);
}
@@ -278,26 +281,34 @@
***********************************************************************************************/
STDINLINE stdcode stdfd_trylock(stdfd *fd)
+#if defined(_WIN32)
{
stdcode ret = STDESUCCESS;
STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-#if defined(_WIN32)
if (_locking(fd->fd, _LK_NBLCK, 1) != 0) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+}
#else
+{
struct flock lock = { 0 };
+ stdcode ret = STDESUCCESS;
lock.l_type = F_WRLCK;
if (fcntl(fd->fd, F_SETLK, &lock) != 0) {
-#endif
ret = errno;
- STDSAFETY_CHECK(ret != STDESUCCESS);
+ STDSAFETY_CHECK(ret != STDESUCCESS);
}
return ret;
}
+#endif
/************************************************************************************************
* stdfd_unlock: Release an advisory lock on a file descriptor's
@@ -305,26 +316,34 @@
***********************************************************************************************/
STDINLINE stdcode stdfd_unlock(stdfd *fd)
+#if defined(_WIN32)
{
stdcode ret = STDESUCCESS;
STDSAFETY_CHECK(fd->stream != NULL && fd->fd >= 0);
-#if defined(_WIN32)
if (_locking(fd->fd, _LK_UNLCK, 1) != 0) {
+ ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
+ }
+
+ return ret;
+}
#else
+{
struct flock lock = { 0 };
+ stdcode ret = STDESUCCESS;
lock.l_type = F_UNLCK;
-
+
if (fcntl(fd->fd, F_SETLK, &lock) != 0) {
-#endif
ret = errno;
STDSAFETY_CHECK(ret != STDESUCCESS);
- }
+ }
return ret;
-}
+ }
+#endif
/************************************************************************************************
* stdfile_unlink: Erase a file.
@@ -341,3 +360,7 @@
return ret;
}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stdhash.c
===================================================================
--- trunk/stdutil/src/stdhash.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdhash.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -27,6 +26,10 @@
#include <stdutil/stderror.h>
#include <stdutil/stdhash.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* stdhash is a table based implementation of a dictionary data
structure. In particular, it is an open-address, double hashing
hashtable (ref: Sedgewick: Algorithms in C, 3rd Ed.) that maps
@@ -1390,3 +1393,7 @@
return it;
}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stdit.c
===================================================================
--- trunk/stdutil/src/stdit.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdit.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -28,6 +27,10 @@
#include <stdutil/stdhash.h>
#include <stdutil/stdskl.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/************************************************************************************************
* stdit_get_type: Get the functional type of an iterator.
***********************************************************************************************/
@@ -53,7 +56,7 @@
break;
default:
- ret = 0;
+ ret = (stdit_type) 0;
STDEXCEPTION(uninitialized or corrupted iterator);
break;
}
@@ -628,3 +631,7 @@
return it;
}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stdskl.c
===================================================================
--- trunk/stdutil/src/stdskl.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdskl.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -28,6 +27,10 @@
#include <stdutil/stdtime.h>
#include <stdutil/stdskl.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* TODO: consider shrinking end_node's arrays when the top level
becomes empty (down to some minimum height like 4 or 5); this is
easy to detect: if the node being removed has the same height as
@@ -61,6 +64,12 @@
/************************************************************************************************
* stdskl_low_create_node: Create a node to be inserted into 'l.'
+ *
+ * For random height generation, a node is promoted to a higher height
+ * w/ 25% chance. The optimum promotion chance for a skiplist is
+ * somewhere between 28% and 37% depending on the analysis used. 25%
+ * gives nearly optimal performance while using less memory and not
+ * requiring excessive random bit generation.
***********************************************************************************************/
STDINLINE static stdskl_node *stdskl_low_create_node(stdskl *l, stdint8 height, const void *key, const void *val)
@@ -75,15 +84,15 @@
if (height == -1) { /* height generation requested */
stdbool keep_going = STDTRUE;
- for (; keep_going && height < STDSKL_MAX_HEIGHT; ++height) { /* count how many random "on" bits we get in a row */
+ for (; keep_going && height < STDSKL_MAX_HEIGHT; ++height) { /* loop while random height increases */
- if (l->bits_left <= 0) { /* out of random bits */
+ if (l->bits_left == 0) { /* out of random bits */
l->rand_bits = stdrand32(l->seed); /* generate 32 new ones */
l->bits_left = 32;
}
- keep_going = ((l->rand_bits & 0x3) == 0x3); /* keep going on a 3 out of 0-3 chance */
- l->bits_left -= 2; /* remove used bit */
+ keep_going = ((l->rand_bits & 0x3) == 0x3); /* continue loop w/ 25% chance */
+ l->bits_left -= 2; /* remove used bits */
l->rand_bits >>= 2;
}
}
@@ -100,8 +109,6 @@
mem_tot = STDARCH_PADDED_SIZE(mem_tot); /* pad memory for key */
key_off = mem_tot;
- /* TODO: might only pad the key size if vsize != 0 */
-
mem_tot += STDARCH_PADDED_SIZE(l->ksize); /* memory for key and padding for value */
val_off = mem_tot;
@@ -1179,3 +1186,7 @@
return it;
}
+
+#ifdef __cplusplus
+}
+#endif
Copied: trunk/stdutil/src/stdtest (from rev 372, vendor/stdutil/current/src/stdtest)
Modified: trunk/stdutil/src/stdthread.c
===================================================================
--- trunk/stdutil/src/stdthread.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdthread.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -36,6 +35,10 @@
# include <stdutil/stderror.h>
# include <stdutil/stdthread.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/************************************************************************************************
* stdthread_spawn: Create a new thread and start its execution.
***********************************************************************************************/
@@ -49,6 +52,7 @@
if ((thr = (HANDLE) _beginthreadex(NULL, 0, (unsigned(STDTHREAD_FCN*)(void*)) thr_fcn, fcn_arg, 0, &tid)) == NULL) {
ret = errno;
+ STDSAFETY_CHECK(ret != STDESUCCESS);
goto stdthread_spawn_end;
}
@@ -88,6 +92,7 @@
if (CloseHandle(thr) == 0) {
ret = (stdcode) GetLastError();
+ STDSAFETY_CHECK(ret != STDESUCCESS);
}
return ret;
@@ -135,6 +140,7 @@
stdthread_join_fail:
ret = (stdcode) GetLastError();
+ STDSAFETY_CHECK(ret != STDESUCCESS);
stdthread_join_end:
return ret;
@@ -314,7 +320,7 @@
woke_one = STDFALSE;
- for (loop_cnt = 20; loop_cnt != 0; --loop_cnt) { /* don't try to wake sleeper more than a constant # of times */
+ for (loop_cnt = 10; loop_cnt != 0; --loop_cnt) { /* don't try to wake sleeper more than a constant # of times */
err = ResumeThread(sleeper);
if (err == 1) {
@@ -326,6 +332,7 @@
} else if (err == (DWORD) -1) { /* error */
ret = (stdcode) GetLastError();
+ STDSAFETY_CHECK(ret != STDESUCCESS);
break;
} else if (err > MAXIMUM_SUSPEND_COUNT || (err > loop_cnt && inf_loop)) {
@@ -543,7 +550,7 @@
higher priority, then he would just loop forever waiting for this
thread to Suspend, which would never happen due to its lower
priority.
-x */
+ */
if (SuspendThread(curr_thread) == -1) {
abort();
@@ -573,6 +580,7 @@
stdmutex_fast_cond_wait_malloc:
CloseHandle(dup_handle);
+ STDSAFETY_CHECK(ret != STDESUCCESS);
stdmutex_fast_cond_wait_end:
if (reacquire) {
@@ -1181,6 +1189,10 @@
# endif
#endif
+#ifdef __cplusplus
+}
+#endif
+
#else
int stdthread_trnsl_dummy; /* avoids empty translation unit error #if !defined(_REENTRANT) */
#endif
Modified: trunk/stdutil/src/stdtime.c
===================================================================
--- trunk/stdutil/src/stdtime.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdtime.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -32,6 +31,10 @@
#include <stdutil/stderror.h>
#include <stdutil/stdtime.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* stdtime: sec == STDINT64_MIN -> nano == 0
sec < 0 -> -STD1BILLION < nano <= 0
sec == 0 -> -STD1BILLION < nano < STD1BILLION
@@ -234,7 +237,8 @@
}
/************************************************************************************************
- * stdsleep: Sleep for a period of time.
+ * stdsleep: Sleep for a period of time. On error, remndr will be
+ * filled if non-NULL.
***********************************************************************************************/
STDINLINE stdcode stdsleep(stdtime delta, stdtime *remndr)
@@ -324,3 +328,7 @@
return ret;
}
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/stdutil/src/stdutil/private/stdarch.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarch.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdarch.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/private/stdarch_autoconf.h.in
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarch_autoconf.h.in 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdarch_autoconf.h.in 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/private/stdarch_wintel32.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarch_wintel32.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdarch_wintel32.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/private/stdarr_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdarr_p.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdarr_p.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -29,7 +28,7 @@
begin - address of the lowest byte of the array's alloc'ed memory, NULL if none alloc'ed
end - address of the first byte past the last value stored in the array, same as begin if empty
- size - number of values this array is storing
+ size - number of values this array is storing [(end - begin) / vsize]
cap - number of values that can legally fit in alloc'ed memory
vsize - size, in bytes, of the type of values this array is storing
opts - user flags affecting default operation
Modified: trunk/stdutil/src/stdutil/private/stdcarr_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdcarr_p.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdcarr_p.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -27,7 +26,7 @@
or vector. Stores element by value, contiguously in
memory modulo the size of the array. Always maintains at
least one empty element in a non-empty array to act as a
- sentinel position and to remove the amibiguous of case
+ sentinel position and to remove the amibiguous case of
when begin == end -- Is the array full or empty? In
particular, this allows for the test begin <= end ? (data
doesn't wrap around) : (data wraps around)
Modified: trunk/stdutil/src/stdutil/private/stddll_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stddll_p.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stddll_p.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/private/stdhash_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdhash_p.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdhash_p.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/private/stdit_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdit_p.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdit_p.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/private/stdskl_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdskl_p.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdskl_p.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/private/stdthread_p.h
===================================================================
--- trunk/stdutil/src/stdutil/private/stdthread_p.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/private/stdthread_p.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stdarr.h
===================================================================
--- trunk/stdutil/src/stdutil/stdarr.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdarr.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stdcarr.h
===================================================================
--- trunk/stdutil/src/stdutil/stdcarr.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdcarr.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stddefines.h
===================================================================
--- trunk/stdutil/src/stdutil/stddefines.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stddefines.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stddll.h
===================================================================
--- trunk/stdutil/src/stdutil/stddll.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stddll.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stderror.h
===================================================================
--- trunk/stdutil/src/stdutil/stderror.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stderror.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -32,25 +31,33 @@
extern "C" {
#endif
+/* NOTE: redefining this limit only has an effect at compile time of the stdutil library */
+
#ifndef STDERR_MAX_ERR_MSG_LEN
-/* NOTE: redefining this variable only has an effect at compile time of the stdutil library */
# define STDERR_MAX_ERR_MSG_LEN 1024
#endif
+/* stderr output stream (can be set to NULL to squelch all stdutil output) */
+
+extern FILE * stdutil_output /* = stderr */;
+
/* stderr error routines */
-int stderr_msg(const char *fmt, ...);
-int stderr_ret(const char *fmt, ...);
-void stderr_quit(const char *fmt, ...);
-void stderr_abort(const char *fmt, ...);
-void stderr_sys(const char *fmt, ...);
-void stderr_dump(const char *fmt, ...);
+typedef enum
+{
+ STDERR_RETURN,
+ STDERR_EXIT,
+ STDERR_ABORT
+} stderr_action;
+
+int stderr_output(stderr_action act, int errno_cpy, const char *fmt, ...);
+
STDINLINE const char *stderr_strerr(stdcode code);
/* error macros */
-#define STDEXCEPTION(x) stderr_abort("STDEXCEPTION: File: %s; Line: %d: %s", __FILE__, __LINE__, #x)
+#define STDEXCEPTION(x) stderr_output(STDERR_ABORT, 0, "STDEXCEPTION: File: %s; Line: %d: %s", __FILE__, __LINE__, #x)
#if defined(STDSAFETY_CHECKS)
# define STDSAFETY_CHECK(x) { if (!(x)) { STDEXCEPTION(safety check (x) failed); } }
Modified: trunk/stdutil/src/stdutil/stdfd.h
===================================================================
--- trunk/stdutil/src/stdutil/stdfd.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdfd.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stdhash.h
===================================================================
--- trunk/stdutil/src/stdutil/stdhash.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdhash.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stdit.h
===================================================================
--- trunk/stdutil/src/stdutil/stdit.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdit.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stdskl.h
===================================================================
--- trunk/stdutil/src/stdutil/stdskl.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdskl.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stdthread.h
===================================================================
--- trunk/stdutil/src/stdutil/stdthread.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdthread.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stdtime.h
===================================================================
--- trunk/stdutil/src/stdutil/stdtime.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdtime.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil/stdutil.h
===================================================================
--- trunk/stdutil/src/stdutil/stdutil.h 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil/stdutil.h 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
Modified: trunk/stdutil/src/stdutil.c
===================================================================
--- trunk/stdutil/src/stdutil.c 2006-11-19 15:19:18 UTC (rev 372)
+++ trunk/stdutil/src/stdutil.c 2006-11-19 19:38:49 UTC (rev 373)
@@ -1,8 +1,7 @@
-/* Copyright (c) 2000-2005, The Johns Hopkins University
+/* Copyright (c) 2000-2006, The Johns Hopkins University
* All rights reserved.
*
- * The contents of this file are subject to a license (the ``License'')
- * that is the exact equivalent of the BSD license as of July 23, 1999.
+ * The contents of this file are subject to a license (the ``License'').
* You may not use this file except in compliance with the License. The
* specific language governing the rights and limitations of the License
* can be found in the file ``STDUTIL_LICENSE'' found in this
@@ -29,6 +28,10 @@
#include <stdutil/stdtime.h>
#include <stdutil/stdutil.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/************************************************************************************************
* stdstrcpy: Like C's strcpy, but returns strlen(dst) instead.
***********************************************************************************************/
@@ -159,7 +162,7 @@
* span several buffers. Preferably, but not required, tot_len would
* equal the total length of the buffers to be hcoded. If the total
* length is unknown (or you simply don't want to compute it), then
- * consistently use the same arbitrary constant (e.g. - 0) when
+ * consistently use the same arbitrary constant (e.g. - 0x1) when
* computing the hcode for those objects.
***********************************************************************************************/
@@ -216,7 +219,7 @@
defined (__BORLANDC__) || defined (__TURBOC__))
# define stdhcode_sfh_get16bits(d) ( *((const stduint16*)(d)) )
#else
-# define stdhcode_sfh_get16bits(d) ( ((stduint16) *((const stduint8 *)(d) + 1) << 8) + *(const stduint8 *)(d) )
+# define stdhcode_sfh_get16bits(d) ( ((stduint32) *((const stduint8 *)(d) + 1) << 8) | *(const stduint32 *)(d) )
#endif
STDINLINE stduint32 stdhcode_sfh(const void * buf, stdsize buf_len)
@@ -263,9 +266,10 @@
ret ^= ret << 3;
ret += ret >> 5;
- ret ^= ret << 2;
- ret += ret >> 15;
- ret ^= ret << 10;
+ ret ^= ret << 4;
+ ret += ret >> 17;
+ ret ^= ret << 25;
+ ret += ret >> 6;
return ret;
}
@@ -275,7 +279,7 @@
* span several buffers. Preferably, but not required, tot_len would
* equal the total length of the buffers to be hash coded. If the total
* length is unknown (or you simply don't want to compute it), then
- * consistently use the same arbitrary constant (e.g. - 0) when
+ * consistently use the same arbitrary constant (e.g. - 0x1) when
* computing the hcode for those objects.
*
* NOTE: The incremental versions of sfh depend on how you partition
@@ -351,10 +355,11 @@
ret ^= ret << 3;
ret += ret >> 5;
- ret ^= ret << 2;
- ret += ret >> 15;
- ret ^= ret << 10;
-
+ ret ^= ret << 4;
+ ret += ret >> 17;
+ ret ^= ret << 25;
+ ret += ret >> 6;
+
*hsh = ret;
}
@@ -1047,3 +1052,7 @@
return up_pow2; /* up_pow2 in range [1.5x, 3x) */
}
+
+#ifdef __cplusplus
+}
+#endif
More information about the Spread-cvs
mailing list