blob: 134ebc053c643af783c60c662eb81507a0882ee3 [file] [log] [blame]
Shih-wei Liao77ed6142010-04-07 12:21:42 -07001/*
Zonr Chang932648d2010-10-13 22:23:56 +08002 * Copyright (C) 2010 The Android Open Source Project
Shih-wei Liao77ed6142010-04-07 12:21:42 -07003 *
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
23typedef char BCCchar;
24typedef int32_t BCCint;
25typedef uint32_t BCCuint;
26typedef ssize_t BCCsizei;
27typedef unsigned int BCCenum;
28typedef void BCCvoid;
Logan3f3d31f2010-11-27 13:52:03 +080029
30#if !defined(__cplusplus)
31
Shih-wei Liao77ed6142010-04-07 12:21:42 -070032typedef struct BCCscript BCCscript;
Shih-wei Liao77ed6142010-04-07 12:21:42 -070033
Logan3f3d31f2010-11-27 13:52:03 +080034#else
35
36namespace bcc {
Logan0647e9e2010-12-29 00:21:31 +080037 class Script;
Logan3f3d31f2010-11-27 13:52:03 +080038}
39
Logan0647e9e2010-12-29 00:21:31 +080040typedef bcc::Script BCCscript;
Logan3f3d31f2010-11-27 13:52:03 +080041
42#endif
43
Shih-wei Liao77ed6142010-04-07 12:21:42 -070044#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
57extern "C" {
58#endif
59
Zonr Chang932648d2010-10-13 22:23:56 +080060BCCscript *bccCreateScript();
Shih-wei Liao77ed6142010-04-07 12:21:42 -070061
Zonr Chang932648d2010-10-13 22:23:56 +080062void bccDeleteScript(BCCscript *script);
Shih-wei Liao77ed6142010-04-07 12:21:42 -070063
Zonr Chang932648d2010-10-13 22:23:56 +080064typedef BCCvoid *(*BCCSymbolLookupFn)(BCCvoid *pContext, const BCCchar *name);
Shih-wei Liao77ed6142010-04-07 12:21:42 -070065
Zonr Chang932648d2010-10-13 22:23:56 +080066void bccRegisterSymbolCallback(BCCscript *script,
Shih-wei Liao77ed6142010-04-07 12:21:42 -070067 BCCSymbolLookupFn pFn,
Zonr Chang932648d2010-10-13 22:23:56 +080068 BCCvoid *pContext);
Shih-wei Liao77ed6142010-04-07 12:21:42 -070069
Zonr Chang932648d2010-10-13 22:23:56 +080070BCCenum bccGetError( BCCscript *script );
Shih-wei Liao77ed6142010-04-07 12:21:42 -070071
Shih-wei Liao7c5a5f72010-11-08 01:59:13 -080072int bccReadBC(BCCscript *script,
73 const BCCchar *bitcode,
Loganb9b04162010-12-20 16:36:57 +080074 BCCint bitcodeSize,
75 long bitcodeFileModTime,
76 long bitcodeFileCRC32,
Shih-wei Liaoe6a18512010-12-09 12:38:10 -080077 const BCCchar *resName,
78 const BCCchar *cacheDir);
Shih-wei Liao7c5a5f72010-11-08 01:59:13 -080079
80int bccLoadBinary(BCCscript *script);
Zonr Changdbee68b2010-10-22 05:02:16 +080081
82// Interface for llvm::Module input. @module should be a valid llvm::Module
83// instance.
Shih-wei Liao7c5a5f72010-11-08 01:59:13 -080084int bccReadModule(BCCscript *script,
85 BCCvoid *module);
Shih-wei Liao77ed6142010-04-07 12:21:42 -070086
Shih-wei Liao7c5a5f72010-11-08 01:59:13 -080087void bccLinkBC(BCCscript *script,
88 const BCCchar *bitcode,
89 BCCint size);
Zonr Chang97f5e612010-10-22 20:38:26 +080090
Logand80e65b2010-12-03 21:28:04 +080091int bccCompileBC(BCCscript *script);
Shih-wei Liao77ed6142010-04-07 12:21:42 -070092
Zonr Chang932648d2010-10-13 22:23:56 +080093void bccGetScriptInfoLog(BCCscript *script,
Shih-wei Liao77ed6142010-04-07 12:21:42 -070094 BCCsizei maxLength,
Zonr Chang932648d2010-10-13 22:23:56 +080095 BCCsizei *length,
96 BCCchar *infoLog);
Shih-wei Liao77ed6142010-04-07 12:21:42 -070097
Zonr Chang932648d2010-10-13 22:23:56 +080098void bccGetScriptLabel(BCCscript *script,
99 const BCCchar *name,
100 BCCvoid **address);
Shih-wei Liao77ed6142010-04-07 12:21:42 -0700101
Zonr Chang932648d2010-10-13 22:23:56 +0800102void bccGetExportVars(BCCscript *script,
103 BCCsizei *actualVarCount,
Shih-wei Liaoabd1e3d2010-04-28 01:47:00 -0700104 BCCsizei maxVarCount,
Zonr Chang932648d2010-10-13 22:23:56 +0800105 BCCvoid **vars);
Shih-wei Liaoabd1e3d2010-04-28 01:47:00 -0700106
Zonr Chang932648d2010-10-13 22:23:56 +0800107void bccGetExportFuncs(BCCscript *script,
108 BCCsizei *actualFuncCount,
Shih-wei Liao6bfd5422010-05-07 05:20:22 -0700109 BCCsizei maxFuncCount,
Zonr Chang932648d2010-10-13 22:23:56 +0800110 BCCvoid **funcs);
Shih-wei Liao6bfd5422010-05-07 05:20:22 -0700111
Zonr Chang932648d2010-10-13 22:23:56 +0800112void bccGetPragmas(BCCscript *script,
113 BCCsizei *actualStringCount,
114 BCCsizei maxStringCount,
115 BCCchar **strings);
Shih-wei Liao77ed6142010-04-07 12:21:42 -0700116
Shih-wei Liao6bfd5422010-05-07 05:20:22 -0700117// Below two functions are for debugging
Zonr Chang932648d2010-10-13 22:23:56 +0800118void bccGetFunctions(BCCscript *script,
119 BCCsizei *actualFunctionCount,
120 BCCsizei maxFunctionCount,
121 BCCchar **functions);
Shih-wei Liao77ed6142010-04-07 12:21:42 -0700122
Zonr Chang932648d2010-10-13 22:23:56 +0800123void bccGetFunctionBinary(BCCscript *script,
124 BCCchar *function,
125 BCCvoid **base,
126 BCCsizei *length);
Shih-wei Liao77ed6142010-04-07 12:21:42 -0700127
Shih-wei Liao77ed6142010-04-07 12:21:42 -0700128#ifdef __cplusplus
129};
130#endif
131
132// ----------------------------------------------------------------------------
133
134#endif