X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=src%2Fcommon_stub.hpp;h=ae672dada8b3943ae59fdb0947827de3f6df03d0;hb=9cce2a2d99b15d1cb51623b29a20ad77074afa70;hp=438b5d2b78636f33bad62ded954cdfeac1ec8bff;hpb=b8995e8af34dcada69bdfe16ca2c924a701a2e93;p=SXSI%2Fxpathcomp.git diff --git a/src/common_stub.hpp b/src/common_stub.hpp index 438b5d2..ae672da 100644 --- a/src/common_stub.hpp +++ b/src/common_stub.hpp @@ -1,5 +1,5 @@ -#ifndef COMMON_STUB_H_ -#define COMMON_STUB_H_ +#ifndef COMMON_STUB_HPP_ +#define COMMON_STUB_HPP_ extern "C" { #define CAML_NAME_SPACE @@ -11,9 +11,19 @@ extern "C" { #include #include #include - } #include +#include +#include + +#define NoAlloc + +//Must be used in front of every function that is called from OCaml. +#if _M_IX86 || __i386 +#define ML_BINDING extern "C" __attribute__ ((force_align_arg_pointer)) +#else +#define ML_BINDING extern "C" +#endif void register_custom_(char* name, @@ -24,6 +34,7 @@ value alloc_custom_(char* name); template X& Obj_val(value v) { + assert(Tag_val(v) == Custom_tag); return * (X*) Data_custom_val(v); } @@ -39,7 +50,8 @@ template void sxsi_finalize_custom(value v) sxsi_finalize_obj(Obj_val(v)); } -template value sxsi_alloc_custom(void (*finalize)(value) = sxsi_finalize_custom) +template value +sxsi_alloc_custom(void (*finalize)(value) = sxsi_finalize_custom) { char * name = const_cast(typeid(X).name()); @@ -51,10 +63,9 @@ template value sxsi_alloc_custom(void (*finalize)(value) = sxsi_finali return v; } -void sxsi_raise_msg(char * msg); - -extern "C" value sxsi_cpp_init(value unit); +void sxsi_raise_msg(const char * msg); +ML_BINDING value sxsi_cpp_init(value unit); #endif