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
This commit is contained in:
Axel Dörfler 2006-03-14 14:29:56 +00:00
parent 33dd85501f
commit f46bdd1c9a
3 changed files with 32 additions and 13 deletions

View File

@ -1,6 +1,8 @@
/* /*
** Copyright 2003, Jeff Ward, jeff@r2d2.stcloudstate.edu. All rights reserved. * Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License. * 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 #ifndef _KERNEL_REAL_TIME_CLOCK_H
#define _KERNEL_REAL_TIME_CLOCK_H #define _KERNEL_REAL_TIME_CLOCK_H
@ -13,6 +15,14 @@
#define RTC_EPOCHE_BASE_YEAR 1970 #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 #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -21,13 +31,6 @@ status_t rtc_init(kernel_args *args);
bigtime_t rtc_boot_time(void); bigtime_t rtc_boot_time(void);
// Returns the time at which the system was booted in microseconds since Jan 1, 1970 UTC. // 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); status_t get_rtc_info(rtc_info *info);
// Both functions use the passed struct tm only partially // 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); bigtime_t _user_system_time(void);
status_t _user_set_real_time_clock(uint32 time); status_t _user_set_real_time_clock(uint32 time);
status_t _user_set_timezone(int32 timezoneOffset, bool daylightSavingTime); 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_set_tzfilename(const char* filename, size_t length, bool isGMT);
status_t _user_get_tzfilename(char *filename, size_t length, bool *_isGMT); status_t _user_get_tzfilename(char *filename, size_t length, bool *_isGMT);

View File

@ -208,6 +208,7 @@ extern status_t _kern_stop_watching(dev_t device, ino_t node, uint32 flags,
// time functions // time functions
extern status_t _kern_set_real_time_clock(uint32 time); extern status_t _kern_set_real_time_clock(uint32 time);
extern status_t _kern_set_timezone(int32 timezoneOffset, bool daylightSavingTime); 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_set_tzfilename(const char *filename, size_t length, bool isGMT);
extern status_t _kern_get_tzfilename(char *filename, size_t length, bool *_isGMT); extern status_t _kern_get_tzfilename(char *filename, size_t length, bool *_isGMT);

View File

@ -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. * Copyright 2003, Jeff Ward, jeff@r2d2.stcloudstate.edu. All rights reserved.
* *
* Distributed under the terms of the MIT License. * 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 status_t
_user_set_tzfilename(const char *filename, size_t length, bool isGMT) _user_set_tzfilename(const char *filename, size_t length, bool isGMT)
{ {