Merge "Clean up some mess by only building Android-specific code for the device."
am: 443fdb2fdc
Change-Id: I3ae6f0662bffd9cf81ae401e80821488cccd3933
This commit is contained in:
commit
0fa7eddc31
4 changed files with 15 additions and 37 deletions
|
|
@ -18,7 +18,6 @@
|
||||||
// they correspond to features not used by our host development tools
|
// they correspond to features not used by our host development tools
|
||||||
// which are also hard or even impossible to port to native Win32
|
// which are also hard or even impossible to port to native Win32
|
||||||
libcutils_nonwindows_sources = [
|
libcutils_nonwindows_sources = [
|
||||||
"android_get_control_file.cpp",
|
|
||||||
"fs.cpp",
|
"fs.cpp",
|
||||||
"hashmap.cpp",
|
"hashmap.cpp",
|
||||||
"multiuser.cpp",
|
"multiuser.cpp",
|
||||||
|
|
@ -102,6 +101,7 @@ cc_library {
|
||||||
|
|
||||||
android: {
|
android: {
|
||||||
srcs: libcutils_nonwindows_sources + [
|
srcs: libcutils_nonwindows_sources + [
|
||||||
|
"android_get_control_file.cpp",
|
||||||
"android_reboot.cpp",
|
"android_reboot.cpp",
|
||||||
"ashmem-dev.cpp",
|
"ashmem-dev.cpp",
|
||||||
"fs_config.cpp",
|
"fs_config.cpp",
|
||||||
|
|
|
||||||
|
|
@ -14,20 +14,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __CUTILS_ANDROID_GET_CONTROL_ENV_H
|
#pragma once
|
||||||
#define __CUTILS_ANDROID_GET_CONTROL_ENV_H
|
|
||||||
|
|
||||||
/* To declare library function hidden and internal */
|
#include <sys/cdefs.h>
|
||||||
#define LIBCUTILS_HIDDEN __attribute__((visibility("hidden")))
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
__BEGIN_DECLS
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LIBCUTILS_HIDDEN int __android_get_control_from_env(const char* prefix,
|
int __android_get_control_from_env(const char* prefix, const char* name)
|
||||||
const char* name);
|
__attribute__((visibility("hidden")));
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __CUTILS_ANDROID_GET_CONTROL_ENV_H */
|
__END_DECLS
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,7 @@
|
||||||
|
|
||||||
#include "android_get_control_env.h"
|
#include "android_get_control_env.h"
|
||||||
|
|
||||||
#ifndef TEMP_FAILURE_RETRY
|
int __android_get_control_from_env(const char* prefix, const char* name) {
|
||||||
#define TEMP_FAILURE_RETRY(exp) (exp) // KISS implementation
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LIBCUTILS_HIDDEN int __android_get_control_from_env(const char* prefix,
|
|
||||||
const char* name) {
|
|
||||||
if (!prefix || !name) return -1;
|
if (!prefix || !name) return -1;
|
||||||
|
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
|
|
@ -67,20 +62,11 @@ LIBCUTILS_HIDDEN int __android_get_control_from_env(const char* prefix,
|
||||||
long fd = strtol(val, NULL, 10);
|
long fd = strtol(val, NULL, 10);
|
||||||
if (errno) return -1;
|
if (errno) return -1;
|
||||||
|
|
||||||
// validity checking
|
// Since we are inheriting an fd, it could legitimately exceed _SC_OPEN_MAX
|
||||||
if ((fd < 0) || (fd > INT_MAX)) return -1;
|
if ((fd < 0) || (fd > INT_MAX)) return -1;
|
||||||
|
|
||||||
// Since we are inheriting an fd, it could legitimately exceed _SC_OPEN_MAX
|
|
||||||
|
|
||||||
// Still open?
|
// Still open?
|
||||||
#if defined(F_GETFD) // Lowest overhead
|
|
||||||
if (TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD)) < 0) return -1;
|
if (TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD)) < 0) return -1;
|
||||||
#elif defined(F_GETFL) // Alternate lowest overhead
|
|
||||||
if (TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL)) < 0) return -1;
|
|
||||||
#else // Hail Mary pass
|
|
||||||
struct stat s;
|
|
||||||
if (TEMP_FAILURE_RETRY(fstat(fd, &s)) < 0) return -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return static_cast<int>(fd);
|
return static_cast<int>(fd);
|
||||||
}
|
}
|
||||||
|
|
@ -88,7 +74,6 @@ LIBCUTILS_HIDDEN int __android_get_control_from_env(const char* prefix,
|
||||||
int android_get_control_file(const char* path) {
|
int android_get_control_file(const char* path) {
|
||||||
int fd = __android_get_control_from_env(ANDROID_FILE_ENV_PREFIX, path);
|
int fd = __android_get_control_from_env(ANDROID_FILE_ENV_PREFIX, path);
|
||||||
|
|
||||||
#if defined(__linux__)
|
|
||||||
// Find file path from /proc and make sure it is correct
|
// Find file path from /proc and make sure it is correct
|
||||||
char *proc = NULL;
|
char *proc = NULL;
|
||||||
if (asprintf(&proc, "/proc/self/fd/%d", fd) < 0) return -1;
|
if (asprintf(&proc, "/proc/self/fd/%d", fd) < 0) return -1;
|
||||||
|
|
@ -108,7 +93,6 @@ int android_get_control_file(const char* path) {
|
||||||
if (ret < 0) return -1;
|
if (ret < 0) return -1;
|
||||||
if (cmp != 0) return -1;
|
if (cmp != 0) return -1;
|
||||||
// It is what we think it is
|
// It is what we think it is
|
||||||
#endif
|
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
#include <cutils/sockets.h>
|
#include <cutils/sockets.h>
|
||||||
|
|
||||||
#define LOG_TAG "socket-unix"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -27,9 +25,6 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cutils/android_get_control_file.h>
|
|
||||||
#include <log/log.h>
|
|
||||||
|
|
||||||
#include "android_get_control_env.h"
|
#include "android_get_control_env.h"
|
||||||
|
|
||||||
int socket_close(int sock) {
|
int socket_close(int sock) {
|
||||||
|
|
@ -62,6 +57,7 @@ ssize_t socket_send_buffers(cutils_socket_t sock,
|
||||||
return writev(sock, iovec_buffers, num_buffers);
|
return writev(sock, iovec_buffers, num_buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
int android_get_control_socket(const char* name) {
|
int android_get_control_socket(const char* name) {
|
||||||
int fd = __android_get_control_from_env(ANDROID_SOCKET_ENV_PREFIX, name);
|
int fd = __android_get_control_from_env(ANDROID_SOCKET_ENV_PREFIX, name);
|
||||||
|
|
||||||
|
|
@ -82,3 +78,8 @@ int android_get_control_socket(const char* name) {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int android_get_control_socket(const char*) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue