ssize_t [patch]
Zack Weinberg
zack@wolery.cumb.org
Tue Apr 25 20:14:00 GMT 2000
On Tue, Apr 25, 2000 at 06:35:03PM -0700, Zack Weinberg wrote:
> On Tue, Apr 25, 2000 at 08:53:49PM -0400, Kaveh R. Ghazi wrote:
> > I already checked in my patch, but feel free to nuke it yourself.
> >
> > BTW, acconfig.h is now down to 3 HAVE_GAS_* features and the gettext
> > entries. Want to take a crack at the HAVE_GAS_* ones?
>
> Sure, why not... may be a bit, the GAS feature checks are hideous.
Okay. Here is a revised patch which includes my ssize_t checks and
the fixes for HAVE_GAS_*.
Whoever wrote the GAS feature tests didn't understand Autoconf very
well, particularly in the way you write a cached check. And the test
for fild[s] and fist[s] was actually wrong.
BTW, I'm not sure TYPE_MINIMUM, TYPE_MAXIMUM, and TYPE_SIGNED are good
choices for macro names. We have a lot of macros that begin with
TYPE_ already, and they all operate on tree nodes. Do you have any
ideas for a better prefix?
zw
* acconfig.h: Remove HAVE_GAS templates and TOP marker. Add
ssize_t template.
* configure.in: Add check for ssize_t. Rewrite checks for
assembler features to use 3 argument AC_DEFINE, and to cache
test results properly.
* configure: Regenerate.
* config.in: Regenerate.
* system.h: Add TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM macros
(borrowed from shellutils). Add default definitions for
UCHAR_MAX and SSIZE_MAX.
* cpplex.c: Remove default definition of UCHAR_MAX.
===================================================================
Index: acconfig.h
--- acconfig.h 2000/04/26 00:03:37 1.48
+++ acconfig.h 2000/04/26 03:07:06
@@ -13,14 +13,5 @@
/* Define as 1 if you have the stpcpy function. */
#undef HAVE_STPCPY
-/* Define if your assembler supports specifying the maximum number
- of bytes to skip when using the GAS .p2align command. */
-#undef HAVE_GAS_MAX_SKIP_P2ALIGN
-
-/* Define if your assembler supports .balign and .p2align. */
-#undef HAVE_GAS_BALIGN_AND_P2ALIGN
-
-/* Define if your assembler uses the old HImode fild and fist notation. */
-#undef HAVE_GAS_FILDS_FISTS
-
-@TOP@
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef ssize_t
===================================================================
Index: configure.in
--- configure.in 2000/04/26 00:03:37 1.362
+++ configure.in 2000/04/26 03:07:06
@@ -431,6 +431,11 @@ AC_CHECK_FUNCS(strtoul bsearch putenv po
# Make sure wchar_t is available
#AC_CHECK_TYPE(wchar_t, unsigned int)
+# The default for this is int, because the default for size_t is
+# unsigned int; also, historical systems (SunOS 4) that didn't have
+# ssize_t used int in its place.
+AC_CHECK_TYPE(ssize_t, int)
+
gcc_AC_FUNC_VFPRINTF_DOPRNT
gcc_AC_FUNC_PRINTF_PTR
@@ -4222,64 +4227,34 @@ fi
# If we have gas in the build tree, make a link to it.
if test -f ../gas/Makefile; then
- rm -f as; $symbolic_link ../gas/as-new$host_exeext as$host_exeext 2>/dev/null
+ rm -f as
+ $symbolic_link ../gas/as-new$host_exeext as$host_exeext 2>/dev/null
fi
# If we have nm in the build tree, make a link to it.
if test -f ../binutils/Makefile; then
- rm -f nm; $symbolic_link ../binutils/nm-new$host_exeext nm$host_exeext 2>/dev/null
+ rm -f nm
+ $symbolic_link ../binutils/nm-new$host_exeext nm$host_exeext 2>/dev/null
fi
# If we have ld in the build tree, make a link to it.
if test -f ../ld/Makefile; then
-# if test x$use_collect2 = x; then
-# rm -f ld; $symbolic_link ../ld/ld-new$host_exeext ld$host_exeext 2>/dev/null
-# else
- rm -f collect-ld; $symbolic_link ../ld/ld-new$host_exeext collect-ld$host_exeext 2>/dev/null
-# fi
+ rm -f collect-ld
+ $symbolic_link ../ld/ld-new$host_exeext collect-ld$host_exeext 2>/dev/null
fi
-# Figure out what assembler alignment features are present.
-AC_MSG_CHECKING(assembler alignment features)
-gcc_cv_as=
-gcc_cv_as_alignment_features=
-gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas
-if test -x "$DEFAULT_ASSEMBLER"; then
+# Locate gas.
+AC_MSG_CHECKING(for gas)
+AC_CACHE_VAL(gcc_cv_as,
+[if test -x "$DEFAULT_ASSEMBLER"; then
gcc_cv_as="$DEFAULT_ASSEMBLER"
elif test -x "$AS"; then
gcc_cv_as="$AS"
-elif test -x as$host_exeext; then
+elif test -x as$host_exeext || test -h as$host_exeext; then
# Build using assembler in the current directory.
+ # This includes the case of a unified build of gcc and binutils,
+ # because of the code above.
gcc_cv_as=./as$host_exeext
-elif test -f $gcc_cv_as_gas_srcdir/configure.in -a -f ../gas/Makefile; then
- # Single tree build which includes gas.
- for f in $gcc_cv_as_gas_srcdir/configure $gcc_cv_as_gas_srcdir/configure.in $gcc_cv_as_gas_srcdir/Makefile.in
- do
-changequote(,)dnl
- gcc_cv_gas_version=`grep '^VERSION=[0-9]*\.[0-9]*' $f`
-changequote([,])dnl
- if test x$gcc_cv_gas_version != x; then
- break
- fi
- done
-changequote(,)dnl
- gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([0-9]*\)"`
- gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[0-9]*\.\([0-9]*\)"`
-changequote([,])dnl
- if test x$gcc_cv_gas_major_version != x -a x$gcc_cv_gas_minor_version != x; then
- # Gas version 2.6 and later support for .balign and .p2align.
- # bytes to skip when using .p2align.
- if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 6 -o "$gcc_cv_gas_major_version" -gt 2; then
- gcc_cv_as_alignment_features=".balign and .p2align"
- AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN)
- fi
- # Gas version 2.8 and later support specifying the maximum
- # bytes to skip when using .p2align.
- if test "$gcc_cv_gas_major_version" -eq 2 -a "$gcc_cv_gas_minor_version" -ge 8 -o "$gcc_cv_gas_major_version" -gt 2; then
- gcc_cv_as_alignment_features=".p2align including maximum skip"
- AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN)
- fi
- fi
elif test x$host = x$target; then
# Native build.
# Search the same directories that the installed compiler will
@@ -4303,11 +4278,6 @@ elif test x$host = x$target; then
test_prefix=$exec_prefix
fi
- # If the loop below does not find an assembler, then use whatever
- # one we can find in the users's path.
- # user's path.
- as=as$host_exeext
-
test_dirs="$test_prefix/lib/gcc-lib/$target/$gcc_version \
$test_prefix/lib/gcc-lib/$target \
/usr/lib/gcc/$target/$gcc_version \
@@ -4331,97 +4301,123 @@ elif test x$host = x$target; then
break;
fi
done
+
+ # If we still haven't found it, try along $PATH.
+ if test x$gcc_cv_as = x; then
+ IFS="${IFS= }"; ac_save_IFS="$IFS" IFS="$IFS,"
+ set fnord $PATH; shift
+ IFS="$ac_save_IFS"
+
+ for dir
+ do if test -f $dir/as$host_exeext; then
+ gcc_cv_as=$dir/as$host_exeext
+ break
+ fi
+ done
+ fi
+fi
+])
+if test x$gcc_cv_as = x
+then AC_MSG_RESULT(not found)
+else AC_MSG_RESULT($gcc_cv_as)
fi
+
if test x$gcc_cv_as != x; then
- # Check if we have .balign and .p2align
- echo ".balign 4" > conftest.s
+ # Check for support for .balign and .p2align.
+ AC_CACHE_CHECK(for .balign and .p2align, gcc_cv_as_balign_p2align,
+ [echo ".balign 4" > conftest.s
echo ".p2align 2" >> conftest.s
- if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
- gcc_cv_as_alignment_features=".balign and .p2align"
- AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN)
+ if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1
+ then gcc_cv_as_balign_p2align=yes
+ else gcc_cv_as_balign_p2align=no
+ fi
+ rm -f conftest.s conftest.o])
+ if test $gcc_cv_as_balign_p2align = yes
+ then AC_DEFINE(HAVE_GAS_BALIGN_AND_P2ALIGN, 1,
+ [Define if your assembler supports .balign and .p2align.])
fi
- rm -f conftest.s conftest.o
+
# Check if specifying the maximum bytes to skip when
# using .p2align is supported.
- echo ".p2align 4,,7" > conftest.s
- if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
- gcc_cv_as_alignment_features=".p2align including maximum skip"
- AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN)
+ AC_CACHE_CHECK(for maximum skip with .p2align,
+ gcc_cv_as_p2align_max_skip,
+ [echo ".p2align 4,,7" > conftest.s
+ if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1
+ then gcc_cv_as_p2align_max_skip=yes
+ else gcc_cv_as_p2align_max_skip=no
fi
- rm -f conftest.s conftest.o
-fi
-AC_MSG_RESULT($gcc_cv_as_alignment_features)
+ rm -f conftest.s conftest.o])
+ if test $gcc_cv_as_p2align_max_skip = yes
+ then AC_DEFINE(HAVE_GAS_MAX_SKIP_P2ALIGN, 1,
+ [Define if your assembler supports specifying the maximum number of
+ bytes to skip with a .p2align directive.])
+ fi
-AC_MSG_CHECKING(assembler subsection support)
-gcc_cv_as_subsections=
-if test x$gcc_cv_as != x; then
- # Check if we have .subsection
- echo ".subsection 1" > conftest.s
- if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
- gcc_cv_as_subsections=".subsection"
- if test -x nm$host_exeext; then
- gcc_cv_nm=./nm$host_exeext
- elif test x$host = x$target; then
- # Native build.
- gcc_cv_nm=nm$host_exeext
- fi
- if test x$gcc_cv_nm != x; then
- cat > conftest.s <<EOF
-conftest_label1: .word 0
+ # Check for .subsection and .subsection -1.
+ AC_CACHE_CHECK(for working .subsection, gcc_cv_as_subsections,
+ [nm=
+ gcc_cv_as_subsections=unknown
+ if test -x nm$host_exeext
+ then nm=./nm$host_exeext
+ elif test x$host = x$target
+ then nm=nm$host_exeext
+ fi
+
+ if test x$nm != x; then
+ cat >conftest.s <<EOF
+label1: .word 0
.subsection -1
-conftest_label2: .word 0
+label2: .word 0
.previous
EOF
- if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
- $gcc_cv_nm conftest.o | grep conftest_label1 > conftest.nm1
- $gcc_cv_nm conftest.o | grep conftest_label2 | sed -e 's/label2/label1/' > conftest.nm2
- if cmp conftest.nm1 conftest.nm2 > /dev/null 2>&1; then
- :
- else
- gcc_cv_as_subsections="working .subsection -1"
- AC_DEFINE(HAVE_GAS_SUBSECTION_ORDERING, 1,
-[Define if your assembler supports .subsection and .subsection -1 starts
- emitting at the beginning of your section.])
- fi
+ if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+ $nm conftest.o | grep label1 > conftest.nm1
+ $nm conftest.o | sed -ne 's/label2/label1/p' > conftest.nm2
+ if cmp conftest.nm1 conftest.nm2 > /dev/null 2>&1
+ then gcc_cv_as_subsections=no
+ else gcc_cv_as_subsections=yes
fi
+ else gcc_cv_as_subsections=no
fi
fi
rm -f conftest.s conftest.o conftest.nm1 conftest.nm2
-fi
-AC_MSG_RESULT($gcc_cv_as_subsections)
+ ])
+ if test $gcc_cv_as_subsections = yes
+ then AC_DEFINE(HAVE_GAS_SUBSECTION_ORDERING, 1,
+ [Define if your assembler supports .subsection and .subsection -1 starts
+ emitting at the beginning of your section.])
+ fi
-AC_MSG_CHECKING(assembler weak support)
-gcc_cv_as_weak=
-if test x$gcc_cv_as != x; then
# Check if we have .weak
- echo " .weak foobar" > conftest.s
- if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
- AC_DEFINE(HAVE_GAS_WEAK, 1,
+ AC_CACHE_CHECK(for .weak, gcc_cv_as_weak,
+ [echo " .weak foobar" > conftest.s
+ if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1
+ then gcc_cv_as_weak=yes
+ else gcc_cv_as_weak=no
+ fi
+ rm -f conftest.s conftest.o])
+ if test $gcc_cv_as_weak = yes
+ then AC_DEFINE(HAVE_GAS_WEAK, 1,
[Define if your assembler supports .weak.])
- gcc_cv_as_weak="yes"
fi
- rm -f conftest.s conftest.o conftest.nm1 conftest.nm2
-fi
-AC_MSG_RESULT($gcc_cv_as_weak)
-AC_MSG_CHECKING(assembler hidden support)
-gcc_cv_as_hidden=
-if test x$gcc_cv_as != x; then
# Check if we have .hidden
- echo " .hidden foobar" > conftest.s
- echo "foobar:" >> conftest.s
- if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
- AC_DEFINE(HAVE_GAS_HIDDEN, 1,
+ AC_CACHE_CHECK(for .hidden, gcc_cv_as_hidden,
+ [echo " .hidden foobar" > conftest.s
+ if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1
+ then gcc_cv_as_hidden=yes
+ else gcc_cv_as_hidden=no
+ fi
+ rm -f conftest.s conftest.o])
+ if test $gcc_cv_as_hidden = yes
+ then AC_DEFINE(HAVE_GAS_HIDDEN, 1,
[Define if your assembler supports .hidden.])
- gcc_cv_as_hidden="yes"
fi
- rm -f conftest.s conftest.o conftest.nm1 conftest.nm2
fi
-AC_MSG_RESULT($gcc_cv_as_hidden)
case "$target" in
sparc*-*-*)
- AC_CACHE_CHECK([assembler .register pseudo-op support],
+ AC_CACHE_CHECK(for .register,
gcc_cv_as_register_pseudo_op, [
gcc_cv_as_register_pseudo_op=unknown
if test x$gcc_cv_as != x; then
@@ -4478,7 +4474,7 @@ changequote([, ])
esac
if test "x$gcc_cv_as_flags64" != xno; then
- AC_CACHE_CHECK([for assembler offsetable %lo() support],
+ AC_CACHE_CHECK([for offsetable %lo()],
gcc_cv_as_offsetable_lo10, [
gcc_cv_as_offsetable_lo10=unknown
if test "x$gcc_cv_as" != x; then
@@ -4510,22 +4506,22 @@ changequote([, ])
changequote(,)dnl
i[34567]86-*-*)
changequote([,])dnl
- AC_MSG_CHECKING(assembler instructions)
- gcc_cv_as_instructions=
if test x$gcc_cv_as != x; then
- set "filds fists" "filds mem; fists mem"
- while test $# -gt 0
- do
- echo "$2" > conftest.s
- if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
- gcc_cv_as_instructions=${gcc_cv_as_instructions}$1" "
- AC_DEFINE_UNQUOTED(HAVE_GAS_`echo "$1" | tr '[a-z ]' '[A-Z_]'`)
- fi
- shift 2
- done
- rm -f conftest.s conftest.o
+ AC_CACHE_CHECK(syntax of HImode fild and fist, gcc_cv_as_fild_fist,
+ [echo "fild mem; fist mem" > conftest.s
+ echo "filds mem; fists mem" >conftest2.s
+ if $gcc_cv_as -o conftest.o conftest.s
+ then gcc_cv_as_fild_fist=new
+ elif $gcc_cv_as -o conftest2.o conftest2.s
+ then gcc_cv_as_fild_fist=old
+ else AC_MSG_ERROR(neither fild nor filds works)
+ fi
+ rm -f conftest.s conftest.o conftest2.s conftest2.o])
+ if test $gcc_cv_as_fild_fist = old
+ then AC_DEFINE(HAVE_GAS_FILDS_FISTS, 1,
+[Define if your assembler uses the old HImode fild and fist notation.])
+ fi
fi
- AC_MSG_RESULT($gcc_cv_as_instructions)
;;
esac
===================================================================
Index: system.h
--- system.h 2000/04/25 11:21:13 1.65
+++ system.h 2000/04/26 03:07:07
@@ -236,6 +236,25 @@ extern int errno;
# endif /* defined(HOST_BITS_PER_LONG) && defined(HOST_BITS_PER_LONGLONG) */
#endif /* ! HOST_WIDEST_INT */
+/* Capability for creating _MAX and _MIN macros if they do not already
+ exist. Currently we only need SSIZE_MAX and UCHAR_MAX, but... */
+
+/* The extra casts work around common compiler bugs. */
+#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
+ It is necessary at least when t == time_t. */
+#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
+ ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
+#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
+
+#ifndef UCHAR_MAX
+#define UCHAR_MAX TYPE_MAXIMUM (unsigned char)
+#endif
+
+#ifndef SSIZE_MAX
+#define SSIZE_MAX TYPE_MAXIMUM (ssize_t)
+#endif
+
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
===================================================================
Index: cpplex.c
--- cpplex.c 2000/04/25 19:32:36 1.25
+++ cpplex.c 2000/04/26 03:07:07
@@ -1729,10 +1729,6 @@ find_position (start, limit, linep)
designated initializers, it can be constant data; otherwise, it is
set up at runtime by _cpp_init_input_buffer. */
-#ifndef UCHAR_MAX
-#define UCHAR_MAX 255 /* assume 8-bit bytes */
-#endif
-
#if (GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L)
#define init_chartab() /* nothing */
#define CHARTAB static const unsigned char chartab[UCHAR_MAX + 1] = {
More information about the Gcc-patches
mailing list