diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-10-09 21:45:51 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-10-09 21:45:51 -0700 |
commit | 889501071aeae561b026fc298e0442d2ef4e433f (patch) | |
tree | 21441698c9bfa98d227790c5ec5ec0b0c9fdd29a /configure | |
parent | c318e1c4bc5dbdb1dbec46bd8962e20d5654de54 (diff) | |
download | txr-889501071aeae561b026fc298e0442d2ef4e433f.tar.gz txr-889501071aeae561b026fc298e0442d2ef4e433f.tar.bz2 txr-889501071aeae561b026fc298e0442d2ef4e433f.zip |
Ported to Cygwin.
TODO: there should be some type safety with the new wli macro
so that if it is forgotten, there will be a diagnostic.
* configure (lit_align): New configuration variable
and configuration test. Generates LIT_ALIGN in config.h.
Fixed the integer-holds-pointer test for the different output
from the nm program on Cygwin. The arrays become common symbols
marked C which do not show an offset attribute, only size:
one less column.
* filter.c (to_html_table, from_html_table): wrap wide string
literals with the wli macro. This must be done from now on for
all literals and initializes of arrays that are going to be
directly converted to type tagged val-s.
* lib.h (wli): New macro.
(auto_str, static_str, litptr, lit_noex): Handle wide literals on
platforms where they are aligned to only two bytes, such that we don't
have two bits in the pointer. We can still add our 11 bit type tag, but
then when recovering the pointer to the data, we have may have
to fix up the pointer.
* parser.l: Another portability issue here. Flex generates a scanner
which has #include <unistd.h> in the middle, after the source file's
own #includes which can introduce macros. On Cygwin, there is some
hygiene problem whereby our "noreturn" macro causes the <unistd.h>
header to generate bad syntax and fail to compile. Stupid Cygwin
and even stupider flex! The workaround is to include <unistd.h>
at the top in the flex source.
* stream.c (string_out_put_char): This is one more place where
the string literal handling hack spreads.
* txr.c (version): Wrap string in wli.
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 85 |
1 files changed, 84 insertions, 1 deletions
@@ -230,6 +230,15 @@ intptr [$intptr] value can be converted to it. If this is blank, the configure script will try to auto detect it. +lit_align [$lit_align] + + Specifies alignment for wide string literals. This is guessed + from the size of the wchar_t type. If your wchar_t type is two byte wide, but + wide literals are aligned to four bytes, then you should specify this. This + will eliminate some kludges in the program. There is no easy way to check + for this withut generating and running a C program, which is unfriendly + for cross-compiling! + inline [$inline] Specifies the syntax for defining an inline function, in such @@ -620,7 +629,15 @@ char sizeof_longlong_t[sizeof (longlong_t)]; while read symbol type offset size ; do eval "size=$(( 0$size + 0 ))" - eval $(printf "%s=%d\n" "$symbol" "$size") + symbol=${symbol#_} + if [ $type == "C" ] ; then + size=$offset + fi + case "$symbol" in + sizeof* ) + eval $(printf "%s=%d\n" "$symbol" "$size") + ;; + esac done < conftest.syms rm -f conftest.syms conftest.o @@ -652,6 +669,68 @@ intptr_max_expr="((((($intptr) 1 << $((sizeof_ptr * 8 - 2))) - 1) << 1) + 1)" printf "#define INT_PTR_MAX %s\n" "$intptr_max_expr" >> config.h printf "#define INT_PTR_MIN (-INT_PTR_MAX)\n" >> config.h +# +# Alignment of wchar_t +# +# What we really want to know is the alignment of wide string literals +# like L"wide literal". +# +# We make pessimistic assumption that the size of the wchar_t type is this +# alignment. +# +# There is no easy way to get the information without running a compiled +# program. +# + +printf "Conservatively guessing the alignment of wide literals ... " + +if [ -z "$lit_align" ] ; then + cat > conftest.c <<! +#include <wchar.h> +char sizeof_wchar_t[sizeof (wchar_t)]; +! + rm -f conftest.o conftest.syms + + if ! make conftest.syms > conftest.err 2>&1 ; then + printf "failed\n\n" + + printf "Errors from compilation: \n\n" + cat conftest.err + exit 1 + fi + + sizeof_wchar_t=0 + + while read symbol type offset size ; do + eval "size=$(( 0$size + 0 ))" + symbol=${symbol#_} + if [ $type == "C" ] ; then + size=$offset + fi + case "$symbol" in + sizeof* ) + eval $(printf "%s=%d\n" "$symbol" "$size") + ;; + esac + done < conftest.syms + + rm -f conftest.syms conftest.o + + if [ $sizeof_wchar_t -eq 0 ] ; then + printf "failed\n" + exit 1 + fi + + lit_align=$sizeof_wchar_t +fi + +printf "%d\n" "$lit_align" +printf "#define LIT_ALIGN %d\n" "$lit_align" >> config.h + +# +# Inline functions +# + printf "Checking how to declare inline functions ... " if [ -z "$inline" ] ; then @@ -687,6 +766,10 @@ fi printf '"%s"\n' "$inline" printf "#define INLINE $inline\n" >> config.h +# +# Valgrind +# + if [ -n "$valgrind" ] ; then printf "Checking valgrind API availability ... " |