Mercurial > cpython-lru_cache-weakref
annotate Modules/dlmodule.c @ 38664:7619216bbc19 2.4
Bug #1502728: Correctly link against librt library on HP-UX.
(backport from rev. 46743)
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Thu, 08 Jun 2006 12:54:16 +0000 |
| parents | f66b3a3509c7 |
| children | 1af7f719ed28 |
| rev | line source |
|---|---|
| 1650 | 1 |
| 2 /* dl module */ | |
| 3 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
4 #include "Python.h" |
| 1650 | 5 |
| 6 #include <dlfcn.h> | |
| 7 | |
| 8 #ifndef RTLD_LAZY | |
| 9 #define RTLD_LAZY 1 | |
| 10 #endif | |
| 11 | |
|
13709
4e2aaf1e722a
Use 'void' directly instead of the ANY #define, now that all code is ANSI C.
Thomas Wouters <thomas@python.org>
parents:
13651
diff
changeset
|
12 typedef void *PyUnivPtr; |
| 1650 | 13 typedef struct { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
14 PyObject_HEAD |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
15 PyUnivPtr *dl_handle; |
| 1650 | 16 } dlobject; |
| 17 | |
|
24280
1598a1e473e2
staticforward bites the dust.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
22710
diff
changeset
|
18 static PyTypeObject Dltype; |
| 1650 | 19 |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
20 static PyObject *Dlerror; |
| 1650 | 21 |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
22 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
23 newdlobject(PyUnivPtr *handle) |
| 1650 | 24 { |
| 25 dlobject *xp; | |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
6889
diff
changeset
|
26 xp = PyObject_New(dlobject, &Dltype); |
| 1650 | 27 if (xp == NULL) |
| 28 return NULL; | |
| 29 xp->dl_handle = handle; | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
30 return (PyObject *)xp; |
| 1650 | 31 } |
| 32 | |
| 33 static void | |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
34 dl_dealloc(dlobject *xp) |
| 1650 | 35 { |
| 36 if (xp->dl_handle != NULL) | |
| 37 dlclose(xp->dl_handle); | |
|
12576
1c7c2dd1beb1
Vladimir Marangozov's long-awaited malloc restructuring.
Guido van Rossum <guido@python.org>
parents:
6889
diff
changeset
|
38 PyObject_Del(xp); |
| 1650 | 39 } |
| 40 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
41 static PyObject * |
|
22710
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
42 dl_close(dlobject *xp) |
| 1650 | 43 { |
| 44 if (xp->dl_handle != NULL) { | |
| 45 dlclose(xp->dl_handle); | |
| 46 xp->dl_handle = NULL; | |
| 47 } | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
48 Py_INCREF(Py_None); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
49 return Py_None; |
| 1650 | 50 } |
| 51 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
52 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
53 dl_sym(dlobject *xp, PyObject *args) |
| 1650 | 54 { |
| 55 char *name; | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
56 PyUnivPtr *func; |
|
22710
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
57 if (PyString_Check(args)) { |
|
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
58 name = PyString_AS_STRING(args); |
|
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
59 } else { |
|
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
60 PyErr_Format(PyExc_TypeError, "expected string, found %.200s", |
|
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
61 args->ob_type->tp_name); |
| 1650 | 62 return NULL; |
|
22710
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
63 } |
| 1650 | 64 func = dlsym(xp->dl_handle, name); |
| 65 if (func == NULL) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
66 Py_INCREF(Py_None); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
67 return Py_None; |
| 1650 | 68 } |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
69 return PyInt_FromLong((long)func); |
| 1650 | 70 } |
| 71 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
72 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
73 dl_call(dlobject *xp, PyObject *args) |
| 1650 | 74 { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
75 PyObject *name; |
|
15157
459232a9b804
Remove one more gcc -Wall warning.
Fred Drake <fdrake@acm.org>
parents:
14542
diff
changeset
|
76 long (*func)(long, long, long, long, long, |
|
459232a9b804
Remove one more gcc -Wall warning.
Fred Drake <fdrake@acm.org>
parents:
14542
diff
changeset
|
77 long, long, long, long, long); |
| 1650 | 78 long alist[10]; |
| 79 long res; | |
| 80 int i; | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
81 int n = PyTuple_Size(args); |
| 1650 | 82 if (n < 1) { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
83 PyErr_SetString(PyExc_TypeError, "at least a name is needed"); |
| 1650 | 84 return NULL; |
| 85 } | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
86 name = PyTuple_GetItem(args, 0); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
87 if (!PyString_Check(name)) { |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
88 PyErr_SetString(PyExc_TypeError, |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
89 "function name must be a string"); |
| 1650 | 90 return NULL; |
| 91 } | |
|
16735
9f86cba4766b
Patch #103926: fix two warnings from Tru64's compiler
Andrew M. Kuchling <amk@amk.ca>
parents:
15157
diff
changeset
|
92 func = (long (*)(long, long, long, long, long, |
|
9f86cba4766b
Patch #103926: fix two warnings from Tru64's compiler
Andrew M. Kuchling <amk@amk.ca>
parents:
15157
diff
changeset
|
93 long, long, long, long, long)) |
|
9f86cba4766b
Patch #103926: fix two warnings from Tru64's compiler
Andrew M. Kuchling <amk@amk.ca>
parents:
15157
diff
changeset
|
94 dlsym(xp->dl_handle, PyString_AsString(name)); |
| 1650 | 95 if (func == NULL) { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
96 PyErr_SetString(PyExc_ValueError, dlerror()); |
| 1650 | 97 return NULL; |
| 98 } | |
| 99 if (n-1 > 10) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
100 PyErr_SetString(PyExc_TypeError, |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
101 "too many arguments (max 10)"); |
| 1650 | 102 return NULL; |
| 103 } | |
| 104 for (i = 1; i < n; i++) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
105 PyObject *v = PyTuple_GetItem(args, i); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
106 if (PyInt_Check(v)) |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
107 alist[i-1] = PyInt_AsLong(v); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
108 else if (PyString_Check(v)) |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
109 alist[i-1] = (long)PyString_AsString(v); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
110 else if (v == Py_None) |
| 1650 | 111 alist[i-1] = (long) ((char *)NULL); |
| 112 else { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
113 PyErr_SetString(PyExc_TypeError, |
| 1650 | 114 "arguments must be int, string or None"); |
| 115 return NULL; | |
| 116 } | |
| 117 } | |
| 118 for (; i <= 10; i++) | |
| 119 alist[i-1] = 0; | |
| 120 res = (*func)(alist[0], alist[1], alist[2], alist[3], alist[4], | |
| 121 alist[5], alist[6], alist[7], alist[8], alist[9]); | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
122 return PyInt_FromLong(res); |
| 1650 | 123 } |
| 124 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
125 static PyMethodDef dlobject_methods[] = { |
|
21757
40631ae74b17
Patch #477750: Use METH_ constants in Modules.
Martin v. Löwis <martin@v.loewis.de>
parents:
21610
diff
changeset
|
126 {"call", (PyCFunction)dl_call, METH_VARARGS}, |
|
22710
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
127 {"sym", (PyCFunction)dl_sym, METH_O}, |
|
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
128 {"close", (PyCFunction)dl_close, METH_NOARGS}, |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
129 {NULL, NULL} /* Sentinel */ |
| 1650 | 130 }; |
| 131 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
132 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
133 dl_getattr(dlobject *xp, char *name) |
| 1650 | 134 { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
135 return Py_FindMethod(dlobject_methods, (PyObject *)xp, name); |
| 1650 | 136 } |
| 137 | |
| 138 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
139 static PyTypeObject Dltype = { |
|
16804
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
140 PyObject_HEAD_INIT(NULL) |
| 1650 | 141 0, /*ob_size*/ |
|
21313
91dd223829c6
Patch supplied by Burton Radons for his own SF bug #487390: Modifying
Guido van Rossum <guido@python.org>
parents:
16804
diff
changeset
|
142 "dl.dl", /*tp_name*/ |
| 1650 | 143 sizeof(dlobject), /*tp_basicsize*/ |
| 144 0, /*tp_itemsize*/ | |
| 145 /* methods */ | |
| 146 (destructor)dl_dealloc, /*tp_dealloc*/ | |
| 147 0, /*tp_print*/ | |
| 148 (getattrfunc)dl_getattr,/*tp_getattr*/ | |
| 149 0, /*tp_setattr*/ | |
| 150 0, /*tp_compare*/ | |
| 151 0, /*tp_repr*/ | |
| 152 0, /*tp_as_number*/ | |
| 153 0, /*tp_as_sequence*/ | |
| 154 0, /*tp_as_mapping*/ | |
| 155 0, /*tp_hash*/ | |
| 156 }; | |
| 157 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
158 static PyObject * |
|
13499
046799a08057
ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents:
13256
diff
changeset
|
159 dl_open(PyObject *self, PyObject *args) |
| 1650 | 160 { |
| 161 char *name; | |
| 162 int mode; | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
163 PyUnivPtr *handle; |
|
21610
a9e06ffaf7fb
Patch #497126: Always compile dl.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
164 if (sizeof(int) != sizeof(long) || |
|
a9e06ffaf7fb
Patch #497126: Always compile dl.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
165 sizeof(long) != sizeof(char *)) { |
|
a9e06ffaf7fb
Patch #497126: Always compile dl.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
166 PyErr_SetString(PyExc_SystemError, |
|
a9e06ffaf7fb
Patch #497126: Always compile dl.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
167 "module dl requires sizeof(int) == sizeof(long) == sizeof(char*)"); |
|
a9e06ffaf7fb
Patch #497126: Always compile dl.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
168 return NULL; |
|
a9e06ffaf7fb
Patch #497126: Always compile dl.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
169 } |
|
a9e06ffaf7fb
Patch #497126: Always compile dl.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
170 |
|
22710
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
171 if (PyArg_ParseTuple(args, "z:open", &name)) |
| 1650 | 172 mode = RTLD_LAZY; |
| 173 else { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
174 PyErr_Clear(); |
|
22710
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
175 if (!PyArg_ParseTuple(args, "zi:open", &name, &mode)) |
| 1650 | 176 return NULL; |
| 177 #ifndef RTLD_NOW | |
| 178 if (mode != RTLD_LAZY) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
179 PyErr_SetString(PyExc_ValueError, "mode must be 1"); |
| 1650 | 180 return NULL; |
| 181 } | |
| 182 #endif | |
| 183 } | |
| 184 handle = dlopen(name, mode); | |
| 185 if (handle == NULL) { | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
186 PyErr_SetString(Dlerror, dlerror()); |
| 1650 | 187 return NULL; |
| 188 } | |
| 189 return newdlobject(handle); | |
| 190 } | |
| 191 | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
192 static PyMethodDef dl_methods[] = { |
|
22710
8a225bd8763a
Convert METH_OLDARGS -> METH_VARARGS: also PyArg_Parse -> PyArg_ParseTuple
Neal Norwitz <nnorwitz@gmail.com>
parents:
21757
diff
changeset
|
193 {"open", dl_open, METH_VARARGS}, |
| 1650 | 194 {NULL, NULL} /* sentinel */ |
| 195 }; | |
| 196 | |
|
14542
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
197 /* From socketmodule.c |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
198 * Convenience routine to export an integer value. |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
199 * |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
200 * Errors are silently ignored, for better or for worse... |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
201 */ |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
202 static void |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
203 insint(PyObject *d, char *name, int value) |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
204 { |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
205 PyObject *v = PyInt_FromLong((long) value); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
206 if (!v || PyDict_SetItemString(d, name, v)) |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
207 PyErr_Clear(); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
208 |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
209 Py_XDECREF(v); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
210 } |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
211 |
|
24471
f66b3a3509c7
Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
Mark Hammond <mhammond@skippinet.com.au>
parents:
24280
diff
changeset
|
212 PyMODINIT_FUNC |
|
13651
8a063423e0b7
Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents:
13499
diff
changeset
|
213 initdl(void) |
| 1650 | 214 { |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
215 PyObject *m, *d, *x; |
| 1650 | 216 |
|
16804
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
217 /* Initialize object type */ |
|
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
218 Dltype.ob_type = &PyType_Type; |
|
8156879fe60d
Patch #404680: disables the nis module and enables the dl module when
Andrew M. Kuchling <amk@amk.ca>
parents:
16735
diff
changeset
|
219 |
| 1650 | 220 /* Create the module and add the functions */ |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
221 m = Py_InitModule("dl", dl_methods); |
| 1650 | 222 |
| 223 /* Add some symbolic constants to the module */ | |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
224 d = PyModule_GetDict(m); |
|
6367
2c29b8982643
Apply two changes, systematically:
Guido van Rossum <guido@python.org>
parents:
4725
diff
changeset
|
225 Dlerror = x = PyErr_NewException("dl.error", NULL, NULL); |
|
4725
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
226 PyDict_SetItemString(d, "error", x); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
227 x = PyInt_FromLong((long)RTLD_LAZY); |
|
8669edb1d9c5
Renamed.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4503
diff
changeset
|
228 PyDict_SetItemString(d, "RTLD_LAZY", x); |
|
14542
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
229 #define INSINT(X) insint(d,#X,X) |
| 1650 | 230 #ifdef RTLD_NOW |
|
14542
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
231 INSINT(RTLD_NOW); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
232 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
233 #ifdef RTLD_NOLOAD |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
234 INSINT(RTLD_NOLOAD); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
235 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
236 #ifdef RTLD_GLOBAL |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
237 INSINT(RTLD_GLOBAL); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
238 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
239 #ifdef RTLD_LOCAL |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
240 INSINT(RTLD_LOCAL); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
241 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
242 #ifdef RTLD_PARENT |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
243 INSINT(RTLD_PARENT); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
244 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
245 #ifdef RTLD_GROUP |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
246 INSINT(RTLD_GROUP); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
247 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
248 #ifdef RTLD_WORLD |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
249 INSINT(RTLD_WORLD); |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
250 #endif |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
251 #ifdef RTLD_NODELETE |
|
a45ca1f7f241
Add several dl.RTLD_ constants. Closes bug 110842.
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
252 INSINT(RTLD_NODELETE); |
| 1650 | 253 #endif |
| 254 } |
