[haiku-commits] r37888 - in haiku/trunk: headers/posix/sys headers/private/kernel headers/private/system src/add-ons/kernel/file_systems/fat src/bin ...

  • From: zooey@xxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 4 Aug 2010 01:02:58 +0200 (CEST)

Author: zooey
Date: 2010-08-04 01:02:57 +0200 (Wed, 04 Aug 2010)
New Revision: 37888
Changeset: http://dev.haiku-os.org/changeset/37888

Modified:
   haiku/trunk/headers/posix/sys/time.h
   haiku/trunk/headers/private/kernel/real_time_clock.h
   haiku/trunk/headers/private/system/syscalls.h
   haiku/trunk/src/add-ons/kernel/file_systems/fat/util.c
   haiku/trunk/src/bin/clockconfig.cpp
   haiku/trunk/src/preferences/time/ZoneView.cpp
   haiku/trunk/src/system/kernel/real_time_clock.cpp
   haiku/trunk/src/system/libroot/posix/sys/gettimeofday.c
Log:
More consolidation of timezone code:
* dropped DaylightSavingTime from real_time_clock code in kernel, it was
  never really being used for what it meant (and just being referred to by
  gettimeofday(), which put a different meaning to it
* adjusted the syscalls get_timezone() & set_timezone() as well as their 
callers 
  accordingly
* got rid of get_rtc_info() and rtc_info struct in kernel, as it was only
  being referred to by the FAT add-on and that one (like gettimeofday()) put a
  different meaning to tz_minuteswest. Added a comment to FAT's util.c
  showing a possible solution, should the hardcoded GMT timezone pose a problem.
* fixed declaration of gettimeofday() to match POSIX base specs, issue 7
* changed implementation of gettimeofday() to not bother trying to fill struct
  timezone - it was using wrong values before, anyway.


Modified: haiku/trunk/headers/posix/sys/time.h
===================================================================
--- haiku/trunk/headers/posix/sys/time.h        2010-08-03 20:33:05 UTC (rev 
37887)
+++ haiku/trunk/headers/posix/sys/time.h        2010-08-03 23:02:57 UTC (rev 
37888)
@@ -1,6 +1,6 @@
 #ifndef _SYS_TIME_H
 #define _SYS_TIME_H
-/* 
+/*
 ** Distributed under the terms of the OpenBeOS License.
 */
 
@@ -40,7 +40,7 @@
 
 extern int     getitimer(int which, struct itimerval *value);
 extern int     setitimer(int which, const struct itimerval *value, struct 
itimerval *oldValue);
-extern int     gettimeofday(struct timeval *tv, struct timezone *tz);
+extern int     gettimeofday(struct timeval *tv, void *tz);
 
 extern int     utimes(const char *name, const struct timeval times[2]);
        /* legacy */

Modified: haiku/trunk/headers/private/kernel/real_time_clock.h
===================================================================
--- haiku/trunk/headers/private/kernel/real_time_clock.h        2010-08-03 
20:33:05 UTC (rev 37887)
+++ haiku/trunk/headers/private/kernel/real_time_clock.h        2010-08-03 
23:02:57 UTC (rev 37888)
@@ -15,14 +15,6 @@
 
 #define RTC_EPOCH_BASE_YEAR    1970
 
-typedef struct rtc_info {
-       uint32  time;
-       bool    is_gmt;
-       int32   tz_minuteswest;
-       bool    tz_dsttime;
-} rtc_info;
-
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -31,8 +23,6 @@
 bigtime_t rtc_boot_time(void);
        // Returns the time at which the system was booted in microseconds 
since Jan 1, 1970 UTC.
 
-status_t get_rtc_info(rtc_info *info);
-
 // Both functions use the passed struct tm only partially
 // (no tm_wday, tm_yday, tm_isdst).
 uint32 rtc_tm_to_secs(const struct tm *t);
@@ -40,8 +30,8 @@
 
 bigtime_t _user_system_time(void);
 status_t _user_set_real_time_clock(uint32 time);
-status_t _user_set_timezone(int32 timezoneOffset, bool daylightSavingTime);
-status_t _user_get_timezone(int32 *_timezoneOffset, bool *_daylightSavingTime);
+status_t _user_set_timezone(int32 timezoneOffset);
+status_t _user_get_timezone(int32 *_timezoneOffset);
 status_t _user_set_real_time_clock_is_gmt(bool isGMT);
 status_t _user_get_real_time_clock_is_gmt(bool *_isGMT);
 

Modified: haiku/trunk/headers/private/system/syscalls.h
===================================================================
--- haiku/trunk/headers/private/system/syscalls.h       2010-08-03 20:33:05 UTC 
(rev 37887)
+++ haiku/trunk/headers/private/system/syscalls.h       2010-08-03 23:02:57 UTC 
(rev 37888)
@@ -363,10 +363,8 @@
 
 // time functions
 extern status_t                _kern_set_real_time_clock(uint32 time);
-extern status_t                _kern_set_timezone(int32 timezoneOffset,
-                                               bool daylightSavingTime);
-extern status_t                _kern_get_timezone(int32 *_timezoneOffset,
-                                               bool *_daylightSavingTime);
+extern status_t                _kern_set_timezone(int32 timezoneOffset);
+extern status_t                _kern_get_timezone(int32 *_timezoneOffset);
 extern status_t                _kern_set_real_time_clock_is_gmt(bool isGMT);
 extern status_t                _kern_get_real_time_clock_is_gmt(bool *_isGMT);
 

Modified: haiku/trunk/src/add-ons/kernel/file_systems/fat/util.c
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/fat/util.c      2010-08-03 
20:33:05 UTC (rev 37887)
+++ haiku/trunk/src/add-ons/kernel/file_systems/fat/util.c      2010-08-03 
23:02:57 UTC (rev 37888)
@@ -69,16 +69,22 @@
 static void
 get_tzoffset()
 {
-       rtc_info info;
-
        if (tzoffset != -1)
                return;
 
-       if (get_rtc_info(&info) < 0) {
-               dprintf("error getting rtc info\n");
-       } else {
-               tzoffset = info.tz_minuteswest;
-       }
+       // tzoffset used to be set to a bogus value (timezone offset in 
seconds),
+       // we could try to use something like the following ...
+       //
+       //      int32 tzOffsetInSeconds;
+       //      if (_kern_get_timezone(&tzOffsetInSeconds) < 0) {
+       //              dprintf("error getting timezone offset\n");
+       //      } else {
+       //              tzoffset = tzOffsetInSeconds / 60;
+       //      }
+       //
+       // but I'd rather like to spare us the specific kernel call,
+       // so we hardcode the timezone (let's see if it makes any difference)
+       tzoffset = 0;
 }
 
 

Modified: haiku/trunk/src/bin/clockconfig.cpp
===================================================================
--- haiku/trunk/src/bin/clockconfig.cpp 2010-08-03 20:33:05 UTC (rev 37887)
+++ haiku/trunk/src/bin/clockconfig.cpp 2010-08-03 23:02:57 UTC (rev 37888)
@@ -68,7 +68,7 @@
                return;
        }
 
-       _kern_set_timezone(timeZoneOffset, false);
+       _kern_set_timezone(timeZoneOffset);
        printf("timezone offset is %ld seconds from GMT.\n", timeZoneOffset);
 }
 

Modified: haiku/trunk/src/preferences/time/ZoneView.cpp
===================================================================
--- haiku/trunk/src/preferences/time/ZoneView.cpp       2010-08-03 20:33:05 UTC 
(rev 37887)
+++ haiku/trunk/src/preferences/time/ZoneView.cpp       2010-08-03 23:02:57 UTC 
(rev 37888)
@@ -357,7 +357,7 @@
 
        mutable_locale_roster->SetDefaultTimeZone(timeZone);
 
-       _kern_set_timezone(timeZone.OffsetFromGMT(), false);
+       _kern_set_timezone(timeZone.OffsetFromGMT());
 
        fSetZone->SetEnabled(false);
        fLastUpdateMinute = -1;

Modified: haiku/trunk/src/system/kernel/real_time_clock.cpp
===================================================================
--- haiku/trunk/src/system/kernel/real_time_clock.cpp   2010-08-03 20:33:05 UTC 
(rev 37887)
+++ haiku/trunk/src/system/kernel/real_time_clock.cpp   2010-08-03 23:02:57 UTC 
(rev 37888)
@@ -32,7 +32,6 @@
 static struct real_time_data *sRealTimeData;
 static bool sIsGMT = false;
 static bigtime_t sTimezoneOffset = 0;
-static bool sDaylightSavingTime = false;
 
 
 /*! Write the system time to CMOS. */
@@ -129,21 +128,6 @@
 }
 
 
-status_t
-get_rtc_info(rtc_info *info)
-{
-       if (info == NULL)
-               return B_BAD_VALUE;
-
-       info->time = real_time_clock();
-       info->is_gmt = sIsGMT;
-       info->tz_minuteswest = sTimezoneOffset / 1000000LL;
-       info->tz_dsttime = sDaylightSavingTime;
-
-       return B_OK;
-}
-
-
 // #pragma mark -
 
 
@@ -202,22 +186,6 @@
 }
 
 
-//     #pragma mark -
-
-
-/*!    This is called from the gettimeofday() implementation that's part of the
-       kernel.
-*/
-status_t
-_kern_get_timezone(time_t *_timezoneOffset, bool *_daylightSavingTime)
-{
-       *_timezoneOffset = (time_t)(sTimezoneOffset / 1000000LL);
-       *_daylightSavingTime = sDaylightSavingTime;
-
-       return B_OK;
-}
-
-
 //     #pragma mark - syscalls
 
 
@@ -242,7 +210,7 @@
 
 
 status_t
-_user_set_timezone(time_t timezoneOffset, bool daylightSavingTime)
+_user_set_timezone(time_t timezoneOffset)
 {
        bigtime_t offset = (bigtime_t)timezoneOffset * 1000000LL;
 
@@ -263,7 +231,6 @@
        }
 
        sTimezoneOffset = offset;
-       sDaylightSavingTime = daylightSavingTime;
 
        TRACE(("new system_time_offset %Ld\n",
                arch_rtc_get_system_time_offset(sRealTimeData)));
@@ -273,15 +240,12 @@
 
 
 status_t
-_user_get_timezone(time_t *_timezoneOffset, bool *_daylightSavingTime)
+_user_get_timezone(time_t *_timezoneOffset)
 {
        time_t offset = (time_t)(sTimezoneOffset / 1000000LL);
 
        if (!IS_USER_ADDRESS(_timezoneOffset)
-               || !IS_USER_ADDRESS(_daylightSavingTime)
-               || user_memcpy(_timezoneOffset, &offset, sizeof(time_t)) < B_OK
-               || user_memcpy(_daylightSavingTime, &sDaylightSavingTime,
-                               sizeof(bool)) < B_OK)
+               || user_memcpy(_timezoneOffset, &offset, sizeof(time_t)) < B_OK)
                return B_BAD_ADDRESS;
 
        return B_OK;

Modified: haiku/trunk/src/system/libroot/posix/sys/gettimeofday.c
===================================================================
--- haiku/trunk/src/system/libroot/posix/sys/gettimeofday.c     2010-08-03 
20:33:05 UTC (rev 37887)
+++ haiku/trunk/src/system/libroot/posix/sys/gettimeofday.c     2010-08-03 
23:02:57 UTC (rev 37888)
@@ -9,7 +9,7 @@
 
 
 int
-gettimeofday(struct timeval *tv, struct timezone *tz)
+gettimeofday(struct timeval *tv, void *tz)
 {
        if (tv != NULL) {
                bigtime_t usecs = real_time_clock_usecs();
@@ -18,14 +18,8 @@
                tv->tv_usec = usecs % 1000000;
        }
 
-       if (tz != NULL) {
-               time_t timezoneOffset;
-               bool daylightSavingTime;
-               _kern_get_timezone(&timezoneOffset, &daylightSavingTime);
+       // struct timezone (tz) has been deprecated since long and its exact
+       // semantics are a bit unclear, so we need not bother to deal with it
 
-               tz->tz_minuteswest = timezoneOffset;
-               tz->tz_dsttime = daylightSavingTime;
-       }
-
        return 0;
 }


Other related posts: