llvm/llvm/examples/OrcV2Examples/OrcV2CBindingsMCJITLikeMemoryManager/OrcV2CBindingsMCJITLikeMemoryManager.c

//=== OrcV2CBindingsMemoryManager.c - OrcV2 Memory Manager C Bindings Demo ===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This demo illustrates the C-API bindings for custom memory managers in
// ORCv2. They are used here to place generated code into manually allocated
// buffers that are subsequently marked as executable.
//
//===----------------------------------------------------------------------===//

#include "llvm-c/Core.h"
#include "llvm-c/Error.h"
#include "llvm-c/LLJIT.h"
#include "llvm-c/OrcEE.h"
#include "llvm-c/Support.h"
#include "llvm-c/Target.h"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

#if defined(_WIN32)
#include <windows.h>
#else
#include <dlfcn.h>
#include <sys/mman.h>
#endif

struct Section {};

char CtxCtxPlaceholder;
char CtxPlaceholder;

#define MaxSections
static size_t SectionCount =;
static struct Section Sections[MaxSections];

void *addSection(size_t Size, LLVMBool IsCode) {}

// Callbacks to create the context for the subsequent functions (not used in
// this example)
void *memCreateContext(void *CtxCtx) {}

void memNotifyTerminating(void *CtxCtx) {}

uint8_t *memAllocate(void *Opaque, uintptr_t Size, unsigned Align, unsigned Id,
                     const char *Name) {}

uint8_t *memAllocateData(void *Opaque, uintptr_t Size, unsigned Align,
                         unsigned Id, const char *Name, LLVMBool ReadOnly) {}

LLVMBool memFinalize(void *Opaque, char **Err) {}

void memDestroy(void *Opaque) {}

LLVMOrcObjectLayerRef objectLinkingLayerCreator(void *Opaque,
                                                LLVMOrcExecutionSessionRef ES,
                                                const char *Triple) {}

int handleError(LLVMErrorRef Err) {}

LLVMOrcThreadSafeModuleRef createDemoModule(void) {}

int main(int argc, const char *argv[]) {}