X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=bitstring_c.c;h=b9ad109e3f982d1db6e3002a7f6b62109c93b0e5;hb=1c8abef3cf8b2ccb2f75b22b9c4509b43c76e11c;hp=1921cfaecc35642fefd4ab5047bbc42eb750dba4;hpb=ec3fe0d1b99dc46c368035f0e25c44e5b630b587;p=ocaml-bitstring.git diff --git a/bitstring_c.c b/bitstring_c.c index 1921cfa..b9ad109 100644 --- a/bitstring_c.c +++ b/bitstring_c.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -74,7 +75,7 @@ { \ type *ptr = (type *) ((void *) String_val (strv) + Int_val (offv)); \ type r; \ - r = *ptr; \ + memcpy(&r, ptr, sizeof(r)); \ swap_##endian(size,r); \ return Val_int (r); \ } @@ -93,7 +94,7 @@ fastpath1(16,ne,signed,int16_t) { \ type *ptr = (type *) ((void *) String_val (strv) + Int_val (offv)); \ type r; \ - r = *ptr; \ + memcpy(&r, ptr, sizeof(r)); \ swap_##endian(size,r); \ rval(rv) = r; \ return rv; \ @@ -117,12 +118,12 @@ fastpath2(32,ne,signed,int32_t,Int32_val) ocaml_bitstring_extract_fastpath_int##size##_##endian##_##signed \ (value strv, value offv, value rv) \ { \ - CAMLparam3(strv, offv, rv); \ type *ptr = (type *) ((void *) String_val (strv) + Int_val (offv)); \ type r; \ - r = *ptr; \ + memcpy(&r, ptr, sizeof(r)); \ swap_##endian(size,r); \ - CAMLreturn(caml_copy_int64(r)); \ + memcpy(Data_custom_val(rv), &r, sizeof(r)); \ + return rv; \ } #else