[PATCH] Support cross compiling with MinGW-w64 on Debian GNU/Linux

Maxim Dounin mdounin at mdounin.ru
Mon Oct 27 17:47:11 UTC 2014


Hello!

On Tue, Oct 28, 2014 at 12:01:26AM +0900, Kouhei Sutou wrote:

> Hi,
> 
> Could you confirm the patch?
> 
>   http://mailman.nginx.org/pipermail/nginx-devel/2014-October/006094.html

Sorry, I have been travelling to the nginx.conf conference and 
wasn't yet able to review the patch.  Below are the patch after 
some polishing.  Changes include:

- the NGX_GNUC_64 macro was removed, __MINGW64_VERSION_MAJOR 
  tested directly instead;

- the #include <_mingw.h> removed as tests are after includes now, 
  see [1];

- some style nits.

Please test if it still works for you.

[1] https://www.mail-archive.com/mingw-w64-public@lists.sourceforge.net/msg00638.html

# HG changeset patch
# User Kouhei Sutou <kou at cozmixng.org>
# Date 1413375301 -32400
#      Wed Oct 15 21:15:01 2014 +0900
# Node ID 839983fff39f58d151e582987f6d3bd9833efde6
# Parent  973fded4f461f3a397779b3a1dc80881b1b34974
Win32: made build-able with MinGW-w64 gcc.

diff -r 973fded4f461 -r 839983fff39f src/os/win32/ngx_win32_config.h
--- a/src/os/win32/ngx_win32_config.h	Wed Oct 15 22:57:23 2014 +0400
+++ b/src/os/win32/ngx_win32_config.h	Wed Oct 15 21:15:01 2014 +0900
@@ -37,14 +37,24 @@
 #include <shellapi.h>
 #include <stddef.h>    /* offsetof() */
 
-#ifdef __GNUC__
+#ifdef __MINGW64_VERSION_MAJOR
+
+/* GCC MinGW-w64 supports _FILE_OFFSET_BITS */
+#define _FILE_OFFSET_BITS 64
+
+#elif defined __GNUC__
+
 /* GCC MinGW's stdio.h includes sys/types.h */
 #define _OFF_T_
+
 #endif
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#ifdef __MINGW64_VERSION_MAJOR
+#include <stdint.h>
+#endif
 #include <ctype.h>
 #include <locale.h>
 
@@ -136,16 +146,21 @@ typedef unsigned short int  uint16_t;
 typedef __int64             int64_t;
 typedef unsigned __int64    uint64_t;
 
-#ifndef __WATCOMC__
+#if !defined(__WATCOMC__) && !defined(__MINGW64_VERSION_MAJOR)
 typedef int                 intptr_t;
 typedef u_int               uintptr_t;
 #endif
 
 
+#ifndef __MINGW64_VERSION_MAJOR
+
 /* Windows defines off_t as long, which is 32-bit */
 typedef __int64             off_t;
 #define _OFF_T_DEFINED
 
+#endif
+
+
 #ifdef __WATCOMC__
 
 /* off_t is redefined by sys/types.h used by zlib.h */
@@ -164,17 +179,35 @@ typedef unsigned int        ino_t;
 #endif
 
 
+#ifndef __MINGW64_VERSION_MAJOR
 typedef int                 ssize_t;
+#endif
+
+
 typedef uint32_t            in_addr_t;
 typedef u_short             in_port_t;
 typedef int                 sig_atomic_t;
 
 
+#ifdef _WIN64
+
+#define NGX_PTR_SIZE            8
+#define NGX_SIZE_T_LEN          (sizeof("-9223372036854775808") - 1)
+#define NGX_MAX_SIZE_T_VALUE    9223372036854775807
+#define NGX_TIME_T_LEN          (sizeof("-9223372036854775808") - 1)
+#define NGX_TIME_T_SIZE         8
+
+#else
+
 #define NGX_PTR_SIZE            4
 #define NGX_SIZE_T_LEN          (sizeof("-2147483648") - 1)
 #define NGX_MAX_SIZE_T_VALUE    2147483647
 #define NGX_TIME_T_LEN          (sizeof("-2147483648") - 1)
 #define NGX_TIME_T_SIZE         4
+
+#endif
+
+
 #define NGX_OFF_T_LEN           (sizeof("-9223372036854775807") - 1)
 #define NGX_MAX_OFF_T_VALUE     9223372036854775807
 #define NGX_SIG_ATOMIC_T_SIZE   4

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx-devel mailing list