shithub: duke3d

Download patch

ref: 77df6fcc4bef18ca74669d94e5fd98432c9c3e69
parent: 8c6c4b3d23f9fe355023419e2d826bc852f4fb95
author: Tanguy Fautre <[email protected]>
date: Mon Feb 10 14:53:16 EST 2020

Removing loads of platform specific cruft.

--- a/Engine/Engine.vcxproj
+++ b/Engine/Engine.vcxproj
@@ -54,7 +54,7 @@
     <ClCompile>
       <Optimization>Disabled</Optimization>
       <AdditionalIncludeDirectories>$(SolutionDir)build\vcpkg.windows\installed\x86-windows-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>nDBGRECORD; nDEBUG; PLATFORM_WIN32; UDP_NETWORKING; WIN32; _LIB; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>nDBGRECORD; nDEBUG; UDP_NETWORKING; WIN32; _LIB; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <AdditionalOptions> /J</AdditionalOptions>
       <PrecompiledHeader />
@@ -79,7 +79,7 @@
       <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
       <OmitFramePointers>true</OmitFramePointers>
       <AdditionalIncludeDirectories>$(SolutionDir)build\vcpkg.windows\installed\x86-windows-static\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>nDBGRECORD; nDEBUG; PLATFORM_WIN32; UDP_NETWORKING; WIN32; _LIB; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>nDBGRECORD; nDEBUG; UDP_NETWORKING; WIN32; _LIB; _CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <BufferSecurityCheck>false</BufferSecurityCheck>
       <AdditionalOptions> /J</AdditionalOptions>
--- a/Engine/src/build.h
+++ b/Engine/src/build.h
@@ -7,11 +7,8 @@
 
 #ifndef _INCLUDE_BUILD_H_
 #define _INCLUDE_BUILD_H_
-#ifdef _WIN32
-   #include "windows/inttypes.h"
-#else
-   #include <inttypes.h>
-#endif
+
+#include <inttypes.h>
 
 #define MAXSECTORS 1024
 #define MAXWALLS 8192
--- a/Engine/src/display.c
+++ b/Engine/src/display.c
@@ -20,11 +20,6 @@
 #include <string.h>
 #include "platform.h"
 
-#if (!defined PLATFORM_SUPPORTS_SDL)
-#error This platform apparently does not use SDL. Do not compile this.
-#endif
-
-
 #define BUILD_NOMOUSEGRAB    "BUILD_NOMOUSEGRAB"
 #define BUILD_WINDOWED       "BUILD_WINDOWED"
 #define BUILD_SDLDEBUG       "BUILD_SDLDEBUG"
@@ -61,11 +56,6 @@
 
 //END // NATIVE TIMER FUNCTION DECLARATION
 
-
-#if ((defined PLATFORM_WIN32))
-#include <windows.h>
-#endif
-
 #include "draw.h"
 #include "cache.h"
 
@@ -155,7 +145,7 @@
 
   	if (screen != NULL)
    	{
-       	if (screenalloctype == 0) kkfree((void *)screen);
+       	if (screenalloctype == 0) free((void *)screen);
    	    if (screenalloctype == 1) suckcache((int32_t *)screen);
    		screen = NULL;
    	} /* if */
@@ -257,7 +247,7 @@
     init_new_res_vars();
 }
 
-static __inline int sdl_mouse_button_filter(SDL_MouseButtonEvent const *event)
+static inline int sdl_mouse_button_filter(SDL_MouseButtonEvent const *event)
 {
         /*
          * What bits BUILD expects:
@@ -334,7 +324,7 @@
      *  which we check for explicitly, and give the engine a keypad enter
      *  enter event.
      */
-static __inline int handle_keypad_enter_hack(const SDL_Event *event)
+static inline int handle_keypad_enter_hack(const SDL_Event *event)
 {
     static int kp_enter_hack = 0;
     int retval = 0;
@@ -902,7 +892,7 @@
 } /* get_dimensions_from_str */
 
 
-static __inline void get_max_screen_res(int32_t *max_w, int32_t *max_h)
+static inline void get_max_screen_res(int32_t *max_w, int32_t *max_h)
 {
     int32_t w = DEFAULT_MAXRESWIDTH;
     int32_t h = DEFAULT_MAXRESHEIGHT;
@@ -937,7 +927,7 @@
 
 
 /* Let the user specify a specific mode via environment variable. */
-static __inline void add_user_defined_resolution(void)
+static inline void add_user_defined_resolution(void)
 {
     int32_t w;
     int32_t h;
@@ -970,7 +960,7 @@
 } /* remove_vesa_mode */
 
 
-static __inline void cull_large_vesa_modes(void)
+static inline void cull_large_vesa_modes(void)
 {
     int32_t max_w;
     int32_t max_h;
@@ -990,7 +980,7 @@
 } /* cull_large_vesa_modes */
 
 
-static __inline void cull_duplicate_vesa_modes(void)
+static inline void cull_duplicate_vesa_modes(void)
 {
     int i;
     int j;
@@ -1009,7 +999,7 @@
 #define swap_macro(tmp, x, y) { tmp = x; x = y; y = tmp; }
 
 /* be sure to call cull_duplicate_vesa_modes() before calling this. */
-static __inline void sort_vesa_modelist(void)
+static inline void sort_vesa_modelist(void)
 {
     int i;
     int sorted;
@@ -1033,7 +1023,7 @@
 } /* sort_vesa_modelist */
 
 
-static __inline void cleanup_vesa_modelist(void)
+static inline void cleanup_vesa_modelist(void)
 {
     cull_large_vesa_modes();
     cull_duplicate_vesa_modes();
@@ -1041,7 +1031,7 @@
 } /* cleanup_vesa_modelist */
 
 
-static __inline void output_vesa_modelist(void)
+static inline void output_vesa_modelist(void)
 {
     char  buffer[256];
     char  numbuf[20];
@@ -1442,7 +1432,7 @@
 
 /* Most of this line code is taken from Abrash's "Graphics Programming Blackbook".
 Remember, sharing code is A Good Thing. AH */
-static __inline void DrawHorizontalRun (uint8_t  **ScreenPtr, int XAdvance, int RunLength, uint8_t  Color)
+static inline void DrawHorizontalRun (uint8_t  **ScreenPtr, int XAdvance, int RunLength, uint8_t  Color)
 {
     int i;
     uint8_t  *WorkingScreenPtr = *ScreenPtr;
@@ -1456,7 +1446,7 @@
     *ScreenPtr = WorkingScreenPtr;
 }
 
-static __inline void DrawVerticalRun (uint8_t  **ScreenPtr, int XAdvance, int RunLength, uint8_t  Color)
+static inline void DrawVerticalRun (uint8_t  **ScreenPtr, int XAdvance, int RunLength, uint8_t  Color)
 {
     int i;
     uint8_t  *WorkingScreenPtr = *ScreenPtr;
@@ -1810,18 +1800,6 @@
 //Timer on windows 98 used to be really poor but now it is very accurate
 // We can just use what SDL uses, no need for QueryPerformanceFrequency or QueryPerformanceCounter
 // (which I bet SDL is using anyway).
-#if 0//PLATFORM_WIN32 
-int TIMER_GetPlatformTicksInOneSecond(int64_t* t)
-{
-    QueryPerformanceFrequency((LARGE_INTEGER*)t);
-    return 1;
-}
-
-void TIMER_GetPlatformTicks(int64_t* t)
-{
-    QueryPerformanceCounter((LARGE_INTEGER*)t);
-}
-#else
 //FCS: Let's try to use SDL again: Maybe SDL library is accurate enough now.
 int TIMER_GetPlatformTicksInOneSecond(int64_t* t)
 {
@@ -1833,6 +1811,3 @@
 {
     *t = SDL_GetTicks();
 }
-#endif
-/* end of sdl_driver.c ... */
-
--- a/Engine/src/draw.h
+++ b/Engine/src/draw.h
@@ -8,12 +8,7 @@
 #ifndef _INCLUDE_A_H_
 #define _INCLUDE_A_H_
 
-#ifdef _WIN32
-   #include "windows/inttypes.h"
-#else
-   #include <inttypes.h>
-#endif
-
+#include <inttypes.h>
 
 //C++ linker friendly
 #ifdef __cplusplus
--- a/Engine/src/engine.c
+++ b/Engine/src/engine.c
@@ -276,7 +276,7 @@
 
 #include "draw.h"
 
-static __inline int32_t nsqrtasm(uint32_t  param)
+static inline int32_t nsqrtasm(uint32_t  param)
 {
     uint16_t *shlookup_a = (uint16_t*)shlookup;
     uint16_t *sqrtable_a = (uint16_t*)sqrtable;
@@ -294,7 +294,7 @@
     return param;
 }
 
-static __inline int32_t krecipasm(int32_t i)
+static inline int32_t krecipasm(int32_t i)
 {   // Ken did this
     float f = (float)i;
     i = *(int32_t *)&f;
@@ -303,7 +303,7 @@
 
 
 
-static __inline int32_t getclipmask(int32_t a, int32_t b, int32_t c, int32_t d)
+static inline int32_t getclipmask(int32_t a, int32_t b, int32_t c, int32_t d)
 {   // Ken did this
     d = ((a<0)*8) + ((b<0)*4) + ((c<0)*2) + (d<0);
     return(((d<<4)^0xf0)|d);
@@ -3349,7 +3349,7 @@
     walltype *w;
     sectortype *sect;
 
-#if ((defined PLATFORM_DOS) || (defined PLATFORM_WIN32))
+#if ((defined PLATFORM_DOS) || (defined WIN32))
     permissions = S_IWRITE;
 #elif (defined PLATFORM_UNIX)
     permissions = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
@@ -3581,11 +3581,11 @@
     //CODE EXPLORATION
     //printf("Num palettes lookup: %d.\n",numpalookups);
     
-    if ((palookup[0] = (uint8_t  *)kkmalloc(numpalookups<<8)) == NULL)
+    if ((palookup[0] = (uint8_t  *)malloc(numpalookups<<8)) == NULL)
         allocache(&palookup[0],numpalookups<<8,&permanentlock);
     
     //Transluctent pallete is 65KB.
-    if ((transluc = (uint8_t  *)kkmalloc(65536)) == NULL)
+    if ((transluc = (uint8_t  *)malloc(65536)) == NULL)
         allocache(&transluc,65536,&permanentlock);
 
     globalpalwritten = palookup[0];
@@ -3670,11 +3670,11 @@
 void uninitengine(void)
 {
     if (transluc != NULL) {
-        kkfree(transluc);
+        free(transluc);
         transluc = NULL;
     }
     if (pic != NULL) {
-        kkfree(pic);
+        free(pic);
         pic = NULL;
     }
     if (artfil != -1) kclose(artfil);
@@ -8206,7 +8206,7 @@
     if (palookup[palnum] == NULL)
     {
         /* Allocate palookup buffer */
-        if ((palookup[palnum] = (uint8_t  *)kkmalloc(numpalookups<<8)) == NULL)
+        if ((palookup[palnum] = (uint8_t  *)malloc(numpalookups<<8)) == NULL)
             allocache((int32_t *)&palookup[palnum],numpalookups<<8,&permanentlock);
     }
 
--- a/Engine/src/filesystem.c
+++ b/Engine/src/filesystem.c
@@ -105,9 +105,9 @@
     archive->numFiles = BUILDSWAP_INTEL32(*((int32_t *)&buf[12]));
     
     
-    archive->gfilelist = kmalloc(archive->numFiles * sizeof(grpIndexEntry_t));
-    archive->fileOffsets = kmalloc(archive->numFiles * sizeof(int32_t));
-    archive->filesizes = kmalloc(archive->numFiles * sizeof(int32_t));
+    archive->gfilelist = malloc(archive->numFiles * sizeof(grpIndexEntry_t));
+    archive->fileOffsets = malloc(archive->numFiles * sizeof(int32_t));
+    archive->filesizes = malloc(archive->numFiles * sizeof(int32_t));
     
     // Load the full index 16 bytes per file (12bytes for name + 4 bytes for the size).
     read(archive->fileDescriptor,archive->gfilelist, archive->numFiles * 16);
--- a/Engine/src/fixedPoint_math.h
+++ b/Engine/src/fixedPoint_math.h
@@ -10,19 +10,19 @@
 
 #include "platform.h" 
 
-static __inline void swapchar(uint8_t  *p1, uint8_t  *p2)
+static inline void swapchar(uint8_t  *p1, uint8_t  *p2)
 { uint8_t  tmp = *p1; *p1 = *p2; *p2 = tmp; }
-static __inline void swapshort(short *p1, short *p2)
+static inline void swapshort(short *p1, short *p2)
 { short tmp = *p1; *p1 = *p2; *p2 = tmp; }
-static __inline void swaplong(int32_t *p1, int32_t *p2)
+static inline void swaplong(int32_t *p1, int32_t *p2)
 { int32_t tmp = *p1; *p1 = *p2; *p2 = tmp; }
-static __inline void swapchar2(uint8_t  *p1, uint8_t  *p2, int xsiz)
+static inline void swapchar2(uint8_t  *p1, uint8_t  *p2, int xsiz)
 {
     swapchar(p1, p2);
     swapchar(p1 + 1, p2 + xsiz);
 }
 
-static __inline int32_t msqrtasm(uint32_t input)
+static inline int32_t msqrtasm(uint32_t input)
 {
 	uint32_t a,b;
 
@@ -113,25 +113,25 @@
 DEFFUN(32)
 
 #define DEFFUN(N) \
-static __inline int32_t mulscale##N(int32_t input1, int32_t input2) \
+static inline int32_t mulscale##N(int32_t input1, int32_t input2) \
 { return mulscale(input1,input2,N); }
 DEFFUNCS
 #undef DEFFUN
 
 #define DEFFUN(N) \
-static __inline int32_t dmulscale##N(int32_t input1, int32_t input2,int32_t input3,int32_t input4) \
+static inline int32_t dmulscale##N(int32_t input1, int32_t input2,int32_t input3,int32_t input4) \
 { return dmulscale(input1,input2,input3,input4,N); }
 DEFFUNCS
 #undef DEFFUN
 
 #define DEFFUN(N) \
-static __inline int32_t tmulscale##N(int32_t i1, int32_t i2,int32_t i3,int32_t i4,int32_t i5,int32_t i6) \
+static inline int32_t tmulscale##N(int32_t i1, int32_t i2,int32_t i3,int32_t i4,int32_t i5,int32_t i6) \
 { return tmulscale(i1,i2,i3,i4,i5,i6,N); }
 DEFFUNCS
 #undef DEFFUN
 
 #define DEFFUN(N) \
-static __inline int32_t divscale##N(int32_t input1, int32_t input2) \
+static inline int32_t divscale##N(int32_t input1, int32_t input2) \
 { return divscale(input1,input2,N); }
 DEFFUNCS
 #undef DEFFUN
--- a/Engine/src/macos_compat.h
+++ b/Engine/src/macos_compat.h
@@ -9,14 +9,7 @@
 #ifndef Duke3D_macos_compat_h
 #define Duke3D_macos_compat_h
 
-#define PLATFORM_SUPPORTS_SDL
-
 #include <stdlib.h>
-
-#define kmalloc(x) malloc(x)
-#define kkmalloc(x) malloc(x)
-#define kfree(x) free(x)
-#define kkfree(x) free(x)
 
 #ifdef FP_OFF
 #undef FP_OFF
--- a/Engine/src/mmulti.c
+++ b/Engine/src/mmulti.c
@@ -595,7 +595,7 @@
 
 #elif UDP_NETWORKING
 
-#if PLATFORM_WIN32
+#if WIN32
 #  include <winsock.h>
 #  define EAGAIN WSAEWOULDBLOCK
 #  define EWOULDBLOCK WSAEWOULDBLOCK
@@ -656,7 +656,7 @@
     ctrlc_pressed = 1;
 }
 
-#if PLATFORM_WIN32
+#if WIN32
 /*
  * Figure out what the last failing Win32 API call was, and
  *  generate a human-readable string for the error message.
@@ -764,7 +764,7 @@
 	if (rc == -1)
         err = neterrno();
 
-#if !PLATFORM_WIN32
+#if !WIN32
 	/* !!! FIXME: Linux specific? */
     if (rc == -1)  /* fill in the addr structure on error... */
     {
@@ -939,7 +939,7 @@
 
     /* set socket to be (non-)blocking. */
 
-#if PLATFORM_WIN32
+#if WIN32
     flags = (onOrOff) ? 0 : 1;
     rc = (ioctlsocket(udpsocket, FIONBIO, &flags) == 0);
 #else
@@ -998,7 +998,7 @@
     if (!set_socket_blockmode(0))
         return(0);
 
-    #if !PLATFORM_WIN32
+    #if !WIN32
     {
         /* !!! FIXME: Might be Linux (not Unix, not BSD, not WinSock) specific. */
         int flags = 1;
@@ -1382,7 +1382,7 @@
 
 static int initialize_sockets(void)
 {
-#if PLATFORM_WIN32
+#if WIN32
     int rc;
     WSADATA data;
     printf("initializing WinSock...\n");
@@ -1410,7 +1410,7 @@
 
 static void deinitialize_sockets(void)
 {
-#if PLATFORM_WIN32
+#if WIN32
     WSACleanup();
 #endif
 }
--- a/Engine/src/platform.h
+++ b/Engine/src/platform.h
@@ -1,7 +1,7 @@
 #ifndef _INCLUDE_PLATFORM_H_
 #define _INCLUDE_PLATFORM_H_
 
-#if (defined PLATFORM_WIN32)
+#if (defined WIN32)
     #include "win32_compat.h"
 #elif (defined PLATFORM_UNIX)
     #include "unix_compat.h"
--- a/Engine/src/tiles.c
+++ b/Engine/src/tiles.c
@@ -268,7 +268,7 @@
     /* try dpmi_DETERMINEMAXREALALLOC! */
     
     cachesize = max(artsize,1048576);
-    while ((pic = (uint8_t  *)kkmalloc(cachesize)) == NULL)
+    while ((pic = (uint8_t  *)malloc(cachesize)) == NULL)
     {
         cachesize -= 65536L;
         if (cachesize < 65536) return(-1);
--- a/Engine/src/unix_compat.h
+++ b/Engine/src/unix_compat.h
@@ -10,14 +10,8 @@
 #define Duke3D_unix_compat_h
 
 //#define BYTE_ORDER LITTLE_ENDIAN
-#define PLATFORM_SUPPORTS_SDL
 
 #include <stdlib.h>
-
-#define kmalloc(x) malloc(x)
-#define kkmalloc(x) malloc(x)
-#define kfree(x) free(x)
-#define kkfree(x) free(x)
 
 #ifdef FP_OFF
 #undef FP_OFF
--- a/Engine/src/win32_compat.h
+++ b/Engine/src/win32_compat.h
@@ -14,18 +14,10 @@
  * See the included license file "BUILDLIC.TXT" for license info.
  * This file IS NOT A PART OF Ken Silverman's original release
  */
-
-
   
 #ifndef _INCLUDE_WIN32_COMPAT_H_
 #define _INCLUDE_WIN32_COMPAT_H_
 
-#if (!defined PLATFORM_WIN32)
-#error PLATFORM_WIN32 is not defined.
-#endif
-
-#define PLATFORM_SUPPORTS_SDL
-
 #include <stdio.h>
 
 #if (!defined _MSC_VER)
@@ -43,11 +35,6 @@
 #include <assert.h>
 #include <string.h>
 
-#define kmalloc(x) malloc(x)
-#define kkmalloc(x) malloc(x)
-#define kfree(x) free(x)
-#define kkfree(x) free(x)
-
 #ifdef FP_OFF
 #undef FP_OFF
 #endif
@@ -66,17 +53,7 @@
 #define min(x, y)  (((x) < (y)) ? (x) : (y))
 #endif
 
-#if (defined __WATCOMC__)
-#define inline
-#pragma intrinsic(min);
-#pragma intrinsic(max);
-#define __int64 long long
-#endif
-
 #if (defined _MSC_VER)
-#if ((!defined _INTEGRAL_MAX_BITS) || (_INTEGRAL_MAX_BITS < 64))
-#error __int64 type not supported
-#endif
 
 #define open _open
 #define O_BINARY _O_BINARY
@@ -94,13 +71,8 @@
 
 #define strncasecmp strnicmp
 
-//Damn you Microsoft, how hard would it REALLY be to support C99 ?!??!?!
-#define inline 
-#include "windows/inttypes.h"
+#include <inttypes.h>
 
 #endif
 
 /* end of win32_compat.h ... */
-
-
-
--- a/Engine/src/windows/inttypes.h
+++ /dev/null
@@ -1,305 +1,0 @@
-// ISO C9x  compliant inttypes.h for Microsoft Visual Studio
-// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 
-// 
-//  Copyright (c) 2006 Alexander Chemeris
-// 
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-// 
-//   1. Redistributions of source code must retain the above copyright notice,
-//      this list of conditions and the following disclaimer.
-// 
-//   2. Redistributions in binary form must reproduce the above copyright
-//      notice, this list of conditions and the following disclaimer in the
-//      documentation and/or other materials provided with the distribution.
-// 
-//   3. The name of the author may be used to endorse or promote products
-//      derived from this software without specific prior written permission.
-// 
-// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
-// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// 
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef _MSC_VER // [
-#error "Use this header only with Microsoft Visual C++ compilers!"
-#endif // _MSC_VER ]
-
-#ifndef _MSC_INTTYPES_H_ // [
-#define _MSC_INTTYPES_H_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif
-
-#include "stdint.h"
-
-// 7.8 Format conversion of integer types
-
-typedef struct {
-   intmax_t quot;
-   intmax_t rem;
-} imaxdiv_t;
-
-// 7.8.1 Macros for format specifiers
-
-#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [   See footnote 185 at page 198
-
-// The fprintf macros for signed integers are:
-#define PRId8       "d"
-#define PRIi8       "i"
-#define PRIdLEAST8  "d"
-#define PRIiLEAST8  "i"
-#define PRIdFAST8   "d"
-#define PRIiFAST8   "i"
-
-#define PRId16       "hd"
-#define PRIi16       "hi"
-#define PRIdLEAST16  "hd"
-#define PRIiLEAST16  "hi"
-#define PRIdFAST16   "hd"
-#define PRIiFAST16   "hi"
-
-#define PRId32       "I32d"
-#define PRIi32       "I32i"
-#define PRIdLEAST32  "I32d"
-#define PRIiLEAST32  "I32i"
-#define PRIdFAST32   "I32d"
-#define PRIiFAST32   "I32i"
-
-#define PRId64       "I64d"
-#define PRIi64       "I64i"
-#define PRIdLEAST64  "I64d"
-#define PRIiLEAST64  "I64i"
-#define PRIdFAST64   "I64d"
-#define PRIiFAST64   "I64i"
-
-#define PRIdMAX     "I64d"
-#define PRIiMAX     "I64i"
-
-#define PRIdPTR     "Id"
-#define PRIiPTR     "Ii"
-
-// The fprintf macros for unsigned integers are:
-#define PRIo8       "o"
-#define PRIu8       "u"
-#define PRIx8       "x"
-#define PRIX8       "X"
-#define PRIoLEAST8  "o"
-#define PRIuLEAST8  "u"
-#define PRIxLEAST8  "x"
-#define PRIXLEAST8  "X"
-#define PRIoFAST8   "o"
-#define PRIuFAST8   "u"
-#define PRIxFAST8   "x"
-#define PRIXFAST8   "X"
-
-#define PRIo16       "ho"
-#define PRIu16       "hu"
-#define PRIx16       "hx"
-#define PRIX16       "hX"
-#define PRIoLEAST16  "ho"
-#define PRIuLEAST16  "hu"
-#define PRIxLEAST16  "hx"
-#define PRIXLEAST16  "hX"
-#define PRIoFAST16   "ho"
-#define PRIuFAST16   "hu"
-#define PRIxFAST16   "hx"
-#define PRIXFAST16   "hX"
-
-#define PRIo32       "I32o"
-#define PRIu32       "I32u"
-#define PRIx32       "I32x"
-#define PRIX32       "I32X"
-#define PRIoLEAST32  "I32o"
-#define PRIuLEAST32  "I32u"
-#define PRIxLEAST32  "I32x"
-#define PRIXLEAST32  "I32X"
-#define PRIoFAST32   "I32o"
-#define PRIuFAST32   "I32u"
-#define PRIxFAST32   "I32x"
-#define PRIXFAST32   "I32X"
-
-#define PRIo64       "I64o"
-#define PRIu64       "I64u"
-#define PRIx64       "I64x"
-#define PRIX64       "I64X"
-#define PRIoLEAST64  "I64o"
-#define PRIuLEAST64  "I64u"
-#define PRIxLEAST64  "I64x"
-#define PRIXLEAST64  "I64X"
-#define PRIoFAST64   "I64o"
-#define PRIuFAST64   "I64u"
-#define PRIxFAST64   "I64x"
-#define PRIXFAST64   "I64X"
-
-#define PRIoMAX     "I64o"
-#define PRIuMAX     "I64u"
-#define PRIxMAX     "I64x"
-#define PRIXMAX     "I64X"
-
-#define PRIoPTR     "Io"
-#define PRIuPTR     "Iu"
-#define PRIxPTR     "Ix"
-#define PRIXPTR     "IX"
-
-// The fscanf macros for signed integers are:
-#define SCNd8       "d"
-#define SCNi8       "i"
-#define SCNdLEAST8  "d"
-#define SCNiLEAST8  "i"
-#define SCNdFAST8   "d"
-#define SCNiFAST8   "i"
-
-#define SCNd16       "hd"
-#define SCNi16       "hi"
-#define SCNdLEAST16  "hd"
-#define SCNiLEAST16  "hi"
-#define SCNdFAST16   "hd"
-#define SCNiFAST16   "hi"
-
-#define SCNd32       "ld"
-#define SCNi32       "li"
-#define SCNdLEAST32  "ld"
-#define SCNiLEAST32  "li"
-#define SCNdFAST32   "ld"
-#define SCNiFAST32   "li"
-
-#define SCNd64       "I64d"
-#define SCNi64       "I64i"
-#define SCNdLEAST64  "I64d"
-#define SCNiLEAST64  "I64i"
-#define SCNdFAST64   "I64d"
-#define SCNiFAST64   "I64i"
-
-#define SCNdMAX     "I64d"
-#define SCNiMAX     "I64i"
-
-#ifdef _WIN64 // [
-#  define SCNdPTR     "I64d"
-#  define SCNiPTR     "I64i"
-#else  // _WIN64 ][
-#  define SCNdPTR     "ld"
-#  define SCNiPTR     "li"
-#endif  // _WIN64 ]
-
-// The fscanf macros for unsigned integers are:
-#define SCNo8       "o"
-#define SCNu8       "u"
-#define SCNx8       "x"
-#define SCNX8       "X"
-#define SCNoLEAST8  "o"
-#define SCNuLEAST8  "u"
-#define SCNxLEAST8  "x"
-#define SCNXLEAST8  "X"
-#define SCNoFAST8   "o"
-#define SCNuFAST8   "u"
-#define SCNxFAST8   "x"
-#define SCNXFAST8   "X"
-
-#define SCNo16       "ho"
-#define SCNu16       "hu"
-#define SCNx16       "hx"
-#define SCNX16       "hX"
-#define SCNoLEAST16  "ho"
-#define SCNuLEAST16  "hu"
-#define SCNxLEAST16  "hx"
-#define SCNXLEAST16  "hX"
-#define SCNoFAST16   "ho"
-#define SCNuFAST16   "hu"
-#define SCNxFAST16   "hx"
-#define SCNXFAST16   "hX"
-
-#define SCNo32       "lo"
-#define SCNu32       "lu"
-#define SCNx32       "lx"
-#define SCNX32       "lX"
-#define SCNoLEAST32  "lo"
-#define SCNuLEAST32  "lu"
-#define SCNxLEAST32  "lx"
-#define SCNXLEAST32  "lX"
-#define SCNoFAST32   "lo"
-#define SCNuFAST32   "lu"
-#define SCNxFAST32   "lx"
-#define SCNXFAST32   "lX"
-
-#define SCNo64       "I64o"
-#define SCNu64       "I64u"
-#define SCNx64       "I64x"
-#define SCNX64       "I64X"
-#define SCNoLEAST64  "I64o"
-#define SCNuLEAST64  "I64u"
-#define SCNxLEAST64  "I64x"
-#define SCNXLEAST64  "I64X"
-#define SCNoFAST64   "I64o"
-#define SCNuFAST64   "I64u"
-#define SCNxFAST64   "I64x"
-#define SCNXFAST64   "I64X"
-
-#define SCNoMAX     "I64o"
-#define SCNuMAX     "I64u"
-#define SCNxMAX     "I64x"
-#define SCNXMAX     "I64X"
-
-#ifdef _WIN64 // [
-#  define SCNoPTR     "I64o"
-#  define SCNuPTR     "I64u"
-#  define SCNxPTR     "I64x"
-#  define SCNXPTR     "I64X"
-#else  // _WIN64 ][
-#  define SCNoPTR     "lo"
-#  define SCNuPTR     "lu"
-#  define SCNxPTR     "lx"
-#  define SCNXPTR     "lX"
-#endif  // _WIN64 ]
-
-#endif // __STDC_FORMAT_MACROS ]
-
-// 7.8.2 Functions for greatest-width integer types
-
-// 7.8.2.1 The imaxabs function
-#define imaxabs _abs64
-
-// 7.8.2.2 The imaxdiv function
-
-// This is modified version of div() function from Microsoft's div.c found
-// in %MSVC.NET%\crt\src\div.c
-#ifdef STATIC_IMAXDIV // [
-static
-#else // STATIC_IMAXDIV ][
-_inline
-#endif // STATIC_IMAXDIV ]
-imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
-{
-   imaxdiv_t result;
-
-   result.quot = numer / denom;
-   result.rem = numer % denom;
-
-   if (numer < 0 && result.rem > 0) {
-      // did division wrong; must fix up
-      ++result.quot;
-      result.rem -= denom;
-   }
-
-   return result;
-}
-
-// 7.8.2.3 The strtoimax and strtoumax functions
-#define strtoimax _strtoi64
-#define strtoumax _strtoui64
-
-// 7.8.2.4 The wcstoimax and wcstoumax functions
-#define wcstoimax _wcstoi64
-#define wcstoumax _wcstoui64
-
-
-#endif // _MSC_INTTYPES_H_ ]