summaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2015-05-16 21:04:52 +0200
committerArmin Rigo <arigo@tunes.org>2015-05-16 21:04:52 +0200
commit92aeb09339ffa7c092d72a784826bc75f7d0b026 (patch)
tree705b6e2676509a2090f87f2283b4e75a3bb733ba /c
parent18f51d8c3865007d4e25b2ef8fff65f8096f0906 (diff)
downloadcffi-92aeb09339ffa7c092d72a784826bc75f7d0b026.tar.gz
Add RTLD_xxx flags to the CompiledFFI type
Diffstat (limited to 'c')
-rw-r--r--c/_cffi_backend.c48
-rw-r--r--c/cffi1_module.c10
2 files changed, 40 insertions, 18 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
index 84ada7a..c498904 100644
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -5946,6 +5946,28 @@ static void *cffi_exports[] = {
convert_array_from_object,
};
+static struct { const char *name; int value; } all_dlopen_flags[] = {
+ { "RTLD_LAZY", RTLD_LAZY },
+ { "RTLD_NOW", RTLD_NOW },
+ { "RTLD_GLOBAL", RTLD_GLOBAL },
+#ifdef RTLD_LOCAL
+ { "RTLD_LOCAL", RTLD_LOCAL },
+#else
+ { "RTLD_LOCAL", 0 },
+#endif
+#ifdef RTLD_NODELETE
+ { "RTLD_NODELETE", RTLD_NODELETE },
+#endif
+#ifdef RTLD_NOLOAD
+ { "RTLD_NOLOAD", RTLD_NOLOAD },
+#endif
+#ifdef RTLD_DEEPBIND
+ { "RTLD_DEEPBIND", RTLD_DEEPBIND },
+#endif
+ { NULL, 0 }
+};
+
+
/************************************************************/
#include "cffi1_module.c"
@@ -5973,6 +5995,7 @@ init_cffi_backend(void)
#endif
{
PyObject *m, *v;
+ int i;
v = PySys_GetObject("version");
if (v == NULL || !PyText_Check(v) ||
@@ -6048,27 +6071,16 @@ init_cffi_backend(void)
PyModule_AddIntConstant(m, "_WIN", 32) < 0 || /* win32 */
# endif
#endif
-
- PyModule_AddIntConstant(m, "RTLD_LAZY", RTLD_LAZY) < 0 ||
- PyModule_AddIntConstant(m, "RTLD_NOW", RTLD_NOW) < 0 ||
- PyModule_AddIntConstant(m, "RTLD_GLOBAL", RTLD_GLOBAL) < 0 ||
-#ifdef RTLD_LOCAL
- PyModule_AddIntConstant(m, "RTLD_LOCAL", RTLD_LOCAL) < 0 ||
-#else
- PyModule_AddIntConstant(m, "RTLD_LOCAL", 0) < 0 ||
-#endif
-#ifdef RTLD_NODELETE
- PyModule_AddIntConstant(m, "RTLD_NODELETE", RTLD_NODELETE) < 0 ||
-#endif
-#ifdef RTLD_NOLOAD
- PyModule_AddIntConstant(m, "RTLD_NOLOAD", RTLD_NOLOAD) < 0 ||
-#endif
-#ifdef RTLD_DEEPBIND
- PyModule_AddIntConstant(m, "RTLD_DEEPBIND", RTLD_DEEPBIND) < 0 ||
-#endif
0)
INITERROR;
+ for (i = 0; all_dlopen_flags[i].name != NULL; i++) {
+ if (PyModule_AddIntConstant(m,
+ all_dlopen_flags[i].name,
+ all_dlopen_flags[i].value) < 0)
+ INITERROR;
+ }
+
init_errno();
if (init_ffi_lib(m) < 0)
diff --git a/c/cffi1_module.c b/c/cffi1_module.c
index 1fd6965..09ff624 100644
--- a/c/cffi1_module.c
+++ b/c/cffi1_module.c
@@ -18,6 +18,7 @@ static PyTypeObject Lib_Type; /* forward */
static int init_ffi_lib(PyObject *m)
{
PyObject *x;
+ int i;
if (PyType_Ready(&FFI_Type) < 0)
return -1;
@@ -38,6 +39,15 @@ static int init_ffi_lib(PyObject *m)
(PyObject *)&CData_Type) < 0)
return -1;
+ for (i = 0; all_dlopen_flags[i].name != NULL; i++) {
+ x = PyInt_FromLong(all_dlopen_flags[i].value);
+ if (x == NULL || PyDict_SetItemString(FFI_Type.tp_dict,
+ all_dlopen_flags[i].name,
+ x) < 0)
+ return -1;
+ Py_DECREF(x);
+ }
+
x = (PyObject *)&FFI_Type;
Py_INCREF(x);
if (PyModule_AddObject(m, "FFI", x) < 0)