Added check whether unaligned memory access is allowed.
Added macros to access unaligned WORDs / DWORDs.
diff --git a/configure b/configure
index ecfda11..711c27c 100755
--- a/configure
+++ b/configure
@@ -5343,24 +5343,67 @@
fi
+echo $ac_n "checking "whether unaligned memory access is allowed"""... $ac_c" 1>&6
+echo "configure:5348: checking "whether unaligned memory access is allowed"" >&5
+if eval "test \"`echo '$''{'wine_cv_allow_unaligned_access'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ wine_cv_allow_unaligned_access=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 5356 "configure"
+#include "confdefs.h"
+
+long volatile test[2];
+main()
+{
+ long volatile *ua = (long volatile *)((char *)test + 1);
+ *ua = 0;
+ exit(0);
+}
+EOF
+if { (eval echo configure:5367: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ wine_cv_allow_unaligned_access=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ wine_cv_allow_unaligned_access=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$wine_cv_allow_unaligned_access" 1>&6
+if test "$wine_allow_unaligned_access" = "yes"
+then
+ cat >> confdefs.h <<\EOF
+#define ALLOW_UNALIGNED_ACCESS 1
+EOF
+
+fi
+
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:5352: checking for working alloca.h" >&5
+echo "configure:5395: checking for working alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5357 "configure"
+#line 5400 "configure"
#include "confdefs.h"
#include <alloca.h>
int main() {
void *p = alloca(2 * sizeof(int));
; return 0; }
EOF
-if { (eval echo configure:5364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_header_alloca_h=yes
else
@@ -5381,12 +5424,12 @@
fi
echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:5385: checking for alloca" >&5
+echo "configure:5428: checking for alloca" >&5
if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5390 "configure"
+#line 5433 "configure"
#include "confdefs.h"
#ifdef __GNUC__
@@ -5414,7 +5457,7 @@
char *p = (char *) alloca(1);
; return 0; }
EOF
-if { (eval echo configure:5418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5461: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_func_alloca_works=yes
else
@@ -5446,12 +5489,12 @@
echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:5450: checking whether alloca needs Cray hooks" >&5
+echo "configure:5493: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5455 "configure"
+#line 5498 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -5476,12 +5519,12 @@
if test $ac_cv_os_cray = yes; then
for ac_func in _getb67 GETB67 getb67; do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5480: checking for $ac_func" >&5
+echo "configure:5523: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5485 "configure"
+#line 5528 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -5504,7 +5547,7 @@
; return 0; }
EOF
-if { (eval echo configure:5508: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5551: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -5531,7 +5574,7 @@
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:5535: checking stack direction for C alloca" >&5
+echo "configure:5578: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5539,7 +5582,7 @@
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 5543 "configure"
+#line 5586 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -5558,7 +5601,7 @@
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:5562: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:5605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@@ -5615,12 +5658,12 @@
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5619: checking for $ac_func" >&5
+echo "configure:5662: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5624 "configure"
+#line 5667 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -5643,7 +5686,7 @@
; return 0; }
EOF
-if { (eval echo configure:5647: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5690: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -5724,17 +5767,17 @@
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:5728: checking for $ac_hdr" >&5
+echo "configure:5771: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5733 "configure"
+#line 5776 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5738: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5781: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -5761,12 +5804,12 @@
done
echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
-echo "configure:5765: checking whether stat file-mode macros are broken" >&5
+echo "configure:5808: checking whether stat file-mode macros are broken" >&5
if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5770 "configure"
+#line 5813 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -5819,12 +5862,12 @@
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:5823: checking for working const" >&5
+echo "configure:5866: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5828 "configure"
+#line 5871 "configure"
#include "confdefs.h"
int main() {
@@ -5873,7 +5916,7 @@
; return 0; }
EOF
-if { (eval echo configure:5877: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5920: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@@ -5894,21 +5937,21 @@
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:5898: checking for inline" >&5
+echo "configure:5941: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
-#line 5905 "configure"
+#line 5948 "configure"
#include "confdefs.h"
int main() {
} int $ac_kw foo() {
; return 0; }
EOF
-if { (eval echo configure:5912: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5955: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
@@ -5934,12 +5977,12 @@
esac
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:5938: checking for ANSI C header files" >&5
+echo "configure:5981: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 5943 "configure"
+#line 5986 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -5947,7 +5990,7 @@
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5951: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5994: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -5964,7 +6007,7 @@
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 5968 "configure"
+#line 6011 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -5982,7 +6025,7 @@
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 5986 "configure"
+#line 6029 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -6003,7 +6046,7 @@
:
else
cat > conftest.$ac_ext <<EOF
-#line 6007 "configure"
+#line 6050 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -6014,7 +6057,7 @@
exit (0); }
EOF
-if { (eval echo configure:6018: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -6038,12 +6081,12 @@
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:6042: checking for size_t" >&5
+echo "configure:6085: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6047 "configure"
+#line 6090 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -6071,7 +6114,7 @@
fi
echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:6075: checking size of long long" >&5
+echo "configure:6118: checking size of long long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6079,7 +6122,7 @@
ac_cv_sizeof_long_long=0
else
cat > conftest.$ac_ext <<EOF
-#line 6083 "configure"
+#line 6126 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -6090,7 +6133,7 @@
exit(0);
}
EOF
-if { (eval echo configure:6094: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long_long=`cat conftestval`
else
@@ -6112,12 +6155,12 @@
echo $ac_n "checking "whether we can use re-entrant gethostbyname_r Linux style"""... $ac_c" 1>&6
-echo "configure:6116: checking "whether we can use re-entrant gethostbyname_r Linux style"" >&5
+echo "configure:6159: checking "whether we can use re-entrant gethostbyname_r Linux style"" >&5
if eval "test \"`echo '$''{'wine_cv_linux_gethostbyname_r_6'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6121 "configure"
+#line 6164 "configure"
#include "confdefs.h"
#include <netdb.h>
@@ -6138,7 +6181,7 @@
; return 0; }
EOF
-if { (eval echo configure:6142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6185: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_linux_gethostbyname_r_6=yes
else
@@ -6164,12 +6207,12 @@
if test "$ac_cv_header_linux_joystick_h" = "yes"
then
echo $ac_n "checking "whether linux/joystick.h uses the Linux 2.2+ API"""... $ac_c" 1>&6
-echo "configure:6168: checking "whether linux/joystick.h uses the Linux 2.2+ API"" >&5
+echo "configure:6211: checking "whether linux/joystick.h uses the Linux 2.2+ API"" >&5
if eval "test \"`echo '$''{'wine_cv_linux_joystick_22_api'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6173 "configure"
+#line 6216 "configure"
#include "confdefs.h"
#include <sys/ioctl.h>
@@ -6184,7 +6227,7 @@
/*empty*/
; return 0; }
EOF
-if { (eval echo configure:6188: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_linux_joystick_22_api=yes
else
@@ -6211,12 +6254,12 @@
if test "$ac_cv_header_sys_vfs_h" = "yes"
then
echo $ac_n "checking "whether sys/vfs.h defines statfs"""... $ac_c" 1>&6
-echo "configure:6215: checking "whether sys/vfs.h defines statfs"" >&5
+echo "configure:6258: checking "whether sys/vfs.h defines statfs"" >&5
if eval "test \"`echo '$''{'wine_cv_sys_vfs_has_statfs'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6220 "configure"
+#line 6263 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6233,7 +6276,7 @@
; return 0; }
EOF
-if { (eval echo configure:6237: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6280: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_sys_vfs_has_statfs=yes
else
@@ -6260,12 +6303,12 @@
if test "$ac_cv_header_sys_statfs_h" = "yes"
then
echo $ac_n "checking "whether sys/statfs.h defines statfs"""... $ac_c" 1>&6
-echo "configure:6264: checking "whether sys/statfs.h defines statfs"" >&5
+echo "configure:6307: checking "whether sys/statfs.h defines statfs"" >&5
if eval "test \"`echo '$''{'wine_cv_sys_statfs_has_statfs'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6269 "configure"
+#line 6312 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6280,7 +6323,7 @@
; return 0; }
EOF
-if { (eval echo configure:6284: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6327: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_sys_statfs_has_statfs=yes
else
@@ -6307,12 +6350,12 @@
if test "$ac_cv_header_sys_mount_h" = "yes"
then
echo $ac_n "checking "whether sys/mount.h defines statfs"""... $ac_c" 1>&6
-echo "configure:6311: checking "whether sys/mount.h defines statfs"" >&5
+echo "configure:6354: checking "whether sys/mount.h defines statfs"" >&5
if eval "test \"`echo '$''{'wine_cv_sys_mount_has_statfs'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6316 "configure"
+#line 6359 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6327,7 +6370,7 @@
; return 0; }
EOF
-if { (eval echo configure:6331: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6374: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_sys_mount_has_statfs=yes
else
@@ -6353,7 +6396,7 @@
echo $ac_n "checking "for statfs.f_bfree"""... $ac_c" 1>&6
-echo "configure:6357: checking "for statfs.f_bfree"" >&5
+echo "configure:6400: checking "for statfs.f_bfree"" >&5
if eval "test \"`echo '$''{'wine_cv_statfs_bfree'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6362,7 +6405,7 @@
wine_cv_statfs_bfree=no
else
cat > conftest.$ac_ext <<EOF
-#line 6366 "configure"
+#line 6409 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6389,7 +6432,7 @@
; return 0; }
EOF
-if { (eval echo configure:6393: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6436: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_statfs_bfree=yes
else
@@ -6413,7 +6456,7 @@
fi
echo $ac_n "checking "for statfs.f_bavail"""... $ac_c" 1>&6
-echo "configure:6417: checking "for statfs.f_bavail"" >&5
+echo "configure:6460: checking "for statfs.f_bavail"" >&5
if eval "test \"`echo '$''{'wine_cv_statfs_bavail'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6422,7 +6465,7 @@
wine_cv_statfs_bavail=no
else
cat > conftest.$ac_ext <<EOF
-#line 6426 "configure"
+#line 6469 "configure"
#include "confdefs.h"
#include <sys/types.h>
@@ -6449,7 +6492,7 @@
; return 0; }
EOF
-if { (eval echo configure:6453: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6496: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_statfs_bavail=yes
else
@@ -6474,12 +6517,12 @@
echo $ac_n "checking "for msg_accrights in struct msghdr"""... $ac_c" 1>&6
-echo "configure:6478: checking "for msg_accrights in struct msghdr"" >&5
+echo "configure:6521: checking "for msg_accrights in struct msghdr"" >&5
if eval "test \"`echo '$''{'ac_cv_c_msg_accrights'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6483 "configure"
+#line 6526 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@@ -6487,7 +6530,7 @@
struct msghdr hdr; hdr.msg_accrights=0
; return 0; }
EOF
-if { (eval echo configure:6491: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6534: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_msg_accrights="yes"
else
@@ -6510,12 +6553,12 @@
echo $ac_n "checking "for sun_len in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:6514: checking "for sun_len in struct sockaddr_un"" >&5
+echo "configure:6557: checking "for sun_len in struct sockaddr_un"" >&5
if eval "test \"`echo '$''{'ac_cv_c_sun_len'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6519 "configure"
+#line 6562 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@@ -6524,7 +6567,7 @@
static struct sockaddr_un addr; addr.sun_len = 1
; return 0; }
EOF
-if { (eval echo configure:6528: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6571: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_sun_len="yes"
else
@@ -6547,12 +6590,12 @@
echo $ac_n "checking "whether we need to define __i386__"""... $ac_c" 1>&6
-echo "configure:6551: checking "whether we need to define __i386__"" >&5
+echo "configure:6594: checking "whether we need to define __i386__"" >&5
if eval "test \"`echo '$''{'ac_cv_cpp_def_i386'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6556 "configure"
+#line 6599 "configure"
#include "confdefs.h"
#if (defined(i386) || defined(__i386)) && !defined(__i386__)
yes
diff --git a/configure.in b/configure.in
index 5a0fbe5..27438c9 100644
--- a/configure.in
+++ b/configure.in
@@ -782,6 +782,21 @@
AC_DEFINE(BITFIELDS_BIGENDIAN)
fi
+AC_CACHE_CHECK( "whether unaligned memory access is allowed", wine_cv_allow_unaligned_access,
+ [AC_TRY_RUN([
+long volatile test[2];
+main()
+{
+ long volatile *ua = (long volatile *)((char *)test + 1);
+ *ua = 0;
+ exit(0);
+} ], wine_cv_allow_unaligned_access=yes, wine_cv_allow_unaligned_access=no,
+ wine_cv_allow_unaligned_access=no ) ])
+if test "$wine_allow_unaligned_access" = "yes"
+then
+ AC_DEFINE(ALLOW_UNALIGNED_ACCESS)
+fi
+
dnl **** Check for functions ****
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c
index df443c5..28a62ec 100644
--- a/dlls/dplayx/dplay.c
+++ b/dlls/dplayx/dplay.c
@@ -5,6 +5,7 @@
* <presently under construction - contact hunnise@nortelnetworks.com>
*
*/
+#include "wine/port.h"
#include "windef.h"
#include "winerror.h"
#include "winbase.h"
diff --git a/dlls/user/exticon.c b/dlls/user/exticon.c
index 4089c2a..c0a419f 100644
--- a/dlls/user/exticon.c
+++ b/dlls/user/exticon.c
@@ -9,6 +9,7 @@
#include <stdlib.h> /* abs() */
#include <sys/types.h>
#include <unistd.h>
+#include "config.h"
#include "winbase.h"
#include "windef.h"
#include "winerror.h"
diff --git a/dlls/version/resource.c b/dlls/version/resource.c
index cdd9a1e..d8a25b4 100644
--- a/dlls/version/resource.c
+++ b/dlls/version/resource.c
@@ -11,6 +11,8 @@
#include <sys/types.h>
#include <unistd.h>
+#include "config.h"
+
#include "winbase.h"
#include "wine/winbase16.h"
#include "winnls.h"
diff --git a/include/acconfig.h b/include/acconfig.h
index d1c7581..b150a19 100644
--- a/include/acconfig.h
+++ b/include/acconfig.h
@@ -6,6 +6,9 @@
/* Define if bitfields are bigendian */
#undef BITFIELDS_BIGENDIAN
+/* Define if unaligned memory access is allowed */
+#undef ALLOW_UNALIGNED_ACCESS
+
/* Define if .type asm directive must be inside a .def directive */
#undef NEED_TYPE_IN_DEF
diff --git a/include/config.h.in b/include/config.h.in
index 4226b9c..4a37aeb 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -50,6 +50,9 @@
/* Define if bitfields are bigendian */
#undef BITFIELDS_BIGENDIAN
+/* Define if unaligned memory access is allowed */
+#undef ALLOW_UNALIGNED_ACCESS
+
/* Define if .type asm directive must be inside a .def directive */
#undef NEED_TYPE_IN_DEF
diff --git a/include/windef.h b/include/windef.h
index ab98867..1ef09b2 100644
--- a/include/windef.h
+++ b/include/windef.h
@@ -166,33 +166,6 @@
#define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
#endif
-/* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
-/* Note: These macros are semantically broken, at least for wrc. wrc
- spits out data in the platform's current binary format, *not* in
- little-endian format. These macros are used throughout the resource
- code to load and store data to the resources. Since it is unlikely
- that we'll ever be dealing with little-endian resource data, the
- byte-swapping nature of these macros has been disabled. Rather than
- remove the use of these macros from the resource loading code, the
- macros have simply been disabled. In the future, someone may want
- to reactivate these macros for other purposes. In that case, the
- resource code will have to be modified to use different macros. */
-
-#if 1
-#define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
-#define GET_WORD(ptr) (*(WORD *)(ptr))
-#define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
-#define GET_DWORD(ptr) (*(DWORD *)(ptr))
-#else
-#define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
- *((BYTE *)(ptr) + 1) = HIBYTE(w))
-#define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
- (WORD)(*((BYTE *)(ptr)+1) << 8)))
-#define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
- PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
-#define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
- ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
-#endif /* 1 */
/* min and max macros */
#define __max(a,b) (((a) > (b)) ? (a) : (b))
diff --git a/include/wine/port.h b/include/wine/port.h
index 4465e16..421a9d5 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -142,4 +142,55 @@
#define RTLD_GLOBAL 0x100
#endif
+
+/* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
+
+#define PUT_WORD(ptr, w) (*(WORD *)(ptr) = (w))
+#define GET_WORD(ptr) (*(WORD *)(ptr))
+#define PUT_DWORD(ptr, d) (*(DWORD *)(ptr) = (d))
+#define GET_DWORD(ptr) (*(DWORD *)(ptr))
+
+#define PUT_LE_WORD(ptr, w) \
+ do { ((BYTE *)(ptr))[0] = LOBYTE(w); \
+ ((BYTE *)(ptr))[1] = HIBYTE(w); } while (0)
+#define GET_LE_WORD(ptr) \
+ MAKEWORD( ((BYTE *)(ptr))[0], \
+ ((BYTE *)(ptr))[1] )
+#define PUT_LE_DWORD(ptr, d) \
+ do { PUT_LE_WORD(&((WORD *)(ptr))[0], LOWORD(d)); \
+ PUT_LE_WORD(&((WORD *)(ptr))[1], HIBYTE(d)); } while (0)
+#define GET_LE_DWORD(ptr) \
+ ((DWORD)MAKELONG( GET_LE_WORD(&((WORD *)(ptr))[0]), \
+ GET_LE_WORD(&((WORD *)(ptr))[1]) ))
+
+#define PUT_BE_WORD(ptr, w) \
+ do { ((BYTE *)(ptr))[1] = LOBYTE(w); \
+ ((BYTE *)(ptr))[0] = HIBYTE(w); } while (0)
+#define GET_BE_WORD(ptr) \
+ MAKEWORD( ((BYTE *)(ptr))[1], \
+ ((BYTE *)(ptr))[0] )
+#define PUT_BE_DWORD(ptr, d) \
+ do { PUT_BE_WORD(&((WORD *)(ptr))[1], LOWORD(d)); \
+ PUT_BE_WORD(&((WORD *)(ptr))[0], HIBYTE(d)); } while (0)
+#define GET_BE_DWORD(ptr) \
+ ((DWORD)MAKELONG( GET_BE_WORD(&((WORD *)(ptr))[1]), \
+ GET_BE_WORD(&((WORD *)(ptr))[0]) ))
+
+#if defined(ALLOW_UNALIGNED_ACCESS)
+#define PUT_UA_WORD(ptr, w) PUT_WORD(ptr, w)
+#define GET_UA_WORD(ptr) GET_WORD(ptr)
+#define PUT_UA_DWORD(ptr, d) PUT_DWORD(ptr, d)
+#define GET_UA_DWORD(ptr) GET_DWORD(ptr)
+#elif defined(WORDS_BIGENDIAN)
+#define PUT_UA_WORD(ptr, w) PUT_BE_WORD(ptr, w)
+#define GET_UA_WORD(ptr) GET_BE_WORD(ptr)
+#define PUT_UA_DWORD(ptr, d) PUT_BE_DWORD(ptr, d)
+#define GET_UA_DWORD(ptr) GET_BE_DWORD(ptr)
+#else
+#define PUT_UA_WORD(ptr, w) PUT_LE_WORD(ptr, w)
+#define GET_UA_WORD(ptr) GET_LE_WORD(ptr)
+#define PUT_UA_DWORD(ptr, d) PUT_LE_DWORD(ptr, d)
+#define GET_UA_DWORD(ptr) GET_LE_DWORD(ptr)
+#endif
+
#endif /* !defined(__WINE_WINE_PORT_H) */
diff --git a/loader/pe_resource.c b/loader/pe_resource.c
index 6549381..41aefdd 100644
--- a/loader/pe_resource.c
+++ b/loader/pe_resource.c
@@ -13,6 +13,8 @@
#include <stdlib.h>
#include <sys/types.h>
+#include "config.h"
+
#include "wine/unicode.h"
#include "windef.h"
#include "winnls.h"
diff --git a/loader/task.c b/loader/task.c
index f38f2b2..14e1407 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -9,6 +9,7 @@
#include <assert.h>
#include <unistd.h>
+#include "wine/port.h"
#include "wine/winbase16.h"
#include "ntddk.h"
#include "callback.h"
@@ -272,8 +273,8 @@
pTask->pdb.int20 = 0x20cd;
pTask->pdb.dispatcher[0] = 0x9a; /* ljmp */
- PUT_DWORD(&pTask->pdb.dispatcher[1], (DWORD)GetProcAddress16( GetModuleHandle16("KERNEL"),
- "DOS3Call" ));
+ PUT_UA_DWORD(&pTask->pdb.dispatcher[1],
+ (DWORD)GetProcAddress16( GetModuleHandle16("KERNEL"), "DOS3Call" ));
pTask->pdb.savedint22 = INT_GetPMHandler( 0x22 );
pTask->pdb.savedint23 = INT_GetPMHandler( 0x23 );
pTask->pdb.savedint24 = INT_GetPMHandler( 0x24 );
diff --git a/memory/environ.c b/memory/environ.c
index 6630137..e7bf71c 100644
--- a/memory/environ.c
+++ b/memory/environ.c
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include <string.h>
+#include "wine/port.h"
#include "windef.h"
#include "winnls.h"
#include "winerror.h"
@@ -59,7 +60,7 @@
/* Fill the extra bytes with the program name and stuff */
#define FILL_EXTRA_ENV(p) \
*(p) = '\0'; \
- PUT_WORD( (p) + 1, 1 ); \
+ PUT_UA_WORD( (p) + 1, 1 ); \
strcpy( (p) + 3, ENV_program_name );
STARTUPINFOA current_startupinfo =
diff --git a/memory/heap.c b/memory/heap.c
index 0437a0c..c73d52a 100644
--- a/memory/heap.c
+++ b/memory/heap.c
@@ -9,6 +9,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include "config.h"
#include "wine/winbase16.h"
#include "wine/unicode.h"
#include "selectors.h"
@@ -682,6 +683,16 @@
{
char *heapEnd = (char *)subheap + subheap->size;
+#if !defined(ALLOW_UNALIGNED_ACCESS)
+ /* Check for unaligned pointers */
+ if ( (long)pArena % sizeof(void *) != 0 )
+ {
+ ERR( "Heap %08lx: unaligned arena pointer %08lx\n",
+ (DWORD)subheap->heap, (DWORD)pArena );
+ return FALSE;
+ }
+#endif
+
/* Check magic number */
if (pArena->magic != ARENA_FREE_MAGIC)
{
@@ -766,6 +777,28 @@
{
char *heapEnd = (char *)subheap + subheap->size;
+#if !defined(ALLOW_UNALIGNED_ACCESS)
+ /* Check for unaligned pointers */
+ if ( (long)pArena % sizeof(void *) != 0 )
+ {
+ if ( quiet == NOISY )
+ {
+ ERR( "Heap %08lx: unaligned arena pointer %08lx\n",
+ (DWORD)subheap->heap, (DWORD)pArena );
+ if ( TRACE_ON(heap) )
+ HEAP_Dump( subheap->heap );
+ }
+ else if ( WARN_ON(heap) )
+ {
+ WARN( "Heap %08lx: unaligned arena pointer %08lx\n",
+ (DWORD)subheap->heap, (DWORD)pArena );
+ if ( TRACE_ON(heap) )
+ HEAP_Dump( subheap->heap );
+ }
+ return FALSE;
+ }
+#endif
+
/* Check magic number */
if (pArena->magic != ARENA_INUSE_MAGIC)
{
diff --git a/windows/class.c b/windows/class.c
index e5caf8e..cf335a2 100644
--- a/windows/class.c
+++ b/windows/class.c
@@ -20,6 +20,7 @@
#include "wingdi.h"
#include "wine/winuser16.h"
#include "wine/unicode.h"
+#include "wine/port.h"
#include "heap.h"
#include "win.h"
#include "controls.h"
diff --git a/windows/dialog.c b/windows/dialog.c
index 3fb66e2..3dafcf1 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -20,6 +20,7 @@
#include "wine/winuser16.h"
#include "wine/winbase16.h"
#include "wine/unicode.h"
+#include "wine/port.h"
#include "controls.h"
#include "heap.h"
#include "win.h"