Bugzilla Bug 322287: Implemented NSPR atomic routines in x86 assembly code
for Intel Macs. The patch is contributed by Josh Aas <joshmoz@gmail.com>. r=mark.mentovai,wtc. Modified files: configure configure.in _darwin.h Added file: os_Darwin_x86.s git-svn-id: svn://10.0.0.236/trunk@187174 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
49
mozilla/nsprpub/configure
vendored
49
mozilla/nsprpub/configure
vendored
@@ -3290,6 +3290,7 @@ EOF
|
||||
EOF
|
||||
|
||||
CPU_ARCH=i386
|
||||
PR_MD_ASFILES=os_Darwin_x86.s
|
||||
;;
|
||||
*)
|
||||
cat >> confdefs.h <<\EOF
|
||||
@@ -3297,6 +3298,7 @@ EOF
|
||||
EOF
|
||||
|
||||
CPU_ARCH=ppc
|
||||
PR_MD_ASFILES=os_Darwin_ppc.s
|
||||
;;
|
||||
esac
|
||||
DSO_CFLAGS=-fPIC
|
||||
@@ -3309,9 +3311,6 @@ EOF
|
||||
USE_PTHREADS=1
|
||||
MDCPUCFG_H=_darwin.cfg
|
||||
PR_MD_CSRCS=darwin.c
|
||||
if test "$CPU_ARCH" = "ppc"; then
|
||||
PR_MD_ASFILES=os_Darwin_ppc.s
|
||||
fi
|
||||
|
||||
# Add Mac OS X support for loading CFM & CFBundle plugins
|
||||
if test -f /System/Library/Frameworks/Carbon.framework/Carbon; then
|
||||
@@ -4404,17 +4403,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:4408: checking for machine/builtins.h" >&5
|
||||
echo "configure:4407: 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 4413 "configure"
|
||||
#line 4412 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <machine/builtins.h>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:4418: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:4417: \"$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*
|
||||
@@ -4976,7 +4975,7 @@ case $target in
|
||||
;;
|
||||
*)
|
||||
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
|
||||
echo "configure:4980: checking for dlopen in -ldl" >&5
|
||||
echo "configure:4979: 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
|
||||
@@ -4984,7 +4983,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-ldl $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 4988 "configure"
|
||||
#line 4987 "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
|
||||
@@ -4995,7 +4994,7 @@ int main() {
|
||||
dlopen()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:4999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:4998: \"$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
|
||||
@@ -5012,17 +5011,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:5016: checking for dlfcn.h" >&5
|
||||
echo "configure:5015: 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 5021 "configure"
|
||||
#line 5020 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <dlfcn.h>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:5026: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:5025: \"$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*
|
||||
@@ -5055,13 +5054,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:5059: checking whether ${CC-cc} needs -traditional" >&5
|
||||
echo "configure:5058: 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 5065 "configure"
|
||||
#line 5064 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sgtty.h>
|
||||
Autoconf TIOCGETP
|
||||
@@ -5079,7 +5078,7 @@ rm -f conftest*
|
||||
|
||||
if test $ac_cv_prog_gcc_traditional = no; then
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 5083 "configure"
|
||||
#line 5082 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <termio.h>
|
||||
Autoconf TCGETA
|
||||
@@ -5103,12 +5102,12 @@ fi
|
||||
for ac_func in lchown strerror
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:5107: checking for $ac_func" >&5
|
||||
echo "configure:5106: 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 5112 "configure"
|
||||
#line 5111 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@@ -5131,7 +5130,7 @@ $ac_func();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:5135: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:5134: \"$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
|
||||
@@ -5172,7 +5171,7 @@ hpux*)
|
||||
if test -z "$GNU_CC"; then
|
||||
|
||||
echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
|
||||
echo "configure:5176: checking for +Olit support" >&5
|
||||
echo "configure:5175: 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
|
||||
@@ -5211,7 +5210,7 @@ darwin*)
|
||||
*)
|
||||
|
||||
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
|
||||
echo "configure:5215: checking for pthread_create in -lpthreads" >&5
|
||||
echo "configure:5214: checking for pthread_create in -lpthreads" >&5
|
||||
echo "
|
||||
#include <pthread.h>
|
||||
void *foo(void *v) { return v; }
|
||||
@@ -5233,7 +5232,7 @@ echo "
|
||||
echo "$ac_t""no" 1>&6
|
||||
|
||||
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
|
||||
echo "configure:5237: checking for pthread_create in -lpthread" >&5
|
||||
echo "configure:5236: checking for pthread_create in -lpthread" >&5
|
||||
echo "
|
||||
#include <pthread.h>
|
||||
void *foo(void *v) { return v; }
|
||||
@@ -5255,7 +5254,7 @@ echo "
|
||||
echo "$ac_t""no" 1>&6
|
||||
|
||||
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
|
||||
echo "configure:5259: checking for pthread_create in -lc_r" >&5
|
||||
echo "configure:5258: checking for pthread_create in -lc_r" >&5
|
||||
echo "
|
||||
#include <pthread.h>
|
||||
void *foo(void *v) { return v; }
|
||||
@@ -5277,7 +5276,7 @@ echo "
|
||||
echo "$ac_t""no" 1>&6
|
||||
|
||||
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
|
||||
echo "configure:5281: checking for pthread_create in -lc" >&5
|
||||
echo "configure:5280: checking for pthread_create in -lc" >&5
|
||||
echo "
|
||||
#include <pthread.h>
|
||||
void *foo(void *v) { return v; }
|
||||
@@ -5431,7 +5430,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:5435: checking whether ${CC-cc} accepts -pthread" >&5
|
||||
echo "configure:5434: 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
|
||||
@@ -5454,7 +5453,7 @@ echo "configure:5435: 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:5458: checking whether ${CC-cc} accepts -pthreads" >&5
|
||||
echo "configure:5457: 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
|
||||
|
||||
@@ -931,10 +931,12 @@ case "$target" in
|
||||
i*86*)
|
||||
AC_DEFINE(i386)
|
||||
CPU_ARCH=i386
|
||||
PR_MD_ASFILES=os_Darwin_x86.s
|
||||
;;
|
||||
*)
|
||||
AC_DEFINE(ppc)
|
||||
CPU_ARCH=ppc
|
||||
PR_MD_ASFILES=os_Darwin_ppc.s
|
||||
;;
|
||||
esac
|
||||
DSO_CFLAGS=-fPIC
|
||||
@@ -947,9 +949,6 @@ case "$target" in
|
||||
USE_PTHREADS=1
|
||||
MDCPUCFG_H=_darwin.cfg
|
||||
PR_MD_CSRCS=darwin.c
|
||||
if test "$CPU_ARCH" = "ppc"; then
|
||||
PR_MD_ASFILES=os_Darwin_ppc.s
|
||||
fi
|
||||
|
||||
# Add Mac OS X support for loading CFM & CFBundle plugins
|
||||
if test -f /System/Library/Frameworks/Carbon.framework/Carbon; then
|
||||
|
||||
@@ -48,9 +48,9 @@
|
||||
|
||||
#define PR_LINKER_ARCH "darwin"
|
||||
#define _PR_SI_SYSNAME "DARWIN"
|
||||
#ifdef i386
|
||||
#ifdef __i386__
|
||||
#define _PR_SI_ARCHITECTURE "x86"
|
||||
#else
|
||||
#elif defined(__ppc__)
|
||||
#define _PR_SI_ARCHITECTURE "ppc"
|
||||
#endif
|
||||
#define PR_DLL_SUFFIX ".dylib"
|
||||
@@ -113,7 +113,18 @@ 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)
|
||||
#endif /* __ppc__ */
|
||||
#elif defined(__i386__)
|
||||
#define _PR_HAVE_ATOMIC_OPS
|
||||
#define _MD_INIT_ATOMIC()
|
||||
extern PRInt32 _PR_Darwin_x86_AtomicIncrement(PRInt32 *val);
|
||||
#define _MD_ATOMIC_INCREMENT(val) _PR_Darwin_x86_AtomicIncrement(val)
|
||||
extern PRInt32 _PR_Darwin_x86_AtomicDecrement(PRInt32 *val);
|
||||
#define _MD_ATOMIC_DECREMENT(val) _PR_Darwin_x86_AtomicDecrement(val)
|
||||
extern PRInt32 _PR_Darwin_x86_AtomicSet(PRInt32 *val, PRInt32 newval);
|
||||
#define _MD_ATOMIC_SET(val, newval) _PR_Darwin_x86_AtomicSet(val, newval)
|
||||
extern PRInt32 _PR_Darwin_x86_AtomicAdd(PRInt32 *ptr, PRInt32 val);
|
||||
#define _MD_ATOMIC_ADD(ptr, val) _PR_Darwin_x86_AtomicAdd(ptr, val)
|
||||
#endif /* __i386__ */
|
||||
|
||||
#define USE_SETJMP
|
||||
|
||||
|
||||
105
mozilla/nsprpub/pr/src/md/unix/os_Darwin_x86.s
Normal file
105
mozilla/nsprpub/pr/src/md/unix/os_Darwin_x86.s
Normal file
@@ -0,0 +1,105 @@
|
||||
# -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 2003 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Josh Aas <josh@mozilla.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the
|
||||
# terms of the GNU General Public License Version 2 or later (the
|
||||
# "GPL"), in which case the provisions of the GPL are applicable
|
||||
# instead of those above. If you wish to allow use of your
|
||||
# version of this file only under the terms of the GPL and not to
|
||||
# allow others to use your version of this file under the MPL,
|
||||
# indicate your decision by deleting the provisions above and
|
||||
# replace them with the notice and other provisions required by
|
||||
# the GPL. If you do not delete the provisions above, a recipient
|
||||
# may use your version of this file under either the MPL or the
|
||||
# GPL.
|
||||
#
|
||||
|
||||
#
|
||||
# Based on os_Linux_x86.s
|
||||
#
|
||||
|
||||
#
|
||||
# PRInt32 __PR_Darwin_x86_AtomicIncrement(PRInt32 *val);
|
||||
#
|
||||
# Atomically increment the integer pointed to by 'val' and return
|
||||
# the result of the increment.
|
||||
#
|
||||
.text
|
||||
.globl __PR_Darwin_x86_AtomicIncrement
|
||||
.align 4
|
||||
__PR_Darwin_x86_AtomicIncrement:
|
||||
movl 4(%esp), %ecx
|
||||
movl $1, %eax
|
||||
lock
|
||||
xaddl %eax, (%ecx)
|
||||
incl %eax
|
||||
ret
|
||||
|
||||
#
|
||||
# PRInt32 __PR_Darwin_x86_AtomicDecrement(PRInt32 *val);
|
||||
#
|
||||
# Atomically decrement the integer pointed to by 'val' and return
|
||||
# the result of the decrement.
|
||||
#
|
||||
.text
|
||||
.globl __PR_Darwin_x86_AtomicDecrement
|
||||
.align 4
|
||||
__PR_Darwin_x86_AtomicDecrement:
|
||||
movl 4(%esp), %ecx
|
||||
movl $-1, %eax
|
||||
lock
|
||||
xaddl %eax, (%ecx)
|
||||
decl %eax
|
||||
ret
|
||||
|
||||
#
|
||||
# PRInt32 __PR_Darwin_x86_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_AtomicSet
|
||||
.align 4
|
||||
__PR_Darwin_x86_AtomicSet:
|
||||
movl 4(%esp), %ecx
|
||||
movl 8(%esp), %eax
|
||||
xchgl %eax, (%ecx)
|
||||
ret
|
||||
|
||||
#
|
||||
# PRInt32 __PR_Darwin_x86_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_AtomicAdd
|
||||
.align 4
|
||||
__PR_Darwin_x86_AtomicAdd:
|
||||
movl 4(%esp), %ecx
|
||||
movl 8(%esp), %eax
|
||||
movl %eax, %edx
|
||||
lock
|
||||
xaddl %eax, (%ecx)
|
||||
addl %edx, %eax
|
||||
ret
|
||||
Reference in New Issue
Block a user