| Attached Files | patch-byte-order.diff [^] (1,710 bytes) 2009-10-23 09:47 [Show Content] [Hide Content]diff --git a/byterun/sys.c b/byterun/sys.c
index bbc0e60..ca21934 100644
--- a/byterun/sys.c
+++ b/byterun/sys.c
@@ -322,9 +322,14 @@ CAMLprim value caml_sys_get_config(value unit)
CAMLlocal2 (result, ostype);
ostype = caml_copy_string(OCAML_OS_TYPE);
- result = caml_alloc_small (2, 0);
+ result = caml_alloc_small (3, 0);
Field(result, 0) = ostype;
Field(result, 1) = Val_long (8 * sizeof(value));
+#ifdef ARCH_BIG_ENDIAN
+ Field(result, 2) = Val_int(1);
+#else
+ Field(result, 2) = Val_int(0);
+#endif
CAMLreturn (result);
}
diff --git a/stdlib/sys.mli b/stdlib/sys.mli
index c88e881..c8b41e4 100644
--- a/stdlib/sys.mli
+++ b/stdlib/sys.mli
@@ -90,6 +90,12 @@ val max_array_length : int
array is [max_array_length/2] on 32-bit machines and
[max_array_length] on 64-bit machines. *)
+type byte_order =
+ Little_endian
+ | Big_endian
+
+val byte_order : byte_order
+(** Byte order of the machine currently executing the Caml program. *)
(** {6 Signal handling} *)
diff --git a/stdlib/sys.mlp b/stdlib/sys.mlp
index b58ca0b..113f8c4 100644
--- a/stdlib/sys.mlp
+++ b/stdlib/sys.mlp
@@ -19,11 +19,15 @@
(* System interface *)
-external get_config: unit -> string * int = "caml_sys_get_config"
+type byte_order =
+ Little_endian
+ | Big_endian
+
+external get_config: unit -> string * int * byte_order = "caml_sys_get_config"
external get_argv: unit -> string * string array = "caml_sys_get_argv"
let (executable_name, argv) = get_argv()
-let (os_type, word_size) = get_config()
+let (os_type, word_size, byte_order) = get_config()
let max_array_length = (1 lsl (word_size - 10)) - 1;;
let max_string_length = word_size / 8 * max_array_length - 1;;
|