summary refs log tree commit diff stats
path: root/tinyc/win32/include/sys
diff options
context:
space:
mode:
Diffstat (limited to 'tinyc/win32/include/sys')
-rw-r--r--tinyc/win32/include/sys/fcntl.h5
-rw-r--r--tinyc/win32/include/sys/file.h5
-rw-r--r--tinyc/win32/include/sys/locking.h66
-rw-r--r--tinyc/win32/include/sys/stat.h398
-rw-r--r--tinyc/win32/include/sys/time.h66
-rw-r--r--tinyc/win32/include/sys/timeb.h177
-rw-r--r--tinyc/win32/include/sys/types.h162
-rw-r--r--tinyc/win32/include/sys/unistd.h5
-rw-r--r--tinyc/win32/include/sys/utime.h195
9 files changed, 673 insertions, 406 deletions
diff --git a/tinyc/win32/include/sys/fcntl.h b/tinyc/win32/include/sys/fcntl.h
index b343f272f..29fd55a1f 100644
--- a/tinyc/win32/include/sys/fcntl.h
+++ b/tinyc/win32/include/sys/fcntl.h
@@ -1,3 +1,8 @@
+/**
+ * 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.
+ */
 /*
  * This file is part of the Mingw32 package.
  *
diff --git a/tinyc/win32/include/sys/file.h b/tinyc/win32/include/sys/file.h
index 96c49e117..370f352d6 100644
--- a/tinyc/win32/include/sys/file.h
+++ b/tinyc/win32/include/sys/file.h
@@ -1,3 +1,8 @@
+/**
+ * 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.
+ */
 /*
  * This file is part of the Mingw32 package.
  *
diff --git a/tinyc/win32/include/sys/locking.h b/tinyc/win32/include/sys/locking.h
index 2ecd11628..e3fc85b3a 100644
--- a/tinyc/win32/include/sys/locking.h
+++ b/tinyc/win32/include/sys/locking.h
@@ -1,52 +1,30 @@
-/*
- * locking.h
- *
- * Constants for the mode parameter of the locking function.
- *
- * 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 _INC_LOCKING
+#define _INC_LOCKING
 
-#ifndef	__STRICT_ANSI__
-
-#ifndef	_LOCKING_H_
-#define	_LOCKING_H_
+#ifndef _WIN32
+#error Only Win32 target is supported!
+#endif
 
 /* All the headers include this file. */
 #include <_mingw.h>
 
-#define	_LK_UNLCK	0	/* Unlock */
-#define	_LK_LOCK	1	/* Lock */
-#define	_LK_NBLCK	2	/* Non-blocking lock */
-#define	_LK_RLCK	3	/* Lock for read only */
-#define	_LK_NBRLCK	4	/* Non-blocking lock for read only */
+#define _LK_UNLCK 0
+#define _LK_LOCK 1
+#define _LK_NBLCK 2
+#define _LK_RLCK 3
+#define _LK_NBRLCK 4
 
 #ifndef	NO_OLDNAMES
-#define	LK_UNLCK	_LK_UNLCK
-#define	LK_LOCK		_LK_LOCK
-#define	LK_NBLCK	_LK_NBLCK
-#define	LK_RLCK		_LK_RLCK
-#define	LK_NBRLCK	_LK_NBRLCK
-#endif	/* Not NO_OLDNAMES */
-
-#endif	/* Not _LOCKING_H_ */
-
-#endif	/* Not __STRICT_ANSI__ */
-
+#define LK_UNLCK _LK_UNLCK
+#define LK_LOCK _LK_LOCK
+#define LK_NBLCK _LK_NBLCK
+#define LK_RLCK _LK_RLCK
+#define LK_NBRLCK _LK_NBRLCK
+#endif
+
+#endif
diff --git a/tinyc/win32/include/sys/stat.h b/tinyc/win32/include/sys/stat.h
index 0e2054942..344d4a249 100644
--- a/tinyc/win32/include/sys/stat.h
+++ b/tinyc/win32/include/sys/stat.h
@@ -1,139 +1,108 @@
-/*
- * stat.h
- *
- * Symbolic constants for opening and creating files, also stat, fstat and
- * chmod functions.
- *
- * 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 _INC_STAT
+#define _INC_STAT
 
-#ifndef __STRICT_ANSI__
-
-#ifndef _STAT_H_
-#define _STAT_H_
+#ifndef _WIN32
+#error Only Win32 target is supported!
+#endif
 
-/* All the headers include this file. */
 #include <_mingw.h>
+#include <io.h>
 
-#define __need_size_t
-#define __need_wchar_t
-#ifndef RC_INVOKED
-#include <stddef.h>
-#endif /* Not RC_INVOKED */
+#pragma pack(push,_CRT_PACKING)
 
-#include <sys/types.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-/*
- * Constants for the stat st_mode member.
- */
-#define	_S_IFIFO	0x1000	/* FIFO */
-#define	_S_IFCHR	0x2000	/* Character */
-#define	_S_IFBLK	0x3000	/* Block: Is this ever set under w32? */
-#define	_S_IFDIR	0x4000	/* Directory */
-#define	_S_IFREG	0x8000	/* Regular */
+#ifndef _CRTIMP
+#define _CRTIMP __declspec(dllimport)
+#endif
 
-#define	_S_IFMT		0xF000	/* File type mask */
+#include <sys/types.h>
 
-#define	_S_IEXEC	0x0040
-#define	_S_IWRITE	0x0080
-#define	_S_IREAD	0x0100
+#ifndef __TINYC__ /* gr */
+#ifdef _USE_32BIT_TIME_T
+#ifdef _WIN64
+#undef _USE_32BIT_TIME_T
+#endif
+#else
+#if _INTEGRAL_MAX_BITS < 64
+#define _USE_32BIT_TIME_T
+#endif
+#endif
+#endif
 
-#define	_S_IRWXU	(_S_IREAD | _S_IWRITE | _S_IEXEC)
-#define	_S_IXUSR	_S_IEXEC
-#define	_S_IWUSR	_S_IWRITE
-#define	_S_IRUSR	_S_IREAD
+#ifndef _TIME32_T_DEFINED
+  typedef long __time32_t;
+#define _TIME32_T_DEFINED
+#endif
 
-#define	_S_ISDIR(m)	(((m) & _S_IFMT) == _S_IFDIR)
-#define	_S_ISFIFO(m)	(((m) & _S_IFMT) == _S_IFIFO)
-#define	_S_ISCHR(m)	(((m) & _S_IFMT) == _S_IFCHR)
-#define	_S_ISBLK(m)	(((m) & _S_IFMT) == _S_IFBLK)
-#define	_S_ISREG(m)	(((m) & _S_IFMT) == _S_IFREG)
+#ifndef _TIME64_T_DEFINED
+#if _INTEGRAL_MAX_BITS >= 64
+  typedef __int64 __time64_t;
+#endif
+#define _TIME64_T_DEFINED
+#endif
 
-#ifndef _NO_OLDNAMES
+#ifndef _TIME_T_DEFINED
+#ifdef _USE_32BIT_TIME_T
+  typedef __time32_t time_t;
+#else
+  typedef __time64_t time_t;
+#endif
+#define _TIME_T_DEFINED
+#endif
 
-#define	S_IFIFO		_S_IFIFO
-#define	S_IFCHR		_S_IFCHR
-#define	S_IFBLK		_S_IFBLK
-#define	S_IFDIR		_S_IFDIR
-#define	S_IFREG		_S_IFREG
-#define	S_IFMT		_S_IFMT
-#define	S_IEXEC		_S_IEXEC
-#define	S_IWRITE	_S_IWRITE
-#define	S_IREAD		_S_IREAD
-#define	S_IRWXU		_S_IRWXU
-#define	S_IXUSR		_S_IXUSR
-#define	S_IWUSR		_S_IWUSR
-#define	S_IRUSR		_S_IRUSR
+#ifndef _WCHAR_T_DEFINED
+  typedef unsigned short wchar_t;
+#define _WCHAR_T_DEFINED
+#endif
 
-#define	S_ISDIR(m)	(((m) & S_IFMT) == S_IFDIR)
-#define	S_ISFIFO(m)	(((m) & S_IFMT) == S_IFIFO)
-#define	S_ISCHR(m)	(((m) & S_IFMT) == S_IFCHR)
-#define	S_ISBLK(m)	(((m) & S_IFMT) == S_IFBLK)
-#define	S_ISREG(m)	(((m) & S_IFMT) == S_IFREG)
+#ifndef _STAT_DEFINED
 
-#endif	/* Not _NO_OLDNAMES */
+#ifdef _USE_32BIT_TIME_T
+#ifndef _WIN64
+#define _fstat32 _fstat
+#define _stat32 _stat
+#define _wstat32 _wstat
+#else
+#define _fstat _fstat32
+#define _stat _stat32
+#define _wstat _wstat32
+#endif
+#define _fstati64 _fstat32i64
+#define _stati64 _stat32i64
+#define _wstati64 _wstat32i64
+#else
+#define _fstat _fstat64i32
+#define _fstati64 _fstat64
+#define _stat _stat64i32
+#define _stati64 _stat64
+#define _wstat _wstat64i32
+#define _wstati64 _wstat64
+#endif
 
-#ifndef RC_INVOKED
+  struct _stat32 {
+    _dev_t st_dev;
+    _ino_t st_ino;
+    unsigned short st_mode;
+    short st_nlink;
+    short st_uid;
+    short st_gid;
+    _dev_t st_rdev;
+    _off_t st_size;
+    __time32_t st_atime;
+    __time32_t st_mtime;
+    __time32_t st_ctime;
+  };
 
-#ifndef _STAT_DEFINED
-/*
- * The structure manipulated and returned by stat and fstat.
- *
- * NOTE: If called on a directory the values in the time fields are not only
- * invalid, they will cause localtime et. al. to return NULL. And calling
- * asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
- */
-struct _stat
-{
-	_dev_t	st_dev;		/* Equivalent to drive number 0=A 1=B ... */
-	_ino_t	st_ino;		/* Always zero ? */
-	_mode_t	st_mode;	/* See above constants */
-	short	st_nlink;	/* Number of links. */
-	short	st_uid;		/* User: Maybe significant on NT ? */
-	short	st_gid;		/* Group: Ditto */
-	_dev_t	st_rdev;	/* Seems useless (not even filled in) */
-	_off_t	st_size;	/* File size in bytes */
-	time_t	st_atime;	/* Accessed date (always 00:00 hrs local
-				 * on FAT) */
-	time_t	st_mtime;	/* Modified time */
-	time_t	st_ctime;	/* Creation time */
-};
-
-struct stat
-{
-	_dev_t	st_dev;		/* Equivalent to drive number 0=A 1=B ... */
-	_ino_t	st_ino;		/* Always zero ? */
-	_mode_t	st_mode;	/* See above constants */
-	short	st_nlink;	/* Number of links. */
-	short	st_uid;		/* User: Maybe significant on NT ? */
-	short	st_gid;		/* Group: Ditto */
-	_dev_t	st_rdev;	/* Seems useless (not even filled in) */
-	_off_t	st_size;	/* File size in bytes */
-	time_t	st_atime;	/* Accessed date (always 00:00 hrs local
-				 * on FAT) */
-	time_t	st_mtime;	/* Modified time */
-	time_t	st_ctime;	/* Creation time */
-};
-#if defined (__MSVCRT__)
-struct _stati64 {
+#ifndef	NO_OLDNAMES
+  struct stat {
     _dev_t st_dev;
     _ino_t st_ino;
     unsigned short st_mode;
@@ -141,50 +110,181 @@ struct _stati64 {
     short st_uid;
     short st_gid;
     _dev_t st_rdev;
-    __int64 st_size;
+    _off_t st_size;
     time_t st_atime;
     time_t st_mtime;
     time_t st_ctime;
-};
-#endif /* __MSVCRT__ */
-#define _STAT_DEFINED
-#endif /* _STAT_DEFINED */
+  };
+#endif
 
-#ifdef	__cplusplus
-extern "C" {
+#if _INTEGRAL_MAX_BITS >= 64
+  struct _stat32i64 {
+    _dev_t st_dev;
+    _ino_t st_ino;
+    unsigned short st_mode;
+    short st_nlink;
+    short st_uid;
+    short st_gid;
+    _dev_t st_rdev;
+    __int64 st_size;
+    __time32_t st_atime;
+    __time32_t st_mtime;
+    __time32_t st_ctime;
+  };
+
+  struct _stat64i32 {
+    _dev_t st_dev;
+    _ino_t st_ino;
+    unsigned short st_mode;
+    short st_nlink;
+    short st_uid;
+    short st_gid;
+    _dev_t st_rdev;
+    _off_t st_size;
+    __time64_t st_atime;
+    __time64_t st_mtime;
+    __time64_t st_ctime;
+  };
+
+  struct _stat64 {
+    _dev_t st_dev;
+    _ino_t st_ino;
+    unsigned short st_mode;
+    short st_nlink;
+    short st_uid;
+    short st_gid;
+    _dev_t st_rdev;
+    __int64 st_size;
+    __time64_t st_atime;
+    __time64_t st_mtime;
+    __time64_t st_ctime;
+  };
+#endif
+
+#define __stat64 _stat64
+
+#define _STAT_DEFINED
 #endif
 
-int	_fstat (int, struct _stat*);
-int	_chmod (const char*, int);
-int	_stat (const char*, struct _stat*);
+#define _S_IFMT 0xF000
+#define _S_IFDIR 0x4000
+#define _S_IFCHR 0x2000
+#define _S_IFIFO 0x1000
+#define _S_IFREG 0x8000
+#define _S_IREAD 0x0100
+#define _S_IWRITE 0x0080
+#define _S_IEXEC 0x0040
+
+  _CRTIMP int __cdecl _fstat32(int _FileDes,struct _stat32 *_Stat);
+  _CRTIMP int __cdecl _stat32(const char *_Name,struct _stat32 *_Stat);
+#if _INTEGRAL_MAX_BITS >= 64
+  _CRTIMP int __cdecl _fstat64(int _FileDes,struct _stat64 *_Stat);
+  _CRTIMP int __cdecl _fstat32i64(int _FileDes,struct _stat32i64 *_Stat);
+  int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat);
+  __CRT_INLINE int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat)
+  {
+    struct _stat64 st;
+    int ret=_fstat64(_FileDes,&st);
+    _Stat->st_dev=st.st_dev;
+    _Stat->st_ino=st.st_ino;
+    _Stat->st_mode=st.st_mode;
+    _Stat->st_nlink=st.st_nlink;
+    _Stat->st_uid=st.st_uid;
+    _Stat->st_gid=st.st_gid;
+    _Stat->st_rdev=st.st_rdev;
+    _Stat->st_size=(_off_t) st.st_size;
+    _Stat->st_atime=st.st_atime;
+    _Stat->st_mtime=st.st_mtime;
+    _Stat->st_ctime=st.st_ctime;
+    return ret;
+  }
+  _CRTIMP int __cdecl _stat64(const char *_Name,struct _stat64 *_Stat);
+  _CRTIMP int __cdecl _stat32i64(const char *_Name,struct _stat32i64 *_Stat);
+  int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat);
+  __CRT_INLINE int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat)
+  {
+    struct _stat64 st;
+    int ret=_stat64(_Name,&st);
+    _Stat->st_dev=st.st_dev;
+    _Stat->st_ino=st.st_ino;
+    _Stat->st_mode=st.st_mode;
+    _Stat->st_nlink=st.st_nlink;
+    _Stat->st_uid=st.st_uid;
+    _Stat->st_gid=st.st_gid;
+    _Stat->st_rdev=st.st_rdev;
+    _Stat->st_size=(_off_t) st.st_size;
+    _Stat->st_atime=st.st_atime;
+    _Stat->st_mtime=st.st_mtime;
+    _Stat->st_ctime=st.st_ctime;
+    return ret;
+  }
+#endif
 
-#if defined (__MSVCRT__)
-int  _fstati64(int, struct _stati64 *);
-int  _stati64(const char *, struct _stati64 *);
-#if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
-int	_wstat(const wchar_t*, struct _stat*);
-int	_wstati64 (const wchar_t*, struct _stati64*);
+#ifndef _WSTAT_DEFINED
 #define _WSTAT_DEFINED
-#endif /* _WSTAT_DEFIND */
-#endif /* __MSVCRT__ */
+  _CRTIMP int __cdecl _wstat32(const wchar_t *_Name,struct _stat32 *_Stat);
+#if _INTEGRAL_MAX_BITS >= 64
+  _CRTIMP int __cdecl _wstat32i64(const wchar_t *_Name,struct _stat32i64 *_Stat);
+  int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat);
+  _CRTIMP int __cdecl _wstat64(const wchar_t *_Name,struct _stat64 *_Stat);
+#endif
+#endif
 
-#ifndef	_NO_OLDNAMES
+#ifndef	NO_OLDNAMES
+#define	_S_IFBLK	0x3000	/* Block: Is this ever set under w32? */
 
-/* These functions live in liboldnames.a. */
-int	fstat (int, struct stat*);
-int	chmod (const char*, int);
-int	stat (const char*, struct stat*);
+#define S_IFMT _S_IFMT
+#define S_IFDIR _S_IFDIR
+#define S_IFCHR _S_IFCHR
+#define S_IFREG _S_IFREG
+#define S_IREAD _S_IREAD
+#define S_IWRITE _S_IWRITE
+#define S_IEXEC _S_IEXEC
+#define	S_IFIFO		_S_IFIFO
+#define	S_IFBLK		_S_IFBLK
 
-#endif	/* Not _NO_OLDNAMES */
+#define	_S_IRWXU	(_S_IREAD | _S_IWRITE | _S_IEXEC)
+#define	_S_IXUSR	_S_IEXEC
+#define	_S_IWUSR	_S_IWRITE
 
+#define	S_IRWXU		_S_IRWXU
+#define	S_IXUSR		_S_IXUSR
+#define	S_IWUSR		_S_IWUSR
+#define	S_IRUSR		_S_IRUSR
+#define	_S_IRUSR	_S_IREAD
 
-#ifdef	__cplusplus
-}
-#endif
+#define	S_ISDIR(m)	(((m) & S_IFMT) == S_IFDIR)
+#define	S_ISFIFO(m)	(((m) & S_IFMT) == S_IFIFO)
+#define	S_ISCHR(m)	(((m) & S_IFMT) == S_IFCHR)
+#define	S_ISBLK(m)	(((m) & S_IFMT) == S_IFBLK)
+#define	S_ISREG(m)	(((m) & S_IFMT) == S_IFREG)
 
-#endif	/* Not RC_INVOKED */
+#endif
 
-#endif	/* Not _STAT_H_ */
+#if !defined (RC_INVOKED) && !defined (NO_OLDNAMES)
+int __cdecl stat(const char *_Filename,struct stat *_Stat);
+int __cdecl fstat(int _Desc,struct stat *_Stat);
+int __cdecl wstat(const wchar_t *_Filename,struct stat *_Stat);
+#ifdef _USE_32BIT_TIME_T
+__CRT_INLINE int __cdecl fstat(int _Desc,struct stat *_Stat) {
+  return _fstat32(_Desc,(struct _stat32 *)_Stat);
+}
+__CRT_INLINE int __cdecl stat(const char *_Filename,struct stat *_Stat) {
+  return _stat32(_Filename,(struct _stat32 *)_Stat);
+}
+#else
+__CRT_INLINE int __cdecl fstat(int _Desc,struct stat *_Stat) {
+  return _fstat64i32(_Desc,(struct _stat64i32 *)_Stat);
+}
+__CRT_INLINE int __cdecl stat(const char *_Filename,struct stat *_Stat) {
+  return _stat64i32(_Filename,(struct _stat64i32 *)_Stat);
+}
+#endif
+#endif
 
-#endif	/* Not __STRICT_ANSI__ */
+#ifdef __cplusplus
+}
+#endif
 
+#pragma pack(pop)
+#endif
diff --git a/tinyc/win32/include/sys/time.h b/tinyc/win32/include/sys/time.h
index 39d85f67b..8ccab8319 100644
--- a/tinyc/win32/include/sys/time.h
+++ b/tinyc/win32/include/sys/time.h
@@ -1,3 +1,69 @@
+/**
+ * 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 _SYS_TIME_H_
+#define _SYS_TIME_H_
 
 #include <time.h>
 
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#ifndef __STRICT_ANSI__
+#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 != (uvp)->tv_sec) ? \
+  ((tvp)->tv_sec cmp (uvp)->tv_sec) : \
+  ((tvp)->tv_usec cmp (uvp)->tv_usec))
+#define timerclear(tvp)	 (tvp)->tv_sec = (tvp)->tv_usec = 0
+#endif /* _TIMEVAL_DEFINED */
+
+#ifndef _TIMEZONE_DEFINED /* also in sys/time.h */
+#define _TIMEZONE_DEFINED
+/* Provided for compatibility with code that assumes that
+   the presence of gettimeofday function implies a definition
+   of struct timezone. */
+struct timezone
+{
+  int tz_minuteswest; /* of Greenwich */
+  int tz_dsttime;     /* type of dst correction to apply */
+};
+
+  extern int __cdecl mingw_gettimeofday (struct timeval *p, struct timezone *z);
+
+#endif
+
+/*
+   Implementation as per:
+   The Open Group Base Specifications, Issue 6
+   IEEE Std 1003.1, 2004 Edition
+
+   The timezone pointer arg is ignored.  Errors are ignored.
+*/
+#ifndef _GETTIMEOFDAY_DEFINED
+#define _GETTIMEOFDAY_DEFINED
+int __cdecl gettimeofday(struct timeval *__restrict__,
+                         void *__restrict__  /* tzp (unused) */);
+#endif
+
+#endif /* __STRICT_ANSI__ */
+
+#ifdef  __cplusplus
+}
+#endif
+
+/* Adding timespec definition.  */
+#include <sys/timeb.h>
+
+
+#endif /* _SYS_TIME_H_ */
diff --git a/tinyc/win32/include/sys/timeb.h b/tinyc/win32/include/sys/timeb.h
index b5bb0fc3d..34837738b 100644
--- a/tinyc/win32/include/sys/timeb.h
+++ b/tinyc/win32/include/sys/timeb.h
@@ -1,82 +1,133 @@
-/*
- * timeb.h
- *
- * Support for the UNIX System V ftime system call.
- *
- * 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 _TIMEB_H_
+#define _TIMEB_H_
 
-#ifndef	__STRICT_ANSI__
+#include <_mingw.h>
 
-#ifndef	_TIMEB_H_
-#define	_TIMEB_H_
+#ifndef _WIN32
+#error Only Win32 target is supported!
+#endif
 
-/* All the headers include this file. */
-#include <_mingw.h>
+#pragma pack(push,_CRT_PACKING)
 
-#ifndef	RC_INVOKED
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-/*
- * TODO: Structure not tested.
- */
-struct _timeb
-{
-	long	time;
-	short	millitm;
-	short	timezone;
-	short	dstflag;
-};
+#ifndef _CRTIMP
+#define _CRTIMP __declspec(dllimport)
+#endif
 
-#ifndef	_NO_OLDNAMES
-/*
- * TODO: Structure not tested.
- */
-struct timeb
-{
-	long	time;
-	short	millitm;
-	short	timezone;
-	short	dstflag;
-};
+#ifndef __TINYC__ /* gr */
+#ifdef _USE_32BIT_TIME_T
+#ifdef _WIN64
+#undef _USE_32BIT_TIME_T
+#endif
+#else
+#if _INTEGRAL_MAX_BITS < 64
+#define _USE_32BIT_TIME_T
+#endif
+#endif
 #endif
 
+#ifndef _TIME32_T_DEFINED
+  typedef long __time32_t;
+#define _TIME32_T_DEFINED
+#endif
 
-#ifdef	__cplusplus
-extern "C" {
+#ifndef _TIME64_T_DEFINED
+#if _INTEGRAL_MAX_BITS >= 64
+  typedef __int64 __time64_t;
+#endif
+#define _TIME64_T_DEFINED
 #endif
 
-/* TODO: Not tested. */
-void	_ftime (struct _timeb*);
+#ifndef _TIME_T_DEFINED
+#ifdef _USE_32BIT_TIME_T
+  typedef __time32_t time_t;
+#else
+  typedef __time64_t time_t;
+#endif
+#define _TIME_T_DEFINED
+#endif
 
-#ifndef	_NO_OLDNAMES
-void	ftime (struct timeb*);
-#endif	/* Not _NO_OLDNAMES */
+#ifndef _TIMEB_DEFINED
+#define _TIMEB_DEFINED
 
-#ifdef	__cplusplus
-}
+  struct __timeb32 {
+    __time32_t time;
+    unsigned short millitm;
+    short timezone;
+    short dstflag;
+  };
+
+#ifndef	NO_OLDNAMES
+  struct timeb {
+    time_t time;
+    unsigned short millitm;
+    short timezone;
+    short dstflag;
+  };
 #endif
 
-#endif	/* Not RC_INVOKED */
+#if _INTEGRAL_MAX_BITS >= 64
+  struct __timeb64 {
+    __time64_t time;
+    unsigned short millitm;
+    short timezone;
+    short dstflag;
+  };
+#endif
+
+#ifdef _USE_32BIT_TIME_T
+#define _timeb __timeb32
+//gr #define _ftime _ftime32
+#define _ftime32 _ftime
+#else
+#define _timeb __timeb64
+#define _ftime _ftime64
+#endif
+#endif
+
+  _CRTIMP void __cdecl _ftime32(struct __timeb32 *_Time);
+#if _INTEGRAL_MAX_BITS >= 64
+  _CRTIMP void __cdecl _ftime64(struct __timeb64 *_Time);
+#endif
 
-#endif	/* Not _TIMEB_H_ */
+#ifndef _TIMESPEC_DEFINED
+#define _TIMESPEC_DEFINED
+struct timespec {
+  time_t  tv_sec;   /* Seconds */
+  long    tv_nsec;  /* Nanoseconds */
+};
 
-#endif	/* Not __STRICT_ANSI__ */
+struct itimerspec {
+  struct timespec  it_interval;  /* Timer period */
+  struct timespec  it_value;     /* Timer expiration */
+};
+#endif
 
+#if !defined (RC_INVOKED) && !defined (NO_OLDNAMES)
+#ifdef _USE_32BIT_TIME_T
+__CRT_INLINE void __cdecl ftime(struct timeb *_Tmb) {
+  _ftime32((struct __timeb32 *)_Tmb);
+}
+#else
+__CRT_INLINE void __cdecl ftime(struct timeb *_Tmb) {
+  _ftime64((struct __timeb64 *)_Tmb);
+}
+#endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#pragma pack(pop)
+
+#include <sec_api/sys/timeb_s.h>
+#endif
diff --git a/tinyc/win32/include/sys/types.h b/tinyc/win32/include/sys/types.h
index 0679ac9b3..7379b0f1e 100644
--- a/tinyc/win32/include/sys/types.h
+++ b/tinyc/win32/include/sys/types.h
@@ -1,118 +1,118 @@
-/*
- * types.h
- *
- * The definition of constants, data types and global variables.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *  Lots of types supplied by Pedro A. Aranda <paag@tid.es>
- *
- *  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 WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
- *  DISCLAIMED. This includes but is not limited to warrenties 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 _INC_TYPES
+#define _INC_TYPES
 
-#ifndef	_TYPES_H_
-#define	_TYPES_H_
+#ifndef _WIN32
+#error Only Win32 target is supported!
+#endif
 
-/* All the headers include this file. */
 #include <_mingw.h>
 
-#define __need_wchar_t
-#define __need_size_t
-#define __need_ptrdiff_t
-#ifndef RC_INVOKED
-#include <stddef.h>
-#endif	/* Not RC_INVOKED */
-
-#ifndef RC_INVOKED
-
-#ifndef _TIME_T_DEFINED
-typedef	long	time_t;
-#define	_TIME_T_DEFINED
+#ifndef __TINYC__ /* gr */
+#ifdef _USE_32BIT_TIME_T
+#ifdef _WIN64
+#undef _USE_32BIT_TIME_T
+#endif
+#else
+#if _INTEGRAL_MAX_BITS < 64
+#define _USE_32BIT_TIME_T
+#endif
+#endif
 #endif
 
-
-#ifndef	__STRICT_ANSI__
-
-#ifndef	_OFF_T_
-#define	_OFF_T_
-typedef long _off_t;
-
-#ifndef	_NO_OLDNAMES
-typedef _off_t	off_t;
+#ifndef _TIME32_T_DEFINED
+#define _TIME32_T_DEFINED
+typedef long __time32_t;
 #endif
-#endif	/* Not _OFF_T_ */
 
+#ifndef _TIME64_T_DEFINED
+#define _TIME64_T_DEFINED
+#if _INTEGRAL_MAX_BITS >= 64
+typedef __int64 __time64_t;
+#endif
+#endif
 
-#ifndef _DEV_T_
-#define	_DEV_T_
-#ifdef __MSVCRT__
-typedef unsigned int _dev_t;
+#ifndef _TIME_T_DEFINED
+#define _TIME_T_DEFINED
+#ifdef _USE_32BIT_TIME_T
+typedef __time32_t time_t;
 #else
-typedef short _dev_t;
+typedef __time64_t time_t;
 #endif
-
-#ifndef	_NO_OLDNAMES
-typedef _dev_t	dev_t;
 #endif
-#endif	/* Not _DEV_T_ */
-
 
-#ifndef _INO_T_
-#define	_INO_T_
-typedef short _ino_t;
-
-#ifndef	_NO_OLDNAMES
-typedef _ino_t	ino_t;
+#ifndef _INO_T_DEFINED
+#define _INO_T_DEFINED
+typedef unsigned short _ino_t;
+#ifndef	NO_OLDNAMES
+typedef unsigned short ino_t;
+#endif
 #endif
-#endif	/* Not _INO_T_ */
 
+#ifndef _DEV_T_DEFINED
+#define _DEV_T_DEFINED
+typedef unsigned int _dev_t;
+#ifndef	NO_OLDNAMES
+typedef unsigned int dev_t;
+#endif
+#endif
 
 #ifndef _PID_T_
 #define	_PID_T_
+#ifndef _WIN64
 typedef int	_pid_t;
+#else
+typedef __int64	_pid_t;
+#endif
 
-#ifndef	_NO_OLDNAMES
+#ifndef	NO_OLDNAMES
 typedef _pid_t	pid_t;
 #endif
 #endif	/* Not _PID_T_ */
 
-
 #ifndef _MODE_T_
 #define	_MODE_T_
 typedef unsigned short _mode_t;
 
-#ifndef	_NO_OLDNAMES
+#ifndef	NO_OLDNAMES
 typedef _mode_t	mode_t;
 #endif
 #endif	/* Not _MODE_T_ */
 
-
-#ifndef _SIGSET_T_
-#define	_SIGSET_T_
-typedef int	_sigset_t;
-
-#ifndef	_NO_OLDNAMES
-typedef _sigset_t	sigset_t;
+#ifndef _OFF_T_DEFINED
+#define _OFF_T_DEFINED
+#ifndef _OFF_T_
+#define _OFF_T_
+  typedef long _off_t;
+#if !defined(NO_OLDNAMES) || defined(_POSIX)
+  typedef long off_t;
+#endif
+#endif
 #endif
-#endif	/* Not _SIGSET_T_ */
 
-#endif	/* Not __STRICT_ANSI__ */
+#ifndef _OFF64_T_DEFINED
+#define _OFF64_T_DEFINED
+  typedef long long _off64_t;
+#if !defined(NO_OLDNAMES) || defined(_POSIX)
+  typedef long long off64_t;
+#endif
+#endif
 
-#endif	/* Not RC_INVOKED */
+#ifndef _TIMESPEC_DEFINED
+#define _TIMESPEC_DEFINED
+struct timespec {
+  time_t  tv_sec;   /* Seconds */
+  long    tv_nsec;  /* Nanoseconds */
+};
+
+struct itimerspec {
+  struct timespec  it_interval;  /* Timer period */
+  struct timespec  it_value;     /* Timer expiration */
+};
+#endif
 
-#endif	/* Not _TYPES_H_ */
+#endif
diff --git a/tinyc/win32/include/sys/unistd.h b/tinyc/win32/include/sys/unistd.h
index ed122d9dd..31006d325 100644
--- a/tinyc/win32/include/sys/unistd.h
+++ b/tinyc/win32/include/sys/unistd.h
@@ -1,3 +1,8 @@
+/**
+ * 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.
+ */
 /*
  * This file is part of the Mingw32 package.
  *
diff --git a/tinyc/win32/include/sys/utime.h b/tinyc/win32/include/sys/utime.h
index 049524bed..fec8304ff 100644
--- a/tinyc/win32/include/sys/utime.h
+++ b/tinyc/win32/include/sys/utime.h
@@ -1,89 +1,146 @@
-/*
- * utime.h
- *
- * Support for the utime function.
- *
- * 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 _INC_UTIME
+#define _INC_UTIME
 
-#ifndef	__STRICT_ANSI__
-
-#ifndef	_UTIME_H_
-#define	_UTIME_H_
+#ifndef _WIN32
+#error Only Win32 target is supported!
+#endif
 
-/* 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 */
-#include <sys/types.h>
+#pragma pack(push,_CRT_PACKING)
 
-#ifndef	RC_INVOKED
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-/*
- * Structure used by _utime function.
- */
-struct _utimbuf
-{
-	time_t	actime;		/* Access time */
-	time_t	modtime;	/* Modification time */
-};
+#ifndef _CRTIMP
+#define _CRTIMP __declspec(dllimport)
+#endif
 
+#ifndef _WCHAR_T_DEFINED
+  typedef unsigned short wchar_t;
+#define _WCHAR_T_DEFINED
+#endif
 
-#ifndef	_NO_OLDNAMES
-/* NOTE: Must be the same as _utimbuf above. */
-struct utimbuf
-{
-	time_t	actime;
-	time_t	modtime;
-};
-#endif	/* Not _NO_OLDNAMES */
+#ifndef __TINYC__ /* gr */
+#ifdef _USE_32BIT_TIME_T
+#ifdef _WIN64
+#undef _USE_32BIT_TIME_T
+#endif
+#else
+#if _INTEGRAL_MAX_BITS < 64
+#define _USE_32BIT_TIME_T
+#endif
+#endif
+#endif
 
+#ifndef _TIME32_T_DEFINED
+#define _TIME32_T_DEFINED
+  typedef long __time32_t;
+#endif
 
-#ifdef	__cplusplus
-extern "C" {
+#ifndef _TIME64_T_DEFINED
+#define _TIME64_T_DEFINED
+#if _INTEGRAL_MAX_BITS >= 64
+  typedef __int64 __time64_t;
+#endif
+#endif
+
+#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
 
-int	_utime (const char*, struct _utimbuf*);
-int	_futime (int, struct _utimbuf*);
+#ifndef _UTIMBUF_DEFINED
+#define _UTIMBUF_DEFINED
 
-/* The wide character version, only available for MSVCRT versions of the
- * C runtime library. */
-#ifdef __MSVCRT__
-int	_wutime (const wchar_t*, struct _utimbuf*);
-#endif /* MSVCRT runtime */
-#ifndef	_NO_OLDNAMES
-int	utime (const char*, struct utimbuf*);
-#endif	/* Not _NO_OLDNAMES */
+  struct _utimbuf {
+    time_t actime;
+    time_t modtime;
+  };
 
-#ifdef	__cplusplus
-}
+  struct __utimbuf32 {
+    __time32_t actime;
+    __time32_t modtime;
+  };
+
+#if _INTEGRAL_MAX_BITS >= 64
+  struct __utimbuf64 {
+    __time64_t actime;
+    __time64_t modtime;
+  };
+#endif
+
+#ifndef	NO_OLDNAMES
+  struct utimbuf {
+    time_t actime;
+    time_t modtime;
+  };
+
+  struct utimbuf32 {
+    __time32_t actime;
+    __time32_t modtime;
+  };
+#endif
 #endif
 
-#endif	/* Not RC_INVOKED */
+  _CRTIMP int __cdecl _utime32(const char *_Filename,struct __utimbuf32 *_Time);
+  _CRTIMP int __cdecl _futime32(int _FileDes,struct __utimbuf32 *_Time);
+  _CRTIMP int __cdecl _wutime32(const wchar_t *_Filename,struct __utimbuf32 *_Time);
+#if _INTEGRAL_MAX_BITS >= 64
+  _CRTIMP int __cdecl _utime64(const char *_Filename,struct __utimbuf64 *_Time);
+  _CRTIMP int __cdecl _futime64(int _FileDes,struct __utimbuf64 *_Time);
+  _CRTIMP int __cdecl _wutime64(const wchar_t *_Filename,struct __utimbuf64 *_Time);
+#endif
 
-#endif	/* Not _UTIME_H_ */
+#ifndef RC_INVOKED
+#ifdef _USE_32BIT_TIME_T
+__CRT_INLINE int __cdecl _utime(const char *_Filename,struct _utimbuf *_Utimbuf) {
+  return _utime32(_Filename,(struct __utimbuf32 *)_Utimbuf);
+}
+__CRT_INLINE int __cdecl _futime(int _Desc,struct _utimbuf *_Utimbuf) {
+  return _futime32(_Desc,(struct __utimbuf32 *)_Utimbuf);
+}
+__CRT_INLINE int __cdecl _wutime(const wchar_t *_Filename,struct _utimbuf *_Utimbuf) {
+  return _wutime32(_Filename,(struct __utimbuf32 *)_Utimbuf);
+}
+#else
+__CRT_INLINE int __cdecl _utime(const char *_Filename,struct _utimbuf *_Utimbuf) {
+  return _utime64(_Filename,(struct __utimbuf64 *)_Utimbuf);
+}
+__CRT_INLINE int __cdecl _futime(int _Desc,struct _utimbuf *_Utimbuf) {
+  return _futime64(_Desc,(struct __utimbuf64 *)_Utimbuf);
+}
+__CRT_INLINE int __cdecl _wutime(const wchar_t *_Filename,struct _utimbuf *_Utimbuf) {
+  return _wutime64(_Filename,(struct __utimbuf64 *)_Utimbuf);
+}
+#endif
+
+#ifndef	NO_OLDNAMES
+#ifdef _USE_32BIT_TIME_T
+__CRT_INLINE int __cdecl utime(const char *_Filename,struct utimbuf *_Utimbuf) {
+  return _utime32(_Filename,(struct __utimbuf32 *)_Utimbuf);
+}
+#else
+__CRT_INLINE int __cdecl utime(const char *_Filename,struct utimbuf *_Utimbuf) {
+  return _utime64(_Filename,(struct __utimbuf64 *)_Utimbuf);
+}
+#endif
+#endif
+#endif
 
-#endif	/* Not __STRICT_ANSI__ */
+#ifdef __cplusplus
+}
+#endif
 
+#pragma pack(pop)
+#endif