Bugzilla bug #85673: added assembly implementation of the atomic routines

for OS/2 contributed by Michael Kaply of IBM.
Modified files: configure configure.in autoconf.mk.in rules.mk _os2.h
pr/src/md/os2/Makefile.in pr/src/md/os2/objs.mk os2misc.c
This commit is contained in:
wtc%netscape.com 2001-06-23 04:09:19 +00:00
parent 8c97591eed
commit 3aeb80d883
8 changed files with 111 additions and 44 deletions

View File

@ -25,6 +25,7 @@ OBJDIR = @OBJDIR@
OBJ_SUFFIX = @OBJ_SUFFIX@
LIB_SUFFIX = @LIB_SUFFIX@
DLL_SUFFIX = @DLL_SUFFIX@
ASM_SUFFIX = @ASM_SUFFIX@
MOD_NAME = @NSPR_MODNAME@
MOD_MAJOR_VERSION = @MOD_MAJOR_VERSION@

View File

@ -145,7 +145,7 @@ endif
ifndef OBJS
OBJS = $(addprefix $(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \
$(addprefix $(OBJDIR)/,$(ASFILES:.s=.$(OBJ_SUFFIX)))
$(addprefix $(OBJDIR)/,$(ASFILES:.$(ASM_SUFFIX)=.$(OBJ_SUFFIX)))
endif
ifeq ($(OS_ARCH), WINNT)
@ -388,6 +388,12 @@ $(OBJDIR)/%.$(OBJ_SUFFIX): %.s
@$(MAKE_OBJDIR)
$(AS) -o $@ $(ASFLAGS) -c $<
ifeq ($(MOZ_OS2_TOOLS),VACPP)
$(OBJDIR)/%.$(OBJ_SUFFIX): %.asm
@$(MAKE_OBJDIR)
$(AS) -Fdo:./$(OBJDIR) $(ASFLAGS) $<
endif
%.i: %.c
$(CC) -C -E $(CFLAGS) $< > $*.i

54
nsprpub/configure vendored
View File

@ -2595,6 +2595,7 @@ fi
OBJ_SUFFIX=o
LIB_SUFFIX=a
DLL_SUFFIX=so
ASM_SUFFIX=s
MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
PR_MD_ASFILES=
PR_MD_CSRCS=
@ -2775,17 +2776,17 @@ EOF
DSO_LDOPTS='-brtl -bM:SRE -bnoentry -bexpall'
ac_safe=`echo "sys/atomic_op.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for sys/atomic_op.h""... $ac_c" 1>&6
echo "configure:2779: checking for sys/atomic_op.h" >&5
echo "configure:2780: checking for sys/atomic_op.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 2784 "configure"
#line 2785 "configure"
#include "confdefs.h"
#include <sys/atomic_op.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2789: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2790: \"$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*
@ -4004,17 +4005,17 @@ EOF
ac_safe=`echo "machine/builtins.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for machine/builtins.h""... $ac_c" 1>&6
echo "configure:4008: checking for machine/builtins.h" >&5
echo "configure:4009: 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 4013 "configure"
#line 4014 "configure"
#include "confdefs.h"
#include <machine/builtins.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4018: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4019: \"$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*
@ -4451,6 +4452,7 @@ EOF
OBJ_SUFFIX=obj
LIB_SUFFIX=lib
DLL_SUFFIX=dll
ASM_SUFFIX=asm
DLLTOOL=''
RC=rc.exe
PR_MD_ARCH_DIR=os2
@ -4508,6 +4510,8 @@ EOF
#define _X86_ 1
EOF
AS=alp
ASFLAGS='-Mb'
AR=-ilib
AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)'
CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl-'
@ -4549,12 +4553,12 @@ esac
if test -z "$SKIP_LIBRARY_CHECKS"; then
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
echo "configure:4553: checking for dlopen" >&5
echo "configure:4557: checking for dlopen" >&5
if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4558 "configure"
#line 4562 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@ -4577,7 +4581,7 @@ dlopen();
; return 0; }
EOF
if { (eval echo configure:4581: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_dlopen=yes"
else
@ -4596,7 +4600,7 @@ else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
echo "configure:4600: checking for dlopen in -ldl" >&5
echo "configure:4604: 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
@ -4604,7 +4608,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 4608 "configure"
#line 4612 "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
@ -4615,7 +4619,7 @@ int main() {
dlopen()
; return 0; }
EOF
if { (eval echo configure:4619: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4623: \"$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
@ -4643,13 +4647,13 @@ fi
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
echo "configure:4647: checking whether ${CC-cc} needs -traditional" >&5
echo "configure:4651: 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 4653 "configure"
#line 4657 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@ -4667,7 +4671,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
#line 4671 "configure"
#line 4675 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@ -4691,12 +4695,12 @@ fi
for ac_func in lchown strerror
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:4695: checking for $ac_func" >&5
echo "configure:4699: 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 4700 "configure"
#line 4704 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -4719,7 +4723,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:4723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:4727: \"$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
@ -4750,7 +4754,7 @@ done
echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6
echo "configure:4754: checking for pthread_create in -lpthreads" >&5
echo "configure:4758: checking for pthread_create in -lpthreads" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4772,7 +4776,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
echo "configure:4776: checking for pthread_create in -lpthread" >&5
echo "configure:4780: checking for pthread_create in -lpthread" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4794,7 +4798,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
echo "configure:4798: checking for pthread_create in -lc_r" >&5
echo "configure:4802: checking for pthread_create in -lc_r" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4816,7 +4820,7 @@ echo "
echo "$ac_t""no" 1>&6
echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6
echo "configure:4820: checking for pthread_create in -lc" >&5
echo "configure:4824: checking for pthread_create in -lc" >&5
echo "
#include <pthread.h>
void *foo(void *v) { int a = 1; }
@ -4966,7 +4970,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:4970: checking whether ${CC-cc} accepts -pthread" >&5
echo "configure:4974: 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
@ -4982,7 +4986,7 @@ echo "configure:4970: 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:4986: checking whether ${CC-cc} accepts -pthreads" >&5
echo "configure:4990: 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
@ -5321,6 +5325,7 @@ RELEASE_OBJDIR_NAME="${OS_CONFIG}${CPU_ARCH_TAG}${COMPILER_TAG}${IMPL_STRATEGY}$
MAKEFILES="
@ -5573,6 +5578,7 @@ s%@CPU_ARCH@%$CPU_ARCH%g
s%@OBJ_SUFFIX@%$OBJ_SUFFIX%g
s%@LIB_SUFFIX@%$LIB_SUFFIX%g
s%@DLL_SUFFIX@%$DLL_SUFFIX%g
s%@ASM_SUFFIX@%$ASM_SUFFIX%g
s%@MKSHLIB@%$MKSHLIB%g
s%@DSO_CFLAGS@%$DSO_CFLAGS%g
s%@DSO_LDOPTS@%$DSO_LDOPTS%g

View File

@ -447,6 +447,7 @@ dnl ========================================================
OBJ_SUFFIX=o
LIB_SUFFIX=a
DLL_SUFFIX=so
ASM_SUFFIX=s
MKSHLIB='$(LD) $(DSO_LDOPTS) -o $@'
PR_MD_ASFILES=
PR_MD_CSRCS=
@ -1632,6 +1633,7 @@ mips-sony-newsos*)
OBJ_SUFFIX=obj
LIB_SUFFIX=lib
DLL_SUFFIX=dll
ASM_SUFFIX=asm
DLLTOOL=''
RC=rc.exe
PR_MD_ARCH_DIR=os2
@ -1671,6 +1673,8 @@ mips-sony-newsos*)
AC_DEFINE(OS2,4)
AC_DEFINE(TCPV40HDRS)
AC_DEFINE(_X86_)
AS=alp
ASFLAGS='-Mb'
AR=-ilib
AR_FLAGS='/NOL /NOI /O:$(subst /,\\,$@)'
CFLAGS='/Q /qlibansi /Gd+ /Gm+ /Su4 /Mp /Tl-'
@ -2163,6 +2167,7 @@ AC_SUBST(CPU_ARCH)
AC_SUBST(OBJ_SUFFIX)
AC_SUBST(LIB_SUFFIX)
AC_SUBST(DLL_SUFFIX)
AC_SUBST(ASM_SUFFIX)
AC_SUBST(MKSHLIB)
AC_SUBST(DSO_CFLAGS)
AC_SUBST(DSO_LDOPTS)

View File

@ -71,7 +71,7 @@
#define HAVE_DLL
#undef HAVE_THREAD_AFFINITY
#undef _PR_HAVE_ATOMIC_OPS
#define _PR_HAVE_ATOMIC_OPS
#define HANDLE unsigned long
#define HINSTANCE HMODULE
@ -280,11 +280,11 @@ extern PRInt32 _MD_SELECT(int nfds, fd_set *readfds, fd_set *writefds,
#define _MD_FSYNC _PR_MD_FSYNC
#define _MD_SET_FD_INHERITABLE (_PR_MD_SET_FD_INHERITABLE)
#define _MD_INIT_ATOMIC _PR_MD_INIT_ATOMIC
#define _MD_ATOMIC_INCREMENT(x) _PR_MD_ATOMIC_INCREMENT(x)
#define _MD_ATOMIC_ADD(x,y) _PR_MD_ATOMIC_ADD(x,y)
#define _MD_ATOMIC_DECREMENT(x) _PR_MD_ATOMIC_DECREMENT(x)
#define _MD_ATOMIC_SET(x,y) _PR_MD_ATOMIC_SET(x, y)
#define _MD_INIT_ATOMIC()
#define _MD_ATOMIC_INCREMENT _PR_MD_ATOMIC_INCREMENT
#define _MD_ATOMIC_ADD _PR_MD_ATOMIC_ADD
#define _MD_ATOMIC_DECREMENT _PR_MD_ATOMIC_DECREMENT
#define _MD_ATOMIC_SET _PR_MD_ATOMIC_SET
#define _MD_INIT_IO (_PR_MD_INIT_IO)
#define _MD_PR_POLL (_PR_MD_PR_POLL)

View File

@ -58,6 +58,10 @@ CSRCS = \
$(NULL)
endif
ifeq ($(MOZ_OS2_TOOLS),VACPP)
ASFILES = os2vacpp.asm
endif
TARGETS = $(OBJS)
INCLUDES = -I$(dist_includedir) -I$(topsrcdir)/pr/include -I$(topsrcdir)/pr/include/private

View File

@ -18,20 +18,24 @@
# This makefile appends to the variable OBJS the platform-dependent
# object modules that will be part of the nspr20 library.
CSRCS = \
os2io.c \
os2sock.c \
os2thred.c \
os2cv.c \
os2gc.c \
os2misc.c \
os2inrval.c \
os2sem.c \
CSRCS = \
os2io.c \
os2sock.c \
os2thred.c \
os2cv.c \
os2gc.c \
os2misc.c \
os2inrval.c \
os2sem.c \
os2_errors.c \
os2poll.c \
os2rng.c \
os2poll.c \
os2rng.c \
$(NULL)
OBJS += $(addprefix md/os2/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \
$(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.s=.$(OBJ_SUFFIX)))
ifeq ($(MOZ_OS2_TOOLS),VACPP)
ASFILES = os2vacpp.asm
endif
OBJS += $(addprefix md/os2/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \
$(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.asm=.$(OBJ_SUFFIX)))

View File

@ -576,3 +576,44 @@ unsigned long _System _DLL_InitTerm( unsigned long mod_handle, unsigned long fla
return rc;
}
#ifndef XP_OS2_VACPP
PRInt32 _PR_MD_ATOMIC_SET(PRInt32 *intp, PRInt32 val)
{
PRInt32 result;
asm volatile ("lock ; xchg %0, %1"
: "=r"(result), "=m"(intp)
: "0"(val), "m"(intp));
return result;
}
PRInt32 _PR_MD_ATOMIC_ADD(PRInt32 *intp, PRInt32 val)
{
PRInt32 result;
asm volatile ("lock ; xadd %0, %1"
: "=r"(result), "=m"(intp)
: "0"(val), "m"(intp));
return result + val;
}
PRInt32 _PR_MD_ATOMIC_INCREMENT(PRInt32 *val)
{
PRInt32 result;
asm volatile ("lock ; xadd %0, %1"
: "=r"(result), "=m"(*val)
: "0"(1), "m"(*val));
return result + 1;
}
PRInt32 _PR_MD_ATOMIC_DECREMENT(PRInt32 *val)
{
PRInt32 result;
asm volatile ("lock ; xadd %0, %1"
: "=r"(result), "=m"(*val)
: "0"(1), "m"(*val));
return result - 1;
}
#endif