On Fri, 16 Aug 2013, David Coppa wrote: > > As already pointed out to Matthias some time ago, I think we'll > want the diff[1] below. > > 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... 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) + peek p = do +- s <- peekElemOff (castPtr p) 0 +- mus <- peekElemOff (castPtr p) 1 ++ s <- peekByteOff p 0 ++ mus <- peekByteOff p (sizeOf (undefined :: TimeT)) + return (MkCTimeval s mus) + poke p (MkCTimeval s mus) = do +- pokeElemOff (castPtr p) 0 s +- pokeElemOff (castPtr p) 1 mus ++ pokeByteOff p 0 s ++ pokeByteOff p (sizeOf (undefined :: TimeT)) mus + + foreign import ccall unsafe "time.h gettimeofday" gettimeofday :: Ptr CTimeval -> Ptr () -> IO CInt + Index: patches/patch-libraries_time_configure =================================================================== RCS file: patches/patch-libraries_time_configure diff -N patches/patch-libraries_time_configure --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-libraries_time_configure 16 Aug 2013 09:32:35 -0000 @@ -0,0 +1,340 @@ +$OpenBSD$ +--- libraries/time/configure.orig Fri Apr 19 00:47:17 2013 ++++ libraries/time/configure Fri Aug 16 09:53:12 2013 +@@ -1712,6 +1712,184 @@ $as_echo "$ac_res" >&6; } + + } # ac_fn_c_check_func + ++# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES ++# -------------------------------------------- ++# Tries to find the compile-time value of EXPR in a program that includes ++# INCLUDES, setting VAR accordingly. Returns whether the value could be ++# computed ++ac_fn_c_compute_int () ++{ ++ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack ++ if test "$cross_compiling" = yes; then ++ # Depending upon the size, compute the lo and hi bounds. ++cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) >= 0)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_lo=0 ac_mid=0 ++ while :; do ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) <= $ac_mid)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_hi=$ac_mid; break ++else ++ as_fn_arith $ac_mid + 1 && ac_lo=$as_val ++ if test $ac_lo -le $ac_mid; then ++ ac_lo= ac_hi= ++ break ++ fi ++ as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ done ++else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) < 0)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_hi=-1 ac_mid=-1 ++ while :; do ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) >= $ac_mid)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_lo=$ac_mid; break ++else ++ as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val ++ if test $ac_mid -le $ac_hi; then ++ ac_lo= ac_hi= ++ break ++ fi ++ as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ done ++else ++ ac_lo= ac_hi= ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++# Binary search between lo and hi bounds. ++while test "x$ac_lo" != "x$ac_hi"; do ++ as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++int ++main () ++{ ++static int test_array [1 - 2 * !(($2) <= $ac_mid)]; ++test_array [0] = 0 ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ ac_hi=$ac_mid ++else ++ as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++done ++case $ac_lo in #(( ++?*) eval "$3=\$ac_lo"; ac_retval=0 ;; ++'') ac_retval=1 ;; ++esac ++ else ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++$4 ++static long int longval () { return $2; } ++static unsigned long int ulongval () { return $2; } ++#include <stdio.h> ++#include <stdlib.h> ++int ++main () ++{ ++ ++ FILE *f = fopen ("conftest.val", "w"); ++ if (! f) ++ return 1; ++ if (($2) < 0) ++ { ++ long int i = longval (); ++ if (i != ($2)) ++ return 1; ++ fprintf (f, "%ld", i); ++ } ++ else ++ { ++ unsigned long int i = ulongval (); ++ if (i != ($2)) ++ return 1; ++ fprintf (f, "%lu", i); ++ } ++ /* Do not output a trailing newline, as this causes \r\n confusion ++ on some platforms. */ ++ return ferror (f) || fclose (f) != 0; ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_run "$LINENO"; then : ++ echo >>conftest.val; read $3 <conftest.val; ac_retval=0 ++else ++ ac_retval=1 ++fi ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ ++ conftest.$ac_objext conftest.beam conftest.$ac_ext ++rm -f conftest.val ++ ++ fi ++ eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} ++ as_fn_set_status $ac_retval ++ ++} # ac_fn_c_compute_int ++ + # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES + # ---------------------------------------------------- + # Tries to find if the field MEMBER exists in type AGGR, after including +@@ -3391,6 +3569,151 @@ _ACEOF + + fi + done ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5 ++$as_echo_n "checking size of time_t... " >&6; } ++if test "${ac_cv_sizeof_time_t+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_time_t" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error 77 "cannot compute sizeof (time_t) ++See \`config.log' for more details" "$LINENO" 5; } ++ else ++ ac_cv_sizeof_time_t=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5 ++$as_echo "$ac_cv_sizeof_time_t" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_TIME_T $ac_cv_sizeof_time_t ++_ACEOF ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of suseconds_t" >&5 ++$as_echo_n "checking size of suseconds_t... " >&6; } ++if test "${ac_cv_sizeof_suseconds_t+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (suseconds_t))" "ac_cv_sizeof_suseconds_t" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_suseconds_t" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error 77 "cannot compute sizeof (suseconds_t) ++See \`config.log' for more details" "$LINENO" 5; } ++ else ++ ac_cv_sizeof_suseconds_t=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_suseconds_t" >&5 ++$as_echo "$ac_cv_sizeof_suseconds_t" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_SUSECONDS_T $ac_cv_sizeof_suseconds_t ++_ACEOF ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 ++$as_echo_n "checking size of int... " >&6; } ++if test "${ac_cv_sizeof_int+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_int" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error 77 "cannot compute sizeof (int) ++See \`config.log' for more details" "$LINENO" 5; } ++ else ++ ac_cv_sizeof_int=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 ++$as_echo "$ac_cv_sizeof_int" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_INT $ac_cv_sizeof_int ++_ACEOF ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 ++$as_echo_n "checking size of long... " >&6; } ++if test "${ac_cv_sizeof_long+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_long" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error 77 "cannot compute sizeof (long) ++See \`config.log' for more details" "$LINENO" 5; } ++ else ++ ac_cv_sizeof_long=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 ++$as_echo "$ac_cv_sizeof_long" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_LONG $ac_cv_sizeof_long ++_ACEOF ++ ++ ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 ++$as_echo_n "checking size of long long... " >&6; } ++if test "${ac_cv_sizeof_long_long+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : ++ ++else ++ if test "$ac_cv_type_long_long" = yes; then ++ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 ++$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} ++as_fn_error 77 "cannot compute sizeof (long long) ++See \`config.log' for more details" "$LINENO" 5; } ++ else ++ ac_cv_sizeof_long_long=0 ++ fi ++fi ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 ++$as_echo "$ac_cv_sizeof_long_long" >&6; } ++ ++ ++ ++cat >>confdefs.h <<_ACEOF ++#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long ++_ACEOF ++ + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 Index: patches/patch-libraries_time_configure_ac =================================================================== RCS file: patches/patch-libraries_time_configure_ac diff -N patches/patch-libraries_time_configure_ac --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-libraries_time_configure_ac 16 Aug 2013 09:32:35 -0000 @@ -0,0 +1,15 @@ +$OpenBSD$ +--- libraries/time/configure.ac.orig Fri Aug 16 11:30:28 2013 ++++ libraries/time/configure.ac Fri Aug 16 11:30:55 2013 +@@ -12,6 +12,11 @@ AC_CONFIG_HEADERS([include/HsTimeConfig.h]) + + AC_CHECK_HEADERS([time.h]) + AC_CHECK_FUNCS([gmtime_r localtime_r]) ++AC_CHECK_SIZEOF([time_t]) ++AC_CHECK_SIZEOF([suseconds_t]) ++AC_CHECK_SIZEOF([int]) ++AC_CHECK_SIZEOF([long]) ++AC_CHECK_SIZEOF([long long]) + + AC_STRUCT_TM + AC_STRUCT_TIMEZONE Index: patches/patch-libraries_time_include_HsTimeConfig_h_in =================================================================== RCS file: patches/patch-libraries_time_include_HsTimeConfig_h_in diff -N patches/patch-libraries_time_include_HsTimeConfig_h_in --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-libraries_time_include_HsTimeConfig_h_in 16 Aug 2013 09:32:35 -0000 @@ -0,0 +1,25 @@ +$OpenBSD$ +--- libraries/time/include/HsTimeConfig.h.in.orig Fri Aug 16 09:53:58 2013 ++++ libraries/time/include/HsTimeConfig.h.in Fri Aug 16 09:54:39 2013 +@@ -58,6 +58,21 @@ + /* Define to 1 if you have the <unistd.h> header file. */ + #undef HAVE_UNISTD_H + ++/* The size of `int', as computed by sizeof. */ ++#undef SIZEOF_INT ++ ++/* The size of `long', as computed by sizeof. */ ++#undef SIZEOF_LONG ++ ++/* The size of `long long', as computed by sizeof. */ ++#undef SIZEOF_LONG_LONG ++ ++/* The size of `suseconds_t', as computed by sizeof. */ ++#undef SIZEOF_SUSECONDS_T ++ ++/* The size of `time_t', as computed by sizeof. */ ++#undef SIZEOF_TIME_T ++ + /* Define to the address where bug reports for this package should be sent. */ + #undef PACKAGE_BUGREPORT +