This commit was manufactured by cvs2svn to create tag 'r23b1-mac'.
[python/dscho.git] / Include / ceval.h
blob411cf3e97bd4bf6ed2812f6223828471d9cbb5c9
1 #ifndef Py_CEVAL_H
2 #define Py_CEVAL_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
8 /* Interface to random parts in ceval.c */
10 PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
11 PyObject *, PyObject *, PyObject *);
13 /* DLL-level Backwards compatibility: */
14 #undef PyEval_CallObject
15 PyAPI_FUNC(PyObject *) PyEval_CallObject(PyObject *, PyObject *);
17 /* Inline this */
18 #define PyEval_CallObject(func,arg) \
19 PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
21 PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, char *format, ...);
22 PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
23 char *methodname, char *format, ...);
25 PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
26 PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
28 struct _frame; /* Avoid including frameobject.h */
30 PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
31 PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
32 PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
33 PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
34 PyAPI_FUNC(int) PyEval_GetRestricted(void);
36 /* Look at the current frame's (if any) code's co_flags, and turn on
37 the corresponding compiler flags in cf->cf_flags. Return 1 if any
38 flag was set, else return 0. */
39 PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
41 PyAPI_FUNC(int) Py_FlushLine(void);
43 PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
44 PyAPI_FUNC(int) Py_MakePendingCalls(void);
46 PyAPI_FUNC(void) Py_SetRecursionLimit(int);
47 PyAPI_FUNC(int) Py_GetRecursionLimit(void);
49 PyAPI_FUNC(char *) PyEval_GetFuncName(PyObject *);
50 PyAPI_FUNC(char *) PyEval_GetFuncDesc(PyObject *);
52 PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
54 /* this used to be handled on a per-thread basis - now just two globals */
55 PyAPI_DATA(volatile int) _Py_Ticker;
56 PyAPI_DATA(int) _Py_CheckInterval;
58 /* Interface for threads.
60 A module that plans to do a blocking system call (or something else
61 that lasts a long time and doesn't touch Python data) can allow other
62 threads to run as follows:
64 ...preparations here...
65 Py_BEGIN_ALLOW_THREADS
66 ...blocking system call here...
67 Py_END_ALLOW_THREADS
68 ...interpret result here...
70 The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
71 {}-surrounded block.
72 To leave the block in the middle (e.g., with return), you must insert
73 a line containing Py_BLOCK_THREADS before the return, e.g.
75 if (...premature_exit...) {
76 Py_BLOCK_THREADS
77 PyErr_SetFromErrno(PyExc_IOError);
78 return NULL;
81 An alternative is:
83 Py_BLOCK_THREADS
84 if (...premature_exit...) {
85 PyErr_SetFromErrno(PyExc_IOError);
86 return NULL;
88 Py_UNBLOCK_THREADS
90 For convenience, that the value of 'errno' is restored across
91 Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
93 WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
94 Py_END_ALLOW_THREADS!!!
96 The function PyEval_InitThreads() should be called only from
97 initthread() in "threadmodule.c".
99 Note that not yet all candidates have been converted to use this
100 mechanism!
103 PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
104 PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
106 #ifdef WITH_THREAD
108 PyAPI_FUNC(void) PyEval_InitThreads(void);
109 PyAPI_FUNC(void) PyEval_AcquireLock(void);
110 PyAPI_FUNC(void) PyEval_ReleaseLock(void);
111 PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
112 PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
113 PyAPI_FUNC(void) PyEval_ReInitThreads(void);
115 #define Py_BEGIN_ALLOW_THREADS { \
116 PyThreadState *_save; \
117 _save = PyEval_SaveThread();
118 #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
119 #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
120 #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
123 #else /* !WITH_THREAD */
125 #define Py_BEGIN_ALLOW_THREADS {
126 #define Py_BLOCK_THREADS
127 #define Py_UNBLOCK_THREADS
128 #define Py_END_ALLOW_THREADS }
130 #endif /* !WITH_THREAD */
132 PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, int *);
135 #ifdef __cplusplus
137 #endif
138 #endif /* !Py_CEVAL_H */