summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%google.com <devnull@localhost>2008-07-27 16:04:23 +0000
committerwtc%google.com <devnull@localhost>2008-07-27 16:04:23 +0000
commitcb445ab968cb3a261fc614ebc54611e9e1aece4f (patch)
tree86b881a853ed93c18717adcff869a52dc99de097
parentde7201513f7e04719584eef7136880bb1524e7ad (diff)
downloadnspr-hg-cb445ab968cb3a261fc614ebc54611e9e1aece4f.tar.gz
Bug 370766: Ported NSPR to 64-bit Mac OS X (x86-64), except prlink.c. The
patch is contributed by Glen Beasley <glen.beasley@sun.com>. r=wtc. Modified files: configure configure.in _darwin.cfg _darwin.h os_Darwin.s Added file: os_Darwin_x86_64.s
-rwxr-xr-xconfigure55
-rw-r--r--configure.in8
-rw-r--r--pr/include/md/_darwin.cfg52
-rw-r--r--pr/include/md/_darwin.h25
-rw-r--r--pr/src/md/unix/os_Darwin.s2
-rw-r--r--pr/src/md/unix/os_Darwin_x86_64.s95
6 files changed, 210 insertions, 27 deletions
diff --git a/configure b/configure
index 0d1ac864..00f0ab64 100755
--- a/configure
+++ b/configure
@@ -3346,10 +3346,19 @@ EOF
#define HAVE_BSD_FLOCK 1
EOF
+ cat >> confdefs.h <<\EOF
+#define HAVE_SOCKLEN_T 1
+EOF
+
CFLAGS="$CFLAGS -Wmost -fno-common"
case "${target_cpu}" in
i*86*)
- CPU_ARCH=i386
+ if test -n "$USE_64"; then
+ CPU_ARCH=x86_64
+ CC="$CC -arch x86_64"
+ else
+ CPU_ARCH=i386
+ fi
;;
*)
CPU_ARCH=ppc
@@ -4492,17 +4501,17 @@ EOF
_OPTIMIZE_FLAGS="$_OPTIMIZE_FLAGS -Olimit 4000"
ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
-echo "configure:4496: checking for machine/builtins.h" >&5
+echo "configure:4505: checking for machine/builtins.h" >&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 4501 "configure"
+#line 4510 "configure"
#include "confdefs.h"
#include <machine/builtins.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4506: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4515: \"$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*
@@ -5018,7 +5027,7 @@ case $target in
;;
*)
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:5022: checking for dlopen in -ldl" >&5
+echo "configure:5031: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -5026,7 +5035,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 5030 "configure"
+#line 5039 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -5037,7 +5046,7 @@ int main() {
dlopen()
; return 0; }
EOF
-if { (eval echo configure:5041: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5050: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -5054,17 +5063,17 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_safe=`echo "dlfcn.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for dlfcn.h""... $ac_c" 1>&6
-echo "configure:5058: checking for dlfcn.h" >&5
+echo "configure:5067: checking for dlfcn.h" >&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 5063 "configure"
+#line 5072 "configure"
#include "confdefs.h"
#include <dlfcn.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:5068: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:5077: \"$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*
@@ -5097,13 +5106,13 @@ esac
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:5101: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:5110: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
-#line 5107 "configure"
+#line 5116 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@@ -5121,7 +5130,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
-#line 5125 "configure"
+#line 5134 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@@ -5145,12 +5154,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5149: checking for $ac_func" >&5
+echo "configure:5158: 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 5154 "configure"
+#line 5163 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -5173,7 +5182,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:5177: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5186: \"$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
@@ -5214,7 +5223,7 @@ hpux*)
if test -z "$GNU_CC"; then
echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
-echo "configure:5218: checking for +Olit support" >&5
+echo "configure:5227: checking for +Olit support" >&5
if eval "test \"`echo '$''{'ac_cv_hpux_usable_olit_option'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -5253,7 +5262,7 @@ darwin*)
*)
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
-echo "configure:5257: checking for pthread_create in -lpthreads" >&5
+echo "configure:5266: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5275,7 +5284,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:5279: checking for pthread_create in -lpthread" >&5
+echo "configure:5288: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5297,7 +5306,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:5301: checking for pthread_create in -lc_r" >&5
+echo "configure:5310: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5319,7 +5328,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
-echo "configure:5323: checking for pthread_create in -lc" >&5
+echo "configure:5332: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@@ -5451,7 +5460,7 @@ if test -n "$USE_PTHREADS"; then
rm -f conftest*
ac_cv_have_dash_pthread=no
echo $ac_n "checking whether ${CC-cc} accepts -pthread""... $ac_c" 1>&6
-echo "configure:5455: checking whether ${CC-cc} accepts -pthread" >&5
+echo "configure:5464: checking whether ${CC-cc} accepts -pthread" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthread -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
@@ -5474,7 +5483,7 @@ echo "configure:5455: checking whether ${CC-cc} accepts -pthread" >&5
ac_cv_have_dash_pthreads=no
if test "$ac_cv_have_dash_pthread" = "no"; then
echo $ac_n "checking whether ${CC-cc} accepts -pthreads""... $ac_c" 1>&6
-echo "configure:5478: checking whether ${CC-cc} accepts -pthreads" >&5
+echo "configure:5487: checking whether ${CC-cc} accepts -pthreads" >&5
echo 'int main() { return 0; }' | cat > conftest.c
${CC-cc} -pthreads -o conftest conftest.c > conftest.out 2>&1
if test $? -eq 0; then
diff --git a/configure.in b/configure.in
index 01ea8f29..3dbbd274 100644
--- a/configure.in
+++ b/configure.in
@@ -996,10 +996,16 @@ case "$target" in
AC_DEFINE(XP_UNIX)
AC_DEFINE(DARWIN)
AC_DEFINE(HAVE_BSD_FLOCK)
+ AC_DEFINE(HAVE_SOCKLEN_T)
CFLAGS="$CFLAGS -Wmost -fno-common"
case "${target_cpu}" in
i*86*)
- CPU_ARCH=i386
+ if test -n "$USE_64"; then
+ CPU_ARCH=x86_64
+ CC="$CC -arch x86_64"
+ else
+ CPU_ARCH=i386
+ fi
;;
*)
CPU_ARCH=ppc
diff --git a/pr/include/md/_darwin.cfg b/pr/include/md/_darwin.cfg
index 1cc39aa5..3417c2dc 100644
--- a/pr/include/md/_darwin.cfg
+++ b/pr/include/md/_darwin.cfg
@@ -44,7 +44,7 @@
#define PR_AF_INET6 30 /* same as AF_INET6 */
-#if defined(__i386__)
+#if defined(__i386__) || defined(__x86_64__)
#undef IS_BIG_ENDIAN
#define IS_LITTLE_ENDIAN 1
#else
@@ -52,12 +52,60 @@
#define IS_BIG_ENDIAN 1
#endif
+#ifdef __x86_64__
+#define IS_64
+#endif
+
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#undef HAVE_ALIGNED_DOUBLES
#define HAVE_ALIGNED_LONGLONGS 1
+#ifdef IS_64
+
+#define PR_BYTES_PER_BYTE 1
+#define PR_BYTES_PER_SHORT 2
+#define PR_BYTES_PER_INT 4
+#define PR_BYTES_PER_INT64 8
+#define PR_BYTES_PER_LONG 8
+#define PR_BYTES_PER_FLOAT 4
+#define PR_BYTES_PER_DOUBLE 8
+#define PR_BYTES_PER_WORD 8
+#define PR_BYTES_PER_DWORD 8
+
+#define PR_BITS_PER_BYTE 8
+#define PR_BITS_PER_SHORT 16
+#define PR_BITS_PER_INT 32
+#define PR_BITS_PER_INT64 64
+#define PR_BITS_PER_LONG 64
+#define PR_BITS_PER_FLOAT 32
+#define PR_BITS_PER_DOUBLE 64
+#define PR_BITS_PER_WORD 64
+#define PR_BITS_PER_DWORD 64
+
+#define PR_BITS_PER_BYTE_LOG2 3
+#define PR_BITS_PER_SHORT_LOG2 4
+#define PR_BITS_PER_INT_LOG2 5
+#define PR_BITS_PER_INT64_LOG2 6
+#define PR_BITS_PER_LONG_LOG2 6
+#define PR_BITS_PER_FLOAT_LOG2 5
+#define PR_BITS_PER_DOUBLE_LOG2 6
+#define PR_BITS_PER_WORD_LOG2 6
+#define PR_BITS_PER_DWORD_LOG2 6
+
+#define PR_ALIGN_OF_SHORT 2
+#define PR_ALIGN_OF_INT 4
+#define PR_ALIGN_OF_LONG 8
+#define PR_ALIGN_OF_INT64 8
+#define PR_ALIGN_OF_FLOAT 4
+#define PR_ALIGN_OF_DOUBLE 8
+#define PR_ALIGN_OF_POINTER 8
+#define PR_ALIGN_OF_WORD 8
+#define PR_ALIGN_OF_DWORD 8
+
+#else /* IS_64 */
+
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
@@ -98,6 +146,8 @@
#define PR_ALIGN_OF_POINTER 4
#define PR_ALIGN_OF_WORD 4
+#endif /* IS_64 */
+
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
diff --git a/pr/include/md/_darwin.h b/pr/include/md/_darwin.h
index 3c599fa7..0d4e6ce3 100644
--- a/pr/include/md/_darwin.h
+++ b/pr/include/md/_darwin.h
@@ -50,6 +50,8 @@
#define _PR_SI_SYSNAME "DARWIN"
#ifdef __i386__
#define _PR_SI_ARCHITECTURE "x86"
+#elif defined(__x86_64__)
+#define _PR_SI_ARCHITECTURE "x86-64"
#elif defined(__ppc__)
#define _PR_SI_ARCHITECTURE "ppc"
#endif
@@ -62,7 +64,11 @@
#undef HAVE_STACK_GROWING_UP
#define HAVE_DLL
+#ifdef __x86_64__
+#define USE_DLFCN
+#else
#define USE_MACH_DYLD
+#endif
#define _PR_HAVE_SOCKADDR_LEN
#define _PR_STAT_HAS_ST_ATIMESPEC
#define _PR_HAVE_LARGE_OFF_T
@@ -102,7 +108,7 @@
#define IPV6_V6ONLY 27
#endif
-#if defined(__ppc__)
+#ifdef __ppc__
#define _PR_HAVE_ATOMIC_OPS
#define _MD_INIT_ATOMIC()
extern PRInt32 _PR_DarwinPPC_AtomicIncrement(PRInt32 *val);
@@ -113,7 +119,9 @@ extern PRInt32 _PR_DarwinPPC_AtomicSet(PRInt32 *val, PRInt32 newval);
#define _MD_ATOMIC_SET(val, newval) _PR_DarwinPPC_AtomicSet(val, newval)
extern PRInt32 _PR_DarwinPPC_AtomicAdd(PRInt32 *ptr, PRInt32 val);
#define _MD_ATOMIC_ADD(ptr, val) _PR_DarwinPPC_AtomicAdd(ptr, val)
-#elif defined(__i386__)
+#endif /* __ppc__ */
+
+#ifdef __i386__
#define _PR_HAVE_ATOMIC_OPS
#define _MD_INIT_ATOMIC()
extern PRInt32 _PR_Darwin_x86_AtomicIncrement(PRInt32 *val);
@@ -126,6 +134,19 @@ extern PRInt32 _PR_Darwin_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);
#define _MD_ATOMIC_ADD(ptr, val) _PR_Darwin_x86_AtomicAdd(ptr, val)
#endif /* __i386__ */
+#ifdef __x86_64__
+#define _PR_HAVE_ATOMIC_OPS
+#define _MD_INIT_ATOMIC()
+extern PRInt32 _PR_Darwin_x86_64_AtomicIncrement(PRInt32 *val);
+#define _MD_ATOMIC_INCREMENT(val) _PR_Darwin_x86_64_AtomicIncrement(val)
+extern PRInt32 _PR_Darwin_x86_64_AtomicDecrement(PRInt32 *val);
+#define _MD_ATOMIC_DECREMENT(val) _PR_Darwin_x86_64_AtomicDecrement(val)
+extern PRInt32 _PR_Darwin_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
+#define _MD_ATOMIC_SET(val, newval) _PR_Darwin_x86_64_AtomicSet(val, newval)
+extern PRInt32 _PR_Darwin_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val);
+#define _MD_ATOMIC_ADD(ptr, val) _PR_Darwin_x86_64_AtomicAdd(ptr, val)
+#endif /* __x86_64__ */
+
#define USE_SETJMP
#if !defined(_PR_PTHREADS)
diff --git a/pr/src/md/unix/os_Darwin.s b/pr/src/md/unix/os_Darwin.s
index 00daf1e3..ce2cc0ba 100644
--- a/pr/src/md/unix/os_Darwin.s
+++ b/pr/src/md/unix/os_Darwin.s
@@ -38,6 +38,8 @@
#ifdef __i386__
#include "os_Darwin_x86.s"
+#elif defined(__x86_64__)
+#include "os_Darwin_x86_64.s"
#elif defined(__ppc__)
#include "os_Darwin_ppc.s"
#endif
diff --git a/pr/src/md/unix/os_Darwin_x86_64.s b/pr/src/md/unix/os_Darwin_x86_64.s
new file mode 100644
index 00000000..031186f5
--- /dev/null
+++ b/pr/src/md/unix/os_Darwin_x86_64.s
@@ -0,0 +1,95 @@
+# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1#GPL 2.0#LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http:##www.mozilla.org#MPL#
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the Netscape Portable Runtime (NSPR).
+#
+# The Initial Developer of the Original Code is
+# Netscape Communications Corporation.
+# Portions created by the Initial Developer are Copyright (C) 2004
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+# PRInt32 __PR_Darwin_x86_64_AtomicIncrement(PRInt32 *val)
+#
+# Atomically increment the integer pointed to by 'val' and return
+# the result of the increment.
+#
+ .text
+ .globl __PR_Darwin_x86_64_AtomicIncrement
+ .align 4
+__PR_Darwin_x86_64_AtomicIncrement:
+ movl $1, %eax
+ lock
+ xaddl %eax, (%rdi)
+ incl %eax
+ ret
+
+# PRInt32 __PR_Darwin_x86_64_AtomicDecrement(PRInt32 *val)
+#
+# Atomically decrement the integer pointed to by 'val' and return
+# the result of the decrement.
+#
+ .text
+ .globl __PR_Darwin_x86_64_AtomicDecrement
+ .align 4
+__PR_Darwin_x86_64_AtomicDecrement:
+ movl $-1, %eax
+ lock
+ xaddl %eax, (%rdi)
+ decl %eax
+ ret
+
+# PRInt32 __PR_Darwin_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval)
+#
+# Atomically set the integer pointed to by 'val' to the new
+# value 'newval' and return the old value.
+#
+ .text
+ .globl __PR_Darwin_x86_64_AtomicSet
+ .align 4
+__PR_Darwin_x86_64_AtomicSet:
+ movl %esi, %eax
+ xchgl %eax, (%rdi)
+ ret
+
+# PRInt32 __PR_Darwin_x86_64_AtomicAdd(PRInt32 *ptr, PRInt32 val)
+#
+# Atomically add 'val' to the integer pointed to by 'ptr'
+# and return the result of the addition.
+#
+ .text
+ .globl __PR_Darwin_x86_64_AtomicAdd
+ .align 4
+__PR_Darwin_x86_64_AtomicAdd:
+ movl %esi, %eax
+ lock
+ xaddl %eax, (%rdi)
+ addl %esi, %eax
+ ret