From 15ac8b9e6dec8f60879331fe62e62c92e09bfdb6 Mon Sep 17 00:00:00 2001 From: Gordon Henriksen Date: Sun, 23 Dec 2007 17:10:23 +0000 Subject: [PATCH] Fix some Ocaml GC errors noticed upon review. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45336 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../executionengine/executionengine_ocaml.c | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/bindings/ocaml/executionengine/executionengine_ocaml.c b/bindings/ocaml/executionengine/executionengine_ocaml.c index 816c966104a..03b0f327f80 100644 --- a/bindings/ocaml/executionengine/executionengine_ocaml.c +++ b/bindings/ocaml/executionengine/executionengine_ocaml.c @@ -72,12 +72,15 @@ static value alloc_generic_value(LLVMGenericValueRef Ref) { /* Llvm.lltype -> float -> t */ CAMLprim value llvm_genericvalue_of_float(LLVMTypeRef Ty, value N) { - return alloc_generic_value(LLVMCreateGenericValueOfFloat(Ty, Double_val(N))); + CAMLparam1(N); + CAMLreturn(alloc_generic_value( + LLVMCreateGenericValueOfFloat(Ty, Double_val(N)))); } /* 'a -> t */ CAMLprim value llvm_genericvalue_of_value(value V) { - return alloc_generic_value(LLVMCreateGenericValueOfPointer(Op_val(V))); + CAMLparam1(V); + CAMLreturn(alloc_generic_value(LLVMCreateGenericValueOfPointer(Op_val(V)))); } /* Llvm.lltype -> int -> t */ @@ -87,26 +90,30 @@ CAMLprim value llvm_genericvalue_of_int(LLVMTypeRef Ty, value Int) { /* Llvm.lltype -> int32 -> t */ CAMLprim value llvm_genericvalue_of_int32(LLVMTypeRef Ty, value Int32) { - return alloc_generic_value(LLVMCreateGenericValueOfInt(Ty, Int32_val(Int32), - 1)); + CAMLparam1(Int32); + CAMLreturn(alloc_generic_value( + LLVMCreateGenericValueOfInt(Ty, Int32_val(Int32), 1))); } /* Llvm.lltype -> nativeint -> t */ CAMLprim value llvm_genericvalue_of_nativeint(LLVMTypeRef Ty, value NatInt) { - return alloc_generic_value(LLVMCreateGenericValueOfInt(Ty, - Nativeint_val(NatInt), - 1)); + CAMLparam1(NatInt); + CAMLreturn(alloc_generic_value( + LLVMCreateGenericValueOfInt(Ty, Nativeint_val(NatInt), 1))); } /* Llvm.lltype -> int64 -> t */ CAMLprim value llvm_genericvalue_of_int64(LLVMTypeRef Ty, value Int64) { - return alloc_generic_value(LLVMCreateGenericValueOfInt(Ty, Int64_val(Int64), - 1)); + CAMLparam1(Int64); + CAMLreturn(alloc_generic_value( + LLVMCreateGenericValueOfInt(Ty, Int64_val(Int64), 1))); } /* Llvm.lltype -> t -> float */ CAMLprim value llvm_genericvalue_as_float(LLVMTypeRef Ty, value GenVal) { - return copy_double(LLVMGenericValueToFloat(Ty, Genericvalue_val(GenVal))); + CAMLparam1(GenVal); + CAMLreturn(copy_double( + LLVMGenericValueToFloat(Ty, Genericvalue_val(GenVal)))); } /* t -> 'a */ @@ -123,23 +130,26 @@ CAMLprim value llvm_genericvalue_as_int(value GenVal) { /* t -> int32 */ CAMLprim value llvm_genericvalue_as_int32(value GenVal) { + CAMLparam1(GenVal); assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 32 && "Generic value too wide to treat as an int32!"); - return copy_int32(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1)); + CAMLreturn(copy_int32(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1))); } /* t -> int64 */ CAMLprim value llvm_genericvalue_as_int64(value GenVal) { + CAMLparam1(GenVal); assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 64 && "Generic value too wide to treat as an int64!"); - return copy_int64(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1)); + CAMLreturn(copy_int64(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1))); } /* t -> nativeint */ CAMLprim value llvm_genericvalue_as_nativeint(value GenVal) { + CAMLparam1(GenVal); assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 8 * sizeof(value) && "Generic value too wide to treat as a nativeint!"); - return copy_nativeint(LLVMGenericValueToInt(Genericvalue_val(GenVal),1)); + CAMLreturn(copy_nativeint(LLVMGenericValueToInt(Genericvalue_val(GenVal),1))); }