[Spread-cvs] commit: r281 - in trunk: include libspread stdutil/src

jschultz at spread.org jschultz at spread.org
Tue Jan 17 18:49:00 EST 2006


Author: jschultz
Date: 2006-01-17 18:49:00 -0500 (Tue, 17 Jan 2006)
New Revision: 281

Modified:
   trunk/include/fl.h
   trunk/libspread/fl.c
   trunk/libspread/fl_p.h
   trunk/stdutil/src/stddll.c
Log:
Final bugfixes for StdUtil/Flush.  Primary bugs were in doubly linked list of StdUtil, passing switched parameters and decrementing something and then using it rather than the other way around.



Modified: trunk/include/fl.h
===================================================================
--- trunk/include/fl.h	2005-09-23 17:09:01 UTC (rev 280)
+++ trunk/include/fl.h	2006-01-17 23:49:00 UTC (rev 281)
@@ -121,6 +121,3 @@
 #endif
 
 #endif
-
-
-

Modified: trunk/libspread/fl.c
===================================================================
--- trunk/libspread/fl.c	2005-09-23 17:09:01 UTC (rev 280)
+++ trunk/libspread/fl.c	2006-01-17 23:49:00 UTC (rev 281)
@@ -32,8 +32,6 @@
  *
  */
 
-
-
 #include <stdlib.h>
 
 #ifdef USE_DMALLOC
@@ -53,6 +51,36 @@
 
 /********************************* public flush layer interface ********************************/
 
+/* only does indention properly for single threaded programs right now */
+int std_stkfprintf(FILE *stream, int entering, const char *fmt, ...) {
+#define MAX_TAB_IN 4096
+#define INDENT 2
+  static int tab_in = 0;
+  static char tab[MAX_TAB_IN] = { 0 };
+  va_list ap;
+  int ret;
+
+  if (entering < 0) {
+    if ((tab_in -= INDENT) < 0)
+      stderr_abort("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);
+    memset(tab + tab_in, ' ', INDENT);
+    tab_in += INDENT;
+  } else
+    fprintf(stream, "%s", tab);
+
+  va_start(ap, fmt);
+  ret = vfprintf(stream, fmt, ap);
+  va_end(ap);
+
+  return ret;
+}
+
 int FL_lib_init(void)
 {
   static stdbool first_time = STDTRUE;  /* *TRY* to mitigate bad call race conditions to FL_lib_init */
@@ -80,9 +108,11 @@
 
   DEBUG(std_stkfprintf(stderr, 1, "FL_connect: daemon '%s', user '%s', priority %d\n",
 		       daemon, user, priority));
+
   if (FL_SP_version() < (float) 3.12) {             /* flush depends on the DROP_RECV semantics */
     DEBUG(std_stkfprintf(stderr, 0, "REJECT_VERSION: SP too old v%f < v3.12\n", FL_SP_version()));
     ret = REJECT_VERSION;
+
   } else if ((ret = SP_connect(daemon, user, priority, 1, mbox, private)) == ACCEPT_SESSION) {
     DEBUG(std_stkfprintf(stderr, 0, "mbox %d, private '%s'\n", *mbox, private));
 
@@ -113,7 +143,9 @@
     stdhash_insert(&glob_conns, 0, mbox, &conn);                   /* add mbox -> conn mapping */
     stdmutex_drop(&glob_conns_lock);                                     /* UNLOCK CONNS TAB */
   }
+
   DEBUG(std_stkfprintf(stderr, -1, "FL_connect: ret %d\n", ret));
+
   return ret;
 }
 

Modified: trunk/libspread/fl_p.h
===================================================================
--- trunk/libspread/fl_p.h	2005-09-23 17:09:01 UTC (rev 280)
+++ trunk/libspread/fl_p.h	2006-01-17 23:49:00 UTC (rev 281)
@@ -43,6 +43,7 @@
    they do (due to a system problem, such as malloc failing) they abort
    with an appropriate error message, line number, etc.
 */
+
 #include <fl.h>
 #include <scatp.h>
 #include <stdutil/stddefines.h>
@@ -51,9 +52,9 @@
 #include <stdutil/stddll.h>
 #include <stdutil/stdhash.h>
 
-#define FL_MAJOR_VERSION 1
+#define FL_MAJOR_VERSION 2
 #define FL_MINOR_VERSION 0
-#define FL_PATCH_VERSION 3
+#define FL_PATCH_VERSION 0
 
 #ifdef __cplusplus
 extern "C" {

Modified: trunk/stdutil/src/stddll.c
===================================================================
--- trunk/stdutil/src/stddll.c	2005-09-23 17:09:01 UTC (rev 280)
+++ trunk/stdutil/src/stddll.c	2006-01-17 23:49:00 UTC (rev 281)
@@ -125,7 +125,7 @@
   stddll_node * prev;
 
   if (num_ins == 0 ||
-      (ret = stddll_low_alloc_chain(l->vsize, num_ins, init, b, advnc, &first, &last)) != STDESUCCESS) {
+      (ret = stddll_low_alloc_chain(num_ins, l->vsize, init, b, advnc, &first, &last)) != STDESUCCESS) {
     goto stddll_low_insert_end;
   }
 
@@ -155,10 +155,11 @@
 {
   stddll_node * curr = erase_begin;
   stddll_node * prev;
+  stdsize       ne   = num_erase;
 
   erase_begin = erase_begin->prev;            /* get last node before erase region */
 
-  while (num_erase-- != 0) {
+  while (ne-- != 0) {
     STDBOUNDS_CHECK(curr != STDDLL_LEND(l));  /* check for an illegal erasure */
     prev = curr;
     curr = curr->next;
@@ -258,7 +259,8 @@
   /* error handling and return */
 
  stddll_construct_fail:
-  l->vsize = 0;  /* make STDDLL_IS_LEGAL(l) false */
+  l->end_node = NULL;
+  l->vsize    = 0;  /* make STDDLL_IS_LEGAL(l) false */
 
  stddll_construct_end:
   return ret;




More information about the Spread-cvs mailing list