Fixups for nacl at head revision.
authorElijah Taylor <elijahtaylor@google.com>
Fri, 5 Aug 2011 15:00:38 +0000 (17:00 +0200)
committerZoltan Varga <vargaz@gmail.com>
Fri, 5 Aug 2011 15:03:02 +0000 (17:03 +0200)
mono/io-layer/io.c
mono/metadata/tpool-poll.c
mono/mini/mini-exceptions.c
mono/utils/mono-context.c
mono/utils/mono-context.h
mono/utils/mono-threads-posix.c
mono/utils/mono-threads.h

index 2559c5ad7ee01c6d7446b3706bb4136297f930e6..abf39a5caa2e55ffd50632eebdbfe1b5718f9e72 100644 (file)
@@ -3654,6 +3654,8 @@ unescape_octal (gchar *str)
        }
        *wptr = '\0';
 }
+static gint32 GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf);
+
 #if __linux__
 #define GET_LOGICAL_DRIVE_STRINGS_BUFFER 512
 #define GET_LOGICAL_DRIVE_STRINGS_MOUNTPOINT_BUFFER 512
@@ -3680,7 +3682,6 @@ typedef struct
 
 static gboolean GetLogicalDriveStrings_Mounts (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
 static gboolean GetLogicalDriveStrings_MountInfo (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
-static gint32 GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf);
 static void append_to_mountpoint (LinuxMountInfoParseState *state);
 static gboolean add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state);
 
@@ -4414,7 +4415,7 @@ get_fstypename (gchar *utfpath)
 }
 
 /* Linux has struct statfs which has a different layout */
-#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD)
+#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__)
 gboolean
 GetVolumeInformation (const gunichar2 *path, gunichar2 *volumename, int volumesize, int *outserial, int *maxcomp, int *fsflags, gunichar2 *fsbuffer, int fsbuffersize)
 {
index 827bbb402c6367bff08270f726549ef6edeea828..2b573349971b5bca049075c91997ca40835c201c 100644 (file)
@@ -141,6 +141,10 @@ tp_poll_wait (gpointer p)
 #define INITIAL_POLLFD_SIZE    1024
 #endif
 #define POLL_ERRORS (MONO_POLLERR | MONO_POLLHUP | MONO_POLLNVAL)
+
+#ifdef DISABLE_SOCKETS
+#define socket_io_cleanup(x)
+#endif
        mono_pollfd *pfds;
        gint maxfd = 1;
        gint allocated;
index e1f97f2507436f6abeeb6a08bfc8344d25051bd5..1ad3d5a98a349429ec0a62a9a01a73a99d9d762e 100644 (file)
@@ -2533,7 +2533,7 @@ mono_thread_state_init_from_sigctx (MonoThreadUnwindState *ctx, void *sigctx)
        if (sigctx)
                mono_arch_sigctx_to_monoctx (sigctx, &ctx->ctx);
        else
-#if MONO_ARCH_HAS_MONO_CONTEXT
+#if MONO_ARCH_HAS_MONO_CONTEXT && !defined(MONO_CROSS_COMPILE)
                MONO_CONTEXT_GET_CURRENT (ctx->ctx);
 #else
                g_error ("Use a null sigctx requires a working mono-context");
index 942ff0baf86233a99fd33ddf223dac3de2232db3..df77239aebb1fcebc8fbd323822b172e3e1b8121 100644 (file)
@@ -11,7 +11,7 @@
 #include <ucontext.h>
 #endif
 
-#if defined(__i386__)
+#if (defined(__i386__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_X86))
 
 #include <mono/utils/mono-context.h>
 
@@ -100,7 +100,7 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
 #endif /* __native_client__ */
 }
 
-#elif defined(__x86_64__) /* defined(__i386__) */
+#elif (defined(__x86_64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_AMD64)) /* defined(__i386__) */
 
 #include <mono/utils/mono-context.h>
 
index 5e027ad1ae9fc80565697176043956727996bfde..8c8db9cbaabbdb2ce6b53a2ebc3a2f9581a5ecb0 100644 (file)
@@ -25,7 +25,7 @@
  * MONO_CONTEXT_GET_CURRENT captures the current context as close as possible. One reg might be clobbered
  *  to hold the address of the target MonoContext. It will be a caller save one, so should not be a problem.
  */
-#if defined(__i386__)
+#if (defined(__i386__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_X86))
 
 /*HACK, move this to an eventual mono-signal.c*/
 #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
@@ -125,7 +125,7 @@ typedef struct {
 #define MONO_ARCH_HAS_MONO_CONTEXT 1
 #endif
 
-#elif defined(__x86_64__) /* defined(__i386__) */
+#elif (defined(__x86_64__) && !defined(MONO_CROSS_COMPILE)) || (defined(TARGET_AMD64)) /* defined(__i386__) */
 
 
 #if !defined( HOST_WIN32 ) && !defined(__native_client__) && !defined(__native_client_codegen__)
@@ -162,6 +162,31 @@ typedef struct {
 #define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->rbp))
 #define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->rsp))
 
+#if defined(__native_client__)
+#define MONO_CONTEXT_GET_CURRENT(ctx)  \
+       __asm__ __volatile__(   \
+               "movq $0x0,  %%nacl:0x00(%%r15, %0, 1)\n"       \
+               "movq %%rbx, %%nacl:0x08(%%r15, %0, 1)\n"       \
+               "movq %%rcx, %%nacl:0x10(%%r15, %0, 1)\n"       \
+               "movq %%rdx, %%nacl:0x18(%%r15, %0, 1)\n"       \
+               "movq %%rbp, %%nacl:0x20(%%r15, %0, 1)\n"       \
+               "movq %%rsp, %%nacl:0x28(%%r15, %0, 1)\n"       \
+               "movq %%rsi, %%nacl:0x30(%%r15, %0, 1)\n"       \
+               "movq %%rdi, %%nacl:0x38(%%r15, %0, 1)\n"       \
+               "movq %%r8,  %%nacl:0x40(%%r15, %0, 1)\n"       \
+               "movq %%r9,  %%nacl:0x48(%%r15, %0, 1)\n"       \
+               "movq %%r10, %%nacl:0x50(%%r15, %0, 1)\n"       \
+               "movq %%r11, %%nacl:0x58(%%r15, %0, 1)\n"       \
+               "movq %%r12, %%nacl:0x60(%%r15, %0, 1)\n"       \
+               "movq %%r13, %%nacl:0x68(%%r15, %0, 1)\n"       \
+               "movq %%r14, %%nacl:0x70(%%r15, %0, 1)\n"       \
+               "movq %%r15, %%nacl:0x78(%%r15, %0, 1)\n"       \
+               "leaq (%%rip), %%rdx\n" \
+               "movq %%rdx, %%nacl:0x80(%%r15, %0, 1)\n"       \
+               :       \
+               : "a" ((int64_t)&(ctx)) \
+               : "rdx", "memory")
+#else
 #define MONO_CONTEXT_GET_CURRENT(ctx)  \
        __asm__ __volatile__(   \
                "movq $0x0,  0x00(%0)\n"        \
@@ -185,6 +210,7 @@ typedef struct {
                :       \
                : "a" (&(ctx))  \
                : "rdx", "memory")
+#endif
 
 #if !defined(HOST_WIN32)
 #define MONO_ARCH_HAS_MONO_CONTEXT 1
index 7f7edcedc4a1e4a79db80caf5c84fdc33462ee89..9f2e56b0c2852500000b7afb0fda20900c7033ef 100644 (file)
@@ -17,7 +17,8 @@
 
 #include <errno.h>
 
-#if defined(_POSIX_VERSION)
+#if defined(_POSIX_VERSION) || defined(__native_client__)
+#include <signal.h>
 
 typedef struct {
        void *(*start_routine)(void*);
@@ -74,6 +75,7 @@ mono_threads_pthread_create (pthread_t *new_thread, const pthread_attr_t *attr,
 
 #if !defined (__MACH__)
 
+#if !defined(__native_client__)
 static void
 suspend_signal_handler (int _dummy, siginfo_t *info, void *context)
 {
@@ -104,10 +106,12 @@ suspend_signal_handler (int _dummy, siginfo_t *info, void *context)
 
        MONO_SEM_POST (&current->finish_resume_semaphore);
 }
+#endif
 
 static void
 mono_posix_add_signal_handler (int signo, gpointer handler)
 {
+#if !defined(__native_client__)
        /*FIXME, move the code from mini to utils and do the right thing!*/
        struct sigaction sa;
        struct sigaction previous_sa;
@@ -119,17 +123,20 @@ mono_posix_add_signal_handler (int signo, gpointer handler)
        ret = sigaction (signo, &sa, &previous_sa);
 
        g_assert (ret != -1);
+#endif
 }
 
 void
 mono_threads_init_platform (void)
 {
+#if !defined(__native_client__)
        /*
        FIXME we should use all macros from mini to make this more portable
        FIXME it would be very sweet if sgen could end up using this too.
        */
        if (mono_thread_info_new_interrupt_enabled ())
                mono_posix_add_signal_handler (mono_thread_get_abort_signal (), suspend_signal_handler);
+#endif
 }
 
 /*nothing to be done here since suspend always abort syscalls due using signals*/
index db4817e1a3906ac702bdcda9b60d529b9ca892a2..5c20774b68981effde5a1229cb32100afc72c1ea 100644 (file)
@@ -73,7 +73,7 @@ typedef struct {
        int suspend_count;
 
        /* only needed by the posix backend */ 
-#if defined(_POSIX_VERSION) && !defined (__MACH__)
+#if (defined(_POSIX_VERSION) || defined(__native_client__)) && !defined (__MACH__)
        MonoSemType suspend_semaphore;
        MonoSemType resume_semaphore; 
        MonoSemType finish_resume_semaphore;