http server
This commit is contained in:
@@ -3,10 +3,10 @@ const c = llvm.c;
|
||||
|
||||
pub const Builtins = struct {
|
||||
printf_fn: c.LLVMValueRef,
|
||||
calloc_fn: c.LLVMValueRef,
|
||||
malloc_fn: c.LLVMValueRef,
|
||||
free_fn: c.LLVMValueRef,
|
||||
memcpy_fn: c.LLVMValueRef,
|
||||
memset_fn: c.LLVMValueRef,
|
||||
|
||||
pub fn init(module: c.LLVMModuleRef, ctx: c.LLVMContextRef) Builtins {
|
||||
const ptr_type = c.LLVMPointerTypeInContext(ctx, 0);
|
||||
@@ -19,11 +19,6 @@ pub const Builtins = struct {
|
||||
const printf_type = c.LLVMFunctionType(i32_type, &printf_params, 1, 1);
|
||||
const printf_fn = c.LLVMAddFunction(module, "printf", printf_type);
|
||||
|
||||
// Declare: void* calloc(size_t count, size_t size)
|
||||
var calloc_params = [_]c.LLVMTypeRef{ i64_type, i64_type };
|
||||
const calloc_type = c.LLVMFunctionType(ptr_type, &calloc_params, 2, 0);
|
||||
const calloc_fn = c.LLVMAddFunction(module, "calloc", calloc_type);
|
||||
|
||||
// Declare: void* malloc(size_t size)
|
||||
var malloc_params = [_]c.LLVMTypeRef{i64_type};
|
||||
const malloc_type = c.LLVMFunctionType(ptr_type, &malloc_params, 1, 0);
|
||||
@@ -39,12 +34,17 @@ pub const Builtins = struct {
|
||||
const memcpy_type = c.LLVMFunctionType(ptr_type, &memcpy_params, 3, 0);
|
||||
const memcpy_fn = c.LLVMAddFunction(module, "memcpy", memcpy_type);
|
||||
|
||||
// Declare: void* memset(void* s, int c, size_t n)
|
||||
var memset_params = [_]c.LLVMTypeRef{ ptr_type, i32_type, i64_type };
|
||||
const memset_type = c.LLVMFunctionType(ptr_type, &memset_params, 3, 0);
|
||||
const memset_fn = c.LLVMAddFunction(module, "memset", memset_type);
|
||||
|
||||
return .{
|
||||
.printf_fn = printf_fn,
|
||||
.calloc_fn = calloc_fn,
|
||||
.malloc_fn = malloc_fn,
|
||||
.free_fn = free_fn,
|
||||
.memcpy_fn = memcpy_fn,
|
||||
.memset_fn = memset_fn,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user