On Fri, Aug 16, 2013 at 11:41:34AM +0200, David Coppa wrote:
> > Otherwise, ghc assumes time_t is long.
> >
> > [1] Adapted from the larger diff at
> > https://raw.github.com/iquiw/ghc-NetBSD-patches/master/ghc-7.6.2-NetBSD.patch
>
> New diff that adds the configure.ac bits, just because I'm unsure
> if they'd be needed or not...
Not during a normal build, I guess. But it may be used when building
a new bootstrapper. So it's ok to include it.
> Index: patches/patch-libraries_time_Data_Time_Clock_CTimeval_hs
> ===================================================================
> RCS file: patches/patch-libraries_time_Data_Time_Clock_CTimeval_hs
> diff -N patches/patch-libraries_time_Data_Time_Clock_CTimeval_hs
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-libraries_time_Data_Time_Clock_CTimeval_hs 16 Aug 2013
> 09:32:34 -0000
> @@ -0,0 +1,52 @@
> +$OpenBSD$
> +--- libraries/time/Data/Time/Clock/CTimeval.hs.orig Mon Oct 31 01:39:22 2011
> ++++ libraries/time/Data/Time/Clock/CTimeval.hs Fri Aug 16 09:53:12 2013
> +@@ -7,18 +7,42 @@ module Data.Time.Clock.CTimeval where
> + import Foreign
> + import Foreign.C
> +
> +-data CTimeval = MkCTimeval CLong CLong
> ++#include "HsTimeConfig.h"
> +
> ++--
> ++-- we assume time_t and suseconds_t are either long long, long or int.
> ++--
> ++#ifndef SIZEOF_TIME_T
> ++#error "SIZEOF_TIME_T is not defined!"
> ++#endif
> ++#if SIZEOF_TIME_T == SIZEOF_LONG_LONG
> ++type TimeT = CLLong
> ++#elif SIZEOF_TIME_T == SIZEOF_LONG
> ++type TimeT = CLong
> ++#elif SIZEOF_TIME_T == SIZEOF_INT
> ++type TimeT = CInt
> ++#endif
> ++
> ++#if SIZEOF_SUSECONDS_T == SIZEOF_LONG_LONG
> ++type SusecondsT = CLLong
> ++#elif SIZEOF_SUSECONDS_T == SIZEOF_LONG
> ++type SusecondsT = CLong
> ++#elif SIZEOF_SUSECONDS_T == SIZEOF_INT
> ++type SusecondsT = CInt
> ++#endif
> ++
> ++data CTimeval = MkCTimeval TimeT SusecondsT
> ++
> + instance Storable CTimeval where
> +- sizeOf _ = (sizeOf (undefined :: CLong)) * 2
> ++ sizeOf _ = sizeOf (undefined :: TimeT) + sizeOf (undefined ::
> SusecondsT)
> + alignment _ = alignment (undefined :: CLong)
Is that the correct alignment?
I'd prefer to run some tests on amd64 and i386 before this goes in
(unless someone beats me doing tests).
Ciao,
Kili