AC_DEFINE(__mono_ilp32__, 1, [64 bit mode with 4 byte longs and pointers])
sizeof_register=8
;;
+ *-*-nacl)
+ TARGET=X86
+ arch_target=x86
+ AC_DEFINE(TARGET_X86, 1, [...])
+ sizeof_register=4
+ ;;
armv7l-unknown-linux-gnueabi*)
# TEGRA
TARGET=ARM;
# ifdef NACL
# define OS_TYPE "NACL"
extern int etext[];
-# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
+//# define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
+# define DATASTART ((ptr_t)0x10000000)
extern int _end[];
# define DATAEND (_end)
# ifdef STACK_GRAN
#else /* NACL */
GC_thread p;
int i;
+ int num_sleeps = 0;
#if DEBUG_THREADS
GC_printf1("pthread_stop_world: num_threads %d\n", nacl_num_gc_threads - 1);
while (1) {
#define NACL_PARK_WAIT_NANOSECONDS 100000
+ #define NANOS_PER_SECOND 1000000000
int num_threads_parked = 0;
struct timespec ts;
int num_used = 0;
GC_printf1("sleeping waiting for %d threads to park...\n", nacl_num_gc_threads - num_threads_parked - 1);
#endif
nanosleep(&ts, 0);
+ if (++num_sleeps > NANOS_PER_SECOND / NACL_PARK_WAIT_NANOSECONDS) {
+ GC_printf1("GC appears stalled waiting for %d threads to park...\n", nacl_num_gc_threads - num_threads_parked - 1);
+ num_sleeps = 0;
+ }
}
#endif /* NACL */
extern __thread int nacl_thread_idx;
extern __thread GC_thread nacl_gc_thread_self;
+extern void nacl_pre_syscall_hook();
+extern void nacl_post_syscall_hook();
+extern void nacl_register_gc_hooks(void (*pre)(), void (*post)());
+
void nacl_initialize_gc_thread()
{
int i;
+ nacl_register_gc_hooks(nacl_pre_syscall_hook, nacl_post_syscall_hook);
pthread_mutex_lock(&nacl_thread_alloc_lock);
if (!nacl_thread_parking_inited)
{
#include <mono/metadata/rand.h>
#include <mono/metadata/exception.h>
-#if defined(__native_client__)
-#include <errno.h>
-
-static void
-get_entropy_from_server (const char *path, guchar *buf, int len)
-{
- return;
-}
-
-#else /* defined(__native_client__) */
-
-#if !defined(HOST_WIN32)
+#if !defined(__native_client__) && !defined(HOST_WIN32)
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
close (file);
}
#endif
-#endif /* __native_client__ */
#if defined (HOST_WIN32)
CryptReleaseContext ((HCRYPTPROV) handle, 0);
}
+#elif defined (__native_client__)
+
+MonoBoolean
+ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngOpen (void)
+{
+ srand (time (NULL));
+ return TRUE;
+}
+
+gpointer
+ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngInitialize (MonoArray *seed)
+{
+ return -1;
+}
+
+gpointer
+ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngGetBytes (gpointer handle, MonoArray *arry)
+{
+ guint32 len = mono_array_length (arry);
+ guchar *buf = mono_array_addr (arry, guchar, 0);
+
+ /* Read until the buffer is filled. This may block if using NAME_DEV_RANDOM. */
+ gint count = 0;
+ gint err;
+
+ do {
+ if (len - count >= sizeof (long))
+ {
+ *(long*)buf = rand();
+ count += sizeof (long);
+ }
+ else if (len - count >= sizeof (short))
+ {
+ *(short*)buf = rand();
+ count += sizeof (short);
+ }
+ else if (len - count >= sizeof (char))
+ {
+ *buf = rand();
+ count += sizeof (char);
+ }
+ } while (count < len);
+
+ return (gpointer)-1L;
+}
+
+void
+ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngClose (gpointer handle)
+{
+}
#else
#ifndef NAME_DEV_URANDOM
#if defined(__native_client_codegen__) && defined(__native_client__)
#include <malloc.h>
-#include <sys/nacl_syscalls.h>
+#include <nacl/nacl_dyncode.h>
#endif
/*