I'm adding conversions for other C types, based on the latest master
(cf6f86a), but building fails without any error message. polyimport
fails on my version of ForeignConstants.sml. After experimenting, it
seems that introducing
RunCall.rtsCallFast1"f" ()
where f is a new function that I am also introducing, causes the failure.
Is there a different way I should be building? I'm sure I just ran
'make', 'make compiler' when I did this before. I have attached the
patch in case I've done something silly in there.
>From 953f8dcbfec9259cc0a34819784a4742c8d616dd Mon Sep 17 00:00:00 2001
From: Phil Clayton
Date: Fri, 1 Oct 2021 08:16:24 +0100
Subject: [PATCH] Add FFI conversions for C types
Conversions are added to the structure Foreign for C types as follows:
long long cLonglong, cLonglongLarge
unsigned long long cUlonglong, cUlonglongLarge
ptrdiff_t cPtrdiff, cPtrdiffLarge
intptr_tcIntptr, cIntptrLarge
uintptr_t cUintptr, cUintptrLarge
---
basis/Foreign.sml | 74 ++
basis/ForeignConstants.sml | 8 +
libpolyml/polyffi.cpp | 24 +
3 files changed, 106 insertions(+)
diff --git a/basis/Foreign.sml b/basis/Foreign.sml
index 70921620..e4d1b948 100644
--- a/basis/Foreign.sml
+++ b/basis/Foreign.sml
@@ -205,14 +205,24 @@ sig
val cUint: int conversion
val cLong: int conversion
val cUlong: int conversion
+val cLonglong: int conversion
+val cUlonglong: int conversion
val cIntLarge: LargeInt.int conversion
val cUintLarge: LargeInt.int conversion
val cLongLarge: LargeInt.int conversion
val cUlongLarge: LargeInt.int conversion
+val cLonglongLarge: LargeInt.int conversion
+val cUlonglongLarge: LargeInt.int conversion
val cSsize: int conversion
val cSize: int conversion
+val cPtrdiff : int conversion
+val cIntptr : int conversion
+val cUintptr : int conversion
val cSsizeLarge: LargeInt.int conversion
val cSizeLarge: LargeInt.int conversion
+val cPtrdiffLarge : LargeInt.int conversion
+val cIntptrLarge : LargeInt.int conversion
+val cUintptrLarge : LargeInt.int conversion
val cString: string conversion
val cByteArray: Word8Vector.vector conversion
val cFloat: real conversion
@@ -594,12 +604,26 @@ struct
{ size= #size saLong, align= #align saLong, typeForm = CTypeSignedInt }
val cTypeUlong =
{ size= #size saLong, align= #align saLong, typeForm = CTypeUnsignedInt }
+(* long long *)
+val cTypeLonglong =
+{ size= #size saLonglong, align= #align saLonglong, typeForm = CTypeSignedInt }
+val cTypeUlonglong =
+{ size= #size saLonglong, align= #align saLonglong, typeForm = CTypeUnsignedInt }
(* ssize_t *)
val cTypeSsize =
{ size= #size saSsize, align= #align saSsize, typeForm = CTypeSignedInt }
(* size_t *)
val cTypeSize =
{ size= #size saSize, align= #align saSize, typeForm = CTypeUnsignedInt }
+(* ptrdiff_t *)
+val cTypePtrdiff =
+{ size= #size saPtrdiff, align= #align saPtrdiff, typeForm = CTypeSignedInt }
+(* intptr_t *)
+val cTypeIntptr =
+{ size= #size saIntptr, align= #align saIntptr, typeForm = CTypeSignedInt }
+(* uintptr_t *)
+val cTypeUintptr =
+{ size= #size saUintptr, align= #align saUintptr, typeForm = CTypeUnsignedInt }
(* Float: 4 on X86 *)
val cTypeFloat =
{ size= #size saFloat, align= #align saFloat, typeForm = CTypeFloatingPt }
@@ -970,6 +994,26 @@ struct
else if #size saLong = #size (#ctype cUint64Large) then cUint64Large
else raise Foreign "Unable to find type for unsigned long"
+val cLonglong =
+if #size saLonglong = #size (#ctype cInt32) then cInt32
+else if #size saLonglong = #size (#ctype cInt64) then cInt64
+else raise Foreign "Unable to find type for long long"
+
+val cLonglongLarge =
+if #size saLonglong = #size (#ctype cInt32Large) then cInt32Large
+else if #size saLonglong = #size (#ctype cInt64Large) then cInt64Large
+else raise Foreign "Unable to find type for long long"
+
+val cUlonglong =
+if #size saLonglong = #size (#ctype cUint32) then cUint32
+else if #size saLonglong = #size (#ctype cUint64) then cUint64
+else raise Foreign "Unable to find type for unsigned long long"
+
+val cUlonglongLarge =
+if #size saLonglong = #size (#ctype cUint32Large) then cUint32Large
+else if #size saLonglong = #size (#ctype cUint64Large) then cUint64Large
+else raise Foreign "Unable to find type for