[-]
[+]
|
Changed |
_service:tar_git:libhybris.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris.spec
^
|
|
[-]
[+]
|
Changed |
_service
^
|
@@ -2,7 +2,7 @@
<service name="tar_git">
<param name="url">https://github.com/mer-hybris/libhybris.git</param>
<param name="branch">master</param>
- <param name="revision">20bcd5be11fcd82aa9e2e995c4bb37af9c94cbad</param>
+ <param name="revision">ffa30dad131856e847fdaaf4aa6a41a329f20982</param>
<param name="token"/>
<param name="debian">N</param>
<param name="dumb">N</param>
|
[-]
[+]
|
Deleted |
_service:tar_git:libhybris-0.0.5.25.tar.bz2/libhybris/hybris/properties/properties.c
^
|
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2012 Carsten Munk <carsten.munk@gmail.com>
- * 2008 The Android Open Source Project
- * 2013 Simon Busch <morphis@gravedo.de>
- * 2013 Canonical Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stddef.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#define __USE_GNU
-#include <unistd.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/select.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <poll.h>
-
-#include <hybris/properties/properties.h>
-#include "properties_p.h"
-
-
-static const char property_service_socket[] = "/dev/socket/" PROP_SERVICE_NAME;
-static int send_prop_msg_no_reply = 0;
-
-/* Get/Set a property from the Android Init property socket */
-static int send_prop_msg(prop_msg_t *msg,
- void (*propfn)(const char *, const char *, void *),
- void *cookie)
-{
- union {
- struct sockaddr_un addr;
- struct sockaddr addr_g;
- } addr;
- socklen_t alen;
- size_t namelen;
- int s;
- int r;
- int result = -1;
- int patched_init = 0;
-
- /* if we tried to talk to the server in the past and didn't get a reply,
- * it's fairly safe to say that init is not patched and this is all
- * hopeless, so we should just quit while we're ahead
- */
- if (send_prop_msg_no_reply == 1)
- return -EIO;
-
- s = socket(AF_LOCAL, SOCK_STREAM, 0);
- if (s < 0) {
- return result;
- }
-
- memset(&addr, 0, sizeof(addr));
- namelen = strlen(property_service_socket);
- strncpy(addr.addr.sun_path, property_service_socket,
- sizeof(addr.addr.sun_path));
- addr.addr.sun_family = AF_LOCAL;
- alen = namelen + offsetof(struct sockaddr_un, sun_path) + 1;
-
- if (TEMP_FAILURE_RETRY(connect(s, &addr.addr_g, alen) < 0)) {
- close(s);
- return result;
- }
-
- r = TEMP_FAILURE_RETRY(send(s, msg, sizeof(prop_msg_t), 0));
-
- if (r == sizeof(prop_msg_t)) {
- // We successfully wrote to the property server, so use recv
- // in case we need to get a property. Once the other side is
- // finished, the socket is closed.
- while ((r = recv(s, msg, sizeof(prop_msg_t), 0)) > 0) {
- if (r != sizeof(prop_msg_t)) {
- close(s);
- return result;
- }
-
- /* If we got a reply, this is a patched init */
- if (!patched_init)
- patched_init = 1;
-
- if (propfn)
- propfn(msg->name, msg->value, cookie);
- }
-
- /* We also just get a close in case of setprop */
- if ((r >= 0) && (patched_init ||
- (msg->cmd == PROP_MSG_SETPROP))) {
- result = 0;
- } else {
- send_prop_msg_no_reply = 1;
- }
- }
-
- close(s);
- return result;
-}
-
-int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie)
-{
- int err;
- prop_msg_t msg;
-
- memset(&msg, 0, sizeof(msg));
- msg.cmd = PROP_MSG_LISTPROP;
-
- err = send_prop_msg(&msg, propfn, cookie);
- if (err < 0)
- /* fallback to property cache */
- hybris_propcache_list((hybris_propcache_list_cb) propfn, cookie);
-
- return 0;
-}
-
-static int property_get_socket(const char *key, char *value, const char *default_value)
-{
- int err;
- prop_msg_t msg;
-
- memset(&msg, 0, sizeof(msg));
- msg.cmd = PROP_MSG_GETPROP;
-
- if (key) {
- strncpy(msg.name, key, sizeof(msg.name));
- err = send_prop_msg(&msg, NULL, NULL);
- if (err < 0)
- return err;
- }
-
- /* In case it's null, just use the default */
- if ((strlen(msg.value) == 0) && (default_value)) {
- if (strlen(default_value) > PROP_VALUE_MAX -1) return -1;
- strcpy(msg.value, default_value);
- }
-
- strcpy(value, msg.value);
-
- return 0;
-}
-
-int property_get(const char *key, char *value, const char *default_value)
-{
- char *ret = NULL;
-
- if ((key) && (strlen(key) > PROP_NAME_MAX -1)) return -1;
- if (value == NULL) return -1;
-
-
- // Runtime cache will serialize property lookups within the process.
- // This will increase latency if multiple threads are doing many
- // parallel lookups to new properties, but the overhead should
- // be offset with the caching eventually.
- runtime_cache_lock();
- if (runtime_cache_get(key, value) == 0) {
- ret = value;
- } else if (property_get_socket(key, value, default_value) == 0) {
- runtime_cache_insert(key, value);
- ret = value;
- }
- runtime_cache_unlock();
-
- if (ret)
- return strlen(ret);
-
-
- /* In case the socket is not available, search the property file cache by hand */
- ret = hybris_propcache_find(key);
-
- if (ret) {
- strcpy(value, ret);
- return strlen(value);
- } else if (default_value != NULL) {
- strcpy(value, default_value);
- return strlen(value);
- } else {
- value = '\0';
- }
-
- return 0;
-}
|
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/.gitmodules
^
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/camera/Android.mk
^
|
@@ -1,4 +1,11 @@
LOCAL_PATH:= $(call my-dir)
+
+HYBRIS_MEDIA_32_BIT_ONLY := $(shell cat frameworks/av/media/libmediaplayerservice/Android.mk |grep LOCAL_32_BIT_ONLY |grep -o "true\|false")
+
+ifeq ($(HYBRIS_MEDIA_32_BIT_ONLY),true)
+HYBRIS_MEDIA_MULTILIB := 32
+endif
+
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../Android.common.mk
@@ -21,6 +28,11 @@
libui \
libgui
+ifeq ($(HYBRIS_MEDIA_32_BIT_ONLY),true)
+LOCAL_32_BIT_ONLY := true
+LOCAL_MULTILIB := 32
+endif
+
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
@@ -60,4 +72,9 @@
libEGL \
libGLESv2
+ifeq ($(HYBRIS_MEDIA_32_BIT_ONLY),true)
+LOCAL_32_BIT_ONLY := true
+LOCAL_MULTILIB := 32
+endif
+
include $(BUILD_EXECUTABLE)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/Android.mk
^
|
@@ -0,0 +1,113 @@
+# define ANDROID_VERSION MAJOR, MINOR and PATCH
+
+ANDROID_VERSION_MAJOR := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
+ANDROID_VERSION_MINOR := $(word 2, $(subst ., , $(PLATFORM_VERSION)))
+ANDROID_VERSION_PATCH := $(word 3, $(subst ., , $(PLATFORM_VERSION)))
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libhwc2_compat_layer
+LOCAL_SRC_FILES := HWC2.cpp ComposerHal.cpp hwc2_compatibility_layer.cpp
+
+LOCAL_C_INCLUDES := ../hybris/include
+
+LOCAL_STATIC_LIBRARIES := \
+ libhwcomposer-command-buffer
+
+LOCAL_SHARED_LIBRARIES := \
+ android.frameworks.vr.composer@1.0 \
+ android.hardware.graphics.allocator@2.0 \
+ android.hardware.graphics.composer@2.1 \
+ android.hardware.configstore@1.0 \
+ android.hardware.configstore-utils \
+ libcutils \
+ liblog \
+ libfmq \
+ libhardware \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder \
+ libutils \
+ libEGL \
+ libGLESv1_CM \
+ libGLESv2 \
+ libbinder \
+ libui \
+ libgui \
+ libsync \
+ libbase
+
+LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := \
+ android.hardware.graphics.allocator@2.0 \
+ android.hardware.graphics.composer@2.1 \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder
+
+LOCAL_CFLAGS += -Wno-unused-parameter -DGL_GLEXT_PROTOTYPES -UNDEBUG
+LOCAL_CFLAGS += \
+ -DANDROID_VERSION_MAJOR=$(ANDROID_VERSION_MAJOR) \
+ -DANDROID_VERSION_MINOR=$(ANDROID_VERSION_MINOR) \
+ -DANDROID_VERSION_PATCH=$(ANDROID_VERSION_PATCH)
+
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libhybris-gralloc
+LOCAL_SRC_FILES := tests/hybris-gralloc.c \
+ GrallocUsageConversion.cpp
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/tests
+LOCAL_SHARED_LIBRARIES := libcutils
+LOCAL_CFLAGS := \
+ -DANDROID_VERSION_MAJOR=$(ANDROID_VERSION_MAJOR) \
+ -DANDROID_VERSION_MINOR=$(ANDROID_VERSION_MINOR) \
+ -DANDROID_VERSION_PATCH=$(ANDROID_VERSION_PATCH) \
+ -DANDROID_BUILD=1
+LOCAL_CFLAGS += -Wno-unused-parameter -UNDEBUG -DHAS_GRALLOC1_HEADER=1
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libhwcnativewindow
+LOCAL_SRC_FILES := tests/hwcomposer_window.cpp \
+ tests/nativewindowbase.cpp
+LOCAL_SHARED_LIBRARIES := libsync liblog libnativewindow
+LOCAL_CFLAGS := \
+ -DANDROID_VERSION_MAJOR=$(ANDROID_VERSION_MAJOR) \
+ -DANDROID_VERSION_MINOR=$(ANDROID_VERSION_MINOR) \
+ -DANDROID_VERSION_PATCH=$(ANDROID_VERSION_PATCH) \
+ -DANDROID_BUILD=1
+LOCAL_CFLAGS += -Wno-unused-parameter -UNDEBUG
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := direct_hwc2_test
+LOCAL_SRC_FILES := tests/direct_hwc2_test.cpp
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/tests
+ifdef TARGET_2ND_ARCH
+LOCAL_MULTILIB := both
+LOCAL_MODULE_STEM_32 := $(if $(filter false,$(BOARD_UBUNTU_PREFER_32_BIT)),$(LOCAL_MODULE)$(TARGET_2ND_ARCH_MODULE_SUFFIX),$(LOCAL_MODULE))
+LOCAL_MODULE_STEM_64 := $(if $(filter false,$(BOARD_UBUNTU_PREFER_32_BIT)),$(LOCAL_MODULE),$(LOCAL_MODULE)_64)
+endif
+
+LOCAL_STATIC_LIBRARIES := \
+ libhwcnativewindow libhybris-gralloc
+
+LOCAL_SHARED_LIBRARIES := \
+ libcutils \
+ liblog \
+ libhardware \
+ libnativewindow \
+ libsync \
+ libEGL \
+ libGLESv2 \
+ libhwc2_compat_layer
+
+LOCAL_CFLAGS += -Wno-unused-parameter -DGL_GLEXT_PROTOTYPES -UNDEBUG \
+ -DHWC2_USE_CPP11 -DHWC2_INCLUDE_STRINGIFICATION
+LOCAL_CFLAGS += \
+ -DANDROID_VERSION_MAJOR=$(ANDROID_VERSION_MAJOR) \
+ -DANDROID_VERSION_MINOR=$(ANDROID_VERSION_MINOR) \
+ -DANDROID_VERSION_PATCH=$(ANDROID_VERSION_PATCH)
+
+include $(BUILD_EXECUTABLE)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/ComposerHal.cpp
^
|
@@ -0,0 +1,1118 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#undef LOG_TAG
+#define LOG_TAG "HwcComposer"
+
+#include <inttypes.h>
+#include <log/log.h>
+#include <gui/BufferQueue.h>
+
+#include "ComposerHal.h"
+
+namespace android {
+
+using hardware::Return;
+using hardware::hidl_vec;
+using hardware::hidl_handle;
+
+namespace Hwc2 {
+
+namespace {
+
+class BufferHandle {
+public:
+ BufferHandle(const native_handle_t* buffer)
+ {
+ // nullptr is not a valid handle to HIDL
+ mHandle = (buffer) ? buffer : native_handle_init(mStorage, 0, 0);
+ }
+
+ operator const hidl_handle&() const
+ {
+ return mHandle;
+ }
+
+private:
+ NATIVE_HANDLE_DECLARE_STORAGE(mStorage, 0, 0);
+ hidl_handle mHandle;
+};
+
+class FenceHandle
+{
+public:
+ FenceHandle(int fd, bool owned)
+ : mOwned(owned)
+ {
+ native_handle_t* handle;
+ if (fd >= 0) {
+ handle = native_handle_init(mStorage, 1, 0);
+ handle->data[0] = fd;
+ } else {
+ // nullptr is not a valid handle to HIDL
+ handle = native_handle_init(mStorage, 0, 0);
+ }
+ mHandle = handle;
+ }
+
+ ~FenceHandle()
+ {
+ if (mOwned) {
+ native_handle_close(mHandle);
+ }
+ }
+
+ operator const hidl_handle&() const
+ {
+ return mHandle;
+ }
+
+private:
+ bool mOwned;
+ NATIVE_HANDLE_DECLARE_STORAGE(mStorage, 1, 0);
+ hidl_handle mHandle;
+};
+
+// assume NO_RESOURCES when Status::isOk returns false
+constexpr Error kDefaultError = Error::NO_RESOURCES;
+
+template<typename T, typename U>
+T unwrapRet(Return<T>& ret, const U& default_val)
+{
+ return (ret.isOk()) ? static_cast<T>(ret) :
+ static_cast<T>(default_val);
+}
+
+Error unwrapRet(Return<Error>& ret)
+{
+ return unwrapRet(ret, kDefaultError);
+}
+
+} // anonymous namespace
+
+Composer::CommandWriter::CommandWriter(uint32_t initialMaxSize)
+ : CommandWriterBase(initialMaxSize) {}
+
+Composer::CommandWriter::~CommandWriter()
+{
+}
+
+void Composer::CommandWriter::setLayerInfo(uint32_t type, uint32_t appId)
+{
+ constexpr uint16_t kSetLayerInfoLength = 2;
+ beginCommand(
+ static_cast<IComposerClient::Command>(
+ IVrComposerClient::VrCommand::SET_LAYER_INFO),
+ kSetLayerInfoLength);
+ write(type);
+ write(appId);
+ endCommand();
+}
+
+void Composer::CommandWriter::setClientTargetMetadata(
+ const IVrComposerClient::BufferMetadata& metadata)
+{
+ constexpr uint16_t kSetClientTargetMetadataLength = 7;
+ beginCommand(
+ static_cast<IComposerClient::Command>(
+ IVrComposerClient::VrCommand::SET_CLIENT_TARGET_METADATA),
+ kSetClientTargetMetadataLength);
+ writeBufferMetadata(metadata);
+ endCommand();
+}
+
+void Composer::CommandWriter::setLayerBufferMetadata(
+ const IVrComposerClient::BufferMetadata& metadata)
+{
+ constexpr uint16_t kSetLayerBufferMetadataLength = 7;
+ beginCommand(
+ static_cast<IComposerClient::Command>(
+ IVrComposerClient::VrCommand::SET_LAYER_BUFFER_METADATA),
+ kSetLayerBufferMetadataLength);
+ writeBufferMetadata(metadata);
+ endCommand();
+}
+
+void Composer::CommandWriter::writeBufferMetadata(
+ const IVrComposerClient::BufferMetadata& metadata)
+{
+ write(metadata.width);
+ write(metadata.height);
+ write(metadata.stride);
+ write(metadata.layerCount);
+ writeSigned(static_cast<int32_t>(metadata.format));
+ write64(metadata.usage);
+}
+
+Composer::Composer(bool useVrComposer)
+ : mWriter(kWriterInitialSize),
+ mIsUsingVrComposer(useVrComposer)
+{
+ if (mIsUsingVrComposer) {
+ mComposer = IComposer::getService("vr");
+ } else {
+ mComposer = IComposer::getService(); // use default name
+ }
+
+ if (mComposer == nullptr) {
+ LOG_ALWAYS_FATAL("failed to get hwcomposer service");
+ }
+
+ mComposer->createClient(
+ [&](const auto& tmpError, const auto& tmpClient)
+ {
+ if (tmpError == Error::NONE) {
+ mClient = tmpClient;
+ }
+ });
+ if (mClient == nullptr) {
+ LOG_ALWAYS_FATAL("failed to create composer client");
+ }
+
+ if (mIsUsingVrComposer) {
+ sp<IVrComposerClient> vrClient = IVrComposerClient::castFrom(mClient);
+ if (vrClient == nullptr) {
+ LOG_ALWAYS_FATAL("failed to create vr composer client");
+ }
+ }
+}
+
+std::vector<IComposer::Capability> Composer::getCapabilities()
+{
+ std::vector<IComposer::Capability> capabilities;
+ mComposer->getCapabilities(
+ [&](const auto& tmpCapabilities) {
+ capabilities = tmpCapabilities;
+ });
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/ComposerHal.h
^
|
@@ -0,0 +1,291 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SF_COMPOSER_HAL_H
+#define ANDROID_SF_COMPOSER_HAL_H
+
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <utility>
+#include <vector>
+
+#include <android/frameworks/vr/composer/1.0/IVrComposerClient.h>
+#include <android/hardware/graphics/composer/2.1/IComposer.h>
+#include <utils/StrongPointer.h>
+#include <IComposerCommandBuffer.h>
+
+namespace android {
+
+namespace Hwc2 {
+
+using android::frameworks::vr::composer::V1_0::IVrComposerClient;
+
+using android::hardware::graphics::common::V1_0::ColorMode;
+using android::hardware::graphics::common::V1_0::ColorTransform;
+using android::hardware::graphics::common::V1_0::Dataspace;
+using android::hardware::graphics::common::V1_0::Hdr;
+using android::hardware::graphics::common::V1_0::PixelFormat;
+using android::hardware::graphics::common::V1_0::Transform;
+
+using android::hardware::graphics::composer::V2_1::IComposer;
+using android::hardware::graphics::composer::V2_1::IComposerCallback;
+using android::hardware::graphics::composer::V2_1::IComposerClient;
+using android::hardware::graphics::composer::V2_1::Error;
+using android::hardware::graphics::composer::V2_1::Display;
+using android::hardware::graphics::composer::V2_1::Layer;
+using android::hardware::graphics::composer::V2_1::Config;
+
+using android::hardware::graphics::composer::V2_1::CommandWriterBase;
+using android::hardware::graphics::composer::V2_1::CommandReaderBase;
+
+using android::hardware::kSynchronizedReadWrite;
+using android::hardware::MessageQueue;
+using android::hardware::MQDescriptorSync;
+using android::hardware::hidl_vec;
+using android::hardware::hidl_handle;
+
+class CommandReader : public CommandReaderBase {
+public:
+ ~CommandReader();
+
+ // Parse and execute commands from the command queue. The commands are
+ // actually return values from the server and will be saved in ReturnData.
+ Error parse();
+
+ // Get and clear saved errors.
+ struct CommandError {
+ uint32_t location;
+ Error error;
+ };
+ std::vector<CommandError> takeErrors();
+
+ bool hasChanges(Display display, uint32_t* outNumChangedCompositionTypes,
+ uint32_t* outNumLayerRequestMasks) const;
+
+ // Get and clear saved changed composition types.
+ void takeChangedCompositionTypes(Display display,
+ std::vector<Layer>* outLayers,
+ std::vector<IComposerClient::Composition>* outTypes);
+
+ // Get and clear saved display requests.
+ void takeDisplayRequests(Display display,
+ uint32_t* outDisplayRequestMask, std::vector<Layer>* outLayers,
+ std::vector<uint32_t>* outLayerRequestMasks);
+
+ // Get and clear saved release fences.
+ void takeReleaseFences(Display display, std::vector<Layer>* outLayers,
+ std::vector<int>* outReleaseFences);
+
+ // Get and clear saved present fence.
+ void takePresentFence(Display display, int* outPresentFence);
+
+ // Get what stage succeeded during PresentOrValidate: Present or Validate
+ void takePresentOrValidateStage(Display display, uint32_t * state);
+
+private:
+ void resetData();
+
+ bool parseSelectDisplay(uint16_t length);
+ bool parseSetError(uint16_t length);
+ bool parseSetChangedCompositionTypes(uint16_t length);
+ bool parseSetDisplayRequests(uint16_t length);
+ bool parseSetPresentFence(uint16_t length);
+ bool parseSetReleaseFences(uint16_t length);
+ bool parseSetPresentOrValidateDisplayResult(uint16_t length);
+
+ struct ReturnData {
+ uint32_t displayRequests = 0;
+
+ std::vector<Layer> changedLayers;
+ std::vector<IComposerClient::Composition> compositionTypes;
+
+ std::vector<Layer> requestedLayers;
+ std::vector<uint32_t> requestMasks;
+
+ int presentFence = -1;
+
+ std::vector<Layer> releasedLayers;
+ std::vector<int> releaseFences;
+
+ uint32_t presentOrValidateState;
+ };
+
+ std::vector<CommandError> mErrors;
+ std::unordered_map<Display, ReturnData> mReturnData;
+
+ // When SELECT_DISPLAY is parsed, this is updated to point to the
+ // display's return data in mReturnData. We use it to avoid repeated
+ // map lookups.
+ ReturnData* mCurrentReturnData;
+};
+
+// Composer is a wrapper to IComposer, a proxy to server-side composer.
+class Composer {
+public:
+ Composer(bool useVrComposer);
+
+ std::vector<IComposer::Capability> getCapabilities();
+ std::string dumpDebugInfo();
+
+ void registerCallback(const sp<IComposerCallback>& callback);
+
+ // Returns true if the connected composer service is running in a remote
+ // process, false otherwise. This will return false if the service is
+ // configured in passthrough mode, for example.
+ bool isRemote();
+
+ // Reset all pending commands in the command buffer. Useful if you want to
+ // skip a frame but have already queued some commands.
+ void resetCommands();
+
+ uint32_t getMaxVirtualDisplayCount();
+ bool isUsingVrComposer() const { return mIsUsingVrComposer; }
+ Error createVirtualDisplay(uint32_t width, uint32_t height,
+ PixelFormat* format, Display* outDisplay);
+ Error destroyVirtualDisplay(Display display);
+
+ Error acceptDisplayChanges(Display display);
+
+ Error createLayer(Display display, Layer* outLayer);
+ Error destroyLayer(Display display, Layer layer);
+
+ Error getActiveConfig(Display display, Config* outConfig);
+ Error getChangedCompositionTypes(Display display,
+ std::vector<Layer>* outLayers,
+ std::vector<IComposerClient::Composition>* outTypes);
+ Error getColorModes(Display display, std::vector<ColorMode>* outModes);
+ Error getDisplayAttribute(Display display, Config config,
+ IComposerClient::Attribute attribute, int32_t* outValue);
+ Error getDisplayConfigs(Display display, std::vector<Config>* outConfigs);
+ Error getDisplayName(Display display, std::string* outName);
+
+ Error getDisplayRequests(Display display, uint32_t* outDisplayRequestMask,
+ std::vector<Layer>* outLayers,
+ std::vector<uint32_t>* outLayerRequestMasks);
+
+ Error getDisplayType(Display display,
+ IComposerClient::DisplayType* outType);
+ Error getDozeSupport(Display display, bool* outSupport);
+ Error getHdrCapabilities(Display display, std::vector<Hdr>* outTypes,
+ float* outMaxLuminance, float* outMaxAverageLuminance,
+ float* outMinLuminance);
+
+ Error getReleaseFences(Display display, std::vector<Layer>* outLayers,
+ std::vector<int>* outReleaseFences);
+
+ Error presentDisplay(Display display, int* outPresentFence);
+
+ Error setActiveConfig(Display display, Config config);
+
+ /*
+ * The composer caches client targets internally. When target is nullptr,
+ * the composer uses slot to look up the client target from its cache.
+ * When target is not nullptr, the cache is updated with the new target.
+ */
+ Error setClientTarget(Display display, uint32_t slot,
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/GrallocUsageConversion.cpp
^
|
+(symlink to ../../hybris/gralloc/GrallocUsageConversion.cpp)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/HWC2.cpp
^
|
@@ -0,0 +1,879 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// #define LOG_NDEBUG 0
+
+#undef LOG_TAG
+#define LOG_TAG "HWC2"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+
+#include "HWC2.h"
+#include "ComposerHal.h"
+
+#include <ui/Fence.h>
+#include <ui/FloatRect.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/Region.h>
+
+#include <android/configuration.h>
+
+#include <algorithm>
+#include <inttypes.h>
+
+using android::Fence;
+using android::FloatRect;
+using android::GraphicBuffer;
+using android::HdrCapabilities;
+using android::Rect;
+using android::Region;
+using android::sp;
+using android::hardware::Return;
+using android::hardware::Void;
+
+namespace HWC2 {
+
+namespace Hwc2 = android::Hwc2;
+
+namespace {
+
+class ComposerCallbackBridge : public Hwc2::IComposerCallback {
+public:
+ ComposerCallbackBridge(ComposerCallback* callback, int32_t sequenceId)
+ : mCallback(callback), mSequenceId(sequenceId),
+ mHasPrimaryDisplay(false) {}
+
+ Return<void> onHotplug(Hwc2::Display display,
+ IComposerCallback::Connection conn) override
+ {
+ HWC2::Connection connection = static_cast<HWC2::Connection>(conn);
+ if (!mHasPrimaryDisplay) {
+ LOG_ALWAYS_FATAL_IF(connection != HWC2::Connection::Connected,
+ "Initial onHotplug callback should be "
+ "primary display connected");
+ mHasPrimaryDisplay = true;
+ mCallback->onHotplugReceived(mSequenceId, display,
+ connection, true);
+ } else {
+ mCallback->onHotplugReceived(mSequenceId, display,
+ connection, false);
+ }
+ return Void();
+ }
+
+ Return<void> onRefresh(Hwc2::Display display) override
+ {
+ mCallback->onRefreshReceived(mSequenceId, display);
+ return Void();
+ }
+
+ Return<void> onVsync(Hwc2::Display display, int64_t timestamp) override
+ {
+ mCallback->onVsyncReceived(mSequenceId, display, timestamp);
+ return Void();
+ }
+
+ bool HasPrimaryDisplay() { return mHasPrimaryDisplay; }
+
+private:
+ ComposerCallback* mCallback;
+ int32_t mSequenceId;
+ bool mHasPrimaryDisplay;
+};
+
+} // namespace anonymous
+
+
+// Device methods
+
+Device::Device(bool useVrComposer)
+ : mComposer(std::make_unique<Hwc2::Composer>(useVrComposer)),
+ mCapabilities(),
+ mDisplays(),
+ mRegisteredCallback(false)
+{
+ loadCapabilities();
+}
+
+void Device::registerCallback(ComposerCallback* callback, int32_t sequenceId) {
+ if (mRegisteredCallback) {
+ ALOGW("Callback already registered. Ignored extra registration "
+ "attempt.");
+ return;
+ }
+ mRegisteredCallback = true;
+ sp<ComposerCallbackBridge> callbackBridge(
+ new ComposerCallbackBridge(callback, sequenceId));
+ mComposer->registerCallback(callbackBridge);
+ LOG_ALWAYS_FATAL_IF(!callbackBridge->HasPrimaryDisplay(),
+ "Registered composer callback but didn't get primary display");
+}
+
+// Required by HWC2 device
+
+std::string Device::dump() const
+{
+ return mComposer->dumpDebugInfo();
+}
+
+uint32_t Device::getMaxVirtualDisplayCount() const
+{
+ return mComposer->getMaxVirtualDisplayCount();
+}
+
+Error Device::createVirtualDisplay(uint32_t width, uint32_t height,
+ android_pixel_format_t* format, Display** outDisplay)
+{
+ ALOGI("Creating virtual display");
+
+ hwc2_display_t displayId = 0;
+ auto intFormat = static_cast<Hwc2::PixelFormat>(*format);
+ auto intError = mComposer->createVirtualDisplay(width, height,
+ &intFormat, &displayId);
+ auto error = static_cast<Error>(intError);
+ if (error != Error::None) {
+ return error;
+ }
+
+ auto display = std::make_unique<Display>(
+ *mComposer.get(), mCapabilities, displayId, DisplayType::Virtual);
+ *outDisplay = display.get();
+ *format = static_cast<android_pixel_format_t>(intFormat);
+ mDisplays.emplace(displayId, std::move(display));
+ ALOGI("Created virtual display");
+ return Error::None;
+}
+
+void Device::destroyDisplay(hwc2_display_t displayId)
+{
+ ALOGI("Destroying display %" PRIu64, displayId);
+ mDisplays.erase(displayId);
+}
+
+void Device::onHotplug(hwc2_display_t displayId, Connection connection) {
+ if (connection == Connection::Connected) {
+ auto display = getDisplayById(displayId);
+ if (display) {
+ if (display->isConnected()) {
+ ALOGW("Attempt to hotplug connect display %" PRIu64
+ " , which is already connected.", displayId);
+ } else {
+ display->setConnected(true);
+ }
+ } else {
+ DisplayType displayType;
+ auto intError = mComposer->getDisplayType(displayId,
+ reinterpret_cast<Hwc2::IComposerClient::DisplayType *>(
+ &displayType));
+ auto error = static_cast<Error>(intError);
+ if (error != Error::None) {
+ ALOGE("getDisplayType(%" PRIu64 ") failed: %s (%d). "
+ "Aborting hotplug attempt.",
+ displayId, to_string(error).c_str(), intError);
+ return;
+ }
+
+ auto newDisplay = std::make_unique<Display>(
+ *mComposer.get(), mCapabilities, displayId, displayType);
+ mDisplays.emplace(displayId, std::move(newDisplay));
+ }
+ } else if (connection == Connection::Disconnected) {
+ // The display will later be destroyed by a call to
+ // destroyDisplay(). For now we just mark it disconnected.
+ auto display = getDisplayById(displayId);
+ if (display) {
+ display->setConnected(false);
+ } else {
+ ALOGW("Attempted to disconnect unknown display %" PRIu64,
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/HWC2.h
^
|
@@ -0,0 +1,342 @@
+/*
+ * Copyright 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SF_HWC2_H
+#define ANDROID_SF_HWC2_H
+
+#define HWC2_INCLUDE_STRINGIFICATION
+#define HWC2_USE_CPP11
+#include <hardware/hwcomposer2.h>
+#undef HWC2_INCLUDE_STRINGIFICATION
+#undef HWC2_USE_CPP11
+
+#include <ui/HdrCapabilities.h>
+#include <math/mat4.h>
+
+#include <utils/Log.h>
+#include <utils/StrongPointer.h>
+#include <utils/Timers.h>
+
+#include <functional>
+#include <string>
+#include <unordered_map>
+#include <unordered_set>
+#include <vector>
+#include <map>
+
+namespace android {
+ class Fence;
+ class FloatRect;
+ class GraphicBuffer;
+ class Rect;
+ class Region;
+ namespace Hwc2 {
+ class Composer;
+ }
+}
+
+namespace HWC2 {
+
+class Display;
+class Layer;
+
+// Implement this interface to receive hardware composer events.
+//
+// These callback functions will generally be called on a hwbinder thread, but
+// when first registering the callback the onHotplugReceived() function will
+// immediately be called on the thread calling registerCallback().
+//
+// All calls receive a sequenceId, which will be the value that was supplied to
+// HWC2::Device::registerCallback(). It's used to help differentiate callbacks
+// from different hardware composer instances.
+class ComposerCallback {
+ public:
+ virtual void onHotplugReceived(int32_t sequenceId, hwc2_display_t display,
+ Connection connection,
+ bool primaryDisplay) = 0;
+ virtual void onRefreshReceived(int32_t sequenceId,
+ hwc2_display_t display) = 0;
+ virtual void onVsyncReceived(int32_t sequenceId, hwc2_display_t display,
+ int64_t timestamp) = 0;
+ virtual ~ComposerCallback() = default;
+};
+
+// C++ Wrapper around hwc2_device_t. Load all functions pointers
+// and handle callback registration.
+class Device
+{
+public:
+ // useVrComposer is passed to the composer HAL. When true, the composer HAL
+ // will use the vr composer service, otherwise it uses the real hardware
+ // composer.
+ Device(bool useVrComposer);
+
+ void registerCallback(ComposerCallback* callback, int32_t sequenceId);
+
+ // Required by HWC2
+
+ std::string dump() const;
+
+ const std::unordered_set<Capability>& getCapabilities() const {
+ return mCapabilities;
+ };
+
+ uint32_t getMaxVirtualDisplayCount() const;
+ Error createVirtualDisplay(uint32_t width, uint32_t height,
+ android_pixel_format_t* format, Display** outDisplay);
+ void destroyDisplay(hwc2_display_t displayId);
+
+ void onHotplug(hwc2_display_t displayId, Connection connection);
+
+ // Other Device methods
+
+ Display* getDisplayById(hwc2_display_t id);
+
+ android::Hwc2::Composer* getComposer() { return mComposer.get(); }
+
+private:
+ // Initialization methods
+
+ void loadCapabilities();
+
+ // Member variables
+ std::unique_ptr<android::Hwc2::Composer> mComposer;
+ std::unordered_set<Capability> mCapabilities;
+ std::unordered_map<hwc2_display_t, std::unique_ptr<Display>> mDisplays;
+ bool mRegisteredCallback;
+};
+
+// Convenience C++ class to access hwc2_device_t Display functions directly.
+class Display
+{
+public:
+ Display(android::Hwc2::Composer& composer,
+ const std::unordered_set<Capability>& capabilities,
+ hwc2_display_t id, DisplayType type);
+ ~Display();
+
+ class Config
+ {
+ public:
+ class Builder
+ {
+ public:
+ Builder(Display& display, hwc2_config_t id);
+
+ std::shared_ptr<const Config> build() {
+ return std::const_pointer_cast<const Config>(
+ std::move(mConfig));
+ }
+
+ Builder& setWidth(int32_t width) {
+ mConfig->mWidth = width;
+ return *this;
+ }
+ Builder& setHeight(int32_t height) {
+ mConfig->mHeight = height;
+ return *this;
+ }
+ Builder& setVsyncPeriod(int32_t vsyncPeriod) {
+ mConfig->mVsyncPeriod = vsyncPeriod;
+ return *this;
+ }
+ Builder& setDpiX(int32_t dpiX) {
+ if (dpiX == -1) {
+ mConfig->mDpiX = getDefaultDensity();
+ } else {
+ mConfig->mDpiX = dpiX / 1000.0f;
+ }
+ return *this;
+ }
+ Builder& setDpiY(int32_t dpiY) {
+ if (dpiY == -1) {
+ mConfig->mDpiY = getDefaultDensity();
+ } else {
+ mConfig->mDpiY = dpiY / 1000.0f;
+ }
+ return *this;
+ }
+
+ private:
+ float getDefaultDensity();
+ std::shared_ptr<Config> mConfig;
+ };
+
+ hwc2_display_t getDisplayId() const { return mDisplay.getId(); }
+ hwc2_config_t getId() const { return mId; }
+
+ int32_t getWidth() const { return mWidth; }
+ int32_t getHeight() const { return mHeight; }
+ nsecs_t getVsyncPeriod() const { return mVsyncPeriod; }
+ float getDpiX() const { return mDpiX; }
+ float getDpiY() const { return mDpiY; }
+
+ private:
+ Config(Display& display, hwc2_config_t id);
+
+ Display& mDisplay;
+ hwc2_config_t mId;
+
+ int32_t mWidth;
+ int32_t mHeight;
+ nsecs_t mVsyncPeriod;
+ float mDpiX;
+ float mDpiY;
+ };
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/hwc2_compatibility_layer.cpp
^
|
@@ -0,0 +1,379 @@
+/*
+ * Copyright (C) 2018 TheKit <nekit1000@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ui/Fence.h>
+#include <ui/FloatRect.h>
+#include <ui/GraphicBuffer.h>
+#include <ui/Region.h>
+#include <sync/sync.h>
+
+#include "HWC2.h"
+#include "hwc2_compatibility_layer.h"
+
+class HWComposerCallback : public HWC2::ComposerCallback
+{
+public:
+ HWComposerCallback(HWC2EventListener* listener);
+
+ void onVsyncReceived(int32_t sequenceId, hwc2_display_t display,
+ int64_t timestamp) override;
+ void onHotplugReceived(int32_t sequenceId, hwc2_display_t display,
+ HWC2::Connection connection,
+ bool primaryDisplay) override;
+ void onRefreshReceived(int32_t sequenceId,
+ hwc2_display_t display) override;
+private:
+ HWC2EventListener *listener;
+};
+
+HWComposerCallback::HWComposerCallback(HWC2EventListener* listener) :
+ listener(listener)
+{
+}
+
+void HWComposerCallback::onVsyncReceived(int32_t sequenceId,
+ hwc2_display_t display,
+ int64_t timestamp)
+{
+ listener->on_vsync_received(listener, sequenceId, display, timestamp);
+}
+
+void HWComposerCallback::onHotplugReceived(int32_t sequenceId,
+ hwc2_display_t display,
+ HWC2::Connection connection,
+ bool primaryDisplay)
+{
+ listener->on_hotplug_received(listener, sequenceId, display,
+ connection == HWC2::Connection::Connected,
+ primaryDisplay);
+}
+
+void HWComposerCallback::onRefreshReceived(int32_t sequenceId,
+ hwc2_display_t display)
+{
+ listener->on_refresh_received(listener, sequenceId, display);
+}
+
+struct hwc2_compat_device
+{
+ HWC2::Device *self;
+};
+
+struct hwc2_compat_display
+{
+ HWC2::Display *self;
+};
+
+struct hwc2_compat_layer
+{
+ HWC2::Layer *self;
+};
+
+struct hwc2_compat_out_fences
+{
+ std::unordered_map<HWC2::Layer*, android::sp<android::Fence>> fences;
+};
+
+hwc2_compat_device_t* hwc2_compat_device_new(bool useVrComposer)
+{
+ hwc2_compat_device_t *device = (hwc2_compat_device_t*) malloc(
+ sizeof(hwc2_compat_device_t));
+ if (!device)
+ return nullptr;
+
+ device->self = new HWC2::Device(useVrComposer);
+
+ return device;
+}
+
+void hwc2_compat_device_register_callback(hwc2_compat_device_t *device,
+ HWC2EventListener* listener,
+ int composerSequenceId)
+{
+ device->self->registerCallback(new HWComposerCallback(listener),
+ composerSequenceId);
+}
+
+void hwc2_compat_device_on_hotplug(hwc2_compat_device_t* device,
+ hwc2_display_t displayId, bool connected)
+{
+ device->self->onHotplug(displayId,
+ static_cast<HWC2::Connection>(connected));
+}
+
+hwc2_compat_display_t* hwc2_compat_device_get_display_by_id(
+ hwc2_compat_device_t *device, hwc2_display_t id)
+{
+ hwc2_compat_display_t *display = (hwc2_compat_display_t*) malloc(
+ sizeof(hwc2_compat_display_t));
+ if (!display)
+ return nullptr;
+
+ display->self = device->self->getDisplayById(id);
+
+ if (!display->self) {
+ free(display);
+ return nullptr;
+ }
+
+ return display;
+}
+
+HWC2DisplayConfig* hwc2_compat_display_get_active_config(
+ hwc2_compat_display_t* display)
+{
+ HWC2DisplayConfig* config = (HWC2DisplayConfig*) malloc(
+ sizeof(HWC2DisplayConfig));
+
+ std::shared_ptr<const HWC2::Display::Config> activeConfig;
+ auto error = display->self->getActiveConfig(&activeConfig);
+ if (error == HWC2::Error::BadConfig) {
+ fprintf(stderr, "getActiveConfig: No config active, returning null");
+ } else if (error != HWC2::Error::None) {
+ fprintf(stderr, "getActiveConfig failed for display %d: %s (%d)",
+ static_cast<int32_t>(display->self->getId()),
+ to_string(error).c_str(),
+ static_cast<int32_t>(error));
+ } else if (!activeConfig) {
+ fprintf(stderr, "getActiveConfig returned empty config for display %d",
+ static_cast<int32_t>(display->self->getId()));
+ } else {
+ config->id = activeConfig->getId();
+ config->display = activeConfig->getDisplayId();
+ config->width = activeConfig->getWidth();
+ config->height = activeConfig->getHeight();
+ config->vsyncPeriod = activeConfig->getVsyncPeriod();
+ config->dpiX = activeConfig->getDpiX();
+ config->dpiY = activeConfig->getDpiY();
+
+ return config;
+ }
+
+ return nullptr;
+}
+
+hwc2_error_t hwc2_compat_display_accept_changes(hwc2_compat_display_t* display)
+{
+ HWC2::Error error = display->self->acceptChanges();
+ return static_cast<hwc2_error_t>(error);
+}
+
+hwc2_compat_layer_t* hwc2_compat_display_create_layer(hwc2_compat_display_t* display)
+{
+ hwc2_compat_layer_t *layer = (hwc2_compat_layer_t*) malloc(
+ sizeof(hwc2_compat_layer_t));
+ if (!layer)
+ return nullptr;
+
+ display->self->createLayer(&layer->self);
+
+ return layer;
+}
+
+void hwc2_compat_display_destroy_layer(hwc2_compat_display_t* display,
+ hwc2_compat_layer_t* layer)
+{
+ display->self->destroyLayer(layer->self);
+
+ delete layer->self;
+ free(layer);
+}
+
+hwc2_error_t hwc2_compat_display_get_release_fences(hwc2_compat_display_t* display,
+ hwc2_compat_out_fences_t** outFences)
+{
+ hwc2_compat_out_fences_t *fences = new struct hwc2_compat_out_fences;
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/hwc2_compatibility_layer.h
^
|
+(symlink to ../../../libhybris/hybris/include/hybris/hwc2/hwc2_compatibility_layer.h)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/hybris/grallocusage/GrallocUsageConversion.h
^
|
+(symlink to ../../../../../libhybris/hybris/include/hybris/grallocusage/GrallocUsageConversion.h)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/direct_hwc2_test.cpp
^
|
@@ -0,0 +1,353 @@
+/*
+ * Copyright (C) 2018 TheKit <nekit1000@gmail.com>
+ * Copyright (c) 2012 Carsten Munk <carsten.munk@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <assert.h>
+#include <stdio.h>
+#include <math.h>
+#include <mutex>
+
+#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+#include <cutils/log.h>
+#include <sync/sync.h>
+
+#include "hybris-gralloc.h"
+#include <hwcomposer_window.h>
+
+#include "hwc2_compatibility_layer.h"
+
+const char vertex_src [] =
+" \
+ attribute vec4 position; \
+ varying mediump vec2 pos; \
+ uniform vec4 offset; \
+ \
+ void main() \
+ { \
+ gl_Position = position + offset; \
+ pos = position.xy; \
+ } \
+";
+
+
+const char fragment_src [] =
+" \
+ varying mediump vec2 pos; \
+ uniform mediump float phase; \
+ \
+ void main() \
+ { \
+ gl_FragColor = vec4( 1., 0.9, 0.7, 1.0 ) * \
+ cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y) \
+ + atan(pos.y,pos.x) - phase ); \
+ } \
+";
+
+GLuint load_shader(const char *shader_source, GLenum type)
+{
+ GLuint shader = glCreateShader(type);
+
+ glShaderSource(shader, 1, &shader_source, NULL);
+ glCompileShader(shader);
+
+ return shader;
+}
+
+
+GLfloat norm_x = 0.0;
+GLfloat norm_y = 0.0;
+GLfloat offset_x = 0.0;
+GLfloat offset_y = 0.0;
+GLfloat p1_pos_x = 0.0;
+GLfloat p1_pos_y = 0.0;
+
+GLint phase_loc;
+GLint offset_loc;
+GLint position_loc;
+
+const float vertexArray[] = {
+ 0.0, 1.0, 0.0,
+ -1., 0.0, 0.0,
+ 0.0, -1.0, 0.0,
+ 1., 0.0, 0.0,
+ 0.0, 1., 0.0
+};
+
+std::mutex hotplugMutex;
+std::condition_variable hotplugCv;
+hwc2_compat_device_t* hwcDevice;
+
+class HWComposer : public HWComposerNativeWindow
+{
+ private:
+ hwc2_compat_layer_t *layer;
+ hwc2_compat_display_t *hwcDisplay;
+ int lastPresentFence = -1;
+ protected:
+ void present(HWComposerNativeWindowBuffer *buffer);
+
+ public:
+
+ HWComposer(unsigned int width, unsigned int height, unsigned int format,
+ hwc2_compat_display_t *display, hwc2_compat_layer_t *layer);
+ void set();
+};
+
+HWComposer::HWComposer(unsigned int width, unsigned int height,
+ unsigned int format, hwc2_compat_display_t* display,
+ hwc2_compat_layer_t *layer) :
+ HWComposerNativeWindow(width, height, format)
+{
+ this->layer = layer;
+ this->hwcDisplay = display;
+}
+
+void HWComposer::present(HWComposerNativeWindowBuffer *buffer)
+{
+ uint32_t numTypes = 0;
+ uint32_t numRequests = 0;
+ hwc2_display_t displayId = 0;
+
+ hwc2_error_t error = hwc2_compat_display_validate(hwcDisplay, &numTypes,
+ &numRequests);
+
+ if (error != HWC2_ERROR_NONE && error != HWC2_ERROR_HAS_CHANGES) {
+ ALOGE("prepare: validate failed for display %d: %s (%d)",
+ (uint32_t) displayId,
+ to_string(static_cast<HWC2::Error>(error)).c_str(), error);
+ return;
+ }
+
+ if (numTypes || numRequests) {
+ ALOGE("prepare: validate required changes for display %d: %s (%d)",
+ (uint32_t) displayId,
+ to_string(static_cast<HWC2::Error>(error)).c_str(), error);
+ return;
+ }
+
+ error = hwc2_compat_display_accept_changes(hwcDisplay);
+ if (error != HWC2_ERROR_NONE) {
+ ALOGE("prepare: acceptChanges failed: %s",
+ to_string(static_cast<HWC2::Error>(error)).c_str());
+ return;
+ }
+
+ hwc2_compat_display_set_client_target(hwcDisplay, /* slot */0, buffer,
+ getFenceBufferFd(buffer),
+ HAL_DATASPACE_UNKNOWN);
+
+ int presentFence;
+ hwc2_compat_display_present(hwcDisplay, &presentFence);
+
+ if (error != HWC2_ERROR_NONE) {
+ ALOGE("presentAndGetReleaseFences: failed for display %d: %s (%d)",
+ (uint32_t) displayId,
+ to_string(static_cast<HWC2::Error>(error)).c_str(), error);
+ return;
+ }
+
+ hwc2_compat_out_fences_t* fences;
+ error = hwc2_compat_display_get_release_fences(
+ hwcDisplay, &fences);
+
+ if (error != HWC2_ERROR_NONE) {
+ ALOGE("presentAndGetReleaseFences: Failed to get release fences "
+ "for display %d: %s (%d)",
+ (uint32_t) displayId, to_string(static_cast<HWC2::Error>(error)).c_str(),
+ error);
+ return;
+ }
+
+ int fenceFd = hwc2_compat_out_fences_get_fence(fences, layer);
+ if (fenceFd != -1)
+ setFenceBufferFd(buffer, fenceFd);
+
+ hwc2_compat_out_fences_destroy(fences);
+
+ if (lastPresentFence != -1) {
+ sync_wait(lastPresentFence, -1);
+ close(lastPresentFence);
+ }
+ lastPresentFence = presentFence;
+}
+
+void onVsyncReceived(HWC2EventListener* listener, int32_t sequenceId,
+ hwc2_display_t display, int64_t timestamp)
+{
+}
+
+void onHotplugReceived(HWC2EventListener* listener, int32_t sequenceId,
+ hwc2_display_t display, bool connected,
+ bool primaryDisplay)
+{
+ ALOGI("onHotplugReceived(%d, %" PRIu64 ", %s, %s)",
+ sequenceId, display,
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/hwcomposer.h
^
|
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2015 Jolla Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HYBRIS_HWCOMPOSER_H
+#define HYBRIS_HWCOMPOSER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ANativeWindow;
+struct ANativeWindowBuffer;
+
+typedef void (*HWCPresentCallback)(void *user_data, struct ANativeWindow *window,
+ struct ANativeWindowBuffer *buffer);
+
+/** Create a new HWC ANativeWindow.
+ *
+ * The Window can be casted to EGLNativeWindowType and used to create
+ * an EGLSurface.
+ * The specified present callback will be called by the window when a new
+ * buffer is ready to be presented on screen. It is responsibility of the
+ * caller to make sure that happens, by using the hwcomposer API.
+ * Returns the window on success or NULL on failure.
+ *
+ * \param width The width of the window in pixels.
+ * \param height The height of the window in pixels.
+ * \param format The HAL format of the window.
+ * \param present The present callback the window will use.
+ * \param cbData The callback data the window will pass along to the present callback.
+ *
+ * \sa HWCNativeWindowDestroy
+ */
+struct ANativeWindow *HWCNativeWindowCreate(unsigned int width, unsigned int height, unsigned int format,
+ HWCPresentCallback present, void *cbData);
+
+/** Destroy a HWC ANativeWindow.
+ *
+ * Destroys a native window created with HWCNativeWindowCreate().
+ * It is not necessary to call this after using eglDestroyWindowSurface()
+ * with an EGLSurface backing a valid ANativeWindow, the window will
+ * be destroyed automatically.
+ *
+ * \sa HWCNativeWindowCreate
+ */
+void HWCNativeWindowDestroy(struct ANativeWindow *window);
+
+/** Get the current fence FD on a buffer.
+ *
+ * The buffer must be a buffer passed from the HWC layer trough the present
+ * callback of a ANativeWindow.
+ *
+ * \sa HWCNativeWindowCreate
+ * \sa HWCNativeBufferSetFence
+ */
+int HWCNativeBufferGetFence(struct ANativeWindowBuffer *buf);
+
+/** Set the current fence FD on a buffer.
+ *
+ * The buffer must be a buffer passed from the HWC layer trough the present
+ * callback of a ANativeWindow.
+ *
+ * \sa HWCNativeWindowCreate
+ * \sa HWCNativeBufferGetFence
+ */
+void HWCNativeBufferSetFence(struct ANativeWindowBuffer *buf, int fd);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/hwcomposer_window.cpp
^
|
+(symlink to ../../../../libhybris/hybris/egl/platforms/hwcomposer/hwcomposer_window.cpp)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/hwcomposer_window.h
^
|
+(symlink to ../../../../libhybris/hybris/egl/platforms/hwcomposer/hwcomposer_window.h)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/hybris-gralloc.c
^
|
+(symlink to ../../../hybris/gralloc/gralloc.c)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/hybris-gralloc.h
^
|
+(symlink to ../../../hybris/include/hybris/gralloc/gralloc.h)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/nativewindowbase.cpp
^
|
+(symlink to ../../../../libhybris/hybris/egl/platforms/common/nativewindowbase.cpp)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/nativewindowbase.h
^
|
+(symlink to ../../../../libhybris/hybris/egl/platforms/common/nativewindowbase.h)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/hwc2/tests/support.h
^
|
@@ -0,0 +1,17 @@
+#ifndef SUPPORT_H_
+#define SUPPORT_H_
+
+#include <stddef.h>
+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/compat/media/Android.mk
^
|
@@ -1,4 +1,11 @@
LOCAL_PATH:= $(call my-dir)
+
+HYBRIS_MEDIA_32_BIT_ONLY := $(shell cat frameworks/av/media/libmediaplayerservice/Android.mk |grep LOCAL_32_BIT_ONLY |grep -o "true\|false")
+
+ifeq ($(HYBRIS_MEDIA_32_BIT_ONLY),true)
+HYBRIS_MEDIA_MULTILIB := 32
+endif
+
include $(CLEAR_VARS)
include $(LOCAL_PATH)/../Android.common.mk
@@ -40,6 +47,11 @@
LOCAL_MODULE_STEM_64 := $(if $(filter false,$(BOARD_UBUNTU_PREFER_32_BIT)),$(LOCAL_MODULE),$(LOCAL_MODULE)_64)
endif
+ifeq ($(HYBRIS_MEDIA_32_BIT_ONLY),true)
+LOCAL_32_BIT_ONLY := true
+LOCAL_MULTILIB := 32
+endif
+
include $(BUILD_EXECUTABLE)
# -------------------------------------------------
@@ -129,6 +141,11 @@
$(TOP)/$(MTK_PATH_SOURCE)/frameworks/av/include
endif
+ifeq ($(HYBRIS_MEDIA_32_BIT_ONLY),true)
+LOCAL_32_BIT_ONLY := true
+LOCAL_MULTILIB := 32
+endif
+
include $(BUILD_SHARED_LIBRARY)
# -------------------------------------------------
@@ -170,4 +187,9 @@
LOCAL_MODULE_STEM_64 := $(if $(filter false,$(BOARD_UBUNTU_PREFER_32_BIT)),$(LOCAL_MODULE),$(LOCAL_MODULE)_64)
endif
+ifeq ($(HYBRIS_MEDIA_32_BIT_ONLY),true)
+LOCAL_32_BIT_ONLY := true
+LOCAL_MULTILIB := 32
+endif
+
include $(BUILD_EXECUTABLE)
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/Makefile.am
^
|
@@ -1,4 +1,4 @@
-SUBDIRS = include properties common hardware
+SUBDIRS = include common properties hardware gralloc
if HAS_ANDROID_4_2_0
SUBDIRS += libsync
@@ -6,13 +6,11 @@
if HAS_ANDROID_5_0_0
SUBDIRS += libsync
endif
-SUBDIRS += egl glesv1 glesv2 ui sf input camera vibrator media wifi opencl
+SUBDIRS += egl glesv1 glesv2 ui sf input camera vibrator media opencl wifi hwc2
-if HAS_LIBNFC_NXP_HEADERS
SUBDIRS += libnfc_nxp libnfc_ndef_nxp
-endif
-SUBDIRS += utils tests
+SUBDIRS += utils tests
MAINTAINERCLEANFILES = \
aclocal.m4 compile config.guess config.sub \
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/Makefile.am
^
|
@@ -15,14 +15,27 @@
SUBDIRS += n
endif
+if HAS_ANDROID_8_0_0
+SUBDIRS += o
+endif
+
libhybris_common_la_SOURCES = \
hooks.c \
hooks_shm.c \
strlcpy.c \
strlcat.c \
logging.c \
- sysconf.c
+ sysconf.c \
+ legacy_properties/properties.c \
+ legacy_properties/cache.c
+if WANT_RUNTIME_PROPERTY_CACHE
+libhybris_common_la_SOURCES += \
+ legacy_properties/runtime_cache.c
+libhybris_common_la_CFLAGS =
+else
+libhybris_common_la_CFLAGS = -DNO_RUNTIME_PROPERTY_CACHE
+endif
if WANT_ARM_TRACING
libhybris_common_la_SOURCES += \
wrappers.c \
@@ -41,7 +54,7 @@
if WANT_ARM_TRACING
# thumb mode not supported
-libhybris_common_la_CFLAGS = \
+libhybris_common_la_CFLAGS += \
-marm
libhybris_common_la_CPPFLAGS += \
-marm
@@ -71,11 +84,13 @@
if HAS_ANDROID_7_0_0
libhybris_common_la_CPPFLAGS += -DWANT_LINKER_N
endif
+if HAS_ANDROID_8_0_0
+libhybris_common_la_CPPFLAGS += -DWANT_LINKER_O
+endif
libhybris_common_la_LDFLAGS = \
-ldl \
-lrt \
-pthread \
-lc \
-lstdc++ \
- $(top_builddir)/properties/libandroid-properties.la \
-version-info "$(LT_CURRENT)":"$(LT_REVISION)":"$(LT_AGE)"
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/hooks.c
^
|
@@ -71,10 +71,19 @@
#include <mntent.h>
#include <hybris/properties/properties.h>
+
+// using private implementations
+extern int my_property_set(const char *key, const char *value);
+extern int my_property_get(const char *key, char *value, const char *default_value);
+extern int my_property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie);
+
#include <hybris/common/hooks.h>
#include <android-config.h>
+// this is also used in bionic:
+#define bool int
+
#ifdef WANT_ARM_TRACING
#include "wrappers.h"
#endif
@@ -89,12 +98,29 @@
static void (*_android_linker_init)(int sdk_version, void* (*get_hooked_symbol)(const char*, const char*)) = NULL;
#endif
-static void* (*_android_dlopen)(const char *filename, int flags) = NULL;
-static void* (*_android_dlsym)(void *handle, const char *symbol) = NULL;
-static void* (*_android_dlvsym)(void *handle, const char *symbol, const char* version) = NULL;
-static void* (*_android_dladdr)(void *addr, Dl_info *info) = NULL;
-static int (*_android_dlclose)(void *handle) = NULL;
-static const char* (*_android_dlerror)(void) = NULL;
+void *(*_android_dlopen)(const char* filename, int flag) = NULL;
+char *(*_android_dlerror)() = NULL;
+void *(*_android_dlsym)(void* handle, const char* symbol) = NULL;
+void *(*_android_dlvsym)(void* handle, const char* symbol, const char* version) = NULL;
+int (*_android_dladdr)(const void* addr, void* info) = NULL;
+int (*_android_dlclose)(void* handle) = NULL;
+void *(*_android_dl_unwind_find_exidx)(void *pc, int* pcount) = NULL;
+int (*_android_dl_iterate_phdr)(int (*cb)(void* info, size_t size, void* data), void* data) = NULL;
+void (*_android_get_LD_LIBRARY_PATH)(char* buffer, size_t buffer_size) = NULL;
+void (*_android_update_LD_LIBRARY_PATH)(const char* ld_library_path) = NULL;
+void *(*_android_dlopen_ext)(const char* filename, int flag, const void* extinfo) = NULL;
+void (*_android_set_application_target_sdk_version)(uint32_t target) = NULL;
+uint32_t (*_android_get_application_target_sdk_version)() = NULL;
+void *(*_android_create_namespace)(const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path,
+ void* parent) = NULL;
+bool (*_android_init_anonymous_namespace)(const char* shared_libs_sonames,
+ const char* library_search_path) = NULL;
+void (*_android_dlwarning)(void* obj, void (*f)(void*, const char*)) = NULL;
+void *(*_android_get_exported_namespace)(const char* name) = NULL;
/* TODO:
* - Check if the int arguments at attr_set/get match the ones at Android
@@ -1276,6 +1302,36 @@
return pthread_rwlock_unlock(realrwlock);
}
+/* Bionic implementation of pthread_cleanup_push/pop doesn't support C++ exceptions
+ and thread cancelation. We only make sure to call the cleanup routine when
+ requested. We duplicate the bionic cleanup struct here for our purposes. */
+
+typedef void (*bionic___pthread_cleanup_func_t)(void*);
+
+typedef struct bionic___pthread_cleanup_t {
+ struct bionic___pthread_cleanup_t* __cleanup_prev; /* unused */
+ bionic___pthread_cleanup_func_t __cleanup_routine;
+ void* __cleanup_arg;
+} bionic___pthread_cleanup_t;
+
+static void _hybris_hook___pthread_cleanup_push(void *bionic_cleanup, void *routine, void *arg)
+{
+ bionic___pthread_cleanup_t *cleanup = bionic_cleanup;
+
+ TRACE_HOOK("cleanup %p routine %p arg %p", cleanup, routine, arg);
+ cleanup->__cleanup_routine = routine;
+ cleanup->__cleanup_arg = arg;
+}
+
+static void _hybris_hook___pthread_cleanup_pop(void *bionic_cleanup, int execute)
+{
+ bionic___pthread_cleanup_t *cleanup = bionic_cleanup;
+
+ TRACE_HOOK("cleanup %p execute %d", cleanup, execute);
+ if (execute)
+ cleanup->__cleanup_routine(cleanup->__cleanup_arg);
+}
+
#define min(X,Y) (((X) < (Y)) ? (X) : (Y))
static pid_t _hybris_hook_pthread_gettid_np(pthread_t t)
@@ -1964,7 +2020,7 @@
{
TRACE_HOOK("pi %p name '%s' value '%s'", pi, name, value);
- return property_get(name, value, NULL);
+ return my_property_get(name, value, NULL);
}
static int _hybris_hook___system_property_foreach(void (*propfn)(const void *pi, void *cookie), void *cookie)
@@ -2035,7 +2091,7 @@
{
TRACE_HOOK("name '%s' value '%s'", name, value);
- return property_get(name, (char*) value, NULL);
+ return my_property_get(name, (char*) value, NULL);
}
int _hybris_hook_property_get(const char *key, char *value, const char *default_value)
@@ -2043,14 +2099,22 @@
TRACE_HOOK("key '%s' value '%s' default value '%s'",
key, value, default_value);
- return property_get(key, value, default_value);
+ return my_property_get(key, value, default_value);
+}
+
+int _hybris_hook_property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie)
+{
+ TRACE_HOOK("propfn '%p' cookie '%p'",
+ propfn, cookie);
+
+ return my_property_list(propfn, cookie);
}
int _hybris_hook_property_set(const char *key, const char *value)
{
TRACE_HOOK("key '%s' value '%s'", key, value);
- return property_set(key, value);
+ return my_property_set(key, value);
}
char *_hybris_hook_getenv(const char *name)
@@ -2445,19 +2509,126 @@
return android_dlerror();
}
+void *_hybris_hook_dl_unwind_find_exidx(void* pc, int* pcount)
+{
+ TRACE("pc %p, pcount %p", pc, pcount);
+
+ return _android_dl_unwind_find_exidx(pc, pcount);
+}
+
+int _hybris_hook_dl_iterate_phdr(int (*cb)(void* info, size_t size, void* data), void* data)
+{
+ TRACE("cb %p, data %p", cb, data);
+
+ return _android_dl_iterate_phdr(cb, data);
+}
+
+void _hybris_hook_android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size)
+{
+ TRACE("buffer %p, buffer_size %zu\n", buffer_size);
+
+ _android_get_LD_LIBRARY_PATH(buffer, buffer_size);
+}
+
+void _hybris_hook_android_update_LD_LIBRARY_PATH(const char* ld_library_path)
+{
+ TRACE("ld_library_path %s", ld_library_path);
+
+ _android_update_LD_LIBRARY_PATH(ld_library_path);
+}
+
+void* _hybris_hook_android_dlopen_ext(const char* filename, int flag, const void* extinfo)
+{
+ TRACE("filename %s, flag %d, extinfo %s", filename, flag, extinfo);
+
+ return _android_dlopen_ext(filename, flag, extinfo);
+}
+
+void _hybris_hook_android_set_application_target_sdk_version(uint32_t target)
+{
+ TRACE("target %d", target);
+
+ android_set_application_target_sdk_version(target);
+}
+
+uint32_t _hybris_hook_android_get_application_target_sdk_version()
+{
+ TRACE("");
+
+ return _android_get_application_target_sdk_version();
+}
+
+void* _hybris_hook_android_create_namespace(const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path,
+ void* parent)
+{
+ TRACE("name %s, ld_library_path %s, default_library_path %s, type %" PRIu64 ", permitted_when_isolated_path %s, parent %p", name, ld_library_path, default_library_path, type, permitted_when_isolated_path, parent);
+
+ return _android_create_namespace(name, ld_library_path, default_library_path, type, permitted_when_isolated_path, parent);
+}
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/legacy_properties/cache.c
^
|
(renamed from libhybris/hybris/properties/cache.c)
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/legacy_properties/properties.c
^
|
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2012 Carsten Munk <carsten.munk@gmail.com>
+ * 2008 The Android Open Source Project
+ * 2013 Simon Busch <morphis@gravedo.de>
+ * 2013 Canonical Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stddef.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#define __USE_GNU
+#include <unistd.h>
+#include <errno.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/select.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <poll.h>
+
+#include <hybris/properties/properties.h>
+#include "properties_p.h"
+
+static const char property_service_socket[] = "/dev/socket/" PROP_SERVICE_NAME;
+static int send_prop_msg_no_reply = 0;
+
+typedef struct prop_msg_s {
+ unsigned cmd;
+ char name[PROP_NAME_MAX];
+ char value[PROP_VALUE_MAX];
+} prop_msg_t;
+
+/* Get/Set a property from the Android Init property socket */
+static int send_prop_msg(prop_msg_t *msg,
+ void (*propfn)(const char *, const char *, void *),
+ void *cookie)
+{
+ union {
+ struct sockaddr_un addr;
+ struct sockaddr addr_g;
+ } addr;
+ socklen_t alen;
+ size_t namelen;
+ int s;
+ int r;
+ int result = -1;
+ int patched_init = 0;
+
+ /* if we tried to talk to the server in the past and didn't get a reply,
+ * it's fairly safe to say that init is not patched and this is all
+ * hopeless, so we should just quit while we're ahead
+ */
+ if (send_prop_msg_no_reply == 1)
+ return -EIO;
+
+ s = socket(AF_LOCAL, SOCK_STREAM, 0);
+ if (s < 0) {
+ return result;
+ }
+
+ memset(&addr, 0, sizeof(addr));
+ namelen = strlen(property_service_socket);
+ strncpy(addr.addr.sun_path, property_service_socket,
+ sizeof(addr.addr.sun_path));
+ addr.addr.sun_family = AF_LOCAL;
+ alen = namelen + offsetof(struct sockaddr_un, sun_path) + 1;
+
+ if (TEMP_FAILURE_RETRY(connect(s, &addr.addr_g, alen) < 0)) {
+ close(s);
+ return result;
+ }
+
+ r = TEMP_FAILURE_RETRY(send(s, msg, sizeof(prop_msg_t), 0));
+
+ if (r == sizeof(prop_msg_t)) {
+ // We successfully wrote to the property server, so use recv
+ // in case we need to get a property. Once the other side is
+ // finished, the socket is closed.
+ while ((r = recv(s, msg, sizeof(prop_msg_t), 0)) > 0) {
+ if (r != sizeof(prop_msg_t)) {
+ close(s);
+ return result;
+ }
+
+ /* If we got a reply, this is a patched init */
+ if (!patched_init)
+ patched_init = 1;
+
+ if (propfn)
+ propfn(msg->name, msg->value, cookie);
+ }
+
+ /* We also just get a close in case of setprop */
+ if ((r >= 0) && (patched_init ||
+ (msg->cmd == PROP_MSG_SETPROP))) {
+ result = 0;
+ } else {
+ send_prop_msg_no_reply = 1;
+ }
+ }
+
+ close(s);
+ return result;
+}
+
+int my_property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie)
+{
+ int err;
+ prop_msg_t msg;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.cmd = PROP_MSG_LISTPROP;
+
+ err = send_prop_msg(&msg, propfn, cookie);
+ if (err < 0)
+ /* fallback to property cache */
+ hybris_propcache_list((hybris_propcache_list_cb) propfn, cookie);
+
+ return 0;
+}
+
+static int property_get_socket(const char *key, char *value, const char *default_value)
+{
+ int err;
+ prop_msg_t msg;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.cmd = PROP_MSG_GETPROP;
+
+ if (key) {
+ strncpy(msg.name, key, sizeof(msg.name));
+ err = send_prop_msg(&msg, NULL, NULL);
+ if (err < 0)
+ return err;
+ }
+
+ /* In case it's null, just use the default */
+ if ((strlen(msg.value) == 0) && (default_value)) {
+ if (strlen(default_value) > PROP_VALUE_MAX -1) return -1;
+ strcpy(msg.value, default_value);
+ }
+
+ strcpy(value, msg.value);
+
+ return 0;
+}
+
+int my_property_get(const char *key, char *value, const char *default_value)
+{
+ char *ret = NULL;
+
+ if ((key) && (strlen(key) > PROP_NAME_MAX -1)) return -1;
+ if (value == NULL) return -1;
+
+
+ // Runtime cache will serialize property lookups within the process.
+ // This will increase latency if multiple threads are doing many
+ // parallel lookups to new properties, but the overhead should
+ // be offset with the caching eventually.
+ runtime_cache_lock();
+ if (runtime_cache_get(key, value) == 0) {
+ ret = value;
+ } else if (property_get_socket(key, value, default_value) == 0) {
+ runtime_cache_insert(key, value);
+ ret = value;
+ }
+ runtime_cache_unlock();
+
+ if (ret)
+ return strlen(ret);
+
+
+ /* In case the socket is not available, search the property file cache by hand */
+ ret = hybris_propcache_find(key);
+
+ if (ret) {
+ strcpy(value, ret);
+ return strlen(value);
+ } else if (default_value != NULL) {
+ strcpy(value, default_value);
+ return strlen(value);
+ } else {
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/legacy_properties/properties_p.h
^
|
(renamed from libhybris/hybris/properties/properties_p.h)
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/legacy_properties/runtime_cache.c
^
|
(renamed from libhybris/hybris/properties/runtime_cache.c)
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/n/Makefile.am
^
|
@@ -54,3 +54,9 @@
n_la_CPPFLAGS += \
-DTRACE_DEBUG=1
endif
+
+if WANT_ARM_TRACING
+n_la_CPPFLAGS += \
+ -DWANT_ARM_TRACING
+endif
+
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/n/linker.cpp
^
|
@@ -68,6 +68,10 @@
#include "linker_non_pie.h"
#endif
+#ifdef WANT_ARM_TRACING
+#include "../wrappers.h"
+#endif
+
// Stay compatible with newer glibc
#ifndef R_AARCH64_TLS_TPREL64
#define R_AARCH64_TLS_TPREL64 R_AARCH64_TLS_TPREL
@@ -348,6 +352,10 @@
static void* (*_get_hooked_symbol)(const char *sym, const char *requester);
+#ifdef WANT_ARM_TRACING
+void *(*_create_wrapper)(const char *symbol, void *function, int wrapper_type);
+#endif
+
static char __linker_dl_err_buf[768];
char* linker_get_error_buffer() {
@@ -2621,7 +2629,19 @@
uint32_t bind = ELF_ST_BIND(sym->st_info);
if ((bind == STB_GLOBAL || bind == STB_WEAK) && sym->st_shndx != 0) {
+#ifdef WANT_ARM_TRACING
+ switch(ELF_ST_TYPE(sym->st_info))
+ {
+ case STT_FUNC:
+ case STT_GNU_IFUNC:
+ case STT_ARM_TFUNC:
+ *symbol = reinterpret_cast<void*>(_create_wrapper((char*)symbol, (void*)found->resolve_symbol_address(sym), WRAPPER_DYNHOOK));
+ default:
+ *symbol = reinterpret_cast<void*>(found->resolve_symbol_address(sym));
+ }
+#else
*symbol = reinterpret_cast<void*>(found->resolve_symbol_address(sym));
+#endif
return true;
}
@@ -2914,6 +2934,28 @@
return false;
}
}
+#ifdef WANT_ARM_TRACING
+ else
+ {
+ // this will be slower.
+ if (!lookup_version_info(version_tracker, sym, sym_name, &vi)) {
+ return false;
+ }
+
+ if (!soinfo_do_lookup(this, sym_name, vi, &lsi, global_group, local_group, &s)) {
+ return false;
+ }
+
+ switch(ELF_ST_TYPE(s->st_info))
+ {
+ case STT_FUNC:
+ case STT_GNU_IFUNC:
+ case STT_ARM_TFUNC:
+ sym_addr = (ElfW(Addr))_create_wrapper(sym_name, (void*)sym_addr, WRAPPER_HOOKED);
+ break;
+ }
+ }
+#endif
if (sym_addr == 0 && s == nullptr) {
// We only allow an undefined symbol if this is a weak reference...
@@ -2987,7 +3029,24 @@
}
}
#endif
- sym_addr = lsi->resolve_symbol_address(s);
+
+#ifdef WANT_ARM_TRACING
+ switch(ELF_ST_TYPE(s->st_info))
+ {
+ case STT_FUNC:
+ case STT_GNU_IFUNC:
+ case STT_ARM_TFUNC:
+ sym_addr = (ElfW(Addr))_create_wrapper(sym_name,
+ (void*)lsi->resolve_symbol_address(s), WRAPPER_UNHOOKED);
+ break;
+ default:
+ sym_addr = lsi->resolve_symbol_address(s);
+ break;
+ }
+#else
+ sym_addr = lsi->resolve_symbol_address(s);
+#endif
+
#if !defined(__LP64__)
if (protect_segments) {
if (phdr_table_unprotect_segments(phdr, phnum, load_bias) < 0) {
@@ -4624,7 +4683,11 @@
__libc_fatal("CANNOT LINK EXECUTABLE \"%s\": %s", args.argv[0], linker_get_error_buffer());
}
+#ifdef WANT_ARM_TRACING
+extern "C" void android_linker_init(int sdk_version, void* (*get_hooked_symbol)(const char*, const char*), void *(create_wrapper)(const char*, void*, int)) {
+#else
extern "C" void android_linker_init(int sdk_version, void* (*get_hooked_symbol)(const char*, const char*)) {
+#endif
// Get a few environment variables.
const char* LD_DEBUG = getenv("HYBRIS_LD_DEBUG");
if (LD_DEBUG != nullptr) {
@@ -4648,6 +4711,9 @@
set_application_target_sdk_version(sdk_version);
_get_hooked_symbol = get_hooked_symbol;
+#ifdef WANT_ARM_TRACING
+ _create_wrapper = create_wrapper;
+#endif
}
#ifdef DISABLED_FOR_HYBRIS_SUPPORT
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/n/linker_gdb_support.cpp
^
|
@@ -31,28 +31,46 @@
{1, nullptr, reinterpret_cast<uintptr_t>(&rtld_db_dlactivity), r_debug::RT_CONSISTENT, 0};
static pthread_mutex_t g__r_debug_mutex = PTHREAD_MUTEX_INITIALIZER;
-static link_map* r_debug_tail = nullptr;
+static link_map* r_debug_head = nullptr;
void insert_link_map_into_debug_map(link_map* map) {
// Stick the new library at the end of the list.
// gdb tends to care more about libc than it does
// about leaf libraries, and ordering it this way
// reduces the back-and-forth over the wire.
- if (r_debug_tail != nullptr) {
- r_debug_tail->l_next = map;
- map->l_prev = r_debug_tail;
- map->l_next = nullptr;
+
+ ///// PATCHED: we don't want libhybris modifying glibc's
+ ///// link_map objects, which should not be linked
+ ///// to bionic's stripped link_map objects.
+ ///// ==> make a copy of the whole chain
+ if(r_debug_head == nullptr && _r_debug.r_map != nullptr) {
+ link_map *glibc_link_map = new link_map(*_r_debug.r_map);
+ r_debug_head = glibc_link_map;
+
+ while(glibc_link_map->l_next != nullptr) {
+ link_map *copy_next_link_map = new link_map(*glibc_link_map->l_next);
+ glibc_link_map->l_next = copy_next_link_map;
+ copy_next_link_map->l_prev = glibc_link_map;
+
+ glibc_link_map = copy_next_link_map;
+ }
+ }
+
+ if (r_debug_head != nullptr) {
+ r_debug_head->l_prev = map;
+ map->l_next = r_debug_head;
+ map->l_prev = nullptr;
} else {
_r_debug.r_map = map;
map->l_prev = nullptr;
map->l_next = nullptr;
}
- r_debug_tail = map;
+ _r_debug.r_map = r_debug_head = map;
}
void remove_link_map_from_debug_map(link_map* map) {
- if (r_debug_tail == map) {
- r_debug_tail = map->l_prev;
+ if (r_debug_head == map) {
+ r_debug_head = map->l_next;
}
if (map->l_prev) {
|
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/MODULE_LICENSE_BSD
^
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/Makefile.am
^
|
@@ -0,0 +1,69 @@
+bionic = $(top_srcdir)/common/o/bionic
+bionic_libc = $(bionic)/libc
+
+modlibexecdir = $(libdir)/libhybris/linker
+modlibexec_LTLIBRARIES = o.la
+
+ARCH_FLAGS =
+
+AM_CFLAGS = \
+ -std=gnu99
+
+AM_CPPFLAGS = \
+ -fno-stack-protector \
+ -Wstrict-overflow=5
+
+AM_CXXFLAGS = \
+ -std=gnu++11 \
+ -Wold-style-cast
+
+o_la_SOURCES = \
+ hybris_compat.cpp \
+ dlfcn.cpp \
+ linker_allocator.cpp \
+ linker_block_allocator.cpp \
+ linker.cpp \
+ linker_cfi.cpp \
+ linker_config.cpp \
+ linker_dlwarning.cpp \
+ linker_gdb_support.cpp \
+ linker_globals.cpp \
+ linker_logger.cpp \
+ linker_main.cpp \
+ linker_mapped_file_fragment.cpp \
+ linker_memory.cpp \
+ linker_namespaces.cpp \
+ linker_phdr.cpp \
+ linker_sdk_versions.cpp \
+ linker_soinfo.cpp \
+ linker_utils.cpp \
+ rt.cpp \
+ ../strlcpy.c \
+ ../strlcat.c
+o_la_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/common \
+ -I$(bionic_libc)/ \
+ -I$(bionic_libc)/include \
+ -DDEFAULT_HYBRIS_LD_LIBRARY_PATH="\"@DEFAULT_HYBRIS_LD_LIBRARY_PATH@\"" \
+ $(ARCH_FLAGS) \
+ $(ANDROID_HEADERS_CFLAGS)
+o_la_LDFLAGS = \
+ -lsupc++ \
+ -module \
+ -avoid-version
+
+if WANT_DEBUG
+o_la_CPPFLAGS += \
+ -DTRACE_DEBUG=1
+else
+o_la_CPPFLAGS += \
+ -DTRACE_DEBUG=1
+endif
+
+if WANT_ARM_TRACING
+o_la_CPPFLAGS += \
+ -DWANT_ARM_TRACING
+endif
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/async_safe/log.h
^
|
@@ -0,0 +1,26 @@
+#ifndef thatasyncsafeheaderthingy_replacement__
+#define thatasyncsafeheaderthingy_replacement__
+
+enum {
+ ANDROID_LOG_UNKNOWN = 0,
+ ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
+
+ ANDROID_LOG_VERBOSE,
+ ANDROID_LOG_DEBUG,
+ ANDROID_LOG_INFO,
+ ANDROID_LOG_WARN,
+ ANDROID_LOG_ERROR,
+ ANDROID_LOG_FATAL,
+
+ ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
+};
+
+#define async_safe_fatal(...) { fprintf(stderr, __VA_ARGS__); abort(); }
+
+#define async_safe_format_fd(...) dprintf(__VA_ARGS)
+
+// Don't really care about verbose/debug logs for now
+#define async_safe_format_log_va_list(loglevel, category, format, ...) { if (loglevel > ANDROID_LOG_INFO) { vfprintf(stderr, format, __VA_ARGS__); } }
+
+#endif
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/bionic/pthread_internal.h
^
|
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _PTHREAD_INTERNAL_H_
+#define _PTHREAD_INTERNAL_H_
+
+#include <pthread.h>
+#include <stdatomic.h>
+
+#include "private/bionic_lock.h"
+#include "private/bionic_tls.h"
+
+/* Has the thread been detached by a pthread_join or pthread_detach call? */
+#define PTHREAD_ATTR_FLAG_DETACHED 0x00000001
+
+/* Has the thread been joined by another thread? */
+#define PTHREAD_ATTR_FLAG_JOINED 0x00000002
+
+class pthread_key_data_t {
+ public:
+ uintptr_t seq; // Use uintptr_t just for alignment, as we use pointer below.
+ void* data;
+};
+
+enum ThreadJoinState {
+ THREAD_NOT_JOINED,
+ THREAD_EXITED_NOT_JOINED,
+ THREAD_JOINED,
+ THREAD_DETACHED
+};
+
+class thread_local_dtor;
+
+class pthread_internal_t {
+ public:
+ class pthread_internal_t* next;
+ class pthread_internal_t* prev;
+
+ pid_t tid;
+
+ private:
+ pid_t cached_pid_;
+
+ public:
+ pid_t invalidate_cached_pid() {
+ pid_t old_value;
+ get_cached_pid(&old_value);
+ set_cached_pid(0);
+ return old_value;
+ }
+
+ void set_cached_pid(pid_t value) {
+ cached_pid_ = value;
+ }
+
+ bool get_cached_pid(pid_t* cached_pid) {
+ *cached_pid = cached_pid_;
+ return (*cached_pid != 0);
+ }
+
+ pthread_attr_t attr;
+
+ _Atomic(ThreadJoinState) join_state;
+
+ //__pthread_cleanup_t* cleanup_stack;
+
+ void* (*start_routine)(void*);
+ void* start_routine_arg;
+ void* return_value;
+
+ void* alternate_signal_stack;
+
+ Lock startup_handshake_lock;
+
+ size_t mmap_size;
+
+ thread_local_dtor* thread_local_dtors;
+
+ void* tls[BIONIC_TLS_SLOTS];
+
+ pthread_key_data_t key_data[BIONIC_PTHREAD_KEY_COUNT];
+
+ /*
+ * The dynamic linker implements dlerror(3), which makes it hard for us to implement this
+ * per-thread buffer by simply using malloc(3) and free(3).
+ */
+#define __BIONIC_DLERROR_BUFFER_SIZE 512
+ char dlerror_buffer[__BIONIC_DLERROR_BUFFER_SIZE];
+
+ struct bionic_tls* bionic_tls;
+};
+
+int __init_thread(pthread_internal_t* thread);
+bool __init_tls(pthread_internal_t* thread);
+void __init_thread_stack_guard(pthread_internal_t* thread);
+void __init_alternate_signal_stack(pthread_internal_t*);
+
+pthread_t __pthread_internal_add(pthread_internal_t* thread);
+pthread_internal_t* __pthread_internal_find(pthread_t pthread_id);
+void __pthread_internal_remove(pthread_internal_t* thread);
+void __pthread_internal_remove_and_free(pthread_internal_t* thread);
+
+// Make __get_thread() inlined for performance reason. See http://b/19825434.
+static inline pthread_internal_t* __get_thread() {
+ void** tls = __get_tls();
+ if (tls) {
+ return reinterpret_cast<pthread_internal_t*>(tls[TLS_SLOT_THREAD_ID]);
+ }
+
+ // This happens when called during libc initialization before TLS has been initialized.
+ return nullptr;
+}
+
+static inline bionic_tls& __get_bionic_tls() {
+ return *__get_thread()->bionic_tls;
+}
+
+void pthread_key_clean_all(void);
+
+// SIGSTKSZ (8kB) is not big enough.
+// snprintf to a stack buffer of size PATH_MAX consumes ~7kB of stack.
+// Also, on 64-bit, logging uses more than 8kB by itself:
+// https://code.google.com/p/android/issues/detail?id=187064
+#define SIGNAL_STACK_SIZE_WITHOUT_GUARD_PAGE (16 * 1024)
+
+/*
+ * Traditionally we gave threads a 1MiB stack. When we started
+ * allocating per-thread alternate signal stacks to ease debugging of
+ * stack overflows, we subtracted the same amount we were using there
+ * from the default thread stack size. This should keep memory usage
+ * roughly constant.
+ */
+#define PTHREAD_STACK_SIZE_DEFAULT ((1 * 1024 * 1024) - SIGNAL_STACK_SIZE_WITHOUT_GUARD_PAGE)
+
+// Leave room for a guard page in the internally created signal stacks.
+#define SIGNAL_STACK_SIZE (SIGNAL_STACK_SIZE_WITHOUT_GUARD_PAGE + PAGE_SIZE)
+
+/* Needed by fork. */
+extern void __bionic_atfork_run_prepare();
+extern void __bionic_atfork_run_child();
+extern void __bionic_atfork_run_parent();
+
+#endif /* _PTHREAD_INTERNAL_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/endian.h
^
|
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_ENDIAN_H
+#define ANDROID_BASE_ENDIAN_H
+
+/* A cross-platform equivalent of bionic's <sys/endian.h>. */
+
+#if defined(__BIONIC__)
+
+#include <sys/endian.h>
+
+#elif defined(__GLIBC__)
+
+/* glibc's <endian.h> is like bionic's <sys/endian.h>. */
+#include <endian.h>
+
+/* glibc keeps htons and htonl in <netinet/in.h>. */
+#include <netinet/in.h>
+
+/* glibc doesn't have the 64-bit variants. */
+#define htonq(x) htobe64(x)
+#define ntohq(x) be64toh(x)
+
+/* glibc has different names to BSD for these. */
+#define betoh16(x) be16toh(x)
+#define betoh32(x) be32toh(x)
+#define betoh64(x) be64toh(x)
+
+#else
+
+/* Mac OS and Windows have nothing. */
+
+#define __LITTLE_ENDIAN 1234
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+
+#define __BIG_ENDIAN 4321
+#define BIG_ENDIAN __BIG_ENDIAN
+
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#define htons(x) __builtin_bswap16(x)
+#define htonl(x) __builtin_bswap32(x)
+#define htonq(x) __builtin_bswap64(x)
+
+#define ntohs(x) __builtin_bswap16(x)
+#define ntohl(x) __builtin_bswap32(x)
+#define ntohq(x) __builtin_bswap64(x)
+
+#define htobe16(x) __builtin_bswap16(x)
+#define htobe32(x) __builtin_bswap32(x)
+#define htobe64(x) __builtin_bswap64(x)
+
+#define betoh16(x) __builtin_bswap16(x)
+#define betoh32(x) __builtin_bswap32(x)
+#define betoh64(x) __builtin_bswap64(x)
+
+#define htole16(x) (x)
+#define htole32(x) (x)
+#define htole64(x) (x)
+
+#define letoh16(x) (x)
+#define letoh32(x) (x)
+#define letoh64(x) (x)
+
+#define be16toh(x) __builtin_bswap16(x)
+#define be32toh(x) __builtin_bswap32(x)
+#define be64toh(x) __builtin_bswap64(x)
+
+#define le16toh(x) (x)
+#define le32toh(x) (x)
+#define le64toh(x) (x)
+
+#endif
+
+#endif // ANDROID_BASE_ENDIAN_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/errors.h
^
|
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Portable error handling functions. This is only necessary for host-side
+// code that needs to be cross-platform; code that is only run on Unix should
+// just use errno and strerror() for simplicity.
+//
+// There is some complexity since Windows has (at least) three different error
+// numbers, not all of which share the same type:
+// * errno: for C runtime errors.
+// * GetLastError(): Windows non-socket errors.
+// * WSAGetLastError(): Windows socket errors.
+// errno can be passed to strerror() on all platforms, but the other two require
+// special handling to get the error string. Refer to Microsoft documentation
+// to determine which error code to check for each function.
+
+#ifndef ANDROID_BASE_ERRORS_H
+#define ANDROID_BASE_ERRORS_H
+
+#include <string>
+
+namespace android {
+namespace base {
+
+// Returns a string describing the given system error code. |error_code| must
+// be errno on Unix or GetLastError()/WSAGetLastError() on Windows. Passing
+// errno on Windows has undefined behavior.
+std::string SystemErrorCodeToString(int error_code);
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_ERRORS_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/file.h
^
|
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_FILE_H
+#define ANDROID_BASE_FILE_H
+
+#include <sys/stat.h>
+#include <string>
+
+#if !defined(_WIN32) && !defined(O_BINARY)
+#define O_BINARY 0
+#endif
+
+namespace android {
+namespace base {
+
+bool ReadFdToString(int fd, std::string* content);
+bool ReadFileToString(const std::string& path, std::string* content,
+ bool follow_symlinks = false);
+
+bool WriteStringToFile(const std::string& content, const std::string& path,
+ bool follow_symlinks = false);
+bool WriteStringToFd(const std::string& content, int fd);
+
+#if !defined(_WIN32)
+bool WriteStringToFile(const std::string& content, const std::string& path,
+ mode_t mode, uid_t owner, gid_t group,
+ bool follow_symlinks = false);
+#endif
+
+bool ReadFully(int fd, void* data, size_t byte_count);
+bool WriteFully(int fd, const void* data, size_t byte_count);
+
+bool RemoveFileIfExists(const std::string& path, std::string* err = nullptr);
+
+#if !defined(_WIN32)
+bool Realpath(const std::string& path, std::string* result);
+bool Readlink(const std::string& path, std::string* result);
+#endif
+
+std::string GetExecutablePath();
+std::string GetExecutableDirectory();
+
+// Like the regular basename and dirname, but thread-safe on all
+// platforms and capable of correctly handling exotic Windows paths.
+std::string Basename(const std::string& path);
+std::string Dirname(const std::string& path);
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_FILE_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/logging.h
^
|
@@ -0,0 +1,426 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_LOGGING_H
+#define ANDROID_BASE_LOGGING_H
+
+//
+// Google-style C++ logging.
+//
+
+// This header provides a C++ stream interface to logging.
+//
+// To log:
+//
+// LOG(INFO) << "Some text; " << some_value;
+//
+// Replace `INFO` with any severity from `enum LogSeverity`.
+//
+// To log the result of a failed function and include the string
+// representation of `errno` at the end:
+//
+// PLOG(ERROR) << "Write failed";
+//
+// The output will be something like `Write failed: I/O error`.
+// Remember this as 'P' as in perror(3).
+//
+// To output your own types, simply implement operator<< as normal.
+//
+// By default, output goes to logcat on Android and stderr on the host.
+// A process can use `SetLogger` to decide where all logging goes.
+// Implementations are provided for logcat, stderr, and dmesg.
+
+// This header also provides assertions:
+//
+// CHECK(must_be_true);
+// CHECK_EQ(a, b) << z_is_interesting_too;
+
+// NOTE: For Windows, you must include logging.h after windows.h to allow the
+// following code to suppress the evil ERROR macro:
+#ifdef _WIN32
+// windows.h includes wingdi.h which defines an evil macro ERROR.
+#ifdef ERROR
+#undef ERROR
+#endif
+#endif
+
+#include <functional>
+#include <memory>
+#include <ostream>
+
+#include "android-base/macros.h"
+
+namespace android {
+namespace base {
+
+enum LogSeverity {
+ VERBOSE,
+ DEBUG,
+ INFO,
+ WARNING,
+ ERROR,
+ FATAL_WITHOUT_ABORT,
+ FATAL,
+};
+
+enum LogId {
+ DEFAULT,
+ MAIN,
+ SYSTEM,
+};
+
+using LogFunction = std::function<void(LogId, LogSeverity, const char*, const char*,
+ unsigned int, const char*)>;
+using AbortFunction = std::function<void(const char*)>;
+
+void KernelLogger(LogId, LogSeverity, const char*, const char*, unsigned int, const char*);
+void StderrLogger(LogId, LogSeverity, const char*, const char*, unsigned int, const char*);
+
+void DefaultAborter(const char* abort_message);
+
+#ifdef __ANDROID__
+// We expose this even though it is the default because a user that wants to
+// override the default log buffer will have to construct this themselves.
+class LogdLogger {
+ public:
+ explicit LogdLogger(LogId default_log_id = android::base::MAIN);
+
+ void operator()(LogId, LogSeverity, const char* tag, const char* file,
+ unsigned int line, const char* message);
+
+ private:
+ LogId default_log_id_;
+};
+#endif
+
+// Configure logging based on ANDROID_LOG_TAGS environment variable.
+// We need to parse a string that looks like
+//
+// *:v jdwp:d dalvikvm:d dalvikvm-gc:i dalvikvmi:i
+//
+// The tag (or '*' for the global level) comes first, followed by a colon and a
+// letter indicating the minimum priority level we're expected to log. This can
+// be used to reveal or conceal logs with specific tags.
+#ifdef __ANDROID__
+#define INIT_LOGGING_DEFAULT_LOGGER LogdLogger()
+#else
+#define INIT_LOGGING_DEFAULT_LOGGER StderrLogger
+#endif
+void InitLogging(char* argv[],
+ LogFunction&& logger = INIT_LOGGING_DEFAULT_LOGGER,
+ AbortFunction&& aborter = DefaultAborter);
+#undef INIT_LOGGING_DEFAULT_LOGGER
+
+// Replace the current logger.
+void SetLogger(LogFunction&& logger);
+
+// Replace the current aborter.
+void SetAborter(AbortFunction&& aborter);
+
+class ErrnoRestorer {
+ public:
+ ErrnoRestorer()
+ : saved_errno_(errno) {
+ }
+
+ ~ErrnoRestorer() {
+ errno = saved_errno_;
+ }
+
+ // Allow this object to be used as part of && operation.
+ operator bool() const {
+ return true;
+ }
+
+ private:
+ const int saved_errno_;
+
+ DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
+};
+
+// A helper macro that produces an expression that accepts both a qualified name and an
+// unqualified name for a LogSeverity, and returns a LogSeverity value.
+// Note: DO NOT USE DIRECTLY. This is an implementation detail.
+#define SEVERITY_LAMBDA(severity) ([&]() { \
+ using ::android::base::VERBOSE; \
+ using ::android::base::DEBUG; \
+ using ::android::base::INFO; \
+ using ::android::base::WARNING; \
+ using ::android::base::ERROR; \
+ using ::android::base::FATAL_WITHOUT_ABORT; \
+ using ::android::base::FATAL; \
+ return (severity); }())
+
+// Defines whether the given severity will be logged or silently swallowed.
+#define WOULD_LOG(severity) \
+ UNLIKELY((SEVERITY_LAMBDA(severity)) >= ::android::base::GetMinimumLogSeverity())
+
+// Get an ostream that can be used for logging at the given severity and to the default
+// destination.
+//
+// Notes:
+// 1) This will not check whether the severity is high enough. One should use WOULD_LOG to filter
+// usage manually.
+// 2) This does not save and restore errno.
+#define LOG_STREAM(severity) LOG_STREAM_TO(DEFAULT, severity)
+
+// Get an ostream that can be used for logging at the given severity and to the
+// given destination. The same notes as for LOG_STREAM apply.
+#define LOG_STREAM_TO(dest, severity) \
+ ::android::base::LogMessage(__FILE__, __LINE__, \
+ ::android::base::dest, \
+ SEVERITY_LAMBDA(severity), -1).stream()
+
+// Logs a message to logcat on Android otherwise to stderr. If the severity is
+// FATAL it also causes an abort. For example:
+//
+// LOG(FATAL) << "We didn't expect to reach here";
+#define LOG(severity) LOG_TO(DEFAULT, severity)
+
+// Logs a message to logcat with the specified log ID on Android otherwise to
+// stderr. If the severity is FATAL it also causes an abort.
+// Use an if-else statement instead of just an if statement here. So if there is a
+// else statement after LOG() macro, it won't bind to the if statement in the macro.
+// do-while(0) statement doesn't work here. Because we need to support << operator
+// following the macro, like "LOG(DEBUG) << xxx;".
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/macros.h
^
|
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_MACROS_H
+#define ANDROID_BASE_MACROS_H
+
+#include <stddef.h> // for size_t
+#include <unistd.h> // for TEMP_FAILURE_RETRY
+
+// bionic and glibc both have TEMP_FAILURE_RETRY, but eg Mac OS' libc doesn't.
+#ifndef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(exp) \
+ ({ \
+ decltype(exp) _rc; \
+ do { \
+ _rc = (exp); \
+ } while (_rc == -1 && errno == EINTR); \
+ _rc; \
+ })
+#endif
+
+// A macro to disallow the copy constructor and operator= functions
+// This must be placed in the private: declarations for a class.
+//
+// For disallowing only assign or copy, delete the relevant operator or
+// constructor, for example:
+// void operator=(const TypeName&) = delete;
+// Note, that most uses of DISALLOW_ASSIGN and DISALLOW_COPY are broken
+// semantically, one should either use disallow both or neither. Try to
+// avoid these in new code.
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&) = delete; \
+ void operator=(const TypeName&) = delete
+
+// A macro to disallow all the implicit constructors, namely the
+// default constructor, copy constructor and operator= functions.
+//
+// This should be used in the private: declarations for a class
+// that wants to prevent anyone from instantiating it. This is
+// especially useful for classes containing only static methods.
+#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
+ TypeName() = delete; \
+ DISALLOW_COPY_AND_ASSIGN(TypeName)
+
+// The arraysize(arr) macro returns the # of elements in an array arr.
+// The expression is a compile-time constant, and therefore can be
+// used in defining new arrays, for example. If you use arraysize on
+// a pointer by mistake, you will get a compile-time error.
+//
+// One caveat is that arraysize() doesn't accept any array of an
+// anonymous type or a type defined inside a function. In these rare
+// cases, you have to use the unsafe ARRAYSIZE_UNSAFE() macro below. This is
+// due to a limitation in C++'s template system. The limitation might
+// eventually be removed, but it hasn't happened yet.
+
+// This template function declaration is used in defining arraysize.
+// Note that the function doesn't need an implementation, as we only
+// use its type.
+template <typename T, size_t N>
+char(&ArraySizeHelper(T(&array)[N]))[N]; // NOLINT(readability/casting)
+
+#define arraysize(array) (sizeof(ArraySizeHelper(array)))
+
+// ARRAYSIZE_UNSAFE performs essentially the same calculation as arraysize,
+// but can be used on anonymous types or types defined inside
+// functions. It's less safe than arraysize as it accepts some
+// (although not all) pointers. Therefore, you should use arraysize
+// whenever possible.
+//
+// The expression ARRAYSIZE_UNSAFE(a) is a compile-time constant of type
+// size_t.
+//
+// ARRAYSIZE_UNSAFE catches a few type errors. If you see a compiler error
+//
+// "warning: division by zero in ..."
+//
+// when using ARRAYSIZE_UNSAFE, you are (wrongfully) giving it a pointer.
+// You should only use ARRAYSIZE_UNSAFE on statically allocated arrays.
+//
+// The following comments are on the implementation details, and can
+// be ignored by the users.
+//
+// ARRAYSIZE_UNSAFE(arr) works by inspecting sizeof(arr) (the # of bytes in
+// the array) and sizeof(*(arr)) (the # of bytes in one array
+// element). If the former is divisible by the latter, perhaps arr is
+// indeed an array, in which case the division result is the # of
+// elements in the array. Otherwise, arr cannot possibly be an array,
+// and we generate a compiler error to prevent the code from
+// compiling.
+//
+// Since the size of bool is implementation-defined, we need to cast
+// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final
+// result has type size_t.
+//
+// This macro is not perfect as it wrongfully accepts certain
+// pointers, namely where the pointer size is divisible by the pointee
+// size. Since all our code has to go through a 32-bit compiler,
+// where a pointer is 4 bytes, this means all pointers to a type whose
+// size is 3 or greater than 4 will be (righteously) rejected.
+#define ARRAYSIZE_UNSAFE(a) \
+ ((sizeof(a) / sizeof(*(a))) / \
+ static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+
+// Changing this definition will cause you a lot of pain. A majority of
+// vendor code defines LIKELY and UNLIKELY this way, and includes
+// this header through an indirect path.
+#define LIKELY( exp ) (__builtin_expect( (exp) != 0, true ))
+#define UNLIKELY( exp ) (__builtin_expect( (exp) != 0, false ))
+
+#define WARN_UNUSED __attribute__((warn_unused_result))
+
+// A deprecated function to call to create a false use of the parameter, for
+// example:
+// int foo(int x) { UNUSED(x); return 10; }
+// to avoid compiler warnings. Going forward we prefer ATTRIBUTE_UNUSED.
+template <typename... T>
+void UNUSED(const T&...) {
+}
+
+// An attribute to place on a parameter to a function, for example:
+// int foo(int x ATTRIBUTE_UNUSED) { return 10; }
+// to avoid compiler warnings.
+#define ATTRIBUTE_UNUSED __attribute__((__unused__))
+
+// The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through
+// between switch labels:
+// switch (x) {
+// case 40:
+// case 41:
+// if (truth_is_out_there) {
+// ++x;
+// FALLTHROUGH_INTENDED; // Use instead of/along with annotations in
+// // comments.
+// } else {
+// return x;
+// }
+// case 42:
+// ...
+//
+// As shown in the example above, the FALLTHROUGH_INTENDED macro should be
+// followed by a semicolon. It is designed to mimic control-flow statements
+// like 'break;', so it can be placed in most places where 'break;' can, but
+// only if there are no statements on the execution path between it and the
+// next switch label.
+//
+// When compiled with clang, the FALLTHROUGH_INTENDED macro is expanded to
+// [[clang::fallthrough]] attribute, which is analysed when performing switch
+// labels fall-through diagnostic ('-Wimplicit-fallthrough'). See clang
+// documentation on language extensions for details:
+// http://clang.llvm.org/docs/LanguageExtensions.html#clang__fallthrough
+//
+// When used with unsupported compilers, the FALLTHROUGH_INTENDED macro has no
+// effect on diagnostics.
+//
+// In either case this macro has no effect on runtime behavior and performance
+// of code.
+#if defined(__clang__) && defined(__has_warning)
+#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
+#define FALLTHROUGH_INTENDED [[clang::fallthrough]] // NOLINT
+#endif
+#endif
+
+#ifndef FALLTHROUGH_INTENDED
+#define FALLTHROUGH_INTENDED \
+ do { \
+ } while (0)
+#endif
+
+#endif // ANDROID_BASE_MACROS_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/memory.h
^
|
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_MEMORY_H
+#define ANDROID_BASE_MEMORY_H
+
+namespace android {
+namespace base {
+
+// Use memcpy for access to unaligned data on targets with alignment
+// restrictions. The compiler will generate appropriate code to access these
+// structures without generating alignment exceptions.
+template <typename T>
+static inline T get_unaligned(const void* address) {
+ T result;
+ memcpy(&result, address, sizeof(T));
+ return result;
+}
+
+template <typename T>
+static inline void put_unaligned(void* address, T v) {
+ memcpy(address, &v, sizeof(T));
+}
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_MEMORY_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/parsedouble.h
^
|
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_PARSEDOUBLE_H
+#define ANDROID_BASE_PARSEDOUBLE_H
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include <limits>
+
+namespace android {
+namespace base {
+
+// Parse double value in the string 's' and sets 'out' to that value.
+// Optionally allows the caller to define a 'min' and 'max' beyond which
+// otherwise valid values will be rejected. Returns boolean success.
+static inline bool ParseDouble(const char* s, double* out,
+ double min = std::numeric_limits<double>::lowest(),
+ double max = std::numeric_limits<double>::max()) {
+ errno = 0;
+ char* end;
+ double result = strtod(s, &end);
+ if (errno != 0 || s == end || *end != '\0') {
+ return false;
+ }
+ if (result < min || max < result) {
+ return false;
+ }
+ *out = result;
+ return true;
+}
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_PARSEDOUBLE_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/parseint.h
^
|
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_PARSEINT_H
+#define ANDROID_BASE_PARSEINT_H
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include <limits>
+#include <string>
+
+namespace android {
+namespace base {
+
+// Parses the unsigned decimal integer in the string 's' and sets 'out' to
+// that value. Optionally allows the caller to define a 'max' beyond which
+// otherwise valid values will be rejected. Returns boolean success; 'out'
+// is untouched if parsing fails.
+template <typename T>
+bool ParseUint(const char* s, T* out,
+ T max = std::numeric_limits<T>::max()) {
+ int base = (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) ? 16 : 10;
+ errno = 0;
+ char* end;
+ unsigned long long int result = strtoull(s, &end, base);
+ if (errno != 0 || s == end || *end != '\0') {
+ return false;
+ }
+ if (max < result) {
+ return false;
+ }
+ *out = static_cast<T>(result);
+ return true;
+}
+
+// TODO: string_view
+template <typename T>
+bool ParseUint(const std::string& s, T* out,
+ T max = std::numeric_limits<T>::max()) {
+ return ParseUint(s.c_str(), out, max);
+}
+
+// Parses the signed decimal integer in the string 's' and sets 'out' to
+// that value. Optionally allows the caller to define a 'min' and 'max
+// beyond which otherwise valid values will be rejected. Returns boolean
+// success; 'out' is untouched if parsing fails.
+template <typename T>
+bool ParseInt(const char* s, T* out,
+ T min = std::numeric_limits<T>::min(),
+ T max = std::numeric_limits<T>::max()) {
+ int base = (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) ? 16 : 10;
+ errno = 0;
+ char* end;
+ long long int result = strtoll(s, &end, base);
+ if (errno != 0 || s == end || *end != '\0') {
+ return false;
+ }
+ if (result < min || max < result) {
+ return false;
+ }
+ *out = static_cast<T>(result);
+ return true;
+}
+
+// TODO: string_view
+template <typename T>
+bool ParseInt(const std::string& s, T* out,
+ T min = std::numeric_limits<T>::min(),
+ T max = std::numeric_limits<T>::max()) {
+ return ParseInt(s.c_str(), out, min, max);
+}
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_PARSEINT_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/parsenetaddress.h
^
|
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_PARSENETADDRESS_H
+#define ANDROID_BASE_PARSENETADDRESS_H
+
+#include <string>
+
+namespace android {
+namespace base {
+
+// Parses |address| into |host| and |port|.
+//
+// If |address| doesn't contain a port number, the default value is taken from
+// |port|. If |canonical_address| is non-null it will be set to "host:port" or
+// "[host]:port" as appropriate.
+//
+// On failure, returns false and fills |error|.
+bool ParseNetAddress(const std::string& address, std::string* host, int* port,
+ std::string* canonical_address, std::string* error);
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_PARSENETADDRESS_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/properties.h
^
|
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_PROPERTIES_H
+#define ANDROID_BASE_PROPERTIES_H
+
+#include <sys/cdefs.h>
+
+#if !defined(__BIONIC__)
+#error Only bionic supports system properties.
+#endif
+
+#include <chrono>
+#include <limits>
+#include <string>
+
+namespace android {
+namespace base {
+
+// Returns the current value of the system property `key`,
+// or `default_value` if the property is empty or doesn't exist.
+std::string GetProperty(const std::string& key, const std::string& default_value);
+
+// Returns true if the system property `key` has the value "1", "y", "yes", "on", or "true",
+// false for "0", "n", "no", "off", or "false", or `default_value` otherwise.
+bool GetBoolProperty(const std::string& key, bool default_value);
+
+// Returns the signed integer corresponding to the system property `key`.
+// If the property is empty, doesn't exist, doesn't have an integer value, or is outside
+// the optional bounds, returns `default_value`.
+template <typename T> T GetIntProperty(const std::string& key,
+ T default_value,
+ T min = std::numeric_limits<T>::min(),
+ T max = std::numeric_limits<T>::max());
+
+// Returns the unsigned integer corresponding to the system property `key`.
+// If the property is empty, doesn't exist, doesn't have an integer value, or is outside
+// the optional bound, returns `default_value`.
+template <typename T> T GetUintProperty(const std::string& key,
+ T default_value,
+ T max = std::numeric_limits<T>::max());
+
+// Sets the system property `key` to `value`.
+// Note that system property setting is inherently asynchronous so a return value of `true`
+// isn't particularly meaningful, and immediately reading back the value won't necessarily
+// tell you whether or not your call succeeded. A `false` return value definitely means failure.
+bool SetProperty(const std::string& key, const std::string& value);
+
+// Waits for the system property `key` to have the value `expected_value`.
+// Times out after `relative_timeout`.
+// Returns true on success, false on timeout.
+bool WaitForProperty(const std::string& key,
+ const std::string& expected_value,
+ std::chrono::milliseconds relative_timeout);
+
+// Waits for the system property `key` to be created.
+// Times out after `relative_timeout`.
+// Returns true on success, false on timeout.
+bool WaitForPropertyCreation(const std::string& key,
+ std::chrono::milliseconds relative_timeout);
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_PROPERTIES_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/quick_exit.h
^
|
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <stdlib.h>
+
+// Provide emulation for at_quick_exit/quick_exit on platforms that don't have it.
+namespace android {
+namespace base {
+
+// Bionic and glibc have quick_exit, Darwin and Windows don't.
+#if !defined(__linux__)
+ void quick_exit(int exit_code) __attribute__((noreturn));
+ int at_quick_exit(void (*func)());
+#else
+ using ::at_quick_exit;
+ using ::quick_exit;
+#endif
+}
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/scopeguard.h
^
|
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef ANDROID_BASE_SCOPEGUARD_H
+#define ANDROID_BASE_SCOPEGUARD_H
+#include <utility> // for std::move
+namespace android {
+namespace base {
+template <typename F>
+class ScopeGuard {
+ public:
+ ScopeGuard(F f) : f_(f), active_(true) {}
+ ScopeGuard(ScopeGuard&& that) : f_(std::move(that.f_)), active_(that.active_) {
+ that.active_ = false;
+ }
+ ~ScopeGuard() {
+ if (active_) f_();
+ }
+ ScopeGuard() = delete;
+ ScopeGuard(const ScopeGuard&) = delete;
+ void operator=(const ScopeGuard&) = delete;
+ void operator=(ScopeGuard&& that) = delete;
+ void Disable() { active_ = false; }
+ bool active() const { return active_; }
+ private:
+ F f_;
+ bool active_;
+};
+template <typename T>
+ScopeGuard<T> make_scope_guard(T f) {
+ return ScopeGuard<T>(f);
+}
+} // namespace base
+} // namespace android
+#endif // ANDROID_BASE_SCOPEGUARD_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/stringprintf.h
^
|
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_STRINGPRINTF_H
+#define ANDROID_BASE_STRINGPRINTF_H
+
+#include <stdarg.h>
+#include <string>
+
+namespace android {
+namespace base {
+
+// These printf-like functions are implemented in terms of vsnprintf, so they
+// use the same attribute for compile-time format string checking. On Windows,
+// if the mingw version of vsnprintf is used, use `gnu_printf' which allows z
+// in %zd and PRIu64 (and related) to be recognized by the compile-time
+// checking.
+#define FORMAT_ARCHETYPE __printf__
+#ifdef __USE_MINGW_ANSI_STDIO
+#if __USE_MINGW_ANSI_STDIO
+#undef FORMAT_ARCHETYPE
+#define FORMAT_ARCHETYPE gnu_printf
+#endif
+#endif
+
+// Returns a string corresponding to printf-like formatting of the arguments.
+std::string StringPrintf(const char* fmt, ...)
+ __attribute__((__format__(FORMAT_ARCHETYPE, 1, 2)));
+
+// Appends a printf-like formatting of the arguments to 'dst'.
+void StringAppendF(std::string* dst, const char* fmt, ...)
+ __attribute__((__format__(FORMAT_ARCHETYPE, 2, 3)));
+
+// Appends a printf-like formatting of the arguments to 'dst'.
+void StringAppendV(std::string* dst, const char* format, va_list ap)
+ __attribute__((__format__(FORMAT_ARCHETYPE, 2, 0)));
+
+#undef FORMAT_ARCHETYPE
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_STRINGPRINTF_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/strings.h
^
|
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_STRINGS_H
+#define ANDROID_BASE_STRINGS_H
+
+#include <sstream>
+#include <string>
+#include <vector>
+
+namespace android {
+namespace base {
+
+// Splits a string into a vector of strings.
+//
+// The string is split at each occurrence of a character in delimiters.
+//
+// The empty string is not a valid delimiter list.
+std::vector<std::string> Split(const std::string& s,
+ const std::string& delimiters);
+
+// Trims whitespace off both ends of the given string.
+std::string Trim(const std::string& s);
+
+// Joins a container of things into a single string, using the given separator.
+template <typename ContainerT, typename SeparatorT>
+std::string Join(const ContainerT& things, SeparatorT separator) {
+ if (things.empty()) {
+ return "";
+ }
+
+ std::ostringstream result;
+ result << *things.begin();
+ for (auto it = std::next(things.begin()); it != things.end(); ++it) {
+ result << separator << *it;
+ }
+ return result.str();
+}
+
+// We instantiate the common cases in strings.cpp.
+extern template std::string Join(const std::vector<std::string>&, char);
+extern template std::string Join(const std::vector<const char*>&, char);
+extern template std::string Join(const std::vector<std::string>&, const std::string&);
+extern template std::string Join(const std::vector<const char*>&, const std::string&);
+
+// Tests whether 's' starts with 'prefix'.
+bool StartsWith(const std::string& s, const char* prefix);
+bool StartsWithIgnoreCase(const std::string& s, const char* prefix);
+
+// Tests whether 's' ends with 'suffix'.
+bool EndsWith(const std::string& s, const char* suffix);
+bool EndsWithIgnoreCase(const std::string& s, const char* suffix);
+
+// Tests whether 'lhs' equals 'rhs', ignoring case.
+bool EqualsIgnoreCase(const std::string& lhs, const std::string& rhs);
+
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_STRINGS_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/test_utils.h
^
|
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_TEST_UTILS_H
+#define ANDROID_BASE_TEST_UTILS_H
+
+#include <string>
+
+#include <android-base/macros.h>
+
+class TemporaryFile {
+ public:
+ TemporaryFile();
+ ~TemporaryFile();
+
+ int fd;
+ char path[1024];
+
+ private:
+ void init(const std::string& tmp_dir);
+
+ DISALLOW_COPY_AND_ASSIGN(TemporaryFile);
+};
+
+class TemporaryDir {
+ public:
+ TemporaryDir();
+ ~TemporaryDir();
+
+ char path[1024];
+
+ private:
+ bool init(const std::string& tmp_dir);
+
+ DISALLOW_COPY_AND_ASSIGN(TemporaryDir);
+};
+
+class CapturedStderr {
+ public:
+ CapturedStderr();
+ ~CapturedStderr();
+
+ int fd() const;
+
+ private:
+ void init();
+ void reset();
+
+ TemporaryFile temp_file_;
+ int old_stderr_;
+
+ DISALLOW_COPY_AND_ASSIGN(CapturedStderr);
+};
+
+#endif // ANDROID_BASE_TEST_UTILS_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/thread_annotations.h
^
|
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_THREAD_ANNOTATIONS_H
+#define ANDROID_BASE_THREAD_ANNOTATIONS_H
+
+#if defined(__SUPPORT_TS_ANNOTATION__) || defined(__clang__)
+#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
+#else
+#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
+#endif
+
+#define CAPABILITY(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
+
+#define SCOPED_CAPABILITY \
+ THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
+
+#define SHARED_CAPABILITY(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(shared_capability(__VA_ARGS__))
+
+#define GUARDED_BY(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
+
+#define PT_GUARDED_BY(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
+
+#define ACQUIRED_BEFORE(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
+
+#define ACQUIRED_AFTER(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
+
+#define REQUIRES(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
+
+#define REQUIRES_SHARED(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
+
+#define ACQUIRE(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
+
+#define ACQUIRE_SHARED(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
+
+#define RELEASE(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
+
+#define RELEASE_SHARED(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
+
+#define TRY_ACQUIRE(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
+
+#define TRY_ACQUIRE_SHARED(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
+
+#define EXCLUDES(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
+
+#define ASSERT_CAPABILITY(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
+
+#define ASSERT_SHARED_CAPABILITY(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
+
+#define RETURN_CAPABILITY(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
+
+#define EXCLUSIVE_LOCK_FUNCTION(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__))
+
+#define EXCLUSIVE_TRYLOCK_FUNCTION(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__))
+
+#define SHARED_LOCK_FUNCTION(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__))
+
+#define SHARED_TRYLOCK_FUNCTION(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__))
+
+#define UNLOCK_FUNCTION(...) \
+ THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__))
+
+#define SCOPED_LOCKABLE \
+ THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
+
+#define LOCK_RETURNED(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
+
+#define NO_THREAD_SAFETY_ANALYSIS \
+ THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
+
+#endif // ANDROID_BASE_THREAD_ANNOTATIONS_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/unique_fd.h
^
|
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_UNIQUE_FD_H
+#define ANDROID_BASE_UNIQUE_FD_H
+
+#include <unistd.h>
+
+// DO NOT INCLUDE OTHER LIBBASE HEADERS!
+// This file gets used in libbinder, and libbinder is used everywhere.
+// Including other headers from libbase frequently results in inclusion of
+// android-base/macros.h, which causes macro collisions.
+
+// Container for a file descriptor that automatically closes the descriptor as
+// it goes out of scope.
+//
+// unique_fd ufd(open("/some/path", "r"));
+// if (ufd.get() == -1) return error;
+//
+// // Do something useful, possibly including 'return'.
+//
+// return 0; // Descriptor is closed for you.
+//
+// unique_fd is also known as ScopedFd/ScopedFD/scoped_fd; mentioned here to help
+// you find this class if you're searching for one of those names.
+namespace android {
+namespace base {
+
+struct DefaultCloser {
+ static void Close(int fd) {
+ // Even if close(2) fails with EINTR, the fd will have been closed.
+ // Using TEMP_FAILURE_RETRY will either lead to EBADF or closing someone
+ // else's fd.
+ // http://lkml.indiana.edu/hypermail/linux/kernel/0509.1/0877.html
+ ::close(fd);
+ }
+};
+
+template <typename Closer>
+class unique_fd_impl final {
+ public:
+ unique_fd_impl() : value_(-1) {}
+
+ explicit unique_fd_impl(int value) : value_(value) {}
+ ~unique_fd_impl() { reset(); }
+
+ unique_fd_impl(unique_fd_impl&& other) : value_(other.release()) {}
+ unique_fd_impl& operator=(unique_fd_impl&& s) {
+ reset(s.release());
+ return *this;
+ }
+
+ void reset(int new_value = -1) {
+ if (value_ != -1) {
+ Closer::Close(value_);
+ }
+ value_ = new_value;
+ }
+
+ int get() const { return value_; }
+ operator int() const { return get(); }
+
+ int release() __attribute__((warn_unused_result)) {
+ int ret = value_;
+ value_ = -1;
+ return ret;
+ }
+
+ private:
+ int value_;
+
+ unique_fd_impl(const unique_fd_impl&);
+ void operator=(const unique_fd_impl&);
+};
+
+using unique_fd = unique_fd_impl<DefaultCloser>;
+
+} // namespace base
+} // namespace android
+
+template <typename T>
+int close(const android::base::unique_fd_impl<T>&)
+#if defined(__clang__)
+ __attribute__((__unavailable__(
+#else
+ __attribute__((__error__(
+#endif
+ "close called on unique_fd"
+ )));
+
+#endif // ANDROID_BASE_UNIQUE_FD_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android-base/utf8.h
^
|
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_BASE_UTF8_H
+#define ANDROID_BASE_UTF8_H
+
+#ifdef _WIN32
+#include <string>
+#else
+// Bring in prototypes for standard APIs so that we can import them into the utf8 namespace.
+#include <fcntl.h> // open
+#include <unistd.h> // unlink
+#endif
+
+namespace android {
+namespace base {
+
+// Only available on Windows because this is only needed on Windows.
+#ifdef _WIN32
+// Convert size number of UTF-16 wchar_t's to UTF-8. Returns whether the
+// conversion was done successfully.
+bool WideToUTF8(const wchar_t* utf16, const size_t size, std::string* utf8);
+
+// Convert a NULL-terminated string of UTF-16 characters to UTF-8. Returns
+// whether the conversion was done successfully.
+bool WideToUTF8(const wchar_t* utf16, std::string* utf8);
+
+// Convert a UTF-16 std::wstring (including any embedded NULL characters) to
+// UTF-8. Returns whether the conversion was done successfully.
+bool WideToUTF8(const std::wstring& utf16, std::string* utf8);
+
+// Convert size number of UTF-8 char's to UTF-16. Returns whether the conversion
+// was done successfully.
+bool UTF8ToWide(const char* utf8, const size_t size, std::wstring* utf16);
+
+// Convert a NULL-terminated string of UTF-8 characters to UTF-16. Returns
+// whether the conversion was done successfully.
+bool UTF8ToWide(const char* utf8, std::wstring* utf16);
+
+// Convert a UTF-8 std::string (including any embedded NULL characters) to
+// UTF-16. Returns whether the conversion was done successfully.
+bool UTF8ToWide(const std::string& utf8, std::wstring* utf16);
+#endif
+
+// The functions in the utf8 namespace take UTF-8 strings. For Windows, these
+// are wrappers, for non-Windows these just expose existing APIs. To call these
+// functions, use:
+//
+// // anonymous namespace to avoid conflict with existing open(), unlink(), etc.
+// namespace {
+// // Import functions into anonymous namespace.
+// using namespace android::base::utf8;
+//
+// void SomeFunction(const char* name) {
+// int fd = open(name, ...); // Calls android::base::utf8::open().
+// ...
+// unlink(name); // Calls android::base::utf8::unlink().
+// }
+// }
+namespace utf8 {
+
+#ifdef _WIN32
+int open(const char* name, int flags, ...);
+int unlink(const char* name);
+#else
+using ::open;
+using ::unlink;
+#endif
+
+} // namespace utf8
+} // namespace base
+} // namespace android
+
+#endif // ANDROID_BASE_UTF8_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android/api-level.h
^
|
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef ANDROID_API_LEVEL_H
+#define ANDROID_API_LEVEL_H
+
+#include <sys/cdefs.h>
+
+/*
+ * Magic version number for a current development build, which has
+ * not yet turned into an official release.
+ */
+#ifndef __ANDROID_API_FUTURE__
+#define __ANDROID_API_FUTURE__ 10000
+#endif
+
+#ifndef __ANDROID_API__
+#define __ANDROID_API__ __ANDROID_API_FUTURE__
+#endif
+
+#define __ANDROID_API_G__ 9
+#define __ANDROID_API_I__ 14
+#define __ANDROID_API_J__ 16
+#define __ANDROID_API_J_MR1__ 17
+#define __ANDROID_API_J_MR2__ 18
+#define __ANDROID_API_K__ 19
+#define __ANDROID_API_L__ 21
+#define __ANDROID_API_L_MR1__ 22
+#define __ANDROID_API_M__ 23
+#define __ANDROID_API_N__ 24
+#define __ANDROID_API_N_MR1__ 25
+#define __ANDROID_API_O__ 26
+#define __ANDROID_API_O_MR1__ 27
+
+#endif /* ANDROID_API_LEVEL_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android/dlext.h
^
|
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ANDROID_DLEXT_H__
+#define __ANDROID_DLEXT_H__
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h> /* for off64_t */
+
+__BEGIN_DECLS
+
+/* bitfield definitions for android_dlextinfo.flags */
+enum {
+ /* When set, the reserved_addr and reserved_size fields must point to an
+ * already-reserved region of address space which will be used to load the
+ * library if it fits. If the reserved region is not large enough, the load
+ * will fail.
+ */
+ ANDROID_DLEXT_RESERVED_ADDRESS = 0x1,
+
+ /* As DLEXT_RESERVED_ADDRESS, but if the reserved region is not large enough,
+ * the linker will choose an available address instead.
+ */
+ ANDROID_DLEXT_RESERVED_ADDRESS_HINT = 0x2,
+
+ /* When set, write the GNU RELRO section of the mapped library to relro_fd
+ * after relocation has been performed, to allow it to be reused by another
+ * process loading the same library at the same address. This implies
+ * ANDROID_DLEXT_USE_RELRO.
+ */
+ ANDROID_DLEXT_WRITE_RELRO = 0x4,
+
+ /* When set, compare the GNU RELRO section of the mapped library to relro_fd
+ * after relocation has been performed, and replace any relocated pages that
+ * are identical with a version mapped from the file.
+ */
+ ANDROID_DLEXT_USE_RELRO = 0x8,
+
+ /* Instruct dlopen to use library_fd instead of opening file by name.
+ * The filename parameter is still used to identify the library.
+ */
+ ANDROID_DLEXT_USE_LIBRARY_FD = 0x10,
+
+ /* If opening a library using library_fd read it starting at library_fd_offset.
+ * This flag is only valid when ANDROID_DLEXT_USE_LIBRARY_FD is set.
+ */
+ ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET = 0x20,
+
+ /* When set, do not check if the library has already been loaded by file stat(2)s.
+ *
+ * This flag allows forced loading of the library in the case when for some
+ * reason multiple ELF files share the same filename (because the already-loaded
+ * library has been removed and overwritten, for example).
+ *
+ * Note that if the library has the same dt_soname as an old one and some other
+ * library has the soname in DT_NEEDED list, the first one will be used to resolve any
+ * dependencies.
+ */
+ ANDROID_DLEXT_FORCE_LOAD = 0x40,
+
+ /* When set, if the minimum p_vaddr of the ELF file's PT_LOAD segments is non-zero,
+ * the dynamic linker will load it at that address.
+ *
+ * This flag is for ART internal use only.
+ */
+ ANDROID_DLEXT_FORCE_FIXED_VADDR = 0x80,
+
+ /* Instructs dlopen to load the library at the address specified by reserved_addr.
+ *
+ * The difference between ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS and ANDROID_DLEXT_RESERVED_ADDRESS
+ * is that for ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS the linker reserves memory at reserved_addr
+ * whereas for ANDROID_DLEXT_RESERVED_ADDRESS the linker relies on the caller to reserve the memory.
+ *
+ * This flag can be used with ANDROID_DLEXT_FORCE_FIXED_VADDR; when ANDROID_DLEXT_FORCE_FIXED_VADDR
+ * is set and load_bias is not 0 (load_bias is min(p_vaddr) of PT_LOAD segments) this flag is ignored.
+ * This is implemented this way because the linker has to pick one address over the other and this
+ * way is more convenient for art. Note that ANDROID_DLEXT_FORCE_FIXED_VADDR does not generate
+ * an error when min(p_vaddr) is 0.
+ *
+ * Cannot be used with ANDROID_DLEXT_RESERVED_ADDRESS or ANDROID_DLEXT_RESERVED_ADDRESS_HINT.
+ *
+ * This flag is for ART internal use only.
+ */
+ ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS = 0x100,
+
+ /* This flag used to load library in a different namespace. The namespace is
+ * specified in library_namespace.
+ */
+ ANDROID_DLEXT_USE_NAMESPACE = 0x200,
+
+ /* Mask of valid bits */
+ ANDROID_DLEXT_VALID_FLAG_BITS = ANDROID_DLEXT_RESERVED_ADDRESS |
+ ANDROID_DLEXT_RESERVED_ADDRESS_HINT |
+ ANDROID_DLEXT_WRITE_RELRO |
+ ANDROID_DLEXT_USE_RELRO |
+ ANDROID_DLEXT_USE_LIBRARY_FD |
+ ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET |
+ ANDROID_DLEXT_FORCE_LOAD |
+ ANDROID_DLEXT_FORCE_FIXED_VADDR |
+ ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS |
+ ANDROID_DLEXT_USE_NAMESPACE,
+};
+
+struct android_namespace_t;
+
+typedef struct {
+ uint64_t flags;
+ void* reserved_addr;
+ size_t reserved_size;
+ int relro_fd;
+ int library_fd;
+ off64_t library_fd_offset;
+ struct android_namespace_t* library_namespace;
+} android_dlextinfo;
+
+void* android_dlopen_ext(const char* filename, int flag, const android_dlextinfo* extinfo);
+
+__END_DECLS
+
+#endif /* __ANDROID_DLEXT_H__ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/android/versioning.h
^
|
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_VERSIONING_H
+#define ANDROID_VERSIONING_H
+
+#define __INTRODUCED_IN(api_level) __attribute__((annotate("introduced_in=" #api_level)))
+#define __INTRODUCED_IN_FUTURE __attribute__((annotate("introduced_in_future")))
+#define __DEPRECATED_IN(api_level) __attribute__((annotate("deprecated_in=" #api_level)))
+#define __REMOVED_IN(api_level) __attribute__((annotate("obsoleted_in=" #api_level)))
+#define __INTRODUCED_IN_32(api_level) __attribute__((annotate("introduced_in_32=" #api_level)))
+#define __INTRODUCED_IN_64(api_level) __attribute__((annotate("introduced_in_64=" #api_level)))
+#define __INTRODUCED_IN_ARM(api_level) __attribute__((annotate("introduced_in_arm=" #api_level)))
+#define __INTRODUCED_IN_X86(api_level) __attribute__((annotate("introduced_in_x86=" #api_level)))
+#define __INTRODUCED_IN_MIPS(api_level) __attribute__((annotate("introduced_in_mips=" #api_level)))
+
+#define __VERSIONER_NO_GUARD __attribute__((annotate("versioner_no_guard")))
+
+#endif /* ANDROID_VERSIONING_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/dlfcn.h
^
|
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __DLFCN_H__
+#define __DLFCN_H__
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+#if defined(__cplusplus)
+#define __BIONIC_CAST(_k,_t,_v) (_k<_t>(_v))
+#else
+#define __BIONIC_CAST(_k,_t,_v) ((_t) (_v))
+#endif
+
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+#endif
+
+typedef struct {
+ /* Pathname of shared object that contains address. */
+ const char* dli_fname;
+ /* Address at which shared object is loaded. */
+ void* dli_fbase;
+ /* Name of nearest symbol with address lower than addr. */
+ const char* dli_sname;
+ /* Exact address of symbol named in dli_sname. */
+ void* dli_saddr;
+} Dl_info;
+
+void* dlopen(const char* filename, int flag);
+int dlclose(void* handle) __nonnull((1));
+char* dlerror(void);
+void* dlsym(void* handle, const char* symbol) __nonnull((2));
+void* dlvsym(void* handle, const char* symbol, const char* version) __nonnull((2, 3));
+int dladdr(const void* addr, Dl_info* info) __nonnull((2));
+
+#define RTLD_LOCAL 0
+#define RTLD_LAZY 0x00001
+#define RTLD_NOW 0x00002
+#define RTLD_NOLOAD 0x00004
+#define RTLD_GLOBAL 0x00100
+#define RTLD_NODELETE 0x01000
+
+#if !defined(__LP64__)
+/* LP32 is broken for historical reasons. */
+#undef RTLD_NOW
+#define RTLD_NOW 0x00000
+#undef RTLD_GLOBAL
+#define RTLD_GLOBAL 0x00002
+#endif
+
+#if defined (__LP64__)
+#define RTLD_DEFAULT __BIONIC_CAST(reinterpret_cast, void*, 0)
+#define RTLD_NEXT __BIONIC_CAST(reinterpret_cast, void*, -1L)
+#else
+#define RTLD_DEFAULT __BIONIC_CAST(reinterpret_cast, void*, 0xffffffff)
+#define RTLD_NEXT __BIONIC_CAST(reinterpret_cast, void*, 0xfffffffe)
+#endif
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
+__END_DECLS
+
+#endif /* __DLFCN_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/link.h
^
|
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _LINK_H_
+#define _LINK_H_
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <elf.h>
+
+__BEGIN_DECLS
+
+#if defined(__LP64__)
+#define ElfW(type) Elf64_ ## type
+#else
+#define ElfW(type) Elf32_ ## type
+#endif
+
+struct dl_phdr_info {
+ ElfW(Addr) dlpi_addr;
+ const char* dlpi_name;
+ const ElfW(Phdr)* dlpi_phdr;
+ ElfW(Half) dlpi_phnum;
+};
+
+#if defined(__arm__)
+int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*);
+#else
+int dl_iterate_phdr(int (*)(struct dl_phdr_info*, size_t, void*), void*);
+#endif
+
+#ifdef __arm__
+typedef uintptr_t _Unwind_Ptr;
+_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr, int*);
+#endif
+
+/* Used by the dynamic linker to communicate with the debugger. */
+struct link_map {
+ ElfW(Addr) l_addr;
+ char* l_name;
+ ElfW(Dyn)* l_ld;
+ struct link_map* l_next;
+ struct link_map* l_prev;
+};
+
+/* Used by the dynamic linker to communicate with the debugger. */
+struct r_debug {
+ int32_t r_version;
+ struct link_map* r_map;
+ ElfW(Addr) r_brk;
+ enum {
+ RT_CONSISTENT,
+ RT_ADD,
+ RT_DELETE
+ } r_state;
+ ElfW(Addr) r_ldbase;
+};
+
+__END_DECLS
+
+#endif /* _LINK_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/stdatomic.h
^
|
@@ -0,0 +1,546 @@
+/*-
+ * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
+ * David Chisnall <theraven@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _STDATOMIC_H_
+#define _STDATOMIC_H_
+
+#include <sys/cdefs.h>
+
+#if defined(__cplusplus) && __cplusplus >= 201103L && defined(_USING_LIBCXX)
+# ifdef __clang__
+# if __has_feature(cxx_atomic)
+# define _STDATOMIC_HAVE_ATOMIC
+# endif
+# else /* gcc */
+# define _STDATOMIC_HAVE_ATOMIC
+# endif
+#endif
+
+#ifdef _STDATOMIC_HAVE_ATOMIC
+
+/* We have a usable C++ <atomic>; use it instead. */
+
+#include <atomic>
+
+#undef _Atomic
+ /* Also defined by <atomic> for gcc. But not used in macros. */
+ /* Also a clang intrinsic. */
+ /* Should not be used by client code before this file is */
+ /* included. The definitions in <atomic> themselves see */
+ /* the old definition, as they should. */
+ /* Client code sees the following definition. */
+
+#define _Atomic(t) std::atomic<t>
+
+using std::atomic_is_lock_free;
+using std::atomic_init;
+using std::atomic_store;
+using std::atomic_store_explicit;
+using std::atomic_load;
+using std::atomic_load_explicit;
+using std::atomic_exchange;
+using std::atomic_exchange_explicit;
+using std::atomic_compare_exchange_strong;
+using std::atomic_compare_exchange_strong_explicit;
+using std::atomic_compare_exchange_weak;
+using std::atomic_compare_exchange_weak_explicit;
+using std::atomic_fetch_add;
+using std::atomic_fetch_add_explicit;
+using std::atomic_fetch_sub;
+using std::atomic_fetch_sub_explicit;
+using std::atomic_fetch_or;
+using std::atomic_fetch_or_explicit;
+using std::atomic_fetch_xor;
+using std::atomic_fetch_xor_explicit;
+using std::atomic_fetch_and;
+using std::atomic_fetch_and_explicit;
+using std::atomic_thread_fence;
+using std::atomic_signal_fence;
+
+using std::memory_order;
+using std::memory_order_relaxed;
+using std::memory_order_consume;
+using std::memory_order_acquire;
+using std::memory_order_release;
+using std::memory_order_acq_rel;
+using std::memory_order_seq_cst;
+
+using std::atomic_bool;
+using std::atomic_char;
+using std::atomic_schar;
+using std::atomic_uchar;
+using std::atomic_short;
+using std::atomic_ushort;
+using std::atomic_int;
+using std::atomic_uint;
+using std::atomic_long;
+using std::atomic_ulong;
+using std::atomic_llong;
+using std::atomic_ullong;
+using std::atomic_char16_t;
+using std::atomic_char32_t;
+using std::atomic_wchar_t;
+using std::atomic_int_least8_t;
+using std::atomic_uint_least8_t;
+using std::atomic_int_least16_t;
+using std::atomic_uint_least16_t;
+using std::atomic_int_least32_t;
+using std::atomic_uint_least32_t;
+using std::atomic_int_least64_t;
+using std::atomic_uint_least64_t;
+using std::atomic_int_fast8_t;
+using std::atomic_uint_fast8_t;
+using std::atomic_int_fast16_t;
+using std::atomic_uint_fast16_t;
+using std::atomic_int_fast32_t;
+using std::atomic_uint_fast32_t;
+using std::atomic_int_fast64_t;
+using std::atomic_uint_fast64_t;
+using std::atomic_intptr_t;
+using std::atomic_uintptr_t;
+using std::atomic_size_t;
+using std::atomic_ptrdiff_t;
+using std::atomic_intmax_t;
+using std::atomic_uintmax_t;
+
+#else /* <atomic> unavailable, possibly because this is C, not C++ */
+
+#include <sys/types.h>
+#include <stdbool.h>
+
+/*
+ * C: Do it ourselves.
+ * Note that the runtime representation defined here should be compatible
+ * with the C++ one, i.e. an _Atomic(T) needs to contain the same
+ * bits as a T.
+ */
+
+#include <stddef.h> /* For ptrdiff_t. */
+#include <stdint.h> /* TODO: don't drag in all the macros, just the types. */
+// Include uchar.h only when needed. Bionic's stdatomic.h is also used for the
+// host (via a copy in prebuilts/clang) and uchar.h is not available in the
+// glibc used for the host.
+#if __STDC_VERSION__ >= 201112L
+# include <uchar.h> /* For char16_t and char32_t. */
+#endif
+
+
+#ifdef __clang__
+# if __has_extension(c_atomic) || __has_extension(cxx_atomic)
+# define __CLANG_ATOMICS
+# else
+# error "stdatomic.h does not support your compiler"
+# endif
+# if __has_builtin(__sync_swap)
+# define __HAS_BUILTIN_SYNC_SWAP
+# endif
+#else
+# define __GNUC_ATOMICS
+#endif
+
+/*
+ * 7.17.1 Atomic lock-free macros.
+ */
+
+#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE
+#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE
+#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE
+#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE
+#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE
+#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE
+#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_INT_LOCK_FREE
+#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_LONG_LOCK_FREE
+#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE
+#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
+#endif
+#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE
+#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/sys/_system_properties.h
^
|
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _INCLUDE_SYS__SYSTEM_PROPERTIES_H
+#define _INCLUDE_SYS__SYSTEM_PROPERTIES_H
+
+#include <sys/cdefs.h>
+#include <stdint.h>
+
+#ifndef _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
+#error you should #include <sys/system_properties.h> instead
+#endif
+
+#include <sys/system_properties.h>
+
+__BEGIN_DECLS
+
+#define PROP_SERVICE_NAME "property_service"
+#define PROP_FILENAME "/dev/__properties__"
+
+#define PROP_MSG_SETPROP 1
+#define PROP_MSG_SETPROP2 0x00020001
+
+#define PROP_SUCCESS 0
+#define PROP_ERROR_READ_CMD 0x0004
+#define PROP_ERROR_READ_DATA 0x0008
+#define PROP_ERROR_READ_ONLY_PROPERTY 0x000B
+#define PROP_ERROR_INVALID_NAME 0x0010
+#define PROP_ERROR_INVALID_VALUE 0x0014
+#define PROP_ERROR_PERMISSION_DENIED 0x0018
+#define PROP_ERROR_INVALID_CMD 0x001B
+#define PROP_ERROR_HANDLE_CONTROL_MESSAGE 0x0020
+#define PROP_ERROR_SET_FAILED 0x0024
+
+/*
+** Map the property area from the specified filename. This
+** method is for testing only.
+*/
+int __system_property_set_filename(const char *filename);
+
+/*
+** Initialize the area to be used to store properties. Can
+** only be done by a single process that has write access to
+** the property area.
+*/
+int __system_property_area_init();
+
+/* Read the global serial number of the system properties
+**
+** Called to predict if a series of cached __system_property_find
+** objects will have seen __system_property_serial values change.
+** But also aids the converse, as changes in the global serial can
+** also be used to predict if a failed __system_property_find
+** could in-turn now find a new object; thus preventing the
+** cycles of effort to poll __system_property_find.
+**
+** Typically called at beginning of a cache cycle to signal if _any_ possible
+** changes have occurred since last. If there is, one may check each individual
+** __system_property_serial to confirm dirty, or __system_property_find
+** to check if the property now exists. If a call to __system_property_add
+** or __system_property_update has completed between two calls to
+** __system_property_area_serial then the second call will return a larger
+** value than the first call. Beware of race conditions as changes to the
+** properties are not atomic, the main value of this call is to determine
+** whether the expensive __system_property_find is worth retrying to see if
+** a property now exists.
+**
+** Returns the serial number on success, -1 on error.
+*/
+uint32_t __system_property_area_serial();
+
+/* Add a new system property. Can only be done by a single
+** process that has write access to the property area, and
+** that process must handle sequencing to ensure the property
+** does not already exist and that only one property is added
+** or updated at a time.
+**
+** Returns 0 on success, -1 if the property area is full.
+*/
+int __system_property_add(const char *name, unsigned int namelen, const char *value, unsigned int valuelen);
+
+/* Update the value of a system property returned by
+** __system_property_find. Can only be done by a single process
+** that has write access to the property area, and that process
+** must handle sequencing to ensure that only one property is
+** updated at a time.
+**
+** Returns 0 on success, -1 if the parameters are incorrect.
+*/
+int __system_property_update(prop_info *pi, const char *value, unsigned int len);
+
+/* Read the serial number of a system property returned by
+** __system_property_find.
+**
+** Returns the serial number on success, -1 on error.
+*/
+uint32_t __system_property_serial(const prop_info* pi);
+
+/* Initialize the system properties area in read only mode.
+ * Should be done by all processes that need to read system
+ * properties.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+int __system_properties_init();
+
+/* Deprecated: use __system_property_wait instead. */
+uint32_t __system_property_wait_any(uint32_t old_serial);
+
+__END_DECLS
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/include/sys/system_properties.h
^
|
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _INCLUDE_SYS_SYSTEM_PROPERTIES_H
+#define _INCLUDE_SYS_SYSTEM_PROPERTIES_H
+
+#include <sys/cdefs.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+__BEGIN_DECLS
+
+typedef struct prop_info prop_info;
+
+#define PROP_VALUE_MAX 92
+
+/*
+ * Sets system property `key` to `value`, creating the system property if it doesn't already exist.
+ */
+int __system_property_set(const char* key, const char* value);
+
+/*
+ * Returns a `prop_info` corresponding system property `name`, or nullptr if it doesn't exist.
+ * Use __system_property_read_callback to query the current value.
+ *
+ * Property lookup is expensive, so it can be useful to cache the result of this function.
+ */
+const prop_info* __system_property_find(const char* name);
+
+/*
+ * Calls `callback` with a consistent trio of name, value, and serial number for property `pi`.
+ */
+void __system_property_read_callback(const prop_info *pi,
+ void (*callback)(void* cookie, const char *name, const char *value, uint32_t serial),
+ void* cookie);
+
+/*
+ * Passes a `prop_info` for each system property to the provided
+ * callback. Use __system_property_read_callback() to read the value.
+ *
+ * This method is for inspecting and debugging the property system, and not generally useful.
+ */
+int __system_property_foreach(void (*propfn)(const prop_info* pi, void* cookie), void* cookie);
+
+/*
+ * Waits for the specific system property identified by `pi` to be updated
+ * past `old_serial`. Waits no longer than `relative_timeout`, or forever
+ * if `relaive_timeout` is null.
+ *
+ * If `pi` is null, waits for the global serial number instead.
+ *
+ * If you don't know the current serial, use 0.
+ *
+ * Returns true and updates `*new_serial_ptr` on success, or false if the call
+ * timed out.
+ */
+struct timespec;
+bool __system_property_wait(const prop_info* pi,
+ uint32_t old_serial,
+ uint32_t* new_serial_ptr,
+ const struct timespec* relative_timeout);
+
+/* Deprecated. In Android O and above, there's no limit on property name length. */
+#define PROP_NAME_MAX 32
+/* Deprecated. Use __system_property_read_callback instead. */
+int __system_property_read(const prop_info* pi, char* name, char* value);
+/* Deprecated. Use __system_property_read_callback instead. */
+int __system_property_get(const char* name, char* value);
+/* Deprecated. Use __system_property_foreach instead. */
+const prop_info* __system_property_find_nth(unsigned n);
+
+__END_DECLS
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/CFIShadow.h
^
|
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CFI_SHADOW_H
+#define CFI_SHADOW_H
+
+#include <stdint.h>
+
+#include "private/bionic_page.h"
+#include "private/bionic_macros.h"
+
+constexpr unsigned kLibraryAlignmentBits = 18;
+constexpr size_t kLibraryAlignment = 1UL << kLibraryAlignmentBits;
+
+// This class defines format of the shadow region for Control Flow Integrity support.
+// See documentation in http://clang.llvm.org/docs/ControlFlowIntegrityDesign.html#shared-library-support.
+//
+// CFI shadow is effectively a very fast and specialized implementation of dladdr: given an address that
+// belongs to a shared library or an executable, it can find the address of a specific export in that
+// library (a function called "__cfi_check"). This is only guaranteed to work for
+// addresses of possible CFI targets inside a library: indirectly called functions and virtual
+// tables. A random address inside a library may not work in the future (but it does in the current
+// implementation).
+//
+// Implementation is a sparse array of uint16_t where each element describes the location of
+// __cfi_check for a 2**kShadowGranularity range of memory. Array elements (called "shadow values"
+// below) are interpreted as follows.
+//
+// For an address P and corresponding shadow value V, the address of __cfi_check is calculated as
+// align_up(P, 2**kShadowGranularity) - (V - 2) * (2 ** kCfiCheckGranularity)
+//
+// Special shadow values:
+// 0 = kInvalidShadow, this memory range has no valid CFI targets.
+// 1 = kUncheckedShadow, any address is this memory range is a valid CFI target
+//
+// Loader requirement: each aligned 2**kShadowGranularity region of address space may contain at
+// most one DSO.
+// Compiler requirement: __cfi_check is aligned at kCfiCheckGranularity.
+// Compiler requirement: __cfi_check for a given DSO is located below any CFI target for that DSO.
+class CFIShadow {
+ public:
+ static constexpr uintptr_t kShadowGranularity = kLibraryAlignmentBits;
+ static constexpr uintptr_t kCfiCheckGranularity = 12;
+
+ // Each uint16_t element of the shadow corresponds to this much application memory.
+ static constexpr uintptr_t kShadowAlign = 1UL << kShadowGranularity;
+
+ // Alignment of __cfi_check.
+ static constexpr uintptr_t kCfiCheckAlign = 1UL << kCfiCheckGranularity; // 4K
+
+#if defined (__LP64__)
+ static constexpr uintptr_t kMaxTargetAddr = 0xffffffffffff;
+#else
+ static constexpr uintptr_t kMaxTargetAddr = 0xffffffff;
+#endif
+
+ // Shadow is 2 -> 2**kShadowGranularity.
+ static constexpr uintptr_t kShadowSize =
+ align_up((kMaxTargetAddr >> (kShadowGranularity - 1)), PAGE_SIZE);
+
+ // Returns offset inside the shadow region for an address.
+ static constexpr uintptr_t MemToShadowOffset(uintptr_t x) {
+ return (x >> kShadowGranularity) << 1;
+ }
+
+ typedef int (*CFICheckFn)(uint64_t, void *, void *);
+
+ public:
+ enum ShadowValues : uint16_t {
+ kInvalidShadow = 0, // Not a valid CFI target.
+ kUncheckedShadow = 1, // Unchecked, valid CFI target.
+ kRegularShadowMin = 2 // This and all higher values encode a negative offset to __cfi_check in
+ // the units of kCfiCheckGranularity, starting with 0 at
+ // kRegularShadowMin.
+ };
+};
+
+#endif // CFI_SHADOW_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/ErrnoRestorer.h
^
|
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ERRNO_RESTORER_H
+#define ERRNO_RESTORER_H
+
+#include <errno.h>
+
+#include "bionic_macros.h"
+
+class ErrnoRestorer {
+ public:
+ explicit ErrnoRestorer() : saved_errno_(errno) {
+ }
+
+ ~ErrnoRestorer() {
+ errno = saved_errno_;
+ }
+
+ void override(int new_errno) {
+ saved_errno_ = new_errno;
+ }
+
+ private:
+ int saved_errno_;
+
+ DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
+};
+
+#endif // ERRNO_RESTORER_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/KernelArgumentBlock.h
^
|
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef KERNEL_ARGUMENT_BLOCK_H
+#define KERNEL_ARGUMENT_BLOCK_H
+
+#include <elf.h>
+#include <link.h>
+#include <stdint.h>
+#include <sys/auxv.h>
+
+#include "private/bionic_macros.h"
+
+struct abort_msg_t;
+
+// When the kernel starts the dynamic linker, it passes a pointer to a block
+// of memory containing argc, the argv array, the environment variable array,
+// and the array of ELF aux vectors. This class breaks that block up into its
+// constituents for easy access.
+class KernelArgumentBlock {
+ public:
+ KernelArgumentBlock(void* raw_args) {
+ uintptr_t* args = reinterpret_cast<uintptr_t*>(raw_args);
+ argc = static_cast<int>(*args);
+ argv = reinterpret_cast<char**>(args + 1);
+ envp = argv + argc + 1;
+
+ // Skip over all environment variable definitions to find the aux vector.
+ // The end of the environment block is marked by a NULL pointer.
+ char** p = envp;
+ while (*p != NULL) {
+ ++p;
+ }
+ ++p; // Skip the NULL itself.
+
+ auxv = reinterpret_cast<ElfW(auxv_t)*>(p);
+ }
+
+ // Similar to ::getauxval but doesn't require the libc global variables to be set up,
+ // so it's safe to call this really early on.
+ unsigned long getauxval(unsigned long type) {
+ for (ElfW(auxv_t)* v = auxv; v->a_type != AT_NULL; ++v) {
+ if (v->a_type == type) {
+ return v->a_un.a_val;
+ }
+ }
+ return 0;
+ }
+
+ int argc;
+ char** argv;
+ char** envp;
+ ElfW(auxv_t)* auxv;
+
+ abort_msg_t** abort_message_ptr;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(KernelArgumentBlock);
+};
+
+#endif // KERNEL_ARGUMENT_BLOCK_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/NetdClientDispatch.h
^
|
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PRIVATE_NETD_CLIENT_DISPATCH_H
+#define PRIVATE_NETD_CLIENT_DISPATCH_H
+
+#include <sys/cdefs.h>
+#include <sys/socket.h>
+
+__BEGIN_DECLS
+
+struct NetdClientDispatch {
+ int (*accept4)(int, struct sockaddr*, socklen_t*, int);
+ int (*connect)(int, const struct sockaddr*, socklen_t);
+ int (*socket)(int, int, int);
+ unsigned (*netIdForResolv)(unsigned);
+};
+
+extern __LIBC_HIDDEN__ struct NetdClientDispatch __netdClientDispatch;
+
+__END_DECLS
+
+#endif // PRIVATE_NETD_CLIENT_DISPATCH_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/ScopedPthreadMutexLocker.h
^
|
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SCOPED_PTHREAD_MUTEX_LOCKER_H
+#define SCOPED_PTHREAD_MUTEX_LOCKER_H
+
+#include <pthread.h>
+
+#include "bionic_macros.h"
+
+class ScopedPthreadMutexLocker {
+ public:
+ explicit ScopedPthreadMutexLocker(pthread_mutex_t* mu) : mu_(mu) {
+ pthread_mutex_lock(mu_);
+ }
+
+ ~ScopedPthreadMutexLocker() {
+ pthread_mutex_unlock(mu_);
+ }
+
+ private:
+ pthread_mutex_t* mu_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedPthreadMutexLocker);
+};
+
+#endif // SCOPED_PTHREAD_MUTEX_LOCKER_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/ScopedReaddir.h
^
|
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SCOPED_READDIR_H
+#define SCOPED_READDIR_H
+
+#include <dirent.h>
+
+#include "private/bionic_macros.h"
+
+class ScopedReaddir {
+ public:
+ ScopedReaddir(const char* path) : ScopedReaddir(opendir(path)) {
+ }
+
+ ScopedReaddir(DIR* dir) {
+ dir_ = dir;
+ }
+
+ ~ScopedReaddir() {
+ if (dir_ != NULL) {
+ closedir(dir_);
+ }
+ }
+
+ bool IsBad() {
+ return dir_ == NULL;
+ }
+
+ dirent* ReadEntry() {
+ return readdir(dir_);
+ }
+
+ private:
+ DIR* dir_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedReaddir);
+};
+
+#endif // SCOPED_READDIR_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/WriteProtected.h
^
|
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _PRIVATE_WRITEPROTECTED_H
+#define _PRIVATE_WRITEPROTECTED_H
+
+#include <errno.h>
+#include <string.h>
+#include <sys/cdefs.h>
+#include <sys/mman.h>
+#include <sys/user.h>
+
+#include <async_safe/log.h>
+
+#include "private/bionic_macros.h"
+#include "private/bionic_prctl.h"
+
+template <typename T>
+union WriteProtectedContents {
+ T value;
+ char padding[PAGE_SIZE];
+
+ WriteProtectedContents() = default;
+ DISALLOW_COPY_AND_ASSIGN(WriteProtectedContents);
+} __attribute__((aligned(PAGE_SIZE)));
+
+// Write protected wrapper class that aligns its contents to a page boundary,
+// and sets the memory protection to be non-writable, except when being modified
+// explicitly.
+template <typename T>
+class WriteProtected {
+ static_assert(sizeof(T) < PAGE_SIZE,
+ "WriteProtected only supports contents up to PAGE_SIZE");
+ static_assert(__is_pod(T), "WriteProtected only supports POD contents");
+
+ WriteProtectedContents<T> contents;
+
+ public:
+ WriteProtected() = default;
+ DISALLOW_COPY_AND_ASSIGN(WriteProtected);
+
+ void initialize() {
+ // Not strictly necessary, but this will hopefully segfault if we initialize
+ // multiple times by accident.
+ memset(&contents, 0, sizeof(contents));
+
+ if (mprotect(&contents, PAGE_SIZE, PROT_READ)) {
+ async_safe_fatal("failed to make WriteProtected nonwritable in initialize");
+ }
+ }
+
+ const T* operator->() {
+ return &contents.value;
+ }
+
+ const T& operator*() {
+ return contents.value;
+ }
+
+ template <typename Mutator>
+ void mutate(Mutator mutator) {
+ if (mprotect(&contents, PAGE_SIZE, PROT_READ | PROT_WRITE) != 0) {
+ async_safe_fatal("failed to make WriteProtected writable in mutate: %s",
+ strerror(errno));
+ }
+ mutator(&contents.value);
+ if (mprotect(&contents, PAGE_SIZE, PROT_READ) != 0) {
+ async_safe_fatal("failed to make WriteProtected nonwritable in mutate: %s",
+ strerror(errno));
+ }
+ }
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/__get_tls.h
^
|
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __BIONIC_PRIVATE_GET_TLS_H_
+#define __BIONIC_PRIVATE_GET_TLS_H_
+
+#if defined(__aarch64__)
+# define __get_tls() ({ void** __val; __asm__("mrs %0, tpidr_el0" : "=r"(__val)); __val; })
+#elif defined(__arm__)
+# define __get_tls() ({ void** __val; __asm__("mrc p15, 0, %0, c13, c0, 3" : "=r"(__val)); __val; })
+#elif defined(__mips__)
+# define __get_tls() \
+ /* On mips32r1, this goes via a kernel illegal instruction trap that's optimized for v1. */ \
+ ({ register void** __val asm("v1"); \
+ __asm__(".set push\n" \
+ ".set mips32r2\n" \
+ "rdhwr %0,$29\n" \
+ ".set pop\n" : "=r"(__val)); \
+ __val; })
+#elif defined(__i386__)
+# define __get_tls() ({ void** __val; __asm__("movl %%gs:0, %0" : "=r"(__val)); __val; })
+#elif defined(__x86_64__)
+# define __get_tls() ({ void** __val; __asm__("mov %%fs:0, %0" : "=r"(__val)); __val; })
+#else
+#error unsupported architecture
+#endif
+
+#endif /* __BIONIC_PRIVATE_GET_TLS_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_arc4random.h
^
|
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PRIVATE_BIONIC_ARC4RANDOM_H_
+#define _PRIVATE_BIONIC_ARC4RANDOM_H_
+
+#include <stddef.h>
+
+#include "private/KernelArgumentBlock.h"
+
+/*
+ * arc4random aborts if it's unable to fetch entropy, which is always the case
+ * for init on devices without getrandom(2), since /dev/random hasn't been
+ * created yet. Provide a wrapper function that falls back to AT_RANDOM if
+ * we don't have getrandom and /dev/urandom is missing.
+ */
+void __libc_safe_arc4random_buf(void* buf, size_t n, KernelArgumentBlock& args);
+
+/*
+ * Return true if libc has an unlimited entropy source (something other than
+ * AT_RANDOM), and arc4random* calls will always succeed.
+ */
+bool __libc_arc4random_has_unlimited_entropy();
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_asm.h
^
|
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PRIVATE_BIONIC_ASM_H_
+#define _PRIVATE_BIONIC_ASM_H_
+
+#include <asm/unistd.h> /* For system call numbers. */
+#define MAX_ERRNO 4095 /* For recognizing system call error returns. */
+
+#define __bionic_asm_custom_entry(f)
+#define __bionic_asm_custom_end(f)
+#define __bionic_asm_function_type @function
+
+#include <machine/asm.h>
+
+#define ENTRY_NO_DWARF(f) \
+ .text; \
+ .globl f; \
+ .balign __bionic_asm_align; \
+ .type f, __bionic_asm_function_type; \
+ f: \
+ __bionic_asm_custom_entry(f); \
+
+#define ENTRY(f) \
+ ENTRY_NO_DWARF(f) \
+ .cfi_startproc \
+
+#define END_NO_DWARF(f) \
+ .size f, .-f; \
+ __bionic_asm_custom_end(f) \
+
+#define END(f) \
+ .cfi_endproc; \
+ END_NO_DWARF(f) \
+
+/* Like ENTRY, but with hidden visibility. */
+#define ENTRY_PRIVATE(f) \
+ ENTRY(f); \
+ .hidden f \
+
+/* Like ENTRY_NO_DWARF, but with hidden visibility. */
+#define ENTRY_PRIVATE_NO_DWARF(f) \
+ ENTRY_NO_DWARF(f); \
+ .hidden f \
+
+#define ALIAS_SYMBOL(alias, original) \
+ .globl alias; \
+ .equ alias, original
+
+#endif /* _PRIVATE_BIONIC_ASM_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_auxv.h
^
|
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _PRIVATE_BIONIC_AUXV_H_
+#define _PRIVATE_BIONIC_AUXV_H_
+
+#include <elf.h>
+#include <link.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+extern ElfW(auxv_t)* __libc_auxv;
+
+__END_DECLS
+
+#endif /* _PRIVATE_BIONIC_AUXV_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_config.h
^
|
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_CONFIG_H_
+#define _BIONIC_CONFIG_H_
+
+// valloc(3) and pvalloc(3) were removed from POSIX 2004. We do not include them
+// for LP64, but the symbols remain in LP32 for binary compatibility.
+#if !defined(__LP64__)
+#define HAVE_DEPRECATED_MALLOC_FUNCS 1
+#endif
+
+#endif // _BIONIC_CONFIG_H_
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_constants.h
^
|
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_CONSTANTS_H_
+#define _BIONIC_CONSTANTS_H_
+
+#define NS_PER_S 1000000000
+
+#endif // _BIONIC_CONSTANTS_H_
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_errdefs.h
^
|
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* the following corresponds to the error codes of the Linux kernel used by the Android platform
+ * these are distinct from the OpenBSD ones, which is why we need to redeclare them here
+ *
+ * this file may be included several times to define either error constants or their
+ * string representation
+ */
+
+#ifndef __BIONIC_ERRDEF
+#error "__BIONIC_ERRDEF must be defined before including this file"
+#endif
+__BIONIC_ERRDEF( 0 , 0, "Success" )
+__BIONIC_ERRDEF( EPERM , 1, "Operation not permitted" )
+__BIONIC_ERRDEF( ENOENT , 2, "No such file or directory" )
+__BIONIC_ERRDEF( ESRCH , 3, "No such process" )
+__BIONIC_ERRDEF( EINTR , 4, "Interrupted system call" )
+__BIONIC_ERRDEF( EIO , 5, "I/O error" )
+__BIONIC_ERRDEF( ENXIO , 6, "No such device or address" )
+__BIONIC_ERRDEF( E2BIG , 7, "Argument list too long" )
+__BIONIC_ERRDEF( ENOEXEC , 8, "Exec format error" )
+__BIONIC_ERRDEF( EBADF , 9, "Bad file descriptor" )
+__BIONIC_ERRDEF( ECHILD , 10, "No child processes" )
+__BIONIC_ERRDEF( EAGAIN , 11, "Try again" )
+__BIONIC_ERRDEF( ENOMEM , 12, "Out of memory" )
+__BIONIC_ERRDEF( EACCES , 13, "Permission denied" )
+__BIONIC_ERRDEF( EFAULT , 14, "Bad address" )
+__BIONIC_ERRDEF( ENOTBLK , 15, "Block device required" )
+__BIONIC_ERRDEF( EBUSY , 16, "Device or resource busy" )
+__BIONIC_ERRDEF( EEXIST , 17, "File exists" )
+__BIONIC_ERRDEF( EXDEV , 18, "Cross-device link" )
+__BIONIC_ERRDEF( ENODEV , 19, "No such device" )
+__BIONIC_ERRDEF( ENOTDIR , 20, "Not a directory" )
+__BIONIC_ERRDEF( EISDIR , 21, "Is a directory" )
+__BIONIC_ERRDEF( EINVAL , 22, "Invalid argument" )
+__BIONIC_ERRDEF( ENFILE , 23, "File table overflow" )
+__BIONIC_ERRDEF( EMFILE , 24, "Too many open files" )
+__BIONIC_ERRDEF( ENOTTY , 25, "Not a typewriter" )
+__BIONIC_ERRDEF( ETXTBSY , 26, "Text file busy" )
+__BIONIC_ERRDEF( EFBIG , 27, "File too large" )
+__BIONIC_ERRDEF( ENOSPC , 28, "No space left on device" )
+__BIONIC_ERRDEF( ESPIPE , 29, "Illegal seek" )
+__BIONIC_ERRDEF( EROFS , 30, "Read-only file system" )
+__BIONIC_ERRDEF( EMLINK , 31, "Too many links" )
+__BIONIC_ERRDEF( EPIPE , 32, "Broken pipe" )
+__BIONIC_ERRDEF( EDOM , 33, "Math argument out of domain of func" )
+__BIONIC_ERRDEF( ERANGE , 34, "Math result not representable" )
+__BIONIC_ERRDEF( EDEADLK , 35, "Resource deadlock would occur" )
+__BIONIC_ERRDEF( ENAMETOOLONG , 36, "File name too long" )
+__BIONIC_ERRDEF( ENOLCK , 37, "No record locks available" )
+__BIONIC_ERRDEF( ENOSYS , 38, "Function not implemented" )
+__BIONIC_ERRDEF( ENOTEMPTY , 39, "Directory not empty" )
+__BIONIC_ERRDEF( ELOOP , 40, "Too many symbolic links encountered" )
+__BIONIC_ERRDEF( ENOMSG , 42, "No message of desired type" )
+__BIONIC_ERRDEF( EIDRM , 43, "Identifier removed" )
+__BIONIC_ERRDEF( ECHRNG , 44, "Channel number out of range" )
+__BIONIC_ERRDEF( EL2NSYNC , 45, "Level 2 not synchronized" )
+__BIONIC_ERRDEF( EL3HLT , 46, "Level 3 halted" )
+__BIONIC_ERRDEF( EL3RST , 47, "Level 3 reset" )
+__BIONIC_ERRDEF( ELNRNG , 48, "Link number out of range" )
+__BIONIC_ERRDEF( EUNATCH , 49, "Protocol driver not attached" )
+__BIONIC_ERRDEF( ENOCSI , 50, "No CSI structure available" )
+__BIONIC_ERRDEF( EL2HLT , 51, "Level 2 halted" )
+__BIONIC_ERRDEF( EBADE , 52, "Invalid exchange" )
+__BIONIC_ERRDEF( EBADR , 53, "Invalid request descriptor" )
+__BIONIC_ERRDEF( EXFULL , 54, "Exchange full" )
+__BIONIC_ERRDEF( ENOANO , 55, "No anode" )
+__BIONIC_ERRDEF( EBADRQC , 56, "Invalid request code" )
+__BIONIC_ERRDEF( EBADSLT , 57, "Invalid slot" )
+__BIONIC_ERRDEF( EBFONT , 59, "Bad font file format" )
+__BIONIC_ERRDEF( ENOSTR , 60, "Device not a stream" )
+__BIONIC_ERRDEF( ENODATA , 61, "No data available" )
+__BIONIC_ERRDEF( ETIME , 62, "Timer expired" )
+__BIONIC_ERRDEF( ENOSR , 63, "Out of streams resources" )
+__BIONIC_ERRDEF( ENONET , 64, "Machine is not on the network" )
+__BIONIC_ERRDEF( ENOPKG , 65, "Package not installed" )
+__BIONIC_ERRDEF( EREMOTE , 66, "Object is remote" )
+__BIONIC_ERRDEF( ENOLINK , 67, "Link has been severed" )
+__BIONIC_ERRDEF( EADV , 68, "Advertise error" )
+__BIONIC_ERRDEF( ESRMNT , 69, "Srmount error" )
+__BIONIC_ERRDEF( ECOMM , 70, "Communication error on send" )
+__BIONIC_ERRDEF( EPROTO , 71, "Protocol error" )
+__BIONIC_ERRDEF( EMULTIHOP , 72, "Multihop attempted" )
+__BIONIC_ERRDEF( EDOTDOT , 73, "RFS specific error" )
+__BIONIC_ERRDEF( EBADMSG , 74, "Not a data message" )
+__BIONIC_ERRDEF( EOVERFLOW , 75, "Value too large for defined data type" )
+__BIONIC_ERRDEF( ENOTUNIQ , 76, "Name not unique on network" )
+__BIONIC_ERRDEF( EBADFD , 77, "File descriptor in bad state" )
+__BIONIC_ERRDEF( EREMCHG , 78, "Remote address changed" )
+__BIONIC_ERRDEF( ELIBACC , 79, "Can not access a needed shared library" )
+__BIONIC_ERRDEF( ELIBBAD , 80, "Accessing a corrupted shared library" )
+__BIONIC_ERRDEF( ELIBSCN , 81, ".lib section in a.out corrupted" )
+__BIONIC_ERRDEF( ELIBMAX , 82, "Attempting to link in too many shared libraries" )
+__BIONIC_ERRDEF( ELIBEXEC , 83, "Cannot exec a shared library directly" )
+__BIONIC_ERRDEF( EILSEQ , 84, "Illegal byte sequence" )
+__BIONIC_ERRDEF( ERESTART , 85, "Interrupted system call should be restarted" )
+__BIONIC_ERRDEF( ESTRPIPE , 86, "Streams pipe error" )
+__BIONIC_ERRDEF( EUSERS , 87, "Too many users" )
+__BIONIC_ERRDEF( ENOTSOCK , 88, "Socket operation on non-socket" )
+__BIONIC_ERRDEF( EDESTADDRREQ , 89, "Destination address required" )
+__BIONIC_ERRDEF( EMSGSIZE , 90, "Message too long" )
+__BIONIC_ERRDEF( EPROTOTYPE , 91, "Protocol wrong type for socket" )
+__BIONIC_ERRDEF( ENOPROTOOPT , 92, "Protocol not available" )
+__BIONIC_ERRDEF( EPROTONOSUPPORT, 93, "Protocol not supported" )
+__BIONIC_ERRDEF( ESOCKTNOSUPPORT, 94, "Socket type not supported" )
+__BIONIC_ERRDEF( EOPNOTSUPP , 95, "Operation not supported on transport endpoint" )
+__BIONIC_ERRDEF( EPFNOSUPPORT , 96, "Protocol family not supported" )
+__BIONIC_ERRDEF( EAFNOSUPPORT , 97, "Address family not supported by protocol" )
+__BIONIC_ERRDEF( EADDRINUSE , 98, "Address already in use" )
+__BIONIC_ERRDEF( EADDRNOTAVAIL , 99, "Cannot assign requested address" )
+__BIONIC_ERRDEF( ENETDOWN , 100, "Network is down" )
+__BIONIC_ERRDEF( ENETUNREACH , 101, "Network is unreachable" )
+__BIONIC_ERRDEF( ENETRESET , 102, "Network dropped connection because of reset" )
+__BIONIC_ERRDEF( ECONNABORTED , 103, "Software caused connection abort" )
+__BIONIC_ERRDEF( ECONNRESET , 104, "Connection reset by peer" )
+__BIONIC_ERRDEF( ENOBUFS , 105, "No buffer space available" )
+__BIONIC_ERRDEF( EISCONN , 106, "Transport endpoint is already connected" )
+__BIONIC_ERRDEF( ENOTCONN , 107, "Transport endpoint is not connected" )
+__BIONIC_ERRDEF( ESHUTDOWN , 108, "Cannot send after transport endpoint shutdown" )
+__BIONIC_ERRDEF( ETOOMANYREFS , 109, "Too many references: cannot splice" )
+__BIONIC_ERRDEF( ETIMEDOUT , 110, "Connection timed out" )
+__BIONIC_ERRDEF( ECONNREFUSED , 111, "Connection refused" )
+__BIONIC_ERRDEF( EHOSTDOWN , 112, "Host is down" )
+__BIONIC_ERRDEF( EHOSTUNREACH , 113, "No route to host" )
+__BIONIC_ERRDEF( EALREADY , 114, "Operation already in progress" )
+__BIONIC_ERRDEF( EINPROGRESS , 115, "Operation now in progress" )
+__BIONIC_ERRDEF( ESTALE , 116, "Stale NFS file handle" )
+__BIONIC_ERRDEF( EUCLEAN , 117, "Structure needs cleaning" )
+__BIONIC_ERRDEF( ENOTNAM , 118, "Not a XENIX named type file" )
+__BIONIC_ERRDEF( ENAVAIL , 119, "No XENIX semaphores available" )
+__BIONIC_ERRDEF( EISNAM , 120, "Is a named type file" )
+__BIONIC_ERRDEF( EREMOTEIO , 121, "Remote I/O error" )
+__BIONIC_ERRDEF( EDQUOT , 122, "Quota exceeded" )
+__BIONIC_ERRDEF( ENOMEDIUM , 123, "No medium found" )
+__BIONIC_ERRDEF( EMEDIUMTYPE , 124, "Wrong medium type" )
+__BIONIC_ERRDEF( ECANCELED , 125, "Operation Canceled" )
+__BIONIC_ERRDEF( ENOKEY , 126, "Required key not available" )
+__BIONIC_ERRDEF( EKEYEXPIRED , 127, "Key has expired" )
+__BIONIC_ERRDEF( EKEYREVOKED , 128, "Key has been revoked" )
+__BIONIC_ERRDEF( EKEYREJECTED , 129, "Key was rejected by service" )
+__BIONIC_ERRDEF( EOWNERDEAD , 130, "Owner died" )
+__BIONIC_ERRDEF( ENOTRECOVERABLE, 131, "State not recoverable" )
+
+#undef __BIONIC_ERRDEF
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_fortify.h
^
|
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <poll.h> // For struct pollfd.
+#include <stdarg.h>
+#include <stdlib.h>
+#include <sys/select.h> // For struct fd_set.
+
+#include <async_safe/log.h>
+
+static inline __noreturn void __fortify_fatal(const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ async_safe_fatal_va_list("FORTIFY", fmt, args);
+ va_end(args);
+ abort();
+}
+
+//
+// Common helpers.
+//
+
+static inline void __check_fd_set(const char* fn, int fd, size_t set_size) {
+ if (__predict_false(fd < 0)) {
+ __fortify_fatal("%s: file descriptor %d < 0", fn, fd);
+ }
+ if (__predict_false(fd >= FD_SETSIZE)) {
+ __fortify_fatal("%s: file descriptor %d >= FD_SETSIZE %zu", fn, fd, set_size);
+ }
+ if (__predict_false(set_size < sizeof(fd_set))) {
+ __fortify_fatal("%s: set size %zu is too small to be an fd_set", fn, set_size);
+ }
+}
+
+static inline void __check_pollfd_array(const char* fn, size_t fds_size, nfds_t fd_count) {
+ size_t pollfd_array_length = fds_size / sizeof(pollfd);
+ if (__predict_false(pollfd_array_length < fd_count)) {
+ __fortify_fatal("%s: %zu-element pollfd array too small for %u fds",
+ fn, pollfd_array_length, fd_count);
+ }
+}
+
+static inline void __check_count(const char* fn, const char* identifier, size_t value) {
+ if (__predict_false(value > SSIZE_MAX)) {
+ __fortify_fatal("%s: %s %zu > SSIZE_MAX", fn, identifier, value);
+ }
+}
+
+static inline void __check_buffer_access(const char* fn, const char* action,
+ size_t claim, size_t actual) {
+ if (__predict_false(claim > actual)) {
+ __fortify_fatal("%s: prevented %zu-byte %s %zu-byte buffer", fn, claim, action, actual);
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_futex.h
^
|
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _BIONIC_FUTEX_H
+#define _BIONIC_FUTEX_H
+
+#include <errno.h>
+#include <linux/futex.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <sys/cdefs.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+__BEGIN_DECLS
+
+struct timespec;
+
+static inline int __futex(volatile void* ftx, int op, int value,
+ const struct timespec* timeout,
+ int bitset) {
+ // Our generated syscall assembler sets errno, but our callers (pthread functions) don't want to.
+ int saved_errno = errno;
+ int result = syscall(__NR_futex, ftx, op, value, timeout, NULL, bitset);
+ if (result == -1) {
+ result = -errno;
+ errno = saved_errno;
+ }
+ return result;
+}
+
+static inline int __futex_wake(volatile void* ftx, int count) {
+ return __futex(ftx, FUTEX_WAKE, count, NULL, 0);
+}
+
+static inline int __futex_wake_ex(volatile void* ftx, bool shared, int count) {
+ return __futex(ftx, shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, count, NULL, 0);
+}
+
+static inline int __futex_wait(volatile void* ftx, int value, const struct timespec* timeout) {
+ return __futex(ftx, FUTEX_WAIT, value, timeout, 0);
+}
+
+static inline int __futex_wait_ex(volatile void* ftx, bool shared, int value,
+ bool use_realtime_clock, const struct timespec* abs_timeout) {
+ return __futex(ftx, (shared ? FUTEX_WAIT_BITSET : FUTEX_WAIT_BITSET_PRIVATE) |
+ (use_realtime_clock ? FUTEX_CLOCK_REALTIME : 0), value, abs_timeout,
+ FUTEX_BITSET_MATCH_ANY);
+}
+
+__END_DECLS
+
+#endif /* _BIONIC_FUTEX_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_globals.h
^
|
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PRIVATE_BIONIC_GLOBALS_H
+#define _PRIVATE_BIONIC_GLOBALS_H
+
+#include <sys/cdefs.h>
+
+#include "private/bionic_malloc_dispatch.h"
+#include "private/bionic_vdso.h"
+#include "private/WriteProtected.h"
+
+struct libc_globals {
+ vdso_entry vdso[VDSO_END];
+ long setjmp_cookie;
+ MallocDispatch malloc_dispatch;
+};
+
+extern WriteProtected<libc_globals> __libc_globals;
+
+class KernelArgumentBlock;
+void __libc_init_malloc(libc_globals* globals);
+void __libc_init_setjmp_cookie(libc_globals* globals, KernelArgumentBlock& args);
+void __libc_init_vdso(libc_globals* globals, KernelArgumentBlock& args);
+
+#if defined(__i386__)
+extern void* __libc_sysinfo;
+void __libc_init_sysinfo(KernelArgumentBlock& args);
+#endif
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_ieee.h
^
|
@@ -0,0 +1,118 @@
+/* $OpenBSD: ieee.h,v 1.4 2011/11/08 17:06:51 deraadt Exp $ */
+/* $NetBSD: ieee.h,v 1.2 2001/02/21 17:43:50 bjh21 Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ieee.h 8.1 (Berkeley) 6/11/93
+ */
+
+#ifndef _MACHINE_IEEE_H_
+#define _MACHINE_IEEE_H_
+
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+#define SNG_EXPBITS 8
+#define SNG_FRACBITS 23
+
+#define SNG_EXP_INFNAN 255
+#define SNG_EXP_BIAS 127
+
+struct ieee_single {
+ unsigned sng_frac:23;
+ unsigned sng_exp:8;
+ unsigned sng_sign:1;
+};
+
+#define DBL_EXPBITS 11
+#define DBL_FRACHBITS 20
+#define DBL_FRACLBITS 32
+#define DBL_FRACBITS 52
+
+#define DBL_EXP_INFNAN 2047
+#define DBL_EXP_BIAS 1023
+
+struct ieee_double {
+ unsigned dbl_fracl;
+ unsigned dbl_frach:20;
+ unsigned dbl_exp:11;
+ unsigned dbl_sign:1;
+};
+
+#if defined(__LP64__)
+
+/* 64-bit Android uses ld128 long doubles. */
+
+#define EXT_EXPBITS 15
+#define EXT_FRACHBITS 16
+#define EXT_FRACHMBITS 32
+#define EXT_FRACLMBITS 32
+#define EXT_FRACLBITS 32
+#define EXT_FRACBITS 112
+
+#define EXT_EXP_INFNAN 32767
+#define EXT_EXP_BIAS 16383
+
+#define EXT_IMPLICIT_NBIT
+
+#define EXT_TO_ARRAY32(p, a) do { \
+ (a)[0] = (uint32_t)(p)->ext_fracl; \
+ (a)[1] = (uint32_t)(p)->ext_fraclm; \
+ (a)[2] = (uint32_t)(p)->ext_frachm; \
+ (a)[3] = (uint32_t)(p)->ext_frach; \
+} while(0)
+
+struct ieee_ext {
+ unsigned ext_fracl;
+ unsigned ext_fraclm;
+ unsigned ext_frachm;
+ unsigned ext_frach:16;
+ unsigned ext_exp:15;
+ unsigned ext_sign:1;
+};
+
+#endif
+
+__END_DECLS
+
+#endif /* _MACHINE_IEEE_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_lock.h
^
|
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _BIONIC_LOCK_H
+#define _BIONIC_LOCK_H
+
+#include <stdatomic.h>
+#include "private/bionic_futex.h"
+#include "private/bionic_macros.h"
+
+// Lock is used in places like pthread_rwlock_t, which can be initialized without calling
+// an initialization function. So make sure Lock can be initialized by setting its memory to 0.
+class Lock {
+ private:
+ enum LockState {
+ Unlocked = 0,
+ LockedWithoutWaiter,
+ LockedWithWaiter,
+ };
+ _Atomic(LockState) state;
+ bool process_shared;
+
+ public:
+ void init(bool process_shared) {
+ atomic_init(&state, Unlocked);
+ this->process_shared = process_shared;
+ }
+
+ bool trylock() {
+ LockState old_state = Unlocked;
+ return atomic_compare_exchange_strong_explicit(&state, &old_state,
+ LockedWithoutWaiter, memory_order_acquire, memory_order_relaxed);
+ }
+
+ void lock() {
+ LockState old_state = Unlocked;
+ if (atomic_compare_exchange_strong_explicit(&state, &old_state,
+ LockedWithoutWaiter, memory_order_acquire, memory_order_relaxed)) {
+ return;
+ }
+ while (atomic_exchange_explicit(&state, LockedWithWaiter, memory_order_acquire) != Unlocked) {
+ // TODO: As the critical section is brief, it is a better choice to spin a few times befor sleeping.
+ __futex_wait_ex(&state, process_shared, LockedWithWaiter, false, nullptr);
+ }
+ return;
+ }
+
+ void unlock() {
+ if (atomic_exchange_explicit(&state, Unlocked, memory_order_release) == LockedWithWaiter) {
+ __futex_wake_ex(&state, process_shared, 1);
+ }
+ }
+};
+
+#endif // _BIONIC_LOCK_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_macros.h
^
|
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_MACROS_H_
+#define _BIONIC_MACROS_H_
+
+#include <stdint.h>
+
+// Frameworks OpenGL code currently leaks this header and allows
+// collisions with other declarations, e.g., from libnativehelper.
+// TODO: Remove once cleaned up. b/18334516
+#if !defined(DISALLOW_COPY_AND_ASSIGN)
+// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions.
+// It goes in the private: declarations in a class.
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&) = delete; \
+ void operator=(const TypeName&) = delete
+#endif // !defined(DISALLOW_COPY_AND_ASSIGN)
+
+// A macro to disallow all the implicit constructors, namely the
+// default constructor, copy constructor and operator= functions.
+//
+// This should be used in the private: declarations for a class
+// that wants to prevent anyone from instantiating it. This is
+// especially useful for classes containing only static methods.
+#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
+ TypeName() = delete; \
+ DISALLOW_COPY_AND_ASSIGN(TypeName)
+
+#define BIONIC_ALIGN(value, alignment) \
+ (((value) + (alignment) - 1) & ~((alignment) - 1))
+
+#define BIONIC_ROUND_UP_POWER_OF_2(value) \
+ ((sizeof(value) == 8) \
+ ? (1UL << (64 - __builtin_clzl(static_cast<unsigned long>(value)))) \
+ : (1UL << (32 - __builtin_clz(static_cast<unsigned int>(value)))))
+
+static constexpr uintptr_t align_down(uintptr_t p, size_t align) {
+ return p & ~(align - 1);
+}
+
+static constexpr uintptr_t align_up(uintptr_t p, size_t align) {
+ return (p + align - 1) & ~(align - 1);
+}
+
+template <typename T>
+static inline T* align_down(T* p, size_t align) {
+ return reinterpret_cast<T*>(align_down(reinterpret_cast<uintptr_t>(p), align));
+}
+
+template <typename T>
+static inline T* align_up(T* p, size_t align) {
+ return reinterpret_cast<T*>(align_up(reinterpret_cast<uintptr_t>(p), align));
+}
+
+#endif // _BIONIC_MACROS_H_
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_malloc_dispatch.h
^
|
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PRIVATE_BIONIC_MALLOC_DISPATCH_H
+#define _PRIVATE_BIONIC_MALLOC_DISPATCH_H
+
+#include <stddef.h>
+#include <stdint.h>
+#include <private/bionic_config.h>
+
+// Entry in malloc dispatch table.
+typedef void* (*MallocCalloc)(size_t, size_t);
+typedef void (*MallocFree)(void*);
+typedef struct mallinfo (*MallocMallinfo)();
+typedef void* (*MallocMalloc)(size_t);
+typedef size_t (*MallocMallocUsableSize)(const void*);
+typedef void* (*MallocMemalign)(size_t, size_t);
+typedef int (*MallocPosixMemalign)(void**, size_t, size_t);
+typedef void* (*MallocRealloc)(void*, size_t);
+typedef int (*MallocIterate)(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*);
+typedef void (*MallocMallocDisable)();
+typedef void (*MallocMallocEnable)();
+typedef int (*MallocMallopt)(int, int);
+
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+typedef void* (*MallocPvalloc)(size_t);
+typedef void* (*MallocValloc)(size_t);
+#endif
+
+struct MallocDispatch {
+ MallocCalloc calloc;
+ MallocFree free;
+ MallocMallinfo mallinfo;
+ MallocMalloc malloc;
+ MallocMallocUsableSize malloc_usable_size;
+ MallocMemalign memalign;
+ MallocPosixMemalign posix_memalign;
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+ MallocPvalloc pvalloc;
+#endif
+ MallocRealloc realloc;
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+ MallocValloc valloc;
+#endif
+ MallocIterate iterate;
+ MallocMallocDisable malloc_disable;
+ MallocMallocEnable malloc_enable;
+ MallocMallopt mallopt;
+} __attribute__((aligned(32)));
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_mbstate.h
^
|
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BIONIC_MBSTATE_H
+#define _BIONIC_MBSTATE_H
+
+#include <wchar.h>
+
+__BEGIN_DECLS
+
+/*
+ * These return values are specified by POSIX for multibyte conversion
+ * functions.
+ */
+#define __MB_ERR_ILLEGAL_SEQUENCE static_cast<size_t>(-1)
+#define __MB_ERR_INCOMPLETE_SEQUENCE static_cast<size_t>(-2)
+
+#define __MB_IS_ERR(rv) (rv == __MB_ERR_ILLEGAL_SEQUENCE || \
+ rv == __MB_ERR_INCOMPLETE_SEQUENCE)
+
+static inline __wur size_t mbstate_bytes_so_far(const mbstate_t* ps) {
+ return
+ (ps->__seq[2] != 0) ? 3 :
+ (ps->__seq[1] != 0) ? 2 :
+ (ps->__seq[0] != 0) ? 1 : 0;
+}
+
+static inline void mbstate_set_byte(mbstate_t* ps, int i, char byte) {
+ ps->__seq[i] = static_cast<uint8_t>(byte);
+}
+
+static inline __wur uint8_t mbstate_get_byte(const mbstate_t* ps, int n) {
+ return ps->__seq[n];
+}
+
+static inline __wur size_t mbstate_reset_and_return_illegal(int _errno, mbstate_t* ps) {
+ errno = _errno;
+ *(reinterpret_cast<uint32_t*>(ps->__seq)) = 0;
+ return __MB_ERR_ILLEGAL_SEQUENCE;
+}
+
+static inline __wur size_t mbstate_reset_and_return(int _return, mbstate_t* ps) {
+ *(reinterpret_cast<uint32_t*>(ps->__seq)) = 0;
+ return _return;
+}
+
+__END_DECLS
+
+#endif // _BIONIC_MBSTATE_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_page.h
^
|
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_PAGE_H_
+#define _BIONIC_PAGE_H_
+
+// Get PAGE_SIZE and PAGE_MASK.
+#include <sys/user.h>
+
+// Returns the address of the page containing address 'x'.
+#define PAGE_START(x) ((x) & PAGE_MASK)
+
+// Returns the offset of address 'x' in its page.
+#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK)
+
+// Returns the address of the next page after address 'x', unless 'x' is
+// itself at the start of a page.
+#define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE-1))
+
+#endif // _BIONIC_PAGE_H_
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_prctl.h
^
|
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BIONIC_PRCTL_H
+#define BIONIC_PRCTL_H
+
+#include <sys/prctl.h>
+
+// This is only supported by Android kernels, so it's not in the uapi headers.
+#define PR_SET_VMA 0x53564d41
+#define PR_SET_VMA_ANON_NAME 0
+
+#endif // BIONIC_PRCTL_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_sdk_version.h
^
|
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_SDK_VERSION_H_
+#define _BIONIC_SDK_VERSION_H_
+
+#include <stdint.h>
+
+uint32_t bionic_get_application_target_sdk_version();
+
+#endif // _BIONIC_SDK_VERSION_H_
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_sigdefs.h
^
|
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * this header is used to define signal constants and names;
+ * it might be included several times
+ */
+
+#ifndef __BIONIC_SIGDEF
+#error __BIONIC_SIGDEF not defined
+#endif
+
+__BIONIC_SIGDEF(SIGHUP, "Hangup")
+__BIONIC_SIGDEF(SIGINT, "Interrupt")
+__BIONIC_SIGDEF(SIGQUIT, "Quit")
+__BIONIC_SIGDEF(SIGILL, "Illegal instruction")
+__BIONIC_SIGDEF(SIGTRAP, "Trap")
+__BIONIC_SIGDEF(SIGABRT, "Aborted")
+#ifdef SIGEMT
+__BIONIC_SIGDEF(SIGEMT, "EMT")
+#endif
+__BIONIC_SIGDEF(SIGFPE, "Floating point exception")
+__BIONIC_SIGDEF(SIGKILL, "Killed")
+__BIONIC_SIGDEF(SIGBUS, "Bus error")
+__BIONIC_SIGDEF(SIGSEGV, "Segmentation fault")
+__BIONIC_SIGDEF(SIGPIPE, "Broken pipe")
+__BIONIC_SIGDEF(SIGALRM, "Alarm clock")
+__BIONIC_SIGDEF(SIGTERM, "Terminated")
+__BIONIC_SIGDEF(SIGUSR1, "User signal 1")
+__BIONIC_SIGDEF(SIGUSR2, "User signal 2")
+__BIONIC_SIGDEF(SIGCHLD, "Child exited")
+__BIONIC_SIGDEF(SIGPWR, "Power failure")
+__BIONIC_SIGDEF(SIGWINCH, "Window size changed")
+__BIONIC_SIGDEF(SIGURG, "Urgent I/O condition")
+__BIONIC_SIGDEF(SIGIO, "I/O possible")
+__BIONIC_SIGDEF(SIGSTOP, "Stopped (signal)")
+__BIONIC_SIGDEF(SIGTSTP, "Stopped")
+__BIONIC_SIGDEF(SIGCONT, "Continue")
+__BIONIC_SIGDEF(SIGTTIN, "Stopped (tty input)")
+__BIONIC_SIGDEF(SIGTTOU, "Stopped (tty output)")
+__BIONIC_SIGDEF(SIGVTALRM, "Virtual timer expired")
+__BIONIC_SIGDEF(SIGPROF, "Profiling timer expired")
+__BIONIC_SIGDEF(SIGXCPU, "CPU time limit exceeded")
+__BIONIC_SIGDEF(SIGXFSZ, "File size limit exceeded")
+#if defined(SIGSTKFLT)
+__BIONIC_SIGDEF(SIGSTKFLT, "Stack fault")
+#endif
+__BIONIC_SIGDEF(SIGSYS, "Bad system call")
+
+#undef __BIONIC_SIGDEF
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_ssp.h
^
|
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PRIVATE_SSP_H
+#define _PRIVATE_SSP_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+/* GCC uses this on ARM and MIPS; we use it on x86 to set the guard in TLS. */
+extern uintptr_t __stack_chk_guard;
+
+/* GCC calls this if a stack guard check fails. */
+extern void __stack_chk_fail();
+
+__END_DECLS
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_string_utils.h
^
|
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _BIONIC_STRING_UTILS_H_
+#define _BIONIC_STRING_UTILS_H_
+
+#include <string.h>
+
+static inline bool ends_with(const char* s1, const char* s2) {
+ size_t s1_length = strlen(s1);
+ size_t s2_length = strlen(s2);
+ if (s2_length > s1_length) {
+ return false;
+ }
+ return memcmp(s1 + (s1_length - s2_length), s2, s2_length) == 0;
+}
+
+#endif // _BIONIC_STRING_UTILS_H_
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_systrace.h
^
|
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BIONIC_SYSTRACE_H
+#define BIONIC_SYSTRACE_H
+
+#include "bionic_macros.h"
+
+// Tracing class for bionic. To begin a trace at a specified point:
+// ScopedTrace("Trace message");
+// The trace will end when the contructor goes out of scope.
+
+// stubbed for hybris support
+class ScopedTrace {
+ public:
+ explicit ScopedTrace(const char* message) {};
+ ~ScopedTrace() {};
+
+ void End() {};
+ private:
+ bool called_end_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedTrace);
+};
+
+// stubbed for hybris support:
+static inline void bionic_trace_begin(const char* message) {};
+static inline void bionic_trace_end() {};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_time_conversions.h
^
|
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _BIONIC_TIME_CONVERSIONS_H
+#define _BIONIC_TIME_CONVERSIONS_H
+
+#include <errno.h>
+#include <time.h>
+#include <sys/cdefs.h>
+
+#include "private/bionic_constants.h"
+
+__BEGIN_DECLS
+
+__LIBC_HIDDEN__ bool timespec_from_timeval(timespec& ts, const timeval& tv);
+__LIBC_HIDDEN__ void timespec_from_ms(timespec& ts, const int ms);
+
+__LIBC_HIDDEN__ void timeval_from_timespec(timeval& tv, const timespec& ts);
+
+__END_DECLS
+
+static inline int check_timespec(const timespec* ts, bool null_allowed) {
+ if (null_allowed && ts == nullptr) {
+ return 0;
+ }
+ // glibc just segfaults if you pass a null timespec.
+ // That seems a lot more likely to catch bad code than returning EINVAL.
+ if (ts->tv_nsec < 0 || ts->tv_nsec >= NS_PER_S) {
+ return EINVAL;
+ }
+ if (ts->tv_sec < 0) {
+ return ETIMEDOUT;
+ }
+ return 0;
+}
+
+#if !defined(__LP64__)
+static inline void absolute_timespec_from_timespec(timespec& abs_ts, const timespec& ts, clockid_t clock) {
+ clock_gettime(clock, &abs_ts);
+ abs_ts.tv_sec += ts.tv_sec;
+ abs_ts.tv_nsec += ts.tv_nsec;
+ if (abs_ts.tv_nsec >= NS_PER_S) {
+ abs_ts.tv_nsec -= NS_PER_S;
+ abs_ts.tv_sec++;
+ }
+}
+#endif
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_tls.h
^
|
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __BIONIC_PRIVATE_BIONIC_TLS_H_
+#define __BIONIC_PRIVATE_BIONIC_TLS_H_
+
+#include <locale.h>
+#include <mntent.h>
+#include <stdio.h>
+#include <sys/cdefs.h>
+#include <sys/param.h>
+
+#include "bionic_macros.h"
+#include "__get_tls.h"
+#include "grp_pwd.h"
+
+__BEGIN_DECLS
+
+/** WARNING WARNING WARNING
+ **
+ ** This header file is *NOT* part of the public Bionic ABI/API
+ ** and should not be used/included by user-serviceable parts of
+ ** the system (e.g. applications).
+ **
+ ** It is only provided here for the benefit of the system dynamic
+ ** linker and the OpenGL sub-system (which needs to access the
+ ** pre-allocated slot directly for performance reason).
+ **/
+
+// Well-known TLS slots. What data goes in which slot is arbitrary unless otherwise noted.
+enum {
+ TLS_SLOT_SELF = 0, // The kernel requires this specific slot for x86.
+ TLS_SLOT_THREAD_ID,
+ TLS_SLOT_ERRNO,
+
+ // These two aren't used by bionic itself, but allow the graphics code to
+ // access TLS directly rather than using the pthread API.
+ TLS_SLOT_OPENGL_API = 3,
+ TLS_SLOT_OPENGL = 4,
+
+ // This slot is only used to pass information from the dynamic linker to
+ // libc.so when the C library is loaded in to memory. The C runtime init
+ // function will then clear it. Since its use is extremely temporary,
+ // we reuse an existing location that isn't needed during libc startup.
+ TLS_SLOT_BIONIC_PREINIT = TLS_SLOT_OPENGL_API,
+
+ TLS_SLOT_STACK_GUARD = 5, // GCC requires this specific slot for x86.
+ TLS_SLOT_DLERROR,
+
+ // Fast storage for Thread::Current() in ART.
+ TLS_SLOT_ART_THREAD_SELF,
+
+ // Lets TSAN avoid using pthread_getspecific for finding the current thread
+ // state.
+ TLS_SLOT_TSAN,
+
+ BIONIC_TLS_SLOTS // Must come last!
+};
+
+// ~3 pages.
+struct bionic_tls {
+ locale_t locale;
+
+ char basename_buf[MAXPATHLEN];
+ char dirname_buf[MAXPATHLEN];
+
+ mntent mntent_buf;
+ char mntent_strings[BUFSIZ];
+
+ char ptsname_buf[32];
+ char ttyname_buf[64];
+
+ char strerror_buf[NL_TEXTMAX];
+ char strsignal_buf[NL_TEXTMAX];
+
+ group_state_t group;
+ passwd_state_t passwd;
+};
+
+#define BIONIC_TLS_SIZE (BIONIC_ALIGN(sizeof(bionic_tls), PAGE_SIZE))
+
+/*
+ * Bionic uses some pthread keys internally. All pthread keys used internally
+ * should be created in constructors, except for keys that may be used in or
+ * before constructors.
+ *
+ * We need to manually maintain the count of pthread keys used internally, but
+ * pthread_test should fail if we forget.
+ *
+ * These are the pthread keys currently used internally by libc:
+ * _res_key libc (constructor in BSD code)
+ */
+
+#define LIBC_PTHREAD_KEY_RESERVED_COUNT 1
+
+/* Internally, jemalloc uses a single key for per thread data. */
+#define JEMALLOC_PTHREAD_KEY_RESERVED_COUNT 1
+#define BIONIC_PTHREAD_KEY_RESERVED_COUNT (LIBC_PTHREAD_KEY_RESERVED_COUNT + JEMALLOC_PTHREAD_KEY_RESERVED_COUNT)
+
+/*
+ * Maximum number of pthread keys allocated.
+ * This includes pthread keys used internally and externally.
+ */
+#define BIONIC_PTHREAD_KEY_COUNT (BIONIC_PTHREAD_KEY_RESERVED_COUNT + PTHREAD_KEYS_MAX)
+
+__END_DECLS
+
+#if defined(__cplusplus)
+class KernelArgumentBlock;
+extern void __libc_init_main_thread(KernelArgumentBlock&);
+#endif
+
+#endif /* __BIONIC_PRIVATE_BIONIC_TLS_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/bionic_vdso.h
^
|
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PRIVATE_BIONIC_VDSO_H
+#define _PRIVATE_BIONIC_VDSO_H
+
+#include <time.h>
+
+#if defined(__aarch64__)
+#define VDSO_CLOCK_GETTIME_SYMBOL "__kernel_clock_gettime"
+#define VDSO_GETTIMEOFDAY_SYMBOL "__kernel_gettimeofday"
+#else
+#define VDSO_CLOCK_GETTIME_SYMBOL "__vdso_clock_gettime"
+#define VDSO_GETTIMEOFDAY_SYMBOL "__vdso_gettimeofday"
+#endif
+
+extern "C" int __clock_gettime(int, timespec*);
+extern "C" int __gettimeofday(timeval*, struct timezone*);
+
+struct vdso_entry {
+ const char* name;
+ void* fn;
+};
+
+enum {
+ VDSO_CLOCK_GETTIME = 0,
+ VDSO_GETTIMEOFDAY,
+ VDSO_END
+};
+
+#endif // _PRIVATE_BIONIC_VDSO_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/get_cpu_count_from_string.h
^
|
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+
+// Parse a string like: 0, 2-4, 6.
+static int GetCpuCountFromString(const char* s) {
+ int cpu_count = 0;
+ int last_cpu = -1;
+ while (*s != '\0') {
+ if (isdigit(*s)) {
+ int cpu = static_cast<int>(strtol(s, const_cast<char**>(&s), 10));
+ if (last_cpu != -1) {
+ cpu_count += cpu - last_cpu;
+ } else {
+ cpu_count++;
+ }
+ last_cpu = cpu;
+ } else {
+ if (*s == ',') {
+ last_cpu = -1;
+ }
+ s++;
+ }
+ }
+ return cpu_count;
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/grp_pwd.h
^
|
@@ -0,0 +1,48 @@
+#pragma once
+
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <grp.h>
+#include <pwd.h>
+
+struct group_state_t {
+ group group_;
+ char* group_members_[2];
+ char group_name_buffer_[32];
+ // Must be last so init_group_state can run a simple memset for the above
+ ssize_t getgrent_idx;
+};
+
+struct passwd_state_t {
+ passwd passwd_;
+ char name_buffer_[32];
+ char dir_buffer_[32];
+ char sh_buffer_[32];
+ ssize_t getpwent_idx;
+};
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/icu.h
^
|
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _PRIVATE_ICU_H
+#define _PRIVATE_ICU_H
+
+#include <stdint.h>
+
+typedef int8_t UBool;
+typedef int32_t UChar32;
+
+enum UProperty {
+ UCHAR_ALPHABETIC = 0,
+ UCHAR_LOWERCASE = 22,
+ UCHAR_POSIX_ALNUM = 44,
+ UCHAR_POSIX_BLANK = 45,
+ UCHAR_POSIX_GRAPH = 46,
+ UCHAR_POSIX_PRINT = 47,
+ UCHAR_POSIX_XDIGIT = 48,
+ UCHAR_UPPERCASE = 30,
+ UCHAR_WHITE_SPACE = 31,
+};
+
+enum UCharCategory {
+ U_CONTROL_CHAR = 15,
+};
+
+void* __find_icu_symbol(const char* symbol_name);
+
+#endif // _PRIVATE_ICU_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/kernel_sigset_t.h
^
|
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LIBC_PRIVATE_KERNEL_SIGSET_T_H_
+#define LIBC_PRIVATE_KERNEL_SIGSET_T_H_
+
+#include <signal.h>
+
+// Our sigset_t is wrong for ARM and x86. It's 32-bit but the kernel expects 64 bits.
+// This means we can't support real-time signals correctly until we can change the ABI.
+// In the meantime, we can use this union to pass an appropriately-sized block of memory
+// to the kernel, at the cost of not being able to refer to real-time signals.
+union kernel_sigset_t {
+ kernel_sigset_t() {
+ clear();
+ }
+
+ kernel_sigset_t(const sigset_t* value) {
+ clear();
+ set(value);
+ }
+
+ void clear() {
+ __builtin_memset(this, 0, sizeof(*this));
+ }
+
+ void set(const sigset_t* value) {
+ bionic = *value;
+ }
+
+ sigset_t* get() {
+ return &bionic;
+ }
+
+ sigset_t bionic;
+#ifndef __mips__
+ uint32_t kernel[2];
+#endif
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/bionic/libc/private/thread_private.h
^
|
@@ -0,0 +1,57 @@
+/* $OpenBSD: thread_private.h,v 1.18 2006/02/22 07:16:31 otto Exp $ */
+
+/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
+
+#ifndef _THREAD_PRIVATE_H_
+#define _THREAD_PRIVATE_H_
+
+#include <pthread.h>
+
+__BEGIN_DECLS
+
+/*
+ * This file defines the thread library interface to libc. Thread
+ * libraries must implement the functions described here for proper
+ * inter-operation with libc. libc contains weak versions of the
+ * described functions for operation in a non-threaded environment.
+ */
+
+/*
+ * helper macro to make unique names in the thread namespace
+ */
+#define __THREAD_NAME(name) __CONCAT(_thread_tagname_,name)
+
+struct __thread_private_tag_t {
+ pthread_mutex_t _private_lock;
+ pthread_key_t _private_key;
+};
+
+#define _THREAD_PRIVATE_MUTEX(name) \
+ static struct __thread_private_tag_t __THREAD_NAME(name) = { PTHREAD_MUTEX_INITIALIZER, -1 }
+#define _THREAD_PRIVATE_MUTEX_LOCK(name) \
+ pthread_mutex_lock( &__THREAD_NAME(name)._private_lock )
+#define _THREAD_PRIVATE_MUTEX_UNLOCK(name) \
+ pthread_mutex_unlock( &__THREAD_NAME(name)._private_lock )
+
+/* Note that these aren't compatible with the usual OpenBSD ones which lazy-initialize! */
+#define _MUTEX_LOCK(l) pthread_mutex_lock((pthread_mutex_t*) l)
+#define _MUTEX_UNLOCK(l) pthread_mutex_unlock((pthread_mutex_t*) l)
+
+__LIBC_HIDDEN__ void _thread_atexit_lock(void);
+__LIBC_HIDDEN__ void _thread_atexit_unlock(void);
+
+#define _ATEXIT_LOCK() _thread_atexit_lock()
+#define _ATEXIT_UNLOCK() _thread_atexit_unlock()
+
+__LIBC_HIDDEN__ void _thread_arc4_lock(void);
+__LIBC_HIDDEN__ void _thread_arc4_unlock(void);
+
+#define _ARC4_LOCK() _thread_arc4_lock()
+#define _ARC4_UNLOCK() _thread_arc4_unlock()
+#define _ARC4_ATFORK(f) pthread_atfork(NULL, NULL, (f))
+
+extern volatile sig_atomic_t _rs_forked;
+
+__END_DECLS
+
+#endif /* _THREAD_PRIVATE_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/dlfcn.cpp
^
|
@@ -0,0 +1,466 @@
+/*
+ * Copyright (C) 2007 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "hybris_compat.h"
+
+#include "linker.h"
+#include "linker_cfi.h"
+#include "linker_globals.h"
+#include "linker_dlwarning.h"
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <android/api-level.h>
+
+#include <bionic/pthread_internal.h>
+#include "private/bionic_tls.h"
+#include "private/ScopedPthreadMutexLocker.h"
+
+static pthread_mutex_t g_dl_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+
+static __thread char *dl_err_str;
+char __thread dlerror_buffer[__BIONIC_DLERROR_BUFFER_SIZE];
+
+static char* __bionic_set_dlerror(char* new_value) {
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+ char** dlerror_slot = &reinterpret_cast<char**>(__get_tls())[TLS_SLOT_DLERROR];
+
+ char* old_value = *dlerror_slot;
+ *dlerror_slot = new_value;
+ if (new_value != nullptr) LD_LOG(kLogErrors, "dlerror set to \"%s\"", new_value);
+ return old_value;
+#else
+ char *old_value = dl_err_str;
+ dl_err_str = new_value;
+ return old_value;
+#endif
+}
+
+static void __bionic_format_dlerror(const char* msg, const char* detail) {
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+ char* buffer = __get_thread()->dlerror_buffer;
+#else
+ char* buffer = dlerror_buffer;
+#endif
+ strlcpy(buffer, msg, __BIONIC_DLERROR_BUFFER_SIZE);
+ if (detail != nullptr) {
+ strlcat(buffer, ": ", __BIONIC_DLERROR_BUFFER_SIZE);
+ strlcat(buffer, detail, __BIONIC_DLERROR_BUFFER_SIZE);
+ }
+
+ __bionic_set_dlerror(buffer);
+}
+
+char* __dlerror() {
+ char* old_value = __bionic_set_dlerror(nullptr);
+ return old_value;
+}
+
+void __android_get_LD_LIBRARY_PATH(char* buffer, size_t buffer_size) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ do_android_get_LD_LIBRARY_PATH(buffer, buffer_size);
+}
+
+void __android_update_LD_LIBRARY_PATH(const char* ld_library_path) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ do_android_update_LD_LIBRARY_PATH(ld_library_path);
+}
+
+static void* dlopen_ext(const char* filename,
+ int flags,
+ const android_dlextinfo* extinfo,
+ const void* caller_addr) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ g_linker_logger.ResetState();
+ void* result = do_dlopen(filename, flags, extinfo, caller_addr);
+ if (result == nullptr) {
+ __bionic_format_dlerror("dlopen failed", linker_get_error_buffer());
+ return nullptr;
+ }
+ return result;
+}
+
+void* __android_dlopen_ext(const char* filename,
+ int flags,
+ const android_dlextinfo* extinfo,
+ const void* caller_addr) {
+ return dlopen_ext(filename, flags, extinfo, caller_addr);
+}
+
+void* __dlopen(const char* filename, int flags, const void* caller_addr) {
+ return dlopen_ext(filename, flags, nullptr, caller_addr);
+}
+
+void* dlsym_impl(void* handle, const char* symbol, const char* version, const void* caller_addr) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ g_linker_logger.ResetState();
+ void* result;
+ if (!do_dlsym(handle, symbol, version, caller_addr, &result)) {
+ __bionic_format_dlerror(linker_get_error_buffer(), nullptr);
+ return nullptr;
+ }
+
+ return result;
+}
+
+void* __dlsym(void* handle, const char* symbol, const void* caller_addr) {
+ return dlsym_impl(handle, symbol, nullptr, caller_addr);
+}
+
+void* __dlvsym(void* handle, const char* symbol, const char* version, const void* caller_addr) {
+ return dlsym_impl(handle, symbol, version, caller_addr);
+}
+
+int __dladdr(const void* addr, Dl_info* info) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ return do_dladdr(addr, info);
+}
+
+int __dlclose(void* handle) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ int result = do_dlclose(handle);
+ if (result != 0) {
+ __bionic_format_dlerror("dlclose failed", linker_get_error_buffer());
+ }
+ return result;
+}
+
+// This function is needed by libgcc.a (this is why there is no prefix for this one) // in hybris there is a prefix, libgcc.a from android doesn't affect us here.
+int __android_dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void* data) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ return do_dl_iterate_phdr(cb, data);
+}
+
+#if defined(__arm__)
+_Unwind_Ptr __android_dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ return do_dl_unwind_find_exidx(pc, pcount);
+}
+#endif
+
+void __android_set_application_target_sdk_version(uint32_t target) {
+ // lock to avoid modification in the middle of dlopen.
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ set_application_target_sdk_version(target);
+}
+
+uint32_t __android_get_application_target_sdk_version() {
+ return get_application_target_sdk_version();
+}
+
+void __android_dlwarning(void* obj, void (*f)(void*, const char*)) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ get_dlwarning(obj, f);
+}
+
+bool __android_init_anonymous_namespace(const char* shared_libs_sonames,
+ const char* library_search_path) {
+ ScopedPthreadMutexLocker locker(&g_dl_mutex);
+ bool success = init_anonymous_namespace(shared_libs_sonames, library_search_path);
+ if (!success) {
+ __bionic_format_dlerror("android_init_anonymous_namespace failed", linker_get_error_buffer());
+ }
+
+ return success;
+}
+
+android_namespace_t* __android_create_namespace(const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path,
+ android_namespace_t* parent_namespace,
+ const void* caller_addr) {
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/hybris_compat.cpp
^
|
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "hybris_compat.h"
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/hybris_compat.h
^
|
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#ifndef HYBRIS_ANDROID_MM_COMPAT_H_
+#define HYBRIS_ANDROID_MM_COMPAT_H_
+
+#include <string.h>
+#include <memory.h>
+
+extern "C" size_t strlcpy(char *dest, const char *src, size_t size);
+extern "C" size_t strlcat(char *dst, const char *src, size_t size);
+
+#define ELF_ST_BIND(x) ((x) >> 4)
+
+#ifndef PAGE_SIZE
+#define PAGE_SIZE 4096
+#endif
+
+#define PAGE_MASK (~(PAGE_SIZE - 1))
+
+/*
+ * From bionic/libc/include/elf.h
+ *
+ * Android compressed rel/rela sections
+ */
+#define DT_ANDROID_REL (DT_LOOS + 2)
+#define DT_ANDROID_RELSZ (DT_LOOS + 3)
+
+#define DT_ANDROID_RELA (DT_LOOS + 4)
+#define DT_ANDROID_RELASZ (DT_LOOS + 5)
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/ld.config.format.md
^
|
@@ -0,0 +1,83 @@
+# Linker config file format
+
+This document describes format of /system/etc/ld.config.txt file. This file can be used to customize
+linker-namespace setup for dynamic executables.
+
+## Overview
+
+The configuration consists of 2 parts
+1. Mappings - maps executable locations to sections
+2. Sections - contains linker-namespace configuration
+
+## Mappings
+
+This part of the document maps location of an executable to a section. Here is an example
+
+The format is `dir.<section_name>=<directory>`
+
+The mappings should be defined between start of ld.config.txt and the first section.
+
+## Section
+
+Every section starts with `[section_name]` (which is used in mappings) and it defines namespaces
+configuration using set of properties described in example below.
+
+## Example
+
+```
+# The following line maps section to a dir. Binraies ran from this location will use namespaces
+# configuration specified in [example_section] below
+dir.example_section=/system/bin/example
+
+# Section starts
+[example_section]
+
+# When this flag is set to true linker will set target_sdk_version for this binary to
+# the version specified in <dirname>/.version file, where <dirname> = dirname(executable_path)
+#
+# default value is false
+enable.target.sdk.version = true
+
+# This property can be used to declare additional namespaces.Note that there is always the default
+# namespace. The default namespace is the namespace for the main executable. This list is
+# comma-separated.
+additional.namespaces = ns1
+
+# Each namespace property starts with "namespace.<namespace-name>" The following is configuration
+# for the default namespace
+
+# Is namespace isolated - the default value is false
+namespace.default.isolated = true
+
+# Default namespace search path. Note that ${LIB} here is substituted with "lib" for 32bit targets
+# and with "lib64" for 64bit ones.
+namespace.default.search.paths = /system/${LIB}:/system/other/${LIB}
+
+# ... same for asan
+namespace.default.asan.search.paths = /data/${LIB}:/data/other/${LIB}
+
+# Permitted path
+namespace.default.permitted.paths = /system/${LIB}
+
+# ... asan
+namespace.default.asan.permitted.paths = /data/${LIB}
+
+# This declares linked namespaces - comma separated list.
+namespace.default.links = ns1
+
+# For every link define list of shared libraries. This is list of the libraries accessilbe from
+# default namespace but loaded in the linked namespace.
+namespace.default.link.ns1.shared_libs = libexternal.so:libother.so
+
+# This part defines config for ns1
+namespace.ns1.isolated = true
+namespace.ns1.search.paths = /vendor/${LIB}
+namespace.ns1.asan.search.paths = /data/vendor/${LIB}
+namespace.ns1.permitted.paths = /vendor/${LIB}
+namespace.ns1.asan.permitted.paths = /data/vendor/${LIB}
+
+# and links it to default namespace
+namespace.ns.links = default
+namespace.ns.link.default.shared_libs = libc.so:libdl.so:libm.so:libstdc++.so
+```
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linked_list.h
^
|
@@ -0,0 +1,263 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKED_LIST_H
+#define __LINKED_LIST_H
+
+#include "private/bionic_macros.h"
+
+template<typename T>
+struct LinkedListEntry {
+ LinkedListEntry<T>* next;
+ T* element;
+};
+
+// ForwardInputIterator
+template<typename T>
+class LinkedListIterator {
+ public:
+ LinkedListIterator() : entry_(nullptr) {}
+ LinkedListIterator(const LinkedListIterator<T>& that) : entry_(that.entry_) {}
+ explicit LinkedListIterator(LinkedListEntry<T>* entry) : entry_(entry) {}
+
+ LinkedListIterator<T>& operator=(const LinkedListIterator<T>& that) {
+ entry_ = that.entry_;
+ return *this;
+ }
+
+ LinkedListIterator<T>& operator++() {
+ entry_ = entry_->next;
+ return *this;
+ }
+
+ T* const operator*() {
+ return entry_->element;
+ }
+
+ bool operator==(const LinkedListIterator<T>& that) const {
+ return entry_ == that.entry_;
+ }
+
+ bool operator!=(const LinkedListIterator<T>& that) const {
+ return entry_ != that.entry_;
+ }
+
+ private:
+ LinkedListEntry<T> *entry_;
+};
+
+/*
+ * Represents linked list of objects of type T
+ */
+template<typename T, typename Allocator>
+class LinkedList {
+ public:
+ typedef LinkedListIterator<T> iterator;
+ typedef T* value_type;
+
+ LinkedList() : head_(nullptr), tail_(nullptr) {}
+ ~LinkedList() {
+ clear();
+ }
+
+ LinkedList(LinkedList&& that) {
+ this->head_ = that.head_;
+ this->tail_ = that.tail_;
+ that.head_ = that.tail_ = nullptr;
+ }
+
+ void push_front(T* const element) {
+ LinkedListEntry<T>* new_entry = Allocator::alloc();
+ new_entry->next = head_;
+ new_entry->element = element;
+ head_ = new_entry;
+ if (tail_ == nullptr) {
+ tail_ = new_entry;
+ }
+ }
+
+ void push_back(T* const element) {
+ LinkedListEntry<T>* new_entry = Allocator::alloc();
+ new_entry->next = nullptr;
+ new_entry->element = element;
+ if (tail_ == nullptr) {
+ tail_ = head_ = new_entry;
+ } else {
+ tail_->next = new_entry;
+ tail_ = new_entry;
+ }
+ }
+
+ T* pop_front() {
+ if (head_ == nullptr) {
+ return nullptr;
+ }
+
+ LinkedListEntry<T>* entry = head_;
+ T* element = entry->element;
+ head_ = entry->next;
+ Allocator::free(entry);
+
+ if (head_ == nullptr) {
+ tail_ = nullptr;
+ }
+
+ return element;
+ }
+
+ T* front() const {
+ if (head_ == nullptr) {
+ return nullptr;
+ }
+
+ return head_->element;
+ }
+
+ void clear() {
+ while (head_ != nullptr) {
+ LinkedListEntry<T>* p = head_;
+ head_ = head_->next;
+ Allocator::free(p);
+ }
+
+ tail_ = nullptr;
+ }
+
+ bool empty() {
+ return (head_ == nullptr);
+ }
+
+ template<typename F>
+ void for_each(F action) const {
+ visit([&] (T* si) {
+ action(si);
+ return true;
+ });
+ }
+
+ template<typename F>
+ bool visit(F action) const {
+ for (LinkedListEntry<T>* e = head_; e != nullptr; e = e->next) {
+ if (!action(e->element)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ template<typename F>
+ void remove_if(F predicate) {
+ for (LinkedListEntry<T>* e = head_, *p = nullptr; e != nullptr;) {
+ if (predicate(e->element)) {
+ LinkedListEntry<T>* next = e->next;
+ if (p == nullptr) {
+ head_ = next;
+ } else {
+ p->next = next;
+ }
+
+ if (tail_ == e) {
+ tail_ = p;
+ }
+
+ Allocator::free(e);
+
+ e = next;
+ } else {
+ p = e;
+ e = e->next;
+ }
+ }
+ }
+
+ void remove(T* element) {
+ remove_if([&](T* e) {
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker.cpp
^
|
@@ -0,0 +1,3696 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <android/api-level.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/param.h>
+#include <sys/vfs.h>
+#include <unistd.h>
+
+#include <new>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "hybris_compat.h"
+
+#include <android-base/scopeguard.h>
+
+#include <async_safe/log.h>
+
+// Private C library headers.
+
+#include "linker.h"
+#include "linker_block_allocator.h"
+#include "linker_cfi.h"
+#include "linker_config.h"
+#include "linker_gdb_support.h"
+#include "linker_globals.h"
+#include "linker_debug.h"
+#include "linker_dlwarning.h"
+#include "linker_main.h"
+#include "linker_namespaces.h"
+#include "linker_sleb128.h"
+#include "linker_phdr.h"
+#include "linker_relocs.h"
+#include "linker_reloc_iterators.h"
+#include "linker_utils.h"
+
+//#include "android-base/strings.h"
+//#include "android-base/stringprintf.h"
+//#include "ziparchive/zip_archive.h"
+
+#ifdef WANT_ARM_TRACING
+#include "../wrappers.h"
+#endif
+
+// Stay compatible with newer glibc
+#ifndef R_AARCH64_TLS_TPREL64
+#define R_AARCH64_TLS_TPREL64 R_AARCH64_TLS_TPREL
+#endif
+#ifndef R_AARCH64_TLS_DTPREL32
+#define R_AARCH64_TLS_DTPREL32 R_AARCH64_TLS_DTPREL
+#endif
+
+#define TMPFS_MAGIC 0x01021994
+
+#define DF_1_PIE 0x08000000
+
+// Override macros to use C++ style casts.
+#undef ELF_ST_TYPE
+#define ELF_ST_TYPE(x) (static_cast<uint32_t>(x) & 0xf)
+
+static LinkerTypeAllocator<android_namespace_t> g_namespace_allocator;
+static LinkerTypeAllocator<LinkedListEntry<android_namespace_t>> g_namespace_list_allocator;
+android_namespace_t *g_default_namespace = new (g_namespace_allocator.alloc()) android_namespace_t();
+
+static android_namespace_t* g_anonymous_namespace = g_default_namespace;
+static std::unordered_map<std::string, android_namespace_t*> g_exported_namespaces;
+
+static LinkerTypeAllocator<soinfo> g_soinfo_allocator;
+static LinkerTypeAllocator<LinkedListEntry<soinfo>> g_soinfo_links_allocator;
+
+static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt";
+
+#if defined(__LP64__)
+static const char* const kSystemLibDir = "/system/lib64";
+static const char* const kVendorLibDir = "/vendor/lib64";
+static const char* const kOdmLibDir = "/odm/lib64";
+static const char* const kAsanSystemLibDir = "/data/asan/system/lib64";
+static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib64";
+static const char* const kAsanOdmLibDir = "/data/asan/odm/lib64";
+#else
+static const char* const kSystemLibDir = "/system/lib";
+static const char* const kVendorLibDir = "/vendor/lib";
+static const char* const kOdmLibDir = "/odm/lib";
+static const char* const kAsanSystemLibDir = "/data/asan/system/lib";
+static const char* const kAsanVendorLibDir = "/data/asan/vendor/lib";
+static const char* const kAsanOdmLibDir = "/data/asan/odm/lib";
+#endif
+
+static const char* const kAsanLibDirPrefix = "/data/asan";
+
+static const char* const kDefaultLdPaths[] = {
+ kSystemLibDir,
+ kVendorLibDir,
+ kOdmLibDir,
+ nullptr
+};
+
+static const char* const kAsanDefaultLdPaths[] = {
+ kAsanSystemLibDir,
+ kSystemLibDir,
+ kAsanVendorLibDir,
+ kVendorLibDir,
+ kAsanOdmLibDir,
+ kOdmLibDir,
+ nullptr
+};
+
+// Is ASAN enabled?
+static bool g_is_asan = false;
+
+static CFIShadowWriter g_cfi_shadow;
+
+CFIShadowWriter* get_cfi_shadow() {
+ return &g_cfi_shadow;
+}
+
+static bool is_system_library(const std::string& realpath) {
+ for (const auto& dir : g_default_namespace->get_default_library_paths()) {
+ if (file_is_in_dir(realpath, dir)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// Checks if the file exists and not a directory.
+static bool file_exists(const char* path) {
+ struct stat s;
+
+ if (stat(path, &s) != 0) {
+ return false;
+ }
+
+ return S_ISREG(s.st_mode);
+}
+
+static std::string resolve_soname(const std::string& name) {
+ // We assume that soname equals to basename here
+
+ // TODO(dimitry): consider having honest absolute-path -> soname resolution
+ // note that since we might end up refusing to load this library because
+ // it is not in shared libs list we need to get the soname without actually loading
+ // the library.
+ //
+ // On the other hand there are several places where we already assume that
+ // soname == basename in particular for any not-loaded library mentioned
+ // in DT_NEEDED list.
+ return basename(name.c_str());
+}
+
+static bool maybe_accessible_via_namespace_links(android_namespace_t* ns, const char* name) {
+ std::string soname = resolve_soname(name);
+ for (auto& ns_link : ns->linked_namespaces()) {
+ if (ns_link.is_accessible(soname.c_str())) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// TODO(dimitry): The grey-list is a workaround for http://b/26394120 ---
+// gradually remove libraries from this list until it is gone.
+static bool is_greylisted(android_namespace_t* ns, const char* name, const soinfo* needed_by) {
+ static const char* const kLibraryGreyList[] = {
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker.h
^
|
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _LINKER_H_
+#define _LINKER_H_
+
+#include <dlfcn.h>
+#include <android/dlext.h>
+#include <elf.h>
+#include <inttypes.h>
+#include <link.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "private/bionic_page.h"
+#include "linked_list.h"
+#include "linker_common_types.h"
+#include "linker_logger.h"
+#include "linker_soinfo.h"
+
+#include <string>
+#include <vector>
+
+#if defined(__LP64__)
+#define ELFW(what) ELF64_ ## what
+#else
+#define ELFW(what) ELF32_ ## what
+#endif
+
+// mips64 interprets Elf64_Rel structures' r_info field differently.
+// bionic (like other C libraries) has macros that assume regular ELF files,
+// but the dynamic linker needs to be able to load mips64 ELF files.
+#if defined(__mips__) && defined(__LP64__)
+#undef ELF64_R_SYM
+#undef ELF64_R_TYPE
+#undef ELF64_R_INFO
+#define ELF64_R_SYM(info) (((info) >> 0) & 0xffffffff)
+#define ELF64_R_SSYM(info) (((info) >> 32) & 0xff)
+#define ELF64_R_TYPE3(info) (((info) >> 40) & 0xff)
+#define ELF64_R_TYPE2(info) (((info) >> 48) & 0xff)
+#define ELF64_R_TYPE(info) (((info) >> 56) & 0xff)
+#endif
+
+#define SUPPORTED_DT_FLAGS_1 (DF_1_NOW | DF_1_GLOBAL | DF_1_NODELETE | DF_1_PIE)
+
+// Class used construct version dependency graph.
+class VersionTracker {
+ public:
+ VersionTracker() = default;
+ bool init(const soinfo* si_from);
+
+ const version_info* get_version_info(ElfW(Versym) source_symver) const;
+ private:
+ bool init_verneed(const soinfo* si_from);
+ bool init_verdef(const soinfo* si_from);
+ void add_version_info(size_t source_index, ElfW(Word) elf_hash,
+ const char* ver_name, const soinfo* target_si);
+
+ std::vector<version_info> version_infos;
+
+ DISALLOW_COPY_AND_ASSIGN(VersionTracker);
+};
+
+bool soinfo_do_lookup(soinfo* si_from, const char* name, const version_info* vi,
+ soinfo** si_found_in, const soinfo_list_t& global_group,
+ const soinfo_list_t& local_group, const ElfW(Sym)** symbol);
+
+enum RelocationKind {
+ kRelocAbsolute = 0,
+ kRelocRelative,
+ kRelocCopy,
+ kRelocSymbol,
+ kRelocMax
+};
+
+void count_relocation(RelocationKind kind);
+
+soinfo* get_libdl_info(const char* linker_path, const link_map& linker_map);
+
+soinfo* find_containing_library(const void* p);
+
+void do_android_get_LD_LIBRARY_PATH(char*, size_t);
+void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path);
+void* do_dlopen(const char* name,
+ int flags,
+ const android_dlextinfo* extinfo,
+ const void* caller_addr);
+
+int do_dlclose(void* handle);
+
+int do_dl_iterate_phdr(int (*cb)(dl_phdr_info* info, size_t size, void* data), void* data);
+
+#if defined(__arm__)
+_Unwind_Ptr do_dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount);
+#endif
+
+bool do_dlsym(void* handle, const char* sym_name,
+ const char* sym_ver,
+ const void* caller_addr,
+ void** symbol);
+
+int do_dladdr(const void* addr, Dl_info* info);
+
+// void ___cfi_slowpath(uint64_t CallSiteTypeId, void *Ptr, void *Ret);
+// void ___cfi_slowpath_diag(uint64_t CallSiteTypeId, void *Ptr, void *DiagData, void *Ret);
+void ___cfi_fail(uint64_t CallSiteTypeId, void* Ptr, void *DiagData, void *Ret);
+
+void set_application_target_sdk_version(uint32_t target);
+uint32_t get_application_target_sdk_version();
+
+enum {
+ /* A regular namespace is the namespace with a custom search path that does
+ * not impose any restrictions on the location of native libraries.
+ */
+ ANDROID_NAMESPACE_TYPE_REGULAR = 0,
+
+ /* An isolated namespace requires all the libraries to be on the search path
+ * or under permitted_when_isolated_path. The search path is the union of
+ * ld_library_path and default_library_path.
+ */
+ ANDROID_NAMESPACE_TYPE_ISOLATED = 1,
+
+ /* The shared namespace clones the list of libraries of the caller namespace upon creation
+ * which means that they are shared between namespaces - the caller namespace and the new one
+ * will use the same copy of a library if it was loaded prior to android_create_namespace call.
+ *
+ * Note that libraries loaded after the namespace is created will not be shared.
+ *
+ * Shared namespaces can be isolated or regular. Note that they do not inherit the search path nor
+ * permitted_path from the caller's namespace.
+ */
+ ANDROID_NAMESPACE_TYPE_SHARED = 2,
+
+ /* This flag instructs linker to enable grey-list workaround for the namespace.
+ * See http://b/26394120 for details.
+ */
+ ANDROID_NAMESPACE_TYPE_GREYLIST_ENABLED = 0x08000000,
+
+ ANDROID_NAMESPACE_TYPE_SHARED_ISOLATED = ANDROID_NAMESPACE_TYPE_SHARED |
+ ANDROID_NAMESPACE_TYPE_ISOLATED,
+};
+
+bool init_anonymous_namespace(const char* shared_lib_sonames, const char* library_search_path);
+android_namespace_t* create_namespace(const void* caller_addr,
+ const char* name,
+ const char* ld_library_path,
+ const char* default_library_path,
+ uint64_t type,
+ const char* permitted_when_isolated_path,
+ android_namespace_t* parent_namespace);
+
+bool link_namespaces(android_namespace_t* namespace_from,
+ android_namespace_t* namespace_to,
+ const char* shared_lib_sonames);
+
+android_namespace_t* get_exported_namespace(const char* name);
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_allocator.cpp
^
|
@@ -0,0 +1,360 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_allocator.h"
+#include "linker_debug.h"
+#include "linker_utils.h"
+#include "linker.h"
+
+#include <algorithm>
+#include <vector>
+
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#include <async_safe/log.h>
+
+#include <memory.h>
+
+#include "private/bionic_prctl.h"
+
+#include "hybris_compat.h"
+
+//
+// LinkerMemeoryAllocator is general purpose allocator
+// designed to provide the same functionality as the malloc/free/realloc
+// libc functions.
+//
+// On alloc:
+// If size is >= 1k allocator proxies malloc call directly to mmap
+// If size < 1k allocator uses SmallObjectAllocator for the size
+// rounded up to the nearest power of two.
+//
+// On free:
+//
+// For a pointer allocated using proxy-to-mmap allocator unmaps
+// the memory.
+//
+// For a pointer allocated using SmallObjectAllocator it adds
+// the block to free_blocks_list_. If the number of free pages reaches 2,
+// SmallObjectAllocator munmaps one of the pages keeping the other one
+// in reserve.
+
+static const char kSignature[4] = {'L', 'M', 'A', 1};
+
+static const size_t kSmallObjectMaxSize = 1 << kSmallObjectMaxSizeLog2;
+
+// This type is used for large allocations (with size >1k)
+static const uint32_t kLargeObject = 111;
+
+bool operator<(const small_object_page_record& one, const small_object_page_record& two) {
+ return one.page_addr < two.page_addr;
+}
+
+static inline uint16_t log2(size_t number) {
+ uint16_t result = 0;
+ number--;
+
+ while (number != 0) {
+ result++;
+ number >>= 1;
+ }
+
+ return result;
+}
+
+LinkerSmallObjectAllocator::LinkerSmallObjectAllocator(uint32_t type, size_t block_size)
+ : type_(type), block_size_(block_size), free_pages_cnt_(0), free_blocks_list_(nullptr) {}
+
+void* LinkerSmallObjectAllocator::alloc() {
+ CHECK(block_size_ != 0);
+
+ if (free_blocks_list_ == nullptr) {
+ alloc_page();
+ }
+
+ small_object_block_record* block_record = free_blocks_list_;
+ if (block_record->free_blocks_cnt > 1) {
+ small_object_block_record* next_free = reinterpret_cast<small_object_block_record*>(
+ reinterpret_cast<uint8_t*>(block_record) + block_size_);
+ next_free->next = block_record->next;
+ next_free->free_blocks_cnt = block_record->free_blocks_cnt - 1;
+ free_blocks_list_ = next_free;
+ } else {
+ free_blocks_list_ = block_record->next;
+ }
+
+ // bookkeeping...
+ auto page_record = find_page_record(block_record);
+
+ if (page_record->allocated_blocks_cnt == 0) {
+ free_pages_cnt_--;
+ }
+
+ page_record->free_blocks_cnt--;
+ page_record->allocated_blocks_cnt++;
+
+ memset(block_record, 0, block_size_);
+
+ return block_record;
+}
+
+void LinkerSmallObjectAllocator::free_page(linker_vector_t::iterator page_record) {
+ void* page_start = reinterpret_cast<void*>(page_record->page_addr);
+ void* page_end = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(page_start) + PAGE_SIZE);
+
+ while (free_blocks_list_ != nullptr &&
+ free_blocks_list_ > page_start &&
+ free_blocks_list_ < page_end) {
+ free_blocks_list_ = free_blocks_list_->next;
+ }
+
+ small_object_block_record* current = free_blocks_list_;
+
+ while (current != nullptr) {
+ while (current->next > page_start && current->next < page_end) {
+ current->next = current->next->next;
+ }
+
+ current = current->next;
+ }
+
+ munmap(page_start, PAGE_SIZE);
+ page_records_.erase(page_record);
+ free_pages_cnt_--;
+}
+
+void LinkerSmallObjectAllocator::free(void* ptr) {
+ auto page_record = find_page_record(ptr);
+
+ ssize_t offset = reinterpret_cast<uintptr_t>(ptr) - sizeof(page_info);
+
+ if (offset % block_size_ != 0) {
+ async_safe_fatal("invalid pointer: %p (block_size=%zd)", ptr, block_size_);
+ }
+
+ memset(ptr, 0, block_size_);
+ small_object_block_record* block_record = reinterpret_cast<small_object_block_record*>(ptr);
+
+ block_record->next = free_blocks_list_;
+ block_record->free_blocks_cnt = 1;
+
+ free_blocks_list_ = block_record;
+
+ page_record->free_blocks_cnt++;
+ page_record->allocated_blocks_cnt--;
+
+ if (page_record->allocated_blocks_cnt == 0) {
+ if (free_pages_cnt_++ > 1) {
+ // if we already have a free page - unmap this one.
+ free_page(page_record);
+ }
+ }
+}
+
+linker_vector_t::iterator LinkerSmallObjectAllocator::find_page_record(void* ptr) {
+ void* addr = reinterpret_cast<void*>(PAGE_START(reinterpret_cast<uintptr_t>(ptr)));
+ small_object_page_record boundary;
+ boundary.page_addr = addr;
+ linker_vector_t::iterator it = std::lower_bound(
+ page_records_.begin(), page_records_.end(), boundary);
+
+ if (it == page_records_.end() || it->page_addr != addr) {
+ // not found...
+ async_safe_fatal("page record for %p was not found (block_size=%zd)", ptr, block_size_);
+ }
+
+ return it;
+}
+
+void LinkerSmallObjectAllocator::create_page_record(void* page_addr, size_t free_blocks_cnt) {
+ small_object_page_record record;
+ record.page_addr = page_addr;
+ record.free_blocks_cnt = free_blocks_cnt;
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_allocator.h
^
|
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_ALLOCATOR_H
+#define __LINKER_ALLOCATOR_H
+
+#include <stdlib.h>
+#include <sys/cdefs.h>
+#include <sys/mman.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <vector>
+
+#include <async_safe/log.h>
+
+#include "private/bionic_prctl.h"
+
+const uint32_t kSmallObjectMaxSizeLog2 = 10;
+const uint32_t kSmallObjectMinSizeLog2 = 4;
+const uint32_t kSmallObjectAllocatorsCount = kSmallObjectMaxSizeLog2 - kSmallObjectMinSizeLog2 + 1;
+
+class LinkerSmallObjectAllocator;
+
+// This structure is placed at the beginning of each addressable page
+// and has all information we need to find the corresponding memory allocator.
+struct page_info {
+ char signature[4];
+ uint32_t type;
+ union {
+ // we use allocated_size for large objects allocator
+ size_t allocated_size;
+ // and allocator_addr for small ones.
+ LinkerSmallObjectAllocator* allocator_addr;
+ };
+} __attribute__((aligned(16)));
+
+struct small_object_page_record {
+ void* page_addr;
+ size_t free_blocks_cnt;
+ size_t allocated_blocks_cnt;
+};
+
+// for lower_bound...
+bool operator<(const small_object_page_record& one, const small_object_page_record& two);
+
+struct small_object_block_record {
+ small_object_block_record* next;
+ size_t free_blocks_cnt;
+};
+
+// This is implementation for std::vector allocator
+template <typename T>
+class linker_vector_allocator {
+ public:
+ typedef T value_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ T* allocate(size_t n, const T* hint = nullptr) {
+ size_t size = n * sizeof(T);
+ void* ptr = mmap(const_cast<T*>(hint), size,
+ PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ if (ptr == MAP_FAILED) {
+ // Spec says we need to throw std::bad_alloc here but because our
+ // code does not support exception handling anyways - we are going to abort.
+ async_safe_fatal("mmap failed");
+ }
+
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr, size, "linker_alloc_vector");
+
+ return reinterpret_cast<T*>(ptr);
+ }
+
+ void deallocate(T* ptr, size_t n) {
+ munmap(ptr, n * sizeof(T));
+ }
+};
+
+typedef
+ std::vector<small_object_page_record, linker_vector_allocator<small_object_page_record>>
+ linker_vector_t;
+
+
+class LinkerSmallObjectAllocator {
+ public:
+ LinkerSmallObjectAllocator(uint32_t type, size_t block_size);
+ void* alloc();
+ void free(void* ptr);
+
+ size_t get_block_size() const { return block_size_; }
+ private:
+ void alloc_page();
+ void free_page(linker_vector_t::iterator page_record);
+ linker_vector_t::iterator find_page_record(void* ptr);
+ void create_page_record(void* page_addr, size_t free_blocks_cnt);
+
+ uint32_t type_;
+ size_t block_size_;
+
+ size_t free_pages_cnt_;
+ small_object_block_record* free_blocks_list_;
+
+ // sorted vector of page records
+ linker_vector_t page_records_;
+};
+
+class LinkerMemoryAllocator {
+ public:
+ constexpr LinkerMemoryAllocator() : allocators_(nullptr), allocators_buf_() {}
+ void* alloc(size_t size);
+
+ // Note that this implementation of realloc never shrinks allocation
+ void* realloc(void* ptr, size_t size);
+ void free(void* ptr);
+ private:
+ void* alloc_mmap(size_t size);
+ page_info* get_page_info(void* ptr);
+ LinkerSmallObjectAllocator* get_small_object_allocator(uint32_t type);
+ void initialize_allocators();
+
+ LinkerSmallObjectAllocator* allocators_;
+ uint8_t allocators_buf_[sizeof(LinkerSmallObjectAllocator)*kSmallObjectAllocatorsCount];
+};
+
+
+#endif /* __LINKER_ALLOCATOR_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_block_allocator.cpp
^
|
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_block_allocator.h"
+#include <inttypes.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#include "private/bionic_prctl.h"
+
+#include "hybris_compat.h"
+
+// the multiplier should be power of 2
+static constexpr size_t round_up(size_t size, size_t multiplier) {
+ return (size + (multiplier - 1)) & ~(multiplier-1);
+}
+
+struct LinkerBlockAllocatorPage {
+ LinkerBlockAllocatorPage* next;
+ uint8_t bytes[PAGE_SIZE - 16] __attribute__((aligned(16)));
+};
+
+struct FreeBlockInfo {
+ void* next_block;
+ size_t num_free_blocks;
+};
+
+LinkerBlockAllocator::LinkerBlockAllocator(size_t block_size)
+ : block_size_(
+ round_up(block_size < sizeof(FreeBlockInfo) ? sizeof(FreeBlockInfo) : block_size, 16)),
+ page_list_(nullptr),
+ free_block_list_(nullptr)
+{}
+
+void* LinkerBlockAllocator::alloc() {
+ if (free_block_list_ == nullptr) {
+ create_new_page();
+ }
+
+ FreeBlockInfo* block_info = reinterpret_cast<FreeBlockInfo*>(free_block_list_);
+ if (block_info->num_free_blocks > 1) {
+ FreeBlockInfo* next_block_info = reinterpret_cast<FreeBlockInfo*>(
+ reinterpret_cast<char*>(free_block_list_) + block_size_);
+ next_block_info->next_block = block_info->next_block;
+ next_block_info->num_free_blocks = block_info->num_free_blocks - 1;
+ free_block_list_ = next_block_info;
+ } else {
+ free_block_list_ = block_info->next_block;
+ }
+
+ memset(block_info, 0, block_size_);
+
+ return block_info;
+}
+
+void LinkerBlockAllocator::free(void* block) {
+ if (block == nullptr) {
+ return;
+ }
+
+ LinkerBlockAllocatorPage* page = find_page(block);
+
+ if (page == nullptr) {
+ abort();
+ }
+
+ ssize_t offset = reinterpret_cast<uint8_t*>(block) - page->bytes;
+
+ if (offset % block_size_ != 0) {
+ abort();
+ }
+
+ memset(block, 0, block_size_);
+
+ FreeBlockInfo* block_info = reinterpret_cast<FreeBlockInfo*>(block);
+
+ block_info->next_block = free_block_list_;
+ block_info->num_free_blocks = 1;
+
+ free_block_list_ = block_info;
+}
+
+void LinkerBlockAllocator::protect_all(int prot) {
+ for (LinkerBlockAllocatorPage* page = page_list_; page != nullptr; page = page->next) {
+ if (mprotect(page, PAGE_SIZE, prot) == -1) {
+ abort();
+ }
+ }
+}
+
+void LinkerBlockAllocator::create_new_page() {
+ static_assert(sizeof(LinkerBlockAllocatorPage) == PAGE_SIZE,
+ "Invalid sizeof(LinkerBlockAllocatorPage)");
+
+ LinkerBlockAllocatorPage* page = reinterpret_cast<LinkerBlockAllocatorPage*>(
+ mmap(nullptr, PAGE_SIZE, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0));
+
+ if (page == MAP_FAILED) {
+ abort(); // oom
+ }
+
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, page, PAGE_SIZE, "linker_alloc");
+
+ FreeBlockInfo* first_block = reinterpret_cast<FreeBlockInfo*>(page->bytes);
+ first_block->next_block = free_block_list_;
+ first_block->num_free_blocks = (PAGE_SIZE - sizeof(LinkerBlockAllocatorPage*))/block_size_;
+
+ free_block_list_ = first_block;
+
+ page->next = page_list_;
+ page_list_ = page;
+}
+
+LinkerBlockAllocatorPage* LinkerBlockAllocator::find_page(void* block) {
+ if (block == nullptr) {
+ abort();
+ }
+
+ LinkerBlockAllocatorPage* page = page_list_;
+ while (page != nullptr) {
+ const uint8_t* page_ptr = reinterpret_cast<const uint8_t*>(page);
+ if (block >= (page_ptr + sizeof(page->next)) && block < (page_ptr + PAGE_SIZE)) {
+ return page;
+ }
+
+ page = page->next;
+ }
+
+ abort();
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_block_allocator.h
^
|
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_BLOCK_ALLOCATOR_H
+#define __LINKER_BLOCK_ALLOCATOR_H
+
+#include <stdlib.h>
+#include <limits.h>
+#include "private/bionic_macros.h"
+
+struct LinkerBlockAllocatorPage;
+
+/*
+ * This class is a non-template version of the LinkerTypeAllocator
+ * It keeps code inside .cpp file by keeping the interface
+ * template-free.
+ *
+ * Please use LinkerTypeAllocator<type> where possible (everywhere).
+ */
+class LinkerBlockAllocator {
+ public:
+ explicit LinkerBlockAllocator(size_t block_size);
+
+ void* alloc();
+ void free(void* block);
+ void protect_all(int prot);
+
+ private:
+ void create_new_page();
+ LinkerBlockAllocatorPage* find_page(void* block);
+
+ size_t block_size_;
+ LinkerBlockAllocatorPage* page_list_;
+ void* free_block_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(LinkerBlockAllocator);
+};
+
+/*
+ * A simple allocator for the dynamic linker. An allocator allocates instances
+ * of a single fixed-size type. Allocations are backed by page-sized private
+ * anonymous mmaps.
+ *
+ * The differences between this allocator and LinkerMemoryAllocator are:
+ * 1. This allocator manages space more efficiently. LinkerMemoryAllocator
+ * operates in power-of-two sized blocks up to 1k, when this implementation
+ * splits the page to aligned size of structure; For example for structures
+ * with size 513 this allocator will use 516 (520 for lp64) bytes of data
+ * where generalized implementation is going to use 1024 sized blocks.
+ *
+ * 2. This allocator does not munmap allocated memory, where LinkerMemoryAllocator does.
+ *
+ * 3. This allocator provides mprotect services to the user, where LinkerMemoryAllocator
+ * always treats it's memory as READ|WRITE.
+ */
+template<typename T>
+class LinkerTypeAllocator {
+ public:
+ LinkerTypeAllocator() : block_allocator_(sizeof(T)) {}
+ T* alloc() { return reinterpret_cast<T*>(block_allocator_.alloc()); }
+ void free(T* t) { block_allocator_.free(t); }
+ void protect_all(int prot) { block_allocator_.protect_all(prot); }
+ private:
+ LinkerBlockAllocator block_allocator_;
+ DISALLOW_COPY_AND_ASSIGN(LinkerTypeAllocator);
+};
+
+#endif // __LINKER_BLOCK_ALLOCATOR_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_cfi.cpp
^
|
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_cfi.h"
+
+#include "linker_debug.h"
+#include "linker_globals.h"
+#include "linker_utils.h"
+#include "private/bionic_page.h"
+#include "private/bionic_prctl.h"
+
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <cstdint>
+
+// Update shadow without making it writable by preparing the data on the side and mremap-ing it in
+// place.
+class ShadowWrite {
+ char* shadow_start;
+ char* shadow_end;
+ char* aligned_start;
+ char* aligned_end;
+ char* tmp_start;
+
+ public:
+ ShadowWrite(uint16_t* s, uint16_t* e) {
+ shadow_start = reinterpret_cast<char*>(s);
+ shadow_end = reinterpret_cast<char*>(e);
+ aligned_start = reinterpret_cast<char*>(PAGE_START(reinterpret_cast<uintptr_t>(shadow_start)));
+ aligned_end = reinterpret_cast<char*>(PAGE_END(reinterpret_cast<uintptr_t>(shadow_end)));
+ tmp_start =
+ reinterpret_cast<char*>(mmap(nullptr, aligned_end - aligned_start, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
+ CHECK(tmp_start != MAP_FAILED);
+ memcpy(tmp_start, aligned_start, shadow_start - aligned_start);
+ memcpy(tmp_start + (shadow_end - aligned_start), shadow_end, aligned_end - shadow_end);
+ }
+
+ uint16_t* begin() {
+ return reinterpret_cast<uint16_t*>(tmp_start + (shadow_start - aligned_start));
+ }
+
+ uint16_t* end() {
+ return reinterpret_cast<uint16_t*>(tmp_start + (shadow_end - aligned_start));
+ }
+
+ ~ShadowWrite() {
+ size_t size = aligned_end - aligned_start;
+ mprotect(tmp_start, size, PROT_READ);
+ void* res = mremap(tmp_start, size, size, MREMAP_MAYMOVE | MREMAP_FIXED,
+ reinterpret_cast<void*>(aligned_start));
+ CHECK(res != MAP_FAILED);
+ }
+};
+
+void CFIShadowWriter::FixupVmaName() {
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, *shadow_start, kShadowSize, "cfi shadow");
+}
+
+void CFIShadowWriter::AddConstant(uintptr_t begin, uintptr_t end, uint16_t v) {
+ uint16_t* shadow_begin = MemToShadow(begin);
+ uint16_t* shadow_end = MemToShadow(end - 1) + 1;
+
+ ShadowWrite sw(shadow_begin, shadow_end);
+ std::fill(sw.begin(), sw.end(), v);
+}
+
+void CFIShadowWriter::AddUnchecked(uintptr_t begin, uintptr_t end) {
+ AddConstant(begin, end, kUncheckedShadow);
+}
+
+void CFIShadowWriter::AddInvalid(uintptr_t begin, uintptr_t end) {
+ AddConstant(begin, end, kInvalidShadow);
+}
+
+void CFIShadowWriter::Add(uintptr_t begin, uintptr_t end, uintptr_t cfi_check) {
+ CHECK((cfi_check & (kCfiCheckAlign - 1)) == 0);
+
+ // Don't fill anything below cfi_check. We can not represent those addresses
+ // in the shadow, and must make sure at codegen to place all valid call
+ // targets above cfi_check.
+ begin = std::max(begin, cfi_check) & ~(kShadowAlign - 1);
+ uint16_t* shadow_begin = MemToShadow(begin);
+ uint16_t* shadow_end = MemToShadow(end - 1) + 1;
+
+ ShadowWrite sw(shadow_begin, shadow_end);
+ uint16_t sv_begin = ((begin + kShadowAlign - cfi_check) >> kCfiCheckGranularity) + kRegularShadowMin;
+
+ // With each step of the loop below, __cfi_check address computation base is increased by
+ // 2**ShadowGranularity.
+ // To compensate for that, each next shadow value must be increased by 2**ShadowGranularity /
+ // 2**CfiCheckGranularity.
+ uint16_t sv_step = 1 << (kShadowGranularity - kCfiCheckGranularity);
+ uint16_t sv = sv_begin;
+ for (uint16_t& s : sw) {
+ if (sv < sv_begin) {
+ // If shadow value wraps around, also fall back to unchecked. This means the binary is too
+ // large. FIXME: consider using a (slow) resolution function instead.
+ s = kUncheckedShadow;
+ continue;
+ }
+ // If there is something there already, fall back to unchecked. This may happen in rare cases
+ // with MAP_FIXED libraries. FIXME: consider using a (slow) resolution function instead.
+ s = (s == kInvalidShadow) ? sv : kUncheckedShadow;
+ sv += sv_step;
+ }
+}
+
+static soinfo* find_libdl(soinfo* solist) {
+ for (soinfo* si = solist; si != nullptr; si = si->next) {
+ const char* soname = si->get_soname();
+ if (soname && strcmp(soname, "libdl.so") == 0) {
+ return si;
+ }
+ }
+ return nullptr;
+}
+
+static uintptr_t soinfo_find_symbol(soinfo* si, const char* s) {
+ SymbolName name(s);
+ const ElfW(Sym) * sym;
+ if (si->find_symbol_by_name(name, nullptr, &sym) && sym) {
+ return si->resolve_symbol_address(sym);
+ }
+ return 0;
+}
+
+uintptr_t soinfo_find_cfi_check(soinfo* si) {
+ return soinfo_find_symbol(si, "__cfi_check");
+}
+
+uintptr_t CFIShadowWriter::MapShadow() {
+ void* p =
+ mmap(nullptr, kShadowSize, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
+ CHECK(p != MAP_FAILED);
+ return reinterpret_cast<uintptr_t>(p);
+}
+
+bool CFIShadowWriter::AddLibrary(soinfo* si) {
+ CHECK(shadow_start != nullptr);
+ if (si->base == 0 || si->size == 0) {
+ return true;
+ }
+ uintptr_t cfi_check = soinfo_find_cfi_check(si);
+ if (cfi_check == 0) {
+ INFO("[ CFI add 0x%zx + 0x%zx %s ]", static_cast<uintptr_t>(si->base),
+ static_cast<uintptr_t>(si->size), si->get_soname());
+ AddUnchecked(si->base, si->base + si->size);
+ return true;
+ }
+
+ INFO("[ CFI add 0x%zx + 0x%zx %s: 0x%zx ]", static_cast<uintptr_t>(si->base),
+ static_cast<uintptr_t>(si->size), si->get_soname(), cfi_check);
+#ifdef __arm__
+ // Require Thumb encoding.
+ if ((cfi_check & 1UL) != 1UL) {
+ DL_ERR("__cfi_check in not a Thumb function in the library \"%s\"", si->get_soname());
+ return false;
+ }
+ cfi_check &= ~1UL;
+#endif
+ if ((cfi_check & (kCfiCheckAlign - 1)) != 0) {
+ DL_ERR("unaligned __cfi_check in the library \"%s\"", si->get_soname());
+ return false;
+ }
+ Add(si->base, si->base + si->size, cfi_check);
+ return true;
+}
+
+// Pass the shadow mapping address to libdl.so. In return, we get an pointer to the location
+// libdl.so uses to store the address.
+bool CFIShadowWriter::NotifyLibDl(soinfo* solist, uintptr_t p) {
+ soinfo* libdl = find_libdl(solist);
+ if (libdl == nullptr) {
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_cfi.h
^
|
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _LINKER_CFI_H_
+#define _LINKER_CFI_H_
+
+#include "linker.h"
+#include "linker_debug.h"
+
+#include <algorithm>
+
+#include "hybris_compat.h"
+#include "private/CFIShadow.h"
+
+// This class keeps the contents of CFI shadow up-to-date with the current set of loaded libraries.
+// See the comment in CFIShadow.h for more context.
+// See documentation in http://clang.llvm.org/docs/ControlFlowIntegrityDesign.html#shared-library-support.
+//
+// Shadow is mapped and initialized lazily as soon as the first CFI-enabled DSO is loaded.
+// It is updated after any library is loaded (but before any constructors are ran), and
+// before any library is unloaded.
+class CFIShadowWriter : private CFIShadow {
+ // Returns pointer to the shadow element for an address.
+ uint16_t* MemToShadow(uintptr_t x) {
+ return reinterpret_cast<uint16_t*>(*shadow_start + MemToShadowOffset(x));
+ }
+
+ // Update shadow for the address range to the given constant value.
+ void AddConstant(uintptr_t begin, uintptr_t end, uint16_t v);
+
+ // Update shadow for the address range to kUncheckedShadow.
+ void AddUnchecked(uintptr_t begin, uintptr_t end);
+
+ // Update shadow for the address range to kInvalidShadow.
+ void AddInvalid(uintptr_t begin, uintptr_t end);
+
+ // Update shadow for the address range to the given __cfi_check value.
+ void Add(uintptr_t begin, uintptr_t end, uintptr_t cfi_check);
+
+ // Add a DSO to CFI shadow.
+ bool AddLibrary(soinfo* si);
+
+ // Map CFI shadow.
+ uintptr_t MapShadow();
+
+ // Initialize CFI shadow and update its contents for everything in solist if any loaded library is
+ // CFI-enabled. If new_si != nullptr, do an incremental check by looking only at new_si; otherwise
+ // look at the entire solist.
+ bool MaybeInit(soinfo *new_si, soinfo *solist);
+
+ // Set a human readable name for the entire shadow region.
+ void FixupVmaName();
+
+ // Pass the pointer to the mapped shadow region to libdl. Must only be called once.
+ // Flips shadow_start to a non-nullptr value.
+ bool NotifyLibDl(soinfo *solist, uintptr_t p);
+
+ // Pointer to the shadow start address.
+ uintptr_t *shadow_start;
+
+ bool initial_link_done;
+
+ public:
+ // Update shadow after loading a DSO.
+ // This function will initialize the shadow if it sees a CFI-enabled DSO for the first time.
+ // In that case it will retroactively update shadow for all previously loaded DSOs. "solist" is a
+ // pointer to the global list.
+ // This function must be called before any user code has observed the newly loaded DSO.
+ bool AfterLoad(soinfo* si, soinfo *solist);
+
+ // Update shadow before unloading a DSO.
+ void BeforeUnload(soinfo* si);
+
+ // This is called as soon as the initial set of libraries is linked.
+ bool InitialLinkDone(soinfo *solist);
+
+ // Handle failure to locate __cfi_check for a target address.
+ static void CfiFail(uint64_t CallSiteTypeId, void* Ptr, void* DiagData, void *caller_pc);
+};
+
+CFIShadowWriter* get_cfi_shadow();
+
+#endif // _LINKER_CFI_H_
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_common_types.h
^
|
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_COMMON_TYPES_H
+#define __LINKER_COMMON_TYPES_H
+
+#include <android/dlext.h>
+#include "linked_list.h"
+
+// TODO(dimitry): move this to linker_defines.h? Unless it is removed by
+// consequent refactoring steps.
+
+// Android uses RELA for aarch64 and x86_64. mips64 still uses REL.
+#if defined(__aarch64__) || defined(__x86_64__)
+#define USE_RELA 1
+#endif
+
+
+struct soinfo;
+
+class SoinfoListAllocator {
+ public:
+ static LinkedListEntry<soinfo>* alloc();
+ static void free(LinkedListEntry<soinfo>* entry);
+
+ private:
+ // unconstructable
+ DISALLOW_IMPLICIT_CONSTRUCTORS(SoinfoListAllocator);
+};
+
+class NamespaceListAllocator {
+ public:
+ static LinkedListEntry<android_namespace_t>* alloc();
+ static void free(LinkedListEntry<android_namespace_t>* entry);
+
+ private:
+ // unconstructable
+ DISALLOW_IMPLICIT_CONSTRUCTORS(NamespaceListAllocator);
+};
+
+typedef LinkedList<soinfo, SoinfoListAllocator> soinfo_list_t;
+typedef LinkedList<android_namespace_t, NamespaceListAllocator> android_namespace_list_t;
+
+#endif /* __LINKER_COMMON_TYPES_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_config.cpp
^
|
@@ -0,0 +1,503 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_config.h"
+
+#include "linker_globals.h"
+#include "linker_debug.h"
+#include "linker_utils.h"
+
+#include <android-base/file.h>
+#include <android-base/scopeguard.h>
+#include <android-base/strings.h>
+
+#include <stdio.h>
+
+#include <stdlib.h>
+
+#include <string>
+#include <unordered_map>
+
+#include "hybris_compat.h"
+
+class ConfigParser {
+ public:
+ enum {
+ kProperty,
+ kSection,
+ kEndOfFile,
+ kError,
+ };
+
+ explicit ConfigParser(std::string&& content)
+ : content_(content), p_(0), lineno_(0), was_end_of_file_(false) {}
+
+ /*
+ * Possible return values
+ * kProperty: name is set to property name and value is set to property value
+ * kSection: name is set to section name.
+ * kEndOfFile: reached end of file.
+ * kError: error_msg is set.
+ */
+ int next_token(std::string* name, std::string* value, std::string* error_msg) {
+ std::string line;
+ while(NextLine(&line)) {
+ size_t found = line.find('#');
+ line = trim(line.substr(0, found));
+
+ if (line.empty()) {
+ continue;
+ }
+
+ if (line[0] == '[' && line[line.size() - 1] == ']') {
+ *name = line.substr(1, line.size() - 2);
+ return kSection;
+ }
+
+ found = line.find('=');
+ if (found == std::string::npos) {
+ *error_msg = std::string("invalid format: ") +
+ line +
+ ", expected \"name = property\" or \"[section]\"";
+ return kError;
+ }
+
+ *name = trim(line.substr(0, found));
+ *value = trim(line.substr(found + 1));
+ return kProperty;
+ }
+
+ // to avoid infinite cycles when programmer makes a mistake
+ CHECK(!was_end_of_file_);
+ was_end_of_file_ = true;
+ return kEndOfFile;
+ }
+
+ size_t lineno() const {
+ return lineno_;
+ }
+
+ private:
+ bool NextLine(std::string* line) {
+ if (p_ == std::string::npos) {
+ return false;
+ }
+
+ size_t found = content_.find('\n', p_);
+ if (found != std::string::npos) {
+ *line = content_.substr(p_, found - p_);
+ p_ = found + 1;
+ } else {
+ *line = content_.substr(p_);
+ p_ = std::string::npos;
+ }
+
+ lineno_++;
+ return true;
+ }
+
+ std::string content_;
+ size_t p_;
+ size_t lineno_;
+ bool was_end_of_file_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(ConfigParser);
+};
+
+class PropertyValue {
+ public:
+ PropertyValue() = default;
+
+ PropertyValue(std::string&& value, size_t lineno)
+ : value_(value), lineno_(lineno) {}
+
+ const std::string& value() const {
+ return value_;
+ }
+
+ size_t lineno() const {
+ return lineno_;
+ }
+
+ private:
+ std::string value_;
+ size_t lineno_;
+};
+
+static std::string create_error_msg(const char* file,
+ size_t lineno,
+ const std::string& msg) {
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "%s:%zu: error: %s", file, lineno, msg.c_str());
+
+ return std::string(buf);
+}
+
+static bool parse_config_file(const char* ld_config_file_path,
+ const char* binary_realpath,
+ std::unordered_map<std::string, PropertyValue>* properties,
+ std::string* error_msg) {
+ std::string content;
+ if (!readFileToString(ld_config_file_path, &content)) {
+ if (errno != ENOENT) {
+ *error_msg = std::string("error reading file \"") +
+ ld_config_file_path + "\": " + strerror(errno);
+ }
+ return false;
+ }
+
+ ConfigParser cp(std::move(content));
+
+ std::string section_name;
+
+ while(true) {
+ std::string name;
+ std::string value;
+ std::string error;
+
+ int result = cp.next_token(&name, &value, &error);
+ if (result == ConfigParser::kError) {
+ DL_WARN("error parsing %s:%zd: %s (ignoring this line)",
+ ld_config_file_path,
+ cp.lineno(),
+ error.c_str());
+ continue;
+ }
+
+ if (result == ConfigParser::kSection || result == ConfigParser::kEndOfFile) {
+ return false;
+ }
+
+ if (result == ConfigParser::kProperty) {
+ if (!startsWith(name, "dir.")) {
+ DL_WARN("error parsing %s:%zd: unexpected property name \"%s\", "
+ "expected format dir.<section_name> (ignoring this line)",
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_config.h
^
|
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _LINKER_CONFIG_H_
+#define _LINKER_CONFIG_H_
+
+#include <android/api-level.h>
+
+#include <stdlib.h>
+#include <limits.h>
+#include "private/bionic_macros.h"
+
+#include <memory>
+#include <string>
+#include <vector>
+#include <unordered_map>
+
+class NamespaceLinkConfig {
+ public:
+ NamespaceLinkConfig() = default;
+ NamespaceLinkConfig(const std::string& ns_name, const std::string& shared_libs)
+ : ns_name_(ns_name), shared_libs_(shared_libs) {}
+
+ const std::string& ns_name() const {
+ return ns_name_;
+ }
+
+ const std::string& shared_libs() const {
+ return shared_libs_;
+ }
+
+ private:
+ std::string ns_name_;
+ std::string shared_libs_;
+};
+
+class NamespaceConfig {
+ public:
+ explicit NamespaceConfig(const std::string& name)
+ : name_(name), isolated_(false), visible_(false)
+ {}
+
+ const char* name() const {
+ return name_.c_str();
+ }
+
+ bool isolated() const {
+ return isolated_;
+ }
+
+ bool visible() const {
+ return visible_;
+ }
+
+ const std::vector<std::string>& search_paths() const {
+ return search_paths_;
+ }
+
+ const std::vector<std::string>& permitted_paths() const {
+ return permitted_paths_;
+ }
+
+ const std::vector<NamespaceLinkConfig>& links() const {
+ return namespace_links_;
+ }
+
+ void add_namespace_link(const std::string& ns_name, const std::string& shared_libs) {
+ namespace_links_.push_back(NamespaceLinkConfig(ns_name, shared_libs));
+ }
+
+ void set_isolated(bool isolated) {
+ isolated_ = isolated;
+ }
+
+ void set_visible(bool visible) {
+ visible_ = visible;
+ }
+
+ void set_search_paths(std::vector<std::string>&& search_paths) {
+ search_paths_ = search_paths;
+ }
+
+ void set_permitted_paths(std::vector<std::string>&& permitted_paths) {
+ permitted_paths_ = permitted_paths;
+ }
+ private:
+ const std::string name_;
+ bool isolated_;
+ bool visible_;
+ std::vector<std::string> search_paths_;
+ std::vector<std::string> permitted_paths_;
+ std::vector<NamespaceLinkConfig> namespace_links_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(NamespaceConfig);
+};
+
+class Config {
+ public:
+ Config() : target_sdk_version_(__ANDROID_API__) {}
+
+ const std::vector<std::unique_ptr<NamespaceConfig>>& namespace_configs() const {
+ return namespace_configs_;
+ }
+
+ const NamespaceConfig* default_namespace_config() const {
+ auto it = namespace_configs_map_.find("default");
+ return it == namespace_configs_map_.end() ? nullptr : it->second;
+ }
+
+ uint32_t target_sdk_version() const {
+ return target_sdk_version_;
+ }
+
+ // note that this is one time event and therefore there is no need to
+ // read every section of the config. Every linker instance needs at
+ // most one configuration.
+ // Returns false in case of an error. If binary config was not found
+ // sets *config = nullptr.
+ static bool read_binary_config(const char* ld_config_file_path,
+ const char* binary_realpath,
+ bool is_asan,
+ const Config** config,
+ std::string* error_msg);
+ private:
+ void clear();
+
+ void set_target_sdk_version(uint32_t target_sdk_version) {
+ target_sdk_version_ = target_sdk_version;
+ }
+
+ NamespaceConfig* create_namespace_config(const std::string& name);
+
+ std::vector<std::unique_ptr<NamespaceConfig>> namespace_configs_;
+ std::unordered_map<std::string, NamespaceConfig*> namespace_configs_map_;
+ uint32_t target_sdk_version_;
+
+ DISALLOW_COPY_AND_ASSIGN(Config);
+};
+
+#endif /* _LINKER_CONFIG_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_debug.h
^
|
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _LINKER_DEBUG_H_
+#define _LINKER_DEBUG_H_
+
+// You can increase the verbosity of debug traces by defining the LD_DEBUG
+// environment variable to a numeric value from 0 to 2 (corresponding to
+// INFO, TRACE, and DEBUG calls in the source). This will only
+// affect new processes being launched.
+
+// By default, traces are sent to logcat, with the "linker" tag. You can
+// change this to go to stdout instead by setting the definition of
+// LINKER_DEBUG_TO_LOG to 0.
+#define LINKER_DEBUG_TO_LOG 0
+
+#define TRACE_DEBUG 1
+#define DO_TRACE_LOOKUP 1
+#define DO_TRACE_RELO 1
+#define DO_TRACE_IFUNC 1
+#define TIMING 0
+#define STATS 0
+#define COUNT_PAGES 0
+
+/*********************************************************************
+ * You shouldn't need to modify anything below unless you are adding
+ * more debugging information.
+ *
+ * To enable/disable specific debug options, change the defines above
+ *********************************************************************/
+
+#include <unistd.h>
+
+#include <async_safe/log.h>
+
+extern int g_ld_debug_verbosity;
+
+#define _PRINTVF(v, x...) \
+ do { \
+ if (g_ld_debug_verbosity > (v)) { fprintf(stderr, x); fprintf(stderr, "\n"); } \
+ } while (0)
+
+#define PRINT(x...) _PRINTVF(-1, x)
+#define INFO(x...) _PRINTVF(0, x)
+#define TRACE(x...) _PRINTVF(1, x)
+
+#if TRACE_DEBUG
+#define DEBUG(x...) _PRINTVF(2, "DEBUG: " x)
+#else /* !TRACE_DEBUG */
+#define DEBUG(x...) do {} while (0)
+#endif /* TRACE_DEBUG */
+
+#define TRACE_TYPE(t, x...) do { if (DO_TRACE_##t) { TRACE(x); } } while (0)
+
+#if COUNT_PAGES
+extern uint32_t bitmask[];
+#if defined(__LP64__)
+#define MARK(offset) \
+ do { \
+ if ((((offset) >> 12) >> 5) < 4096) \
+ bitmask[((offset) >> 12) >> 5] |= (1 << (((offset) >> 12) & 31)); \
+ } while (0)
+#else
+#define MARK(offset) \
+ do { \
+ bitmask[((offset) >> 12) >> 3] |= (1 << (((offset) >> 12) & 7)); \
+ } while (0)
+#endif
+#else
+#define MARK(x) do {} while (0)
+
+#endif
+
+#endif /* _LINKER_DEBUG_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_dlwarning.cpp
^
|
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_dlwarning.h"
+
+#include <strings.h>
+
+#include <string>
+
+#include "hybris_compat.h"
+
+static std::string current_msg;
+
+void add_dlwarning(const char* sopath, const char* message, const char* value) {
+ if (!current_msg.empty()) {
+ current_msg += '\n';
+ }
+
+ current_msg = current_msg + basename(sopath) + ": " + message;
+
+ if (value != nullptr) {
+ current_msg = current_msg + " \"" + value + "\"";
+ }
+}
+
+// Resets the current one (like dlerror but instead of
+// being thread-local it is process-local).
+void get_dlwarning(void* obj, void (*f)(void*, const char*)) {
+ if (current_msg.empty()) {
+ f(obj, nullptr);
+ } else {
+ std::string msg = current_msg;
+ current_msg.clear();
+ f(obj, msg.c_str());
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_dlwarning.h
^
|
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_DLWARNING_H
+#define __LINKER_DLWARNING_H
+
+void add_dlwarning(const char* sopath, const char* message, const char* value = nullptr);
+
+// Resets the current one (like dlerror but instead of
+// being thread-local it is process-local). The user_data
+// is used to avoid forcing user into saving the message
+// to a global variable.
+void get_dlwarning(void* user_data, void (*f)(void*, const char*));
+
+#endif /* __LINKER_DLWARNING_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_gdb_support.cpp
^
|
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_gdb_support.h"
+
+#include <pthread.h>
+
+#include "private/ScopedPthreadMutexLocker.h"
+
+#include "hybris_compat.h"
+
+// This function is an empty stub where GDB locates a breakpoint to get notified
+// about linker activity.
+extern "C"
+void __attribute__((noinline)) __attribute__((visibility("default"))) rtld_db_dlactivity();
+
+r_debug _r_debug =
+ {1, nullptr, reinterpret_cast<uintptr_t>(&rtld_db_dlactivity), r_debug::RT_CONSISTENT, 0};
+
+static pthread_mutex_t g__r_debug_mutex = PTHREAD_MUTEX_INITIALIZER;
+static link_map* r_debug_head = nullptr;
+
+void insert_link_map_into_debug_map(link_map* map) {
+ // Stick the new library at the end of the list.
+ // gdb tends to care more about libc than it does
+ // about leaf libraries, and ordering it this way
+ // reduces the back-and-forth over the wire.
+
+ ///// PATCHED: we don't want libhybris modifying glibc's
+ ///// link_map objects, which should not be linked
+ ///// to bionic's stripped link_map objects.
+ ///// ==> make a copy of the whole chain
+ if(r_debug_head == nullptr && _r_debug.r_map != nullptr) {
+ link_map *glibc_link_map = new link_map(*_r_debug.r_map);
+ r_debug_head = glibc_link_map;
+
+ while(glibc_link_map->l_next != nullptr) {
+ link_map *copy_next_link_map = new link_map(*glibc_link_map->l_next);
+ glibc_link_map->l_next = copy_next_link_map;
+ copy_next_link_map->l_prev = glibc_link_map;
+
+ glibc_link_map = copy_next_link_map;
+ }
+ }
+
+ if (r_debug_head != nullptr) {
+ r_debug_head->l_prev = map;
+ map->l_next = r_debug_head;
+ map->l_prev = nullptr;
+ } else {
+ _r_debug.r_map = map;
+ map->l_prev = nullptr;
+ map->l_next = nullptr;
+ }
+ _r_debug.r_map = r_debug_head = map;
+}
+
+void remove_link_map_from_debug_map(link_map* map) {
+ if (r_debug_head == map) {
+ r_debug_head = map->l_next;
+ }
+
+ if (map->l_prev) {
+ map->l_prev->l_next = map->l_next;
+ }
+ if (map->l_next) {
+ map->l_next->l_prev = map->l_prev;
+ }
+}
+
+void notify_gdb_of_load(link_map* map) {
+ ScopedPthreadMutexLocker locker(&g__r_debug_mutex);
+
+ _r_debug.r_state = r_debug::RT_ADD;
+ rtld_db_dlactivity();
+
+ insert_link_map_into_debug_map(map);
+
+ _r_debug.r_state = r_debug::RT_CONSISTENT;
+ rtld_db_dlactivity();
+}
+
+void notify_gdb_of_unload(link_map* map) {
+ ScopedPthreadMutexLocker locker(&g__r_debug_mutex);
+
+ _r_debug.r_state = r_debug::RT_DELETE;
+ rtld_db_dlactivity();
+
+ remove_link_map_from_debug_map(map);
+
+ _r_debug.r_state = r_debug::RT_CONSISTENT;
+ rtld_db_dlactivity();
+}
+
+void notify_gdb_of_libraries() {
+ _r_debug.r_state = r_debug::RT_ADD;
+ rtld_db_dlactivity();
+ _r_debug.r_state = r_debug::RT_CONSISTENT;
+ rtld_db_dlactivity();
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_gdb_support.h
^
|
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef __LINKER_GDB_SUPPORT_H
+#define __LINKER_GDB_SUPPORT_H
+
+#include <link.h>
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+void insert_link_map_into_debug_map(link_map* map);
+void remove_link_map_from_debug_map(link_map* map);
+void notify_gdb_of_load(link_map* map);
+void notify_gdb_of_unload(link_map* map);
+void notify_gdb_of_libraries();
+
+extern struct r_debug _r_debug;
+
+__END_DECLS
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_globals.cpp
^
|
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include "linker_globals.h"
+#include "linker_namespaces.h"
+
+int g_argc = 0;
+char** g_argv = nullptr;
+char** g_envp = nullptr;
+
+std::unordered_map<uintptr_t, soinfo*> g_soinfo_handles_map;
+
+static char __linker_dl_err_buf[768];
+
+char* linker_get_error_buffer() {
+ return &__linker_dl_err_buf[0];
+}
+
+size_t linker_get_error_buffer_size() {
+ return sizeof(__linker_dl_err_buf);
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_globals.h
^
|
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_GLOBALS_H
+#define __LINKER_GLOBALS_H
+
+#include <link.h>
+#include <stddef.h>
+
+#include <unordered_map>
+
+#include <async_safe/log.h>
+
+#define DL_ERR(fmt, x...) \
+ do { \
+ fprintf(stderr, fmt, ##x); \
+ fprintf(stderr, "\n"); \
+ /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
+ } while (false)
+
+#define DL_ERR_NO_PRINT(fmt, x...) \
+ do { \
+ /* If LD_DEBUG is set high enough, log every dlerror(3) message. */ \
+ DEBUG("%s\n", linker_get_error_buffer()); \
+ } while (false)
+
+#define DL_WARN(fmt, x...) \
+ do { \
+ fprintf(stderr, "WARNING: linker " fmt, ##x); \
+ fprintf(stderr, "\n"); \
+ } while (false)
+
+#define DL_ERR_AND_LOG(fmt, x...) \
+ do { \
+ DL_ERR(fmt, x); \
+ PRINT(fmt, x); \
+ } while (false)
+
+constexpr ElfW(Versym) kVersymNotNeeded = 0;
+constexpr ElfW(Versym) kVersymGlobal = 1;
+
+// These values are used to call constructors for .init_array && .preinit_array
+extern int g_argc;
+extern char** g_argv;
+extern char** g_envp;
+
+struct soinfo;
+struct android_namespace_t;
+
+extern android_namespace_t *g_default_namespace;
+
+extern std::unordered_map<uintptr_t, soinfo*> g_soinfo_handles_map;
+
+// Error buffer "variable"
+char* linker_get_error_buffer();
+size_t linker_get_error_buffer_size();
+
+extern void* (*_get_hooked_symbol)(const char *sym, const char *requester);
+
+#ifdef WANT_ARM_TRACING
+extern void *(*_create_wrapper)(const char *symbol, void *function, int wrapper_type);
+#endif
+
+#endif /* __LINKER_GLOBALS_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_libc_support.c
^
|
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "../libc/arch-common/bionic/__dso_handle.h"
+#include "../libc/arch-common/bionic/pthread_atfork.h"
+
+int atexit(void (*function)(void) __attribute__((__unused__))) {
+ return -1;
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_libcxx_support.cpp
^
|
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <async_safe/log.h>
+
+void* __find_icu_symbol(const char* symbol_name __attribute__((__unused__))) {
+ async_safe_fatal("__find_icu_symbol should not be called in the linker");
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_logger.cpp
^
|
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_logger.h"
+
+#include <string.h>
+#include <sys/prctl.h>
+#include <unistd.h>
+
+#include <string>
+#include <vector>
+
+#include <async_safe/log.h>
+
+#include "linker_utils.h"
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+#include "private/CachedProperty.h"
+#endif
+
+#include "hybris_compat.h"
+
+LinkerLogger g_linker_logger;
+bool g_greylist_disabled = false;
+
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+static uint32_t ParseProperty(const std::string& value) {
+ if (value.empty()) {
+ return 0;
+ }
+
+ std::vector<std::string> options = split(value, ",");
+
+ uint32_t flags = 0;
+
+ for (const auto& o : options) {
+ if (o == "dlerror") {
+ flags |= kLogErrors;
+ } else if (o == "dlopen") {
+ flags |= kLogDlopen;
+ } else if (o == "dlsym") {
+ flags |= kLogDlsym;
+ } else {
+ async_safe_format_log(ANDROID_LOG_WARN, "linker", "Ignoring unknown debug.ld option \"%s\"",
+ o.c_str());
+ }
+ }
+
+ return flags;
+}
+#endif
+
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+static void GetAppSpecificProperty(char* buffer) {
+ // Get process basename.
+ const char* process_name_start = basename(g_argv[0]);
+
+ // Remove ':' and everything after it. This is the naming convention for
+ // services: https://developer.android.com/guide/components/services.html
+ const char* process_name_end = strchr(process_name_start, ':');
+
+ std::string process_name = (process_name_end != nullptr) ?
+ std::string(process_name_start, (process_name_end - process_name_start)) :
+ std::string(process_name_start);
+
+ std::string property_name = std::string("debug.ld.app.") + process_name;
+ __system_property_get(property_name.c_str(), buffer);
+}
+#endif
+
+void LinkerLogger::ResetState() {
+ // The most likely scenario app is not debuggable and
+ // is running on a user build, in which case logging is disabled.
+ if (prctl(PR_GET_DUMPABLE, 0, 0, 0, 0) == 0) {
+ return;
+ }
+
+ // This is a convenient place to check whether the greylist should be disabled for testing.
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+ static CachedProperty greylist_disabled("debug.ld.greylist_disabled");
+ bool old_value = g_greylist_disabled;
+ g_greylist_disabled = (strcmp(greylist_disabled.Get(), "true") == 0);
+ if (g_greylist_disabled != old_value) {
+ async_safe_format_log(ANDROID_LOG_INFO, "linker", "%s greylist",
+ g_greylist_disabled ? "Disabling" : "Enabling");
+ }
+ flags_ = 0;
+
+ // For logging, check the flag applied to all processes first.
+ static CachedProperty debug_ld_all("debug.ld.all");
+ flags_ |= ParseProperty(debug_ld_all.Get());
+#endif
+ // Ignore processes started without argv (http://b/33276926).
+ if (g_argv[0] == nullptr) {
+ return;
+ }
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+ // Otherwise check the app-specific property too.
+ // We can't easily cache the property here because argv[0] changes.
+ char debug_ld_app[PROP_VALUE_MAX] = {};
+ GetAppSpecificProperty(debug_ld_app);
+ flags_ |= ParseProperty(debug_ld_app);
+#endif
+}
+
+void LinkerLogger::Log(uint32_t type, const char* format, ...) {
+ if ((flags_ & type) == 0) {
+ return;
+ }
+
+ va_list ap;
+ va_start(ap, format);
+ async_safe_format_log_va_list(ANDROID_LOG_DEBUG, "linker", format, ap);
+ va_end(ap);
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_logger.h
^
|
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _LINKER_LOGGER_H_
+#define _LINKER_LOGGER_H_
+
+#include <stdlib.h>
+#include <limits.h>
+#include "private/bionic_macros.h"
+#include "private/bionic_systrace.h"
+
+#define LD_LOG(type, x...) \
+ { \
+ g_linker_logger.Log(type, x); \
+ }
+
+constexpr const uint32_t kLogErrors = 1 << 0;
+constexpr const uint32_t kLogDlopen = 1 << 1;
+constexpr const uint32_t kLogDlsym = 1 << 2;
+
+class LinkerLogger {
+ public:
+ LinkerLogger() : flags_(0) { }
+
+ void ResetState();
+ void Log(uint32_t type, const char* format, ...);
+ private:
+ uint32_t flags_;
+
+ DISALLOW_COPY_AND_ASSIGN(LinkerLogger);
+};
+
+extern LinkerLogger g_linker_logger;
+extern char** g_argv;
+
+// If the system property debug.ld.greylist_disabled is true, we'll not use the greylist
+// regardless of API level.
+extern bool g_greylist_disabled;
+
+#endif /* _LINKER_LOGGER_H_ */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_main.cpp
^
|
@@ -0,0 +1,651 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "hybris_compat.h"
+
+#include "linker_main.h"
+
+#include "linker_debug.h"
+#include "linker_cfi.h"
+#include "linker_gdb_support.h"
+#include "linker_globals.h"
+#include "linker_phdr.h"
+#include "linker_utils.h"
+
+#include "private/bionic_globals.h"
+#include "private/bionic_tls.h"
+#include "private/KernelArgumentBlock.h"
+
+#include "android-base/strings.h"
+#include "android-base/stringprintf.h"
+#ifdef __ANDROID__
+#include "debuggerd/handler.h"
+#endif
+
+#include <async_safe/log.h>
+
+#include <vector>
+
+extern void __libc_init_globals(KernelArgumentBlock&);
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+extern void __libc_init_AT_SECURE(KernelArgumentBlock&);
+#endif
+
+#ifdef DISABLED_FOR_HYBRIS_SUPPORT
+extern "C" void _start();
+#endif
+
+static ElfW(Addr) get_elf_exec_load_bias(const ElfW(Ehdr)* elf);
+
+// These should be preserved static to avoid emitting
+// RELATIVE relocations for the part of the code running
+// before linker links itself.
+
+// TODO (dimtiry): remove somain, rename solist to solist_head
+static soinfo* solist;
+static soinfo* sonext;
+static soinfo* somain; // main process, always the one after libdl_info
+
+void solist_add_soinfo(soinfo* si) {
+ sonext->next = si;
+ sonext = si;
+}
+
+bool solist_remove_soinfo(soinfo* si) {
+ soinfo *prev = nullptr, *trav;
+ for (trav = solist; trav != nullptr; trav = trav->next) {
+ if (trav == si) {
+ break;
+ }
+ prev = trav;
+ }
+
+ if (trav == nullptr) {
+ // si was not in solist
+ PRINT("name \"%s\"@%p is not in solist!", si->get_realpath(), si);
+ return false;
+ }
+
+ // prev will never be null, because the first entry in solist is
+ // always the static libdl_info.
+ CHECK(prev != nullptr);
+ prev->next = si->next;
+ if (si == sonext) {
+ sonext = prev;
+ }
+
+ return true;
+}
+
+soinfo* solist_get_head() {
+ return solist;
+}
+
+soinfo* solist_get_somain() {
+ return somain;
+}
+
+int g_ld_debug_verbosity;
+abort_msg_t* g_abort_message = nullptr; // For debuggerd.
+
+static std::vector<std::string> g_ld_preload_names;
+
+static std::vector<soinfo*> g_ld_preloads;
+
+static void parse_path(const char* path, const char* delimiters,
+ std::vector<std::string>* resolved_paths) {
+ std::vector<std::string> paths;
+ split_path(path, delimiters, &paths);
+ resolve_paths(paths, resolved_paths);
+}
+
+static void parse_LD_LIBRARY_PATH(const char* path) {
+ std::vector<std::string> ld_libary_paths;
+ parse_path(path, ":", &ld_libary_paths);
+ g_default_namespace->set_ld_library_paths(std::move(ld_libary_paths));
+}
+
+static void parse_LD_PRELOAD(const char* path) {
+ g_ld_preload_names.clear();
+ if (path != nullptr) {
+ // We have historically supported ':' as well as ' ' in LD_PRELOAD.
+ g_ld_preload_names = split(path, " :");
+ std::remove_if(g_ld_preload_names.begin(),
+ g_ld_preload_names.end(),
+ [] (const std::string& s) { return s.empty(); });
+ }
+}
+
+// An empty list of soinfos
+static soinfo_list_t g_empty_list;
+
+static void add_vdso(KernelArgumentBlock& args) {
+ ElfW(Ehdr)* ehdr_vdso = reinterpret_cast<ElfW(Ehdr)*>(args.getauxval(AT_SYSINFO_EHDR));
+ if (ehdr_vdso == nullptr) {
+ return;
+ }
+
+ soinfo* si = soinfo_alloc(g_default_namespace, "[vdso]", nullptr, 0, 0);
+
+ si->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
+ si->phnum = ehdr_vdso->e_phnum;
+ si->base = reinterpret_cast<ElfW(Addr)>(ehdr_vdso);
+ si->size = phdr_table_get_load_size(si->phdr, si->phnum);
+ si->load_bias = get_elf_exec_load_bias(ehdr_vdso);
+
+ si->prelink_image();
+ si->link_image(g_empty_list, soinfo_list_t::make_list(si), nullptr);
+}
+
+/* gdb expects the linker to be in the debug shared object list.
+ * Without this, gdb has trouble locating the linker's ".text"
+ * and ".plt" sections. Gdb could also potentially use this to
+ * relocate the offset of our exported 'rtld_db_dlactivity' symbol.
+ * Note that the linker shouldn't be on the soinfo list.
+ */
+static link_map linker_link_map;
+
+static void init_linker_info_for_gdb(ElfW(Addr) linker_base, char* linker_path) {
+ linker_link_map.l_addr = linker_base;
+ linker_link_map.l_name = linker_path;
+
+ /*
+ * Set the dynamic field in the link map otherwise gdb will complain with
+ * the following:
+ * warning: .dynamic section for "/system/bin/linker" is not at the
+ * expected address (wrong library or version mismatch?)
+ */
+ ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(linker_base);
+ ElfW(Phdr)* phdr = reinterpret_cast<ElfW(Phdr)*>(linker_base + elf_hdr->e_phoff);
+ phdr_table_get_dynamic_section(phdr, elf_hdr->e_phnum, linker_base,
+ &linker_link_map.l_ld, nullptr);
+
+}
+
+extern "C" int __system_properties_init(void);
+
+static const char* get_executable_path() {
+ static std::string executable_path;
+ if (executable_path.empty()) {
+ char path[PATH_MAX];
+ ssize_t path_len = readlink("/proc/self/exe", path, sizeof(path));
+ if (path_len == -1 || path_len >= static_cast<ssize_t>(sizeof(path))) {
+ async_safe_fatal("readlink('/proc/self/exe') failed: %s", strerror(errno));
+ }
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_main.h
^
|
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_MAIN_H
+#define __LINKER_MAIN_H
+
+#include <android/dlext.h>
+
+#include <unordered_map>
+#include <vector>
+
+#include "linker_namespaces.h"
+#include "linker_soinfo.h"
+
+class ProtectedDataGuard {
+ public:
+ ProtectedDataGuard();
+ ~ProtectedDataGuard();
+
+ private:
+ void protect_data(int protection);
+ static size_t ref_count_;
+};
+
+class ElfReader;
+
+std::vector<android_namespace_t*> init_default_namespaces(const char* executable_path);
+soinfo* soinfo_alloc(android_namespace_t* ns, const char* name,
+ struct stat* file_stat, off64_t file_offset,
+ uint32_t rtld_flags);
+
+bool find_libraries(android_namespace_t* ns,
+ soinfo* start_with,
+ const char* const library_names[],
+ size_t library_names_count,
+ soinfo* soinfos[],
+ std::vector<soinfo*>* ld_preloads,
+ size_t ld_preloads_count,
+ int rtld_flags,
+ const android_dlextinfo* extinfo,
+ bool add_as_children,
+ bool search_linked_namespaces,
+ std::unordered_map<const soinfo*, ElfReader>& readers_map,
+ std::vector<android_namespace_t*>* namespaces = nullptr);
+
+void solist_add_soinfo(soinfo* si);
+bool solist_remove_soinfo(soinfo* si);
+soinfo* solist_get_head();
+soinfo* solist_get_somain();
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_mapped_file_fragment.cpp
^
|
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_mapped_file_fragment.h"
+#include "linker_debug.h"
+#include "linker_utils.h"
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#include "hybris_compat.h"
+
+MappedFileFragment::MappedFileFragment() : map_start_(nullptr), map_size_(0),
+ data_(nullptr), size_ (0)
+{ }
+
+MappedFileFragment::~MappedFileFragment() {
+ if (map_start_ != nullptr) {
+ munmap(map_start_, map_size_);
+ }
+}
+
+bool MappedFileFragment::Map(int fd, off64_t base_offset, size_t elf_offset, size_t size) {
+ off64_t offset;
+ CHECK(safe_add(&offset, base_offset, elf_offset));
+
+ off64_t page_min = page_start(offset);
+ off64_t end_offset;
+
+ CHECK(safe_add(&end_offset, offset, size));
+ CHECK(safe_add(&end_offset, end_offset, page_offset(offset)));
+
+ size_t map_size = static_cast<size_t>(end_offset - page_min);
+ CHECK(map_size >= size);
+
+ uint8_t* map_start = static_cast<uint8_t*>(
+ mmap64(nullptr, map_size, PROT_READ, MAP_PRIVATE, fd, page_min));
+
+ if (map_start == MAP_FAILED) {
+ return false;
+ }
+
+ map_start_ = map_start;
+ map_size_ = map_size;
+
+ data_ = map_start + page_offset(offset);
+ size_ = size;
+
+ return true;
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_mapped_file_fragment.h
^
|
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef LINKER_MAPPED_FILE_FRAGMENT_H
+#define LINKER_MAPPED_FILE_FRAGMENT_H
+
+#include <unistd.h>
+
+#include "private/bionic_macros.h"
+
+class MappedFileFragment {
+ public:
+ MappedFileFragment();
+ ~MappedFileFragment();
+
+ bool Map(int fd, off64_t base_offset, size_t elf_offset, size_t size);
+
+ void* data() const { return data_; }
+ size_t size() const { return size_; }
+ private:
+ void* map_start_;
+ size_t map_size_;
+ void* data_;
+ size_t size_;
+
+ DISALLOW_COPY_AND_ASSIGN(MappedFileFragment);
+};
+
+#endif /* LINKER_MAPPED_FILE_FRAGMENT_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_memory.cpp
^
|
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_allocator.h"
+
+#include <stdlib.h>
+#include <sys/cdefs.h>
+#include <unistd.h>
+
+#include <async_safe/log.h>
+
+#if DISABLED_FOR_HYBRIS_SUPPORT
+static LinkerMemoryAllocator g_linker_allocator;
+static pid_t fallback_tid = 0;
+
+// Used by libdebuggerd_handler to switch allocators during a crash dump, in
+// case the linker heap is corrupted. Do not use this function.
+extern "C" void __linker_enable_fallback_allocator() {
+ if (fallback_tid != 0) {
+ async_safe_fatal("attempted to use currently-in-use fallback allocator");
+ }
+
+ fallback_tid = gettid();
+}
+
+extern "C" void __linker_disable_fallback_allocator() {
+ if (fallback_tid == 0) {
+ async_safe_fatal("attempted to disable unused fallback allocator");
+ }
+
+ fallback_tid = 0;
+}
+
+static LinkerMemoryAllocator& get_fallback_allocator() {
+ static LinkerMemoryAllocator fallback_allocator;
+ return fallback_allocator;
+}
+
+static LinkerMemoryAllocator& get_allocator() {
+ if (__predict_false(fallback_tid) && __predict_false(gettid() == fallback_tid)) {
+ return get_fallback_allocator();
+ }
+ return g_linker_allocator;
+}
+
+void* malloc(size_t byte_count) {
+ return get_allocator().alloc(byte_count);
+}
+
+void* calloc(size_t item_count, size_t item_size) {
+ return get_allocator().alloc(item_count*item_size);
+}
+
+void* realloc(void* p, size_t byte_count) {
+ return get_allocator().realloc(p, byte_count);
+}
+
+void free(void* ptr) {
+ get_allocator().free(ptr);
+}
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_namespaces.cpp
^
|
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_namespaces.h"
+#include "linker_globals.h"
+#include "linker_soinfo.h"
+#include "linker_utils.h"
+
+#include <dlfcn.h>
+
+#include "hybris_compat.h"
+
+bool android_namespace_t::is_accessible(const std::string& file) {
+ if (!is_isolated_) {
+ return true;
+ }
+
+ for (const auto& dir : ld_library_paths_) {
+ if (file_is_in_dir(file, dir)) {
+ return true;
+ }
+ }
+
+ for (const auto& dir : default_library_paths_) {
+ if (file_is_in_dir(file, dir)) {
+ return true;
+ }
+ }
+
+ for (const auto& dir : permitted_paths_) {
+ if (file_is_under_dir(file, dir)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool android_namespace_t::is_accessible(soinfo* s) {
+ auto is_accessible_ftor = [this] (soinfo* si) {
+ // This is workaround for apps hacking into soinfo list.
+ // and inserting their own entries into it. (http://b/37191433)
+ if (!si->has_min_version(3)) {
+ DL_WARN("invalid soinfo version for \"%s\"", si->get_soname());
+ return false;
+ }
+
+ if (si->get_primary_namespace() == this) {
+ return true;
+ }
+
+ const android_namespace_list_t& secondary_namespaces = si->get_secondary_namespaces();
+ if (secondary_namespaces.find(this) != secondary_namespaces.end()) {
+ return true;
+ }
+
+ return false;
+ };
+
+ if (is_accessible_ftor(s)) {
+ return true;
+ }
+
+ return !s->get_parents().visit([&](soinfo* si) {
+ return !is_accessible_ftor(si);
+ });
+}
+
+// TODO: this is slightly unusual way to construct
+// the global group for relocation. Not every RTLD_GLOBAL
+// library is included in this group for backwards-compatibility
+// reasons.
+//
+// This group consists of the main executable, LD_PRELOADs
+// and libraries with the DF_1_GLOBAL flag set.
+soinfo_list_t android_namespace_t::get_global_group() {
+ soinfo_list_t global_group;
+ soinfo_list().for_each([&](soinfo* si) {
+ if ((si->get_dt_flags_1() & DF_1_GLOBAL) != 0) {
+ global_group.push_back(si);
+ }
+ });
+
+ return global_group;
+}
+
+// This function provides a list of libraries to be shared
+// by the namespace. For the default namespace this is the global
+// group (see get_global_group). For all others this is a group
+// of RTLD_GLOBAL libraries (which includes the global group from
+// the default namespace).
+soinfo_list_t android_namespace_t::get_shared_group() {
+ if (this == g_default_namespace) {
+ return get_global_group();
+ }
+
+ soinfo_list_t shared_group;
+ soinfo_list().for_each([&](soinfo* si) {
+ if ((si->get_rtld_flags() & RTLD_GLOBAL) != 0) {
+ shared_group.push_back(si);
+ }
+ });
+
+ return shared_group;
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_namespaces.h
^
|
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_NAMESPACES_H
+#define __LINKER_NAMESPACES_H
+
+#include "linker_common_types.h"
+
+#include <string>
+#include <vector>
+#include <unordered_set>
+
+struct android_namespace_t;
+
+struct android_namespace_link_t {
+ public:
+ android_namespace_link_t(android_namespace_t* linked_namespace,
+ const std::unordered_set<std::string>& shared_lib_sonames)
+ : linked_namespace_(linked_namespace), shared_lib_sonames_(shared_lib_sonames)
+ {}
+
+ android_namespace_t* linked_namespace() const {
+ return linked_namespace_;
+ }
+
+ const std::unordered_set<std::string>& shared_lib_sonames() const {
+ return shared_lib_sonames_;
+ }
+
+ bool is_accessible(const char* soname) const {
+ return shared_lib_sonames_.find(soname) != shared_lib_sonames_.end();
+ }
+
+ private:
+ android_namespace_t* const linked_namespace_;
+ const std::unordered_set<std::string> shared_lib_sonames_;
+};
+
+struct android_namespace_t {
+ public:
+ android_namespace_t() : name_(nullptr), is_isolated_(false), is_greylist_enabled_(false) {}
+
+ const char* get_name() const { return name_; }
+ void set_name(const char* name) { name_ = name; }
+
+ bool is_isolated() const { return is_isolated_; }
+ void set_isolated(bool isolated) { is_isolated_ = isolated; }
+
+ bool is_greylist_enabled() const { return is_greylist_enabled_; }
+ void set_greylist_enabled(bool enabled) { is_greylist_enabled_ = enabled; }
+
+ const std::vector<std::string>& get_ld_library_paths() const {
+ return ld_library_paths_;
+ }
+ void set_ld_library_paths(std::vector<std::string>&& library_paths) {
+ ld_library_paths_ = library_paths;
+ }
+
+ const std::vector<std::string>& get_default_library_paths() const {
+ return default_library_paths_;
+ }
+ void set_default_library_paths(std::vector<std::string>&& library_paths) {
+ default_library_paths_ = library_paths;
+ }
+ void set_default_library_paths(const std::vector<std::string>& library_paths) {
+ default_library_paths_ = library_paths;
+ }
+
+ const std::vector<std::string>& get_permitted_paths() const {
+ return permitted_paths_;
+ }
+ void set_permitted_paths(std::vector<std::string>&& permitted_paths) {
+ permitted_paths_ = permitted_paths;
+ }
+ void set_permitted_paths(const std::vector<std::string>& permitted_paths) {
+ permitted_paths_ = permitted_paths;
+ }
+
+ const std::vector<android_namespace_link_t>& linked_namespaces() const {
+ return linked_namespaces_;
+ }
+ void add_linked_namespace(android_namespace_t* linked_namespace,
+ const std::unordered_set<std::string>& shared_lib_sonames) {
+ linked_namespaces_.push_back(android_namespace_link_t(linked_namespace, shared_lib_sonames));
+ }
+
+ void add_soinfo(soinfo* si) {
+ soinfo_list_.push_back(si);
+ }
+
+ void add_soinfos(const soinfo_list_t& soinfos) {
+ for (auto si : soinfos) {
+ add_soinfo(si);
+ }
+ }
+
+ void remove_soinfo(soinfo* si) {
+ soinfo_list_.remove_if([&](soinfo* candidate) {
+ return si == candidate;
+ });
+ }
+
+ const soinfo_list_t& soinfo_list() const { return soinfo_list_; }
+
+ // For isolated namespaces - checks if the file is on the search path;
+ // always returns true for not isolated namespace.
+ bool is_accessible(const std::string& path);
+
+ // Returns true if si is accessible from this namespace. A soinfo
+ // is considered accessible when it belongs to this namespace
+ // or one of it's parent soinfos belongs to this namespace.
+ bool is_accessible(soinfo* si);
+
+ soinfo_list_t get_global_group();
+ soinfo_list_t get_shared_group();
+
+ private:
+ const char* name_;
+ bool is_isolated_;
+ bool is_greylist_enabled_;
+ std::vector<std::string> ld_library_paths_;
+ std::vector<std::string> default_library_paths_;
+ std::vector<std::string> permitted_paths_;
+ // Loader looks into linked namespace if it was not able
+ // to find a library in this namespace. Note that library
+ // lookup in linked namespaces are limited by the list of
+ // shared sonames.
+ std::vector<android_namespace_link_t> linked_namespaces_;
+ soinfo_list_t soinfo_list_;
+
+ DISALLOW_COPY_AND_ASSIGN(android_namespace_t);
+};
+
+#endif /* __LINKER_NAMESPACES_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_phdr.cpp
^
|
@@ -0,0 +1,1118 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "hybris_compat.h"
+
+#include "linker_phdr.h"
+
+#include <errno.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "linker.h"
+#include "linker_dlwarning.h"
+#include "linker_globals.h"
+#include "linker_debug.h"
+#include "linker_utils.h"
+
+#include <android/api-level.h>
+#include "private/bionic_prctl.h"
+#include "private/CFIShadow.h" // For kLibraryAlignment
+
+static int GetTargetElfMachine() {
+#if defined(__arm__)
+ return EM_ARM;
+#elif defined(__aarch64__)
+ return EM_AARCH64;
+#elif defined(__i386__)
+ return EM_386;
+#elif defined(__mips__)
+ return EM_MIPS;
+#elif defined(__x86_64__)
+ return EM_X86_64;
+#endif
+}
+
+/**
+ TECHNICAL NOTE ON ELF LOADING.
+
+ An ELF file's program header table contains one or more PT_LOAD
+ segments, which corresponds to portions of the file that need to
+ be mapped into the process' address space.
+
+ Each loadable segment has the following important properties:
+
+ p_offset -> segment file offset
+ p_filesz -> segment file size
+ p_memsz -> segment memory size (always >= p_filesz)
+ p_vaddr -> segment's virtual address
+ p_flags -> segment flags (e.g. readable, writable, executable)
+
+ We will ignore the p_paddr and p_align fields of ElfW(Phdr) for now.
+
+ The loadable segments can be seen as a list of [p_vaddr ... p_vaddr+p_memsz)
+ ranges of virtual addresses. A few rules apply:
+
+ - the virtual address ranges should not overlap.
+
+ - if a segment's p_filesz is smaller than its p_memsz, the extra bytes
+ between them should always be initialized to 0.
+
+ - ranges do not necessarily start or end at page boundaries. Two distinct
+ segments can have their start and end on the same page. In this case, the
+ page inherits the mapping flags of the latter segment.
+
+ Finally, the real load addrs of each segment is not p_vaddr. Instead the
+ loader decides where to load the first segment, then will load all others
+ relative to the first one to respect the initial range layout.
+
+ For example, consider the following list:
+
+ [ offset:0, filesz:0x4000, memsz:0x4000, vaddr:0x30000 ],
+ [ offset:0x4000, filesz:0x2000, memsz:0x8000, vaddr:0x40000 ],
+
+ This corresponds to two segments that cover these virtual address ranges:
+
+ 0x30000...0x34000
+ 0x40000...0x48000
+
+ If the loader decides to load the first segment at address 0xa0000000
+ then the segments' load address ranges will be:
+
+ 0xa0030000...0xa0034000
+ 0xa0040000...0xa0048000
+
+ In other words, all segments must be loaded at an address that has the same
+ constant offset from their p_vaddr value. This offset is computed as the
+ difference between the first segment's load address, and its p_vaddr value.
+
+ However, in practice, segments do _not_ start at page boundaries. Since we
+ can only memory-map at page boundaries, this means that the bias is
+ computed as:
+
+ load_bias = phdr0_load_address - PAGE_START(phdr0->p_vaddr)
+
+ (NOTE: The value must be used as a 32-bit unsigned integer, to deal with
+ possible wrap around UINT32_MAX for possible large p_vaddr values).
+
+ And that the phdr0_load_address must start at a page boundary, with
+ the segment's real content starting at:
+
+ phdr0_load_address + PAGE_OFFSET(phdr0->p_vaddr)
+
+ Note that ELF requires the following condition to make the mmap()-ing work:
+
+ PAGE_OFFSET(phdr0->p_vaddr) == PAGE_OFFSET(phdr0->p_offset)
+
+ The load_bias must be added to any p_vaddr value read from the ELF file to
+ determine the corresponding memory address.
+
+ **/
+
+#define MAYBE_MAP_FLAG(x, from, to) (((x) & (from)) ? (to) : 0)
+#define PFLAGS_TO_PROT(x) (MAYBE_MAP_FLAG((x), PF_X, PROT_EXEC) | \
+ MAYBE_MAP_FLAG((x), PF_R, PROT_READ) | \
+ MAYBE_MAP_FLAG((x), PF_W, PROT_WRITE))
+
+ElfReader::ElfReader()
+ : did_read_(false), did_load_(false), fd_(-1), file_offset_(0), file_size_(0), phdr_num_(0),
+ phdr_table_(nullptr), shdr_table_(nullptr), shdr_num_(0), dynamic_(nullptr), strtab_(nullptr),
+ strtab_size_(0), load_start_(nullptr), load_size_(0), load_bias_(0), loaded_phdr_(nullptr),
+ mapped_by_caller_(false) {
+}
+
+bool ElfReader::Read(const char* name, int fd, off64_t file_offset, off64_t file_size) {
+ if (did_read_) {
+ return true;
+ }
+ name_ = name;
+ fd_ = fd;
+ file_offset_ = file_offset;
+ file_size_ = file_size;
+
+ if (ReadElfHeader() &&
+ VerifyElfHeader() &&
+ ReadProgramHeaders() &&
+ ReadSectionHeaders() &&
+ ReadDynamicSection()) {
+ did_read_ = true;
+ }
+
+ return did_read_;
+}
+
+bool ElfReader::Load(const android_dlextinfo* extinfo) {
+ CHECK(did_read_);
+ if (did_load_) {
+ return true;
+ }
+ if (ReserveAddressSpace(extinfo) &&
+ LoadSegments() &&
+ FindPhdr()) {
+ did_load_ = true;
+ }
+
+ return did_load_;
+}
+
+const char* ElfReader::get_string(ElfW(Word) index) const {
+ CHECK(strtab_ != nullptr);
+ CHECK(index < strtab_size_);
+
+ return strtab_ + index;
+}
+
+bool ElfReader::ReadElfHeader() {
+ ssize_t rc = TEMP_FAILURE_RETRY(pread64(fd_, &header_, sizeof(header_), file_offset_));
+ if (rc < 0) {
+ DL_ERR("can't read file \"%s\": %s", name_.c_str(), strerror(errno));
+ return false;
+ }
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_phdr.h
^
|
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef LINKER_PHDR_H
+#define LINKER_PHDR_H
+
+/* Declarations related to the ELF program header table and segments.
+ *
+ * The design goal is to provide an API that is as close as possible
+ * to the ELF spec, and does not depend on linker-specific data
+ * structures (e.g. the exact layout of struct soinfo).
+ */
+
+#include "linker.h"
+#include "linker_mapped_file_fragment.h"
+
+class ElfReader {
+ public:
+ ElfReader();
+
+ bool Read(const char* name, int fd, off64_t file_offset, off64_t file_size);
+ bool Load(const android_dlextinfo* extinfo);
+
+ const char* name() const { return name_.c_str(); }
+ size_t phdr_count() const { return phdr_num_; }
+ ElfW(Addr) load_start() const { return reinterpret_cast<ElfW(Addr)>(load_start_); }
+ size_t load_size() const { return load_size_; }
+ ElfW(Addr) load_bias() const { return load_bias_; }
+ const ElfW(Phdr)* loaded_phdr() const { return loaded_phdr_; }
+ const ElfW(Dyn)* dynamic() const { return dynamic_; }
+ const char* get_string(ElfW(Word) index) const;
+ bool is_mapped_by_caller() const { return mapped_by_caller_; }
+
+ private:
+ bool ReadElfHeader();
+ bool VerifyElfHeader();
+ bool ReadProgramHeaders();
+ bool ReadSectionHeaders();
+ bool ReadDynamicSection();
+ bool ReserveAddressSpace(const android_dlextinfo* extinfo);
+ bool LoadSegments();
+ bool FindPhdr();
+ bool CheckPhdr(ElfW(Addr));
+ bool CheckFileRange(ElfW(Addr) offset, size_t size, size_t alignment);
+
+ bool did_read_;
+ bool did_load_;
+ std::string name_;
+ int fd_;
+ off64_t file_offset_;
+ off64_t file_size_;
+
+ ElfW(Ehdr) header_;
+ size_t phdr_num_;
+
+ MappedFileFragment phdr_fragment_;
+ const ElfW(Phdr)* phdr_table_;
+
+ MappedFileFragment shdr_fragment_;
+ const ElfW(Shdr)* shdr_table_;
+ size_t shdr_num_;
+
+ MappedFileFragment dynamic_fragment_;
+ const ElfW(Dyn)* dynamic_;
+
+ MappedFileFragment strtab_fragment_;
+ const char* strtab_;
+ size_t strtab_size_;
+
+ // First page of reserved address space.
+ void* load_start_;
+ // Size in bytes of reserved address space.
+ size_t load_size_;
+ // Load bias.
+ ElfW(Addr) load_bias_;
+
+ // Loaded phdr.
+ const ElfW(Phdr)* loaded_phdr_;
+
+ // Is map owned by the caller
+ bool mapped_by_caller_;
+};
+
+size_t phdr_table_get_load_size(const ElfW(Phdr)* phdr_table, size_t phdr_count,
+ ElfW(Addr)* min_vaddr = nullptr, ElfW(Addr)* max_vaddr = nullptr);
+
+int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table,
+ size_t phdr_count, ElfW(Addr) load_bias);
+
+int phdr_table_unprotect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count,
+ ElfW(Addr) load_bias);
+
+int phdr_table_protect_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count,
+ ElfW(Addr) load_bias);
+
+int phdr_table_serialize_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count,
+ ElfW(Addr) load_bias, int fd);
+
+int phdr_table_map_gnu_relro(const ElfW(Phdr)* phdr_table, size_t phdr_count,
+ ElfW(Addr) load_bias, int fd);
+
+#if defined(__arm__)
+int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias,
+ ElfW(Addr)** arm_exidx, size_t* arm_exidix_count);
+#endif
+
+void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_count,
+ ElfW(Addr) load_bias, ElfW(Dyn)** dynamic,
+ ElfW(Word)* dynamic_flags);
+
+const char* phdr_table_get_interpreter_name(const ElfW(Phdr) * phdr_table, size_t phdr_count,
+ ElfW(Addr) load_bias);
+
+#endif /* LINKER_PHDR_H */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_reloc_iterators.h
^
|
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_RELOC_ITERATORS_H
+#define __LINKER_RELOC_ITERATORS_H
+
+#include "linker.h"
+
+#include <string.h>
+
+const size_t RELOCATION_GROUPED_BY_INFO_FLAG = 1;
+const size_t RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG = 2;
+const size_t RELOCATION_GROUPED_BY_ADDEND_FLAG = 4;
+const size_t RELOCATION_GROUP_HAS_ADDEND_FLAG = 8;
+
+class plain_reloc_iterator {
+#if defined(USE_RELA)
+ typedef ElfW(Rela) rel_t;
+#else
+ typedef ElfW(Rel) rel_t;
+#endif
+ public:
+ plain_reloc_iterator(rel_t* rel_array, size_t count)
+ : begin_(rel_array), end_(begin_ + count), current_(begin_) {}
+
+ bool has_next() {
+ return current_ < end_;
+ }
+
+ rel_t* next() {
+ return current_++;
+ }
+ private:
+ rel_t* const begin_;
+ rel_t* const end_;
+ rel_t* current_;
+
+ DISALLOW_COPY_AND_ASSIGN(plain_reloc_iterator);
+};
+
+template <typename decoder_t>
+class packed_reloc_iterator {
+#if defined(USE_RELA)
+ typedef ElfW(Rela) rel_t;
+#else
+ typedef ElfW(Rel) rel_t;
+#endif
+ public:
+ explicit packed_reloc_iterator(decoder_t&& decoder)
+ : decoder_(decoder) {
+ // initialize fields
+ memset(&reloc_, 0, sizeof(reloc_));
+ relocation_count_ = decoder_.pop_front();
+ reloc_.r_offset = decoder_.pop_front();
+ relocation_index_ = 0;
+ relocation_group_index_ = 0;
+ group_size_ = 0;
+ }
+
+ bool has_next() const {
+ return relocation_index_ < relocation_count_;
+ }
+
+ rel_t* next() {
+ if (relocation_group_index_ == group_size_) {
+ if (!read_group_fields()) {
+ // Iterator is inconsistent state; it should not be called again
+ // but in case it is let's make sure has_next() returns false.
+ relocation_index_ = relocation_count_ = 0;
+ return nullptr;
+ }
+ }
+
+ if (is_relocation_grouped_by_offset_delta()) {
+ reloc_.r_offset += group_r_offset_delta_;
+ } else {
+ reloc_.r_offset += decoder_.pop_front();
+ }
+
+ if (!is_relocation_grouped_by_info()) {
+ reloc_.r_info = decoder_.pop_front();
+ }
+
+#if defined(USE_RELA)
+ if (is_relocation_group_has_addend() &&
+ !is_relocation_grouped_by_addend()) {
+ reloc_.r_addend += decoder_.pop_front();
+ }
+#endif
+
+ relocation_index_++;
+ relocation_group_index_++;
+
+ return &reloc_;
+ }
+ private:
+ bool read_group_fields() {
+ group_size_ = decoder_.pop_front();
+ group_flags_ = decoder_.pop_front();
+
+ if (is_relocation_grouped_by_offset_delta()) {
+ group_r_offset_delta_ = decoder_.pop_front();
+ }
+
+ if (is_relocation_grouped_by_info()) {
+ reloc_.r_info = decoder_.pop_front();
+ }
+
+ if (is_relocation_group_has_addend() &&
+ is_relocation_grouped_by_addend()) {
+#if !defined(USE_RELA)
+ // This platform does not support rela, and yet we have it encoded in android_rel section.
+ DL_ERR("unexpected r_addend in android.rel section");
+ return false;
+#else
+ reloc_.r_addend += decoder_.pop_front();
+ } else if (!is_relocation_group_has_addend()) {
+ reloc_.r_addend = 0;
+#endif
+ }
+
+ relocation_group_index_ = 0;
+ return true;
+ }
+
+ bool is_relocation_grouped_by_info() {
+ return (group_flags_ & RELOCATION_GROUPED_BY_INFO_FLAG) != 0;
+ }
+
+ bool is_relocation_grouped_by_offset_delta() {
+ return (group_flags_ & RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG) != 0;
+ }
+
+ bool is_relocation_grouped_by_addend() {
+ return (group_flags_ & RELOCATION_GROUPED_BY_ADDEND_FLAG) != 0;
+ }
+
+ bool is_relocation_group_has_addend() {
+ return (group_flags_ & RELOCATION_GROUP_HAS_ADDEND_FLAG) != 0;
+ }
+
+ decoder_t decoder_;
+ size_t relocation_count_;
+ size_t group_size_;
+ size_t group_flags_;
+ size_t group_r_offset_delta_;
+ size_t relocation_index_;
+ size_t relocation_group_index_;
+ rel_t reloc_;
+};
+
+#endif // __LINKER_RELOC_ITERATORS_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_relocs.h
^
|
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_RELOCS_H
+#define __LINKER_RELOCS_H
+
+#include <elf.h>
+
+#define R_GENERIC_NONE 0 // R_*_NONE is always 0
+
+#if defined (__aarch64__)
+
+#define R_GENERIC_JUMP_SLOT R_AARCH64_JUMP_SLOT
+#define R_GENERIC_GLOB_DAT R_AARCH64_GLOB_DAT
+#define R_GENERIC_RELATIVE R_AARCH64_RELATIVE
+#define R_GENERIC_IRELATIVE R_AARCH64_IRELATIVE
+
+#elif defined (__arm__)
+
+#define R_GENERIC_JUMP_SLOT R_ARM_JUMP_SLOT
+#define R_GENERIC_GLOB_DAT R_ARM_GLOB_DAT
+#define R_GENERIC_RELATIVE R_ARM_RELATIVE
+#define R_GENERIC_IRELATIVE R_ARM_IRELATIVE
+
+#elif defined (__i386__)
+
+#define R_GENERIC_JUMP_SLOT R_386_JMP_SLOT
+#define R_GENERIC_GLOB_DAT R_386_GLOB_DAT
+#define R_GENERIC_RELATIVE R_386_RELATIVE
+#define R_GENERIC_IRELATIVE R_386_IRELATIVE
+
+#elif defined (__x86_64__)
+
+#define R_GENERIC_JUMP_SLOT R_X86_64_JUMP_SLOT
+#define R_GENERIC_GLOB_DAT R_X86_64_GLOB_DAT
+#define R_GENERIC_RELATIVE R_X86_64_RELATIVE
+#define R_GENERIC_IRELATIVE R_X86_64_IRELATIVE
+
+#endif
+
+#endif // __LINKER_RELOCS_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_sdk_versions.cpp
^
|
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker.h"
+#include <android/api-level.h>
+#include <atomic>
+
+static std::atomic<uint32_t> g_target_sdk_version(__ANDROID_API__);
+
+void set_application_target_sdk_version(uint32_t target) {
+ // translate current sdk_version to platform sdk_version
+ if (target == 0) {
+ target = __ANDROID_API__;
+ }
+ g_target_sdk_version = target;
+}
+
+uint32_t get_application_target_sdk_version() {
+ return g_target_sdk_version;
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_sleb128.h
^
|
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _LINKER_SLEB128_H
+#define _LINKER_SLEB128_H
+
+#include <stdint.h>
+
+#include <async_safe/log.h>
+
+#include "linker_debug.h"
+
+// Helper classes for decoding LEB128, used in packed relocation data.
+// http://en.wikipedia.org/wiki/LEB128
+
+class sleb128_decoder {
+ public:
+ sleb128_decoder(const uint8_t* buffer, size_t count)
+ : current_(buffer), end_(buffer+count) { }
+
+ size_t pop_front() {
+ size_t value = 0;
+ static const size_t size = CHAR_BIT * sizeof(value);
+
+ size_t shift = 0;
+ uint8_t byte;
+
+ do {
+ if (current_ >= end_) {
+ async_safe_fatal("sleb128_decoder ran out of bounds");
+ }
+ byte = *current_++;
+ value |= (static_cast<size_t>(byte & 127) << shift);
+ shift += 7;
+ } while (byte & 128);
+
+ if (shift < size && (byte & 64)) {
+ value |= -(static_cast<size_t>(1) << shift);
+ }
+
+ return value;
+ }
+
+ private:
+ const uint8_t* current_;
+ const uint8_t* const end_;
+};
+
+#endif // __LINKER_SLEB128_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_soinfo.cpp
^
|
@@ -0,0 +1,811 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_soinfo.h"
+
+#include <dlfcn.h>
+#include <elf.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <async_safe/log.h>
+#include <android/api-level.h>
+
+#include "linker_debug.h"
+#include "linker_globals.h"
+#include "linker_logger.h"
+#include "linker_utils.h"
+
+#include "hybris_compat.h"
+
+#define ELF_ST_TYPE(x) ((x) & 0xf)
+
+// TODO(dimitry): These functions are currently located in linker.cpp - find a better place for it
+bool find_verdef_version_index(const soinfo* si, const version_info* vi, ElfW(Versym)* versym);
+ElfW(Addr) call_ifunc_resolver(ElfW(Addr) resolver_addr);
+uint32_t get_application_target_sdk_version();
+
+soinfo::soinfo(android_namespace_t* ns, const char* realpath,
+ const struct stat* file_stat, off64_t file_offset,
+ int rtld_flags) {
+
+ if (realpath != nullptr) {
+ realpath_ = realpath;
+ }
+
+ flags_ = FLAG_NEW_SOINFO;
+ version_ = SOINFO_VERSION;
+
+ if (file_stat != nullptr) {
+ this->st_dev_ = file_stat->st_dev;
+ this->st_ino_ = file_stat->st_ino;
+ this->file_offset_ = file_offset;
+ }
+
+ this->rtld_flags_ = rtld_flags;
+ this->primary_namespace_ = ns;
+}
+
+soinfo::~soinfo() {
+ g_soinfo_handles_map.erase(handle_);
+}
+
+void soinfo::set_dt_runpath(const char* path) {
+ if (!has_min_version(3)) {
+ return;
+ }
+
+ std::vector<std::string> runpaths;
+
+ split_path(path, ":", &runpaths);
+
+ std::string origin = dirname(get_realpath());
+ // FIXME: add $LIB and $PLATFORM.
+ std::vector<std::pair<std::string, std::string>> params = {{"ORIGIN", origin}};
+ for (auto&& s : runpaths) {
+ format_string(&s, params);
+ }
+
+ resolve_paths(runpaths, &dt_runpath_);
+}
+
+const ElfW(Versym)* soinfo::get_versym(size_t n) const {
+ if (has_min_version(2) && versym_ != nullptr) {
+ return versym_ + n;
+ }
+
+ return nullptr;
+}
+
+ElfW(Addr) soinfo::get_verneed_ptr() const {
+ if (has_min_version(2)) {
+ return verneed_ptr_;
+ }
+
+ return 0;
+}
+
+size_t soinfo::get_verneed_cnt() const {
+ if (has_min_version(2)) {
+ return verneed_cnt_;
+ }
+
+ return 0;
+}
+
+ElfW(Addr) soinfo::get_verdef_ptr() const {
+ if (has_min_version(2)) {
+ return verdef_ptr_;
+ }
+
+ return 0;
+}
+
+size_t soinfo::get_verdef_cnt() const {
+ if (has_min_version(2)) {
+ return verdef_cnt_;
+ }
+
+ return 0;
+}
+
+bool soinfo::find_symbol_by_name(SymbolName& symbol_name,
+ const version_info* vi,
+ const ElfW(Sym)** symbol) const {
+ uint32_t symbol_index;
+ bool success =
+ is_gnu_hash() ?
+ gnu_lookup(symbol_name, vi, &symbol_index) :
+ elf_lookup(symbol_name, vi, &symbol_index);
+
+ if (success) {
+ *symbol = symbol_index == 0 ? nullptr : symtab_ + symbol_index;
+ }
+
+ return success;
+}
+
+static bool is_symbol_global_and_defined(const soinfo* si, const ElfW(Sym)* s) {
+ if (ELF_ST_BIND(s->st_info) == STB_GLOBAL ||
+ ELF_ST_BIND(s->st_info) == STB_WEAK) {
+ return s->st_shndx != SHN_UNDEF;
+ } else if (ELF_ST_BIND(s->st_info) != STB_LOCAL) {
+ DL_WARN("unexpected ST_BIND value: %d for \"%s\" in \"%s\"",
+ ELF_ST_BIND(s->st_info), si->get_string(s->st_name), si->get_realpath());
+ }
+
+ return false;
+}
+
+static const ElfW(Versym) kVersymHiddenBit = 0x8000;
+
+static inline bool is_versym_hidden(const ElfW(Versym)* versym) {
+ // the symbol is hidden if bit 15 of versym is set.
+ return versym != nullptr && (*versym & kVersymHiddenBit) != 0;
+}
+
+static inline bool check_symbol_version(const ElfW(Versym) verneed,
+ const ElfW(Versym)* verdef) {
+ return verneed == kVersymNotNeeded ||
+ verdef == nullptr ||
+ verneed == (*verdef & ~kVersymHiddenBit);
+}
+
+bool soinfo::gnu_lookup(SymbolName& symbol_name,
+ const version_info* vi,
+ uint32_t* symbol_index) const {
+ uint32_t hash = symbol_name.gnu_hash();
+ uint32_t h2 = hash >> gnu_shift2_;
+
+ uint32_t bloom_mask_bits = sizeof(ElfW(Addr))*8;
+ uint32_t word_num = (hash / bloom_mask_bits) & gnu_maskwords_;
+ ElfW(Addr) bloom_word = gnu_bloom_filter_[word_num];
+
+ *symbol_index = 0;
+
+ TRACE_TYPE(LOOKUP, "SEARCH %s in %s@%p (gnu)",
+ symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
+
+ // test against bloom filter
+ if ((1 & (bloom_word >> (hash % bloom_mask_bits)) & (bloom_word >> (h2 % bloom_mask_bits))) == 0) {
+ TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
+ symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_soinfo.h
^
|
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_SOINFO_H
+#define __LINKER_SOINFO_H
+
+#include <link.h>
+
+#include <string>
+
+#include "linker_namespaces.h"
+
+#define FLAG_LINKED 0x00000001
+#define FLAG_EXE 0x00000004 // The main executable
+#define FLAG_LINKER 0x00000010 // The linker itself
+#define FLAG_GNU_HASH 0x00000040 // uses gnu hash
+#define FLAG_MAPPED_BY_CALLER 0x00000080 // the map is reserved by the caller
+ // and should not be unmapped
+#define FLAG_NEW_SOINFO 0x40000000 // new soinfo format
+
+#define SOINFO_VERSION 3
+
+typedef void (*linker_dtor_function_t)();
+typedef void (*linker_ctor_function_t)(int, char**, char**);
+
+class SymbolName {
+ public:
+ explicit SymbolName(const char* name)
+ : name_(name), has_elf_hash_(false), has_gnu_hash_(false),
+ elf_hash_(0), gnu_hash_(0) { }
+
+ const char* get_name() {
+ return name_;
+ }
+
+ uint32_t elf_hash();
+ uint32_t gnu_hash();
+
+ private:
+ const char* name_;
+ bool has_elf_hash_;
+ bool has_gnu_hash_;
+ uint32_t elf_hash_;
+ uint32_t gnu_hash_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolName);
+};
+
+struct version_info {
+ constexpr version_info() : elf_hash(0), name(nullptr), target_si(nullptr) {}
+
+ uint32_t elf_hash;
+ const char* name;
+ const soinfo* target_si;
+};
+
+// TODO(dimitry): remove reference from soinfo member functions to this class.
+class VersionTracker;
+
+#if defined(__work_around_b_24465209__)
+#define SOINFO_NAME_LEN 128
+#endif
+
+struct soinfo {
+#if defined(__work_around_b_24465209__)
+ private:
+ char old_name_[SOINFO_NAME_LEN];
+#endif
+ public:
+ const ElfW(Phdr)* phdr;
+ size_t phnum;
+#if defined(__work_around_b_24465209__)
+ ElfW(Addr) unused0; // DO NOT USE, maintained for compatibility.
+#endif
+ ElfW(Addr) base;
+ size_t size;
+
+#if defined(__work_around_b_24465209__)
+ uint32_t unused1; // DO NOT USE, maintained for compatibility.
+#endif
+
+ ElfW(Dyn)* dynamic;
+
+#if defined(__work_around_b_24465209__)
+ uint32_t unused2; // DO NOT USE, maintained for compatibility
+ uint32_t unused3; // DO NOT USE, maintained for compatibility
+#endif
+
+ soinfo* next;
+ private:
+ uint32_t flags_;
+
+ const char* strtab_;
+ ElfW(Sym)* symtab_;
+
+ size_t nbucket_;
+ size_t nchain_;
+ uint32_t* bucket_;
+ uint32_t* chain_;
+
+#if defined(__mips__) || !defined(__LP64__)
+ // This is only used by mips and mips64, but needs to be here for
+ // all 32-bit architectures to preserve binary compatibility.
+ ElfW(Addr)** plt_got_;
+#endif
+
+#if defined(USE_RELA)
+ ElfW(Rela)* plt_rela_;
+ size_t plt_rela_count_;
+
+ ElfW(Rela)* rela_;
+ size_t rela_count_;
+#else
+ ElfW(Rel)* plt_rel_;
+ size_t plt_rel_count_;
+
+ ElfW(Rel)* rel_;
+ size_t rel_count_;
+#endif
+
+ linker_ctor_function_t* preinit_array_;
+ size_t preinit_array_count_;
+
+ linker_ctor_function_t* init_array_;
+ size_t init_array_count_;
+ linker_dtor_function_t* fini_array_;
+ size_t fini_array_count_;
+
+ linker_ctor_function_t init_func_;
+ linker_dtor_function_t fini_func_;
+
+#if defined(__arm__)
+ public:
+ // ARM EABI section used for stack unwinding.
+ uint32_t* ARM_exidx;
+ size_t ARM_exidx_count;
+ private:
+#elif defined(__mips__)
+ uint32_t mips_symtabno_;
+ uint32_t mips_local_gotno_;
+ uint32_t mips_gotsym_;
+ bool mips_relocate_got(const VersionTracker& version_tracker,
+ const soinfo_list_t& global_group,
+ const soinfo_list_t& local_group);
+#if !defined(__LP64__)
+ bool mips_check_and_adjust_fp_modes();
+#endif
+#endif
+ size_t ref_count_;
+ public:
+ link_map link_map_head;
+
+ bool constructors_called;
+
+ // When you read a virtual address from the ELF file, add this
+ // value to get the corresponding address in the process' address space.
+ ElfW(Addr) load_bias;
+
+#if !defined(__LP64__)
+ bool has_text_relocations;
+#endif
+ bool has_DT_SYMBOLIC;
+
+ public:
+ soinfo(android_namespace_t* ns, const char* name, const struct stat* file_stat,
+ off64_t file_offset, int rtld_flags);
+ ~soinfo();
+
+ void call_constructors();
+ void call_destructors();
+ void call_pre_init_constructors();
+ bool prelink_image();
+ bool link_image(const soinfo_list_t& global_group, const soinfo_list_t& local_group,
+ const android_dlextinfo* extinfo);
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_utils.cpp
^
|
@@ -0,0 +1,402 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "linker_utils.h"
+
+#include "linker_debug.h"
+#include "linker_globals.h"
+
+#include <android-base/file.h>
+#include <android-base/unique_fd.h>
+
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <linux/limits.h>
+
+#include <algorithm>
+#include <sstream>
+
+#include "hybris_compat.h"
+
+std::string trim(const std::string& s) {
+ std::string result;
+
+ if (s.size() == 0) {
+ return result;
+ }
+
+ size_t start_index = 0;
+ size_t end_index = s.size() - 1;
+
+ // Skip initial whitespace.
+ while (start_index < s.size()) {
+ if (!isspace(s[start_index])) {
+ break;
+ }
+ start_index++;
+ }
+
+ // Skip terminating whitespace.
+ while (end_index >= start_index) {
+ if (!isspace(s[end_index])) {
+ break;
+ }
+ end_index--;
+ }
+
+ // All spaces, no beef.
+ if (end_index < start_index) {
+ return "";
+ }
+ // Start_index is the first non-space, end_index is the last one.
+ return s.substr(start_index, end_index - start_index + 1);
+}
+
+std::vector<std::string> split(const std::string &text, const std::string &sep) {
+ std::vector<std::string> tokens;
+ std::size_t start = 0, end = 0;
+ while ((end = text.find(sep, start)) != std::string::npos) {
+ tokens.push_back(text.substr(start, end - start));
+ start = end + 1;
+ }
+ tokens.push_back(text.substr(start));
+ return tokens;
+}
+
+std::string join(const std::vector<std::string>& things, char separator) {
+ if (things.empty()) {
+ return "";
+ }
+ std::ostringstream result;
+ result << *things.begin();
+ for (auto it = std::next(things.begin()); it != things.end(); ++it) {
+ result << separator << *it;
+ }
+ return result.str();
+}
+
+void format_string(std::string* str, const std::vector<std::pair<std::string, std::string>>& params) {
+ size_t pos = 0;
+ while (pos < str->size()) {
+ pos = str->find("$", pos);
+ if (pos == std::string::npos) break;
+ for (const auto& param : params) {
+ const std::string& token = param.first;
+ const std::string& replacement = param.second;
+ if (str->substr(pos + 1, token.size()) == token) {
+ str->replace(pos, token.size() + 1, replacement);
+ // -1 to compensate for the ++pos below.
+ pos += replacement.size() - 1;
+ break;
+ } else if (str->substr(pos + 1, token.size() + 2) == "{" + token + "}") {
+ str->replace(pos, token.size() + 3, replacement);
+ pos += replacement.size() - 1;
+ break;
+ }
+ }
+ // Skip $ in case it did not match any of the known substitutions.
+ ++pos;
+ }
+}
+
+std::string dirname(const char* path) {
+ const char* last_slash = strrchr(path, '/');
+
+ if (last_slash == path) {
+ return "/";
+ } else if (last_slash == nullptr) {
+ return ".";
+ } else {
+ return std::string(path, last_slash - path);
+ }
+}
+
+bool normalize_path(const char* path, std::string* normalized_path) {
+ // Input should be an absolute path
+ if (path[0] != '/') {
+ PRINT("normalize_path - invalid input: \"%s\", the input path should be absolute", path);
+ return false;
+ }
+
+ const size_t len = strlen(path) + 1;
+ char buf[len];
+
+ const char* in_ptr = path;
+ char* out_ptr = buf;
+
+ while (*in_ptr != 0) {
+ if (*in_ptr == '/') {
+ char c1 = in_ptr[1];
+ if (c1 == '.') {
+ char c2 = in_ptr[2];
+ if (c2 == '/') {
+ in_ptr += 2;
+ continue;
+ } else if (c2 == '.' && (in_ptr[3] == '/' || in_ptr[3] == 0)) {
+ in_ptr += 3;
+ while (out_ptr > buf && *--out_ptr != '/') {
+ }
+ if (in_ptr[0] == 0) {
+ // retain '/'
+ out_ptr++;
+ }
+ continue;
+ }
+ } else if (c1 == '/') {
+ ++in_ptr;
+ continue;
+ }
+ }
+ *out_ptr++ = *in_ptr++;
+ }
+
+ *out_ptr = 0;
+ *normalized_path = buf;
+ return true;
+}
+
+bool file_is_in_dir(const std::string& file, const std::string& dir) {
+ const char* needle = dir.c_str();
+ const char* haystack = file.c_str();
+ size_t needle_len = strlen(needle);
+
+ return strncmp(haystack, needle, needle_len) == 0 &&
+ haystack[needle_len] == '/' &&
+ strchr(haystack + needle_len + 1, '/') == nullptr;
+}
+
+bool file_is_under_dir(const std::string& file, const std::string& dir) {
+ const char* needle = dir.c_str();
+ const char* haystack = file.c_str();
+ size_t needle_len = strlen(needle);
+
+ return strncmp(haystack, needle, needle_len) == 0 &&
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/linker_utils.h
^
|
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef __LINKER_UTILS_H
+#define __LINKER_UTILS_H
+
+#include <cstdarg>
+#include <string>
+#include <vector>
+
+extern const char* const kZipFileSeparator;
+
+std::string trim(const std::string& s);
+std::vector<std::string> split(const std::string &text, const std::string &sep);
+std::string join(const std::vector<std::string>& things, char separator);
+
+void format_string(std::string* str, const std::vector<std::pair<std::string, std::string>>& params);
+
+bool file_is_in_dir(const std::string& file, const std::string& dir);
+bool file_is_under_dir(const std::string& file, const std::string& dir);
+bool normalize_path(const char* path, std::string* normalized_path);
+bool parse_zip_path(const char* input_path, std::string* zip_path, std::string* entry_path);
+
+// For every path element this function checks of it exists, and is a directory,
+// and normalizes it:
+// 1. For regular path it converts it to realpath()
+// 2. For path in a zip file it uses realpath on the zipfile
+// normalizes entry name by calling normalize_path function.
+void resolve_paths(std::vector<std::string>& paths,
+ std::vector<std::string>* resolved_paths);
+
+void split_path(const char* path, const char* delimiters, std::vector<std::string>* paths);
+
+std::string dirname(const char* path);
+
+off64_t page_start(off64_t offset);
+size_t page_offset(off64_t offset);
+bool safe_add(off64_t* out, off64_t a, size_t b);
+
+void stringAppendV(std::string* dst, const char* format, va_list ap);
+std::string stringPrintf(const char* fmt, ...);
+void stringAppendF(std::string* dst, const char* format, ...);
+
+#define CHECK(predicate) \
+ do { \
+ if (!(predicate)) { \
+ fprintf(stderr, "%s:%d: %s CHECK '" #predicate "' failed", \
+ __FILE__, __LINE__, __FUNCTION__); \
+ } \
+ } while(0)
+
+bool readFileToString(const std::string& path, std::string* content, bool follow_symlinks = false);
+
+bool startsWith(const std::string& s, const char* prefix);
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/common/o/rt.cpp
^
|
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * This function is an empty stub where GDB locates a breakpoint to get notified
+ * about linker activity. It canʼt be inlined away, can't be hidden.
+ */
+extern "C" void __attribute__((noinline)) __attribute__((visibility("default"))) rtld_db_dlactivity() {
+}
+
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/configure.ac
^
|
@@ -60,11 +60,11 @@
[trace="no"])
AM_CONDITIONAL( [WANT_TRACE], [test x"$trace" = x"yes"])
-AC_ARG_ENABLE(mm_arm_tracing,
- [ --enable-mm-arm-tracing Enable ARM (32-bit only) tracing, useful for understanding what the blob is doing, currently only the mm linker is supported. (default=disabled)],
- [mm_arm_tracing=$enableval],
- [mm_arm_tracing="no"])
-AM_CONDITIONAL([WANT_ARM_TRACING], [test x"$mm_arm_tracing" = x"yes"])
+AC_ARG_ENABLE(arm_tracing,
+ [ --enable-arm-tracing Enable ARM (32-bit only) tracing, useful for understanding what the blob is doing, currently only the mm linker is supported. (default=disabled)],
+ [arm_tracing=$enableval],
+ [arm_tracing="no"])
+AM_CONDITIONAL([WANT_ARM_TRACING], [test x"$arm_tracing" = x"yes"])
AC_ARG_ENABLE(mesa,
[ --enable-mesa Enable mesa headers (default=disabled)],
@@ -151,12 +151,20 @@
[ --with-android-headers=DIR Use android headers available in DIR. See utils/extract-headers.sh ],
[
AM_CONDITIONAL([HAS_LIBNFC_NXP_HEADERS], [test -f $withval/libnfc-nxp/phLibNfc.h])
+ AM_CONDITIONAL([HAS_WIFI_LEGACY_HEADERS], [test -f $withval/hardware_legacy/wifi.h])
+ AM_CONDITIONAL([HAS_HWCOMPOSER2_HEADERS], [test -f $withval/hardware/hwcomposer2.h])
+ AM_CONDITIONAL([HAS_GRALLOC1_HEADER], [test -f $withval/hardware/gralloc1.h])
+ AM_CONDITIONAL([HAS_VIBRATOR_HEADER], [test -f $withval/hardware_legacy/vibrator.h])
AS_IF([test -f $withval/libnfc-nxp/phLibNfc.h], [ANDROID_HEADERS_CFLAGS="-I$withval -I$withval/libnfc-nxp"],[ANDROID_HEADERS_CFLAGS="-I$withval"])
AC_SUBST([ANDROID_HEADERS_CFLAGS])
],
[
PKG_CHECK_MODULES(ANDROID_HEADERS, android-headers,, exit)
AM_CONDITIONAL([HAS_LIBNFC_NXP_HEADERS], [false])
+ AM_CONDITIONAL([HAS_WIFI_LEGACY_HEADERS], [false])
+ AM_CONDITIONAL([HAS_HWCOMPOSER2_HEADERS], [false])
+ AM_CONDITIONAL([HAS_GRALLOC1_HEADER], [false])
+ AM_CONDITIONAL([HAS_VIBRATOR_HEADER], [false])
]
)
CPPFLAGS="$CPPFLAGS $ANDROID_HEADERS_CFLAGS"
@@ -214,6 +222,7 @@
AC_MSG_NOTICE("Android headers version is $android_headers_major.$android_headers_minor.$android_headers_patch")
# Add automake tests for version/API needs here that you need in code, including test .am's
+AM_CONDITIONAL([HAS_ANDROID_8_0_0], [test $android_headers_major -ge 8 -a $android_headers_minor -ge 0 ])
AM_CONDITIONAL([HAS_ANDROID_7_0_0], [test $android_headers_major -ge 7 -a $android_headers_minor -ge 0 ])
AM_CONDITIONAL([HAS_ANDROID_6_0_0], [test $android_headers_major -ge 6 -a $android_headers_minor -ge 0 ])
AM_CONDITIONAL([HAS_ANDROID_5_0_0], [test $android_headers_major -ge 5 -a $android_headers_minor -ge 0 ])
@@ -246,6 +255,7 @@
common/stub/Makefile
common/mm/Makefile
common/n/Makefile
+ common/o/Makefile
egl/egl.pc
egl/Makefile
egl/platforms/Makefile
@@ -262,6 +272,8 @@
glesv2/Makefile
hardware/Makefile
hardware/libhardware.pc
+ gralloc/Makefile
+ gralloc/libgralloc.pc
libnfc_nxp/Makefile
libnfc_nxp/libnfc_nxp.pc
libnfc_ndef_nxp/Makefile
@@ -281,6 +293,8 @@
utils/Makefile
sf/Makefile
sf/libsf.pc
+ hwc2/Makefile
+ hwc2/libhwc2.pc
opencl/Makefile
opencl/OpenCL.pc
tests/Makefile
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/eglhybris.h
^
|
@@ -18,7 +18,6 @@
#ifndef EGL_HYBRIS_H_
#define EGL_HYBRIS_H_
-#include <hardware/gralloc.h>
/* Needed for ICS window.h */
#include <string.h>
#include <system/window.h>
@@ -27,8 +26,6 @@
extern "C" {
#endif
-int hybris_register_buffer_handle(buffer_handle_t handle);
-int hybris_unregister_buffer_handle(buffer_handle_t handle);
void hybris_dump_buffer_to_file(struct ANativeWindowBuffer *buf);
void *hybris_android_egl_dlsym(const char *symbol);
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/eglplatformcommon.cpp
^
|
@@ -3,7 +3,6 @@
#include <stdlib.h>
#include <dlfcn.h>
#include <string.h>
-#include <hardware/gralloc.h>
#include <stdio.h>
#include <assert.h>
#include "config.h"
@@ -22,15 +21,13 @@
#include "windowbuffer.h"
+#include <hybris/gralloc/gralloc.h>
+
static struct ws_egl_interface *my_egl_interface;
-static gralloc_module_t *my_gralloc = 0;
-static alloc_device_t *my_alloc = 0;
-extern "C" void eglplatformcommon_init(struct ws_egl_interface *egl_iface, gralloc_module_t *gralloc, alloc_device_t *allocdevice)
+extern "C" void eglplatformcommon_init(struct ws_egl_interface *egl_iface)
{
my_egl_interface = egl_iface;
- my_gralloc = gralloc;
- my_alloc = allocdevice;
}
extern "C" void *hybris_android_egl_dlsym(const char *symbol)
@@ -48,27 +45,11 @@
return (*my_egl_interface->get_mapping)(surface);
}
-extern "C" int hybris_register_buffer_handle(buffer_handle_t handle)
-{
- if (!my_gralloc)
- return -1;
-
- return my_gralloc->registerBuffer(my_gralloc, handle);
-}
-
-extern "C" int hybris_unregister_buffer_handle(buffer_handle_t handle)
-{
- if (!my_gralloc)
- return -1;
-
- return my_gralloc->unregisterBuffer(my_gralloc, handle);
-}
-
extern "C" void hybris_dump_buffer_to_file(ANativeWindowBuffer *buf)
{
static int cnt = 0;
void *vaddr;
- int ret = my_gralloc->lock(my_gralloc, buf->handle, buf->usage, 0, 0, buf->width, buf->height, &vaddr);
+ int ret = hybris_gralloc_lock(buf->handle, buf->usage, 0, 0, buf->width, buf->height, &vaddr);
TRACE("buf:%p gralloc lock returns %i", buf, ret);
TRACE("buf:%p lock to vaddr %p", buf, vaddr);
char b[1024];
@@ -87,15 +68,14 @@
::write(fd, vaddr, buf->stride * buf->height * bytes_pp);
::close(fd);
- my_gralloc->unlock(my_gralloc, buf->handle);
+ hybris_gralloc_unlock(buf->handle);
}
#ifdef WANT_WAYLAND
extern "C" EGLBoolean eglplatformcommon_eglBindWaylandDisplayWL(EGLDisplay dpy, struct wl_display *display)
{
- assert(my_gralloc != NULL);
- server_wlegl_create(display, my_gralloc, my_alloc);
+ server_wlegl_create(display);
return EGL_TRUE;
}
@@ -183,17 +163,15 @@
extern "C" EGLBoolean eglplatformcommon_eglHybrisCreateRemoteBuffer(EGLint width, EGLint height, EGLint usage, EGLint format, EGLint stride,
int num_ints, int *ints, int num_fds, int *fds, EGLClientBuffer *buffer)
{
- assert(my_gralloc != NULL);
-
native_handle_t *native = native_handle_create(num_fds, num_ints);
memcpy(&native->data[0], fds, num_fds * sizeof(int));
memcpy(&native->data[num_fds], ints, num_ints * sizeof(int));
- int ret = my_gralloc->registerBuffer(my_gralloc, (buffer_handle_t)native);
+ int ret = hybris_gralloc_retain(native);
if (ret == 0)
{
- RemoteWindowBuffer *buf = new RemoteWindowBuffer(width, height, stride, format, usage, (buffer_handle_t)native, my_gralloc, my_alloc);
+ RemoteWindowBuffer *buf = new RemoteWindowBuffer(width, height, stride, format, usage, (buffer_handle_t)native);
buf->common.incRef(&buf->common);
*buffer = (EGLClientBuffer) static_cast<ANativeWindowBuffer *>(buf);
return EGL_TRUE;
@@ -208,14 +186,11 @@
buffer_handle_t _handle;
int _stride;
- assert(my_gralloc != NULL);
- assert(my_alloc != NULL);
-
- ret = my_alloc->alloc(my_alloc, width, height, format, usage, &_handle, &_stride);
+ hybris_gralloc_allocate(width, height, format, usage, &_handle, (uint32_t*)&_stride);
if (ret == 0)
{
- RemoteWindowBuffer *buf = new RemoteWindowBuffer(width, height, _stride, format, usage, _handle, my_gralloc, my_alloc);
+ RemoteWindowBuffer *buf = new RemoteWindowBuffer(width, height, _stride, format, usage, _handle);
buf->common.incRef(&buf->common);
buf->setAllocated(true);
*buffer = (EGLClientBuffer) static_cast<ANativeWindowBuffer *>(buf);
@@ -231,9 +206,7 @@
int ret;
RemoteWindowBuffer *buf = static_cast<RemoteWindowBuffer *>((ANativeWindowBuffer *) buffer);
- assert(my_gralloc != NULL);
-
- ret = my_gralloc->lock(my_gralloc, buf->handle, usage, l, t, w, h, vaddr);
+ ret = hybris_gralloc_lock(buf->handle, usage, l, t, w, h, vaddr);
if (ret == 0)
return EGL_TRUE;
else
@@ -245,9 +218,7 @@
int ret;
RemoteWindowBuffer *buf = static_cast<RemoteWindowBuffer *>((ANativeWindowBuffer *) buffer);
- assert(my_gralloc != NULL);
-
- ret = my_gralloc->unlock(my_gralloc, buf->handle);
+ ret = hybris_gralloc_unlock(buf->handle);
if (ret == 0)
return EGL_TRUE;
else
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/eglplatformcommon.h
^
|
@@ -1,10 +1,9 @@
#ifndef __EGLPLATFORMCOMMON_H
#define __EGLPLATFORMCOMMON_H
#include <string.h>
-#include <hardware/gralloc.h>
#include <EGL/egl.h>
-void eglplatformcommon_init(struct ws_egl_interface *egl_iface, gralloc_module_t *gralloc, alloc_device_t *allocdevice);
+void eglplatformcommon_init(struct ws_egl_interface *egl_iface);
__eglMustCastToProperFunctionPointerType eglplatformcommon_eglGetProcAddress(const char *procname);
void eglplatformcommon_passthroughImageKHR(EGLContext *ctx, EGLenum *target, EGLClientBuffer *buffer, const EGLint **attrib_list);
const char *eglplatformcommon_eglQueryString(EGLDisplay dpy, EGLint name, const char *(*real_eglQueryString)(EGLDisplay dpy, EGLint name));
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/nativewindowbase.cpp
^
|
@@ -1,4 +1,11 @@
+
+#ifndef ANDROID_BUILD
#include <android-config.h>
+#include "logging.h"
+#else
+#define TRACE(message, ...)
+#endif
+
#include <string.h>
#include <system/window.h>
#include <system/graphics.h>
@@ -12,15 +19,14 @@
}
#endif
+#ifdef ANDROID_BUILD
+#define TRACE(...)
+#define HYBRIS_TRACE_BEGIN(...)
+#define HYBRIS_TRACE_END(...)
+#endif
#include "nativewindowbase.h"
-#include "logging.h"
-
-#define TRACE(message, ...) HYBRIS_DEBUG_LOG(EGL, message, ##__VA_ARGS__)
-
-
-
BaseNativeWindowBuffer::BaseNativeWindowBuffer()
{
TRACE("%p", this);
@@ -265,6 +271,10 @@
case NATIVE_WINDOW_DEFAULT_DATASPACE: return "NATIVE_WINDOW_DEFAULT_DATASPACE";
case NATIVE_WINDOW_CONSUMER_USAGE_BITS: return "NATIVE_WINDOW_CONSUMER_USAGE_BITS";
#endif
+#if ANDROID_VERSION_MAJOR>=8
+ case NATIVE_WINDOW_IS_VALID: return "NATIVE_WINDOW_IS_VALID";
+ case NATIVE_WINDOW_BUFFER_AGE: return "NATIVE_WINDOW_BUFFER_AGE";
+#endif
default: return "NATIVE_UNKNOWN_QUERY";
}
}
@@ -309,6 +319,16 @@
*value = self->getUsage();
return NO_ERROR;
#endif
+#if ANDROID_VERSION_MAJOR>=8
+ case NATIVE_WINDOW_IS_VALID:
+ // sure :)
+ *value = 1;
+ return NO_ERROR;
+ case NATIVE_WINDOW_BUFFER_AGE:
+ // sure :)
+ *value = 2;
+ return NO_ERROR;
+#endif
}
TRACE("EGL error: unkown window attribute! %i", what);
*value = 0;
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/server_wlegl.cpp
^
|
@@ -28,15 +28,18 @@
extern "C" {
#include <cutils/native_handle.h>
-#include <hardware/gralloc.h>
}
+#include "logging.h"
+
#include <wayland-server.h>
#include "wayland-android-server-protocol.h"
#include "server_wlegl_private.h"
#include "server_wlegl_handle.h"
#include "server_wlegl_buffer.h"
+#include <hybris/gralloc/gralloc.h>
+
static inline server_wlegl *
server_wlegl_from(struct wl_resource *resource)
{
@@ -127,7 +130,10 @@
usage |= GRALLOC_USAGE_HW_COMPOSER;
- int ret = wlegl->alloc->alloc(wlegl->alloc, width, height, format, usage, &_handle, &_stride);
+ int r = hybris_gralloc_allocate(width, height, format, usage, &_handle, (uint32_t*)&_stride);
+ if (r) {
+ HYBRIS_ERROR_LOG(SERVER_WLEGL, "failed to allocate buffer\n");
+ }
server_wlegl_buffer *buffer = server_wlegl_buffer_create_server(client, width, height, _stride, format, usage, _handle, wlegl);
struct wl_array ints;
@@ -165,18 +171,15 @@
}
server_wlegl *
-server_wlegl_create(struct wl_display *display, gralloc_module_t *gralloc, alloc_device_t *alloc)
+server_wlegl_create(struct wl_display *display)
{
struct server_wlegl *wlegl;
- int ret;
wlegl = new server_wlegl;
wlegl->display = display;
wlegl->global = wl_global_create(display, &android_wlegl_interface, 2,
wlegl, server_wlegl_bind);
- wlegl->gralloc = (const gralloc_module_t *)gralloc;
- wlegl->alloc = alloc;
return wlegl;
}
@@ -186,8 +189,6 @@
{
/* FIXME: server_wlegl_buffer objects may exist */
- /* no way to release wlegl->gralloc */
-
/* FIXME: remove global_ */
/* Better to leak than expose dtor segfaults, the server
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/server_wlegl.h
^
|
@@ -25,8 +25,8 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <hardware/gralloc.h>
#include <system/window.h>
+
extern "C" {
struct wl_display;
@@ -37,7 +37,7 @@
struct server_wlegl;
server_wlegl *
-server_wlegl_create(struct wl_display *wldpy, gralloc_module_t *gralloc, alloc_device_t *alloc);
+server_wlegl_create(struct wl_display *wldpy);
void
server_wlegl_destroy(server_wlegl *wlegl);
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/server_wlegl_buffer.cpp
^
|
@@ -27,6 +27,8 @@
#include "server_wlegl_buffer.h"
#include "server_wlegl_private.h"
+#include <hybris/gralloc/gralloc.h>
+
static void
destroy(struct wl_client *client, struct wl_resource *resource)
{
@@ -69,14 +71,14 @@
buffer->resource = wl_resource_create(client, &wl_buffer_interface, 1, id);
wl_resource_set_implementation(buffer->resource, &server_wlegl_buffer_impl, buffer, server_wlegl_buffer_dtor);
- ret = wlegl->gralloc->registerBuffer(wlegl->gralloc, handle);
+ ret = hybris_gralloc_retain(handle);
if (ret) {
delete buffer;
return NULL;
}
buffer->buf = new RemoteWindowBuffer(
- width, height, stride, format, usage, handle, wlegl->gralloc, NULL);
+ width, height, stride, format, usage, handle);
buffer->buf->common.incRef(&buffer->buf->common);
return buffer;
}
@@ -92,14 +94,13 @@
server_wlegl *wlegl)
{
server_wlegl_buffer *buffer = new server_wlegl_buffer;
- int ret;
buffer->wlegl = wlegl;
buffer->resource = wl_resource_create(client, &wl_buffer_interface, 1, 0);
wl_resource_set_implementation(buffer->resource, &server_wlegl_buffer_impl, buffer, server_wlegl_buffer_dtor);
buffer->buf = new RemoteWindowBuffer(
- width, height, stride, format, usage, handle, wlegl->gralloc, wlegl->alloc);
+ width, height, stride, format, usage, handle);
buffer->buf->setAllocated(true);
buffer->buf->common.incRef(&buffer->buf->common);
return buffer;
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/server_wlegl_private.h
^
|
@@ -23,7 +23,6 @@
#ifndef SERVER_WLEGL_PRIVATE_H
#define SERVER_WLEGL_PRIVATE_H
-#include <hardware/gralloc.h>
#include <wayland-server.h>
#include "server_wlegl.h"
@@ -32,9 +31,6 @@
struct wl_display *display;
struct wl_global *global;
-
- const gralloc_module_t *gralloc;
- alloc_device_t *alloc;
};
#endif /* SERVER_WLEGL_PRIVATE_H */
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/windowbuffer.cpp
^
|
@@ -24,14 +24,9 @@
#include <cstring>
#include <cassert>
#include "windowbuffer.h"
+#include <hybris/gralloc/gralloc.h>
RemoteWindowBuffer::~RemoteWindowBuffer()
{
- if (!m_allocated) {
- this->m_gralloc->unregisterBuffer(this->m_gralloc, this->handle);
- native_handle_close(this->handle);
- native_handle_delete(const_cast<native_handle_t*>(this->handle));
- } else if (this->m_alloc) {
- this->m_alloc->free((alloc_device_t *)this->m_alloc, this->handle);
- }
+ hybris_gralloc_release(this->handle, m_allocated);
}
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/common/windowbuffer.h
^
|
@@ -37,9 +37,7 @@
unsigned int stride,
unsigned int format,
unsigned int usage,
- buffer_handle_t handle,
- const gralloc_module_t *gralloc,
- const alloc_device_t *alloc = NULL
+ buffer_handle_t handle
) {
// Base members
ANativeWindowBuffer::width = width;
@@ -48,8 +46,6 @@
ANativeWindowBuffer::usage = usage;
ANativeWindowBuffer::stride = stride;
ANativeWindowBuffer::handle = handle;
- this->m_gralloc = gralloc;
- this->m_alloc = alloc;
this->m_allocated = false;
};
~RemoteWindowBuffer();
@@ -58,8 +54,6 @@
bool isAllocated() const { return m_allocated; }
private:
- const gralloc_module_t *m_gralloc;
- const alloc_device_t *m_alloc;
bool m_allocated;
};
#endif /* WINDOWBUFFER_H */
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/fbdev/Makefile.am
^
|
@@ -21,4 +21,4 @@
eglplatform_fbdev_la_LDFLAGS = \
-avoid-version -module -shared -export-dynamic \
$(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
- $(top_builddir)/hardware/libhardware.la
+ $(top_builddir)/gralloc/libgralloc.la
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/fbdev/eglplatform_fbdev.cpp
^
|
@@ -9,46 +9,24 @@
#include <sys/stat.h>
#include <unistd.h>
#include <assert.h>
+
extern "C" {
#include <eglplatformcommon.h>
};
#include "logging.h"
+#include <hybris/gralloc/gralloc.h>
-static gralloc_module_t *gralloc = 0;
-static framebuffer_device_t *framebuffer = 0;
-static alloc_device_t *alloc = 0;
static FbDevNativeWindow *_nativewindow = NULL;
extern "C" void fbdevws_init_module(struct ws_egl_interface *egl_iface)
{
- int err;
- err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &gralloc);
- if (gralloc==NULL) {
- fprintf(stderr, "failed to get gralloc module: (%s)\n",strerror(-err));
- assert(0);
- }
-
- err = framebuffer_open((hw_module_t *) gralloc, &framebuffer);
- if (err) {
- fprintf(stderr, "ERROR: failed to open framebuffer: (%s)\n",strerror(-err));
- assert(0);
- }
- TRACE("** framebuffer_open: status=(%s) format=x%x", strerror(-err), framebuffer->format);
-
- err = gralloc_open((const hw_module_t *) gralloc, &alloc);
- if (err) {
- fprintf(stderr, "ERROR: failed to open gralloc: (%s)\n",strerror(-err));
- assert(0);
- }
- TRACE("** gralloc_open %p status=%s", gralloc, strerror(-err));
- eglplatformcommon_init(egl_iface, gralloc, alloc);
+ hybris_gralloc_initialize(1);
+ eglplatformcommon_init(egl_iface);
}
extern "C" _EGLDisplay *fbdevws_GetDisplay(EGLNativeDisplayType display)
{
- assert (gralloc != NULL);
-
_EGLDisplay *dpy = 0;
if (display == EGL_DEFAULT_DISPLAY) {
dpy = new _EGLDisplay;
@@ -63,10 +41,9 @@
extern "C" EGLNativeWindowType fbdevws_CreateWindow(EGLNativeWindowType win, _EGLDisplay *display)
{
- assert (gralloc != NULL);
assert (_nativewindow == NULL);
- _nativewindow = new FbDevNativeWindow(alloc, framebuffer);
+ _nativewindow = new FbDevNativeWindow();
_nativewindow->common.incRef(&_nativewindow->common);
return (EGLNativeWindowType) static_cast<struct ANativeWindow *>(_nativewindow);
}
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/fbdev/fbdev_window.cpp
^
|
@@ -30,14 +30,15 @@
};
#endif
+#include <hybris/gralloc/gralloc.h>
+
#define FRAMEBUFFER_PARTITIONS 2
static pthread_cond_t _cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
-FbDevNativeWindowBuffer::FbDevNativeWindowBuffer(alloc_device_t* alloc_device,
- unsigned int width,
+FbDevNativeWindowBuffer::FbDevNativeWindowBuffer(unsigned int width,
unsigned int height,
unsigned int format,
unsigned int usage)
@@ -48,13 +49,8 @@
ANativeWindowBuffer::usage = usage;
busy = 0;
status = 0;
- m_alloc = alloc_device;
- if (m_alloc) {
- status = m_alloc->alloc(m_alloc,
- width, height, format, usage,
- &handle, &stride);
- }
+ hybris_gralloc_allocate(width, height, format, usage, &handle, (uint32_t*)&stride);
TRACE("width=%d height=%d stride=%d format=x%x usage=x%x status=%s this=%p",
width, height, stride, format, usage, strerror(-status), this);
@@ -65,31 +61,26 @@
FbDevNativeWindowBuffer::~FbDevNativeWindowBuffer()
{
TRACE("%p", this);
- if (m_alloc && handle)
- m_alloc->free(m_alloc, handle);
+ hybris_gralloc_release(handle, 1);
}
////////////////////////////////////////////////////////////////////////////////
-FbDevNativeWindow::FbDevNativeWindow( alloc_device_t* alloc,
- framebuffer_device_t* fbDev)
+FbDevNativeWindow::FbDevNativeWindow()
{
- m_alloc = alloc;
- m_fbDev = fbDev;
- m_bufFormat = m_fbDev->format;
+ m_bufFormat = hybris_gralloc_fbdev_format();
m_usage = GRALLOC_USAGE_HW_FB;
m_bufferCount = 0;
m_allocateBuffers = true;
#if ANDROID_VERSION_MAJOR>=4 && ANDROID_VERSION_MINOR>=2 || ANDROID_VERSION_MAJOR>=5
- if (m_fbDev->numFramebuffers>0)
- setBufferCount(m_fbDev->numFramebuffers);
+ if (hybris_gralloc_fbdev_framebuffer_count() > 0)
+ setBufferCount(hybris_gralloc_fbdev_framebuffer_count());
else
setBufferCount(FRAMEBUFFER_PARTITIONS);
#else
setBufferCount(FRAMEBUFFER_PARTITIONS);
#endif
-
}
@@ -128,7 +119,7 @@
int FbDevNativeWindow::setSwapInterval(int interval)
{
TRACE("interval=%i", interval);
- return m_fbDev->setSwapInterval(m_fbDev, interval);
+ return hybris_gralloc_fbdev_setSwapInterval(interval);
}
@@ -279,7 +270,7 @@
HYBRIS_TRACE_BEGIN("fbdev-platform", "queueBuffer-post", "-%p", fbnb);
- int rv = m_fbDev->post(m_fbDev, fbnb->handle);
+ int rv = hybris_gralloc_fbdev_post(fbnb->handle);
if (rv!=0)
{
fprintf(stderr,"ERROR: fb->post(%s)\n",strerror(-rv));
@@ -374,7 +365,7 @@
*/
unsigned int FbDevNativeWindow::width() const
{
- unsigned int rv = m_fbDev->width;
+ unsigned int rv = hybris_gralloc_fbdev_width();
TRACE("width=%i", rv);
return rv;
}
@@ -385,7 +376,7 @@
*/
unsigned int FbDevNativeWindow::height() const
{
- unsigned int rv = m_fbDev->height;
+ unsigned int rv = hybris_gralloc_fbdev_height();
TRACE("height=%i", rv);
return rv;
}
@@ -396,7 +387,7 @@
*/
unsigned int FbDevNativeWindow::format() const
{
- unsigned int rv = m_fbDev->format;
+ unsigned int rv = hybris_gralloc_fbdev_format();
TRACE("format=x%x", rv);
return rv;
}
@@ -413,7 +404,7 @@
*/
unsigned int FbDevNativeWindow::defaultHeight() const
{
- unsigned int rv = m_fbDev->height;
+ unsigned int rv = hybris_gralloc_fbdev_height();
TRACE("height=%i", rv);
return rv;
}
@@ -424,7 +415,7 @@
*/
unsigned int FbDevNativeWindow::defaultWidth() const
{
- unsigned int rv = m_fbDev->width;
+ unsigned int rv = hybris_gralloc_fbdev_width();
TRACE("width=%i", rv);
return rv;
}
@@ -521,9 +512,8 @@
for(unsigned int i = 0; i < m_bufferCount; i++)
{
- FbDevNativeWindowBuffer *fbnb = new FbDevNativeWindowBuffer(m_alloc,
- m_fbDev->width, m_fbDev->height, m_fbDev->format,
- m_usage|GRALLOC_USAGE_HW_FB );
+ FbDevNativeWindowBuffer *fbnb = new FbDevNativeWindowBuffer(hybris_gralloc_fbdev_width(),
+ hybris_gralloc_fbdev_height(), hybris_gralloc_fbdev_format(), m_usage|GRALLOC_USAGE_HW_FB);
fbnb->common.incRef(&fbnb->common);
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/fbdev/fbdev_window.h
^
|
@@ -28,8 +28,7 @@
friend class FbDevNativeWindow;
protected:
- FbDevNativeWindowBuffer(alloc_device_t* alloc,
- unsigned int width,
+ FbDevNativeWindowBuffer(unsigned int width,
unsigned int height,
unsigned int format,
unsigned int usage) ;
@@ -38,14 +37,12 @@
protected:
int busy;
int status;
- alloc_device_t* m_alloc;
};
class FbDevNativeWindow : public BaseNativeWindow {
public:
- FbDevNativeWindow(alloc_device_t* alloc,
- framebuffer_device_t* fbDev);
+ FbDevNativeWindow();
~FbDevNativeWindow();
// overloads from BaseNativeWindow
@@ -77,8 +74,6 @@
void reallocateBuffers();
private:
- framebuffer_device_t* m_fbDev;
- alloc_device_t* m_alloc;
unsigned int m_usage;
unsigned int m_bufFormat;
unsigned int m_bufferCount;
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/hwcomposer/Makefile.am
^
|
@@ -28,7 +28,7 @@
libhybris_hwcomposerwindow_la_LDFLAGS = \
-version-info "1":"0":"0" \
$(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
- $(top_builddir)/hardware/libhardware.la
+ $(top_builddir)/gralloc/libgralloc.la
if HAS_ANDROID_4_2_0
libhybris_hwcomposerwindow_la_LDFLAGS += $(top_builddir)/libsync/libsync.la
@@ -58,5 +58,5 @@
eglplatform_hwcomposer_la_LDFLAGS = \
-avoid-version -module -shared -export-dynamic \
$(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
- $(top_builddir)/hardware/libhardware.la
+ $(top_builddir)/gralloc/libgralloc.la
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/hwcomposer/eglplatform_hwcomposer.cpp
^
|
@@ -15,31 +15,18 @@
#include "logging.h"
-static gralloc_module_t *gralloc = 0;
-static alloc_device_t *alloc = 0;
+#include <hybris/gralloc/gralloc.h>
+
static HWComposerNativeWindow *_nativewindow = NULL;
extern "C" void hwcomposerws_init_module(struct ws_egl_interface *egl_iface)
{
- int err;
- err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &gralloc);
- if (gralloc==NULL) {
- fprintf(stderr, "failed to get gralloc module: (%s)\n",strerror(-err));
- assert(0);
- }
-
- err = gralloc_open((const hw_module_t *) gralloc, &alloc);
- if (err) {
- fprintf(stderr, "ERROR: failed to open gralloc: (%s)\n",strerror(-err));
- assert(0);
- }
- TRACE("** gralloc_open %p status=%s", gralloc, strerror(-err));
- eglplatformcommon_init(egl_iface, gralloc, alloc);
+ hybris_gralloc_initialize(0);
+ eglplatformcommon_init(egl_iface);
}
extern "C" _EGLDisplay *hwcomposerws_GetDisplay(EGLNativeDisplayType display)
{
- assert (gralloc != NULL);
_EGLDisplay *dpy = 0;
if (display == EGL_DEFAULT_DISPLAY) {
dpy = new _EGLDisplay;
@@ -54,11 +41,9 @@
extern "C" EGLNativeWindowType hwcomposerws_CreateWindow(EGLNativeWindowType win, _EGLDisplay *display)
{
- assert (gralloc != NULL);
assert (_nativewindow == NULL);
HWComposerNativeWindow *window = static_cast<HWComposerNativeWindow *>((ANativeWindow *) win);
- window->setup(gralloc, alloc);
_nativewindow = window;
_nativewindow->common.incRef(&_nativewindow->common);
return (EGLNativeWindowType) static_cast<struct ANativeWindow *>(_nativewindow);
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/hwcomposer/hwcomposer_window.cpp
^
|
@@ -14,10 +14,13 @@
* limitations under the License.
*/
+#ifndef ANDROID_BUILD
#include <android-config.h>
+#include "logging.h"
+#endif
+
#include "hwcomposer_window.h"
#include "hwcomposer.h"
-#include "logging.h"
#include <errno.h>
#include <assert.h>
@@ -30,7 +33,15 @@
extern "C" {
#include <sync/sync.h>
};
-
+
+#ifdef ANDROID_BUILD
+#define TRACE(...)
+#define HYBRIS_TRACE_BEGIN(...)
+#define HYBRIS_TRACE_END(...)
+#include "hybris-gralloc.h"
+#else
+#include <hybris/gralloc/gralloc.h>
+#endif
extern "C" struct ANativeWindow *HWCNativeWindowCreate(unsigned int width, unsigned int height, unsigned int format, HWCPresentCallback present, void *cb_data)
{
@@ -84,8 +95,7 @@
static pthread_mutex_t _mutex = PTHREAD_MUTEX_INITIALIZER;
-HWComposerNativeWindowBuffer::HWComposerNativeWindowBuffer(alloc_device_t* alloc_device,
- unsigned int width,
+HWComposerNativeWindowBuffer::HWComposerNativeWindowBuffer(unsigned int width,
unsigned int height,
unsigned int format,
unsigned int usage)
@@ -97,13 +107,8 @@
fenceFd = -1;
busy = 0;
status = 0;
- m_alloc = alloc_device;
- if (m_alloc) {
- status = m_alloc->alloc(m_alloc,
- width, height, format, usage,
- &handle, &stride);
- }
+ hybris_gralloc_allocate(width, height, format, usage, &handle, (uint32_t*)&stride);
TRACE("width=%d height=%d stride=%d format=x%x usage=x%x status=%s this=%p",
width, height, stride, format, usage, strerror(-status), this);
@@ -114,9 +119,7 @@
HWComposerNativeWindowBuffer::~HWComposerNativeWindowBuffer()
{
TRACE("%p", this);
- if (m_alloc && handle)
- m_alloc->free(m_alloc, handle);
-
+ hybris_gralloc_release(handle, 1);
}
@@ -124,7 +127,6 @@
HWComposerNativeWindow::HWComposerNativeWindow(unsigned int width, unsigned int height, unsigned int format)
{
pthread_mutex_init(&m_mutex, 0);
- m_alloc = NULL;
m_width = width;
m_height = height;
m_bufFormat = format;
@@ -133,11 +135,6 @@
m_nextBuffer = 0;
}
-void HWComposerNativeWindow::setup(gralloc_module_t* gralloc, alloc_device_t* alloc)
-{
- m_alloc = alloc;
-}
-
HWComposerNativeWindow::~HWComposerNativeWindow()
{
destroyBuffers();
@@ -489,7 +486,7 @@
for(unsigned int i = 0; i < m_bufferCount; i++)
{
HWComposerNativeWindowBuffer *b
- = new HWComposerNativeWindowBuffer(m_alloc, m_width, m_height, m_bufFormat, m_usage);
+ = new HWComposerNativeWindowBuffer(m_width, m_height, m_bufFormat, m_usage);
b->common.incRef(&b->common);
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/hwcomposer/hwcomposer_window.h
^
|
@@ -28,18 +28,16 @@
friend class HWComposerNativeWindow;
protected:
- HWComposerNativeWindowBuffer(alloc_device_t* alloc,
- unsigned int width,
- unsigned int height,
- unsigned int format,
- unsigned int usage) ;
+ HWComposerNativeWindowBuffer(unsigned int width,
+ unsigned int height,
+ unsigned int format,
+ unsigned int usage) ;
virtual ~HWComposerNativeWindowBuffer() ;
protected:
int busy;
int fenceFd;
int status;
- alloc_device_t* m_alloc;
};
@@ -47,8 +45,6 @@
public:
HWComposerNativeWindow(unsigned int width, unsigned int height, unsigned int format);
~HWComposerNativeWindow();
- void setup(gralloc_module_t* gralloc, alloc_device_t* alloc);
-
int getFenceBufferFd(HWComposerNativeWindowBuffer *buffer);
void setFenceBufferFd(HWComposerNativeWindowBuffer *buffer, int fd);
@@ -82,8 +78,6 @@
void allocateBuffers();
private:
- framebuffer_device_t* m_fbDev;
- alloc_device_t* m_alloc;
unsigned int m_usage;
unsigned int m_bufFormat;
std::vector<HWComposerNativeWindowBuffer*> m_bufList;
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/null/Makefile.am
^
|
@@ -14,7 +14,7 @@
eglplatform_null_la_LDFLAGS = \
-avoid-version -module -shared -export-dynamic \
$(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
- $(top_builddir)/hardware/libhardware.la \
+ $(top_builddir)/gralloc/libgralloc.la \
$(WAYLAND_SERVER_LIBS)
if WANT_DEBUG
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/null/eglplatform_null.c
^
|
@@ -7,9 +7,7 @@
#include <hybris/common/binding.h>
#include <eglplatformcommon.h>
#include "logging.h"
-
-static gralloc_module_t *gralloc = 0;
-static alloc_device_t *alloc = 0;
+#include <hybris/gralloc/gralloc.h>
#pragma GCC visibility push(hidden)
HYBRIS_LIBRARY_INITIALIZE(nullui, "/system/lib/libui.so");
@@ -19,12 +17,8 @@
static void nullws_init_module(struct ws_egl_interface *egl_iface)
{
- int err;
- hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &gralloc);
- err = gralloc_open((const hw_module_t *) gralloc, &alloc);
- TRACE("++ %lu wayland: got gralloc %p err:%s", pthread_self(), gralloc, strerror(-err));
- eglplatformcommon_init(egl_iface, gralloc, alloc);
-
+ hybris_gralloc_initialize(0);
+ eglplatformcommon_init(egl_iface);
}
static struct _EGLDisplay *nullws_GetDisplay(EGLNativeDisplayType display)
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/wayland/Makefile.am
^
|
@@ -6,6 +6,7 @@
-I$(top_srcdir)/include \
-I$(top_srcdir)/egl \
-I$(top_srcdir)/egl/platforms/common \
+ -I$(top_builddir)/egl/platforms/common \
$(ANDROID_HEADERS_CFLAGS) \
$(WAYLAND_CLIENT_CFLAGS)
@@ -30,7 +31,7 @@
eglplatform_wayland_la_LDFLAGS = \
-avoid-version -module -shared -export-dynamic \
$(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
- $(top_builddir)/hardware/libhardware.la \
+ $(top_builddir)/gralloc/libgralloc.la \
$(WAYLAND_CLIENT_LIBS)
if HAS_ANDROID_4_2_0
eglplatform_wayland_la_LDFLAGS += $(top_builddir)/libsync/libsync.la
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/wayland/eglplatform_wayland.cpp
^
|
@@ -48,16 +48,13 @@
#include <wayland-egl.h>
}
+#include <hybris/gralloc/gralloc.h>
#include "wayland_window.h"
#include "logging.h"
#include "wayland-egl-priv.h"
#include "server_wlegl_buffer.h"
#include "wayland-android-client-protocol.h"
-static gralloc_module_t *gralloc = 0;
-static alloc_device_t *alloc = 0;
-
-
static const char * (*_eglQueryString)(EGLDisplay dpy, EGLint name) = NULL;
static __eglMustCastToProperFunctionPointerType (*_eglGetProcAddress)(const char *procname) = NULL;
static EGLSyncKHR (*_eglCreateSyncKHR)(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) = NULL;
@@ -75,11 +72,8 @@
extern "C" void waylandws_init_module(struct ws_egl_interface *egl_iface)
{
- int err;
- hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &gralloc);
- err = gralloc_open((const hw_module_t *) gralloc, &alloc);
- TRACE("++ %lu wayland: got gralloc %p err:%s", pthread_self(), gralloc, strerror(-err));
- eglplatformcommon_init(egl_iface, gralloc, alloc);
+ hybris_gralloc_initialize(0);
+ eglplatformcommon_init(egl_iface);
}
static void _init_egl_funcs(EGLDisplay display)
@@ -140,7 +134,7 @@
extern "C" _EGLDisplay *waylandws_GetDisplay(EGLNativeDisplayType display)
{
WaylandDisplay *wdpy = new WaylandDisplay;
- wdpy->wl_dpy = (wl_display *)display;
+ wdpy->wl_dpy = display ? (wl_display *)display : wl_display_connect(NULL);
wdpy->wlegl = NULL;
wdpy->queue = wl_display_create_queue(wdpy->wl_dpy);
wdpy->registry = wl_display_get_registry(wdpy->wl_dpy);
@@ -190,7 +184,7 @@
}
assert(ret >= 0);
- WaylandNativeWindow *window = new WaylandNativeWindow((struct wl_egl_window *) win, wdpy->wl_dpy, wdpy->wlegl, alloc, gralloc);
+ WaylandNativeWindow *window = new WaylandNativeWindow((struct wl_egl_window *) win, wdpy->wl_dpy, wdpy->wlegl);
window->common.incRef(&window->common);
return (EGLNativeWindowType) static_cast<struct ANativeWindow *>(window);
}
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/wayland/wayland_window.cpp
^
|
@@ -102,7 +102,11 @@
void WaylandNativeWindow::free_callback(struct wl_egl_window *egl_window, void *)
{
- ((WaylandNativeWindow*)(egl_window->nativewindow))->m_window = 0;
+ WaylandNativeWindow *native = (WaylandNativeWindow*)egl_window->nativewindow;
+
+ native->lock();
+ native->m_window = 0;
+ native->unlock();
}
void WaylandNativeWindow::lock()
@@ -172,7 +176,7 @@
wayland_frame_callback
};
-WaylandNativeWindow::WaylandNativeWindow(struct wl_egl_window *window, struct wl_display *display, android_wlegl *wlegl, alloc_device_t* alloc_device, gralloc_module_t *gralloc)
+WaylandNativeWindow::WaylandNativeWindow(struct wl_egl_window *window, struct wl_display *display, android_wlegl *wlegl)
: m_android_wlegl(wlegl)
{
int wayland_ok;
@@ -196,9 +200,6 @@
// This is the default as per the EGL documentation
this->m_swap_interval = 1;
- this->m_alloc = alloc_device;
- m_gralloc = gralloc;
-
m_usage=GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE;
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cond, NULL);
@@ -218,7 +219,7 @@
if (frame_callback)
wl_callback_destroy(frame_callback);
wl_event_queue_destroy(wl_queue);
- if (m_window) {
+ if (m_window) {
m_window->nativewindow = NULL;
m_window->resize_callback = NULL;
m_window->free_callback = NULL;
@@ -371,12 +372,12 @@
HYBRIS_TRACE_END("wayland-platform", "dequeueBuffer_wait_for_buffer", "");
/* If the buffer doesn't match the window anymore, re-allocate */
- if (wnb->width != m_window->width || wnb->height != m_window->height
+ if (wnb->width != m_width || wnb->height != m_height
|| wnb->format != m_format || wnb->usage != m_usage)
{
TRACE("wnb:%p,win:%p %i,%i %i,%i x%x,x%x x%x,x%x",
wnb,m_window,
- wnb->width,m_window->width, wnb->height,m_window->height,
+ wnb->width,m_width, wnb->height,m_height,
wnb->format,m_format, wnb->usage,m_usage);
destroyBuffer(wnb);
m_bufList.erase(it);
@@ -507,6 +508,10 @@
{
int ret = 0;
lock();
+ if (!m_window) {
+ unlock();
+ return;
+ }
WaylandNativeWindowBuffer *wnb = queue.front();
if (!wnb) {
@@ -526,6 +531,7 @@
}
if (ret < 0) {
HYBRIS_TRACE_END("wayland-platform", "queueBuffer_wait_for_frame_callback", "-%p", wnb);
+ unlock();
return;
}
@@ -748,10 +754,10 @@
WaylandNativeWindowBuffer *wnb;
#ifndef HYBRIS_NO_SERVER_SIDE_BUFFERS
- wnb = new ServerWaylandBuffer(m_width, m_height, m_format, m_usage, m_gralloc, m_android_wlegl, wl_queue);
+ wnb = new ServerWaylandBuffer(m_width, m_height, m_format, m_usage, m_android_wlegl, wl_queue);
wayland_roundtrip(this);
#else
- wnb = new ClientWaylandBuffer(m_alloc, m_width, m_height, m_format, m_usage);
+ wnb = new ClientWaylandBuffer(m_width, m_height, m_format, m_usage);
#endif
m_bufList.push_back(wnb);
++m_freeBufs;
@@ -866,7 +872,7 @@
wsb->format = format;
wsb->stride = stride;
- int ret = wsb->m_gralloc->registerBuffer(wsb->m_gralloc, wsb->handle);
+ int ret = hybris_gralloc_retain(wsb->handle);
if (ret) {
fprintf(stderr,"failed to register buffer\n");
return;
@@ -882,13 +888,12 @@
ssb_buffer,
};
-ServerWaylandBuffer::ServerWaylandBuffer(unsigned int w, unsigned int h, int f, int u, gralloc_module_t *gralloc, android_wlegl *android_wlegl, struct wl_event_queue *queue)
+ServerWaylandBuffer::ServerWaylandBuffer(unsigned int w, unsigned int h, int f, int u, android_wlegl *android_wlegl, struct wl_event_queue *queue)
: WaylandNativeWindowBuffer()
, m_buf(0)
{
ANativeWindowBuffer::width = w;
ANativeWindowBuffer::height = h;
- m_gralloc = gralloc;
usage = u;
wl_array_init(&ints);
@@ -904,9 +909,7 @@
if (m_buf)
wl_buffer_destroy(m_buf);
- m_gralloc->unregisterBuffer(m_gralloc, handle);
- native_handle_close(handle);
- native_handle_delete(const_cast<native_handle_t *>(handle));
+ hybris_gralloc_release(handle, 1);
wl_array_release(&ints);
wl_array_release(&fds);
}
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/egl/platforms/wayland/wayland_window.h
^
|
@@ -28,7 +28,9 @@
#define Wayland_WINDOW_H
#include "nativewindowbase.h"
#include <linux/fb.h>
-#include <hardware/gralloc.h>
+
+#include <hybris/gralloc/gralloc.h>
+
extern "C" {
#include <wayland-client.h>
@@ -36,6 +38,7 @@
#include "wayland-android-client-protocol.h"
#include <pthread.h>
}
+
#include <list>
#include <deque>
@@ -80,11 +83,9 @@
friend class WaylandNativeWindow;
protected:
ClientWaylandBuffer()
- : m_alloc(0)
- {}
+ : {}
- ClientWaylandBuffer(alloc_device_t* alloc_device,
- unsigned int width,
+ ClientWaylandBuffer( unsigned int width,
unsigned int height,
unsigned int format,
unsigned int usage)
@@ -98,9 +99,7 @@
this->creation_callback = NULL;
this->busy = 0;
this->other = NULL;
- this->m_alloc = alloc_device;
- int alloc_ok = this->m_alloc->alloc(this->m_alloc,
- this->width ? this->width : 1, this->height ? this->height : 1,
+ int alloc_ok = hybris_gralloc_allocate(this->width ? this->width : 1, this->height ? this->height : 1,
this->format, this->usage,
&this->handle, &this->stride);
assert(alloc_ok == 0);
@@ -110,8 +109,7 @@
~ClientWaylandBuffer()
{
- if (this->m_alloc)
- m_alloc->free(m_alloc, this->handle);
+ hybris_gralloc_release(this->handle, 1);
}
void init(struct android_wlegl *android_wlegl,
@@ -120,7 +118,6 @@
protected:
void* vaddr;
- alloc_device_t* m_alloc;
public:
@@ -131,7 +128,7 @@
class ServerWaylandBuffer : public WaylandNativeWindowBuffer
{
public:
- ServerWaylandBuffer(unsigned int w, unsigned int h, int format, int usage, gralloc_module_t *gralloc, android_wlegl *android_wlegl, struct wl_event_queue *queue);
+ ServerWaylandBuffer(unsigned int w, unsigned int h, int format, int usage, android_wlegl *android_wlegl, struct wl_event_queue *queue);
~ServerWaylandBuffer();
void init(struct android_wlegl *android_wlegl,
struct wl_display *display,
@@ -139,7 +136,6 @@
struct wl_array ints;
struct wl_array fds;
- gralloc_module_t *m_gralloc;
wl_buffer *m_buf;
};
@@ -147,7 +143,7 @@
class WaylandNativeWindow : public BaseNativeWindow {
public:
- WaylandNativeWindow(struct wl_egl_window *win, struct wl_display *display, android_wlegl *wlegl, alloc_device_t* alloc_device, gralloc_module_t *gralloc);
+ WaylandNativeWindow(struct wl_egl_window *win, struct wl_display *display, android_wlegl *wlegl);
~WaylandNativeWindow();
void lock();
@@ -210,7 +206,6 @@
unsigned int m_defaultHeight;
unsigned int m_usage;
struct android_wlegl *m_android_wlegl;
- alloc_device_t* m_alloc;
pthread_mutex_t mutex;
pthread_cond_t cond;
int m_queueReads;
@@ -219,7 +214,6 @@
struct wl_callback *frame_callback;
int m_swap_interval;
static int wayland_roundtrip(WaylandNativeWindow *display);
- gralloc_module_t *m_gralloc;
};
#endif
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/gralloc/GrallocUsageConversion.cpp
^
|
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hybris/grallocusage/GrallocUsageConversion.h>
+
+#include <hardware/gralloc.h>
+#include <hardware/gralloc1.h>
+
+#ifndef ANDROID_BUILD
+#include <config.h>
+#endif
+
+void android_convertGralloc0To1Usage(int32_t usage, uint64_t* producerUsage,
+ uint64_t* consumerUsage) {
+ constexpr uint64_t PRODUCER_MASK =
+ GRALLOC1_PRODUCER_USAGE_CPU_READ |
+ /* GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN | */
+ GRALLOC1_PRODUCER_USAGE_CPU_WRITE |
+ /* GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN | */
+ GRALLOC1_PRODUCER_USAGE_GPU_RENDER_TARGET | GRALLOC1_PRODUCER_USAGE_PROTECTED |
+ GRALLOC1_PRODUCER_USAGE_CAMERA | GRALLOC1_PRODUCER_USAGE_VIDEO_DECODER
+#if ANDROID_VERSION_MAJOR >= 8
+ | GRALLOC1_PRODUCER_USAGE_SENSOR_DIRECT_DATA
+#endif
+ ;
+ constexpr uint64_t CONSUMER_MASK =
+ GRALLOC1_CONSUMER_USAGE_CPU_READ |
+ /* GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN | */
+ GRALLOC1_CONSUMER_USAGE_GPU_TEXTURE | GRALLOC1_CONSUMER_USAGE_HWCOMPOSER |
+ GRALLOC1_CONSUMER_USAGE_CLIENT_TARGET | GRALLOC1_CONSUMER_USAGE_CURSOR |
+ GRALLOC1_CONSUMER_USAGE_VIDEO_ENCODER | GRALLOC1_CONSUMER_USAGE_CAMERA |
+ GRALLOC1_CONSUMER_USAGE_RENDERSCRIPT
+#if ANDROID_VERSION_MAJOR >= 8
+ | GRALLOC1_CONSUMER_USAGE_GPU_DATA_BUFFER
+#endif
+ ;
+ *producerUsage = static_cast<uint64_t>(usage) & PRODUCER_MASK;
+ *consumerUsage = static_cast<uint64_t>(usage) & CONSUMER_MASK;
+ if ((static_cast<uint32_t>(usage) & GRALLOC_USAGE_SW_READ_OFTEN) == GRALLOC_USAGE_SW_READ_OFTEN) {
+ *producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN;
+ *consumerUsage |= GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN;
+ }
+ if ((static_cast<uint32_t>(usage) & GRALLOC_USAGE_SW_WRITE_OFTEN) ==
+ GRALLOC_USAGE_SW_WRITE_OFTEN) {
+ *producerUsage |= GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN;
+ }
+}
+
+int32_t android_convertGralloc1To0Usage(uint64_t producerUsage, uint64_t consumerUsage) {
+ static_assert(uint64_t(GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN) ==
+ uint64_t(GRALLOC1_PRODUCER_USAGE_CPU_READ_OFTEN),
+ "expected ConsumerUsage and ProducerUsage CPU_READ_OFTEN bits to match");
+ uint64_t merged = producerUsage | consumerUsage;
+ if ((merged & (GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN)) ==
+ GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN) {
+ merged &= ~uint64_t(GRALLOC1_CONSUMER_USAGE_CPU_READ_OFTEN);
+ merged |= GRALLOC_USAGE_SW_READ_OFTEN;
+ }
+ if ((merged & (GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN)) ==
+ GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN) {
+ merged &= ~uint64_t(GRALLOC1_PRODUCER_USAGE_CPU_WRITE_OFTEN);
+ merged |= GRALLOC_USAGE_SW_WRITE_OFTEN;
+ }
+ return static_cast<int32_t>(merged);
+}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/gralloc/Makefile.am
^
|
@@ -0,0 +1,28 @@
+lib_LTLIBRARIES = \
+ libgralloc.la
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libgralloc.pc
+
+libgralloc_la_SOURCES = gralloc.c
+
+if HAS_GRALLOC1_HEADER
+libgralloc_la_SOURCES += GrallocUsageConversion.cpp
+endif
+
+if HAS_GRALLOC1_HEADER
+libgralloc_la_CFLAGS = -DHAS_GRALLOC1_HEADER=1
+else
+libgralloc_la_CFLAGS = -DHAS_GRALLOC1_HEADER=0
+endif
+libgralloc_la_CFLAGS += -I$(top_srcdir)/include $(ANDROID_HEADERS_CFLAGS)
+libgralloc_la_CXXFLAGS = -std=gnu++11 -I$(top_srcdir)/include
+if WANT_TRACE
+libgralloc_la_CFLAGS += -DDEBUG
+endif
+if WANT_DEBUG
+libgralloc_la_CFLAGS += -ggdb -O0
+endif
+libgralloc_la_LDFLAGS = \
+ $(top_builddir)/hardware/libhardware.la \
+ -version-info "1":"0":"0"
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/gralloc/gralloc.c
^
|
@@ -0,0 +1,356 @@
+#include <stdlib.h>
+
+#include <hardware/hardware.h>
+
+#include <hardware/gralloc.h>
+#if HAS_GRALLOC1_HEADER
+#include <hybris/grallocusage/GrallocUsageConversion.h>
+#include <hardware/gralloc1.h>
+#endif
+#include <hardware/fb.h>
+
+#ifdef ANDROID_BUILD
+#include "hybris-gralloc.h"
+#else
+#include <config.h>
+#include <hybris/gralloc/gralloc.h>
+#include <hybris/common/binding.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include <dlfcn.h>
+
+static int version = -1;
+static hw_module_t *gralloc_hardware_module = NULL;
+
+static framebuffer_device_t *framebuffer_device = NULL;
+static gralloc_module_t *gralloc0_module;
+static alloc_device_t *gralloc0_alloc;
+
+#if HAS_GRALLOC1_HEADER
+static gralloc1_device_t *gralloc1_device = NULL;
+static int gralloc1_release_implies_delete = 0;
+static GRALLOC1_PFN_CREATE_DESCRIPTOR gralloc1_create_descriptor = NULL;
+static GRALLOC1_PFN_DESTROY_DESCRIPTOR gralloc1_destroy_descriptor = NULL;
+static GRALLOC1_PFN_SET_CONSUMER_USAGE gralloc1_set_consumer_usage = NULL;
+static GRALLOC1_PFN_SET_DIMENSIONS gralloc1_set_dimensions = NULL;
+static GRALLOC1_PFN_SET_FORMAT gralloc1_set_format = NULL;
+static GRALLOC1_PFN_SET_PRODUCER_USAGE gralloc1_set_producer_usage = NULL;
+static GRALLOC1_PFN_GET_BACKING_STORE gralloc1_get_backing_store = NULL;
+static GRALLOC1_PFN_GET_CONSUMER_USAGE gralloc1_get_consumer_usage = NULL;
+static GRALLOC1_PFN_GET_DIMENSIONS gralloc1_get_dimensions = NULL;
+static GRALLOC1_PFN_GET_FORMAT gralloc1_get_format = NULL;
+static GRALLOC1_PFN_GET_PRODUCER_USAGE gralloc1_get_producer_usage = NULL;
+static GRALLOC1_PFN_GET_STRIDE gralloc1_get_stride = NULL;
+static GRALLOC1_PFN_ALLOCATE gralloc1_allocate = NULL;
+static GRALLOC1_PFN_RETAIN gralloc1_retain = NULL;
+static GRALLOC1_PFN_RELEASE gralloc1_release = NULL;
+static GRALLOC1_PFN_GET_NUM_FLEX_PLANES gralloc1_get_num_flex_planes = NULL;
+static GRALLOC1_PFN_LOCK gralloc1_lock = NULL;
+static GRALLOC1_PFN_LOCK_FLEX gralloc1_lock_flex = NULL;
+static GRALLOC1_PFN_UNLOCK gralloc1_unlock = NULL;
+#ifdef GRALLOC1_PFN_SET_LAYER_COUNT
+static GRALLOC1_PFN_SET_LAYER_COUNT gralloc1_set_layer_count = NULL;
+static GRALLOC1_PFN_GET_LAYER_COUNT gralloc1_get_layer_count = NULL;
+#endif
+
+static void gralloc1_init(void);
+#endif
+
+// simple macros to make sure the code is only compiled if we actually have the
+// header to be able to compile it.
+// we could also use Gralloc1On0Adapter, but that would mean we need to import
+// headers and cpp files from android 8, which may not compile against older
+// android trees.
+#if HAS_GRALLOC1_HEADER
+#define GRALLOC0(code) (version == 0) { code }
+#define GRALLOC1(code) (version == 1) { code }
+#else
+#define GRALLOC0(code) (version == 0) { code }
+#define GRALLOC1(code) (0) {}
+#endif
+
+#define NO_GRALLOC { fprintf(stderr, "%s:%d: called gralloc method without gralloc loaded\n", __func__, __LINE__); assert(NULL); }
+
+void hybris_gralloc_deinitialize(void);
+
+void hybris_gralloc_initialize(int framebuffer)
+{
+ if (version == -1) {
+ if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, (const struct hw_module_t **)&gralloc_hardware_module) == 0) {
+#if HAS_GRALLOC1_HEADER
+ if ((gralloc1_open(gralloc_hardware_module, &gralloc1_device) == 0) && (gralloc1_device != NULL)) {
+ // success
+ gralloc1_init();
+ version = 1;
+ atexit(hybris_gralloc_deinitialize);
+ } else
+#endif
+ if (framebuffer) {
+ if (framebuffer_open(gralloc_hardware_module, &framebuffer_device) == 0) {
+ if ((gralloc_open(gralloc_hardware_module, &gralloc0_alloc) == 0) && gralloc0_alloc != NULL) {
+ // success
+ gralloc0_module = (struct gralloc_module_t*)gralloc_hardware_module;
+ version = 0;
+ atexit(hybris_gralloc_deinitialize);
+ } else {
+ fprintf(stderr, "failed to open the gralloc 0 module (framebuffer was requested therefore defaulted to version 0)\n");
+ assert(NULL);
+ }
+ } else {
+ fprintf(stderr, "failed to open the framebuffer module\n");
+ assert(NULL);
+ }
+ } else
+ if ((gralloc_open(gralloc_hardware_module, &gralloc0_alloc) == 0) && gralloc0_alloc != NULL) {
+ // success
+ gralloc0_module = (struct gralloc_module_t*)gralloc_hardware_module;
+ version = 0;
+ atexit(hybris_gralloc_deinitialize);
+ } else {
+ // fail
+ framebuffer_device = NULL;
+#if HAS_GRALLOC1_HEADER
+ gralloc1_device = NULL;
+#endif
+ version = -2;
+ fprintf(stderr, "failed to open gralloc module with both version 0 and 1 methods\n");
+ hybris_gralloc_deinitialize();
+ assert(NULL);
+ }
+ } else {
+ fprintf(stderr, "failed to find/load gralloc module\n");
+ assert(NULL);
+ }
+ } else {
+ // shouldn't reach here.
+ assert(NULL);
+ }
+}
+
+void hybris_gralloc_deinitialize(void)
+{
+ if (framebuffer_device) framebuffer_close(framebuffer_device);
+ framebuffer_device = NULL;
+
+ if (gralloc0_alloc) gralloc_close(gralloc0_alloc);
+ gralloc0_alloc = NULL;
+
+#if HAS_GRALLOC1_HEADER
+ if (gralloc1_device) gralloc1_close(gralloc1_device);
+ gralloc1_device = NULL;
+#endif
+
+#ifdef ANDROID_BUILD
+ if (gralloc_hardware_module) dlclose(gralloc_hardware_module->dso);
+#else
+ if (gralloc_hardware_module) android_dlclose(gralloc_hardware_module->dso);
+#endif
+ gralloc_hardware_module = NULL;
+}
+
+#if HAS_GRALLOC1_HEADER
+static void gralloc1_init(void)
+{
+ uint32_t count = 0;
+ gralloc1_device->getCapabilities(gralloc1_device, &count, NULL);
+
+ if (count >= 1) {
+ int32_t i;
+ int32_t *gralloc1_capabilities = (int32_t*)malloc(sizeof(int32_t) * count);
+
+ gralloc1_device->getCapabilities(gralloc1_device, &count, gralloc1_capabilities);
+
+ // currently the only one that affects us/interests us is release imply delete.
+ for (i = 0; i < count; i++) {
+#if ANDROID_VERSION_MAJOR >= 8
+ if (gralloc1_capabilities[i] == GRALLOC1_CAPABILITY_RELEASE_IMPLY_DELETE) {
+ gralloc1_release_implies_delete = 1;
+ }
+#endif
+ }
+
+ free(gralloc1_capabilities);
+ }
+
+ gralloc1_create_descriptor = (GRALLOC1_PFN_CREATE_DESCRIPTOR)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_CREATE_DESCRIPTOR);
+ gralloc1_destroy_descriptor = (GRALLOC1_PFN_DESTROY_DESCRIPTOR)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_DESTROY_DESCRIPTOR);
+ gralloc1_set_consumer_usage = (GRALLOC1_PFN_SET_CONSUMER_USAGE)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_SET_CONSUMER_USAGE);
+ gralloc1_set_dimensions = (GRALLOC1_PFN_SET_DIMENSIONS)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_SET_DIMENSIONS);
+ gralloc1_set_format = (GRALLOC1_PFN_SET_FORMAT)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_SET_FORMAT);
+ gralloc1_set_producer_usage = (GRALLOC1_PFN_SET_PRODUCER_USAGE)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_SET_PRODUCER_USAGE);
+ gralloc1_get_backing_store = (GRALLOC1_PFN_GET_BACKING_STORE)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_GET_BACKING_STORE);
+ gralloc1_get_consumer_usage = (GRALLOC1_PFN_GET_CONSUMER_USAGE)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_GET_CONSUMER_USAGE);
+ gralloc1_get_dimensions = (GRALLOC1_PFN_GET_DIMENSIONS)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_GET_DIMENSIONS);
+ gralloc1_get_format = (GRALLOC1_PFN_GET_FORMAT)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_GET_FORMAT);
+ gralloc1_get_producer_usage = (GRALLOC1_PFN_GET_PRODUCER_USAGE)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_GET_PRODUCER_USAGE);
+ gralloc1_get_stride = (GRALLOC1_PFN_GET_STRIDE)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_GET_STRIDE);
+ gralloc1_allocate = (GRALLOC1_PFN_ALLOCATE)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_ALLOCATE);
+ gralloc1_retain = (GRALLOC1_PFN_RETAIN)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_RETAIN);
+ gralloc1_release = (GRALLOC1_PFN_RELEASE)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_RELEASE);
+ gralloc1_get_num_flex_planes = (GRALLOC1_PFN_GET_NUM_FLEX_PLANES)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_GET_NUM_FLEX_PLANES);
+ gralloc1_lock = (GRALLOC1_PFN_LOCK)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_LOCK);
+ gralloc1_lock_flex = (GRALLOC1_PFN_LOCK_FLEX)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_LOCK_FLEX);
+ gralloc1_unlock = (GRALLOC1_PFN_UNLOCK)gralloc1_device->getFunction(gralloc1_device, GRALLOC1_FUNCTION_UNLOCK);
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/gralloc/libgralloc.pc.in
^
|
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: hybris-gralloc
+Description: libhybris gralloc library
+Version: @VERSION@
+Requires: android-headers
+Libs: -L${libdir} -lgralloc
+Cflags: -I${includedir}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/hwc2/Makefile.am
^
|
@@ -0,0 +1,24 @@
+lib_LTLIBRARIES = \
+ libhwc2.la
+
+libhwc2_la_SOURCES = hwc2.c
+libhwc2_la_CFLAGS = -I$(top_srcdir)/include $(ANDROID_HEADERS_CFLAGS)
+if WANT_TRACE
+libhwc2_la_CFLAGS += -DDEBUG
+endif
+if WANT_DEBUG
+libhwc2_la_CFLAGS += -ggdb -O0
+endif
+if HAS_HWCOMPOSER2_HEADERS
+libhwc2_la_CFLAGS += \
+ -DHAS_HWCOMPOSER2_HEADERS=1
+else
+libhwc2_la_CFLAGS += \
+ -DHAS_HWCOMPOSER2_HEADERS=0
+endif
+libhwc2_la_LDFLAGS = \
+ $(top_builddir)/common/libhybris-common.la \
+ -version-info "1":"0":"0"
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libhwc2.pc
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/hwc2/hwc2.c
^
|
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2018 TheKit <nekit1000@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if HAS_HWCOMPOSER2_HEADERS
+
+#include <dlfcn.h>
+#include <stddef.h>
+
+#include <hybris/common/binding.h>
+#include <hybris/hwc2/hwc2_compatibility_layer.h>
+
+#define COMPAT_LIBRARY_PATH "libhwc2_compat_layer.so"
+
+HYBRIS_LIBRARY_INITIALIZE(hwc2, COMPAT_LIBRARY_PATH);
+
+HYBRIS_IMPLEMENT_FUNCTION1(hwc2, hwc2_compat_device_t*, hwc2_compat_device_new,
+ bool);
+
+HYBRIS_IMPLEMENT_VOID_FUNCTION3(hwc2, hwc2_compat_device_register_callback,
+ hwc2_compat_device_t*, HWC2EventListener*, int);
+
+HYBRIS_IMPLEMENT_VOID_FUNCTION3(hwc2, hwc2_compat_device_on_hotplug,
+ hwc2_compat_device_t*, hwc2_display_t, bool);
+
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_compat_display_t*,
+ hwc2_compat_device_get_display_by_id,
+ hwc2_compat_device_t*,
+ hwc2_display_t);
+
+HYBRIS_IMPLEMENT_FUNCTION1(hwc2, HWC2DisplayConfig*,
+ hwc2_compat_display_get_active_config,
+ hwc2_compat_display_t*);
+
+HYBRIS_IMPLEMENT_FUNCTION1(hwc2, hwc2_error_t,
+ hwc2_compat_display_accept_changes,
+ hwc2_compat_display_t*);
+
+HYBRIS_IMPLEMENT_FUNCTION1(hwc2, hwc2_compat_layer_t*,
+ hwc2_compat_display_create_layer,
+ hwc2_compat_display_t*);
+
+HYBRIS_IMPLEMENT_VOID_FUNCTION2(hwc2, hwc2_compat_display_destroy_layer,
+ hwc2_compat_display_t*, hwc2_compat_layer_t*);
+
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t,
+ hwc2_compat_display_get_release_fences,
+ hwc2_compat_display_t*, hwc2_compat_out_fences_t**);
+
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_display_present,
+ hwc2_compat_display_t*, int32_t*);
+
+HYBRIS_IMPLEMENT_FUNCTION5(hwc2, hwc2_error_t, hwc2_compat_display_set_client_target,
+ hwc2_compat_display_t*, uint32_t,
+ ANativeWindowBuffer_t*, int32_t,
+ android_dataspace_t);
+
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_display_set_power_mode,
+ hwc2_compat_display_t*, int);
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_display_set_vsync_enabled,
+ hwc2_compat_display_t*, int);
+
+HYBRIS_IMPLEMENT_FUNCTION3(hwc2, hwc2_error_t, hwc2_compat_display_validate,
+ hwc2_compat_display_t*, uint32_t*, uint32_t*);
+
+HYBRIS_IMPLEMENT_FUNCTION5(hwc2, hwc2_error_t, hwc2_compat_display_present_or_validate,
+ hwc2_compat_display_t*, uint32_t*, uint32_t*,
+ int32_t*, uint32_t*);
+
+HYBRIS_IMPLEMENT_FUNCTION4(hwc2, hwc2_error_t, hwc2_compat_layer_set_buffer,
+ hwc2_compat_layer_t*, uint32_t,
+ ANativeWindowBuffer_t*, int32_t);
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_layer_set_blend_mode,
+ hwc2_compat_layer_t*, int);
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_layer_set_color,
+ hwc2_compat_layer_t*, hwc_color_t);
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_layer_set_composition_type,
+ hwc2_compat_layer_t*, int);
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_layer_set_dataspace,
+ hwc2_compat_layer_t*, android_dataspace_t);
+HYBRIS_IMPLEMENT_FUNCTION5(hwc2, hwc2_error_t, hwc2_compat_layer_set_display_frame,
+ hwc2_compat_layer_t*, int32_t, int32_t,
+ int32_t, int32_t);
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_layer_set_plane_alpha,
+ hwc2_compat_layer_t*, float);
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_layer_set_sideband_stream,
+ hwc2_compat_layer_t*, native_handle_t*);
+HYBRIS_IMPLEMENT_FUNCTION5(hwc2, hwc2_error_t, hwc2_compat_layer_set_source_crop,
+ hwc2_compat_layer_t*, float, float, float, float);
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, hwc2_error_t, hwc2_compat_layer_set_transform,
+ hwc2_compat_layer_t*, int);
+HYBRIS_IMPLEMENT_FUNCTION5(hwc2, hwc2_error_t, hwc2_compat_layer_set_visible_region,
+ hwc2_compat_layer_t*, int32_t, int32_t,
+ int32_t, int32_t);
+
+HYBRIS_IMPLEMENT_FUNCTION2(hwc2, int32_t, hwc2_compat_out_fences_get_fence,
+ hwc2_compat_out_fences_t*, hwc2_compat_layer_t*);
+HYBRIS_IMPLEMENT_VOID_FUNCTION1(hwc2, hwc2_compat_out_fences_destroy,
+ hwc2_compat_out_fences_t*);
+
+#endif
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/hwc2/libhwc2.pc.in
^
|
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=@includedir@
+
+Name: hybris-hwcomposer2
+Description: libhybris hwcomposer2 library
+Version: @VERSION@
+Libs: -L${libdir} -lhybris-common -lhwc2
+Cflags: -I${includedir}
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/include/Makefile.am
^
|
@@ -47,6 +47,10 @@
surface_flingerinclude_HEADERS = \
hybris/surface_flinger/surface_flinger_compatibility_layer.h
+hwc2includedir = $(includedir)/hybris/hwc2
+hwc2include_HEADERS = \
+ hybris/hwc2/hwc2_compatibility_layer.h
+
inputincludedir = $(includedir)/hybris/input
inputinclude_HEADERS = \
hybris/input/input_stack_compatibility_layer_codes_key.h \
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/include/hybris/common/binding.h
^
|
@@ -28,7 +28,7 @@
void *android_dlopen(const char *filename, int flag);
void *android_dlsym(void *name, const char *symbol);
int android_dlclose(void *handle);
-const char *android_dlerror(void);
+char *android_dlerror(void);
int android_dladdr(const void *addr, void *info);
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/include/hybris/common/dlfcn.h
^
|
@@ -25,7 +25,7 @@
void *hybris_dlopen(const char *filename, int flag);
void *hybris_dlsym(void *handle, const char *symbol);
int hybris_dlclose(void *handle);
-const char *hybris_dlerror(void);
+char *hybris_dlerror(void);
#ifdef __cplusplus
}
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/include/hybris/gralloc/gralloc.h
^
|
@@ -0,0 +1,36 @@
+#ifndef hybris_gralloc_header_include_guard__
+#define hybris_gralloc_header_include_guard__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// for usage definitions and so on
+#if HAS_GRALLOC1_HEADER
+#include <hardware/gralloc1.h>
+#endif
+#include <hardware/gralloc.h>
+
+#include <cutils/native_handle.h>
+
+void hybris_gralloc_deinitialize(void);
+void hybris_gralloc_initialize(int framebuffer);
+void hybris_gralloc_deinitialize(void);
+int hybris_gralloc_release(buffer_handle_t handle, int was_allocated);
+int hybris_gralloc_retain(buffer_handle_t handle);
+int hybris_gralloc_allocate(int width, int height, int format, int usage, buffer_handle_t *handle, uint32_t *stride);
+int hybris_gralloc_lock(buffer_handle_t handle, int usage, int l, int t, int w, int h, void **vaddr);
+int hybris_gralloc_unlock(buffer_handle_t handle);
+int hybris_gralloc_fbdev_format(void);
+int hybris_gralloc_fbdev_framebuffer_count(void);
+int hybris_gralloc_fbdev_setSwapInterval(int interval);
+int hybris_gralloc_fbdev_post(buffer_handle_t handle);
+int hybris_gralloc_fbdev_width(void);
+int hybris_gralloc_fbdev_height(void);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/include/hybris/grallocusage/GrallocUsageConversion.h
^
|
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_GRALLOCUSAGE_GRALLOC_USAGE_CONVERSION_H
+#define ANDROID_GRALLOCUSAGE_GRALLOC_USAGE_CONVERSION_H 1
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Conversion functions are out-of-line so that users don't have to be exposed to
+// android/hardware/graphics/allocator/2.0/types.h and link against
+// android.hardware.graphics.allocator@2.0 to get that in their search path.
+
+// Convert a 32-bit gralloc0 usage mask to a producer/consumer pair of 64-bit usage masks as used
+// by android.hardware.graphics.allocator@2.0 (and gralloc1). This conversion properly handles the
+// mismatch between a.h.g.allocator@2.0's CPU_{READ,WRITE}_OFTEN and gralloc0's
+// SW_{READ,WRITE}_OFTEN.
+void android_convertGralloc0To1Usage(int32_t usage, uint64_t* producerUsage,
+ uint64_t* consumerUsage);
+
+// Convert a producer/consumer pair of 64-bit usage masks as used by
+// android.hardware.graphics.allocator@2.0 (and gralloc1) to a 32-bit gralloc0 usage mask. This
+// conversion properly handles the mismatch between a.h.g.allocator@2.0's CPU_{READ,WRITE}_OFTEN
+// and gralloc0's SW_{READ,WRITE}_OFTEN.
+int32_t android_convertGralloc1To0Usage(uint64_t producerUsage, uint64_t consumerUsage);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ANDROID_GRALLOCUSAGE_GRALLOC_USAGE_CONVERSION_H
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/include/hybris/hwc2/hwc2_compatibility_layer.h
^
|
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2018 TheKit <nekit1000@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HWC2_COMPATIBILITY_LAYER_H_
+#define HWC2_COMPATIBILITY_LAYER_H_
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <unistd.h>
+
+#include <hardware/hwcomposer2.h>
+#include <system/graphics.h>
+#include <system/window.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ struct HWC2EventListener;
+ typedef struct HWC2EventListener HWC2EventListener;
+
+ typedef void (*on_vsync_received_callback)(HWC2EventListener* self,
+ int32_t sequenceId, hwc2_display_t display,
+ int64_t timestamp);
+ typedef void (*on_hotplug_received_callback)(HWC2EventListener* self,
+ int32_t sequenceId, hwc2_display_t display,
+ bool connected, bool primaryDisplay);
+ typedef void (*on_refresh_received_callback)(HWC2EventListener* self,
+ int32_t sequenceId, hwc2_display_t display);
+
+ struct HWC2EventListener
+ {
+ on_vsync_received_callback on_vsync_received;
+ on_hotplug_received_callback on_hotplug_received;
+ on_refresh_received_callback on_refresh_received;
+ };
+
+ typedef struct HWC2DisplayConfig {
+ hwc2_config_t id;
+ hwc2_display_t display;
+ int32_t width;
+ int32_t height;
+ int64_t vsyncPeriod;
+ float dpiX;
+ float dpiY;
+ } HWC2DisplayConfig;
+
+ struct hwc2_compat_device;
+ typedef struct hwc2_compat_device hwc2_compat_device_t;
+
+ struct hwc2_compat_display;
+ typedef struct hwc2_compat_display hwc2_compat_display_t;
+
+ struct hwc2_compat_layer;
+ typedef struct hwc2_compat_layer hwc2_compat_layer_t;
+
+ struct hwc2_compat_out_fences;
+ typedef struct hwc2_compat_out_fences hwc2_compat_out_fences_t;
+
+ hwc2_compat_device_t* hwc2_compat_device_new(bool);
+ void hwc2_compat_device_register_callback(hwc2_compat_device_t* device,
+ HWC2EventListener* listener,
+ int composerSequenceId);
+
+ void hwc2_compat_device_on_hotplug(hwc2_compat_device_t* device,
+ hwc2_display_t displayId,
+ bool connected);
+
+ hwc2_compat_display_t* hwc2_compat_device_get_display_by_id(
+ hwc2_compat_device_t* device,
+ hwc2_display_t id);
+
+ HWC2DisplayConfig* hwc2_compat_display_get_active_config(
+ hwc2_compat_display_t* display);
+
+ hwc2_error_t hwc2_compat_display_accept_changes(hwc2_compat_display_t* display);
+ hwc2_compat_layer_t* hwc2_compat_display_create_layer(hwc2_compat_display_t*
+ display);
+ void hwc2_compat_display_destroy_layer(hwc2_compat_display_t* display,
+ hwc2_compat_layer_t* layer);
+
+ hwc2_error_t hwc2_compat_display_get_release_fences(
+ hwc2_compat_display_t* display,
+ hwc2_compat_out_fences_t** outFences);
+
+ hwc2_error_t hwc2_compat_display_present(hwc2_compat_display_t* display,
+ int32_t* outPresentFence);
+
+ hwc2_error_t hwc2_compat_display_set_client_target(hwc2_compat_display_t* display,
+ uint32_t slot,
+ struct ANativeWindowBuffer* buffer,
+ const int32_t acquireFenceFd,
+ android_dataspace_t dataspace);
+
+ hwc2_error_t hwc2_compat_display_set_power_mode(hwc2_compat_display_t* display,
+ int mode);
+ hwc2_error_t hwc2_compat_display_set_vsync_enabled(hwc2_compat_display_t* display,
+ int enabled);
+
+ hwc2_error_t hwc2_compat_display_validate(hwc2_compat_display_t* display,
+ uint32_t* outNumTypes,
+ uint32_t* outNumRequests);
+
+ hwc2_error_t hwc2_compat_display_present_or_validate(hwc2_compat_display_t* display,
+ uint32_t* outNumTypes,
+ uint32_t* outNumRequests,
+ int32_t* outPresentFence,
+ uint32_t* state);
+
+ hwc2_error_t hwc2_compat_layer_set_buffer(hwc2_compat_layer_t* layer,
+ uint32_t slot,
+ struct ANativeWindowBuffer* buffer,
+ const int32_t acquireFenceFd);
+ hwc2_error_t hwc2_compat_layer_set_blend_mode(hwc2_compat_layer_t* layer, int mode);
+ hwc2_error_t hwc2_compat_layer_set_color(hwc2_compat_layer_t* layer,
+ hwc_color_t color);
+ hwc2_error_t hwc2_compat_layer_set_composition_type(hwc2_compat_layer_t* layer,
+ int type);
+ hwc2_error_t hwc2_compat_layer_set_dataspace(hwc2_compat_layer_t* layer,
+ android_dataspace_t dataspace);
+ hwc2_error_t hwc2_compat_layer_set_display_frame(hwc2_compat_layer_t* layer,
+ int32_t left, int32_t top,
+ int32_t right, int32_t bottom);
+ hwc2_error_t hwc2_compat_layer_set_plane_alpha(hwc2_compat_layer_t* layer,
+ float alpha);
+ hwc2_error_t hwc2_compat_layer_set_sideband_stream(hwc2_compat_layer_t* layer,
+ native_handle_t* stream);
+ hwc2_error_t hwc2_compat_layer_set_source_crop(hwc2_compat_layer_t* layer,
+ float left, float top,
+ float right, float bottom);
+ hwc2_error_t hwc2_compat_layer_set_transform(hwc2_compat_layer_t* layer,
+ int transform);
+ hwc2_error_t hwc2_compat_layer_set_visible_region(hwc2_compat_layer_t* layer,
+ int32_t left, int32_t top,
+ int32_t right, int32_t bottom);
+
+ int32_t hwc2_compat_out_fences_get_fence(hwc2_compat_out_fences_t* fences,
+ hwc2_compat_layer_t* layer);
+ void hwc2_compat_out_fences_destroy(hwc2_compat_out_fences_t* fences);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HWC2_COMPATIBILITY_LAYER_H_
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/include/hybris/properties/properties.h
^
|
@@ -25,6 +25,8 @@
#include <unistd.h>
#include <stdint.h>
+#include <android-config.h>
+
/* Based on Android */
#define PROP_SERVICE_NAME "property_service"
@@ -33,6 +35,9 @@
/* Only SETPROP is defined by Android, for GETPROP and LISTPROP to work
* an extended Android init service needs to be in place */
+/* Starting from android 8 getprop and listprop are handled in libhybris
+ * via bionic, thus the init service does not need to be patched for this
+ * anymore */
#define PROP_MSG_SETPROP 1
#define PROP_MSG_GETPROP 2
#define PROP_MSG_LISTPROP 3
@@ -41,15 +46,9 @@
extern "C" {
#endif
- typedef struct prop_msg_s {
- unsigned cmd;
- char name[PROP_NAME_MAX];
- char value[PROP_VALUE_MAX];
- } prop_msg_t;
-
- int property_set(const char *key, const char *value);
- int property_get(const char *key, char *value, const char *default_value);
- int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie);
+int property_set(const char *key, const char *value);
+int property_get(const char *key, char *value, const char *default_value);
+int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie);
#ifdef __cplusplus
}
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/libnfc_ndef_nxp/Makefile.am
^
|
@@ -7,6 +7,14 @@
$(ANDROID_HEADERS_CFLAGS) \
-Wno-error=unused-function
+if HAS_LIBNFC_NXP_HEADERS
+libnfc_ndef_nxp_la_CFLAGS += \
+ -DHAS_LIBNFC_NXP_HEADERS=1
+else
+libnfc_ndef_nxp_la_CFLAGS += \
+ -DHAS_LIBNFC_NXP_HEADERS=0
+endif
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnfc_ndef_nxp.pc
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/libnfc_ndef_nxp/libnfc_ndef_nxp.c
^
|
@@ -17,10 +17,11 @@
*/
/**
- * Bindings generated using:
- * https://github.com/thp/libhybris-nfc-wrapper-generator
+ * Bindings generated using scripts in: utils/generate_nfc
**/
+#if HAS_LIBNFC_NXP_HEADERS
+
#include <libnfc-nxp/phNfcStatus.h>
#include <libnfc-nxp/phNfcTypes.h>
#include <libnfc-nxp/phNfcIoctlCode.h>
@@ -41,3 +42,5 @@
HYBRIS_IMPLEMENT_FUNCTION2(libnfc_ndef_so, NFCSTATUS, phFriNfc_NdefRecord_Parse, phFriNfc_NdefRecord_t *, uint8_t *);
HYBRIS_IMPLEMENT_FUNCTION4(libnfc_ndef_so, NFCSTATUS, phFriNfc_NdefRecord_Generate, phFriNfc_NdefRecord_t *, uint8_t *, uint32_t, uint32_t *);
/* XXX No prototype for exported symbol: __on_dlclose */
+#endif
+
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/libnfc_nxp/Makefile.am
^
|
@@ -7,6 +7,14 @@
$(ANDROID_HEADERS_CFLAGS) \
-Wno-error=unused-function
+if HAS_LIBNFC_NXP_HEADERS
+libnfc_nxp_la_CFLAGS += \
+ -DHAS_LIBNFC_NXP_HEADERS=1
+else
+libnfc_nxp_la_CFLAGS += \
+ -DHAS_LIBNFC_NXP_HEADERS=0
+endif
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnfc_nxp.pc
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/libnfc_nxp/libnfc_nxp.c
^
|
@@ -17,10 +17,11 @@
*/
/**
- * Bindings generated using:
- * https://github.com/thp/libhybris-nfc-wrapper-generator
+ * Bindings generated using scripts in: utils/generate_nfc
**/
+#if HAS_LIBNFC_NXP_HEADERS
+
#include <android-config.h>
#include <libnfc-nxp/phNfcTypes.h>
@@ -594,3 +595,5 @@
HYBRIS_IMPLEMENT_FUNCTION3(libnfc_so, int, phDal4Nfc_msgctl, int, int, void *);
HYBRIS_IMPLEMENT_FUNCTION5(libnfc_so, int, phDal4Nfc_msgrcv, int, void *, size_t, long, int);
/* XXX No prototype for exported symbol: __on_dlclose */
+#endif
+
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/libsync/sync.c
^
|
@@ -21,22 +21,119 @@
#include <string.h>
#include <stdlib.h>
+#include <android-version.h>
+
+#if (ANDROID_VERSION_MAJOR <= 7)
#include <linux/sync.h>
#include <linux/sw_sync.h>
+#else
+#include <sync/sync.h>
+#endif
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
+#if (ANDROID_VERSION_MAJOR >= 8)
+#include <errno.h>
+#include <linux/types.h>
+#include <poll.h>
+#include <../common/n/bionic/libc/include/stdatomic.h>
+
+enum uapi_version {
+ UAPI_UNKNOWN,
+ UAPI_MODERN,
+ UAPI_LEGACY
+};
+static atomic_int g_uapi_version = ATOMIC_VAR_INIT(UAPI_UNKNOWN);
+
+/* Legacy Sync API */
+
+struct sync_legacy_merge_data {
+ int32_t fd2;
+ char name[32];
+ int32_t fence;
+};
+/**
+ * DOC: SYNC_IOC_MERGE - merge two fences
+ *
+ * Takes a struct sync_merge_data. Creates a new fence containing copies of
+ * the sync_pts in both the calling fd and sync_merge_data.fd2. Returns the
+ * new fence's fd in sync_merge_data.fence
+ *
+ * This is the legacy version of the Sync API before the de-stage that happened
+ * on Linux kernel 4.7.
+ */
+#define SYNC_IOC_LEGACY_MERGE _IOWR(SYNC_IOC_MAGIC, 1, \
+ struct sync_legacy_merge_data)
+/**
+ * DOC: SYNC_IOC_LEGACY_FENCE_INFO - get detailed information on a fence
+ *
+ * Takes a struct sync_fence_info_data with extra space allocated for pt_info.
+ * Caller should write the size of the buffer into len. On return, len is
+ * updated to reflect the total size of the sync_fence_info_data including
+ * pt_info.
+ *
+ * pt_info is a buffer containing sync_pt_infos for every sync_pt in the fence.
+ * To iterate over the sync_pt_infos, use the sync_pt_info.len field.
+ *
+ * This is the legacy version of the Sync API before the de-stage that happened
+ * on Linux kernel 4.7.
+ */
+
+#define SYNC_IOC_LEGACY_FENCE_INFO _IOWR(SYNC_IOC_MAGIC, 2,\
+ struct sync_fence_info_data)
+
+/* SW Sync API */
+struct sw_sync_create_fence_data {
+ __u32 value;
+ char name[32];
+ __s32 fence;
+};
+
+#define SW_SYNC_IOC_MAGIC 'W'
+#define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0, struct sw_sync_create_fence_data)
+#define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32)
+
+
+
+#endif //(ANDROID_VERSION_MAJOR >= 8)
+
extern size_t strlcpy(char *dst, const char *src, size_t siz);
int sync_wait(int fd, int timeout)
{
+#if (ANDROID_VERSION_MAJOR <= 7)
__s32 to = timeout;
return ioctl(fd, SYNC_IOC_WAIT, &to);
+#else
+ struct pollfd fds;
+ int ret;
+ if (fd < 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ fds.fd = fd;
+ fds.events = POLLIN;
+ do {
+ ret = poll(&fds, 1, timeout);
+ if (ret > 0) {
+ if (fds.revents & (POLLERR | POLLNVAL)) {
+ errno = EINVAL;
+ return -1;
+ }
+ return 0;
+ } else if (ret == 0) {
+ errno = ETIME;
+ return -1;
+ }
+ } while (ret == -1 && (errno == EINTR || errno == EAGAIN));
+ return ret;
+#endif
}
+#if (ANDROID_VERSION_MAJOR <= 7)
int sync_merge(const char *name, int fd1, int fd2)
{
struct sync_merge_data data;
@@ -51,7 +148,64 @@
return data.fence;
}
+#else
+static int legacy_sync_merge(const char *name, int fd1, int fd2)
+{
+ struct sync_legacy_merge_data data;
+ int ret;
+
+ data.fd2 = fd2;
+ strlcpy(data.name, name, sizeof(data.name));
+ ret = ioctl(fd1, SYNC_IOC_LEGACY_MERGE, &data);
+ if (ret < 0)
+ return ret;
+ return data.fence;
+}
+
+static int modern_sync_merge(const char *name, int fd1, int fd2)
+{
+ struct sync_merge_data data;
+ int ret;
+
+ data.fd2 = fd2;
+ strlcpy(data.name, name, sizeof(data.name));
+ data.flags = 0;
+ data.pad = 0;
+
+ ret = ioctl(fd1, SYNC_IOC_MERGE, &data);
+ if (ret < 0)
+ return ret;
+ return data.fence;
+}
+
+int sync_merge(const char *name, int fd1, int fd2)
+{
+ int uapi;
+ int ret;
+ uapi = atomic_load_explicit(&g_uapi_version, memory_order_acquire);
+
+ if (uapi == UAPI_MODERN || uapi == UAPI_UNKNOWN) {
+ ret = modern_sync_merge(name, fd1, fd2);
+ if (ret >= 0 || errno != ENOTTY) {
+ if (ret >= 0 && uapi == UAPI_UNKNOWN) {
+ atomic_store_explicit(&g_uapi_version, UAPI_MODERN,
+ memory_order_release);
+ }
+ return ret;
+ }
+ }
+
+ ret = legacy_sync_merge(name, fd1, fd2);
+ if (ret >= 0 && uapi == UAPI_UNKNOWN) {
+ atomic_store_explicit(&g_uapi_version, UAPI_LEGACY,
+ memory_order_release);
+ }
+ return ret;
+}
+#endif
+
+#if (ANDROID_VERSION_MAJOR <= 7)
struct sync_fence_info_data *sync_fence_info(int fd)
{
struct sync_fence_info_data *info;
@@ -70,6 +224,188 @@
return info;
}
+#else
+static struct sync_fence_info_data *legacy_sync_fence_info(int fd)
+{
+ struct sync_fence_info_data *legacy_info;
+ int err;
+
+ legacy_info = malloc(4096);
+ if (legacy_info == NULL)
+ return NULL;
+
+ legacy_info->len = 4096;
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/properties/Makefile.am
^
|
@@ -1,19 +1,20 @@
lib_LTLIBRARIES = \
libandroid-properties.la
-libandroid_properties_la_SOURCES = properties.c cache.c
-libandroid_properties_la_CFLAGS = -I$(top_srcdir)/include $(ANDROID_HEADERS_CFLAGS)
-if WANT_RUNTIME_PROPERTY_CACHE
-libandroid_properties_la_SOURCES += runtime_cache.c
-else
-libandroid_properties_la_CFLAGS += -DNO_RUNTIME_PROPERTY_CACHE
-endif
+libandroid_properties_la_SOURCES = hybris_properties.c
if WANT_DEBUG
-libandroid_properties_la_CFLAGS += -ggdb -O0
+libandroid_properties_la_CFLAGS = -ggdb -O0
+else
+libandroid_properties_la_CFLAGS =
endif
+
+libandroid_properties_la_CFLAGS += -I$(top_srcdir)/include
+
libandroid_properties_la_LDFLAGS = \
+ $(top_srcdir)/common/libhybris-common.la \
-version-info "1":"0":"0"
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libandroid-properties.pc
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/properties/hybris_properties.c
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2018 Jolla Ltd. <franz.haider@jolla.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+#include <hybris/common/binding.h>
+
+static void *libcutils = NULL;
+
+// These may point to the libhybris implementation or to the bionic implementation, depending on the linker being used.
+static int (*bionic_property_list)(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie) = NULL;
+static int (*bionic_property_get)(const char *key, char *value, const char *default_value) = NULL;
+static int (*bionic_property_set)(const char *key, const char *value) = NULL;
+
+static void unload_libcutils(void)
+{
+ if (libcutils) {
+ android_dlclose(libcutils);
+ }
+}
+
+#define PROPERTY_DLSYM(func) {*(void **)(&bionic_##func) = (void*)android_dlsym(libcutils, #func); \
+ if (!bionic_##func) { \
+ fprintf(stderr, "failed to load " #func " from bionic libcutils\n"); \
+ abort(); \
+ }}
+
+static void ensure_bionic_properties_initialized(void)
+{
+ if (!libcutils) {
+ libcutils = android_dlopen("libcutils.so", RTLD_LAZY);
+ if (libcutils) {
+ PROPERTY_DLSYM(property_get);
+ PROPERTY_DLSYM(property_set);
+ PROPERTY_DLSYM(property_list);
+ atexit(unload_libcutils);
+ } else {
+ fprintf(stderr, "failed to load bionic libc.so\n");
+ abort();
+ }
+ }
+}
+
+int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie)
+{
+ ensure_bionic_properties_initialized();
+
+ return bionic_property_list(propfn, cookie);
+}
+
+int property_get(const char *key, char *value, const char *default_value)
+{
+ ensure_bionic_properties_initialized();
+
+ return bionic_property_get(key, value, default_value);
+}
+
+int property_set(const char *key, const char *value)
+{
+ ensure_bionic_properties_initialized();
+
+ return bionic_property_set(key, value);
+}
+
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/tests/Makefile.am
^
|
@@ -13,34 +13,11 @@
test_recorder \
test_gps \
test_opencl \
- test_wifi
+ test_wifi \
+ test_hwc2 \
+ test_hwcomposer \
+ test_nfc
-if HAS_ANDROID_4_2_0
-bin_PROGRAMS += test_hwcomposer
-endif
-
-if HAS_ANDROID_5_0_0
-bin_PROGRAMS += test_hwcomposer
-endif
-
-
-if HAS_LIBNFC_NXP_HEADERS
-# test_nfc depends on NFC hardware HAL interface, which is only
-# available until Android API level 15 (v4.0.3, v4.0.4).
-if HAS_ANDROID_4_0_3
-bin_PROGRAMS += test_nfc
-else
-if HAS_ANDROID_4_1_0
-bin_PROGRAMS += test_nfc
-else
-if HAS_ANDROID_5_0_0
-bin_PROGRAMS += test_nfc
-endif
-endif
-endif
-endif
-
-bin_PROGRAMS += test_audio
test_audio_SOURCES = test_audio.c
test_audio_CFLAGS = \
-I$(top_srcdir)/include \
@@ -98,13 +75,24 @@
test_hwcomposer_LDADD = \
-lm \
$(top_builddir)/common/libhybris-common.la \
- $(top_builddir)/egl/platforms/hwcomposer/libhybris-hwcomposerwindow.la \
$(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
$(top_builddir)/egl/libEGL.la \
$(top_builddir)/glesv2/libGLESv2.la \
- $(top_builddir)/libsync/libsync.la \
$(top_builddir)/hardware/libhardware.la
+
+if HAS_ANDROID_4_2_0
+test_hwcomposer_LDADD += \
+ $(top_builddir)/libsync/libsync.la \
+ $(top_builddir)/egl/platforms/hwcomposer/libhybris-hwcomposerwindow.la
+else
+if HAS_ANDROID_5_0_0
+test_hwcomposer_LDADD += \
+ $(top_builddir)/libsync/libsync.la \
+ $(top_builddir)/egl/platforms/hwcomposer/libhybris-hwcomposerwindow.la
+endif
+endif
+
test_sensors_SOURCES = test_sensors.c
test_sensors_CFLAGS = \
-I$(top_srcdir)/include \
@@ -196,6 +184,15 @@
-I$(top_srcdir)/include \
$(ANDROID_HEADERS_CFLAGS) \
-Wno-error=unused-function
+
+if HAS_LIBNFC_NXP_HEADERS
+test_nfc_CFLAGS += \
+ -DHAS_LIBNFC_NXP_HEADERS=1
+else
+test_nfc_CFLAGS += \
+ -DHAS_LIBNFC_NXP_HEADERS=0
+endif
+
test_nfc_LDFLAGS = -pthread
test_nfc_LDADD = \
$(top_builddir)/common/libhybris-common.la \
@@ -206,6 +203,11 @@
test_vibrator_CFLAGS = \
-I$(top_srcdir)/include \
$(ANDROID_HEADERS_CFLAGS)
+if HAS_VIBRATOR_HEADER
+test_vibrator_CFLAGS += -DHAS_VIBRATOR_HEADER=1
+else
+test_vibrator_CFLAGS += -DHAS_VIBRATOR_HEADER=0
+endif
test_vibrator_LDADD = \
$(top_builddir)/common/libhybris-common.la \
$(top_builddir)/hardware/libhardware.la \
@@ -215,6 +217,15 @@
test_wifi_CFLAGS = \
-I$(top_srcdir)/include \
$(ANDROID_HEADERS_CFLAGS)
+
+if HAS_WIFI_LEGACY_HEADERS
+test_wifi_CFLAGS += \
+ -DHAS_WIFI_LEGACY_HEADERS=1
+else
+test_wifi_CFLAGS += \
+ -DHAS_WIFI_LEGACY_HEADERS=0
+endif
+
test_wifi_LDADD = \
$(top_builddir)/wifi/libwifi.la
@@ -226,3 +237,33 @@
$(top_builddir)/common/libhybris-common.la \
$(top_builddir)/opencl/libOpenCL.la
+test_hwc2_SOURCES = test_hwc2.cpp
+test_hwc2_CXXFLAGS = \
+ -I$(top_srcdir)/include \
+ $(ANDROID_HEADERS_CFLAGS) \
+ -I$(top_srcdir)/common \
+ -I$(top_srcdir)/egl/platforms/common \
+ -I$(top_srcdir)/egl/platforms/hwcomposer \
+ -I$(top_srcdir)/libsync \
+ -std=gnu++11
+
+if HAS_HWCOMPOSER2_HEADERS
+test_hwc2_CXXFLAGS += \
+ -DHAS_HWCOMPOSER2_HEADERS=1
+else
+test_hwc2_CXXFLAGS += \
+ -DHAS_HWCOMPOSER2_HEADERS=0
+endif
+
+if HAS_ANDROID_7_0_0
+test_hwc2_LDADD = \
+ -lm \
+ $(top_builddir)/common/libhybris-common.la \
+ $(top_builddir)/egl/platforms/hwcomposer/libhybris-hwcomposerwindow.la \
+ $(top_builddir)/egl/platforms/common/libhybris-eglplatformcommon.la \
+ $(top_builddir)/egl/libEGL.la \
+ $(top_builddir)/glesv2/libGLESv2.la \
+ $(top_builddir)/libsync/libsync.la \
+ $(top_builddir)/hwc2/libhwc2.la
+endif
+
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/tests/test_gps.c
^
|
@@ -277,11 +277,19 @@
{
case GPS_REQUEST_AGPS_DATA_CONN:
fprintf(stdout, "*** data_conn_open\n");
- AGps->data_conn_open(apn);
+#if ANDROID_VERSION_MAJOR == 4 && ANDROID_VERSION_MINOR < 2
+ AGps->data_conn_open(AGPS_TYPE_SUPL, apn, AGPS_APN_BEARER_IPV4);
+#else
+ AGps->data_conn_open(apn);
+#endif
break;
case GPS_RELEASE_AGPS_DATA_CONN:
fprintf(stdout, "*** data_conn_closed\n");
+#if ANDROID_VERSION_MAJOR == 4 && ANDROID_VERSION_MINOR < 2
+ AGps->data_conn_closed(AGPS_TYPE_SUPL);
+#else
AGps->data_conn_closed();
+#endif
break;
case GPS_AGPS_DATA_CONNECTED:
fprintf(stdout, "*** data_conn_established\n");
@@ -395,7 +403,7 @@
fprintf(stdout, "*** cleanup\n");
if(AGps)
{
-#if ! defined(HAS_ANDROID_4_2_0) && ! defined(HAS_ANDROID_5_0_0)
+#if ANDROID_VERSION_MAJOR == 4 && ANDROID_VERSION_MINOR < 2
AGps->data_conn_closed(AGPS_TYPE_SUPL);
#else
AGps->data_conn_closed();
@@ -603,7 +611,11 @@
}
if (AGps)
- AGps->data_conn_closed(AGPS_TYPE_SUPL);
+#if ANDROID_VERSION_MAJOR == 4 && ANDROID_VERSION_MINOR < 2
+ AGps->data_conn_closed(AGPS_TYPE_SUPL);
+#else
+ AGps->data_conn_closed();
+#endif
fprintf(stdout, "*** stop tracking\n");
Gps->stop();
fprintf(stdout, "*** cleaning up\n");
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/tests/test_hwc2.cpp
^
|
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2018 TheKit <nekit1000@gmail.com>
+ * Copyright (c) 2012 Carsten Munk <carsten.munk@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#if HAS_HWCOMPOSER2_HEADERS
+
+#include <assert.h>
+#include <stdio.h>
+#include <math.h>
+#include <mutex>
+
+#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+#include <cutils/log.h>
+#include <sync/sync.h>
+
+#include <hwcomposer_window.h>
+
+#include <hybris/hwc2/hwc2_compatibility_layer.h>
+#include "logging.h"
+
+const char vertex_src [] =
+" \
+ attribute vec4 position; \
+ varying mediump vec2 pos; \
+ uniform vec4 offset; \
+ \
+ void main() \
+ { \
+ gl_Position = position + offset; \
+ pos = position.xy; \
+ } \
+";
+
+
+const char fragment_src [] =
+" \
+ varying mediump vec2 pos; \
+ uniform mediump float phase; \
+ \
+ void main() \
+ { \
+ gl_FragColor = vec4( 1., 0.9, 0.7, 1.0 ) * \
+ cos( 30.*sqrt(pos.x*pos.x + 1.5*pos.y*pos.y) \
+ + atan(pos.y,pos.x) - phase ); \
+ } \
+";
+
+GLuint load_shader(const char *shader_source, GLenum type)
+{
+ GLuint shader = glCreateShader(type);
+
+ glShaderSource(shader, 1, &shader_source, NULL);
+ glCompileShader(shader);
+
+ return shader;
+}
+
+
+GLfloat norm_x = 0.0;
+GLfloat norm_y = 0.0;
+GLfloat offset_x = 0.0;
+GLfloat offset_y = 0.0;
+GLfloat p1_pos_x = 0.0;
+GLfloat p1_pos_y = 0.0;
+
+GLint phase_loc;
+GLint offset_loc;
+GLint position_loc;
+
+const float vertexArray[] = {
+ 0.0, 1.0, 0.0,
+ -1., 0.0, 0.0,
+ 0.0, -1.0, 0.0,
+ 1., 0.0, 0.0,
+ 0.0, 1., 0.0
+};
+
+hwc2_compat_device_t* hwcDevice;
+
+class HWComposer : public HWComposerNativeWindow
+{
+ private:
+ hwc2_compat_layer_t *layer;
+ hwc2_compat_display_t *hwcDisplay;
+ int lastPresentFence = -1;
+ protected:
+ void present(HWComposerNativeWindowBuffer *buffer);
+
+ public:
+
+ HWComposer(unsigned int width, unsigned int height, unsigned int format,
+ hwc2_compat_display_t *display, hwc2_compat_layer_t *layer);
+ void set();
+};
+
+HWComposer::HWComposer(unsigned int width, unsigned int height,
+ unsigned int format, hwc2_compat_display_t* display,
+ hwc2_compat_layer_t *layer) :
+ HWComposerNativeWindow(width, height, format)
+{
+ this->layer = layer;
+ this->hwcDisplay = display;
+}
+
+void HWComposer::present(HWComposerNativeWindowBuffer *buffer)
+{
+ uint32_t numTypes = 0;
+ uint32_t numRequests = 0;
+ hwc2_display_t displayId = 0;
+
+ hwc2_error_t error = hwc2_compat_display_validate(hwcDisplay, &numTypes,
+ &numRequests);
+
+ if (error != HWC2_ERROR_NONE && error != HWC2_ERROR_HAS_CHANGES) {
+ HYBRIS_ERROR("prepare: validate failed for display %lu: %s (%d)", displayId,
+ to_string(static_cast<HWC2::Error>(error)).c_str(), error);
+ return;
+ }
+
+ if (numTypes || numRequests) {
+ HYBRIS_ERROR("prepare: validate required changes for display %lu: %s (%d)",
+ displayId, to_string(static_cast<HWC2::Error>(error)).c_str(),
+ error);
+ return;
+ }
+
+ error = hwc2_compat_display_accept_changes(hwcDisplay);
+ if (error != HWC2_ERROR_NONE) {
+ HYBRIS_ERROR("prepare: acceptChanges failed: %s",
+ to_string(static_cast<HWC2::Error>(error)).c_str());
+ return;
+ }
+
+ hwc2_compat_display_set_client_target(hwcDisplay, /* slot */0, buffer,
+ getFenceBufferFd(buffer),
+ HAL_DATASPACE_UNKNOWN);
+
+ int presentFence;
+ hwc2_compat_display_present(hwcDisplay, &presentFence);
+
+ if (error != HWC2_ERROR_NONE) {
+ HYBRIS_ERROR("presentAndGetReleaseFences: failed for display %lu: %s (%d)",
+ displayId,
+ to_string(static_cast<HWC2::Error>(error)).c_str(), error);
+ return;
+ }
+
+ hwc2_compat_out_fences_t* fences;
+ error = hwc2_compat_display_get_release_fences(
+ hwcDisplay, &fences);
+
+ if (error != HWC2_ERROR_NONE) {
+ HYBRIS_ERROR("presentAndGetReleaseFences: Failed to get release fences "
+ "for display %lu: %s (%d)",
+ displayId, to_string(static_cast<HWC2::Error>(error)).c_str(),
+ error);
+ return;
+ }
+
+ int fenceFd = hwc2_compat_out_fences_get_fence(fences, layer);
+ if (fenceFd != -1)
+ setFenceBufferFd(buffer, fenceFd);
+
+ hwc2_compat_out_fences_destroy(fences);
+
+ if (lastPresentFence != -1) {
+ sync_wait(lastPresentFence, -1);
+ close(lastPresentFence);
+ }
+ lastPresentFence = presentFence;
+}
+
+void onVsyncReceived(HWC2EventListener* listener, int32_t sequenceId,
+ hwc2_display_t display, int64_t timestamp)
+{
+}
+
+void onHotplugReceived(HWC2EventListener* listener, int32_t sequenceId,
+ hwc2_display_t display, bool connected,
+ bool primaryDisplay)
+{
+ HYBRIS_INFO("onHotplugReceived(%d, %" PRIu64 ", %s, %s)",
+ sequenceId, display,
+ connected ?
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/tests/test_hwcomposer.cpp
^
|
@@ -16,6 +16,9 @@
*/
#include <android-config.h>
+
+#if ((ANDROID_VERSION_MAJOR >= 4 && ANDROID_VERSION_MINOR >= 2) || ANDROID_VERSION_MAJOR >= 5)
+
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <assert.h>
@@ -371,4 +374,14 @@
#endif
}
+#else
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ printf("test_hwcomposer is not supported in this build\n");
+ return 0;
+}
+#endif
+
// vim:ts=4:sw=4:noexpandtab
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/tests/test_nfc.c
^
|
@@ -17,6 +17,9 @@
*/
#include <android-config.h>
+
+#if HAS_LIBNFC_NXP_HEADERS
+
#include <assert.h>
#include <stdio.h>
#include <pthread.h>
@@ -371,3 +374,15 @@
return 0;
}
+
+#else
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ printf("test_nfc is not supported in this build\n");
+ return 0;
+}
+
+#endif
+
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/tests/test_vibrator.c
^
|
@@ -16,6 +16,8 @@
*
*/
+#if HAS_VIBRATOR_HEADER
+
#include <android-config.h>
#include <assert.h>
#include <stdio.h>
@@ -54,4 +56,14 @@
return 0;
}
+#else
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ printf("test_vibrator is not supported in this build");
+ return 0;
+}
+#endif
+
// vim:ts=4:sw=4:noexpandtab
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/tests/test_wifi.c
^
|
@@ -19,7 +19,9 @@
#include <string.h>
#include <android-config.h>
-#include <hardware_legacy/wifi.h>
+
+int wifi_load_driver();
+int wifi_unload_driver();
#define COMMAND_LOAD_WIFI "1"
#define COMMAND_UNLOAD_WIFI "0"
@@ -49,7 +51,6 @@
}
fprintf(stdout, "WiFi driver load state: %d\n", is_wifi_driver_loaded());
-
return 0;
}
|
[-]
[+]
|
Changed |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/hybris/wifi/wifi.c
^
|
@@ -20,7 +20,6 @@
#include <stddef.h>
#include <hybris/common/binding.h>
-#include <hardware_legacy/wifi.h>
#define COMPAT_LIBRARY_PATH "libhardware_legacy.so"
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/README
^
|
@@ -0,0 +1,18 @@
+libnfc wrapper generator scripts for libhybris
+==============================================
+
+These scripts generate libhybris wrapper libraries for Android libnfc.
+There are actually two different libnfc implementations in Android:
+
+ - libnfc-nxp
+ - libnfc-nci
+
+These scripts currently generate wrappers for libnfc-nxp, but could be
+adapted to generate wrappers for libnfc-nci as well.
+
+Usage:
+
+ git submodule init
+ git submodule update
+ sh -x generate.sh
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/README.android-src
^
|
@@ -0,0 +1,19 @@
+Clone to folder:
+ android_platform_frameworks_native
+URL:
+ https://android.googlesource.com/platform/frameworks/native
+
+Clone to folder:
+ android_platform_hardware_libhardware
+URL:
+ https://android.googlesource.com/platform/hardware/libhardware/
+
+Clone to folder:
+ android_platform_system_core
+URL:
+ https://android.googlesource.com/platform/system/core
+
+Clone to folder:
+ android_platform_external_libnfc-nxp
+URL:
+ https://android.googlesource.com/platform/external/libnfc-nxp
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/generate.sh
^
|
@@ -0,0 +1,30 @@
+#!/bin/sh -e
+# Generate C prototype definitions for Android libnfc
+# Copyright (C) 2013 Jolla Ltd.
+# Contact: Thomas Perl <thomas.perl@jollamobile.com>
+
+mkdir -p output
+
+cproto -x \
+ android_platform_external_libnfc-nxp/*/*.c \
+ -I android_platform_external_libnfc-nxp/inc \
+ -I android_platform_external_libnfc-nxp/src \
+ -I android_platform_external_libnfc-nxp/Linux_x86 \
+ -I android_platform_hardware_libhardware/include \
+ -I android_platform_system_core/include \
+ -I android_platform_frameworks_native/include \
+ -I . -DNXP_MESSAGING \
+ > output/libnfc_prototypes.h
+
+python generate_wrappers.py \
+ output/libnfc_prototypes.h \
+ symbols/libnfc.so.txt \
+ /system/lib/libnfc.so \
+ > output/libnfc-nxp.c
+
+python generate_wrappers.py \
+ output/libnfc_prototypes.h \
+ symbols/libnfc_ndef.so.txt \
+ /system/lib/libnfc_ndef.so \
+ > output/libnfc_ndef-nxp.c
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/generate_wrappers.py
^
|
@@ -0,0 +1,145 @@
+#!/usr/bin/python
+# gnerate_wrappers.py: Parse header and output libhybris binding code
+# Adapted for libhybris from apkenv-wrapper-generator
+#
+# apkenv-wrapper-generator version:
+# Copyright (C) 2012 Thomas Perl <m@thp.io>; 2012-10-19
+#
+# libhybris version:
+# Copyright (C) 2013 Jolla Ltd.
+# Contact: Thomas Perl <thomas.perl@jollamobile.com>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+import re
+import os
+import sys
+
+# Some special cases to to avoid having to parse the full C grammar
+FIXED_MAPPINGS = {
+}
+
+# Never generate wrappers for these functions
+BLACKLISTED_FUNCS = [
+]
+
+def clean_arg(arg):
+ arg = arg.strip()
+ arg = arg.replace('__const', 'const')
+
+ while '[' in arg:
+ # int x[] -> int *x
+ arg = re.sub(r'(.*?)([A-Za-z_]+)(\[[^\]]*\])(.*)$', r'\1*\2\4', arg)
+
+ return arg.strip()
+
+class Argument:
+ def __init__(self, type_, name):
+ self.type_ = type_
+ self.name = name
+
+class Function:
+ def __init__(self, retval, name, args):
+ self.retval = retval
+ self.name = name
+ self.raw_args = args
+ self.parsing_error = None
+ self.args = list(self._parse_args(args))
+
+ def _parse_args(self, args):
+ for arg in map(clean_arg, args.split(',')):
+ arg = clean_arg(arg)
+ xarg = re.match(r'^(.*?)([A-Za-z0-9_]+)$', arg)
+ if not xarg:
+ # Unknown argument
+ if arg in FIXED_MAPPINGS:
+ yield Argument(FIXED_MAPPINGS[arg], '__undefined__')
+ continue
+ self.parsing_error = 'Could not parse: ' + repr(arg)
+ print self.parsing_error
+ continue
+ type_, name = xarg.groups()
+ if type_ == '':
+ type_ = name
+ name = '__undefined__'
+ yield Argument(type_, name)
+
+def parse_header(filename):
+ """Parse header file written by cproto"""
+ for line in open(filename):
+ if line.startswith('/*'):
+ continue
+ retval, funcname, args = re.match(r'^(.+ [*]?)([A-Za-z0-9_]+)\((.*)\);\s*$', line).groups()
+ retval, funcname, args = [x.strip() for x in (retval, funcname, args)]
+ if funcname not in BLACKLISTED_FUNCS:
+ yield (funcname, Function(retval, funcname, args))
+
+def parse_symbols(filename):
+ """Parse 'objdump -T'-style symbol list"""
+ for line in open(filename):
+ line = line.strip()
+ if not line:
+ continue
+
+ items = line.split()
+ if len(items) != 6:
+ continue
+
+ if 'DF' in items and '.text' in items:
+ # Print exported symbol name from text segment in library
+ yield items[-1]
+
+
+
+if len(sys.argv) != 4:
+ print >>sys.stderr, """
+ Usage: %s headerfile.h objdump-Tfile.so.txt /system/lib/something.so
+ """ % (sys.argv[0],)
+ sys.exit(1)
+
+
+headerfile = sys.argv[1]
+symbolsfile = sys.argv[2]
+libraryfile = sys.argv[3]
+
+libname = os.path.basename(libraryfile).replace('.', '_')
+
+available_functions = dict(parse_header(headerfile))
+
+print """
+#include <hybris/internal/binding.h>
+
+HYBRIS_LIBRARY_INITIALIZE(%s, "%s");
+""" % (libname, libraryfile)
+
+for symbol in parse_symbols(symbolsfile):
+ if symbol not in available_functions:
+ print '/* XXX No prototype for exported symbol: %s */' % symbol
+ continue
+
+ function = available_functions[symbol]
+ args = [a.type_.strip() for a in function.args if a.type_.strip() not in ('', 'void')]
+ if function.retval == 'void':
+ print 'HYBRIS_IMPLEMENT_VOID_FUNCTION%d(%s, %s);' % (len(args), libname, ', '.join([function.name] + args))
+ else:
+ print 'HYBRIS_IMPLEMENT_FUNCTION%d(%s, %s, %s);' % (len(args), libname, function.retval, ', '.join([function.name] + args))
+
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/linux/README
^
|
@@ -0,0 +1,5 @@
+This is just a dummy include directory, so the file
+
+android_platform_external_libnfc-nxp/Linux_x86/phDal4Nfc_i2c.c
+
+can be properly parsed by cproto.
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/linux/pn544.h
^
|
@@ -0,0 +1 @@
+/* Dummy header */
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/symbols/README
^
|
@@ -0,0 +1,3 @@
+These symbols have been obtained via:
+
+ objdump -T <filename>
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/symbols/libnfc.so.txt
^
|
@@ -0,0 +1,603 @@
+
+libnfc.so: file format elf32-little
+
+DYNAMIC SYMBOL TABLE:
+0000790c g DF .text 00000020 phLibNfc_Mgt_ConfigureDriver
+0003d120 g DF .text 00000394 phDal4Nfc_Config
+00000000 DF *UND* 00000000 __aeabi_unwind_cpp_pr0
+0000792c g DF .text 00000020 phLibNfc_Mgt_UnConfigureDriver
+0003d018 g DF .text 00000108 phDal4Nfc_ConfigRelease
+0000794c g DF .text 00000020 phLibNfc_HW_Reset
+0003d630 g DF .text 00000020 phDal4Nfc_Reset
+00000000 DF *UND* 00000000 __aeabi_unwind_cpp_pr1
+0000796c g DF .text 00000004 phLibNfc_Download_Mode
+0003d650 g DF .text 0000002c phDal4Nfc_Download
+00007970 g DF .text 00000004 phLibNfc_Load_Firmware_Image
+0000f3ec g DF .text 000000fc dlopen_firmware
+00007974 g DF .text 00000024 phLibNfc_Mgt_Recovery
+00000000 DF *UND* 00000000 usleep
+00007998 g DF .text 00000018 phLibNfc_SetIsoXchgTimeout
+0004102e g DO .data 00000001 nxp_nfc_isoxchg_timeout
+000079b0 g DF .text 00000014 phLibNfc_GetIsoXchgTimeout
+000079c4 g DF .text 00000018 phLibNfc_SetHciTimeout
+00041028 g DO .data 00000004 nxp_nfc_hci_response_timeout
+000079dc g DF .text 00000014 phLibNfc_GetHciTimeout
+000079f0 g DF .text 00000018 phLibNfc_SetFelicaTimeout
+00041021 g DO .data 00000001 nxp_nfc_felica_timeout
+00007a08 g DF .text 00000014 phLibNfc_GetFelicaTimeout
+00007a1c g DF .text 00000018 phLibNfc_SetMifareRawTimeout
+0004102d g DO .data 00000001 nxp_nfc_mifareraw_timeout
+00007a34 g DF .text 00000014 phLibNfc_GetMifareRawTimeout
+00007a48 g DF .text 000000f4 phLibNfc_Mgt_DeInitialize
+0000fa30 g DF .text 000000ac phHal4Nfc_Close
+0000fadc g DF .text 00000130 phHal4Nfc_Hal4Reset
+0003c0ec g DF .text 0000000c phOsalNfc_FreeMemory
+0000c370 g DF .text 000000cc phLibNfc_Ndef_DeInit
+00007b3c g DF .text 00000030 phLibNfc_Pending_Shutdown
+00007b6c g DF .text 000003c8 phLibNfc_Mgt_Reset
+00000000 DF *UND* 00000000 memset
+00041058 g DO .bss 00000004 pNdefRecord
+00041498 g DO .bss 00000014 NdefInfo
+00007f34 g DF .text 000000ec phLibNfc_UpdateNextState
+00008020 g DF .text 000000fc phLibNfc_Mgt_Initialize
+0003c0e8 g DF .text 00000004 phOsalNfc_GetMemory
+0000f4e8 g DF .text 00000278 phHal4Nfc_Open
+0000c1f8 g DF .text 00000178 phLibNfc_Ndef_Init
+0000811c g DF .text 00000064 phLibNfc_UpdateCurState
+0000e4b8 g DF .text 000000c4 phHal4Nfc_RegisterNotification
+00041480 g DO .bss 00000018 sSecuredElementInfo
+0003c0fc g DF .text 00000014 phOsalNfc_RaiseException
+00008424 g DF .text 00000180 phLibNfc_Mgt_GetstackCapabilities
+0000fc0c g DF .text 000000b8 phHal4Nfc_GetDeviceCapabilities
+00000000 DF *UND* 00000000 memcpy
+00000000 DF *UND* 00000000 memcmp
+00000000 DF *UND* 00000000 __android_log_print
+000410a0 g DO .bss 00000004 nxp_nfc_full_version
+000085a4 g DF .text 000001c4 phLibNfc_Mgt_ConfigureTestMode
+00041040 g DO .bss 00000004 gpphLibContext
+00008814 g DF .text 000000b8 phLibNfc_config_discovery_cb
+000088cc g DF .text 000000e8 phLibNfc_Mgt_ConfigureDiscovery
+0000db9c g DF .text 000001a0 phHal4Nfc_ConfigureDiscovery
+000089b4 g DF .text 00000130 phLibNfc_RemoteDev_CheckPresence
+0001130c g DF .text 000000cc phHal4Nfc_PresenceCheck
+00010bb8 g DF .text 0000059c phHal4Nfc_Transceive
+000109a8 g DF .text 00000210 phHal4Nfc_Connect
+0000ac0c g DF .text 00000140 phLibNfc_Reconnect_Mifare_Cb
+0000929c g DF .text 000000c0 phLibNfc_RemoteDev_NtfRegister
+0000935c g DF .text 00000078 phLibNfc_RemoteDev_NtfUnregister
+0000e57c g DF .text 000000c8 phHal4Nfc_UnregisterNotification
+000093d4 g DF .text 0000015c phLibNfc_RemoteDev_ReConnect
+00009530 g DF .text 00000164 phLibNfc_RemoteDev_Connect
+00009694 g DF .text 0000012c phLibNfc_RemoteDev_Disconnect
+0001120c g DF .text 00000100 phHal4Nfc_Disconnect
+000097c0 g DF .text 00000264 phLibNfc_RemoteDev_Transceive
+00009a24 g DF .text 00000128 phLibNfc_Mgt_SetP2P_ConfigParams
+0000da58 g DF .text 00000144 phHal4Nfc_ConfigParameters
+00000000 DF *UND* 00000000 __stack_chk_fail
+00000000 DO *UND* 00000000 __stack_chk_guard
+0002541c g DF .text 000000bc phFriNfc_LlcpTransport_CloseAll
+00009d44 g DF .text 0000018c phLibNfc_Mgt_SetLlcp_ConfigParams
+00023708 g DF .text 00000154 phFriNfc_Llcp_EncodeLinkParams
+00023be8 g DF .text 000000f0 phFriNfc_Llcp_Reset
+00024a6c g DF .text 00000188 phFriNfc_LlcpTransport_Reset
+00009ed0 g DF .text 0000010c phLibNfc_Llcp_CheckLlcp
+00023cd8 g DF .text 00000060 phFriNfc_Llcp_ChkLlcp
+00009fdc g DF .text 00000058 phLibNfc_Llcp_Activate
+00023d38 g DF .text 0000002c phFriNfc_Llcp_Activate
+0000a034 g DF .text 00000058 phLibNfc_Llcp_Deactivate
+00023d64 g DF .text 00000084 phFriNfc_Llcp_Deactivate
+0000a08c g DF .text 0000004c phLibNfc_Llcp_GetLocalInfo
+00023de8 g DF .text 0000003c phFriNfc_Llcp_GetLocalInfo
+0000a0d8 g DF .text 00000064 phLibNfc_Llcp_GetRemoteInfo
+00023e24 g DF .text 0000003c phFriNfc_Llcp_GetRemoteInfo
+0000a13c g DF .text 000000d8 phLibNfc_Llcp_DiscoverServices
+000250a4 g DF .text 0000004c phFriNfc_LlcpTransport_DiscoverServices
+0000a214 g DF .text 0000008c phLibNfc_Llcp_Socket
+000250f0 g DF .text 00000300 phFriNfc_LlcpTransport_Socket
+0000a2a0 g DF .text 00000034 phLibNfc_Llcp_Close
+000253f0 g DF .text 0000002c phFriNfc_LlcpTransport_Close
+0000a2d4 g DF .text 00000040 phLibNfc_Llcp_SocketGetLocalOptions
+00025034 g DF .text 00000038 phFriNfc_LlcpTransport_SocketGetLocalOptions
+0000a314 g DF .text 00000060 phLibNfc_Llcp_SocketGetRemoteOptions
+0002506c g DF .text 00000038 phFriNfc_LlcpTransport_SocketGetRemoteOptions
+0000a374 g DF .text 00000044 phLibNfc_Llcp_Bind
+000254d8 g DF .text 00000218 phFriNfc_LlcpTransport_Bind
+0000a3b8 g DF .text 00000048 phLibNfc_Llcp_Listen
+000256f0 g DF .text 00000054 phFriNfc_LlcpTransport_Listen
+0000a400 g DF .text 0000007c phLibNfc_Llcp_Accept
+00025744 g DF .text 000000d0 phFriNfc_LlcpTransport_Accept
+0000a47c g DF .text 00000068 phLibNfc_Llcp_Reject
+00025814 g DF .text 00000034 phFriNfc_LlcpTransport_Reject
+0000a4e4 g DF .text 0000006c phLibNfc_Llcp_Connect
+00025848 g DF .text 000000cc phFriNfc_LlcpTransport_Connect
+0000a550 g DF .text 00000070 phLibNfc_Llcp_ConnectByUri
+00025914 g DF .text 000000c0 phFriNfc_LlcpTransport_ConnectByUri
+0000a5c0 g DF .text 00000068 phLibNfc_Llcp_Disconnect
+000259d4 g DF .text 00000038 phFriNfc_LlcpTransport_Disconnect
+0000a628 g DF .text 00000070 phLibNfc_Llcp_Recv
+00025a84 g DF .text 00000060 phFriNfc_LlcpTransport_Recv
+0000a698 g DF .text 00000070 phLibNfc_Llcp_RecvFrom
+00025bbc g DF .text 00000064 phFriNfc_LlcpTransport_RecvFrom
+0000a708 g DF .text 00000070 phLibNfc_Llcp_Send
+00025a0c g DF .text 00000078 phFriNfc_LlcpTransport_Send
+0000a778 g DF .text 00000084 phLibNfc_Llcp_SendTo
+00025ae4 g DF .text 000000d8 phFriNfc_LlcpTransport_SendTo
+0000a930 g DF .text 000002dc phLibNfc_Mgt_IoCtl
+0000f760 g DF .text 000002d0 phHal4Nfc_Ioctl
+0000fe6c g DF .text 000000e8 phHal4Nfc_Switch_Swp_Mode
+00000000 DF *UND* 00000000 phFriNfc_NdefRecord_GetRecords
+00037da8 g DF .text 00000044 phFriNfc_NdefReg_DispatchPacket
+00037e14 g DF .text 00000564 phFriNfc_NdefReg_Process
+00037d04 g DF .text 000000a4 phFriNfc_NdefReg_RmCb
+00000000 DF *UND* 00000000 phFriNfc_NdefRecord_Parse
+000378b4 g DF .text 00000238 phFriNfc_NdefMap_GetContainerSize
+0003bf2c g DF .text 00000070 phOsalNfc_Timer_Stop
+0003c0a0 g DF .text 00000048 phOsalNfc_Timer_Delete
+0000bc40 g DF .text 0000030c phLibNfc_Ndef_Read
+00037338 g DF .text 00000040 phFriNfc_NdefMap_SetCompletionRoutine
+00037378 g DF .text 00000150 phFriNfc_NdefMap_RdNdef
+0000bf4c g DF .text 000002ac phLibNfc_Ndef_Write
+00037850 g DF .text 00000064 phFriNfc_NdefMap_EraseNdef
+000374c8 g DF .text 00000180 phFriNfc_NdefMap_WrNdef
+0000c43c g DF .text 000001c0 phLibNfc_Ndef_CheckNdef
+0003715c g DF .text 000001dc phFriNfc_NdefMap_Reset
+000376a0 g DF .text 000000f4 phFriNfc_NdefMap_ChkNdef
+0003be58 g DF .text 000000d4 phOsalNfc_Timer_Start
+0003bdac g DF .text 000000ac phOsalNfc_Timer_Create
+0000c5fc g DF .text 000001f4 phLibNfc_RemoteDev_FormatNdef
+0003b188 g DF .text 000000cc phFriNfc_NdefSmtCrd_Reset
+0003b254 g DF .text 00000044 phFriNfc_NdefSmtCrd_SetCR
+0003b2f8 g DF .text 000000f0 phFriNfc_NdefSmtCrd_Format
+0000c7f0 g DF .text 000002f0 phLibNfc_ConvertToReadOnlyNdef
+00037648 g DF .text 00000058 phFriNfc_NdefMap_ConvertToReadOnly
+0003b298 g DF .text 00000060 phFriNfc_NdefSmtCrd_ConvertToReadOnly
+0002ebec g DF .text 00000130 phFriNfc_MifareStdMap_ConvertToReadOnly
+0000cae0 g DF .text 00000268 phLibNfc_Ndef_SearchNdefContent
+00037c14 g DF .text 0000007c phFriNfc_NdefReg_Reset
+00037c90 g DF .text 00000074 phFriNfc_NdefReg_AddCb
+0000d0d0 g DF .text 0000008c phLibNfc_SE_NtfRegister
+0000d15c g DF .text 00000070 phLibNfc_SE_NtfUnregister
+0000d1cc g DF .text 00000100 phLibNfc_SE_GetSecureElementList
+0000d2cc g DF .text 00000320 phLibNfc_SE_SetMode
+0000fd0c g DF .text 00000160 phHal4Nfc_Switch_SMX_Mode
+0000d780 g DF .text 00000124 phLibNfc_RemoteDev_Receive
+000101b4 g DF .text 00000158 phHal4Nfc_Receive
+0000d8a4 g DF .text 000001b4 phLibNfc_RemoteDev_Send
+0000ffe8 g DF .text 000001cc phHal4Nfc_Send
+00014484 g DF .text 00000180 phHciNfc_Configure
+00014604 g DF .text 00000088 phHciNfc_Config_Discovery
+0001468c g DF .text 00000120 phHciNfc_Restart_Discovery
+0000dd3c g DF .text 000000b4 phHal4Nfc_ConfigureComplete
+000116f8 g DF .text 00000180 phHal4Nfc_DisconnectComplete
+0000ddf0 g DF .text 000006c8 phHal4Nfc_TargetDiscoveryComplete
+000148ec g DF .text 00000068 phHciNfc_Select_Next_Target
+000414b8 g DO .bss 00000004 gpphHal4Nfc_Hwref
+0000fcc4 g DF .text 00000048 phHal4Nfc_HandleEmulationEvent
+00011878 g DF .text 00000128 phHal4Nfc_TransceiveComplete
+0001030c g DF .text 0000024c phHal4Nfc_SendCompleteHandler
+000114e8 g DF .text 00000060 phHal4Nfc_ReactivationComplete
+000113d8 g DF .text 00000110 phHal4Nfc_PresenceChkComplete
+00011548 g DF .text 000001b0 phHal4Nfc_ConnectComplete
+00010558 g DF .text 000001ac phHal4Nfc_RecvCompleteHandler
+000143b0 g DF .text 000000d4 phHciNfc_Release
+00010830 g DF .text 0000013c phHal4Nfc_HandleP2PDeActivate
+00010704 g DF .text 0000012c phHal4Nfc_P2PActivateComplete
+00000000 DF *UND* 00000000 dlopen
+00000000 DF *UND* 00000000 dlsym
+000141e0 g DF .text 000001d0 phHciNfc_Initialise
+0003cf04 g DF .text 00000114 phDal4Nfc_Register
+00020850 g DF .text 0000011c phLlcNfc_Register
+00015008 g DF .text 00000080 phHciNfc_System_Get_Info
+00014edc g DF .text 000000b4 phHciNfc_System_Test
+00014f90 g DF .text 00000078 phHciNfc_System_Configure
+00014e60 g DF .text 0000007c phHciNfc_PRBS_Test
+000133bc g DF .text 00000378 phDnldNfc_Upgrade
+00013338 g DF .text 00000084 phDnldNfc_Run_Check
+00041080 g DO .bss 00000004 nxp_nfc_fw
+0001482c g DF .text 000000c0 phHciNfc_Switch_SmxMode
+000147ac g DF .text 00000080 phHciNfc_Switch_SwpMode
+00014cd4 g DF .text 000000d8 phHciNfc_Send_Data
|
[-]
[+]
|
Added |
_service:tar_git:libhybris-0.0.5.27.tar.bz2/libhybris/utils/generate_nfc/symbols/libnfc_ndef.so.txt
^
|
@@ -0,0 +1,19 @@
+
+libnfc_ndef.so: file format elf32-little
+
+DYNAMIC SYMBOL TABLE:
+00000000 DF *UND* 00000000 __aeabi_unwind_cpp_pr0
+000004a7 g DF .text 000001ee phFriNfc_NdefRecord_GetRecords
+00000695 g DF .text 00000050 phFriNfc_NdefRecord_GetLength
+000006e5 g DF .text 000000e8 phFriNfc_NdefRecord_Parse
+000007cd g DF .text 00000146 phFriNfc_NdefRecord_Generate
+00000914 g DF .text 0000000c __on_dlclose
+00000000 DF *UND* 00000000 __cxa_finalize
+00002000 g D .bss 00000000 __dso_handle
+00001ed4 g D .init_array 00000000 __INIT_ARRAY__
+00001edc g D .fini_array 00000000 __FINI_ARRAY__
+00002000 g D *ABS* 00000000 _edata
+00002000 g D *ABS* 00000000 __bss_start
+00002010 g D *ABS* 00000000 _end
+
+
|