Skip to content
Browse files

Configuration improvements: now multi-context can be supported but st…

…ill disabled in an installation, and configuration macros reflect this duality
  • Loading branch information...
1 parent 3b7a1a7 commit 0250279b617b841e056071047106d93d0189cefd @lucasaiu committed Sep 9, 2013
View
3 Makefile
@@ -420,7 +420,8 @@ utils/config.ml: utils/config.mlp config/Makefile
-e 's|%%ARCH%%|$(ARCH)|' \
-e 's|%%MODEL%%|$(MODEL)|' \
-e 's|%%SYSTEM%%|$(SYSTEM)|' \
- -e 's|%%MULTICONTEXT%%|$(MULTICONTEXT)|' \
+ -e 's|%%MULTICONTEXT_SUPPORTED%%|$(MULTICONTEXT_SUPPORTED)|' \
+ -e 's|%%MULTICONTEXT_ENABLED%%|$(MULTICONTEXT_ENABLED)|' \
-e 's|%%EXT_OBJ%%|.o|' \
-e 's|%%EXT_ASM%%|.s|' \
-e 's|%%EXT_LIB%%|.a|' \
View
2 boot/camlheader
@@ -1 +1 @@
-#!/home/luca/usr-patched-ocaml//bin/ocamlrun
+#!/home/luca/usr-patched-ocaml/bin/ocamlrun
View
BIN boot/myocamlbuild
Binary file not shown.
View
BIN boot/ocamlc
Binary file not shown.
View
BIN boot/ocamldep
Binary file not shown.
View
BIN boot/ocamllex
Binary file not shown.
View
BIN boot/ocamlrun
Binary file not shown.
View
BIN boot/ocamlrun.boot
Binary file not shown.
View
BIN boot/ocamlyacc
Binary file not shown.
View
BIN boot/stdlib.cma
Binary file not shown.
View
18 byterun/context.c
@@ -138,17 +138,17 @@ void caml_v_semaphore(sem_t* semaphore){
#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);
+ //DUMP("Hello from the destructor thread for context %p (ctx is %p)", ctx_as_void_star, ctx);
/* Block until notified by a V: */
- DUMP("waiting to be notified before destroying the context");
+ //DUMP("waiting to be notified before destroying the context");
caml_p_semaphore(&ctx->destruction_semaphore);
/* We were notified; run at_exit callbacks and destroy the context: */
caml_run_at_context_exit_functions_r(ctx);
- DUMP("about to destroy the context");
+ //DUMP("about to destroy the context");
caml_destroy_context_r(ctx);
- fprintf(stderr, "Destroyed the context %p: exiting the destructor thread %p as well.\n", ctx, (void*)pthread_self()); fflush(stderr);
+ //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_PTHREAD
@@ -550,7 +550,7 @@ 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);}
+ //{CAML_R = this_ctx; DUMP("added the initial pin to the context %p", this_ctx);}
#ifdef HAS_PTHREAD
caml_initialize_semaphore(&this_ctx->destruction_semaphore, 0);
int pthread_create_result =
@@ -768,7 +768,7 @@ void caml_finalize_context_r(CAML_R){
//fprintf(stderr, "caml_finalize_context_r [context %p] [thread %p]: FIXME: actually free everything\n", ctx, (void*)(pthread_self())); fflush(stderr);
//fprintf(stderr, "caml_finalize_context_r [context %p] [thread %p]: OK-4\n", ctx, (void*)(pthread_self())); fflush(stderr);
- fprintf(stderr, "caml_finalize_context_r [context %p] [thread %p]: OK-5: finalized %p\n", ctx, (void*)(pthread_self()), ctx); fflush(stderr);
+ //fprintf(stderr, "caml_finalize_context_r [context %p] [thread %p]: OK-5: finalized %p\n", ctx, (void*)(pthread_self()), ctx); fflush(stderr);
// FIXME: really destroy stuff
}
@@ -1074,15 +1074,15 @@ int caml_can_split_r(CAML_R){
void caml_pin_context_r(CAML_R){
Assert(ctx->reference_count > 0);
ctx->reference_count ++;
- DUMP(" PIN %i -> %i", ctx->reference_count - 1, ctx->reference_count);
+ //DUMP(" PIN %i -> %i", ctx->reference_count - 1, ctx->reference_count);
}
void caml_unpin_context_r(CAML_R){
Assert(ctx->reference_count > 0);
ctx->reference_count --;
- DUMP("UNpin %i -> %i", ctx->reference_count + 1, ctx->reference_count);
+ //DUMP("UNpin %i -> %i", ctx->reference_count + 1, ctx->reference_count);
if(ctx->reference_count == 0){
- DUMP("removed the last pin");
+ //DUMP("removed the last pin");
#ifdef HAS_MULTICONTEXT
caml_v_semaphore(&ctx->destruction_semaphore);
#else
View
2 byterun/context.h
@@ -658,8 +658,6 @@ struct caml_global_context {
/* Context-destructor structures: */
int reference_count;
- //pthread_mutex_t reference_count_mutex; // NO: I'll just use the contextual mutex // Actually I don't need *any* mutex: caml threads on the same context are not parallel!!!!
- //pthread_cond_t reference_count_condition;
#ifdef HAS_MULTICONTEXT
sem_t destruction_semaphore;
pthread_t destructor_thread;
View
6 byterun/context_split.c
@@ -95,7 +95,7 @@ void caml_run_at_context_exit_functions_r(CAML_R){
we simply won't run cleanup functions. */
if(run_at_context_exit_functions_pointer != NULL){
run_at_context_exit_functions = *run_at_context_exit_functions_pointer;
- DUMP("Context.run_at_context_exit_functions is %p", (void*)(long)run_at_context_exit_functions);
+ //DUMP("Context.run_at_context_exit_functions is %p", (void*)(long)run_at_context_exit_functions);
caml_callback_exn_r(ctx, run_at_context_exit_functions, Val_unit);
}
CAMLreturn0;
@@ -636,7 +636,7 @@ static void caml_raise_unimplemented_r(CAML_R){
CAMLprim value caml_context_split_r(CAML_R, value thread_no_as_value, value function)
{
-#if defined(HAS_MULTICONTEXT) && defined(NATIVE_CODE)
+#if defined(HAS_MULTICONTEXT) //&& defined(NATIVE_CODE)
//DUMPROOTS("splitting: before GC-protecting locals");
CAMLparam1(function);
@@ -753,7 +753,7 @@ CAMLprim value caml_context_split_r(CAML_R, value thread_no_as_value, value func
#else
caml_raise_unimplemented_r(ctx);
return Val_unit; // unreachable
-#endif // #if defined(HAS_MULTICONTEXT) && defined(NATIVE_CODE)
+#endif // #if defined(HAS_MULTICONTEXT) //&& defined(NATIVE_CODE)
}
// FIXME: is this useful? I'd like to kill it
View
2 byterun/sys.c
@@ -99,7 +99,7 @@ CAMLexport void caml_sys_io_error_r(CAML_R, value arg)
CAMLprim value caml_sys_exit_r(CAML_R, value retcode)
{
- DUMP();
+ //DUMP();
#ifndef NATIVE_CODE
caml_debugger_r(ctx, PROGRAM_EXIT);
#endif
View
3 config/Makefile.mingw
@@ -170,4 +170,5 @@ MAKEREC=$(MAKE) -f Makefile.nt
MAKECMD=$(MAKE)
## Multicontext isn't supported on this architecture
-MULTICONTEXT=false
+MULTICONTEXT_SUPPORTED=false
+MULTICONTEXT_ENABLED=false
View
3 config/Makefile.mingw64
@@ -165,4 +165,5 @@ MAKEREC=$(MAKE) -f Makefile.nt
MAKECMD=$(MAKE)
## Multicontext isn't supported on this architecture
-MULTICONTEXT=false
+MULTICONTEXT_SUPPORTED=false
+MULTICONTEXT_ENABLED=false
View
3 config/Makefile.msvc
@@ -176,4 +176,5 @@ MAKEREC=$(MAKE) -f Makefile.nt
MAKECMD=$(MAKE)
## Multicontext isn't supported on this architecture
-MULTICONTEXT=false
+MULTICONTEXT_SUPPORTED=false
+MULTICONTEXT_ENABLED=false
View
3 config/Makefile.msvc64
@@ -172,4 +172,5 @@ MAKEREC=$(MAKE) -f Makefile.nt
MAKECMD=$(MAKE)
## Multicontext isn't supported on this architecture
-MULTICONTEXT=false
+MULTICONTEXT_SUPPORTED=false
+MULTICONTEXT_ENABLED=false
View
17 config/m.h
@@ -1,12 +1,15 @@
-#undef ARCH_SIXTYFOUR
+#ifndef __PIC__
+# define ARCH_CODE32
+#endif
+#define ARCH_SIXTYFOUR
#define SIZEOF_INT 4
-#define SIZEOF_LONG 4
-#define SIZEOF_PTR 4
+#define SIZEOF_LONG 8
+#define SIZEOF_PTR 8
#define SIZEOF_SHORT 2
-#define ARCH_INT64_TYPE long long
-#define ARCH_UINT64_TYPE unsigned long long
-#define ARCH_INT64_PRINTF_FORMAT "ll"
-#define ARCH_BIG_ENDIAN
+#define ARCH_INT64_TYPE long
+#define ARCH_UINT64_TYPE unsigned long
+#define ARCH_INT64_PRINTF_FORMAT "l"
+#undef ARCH_BIG_ENDIAN
#undef ARCH_ALIGN_DOUBLE
#undef ARCH_ALIGN_INT64
#undef NONSTANDARD_DIV_MOD
View
7 config/s.h
@@ -1,5 +1,5 @@
#define OCAML_OS_TYPE "Unix"
-#define OCAML_STDLIB_DIR "/home/luca/usr-patched-ocaml//lib/ocaml"
+#define OCAML_STDLIB_DIR "/home/luca/usr-patched-ocaml/lib/ocaml"
#define POSIX_SIGNALS
#define HAS_C99_FLOAT_OPS
#define HAS_GETRUSAGE
@@ -46,6 +46,9 @@
#define HAS_PWRITE
#define HAS_GETHOSTBYNAME_R 6
#define HAS_GETHOSTBYADDR_R 8
+#define HAS_STACK_OVERFLOW_DETECTION
#define HAS_PTHREAD
#define HAS_SIGWAIT
-// #define HAS_MULTICONTEXT /* not supported */
+#define SUPPORTS_MULTICONTEXT
+#define HAS_MULTICONTEXT
+#define HAS_LIBBFD
View
59 configure
@@ -1241,29 +1241,35 @@ fi
# Determine if multi-context is supported
-multicontext_support=false
-if test "$multicontext_wanted" = "yes"; then
- case "$arch,$system" in
- amd64,linux)
- if test "$systhread_support" != "true"; then
- echo "No pthreads on GNU/Linux amd64. This should not happen" 1>&2
- exit 2 # Why 2? Just a local convention? --L.S. !!!!!!!!!!!!!!!!!!!
- fi
- echo "Multi-context is supported."
- multicontext_support=true
- echo "#define HAS_MULTICONTEXT" >> s.h
- ;;
- *)
- echo "Multi-context is not supported"
- echo '// #define HAS_MULTICONTEXT /* not supported */' >> s.h
- ;;
- esac
-## FIXME: disable the next else branch, for uniformity !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+multicontext_supported=false
+case "$arch,$system" in
+ amd64,linux)
+ echo "Multi-context is supported."
+ multicontext_supported=true
+ echo "#define SUPPORTS_MULTICONTEXT" >> s.h
+ ;;
+ *)
+ echo "Multi-context is not supported"
+ echo '// #define SUPPORTS_MULTICONTEXT /* not supported */' >> s.h
+ ;;
+esac
+
+# Determine if multi-context is enabled
+multicontext_enabled=false
+if test "$multicontext_wanted" = "yes" && test "$multicontext_supported" = "true"; then
+ if test "$systhread_support" != "true"; then
+ echo "No pthreads on GNU/Linux amd64. This should not happen" 1>&2
+ exit 2 # Why 2? Just a local convention? --L.S. !!!!!!!!!!!!!!!!!!!
+ fi
+ echo "Multi-context is enabled."
+ multicontext_enabled=true
+ echo "#define HAS_MULTICONTEXT" >> s.h
else
- echo "You disabled multi-context"
- echo '// #define HAS_MULTICONTEXT /* disabled at configuration time */' >> s.h
+ echo "Multi-context is not supported or explicitly disabled"
+ echo '// #define HAS_MULTICONTEXT /* disabled or not supported */' >> s.h
fi
+
# Determine the location of X include files and libraries
# If the user specified -x11include and/or -x11lib, these settings
@@ -1670,7 +1676,8 @@ echo "MKMAINDLL=$mkmaindll" >> Makefile
echo "RUNTIMED=${debugruntime}" >>Makefile
echo "CAMLP4=${withcamlp4}" >>Makefile
echo "ASM_CFI_SUPPORTED=$asm_cfi_supported" >> Makefile
-echo "MULTICONTEXT=$multicontext_support" >> Makefile
+echo "MULTICONTEXT_SUPPORTED=$multicontext_supported" >> Makefile
+echo "MULTICONTEXT_ENABLED=$multicontext_enabled" >> Makefile
rm -f tst hasgot.c
rm -f ../m.h ../s.h ../Makefile
@@ -1728,10 +1735,14 @@ else
fi
fi
-if test "$multicontext_support" = "true"; then
- echo "Multi-context: enabled"
+if test "$multicontext_supported" = "true"; then
+ if test "$multicontext_enabled" = "true"; then
+ echo "Multi-context: supported and enabled"
+ else
+ echo "Multi-context: supported but disabled"
+ fi
else
- echo "Multi-context: disabled or not supported"
+ echo "Multi-context: not supported"
fi
if test "$debugger" = "ocamldebugger"; then
View
21 myocamlbuild_config.ml
@@ -1,5 +1,5 @@
-(* # generated by ./configure --prefix /home/luca/usr-patched-ocaml/ --with-debug-runtime *)
-let prefix = "/home/luca/usr-patched-ocaml/";;
+(* # generated by ./configure --prefix /home/luca/usr-patched-ocaml --with-debug-runtime *)
+let prefix = "/home/luca/usr-patched-ocaml";;
let bindir = prefix^"/bin";;
let libdir = prefix^"/lib/ocaml";;
let stublibdir = libdir^"/stublibs";;
@@ -9,14 +9,14 @@ let ranlib = "ranlib";;
let ranlibcmd = "ranlib";;
let arcmd = "ar";;
let sharpbangscripts = true;;
-let bng_arch = "ppc";;
+let bng_arch = "amd64";;
let bng_asm_level = "1";;
let pthread_link = "-cclib -lpthread";;
let x11_includes = "not found";;
let x11_link = "not found";;
let tk_defs = "";;
let tk_link = "";;
-let libbfd_link = "";;
+let libbfd_link = "-lbfd -ldl -liberty -lz";;
let bytecc = "gcc";;
let bytecccompopts = "-fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT";;
let bytecclinkopts = " -Wl,-E";;
@@ -33,19 +33,19 @@ let syslib x = "-l"^x;;
(* ## *)
(* MKLIB=ar rc "^1^" "^2^"; ranlib "^1^" *)
let mklib out files opts = Printf.sprintf "ar rc %s %s %s; ranlib %s" out opts files out;;
-let arch = "power";;
-let model = "ppc";;
-let system = "elf";;
+let arch = "amd64";;
+let model = "default";;
+let system = "linux";;
let nativecc = "gcc";;
let nativecccompopts = "-Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT";;
let nativeccprofopts = "-Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT";;
let nativecclinkopts = "";;
let nativeccrpath = "-Wl,-rpath,";;
let nativecclibs = " -lm -ldl -lpthread";;
-let asm = "as -u -m ppc";;
+let asm = "as";;
let aspp = "gcc -c";;
let asppprofflags = "-DPROFILING";;
-let profiling = "noprof";;
+let profiling = "prof";;
let dynlinkopts = " -ldl";;
let otherlibraries = "unix str num dynlink bigarray systhreads threads";;
let debugger = "ocamldebugger";;
@@ -74,4 +74,5 @@ let mkmaindll = "gcc -shared";;
let runtimed = "runtimed";;
let camlp4 = "camlp4";;
let asm_cfi_supported = true;;
-let multicontext = false;;
+let multicontext_supported = true;;
+let multicontext_enabled = true;;
View
2 otherlibs/systhreads/st_stubs.c
@@ -124,8 +124,6 @@ static void (*prev_scan_roots_hook) (scanning_action);
/*static*/ int caml_systhreads_get_thread_no_r(CAML_R); // !!!!!!!!!!!!!!
-// NEW EXPERIMENTAL VERSION, IN WHICH IS SCAN FROM all_threads TO NULL
-// INSTEAD OF FROM curr_thread TO curr_thread
static void caml_thread_scan_roots(scanning_action action)
{
QB();
View
12 stdlib/context.ml
@@ -163,16 +163,18 @@ external set_debugging : bool -> unit = "caml_set_debugging"
(* This is to be called from C: *)
let run_at_context_exit_functions () =
- dump "Executing \"contextual\" at_exit functions";
+ (* dump "Executing \"contextual\" at_exit functions"; *)
List.iter
(fun f -> f ())
- ((* List.rev *) !at_context_exit_functions);
- dump "Executed \"contextual\" at_exit functions"
+ ((* List.rev *) !at_context_exit_functions)(* ; *)
+ (* dump "Executed \"contextual\" at_exit functions" *)
let () =
Callback.register "Context.run_at_context_exit_functions" run_at_context_exit_functions
let at_exit f =
at_context_exit_functions := f :: !at_context_exit_functions
-let _ =
- at_exit (fun () -> dump "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE about to exit the context")
+(* let _ = *)
+(* at_exit *)
+(* (fun () -> *)
+(* dump "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE about to exit the context") *)
View
6 stdlib/context.mli
@@ -27,18 +27,22 @@ val make_mailbox : unit -> mailbox
val context_of_mailbox : mailbox -> t
val is_mailbox_local : mailbox -> bool
+
(* These may raise CannotSplit and Unimplemented *)
val split1 : (mailbox -> unit) -> (*new context mailbox*)mailbox
val split : int -> (int -> mailbox -> unit) -> (*mailboxes to new contexts*)(mailbox list)
val split_into_array : int -> (int -> mailbox -> unit) -> (*mailboxes to new contexts*)(mailbox array)
+(* val low_level_split_into_context_array : int -> (int -> unit) -> (t option array) *)
+
+
(* FIXME: do I need to expose these? *)
val split_into_context_array : int -> (int -> unit) -> (t array)
val split_into_context_list : int -> (int -> unit) -> (t list)
val split_into_context : (unit -> unit) -> t
val send : mailbox -> 'a -> unit
-val receive : mailbox -> 'a
+val receive : mailbox -> 'a (* not exactly type-safe :-) *)
(* (\* Wait until the context local to the given mailbox or mailboxes terminates: *\) *)
View
21 tools/myocamlbuild_config.ml
@@ -1,5 +1,5 @@
-(* # generated by ./configure --prefix /home/luca/usr-patched-ocaml/ --with-debug-runtime *)
-let prefix = "/home/luca/usr-patched-ocaml/";;
+(* # generated by ./configure --prefix /home/luca/usr-patched-ocaml --with-debug-runtime *)
+let prefix = "/home/luca/usr-patched-ocaml";;
let bindir = prefix^"/bin";;
let libdir = prefix^"/lib/ocaml";;
let stublibdir = libdir^"/stublibs";;
@@ -9,14 +9,14 @@ let ranlib = "ranlib";;
let ranlibcmd = "ranlib";;
let arcmd = "ar";;
let sharpbangscripts = true;;
-let bng_arch = "ppc";;
+let bng_arch = "amd64";;
let bng_asm_level = "1";;
let pthread_link = "-cclib -lpthread";;
let x11_includes = "not found";;
let x11_link = "not found";;
let tk_defs = "";;
let tk_link = "";;
-let libbfd_link = "";;
+let libbfd_link = "-lbfd -ldl -liberty -lz";;
let bytecc = "gcc";;
let bytecccompopts = "-fno-defer-pop -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT";;
let bytecclinkopts = " -Wl,-E";;
@@ -33,19 +33,19 @@ let syslib x = "-l"^x;;
(* ## *)
(* MKLIB=ar rc "^1^" "^2^"; ranlib "^1^" *)
let mklib out files opts = Printf.sprintf "ar rc %s %s %s; ranlib %s" out opts files out;;
-let arch = "power";;
-let model = "ppc";;
-let system = "elf";;
+let arch = "amd64";;
+let model = "default";;
+let system = "linux";;
let nativecc = "gcc";;
let nativecccompopts = "-Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT";;
let nativeccprofopts = "-Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT";;
let nativecclinkopts = "";;
let nativeccrpath = "-Wl,-rpath,";;
let nativecclibs = " -lm -ldl -lpthread";;
-let asm = "as -u -m ppc";;
+let asm = "as";;
let aspp = "gcc -c";;
let asppprofflags = "-DPROFILING";;
-let profiling = "noprof";;
+let profiling = "prof";;
let dynlinkopts = " -ldl";;
let otherlibraries = "unix str num dynlink bigarray systhreads threads";;
let debugger = "ocamldebugger";;
@@ -74,4 +74,5 @@ let mkmaindll = "gcc -shared";;
let runtimed = "runtimed";;
let camlp4 = "camlp4";;
let asm_cfi_supported = true;;
-let multicontext = false;;
+let multicontext_supported = true;;
+let multicontext_enabled = true;;
View
6 utils/config.mli
@@ -103,8 +103,10 @@ val asm: string
val asm_cfi_supported: bool
(* Whether assembler understands CFI directives *)
-val multicontext: bool
- (* Whether multicontext is enabled / supported *)
+val multicontext_supported: bool
+ (* Whether multicontext can be supported (the user can still disable it) *)
+val multicontext_enabled: bool
+ (* Whether multicontext is enabled *)
val ext_obj: string
(* Extension for object files, e.g. [.o] under Unix. *)
View
3 utils/config.mlp
@@ -80,7 +80,8 @@ let system = "%%SYSTEM%%"
let asm = "%%ASM%%"
let asm_cfi_supported = %%ASM_CFI_SUPPORTED%%
-let multicontext = %%MULTICONTEXT%%
+let multicontext_supported = %%MULTICONTEXT_SUPPORTED%%
+let multicontext_enabled = %%MULTICONTEXT_ENABLED%%
let ext_obj = "%%EXT_OBJ%%"
let ext_asm = "%%EXT_ASM%%"

0 comments on commit 0250279

Please sign in to comment.
Something went wrong with that request. Please try again.