Skip to content

Commit

Permalink
Update custom_operations initialization
Browse files Browse the repository at this point in the history
compare_ext (added in 3.12.1) now initialised with the default function.

fixed_length optimisation implemented for 4.08+
  • Loading branch information
dra27 committed Oct 27, 2020
1 parent d56eb5f commit e28ee25
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
11 changes: 10 additions & 1 deletion lib/int128_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <caml/intext.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/version.h>

#include "uint128.h"
#include "int128.h"
Expand Down Expand Up @@ -129,13 +130,21 @@ int128_deserialize(void *dst)
return 16;
}

#if OCAML_VERSION_MAJOR > 4 || OCAML_VERSION_MAJOR == 4 && OCAML_VERSION_MINOR >= 8
static const struct custom_fixed_length int128_length = { 16, 16 };
#endif

struct custom_operations int128_ops = {
"stdint.int128",
custom_finalize_default,
int128_cmp,
int128_hash,
int128_serialize,
int128_deserialize
int128_deserialize,
custom_compare_ext_default
#if OCAML_VERSION_MAJOR > 4 || OCAML_VERSION_MAJOR == 4 && OCAML_VERSION_MINOR >= 8
, &int128_length
#endif
};

#ifdef HAVE_INT128
Expand Down
11 changes: 10 additions & 1 deletion lib/uint128_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <caml/intext.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/version.h>

#include "int8.h"
#include "int16.h"
Expand Down Expand Up @@ -171,13 +172,21 @@ uint128_deserialize(void *dst)
return 16;
}

#if OCAML_VERSION_MAJOR > 4 || OCAML_VERSION_MAJOR == 4 && OCAML_VERSION_MINOR >= 8
static const struct custom_fixed_length uint128_length = { 16, 16 };
#endif

struct custom_operations uint128_ops = {
"stdint.uint128",
custom_finalize_default,
uint128_cmp,
uint128_hash,
uint128_serialize,
uint128_deserialize
uint128_deserialize,
custom_compare_ext_default
#if OCAML_VERSION_MAJOR > 4 || OCAML_VERSION_MAJOR == 4 && OCAML_VERSION_MINOR >= 8
, &uint128_length
#endif
};

#ifdef HAVE_UINT128
Expand Down
11 changes: 10 additions & 1 deletion lib/uint32_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <caml/intext.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/version.h>

#include "uint32.h"

Expand Down Expand Up @@ -39,13 +40,21 @@ uint32_deserialize(void *dst)
return 4;
}

#if OCAML_VERSION_MAJOR > 4 || OCAML_VERSION_MAJOR == 4 && OCAML_VERSION_MINOR >= 8
static const struct custom_fixed_length uint32_length = { 4, 4 };
#endif

struct custom_operations uint32_ops = {
"uint.uint32",
custom_finalize_default,
uint32_cmp,
uint32_hash,
uint32_serialize,
uint32_deserialize
uint32_deserialize,
custom_compare_ext_default
#if OCAML_VERSION_MAJOR > 4 || OCAML_VERSION_MAJOR == 4 && OCAML_VERSION_MINOR >= 8
, &uint32_length
#endif
};

CAMLprim value
Expand Down
11 changes: 10 additions & 1 deletion lib/uint64_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <caml/intext.h>
#include <caml/memory.h>
#include <caml/mlvalues.h>
#include <caml/version.h>

#include "uint64.h"

Expand Down Expand Up @@ -39,13 +40,21 @@ uint64_deserialize(void *dst)
return 8;
}

#if OCAML_VERSION_MAJOR > 4 || OCAML_VERSION_MAJOR == 4 && OCAML_VERSION_MINOR >= 8
static const struct custom_fixed_length uint64_length = { 8, 8 };
#endif

struct custom_operations uint64_ops = {
"uint.uint64",
custom_finalize_default,
uint64_cmp,
uint64_hash,
uint64_serialize,
uint64_deserialize
uint64_deserialize,
custom_compare_ext_default
#if OCAML_VERSION_MAJOR > 4 || OCAML_VERSION_MAJOR == 4 && OCAML_VERSION_MINOR >= 8
, &uint64_length
#endif
};

CAMLprim value
Expand Down

0 comments on commit e28ee25

Please sign in to comment.