Skip to content
Snippets Groups Projects
Commit 3b6bff14 authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

Added a macro to get some debug trace.

Rev: src/cyclic.c:1.9
Rev: src/cyclic.h:1.8
parent c64c0950
No related branches found
No related tags found
No related merge requests found
......@@ -2,13 +2,13 @@
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
|| $Id: cyclic.c,v 1.8 2002/10/11 01:39:30 nilsson Exp $
|| $Id: cyclic.c,v 1.9 2002/12/01 17:36:03 mast Exp $
*/
#include "global.h"
#include "cyclic.h"
RCSID("$Id: cyclic.c,v 1.8 2002/10/11 01:39:30 nilsson Exp $");
RCSID("$Id: cyclic.c,v 1.9 2002/12/01 17:36:03 mast Exp $");
#define CYCLIC_HASH_SIZE 4711
......@@ -33,6 +33,9 @@ static void low_unlink_cyclic(CYCLIC *c)
if(c == *p)
{
*p=c->next;
#ifdef CYCLIC_DEBUG
fprintf (stderr, "%s: END_CYCLIC a=%p b=%p: no cycle\n", c->id, c->a, c->b);
#endif
return;
}
}
......@@ -46,7 +49,7 @@ void unlink_cyclic(CYCLIC *c)
}
void *begin_cyclic(CYCLIC *c,
void *id,
char *id,
void *th,
void *a,
void *b)
......@@ -69,6 +72,9 @@ void *begin_cyclic(CYCLIC *c,
{
if(a == p->a && b==p->b && id==p->id)
{
#ifdef CYCLIC_DEBUG
fprintf (stderr, "%s: BEGIN_CYCLIC a=%p b=%p: found cycle\n", id, a, b);
#endif
ret=p->ret;
break;
}
......@@ -82,5 +88,8 @@ void *begin_cyclic(CYCLIC *c,
c->next=cyclic_hash[h];
cyclic_hash[h]=c;
SET_ONERROR(c->onerr, low_unlink_cyclic, c);
#ifdef CYCLIC_DEBUG
if (!ret) fprintf (stderr, "%s: BEGIN_CYCLIC a=%p b=%p: no cycle\n", id, a, b);
#endif
return ret;
}
......@@ -2,7 +2,7 @@
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
|| $Id: cyclic.h,v 1.7 2002/10/11 01:39:30 nilsson Exp $
|| $Id: cyclic.h,v 1.8 2002/12/01 17:36:03 mast Exp $
*/
#ifndef CYCLIC_H
......@@ -11,24 +11,39 @@
#include "pike_error.h"
#include "threads.h"
/* #define CYCLIC_DEBUG */
typedef struct CYCLIC
{
ONERROR onerr;
void *th;
void *id,*a,*b;
char *id;
void *a,*b;
void *ret;
struct CYCLIC *next;
} CYCLIC;
#ifdef CYCLIC_DEBUG
#define DECLARE_CYCLIC() \
static char cyclic_identifier__; \
static char cyclic_identifier__[] = __FILE__ ":" DEFINETOSTR(__LINE__); \
CYCLIC cyclic_struct__
#define BEGIN_CYCLIC(A,B) \
begin_cyclic(&cyclic_struct__, cyclic_identifier__, \
(void *)(ptrdiff_t)th_self(), (void *)(A), (void *)(B))
#else /* CYCLIC_DEBUG */
#define DECLARE_CYCLIC() \
static char cyclic_identifier__; \
CYCLIC cyclic_struct__
#define BEGIN_CYCLIC(A,B) \
begin_cyclic(&cyclic_struct__, &cyclic_identifier__, \
(void *)(ptrdiff_t)th_self(), (void *)(A), (void *)(B))
#endif /* !CYCLIC_DEBUG */
#define SET_CYCLIC_RET(RET) \
cyclic_struct__.ret=(void *)(RET)
......@@ -37,7 +52,7 @@ typedef struct CYCLIC
/* Prototypes begin here */
void unlink_cyclic(CYCLIC *c);
void *begin_cyclic(CYCLIC *c,
void *id,
char *id,
void *thread,
void *a,
void *b);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment