Hello,
after some work I made a fully working port.
This patch includes the fixes in my previous (uncommitted) patches with newer
ones.
I did a checkout of the very latest SVN tree and I ported my changes on those
sources.
I hope this will be helpful.
Sincerely,
Carlo Bramini.
Index: include/apr.h.in
===================================================================
--- include/apr.h.in (revisione 710059)
+++ include/apr.h.in (copia locale)
@@ -105,8 +105,11 @@
#define APR_HAVE_SYS_WAIT_H @sys_waith@
#define APR_HAVE_TIME_H @timeh@
#define APR_HAVE_UNISTD_H @unistdh@
+#define APR_HAVE_STDDEF_H @stddefh@
+#define APR_HAVE_PROCESS_H @processh@
#define APR_HAVE_WINDOWS_H @windowsh@
#define APR_HAVE_WINSOCK2_H @winsock2h@
+#define APR_HAVE_TLHELP32_H @tlhelp32h@
/** @} */
/** @} */
@@ -116,17 +119,47 @@
*/
#if APR_HAVE_WINDOWS_H
+/* Required for NTFS support */
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0500
+#endif
#include <windows.h>
#endif
#if APR_HAVE_WINSOCK2_H
#include <winsock2.h>
+#include <mswsock.h>
+#include <ws2tcpip.h>
#endif
+#if APR_HAVE_TLHELP32_H
+#include <tlhelp32.h>
+#endif
+
+#if APR_HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#if APR_HAVE_STDIO_H
+#include <stdio.h>
+#endif
+
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
+#if APR_HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+
+#if APR_HAVE_TIME_H
+#include <time.h>
+#endif
+
+#if APR_HAVE_PROCESS_H
+#include <process.h>
+#endif
+
#if APR_HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
@@ -178,6 +211,8 @@
#define APR_HAVE_SHMEM_SHMGET @haveshmget@
#define APR_HAVE_SHMEM_MMAP_ANON @havemmapanon@
#define APR_HAVE_SHMEM_BEOS @havebeosarea@
+#define APR_HAVE_SHMEM_OS2 @haveos2shm@
+#define APR_HAVE_SHMEM_WIN32 @havewin32shm@
#define APR_USE_SHMEM_MMAP_TMP @usemmaptmp@
#define APR_USE_SHMEM_MMAP_SHM @usemmapshm@
@@ -186,6 +221,8 @@
#define APR_USE_SHMEM_SHMGET @useshmget@
#define APR_USE_SHMEM_MMAP_ANON @usemmapanon@
#define APR_USE_SHMEM_BEOS @usebeosarea@
+#define APR_USE_SHMEM_OS2 @useos2shm@
+#define APR_USE_SHMEM_WIN32 @usewin32shm@
#define APR_USE_FLOCK_SERIALIZE @flockser@
#define APR_USE_SYSVSEM_SERIALIZE @sysvser@
@@ -202,7 +239,7 @@
#define APR_PROCESS_LOCK_IS_GLOBAL @proclockglobal@
-#define APR_HAVE_CORKABLE_TCP @have_corkable_tcp@
+#define APR_HAVE_CORKABLE_TCP @have_corkable_tcp@
#define APR_HAVE_GETRLIMIT @have_getrlimit@
#define APR_HAVE_IN_ADDR @have_in_addr@
#define APR_HAVE_INET_ADDR @have_inet_addr@
@@ -238,13 +275,20 @@
#define APR_HAS_SO_ACCEPTFILTER @acceptfilter@
#define APR_HAS_UNICODE_FS @have_unicode_fs@
#define APR_HAS_PROC_INVOKED @have_proc_invoked@
-#define APR_HAS_USER 1
+#define APR_HAS_USER @apr_has_user@
#define APR_HAS_LARGE_FILES @aprlfs@
-#define APR_HAS_XTHREAD_FILES 0
+#define APR_HAS_XTHREAD_FILES @xthread_files@
#define APR_HAS_OS_UUID @osuuid@
-#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD 0
+#if APR_HAS_MMAP == 0
+# if APR_USE_SHMEM_WIN32 == 1
+# undef APR_HAS_MMAP
+# define APR_HAS_MMAP 1
+# endif
+#endif
+#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD
@procattr_user_set_requires_pwd@
+
/* APR sets APR_FILES_AS_SOCKETS to 1 on systems where it is possible
* to poll on files/pipes.
*/
@@ -260,12 +304,12 @@
#define APR_TCP_NOPUSH_FLAG @apr_tcp_nopush_flag@
/* Is the TCP_NODELAY socket option inherited from listening sockets?
-*/
+ */
#define APR_TCP_NODELAY_INHERITED @tcp_nodelay_inherited@
/* Is the O_NONBLOCK flag inherited from listening sockets?
-*/
-#define APR_O_NONBLOCK_INHERITED @o_nonblock_inherited@
+ */
+#define APR_O_NONBLOCK_INHERITED @o_nonblock_inherited@
/* Typedefs that APR needs. */
@@ -298,8 +342,13 @@
#define APR_IS_BIGENDIAN @bigendian@
/* Mechanisms to properly type numeric literals */
+#ifdef _MSC_VER
+#define APR_INT64_C(val) (val##i64)
+#define APR_UINT64_C(val) (val##Ui64)
+#else
@int64_literal@
@uint64_literal@
+#endif
#ifdef INT16_MIN
#define APR_INT16_MIN INT16_MIN
@@ -380,7 +429,7 @@
*
* </PRE>
*/
-#define APR_THREAD_FUNC
+#define APR_THREAD_FUNC @apr_thread_func@
/**
* The public APR functions are declared with APR_DECLARE(), so they may
Index: include/apr.hw
===================================================================
--- include/apr.hw (revisione 710059)
+++ include/apr.hw (copia locale)
@@ -214,22 +214,28 @@
#if APR_HAVE_STDLIB_H
#include <stdlib.h>
#endif
+
#if APR_HAVE_STDIO_H
#include <stdio.h>
#endif
+
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
+
#if APR_HAVE_STDDEF_H
#include <stddef.h>
#endif
+
#if APR_HAVE_TIME_H
#include <time.h>
#endif
+
#if APR_HAVE_PROCESS_H
#include <process.h>
#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -247,6 +253,8 @@
#define APR_HAVE_SHMEM_SHMGET 0
#define APR_HAVE_SHMEM_MMAP_ANON 0
#define APR_HAVE_SHMEM_BEOS 0
+#define APR_HAVE_SHMEM_OS2 0
+#define APR_HAVE_SHMEM_WIN32 1
#define APR_USE_SHMEM_MMAP_TMP 0
#define APR_USE_SHMEM_MMAP_SHM 0
@@ -255,10 +263,12 @@
#define APR_USE_SHMEM_SHMGET 0
#define APR_USE_SHMEM_MMAP_ANON 0
#define APR_USE_SHMEM_BEOS 0
+#define APR_USE_SHMEM_OS2 0
+#define APR_USE_SHMEM_WIN32 1
#define APR_USE_FLOCK_SERIALIZE 0
+#define APR_USE_SYSVSEM_SERIALIZE 0
#define APR_USE_POSIXSEM_SERIALIZE 0
-#define APR_USE_SYSVSEM_SERIALIZE 0
#define APR_USE_FCNTL_SERIALIZE 0
#define APR_USE_PROC_PTHREAD_SERIALIZE 0
#define APR_USE_PTHREAD_SERIALIZE 0
@@ -276,13 +286,14 @@
#define APR_HAVE_ICONV 0
#define APR_HAVE_IN_ADDR 1
#define APR_HAVE_INET_ADDR 1
-#define APR_HAVE_INET_NETWORK 0
+#define APR_HAVE_INET_NETWORK 1
#define APR_HAVE_IPV6 0
#define APR_HAVE_MEMMOVE 1
#define APR_HAVE_SETRLIMIT 0
#define APR_HAVE_SIGACTION 0
#define APR_HAVE_SIGSUSPEND 0
#define APR_HAVE_SIGWAIT 0
+#define APR_HAVE_SA_STORAGE 0
#define APR_HAVE_STRCASECMP 0
#define APR_HAVE_STRDUP 1
#define APR_HAVE_STRNCASECMP 0
@@ -304,7 +315,7 @@
/* APR Feature Macros */
#define APR_HAS_SHARED_MEMORY 1
#define APR_HAS_THREADS 1
-#define APR_HAS_MMAP 1
+#define APR_HAS_MMAP 0
#define APR_HAS_FORK 0
#define APR_HAS_RANDOM 1
#define APR_HAS_OTHER_CHILD 1
@@ -328,6 +339,13 @@
#define APR_PROCATTR_USER_SET_REQUIRES_PASSWORD 0
#endif
+#if APR_HAS_MMAP == 0
+# if APR_USE_SHMEM_WIN32 == 1
+# undef APR_HAS_MMAP
+# define APR_HAS_MMAP 1
+# endif
+#endif
+
/* APR sets APR_FILES_AS_SOCKETS to 1 on systems where it is possible
* to poll on files/pipes.
*/
@@ -340,7 +358,7 @@
/* If we have a TCP implementation that can be "corked", what flag
* do we use?
*/
-#define APR_TCP_NOPUSH_FLAG @apr_tcp_nopush_flag@
+#define APR_TCP_NOPUSH_FLAG 0
/* Is the TCP_NODELAY socket option inherited from listening sockets?
*/
@@ -459,6 +477,7 @@
#define APR_SIZE_MAX (~((apr_size_t)0))
+
/* Definitions that APR programs need to work properly. */
/**
Index: configure.in
===================================================================
--- configure.in (revisione 710059)
+++ configure.in (copia locale)
@@ -183,6 +183,7 @@
fi
else
dnl libtoolize requires that the following not be indented
+AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
# get libtool's setting of shlibpath_var
eval `grep "^shlibpath_var=[[A-Z_]]*$" $apr_builddir/libtool`
@@ -219,6 +220,9 @@
*-solaris2*)
apr_platform_runtime_link_flag="-R"
;;
+ *mingw* | *cygwin*)
+ LT_VERSION="$LT_VERSION -no-undefined"
+ ;;
*)
;;
esac
@@ -467,6 +471,7 @@
eolstr="\\n"
proc_mutex_is_global=1
OBJECTS_PLATFORM='$(OBJECTS_win32)'
+ file_as_socket="0"
;;
*cygwin*)
OSDIR="unix"
@@ -487,6 +492,10 @@
AC_SUBST(OBJECTS_PLATFORM)
+# Check the presence of some basic types required by next tests
+AC_CHECK_HEADERS([sys/types.h sys/mman.h sys/ipc.h sys/mutex.h sys/shm.h
sys/file.h kernel/OS.h os2.h])
+AC_CHECK_HEADERS([time.h stddef.h process.h windows.h winsock2.h])
+
# Check whether LFS has explicitly been disabled
AC_ARG_ENABLE(lfs,[ --disable-lfs Disable large file support on
32-bit platforms],
[apr_lfs_choice=$enableval], [apr_lfs_choice=yes])
@@ -497,7 +506,9 @@
apr_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
AC_TRY_RUN([
+#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
+#endif
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
@@ -589,16 +600,44 @@
dnl end up LIBS="-lm -lcrypt -lnsl -ldl" which is an annoyance.
case $host in
*mingw*)
- dnl APR_ADDTO(LIBS,[-lmsvcrt --lshell32 -ladvapi32 -lws2_32])
-
+ AC_CHECK_HEADERS([tlhelp32.h], [], [], [
+ #ifdef HAVE_WINDOWS_H
+ #include <windows.h>
+ #endif
+ ])
AC_CHECK_LIB(msvcrt, getpid)
- APR_CHECK_DLL_FUNC(kernel32, [EMAIL PROTECTED])
- APR_CHECK_DLL_FUNC(advapi32, [EMAIL PROTECTED])
- APR_CHECK_DLL_FUNC(ws2_32, [EMAIL PROTECTED])
- APR_CHECK_DLL_FUNC(shell32, [EMAIL PROTECTED])
- APR_CHECK_DLL_FUNC(kernel32,[EMAIL PROTECTED],
- [ac_cv_func_CreateFileMapping=$ac_cv_lib_kernel32_CreateFileMappingA])
- APR_CHECK_DLL_FUNC(rpcrt4,[EMAIL PROTECTED])
+ APR_ADDTO(LIBS,[-lshell32 -ladvapi32 -lws2_32 -lrpcrt4 -lmswsock])
+ AC_TRY_COMPILE(
+ [
+ #ifdef HAVE_WINDOWS_H
+ #include <windows.h>
+ #endif
+ ],
+ [
+ DWORD dwMaxSizeHigh = 0, dwMaxSizeLow = 0;
+ HANDLE hMap =
+ CreateFileMapping(INVALID_HANDLE_VALUE,
+ NULL,
+ PAGE_READWRITE | SEC_RESERVE,
+ dwMaxSizeHigh,
+ dwMaxSizeLow,
+ NULL
+ );
+ if (hMap != NULL)
+ CloseHandle(hMap);
+ ],
+ [
+ AC_DEFINE(HAVE_CREATEFILEMAPPING, 1, [Define if CreateFileMapping is
available.])
+ ac_cv_func_CreateFileMapping=yes
+ ]
+ )
+# APR_CHECK_DLL_FUNC(kernel32, [EMAIL PROTECTED])
+# APR_CHECK_DLL_FUNC(advapi32, [EMAIL PROTECTED])
+# APR_CHECK_DLL_FUNC(ws2_32, [EMAIL PROTECTED])
+# APR_CHECK_DLL_FUNC(shell32, [EMAIL PROTECTED])
+# APR_CHECK_DLL_FUNC(kernel32,[EMAIL PROTECTED],
+#
[ac_cv_func_CreateFileMapping=$ac_cv_lib_kernel32_CreateFileMappingA])
+# APR_CHECK_DLL_FUNC(rpcrt4,[EMAIL PROTECTED])
;;
*)
AC_SEARCH_LIBS(gethostbyname, nsl)
@@ -789,7 +828,6 @@
#endif";;
esac
-AC_CHECK_HEADERS([sys/types.h sys/mman.h sys/ipc.h sys/mutex.h sys/shm.h
sys/file.h kernel/OS.h os2.h windows.h])
AC_CHECK_FUNCS([mmap munmap shm_open shm_unlink shmget shmat shmdt shmctl \
create_area])
@@ -832,6 +870,9 @@
haveshmgetanon="0"
havemmapzero="0"
havemmapanon="0"
+haveos2shmanom="0"
+havebeosshmanom="0"
+havewin32shmanom="0"
APR_BEGIN_DECISION([anonymous shared memory allocation method])
APR_IFALLYES(header:sys/ipc.h header:sys/shm.h header:sys/file.h dnl
func:shmget func:shmat func:shmdt func:shmctl,
@@ -846,14 +887,14 @@
APR_DECIDE(USE_SHMEM_MMAP_ANON,
[4.4BSD-style mmap() via MAP_ANON])])
APR_IFALLYES(header:os2.h,
- [haveos2shm="1"
+ [haveos2shmanom="1"
APR_DECIDE(USE_SHMEM_OS2_ANON, [OS/2 DosAllocSharedMem()])])
APR_IFALLYES(header:kernel/OS.h func:create_area,
- [havebeosshm="1"
+ [havebeosshmanom="1"
APR_DECIDE(USE_SHMEM_BEOS_ANON,
[BeOS areas])])
APR_IFALLYES(header:windows.h func:CreateFileMapping,
- [havewin32shm="1"
+ [havewin32shmanom="1"
APR_DECIDE(USE_SHMEM_WIN32_ANON,
[Windows CreateFileMapping()])])
case $host in
@@ -918,7 +959,7 @@
[haveshmget="1"
APR_DECIDE(USE_SHMEM_SHMGET, [SysV IPC shmget()])])
APR_IFALLYES(header:kernel/OS.h func:create_area,
- [havebeosshm="1"
+ [havebeosarea="1"
APR_DECIDE(USE_SHMEM_BEOS, [BeOS areas])])
APR_IFALLYES(header:os2.h,
[haveos2shm="1"
@@ -1004,6 +1045,18 @@
AC_CHECK_LIB(sendfile, sendfilev)
AC_CHECK_FUNCS(sendfile send_file sendfilev, [ sendfile="1" ])
+dnl If the above tests did not find sendfile(), let's check its support here.
+if test "$sendfile" = "0"; then
+ case $host in
+ *mingw32*)
+ sendfile="1"
+ ;;
+ *mingwce*)
+ sendfile="0"
+ ;;
+ esac
+fi
+
dnl THIS MUST COME AFTER THE THREAD TESTS - FreeBSD doesn't always have a
dnl threaded poll() and we don't want to use sendfile on early FreeBSD
dnl systems if we are also using threads.
@@ -1122,6 +1175,7 @@
unix.h \
windows.h \
winsock2.h \
+ tlhelp32.h \
arpa/inet.h \
kernel/OS.h \
net/errno.h \
@@ -1201,8 +1255,11 @@
AC_SUBST(sys_waith)
AC_SUBST(pthreadh)
AC_SUBST(semaphoreh)
+AC_SUBST(processh)
+AC_SUBST(stddefh)
AC_SUBST(windowsh)
AC_SUBST(winsock2h)
+AC_SUBST(tlhelp32h)
# Checking for h_errno in <netdb.h>
if test "$netdbh" = "1"; then
@@ -2332,12 +2389,22 @@
dnl Do we have a Win32-centric Unicode FS?
-if test -z "$have_unicode_fs"; then
- have_unicode_fs="0"
-fi
-
+APR_SETIFNULL(have_unicode_fs, [0])
AC_SUBST(have_unicode_fs)
+dnl ----------------------------- Other misc variable
+APR_SETIFNULL(xthread_files, [0])
+AC_SUBST(xthread_files)
+
+APR_SETIFNULL(procattr_user_set_requires_pwd, [0])
+AC_SUBST(procattr_user_set_requires_pwd)
+
+APR_SETIFNULL(apr_thread_func, [])
+AC_SUBST(apr_thread_func)
+
+APR_SETIFNULL(apr_has_user, [1])
+AC_SUBST(apr_has_user)
+
dnl ----------------------------- Finalize the variables
echo "${nl}Restore user-defined environment settings..."
Index: build/apr_hints.m4
===================================================================
--- build/apr_hints.m4 (revisione 710059)
+++ build/apr_hints.m4 (copia locale)
@@ -442,19 +442,35 @@
dnl Example error messages:
dnl undefined reference to 'libmsvcrt_a_iname'
dnl undefined reference to '_nm___pctype'
- if test "$ac_test_CFLAGS" != set; then
- APR_REMOVEFROM(CFLAGS,-O2)
- APR_ADDTO(CFLAGS,-O0)
- fi
+ dnl if test "$ac_test_CFLAGS" != set; then
+ dnl APR_REMOVEFROM(CFLAGS,-O2)
+ dnl APR_ADDTO(CFLAGS,-O0)
+ dnl fi
APR_ADDTO(LDFLAGS, [-Wl,--enable-auto-import,--subsystem,console])
APR_SETIFNULL(apr_lock_method, [win32])
APR_SETIFNULL(apr_process_lock_is_global, [yes])
APR_SETIFNULL(have_unicode_fs, [1])
APR_SETIFNULL(have_proc_invoked, [1])
APR_SETIFNULL(apr_cv_use_lfs64, [yes])
+ APR_SETIFNULL(apr_thread_func, [__stdcall])
+ case $host in
+ *mingw32*)
+ APR_SETIFNULL(xthread_files, [1])
+ APR_SETIFNULL(procattr_user_set_requires_pwd, [1])
+ APR_SETIFNULL(apr_has_user, [1])
+ # override the test for O_NONBLOCK inheritance.
+ APR_SETIFNULL(ac_cv_o_nonblock_inherited, [yes])
+ # override the test for TCP_NOPUSH inheritance.
+ APR_SETIFNULL(ac_cv_tcp_nodelay_inherited, [yes])
+ ;;
+ *mingwce)
+ APR_SETIFNULL(xthread_files, [0])
+ APR_SETIFNULL(procattr_user_set_requires_pwd, [0])
+ APR_SETIFNULL(apr_has_user, [0])
+ ;;
+ esac
;;
esac
-
fi
])
Index: build/apr_rules.mk.in
===================================================================
--- build/apr_rules.mk.in (revisione 710059)
+++ build/apr_rules.mk.in (copia locale)
@@ -24,6 +24,7 @@
#
# Configuration variables
#
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
Index: build/apr_network.m4
===================================================================
--- build/apr_network.m4 (revisione 710059)
+++ build/apr_network.m4 (copia locale)
@@ -744,6 +744,9 @@
AC_DEFUN([APR_CHECK_SOCKADDR_STORAGE], [
AC_CACHE_CHECK(for sockaddr_storage, apr_cv_define_sockaddr_storage,[
AC_TRY_COMPILE([
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
Index: file_io/win32/pipe.c
===================================================================
--- file_io/win32/pipe.c (revisione 710059)
+++ file_io/win32/pipe.c (copia locale)
@@ -238,7 +238,7 @@
apr_status_t rv = APR_SUCCESS;
int ll = sizeof(la);
int lc = sizeof(ca);
- int bm = 1;
+ u_long bm = 1;
int uid[2];
int iid[2];