From 3c88e47f3e6d80e92ca8d923dac38a8ea5572b98 Mon Sep 17 00:00:00 2001 From: Elijah Taylor Date: Tue, 17 Aug 2010 07:30:16 +0200 Subject: [PATCH] Disable sockets and a few other things when using NACL. --- mono/metadata/Makefile.am | 1 + mono/metadata/console-unix.c | 5 +++++ mono/metadata/nacl-stub.c | 16 ++++++++++++++++ mono/metadata/rand.c | 12 ++++++++++++ mono/metadata/socket-io.c | 4 ++++ 5 files changed, 38 insertions(+) create mode 100644 mono/metadata/nacl-stub.c diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am index 1d5321f0378..99922b20b9c 100644 --- a/mono/metadata/Makefile.am +++ b/mono/metadata/Makefile.am @@ -142,6 +142,7 @@ libmonoruntime_la_SOURCES = \ mono-wsq.h \ monitor.c \ monitor.h \ + nacl-stub.c \ normalization-tables.h \ null-gc.c \ number-formatter.h \ diff --git a/mono/metadata/console-unix.c b/mono/metadata/console-unix.c index 0808baabc2d..773833deabc 100644 --- a/mono/metadata/console-unix.c +++ b/mono/metadata/console-unix.c @@ -6,6 +6,9 @@ * * Copyright (C) 2005-2009 Novell, Inc. (http://www.novell.com) */ +#if defined(__native_client__) +#include "console-null.c" +#else #include #include @@ -485,3 +488,5 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoString *keypad, MonoString *teardow return TRUE; } +#endif /* #if defined(__native_client__) */ + diff --git a/mono/metadata/nacl-stub.c b/mono/metadata/nacl-stub.c new file mode 100644 index 00000000000..83494def459 --- /dev/null +++ b/mono/metadata/nacl-stub.c @@ -0,0 +1,16 @@ + +#if defined(__native_client__) + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include + +struct group *getgrnam(const char *name) { return NULL; } +struct group *getgrgid(gid_t gid) { errno=EIO; return NULL; } +int fsync(int fd) { errno=EINVAL; return -1; } +dev_t makedev(guint32 maj, guint32 min) { return (maj)*256+(min); } + +#endif diff --git a/mono/metadata/rand.c b/mono/metadata/rand.c index 9b657343ca4..935325ed198 100644 --- a/mono/metadata/rand.c +++ b/mono/metadata/rand.c @@ -26,6 +26,17 @@ #include #include +#if defined(__native_client__) +#include + +static void +get_entropy_from_server (const char *path, guchar *buf, int len) +{ + return; +} + +#else /* defined(__native_client__) */ + #if !defined(HOST_WIN32) #include #include @@ -96,6 +107,7 @@ get_entropy_from_server (const char *path, guchar *buf, int len) close (file); } #endif +#endif /* __native_client__ */ #if defined (HOST_WIN32) diff --git a/mono/metadata/socket-io.c b/mono/metadata/socket-io.c index 53dd0d8b13c..e4c639f7677 100644 --- a/mono/metadata/socket-io.c +++ b/mono/metadata/socket-io.c @@ -11,6 +11,8 @@ #include +#ifndef DISABLE_SOCKETS + #include #include #include @@ -3075,3 +3077,5 @@ void mono_network_cleanup(void) WSACleanup(); } + +#endif /* #ifndef DISABLE_SOCKETS */ -- 2.25.1