1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ANDROID_BCC_BCC_H 18 #define ANDROID_BCC_BCC_H 19 20 #include <stddef.h> 21 #include <stdint.h> 22 23 /*-------------------------------------------------------------------------*/ 24 25 /* libbcc script opaque type */ 26 typedef struct BCCOpaqueScript *BCCScriptRef; 27 28 29 /* Symbol lookup function type */ 30 typedef void *(*BCCSymbolLookupFn)(void *context, char const *symbolName); 31 32 33 /* llvm::Module (see <llvm>/include/llvm-c/Core.h for details) */ 34 typedef struct LLVMOpaqueModule *LLVMModuleRef; 35 36 37 /*-------------------------------------------------------------------------*/ 38 39 40 #define BCC_NO_ERROR 0x0000 41 #define BCC_INVALID_ENUM 0x0500 42 #define BCC_INVALID_OPERATION 0x0502 43 #define BCC_INVALID_VALUE 0x0501 44 #define BCC_OUT_OF_MEMORY 0x0505 45 46 47 /*-------------------------------------------------------------------------*/ 48 49 50 /* Optional Flags for bccReadBC, bccReadFile, bccLinkBC, bccLinkFile */ 51 #define BCC_SKIP_DEP_SHA1 (1 << 0) 52 53 54 /*-------------------------------------------------------------------------*/ 55 56 57 #ifdef __cplusplus 58 extern "C" { 59 #endif 60 61 BCCScriptRef bccCreateScript(); 62 63 void bccDisposeScript(BCCScriptRef script); 64 65 int bccRegisterSymbolCallback(BCCScriptRef script, 66 BCCSymbolLookupFn pFn, 67 void *pContext); 68 69 int bccGetError(BCCScriptRef script); /* deprecated */ 70 71 72 73 int bccReadBC(BCCScriptRef script, 74 char const *resName, 75 char const *bitcode, 76 size_t bitcodeSize, 77 unsigned long flags); 78 79 int bccReadModule(BCCScriptRef script, 80 char const *resName, 81 LLVMModuleRef module, 82 unsigned long flags); 83 84 int bccReadFile(BCCScriptRef script, 85 char const *path, 86 unsigned long flags); 87 88 int bccLinkBC(BCCScriptRef script, 89 char const *resName, 90 char const *bitcode, 91 size_t bitcodeSize, 92 unsigned long flags); 93 94 int bccLinkFile(BCCScriptRef script, 95 char const *path, 96 unsigned long flags); 97 98 void bccMarkExternalSymbol(BCCScriptRef script, char const *name); 99 100 int bccPrepareSharedObject(BCCScriptRef script, 101 char const *cacheDir, 102 char const *cacheName, 103 unsigned long flags); 104 105 int bccPrepareExecutable(BCCScriptRef script, 106 char const *cacheDir, 107 char const *cacheName, 108 unsigned long flags); 109 110 void *bccGetFuncAddr(BCCScriptRef script, char const *funcname); 111 112 void bccGetExportVarList(BCCScriptRef script, 113 size_t varListSize, 114 void **varList); 115 116 void bccGetExportFuncList(BCCScriptRef script, 117 size_t funcListSize, 118 void **funcList); 119 120 char const *bccGetBuildTime(); 121 122 char const *bccGetBuildRev(); 123 124 char const *bccGetBuildSHA1(); 125 126 #ifdef __cplusplus 127 }; 128 #endif 129 130 /*-------------------------------------------------------------------------*/ 131 132 #endif 133