Skip to content

Commit

Permalink
Add support for OCaml 5.00
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate authored and rgrinberg committed Jul 21, 2022
1 parent e3cc931 commit 322a8a4
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 109 deletions.
12 changes: 6 additions & 6 deletions gen/gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ let copyf : i -> (('a -> 'b, unit, string) format) = function
| F -> "caml_copy_double(%s)"
| I8 -> "copy_int8(%s)"
| I16 -> "copy_int16(%s)"
| I24 -> "copy_int32((%s) << 8)"
| I32 -> "copy_int32(%s)"
| I40 -> "copy_int64((%s) << 24)"
| I48 -> "copy_int64((%s) << 16)"
| I56 -> "copy_int64((%s) << 8)"
| I64 -> "copy_int64(%s)"
| I24 -> "caml_copy_int32((%s) << 8)"
| I32 -> "caml_copy_int32(%s)"
| I40 -> "caml_copy_int64((%s) << 24)"
| I48 -> "caml_copy_int64((%s) << 16)"
| I56 -> "caml_copy_int64((%s) << 8)"
| I64 -> "caml_copy_int64(%s)"
| I128 -> "copy_int128(%s)"
| U8 -> "copy_uint8(%s)"
| U16 -> "copy_uint16(%s)"
Expand Down
42 changes: 22 additions & 20 deletions lib/int32_conv.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define CAML_NAME_SPACE

#include <assert.h>
#include <stdint.h>
#include <string.h>
Expand Down Expand Up @@ -30,78 +32,78 @@ CAMLprim value
int32_of_int(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Long_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Long_val(v)));
}

CAMLprim value
int32_of_nativeint(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Nativeint_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Nativeint_val(v)));
}

CAMLprim value
int32_of_float(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Double_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Double_val(v)));
}

CAMLprim value
int32_of_int8(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Int8_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Int8_val(v)));
}

CAMLprim value
int32_of_int16(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Int16_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Int16_val(v)));
}

CAMLprim value
int32_of_int24(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Int24_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Int24_val(v)));
}

CAMLprim value
int32_of_int40(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Int40_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Int40_val(v)));
}

CAMLprim value
int32_of_int48(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Int48_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Int48_val(v)));
}

CAMLprim value
int32_of_int56(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Int56_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Int56_val(v)));
}

CAMLprim value
int32_of_int64(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Int64_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Int64_val(v)));
}

CAMLprim value
int32_of_int128(value v)
{
CAMLparam1(v);
#ifdef HAVE_INT128
CAMLreturn (copy_int32((int32_t)Int128_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Int128_val(v)));
#else
failwith("unimplemented");
CAMLreturn(Val_unit);
Expand All @@ -112,64 +114,64 @@ CAMLprim value
int32_of_uint8(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Uint8_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint8_val(v)));
}

CAMLprim value
int32_of_uint16(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Uint16_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint16_val(v)));
}

CAMLprim value
int32_of_uint24(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Uint24_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint24_val(v)));
}

CAMLprim value
int32_of_uint32(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Uint32_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint32_val(v)));
}

CAMLprim value
int32_of_uint40(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Uint40_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint40_val(v)));
}

CAMLprim value
int32_of_uint48(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Uint48_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint48_val(v)));
}

CAMLprim value
int32_of_uint56(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Uint56_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint56_val(v)));
}

CAMLprim value
int32_of_uint64(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int32((int32_t)Uint64_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint64_val(v)));
}

CAMLprim value
int32_of_uint128(value v)
{
CAMLparam1(v);
#ifdef HAVE_UINT128
CAMLreturn (copy_int32((int32_t)Uint128_val(v)));
CAMLreturn (caml_copy_int32((int32_t)Uint128_val(v)));
#else
failwith("unimplemented");
CAMLreturn(Val_unit);
Expand Down
2 changes: 1 addition & 1 deletion lib/int40.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

#define Int40_val(v) ((*((int64_t *)Data_custom_val(v))) >> 24)

#define copy_int40(v) copy_int64(v)
#define copy_int40(v) caml_copy_int64(v)

#endif
42 changes: 22 additions & 20 deletions lib/int40_conv.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define CAML_NAME_SPACE

#include <assert.h>
#include <stdint.h>
#include <string.h>
Expand Down Expand Up @@ -30,78 +32,78 @@ CAMLprim value
int40_of_int(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Long_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Long_val(v)) << 24));
}

CAMLprim value
int40_of_nativeint(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Nativeint_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Nativeint_val(v)) << 24));
}

CAMLprim value
int40_of_float(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Double_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Double_val(v)) << 24));
}

CAMLprim value
int40_of_int8(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Int8_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Int8_val(v)) << 24));
}

CAMLprim value
int40_of_int16(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Int16_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Int16_val(v)) << 24));
}

CAMLprim value
int40_of_int24(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Int24_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Int24_val(v)) << 24));
}

CAMLprim value
int40_of_int32(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Int32_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Int32_val(v)) << 24));
}

CAMLprim value
int40_of_int48(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Int48_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Int48_val(v)) << 24));
}

CAMLprim value
int40_of_int56(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Int56_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Int56_val(v)) << 24));
}

CAMLprim value
int40_of_int64(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Int64_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Int64_val(v)) << 24));
}

CAMLprim value
int40_of_int128(value v)
{
CAMLparam1(v);
#ifdef HAVE_INT128
CAMLreturn (copy_int64(((int64_t)Int128_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Int128_val(v)) << 24));
#else
failwith("unimplemented");
CAMLreturn(Val_unit);
Expand All @@ -112,64 +114,64 @@ CAMLprim value
int40_of_uint8(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Uint8_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint8_val(v)) << 24));
}

CAMLprim value
int40_of_uint16(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Uint16_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint16_val(v)) << 24));
}

CAMLprim value
int40_of_uint24(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Uint24_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint24_val(v)) << 24));
}

CAMLprim value
int40_of_uint32(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Uint32_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint32_val(v)) << 24));
}

CAMLprim value
int40_of_uint40(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Uint40_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint40_val(v)) << 24));
}

CAMLprim value
int40_of_uint48(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Uint48_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint48_val(v)) << 24));
}

CAMLprim value
int40_of_uint56(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Uint56_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint56_val(v)) << 24));
}

CAMLprim value
int40_of_uint64(value v)
{
CAMLparam1(v);
CAMLreturn (copy_int64(((int64_t)Uint64_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint64_val(v)) << 24));
}

CAMLprim value
int40_of_uint128(value v)
{
CAMLparam1(v);
#ifdef HAVE_UINT128
CAMLreturn (copy_int64(((int64_t)Uint128_val(v)) << 24));
CAMLreturn (caml_copy_int64(((int64_t)Uint128_val(v)) << 24));
#else
failwith("unimplemented");
CAMLreturn(Val_unit);
Expand Down
2 changes: 1 addition & 1 deletion lib/int48.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

#define Int48_val(v) ((*((int64_t *)Data_custom_val(v))) >> 16)

#define copy_int48(v) copy_int64(v)
#define copy_int48(v) caml_copy_int64(v)

#endif
Loading

0 comments on commit 322a8a4

Please sign in to comment.