diff options
author | wtc%netscape.com <devnull@localhost> | 2001-06-27 01:36:22 +0000 |
---|---|---|
committer | wtc%netscape.com <devnull@localhost> | 2001-06-27 01:36:22 +0000 |
commit | f55269288c648f4b4722e391fea0e338f988f8f9 (patch) | |
tree | 1840d9575dc81b9b96763f29aad56f89ee42f613 | |
parent | 02c4cd668bc6def329d1d590b196b76a164b217f (diff) | |
download | nspr-hg-f55269288c648f4b4722e391fea0e338f988f8f9.tar.gz |
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
Added file: os2vacpp.asm
Tag: NSPRPUB_CLIENT_BRANCH
-rw-r--r-- | config/autoconf.mk.in | 1 | ||||
-rw-r--r-- | config/rules.mk | 8 | ||||
-rwxr-xr-x | configure | 56 | ||||
-rw-r--r-- | configure.in | 5 | ||||
-rw-r--r-- | pr/include/md/_os2.h | 12 | ||||
-rw-r--r-- | pr/src/md/os2/Makefile.in | 4 | ||||
-rw-r--r-- | pr/src/md/os2/objs.mk | 28 | ||||
-rw-r--r-- | pr/src/md/os2/os2misc.c | 41 | ||||
-rw-r--r-- | pr/src/md/os2/os2vacpp.asm | 33 |
9 files changed, 120 insertions, 68 deletions
diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 9ac9c31e..71cb9751 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -23,6 +23,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/config/rules.mk b/config/rules.mk index 2e623a75..0b18e632 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -129,7 +129,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) @@ -373,6 +373,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 @@ -2425,6 +2425,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= @@ -4159,6 +4160,7 @@ EOF OBJ_SUFFIX=obj LIB_SUFFIX=lib DLL_SUFFIX=dll + ASM_SUFFIX=asm DLLTOOL='' RC=rc.exe PR_MD_ARCH_DIR=os2 @@ -4216,6 +4218,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-' @@ -4257,12 +4261,12 @@ esac if test -z "$SKIP_LIBRARY_CHECKS"; then echo $ac_n "checking for dlopen""... $ac_c" 1>&6 -echo "configure:4261: checking for dlopen" >&5 +echo "configure:4265: 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 4266 "configure" +#line 4270 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen(); below. */ @@ -4285,7 +4289,7 @@ dlopen(); ; return 0; } EOF -if { (eval echo configure:4289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4293: \"$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 @@ -4304,7 +4308,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:4308: checking for dlopen in -ldl" >&5 +echo "configure:4312: 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 @@ -4312,7 +4316,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <<EOF -#line 4316 "configure" +#line 4320 "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 @@ -4323,7 +4327,7 @@ int main() { dlopen() ; return 0; } EOF -if { (eval echo configure:4327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4331: \"$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 @@ -4350,7 +4354,7 @@ fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:4354: checking how to run the C preprocessor" >&5 +echo "configure:4358: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -4365,13 +4369,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext <<EOF -#line 4369 "configure" +#line 4373 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4375: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4379: \"$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 : @@ -4382,13 +4386,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext <<EOF -#line 4386 "configure" +#line 4390 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4392: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4396: \"$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 : @@ -4399,13 +4403,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext <<EOF -#line 4403 "configure" +#line 4407 "configure" #include "confdefs.h" #include <assert.h> Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:4409: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:4413: \"$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 : @@ -4431,13 +4435,13 @@ echo "$ac_t""$CPP" 1>&6 if test $ac_cv_prog_gcc = yes; then echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6 -echo "configure:4435: checking whether ${CC-cc} needs -traditional" >&5 +echo "configure:4439: 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 4441 "configure" +#line 4445 "configure" #include "confdefs.h" #include <sgtty.h> Autoconf TIOCGETP @@ -4455,7 +4459,7 @@ rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat > conftest.$ac_ext <<EOF -#line 4459 "configure" +#line 4463 "configure" #include "confdefs.h" #include <termio.h> Autoconf TCGETA @@ -4479,12 +4483,12 @@ fi for ac_func in lchown strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:4483: checking for $ac_func" >&5 +echo "configure:4487: 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 4488 "configure" +#line 4492 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func(); below. */ @@ -4507,7 +4511,7 @@ $ac_func(); ; return 0; } EOF -if { (eval echo configure:4511: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:4515: \"$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 @@ -4538,7 +4542,7 @@ done echo $ac_n "checking for pthread_create in -lpthreads""... $ac_c" 1>&6 -echo "configure:4542: checking for pthread_create in -lpthreads" >&5 +echo "configure:4546: checking for pthread_create in -lpthreads" >&5 echo " #include <pthread.h> void *foo(void *v) { int a = 1; } @@ -4560,7 +4564,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6 -echo "configure:4564: checking for pthread_create in -lpthread" >&5 +echo "configure:4568: checking for pthread_create in -lpthread" >&5 echo " #include <pthread.h> void *foo(void *v) { int a = 1; } @@ -4582,7 +4586,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6 -echo "configure:4586: checking for pthread_create in -lc_r" >&5 +echo "configure:4590: checking for pthread_create in -lc_r" >&5 echo " #include <pthread.h> void *foo(void *v) { int a = 1; } @@ -4604,7 +4608,7 @@ echo " echo "$ac_t""no" 1>&6 echo $ac_n "checking for pthread_create in -lc""... $ac_c" 1>&6 -echo "configure:4608: checking for pthread_create in -lc" >&5 +echo "configure:4612: checking for pthread_create in -lc" >&5 echo " #include <pthread.h> void *foo(void *v) { int a = 1; } @@ -4754,7 +4758,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:4758: checking whether ${CC-cc} accepts -pthread" >&5 +echo "configure:4762: 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 @@ -4770,7 +4774,7 @@ echo "configure:4758: 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:4774: checking whether ${CC-cc} accepts -pthreads" >&5 +echo "configure:4778: 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 @@ -5032,6 +5036,7 @@ fi + MAKEFILES=" Makefile config/Makefile @@ -5281,6 +5286,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/configure.in b/configure.in index 95d49470..f8430ebb 100644 --- a/configure.in +++ b/configure.in @@ -334,6 +334,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= @@ -1475,6 +1476,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 @@ -1514,6 +1516,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-' @@ -1954,6 +1958,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/pr/include/md/_os2.h b/pr/include/md/_os2.h index c08202e9..0ecad55f 100644 --- a/pr/include/md/_os2.h +++ b/pr/include/md/_os2.h @@ -55,7 +55,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 @@ -262,11 +262,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/pr/src/md/os2/Makefile.in b/pr/src/md/os2/Makefile.in index 08f866d7..1965f882 100644 --- a/pr/src/md/os2/Makefile.in +++ b/pr/src/md/os2/Makefile.in @@ -42,6 +42,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/pr/src/md/os2/objs.mk b/pr/src/md/os2/objs.mk index 82693637..1cc6029f 100644 --- a/pr/src/md/os2/objs.mk +++ b/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) +ifeq ($(MOZ_OS2_TOOLS),VACPP) +ASFILES = os2vacpp.asm +endif + OBJS += $(addprefix md/os2/$(OBJDIR)/,$(CSRCS:.c=.$(OBJ_SUFFIX))) \ - $(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.s=.$(OBJ_SUFFIX))) + $(addprefix md/os2/$(OBJDIR)/,$(ASFILES:.asm=.$(OBJ_SUFFIX))) diff --git a/pr/src/md/os2/os2misc.c b/pr/src/md/os2/os2misc.c index 28c9a641..82393035 100644 --- a/pr/src/md/os2/os2misc.c +++ b/pr/src/md/os2/os2misc.c @@ -553,3 +553,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 + diff --git a/pr/src/md/os2/os2vacpp.asm b/pr/src/md/os2/os2vacpp.asm index 2581323b..516ff371 100644 --- a/pr/src/md/os2/os2vacpp.asm +++ b/pr/src/md/os2/os2vacpp.asm @@ -1,34 +1,19 @@ COMMENT | -*- Mode: asm; tab-width: 8; c-basic-offset: 4 -*- - 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 contents of this file are subject to the Mozilla Public License + Version 1.1 (the "MPL"); you may not use this file except in + compliance with the MPL. You may obtain a copy of the MPL at + http://www.mozilla.org/MPL/ - The Original Code is the Netscape Portable Runtime (NSPR). + Software distributed under the MPL is distributed on an "AS IS" basis, + WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL + for the specific language governing rights and limitations under the + MPL. - The Initial Developer of the Original Code is IBM Corporation. + The Initial Developer of this code under the MPL is IBM Corporation. Portions created by IBM are Copyright (C) 2001 IBM Corporation. All Rights Reserved. - Contributor(s): - - 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. - Windows uses inline assembly for their atomic functions, so we have created an assembly file for VACPP on OS/2 | |