You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by John Mark Vandenberg <ja...@gmail.com> on 2006/04/15 03:41:23 UTC
[patch 05/17] win32api support
The include paths are automaticly set up to be:
-I./include
-I/path/to/apr/include/arch/win32
-I./include/arch/unix
-I/path/to/apr/include
This patch sets up the MINGW header arrangement as follows:
include/apr.h.in -> apr.h includes
windows.h
winsock2.h
include/arch/win32/apr_private.h
as per MS VC++ builds
include/arch/unix/apr_private.h.in include/arch/unix/apr_private.h
not used. In order to achieve this, AH_TOP & AH_BOTTOM add a
condition around this generated file to prevent it from being
included.
This set up requires careful ordering of includes. Includes from
a unix header will result in the unix copy being included even if
a win32 copy exists.
for example, apr_private.h will exist in include/arch/win32/ and
include/arch/unix/, requiring that apr_private.h is included very
early to prevent a unix header including it.
locks/unix/global_mutex.c illistrates why this probably needs to be
improved before check. Without the changes in this patch:
global_mutex.c
...
include/arch/unix/apr_arch_global_mutex.h
...
include/arch/unix/apr_arch_thread_mutex.h <- wrong
Index: configure.in
===================================================================
--- configure.in.orig
+++ configure.in
@@ -21,6 +21,15 @@ sinclude(build/apr_hints.m4)
sinclude(build/libtool.m4)
sinclude(build/ltsugar.m4)
+dnl For win32, we need to be sure that arch/win32/apr_private.h is
+dnl included first, and the unix one cant be included
+AH_TOP([
+
+#ifndef APR_PRIVATE_H
+#define APR_PRIVATE_H
+
+])
+
dnl Hard-coded inclusion at the tail end of apr_private.h:
AH_BOTTOM([
/* switch this on if we have a BeOS version below BONE */
@@ -34,6 +43,8 @@ AH_BOTTOM([
* Include common private declarations.
*/
#include "../apr_private_common.h"
+
+#endif /* APR_PRIVATE_H */
])
dnl Save user-defined environment settings for later restoration
@@ -1058,6 +1069,8 @@ APR_FLAG_HEADERS(
unix.h \
arpa/inet.h \
kernel/OS.h \
+ windows.h \
+ winsock2.h \
net/errno.h \
netinet/in.h \
netinet/sctp.h \
@@ -1134,6 +1147,8 @@ AC_SUBST(signalh)
AC_SUBST(sys_waith)
AC_SUBST(pthreadh)
AC_SUBST(semaphoreh)
+AC_SUBST(windowsh)
+AC_SUBST(winsock2h)
# Checking for h_errno in <netdb.h>
if test "$netdbh" = "1"; then
Index: include/apr.h.in
===================================================================
--- include/apr.h.in.orig
+++ include/apr.h.in
@@ -102,6 +102,8 @@
#define APR_HAVE_SYS_WAIT_H @sys_waith@
#define APR_HAVE_TIME_H @timeh@
#define APR_HAVE_UNISTD_H @unistdh@
+#define APR_HAVE_WINDOWS_H @windowsh@
+#define APR_HAVE_WINSOCK2_H @winsock2h@
/** @} */
@@ -109,6 +111,14 @@
* or the extern "C" namespace
*/
+#if defined(APR_HAVE_WINDOWS_H)
+#include <windows.h>
+#endif
+
+#if defined(APR_HAVE_WINSOCK2_H)
+#include <winsock2.h>
+#endif
+
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
Index: atomic/win32/apr_atomic.c
===================================================================
--- atomic/win32/apr_atomic.c.orig
+++ atomic/win32/apr_atomic.c
@@ -15,6 +15,7 @@
*/
#include "apr.h"
+#include "apr_private.h"
#include "apr_atomic.h"
#include "apr_thread_mutex.h"
Index: misc/win32/apr_app.c
===================================================================
--- misc/win32/apr_app.c.orig
+++ misc/win32/apr_app.c
@@ -34,12 +34,12 @@
*/
#include "apr_general.h"
+#include "apr_private.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"
/* This symbol is _private_, although it must be exported.
Index: locks/unix/global_mutex.c
===================================================================
--- locks/unix/global_mutex.c.orig
+++ locks/unix/global_mutex.c
@@ -16,6 +16,10 @@
#include "apr.h"
#include "apr_strings.h"
+// horrible hack to force win32 header inclusion
+#include "apr_private.h"
+#include "apr_arch_thread_mutex.h"
+
#include "apr_arch_global_mutex.h"
#include "apr_proc_mutex.h"
#include "apr_thread_mutex.h"
--
Re: [patch 05/17] win32api support
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On 4/14/06, John Mark Vandenberg <ja...@gmail.com> wrote:
> The include paths are automaticly set up to be:
> -I./include
> -I/path/to/apr/include/arch/win32
> -I./include/arch/unix
> -I/path/to/apr/include
>
> This patch sets up the MINGW header arrangement as follows:
>
> include/apr.h.in -> apr.h includes
> windows.h
> winsock2.h
>
> include/arch/win32/apr_private.h
> as per MS VC++ builds
>
> include/arch/unix/apr_private.h.in include/arch/unix/apr_private.h
> not used. In order to achieve this, AH_TOP & AH_BOTTOM add a
> condition around this generated file to prevent it from being
> included.
I think the better thing to do is just toss arch/unix/apr_private.h
instead. This way there is no confusion by the preprocessor. I'm
going to try to go down that route and see how far I get. I realize
we may need to re-evaluate that decision later, but I'm hopeful... =)
I've committed the other bits from this set - suitably tweaked - in r421063.
Thanks! -- justin