Add libatomic as a target library.
From-SVN: r187018
This commit is contained in:
parent
e8053cf5b5
commit
483104922a
84 changed files with 29407 additions and 5 deletions
|
@ -1,3 +1,10 @@
|
|||
2012-05-01 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* Makefile.def (libatomic): New target_module.
|
||||
* configure.ac (target_libraries): Add libatomic.
|
||||
(noconfigdirs): Check if libatomic is supported.
|
||||
* Makefile.in, configure: Rebuild.
|
||||
|
||||
2012-05-01 Greta Yorsh <Greta.Yorsh@arm.com>
|
||||
|
||||
* MAINTAINERS (Write After Approval): Add myself.
|
||||
|
|
|
@ -140,6 +140,7 @@ target_modules = { module= rda; };
|
|||
target_modules = { module= libada; };
|
||||
target_modules = { module= libgomp; bootstrap= true; lib_path=.libs; };
|
||||
target_modules = { module= libitm; lib_path=.libs; };
|
||||
target_modules = { module= libatomic; lib_path=.libs; };
|
||||
|
||||
// These are (some of) the make targets to be done in each subdirectory.
|
||||
// Not all; these are the ones which don't have special options.
|
||||
|
|
494
Makefile.in
494
Makefile.in
|
@ -599,7 +599,7 @@ all:
|
|||
|
||||
# This is the list of directories that may be needed in RPATH_ENVVAR
|
||||
# so that programs built for the target machine work.
|
||||
TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libmudflap)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(TARGET_LIB_PATH_libitm)$(HOST_LIB_PATH_gcc)
|
||||
TARGET_LIB_PATH = $(TARGET_LIB_PATH_libstdc++-v3)$(TARGET_LIB_PATH_libmudflap)$(TARGET_LIB_PATH_libssp)$(TARGET_LIB_PATH_libgomp)$(TARGET_LIB_PATH_libitm)$(TARGET_LIB_PATH_libatomic)$(HOST_LIB_PATH_gcc)
|
||||
|
||||
@if target-libstdc++-v3
|
||||
TARGET_LIB_PATH_libstdc++-v3 = $$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs:
|
||||
|
@ -621,6 +621,10 @@ TARGET_LIB_PATH_libgomp = $$r/$(TARGET_SUBDIR)/libgomp/.libs:
|
|||
TARGET_LIB_PATH_libitm = $$r/$(TARGET_SUBDIR)/libitm/.libs:
|
||||
@endif target-libitm
|
||||
|
||||
@if target-libatomic
|
||||
TARGET_LIB_PATH_libatomic = $$r/$(TARGET_SUBDIR)/libatomic/.libs:
|
||||
@endif target-libatomic
|
||||
|
||||
|
||||
|
||||
# This is the list of directories that may be needed in RPATH_ENVVAR
|
||||
|
@ -960,7 +964,8 @@ configure-target: \
|
|||
maybe-configure-target-rda \
|
||||
maybe-configure-target-libada \
|
||||
maybe-configure-target-libgomp \
|
||||
maybe-configure-target-libitm
|
||||
maybe-configure-target-libitm \
|
||||
maybe-configure-target-libatomic
|
||||
|
||||
# The target built for a native non-bootstrap build.
|
||||
.PHONY: all
|
||||
|
@ -1108,6 +1113,7 @@ all-target: maybe-all-target-libada
|
|||
all-target: maybe-all-target-libgomp
|
||||
@endif target-libgomp-no-bootstrap
|
||||
all-target: maybe-all-target-libitm
|
||||
all-target: maybe-all-target-libatomic
|
||||
|
||||
# Do a target for all the subdirectories. A ``make do-X'' will do a
|
||||
# ``make X'' in all subdirectories (because, in general, there is a
|
||||
|
@ -1191,6 +1197,7 @@ info-target: maybe-info-target-rda
|
|||
info-target: maybe-info-target-libada
|
||||
info-target: maybe-info-target-libgomp
|
||||
info-target: maybe-info-target-libitm
|
||||
info-target: maybe-info-target-libatomic
|
||||
|
||||
.PHONY: do-dvi
|
||||
do-dvi:
|
||||
|
@ -1269,6 +1276,7 @@ dvi-target: maybe-dvi-target-rda
|
|||
dvi-target: maybe-dvi-target-libada
|
||||
dvi-target: maybe-dvi-target-libgomp
|
||||
dvi-target: maybe-dvi-target-libitm
|
||||
dvi-target: maybe-dvi-target-libatomic
|
||||
|
||||
.PHONY: do-pdf
|
||||
do-pdf:
|
||||
|
@ -1347,6 +1355,7 @@ pdf-target: maybe-pdf-target-rda
|
|||
pdf-target: maybe-pdf-target-libada
|
||||
pdf-target: maybe-pdf-target-libgomp
|
||||
pdf-target: maybe-pdf-target-libitm
|
||||
pdf-target: maybe-pdf-target-libatomic
|
||||
|
||||
.PHONY: do-html
|
||||
do-html:
|
||||
|
@ -1425,6 +1434,7 @@ html-target: maybe-html-target-rda
|
|||
html-target: maybe-html-target-libada
|
||||
html-target: maybe-html-target-libgomp
|
||||
html-target: maybe-html-target-libitm
|
||||
html-target: maybe-html-target-libatomic
|
||||
|
||||
.PHONY: do-TAGS
|
||||
do-TAGS:
|
||||
|
@ -1503,6 +1513,7 @@ TAGS-target: maybe-TAGS-target-rda
|
|||
TAGS-target: maybe-TAGS-target-libada
|
||||
TAGS-target: maybe-TAGS-target-libgomp
|
||||
TAGS-target: maybe-TAGS-target-libitm
|
||||
TAGS-target: maybe-TAGS-target-libatomic
|
||||
|
||||
.PHONY: do-install-info
|
||||
do-install-info:
|
||||
|
@ -1581,6 +1592,7 @@ install-info-target: maybe-install-info-target-rda
|
|||
install-info-target: maybe-install-info-target-libada
|
||||
install-info-target: maybe-install-info-target-libgomp
|
||||
install-info-target: maybe-install-info-target-libitm
|
||||
install-info-target: maybe-install-info-target-libatomic
|
||||
|
||||
.PHONY: do-install-pdf
|
||||
do-install-pdf:
|
||||
|
@ -1659,6 +1671,7 @@ install-pdf-target: maybe-install-pdf-target-rda
|
|||
install-pdf-target: maybe-install-pdf-target-libada
|
||||
install-pdf-target: maybe-install-pdf-target-libgomp
|
||||
install-pdf-target: maybe-install-pdf-target-libitm
|
||||
install-pdf-target: maybe-install-pdf-target-libatomic
|
||||
|
||||
.PHONY: do-install-html
|
||||
do-install-html:
|
||||
|
@ -1737,6 +1750,7 @@ install-html-target: maybe-install-html-target-rda
|
|||
install-html-target: maybe-install-html-target-libada
|
||||
install-html-target: maybe-install-html-target-libgomp
|
||||
install-html-target: maybe-install-html-target-libitm
|
||||
install-html-target: maybe-install-html-target-libatomic
|
||||
|
||||
.PHONY: do-installcheck
|
||||
do-installcheck:
|
||||
|
@ -1815,6 +1829,7 @@ installcheck-target: maybe-installcheck-target-rda
|
|||
installcheck-target: maybe-installcheck-target-libada
|
||||
installcheck-target: maybe-installcheck-target-libgomp
|
||||
installcheck-target: maybe-installcheck-target-libitm
|
||||
installcheck-target: maybe-installcheck-target-libatomic
|
||||
|
||||
.PHONY: do-mostlyclean
|
||||
do-mostlyclean:
|
||||
|
@ -1893,6 +1908,7 @@ mostlyclean-target: maybe-mostlyclean-target-rda
|
|||
mostlyclean-target: maybe-mostlyclean-target-libada
|
||||
mostlyclean-target: maybe-mostlyclean-target-libgomp
|
||||
mostlyclean-target: maybe-mostlyclean-target-libitm
|
||||
mostlyclean-target: maybe-mostlyclean-target-libatomic
|
||||
|
||||
.PHONY: do-clean
|
||||
do-clean:
|
||||
|
@ -1971,6 +1987,7 @@ clean-target: maybe-clean-target-rda
|
|||
clean-target: maybe-clean-target-libada
|
||||
clean-target: maybe-clean-target-libgomp
|
||||
clean-target: maybe-clean-target-libitm
|
||||
clean-target: maybe-clean-target-libatomic
|
||||
|
||||
.PHONY: do-distclean
|
||||
do-distclean:
|
||||
|
@ -2049,6 +2066,7 @@ distclean-target: maybe-distclean-target-rda
|
|||
distclean-target: maybe-distclean-target-libada
|
||||
distclean-target: maybe-distclean-target-libgomp
|
||||
distclean-target: maybe-distclean-target-libitm
|
||||
distclean-target: maybe-distclean-target-libatomic
|
||||
|
||||
.PHONY: do-maintainer-clean
|
||||
do-maintainer-clean:
|
||||
|
@ -2127,6 +2145,7 @@ maintainer-clean-target: maybe-maintainer-clean-target-rda
|
|||
maintainer-clean-target: maybe-maintainer-clean-target-libada
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-libgomp
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-libitm
|
||||
maintainer-clean-target: maybe-maintainer-clean-target-libatomic
|
||||
|
||||
|
||||
# Here are the targets which correspond to the do-X targets.
|
||||
|
@ -2259,7 +2278,8 @@ check-target: \
|
|||
maybe-check-target-rda \
|
||||
maybe-check-target-libada \
|
||||
maybe-check-target-libgomp \
|
||||
maybe-check-target-libitm
|
||||
maybe-check-target-libitm \
|
||||
maybe-check-target-libatomic
|
||||
|
||||
do-check:
|
||||
@: $(MAKE); $(unstage)
|
||||
|
@ -2409,7 +2429,8 @@ install-target: \
|
|||
maybe-install-target-rda \
|
||||
maybe-install-target-libada \
|
||||
maybe-install-target-libgomp \
|
||||
maybe-install-target-libitm
|
||||
maybe-install-target-libitm \
|
||||
maybe-install-target-libatomic
|
||||
|
||||
uninstall:
|
||||
@echo "the uninstall target is not supported in this tree"
|
||||
|
@ -2506,7 +2527,8 @@ install-strip-target: \
|
|||
maybe-install-strip-target-rda \
|
||||
maybe-install-strip-target-libada \
|
||||
maybe-install-strip-target-libgomp \
|
||||
maybe-install-strip-target-libitm
|
||||
maybe-install-strip-target-libitm \
|
||||
maybe-install-strip-target-libatomic
|
||||
|
||||
|
||||
### other supporting targets
|
||||
|
@ -40629,6 +40651,463 @@ maintainer-clean-target-libitm:
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
.PHONY: configure-target-libatomic maybe-configure-target-libatomic
|
||||
maybe-configure-target-libatomic:
|
||||
@if gcc-bootstrap
|
||||
configure-target-libatomic: stage_current
|
||||
@endif gcc-bootstrap
|
||||
@if target-libatomic
|
||||
maybe-configure-target-libatomic: configure-target-libatomic
|
||||
configure-target-libatomic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
echo "Checking multilib configuration for libatomic..."; \
|
||||
$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libatomic ; \
|
||||
$(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libatomic/multilib.tmp 2> /dev/null ; \
|
||||
if test -r $(TARGET_SUBDIR)/libatomic/multilib.out; then \
|
||||
if cmp -s $(TARGET_SUBDIR)/libatomic/multilib.tmp $(TARGET_SUBDIR)/libatomic/multilib.out; then \
|
||||
rm -f $(TARGET_SUBDIR)/libatomic/multilib.tmp; \
|
||||
else \
|
||||
rm -f $(TARGET_SUBDIR)/libatomic/Makefile; \
|
||||
mv $(TARGET_SUBDIR)/libatomic/multilib.tmp $(TARGET_SUBDIR)/libatomic/multilib.out; \
|
||||
fi; \
|
||||
else \
|
||||
mv $(TARGET_SUBDIR)/libatomic/multilib.tmp $(TARGET_SUBDIR)/libatomic/multilib.out; \
|
||||
fi; \
|
||||
test ! -f $(TARGET_SUBDIR)/libatomic/Makefile || exit 0; \
|
||||
$(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libatomic ; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo Configuring in $(TARGET_SUBDIR)/libatomic; \
|
||||
cd "$(TARGET_SUBDIR)/libatomic" || exit 1; \
|
||||
case $(srcdir) in \
|
||||
/* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
|
||||
*) topdir=`echo $(TARGET_SUBDIR)/libatomic/ | \
|
||||
sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
|
||||
esac; \
|
||||
srcdiroption="--srcdir=$${topdir}/libatomic"; \
|
||||
libsrcdir="$$s/libatomic"; \
|
||||
rm -f no-such-file || : ; \
|
||||
CONFIG_SITE=no-such-file $(SHELL) $${libsrcdir}/configure \
|
||||
$(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \
|
||||
--target=${target_alias} $${srcdiroption} \
|
||||
|| exit 1
|
||||
@endif target-libatomic
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.PHONY: all-target-libatomic maybe-all-target-libatomic
|
||||
maybe-all-target-libatomic:
|
||||
@if gcc-bootstrap
|
||||
all-target-libatomic: stage_current
|
||||
@endif gcc-bootstrap
|
||||
@if target-libatomic
|
||||
TARGET-target-libatomic=all
|
||||
maybe-all-target-libatomic: all-target-libatomic
|
||||
all-target-libatomic: configure-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) \
|
||||
$(TARGET-target-libatomic))
|
||||
@endif target-libatomic
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.PHONY: check-target-libatomic maybe-check-target-libatomic
|
||||
maybe-check-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-check-target-libatomic: check-target-libatomic
|
||||
|
||||
check-target-libatomic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(TARGET_FLAGS_TO_PASS) check)
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: install-target-libatomic maybe-install-target-libatomic
|
||||
maybe-install-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-install-target-libatomic: install-target-libatomic
|
||||
|
||||
install-target-libatomic: installdirs
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(TARGET_FLAGS_TO_PASS) install)
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: install-strip-target-libatomic maybe-install-strip-target-libatomic
|
||||
maybe-install-strip-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-install-strip-target-libatomic: install-strip-target-libatomic
|
||||
|
||||
install-strip-target-libatomic: installdirs
|
||||
@: $(MAKE); $(unstage)
|
||||
@r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(TARGET_FLAGS_TO_PASS) install-strip)
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
# Other targets (info, dvi, pdf, etc.)
|
||||
|
||||
.PHONY: maybe-info-target-libatomic info-target-libatomic
|
||||
maybe-info-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-info-target-libatomic: info-target-libatomic
|
||||
|
||||
info-target-libatomic: \
|
||||
configure-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing info in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
info) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-dvi-target-libatomic dvi-target-libatomic
|
||||
maybe-dvi-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-dvi-target-libatomic: dvi-target-libatomic
|
||||
|
||||
dvi-target-libatomic: \
|
||||
configure-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing dvi in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
dvi) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-pdf-target-libatomic pdf-target-libatomic
|
||||
maybe-pdf-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-pdf-target-libatomic: pdf-target-libatomic
|
||||
|
||||
pdf-target-libatomic: \
|
||||
configure-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing pdf in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
pdf) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-html-target-libatomic html-target-libatomic
|
||||
maybe-html-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-html-target-libatomic: html-target-libatomic
|
||||
|
||||
html-target-libatomic: \
|
||||
configure-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing html in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
html) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-TAGS-target-libatomic TAGS-target-libatomic
|
||||
maybe-TAGS-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-TAGS-target-libatomic: TAGS-target-libatomic
|
||||
|
||||
TAGS-target-libatomic: \
|
||||
configure-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing TAGS in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
TAGS) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-install-info-target-libatomic install-info-target-libatomic
|
||||
maybe-install-info-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-install-info-target-libatomic: install-info-target-libatomic
|
||||
|
||||
install-info-target-libatomic: \
|
||||
configure-target-libatomic \
|
||||
info-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing install-info in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
install-info) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-install-pdf-target-libatomic install-pdf-target-libatomic
|
||||
maybe-install-pdf-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-install-pdf-target-libatomic: install-pdf-target-libatomic
|
||||
|
||||
install-pdf-target-libatomic: \
|
||||
configure-target-libatomic \
|
||||
pdf-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing install-pdf in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
install-pdf) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-install-html-target-libatomic install-html-target-libatomic
|
||||
maybe-install-html-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-install-html-target-libatomic: install-html-target-libatomic
|
||||
|
||||
install-html-target-libatomic: \
|
||||
configure-target-libatomic \
|
||||
html-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing install-html in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
install-html) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-installcheck-target-libatomic installcheck-target-libatomic
|
||||
maybe-installcheck-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-installcheck-target-libatomic: installcheck-target-libatomic
|
||||
|
||||
installcheck-target-libatomic: \
|
||||
configure-target-libatomic
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing installcheck in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
installcheck) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-mostlyclean-target-libatomic mostlyclean-target-libatomic
|
||||
maybe-mostlyclean-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-mostlyclean-target-libatomic: mostlyclean-target-libatomic
|
||||
|
||||
mostlyclean-target-libatomic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing mostlyclean in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
mostlyclean) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-clean-target-libatomic clean-target-libatomic
|
||||
maybe-clean-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-clean-target-libatomic: clean-target-libatomic
|
||||
|
||||
clean-target-libatomic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing clean in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
clean) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-distclean-target-libatomic distclean-target-libatomic
|
||||
maybe-distclean-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-distclean-target-libatomic: distclean-target-libatomic
|
||||
|
||||
distclean-target-libatomic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing distclean in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
distclean) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
.PHONY: maybe-maintainer-clean-target-libatomic maintainer-clean-target-libatomic
|
||||
maybe-maintainer-clean-target-libatomic:
|
||||
@if target-libatomic
|
||||
maybe-maintainer-clean-target-libatomic: maintainer-clean-target-libatomic
|
||||
|
||||
maintainer-clean-target-libatomic:
|
||||
@: $(MAKE); $(unstage)
|
||||
@[ -f $(TARGET_SUBDIR)/libatomic/Makefile ] || exit 0 ; \
|
||||
r=`${PWD_COMMAND}`; export r; \
|
||||
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
|
||||
$(NORMAL_TARGET_EXPORTS) \
|
||||
echo "Doing maintainer-clean in $(TARGET_SUBDIR)/libatomic" ; \
|
||||
for flag in $(EXTRA_TARGET_FLAGS); do \
|
||||
eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
|
||||
done; \
|
||||
(cd $(TARGET_SUBDIR)/libatomic && \
|
||||
$(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
|
||||
"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
|
||||
"RANLIB=$${RANLIB}" \
|
||||
"DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \
|
||||
maintainer-clean) \
|
||||
|| exit 1
|
||||
|
||||
@endif target-libatomic
|
||||
|
||||
|
||||
|
||||
@if target-libmudflap
|
||||
.PHONY: check-target-libmudflap-c++
|
||||
check-target-libmudflap-c++:
|
||||
|
@ -42721,6 +43200,7 @@ configure-stage4-target-libgomp: maybe-all-stage4-gcc
|
|||
configure-stageprofile-target-libgomp: maybe-all-stageprofile-gcc
|
||||
configure-stagefeedback-target-libgomp: maybe-all-stagefeedback-gcc
|
||||
configure-target-libitm: stage_last
|
||||
configure-target-libatomic: stage_last
|
||||
@endif gcc-bootstrap
|
||||
|
||||
@if gcc-no-bootstrap
|
||||
|
@ -42744,6 +43224,7 @@ configure-target-rda: maybe-all-gcc
|
|||
configure-target-libada: maybe-all-gcc
|
||||
configure-target-libgomp: maybe-all-gcc
|
||||
configure-target-libitm: maybe-all-gcc
|
||||
configure-target-libatomic: maybe-all-gcc
|
||||
@endif gcc-no-bootstrap
|
||||
|
||||
|
||||
|
@ -43519,6 +44000,7 @@ configure-target-rda: maybe-all-target-libgcc
|
|||
configure-target-libada: maybe-all-target-libgcc
|
||||
configure-target-libgomp: maybe-all-target-libgcc
|
||||
configure-target-libitm: maybe-all-target-libgcc
|
||||
configure-target-libatomic: maybe-all-target-libgcc
|
||||
@endif gcc-no-bootstrap
|
||||
|
||||
|
||||
|
@ -43561,6 +44043,8 @@ configure-target-libgomp: maybe-all-target-newlib maybe-all-target-libgloss
|
|||
configure-target-libitm: maybe-all-target-newlib maybe-all-target-libgloss
|
||||
configure-target-libitm: maybe-all-target-libstdc++-v3
|
||||
|
||||
configure-target-libatomic: maybe-all-target-newlib maybe-all-target-libgloss
|
||||
|
||||
|
||||
CONFIGURE_GDB_TK = @CONFIGURE_GDB_TK@
|
||||
GDB_TK = @GDB_TK@
|
||||
|
|
20
configure
vendored
20
configure
vendored
|
@ -2688,6 +2688,7 @@ target_libraries="target-libgcc \
|
|||
target-libgloss \
|
||||
target-newlib \
|
||||
target-libgomp \
|
||||
target-libatomic \
|
||||
target-libitm \
|
||||
target-libstdc++-v3 \
|
||||
target-libmudflap \
|
||||
|
@ -3064,6 +3065,25 @@ if test x$enable_libgomp = x ; then
|
|||
esac
|
||||
fi
|
||||
|
||||
# Disable libatomic on unsupported systems.
|
||||
if test -d ${srcdir}/libatomic; then
|
||||
if test x$enable_libatomic = x; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libatomic support" >&5
|
||||
$as_echo_n "checking for libatomic support... " >&6; }
|
||||
if (srcdir=${srcdir}/libatomic; \
|
||||
. ${srcdir}/configure.tgt; \
|
||||
test -n "$UNSUPPORTED")
|
||||
then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
noconfigdirs="$noconfigdirs target-libatomic"
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Disable libitm on unsupported systems.
|
||||
if test -d ${srcdir}/libitm; then
|
||||
if test x$enable_libitm = x; then
|
||||
|
|
17
configure.ac
17
configure.ac
|
@ -154,6 +154,7 @@ target_libraries="target-libgcc \
|
|||
target-libgloss \
|
||||
target-newlib \
|
||||
target-libgomp \
|
||||
target-libatomic \
|
||||
target-libitm \
|
||||
target-libstdc++-v3 \
|
||||
target-libmudflap \
|
||||
|
@ -493,6 +494,22 @@ if test x$enable_libgomp = x ; then
|
|||
esac
|
||||
fi
|
||||
|
||||
# Disable libatomic on unsupported systems.
|
||||
if test -d ${srcdir}/libatomic; then
|
||||
if test x$enable_libatomic = x; then
|
||||
AC_MSG_CHECKING([for libatomic support])
|
||||
if (srcdir=${srcdir}/libatomic; \
|
||||
. ${srcdir}/configure.tgt; \
|
||||
test -n "$UNSUPPORTED")
|
||||
then
|
||||
AC_MSG_RESULT([no])
|
||||
noconfigdirs="$noconfigdirs target-libatomic"
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Disable libitm on unsupported systems.
|
||||
if test -d ${srcdir}/libitm; then
|
||||
if test x$enable_libitm = x; then
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2012-05-01 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* gcc_update: Add libatomic generated files.
|
||||
|
||||
2012-04-23 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
* compare_tests: Append '/' to make 'find' traverse
|
||||
|
|
|
@ -144,6 +144,11 @@ libitm/Makefile.in: libitm/Makefile.am libitm/aclocal.m4
|
|||
libitm/testsuite/Makefile.in: libitm/testsuite/Makefile.am libitm/aclocal.m4
|
||||
libitm/configure: libitm/configure.ac libitm/aclocal.m4
|
||||
libitm/config.h.in: libitm/configure.ac libitm/aclocal.m4
|
||||
libatomic/aclocal.m4: libatomic/configure.ac libatomic/acinclude.m4
|
||||
libatomic/Makefile.in: libatomic/Makefile.am libatomic/aclocal.m4
|
||||
libatomic/testsuite/Makefile.in: libatomic/testsuite/Makefile.am libatomic/aclocal.m4
|
||||
libatomic/configure: libatomic/configure.ac libatomic/aclocal.m4
|
||||
libatomic/auto-config.h.in: libatomic/configure.ac libatomic/aclocal.m4
|
||||
# Top level
|
||||
Makefile.in: Makefile.tpl Makefile.def
|
||||
configure: configure.ac config/acx.m4
|
||||
|
|
2
libatomic/.gitignore
vendored
Normal file
2
libatomic/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
autom4te.cache
|
||||
auto-config.h.in~
|
3
libatomic/ChangeLog
Normal file
3
libatomic/ChangeLog
Normal file
|
@ -0,0 +1,3 @@
|
|||
2012-05-01 Richard Henderson <rth@redhat.com>
|
||||
|
||||
* Initial commit.
|
136
libatomic/Makefile.am
Normal file
136
libatomic/Makefile.am
Normal file
|
@ -0,0 +1,136 @@
|
|||
## Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
## Contributed by Richard Henderson <rth@redhat.com>.
|
||||
##
|
||||
## This file is part of the GNU Atomic Library (libatomic).
|
||||
##
|
||||
## Libatomic is free software; you can redistribute it and/or modify it
|
||||
## under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
## WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
## more details.
|
||||
##
|
||||
## Under Section 7 of GPL version 3, you are granted additional
|
||||
## permissions described in the GCC Runtime Library Exception, version
|
||||
## 3.1, as published by the Free Software Foundation.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License and
|
||||
## a copy of the GCC Runtime Library Exception along with this program;
|
||||
## see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
## <http://www.gnu.org/licenses/>.
|
||||
|
||||
ACLOCAL_AMFLAGS = -I .. -I ../config
|
||||
SUBDIRS = testsuite
|
||||
|
||||
## May be used by toolexeclibdir.
|
||||
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
|
||||
|
||||
config_path= @config_path@
|
||||
search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) \
|
||||
$(top_srcdir) $(top_builddir)
|
||||
|
||||
vpath % $(strip $(search_path))
|
||||
|
||||
DEFAULT_INCLUDES = $(addprefix -I, $(search_path))
|
||||
AM_CFLAGS = $(XCFLAGS)
|
||||
AM_CCASFLAGS = $(XCFLAGS)
|
||||
AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
|
||||
|
||||
toolexeclib_LTLIBRARIES = libatomic.la
|
||||
|
||||
if LIBAT_BUILD_VERSIONED_SHLIB
|
||||
if LIBAT_BUILD_VERSIONED_SHLIB_GNU
|
||||
libatomic_version_script = -Wl,--version-script,$(top_srcdir)/libatomic.map
|
||||
libatomic_version_dep = $(top_srcdir)/libatomic.map
|
||||
endif
|
||||
if LIBAT_BUILD_VERSIONED_SHLIB_SUN
|
||||
libatomic_version_script = -Wl,-M,libatomic.map-sun
|
||||
libatomic_version_dep = libatomic.map-sun
|
||||
libatomic.map-sun : $(top_srcdir)/libatomic.map \
|
||||
$(top_srcdir)/../contrib/make_sunver.pl \
|
||||
$(libatomic_la_OBJECTS) $(libatomic_la_LIBADD)
|
||||
perl $(top_srcdir)/../contrib/make_sunver.pl \
|
||||
$(top_srcdir)/libatomic.map \
|
||||
$(libatomic_la_OBJECTS:%.lo=.libs/%.o) \
|
||||
`echo $(libatomic_la_LIBADD) | \
|
||||
sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
|
||||
> $@ || (rm -f $@ ; exit 1)
|
||||
endif
|
||||
else
|
||||
libatomic_version_script =
|
||||
libatomic_version_dep =
|
||||
endif
|
||||
libatomic_version_info = -version-info $(libtool_VERSION)
|
||||
|
||||
libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script)
|
||||
libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c
|
||||
|
||||
SIZEOBJS = load store cas exch fadd fsub fand fior fxor fnand tas
|
||||
SIZES = @SIZES@
|
||||
|
||||
EXTRA_libatomic_la_SOURCES = $(addsuffix _n.c,$(SIZEOBJS))
|
||||
libatomic_la_DEPENDENCIES = $(libatomic_la_LIBADD) $(libatomic_version_dep)
|
||||
|
||||
## And now our custom target patterns that allow us not to have tons of
|
||||
## extra source files hanging about. Unfortunately, the complex relation
|
||||
## between source and object filenames doesn't allow us to add an explicit
|
||||
## dependency here. Fortunately that doesn't matter since auto-generated
|
||||
## dependencies do the job just as well:
|
||||
-include $(wildcard $(DEPDIR)/*.Ppo)
|
||||
|
||||
## Naming pattern: base_n_i_.lo
|
||||
##
|
||||
## N size of data
|
||||
## I IFUNC alternative, index beginning at 1.
|
||||
##
|
||||
## The trailing _ in the output object file name is required to differentiate
|
||||
## these objects from those which should be compiled normally. We can only
|
||||
## have one stem in the implicit rule.
|
||||
|
||||
empty =
|
||||
space = $(empty) $(empty)
|
||||
PAT_SPLIT = $(subst _,$(space),$(*F))
|
||||
PAT_BASE = $(word 1,$(PAT_SPLIT))
|
||||
PAT_N = $(word 2,$(PAT_SPLIT))
|
||||
PAT_S = $(word 3,$(PAT_SPLIT))
|
||||
IFUNC_DEF = -DIFUNC_ALT=$(PAT_S)
|
||||
IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS))
|
||||
|
||||
M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
|
||||
M_SIZE = -DN=$(PAT_N)
|
||||
M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT))
|
||||
M_FILE = $(PAT_BASE)_n.c
|
||||
|
||||
# The lack of explicit dependency on the source file means that VPATH cannot
|
||||
# work properly. Instead, perform this operation by hand. First, collect a
|
||||
# list of all .c files in the search path.
|
||||
all_c_files := $(foreach dir,$(search_path),$(wildcard $(dir)/*.c))
|
||||
|
||||
# Then sort through them to find the one we want, and select the first.
|
||||
M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files)))
|
||||
|
||||
%_.lo: Makefile
|
||||
$(LTCOMPILE) $(M_DEPS) $(M_SIZE) $(M_IFUNC) -c -o $@ $(M_SRC)
|
||||
|
||||
## Include all of the sizes in the "normal" set of compilation flags.
|
||||
libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS)))
|
||||
|
||||
## On a target-specific basis, include alternates to be selected by IFUNC.
|
||||
if HAVE_IFUNC
|
||||
if ARCH_ARM_LINUX
|
||||
IFUNC_OPTIONS = -march=armv7-a -DHAVE_KERNEL64
|
||||
libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
|
||||
libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS))
|
||||
endif
|
||||
if ARCH_I386
|
||||
IFUNC_OPTIONS = -march=i586
|
||||
libatomic_la_LIBADD += $(addsuffix _8_1_.lo,$(SIZEOBJS))
|
||||
endif
|
||||
if ARCH_X86_64
|
||||
IFUNC_OPTIONS = -mcx16
|
||||
libatomic_la_LIBADD += $(addsuffix _16_1_.lo,$(SIZEOBJS))
|
||||
endif
|
||||
endif
|
963
libatomic/Makefile.in
Normal file
963
libatomic/Makefile.in
Normal file
|
@ -0,0 +1,963 @@
|
|||
# Makefile.in generated by automake 1.11.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
target_triplet = @target@
|
||||
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_1 = $(foreach \
|
||||
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ s,$(SIZES),$(addsuffix \
|
||||
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _$(s)_1_.lo,$(SIZEOBJS))) \
|
||||
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ $(addsuffix \
|
||||
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _8_2_.lo,$(SIZEOBJS))
|
||||
@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_2 = $(addsuffix _8_1_.lo,$(SIZEOBJS))
|
||||
@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_3 = $(addsuffix _16_1_.lo,$(SIZEOBJS))
|
||||
subdir = .
|
||||
DIST_COMMON = $(am__configure_deps) $(srcdir)/../config.guess \
|
||||
$(srcdir)/../config.sub $(srcdir)/../depcomp \
|
||||
$(srcdir)/../install-sh $(srcdir)/../ltmain.sh \
|
||||
$(srcdir)/../missing $(srcdir)/../mkinstalldirs \
|
||||
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
||||
$(srcdir)/auto-config.h.in $(top_srcdir)/configure
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
|
||||
$(top_srcdir)/../config/depstand.m4 \
|
||||
$(top_srcdir)/../config/lead-dot.m4 \
|
||||
$(top_srcdir)/../config/multi.m4 \
|
||||
$(top_srcdir)/../config/override.m4 \
|
||||
$(top_srcdir)/../config/stdint.m4 \
|
||||
$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
|
||||
$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
|
||||
CONFIG_HEADER = auto-config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
|
||||
LTLIBRARIES = $(toolexeclib_LTLIBRARIES)
|
||||
am_libatomic_la_OBJECTS = gload.lo gstore.lo gcas.lo gexch.lo \
|
||||
glfree.lo lock.lo init.lo
|
||||
libatomic_la_OBJECTS = $(am_libatomic_la_OBJECTS)
|
||||
libatomic_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(libatomic_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
depcomp = $(SHELL) $(top_srcdir)/../depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
SOURCES = $(libatomic_la_SOURCES) $(EXTRA_libatomic_la_SOURCES)
|
||||
DIST_SOURCES = $(libatomic_la_SOURCES) $(EXTRA_libatomic_la_SOURCES)
|
||||
MULTISRCTOP =
|
||||
MULTIBUILDTOP =
|
||||
MULTIDIRS =
|
||||
MULTISUBDIR =
|
||||
MULTIDO = true
|
||||
MULTICLEAN = true
|
||||
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
|
||||
html-recursive info-recursive install-data-recursive \
|
||||
install-dvi-recursive install-exec-recursive \
|
||||
install-html-recursive install-info-recursive \
|
||||
install-pdf-recursive install-ps-recursive install-recursive \
|
||||
installcheck-recursive installdirs-recursive pdf-recursive \
|
||||
ps-recursive uninstall-recursive
|
||||
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
|
||||
distclean-recursive maintainer-clean-recursive
|
||||
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
|
||||
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
|
||||
distdir dist dist-all distcheck
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
am__remove_distdir = \
|
||||
{ test ! -d "$(distdir)" \
|
||||
|| { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
&& rm -fr "$(distdir)"; }; }
|
||||
am__relativize = \
|
||||
dir0=`pwd`; \
|
||||
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
|
||||
sed_rest='s,^[^/]*/*,,'; \
|
||||
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
|
||||
sed_butlast='s,/*[^/]*$$,,'; \
|
||||
while test -n "$$dir1"; do \
|
||||
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
|
||||
if test "$$first" != "."; then \
|
||||
if test "$$first" = ".."; then \
|
||||
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
|
||||
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
|
||||
else \
|
||||
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
|
||||
if test "$$first2" = "$$first"; then \
|
||||
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
|
||||
else \
|
||||
dir2="../$$dir2"; \
|
||||
fi; \
|
||||
dir0="$$dir0"/"$$first"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
|
||||
done; \
|
||||
reldir="$$dir2"
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
distcleancheck_listfiles = find . -type f -print
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCAS = @CCAS@
|
||||
CCASDEPMODE = @CCASDEPMODE@
|
||||
CCASFLAGS = @CCASFLAGS@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OPT_LDFLAGS = @OPT_LDFLAGS@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PERL = @PERL@
|
||||
RANLIB = @RANLIB@
|
||||
SECTION_LDFLAGS = @SECTION_LDFLAGS@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SIZES = @SIZES@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
XCFLAGS = @XCFLAGS@
|
||||
XLDFLAGS = @XLDFLAGS@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
config_path = @config_path@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
enable_shared = @enable_shared@
|
||||
enable_static = @enable_static@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
libtool_VERSION = @libtool_VERSION@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
multi_basedir = @multi_basedir@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target = @target@
|
||||
target_alias = @target_alias@
|
||||
target_cpu = @target_cpu@
|
||||
target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
toolexecdir = @toolexecdir@
|
||||
toolexeclibdir = @toolexeclibdir@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
ACLOCAL_AMFLAGS = -I .. -I ../config
|
||||
SUBDIRS = testsuite
|
||||
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
|
||||
search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) \
|
||||
$(top_srcdir) $(top_builddir)
|
||||
|
||||
DEFAULT_INCLUDES = $(addprefix -I, $(search_path))
|
||||
AM_CFLAGS = $(XCFLAGS)
|
||||
AM_CCASFLAGS = $(XCFLAGS)
|
||||
AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
|
||||
toolexeclib_LTLIBRARIES = libatomic.la
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_FALSE@libatomic_version_script =
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic_version_script = -Wl,--version-script,$(top_srcdir)/libatomic.map
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic_version_script = -Wl,-M,libatomic.map-sun
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_FALSE@libatomic_version_dep =
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic_version_dep = $(top_srcdir)/libatomic.map
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic_version_dep = libatomic.map-sun
|
||||
libatomic_version_info = -version-info $(libtool_VERSION)
|
||||
libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script)
|
||||
libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c
|
||||
SIZEOBJS = load store cas exch fadd fsub fand fior fxor fnand tas
|
||||
EXTRA_libatomic_la_SOURCES = $(addsuffix _n.c,$(SIZEOBJS))
|
||||
libatomic_la_DEPENDENCIES = $(libatomic_la_LIBADD) $(libatomic_version_dep)
|
||||
empty =
|
||||
space = $(empty) $(empty)
|
||||
PAT_SPLIT = $(subst _,$(space),$(*F))
|
||||
PAT_BASE = $(word 1,$(PAT_SPLIT))
|
||||
PAT_N = $(word 2,$(PAT_SPLIT))
|
||||
PAT_S = $(word 3,$(PAT_SPLIT))
|
||||
IFUNC_DEF = -DIFUNC_ALT=$(PAT_S)
|
||||
IFUNC_OPT = $(word $(PAT_S),$(IFUNC_OPTIONS))
|
||||
M_DEPS = -MT $@ -MD -MP -MF $(DEPDIR)/$(@F).Ppo
|
||||
M_SIZE = -DN=$(PAT_N)
|
||||
M_IFUNC = $(if $(PAT_S),$(IFUNC_DEF) $(IFUNC_OPT))
|
||||
M_FILE = $(PAT_BASE)_n.c
|
||||
|
||||
# The lack of explicit dependency on the source file means that VPATH cannot
|
||||
# work properly. Instead, perform this operation by hand. First, collect a
|
||||
# list of all .c files in the search path.
|
||||
all_c_files := $(foreach dir,$(search_path),$(wildcard $(dir)/*.c))
|
||||
|
||||
# Then sort through them to find the one we want, and select the first.
|
||||
M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files)))
|
||||
libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \
|
||||
_$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \
|
||||
$(am__append_3)
|
||||
@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a -DHAVE_KERNEL64
|
||||
@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
|
||||
@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16
|
||||
all: auto-config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
am--refresh:
|
||||
@:
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
auto-config.h: stamp-h1
|
||||
@if test ! -f $@; then \
|
||||
rm -f stamp-h1; \
|
||||
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
|
||||
else :; fi
|
||||
|
||||
stamp-h1: $(srcdir)/auto-config.h.in $(top_builddir)/config.status
|
||||
@rm -f stamp-h1
|
||||
cd $(top_builddir) && $(SHELL) ./config.status auto-config.h
|
||||
$(srcdir)/auto-config.h.in: $(am__configure_deps)
|
||||
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
|
||||
rm -f stamp-h1
|
||||
touch $@
|
||||
|
||||
distclean-hdr:
|
||||
-rm -f auto-config.h stamp-h1
|
||||
install-toolexeclibLTLIBRARIES: $(toolexeclib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(toolexeclibdir)" || $(MKDIR_P) "$(DESTDIR)$(toolexeclibdir)"
|
||||
@list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \
|
||||
list2=; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
list2="$$list2 $$p"; \
|
||||
else :; fi; \
|
||||
done; \
|
||||
test -z "$$list2" || { \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(toolexeclibdir)'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(toolexeclibdir)"; \
|
||||
}
|
||||
|
||||
uninstall-toolexeclibLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(toolexeclib_LTLIBRARIES)'; test -n "$(toolexeclibdir)" || list=; \
|
||||
for p in $$list; do \
|
||||
$(am__strip_dir) \
|
||||
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(toolexeclibdir)/$$f'"; \
|
||||
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(toolexeclibdir)/$$f"; \
|
||||
done
|
||||
|
||||
clean-toolexeclibLTLIBRARIES:
|
||||
-test -z "$(toolexeclib_LTLIBRARIES)" || rm -f $(toolexeclib_LTLIBRARIES)
|
||||
@list='$(toolexeclib_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libatomic.la: $(libatomic_la_OBJECTS) $(libatomic_la_DEPENDENCIES)
|
||||
$(libatomic_la_LINK) -rpath $(toolexeclibdir) $(libatomic_la_OBJECTS) $(libatomic_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcas.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gexch.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glfree.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gload.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gstore.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/init.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lock.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
|
||||
# GNU Make needs to see an explicit $(MAKE) variable in the command it
|
||||
# runs to enable its job server during parallel builds. Hence the
|
||||
# comments below.
|
||||
all-multi:
|
||||
$(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE)
|
||||
install-multi:
|
||||
$(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do # $(MAKE)
|
||||
|
||||
mostlyclean-multi:
|
||||
$(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean # $(MAKE)
|
||||
clean-multi:
|
||||
$(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean # $(MAKE)
|
||||
distclean-multi:
|
||||
$(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE)
|
||||
maintainer-clean-multi:
|
||||
$(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean # $(MAKE)
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
$(RECURSIVE_TARGETS):
|
||||
@fail= failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
$(RECURSIVE_CLEAN_TARGETS):
|
||||
@fail= failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
case "$@" in \
|
||||
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
|
||||
*) list='$(SUBDIRS)' ;; \
|
||||
esac; \
|
||||
rev=''; for subdir in $$list; do \
|
||||
if test "$$subdir" = "."; then :; else \
|
||||
rev="$$subdir $$rev"; \
|
||||
fi; \
|
||||
done; \
|
||||
rev="$$rev ."; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
ctags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
|
||||
done
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) auto-config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
|
||||
include_option=--etags-include; \
|
||||
empty_fix=.; \
|
||||
else \
|
||||
include_option=--include; \
|
||||
empty_fix=; \
|
||||
fi; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test ! -f $$subdir/TAGS || \
|
||||
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS) auto-config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) auto-config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) auto-config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(am__remove_distdir)
|
||||
test -d "$(distdir)" || mkdir "$(distdir)"
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d "$(distdir)/$$subdir" \
|
||||
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
|
||||
$(am__relativize); \
|
||||
new_distdir=$$reldir; \
|
||||
dir1=$$subdir; dir2="$(top_distdir)"; \
|
||||
$(am__relativize); \
|
||||
new_top_distdir=$$reldir; \
|
||||
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
|
||||
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
|
||||
($(am__cd) $$subdir && \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
top_distdir="$$new_top_distdir" \
|
||||
distdir="$$new_distdir" \
|
||||
am__remove_distdir=: \
|
||||
am__skip_length_check=: \
|
||||
am__skip_mode_fix=: \
|
||||
distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
-test -n "$(am__skip_mode_fix)" \
|
||||
|| find "$(distdir)" -type d ! -perm -755 \
|
||||
-exec chmod u+rwx,go+rx {} \; -o \
|
||||
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||
|| chmod -R a+r "$(distdir)"
|
||||
dist-gzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-bzip2: distdir
|
||||
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-lzma: distdir
|
||||
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-shar: distdir
|
||||
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-zip: distdir
|
||||
-rm -f $(distdir).zip
|
||||
zip -rq $(distdir).zip $(distdir)
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist dist-all: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
case '$(DIST_ARCHIVES)' in \
|
||||
*.tar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
|
||||
*.tar.bz2*) \
|
||||
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.lzma*) \
|
||||
lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
|
||||
*.tar.xz*) \
|
||||
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
|
||||
*.tar.Z*) \
|
||||
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
*.shar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
|
||||
*.zip*) \
|
||||
unzip $(distdir).zip ;;\
|
||||
esac
|
||||
chmod -R a-w $(distdir); chmod a+w $(distdir)
|
||||
mkdir $(distdir)/_build
|
||||
mkdir $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build \
|
||||
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
|
||||
distuninstallcheck \
|
||||
&& chmod -R a-w "$$dc_install_base" \
|
||||
&& ({ \
|
||||
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
|
||||
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
|
||||
} || { rm -rf "$$dc_destdir"; exit 1; }) \
|
||||
&& rm -rf "$$dc_destdir" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||
&& rm -rf $(DIST_ARCHIVES) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
|
||||
&& cd "$$am__cwd" \
|
||||
|| exit 1
|
||||
$(am__remove_distdir)
|
||||
@(echo "$(distdir) archives ready for distribution: "; \
|
||||
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
|
||||
distuninstallcheck:
|
||||
@$(am__cd) '$(distuninstallcheck_dir)' \
|
||||
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|
||||
|| { echo "ERROR: files left after uninstall:" ; \
|
||||
if test -n "$(DESTDIR)"; then \
|
||||
echo " (check DESTDIR support)"; \
|
||||
fi ; \
|
||||
$(distuninstallcheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
distcleancheck: distclean
|
||||
@if test '$(srcdir)' = . ; then \
|
||||
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left in build directory after distclean:" ; \
|
||||
$(distcleancheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
all-am: Makefile $(LTLIBRARIES) all-multi auto-config.h
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
for dir in "$(DESTDIR)$(toolexeclibdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-recursive
|
||||
install-exec: install-exec-recursive
|
||||
install-data: install-data-recursive
|
||||
uninstall: uninstall-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-multi clean-recursive
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-toolexeclibLTLIBRARIES \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-multi distclean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-recursive
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-recursive
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-recursive
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-recursive
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-multi install-toolexeclibLTLIBRARIES
|
||||
|
||||
install-html: install-html-recursive
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-recursive
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-recursive
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-recursive
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-multi maintainer-clean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-multi mostlyclean-recursive
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-recursive
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-recursive
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-toolexeclibLTLIBRARIES
|
||||
|
||||
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all all-multi \
|
||||
clean-multi ctags-recursive distclean-multi install-am \
|
||||
install-multi install-strip maintainer-clean-multi \
|
||||
mostlyclean-multi tags-recursive
|
||||
|
||||
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
|
||||
all all-am all-multi am--refresh check check-am clean \
|
||||
clean-generic clean-libtool clean-multi \
|
||||
clean-toolexeclibLTLIBRARIES ctags ctags-recursive dist \
|
||||
dist-all dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ \
|
||||
dist-xz dist-zip distcheck distclean distclean-compile \
|
||||
distclean-generic distclean-hdr distclean-libtool \
|
||||
distclean-multi distclean-tags distcleancheck distdir \
|
||||
distuninstallcheck dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-multi install-pdf install-pdf-am install-ps \
|
||||
install-ps-am install-strip install-toolexeclibLTLIBRARIES \
|
||||
installcheck installcheck-am installdirs installdirs-am \
|
||||
maintainer-clean maintainer-clean-generic \
|
||||
maintainer-clean-multi mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool mostlyclean-multi pdf \
|
||||
pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
|
||||
uninstall-toolexeclibLTLIBRARIES
|
||||
|
||||
|
||||
vpath % $(strip $(search_path))
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libatomic.map-sun : $(top_srcdir)/libatomic.map \
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(top_srcdir)/../contrib/make_sunver.pl \
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(libatomic_la_OBJECTS) $(libatomic_la_LIBADD)
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ perl $(top_srcdir)/../contrib/make_sunver.pl \
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(top_srcdir)/libatomic.map \
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(libatomic_la_OBJECTS:%.lo=.libs/%.o) \
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ `echo $(libatomic_la_LIBADD) | \
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
|
||||
@LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ > $@ || (rm -f $@ ; exit 1)
|
||||
|
||||
-include $(wildcard $(DEPDIR)/*.Ppo)
|
||||
|
||||
%_.lo: Makefile
|
||||
$(LTCOMPILE) $(M_DEPS) $(M_SIZE) $(M_IFUNC) -c -o $@ $(M_SRC)
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
637
libatomic/acinclude.m4
Normal file
637
libatomic/acinclude.m4
Normal file
|
@ -0,0 +1,637 @@
|
|||
dnl
|
||||
dnl Unconditionally define a preprocessor macro, translating the shell
|
||||
dnl macro from yes/no to 1/0.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_DEFINE_YESNO], [
|
||||
yesno=`echo $2 | tr 'yesno' '1 0 '`
|
||||
AC_DEFINE_UNQUOTED([$1], $yesno, [$3])
|
||||
])
|
||||
dnl
|
||||
dnl Iterate over all of the modes we're prepared to check.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_FORALL_MODES],
|
||||
[$1(QI,1)
|
||||
$1(HI,2)
|
||||
$1(SI,4)
|
||||
$1(DI,8)
|
||||
$1(TI,16)]
|
||||
)
|
||||
dnl
|
||||
dnl Check for builtin types by mode.
|
||||
dnl
|
||||
dnl A less interesting of size checking than autoconf normally provides.
|
||||
dnl We know that gcc always provides <stdint.h>, but we don't often
|
||||
dnl provide a builtin type for TImode.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_HAVE_INT_MODE],[
|
||||
AC_CACHE_CHECK([for $2 byte integer],[libat_cv_have_mode_$1],
|
||||
[AC_COMPILE_IFELSE([int x __attribute__((mode($1)));],
|
||||
[libat_cv_have_mode_$1=yes],[libat_cv_have_mode_$1=no])])
|
||||
LIBAT_DEFINE_YESNO([HAVE_INT$2], [$libat_cv_have_mode_$1],
|
||||
[Have support for $2 byte integers.])
|
||||
if test x$libat_cv_have_mode_$1 = xyes; then
|
||||
SIZES="$SIZES $2"
|
||||
fi
|
||||
])
|
||||
dnl
|
||||
dnl Check for atomic builtins.
|
||||
dnl See:
|
||||
dnl http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
|
||||
dnl
|
||||
dnl This checks to see if the host supports the compiler-generated
|
||||
dnl builtins for atomic operations for various integral sizes.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_TEST_ATOMIC_INIT],[
|
||||
# Do link tests if possible, instead asm tests, limited to some platforms
|
||||
# see discussion in PR target/40134, PR libstdc++/40133 and the thread
|
||||
# starting at http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00322.html
|
||||
atomic_builtins_link_tests=no
|
||||
if test x$gcc_no_link != xyes; then
|
||||
# Can do link tests. Limit to some tested platforms
|
||||
case "$host" in
|
||||
*-*-linux* | *-*-uclinux* | *-*-kfreebsd*-gnu | *-*-gnu*)
|
||||
atomic_builtins_link_tests=yes
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
AC_DEFUN([LIBAT_TEST_ATOMIC_BUILTIN],[
|
||||
AC_CACHE_CHECK([$1],[$2],[
|
||||
AC_LANG_CONFTEST([AC_LANG_PROGRAM([],[$3])])
|
||||
if test x$atomic_builtins_link_tests = xyes; then
|
||||
if AC_TRY_EVAL(ac_link); then
|
||||
eval $2=yes
|
||||
else
|
||||
eval $2=no
|
||||
fi
|
||||
else
|
||||
old_CFLAGS="$CFLAGS"
|
||||
# Compile unoptimized.
|
||||
CFLAGS='-O0 -S'
|
||||
if AC_TRY_EVAL(ac_compile); then
|
||||
if grep __atomic_ conftest.s >/dev/null 2>&1 ; then
|
||||
eval $2=no
|
||||
else
|
||||
eval $2=yes
|
||||
fi
|
||||
fi
|
||||
CFLAGS="$old_CFLAGS"
|
||||
fi
|
||||
rm -f conftest*
|
||||
])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Test if we have __atomic_load and __atomic_store for mode $1, size $2
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_HAVE_ATOMIC_LOADSTORE],[
|
||||
LIBAT_TEST_ATOMIC_BUILTIN([for __atomic_load/store for size $2],
|
||||
[libat_cv_have_at_ldst_$2],
|
||||
[typedef int T __attribute__((mode($1)));
|
||||
T *x; volatile T sink; asm("" : "=g"(x));
|
||||
sink = __atomic_load_n(x, 0);
|
||||
__atomic_store_n(x, sink, 0);])
|
||||
LIBAT_DEFINE_YESNO([HAVE_ATOMIC_LDST_$2], [$libat_cv_have_at_ldst_$2],
|
||||
[Have __atomic_load/store for $2 byte integers.])
|
||||
AH_BOTTOM([#define MAYBE_HAVE_ATOMIC_LDST_$2 HAVE_ATOMIC_LDST_$2])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Test if we have __atomic_test_and_set for mode $1, size $2
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_HAVE_ATOMIC_TAS],[
|
||||
LIBAT_TEST_ATOMIC_BUILTIN([for __atomic_test_and_set for size $2],
|
||||
[libat_cv_have_at_tas_$2],
|
||||
[typedef int T __attribute__((mode($1))); T *x; asm("" : "=g"(x));
|
||||
__atomic_test_and_set(x, 0);])
|
||||
LIBAT_DEFINE_YESNO([HAVE_ATOMIC_TAS_$2], [$libat_cv_have_at_tas_$2],
|
||||
[Have __atomic_test_and_set for $2 byte integers.])
|
||||
AH_BOTTOM([#define MAYBE_HAVE_ATOMIC_TAS_$2 HAVE_ATOMIC_TAS_$2])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Test if we have __atomic_exchange for mode $1, size $2
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_HAVE_ATOMIC_EXCHANGE],[
|
||||
LIBAT_TEST_ATOMIC_BUILTIN([for __atomic_exchange for size $2],
|
||||
[libat_cv_have_at_exch_$2],
|
||||
[typedef int T __attribute__((mode($1))); T *x; asm("" : "=g"(x));
|
||||
__atomic_exchange_n(x, 0, 0);])
|
||||
LIBAT_DEFINE_YESNO([HAVE_ATOMIC_EXCHANGE_$2], [$libat_cv_have_at_exch_$2],
|
||||
[Have __atomic_exchange for $2 byte integers.])
|
||||
AH_BOTTOM([#define MAYBE_HAVE_ATOMIC_EXCHANGE_$2 HAVE_ATOMIC_EXCHANGE_$2])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Test if we have __atomic_compare_exchange for mode $1, size $2
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_HAVE_ATOMIC_CAS],[
|
||||
LIBAT_TEST_ATOMIC_BUILTIN([for __atomic_compare_exchange for size $2],
|
||||
[libat_cv_have_at_cas_$2],
|
||||
[typedef int T __attribute__((mode($1))); T *x, *y;
|
||||
asm("" : "=g"(x), "=g"(y));
|
||||
__atomic_compare_exchange_n(x, y, 0, 0, 0, 0);])
|
||||
LIBAT_DEFINE_YESNO([HAVE_ATOMIC_CAS_$2], [$libat_cv_have_at_cas_$2],
|
||||
[Have __atomic_compare_exchange for $2 byte integers.])
|
||||
AH_BOTTOM([#define MAYBE_HAVE_ATOMIC_CAS_$2 HAVE_ATOMIC_CAS_$2])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Test if we have __atomic_fetch_add for mode $1, size $2
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_HAVE_ATOMIC_FETCH_ADD],[
|
||||
LIBAT_TEST_ATOMIC_BUILTIN([for __atomic_fetch_add for size $2],
|
||||
[libat_cv_have_at_fadd_$2],
|
||||
[typedef int T __attribute__((mode($1))); T *x, y;
|
||||
asm("" : "=g"(x), "=g"(y));
|
||||
__atomic_fetch_add (x, y, 0);
|
||||
__atomic_add_fetch (x, y, 0);])
|
||||
LIBAT_DEFINE_YESNO([HAVE_ATOMIC_FETCH_ADD_$2], [$libat_cv_have_at_fadd_$2],
|
||||
[Have __atomic_fetch_add for $2 byte integers.])
|
||||
AH_BOTTOM([#define MAYBE_HAVE_ATOMIC_FETCH_ADD_$2 HAVE_ATOMIC_FETCH_ADD_$2])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Test if we have __atomic_fetch_op for all op for mode $1, size $2
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_HAVE_ATOMIC_FETCH_OP],[
|
||||
LIBAT_TEST_ATOMIC_BUILTIN([for __atomic_fetch_op for size $2],
|
||||
[libat_cv_have_at_fop_$2],
|
||||
[typedef int T __attribute__((mode($1))); T *x, y;
|
||||
asm("" : "=g"(x), "=g"(y));
|
||||
__atomic_fetch_add (x, y, 0); __atomic_add_fetch (x, y, 0);
|
||||
__atomic_fetch_sub (x, y, 0); __atomic_sub_fetch (x, y, 0);
|
||||
__atomic_fetch_and (x, y, 0); __atomic_and_fetch (x, y, 0);
|
||||
__atomic_fetch_nand (x, y, 0); __atomic_nand_fetch (x, y, 0);
|
||||
__atomic_fetch_xor (x, y, 0); __atomic_xor_fetch (x, y, 0);
|
||||
__atomic_fetch_or (x, y, 0); __atomic_or_fetch (x, y, 0); ])
|
||||
LIBAT_DEFINE_YESNO([HAVE_ATOMIC_FETCH_OP_$2], [$libat_cv_have_at_fop_$2],
|
||||
[Have __atomic_fetch_op for all op for $2 byte integers.])
|
||||
AH_BOTTOM([#define MAYBE_HAVE_ATOMIC_FETCH_OP_$2 HAVE_ATOMIC_FETCH_OP_$2])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Test for the size of the target word.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_WORDSIZE],[
|
||||
AC_CACHE_CHECK([for the word size],[libat_cv_wordsize],
|
||||
[AC_COMPUTE_INT(libat_cv_wordsize,
|
||||
[sizeof(word)], [typedef int word __attribute__((mode(word)));],
|
||||
AC_ERROR([Could not determine word size.]))])
|
||||
AC_DEFINE_UNQUOTED(WORDSIZE, $libat_cv_wordsize,
|
||||
[The word size in bytes of the machine.])
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Check whether the target supports ifuncs.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_CHECK_IFUNC], [
|
||||
AC_CACHE_CHECK([whether the target supports funcs], libat_cv_have_ifunc, [
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
AC_TRY_LINK([
|
||||
int foo_alt(void) { return 0; }
|
||||
void *foo_sel(void) { return foo_alt; }
|
||||
int foo(void) __attribute__((ifunc("foo_sel")));],
|
||||
[return foo();], libat_cv_have_ifunc=yes, libat_cv_have_ifunc=no)])
|
||||
LIBAT_DEFINE_YESNO([HAVE_IFUNC], [$libat_cv_have_ifunc],
|
||||
[Define to 1 if the target supports __attribute__((ifunc(...))).])
|
||||
])
|
||||
|
||||
dnl ----------------------------------------------------------------------
|
||||
dnl This whole bit snagged from libitm.
|
||||
|
||||
dnl Check whether the target supports hidden visibility.
|
||||
AC_DEFUN([LIBAT_CHECK_ATTRIBUTE_VISIBILITY], [
|
||||
AC_CACHE_CHECK([whether the target supports hidden visibility],
|
||||
libat_cv_have_attribute_visibility, [
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
AC_TRY_COMPILE([void __attribute__((visibility("hidden"))) foo(void) { }],
|
||||
[], libat_cv_have_attribute_visibility=yes,
|
||||
libat_cv_have_attribute_visibility=no)
|
||||
CFLAGS="$save_CFLAGS"])
|
||||
if test $libat_cv_have_attribute_visibility = yes; then
|
||||
AC_DEFINE(HAVE_ATTRIBUTE_VISIBILITY, 1,
|
||||
[Define to 1 if the target supports __attribute__((visibility(...))).])
|
||||
fi])
|
||||
|
||||
dnl Check whether the target supports dllexport
|
||||
AC_DEFUN([LIBAT_CHECK_ATTRIBUTE_DLLEXPORT], [
|
||||
AC_CACHE_CHECK([whether the target supports dllexport],
|
||||
libat_cv_have_attribute_dllexport, [
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
AC_TRY_COMPILE([void __attribute__((dllexport)) foo(void) { }],
|
||||
[], libat_cv_have_attribute_dllexport=yes,
|
||||
libat_cv_have_attribute_dllexport=no)
|
||||
CFLAGS="$save_CFLAGS"])
|
||||
if test $libat_cv_have_attribute_dllexport = yes; then
|
||||
AC_DEFINE(HAVE_ATTRIBUTE_DLLEXPORT, 1,
|
||||
[Define to 1 if the target supports __attribute__((dllexport)).])
|
||||
fi])
|
||||
|
||||
dnl Check whether the target supports symbol aliases.
|
||||
AC_DEFUN([LIBAT_CHECK_ATTRIBUTE_ALIAS], [
|
||||
AC_CACHE_CHECK([whether the target supports symbol aliases],
|
||||
libat_cv_have_attribute_alias, [
|
||||
AC_TRY_LINK([
|
||||
void foo(void) { }
|
||||
extern void bar(void) __attribute__((alias("foo")));],
|
||||
[bar();], libat_cv_have_attribute_alias=yes, libat_cv_have_attribute_alias=no)])
|
||||
if test $libat_cv_have_attribute_alias = yes; then
|
||||
AC_DEFINE(HAVE_ATTRIBUTE_ALIAS, 1,
|
||||
[Define to 1 if the target supports __attribute__((alias(...))).])
|
||||
fi])
|
||||
|
||||
dnl ----------------------------------------------------------------------
|
||||
dnl This whole bit snagged from libstdc++-v3.
|
||||
|
||||
dnl
|
||||
dnl LIBAT_ENABLE
|
||||
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING)
|
||||
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, permit a|b|c)
|
||||
dnl (FEATURE, DEFAULT, HELP-ARG, HELP-STRING, SHELL-CODE-HANDLER)
|
||||
dnl
|
||||
dnl See docs/html/17_intro/configury.html#enable for documentation.
|
||||
dnl
|
||||
m4_define([LIBAT_ENABLE],[dnl
|
||||
m4_define([_g_switch],[--enable-$1])dnl
|
||||
m4_define([_g_help],[AC_HELP_STRING(_g_switch$3,[$4 @<:@default=$2@:>@])])dnl
|
||||
AC_ARG_ENABLE($1,_g_help,
|
||||
m4_bmatch([$5],
|
||||
[^permit ],
|
||||
[[
|
||||
case "$enableval" in
|
||||
m4_bpatsubst([$5],[permit ])) ;;
|
||||
*) AC_MSG_ERROR(Unknown argument to enable/disable $1) ;;
|
||||
dnl Idea for future: generate a URL pointing to
|
||||
dnl "onlinedocs/configopts.html#whatever"
|
||||
esac
|
||||
]],
|
||||
[^$],
|
||||
[[
|
||||
case "$enableval" in
|
||||
yes|no) ;;
|
||||
*) AC_MSG_ERROR(Argument to enable/disable $1 must be yes or no) ;;
|
||||
esac
|
||||
]],
|
||||
[[$5]]),
|
||||
[enable_]m4_bpatsubst([$1],-,_)[=][$2])
|
||||
m4_undefine([_g_switch])dnl
|
||||
m4_undefine([_g_help])dnl
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
|
||||
dnl the native linker is in use, all variables will be defined to something
|
||||
dnl safe (like an empty string).
|
||||
dnl
|
||||
dnl Defines:
|
||||
dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
|
||||
dnl OPT_LDFLAGS='-Wl,-O1' if possible
|
||||
dnl LD (as a side effect of testing)
|
||||
dnl Sets:
|
||||
dnl with_gnu_ld
|
||||
dnl libat_ld_is_gold (possibly)
|
||||
dnl libat_gnu_ld_version (possibly)
|
||||
dnl
|
||||
dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
|
||||
dnl set libat_gnu_ld_version to 12345. Zeros cause problems.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
|
||||
# If we're not using GNU ld, then there's no point in even trying these
|
||||
# tests. Check for that first. We should have already tested for gld
|
||||
# by now (in libtool), but require it now just to be safe...
|
||||
test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
|
||||
test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
|
||||
AC_REQUIRE([AC_PROG_LD])
|
||||
AC_REQUIRE([AC_PROG_AWK])
|
||||
|
||||
# The name set by libtool depends on the version of libtool. Shame on us
|
||||
# for depending on an impl detail, but c'est la vie. Older versions used
|
||||
# ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
|
||||
# top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
|
||||
# makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
|
||||
# set (hence we're using an older libtool), then set it.
|
||||
if test x${with_gnu_ld+set} != xset; then
|
||||
if test x${ac_cv_prog_gnu_ld+set} != xset; then
|
||||
# We got through "ac_require(ac_prog_ld)" and still not set? Huh?
|
||||
with_gnu_ld=no
|
||||
else
|
||||
with_gnu_ld=$ac_cv_prog_gnu_ld
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start by getting the version number. I think the libtool test already
|
||||
# does some of this, but throws away the result.
|
||||
libat_ld_is_gold=no
|
||||
if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
|
||||
libat_ld_is_gold=yes
|
||||
fi
|
||||
changequote(,)
|
||||
ldver=`$LD --version 2>/dev/null |
|
||||
sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
|
||||
changequote([,])
|
||||
libat_gnu_ld_version=`echo $ldver | \
|
||||
$AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
|
||||
|
||||
# Set --gc-sections.
|
||||
if test "$with_gnu_ld" = "notbroken"; then
|
||||
# GNU ld it is! Joy and bunny rabbits!
|
||||
|
||||
# All these tests are for C++; save the language and the compiler flags.
|
||||
# Need to do this so that g++ won't try to link in libstdc++
|
||||
ac_test_CFLAGS="${CFLAGS+set}"
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS='-x c++ -Wl,--gc-sections'
|
||||
|
||||
# Check for -Wl,--gc-sections
|
||||
# XXX This test is broken at the moment, as symbols required for linking
|
||||
# are now in libsupc++ (not built yet). In addition, this test has
|
||||
# cored on solaris in the past. In addition, --gc-sections doesn't
|
||||
# really work at the moment (keeps on discarding used sections, first
|
||||
# .eh_frame and now some of the glibc sections for iconv).
|
||||
# Bzzzzt. Thanks for playing, maybe next time.
|
||||
AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
|
||||
AC_TRY_RUN([
|
||||
int main(void)
|
||||
{
|
||||
try { throw 1; }
|
||||
catch (...) { };
|
||||
return 0;
|
||||
}
|
||||
], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
|
||||
if test "$ac_test_CFLAGS" = set; then
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
else
|
||||
# this is the suspicious part
|
||||
CFLAGS=''
|
||||
fi
|
||||
if test "$ac_sectionLDflags" = "yes"; then
|
||||
SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
|
||||
fi
|
||||
AC_MSG_RESULT($ac_sectionLDflags)
|
||||
fi
|
||||
|
||||
# Set linker optimization flags.
|
||||
if test x"$with_gnu_ld" = x"yes"; then
|
||||
OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
|
||||
fi
|
||||
|
||||
AC_SUBST(SECTION_LDFLAGS)
|
||||
AC_SUBST(OPT_LDFLAGS)
|
||||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl If GNU ld is in use, check to see if tricky linker opts can be used. If
|
||||
dnl the native linker is in use, all variables will be defined to something
|
||||
dnl safe (like an empty string).
|
||||
dnl
|
||||
dnl Defines:
|
||||
dnl SECTION_LDFLAGS='-Wl,--gc-sections' if possible
|
||||
dnl OPT_LDFLAGS='-Wl,-O1' if possible
|
||||
dnl LD (as a side effect of testing)
|
||||
dnl Sets:
|
||||
dnl with_gnu_ld
|
||||
dnl libat_ld_is_gold (possibly)
|
||||
dnl libat_gnu_ld_version (possibly)
|
||||
dnl
|
||||
dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
|
||||
dnl set libat_gnu_ld_version to 12345. Zeros cause problems.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_CHECK_LINKER_FEATURES], [
|
||||
# If we're not using GNU ld, then there's no point in even trying these
|
||||
# tests. Check for that first. We should have already tested for gld
|
||||
# by now (in libtool), but require it now just to be safe...
|
||||
test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
|
||||
test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
|
||||
AC_REQUIRE([AC_PROG_LD])
|
||||
AC_REQUIRE([AC_PROG_AWK])
|
||||
|
||||
# The name set by libtool depends on the version of libtool. Shame on us
|
||||
# for depending on an impl detail, but c'est la vie. Older versions used
|
||||
# ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
|
||||
# top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
|
||||
# makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
|
||||
# set (hence we're using an older libtool), then set it.
|
||||
if test x${with_gnu_ld+set} != xset; then
|
||||
if test x${ac_cv_prog_gnu_ld+set} != xset; then
|
||||
# We got through "ac_require(ac_prog_ld)" and still not set? Huh?
|
||||
with_gnu_ld=no
|
||||
else
|
||||
with_gnu_ld=$ac_cv_prog_gnu_ld
|
||||
fi
|
||||
fi
|
||||
|
||||
# Start by getting the version number. I think the libtool test already
|
||||
# does some of this, but throws away the result.
|
||||
libat_ld_is_gold=no
|
||||
if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
|
||||
libat_ld_is_gold=yes
|
||||
fi
|
||||
changequote(,)
|
||||
ldver=`$LD --version 2>/dev/null |
|
||||
sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
|
||||
changequote([,])
|
||||
libat_gnu_ld_version=`echo $ldver | \
|
||||
$AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
|
||||
|
||||
# Set --gc-sections.
|
||||
if test "$with_gnu_ld" = "notbroken"; then
|
||||
# GNU ld it is! Joy and bunny rabbits!
|
||||
|
||||
# All these tests are for C++; save the language and the compiler flags.
|
||||
# Need to do this so that g++ won't try to link in libstdc++
|
||||
ac_test_CFLAGS="${CFLAGS+set}"
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS='-x c++ -Wl,--gc-sections'
|
||||
|
||||
# Check for -Wl,--gc-sections
|
||||
# XXX This test is broken at the moment, as symbols required for linking
|
||||
# are now in libsupc++ (not built yet). In addition, this test has
|
||||
# cored on solaris in the past. In addition, --gc-sections doesn't
|
||||
# really work at the moment (keeps on discarding used sections, first
|
||||
# .eh_frame and now some of the glibc sections for iconv).
|
||||
# Bzzzzt. Thanks for playing, maybe next time.
|
||||
AC_MSG_CHECKING([for ld that supports -Wl,--gc-sections])
|
||||
AC_TRY_RUN([
|
||||
int main(void)
|
||||
{
|
||||
try { throw 1; }
|
||||
catch (...) { };
|
||||
return 0;
|
||||
}
|
||||
], [ac_sectionLDflags=yes],[ac_sectionLDflags=no], [ac_sectionLDflags=yes])
|
||||
if test "$ac_test_CFLAGS" = set; then
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
else
|
||||
# this is the suspicious part
|
||||
CFLAGS=''
|
||||
fi
|
||||
if test "$ac_sectionLDflags" = "yes"; then
|
||||
SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
|
||||
fi
|
||||
AC_MSG_RESULT($ac_sectionLDflags)
|
||||
fi
|
||||
|
||||
# Set linker optimization flags.
|
||||
if test x"$with_gnu_ld" = x"yes"; then
|
||||
OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
|
||||
fi
|
||||
|
||||
AC_SUBST(SECTION_LDFLAGS)
|
||||
AC_SUBST(OPT_LDFLAGS)
|
||||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Add version tags to symbols in shared library (or not), additionally
|
||||
dnl marking other symbols as private/local (or not).
|
||||
dnl
|
||||
dnl --enable-symvers=style adds a version script to the linker call when
|
||||
dnl creating the shared library. The choice of version script is
|
||||
dnl controlled by 'style'.
|
||||
dnl --disable-symvers does not.
|
||||
dnl + Usage: LIBAT_ENABLE_SYMVERS[(DEFAULT)]
|
||||
dnl Where DEFAULT is either 'yes' or 'no'. Passing `yes' tries to
|
||||
dnl choose a default style based on linker characteristics. Passing
|
||||
dnl 'no' disables versioning.
|
||||
dnl
|
||||
AC_DEFUN([LIBAT_ENABLE_SYMVERS], [
|
||||
|
||||
LIBAT_ENABLE(symvers,yes,[=STYLE],
|
||||
[enables symbol versioning of the shared library],
|
||||
[permit yes|no|gnu*|sun])
|
||||
|
||||
# If we never went through the LIBAT_CHECK_LINKER_FEATURES macro, then we
|
||||
# don't know enough about $LD to do tricks...
|
||||
AC_REQUIRE([LIBAT_CHECK_LINKER_FEATURES])
|
||||
|
||||
# Turn a 'yes' into a suitable default.
|
||||
if test x$enable_symvers = xyes ; then
|
||||
# FIXME The following test is too strict, in theory.
|
||||
if test $enable_shared = no || test "x$LD" = x; then
|
||||
enable_symvers=no
|
||||
else
|
||||
if test $with_gnu_ld = yes ; then
|
||||
enable_symvers=gnu
|
||||
else
|
||||
case ${target_os} in
|
||||
# Sun symbol versioning exists since Solaris 2.5.
|
||||
solaris2.[[5-9]]* | solaris2.1[[0-9]]*)
|
||||
enable_symvers=sun ;;
|
||||
*)
|
||||
enable_symvers=no ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if 'sun' was requested on non-Solaris 2 platforms.
|
||||
if test x$enable_symvers = xsun ; then
|
||||
case ${target_os} in
|
||||
solaris2*)
|
||||
# All fine.
|
||||
;;
|
||||
*)
|
||||
# Unlikely to work.
|
||||
AC_MSG_WARN([=== You have requested Sun symbol versioning, but])
|
||||
AC_MSG_WARN([=== you are not targetting Solaris 2.])
|
||||
AC_MSG_WARN([=== Symbol versioning will be disabled.])
|
||||
enable_symvers=no
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Check to see if libgcc_s exists, indicating that shared libgcc is possible.
|
||||
if test $enable_symvers != no; then
|
||||
AC_MSG_CHECKING([for shared libgcc])
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS=' -lgcc_s'
|
||||
AC_TRY_LINK(, [return 0;], libat_shared_libgcc=yes, libat_shared_libgcc=no)
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
if test $libat_shared_libgcc = no; then
|
||||
cat > conftest.c <<EOF
|
||||
int main (void) { return 0; }
|
||||
EOF
|
||||
changequote(,)dnl
|
||||
libat_libgcc_s_suffix=`${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
|
||||
-shared -shared-libgcc -o conftest.so \
|
||||
conftest.c -v 2>&1 >/dev/null \
|
||||
| sed -n 's/^.* -lgcc_s\([^ ]*\) .*$/\1/p'`
|
||||
changequote([,])dnl
|
||||
rm -f conftest.c conftest.so
|
||||
if test x${libat_libgcc_s_suffix+set} = xset; then
|
||||
CFLAGS=" -lgcc_s$libat_libgcc_s_suffix"
|
||||
AC_TRY_LINK(, [return 0;], libat_shared_libgcc=yes)
|
||||
CFLAGS="$ac_save_CFLAGS"
|
||||
fi
|
||||
fi
|
||||
AC_MSG_RESULT($libat_shared_libgcc)
|
||||
fi
|
||||
|
||||
# For GNU ld, we need at least this version. The format is described in
|
||||
# LIBAT_CHECK_LINKER_FEATURES above.
|
||||
libat_min_gnu_ld_version=21400
|
||||
# XXXXXXXXXXX libat_gnu_ld_version=21390
|
||||
|
||||
# Check to see if unspecified "yes" value can win, given results above.
|
||||
# Change "yes" into either "no" or a style name.
|
||||
if test $enable_symvers != no && test $libat_shared_libgcc = yes; then
|
||||
if test $with_gnu_ld = yes; then
|
||||
if test $libat_gnu_ld_version -ge $libat_min_gnu_ld_version ; then
|
||||
enable_symvers=gnu
|
||||
elif test $libat_ld_is_gold = yes ; then
|
||||
enable_symvers=gnu
|
||||
else
|
||||
# The right tools, the right setup, but too old. Fallbacks?
|
||||
AC_MSG_WARN(=== Linker version $libat_gnu_ld_version is too old for)
|
||||
AC_MSG_WARN(=== full symbol versioning support in this release of GCC.)
|
||||
AC_MSG_WARN(=== You would need to upgrade your binutils to version)
|
||||
AC_MSG_WARN(=== $libat_min_gnu_ld_version or later and rebuild GCC.)
|
||||
if test $libat_gnu_ld_version -ge 21200 ; then
|
||||
# Globbing fix is present, proper block support is not.
|
||||
dnl AC_MSG_WARN([=== Dude, you are soooo close. Maybe we can fake it.])
|
||||
dnl enable_symvers=???
|
||||
AC_MSG_WARN([=== Symbol versioning will be disabled.])
|
||||
enable_symvers=no
|
||||
else
|
||||
# 2.11 or older.
|
||||
AC_MSG_WARN([=== Symbol versioning will be disabled.])
|
||||
enable_symvers=no
|
||||
fi
|
||||
fi
|
||||
elif test $enable_symvers = sun; then
|
||||
: All interesting versions of Sun ld support sun style symbol versioning.
|
||||
else
|
||||
# just fail for now
|
||||
AC_MSG_WARN([=== You have requested some kind of symbol versioning, but])
|
||||
AC_MSG_WARN([=== either you are not using a supported linker, or you are])
|
||||
AC_MSG_WARN([=== not building a shared libgcc_s (which is required).])
|
||||
AC_MSG_WARN([=== Symbol versioning will be disabled.])
|
||||
enable_symvers=no
|
||||
fi
|
||||
fi
|
||||
if test $enable_symvers = gnu; then
|
||||
AC_DEFINE(LIBAT_GNU_SYMBOL_VERSIONING, 1,
|
||||
[Define to 1 if GNU symbol versioning is used for libatomic.])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(LIBAT_BUILD_VERSIONED_SHLIB, test $enable_symvers != no)
|
||||
AM_CONDITIONAL(LIBAT_BUILD_VERSIONED_SHLIB_GNU, test $enable_symvers = gnu)
|
||||
AM_CONDITIONAL(LIBAT_BUILD_VERSIONED_SHLIB_SUN, test $enable_symvers = sun)
|
||||
AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
|
||||
])
|
||||
|
||||
dnl ----------------------------------------------------------------------
|
||||
sinclude(../libtool.m4)
|
||||
dnl The lines below arrange for aclocal not to bring an installed
|
||||
dnl libtool.m4 into aclocal.m4, while still arranging for automake to
|
||||
dnl add a definition of LIBTOOL to Makefile.in.
|
||||
ifelse(,,,[AC_SUBST(LIBTOOL)
|
||||
AC_DEFUN([AM_PROG_LIBTOOL])
|
||||
AC_DEFUN([AC_LIBTOOL_DLOPEN])
|
||||
AC_DEFUN([AC_PROG_LD])
|
||||
])
|
963
libatomic/aclocal.m4
vendored
Normal file
963
libatomic/aclocal.m4
vendored
Normal file
|
@ -0,0 +1,963 @@
|
|||
# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.64],,
|
||||
[m4_warning([this file was generated for autoconf 2.64.
|
||||
You have another version of autoconf. It may work, but is not guaranteed to.
|
||||
If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically `autoreconf'.])])
|
||||
|
||||
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_AUTOMAKE_VERSION(VERSION)
|
||||
# ----------------------------
|
||||
# Automake X.Y traces this macro to ensure aclocal.m4 has been
|
||||
# generated from the m4 files accompanying Automake X.Y.
|
||||
# (This private macro should not be called outside this file.)
|
||||
AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||
[am__api_version='1.11'
|
||||
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||
dnl require some minimum version. Point them to the right macro.
|
||||
m4_if([$1], [1.11.1], [],
|
||||
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||
])
|
||||
|
||||
# _AM_AUTOCONF_VERSION(VERSION)
|
||||
# -----------------------------
|
||||
# aclocal traces this macro to find the Autoconf version.
|
||||
# This is a private macro too. Using m4_define simplifies
|
||||
# the logic in aclocal, which can simply ignore this definition.
|
||||
m4_define([_AM_AUTOCONF_VERSION], [])
|
||||
|
||||
# AM_SET_CURRENT_AUTOMAKE_VERSION
|
||||
# -------------------------------
|
||||
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.11.1])dnl
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||
|
||||
# Figure out how to run the assembler. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 5
|
||||
|
||||
# AM_PROG_AS
|
||||
# ----------
|
||||
AC_DEFUN([AM_PROG_AS],
|
||||
[# By default we simply use the C compiler to build assembly code.
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
test "${CCAS+set}" = set || CCAS=$CC
|
||||
test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS
|
||||
AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)])
|
||||
AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)])
|
||||
_AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
|
||||
])
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
|
||||
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
|
||||
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
|
||||
#
|
||||
# Of course, Automake must honor this variable whenever it calls a
|
||||
# tool from the auxiliary directory. The problem is that $srcdir (and
|
||||
# therefore $ac_aux_dir as well) can be either absolute or relative,
|
||||
# depending on how configure is run. This is pretty annoying, since
|
||||
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
|
||||
# source directory, any form will work fine, but in subdirectories a
|
||||
# relative path needs to be adjusted first.
|
||||
#
|
||||
# $ac_aux_dir/missing
|
||||
# fails when called from a subdirectory if $ac_aux_dir is relative
|
||||
# $top_srcdir/$ac_aux_dir/missing
|
||||
# fails if $ac_aux_dir is absolute,
|
||||
# fails when called from a subdirectory in a VPATH build with
|
||||
# a relative $ac_aux_dir
|
||||
#
|
||||
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
|
||||
# are both prefixed by $srcdir. In an in-source build this is usually
|
||||
# harmless because $srcdir is `.', but things will broke when you
|
||||
# start a VPATH build or use an absolute $srcdir.
|
||||
#
|
||||
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
|
||||
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
|
||||
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
|
||||
# and then we would define $MISSING as
|
||||
# MISSING="\${SHELL} $am_aux_dir/missing"
|
||||
# This will work as long as MISSING is not called from configure, because
|
||||
# unfortunately $(top_srcdir) has no meaning in configure.
|
||||
# However there are other variables, like CC, which are often used in
|
||||
# configure, and could therefore not use this "fixed" $ac_aux_dir.
|
||||
#
|
||||
# Another solution, used here, is to always expand $ac_aux_dir to an
|
||||
# absolute PATH. The drawback is that using absolute paths prevent a
|
||||
# configured tree to be moved without reconfiguration.
|
||||
|
||||
AC_DEFUN([AM_AUX_DIR_EXPAND],
|
||||
[dnl Rely on autoconf to set up CDPATH properly.
|
||||
AC_PREREQ([2.50])dnl
|
||||
# expand $ac_aux_dir to an absolute path
|
||||
am_aux_dir=`cd $ac_aux_dir && pwd`
|
||||
])
|
||||
|
||||
# AM_CONDITIONAL -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 9
|
||||
|
||||
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
|
||||
# -------------------------------------
|
||||
# Define a conditional.
|
||||
AC_DEFUN([AM_CONDITIONAL],
|
||||
[AC_PREREQ(2.52)dnl
|
||||
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
|
||||
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
|
||||
AC_SUBST([$1_TRUE])dnl
|
||||
AC_SUBST([$1_FALSE])dnl
|
||||
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
|
||||
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
|
||||
m4_define([_AM_COND_VALUE_$1], [$2])dnl
|
||||
if $2; then
|
||||
$1_TRUE=
|
||||
$1_FALSE='#'
|
||||
else
|
||||
$1_TRUE='#'
|
||||
$1_FALSE=
|
||||
fi
|
||||
AC_CONFIG_COMMANDS_PRE(
|
||||
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
|
||||
AC_MSG_ERROR([[conditional "$1" was never defined.
|
||||
Usually this means the macro was only invoked conditionally.]])
|
||||
fi])])
|
||||
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 10
|
||||
|
||||
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
|
||||
# written in clear, in which case automake, when reading aclocal.m4,
|
||||
# will think it sees a *use*, and therefore will trigger all it's
|
||||
# C support machinery. Also note that it means that autoscan, seeing
|
||||
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
|
||||
|
||||
|
||||
# _AM_DEPENDENCIES(NAME)
|
||||
# ----------------------
|
||||
# See how the compiler implements dependency checking.
|
||||
# NAME is "CC", "CXX", "GCJ", or "OBJC".
|
||||
# We try a few techniques and use that to set a single cache variable.
|
||||
#
|
||||
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
|
||||
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
|
||||
# dependency, and given that the user is not expected to run this macro,
|
||||
# just rely on AC_PROG_CC.
|
||||
AC_DEFUN([_AM_DEPENDENCIES],
|
||||
[AC_REQUIRE([AM_SET_DEPDIR])dnl
|
||||
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
|
||||
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
|
||||
AC_REQUIRE([AM_DEP_TRACK])dnl
|
||||
|
||||
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
|
||||
[$1], CXX, [depcc="$CXX" am_compiler_list=],
|
||||
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
|
||||
[$1], UPC, [depcc="$UPC" am_compiler_list=],
|
||||
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
|
||||
[depcc="$$1" am_compiler_list=])
|
||||
|
||||
AC_CACHE_CHECK([dependency style of $depcc],
|
||||
[am_cv_$1_dependencies_compiler_type],
|
||||
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
|
||||
# We make a subdir and do the tests there. Otherwise we can end up
|
||||
# making bogus files that we don't know about and never remove. For
|
||||
# instance it was reported that on HP-UX the gcc test will end up
|
||||
# making a dummy file named `D' -- because `-MD' means `put the output
|
||||
# in D'.
|
||||
mkdir conftest.dir
|
||||
# Copy depcomp to subdir because otherwise we won't find it if we're
|
||||
# using a relative directory.
|
||||
cp "$am_depcomp" conftest.dir
|
||||
cd conftest.dir
|
||||
# We will build objects and dependencies in a subdirectory because
|
||||
# it helps to detect inapplicable dependency modes. For instance
|
||||
# both Tru64's cc and ICC support -MD to output dependencies as a
|
||||
# side effect of compilation, but ICC will put the dependencies in
|
||||
# the current directory while Tru64 will put them in the object
|
||||
# directory.
|
||||
mkdir sub
|
||||
|
||||
am_cv_$1_dependencies_compiler_type=none
|
||||
if test "$am_compiler_list" = ""; then
|
||||
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
|
||||
fi
|
||||
am__universal=false
|
||||
m4_case([$1], [CC],
|
||||
[case " $depcc " in #(
|
||||
*\ -arch\ *\ -arch\ *) am__universal=true ;;
|
||||
esac],
|
||||
[CXX],
|
||||
[case " $depcc " in #(
|
||||
*\ -arch\ *\ -arch\ *) am__universal=true ;;
|
||||
esac])
|
||||
|
||||
for depmode in $am_compiler_list; do
|
||||
# Setup a source with many dependencies, because some compilers
|
||||
# like to wrap large dependency lists on column 80 (with \), and
|
||||
# we should not choose a depcomp mode which is confused by this.
|
||||
#
|
||||
# We need to recreate these files for each test, as the compiler may
|
||||
# overwrite some of them when testing with obscure command lines.
|
||||
# This happens at least with the AIX C compiler.
|
||||
: > sub/conftest.c
|
||||
for i in 1 2 3 4 5 6; do
|
||||
echo '#include "conftst'$i'.h"' >> sub/conftest.c
|
||||
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
|
||||
# Solaris 8's {/usr,}/bin/sh.
|
||||
touch sub/conftst$i.h
|
||||
done
|
||||
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
|
||||
|
||||
# We check with `-c' and `-o' for the sake of the "dashmstdout"
|
||||
# mode. It turns out that the SunPro C++ compiler does not properly
|
||||
# handle `-M -o', and we need to detect this. Also, some Intel
|
||||
# versions had trouble with output in subdirs
|
||||
am__obj=sub/conftest.${OBJEXT-o}
|
||||
am__minus_obj="-o $am__obj"
|
||||
case $depmode in
|
||||
gcc)
|
||||
# This depmode causes a compiler race in universal mode.
|
||||
test "$am__universal" = false || continue
|
||||
;;
|
||||
nosideeffect)
|
||||
# after this tag, mechanisms are not by side-effect, so they'll
|
||||
# only be used when explicitly requested
|
||||
if test "x$enable_dependency_tracking" = xyes; then
|
||||
continue
|
||||
else
|
||||
break
|
||||
fi
|
||||
;;
|
||||
msvisualcpp | msvcmsys)
|
||||
# This compiler won't grok `-c -o', but also, the minuso test has
|
||||
# not run yet. These depmodes are late enough in the game, and
|
||||
# so weak that their functioning should not be impacted.
|
||||
am__obj=conftest.${OBJEXT-o}
|
||||
am__minus_obj=
|
||||
;;
|
||||
none) break ;;
|
||||
esac
|
||||
if depmode=$depmode \
|
||||
source=sub/conftest.c object=$am__obj \
|
||||
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
|
||||
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
|
||||
>/dev/null 2>conftest.err &&
|
||||
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
|
||||
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
|
||||
# icc doesn't choke on unknown options, it will just issue warnings
|
||||
# or remarks (even with -Werror). So we grep stderr for any message
|
||||
# that says an option was ignored or not supported.
|
||||
# When given -MP, icc 7.0 and 7.1 complain thusly:
|
||||
# icc: Command line warning: ignoring option '-M'; no argument required
|
||||
# The diagnosis changed in icc 8.0:
|
||||
# icc: Command line remark: option '-MP' not supported
|
||||
if (grep 'ignoring option' conftest.err ||
|
||||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
|
||||
am_cv_$1_dependencies_compiler_type=$depmode
|
||||
break
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
cd ..
|
||||
rm -rf conftest.dir
|
||||
else
|
||||
am_cv_$1_dependencies_compiler_type=none
|
||||
fi
|
||||
])
|
||||
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
|
||||
AM_CONDITIONAL([am__fastdep$1], [
|
||||
test "x$enable_dependency_tracking" != xno \
|
||||
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
|
||||
])
|
||||
|
||||
|
||||
# AM_SET_DEPDIR
|
||||
# -------------
|
||||
# Choose a directory name for dependency files.
|
||||
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
|
||||
AC_DEFUN([AM_SET_DEPDIR],
|
||||
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
|
||||
])
|
||||
|
||||
|
||||
# AM_DEP_TRACK
|
||||
# ------------
|
||||
AC_DEFUN([AM_DEP_TRACK],
|
||||
[AC_ARG_ENABLE(dependency-tracking,
|
||||
[ --disable-dependency-tracking speeds up one-time build
|
||||
--enable-dependency-tracking do not reject slow dependency extractors])
|
||||
if test "x$enable_dependency_tracking" != xno; then
|
||||
am_depcomp="$ac_aux_dir/depcomp"
|
||||
AMDEPBACKSLASH='\'
|
||||
fi
|
||||
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
|
||||
AC_SUBST([AMDEPBACKSLASH])dnl
|
||||
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
|
||||
])
|
||||
|
||||
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
#serial 5
|
||||
|
||||
# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
# ------------------------------
|
||||
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[{
|
||||
# Autoconf 2.62 quotes --file arguments for eval, but not when files
|
||||
# are listed without --file. Let's play safe and only enable the eval
|
||||
# if we detect the quoting.
|
||||
case $CONFIG_FILES in
|
||||
*\'*) eval set x "$CONFIG_FILES" ;;
|
||||
*) set x $CONFIG_FILES ;;
|
||||
esac
|
||||
shift
|
||||
for mf
|
||||
do
|
||||
# Strip MF so we end up with the name of the file.
|
||||
mf=`echo "$mf" | sed -e 's/:.*$//'`
|
||||
# Check whether this is an Automake generated Makefile or not.
|
||||
# We used to match only the files named `Makefile.in', but
|
||||
# some people rename them; so instead we look at the file content.
|
||||
# Grep'ing the first line is not enough: some people post-process
|
||||
# each Makefile.in and add a new line on top of each file to say so.
|
||||
# Grep'ing the whole file is not good either: AIX grep has a line
|
||||
# limit of 2048, but all sed's we know have understand at least 4000.
|
||||
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
|
||||
dirpart=`AS_DIRNAME("$mf")`
|
||||
else
|
||||
continue
|
||||
fi
|
||||
# Extract the definition of DEPDIR, am__include, and am__quote
|
||||
# from the Makefile without running `make'.
|
||||
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
|
||||
test -z "$DEPDIR" && continue
|
||||
am__include=`sed -n 's/^am__include = //p' < "$mf"`
|
||||
test -z "am__include" && continue
|
||||
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
|
||||
# When using ansi2knr, U may be empty or an underscore; expand it
|
||||
U=`sed -n 's/^U = //p' < "$mf"`
|
||||
# Find all dependency output files, they are included files with
|
||||
# $(DEPDIR) in their names. We invoke sed twice because it is the
|
||||
# simplest approach to changing $(DEPDIR) to its actual value in the
|
||||
# expansion.
|
||||
for file in `sed -n "
|
||||
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
|
||||
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
|
||||
# Make sure the directory exists.
|
||||
test -f "$dirpart/$file" && continue
|
||||
fdir=`AS_DIRNAME(["$file"])`
|
||||
AS_MKDIR_P([$dirpart/$fdir])
|
||||
# echo "creating $dirpart/$file"
|
||||
echo '# dummy' > "$dirpart/$file"
|
||||
done
|
||||
done
|
||||
}
|
||||
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
|
||||
|
||||
# AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
# -----------------------------
|
||||
# This macro should only be invoked once -- use via AC_REQUIRE.
|
||||
#
|
||||
# This code is only required when automatic dependency tracking
|
||||
# is enabled. FIXME. This creates each `.P' file that we will
|
||||
# need in order to bootstrap the dependency handling code.
|
||||
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[AC_CONFIG_COMMANDS([depfiles],
|
||||
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
|
||||
])
|
||||
|
||||
# Do all the work for Automake. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 16
|
||||
|
||||
# This macro actually does too much. Some checks are only needed if
|
||||
# your package does certain things. But this isn't really a big deal.
|
||||
|
||||
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
|
||||
# AM_INIT_AUTOMAKE([OPTIONS])
|
||||
# -----------------------------------------------
|
||||
# The call with PACKAGE and VERSION arguments is the old style
|
||||
# call (pre autoconf-2.50), which is being phased out. PACKAGE
|
||||
# and VERSION should now be passed to AC_INIT and removed from
|
||||
# the call to AM_INIT_AUTOMAKE.
|
||||
# We support both call styles for the transition. After
|
||||
# the next Automake release, Autoconf can make the AC_INIT
|
||||
# arguments mandatory, and then we can depend on a new Autoconf
|
||||
# release and drop the old call support.
|
||||
AC_DEFUN([AM_INIT_AUTOMAKE],
|
||||
[AC_PREREQ([2.62])dnl
|
||||
dnl Autoconf wants to disallow AM_ names. We explicitly allow
|
||||
dnl the ones we care about.
|
||||
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
|
||||
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
|
||||
AC_REQUIRE([AC_PROG_INSTALL])dnl
|
||||
if test "`cd $srcdir && pwd`" != "`pwd`"; then
|
||||
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
|
||||
# is not polluted with repeated "-I."
|
||||
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
|
||||
# test to see if srcdir already configured
|
||||
if test -f $srcdir/config.status; then
|
||||
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
|
||||
fi
|
||||
fi
|
||||
|
||||
# test whether we have cygpath
|
||||
if test -z "$CYGPATH_W"; then
|
||||
if (cygpath --version) >/dev/null 2>/dev/null; then
|
||||
CYGPATH_W='cygpath -w'
|
||||
else
|
||||
CYGPATH_W=echo
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([CYGPATH_W])
|
||||
|
||||
# Define the identity of the package.
|
||||
dnl Distinguish between old-style and new-style calls.
|
||||
m4_ifval([$2],
|
||||
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
|
||||
AC_SUBST([PACKAGE], [$1])dnl
|
||||
AC_SUBST([VERSION], [$2])],
|
||||
[_AM_SET_OPTIONS([$1])dnl
|
||||
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
|
||||
m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
|
||||
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
|
||||
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
|
||||
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
|
||||
|
||||
_AM_IF_OPTION([no-define],,
|
||||
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
|
||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
|
||||
|
||||
# Some tools Automake needs.
|
||||
AC_REQUIRE([AM_SANITY_CHECK])dnl
|
||||
AC_REQUIRE([AC_ARG_PROGRAM])dnl
|
||||
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
|
||||
AM_MISSING_PROG(AUTOCONF, autoconf)
|
||||
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo)
|
||||
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
|
||||
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
|
||||
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
|
||||
# We need awk for the "check" target. The system "awk" is bad on
|
||||
# some platforms.
|
||||
AC_REQUIRE([AC_PROG_AWK])dnl
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
|
||||
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
|
||||
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
|
||||
[_AM_PROG_TAR([v7])])])
|
||||
_AM_IF_OPTION([no-dependencies],,
|
||||
[AC_PROVIDE_IFELSE([AC_PROG_CC],
|
||||
[_AM_DEPENDENCIES(CC)],
|
||||
[define([AC_PROG_CC],
|
||||
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
|
||||
AC_PROVIDE_IFELSE([AC_PROG_CXX],
|
||||
[_AM_DEPENDENCIES(CXX)],
|
||||
[define([AC_PROG_CXX],
|
||||
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
|
||||
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
|
||||
[_AM_DEPENDENCIES(OBJC)],
|
||||
[define([AC_PROG_OBJC],
|
||||
defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
|
||||
])
|
||||
_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
|
||||
dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
|
||||
dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro
|
||||
dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
|
||||
AC_CONFIG_COMMANDS_PRE(dnl
|
||||
[m4_provide_if([_AM_COMPILER_EXEEXT],
|
||||
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
|
||||
])
|
||||
|
||||
dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
|
||||
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
|
||||
dnl mangled by Autoconf and run in a shell conditional statement.
|
||||
m4_define([_AC_COMPILER_EXEEXT],
|
||||
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
|
||||
|
||||
|
||||
# When config.status generates a header, we must update the stamp-h file.
|
||||
# This file resides in the same directory as the config header
|
||||
# that is generated. The stamp files are numbered to have different names.
|
||||
|
||||
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
|
||||
# loop where config.status creates the headers, so we can generate
|
||||
# our stamp files there.
|
||||
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
|
||||
[# Compute $1's index in $config_headers.
|
||||
_am_arg=$1
|
||||
_am_stamp_count=1
|
||||
for _am_header in $config_headers :; do
|
||||
case $_am_header in
|
||||
$_am_arg | $_am_arg:* )
|
||||
break ;;
|
||||
* )
|
||||
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
|
||||
esac
|
||||
done
|
||||
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
|
||||
|
||||
# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_PROG_INSTALL_SH
|
||||
# ------------------
|
||||
# Define $install_sh.
|
||||
AC_DEFUN([AM_PROG_INSTALL_SH],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
if test x"${install_sh}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
|
||||
*)
|
||||
install_sh="\${SHELL} $am_aux_dir/install-sh"
|
||||
esac
|
||||
fi
|
||||
AC_SUBST(install_sh)])
|
||||
|
||||
# Check to see how 'make' treats includes. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 4
|
||||
|
||||
# AM_MAKE_INCLUDE()
|
||||
# -----------------
|
||||
# Check to see how make treats includes.
|
||||
AC_DEFUN([AM_MAKE_INCLUDE],
|
||||
[am_make=${MAKE-make}
|
||||
cat > confinc << 'END'
|
||||
am__doit:
|
||||
@echo this is the am__doit target
|
||||
.PHONY: am__doit
|
||||
END
|
||||
# If we don't find an include directive, just comment out the code.
|
||||
AC_MSG_CHECKING([for style of include used by $am_make])
|
||||
am__include="#"
|
||||
am__quote=
|
||||
_am_result=none
|
||||
# First try GNU make style include.
|
||||
echo "include confinc" > confmf
|
||||
# Ignore all kinds of additional output from `make'.
|
||||
case `$am_make -s -f confmf 2> /dev/null` in #(
|
||||
*the\ am__doit\ target*)
|
||||
am__include=include
|
||||
am__quote=
|
||||
_am_result=GNU
|
||||
;;
|
||||
esac
|
||||
# Now try BSD make style include.
|
||||
if test "$am__include" = "#"; then
|
||||
echo '.include "confinc"' > confmf
|
||||
case `$am_make -s -f confmf 2> /dev/null` in #(
|
||||
*the\ am__doit\ target*)
|
||||
am__include=.include
|
||||
am__quote="\""
|
||||
_am_result=BSD
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AC_SUBST([am__include])
|
||||
AC_SUBST([am__quote])
|
||||
AC_MSG_RESULT([$_am_result])
|
||||
rm -f confinc confmf
|
||||
])
|
||||
|
||||
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 6
|
||||
|
||||
# AM_MISSING_PROG(NAME, PROGRAM)
|
||||
# ------------------------------
|
||||
AC_DEFUN([AM_MISSING_PROG],
|
||||
[AC_REQUIRE([AM_MISSING_HAS_RUN])
|
||||
$1=${$1-"${am_missing_run}$2"}
|
||||
AC_SUBST($1)])
|
||||
|
||||
|
||||
# AM_MISSING_HAS_RUN
|
||||
# ------------------
|
||||
# Define MISSING if not defined so far and test if it supports --run.
|
||||
# If it does, set am_missing_run to use it, otherwise, to nothing.
|
||||
AC_DEFUN([AM_MISSING_HAS_RUN],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
AC_REQUIRE_AUX_FILE([missing])dnl
|
||||
if test x"${MISSING+set}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
|
||||
*)
|
||||
MISSING="\${SHELL} $am_aux_dir/missing" ;;
|
||||
esac
|
||||
fi
|
||||
# Use eval to expand $SHELL
|
||||
if eval "$MISSING --run true"; then
|
||||
am_missing_run="$MISSING --run "
|
||||
else
|
||||
am_missing_run=
|
||||
AC_MSG_WARN([`missing' script is too old or missing])
|
||||
fi
|
||||
])
|
||||
|
||||
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_PROG_MKDIR_P
|
||||
# ---------------
|
||||
# Check for `mkdir -p'.
|
||||
AC_DEFUN([AM_PROG_MKDIR_P],
|
||||
[AC_PREREQ([2.60])dnl
|
||||
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
|
||||
dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
|
||||
dnl while keeping a definition of mkdir_p for backward compatibility.
|
||||
dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
|
||||
dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
|
||||
dnl Makefile.ins that do not define MKDIR_P, so we do our own
|
||||
dnl adjustment using top_builddir (which is defined more often than
|
||||
dnl MKDIR_P).
|
||||
AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
|
||||
case $mkdir_p in
|
||||
[[\\/$]]* | ?:[[\\/]]*) ;;
|
||||
*/*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
|
||||
esac
|
||||
])
|
||||
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 4
|
||||
|
||||
# _AM_MANGLE_OPTION(NAME)
|
||||
# -----------------------
|
||||
AC_DEFUN([_AM_MANGLE_OPTION],
|
||||
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
|
||||
|
||||
# _AM_SET_OPTION(NAME)
|
||||
# ------------------------------
|
||||
# Set option NAME. Presently that only means defining a flag for this option.
|
||||
AC_DEFUN([_AM_SET_OPTION],
|
||||
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
|
||||
|
||||
# _AM_SET_OPTIONS(OPTIONS)
|
||||
# ----------------------------------
|
||||
# OPTIONS is a space-separated list of Automake options.
|
||||
AC_DEFUN([_AM_SET_OPTIONS],
|
||||
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
|
||||
|
||||
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
|
||||
# -------------------------------------------
|
||||
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||
AC_DEFUN([_AM_IF_OPTION],
|
||||
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
|
||||
|
||||
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 5
|
||||
|
||||
# AM_SANITY_CHECK
|
||||
# ---------------
|
||||
AC_DEFUN([AM_SANITY_CHECK],
|
||||
[AC_MSG_CHECKING([whether build environment is sane])
|
||||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftest.file
|
||||
# Reject unsafe characters in $srcdir or the absolute working directory
|
||||
# name. Accept space and tab only in the latter.
|
||||
am_lf='
|
||||
'
|
||||
case `pwd` in
|
||||
*[[\\\"\#\$\&\'\`$am_lf]]*)
|
||||
AC_MSG_ERROR([unsafe absolute working directory name]);;
|
||||
esac
|
||||
case $srcdir in
|
||||
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
|
||||
AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
|
||||
esac
|
||||
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
|
||||
if test "$[*]" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t "$srcdir/configure" conftest.file`
|
||||
fi
|
||||
rm -f conftest.file
|
||||
if test "$[*]" != "X $srcdir/configure conftest.file" \
|
||||
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
|
||||
|
||||
# If neither matched, then we have a broken ls. This can happen
|
||||
# if, for instance, CONFIG_SHELL is bash and it inherits a
|
||||
# broken ls alias from the environment. This has actually
|
||||
# happened. Such a system could not be considered "sane".
|
||||
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
|
||||
alias in your environment])
|
||||
fi
|
||||
|
||||
test "$[2]" = conftest.file
|
||||
)
|
||||
then
|
||||
# Ok.
|
||||
:
|
||||
else
|
||||
AC_MSG_ERROR([newly created file is older than distributed files!
|
||||
Check your system clock])
|
||||
fi
|
||||
AC_MSG_RESULT(yes)])
|
||||
|
||||
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_PROG_INSTALL_STRIP
|
||||
# ---------------------
|
||||
# One issue with vendor `install' (even GNU) is that you can't
|
||||
# specify the program used to strip binaries. This is especially
|
||||
# annoying in cross-compiling environments, where the build's strip
|
||||
# is unlikely to handle the host's binaries.
|
||||
# Fortunately install-sh will honor a STRIPPROG variable, so we
|
||||
# always use install-sh in `make install-strip', and initialize
|
||||
# STRIPPROG with the value of the STRIP variable (set by the user).
|
||||
AC_DEFUN([AM_PROG_INSTALL_STRIP],
|
||||
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
|
||||
# Installed binaries are usually stripped using `strip' when the user
|
||||
# run `make install-strip'. However `strip' might not be the right
|
||||
# tool to use in cross-compilation environments, therefore Automake
|
||||
# will honor the `STRIP' environment variable to overrule this program.
|
||||
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
|
||||
if test "$cross_compiling" != no; then
|
||||
AC_CHECK_TOOL([STRIP], [strip], :)
|
||||
fi
|
||||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||
|
||||
# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 2
|
||||
|
||||
# _AM_SUBST_NOTMAKE(VARIABLE)
|
||||
# ---------------------------
|
||||
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
|
||||
# This macro is traced by Automake.
|
||||
AC_DEFUN([_AM_SUBST_NOTMAKE])
|
||||
|
||||
# AM_SUBST_NOTMAKE(VARIABLE)
|
||||
# ---------------------------
|
||||
# Public sister of _AM_SUBST_NOTMAKE.
|
||||
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
|
||||
|
||||
# Check how to create a tarball. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 2
|
||||
|
||||
# _AM_PROG_TAR(FORMAT)
|
||||
# --------------------
|
||||
# Check how to create a tarball in format FORMAT.
|
||||
# FORMAT should be one of `v7', `ustar', or `pax'.
|
||||
#
|
||||
# Substitute a variable $(am__tar) that is a command
|
||||
# writing to stdout a FORMAT-tarball containing the directory
|
||||
# $tardir.
|
||||
# tardir=directory && $(am__tar) > result.tar
|
||||
#
|
||||
# Substitute a variable $(am__untar) that extract such
|
||||
# a tarball read from stdin.
|
||||
# $(am__untar) < result.tar
|
||||
AC_DEFUN([_AM_PROG_TAR],
|
||||
[# Always define AMTAR for backward compatibility.
|
||||
AM_MISSING_PROG([AMTAR], [tar])
|
||||
m4_if([$1], [v7],
|
||||
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
|
||||
[m4_case([$1], [ustar],, [pax],,
|
||||
[m4_fatal([Unknown tar format])])
|
||||
AC_MSG_CHECKING([how to create a $1 tar archive])
|
||||
# Loop over all known methods to create a tar archive until one works.
|
||||
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
|
||||
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
|
||||
# Do not fold the above two line into one, because Tru64 sh and
|
||||
# Solaris sh will not grok spaces in the rhs of `-'.
|
||||
for _am_tool in $_am_tools
|
||||
do
|
||||
case $_am_tool in
|
||||
gnutar)
|
||||
for _am_tar in tar gnutar gtar;
|
||||
do
|
||||
AM_RUN_LOG([$_am_tar --version]) && break
|
||||
done
|
||||
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
|
||||
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
|
||||
am__untar="$_am_tar -xf -"
|
||||
;;
|
||||
plaintar)
|
||||
# Must skip GNU tar: if it does not support --format= it doesn't create
|
||||
# ustar tarball either.
|
||||
(tar --version) >/dev/null 2>&1 && continue
|
||||
am__tar='tar chf - "$$tardir"'
|
||||
am__tar_='tar chf - "$tardir"'
|
||||
am__untar='tar xf -'
|
||||
;;
|
||||
pax)
|
||||
am__tar='pax -L -x $1 -w "$$tardir"'
|
||||
am__tar_='pax -L -x $1 -w "$tardir"'
|
||||
am__untar='pax -r'
|
||||
;;
|
||||
cpio)
|
||||
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
|
||||
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
|
||||
am__untar='cpio -i -H $1 -d'
|
||||
;;
|
||||
none)
|
||||
am__tar=false
|
||||
am__tar_=false
|
||||
am__untar=false
|
||||
;;
|
||||
esac
|
||||
|
||||
# If the value was cached, stop now. We just wanted to have am__tar
|
||||
# and am__untar set.
|
||||
test -n "${am_cv_prog_tar_$1}" && break
|
||||
|
||||
# tar/untar a dummy directory, and stop if the command works
|
||||
rm -rf conftest.dir
|
||||
mkdir conftest.dir
|
||||
echo GrepMe > conftest.dir/file
|
||||
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
|
||||
rm -rf conftest.dir
|
||||
if test -s conftest.tar; then
|
||||
AM_RUN_LOG([$am__untar <conftest.tar])
|
||||
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
|
||||
fi
|
||||
done
|
||||
rm -rf conftest.dir
|
||||
|
||||
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
|
||||
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
|
||||
AC_SUBST([am__tar])
|
||||
AC_SUBST([am__untar])
|
||||
]) # _AM_PROG_TAR
|
||||
|
||||
m4_include([../config/acx.m4])
|
||||
m4_include([../config/depstand.m4])
|
||||
m4_include([../config/lead-dot.m4])
|
||||
m4_include([../config/multi.m4])
|
||||
m4_include([../config/override.m4])
|
||||
m4_include([../config/stdint.m4])
|
||||
m4_include([../ltoptions.m4])
|
||||
m4_include([../ltsugar.m4])
|
||||
m4_include([../ltversion.m4])
|
||||
m4_include([../lt~obsolete.m4])
|
||||
m4_include([acinclude.m4])
|
282
libatomic/auto-config.h.in
Normal file
282
libatomic/auto-config.h.in
Normal file
|
@ -0,0 +1,282 @@
|
|||
/* auto-config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
#undef AC_APPLE_UNIVERSAL_BUILD
|
||||
|
||||
/* Have __atomic_compare_exchange for 1 byte integers. */
|
||||
#undef HAVE_ATOMIC_CAS_1
|
||||
|
||||
/* Have __atomic_compare_exchange for 16 byte integers. */
|
||||
#undef HAVE_ATOMIC_CAS_16
|
||||
|
||||
/* Have __atomic_compare_exchange for 2 byte integers. */
|
||||
#undef HAVE_ATOMIC_CAS_2
|
||||
|
||||
/* Have __atomic_compare_exchange for 4 byte integers. */
|
||||
#undef HAVE_ATOMIC_CAS_4
|
||||
|
||||
/* Have __atomic_compare_exchange for 8 byte integers. */
|
||||
#undef HAVE_ATOMIC_CAS_8
|
||||
|
||||
/* Have __atomic_exchange for 1 byte integers. */
|
||||
#undef HAVE_ATOMIC_EXCHANGE_1
|
||||
|
||||
/* Have __atomic_exchange for 16 byte integers. */
|
||||
#undef HAVE_ATOMIC_EXCHANGE_16
|
||||
|
||||
/* Have __atomic_exchange for 2 byte integers. */
|
||||
#undef HAVE_ATOMIC_EXCHANGE_2
|
||||
|
||||
/* Have __atomic_exchange for 4 byte integers. */
|
||||
#undef HAVE_ATOMIC_EXCHANGE_4
|
||||
|
||||
/* Have __atomic_exchange for 8 byte integers. */
|
||||
#undef HAVE_ATOMIC_EXCHANGE_8
|
||||
|
||||
/* Have __atomic_fetch_add for 1 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_ADD_1
|
||||
|
||||
/* Have __atomic_fetch_add for 16 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_ADD_16
|
||||
|
||||
/* Have __atomic_fetch_add for 2 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_ADD_2
|
||||
|
||||
/* Have __atomic_fetch_add for 4 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_ADD_4
|
||||
|
||||
/* Have __atomic_fetch_add for 8 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_ADD_8
|
||||
|
||||
/* Have __atomic_fetch_op for all op for 1 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_OP_1
|
||||
|
||||
/* Have __atomic_fetch_op for all op for 16 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_OP_16
|
||||
|
||||
/* Have __atomic_fetch_op for all op for 2 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_OP_2
|
||||
|
||||
/* Have __atomic_fetch_op for all op for 4 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_OP_4
|
||||
|
||||
/* Have __atomic_fetch_op for all op for 8 byte integers. */
|
||||
#undef HAVE_ATOMIC_FETCH_OP_8
|
||||
|
||||
/* Have __atomic_load/store for 1 byte integers. */
|
||||
#undef HAVE_ATOMIC_LDST_1
|
||||
|
||||
/* Have __atomic_load/store for 16 byte integers. */
|
||||
#undef HAVE_ATOMIC_LDST_16
|
||||
|
||||
/* Have __atomic_load/store for 2 byte integers. */
|
||||
#undef HAVE_ATOMIC_LDST_2
|
||||
|
||||
/* Have __atomic_load/store for 4 byte integers. */
|
||||
#undef HAVE_ATOMIC_LDST_4
|
||||
|
||||
/* Have __atomic_load/store for 8 byte integers. */
|
||||
#undef HAVE_ATOMIC_LDST_8
|
||||
|
||||
/* Have __atomic_test_and_set for 1 byte integers. */
|
||||
#undef HAVE_ATOMIC_TAS_1
|
||||
|
||||
/* Have __atomic_test_and_set for 16 byte integers. */
|
||||
#undef HAVE_ATOMIC_TAS_16
|
||||
|
||||
/* Have __atomic_test_and_set for 2 byte integers. */
|
||||
#undef HAVE_ATOMIC_TAS_2
|
||||
|
||||
/* Have __atomic_test_and_set for 4 byte integers. */
|
||||
#undef HAVE_ATOMIC_TAS_4
|
||||
|
||||
/* Have __atomic_test_and_set for 8 byte integers. */
|
||||
#undef HAVE_ATOMIC_TAS_8
|
||||
|
||||
/* Define to 1 if the target supports __attribute__((alias(...))). */
|
||||
#undef HAVE_ATTRIBUTE_ALIAS
|
||||
|
||||
/* Define to 1 if the target supports __attribute__((dllexport)). */
|
||||
#undef HAVE_ATTRIBUTE_DLLEXPORT
|
||||
|
||||
/* Define to 1 if the target supports __attribute__((visibility(...))). */
|
||||
#undef HAVE_ATTRIBUTE_VISIBILITY
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if the target supports __attribute__((ifunc(...))). */
|
||||
#undef HAVE_IFUNC
|
||||
|
||||
/* Have support for 1 byte integers. */
|
||||
#undef HAVE_INT1
|
||||
|
||||
/* Have support for 16 byte integers. */
|
||||
#undef HAVE_INT16
|
||||
|
||||
/* Have support for 2 byte integers. */
|
||||
#undef HAVE_INT2
|
||||
|
||||
/* Have support for 4 byte integers. */
|
||||
#undef HAVE_INT4
|
||||
|
||||
/* Have support for 8 byte integers. */
|
||||
#undef HAVE_INT8
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if GNU symbol versioning is used for libatomic. */
|
||||
#undef LIBAT_GNU_SYMBOL_VERSIONING
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* The size of `char', as computed by sizeof. */
|
||||
#undef SIZEOF_CHAR
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#undef SIZEOF_INT
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#undef SIZEOF_LONG
|
||||
|
||||
/* The size of `short', as computed by sizeof. */
|
||||
#undef SIZEOF_SHORT
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#undef SIZEOF_VOID_P
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if you can safely include both <string.h> and <strings.h>. */
|
||||
#undef STRING_WITH_STRINGS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* The word size in bytes of the machine. */
|
||||
#undef WORDSIZE
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
# undef WORDS_BIGENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_LDST_1 HAVE_ATOMIC_LDST_1
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_TAS_16 HAVE_ATOMIC_TAS_16
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_EXCHANGE_1 HAVE_ATOMIC_EXCHANGE_1
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_EXCHANGE_2 HAVE_ATOMIC_EXCHANGE_2
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_EXCHANGE_4 HAVE_ATOMIC_EXCHANGE_4
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_EXCHANGE_8 HAVE_ATOMIC_EXCHANGE_8
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_EXCHANGE_16 HAVE_ATOMIC_EXCHANGE_16
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_CAS_1 HAVE_ATOMIC_CAS_1
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_CAS_2 HAVE_ATOMIC_CAS_2
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_CAS_4 HAVE_ATOMIC_CAS_4
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_CAS_8 HAVE_ATOMIC_CAS_8
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_LDST_2 HAVE_ATOMIC_LDST_2
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_CAS_16 HAVE_ATOMIC_CAS_16
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_ADD_1 HAVE_ATOMIC_FETCH_ADD_1
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_ADD_2 HAVE_ATOMIC_FETCH_ADD_2
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_ADD_4 HAVE_ATOMIC_FETCH_ADD_4
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_ADD_8 HAVE_ATOMIC_FETCH_ADD_8
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_ADD_16 HAVE_ATOMIC_FETCH_ADD_16
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_OP_1 HAVE_ATOMIC_FETCH_OP_1
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_OP_2 HAVE_ATOMIC_FETCH_OP_2
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_OP_4 HAVE_ATOMIC_FETCH_OP_4
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_OP_8 HAVE_ATOMIC_FETCH_OP_8
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_LDST_4 HAVE_ATOMIC_LDST_4
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_FETCH_OP_16 HAVE_ATOMIC_FETCH_OP_16
|
||||
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
#define WORDS_BIGENDIAN 0
|
||||
#endif
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_LDST_8 HAVE_ATOMIC_LDST_8
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_LDST_16 HAVE_ATOMIC_LDST_16
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_TAS_1 HAVE_ATOMIC_TAS_1
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_TAS_2 HAVE_ATOMIC_TAS_2
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_TAS_4 HAVE_ATOMIC_TAS_4
|
||||
|
||||
#define MAYBE_HAVE_ATOMIC_TAS_8 HAVE_ATOMIC_TAS_8
|
125
libatomic/cas_n.c
Normal file
125
libatomic/cas_n.c
Normal file
|
@ -0,0 +1,125 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we support the builtin, just use it. */
|
||||
#if !DONE && defined(atomic_compare_exchange_n)
|
||||
bool
|
||||
SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
|
||||
int smodel, int fmodel UNUSED)
|
||||
{
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
return atomic_compare_exchange_n (mptr, eptr, newval, false,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
||||
else if (maybe_specialcase_acqrel(smodel))
|
||||
return atomic_compare_exchange_n (mptr, eptr, newval, false,
|
||||
__ATOMIC_ACQ_REL, __ATOMIC_RELAXED);
|
||||
else
|
||||
return atomic_compare_exchange_n (mptr, eptr, newval, false,
|
||||
__ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_CAS */
|
||||
|
||||
|
||||
/* If this type is not larger than word-sized, fall back to a word-sized
|
||||
compare-and-swap loop, possibly assisted by the OS. */
|
||||
#if !DONE && N <= WORDSIZE && defined(atomic_compare_exchange_w)
|
||||
bool
|
||||
SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
|
||||
int smodel, int fmodel UNUSED)
|
||||
{
|
||||
UWORD mask, shift, weval, woldval, wnewval, t, *wptr;
|
||||
bool ret = false;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
if (N < WORDSIZE)
|
||||
{
|
||||
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
|
||||
shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
|
||||
mask = SIZE(MASK) << shift;
|
||||
}
|
||||
else
|
||||
{
|
||||
wptr = (UWORD *)mptr;
|
||||
shift = 0;
|
||||
mask = -1;
|
||||
}
|
||||
|
||||
weval = *eptr << shift;
|
||||
wnewval = (UWORD)newval << shift;
|
||||
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
|
||||
do
|
||||
{
|
||||
if ((woldval & mask) != weval)
|
||||
goto failure;
|
||||
t = (woldval & ~mask) | wnewval;
|
||||
}
|
||||
while (!atomic_compare_exchange_w (wptr, &woldval, t, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED));
|
||||
ret = true;
|
||||
failure:
|
||||
*eptr = woldval >> shift;
|
||||
|
||||
post_barrier (smodel);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_CAS && N <= WORDSIZE */
|
||||
|
||||
|
||||
/* Otherwise, fall back to some sort of protection mechanism. */
|
||||
#if !DONE
|
||||
bool
|
||||
SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
|
||||
int smodel, int fmodel UNUSED)
|
||||
{
|
||||
UTYPE oldval;
|
||||
UWORD magic;
|
||||
bool ret = false;
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
magic = protect_start (mptr);
|
||||
|
||||
oldval = *mptr;
|
||||
if (oldval == *eptr)
|
||||
{
|
||||
*mptr = newval;
|
||||
ret = true;
|
||||
}
|
||||
*eptr = oldval;
|
||||
|
||||
protect_end (mptr, magic);
|
||||
post_seq_barrier (smodel);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
EXPORT_ALIAS (SIZE(compare_exchange));
|
75
libatomic/config/arm/arm-config.h
Normal file
75
libatomic/config/arm/arm-config.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
#if defined(__ARM_ARCH_2__)
|
||||
# define __ARM_ARCH__ 2
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_ARCH_3__)
|
||||
# define __ARM_ARCH__ 3
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_ARCH_3M__) || defined(__ARM_ARCH_4__) \
|
||||
|| defined(__ARM_ARCH_4T__)
|
||||
/* We use __ARM_ARCH__ set to 4 here, but in reality it's any processor with
|
||||
long multiply instructions. That includes v3M. */
|
||||
# define __ARM_ARCH__ 4
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
|
||||
|| defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
|
||||
|| defined(__ARM_ARCH_5TEJ__)
|
||||
# define __ARM_ARCH__ 5
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
|
||||
|| defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
|
||||
|| defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
|
||||
|| defined(__ARM_ARCH_6M__)
|
||||
# define __ARM_ARCH__ 6
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
|
||||
|| defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
|
||||
|| defined(__ARM_ARCH_7EM__)
|
||||
# define __ARM_ARCH__ 7
|
||||
#endif
|
||||
|
||||
#ifndef __ARM_ARCH__
|
||||
#error Unable to determine architecture.
|
||||
#endif
|
||||
|
||||
#if __ARM_ARCH__ >= 7 || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6ZK__)
|
||||
# define HAVE_STREX 1
|
||||
# define HAVE_STREXBHD 1
|
||||
#elif __ARM_ARCH__ == 6
|
||||
# define HAVE_STREX 1
|
||||
#endif
|
||||
|
||||
#if __ARM_ARCH__ >= 7
|
||||
# define HAVE_DMB 1
|
||||
#elif __ARM_ARCH__ == 6
|
||||
# define HAVE_DMB_MCR 1
|
||||
#endif
|
114
libatomic/config/arm/exch_n.c
Normal file
114
libatomic/config/arm/exch_n.c
Normal file
|
@ -0,0 +1,114 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libatomic_i.h>
|
||||
#include <arm-config.h>
|
||||
|
||||
|
||||
/* When using STREX to implement sub-word exchange, we can do much better
|
||||
than the compiler by using the APSR.GE and APSR.C flags. */
|
||||
|
||||
#if !DONE && HAVE_STREX && !HAVE_STREXBH && N == 2
|
||||
UTYPE
|
||||
SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
UWORD t1, t2;
|
||||
UTYPE oldval;
|
||||
|
||||
__atomic_thread_fence (__ATOMIC_SEQ_CST);
|
||||
|
||||
/* In the N=2 case, there are only two cases for MPTR: mptr % 4 == {0,2}.
|
||||
Rather than computing a variable shift for this, we can store the one
|
||||
bit of misalignment in the carry flag, and use conditional constant
|
||||
shifts instead. This saves a register. */
|
||||
#ifdef __ARMEB__
|
||||
# define HI "cc" /* iff value is in high half */
|
||||
# define LO "cs" /* iff value is in low half */
|
||||
#else
|
||||
# define HI "cs"
|
||||
# define LO "cc"
|
||||
#endif
|
||||
|
||||
asm volatile (
|
||||
"lsrs %[t2],%[ptr],#2\n" /* carry = mptr & 2 */
|
||||
" bic %[ptr],%[ptr],#3\n" /* align mptr */
|
||||
" itt "HI"\n"
|
||||
" lsl"HI" %[t1],%[t1],#16\n" /* shift mask into place */
|
||||
" lsl"HI" %[new],%[new],#16\n" /* shift newval into place */
|
||||
" uadd16 %[t1],%[t1],%[t1]\n" /* copy mask into APSR.GE */
|
||||
"0: ldrex %[t2],[%[ptr]]\n"
|
||||
" ite "LO"\n"
|
||||
" uxth"LO" %[old],%[t2]\n" /* return old value */
|
||||
" uxth"HI" %[old],%[t2], ror #16\n"
|
||||
" sel %[t1],%[new],%[t2]\n" /* merge newval */
|
||||
" strex %[t2],%[t1],[%[ptr]]\n"
|
||||
" tst %[t2],%[t2]\n" /* dont clobber carry */
|
||||
" bne 0b"
|
||||
: [old] "=&r"(oldval), [t1] "=&r"(t1), [t2] "=&r"(t2),
|
||||
[ptr] "+r"(mptr), [new] "+r"(newval)
|
||||
: "1"(0xffff)
|
||||
: "memory");
|
||||
|
||||
__atomic_thread_fence (__ATOMIC_SEQ_CST);
|
||||
|
||||
return oldval;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* !HAVE_STREXBH && N == 2 */
|
||||
|
||||
|
||||
#if !DONE && HAVE_STREX && !HAVE_STREXBH && N == 1
|
||||
UTYPE
|
||||
SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
UWORD *wptr, woldval, wnewval, shift, mask, t1, t2;
|
||||
|
||||
__atomic_thread_fence (__ATOMIC_SEQ_CST);
|
||||
|
||||
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
|
||||
shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ INVERT_MASK_1;
|
||||
mask = MASK_1 << shift;
|
||||
wnewval = newval << shift;
|
||||
|
||||
asm volatile (
|
||||
"uadd8 %[t1],%[t1],%[t1]\n" /* move mask to APSR.GE */
|
||||
"0: ldrex %[old],[%[wptr]]\n"
|
||||
" sel %[t1],%[new],%[old]\n" /* merge newval */
|
||||
" strex %[t2],%[t1],[%[wptr]]\n"
|
||||
" cmp %[t2],#0\n"
|
||||
" bne 0b"
|
||||
: [old] "=&r"(woldval), [t1] "=&r"(t1), [t2] "=&r"(t2)
|
||||
: [new] "r"(wnewval), [wptr] "r"(wptr), "1"(mask)
|
||||
: "memory");
|
||||
|
||||
__atomic_thread_fence (__ATOMIC_SEQ_CST);
|
||||
|
||||
return woldval >> shift;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* !HAVE_STREXBH && N == 1 */
|
||||
|
||||
#include "../../exch_n.c"
|
4
libatomic/config/arm/host-config.h
Normal file
4
libatomic/config/arm/host-config.h
Normal file
|
@ -0,0 +1,4 @@
|
|||
/* Avoiding the DMB (or kernel helper) can be a good thing. */
|
||||
#define WANT_SPECIALCASE_RELAXED
|
||||
|
||||
#include_next <host-config.h>
|
5
libatomic/config/ia64/host-config.h
Normal file
5
libatomic/config/ia64/host-config.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
/* Avoiding the synchronizations are a good thing. */
|
||||
#define WANT_SPECIALCASE_RELAXED
|
||||
#define WANT_SPECIALCASE_ACQREL
|
||||
|
||||
#include_next <host-config.h>
|
179
libatomic/config/linux/arm/host-config.h
Normal file
179
libatomic/config/linux/arm/host-config.h
Normal file
|
@ -0,0 +1,179 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config/arm/arm-config.h>
|
||||
|
||||
|
||||
/* Kernel helper for 32-bit compare-and-exchange. */
|
||||
typedef int (__kernel_cmpxchg_t) (UWORD oldval, UWORD newval, UWORD *ptr);
|
||||
#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *) 0xffff0fc0)
|
||||
|
||||
/* Kernel helper for 64-bit compare-and-exchange. */
|
||||
typedef int (__kernel_cmpxchg64_t) (const U_8 * oldval, const U_8 * newval,
|
||||
U_8 *ptr);
|
||||
#define __kernel_cmpxchg64 (*(__kernel_cmpxchg64_t *) 0xffff0f60)
|
||||
|
||||
/* Kernel helper for memory barrier. */
|
||||
typedef void (__kernel_dmb_t) (void);
|
||||
#define __kernel_dmb (*(__kernel_dmb_t *) 0xffff0fa0)
|
||||
|
||||
/* Kernel helper page version number. */
|
||||
#define __kernel_helper_version (*(unsigned int *)0xffff0ffc)
|
||||
|
||||
|
||||
#ifndef HAVE_STREX
|
||||
static inline bool
|
||||
atomic_compare_exchange_w (UWORD *mptr, UWORD *eptr, UWORD newval,
|
||||
bool weak_p UNUSED, int sm UNUSED, int fm UNUSED)
|
||||
{
|
||||
bool ret = true;
|
||||
UWORD oldval;
|
||||
|
||||
oldval = *eptr;
|
||||
if (__builtin_expect (__kernel_cmpxchg (oldval, newval, mptr) != 0, 0))
|
||||
{
|
||||
oldval = *mptr;
|
||||
ret = false;
|
||||
}
|
||||
*eptr = oldval;
|
||||
|
||||
return ret;
|
||||
}
|
||||
# define atomic_compare_exchange_w atomic_compare_exchange_w
|
||||
# if N == WORDSIZE
|
||||
# define atomic_compare_exchange_n atomic_compare_exchange_w
|
||||
# endif
|
||||
#endif /* HAVE_STREX */
|
||||
|
||||
#if !defined(HAVE_STREXBHD) && defined(HAVE_KERNEL64) && N == 8
|
||||
static inline bool
|
||||
atomic_compare_exchange_n (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
|
||||
bool weak_p UNUSED, int sm UNUSED, int fm UNUSED)
|
||||
{
|
||||
if (__kernel_cmpxchg64 (eptr, &newval, mptr) == 0)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
*eptr = *mptr;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#define atomic_compare_exchange_n atomic_compare_exchange_n
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_DMB) && !defined(HAVE_DMB_MCR)
|
||||
static inline void
|
||||
pre_barrier(int model UNUSED)
|
||||
{
|
||||
__kernel_dmb ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
post_barrier(int model UNUSED)
|
||||
{
|
||||
__kernel_dmb ();
|
||||
}
|
||||
# define pre_post_barrier 1
|
||||
#endif /* !HAVE_DMB */
|
||||
|
||||
#if HAVE_IFUNC
|
||||
extern bool libat_have_strexbhd HIDDEN;
|
||||
|
||||
# define IFUNC_COND_1 libat_have_strexbhd
|
||||
# define IFUNC_COND_2 (__kernel_helper_version >= 5)
|
||||
|
||||
/* Alternative 1 is -march=armv7-a -- we have everything native. */
|
||||
# if IFUNC_ALT == 1
|
||||
# undef HAVE_ATOMIC_CAS_1
|
||||
# undef HAVE_ATOMIC_CAS_2
|
||||
# undef HAVE_ATOMIC_CAS_4
|
||||
# undef HAVE_ATOMIC_CAS_8
|
||||
# undef HAVE_ATOMIC_EXCHANGE_1
|
||||
# undef HAVE_ATOMIC_EXCHANGE_2
|
||||
# undef HAVE_ATOMIC_EXCHANGE_4
|
||||
# undef HAVE_ATOMIC_EXCHANGE_8
|
||||
# undef HAVE_ATOMIC_LDST_1
|
||||
# undef HAVE_ATOMIC_LDST_2
|
||||
# undef HAVE_ATOMIC_LDST_4
|
||||
# undef HAVE_ATOMIC_LDST_8
|
||||
# undef HAVE_ATOMIC_FETCH_OP_1
|
||||
# undef HAVE_ATOMIC_FETCH_OP_2
|
||||
# undef HAVE_ATOMIC_FETCH_OP_4
|
||||
# undef HAVE_ATOMIC_FETCH_OP_8
|
||||
# undef HAVE_ATOMIC_TAS_1
|
||||
# undef HAVE_ATOMIC_TAS_2
|
||||
# undef HAVE_ATOMIC_TAS_4
|
||||
# undef HAVE_ATOMIC_TAS_8
|
||||
# define HAVE_ATOMIC_CAS_1 1
|
||||
# define HAVE_ATOMIC_CAS_2 1
|
||||
# define HAVE_ATOMIC_CAS_4 1
|
||||
# define HAVE_ATOMIC_CAS_8 1
|
||||
# define HAVE_ATOMIC_EXCHANGE_1 1
|
||||
# define HAVE_ATOMIC_EXCHANGE_2 1
|
||||
# define HAVE_ATOMIC_EXCHANGE_4 1
|
||||
# define HAVE_ATOMIC_EXCHANGE_8 1
|
||||
# define HAVE_ATOMIC_LDST_1 1
|
||||
# define HAVE_ATOMIC_LDST_2 1
|
||||
# define HAVE_ATOMIC_LDST_4 1
|
||||
# define HAVE_ATOMIC_LDST_8 1
|
||||
# define HAVE_ATOMIC_FETCH_OP_1 1
|
||||
# define HAVE_ATOMIC_FETCH_OP_2 1
|
||||
# define HAVE_ATOMIC_FETCH_OP_4 1
|
||||
# define HAVE_ATOMIC_FETCH_OP_8 1
|
||||
# define HAVE_ATOMIC_TAS_1 1
|
||||
# define HAVE_ATOMIC_TAS_2 1
|
||||
# define HAVE_ATOMIC_TAS_4 1
|
||||
# define HAVE_ATOMIC_TAS_8 1
|
||||
# endif /* IFUNC_ALT == 1 */
|
||||
|
||||
# undef MAYBE_HAVE_ATOMIC_CAS_1
|
||||
# define MAYBE_HAVE_ATOMIC_CAS_1 IFUNC_COND_1
|
||||
# undef MAYBE_HAVE_ATOMIC_EXCHANGE_1
|
||||
# define MAYBE_HAVE_ATOMIC_EXCHANGE_1 MAYBE_HAVE_ATOMIC_CAS_1
|
||||
# undef MAYBE_HAVE_ATOMIC_LDST_1
|
||||
# define MAYBE_HAVE_ATOMIC_LDST_1 MAYBE_HAVE_ATOMIC_CAS_1
|
||||
# undef MAYBE_HAVE_ATOMIC_CAS_2
|
||||
# define MAYBE_HAVE_ATOMIC_CAS_2 IFUNC_COND_1
|
||||
# undef MAYBE_HAVE_ATOMIC_EXCHANGE_2
|
||||
# define MAYBE_HAVE_ATOMIC_EXCHANGE_2 MAYBE_HAVE_ATOMIC_CAS_2
|
||||
# undef MAYBE_HAVE_ATOMIC_LDST_2
|
||||
# define MAYBE_HAVE_ATOMIC_LDST_2 MAYBE_HAVE_ATOMIC_CAS_2
|
||||
# undef MAYBE_HAVE_ATOMIC_CAS_4
|
||||
# define MAYBE_HAVE_ATOMIC_CAS_4 IFUNC_COND_1
|
||||
# undef MAYBE_HAVE_ATOMIC_EXCHANGE_4
|
||||
# define MAYBE_HAVE_ATOMIC_EXCHANGE_4 MAYBE_HAVE_ATOMIC_CAS_4
|
||||
# undef MAYBE_HAVE_ATOMIC_LDST_4
|
||||
# define MAYBE_HAVE_ATOMIC_LDST_4 MAYBE_HAVE_ATOMIC_CAS_4
|
||||
# undef MAYBE_HAVE_ATOMIC_CAS_8
|
||||
# define MAYBE_HAVE_ATOMIC_CAS_8 (IFUNC_COND_1 | IFUNC_COND_2)
|
||||
# undef MAYBE_HAVE_ATOMIC_EXCHANGE_8
|
||||
# define MAYBE_HAVE_ATOMIC_EXCHANGE_8 MAYBE_HAVE_ATOMIC_CAS_8
|
||||
# undef MAYBE_HAVE_ATOMIC_LDST_8
|
||||
# define MAYBE_HAVE_ATOMIC_LDST_8 MAYBE_HAVE_ATOMIC_CAS_8
|
||||
|
||||
# define IFUNC_NCOND(N) (N == 8 ? 2 : 1)
|
||||
|
||||
#endif /* HAVE_IFUNC */
|
||||
|
||||
#include_next <host-config.h>
|
36
libatomic/config/linux/arm/init.c
Normal file
36
libatomic/config/linux/arm/init.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
#if HAVE_IFUNC
|
||||
|
||||
bool libat_have_strexbhd;
|
||||
|
||||
static void __attribute__((constructor))
|
||||
init_cpu_revision (void)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* HAVE_IFUNC */
|
49
libatomic/config/linux/arm/load_n.c
Normal file
49
libatomic/config/linux/arm/load_n.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we use the builtin we'll get __sync_synchronize, not __kernel_dmb. */
|
||||
#if !DONE && N <= WORDSIZE && !defined(HAVE_DMB) && !defined(HAVE_DMB_MCR)
|
||||
UTYPE
|
||||
SIZE(libat_load) (UTYPE *mptr, int smodel)
|
||||
{
|
||||
UTYPE ret;
|
||||
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
ret = *mptr;
|
||||
else
|
||||
{
|
||||
__kernel_dmb ();
|
||||
ret = *mptr;
|
||||
__kernel_dmb ();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* !HAVE_DMB */
|
||||
|
||||
#include "../../../load_n.c"
|
46
libatomic/config/linux/arm/store_n.c
Normal file
46
libatomic/config/linux/arm/store_n.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we use the builtin we'll get __sync_synchronize, not __kernel_dmb. */
|
||||
#if !DONE && N <= WORDSIZE && !defined(HAVE_DMB) && !defined(HAVE_DMB_MCR)
|
||||
void
|
||||
SIZE(libat_store) (UTYPE *mptr, UTYPE val, int smodel)
|
||||
{
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
*mptr = val;
|
||||
else
|
||||
{
|
||||
__kernel_dmb ();
|
||||
*mptr = val;
|
||||
__kernel_dmb ();
|
||||
}
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* !HAVE_DMB */
|
||||
|
||||
#include "../../../store_n.c"
|
55
libatomic/config/posix/host-config.h
Normal file
55
libatomic/config/posix/host-config.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Included after all more target-specific host-config.h. */
|
||||
|
||||
|
||||
#ifndef protect_start_end
|
||||
# ifdef HAVE_ATTRIBUTE_VISIBILITY
|
||||
# pragma GCC visibility push(hidden)
|
||||
# endif
|
||||
|
||||
void libat_lock_1 (void *ptr);
|
||||
void libat_unlock_1 (void *ptr);
|
||||
|
||||
static inline UWORD
|
||||
protect_start (void *ptr)
|
||||
{
|
||||
libat_lock_1 (ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
protect_end (void *ptr, UWORD dummy UNUSED)
|
||||
{
|
||||
libat_unlock_1 (ptr);
|
||||
}
|
||||
|
||||
# define protect_start_end 1
|
||||
# ifdef HAVE_ATTRIBUTE_VISIBILITY
|
||||
# pragma GCC visibility pop
|
||||
# endif
|
||||
#endif /* protect_start_end */
|
||||
|
||||
#include_next <host-config.h>
|
116
libatomic/config/posix/lock.c
Normal file
116
libatomic/config/posix/lock.c
Normal file
|
@ -0,0 +1,116 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
/* The target page size. Must be no larger than the runtime page size,
|
||||
lest locking fail with virtual address aliasing (i.e. a page mmaped
|
||||
at two locations). */
|
||||
#ifndef PAGE_SIZE
|
||||
#define PAGE_SIZE 4096
|
||||
#endif
|
||||
|
||||
/* The target cacheline size. This is an optimization; the padding that
|
||||
should be applied to the locks to keep them from interfering. */
|
||||
#ifndef CACHLINE_SIZE
|
||||
#define CACHLINE_SIZE 64
|
||||
#endif
|
||||
|
||||
/* The granularity at which locks are applied. Almost certainly the
|
||||
cachline size is the right thing to use here. */
|
||||
#ifndef WATCH_SIZE
|
||||
#define WATCH_SIZE CACHLINE_SIZE
|
||||
#endif
|
||||
|
||||
struct lock
|
||||
{
|
||||
pthread_mutex_t mutex;
|
||||
char pad[sizeof(pthread_mutex_t) < CACHLINE_SIZE
|
||||
? CACHLINE_SIZE - sizeof(pthread_mutex_t)
|
||||
: 0];
|
||||
};
|
||||
|
||||
#define NLOCKS (PAGE_SIZE / WATCH_SIZE)
|
||||
static struct lock locks[NLOCKS] = {
|
||||
[0 ... NLOCKS-1].mutex = PTHREAD_MUTEX_INITIALIZER
|
||||
};
|
||||
|
||||
static inline uintptr_t
|
||||
addr_hash (void *ptr)
|
||||
{
|
||||
return ((uintptr_t)ptr / WATCH_SIZE) % NLOCKS;
|
||||
}
|
||||
|
||||
void
|
||||
libat_lock_1 (void *ptr)
|
||||
{
|
||||
pthread_mutex_lock (&locks[addr_hash (ptr)].mutex);
|
||||
}
|
||||
|
||||
void
|
||||
libat_unlock_1 (void *ptr)
|
||||
{
|
||||
pthread_mutex_unlock (&locks[addr_hash (ptr)].mutex);
|
||||
}
|
||||
|
||||
void
|
||||
libat_lock_n (void *ptr, size_t n)
|
||||
{
|
||||
uintptr_t h = addr_hash (ptr);
|
||||
size_t i = 0;
|
||||
|
||||
/* Don't lock more than all the locks we have. */
|
||||
if (n > PAGE_SIZE)
|
||||
n = PAGE_SIZE;
|
||||
|
||||
do
|
||||
{
|
||||
pthread_mutex_lock (&locks[h].mutex);
|
||||
if (++h == NLOCKS)
|
||||
h = 0;
|
||||
i += WATCH_SIZE;
|
||||
}
|
||||
while (i < n);
|
||||
}
|
||||
|
||||
void
|
||||
libat_unlock_n (void *ptr, size_t n)
|
||||
{
|
||||
uintptr_t h = addr_hash (ptr);
|
||||
size_t i = 0;
|
||||
|
||||
if (n > PAGE_SIZE)
|
||||
n = PAGE_SIZE;
|
||||
|
||||
do
|
||||
{
|
||||
pthread_mutex_unlock (&locks[h].mutex);
|
||||
if (++h == NLOCKS)
|
||||
h = 0;
|
||||
i += WATCH_SIZE;
|
||||
}
|
||||
while (i < n);
|
||||
}
|
24
libatomic/config/powerpc/host-config.h
Normal file
24
libatomic/config/powerpc/host-config.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/* Avoiding the synchronizations are a good thing. */
|
||||
#define WANT_SPECIALCASE_RELAXED
|
||||
#define WANT_SPECIALCASE_ACQREL
|
||||
|
||||
/* Glibc, at least, uses lwsync (aka acq_rel) in its pthread mutex
|
||||
implementation. If the user is asking for seq_cst (aka hwsync),
|
||||
this is insufficient. */
|
||||
|
||||
static inline void __attribute__((always_inline, artificial))
|
||||
pre_seq_barrier(int model)
|
||||
{
|
||||
if (model == __ATOMIC_SEQ_CST)
|
||||
__atomic_thread_fence (__ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
static inline void __attribute__((always_inline, artificial))
|
||||
post_seq_barrier(int model)
|
||||
{
|
||||
pre_seq_barrier(model);
|
||||
}
|
||||
|
||||
#define pre_post_seq_barrier 1
|
||||
|
||||
#include_next <host-config.h>
|
69
libatomic/config/x86/host-config.h
Normal file
69
libatomic/config/x86/host-config.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#if HAVE_IFUNC
|
||||
#include <cpuid.h>
|
||||
|
||||
extern unsigned int libat_feat1_ecx HIDDEN;
|
||||
extern unsigned int libat_feat1_edx HIDDEN;
|
||||
|
||||
#ifdef __x86_64__
|
||||
# define IFUNC_COND_1 (libat_feat1_ecx & bit_CMPXCHG16B)
|
||||
#else
|
||||
# define IFUNC_COND_1 (libat_feat1_edx & bit_CMPXCHG8B)
|
||||
#endif
|
||||
|
||||
#ifdef __x86_64__
|
||||
# define IFUNC_NCOND(N) (N == 16)
|
||||
#else
|
||||
# define IFUNC_NCOND(N) (N == 8)
|
||||
#endif
|
||||
|
||||
#ifdef __x86_64__
|
||||
# undef MAYBE_HAVE_ATOMIC_CAS_16
|
||||
# define MAYBE_HAVE_ATOMIC_CAS_16 IFUNC_COND_1
|
||||
# undef MAYBE_HAVE_ATOMIC_EXCHANGE_16
|
||||
# define MAYBE_HAVE_ATOMIC_EXCHANGE_16 IFUNC_COND_1
|
||||
# undef MAYBE_HAVE_ATOMIC_LDST_16
|
||||
# define MAYBE_HAVE_ATOMIC_LDST_16 IFUNC_COND_1
|
||||
# if IFUNC_ALT == 1
|
||||
# undef HAVE_ATOMIC_CAS_16
|
||||
# define HAVE_ATOMIC_CAS_16 1
|
||||
# endif
|
||||
#else
|
||||
# undef MAYBE_HAVE_ATOMIC_CAS_8
|
||||
# define MAYBE_HAVE_ATOMIC_CAS_8 IFUNC_COND_1
|
||||
# undef MAYBE_HAVE_ATOMIC_EXCHANGE_8
|
||||
# define MAYBE_HAVE_ATOMIC_EXCHANGE_8 IFUNC_COND_1
|
||||
# undef MAYBE_HAVE_ATOMIC_LDST_8
|
||||
# define MAYBE_HAVE_ATOMIC_LDST_8 IFUNC_COND_1
|
||||
# if IFUNC_ALT == 1
|
||||
# undef HAVE_ATOMIC_CAS_8
|
||||
# define HAVE_ATOMIC_CAS_8 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_IFUNC */
|
||||
|
||||
#include_next <host-config.h>
|
38
libatomic/config/x86/init.c
Normal file
38
libatomic/config/x86/init.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
#if HAVE_IFUNC
|
||||
|
||||
unsigned int libat_feat1_ecx, libat_feat1_edx;
|
||||
|
||||
static void __attribute__((constructor))
|
||||
init_cpuid (void)
|
||||
{
|
||||
unsigned int eax, ebx;
|
||||
__get_cpuid (1, &eax, &ebx, &libat_feat1_ecx, &libat_feat1_edx);
|
||||
}
|
||||
|
||||
#endif /* HAVE_IFUNC */
|
17809
libatomic/configure
vendored
Executable file
17809
libatomic/configure
vendored
Executable file
File diff suppressed because it is too large
Load diff
255
libatomic/configure.ac
Normal file
255
libatomic/configure.ac
Normal file
|
@ -0,0 +1,255 @@
|
|||
# Process this file with autoreconf to produce a configure script.
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of the GNU Atomic Library (libatomic).
|
||||
#
|
||||
# Libatomic is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# Under Section 7 of GPL version 3, you are granted additional
|
||||
# permissions described in the GCC Runtime Library Exception, version
|
||||
# 3.1, as published by the Free Software Foundation.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License and
|
||||
# a copy of the GCC Runtime Library Exception along with this program;
|
||||
# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT([GNU Atomic Library], 1.0,,[libatomic])
|
||||
AC_CONFIG_HEADER(auto-config.h)
|
||||
|
||||
# -------
|
||||
# Options
|
||||
# -------
|
||||
|
||||
AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
|
||||
LIBAT_ENABLE(version-specific-runtime-libs, no, ,
|
||||
[Specify that runtime libraries should be installed in a compiler-specific directory],
|
||||
permit yes|no)
|
||||
AC_MSG_RESULT($enable_version_specific_runtime_libs)
|
||||
|
||||
# We would like our source tree to be readonly. However when releases or
|
||||
# pre-releases are generated, the flex/bison generated files as well as the
|
||||
# various formats of manuals need to be included along with the rest of the
|
||||
# sources. Therefore we have --enable-generated-files-in-srcdir to do
|
||||
# just that.
|
||||
AC_MSG_CHECKING([for --enable-generated-files-in-srcdir])
|
||||
LIBAT_ENABLE(generated-files-in-srcdir, no, ,
|
||||
[put copies of generated files in source dir intended for creating source
|
||||
tarballs for users without texinfo bison or flex.],
|
||||
permit yes|no)
|
||||
AC_MSG_RESULT($enable_generated_files_in_srcdir)
|
||||
AM_CONDITIONAL(GENINSRC, test "$enable_generated_files_in_srcdir" = yes)
|
||||
|
||||
|
||||
# -------
|
||||
|
||||
# Gets build, host, target, *_vendor, *_cpu, *_os, etc.
|
||||
#
|
||||
# You will slowly go insane if you do not grok the following fact: when
|
||||
# building this library, the top-level /target/ becomes the library's /host/.
|
||||
#
|
||||
# configure then causes --target to default to --host, exactly like any
|
||||
# other package using autoconf. Therefore, 'target' and 'host' will
|
||||
# always be the same. This makes sense both for native and cross compilers
|
||||
# just think about it for a little while. :-)
|
||||
#
|
||||
# Also, if this library is being configured as part of a cross compiler, the
|
||||
# top-level configure script will pass the "real" host as $with_cross_host.
|
||||
#
|
||||
# Do not delete or change the following two lines. For why, see
|
||||
# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
|
||||
AC_CANONICAL_SYSTEM
|
||||
target_alias=${target_alias-$host_alias}
|
||||
|
||||
# Sets up automake. Must come after AC_CANONICAL_SYSTEM. Each of the
|
||||
# following is magically included in AUTOMAKE_OPTIONS in each Makefile.am.
|
||||
# 1.9.0: minimum required version
|
||||
# no-define: PACKAGE and VERSION will not be #define'd in config.h (a bunch
|
||||
# of other PACKAGE_* variables will, however, and there's nothing
|
||||
# we can do about that; they come from AC_INIT).
|
||||
# foreign: we don't follow the normal rules for GNU packages (no COPYING
|
||||
# file in the top srcdir, etc, etc), so stop complaining.
|
||||
# -Wall: turns on all automake warnings...
|
||||
# -Wno-portability: ...except this one, since GNU make is required.
|
||||
# -Wno-override: ... and this one, since we do want this in testsuite.
|
||||
AM_INIT_AUTOMAKE([1.9.0 foreign -Wall -Wno-portability -Wno-override])
|
||||
AM_ENABLE_MULTILIB(, ..)
|
||||
|
||||
# Calculate toolexeclibdir
|
||||
# Also toolexecdir, though it's only used in toolexeclibdir
|
||||
case ${enable_version_specific_runtime_libs} in
|
||||
yes)
|
||||
# Need the gcc compiler version to know where to install libraries
|
||||
# and header files if --enable-version-specific-runtime-libs option
|
||||
# is selected.
|
||||
toolexecdir='$(libdir)/gcc/$(target_alias)'
|
||||
toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
|
||||
;;
|
||||
no)
|
||||
if test -n "$with_cross_host" &&
|
||||
test x"$with_cross_host" != x"no"; then
|
||||
# Install a library built with a cross compiler in tooldir, not libdir.
|
||||
toolexecdir='$(exec_prefix)/$(target_alias)'
|
||||
toolexeclibdir='$(toolexecdir)/lib'
|
||||
else
|
||||
toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
|
||||
toolexeclibdir='$(libdir)'
|
||||
fi
|
||||
multi_os_directory=`$CC -print-multi-os-directory`
|
||||
case $multi_os_directory in
|
||||
.) ;; # Avoid trailing /.
|
||||
*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(toolexecdir)
|
||||
AC_SUBST(toolexeclibdir)
|
||||
|
||||
# Check the compiler.
|
||||
# The same as in boehm-gc and libstdc++. Have to borrow it from there.
|
||||
# We must force CC to /not/ be precious variables; otherwise
|
||||
# the wrong, non-multilib-adjusted value will be used in multilibs.
|
||||
# As a side effect, we have to subst CFLAGS ourselves.
|
||||
|
||||
m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
|
||||
m4_define([_AC_ARG_VAR_PRECIOUS],[])
|
||||
AC_PROG_CC
|
||||
AM_PROG_AS
|
||||
m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
|
||||
# In order to override CFLAGS_FOR_TARGET, all of our special flags go
|
||||
# in XCFLAGS. But we need them in CFLAGS during configury. So put them
|
||||
# in both places for now and restore CFLAGS at the end of config.
|
||||
save_CFLAGS="$CFLAGS"
|
||||
|
||||
# Find other programs we need.
|
||||
AC_CHECK_TOOL(AR, ar)
|
||||
AC_CHECK_TOOL(NM, nm)
|
||||
AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
|
||||
AC_PATH_PROG(PERL, perl, perl-not-found-in-path-error)
|
||||
AC_PROG_INSTALL
|
||||
|
||||
# Configure libtool
|
||||
AM_PROG_LIBTOOL
|
||||
AC_SUBST(enable_shared)
|
||||
AC_SUBST(enable_static)
|
||||
|
||||
# For libtool versioning info, format is CURRENT:REVISION:AGE
|
||||
libtool_VERSION=1:0:0
|
||||
AC_SUBST(libtool_VERSION)
|
||||
|
||||
# Get target configury.
|
||||
. ${srcdir}/configure.tgt
|
||||
if test -n "$UNSUPPORTED"; then
|
||||
AC_MSG_ERROR([Configuration ${target} is unsupported.])
|
||||
fi
|
||||
|
||||
# Disable fallbacks to __sync routines from libgcc. Otherwise we'll
|
||||
# make silly decisions about what the cpu can do.
|
||||
CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS"
|
||||
|
||||
# Check header files.
|
||||
AC_STDC_HEADERS
|
||||
ACX_HEADER_STRING
|
||||
GCC_HEADER_STDINT(gstdint.h)
|
||||
|
||||
# Check for common type sizes
|
||||
LIBAT_FORALL_MODES([LIBAT_HAVE_INT_MODE])
|
||||
|
||||
# Check for compiler builtins of atomic operations.
|
||||
LIBAT_TEST_ATOMIC_INIT
|
||||
LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_LOADSTORE])
|
||||
LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_TAS])
|
||||
LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_EXCHANGE])
|
||||
LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_CAS])
|
||||
LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_ADD])
|
||||
LIBAT_FORALL_MODES([LIBAT_HAVE_ATOMIC_FETCH_OP])
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
# I don't like the default behaviour of WORDS_BIGENDIAN undefined for LE.
|
||||
AH_BOTTOM(
|
||||
[#ifndef WORDS_BIGENDIAN
|
||||
#define WORDS_BIGENDIAN 0
|
||||
#endif])
|
||||
|
||||
LIBAT_WORDSIZE
|
||||
|
||||
# Check to see if -pthread or -lpthread is needed. Prefer the former.
|
||||
# In case the pthread.h system header is not found, this test will fail.
|
||||
case " $config_path " in
|
||||
*" posix "*)
|
||||
XPCFLAGS=""
|
||||
CFLAGS="$CFLAGS -pthread"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[#include <pthread.h>
|
||||
void *g(void *d) { return NULL; }],
|
||||
[pthread_t t; pthread_create(&t,NULL,g,NULL);])],
|
||||
[XPCFLAGS=" -pthread"],
|
||||
[CFLAGS="$save_CFLAGS $XCFLAGS" LIBS="-lpthread $LIBS"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[#include <pthread.h>
|
||||
void *g(void *d) { return NULL; }],
|
||||
[pthread_t t; pthread_create(&t,NULL,g,NULL);])],
|
||||
[],
|
||||
[AC_MSG_ERROR([Pthreads are required to build libatomic])])])
|
||||
CFLAGS="$save_CFLAGS $XCFLAGS"
|
||||
;;
|
||||
esac
|
||||
|
||||
# See what sort of export controls are available.
|
||||
LIBAT_CHECK_ATTRIBUTE_VISIBILITY
|
||||
LIBAT_CHECK_ATTRIBUTE_DLLEXPORT
|
||||
LIBAT_CHECK_ATTRIBUTE_ALIAS
|
||||
if test x$try_ifunc = xyes; then
|
||||
LIBAT_CHECK_IFUNC
|
||||
fi
|
||||
|
||||
# Check linker support.
|
||||
LIBAT_ENABLE_SYMVERS
|
||||
|
||||
# Cleanup and exit.
|
||||
CFLAGS="$save_CFLAGS"
|
||||
AC_CACHE_SAVE
|
||||
|
||||
# Add -Wall -Werror if we are using GCC.
|
||||
if test "x$GCC" = "xyes"; then
|
||||
XCFLAGS="$XCFLAGS -Wall -Werror"
|
||||
fi
|
||||
|
||||
XCFLAGS="$XCFLAGS $XPCFLAGS"
|
||||
|
||||
AC_SUBST(config_path)
|
||||
AC_SUBST(XCFLAGS)
|
||||
AC_SUBST(XLDFLAGS)
|
||||
AC_SUBST(LIBS)
|
||||
AC_SUBST(SIZES)
|
||||
|
||||
AM_CONDITIONAL(HAVE_IFUNC, test x$libat_cv_have_ifunc = xyes)
|
||||
AM_CONDITIONAL(ARCH_ARM_LINUX,
|
||||
[expr "$config_path" : ".* linux/arm .*" > /dev/null])
|
||||
AM_CONDITIONAL(ARCH_I386,
|
||||
[test "$ARCH" = x86 && test x$libat_cv_wordsize = x4])
|
||||
AM_CONDITIONAL(ARCH_X86_64,
|
||||
[test "$ARCH" = x86 && test x$libat_cv_wordsize = x8])
|
||||
|
||||
if test ${multilib} = yes; then
|
||||
multilib_arg="--enable-multilib"
|
||||
else
|
||||
multilib_arg=
|
||||
fi
|
||||
|
||||
AC_CONFIG_FILES(Makefile testsuite/Makefile)
|
||||
AC_OUTPUT
|
124
libatomic/configure.tgt
Normal file
124
libatomic/configure.tgt
Normal file
|
@ -0,0 +1,124 @@
|
|||
# -*- shell-script -*-
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
# Contributed by Richard Henderson <rth@redhat.com>.
|
||||
#
|
||||
# This file is part of the GNU Atomic Library (libatomic).
|
||||
#
|
||||
# Libatomic is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
# more details.
|
||||
#
|
||||
# Under Section 7 of GPL version 3, you are granted additional
|
||||
# permissions described in the GCC Runtime Library Exception, version
|
||||
# 3.1, as published by the Free Software Foundation.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License and
|
||||
# a copy of the GCC Runtime Library Exception along with this program;
|
||||
# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Map the target cpu to an ARCH sub-directory. At the same time,
|
||||
# work out any special compilation flags as necessary.
|
||||
|
||||
case "${target_cpu}" in
|
||||
alpha*) ARCH=alpha ;;
|
||||
rs6000 | powerpc*) ARCH=powerpc ;;
|
||||
sh*) ARCH=sh ;;
|
||||
|
||||
arm*)
|
||||
ARCH=arm
|
||||
# ??? Detect when -march=armv7 is already enabled.
|
||||
try_ifunc=yes
|
||||
;;
|
||||
|
||||
sparc)
|
||||
case " ${CC} ${CFLAGS} " in
|
||||
*" -m64 "*)
|
||||
;;
|
||||
*)
|
||||
if test -z "$with_cpu"; then
|
||||
XCFLAGS="${XCFLAGS} -mcpu=v9"
|
||||
fi
|
||||
esac
|
||||
ARCH=sparc
|
||||
;;
|
||||
sparc64|sparcv9)
|
||||
case " ${CC} ${CFLAGS} " in
|
||||
*" -m32 "*)
|
||||
XCFLAGS="${XCFLAGS} -mcpu=v9"
|
||||
;;
|
||||
esac
|
||||
ARCH=sparc
|
||||
;;
|
||||
|
||||
i[3456]86)
|
||||
case " ${CC} ${CFLAGS} " in
|
||||
*" -m64 "*)
|
||||
;;
|
||||
*)
|
||||
if test -z "$with_arch"; then
|
||||
XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
|
||||
XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
|
||||
fi
|
||||
esac
|
||||
ARCH=x86
|
||||
# ??? Detect when -march=i686 is already enabled.
|
||||
try_ifunc=yes
|
||||
;;
|
||||
x86_64)
|
||||
case " ${CC} ${CFLAGS} " in
|
||||
*" -m32 "*)
|
||||
XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
|
||||
XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
ARCH=x86
|
||||
# ??? Detect when -mcx16 is already enabled.
|
||||
try_ifunc=yes
|
||||
;;
|
||||
|
||||
*) ARCH="${target_cpu}" ;;
|
||||
esac
|
||||
|
||||
# The cpu configury is always most relevant.
|
||||
if test -d ${srcdir}/config/$ARCH ; then
|
||||
config_path="$ARCH"
|
||||
fi
|
||||
|
||||
# Other system configury
|
||||
case "${target}" in
|
||||
arm*-*-linux*)
|
||||
# OS support for atomic primitives.
|
||||
config_path="${config_path} linux/arm posix"
|
||||
;;
|
||||
|
||||
*-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu \
|
||||
| *-*-netbsd* | *-*-freebsd* | *-*-openbsd* \
|
||||
| *-*-solaris2* | *-*-sysv4* | *-*-irix6* | *-*-osf* | *-*-hpux11* \
|
||||
| *-*-darwin* | *-*-aix*)
|
||||
# POSIX system. The OS is supported.
|
||||
config_path="${config_path} posix"
|
||||
;;
|
||||
|
||||
*-*-elf*)
|
||||
# ??? No target OS. We could be targeting bare-metal kernel-mode,
|
||||
# or user-mode for some custom OS. If the target supports TAS,
|
||||
# we can build our own spinlocks, given there are no signals.
|
||||
# If the target supports disabling interrupts, we can work in
|
||||
# kernel-mode, given the system is not multi-processor.
|
||||
UNSUPPORTED=1
|
||||
;;
|
||||
|
||||
*)
|
||||
# Who are you?
|
||||
UNSUPPORTED=1
|
||||
;;
|
||||
esac
|
128
libatomic/exch_n.c
Normal file
128
libatomic/exch_n.c
Normal file
|
@ -0,0 +1,128 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we support the builtin, just use it. */
|
||||
#if !DONE && SIZE(HAVE_ATOMIC_EXCHANGE)
|
||||
UTYPE
|
||||
SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
return __atomic_exchange_n (mptr, newval, __ATOMIC_RELAXED);
|
||||
else if (maybe_specialcase_acqrel(smodel))
|
||||
return __atomic_exchange_n (mptr, newval, __ATOMIC_ACQ_REL);
|
||||
else
|
||||
return __atomic_exchange_n (mptr, newval, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_EXCHANGE */
|
||||
|
||||
|
||||
#if !DONE && defined(atomic_compare_exchange_n)
|
||||
UTYPE
|
||||
SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
UTYPE oldval;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
oldval = *mptr;
|
||||
while (!atomic_compare_exchange_n (mptr, &oldval, newval, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
continue;
|
||||
|
||||
post_barrier (smodel);
|
||||
|
||||
return oldval;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* atomic_compare_exchange_n */
|
||||
|
||||
|
||||
/* If this type is smaller than word-sized, fall back to a word-sized
|
||||
compare-and-swap loop. */
|
||||
#if !DONE && N <= WORDSIZE && defined(atomic_compare_exchange_w)
|
||||
UTYPE
|
||||
SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
UWORD mask, shift, woldval, wnewval, t, *wptr;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
if (N < WORDSIZE)
|
||||
{
|
||||
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
|
||||
shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
|
||||
mask = SIZE(MASK) << shift;
|
||||
}
|
||||
else
|
||||
{
|
||||
wptr = (UWORD *)mptr;
|
||||
shift = 0;
|
||||
mask = -1;
|
||||
}
|
||||
|
||||
wnewval = (UWORD)newval << shift;
|
||||
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
|
||||
do
|
||||
{
|
||||
t = (woldval & ~mask) | wnewval;
|
||||
}
|
||||
while (!atomic_compare_exchange_w (wptr, &woldval, t, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED));
|
||||
|
||||
post_barrier (smodel);
|
||||
return woldval >> shift;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_CAS && N < WORDSIZE */
|
||||
|
||||
|
||||
/* Otherwise, fall back to some sort of protection mechanism. */
|
||||
#if !DONE
|
||||
UTYPE
|
||||
SIZE(libat_exchange) (UTYPE *mptr, UTYPE newval, int smodel UNUSED)
|
||||
{
|
||||
UTYPE oldval;
|
||||
UWORD magic;
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
magic = protect_start (mptr);
|
||||
|
||||
oldval = *mptr;
|
||||
*mptr = newval;
|
||||
|
||||
protect_end (mptr, magic);
|
||||
post_seq_barrier (smodel);
|
||||
|
||||
return oldval;
|
||||
}
|
||||
#endif
|
||||
|
||||
EXPORT_ALIAS (SIZE(exchange));
|
45
libatomic/fadd_n.c
Normal file
45
libatomic/fadd_n.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libatomic_i.h>
|
||||
|
||||
#define NAME add
|
||||
#define OP(X,Y) ((X) + (Y))
|
||||
|
||||
/* Defer to HAVE_ATOMIC_FETCH_ADD, which some targets implement specially,
|
||||
even if HAVE_ATOMIC_FETCH_OP is not defined. */
|
||||
#if !SIZE(HAVE_ATOMIC_FETCH_OP)
|
||||
# undef HAVE_ATOMIC_FETCH_OP_1
|
||||
# undef HAVE_ATOMIC_FETCH_OP_2
|
||||
# undef HAVE_ATOMIC_FETCH_OP_4
|
||||
# undef HAVE_ATOMIC_FETCH_OP_8
|
||||
# undef HAVE_ATOMIC_FETCH_OP_16
|
||||
# define HAVE_ATOMIC_FETCH_OP_1 HAVE_ATOMIC_FETCH_ADD_1
|
||||
# define HAVE_ATOMIC_FETCH_OP_2 HAVE_ATOMIC_FETCH_ADD_2
|
||||
# define HAVE_ATOMIC_FETCH_OP_4 HAVE_ATOMIC_FETCH_ADD_4
|
||||
# define HAVE_ATOMIC_FETCH_OP_8 HAVE_ATOMIC_FETCH_ADD_8
|
||||
# define HAVE_ATOMIC_FETCH_OP_16 HAVE_ATOMIC_FETCH_ADD_16
|
||||
#endif
|
||||
|
||||
#include "fop_n.c"
|
3
libatomic/fand_n.c
Normal file
3
libatomic/fand_n.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define NAME and
|
||||
#define OP(X,Y) ((X) & (Y))
|
||||
#include "fop_n.c"
|
3
libatomic/fior_n.c
Normal file
3
libatomic/fior_n.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define NAME or
|
||||
#define OP(X,Y) ((X) | (Y))
|
||||
#include "fop_n.c"
|
3
libatomic/fnand_n.c
Normal file
3
libatomic/fnand_n.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define NAME nand
|
||||
#define OP(X,Y) ~((X) & (Y))
|
||||
#include "fop_n.c"
|
200
libatomic/fop_n.c
Normal file
200
libatomic/fop_n.c
Normal file
|
@ -0,0 +1,200 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <libatomic_i.h>
|
||||
|
||||
|
||||
/* This file is included multiple times with required defines:
|
||||
NAME the name of the operation that we're implementing;
|
||||
OP a two-operand functional macro the implements the operation.
|
||||
*/
|
||||
|
||||
|
||||
/* If we support the builtin, just use it. */
|
||||
#if !DONE && SIZE(HAVE_ATOMIC_FETCH_OP)
|
||||
UTYPE
|
||||
SIZE(C2(libat_fetch_,NAME)) (UTYPE *mptr, UTYPE opval, int smodel)
|
||||
{
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
return C2(__atomic_fetch_,NAME) (mptr, opval, __ATOMIC_RELAXED);
|
||||
else if (maybe_specialcase_acqrel(smodel))
|
||||
return C2(__atomic_fetch_,NAME) (mptr, opval, __ATOMIC_ACQ_REL);
|
||||
else
|
||||
return C2(__atomic_fetch_,NAME) (mptr, opval, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
UTYPE
|
||||
SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel)
|
||||
{
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
return C3(__atomic_,NAME,_fetch) (mptr, opval, __ATOMIC_RELAXED);
|
||||
else if (maybe_specialcase_acqrel(smodel))
|
||||
return C3(__atomic_,NAME,_fetch) (mptr, opval, __ATOMIC_ACQ_REL);
|
||||
else
|
||||
return C3(__atomic_,NAME,_fetch) (mptr, opval, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_FETCH_OP */
|
||||
|
||||
|
||||
#if !DONE && defined(atomic_compare_exchange_n)
|
||||
UTYPE
|
||||
SIZE(C2(libat_fetch_,NAME)) (UTYPE *mptr, UTYPE opval, int smodel)
|
||||
{
|
||||
UTYPE oldval, t;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
oldval = *mptr;
|
||||
do
|
||||
{
|
||||
t = OP(oldval, opval);
|
||||
}
|
||||
while (!atomic_compare_exchange_n (mptr, &oldval, t, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED));
|
||||
|
||||
post_barrier (smodel);
|
||||
return oldval;
|
||||
}
|
||||
|
||||
UTYPE
|
||||
SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel)
|
||||
{
|
||||
UTYPE oldval, t;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
oldval = *mptr;
|
||||
do
|
||||
{
|
||||
t = OP(oldval, opval);
|
||||
}
|
||||
while (!atomic_compare_exchange_n (mptr, &oldval, t, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED));
|
||||
|
||||
post_barrier (smodel);
|
||||
return t;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* atomic_compare_exchange_n */
|
||||
|
||||
|
||||
/* If this type is no larger than word-sized, fall back to a word-sized
|
||||
compare-and-swap loop. */
|
||||
#if !DONE && N < WORDSIZE && defined(atomic_compare_exchange_w)
|
||||
UTYPE
|
||||
SIZE(C2(libat_fetch_,NAME)) (UTYPE *mptr, UTYPE opval, int smodel)
|
||||
{
|
||||
UWORD mask, shift, woldval, wopval, t, *wptr;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
wptr = (UWORD *)mptr;
|
||||
shift = 0;
|
||||
mask = -1;
|
||||
|
||||
wopval = (UWORD)opval << shift;
|
||||
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
|
||||
do
|
||||
{
|
||||
t = (woldval & ~mask) | (OP(woldval, wopval) & mask);
|
||||
}
|
||||
while (!atomic_compare_exchange_w (wptr, &woldval, t, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED));
|
||||
|
||||
post_barrier (smodel);
|
||||
return woldval >> shift;
|
||||
}
|
||||
|
||||
UTYPE
|
||||
SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel)
|
||||
{
|
||||
UWORD mask, shift, woldval, wopval, t, *wptr;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
wptr = (UWORD *)mptr;
|
||||
shift = 0;
|
||||
mask = -1;
|
||||
|
||||
wopval = (UWORD)opval << shift;
|
||||
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
|
||||
do
|
||||
{
|
||||
t = (woldval & ~mask) | (OP(woldval, wopval) & mask);
|
||||
}
|
||||
while (!atomic_compare_exchange_w (wptr, &woldval, t, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED));
|
||||
|
||||
post_barrier (smodel);
|
||||
return t >> shift;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* atomic_compare_exchange_w */
|
||||
|
||||
|
||||
/* Otherwise, fall back to some sort of protection mechanism. */
|
||||
#if !DONE
|
||||
UTYPE
|
||||
SIZE(C2(libat_fetch_,NAME)) (UTYPE *mptr, UTYPE opval, int smodel UNUSED)
|
||||
{
|
||||
UTYPE ret;
|
||||
UWORD magic;
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
magic = protect_start (mptr);
|
||||
|
||||
ret = *mptr;
|
||||
*mptr = OP(ret, opval);
|
||||
|
||||
protect_end (mptr, magic);
|
||||
post_seq_barrier (smodel);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
UTYPE
|
||||
SIZE(C3(libat_,NAME,_fetch)) (UTYPE *mptr, UTYPE opval, int smodel UNUSED)
|
||||
{
|
||||
UTYPE ret;
|
||||
UWORD magic;
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
magic = protect_start (mptr);
|
||||
|
||||
ret = OP (*mptr, opval);
|
||||
*mptr = ret;
|
||||
|
||||
protect_end (mptr, magic);
|
||||
post_seq_barrier (smodel);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
EXPORT_ALIAS (SIZE(C2(fetch_,NAME)));
|
||||
EXPORT_ALIAS (SIZE(C2(NAME,_fetch)));
|
3
libatomic/fsub_n.c
Normal file
3
libatomic/fsub_n.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define NAME sub
|
||||
#define OP(X,Y) ((X) - (Y))
|
||||
#include "fop_n.c"
|
3
libatomic/fxor_n.c
Normal file
3
libatomic/fxor_n.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
#define NAME xor
|
||||
#define OP(X,Y) ((X) ^ (Y))
|
||||
#include "fop_n.c"
|
120
libatomic/gcas.c
Normal file
120
libatomic/gcas.c
Normal file
|
@ -0,0 +1,120 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we natively support the cas, and if we're unconcerned with extra
|
||||
barriers (e.g. fully in-order cpu for which barriers are a nop), then
|
||||
go ahead and expand the operation inline. */
|
||||
#if !defined(WANT_SPECIALCASE_RELAXED) && !defined(__OPTIMIZE_SIZE__)
|
||||
# define EXACT_INLINE(N) \
|
||||
if (C2(HAVE_ATOMIC_CAS_,N)) \
|
||||
return __atomic_compare_exchange_n \
|
||||
(PTR(N,mptr), PTR(N,eptr), *PTR(N,dptr), false, smodel, fmodel)
|
||||
#else
|
||||
# define EXACT_INLINE(N)
|
||||
#endif
|
||||
|
||||
/* ... and if all that fails, invoke the function we generated elsewhere.
|
||||
Worst case, this will *also* use locks. */
|
||||
#define EXACT(N) \
|
||||
do { \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if ((uintptr_t)mptr & (N - 1)) break; \
|
||||
EXACT_INLINE (N); \
|
||||
return C3(local_,compare_exchange_,N) \
|
||||
(PTR(N,mptr), PTR(N,eptr), *PTR(N,dptr), smodel, fmodel); \
|
||||
} while (0)
|
||||
|
||||
#define LARGER(N) \
|
||||
do { \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if (!C2(HAVE_ATOMIC_LDST_,N)) break; \
|
||||
if (!C2(MAYBE_HAVE_ATOMIC_CAS_,N)) break; \
|
||||
r = (uintptr_t)mptr & (N - 1); \
|
||||
a = (uintptr_t)mptr & -N; \
|
||||
if (r + n <= N) \
|
||||
{ \
|
||||
pre_barrier (smodel); \
|
||||
u.C2(i,N) = __atomic_load_n (PTR(N,a), __ATOMIC_RELAXED); \
|
||||
do { \
|
||||
if (memcmp (u.b + r, eptr, n) != 0) goto Lfail; \
|
||||
v = u; memcpy (v.b + r, dptr, n); \
|
||||
} while (!(C2(HAVE_ATOMIC_CAS_,N) \
|
||||
? __atomic_compare_exchange_n (PTR(N,a), \
|
||||
&u.C2(i,N), v.C2(i,N), true, \
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED) \
|
||||
: C3(local_,compare_exchange_,N) (PTR(N,a), \
|
||||
&u.C2(i,N), v.C2(i,N), \
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED))); \
|
||||
goto Lsucc; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
bool
|
||||
libat_compare_exchange (size_t n, void *mptr, void *eptr, void *dptr,
|
||||
int smodel, int fmodel)
|
||||
{
|
||||
union max_size_u u, v;
|
||||
uintptr_t r, a;
|
||||
bool ret;
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 0: return true;
|
||||
case 1: EXACT(1); goto L4;
|
||||
case 2: EXACT(2); goto L4;
|
||||
case 4: EXACT(4); goto L8;
|
||||
case 8: EXACT(8); goto L16;
|
||||
case 16: EXACT(16); break;
|
||||
|
||||
case 3: L4: LARGER(4); /* FALLTHRU */
|
||||
case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
|
||||
case 9 ... 15: L16: LARGER(16); break;
|
||||
|
||||
Lsucc:
|
||||
post_barrier (smodel);
|
||||
return true;
|
||||
Lfail:
|
||||
post_barrier (fmodel);
|
||||
memcpy (eptr, u.b + r, n);
|
||||
return false;
|
||||
}
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
libat_lock_n (mptr, n);
|
||||
|
||||
ret = memcmp (mptr, eptr, n) == 0;
|
||||
memcpy ((ret ? mptr : eptr), (ret ? dptr : mptr), n);
|
||||
|
||||
libat_unlock_n (mptr, n);
|
||||
post_seq_barrier (ret ? smodel : fmodel);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT_ALIAS (compare_exchange);
|
144
libatomic/gexch.c
Normal file
144
libatomic/gexch.c
Normal file
|
@ -0,0 +1,144 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we natively support the exchange, and if we're unconcerned with extra
|
||||
barriers (e.g. fully in-order cpu for which barriers are a nop), then
|
||||
go ahead and expand the operation inline. */
|
||||
#if !defined(WANT_SPECIALCASE_RELAXED) && !defined(__OPTIMIZE_SIZE__)
|
||||
# define EXACT_INLINE(N) \
|
||||
if (C2(HAVE_ATOMIC_EXCHANGE_,N)) \
|
||||
{ \
|
||||
*PTR(N,rptr) = __atomic_exchange_n \
|
||||
(PTR(N,mptr), *PTR(N,vptr), smodel); \
|
||||
return; \
|
||||
}
|
||||
#else
|
||||
# define EXACT_INLINE(N)
|
||||
#endif
|
||||
|
||||
|
||||
#define EXACT(N) \
|
||||
do { \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if ((uintptr_t)mptr & (N - 1)) break; \
|
||||
EXACT_INLINE (N); \
|
||||
*PTR(N,rptr) = C3(local_,exchange_,N) \
|
||||
(PTR(N,mptr), *PTR(N,vptr), smodel); \
|
||||
return; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LARGER(N) \
|
||||
do { \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if (!C2(MAYBE_HAVE_ATOMIC_CAS_,N)) break; \
|
||||
r = (uintptr_t)mptr & (N - 1); \
|
||||
a = (uintptr_t)mptr & -N; \
|
||||
if (r + n <= N) \
|
||||
{ \
|
||||
pre_barrier (smodel); \
|
||||
u.C2(i,N) = *PTR(N,a); \
|
||||
do { \
|
||||
v = u; \
|
||||
memcpy (v.b + r, vptr, n); \
|
||||
} while (!(C2(HAVE_ATOMIC_CAS_,N) \
|
||||
? __atomic_compare_exchange_n (PTR(N,a), \
|
||||
&u.C2(i,N), v.C2(i,N), true, \
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED) \
|
||||
: C3(local_,compare_exchange_,N) (PTR(N,a), \
|
||||
&u.C2(i,N), v.C2(i,N), \
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED))); \
|
||||
goto Lfinish; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
static void __attribute__((noinline))
|
||||
libat_exchange_large_inplace (size_t n, void *mptr, void *vptr)
|
||||
{
|
||||
#define BUF 1024
|
||||
|
||||
char temp[BUF];
|
||||
size_t i = 0;
|
||||
|
||||
for (i = 0; n >= BUF; i += BUF, n -= BUF)
|
||||
{
|
||||
memcpy (temp, mptr + i, BUF);
|
||||
memcpy (mptr + i, vptr + i, BUF);
|
||||
memcpy (vptr + i, temp, BUF);
|
||||
}
|
||||
if (n > 0)
|
||||
{
|
||||
memcpy (temp, mptr + i, n);
|
||||
memcpy (mptr + i, vptr + i, n);
|
||||
memcpy (vptr + i, temp, n);
|
||||
}
|
||||
|
||||
#undef BUF
|
||||
}
|
||||
|
||||
void
|
||||
libat_exchange (size_t n, void *mptr, void *vptr, void *rptr, int smodel)
|
||||
{
|
||||
union max_size_u u, v;
|
||||
uintptr_t r, a;
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 0: return;
|
||||
case 1: EXACT(1); goto L4;
|
||||
case 2: EXACT(2); goto L4;
|
||||
case 4: EXACT(4); goto L8;
|
||||
case 8: EXACT(8); goto L16;
|
||||
case 16: EXACT(16); break;
|
||||
|
||||
case 3: L4: LARGER(4); /* FALLTHRU */
|
||||
case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
|
||||
case 9 ... 15: L16: LARGER(16); break;
|
||||
|
||||
Lfinish:
|
||||
post_barrier (smodel);
|
||||
memcpy (rptr, u.b + r, n);
|
||||
return;
|
||||
}
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
libat_lock_n (mptr, n);
|
||||
|
||||
if (vptr != rptr)
|
||||
{
|
||||
memcpy (rptr, mptr, n);
|
||||
memcpy (mptr, vptr, n);
|
||||
}
|
||||
else
|
||||
libat_exchange_large_inplace (n, mptr, vptr);
|
||||
|
||||
libat_unlock_n (mptr, n);
|
||||
post_seq_barrier (smodel);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS (exchange);
|
67
libatomic/glfree.c
Normal file
67
libatomic/glfree.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
#define EXACT(N) \
|
||||
do { \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if ((uintptr_t)ptr & (N - 1)) break; \
|
||||
if (__atomic_always_lock_free(N, 0)) return true; \
|
||||
if (C2(MAYBE_HAVE_ATOMIC_CAS_,N)) return true; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LARGER(N) \
|
||||
do { \
|
||||
uintptr_t r = (uintptr_t)ptr & (N - 1); \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if (!C2(HAVE_ATOMIC_LDST_,N)) break; \
|
||||
if (!C2(MAYBE_HAVE_ATOMIC_CAS_,N)) break; \
|
||||
if (r + n <= N) return true; \
|
||||
} while (0)
|
||||
|
||||
|
||||
bool
|
||||
libat_is_lock_free (size_t n, void *ptr)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
case 0: return true;
|
||||
case 1: EXACT(1); goto L4;
|
||||
case 2: EXACT(2); goto L4;
|
||||
case 4: EXACT(4); goto L8;
|
||||
case 8: EXACT(8); goto L16;
|
||||
case 16: EXACT(16); break;
|
||||
|
||||
case 3: L4: LARGER(4); /* FALLTHRU */
|
||||
case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
|
||||
case 9 ... 15: L16: LARGER(16); break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
EXPORT_ALIAS (is_lock_free);
|
100
libatomic/gload.c
Normal file
100
libatomic/gload.c
Normal file
|
@ -0,0 +1,100 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we natively support the load, and if we're unconcerned with extra
|
||||
barriers (e.g. fully in-order cpu for which barriers are a nop), then
|
||||
go ahead and expand the operation inline. */
|
||||
#if !defined(WANT_SPECIALCASE_RELAXED) && !defined(__OPTIMIZE_SIZE__)
|
||||
# define EXACT_INLINE(N, DEST, SRC, DONE) \
|
||||
if (C2(HAVE_ATOMIC_LDST_,N)) \
|
||||
{ \
|
||||
DEST = __atomic_load_n (SRC, smodel); \
|
||||
DONE; \
|
||||
}
|
||||
#else
|
||||
# define EXACT_INLINE(N, DEST, SRC, DONE)
|
||||
#endif
|
||||
|
||||
|
||||
#define EXACT_(N, DEST, SRC, DONE) \
|
||||
do { \
|
||||
EXACT_INLINE (N, DEST, SRC, DONE); \
|
||||
DEST = C3(local_,load_,N) (SRC, smodel); \
|
||||
DONE; \
|
||||
} while (0)
|
||||
|
||||
#define EXACT(N) \
|
||||
do { \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if ((uintptr_t)mptr & (N - 1)) break; \
|
||||
EXACT_(N, *PTR(N,rptr), PTR(N,mptr), return); \
|
||||
} while (0)
|
||||
|
||||
#define LARGER(N) \
|
||||
do { \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
r = (uintptr_t)mptr & (N - 1); \
|
||||
a = (uintptr_t)mptr & -N; \
|
||||
if (r + n <= N) \
|
||||
EXACT_ (N, u.C2(i,N), PTR(N,a), goto Lfinish); \
|
||||
} while (0)
|
||||
|
||||
|
||||
void
|
||||
libat_load (size_t n, void *mptr, void *rptr, int smodel)
|
||||
{
|
||||
union max_size_u u;
|
||||
uintptr_t r, a;
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 0: return;
|
||||
case 1: EXACT(1); goto L4;
|
||||
case 2: EXACT(2); goto L4;
|
||||
case 4: EXACT(4); goto L8;
|
||||
case 8: EXACT(8); goto L16;
|
||||
case 16: EXACT(16); break;
|
||||
|
||||
case 3: L4: LARGER(4); /* FALLTHRU */
|
||||
case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
|
||||
case 9 ... 15: L16: LARGER(16); break;
|
||||
|
||||
Lfinish:
|
||||
memcpy (rptr, u.b + r, n);
|
||||
return;
|
||||
}
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
libat_lock_n (mptr, n);
|
||||
|
||||
memcpy (rptr, mptr, n);
|
||||
|
||||
libat_unlock_n (mptr, n);
|
||||
post_seq_barrier (smodel);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS (load);
|
108
libatomic/gstore.c
Normal file
108
libatomic/gstore.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we natively support the store, and if we're unconcerned with extra
|
||||
barriers (e.g. fully in-order cpu for which barriers are a nop), then
|
||||
go ahead and expand the operation inline. */
|
||||
#if !defined(WANT_SPECIALCASE_RELAXED) && !defined(__OPTIMIZE_SIZE__)
|
||||
# define EXACT_INLINE(N) \
|
||||
if (C2(HAVE_ATOMIC_LDST_,N)) \
|
||||
{ \
|
||||
__atomic_store_n (PTR(N,mptr), *PTR(N,vptr), smodel); \
|
||||
return; \
|
||||
}
|
||||
#else
|
||||
# define EXACT_INLINE(N)
|
||||
#endif
|
||||
|
||||
|
||||
#define EXACT(N) \
|
||||
do { \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if ((uintptr_t)mptr & (N - 1)) break; \
|
||||
EXACT_INLINE (N); \
|
||||
C3(local_,store_,N) (PTR(N,mptr), *PTR(N,vptr), smodel); \
|
||||
return; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LARGER(N) \
|
||||
do { \
|
||||
union max_size_u u, v; \
|
||||
uintptr_t r, a; \
|
||||
if (!C2(HAVE_INT,N)) break; \
|
||||
if (!C2(MAYBE_HAVE_ATOMIC_CAS_,N)) break; \
|
||||
r = (uintptr_t)mptr & (N - 1); \
|
||||
a = (uintptr_t)mptr & -N; \
|
||||
if (r + n <= N) \
|
||||
{ \
|
||||
pre_barrier (smodel); \
|
||||
/* This load need not be atomic, as the CAS \
|
||||
below will validate it. */ \
|
||||
u.C2(i,N) = *PTR(N,a); \
|
||||
do { \
|
||||
v = u; memcpy (v.b + r, vptr, n); \
|
||||
} while (!(C2(HAVE_ATOMIC_CAS_,N) \
|
||||
? __atomic_compare_exchange_n (PTR(N,a), \
|
||||
&u.C2(i,N), v.C2(i,N), true, \
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED) \
|
||||
: C3(local_,compare_exchange_,N) (PTR(N,a), \
|
||||
&u.C2(i,N), v.C2(i,N), \
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED))); \
|
||||
post_barrier (smodel); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
void
|
||||
libat_store (size_t n, void *mptr, void *vptr, int smodel)
|
||||
{
|
||||
switch (n)
|
||||
{
|
||||
case 0: return;
|
||||
case 1: EXACT(1); goto L4;
|
||||
case 2: EXACT(2); goto L4;
|
||||
case 4: EXACT(4); goto L8;
|
||||
case 8: EXACT(8); goto L16;
|
||||
case 16: EXACT(16); break;
|
||||
|
||||
case 3: L4: LARGER(4); /* FALLTHRU */
|
||||
case 5 ... 7: L8: LARGER(8); /* FALLTHRU */
|
||||
case 9 ... 15: L16: LARGER(16); break;
|
||||
}
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
libat_lock_n (mptr, n);
|
||||
|
||||
memcpy (mptr, vptr, n);
|
||||
|
||||
libat_unlock_n (mptr, n);
|
||||
post_seq_barrier (smodel);
|
||||
}
|
||||
|
||||
EXPORT_ALIAS (store);
|
86
libatomic/host-config.h
Normal file
86
libatomic/host-config.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Included after all more target-specific host-config.h. */
|
||||
|
||||
|
||||
/* The target may have some OS specific way to implement compare-and-swap. */
|
||||
#if !defined(atomic_compare_exchange_n) && SIZE(HAVE_ATOMIC_CAS)
|
||||
# define atomic_compare_exchange_n __atomic_compare_exchange_n
|
||||
#endif
|
||||
#if !defined(atomic_compare_exchange_w) && WSIZE(HAVE_ATOMIC_CAS)
|
||||
# define atomic_compare_exchange_w __atomic_compare_exchange_n
|
||||
#endif
|
||||
|
||||
/* For some targets, it may be significantly faster to avoid all barriers
|
||||
if the user only wants relaxed memory order. Sometimes we don't want
|
||||
the extra code bloat. In all cases, use the input to avoid warnings. */
|
||||
#if defined(WANT_SPECIALCASE_RELAXED) && !defined(__OPTIMIZE_SIZE__)
|
||||
# define maybe_specialcase_relaxed(x) ((x) == __ATOMIC_RELAXED)
|
||||
#else
|
||||
# define maybe_specialcase_relaxed(x) ((x) & 0)
|
||||
#endif
|
||||
|
||||
/* Similar, but for targets for which the seq_cst model is sufficiently
|
||||
more expensive than the acq_rel model. */
|
||||
#if defined(WANT_SPECIALCASE_ACQREL) && !defined(__OPTIMIZE_SIZE__)
|
||||
# define maybe_specialcase_acqrel(x) ((x) != __ATOMIC_SEQ_CST)
|
||||
#else
|
||||
# define maybe_specialcase_acqrel(x) ((x) & 0)
|
||||
#endif
|
||||
|
||||
|
||||
/* The target may have some OS specific way to emit barriers. */
|
||||
#ifndef pre_post_barrier
|
||||
static inline void __attribute__((always_inline, artificial))
|
||||
pre_barrier(int model)
|
||||
{
|
||||
if (!maybe_specialcase_relaxed(model))
|
||||
{
|
||||
if (maybe_specialcase_acqrel(model))
|
||||
__atomic_thread_fence (__ATOMIC_ACQ_REL);
|
||||
else
|
||||
__atomic_thread_fence (__ATOMIC_SEQ_CST);
|
||||
}
|
||||
}
|
||||
static inline void __attribute__((always_inline, artificial))
|
||||
post_barrier(int model)
|
||||
{
|
||||
pre_barrier(model);
|
||||
}
|
||||
#define pre_post_barrier 1
|
||||
#endif /* pre_post_barrier */
|
||||
|
||||
/* Similar, but assume that acq_rel is already handled via locks. */
|
||||
#ifndef pre_post_seq_barrier
|
||||
static inline void __attribute__((always_inline, artificial))
|
||||
pre_seq_barrier(int model)
|
||||
{
|
||||
}
|
||||
static inline void __attribute__((always_inline, artificial))
|
||||
post_seq_barrier(int model)
|
||||
{
|
||||
}
|
||||
#define pre_post_seq_barrier 1
|
||||
#endif
|
1
libatomic/init.c
Normal file
1
libatomic/init.c
Normal file
|
@ -0,0 +1 @@
|
|||
/* No runtime initialization needed. */
|
97
libatomic/libatomic.map
Normal file
97
libatomic/libatomic.map
Normal file
|
@ -0,0 +1,97 @@
|
|||
LIBATOMIC_1.0 {
|
||||
global:
|
||||
__atomic_load;
|
||||
__atomic_store;
|
||||
__atomic_exchange;
|
||||
__atomic_compare_exchange;
|
||||
__atomic_is_lock_free;
|
||||
|
||||
__atomic_add_fetch_1;
|
||||
__atomic_add_fetch_2;
|
||||
__atomic_add_fetch_4;
|
||||
__atomic_add_fetch_8;
|
||||
__atomic_add_fetch_16;
|
||||
__atomic_and_fetch_1;
|
||||
__atomic_and_fetch_2;
|
||||
__atomic_and_fetch_4;
|
||||
__atomic_and_fetch_8;
|
||||
__atomic_and_fetch_16;
|
||||
__atomic_compare_exchange_1;
|
||||
__atomic_compare_exchange_2;
|
||||
__atomic_compare_exchange_4;
|
||||
__atomic_compare_exchange_8;
|
||||
__atomic_compare_exchange_16;
|
||||
__atomic_exchange_1;
|
||||
__atomic_exchange_2;
|
||||
__atomic_exchange_4;
|
||||
__atomic_exchange_8;
|
||||
__atomic_exchange_16;
|
||||
__atomic_fetch_add_1;
|
||||
__atomic_fetch_add_2;
|
||||
__atomic_fetch_add_4;
|
||||
__atomic_fetch_add_8;
|
||||
__atomic_fetch_add_16;
|
||||
__atomic_fetch_and_1;
|
||||
__atomic_fetch_and_2;
|
||||
__atomic_fetch_and_4;
|
||||
__atomic_fetch_and_8;
|
||||
__atomic_fetch_and_16;
|
||||
__atomic_fetch_nand_1;
|
||||
__atomic_fetch_nand_2;
|
||||
__atomic_fetch_nand_4;
|
||||
__atomic_fetch_nand_8;
|
||||
__atomic_fetch_nand_16;
|
||||
__atomic_fetch_or_1;
|
||||
__atomic_fetch_or_2;
|
||||
__atomic_fetch_or_4;
|
||||
__atomic_fetch_or_8;
|
||||
__atomic_fetch_or_16;
|
||||
__atomic_fetch_sub_1;
|
||||
__atomic_fetch_sub_2;
|
||||
__atomic_fetch_sub_4;
|
||||
__atomic_fetch_sub_8;
|
||||
__atomic_fetch_sub_16;
|
||||
__atomic_fetch_xor_1;
|
||||
__atomic_fetch_xor_2;
|
||||
__atomic_fetch_xor_4;
|
||||
__atomic_fetch_xor_8;
|
||||
__atomic_fetch_xor_16;
|
||||
__atomic_load_1;
|
||||
__atomic_load_2;
|
||||
__atomic_load_4;
|
||||
__atomic_load_8;
|
||||
__atomic_load_16;
|
||||
__atomic_nand_fetch_1;
|
||||
__atomic_nand_fetch_2;
|
||||
__atomic_nand_fetch_4;
|
||||
__atomic_nand_fetch_8;
|
||||
__atomic_nand_fetch_16;
|
||||
__atomic_or_fetch_1;
|
||||
__atomic_or_fetch_2;
|
||||
__atomic_or_fetch_4;
|
||||
__atomic_or_fetch_8;
|
||||
__atomic_or_fetch_16;
|
||||
__atomic_store_1;
|
||||
__atomic_store_2;
|
||||
__atomic_store_4;
|
||||
__atomic_store_8;
|
||||
__atomic_store_16;
|
||||
__atomic_sub_fetch_1;
|
||||
__atomic_sub_fetch_2;
|
||||
__atomic_sub_fetch_4;
|
||||
__atomic_sub_fetch_8;
|
||||
__atomic_sub_fetch_16;
|
||||
__atomic_test_and_set_1;
|
||||
__atomic_test_and_set_2;
|
||||
__atomic_test_and_set_4;
|
||||
__atomic_test_and_set_8;
|
||||
__atomic_test_and_set_16;
|
||||
__atomic_xor_fetch_1;
|
||||
__atomic_xor_fetch_2;
|
||||
__atomic_xor_fetch_4;
|
||||
__atomic_xor_fetch_8;
|
||||
__atomic_xor_fetch_16;
|
||||
|
||||
local:
|
||||
*;
|
||||
};
|
293
libatomic/libatomic_i.h
Normal file
293
libatomic/libatomic_i.h
Normal file
|
@ -0,0 +1,293 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3, or (at your option)
|
||||
any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* This file contains data types and function declarations that are
|
||||
private to the implementation of libatomic. */
|
||||
|
||||
#ifndef LIBATOMIC_H
|
||||
#define LIBATOMIC_H 1
|
||||
|
||||
#include "auto-config.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* Symbol concatenation macros. */
|
||||
#define C2_(X,Y) X ## Y
|
||||
#define C2(X,Y) C2_(X,Y)
|
||||
#define C3_(X,Y,Z) X ## Y ## Z
|
||||
#define C3(X,Y,Z) C3_(X,Y,Z)
|
||||
#define C4_(W,X,Y,Z) W ## X ## Y ## Z
|
||||
#define C4(W,X,Y,Z) C4_(W,X,Y,Z)
|
||||
|
||||
/* Stringification macros. */
|
||||
#define S2(X) #X
|
||||
#define S(X) S2(X)
|
||||
|
||||
/* All of the primitive types on which we operate. */
|
||||
typedef unsigned U_1 __attribute__((mode(QI)));
|
||||
#if HAVE_INT2
|
||||
typedef unsigned U_2 __attribute__((mode(HI)));
|
||||
#endif
|
||||
#if HAVE_INT4
|
||||
typedef unsigned U_4 __attribute__((mode(SI)));
|
||||
#endif
|
||||
#if HAVE_INT8
|
||||
typedef unsigned U_8 __attribute__((mode(DI)));
|
||||
#endif
|
||||
#if HAVE_INT16
|
||||
typedef unsigned U_16 __attribute__((mode(TI)));
|
||||
#endif
|
||||
|
||||
/* The widest type that we support. */
|
||||
#if HAVE_INT16
|
||||
# define MAX_SIZE 16
|
||||
#elif HAVE_INT8
|
||||
# define MAX_SIZE 8
|
||||
#elif HAVE_INT4
|
||||
# define MAX_SIZE 4
|
||||
#elif HAVE_INT2
|
||||
# define MAX_SIZE 2
|
||||
#else
|
||||
# define MAX_SIZE 1
|
||||
#endif
|
||||
typedef C2(U_,MAX_SIZE) U_MAX;
|
||||
|
||||
/* Provide dummy fallback types so that stuff is syntactically correct
|
||||
without having to overdo the ifdefs. The code using these should
|
||||
always be protected with the HAVE_INT{n} macros. */
|
||||
#if !HAVE_INT2
|
||||
typedef U_MAX U_2;
|
||||
#endif
|
||||
#if !HAVE_INT4
|
||||
typedef U_MAX U_4;
|
||||
#endif
|
||||
#if !HAVE_INT8
|
||||
typedef U_MAX U_8;
|
||||
#endif
|
||||
#if !HAVE_INT16
|
||||
typedef U_MAX U_16;
|
||||
#endif
|
||||
|
||||
union max_size_u
|
||||
{
|
||||
U_1 b[MAX_SIZE];
|
||||
U_2 i2;
|
||||
U_4 i4;
|
||||
U_8 i8;
|
||||
U_16 i16;
|
||||
};
|
||||
|
||||
/* The "word" size of the machine. */
|
||||
typedef unsigned UWORD __attribute__((mode(word)));
|
||||
|
||||
/* Macros for handing sub-word sized quantities. */
|
||||
#define MASK_1 ((UWORD)0xff)
|
||||
#define MASK_2 ((UWORD)0xffff)
|
||||
#define MASK_4 ((UWORD)0xffffffff)
|
||||
#define INVERT_MASK_1 ((UWORD)WORDS_BIGENDIAN << ((WORDSIZE - 1) * CHAR_BIT))
|
||||
#define INVERT_MASK_2 ((UWORD)WORDS_BIGENDIAN << ((WORDSIZE - 2) * CHAR_BIT))
|
||||
#define INVERT_MASK_4 ((UWORD)WORDS_BIGENDIAN << ((WORDSIZE - 4) * CHAR_BIT))
|
||||
|
||||
/* Most of the files in this library are compiled multiple times with
|
||||
N defined to be a power of 2 between 1 and 16. The SIZE macro is
|
||||
then used to append _N to the symbol being manipulated. */
|
||||
#define SIZE(X) C3(X,_,N)
|
||||
#define WSIZE(X) C3(X,_,WORDSIZE)
|
||||
#define PTR(N,X) ((C2(U_,N) *)X)
|
||||
|
||||
/* And thus, the type on which this compilation will be operating. */
|
||||
#define ITYPE SIZE(I)
|
||||
#define UTYPE SIZE(U)
|
||||
|
||||
/* Utility macros for GCC attributes. */
|
||||
#define UNUSED __attribute__((unused))
|
||||
#ifdef HAVE_ATTRIBUTE_VISIBILITY
|
||||
# define HIDDEN __attribute__((visibility("hidden")))
|
||||
#else
|
||||
# define HIDDEN
|
||||
#endif
|
||||
|
||||
/* Occasionally we have to play games with internal and external symbol
|
||||
names, in order to work around builtin functions of the same name.
|
||||
This macro sets the external name of the function appropriately. */
|
||||
#define ASMNAME(X) __asm__(S(C2(__USER_LABEL_PREFIX__,X)))
|
||||
|
||||
/* Locking for a "small" operation. In the bare-metal single processor
|
||||
cases this could be implemented by disabling interrupts. Thus the extra
|
||||
word passed between the two functions, saving the interrupt level.
|
||||
It is assumed that the object being locked does not cross the locking
|
||||
granularity.
|
||||
|
||||
Not actually declared here so that they can be defined static inline
|
||||
in a target-specfic <host-config.h>.
|
||||
|
||||
UWORD protect_start (void *ptr);
|
||||
void protect_end (void *ptr, UWORD);
|
||||
*/
|
||||
|
||||
/* Locking for a "large' operation. This should always be some sort of
|
||||
test-and-set operation, as we assume that the interrupt latency would
|
||||
be unreasonably large. */
|
||||
void libat_lock_n (void *ptr, size_t n);
|
||||
void libat_unlock_n (void *ptr, size_t n);
|
||||
|
||||
/* We'll need to declare all of the sized functions a few times... */
|
||||
#define DECLARE_ALL_SIZED(N) DECLARE_ALL_SIZED_(N,C2(U_,N))
|
||||
#define DECLARE_ALL_SIZED_(N,T) \
|
||||
DECLARE_1(T, C2(load_,N), (T *mptr, int)); \
|
||||
DECLARE_1(void, C2(store_,N), (T *mptr, T val, int)); \
|
||||
DECLARE_1(T, C2(exchange_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(bool, C2(compare_exchange_,N), (T *mptr, T *, T, int, int)); \
|
||||
DECLARE_1(bool, C2(test_and_set_,N), (T *mptr, int)); \
|
||||
DECLARE_1(T, C2(fetch_add_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(fetch_sub_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(fetch_and_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(fetch_xor_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(fetch_or_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(fetch_nand_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(add_fetch_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(sub_fetch_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(and_fetch_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(xor_fetch_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(or_fetch_,N), (T *mptr, T, int)); \
|
||||
DECLARE_1(T, C2(nand_fetch_,N), (T *mptr, T, int))
|
||||
|
||||
/* All sized operations are implemented in hidden functions prefixed with
|
||||
"libat_". These are either renamed or aliased to the expected prefix
|
||||
of "__atomic". Some amount of renaming is required to avoid hiding or
|
||||
conflicting with the builtins of the same name, but this additional
|
||||
use of hidden symbols (where appropriate) avoids unnecessary PLT entries
|
||||
on relevant targets. */
|
||||
|
||||
#if IFUNC_ALT
|
||||
# define MAN(X) ASMNAME(C4(libat_,X,_i,IFUNC_ALT)) HIDDEN
|
||||
#elif defined(HAVE_ATTRIBUTE_ALIAS)
|
||||
# define MAN(X) HIDDEN
|
||||
#else
|
||||
# define MAN(X) ASMNAME(C2(__atomic_,X))
|
||||
#endif
|
||||
|
||||
#if !defined(N) && HAVE_IFUNC
|
||||
# define DECLARE_1(RET,NAME,ARGS) \
|
||||
RET C2(libat_,NAME) ARGS MAN(NAME); \
|
||||
RET C2(ifunc_,NAME) ARGS ASMNAME(C2(__atomic_,NAME))
|
||||
#else
|
||||
# define DECLARE_1(RET,NAME,ARGS) RET C2(libat_,NAME) ARGS MAN(NAME)
|
||||
#endif
|
||||
|
||||
/* Prefix to use when calling internal, possibly ifunc'ed functions. */
|
||||
#if HAVE_IFUNC
|
||||
# define local_ ifunc_
|
||||
#else
|
||||
# define local_ libat_
|
||||
#endif
|
||||
|
||||
DECLARE_ALL_SIZED(1);
|
||||
DECLARE_ALL_SIZED(2);
|
||||
DECLARE_ALL_SIZED(4);
|
||||
DECLARE_ALL_SIZED(8);
|
||||
DECLARE_ALL_SIZED(16);
|
||||
|
||||
#undef DECLARE_1
|
||||
#undef DECLARE_ALL_SIZED
|
||||
#undef DECLARE_ALL_SIZED_
|
||||
|
||||
/* And the generic sized versions. */
|
||||
void libat_load (size_t, void *, void *, int) MAN(load);
|
||||
void libat_store (size_t, void *, void *, int) MAN(store);
|
||||
void libat_exchange (size_t, void *, void *, void *, int) MAN(exchange);
|
||||
bool libat_compare_exchange (size_t, void *, void *, void *, int, int)
|
||||
MAN(compare_exchange);
|
||||
bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
|
||||
|
||||
#undef MAN
|
||||
|
||||
#include <host-config.h>
|
||||
|
||||
/* We don't have IFUNC_NCOND until after host-config.h. */
|
||||
#if !HAVE_IFUNC
|
||||
# define IFUNC_NCOND(N) 0
|
||||
#endif
|
||||
|
||||
#if IFUNC_ALT
|
||||
# define EXPORT_ALIAS(X) /* exported symbol in non-alternate file */
|
||||
#elif defined(N) && IFUNC_NCOND(N)
|
||||
# if IFUNC_NCOND(N) == 1
|
||||
# define GEN_SELECTOR(X) \
|
||||
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
|
||||
static void * C2(select_,X) (void) \
|
||||
{ \
|
||||
if (IFUNC_COND_1) \
|
||||
return C3(libat_,X,_i1); \
|
||||
return C2(libat_,X); \
|
||||
}
|
||||
# elif IFUNC_NCOND(N) == 2
|
||||
# define GEN_SELECTOR(X) \
|
||||
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
|
||||
extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN; \
|
||||
static void * C2(select_,X) (void) \
|
||||
{ \
|
||||
if (IFUNC_COND_1) \
|
||||
return C3(libat_,X,_i1); \
|
||||
if (IFUNC_COND_2) \
|
||||
return C3(libat_,X,_i2); \
|
||||
return C2(libat_,X); \
|
||||
}
|
||||
# elif IFUNC_NCOND(N) == 3
|
||||
# define GEN_SELECTOR(X) \
|
||||
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
|
||||
extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN; \
|
||||
extern typeof(C2(libat_,X)) C3(libat_,X,_i3) HIDDEN; \
|
||||
static void * C2(select_,X) (void) \
|
||||
{ \
|
||||
if (IFUNC_COND_1) \
|
||||
return C3(libat_,X,_i1); \
|
||||
if (IFUNC_COND_2) \
|
||||
return C3(libat_,X,_i2); \
|
||||
if (IFUNC_COND_3) \
|
||||
return C3(libat_,X,_i3); \
|
||||
return C2(libat_,X); \
|
||||
}
|
||||
# else
|
||||
# error "Unsupported number of ifunc alternatives."
|
||||
# endif
|
||||
# define EXPORT_ALIAS(X) \
|
||||
GEN_SELECTOR(X) \
|
||||
typeof(C2(libat_,X)) C2(ifunc_,X) \
|
||||
ASMNAME(C2(__atomic_,X)) \
|
||||
__attribute__((ifunc(S(C2(select_,X)))))
|
||||
#elif defined(HAVE_ATTRIBUTE_ALIAS)
|
||||
# define EXPORT_ALIAS(X) \
|
||||
extern typeof(C2(libat_,X)) C2(export_,X) \
|
||||
ASMNAME(C2(__atomic_,X)) \
|
||||
__attribute__((alias(S(C2(libat_,X)))))
|
||||
#else
|
||||
# define EXPORT_ALIAS(X) /* original symbol is exported */
|
||||
#endif
|
||||
|
||||
#endif /* LIBATOMIC_H */
|
115
libatomic/load_n.c
Normal file
115
libatomic/load_n.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we support the builtin, just use it. */
|
||||
#if !DONE && SIZE(HAVE_ATOMIC_LDST)
|
||||
UTYPE
|
||||
SIZE(libat_load) (UTYPE *mptr, int smodel)
|
||||
{
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
return __atomic_load_n (mptr, __ATOMIC_RELAXED);
|
||||
else if (maybe_specialcase_acqrel(smodel))
|
||||
/* Note that REL and ACQ_REL are not valid for loads. */
|
||||
return __atomic_load_n (mptr, __ATOMIC_ACQUIRE);
|
||||
else
|
||||
return __atomic_load_n (mptr, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_LOAD */
|
||||
|
||||
|
||||
/* If we have compare-and-swap, use it to swap 0 with 0 and as a side
|
||||
effect load the original value. */
|
||||
#if !DONE && defined(atomic_compare_exchange_n)
|
||||
UTYPE
|
||||
SIZE(libat_load) (UTYPE *mptr, int smodel)
|
||||
{
|
||||
UTYPE t = 0;
|
||||
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
atomic_compare_exchange_n (mptr, &t, 0, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED);
|
||||
else if (maybe_specialcase_acqrel(smodel))
|
||||
atomic_compare_exchange_n (mptr, &t, 0, true,
|
||||
__ATOMIC_ACQ_REL, __ATOMIC_ACQ_REL);
|
||||
else
|
||||
atomic_compare_exchange_n (mptr, &t, 0, true,
|
||||
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* atomic_compare_exchange_n */
|
||||
|
||||
|
||||
/* Similar, but only assume a word-sized compare-and-swap. */
|
||||
#if !DONE && N < WORDSIZE && defined(atomic_compare_exchange_w)
|
||||
UTYPE
|
||||
SIZE(libat_load) (UTYPE *mptr, int smodel)
|
||||
{
|
||||
UWORD shift, t, *wptr;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
|
||||
shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
|
||||
|
||||
/* Exchange 0 with 0, placing the old value of *WPTR in T. */
|
||||
t = 0;
|
||||
atomic_compare_exchange_w (wptr, &t, 0);
|
||||
|
||||
post_barrier (smodel);
|
||||
return t >> shift;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_CAS && N < WORDSIZE */
|
||||
|
||||
|
||||
/* Otherwise, fall back to some sort of protection mechanism. */
|
||||
#if !DONE
|
||||
UTYPE
|
||||
SIZE(libat_load) (UTYPE *mptr, int smodel)
|
||||
{
|
||||
UTYPE ret;
|
||||
UWORD magic;
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
magic = protect_start (mptr);
|
||||
|
||||
ret = *mptr;
|
||||
|
||||
protect_end (mptr, magic);
|
||||
post_seq_barrier (smodel);
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
EXPORT_ALIAS (SIZE(load));
|
112
libatomic/store_n.c
Normal file
112
libatomic/store_n.c
Normal file
|
@ -0,0 +1,112 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we support the builtin, just use it. */
|
||||
#if !DONE && SIZE(HAVE_ATOMIC_LDST)
|
||||
void
|
||||
SIZE(libat_store) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
__atomic_store_n (mptr, newval, __ATOMIC_RELAXED);
|
||||
else if (maybe_specialcase_acqrel(smodel))
|
||||
/* Note that ACQ and ACQ_REL are not valid for store. */
|
||||
__atomic_store_n (mptr, newval, __ATOMIC_RELEASE);
|
||||
else
|
||||
__atomic_store_n (mptr, newval, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_STORE */
|
||||
|
||||
/* If we have compare-and-swap, use it perform the store. */
|
||||
#if !DONE && defined(atomic_compare_exchange_n)
|
||||
void
|
||||
SIZE(libat_store) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
UTYPE oldval;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
oldval = *mptr;
|
||||
while (!atomic_compare_exchange_n (mptr, &oldval, newval, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
continue;
|
||||
|
||||
post_barrier (smodel);
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* atomic_compare_exchange_n */
|
||||
|
||||
|
||||
/* If this type is smaller than word-sized, fall back to a word-sized
|
||||
compare-and-swap loop. */
|
||||
#if !DONE && N < WORDSIZE && defined(atomic_compare_exchange_w)
|
||||
void
|
||||
SIZE(libat_store) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
UWORD mask, shift, woldval, wnewval, t, *wptr;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
|
||||
shift = (((uintptr_t)mptr % WORDSIZE) * CHAR_BIT) ^ SIZE(INVERT_MASK);
|
||||
mask = SIZE(MASK) << shift;
|
||||
|
||||
wnewval = (UWORD)newval << shift;
|
||||
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
|
||||
do
|
||||
{
|
||||
t = (woldval & ~mask) | wnewval;
|
||||
}
|
||||
while (!atomic_compare_exchange_w (wptr, &woldval, t));
|
||||
|
||||
post_barrier (smodel);
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* N < WORDSIZE && atomic_compare_exchange_w */
|
||||
|
||||
|
||||
/* Otherwise, fall back to some sort of protection mechanism. */
|
||||
#if !DONE
|
||||
void
|
||||
SIZE(libat_store) (UTYPE *mptr, UTYPE newval, int smodel)
|
||||
{
|
||||
UWORD magic;
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
magic = protect_start (mptr);
|
||||
|
||||
*mptr = newval;
|
||||
|
||||
protect_end (mptr, magic);
|
||||
post_seq_barrier (smodel);
|
||||
}
|
||||
#endif
|
||||
|
||||
EXPORT_ALIAS (SIZE(store));
|
115
libatomic/tas_n.c
Normal file
115
libatomic/tas_n.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
Contributed by Richard Henderson <rth@redhat.com>.
|
||||
|
||||
This file is part of the GNU Atomic Library (libatomic).
|
||||
|
||||
Libatomic is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
Under Section 7 of GPL version 3, you are granted additional
|
||||
permissions described in the GCC Runtime Library Exception, version
|
||||
3.1, as published by the Free Software Foundation.
|
||||
|
||||
You should have received a copy of the GNU General Public License and
|
||||
a copy of the GCC Runtime Library Exception along with this program;
|
||||
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "libatomic_i.h"
|
||||
|
||||
|
||||
/* If we support the builtin, just use it. */
|
||||
#if !DONE && SIZE(HAVE_ATOMIC_TAS)
|
||||
bool
|
||||
SIZE(libat_test_and_set) (UTYPE *mptr, int smodel)
|
||||
{
|
||||
if (maybe_specialcase_relaxed(smodel))
|
||||
return __atomic_test_and_set (mptr, __ATOMIC_RELAXED);
|
||||
else if (maybe_specialcase_acqrel(smodel))
|
||||
return __atomic_test_and_set (mptr, __ATOMIC_ACQ_REL);
|
||||
else
|
||||
return __atomic_test_and_set (mptr, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_TAS */
|
||||
|
||||
|
||||
/* If this type is smaller than word-sized, fall back to a word-sized
|
||||
compare-and-swap loop. */
|
||||
#if !DONE && N <= WORDSIZE && defined(atomic_compare_exchange_w)
|
||||
bool
|
||||
SIZE(libat_test_and_set) (UTYPE *mptr, int smodel)
|
||||
{
|
||||
UWORD wval, woldval, shift, *wptr, t;
|
||||
|
||||
pre_barrier (smodel);
|
||||
|
||||
if (N < WORDSIZE)
|
||||
{
|
||||
wptr = (UWORD *)((uintptr_t)mptr & -WORDSIZE);
|
||||
shift = SIZE(INVERT_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
wptr = (UWORD *)mptr;
|
||||
shift = 0;
|
||||
}
|
||||
|
||||
wval = (UWORD)__GCC_ATOMIC_TEST_AND_SET_TRUEVAL << shift;
|
||||
woldval = __atomic_load_n (wptr, __ATOMIC_RELAXED);
|
||||
do
|
||||
{
|
||||
t = woldval | wval;
|
||||
}
|
||||
while (!atomic_compare_exchange_w (wptr, &woldval, t, true,
|
||||
__ATOMIC_RELAXED, __ATOMIC_RELAXED));
|
||||
|
||||
post_barrier (smodel);
|
||||
return woldval != 0;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* HAVE_ATOMIC_CAS && N < WORDSIZE */
|
||||
|
||||
|
||||
/* Otherwise, fall back to some sort of protection mechanism. */
|
||||
#if !DONE && N == 1
|
||||
bool
|
||||
SIZE(libat_test_and_set) (UTYPE *mptr, int smodel)
|
||||
{
|
||||
UTYPE oldval, newval;
|
||||
UWORD magic;
|
||||
|
||||
pre_seq_barrier (smodel);
|
||||
magic = protect_start (mptr);
|
||||
|
||||
oldval = *mptr;
|
||||
*mptr = __GCC_ATOMIC_TEST_AND_SET_TRUEVAL;
|
||||
|
||||
protect_end (mptr, magic);
|
||||
post_seq_barrier (smodel);
|
||||
|
||||
return ret != 0;
|
||||
}
|
||||
|
||||
#define DONE 1
|
||||
#endif /* N == 1 */
|
||||
|
||||
|
||||
#if !DONE
|
||||
bool
|
||||
SIZE(libat_test_and_set) (UTYPE *mptr, int smodel UNUSED)
|
||||
{
|
||||
return libat_test_and_set_1 ((U_1 *)mptr, smodel);
|
||||
}
|
||||
#endif
|
||||
|
||||
EXPORT_ALIAS (SIZE(test_and_set));
|
13
libatomic/testsuite/Makefile.am
Normal file
13
libatomic/testsuite/Makefile.am
Normal file
|
@ -0,0 +1,13 @@
|
|||
## Process this file with automake to produce Makefile.in.
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign dejagnu
|
||||
|
||||
# May be used by various substitution variables.
|
||||
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
|
||||
|
||||
EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
|
||||
echo $(top_builddir)/../expect/expect; else echo expect; fi)
|
||||
|
||||
_RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
|
||||
echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
|
||||
RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
|
429
libatomic/testsuite/Makefile.in
Normal file
429
libatomic/testsuite/Makefile.in
Normal file
|
@ -0,0 +1,429 @@
|
|||
# Makefile.in generated by automake 1.11.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
target_triplet = @target@
|
||||
subdir = testsuite
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
|
||||
$(top_srcdir)/../config/depstand.m4 \
|
||||
$(top_srcdir)/../config/lead-dot.m4 \
|
||||
$(top_srcdir)/../config/multi.m4 \
|
||||
$(top_srcdir)/../config/override.m4 \
|
||||
$(top_srcdir)/../config/stdint.m4 \
|
||||
$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
|
||||
$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
|
||||
$(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/auto-config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
DEJATOOL = $(PACKAGE)
|
||||
RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCAS = @CCAS@
|
||||
CCASDEPMODE = @CCASDEPMODE@
|
||||
CCASFLAGS = @CCASFLAGS@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OPT_LDFLAGS = @OPT_LDFLAGS@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PERL = @PERL@
|
||||
RANLIB = @RANLIB@
|
||||
SECTION_LDFLAGS = @SECTION_LDFLAGS@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
SIZES = @SIZES@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
XCFLAGS = @XCFLAGS@
|
||||
XLDFLAGS = @XLDFLAGS@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
config_path = @config_path@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
enable_shared = @enable_shared@
|
||||
enable_static = @enable_static@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
libtool_VERSION = @libtool_VERSION@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
multi_basedir = @multi_basedir@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target = @target@
|
||||
target_alias = @target_alias@
|
||||
target_cpu = @target_cpu@
|
||||
target_os = @target_os@
|
||||
target_vendor = @target_vendor@
|
||||
toolexecdir = @toolexecdir@
|
||||
toolexeclibdir = @toolexeclibdir@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = foreign dejagnu
|
||||
|
||||
# May be used by various substitution variables.
|
||||
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
|
||||
EXPECT = $(shell if test -f $(top_builddir)/../expect/expect; then \
|
||||
echo $(top_builddir)/../expect/expect; else echo expect; fi)
|
||||
|
||||
_RUNTEST = $(shell if test -f $(top_srcdir)/../dejagnu/runtest; then \
|
||||
echo $(top_srcdir)/../dejagnu/runtest; else echo runtest; fi)
|
||||
|
||||
RUNTEST = "$(_RUNTEST) $(AM_RUNTESTFLAGS)"
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign testsuite/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
ctags: CTAGS
|
||||
CTAGS:
|
||||
|
||||
|
||||
check-DEJAGNU: site.exp
|
||||
srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
|
||||
EXPECT=$(EXPECT); export EXPECT; \
|
||||
runtest=$(RUNTEST); \
|
||||
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
|
||||
exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
|
||||
if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
|
||||
then :; else exit_status=1; fi; \
|
||||
done; \
|
||||
else echo "WARNING: could not find \`runtest'" 1>&2; :;\
|
||||
fi; \
|
||||
exit $$exit_status
|
||||
site.exp: Makefile
|
||||
@echo 'Making a new site.exp file...'
|
||||
@echo '## these variables are automatically generated by make ##' >site.tmp
|
||||
@echo '# Do not edit here. If you wish to override these values' >>site.tmp
|
||||
@echo '# edit the last section' >>site.tmp
|
||||
@echo 'set srcdir $(srcdir)' >>site.tmp
|
||||
@echo "set objdir `pwd`" >>site.tmp
|
||||
@echo 'set build_alias "$(build_alias)"' >>site.tmp
|
||||
@echo 'set build_triplet $(build_triplet)' >>site.tmp
|
||||
@echo 'set host_alias "$(host_alias)"' >>site.tmp
|
||||
@echo 'set host_triplet $(host_triplet)' >>site.tmp
|
||||
@echo 'set target_alias "$(target_alias)"' >>site.tmp
|
||||
@echo 'set target_triplet $(target_triplet)' >>site.tmp
|
||||
@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
|
||||
@test ! -f site.exp || \
|
||||
sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
|
||||
@-rm -f site.bak
|
||||
@test ! -f site.exp || mv site.exp site.bak
|
||||
@mv site.tmp site.exp
|
||||
|
||||
distclean-DEJAGNU:
|
||||
-rm -f site.exp site.bak
|
||||
-l='$(DEJATOOL)'; for tool in $$l; do \
|
||||
rm -f $$tool.sum $$tool.log; \
|
||||
done
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
|
||||
check: check-am
|
||||
all-am: Makefile
|
||||
installdirs:
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-DEJAGNU distclean-generic
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: check-am install-am install-strip
|
||||
|
||||
.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \
|
||||
clean-libtool distclean distclean-DEJAGNU distclean-generic \
|
||||
distclean-libtool distdir dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
uninstall uninstall-am
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
17
libatomic/testsuite/config/default.exp
Normal file
17
libatomic/testsuite/config/default.exp
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
load_lib "standard.exp"
|
21
libatomic/testsuite/lib/libatomic-dg.exp
Normal file
21
libatomic/testsuite/lib/libatomic-dg.exp
Normal file
|
@ -0,0 +1,21 @@
|
|||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
proc libatomic-dg-test { prog do_what extra_tool_flags } {
|
||||
return [gcc-dg-test-1 libatomic_target_compile $prog $do_what $extra_tool_flags]
|
||||
}
|
||||
|
||||
proc libatomic-dg-prune { system text } {
|
||||
return [gcc-dg-prune $system $text]
|
||||
}
|
220
libatomic/testsuite/lib/libatomic.exp
Normal file
220
libatomic/testsuite/lib/libatomic.exp
Normal file
|
@ -0,0 +1,220 @@
|
|||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
# Damn dejagnu for not having proper library search paths for load_lib.
|
||||
# We have to explicitly load everything that gcc-dg.exp wants to load.
|
||||
|
||||
proc load_gcc_lib { filename } {
|
||||
global srcdir loaded_libs
|
||||
|
||||
load_file $srcdir/../../gcc/testsuite/lib/$filename
|
||||
set loaded_libs($filename) ""
|
||||
}
|
||||
|
||||
load_lib dg.exp
|
||||
load_gcc_lib file-format.exp
|
||||
load_gcc_lib target-supports.exp
|
||||
load_gcc_lib target-supports-dg.exp
|
||||
load_gcc_lib scanasm.exp
|
||||
load_gcc_lib scandump.exp
|
||||
load_gcc_lib scanrtl.exp
|
||||
load_gcc_lib scantree.exp
|
||||
load_gcc_lib scanipa.exp
|
||||
load_gcc_lib prune.exp
|
||||
load_gcc_lib target-libpath.exp
|
||||
load_gcc_lib wrapper.exp
|
||||
load_gcc_lib gcc-defs.exp
|
||||
load_gcc_lib torture-options.exp
|
||||
load_gcc_lib timeout.exp
|
||||
load_gcc_lib timeout-dg.exp
|
||||
load_gcc_lib fortran-modules.exp
|
||||
load_gcc_lib gcc-dg.exp
|
||||
|
||||
set dg-do-what-default run
|
||||
|
||||
#
|
||||
# GCC_UNDER_TEST is the compiler under test.
|
||||
#
|
||||
|
||||
set libatomic_compile_options ""
|
||||
|
||||
#
|
||||
# libatomic_init
|
||||
#
|
||||
|
||||
if [info exists TOOL_OPTIONS] {
|
||||
set multilibs [get_multilibs $TOOL_OPTIONS]
|
||||
} else {
|
||||
set multilibs [get_multilibs]
|
||||
}
|
||||
|
||||
proc libatomic_init { args } {
|
||||
global srcdir blddir objdir tool_root_dir
|
||||
global libatomic_initialized
|
||||
global tmpdir
|
||||
global blddir
|
||||
global gluefile wrap_flags
|
||||
global ALWAYS_CFLAGS
|
||||
global CFLAGS
|
||||
global TOOL_EXECUTABLE TOOL_OPTIONS
|
||||
global GCC_UNDER_TEST
|
||||
global TESTING_IN_BUILD_TREE
|
||||
global target_triplet
|
||||
global always_ld_library_path
|
||||
|
||||
set blddir [lookfor_file [get_multilibs] libatomic]
|
||||
|
||||
# We set LC_ALL and LANG to C so that we get the same error
|
||||
# messages as expected.
|
||||
setenv LC_ALL C
|
||||
setenv LANG C
|
||||
|
||||
if ![info exists GCC_UNDER_TEST] then {
|
||||
if [info exists TOOL_EXECUTABLE] {
|
||||
set GCC_UNDER_TEST $TOOL_EXECUTABLE
|
||||
} else {
|
||||
set GCC_UNDER_TEST "[find_gcc]"
|
||||
}
|
||||
}
|
||||
|
||||
if ![info exists tmpdir] {
|
||||
set tmpdir "/tmp"
|
||||
}
|
||||
|
||||
if [info exists gluefile] {
|
||||
unset gluefile
|
||||
}
|
||||
|
||||
if {![info exists CFLAGS]} {
|
||||
set CFLAGS ""
|
||||
}
|
||||
|
||||
# Locate libgcc.a so we don't need to account for different values of
|
||||
# SHLIB_EXT on different platforms
|
||||
set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
|
||||
if {$gccdir != ""} {
|
||||
set gccdir [file dirname $gccdir]
|
||||
}
|
||||
|
||||
# Compute what needs to be put into LD_LIBRARY_PATH
|
||||
set always_ld_library_path ".:${blddir}/.libs"
|
||||
|
||||
# Compute what needs to be added to the existing LD_LIBRARY_PATH.
|
||||
if {$gccdir != ""} {
|
||||
# Add AIX pthread directory first.
|
||||
if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
|
||||
append always_ld_library_path ":${gccdir}/pthread"
|
||||
}
|
||||
append always_ld_library_path ":${gccdir}"
|
||||
set compiler [lindex $GCC_UNDER_TEST 0]
|
||||
|
||||
if { [is_remote host] == 0 && [which $compiler] != 0 } {
|
||||
foreach i "[exec $compiler --print-multi-lib]" {
|
||||
set mldir ""
|
||||
regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
|
||||
set mldir [string trimright $mldir "\;@"]
|
||||
if { "$mldir" == "." } {
|
||||
continue
|
||||
}
|
||||
if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
|
||||
append always_ld_library_path ":${gccdir}/${mldir}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set ALWAYS_CFLAGS ""
|
||||
if { $blddir != "" } {
|
||||
lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
|
||||
lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
|
||||
lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
|
||||
}
|
||||
lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
|
||||
|
||||
if [istarget *-*-darwin*] {
|
||||
lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
|
||||
}
|
||||
|
||||
if [info exists TOOL_OPTIONS] {
|
||||
lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
|
||||
}
|
||||
|
||||
# Make sure that lines are not wrapped. That can confuse the
|
||||
# error-message parsing machinery.
|
||||
lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
|
||||
|
||||
# Turn off builtin support for atomics so that we test the library.
|
||||
lappend ALWAYS_CFLAGS "additional_flags=-fno-inline-atomics"
|
||||
lappend ALWAYS_CFLAGS "ldflags=-latomic"
|
||||
}
|
||||
|
||||
#
|
||||
# libatomic_target_compile -- compile a source file
|
||||
#
|
||||
|
||||
proc libatomic_target_compile { source dest type options } {
|
||||
global blddir
|
||||
global libatomic_compile_options
|
||||
global gluefile wrap_flags
|
||||
global ALWAYS_CFLAGS
|
||||
global GCC_UNDER_TEST
|
||||
global lang_test_file
|
||||
global lang_library_path
|
||||
global lang_link_flags
|
||||
|
||||
if { [info exists lang_test_file] } {
|
||||
if { $blddir != "" } {
|
||||
lappend options "ldflags=-L${blddir}/${lang_library_path}"
|
||||
}
|
||||
lappend options "ldflags=${lang_link_flags}"
|
||||
}
|
||||
|
||||
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
|
||||
lappend options "libs=${gluefile}"
|
||||
lappend options "ldflags=${wrap_flags}"
|
||||
}
|
||||
|
||||
lappend options "additional_flags=[libio_include_flags]"
|
||||
lappend options "timeout=[timeout_value]"
|
||||
lappend options "compiler=$GCC_UNDER_TEST"
|
||||
|
||||
set options [concat $libatomic_compile_options $options]
|
||||
|
||||
if [info exists ALWAYS_CFLAGS] {
|
||||
set options [concat "$ALWAYS_CFLAGS" $options]
|
||||
}
|
||||
|
||||
set options [dg-additional-files-options $options $source]
|
||||
|
||||
set result [target_compile $source $dest $type $options]
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
proc libatomic_option_help { } {
|
||||
send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
|
||||
}
|
||||
|
||||
proc libatomic_option_proc { option } {
|
||||
if [regexp "^--additional_options," $option] {
|
||||
global libatomic_compile_options
|
||||
regsub "--additional_options," $option "" option
|
||||
foreach x [split $option ","] {
|
||||
lappend libatomic_compile_options "additional_flags=$x"
|
||||
}
|
||||
return 1
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
85
libatomic/testsuite/libatomic.c/atomic-compare-exchange-1.c
Normal file
85
libatomic/testsuite/libatomic.c/atomic-compare-exchange-1.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* Test __atomic routines for existence and proper execution on 1 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
/* Test the execution of the __atomic_compare_exchange_n builtin for a char. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
char v = 0;
|
||||
char expected = 0;
|
||||
char max = ~0;
|
||||
char desired = ~0;
|
||||
char zero = 0;
|
||||
|
||||
#define STRONG 0
|
||||
#define WEAK 1
|
||||
|
||||
main ()
|
||||
{
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
v = 0;
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
85
libatomic/testsuite/libatomic.c/atomic-compare-exchange-2.c
Normal file
85
libatomic/testsuite/libatomic.c/atomic-compare-exchange-2.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* Test __atomic routines for existence and proper execution on 2 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
/* Test the execution of the __atomic_compare_exchange_n builtin for a short. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
short v = 0;
|
||||
short expected = 0;
|
||||
short max = ~0;
|
||||
short desired = ~0;
|
||||
short zero = 0;
|
||||
|
||||
#define STRONG 0
|
||||
#define WEAK 1
|
||||
|
||||
main ()
|
||||
{
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
v = 0;
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
85
libatomic/testsuite/libatomic.c/atomic-compare-exchange-3.c
Normal file
85
libatomic/testsuite/libatomic.c/atomic-compare-exchange-3.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* Test __atomic routines for existence and proper execution on 4 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_long } */
|
||||
|
||||
/* Test the execution of the __atomic_compare_exchange_n builtin for an int. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
int v = 0;
|
||||
int expected = 0;
|
||||
int max = ~0;
|
||||
int desired = ~0;
|
||||
int zero = 0;
|
||||
|
||||
#define STRONG 0
|
||||
#define WEAK 1
|
||||
|
||||
main ()
|
||||
{
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
v = 0;
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
87
libatomic/testsuite/libatomic.c/atomic-compare-exchange-4.c
Normal file
87
libatomic/testsuite/libatomic.c/atomic-compare-exchange-4.c
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* Test __atomic routines for existence and proper execution on 8 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_long_long_runtime } */
|
||||
/* { dg-options "" } */
|
||||
/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
|
||||
|
||||
/* Test the execution of __atomic_compare_exchange_n builtin for a long_long. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
long long v = 0;
|
||||
long long expected = 0;
|
||||
long long max = ~0;
|
||||
long long desired = ~0;
|
||||
long long zero = 0;
|
||||
|
||||
#define STRONG 0
|
||||
#define WEAK 1
|
||||
|
||||
main ()
|
||||
{
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
v = 0;
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
86
libatomic/testsuite/libatomic.c/atomic-compare-exchange-5.c
Normal file
86
libatomic/testsuite/libatomic.c/atomic-compare-exchange-5.c
Normal file
|
@ -0,0 +1,86 @@
|
|||
/* Test __atomic routines for existence and proper execution on 16 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_128_runtime } */
|
||||
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
|
||||
|
||||
/* Test the execution of __atomic_compare_exchange_n builtin for an int_128. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
__int128_t v = 0;
|
||||
__int128_t expected = 0;
|
||||
__int128_t max = ~0;
|
||||
__int128_t desired = ~0;
|
||||
__int128_t zero = 0;
|
||||
|
||||
#define STRONG 0
|
||||
#define WEAK 1
|
||||
|
||||
main ()
|
||||
{
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, max, STRONG , __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange_n (&v, &expected, desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange_n (&v, &expected, desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
v = 0;
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &max, STRONG, __ATOMIC_RELAXED, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &zero, STRONG , __ATOMIC_RELEASE, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != max)
|
||||
abort ();
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&v, &expected, &desired, WEAK, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&v, &expected, &desired, STRONG , __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
|
||||
abort ();
|
||||
if (expected != 0)
|
||||
abort ();
|
||||
if (v != max)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
62
libatomic/testsuite/libatomic.c/atomic-exchange-1.c
Normal file
62
libatomic/testsuite/libatomic.c/atomic-exchange-1.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* Test __atomic routines for existence and proper execution on 1 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
/* Test the execution of the __atomic_exchange_n builtin for a char. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
char v, count, ret;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count++)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
return 0;
|
||||
}
|
62
libatomic/testsuite/libatomic.c/atomic-exchange-2.c
Normal file
62
libatomic/testsuite/libatomic.c/atomic-exchange-2.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* Test __atomic routines for existence and proper execution on 2 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
/* Test the execution of the __atomic_X builtin for a short. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
short v, count, ret;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count++)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
return 0;
|
||||
}
|
62
libatomic/testsuite/libatomic.c/atomic-exchange-3.c
Normal file
62
libatomic/testsuite/libatomic.c/atomic-exchange-3.c
Normal file
|
@ -0,0 +1,62 @@
|
|||
/* Test __atomic routines for existence and proper execution on 4 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_long } */
|
||||
|
||||
/* Test the execution of the __atomic_X builtin for an int. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
int v, count, ret;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count++)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
return 0;
|
||||
}
|
64
libatomic/testsuite/libatomic.c/atomic-exchange-4.c
Normal file
64
libatomic/testsuite/libatomic.c/atomic-exchange-4.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/* Test __atomic routines for existence and proper execution on 8 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_long_long_runtime } */
|
||||
/* { dg-options "" } */
|
||||
/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
|
||||
|
||||
/* Test the execution of the __atomic_X builtin for a long_long. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
long long v, count, ret;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count++)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
return 0;
|
||||
}
|
63
libatomic/testsuite/libatomic.c/atomic-exchange-5.c
Normal file
63
libatomic/testsuite/libatomic.c/atomic-exchange-5.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* Test __atomic routines for existence and proper execution on 16 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_128_runtime } */
|
||||
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
|
||||
|
||||
/* Test the execution of the __atomic_X builtin for a 16 byte value. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
__int128_t v, count, ret;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count++)
|
||||
abort ();
|
||||
|
||||
if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count++)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic version. */
|
||||
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELAXED);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQUIRE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_RELEASE);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_ACQ_REL);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
__atomic_exchange (&v, &count, &ret, __ATOMIC_SEQ_CST);
|
||||
if (ret != count - 1 || v != count)
|
||||
abort ();
|
||||
count++;
|
||||
|
||||
return 0;
|
||||
}
|
55
libatomic/testsuite/libatomic.c/atomic-generic.c
Normal file
55
libatomic/testsuite/libatomic.c/atomic-generic.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
/* Test generic __atomic routines for proper function calling.
|
||||
memory model. */
|
||||
/* { dg-options "-w" } */
|
||||
/* { dg-do run } */
|
||||
|
||||
/* Test that the generioc atomic builtins execute as expected..
|
||||
sync-mem-generic-aux.c supplies a functional external entry point for
|
||||
the 4 generic functions. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
extern void abort();
|
||||
|
||||
typedef struct test {
|
||||
int array[10];
|
||||
} test_struct;
|
||||
|
||||
test_struct zero = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
test_struct ones = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||
test_struct a,b;
|
||||
|
||||
int size = sizeof (test_struct);
|
||||
/* Test for consistency on sizes 1, 2, 4, 8, 16 and 32. */
|
||||
main ()
|
||||
{
|
||||
test_struct c;
|
||||
|
||||
__atomic_store (&a, &zero, __ATOMIC_RELAXED);
|
||||
if (memcmp (&a, &zero, size))
|
||||
abort ();
|
||||
|
||||
__atomic_exchange (&a, &ones, &c, __ATOMIC_SEQ_CST);
|
||||
if (memcmp (&c, &zero, size))
|
||||
abort ();
|
||||
if (memcmp (&a, &ones, size))
|
||||
abort ();
|
||||
|
||||
__atomic_load (&a, &b, __ATOMIC_RELAXED);
|
||||
if (memcmp (&b, &ones, size))
|
||||
abort ();
|
||||
|
||||
if (!__atomic_compare_exchange (&a, &b, &zero, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE))
|
||||
abort();
|
||||
if (memcmp (&a, &zero, size))
|
||||
abort ();
|
||||
|
||||
if (__atomic_compare_exchange (&a, &b, &ones, false, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE))
|
||||
abort();
|
||||
if (memcmp (&b, &zero, size))
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
66
libatomic/testsuite/libatomic.c/atomic-load-1.c
Normal file
66
libatomic/testsuite/libatomic.c/atomic-load-1.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* Test __atomic routines for existence and proper execution on 1 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
|
||||
/* Test the execution of the __atomic_load_n builtin for a char. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
char v, count;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
/* Now test the generic variants. */
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_RELAXED);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_ACQUIRE);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_CONSUME);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
68
libatomic/testsuite/libatomic.c/atomic-load-2.c
Normal file
68
libatomic/testsuite/libatomic.c/atomic-load-2.c
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* Test __atomic routines for existence and proper execution on 2 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
|
||||
/* Test the execution of the __atomic_load_n builtin for a short. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
short v, count;
|
||||
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
/* Now test the generic variants. */
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_RELAXED);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_ACQUIRE);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_CONSUME);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
65
libatomic/testsuite/libatomic.c/atomic-load-3.c
Normal file
65
libatomic/testsuite/libatomic.c/atomic-load-3.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* Test __atomic routines for existence and proper execution on 4 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_long } */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
int v, count;
|
||||
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
/* Now test the generic variants. */
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_RELAXED);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_ACQUIRE);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_CONSUME);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
66
libatomic/testsuite/libatomic.c/atomic-load-4.c
Normal file
66
libatomic/testsuite/libatomic.c/atomic-load-4.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
/* Test __atomic routines for existence and proper execution on 8 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_long_long_runtime } */
|
||||
/* { dg-options "" } */
|
||||
/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
long long v, count;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
/* Now test the generic variants. */
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_RELAXED);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_ACQUIRE);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_CONSUME);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
65
libatomic/testsuite/libatomic.c/atomic-load-5.c
Normal file
65
libatomic/testsuite/libatomic.c/atomic-load-5.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* Test __atomic routines for existence and proper execution on 16 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_128_runtime } */
|
||||
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
__int128_t v, count;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_RELAXED) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_ACQUIRE) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_CONSUME) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
if (__atomic_load_n (&v, __ATOMIC_SEQ_CST) != count++)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
/* Now test the generic variants. */
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_RELAXED);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_ACQUIRE);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_CONSUME);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
__atomic_load (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (count != v)
|
||||
abort();
|
||||
else
|
||||
v++;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
554
libatomic/testsuite/libatomic.c/atomic-op-1.c
Normal file
554
libatomic/testsuite/libatomic.c/atomic-op-1.c
Normal file
|
@ -0,0 +1,554 @@
|
|||
/* Test __atomic routines for existence and proper execution on 1 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
/* Test the execution of the __atomic_*OP builtin routines for a char. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
char v, count, res;
|
||||
const char init = ~0;
|
||||
|
||||
/* The fetch_op routines return the original value before the operation. */
|
||||
|
||||
void
|
||||
test_fetch_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_fetch_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 )
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* The OP_fetch routines return the new value after the operation. */
|
||||
|
||||
void
|
||||
test_add_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub_fetch ()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor_fetch ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Test the OP routines with a result which isn't used. Use both variations
|
||||
within each function. */
|
||||
|
||||
void
|
||||
test_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 2)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != 4)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 5)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE);
|
||||
if (v != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE);
|
||||
if (v != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
test_fetch_add ();
|
||||
test_fetch_sub ();
|
||||
test_fetch_and ();
|
||||
test_fetch_nand ();
|
||||
test_fetch_xor ();
|
||||
test_fetch_or ();
|
||||
|
||||
test_add_fetch ();
|
||||
test_sub_fetch ();
|
||||
test_and_fetch ();
|
||||
test_nand_fetch ();
|
||||
test_xor_fetch ();
|
||||
test_or_fetch ();
|
||||
|
||||
test_add ();
|
||||
test_sub ();
|
||||
test_and ();
|
||||
test_nand ();
|
||||
test_xor ();
|
||||
test_or ();
|
||||
|
||||
return 0;
|
||||
}
|
555
libatomic/testsuite/libatomic.c/atomic-op-2.c
Normal file
555
libatomic/testsuite/libatomic.c/atomic-op-2.c
Normal file
|
@ -0,0 +1,555 @@
|
|||
/* Test __atomic routines for existence and proper execution on 2 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
|
||||
/* Test the execution of the __atomic_*OP builtin routines for a short. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
short v, count, res;
|
||||
const short init = ~0;
|
||||
|
||||
/* The fetch_op routines return the original value before the operation. */
|
||||
|
||||
void
|
||||
test_fetch_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_fetch_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 )
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* The OP_fetch routines return the new value after the operation. */
|
||||
|
||||
void
|
||||
test_add_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub_fetch ()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor_fetch ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Test the OP routines with a result which isn't used. Use both variations
|
||||
within each function. */
|
||||
|
||||
void
|
||||
test_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 2)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != 4)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 5)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE);
|
||||
if (v != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE);
|
||||
if (v != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
test_fetch_add ();
|
||||
test_fetch_sub ();
|
||||
test_fetch_and ();
|
||||
test_fetch_nand ();
|
||||
test_fetch_xor ();
|
||||
test_fetch_or ();
|
||||
|
||||
test_add_fetch ();
|
||||
test_sub_fetch ();
|
||||
test_and_fetch ();
|
||||
test_nand_fetch ();
|
||||
test_xor_fetch ();
|
||||
test_or_fetch ();
|
||||
|
||||
test_add ();
|
||||
test_sub ();
|
||||
test_and ();
|
||||
test_nand ();
|
||||
test_xor ();
|
||||
test_or ();
|
||||
|
||||
return 0;
|
||||
}
|
554
libatomic/testsuite/libatomic.c/atomic-op-3.c
Normal file
554
libatomic/testsuite/libatomic.c/atomic-op-3.c
Normal file
|
@ -0,0 +1,554 @@
|
|||
/* Test __atomic routines for existence and proper execution on 4 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_long } */
|
||||
|
||||
/* Test the execution of the __atomic_*OP builtin routines for an int. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
int v, count, res;
|
||||
const int init = ~0;
|
||||
|
||||
/* The fetch_op routines return the original value before the operation. */
|
||||
|
||||
void
|
||||
test_fetch_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_fetch_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 )
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* The OP_fetch routines return the new value after the operation. */
|
||||
|
||||
void
|
||||
test_add_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub_fetch ()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor_fetch ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Test the OP routines with a result which isn't used. Use both variations
|
||||
within each function. */
|
||||
|
||||
void
|
||||
test_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 2)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != 4)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 5)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE);
|
||||
if (v != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE);
|
||||
if (v != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
test_fetch_add ();
|
||||
test_fetch_sub ();
|
||||
test_fetch_and ();
|
||||
test_fetch_nand ();
|
||||
test_fetch_xor ();
|
||||
test_fetch_or ();
|
||||
|
||||
test_add_fetch ();
|
||||
test_sub_fetch ();
|
||||
test_and_fetch ();
|
||||
test_nand_fetch ();
|
||||
test_xor_fetch ();
|
||||
test_or_fetch ();
|
||||
|
||||
test_add ();
|
||||
test_sub ();
|
||||
test_and ();
|
||||
test_nand ();
|
||||
test_xor ();
|
||||
test_or ();
|
||||
|
||||
return 0;
|
||||
}
|
556
libatomic/testsuite/libatomic.c/atomic-op-4.c
Normal file
556
libatomic/testsuite/libatomic.c/atomic-op-4.c
Normal file
|
@ -0,0 +1,556 @@
|
|||
/* Test __atomic routines for existence and proper execution on 8 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_long_long_runtime } */
|
||||
/* { dg-options "" } */
|
||||
/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
|
||||
|
||||
/* Test the execution of the __atomic_*OP builtin routines for long long. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
long long v, count, res;
|
||||
const long long init = ~0;
|
||||
|
||||
/* The fetch_op routines return the original value before the operation. */
|
||||
|
||||
void
|
||||
test_fetch_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_fetch_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 )
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* The OP_fetch routines return the new value after the operation. */
|
||||
|
||||
void
|
||||
test_add_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub_fetch ()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor_fetch ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Test the OP routines with a result which isn't used. Use both variations
|
||||
within each function. */
|
||||
|
||||
void
|
||||
test_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 2)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != 4)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 5)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE);
|
||||
if (v != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE);
|
||||
if (v != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
test_fetch_add ();
|
||||
test_fetch_sub ();
|
||||
test_fetch_and ();
|
||||
test_fetch_nand ();
|
||||
test_fetch_xor ();
|
||||
test_fetch_or ();
|
||||
|
||||
test_add_fetch ();
|
||||
test_sub_fetch ();
|
||||
test_and_fetch ();
|
||||
test_nand_fetch ();
|
||||
test_xor_fetch ();
|
||||
test_or_fetch ();
|
||||
|
||||
test_add ();
|
||||
test_sub ();
|
||||
test_and ();
|
||||
test_nand ();
|
||||
test_xor ();
|
||||
test_or ();
|
||||
|
||||
return 0;
|
||||
}
|
555
libatomic/testsuite/libatomic.c/atomic-op-5.c
Normal file
555
libatomic/testsuite/libatomic.c/atomic-op-5.c
Normal file
|
@ -0,0 +1,555 @@
|
|||
/* Test __atomic routines for existence and proper execution on 16 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_128_runtime } */
|
||||
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
|
||||
|
||||
/* Test the execution of the __atomic_*OP builtin routines for an int_128. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
__int128_t v, count, res;
|
||||
const __int128_t init = ~0;
|
||||
|
||||
/* The fetch_op routines return the original value before the operation. */
|
||||
|
||||
void
|
||||
test_fetch_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQUIRE) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, count, __ATOMIC_ACQ_REL) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_add (&v, 1, __ATOMIC_SEQ_CST) != 5)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_fetch_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_RELAXED) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_CONSUME) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQUIRE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, count + 1, __ATOMIC_ACQ_REL) != res--)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_sub (&v, 1, __ATOMIC_SEQ_CST) != res--)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_fetch_and (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_ACQUIRE) != 0 )
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_nand (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_fetch_xor (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_fetch_xor (&v, ~count, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_fetch_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 2, __ATOMIC_CONSUME) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_ACQ_REL) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST) != 31)
|
||||
abort ();
|
||||
}
|
||||
|
||||
/* The OP_fetch routines return the new value after the operation. */
|
||||
|
||||
void
|
||||
test_add_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_CONSUME) != 2)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQUIRE) != 3)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, 1, __ATOMIC_RELEASE) != 4)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL) != 5)
|
||||
abort ();
|
||||
|
||||
if (__atomic_add_fetch (&v, count, __ATOMIC_SEQ_CST) != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub_fetch ()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_CONSUME) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQUIRE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, 1, __ATOMIC_RELEASE) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL) != --res)
|
||||
abort ();
|
||||
|
||||
if (__atomic_sub_fetch (&v, count + 1, __ATOMIC_SEQ_CST) != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED) != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_CONSUME) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, init, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL) != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
if (__atomic_and_fetch (&v, 0, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand_fetch ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, init, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST) != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor_fetch ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
if (__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_CONSUME) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE) != 0)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_RELEASE) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, 0, __ATOMIC_ACQ_REL) != init)
|
||||
abort ();
|
||||
|
||||
if (__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST) != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or_fetch ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_RELAXED) != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 2, __ATOMIC_CONSUME) != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQUIRE) != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, 8, __ATOMIC_RELEASE) != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL) != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
if (__atomic_or_fetch (&v, count, __ATOMIC_SEQ_CST) != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
/* Test the OP routines with a result which isn't used. Use both variations
|
||||
within each function. */
|
||||
|
||||
void
|
||||
test_add ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 2)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, 1 , __ATOMIC_ACQUIRE);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != 4)
|
||||
abort ();
|
||||
|
||||
__atomic_add_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 5)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_add (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 6)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
test_sub()
|
||||
{
|
||||
v = res = 20;
|
||||
count = 0;
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_CONSUME);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, 1, __ATOMIC_ACQUIRE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, 1, __ATOMIC_RELEASE);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_sub_fetch (&v, count + 1, __ATOMIC_ACQ_REL);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_sub (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != --res)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_and ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = init;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_and_fetch (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
v = ~v;
|
||||
__atomic_fetch_and (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_nand ()
|
||||
{
|
||||
v = init;
|
||||
|
||||
__atomic_fetch_nand (&v, 0, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, init, __ATOMIC_RELEASE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_nand (&v, init, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_nand_fetch (&v, 0, __ATOMIC_SEQ_CST);
|
||||
if (v != init)
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
test_xor ()
|
||||
{
|
||||
v = init;
|
||||
count = 0;
|
||||
|
||||
__atomic_xor_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_CONSUME);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, 0, __ATOMIC_ACQUIRE);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, ~count, __ATOMIC_RELEASE);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_fetch_xor (&v, 0, __ATOMIC_ACQ_REL);
|
||||
if (v != init)
|
||||
abort ();
|
||||
|
||||
__atomic_xor_fetch (&v, ~count, __ATOMIC_SEQ_CST);
|
||||
if (v != 0)
|
||||
abort ();
|
||||
}
|
||||
|
||||
void
|
||||
test_or ()
|
||||
{
|
||||
v = 0;
|
||||
count = 1;
|
||||
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_RELAXED);
|
||||
if (v != 1)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_CONSUME);
|
||||
if (v != 3)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, 4, __ATOMIC_ACQUIRE);
|
||||
if (v != 7)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, 8, __ATOMIC_RELEASE);
|
||||
if (v != 15)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_or_fetch (&v, count, __ATOMIC_ACQ_REL);
|
||||
if (v != 31)
|
||||
abort ();
|
||||
|
||||
count *= 2;
|
||||
__atomic_fetch_or (&v, count, __ATOMIC_SEQ_CST);
|
||||
if (v != 63)
|
||||
abort ();
|
||||
}
|
||||
|
||||
main ()
|
||||
{
|
||||
test_fetch_add ();
|
||||
test_fetch_sub ();
|
||||
test_fetch_and ();
|
||||
test_fetch_nand ();
|
||||
test_fetch_xor ();
|
||||
test_fetch_or ();
|
||||
|
||||
test_add_fetch ();
|
||||
test_sub_fetch ();
|
||||
test_and_fetch ();
|
||||
test_nand_fetch ();
|
||||
test_xor_fetch ();
|
||||
test_or_fetch ();
|
||||
|
||||
test_add ();
|
||||
test_sub ();
|
||||
test_and ();
|
||||
test_nand ();
|
||||
test_xor ();
|
||||
test_or ();
|
||||
|
||||
return 0;
|
||||
}
|
47
libatomic/testsuite/libatomic.c/atomic-store-1.c
Normal file
47
libatomic/testsuite/libatomic.c/atomic-store-1.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* Test __atomic routines for existence and proper execution on 1 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
/* Test the execution of the __atomic_store_n builtin for a char. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
char v, count;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic variant. */
|
||||
count++;
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELAXED);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELEASE);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (v != count)
|
||||
abort ();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
46
libatomic/testsuite/libatomic.c/atomic-store-2.c
Normal file
46
libatomic/testsuite/libatomic.c/atomic-store-2.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* Test __atomic routines for existence and proper execution on 2 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_char_short } */
|
||||
|
||||
/* Test the execution of the __atomic_store_n builtin for a short. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
short v, count;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic variant. */
|
||||
count++;
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELAXED);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELEASE);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (v != count)
|
||||
abort ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
47
libatomic/testsuite/libatomic.c/atomic-store-3.c
Normal file
47
libatomic/testsuite/libatomic.c/atomic-store-3.c
Normal file
|
@ -0,0 +1,47 @@
|
|||
/* Test __atomic routines for existence and proper execution on 4 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_long } */
|
||||
|
||||
/* Test the execution of the __atomic_store_n builtin for an int. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
int v, count;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic variant. */
|
||||
count++;
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELAXED);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELEASE);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (v != count)
|
||||
abort ();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
49
libatomic/testsuite/libatomic.c/atomic-store-4.c
Normal file
49
libatomic/testsuite/libatomic.c/atomic-store-4.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* Test __atomic routines for existence and proper execution on 8 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_long_long_runtime } */
|
||||
/* { dg-options "" } */
|
||||
/* { dg-options "-march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
|
||||
|
||||
/* Test the execution of the __atomic_store_n builtin for a long long. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
long long v, count;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic variant. */
|
||||
count++;
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELAXED);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELEASE);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (v != count)
|
||||
abort ();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
48
libatomic/testsuite/libatomic.c/atomic-store-5.c
Normal file
48
libatomic/testsuite/libatomic.c/atomic-store-5.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Test __atomic routines for existence and proper execution on 16 byte
|
||||
values with each valid memory model. */
|
||||
/* { dg-do run } */
|
||||
/* { dg-require-effective-target sync_int_128_runtime } */
|
||||
/* { dg-options "-mcx16" { target { i?86-*-* x86_64-*-* } } } */
|
||||
|
||||
/* Test the execution of the __atomic_store_n builtin for a 16 byte value. */
|
||||
|
||||
extern void abort(void);
|
||||
|
||||
__int128_t v, count;
|
||||
|
||||
main ()
|
||||
{
|
||||
v = 0;
|
||||
count = 0;
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELAXED);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_RELEASE);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
__atomic_store_n (&v, count + 1, __ATOMIC_SEQ_CST);
|
||||
if (v != ++count)
|
||||
abort ();
|
||||
|
||||
/* Now test the generic variant. */
|
||||
count++;
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELAXED);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_RELEASE);
|
||||
if (v != count++)
|
||||
abort ();
|
||||
|
||||
__atomic_store (&v, &count, __ATOMIC_SEQ_CST);
|
||||
if (v != count)
|
||||
abort ();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
44
libatomic/testsuite/libatomic.c/c.exp
Normal file
44
libatomic/testsuite/libatomic.c/c.exp
Normal file
|
@ -0,0 +1,44 @@
|
|||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
if [info exists lang_library_path] then {
|
||||
unset lang_library_path
|
||||
unset lang_link_flags
|
||||
}
|
||||
if [info exists lang_test_file] then {
|
||||
unset lang_test_file
|
||||
}
|
||||
|
||||
load_lib libatomic-dg.exp
|
||||
|
||||
# If a testcase doesn't have special options, use these.
|
||||
if ![info exists DEFAULT_CFLAGS] then {
|
||||
set DEFAULT_CFLAGS "-g"
|
||||
}
|
||||
|
||||
# Initialize dg.
|
||||
dg-init
|
||||
|
||||
# Gather a list of all tests.
|
||||
set tests [lsort [find $srcdir/$subdir *.c]]
|
||||
|
||||
set ld_library_path $always_ld_library_path
|
||||
append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
|
||||
set_ld_library_path_env_vars
|
||||
|
||||
# Main loop.
|
||||
dg-runtest $tests "" $DEFAULT_CFLAGS
|
||||
|
||||
# All done.
|
||||
dg-finish
|
128
libatomic/testsuite/libatomic.c/generic-2.c
Normal file
128
libatomic/testsuite/libatomic.c/generic-2.c
Normal file
|
@ -0,0 +1,128 @@
|
|||
/* { dg-do run } */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Avoid using the builtins, calling directly to the library functions
|
||||
of the same name, so that we get direct access to the size_t and
|
||||
don't have to create myriad types of different sizes. */
|
||||
|
||||
#define C2_(X,Y) X ## Y
|
||||
#define C2(X,Y) C2_(X,Y)
|
||||
|
||||
#define S2(X) #X
|
||||
#define S(X) S2(X)
|
||||
|
||||
#define ASMNAME(X) __asm__(S(C2(__USER_LABEL_PREFIX__,X)))
|
||||
#define MAN(X) ASMNAME(C2(__atomic_,X))
|
||||
|
||||
void libat_load (size_t, void *, void *, int) MAN(load);
|
||||
void libat_store (size_t, void *, void *, int) MAN(store);
|
||||
void libat_exchange (size_t, void *, void *, void *, int) MAN(exchange);
|
||||
bool libat_compare_exchange (size_t, void *, void *, void *, int, int)
|
||||
MAN(compare_exchange);
|
||||
bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
|
||||
|
||||
|
||||
#define ALIGN 16
|
||||
#define MAX 4*ALIGN
|
||||
|
||||
static char a[MAX];
|
||||
static char b[MAX];
|
||||
static char c[MAX];
|
||||
static char pa[MAX];
|
||||
static char pb[MAX];
|
||||
|
||||
static void test_load(void)
|
||||
{
|
||||
int i, j;
|
||||
for (i = ALIGN; i < 2*ALIGN; ++i)
|
||||
for (j = 1; j <= 2*ALIGN; ++j)
|
||||
{
|
||||
memcpy(b, pa, MAX);
|
||||
memcpy(b + i, pb, j);
|
||||
libat_load (j, b + i, a, 0);
|
||||
if (memcmp (a, pb, j) != 0) abort ();
|
||||
}
|
||||
}
|
||||
|
||||
static void test_store(void)
|
||||
{
|
||||
int i, j;
|
||||
for (i = ALIGN; i < 2*ALIGN; ++i)
|
||||
for (j = 1; j <= 2*ALIGN; ++j)
|
||||
{
|
||||
memcpy(a, pa, MAX);
|
||||
memcpy(b, pa, MAX);
|
||||
memcpy(b + i, pb, j);
|
||||
libat_store (j, a + i, pb, 0);
|
||||
if (memcmp (a, b, MAX) != 0) abort ();
|
||||
}
|
||||
}
|
||||
|
||||
static void test_exch(void)
|
||||
{
|
||||
int i, j;
|
||||
for (i = ALIGN; i < 2 * ALIGN; ++i)
|
||||
for (j = 1; j <= 2*ALIGN; ++j)
|
||||
{
|
||||
memcpy(a, pa, MAX);
|
||||
memcpy(b, pa, MAX);
|
||||
memcpy(b + i, pb, j);
|
||||
libat_exchange (j, a + i, pb, c, 0);
|
||||
if (memcmp (a, b, MAX) != 0) abort ();
|
||||
if (memcmp (c, pa + i, j) != 0) abort ();
|
||||
|
||||
memcpy(a, pa, MAX);
|
||||
memcpy(c, pb, MAX);
|
||||
libat_exchange (j, a + i, c + i, c + i, 0);
|
||||
memcpy(b, pa, MAX);
|
||||
memcpy(b + i, pb + i, j);
|
||||
if (memcmp (b, a, MAX) != 0) abort ();
|
||||
memcpy(b, pb, MAX);
|
||||
memcpy(b + i, pa + i, j);
|
||||
if (memcmp (b, c, MAX) != 0) abort ();
|
||||
}
|
||||
}
|
||||
|
||||
static void test_cas(void)
|
||||
{
|
||||
int i, j;
|
||||
for (i = ALIGN; i < 2 * ALIGN; ++i)
|
||||
for (j = 1; j <= 2*ALIGN; ++j)
|
||||
{
|
||||
memcpy(a, pa, MAX);
|
||||
memcpy(b, pa, MAX);
|
||||
memcpy(c, pa, MAX);
|
||||
memcpy(b + i, pb, j);
|
||||
if (!libat_compare_exchange (j, a + i, c + i, pb, 0, 0)) abort ();
|
||||
if (memcmp (c, pa, MAX) != 0) abort ();
|
||||
if (memcmp (a, b, MAX) != 0) abort ();
|
||||
|
||||
memcpy(a, pb, MAX);
|
||||
memcpy(b, pa, MAX);
|
||||
memcpy(c, pa, MAX);
|
||||
memcpy(b + i, pb + i, j);
|
||||
if (libat_compare_exchange (j, a + i, c + i, pb, 0, 0)) abort ();
|
||||
if (memcmp (a, pb, MAX) != 0) abort ();
|
||||
if (memcmp (b, c, MAX) != 0) abort ();
|
||||
}
|
||||
}
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < MAX; ++i)
|
||||
{
|
||||
pa[i] = i * 2;
|
||||
pb[i] = i * 2 + 1;
|
||||
}
|
||||
|
||||
test_load ();
|
||||
test_store ();
|
||||
test_exch ();
|
||||
test_cas ();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue