The 0.5 release happened on 2/15, not on 2/14. :-)
[python/dscho.git] / Include / ceval.h
blob8200e3cd1b88fbff185daf6af08ce5c15caa189b
1 #ifndef Py_CEVAL_H
2 #define Py_CEVAL_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
7 /***********************************************************
8 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
9 The Netherlands.
11 All Rights Reserved
13 Permission to use, copy, modify, and distribute this software and its
14 documentation for any purpose and without fee is hereby granted,
15 provided that the above copyright notice appear in all copies and that
16 both that copyright notice and this permission notice appear in
17 supporting documentation, and that the names of Stichting Mathematisch
18 Centrum or CWI or Corporation for National Research Initiatives or
19 CNRI not be used in advertising or publicity pertaining to
20 distribution of the software without specific, written prior
21 permission.
23 While CWI is the initial source for this software, a modified version
24 is made available by the Corporation for National Research Initiatives
25 (CNRI) at the Internet address ftp://ftp.python.org.
27 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
28 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
29 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
30 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
31 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
32 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
33 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34 PERFORMANCE OF THIS SOFTWARE.
36 ******************************************************************/
38 /* Interface to random parts in ceval.c */
40 DL_IMPORT(PyObject *) PyEval_CallObjectWithKeywords
41 Py_PROTO((PyObject *, PyObject *, PyObject *));
43 /* DLL-level Backwards compatibility: */
44 #undef PyEval_CallObject
45 DL_IMPORT(PyObject *) PyEval_CallObject Py_PROTO((PyObject *, PyObject *));
47 /* Inline this */
48 #define PyEval_CallObject(func,arg) \
49 PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
51 #ifdef HAVE_STDARG_PROTOTYPES
52 DL_IMPORT(PyObject *) PyEval_CallFunction Py_PROTO((PyObject *obj, char *format, ...));
53 DL_IMPORT(PyObject *) PyEval_CallMethod Py_PROTO((PyObject *obj,
54 char *methodname, char *format, ...));
55 #else
56 /* Better to have no prototypes at all for varargs functions in this case */
57 DL_IMPORT(PyObject *) PyEval_CallFunction();
58 DL_IMPORT(PyObject *) PyEval_CallMethod();
59 #endif
61 DL_IMPORT(PyObject *) PyEval_GetBuiltins Py_PROTO((void));
62 DL_IMPORT(PyObject *) PyEval_GetGlobals Py_PROTO((void));
63 DL_IMPORT(PyObject *) PyEval_GetLocals Py_PROTO((void));
64 DL_IMPORT(PyObject *) PyEval_GetOwner Py_PROTO((void));
65 DL_IMPORT(PyObject *) PyEval_GetFrame Py_PROTO((void));
66 DL_IMPORT(int) PyEval_GetRestricted Py_PROTO((void));
68 DL_IMPORT(int) Py_FlushLine Py_PROTO((void));
70 DL_IMPORT(int) Py_AddPendingCall Py_PROTO((int (*func) Py_PROTO((ANY *)), ANY *arg));
71 DL_IMPORT(int) Py_MakePendingCalls Py_PROTO((void));
74 /* Interface for threads.
76 A module that plans to do a blocking system call (or something else
77 that lasts a long time and doesn't touch Python data) can allow other
78 threads to run as follows:
80 ...preparations here...
81 Py_BEGIN_ALLOW_THREADS
82 ...blocking system call here...
83 Py_END_ALLOW_THREADS
84 ...interpret result here...
86 The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
87 {}-surrounded block.
88 To leave the block in the middle (e.g., with return), you must insert
89 a line containing RET_SAVE before the return, e.g.
91 if (...premature_exit...) {
92 Py_BLOCK_THREADS
93 PyErr_SetFromErrno(PyExc_IOError);
94 return NULL;
97 An alternative is:
99 Py_BLOCK_THREADS
100 if (...premature_exit...) {
101 PyErr_SetFromErrno(PyExc_IOError);
102 return NULL;
104 Py_UNBLOCK_THREADS
106 For convenience, that the value of 'errno' is restored across
107 Py_END_ALLOW_THREADS and RET_SAVE.
109 WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
110 Py_END_ALLOW_THREADS!!!
112 The function PyEval_InitThreads() should be called only from
113 initthread() in "threadmodule.c".
115 Note that not yet all candidates have been converted to use this
116 mechanism!
119 extern DL_IMPORT(PyThreadState *) PyEval_SaveThread Py_PROTO((void));
120 extern DL_IMPORT(void) PyEval_RestoreThread Py_PROTO((PyThreadState *));
122 #ifdef WITH_THREAD
124 extern DL_IMPORT(void) PyEval_InitThreads Py_PROTO((void));
125 extern DL_IMPORT(void) PyEval_AcquireLock Py_PROTO((void));
126 extern DL_IMPORT(void) PyEval_ReleaseLock Py_PROTO((void));
127 extern DL_IMPORT(void) PyEval_AcquireThread Py_PROTO((PyThreadState *tstate));
128 extern DL_IMPORT(void) PyEval_ReleaseThread Py_PROTO((PyThreadState *tstate));
130 #define Py_BEGIN_ALLOW_THREADS { \
131 PyThreadState *_save; \
132 _save = PyEval_SaveThread();
133 #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
134 #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
135 #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
138 #else /* !WITH_THREAD */
140 #define Py_BEGIN_ALLOW_THREADS {
141 #define Py_BLOCK_THREADS
142 #define Py_UNBLOCK_THREADS
143 #define Py_END_ALLOW_THREADS }
145 #endif /* !WITH_THREAD */
147 #ifdef __cplusplus
149 #endif
150 #endif /* !Py_CEVAL_H */