libgimp: Do not try to include sys/time.h on Windows

Code taken from: https://gist.github.com/ugovaretto/5875385
We already do that on babl repo.

It does not exist on such platform. What MINGW do on
the pseudo-header is to implement a wrapper to
native Windows functions.
This commit is contained in:
Bruno Lopes 2025-11-28 18:24:47 -03:00
parent 452f9a3951
commit ffcbf8b5dc
No known key found for this signature in database
2 changed files with 57 additions and 0 deletions

View file

@ -21,7 +21,18 @@
#include "config.h"
#include <string.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#if defined(_WIN32) && !defined(HAVE_SYS_TIME_H)
#include <time.h>
#include <windows.h>
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif
#endif
#include <gexiv2/gexiv2.h>
@ -619,6 +630,50 @@ gimp_image_metadata_set_xmp_structs (GList *xmp_list,
return exclude;
}
#if defined(_WIN32) && ! defined(HAVE_SYS_TIME_H)
struct timezone
{
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
int
gettimeofday (struct timeval *tv, struct timezone *tz)
{
FILETIME ft;
unsigned __int64 tmpres = 0;
static int tzflag = 0;
if (NULL != tv)
{
GetSystemTimeAsFileTime (&ft);
tmpres |= ft.dwHighDateTime;
tmpres <<= 32;
tmpres |= ft.dwLowDateTime;
tmpres /= 10; /*convert into microseconds*/
/*converting file time to unix epoch*/
tmpres -= DELTA_EPOCH_IN_MICROSECS;
tv->tv_sec = (long) (tmpres / 1000000UL);
tv->tv_usec = (long) (tmpres % 1000000UL);
}
if (NULL != tz)
{
if (! tzflag)
{
_tzset ();
tzflag++;
}
tz->tz_minuteswest = _timezone / 60;
tz->tz_dsttime = _daylight;
}
return 0;
}
#endif
/**
* gimp_image_metadata_save_filter:
* @image: The actually saved image

View file

@ -21,7 +21,9 @@
#include "config.h"
#include <string.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <gexiv2/gexiv2.h>