Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
numba
GitHub Repository: numba/llvmlite
Path: blob/main/ffi/core.cpp
1154 views
1
#include "core.h"
2
3
#include "llvm-c/Support.h"
4
5
extern "C" {
6
7
API_EXPORT(const char *)
8
LLVMPY_CreateString(const char *msg) { return strdup(msg); }
9
10
API_EXPORT(const char *)
11
LLVMPY_CreateByteString(const char *buf, size_t len) {
12
char *dest = (char *)malloc(len + 1);
13
if (dest != NULL) {
14
memcpy(dest, buf, len);
15
dest[len] = '\0';
16
}
17
return dest;
18
}
19
20
API_EXPORT(void)
21
LLVMPY_DisposeString(const char *msg) { free(const_cast<char *>(msg)); }
22
23
API_EXPORT(LLVMContextRef)
24
LLVMPY_GetGlobalContext() {
25
auto context = LLVMGetGlobalContext();
26
return context;
27
}
28
29
API_EXPORT(LLVMContextRef)
30
LLVMPY_ContextCreate() {
31
LLVMContextRef context = LLVMContextCreate();
32
return context;
33
}
34
35
API_EXPORT(void)
36
LLVMPY_ContextDispose(LLVMContextRef context) {
37
return LLVMContextDispose(context);
38
}
39
40
API_EXPORT(void)
41
LLVMPY_SetCommandLine(const char *name, const char *option) {
42
const char *argv[] = {name, option};
43
LLVMParseCommandLineOptions(2, argv, NULL);
44
}
45
46
} // end extern "C"
47
48