added more for OS/2

This commit is contained in:
2011-03-16 09:20:03 +00:00
parent 3822b48eea
commit 8869368a02
6 changed files with 124 additions and 49 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: time.c 287 2009-09-15 10:01:02Z hyunghwan.chung $
* $Id: time.c 398 2011-03-15 15:20:03Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -21,8 +21,10 @@
#include <qse/cmn/time.h>
#include "mem.h"
#ifdef _WIN32
# include <windows.h>
#if defined(_WIN32)
# include <windows.h>
#elif defined(__OS2__)
# include <os2.h>
#else
# include "syscall.h"
# include <sys/time.h>
@ -73,7 +75,7 @@ static int get_leap_days (int fy, int ty)
int qse_gettime (qse_ntime_t* t)
{
#ifdef _WIN32
#if defined(_WIN32)
SYSTEMTIME st;
FILETIME ft;
@ -86,7 +88,10 @@ int qse_gettime (qse_ntime_t* t)
if (SystemTimeToFileTime (&st, &ft) == FALSE) return -1;
*t = ((qse_ntime_t)(*((qse_int64_t*)&ft)) / (10 * 1000));
*t -= EPOCH_DIFF_MSECS;
return 0;
return 0;
#elif defined(__OS2__)
/* TODO: implement this */
return -1;
#else
struct timeval tv;
int n;
@ -102,14 +107,17 @@ int qse_gettime (qse_ntime_t* t)
int qse_settime (qse_ntime_t t)
{
#ifdef _WIN32
#if defined(_WIN32)
FILETIME ft;
SYSTEMTIME st;
*((qse_int64_t*)&ft) = ((t + EPOCH_DIFF_MSECS) * (10 * 1000));
if (FileTimeToSystemTime (&ft, &st) == FALSE) return -1;
if (SetSystemTime(&st) == FALSE) return -1;
return 0;
return 0;
#elif defined(__OS2__)
/* TODO: implement this */
return -1;
#else
struct timeval tv;
int n;
@ -215,8 +223,9 @@ int qse_localtime (qse_ntime_t nt, qse_btime_t* bt)
qse_ntime_t rem = nt % QSE_MSECS_PER_SEC;
/* TODO: remove dependency on localtime/localtime_r */
#ifdef _WIN32
tm = localtime (&t);
#if defined(_WIN32)
tm = localtime (&t);
#elif defined(__OS2__)
#else
struct tm btm;
tm = localtime_r (&t, &btm);