1 #include "utils_stub.hpp"
4 #define CAML_NAME_SPACE
6 #include <caml/mlvalues.h>
7 #include <caml/alloc.h>
8 #include <caml/memory.h>
9 #include <caml/callback.h>
10 #include <caml/fail.h>
11 #include <caml/custom.h>
12 #include <caml/bigarray.h>
16 extern "C" value caml_clz(value i)
18 return Val_long( ((sizeof(unsigned long)*8) - __builtin_clzl(Long_val(i))) - 1);
21 extern "C" value caml_leading_bit(value i)
23 return Val_long( ( 1 << (sizeof(unsigned long)*8 - __builtin_clzl(Long_val(i)) - 1)));
27 static char * rtrim(char *str)
33 for (ptr = str + len - 1; ptr >= str && isspace((int)*ptr ); --ptr);
39 static char * ltrim(char *str)
44 for (ptr = str; *ptr && isspace((int)*ptr); ++ptr);
47 memmove(str, ptr, len + 1);
51 extern "C" value caml_trim(value s)
56 char * str = String_val(s);
59 res = caml_copy_string(str);
63 xml_tree::tag_t*& TAGLIST(value x)
65 return Obj_val<xml_tree::tag_t*>(x);
70 static void finalize_tag_list(value x)
72 xml_tree::tag_t * t = TAGLIST(x);
76 extern "C" value caml_tag_list_alloc(value length)
80 tlist = sxsi_alloc_custom<xml_tree::tag_t*>();
81 TAGLIST(tlist) = new xml_tree::tag_t[Int_val(length)];
85 NoAlloc extern "C" value caml_tag_list_set(value tl, value i, value v)
87 TAGLIST(tl)[Int_val(i)] = Int_val(v);