From d5893dc5565da3dfa0e398cdcf7dd888200eb009 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 9 May 2006 09:24:27 +0000 Subject: [PATCH] add CIntPtr, CUIntPtr, CIntMax, CUIntMax types --- Foreign/C/Types.hs | 16 +++++++++++++++- aclocal.m4 | 8 ++++++++ configure.ac | 5 +++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Foreign/C/Types.hs b/Foreign/C/Types.hs index b897718..625c4b3 100644 --- a/Foreign/C/Types.hs +++ b/Foreign/C/Types.hs @@ -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 diff --git a/aclocal.m4 b/aclocal.m4 index d03e738..49ad919 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -105,6 +105,14 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[#include # include #endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif + #if defined(HAVE_GL_GL_H) # include #elif defined(HAVE_OPENGL_GL_H) diff --git a/configure.ac b/configure.ac index bf75f80..be50d70 100644 --- a/configure.ac +++ b/configure.ac @@ -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 #include ]) -- 1.7.10.4