Skip to content

Commit 6beacd7

Browse files
author
loewis
committed
Add several dl.RTLD_ constants. Closes bug 110842.
git-svn-id: http://svn.python.org/projects/python/trunk@17397 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent be61cfc commit 6beacd7

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

Modules/dlmodule.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ static PyMethodDef dl_methods[] = {
181181
{NULL, NULL} /* sentinel */
182182
};
183183

184+
/* From socketmodule.c
185+
* Convenience routine to export an integer value.
186+
*
187+
* Errors are silently ignored, for better or for worse...
188+
*/
189+
static void
190+
insint(PyObject *d, char *name, int value)
191+
{
192+
PyObject *v = PyInt_FromLong((long) value);
193+
if (!v || PyDict_SetItemString(d, name, v))
194+
PyErr_Clear();
195+
196+
Py_XDECREF(v);
197+
}
198+
184199
void
185200
initdl(void)
186201
{
@@ -202,8 +217,29 @@ initdl(void)
202217
PyDict_SetItemString(d, "error", x);
203218
x = PyInt_FromLong((long)RTLD_LAZY);
204219
PyDict_SetItemString(d, "RTLD_LAZY", x);
220+
#define INSINT(X) insint(d,#X,X)
205221
#ifdef RTLD_NOW
206-
x = PyInt_FromLong((long)RTLD_NOW);
207-
PyDict_SetItemString(d, "RTLD_NOW", x);
222+
INSINT(RTLD_NOW);
223+
#endif
224+
#ifdef RTLD_NOLOAD
225+
INSINT(RTLD_NOLOAD);
226+
#endif
227+
#ifdef RTLD_GLOBAL
228+
INSINT(RTLD_GLOBAL);
229+
#endif
230+
#ifdef RTLD_LOCAL
231+
INSINT(RTLD_LOCAL);
232+
#endif
233+
#ifdef RTLD_PARENT
234+
INSINT(RTLD_PARENT);
235+
#endif
236+
#ifdef RTLD_GROUP
237+
INSINT(RTLD_GROUP);
238+
#endif
239+
#ifdef RTLD_WORLD
240+
INSINT(RTLD_WORLD);
241+
#endif
242+
#ifdef RTLD_NODELETE
243+
INSINT(RTLD_NODELETE);
208244
#endif
209245
}

0 commit comments

Comments
 (0)