mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
w32: Add implementation of gmtime_r, localtime_r
Those functions are missing in MinGW. Some versions of MinGW-w64 include defines for gmtime_r and localtime_r. Older versions of these macros are buggy (they return a pointer to a static variable), therefore we don't want them. Newer versions are similar to the code used here, but without the memset. The implementation which is used here is not strictly reentrant, but sufficiently good for QEMU on w32 or w64. Signed-off-by: Stefan Weil <sw@weilnetz.de> [blauwirbel@gmail.com: added comment about locking] Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
93b6599734
commit
d3e8f95753
2 changed files with 30 additions and 0 deletions
|
@ -74,6 +74,30 @@ void qemu_vfree(void *ptr)
|
|||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
}
|
||||
|
||||
/* FIXME: add proper locking */
|
||||
struct tm *gmtime_r(const time_t *timep, struct tm *result)
|
||||
{
|
||||
struct tm *p = gmtime(timep);
|
||||
memset(result, 0, sizeof(*result));
|
||||
if (p) {
|
||||
*result = *p;
|
||||
p = result;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/* FIXME: add proper locking */
|
||||
struct tm *localtime_r(const time_t *timep, struct tm *result)
|
||||
{
|
||||
struct tm *p = localtime(timep);
|
||||
memset(result, 0, sizeof(*result));
|
||||
if (p) {
|
||||
*result = *p;
|
||||
p = result;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void socket_set_block(int fd)
|
||||
{
|
||||
unsigned long opt = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue