first commit

This commit is contained in:
Jose Caban
2025-06-07 11:34:38 -04:00
commit 0eb2d7c07d
4708 changed files with 1500614 additions and 0 deletions

View File

@@ -0,0 +1,173 @@
# -*- Makefile -*-
#
# $Id: GNUmakefile.bin 580483 2007-09-28 20:55:52Z sebor $
#
# makefile to build the C++ Standard library utility programs
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
include ../makefile.in
SRCDIRS = $(TOPDIR)/util
# include common variables setting for all makefiles
ONE_REPOSITORY = 1
include ../makefile.common
TARGET = exec localedef locale gencat
# locale sources and related
NLSDIR = $(TOPDIR)/etc/nls
LOCDIR = $(BUILDDIR)/nls
# add nls directory to VPATH so that the database directories do not
# have to carry the path with them in the rule target.
VPATH += $(LOCDIR)
# list of locales to build
# first compose a full name from gen_list in the form
# <locale name>.<codeset>
# then move the known modifiers (@euro and @cyrillic) to the end
# of the name
LOCALES := \
$(shell sed -e s:"^ *\([^ ]*\) *\([^ ]*\) *":"\1\.\2":g \
-e s:"\([^.]*\)\(.euro\)\([^ ]*\)":"\1\3@euro":g \
-e s:"\([^.]*\)\(.cyrillic\)\([^ ]*\)":"\1\3@cyrillic":g \
$(NLSDIR)/gen_list)
## Filter from RUNTARGET only the scripts
RUNTARGET := $(filter %.sh,$(RUNTARGET))
# If empty populate it with the names of the locales databases test scripts
ifeq ($(RUNTARGET),)
RUNTARGET := sanity_test.sh $(patsubst %,%.sh,$(LOCALES))
endif
ifneq ($(CXX_REPOSITORY),)
LDFLAGS += $(CPPFLAGS)
endif # ($(CXX_REPOSITORY),)
# Don't want to link exec utility with stdlib, so create our own LDFLAGS var
LDFLAGS.exec = $(filter-out -l$(LIBBASE),$(LDFLAGS))
ifneq ($(RPATH),)
LDFLAGS += $(RPATH)$(LIBDIR)
endif
########################################################################
# TARGETS
########################################################################
all: $(LIBDIR)/$(LIBNAME) $(TARGET) $(RUNTARGET)
$(LIBDIR)/$(LIBNAME):
@$(MAKE) -C $(LIBDIR)
# link the run utility
exec: runall.o cmdopt.o output.o util.o exec.o display.o
@echo "$(LD) $^ -o $@ $(LDFLAGS.exec) $(LDLIBS)" $(call CXX.repo,$<) \
>> $(LOGFILE)
$(LD) $^ -o $@ $(LDFLAGS.exec) $(LDLIBS) $(call CXX.repo,$<) $(TEEOPTS)
# link the localedef utility
localedef: localedef.o locale.o aliases.o charmap.o codecvt.o collate.o \
ctype.o def.o diagnostic.o memchk.o messages.o monetary.o \
numeric.o path.o time.o scanner.o
@echo "$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS)" $(call CXX.repo,$<) \
>> $(LOGFILE)
$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(call CXX.repo,$<) $(TEEOPTS)
# link the locale utility
locale: locale_stub.o
@echo "$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS)" $(call CXX.repo,$<) \
>> $(LOGFILE)
$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(call CXX.repo,$<) $(TEEOPTS)
# link the gencat utility
gencat: gencat.o
@echo "$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS)" $(call CXX.repo,$<) \
>> $(LOGFILE)
$(LD) $^ -o $@ $(LDFLAGS) $(LDLIBS) $(call CXX.repo,$<) $(TEEOPTS)
# build all locales with the localedef utility
locales: localedef $(LOCALES)
# the rule builds the scripts that are run by the runall script
$(RUNTARGET): $(NLSDIR)/gen_list
@(echo "making $@..."; \
echo "#!/bin/sh" > $@; \
locname=`echo $@ | sed "s:^\./::g;s:\.sh$$::g"`; \
if [ "$@" = "sanity_test.sh" ]; then \
echo "./run_utils -s -b $(BUILDDIR)/bin $$""*" >>$@; \
else \
echo "./run_utils -f -i $(NLSDIR) -l $$locname $$""*" >> $@; \
fi; \
chmod ug+x $@;)
# the rule presents as dependencies the source files corresponding
# to that locale; it is run once for each entry in LOCALES
$(LOCALES): $(NLSDIR)/gen_list
@(lname=`echo $@ | sed "s:\([^.]*\)\.\([^@]*\)\(.*\):\1\3:;y:@:.:"`; \
cname=`echo $@ | sed "s:\([^.]*\)\.\([^@]*\)\(.*\):\2:"`; \
echo "./localedef -w -c -f $(NLSDIR)/charmaps/$$cname" \
"-i $(NLSDIR)/src/$$lname $(LOCDIR)/$@"; \
./localedef -w -c -f $(NLSDIR)/charmaps/$$cname \
-i $(NLSDIR)/src/$$lname $(LOCDIR)/$@)
$(DEPENDDIR)/localedb.d: $(DEPENDDIR) $(NLSDIR)/gen_list
@(echo "# generated locale dependencies" > $@; \
for f in ""$(LOCALES); do \
lname=`echo $$f | \
sed "s:\([^.]*\)\.\([^@]*\)\(.*\):\1\3:;y:@:.:"`; \
cname=`echo $$f | sed "s:\([^.]*\)\.\([^@]*\)\(.*\):\2:"`; \
f=$$f; \
echo "generating dependencies for $$f"; \
echo "$$f: $$""(NLSDIR)/src/$$lname" \
"$$""(NLSDIR)/charmaps/$$cname" >> $@; \
done;)
# tell makefile.rules to include the generated dependencies file
DEPS := $(DEPENDDIR)/localedb.d
# do any directory specific cleanup using the realclean target
realclean: clean dependclean
-rm -rf $(TARGET)
# compute the names of codesets (codecvt databases) and set
# the variable only for the install target for efficiency
install: codesets := \
$(sort $(shell echo $(LOCALES) \
| sed -e "s/[^ .@][^ .@]*\.\([^ ]*\)/\1/g" \
-e "s/@[^ ]*//g"))
# create the $(PREFIX)/bin $(PREFIX)/nls directories and install
# the utilities and locales
install: locale localedef $(LOCALES)
mkdir -p $(PREFIX)/bin
cp locale localedef $(PREFIX)/bin
mkdir -p $(PREFIX)/nls
if [ "$(LOCALES)" != "" ]; then \
cd ../nls && cp -R $(LOCALES) $(codesets) $(PREFIX)/nls; \
fi
include ../makefile.rules

View File

@@ -0,0 +1,411 @@
# -*- Makefile -*-
#
# $Id: GNUmakefile.cfg 629815 2008-02-21 14:54:57Z faridz $
#
# makefile to configure the C++ Standard library
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
#
# Creates a C++ header file, config.h, containing a list of (possibly
# commented out) preprocessor #defines in the form _RWSTD_NO_XXX,
# where the XXX is the file name part (w/o the extension) of XXX.cpp
# (some C or C++ program)
#
# Files named NO_XXX.cpp are assumed to be negative tests, which are
# considered successful unless they exit with zero status, in which
# case they are considered failed and the corresponding macro,
# _RWSTD_NO_XXX, is #defined.
#
# Each test named XXX.lib.cpp is translated into a static or dynamic
# library (depending on the presence of shared in BUILDMODE variable),
# and may be linked into other executables. To link a library into an
# executable the name of the library must be mentioned in LDOPTS
# somewhere in the executable's source.
#
# XXX.cpp can but doesn't need to contain main(). If it doesn't, the
# macro _RWSTD_NO_XXX will be commented out in config.h iff XXX.cpp
# successfully compiles.
#
# If XXX.cpp contains main(), _RWSTD_NO_XXX will be commented out iff
# XXX.cpp not only successfully compiles, but also links and runs.
#
# Any output produced by the executable XXX obtained by compiling and
# linking XXX.cpp is appended to the end of config.h.
#
########################################################################
include ../makefile.in
SRCDIR = $(TOPDIR)/etc/config/src
VPATH = $(SRCDIR)
CPPFLAGS += -I.
CPPFLAGS := $(filter-out -I$(TOPDIR)/include/ansi,$(CPPFLAGS))
CXXFLAGS += $(WARNFLAGS)
# get a sorted list of config tests, starting with any shell scripts
# with the .sh suffix, followed by C++ (.cpp) programs
SRCS := $(sort $(notdir $(wildcard $(SRCDIR)/*.sh)))
SRCS += $(sort $(notdir $(wildcard $(SRCDIR)/*.cpp)))
OBJS := $(SRCS:.cpp=.o)
TARGET := $(SRCS:.cpp=)
PWD := $(shell pwd)
DASH_H = -H
CCNAME = $(CXX)-$(CCVER)
LOGFILE = config.log
# can't use LDOPTS when working with HP aCC, it's used by the linker
ifneq ($(CXX),aCC)
LOPT = LDOPTS
LDFLAGS += $(LDOPTS)
else
LOPT = _LDOPTS
LDFLAGS += $(_LDOPTS)
endif
# append $(LDLIBS) last, after $(LDOPTS), since the latter may depend
# on the former being after it on the link line
LDFLAGS += -lm $(LDLIBS)
# CXXPRELINK - command for compilers that use template
# instantiation models that require a prelink stage
ifneq ($(PRELINKFLAGS),)
CXXPRELINK = $(CXX) $(CPPFLAGS) $(LDFLAGS) $(PRELINKFLAGS)
endif # ($(PRELINKFLAGS),)
# helper function to compile a file and log results
# arguments:
# $(1): source file name
# $(2): object file name
# $(3): additional compiler flags (optional)
define compile
command="$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(3) -c $(1) -o $(2)"; \
echo "$$command" >>$(LOGFILE); \
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(3) -c $(1) -o $(2) >>$(LOGFILE) 2>&1
endef
# helper function to link a file and log results
# arguments:
# $(1): object file name
# $(2): executable file name
# $(3): additional linker flags (optional)
define link
command="$(LD) $(1) $(LDFLAGS) $(3) -o $(2)"; \
echo "$$command" >>$(LOGFILE); \
$(LD) $(1) $(LDFLAGS) $(3) -o $(2) >>$(LOGFILE) 2>&1
endef
# helper function to compile and link a file and log results
# arguments:
# $(1): source file name
# $(2): object file name
# $(3): executable file name
# $(4): additional compiler flags (optional)
# $(5): additional linker flags (optional)
define compile_then_link
command="$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(4) -c $(1) -o $(2)" \
"&& $(LD) $(2) $(LDFLAGS) $(5) -o $(3)"; \
echo "$$command" >>$(LOGFILE); \
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(4) -c $(1) -o $(2) >>$(LOGFILE) 2>&1 \
&& $(LD) $(2) $(LDFLAGS) $(5) -o $(3) >>$(LOGFILE) 2>&1
endef
# helper function to prelink a file and log results
# arguments:
# $(1): source file name
# $(2): object file name
define prelink
command="$(CXXPRELINK) $(1) -o $(2)"; \
echo "$$command" >>$(LOGFILE); \
$(CXXPRELINK) $(1) -o $(2) >>$(LOGFILE)
endef
# helper function to create an archive out of an object file
define archive
command="$(AR) $(ARFLAGS) $(1) $(2)"; \
echo "$$command" >>$(LOGFILE); \
$(AR) $(ARFLAGS) $(1) $(2) >>$(LOGFILE)
endef
########################################################################
# TARGETS
########################################################################
all: config.h
# recreate config.h and update its timestamp
config.h: $(SRCS)
$(MAKE) config
touch config.h
# (re)create config.h; do not change timestamp if the new file is the same
# make .o first to make sure the %.o: %.cpp rule gets invoked (make bug?)
# run a configure script as the last step (e.g., to remove unwanted files)
# creates a file named vars.sh, containing shell assignments corresponding
# to makefile variables defined in $(BUILDDIR)/makefile.in (variables with
# invalid names (those containing periods) are commented out); vars.sh is
# used in libc_decl.sh to invoke the compiler and linker
config: clean sane
@([ -f config.h ] && mv config.h config.h.~ ; \
echo "// configured for $(CCNAME) on `uname -sr`" >config.h ; \
for file in $(TARGET) ; do \
src=$(SRCDIR)/$$file.cpp; \
desc=`head -n 1 2>/dev/null $$src | sed "s:// *::"`; \
[ "$$desc" != "" ] && printf "%-50.50s " "$$desc"; \
grep "[^a-zA-Z0-9_]*main *(" $$src >/dev/null 2>&1 ; \
if [ $$? -eq 0 ] ; then \
opts=`sed -n "s/^[^A-Z_a-z0-9]*LDOPTS *= *\(.*\)/\1/p" \
$$src`; \
targets="$$file.o $$file run RUN=$$file $(LOPT)=$$opts"; \
elif [ `echo $$file | grep "\.lib"` ] ; then \
targets="$$file$(LIBSUFFIX)" ; \
elif [ `echo $$file | grep "\.sh"` ] ; then \
if [ ! -f vars.sh ] ; then \
cat ../makefile.in \
| sed -e "s/= *\([^ ][^ ]* .*\)/=\"\1\"/" \
-e "s/^\( *[^=]*\.[^=]*=.*\)/# \1/" \
-e "s/^\([^ ]*\) *= *\(.*\)/\1=\2 ; export \1/" \
-e 's/$$(\([^)]*\))/${\1}/g' >vars.sh ; \
fi ; \
$(SRCDIR)/$$file config.h $(LOGFILE) ; \
echo ; \
continue ; \
else \
targets="$$file.o run RUN=$$file.o" ; \
fi; \
$(MAKE) $$targets OUTPUT=config.h -k >/dev/null 2>&1 ; \
if [ "$$desc" != "" ] ; then \
sym="_RWSTD_" ; \
echo $$file | grep "^NO_" >/dev/null ; \
[ $$? -ne 0 ] && sym="$${sym}NO_" ; \
str=`sed -n "s/\(.*\)\(#\)define $$sym$$file$$/\1\2/p" \
config.h`; \
if [ "$$str" = "// #" ] ; then \
echo "ok"; \
elif [ "$$str" = "#" ] ; then \
echo "no ($$sym$$file)"; \
else \
echo "--" ; \
fi; \
fi; \
done; \
diff config.h config.h.~ >/dev/null 2>&1 ; \
if [ $$? -eq 0 ] ; then \
mv config.h.~ config.h ; \
echo "config.h unchanged"; \
elif [ -f config.h~ ] ; then \
echo "previous config.h saved in config.h~"; \
fi; \
[ -x ./configure ] && ./configure -f ./config.h -d $(TOPDIR) ; \
exit 0)
# run one or more (perhaps all) executables in $(RUN) or $(TARGET) if
# the former is not defined; if an executable doesn't exist and the .o
# doesn't contain main it is still considered success (this is needed
# when the run target is invoked from within the %.o: %.cpp pattern rule
# .o's are not run (obviously) and are just assumed to be the result of
# a successful compilation
run:
@(output=$(OUTPUT) ; \
[ "$$output" = "" ] && output=/dev/tty ; \
target=$(RUN) ; \
[ "$$target" = "" ] && target=$(TARGET) ; \
for file in $$target ; do \
symbol="#define _RWSTD_" ; \
basename $$file | grep "^NO_" >/dev/null 2>&1 ; \
neg=$$? ; \
[ $$neg -ne 0 ] && symbol="$${symbol}NO_" ; \
symbol="$${symbol}`echo $$file \
| sed -e 's:.*/::' -e 's/\.o//'`"; \
if [ `echo $$file | grep "\.o"` ] ; then \
test -r $$file ; \
elif [ ! -x $$file ] ; then \
nm -gp $$file.o 2>&1 | grep "T *main *$$" >/dev/null ; \
test -f $$file.o -a ! $$? -eq 0 ; \
else \
echo "./$$file" >>$(LOGFILE) ; \
LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:. ; \
LIBPATH=$$LIBPATH:. ; \
export LIBPATH LD_LIBRARY_PATH ; \
text=`./$$file` ; \
fi; \
res=$$? ; \
[ $$res -eq 0 -a $$neg -ne 0 ] \
|| [ $$res -ne 0 -a $$neg -eq 0 ] && symbol="// $$symbol" ;\
grep "$$symbol$$" config.h ; \
if [ $$? -ne 0 ] ; then \
echo "$$symbol" >>$$output; \
if [ "$$text" != "" ]; then \
printf "%s\n" "$$text" >>$$output; \
fi; \
fi; \
done; \
exit 0)
# determine the type of architecture (LP32, ILP32, ILP64, LLP64, or LP64)
arch:
@(output=$(OUTPUT); \
[ "$$output" = "" ] && output=/dev/tty ; \
for type in int long "long long" "void*" ; do \
echo "int main () { return sizeof ($$type); }" \
| tee a.cpp >>$(LOGFILE) ; \
$(call compile_then_link,a.cpp,a.o,a.out); \
if [ $$? -eq 0 ] ; then \
size="$$size`./a.out ; echo $$?`" ; \
else \
size="$${size}-"; \
fi; \
done; \
case "$$size" in \
24?4 ) arch="LP32" ;; 44?4 ) arch="ILP32" ;; \
88?8 ) arch="ILP64" ;; 4488 ) arch="LLP64" ;; \
48?8 ) arch="LP64" ;; * ) arch="$$size" ;; \
esac ; \
echo "int main () { int i = 1; return *(char*)&i; }" \
| tee a.cpp >>$(LOGFILE) ; \
$(call compile_then_link,a.cpp,a.o,a.out); \
if [ $$? -eq 0 ] ; then \
endian=" little endian" ; \
./a.out ; \
[ $$? -eq 0 ] && endian=" big endian" ; \
else \
echo "error"; \
cat $(LOGFILE); \
exit 1; \
fi; \
echo "$$arch$$endian" >$$output ; \
)
# check compiler, linker, and run environment's sanity, determine
# system (or compiler) architecture (word size, address size, etc.)
sane:
@(echo; \
echo "configuring stdcxx $(LIBVER) for $(CCNAME) on $(PLATFORM)"; \
echo; \
rm -f a.out ; \
echo "int main () { return 0; }" | tee a.cpp >>$(LOGFILE) ; \
printf "%-50.50s " "checking if the compiler is sane"; \
$(call compile,a.cpp,a.o); \
if [ $$? -eq 0 ] ; then \
echo "ok (invoked with $(CXX))"; \
else \
echo "no"; echo; \
cat $(LOGFILE) ; \
exit 1; \
fi; \
printf "%-50.50s " "checking if the linker is sane"; \
$(call link,a.o,a.out); \
if [ $$? -eq 0 ] ; then \
echo "ok (invoked with $(LD))"; \
else \
echo "no"; echo; \
cat $(LOGFILE) ; \
exit 1; \
fi; \
printf "%-50.50s " "checking system architecture"; \
`$(MAKE) arch OUTPUT=a.cpp>/dev/null 2>&1` ; \
cat a.cpp ; \
rm a.cpp )
clean:
@rm -f a.out core *.o *.i *.ii *.ti vars.sh \
*$(LIBSUFFIX) $(TARGET)
realclean: clean
rm -f *.d *.o *.a *.so a.cpp
listtarget:
@echo $(TARGET)
.PHONY: all clean config configure c_headers listtarget realclean run
########################################################################
# COMMON RULES
########################################################################
#empty rule for .cc files so they won't be separately compiled
%: %.cc ;
# compile .cpp so that any macros used by the translation unit are configured
# checks config.h to make sure macro isn't yet defined before going recursive
# *.lib.cpp files a compiled (and linked) into libraries (shared or static)
# with LDOPTS reset to the empty string
%.o: %.cpp
@(dep=`egrep "^ *# *if[n]*def *_RWSTD_" $< \
| sed -e "s/.*# *if[n]*def *\([^ ]*\) */\1/g" \
-e "s/_RWSTD_NO_//g" -e "s/_RWSTD_//g"` ; \
for sym in $$dep ; do \
fname=$$sym ; \
src=$(SRCDIR)/$$fname.cpp; \
[ ! -r $$src ] && fname="NO_$$fname" ; \
grep "_RWSTD_NO_$$sym$$" config.h >/dev/null ; \
if [ $$? -ne 0 ] ; then \
grep "[^a-zA-Z0-9_]*main *(" $$src >/dev/null 2>&1 ; \
if [ $$? -eq 0 ] ; then \
opts=`sed -n \
"s/^[^A-Z_a-z0-9]*LDOPTS *= *\(.*\)/\1/p" \
$$src`; \
targets="$$fname.o $$fname run RUN=$$fname \
$(LOPT)=$$opts" ; \
elif [ `echo $$fname | grep "\.lib"` ] ; then \
targets="$$fname$(LIBSUFFIX) $(LOPT)=" ; \
else \
targets="$$fname.o run RUN=$$fname.o" ; \
fi; \
$(MAKE) $$targets OUTPUT=config.h -k ; \
fi; \
done; \
true)
$(call compile,$<,$@)
# remove .o to prevent the run target from getting confused
%: %.o
$(call link,$^,$@); rm $<
# build a library from any source file named *.lib.cpp
%.lib$(LIBSUFFIX): %.lib.cpp
ifeq ($(findstring shared,$(BUILDMODE)),shared)
$(call compile,$<,$@.o,$(PICFLAGS))
ifeq ($(findstring xlC,$(CXX)),xlC)
# IBM xlC first "preprocesses" .o's with -qmkshrobj
# and then uses `ar' to create a shared library...
$(call prelink,$@.o,@.lib.o)
$(call archive,$@,$@.lib.o)
else
$(call link,$@.o,$@,$(LDSOFLAGS))
endif
else
$(call compile,$<,$@.o)
$(call archive,$@,$@.o)
endif
# parallelization of the configuration infrastructure not supported
.NOTPARALLEL:

View File

@@ -0,0 +1,76 @@
# -*- Makefile -*-
#
# $Id: GNUmakefile.exm 636366 2008-03-12 15:27:36Z faridz $
#
# makefile to build the C++ Standard library examples
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
include ../makefile.in
EXMDIR = $(TOPDIR)/examples
SRCDIRS = $(EXMDIR)/manual $(EXMDIR)/tutorial
# do not compile these sources...
OMIT_SRCS += rwstdmessages.cpp
# override setting from makefile.in (examples only)
CATFILE = rwstdmessages.cat
include ../makefile.common
INCLUDES += -I$(EXMDIR)/include
# No example should use more than 512MB of memory. On most platforms
# except HP-UX/IPF, 256MB is enough. (Related to STDCXX-440).
RUNFLAGS += -d $(EXMDIR) --ulimit=as:536870912
ifneq ($(RPATH),)
LDFLAGS += $(RPATH)$(LIBDIR)
endif
########################################################################
# TARGETS
########################################################################
.SUFFIXES:
all: $(TARGET) $(CATFILE)
# dependency on main library
$(TARGET): $(LIBDIR)/$(LIBNAME)
$(LIBDIR)/$(LIBNAME):
@$(MAKE) -C $(LIBDIR)
$(BINDIR)/runutil:
@$(MAKE) -C $(BINDIR) runutil
# do any directory specific cleanup using the realclean target
realclean: dependclean clean
rm -f *.out
#set TZ environment variable for examples
run runall run_all: TZ = MST+7
include ../makefile.rules

View File

@@ -0,0 +1,143 @@
# -*- Makefile -*-
#
# $Id: GNUmakefile.lib 580483 2007-09-28 20:55:52Z sebor $
#
# makefile to build the C++ Standard library
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
include ../makefile.in
# catalog to build and source files to build it from
CATFILE := rwstderr.cat
MSGFILES := rwstderr.msg
# the name of the library to build (and in shared builds,
# the name of the symbolic link pointing to it, for library
# versioning)
LIBLINK := $(LIBNAME)
ifeq ($(findstring shared,$(BUILDMODE)),shared)
ifneq ($(LIBSUFFIX),.dll)
LIB := $(LIBLINK).$(LIBVER)
else
# on Cygwin use name libstd${BUILDTYPE}-X.Y.Z.dll
LIB := $(basename $(LIBLINK))-$(LIBVER)$(LIBSUFFIX)
endif
TARGET := $(LIB) $(LIBLINK)
else
LIB := $(LIBLINK)
TARGET := $(LIB)
endif
TARGET += $(CATFILE)
SRCDIRS = $(TOPDIR)/src
# do not compile these sources...
OMIT_SRCS += rwstderr.cpp
# include common variables setting for all makefiles
ONE_REPOSITORY = 1
include ../makefile.common
CXXFLAGS += $(PICFLAGS)
LDFLAGS += $(LDSOFLAGS) $(MAPFLAGS) $(MAPFILE)
# For AIX 5.1 xlC 5.0.2.0
ifneq ($(DEFAULT_SHROBJ),)
SOBJS=$(DEFAULT_SHROBJ)
else
SOBJS=$(OBJS)
endif
# CXXPRELINK - command for compilers that use template
# instantiation models that require a prelink stage
ifneq ($(PRELINKFLAGS),)
CXXPRELINK = $(CXX) $(CPPFLAGS) $(LDFLAGS) $(PRELINKFLAGS) $(OBJS)
endif # ($(PRELINKFLAGS),)
########################################################################
# TARGETS
########################################################################
# Cancel implicit rules
.SUFFIXES:
all: $(TARGET)
# do any directory specific cleanup using the realclean target
realclean: dependclean clean
# build an archive or shared library (repository included for DEC cxx 6.2)
ifeq ($(findstring shared,$(BUILDMODE)),shared)
ifeq ($(findstring archive,$(BUILDMODE)),archive)
# shared archives are unique to IBM AIX
# IBM VisualAge/XLC++ on AIX first "preprocesses" object files
# with -qmkshrobj and then uses `ar' to create a shared archive
$(LIB): $(OBJS)
@echo "$(CXXPRELINK) -o $(LIBBASE).o" >> $(LOGFILE)
$(CXXPRELINK) -o $(LIBBASE).o $(TEEOPTS)
@echo "$(AR) $(ARFLAGS) $@ $(LIBBASE).o" >> $(LOGFILE)
$(AR) $(ARFLAGS) $@ $(LIBBASE).o $(TEEOPTS)
else
$(LIB): $(OBJS) $(MAPFILE)
@echo "$(LD) $(LDFLAGS) $< $(LDLIBS) -o $@" >> $(LOGFILE)
$(LD) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@ $(TEEOPTS)
endif # shared archive
$(LIBLINK): $(LIB)
@echo "ln -sf $< $@" >> $(LOGFILE)
ln -sf $< $@
else
# Compaq C++ needs all files from the repository
SOBJS += $(shell [ -d repository.ti ] && echo repository.ti/*.o)
$(LIB): $(OBJS)
@echo "$(CXXPRELINK)" >> $(LOGFILE)
$(CXXPRELINK) $(TEEOPTS)
@echo "$(AR) $(ARFLAGS) $(LIBNAME) $(SOBJS)" >> $(LOGFILE)
$(AR) $(ARFLAGS) $(LIBNAME) $(SOBJS) $(TEEOPTS)
endif # ($(findstring shared,$(BUILDMODE)),shared)
# Common rules used by all Makefiles
include ../makefile.rules
# create the $(PREFIX)/etc/ and $(PREFIX)/lib/ directories
# and install the library binary and the message catalog(s)
install: $(TARGET)
mkdir -p $(PREFIX)/lib
cp $(LIB) $(PREFIX)/lib
if [ $(LIBLINK) != $(LIB) ]; then \
rm $(PREFIX)/lib/$(LIBLINK); \
ln -s $(LIB) $(PREFIX)/lib/$(LIBLINK); \
fi
mkdir -p $(PREFIX)/etc
cp $(CATFILE) $(PREFIX)/etc

View File

@@ -0,0 +1,113 @@
# -*- Makefile -*-
#
# $Id: GNUmakefile.ph 580483 2007-09-28 20:55:52Z sebor $
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
include ../makefile.in
########################################################################
# if PHDIR isn't set, don't try to build anything
########################################################################
ifeq ($(PHDIR),)
all: .DEFAULT
listtarget:
@echo
.DEFAULT:
@echo "PHDIR not set; skipping Plum Hall tests"
########################################################################
# end of makefile if PHDIR isn't set
########################################################################
else # ifneq ($(PHDIR),)
SRCDIRS = $(PHDIR)/conform
# do not compile these sources...
# exclude files beginning with '_' or 0-9
OMIT_SRCS += $(notdir $(shell $(FIND) $(SRCDIRS) \
-name "[_0-9]*.cpp" -print)) linkwith.cpp
include ../makefile.common
INCLUDES += -I$(TOPDIR)/include/ansi -I$(PHDIR)/conform -I$(PHDIR)/dst.3
WARNFLAGS += $(PHWARNFLAGS)
# add --ph to RUNFLAGS to indicate that these are plumhall tests
RUNFLAGS += --ph -X "-C $(CXX)-$(CCVER)"
# override the runtarget set in makefile.common
RUNTARGET = $(shell $(MAKE) -s listtarget listsubtests | sed "s/ / .\//g")
ifneq ($(RPATH),)
LDFLAGS += $(RPATH)$(LIBDIR)
endif
########################################################################
# TARGETS
########################################################################
# first try to build all tests, then build subtests for
# those tests that didn't compile
all: $(LIBDIR)/$(LIBNAME) maintests subtests
$(LIBDIR)/$(LIBNAME):
@$(MAKE) -C $(LIBDIR)
# TARGET variable contains the names of all the main tests
# (does not contain subtests)
maintests: $(TARGET)
# call make recursively to get a list of all subtests that should be deleted
realclean: clean dependclean
rm -f `$(MAKE) -s listsubtests`
# call make recursively to get a list of all subtests that need to be
# built because the main test didn't compile
subtests:
@$(MAKE) -r -s `$(MAKE) -s listsubtests`
# print out the names of all subtests that need to be compiled
# because the corresponding main test didn't compile
listsubtests:
@(for test in $(TARGET); do \
if [ ! -x ./$$test ]; then \
$(FIND) $(PHDIR)/conform/$${test}.dir \
-name "[_0-9]*.cpp" -print \
| sed "s:.*/\(.*\)\.cpp:\1:" ; \
fi; \
done)
include ../makefile.rules
endif # ifeq ($(PHDIR),)

View File

@@ -0,0 +1,110 @@
# -*- Makefile -*-
#
# $Id: GNUmakefile.rwt 580483 2007-09-28 20:55:52Z sebor $
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
#
# Usage:
#
# $ make
#
# To make all tests uder $(TOPDIR)/tests. Will generate a .d file
# an place in the directory $(DEPENDDIR) for every source file.
#
########################################################################
# Generated when make is run in TOPDIR
include ../makefile.in
# The place where the sources are looked for;
# used in the variables setup in makefile.common
TESTDIR = $(TOPDIR)/tests
SRCDIRS = $(TESTDIR)/src
# include common variables setting for all makefiles
ONE_REPOSITORY = 1
include ../makefile.common
# Reset LIBSUFFIX to .a until we decide to build a dynamic library
LIBSUFFIX = .a
# Target library to be built
RWTESTLIB = librwtest$(BUILDTYPE)$(LIBSUFFIX)
# Additional include directories:
INCLUDES += -I$(TESTDIR)/include
# VPATH to look for sources in (appended dir for test.cpp)
VPATH += $(TESTDIR)/src
# For xlC 5.0.2.0
ifneq ($(DEFAULT_SHROBJ),)
SOBJS = $(DEFAULT_SHROBJ)
else
SOBJS = $(OBJS)
endif
# CXXPRELINK - command for compilers that use template
# instantiation models that require a prelink stage
ifneq ($(PRELINKFLAGS),)
CXXPRELINK = $(CXX) $(CPPFLAGS) $(PRELINKFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS)
endif # ($(PRELINKFLAGS),)
ifneq ($(RPATH),)
LDFLAGS += $(RPATH)$(LIBDIR)
endif
########################################################################
# TARGETS
########################################################################
all: $(RWTESTLIB)
# do any directory specific cleanup using the realclean target
realclean: clean dependclean
rm -f $(RWTESTLIB)
# For the time being the rules are identical until we
# decide to build a shared library for rw test lib.
ifeq ($(findstring shared,$(BUILDMODE)),shared)
$(RWTESTLIB): $(OBJS)
@echo "$(CXXPRELINK)" >> $(LOGFILE)
$(CXXPRELINK) $(TEEOPTS)
@echo "$(AR) $(ARFLAGS) $(RWTESTLIB) $(SOBJS)" >> $(LOGFILE)
$(AR) $(ARFLAGS) $(RWTESTLIB) $(SOBJS)
else
$(RWTESTLIB): $(OBJS)
@echo "$(CXXPRELINK)" >> $(LOGFILE)
$(CXXPRELINK) $(TEEOPTS)
@echo "$(AR) $(ARFLAGS) $(RWTESTLIB) $(SOBJS)" >> $(LOGFILE)
$(AR) $(ARFLAGS) $(RWTESTLIB) $(SOBJS)
endif # ($(findstring shared,$(BUILDMODE)),shared)
# Common rules for all Makefile_s
include ../makefile.rules

View File

@@ -0,0 +1,141 @@
# -*- Makefile -*-
#
# $Id: GNUmakefile.tst 580483 2007-09-28 20:55:52Z sebor $
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
#
# Usage:
#
# $ make
#
# To make all tests uder $(TOPDIR)/tests. Will generate a .d file
# an place in the directory $(DEPENDDIR) for every source file.
#
# $ make [ tagets ] run | runall | run_all
#
# To make targets and run them one at a time, displaying progress
# and test results on stdout. When no targets are specified, will
# make and run all and create a report file in the parent directory.
#
# $ make run | runall | run_all [ RUN=<executables> | ALL ]
#
# Same as above.
#
# $ make SRCS="...sources..." [ run | runall | run_all ]
#
# Same as above, but considerably faster since SRCS doesn't have to be
# found in $(TOPDIR)/tests, and only the necessary .d files are included.
#
########################################################################
include ../makefile.in
# tests & rwtest library directories
TESTDIR = $(TOPDIR)/tests
# get the test suite subdirectories minus those known
# not to contain any source (i.e., .cpp) files
SRCDIRS := $(filter-out $(TESTDIR)/docs \
$(TESTDIR)/etc \
$(TESTDIR)/include \
$(TESTDIR)/src \
%.C %.c %.cc %.cpp \
%.h %.hpp, \
$(wildcard $(TESTDIR)/*))
SRCDIRNAMES := $(notdir $(SRCDIRS))
# do not compile these sources
OMIT_SRCS += $(notdir $(wildcard $(TESTDIR)/src/*.cpp)) 22_locale.cpp
# override setting from makefile.in (tests only)
CATFILE = rwstdmessages.cat
include ../makefile.common
# RW test library
RWTLIBBASE = rwtest$(BUILDTYPE)
RWTLIBNAME = lib$(RWTLIBBASE).a
# Add to include dirs and link flags:
INCLUDES += -I$(TESTDIR)/include
LDFLAGS := -L$(BUILDDIR)/rwtest -l$(RWTLIBBASE) $(LDFLAGS)
# targets to be built: object files for sources in the source directories
TARGET := $(patsubst %.cpp,%,$(SRCS))
# add to targets objects for any sources in the current working directory
TARGET += $(patsubst %.cpp,%.o,$(wildcard *.cpp))
ifneq ($(RPATH),)
LDFLAGS += $(RPATH)$(LIBDIR):$(BUILDDIR)/rwtest
endif
RUNFLAGS += --compat -x "--compat -O -" --ulimit=as:1073741824
# No test should use more than 1 GB of memory (See STDCXX-440).
# The magic number 1073741824 is 1 GB in bytes.
########################################################################
# TARGETS
########################################################################
all: $(TARGET)
$(TARGET): $(LIBDIR)/$(LIBNAME) $(BUILDDIR)/rwtest/$(RWTLIBNAME)
$(LIBDIR)/$(LIBNAME):
@$(MAKE) -C $(LIBDIR) MAKEOVERRIDES=
$(BUILDDIR)/rwtest/$(RWTLIBNAME):
@$(MAKE) -C $(BUILDDIR)/rwtest MAKEOVERRIDES=
$(BINDIR)/runutil:
@$(MAKE) -C $(BINDIR) runutil
# do any directory specific cleanup using the realclean target
realclean: clean dependclean
rm -f _*.cpp
# build all tests in the given subdirectory (subsection of the standard)
$(notdir $(SRCDIRNAMES)):
$(MAKE) SRCS="`cd $(TESTDIR)/$@/ && echo *.cpp`"
# generate compile-only tests (.cpp's) from lib headers; every header must
# compile on its own (without prior inclusion of any other header)
gentest:
@(echo "generating compile-only tests..." ; \
HEADERS=`$(FIND) $(TOPDIR)/include -type f \
! -name "*.cc" ! -name "*.c" \
! -name "*.~*" ! -name "#*#" ! -name "*_spec.h" \
| sed "s:$(TOPDIR)/include/::g"`; \
for f in $$HEADERS ; do \
cppfile="_`basename $${f}`.cpp" ; \
printf "%s " $$cppfile ; \
echo "#include <$$f>" > $$cppfile ; \
done ; \
echo ; )
.PHONY: $(SRCDIRNAMES) rwtest
# Common rules for all Makefile_s
include ../makefile.rules

View File

@@ -0,0 +1,178 @@
# -*- Makefile -*-
#
# $Id: acc.config 642302 2008-03-28 17:22:02Z sebor $
#
# configuration file for HP aCC on HP-UX
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2008 Rogue Wave Software, Inc.
#
########################################################################
CXX = aCC
CCVER := $(shell $(CXX) -V 2>&1 \
| sed "s/.* \(A\.[0-9][0-9]*\.[0-9][0-9]\)[^0-9]*.*/\1/")
aCC_MAJOR := $(shell echo $(CCVER) | sed "s/[^.]*\.\([0-9]*\)\..*/\1/")
aCC_MINOR := $(shell echo $(CCVER) | sed "s/[^.]*\.[^.]*\.\([0-9]*\)/\1/")
WARNFLAGS = +w +W392,655,684,818,819,849
ifeq ($(shell [ $(aCC_MAJOR) -eq 3 -a $(aCC_MINOR) -lt 33 ] && echo 1),1)
# disable bogus aCC warnings (aCC prior to 3.32):
# 229 Ambiguous overloaded function call
# 361 Value-returning function might end without executing a return statement
WARNFLAGS += +W229,361
endif
ifeq ($(aCC_MAJOR),06)
# disabled warnings:
# 2193 zero used for undefined preprocessing identifier
# 2236 controlling expression is constant
# 2261 access control not specified (%sq by default)
# 2340 value copied to temporary, reference to temporary used
# 2401 destructor for base class %t is not virtual
# 2487 inline %n cannot be explicitly instantiated
# disable aCC 6.x (EDG front end) warnings emitted with +w:
WARNFLAGS += +W2193,2236,2261,2340,2401,2487
ifeq ($(shell [ $(aCC_MINOR) -gt 10 ] && echo 1),1)
# disabled remarks:
# 4227 padding struct with N bytes to align member
# 4229 64 bit migration: conversion from "long" to "int" may truncate value
# 4231 64 bit migration: conversion between types of different sizes
# 4235 conversion from "T" to "U" may lose significant bits
# 4237 type cast from "T" to "U" may cause sign extension
# 4249 64 bit migration: value could be truncated before cast
# 4255 padding size of struct with N bytes to alignment boundary
# 4272 conversion from "T" to "unsigned T" may lose sign
# 4284 operator= does not return reference to *this
# 4285 operator= does not have a check for the source and destination
# 4286 return non-const handle to non-public data member
# remarks disabled as useless (even according to HP):
# 4296 arithmetic operation on boolean type
# 4297 boolean value is used as array index
WARNFLAGS += +W4227,4229,4231,4235,4237,4249 \
+W4255,4272,4284,4285,4286,4296,4297
ifeq ($(shell [ $(aCC_MINOR) -lt 20 ] && echo 1),1)
# disabled due to STDCXX-694 (hopefully fixed by the time 6.20 comes out)
# 3348 declaration hides constant or variable
WARNFLAGS += +W3348
endif # aCC < 6.20
endif # aCC > 6.10
endif # aCC 6.x
ifeq ($(shell [ $(aCC_MAJOR) -ge 6 -o $(aCC_MINOR) -ge 38 ] && echo 1),1)
# starting with aCC x.38, the +Md option is deprecated in favor of +Maked
DEPENDFLAGS = +Maked -E
else
DEPENDFLAGS = +Md -E
endif
PICFLAGS = +Z
LDSOFLAGS = +Z -b
# the extension of assembly files is .s
AS_EXT = .s
# $(_CPPOPTS), $(_CXXOPTS), and $(_LDOPTS) provided to allow for modification
# of the respective variables w/o underscores on HP-UX where the latter are
# used directly by the compiler and linker, respectively
# use -AA by default, allow -Aa as an option
use_Aa := $(filter -Aa,$(_CXXOPTS))
ifneq ($(use_Aa),-Aa)
CXXFLAGS = -AA "$$"(_CXXOPTS)
CXXPRELINK =
CPPFLAGS = "$$"(_CPPOPTS)
LDFLAGS = -AA +nostl -Wl,+s "$$"(_LDOPTS)
else
# -Aa was specified in _CXXOPTS
CXXFLAGS = -Aa +nostl "$$"(_CXXOPTS)
CXXPRELINK =
CPPFLAGS = -I$(TOPDIR)/include/ansi -I/usr/include "$$"(_CPPOPTS)
# -Wl,+s allows the dynamic loader to consider LD_LIBRARY_PATH (LP64)
# and SHLIB_PATH when loading an executable into memory
LDFLAGS = -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings "$$"(_LDOPTS)
endif
# The flag(s) to use to embed a library search path into generated executables.
RPATH = -Wl,+b
# debug/optimization options
DEBUG_CXXFLAGS = -g +d
DEBUG_CPPFLAGS =
OPTMZ_CXXFLAGS = +O2
OPTMZ_CPPFLAGS =
# shared/static library options
SHARED_CXXFLAGS =
SHARED_CPPFLAGS =
SHARED_LDFLAGS =
SHARED_SUFFIX = .sl
STATIC_CXXFLAGS =
STATIC_CPPFLAGS =
STATIC_LDFLAGS =
# multi/single thread options;
# we use the macros defined by the compiler when the -mt option is used
# DCE threads not added since HP-UX versions after 10.20 use POSIX
MULTI_CPPFLAGS_POSIX = -mt
MULTI_CPPFLAGS_SOLARIS =
MULTI_CPPFLAGS_DCE =
MULTI_LDFLAGS_POSIX = -mt
MULTI_LDFLAGS_SOLARIS =
MULTI_LDFLAGS_DCE =
# POSIX
MULTI_CPPFLAGS = $(MULTI_CPPFLAGS_POSIX)
MULTI_LDFLAGS = $(MULTI_LDFLAGS_POSIX)
SINGL_CPPFLAGS =
SINGL_LDFLAGS =
# wide (64-bit, LP64) flags -- must be set explicitly
CXXFLAGS.wide = +DD64
LDFLAGS.wide = +DD64
LDSOFLAGS.wide = +DD64
ARFLAGS.wide =
# narrow (32-bit, ILP32) flags -- implicit in the default invocation
# CXXFLAGS.narrow = +DD32
# LDFLAGS.narrow = +DD32
# LDSOFLAGS.narrow = +DD32
# ARFLAGS.narrow =

View File

@@ -0,0 +1,86 @@
#
# $Id: como.config 580483 2007-09-28 20:55:52Z sebor $
#
# configuration file for the Comeau compiler
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
CXX = como
CCVER := $(shell $(CXX) -v foo.c 2>&1 | head -1 | awk '{ print $$3'})
CC_MAJOR := $(shell echo "$(CCVER)" | sed -n "s/^\([^\.]*\).*/\1/p")
CC_MINOR := $(shell echo "$(CCVER)" | sed -n "s/^.*\.\([0-9]*\).*/\1/p")
ifeq ($(CC_MINOR),2)
CPPFLAGS = -I$(TOPDIR)/include/ansi --incl_suffixes ::
CXXFLAGS = -A -B -x
LDFLAGS =
else
CPPFLAGS = -I$(TOPDIR)/include/ansi
CXXFLAGS = -A -x --no_stdarg_builtin --template_directory=$(BUILDDIR)/lib
LDFLAGS = --template_directory=$(BUILDDIR)/lib
endif # CC_MAJOR == 2
WARNFLAGS = --display_error_number --diag_suppress 11,450,518
DEPENDFLAGS = -M
PICFLAGS =
PRELINKFLAGS = --prelink_objects
# The flag(s) to use to embed a library search path into generated executables.
# Appropriate flag(s) (if available) not determined at this time.
RPATH =
# debug/optimization options
DEBUG_CXXFLAGS = -g
DEBUG_CPPFLAGS =
OPTMZ_CXXFLAGS = -O
OPTMZ_CPPFLAGS =
# shared/static library options
SHARED_CXXFLAGS =
SHARED_CPPFLAGS = -D_RWSTD_SHARED_LIB
SHARED_LDFLAGS = -shared
STATIC_CXXFLAGS =
STATIC_CPPFLAGS =
STATIC_LDFLAGS =
# Compiler and linker flags for multi-threading
MULTI_CPPFLAGS_POSIX = -D_REENTRANT
MULTI_CPPFLAGS_SOLARIS =
MULTI_CPPFLAGS_DCE =
ifeq ($(OSNAME),SunOS)
MULTI_LDFLAGS_POSIX = /usr/lib/libpthread.so
else
MULTI_LDFLAGS_POSIX = -lpthread
endif
MULTI_LDFLAGS_SOLARIS =
MULTI_LDFLAGS_DCE =
# Posix
MULTI_CPPFLAGS = $(MULTI_CPPFLAGS_POSIX)
MULTI_LDFLAGS = $(MULTI_LDFLAGS_POSIX)
SINGL_CPPFLAGS =
SINGL_LDFLAGS =

View File

@@ -0,0 +1,52 @@
#!/bin/sh
#
# $Id: configure.sh 580483 2007-09-28 20:55:52Z sebor $
#
# script to configure the C++ Standard library
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
CONFIG_FILE="config.h"
TOPDIR=":"
# process command line arguments
for f in $* ; do
if [ "$CONFIG_FILE" = "" ] ; then
CONFIG_FILE="$f"
continue
elif [ "$TOPDIR" = "" ] ; then
TOPDIR="$f"
continue
elif [ "$f" = "-f" ] ; then
unset CONFIG_FILE
continue
elif [ "$f" = "-d" ] ; then
unset TOPDIR
continue
fi
done
if [ ! -d "$TOPDIR" ] ; then
echo "TOPDIR ('$TOPDIR') not found."
exit 1
fi

View File

@@ -0,0 +1,109 @@
#
# $Id: eccp.config 580483 2007-09-28 20:55:52Z sebor $
#
# configuration file for EDG eccp
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
CXX = eccp
CCVER := $(shell eccp -v foo.c 2>&1 | head -1 | awk '{ print $$8'})
ECCP_MAJOR := $(shell echo "$(CCVER)" | sed -n "s/^\([^\.]*\).*/\1/p")
ECCP_MINOR := $(shell echo "$(CCVER)" | sed -n "s/^.*\.\([0-9]*\).*/\1/p")
ifeq ($(BUILDDIR),)
# set to the CWD when not defined
BUILDDIR=$(shell pwd)/build
endif
ifeq ($(ECCP_MAJOR),2)
CPPFLAGS = -I$(TOPDIR)/include/ansi --incl_suffixes ::
CXXFLAGS = -A -B -x
LDFLAGS =
else
CPPFLAGS = -I$(TOPDIR)/include/ansi
CXXFLAGS = -A -x --template_directory=$(BUILDDIR)/lib
LDFLAGS = --template_directory=$(BUILDDIR)/lib
endif # ECCP_MAJOR == 2
# disabled remarks (othewise issued with --remarks)
# 193: zero used for undefined preprocessing identifier
# 236: controlling expression is constant
# 261: access control not specified ("public" by default)
# 340: value copied to temporary, reference to temporary used
# 401: destructor for base class is not virtual
# 479: function redeclared "inline" after being called
# 487: inline function cannot be explicitly instantiated
# 678: call of function cannot be inlined
# 679: function cannot be inlined
# 815: type qualifier on return type is meaningless
# other diagnostics (not disabled):
# 450: the type "long long" is nonstandard
WARNFLAGS = --display_error_number --remarks \
--diag_suppress 193,236,340,401,261,479,487,678,679,815
PHWARNFLAGS = --diag_suppress 177,381,191,68,550,611,997,549
DEPENDFLAGS = -M
PICFLAGS =
PRELINKFLAGS = --prelink_objects
# disable assembly files for now, eccp doesn't understand them
# (until the makefiles are changed to use the system assembler
# to assemble such files)
AS_EXT = .
# The flag(s) to use to embed a library search path into generated executables.
# Appropriate flag(s) (if available) not determined at this time.
RPATH =
# debug/optimization options
DEBUG_CXXFLAGS = -g
DEBUG_CPPFLAGS =
OPTMZ_CXXFLAGS = -O
OPTMZ_CPPFLAGS =
# shared/static library options
SHARED_CXXFLAGS =
SHARED_CPPFLAGS = -D_RWSTD_SHARED_LIB
SHARED_LDFLAGS = -shared
STATIC_CXXFLAGS =
STATIC_CPPFLAGS =
STATIC_LDFLAGS =
# Compiler and linker flags for multi-threading
MULTI_CPPFLAGS_POSIX = -D_REENTRANT
MULTI_CPPFLAGS_SOLARIS =
MULTI_CPPFLAGS_DCE =
MULTI_LDFLAGS_POSIX = /usr/lib/libpthread.so
MULTI_LDFLAGS_SOLARIS =
MULTI_LDFLAGS_DCE =
# POSIX
MULTI_CPPFLAGS = $(MULTI_CPPFLAGS_POSIX)
MULTI_LDFLAGS = $(MULTI_LDFLAGS_POSIX)
SINGL_CPPFLAGS =
SINGL_LDFLAGS =

View File

@@ -0,0 +1,87 @@
#!/bin/sh
#
# $Id: fixtree.sh 580483 2007-09-28 20:55:52Z sebor $
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
#
# fixtree.sh - creates a source directory tree (using symlinks) suitable for
# the GNUmakefile infrastructure from a directory tree required by HAL/RCB
#
##############################################################################
if [ $# -ne 1 ] ; then
echo "usage: $0 [<directory>]"
exit
fi
ROOTDIR=$1
if [ ! -d $ROOTDIR ] ; then
echo "$0: $ROOTDIR not found"
exit 1
fi
mkdir stdlib
if [ $? -ne 0 ] ; then
exit 2
fi
if [ -d $ROOTDIR/include ] ; then
ln -s $ROOTDIR/include stdlib/include
else
echo "$0: $ROOTDIR/include: directory doesn't exist" >&2
exit 3
fi
for d in etc examples source tests ; do
if [ -d $ROOTDIR/$d ] ; then
ln -s $ROOTDIR/$d/stdlib stdlib/$d
else
echo "$0: $ROOTDIR/$d: directory doesn't exist" >&2
exit 3
fi
done
if [ -r $ROOTDIR/etc/stdlib/config/GNUmakefile ] ; then
ln -s $ROOTDIR/etc/stdlib/config/GNUmakefile stdlib/GNUmakefile
else
echo "$0: $ROOTDIR/etc/stdlib/config/GNUmakefile file doesn't exist" >&2
exit 3
fi
mkdir rwtest
if [ $? -ne 0 ] ; then
exit 2
fi
if [ -d $ROOTDIR/source/rwtest ] ; then
ln -s $ROOTDIR/source/rwtest rwtest/source
else
echo "$0: $ROOTDIR/source/rwtest: directory doesn't exist (continuing)" >&2
fi
if [ -d $ROOTDIR/rw ] ; then
ln -s $ROOTDIR/rw rwtest/rw
else
echo "$0: $ROOTDIR/rw: directory doesn't exist (continuing)" >&2
fi

View File

@@ -0,0 +1,321 @@
# -*- Makefile -*-
#
# $Id: gcc.config 638562 2008-03-18 20:52:07Z elemings $
#
# configuration file for gcc
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
CXX = gcc
CCVER := $(shell $(CXX) -dumpversion | sed "s/[^0-9]*\([0-9.]*\).*/\1/g")
# determine the major version of gcc
CXX_MAJOR := $(shell echo "$(CCVER)" | sed "s/^\([1-9][0-9]*\).*/\1/")
CXX_MINOR := $(shell echo "$(CCVER)" | sed "s/[1-9]*\.\([0-9]*\).*/\1/")
# determine the major and minor version of the OS on AIX
ifeq ($(OSNAME),AIX)
OS_MAJOR := $(shell uname -v)
OS_MINOR := $(shell uname -r)
endif
# -W and -Wextra are the same
WARNFLAGS = -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings
# -Wno-long-long not available prior to 2.90
ifeq ($(shell [ $(CXX_MAJOR) -gt 2 -o $(CXX_MAJOR) -eq 2 \
-a $(CXX_MINOR) -ge 90 ] && echo 1), 1)
WARNFLAGS += -Wno-long-long
endif # gcc >= 2.90
# prevent (bogus?) warnings on SunOS
ifneq ($(OSNAME),SunOS)
WARNFLAGS += -Wcast-align
else
# prevent gcc 3.x warnings about #pragma ident on SunOS
ifeq ($(CXX_MAJOR),3)
ifeq ($(shell expr $(CXX_MINOR) \< 4),1)
WARNFLAGS += -Wno-unknown-pragmas
endif # gcc < 3.4
endif # gcc == 3.x
endif # !SunOS
# do not enable -Wunreachable-code: it's useless the way implemented
# ifeq ($(shell expr $(CXX_MAJOR) \> 3 \& $(CXX_MINOR) \> 3),1)
# WARNFLAGS += -Wunreachable-code
# endif # gcc > 3.3
DEPENDFLAGS = -M
# avoid adding -FPIC on IBM AIX and Cygwin where
# gcc generated code is always position independent
ifeq (,$(findstring AIX,$(OSNAME)))
ifeq (,$(findstring CYGWIN,$(OSNAME)))
PICFLAGS = -fPIC
endif
endif
ifeq ($(OSNAME),SunOS)
# linker flags for symbol versioning
# temporarily disabled (not fully implemented)
# MAPFLAGS = -Wl,-M
endif
ifneq ($(MAPFLAGS),)
# path to mapfile (relative to $(TOPDIR)) for symbol versioning
ifneq ($(CXX_MAJOR),2)
MAPFILE = src/mapfile.$(CXX)
else
# gcc 2.x implements a different ABI than gcc 3
MAPFILE = src/mapfile.$(CXX)-$(CXX_MAJOR)
endif
endif
ifneq ($(OSNAME),Darwin)
# no -shared option for GCC on Mac OS X (Darwin)
LDSOFLAGS = -shared
else
# Flags needed when linking the library
LDSOFLAGS = \
-dynamiclib \
-install_name $(BUILDDIR)/lib/$(LIBNAME) \
-compatibility_version 4 \
-current_version $(LIBVER)
endif
# -fPIC needed both to compile and link shared libs on HP-UX 11
ifeq ($(OSNAME),HP-UX)
LDSOFLAGS += -fPIC
endif
ifeq ($(CXX_MAJOR),3)
ifeq ($(shell [ $(CXX_MINOR) -lt 4 ] && echo 1),1)
# for gcc 3 prior to gcc 3.4 force linking with libgcc_s.so
# and avoid linking with libgcc_s.a to get stack unwinding
# due to exceptions right (see STDCXX-369)
LDSOFLAGS += -shared-libgcc
endif
endif
CXXFLAGS = -pedantic -nostdinc++
ifeq ($(CXX_MAJOR),2)
ifeq ($(shell expr $(CXX_MINOR) / 10),9)
CXXFLAGS += -fhonor-std -ftemplate-depth-32
else
CXXFLAGS += -ftemplate-depth-32
endif
endif
ifeq ($(OSNAME),IRIX64)
ifeq ($(CXX_MAJOR),2)
# prevent (some) assembler errors caused by overly long symbol
# names (the option is not supported in gcc 3 and beyond)
CXXFLAGS += -fsquangle
endif
# disable ld warnings about libs not used to resolve any symbols
LDFLAGS += -Wl,-woff,84
endif
# prevent (some) assemler errors caused by overly long symbol names
ifeq ($(OSNAME),OSF1)
CXXFLAGS += -fsquangle
endif
CXXPRELINK =
# enable C++ C library headers (the <cname> kind)
CPPFLAGS = -I$(TOPDIR)/include/ansi
# decrease warning level to prevent annoying linker warnings
# about duplicate symbols (the linker has no concept of weak symbols)
ifeq ($(OSNAME),AIX)
LDFLAGS = -Wl,-bh:5
endif
ifneq ($(CXX_MAJOR),2)
# gcc 3.x needs to explicitly link with libsupc++ for language support
# g++ 3.x links with it as well as libstdc++ automatically
LDLIBS = -lsupc++
ifeq ($(OSNAME),Darwin)
# link with gcc_eh to resolve the _Unwind_xxx functions
# (shouldn't we link with it on all platforms?)
LDLIBS += -lgcc_eh
endif
endif # gcc > 2
# The flag(s) to use to embed a library search path into generated executables.
ifeq ($(OSNAME),Linux)
RPATH = -Wl,-R
else
ifeq ($(OSNAME),SunOS)
RPATH = -Wl,-R
else
ifeq ($(OSNAME),AIX)
ifeq ($(shell [ $(OS_MAJOR) -gt 5 -o $(OS_MAJOR) -eq 5 \
-a $(OS_MINOR) -ge 3 ] && echo 1), 1)
# -bsrv4, -R only available on AIX 5.3 and newer
RPATH = -Wl,-bsvr4,-R
endif
else
ifeq ($(OSNAME),HP-UX)
RPATH = -Wl,+b
else
ifeq ($(OSNAME),IRIX64)
RPATH = -Wl,-rpath,
else
ifeq ($(OSNAME),OSF1)
RPATH = -Wl,-rpath,
endif
endif
endif
endif
endif
endif
# debug/optimization options
DEBUG_CXXFLAGS = -g
DEBUG_CPPFLAGS =
OPTMZ_CXXFLAGS = -O2
OPTMZ_CPPFLAGS =
# shared/static library options
SHARED_CXXFLAGS =
SHARED_CPPFLAGS =
SHARED_LDFLAGS =
ifeq ($(OSNAME),AIX)
SHARED_SUFFIX = .a
endif
ifeq ($(OSNAME),HP-UX)
SHARED_SUFFIX = .sl
endif
ifeq ($(OSNAME),Darwin)
SHARED_SUFFIX = .dylib
endif
ifneq ($(findstring CYGWIN,$(OSNAME)),)
SHARED_SUFFIX = .dll
SHARED_CPPFLAGS += -D_RWSHARED
LDFLAGS += -Wl,-force-exe-suffix
endif
STATIC_CXXFLAGS =
STATIC_CPPFLAGS =
STATIC_LDFLAGS =
# compiler and linker flags for thread safety
# use undocumented (though long implemented) gcc option -pthread
# which defines _REENTRANT;
# the same option is named -pthreads on Solaris
ifeq ($(findstring CYGWIN,$(OSNAME)),)
ifeq ($(OSNAME),SunOS)
MULTI_CPPFLAGS_POSIX = -pthreads
MULTI_LDFLAGS_POSIX = -pthreads
else
ifeq ($(OSNAME),IRIX64)
# no -pthreads option (or similar) on IRIX?
MULTI_CPPFLAGS_POSIX = -D_REENTRANT
MULTI_LDFLAGS_POSIX = -lpthread
else
# option doesn't exist in Darwin gcc
ifneq ($(OSNAME),Darwin)
MULTI_CPPFLAGS_POSIX = -pthread
MULTI_LDFLAGS_POSIX = -pthread
endif
endif
endif
else
# on Cygwin use MingW-threads by default
# -mthreads not defines _REENTRANT
MULTI_CPPFLAGS_POSIX = -D_REENTRANT -mthreads
MULTI_LDFLAGS_POSIX = -mthreads
# link with libcatgets and libiconv
LDLIBS += -lcatgets -liconv
endif
MULTI_CPPFLAGS_SOLARIS = -threads
MULTI_LDFLAGS_SOLARIS = -threads
MULTI_CPPFLAGS_DCE =
MULTI_LDFLAGS_DCE =
# POSIX
MULTI_CPPFLAGS = $(MULTI_CPPFLAGS_POSIX)
MULTI_LDFLAGS = $(MULTI_LDFLAGS_POSIX)
SINGL_CPPFLAGS =
SINGL_LDFLAGS =
# (try to) determine the architecture via the (non-standard) -p option
# the option is recognized on at least HP-UX, IRIX, and Linux (are there
# any other systems running on IA64?)
arch=$(shell uname -p 2>/dev/null)
ifeq ($(arch),ia64)
# LP64 is the default (implicit) setting on IA64
ifeq ($(OSNAME),HP-UX)
# -milp32, -mlp64, etc. are options specific to HP-UX
CXXFLAGS.narrow = -milp32
LDFLAGS.narrow = -milp32
LDSOFLAGS.narrow = -milp32
ARFLAGS.narrow =
endif
else
# determine whether the default compiler invocation produces
# wide (64-bit) or narrow (32-bit) code and set compiler,
# linker, and other flags accordingly
wide = $(shell tmpfile=/tmp/longsize-$$; export tmpfile; \
echo "int main() { return 8 == sizeof (long); }" \
> $$tmpfile.c \
&& $(CXX) $$tmpfile.c >/dev/null 2>&1 -o $$tmpfile; \
$$tmpfile; echo $$?; rm -f $$tmpfile.c $$tmpfile)
ifeq ($(wide),0)
# wide (64-bit) flags
CXXFLAGS.wide = -m64
LDFLAGS.wide = -m64
LDSOFLAGS.wide = -m64
ARFLAGS.wide =
# narrow (32-bit) mode is implicit
else
# narrow (32-bit) flags
CXXFLAGS.narrow = -m32
LDFLAGS.narrow = -m32
LDSOFLAGS.narrow = -m32
ARFLAGS.narrow =
# wide (64-bit) mode is implicit
endif
endif

View File

@@ -0,0 +1,101 @@
#
# $Id: icc.config 580483 2007-09-28 20:55:52Z sebor $
#
# configuration file for Intel C++
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
CXX = icc
ifeq ($(shell uname -m),ia64)
# check if icc works (prior to 8.0 the name of the IA64 compiler was ecc
ifneq ($(shell $(CXX) -v >/dev/null 2>&1 && echo $$?),0)
CXX = ecc
endif
endif
CCVER := $(shell $(CXX) -V foo.c 2>&1 | sed -n "s/.*Version *\([0-9.]*\).*/\1/p")
CXX_MAJOR := $(shell echo "$(CCVER)" | sed "s/^\([1-9][0-9]*\).*/\1/")
CXX_MINOR := $(shell echo "$(CCVER)" | sed "s/[1-9]*\.\([0-9]*\).*/\1/")
CPPFLAGS = -I$(TOPDIR)/include/ansi
WARNFLAGS = -w1
PHWARNFLAGS =
DEPENDFLAGS = -M
PICFLAGS = -fpic
PRELINKFLAGS =
ICCDIR = `which $(CXX) | sed 's:bin/$(CXX):lib:'`
LDSOFLAGS = -shared
# -cxxlib-nostd, present in all compilers since 8.1, will be documented in 10.x
ifeq ($(shell [ $(CXX_MAJOR) -gt 8 -o $(CXX_MAJOR) -eq 8 -a $(CXX_MINOR) -ge 1 ]), 0)
LD = $(CXX) -no_cpprt $(ICCDIR)/crtxi.o
CXXFLAGS = -Xc -no_cpprt
LDFLAGS =
LDLIBS = -Bstatic -lcxa -lunwind -Bdynamic $(ICCDIR)/crtxn.o
else
LD = $(CXX)
CXXFLAGS = -cxxlib-nostd
LDFLAGS = -cxxlib-nostd
LDLIBS = -lcxaguard -lsupc++
endif
# The flag(s) to use to embed a library search path into generated executables.
RPATH = -Wl,-R
# debug/optimization options
DEBUG_CXXFLAGS = -g
DEBUG_CPPFLAGS =
OPTMZ_CXXFLAGS = -O2
OPTMZ_CPPFLAGS =
# shared/archive library options
SHARED_CXXFLAGS =
SHARED_CPPFLAGS =
SHARED_LDFLAGS =
STATIC_CXXFLAGS =
STATIC_CPPFLAGS =
STATIC_LDFLAGS =
# compiler and linker flags for thread safety
MULTI_CPPFLAGS_POSIX = -D_REENTRANT
MULTI_CPPFLAGS_SOLARIS =
MULTI_CPPFLAGS_DCE =
MULTI_LDFLAGS_POSIX = -lpthread
MULTI_LDFLAGS_SOLARIS =
MULTI_LDFLAGS_DCE =
# POSIX
MULTI_CPPFLAGS = $(MULTI_CPPFLAGS_POSIX)
MULTI_LDFLAGS = $(MULTI_LDFLAGS_POSIX)
SINGL_CPPFLAGS =
SINGL_LDFLAGS =

View File

@@ -0,0 +1,184 @@
# -*- Makefile -*-
#
# $Id: makefile.common 580483 2007-09-28 20:55:52Z sebor $
#
# common makefile definitions shared by all GNUmakefile.*
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
SHELL = /bin/sh
# specify path to find to avoid problems with example named 'find'
FIND = /usr/bin/find
# set common variables used in makefiles
BINDIR = $(BUILDDIR)/bin
LIBDIR = $(BUILDDIR)/lib
# provide a value if it isn't already set by make
ifeq ($(CURDIR),)
CURDIR := $(shell pwd)
endif
INCLUDES = -I$(TOPDIR)/include -I$(BUILDDIR)/include
ALL_FILES := "*"
ifneq ($(AS_EXT),"")
ifneq ($(AS_EXT),".") # special value -- ignore atomic
# if the assembly file extension is non-empty and not the dot,
# add all files with that extension to the list of files to
# compile
ALL_FILES := $(foreach dir,$(SRCDIRS),\
$(wildcard $(dir)/*.cpp $(dir)/*.msg $(dir)/*$(AS_EXT)))
endif
endif
ifeq ($(ALL_FILES),"*")
# traverse all subdirectories and get the names of all source files
ALL_FILES := $(foreach dir,$(SRCDIRS), $(wildcard $(dir)/*.cpp $(dir)/*.msg))
endif
# SRCDIRS must be defined in GNUmakefile that includes this file
ifeq ($(ONE_REPOSITORY),)
# using a separate template instantiation repository for each source
# and object file (i.e., when each source produces one executable)
ifneq ($(CXX_REPOSITORY),)
# define a function, CXX.repo, that returns the name of the template
# instantiation repository from the name of a source or object file
# and a unique suffix (so that each program has its own and the same
# names with different definitions do not cause conflicts)
#
# e.g., Compaq C++ where this will expand to something like
# -ptr foo.ti
# or IBM VisualAge/XLC++ where it will be along the lines of
# --qtempinc=foo.ti
# or
# --qtemplateregistry=foo.ti
#
ifeq ($(findstring =,$(CXX_REPOSITORY)),=)
CXX.repo = $(CXX_REPOSITORY)$(basename $(notdir $(1))).ti
else
CXX.repo = $(CXX_REPOSITORY) $(basename $(notdir $(1))).ti
endif
else # ifeq ($(CXX_REPOSITORY),)
ifeq ($(CXX),CC)
ifeq ($(findstring SunOS,$(PLATFORM)),SunOS)
# set SUNWS_CACHE_NAME to the basename of the file being compiled
# followed by .ti, to override the default template repository,
# SunWS_cache
tmp := $(CXX)
CXX =
CXX += SUNWS_CACHE_NAME=$(*F).ti
CXX += $(tmp)
tmp := $(LD)
LD =
LD += SUNWS_CACHE_NAME=$(*F).ti
LD += $(tmp)
endif # SunOS
endif # SunPro
endif # neq ($(CXX_REPOSITORY),)
else # ifneq ($(ONE_REPOSITORY),)
ifneq ($(CXX_REPOSITORY),)
# using a template instantiation repository shared by all sources
# (i.e., when creating a single executable or library out of all
# the object files
ifeq ($(findstring =,$(CXX_REPOSITORY)),=)
CXX.repo = $(CXX_REPOSITORY)repository.ti
else
CXX.repo = $(CXX_REPOSITORY) repository.ti
endif
endif
endif
CPPFLAGS += $(INCLUDES)
CXXFLAGS += $(WARNFLAGS)
VPATH := $(SRCDIRS)
SRCS := $(notdir $(filter %.cpp %$(AS_EXT),$(ALL_FILES)))
SRCS := $(sort $(filter-out $(OMIT_SRCS),$(SRCS)))
OBJS := $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRCS)))
OBJS += $(patsubst %$(AS_EXT),%.o,$(filter %$(AS_EXT),$(SRCS)))
OBJS := $(sort $(OBJS))
DEPS :=
# message files - text files used to generate a catalog - see gencat(1)
MSGFILES = $(filter %.msg,$(ALL_FILES))
ifeq ($(TARGET),)
# generate binaries or scripts (in constrained environments)
ifeq ($(NO_A_DOT_OUT),)
TARGET := $(patsubst %.o,%,$(OBJS))
else
TARGET := $(patsubst %.o,%.sh,$(OBJS))
endif
endif #ifneq ($(TARGET),)
# link with the produced library and the math library
# (take care not to try to link the library with itself)
ifeq ($(findstring $(LIBNAME),$(TARGET)),)
LDFLAGS += -L$(LIBDIR)
# set the GNU make variable LDLIBS to the names of the libraries
# to link with (make puts $(LDLIBS) last on the link line in
# implicit rules)
LDLIBS := -l$(LIBBASE) $(LDLIBS) -lm
endif # ifneq ($(LIBNAME),$findstring ($(LIBNAME),$(TARGET)))
# file to write log of the build to
LOGFILE = /dev/null
# if LOGFILE is being created, tee command output into it
# IMPORTANT: $(TEEOPTS) must be last on the command line
ifneq ($(LOGFILE),/dev/null)
TEEOPTS = 2>&1 | tee -a $(LOGFILE)
endif
# set the RUNTARGET variable to command line args if $RUN isn't set
ifeq ($(RUN),)
RUNTARGET := $(filter-out run_all runall run,$(MAKECMDGOALS))
else
RUNTARGET := $(RUN)
endif
ifeq ($(RUNTARGET),)
RUNTARGET := $(shell echo ./$(TARGET) | sed "s/ / .\//g")
endif
# append command line options to standard flags
CPPFLAGS += $(CPPOPTS)
CXXFLAGS += $(CXXOPTS)
LDFLAGS += $(LDOPTS)
ARFLAGS += $(AROPTS)
RUNFLAGS += $(RUNOPTS)

View File

@@ -0,0 +1,326 @@
# -*- Makefile -*-
#
# $Id: makefile.rules 648752 2008-04-16 17:01:56Z faridz $
#
# common makefile rules shared by all GNUmakefile.*
#
########################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
########################################################################
#
# Running tests:
# --------------
# $ make [run | runall | run_all] [target] [target]... ;
# runs the tests specified on the command line
# OR
# $ make [run | runall | run_all] ;
# runs all the tests producing a complete report
#
#
########################################################################
clean: cleantarget
rm -rf a.out core *.o *.i *.ii *.ti *.sh *.sta *.out \
*$(LIBSUFFIX) $(CATFILE) \
tempinc cxx_repository SunWS_cache 2>/dev/null
cleantarget:
rm -f $(TARGET)
listtarget:
@echo $(TARGET)
listsrc:
@echo $(SRCS)
listobj:
@echo $(OBJS)
listfiles:
@echo $(SRCDIRS)
@echo $(ALL_FILES)
listvpath:
@echo $(VPATH)
listruntarget:
@echo $(RUNTARGET)
# create a catalog from text message files - see gencat(1)
$(CATFILE): $(MSGFILES)
-gencat $@ $^
ifeq ($(WITH_PURIFY),true)
ifeq ($(PURIFYFLAGS),)
PURIFYFLAGS = -windows=no
PURIFYFLAGS += -log-file=stderr -view-file=$@.purify-view
endif
ifneq ($(OSNAME),AIX)
PURIFY = purify $(PURIFYFLAGS)
endif
endif
ifeq ($(WITH_CADVISE),true)
ifeq ($(CADVISEFLAGS),)
CADVISEFLAGS = +w
endif
CADVISE = cadvise $(CADVISEFLAGS)
endif
########################################################################
# COMMON RULES
########################################################################
ifeq ($(NO_DOT_O),)
# compile and link in two separate steps
ifneq ($(AS_EXT),)
ifneq ($(AS_EXT),".")
%.o: %$(AS_EXT)
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $<
endif # ifneq ($(AS_EXT),".")
endif # ifneq ($(AS_EXT),)
# make the rule match for sources matching *.out.cpp
%.out.o: %.out.cpp
$(CADVISE) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(call CXX.repo,$<) $<
%.o: %.cpp
$(CADVISE) $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(call CXX.repo,$<) $<
# make the rule match for objects matching *.out.o
%.out: %.out.o
$(PURIFY) $(LD) $< -o $@ $(LDFLAGS) $(LDLIBS) $(call CXX.repo,$<)
%: %.o
$(PURIFY) $(LD) $< -o $@ $(LDFLAGS) $(LDLIBS) $(call CXX.repo,$<)
# disable compilation and linking in the same step
# %: %.cpp
else
# compile and link in one step to eliminate the space overhead of .o files
%: %.cpp
$(CADVISE) $(PURIFY) $(CXX) $< -o $@ $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) \
$(LDLIBS) $(call CXX.repo,$<)
endif # eq ($(NO_DOT_O),)
# produce a .out file by running the executable
%.out: %
LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIR) ./$< >$@ 2>&1
# create a script that when run first builds the executable and then runs it
# done to save even more space than `NO_DOT_O' on constrained systems
%.sh: %.cpp
@(echo "generating $@..." ; \
echo "#!$(SHELL)" > $@ ; \
a_dot_out="$(PWD)/$(basename $@)."'$$''$$' ; \
tmp="$(CXX) $< -o $$a_dot_out $(CPPFLAGS) $(CXXFLAGS) " \
"$(LDFLAGS) $(LDLIBS)" ; \
tmp="$$tmp && $$a_dot_out "'$$''*'" && rm $$a_dot_out" ; \
echo >> $@ ; echo "$$tmp" >> $@ ; \
chmod +x $@)
# run all tests, collect exit status and report statistics; the variable
# RUN can be set to contain a list of executables to run without generating
# a report (set to ALL to run all executables)
# hung or runaway processes are killed after a customizable timeout period
#
# to avoid filling up disk space with files left behind by bad programs
# creates and sets the POSIX TMPDIR environment variable to a temporary
# directory before running the programs which is then removed when done
#
# PlumHall specific:
# for all "top level" tests that failed to build, find and build all
# subtests (the little tests the main test consists of)
ifeq (,$(findstring cygwin,$(PLATFORM)))
run runall run_all: $(BINDIR)/exec
@(LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIR); \
PATH=$$PATH:.; \
TOPDIR=$(TOPDIR); \
TMPDIR=$${TMPDIR:-/tmp}/stdcxx-run-$$$$; \
export LD_LIBRARY_PATH PATH TMPDIR TOPDIR TZ; \
trap "rm -rf $$TMPDIR" HUP INT QUIT TERM EXIT; \
mkdir -p $$TMPDIR; \
./run $(RUNFLAGS) $(RUNTARGET); \
exit 0)
else
# on Cygwin add $(LIBDIR) and $(BINDIR) to PATH
run runall run_all: $(BINDIR)/exec
@(LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:$(LIBDIR); \
PATH=$$PATH:$(LIBDIR):$(BINDIR):.; \
TOPDIR=$(TOPDIR); \
TMPDIR=$${TMPDIR:-/tmp}/stdcxx-run-$$$$; \
export LD_LIBRARY_PATH PATH TMPDIR TOPDIR TZ; \
trap "rm -rf $$TMPDIR" HUP INT QUIT TERM EXIT; \
mkdir -p $$TMPDIR; \
./run $(RUNFLAGS) $(RUNTARGET); \
exit 0)
endif
# include the automatically generated dependencies unless "clean"
# or similar is one of the targets
ifeq ($(findstring clean,$(MAKECMDGOALS)),)
ifeq ($(MAKECMDGOALS),)
# include all dependencies (can be slow when there are a lot of them)
DEPS += $(patsubst %.cpp,$(DEPENDDIR)/%.d,$(filter %.cpp,$(SRCS)))
DEPS += $(patsubst %$(AS_EXT),$(DEPENDDIR)/%.d,$(filter %$(AS_EXT),$(SRCS)))
else
# as a (potentially significant) optimization, include
# only the dependencies for the explicitly specified goals
DEPS += $(addprefix $(DEPENDDIR)/,$(basename $(MAKECMDGOALS)))
DEPS += $(addsuffix .d,$(DEPS))
endif
# (try to) include the dependency file(s), failing gracefully
# if they don't exist (e.g., in the case of a .PHONY goal)
-include $(DEPS)
endif # eq ($(findstring clean,$(MAKECMDGOALS)),)
# generate dependencies only if they don't yet exist, removing anything
# not under $(TOPDIR) or $(BUILDDIR) (e.g., system headers) from the list
# this is done by splitting up dependencies using tr so that there is just
# one per line and then replacing the values of $(TOPDIR) and $(BUILDDIR)
# with the actual make variable names themselves
# move IBM xlC generated .u files to the respective .d files
define makedep
-@(if [ ! -f $@ ] ; then \
echo "generating dependencies for" \
`echo $< | sed "s:$(TOPDIR):$$""(TOPDIR):"` ; \
\
stripexp="s:/$$::;s:[^/]*$$::"; \
RWTSRCDIR=`echo $(TOPDIR) | sed "$$stripexp"`rwtest; \
\
sedexp1="s:\([^ :]\)\( */\):\1 \\\@\2:" ; \
sedexp2="/:[^/]*$$/p; \
s:$$RWTSRCDIR:$$""(TOPDIR)/\.\./rwtest:gp; \
s:$(TOPDIR):$$""(TOPDIR):gp; \
s:$(BUILDDIR):$$""(BUILDDIR):gp" ; \
depflags="$(value DEPENDFLAGS$(depsuffix))"; \
[ "$$depflags" = "" ] && depflags=$(DEPENDFLAGS); \
echo "$(CXX) $$depflags $(CPPFLAGS) $(CXXFLAGS) $<"; \
$(CXX) $$depflags $(CPPFLAGS) $(CXXFLAGS) $< \
| sed "$$sedexp1" | tr "@" "\n" | sed -n "$$sedexp2" >$@ ; \
if [ ! -s $@ ]; then \
depfile=$*.u; \
[ ! -s $$depfile ] && depfile=`basename $*.d`; \
if [ -s $$depfile ] ; then \
sed "$$sedexp1" $$depfile | tr "@" "\n" \
| sed -n "$$sedexp2" > $@ ; \
fi; \
rm -f $$depfile ; \
fi ; \
rm -f $*.i ; \
fi)
endef
$(DEPENDDIR):
@[ ! -d $(DEPENDDIR) ] && mkdir -p $(DEPENDDIR)
ifeq ($(DEPENDFLAGS),)
# if DEPENDFLAGS is empty or not defined, set it to the concatenation
# of the variables specific to each type of a source file
DEPENDFLAGS = $(DEPENDFLAGS.cpp) $(value DEPENDFLAGS$(AS_EXT))
else
DEPENDFLAGS.cpp := $(DEPENDFLAGS)
DEPENDFLAGS.S := $(DEPENDFLAGS)
DEPENDFLAGS.s := $(DEPENDFLAGS)
endif
ifneq ($(DEPENDFLAGS),)
# set depsuffix to the suffix of the first prerequisite
$(DEPENDDIR)/%.d: depsuffix = $(suffix $<)
ifneq ($(DEPENDFLAGS.cpp),)
# rule to make dependencies for C++ source files
$(DEPENDDIR)/%.d: %.cpp $(DEPENDDIR)
$(makedep)
endif # DEPENDFLAGS.cpp
ifneq ($(value DEPENDFLAGS$(AS_EXT)),)
# rule to make dependencies for assembly files
$(DEPENDDIR)/%.d: %$(AS_EXT) $(DEPENDDIR)
$(makedep)
endif # DEPENDFLAGS.as
else # ifeq ($(DEPENDFLAGS),)
$(DEPENDDIR)/%.d:
endif # neq ($(DEPENDFLAGS),)
# disable implicit rules from trying to compile .c and .cc files
# under the include/ directory (e.g., istream.c to istream) due
# to being listed as dependencies of .cpp files
%: %.c
%.o: %.c
%: %.cc
%.o: %.cc
%: %.h
# force the regeneration of all dependencies by removing them
dependclean:
rm -f $(DEPENDDIR)/*.d;
@echo "dependencies will be regenerated at the next invocation of make"
# print ordinary make variables and their values (requires GNU make 3.80)
printvars:
@$(foreach V,$(sort $(.VARIABLES)), \
$(if $(filter-out environment% default automatic, $(origin $V)), \
$(warning $V=$($V) ($(value $V)))))
# define a set of phony targets that make should make unconditionally
# regardless of whether files with the same name exist and their
# timestamps
.PHONY: all c_headers clean dependclean realclean config configure listtarget \
listruntarget listsrc listobj listvpath listsubtests printvars \
run run_all runall
# override the default set of suffixes with our own
.SUFFIXES: .a .c .cc .cpp .d .h .o .$(AS_EXT)

View File

@@ -0,0 +1,113 @@
# -*- Makefile -*-
#
# $Id: mipspro.config 580483 2007-09-28 20:55:52Z sebor $
#
# configuration file for SGI MIPSpro on IRIX
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
CXX = CC
CCVER := $(shell $(CXX) -version 2>&1 | awk '{ print $$4 }')
# disable warnings:
# 1429 - The type "long long" is nonstandard.
# 1460
# 1521 - A nonstandard preprocessing directive is used. (#ident in sys files)
# 3150
# 3333 - Support for placement delete is disabled.
WARNFLAGS = -ansiW -woff1429,1460,1521,3150,3333
DEPENDFLAGS = -M
PICFLAGS = -KPIC
LDSOFLAGS = -shared
CXXFLAGS =
CPPFLAGS = -I$(TOPDIR)/include/ansi
# use CC to invoke the archiver (needed in order to include template
# instantiations from the ii_files/ template repository)
AR = CC
ARFLAGS = -ar -WR,-v -o
# disable warnings about libs that aren't being used to resolve any symbols
LDFLAGS = -Wl,-woff,84
# use the undocumented -LANG:std=off option to prevent linking
# with the native C++ Standard Library
LDFLAGS += -LANG:std=off
# add libpthread to the list of libraries to link with
ifeq ($(findstring pthread,$(BUILDMODE)),pthread)
LDLIBS := -lpthread
endif
# the extension of assembly files is .s
AS_EXT = .s
# The flag(s) to use to embed a library search path into generated executables.
RPATH = -Wl,-rpath,
# debug/optimization options
DEBUG_CXXFLAGS = -g
DEBUG_CPPFLAGS =
# disable Olimit (can be easily exceeded)
OPTMZ_CXXFLAGS = -O -OPT:Olimit=0
OPTMZ_CPPFLAGS =
# shared/static library options
SHARED_CXXFLAGS =
SHARED_CPPFLAGS =
SHARED_LDFLAGS =
STATIC_CXXFLAGS =
STATIC_CPPFLAGS =
STATIC_LDFLAGS =
# multi/single thread options
MULTI_CPPFLAGS_POSIX = -D_REENTRANT
MULTI_CPPFLAGS_SOLARIS =
MULTI_CPPFLAGS_DCE =
MULTI_LDFLAGS_POSIX =
MULTI_LDFLAGS_SOLARIS =
MULTI_LDFLAGS_DCE =
# POSIX
MULTI_CPPFLAGS = $(MULTI_CPPFLAGS_POSIX)
MULTI_LDFLAGS = $(MULTI_LDFLAGS_POSIX)
SINGL_CPPFLAGS =
SINGL_LDFLAGS =
# wide (64-bit) flags -- must be set explicitly
CXXFLAGS.wide = -64
LDFLAGS.wide = -64
LDSOFLAGS.wide = -64
ARFLAGS.wide =
# narrow (32-bit) flags -- implicit in the default invocation
# CXXFLAGS.narrow = -32
# LDFLAGS.narrow = -32
# LDSOFLAGS.narrow = -32
# ARFLAGS.narrow =

View File

@@ -0,0 +1,81 @@
#
# $Id: osf_cxx.config 580483 2007-09-28 20:55:52Z sebor $
#
# configuration file DEC cxx on DEC OSF
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
CXX = cxx
CCVER := $(shell $(CXX) -V 2>&1 | awk '{ print $$3 }')
CXXFLAGS = -x cxx -nocxxstd -std strict_ansi_errors
WARNFLAGS = -w1 -msg_disable 450
DEPENDFLAGS = -M -noimplicit_include
PICFLAGS =
PRELINKFLAGS =
CPPFLAGS =
LDFLAGS = -nocxxstd
LDSOFLAGS = -shared
ifeq ($(OSNAME),OSF1)
# link with libiconv only on AIX (and not on Linux)
LDFLAGS += -liconv
endif
# use a unique template repository for each program
# (makefiles will append '=' followed by the name of the repository)
CXX_REPOSITORY = -ptr
# The flag(s) to use to embed a library search path into generated executables.
RPATH = -rpath
# debug/optimization options
DEBUG_CXXFLAGS = -g
DEBUG_CPPFLAGS =
OPTMZ_CXXFLAGS = -O2
OPTMZ_CPPFLAGS =
# shared/static library option
SHARED_CXXFLAGS =
SHARED_CPPFLAGS = -D_RWSTD_SHARED_LIB
SHARED_LDFLAGS =
STATIC_CXXFLAGS =
STATIC_CPPFLAGS =
STATIC_LDFLAGS =
# multi/single thread options; -pthread option defines _REENTRANT
MULTI_CPPFLAGS_POSIX = -pthread
MULTI_CPPFLAGS_SOLARIS =
MULTI_CPPFLAGS_DCE = -threads
MULTI_LDFLAGS_POSIX = -pthread
MULTI_LDFLAGS_SOLARIS =
MULTI_LDFLAGS_DCE = -threads
# Posix
MULTI_CPPFLAGS = $(MULTI_CPPFLAGS_POSIX)
MULTI_LDFLAGS = $(MULTI_LDFLAGS_POSIX)
SINGL_CPPFLAGS =
SINGL_LDFLAGS =

View File

@@ -0,0 +1,63 @@
#
# $Id: reliant_cds.config 580483 2007-09-28 20:55:52Z sebor $
#
# configuration file for Siemens CDS++ on Reliant UNIX
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
CXX = CC
CCVER := $(shell $(CXX) -V /bogus/file.cpp 2>&1 | head -1 | awk '{ print $4 }')
CXXFLAGS = -Xe
WARNFLAGS =
DEPENDFLAGS = -M
PICFLAGS =
PRELINKFLAGS =
CPPFLAGS =
LDFLAGS =
# The flag(s) to use to embed a library search path into generated executables.
# Appropriate flag(s) (if available) not determined at this time.
RPATH =
# debug/optimization options
DEBUG_CXXFLAGS = -g
DEBUG_CPPFLAGS =
OPTMZ_CXXFLAGS = -F O2
OPTMZ_CPPFLAGS =
# shared/static library options
SHARED_CXXFLAGS = -Kpic
SHARED_CPPFLAGS = -D_RWSTD_SHARED_LIB
SHARED_LDFLAGS = -G
STATIC_CXXFLAGS =
STATIC_CPPFLAGS =
STATIC_LDFLAGS =
# multi/single thread options
MULTI_CPPFLAGS = -D_REENTRANT
MULTI_LDFLAGS = -lpthread
SINGL_CPPFLAGS =
SINGL_LDFLAGS =

View File

@@ -0,0 +1,617 @@
#!/bin/sh
#
# $Id: run_locale_utils.sh 648752 2008-04-16 17:01:56Z faridz $
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2008 Rogue Wave Software, Inc.
#
##############################################################################
#
# NAME
# run_locale_utils.sh
#
# SYNOPSIS
# run_locale_utils.sh
#
# DESCRIPTION
# Exercise the locale utilities:
# 1. Locale utilities sanity: location, output, etc;
# 2. Functionality:
# - (re)generation of databases;
#
# OPTIONS:
# - "-d" debug
# - "-n" no cleanup
# - "-s" tests location, output
# - "-f" tests functionality; is followed by:
# - "-i <nlsdir>"
# - "-l <locale name>"
#
##############################################################################
OSNAME=`uname`
if [ "$OSNAME" = "OSF1" -a "$BIN_SH" != "xpg4" ]; then
# make getopts work on Tru64 by setting the BIN_SH variable
# and re-executing self with the same command line arguments
BIN_SH=xpg4
export BIN_SH
exec $0 $*
elif [ "$OSNAME" = "AIX" -a -z "$BASH_VERSION" ]; then
# use an alternate shell to work around a bug (?) in the AIX system
# shell that prevents it from trapping SIGHUP (and invoking the signal
# handler)
if [ -x /bin/bash ]; then
exec /bin/bash $0 $*
fi
fi
locale="./locale"
localedef="./localedef"
output ()
{
if test -z "$outfile"; then
echo "$*" 2>/dev/null
else
echo "$*" >> $outfile
fi;
}
debug_output ()
{
if test ! -z "$dbgout"; then
echo "$*" >> $dbgout 2>/dev/null
fi;
}
##############################################################################
# Function definitions - checking sanity
##############################################################################
check_locale_help ()
{
debug_output "Checking \"locale --help\" output..."
loc_h_out=`${locale} --help 2>/dev/null`
loc_h_xout="NAME SYNOPSIS DESCRIPTION"
loc_h_regexp="locale - get locale-specific information"
for it in $loc_h_xout; do
assertions=`expr $assertions + 1`
if test -z "`echo $loc_h_out | grep $it`"; then
debug_output " incorrect."
debug_output "ERROR: \"locale --help\" gives wrong output ($it)."
debug_output ""
failedassertions=`expr $failedassertions + 1`
fi;
done
debug_output "...ok"
}
check_locale_all()
{
debug_output "Checking \"locale -a\" output..."
loc_a_out=`${locale} -a 2>/dev/null`
loc_a_regexp="[a-z]\{2\}_[A-Z]\{2\}"
for it in $loc_a_out; do
assertions=`expr $assertions + 1`
test "$it" = "C" && continue;
if test -z "`echo $it | grep -e \"$loc_a_regexp\"`"; then
debug_output "incorrect."
debug_output "Warning: Locale name \"$it\" not matching pattern."
failedassertions=`expr $failedassertions + 1`
fi;
done
debug_output "...ok"
}
check_locale_m()
{
debug_output "Checking \"locale -m\" output..."
any_failed=0
loc_m_out=`${locale} -m 2>/dev/null`
any_failed=$?
for it in $loc_m_out; do
assertions=`expr $assertions + 1`
if test -z "`echo $it | grep .cm`" ; then
any_failed=1
debug_output " incorrect."
debug_output "ERROR: \"locale -m\" failed."
debug_output
failedassertions=`expr $failedassertions + 1`
fi;
done;
if [ $any_failed -eq 0 ]; then
debug_output "...ok"
fi
}
check_locale_k()
{
debug_output "Checking \"locale -k LC_ALL\" output..."
loc_k_out=`${locale} -k LC_ALL 2>/dev/null`
loc_k_xout="upper lower space print \
cntrl alpha digit punct \
graph xdigit toupper tolower \
abday day abmon mon \
am_pm d_t_fmt d_fmt t_fmt t_fmt_ampm \
int_curr_symbol currency_symbol mon_decimal_point \
mon_thousands_sep mon_grouping positive_sign negative_sign \
int_frac_digits frac_digits p_cs_precedes p_sep_by_space \
n_cs_precedes n_sep_by_space p_sign_posn n_sign_posn \
decimal_point thousands_sep grouping"
any_failed=0
for it in $loc_k_xout; do
assertions=`expr $assertions + 1`;
if test -z "`echo $loc_k_out | grep $it`"; then
# output text only for the first failure
[ $any_failed -eq 0 ] && debug_output " incorrect."
debug_output "ERROR: \"locale -k\" gives wrong output ($it)."
debug_output
failedassertions=`expr $failedassertions + 1`
any_failed=1
fi;
done
if [ $any_failed -eq 0 ]; then
debug_output "...ok"
fi
}
check_localedef_help()
{
debug_output "Checking \"localedef --help\" output..."
locdef_h_out=`${localedef} --help 2>/dev/null`
locdef_h_xout="NAME SYNOPSIS DESCRIPTION"
locdef_h_regexp="localedef - generate a locale environment"
for it in $locdef_h_xout; do
assertions=`expr $assertions + 1`;
if test -z "`echo $locdef_h_out | grep $it`"; then
debug_output " incorrect."
debug_output "ERROR: \"localedef --help\" gives wrong output ($it)."
debug_output
failedassertions=`expr $failedassertions + 1`
fi;
done
debug_output "...ok"
}
##############################################################################
# Function definitions - checking functionality
##############################################################################
#
# Generates one specified locale
#
generate_locale()
{
err="Cannot generate locale database - "
# 1 - character map file used in generating the locale database
# 2 - source/locale definition file
# 3 - locale database name
if [ "$1" = "" ]; then
output "$err character maps file not specified."
exit 1;
fi
if [ "$2" = "" ]; then
output "$err source input file not specified."
exit 1;
fi
if [ "$3" = "" ]; then
output "$err output locale name not specified."
exit 1;
fi
assertions=`expr $assertions + 1`
# Generating the database
debug_output "${localedef} -w -c -f $1 -i $2 $3 >${dbgout:-/dev/null} 2>&1"
${localedef} -w -c -f $1 -i $2 $3 >${dbgout:-/dev/null} 2>&1
retcode=$?
if [ $retcode -ne 0 ]; then
# exit with the same status as the tool
exit $retcode
fi
}
#
#
#
dump_charmap()
{
err="Cannot create characater set description file - "
# $1: LC_ALL value
# $2: output file name
assertions=`expr $assertions + 1`
# dumping charmap
output "LC_ALL=$1 ${locale} --charmap -l >$2 2>${dbgout:-/dev/null}"
LC_ALL=$1 ${locale} --charmap -l > $2 2>${dbgout:-/dev/null}
retcode=$?
if [ $retcode -ne 0 ]; then
# exit with the same status as the tool
exit $retcode
fi
}
#
# Dumps one locale database
#
dump_locale ()
{
err="Cannot dump locale database - "
# $1: LC_ALL value
# $2: current locale dump file
if [ "$2" = "" ]; then
output "$err - no output file specified."
exit 1
fi
assertions=`expr $assertions + 1`
# dumping locale database
output "LC_ALL=$1 ${locale} -ck -h -l LC_ALL >$2 2>${dbgout:-/dev/null}"
LC_ALL=$1 ${locale} -ck -h -l LC_ALL > $2 2>${dbgout:-/dev/null}
retcode=$?
if [ $retcode -ne 0 ]; then
# exit with the same status as the tool
exit $retcode
fi
}
#
# Test one locale
#
test_locale()
{
err="Cannot test locale - "
# $1 - nls subdirectory of the source directory tree
# $2 - the test (sandbox) directory
# $3 - name of the locale database
if [ "$1" = "" ]; then
output "$err - nls directory not specified."
exit 1
fi
if [ "$2" = "" ]; then
output "$err - temporary directory not specified."
exit 1
fi
if [ "$3" = "" ]; then
output "$err - locale database name not specified."
exit 1
fi
nlsdir=$1
tmpdir=$2
fname=$3
# get the name of the locale and the character map
source=`echo $fname | sed "s:\([^.]*\)\.\([^@]*\)\(.*\):\1\3:;y:@:.:"`;
charmap=`echo $fname | sed "s:\([^.]*\)\.\([^@]*\)\(.*\):\2:"`;
src_path=$nlsdir/src/$source
cm_path=$nlsdir/charmaps/$charmap
stage_1=$tmpdir/stage.1
stage_2=$tmpdir/stage.2
stage_3=$tmpdir/stage.3
# point locale at the original source directory
debug_output "RWSTD_SRC_ROOT="$nlsdir
RWSTD_SRC_ROOT=$nlsdir
debug_output "export RWSTD_SRC_ROOT"
export RWSTD_SRC_ROOT
# create a directory for stage 1 charmap source files
debug_output "mkdir -p $stage_1/charmaps"
mkdir -p $stage_1/charmaps
assertions=`expr $assertions + 1`
## generate stage 1 locale database from the orignal sources
generate_locale $cm_path $src_path $stage_1/$fname
if [ $? -ne 0 ]; then
failedassertions=`expr $failedassertions + 1`
return;
fi
# set necessary environment variables
# debug_output "LC_ALL=$fname"
# LC_ALL=$fname
# debug_output "export LC_ALL"
# export LC_ALL
# debug_output "LANG=$fname"
# LANG=$fname
# debug_output "export LANG"
# export LANG
assertions=`expr $assertions + 1`
# dump the charmap and the locale data from the database
# to a pair of charmap and locale source files
dump_charmap $stage_1/$fname $stage_1/charmaps/$charmap
dump_locale $stage_1/$fname $stage_1/$source.src
if [ -z "$no_clean" ]; then
# remove stage 1 locale to free up disk space but keep
# the text dumps for later processing
debug_output "rm $stage_1/$fname"
rm $stage_1/$fname
fi
# create a directory for stage 2 charmap source files
debug_output "mkdir -p $stage_2/charmaps"
mkdir -p $stage_2/charmaps
assertions=`expr $assertions + 1`
# generate stage 2 locale database from the charmap and locale
# source files produced by locale from the stage 1 database
generate_locale $stage_1/charmaps/$charmap \
$stage_1/$source.src \
$stage_2/$fname
if [ $? -ne 0 ]; then
failedassertions=`expr $failedassertions + 1`
return;
fi
# point locale at the stage 1 directory
debug_output "RWSTD_SRC_ROOT=$stage_1"
RWSTD_SRC_ROOT=$stage_1
debug_output "export RWSTD_SRC_ROOT"
export RWSTD_SRC_ROOT
assertions=`expr $assertions + 1`
# dump the charmap and the locale data from the database
# to a pair of charmap and locale source files
dump_charmap $stage_2/$fname $stage_2/charmaps/$charmap
dump_locale $stage_2/$fname $stage_2/$source.src
if [ -z "$no_clean" ]; then
# remove stage 2 locale to free up disk space but keep
# the text dumps for later processing
debug_output "rm $stage_2/$fname"
rm $stage_2/$fname
fi
assertions=`expr $assertions + 1`
# create a directory for stage 2 charmap source files
debug_output "mkdir -p $stage_3/charmaps"
mkdir -p $stage_3/charmaps
# generate stage 3 locale database from the charmap and locale
# source files produced by locale from the stage 2 database
generate_locale $stage_2/charmaps/$charmap \
$stage_2/$source.src \
$stage_3/$fname
if [ $? -ne 0 ]; then
failedassertions=`expr $failedassertions + 1`
return;
fi
# point locale at the stage 2 directory
debug_output "RWSTD_SRC_ROOT=$stage_2"
RWSTD_SRC_ROOT=$stage_2
debug_output "export RWSTD_SRC_ROOT"
export RWSTD_SRC_ROOT
assertions=`expr $assertions + 1`
# dump the charmap and the locale data from the database
# to a pair of charmap and locale source files
dump_charmap $stage_3/$fname $stage_3/charmaps/$charmap
dump_locale $stage_3/$fname $stage_3/$source.src
if [ -z "$no_clean" ]; then
# remove stage 3 locale to free up disk space but keep
# the text dumps for later processing
debug_output "rm $stage_3/$fname"
rm $stage_3/$fname
fi
assertions=`expr $assertions + 1`
# verify that stage 1 and stage 2 charmaps are the same
debug_output "diff $stage_1/charmaps/$charmap " \
"$stage_2/charmaps/$charmap >/dev/null"
diff $stage_1/charmaps/$charmap $stage_2/charmaps/$charmap >/dev/null
if [ $? -ne 0 ]; then
debug_output "## AssertionFailed: $stage_1/charmaps/$charmap " \
"and $stage_2/charmaps/$charmap differ."
failedassertions=`expr $failedassertions + 1`
fi
# verify that stage 2 and stage 3 charmaps are the same
debug_output "diff $stage_2/charmaps/$charmap " \
"$stage_3/charmaps/$charmap >/dev/null"
diff $stage_2/charmaps/$charmap $stage_3/charmaps/$charmap >/dev/null
if [ $? -ne 0 ]; then
debug_output "## AssertionFailed: $stage_2/charmaps/$charmap " \
"and $stage_3/charmaps/$charmap differ."
failedassertions=`expr $failedassertions + 1`
fi
# verify that stage 2 and stage 3 locale sources are the same
debug_output "diff $stage_2/$source.src " \
"$stage_3/$source.src >/dev/null"
diff $stage_2/$source.src $stage_3/$source.src >/dev/null
if [ $? -ne 0 ]; then
debug_output "## AssertionFailed: $stage_2/$source.src " \
"and $stage_3/$source.src differ."
failedassertions=`expr $failedassertions + 1`
fi
if [ -z "$no_clean" ]; then
# clean up
debug_output "rm -rf $stage_1 $stage_2 $stage_3"
rm -rf $stage_1 $stage_2 $stage_3
fi
}
#
# cleanup/signal handler
#
cleanup ()
{
if [ -z "$no_clean" ]; then
# clean up
debug_output "rm -rf $tmpdir"
rm -rf $tmpdir
fi
exit
}
##############################################################################
# Main code
##############################################################################
## assertions
assertions=0
failedassertions=0
## main functions
debug=no
chk_sanity=no
chk_func=no
## directories
bindir=""
nlsdir=""
locdir=""
## Get the options from the command line
while getopts ":nsfdb:i:l:O:L:M:C:D:" opt_name; do
case $opt_name in
d) dbgout="/dev/tty";;
s) chk_sanity=yes;;
f) chk_func=yes;;
b) bindir=$OPTARG;;
i) nlsdir=$OPTARG;;
l) locale_db=$OPTARG;;
n) no_clean=yes;;
O) outfile=$OPTARG;;
L);; ## ignored
M);; ## ignored
C);; ## ignored
D);; ## ignored
*) echo "Unimplemented option : -$opt_name" >&2;
exit 1;;
esac;
done
## set temporary (working) directory
if [ -z "$TMPDIR" ]; then
TMPDIR="/tmp"
export TMPDIR
fi
tmpdir=$TMPDIR/${locale_db:-unnamed-locale}.$$
## Actual test
if [ "$chk_sanity" = "yes" ]; then
## checking locale sanity
check_locale_help
check_locale_all
check_locale_m
check_locale_k
check_localedef_help
elif [ "$chk_func" = "yes" ]; then
## create the temp dir
mkdir $tmpdir
if [ $? -ne 0 ]; then
echo "$0: Unable to create $tmpdir, aborting" >&2
exit 1
fi
# clean up temporary files on signal or exit
trap cleanup HUP INT QUIT TERM EXIT
# test only one locale
test_locale $nlsdir $tmpdir $locale_db;
else
## Invocation is wrong
echo "$0: Usage : " >&2
echo "script -s -b <bindir> ## checking sanity" >&2
echo "script -f -i <nlsdir> -l <locale name> ## check functionality" >&2
exit 2
fi
pcnt=`expr 100 \* \( $assertions - $failedassertions \) / $assertions`
output "# +-----------------------+----------+----------+----------+"
output "# | DIAGNOSTIC | ACTIVE | TOTAL | INACTIVE |"
output "# +-----------------------+----------+----------+----------+"
if test -z "$outfile"; then
printf "# | (S7) ASSERTION | %8d | %8d | %7d%% |\n" \
$failedassertions $assertions $pcnt
else
printf "# | (S7) ASSERTION | %8d | %8d | %7d%% |\n" \
$failedassertions $assertions $pcnt >> $outfile
fi
output "# +-----------------------+----------+----------+----------+"
output
output "## Warnings = 0"
output "## Assertions = "$assertions
output "## FailedAssertions = "$failedassertions
output

882
extern/stdcxx/4.2.1/etc/config/runall.sh vendored Normal file
View File

@@ -0,0 +1,882 @@
#!/bin/sh
# $Id: runall.sh 580483 2007-09-28 20:55:52Z sebor $
#
##############################################################################
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Copyright 1999-2007 Rogue Wave Software, Inc.
#
##############################################################################
#
# NAME
# runall.sh, run - run programs and analyze output
#
# SYNOPSIS
# runall.sh [option(s)...] [file(s)...]
#
# DESCRIPTION
# Takes a list of files as arguments. The files are assumed to be
# executable; if a file isn't executable, it is assumed to have a
# .o suffix, in which case it is considered as an object file and
# its existence is taken as success. If the file isn't executable
# and doesn't have a .o suffix, it is considered a failure.
#
# Runs all executables named on the command line giving each a
# fixed amount of time to complete. If the program fails to exit
# within the alotted amount of time, it is killed via a
# signal. Collects and reports statistics on each executable with
# the -p option tries to post a result file into a revison control
# system (Perforce).
#
# OPTIONS
# -a <age>
# Do not run programs, just collect output unless output
# file is older than `age' minutes.
#
# -c or --color
# Produce colorized output (default). Requires xterm.
#
# -d <text>
# Use `text' as a description when submitting a
# report. If `text' is an existing file, use the contents
# of the file as the description. Meaningful only with -p.
#
# -l <fname> or --log <fname>
# Append the file named `fname' to the end of the result
# file before posting. Meaningful only with -p.
#
# --label <name>
# Label files with the label `name', or generate own label
# name if "--label -". The generated label will have the
# following format: stdlib-<compiler>-<os>-<timestamp>.
# Meaningful only with -p.
#
# -m or --mono or --nocolor
# Produce monochrome output (no escape sequences). Default
# for all terminals other than xterm.
#
# -o <fname>
# Redirect process output to the named file. The option
# affects only the next executable to be run, it is reset
# for all others.
#
# -p <postdir>
# Run tests and examples and post results in a revision
# control system (Perforce by default).
#
# --ph Run plumhall LVS tests
#
# --rate <percent>
# Minimum pass rate (in percent) to post. If the pass rate
# is lower, send email to $P4USER notifying that post
# failed. Meaningful only with -p.
#
# -r <fname>
# Compare results against `fname' and report differences as
# regressions.
#
# -s <signo>
# Set the signal to be sent to the hung process. SIGKILL
# (signo 9) is default.
#
# -t <sec>
# Set process timeout to `sec' seconds. Negative value of
# `sec' allows an infinite timeout.
#
# -T <ts0,ts1,ts2>
# Specifies the timestamps corresponding to the local times
# at which the following events started: configuration, lib
# build, and tests (and examples) build, in that order.
# Meaningful only with -p.
#
# -X <text>
# Specifies additional command line options to be passed to
# the executable being run.
#
# -x <dir>
# Run subsequent filenames as examples and diff output
# against files in the respective subdirectories of `dir'
# (manual/ or tutorial/), if they exist.
#
##############################################################################
##############################################################################
# GLOBAL VARIABLES
##############################################################################
TIMEOUT=10 # seconds by default
SIGNO=9 # signal to be sent by default (SIGKILL by default)
REGRESS="." # regression file (cwd by default, ignored)
LINES=24 # default number of continuous lines
MANDIR="-" # directory containing manual (none by default)
MIN_PASS_RATE=70 # minimum acceptable pass rate
POSTFILE="." # posted results file name
POSTDESC="test results" # description used when posting
LABEL="-" # generate a label when posting
OUTFILE="." # default output file name
AGEMAX=0 # if non-zero will not run tests, just looks at
# test results not older than AGEMAX minutes
XOPTS="-D ." # additional options to be passed to executable
BUILDLOG=/dev/null # log to append to results when posting
TIMESTAMPS="-" # times when lib and tests builds started
case "`uname`" in
CYGWIN*)
DIFF_STRIP_CR="--strip-trailing-cr";; # strip trailing CR on CygWin
esac
##############################################################################
# FUNCTION DEFINITIONS
##############################################################################
setcolors ()
{
COLORS=$1
if [ $COLORS -ne 0 ] ; then
ESC0="" # escape sequence turning off any formatting
CLR_BLACK=""
CLR_RED=""
CLR_GREEN=""
CLR_BLUE=""
CLR_YELLOW=""
CLR_MAGENTA=""
CLR_CYAN=""
CLR_GRAY=""
CLR_ERROR="" # serious error (core dump, etc)
CLR_SUCCESS="" # important improvement (e.g., regress < 0)
CLR_WARN="" # potential problem (decrease in assertins)
else
unset ESC0
unset CLR_BLACK
unset CLR_RED
unset CLR_GREEN
unset CLR_BLUE
unset CLR_YELLOW
unset CLR_CYAN
unset CLR_GRAY
unset CLR_ERROR
unset CLR_SUCCESS
unset CLR_WARN
fi
}
# post results in Perforce
post_results ()
{
p4 opened 2>&1 | grep "File(s) not opened on this client."
if [ $? -ne 0 ] ; then
echo "Warning: files opened on $P4CLIENT."
# exit 1
fi
# create a label containing all files in our client view
if [ "$LABEL" ] ; then
[ "$LABEL" = "-" ] && LABEL="stdlib-$POSTFILE-`date +%m.%d.%y-%H:%M`"
( echo Label: $LABEL ;
echo View: ;
p4 client -o | sed -n "s:\(//.*\) //.*:\1:p" ) | p4 label -i
fi
# see if we can check the file out
P4PATH=`p4 edit $POSTDIR/$POSTFILE 2>&1`
echo $P4PATH | grep " - file(s) not on client." > /dev/null 2>&1
# add the file if it is not in p4
[ $? -eq 0 ] && P4PATH=`p4 add $POSTDIR/$POSTFILE`
[ ! -x "$POSTDIR" ] && echo "$POSTDIR doesn't exist, can't post"
# copy postfile (and a log, if any) where it can be checked in from
cat $POSTFILE $BUILDLOG > $POSTDIR/$POSTFILE
# remove junk p4 appends to the end of file names
P4PATH=`echo $P4PATH | sed "s/#[1-9][0-9]* - .*$//"`
echo "executing: p4 submit -i $P4PATH"
# submit into Perforce
cat << EOF | p4 submit -i $P4PATH
Change: new
Description:
`cat /tmp/summary-$$`
Files: $P4PATH
EOF
# clean up
rm /tmp/summary-$$
}
# send mail with postfile (containing summary info) to p4 user
send_mail ()
{
# check for mailx to use -s subject
if type mailx > /dev/null 2>&1 ; then
mailcmd=mailx -s "could not post $POSTFILE"
elif [ `uname` = Linux ] ; then
# mail on Linux understands -s
mailcmd=mail -s "could not post $POSTFILE"
else
mailcmd=mail
fi
email=`p4 user -o | sed -n "s/^Email:.\(.*\)/\1/p"`
cat $POSTFILE | $mailcmd $email
}
# format a line on output
# $1: STATUS, $2: ASSRTS, $3 HIGH, $4 DELTA, $5 FAILED, $6 LOW,
# $7: REGRESS, $8: PERCNT
format ()
{
if [ $4 -ne 0 ] ; then
ESC2="$CLR_BLACK"
ESC4="$ESC2"
fi
# colorize regression field (numeric $1 okay, non-numeric considered error)
if [ $7 -gt 0 ] || [ `expr $1 + 0 >/dev/null 2>&1; echo $?` -eq 2 ] ; then
ESC7="$CLR_ERROR"
elif [ $7 -lt 0 ] ; then
ESC7="$CLR_SUCCESS"
fi
printf "$ESC1" >&2 ; printf " %6.6s" $1 ; printf "$ESC0" >&2
# skip negative value (indicates that values don't make sense)
if [ $2 -ge 0 ] ; then
printf "$ESC2" >&2 ; printf " %6d" $2 ; printf "$ESC0" >&2
printf "$ESC3" >&2 ; printf " %6d" $3 ; printf "$ESC0" >&2
printf "$ESC4" >&2 ; printf " %6d" $4 ; printf "$ESC0" >&2
printf "$ESC5" >&2 ; printf " %6d" $5 ; printf "$ESC0" >&2
printf "$ESC6" >&2 ; printf " %6d" $6 ; printf "$ESC0" >&2
printf "$ESC7" >&2 ; printf " %6d" $7 ; printf "$ESC0" >&2
printf "$ESC8" >&2 ; printf " %5d%%" $8 ; printf "$ESC0" >&2
printf "$ESC0" >&2
fi
echo
}
# get signal name from signal number (first argument)
signame ()
{
n=`expr \( \( $1 - 1 \) % 4 + 1 \) \* 2`
n=`kill -l | grep ".$1)" | head -1 | awk "{ print $"$n" }" | sed "s/SIG//"`
[ "$n" = "" ] && n="SIG$1"
echo $n
}
# compmute the elapsed time between adjacent arguments, each of which is
# expected to be in date +%T format, result is sent to stdout in +%T format
elapsed_time ()
{
first=$1
t0=`echo $1 | awk 'BEGIN { FS=":" } { print $1 * 3600 + $2 * 60 + $3 }'`
shift
for t in $* ; do
t1=`echo $t | awk 'BEGIN { FS=":" } { print $1 * 3600 + $2 * 60 + $3 }'`
[ $t1 -lt $t0 ] && t1=`expr $t1 + 24 \* 60 \* 60`
hrs=`expr \( $t1 - $t0 \) / 3600`
if [ $hrs -gt 0 ] ; then
printf "%d:%02d:%02d " $hrs \
`expr \( \( $t1 - $t0 \) % 3600 \) / 60` \
`expr \( $t1 - $t0 \) % 60`
else
printf "%d:%02d " `expr \( \( $t1 - $t0 \) % 3600 \) / 60` \
`expr \( $t1 - $t0 \) % 60`
fi
t0=$t1
done
# compute the difference between the first and the last args
[ $# -gt 2 ] && elapsed_time $first $t
}
fmat_diff ()
{
# search file for the first occurrence of a number followed by
# the string in $2; keep number and exit immediately to save time
d=`sed -n "/$2/{s/[^0-9]*\([1-9][0-9]*\).*$2.*/\1/p;q
}" $REGRESS`
if [ "$d" != "" ] ; then
d=`expr $1 - $d`
# output only if difference is non-zero
[ $d -ne 0 ] && printf "(%+d) " $d
fi
unset d
}
##############################################################################
# MAIN LOOP
##############################################################################
# ensure consistent behavior of POSIX utilities such as grep and sed
LANG=POSIX
# show help and exit when invoked with no arguments
if [ $# -eq 0 ] ; then
# print out top of this file (between the ###-lines)
# sed expression split up to satisfy non-GNU sed
sed -n "/^###/!D; {: print
n; /^###/q; s/^#//p; t print
}" $0
exit 0
fi
# reset the terminal settings on exit
trap 'printf "$ESC0" >&2 && exit' 0 2 3 15
SIGNAME=`signame $SIGNO`
HEADER="NAME STATUS ASSRTS HIGH DELTA FAILED LOW RGRESS PERCNT"
# write out our command line - uncomment for debugging
# echo $0 $*
tst_count=0 # number of tests tried
tst_pass=0 # number of successfully run tests (perhaps with assertions)
tst_ncomp=0 # number of tests that failed to compile
tst_nlink=0 # number of tests that failed to link
tst_fail=0 # number of tests run to completion but with failures
tst_core=0 # number of tests that dumped core
tst_kill=0 # number of tests that were forcefully killed
tst_rgrs=0 # number of tests with regressions
asrt_count=0 # total number of assertions
asrt_dlta=0 # increase in assertions from last run
asrt_pass=0 # total number of passed assertions
asrt_fail=0 # total number of failed assertions
asrt_rgrs=0 # increase in failed assertions from last run
asrt_hi=0 # the total highest number of failed assertions ever
asrt_lo=0 # the total lowest number of failed assertions ever
t0=`date +%T` # timestamp
# get $LINES and $COLUMNS set if possible
type resize > /dev/null 2>&1 && eval `resize` 2>&1 > /dev/null
[ -z "$LINES" ] && LINES=40
[ -z "$COLUMNS" ] && COLUMNS=80
if [ "$TERM" = "xterm" ] ;then
setcolors 1 # turn on colorized output
else
setcolors 0 # disable colorization
fi
for i do
# process command line options
# avoid the unportable [ ! "$foo" ]
if [ "" = "$AGEMAX" ] ; then
AGEMAX=$i
continue
elif [ "$i" = "-a" ] ; then
unset AGEMAX
continue
elif [ "" = "$POSTDESC" ] ; then
POSTDESC="$i"
continue
elif [ "$i" = "-d" ] ; then
unset POSTDESC
continue
elif [ "$i" = "-m" ] || [ "$i" = "--mono" ] || [ "$i" = "--nocolor" ]; then
setcolors 0
continue
elif [ "$i" = "-c" ] || [ "$i" = "--color" ] ; then
setcolors 1
continue
elif [ "" = "$BUILDLOG" ] ; then
BUILDLOG=$i
continue
elif [ "$i" = "-l" ] || [ "$i" = "--log" ]; then
unset BUILDLOG
continue
elif [ "" = "$LABEL" ] ; then
LABEL=$i
continue
elif [ "$i" = "--label" ] ; then
unset LABEL
continue
elif [ "" = "$REGRESS" ] ; then
REGRESS=$i
continue
elif [ "$i" = "-r" ] ; then
unset REGRESS
continue
elif [ "" = "$MIN_PASS_RATE" ] ; then
MIN_PASS_RATE=$i
continue
elif [ "$i" = "--rate" ] ; then
unset MIN_PASS_RATE
continue
elif [ "" = "$TIMEOUT" ] ; then
TIMEOUT=$i
continue
elif [ "$i" = "-t" ] ; then
unset TIMEOUT
continue;
elif [ "" = "$TIMESTAMPS" ] ; then
TIMESTAMPS=$i
continue
elif [ "$i" = "-T" ] ; then
unset TIMESTAMPS
continue;
elif [ "" = "$SIGNO" ] ; then
SIGNO=$i
SIGNAME=`signame $SIGNO`
continue
elif [ "$i" = "-s" ] ; then
unset SIGNO
continue
elif [ "" = "$MANDIR" ] ; then
MANDIR=$i/manual
TUTDIR=$i/tutorial
continue
elif [ "" = "$XOPTS" ] ; then
XOPTS="$i"
continue
elif [ "$i" = "-X" ] ; then
unset XOPTS
continue
elif [ "$i" = "-x" ] ; then
unset MANDIR
continue
elif [ "$i" = "--ph" ] ; then
PLUMHALL=1
MANDIR='-' # indicates we're running tests
continue
elif [ "" = "$POSTFILE" ] ; then
POSTDIR=`dirname $i`
POSTFILE=`basename $i`
continue
elif [ "$i" = "-p" ] ; then
unset POSTFILE
continue
elif [ "" = "$OUTFILE" ] ; then
OUTFILE=$i
continue
elif [ "$i" = "-o" ] ; then
unset OUTFILE
continue
fi;
n_asrt=0 # number of assertions in this test
d_asrt=0 # increase in assertions from last run
p_asrt=0 # passed assertions in this test
f_asrt=0 # failed assertions in this test
r_asrt=0 # number of regressions
h_asrt=0 # the highest number of assertions ever tested
l_asrt=0 # the least number of assertions ever tested
pcnt_asrt=0 # percentage of passed assertions in this test
no_asserts=0 # non-zero if output doesn't contain assertion tags
exit_status=0 # successful exit status by default (will be overridden)
ESC1="$ESC0" ; ESC2="$ESC0" ; ESC3="$ESC0" ; ESC4="$ESC0"
ESC5="$ESC0" ; ESC6="$ESC0" ; ESC7="$ESC0" ; ESC8="$ESC0"
if [ `expr $tst_count % $LINES` -eq 0 ] ; then
# redirect test number to stderr in order not to mess up diff
echo ; printf "$CLR_BLACK" >&2 ; printf "%s" "--- " >&2
echo "$HEADER" ; printf "$ESC0" >&2
fi
tst_count=`expr $tst_count + 1`
printf "%3d " $tst_count 1>&2
# strip trailing `.sh' from filename if present
file=`basename $i | sed "s/\.sh//"`
printf "%-18.18s" $file
# if an executable file exists _or_ if AGEMAX is not 0
if [ -x "$i" ] || [ $AGEMAX -ne 0 ] ; then
# get the name of input file if any (/dev/null by default)
if [ -f $MANDIR/in/$file.in ] ; then
input=$MANDIR/in/$file.in
elif [ -f $TUTDIR/in/$file.in ] ; then
input=$TUTDIR/in/$file.in
else
input=/dev/null
fi
if [ "$OUTFILE" = "." ] ; then
output="$i.out"
else
output=$OUTFILE
fi
if [ $AGEMAX -eq 0 ] ; then
# save cursor position in case the shell (bash 2 on SunOS)
# reports when a process gets a signal despite redirection
[ "$COLORS" != "0" ] && printf "7" >&2
# set alarm in process (in case we can't kill it if it hangs)
alrm=`expr $TIMEOUT + 3`
# run test in the background, redirect I/O to a file
# stderr redirected to /dev/null to prevent compilation
# warnings in "script" mode from causing false errors
$i $XOPTS -O $output -L $alrm -M "`uname -a`" \
> $output < $input 2>/dev/null &
# get the background process' pid
testpid=$!
# start a subshell to kill hung process
if [ $TIMEOUT -ge 0 ] ; then
(t=$TIMEOUT
while [ $t -ne 0 ]; do
# exit right away if process doesn't exist
ps -p $testpid > /dev/null 2>&1 || exit 0
# show countdown if colorized
[ "$COLORS" != "0" ] \
&& printf "$CLR_WARN %6d$ESC0" $t >&2
t=`expr $t - 1`
sleep 1
done
kill -s $SIGNO $testpid > /dev/null 2>&1
)&
fi
# we'll test for this later
kill_status=`expr 128 + $SIGNO`
# wait for test to exit (on its own or forcefully)
wait $testpid
exit_status=$?
# restore cursor position
[ "$COLORS" != "0" ] && printf "8" >&2
else
# set kill status to be different than exit_status
kill_status=1
found=`find ./$output -mmin -$AGEMAX`
if [ "" = "$found" ] ; then
exit_status=-1
else
# indicate that output file was stale (older than AGEMAX)
exit_status=0
fi
fi
if [ $exit_status -lt 126 ] && [ "$PLUMHALL" ]; then
exit_status=0 #plum hall exit status is number of failed tests
fi
if [ $exit_status -eq 0 ]; then
if [ "$MANDIR" = "-" ] ; then # running tests
# make sure output file exists
if [ -f "$output" ] ; then
tst_pass=`expr $tst_pass + 1`
# grep for the number of total and failed assertions
if [ "$PLUMHALL" ]; then
f_asrt=`grep "errors detected" $output \
| sed "s/\*\*\*\*\* \([0-9]*\) .*/\1/"`
n_success=`grep "successful test case" $output \
| sed "s/\*\*\*\*\* \([0-9]*\) .*/\1/"`
if [ "$f_asrt" ] && [ "$n_success" ]; then
n_asrt=`expr $n_success + $f_asrt`
fi
else
n_asrt=`sed "s/[^ -~]/ /g" $output \
| grep "## Assertions" \
| tail -1 | sed "s/[^0-9]//g"`
f_asrt=`sed "s/[^ -~]/ /g" $output \
| grep "## FailedAssertions" \
| tail -1 | sed "s/[^0-9]//g"`
fi
if [ "" = "$n_asrt" ] ; then
n_asrt=0
no_assert=1
# no regression line found, something's fishy
exit_status="FORMAT" ; ESC1="$CLR_WARN"
fi
[ "" = "$f_asrt" ] && f_asrt=0
# increment the number of tests not passing at 100%
[ $f_asrt -gt 0 ] && tst_fail=`expr $tst_fail + 1`
# compute percentage of passed assertions
p_asrt=`expr $n_asrt - $f_asrt`
asrt_count=`expr $asrt_count + $n_asrt`
asrt_pass=`expr $asrt_pass + $p_asrt`
asrt_fail=`expr $asrt_fail + $f_asrt`
[ $f_asrt -gt 0 ] && ESC5="$CLR_RED"
# prevent division by zero
[ $n_asrt -ne 0 ] \
&& pcnt_asrt=`expr 100 \* $p_asrt / $n_asrt`
else # output file not found
exit_status="OUTPUT" ; ESC1="$CLR_ERROR"
fi
else # running examples (expect output)
no_asserts=1
# get the name of file against which to diff the output
if [ -f $MANDIR/out/$file.out ] ; then
diff_file=$MANDIR/out/$file.out
elif [ -f $TUTDIR/out/$file.out ] ; then
diff_file=$TUTDIR/out/$file.out
else
unset diff_file
fi
if [ "$diff_file" != "" ] ; then
diff $DIFF_STRIP_CR $diff_file $output >/dev/null 2>&1
if [ $? -eq 0 ] ; then
tst_pass=`expr $tst_pass + 1`
else
exit_status="DIFF" ; ESC1="$CLR_ERROR"
fi
else
exit_status="OUTPUT" ; ESC1="$CLR_WARN"
tst_pass=`expr $tst_pass + 1`
fi
ESC2="$ESC0" ; ESC3="$ESC2" ; ESC4="$ESC2" ; ESC5="$ESC2"
ESC6="$ESC2" ; ESC7="$ESC2" ; ESC8="$ESC2"
fi
elif [ $exit_status -eq 126 ] ; then
exit_status="EXIST" # can't find executable
ESC1="$CLR_WARN"
elif [ $exit_status -eq 127 ] ; then
exit_status="EXEC" # can't execute (check LD_LIBRARY_PATH)
ESC1="$CLR_WARN"
elif [ $exit_status -eq $kill_status ] ; then
exit_status=`signame $SIGNO` # forcefully killed
ESC1="$CLR_ERROR"
tst_kill=`expr $tst_kill + 1`
elif [ $exit_status -ge 128 ] ; then
n=`expr $exit_status - 128`
exit_status=`signame $n`
ESC1="$CLR_ERROR"
tst_core=`expr $tst_core + 1`
elif [ $exit_status -eq -1 ] ; then
exit_status="STALE"
ESC1="$CLR_WARN"
else
ESC1="$CLR_WARN"
fi
elif [ -f $i.o ] ; then
exit_status="LINK" # .o exists but no executable, failed to link
ESC1="$CLR_ERROR"
tst_nlink=`expr $tst_nlink + 1`
else
# file isn't executable, see if it's an object file...
suffix=`echo $i | sed "s/.*\(\..*\)/\1/"`
if [ "$suffix" = ".o" ] && [ -f "$i" ] ; then
no_asserts=1
tst_pass=`expr $tst_pass + 1`
else
exit_status="COMP" # no .o, failed to compile
ESC1="$CLR_ERROR"
tst_ncomp=`expr $tst_ncomp + 1`
fi
fi
if [ -f "$REGRESS" ] ; then
# find line for same executable in a previous report file
line=`grep "^$file[ .] " $REGRESS | head -n 1`
# compute difference in tried assertions
d_asrt=`echo $line | awk '{ print $3 }'`
d_asrt=`expr $n_asrt - 0$d_asrt`
# only consider if current exit status is 0 (success)
if [ "$exit_status" = "0" ] ; then
# regressions make sense only if previous exit status was 0
if [ "`echo $line | awk '{ print $2 }'`" = "0" ] ; then
r_asrt=`echo $line | awk '{ print $6 }'`
r_asrt=`expr $f_asrt - 0$r_asrt`
fi
# see if the lowest number of failed assertions improved
l_asrt=`echo $line | awk '{ print $7 }'`
[ "" = "$l_asrt" ] && l_asrt=0
[ $l_asrt -gt $f_asrt ] && l_asrt=$f_asrt && ESC6="$CLR_SUCCESS"
else
# carry over previous low assertions on failure
l_asrt=`echo $line | awk '{ print $7 }'`
[ "" = "$l_asrt" ] && l_asrt=0
# count the test as regressing if the last exit status was 0
old_status=`echo $line | awk '{ print $2 }'`
[ "$old_status" = "0" ] && tst_rgrs=`expr $tst_rgrs + 1`
fi
# adjust highest number of assertions achieved
h_asrt=`echo $line | awk '{ print $4 }'`
[ "" = "$h_asrt" ] && h_asrt=0
[ $h_asrt -lt $n_asrt ] && h_asrt=$n_asrt && ESC3="$CLR_BLACK"
# increment cumulative totals
asrt_dlta=`expr $asrt_dlta + $d_asrt`
asrt_rgrs=`expr $asrt_rgrs + $r_asrt`
[ $r_asrt -gt 0 ] && tst_rgrs=`expr $tst_rgrs + 1`
else
l_asrt=$f_asrt
h_asrt=$n_asrt
fi
# get rid of leading zeros (to prevent octal conversion by printf)
l_asrt=`expr $l_asrt + 0`
asrt_hi=`expr $h_asrt + $asrt_hi`
asrt_lo=`expr $l_asrt + $asrt_lo`
# set number of assertions negative if assertion tags not found
[ $no_asserts -ne 0 ] && n_asrt=-1
# careful with leading zeros (interpreted as octal with %d)
format $exit_status $n_asrt $h_asrt $d_asrt \
$f_asrt $l_asrt $r_asrt $pcnt_asrt
# reset name of output file
OUTFILE="."
done
# compute pass rate as percentage of tests with perfect score
# out of the total number of tests tried
pass_rate=0
[ $tst_count -gt 0 ] && pass_rate=`expr \( 100 \* \( $tst_pass - $tst_fail \) \) / $tst_count`
if [ $tst_count -gt 1 ] ; then
[ $asrt_count -ne 0 ] && pcnt_asrt=`expr 100 \* $asrt_pass / $asrt_count`
# show cumulative results
printf "\n--- " 1>&2
printf "%-18.18s" ""
ESC1="" ; ESC2="" ; ESC3="" ; ESC4=""
ESC5="" ; ESC6="" ; ESC7="" ; ESC8=""
# careful with leading zeros (interpreted as octal with %d)
format $tst_pass $asrt_count $asrt_hi $asrt_dlta \
$asrt_fail $asrt_lo $asrt_rgrs $pcnt_asrt
echo ; printf "${CLR_BLACK} " >&2
echo " FAIL COMP LINK ASSERT CORE KILL RGRESS";
printf "$ESC0 " >&2
printf " %6d %6d %6d %6d %6d %6d %6d\n" \
`expr $tst_count - $tst_pass` \
$tst_ncomp $tst_nlink $tst_fail $tst_core $tst_kill $tst_rgrs
echo
if [ -f "$REGRESS" ] ; then
# compute and format summary regressions wrt the previous report
# each var will be empty when there's no change, else "(+/-N) "
d_count=`fmat_diff $tst_count "programs"`
d_ncomp=`fmat_diff $tst_ncomp "failed to compile"`
d_nlink=`fmat_diff $tst_nlink "failed to link"`
d_fail=`fmat_diff $tst_fail "failed at least one assertion"`
d_core=`fmat_diff $tst_core "exited with a signal"`
d_kill=`fmat_diff $tst_kill "killed with signal"`
d_rate=`fmat_diff $pass_rate "pass rate"`
# special treatment (no variable $tst_nzero exists)
d_nzero=`expr $tst_count - $tst_pass`
d_nzero=`fmat_diff $d_nzero "exited with non-zero status"`
if [ -f "$POSTFILE" ] ; then
# modify REGRESS to be the p4 path name and rev # of what
# regressions are being reported against (used in description)
tmp=`p4 have $REGRESS | sed "s/ - .*//" 2>/dev/null`
[ $? -eq 0 ] && REGRESS="$tmp"
fi
regress_line="$asrt_rgrs regressions (baseline was $REGRESS)"
else
regress_line="no regressions (this is baseline)"
fi
# present summary only for more files than fits on screen or when posting
if [ $tst_count -ge $LINES -o -f "$POSTFILE" ] ; then
# compute and format timestamps
if [ "$TIMESTAMPS" != "-" ] ; then
# expect: "h0:m0:s0,h1:m1:s1,h2:m2:s2"
TIMESTAMPS="$TIMESTAMPS $t0 `date +%T`"
# replace commas with spaces
TIMESTAMPS=`echo $TIMESTAMPS | sed "s/,/ /g"`
TIMESTAMPS=`elapsed_time $TIMESTAMPS | awk '{ print \
"cfg: " $1 " lib: " $2 " tst: " $3 " run: " $4 " all: " $5 }'`
fi
# create a file containing summary info about this run
cat << EOF | tee /tmp/summary-$$
Generated by $LOGNAME@`uname -n` running `uname -sr`
`if [ -f "$POSTDESC" ]; then cat "$POSTDESC" ; else echo $POSTDESC; fi`
`[ "$TIMESTAMPS" != "-" ] && echo "Times: $TIMESTAMPS"`
Summary: out of $tst_count ${d_count}programs
`expr $tst_count - $tst_pass` ${d_nzero}exited with non-zero status
$tst_ncomp ${d_ncomp}failed to compile
$tst_nlink ${d_nlink}failed to link
$tst_fail ${d_fail}failed at least one assertion
$tst_core ${d_core}exited with a signal
$tst_kill ${d_kill}killed with signal $SIGNO
$regress_line
$pass_rate% ${d_rate}pass rate
EOF
fi
else
echo
fi
# post results in revision control system
if [ -f "$POSTFILE" ] ; then
# make sure minimum pass rate is achieved
if [ $pass_rate -lt $MIN_PASS_RATE ] ; then
# send email to p4 user if not passing at a desired rate
send_mail
echo "pass rate < $MIN_PASS_RATE%, can't post"
elif [ "$P4CLIENT" != "" ] ; then
# post results in Perforce
post_results
else
send_mail
echo "P4CLIENT not defined, can't post"
fi
elif [ "$POSTFILE" != "." ] ; then
echo "$POSTFILE not found, can't post"
exit 1
fi

View File

@@ -0,0 +1,85 @@
// checking for overloads of abs()
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// determine whether the abs() function (including
// any overloads) is defined in the usual libc headers
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#ifndef _RWSTD_NO_LONG_LONG
# if defined _MSC_VER
# define LONG_LONG __int64
# else
# define LONG_LONG long long
# endif
#endif // _RWSTD_NO_LONG_LONG
int template_used;
template <class T>
T abs (T t)
{
++template_used;
return t;
}
template <class T>
void check_abs (T t, const char *tname)
{
template_used = 0;
abs (t);
if (0 == template_used)
printf ("%s", "// ");
printf ("#define _RWSTD_NO_ABS_%s\n", tname);
}
int main ()
{
check_abs ((bool)0, "BOOL");
check_abs ((char)0, "CHAR");
check_abs ((signed char)0, "SCHAR");
check_abs ((unsigned char)0, "UCHAR");
check_abs ((short)0, "SHRT");
check_abs ((unsigned short)0, "USHRT");
check_abs ((int)0, "INT");
check_abs ((unsigned)0, "UINT");
check_abs ((long)0, "LONG");
check_abs ((unsigned long)0, "ULONG");
#if defined (LONG_LONG)
check_abs ((LONG_LONG)0, "LLONG");
check_abs ((unsigned LONG_LONG)0, "ULLONG");
#endif // LONG_LONG
return 0;
}

View File

@@ -0,0 +1,500 @@
// checking for bad_alloc assignment operator
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// NOTE: this file is #included from the following tests,
// each of which #defines bad_alloc to the name of
// the corresponding exception class, and exercises
// the respective class members
//
// BAD_ALLOC_COPY_CTOR.cpp
// BAD_ALLOC_DEFAULT_CTOR.cpp
// BAD_ALLOC_DTOR.cpp
// BAD_CAST_ASSIGNMENT.cpp
// BAD_CAST_COPY_CTOR.cpp
// BAD_CAST_DEFAULT_CTOR.cpp
// BAD_CAST_DTOR.cpp
// BAD_EXCEPTION_ASSIGNMENT.cpp
// BAD_EXCEPTION_COPY_CTOR.cpp
// BAD_EXCEPTION_DEFAULT_CTOR.cpp
// BAD_EXCEPTION_DTOR.cpp
// BAD_TYPEID_ASSIGNMENT.cpp
// BAD_TYPEID_COPY_CTOR.cpp
// BAD_TYPEID_DEFAULT_CTOR.cpp
// BAD_TYPEID_DTOR.cpp
// EXCEPTION_ASSIGNMENT.cpp
// EXCEPTION_COPY_CTOR.cpp
// EXCEPTION_DEFAULT_CTOR.cpp
// EXCEPTION_DTOR.cpp
#include "config.h"
#if 2 == __GNUG__
# ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
# endif // _RWSTD_NO_HONOR_STD
#endif // gcc 2.x
#ifndef _RWSTD_NO_RUNTIME_IN_STD
# define NAMESPACE(name) namespace name
#else
# define NAMESPACE(ignore) extern "C++"
# define std /* empty */
#endif // _RWSTD_NO_RUNTIME_IN_STD
int ndefault_ctors;
int ncopy_ctors;
int ndtors;
int nassignments;
NAMESPACE (std) {
class bad_alloc
{
public:
const void *what_;
#if defined (TEST_DEFAULT_CTOR)
bad_alloc ();
#else // if !defined (TEST_DEFAULT_CTOR)
// provide a default ctor but with a different signature
// than the one above to prevent multiply defined symbol
// linker errors in case that one is defined in the
// runtime library
bad_alloc (int = 0) { }
# if defined (TEST_DTOR)
virtual ~bad_alloc ();
# elif defined (TEST_COPY_CTOR)
bad_alloc (const bad_alloc&);
# elif defined (TEST_WHAT)
virtual const char* what () const;
# else // test assignment
# if !defined (TEST_ASSIGNMENT)
# define TEST_ASSIGNMENT
# endif
bad_alloc& operator= (const bad_alloc&);
bad_alloc& assign (const bad_alloc &rhs) {
++nassignments;
return *this = rhs;
}
# endif // TEST_...
#endif // !TEST_DEFAULT_CTOR
};
} // namespace std
// use virtual inheritance here to prevent aggressive optimizers
// (like VisualAge C++) from optimizing the base class dtor away
struct Base0: virtual std::bad_alloc
{
int index0;
typedef std::bad_alloc Base;
Base0 ();
Base0 (const Base0&);
virtual ~Base0 ();
Base0& operator= (const Base0&);
virtual const char* what () const;
};
struct Base1: virtual std::bad_alloc
{
int index1;
typedef std::bad_alloc Base;
Base1 ();
Base1 (const Base1&);
virtual ~Base1 ();
Base1& operator= (const Base1&);
virtual const char* what () const;
};
int which_what;
struct Derived: Base0, Base1
{
typedef std::bad_alloc Base;
Derived ();
Derived (const Derived&);
virtual ~Derived ();
Derived& operator= (const Derived&);
virtual const char* what () const;
};
#if defined (TEST_COPY_CTOR) ///////////////////////////////////////
int test_member (int argc, void *ptr)
{
// the code below must not be executed
# ifndef _RWSTD_NO_EXCEPTIONS
try {
try {
if (1 < argc) {
// jump through hoops to try to foil
// even the most aggressive optimizers
Derived *pd = (Derived*)ptr;
Base0 *pb0 = (Derived*)ptr + argc;
Base1 *pb1 = (Derived*)ptr + argc + 1;
std::bad_alloc *pba = (Derived*)ptr + argc + 2;
if (argc < 6)
throw *pd;
if (argc < 7)
throw *pb0;
if (argc < 8)
throw *pb1;
if (argc < 9)
throw *pba;
}
}
catch (Derived e) {
e.index0 = e.index1 = __LINE__;
throw e;
}
catch (Base0 b0) {
b0.index0 = __LINE__;
throw b0;
}
catch (Base1 b1) {
b1.index1 = __LINE__;
throw b1;
}
catch (std::bad_alloc e) {
std::bad_alloc copy (e);
if (argc < 5)
throw copy;
if (argc < 4)
throw e;
if (argc < 3)
throw;
}
}
catch (std::bad_alloc e) {
return 0 != e.what_;
}
catch (...) {
return 2;
}
return 3;
# else // if defined (_RWSTD_NO_EXCEPTIONS)
std::bad_alloc *pe = (std::bad_alloc*)ptr;
std::bad_alloc *pf = new std::bad_alloc (*pe);
return !(1 == ndefault_ctors && 1 == ncopy_ctors && pe->what_ == pf->what_);
# endif // _RWSTD_NO_EXCEPTIONS
}
#elif defined (TEST_DEFAULT_CTOR) //////////////////////////////////
int test_member (int, void*)
{
// the code below must not be executed
std::bad_alloc *pe1 = new std::bad_alloc;
std::bad_alloc *pe2 = new Derived;
return pe1 < pe2;
}
#elif defined (TEST_DTOR) //////////////////////////////////////////
int test_member (int argc, void *ptr)
{
// the code below must not be executed
std::bad_alloc *pe;
if (1 < argc)
pe = (Derived*)ptr;
else
pe = (std::bad_alloc*)ptr;
delete pe;
return !(1 < argc ? 1 == ndtors : 0 == ndtors);
}
#elif defined (TEST_WHAT) //////////////////////////////////////////
int test_member (int argc, void *ptr)
{
// the code below must not be executed
std::bad_alloc *pe = (std::bad_alloc*)ptr;
Derived *pd = (Derived*)ptr + 1;
which_what = argc;
return pe [0].what () == pd [argc].what ();
}
#else // test assignment /////////////////////////////////////////
int test_member (int argc, void *ptr)
{
// the code below must not be executed
std::bad_alloc *pe = (Derived*)ptr;
std::bad_alloc& (std::bad_alloc::*pf)(const std::bad_alloc&) =
argc < 3 ? &std::bad_alloc::operator= : &std::bad_alloc::assign;
which_what = argc;
pe [argc] = pe [argc + 1];
(pe [argc + 1].*pf)(pe [argc + 2]);
return pe [0].what_ == pe [1].what_ || 2 < nassignments;
}
#endif // TEST_... ///////////////////////////////////////////////
int main (int argc, char *argv[])
{
(void)&argv;
(void)&nassignments;
(void)&ncopy_ctors;
(void)&ndefault_ctors;
// avoid executing the body of main unless explicitly requested
// by specifying at least one command line argument (this foils
// aggressive optimizers from eliminating the code)
if (argc < 2)
return 0;
return test_member (argc, argv);
}
Base0::Base0 (): Base (), index0 (++ndefault_ctors) { }
Base0::Base0 (const Base0 &rhs)
#if defined (TEST_COPY_CTOR)
: Base (rhs),
#else // if defined (TEST_COPY_CTOR)
: Base (),
#endif // TEST_COPY_CTOR
index0 (rhs.index0)
{
(void)&rhs; // silence unused argument warnings
++ncopy_ctors;
}
Base0::~Base0 ()
{
++ndtors;
index0 = 0;
}
Base0& Base0::operator=(const Base0 &rhs)
{
++nassignments;
index0 = rhs.index0;
#if defined (TEST_ASSIGNMENT)
Base::operator= (rhs);
#endif // TEST_ASSIGNMENT
return *this;
}
const char* Base0::what () const
{
#if defined (TEST_WHAT)
if (1 < which_what++)
return Base::what ();
#endif // TEST_WHAT
return "Base0";
}
Base1::Base1 (): Base (), index1 (++ndefault_ctors) { }
Base1::Base1 (const Base1 &rhs)
#if defined (TEST_COPY_CTOR)
: Base (rhs),
#else // if defined (TEST_COPY_CTOR)
: Base (),
#endif // TEST_COPY_CTOR
index1 (rhs.index1)
{
(void)&rhs; // silence unused argument warnings
++ncopy_ctors;
}
Base1::~Base1 ()
{
++ndtors;
index1 = 0;
}
const char* Base1::what () const
{
#if defined (TEST_WHAT)
if (2 < which_what++)
return Base::what ();
#endif // TEST_WHAT
return "Base1";
}
Base1& Base1::operator=(const Base1 &rhs)
{
++nassignments;
index1 = rhs.index1;
#if defined (TEST_ASSIGNMENT)
Base::operator= (rhs);
#endif // TEST_ASSIGNMENT
return *this;
}
Derived::Derived ()
: Base (), Base0 (), Base1 ()
{
++ndefault_ctors;
}
Derived::Derived (const Derived &rhs)
#if defined (TEST_COPY_CTOR)
: Base (rhs), Base0 (rhs), Base1 (rhs)
#else // if defined (TEST_COPY_CTOR)
: Base (), Base0 (), Base1 ()
#endif // TEST_COPY_CTOR
{
(void)&rhs; // silence unused argument warnings
++ncopy_ctors;
}
Derived::~Derived ()
{
++ndtors;
}
Derived& Derived::operator=(const Derived &rhs)
{
++nassignments;
Base0::operator= (rhs);
Base1::operator= (rhs);
return *this;
}
const char* Derived::what () const
{
if (3 < which_what++)
return Base1::what ();
return Base0::what ();
}

View File

@@ -0,0 +1,39 @@
// checking for bad_alloc copy ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_COPY_CTOR
#define main test_bad_alloc_copy_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_alloc_copy_ctor (argc, argv);
}

View File

@@ -0,0 +1,39 @@
// checking for bad_alloc default ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DEFAULT_CTOR
#define main test_bad_alloc_default_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_alloc_default_ctor (argc, argv);
}

View File

@@ -0,0 +1,39 @@
// checking for bad_alloc dtor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DTOR
#define main test_bad_alloc_dtor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_alloc_dtor (argc, argv);
}

View File

@@ -0,0 +1,39 @@
// checking for bad_alloc::what()
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_WHAT
#define main test_bad_alloc_what
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_alloc_what (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_cast assignment operator
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_ASSIGNMENT
#define bad_alloc bad_cast
#define main test_bad_cast_assignment
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_cast_assignment (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_cast copy ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_COPY_CTOR
#define bad_alloc bad_cast
#define main test_bad_cast_copy_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_cast_copy_ctor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_cast default ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DEFAULT_CTOR
#define bad_alloc bad_cast
#define main test_bad_cast_default_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_cast_default_ctor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_cast dtor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DTOR
#define bad_alloc bad_cast
#define main test_bad_cast_dtor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_cast_dtor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_cast::what()
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_WHAT
#define bad_alloc bad_cast
#define main test_bad_cast_what
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_cast_what (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_exception assignment operator
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_ASSIGNMENT
#define bad_alloc bad_exception
#define main test_bad_exception_assignment
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_exception_assignment (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_exception copy ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_COPY_CTOR
#define bad_alloc bad_exception
#define main test_bad_exception_copy_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_exception_copy_ctor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_exception default ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DEFAULT_CTOR
#define bad_alloc bad_exception
#define main test_bad_exception_default_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_exception_default_ctor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_exception dtor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DTOR
#define bad_alloc bad_exception
#define main test_bad_exception_dtor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_exception_dtor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_exception::what()
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_WHAT
#define bad_alloc bad_exception
#define main test_bad_exception_what
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_exception_what (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_typeid assignment operator
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_ASSIGNMENT
#define bad_alloc bad_typeid
#define main test_bad_typeid_assignment
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_typeid_assignment (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_typeid copy ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_COPY_CTOR
#define bad_alloc bad_typeid
#define main test_bad_typeid_copy_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_typeid_copy_ctor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_typeid default ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DEFAULT_CTOR
#define bad_alloc bad_typeid
#define main test_bad_typeid_default_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_typeid_default_ctor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_typeid dtor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DTOR
#define bad_alloc bad_typeid
#define main test_bad_typeid_dtor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_typeid_dtor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for bad_typeid::what()
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_WHAT
#define bad_alloc bad_typeid
#define main test_bad_typeid_what
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_bad_typeid_what (argc, argv);
}

View File

@@ -0,0 +1,25 @@
// checking bool, false, and true keywords
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
bool b = true && !false;

View File

@@ -0,0 +1,79 @@
// checking partial template specialization
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// primary template
template <class T, class U>
struct PartiallySpecialized
{
enum { e = 0 };
};
// required by std::vector<bool>
template <class U>
struct PartiallySpecialized<int, U>
{
enum { f = 1 };
};
// required by std::iterator_traits
template <class U>
struct PartiallySpecialized<int, U*>
{
enum { g = 2 };
};
// required by std::iterator_traits
template <class U>
struct PartiallySpecialized<int, const U*>
{
enum { h = 3 };
};
// required by std::allocator<const T>
template <class T, class U>
struct PartiallySpecialized<const T, const U>
{
enum { i = 4 };
};
// required by __rw_is_same
// exercises bug 638 in SunPro 5.7, patch 117831-02 2005/03/30
template <class T>
struct PartiallySpecialized<T, T>
{
enum { j = 5 };
};
// compile only, do not link
int foo ()
{
#define PS PartiallySpecialized
return !( 0 == PS<char, int>::e
&& 1 == PS<int, char>::f
&& 2 == PS<int, char*>::g
&& 3 == PS<int, const char*>::h
&& 4 == PS<const int, const char>::i
&& 5 == PS<long, long>::j);
}

View File

@@ -0,0 +1,58 @@
// checking static locals in inline code
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on collapse_static_locals.lib.*
# ifndef _RWSTD_NO_collapse_static_locals.lib
// link this compiled translation unit with the lib below
// LDOPTS = collapse_static_locals.lib$(LIBSUFFIX)
# endif // _RWSTD_NO_collapse_static_locals.lib
#endif // 0
// also defined in collapse_static_locals.lib.cpp
inline int foo ()
{
// multiple instances of `i' must be collapsed
static int i = 0;
return i++;
}
// bar() returns foo()
extern int bar ();
int main ()
{
// compilers that corectly collapse static locals will
// behave as commented below (others will return 0 from bar())
int i = foo (); // returns 0
int j = bar (); // should return 1
return !(i != j);
}

View File

@@ -0,0 +1,59 @@
// checking static locals in template code
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on collapse_template_locals.lib.*
# ifndef _RWSTD_NO_collapse_template_locals.lib
// link this compiled translation unit with the lib below
// LDOPTS = collapse_template_locals.lib$(LIBSUFFIX)
# endif // _RWSTD_NO_collapse_template_locals.lib
#endif // 0
// also defined in collapse_template_locals.lib.cpp
template <class T>
T foo (T)
{
// multiple instances of `t' must be collapsed
static T t;
return t++;
}
// bar() returns foo (0)
extern int bar ();
int main ()
{
// compilers that corectly collapse static locals will
// behave as commented below (others will return 0 from bar())
int i = foo (0); // returns 0
int j = bar (); // should return 1
return !(i != j);
}

View File

@@ -0,0 +1,62 @@
// checking static template members
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on collapse_template_statics.lib.*
# ifndef _RWSTD_NO_collapse_template_statics.lib
// link this compiled translation unit with the lib below
// LDOPTS = collapse_template_statics.lib$(LIBSUFFIX)
# endif // _RWSTD_NO_collapse_template_statics.lib
#endif // 0
// also defined in collapse_template_statics.lib.cpp
template <class T>
struct S
{
// multiple instances of `t' must be collapsed
static T t;
};
template <class T>
T S<T>::t;
// bar() returns S<int>::t++
extern int bar ();
int main ()
{
// compilers that corectly collapse static template members
// behave as commented below (others will return 0 from bar())
int i = S<int>::t++; // yields 0
int j = bar (); // should return 1
return !(i != j);
}

View File

@@ -0,0 +1,27 @@
// checking for const_cast
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
const char *s1 = 0;
char *s2 = const_cast<char*>(s1);
const char *s3 = const_cast<const char*>(s2);

View File

@@ -0,0 +1,240 @@
// checking for ctype constants
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include <ctype.h>
#include <stdio.h>
int main ()
{
struct {
const char* name;
int val;
} bits[] = {
{
"UPPER",
#if defined (_ISUPPER)
_ISUPPER
#elif defined (_ISupper)
_ISupper
#elif defined (_U)
_U
#elif defined (__GLIBC__)
_ISupper,
#else
-1
#endif
},
{
"LOWER",
#if defined (_ISLOWER)
_ISLOWER
#elif defined (_ISlower)
_ISlower
#elif defined (_L)
_L
#elif defined (__GLIBC__)
_ISlower,
#else
-1
#endif
},
{
"DIGIT",
#if defined (_ISDIGIT)
_ISDIGIT
#elif defined (_ISdigit)
_ISdigit
#elif defined (_D)
_D
#elif defined (__GLIBC__)
_ISdigit,
#else
-1
#endif
},
{
"SPACE",
#if defined (_ISSPACE)
_ISSPACE
#elif defined (_ISspace)
_ISspace
#elif defined (_S)
_S
#elif defined (__GLIBC__)
_ISspace,
#else
-1
#endif
},
{
"PUNCT",
#if defined (_ISPUNCT)
_ISPUNCT
#elif defined (_ISpunct)
_ISpunct
#elif defined (_P)
_P
#elif defined (__GLIBC__)
_ISpunct,
#else
-1
#endif
},
{
"CNTRL",
#if defined (_ISCNTRL)
_ISCNTRL
#elif defined (_IScntrl)
_IScntrl
#elif defined (_C)
_C
#elif defined (__GLIBC__)
_IScntrl,
#else
-1
#endif
},
{
"BLANK",
#if defined (_ISBLANK)
_ISBLANK
#elif defined (_ISblank)
_ISblank
#elif defined (_B)
_B
#elif defined (__GLIBC__)
_ISblank,
#else
-1
#endif
},
{
"XDIGIT",
#if defined (_ISXDIGIT)
_ISXDIGIT
#elif defined (_ISxdigit)
_ISxdigit
#elif defined (_X)
_X
#elif defined (__GLIBC__)
_ISxdigit,
#else
-1
#endif
},
{
"GRAPH",
#if defined (_ISGRAPH)
_ISGRAPH
#elif defined (_ISgraph)
_ISgraph
#elif defined (__GLIBC__)
_ISgraph,
#else
-1
#endif
},
{
"ALPHA",
#if defined (_ISALPHA)
_ISALPHA
#elif defined (_ISalpha)
_ISalpha
#elif defined (__GLIBC__)
_ISalpha,
#else
-1
#endif
},
{
"PRINT",
#if defined (_ISPRINT)
_ISPRINT
#elif defined (_ISprint)
_ISprint
#elif defined (__GLIBC__)
_ISprint,
#else
-1
#endif
},
{
"ALNUM",
#if defined (_ISALNUM)
_ISALNUM
#elif defined (_ISalnum)
_ISalnum
#elif defined (__GLIBC__)
_ISalnum,
#else
-1
#endif
}
};
int used = 0;
for (unsigned i = 0; i != sizeof bits / sizeof *bits; ++i) {
if (-1 != bits [i].val) {
used |= bits [i].val;
printf ("#define _RWSTD_CTYPE_%s %#010x"
" /* libc value */\n",
bits [i].name, bits [i].val);
}
}
for (unsigned j = 0; j != sizeof bits / sizeof *bits; ++j) {
if (-1 == bits [j].val) {
for (unsigned i = 0; i != sizeof used * 8; ++i) {
if (!(used & (1 << i))) {
used |= 1 << i;
printf ("#define _RWSTD_CTYPE_%s %#010x"
" /* computed */\n",
bits [j].name, 1 << i);
break;
}
}
}
}
return 0;
}

View File

@@ -0,0 +1,46 @@
// checking for cv qualifiers on type void
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifdef _RWSTD_NO_NEW_CLASS_TEMPLATE_SYNTAX
# define _RWSTD_SPECIALIZED_CLASS
#else
# define _RWSTD_SPECIALIZED_CLASS template<>
#endif
template <class T>
struct S {};
_RWSTD_SPECIALIZED_CLASS
struct S<void> {};
_RWSTD_SPECIALIZED_CLASS
struct S<const void> {};
_RWSTD_SPECIALIZED_CLASS
struct S<volatile void> {};
_RWSTD_SPECIALIZED_CLASS
struct S<const volatile void> {};

View File

@@ -0,0 +1,33 @@
// checking for daylight variable in <time.h>
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include <time.h>
// check to see if the XSI extension to POSIX, daylight,
// is declared in the header <time.h>
int check_daylight ()
{
return daylight;
}

View File

@@ -0,0 +1,40 @@
// checking default template arguments
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
template <class T, class U = int>
struct A { };
template <class T = char, class U = double>
struct B { };
template <class T = char, class U = T>
struct C { };
template <class T = A <short, float>, class U = C <T> >
struct D { };
A<void> a;
B<> b;
C<> c;
D<> d;

View File

@@ -0,0 +1,53 @@
// checking for dependent template
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifdef _RWSTD_NO_TYPENAME
# define typename
#endif
template <class T>
struct A
{
template <class U>
struct B {
typedef A<U> X;
};
};
template <class T, class U>
void foo (T, U)
{
// checking whether the template keyword is allowed
// where required by 14.2, p4
typedef typename A<T>::template B<U>::X ABX;
}
void bar ()
{
foo (0, '\0');
}

View File

@@ -0,0 +1,47 @@
// checking deprecated C headers and namespace std
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include <ctype.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main ()
{
(void)&std::isalpha; // <ctype>
(void)&std::setlocale; // <clocale>
std::pow (0.0, 0.0); // <cmath>
(void)&std::fopen; // <cstdio>
(void)&std::malloc; // <cstdlib>
(void)&std::strcpy; // <cstring>
(void)&std::clock; // <ctime>
return std::size_t (0); // <cstddef>, <cstring>, ...
}

View File

@@ -0,0 +1,76 @@
// checking for overloads of div()
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// determine whether the div() function (including
// any overloads) is defined in the usual libc headers
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#ifndef _RWSTD_NO_LONG_LONG
# if defined _MSC_VER
# define LONG_LONG __int64
# else
# define LONG_LONG long long
# endif
#endif // _RWSTD_NO_LONG_LONG
int template_used;
template <class T>
ldiv_t div (T, T)
{
++template_used;
return ldiv_t ();
}
template <class T>
void check_div (T t, const char *tname)
{
template_used = 0;
div (t, t);
if (0 == template_used)
printf ("%s", "// ");
printf ("#define _RWSTD_NO_DIV_%s\n", tname);
}
int main ()
{
check_div ((int)1, "INT");
check_div ((long)1, "LONG");
#if defined (LONG_LONG)
check_div ((LONG_LONG)1, "LLONG");
#endif // LONG_LONG
return 0;
}

View File

@@ -0,0 +1,87 @@
// checking for dummy default arguments
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
template <class T>
T foo (const T* = 0) { return T (); }
template <>
int foo<int>(const int*) { return 1; }
template <>
long foo<long>(const long*) { return 2; }
struct X { };
template <class T>
struct A {
int i_;
A (int i): i_ (i) { }
};
template <class T>
struct B {
int i_;
B (int i): i_ (i) { }
};
template <class T>
T bar (const X&, const T* = 0) { return T (); }
template <>
A<int> bar<A<int> >(const X&, const A<int>*) { return A<int>(1); }
template <>
B<long> bar<B<long> >(const X&, const B<long>*) { return B<long>(2); }
int main ()
{
int result = 0;
if (0 != foo<char>())
result = result << 1 + 1;
if (1 != foo<int>())
result = result << 1 + 1;
if (2 != foo<long>())
result = result << 1 + 1;
X x;
if (0 != bar<char>(x))
result = result << 1 + 1;
if (1 != bar<A<int> >(x).i_)
result = result << 1 + 1;
if (2 != bar<B<long> >(x).i_)
result = result << 1 + 1;
return result;
}

View File

@@ -0,0 +1,54 @@
// checking for dynamic_cast
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#include "nodbg.h"
#ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
#endif // _RWSTD_NO_HONOR_STD
struct A
{
virtual ~A () { }
};
struct B: A { };
struct C: A { };
int main ()
{
nodbg ();
B b;
A *a = &b;
return !(dynamic_cast<B*>(a) && !dynamic_cast<C*>(a));
}

View File

@@ -0,0 +1,68 @@
// checking for empty mem-initializer arglist
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
template <class T, class U>
struct S
{
T t;
U u;
// exercise 12.6.2, p3, bullet 1
S (): t (/* expression-list optional */), u () { }
};
int foo (char c)
{
// dirty up the stack
char dummy [32];
for (int i = 0; i != sizeof dummy; ++i)
dummy [i] = c + i;
return dummy [0] + dummy [sizeof dummy - 1];
}
struct X
{
char c;
int i;
};
int bar ()
{
S<int, X> s;
const char *p = (const char*)&s;
// member must be default-initialized (zeroed out)
for (int i = 0; i != sizeof s; ++i)
if (*p)
return 0;
return 1;
}
int main ()
{
foo ('a');
return !bar ();
}

View File

@@ -0,0 +1,97 @@
// checking that ctype mask's for char and wchar_t are equal
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#include <locale.h>
#include <ctype.h>
#ifndef _RWSTD_NO_WCTYPE_H
# include <wctype.h>
#endif
int main ()
{
setlocale (LC_ALL, "C");
for (int i = 0; i < 256; ++i) {
#ifndef _RWSTD_NO_ISWSPACE
if (!!isspace (i) != !!iswspace (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWPRINT
if (!!isprint (i) != !!iswprint (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWCNTRL
if (!!iscntrl (i) != !!iswcntrl (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWUPPER
if (!!isupper (i) != !!iswupper (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWLOWER
if (!!islower (i) != !!iswlower (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWALPHA
if (!!isalpha (i) != !!iswalpha (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWDIGIT
if (!!isdigit (i) != !!iswdigit (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWPUNCT
if (!!ispunct (i) != !!iswpunct (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWXDIGIT
if (!!isxdigit (i) != !!iswxdigit (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWALNUM
if (!!isalnum (i) != !!iswalnum (i))
return 1;
#endif
#ifndef _RWSTD_NO_ISWGRAPH
if (!!isgraph (i) != !!iswgraph (i))
return 1;
#endif
}
return 0;
}

View File

@@ -0,0 +1,46 @@
// checking exceptions
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
#endif // _RWSTD_NO_HONOR_STD
int main ()
{
try {
throw 1;
}
catch (int i) {
return 0;
}
catch (...) {
return 1;
}
return 2;
}

View File

@@ -0,0 +1,40 @@
// checking for exception assignment operator
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_ASSIGNMENT
#define bad_alloc exception
#define main test_exception_assignment
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_exception_assignment (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for exception copy ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_COPY_CTOR
#define bad_alloc exception
#define main test_exception_copy_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_exception_copy_ctor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for exception default ctor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DEFAULT_CTOR
#define bad_alloc exception
#define main test_exception_default_ctor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_exception_default_ctor (argc, argv);
}

View File

@@ -0,0 +1,40 @@
// checking for exception dtor
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_DTOR
#define bad_alloc exception
#define main test_exception_dtor
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_exception_dtor (argc, argv);
}

View File

@@ -0,0 +1,92 @@
// checking exception specification
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
namespace std {
void terminate ()
{
abort ();
}
} // std
# endif // _RWSTD_NO_STD_TERMINATE
#endif // _RWSTD_NO_HONOR_STD
extern "C" {
void handle_ABRT (int)
{
// exit successfully
exit (0);
}
} // extern "C"
// test functionality;
struct X {};
struct Y {};
void foobar () { throw Y (); }
void foo () throw (X) { foobar (); }
// test syntax
void bar (int) throw (int) {}
struct A { };
struct B
{
B () throw (A*) { }
~B () throw () { }
};
int main ()
{
signal (SIGABRT, handle_ABRT);
try {
// must not return
foo ();
}
catch (X) {
return 1;
}
catch (Y) {
return 2;
}
catch (...) {
return 3;
}
return 4;
}

View File

@@ -0,0 +1,53 @@
// checking for exception specification on new
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include <stdlib.h>
#include <stddef.h>
#include "config.h"
#ifndef _RWSTD_NO_NAMESPACE
namespace std {
struct bad_alloc { };
}
void* operator new (size_t) throw (std::bad_alloc);
#else // if defined (_RWSTD_NO_NAMESPACE)
struct bad_alloc { };
void* operator new (size_t) throw (bad_alloc);
#endif // _RWSTD_NO_NAMESPACE
void* foo ()
{
void *p = operator new (1);
return p;
}

View File

@@ -0,0 +1,40 @@
// checking for exception::what()
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on RUNTIME_IN_STD.cpp
# ifndef _RWSTD_NO_RUNTIME_IN_STD
# endif // _RWSTD_NO_RUNTIME_IN_STD
#endif // 0
#define TEST_WHAT
#define bad_alloc exception
#define main test_exception_what
#include "BAD_ALLOC_ASSIGNMENT.cpp"
#undef main
int main (int argc, char *argv[])
{
return test_exception_what (argc, argv);
}

View File

@@ -0,0 +1,30 @@
// checking explicit keyword
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
struct S
{
S (double) { }
explicit S (int) { }
};

View File

@@ -0,0 +1,34 @@
// checking explicit function template arguments
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
template<class T>
int foo ()
{
return 0;
}
int main ()
{
return foo<int>();
}

View File

@@ -0,0 +1,37 @@
// checking for explicit instantiation of ctors
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
template <class T>
struct S
{
S () { }
S (const S&) { }
};
template S<int>::S ();
template S<double>::S ();
template S<char>::S (const S<char>&);
template S<unsigned>::S (const S<unsigned>&);

View File

@@ -0,0 +1,32 @@
// checking explicit function instantiation
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
template <class T>
int foo (T)
{
return 0;
}
template int foo (int);
template int foo (char);

View File

@@ -0,0 +1,48 @@
// checking for explicit instantiation
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// IMPLICIT_INSTANTIATION.cpp depends on foo<T>(T)
template <class T>
T foo (T t) { return t; }
template <class T>
struct S
{
T bar () {
// explicit instantiation of S<T> (and, consequently,
// S<T>::bar()) must "implicitly" instantiate foo<T>(T)
return foo (T ());
}
};
// the symbols expected to be produced by the explicit instantiation
// directives and their attributes are as follows:
// TEXT S<int>::bar()
// WEAK (or TEXT) foo<int>(int)
// TEXT S<char>::bar()
// WEAK (or TEXT) foo<char>(char)
// IMPLICIT_INSTANTIATION.cpp uses foo<int>(int)
template class S<int>;
template class S<char>;

View File

@@ -0,0 +1,55 @@
// checking for instantiation before definition
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifdef _RWSTD_NO_IMPLICIT_INCLUSION
// tell "instantiation_before_definition.h" to #include its
// implementation file, instantiation_before_definition.cc
# define INCLUDE_CC_FILE
#endif // _RWSTD_NO_IMPLICIT_INCLUSION
#ifdef _RWSTD_NO_EXTERN_FUNCTION_TEMPLATE
// tell "instantiation_before_definition.h" to use explicit
// function template specialization instead of the extern
// template extension
# define SPECIALIZE_FUNCTION_TEMPLATE
#endif // _RWSTD_NO_EXTERN_FUNCTION_TEMPLATE
#define INSTANTIATE_TEMPLATE
#include "instantiation_before_definition.h"
// test exercises the ability to explicitly instantiate a template
// lexically before the definition of the template (exercises, for
// example, IBM VAC++ 7.0 bug #448:
// http://iwww.cvo.roguewave.com/bugzilla/show_bug.cgi?id=448)
int main ()
{
InstantiatedBeforeDefined<int> ibd;
return ibd.defined_first (0)
+ ibd.instantiated_first (0)
+ instantiated_before_defined (0);
}

View File

@@ -0,0 +1,29 @@
// checking for explicit instantiation with implicit inclusion
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "instantiation_with_implicit_inclusion.h"
template class S<short>;
template long foo (S<long>, long);
template double bar (S<double>, double);

View File

@@ -0,0 +1,46 @@
// checking for explicit instantiation of members
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
template <class T>
T foo (T t) { return t; }
template <class T>
struct S
{
T bar () const {
// explicit instantiation of S<T> (and, consequently,
// S<T>::bar()) must "implicitly" instantiate foo<T>(T)
return foo (T ());
}
static void baz (T t) {
foo (t);
}
};
template int S<int>::bar () const;
template double S<double>::bar () const;
template void S<char>::baz (char);
template void S<unsigned>::baz (unsigned);

View File

@@ -0,0 +1,81 @@
// checking for explicit member specialization
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
struct A
{
int i_;
// no default ctor declared to exercise the compiler's ability
// distinguish between a declaration of an explicir member
// specialization and a definition of the same (see below)
A (int i): i_ (i) { }
};
template <class T>
struct B {
int foo () { return a.i_; }
int bar ();
static A a;
};
// declare explicit specialization of template members
template <> inline int B<int>::foo ();
template <> int B<int>::bar ();
// make sure this is taken as a declaration and not a definition
// as, for example, with SunPro 5.5 (see bug #411)
template <> A B<int>::a;
// define explicit specialization of template members
template <> inline int B<int>::foo () { return 1; }
template <> int B<int>::bar () { return 1; }
template <> A B<int>::a (1);
// define members of the primary template
template <class T> int B<T>::bar () { return foo (); }
template <class T> A B<T>::a (0);
int main ()
{
B<char> bc;
bc.foo ();
bc.bar ();
B<int> bi;
int status = 0;
if (1 != bi.foo ())
status |= 1;
if (1 != bi.bar ())
status |= 2;
if (1 != bi.a.i_)
status |= 4;
return status;
}

View File

@@ -0,0 +1,62 @@
// checking for exported templates
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifndef _RWSTD_NO_EXPORT_KEYWORD
// establish a dependency on EXPORT_KEYWORD.cpp which must be
// compiled first since it defines the exported function template
// LDOPTS = EXPORT_KEYWORD.o
#endif // _RWSTD_NO_EXPORT_KEYWORD
export template <class T>
T exported_function_template (T);
export template <class T>
struct ExportedClass
{
T exported_class_member (T);
};
template <class T>
T ExportedClass<T>::
exported_class_member (T t) {
return exported_function_template (t);
}
struct MyClass {
int i_;
MyClass (): i_ (0) { }
};
int main ()
{
MyClass x;
return ExportedClass<MyClass>().exported_class_member (x).i_;
}

View File

@@ -0,0 +1,33 @@
// checking for the export keyword
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// NOTE: test EXPORT.cpp links with EXPORT_KEYOWRD.o and expects
// to find a definition of the function template below there
export
template <class T>
T exported_function_template (T t)
{
return t;
}

View File

@@ -0,0 +1,38 @@
// checking for compatibility of extern "C" and "C++"
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
extern "C" {
typedef int (*ext_c_fun)();
int foo (int (*pf)()) { return pf (); }
}
extern "C++" {
int bar () { return 0; }
}
int main ()
{
return !(0 == foo ((ext_c_fun)bar));
}

View File

@@ -0,0 +1,79 @@
// checking for exceptions from extern "C" functions
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// test tries to determine whether it's possible to throw exceptions
// from functions with C language linkage
extern "C" {
int extern_c_function (int x, int y, int (*fun)(int, int))
{
if (fun)
return fun (x, y);
return 0;
}
int div_throw (int x, int y)
{
if (0 == y)
throw y;
return x / y;
}
int div_nothrow (int x, int y)
{
if (0 == y)
return 0;
return x / y;
}
typedef int cfun_t (int, int);
} // extern "C"
int main (int argc, char *argv[])
{
const int x = argc < 2 ? 0 : int (*argv [1]);
const int y = argc < 3 ? 0 : int (*argv [2]);
cfun_t* pcfun = argc < 4 ? div_throw : div_nothrow;
int result;
try {
result = extern_c_function (x, y, pcfun);
}
catch (int res) {
result = res;
}
return result;
}

View File

@@ -0,0 +1,45 @@
// checking overloading on extern "C"
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
extern "C" {
typedef int (*pf_t)(void);
int foo (pf_t f) { return f (); }
int bar () { return 0; }
}
extern "C++" {
int foo (int (*f)(void)) { return f (); }
int baz () { return 1; }
}
int main ()
{
return !(0 == foo (bar) && 1 == foo (baz));
}

View File

@@ -0,0 +1,53 @@
// checking for extern function template extension
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// include a file containing the definition of a template
// and an extern template directive referencing an explicit
// instantiation of the same template in extern_function_template_imp.o
#include "extern_function_template_imp.h"
// establish a dependency on extern_function_template_imp.o to make sure
// the extern_function_template_imp.cpp is compiled before this file
#ifndef _RWSTD_NO_extern_function_template_imp
// link with the object file below
// LDOPTS = extern_function_template_imp.o
#endif // _RWSTD_NO_extern_function_template_imp
int main ()
{
S<int> s;
int res = 0;
// verify that the call compiles and links
res += foobar (s).t;
// verify that the call resolves to the definition emitted
// by the explicit instantiation in extern_function_template_imp.o
// and not the one here
return !(1 == res);
}

View File

@@ -0,0 +1,42 @@
// checking for truly extern inline
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#if 0 // guard invalid preprocessor symbol below
// establish a dependency on extern_inline.lib.*
# ifndef _RWSTD_NO_extern_inline.lib
// link this compiled translation unit with the lib below
// LDOPTS = extern_inline.lib$(LIBSUFFIX)
# endif // _RWSTD_NO_extern_inline.lib
#endif // 0
extern int foo (int);
int main ()
{
return !(1 == foo (0));
}

View File

@@ -0,0 +1,64 @@
// checking for extern template extension
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
// establish dependencies on the config tests and define config
// macros used in the header below (the are not autodetected
// in headers)
#ifdef _RWSTD_NO_INLINE_MEMBER_TEMPLATE
# define NO_INLINE_MEMBER_TEMPLATE
#endif // _RWSTD_NO_INLINE_MEMBER_TEMPLATE
#ifdef _RWSTD_NO_MEMBER_TEMPLATE
# define NO_MEMBER_TEMPLATE
#endif // _RWSTD_NO_MEMBER_TEMPLATE
// include a file containing the definition of a template
// and an extern template directive referencing an explicit
// instantiation of the same template in extern_template_imp.o
#include "extern_template_imp.h"
// establish a dependency on extern_template_imp.o to make sure
// the extern_template_imp.cpp is compiled before this file
#ifndef _RWSTD_NO_extern_template_imp
// link with the object file below
// LDOPTS = extern_template_imp.o
#endif // _RWSTD_NO_extern_template_imp
int main ()
{
S<int> s;
// call member template functions on a specialization of
// a class template explicitly instantiated in one file
// and declared extern template in extern_template_imp.h
// to detect if the extern template declaration prevents
// the implicit instantiation of the member templates
// HP aCC 3 and 5 bug -- see STDCXX-270:
// http://issues.apache.org/jira/browse/STDCXX-270
return s.inline_member_template (0) + s.member_template (0);
}

View File

@@ -0,0 +1,62 @@
// checking for extern template extension
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// include a file containing the definition of a template
// and an extern template directive referencing an explicit
// instantiation of the same template in extern_template_imp.o
#include "extern_template_imp.h"
// establish a dependency on extern_template_imp.o to make sure
// the extern_template_imp.cpp is compiled before this file
#ifndef _RWSTD_NO_extern_template_imp
// link with the object file below
// LDOPTS = extern_template_imp.o
#endif // _RWSTD_NO_extern_template_imp
int main ()
{
// each of the member function of S<int> is defined to return 1
// when explicitly instantiated in extern_template_imp.cpp but
// to return 0 when #included here
S<int> s;
int res = 0;
// verify that calls to inline member functions defined in
// the body of the template, inline member functions defined
// outside the body of the template, and out-of-line member
// functions all compile and link
res += s.foo ();
res += s.bar ();
res += s.baz ();
// verify that the calls ultimately resolve to the definition
// emitted by the explicit instantiation in extern_template_imp.o
// and not the one here
return !(3 == res);
}

View File

@@ -0,0 +1,62 @@
// checking for extern template before definition
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifndef _RWSTD_NO_extern_template_before_definition_imp
// establish a dependency on the source file to get it
// compiled first and link with the object file
// LDOPTS = extern_template_before_definition_imp.o
#endif
#ifdef _RWSTD_NO_IMPLICIT_INCLUSION
// tell "instantiation_before_definition.h" to #include its
// implementation file, instantiation_before_definition.cc
# define INCLUDE_CC_FILE
#endif // _RWSTD_NO_IMPLICIT_INCLUSION
#ifdef _RWSTD_NO_EXTERN_FUNCTION_TEMPLATE
// tell "instantiation_before_definition.h" to use explicit
// function template specialization instead of the extern
// template extension
# define SPECIALIZE_FUNCTION_TEMPLATE
#endif // _RWSTD_NO_EXTERN_FUNCTION_TEMPLATE
#define EXTERN_TEMPLATE
#include "instantiation_before_definition.h"
// test exercises the ability to declare an explicit instantiation
// of a template using the "extern template" syntax and lexically
// before the definition of the template (exercises, for example,
// gcc 4.0.2 bug #24511:
// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24511)
int main ()
{
InstantiatedBeforeDefined<int> ibd;
return ibd.defined_first (0)
+ ibd.instantiated_first (0)
+ instantiated_before_defined (0);
}

View File

@@ -0,0 +1,314 @@
// computing floating point properties
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// working around a Compaq C++ headers problem (PR #27459)
#if defined (__PURE_CNAME)
# undef __PURE_CNAME
#endif // __PURE_CNAME
#include "config.h"
enum {
// the enumerators below are expected to be hidden by macros #defined
// in the <float.h> header #included below through "float_defs.h";
// references to macros that are not #defined in the header will
// silently use these enumerators and prevent compilation errors that
// would result otherwise
DBL_DIG = 15, // default
DBL_MANT_DIG = 53,
DBL_MAX_10_EXP = 308,
DBL_MAX_EXP = 1024,
DBL_MIN_10_EXP = -307,
DBL_MIN_EXP = -1021,
FLT_DIG = 6,
FLT_MANT_DIG = 24,
FLT_MAX_10_EXP = 38,
FLT_MAX_EXP = 128,
FLT_MIN_10_EXP = -37,
FLT_MIN_EXP = -125,
FLT_RADIX = 2,
LDBL_DIG = -1,
LDBL_MANT_DIG = -1,
LDBL_MAX_10_EXP = -1,
LDBL_MAX_EXP = -1,
LDBL_MIN_10_EXP = -1,
LDBL_MIN_EXP = -1
};
#include <errno.h> // for ERANGE, errno
#include <stdio.h> // for printf()
#include <stdlib.h> // for strtod()
#include "float_defs.h" // for FLT_XXX, DBL_XXX, LDBL_XXX constants
#ifndef _RWSTD_NO_LIBC_EXCEPTION_SPEC
# define LIBC_THROWS() throw ()
#else
# define LIBC_THROWS() /* empty */
#endif // _RWSTD_NO_LIBC_EXCEPTION_SPEC
extern "C" {
#ifdef _RWSTD_NO_STRTOF
# ifndef _RWSTD_NO_STRTOF_IN_LIBC
# undef _RWSTD_NO_STRTOF
float strtof (const char*, char**) LIBC_THROWS ();
# endif // _RWSTD_NO_STRTOF_IN_LIBC
#endif // _RWSTD_NO_STRTOF
#ifdef _RWSTD_NO_STRTOD
# ifndef _RWSTD_NO_STRTOD_IN_LIBC
# undef _RWSTD_NO_STRTOD
double strtod (const char*, char**) LIBC_THROWS ();
# endif // _RWSTD_NO_STRTOD_IN_LIBC
#endif // _RWSTD_NO_STRTOD
#ifndef _RWSTD_NO_LONG_DOUBLE
# ifdef _RWSTD_NO_STRTOLD
# ifndef _RWSTD_NO_STRTOLD_IN_LIBC
# undef _RWSTD_NO_STRTOLD
long double strtold (const char*, char**) LIBC_THROWS ();
# endif // _RWSTD_NO_STRTOLD_IN_LIBC
# endif // _RWSTD_NO_STRTOLD
#endif // _RWSTD_NO_LONG_DOUBLE
}
#ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
#endif // _RWSTD_NO_HONOR_STD
// print a floating point number, either as a string (if the stringized
// constant is a valid number, and not some complex expression), or as
// a formatted floating point value
template <class FloatT>
void print_float (FloatT x, const char *xstr,
const char *macro_name, const char *fmt, int prec)
{
if ('-' == *xstr || '0' <= *xstr && '9' >= *xstr) {
printf ("#define _RWSTD_%-16s %s", macro_name, xstr);
}
else {
printf ("#define _RWSTD_%-16s ", macro_name);
printf (fmt, prec + 2, x);
}
puts ("");
}
#define DO_STRINGIZE(x) #x
#define STRINGIZE(x) DO_STRINGIZE (x)
#define PRINTINT(macro) \
if (-1 == (macro)) \
printf ("%s", "//"); \
printf ("#define _RWSTD_%-16s %6d\n", #macro, (macro))
#define PRINTFLT(macro, fmt, prec, suffix) \
print_float (macro, STRINGIZE (macro), #macro, "%.*" fmt "e" suffix, prec)
int main ()
{
//////////////////////////////////////////////////////////////////
// compute floating point limits
#undef LDBL_FMT
#ifdef _RWSTD_LDBL_PRINTF_PREFIX
# define LDBL_FMT _RWSTD_LDBL_PRINTF_PREFIX
#else
# define LDBL_FMT "L"
#endif
#if defined (FLT_ROUNDS)
printf ("#define _RWSTD_%-16s %6d /* %s */\n",
"FLT_ROUNDS", FLT_ROUNDS,
0 == FLT_ROUNDS ? "round toward zero"
: 1 == FLT_ROUNDS ? "round to nearest"
: 2 == FLT_ROUNDS ? "round toward infinity"
: 3 == FLT_ROUNDS ? "round toward negative infinity"
: "indeterminable");
#endif // FLT_ROUNDS
PRINTINT (DBL_DIG);
PRINTINT (DBL_MANT_DIG);
PRINTINT (DBL_MAX_10_EXP);
PRINTINT (DBL_MAX_EXP);
PRINTINT (DBL_MIN_10_EXP);
PRINTINT (DBL_MIN_EXP);
PRINTINT (FLT_DIG);
PRINTINT (FLT_MANT_DIG);
PRINTINT (FLT_MAX_10_EXP);
PRINTINT (FLT_MAX_EXP);
PRINTINT (FLT_MIN_10_EXP);
PRINTINT (FLT_MIN_EXP);
PRINTINT (FLT_RADIX);
#ifndef _RWSTD_NO_LONG_DOUBLE
PRINTINT (LDBL_DIG);
PRINTINT (LDBL_MANT_DIG);
PRINTINT (LDBL_MAX_10_EXP);
PRINTINT (LDBL_MAX_EXP);
PRINTINT (LDBL_MIN_10_EXP);
PRINTINT (LDBL_MIN_EXP);
#endif // _RWSTD_NO_LONG_DOUBLE
#if defined (DBL_MAX)
PRINTFLT (DBL_MAX, "l", DBL_DIG, "");
#endif // DBL_MAX
#if defined (FLT_MAX)
PRINTFLT (FLT_MAX, "", FLT_DIG, "F");
#endif // FLT_MAX
#ifndef _RWSTD_NO_LONG_DOUBLE
# if defined (LDBL_MAX)
PRINTFLT (LDBL_MAX, LDBL_FMT, DBL_DIG, "F");
# endif // LDBL_MAX
#endif // _RWSTD_NO_LONG_DOUBLE
#if defined (DBL_EPSILON)
PRINTFLT (DBL_EPSILON, "l", DBL_DIG, "");
#endif // DBL_EPSILON
#if defined (DBL_MIN)
PRINTFLT (DBL_MIN, "l", DBL_DIG, "");
#endif // DBL_MIN
#if defined (FLT_EPSILON)
PRINTFLT (FLT_EPSILON, "", FLT_DIG, "F");
#endif // FLT_EPSILON
#if defined (FLT_MIN)
PRINTFLT (FLT_MIN, "", FLT_DIG, "F");
#endif // FLT_MIN
#ifndef _RWSTD_NO_LONG_DOUBLE
# if defined (LDBL_EPSILON)
PRINTFLT (LDBL_EPSILON, LDBL_FMT, LDBL_DIG, "L");
# endif // LDBL_EPSILON
# if defined (LDBL_MIN)
PRINTFLT (LDBL_MIN, LDBL_FMT, LDBL_DIG, "L");
# endif // LDBL_MIN
#endif // _RWSTD_NO_LONG_DOUBLE
#if !defined (ERANGE)
# define ERANGE -1
#endif // ERANGE
#ifndef _RWSTD_NO_STRTOF
errno = 0;
// determine whether strtof() sets errno on underflow
const float f = strtof ("1.0e-999", (char**)0);
if (f < 0.0 || f > 1.0 || !errno)
printf ("#define _RWSTD_NO_STRTOF_UFLOW\n");
else
printf ("// #define _RWSTD_NO_STRTOF_UFLOW // %d%s\n",
errno, ERANGE == errno ? " (ERANGE)" : "");
#endif // _RWSTD_NO_STRTOF
#ifndef _RWSTD_NO_STRTOD
errno = 0;
// determine whether strtod() sets errno on underflow
const double d = strtod ("1.0e-999", (char**)0);
if (d < 0.0 || d > 1.0 || !errno)
printf ("#define _RWSTD_NO_STRTOD_UFLOW\n");
else
printf ("// #define _RWSTD_NO_STRTOD_UFLOW // %d%s\n",
errno, ERANGE == errno ? " (ERANGE)" : "");
#endif // _RWSTD_NO_STRTOD
#ifndef _RWSTD_NO_LONG_DOUBLE
# ifndef _RWSTD_NO_STRTOLD
errno = 0;
# if !defined (__hpux) || !defined (_LONG_DOUBLE)
// HP-UX strtold() returns struct long_double
// the macro _LONG_DOUBLE is #defined when the struct is defined
// note that gcc's replacement <stdlib.h> may actually define the
// function with the correct signature
// determine whether strtold() sets errno on underflow
const long double ld = strtold ("1.0e-9999", (char**)0);
# else // HP-UX with _LONG_DOUBLE #defined
union {
long double ld;
long_double data;
} ldu;
ldu.data = strtold ("1.0e-9999", (char**)0);
const long double ld = ldu.ld;
# endif // HP-UX, _LONG_DOUBLE
if (ld < 0.0 || ld > 1.0 || !errno)
printf ("#define _RWSTD_NO_STRTOLD_UFLOW\n");
else
printf ("// #define _RWSTD_NO_STRTOLD_UFLOW // %d%s\n",
errno, ERANGE == errno ? " (ERANGE)" : "");
# endif // _RWSTD_NO_STRTOLD
#endif // _RWSTD_NO_LONG_DOUBLE
return 0;
}

View File

@@ -0,0 +1,40 @@
// checking for fpos_t in <stdio.h>
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include <stdio.h>
#include "config.h"
#ifndef _RWSTD_NO_NAMESPACE
namespace std { }
using namespace std;
#endif // _RWSTD_NO_NAMESPACE
int main ()
{
fpos_t pos;
return !(0 != &pos);
}

View File

@@ -0,0 +1,61 @@
// checking for friend templates of templates
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
template <class T>
struct A { enum { i }; };
template <class T>
struct B
{
private:
template <class U, class V>
friend int foo (A<U>, B<V>);
int bar (int i) const { return i; }
};
template <class T, class U>
int foo (A<T> a, B<U> b)
{
return b.bar (a.i);
}
#ifndef _RWSTD_NO_EXPLICIT_FUNC_INSTANTIATION
// explicitly instantiate to detect bugs such as SunPro 5.3's PR #30227
template int foo (A<int>, B<double>);
#endif // _RWSTD_NO_EXPLICIT_FUNC_INSTANTIATION
int baz ()
{
A<int> a;
B<double> b;
return foo (a, b);
}

View File

@@ -0,0 +1,30 @@
// checking the __func__ special macro
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
// 6.4.2.2, p1 of C99
const char* func_test ()
{
return __func__;
}

View File

@@ -0,0 +1,83 @@
// checking function-try-block
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
int tried;
int caught;
template <class T>
T foo (T t)
try { // <-- testing
++tried;
throw t;
}
catch (T) {
++caught;
throw;
}
struct S
{
S (int i)
try // <-- testing
: i_ (i) {
++tried;
foo (i_);
}
catch (int) {
++caught;
throw;
}
int i_;
};
int main ()
{
int result = 0;
try {
S s (123);
(void)&s;
result |= 1;
}
catch (int i) {
if (i != 123)
result |= 2;
if (tried != 2)
result |= 4;
if (caught != 2)
result |= 8;
}
catch (...) {
result |= 0x10;
}
return result;
}

View File

@@ -0,0 +1,52 @@
// checking function template overload
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
template <class T, class U>
struct A { };
template <class T, class U>
int foo (A<T, U>, T)
{
return 0;
}
template <class T, class U>
int foo (A<T, U>, char)
{
return 1;
}
template <class U>
int foo (A<char, U>, char)
{
return 2;
}
int main ()
{
A<double, double> add;
A<char, double> acd;
return !(0 == foo (add, 0.0) && 1 == foo (add, 'a') && 2 == foo (acd, 'a'));
}

View File

@@ -0,0 +1,95 @@
// checking for class ::bad_alloc
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#include "nodbg.h"
#if !defined (_RWSTD_NO_NEW_THROWS) && !defined (_RWSTD_NO_NEW_OFLOW_SAFE)
# include <stddef.h> // for size_t
#endif // !_RWSTD_NO_NEW_THROWS && !_RWSTD_NO_NEW_OFLOW_SAFE
#ifndef _RWSTD_NO_SETRLIMIT
// test for setrlimit() presence before compiling current file
#endif
// proclimits.h must be included only after #if[n]def _RWSTD_NO_SETRLIMIT
#include "proclimits.h"
#ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
#endif // _RWSTD_NO_HONOR_STD
struct bad_alloc { };
int main ()
{
// prevent MSVC's libc from popping up a dialog box
// with an out-of-memory message
nodbg ();
try {
#ifndef _RWSTD_NO_NEW_THROWS
# ifndef _RWSTD_NO_NEW_OFLOW_SAFE
void *p = ::operator new (size_t (-1));
if (!p)
return 1;
# else // if defined (_RWSTD_NO_NEW_OFLOW_SAFE)
limit_memory (0);
for (unsigned long n = 1UL << (sizeof (long) * 8 - 1);
0 != n; n |= (n >> 1)) {
// try to allocate a huge amount of memory
void *p = ::operator new (n);
if (!p)
return 1;
}
# endif // _RWSTD_NO_NEW_OFLOW_SAFE
#else // if defined (_RWSTD_NO_NEW_THROWS)
return 4;
#endif
}
catch (bad_alloc&) {
return 0;
}
catch (...) {
return 2;
}
return 3;
}

View File

@@ -0,0 +1,62 @@
// checking for class ::bad_cast
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
#endif // _RWSTD_NO_HONOR_STD
class bad_cast { };
struct B { virtual ~B () { } };
struct D1: B { };
struct D2: B { };
int main ()
{
D1 d1;
B &b = d1;
try {
// throws [std::]bad_cast
D2 &d2 = dynamic_cast<D2&>(b);
(void)&d2;
}
catch (bad_cast&) {
return 0;
}
catch (...) {
// fail if cast throws anything other than a ::bad_cast
return 1;
}
// fail if cast doesn't throw
return 2;
}

View File

@@ -0,0 +1,102 @@
// checking for class ::bad_exception
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
#endif // _RWSTD_NO_HONOR_STD
#ifndef _RWSTD_NO_EXCEPTION_SPECIFICATION
# define throws(args) throw args
#else
# define throws(ignore)
#endif // _RWSTD_NO_EXCEPTION_SPECIFICATION
#ifndef _RWSTD_NO_STD_SET_UNEXPECTED
namespace std {
#endif // _RWSTD_NO_STD_SET_UNEXPECTED
typedef void (*unexpected_handler)();
unexpected_handler set_unexpected (void (*)()) throws (());
#ifndef _RWSTD_NO_STD_SET_UNEXPECTED
} // namespace std
# define SET_UNEXPECTED(handler) std::set_unexpected (handler)
#else
# define SET_UNEXPECTED(handler) set_unexpected (handler)
#endif // _RWSTD_NO_STD_SET_UNEXPECTED
class bad_exception { };
void foo () throws ((bad_exception))
{
// throw an object of a disallowed type
throw 0;
}
void handler ()
{
// throw an object of a type not allowed by the exception-specification
// of the function that already violated its specification (due to which
// the handler has been called); this requires the exception object to be
// replaced by the runtime library by one of type [std]::bad_exception
throw "";
}
int main ()
{
SET_UNEXPECTED (handler);
try {
// will fail if runtime library doesn't recognize ::bad_exception
// by calling terminate()
foo ();
}
catch (bad_exception&) {
// successfully caught object thrown by runtime library
return 0;
}
catch (...) {
return 1;
}
// runtime library is broken
return 2;
}

View File

@@ -0,0 +1,73 @@
// checking for class ::bad_typeid
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifndef _RWSTD_NO_TYPEINFO
# include <typeinfo>
#else // if defined (_RWSTD_NO_TYPEINFO)
# ifndef _RWSTD_NO_TYPEINFO_H
# include <typeinfo.h>
# else // if defined (_RWSTD_NO_TYPEINFO_H)
// 5.2.8, p6: using typeid() without #including <typeinfo>
// first yields undefined behavior...
class bad_typeid { };
# endif // _RWSTD_NO_TYPEINFO_H
#endif // _RWSTD_NO_TYPEINFO
#if 2 == __GNUG__
# ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
# endif // _RWSTD_NO_HONOR_STD
#endif // gcc 2.x
struct S { virtual ~S () { } };
int main ()
{
try {
S *s = 0;
// expected to throw [std::] bad_typeid
typeid (*s);
}
catch (bad_typeid&) {
return 0;
}
catch (...) {
// fail if typeid throws anything other than a std::bad_typeid
return 1;
}
// fail if typeid doesn't throw
return 2;
}

View File

@@ -0,0 +1,59 @@
// checking for class ::exception
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifndef _RWSTD_NO_HONOR_STD
# ifdef _RWSTD_NO_STD_TERMINATE
# include "terminate.h"
# endif // _RWSTD_NO_STD_TERMINATE
#endif // _RWSTD_NO_HONOR_STD
class exception { };
struct B { virtual ~B () { } };
struct D1: B { };
struct D2: B { };
int main ()
{
D1 d1;
B &b = d1;
try {
// throws [std::] bad_cast
D2 &d2 = dynamic_cast<D2&>(b);
}
catch (exception&) {
return 0;
}
catch (...) {
// fail if cast throws anything other than an ::exception-derivative
return 1;
}
// fail if cast doesn't throw
return 2;
}

View File

@@ -0,0 +1,43 @@
// checking for ::nothrow
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
struct nothrow_t { };
extern const nothrow_t nothrow;
const nothrow_t *ptr = &nothrow;
int main (int argc, char *argv[])
{
(void)&argv;
// foil clever optimizers
if (argc > 2)
ptr = 0;
// will fail at link-time if ::nothrow is not defined
// in the compiler support library
return !(0 != ptr);
}

View File

@@ -0,0 +1,47 @@
// checking for ::nothrow_t
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include <stddef.h> // for size_t
#include "config.h"
// declare a global nothrow_t
struct nothrow_t { };
#ifdef _RWSTD_NO_EXCEPTION_SPECIFICATION
# define throw()
#endif // _RWSTD_NO_EXCEPTION_SPECIFICATION
void* operator new (size_t n, const nothrow_t&) throw ();
int main ()
{
// won't link if ::operator new (size_t, const ::nothrow_t&)
// is not defined in the compiler support library
::operator new (1, nothrow_t ());
return 0;
}

View File

@@ -0,0 +1,52 @@
// checking for ::set_new_handler()
/***************************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
* Copyright 1999-2007 Rogue Wave Software, Inc.
*
**************************************************************************/
#include "config.h"
#ifdef _RWSTD_NO_EXCEPTION_SPECIFICATION
# define throw()
#endif // _RWSTD_NO_EXCEPTION_SPECIFICATION
typedef void (*new_handler)();
// looking for a definition in compiler support library
new_handler set_new_handler (new_handler) throw ();
void handler () { }
int main (int argc, char *argv[])
{
(void)&argv;
if (argc > 1) {
new_handler save = set_new_handler (handler);
return save == handler;
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show More