diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-20 13:15:17 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-20 13:15:17 +0000 |
commit | c436f700b1bba68a8e85b5bc8c15561797a89cee (patch) | |
tree | 4fb430d6fc61a79d5b9eb441961b3c02f6bc0a4a /libgfortran | |
parent | c5d4a10b529a6cf299b7e6d87b5aa762ff147d56 (diff) | |
download | gcc-c436f700b1bba68a8e85b5bc8c15561797a89cee.tar.gz |
PR target/16135
* acinclude.m4 (LIBGFOR_TARGET_ILP32): New check.
* configure.ac: Include LIBGFOR_TARGET_ILP32.
* configure: Regenerate.
* config.h.in: Likewise.
* libgfortran.h: Provide default definitions for C99 types
on ILP32 targets that don't have them.
PR target/17999
* configure.ac: Check for snprintf.
* configure: Regenerate.
* config.h.in: Likewise.
* intrinsics/date_and_time.c (date_and_time): Do not
use snprinf if it is not available.
* io/write.c (output_float): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90964 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r-- | libgfortran/ChangeLog | 18 | ||||
-rw-r--r-- | libgfortran/acinclude.m4 | 19 | ||||
-rw-r--r-- | libgfortran/config.h.in | 6 | ||||
-rwxr-xr-x | libgfortran/configure | 83 | ||||
-rw-r--r-- | libgfortran/configure.ac | 6 | ||||
-rw-r--r-- | libgfortran/intrinsics/date_and_time.c | 15 | ||||
-rw-r--r-- | libgfortran/io/write.c | 4 | ||||
-rw-r--r-- | libgfortran/libgfortran.h | 11 |
8 files changed, 160 insertions, 2 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 3324b0f7dfa..256e0411632 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,21 @@ +2004-11-20 Eric Botcazou <ebotcazou@libertysurf.fr> + + PR target/16135 + * acinclude.m4 (LIBGFOR_TARGET_ILP32): New check. + * configure.ac: Include LIBGFOR_TARGET_ILP32. + * configure: Regenerate. + * config.h.in: Likewise. + * libgfortran.h: Provide default definitions for C99 types + on ILP32 targets that don't have them. + + PR target/17999 + * configure.ac: Check for snprintf. + * configure: Regenerate. + * config.h.in: Likewise. + * intrinsics/date_and_time.c (date_and_time): Do not + use snprinf if it is not available. + * io/write.c (output_float): Likewise. + 2004-11-20 Steven G. Kargl <kargls@comcast.net> * Makefile.am: Add intrinsics/{umask.c,unlink.c,exit.c} diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4 index ebee89df856..87dc72283f9 100644 --- a/libgfortran/acinclude.m4 +++ b/libgfortran/acinclude.m4 @@ -83,3 +83,22 @@ AC_DEFUN([AC_LIBTOOL_DLOPEN]) AC_DEFUN([AC_PROG_LD]) ]) +dnl Check whether the target is ILP32. +AC_DEFUN([LIBGFOR_TARGET_ILP32], [ + AC_CACHE_CHECK([whether the target is ILP32], target_ilp32, [ + save_CFLAGS="$CFLAGS" + CFLAGS="-O2" + AC_TRY_LINK(,[ +if (sizeof(int) == 4 && sizeof(long) == 4 && sizeof(void *) == 4) + ; +else + undefined_function (); + ], + target_ilp32=yes, + target_ilp32=no) + CFLAGS="$save_CFLAGS"]) + if test $target_ilp32 = yes; then + AC_DEFINE(TARGET_ILP32, 1, + [Define to 1 if the target is ILP32.]) + fi + ]) diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in index d31c21b84c9..db4da7aaed6 100644 --- a/libgfortran/config.h.in +++ b/libgfortran/config.h.in @@ -135,6 +135,9 @@ /* libm includes sinhf */ #undef HAVE_SINHF +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + /* libm includes sqrtf */ #undef HAVE_SQRTF @@ -234,6 +237,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to 1 if the target is ILP32. */ +#undef TARGET_ILP32 + /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ #undef TIME_WITH_SYS_TIME diff --git a/libgfortran/configure b/libgfortran/configure index e486b4e9ec8..0e738dfde89 100755 --- a/libgfortran/configure +++ b/libgfortran/configure @@ -6822,7 +6822,8 @@ fi -for ac_func in getrusage times mkstemp strtof + +for ac_func in getrusage times mkstemp strtof snprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 @@ -10716,6 +10717,86 @@ _ACEOF fi fi +# Attempt to assert that the target is of common type in case we don't +# have C99 integer types at all. + + echo "$as_me:$LINENO: checking whether the target is ILP32" >&5 +echo $ECHO_N "checking whether the target is ILP32... $ECHO_C" >&6 +if test "${target_ilp32+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + save_CFLAGS="$CFLAGS" + CFLAGS="-O2" + if test x$gcc_no_link = xyes; then + { { echo "$as_me:$LINENO: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&5 +echo "$as_me: error: Link tests are not allowed after GCC_NO_EXECUTABLES." >&2;} + { (exit 1); exit 1; }; } +fi +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + +if (sizeof(int) == 4 && sizeof(long) == 4 && sizeof(void *) == 4) + ; +else + undefined_function (); + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + target_ilp32=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +target_ilp32=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + CFLAGS="$save_CFLAGS" +fi +echo "$as_me:$LINENO: result: $target_ilp32" >&5 +echo "${ECHO_T}$target_ilp32" >&6 + if test $target_ilp32 = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TARGET_ILP32 1 +_ACEOF + + fi + + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac index 3adcfd61c3d..f91b2604bc8 100644 --- a/libgfortran/configure.ac +++ b/libgfortran/configure.ac @@ -159,7 +159,7 @@ AC_CHECK_HEADER([complex.h],[AC_DEFINE([HAVE_COMPLEX_H], [1], [complex.h exists] AC_CHECK_LIB([m],[csin],[need_math="no"],[need_math="yes"]) # Check for library functions. -AC_CHECK_FUNCS(getrusage times mkstemp strtof) +AC_CHECK_FUNCS(getrusage times mkstemp strtof snprintf) # Check libc for getgid, getpid, getuid AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])]) @@ -226,6 +226,10 @@ AC_SUBST([MATH_OBJ],["$extra_math_obj"]) # to call gettimeofday if we have it. LIBGFOR_GETTIMEOFDAY +# Attempt to assert that the target is of common type in case we don't +# have C99 integer types at all. +LIBGFOR_TARGET_ILP32 + AC_CACHE_SAVE if test ${multilib} = yes; then diff --git a/libgfortran/intrinsics/date_and_time.c b/libgfortran/intrinsics/date_and_time.c index 63d18f5cb2d..e0b01234556 100644 --- a/libgfortran/intrinsics/date_and_time.c +++ b/libgfortran/intrinsics/date_and_time.c @@ -182,20 +182,35 @@ date_and_time (char *__date, if (__date) { +#if HAVE_SNPRINTF snprintf (date, DATE_LEN + 1, "%04d%02d%02d", values[0], values[1], values[2]); +#else + sprintf (date, "%04d%02d%02d", + values[0], values[1], values[2]); +#endif } if (__time) { +#if HAVE_SNPRINTF snprintf (timec, TIME_LEN + 1, "%02d%02d%02d.%03d", values[4], values[5], values[6], values[7]); +#else + sprintf (timec, "%02d%02d%02d.%03d", + values[4], values[5], values[6], values[7]); +#endif } if (__zone) { +#if HAVE_SNPRINTF snprintf (zone, ZONE_LEN + 1, "%+03d%02d", values[3] / 60, abs (values[3] % 60)); +#else + sprintf (zone, "%+03d%02d", + values[3] / 60, abs (values[3] % 60)); +#endif } #else /* if defined HAVE_NO_DATE_TIME */ /* We really have *nothing* to return, so return blanks and HUGE(0). */ diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c index f98ec1f1f36..a121a8f57aa 100644 --- a/libgfortran/io/write.c +++ b/libgfortran/io/write.c @@ -615,7 +615,11 @@ output_float (fnode *f, double value, int len) *(out++) = expchar; edigits--; } +#if HAVE_SNPRINTF snprintf (buffer, 32, "%+0*d", edigits, e); +#else + sprintf (buffer, "%+0*d", edigits, e); +#endif memcpy (out, buffer, edigits); } } diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h index bbe68247706..e73c00a480c 100644 --- a/libgfortran/libgfortran.h +++ b/libgfortran/libgfortran.h @@ -47,6 +47,17 @@ Boston, MA 02111-1307, USA. */ #include <inttypes.h> #endif +#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && defined(TARGET_ILP32) +typedef char int8_t; +typedef short int16_t; +typedef int int32_t; +typedef long long int64_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; +#endif + #if HAVE_SYS_TYPES_H #include <sys/types.h> #endif |