blob: dd895d2ba600c864acbd48bb5d4616d5388e7985 [file] [log] [blame]
Yong WU355383f2014-07-24 21:32:15 +08001/*
2 * Copyright (C) 2014 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 ART_RUNTIME_NATIVE_BRIDGE_H_
18#define ART_RUNTIME_NATIVE_BRIDGE_H_
19
20#include "base/mutex.h"
21
22namespace art {
23
24struct NativeBridgeCallbacks;
25
26class NativeBridge {
27 public:
28 // Load a shared library that is supported by the native-bridge.
29 static void* LoadLibrary(const char* libpath, int flag);
30 // Get a native-bridge trampoline for specified native method.
31 static void* GetTrampoline(void* handle, const char* name, const char* shorty, uint32_t len);
32 // True if native library is valid and is for an ABI that is supported by native-bridge.
33 static bool IsSupported(const char* libpath);
34
35 private:
36 static bool Init();
37 static bool initialized_ GUARDED_BY(lock_);
38 static Mutex lock_;
39 static NativeBridgeCallbacks* callbacks_;
40};
41
42}; // namespace art
43
44#endif // ART_RUNTIME_NATIVE_BRIDGE_H_