Permalink
Browse files

Trivial changes

  • Loading branch information...
1 parent 355cf08 commit 96de9f5f25f92ac12ac0ec569401adf8368e9759 @lucasaiu committed Sep 4, 2013
Showing with 22 additions and 16 deletions.
  1. BIN boot/ocamlrun
  2. +6 −4 byterun/context.c
  3. +11 −8 byterun/context.h
  4. +4 −4 byterun/context_split.c
  5. +1 −0 byterun/extensible_buffer.c
View
Binary file not shown.
View
@@ -36,7 +36,9 @@
#include "callback.h" // for caml_callback_r
#include "alloc.h"
#include "intext.h"
+#ifdef HAS_PTHREAD
#include <pthread.h>
+#endif // #ifdef HAS_PTHREAD
#include <errno.h> // for EBUSY. FIXME: ensure this is still needed at the end --Luca Saiu REENTRANTRUNTIME
#ifndef HAS_MULTICONTEXT
@@ -130,7 +132,7 @@ void caml_v_semaphore(sem_t* semaphore){
#endif // #ifdef HAS_PTHREAD
}
-#ifdef HAS_MULTICONTEXT
+#ifdef HAS_PTHREAD
void* caml_destructor_thread_function(void *ctx_as_void_star){
CAML_R = ctx_as_void_star;
DUMP("Hello from the destructor thread for context %p (ctx is %p)", ctx_as_void_star, ctx);
@@ -146,7 +148,7 @@ void* caml_destructor_thread_function(void *ctx_as_void_star){
fprintf(stderr, "Destroyed the context %p: exiting the destructor thread %p as well.\n", ctx, (void*)pthread_self()); fflush(stderr);
return NULL; // unused
}
-#endif // #ifdef HAS_MULTICONTEXT
+#endif // #ifdef HAS_PTHREAD
/* Initialize the given context structure, which has already been allocated elsewhere: */
void caml_initialize_first_global_context(/* CAML_R */caml_global_context *this_ctx)
@@ -546,13 +548,13 @@ section. */
/* Context-destructor structures: */
this_ctx->reference_count = 1; // there is one user thread: the main one
{CAML_R = this_ctx; DUMP("added the initial pin to the context %p", this_ctx);}
-#ifdef HAS_MULTICONTEXT
+#ifdef HAS_PTHREAD
caml_initialize_semaphore(&this_ctx->destruction_semaphore, 0);
int pthread_create_result =
pthread_create(&this_ctx->destructor_thread, NULL, caml_destructor_thread_function, this_ctx);
assert(pthread_create_result == 0);
//caml_initialize_mutex(&this_ctx->reference_count_mutex);
-#endif // #ifdef HAS_MULTICONTEXT
+#endif // #ifdef HAS_PTHREAD
/* The kludgish self-pointer: */
#ifdef HAS_MULTICONTEXT
View
@@ -28,16 +28,19 @@
#include <signal.h>
#include <setjmp.h> // FIXME: remove if not needed in the end --Luca Saiu REENTRANTRUNTIME
+#include "config.h"
+#include "mlvalues.h"
+#include "misc.h"
+#include "memory.h"
+#include "extensible_buffer.h"
+
+#ifdef HAS_PTHREAD
#ifndef __USE_UNIX98
#define __USE_UNIX98
#endif
#include <pthread.h>
#include <semaphore.h>
-
-#include "config.h"
-#include "mlvalues.h"
-#include "misc.h"
-#include "extensible_buffer.h"
+#endif // #ifdef HAS_PTHREAD
/* An initialization function to be called at startup, once and only once: */
void caml_context_initialize_global_stuff(void);
@@ -355,7 +358,7 @@ struct caml_global_context {
unsigned long minor_gc_counter /* = 0 */;
//#endif
- /* from memory.h */
+/* from memory.h */
#ifdef ARCH_SIXTYFOUR
struct page_table caml_page_table;
#else
@@ -731,8 +734,8 @@ struct caml_mailbox* caml_mailbox_of_value(value v);
#define INIT_CAML_R \
/* nothing */
- /* Some useless constant easy to load into a register, to be passed
- around and then NOT used: */
+// /* Some useless constant easy to load into a register, to be passed
+// around and then NOT used: */
// #define ctx 0
#endif // #ifdef HAS_MULTICONTEXT
View
@@ -2,10 +2,6 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
-#include <limits.h> // FIXME: remove if not used in the end
-#include <assert.h> // FIXME: remove if not used in the end
-#include <pthread.h> // FIXME: remove if not used in the end
-#include <errno.h> // FIXME: remove if not used in the end
#define CAML_CONTEXT_ROOTS /* GC-protection macros */
#include "mlvalues.h"
@@ -24,6 +20,10 @@
#include "gc_ctrl.h" // FIXME: remove after debugging, if possible
#include "compact.h" // FIXME: remove after debugging, if possible
+#include <limits.h> // FIXME: remove if not used in the end
+#include <assert.h> // FIXME: remove if not used in the end
+#include <errno.h> // FIXME: remove if not used in the end
+
struct caml_mailbox* caml_make_mailbox_r(CAML_R){
struct caml_mailbox *m = caml_stat_alloc(sizeof(struct caml_mailbox));
m->descriptor = ctx->descriptor;
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include "mlvalues.h"
+#include "context.h"
#include "memory.h"
#include "extensible_buffer.h"

0 comments on commit 96de9f5

Please sign in to comment.