+++ /dev/null
-/*
- * Project: libFIRM
- * File name: ir/adt/debug.c
- * Purpose: Debug --- run time debug level management
- * Author: Christian von Roques
- * Modified by:
- * Created: 1999 by getting from fiasco
- * CVS-ID: $Id$
- * Copyright: (c) 1995, 1996 Christian von Roques
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include "debug.h"
-#include "xmalloc.h"
-
-
-int
-(d_) (int flag, unsigned level)
-{
- return d_ (flag, level);
-}
-
-
-int
-(d_level) (int flag)
-{
- return d_level (flag);
-}
-
-
-int
-(d_set_level) (int flag, unsigned level)
-{
- return d_set_level (flag, level);
-}
-
-
-#ifdef DEBUG
-int nflags;
-unsigned char *d_vec;
-#endif
-
-
-/*
- * Set debug flags according to the following syntax:
- * number ["-" number] ["." number]
- * 1st number is number of first flag to set.
- * 2nd number is number of last flag to set. [defaults to 1st number]
- * 3rd number is level to set the flags to. [defaults to 1]
- */
-void
-(d_parse) (const char *s)
-{
-#ifdef DEBUG
- long first, last, level;
- char *end;
-
- first = strtol(s, &end, 10);
- last = (s != end) ? first : nflags-1;
-
- s = end;
- if (*s == '-') {
- ++s;
- last = strtol(s, &end, 10);
- if (end == s) last = nflags-1; /* 3- ==> 3..nflags-1 */
- }
-
- s = end;
- if (*s == '.') {
- ++s;
- level = strtol(s, &end, 10);
- /* . with no number gives level 0 */
- } else {
- level = 1;
- }
-
- if (first<0) first=0;
- if (last>=nflags) last = nflags-1;
-
- while (first<=last) d_vec[first++] = level;
-#endif /* DEBUG */
-}
-
-
-void
-(d_init) (int n)
-{
-#ifdef DEBUG
- nflags = n;
- d_vec = xmalloc (sizeof (unsigned char) * n);
- memset(d_vec, 0, sizeof (unsigned char) * n);
-#endif
-}
+++ /dev/null
-/*
- * Project: libFIRM
- * File name: ir/adt/debug.h
- * Purpose: Declarations for debug
- * Author: Christian von Roques
- * Modified by:
- * Created: 1999 by getting from fiasco
- * CVS-ID: $Id$
- * Copyright: (c) 1995, 1996 Christian von Roques
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
- */
-
-
-#ifndef _DEBUG_H_
-#define _DEBUG_H_
-
-void d_init (int nflags);
-int d_ (int flag, unsigned level);
-int d_level (int flag);
-int d_set_level (int flag, unsigned level);
-void d_parse (const char *s);
-
-#ifdef DEBUG
-
-#include "deflag.h"
-
-extern unsigned char *d_vec;
-
-# define d_init(n) (d_init) ((n))
-# define d_(flag, level) (d_vec[(flag)] >= (level))
-# define d_level(flag) (d_vec[(flag)])
-# define d_set_level(flag, level) (d_vec[(flag)] = (level))
-# define d_parse(s) (d_parse) ((s))
-
-#else /* !DEBUG */
-
-# define d_init(n) ((void)0)
-# define d_(flag, level) 0
-# define d_level(flag) 0
-# define d_set_level(flag, level) (level)
-# define d_parse(s) ((void)0)
-
-#endif /* !DEBUG */
-
-#endif
# endif
#include "cookies.h"
-#include "debug.h"
#include "pdeq.h"
#include "xmalloc.h"
#ifdef NDEBUG
# define VRFY(dq) ((void)0)
#else
-# define VRFY(dq) \
- (d_(df_vrfy_level,1) ? _pdeq_vrfy ((dq)) : assert ((dq) && ((dq)->cookie == PDEQ_COOKIE1)))
+# define VRFY(dq) assert((dq) && ((dq)->cookie == PDEQ_COOKIE1))
#endif
/**
p->cookie = 0xbadf00d1;
#endif
if (pdeqs_cached < TUNE_NSAVED_PDEQS) {
- if (d_ (df_pdeq, 2)) printf ("[%p ==> pdeq_block_cache] ", p);
pdeq_block_cache[pdeqs_cached++] = p;
} else {
- if (d_ (df_pdeq, 2)) printf ("[%p ==> free] ", p);
xfree (p);
}
}
pdeq *p;
if (TUNE_NSAVED_PDEQS && pdeqs_cached) {
p = pdeq_block_cache[--pdeqs_cached];
- if (d_ (df_pdeq, 2)) printf ("[pdeq_block_cache ==> %p] ", p);
} else {
p = xmalloc (PREF_MALLOC_SIZE);
- if (d_ (df_pdeq, 2)) printf ("[malloc ==> %p] ", p);
}
return p;
}
{
pdeq *q;
- if (d_ (df_pdeq, 5)) printf ("[pdeq_vrfy %p] ", dq);
assert ( dq
&& (dq->cookie == PDEQ_COOKIE1)
dq->n = dq->p = 0;
VRFY(dq);
- if (d_(df_pdeq, 1)) printf("(new_pdeq ==> %p)\n", dq);
return dq;
}
free_pdeq_block(q);
} while ((q = qq));
- if (d_(df_pdeq, 1)) printf("(del_pdeq %p)\n", dq);
}
/* Checks if a list is empty. */
int pdeq_empty(pdeq *dq)
{
VRFY(dq);
- if (d_(df_pdeq, 4)) printf("(pdeq_empty %p ==> %d)\n", dq, dq->l_end->n == 0);
return dq->l_end->n == 0;
}
q = q->r;
} while (q);
- if (d_(df_pdeq, 4)) printf("(pdeq_len %p ==> %d)\n", dq, n);
return n;
}
{
pdeq *rdq;
int n;
- int pr = 0;
VRFY(dq);
if (dq->n) { /* ... if trunk used */
/* allocate and init new block */
ndq = alloc_pdeq_block();
- pr = d_(df_pdeq, 2);
#ifndef NDEBUG
ndq->cookie = PDEQ_COOKIE2;
#endif
rdq->data[n] = x;
VRFY(dq);
- if (d_(df_pdeq, 3) || pr) printf("(pdeq_putr %p %p)\n", dq, x);
return dq;
}
{
pdeq *ldq;
int p;
- int pr = 0;
VRFY(dq);
if (dq->n) { /* ... if trunk used */
/* allocate and init new block */
ndq = alloc_pdeq_block();
- pr = d_(df_pdeq, 2);
#ifndef NDEBUG
ndq->cookie = PDEQ_COOKIE2;
#endif
ldq->data[p] = x;
VRFY(dq);
- if (d_(df_pdeq, 3) || pr) printf("(pdeq_putl %p %p)\n", dq, x);
return dq;
}
pdeq *rdq;
const void *x;
int n;
- int pr = 0;
VRFY(dq);
assert(dq->l_end->n);
}
if (dq != rdq) {
free_pdeq_block(rdq);
- pr = d_(df_pdeq, 2);
}
}
VRFY(dq);
- if (d_(df_pdeq, 3) || pr) printf("(pdeq_getr %p ==> %p)\n", dq, x);
return (void *)x;
}
pdeq *ldq;
const void *x;
int p;
- int pr = 0;
VRFY(dq);
assert(dq->l_end->n);
}
if (dq != ldq) {
free_pdeq_block(ldq);
- pr = d_(df_pdeq, 2);
}
}
VRFY(dq);
- if (d_(df_pdeq, 3) || pr) printf("(pdeq_getl %p ==> %p)\n", dq, x);
return (void *)x;
}
p = q->p; ep = p + q->n;
if (ep > NDATA) {
- do if (q->data[p] == x) goto found; while (++p < NDATA);
+ do {
+ if (q->data[p] == x) return 1;
+ } while (++p < NDATA);
p = 0;
ep -= NDATA;
}
- while (p < ep) if (q->data[p++] == x) goto found;
+ while (p < ep) {
+ if (q->data[p++] == x) return 1;
+ }
q = q->r;
} while (q);
- if (d_(df_pdeq, 3)) printf("(pdeq_contains %p %p ==> 0)\n", dq, x);
return 0;
-
-found: /* The two gotos can be optimized away, if !DEBUG */
- if (d_(df_pdeq, 3)) printf("(pdeq_contains %p %p ==> 1)\n", dq, x);
- return 1;
}
/*
p = q->p; ep = p + q->n;
if (ep > NDATA) {
- do if (!cmp (q->data[p], key)) goto found; while (++p < NDATA);
+ do {
+ if (!cmp (q->data[p], key)) return (void *)q->data[p-1];
+ } while (++p < NDATA);
p = 0;
ep -= NDATA;
}
- while (p < ep) if (!cmp (q->data[p++], key)) goto found;
+ while (p < ep) {
+ if (!cmp (q->data[p++], key)) return (void *)q->data[p-1];
+ }
q = q->r;
} while (q);
- if (d_(df_pdeq, 3)) printf("(pdeq_search %p %p %p ==> 0)\n", dq, cmp, key);
return NULL;
-
-found: /* The two gotos can be optimized away, if !DEBUG */
- if (d_(df_pdeq, 3)) printf("(pdeq_contains %p %p %p ==> %p)\n",
- dq, cmp, key, q->data[p]);
- return (void *)q->data[p-1];
}
/*
q = q->r;
}
- if (d_(df_pdeq, 3)) printf("(pdeq_copyl %p %p ==> %p)\n", dq, dst, d);
return (void **)dst;
}
q = q->l;
}
- if (d_(df_pdeq, 3)) printf("(pdeq_copyr %p %p ==> %p)\n", dq, dst, d);
return (void **)dst;
}