Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 1 | /* |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 2 | * Copyright (C) 2010 The Android Open Source Project |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 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 <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | typedef char BCCchar; |
| 24 | typedef int32_t BCCint; |
| 25 | typedef uint32_t BCCuint; |
| 26 | typedef ssize_t BCCsizei; |
| 27 | typedef unsigned int BCCenum; |
| 28 | typedef void BCCvoid; |
Logan | 3f3d31f | 2010-11-27 13:52:03 +0800 | [diff] [blame] | 29 | |
| 30 | #if !defined(__cplusplus) |
| 31 | |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 32 | typedef struct BCCscript BCCscript; |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 33 | |
Logan | 3f3d31f | 2010-11-27 13:52:03 +0800 | [diff] [blame] | 34 | #else |
| 35 | |
| 36 | namespace bcc { |
Logan | 0647e9e | 2010-12-29 00:21:31 +0800 | [diff] [blame] | 37 | class Script; |
Logan | 3f3d31f | 2010-11-27 13:52:03 +0800 | [diff] [blame] | 38 | } |
| 39 | |
Logan | 0647e9e | 2010-12-29 00:21:31 +0800 | [diff] [blame] | 40 | typedef bcc::Script BCCscript; |
Logan | 3f3d31f | 2010-11-27 13:52:03 +0800 | [diff] [blame] | 41 | |
| 42 | #endif |
| 43 | |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 44 | #define BCC_NO_ERROR 0x0000 |
| 45 | #define BCC_INVALID_ENUM 0x0500 |
| 46 | #define BCC_INVALID_OPERATION 0x0502 |
| 47 | #define BCC_INVALID_VALUE 0x0501 |
| 48 | #define BCC_OUT_OF_MEMORY 0x0505 |
| 49 | |
| 50 | #define BCC_COMPILE_STATUS 0x8B81 |
| 51 | #define BCC_INFO_LOG_LENGTH 0x8B84 |
| 52 | |
| 53 | |
| 54 | // ---------------------------------------------------------------------------- |
| 55 | |
| 56 | #ifdef __cplusplus |
| 57 | extern "C" { |
| 58 | #endif |
| 59 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 60 | BCCscript *bccCreateScript(); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 61 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 62 | void bccDeleteScript(BCCscript *script); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 63 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 64 | typedef BCCvoid *(*BCCSymbolLookupFn)(BCCvoid *pContext, const BCCchar *name); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 65 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 66 | void bccRegisterSymbolCallback(BCCscript *script, |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 67 | BCCSymbolLookupFn pFn, |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 68 | BCCvoid *pContext); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 69 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 70 | BCCenum bccGetError( BCCscript *script ); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 71 | |
Shih-wei Liao | 7c5a5f7 | 2010-11-08 01:59:13 -0800 | [diff] [blame] | 72 | int bccReadBC(BCCscript *script, |
| 73 | const BCCchar *bitcode, |
Logan | b9b0416 | 2010-12-20 16:36:57 +0800 | [diff] [blame] | 74 | BCCint bitcodeSize, |
| 75 | long bitcodeFileModTime, |
| 76 | long bitcodeFileCRC32, |
Shih-wei Liao | e6a1851 | 2010-12-09 12:38:10 -0800 | [diff] [blame] | 77 | const BCCchar *resName, |
| 78 | const BCCchar *cacheDir); |
Shih-wei Liao | 7c5a5f7 | 2010-11-08 01:59:13 -0800 | [diff] [blame] | 79 | |
| 80 | int bccLoadBinary(BCCscript *script); |
Zonr Chang | dbee68b | 2010-10-22 05:02:16 +0800 | [diff] [blame] | 81 | |
| 82 | // Interface for llvm::Module input. @module should be a valid llvm::Module |
| 83 | // instance. |
Shih-wei Liao | 7c5a5f7 | 2010-11-08 01:59:13 -0800 | [diff] [blame] | 84 | int bccReadModule(BCCscript *script, |
| 85 | BCCvoid *module); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 86 | |
Shih-wei Liao | 7c5a5f7 | 2010-11-08 01:59:13 -0800 | [diff] [blame] | 87 | void bccLinkBC(BCCscript *script, |
| 88 | const BCCchar *bitcode, |
| 89 | BCCint size); |
Zonr Chang | 97f5e61 | 2010-10-22 20:38:26 +0800 | [diff] [blame] | 90 | |
Logan | d80e65b | 2010-12-03 21:28:04 +0800 | [diff] [blame] | 91 | int bccCompileBC(BCCscript *script); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 92 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 93 | void bccGetScriptInfoLog(BCCscript *script, |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 94 | BCCsizei maxLength, |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 95 | BCCsizei *length, |
| 96 | BCCchar *infoLog); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 97 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 98 | void bccGetScriptLabel(BCCscript *script, |
| 99 | const BCCchar *name, |
| 100 | BCCvoid **address); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 101 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 102 | void bccGetExportVars(BCCscript *script, |
| 103 | BCCsizei *actualVarCount, |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 104 | BCCsizei maxVarCount, |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 105 | BCCvoid **vars); |
Shih-wei Liao | abd1e3d | 2010-04-28 01:47:00 -0700 | [diff] [blame] | 106 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 107 | void bccGetExportFuncs(BCCscript *script, |
| 108 | BCCsizei *actualFuncCount, |
Shih-wei Liao | 6bfd542 | 2010-05-07 05:20:22 -0700 | [diff] [blame] | 109 | BCCsizei maxFuncCount, |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 110 | BCCvoid **funcs); |
Shih-wei Liao | 6bfd542 | 2010-05-07 05:20:22 -0700 | [diff] [blame] | 111 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 112 | void bccGetPragmas(BCCscript *script, |
| 113 | BCCsizei *actualStringCount, |
| 114 | BCCsizei maxStringCount, |
| 115 | BCCchar **strings); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 116 | |
Shih-wei Liao | 6bfd542 | 2010-05-07 05:20:22 -0700 | [diff] [blame] | 117 | // Below two functions are for debugging |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 118 | void bccGetFunctions(BCCscript *script, |
| 119 | BCCsizei *actualFunctionCount, |
| 120 | BCCsizei maxFunctionCount, |
| 121 | BCCchar **functions); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 122 | |
Zonr Chang | 932648d | 2010-10-13 22:23:56 +0800 | [diff] [blame] | 123 | void bccGetFunctionBinary(BCCscript *script, |
| 124 | BCCchar *function, |
| 125 | BCCvoid **base, |
| 126 | BCCsizei *length); |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 127 | |
Shih-wei Liao | 77ed614 | 2010-04-07 12:21:42 -0700 | [diff] [blame] | 128 | #ifdef __cplusplus |
| 129 | }; |
| 130 | #endif |
| 131 | |
| 132 | // ---------------------------------------------------------------------------- |
| 133 | |
| 134 | #endif |