Commit a2a2059f by Bud Davis Committed by Paul Brook

re PR libfortran/15292 (libgfortran depends on c99 functionality round and roundf)

	PR gfortran/15292
	* intrinsics/c99_functions.c: New file.
	* Makefile.am: Add new file.
	* configure.ac: Added test for round/roundf.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
        * configure.h.in: Regenerate.

From-SVN: r83036
parent 2bd74949
2004-6-12 Bud Davis <bdavis9659@comcast.net>
Steve Kargl <sgk@troutmask.apl.washington.edu>
PR gfortran/15292
* intrinsics/c99_functions.c: New file.
* Makefile.am: Add new file.
* configure.ac: Added test for round/roundf.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.h.in: Regenerate.
2004-06-12 Steven G. Kargl <kargls@comcast.net> 2004-06-12 Steven G. Kargl <kargls@comcast.net>
* Makefile.am: Add rand.c and etime.c * Makefile.am: Add rand.c and etime.c
......
...@@ -37,6 +37,7 @@ gfor_helper_src= \ ...@@ -37,6 +37,7 @@ gfor_helper_src= \
intrinsics/associated.c \ intrinsics/associated.c \
intrinsics/abort.c \ intrinsics/abort.c \
intrinsics/args.c \ intrinsics/args.c \
intrinsics/c99_functions.c \
intrinsics/cpu_time.c \ intrinsics/cpu_time.c \
intrinsics/cshift0.c \ intrinsics/cshift0.c \
intrinsics/date_and_time.c \ intrinsics/date_and_time.c \
......
...@@ -118,12 +118,13 @@ am__objects_31 = $(am__objects_2) $(am__objects_3) $(am__objects_4) \ ...@@ -118,12 +118,13 @@ am__objects_31 = $(am__objects_2) $(am__objects_3) $(am__objects_4) \
am__objects_32 = backspace.lo close.lo endfile.lo format.lo inquire.lo \ am__objects_32 = backspace.lo close.lo endfile.lo format.lo inquire.lo \
list_read.lo lock.lo open.lo read.lo rewind.lo transfer.lo \ list_read.lo lock.lo open.lo read.lo rewind.lo transfer.lo \
unit.lo unix.lo write.lo unit.lo unix.lo write.lo
am__objects_33 = associated.lo abort.lo args.lo cpu_time.lo cshift0.lo \ am__objects_33 = associated.lo abort.lo args.lo c99_functions.lo \
date_and_time.lo eoshift0.lo eoshift2.lo etime.lo ishftc.lo \ cpu_time.lo cshift0.lo date_and_time.lo eoshift0.lo \
pack_generic.lo size.lo spread_generic.lo string_intrinsics.lo \ eoshift2.lo etime.lo ishftc.lo pack_generic.lo size.lo \
rand.lo random.lo reshape_generic.lo reshape_packed.lo \ spread_generic.lo string_intrinsics.lo rand.lo random.lo \
selected_kind.lo system_clock.lo transpose_generic.lo \ reshape_generic.lo reshape_packed.lo selected_kind.lo \
unpack_generic.lo in_pack_generic.lo in_unpack_generic.lo system_clock.lo transpose_generic.lo unpack_generic.lo \
in_pack_generic.lo in_unpack_generic.lo
am__objects_34 = am__objects_34 =
am__objects_35 = _abs_c4.lo _abs_c8.lo _abs_i4.lo _abs_i8.lo \ am__objects_35 = _abs_c4.lo _abs_c8.lo _abs_i4.lo _abs_i8.lo \
_abs_r4.lo _abs_r8.lo _exp_r4.lo _exp_r8.lo _exp_c4.lo \ _abs_r4.lo _abs_r8.lo _exp_r4.lo _exp_r8.lo _exp_c4.lo \
...@@ -309,6 +310,7 @@ gfor_helper_src = \ ...@@ -309,6 +310,7 @@ gfor_helper_src = \
intrinsics/associated.c \ intrinsics/associated.c \
intrinsics/abort.c \ intrinsics/abort.c \
intrinsics/args.c \ intrinsics/args.c \
intrinsics/c99_functions.c \
intrinsics/cpu_time.c \ intrinsics/cpu_time.c \
intrinsics/cshift0.c \ intrinsics/cshift0.c \
intrinsics/date_and_time.c \ intrinsics/date_and_time.c \
...@@ -1986,6 +1988,15 @@ args.obj: intrinsics/args.c ...@@ -1986,6 +1988,15 @@ args.obj: intrinsics/args.c
args.lo: intrinsics/args.c args.lo: intrinsics/args.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o args.lo `test -f 'intrinsics/args.c' || echo '$(srcdir)/'`intrinsics/args.c $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o args.lo `test -f 'intrinsics/args.c' || echo '$(srcdir)/'`intrinsics/args.c
c99_functions.o: intrinsics/c99_functions.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o c99_functions.o `test -f 'intrinsics/c99_functions.c' || echo '$(srcdir)/'`intrinsics/c99_functions.c
c99_functions.obj: intrinsics/c99_functions.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o c99_functions.obj `if test -f 'intrinsics/c99_functions.c'; then $(CYGPATH_W) 'intrinsics/c99_functions.c'; else $(CYGPATH_W) '$(srcdir)/intrinsics/c99_functions.c'; fi`
c99_functions.lo: intrinsics/c99_functions.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o c99_functions.lo `test -f 'intrinsics/c99_functions.c' || echo '$(srcdir)/'`intrinsics/c99_functions.c
cpu_time.o: intrinsics/cpu_time.c cpu_time.o: intrinsics/cpu_time.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cpu_time.o `test -f 'intrinsics/cpu_time.c' || echo '$(srcdir)/'`intrinsics/cpu_time.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cpu_time.o `test -f 'intrinsics/cpu_time.c' || echo '$(srcdir)/'`intrinsics/cpu_time.c
......
/* config.h.in. Generated from configure.in by autoheader. */ /* config.h.in. Generated from configure.ac by autoheader. */
/* Does gettimeofday take a single argument */ /* Does gettimeofday take a single argument */
#undef GETTIMEOFDAY_ONE_ARGUMENT #undef GETTIMEOFDAY_ONE_ARGUMENT
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
/* Define to 1 if you have a working `mmap' system call. */ /* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP #undef HAVE_MMAP
/* "c99 function" */
#undef HAVE_ROUND
/* "c99 function" */
#undef HAVE_ROUNDF
/* Define to 1 if you have the <stddef.h> header file. */ /* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H #undef HAVE_STDDEF_H
...@@ -75,9 +81,6 @@ ...@@ -75,9 +81,6 @@
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */ /* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT #undef PACKAGE_BUGREPORT
...@@ -99,8 +102,5 @@ ...@@ -99,8 +102,5 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME #undef TIME_WITH_SYS_TIME
/* Version number of package */
#undef VERSION
/* Define to `long' if <sys/types.h> does not define. */ /* Define to `long' if <sys/types.h> does not define. */
#undef off_t #undef off_t
...@@ -166,6 +166,10 @@ AC_CHECK_LIB([mx],[csin],[need_math="no"],[need_math="yes"]) ...@@ -166,6 +166,10 @@ AC_CHECK_LIB([mx],[csin],[need_math="no"],[need_math="yes"])
# Check for library functions. # Check for library functions.
AC_CHECK_FUNCS(getrusage times) AC_CHECK_FUNCS(getrusage times)
# Check for some C99 functions
AC_CHECK_LIB([m],[round],[AC_DEFINE([HAVE_ROUND],[1],["c99 function"])])
AC_CHECK_LIB([m],[roundf],[AC_DEFINE([HAVE_ROUNDF],[1],["c99 function"])])
# Let the user override this # Let the user override this
AC_ARG_ENABLE(cmath, AC_ARG_ENABLE(cmath,
AC_HELP_STRING([--enable-cmath],[Include complex math functions]), AC_HELP_STRING([--enable-cmath],[Include complex math functions]),
......
/* Implementation of various C99 functions
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of the GNU Fortran 95 runtime library (libgfortran).
Libgfortran is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Libgfortran is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with libgfortran; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "config.h"
#include <sys/types.h>
#include <math.h>
#include "libgfortran.h"
/* Algorithm by Steven G. Kargl. */
#ifndef HAVE_ROUND
/* Round to nearest integral value. If the argument is halfway between two
integral values then round away from zero. */
double
round(double x)
{
double t;
int i;
i = fpclassify(x);
if (i == FP_INFINITE || i == FP_NAN)
return (x);
if (x >= 0.0)
{
t = ceil(x);
if (t - x > 0.5)
t -= 1.0;
return (t);
}
else
{
t = ceil(-x);
if (t + x > 0.5)
t -= 1.0;
return (-t);
}
}
#endif
#ifndef HAVE_ROUNDF
/* Round to nearest integral value. If the argument is halfway between two
integral values then round away from zero. */
float
roundf(float x)
{
float t;
int i;
i = fpclassify(x);
if (i == FP_INFINITE || i == FP_NAN)
return (x);
if (x >= 0.0)
{
t = ceilf(x);
if (t - x > 0.5)
t -= 1.0;
return (t);
}
else
{
t = ceilf(-x);
if (t + x > 0.5)
t -= 1.0;
return (-t);
}
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment