1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Added stubs for gmtime(3), localtime(3) and utime(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2012-05-29 00:27:06 +02:00
parent 45981431de
commit 622e0176e3
2 changed files with 54 additions and 0 deletions

View file

@ -44,9 +44,22 @@ struct tm
int tm_isdst;
};
struct utimbuf
{
time_t actime;
time_t modtime;
};
clock_t clock(void);
time_t time(time_t* t);
char* ctime(const time_t* timep);
struct tm* localtime_r(const time_t* timer, struct tm* ret);
struct tm* gmtime_r(const time_t* timer, struct tm* ret);
#if !defined(_SORTIX_SOURCE)
struct tm* localtime(const time_t* timer);
struct tm* gmtime(const time_t* timer);
#endif
int utime(const char* filepath, const struct utimbuf* times);
__END_DECLS

View file

@ -64,9 +64,50 @@ namespace Maxsi
return t ? *t = result : result;
}
extern "C" struct tm* localtime_r(const time_t* timer, struct tm* ret)
{
time_t time = *timer;
ret->tm_sec = time % 60; // No leap seconds.
ret->tm_min = (time / 60) % 60;
ret->tm_hour = (time / 60 / 60) % 24;
ret->tm_mday = 0;
ret->tm_mon = 0;
ret->tm_year = 0;
ret->tm_wday = 0;
ret->tm_isdst = 0;
return ret;
}
extern "C" struct tm* gmtime_r(const time_t* timer, struct tm* ret)
{
return localtime_r(timer, ret);
}
// TODO: Who the hell designed the below two functions? I vote that
// these be removed from Sortix soon - although that'd require fixing
// a lot of applications..
extern "C" struct tm* localtime(const time_t* timer)
{
static struct tm hack_localtime_ret;
return localtime_r(timer, &hack_localtime_ret);
}
extern "C" struct tm* gmtime(const time_t* timer)
{
static struct tm hack_gmtime_ret;
return gmtime_r(timer, &hack_gmtime_ret);
}
extern "C" char* ctime(const time_t* /*timep*/)
{
return (char*) "ctime(3) is not implemented";
}
extern "C" int utime(const char* filepath, const struct utimbuf* times)
{
// TODO: Sure, I did that! There is no kernel support for this yet.
return 0;
}
}
}