From 3aeb80d8839371e39cf6bbf03e68ad828c9a11ed Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Sat, 23 Jun 2001 04:09:19 +0000 Subject: [PATCH] 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 --- nsprpub/config/autoconf.mk.in | 1 + nsprpub/config/rules.mk | 8 ++++- nsprpub/configure | 54 +++++++++++++++++-------------- nsprpub/configure.in | 5 +++ nsprpub/pr/include/md/_os2.h | 12 +++---- nsprpub/pr/src/md/os2/Makefile.in | 4 +++ nsprpub/pr/src/md/os2/objs.mk | 30 +++++++++-------- nsprpub/pr/src/md/os2/os2misc.c | 41 +++++++++++++++++++++++ 8 files changed, 111 insertions(+), 44 deletions(-) diff --git a/nsprpub/config/autoconf.mk.in b/nsprpub/config/autoconf.mk.in index d78881929ca9..0fe58d6b495b 100644 --- a/nsprpub/config/autoconf.mk.in +++ b/nsprpub/config/autoconf.mk.in @@ -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@ diff --git a/nsprpub/config/rules.mk b/nsprpub/config/rules.mk index e6e91e32ed22..ee04b04ff236 100644 --- a/nsprpub/config/rules.mk +++ b/nsprpub/config/rules.mk @@ -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 diff --git a/nsprpub/configure b/nsprpub/configure index 9c34e105527a..82d3e24d1cdf 100755 --- a/nsprpub/configure +++ b/nsprpub/configure @@ -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 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 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 <&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 <&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 < Autoconf TIOCGETP @@ -4667,7 +4671,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext < 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 <&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 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 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 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 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 diff --git a/nsprpub/configure.in b/nsprpub/configure.in index 057bad0887e5..2c7f21d8e2db 100644 --- a/nsprpub/configure.in +++ b/nsprpub/configure.in @@ -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) diff --git a/nsprpub/pr/include/md/_os2.h b/nsprpub/pr/include/md/_os2.h index e06d9a85f678..c11daf5762e1 100644 --- a/nsprpub/pr/include/md/_os2.h +++ b/nsprpub/pr/include/md/_os2.h @@ -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) diff --git a/nsprpub/pr/src/md/os2/Makefile.in b/nsprpub/pr/src/md/os2/Makefile.in index 1a039aa6bdb9..9898c88fe6f1 100644 --- a/nsprpub/pr/src/md/os2/Makefile.in +++ b/nsprpub/pr/src/md/os2/Makefile.in @@ -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 diff --git a/nsprpub/pr/src/md/os2/objs.mk b/nsprpub/pr/src/md/os2/objs.mk index 82693637ab17..1cc6029f484d 100644 --- a/nsprpub/pr/src/md/os2/objs.mk +++ b/nsprpub/pr/src/md/os2/objs.mk @@ -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))) diff --git a/nsprpub/pr/src/md/os2/os2misc.c b/nsprpub/pr/src/md/os2/os2misc.c index 560fbe572b48..be597fcdc838 100644 --- a/nsprpub/pr/src/md/os2/os2misc.c +++ b/nsprpub/pr/src/md/os2/os2misc.c @@ -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 +