Skip to content

Commit e8e1243

Browse files
Enable compilation of libbinder on Fuchsia
This ensures that getMinSchedulerPolicy and getMinSchedulerPriority are only called on Linux as they are only defined here. This replaces some __ANDROID__ ifdef's with BINDER_WITH_KERNEL_IPC. Change-Id: Idec83bf1715ac3c62ac7a849aa188aa491a19fda
1 parent a5f7d9f commit e8e1243

4 files changed

Lines changed: 25 additions & 8 deletions

File tree

libs/binder/IPCThreadState.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#include "Utils.h"
3939
#include "binder_module.h"
4040

41+
#if (defined(__ANDROID__) || defined(__Fuchsia__)) && !defined(BINDER_WITH_KERNEL_IPC)
42+
#error Android and Fuchsia are expected to have BINDER_WITH_KERNEL_IPC
43+
#endif
44+
4145
#if LOG_NDEBUG
4246

4347
#define IF_LOG_TRANSACTIONS() if (false)
@@ -1215,7 +1219,7 @@ status_t IPCThreadState::talkWithDriver(bool doReceive)
12151219
std::string message = logStream.str();
12161220
ALOGI("%s", message.c_str());
12171221
}
1218-
#if defined(__ANDROID__)
1222+
#if defined(BINDER_WITH_KERNEL_IPC)
12191223
if (ioctl(mProcess->mDriverFD, BINDER_WRITE_READ, &bwr) >= 0)
12201224
err = NO_ERROR;
12211225
else
@@ -1604,7 +1608,7 @@ void IPCThreadState::threadDestructor(void *st)
16041608
IPCThreadState* const self = static_cast<IPCThreadState*>(st);
16051609
if (self) {
16061610
self->flushCommands();
1607-
#if defined(__ANDROID__)
1611+
#if defined(BINDER_WITH_KERNEL_IPC)
16081612
if (self->mProcess->mDriverFD >= 0) {
16091613
ioctl(self->mProcess->mDriverFD, BINDER_THREAD_EXIT, 0);
16101614
}
@@ -1620,7 +1624,7 @@ status_t IPCThreadState::getProcessFreezeInfo(pid_t pid, uint32_t *sync_received
16201624
binder_frozen_status_info info = {};
16211625
info.pid = pid;
16221626

1623-
#if defined(__ANDROID__)
1627+
#if defined(BINDER_WITH_KERNEL_IPC)
16241628
if (ioctl(self()->mProcess->mDriverFD, BINDER_GET_FROZEN_INFO, &info) < 0)
16251629
ret = -errno;
16261630
#endif
@@ -1639,7 +1643,7 @@ status_t IPCThreadState::freeze(pid_t pid, bool enable, uint32_t timeout_ms) {
16391643
info.timeout_ms = timeout_ms;
16401644

16411645

1642-
#if defined(__ANDROID__)
1646+
#if defined(BINDER_WITH_KERNEL_IPC)
16431647
if (ioctl(self()->mProcess->mDriverFD, BINDER_FREEZE, &info) < 0)
16441648
ret = -errno;
16451649
#endif
@@ -1657,7 +1661,7 @@ void IPCThreadState::logExtendedError() {
16571661
if (!ProcessState::isDriverFeatureEnabled(ProcessState::DriverFeature::EXTENDED_ERROR))
16581662
return;
16591663

1660-
#if defined(__ANDROID__)
1664+
#if defined(BINDER_WITH_KERNEL_IPC)
16611665
if (ioctl(self()->mProcess->mDriverFD, BINDER_GET_EXTENDED_ERROR, &ee) < 0) {
16621666
ALOGE("Failed to get extended error: %s", strerror(errno));
16631667
return;

libs/binder/IServiceManager.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
#include <binder/IPermissionController.h>
4444
#endif
4545

46-
#ifdef __ANDROID__
46+
#if !(defined(__ANDROID__) || defined(__FUCHSIA))
47+
#define BINDER_SERVICEMANAGEMENT_DELEGATION_SUPPORT
48+
#endif
49+
50+
#if !defined(BINDER_SERVICEMANAGEMENT_DELEGATION_SUPPORT)
4751
#include <cutils/properties.h>
4852
#else
4953
#include "ServiceManagerHost.h"
@@ -902,7 +906,7 @@ std::vector<IServiceManager::ServiceDebugInfo> CppBackendShim::getServiceDebugIn
902906
return ret;
903907
}
904908

905-
#ifndef __ANDROID__
909+
#if defined(BINDER_SERVICEMANAGEMENT_DELEGATION_SUPPORT)
906910
// CppBackendShim for host. Implements the old libbinder android::IServiceManager API.
907911
// The internal implementation of the AIDL interface android::os::IServiceManager calls into
908912
// on-device service manager.

libs/binder/Parcel.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,13 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) {
299299
obj.handle = handle;
300300
obj.cookie = 0;
301301
} else {
302+
#if __linux__
302303
int policy = local->getMinSchedulerPolicy();
303304
int priority = local->getMinSchedulerPriority();
305+
#else
306+
int policy = 0;
307+
int priority = 0;
308+
#endif
304309

305310
if (policy != 0 || priority != 0) {
306311
// override value, since it is set explicitly

libs/binder/ProcessState.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#define DEFAULT_MAX_BINDER_THREADS 15
4949
#define DEFAULT_ENABLE_ONEWAY_SPAM_DETECTION 1
5050

51+
#if defined(__ANDROID__) || defined(__Fuchsia__)
52+
#define EXPECT_BINDER_OPEN_SUCCESS
53+
#endif
54+
5155
#ifdef __ANDROID_VNDK__
5256
const char* kDefaultDriver = "/dev/vndbinder";
5357
#else
@@ -613,7 +617,7 @@ ProcessState::ProcessState(const char* driver)
613617
}
614618
}
615619

616-
#ifdef __ANDROID__
620+
#if defined(EXPECT_BINDER_OPEN_SUCCESS)
617621
LOG_ALWAYS_FATAL_IF(!opened.ok(),
618622
"Binder driver '%s' could not be opened. Error: %s. Terminating.",
619623
driver, error.c_str());

0 commit comments

Comments
 (0)