aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libatomic/testsuite
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/libatomic/testsuite
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/libatomic/testsuite')
-rw-r--r--gcc-4.9/libatomic/testsuite/Makefile.am13
-rw-r--r--gcc-4.9/libatomic/testsuite/Makefile.in397
-rw-r--r--gcc-4.9/libatomic/testsuite/config/default.exp17
-rw-r--r--gcc-4.9/libatomic/testsuite/lib/libatomic-dg.exp21
-rw-r--r--gcc-4.9/libatomic/testsuite/lib/libatomic.exp220
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-1.c85
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-2.c85
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-3.c85
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-4.c86
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-5.c86
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-1.c67
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-2.c67
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-3.c67
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-4.c68
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-5.c68
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-generic.c56
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-1.c66
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-2.c68
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-3.c65
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-4.c65
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-5.c65
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-1.c554
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-2.c555
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-3.c554
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-4.c555
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-5.c555
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-1.c47
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-2.c46
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-3.c47
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-4.c48
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-5.c48
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/c.exp44
-rw-r--r--gcc-4.9/libatomic/testsuite/libatomic.c/generic-2.c128
33 files changed, 4998 insertions, 0 deletions
diff --git a/gcc-4.9/libatomic/testsuite/Makefile.am b/gcc-4.9/libatomic/testsuite/Makefile.am
new file mode 100644
index 000000000..561b7e254
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/Makefile.am
@@ -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)"
diff --git a/gcc-4.9/libatomic/testsuite/Makefile.in b/gcc-4.9/libatomic/testsuite/Makefile.in
new file mode 100644
index 000000000..2a8d90999
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/Makefile.in
@@ -0,0 +1,397 @@
+# 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.in $(srcdir)/Makefile.am
+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 =
+DEJATOOL = $(PACKAGE)
+RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
+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@
+MAINT = @MAINT@
+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: @MAINTAINER_MODE_TRUE@ $(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: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(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
+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 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:
diff --git a/gcc-4.9/libatomic/testsuite/config/default.exp b/gcc-4.9/libatomic/testsuite/config/default.exp
new file mode 100644
index 000000000..ccfda11bc
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/config/default.exp
@@ -0,0 +1,17 @@
+# Copyright (C) 2011-2014 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"
diff --git a/gcc-4.9/libatomic/testsuite/lib/libatomic-dg.exp b/gcc-4.9/libatomic/testsuite/lib/libatomic-dg.exp
new file mode 100644
index 000000000..132d637dd
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/lib/libatomic-dg.exp
@@ -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]
+}
diff --git a/gcc-4.9/libatomic/testsuite/lib/libatomic.exp b/gcc-4.9/libatomic/testsuite/lib/libatomic.exp
new file mode 100644
index 000000000..23c3b0828
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/lib/libatomic.exp
@@ -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
+ }
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-1.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-1.c
new file mode 100644
index 000000000..33dba8640
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-1.c
@@ -0,0 +1,85 @@
+/* Test __atomic routines for existence and proper execution on 1 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* 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
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-2.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-2.c
new file mode 100644
index 000000000..588f3d2fa
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-2.c
@@ -0,0 +1,85 @@
+/* Test __atomic routines for existence and proper execution on 2 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* 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
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-3.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-3.c
new file mode 100644
index 000000000..f424c4a2f
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-3.c
@@ -0,0 +1,85 @@
+/* Test __atomic routines for existence and proper execution on 4 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* 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
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-4.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-4.c
new file mode 100644
index 000000000..5274f8c44
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-4.c
@@ -0,0 +1,86 @@
+/* Test __atomic routines for existence and proper execution on 8 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+/* 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
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-5.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-5.c
new file mode 100644
index 000000000..fd05ce744
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-compare-exchange-5.c
@@ -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 int128 } */
+
+/* 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
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-1.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-1.c
new file mode 100644
index 000000000..71c19807f
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-1.c
@@ -0,0 +1,67 @@
+/* Test __atomic routines for existence and proper execution on 1 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* Test the execution of the __atomic_exchange_n builtin for a char. */
+
+extern void abort(void);
+
+char v, count, ret;
+
+int
+main ()
+{
+ v = 0;
+ count = 0;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count)
+ abort ();
+ count++;
+
+ /* 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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-2.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-2.c
new file mode 100644
index 000000000..e06d72951
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-2.c
@@ -0,0 +1,67 @@
+/* Test __atomic routines for existence and proper execution on 2 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* Test the execution of the __atomic_X builtin for a short. */
+
+extern void abort(void);
+
+short v, count, ret;
+
+int
+main ()
+{
+ v = 0;
+ count = 0;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count)
+ abort ();
+ count++;
+
+ /* 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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-3.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-3.c
new file mode 100644
index 000000000..56841d99b
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-3.c
@@ -0,0 +1,67 @@
+/* Test __atomic routines for existence and proper execution on 4 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* Test the execution of the __atomic_X builtin for an int. */
+
+extern void abort(void);
+
+int v, count, ret;
+
+int
+main ()
+{
+ v = 0;
+ count = 0;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count)
+ abort ();
+ count++;
+
+ /* 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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-4.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-4.c
new file mode 100644
index 000000000..db867d6e5
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-4.c
@@ -0,0 +1,68 @@
+/* Test __atomic routines for existence and proper execution on 8 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+/* Test the execution of the __atomic_X builtin for a long_long. */
+
+extern void abort(void);
+
+long long v, count, ret;
+
+int
+main ()
+{
+ v = 0;
+ count = 0;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count)
+ abort ();
+ count++;
+
+ /* 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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-5.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-5.c
new file mode 100644
index 000000000..02d4a8897
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-exchange-5.c
@@ -0,0 +1,68 @@
+/* Test __atomic routines for existence and proper execution on 16 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+
+/* Test the execution of the __atomic_X builtin for a 16 byte value. */
+
+extern void abort(void);
+
+__int128_t v, count, ret;
+
+int
+main ()
+{
+ v = 0;
+ count = 0;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELAXED) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQUIRE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_RELEASE) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_ACQ_REL) != count)
+ abort ();
+ count++;
+
+ if (__atomic_exchange_n (&v, count + 1, __ATOMIC_SEQ_CST) != count)
+ abort ();
+ count++;
+
+ /* 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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-generic.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-generic.c
new file mode 100644
index 000000000..11ef6c583
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-generic.c
@@ -0,0 +1,56 @@
+/* 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. */
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-1.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-1.c
new file mode 100644
index 000000000..d7e430434
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-1.c
@@ -0,0 +1,66 @@
+/* Test __atomic routines for existence and proper execution on 1 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+
+/* Test the execution of the __atomic_load_n builtin for a char. */
+
+extern void abort(void);
+
+char v, count;
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-2.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-2.c
new file mode 100644
index 000000000..df2966be7
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-2.c
@@ -0,0 +1,68 @@
+/* Test __atomic routines for existence and proper execution on 2 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+
+/* Test the execution of the __atomic_load_n builtin for a short. */
+
+extern void abort(void);
+
+short v, count;
+
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-3.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-3.c
new file mode 100644
index 000000000..b54cc4b2c
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-3.c
@@ -0,0 +1,65 @@
+/* Test __atomic routines for existence and proper execution on 4 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+extern void abort(void);
+
+int v, count;
+
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-4.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-4.c
new file mode 100644
index 000000000..97e46861d
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-4.c
@@ -0,0 +1,65 @@
+/* Test __atomic routines for existence and proper execution on 8 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+extern void abort(void);
+
+long long v, count;
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-5.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-5.c
new file mode 100644
index 000000000..570539376
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-load-5.c
@@ -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 int128 } */
+
+extern void abort(void);
+
+__int128_t v, count;
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-1.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-1.c
new file mode 100644
index 000000000..566322914
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-1.c
@@ -0,0 +1,554 @@
+/* Test __atomic routines for existence and proper execution on 1 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* 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 ();
+}
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-2.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-2.c
new file mode 100644
index 000000000..436b206b4
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-2.c
@@ -0,0 +1,555 @@
+/* Test __atomic routines for existence and proper execution on 2 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+
+/* 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 ();
+}
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-3.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-3.c
new file mode 100644
index 000000000..d72be2e9d
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-3.c
@@ -0,0 +1,554 @@
+/* Test __atomic routines for existence and proper execution on 4 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* 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 ();
+}
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-4.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-4.c
new file mode 100644
index 000000000..0998c3a65
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-4.c
@@ -0,0 +1,555 @@
+/* Test __atomic routines for existence and proper execution on 8 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+/* 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 ();
+}
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-5.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-5.c
new file mode 100644
index 000000000..763880da0
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-op-5.c
@@ -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 int128 } */
+
+/* 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 ();
+}
+
+int
+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;
+}
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-1.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-1.c
new file mode 100644
index 000000000..019aa423f
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-1.c
@@ -0,0 +1,47 @@
+/* Test __atomic routines for existence and proper execution on 1 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* Test the execution of the __atomic_store_n builtin for a char. */
+
+extern void abort(void);
+
+char v, count;
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-2.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-2.c
new file mode 100644
index 000000000..278152788
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-2.c
@@ -0,0 +1,46 @@
+/* Test __atomic routines for existence and proper execution on 2 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* Test the execution of the __atomic_store_n builtin for a short. */
+
+extern void abort(void);
+
+short v, count;
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-3.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-3.c
new file mode 100644
index 000000000..dbbb32d86
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-3.c
@@ -0,0 +1,47 @@
+/* Test __atomic routines for existence and proper execution on 4 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+
+/* Test the execution of the __atomic_store_n builtin for an int. */
+
+extern void abort(void);
+
+int v, count;
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-4.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-4.c
new file mode 100644
index 000000000..a69b9d078
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-4.c
@@ -0,0 +1,48 @@
+/* Test __atomic routines for existence and proper execution on 8 byte
+ values with each valid memory model. */
+/* { dg-do run } */
+/* { dg-options "" } */
+
+/* Test the execution of the __atomic_store_n builtin for a long long. */
+
+extern void abort(void);
+
+long long v, count;
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-5.c b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-5.c
new file mode 100644
index 000000000..16440ce00
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/atomic-store-5.c
@@ -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 int128 } */
+
+/* Test the execution of the __atomic_store_n builtin for a 16 byte value. */
+
+extern void abort(void);
+
+__int128_t v, count;
+
+int
+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;
+}
+
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/c.exp b/gcc-4.9/libatomic/testsuite/libatomic.c/c.exp
new file mode 100644
index 000000000..1da3cb1e8
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/c.exp
@@ -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
diff --git a/gcc-4.9/libatomic/testsuite/libatomic.c/generic-2.c b/gcc-4.9/libatomic/testsuite/libatomic.c/generic-2.c
new file mode 100644
index 000000000..aa0014d2d
--- /dev/null
+++ b/gcc-4.9/libatomic/testsuite/libatomic.c/generic-2.c
@@ -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;
+}