As promised here are the patches needed to build libapr.dll
with MingW + gcc 3.x.

* The inline problem is avoided  by this (contrary to my previous
  message):
#if defined(__GNUC__)
#define APR_INLINE extern __inline
#else
#define APR_INLINE __inline
#endif

* Replaced "__inline" with "APR_INLINE" in some headers. 
  Assuming that's an omission and not a conscious choice (?)
  And some hacks for redefining inline; see apr_pools.c. Add
  another APR_LOCAL_INLINE?

* 'apr_wchar_t' was type-def'ed in 2 places. Added a guard.

* <ShellAPI.h> and <AclAPI.h> are needed for MingW. MSVC
  seems to include these by default (outside WIN32_LEAN_AND_MEAN)

* Only (?) MSVC has <crtdbg.h>. <rpc.h> needed for definition of UUID.

* __attribute__ cannot be ifndef'ed away. All hell breaks loose if you do.

Gisle V.

# rm /bin/laden 
/bin/laden: Not found 
diff -u3 -Hb -r CVS-latest\atomic\win32\apr_atomic.c .\atomic\win32\apr_atomic.c
--- CVS-latest\atomic\win32\apr_atomic.c        Fri Apr 16 15:54:19 2004
+++ .\atomic\win32\apr_atomic.c Mon Aug 30 22:28:38 2004
@@ -44,8 +44,9 @@
 }

 /* Of course we want the 2's compliment of the unsigned value, val */
+#if defined(_MSC_VER)
 #pragma warning(disable: 4146)
-
+#endif
 APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t 
val)
 {
     ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem, -val);
diff -u3 -Hb -r CVS-latest\include\apr.hw .\include\apr.hw
--- CVS-latest\include\apr.hw   Sat Jun 05 01:22:00 2004
+++ .\include\apr.hw    Mon Aug 30 23:15:56 2004
@@ -53,7 +53,9 @@
  *   C4244: int to char/short - precision loss
  *   C4514: unreferenced inline function removed
  */
+#if defined(_MSC_VER)
 #pragma warning(disable: 4100 4127 4163 4201 4514; once: 4057 4075 4244)
+#endif

 /* Has windows.h already been included?  If so, our preferences don't matter,
  * but we will still need the winsock things no matter what was included.
@@ -98,10 +100,14 @@
  * @ingroup APR
  * @{
  */
-
+#if defined(__GNUC__)
+#define APR_INLINE extern __inline
+#else
 #define APR_INLINE __inline
+#endif
+
 #define APR_HAS_INLINE          1
-#ifndef __attribute__
+#if !defined(__GNUC__) && !defined(__attribute__)
 #define __attribute__(__x)
 #endif

@@ -351,8 +357,13 @@

 /* Mechanisms to properly type numeric literals */

+#if defined(__GNUC__)
+#define APR_INT64_C(val) (val##LL)
+#define APR_UINT64_C(val) (val##ULL)
+#else
 #define APR_INT64_C(val) (val##i64)
 #define APR_UINT64_C(val) (val##Ui64)
+#endif


 #if APR_HAVE_IPV6
@@ -363,7 +374,7 @@
 #endif

 #ifndef WS2TCPIP_INLINE
-6:09 PM 11/16/2003#define IN6_IS_ADDR_V4MAPPED(a) \
+#define IN6_IS_ADDR_V4MAPPED(a) \
     (   (*(const apr_uint64_t *)(const void *)(&(a)->s6_addr[0]) == 0) \
      && (*(const apr_uint32_t *)(const void *)(&(a)->s6_addr[8]) == 
ntohl(0x0000ffff)))
 #endif
diff -u3 -Hb -r CVS-latest\include\arch\win32\apr_arch_atime.h 
.\include\arch\win32\apr_arch_atime.h
--- CVS-latest\include\arch\win32\apr_arch_atime.h      Fri Feb 13 11:38:31 2004
+++ .\include\arch\win32\apr_arch_atime.h       Tue Aug 31 01:07:09 2004
@@ -34,8 +34,7 @@
  */
 #define APR_DELTA_EPOCH_IN_USEC   APR_TIME_C(11644473600000000);

-
-__inline void FileTimeToAprTime(apr_time_t *result, FILETIME *input)
+APR_INLINE void FileTimeToAprTime(apr_time_t *result, FILETIME *input)
 {
     /* Convert FILETIME one 64 bit number so we can work with it. */
     *result = input->dwHighDateTime;
@@ -47,7 +46,7 @@
 }


-__inline void AprTimeToFileTime(LPFILETIME pft, apr_time_t t)
+APR_INLINE void AprTimeToFileTime(LPFILETIME pft, apr_time_t t)
 {
     LONGLONG ll;
     t += APR_DELTA_EPOCH_IN_USEC;
diff -u3 -Hb -r CVS-latest\include\arch\win32\apr_arch_file_io.h 
.\include\arch\win32\apr_arch_file_io.h
--- CVS-latest\include\arch\win32\apr_arch_file_io.h    Fri Feb 13 11:38:31 2004
+++ .\include\arch\win32\apr_arch_file_io.h     Mon Aug 30 21:39:57 2004
@@ -51,7 +51,10 @@
 #include "arch/win32/apr_arch_utf8.h"
 #include <wchar.h>

+#ifndef APR_WCHAR_T_DEFINED
 typedef apr_uint16_t apr_wchar_t;
+#define APR_WCHAR_T_DEFINED
+#endif

 /* Helper functions for the WinNT ApiW() functions.  APR treats all
  * resource identifiers (files, etc) by their UTF-8 name, to provide
diff -u3 -Hb -r CVS-latest\include\arch\win32\apr_arch_misc.h 
.\include\arch\win32\apr_arch_misc.h
--- CVS-latest\include\arch\win32\apr_arch_misc.h       Fri Feb 13 11:38:31 2004
+++ .\include\arch\win32\apr_arch_misc.h        Mon Aug 30 23:42:57 2004
@@ -45,6 +45,9 @@
 #include <string.h>
 #endif

+#include <ShellAPI.h> /* CommandLineToArgvW */
+#include <AclAPI.h>   /* GetSecurityInfo etc. */
+
 struct apr_other_child_rec_t {
     apr_pool_t *p;
     struct apr_other_child_rec_t *next;
@@ -129,7 +132,7 @@
 #if APR_HAS_ANSI_FS && APR_HAS_UNICODE_FS
 #define IF_WIN_OS_IS_UNICODE if (apr_os_level >= APR_WIN_UNICODE)
 #define ELSE_WIN_OS_IS_ANSI else
-#else APR_HAS_UNICODE_FS
+#else /* APR_HAS_UNICODE_FS */
 #define IF_WIN_OS_IS_UNICODE
 #define ELSE_WIN_OS_IS_ANSI
 #endif /* WINNT */
@@ -151,10 +154,13 @@
 #define APR_DECLARE_LATE_DLL_FUNC(lib, rettype, calltype, fn, ord, args, 
names) \
     typedef rettype (calltype *apr_winapi_fpt_##fn) args; \
     static apr_winapi_fpt_##fn apr_winapi_pfn_##fn = NULL; \
-    __inline rettype apr_winapi_##fn args \
+    APR_INLINE rettype apr_winapi_##fn args \
     {   if (!apr_winapi_pfn_##fn) \
             apr_winapi_pfn_##fn = (apr_winapi_fpt_##fn) \
                                       apr_load_dll_func(lib, #fn, ord); \
+        if (!apr_winapi_pfn_##fn) \
+           printf ("%s(%u): Failed to load lib %d/%s\n", __FILE__, __LINE__, \
+                   lib, " #fn "); \
         return (*(apr_winapi_pfn_##fn)) names; }; \

 /* Provide late bound declarations of every API function missing from
diff -u3 -Hb -r CVS-latest\include\arch\win32\apr_arch_utf8.h 
.\include\arch\win32\apr_arch_utf8.h
--- CVS-latest\include\arch\win32\apr_arch_utf8.h       Fri Feb 13 11:38:31 2004
+++ .\include\arch\win32\apr_arch_utf8.h        Thu Aug 26 21:10:58 2004
@@ -22,7 +22,10 @@

 /* If we ever support anything more exciting than char... this could move.
  */
+#ifndef APR_WCHAR_T_DEFINED
 typedef apr_uint16_t apr_wchar_t;
+#define APR_WCHAR_T_DEFINED
+#endif

 /**
  * An APR internal function for fast utf-8 octet-encoded Unicode conversion
diff -u3 -Hb -r CVS-latest\include\arch\win32\apr_private.h 
.\include\arch\win32\apr_private.h
--- CVS-latest\include\arch\win32\apr_private.h Sat Jun 05 01:26:02 2004
+++ .\include\arch\win32\apr_private.h  Thu Aug 26 23:51:40 2004
@@ -113,7 +113,9 @@
 #define SIGWINCH   30
 #define SIGIO      31

+#ifndef __GNUC__
 #define __attribute__(__x)
+#endif

 /* APR COMPATABILITY FUNCTIONS
  * This section should be used to define functions and
@@ -144,7 +146,7 @@
 #endif

 /* MSVC 7.0 introduced _strtoi64 */
-#if _MSC_VER >= 1300 && _INTEGRAL_MAX_BITS >= 64
+#if defined(_MSC_VER) && (_MSC_VER >= 1300 && _INTEGRAL_MAX_BITS >= 64)
 #define APR_INT64_STRFN              _strtoi64
 #endif

diff -u3 -Hb -r CVS-latest\memory\unix\apr_pools.c .\memory\unix\apr_pools.c
--- CVS-latest\memory\unix\apr_pools.c  Thu Jun 17 16:13:58 2004
+++ .\memory\unix\apr_pools.c   Mon Aug 30 23:31:22 2004
@@ -37,6 +37,12 @@
 #include <unistd.h>     /* for getpid */
 #endif

+/* Hack ahead. Maybe need a new APR_LOCAL_INLINE?
+ */
+#if defined(_WIN32) && defined(__GNUC__)
+#undef  APR_INLINE
+#define APR_INLINE __inline
+#endif

 /*
  * Magic numbers
diff -u3 -Hb -r CVS-latest\misc\win32\apr_app.c .\misc\win32\apr_app.c
--- CVS-latest\misc\win32\apr_app.c     Fri Feb 13 11:38:32 2004
+++ .\misc\win32\apr_app.c      Mon Aug 30 22:14:51 2004
@@ -34,13 +34,19 @@

 #include "apr_general.h"
 #include "ShellAPI.h"
-#include "crtdbg.h"
 #include "wchar.h"
 #include "apr_arch_file_io.h"
 #include "assert.h"
 #include "apr_private.h"
 #include "apr_arch_misc.h"

+#if defined(_MSC_VER)
+#include <crtdbg.h>
+#else
+#define _malloc_dbg(s,x,f,l)     malloc(s)
+#define _realloc_dbg(p,s,x,f,l)  realloc(p,s)
+#endif
+
 /* This symbol is _private_, although it must be exported.
  */

diff -u3 -Hb -r CVS-latest\misc\win32\internal.c .\misc\win32\internal.c
--- CVS-latest\misc\win32\internal.c    Fri Feb 13 11:38:32 2004
+++ .\misc\win32\internal.c     Mon Aug 30 22:14:39 2004
@@ -14,12 +14,17 @@
  */

 #include "apr_private.h"
-
 #include "apr_arch_misc.h"
 #include "apr_arch_file_io.h"
-#include <crtdbg.h>
 #include <assert.h>

+#if defined(_MSC_VER)
+#include <crtdbg.h>
+#else
+#define _malloc_dbg(s,x,f,l)     malloc(s)
+#define _realloc_dbg(p,s,x,f,l)  realloc(p,s)
+#endif
+
 /* This module is the source of -static- helper functions that are
  * entirely internal to apr.  If the fn is exported - it does not
  * belong here.
diff -u3 -Hb -r CVS-latest\misc\win32\misc.c .\misc\win32\misc.c
--- CVS-latest\misc\win32\misc.c        Fri Feb 13 11:38:32 2004
+++ .\misc\win32\misc.c Mon Aug 30 22:15:38 2004
@@ -15,7 +15,9 @@

 #include "apr_private.h"
 #include "apr_arch_misc.h"
+#if defined(_MSC_VER)
 #include "crtdbg.h"
+#endif
 #include "apr_arch_file_io.h"
 #include "assert.h"
 #include "apr_lib.h"
diff -u3 -Hb -r CVS-latest\misc\win32\rand.c .\misc\win32\rand.c
--- CVS-latest\misc\win32\rand.c        Fri Feb 13 11:38:32 2004
+++ .\misc\win32\rand.c Mon Aug 30 23:04:26 2004
@@ -19,6 +19,7 @@
 #include "apr_portable.h"
 #include "apr_arch_misc.h"
 #include <wincrypt.h>
+#include <rpc.h>


 APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char * buf,
diff -u3 -Hb -r CVS-latest\misc\win32\start.c .\misc\win32\start.c
--- CVS-latest\misc\win32\start.c       Fri Feb 13 11:38:32 2004
+++ .\misc\win32\start.c        Mon Aug 30 22:15:02 2004
@@ -22,9 +22,15 @@
 #include "apr_arch_misc.h"       /* for WSAHighByte / WSALowByte */
 #include "wchar.h"
 #include "apr_arch_file_io.h"
-#include "crtdbg.h"
 #include "assert.h"

+#if defined(_MSC_VER)
+#include "crtdbg.h"
+#else
+#define _malloc_dbg(s,x,f,l)     malloc(s)
+#define _realloc_dbg(p,s,x,f,l)  realloc(p,s)
+#endif
+
 /* This symbol is _private_, although it must be exported.
  */
 int APR_DECLARE_DATA apr_app_init_complete = 0;
diff -u3 -Hb -r CVS-latest\tables\apr_tables.c .\tables\apr_tables.c
--- CVS-latest\tables\apr_tables.c      Fri Feb 13 11:38:34 2004
+++ .\tables\apr_tables.c       Mon Aug 30 23:31:46 2004
@@ -38,6 +38,13 @@
 #include <strings.h>
 #endif

+/* Hack ahead. Maybe need a new APR_LOCAL_INLINE?
+ */
+#if defined(_WIN32) && defined(__GNUC__)
+#undef  APR_INLINE
+#define APR_INLINE __inline
+#endif
+
 /*****************************************************************
  * This file contains array and apr_table_t functions only.
  */

Reply via email to