Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add Android support for rump kernel.



details:   https://anonhg.NetBSD.org/src/rev/319068a8b9b4
branches:  trunk
changeset: 328407:319068a8b9b4
user:      justin <justin%NetBSD.org@localhost>
date:      Wed Apr 02 17:09:23 2014 +0000

description:
Add Android support for rump kernel.

Reviewed by pooka@

diffstat:

 lib/librumpclient/rumpclient.c  |  14 +++++++++++---
 lib/librumphijack/hijack.c      |   9 ++++++---
 lib/librumpuser/rumpuser_dl.c   |   8 ++++----
 lib/librumpuser/rumpuser_port.h |  29 ++++++++++++++++++++++++++---
 lib/librumpuser/rumpuser_pth.c  |  14 +++++++-------
 sys/rump/include/rump/rump.h    |   4 ++--
 6 files changed, 56 insertions(+), 22 deletions(-)

diffs (242 lines):

diff -r 5f99623b8222 -r 319068a8b9b4 lib/librumpclient/rumpclient.c
--- a/lib/librumpclient/rumpclient.c    Wed Apr 02 16:14:50 2014 +0000
+++ b/lib/librumpclient/rumpclient.c    Wed Apr 02 17:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpclient.c,v 1.59 2014/04/02 15:04:19 pooka Exp $   */
+/*      $NetBSD: rumpclient.c,v 1.60 2014/04/02 17:09:23 justin Exp $  */
 
 /*
  * Copyright (c) 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -46,11 +46,11 @@
 #ifdef __NetBSD__
 #define USE_KQUEUE
 #endif
-#ifdef __linux__
+#if defined(__linux__) && !defined(__ANDROID__)
 #define USE_SIGNALFD
 #endif
 
-__RCSID("$NetBSD: rumpclient.c,v 1.59 2014/04/02 15:04:19 pooka Exp $");
+__RCSID("$NetBSD: rumpclient.c,v 1.60 2014/04/02 17:09:23 justin Exp $");
 
 #include <sys/param.h>
 #include <sys/mman.h>
@@ -86,9 +86,17 @@
 int    (*host_close)(int);
 int    (*host_connect)(int, const struct sockaddr *, socklen_t);
 int    (*host_fcntl)(int, int, ...);
+#ifdef __ANDROID__
+int    (*host_poll)(struct pollfd *, nfds_t, long);
+#else
 int    (*host_poll)(struct pollfd *, nfds_t, int);
+#endif
 ssize_t        (*host_read)(int, void *, size_t);
+#ifdef __ANDROID__
+int    (*host_sendmsg)(int, const struct msghdr *, unsigned int);
+#else
 ssize_t (*host_sendmsg)(int, const struct msghdr *, int);
+#endif
 int    (*host_setsockopt)(int, int, int, const void *, socklen_t);
 int    (*host_dup)(int);
 
diff -r 5f99623b8222 -r 319068a8b9b4 lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Wed Apr 02 16:14:50 2014 +0000
+++ b/lib/librumphijack/hijack.c        Wed Apr 02 17:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.106 2013/09/10 16:53:06 pooka Exp $      */
+/*      $NetBSD: hijack.c,v 1.107 2014/04/02 17:09:23 justin Exp $     */
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include <rump/rumpuser_port.h>
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.106 2013/09/10 16:53:06 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.107 2014/04/02 17:09:23 justin Exp $");
 #endif
 
 #include <sys/param.h>
@@ -38,10 +38,13 @@
 #include <sys/mount.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
-#include <sys/statvfs.h>
 #include <sys/time.h>
 #include <sys/uio.h>
 
+#ifdef PLATFORM_HAS_NBVFSSTAT
+#include <sys/statvfs.h>
+#endif
+
 #ifdef PLATFORM_HAS_KQUEUE
 #include <sys/event.h>
 #endif
diff -r 5f99623b8222 -r 319068a8b9b4 lib/librumpuser/rumpuser_dl.c
--- a/lib/librumpuser/rumpuser_dl.c     Wed Apr 02 16:14:50 2014 +0000
+++ b/lib/librumpuser/rumpuser_dl.c     Wed Apr 02 17:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: rumpuser_dl.c,v 1.27 2014/03/14 01:18:39 justin Exp $ */
+/*      $NetBSD: rumpuser_dl.c,v 1.28 2014/04/02 17:09:23 justin Exp $ */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -40,7 +40,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_dl.c,v 1.27 2014/03/14 01:18:39 justin Exp $");
+__RCSID("$NetBSD: rumpuser_dl.c,v 1.28 2014/04/02 17:09:23 justin Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -59,8 +59,8 @@
 #include <rump/rumpuser.h>
 
 #if defined(__ELF__) && (defined(__NetBSD__) || defined(__FreeBSD__)   \
-    || (defined(__sun__) && defined(__svr4__))) || defined(__linux__)  \
-    || defined(__DragonFly__)
+    || (defined(__sun__) && defined(__svr4__))) || defined(__DragonFly__)      \
+    || (defined(__linux__) && !defined(__ANDROID__))
 #include <elf.h>
 #include <link.h>
 
diff -r 5f99623b8222 -r 319068a8b9b4 lib/librumpuser/rumpuser_port.h
--- a/lib/librumpuser/rumpuser_port.h   Wed Apr 02 16:14:50 2014 +0000
+++ b/lib/librumpuser/rumpuser_port.h   Wed Apr 02 17:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser_port.h,v 1.31 2014/03/21 16:03:35 pooka Exp $ */
+/*     $NetBSD: rumpuser_port.h,v 1.32 2014/04/02 17:09:23 justin Exp $        */
 
 /*
  * Portability header for non-NetBSD platforms.
@@ -42,8 +42,15 @@
 #define PLATFORM_HAS_NBVFSSTAT
 #endif /* __NetBSD__ */
 
+#ifndef MIN
+#define MIN(a,b)        ((/*CONSTCOND*/(a)<(b))?(a):(b))
+#endif
+#ifndef MAX
+#define MAX(a,b)        ((/*CONSTCOND*/(a)>(b))?(a):(b))
+#endif
+
 /* might not be 100% accurate, maybe need to revisit later */
-#if defined(__linux__) || defined(__sun__)
+#if (defined(__linux__) && !defined(__ANDROID__)) || defined(__sun__)
 #define HAVE_CLOCK_NANOSLEEP
 #endif
 
@@ -54,6 +61,22 @@
 #include <features.h>
 #endif
 
+#ifdef __ANDROID__
+#include <stdint.h>
+typedef uint16_t in_port_t;
+#include <sys/select.h>
+#define atomic_inc_uint(x)  __sync_fetch_and_add(x, 1)
+#define atomic_dec_uint(x)  __sync_fetch_and_sub(x, 1)
+static inline int getsubopt(char **optionp, char * const *tokens, char **valuep);
+static inline int
+getsubopt(char **optionp, char * const *tokens, char **valuep)
+{
+
+       /* TODO make a definition */
+       return -1;
+}
+#endif
+
 #if defined(__sun__)
 #  if defined(RUMPUSER_NO_FILE_OFFSET_BITS)
 #    undef _FILE_OFFSET_BITS
@@ -226,7 +249,7 @@
 #define MSG_NOSIGNAL 0
 #endif
 
-#if defined(__sun__) && !defined(RUMP_REGISTER_T)
+#if (defined(__sun__) || defined(__ANDROID__)) && !defined(RUMP_REGISTER_T)
 #define RUMP_REGISTER_T long
 typedef RUMP_REGISTER_T register_t;
 #endif
diff -r 5f99623b8222 -r 319068a8b9b4 lib/librumpuser/rumpuser_pth.c
--- a/lib/librumpuser/rumpuser_pth.c    Wed Apr 02 16:14:50 2014 +0000
+++ b/lib/librumpuser/rumpuser_pth.c    Wed Apr 02 17:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser_pth.c,v 1.39 2014/03/21 16:03:07 pooka Exp $  */
+/*     $NetBSD: rumpuser_pth.c,v 1.40 2014/04/02 17:09:23 justin Exp $ */
 
 /*
  * Copyright (c) 2007-2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include "rumpuser_port.h"
 
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.39 2014/03/21 16:03:07 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.40 2014/04/02 17:09:23 justin Exp $");
 #endif /* !lint */
 
 #include <sys/queue.h>
@@ -254,7 +254,7 @@
 
 struct rumpuser_rw {
        pthread_rwlock_t pthrw;
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) && !defined(__ANDROID__)
        char pad[64 - sizeof(pthread_rwlock_t)];
        pthread_spinlock_t spin;
 #endif
@@ -317,7 +317,7 @@
 rw_readup(struct rumpuser_rw *rw)
 {
 
-#if defined(__NetBSD__) || defined(__APPLE__)
+#if defined(__NetBSD__) || defined(__APPLE__) || defined(__ANDROID__)
        atomic_inc_uint(&rw->readers);
 #else
        pthread_spin_lock(&rw->spin);
@@ -330,7 +330,7 @@
 rw_readdown(struct rumpuser_rw *rw)
 {
 
-#if defined(__NetBSD__) || defined(__APPLE__)
+#if defined(__NetBSD__) || defined(__APPLE__) || defined(__ANDROID__)
        atomic_dec_uint(&rw->readers);
 #else
        pthread_spin_lock(&rw->spin);
@@ -346,7 +346,7 @@
 
        NOFAIL(*rw = aligned_alloc(sizeof(struct rumpuser_rw)));
        NOFAIL_ERRNO(pthread_rwlock_init(&((*rw)->pthrw), NULL));
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) && !defined(__ANDROID__)
        NOFAIL_ERRNO(pthread_spin_init(&((*rw)->spin),PTHREAD_PROCESS_PRIVATE));
 #endif
        (*rw)->readers = 0;
@@ -452,7 +452,7 @@
 {
 
        NOFAIL_ERRNO(pthread_rwlock_destroy(&rw->pthrw));
-#if !defined(__APPLE__)
+#if !defined(__APPLE__) && ! defined(__ANDROID__)
        NOFAIL_ERRNO(pthread_spin_destroy(&rw->spin));
 #endif
        free(rw);
diff -r 5f99623b8222 -r 319068a8b9b4 sys/rump/include/rump/rump.h
--- a/sys/rump/include/rump/rump.h      Wed Apr 02 16:14:50 2014 +0000
+++ b/sys/rump/include/rump/rump.h      Wed Apr 02 17:09:23 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.h,v 1.61 2014/03/10 22:48:29 pooka Exp $  */
+/*     $NetBSD: rump.h,v 1.62 2014/04/02 17:09:23 justin Exp $ */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -57,7 +57,7 @@
 #endif
 #endif /* __NetBSD__ */
 
-#if defined(__sun__) && !defined(RUMP_REGISTER_T)
+#if (!defined(_KERNEL)) && (defined(__sun__) || defined(__ANDROID__)) && !defined(RUMP_REGISTER_T)
 #define RUMP_REGISTER_T long
 typedef RUMP_REGISTER_T register_t;
 #endif



Home | Main Index | Thread Index | Old Index