forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dl.c
32 lines (24 loc) · 768 Bytes
/
dl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <Python.h>
#include <dlfcn.h>
PyObject* module;
static PyMethodDef TorchDlMethods[] = {
{NULL, NULL, 0, NULL}
};
static struct PyModuleDef torchdlmodule = {
PyModuleDef_HEAD_INIT,
"torch._dl",
NULL,
-1,
TorchDlMethods
// NOLINTNEXTLINE(clang-diagnostic-missing-field-initializers)
};
PyMODINIT_FUNC PyInit__dl(void)
{
#define ASSERT_TRUE(cmd) if (!(cmd)) return NULL
ASSERT_TRUE(module = PyModule_Create(&torchdlmodule));
ASSERT_TRUE(PyModule_AddIntConstant(module, "RTLD_GLOBAL", (int64_t) RTLD_GLOBAL) == 0);
ASSERT_TRUE(PyModule_AddIntConstant(module, "RTLD_NOW", (int64_t) RTLD_NOW) == 0);
ASSERT_TRUE(PyModule_AddIntConstant(module, "RTLD_LAZY", (int64_t) RTLD_LAZY) == 0);
return module;
#undef ASSERT_TRUE
}