Merge branch 'master' of ssh://git.nguyen.vg/SXSI/xpathcomp
[SXSI/xpathcomp.git] / src / common_stub.hpp
index 3e874b7..b771f33 100644 (file)
@@ -14,9 +14,14 @@ extern "C" {
 }
 #include <typeinfo>
 #include <cstdio>
+#include <cassert>
 
 #define NoAlloc
 
+//Must be used in front of every function that is called from OCaml.
+
+#define ML_BINDING extern "C" __attribute__ ((force_align_arg_pointer)) 
+
 
 void register_custom_(char* name,
                      size_t size,
@@ -26,6 +31,7 @@ value alloc_custom_(char* name);
 
 template <class X> X& Obj_val(value v)
 {
+  assert(Tag_val(v) == Custom_tag);
   return * (X*) Data_custom_val(v);
 }
 
@@ -56,8 +62,7 @@ sxsi_alloc_custom(void (*finalize)(value) = sxsi_finalize_custom<X>)
 
 void sxsi_raise_msg(const char * msg);
 
-extern "C" value sxsi_cpp_init(value unit);
-
+ML_BINDING value sxsi_cpp_init(value unit);
 
 
 #endif