chiark / gitweb /
Change naming to match newer mLib conventions. 1.3.2
authormdw <mdw>
Wed, 19 May 1999 20:27:11 +0000 (20:27 +0000)
committermdw <mdw>
Wed, 19 May 1999 20:27:11 +0000 (20:27 +0000)
exc.c
sub.c
trace.c
track.c

diff --git a/exc.c b/exc.c
index 7ef3812f9d90a62bb4cdab919f6e2f63391fdaed..0b5cf3ed87f4fdb1560da2f17f78742fc9536829 100644 (file)
--- a/exc.c
+++ b/exc.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
 /* -*-c-*-
  *
- * $Id: exc.c,v 1.4 1999/05/17 20:35:30 mdw Exp $
+ * $Id: exc.c,v 1.5 1999/05/19 20:27:11 mdw Exp $
  *
  * Structured exception handling in C
  *
  *
  * Structured exception handling in C
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: exc.c,v $
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: exc.c,v $
+ * Revision 1.5  1999/05/19 20:27:11  mdw
+ * Change naming to match newer mLib conventions.
+ *
  * Revision 1.4  1999/05/17 20:35:30  mdw
  * Output uncaught exception types in hex, because they're easier to
  * translate that way.
  * Revision 1.4  1999/05/17 20:35:30  mdw
  * Output uncaught exception types in hex, because they're easier to
  * translate that way.
@@ -57,7 +60,7 @@ __exc_hnd *__exc_list = 0;
 
 /*----- Functions ---------------------------------------------------------*/
 
 
 /*----- Functions ---------------------------------------------------------*/
 
-/* --- @exc__duff@ --- *
+/* --- @duff@ --- *
  *
  * Arguments:  @exc_extype type@ = type of duff exception
  *             @exc_exval val@ = extra data supplied
  *
  * Arguments:  @exc_extype type@ = type of duff exception
  *             @exc_exval val@ = extra data supplied
@@ -67,18 +70,18 @@ __exc_hnd *__exc_list = 0;
  * Use:                Default handler when everything goes wrong.
  */
 
  * Use:                Default handler when everything goes wrong.
  */
 
-static void exc__duff(exc_extype type, exc_exval val)
+static void duff(exc_extype type, exc_exval val)
 {
   fprintf(stderr, "fatal error: uncaught exception (type = %lx)\n", type);
   abort();
 }
 
 {
   fprintf(stderr, "fatal error: uncaught exception (type = %lx)\n", type);
   abort();
 }
 
-/* --- @exc__duffproc@ --- *
+/* --- @duffproc@ --- *
  *
  * Current handler when there are no more exceptions left.
  */
 
  *
  * Current handler when there are no more exceptions left.
  */
 
-static exc__uncaught exc__duffproc = exc__duff;
+static exc__uncaught duffproc = duff;
 
 /* --- @exc_uncaught@ --- *
  *
 
 /* --- @exc_uncaught@ --- *
  *
@@ -91,9 +94,9 @@ static exc__uncaught exc__duffproc = exc__duff;
 
 exc__uncaught exc_uncaught(exc__uncaught proc)
 {
 
 exc__uncaught exc_uncaught(exc__uncaught proc)
 {
-  exc__uncaught p = exc__duffproc;
+  exc__uncaught p = duffproc;
   if (proc)
   if (proc)
-    exc__duffproc = proc;
+    duffproc = proc;
   return (p);
 }
 
   return (p);
 }
 
@@ -146,7 +149,7 @@ void __exc_rethrow(exc_extype type, exc_exval val)
 {
   __exc_hnd *p = __exc_list;
   if (!p)
 {
   __exc_hnd *p = __exc_list;
   if (!p)
-    exc__duffproc(type, val);
+    duffproc(type, val);
   p->type = type;
   p->val = val;
   __exc_list = p->next;
   p->type = type;
   p->val = val;
   __exc_list = p->next;
diff --git a/sub.c b/sub.c
index bb264a2ef95498d1dd49407480b8efdb58cfd7f4..57ee19499608cb9e59601ac1f531095f77482ea0 100644 (file)
--- a/sub.c
+++ b/sub.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
 /* -*-c-*-
  *
- * $Id: sub.c,v 1.4 1999/05/13 22:48:55 mdw Exp $
+ * $Id: sub.c,v 1.5 1999/05/19 20:27:11 mdw Exp $
  *
  * Allocation of known-size blocks
  *
  *
  * Allocation of known-size blocks
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: sub.c,v $
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: sub.c,v $
+ * Revision 1.5  1999/05/19 20:27:11  mdw
+ * Change naming to match newer mLib conventions.
+ *
  * Revision 1.4  1999/05/13 22:48:55  mdw
  * Change `-ise' to `-ize' throughout.
  *
  * Revision 1.4  1999/05/13 22:48:55  mdw
  * Change `-ise' to `-ize' throughout.
  *
 
 /*----- Static variables --------------------------------------------------*/
 
 
 /*----- Static variables --------------------------------------------------*/
 
-static void *sub__bins[SUB_BINS];
-static size_t sub__sizes[SUB_BINS];
+static void *bins[SUB_BINS];
+static size_t sizes[SUB_BINS];
 
 /*----- Main code ---------------------------------------------------------*/
 
 
 /*----- Main code ---------------------------------------------------------*/
 
@@ -161,11 +164,11 @@ void *sub_alloc(size_t s)
 
   /* --- If the bin is empty, find some memory --- */
 
 
   /* --- If the bin is empty, find some memory --- */
 
-  if (!sub__bins[bin]) {
+  if (!bins[bin]) {
     char *p, *q;
 
     char *p, *q;
 
-    p = xmalloc(sub__sizes[bin]);
-    q = p + sub__sizes[bin];
+    p = xmalloc(sizes[bin]);
+    q = p + sizes[bin];
 
     s = SUB_BINSZ(bin);
 
 
     s = SUB_BINSZ(bin);
 
@@ -177,13 +180,13 @@ void *sub_alloc(size_t s)
       *(void **)q = q + s;
     }
 
       *(void **)q = q + s;
     }
 
-    sub__bins[bin] = p;
+    bins[bin] = p;
   }
 
   /* --- Extract the first block in the list --- */
 
   }
 
   /* --- Extract the first block in the list --- */
 
-  p = sub__bins[bin];
-  sub__bins[bin] = *(void **)p;
+  p = bins[bin];
+  bins[bin] = *(void **)p;
   return (p);
 }
 
   return (p);
 }
 
@@ -204,8 +207,8 @@ void sub_free(void *p, size_t s)
   if (bin >= SUB_BINS)
     free(p);
   else {
   if (bin >= SUB_BINS)
     free(p);
   else {
-    *(void **)p = sub__bins[bin];
-    sub__bins[bin] = p;
+    *(void **)p = bins[bin];
+    bins[bin] = p;
   }
 }
 
   }
 }
 
@@ -225,7 +228,7 @@ void sub_init(void)
   /* --- Initialize the sizes bins --- */
 
   for (i = 1; i < SUB_BINS; i++) {
   /* --- Initialize the sizes bins --- */
 
   for (i = 1; i < SUB_BINS; i++) {
-    sub__sizes[i] = ((SUB_CHUNK + SUB_BINSZ(i) - 1) /
+    sizes[i] = ((SUB_CHUNK + SUB_BINSZ(i) - 1) /
                     SUB_BINSZ(i) * SUB_BINSZ(i));
   }
 }
                     SUB_BINSZ(i) * SUB_BINSZ(i));
   }
 }
diff --git a/trace.c b/trace.c
index d5bdcb7a2b3cf9403ec2aedaf4f3c6663727a767..c1688ef420edd4190090baaae0db56fc319aff6b 100644 (file)
--- a/trace.c
+++ b/trace.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
 /* -*-c-*-
  *
- * $Id: trace.c,v 1.3 1999/05/06 19:51:35 mdw Exp $
+ * $Id: trace.c,v 1.4 1999/05/19 20:27:11 mdw Exp $
  *
  * Tracing functions for debugging
  *
  *
  * Tracing functions for debugging
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: trace.c,v $
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: trace.c,v $
+ * Revision 1.4  1999/05/19 20:27:11  mdw
+ * Change naming to match newer mLib conventions.
+ *
  * Revision 1.3  1999/05/06 19:51:35  mdw
  * Reformatted the LGPL notice a little bit.
  *
  * Revision 1.3  1999/05/06 19:51:35  mdw
  * Reformatted the LGPL notice a little bit.
  *
@@ -58,8 +61,8 @@
 
 /*----- Private state information -----------------------------------------*/
 
 
 /*----- Private state information -----------------------------------------*/
 
-static FILE *trace__fp = 0;            /* Where does debugging go? */
-static unsigned int trace__lvl = 0;    /* How much tracing gets done? */
+static FILE *tracefp = 0;              /* Where does debugging go? */
+static unsigned int tracelvl = 0;      /* How much tracing gets done? */
 
 /*----- Functions provided ------------------------------------------------*/
 
 
 /*----- Functions provided ------------------------------------------------*/
 
@@ -80,11 +83,11 @@ void trace(unsigned int l, const char *f, ...)
   if ((l & tracing()) == 0)
     return;
   va_start(ap, f);
   if ((l & tracing()) == 0)
     return;
   va_start(ap, f);
-  fprintf(trace__fp, "*** %s: ", QUIS);
-  vfprintf(trace__fp, f, ap);
+  fprintf(tracefp, "*** %s: ", QUIS);
+  vfprintf(tracefp, f, ap);
   va_end(ap);
   va_end(ap);
-  putc('\n', trace__fp);
-  fflush(trace__fp);
+  putc('\n', tracefp);
+  fflush(tracefp);
 }
 
 /* --- @trace_block@ --- *
 }
 
 /* --- @trace_block@ --- *
@@ -113,28 +116,28 @@ void trace_block(unsigned int l, const char *s, const void *b, size_t sz)
 
   /* --- Now start work --- */
 
 
   /* --- Now start work --- */
 
-  fprintf(trace__fp, "*** %s: %s\n", QUIS, s);
+  fprintf(tracefp, "*** %s: %s\n", QUIS, s);
 
   while (sz) {
 
   while (sz) {
-    fprintf(trace__fp, "*** %s:   %08lx : ", QUIS, o);
+    fprintf(tracefp, "*** %s:   %08lx : ", QUIS, o);
     for (i = 0; i < 8; i++) {
       if (i < sz)
     for (i = 0; i < 8; i++) {
       if (i < sz)
-       fprintf(trace__fp, "%02x ", p[i]);
+       fprintf(tracefp, "%02x ", p[i]);
       else
       else
-       fputs("** ", trace__fp);
+       fputs("** ", tracefp);
     }
     }
-    fputs(": ", trace__fp);
+    fputs(": ", tracefp);
     for (i = 0; i < 8; i++) {
       if (i < sz)
     for (i = 0; i < 8; i++) {
       if (i < sz)
-       fputc(isprint(p[i]) ? p[i] : '.', trace__fp);
+       fputc(isprint(p[i]) ? p[i] : '.', tracefp);
       else
       else
-       fputc('*', trace__fp);
+       fputc('*', tracefp);
     }
     }
-    fputc('\n', trace__fp);
+    fputc('\n', tracefp);
     c = (sz >= 8) ? 8 : sz;
     sz -= c, p += c, o += c;
   }
     c = (sz >= 8) ? 8 : sz;
     sz -= c, p += c, o += c;
   }
-  fflush(trace__fp);
+  fflush(tracefp);
 }
 
 /* --- @trace_on@ --- *
 }
 
 /* --- @trace_on@ --- *
@@ -149,9 +152,9 @@ void trace_block(unsigned int l, const char *s, const void *b, size_t sz)
 
 void trace_on(FILE *fp, unsigned int l)
 {
 
 void trace_on(FILE *fp, unsigned int l)
 {
-  trace__fp = fp;
-  if (!trace__lvl)
-    trace__lvl = l;
+  tracefp = fp;
+  if (!tracelvl)
+    tracelvl = l;
 }
 
 /* --- @trace_setLevel@ --- *
 }
 
 /* --- @trace_setLevel@ --- *
@@ -165,7 +168,7 @@ void trace_on(FILE *fp, unsigned int l)
 
 void trace_setLevel(unsigned int l)
 {
 
 void trace_setLevel(unsigned int l)
 {
-  trace__lvl = l;
+  tracelvl = l;
 }
 
 /* --- @tracing@ --- *
 }
 
 /* --- @tracing@ --- *
@@ -179,7 +182,7 @@ void trace_setLevel(unsigned int l)
 
 unsigned int tracing(void)
 {
 
 unsigned int tracing(void)
 {
-  return (trace__fp ? trace__lvl : 0u);
+  return (tracefp ? tracelvl : 0u);
 }
 
 /*----- That's all, folks -------------------------------------------------*/
 }
 
 /*----- That's all, folks -------------------------------------------------*/
diff --git a/track.c b/track.c
index 52e800dc518a267de95564e68576b75b2dca075c..10da09bd7474fd89367c136ec2207a86a10fa12d 100644 (file)
--- a/track.c
+++ b/track.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
 /* -*-c-*-
  *
- * $Id: track.c,v 1.3 1999/05/06 19:51:36 mdw Exp $
+ * $Id: track.c,v 1.4 1999/05/19 20:27:11 mdw Exp $
  *
  * Tracing functions for debugging
  *
  *
  * Tracing functions for debugging
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: track.c,v $
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: track.c,v $
+ * Revision 1.4  1999/05/19 20:27:11  mdw
+ * Change naming to match newer mLib conventions.
+ *
  * Revision 1.3  1999/05/06 19:51:36  mdw
  * Reformatted the LGPL notice a little bit.
  *
  * Revision 1.3  1999/05/06 19:51:36  mdw
  * Reformatted the LGPL notice a little bit.
  *
  * This gets prefixed to every block I manage.
  */
 
  * This gets prefixed to every block I manage.
  */
 
-typedef union track__block {
+typedef union block {
   struct {
   struct {
-    union track__block *next;          /* Link to previous block */
-    union track__block *prev;          /* Link to next block */
+    union block *next;                 /* Link to previous block */
+    union block *prev;                 /* Link to next block */
     size_t sz;                         /* Size of the block */
     const char *ctx;                   /* Pointer to allocating context */
   } x;                                 /* Main data area */
   long double _ld;                     /* Long double for alignment */
   void *_p;                            /* Void pointer for alignment */
     size_t sz;                         /* Size of the block */
     const char *ctx;                   /* Pointer to allocating context */
   } x;                                 /* Main data area */
   long double _ld;                     /* Long double for alignment */
   void *_p;                            /* Void pointer for alignment */
-} track__block;
+} block;
 
 /*----- Private state -----------------------------------------------------*/
 
 /* --- Tracking memory usage --- */
 
 
 /*----- Private state -----------------------------------------------------*/
 
 /* --- Tracking memory usage --- */
 
-static unsigned int track__used = 0;   /* Count of bytes occupied */
-static track__block *track__list;      /* List of allocated blocks */
+static unsigned int used = 0;          /* Count of bytes occupied */
+static block *list;                    /* List of allocated blocks */
 
 /* --- Trace level for verbose messages --- */
 
 
 /* --- Trace level for verbose messages --- */
 
-static unsigned int track__vLevel = 0;
+static unsigned int vLevel = 0;
 
 /* --- Context tracking --- */
 
 
 /* --- Context tracking --- */
 
-static track_ctx track__baseContext = {
+static track_ctx baseContext = {
   0, "[unknown context]"
 };
 
   0, "[unknown context]"
 };
 
-static track_ctx *track__context = &track__baseContext;
+static track_ctx *context = &baseContext;
 
 /*----- Functions provided ------------------------------------------------*/
 
 
 /*----- Functions provided ------------------------------------------------*/
 
@@ -106,7 +109,7 @@ static track_ctx *track__context = &track__baseContext;
 
 void track_setLevel(unsigned int l)
 {
 
 void track_setLevel(unsigned int l)
 {
-  track__vLevel = l;
+  vLevel = l;
 }
 
 /* --- @track_pushContext@ --- *
 }
 
 /* --- @track_pushContext@ --- *
@@ -120,8 +123,8 @@ void track_setLevel(unsigned int l)
 
 void track_pushContext(track_ctx *ctx)
 {
 
 void track_pushContext(track_ctx *ctx)
 {
-  ctx->next = track__context;
-  track__context = ctx;
+  ctx->next = context;
+  context = ctx;
 }
 
 /* --- @track_popContext@ --- *
 }
 
 /* --- @track_popContext@ --- *
@@ -135,7 +138,7 @@ void track_pushContext(track_ctx *ctx)
 
 void track_popContext(track_ctx *ctx)
 {
 
 void track_popContext(track_ctx *ctx)
 {
-  track__context = ctx->next;
+  context = ctx->next;
 }
 
 /* --- @track_malloc@ --- *
 }
 
 /* --- @track_malloc@ --- *
@@ -149,20 +152,20 @@ void track_popContext(track_ctx *ctx)
 
 void *track_malloc(size_t sz)
 {
 
 void *track_malloc(size_t sz)
 {
-  track__block *q = (malloc)(sz + sizeof(track__block));
+  block *q = (malloc)(sz + sizeof(block));
   if (q) {
   if (q) {
-    track__used += sz;
-    if (track__vLevel) {
-      trace(track__vLevel, "(track) allocated %lu at %p in %s",
-           (unsigned long)sz, (void *)(q + 1), track__context->s);
+    used += sz;
+    if (vLevel) {
+      trace(vLevel, "(track) allocated %lu at %p in %s",
+           (unsigned long)sz, (void *)(q + 1), context->s);
     }
     q->x.sz = sz;
     }
     q->x.sz = sz;
-    q->x.next = track__list;
+    q->x.next = list;
     q->x.prev = 0;
     q->x.prev = 0;
-    q->x.ctx = track__context->s;
+    q->x.ctx = context->s;
     if (q->x.next)
       q->x.next->x.prev = q;
     if (q->x.next)
       q->x.next->x.prev = q;
-    track__list = q;
+    list = q;
     return (q + 1);
   }
   return (0);
     return (q + 1);
   }
   return (0);
@@ -179,23 +182,23 @@ void *track_malloc(size_t sz)
 
 void track_free(void *p)
 {
 
 void track_free(void *p)
 {
-  track__block *q;
+  block *q;
 
   if (!p)
     return;
 
   if (!p)
     return;
-  q = (track__block *)p - 1;
-  if (track__vLevel) {
-    trace(track__vLevel, "(track) freed %lu at %p for %s in %s",
+  q = (block *)p - 1;
+  if (vLevel) {
+    trace(vLevel, "(track) freed %lu at %p for %s in %s",
          (unsigned long)q->x.sz, (void *)(q + 1),
          (unsigned long)q->x.sz, (void *)(q + 1),
-         q->x.ctx, track__context->s);
+         q->x.ctx, context->s);
   }
   if (q->x.next)
     q->x.next->x.prev = q->x.prev;
   if (q->x.prev)
     q->x.prev->x.next = q->x.next;
   else
   }
   if (q->x.next)
     q->x.next->x.prev = q->x.prev;
   if (q->x.prev)
     q->x.prev->x.next = q->x.next;
   else
-    track__list = q->x.next;
-  track__used -= q->x.sz;
+    list = q->x.next;
+  used -= q->x.sz;
   (free)(q);
 }
 
   (free)(q);
 }
 
@@ -213,36 +216,36 @@ void track_free(void *p)
 void *track_realloc(void *p, size_t sz)
 {
   size_t osz;
 void *track_realloc(void *p, size_t sz)
 {
   size_t osz;
-  track__block *q, *qq;
+  block *q, *qq;
   if (p) {
   if (p) {
-    q = (track__block *)p - 1;
+    q = (block *)p - 1;
     osz = q->x.sz;
     if (q->x.next)
       q->x.next->x.prev = q->x.prev;
     if (q->x.prev)
       q->x.prev->x.next = q->x.next;
     else
     osz = q->x.sz;
     if (q->x.next)
       q->x.next->x.prev = q->x.prev;
     if (q->x.prev)
       q->x.prev->x.next = q->x.next;
     else
-      track__list = q->x.next;
+      list = q->x.next;
   } else {
     q = 0;
     osz = 0;
   }
   } else {
     q = 0;
     osz = 0;
   }
-  qq = (realloc)(q, sz + sizeof(track__block));
+  qq = (realloc)(q, sz + sizeof(block));
   if (qq) {
   if (qq) {
-    if (track__vLevel) {
-      trace(track__vLevel,
+    if (vLevel) {
+      trace(vLevel,
            "(track) reallocated %lu at %p to %lu for %s in %s",
            (unsigned long)osz, (void *)(q + 1),
            (unsigned long)sz,  (void *)(qq + 1),
            "(track) reallocated %lu at %p to %lu for %s in %s",
            (unsigned long)osz, (void *)(q + 1),
            (unsigned long)sz,  (void *)(qq + 1),
-           qq->x.ctx, track__context->s);
+           qq->x.ctx, context->s);
     }
     qq->x.sz = sz;
     }
     qq->x.sz = sz;
-    qq->x.next = track__list;
+    qq->x.next = list;
     qq->x.prev = 0;
     if (qq->x.next)
       qq->x.next->x.prev = qq;
     qq->x.prev = 0;
     if (qq->x.next)
       qq->x.next->x.prev = qq;
-    track__list = qq;
-    track__used += sz - osz;
+    list = qq;
+    used += sz - osz;
     qq->x.sz = sz;
     return (qq + 1);
   }
     qq->x.sz = sz;
     return (qq + 1);
   }
@@ -261,7 +264,7 @@ void *track_realloc(void *p, size_t sz)
 
 unsigned long track_used(void)
 {
 
 unsigned long track_used(void)
 {
-  return (track__used);
+  return (used);
 }
 
 /* --- @track_list@ --- *
 }
 
 /* --- @track_list@ --- *
@@ -279,7 +282,7 @@ unsigned long track_used(void)
 
 void track_list(unsigned int l)
 {
 
 void track_list(unsigned int l)
 {
-  track__block *q = track__list;
+  block *q = list;
 
   if (!(tracing() & l))
     return;
 
   if (!(tracing() & l))
     return;