Merge "system: core: fastboot: Increase USB protocol buffer size to 1024"
diff --git a/adb/Android.mk b/adb/Android.mk
index 3828ed3..3cadee3 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -63,7 +63,6 @@
file_sync_client.c \
$(EXTRA_SRCS) \
$(USB_SRCS) \
- usb_vendors.c
LOCAL_C_INCLUDES += external/openssl/include
@@ -157,7 +156,6 @@
file_sync_client.c \
get_my_path_linux.c \
usb_linux.c \
- usb_vendors.c \
fdevent.c
LOCAL_CFLAGS := \
diff --git a/adb/adb.c b/adb/adb.c
index cf8e3c4..1834472 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -41,8 +41,6 @@
#include <sys/prctl.h>
#include <getopt.h>
#include <selinux/selinux.h>
-#else
-#include "usb_vendors.h"
#endif
#if ADB_TRACE
@@ -947,7 +945,7 @@
return INSTALL_STATUS_INTERNAL_ERROR;
}
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
static BOOL WINAPI ctrlc_handler(DWORD type)
{
exit(STATUS_CONTROL_C_EXIT);
@@ -962,7 +960,7 @@
void start_logging(void)
{
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
char temp[ MAX_PATH ];
FILE* fnul;
FILE* flog;
@@ -1070,7 +1068,7 @@
int launch_server(int server_port)
{
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
/* we need to start the server in the background */
/* we create a PIPE that will be used to wait for the server's "OK" */
/* message since the pipe handles must be inheritable, we use a */
@@ -1169,7 +1167,7 @@
return -1;
}
}
-#elif defined(HAVE_FORKEXEC)
+#else /* !defined(_WIN32) */
char path[PATH_MAX];
int fd[2];
@@ -1220,12 +1218,10 @@
setsid();
}
-#else
-#error "cannot implement background server start on this platform"
-#endif
+#endif /* !defined(_WIN32) */
return 0;
}
-#endif
+#endif /* ADB_HOST */
/* Constructs a local name of form tcp:port.
* target_str points to the target string, it's content will be overwritten.
@@ -1307,9 +1303,9 @@
#endif
atexit(adb_cleanup);
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
SetConsoleCtrlHandler( ctrlc_handler, TRUE );
-#elif defined(HAVE_FORKEXEC)
+#else
// No SIGCHLD. Let the service subproc handle its children.
signal(SIGPIPE, SIG_IGN);
#endif
@@ -1322,7 +1318,6 @@
#ifdef WORKAROUND_BUG6558362
if(is_daemon) adb_set_affinity();
#endif
- usb_vendors_init();
usb_init();
local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
adb_auth_init();
@@ -1353,14 +1348,13 @@
** AID_LOG to read system logs (adb logcat)
** AID_INPUT to diagnose input issues (getevent)
** AID_INET to diagnose network issues (netcfg, ping)
- ** AID_GRAPHICS to access the frame buffer
** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump)
** AID_SDCARD_R to allow reading from the SD card
** AID_SDCARD_RW to allow writing to the SD card
** AID_NET_BW_STATS to read out qtaguid statistics
*/
- gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS,
- AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_R, AID_SDCARD_RW,
+ gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_NET_BT,
+ AID_NET_BT_ADMIN, AID_SDCARD_R, AID_SDCARD_RW,
AID_NET_BW_STATS };
if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
exit(1);
@@ -1425,10 +1419,10 @@
if (is_daemon)
{
// inform our parent that we are up and running.
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
DWORD count;
WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), "OK\n", 3, &count, NULL );
-#elif defined(HAVE_FORKEXEC)
+#else
fprintf(stderr, "OK\n");
#endif
start_logging();
diff --git a/adb/adb.h b/adb/adb.h
index 4f06800..6f5f997 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -375,7 +375,6 @@
int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol);
#endif
-unsigned host_to_le32(unsigned n);
int adb_commandline(int argc, char **argv);
int connection_state(atransport *t);
diff --git a/adb/commandline.c b/adb/commandline.c
index 05b4ef6..23e9ea4 100644
--- a/adb/commandline.c
+++ b/adb/commandline.c
@@ -29,7 +29,7 @@
#include "sysdeps.h"
-#ifdef HAVE_TERMIO_H
+#if !defined(_WIN32)
#include <termios.h>
#endif
@@ -235,7 +235,18 @@
return 1;
}
-#ifdef HAVE_TERMIO_H
+#if defined(_WIN32)
+
+// Windows does not have <termio.h>.
+static void stdin_raw_init(int fd) {
+
+}
+
+static void stdin_raw_restore(int fd) {
+
+}
+
+#else
static struct termios tio_save;
static void stdin_raw_init(int fd)
@@ -309,11 +320,11 @@
long total = 0;
D("copy_to_file(%d -> %d)\n", inFd, outFd);
-#ifdef HAVE_TERMIO_H
+
if (inFd == STDIN_FILENO) {
stdin_raw_init(STDIN_FILENO);
}
-#endif
+
for (;;) {
if (inFd == STDIN_FILENO) {
len = unix_read(inFd, buf, BUFSIZE);
@@ -340,11 +351,11 @@
}
total += len;
}
-#ifdef HAVE_TERMIO_H
+
if (inFd == STDIN_FILENO) {
stdin_raw_restore(STDIN_FILENO);
}
-#endif
+
D("copy_to_file() finished after %lu bytes\n", total);
free(buf);
}
@@ -385,9 +396,7 @@
case '.':
if(state == 2) {
fprintf(stderr,"\n* disconnect *\n");
-#ifdef HAVE_TERMIO_H
stdin_raw_restore(fdi);
-#endif
exit(0);
}
default:
@@ -419,14 +428,10 @@
fds[0] = fd;
fds[1] = fdi;
-#ifdef HAVE_TERMIO_H
stdin_raw_init(fdi);
-#endif
adb_thread_create(&thr, stdin_read_thread, fds);
read_and_dump(fd);
-#ifdef HAVE_TERMIO_H
stdin_raw_restore(fdi);
-#endif
return 0;
}
@@ -729,7 +734,7 @@
*/
int ppp(int argc, char **argv)
{
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
fprintf(stderr, "error: adb %s not implemented on Win32\n", argv[0]);
return -1;
#else
@@ -792,7 +797,7 @@
adb_close(fd);
return 0;
}
-#endif /* !HAVE_WIN32_PROC */
+#endif /* !defined(_WIN32) */
}
static int send_shellcommand(transport_type transport, char* serial, char* buf)
diff --git a/adb/file_sync_service.h b/adb/file_sync_service.h
index 5dd2e80..c3c8574 100644
--- a/adb/file_sync_service.h
+++ b/adb/file_sync_service.h
@@ -17,22 +17,10 @@
#ifndef _FILE_SYNC_SERVICE_H_
#define _FILE_SYNC_SERVICE_H_
-#ifdef HAVE_BIG_ENDIAN
-static inline unsigned __swap_uint32(unsigned x)
-{
- return (((x) & 0xFF000000) >> 24)
- | (((x) & 0x00FF0000) >> 8)
- | (((x) & 0x0000FF00) << 8)
- | (((x) & 0x000000FF) << 24);
-}
-#define htoll(x) __swap_uint32(x)
-#define ltohl(x) __swap_uint32(x)
-#define MKID(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
-#else
#define htoll(x) (x)
#define ltohl(x) (x)
+
#define MKID(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
-#endif
#define ID_STAT MKID('S','T','A','T')
#define ID_LIST MKID('L','I','S','T')
diff --git a/adb/framebuffer_service.c b/adb/framebuffer_service.c
index 8cbe840..61578aa 100644
--- a/adb/framebuffer_service.c
+++ b/adb/framebuffer_service.c
@@ -76,6 +76,7 @@
exit(1);
}
+ close(fds[1]);
fd_screencap = fds[0];
/* read w, h & format */
@@ -173,10 +174,9 @@
}
done:
- TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
-
close(fds[0]);
- close(fds[1]);
+
+ TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
pipefail:
close(fd);
}
diff --git a/adb/get_my_path_darwin.c b/adb/get_my_path_darwin.c
index 5b95d15..ff1396c 100644
--- a/adb/get_my_path_darwin.c
+++ b/adb/get_my_path_darwin.c
@@ -19,12 +19,12 @@
void get_my_path(char *s, size_t maxLen)
{
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- CFDictionaryRef dict;
- dict = ProcessInformationCopyDictionary(&psn, 0xffffffff);
- CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict,
- CFSTR("CFBundleExecutable"));
- CFStringGetCString(value, s, maxLen, kCFStringEncodingUTF8);
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ CFURLRef executableURL = CFBundleCopyExecutableURL(mainBundle);
+ CFStringRef executablePathString = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle);
+ CFRelease(executableURL);
+
+ CFStringGetFileSystemRepresentation(executablePathString, s, maxLen);
+ CFRelease(executablePathString);
}
diff --git a/adb/services.c b/adb/services.c
index e61371a..bcfc163 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -202,10 +202,10 @@
static int create_subproc_pty(const char *cmd, const char *arg0, const char *arg1, pid_t *pid)
{
D("create_subproc_pty(cmd=%s, arg0=%s, arg1=%s)\n", cmd, arg0, arg1);
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
fprintf(stderr, "error: create_subproc_pty not implemented on Win32 (%s %s %s)\n", cmd, arg0, arg1);
return -1;
-#else /* !HAVE_WIN32_PROC */
+#else
int ptm;
ptm = unix_open("/dev/ptmx", O_RDWR | O_CLOEXEC); // | O_NOCTTY);
@@ -251,16 +251,16 @@
} else {
return ptm;
}
-#endif /* !HAVE_WIN32_PROC */
+#endif /* !defined(_WIN32) */
}
static int create_subproc_raw(const char *cmd, const char *arg0, const char *arg1, pid_t *pid)
{
D("create_subproc_raw(cmd=%s, arg0=%s, arg1=%s)\n", cmd, arg0, arg1);
-#ifdef HAVE_WIN32_PROC
+#if defined(_WIN32)
fprintf(stderr, "error: create_subproc_raw not implemented on Win32 (%s %s %s)\n", cmd, arg0, arg1);
return -1;
-#else /* !HAVE_WIN32_PROC */
+#else
// 0 is parent socket, 1 is child socket
int sv[2];
@@ -295,7 +295,7 @@
adb_close(sv[1]);
return sv[0];
}
-#endif /* !HAVE_WIN32_PROC */
+#endif /* !defined(_WIN32) */
}
#endif /* !ABD_HOST */
diff --git a/adb/transport_local.c b/adb/transport_local.c
index 948cc15..6c4e220 100644
--- a/adb/transport_local.c
+++ b/adb/transport_local.c
@@ -28,21 +28,6 @@
#define TRACE_TAG TRACE_TRANSPORT
#include "adb.h"
-#ifdef HAVE_BIG_ENDIAN
-#define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24)
-static inline void fix_endians(apacket *p)
-{
- p->msg.command = H4(p->msg.command);
- p->msg.arg0 = H4(p->msg.arg0);
- p->msg.arg1 = H4(p->msg.arg1);
- p->msg.data_length = H4(p->msg.data_length);
- p->msg.data_check = H4(p->msg.data_check);
- p->msg.magic = H4(p->msg.magic);
-}
-#else
-#define fix_endians(p) do {} while (0)
-#endif
-
#if ADB_HOST
/* we keep a list of opened transports. The atransport struct knows to which
* local transport it is connected. The list is used to detect when we're
@@ -62,12 +47,6 @@
return -1;
}
- fix_endians(p);
-
-#if 0 && defined HAVE_BIG_ENDIAN
- D("read remote packet: %04x arg0=%0x arg1=%0x data_length=%0x data_check=%0x magic=%0x\n",
- p->msg.command, p->msg.arg0, p->msg.arg1, p->msg.data_length, p->msg.data_check, p->msg.magic);
-#endif
if(check_header(p)) {
D("bad header: terminated (data)\n");
return -1;
@@ -90,12 +69,6 @@
{
int length = p->msg.data_length;
- fix_endians(p);
-
-#if 0 && defined HAVE_BIG_ENDIAN
- D("write remote packet: %04x arg0=%0x arg1=%0x data_length=%0x data_check=%0x magic=%0x\n",
- p->msg.command, p->msg.arg0, p->msg.arg1, p->msg.data_length, p->msg.data_check, p->msg.magic);
-#endif
if(writex(t->sfd, &p->msg, sizeof(amessage) + length)) {
D("remote local: write terminated\n");
return -1;
diff --git a/adb/transport_usb.c b/adb/transport_usb.c
index ee6b637..1138ddd 100644
--- a/adb/transport_usb.c
+++ b/adb/transport_usb.c
@@ -23,33 +23,6 @@
#define TRACE_TAG TRACE_TRANSPORT
#include "adb.h"
-#if ADB_HOST
-#include "usb_vendors.h"
-#endif
-
-#ifdef HAVE_BIG_ENDIAN
-#define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24)
-static inline void fix_endians(apacket *p)
-{
- p->msg.command = H4(p->msg.command);
- p->msg.arg0 = H4(p->msg.arg0);
- p->msg.arg1 = H4(p->msg.arg1);
- p->msg.data_length = H4(p->msg.data_length);
- p->msg.data_check = H4(p->msg.data_check);
- p->msg.magic = H4(p->msg.magic);
-}
-unsigned host_to_le32(unsigned n)
-{
- return H4(n);
-}
-#else
-#define fix_endians(p) do {} while (0)
-unsigned host_to_le32(unsigned n)
-{
- return n;
-}
-#endif
-
static int remote_read(apacket *p, atransport *t)
{
if(usb_read(t->usb, &p->msg, sizeof(amessage))){
@@ -57,8 +30,6 @@
return -1;
}
- fix_endians(p);
-
if(check_header(p)) {
D("remote usb: check_header failed\n");
return -1;
@@ -83,8 +54,6 @@
{
unsigned size = p->msg.data_length;
- fix_endians(p);
-
if(usb_write(t->usb, &p->msg, sizeof(amessage))) {
D("remote usb: 1 - write terminated\n");
return -1;
@@ -131,18 +100,6 @@
#if ADB_HOST
int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol)
{
- unsigned i;
- for (i = 0; i < vendorIdCount; i++) {
- if (vid == vendorIds[i]) {
- if (usb_class == ADB_CLASS && usb_subclass == ADB_SUBCLASS &&
- usb_protocol == ADB_PROTOCOL) {
- return 1;
- }
-
- return 0;
- }
- }
-
- return 0;
+ return (usb_class == ADB_CLASS && usb_subclass == ADB_SUBCLASS && usb_protocol == ADB_PROTOCOL);
}
#endif
diff --git a/adb/usb_osx.c b/adb/usb_osx.c
index ee893f5..ba157f1 100644
--- a/adb/usb_osx.c
+++ b/adb/usb_osx.c
@@ -28,12 +28,11 @@
#define TRACE_TAG TRACE_USB
#include "adb.h"
-#include "usb_vendors.h"
#define DBG D
static IONotificationPortRef notificationPort = 0;
-static io_iterator_t* notificationIterators;
+static io_iterator_t notificationIterator;
struct usb_handle
{
@@ -61,8 +60,6 @@
{
CFMutableDictionaryRef matchingDict;
CFRunLoopSourceRef runLoopSource;
- SInt32 vendor, if_subclass, if_protocol;
- unsigned i;
//* To set up asynchronous notifications, create a notification port and
//* add its run loop event source to the program's run loop
@@ -70,47 +67,33 @@
runLoopSource = IONotificationPortGetRunLoopSource(notificationPort);
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopDefaultMode);
- memset(notificationIterators, 0, sizeof(notificationIterators));
+ //* Create our matching dictionary to find the Android device's
+ //* adb interface
+ //* IOServiceAddMatchingNotification consumes the reference, so we do
+ //* not need to release this
+ matchingDict = IOServiceMatching(kIOUSBInterfaceClassName);
- //* loop through all supported vendors
- for (i = 0; i < vendorIdCount; i++) {
- //* Create our matching dictionary to find the Android device's
- //* adb interface
- //* IOServiceAddMatchingNotification consumes the reference, so we do
- //* not need to release this
- matchingDict = IOServiceMatching(kIOUSBInterfaceClassName);
-
- if (!matchingDict) {
- DBG("ERR: Couldn't create USB matching dictionary.\n");
- return -1;
- }
-
- //* Match based on vendor id, interface subclass and protocol
- vendor = vendorIds[i];
- if_subclass = ADB_SUBCLASS;
- if_protocol = ADB_PROTOCOL;
- CFDictionarySetValue(matchingDict, CFSTR(kUSBVendorID),
- CFNumberCreate(kCFAllocatorDefault,
- kCFNumberSInt32Type, &vendor));
- CFDictionarySetValue(matchingDict, CFSTR(kUSBInterfaceSubClass),
- CFNumberCreate(kCFAllocatorDefault,
- kCFNumberSInt32Type, &if_subclass));
- CFDictionarySetValue(matchingDict, CFSTR(kUSBInterfaceProtocol),
- CFNumberCreate(kCFAllocatorDefault,
- kCFNumberSInt32Type, &if_protocol));
- IOServiceAddMatchingNotification(
- notificationPort,
- kIOFirstMatchNotification,
- matchingDict,
- AndroidInterfaceAdded,
- NULL,
- ¬ificationIterators[i]);
-
- //* Iterate over set of matching interfaces to access already-present
- //* devices and to arm the notification
- AndroidInterfaceAdded(NULL, notificationIterators[i]);
+ if (!matchingDict) {
+ DBG("ERR: Couldn't create USB matching dictionary.\n");
+ return -1;
}
+ //* We have to get notifications for all potential candidates and test them
+ //* at connection time because the matching rules don't allow for a
+ //* USB interface class of 0xff for class+subclass+protocol matches
+ //* See https://developer.apple.com/library/mac/qa/qa1076/_index.html
+ IOServiceAddMatchingNotification(
+ notificationPort,
+ kIOFirstMatchNotification,
+ matchingDict,
+ AndroidInterfaceAdded,
+ NULL,
+ ¬ificationIterator);
+
+ //* Iterate over set of matching interfaces to access already-present
+ //* devices and to arm the notification
+ AndroidInterfaceAdded(NULL, notificationIterator);
+
return 0;
}
@@ -126,6 +109,7 @@
HRESULT result;
SInt32 score;
UInt32 locationId;
+ UInt8 class, subclass, protocol;
UInt16 vendor;
UInt16 product;
UInt8 serialIndex;
@@ -156,6 +140,16 @@
continue;
}
+ kr = (*iface)->GetInterfaceClass(iface, &class);
+ kr = (*iface)->GetInterfaceSubClass(iface, &subclass);
+ kr = (*iface)->GetInterfaceProtocol(iface, &protocol);
+ if(class != ADB_CLASS || subclass != ADB_SUBCLASS || protocol != ADB_PROTOCOL) {
+ // Ignore non-ADB devices.
+ DBG("Ignoring interface with incorrect class/subclass/protocol - %d, %d, %d\n", class, subclass, protocol);
+ (*iface)->Release(iface);
+ continue;
+ }
+
//* this gets us an ioservice, with which we will find the actual
//* device; after getting a plugin, and querying the interface, of
//* course.
@@ -192,7 +186,6 @@
//* Now after all that, we actually have a ref to the device and
//* the interface that matched our criteria
-
kr = (*dev)->GetDeviceVendor(dev, &vendor);
kr = (*dev)->GetDeviceProduct(dev, &product);
kr = (*dev)->GetLocationID(dev, &locationId);
@@ -385,8 +378,6 @@
void* RunLoopThread(void* unused)
{
- unsigned i;
-
InitUSB();
currentRunLoop = CFRunLoopGetCurrent();
@@ -399,9 +390,7 @@
CFRunLoopRun();
currentRunLoop = 0;
- for (i = 0; i < vendorIdCount; i++) {
- IOObjectRelease(notificationIterators[i]);
- }
+ IOObjectRelease(notificationIterator);
IONotificationPortDestroy(notificationPort);
DBG("RunLoopThread done\n");
@@ -416,9 +405,6 @@
{
adb_thread_t tid;
- notificationIterators = (io_iterator_t*)malloc(
- vendorIdCount * sizeof(io_iterator_t));
-
adb_mutex_init(&start_lock, NULL);
adb_cond_init(&start_cond, NULL);
@@ -443,11 +429,6 @@
close_usb_devices();
if (currentRunLoop)
CFRunLoopStop(currentRunLoop);
-
- if (notificationIterators != NULL) {
- free(notificationIterators);
- notificationIterators = NULL;
- }
}
int usb_write(usb_handle *handle, const void *buf, int len)
diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c
deleted file mode 100755
index b037268..0000000
--- a/adb/usb_vendors.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Copyright (C) 2009 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 "usb_vendors.h"
-
-#include <stdio.h>
-
-#ifdef _WIN32
-# define WIN32_LEAN_AND_MEAN
-# include "windows.h"
-# include "shlobj.h"
-#else
-# include <unistd.h>
-# include <sys/stat.h>
-#endif
-
-#include "sysdeps.h"
-#include "adb.h"
-
-#define ANDROID_PATH ".android"
-#define ANDROID_ADB_INI "adb_usb.ini"
-
-#define TRACE_TAG TRACE_USB
-
-/* Keep the list below sorted alphabetically by #define name */
-// Acer's USB Vendor ID
-#define VENDOR_ID_ACER 0x0502
-// Alco's USB Vendor ID
-#define VENDOR_ID_ALCO 0x1914
-// Allwinner's USB Vendor ID
-#define VENDOR_ID_ALLWINNER 0x1F3A
-// Amlogic's USB Vendor ID
-#define VENDOR_ID_AMLOGIC 0x1b8e
-// AnyDATA's USB Vendor ID
-#define VENDOR_ID_ANYDATA 0x16D5
-// Archos's USB Vendor ID
-#define VENDOR_ID_ARCHOS 0x0E79
-// Asus's USB Vendor ID
-#define VENDOR_ID_ASUS 0x0b05
-// BYD's USB Vendor ID
-#define VENDOR_ID_BYD 0x1D91
-// Compal's USB Vendor ID
-#define VENDOR_ID_COMPAL 0x04B7
-// Compalcomm's USB Vendor ID
-#define VENDOR_ID_COMPALCOMM 0x1219
-// Dell's USB Vendor ID
-#define VENDOR_ID_DELL 0x413c
-// ECS's USB Vendor ID
-#define VENDOR_ID_ECS 0x03fc
-// EMERGING_TECH's USB Vendor ID
-#define VENDOR_ID_EMERGING_TECH 0x297F
-// Emerson's USB Vendor ID
-#define VENDOR_ID_EMERSON 0x2207
-// Foxconn's USB Vendor ID
-#define VENDOR_ID_FOXCONN 0x0489
-// Fujitsu's USB Vendor ID
-#define VENDOR_ID_FUJITSU 0x04C5
-// Funai's USB Vendor ID
-#define VENDOR_ID_FUNAI 0x0F1C
-// Garmin-Asus's USB Vendor ID
-#define VENDOR_ID_GARMIN_ASUS 0x091E
-// Gigabyte's USB Vendor ID
-#define VENDOR_ID_GIGABYTE 0x0414
-// Gigaset's USB Vendor ID
-#define VENDOR_ID_GIGASET 0x1E85
-// GIONEE's USB Vendor ID
-#define VENDOR_ID_GIONEE 0x271D
-// Google's USB Vendor ID
-#define VENDOR_ID_GOOGLE 0x18d1
-// Haier's USB Vendor ID
-#define VENDOR_ID_HAIER 0x201E
-// Harris's USB Vendor ID
-#define VENDOR_ID_HARRIS 0x19A5
-// Hisense's USB Vendor ID
-#define VENDOR_ID_HISENSE 0x109b
-// Honeywell's USB Vendor ID
-#define VENDOR_ID_HONEYWELL 0x0c2e
-// HP's USB Vendor ID
-#define VENDOR_ID_HP 0x03f0
-// HTC's USB Vendor ID
-#define VENDOR_ID_HTC 0x0bb4
-// Huawei's USB Vendor ID
-#define VENDOR_ID_HUAWEI 0x12D1
-// INQ Mobile's USB Vendor ID
-#define VENDOR_ID_INQ_MOBILE 0x2314
-// Intel's USB Vendor ID
-#define VENDOR_ID_INTEL 0x8087
-// Intermec's USB Vendor ID
-#define VENDOR_ID_INTERMEC 0x067e
-// IRiver's USB Vendor ID
-#define VENDOR_ID_IRIVER 0x2420
-// K-Touch's USB Vendor ID
-#define VENDOR_ID_K_TOUCH 0x24E3
-// KT Tech's USB Vendor ID
-#define VENDOR_ID_KT_TECH 0x2116
-// Kobo's USB Vendor ID
-#define VENDOR_ID_KOBO 0x2237
-// Kyocera's USB Vendor ID
-#define VENDOR_ID_KYOCERA 0x0482
-// Lab126's USB Vendor ID
-#define VENDOR_ID_LAB126 0x1949
-// Lenovo's USB Vendor ID
-#define VENDOR_ID_LENOVO 0x17EF
-// LenovoMobile's USB Vendor ID
-#define VENDOR_ID_LENOVOMOBILE 0x2006
-// LG's USB Vendor ID
-#define VENDOR_ID_LGE 0x1004
-// Lumigon's USB Vendor ID
-#define VENDOR_ID_LUMIGON 0x25E3
-// Micromax's USB Vendor ID
-#define VENDOR_ID_MICROMAX 0x2A96
-// Motorola's USB Vendor ID
-#define VENDOR_ID_MOTOROLA 0x22b8
-// MSI's USB Vendor ID
-#define VENDOR_ID_MSI 0x0DB0
-// MTK's USB Vendor ID
-#define VENDOR_ID_MTK 0x0e8d
-// NEC's USB Vendor ID
-#define VENDOR_ID_NEC 0x0409
-// B&N Nook's USB Vendor ID
-#define VENDOR_ID_NOOK 0x2080
-// Nvidia's USB Vendor ID
-#define VENDOR_ID_NVIDIA 0x0955
-// OPPO's USB Vendor ID
-#define VENDOR_ID_OPPO 0x22D9
-// On-The-Go-Video's USB Vendor ID
-#define VENDOR_ID_OTGV 0x2257
-// OUYA's USB Vendor ID
-#define VENDOR_ID_OUYA 0x2836
-// Pantech's USB Vendor ID
-#define VENDOR_ID_PANTECH 0x10A9
-// Pegatron's USB Vendor ID
-#define VENDOR_ID_PEGATRON 0x1D4D
-// Philips's USB Vendor ID
-#define VENDOR_ID_PHILIPS 0x0471
-// Panasonic Mobile Communication's USB Vendor ID
-#define VENDOR_ID_PMC 0x04DA
-// Positivo's USB Vendor ID
-#define VENDOR_ID_POSITIVO 0x1662
-// Prestigio's USB Vendor ID
-#define VENDOR_ID_PRESTIGIO 0x29e4
-// Qisda's USB Vendor ID
-#define VENDOR_ID_QISDA 0x1D45
-// Qualcomm's USB Vendor ID
-#define VENDOR_ID_QUALCOMM 0x05c6
-// Quanta's USB Vendor ID
-#define VENDOR_ID_QUANTA 0x0408
-// Razer's USB Vendor ID
-#define VENDOR_ID_RAZER 0x1532
-// Rockchip's USB Vendor ID
-#define VENDOR_ID_ROCKCHIP 0x2207
-// Samsung's USB Vendor ID
-#define VENDOR_ID_SAMSUNG 0x04e8
-// Sharp's USB Vendor ID
-#define VENDOR_ID_SHARP 0x04dd
-// SK Telesys's USB Vendor ID
-#define VENDOR_ID_SK_TELESYS 0x1F53
-// Smartisan's USB Vendor ID
-#define VENDOR_ID_SMARTISAN 0x29a9
-// Sonim Tech's USB Vendor ID
-#define VENDOR_ID_SONIM_TECH 0x1d9c
-// Sony's USB Vendor ID
-#define VENDOR_ID_SONY 0x054C
-// Sony Ericsson's USB Vendor ID
-#define VENDOR_ID_SONY_ERICSSON 0x0FCE
-// T & A Mobile Phones' USB Vendor ID
-#define VENDOR_ID_T_AND_A 0x1BBB
-// TechFaith's USB Vendor ID
-#define VENDOR_ID_TECHFAITH 0x1d09
-// Teleepoch's USB Vendor ID
-#define VENDOR_ID_TELEEPOCH 0x2340
-// Texas Instruments's USB Vendor ID
-#define VENDOR_ID_TI 0x0451
-// Toshiba's USB Vendor ID
-#define VENDOR_ID_TOSHIBA 0x0930
-// TrekStor's USB Vendor ID
-#define VENDOR_ID_TREKSTOR 0x1E68
-// Unowhy's USB Vendor ID
-#define VENDOR_ID_UNOWHY 0x2A49
-// Vizio's USB Vendor ID
-#define VENDOR_ID_VIZIO 0xE040
-// Wacom's USB Vendor ID
-#define VENDOR_ID_WACOM 0x0531
-// Xiaomi's USB Vendor ID
-#define VENDOR_ID_XIAOMI 0x2717
-// YotaDevices's USB Vendor ID
-#define VENDOR_ID_YOTADEVICES 0x2916
-// Yulong Coolpad's USB Vendor ID
-#define VENDOR_ID_YULONG_COOLPAD 0x1EBF
-// ZTE's USB Vendor ID
-#define VENDOR_ID_ZTE 0x19D2
-/* Keep the list above sorted alphabetically by #define name */
-
-/** built-in vendor list */
-/* Keep the list below sorted alphabetically */
-int builtInVendorIds[] = {
- VENDOR_ID_ACER,
- VENDOR_ID_ALCO,
- VENDOR_ID_ALLWINNER,
- VENDOR_ID_AMLOGIC,
- VENDOR_ID_ANYDATA,
- VENDOR_ID_ARCHOS,
- VENDOR_ID_ASUS,
- VENDOR_ID_BYD,
- VENDOR_ID_COMPAL,
- VENDOR_ID_COMPALCOMM,
- VENDOR_ID_DELL,
- VENDOR_ID_ECS,
- VENDOR_ID_EMERGING_TECH,
- VENDOR_ID_EMERSON,
- VENDOR_ID_FOXCONN,
- VENDOR_ID_FUJITSU,
- VENDOR_ID_FUNAI,
- VENDOR_ID_GARMIN_ASUS,
- VENDOR_ID_GIGABYTE,
- VENDOR_ID_GIGASET,
- VENDOR_ID_GIONEE,
- VENDOR_ID_GOOGLE,
- VENDOR_ID_HAIER,
- VENDOR_ID_HARRIS,
- VENDOR_ID_HISENSE,
- VENDOR_ID_HONEYWELL,
- VENDOR_ID_HP,
- VENDOR_ID_HTC,
- VENDOR_ID_HUAWEI,
- VENDOR_ID_INQ_MOBILE,
- VENDOR_ID_INTEL,
- VENDOR_ID_INTERMEC,
- VENDOR_ID_IRIVER,
- VENDOR_ID_KOBO,
- VENDOR_ID_K_TOUCH,
- VENDOR_ID_KT_TECH,
- VENDOR_ID_KYOCERA,
- VENDOR_ID_LAB126,
- VENDOR_ID_LENOVO,
- VENDOR_ID_LENOVOMOBILE,
- VENDOR_ID_LGE,
- VENDOR_ID_LUMIGON,
- VENDOR_ID_MICROMAX,
- VENDOR_ID_MOTOROLA,
- VENDOR_ID_MSI,
- VENDOR_ID_MTK,
- VENDOR_ID_NEC,
- VENDOR_ID_NOOK,
- VENDOR_ID_NVIDIA,
- VENDOR_ID_OPPO,
- VENDOR_ID_OTGV,
- VENDOR_ID_OUYA,
- VENDOR_ID_PANTECH,
- VENDOR_ID_PEGATRON,
- VENDOR_ID_PHILIPS,
- VENDOR_ID_PMC,
- VENDOR_ID_POSITIVO,
- VENDOR_ID_PRESTIGIO,
- VENDOR_ID_QISDA,
- VENDOR_ID_QUALCOMM,
- VENDOR_ID_QUANTA,
- VENDOR_ID_RAZER,
- VENDOR_ID_ROCKCHIP,
- VENDOR_ID_SAMSUNG,
- VENDOR_ID_SHARP,
- VENDOR_ID_SK_TELESYS,
- VENDOR_ID_SMARTISAN,
- VENDOR_ID_SONIM_TECH,
- VENDOR_ID_SONY,
- VENDOR_ID_SONY_ERICSSON,
- VENDOR_ID_T_AND_A,
- VENDOR_ID_TECHFAITH,
- VENDOR_ID_TELEEPOCH,
- VENDOR_ID_TI,
- VENDOR_ID_TOSHIBA,
- VENDOR_ID_TREKSTOR,
- VENDOR_ID_UNOWHY,
- VENDOR_ID_VIZIO,
- VENDOR_ID_WACOM,
- VENDOR_ID_XIAOMI,
- VENDOR_ID_YOTADEVICES,
- VENDOR_ID_YULONG_COOLPAD,
- VENDOR_ID_ZTE,
-};
-/* Keep the list above sorted alphabetically */
-
-#define BUILT_IN_VENDOR_COUNT (sizeof(builtInVendorIds)/sizeof(builtInVendorIds[0]))
-
-/* max number of supported vendor ids (built-in + 3rd party). increase as needed */
-#define VENDOR_COUNT_MAX 128
-
-int vendorIds[VENDOR_COUNT_MAX];
-unsigned vendorIdCount = 0;
-
-int get_adb_usb_ini(char* buff, size_t len);
-
-void usb_vendors_init(void)
-{
- if (VENDOR_COUNT_MAX < BUILT_IN_VENDOR_COUNT) {
- fprintf(stderr, "VENDOR_COUNT_MAX not big enough for built-in vendor list.\n");
- exit(2);
- }
-
- /* add the built-in vendors at the beginning of the array */
- memcpy(vendorIds, builtInVendorIds, sizeof(builtInVendorIds));
-
- /* default array size is the number of built-in vendors */
- vendorIdCount = BUILT_IN_VENDOR_COUNT;
-
- if (VENDOR_COUNT_MAX == BUILT_IN_VENDOR_COUNT)
- return;
-
- char temp[PATH_MAX];
- if (get_adb_usb_ini(temp, sizeof(temp)) == 0) {
- FILE * f = fopen(temp, "rt");
-
- if (f != NULL) {
- /* The vendor id file is pretty basic. 1 vendor id per line.
- Lines starting with # are comments */
- while (fgets(temp, sizeof(temp), f) != NULL) {
- if (temp[0] == '#')
- continue;
-
- long value = strtol(temp, NULL, 0);
- if (errno == EINVAL || errno == ERANGE || value > INT_MAX || value < 0) {
- fprintf(stderr, "Invalid content in %s. Quitting.\n", ANDROID_ADB_INI);
- exit(2);
- }
-
- vendorIds[vendorIdCount++] = (int)value;
-
- /* make sure we don't go beyond the array */
- if (vendorIdCount == VENDOR_COUNT_MAX) {
- break;
- }
- }
- fclose(f);
- }
- }
-}
-
-/* Utils methods */
-
-/* builds the path to the adb vendor id file. returns 0 if success */
-int build_path(char* buff, size_t len, const char* format, const char* home)
-{
- if (snprintf(buff, len, format, home, ANDROID_PATH, ANDROID_ADB_INI) >= (signed)len) {
- return 1;
- }
-
- return 0;
-}
-
-/* fills buff with the path to the adb vendor id file. returns 0 if success */
-int get_adb_usb_ini(char* buff, size_t len)
-{
-#ifdef _WIN32
- const char* home = getenv("ANDROID_SDK_HOME");
- if (home != NULL) {
- return build_path(buff, len, "%s\\%s\\%s", home);
- } else {
- char path[MAX_PATH];
- SHGetFolderPath( NULL, CSIDL_PROFILE, NULL, 0, path);
- return build_path(buff, len, "%s\\%s\\%s", path);
- }
-#else
- const char* home = getenv("HOME");
- if (home == NULL)
- home = "/tmp";
-
- return build_path(buff, len, "%s/%s/%s", home);
-#endif
-}
diff --git a/adb/usb_vendors.h b/adb/usb_vendors.h
deleted file mode 100644
index cee23a1..0000000
--- a/adb/usb_vendors.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2009 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 __USB_VENDORS_H
-#define __USB_VENDORS_H
-
-extern int vendorIds[];
-extern unsigned vendorIdCount;
-
-void usb_vendors_init(void);
-
-#endif
diff --git a/adf/libadf/tests/Android.mk b/adf/libadf/tests/Android.mk
new file mode 100644
index 0000000..93efafa
--- /dev/null
+++ b/adf/libadf/tests/Android.mk
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+LOCAL_PATH := $(my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := adf_test.cpp
+LOCAL_MODULE := adf-unit-tests
+LOCAL_STATIC_LIBRARIES := libadf
+include $(BUILD_NATIVE_TEST)
diff --git a/adf/libadf/tests/adf_test.cpp b/adf/libadf/tests/adf_test.cpp
new file mode 100644
index 0000000..d95330d
--- /dev/null
+++ b/adf/libadf/tests/adf_test.cpp
@@ -0,0 +1,342 @@
+/*
+ * 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.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+
+#include <adf/adf.h>
+#include <gtest/gtest.h>
+#include <sys/mman.h>
+
+class AdfTest : public testing::Test {
+public:
+ AdfTest() : intf_id(0), intf(-1), eng_id(0), eng(-1) { }
+
+ virtual void SetUp() {
+ int err = adf_device_open(dev_id, O_RDWR, &dev);
+ ASSERT_GE(err, 0) << "opening ADF device " << dev_id <<
+ " failed: " << strerror(-err);
+
+ err = adf_find_simple_post_configuration(&dev, fmt8888, n_fmt8888,
+ &intf_id, &eng_id);
+ ASSERT_GE(err, 0) << "finding ADF configuration failed: " <<
+ strerror(-err);
+
+ intf = adf_interface_open(&dev, intf_id, O_RDWR);
+ ASSERT_GE(intf, 0) << "opening ADF interface " << dev_id << "." <<
+ intf_id << " failed: " << strerror(-intf);
+
+ eng = adf_overlay_engine_open(&dev, eng_id, O_RDWR);
+ ASSERT_GE(eng, 0) << "opening ADF overlay engine " << dev_id << "." <<
+ eng_id << " failed: " << strerror(-eng);
+ }
+
+ virtual void TearDown() {
+ if (eng >= 0)
+ close(eng);
+ if (intf >= 0)
+ close(intf);
+ adf_device_close(&dev);
+ }
+
+ void get8888Format(uint32_t &fmt, char fmt_str[ADF_FORMAT_STR_SIZE]) {
+ adf_overlay_engine_data data;
+ int err = adf_get_overlay_engine_data(eng, &data);
+ ASSERT_GE(err, 0) << "getting ADF overlay engine data failed: " <<
+ strerror(-err);
+
+ for (size_t i = 0; i < data.n_supported_formats; i++) {
+ for (size_t j = 0; j < n_fmt8888; j++) {
+ if (data.supported_formats[i] == fmt8888[j]) {
+ fmt = data.supported_formats[i];
+ adf_format_str(fmt, fmt_str);
+ adf_free_overlay_engine_data(&data);
+ return;
+ }
+ }
+ }
+
+ adf_free_overlay_engine_data(&data);
+ FAIL(); /* this should never happen */
+ }
+
+ void drawCheckerboard(void *buf, uint32_t w, uint32_t h, uint32_t pitch) {
+ uint8_t *buf8 = reinterpret_cast<uint8_t *>(buf);
+ for (uint32_t y = 0; y < h / 2; y++) {
+ uint32_t *scanline = reinterpret_cast<uint32_t *>(buf8 + y * pitch);
+ for (uint32_t x = 0; x < w / 2; x++)
+ scanline[x] = 0xFF0000FF;
+ for (uint32_t x = w / 2; x < w; x++)
+ scanline[x] = 0xFF00FFFF;
+ }
+ for (uint32_t y = h / 2; y < h; y++) {
+ uint32_t *scanline = reinterpret_cast<uint32_t *>(buf8 + y * pitch);
+ for (uint32_t x = 0; x < w / 2; x++)
+ scanline[x] = 0xFFFF00FF;
+ for (uint32_t x = w / 2; x < w; x++)
+ scanline[x] = 0xFFFFFFFF;
+ }
+ }
+
+ /* various helpers to call ADF and die on failure */
+
+ void getInterfaceData(adf_interface_data &data) {
+ int err = adf_get_interface_data(intf, &data);
+ ASSERT_GE(err, 0) << "getting ADF interface data failed: " <<
+ strerror(-err);
+ }
+
+ void getCurrentMode(uint32_t &w, uint32_t &h) {
+ adf_interface_data data;
+ ASSERT_NO_FATAL_FAILURE(getInterfaceData(data));
+ w = data.current_mode.hdisplay;
+ h = data.current_mode.vdisplay;
+ adf_free_interface_data(&data);
+ }
+
+ void blank(uint8_t mode) {
+ int err = adf_interface_blank(intf, mode);
+ ASSERT_FALSE(err < 0 && err != -EBUSY) <<
+ "unblanking interface failed: " << strerror(-err);
+ }
+
+ void attach() {
+ int err = adf_device_attach(&dev, eng_id, intf_id);
+ ASSERT_FALSE(err < 0 && err != -EALREADY) <<
+ "attaching overlay engine " << eng_id << " to interface " <<
+ intf_id << " failed: " << strerror(-err);
+ }
+
+ void detach() {
+ int err = adf_device_detach(&dev, eng_id, intf_id);
+ ASSERT_FALSE(err < 0 && err != -EINVAL) <<
+ "detaching overlay engine " << eng_id << " from interface " <<
+ intf_id << " failed: " << strerror(-err);
+ }
+
+ void readVsyncTimestamp(uint64_t ×tamp) {
+ adf_event *event;
+ int err = adf_read_event(intf, &event);
+ ASSERT_GE(err, 0) << "reading ADF event failed: " << strerror(-err);
+
+ ASSERT_EQ(ADF_EVENT_VSYNC, event->type);
+ ASSERT_EQ(sizeof(adf_vsync_event), event->length);
+
+ adf_vsync_event *vsync_event =
+ reinterpret_cast<adf_vsync_event *>(event);
+ timestamp = vsync_event->timestamp;
+ free(event);
+ }
+
+protected:
+ adf_device dev;
+ adf_id_t intf_id;
+ int intf;
+ adf_id_t eng_id;
+ int eng;
+
+private:
+ const static adf_id_t dev_id = 0;
+ const static __u32 fmt8888[];
+ const static size_t n_fmt8888;
+};
+
+const __u32 AdfTest::fmt8888[] = {
+ DRM_FORMAT_XRGB8888,
+ DRM_FORMAT_XBGR8888,
+ DRM_FORMAT_RGBX8888,
+ DRM_FORMAT_BGRX8888,
+ DRM_FORMAT_ARGB8888,
+ DRM_FORMAT_ABGR8888,
+ DRM_FORMAT_RGBA8888,
+ DRM_FORMAT_BGRA8888
+};
+const size_t AdfTest::n_fmt8888 = sizeof(fmt8888) / sizeof(fmt8888[0]);
+
+TEST(adf, devices) {
+ adf_id_t *devs;
+ ssize_t n_devs = adf_devices(&devs);
+ free(devs);
+
+ ASSERT_GE(n_devs, 0) << "enumerating ADF devices failed: " <<
+ strerror(-n_devs);
+ ASSERT_TRUE(devs != NULL);
+}
+
+TEST_F(AdfTest, device_data) {
+ adf_device_data data;
+ int err = adf_get_device_data(&dev, &data);
+ ASSERT_GE(err, 0) << "getting ADF device data failed: " << strerror(-err);
+
+ EXPECT_LT(data.n_attachments, ADF_MAX_ATTACHMENTS);
+ EXPECT_GT(data.n_allowed_attachments, 0);
+ EXPECT_LT(data.n_allowed_attachments, ADF_MAX_ATTACHMENTS);
+ EXPECT_LT(data.custom_data_size, ADF_MAX_CUSTOM_DATA_SIZE);
+ adf_free_device_data(&data);
+}
+
+TEST_F(AdfTest, interface_data) {
+ adf_interface_data data;
+ ASSERT_NO_FATAL_FAILURE(getInterfaceData(data));
+
+ EXPECT_LT(data.type, ADF_INTF_TYPE_MAX);
+ EXPECT_LE(data.dpms_state, DRM_MODE_DPMS_OFF);
+ EXPECT_EQ(1, data.hotplug_detect);
+ EXPECT_GT(data.n_available_modes, 0);
+ EXPECT_LT(data.custom_data_size, ADF_MAX_CUSTOM_DATA_SIZE);
+ adf_free_interface_data(&data);
+}
+
+TEST_F(AdfTest, overlay_engine_data) {
+ adf_overlay_engine_data data;
+ int err = adf_get_overlay_engine_data(eng, &data);
+ ASSERT_GE(err, 0) << "getting ADF overlay engine failed: " <<
+ strerror(-err);
+
+ EXPECT_GT(data.n_supported_formats, 0);
+ EXPECT_LT(data.n_supported_formats, ADF_MAX_SUPPORTED_FORMATS);
+ EXPECT_LT(data.custom_data_size, ADF_MAX_CUSTOM_DATA_SIZE);
+ adf_free_overlay_engine_data(&data);
+}
+
+TEST_F(AdfTest, blank) {
+ int err = adf_interface_blank(intf, (uint8_t)-1);
+ EXPECT_EQ(-EINVAL, err) << "setting bogus DPMS mode should have failed";
+
+ err = adf_interface_blank(eng, DRM_MODE_DPMS_OFF);
+ EXPECT_EQ(-EINVAL, err) << "blanking overlay engine should have failed";
+
+ ASSERT_NO_FATAL_FAILURE(blank(DRM_MODE_DPMS_OFF));
+ err = adf_interface_blank(intf, DRM_MODE_DPMS_OFF);
+ EXPECT_EQ(-EBUSY, err) << "blanking interface twice should have failed";
+
+ ASSERT_NO_FATAL_FAILURE(blank(DRM_MODE_DPMS_ON));
+ err = adf_interface_blank(intf, DRM_MODE_DPMS_ON);
+ EXPECT_EQ(-EBUSY, err) << "unblanking interface twice should have failed";
+
+ adf_interface_data data;
+ ASSERT_NO_FATAL_FAILURE(getInterfaceData(data));
+ EXPECT_EQ(DRM_MODE_DPMS_ON, data.dpms_state);
+ adf_free_interface_data(&data);
+}
+
+TEST_F(AdfTest, event) {
+ int err = adf_set_event(intf, ADF_EVENT_TYPE_MAX, true);
+ EXPECT_EQ(-EINVAL, err) << "enabling bogus ADF event should have failed";
+
+ err = adf_set_event(intf, ADF_EVENT_TYPE_MAX, false);
+ EXPECT_EQ(-EINVAL, err) << "disabling bogus ADF event should have failed";
+
+ err = adf_set_event(intf, ADF_EVENT_VSYNC, true);
+ ASSERT_GE(err, 0) << "enabling vsync event failed: " << strerror(-err);
+
+ err = adf_set_event(intf, ADF_EVENT_VSYNC, true);
+ EXPECT_EQ(-EALREADY, err) <<
+ "enabling vsync event twice should have failed";
+
+ ASSERT_NO_FATAL_FAILURE(blank(DRM_MODE_DPMS_ON));
+
+ uint64_t timestamp1, timestamp2;
+ ASSERT_NO_FATAL_FAILURE(readVsyncTimestamp(timestamp1));
+ ASSERT_NO_FATAL_FAILURE(readVsyncTimestamp(timestamp2));
+ EXPECT_GT(timestamp2, timestamp1);
+
+ err = adf_set_event(intf, ADF_EVENT_VSYNC, false);
+ EXPECT_GE(err, 0) << "disabling vsync event failed: " << strerror(-err);
+
+ err = adf_set_event(intf, ADF_EVENT_VSYNC, false);
+ EXPECT_EQ(-EALREADY, err) <<
+ "disabling vsync event twice should have failed";
+}
+
+TEST_F(AdfTest, attach) {
+ ASSERT_NO_FATAL_FAILURE(attach());
+ int err = adf_device_attach(&dev, eng_id, intf_id);
+ EXPECT_EQ(-EALREADY, err) << "attaching overlay engine " << eng_id <<
+ " to interface " << intf_id << " twice should have failed";
+
+ ASSERT_NO_FATAL_FAILURE(detach());
+ err = adf_device_detach(&dev, eng_id, intf_id);
+ EXPECT_EQ(-EINVAL, err) << "detaching overlay engine " << eng_id <<
+ " from interface " << intf_id << " twice should have failed";
+
+ err = adf_device_attach(&dev, eng_id, ADF_MAX_INTERFACES);
+ EXPECT_EQ(-EINVAL, err) << "attaching overlay engine " << eng_id <<
+ " to bogus interface should have failed";
+
+ err = adf_device_detach(&dev, eng_id, ADF_MAX_INTERFACES);
+ EXPECT_EQ(-EINVAL, err) << "detaching overlay engine " << eng_id <<
+ " from bogus interface should have failed";
+}
+
+TEST_F(AdfTest, simple_buffer_alloc) {
+ uint32_t w = 0, h = 0;
+ ASSERT_NO_FATAL_FAILURE(getCurrentMode(w, h));
+
+ uint32_t format;
+ char format_str[ADF_FORMAT_STR_SIZE];
+ ASSERT_NO_FATAL_FAILURE(get8888Format(format, format_str));
+
+ uint32_t offset;
+ uint32_t pitch;
+ int buf_fd = adf_interface_simple_buffer_alloc(intf, w, h, format, &offset,
+ &pitch);
+ EXPECT_GE(buf_fd, 0) << "allocating " << w << "x" << h << " " <<
+ format_str << " buffer failed: " << strerror(-buf_fd);
+ EXPECT_GE(pitch, w * 4);
+ close(buf_fd);
+
+ buf_fd = adf_interface_simple_buffer_alloc(intf, w, h, 0xDEADBEEF, &offset,
+ &pitch);
+ /* n.b.: ADF only allows simple buffers with built-in RGB formats,
+ so this should fail even if a driver supports custom format 0xDEADBEEF */
+ EXPECT_EQ(-EINVAL, buf_fd) <<
+ "allocating buffer with bogus format should have failed";
+}
+
+TEST_F(AdfTest, simple_buffer) {
+ uint32_t w = 0, h = 0;
+ ASSERT_NO_FATAL_FAILURE(getCurrentMode(w, h));
+
+ uint32_t format = 0;
+ char format_str[ADF_FORMAT_STR_SIZE];
+ ASSERT_NO_FATAL_FAILURE(get8888Format(format, format_str));
+
+ uint32_t offset;
+ uint32_t pitch;
+ int buf_fd = adf_interface_simple_buffer_alloc(intf, w, h, format, &offset,
+ &pitch);
+ ASSERT_GE(buf_fd, 0) << "allocating " << w << "x" << h << " " <<
+ format_str << " buffer failed: " << strerror(-buf_fd);
+ EXPECT_GE(pitch, w * 4);
+
+ void *mapped = mmap(NULL, pitch * h, PROT_WRITE, MAP_SHARED, buf_fd,
+ offset);
+ ASSERT_NE(mapped, MAP_FAILED) << "mapping " << w << "x" << h << " " <<
+ format_str << " buffer failed: " << strerror(-errno);
+ drawCheckerboard(mapped, w, h, pitch);
+ munmap(mapped, pitch * h);
+
+ ASSERT_NO_FATAL_FAILURE(attach());
+ ASSERT_NO_FATAL_FAILURE(blank(DRM_MODE_DPMS_ON));
+
+ int release_fence = adf_interface_simple_post(intf, eng_id, w, h, format,
+ buf_fd, offset, pitch, -1);
+ close(buf_fd);
+ ASSERT_GE(release_fence, 0) << "posting " << w << "x" << h << " " <<
+ format_str << " buffer failed: " << strerror(-release_fence);
+ close(release_fence);
+}
diff --git a/debuggerd/Android.mk b/debuggerd/Android.mk
index c33b263..1b8b98d 100644
--- a/debuggerd/Android.mk
+++ b/debuggerd/Android.mk
@@ -28,8 +28,6 @@
liblog \
libselinux \
-include external/stlport/libstlport.mk
-
LOCAL_MODULE := debuggerd
LOCAL_MODULE_STEM_32 := debuggerd
LOCAL_MODULE_STEM_64 := debuggerd64
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 43d05aa..959d3ad 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -244,7 +244,7 @@
// output compatible with "adb devices"
if (!long_listing) {
printf("%s\tfastboot\n", serial);
- } else if (!info->device_path) {
+ } else if (strcmp("", info->device_path) == 0) {
printf("%-22s fastboot\n", serial);
} else {
printf("%-22s fastboot %s\n", serial, info->device_path);
@@ -988,6 +988,7 @@
unsigned sz;
int status;
int c;
+ int longindex;
const struct option longopts[] = {
{"base", required_argument, 0, 'b'},
@@ -996,13 +997,14 @@
{"ramdisk_offset", required_argument, 0, 'r'},
{"tags_offset", required_argument, 0, 't'},
{"help", 0, 0, 'h'},
+ {"unbuffered", 0, 0, 0},
{0, 0, 0, 0}
};
serial = getenv("ANDROID_SERIAL");
while (1) {
- c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:h", longopts, NULL);
+ c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:h", longopts, &longindex);
if (c < 0) {
break;
}
@@ -1063,6 +1065,12 @@
break;
case '?':
return 1;
+ case 0:
+ if (strcmp("unbuffered", longopts[longindex].name) == 0) {
+ setvbuf(stdout, NULL, _IONBF, 0);
+ setvbuf(stderr, NULL, _IONBF, 0);
+ }
+ break;
default:
abort();
}
diff --git a/fastboot/util_osx.c b/fastboot/util_osx.c
index 26b832a..e718562 100644
--- a/fastboot/util_osx.c
+++ b/fastboot/util_osx.c
@@ -31,14 +31,15 @@
void get_my_path(char s[PATH_MAX])
{
- char *x;
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- CFDictionaryRef dict;
- dict = ProcessInformationCopyDictionary(&psn, 0xffffffff);
- CFStringRef value = (CFStringRef)CFDictionaryGetValue(dict,
- CFSTR("CFBundleExecutable"));
- CFStringGetCString(value, s, PATH_MAX - 1, kCFStringEncodingUTF8);
+ CFBundleRef mainBundle = CFBundleGetMainBundle();
+ CFURLRef executableURL = CFBundleCopyExecutableURL(mainBundle);
+ CFStringRef executablePathString = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle);
+ CFRelease(executableURL);
+
+ CFStringGetFileSystemRepresentation(executablePathString, s, PATH_MAX-1);
+ CFRelease(executablePathString);
+
+ char *x;
x = strrchr(s, '/');
if(x) x[1] = 0;
}
diff --git a/fastbootd/commands/virtual_partitions.c b/fastbootd/commands/virtual_partitions.c
index 813f485..9da4020 100644
--- a/fastbootd/commands/virtual_partitions.c
+++ b/fastbootd/commands/virtual_partitions.c
@@ -30,6 +30,9 @@
*/
#include "commands/virtual_partitions.h"
+
+#include <string.h>
+
#include "debug.h"
static struct virtual_partition *partitions = NULL;
diff --git a/fastbootd/utils.h b/fastbootd/utils.h
index 3d98699..2f89582 100644
--- a/fastbootd/utils.h
+++ b/fastbootd/utils.h
@@ -29,7 +29,7 @@
* SUCH DAMAGE.
*/
-#ifndef _FASTBOOT_UTLIS_H
+#ifndef _FASTBOOT_UTILS_H
#define _FASTBOOT_UTILS_H
#include <stdio.h>
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 4a6b702..06497c2 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -389,7 +389,6 @@
if (!strcmp(name, ".") || !strcmp(name, ".."))
continue;
- char buf[20];
// Look for "type" file in each subdirectory
path.clear();
path.appendFormat("%s/%s/type", POWER_SUPPLY_SYSFS_PATH, name);
diff --git a/healthd/BatteryPropertiesRegistrar.cpp b/healthd/BatteryPropertiesRegistrar.cpp
index 74bcbfd..09667a1 100644
--- a/healthd/BatteryPropertiesRegistrar.cpp
+++ b/healthd/BatteryPropertiesRegistrar.cpp
@@ -48,13 +48,13 @@
Mutex::Autolock _l(mRegistrationLock);
// check whether this is a duplicate
for (size_t i = 0; i < mListeners.size(); i++) {
- if (mListeners[i]->asBinder() == listener->asBinder()) {
+ if (IInterface::asBinder(mListeners[i]) == IInterface::asBinder(listener)) {
return;
}
}
mListeners.add(listener);
- listener->asBinder()->linkToDeath(this);
+ IInterface::asBinder(listener)->linkToDeath(this);
}
healthd_battery_update();
}
@@ -64,8 +64,8 @@
return;
Mutex::Autolock _l(mRegistrationLock);
for (size_t i = 0; i < mListeners.size(); i++) {
- if (mListeners[i]->asBinder() == listener->asBinder()) {
- mListeners[i]->asBinder()->unlinkToDeath(this);
+ if (IInterface::asBinder(mListeners[i]) == IInterface::asBinder(listener)) {
+ IInterface::asBinder(mListeners[i])->unlinkToDeath(this);
mListeners.removeAt(i);
break;
}
@@ -93,7 +93,7 @@
Mutex::Autolock _l(mRegistrationLock);
for (size_t i = 0; i < mListeners.size(); i++) {
- if (mListeners[i]->asBinder() == who) {
+ if (IInterface::asBinder(mListeners[i]) == who) {
mListeners.removeAt(i);
break;
}
diff --git a/healthd/healthd.cpp b/healthd/healthd.cpp
index 30a4b42..b34583d 100644
--- a/healthd/healthd.cpp
+++ b/healthd/healthd.cpp
@@ -64,7 +64,6 @@
#define MAX_EPOLL_EVENTS 40
static int uevent_fd;
static int wakealarm_fd;
-static int binder_fd;
// -1 for no epoll timeout
static int awake_poll_interval = -1;
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp
index 394feb8..291cb6c 100644
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -350,7 +350,6 @@
static void update_screen_state(struct charger *charger, int64_t now)
{
struct animation *batt_anim = charger->batt_anim;
- int cur_frame;
int disp_time;
if (!batt_anim->run || now < charger->next_screen_transition)
@@ -393,7 +392,6 @@
/* animation starting, set up the animation */
if (batt_anim->cur_frame == 0) {
int batt_cap;
- int ret;
LOGV("[%" PRId64 "] animation starting\n", now);
batt_cap = get_battery_capacity();
@@ -517,7 +515,6 @@
static void process_key(struct charger *charger, int code, int64_t now)
{
struct key_state *key = &charger->keys[code];
- int64_t next_key_check;
if (code == KEY_POWER) {
if (key->down) {
@@ -590,7 +587,6 @@
{
struct charger *charger = &charger_state;
int64_t now = curr_time_ms();
- int ret;
handle_input_state(charger, now);
handle_power_supply_state(charger, now);
@@ -625,8 +621,6 @@
int64_t now = curr_time_ms();
int64_t next_event = INT64_MAX;
int64_t timeout;
- struct input_event ev;
- int ret;
LOGV("[%" PRId64 "] next screen: %" PRId64 " next key: %" PRId64 " next pwr: %" PRId64 "\n", now,
charger->next_screen_transition, charger->next_key_check,
diff --git a/include/cutils/aref.h b/include/cutils/aref.h
index 460ac02..3bd36ea 100644
--- a/include/cutils/aref.h
+++ b/include/cutils/aref.h
@@ -20,11 +20,7 @@
#include <stddef.h>
#include <sys/cdefs.h>
-#ifdef ANDROID_SMP
-#include <cutils/atomic-inline.h>
-#else
#include <cutils/atomic.h>
-#endif
__BEGIN_DECLS
diff --git a/include/cutils/atomic-arm.h b/include/cutils/atomic-arm.h
deleted file mode 100644
index 6b031b6..0000000
--- a/include/cutils/atomic-arm.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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 ANDROID_CUTILS_ATOMIC_ARM_H
-#define ANDROID_CUTILS_ATOMIC_ARM_H
-
-#include <stdint.h>
-
-#ifndef ANDROID_ATOMIC_INLINE
-#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
-#endif
-
-extern ANDROID_ATOMIC_INLINE void android_compiler_barrier()
-{
- __asm__ __volatile__ ("" : : : "memory");
-}
-
-extern ANDROID_ATOMIC_INLINE void android_memory_barrier()
-{
-#if ANDROID_SMP == 0
- android_compiler_barrier();
-#else
- __asm__ __volatile__ ("dmb" : : : "memory");
-#endif
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_acquire_load(volatile const int32_t *ptr)
-{
- int32_t value = *ptr;
- android_memory_barrier();
- return value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_release_load(volatile const int32_t *ptr)
-{
- android_memory_barrier();
- return *ptr;
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr)
-{
- *ptr = value;
- android_memory_barrier();
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_atomic_release_store(int32_t value, volatile int32_t *ptr)
-{
- android_memory_barrier();
- *ptr = value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- int32_t prev, status;
- do {
- __asm__ __volatile__ ("ldrex %0, [%3]\n"
- "mov %1, #0\n"
- "teq %0, %4\n"
-#ifdef __thumb2__
- "it eq\n"
-#endif
- "strexeq %1, %5, [%3]"
- : "=&r" (prev), "=&r" (status), "+m"(*ptr)
- : "r" (ptr), "Ir" (old_value), "r" (new_value)
- : "cc");
- } while (__builtin_expect(status != 0, 0));
- return prev != old_value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_acquire_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- int status = android_atomic_cas(old_value, new_value, ptr);
- android_memory_barrier();
- return status;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_release_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- android_memory_barrier();
- return android_atomic_cas(old_value, new_value, ptr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr)
-{
- int32_t prev, tmp, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ ("ldrex %0, [%4]\n"
- "add %1, %0, %5\n"
- "strex %2, %1, [%4]"
- : "=&r" (prev), "=&r" (tmp),
- "=&r" (status), "+m" (*ptr)
- : "r" (ptr), "Ir" (increment)
- : "cc");
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t android_atomic_inc(volatile int32_t *addr)
-{
- return android_atomic_add(1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t android_atomic_dec(volatile int32_t *addr)
-{
- return android_atomic_add(-1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_and(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, tmp, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ ("ldrex %0, [%4]\n"
- "and %1, %0, %5\n"
- "strex %2, %1, [%4]"
- : "=&r" (prev), "=&r" (tmp),
- "=&r" (status), "+m" (*ptr)
- : "r" (ptr), "Ir" (value)
- : "cc");
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_or(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, tmp, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ ("ldrex %0, [%4]\n"
- "orr %1, %0, %5\n"
- "strex %2, %1, [%4]"
- : "=&r" (prev), "=&r" (tmp),
- "=&r" (status), "+m" (*ptr)
- : "r" (ptr), "Ir" (value)
- : "cc");
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-#endif /* ANDROID_CUTILS_ATOMIC_ARM_H */
diff --git a/include/cutils/atomic-arm64.h b/include/cutils/atomic-arm64.h
deleted file mode 100644
index 7ae47d7..0000000
--- a/include/cutils/atomic-arm64.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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 ANDROID_CUTILS_ATOMIC_AARCH64_H
-#define ANDROID_CUTILS_ATOMIC_AARCH64_H
-
-#include <stdint.h>
-
-#ifndef ANDROID_ATOMIC_INLINE
-#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
-#endif
-
-/*
- TODOAArch64: Revisit the below functions and check for potential
- optimizations using assembly code or otherwise.
-*/
-
-extern ANDROID_ATOMIC_INLINE
-void android_compiler_barrier(void)
-{
- __asm__ __volatile__ ("" : : : "memory");
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_memory_barrier(void)
-{
- __asm__ __volatile__ ("dmb ish" : : : "memory");
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_acquire_load(volatile const int32_t *ptr)
-{
- int32_t value = *ptr;
- android_memory_barrier();
- return value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_release_load(volatile const int32_t *ptr)
-{
- android_memory_barrier();
- return *ptr;
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr)
-{
- *ptr = value;
- android_memory_barrier();
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_atomic_release_store(int32_t value, volatile int32_t *ptr)
-{
- android_memory_barrier();
- *ptr = value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- return __sync_val_compare_and_swap(ptr, old_value, new_value) != old_value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_acquire_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- int status = android_atomic_cas(old_value, new_value, ptr);
- android_memory_barrier();
- return status;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_release_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- android_memory_barrier();
- return android_atomic_cas(old_value, new_value, ptr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- prev = *ptr;
- status = android_atomic_cas(prev, prev + increment, ptr);
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_inc(volatile int32_t *addr)
-{
- return android_atomic_add(1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_dec(volatile int32_t *addr)
-{
- return android_atomic_add(-1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_and(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- prev = *ptr;
- status = android_atomic_cas(prev, prev & value, ptr);
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_or(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- prev = *ptr;
- status = android_atomic_cas(prev, prev | value, ptr);
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-#endif /* ANDROID_CUTILS_ATOMIC_AARCH64_H */
diff --git a/include/cutils/atomic-inline.h b/include/cutils/atomic-inline.h
deleted file mode 100644
index a31e913..0000000
--- a/include/cutils/atomic-inline.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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 ANDROID_CUTILS_ATOMIC_INLINE_H
-#define ANDROID_CUTILS_ATOMIC_INLINE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Inline declarations and macros for some special-purpose atomic
- * operations. These are intended for rare circumstances where a
- * memory barrier needs to be issued inline rather than as a function
- * call.
- *
- * Most code should not use these.
- *
- * Anything that does include this file must set ANDROID_SMP to either
- * 0 or 1, indicating compilation for UP or SMP, respectively.
- *
- * Macros defined in this header:
- *
- * void ANDROID_MEMBAR_FULL(void)
- * Full memory barrier. Provides a compiler reordering barrier, and
- * on SMP systems emits an appropriate instruction.
- */
-
-#if !defined(ANDROID_SMP)
-# error "Must define ANDROID_SMP before including atomic-inline.h"
-#endif
-
-#if defined(__aarch64__)
-#include <cutils/atomic-arm64.h>
-#elif defined(__arm__)
-#include <cutils/atomic-arm.h>
-#elif defined(__i386__)
-#include <cutils/atomic-x86.h>
-#elif defined(__x86_64__)
-#include <cutils/atomic-x86_64.h>
-#elif defined(__mips64)
-#include <cutils/atomic-mips64.h>
-#elif defined(__mips__)
-#include <cutils/atomic-mips.h>
-#else
-#error atomic operations are unsupported
-#endif
-
-#if ANDROID_SMP == 0
-#define ANDROID_MEMBAR_FULL android_compiler_barrier
-#else
-#define ANDROID_MEMBAR_FULL android_memory_barrier
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */
diff --git a/include/cutils/atomic-mips.h b/include/cutils/atomic-mips.h
deleted file mode 100644
index 5d4f097..0000000
--- a/include/cutils/atomic-mips.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * 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 ANDROID_CUTILS_ATOMIC_MIPS_H
-#define ANDROID_CUTILS_ATOMIC_MIPS_H
-
-#include <stdint.h>
-
-#ifndef ANDROID_ATOMIC_INLINE
-#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
-#endif
-
-extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void)
-{
- __asm__ __volatile__ ("" : : : "memory");
-}
-
-#if ANDROID_SMP == 0
-extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void)
-{
- android_compiler_barrier();
-}
-#else
-extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void)
-{
- __asm__ __volatile__ ("sync" : : : "memory");
-}
-#endif
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_acquire_load(volatile const int32_t *ptr)
-{
- int32_t value = *ptr;
- android_memory_barrier();
- return value;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_release_load(volatile const int32_t *ptr)
-{
- android_memory_barrier();
- return *ptr;
-}
-
-extern ANDROID_ATOMIC_INLINE void
-android_atomic_acquire_store(int32_t value, volatile int32_t *ptr)
-{
- *ptr = value;
- android_memory_barrier();
-}
-
-extern ANDROID_ATOMIC_INLINE void
-android_atomic_release_store(int32_t value, volatile int32_t *ptr)
-{
- android_memory_barrier();
- *ptr = value;
-}
-
-extern ANDROID_ATOMIC_INLINE int
-android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- do {
- __asm__ __volatile__ (
- " ll %[prev], (%[ptr])\n"
- " li %[status], 1\n"
- " bne %[prev], %[old], 9f\n"
- " move %[status], %[new_value]\n"
- " sc %[status], (%[ptr])\n"
- "9:\n"
- : [prev] "=&r" (prev), [status] "=&r" (status)
- : [ptr] "r" (ptr), [old] "r" (old_value), [new_value] "r" (new_value)
- );
- } while (__builtin_expect(status == 0, 0));
- return prev != old_value;
-}
-
-extern ANDROID_ATOMIC_INLINE int
-android_atomic_acquire_cas(int32_t old_value,
- int32_t new_value,
- volatile int32_t *ptr)
-{
- int status = android_atomic_cas(old_value, new_value, ptr);
- android_memory_barrier();
- return status;
-}
-
-extern ANDROID_ATOMIC_INLINE int
-android_atomic_release_cas(int32_t old_value,
- int32_t new_value,
- volatile int32_t *ptr)
-{
- android_memory_barrier();
- return android_atomic_cas(old_value, new_value, ptr);
-}
-
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_add(int32_t increment, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ (
- " ll %[prev], (%[ptr])\n"
- " addu %[status], %[prev], %[inc]\n"
- " sc %[status], (%[ptr])\n"
- : [status] "=&r" (status), [prev] "=&r" (prev)
- : [ptr] "r" (ptr), [inc] "Ir" (increment)
- );
- } while (__builtin_expect(status == 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_inc(volatile int32_t *addr)
-{
- return android_atomic_add(1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_dec(volatile int32_t *addr)
-{
- return android_atomic_add(-1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_and(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ (
- " ll %[prev], (%[ptr])\n"
- " and %[status], %[prev], %[value]\n"
- " sc %[status], (%[ptr])\n"
- : [prev] "=&r" (prev), [status] "=&r" (status)
- : [ptr] "r" (ptr), [value] "Ir" (value)
- );
- } while (__builtin_expect(status == 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_or(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ (
- " ll %[prev], (%[ptr])\n"
- " or %[status], %[prev], %[value]\n"
- " sc %[status], (%[ptr])\n"
- : [prev] "=&r" (prev), [status] "=&r" (status)
- : [ptr] "r" (ptr), [value] "Ir" (value)
- );
- } while (__builtin_expect(status == 0, 0));
- return prev;
-}
-
-#endif /* ANDROID_CUTILS_ATOMIC_MIPS_H */
diff --git a/include/cutils/atomic-mips64.h b/include/cutils/atomic-mips64.h
deleted file mode 100644
index 9d8f65e..0000000
--- a/include/cutils/atomic-mips64.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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 ANDROID_CUTILS_ATOMIC_MIPS64_H
-#define ANDROID_CUTILS_ATOMIC_MIPS64_H
-
-#include <stdint.h>
-
-#ifndef ANDROID_ATOMIC_INLINE
-#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
-#endif
-
-extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void)
-{
- __asm__ __volatile__ ("" : : : "memory");
-}
-
-extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void)
-{
- __asm__ __volatile__ ("sync" : : : "memory");
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_acquire_load(volatile const int32_t *ptr)
-{
- int32_t value = *ptr;
- android_memory_barrier();
- return value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_release_load(volatile const int32_t *ptr)
-{
- android_memory_barrier();
- return *ptr;
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr)
-{
- *ptr = value;
- android_memory_barrier();
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_atomic_release_store(int32_t value, volatile int32_t *ptr)
-{
- android_memory_barrier();
- *ptr = value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- do {
- __asm__ __volatile__ (
- " ll %[prev], (%[ptr])\n"
- " li %[status], 1\n"
- " bne %[prev], %[old], 9f\n"
- " move %[status], %[new_value]\n"
- " sc %[status], (%[ptr])\n"
- "9:\n"
- : [prev] "=&r" (prev), [status] "=&r" (status)
- : [ptr] "r" (ptr), [old] "r" (old_value), [new_value] "r" (new_value)
- );
- } while (__builtin_expect(status == 0, 0));
- return prev != old_value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_acquire_cas(int32_t old_value,
- int32_t new_value,
- volatile int32_t *ptr)
-{
- int status = android_atomic_cas(old_value, new_value, ptr);
- android_memory_barrier();
- return status;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_release_cas(int32_t old_value,
- int32_t new_value,
- volatile int32_t *ptr)
-{
- android_memory_barrier();
- return android_atomic_cas(old_value, new_value, ptr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ (
- " ll %[prev], (%[ptr])\n"
- " addu %[status], %[prev], %[inc]\n"
- " sc %[status], (%[ptr])\n"
- : [status] "=&r" (status), [prev] "=&r" (prev)
- : [ptr] "r" (ptr), [inc] "Ir" (increment)
- );
- } while (__builtin_expect(status == 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_inc(volatile int32_t *addr)
-{
- return android_atomic_add(1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_dec(volatile int32_t *addr)
-{
- return android_atomic_add(-1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_and(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ (
- " ll %[prev], (%[ptr])\n"
- " and %[status], %[prev], %[value]\n"
- " sc %[status], (%[ptr])\n"
- : [prev] "=&r" (prev), [status] "=&r" (status)
- : [ptr] "r" (ptr), [value] "Ir" (value)
- );
- } while (__builtin_expect(status == 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_or(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- android_memory_barrier();
- do {
- __asm__ __volatile__ (
- " ll %[prev], (%[ptr])\n"
- " or %[status], %[prev], %[value]\n"
- " sc %[status], (%[ptr])\n"
- : [prev] "=&r" (prev), [status] "=&r" (status)
- : [ptr] "r" (ptr), [value] "Ir" (value)
- );
- } while (__builtin_expect(status == 0, 0));
- return prev;
-}
-
-#endif /* ANDROID_CUTILS_ATOMIC_MIPS_H */
diff --git a/include/cutils/atomic-x86.h b/include/cutils/atomic-x86.h
deleted file mode 100644
index 06bf1a3..0000000
--- a/include/cutils/atomic-x86.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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 ANDROID_CUTILS_ATOMIC_X86_H
-#define ANDROID_CUTILS_ATOMIC_X86_H
-
-#include <stdint.h>
-
-#ifndef ANDROID_ATOMIC_INLINE
-#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
-#endif
-
-extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void)
-{
- __asm__ __volatile__ ("" : : : "memory");
-}
-
-#if ANDROID_SMP == 0
-extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void)
-{
- android_compiler_barrier();
-}
-#else
-extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void)
-{
- __asm__ __volatile__ ("mfence" : : : "memory");
-}
-#endif
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_acquire_load(volatile const int32_t *ptr)
-{
- int32_t value = *ptr;
- android_compiler_barrier();
- return value;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_release_load(volatile const int32_t *ptr)
-{
- android_memory_barrier();
- return *ptr;
-}
-
-extern ANDROID_ATOMIC_INLINE void
-android_atomic_acquire_store(int32_t value, volatile int32_t *ptr)
-{
- *ptr = value;
- android_memory_barrier();
-}
-
-extern ANDROID_ATOMIC_INLINE void
-android_atomic_release_store(int32_t value, volatile int32_t *ptr)
-{
- android_compiler_barrier();
- *ptr = value;
-}
-
-extern ANDROID_ATOMIC_INLINE int
-android_atomic_cas(int32_t old_value, int32_t new_value, volatile int32_t *ptr)
-{
- int32_t prev;
- __asm__ __volatile__ ("lock; cmpxchgl %1, %2"
- : "=a" (prev)
- : "q" (new_value), "m" (*ptr), "0" (old_value)
- : "memory");
- return prev != old_value;
-}
-
-extern ANDROID_ATOMIC_INLINE int
-android_atomic_acquire_cas(int32_t old_value,
- int32_t new_value,
- volatile int32_t *ptr)
-{
- /* Loads are not reordered with other loads. */
- return android_atomic_cas(old_value, new_value, ptr);
-}
-
-extern ANDROID_ATOMIC_INLINE int
-android_atomic_release_cas(int32_t old_value,
- int32_t new_value,
- volatile int32_t *ptr)
-{
- /* Stores are not reordered with other stores. */
- return android_atomic_cas(old_value, new_value, ptr);
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_add(int32_t increment, volatile int32_t *ptr)
-{
- __asm__ __volatile__ ("lock; xaddl %0, %1"
- : "+r" (increment), "+m" (*ptr)
- : : "memory");
- /* increment now holds the old value of *ptr */
- return increment;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_inc(volatile int32_t *addr)
-{
- return android_atomic_add(1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_dec(volatile int32_t *addr)
-{
- return android_atomic_add(-1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_and(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- do {
- prev = *ptr;
- status = android_atomic_cas(prev, prev & value, ptr);
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE int32_t
-android_atomic_or(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- do {
- prev = *ptr;
- status = android_atomic_cas(prev, prev | value, ptr);
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-#endif /* ANDROID_CUTILS_ATOMIC_X86_H */
diff --git a/include/cutils/atomic-x86_64.h b/include/cutils/atomic-x86_64.h
deleted file mode 100644
index 99cb070..0000000
--- a/include/cutils/atomic-x86_64.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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 ANDROID_CUTILS_ATOMIC_X86_64_H
-#define ANDROID_CUTILS_ATOMIC_X86_64_H
-
-#include <stdint.h>
-
-#ifndef ANDROID_ATOMIC_INLINE
-#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
-#endif
-
-extern ANDROID_ATOMIC_INLINE
-void android_compiler_barrier(void)
-{
- __asm__ __volatile__ ("" : : : "memory");
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_memory_barrier(void)
-{
- __asm__ __volatile__ ("mfence" : : : "memory");
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_acquire_load(volatile const int32_t *ptr)
-{
- int32_t value = *ptr;
- android_compiler_barrier();
- return value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_release_load(volatile const int32_t *ptr)
-{
- android_memory_barrier();
- return *ptr;
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_atomic_acquire_store(int32_t value, volatile int32_t *ptr)
-{
- *ptr = value;
- android_memory_barrier();
-}
-
-extern ANDROID_ATOMIC_INLINE
-void android_atomic_release_store(int32_t value, volatile int32_t *ptr)
-{
- android_compiler_barrier();
- *ptr = value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- int32_t prev;
- __asm__ __volatile__ ("lock; cmpxchgl %1, %2"
- : "=a" (prev)
- : "q" (new_value), "m" (*ptr), "0" (old_value)
- : "memory");
- return prev != old_value;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_acquire_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- /* Loads are not reordered with other loads. */
- return android_atomic_cas(old_value, new_value, ptr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int android_atomic_release_cas(int32_t old_value, int32_t new_value,
- volatile int32_t *ptr)
-{
- /* Stores are not reordered with other stores. */
- return android_atomic_cas(old_value, new_value, ptr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_add(int32_t increment, volatile int32_t *ptr)
-{
- __asm__ __volatile__ ("lock; xaddl %0, %1"
- : "+r" (increment), "+m" (*ptr)
- : : "memory");
- /* increment now holds the old value of *ptr */
- return increment;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_inc(volatile int32_t *addr)
-{
- return android_atomic_add(1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_dec(volatile int32_t *addr)
-{
- return android_atomic_add(-1, addr);
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_and(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- do {
- prev = *ptr;
- status = android_atomic_cas(prev, prev & value, ptr);
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-extern ANDROID_ATOMIC_INLINE
-int32_t android_atomic_or(int32_t value, volatile int32_t *ptr)
-{
- int32_t prev, status;
- do {
- prev = *ptr;
- status = android_atomic_cas(prev, prev | value, ptr);
- } while (__builtin_expect(status != 0, 0));
- return prev;
-}
-
-#endif /* ANDROID_CUTILS_ATOMIC_X86_64_H */
diff --git a/include/cutils/atomic.h b/include/cutils/atomic.h
index 79409a7..ded972a 100644
--- a/include/cutils/atomic.h
+++ b/include/cutils/atomic.h
@@ -19,9 +19,10 @@
#include <stdint.h>
#include <sys/types.h>
+#include <stdatomic.h>
-#ifdef __cplusplus
-extern "C" {
+#ifndef ANDROID_ATOMIC_INLINE
+#define ANDROID_ATOMIC_INLINE static inline
#endif
/*
@@ -77,11 +78,41 @@
* These have the same characteristics (e.g. what happens on overflow)
* as the equivalent non-atomic C operations.
*/
-int32_t android_atomic_inc(volatile int32_t* addr);
-int32_t android_atomic_dec(volatile int32_t* addr);
-int32_t android_atomic_add(int32_t value, volatile int32_t* addr);
-int32_t android_atomic_and(int32_t value, volatile int32_t* addr);
-int32_t android_atomic_or(int32_t value, volatile int32_t* addr);
+ANDROID_ATOMIC_INLINE
+int32_t android_atomic_inc(volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ /* Int32_t, if it exists, is the same as int_least32_t. */
+ return atomic_fetch_add_explicit(a, 1, memory_order_release);
+}
+
+ANDROID_ATOMIC_INLINE
+int32_t android_atomic_dec(volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ return atomic_fetch_sub_explicit(a, 1, memory_order_release);
+}
+
+ANDROID_ATOMIC_INLINE
+int32_t android_atomic_add(int32_t value, volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ return atomic_fetch_add_explicit(a, value, memory_order_release);
+}
+
+ANDROID_ATOMIC_INLINE
+int32_t android_atomic_and(int32_t value, volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ return atomic_fetch_and_explicit(a, value, memory_order_release);
+}
+
+ANDROID_ATOMIC_INLINE
+int32_t android_atomic_or(int32_t value, volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ return atomic_fetch_or_explicit(a, value, memory_order_release);
+}
/*
* Perform an atomic load with "acquire" or "release" ordering.
@@ -96,29 +127,53 @@
* this comment, you are in the vast majority, and should not be
* using release loads or replacing them with anything other than
* locks or default sequentially consistent atomics.
- *
- * This is only necessary if you need the memory barrier. A 32-bit read
- * from a 32-bit aligned address is atomic on all supported platforms.
*/
-int32_t android_atomic_acquire_load(volatile const int32_t* addr);
-int32_t android_atomic_release_load(volatile const int32_t* addr);
+ANDROID_ATOMIC_INLINE
+int32_t android_atomic_acquire_load(volatile const int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ return atomic_load_explicit(a, memory_order_acquire);
+}
+
+ANDROID_ATOMIC_INLINE
+int32_t android_atomic_release_load(volatile const int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ atomic_thread_fence(memory_order_seq_cst);
+ /* Any reasonable clients of this interface would probably prefer */
+ /* something weaker. But some remaining clients seem to be */
+ /* abusing this API in strange ways, e.g. by using it as a fence. */
+ /* Thus we are conservative until we can get rid of remaining */
+ /* clients (and this function). */
+ return atomic_load_explicit(a, memory_order_relaxed);
+}
/*
* Perform an atomic store with "acquire" or "release" ordering.
*
- * Note that the notion of a "acquire" ordering for a store does not
+ * Note that the notion of an "acquire" ordering for a store does not
* really fit into the C11 or C++11 memory model. The extra ordering
* is normally observable only by code using memory_order_relaxed
* atomics, or data races. In the rare cases in which such ordering
* is called for, use memory_order_relaxed atomics and a trailing
* atomic_thread_fence (typically with memory_order_release,
* not memory_order_acquire!) instead.
- *
- * This is only necessary if you need the memory barrier. A 32-bit write
- * to a 32-bit aligned address is atomic on all supported platforms.
*/
-void android_atomic_acquire_store(int32_t value, volatile int32_t* addr);
-void android_atomic_release_store(int32_t value, volatile int32_t* addr);
+ANDROID_ATOMIC_INLINE
+void android_atomic_acquire_store(int32_t value, volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ atomic_store_explicit(a, value, memory_order_relaxed);
+ atomic_thread_fence(memory_order_seq_cst);
+ /* Again overly conservative to accomodate weird clients. */
+}
+
+ANDROID_ATOMIC_INLINE
+void android_atomic_release_store(int32_t value, volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ atomic_store_explicit(a, value, memory_order_release);
+}
/*
* Compare-and-set operation with "acquire" or "release" ordering.
@@ -132,10 +187,44 @@
* Implementations that use the release CAS in a loop may be less efficient
* than possible, because we re-issue the memory barrier on each iteration.
*/
+ANDROID_ATOMIC_INLINE
int android_atomic_acquire_cas(int32_t oldvalue, int32_t newvalue,
- volatile int32_t* addr);
+ volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ return (int)(!atomic_compare_exchange_strong_explicit(
+ a, &oldvalue, newvalue,
+ memory_order_acquire,
+ memory_order_acquire));
+}
+
+ANDROID_ATOMIC_INLINE
int android_atomic_release_cas(int32_t oldvalue, int32_t newvalue,
- volatile int32_t* addr);
+ volatile int32_t* addr)
+{
+ volatile atomic_int_least32_t* a = (volatile atomic_int_least32_t*)addr;
+ return (int)(!atomic_compare_exchange_strong_explicit(
+ a, &oldvalue, newvalue,
+ memory_order_release,
+ memory_order_relaxed));
+}
+
+/*
+ * Fence primitives.
+ */
+ANDROID_ATOMIC_INLINE
+void android_compiler_barrier(void)
+{
+ __asm__ __volatile__ ("" : : : "memory");
+ /* Could probably also be: */
+ /* atomic_signal_fence(memory_order_seq_cst); */
+}
+
+ANDROID_ATOMIC_INLINE
+void android_memory_barrier(void)
+{
+ atomic_thread_fence(memory_order_seq_cst);
+}
/*
* Aliases for code using an older version of this header. These are now
@@ -145,8 +234,4 @@
#define android_atomic_write android_atomic_release_store
#define android_atomic_cmpxchg android_atomic_release_cas
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
#endif // ANDROID_CUTILS_ATOMIC_H
diff --git a/include/cutils/trace.h b/include/cutils/trace.h
index c863afd..59ff6c1 100644
--- a/include/cutils/trace.h
+++ b/include/cutils/trace.h
@@ -25,12 +25,8 @@
#include <sys/types.h>
#include <unistd.h>
-#include <cutils/compiler.h>
-#ifdef ANDROID_SMP
-#include <cutils/atomic-inline.h>
-#else
#include <cutils/atomic.h>
-#endif
+#include <cutils/compiler.h>
__BEGIN_DECLS
diff --git a/include/log/uio.h b/include/log/uio.h
index a71f515..7059da5 100644
--- a/include/log/uio.h
+++ b/include/log/uio.h
@@ -14,20 +14,23 @@
* limitations under the License.
*/
-//
-// implementation of sys/uio.h for platforms that don't have it (Win32)
-//
#ifndef _LIBS_CUTILS_UIO_H
#define _LIBS_CUTILS_UIO_H
-#ifdef HAVE_SYS_UIO_H
+#if !defined(_WIN32)
+
#include <sys/uio.h>
+
#else
#ifdef __cplusplus
extern "C" {
#endif
+//
+// Implementation of sys/uio.h for Win32.
+//
+
#include <stddef.h>
struct iovec {
@@ -42,7 +45,7 @@
}
#endif
-#endif /* !HAVE_SYS_UIO_H */
+#endif
#endif /* _LIBS_UTILS_UIO_H */
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index 5d9c3ea..5efe2e1 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -83,6 +83,11 @@
#define AID_CACHE 2001 /* cache access */
#define AID_DIAG 2002 /* access to diagnostic resources */
+/* The range 2900-2999 is reserved for OEM, and must never be
+ * used here */
+#define AID_OEM_RESERVED_START 2900
+#define AID_OEM_RESERVED_END 2999
+
/* The 3000 series are intended for use as supplemental group id's only.
* They indicate special Android capabilities that the kernel is aware of. */
#define AID_NET_BT_ADMIN 3001 /* bluetooth: create any socket */
@@ -227,7 +232,6 @@
{ 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" },
{ 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.trout.rc" },
{ 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" },
- { 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.testmenu" },
{ 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" },
{ 00444, AID_RADIO, AID_AUDIO, 0, "system/etc/AudioPara4.csv" },
{ 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" },
diff --git a/include/utils/Compat.h b/include/utils/Compat.h
index 20a6920..0df40a1 100644
--- a/include/utils/Compat.h
+++ b/include/utils/Compat.h
@@ -44,6 +44,17 @@
#endif
/*
+ * Needed for cases where something should be constexpr if possible, but not
+ * being constexpr is fine if in pre-C++11 code (such as a const static float
+ * member variable).
+ */
+#if __cplusplus >= 201103L
+#define CONSTEXPR constexpr
+#else
+#define CONSTEXPR
+#endif
+
+/*
* TEMP_FAILURE_RETRY is defined by some, but not all, versions of
* <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's
* not already defined, then define it here.
diff --git a/include/utils/Endian.h b/include/utils/Endian.h
index 19f2504..591cae0 100644
--- a/include/utils/Endian.h
+++ b/include/utils/Endian.h
@@ -20,21 +20,16 @@
#ifndef _LIBS_UTILS_ENDIAN_H
#define _LIBS_UTILS_ENDIAN_H
-#if defined(HAVE_ENDIAN_H)
-
-#include <endian.h>
-
-#else /*not HAVE_ENDIAN_H*/
+#if defined(__APPLE__) || defined(_WIN32)
#define __BIG_ENDIAN 0x1000
#define __LITTLE_ENDIAN 0x0001
+#define __BYTE_ORDER __LITTLE_ENDIAN
-#if defined(HAVE_LITTLE_ENDIAN)
-# define __BYTE_ORDER __LITTLE_ENDIAN
#else
-# define __BYTE_ORDER __BIG_ENDIAN
-#endif
-#endif /*not HAVE_ENDIAN_H*/
+#include <endian.h>
+
+#endif
#endif /*_LIBS_UTILS_ENDIAN_H*/
diff --git a/include/utils/FileMap.h b/include/utils/FileMap.h
index dfe6d51..6c0aa52 100644
--- a/include/utils/FileMap.h
+++ b/include/utils/FileMap.h
@@ -24,7 +24,11 @@
#include <utils/Compat.h>
-#ifdef HAVE_WIN32_FILEMAP
+#if defined(__MINGW32__)
+// Ensure that we always pull in winsock2.h before windows.h
+#ifdef HAVE_WINSOCK
+#include <winsock2.h>
+#endif
#include <windows.h>
#endif
@@ -123,7 +127,7 @@
off64_t mDataOffset; // offset used when map was created
void* mDataPtr; // start of requested data, offset from base
size_t mDataLength; // length, measured from "mDataPtr"
-#ifdef HAVE_WIN32_FILEMAP
+#if defined(__MINGW32__)
HANDLE mFileHandle; // Win32 file handle
HANDLE mFileMapping; // Win32 file mapping handle
#endif
diff --git a/include/utils/Unicode.h b/include/utils/Unicode.h
index 5b98de2..aaf951b 100644
--- a/include/utils/Unicode.h
+++ b/include/utils/Unicode.h
@@ -24,8 +24,8 @@
// Definitions exist in C++11
#if defined __cplusplus && __cplusplus < 201103L
-typedef uint32_t char32_t;
-typedef uint16_t char16_t;
+typedef unsigned int char32_t;
+typedef unsigned short char16_t;
#endif
// Standard string functions on char16_t strings.
diff --git a/init/Android.mk b/init/Android.mk
index 72c2272..8cda879 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -51,25 +51,9 @@
libmincrypt \
libext4_utils_static
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+# Create symlinks
+LOCAL_POST_INSTALL_CMD := $(hide) mkdir -p $(TARGET_ROOT_OUT)/sbin; \
+ ln -sf ../init $(TARGET_ROOT_OUT)/sbin/ueventd; \
+ ln -sf ../init $(TARGET_ROOT_OUT)/sbin/watchdogd
include $(BUILD_EXECUTABLE)
-
-# Make a symlink from /sbin/ueventd and /sbin/watchdogd to /init
-SYMLINKS := \
- $(TARGET_ROOT_OUT)/sbin/ueventd \
- $(TARGET_ROOT_OUT)/sbin/watchdogd
-
-$(SYMLINKS): INIT_BINARY := $(LOCAL_MODULE)
-$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
- @echo "Symlink: $@ -> ../$(INIT_BINARY)"
- @mkdir -p $(dir $@)
- @rm -rf $@
- $(hide) ln -sf ../$(INIT_BINARY) $@
-
-ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
-
-# We need this so that the installed files could be picked up based on the
-# local module name
-ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
- $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
diff --git a/init/builtins.c b/init/builtins.c
index c192551..5d2a517 100644
--- a/init/builtins.c
+++ b/init/builtins.c
@@ -433,6 +433,7 @@
sprintf(tmp, "/dev/block/loop%d", n);
loop = open(tmp, mode);
if (loop < 0) {
+ close(fd);
return -1;
}
@@ -500,7 +501,6 @@
int ret = -1;
int child_ret = -1;
int status;
- const char *prop;
struct fstab *fstab;
if (nargs != 2) {
diff --git a/init/devices.c b/init/devices.c
index 2fa5c22..dde43df 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -191,7 +191,6 @@
static mode_t get_device_perm(const char *path, const char **links,
unsigned *uid, unsigned *gid)
{
- mode_t perm;
struct listnode *node;
struct perm_node *perm_node;
struct perms_ *dp;
@@ -458,7 +457,7 @@
/* skip "/devices/platform/<driver>" */
parent = strchr(uevent->path + pdev->path_len, '/');
- if (!*parent)
+ if (!parent)
goto err;
if (!strncmp(parent, "/usb", 4)) {
@@ -497,15 +496,10 @@
struct platform_node *pdev;
char *slash;
const char *type;
- int width;
char buf[256];
char link_path[256];
- int fd;
int link_num = 0;
- int ret;
char *p;
- unsigned int size;
- struct stat info;
pdev = find_platform_device(uevent->path);
if (pdev) {
@@ -926,7 +920,6 @@
static void handle_firmware_event(struct uevent *uevent)
{
pid_t pid;
- int ret;
if(strcmp(uevent->subsystem, "firmware"))
return;
@@ -1045,15 +1038,18 @@
fcntl(device_fd, F_SETFD, FD_CLOEXEC);
fcntl(device_fd, F_SETFL, O_NONBLOCK);
- if (stat(coldboot_done, &info) < 0) {
+ if (stat(COLDBOOT_DONE, &info) < 0) {
t0 = get_usecs();
coldboot("/sys/class");
coldboot("/sys/block");
coldboot("/sys/devices");
t1 = get_usecs();
- fd = open(coldboot_done, O_WRONLY|O_CREAT, 0000);
+ fd = open(COLDBOOT_DONE, O_WRONLY|O_CREAT, 0000);
close(fd);
log_event_print("coldboot %ld uS\n", ((long) (t1 - t0)));
+ // t0 & t1 are unused if the log isn't doing anything.
+ (void)t0;
+ (void)t1;
} else {
log_event_print("skipping coldboot, already done\n");
}
diff --git a/init/init.c b/init/init.c
index 99474e6..2b82937 100644
--- a/init/init.c
+++ b/init/init.c
@@ -76,7 +76,6 @@
static struct action *cur_action = NULL;
static struct command *cur_command = NULL;
-static struct listnode *command_queue = NULL;
void notify_service_state(const char *name, const char *state)
{
@@ -170,7 +169,6 @@
struct stat s;
pid_t pid;
int needs_console;
- int n;
char *scon = NULL;
int rc;
@@ -578,10 +576,10 @@
static int wait_for_coldboot_done_action(int nargs, char **args)
{
int ret;
- INFO("wait for %s\n", coldboot_done);
- ret = wait_for_file(coldboot_done, COMMAND_RETRY_TIMEOUT);
+ INFO("wait for %s\n", COLDBOOT_DONE);
+ ret = wait_for_file(COLDBOOT_DONE, COMMAND_RETRY_TIMEOUT);
if (ret)
- ERROR("Timed out waiting for %s\n", coldboot_done);
+ ERROR("Timed out waiting for %s\n", COLDBOOT_DONE);
return ret;
}
@@ -1003,9 +1001,6 @@
{
int fd_count = 0;
struct pollfd ufds[4];
- char *tmpdev;
- char* debuggable;
- char tmp[32];
int property_set_fd_init = 0;
int signal_fd_init = 0;
int keychord_fd_init = 0;
diff --git a/init/init_parser.c b/init/init_parser.c
index 6466db2..2b4db8e 100644
--- a/init/init_parser.c
+++ b/init/init_parser.c
@@ -187,19 +187,14 @@
int expand_props(char *dst, const char *src, int dst_size)
{
- int cnt = 0;
char *dst_ptr = dst;
const char *src_ptr = src;
- int src_len;
- int idx = 0;
int ret = 0;
int left = dst_size - 1;
if (!src || !dst || dst_size == 0)
return -1;
- src_len = strlen(src);
-
/* - variables can either be $x.y or ${x.y}, in case they are only part
* of the string.
* - will accept $$ as a literal $.
@@ -847,7 +842,6 @@
{
struct command *cmd;
struct action *act = state->context;
- int (*func)(int nargs, char **args);
int kw, n;
if (nargs == 0) {
diff --git a/init/property_service.c b/init/property_service.c
index 1902b77..1f98e13 100644
--- a/init/property_service.c
+++ b/init/property_service.c
@@ -63,7 +63,6 @@
static int init_workspace(workspace *w, size_t size)
{
- void *data;
int fd = open(PROP_FILENAME, O_RDONLY | O_NOFOLLOW);
if (fd < 0)
return -1;
@@ -142,9 +141,6 @@
*/
static int check_perms(const char *name, char *sctx)
{
- int i;
- unsigned int app_id;
-
if(!strncmp(name, "ro.", 3))
name +=3;
@@ -261,7 +257,6 @@
prop_msg msg;
int s;
int r;
- int res;
struct ucred cr;
struct sockaddr_un addr;
socklen_t addr_size = sizeof(addr);
@@ -448,10 +443,8 @@
while ((entry = readdir(dir)) != NULL) {
if (strncmp("persist.", entry->d_name, strlen("persist.")))
continue;
-#if HAVE_DIRENT_D_TYPE
if (entry->d_type != DT_REG)
continue;
-#endif
/* open the file and read the property value */
fd = openat(dir_fd, entry->d_name, O_RDONLY | O_NOFOLLOW);
if (fd < 0) {
@@ -540,6 +533,7 @@
{
load_properties_from_file(PROP_PATH_SYSTEM_BUILD, NULL);
load_properties_from_file(PROP_PATH_SYSTEM_DEFAULT, NULL);
+ load_properties_from_file(PROP_PATH_VENDOR_BUILD, NULL);
load_properties_from_file(PROP_PATH_FACTORY, "ro.*");
load_override_properties();
diff --git a/init/util.h b/init/util.h
index 04b8129..4cfe99d 100644
--- a/init/util.h
+++ b/init/util.h
@@ -22,7 +22,7 @@
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
-static const char *coldboot_done = "/dev/.coldboot_done";
+#define COLDBOOT_DONE "/dev/.coldboot_done"
int mtd_name_to_number(const char *name);
int create_socket(const char *name, int type, mode_t perm,
diff --git a/libbacktrace/Android.build.mk b/libbacktrace/Android.build.mk
index 2685380..7e1cd53 100644
--- a/libbacktrace/Android.build.mk
+++ b/libbacktrace/Android.build.mk
@@ -61,12 +61,6 @@
$($(module)_ldlibs_$(build_type)) \
ifeq ($(build_type),target)
- ifneq ($($(module)_libc++),)
- include external/libcxx/libcxx.mk
- else
- include external/stlport/libstlport.mk
- endif
-
include $(BUILD_$(build_target))
endif
diff --git a/libbacktrace/Android.mk b/libbacktrace/Android.mk
index c321369..f2f71f9 100755
--- a/libbacktrace/Android.mk
+++ b/libbacktrace/Android.mk
@@ -64,60 +64,19 @@
libbacktrace_static_libraries_host := \
libcutils \
+libbacktrace_ldlibs_host := \
+ -lpthread \
+ -lrt \
+
module := libbacktrace
module_tag := optional
build_type := target
build_target := SHARED_LIBRARY
include $(LOCAL_PATH)/Android.build.mk
build_type := host
+libbacktrace_multilib := both
include $(LOCAL_PATH)/Android.build.mk
-# Don't build for unbundled branches
-ifeq (,$(TARGET_BUILD_APPS))
-#-------------------------------------------------------------------------
-# The libbacktrace library (libc++)
-#-------------------------------------------------------------------------
-libbacktrace_libc++_src_files := \
- BacktraceImpl.cpp \
- BacktraceMap.cpp \
- BacktraceThread.cpp \
- thread_utils.c \
-
-libbacktrace_libc++_shared_libraries_target := \
- libcutils \
- libgccdemangle \
-
-libbacktrace_libc++_src_files += \
- UnwindCurrent.cpp \
- UnwindMap.cpp \
- UnwindPtrace.cpp \
-
-libbacktrace_libc++_c_includes := \
- external/libunwind/include \
-
-libbacktrace_libc++_shared_libraries := \
- libunwind \
- libunwind-ptrace \
-
-libbacktrace_libc++_shared_libraries_host := \
- liblog \
-
-libbacktrace_libc++_static_libraries_host := \
- libcutils \
-
-libbacktrace_libc++_libc++ := true
-
-module := libbacktrace_libc++
-module_tag := optional
-build_type := target
-build_target := SHARED_LIBRARY
-include $(LOCAL_PATH)/Android.build.mk
-build_type := host
-libbacktrace_libc++_multilib := both
-include $(LOCAL_PATH)/Android.build.mk
-libbacktrace_libc++_multilib :=
-endif
-
#-------------------------------------------------------------------------
# The libbacktrace_test library needed by backtrace_test.
#-------------------------------------------------------------------------
@@ -186,25 +145,8 @@
LOCAL_SRC_FILES := \
BacktraceMap.cpp \
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-# Don't build for unbundled branches
-ifeq (,$(TARGET_BUILD_APPS))
-#-------------------------------------------------------------------------
-# The libbacktrace library (libc++)
-#-------------------------------------------------------------------------
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libbacktrace_libc++
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
- BacktraceMap.cpp \
-
LOCAL_MULTILIB := both
include $(BUILD_HOST_SHARED_LIBRARY)
-endif # TARGET_BUILD_APPS
-
endif # HOST_OS-darwin
diff --git a/libbacktrace/BacktraceThread.cpp b/libbacktrace/BacktraceThread.cpp
index b47cd2a..439cc3b 100644
--- a/libbacktrace/BacktraceThread.cpp
+++ b/libbacktrace/BacktraceThread.cpp
@@ -17,14 +17,15 @@
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
-#include <linux/futex.h>
#include <pthread.h>
#include <signal.h>
+#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>
#include <ucontext.h>
+#include <unistd.h>
#include <cutils/atomic.h>
@@ -32,10 +33,6 @@
#include "BacktraceThread.h"
#include "thread_utils.h"
-static inline int futex(volatile int* uaddr, int op, int val, const struct timespec* ts, volatile int* uaddr2, int val3) {
- return syscall(__NR_futex, uaddr, op, val, ts, uaddr2, val3);
-}
-
//-------------------------------------------------------------------------
// ThreadEntry implementation.
//-------------------------------------------------------------------------
@@ -45,7 +42,14 @@
// Assumes that ThreadEntry::list_mutex_ has already been locked before
// creating a ThreadEntry object.
ThreadEntry::ThreadEntry(pid_t pid, pid_t tid)
- : pid_(pid), tid_(tid), futex_(0), ref_count_(1), mutex_(PTHREAD_MUTEX_INITIALIZER), next_(ThreadEntry::list_), prev_(NULL) {
+ : pid_(pid), tid_(tid), ref_count_(1), mutex_(PTHREAD_MUTEX_INITIALIZER),
+ wait_mutex_(PTHREAD_MUTEX_INITIALIZER), wait_value_(0),
+ next_(ThreadEntry::list_), prev_(NULL) {
+ pthread_condattr_t attr;
+ pthread_condattr_init(&attr);
+ pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+ pthread_cond_init(&wait_cond_, &attr);
+
// Add ourselves to the list.
if (ThreadEntry::list_) {
ThreadEntry::list_->prev_ = this;
@@ -99,22 +103,35 @@
next_ = NULL;
prev_ = NULL;
+
+ pthread_cond_destroy(&wait_cond_);
}
void ThreadEntry::Wait(int value) {
timespec ts;
- ts.tv_sec = 10;
- ts.tv_nsec = 0;
- errno = 0;
- futex(&futex_, FUTEX_WAIT, value, &ts, NULL, 0);
- if (errno != 0 && errno != EWOULDBLOCK) {
- BACK_LOGW("futex wait failed, futex = %d: %s", futex_, strerror(errno));
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) {
+ BACK_LOGW("clock_gettime failed: %s", strerror(errno));
+ abort();
}
+ ts.tv_sec += 10;
+
+ pthread_mutex_lock(&wait_mutex_);
+ while (wait_value_ != value) {
+ int ret = pthread_cond_timedwait(&wait_cond_, &wait_mutex_, &ts);
+ if (ret != 0) {
+ BACK_LOGW("pthread_cond_timedwait failed: %s", strerror(ret));
+ break;
+ }
+ }
+ pthread_mutex_unlock(&wait_mutex_);
}
void ThreadEntry::Wake() {
- futex_++;
- futex(&futex_, FUTEX_WAKE, INT_MAX, NULL, NULL, 0);
+ pthread_mutex_lock(&wait_mutex_);
+ wait_value_++;
+ pthread_mutex_unlock(&wait_mutex_);
+
+ pthread_cond_signal(&wait_cond_);
}
void ThreadEntry::CopyUcontextFromSigcontext(void* sigcontext) {
@@ -142,7 +159,7 @@
// Pause the thread until the unwind is complete. This avoids having
// the thread run ahead causing problems.
- entry->Wait(1);
+ entry->Wait(2);
ThreadEntry::Remove(entry);
}
@@ -194,7 +211,7 @@
}
// Wait for the thread to get the ucontext.
- entry->Wait(0);
+ entry->Wait(1);
// After the thread has received the signal, allow other unwinders to
// continue.
diff --git a/libbacktrace/BacktraceThread.h b/libbacktrace/BacktraceThread.h
index ff3e9f3..99a8638 100644
--- a/libbacktrace/BacktraceThread.h
+++ b/libbacktrace/BacktraceThread.h
@@ -48,8 +48,10 @@
inline void Lock() {
pthread_mutex_lock(&mutex_);
- // Reset the futex value in case of multiple unwinds of the same thread.
- futex_ = 0;
+
+ // Always reset the wait value since this could be the first or nth
+ // time this entry is locked.
+ wait_value_ = 0;
}
inline void Unlock() {
@@ -66,9 +68,11 @@
pid_t pid_;
pid_t tid_;
- int futex_;
int ref_count_;
pthread_mutex_t mutex_;
+ pthread_mutex_t wait_mutex_;
+ pthread_cond_t wait_cond_;
+ int wait_value_;
ThreadEntry* next_;
ThreadEntry* prev_;
ucontext_t ucontext_;
diff --git a/libbacktrace/backtrace_test.cpp b/libbacktrace/backtrace_test.cpp
index ed6b211..8002ed6 100644
--- a/libbacktrace/backtrace_test.cpp
+++ b/libbacktrace/backtrace_test.cpp
@@ -51,7 +51,7 @@
#define NS_PER_SEC 1000000000ULL
// Number of simultaneous dumping operations to perform.
-#define NUM_THREADS 20
+#define NUM_THREADS 40
// Number of simultaneous threads running in our forked process.
#define NUM_PTRACE_THREADS 5
@@ -486,6 +486,13 @@
struct sigaction new_action;
ASSERT_TRUE(sigaction(THREAD_SIGNAL, NULL, &new_action) == 0);
EXPECT_EQ(cur_action.sa_sigaction, new_action.sa_sigaction);
+ // The SA_RESTORER flag gets set behind our back, so a direct comparison
+ // doesn't work unless we mask the value off. Mips doesn't have this
+ // flag, so skip this on that platform.
+#ifdef SA_RESTORER
+ cur_action.sa_flags &= ~SA_RESTORER;
+ new_action.sa_flags &= ~SA_RESTORER;
+#endif
EXPECT_EQ(cur_action.sa_flags, new_action.sa_flags);
}
@@ -583,7 +590,7 @@
// Wait for tids to be set.
for (std::vector<thread_t>::iterator it = runners.begin(); it != runners.end(); ++it) {
- ASSERT_TRUE(WaitForNonZero(&it->state, 10));
+ ASSERT_TRUE(WaitForNonZero(&it->state, 30));
}
// Start all of the dumpers at once, they will spin until they are signalled
@@ -602,7 +609,7 @@
android_atomic_acquire_store(1, &dump_now);
for (size_t i = 0; i < NUM_THREADS; i++) {
- ASSERT_TRUE(WaitForNonZero(&dumpers[i].done, 10));
+ ASSERT_TRUE(WaitForNonZero(&dumpers[i].done, 30));
// Tell the runner thread to exit its infinite loop.
android_atomic_acquire_store(0, &runners[i].state);
@@ -625,7 +632,7 @@
ASSERT_TRUE(pthread_create(&runner.threadId, &attr, ThreadMaxRun, &runner) == 0);
// Wait for tids to be set.
- ASSERT_TRUE(WaitForNonZero(&runner.state, 10));
+ ASSERT_TRUE(WaitForNonZero(&runner.state, 30));
// Start all of the dumpers at once, they will spin until they are signalled
// to begin their dump run.
@@ -645,7 +652,7 @@
android_atomic_acquire_store(1, &dump_now);
for (size_t i = 0; i < NUM_THREADS; i++) {
- ASSERT_TRUE(WaitForNonZero(&dumpers[i].done, 100));
+ ASSERT_TRUE(WaitForNonZero(&dumpers[i].done, 30));
ASSERT_TRUE(dumpers[i].backtrace != NULL);
VerifyMaxDump(dumpers[i].backtrace);
diff --git a/libcutils/Android.mk b/libcutils/Android.mk
index 6987e9c..7202704 100644
--- a/libcutils/Android.mk
+++ b/libcutils/Android.mk
@@ -16,13 +16,6 @@
LOCAL_PATH := $(my-dir)
include $(CLEAR_VARS)
-ifeq ($(TARGET_CPU_SMP),true)
- targetSmpFlag := -DANDROID_SMP=1
-else
- targetSmpFlag := -DANDROID_SMP=0
-endif
-hostSmpFlag := -DANDROID_SMP=0
-
commonSources := \
hashmap.c \
atomic.c.arm \
@@ -77,7 +70,6 @@
LOCAL_MODULE := libcutils
LOCAL_SRC_FILES := $(commonSources) $(commonHostSources) dlmalloc_stubs.c
LOCAL_STATIC_LIBRARIES := liblog
-LOCAL_CFLAGS += $(hostSmpFlag)
ifneq ($(HOST_OS),windows)
LOCAL_CFLAGS += -Werror
endif
@@ -154,7 +146,7 @@
LOCAL_C_INCLUDES := $(libcutils_c_includes)
LOCAL_STATIC_LIBRARIES := liblog
-LOCAL_CFLAGS += $(targetSmpFlag) -Werror -std=gnu90
+LOCAL_CFLAGS += -Werror -std=gnu90
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
include $(BUILD_STATIC_LIBRARY)
@@ -164,7 +156,7 @@
# liblog symbols present in libcutils.
LOCAL_WHOLE_STATIC_LIBRARIES := libcutils liblog
LOCAL_SHARED_LIBRARIES := liblog
-LOCAL_CFLAGS += $(targetSmpFlag) -Werror
+LOCAL_CFLAGS += -Werror
LOCAL_C_INCLUDES := $(libcutils_c_includes)
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
include $(BUILD_SHARED_LIBRARY)
diff --git a/libcutils/atomic.c b/libcutils/atomic.c
index 1484ef8..d34aa00 100644
--- a/libcutils/atomic.c
+++ b/libcutils/atomic.c
@@ -14,6 +14,13 @@
* limitations under the License.
*/
+/*
+ * Generate non-inlined versions of android_atomic functions.
+ * Nobody should be using these, but some binary blobs currently (late 2014)
+ * are.
+ * If you read this in 2015 or later, please try to delete this file.
+ */
+
#define ANDROID_ATOMIC_INLINE
-#include <cutils/atomic-inline.h>
+#include <cutils/atomic.h>
diff --git a/libcutils/open_memstream.c b/libcutils/open_memstream.c
index 1c37321..9183266 100644
--- a/libcutils/open_memstream.c
+++ b/libcutils/open_memstream.c
@@ -59,8 +59,6 @@
# define DBUG(x) ((void)0)
#endif
-#ifdef HAVE_FUNOPEN
-
/*
* Definition of a seekable, write-only memory stream.
*/
@@ -251,12 +249,6 @@
return fp;
}
-#else /*not HAVE_FUNOPEN*/
-FILE* open_memstream(char** bufp, size_t* sizep)
-{
- abort();
-}
-#endif /*HAVE_FUNOPEN*/
diff --git a/libcutils/socket_local_client.c b/libcutils/socket_local_client.c
index ddcc2da..7b42daa 100644
--- a/libcutils/socket_local_client.c
+++ b/libcutils/socket_local_client.c
@@ -52,7 +52,7 @@
switch (namespaceId) {
case ANDROID_SOCKET_NAMESPACE_ABSTRACT:
-#ifdef HAVE_LINUX_LOCAL_SOCKET_NAMESPACE
+#if defined(__linux__)
namelen = strlen(name);
// Test with length +1 for the *initial* '\0'.
@@ -67,7 +67,7 @@
p_addr->sun_path[0] = 0;
memcpy(p_addr->sun_path + 1, name, namelen);
-#else /*HAVE_LINUX_LOCAL_SOCKET_NAMESPACE*/
+#else
/* this OS doesn't have the Linux abstract namespace */
namelen = strlen(name) + strlen(FILESYSTEM_SOCKET_PREFIX);
@@ -79,7 +79,7 @@
strcpy(p_addr->sun_path, FILESYSTEM_SOCKET_PREFIX);
strcat(p_addr->sun_path, name);
-#endif /*HAVE_LINUX_LOCAL_SOCKET_NAMESPACE*/
+#endif
break;
case ANDROID_SOCKET_NAMESPACE_RESERVED:
diff --git a/libcutils/socket_local_server.c b/libcutils/socket_local_server.c
index 7628fe4..60eb86b 100644
--- a/libcutils/socket_local_server.c
+++ b/libcutils/socket_local_server.c
@@ -66,7 +66,7 @@
}
/* basically: if this is a filesystem path, unlink first */
-#ifndef HAVE_LINUX_LOCAL_SOCKET_NAMESPACE
+#if !defined(__linux__)
if (1) {
#else
if (namespaceId == ANDROID_SOCKET_NAMESPACE_RESERVED
diff --git a/libcutils/socket_network_client.c b/libcutils/socket_network_client.c
index 4826033..e0031ba 100644
--- a/libcutils/socket_network_client.c
+++ b/libcutils/socket_network_client.c
@@ -45,7 +45,6 @@
{
struct hostent *hp;
struct sockaddr_in addr;
- socklen_t alen;
int s;
int flags = 0, error = 0, ret = 0;
fd_set rset, wset;
diff --git a/libcutils/tests/Android.mk b/libcutils/tests/Android.mk
index 76db5b1..5a54698 100644
--- a/libcutils/tests/Android.mk
+++ b/libcutils/tests/Android.mk
@@ -32,19 +32,21 @@
LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
include $(BUILD_NATIVE_TEST)
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-LOCAL_MODULE := libcutils_test_static
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_SRC_FILES := $(test_src_files)
-LOCAL_STATIC_LIBRARIES := \
- libc \
- libcutils \
- liblog \
- libutils \
+# The static libcutils tests cannot be built when using libc++ because there are
+# multiple symbol definition errors between libc++ and libgcc. b/18389856
+#include $(CLEAR_VARS)
+#LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+#LOCAL_MODULE := libcutils_test_static
+#LOCAL_FORCE_STATIC_EXECUTABLE := true
+#LOCAL_SRC_FILES := $(test_src_files)
+#LOCAL_STATIC_LIBRARIES := \
+# libc \
+# libcutils \
+# liblog \
+# libutils \
-LOCAL_CXX_STL := stlport_static
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-include $(BUILD_NATIVE_TEST)
+#LOCAL_CXX_STL := stlport_static
+#LOCAL_MULTILIB := both
+#LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+#LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+#include $(BUILD_NATIVE_TEST)
diff --git a/libion/ion.c b/libion/ion.c
index 80bdc2a..a79525d 100644
--- a/libion/ion.c
+++ b/libion/ion.c
@@ -117,7 +117,6 @@
int ion_share(int fd, ion_user_handle_t handle, int *share_fd)
{
- int map_fd;
int ret;
struct ion_fd_data data = {
.handle = handle,
diff --git a/libion/ion_test.c b/libion/ion_test.c
index 8872282..b7d5583 100644
--- a/libion/ion_test.c
+++ b/libion/ion_test.c
@@ -164,8 +164,9 @@
printf("master->master? [%10s]\n", ptr);
if (recvmsg(sd[0], &msg, 0) < 0)
perror("master recv 1");
+ close(fd);
+ _exit(0);
} else {
- struct msghdr msg;
struct cmsghdr *cmsg;
char* ptr;
int fd, recv_fd;
@@ -205,6 +206,7 @@
strcpy(ptr, "child");
printf("child sending msg 2\n");
sendmsg(sd[1], &child_msg, 0);
+ close(fd);
}
}
diff --git a/libion/tests/Android.mk b/libion/tests/Android.mk
index 8dc7f9d..abf527a 100644
--- a/libion/tests/Android.mk
+++ b/libion/tests/Android.mk
@@ -21,7 +21,6 @@
LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
LOCAL_CFLAGS += -g -Wall -Werror -std=gnu++11 -Wno-missing-field-initializers
LOCAL_SHARED_LIBRARIES += libion
-LOCAL_STATIC_LIBRARIES += libgtest_main
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../kernel-headers
LOCAL_SRC_FILES := \
ion_test_fixture.cpp \
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index 136792d..117e154 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -320,9 +320,9 @@
return priorityStrings[idx];
}
-#ifndef HAVE_WRITEV
+#if defined(_WIN32)
/*
- * Some platforms like WIN32 do not have writev().
+ * WIN32 does not have writev().
* Make up something to replace it.
*/
static ssize_t fake_writev(int fd, const struct iovec *iov, int iovcnt) {
@@ -352,7 +352,7 @@
static void showLog(LogState *state,
int logPrio, const char* tag, const char* msg)
{
-#if defined(HAVE_LOCALTIME_R)
+#if !defined(_WIN32)
struct tm tmBuf;
#endif
struct tm* ptm;
@@ -377,7 +377,7 @@
* in the time stamp. Don't use forward slashes, parenthesis,
* brackets, asterisks, or other special chars here.
*/
-#if defined(HAVE_LOCALTIME_R)
+#if !defined(_WIN32)
ptm = localtime_r(&when, &tmBuf);
#else
ptm = localtime(&when);
diff --git a/liblog/log_read.c b/liblog/log_read.c
index ca5a1a7..2f21a5d 100644
--- a/liblog/log_read.c
+++ b/liblog/log_read.c
@@ -72,7 +72,7 @@
switch (namespaceId) {
case ANDROID_SOCKET_NAMESPACE_ABSTRACT:
-#ifdef HAVE_LINUX_LOCAL_SOCKET_NAMESPACE
+#if defined(__linux__)
namelen = strlen(name);
/* Test with length +1 for the *initial* '\0'. */
@@ -87,7 +87,7 @@
p_addr->sun_path[0] = 0;
memcpy(p_addr->sun_path + 1, name, namelen);
-#else /*HAVE_LINUX_LOCAL_SOCKET_NAMESPACE*/
+#else
/* this OS doesn't have the Linux abstract namespace */
namelen = strlen(name) + strlen(FILESYSTEM_SOCKET_PREFIX);
@@ -99,7 +99,7 @@
strcpy(p_addr->sun_path, FILESYSTEM_SOCKET_PREFIX);
strcat(p_addr->sun_path, name);
-#endif /*HAVE_LINUX_LOCAL_SOCKET_NAMESPACE*/
+#endif
break;
case ANDROID_SOCKET_NAMESPACE_RESERVED:
diff --git a/liblog/log_time.cpp b/liblog/log_time.cpp
index 755c2d9..209a9da 100644
--- a/liblog/log_time.cpp
+++ b/liblog/log_time.cpp
@@ -39,7 +39,7 @@
#endif
struct tm *ptm;
-#if (defined(HAVE_LOCALTIME_R))
+#if !defined(_WIN32)
struct tm tmBuf;
ptm = localtime_r(&now, &tmBuf);
#else
@@ -78,7 +78,7 @@
++ret;
}
now = tv_sec;
-#if (defined(HAVE_LOCALTIME_R))
+#if !defined(_WIN32)
ptm = localtime_r(&now, &tmBuf);
#else
ptm = localtime(&now);
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 244f723..5987782 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -344,15 +344,6 @@
return -1;
}
-static inline char * strip_end(char *str)
-{
- char *end = str + strlen(str) - 1;
-
- while (end >= str && isspace(*end))
- *end-- = '\0';
- return str;
-}
-
/**
* Splits a wire-format buffer into an AndroidLogEntry
* entry allocated by caller. Pointers will point directly into buf
@@ -726,7 +717,7 @@
const AndroidLogEntry *entry,
size_t *p_outLength)
{
-#if defined(HAVE_LOCALTIME_R)
+#if !defined(_WIN32)
struct tm tmBuf;
#endif
struct tm* ptm;
@@ -749,7 +740,7 @@
* in the time stamp. Don't use forward slashes, parenthesis,
* brackets, asterisks, or other special chars here.
*/
-#if defined(HAVE_LOCALTIME_R)
+#if !defined(_WIN32)
ptm = localtime_r(&(entry->tv_sec), &tmBuf);
#else
ptm = localtime(&(entry->tv_sec));
diff --git a/liblog/tests/Android.mk b/liblog/tests/Android.mk
index b1426d3..172b186 100644
--- a/liblog/tests/Android.mk
+++ b/liblog/tests/Android.mk
@@ -44,7 +44,6 @@
LOCAL_SHARED_LIBRARIES += liblog libm
LOCAL_SRC_FILES := $(benchmark_src_files)
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
-include external/stlport/libstlport.mk
include $(BUILD_EXECUTABLE)
# -----------------------------------------------------------------------------
diff --git a/liblog/tests/benchmark_main.cpp b/liblog/tests/benchmark_main.cpp
index 090394c..e5ef970 100644
--- a/liblog/tests/benchmark_main.cpp
+++ b/liblog/tests/benchmark_main.cpp
@@ -17,6 +17,7 @@
#include <benchmark.h>
#include <inttypes.h>
+#include <math.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/liblog/uio.c b/liblog/uio.c
index 24a6507..f77cc49 100644
--- a/liblog/uio.c
+++ b/liblog/uio.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#ifndef HAVE_SYS_UIO_H
+#if defined(_WIN32)
#include <log/uio.h>
#include <unistd.h>
@@ -73,4 +73,4 @@
return total;
}
-#endif /* !HAVE_SYS_UIO_H */
+#endif
diff --git a/libnetutils/dhcp_utils.c b/libnetutils/dhcp_utils.c
index e1df874..0f7c384 100644
--- a/libnetutils/dhcp_utils.c
+++ b/libnetutils/dhcp_utils.c
@@ -166,14 +166,6 @@
return 0;
}
-static const char *ipaddr_to_string(in_addr_t addr)
-{
- struct in_addr in_addr;
-
- in_addr.s_addr = addr;
- return inet_ntoa(in_addr);
-}
-
/*
* Start the dhcp client daemon, and wait for it to finish
* configuring the interface.
@@ -242,7 +234,6 @@
return -1;
}
if (strcmp(prop_value, "ok") == 0) {
- char dns_prop_name[PROPERTY_KEY_MAX];
if (fill_ip_info(interface, ipaddr, gateway, prefixLength, dns,
server, lease, vendorInfo, domain, mtu) == -1) {
return -1;
diff --git a/libnetutils/dhcpclient.c b/libnetutils/dhcpclient.c
index b58120e..700b02f 100644
--- a/libnetutils/dhcpclient.c
+++ b/libnetutils/dhcpclient.c
@@ -150,7 +150,7 @@
void dump_dhcp_info(dhcp_info *info)
{
- char addr[20], gway[20], mask[20];
+ char addr[20], gway[20];
ALOGD("--- dhcp %s (%d) ---",
dhcp_type_to_name(info->type), info->type);
strcpy(addr, ipaddr(info->ipaddr));
diff --git a/libnetutils/ifc_utils.c b/libnetutils/ifc_utils.c
index 913f51e..bfe7121 100644
--- a/libnetutils/ifc_utils.c
+++ b/libnetutils/ifc_utils.c
@@ -421,7 +421,6 @@
int ifc_set_hwaddr(const char *name, const void *ptr)
{
- int r;
struct ifreq ifr;
ifc_init_ifr(name, &ifr);
diff --git a/libnetutils/packet.c b/libnetutils/packet.c
index 3cdefb0..a878dd3 100644
--- a/libnetutils/packet.c
+++ b/libnetutils/packet.c
@@ -41,7 +41,7 @@
int open_raw_socket(const char *ifname __attribute__((unused)), uint8_t *hwaddr, int if_index)
{
- int s, flag;
+ int s;
struct sockaddr_ll bindaddr;
if((s = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) {
diff --git a/libpixelflinger/Android.mk b/libpixelflinger/Android.mk
index da9829d..f1bd522 100644
--- a/libpixelflinger/Android.mk
+++ b/libpixelflinger/Android.mk
@@ -36,6 +36,7 @@
ifeq ($(ARCH_ARM_HAVE_NEON),true)
PIXELFLINGER_SRC_FILES_arm += col32cb16blend_neon.S
+PIXELFLINGER_CFLAGS_arm += -D__ARM_HAVE_NEON
endif
PIXELFLINGER_SRC_FILES_arm64 := \
diff --git a/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp b/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp
index fd96f7e..5f58797 100644
--- a/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp
+++ b/libpixelflinger/tests/arch-arm64/assembler/arm64_assembler_test.cpp
@@ -493,16 +493,17 @@
if(i == Rd) continue;
if(regs[i] != savedRegs[i])
{
- printf("Test %x failed Reg(%d) tampered Expected(0x%"PRIx64"),"
- "Actual(0x%"PRIx64") t\n", test.id, i, savedRegs[i], regs[i]);
+ printf("Test %x failed Reg(%d) tampered Expected(0x%" PRIx64 "),"
+ "Actual(0x%" PRIx64 ") t\n", test.id, i, savedRegs[i],
+ regs[i]);
return;
}
}
if(test.checkRd == 1 && (uint64_t)regs[Rd] != test.postRdValue)
{
- printf("Test %x failed, Expected(%"PRIx64"), Actual(%"PRIx64")\n",
- test.id, test.postRdValue, regs[Rd]);
+ printf("Test %x failed, Expected(%" PRIx64 "), Actual(%" PRIx64 ")\n",
+ test.id, test.postRdValue, regs[Rd]);
}
else if(test.checkFlag == 1 && flags[test.postFlag] == 0)
{
@@ -610,7 +611,7 @@
if(regs[i] != savedRegs[i])
{
printf("Test %x failed Reg(%d) tampered"
- " Expected(0x%"PRIx64"), Actual(0x%"PRIx64") t\n",
+ " Expected(0x%" PRIx64 "), Actual(0x%" PRIx64 ") t\n",
test.id, i, savedRegs[i], regs[i]);
return;
}
@@ -619,13 +620,13 @@
if((uint64_t)regs[Rd] != test.postRdValue)
{
printf("Test %x failed, "
- "Expected in Rd(0x%"PRIx64"), Actual(0x%"PRIx64")\n",
+ "Expected in Rd(0x%" PRIx64 "), Actual(0x%" PRIx64 ")\n",
test.id, test.postRdValue, regs[Rd]);
}
else if((uint64_t)regs[Rn] != (uint64_t)(&dataMem[test.postRnValue]))
{
printf("Test %x failed, "
- "Expected in Rn(0x%"PRIx64"), Actual(0x%"PRIx64")\n",
+ "Expected in Rn(0x%" PRIx64 "), Actual(0x%" PRIx64 ")\n",
test.id, test.postRnValue, regs[Rn] - (uint64_t)dataMem);
}
else if(test.checkMem == true)
@@ -638,7 +639,7 @@
if(value != test.postMemValue)
{
printf("Test %x failed, "
- "Expected in Mem(0x%"PRIx64"), Actual(0x%"PRIx64")\n",
+ "Expected in Mem(0x%" PRIx64 "), Actual(0x%" PRIx64 ")\n",
test.id, test.postMemValue, value);
}
else
@@ -697,8 +698,8 @@
if(regs[j] != j)
{
printf("LDM/STM Test %x failed "
- "Reg%d expected(0x%x) Actual(0x%"PRIx64") \n",
- patterns[i],j,j,regs[j]);
+ "Reg%d expected(0x%x) Actual(0x%" PRIx64 ") \n",
+ patterns[i], j, j, regs[j]);
break;
}
}
diff --git a/libprocessgroup/processgroup.cpp b/libprocessgroup/processgroup.cpp
index 49f5903..4b09f24 100644
--- a/libprocessgroup/processgroup.cpp
+++ b/libprocessgroup/processgroup.cpp
@@ -20,6 +20,7 @@
#include <assert.h>
#include <dirent.h>
#include <fcntl.h>
+#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -100,7 +101,7 @@
ctx->buf_len += ret;
ctx->buf[ctx->buf_len] = 0;
- SLOGV("Read %d to buffer: %s", ret, ctx->buf);
+ SLOGV("Read %zd to buffer: %s", ret, ctx->buf);
assert(ctx->buf_len <= sizeof(ctx->buf));
@@ -251,7 +252,7 @@
{
int processes;
int sleep_us = 100;
- long startTime = android::uptimeMillis();
+ int64_t startTime = android::uptimeMillis();
while ((processes = killProcessGroupOnce(uid, initialPid, signal)) > 0) {
SLOGV("killed %d processes for processgroup %d\n", processes, initialPid);
@@ -265,7 +266,7 @@
}
}
- SLOGV("Killed process group uid %d pid %d in %ldms, %d procs remain", uid, initialPid,
+ SLOGV("Killed process group uid %d pid %d in %" PRId64 "ms, %d procs remain", uid, initialPid,
android::uptimeMillis()-startTime, processes);
if (processes == 0) {
@@ -279,12 +280,12 @@
{
int ret;
- ret = mkdir(path, 0750);
+ ret = mkdir(path, mode);
if (ret < 0 && errno != EEXIST) {
return -errno;
}
- ret = chown(path, AID_SYSTEM, AID_SYSTEM);
+ ret = chown(path, uid, gid);
if (ret < 0) {
ret = -errno;
rmdir(path);
diff --git a/libsuspend/autosuspend_autosleep.c b/libsuspend/autosuspend_autosleep.c
index 5451615..0d31e74 100644
--- a/libsuspend/autosuspend_autosleep.c
+++ b/libsuspend/autosuspend_autosleep.c
@@ -84,7 +84,6 @@
struct autosuspend_ops *autosuspend_autosleep_init(void)
{
- int ret;
char buf[80];
autosleep_fd = open(SYS_POWER_AUTOSLEEP, O_WRONLY);
diff --git a/libsysutils/src/SocketClient.cpp b/libsysutils/src/SocketClient.cpp
index d3ce8f5..8358823 100644
--- a/libsysutils/src/SocketClient.cpp
+++ b/libsysutils/src/SocketClient.cpp
@@ -220,7 +220,9 @@
sigaction(SIGPIPE, &old_action, &new_action);
- errno = e;
+ if (e != 0) {
+ errno = e;
+ }
return ret;
}
diff --git a/libutils/Android.mk b/libutils/Android.mk
index 0376c8c..e738c15 100644
--- a/libutils/Android.mk
+++ b/libutils/Android.mk
@@ -104,8 +104,6 @@
liblog \
libdl
-include external/stlport/libstlport.mk
-
LOCAL_MODULE:= libutils
include $(BUILD_STATIC_LIBRARY)
@@ -121,8 +119,6 @@
liblog
LOCAL_CFLAGS := -Werror
-include external/stlport/libstlport.mk
-
include $(BUILD_SHARED_LIBRARY)
# Include subdirectory makefiles
diff --git a/libutils/FileMap.cpp b/libutils/FileMap.cpp
index f8d6bda..f49b4f9 100644
--- a/libutils/FileMap.cpp
+++ b/libutils/FileMap.cpp
@@ -23,7 +23,7 @@
#include <utils/FileMap.h>
#include <utils/Log.h>
-#if defined(HAVE_WIN32_FILEMAP) && !defined(__USE_MINGW_ANSI_STDIO)
+#if defined(__MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO)
# define PRId32 "I32d"
# define PRIx32 "I32x"
# define PRId64 "I64d"
@@ -33,7 +33,7 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef HAVE_POSIX_FILEMAP
+#if !defined(__MINGW32__)
#include <sys/mman.h>
#endif
@@ -64,12 +64,7 @@
if (mFileName != NULL) {
free(mFileName);
}
-#ifdef HAVE_POSIX_FILEMAP
- if (mBasePtr && munmap(mBasePtr, mBaseLength) != 0) {
- ALOGD("munmap(%p, %zu) failed\n", mBasePtr, mBaseLength);
- }
-#endif
-#ifdef HAVE_WIN32_FILEMAP
+#if defined(__MINGW32__)
if (mBasePtr && UnmapViewOfFile(mBasePtr) == 0) {
ALOGD("UnmapViewOfFile(%p) failed, error = %" PRId32 "\n", mBasePtr,
GetLastError() );
@@ -77,6 +72,10 @@
if (mFileMapping != INVALID_HANDLE_VALUE) {
CloseHandle(mFileMapping);
}
+#else
+ if (mBasePtr && munmap(mBasePtr, mBaseLength) != 0) {
+ ALOGD("munmap(%p, %zu) failed\n", mBasePtr, mBaseLength);
+ }
#endif
}
@@ -90,7 +89,7 @@
bool FileMap::create(const char* origFileName, int fd, off64_t offset, size_t length,
bool readOnly)
{
-#ifdef HAVE_WIN32_FILEMAP
+#if defined(__MINGW32__)
int adjust;
off64_t adjOffset;
size_t adjLength;
@@ -128,8 +127,7 @@
mFileMapping = INVALID_HANDLE_VALUE;
return false;
}
-#endif
-#ifdef HAVE_POSIX_FILEMAP
+#else // !defined(__MINGW32__)
int prot, flags, adjust;
off64_t adjOffset;
size_t adjLength;
@@ -179,7 +177,7 @@
return false;
}
mBasePtr = ptr;
-#endif // HAVE_POSIX_FILEMAP
+#endif // !defined(__MINGW32__)
mFileName = origFileName != NULL ? strdup(origFileName) : NULL;
mBaseLength = adjLength;
@@ -196,9 +194,9 @@
}
// Provide guidance to the system.
+#if !defined(_WIN32)
int FileMap::advise(MapAdvice advice)
{
-#if HAVE_MADVISE
int cc, sysAdvice;
switch (advice) {
@@ -216,7 +214,11 @@
if (cc != 0)
ALOGW("madvise(%d) failed: %s\n", sysAdvice, strerror(errno));
return cc;
-#else
- return -1;
-#endif // HAVE_MADVISE
}
+
+#else
+int FileMap::advise(MapAdvice /* advice */)
+{
+ return -1;
+}
+#endif
diff --git a/libutils/String8.cpp b/libutils/String8.cpp
index 9092cbc..3323b82 100644
--- a/libutils/String8.cpp
+++ b/libutils/String8.cpp
@@ -424,7 +424,7 @@
next = len;
}
- memcpy(buf + tail, buf + index + skip, next - index - skip);
+ memmove(buf + tail, buf + index + skip, next - index - skip);
tail += next - index - skip;
index = next;
}
diff --git a/libutils/Unicode.cpp b/libutils/Unicode.cpp
index 378d2a7..fb876c9 100644
--- a/libutils/Unicode.cpp
+++ b/libutils/Unicode.cpp
@@ -24,17 +24,10 @@
# undef nhtos
# undef htons
-# ifdef HAVE_LITTLE_ENDIAN
-# define ntohl(x) ( ((x) << 24) | (((x) >> 24) & 255) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) )
-# define htonl(x) ntohl(x)
-# define ntohs(x) ( (((x) << 8) & 0xff00) | (((x) >> 8) & 255) )
-# define htons(x) ntohs(x)
-# else
-# define ntohl(x) (x)
-# define htonl(x) (x)
-# define ntohs(x) (x)
-# define htons(x) (x)
-# endif
+# define ntohl(x) ( ((x) << 24) | (((x) >> 24) & 255) | (((x) << 8) & 0xff0000) | (((x) >> 8) & 0xff00) )
+# define htonl(x) ntohl(x)
+# define ntohs(x) ( (((x) << 8) & 0xff00) | (((x) >> 8) & 255) )
+# define htons(x) ntohs(x)
#else
# include <netinet/in.h>
#endif
@@ -47,8 +40,9 @@
// Surrogates aren't valid for UTF-32 characters, so define some
// constants that will let us screen them out.
static const char32_t kUnicodeSurrogateHighStart = 0x0000D800;
-static const char32_t kUnicodeSurrogateHighEnd = 0x0000DBFF;
-static const char32_t kUnicodeSurrogateLowStart = 0x0000DC00;
+// Unused, here for completeness:
+// static const char32_t kUnicodeSurrogateHighEnd = 0x0000DBFF;
+// static const char32_t kUnicodeSurrogateLowStart = 0x0000DC00;
static const char32_t kUnicodeSurrogateLowEnd = 0x0000DFFF;
static const char32_t kUnicodeSurrogateStart = kUnicodeSurrogateHighStart;
static const char32_t kUnicodeSurrogateEnd = kUnicodeSurrogateLowEnd;
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index d5d4700..92150c3 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -193,7 +193,6 @@
#undef DISALLOW_IMPLICIT_CONSTRUCTORS
static const uint32_t kGPBDDFlagMask = 0x0008; // mask value that signifies that the entry has a DD
-static const uint32_t kMaxErrorLen = 1024;
// The maximum size of a central directory or a file
// comment in bytes.
@@ -744,7 +743,7 @@
// as a side effect of this call.
static inline ssize_t ReadAtOffset(int fd, uint8_t* buf, size_t len,
off64_t off) {
-#ifdef HAVE_PREAD
+#if !defined(_WIN32)
return TEMP_FAILURE_RETRY(pread64(fd, buf, len, off));
#else
// The only supported platform that doesn't support pread at the moment
@@ -756,7 +755,7 @@
}
return TEMP_FAILURE_RETRY(read(fd, buf, len));
-#endif // HAVE_PREAD
+#endif
}
static int32_t FindEntry(const ZipArchive* archive, const int ent,
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c
index a534a24..7bbc811 100644
--- a/lmkd/lmkd.c
+++ b/lmkd/lmkd.c
@@ -607,7 +607,6 @@
static int find_and_kill_process(int other_free, int other_file, bool first)
{
int i;
- int r;
int min_score_adj = OOM_ADJUST_MAX + 1;
int minfree = 0;
int killed_size = 0;
@@ -643,7 +642,6 @@
}
static void mp_event(uint32_t events __unused) {
- int i;
int ret;
unsigned long long evcount;
struct sysmeminfo mi;
diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp
index b1412ff..b358485 100644
--- a/logcat/tests/logcat_test.cpp
+++ b/logcat/tests/logcat_test.cpp
@@ -548,7 +548,6 @@
static const char rotated_log_filename_prefix[] = "log.txt.";
static const size_t rotated_log_filename_prefix_len =
strlen(rotated_log_filename_prefix);
- static const char total[] = "total ";
static const char log_filename[] = "log.txt";
if (!strncmp(buffer, rotated_log_filename_prefix, rotated_log_filename_prefix_len)) {
diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp
index 51feff3..ee2f32d 100644
--- a/logd/LogAudit.cpp
+++ b/logd/LogAudit.cpp
@@ -248,7 +248,7 @@
if (fd < 0) {
return fd;
}
- if (audit_set_pid(fd, getpid(), WAIT_YES) < 0) {
+ if (audit_setup(fd, getpid()) < 0) {
audit_close(fd);
fd = -1;
}
diff --git a/logd/libaudit.c b/logd/libaudit.c
index ca88d1b..d00d579 100644
--- a/logd/libaudit.c
+++ b/logd/libaudit.c
@@ -162,7 +162,7 @@
return rc;
}
-int audit_set_pid(int fd, uint32_t pid, rep_wait_t wmode)
+int audit_setup(int fd, uint32_t pid)
{
int rc;
struct audit_message rep;
@@ -176,7 +176,8 @@
* and the the mask set to AUDIT_STATUS_PID
*/
status.pid = pid;
- status.mask = AUDIT_STATUS_PID;
+ status.mask = AUDIT_STATUS_PID | AUDIT_STATUS_RATE_LIMIT;
+ status.rate_limit = 20; // audit entries per second
/* Let the kernel know this pid will be registering for audit events */
rc = audit_send(fd, AUDIT_SET, &status, sizeof(status));
@@ -188,24 +189,21 @@
/*
* In a request where we need to wait for a response, wait for the message
* and discard it. This message confirms and sync's us with the kernel.
- * This daemon is now registered as the audit logger. Only wait if the
- * wmode is != WAIT_NO
+ * This daemon is now registered as the audit logger.
+ *
+ * TODO
+ * If the daemon dies and restarts the message didn't come back,
+ * so I went to non-blocking and it seemed to fix the bug.
+ * Need to investigate further.
*/
- if (wmode != WAIT_NO) {
- /* TODO
- * If the daemon dies and restarts the message didn't come back,
- * so I went to non-blocking and it seemed to fix the bug.
- * Need to investigate further.
- */
- audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0);
- }
+ audit_get_reply(fd, &rep, GET_REPLY_NONBLOCKING, 0);
return 0;
}
int audit_open()
{
- return socket(PF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
+ return socket(PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_AUDIT);
}
int audit_get_reply(int fd, struct audit_message *rep, reply_t block, int peek)
diff --git a/logd/libaudit.h b/logd/libaudit.h
index cb114f9..b9e330d 100644
--- a/logd/libaudit.h
+++ b/logd/libaudit.h
@@ -37,11 +37,6 @@
GET_REPLY_NONBLOCKING
} reply_t;
-typedef enum {
- WAIT_NO,
- WAIT_YES
-} rep_wait_t;
-
/* type == AUDIT_SIGNAL_INFO */
struct audit_sig_info {
uid_t uid;
@@ -92,12 +87,10 @@
* The fd returned by a call to audit_open()
* @param pid
* The pid whom to set as the reciever of audit messages
- * @param wmode
- * Whether or not to block on the underlying socket io calls.
* @return
* This function returns 0 on success, -errno on error.
*/
-extern int audit_set_pid(int fd, uint32_t pid, rep_wait_t wmode);
+extern int audit_setup(int fd, uint32_t pid);
__END_DECLS
diff --git a/rootdir/etc/init.testmenu b/rootdir/etc/init.testmenu
deleted file mode 100755
index 7ae16d5..0000000
--- a/rootdir/etc/init.testmenu
+++ /dev/null
@@ -1,322 +0,0 @@
-#!/system/bin/sh
-
-atdev=/dev/omap_csmi_tty0
-pppdev=/dev/omap_csmi_tty1
-
-n1=`cat /data/phoneentry1 2>/dev/null`
-n2=`cat /data/phoneentry2 2>/dev/null`
-n3=`cat /data/phoneentry3 2>/dev/null`
-n1=${n1:-"*#06#"}
-n2=${n2:-"*#06#"}
-n3=${n3:-"*#06#"}
-phoneoutputpid=
-eventoutputpid=
-notifypid=
-notifytoggle=false
-pppdpid=
-powerdidletime=120
-
-# map phone specific keys
-setkey -k 0xe4 -v 0x23 # map #
-setkey -k 0xe3 -v 0x2a # map *
-setkey -k 231 -v 513 # map send to newline
-#setkey -k 0x67 -v 0x20b # map up to scroll back
-#setkey -k 0x6c -v 0x20a # map down to scroll forward
-setkey -k 0x73 -v 0x20b # map volume up to scroll back
-setkey -k 0x72 -v 0x20a # map volume down to scroll forward
-setkey -k 0x60 -v 0x211 # map PoC to next console
-
-# tuttle keys
-setkey -k 0x38 -v 0x703 # map leftalt to alt
-setkey -k 0x9b -v 0x703 # map mail to alt
-setkey -t 8 -k 0x9b -v 0x703 # map alt-mail to alt
-setkey -t 8 -k 0x10 -v 0x21 # map alt-q to !
-setkey -t 8 -k 0x11 -v 0x31 # map alt-w to 1
-setkey -t 8 -k 0x12 -v 0x32 # map alt-e to 2
-setkey -t 8 -k 0x13 -v 0x33 # map alt-r to 3
-setkey -t 8 -k 0x14 -v 0x2b # map alt-t to +
-setkey -t 8 -k 0x15 -v 0x28 # map alt-y to (
-setkey -t 8 -k 0x16 -v 0x29 # map alt-u to )
-setkey -t 8 -k 0x17 -v 0x2d # map alt-i to -
-setkey -t 8 -k 0x18 -v 0x5f # map alt-o to _
-setkey -t 8 -k 0x19 -v 0x22 # map alt-p to "
-setkey -t 8 -k 0x1e -v 0x23 # map alt-a to #
-setkey -t 8 -k 0x1f -v 0x34 # map alt-s to 4
-setkey -t 8 -k 0x20 -v 0x35 # map alt-d to 5
-setkey -t 8 -k 0x21 -v 0x36 # map alt-f to 6
-setkey -t 8 -k 0x22 -v 0x2f # map alt-g to /
-setkey -t 8 -k 0x23 -v 0x3f # map alt-h to ?
-setkey -t 8 -k 0x24 -v 0xa3 # map alt-j to pound
-setkey -t 8 -k 0x25 -v 0x24 # map alt-k to $
-setkey -t 8 -k 0x2c -v 0x2a # map alt-z to *
-setkey -t 8 -k 0x2d -v 0x37 # map alt-x to 7
-setkey -t 8 -k 0x2e -v 0x38 # map alt-c to 8
-setkey -t 8 -k 0x2f -v 0x39 # map alt-v to 9
-setkey -t 8 -k 0x30 -v 0x7c # map alt-b to |
-setkey -t 8 -k 0x31 -v 0x40 # map alt-n to @
-setkey -t 8 -k 0x32 -v 0x3d # map alt-m to =
-setkey -t 8 -k 0x33 -v 0x3b # map alt-, to ;
-setkey -t 8 -k 0x34 -v 0x3a # map alt-. to :
-setkey -t 8 -k 0x0f -v 0x30 # map alt-tab to 0
-setkey -t 8 -k 0x67 -v 0x20b # map alt-up to scroll back
-setkey -t 8 -k 0x6c -v 0x20a # map alt-down to scroll forward
-
-while true
-do
- echo
- echo "------------------------------"
- echo " 1: init commands"
- echo " 2: call commands"
- echo " 3: misc phone"
- echo " 4: phone debug output"
- echo " 5: test data connection"
- echo " 6: start runtime"
- echo " 7: start runtime w/output"
- echo " 8: stop runtime"
- echo " 9: misc"
- echo -n ": "
- while true
- do
- c=`readtty -t 50 -f -a 1234567890#`
- case "$c" in
- "" ) ;;
- * ) break;
- esac
- done
- echo Got key -$c-
- case $c in
- "1" )
- while true; do
- echo
- echo "------------------------------"
- echo " 1: Print phone output"
- echo " 2: ATQ0V1E1+CMEE=2;+CREG=0"
- echo " 3: AT+CFUN=1"
- echo " 4: AT+COPS=0"
- echo " 5: AT+CREG?"
- echo " 6: Stop phone output"
- echo " 0: back"
- echo -n ": "
- c=`readtty -f -a 1234560#`
- echo Got key -$c-
- case "$c" in
- "1" ) kill $phoneoutputpid; cat $atdev & phoneoutputpid=$! ;;
- "2" ) echo -e "ATQ0V1E1+CMEE=2;+CREG=0\r" >$atdev;;
- "3" ) echo -e "AT+CFUN=1\r" >$atdev;;
- "4" ) echo -e "AT+COPS=0\r" >$atdev;;
- "5" ) echo -e "AT+CREG?\r" >$atdev;;
- "6" ) kill $phoneoutputpid; phoneoutputpid= ;;
- "0" ) break;;
- esac
- done
- ;;
- "2" )
- while true; do
- echo
- echo "------------------------------"
- echo " 1: Dial: ATD $n1;"
- echo " 2: Dial: ATD $n2;"
- echo " 3: Dial: ATD $n3;"
- echo " 4: Set number for 1"
- echo " 5: Set number for 2"
- echo " 6: Set number for 3"
- echo " 7: Dial: ATD ...;"
- echo " 8: Hang up: ATH"
- echo " 9: Answer: ATA"
- echo " 0: back"
- echo -n ": "
- c=`readtty -f -a 1234567890#`
- echo Got key -$c-
- case "$c" in
- "1" ) echo "Dialing $n1"; echo -e "ATD $n1;\r" >$atdev;;
- "2" ) echo "Dialing $n2"; echo -e "ATD $n2;\r" >$atdev;;
- "3" ) echo "Dialing $n3"; echo -e "ATD $n3;\r" >$atdev;;
- "4" ) echo -n "Number: "; read n1; echo $n1 >/data/phoneentry1;;
- "5" ) echo -n "Number: "; read n2; echo $n2 >/data/phoneentry2;;
- "6" ) echo -n "Number: "; read n3; echo $n3 >/data/phoneentry3;;
- "7" ) echo -n "Number: "; read n; echo "Dialing $n"; echo -e "ATD $n;\r" >$atdev;;
- "8" ) echo -e "ATH\r" >$atdev;;
- "9" ) echo -e "ATA\r" >$atdev;;
- "0" ) break;;
- esac
- done
- ;;
- "3" )
- while true; do
- echo
- echo "------------------------------"
- echo " 1: Save FFS data"
- echo " 2: Load user FFS data"
- echo " 3: Load system FFS data"
- echo " 4: Reset FFS data"
- echo " 5: Set uplink gain"
- echo " 6: Set echo"
- echo " 7: cat /dev/omap_csmi_battery_t"
- echo " 8: cat /dev/omap_csmi_htc"
- echo " 0: back"
- echo -n ": "
- c=`readtty -f -a 123456780#`
- echo Got key -$c-
- case "$c" in
- "1" ) cat /dev/omap_csmi_ffs >/data/ffsdata;;
- "2" ) cat /data/ffsdata >/dev/omap_csmi_ffs;;
- "3" ) cat /system/ffsdata >/dev/omap_csmi_ffs;;
- "4" ) echo - >/dev/omap_csmi_ffs;;
- "5" )
- echo -n "Gain: "; read g;
- echo gu$g >/tmp/gain;
- cat /tmp/gain 2>/dev/null >/dev/omap_csmi_audio_tes
- ;;
- "6" )
- echo -n "Echo param (hex): "; read e;
- echo "e0x$e" >/tmp/echo;
- cat /tmp/echo 2>/dev/null >/dev/omap_csmi_audio_tes
- ;;
- "7" ) cat /dev/omap_csmi_battery_t;;
- "8" ) cat /dev/omap_csmi_htc;;
- "0" ) break;;
- esac
- done
- ;;
- "4" )
- while true; do
- echo
- echo "------------------------------"
- echo " 1: Toggle debug I/O"
- echo " 2: Toggle debug Flow"
- echo " 3: Toggle debug Interrupt"
- echo " 4: Toggle debug Info"
- echo " 5: Toggle GSM run state"
- echo " 6: Clear GSM data area"
- echo " 0: back"
- echo -n ": "
- c=`readtty -f -a 1234560#`
- echo Got key -$c-
- case "$c" in
- "1" ) echo -n "i" >/sys/devices/system/omap_csmi/debug;;
- "2" ) echo -n "f" >/sys/devices/system/omap_csmi/debug;;
- "3" ) echo -n "I" >/sys/devices/system/omap_csmi/debug;;
- "4" ) echo -n "F" >/sys/devices/system/omap_csmi/debug;;
- "5" ) echo -n "s" >/sys/devices/system/omap_csmi/debug;;
- "6" ) echo -n "c" >/sys/devices/system/omap_csmi/debug;;
- "0" ) break;;
- esac
- done
- ;;
- "5" )
- while true; do
- echo
- echo "------------------------------"
- echo " 1: Start pppd - userspace"
- echo " 2: Start pppd - kernel"
- echo " 3: Start pppd - kernel <at1"
- echo " 4: Configure ppp data to at2"
- echo " 5: Test with HTTP GET"
- echo " 6: Kill pppd"
- echo " 0: back"
- echo -n ": "
- c=`readtty -f -a 1234560#`
- echo Got key -$c-
- case "$c" in
- "1" ) kill $pppdpid; pppd notty < $pppdev > $pppdev & pppdpid=$!;;
- "2" ) kill $pppdpid; pppd nodetach $pppdev & pppdpid=$!;;
- "3" ) kill &pppdpid; pppd nodetach $pppdev connect "sh -c \"chat -v -f /etc/ppp/connect-data <$atdev >$atdev\"" & pppdpid=$!;;
- "4" ) echo -e 'AT%DATA=2,"UART",1,,"SER","UART",0\r' >$atdev;;
- "5" ) test-data-connection;;
- "6" ) kill $pppdpid; pppdpid=;;
- "0" ) break;;
- esac
- done
- ;;
- "6" )
- echo
- echo ------------------------
- echo Starting android runtime
- echo ------------------------
- start
- ;;
- "7" )
- echo
- echo ------------------------
- echo Starting android runtime
- echo ------------------------
- if exists /data/singleproc
- then
- single_process="-s"
- else
- single_process=""
- fi
- start runtime $single_process
- ;;
- "8" )
- stop
- ;;
- "9" )
- while true; do
- echo
- echo "------------------------------"
- echo " 1: Print events"
- echo " 2: Stop event output"
- if $notifytoggle
- then
- echo " 3: stop notify"
- else
- echo " 3: notify /sys/android_power"
- fi
- echo " 4: start powerd"
- echo " 5: start powerd verbose"
- echo " 6: stop powerd"
- echo " 7: set powerd idletime ($powerdidletime)"
- echo " 8: start multitap shell"
- if exists /data/singleproc
- then
- echo " 9: enable multiprocess"
- else
- echo " 9: disable multiprocess"
- fi
- echo " c: start shell"
- echo " 0: back"
- echo -n ": "
- c=`readtty -f -a 1234567890c#`
- echo Got key -$c-
- case "$c" in
- "1" ) kill $eventoutputpid; getevent & eventoutputpid=$! ;;
- "2" ) kill $eventoutputpid; eventoutputpid= ;;
- "3" )
- if $notifytoggle
- then
- kill $notifypid
- notifypid=
- notifytoggle=false
- else
- kill $notifypid
- notify -m 0x00000002 -c 0 -p -v 0 -w 30 /sys/android_power &
- notifypid=$!
- notifytoggle=true
- fi
- ;;
- "4" ) start powerd -i $powerdidletime ;;
- "5" ) start powerd -i $powerdidletime -v ;;
- "6" ) stop powerd ;;
- "7" ) echo -n "Idle time (seconds): "; read powerdidletime ;;
- "8" )
- readtty -f -p -t 10 -e "[ ~" | sh -i
- ;;
- "9" )
- if exists /data/singleproc
- then
- echo "Enabling multiprocess environment."
- rm /data/singleproc
- else
- echo "Disabling multiprocess environment."
- echo >/data/singleproc "true"
- fi
- ;;
- "c" ) sh -i <>/dev/tty0 1>&0 2>&1 ;;
- "0" ) break;;
- esac
- done
- ;;
- esac
-done
-
diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c
index b53b581..2318978 100644
--- a/sdcard/sdcard.c
+++ b/sdcard/sdcard.c
@@ -391,12 +391,12 @@
attr->ino = node->nid;
attr->size = s->st_size;
attr->blocks = s->st_blocks;
- attr->atime = s->st_atime;
- attr->mtime = s->st_mtime;
- attr->ctime = s->st_ctime;
- attr->atimensec = s->st_atime_nsec;
- attr->mtimensec = s->st_mtime_nsec;
- attr->ctimensec = s->st_ctime_nsec;
+ attr->atime = s->st_atim.tv_sec;
+ attr->mtime = s->st_mtim.tv_sec;
+ attr->ctime = s->st_ctim.tv_sec;
+ attr->atimensec = s->st_atim.tv_nsec;
+ attr->mtimensec = s->st_mtim.tv_nsec;
+ attr->ctimensec = s->st_ctim.tv_nsec;
attr->mode = s->st_mode;
attr->nlink = s->st_nlink;
@@ -1269,6 +1269,7 @@
return -errno;
}
out.size = res;
+ out.padding = 0;
fuse_reply(fuse, hdr->unique, &out, sizeof(out));
return NO_STATUS;
}
@@ -1833,7 +1834,7 @@
"fd=%i,rootmode=40000,default_permissions,allow_other,user_id=%d,group_id=%d",
fd, uid, gid);
- res = mount("/dev/fuse", dest_path, "fuse", MS_NOSUID | MS_NODEV, opts);
+ res = mount("/dev/fuse", dest_path, "fuse", MS_NOSUID | MS_NODEV | MS_NOEXEC, opts);
if (res < 0) {
ERROR("cannot mount fuse filesystem: %s\n", strerror(errno));
goto error;
diff --git a/toolbox/Android.mk b/toolbox/Android.mk
index 3304e2a..6fdf610 100644
--- a/toolbox/Android.mk
+++ b/toolbox/Android.mk
@@ -52,13 +52,6 @@
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := upstream-freebsd/usr.bin/false/false.c
-LOCAL_CFLAGS += $(common_cflags) -Dmain=false_main
-LOCAL_MODULE := libtoolbox_false
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
upstream-netbsd/usr.bin/grep/fastgrep.c \
upstream-netbsd/usr.bin/grep/file.c \
@@ -92,13 +85,6 @@
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
-LOCAL_SRC_FILES := upstream-netbsd/usr.bin/printenv/printenv.c
-LOCAL_CFLAGS += $(common_cflags) -Dmain=printenv_main
-LOCAL_MODULE := libtoolbox_printenv
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
LOCAL_SRC_FILES := upstream-netbsd/bin/rm/rm.c
LOCAL_CFLAGS += $(common_cflags) -Dmain=rm_main
LOCAL_MODULE := libtoolbox_rm
@@ -112,27 +98,6 @@
LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
include $(BUILD_STATIC_LIBRARY)
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := upstream-netbsd/bin/sleep/sleep.c
-LOCAL_CFLAGS += $(common_cflags) -Dmain=sleep_main
-LOCAL_MODULE := libtoolbox_sleep
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := upstream-netbsd/bin/sync/sync.c
-LOCAL_CFLAGS += $(common_cflags) -Dmain=sync_main
-LOCAL_MODULE := libtoolbox_sync
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := upstream-freebsd/usr.bin/true/true.c
-LOCAL_CFLAGS += $(common_cflags) -Dmain=true_main
-LOCAL_MODULE := libtoolbox_true
-LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
-include $(BUILD_STATIC_LIBRARY)
-
include $(CLEAR_VARS)
@@ -142,26 +107,19 @@
cp \
dd \
du \
- false \
grep \
kill \
ln \
mv \
- printenv \
rm \
rmdir \
- sleep \
- sync \
- true \
OUR_TOOLS := \
chcon \
chmod \
- clear \
cmp \
date \
df \
- dmesg \
getenforce \
getevent \
getprop \
@@ -170,29 +128,23 @@
id \
ifconfig \
iftop \
- insmod \
ioctl \
ionice \
load_policy \
log \
ls \
- lsmod \
lsof \
md5 \
mkdir \
mknod \
- mkswap \
mount \
nandread \
netstat \
newfs_msdos \
- nohup \
notify \
ps \
- readlink \
renice \
restorecon \
- rmmod \
route \
runcon \
schedtop \
@@ -203,8 +155,6 @@
smd \
start \
stop \
- swapoff \
- swapon \
top \
touch \
umount \
@@ -235,16 +185,14 @@
libcutils \
libselinux \
-# libusbhost is only used by lsusb, and that isn't usually included in toolbox.
-# The linker strips out all the unused library code in the normal case.
-LOCAL_STATIC_LIBRARIES := \
- libusbhost \
-
LOCAL_WHOLE_STATIC_LIBRARIES := $(patsubst %,libtoolbox_%,$(BSD_TOOLS))
LOCAL_MODULE := toolbox
LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.mk
+# Install the symlinks.
+LOCAL_POST_INSTALL_CMD := $(hide) $(foreach t,$(ALL_TOOLS),ln -sf toolbox $(TARGET_OUT)/bin/$(t);)
+
# Including this will define $(intermediates).
#
include $(BUILD_EXECUTABLE)
@@ -258,22 +206,6 @@
$(TOOLS_H):
$(transform-generated-source)
-# Make symbolic link launchers for each tool.
-SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS))
-$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE)
-$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk
- @echo "Symlink: $@ -> $(TOOLBOX_BINARY)"
- @mkdir -p $(dir $@)
- @rm -rf $@
- $(hide) ln -sf $(TOOLBOX_BINARY) $@
-
-ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
-
-# We need this so that the installed files could be picked up based on the
-# local module name
-ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
- $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
-
# We only want 'r' on userdebug and eng builds.
include $(CLEAR_VARS)
diff --git a/toolbox/alarm.c b/toolbox/alarm.c
deleted file mode 100644
index 9bd58aa..0000000
--- a/toolbox/alarm.c
+++ /dev/null
@@ -1,190 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string.h>
-#include <errno.h>
-#include <time.h>
-#include <asm/ioctl.h>
-//#include <linux/rtc.h>
-#include <linux/android_alarm.h>
-
-int alarm_main(int argc, char *argv[])
-{
- int c;
- int res;
- struct tm tm;
- time_t t;
- struct timespec ts;
-// struct rtc_time rtc_time;
- char strbuf[26];
- int afd;
- int nfd;
-// struct timeval timeout = { 0, 0 };
- int wait = 0;
- fd_set rfds;
- const char wake_lock_id[] = "alarm_test";
- int waitalarmmask = 0;
-
- int useutc = 0;
- android_alarm_type_t alarmtype_low = ANDROID_ALARM_RTC_WAKEUP;
- android_alarm_type_t alarmtype_high = ANDROID_ALARM_RTC_WAKEUP;
- android_alarm_type_t alarmtype = 0;
-
- do {
- //c = getopt(argc, argv, "uw:");
- c = getopt(argc, argv, "uwat:");
- if (c == EOF)
- break;
- switch (c) {
- case 'u':
- useutc = 1;
- break;
- case 't':
- alarmtype_low = alarmtype_high = strtol(optarg, NULL, 0);
- break;
- case 'a':
- alarmtype_low = ANDROID_ALARM_RTC_WAKEUP;
- alarmtype_high = ANDROID_ALARM_TYPE_COUNT - 1;
- break;
- case 'w':
- //timeout.tv_sec = strtol(optarg, NULL, 0);
- wait = 1;
- break;
- case '?':
- fprintf(stderr, "%s: invalid option -%c\n",
- argv[0], optopt);
- exit(1);
- }
- } while (1);
- if(optind + 2 < argc) {
- fprintf(stderr,"%s [-uwa] [-t type] [seconds]\n", argv[0]);
- return 1;
- }
-
- afd = open("/dev/alarm", O_RDWR);
- if(afd < 0) {
- fprintf(stderr, "Unable to open rtc: %s\n", strerror(errno));
- return 1;
- }
-
- if(optind == argc) {
- for(alarmtype = alarmtype_low; alarmtype <= alarmtype_high; alarmtype++) {
- waitalarmmask |= 1U << alarmtype;
- }
-#if 0
- res = ioctl(fd, RTC_ALM_READ, &tm);
- if(res < 0) {
- fprintf(stderr, "Unable to read alarm: %s\n", strerror(errno));
- return 1;
- }
-#endif
-#if 0
- t = timegm(&tm);
- if(useutc)
- gmtime_r(&t, &tm);
- else
- localtime_r(&t, &tm);
-#endif
-#if 0
- asctime_r(&tm, strbuf);
- printf("%s", strbuf);
-#endif
- }
- else if(optind + 1 == argc) {
-#if 0
- res = ioctl(fd, RTC_RD_TIME, &tm);
- if(res < 0) {
- fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno));
- return 1;
- }
- asctime_r(&tm, strbuf);
- printf("Now: %s", strbuf);
- time(&tv.tv_sec);
-#endif
-#if 0
- time(&ts.tv_sec);
- ts.tv_nsec = 0;
-
- //strptime(argv[optind], NULL, &tm);
- //tv.tv_sec = mktime(&tm);
- //tv.tv_usec = 0;
-#endif
- for(alarmtype = alarmtype_low; alarmtype <= alarmtype_high; alarmtype++) {
- waitalarmmask |= 1U << alarmtype;
- res = ioctl(afd, ANDROID_ALARM_GET_TIME(alarmtype), &ts);
- if(res < 0) {
- fprintf(stderr, "Unable to get current time: %s\n", strerror(errno));
- return 1;
- }
- ts.tv_sec += strtol(argv[optind], NULL, 0);
- //strtotimeval(argv[optind], &tv);
- gmtime_r(&ts.tv_sec, &tm);
- printf("time %s -> %ld.%09ld\n", argv[optind], ts.tv_sec, ts.tv_nsec);
- asctime_r(&tm, strbuf);
- printf("Requested %s", strbuf);
-
- res = ioctl(afd, ANDROID_ALARM_SET(alarmtype), &ts);
- if(res < 0) {
- fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno));
- return 1;
- }
- }
-#if 0
- res = ioctl(fd, RTC_ALM_SET, &tm);
- if(res < 0) {
- fprintf(stderr, "Unable to set alarm: %s\n", strerror(errno));
- return 1;
- }
- res = ioctl(fd, RTC_AIE_ON);
- if(res < 0) {
- fprintf(stderr, "Unable to enable alarm: %s\n", strerror(errno));
- return 1;
- }
-#endif
- }
- else {
- fprintf(stderr,"%s [-u] [date]\n", argv[0]);
- return 1;
- }
-
- if(wait) {
- while(waitalarmmask) {
- printf("wait for alarm %x\n", waitalarmmask);
- res = ioctl(afd, ANDROID_ALARM_WAIT);
- if(res < 0) {
- fprintf(stderr, "alarm wait failed\n");
- }
- printf("got alarm %x\n", res);
- waitalarmmask &= ~res;
- nfd = open("/sys/android_power/acquire_full_wake_lock", O_RDWR);
- write(nfd, wake_lock_id, sizeof(wake_lock_id) - 1);
- close(nfd);
- //sleep(5);
- nfd = open("/sys/android_power/release_wake_lock", O_RDWR);
- write(nfd, wake_lock_id, sizeof(wake_lock_id) - 1);
- close(nfd);
- }
- printf("done\n");
- }
-#if 0
- FD_ZERO(&rfds);
- FD_SET(fd, &rfds);
- res = select(fd + 1, &rfds, NULL, NULL, &timeout);
- if(res < 0) {
- fprintf(stderr, "select failed: %s\n", strerror(errno));
- return 1;
- }
- if(res > 0) {
- int event;
- read(fd, &event, sizeof(event));
- fprintf(stderr, "got %x\n", event);
- }
- else {
- fprintf(stderr, "timeout waiting for alarm\n");
- }
-#endif
-
- close(afd);
-
- return 0;
-}
diff --git a/toolbox/clear.c b/toolbox/clear.c
deleted file mode 100644
index df46ad2..0000000
--- a/toolbox/clear.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- * * Neither the name of Google, Inc. 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 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 <stdio.h>
-
-int clear_main(int argc, char **argv) {
- /* This prints the clear screen and move cursor to top-left corner control
- * characters for VT100 terminals. This means it will not work on
- * non-VT100 compliant terminals, namely Windows' cmd.exe, but should
- * work on anything unix-y. */
- fputs("\x1b[2J\x1b[H", stdout);
- return 0;
-}
diff --git a/toolbox/dmesg.c b/toolbox/dmesg.c
deleted file mode 100644
index 9c73b00..0000000
--- a/toolbox/dmesg.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <errno.h>
-#include <sys/klog.h>
-#include <string.h>
-
-#define FALLBACK_KLOG_BUF_SHIFT 17 /* CONFIG_LOG_BUF_SHIFT from our kernel */
-#define FALLBACK_KLOG_BUF_LEN (1 << FALLBACK_KLOG_BUF_SHIFT)
-
-int dmesg_main(int argc, char **argv)
-{
- char *buffer;
- char *p;
- ssize_t ret;
- int n, op, klog_buf_len;
-
- klog_buf_len = klogctl(KLOG_SIZE_BUFFER, 0, 0);
-
- if (klog_buf_len <= 0) {
- klog_buf_len = FALLBACK_KLOG_BUF_LEN;
- }
-
- buffer = (char *)malloc(klog_buf_len + 1);
-
- if (!buffer) {
- perror("malloc");
- return EXIT_FAILURE;
- }
-
- p = buffer;
-
- if((argc == 2) && (!strcmp(argv[1],"-c"))) {
- op = KLOG_READ_CLEAR;
- } else {
- op = KLOG_READ_ALL;
- }
-
- n = klogctl(op, buffer, klog_buf_len);
- if (n < 0) {
- perror("klogctl");
- return EXIT_FAILURE;
- }
- buffer[n] = '\0';
-
- while((ret = write(STDOUT_FILENO, p, n))) {
- if (ret == -1) {
- if (errno == EINTR)
- continue;
- perror("write");
- return EXIT_FAILURE;
- }
- p += ret;
- n -= ret;
- }
-
- return 0;
-}
diff --git a/toolbox/exists.c b/toolbox/exists.c
deleted file mode 100644
index e348668..0000000
--- a/toolbox/exists.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-int exists_main(int argc, char *argv[])
-{
- struct stat s;
-
- if(argc < 2) return 1;
-
- if(stat(argv[1], &s)) {
- return 1;
- } else {
- return 0;
- }
-}
diff --git a/toolbox/insmod.c b/toolbox/insmod.c
deleted file mode 100644
index d252433..0000000
--- a/toolbox/insmod.c
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <malloc.h>
-#include <errno.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-extern int init_module(void *, unsigned long, const char *);
-
-static void *read_file(const char *filename, ssize_t *_size)
-{
- int ret, fd;
- struct stat sb;
- ssize_t size;
- void *buffer = NULL;
-
- /* open the file */
- fd = open(filename, O_RDONLY);
- if (fd < 0)
- return NULL;
-
- /* find out how big it is */
- if (fstat(fd, &sb) < 0)
- goto bail;
- size = sb.st_size;
-
- /* allocate memory for it to be read into */
- buffer = malloc(size);
- if (!buffer)
- goto bail;
-
- /* slurp it into our buffer */
- ret = read(fd, buffer, size);
- if (ret != size)
- goto bail;
-
- /* let the caller know how big it is */
- *_size = size;
-
-bail:
- close(fd);
- return buffer;
-}
-
-int insmod_main(int argc, char **argv)
-{
- void *file;
- ssize_t size = 0;
- char opts[1024];
- int ret;
-
- /* make sure we've got an argument */
- if (argc < 2) {
- fprintf(stderr, "usage: insmod <module.o>\n");
- return -1;
- }
-
- /* read the file into memory */
- file = read_file(argv[1], &size);
- if (!file) {
- fprintf(stderr, "insmod: can't open '%s'\n", argv[1]);
- return -1;
- }
-
- opts[0] = '\0';
- if (argc > 2) {
- int i, len;
- char *end = opts + sizeof(opts) - 1;
- char *ptr = opts;
-
- for (i = 2; (i < argc) && (ptr < end); i++) {
- len = MIN(strlen(argv[i]), (size_t)(end - ptr));
- memcpy(ptr, argv[i], len);
- ptr += len;
- *ptr++ = ' ';
- }
- *(ptr - 1) = '\0';
- }
-
- /* pass it to the kernel */
- ret = init_module(file, size, opts);
- if (ret != 0) {
- fprintf(stderr,
- "insmod: init_module '%s' failed (%s)\n",
- argv[1], strerror(errno));
- }
-
- /* free the file buffer */
- free(file);
-
- return ret;
-}
-
diff --git a/toolbox/lsmod.c b/toolbox/lsmod.c
deleted file mode 100644
index 8b55ee6..0000000
--- a/toolbox/lsmod.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <stdio.h>
-
-extern int cat_main(int argc, char **argv);
-
-int lsmod_main(int argc, char **argv)
-{
- char *cat_argv[] = { "cat", "/proc/modules", NULL };
- return cat_main(2, cat_argv);
-}
-
diff --git a/toolbox/lsusb.c b/toolbox/lsusb.c
deleted file mode 100644
index 236e74b..0000000
--- a/toolbox/lsusb.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * 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.
- */
-
-#include <endian.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-
-#include <usbhost/usbhost.h>
-
-static int verbose = 0;
-static char str_buff[4096];
-
-static const char *get_str(struct usb_device *dev, int id)
-{
- char *str = usb_device_get_string(dev, id);
-
- if (id && str) {
- strlcpy(str_buff, str, sizeof(str_buff));
- free(str);
- } else {
- snprintf(str_buff, sizeof(str_buff), "%02x", id);
- }
-
- return str_buff;
-}
-
-
-static void lsusb_parse_device_descriptor(struct usb_device *dev,
- struct usb_device_descriptor *desc)
-{
- printf(" Device Descriptor\n");
- printf("\tbcdUSB: %04x\n", letoh16(desc->bcdUSB));
- printf("\tbDeviceClass: %02x\n", desc->bDeviceClass);
- printf("\tbDeviceSubClass: %02x\n", desc->bDeviceSubClass);
- printf("\tbDeviceProtocol: %02x\n", desc->bDeviceProtocol);
- printf("\tbMaxPacketSize0: %02x\n", desc->bMaxPacketSize0);
- printf("\tidVendor: %04x\n", letoh16(desc->idVendor));
- printf("\tidProduct: %04x\n", letoh16(desc->idProduct));
- printf("\tbcdDevice: %04x\n", letoh16(desc->bcdDevice));
- printf("\tiManufacturer: %s\n", get_str(dev, desc->iManufacturer));
- printf("\tiProduct: %s\n", get_str(dev, desc->iProduct));
- printf("\tiSerialNumber: %s\n", get_str(dev,desc->iSerialNumber));
- printf("\tbNumConfiguration: %02x\n", desc->bNumConfigurations);
- printf("\n");
-}
-
-static void lsusb_parse_config_descriptor(struct usb_device *dev,
- struct usb_config_descriptor *desc)
-{
- printf(" Config Descriptor\n");
- printf("\twTotalLength: %04x\n", letoh16(desc->wTotalLength));
- printf("\tbNumInterfaces: %02x\n", desc->bNumInterfaces);
- printf("\tbConfigurationValue: %02x\n", desc->bConfigurationValue);
- printf("\tiConfiguration: %s\n", get_str(dev, desc->iConfiguration));
- printf("\tbmAttributes: %02x\n", desc->bmAttributes);
- printf("\tbMaxPower: %d mA\n", desc->bMaxPower * 2);
- printf("\n");
-}
-
-static void lsusb_parse_interface_descriptor(struct usb_device *dev,
- struct usb_interface_descriptor *desc)
-{
- printf(" Interface Descriptor\n");
- printf("\tbInterfaceNumber: %02x\n", desc->bInterfaceNumber);
- printf("\tbAlternateSetting: %02x\n", desc->bAlternateSetting);
- printf("\tbNumEndpoints: %02x\n", desc->bNumEndpoints);
- printf("\tbInterfaceClass: %02x\n", desc->bInterfaceClass);
- printf("\tbInterfaceSubClass: %02x\n", desc->bInterfaceSubClass);
- printf("\tbInterfaceProtocol: %02x\n", desc->bInterfaceProtocol);
- printf("\tiInterface: %s\n", get_str(dev, desc->iInterface));
- printf("\n");
-}
-
-static void lsusb_parse_endpoint_descriptor(struct usb_device *dev,
- struct usb_endpoint_descriptor *desc)
-{
- printf(" Endpoint Descriptor\n");
- printf("\tbEndpointAddress: %02x\n", desc->bEndpointAddress);
- printf("\tbmAttributes: %02x\n", desc->bmAttributes);
- printf("\twMaxPacketSize: %02x\n", letoh16(desc->wMaxPacketSize));
- printf("\tbInterval: %02x\n", desc->bInterval);
- printf("\tbRefresh: %02x\n", desc->bRefresh);
- printf("\tbSynchAddress: %02x\n", desc->bSynchAddress);
- printf("\n");
-}
-
-static void lsusb_dump_descriptor(struct usb_device *dev,
- struct usb_descriptor_header *desc)
-{
- int i;
- printf(" Descriptor type %02x\n", desc->bDescriptorType);
-
- for (i = 0; i < desc->bLength; i++ ) {
- if ((i % 16) == 0)
- printf("\t%02x:", i);
- printf(" %02x", ((uint8_t *)desc)[i]);
- if ((i % 16) == 15)
- printf("\n");
- }
-
- if ((i % 16) != 0)
- printf("\n");
- printf("\n");
-}
-
-static void lsusb_parse_descriptor(struct usb_device *dev,
- struct usb_descriptor_header *desc)
-{
- switch (desc->bDescriptorType) {
- case USB_DT_DEVICE:
- lsusb_parse_device_descriptor(dev, (struct usb_device_descriptor *) desc);
- break;
-
- case USB_DT_CONFIG:
- lsusb_parse_config_descriptor(dev, (struct usb_config_descriptor *) desc);
- break;
-
- case USB_DT_INTERFACE:
- lsusb_parse_interface_descriptor(dev, (struct usb_interface_descriptor *) desc);
- break;
-
- case USB_DT_ENDPOINT:
- lsusb_parse_endpoint_descriptor(dev, (struct usb_endpoint_descriptor *) desc);
- break;
-
- default:
- lsusb_dump_descriptor(dev, desc);
-
- break;
- }
-}
-
-static int lsusb_device_added(const char *dev_name, void *client_data)
-{
- struct usb_device *dev = usb_device_open(dev_name);
-
- if (!dev) {
- fprintf(stderr, "can't open device %s: %s\n", dev_name, strerror(errno));
- return 0;
- }
-
- if (verbose) {
- struct usb_descriptor_iter iter;
- struct usb_descriptor_header *desc;
-
- printf("%s:\n", dev_name);
-
- usb_descriptor_iter_init(dev, &iter);
-
- while ((desc = usb_descriptor_iter_next(&iter)) != NULL)
- lsusb_parse_descriptor(dev, desc);
-
- } else {
- uint16_t vid, pid;
- char *mfg_name, *product_name, *serial;
-
- vid = usb_device_get_vendor_id(dev);
- pid = usb_device_get_product_id(dev);
- mfg_name = usb_device_get_manufacturer_name(dev);
- product_name = usb_device_get_product_name(dev);
- serial = usb_device_get_serial(dev);
-
- printf("%s: %04x:%04x %s %s %s\n", dev_name, vid, pid,
- mfg_name, product_name, serial);
-
- free(mfg_name);
- free(product_name);
- free(serial);
- }
-
- usb_device_close(dev);
-
- return 0;
-}
-
-static int lsusb_device_removed(const char *dev_name, void *client_data)
-{
- return 0;
-}
-
-
-static int lsusb_discovery_done(void *client_data)
-{
- return 1;
-}
-
-
-
-int lsusb_main(int argc, char **argv)
-{
- struct usb_host_context *ctx;
-
- if (argc == 2 && !strcmp(argv[1], "-v"))
- verbose = 1;
-
- ctx = usb_host_init();
- if (!ctx) {
- perror("usb_host_init:");
- return 1;
- }
-
- usb_host_run(ctx,
- lsusb_device_added,
- lsusb_device_removed,
- lsusb_discovery_done,
- NULL);
-
- usb_host_cleanup(ctx);
-
- return 0;
-}
-
diff --git a/toolbox/mkswap.c b/toolbox/mkswap.c
deleted file mode 100644
index 0904152..0000000
--- a/toolbox/mkswap.c
+++ /dev/null
@@ -1,93 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/swap.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-/* XXX This needs to be obtained from kernel headers. See b/9336527 */
-struct linux_swap_header {
- char bootbits[1024]; /* Space for disklabel etc. */
- uint32_t version;
- uint32_t last_page;
- uint32_t nr_badpages;
- unsigned char sws_uuid[16];
- unsigned char sws_volume[16];
- uint32_t padding[117];
- uint32_t badpages[1];
-};
-
-#define MAGIC_SWAP_HEADER "SWAPSPACE2"
-#define MAGIC_SWAP_HEADER_LEN 10
-#define MIN_PAGES 10
-
-int mkswap_main(int argc, char **argv)
-{
- int err = 0;
- int fd;
- ssize_t len;
- off_t swap_size;
- int pagesize;
- struct linux_swap_header sw_hdr;
-
- if (argc != 2) {
- fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
- return -EINVAL;
- }
-
- fd = open(argv[1], O_WRONLY);
- if (fd < 0) {
- err = errno;
- fprintf(stderr, "Cannot open %s\n", argv[1]);
- return err;
- }
-
- pagesize = getpagesize();
- /* Determine the length of the swap file */
- swap_size = lseek(fd, 0, SEEK_END);
- if (swap_size < MIN_PAGES * pagesize) {
- fprintf(stderr, "Swap file needs to be at least %dkB\n",
- (MIN_PAGES * pagesize) >> 10);
- err = -ENOSPC;
- goto err;
- }
- if (lseek(fd, 0, SEEK_SET)) {
- err = errno;
- fprintf(stderr, "Can't seek to the beginning of the file\n");
- goto err;
- }
-
- memset(&sw_hdr, 0, sizeof(sw_hdr));
- sw_hdr.version = 1;
- sw_hdr.last_page = (swap_size / pagesize) - 1;
-
- len = write(fd, &sw_hdr, sizeof(sw_hdr));
- if (len != sizeof(sw_hdr)) {
- err = errno;
- fprintf(stderr, "Failed to write swap header into %s\n", argv[1]);
- goto err;
- }
-
- /* Write the magic header */
- if (lseek(fd, pagesize - MAGIC_SWAP_HEADER_LEN, SEEK_SET) < 0) {
- err = errno;
- fprintf(stderr, "Failed to seek into %s\n", argv[1]);
- goto err;
- }
-
- len = write(fd, MAGIC_SWAP_HEADER, MAGIC_SWAP_HEADER_LEN);
- if (len != MAGIC_SWAP_HEADER_LEN) {
- err = errno;
- fprintf(stderr, "Failed to write magic swap header into %s\n", argv[1]);
- goto err;
- }
-
- if (fsync(fd) < 0) {
- err = errno;
- fprintf(stderr, "Failed to sync %s\n", argv[1]);
- goto err;
- }
-err:
- close(fd);
- return err;
-}
diff --git a/toolbox/nohup.c b/toolbox/nohup.c
deleted file mode 100644
index 363999d..0000000
--- a/toolbox/nohup.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-int nohup_main(int argc, char *argv[])
-{
- if (argc < 2) {
- fprintf(stderr, "Usage: %s [-n] program args...\n", argv[0]);
- return EXIT_FAILURE;
- }
- signal(SIGHUP, SIG_IGN);
- argv++;
- if (strcmp(argv[0], "-n") == 0) {
- argv++;
- signal(SIGINT, SIG_IGN);
- signal(SIGSTOP, SIG_IGN);
- signal(SIGTTIN, SIG_IGN);
- signal(SIGTTOU, SIG_IGN);
- signal(SIGQUIT, SIG_IGN);
- signal(SIGTERM, SIG_IGN);
- }
- execvp(argv[0], argv);
- perror(argv[0]);
- return EXIT_FAILURE;
-}
diff --git a/toolbox/notify.c b/toolbox/notify.c
index c983ed5..8ce346c 100644
--- a/toolbox/notify.c
+++ b/toolbox/notify.c
@@ -101,14 +101,17 @@
else if(verbose >= 1)
printf("%d: %08x \"%s\"\n", event->wd, event->mask, event->len ? event->name : "");
if(print_files && (event->mask & IN_MODIFY)) {
- char filename[512];
+ char* filename = file_names[event->wd + id_offset];
+ char* alloc_buf = NULL;
ssize_t read_len;
char *display_name;
int buflen;
- strcpy(filename, file_names[event->wd + id_offset]);
if(event->len) {
- strcat(filename, "/");
- strcat(filename, event->name);
+ if(asprintf(&alloc_buf, "%s/%s", filename, event->name) < 0) {
+ fprintf(stderr, "asprintf failed, %s\n", strerror(errno));
+ return 1;
+ }
+ filename = alloc_buf;
}
ffd = open(filename, O_RDONLY);
display_name = (verbose >= 2 || event->len == 0) ? filename : event->name;
@@ -132,6 +135,7 @@
printf("%s: %s", display_name, buf);
}
close(ffd);
+ free(alloc_buf);
}
if(event_count && --event_count == 0)
return 0;
diff --git a/toolbox/readlink.c b/toolbox/readlink.c
deleted file mode 100644
index d114e20..0000000
--- a/toolbox/readlink.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- * * Neither the name of Google, Inc. 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 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 <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static int skip_newline, quiet_errors, canonicalize;
-
-static void usage(char* name) {
- fprintf(stderr, "Usage: %s [OPTION]... FILE\n", name);
-}
-
-int readlink_main(int argc, char* argv[]) {
- int c;
- while ((c = getopt(argc, argv, "nfqs")) != -1) {
- switch (c) {
- case 'n':
- skip_newline = 1;
- break;
- case 'f':
- canonicalize = 1;
- break;
- case 'q':
- case 's':
- quiet_errors = 1;
- break;
- case '?':
- default:
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- }
- int index = optind;
- if (argc - index != 1) {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- char name[PATH_MAX+1];
- if (canonicalize) {
- if(!realpath(argv[optind], name)) {
- if (!quiet_errors) {
- perror("readlink");
- }
- return EXIT_FAILURE;
- }
- } else {
- ssize_t len = readlink(argv[1], name, PATH_MAX);
-
- if (len < 0) {
- if (!quiet_errors) {
- perror("readlink");
- }
- return EXIT_FAILURE;
- }
- name[len] = '\0';
- }
-
- fputs(name, stdout);
- if (!skip_newline) {
- fputs("\n", stdout);
- }
-
- return EXIT_SUCCESS;
-}
diff --git a/toolbox/readtty.c b/toolbox/readtty.c
deleted file mode 100644
index 2b27548..0000000
--- a/toolbox/readtty.c
+++ /dev/null
@@ -1,183 +0,0 @@
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-struct {
- char key;
- char *chars;
-} map[] = {
- { '1', "_ -1?!,.:;\"'<=>()_" },
- { '2', "Cabc2ABC" },
- { '3', "Fdef3DEF" },
- { '4', "Ighi4GHI" },
- { '5', "Ljkl5JKL" },
- { '6', "Omno6MNO" },
- { '7', "Spqrs7PQRS" },
- { '8', "Vtuv8TUV" },
- { '9', "Zwxyz9WXYZ" },
- { '0', "*+&0@/#*" },
-};
-
-char next_char(char key, char current)
-{
- int i;
- char *next;
- for(i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
- if(key == map[i].key) {
- next = strchr(map[i].chars, current);
- if(next && next[1])
- return next[1];
- return map[i].chars[1];
- }
- }
- return key;
-}
-
-char prev_char(char key, char current)
-{
- int i;
- char *next;
- for(i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
- if(key == map[i].key) {
- next = strchr(map[i].chars+1, current);
- if(next && next[-1])
- return next[-1];
- return map[i].chars[1];
- }
- }
- return key;
-}
-
-int readtty_main(int argc, char *argv[])
-{
- int c;
- //int flags;
- char buf[1];
- int res;
- struct termios ttyarg;
- struct termios savedttyarg;
- int nonblock = 0;
- int timeout = 0;
- int flush = 0;
- int phone = 0;
- char *accept = NULL;
- char *rejectstring = NULL;
- char last_char_in = 0;
- char current_char = 0;
- char *exit_string = NULL;
- int exit_match = 0;
-
- do {
- c = getopt(argc, argv, "nt:fa:r:pe:");
- if (c == EOF)
- break;
- switch (c) {
- case 't':
- timeout = atoi(optarg);
- break;
- case 'n':
- nonblock = 1;
- break;
- case 'f':
- flush = 1;
- break;
- case 'a':
- accept = optarg;
- break;
- case 'r':
- rejectstring = optarg;
- break;
- case 'p':
- phone = 1;
- break;
- case 'e':
- exit_string = optarg;
- break;
- case '?':
- fprintf(stderr, "%s: invalid option -%c\n",
- argv[0], optopt);
- exit(1);
- }
- } while (1);
-
- if(flush)
- tcflush(STDIN_FILENO, TCIFLUSH);
- ioctl(STDIN_FILENO, TCGETS , &savedttyarg) ; /* set changed tty arguments */
- ttyarg = savedttyarg;
- ttyarg.c_cc[VMIN] = (timeout > 0 || nonblock) ? 0 : 1; /* minimum of 0 chars */
- ttyarg.c_cc[VTIME] = timeout; /* wait max 15/10 sec */
- ttyarg.c_iflag = BRKINT | ICRNL;
- ttyarg.c_lflag &= ~(ECHO | ICANON);
- ioctl(STDIN_FILENO, TCSETS , &ttyarg);
-
- while (1) {
- res = read(STDIN_FILENO, buf, 1);
- if(res <= 0) {
- if(phone) {
- if(current_char) {
- write(STDERR_FILENO, ¤t_char, 1);
- write(STDOUT_FILENO, ¤t_char, 1);
- if(exit_string && current_char == exit_string[exit_match]) {
- exit_match++;
- if(exit_string[exit_match] == '\0')
- break;
- }
- else
- exit_match = 0;
- current_char = 0;
- }
- continue;
- }
- break;
- }
- if(accept && strchr(accept, buf[0]) == NULL) {
- if(rejectstring) {
- write(STDOUT_FILENO, rejectstring, strlen(rejectstring));
- break;
- }
- if(flush)
- tcflush(STDIN_FILENO, TCIFLUSH);
- continue;
- }
- if(phone) {
- //if(!isprint(buf[0])) {
- // fprintf(stderr, "got unprintable character 0x%x\n", buf[0]);
- //}
- if(buf[0] == '\0') {
- if(current_char) {
- current_char = prev_char(last_char_in, current_char);
- write(STDERR_FILENO, ¤t_char, 1);
- write(STDERR_FILENO, "\b", 1);
- }
- continue;
- }
- if(current_char && buf[0] != last_char_in) {
- write(STDERR_FILENO, ¤t_char, 1);
- write(STDOUT_FILENO, ¤t_char, 1);
- if(exit_string && current_char == exit_string[exit_match]) {
- exit_match++;
- if(exit_string[exit_match] == '\0')
- break;
- }
- else
- exit_match = 0;
- current_char = 0;
- }
- last_char_in = buf[0];
- current_char = next_char(last_char_in, current_char);
- write(STDERR_FILENO, ¤t_char, 1);
- write(STDERR_FILENO, "\b", 1);
- continue;
- }
- write(STDOUT_FILENO, buf, 1);
- break;
- }
- ioctl(STDIN_FILENO, TCSETS , &savedttyarg) ; /* set changed tty arguments */
-
- return 0;
-}
diff --git a/toolbox/rmmod.c b/toolbox/rmmod.c
deleted file mode 100644
index c7e0d6a..0000000
--- a/toolbox/rmmod.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <malloc.h>
-#include <errno.h>
-#include <asm/unistd.h>
-
-extern int delete_module(const char *, unsigned int);
-
-int rmmod_main(int argc, char **argv)
-{
- int ret, i;
- char *modname, *dot;
-
- /* make sure we've got an argument */
- if (argc < 2) {
- fprintf(stderr, "usage: rmmod <module>\n");
- return -1;
- }
-
- /* if given /foo/bar/blah.ko, make a weak attempt
- * to convert to "blah", just for convenience
- */
- modname = strrchr(argv[1], '/');
- if (!modname)
- modname = argv[1];
- else modname++;
-
- dot = strchr(argv[1], '.');
- if (dot)
- *dot = '\0';
-
- /* Replace "-" with "_". This would keep rmmod
- * compatible with module-init-tools version of
- * rmmod
- */
- for (i = 0; modname[i] != '\0'; i++) {
- if (modname[i] == '-')
- modname[i] = '_';
- }
-
- /* pass it to the kernel */
- ret = delete_module(modname, O_NONBLOCK | O_EXCL);
- if (ret != 0) {
- fprintf(stderr, "rmmod: delete_module '%s' failed (errno %d)\n",
- modname, errno);
- return -1;
- }
-
- return 0;
-}
-
diff --git a/toolbox/rotatefb.c b/toolbox/rotatefb.c
deleted file mode 100644
index 2ff4127..0000000
--- a/toolbox/rotatefb.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-#include <errno.h>
-#include <linux/fb.h>
-
-
-int rotatefb_main(int argc, char *argv[])
-{
- int c;
- char *fbdev = "/dev/graphics/fb0";
- int rotation = 0;
- int fd;
- int res;
- struct fb_var_screeninfo fbinfo;
-
- do {
- c = getopt(argc, argv, "d:");
- if (c == EOF)
- break;
- switch (c) {
- case 'd':
- fbdev = optarg;
- break;
- case '?':
- fprintf(stderr, "%s: invalid option -%c\n",
- argv[0], optopt);
- exit(1);
- }
- } while (1);
-
- if(optind + 1 != argc) {
- fprintf(stderr, "%s: specify rotation\n", argv[0]);
- exit(1);
- }
- rotation = atoi(argv[optind]);
-
- fd = open(fbdev, O_RDWR);
- if(fd < 0) {
- fprintf(stderr, "cannot open %s\n", fbdev);
- return 1;
- }
-
- res = ioctl(fd, FBIOGET_VSCREENINFO, &fbinfo);
- if(res < 0) {
- fprintf(stderr, "failed to get fbinfo: %s\n", strerror(errno));
- return 1;
- }
- if((fbinfo.rotate ^ rotation) & 1) {
- unsigned int xres = fbinfo.yres;
- fbinfo.yres = fbinfo.xres;
- fbinfo.xres = xres;
- fbinfo.xres_virtual = fbinfo.xres;
- fbinfo.yres_virtual = fbinfo.yres * 2;
- if(fbinfo.yoffset == xres)
- fbinfo.yoffset = fbinfo.yres;
- }
- fbinfo.rotate = rotation;
- res = ioctl(fd, FBIOPUT_VSCREENINFO, &fbinfo);
- if(res < 0) {
- fprintf(stderr, "failed to set fbinfo: %s\n", strerror(errno));
- return 1;
- }
-
- return 0;
-}
diff --git a/toolbox/setkey.c b/toolbox/setkey.c
deleted file mode 100644
index 1ff2774..0000000
--- a/toolbox/setkey.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string.h>
-#include <linux/kd.h>
-#include <linux/vt.h>
-#include <errno.h>
-
-static void setkey_usage(char *argv[])
-{
- fprintf(stderr, "%s [-t <table>] [-k <index>] [-v value] [-r] [-h]\n"
- " -t <table> Select table\n"
- " -k <index> Select key\n"
- " -v <value> Set entry\n"
- " -r Read current entry\n"
- " -h Print help\n", argv[0]);
-}
-
-#define TTYDEV "/dev/tty0"
-
-int setkey_main(int argc, char *argv[])
-{
- int fd;
- struct kbentry kbe;
- int did_something = 0;
-
- kbe.kb_table = 0;
- kbe.kb_index = -1;
- kbe.kb_value = 0;
-
- fd = open(TTYDEV, O_RDWR | O_SYNC);
- if (fd < 0) {
- fprintf(stderr, "open %s: %s\n", TTYDEV, strerror(errno));
- return 1;
- }
-
- do {
- int c, ret;
-
- c = getopt(argc, argv, "t:k:v:hr");
- if (c == EOF)
- break;
-
- switch (c) {
- case 't':
- kbe.kb_table = strtol(optarg, NULL, 0);
- break;
- case 'k':
- kbe.kb_index = strtol(optarg, NULL, 0);
- break;
- case 'v':
- kbe.kb_value = strtol(optarg, NULL, 0);
- ret = ioctl(fd, KDSKBENT, &kbe);
- if (ret < 0) {
- fprintf(stderr, "KDSKBENT %d %d %d failed: %s\n",
- kbe.kb_table, kbe.kb_index, kbe.kb_value,
- strerror(errno));
- return 1;
- }
- did_something = 1;
- break;
- case 'r':
- ret = ioctl(fd, KDGKBENT, &kbe);
- if (ret < 0) {
- fprintf(stderr, "KDGKBENT %d %d failed: %s\n",
- kbe.kb_table, kbe.kb_index, strerror(errno));
- return 1;
- }
- printf("0x%x 0x%x 0x%x\n",
- kbe.kb_table, kbe.kb_index, kbe.kb_value);
- did_something = 1;
- break;
- case 'h':
- setkey_usage(argv);
- return 1;
- case '?':
- fprintf(stderr, "%s: invalid option -%c\n",
- argv[0], optopt);
- return 1;
- }
- } while (1);
-
- if(optind != argc || !did_something) {
- setkey_usage(argv);
- return 1;
- }
-
- return 0;
-}
diff --git a/toolbox/swapoff.c b/toolbox/swapoff.c
deleted file mode 100644
index d8f6a00..0000000
--- a/toolbox/swapoff.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/swap.h>
-
-int swapoff_main(int argc, char **argv)
-{
- int err = 0;
-
- if (argc != 2) {
- fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
- return -EINVAL;
- }
-
- err = swapoff(argv[1]);
- if (err) {
- fprintf(stderr, "swapoff failed for %s\n", argv[1]);
- }
-
- return err;
-}
diff --git a/toolbox/swapon.c b/toolbox/swapon.c
deleted file mode 100644
index 150701a..0000000
--- a/toolbox/swapon.c
+++ /dev/null
@@ -1,66 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <getopt.h>
-#include <sys/swap.h>
-
-static void usage(char *name)
-{
- fprintf(stderr, "Usage: %s [-p prio] <filename>\n"
- " prio must be between 0 and %d\n", name, SWAP_FLAG_PRIO_MASK);
-}
-
-static int parse_prio(char *prio_str)
-{
- unsigned long p = strtoul(prio_str, NULL, 10);
-
- return (p > SWAP_FLAG_PRIO_MASK)? -1 : (int)p;
-}
-
-int swapon_main(int argc, char **argv)
-{
- int err = 0;
- int flags = 0;
- int prio;
-
- opterr = 0;
- do {
- int c = getopt(argc, argv, "hp:");
- if (c == -1)
- break;
-
- switch (c) {
- case 'p':
- if (optarg != NULL)
- prio = parse_prio(optarg);
- else
- prio = -1;
-
- if (prio < 0) {
- usage(argv[0]);
- return -EINVAL;
- }
- flags |= SWAP_FLAG_PREFER;
- flags |= (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK;
- break;
- case 'h':
- usage(argv[0]);
- return 0;
- case '?':
- fprintf(stderr, "unknown option: %c\n", optopt);
- return -EINVAL;
- }
- } while (1);
-
- if (optind != argc - 1) {
- usage(argv[0]);
- return -EINVAL;
- }
-
- err = swapon(argv[argc - 1], flags);
- if (err) {
- fprintf(stderr, "swapon failed for %s\n", argv[argc - 1]);
- }
-
- return err;
-}
diff --git a/toolbox/syren.c b/toolbox/syren.c
deleted file mode 100644
index 47c2460..0000000
--- a/toolbox/syren.c
+++ /dev/null
@@ -1,158 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <malloc.h>
-
-/* ioctl crap */
-#define SYREN_RD 101
-#define SYREN_WR 102
-#define SYREN_OLD_RD 108
-#define SYREN_OLD_WR 109
-
-struct syren_io_args {
- unsigned long page;
- unsigned long addr;
- unsigned long value;
-};
-
-typedef struct {
- u_char page;
- u_char addr;
- const char *name;
-} syren_reg;
-
-static syren_reg registers[] = {
- { 0, 0x04, "TOGBR1" },
- { 0, 0x05, "TOGBR2" },
- { 0, 0x06, "VBDCTRL" },
- { 1, 0x07, "VBUCTRL" },
- { 1, 0x08, "VBCTRL" },
- { 1, 0x09, "PWDNRG" },
- { 1, 0x0a, "VBPOP" },
- { 1, 0x0b, "VBCTRL2" },
- { 1, 0x0f, "VAUDCTRL" },
- { 1, 0x10, "VAUSCTRL" },
- { 1, 0x11, "VAUOCTRL" },
- { 1, 0x12, "VAUDPLL" },
- { 1, 0x17, "VRPCSIMR" },
- { 0, 0, 0 }
-};
-
-static syren_reg *find_reg(const char *name)
-{
- int i;
-
- for (i = 0; registers[i].name != 0; i++) {
- if (!strcasecmp(registers[i].name, name))
- return ®isters[i];
- }
-
- return NULL;
-}
-
-static int usage(void)
-{
- fprintf(stderr, "usage: syren [r/w] [REGNAME | page:addr] (value)\n");
- return 1;
-}
-
-int
-syren_main(int argc, char **argv)
-{
- int cmd = -1;
- syren_reg *r;
- struct syren_io_args sio;
- char name[32];
- int fd;
-
- if (argc < 3) {
- return usage();
- }
-
- switch(argv[1][0]) {
- case 'r':
- cmd = SYREN_RD;
- break;
- case 'w':
- cmd = SYREN_WR;
- break;
- case 'R':
- cmd = SYREN_OLD_RD;
- break;
- case 'W':
- cmd = SYREN_OLD_WR;
- break;
- default:
- return usage();
- }
-
- if (cmd == SYREN_WR || cmd == SYREN_OLD_WR) {
- if (argc < 4)
- return usage();
- sio.value = strtoul(argv[3], 0, 0);
- }
-
- fd = open("/dev/eac", O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, "can't open /dev/eac\n");
- return 1;
- }
-
- if (strcasecmp(argv[2], "all") == 0) {
- int i;
- if (cmd != SYREN_RD && cmd != SYREN_OLD_RD) {
- fprintf(stderr, "can only read all registers\n");
- return 1;
- }
-
- for (i = 0; registers[i].name; i++) {
- sio.page = registers[i].page;
- sio.addr = registers[i].addr;
- if (ioctl(fd, cmd, &sio) < 0) {
- fprintf(stderr, "%s: error\n", registers[i].name);
- } else {
- fprintf(stderr, "%s: %04x\n", registers[i].name, sio.value);
- }
- }
-
- close(fd);
- return 0;
- }
-
- r = find_reg(argv[2]);
- if (r == NULL) {
- if(strlen(argv[2]) >= sizeof(name)){
- fprintf(stderr, "REGNAME too long\n");
- return 0;
- }
- strlcpy(name, argv[2], sizeof(name));
- char *addr_str = strchr(argv[2], ':');
- if (addr_str == NULL)
- return usage();
- *addr_str++ = 0;
- sio.page = strtoul(argv[2], 0, 0);
- sio.addr = strtoul(addr_str, 0, 0);
- } else {
- strlcpy(name, r->name, sizeof(name));
- sio.page = r->page;
- sio.addr = r->addr;
- }
-
- if (ioctl(fd, cmd, &sio) < 0) {
- fprintf(stderr, "ioctl(%d) failed\n", cmd);
- return 1;
- }
-
- if (cmd == SYREN_RD || cmd == SYREN_OLD_RD) {
- printf("%s: %04x\n", name, sio.value);
- } else {
- printf("wrote %04x to %s\n", sio.value, name);
- }
-
- close(fd);
-
- return 0;
-}
-
diff --git a/toolbox/upstream-freebsd/usr.bin/false/false.c b/toolbox/upstream-freebsd/usr.bin/false/false.c
deleted file mode 100644
index 99948bc..0000000
--- a/toolbox/upstream-freebsd/usr.bin/false/false.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. 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.
- * 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.
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static const char sccsid[] = "@(#)false.c 8.1 (Berkeley) 6/6/93";
-#endif /* not lint */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-int
-main(void)
-{
- return 1;
-}
diff --git a/toolbox/upstream-freebsd/usr.bin/true/true.c b/toolbox/upstream-freebsd/usr.bin/true/true.c
deleted file mode 100644
index a557f58..0000000
--- a/toolbox/upstream-freebsd/usr.bin/true/true.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. 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.
- * 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.
- *
- * $FreeBSD$
- */
-
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1988, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-static const char sccsid[] = "@(#)true.c 8.1 (Berkeley) 6/9/93";
-#endif /* not lint */
-
-int
-main(void)
-{
- return 0;
-}
diff --git a/toolbox/upstream-netbsd/bin/sleep/sleep.c b/toolbox/upstream-netbsd/bin/sleep/sleep.c
deleted file mode 100644
index 4349af4..0000000
--- a/toolbox/upstream-netbsd/bin/sleep/sleep.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* $NetBSD: sleep.c,v 1.24 2011/08/29 14:51:19 joerg Exp $ */
-
-/*
- * Copyright (c) 1988, 1993, 1994
- * The Regents of the University of California. 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.
- * 3. 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.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1988, 1993, 1994\
- The Regents of the University of California. All rights reserved.");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)sleep.c 8.3 (Berkeley) 4/2/94";
-#else
-__RCSID("$NetBSD: sleep.c,v 1.24 2011/08/29 14:51:19 joerg Exp $");
-#endif
-#endif /* not lint */
-
-#include <ctype.h>
-#include <err.h>
-#include <locale.h>
-#include <math.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <unistd.h>
-
-__dead static void alarmhandle(int);
-__dead static void usage(void);
-
-static volatile sig_atomic_t report_requested;
-static void
-report_request(int signo __unused)
-{
-
- report_requested = 1;
-}
-
-int
-main(int argc, char *argv[])
-{
- char *arg, *temp;
- double fval, ival, val;
- struct timespec ntime;
- time_t original;
- int ch, fracflag, rv;
-
- setprogname(argv[0]);
- (void)setlocale(LC_ALL, "");
-
- (void)signal(SIGALRM, alarmhandle);
-
- while ((ch = getopt(argc, argv, "")) != -1)
- switch(ch) {
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (argc != 1)
- usage();
-
- /*
- * Okay, why not just use atof for everything? Why bother
- * checking if there is a fraction in use? Because the old
- * sleep handled the full range of integers, that's why, and a
- * double can't handle a large long. This is fairly useless
- * given how large a number a double can hold on most
- * machines, but now we won't ever have trouble. If you want
- * 1000000000.9 seconds of sleep, well, that's your
- * problem. Why use an isdigit() check instead of checking for
- * a period? Because doing it this way means locales will be
- * handled transparently by the atof code.
- */
- fracflag = 0;
- arg = *argv;
- for (temp = arg; *temp != '\0'; temp++)
- if (!isdigit((unsigned char)*temp))
- fracflag++;
-
- if (fracflag) {
- val = atof(arg);
- if (val <= 0)
- usage();
- ival = floor(val);
- fval = (1000000000 * (val-ival));
- ntime.tv_sec = ival;
- ntime.tv_nsec = fval;
- }
- else {
- ntime.tv_sec = atol(arg);
- if (ntime.tv_sec <= 0)
- return EXIT_SUCCESS;
- ntime.tv_nsec = 0;
- }
-
- original = ntime.tv_sec;
- signal(SIGINFO, report_request);
- while ((rv = nanosleep(&ntime, &ntime)) != 0) {
- if (report_requested) {
- /* Reporting does not bother with nanoseconds. */
- warnx("about %d second(s) left out of the original %d",
- (int)ntime.tv_sec, (int)original);
- report_requested = 0;
- } else
- break;
- }
-
- if (rv == -1)
- err(EXIT_FAILURE, "nanosleep failed");
-
- return EXIT_SUCCESS;
- /* NOTREACHED */
-}
-
-static void
-usage(void)
-{
- (void)fprintf(stderr, "usage: %s seconds\n", getprogname());
- exit(EXIT_FAILURE);
- /* NOTREACHED */
-}
-
-/* ARGSUSED */
-static void
-alarmhandle(int i)
-{
- _exit(EXIT_SUCCESS);
- /* NOTREACHED */
-}
diff --git a/toolbox/upstream-netbsd/bin/sync/sync.c b/toolbox/upstream-netbsd/bin/sync/sync.c
deleted file mode 100644
index 2b9c367..0000000
--- a/toolbox/upstream-netbsd/bin/sync/sync.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* $NetBSD: sync.c,v 1.13 2008/07/20 00:52:40 lukem Exp $ */
-
-/*
- * Copyright (c) 1987, 1993
- * The Regents of the University of California. 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.
- * 3. 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.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1987, 1993\
- The Regents of the University of California. All rights reserved.");
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)sync.c 8.1 (Berkeley) 5/31/93";
-#else
-__RCSID("$NetBSD: sync.c,v 1.13 2008/07/20 00:52:40 lukem Exp $");
-#endif
-#endif /* not lint */
-
-#include <stdlib.h>
-#include <unistd.h>
-
-int main(int, char *[]);
-
-/* ARGSUSED */
-int
-main(int argc, char *argv[])
-{
- setprogname(argv[0]);
- sync();
- exit(0);
- /* NOTREACHED */
-}
diff --git a/toolbox/upstream-netbsd/usr.bin/printenv/printenv.c b/toolbox/upstream-netbsd/usr.bin/printenv/printenv.c
deleted file mode 100644
index e15384f..0000000
--- a/toolbox/upstream-netbsd/usr.bin/printenv/printenv.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* $NetBSD: printenv.c,v 1.12 2011/09/06 18:26:55 joerg Exp $ */
-
-/*
- * Copyright (c) 1987, 1993
- * The Regents of the University of California. 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.
- * 3. 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.
- */
-
-#include <sys/cdefs.h>
-#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1987, 1993\
- The Regents of the University of California. All rights reserved.");
-#endif /* not lint */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)printenv.c 8.2 (Berkeley) 5/4/95";*/
-__RCSID("$NetBSD: printenv.c,v 1.12 2011/09/06 18:26:55 joerg Exp $");
-#endif /* not lint */
-
-#include <sys/types.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <err.h>
-
-__dead static void usage(void);
-
-/*
- * printenv
- *
- * Bill Joy, UCB
- * February, 1979
- */
-int
-main(int argc, char *argv[])
-{
- extern char **environ;
- char *cp, **ep;
- size_t len;
- int ch;
-
- while ((ch = getopt(argc, argv, "")) != -1)
- switch(ch) {
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (argc == 0) {
- for (ep = environ; *ep; ep++)
- (void)printf("%s\n", *ep);
- exit(0);
- }
- if (argc != 1)
- usage();
- if (strchr(*argv, '=') != NULL)
- errx(1, "Invalid environment variable %s", *argv);
- len = strlen(*argv);
- for (ep = environ; *ep; ep++)
- if (!memcmp(*ep, *argv, len)) {
- cp = *ep + len;
- if (!*cp || *cp == '=') {
- (void)printf("%s\n", *cp ? cp + 1 : cp);
- exit(0);
- }
- }
- exit(1);
-}
-
-static void
-usage(void)
-{
- (void)fprintf(stderr, "Usage: printenv [name]\n");
- exit(1);
-}