Bug 296878: use native PowerPC atomic instructions on Linux PowerPC. The

patch is contributed by kevdig@hypersurf.com.  r=mark.mentovai,wtc
Modified files: configure.in configure _linux.h
Added file: os_Linux_ppc.s
This commit is contained in:
wtc%google.com 2008-01-21 01:46:47 +00:00
Родитель 0036c1f572
Коммит 95c91e0da2
4 изменённых файлов: 147 добавлений и 22 удалений

48
nsprpub/configure поставляемый
Просмотреть файл

@ -3927,7 +3927,11 @@ EOF
CXX="$CXX -m32"
fi
;;
ppc|powerpc)
PR_MD_ASFILES=os_Linux_ppc.s
;;
powerpc64)
PR_MD_ASFILES=os_Linux_ppc.s
if test -n "$USE_64"; then
CC="$CC -m64"
CXX="$CXX -m64"
@ -4469,17 +4473,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:4473: checking for machine/builtins.h" >&5
echo "configure:4477: 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 4478 "configure"
#line 4482 "configure"
#include "confdefs.h"
#include <machine/builtins.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4483: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4487: \"$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*
@ -5049,7 +5053,7 @@ case $target in
;;
*)
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
echo "configure:5053: checking for dlopen in -ldl" >&5
echo "configure:5057: 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
@ -5057,7 +5061,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 5061 "configure"
#line 5065 "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
@ -5068,7 +5072,7 @@ int main() {
dlopen()
; return 0; }
EOF
if { (eval echo configure:5072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:5076: \"$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
@ -5085,17 +5089,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:5089: checking for dlfcn.h" >&5
echo "configure:5093: 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 5094 "configure"
#line 5098 "configure"
#include "confdefs.h"
#include <dlfcn.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:5099: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:5103: \"$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*
@ -5128,13 +5132,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:5132: checking whether ${CC-cc} needs -traditional" >&5
echo "configure:5136: 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 5138 "configure"
#line 5142 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@ -5152,7 +5156,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
#line 5156 "configure"
#line 5160 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@ -5176,12 +5180,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:5180: checking for $ac_func" >&5
echo "configure:5184: 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 5185 "configure"
#line 5189 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -5204,7 +5208,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:5208: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:5212: \"$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
@ -5245,7 +5249,7 @@ hpux*)
if test -z "$GNU_CC"; then
echo $ac_n "checking for +Olit support""... $ac_c" 1>&6
echo "configure:5249: checking for +Olit support" >&5
echo "configure:5253: 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
@ -5284,7 +5288,7 @@ darwin*)
*)
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
echo "configure:5288: checking for pthread_create in -lpthreads" >&5
echo "configure:5292: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@ -5306,7 +5310,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
echo "configure:5310: checking for pthread_create in -lpthread" >&5
echo "configure:5314: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@ -5328,7 +5332,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
echo "configure:5332: checking for pthread_create in -lc_r" >&5
echo "configure:5336: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@ -5350,7 +5354,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
echo "configure:5354: checking for pthread_create in -lc" >&5
echo "configure:5358: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { return v; }
@ -5504,7 +5508,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:5508: checking whether ${CC-cc} accepts -pthread" >&5
echo "configure:5512: 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
@ -5527,7 +5531,7 @@ echo "configure:5508: 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:5531: checking whether ${CC-cc} accepts -pthreads" >&5
echo "configure:5535: 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

Просмотреть файл

@ -1461,7 +1461,11 @@ tools are selected during the Xcode/Developer Tools installation.])
CXX="$CXX -m32"
fi
;;
ppc|powerpc)
PR_MD_ASFILES=os_Linux_ppc.s
;;
powerpc64)
PR_MD_ASFILES=os_Linux_ppc.s
if test -n "$USE_64"; then
CC="$CC -m64"
CXX="$CXX -m64"

Просмотреть файл

@ -138,6 +138,19 @@ extern PRInt32 _PR_x86_64_AtomicSet(PRInt32 *val, PRInt32 newval);
#define _MD_ATOMIC_SET _PR_x86_64_AtomicSet
#endif
#if defined(__powerpc__)
#define _PR_HAVE_ATOMIC_OPS
#define _MD_INIT_ATOMIC()
extern PRInt32 _PR_ppc_AtomicIncrement(PRInt32 *val);
#define _MD_ATOMIC_INCREMENT _PR_ppc_AtomicIncrement
extern PRInt32 _PR_ppc_AtomicDecrement(PRInt32 *val);
#define _MD_ATOMIC_DECREMENT _PR_ppc_AtomicDecrement
extern PRInt32 _PR_ppc_AtomicAdd(PRInt32 *ptr, PRInt32 val);
#define _MD_ATOMIC_ADD _PR_ppc_AtomicAdd
extern PRInt32 _PR_ppc_AtomicSet(PRInt32 *val, PRInt32 newval);
#define _MD_ATOMIC_SET _PR_ppc_AtomicSet
#endif
#if defined(__alpha)
#define _PR_HAVE_ATOMIC_OPS
#define _MD_INIT_ATOMIC()

Просмотреть файл

@ -0,0 +1,104 @@
# -*- 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) 2003
# 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 *****
#
# Based on the programming examples in The PowerPC Architecture:
# A Specification for A New Family of RISC Processors, 2nd Ed.,
# Book I, Section E.1, "Synchronization," pp. 249-256, May 1994.
#
.section ".text"
#
# PRInt32 _PR_ppc_AtomicIncrement(PRInt32 *val);
#
.align 2
.globl _PR_ppc_AtomicIncrement
.type _PR_ppc_AtomicIncrement,@function
_PR_ppc_AtomicIncrement:
.Lfd1: lwarx 4,0,3
addi 0,4,1
stwcx. 0,0,3
bne- .Lfd1
mr 3,0
blr
.Lfe1: .size _PR_ppc_AtomicIncrement,.Lfe1-_PR_ppc_AtomicIncrement
#
# PRInt32 _PR_ppc_AtomicDecrement(PRInt32 *val);
#
.align 2
.globl _PR_ppc_AtomicDecrement
.type _PR_ppc_AtomicDecrement,@function
_PR_ppc_AtomicDecrement:
.Lfd2: lwarx 4,0,3
addi 0,4,-1
stwcx. 0,0,3
bne- .Lfd2
mr 3,0
blr
.Lfe2: .size _PR_ppc_AtomicDecrement,.Lfe2-_PR_ppc_AtomicDecrement
#
# PRInt32 _PR_ppc_AtomicSet(PRInt32 *val, PRInt32 newval);
#
.align 2
.globl _PR_ppc_AtomicSet
.type _PR_ppc_AtomicSet,@function
_PR_ppc_AtomicSet:
.Lfd3: lwarx 5,0,3
stwcx. 4,0,3
bne- .Lfd3
mr 3,5
blr
.Lfe3: .size _PR_ppc_AtomicSet,.Lfe3-_PR_ppc_AtomicSet
#
# PRInt32 _PR_ppc_AtomicAdd(PRInt32 *ptr, PRInt32 val);
#
.align 2
.globl _PR_ppc_AtomicAdd
.type _PR_ppc_AtomicAdd,@function
_PR_ppc_AtomicAdd:
.Lfd4: lwarx 5,0,3
add 0,4,5
stwcx. 0,0,3
bne- .Lfd4
mr 3,0
blr
.Lfe4: .size _PR_ppc_AtomicAdd,.Lfe4-_PR_ppc_AtomicAdd