[PATCH] llvm-c: use typedef for function pointers

Anders Waldenborg anders at 0x63.nu
Wed Sep 18 12:35:07 PDT 2013


wanders added you to the CC list for the revision "llvm-c: use typedef for function pointers".

Hi baldrick,

This makes it consistent with other function pointers used in llvm-c

http://llvm-reviews.chandlerc.com/D1712

Files:
  include/llvm-c/ExecutionEngine.h
  lib/ExecutionEngine/ExecutionEngineBindings.cpp

Index: include/llvm-c/ExecutionEngine.h
===================================================================
--- include/llvm-c/ExecutionEngine.h
+++ include/llvm-c/ExecutionEngine.h
@@ -171,6 +171,15 @@
 
 /*===-- Operations on memory managers -------------------------------------===*/
 
+typedef uint8_t *(*LLVMMemoryManagerAllocateCodeSectionCallback)(void *Opaque,
+						    uintptr_t Size, unsigned Alignment,
+						    unsigned SectionID);
+typedef uint8_t *(*LLVMMemoryManagerAllocateDataSectionCallback)(void *Opaque,
+						    uintptr_t Size, unsigned Alignment,
+						    unsigned SectionID, LLVMBool IsReadOnly);
+typedef LLVMBool (*LLVMMemoryManagerFinalizeMemoryCallback)(void *Opaque, char **ErrMsg);
+typedef void (*LLVMMemoryManagerDestroyCallback)(void *Opaque);
+
 /**
  * Create a simple custom MCJIT memory manager. This memory manager can
  * intercept allocations in a module-oblivious way. This will return NULL
@@ -184,14 +193,10 @@
  */
 LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager(
   void *Opaque,
-  uint8_t *(*AllocateCodeSection)(void *Opaque,
-                                  uintptr_t Size, unsigned Alignment,
-                                  unsigned SectionID),
-  uint8_t *(*AllocateDataSection)(void *Opaque,
-                                  uintptr_t Size, unsigned Alignment,
-                                  unsigned SectionID, LLVMBool IsReadOnly),
-  LLVMBool (*FinalizeMemory)(void *Opaque, char **ErrMsg),
-  void (*Destroy)(void *Opaque));
+  LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection,
+  LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection,
+  LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory,
+  LLVMMemoryManagerDestroyCallback Destory);
 
 void LLVMDisposeMCJITMemoryManager(LLVMMCJITMemoryManagerRef MM);
 
Index: lib/ExecutionEngine/ExecutionEngineBindings.cpp
===================================================================
--- lib/ExecutionEngine/ExecutionEngineBindings.cpp
+++ lib/ExecutionEngine/ExecutionEngineBindings.cpp
@@ -339,14 +339,10 @@
 namespace {
 
 struct SimpleBindingMMFunctions {
-  uint8_t *(*AllocateCodeSection)(void *Opaque,
-                                  uintptr_t Size, unsigned Alignment,
-                                  unsigned SectionID);
-  uint8_t *(*AllocateDataSection)(void *Opaque,
-                                  uintptr_t Size, unsigned Alignment,
-                                  unsigned SectionID, LLVMBool IsReadOnly);
-  LLVMBool (*FinalizeMemory)(void *Opaque, char **ErrMsg);
-  void (*Destroy)(void *Opaque);
+  LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection;
+  LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection;
+  LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory;
+  LLVMMemoryManagerDestroyCallback Destroy;
 };
 
 class SimpleBindingMemoryManager : public RTDyldMemoryManager {
@@ -415,14 +411,10 @@
 
 LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager(
   void *Opaque,
-  uint8_t *(*AllocateCodeSection)(void *Opaque,
-                                  uintptr_t Size, unsigned Alignment,
-                                  unsigned SectionID),
-  uint8_t *(*AllocateDataSection)(void *Opaque,
-                                  uintptr_t Size, unsigned Alignment,
-                                  unsigned SectionID, LLVMBool IsReadOnly),
-  LLVMBool (*FinalizeMemory)(void *Opaque, char **ErrMsg),
-  void (*Destroy)(void *Opaque)) {
+  LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection,
+  LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection,
+  LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory,
+  LLVMMemoryManagerDestroyCallback Destroy) {
   
   if (!AllocateCodeSection || !AllocateDataSection || !FinalizeMemory ||
       !Destroy)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1712.1.patch
Type: text/x-patch
Size: 3819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130918/ecd5124e/attachment.bin>


More information about the llvm-commits mailing list