win64: use new headers from mingw
This commit is contained in:
@ -1,219 +1,286 @@
|
||||
/*
|
||||
* time.h
|
||||
*
|
||||
* Date and time functions and types.
|
||||
*
|
||||
* This file is part of the Mingw32 package.
|
||||
*
|
||||
* Contributors:
|
||||
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
|
||||
*
|
||||
* THIS SOFTWARE IS NOT COPYRIGHTED
|
||||
*
|
||||
* This source code is offered for use in the public domain. You may
|
||||
* use, modify or distribute it freely.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful but
|
||||
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
||||
* DISCLAIMED. This includes but is not limited to warranties of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Author: bellard $
|
||||
* $Date: 2005/04/17 13:14:29 $
|
||||
*
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the w64 mingw-runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
#ifndef _TIME_H_
|
||||
#define _TIME_H_
|
||||
|
||||
#ifndef _TIME_H_
|
||||
#define _TIME_H_
|
||||
|
||||
/* All the headers include this file. */
|
||||
#include <_mingw.h>
|
||||
|
||||
#define __need_wchar_t
|
||||
#define __need_size_t
|
||||
#ifndef RC_INVOKED
|
||||
#include <stddef.h>
|
||||
#endif /* Not RC_INVOKED */
|
||||
|
||||
/*
|
||||
* Need a definition of time_t.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Number of clock ticks per second. A clock tick is the unit by which
|
||||
* processor time is measured and is returned by 'clock'.
|
||||
*/
|
||||
#define CLOCKS_PER_SEC ((clock_t)1000)
|
||||
#define CLK_TCK CLOCKS_PER_SEC
|
||||
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
/*
|
||||
* A type for storing the current time and date. This is the number of
|
||||
* seconds since midnight Jan 1, 1970.
|
||||
* NOTE: Normally this is defined by the above include of sys/types.h
|
||||
*/
|
||||
#ifndef _TIME_T_DEFINED
|
||||
typedef long time_t;
|
||||
#define _TIME_T_DEFINED
|
||||
#ifndef _WIN32
|
||||
#error Only Win32 target is supported!
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A type for measuring processor time (in clock ticks).
|
||||
*/
|
||||
#ifndef _CLOCK_T_DEFINED
|
||||
typedef long clock_t;
|
||||
#define _CLOCK_T_DEFINED
|
||||
#endif
|
||||
#pragma pack(push,_CRT_PACKING)
|
||||
|
||||
|
||||
/*
|
||||
* A structure for storing all kinds of useful information about the
|
||||
* current (or another) time.
|
||||
*/
|
||||
struct tm
|
||||
{
|
||||
int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */
|
||||
int tm_min; /* Minutes: 0-59 */
|
||||
int tm_hour; /* Hours since midnight: 0-23 */
|
||||
int tm_mday; /* Day of the month: 1-31 */
|
||||
int tm_mon; /* Months *since* january: 0-11 */
|
||||
int tm_year; /* Years since 1900 */
|
||||
int tm_wday; /* Days since Sunday (0-6) */
|
||||
int tm_yday; /* Days since Jan. 1: 0-365 */
|
||||
int tm_isdst; /* +1 Daylight Savings Time, 0 No DST,
|
||||
* -1 don't know */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
clock_t clock (void);
|
||||
time_t time (time_t*);
|
||||
double difftime (time_t, time_t);
|
||||
time_t mktime (struct tm*);
|
||||
|
||||
/*
|
||||
* These functions write to and return pointers to static buffers that may
|
||||
* be overwritten by other function calls. Yikes!
|
||||
*
|
||||
* NOTE: localtime, and perhaps the others of the four functions grouped
|
||||
* below may return NULL if their argument is not 'acceptable'. Also note
|
||||
* that calling asctime with a NULL pointer will produce an Invalid Page
|
||||
* Fault and crap out your program. Guess how I know. Hint: stat called on
|
||||
* a directory gives 'invalid' times in st_atime etc...
|
||||
*/
|
||||
char* asctime (const struct tm*);
|
||||
char* ctime (const time_t*);
|
||||
struct tm* gmtime (const time_t*);
|
||||
struct tm* localtime (const time_t*);
|
||||
|
||||
|
||||
size_t strftime (char*, size_t, const char*, const struct tm*);
|
||||
|
||||
size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*);
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
extern void _tzset (void);
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
extern void tzset (void);
|
||||
#ifndef _CRTIMP
|
||||
#define _CRTIMP __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
size_t strftime(char*, size_t, const char*, const struct tm*);
|
||||
char* _strdate(char*);
|
||||
char* _strtime(char*);
|
||||
#ifndef _WCHAR_T_DEFINED
|
||||
#define _WCHAR_T_DEFINED
|
||||
typedef unsigned short wchar_t;
|
||||
#endif
|
||||
|
||||
#endif /* Not __STRICT_ANSI__ */
|
||||
#ifndef _TIME32_T_DEFINED
|
||||
#define _TIME32_T_DEFINED
|
||||
typedef long __time32_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* _daylight: non zero if daylight savings time is used.
|
||||
* _timezone: difference in seconds between GMT and local time.
|
||||
* _tzname: standard/daylight savings time zone names (an array with two
|
||||
* elements).
|
||||
*/
|
||||
#ifdef __MSVCRT__
|
||||
#ifndef _TIME64_T_DEFINED
|
||||
#define _TIME64_T_DEFINED
|
||||
#if _INTEGRAL_MAX_BITS >= 64
|
||||
#if defined(__GNUC__) && defined(__STRICT_ANSI__)
|
||||
typedef int _time64_t __attribute__ ((mode (DI)));
|
||||
#else
|
||||
typedef __int64 __time64_t;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */
|
||||
extern int* __p__daylight (void);
|
||||
extern long* __p__timezone (void);
|
||||
extern char** __p__tzname (void);
|
||||
#ifndef _TIME_T_DEFINED
|
||||
#define _TIME_T_DEFINED
|
||||
#ifdef _USE_32BIT_TIME_T
|
||||
typedef __time32_t time_t;
|
||||
#else
|
||||
typedef __time64_t time_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__MINGW_IMPORT int _daylight;
|
||||
__MINGW_IMPORT long _timezone;
|
||||
__MINGW_IMPORT char *_tzname[2];
|
||||
#ifndef _CLOCK_T_DEFINED
|
||||
#define _CLOCK_T_DEFINED
|
||||
typedef long clock_t;
|
||||
#endif
|
||||
|
||||
#else /* not __MSVCRT (ie. crtdll) */
|
||||
#ifndef _SIZE_T_DEFINED
|
||||
#define _SIZE_T_DEFINED
|
||||
#undef size_t
|
||||
#ifdef _WIN64
|
||||
#if defined(__GNUC__) && defined(__STRICT_ANSI__)
|
||||
typedef unsigned int size_t __attribute__ ((mode (DI)));
|
||||
#else
|
||||
typedef unsigned __int64 size_t;
|
||||
#endif
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __DECLSPEC_SUPPORTED
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
#define _SSIZE_T_DEFINED
|
||||
#undef ssize_t
|
||||
#ifdef _WIN64
|
||||
#if defined(__GNUC__) && defined(__STRICT_ANSI__)
|
||||
typedef int ssize_t __attribute__ ((mode (DI)));
|
||||
#else
|
||||
typedef __int64 ssize_t;
|
||||
#endif
|
||||
#else
|
||||
typedef int ssize_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int* __imp__daylight_dll;
|
||||
extern long* __imp__timezone_dll;
|
||||
extern char** __imp__tzname;
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _daylight (*__imp__daylight_dll)
|
||||
#define _timezone (*__imp__timezone_dll)
|
||||
#define _tzname (__imp__tzname)
|
||||
#ifdef _USE_32BIT_TIME_T
|
||||
#define _localtime32 localtime
|
||||
#define _difftime32 difftime
|
||||
#define _ctime32 ctime
|
||||
#define _gmtime32 gmtime
|
||||
#define _mktime32 mktime
|
||||
#define _time32 time
|
||||
#endif
|
||||
|
||||
#else /* __DECLSPEC_SUPPORTED */
|
||||
#ifndef _TM_DEFINED
|
||||
#define _TM_DEFINED
|
||||
struct tm {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
};
|
||||
#endif
|
||||
|
||||
__MINGW_IMPORT int _daylight_dll;
|
||||
__MINGW_IMPORT long _timezone_dll;
|
||||
__MINGW_IMPORT char* _tzname[2];
|
||||
#define CLOCKS_PER_SEC 1000
|
||||
|
||||
#define _daylight _daylight_dll
|
||||
#define _timezone _timezone_dll
|
||||
//!__TINYC__: __MINGW_IMPORT int _daylight;
|
||||
//!__TINYC__: __MINGW_IMPORT long _dstbias;
|
||||
//!__TINYC__: __MINGW_IMPORT long _timezone;
|
||||
//!__TINYC__: __MINGW_IMPORT char * _tzname[2];
|
||||
_CRTIMP errno_t __cdecl _get_daylight(int *_Daylight);
|
||||
_CRTIMP errno_t __cdecl _get_dstbias(long *_Daylight_savings_bias);
|
||||
_CRTIMP errno_t __cdecl _get_timezone(long *_Timezone);
|
||||
_CRTIMP errno_t __cdecl _get_tzname(size_t *_ReturnValue,char *_Buffer,size_t _SizeInBytes,int _Index);
|
||||
char *__cdecl asctime(const struct tm *_Tm);
|
||||
_CRTIMP char *__cdecl _ctime32(const __time32_t *_Time);
|
||||
clock_t __cdecl clock(void);
|
||||
_CRTIMP double __cdecl _difftime32(__time32_t _Time1,__time32_t _Time2);
|
||||
_CRTIMP struct tm *__cdecl _gmtime32(const __time32_t *_Time);
|
||||
_CRTIMP struct tm *__cdecl _localtime32(const __time32_t *_Time);
|
||||
size_t __cdecl strftime(char *_Buf,size_t _SizeInBytes,const char *_Format,const struct tm *_Tm);
|
||||
_CRTIMP size_t __cdecl _strftime_l(char *_Buf,size_t _Max_size,const char *_Format,const struct tm *_Tm,_locale_t _Locale);
|
||||
_CRTIMP char *__cdecl _strdate(char *_Buffer);
|
||||
_CRTIMP char *__cdecl _strtime(char *_Buffer);
|
||||
_CRTIMP __time32_t __cdecl _time32(__time32_t *_Time);
|
||||
_CRTIMP __time32_t __cdecl _mktime32(struct tm *_Tm);
|
||||
_CRTIMP __time32_t __cdecl _mkgmtime32(struct tm *_Tm);
|
||||
#if defined (_POSIX_) || defined(__GNUC__)
|
||||
void __cdecl tzset(void);
|
||||
#else
|
||||
_CRTIMP void __cdecl _tzset(void);
|
||||
#endif
|
||||
|
||||
#endif /* __DECLSPEC_SUPPORTED */
|
||||
#if _INTEGRAL_MAX_BITS >= 64
|
||||
double __cdecl _difftime64(__time64_t _Time1,__time64_t _Time2);
|
||||
_CRTIMP char *__cdecl _ctime64(const __time64_t *_Time);
|
||||
_CRTIMP struct tm *__cdecl _gmtime64(const __time64_t *_Time);
|
||||
_CRTIMP struct tm *__cdecl _localtime64(const __time64_t *_Time);
|
||||
_CRTIMP __time64_t __cdecl _mktime64(struct tm *_Tm);
|
||||
_CRTIMP __time64_t __cdecl _mkgmtime64(struct tm *_Tm);
|
||||
_CRTIMP __time64_t __cdecl _time64(__time64_t *_Time);
|
||||
#endif
|
||||
unsigned __cdecl _getsystime(struct tm *_Tm);
|
||||
unsigned __cdecl _setsystime(struct tm *_Tm,unsigned _MilliSec);
|
||||
|
||||
#endif /* not __MSVCRT__ */
|
||||
#ifndef _SIZE_T_DEFINED
|
||||
#define _SIZE_T_DEFINED
|
||||
#ifdef _WIN64
|
||||
#if defined(__GNUC__) && defined(__STRICT_ANSI__)
|
||||
typedef unsigned int size_t __attribute__ ((mode (DI)));
|
||||
#else
|
||||
typedef unsigned __int64 size_t;
|
||||
#endif
|
||||
#else
|
||||
typedef unsigned long size_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _NO_OLDNAMES
|
||||
|
||||
#ifdef __MSVCRT__
|
||||
|
||||
/* These go in the oldnames import library for MSVCRT. */
|
||||
__MINGW_IMPORT int daylight;
|
||||
__MINGW_IMPORT long timezone;
|
||||
__MINGW_IMPORT char *tzname[2];
|
||||
#ifndef _SSIZE_T_DEFINED
|
||||
#define _SSIZE_T_DEFINED
|
||||
#ifdef _WIN64
|
||||
#if defined(__GNUC__) && defined(__STRICT_ANSI__)
|
||||
typedef int ssize_t __attribute__ ((mode (DI)));
|
||||
#else
|
||||
typedef __int64 ssize_t;
|
||||
#endif
|
||||
#else
|
||||
typedef long ssize_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _WTIME_DEFINED
|
||||
_CRTIMP wchar_t *__cdecl _wasctime(const struct tm *_Tm);
|
||||
_CRTIMP wchar_t *__cdecl _wctime32(const __time32_t *_Time);
|
||||
size_t __cdecl wcsftime(wchar_t *_Buf,size_t _SizeInWords,const wchar_t *_Format,const struct tm *_Tm);
|
||||
_CRTIMP size_t __cdecl _wcsftime_l(wchar_t *_Buf,size_t _SizeInWords,const wchar_t *_Format,const struct tm *_Tm,_locale_t _Locale);
|
||||
_CRTIMP wchar_t *__cdecl _wstrdate(wchar_t *_Buffer);
|
||||
_CRTIMP wchar_t *__cdecl _wstrtime(wchar_t *_Buffer);
|
||||
#if _INTEGRAL_MAX_BITS >= 64
|
||||
_CRTIMP wchar_t *__cdecl _wctime64(const __time64_t *_Time);
|
||||
#endif
|
||||
|
||||
/* wide function prototypes, also declared in wchar.h */
|
||||
|
||||
wchar_t * _wasctime(const struct tm*);
|
||||
wchar_t * _wctime(const time_t*);
|
||||
wchar_t* _wstrdate(wchar_t*);
|
||||
wchar_t* _wstrtime(wchar_t*);
|
||||
#if !defined (RC_INVOKED) && !defined (_INC_WTIME_INL)
|
||||
#define _INC_WTIME_INL
|
||||
#ifdef _USE_32BIT_TIME_T
|
||||
__CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime32(_Time); }
|
||||
#else
|
||||
__CRT_INLINE wchar_t *__cdecl _wctime(const time_t *_Time) { return _wctime64(_Time); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define _WTIME_DEFINED
|
||||
#endif /* _WTIME_DEFINED */
|
||||
#endif
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
double __cdecl difftime(time_t _Time1,time_t _Time2);
|
||||
char *__cdecl ctime(const time_t *_Time);
|
||||
struct tm *__cdecl gmtime(const time_t *_Time);
|
||||
struct tm *__cdecl localtime(const time_t *_Time);
|
||||
struct tm *__cdecl localtime_r(const time_t *_Time,struct tm *);
|
||||
|
||||
#else /* not __MSVCRT__ */
|
||||
time_t __cdecl mktime(struct tm *_Tm);
|
||||
time_t __cdecl _mkgmtime(struct tm *_Tm);
|
||||
time_t __cdecl time(time_t *_Time);
|
||||
|
||||
/* CRTDLL is royally messed up when it comes to these macros.
|
||||
TODO: import and alias these via oldnames import library instead
|
||||
of macros. */
|
||||
#ifdef _USE_32BIT_TIME_T
|
||||
#if 0
|
||||
__CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime32(_Time1,_Time2); }
|
||||
__CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime32(_Time); }
|
||||
__CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime32(_Time); }
|
||||
__CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime32(_Time); }
|
||||
__CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime32(_Tm); }
|
||||
__CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime32(_Tm); }
|
||||
__CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time32(_Time); }
|
||||
#endif
|
||||
#else
|
||||
__CRT_INLINE double __cdecl difftime(time_t _Time1,time_t _Time2) { return _difftime64(_Time1,_Time2); }
|
||||
__CRT_INLINE char *__cdecl ctime(const time_t *_Time) { return _ctime64(_Time); }
|
||||
__CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time) { return _gmtime64(_Time); }
|
||||
__CRT_INLINE struct tm *__cdecl localtime(const time_t *_Time) { return _localtime64(_Time); }
|
||||
__CRT_INLINE time_t __cdecl mktime(struct tm *_Tm) { return _mktime64(_Tm); }
|
||||
__CRT_INLINE time_t __cdecl _mkgmtime(struct tm *_Tm) { return _mkgmtime64(_Tm); }
|
||||
__CRT_INLINE time_t __cdecl time(time_t *_Time) { return _time64(_Time); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define daylight _daylight
|
||||
/* NOTE: timezone not defined because it would conflict with sys/timeb.h.
|
||||
Also, tzname used to a be macro, but now it's in moldname. */
|
||||
__MINGW_IMPORT char *tzname[2];
|
||||
#if !defined(NO_OLDNAMES) || defined(_POSIX)
|
||||
#define CLK_TCK CLOCKS_PER_SEC
|
||||
|
||||
#endif /* not __MSVCRT__ */
|
||||
_CRTIMP extern int daylight;
|
||||
_CRTIMP extern long timezone;
|
||||
_CRTIMP extern char *tzname[2];
|
||||
void __cdecl tzset(void);
|
||||
#endif
|
||||
|
||||
#endif /* Not _NO_OLDNAMES */
|
||||
#ifndef _TIMEVAL_DEFINED /* also in winsock[2].h */
|
||||
#define _TIMEVAL_DEFINED
|
||||
struct timeval {
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
||||
#define timercmp(tvp,uvp,cmp) ((tvp)->tv_sec cmp (uvp)->tv_sec || (tvp)->tv_sec==(uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
|
||||
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
||||
#endif /* _TIMEVAL_DEFINED */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifndef __STRICT_ANSI__
|
||||
#ifndef _TIMEZONE_DEFINED /* also in sys/time.h */
|
||||
#define _TIMEZONE_DEFINED
|
||||
struct timezone {
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
extern int __cdecl mingw_gettimeofday (struct timeval *p, struct timezone *z);
|
||||
#endif
|
||||
#endif /* __STRICT_ANSI__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Not RC_INVOKED */
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif /* Not _TIME_H_ */
|
||||
#include <sec_api/time_s.h>
|
||||
|
||||
/* Adding timespec definition. */
|
||||
#include <sys/timeb.h>
|
||||
|
||||
#endif /* End _TIME_H_ */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user