summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDimitry Ivanov <dimitry@google.com>2016-10-26 20:11:25 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-10-26 20:11:25 +0000
commit996cfc70a00f9ec56cd7b8c902e2c7a1228dba65 (patch)
tree8c650407ef711e011333d7be43123e4d1642a1ae /include
parent66321bc8891ee95f48d08c7d825969bb4fecccc4 (diff)
parent28c0c0762eb8d0de011d85b577244d26a7c00fd0 (diff)
downloadsystem_core-996cfc70a00f9ec56cd7b8c902e2c7a1228dba65.tar.gz
system_core-996cfc70a00f9ec56cd7b8c902e2c7a1228dba65.tar.bz2
system_core-996cfc70a00f9ec56cd7b8c902e2c7a1228dba65.zip
Merge "Upgrade native bridge to version 3 to support namespace"
am: 28c0c0762e Change-Id: Ic4263e89f59b1ad34f1f8f28b52f4b45a4df351d
Diffstat (limited to 'include')
-rw-r--r--include/nativebridge/native_bridge.h139
1 files changed, 138 insertions, 1 deletions
diff --git a/include/nativebridge/native_bridge.h b/include/nativebridge/native_bridge.h
index 18300bc87..26556f048 100644
--- a/include/nativebridge/native_bridge.h
+++ b/include/nativebridge/native_bridge.h
@@ -62,12 +62,19 @@ bool NativeBridgeAvailable();
bool NativeBridgeInitialized();
// Load a shared library that is supported by the native bridge.
+//
+// Starting with v3, NativeBridge has two scenarios: with/without namespace.
+// Use NativeBridgeLoadLibraryExt() instead in namespace scenario.
void* NativeBridgeLoadLibrary(const char* libpath, int flag);
// Get a native bridge trampoline for specified native method.
void* NativeBridgeGetTrampoline(void* handle, const char* name, const char* shorty, uint32_t len);
-// True if native library is valid and is for an ABI that is supported by native bridge.
+// True if native library paths are valid and is for an ABI that is supported by native bridge.
+// The *libpath* must point to a library.
+//
+// Starting with v3, NativeBridge has two scenarios: with/without namespace.
+// Use NativeBridgeIsPathSupported() instead in namespace scenario.
bool NativeBridgeIsSupported(const char* libpath);
// Returns the version number of the native bridge. This information is available after a
@@ -91,6 +98,48 @@ bool NativeBridgeError();
// This functionality is exposed mainly for testing.
bool NativeBridgeNameAcceptable(const char* native_bridge_library_filename);
+// Decrements the reference count on the dynamic library handler. If the reference count drops
+// to zero then the dynamic library is unloaded.
+int NativeBridgeUnloadLibrary(void* handle);
+
+// Get last error message of native bridge when fail to load library or search symbol.
+// This is reflection of dlerror() for native bridge.
+char* NativeBridgeGetError();
+
+struct native_bridge_namespace_t;
+
+// True if native library paths are valid and is for an ABI that is supported by native bridge.
+// Different from NativeBridgeIsSupported(), the *path* here must be a directory containing
+// libraries of an ABI.
+//
+// Starting with v3, NativeBridge has two scenarios: with/without namespace.
+// Use NativeBridgeIsSupported() instead in non-namespace scenario.
+bool NativeBridgeIsPathSupported(const char* path);
+
+// Initializes public and anonymous namespace at native bridge side.
+//
+// Starting with v3, NativeBridge has two scenarios: with/without namespace.
+// Should not use in non-namespace scenario.
+bool NativeBridgeInitNamespace(const char* public_ns_sonames,
+ const char* anon_ns_library_path);
+
+// Create a namespace and pass the key of related namespaces to native bridge.
+//
+// Starting with v3, NativeBridge has two scenarios: with/without namespace.
+// Should not use in non-namespace scenario.
+native_bridge_namespace_t* NativeBridgeCreateNamespace(const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path,
+ native_bridge_namespace_t* parent_ns);
+
+// Load a shared library with namespace key that is supported by the native bridge.
+//
+// Starting with v3, NativeBridge has two scenarios: with/without namespace.
+// Use NativeBridgeLoadLibrary() instead in non-namespace scenario.
+void* NativeBridgeLoadLibraryExt(const char* libpath, int flag, native_bridge_namespace_t* ns);
+
// Native bridge interfaces to runtime.
struct NativeBridgeCallbacks {
// Version number of the interface.
@@ -114,6 +163,9 @@ struct NativeBridgeCallbacks {
// flag [IN] the stardard RTLD_XXX defined in bionic dlfcn.h
// Returns:
// The opaque handle of the shared library if sucessful, otherwise NULL
+ //
+ // Starting with v3, NativeBridge has two scenarios: with/without namespace.
+ // Use loadLibraryExt instead in namespace scenario.
void* (*loadLibrary)(const char* libpath, int flag);
// Get a native bridge trampoline for specified native method. The trampoline has same
@@ -133,6 +185,9 @@ struct NativeBridgeCallbacks {
// libpath [IN] path to the shared library
// Returns:
// TRUE if library is supported by native bridge, FALSE otherwise
+ //
+ // Starting with v3, NativeBridge has two scenarios: with/without namespace.
+ // Use isPathSupported instead in namespace scenario.
bool (*isSupported)(const char* libpath);
// Provide environment values required by the app running with native bridge according to the
@@ -169,6 +224,88 @@ struct NativeBridgeCallbacks {
// runtime.
// Otherwise, a pointer to the signal handler.
NativeBridgeSignalHandlerFn (*getSignalHandler)(int signal);
+
+ // Added callbacks in version 3.
+
+ // Decrements the reference count on the dynamic library handler. If the reference count drops
+ // to zero then the dynamic library is unloaded.
+ //
+ // Parameters:
+ // handle [IN] the handler of a dynamic library.
+ //
+ // Returns:
+ // 0 on success, and nonzero on error.
+ int (*unloadLibrary)(void* handle);
+
+ // Dump the last failure message of native bridge when fail to load library or search symbol.
+ //
+ // Parameters:
+ //
+ // Returns:
+ // A string describing the most recent error that occurred when load library
+ // or lookup symbol via native bridge.
+ char* (*getError)();
+
+ // Check whether library paths are supported by native bridge.
+ //
+ // Parameters:
+ // library_path [IN] search paths for native libraries (directories separated by ':')
+ // Returns:
+ // TRUE if libraries within search paths are supported by native bridge, FALSE otherwise
+ //
+ // Starting with v3, NativeBridge has two scenarios: with/without namespace.
+ // Use isSupported instead in non-namespace scenario.
+ bool (*isPathSupported)(const char* library_path);
+
+ // Initializes anonymous namespace at native bridge side and pass the key of
+ // two namespaces(default and anonymous) owned by dynamic linker to native bridge.
+ //
+ // Parameters:
+ // public_ns_sonames [IN] the name of "public" libraries.
+ // anon_ns_library_path [IN] the library search path of (anonymous) namespace.
+ // Returns:
+ // true if the pass is ok.
+ // Otherwise, false.
+ //
+ // Starting with v3, NativeBridge has two scenarios: with/without namespace.
+ // Should not use in non-namespace scenario.
+ bool (*initNamespace)(const char* public_ns_sonames,
+ const char* anon_ns_library_path);
+
+
+ // Create a namespace and pass the key of releated namespaces to native bridge.
+ //
+ // Parameters:
+ // name [IN] the name of the namespace.
+ // ld_library_path [IN] the first set of library search paths of the namespace.
+ // default_library_path [IN] the second set of library search path of the namespace.
+ // type [IN] the attribute of the namespace.
+ // permitted_when_isolated_path [IN] the permitted path for isolated namespace(if it is).
+ // parent_ns [IN] the pointer of the parent namespace to be inherited from.
+ // Returns:
+ // native_bridge_namespace_t* for created namespace or nullptr in the case of error.
+ //
+ // Starting with v3, NativeBridge has two scenarios: with/without namespace.
+ // Should not use in non-namespace scenario.
+ native_bridge_namespace_t* (*createNamespace)(const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path,
+ native_bridge_namespace_t* parent_ns);
+
+ // Load a shared library within a namespace.
+ //
+ // Parameters:
+ // libpath [IN] path to the shared library
+ // flag [IN] the stardard RTLD_XXX defined in bionic dlfcn.h
+ // ns [IN] the pointer of the namespace in which the library should be loaded.
+ // Returns:
+ // The opaque handle of the shared library if sucessful, otherwise NULL
+ //
+ // Starting with v3, NativeBridge has two scenarios: with/without namespace.
+ // Use loadLibrary instead in non-namespace scenario.
+ void* (*loadLibraryExt)(const char* libpath, int flag, native_bridge_namespace_t* ns);
};
// Runtime interfaces to native bridge.