From a38cb088619d3e2f2194247038c10897d1c5036e Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 17 Feb 2014 12:33:16 -0800 Subject: [PATCH] Clean up various warnings in bionic. Change-Id: Ic57541d0a567fd4ae79f0ad59b2ffde1130eb7d2 --- libc/Android.mk | 4 +-- libc/bionic/{name_mem.c => __bionic_name_mem.cpp} | 35 +++++++++++------------ libc/bionic/{reboot.c => reboot.cpp} | 8 ++++-- libc/private/bionic_name_mem.h | 3 +- libc/upstream-freebsd/freebsd-compat.h | 4 +++ libc/upstream-netbsd/port_before.h | 1 + libm/freebsd-compat.h | 3 ++ 7 files changed, 33 insertions(+), 25 deletions(-) rename libc/bionic/{name_mem.c => __bionic_name_mem.cpp} (68%) rename libc/bionic/{reboot.c => reboot.cpp} (90%) diff --git a/libc/Android.mk b/libc/Android.mk index 3aced4e80..c1716b1d0 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -67,13 +67,11 @@ libc_common_src_files := \ bionic/md5.c \ bionic/memmem.c \ bionic/memswap.c \ - bionic/name_mem.c \ bionic/pathconf.c \ bionic/perror.c \ bionic/ptsname.c \ bionic/ptsname_r.c \ bionic/pututline.c \ - bionic/reboot.c \ bionic/recv.c \ bionic/sched_cpualloc.c \ bionic/sched_cpucount.c \ @@ -212,6 +210,7 @@ libc_bionic_src_files := \ bionic/abort.cpp \ bionic/access.cpp \ bionic/assert.cpp \ + bionic/__bionic_name_mem.cpp \ bionic/bionic_time_conversions.cpp \ bionic/brk.cpp \ bionic/chmod.cpp \ @@ -268,6 +267,7 @@ libc_bionic_src_files := \ bionic/ptrace.cpp \ bionic/raise.cpp \ bionic/readlink.cpp \ + bionic/reboot.cpp \ bionic/rename.cpp \ bionic/rmdir.cpp \ bionic/sbrk.cpp \ diff --git a/libc/bionic/name_mem.c b/libc/bionic/__bionic_name_mem.cpp similarity index 68% rename from libc/bionic/name_mem.c rename to libc/bionic/__bionic_name_mem.cpp index 69e10c252..72a1d1eab 100644 --- a/libc/bionic/name_mem.c +++ b/libc/bionic/__bionic_name_mem.cpp @@ -28,26 +28,23 @@ #include "private/bionic_name_mem.h" -/* - * Local definitions of custom prctl arguments to set a vma name in some kernels - */ +#include + +// Local definitions of custom prctl arguments to set a vma name in some kernels. #define BIONIC_PR_SET_VMA 0x53564d41 #define BIONIC_PR_SET_VMA_ANON_NAME 0 -/* - * Names a region of memory. The name is expected to show up in /proc/pid/maps - * and /proc/pid/smaps. There is no guarantee that it will work, and it if it - * does work it is likely to only work on memory that was allocated with - * mmap(MAP_ANONYMOUS), and only on regions that are page aligned. name should - * be a pointer to a string that is valid for as long as the memory is mapped, - * preferably a compile-time constant string. - * - * Returns -1 on error and sets errno. If it returns an error naming page - * aligned anonymous memory the kernel doesn't support naming, and an alternate - * method of naming memory should be used (like ashmem). - */ -int __bionic_name_mem(void *addr, size_t len, const char *name) -{ - return prctl(BIONIC_PR_SET_VMA, BIONIC_PR_SET_VMA_ANON_NAME, - addr, len, name); +// Names a region of memory. The name is expected to show up in /proc/pid/maps +// and /proc/pid/smaps. There is no guarantee that it will work, and if it +// does work it is likely to only work on memory that was allocated with +// mmap(MAP_ANONYMOUS), and only on regions that are page aligned. name should +// be a pointer to a string that is valid for as long as the memory is mapped, +// preferably a compile-time constant string. +// +// Returns -1 on error and sets errno. If it returns an error naming page +// aligned anonymous memory the kernel doesn't support naming, and an alternate +// method of naming memory should be used (like ashmem). + +int __bionic_name_mem(void* addr, size_t len, const char* name) { + return prctl(BIONIC_PR_SET_VMA, BIONIC_PR_SET_VMA_ANON_NAME, addr, len, name); } diff --git a/libc/bionic/reboot.c b/libc/bionic/reboot.cpp similarity index 90% rename from libc/bionic/reboot.c rename to libc/bionic/reboot.cpp index 0fe8cdc46..9cf44115f 100644 --- a/libc/bionic/reboot.c +++ b/libc/bionic/reboot.cpp @@ -25,10 +25,12 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + #include #include -int reboot (int mode) -{ - return __reboot( LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, mode, NULL ); +extern "C" int __reboot(int, int, int, void*); + +int reboot(int mode) { + return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, mode, NULL); } diff --git a/libc/private/bionic_name_mem.h b/libc/private/bionic_name_mem.h index 9f6163d0b..98716f41e 100644 --- a/libc/private/bionic_name_mem.h +++ b/libc/private/bionic_name_mem.h @@ -25,6 +25,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ + #ifndef _BIONIC_NAME_MEM_H #define _BIONIC_NAME_MEM_H @@ -33,7 +34,7 @@ __BEGIN_DECLS -int __bionic_name_mem(void *addr, size_t len, const char *name); +int __bionic_name_mem(void* addr, size_t len, const char* name); __END_DECLS diff --git a/libc/upstream-freebsd/freebsd-compat.h b/libc/upstream-freebsd/freebsd-compat.h index 74dc679c3..d5f14258e 100644 --- a/libc/upstream-freebsd/freebsd-compat.h +++ b/libc/upstream-freebsd/freebsd-compat.h @@ -47,4 +47,8 @@ /* This one is only needed as long as we have a mix of OpenBSD and FreeBSD stdio. */ #define _sseek __sseek +/* This is in BSD's . */ +#include +extern uint32_t arc4random_uniform(uint32_t upper_bound); + #endif diff --git a/libc/upstream-netbsd/port_before.h b/libc/upstream-netbsd/port_before.h index 5e06e52d0..23d99c2be 100644 --- a/libc/upstream-netbsd/port_before.h +++ b/libc/upstream-netbsd/port_before.h @@ -19,6 +19,7 @@ #include "namespace.h" #include +#include #include "private/arpa_nameser.h" #define ISC_FORMAT_PRINTF(a,b) __printflike(a,b) diff --git a/libm/freebsd-compat.h b/libm/freebsd-compat.h index 4b14fae19..c63d4072a 100644 --- a/libm/freebsd-compat.h +++ b/libm/freebsd-compat.h @@ -23,4 +23,7 @@ #define __strong_reference(sym,aliassym) \ extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))) +/* digittoint is in BSD's . */ +int digittoint(char ch); + #endif -- 2.11.0