forked from pikelang/Pike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcyclic.h
81 lines (67 loc) · 2.26 KB
/
cyclic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
|| 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.
*/
#ifndef CYCLIC_H
#define CYCLIC_H
#include "pike_error.h"
#include "threads.h"
/* #define CYCLIC_DEBUG */
typedef struct CYCLIC
{
ONERROR onerr;
void *th;
char *id;
void *a,*b,*d;
void *ret;
struct CYCLIC *next;
} CYCLIC;
#ifdef CYCLIC_DEBUG
#define DECLARE_CYCLIC() \
static char cyclic_identifier__[] = __FILE__ ":" DEFINETOSTR(__LINE__); \
CYCLIC cyclic_struct__
#define BEGIN_CYCLIC(A,B) \
begin_cyclic(&cyclic_struct__, cyclic_identifier__, \
THREAD_T_TO_PTR(th_self()), (void *)(A), (void *)(B), NULL)
#define LOW_BEGIN_CYCLIC(A,B) \
low_begin_cyclic(&cyclic_struct__, cyclic_identifier__, \
THREAD_T_TO_PTR(th_self()), (void *)(A), (void *)(B), NULL)
#define BEGIN_CYCLIC3(A,B,D) \
begin_cyclic(&cyclic_struct__, cyclic_identifier__, \
THREAD_T_TO_PTR(th_self()), (void *)(A), (void *)(B), (void *)(D))
#else /* CYCLIC_DEBUG */
#define DECLARE_CYCLIC() \
static char cyclic_identifier__; \
CYCLIC cyclic_struct__
#define BEGIN_CYCLIC(A,B) \
begin_cyclic(&cyclic_struct__, &cyclic_identifier__, \
THREAD_T_TO_PTR(th_self()), (void *)(A), (void *)(B), NULL)
#define LOW_BEGIN_CYCLIC(A,B) \
low_begin_cyclic(&cyclic_struct__, &cyclic_identifier__, \
THREAD_T_TO_PTR(th_self()), (void *)(A), (void *)(B), NULL)
#define BEGIN_CYCLIC3(A,B,D) \
begin_cyclic(&cyclic_struct__, &cyclic_identifier__, \
THREAD_T_TO_PTR(th_self()), (void *)(A), (void *)(B), (void *)(D))
#endif /* !CYCLIC_DEBUG */
#define SET_CYCLIC_RET(RET) \
cyclic_struct__.ret=(void *)(RET)
#define END_CYCLIC() unlink_cyclic(&cyclic_struct__)
#define LOW_END_CYCLIC() low_unlink_cyclic(&cyclic_struct__)
/* Prototypes begin here */
void low_unlink_cyclic(CYCLIC *c);
PMOD_EXPORT void unlink_cyclic(CYCLIC *c);
void *low_begin_cyclic(CYCLIC *c,
char *id,
void *thread,
void *a,
void *b,
void *d);
PMOD_EXPORT void *begin_cyclic(CYCLIC *c,
char *id,
void *thread,
void *a,
void *b,
void *d);
/* Prototypes end here */
#endif /* CYCLIC_H */