From c33d97c2809bc86c083b5996652c03d3d0213e53 Mon Sep 17 00:00:00 2001 From: Alex Smith Date: Mon, 27 Sep 2010 11:28:09 +0100 Subject: [PATCH] Fix permute.i test failure, and clean up build system and boolean detection The cause of the bug was that "bool" referred to a different type in libick.a and in compiled programs, which could be caused by, e.g., different compilers (entirely plausible in cross-compiling) or a different header environment (what actually happened was a missing config.h, as that isn't installed). The fix used here was to change abcess.h from immutable to a generated file, containing the boolean types actually used to build C-INTERCAL and requiring their use for the eventually generated programs, preventing the type mismatch. This fails if C-INTERCAL is built with a compiler that supports booleans, and run with a $CC that doesn't, but at least it now fails noisly in that case rather than silently, with nothing but a mysterious regression check failure in permute.i. As part of this, config.h was cleaned up; configuration #defines now consistently use the values 1 or undef, rather than /**/ or undef sometimes, and 1 or undef other times; this is needed to AC_SUBST the values into abcess.h correctly, but is useful cleanup in any case. --- README | 2 +- buildaux/Makefile.am | 16 +++++++--------- configure.ac | 29 ++++++++++++++++++----------- src/{abcess.h => abcessh.in} | 30 ++++++++++++++++++++++++++---- src/ick_bool.h | 6 +++--- 5 files changed, 55 insertions(+), 28 deletions(-) rename src/{abcess.h => abcessh.in} (92%) diff --git a/README b/README index 812d3ab..a1ab973 100644 --- a/README +++ b/README @@ -44,7 +44,7 @@ The files included are: |doc/chipspec.txt | plans for an INTERCAL-based microprocessor |doc/ick.1 | man page for ick |doc/convickt.1 | man page for convickt -|src/abcess.h | interface to functions linked with programs +|src/abcessh.in | template interface to functions linked with programs |src/arrgghh.c | option argument parsing for generated programs |src/bin2c.c | creates C code representations of binary files |src/cesspool.c | the INTERCAL runtime support code diff --git a/buildaux/Makefile.am b/buildaux/Makefile.am index 6238a6c..aa791f4 100644 --- a/buildaux/Makefile.am +++ b/buildaux/Makefile.am @@ -42,8 +42,6 @@ ick_lose.h : src/ick_lose.h $(LN_S) -f `test -f 'src/ick_lose.h' || echo '$(srcdir)/'`src/ick_lose.h ick_lose.h fiddle.h : src/fiddle.h $(LN_S) -f `test -f 'src/fiddle.h' || echo '$(srcdir)/'`src/fiddle.h fiddle.h -abcess.h : src/abcess.h - $(LN_S) -f `test -f 'src/abcess.h' || echo '$(srcdir)/'`src/abcess.h abcess.h ick_bool.h : src/ick_bool.h $(LN_S) -f `test -f 'src/ick_bool.h' || echo '$(srcdir)/'`src/ick_bool.h ick_bool.h yuk.h : src/yuk.h @@ -55,7 +53,7 @@ AM_YFLAGS = -d # installed. BUILT_SOURCES = parser.h ick-wrap.c pickwrap.c syslib.i syslib3.3i syslib4.4i \ syslib5.5i syslib6.6i syslib7.7i floatlib.i ecto_b98.c \ - ick_ec.h fiddle.h abcess.h ick_bool.h ick_lose.h yuk.h + ick_ec.h fiddle.h ick_bool.h ick_lose.h yuk.h noinst_LIBRARIES = libidiot.a libidiot_a_SOURCES = src/idiotism.oil libidiot.a: src/idiotism.oil oil$(EXEEXT) src/oil.h src/sizes.h src/ick.h \ @@ -108,9 +106,9 @@ latin1.o: bin2c$(EXEEXT_FOR_BUILD) src/latin1.bin ./bin2c$(EXEEXT_FOR_BUILD) ick_clc_cset_latin1 < `test -f 'src/latin1.bin' || echo '$(srcdir)/'`src/latin1.bin > latin1.c $(COMPILE) -c latin1.c -ickinclude_HEADERS = src/ick_ec.h src/fiddle.h src/abcess.h src/ick_lose.h \ - src/yuk.h src/ick_bool.h -nodist_ickinclude_HEADERS = config.h +ickinclude_HEADERS = src/ick_ec.h src/fiddle.h src/ick_lose.h src/yuk.h \ + src/ick_bool.h +nodist_ickinclude_HEADERS = config.h abcess.h dist_ickdata_DATA = src/atari.bin src/baudot.bin src/ebcdic.bin src/latin1.bin \ src/ick-wrap.c src/pickwrap.c COPYING # These necessary pit files are in nodist_ here because they're in EXTRA_DIST @@ -128,7 +126,7 @@ splint: $(ick_SOURCES) parser.h @echo "Running splint on ick..." -(for x in $(ick_SOURCES); do echo $(top_srcdir)/$$x; done) | xargs splint $(SPLINTOPTS) -exportlocal -redef -EXTRA_DIST = pit etc BUGS src/abcess.h src/feh.h src/fiddle.h src/ick_ec.h \ +EXTRA_DIST = pit etc BUGS src/abcessh.in src/feh.h src/fiddle.h src/ick_ec.h \ src/ick.h src/ick_lose.h src/oil.h src/pick1.h src/pick2.h \ src/sizes.h src/uncommon.h src/yuk.h src/parser.y src/lexer.l \ doc/Makefile doc/fdl-1-2.txi doc/fix83.pl doc/fixtoc.pl \ @@ -159,7 +157,7 @@ dist-hook: CLEANFILES = oilout*.c parser.y lexer.l ick-wrap.c pickwrap.c \ atari.c baudot.c ebcdic.c latin1.c ick.dvi \ syslib.i syslib3.3i syslib4.4i syslib5.5i \ - syslib6.6i syslib7.7i ick_ec.h fiddle.h abcess.h \ + syslib6.6i syslib7.7i ick_ec.h fiddle.h \ ick_lose.h yuk.h floatlib.i ecto_b98.c ick_bool.h # Distclean deletes the Makefile and thus requires reconfiguring, # and therefore this is a safe moment to delete the build tree @@ -220,4 +218,4 @@ $(top_srcdir)/buildaux/bconfigh.in: $(top_srcdir)/buildaux/buildconfig.ac cd $(top_srcdir)/buildaux && $(AUTOHEADER) buildconfig.ac rm -f stamp-h1 touch $@ -CONFIG_STATUS_DEPENDENCIES=$(top_srcdir)/buildaux/buildconfig $(top_srcdir)/buildaux/bconfigh.in +CONFIG_STATUS_DEPENDENCIES=$(top_srcdir)/buildaux/buildconfig $(top_srcdir)/buildaux/bconfigh.in $(top_srcdir)/src/abcessh.in diff --git a/configure.ac b/configure.ac index 4f2cf61..f490619 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. dnl Yes, that is a valid email address. If your mailer doesn't support nested dnl comments, then get a better mailer. AC_INIT([C-INTERCAL],[0.29],[[ais523(524\)x\((525)y)@bham.ac.uk]],[ick]) -AC_CONFIG_SRCDIR([src/abcess.h]) +AC_CONFIG_SRCDIR([src/perpet.c]) AC_CONFIG_HEADER([config.h:buildaux/configh.in]) AC_CONFIG_AUX_DIR([buildaux]) AM_INIT_AUTOMAKE([foreign dist-bzip2 dist-lzma tar-pax check-news @@ -32,14 +32,19 @@ dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC AC_HEADER_STDBOOL +if test "x$ac_cv_header_stdbool_h" == "xyes" +then +HAVE_STDBOOL_H=1 +fi AC_CHECK_HEADERS([sys/time.h unistd.h stdarg.h]) AC_CHECK_HEADERS([stdint.h],[HAVE_STDINT_H=1]) AC_SUBST(HAVE_STDINT_H) +AC_SUBST(HAVE_STDBOOL_H) dnl Checks for typedefs, structures, and compiler characteristics. dnl This Autoconf input is compatible with pre-C99 Autoconf, so to -dnl check for long long AC_CHECK_SIZEOF is used to test for a nonzero result, -dnl likewise for _Bool. +dnl check for long long AC_CHECK_SIZEOF is used to test for a nonzero +dnl result. AC_C_CONST AC_C_VOLATILE AC_CHECK_SIZEOF([long long int],[0]) @@ -57,6 +62,7 @@ AC_TYPE_UINT32_T # actual use in code) dislike mixing _Bool and varargs. if test "x$ac_cv_type__Bool" == "xyes" then +HAVE__BOOL=1 AC_MSG_CHECKING([[whether booleans can be passed via varargs]]) AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include @@ -90,14 +96,16 @@ test(12345,match,12345); test(23456,nomatch,1234); exit(0); ]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no) -AC_DEFINE([BOOL_VARARGS_BROKEN],[],dnl -[Define if _Bool works but cannot be passed via varargs.]) +AC_DEFINE([BOOL_VARARGS_BROKEN],[1],dnl +[Define to 1 if _Bool works but cannot be passed via varargs.]) ],[AC_MSG_RESULT([[unknown in a cross-compile, assuming no]]) -AC_DEFINE([BOOL_VARARGS_BROKEN],[],dnl -[Define if _Bool works but cannot be passed via varargs.]) +AC_DEFINE([BOOL_VARARGS_BROKEN],[1],dnl +[Define to 1 if _Bool works but cannot be passed via varargs.]) ]) fi +AC_SUBST(HAVE__BOOL) + AC_MSG_CHECKING([[whether yyrestart() is needed]]) # Write a lex program that will cause an error if yyrestart exists. echo '%% @@ -105,12 +113,12 @@ echo '%% float yyrestart(int, ...);' | $LEX AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "${LEX_OUTPUT_ROOT}.c" ]], [[exit(0);]])],[AC_MSG_RESULT(no)],[AC_DEFINE([NEED_YYRESTART],dnl -[],[Define if yyrestart() is necessary to yyparse a new file.]) +[1],[Define to 1 if yyrestart() is necessary to yyparse a new file.]) AC_MSG_RESULT(yes)]) rm -f ${LEX_OUTPUT_ROOT}.c if test "$interpval" != "no"; then -AC_DEFINE([HAVE_SYS_INTERPRETER], [], [Define if #! works on your system.]) +AC_DEFINE([HAVE_SYS_INTERPRETER], [1], [Define to 1 if #! works on your system.]) fi AC_DEFINE_UNQUOTED([EXEEXT],"$EXEEXT",[Extension to use on executable files.]) @@ -126,7 +134,7 @@ INCLUDE_HIDDEN_FROM_AUTOMAKE="include" AC_SUBST(PACKAGE_VERSION) AC_SUBST(INCLUDE_HIDDEN_FROM_AUTOMAKE) -AC_CONFIG_FILES([Makefile:buildaux/Makefile.in coopt.sh:src/cooptsh.in host.mak:buildaux/hostmak.in]) +AC_CONFIG_FILES([Makefile:buildaux/Makefile.in coopt.sh:src/cooptsh.in host.mak:buildaux/hostmak.in abcess.h:src/abcessh.in]) AC_OUTPUT() # After the output, chmod coopt.sh to be executable. chmod a+x coopt.sh @@ -193,4 +201,3 @@ mv config.status config.status.save (env -i "PATH=$PATH" $srcdir/buildaux/buildconfig "$BUILD_MACHINE_ARG" "$BUILD_CC_ARG" "$BUILD_CFLAGS_ARG" "$BUILD_LDFLAGS_ARG" "$BUILD_LIBS_ARG" "$BUILD_CPPFLAGS_ARG" "$BUILD_CPP_ARG") mv config.status config.status.build mv config.status.save config.status - diff --git a/src/abcess.h b/src/abcessh.in similarity index 92% rename from src/abcess.h rename to src/abcessh.in index e5dbb3f..9f0fba4 100644 --- a/src/abcess.h +++ b/src/abcessh.in @@ -1,4 +1,5 @@ -/* abcess.h -- functions used by compiled INTERCAL programs */ +/* abcess.h -- functions used by compiled INTERCAL programs -*- c -*- */ +/* This file is generated from abcessh.in */ /* AIS note: This header file now serves two purposes. For non-multithread programs, it serves as headers to the degenerated code and many support @@ -10,17 +11,38 @@ #include #include +/* We use the +1 trick here, as it works whether the values substituted in are + the null string, 0, or positive. */ +#ifndef HAVE_STDBOOL_H +# define HAVE_STDBOOL_H @HAVE_STDBOOL_H@ + 1 +# if HAVE_STDBOOL_H == 1 +# undef HAVE_STDBOOL_H +# endif +#endif +#ifndef HAVE__BOOL +# define HAVE__BOOL @HAVE__BOOL@ + 1 +# if HAVE__BOOL == 1 +# undef HAVE__BOOL +# endif +#endif +#ifndef HAVE_STDINT_H +# define HAVE_STDINT_H @HAVE_STDINT_H@ + 1 +# if HAVE_STDINT_H == 1 +# undef HAVE_STDINT_H +# endif +#endif + /* * Duplicates contents of ick_bool.h. Someday maybe we'll install this * and avoid such grottiness. */ /*@-redef@*/ #ifndef __bool_true_false_are_defined -# ifdef HAVE_STDBOOL_H +# if HAVE_STDBOOL_H >= 1 # include # else -# ifndef HAVE__BOOL -# ifdef HAVE_STDINT_H +# ifndef HAVE__BOOL >= 1 +# ifdef HAVE_STDINT_H >= 1 # include typedef int_fast8_t bool; # else diff --git a/src/ick_bool.h b/src/ick_bool.h index a9ec63c..ae9de78 100644 --- a/src/ick_bool.h +++ b/src/ick_bool.h @@ -7,11 +7,11 @@ /*@-redef@ -incondefs*/ #ifndef __bool_true_false_are_defined -# ifdef HAVE_STDBOOL_H +# if HAVE_STDBOOL_H >= 1 # include # else -# ifndef HAVE__BOOL -# ifdef HAVE_STDINT_H +# if !defined(HAVE__BOOL) || HAVE__BOOL < 1 +# if HAVE_STDINT_H >= 1 # include typedef int_fast8_t bool; # else -- 2.43.0