Ticket #4970: 0001-Use-CSUSeconds-rather-than-CTime-in-getClockTime.-Fi.patch

File 0001-Use-CSUSeconds-rather-than-CTime-in-getClockTime.-Fi.patch, 1.2 KB (added by altaic, 2 years ago)

git patch #4

  • System/Time.hsc

    From 552362ac1fcce0b8dcec5917c81d4c16682aa992 Mon Sep 17 00:00:00 2001
    From: William Knop <william.knop.nospam@gmail.com>
    Date: Mon, 4 Apr 2011 21:15:27 -0400
    Subject: [PATCH] Use CSUSeconds rather than CTime in getClockTime. Fixes #4970.
    
    The tv_usec field of struct timeval was incorrectly used as C type time_t; the actual C type is suseconds_t. On OS X, time_t is longer than suseconds_t, which caused garbage bits to be copied as reported in trace #4247 and #4970. This is patch 4 of 4 to fix those tickets.
    ---
     System/Time.hsc |    2 +-
     1 files changed, 1 insertions(+), 1 deletions(-)
    
    diff --git a/System/Time.hsc b/System/Time.hsc
    index 663e875..ecd83c2 100644
    a b  
    250250  allocaBytes (#const sizeof(struct timeval)) $ \ p_timeval -> do 
    251251    throwErrnoIfMinus1_ "getClockTime" $ gettimeofday p_timeval nullPtr 
    252252    sec  <- (#peek struct timeval,tv_sec)  p_timeval :: IO CTime 
    253     usec <- (#peek struct timeval,tv_usec) p_timeval :: IO CTime 
     253    usec <- (#peek struct timeval,tv_usec) p_timeval :: IO CSUSeconds 
    254254    return (TOD (realToInteger sec) ((realToInteger usec) * 1000000)) 
    255255  
    256256#elif HAVE_FTIME