pike.git/
src/
threads.h
Branch:
Tag:
Non-build tags
All tags
No tags
1997-10-21
1997-10-21 13:30:22 by Henrik Grubbström (Grubba) <grubba@grubba.org>
d81860935329bdf4d7ccde0e83ff4eed84615f37 (
32
lines) (+
21
/-
11
)
[
Show
|
Annotate
]
Branch:
7.9
Added code to catch a lot of illegal global-variable use.
Rev: src/threads.h:1.18
208:
struct thread_state *_tmp=(struct thread_state *)thread_id->storage; \ SWAP_OUT_THREAD(_tmp); \ THREADS_FPRINTF((stderr, "SWAP_OUT_CURRENT_THREAD() %s:%d t:%08x\n", \
-
__FILE__, __LINE__, (unsigned int)_tmp->thread_id))
;
\
+
__FILE__, __LINE__, (unsigned int)_tmp->thread_id)) \
#define SWAP_IN_CURRENT_THREAD() \ THREADS_FPRINTF((stderr, "SWAP_IN_CURRENT_THREAD() %s:%d ... t:%08x\n", \
216:
SWAP_IN_THREAD(_tmp);\ } while(0)
-
#
define
THREADS_ALLOW() \
-
do
{\
-
struct
thread_state
*_tmp=(struct
thread_state
*)thread_id->storage;
\
-
if(num_threads
>
1
&&
!threads_disabled)
{ \
-
SWAP_OUT_THREAD(_tmp);
\
-
THREADS_FPRINTF((stderr,
"THREADS
_
ALLOW
()
%s:%d
t:%08x\n",
\
-
__
FILE__
, __
LINE__,
(unsigned
int)_tmp->thread_id))
; \
-
mt
_
unlock(&
interpreter_lock);
\
-
}
+
#
ifdef
DEBUG
+
/*
Note
that
scalar
types
are
used
in
place
of
pointers
and
vice
versa
+
*
below.
This
is
intended
to
cause
compiler
warnings/errors
if
+
*
there
is
an
attempt
to
use
the
global
variables
in
an
unsafe
+
*
environment.
+
*/
+
#define HIDE
_
GLOBAL_VARIABLES
()
do
{
\
+
int
sp
=
0,
evaluator_stack
=
0,
mark_sp
=
0,
mark_stack
=
0,
fp
=
0;
\
+
void
*evaluator
_
stack
_
malloced = NULL
,
*mark
_
stack
_
malloced
=
NULL
; \
+
int
recoveries
=
0,
thread
_
id
=
0
-
+
#define REVEAL_GLOBAL_VARIABLES() } while(0)
+
#else /* DEBUG */
+
#define HIDE_GLOBAL_VARIABLES()
+
#define REVEAL_GLOBAL_VARIABLES()
+
#endif /* DEBUG */
+
+
#define THREADS_ALLOW() \ do {\ struct thread_state *_tmp=(struct thread_state *)thread_id->storage; \
234:
THREADS_FPRINTF((stderr, "THREADS_ALLOW() %s:%d t:%08x\n", \ __FILE__, __LINE__, (unsigned int)_tmp->thread_id)); \ mt_unlock(& interpreter_lock); \
-
}
+
}
else {} HIDE_GLOBAL_VARIABLES()
#define THREADS_DISALLOW() \
-
+
REVEAL_GLOBAL_VARIABLES(); \
if(_tmp->swapped) { \ mt_lock(& interpreter_lock); \ THREADS_FPRINTF((stderr, "THREADS_DISALLOW() %s:%d ... t:%08x\n", \