summaryrefslogtreecommitdiffstats
path: root/byterun/array.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2011-03-29 07:33:34 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2011-03-29 07:33:34 +0000
commitde47195103ab3165f370adf1e19e44514d681c91 (patch)
tree0709e57bd6d99e7b858b2e2790f5a69497e775a0 /byterun/array.c
parent919873347fd2a37f1bf037f994e991b58545db75 (diff)
Added public functions "caml_array_length" and "caml_is_double_array"
to abstract (slightly) over the concrete representation of arrays. Contributed by F. Le Fessant. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11006 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/array.c')
-rw-r--r--byterun/array.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/byterun/array.c b/byterun/array.c
index fc6065952..8f658058b 100644
--- a/byterun/array.c
+++ b/byterun/array.c
@@ -21,6 +21,17 @@
#include "misc.h"
#include "mlvalues.h"
+CAMLexport mlsize_t caml_array_length(value array){
+ tag_t tag = Tag_val(array);
+ if (tag == Double_array_tag)
+ return Wosize_val(array) / Double_wosize;
+ else return Wosize_val(array);
+}
+
+CAMLexport int caml_is_double_array(value array){
+ return (Tag_val(array) == Double_array_tag);
+}
+
CAMLprim value caml_array_get_addr(value array, value index)
{
intnat idx = Long_val(index);