add CIntPtr, CUIntPtr, CIntMax, CUIntMax types
authorSimon Marlow <simonmar@microsoft.com>
Tue, 9 May 2006 09:24:27 +0000 (09:24 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Tue, 9 May 2006 09:24:27 +0000 (09:24 +0000)
Foreign/C/Types.hs
aclocal.m4
configure.ac

index b897718..625c4b3 100644 (file)
@@ -30,6 +30,8 @@ module Foreign.C.Types
        , CLong,  CULong
        , CPtrdiff, CSize, CWchar, CSigAtomic
         , CLLong, CULLong
+       , CIntPtr, CUIntPtr
+       , CIntMax, CUIntMax
 
          -- ** Numeric types
          -- | These types are are represented as @newtype@s of basic
@@ -191,8 +193,20 @@ data CFpos = CFpos
 -- | Haskell type representing the C @jmp_buf@ type.
 data CJmpBuf = CJmpBuf
 
+INTEGRAL_TYPE(CIntPtr,tyConCIntPtr,"CIntPtr",HTYPE_INTPTR_T)
+INTEGRAL_TYPE(CUIntPtr,tyConCUIntPtr,"CUIntPtr",HTYPE_UINTPTR_T)
+INTEGRAL_TYPE(CIntMax,tyConCIntMax,"CIntMax",HTYPE_INTMAX_T)
+INTEGRAL_TYPE(CUIntMax,tyConCUIntMax,"CUIntMax",HTYPE_UINTMAX_T)
+
+{-# RULES
+"fromIntegral/a->CIntPtr"  fromIntegral = \x -> CIntPtr  (fromIntegral x)
+"fromIntegral/a->CUIntPtr" fromIntegral = \x -> CUIntPtr (fromIntegral x)
+"fromIntegral/a->CIntMax"  fromIntegral = \x -> CIntMax  (fromIntegral x)
+"fromIntegral/a->CUIntMax" fromIntegral = \x -> CUIntMax (fromIntegral x)
+ #-}
+
 -- C99 types which are still missing include:
--- intptr_t, uintptr_t, intmax_t, uintmax_t, wint_t, wctrans_t, wctype_t
+-- wint_t, wctrans_t, wctype_t
 
 {- $ctypes
 
index d03e738..49ad919 100644 (file)
@@ -105,6 +105,14 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
 # include <ctype.h>
 #endif
 
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+#  include <stdint.h>
+# endif
+#endif
+
 #if defined(HAVE_GL_GL_H)
 # include <GL/gl.h>
 #elif defined(HAVE_OPENGL_GL_H)
index bf75f80..be50d70 100644 (file)
@@ -67,6 +67,11 @@ FPTOOLS_CHECK_HTYPE(ssize_t)
 FPTOOLS_CHECK_HTYPE(rlim_t)
 FPTOOLS_CHECK_HTYPE(wint_t)
 
+FPTOOLS_CHECK_HTYPE(intptr_t)
+FPTOOLS_CHECK_HTYPE(uintptr_t)
+FPTOOLS_CHECK_HTYPE(intmax_t)
+FPTOOLS_CHECK_HTYPE(uintmax_t)
+
 # test errno values
 FP_CHECK_CONSTS([E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EADV EAFNOSUPPORT EAGAIN EALREADY EBADF EBADMSG EBADRPC EBUSY ECHILD ECOMM ECONNABORTED ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDIRTY EDOM EDQUOT EEXIST EFAULT EFBIG EFTYPE EHOSTDOWN EHOSTUNREACH EIDRM EILSEQ EINPROGRESS EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK EMSGSIZE EMULTIHOP ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH ENFILE ENOBUFS ENODATA ENODEV ENOENT ENOEXEC ENOLCK ENOLINK ENOMEM ENOMSG ENONET ENOPROTOOPT ENOSPC ENOSR ENOSTR ENOSYS ENOTBLK ENOTCONN ENOTDIR ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM EPFNOSUPPORT EPIPE EPROCLIM EPROCUNAVAIL EPROGMISMATCH EPROGUNAVAIL EPROTO EPROTONOSUPPORT EPROTOTYPE ERANGE EREMCHG EREMOTE EROFS ERPCMISMATCH ERREMOTE ESHUTDOWN ESOCKTNOSUPPORT ESPIPE ESRCH ESRMNT ESTALE ETIME ETIMEDOUT ETOOMANYREFS ETXTBSY EUSERS EWOULDBLOCK EXDEV ENOCIGAR], [#include <stdio.h>
 #include <errno.h>])