e576bb2002-10-11Martin Nilsson /* || 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.
8822552010-06-01Henrik Grubbström (Grubba) || $Id: cyclic.h,v 1.10 2010/06/01 09:43:20 grubba Exp $
e576bb2002-10-11Martin Nilsson */
1b10db2002-10-08Martin Nilsson 
fc33451997-10-02Fredrik Hübinette (Hubbe) #ifndef CYCLIC_H #define CYCLIC_H
b2d3e42000-12-01Fredrik Hübinette (Hubbe) #include "pike_error.h"
fc33451997-10-02Fredrik Hübinette (Hubbe) #include "threads.h"
3b6bff2002-12-01Martin Stjernholm /* #define CYCLIC_DEBUG */
fc33451997-10-02Fredrik Hübinette (Hubbe) typedef struct CYCLIC { ONERROR onerr; void *th;
3b6bff2002-12-01Martin Stjernholm  char *id; void *a,*b;
fc33451997-10-02Fredrik Hübinette (Hubbe)  void *ret; struct CYCLIC *next; } CYCLIC;
3b6bff2002-12-01Martin Stjernholm #ifdef CYCLIC_DEBUG #define DECLARE_CYCLIC() \ static char cyclic_identifier__[] = __FILE__ ":" DEFINETOSTR(__LINE__); \
fc33451997-10-02Fredrik Hübinette (Hubbe)  CYCLIC cyclic_struct__
3b6bff2002-12-01Martin Stjernholm #define BEGIN_CYCLIC(A,B) \ begin_cyclic(&cyclic_struct__, cyclic_identifier__, \
40fb6d2003-01-05Henrik Grubbström (Grubba)  THREAD_T_TO_PTR(th_self()), (void *)(A), (void *)(B))
fc33451997-10-02Fredrik Hübinette (Hubbe) 
3b6bff2002-12-01Martin Stjernholm #else /* CYCLIC_DEBUG */ #define DECLARE_CYCLIC() \ static char cyclic_identifier__; \ CYCLIC cyclic_struct__
fc33451997-10-02Fredrik Hübinette (Hubbe) #define BEGIN_CYCLIC(A,B) \
a850e32000-08-14Henrik Grubbström (Grubba)  begin_cyclic(&cyclic_struct__, &cyclic_identifier__, \
40fb6d2003-01-05Henrik Grubbström (Grubba)  THREAD_T_TO_PTR(th_self()), (void *)(A), (void *)(B))
fc33451997-10-02Fredrik Hübinette (Hubbe) 
3b6bff2002-12-01Martin Stjernholm #endif /* !CYCLIC_DEBUG */
fc33451997-10-02Fredrik Hübinette (Hubbe) #define SET_CYCLIC_RET(RET) \ cyclic_struct__.ret=(void *)(RET) #define END_CYCLIC() unlink_cyclic(&cyclic_struct__) /* Prototypes begin here */
8822552010-06-01Henrik Grubbström (Grubba) PMOD_EXPORT void unlink_cyclic(CYCLIC *c); PMOD_EXPORT void *begin_cyclic(CYCLIC *c, char *id, void *thread, void *a, void *b);
fc33451997-10-02Fredrik Hübinette (Hubbe) /* Prototypes end here */ #endif /* CYCLIC_H */