[Box Backup-dev] COMMIT r766 - box/chris/general/lib/win32

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Thu Aug 10 00:56:40 BST 2006


Author: chris
Date: 2006-08-09 23:56:38 +0000 (Wed, 09 Aug 2006)
New Revision: 766

Modified:
   box/chris/general/lib/win32/emu.h
Log:
* emu.h
- First attempt to achieve a more logical order in this chaos
- Ensure that _ino_t is consistent everywhere on MSVC
- Fixed mode_t not defined before being used


Modified: box/chris/general/lib/win32/emu.h
===================================================================
--- box/chris/general/lib/win32/emu.h	2006-08-09 23:54:04 UTC (rev 765)
+++ box/chris/general/lib/win32/emu.h	2006-08-09 23:56:38 UTC (rev 766)
@@ -3,14 +3,46 @@
 #if ! defined EMU_INCLUDE && defined WIN32
 #define EMU_INCLUDE
 
-#define _INO_T_DEFINED
+// basic types, may be required by other headers since we
+// don't include sys/types.h
 
+#ifndef __MINGW32__
+	typedef unsigned __int64 u_int64_t;
+	typedef unsigned __int64 uint64_t;
+	typedef          __int64 int64_t;
+	typedef unsigned __int32 uint32_t;
+	typedef unsigned __int32 u_int32_t;
+	typedef          __int32 int32_t;
+	typedef unsigned __int16 uint16_t;
+	typedef          __int16 int16_t;
+	typedef unsigned __int8  uint8_t;
+	typedef          __int8  int8_t;
+#endif
+
+// emulated types, present on MinGW but not MSVC or vice versa
+
+#ifdef __MINGW32__
+	typedef uint32_t u_int32_t;
+#else
+	typedef unsigned int mode_t;
+	typedef unsigned int pid_t;
+
+	// must define _INO_T_DEFINED before including <sys/types.h>
+	// to replace it with our own.
+	typedef u_int64_t _ino_t;
+	#define _INO_T_DEFINED
+#endif
+
+// set up to include the necessary parts of Windows headers
+
 #define WIN32_LEAN_AND_MEAN
 
 #ifndef __MSVCRT_VERSION__
 #define __MSVCRT_VERSION__ 0x0601
 #endif
 
+// Windows headers
+
 #include <winsock2.h>
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -25,6 +57,8 @@
 
 #include <string>
 
+// emulated functions
+
 #define gmtime_r( _clock, _result ) \
 	( *(_result) = *gmtime( (_clock) ), \
 	(_result) )
@@ -42,8 +76,6 @@
 #define fileno(struct_file)   _fileno(struct_file)
 #endif
 
-typedef uint32_t u_int32_t;
-
 int SetTimerHandler(void (__cdecl *func ) (int));
 int setitimer(int type, struct itimerval *timeout, void *arg);
 void InitTimer(void);
@@ -91,7 +123,6 @@
 	#define S_ISDIR(x) (S_IFDIR & x)
 #endif
 
-
 inline int chown(const char * Filename, u_int32_t uid, u_int32_t gid)
 {
 	//important - this needs implementing
@@ -165,17 +196,6 @@
 #define tv_nsec tv_usec 
 
 #ifndef __MINGW32__
-	typedef unsigned __int64 u_int64_t;
-	typedef unsigned __int64 uint64_t;
-	typedef __int64 int64_t;
-	typedef unsigned __int32 uint32_t;
-	typedef unsigned __int32 u_int32_t;
-	typedef __int32 int32_t;
-	typedef unsigned __int16 uint16_t;
-	typedef __int16 int16_t;
-	typedef unsigned __int8 uint8_t;
-	typedef __int8 int8_t;
-
 	typedef int socklen_t;
 #endif
 
@@ -191,10 +211,6 @@
 
 #define vsnprintf _vsnprintf
 
-#ifndef __MINGW32__
-typedef unsigned int mode_t;
-#endif
-
 int emu_mkdir(const char* pPathName);
 
 inline int mkdir(const char *pPathName, mode_t mode)
@@ -308,11 +324,7 @@
 	time_t st_mtime;
 	time_t st_ctime;
 };
-
-#ifndef __MINGW32__
-typedef u_int64_t _ino_t;
 #endif
-#endif
 
 int emu_stat(const char * name, struct stat * st);
 int emu_fstat(HANDLE file, struct stat * st);




More information about the Boxbackup-dev mailing list