diff options
Diffstat (limited to 'libc')
-rw-r--r-- | libc/Android.mk | 4 | ||||
-rw-r--r-- | libc/bionic/__bionic_name_mem.cpp (renamed from libc/bionic/name_mem.c) | 35 | ||||
-rw-r--r-- | libc/bionic/reboot.cpp (renamed from libc/bionic/reboot.c) | 8 | ||||
-rw-r--r-- | libc/private/bionic_name_mem.h | 3 | ||||
-rw-r--r-- | libc/upstream-freebsd/freebsd-compat.h | 4 | ||||
-rw-r--r-- | libc/upstream-netbsd/port_before.h | 1 |
6 files changed, 30 insertions, 25 deletions
diff --git a/libc/Android.mk b/libc/Android.mk index 3aced4e..c1716b1 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 index 69e10c2..72a1d1e 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 <sys/prctl.h> + +// 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 index 0fe8cdc..9cf4411 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 <unistd.h> #include <sys/reboot.h> -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 9f6163d..98716f4 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 74dc679..d5f1425 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 <stdlib.h>. */ +#include <stdint.h> +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 5e06e52..23d99c2 100644 --- a/libc/upstream-netbsd/port_before.h +++ b/libc/upstream-netbsd/port_before.h @@ -19,6 +19,7 @@ #include "namespace.h" #include <sys/cdefs.h> +#include <time.h> #include "private/arpa_nameser.h" #define ISC_FORMAT_PRINTF(a,b) __printflike(a,b) |