From f46bdd1c9ada5b6bc8641a6ef74c870c9eb26421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 14 Mar 2006 14:29:56 +0000 Subject: [PATCH] Added a _kern_get_timezone() syscall that can be used without needing to re-evaluate the timezone file over and over. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16785 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/real_time_clock.h | 26 ++++++++++++++---------- headers/private/kernel/syscalls.h | 1 + src/system/kernel/real_time_clock.c | 18 ++++++++++++++-- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/headers/private/kernel/real_time_clock.h b/headers/private/kernel/real_time_clock.h index c70bf89ff0..4e48aeef1c 100644 --- a/headers/private/kernel/real_time_clock.h +++ b/headers/private/kernel/real_time_clock.h @@ -1,7 +1,9 @@ -/* -** Copyright 2003, Jeff Ward, jeff@r2d2.stcloudstate.edu. All rights reserved. -** Distributed under the terms of the Haiku License. -*/ +/* + * Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Copyright 2003, Jeff Ward, jeff@r2d2.stcloudstate.edu. All rights reserved. + * + * Distributed under the terms of the MIT License. + */ #ifndef _KERNEL_REAL_TIME_CLOCK_H #define _KERNEL_REAL_TIME_CLOCK_H @@ -13,6 +15,14 @@ #define RTC_EPOCHE_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 @@ -21,13 +31,6 @@ status_t rtc_init(kernel_args *args); bigtime_t rtc_boot_time(void); // Returns the time at which the system was booted in microseconds since Jan 1, 1970 UTC. -typedef struct rtc_info { - uint32 time; - bool is_gmt; - int32 tz_minuteswest; - bool tz_dsttime; -} rtc_info; - status_t get_rtc_info(rtc_info *info); // Both functions use the passed struct tm only partially @@ -38,6 +41,7 @@ void rtc_secs_to_tm(uint32 seconds, struct tm *t); 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_tzfilename(const char* filename, size_t length, bool isGMT); status_t _user_get_tzfilename(char *filename, size_t length, bool *_isGMT); diff --git a/headers/private/kernel/syscalls.h b/headers/private/kernel/syscalls.h index 92a69098e0..71f4a0ed4d 100644 --- a/headers/private/kernel/syscalls.h +++ b/headers/private/kernel/syscalls.h @@ -208,6 +208,7 @@ extern status_t _kern_stop_watching(dev_t device, ino_t node, uint32 flags, // 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_tzfilename(const char *filename, size_t length, bool isGMT); extern status_t _kern_get_tzfilename(char *filename, size_t length, bool *_isGMT); diff --git a/src/system/kernel/real_time_clock.c b/src/system/kernel/real_time_clock.c index fd377d13f1..2ab9aef28d 100644 --- a/src/system/kernel/real_time_clock.c +++ b/src/system/kernel/real_time_clock.c @@ -1,5 +1,5 @@ -/* - * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +/* + * Copyright 2004-2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved. * Copyright 2003, Jeff Ward, jeff@r2d2.stcloudstate.edu. All rights reserved. * * Distributed under the terms of the MIT License. @@ -341,6 +341,20 @@ _user_set_timezone(time_t timezoneOffset, bool daylightSavingTime) } +status_t +_user_get_timezone(time_t *_timezoneOffset, bool *_daylightSavingTime) +{ + 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) + return B_BAD_ADDRESS; + + return B_OK; +} + + status_t _user_set_tzfilename(const char *filename, size_t length, bool isGMT) {