This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: i386/cygwin fpu hard-float [l]{0-2}rint[lf]? implementation pt. 1


Hi Dave,

After looking at it, I tend to agree with you that you have really provided fastmath versions of the functions. In keeping with that, I renamed the functions appropriately, removed the inclusion of common code (not needed), and fixed up math.h (can't assume all types exist) and added the functions to libc/machine/i386/machine/fastmath.h.

I have included the modified patch with this. Please look at it and try it out if you are ok with it.

The consequence of my tinkering is that there is no default versions for lrintl, rintl, llrint, llrintf, and llrintl (i.e. the new functions). This could be remedied by adding s* C code that calls the _f_ versions for the time-being until they are eventually added to the common directory. The alternative is that -ffast-math is required to use these functions. I'll let you decide which you prefer. In the soft-float case, the functions don't exist.

-- Jeff J.

Dave Korn wrote:

Hi Jeff,


  Here's part 1 of the new hw fp math functions for x86.  It adds the
implementations themselves.  There's some documentation in the C files, but nothing
trying to chew it yet.  I added the prototypes to math.h unconditionally - it's just
occurred to me as an afterthought that I should probably have put them in
fastmath.h, so I guess I'll need to respin this or just give you a follow-on patch
that rolls back math.h and moves the prototypes across, at your preference.

  It's not customary to post a diff of the regenerated files, but I've attached one
here because I'd like to ask you to eyeball it.  There seems to be a whole lot of
peturbation that I wouldn't expect from the changes I made, I'm not sure if I don't
have something wrong in my autotools environment or if perhaps there are some
differences in how the cygwin versions regenerate?

  I tested it reasonably thoroughly.  The tests I ran included two of BYTE's nbench
benchmarks, whetstone and dhrystone, kahan's paranoia, guenther's tramp-3d and
fourmilabs' fbench.  None showed any differences in results apart from increased
performance.  (They did reveal some existing problems in our implementation,
specifically with -ffast-math, but that's for another day).


Anyway, here it is. Subject to whatever you decide about the header prototypes, OK?


newlib/ChangeLog


2007-12-18 Dave Korn <dave.korn@artimi.com>

	* libc/include/math.h (llrint, llrintf, rintl, lrintl, llrintl):  Add
	prototypes.
	* libm/machine/i386/Makefile.am (LIB_SOURCES):  Add new files sf_rint.c,
	sf_lrint.c, sf_llrint.c, s_rint.c, s_lrint.c, s_llrint.c, sl_rint.c,
	sl_lrint.c and sl_llrint.c.
	(lib_a-s_lrint.$(OBJEXT), lib_a-s_rint.$(OBJEXT), lib_a-sf_lrint.$(OBJEXT),
	lib_a-sf_rint.$(OBJEXT)):  Add explicit dependencies on common sources
	which are directly included by i386 MD implementations when !FAST_MATH.
	* libm/machine/i386/Makefile.in:  Regenerated.
	* libm/machine/i386/s_llrint.c, libm/machine/i386/s_lrint.c,
	libm/machine/i386/s_rint.c, libm/machine/i386/sf_llrint.c,
	libm/machine/i386/sf_lrint.c, libm/machine/i386/sf_rint.c,
	libm/machine/i386/sl_llrint.c, libm/machine/i386/sl_lrint.c,
	libm/machine/i386/sl_rint.c:  New files.


cheers, DaveK


? libm/machine/i386/autom4te.cache
Index: libc/include/math.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/math.h,v
retrieving revision 1.31
diff -u -p -r1.31 math.h
--- libc/include/math.h	7 Sep 2007 15:30:59 -0000	1.31
+++ libc/include/math.h	18 Dec 2007 19:55:45 -0000
@@ -226,6 +226,7 @@ extern double scalbln _PARAMS((double, l
 extern double tgamma _PARAMS((double));
 extern double nearbyint _PARAMS((double));
 extern long int lrint _PARAMS((double));
+extern _LONG_LONG int llrint _PARAMS((double));
 extern double round _PARAMS((double));
 extern long int lround _PARAMS((double));
 extern double trunc _PARAMS((double));
@@ -292,6 +293,7 @@ extern float scalblnf _PARAMS((float, lo
 extern float tgammaf _PARAMS((float));
 extern float nearbyintf _PARAMS((float));
 extern long int lrintf _PARAMS((float));
+extern _LONG_LONG llrintf _PARAMS((float));
 extern float roundf _PARAMS((float));
 extern long int lroundf _PARAMS((float));
 extern float truncf _PARAMS((float));
@@ -330,6 +332,11 @@ extern float erfcf _PARAMS((float));
 extern float hypotf _PARAMS((float, float));
 #endif /* ! defined (_REENT_ONLY) */
 
+/* Other long double precision functions.  */
+extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE));
+extern long int lrintl _PARAMS((_LONG_DOUBLE));
+extern _LONG_LONG llrintl _PARAMS((_LONG_DOUBLE));
+
 #endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L */
 
 #if !defined (__STRICT_ANSI__) || defined(__cplusplus)
Index: libm/machine/i386/Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/libm/machine/i386/Makefile.am,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.am
--- libm/machine/i386/Makefile.am	24 May 2007 17:33:42 -0000	1.4
+++ libm/machine/i386/Makefile.am	18 Dec 2007 19:55:45 -0000
@@ -8,8 +8,12 @@ AM_CCASFLAGS = $(INCLUDES)
 
 LIB_SOURCES = \
 	f_atan2.S f_atan2f.S f_exp.c f_expf.c \
-	f_frexp.S f_frexpf.S f_log.S f_logf.S f_log10.S f_log10f.S \
-	f_ldexp.S f_ldexpf.S f_pow.c f_powf.c f_tan.S f_tanf.S f_math.h i386mach.h
+	f_frexp.S f_frexpf.S f_llrint.c f_llrintf.c f_llrintl.c \
+	f_log.S f_logf.S f_log10.S f_log10f.S \
+	f_ldexp.S f_ldexpf.S f_lrint.c f_lrintf.c f_lrintl.c \
+	f_pow.c f_powf.c f_rint.c f_rintf.c f_rintl.c \
+	f_tan.S f_tanf.S f_math.h \
+	i386mach.h 
 
 libi386_la_LDFLAGS = -Xcompiler -nostdlib
 
@@ -29,3 +33,4 @@ include $(srcdir)/../../../Makefile.shar
 
 ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..
 CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
+
Index: libm/machine/i386/Makefile.in
===================================================================
RCS file: /cvs/src/src/newlib/libm/machine/i386/Makefile.in,v
retrieving revision 1.11
diff -u -p -r1.11 Makefile.in
--- libm/machine/i386/Makefile.in	24 May 2007 17:33:42 -0000	1.11
+++ libm/machine/i386/Makefile.in	18 Dec 2007 19:55:46 -0000
@@ -45,7 +45,11 @@ DIST_COMMON = $(srcdir)/../../../Makefil
 	$(am__configure_deps) $(srcdir)/../../../../mkinstalldirs \
 	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
 	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
-	$(srcdir)/../../../../ltmain.sh \
+	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
+	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
+	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
+	$(srcdir)/../../../../compile $(srcdir)/../../../../compile \
+	$(srcdir)/../../../../compile $(srcdir)/../../../../ltmain.sh \
 	$(srcdir)/../../../../config.guess \
 	$(srcdir)/../../../../config.sub
 subdir = .
@@ -68,18 +72,25 @@ lib_a_LIBADD =
 am__objects_1 = lib_a-f_atan2.$(OBJEXT) lib_a-f_atan2f.$(OBJEXT) \
 	lib_a-f_exp.$(OBJEXT) lib_a-f_expf.$(OBJEXT) \
 	lib_a-f_frexp.$(OBJEXT) lib_a-f_frexpf.$(OBJEXT) \
-	lib_a-f_log.$(OBJEXT) lib_a-f_logf.$(OBJEXT) \
-	lib_a-f_log10.$(OBJEXT) lib_a-f_log10f.$(OBJEXT) \
-	lib_a-f_ldexp.$(OBJEXT) lib_a-f_ldexpf.$(OBJEXT) \
+	lib_a-f_llrint.$(OBJEXT) lib_a-f_llrintf.$(OBJEXT) \
+	lib_a-f_llrintl.$(OBJEXT) lib_a-f_log.$(OBJEXT) \
+	lib_a-f_logf.$(OBJEXT) lib_a-f_log10.$(OBJEXT) \
+	lib_a-f_log10f.$(OBJEXT) lib_a-f_ldexp.$(OBJEXT) \
+	lib_a-f_ldexpf.$(OBJEXT) lib_a-f_lrint.$(OBJEXT) \
+	lib_a-f_lrintf.$(OBJEXT) lib_a-f_lrintl.$(OBJEXT) \
 	lib_a-f_pow.$(OBJEXT) lib_a-f_powf.$(OBJEXT) \
-	lib_a-f_tan.$(OBJEXT) lib_a-f_tanf.$(OBJEXT)
+	lib_a-f_rint.$(OBJEXT) lib_a-f_rintf.$(OBJEXT) \
+	lib_a-f_rintl.$(OBJEXT) lib_a-f_tan.$(OBJEXT) \
+	lib_a-f_tanf.$(OBJEXT)
 @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 LTLIBRARIES = $(noinst_LTLIBRARIES)
 libi386_la_LIBADD =
 am__objects_2 = f_atan2.lo f_atan2f.lo f_exp.lo f_expf.lo f_frexp.lo \
-	f_frexpf.lo f_log.lo f_logf.lo f_log10.lo f_log10f.lo \
-	f_ldexp.lo f_ldexpf.lo f_pow.lo f_powf.lo f_tan.lo f_tanf.lo
+	f_frexpf.lo f_llrint.lo f_llrintf.lo f_llrintl.lo f_log.lo \
+	f_logf.lo f_log10.lo f_log10f.lo f_ldexp.lo f_ldexpf.lo \
+	f_lrint.lo f_lrintf.lo f_lrintl.lo f_pow.lo f_powf.lo \
+	f_rint.lo f_rintf.lo f_rintl.lo f_tan.lo f_tanf.lo
 @USE_LIBTOOL_TRUE@am_libi386_la_OBJECTS = $(am__objects_2)
 libi386_la_OBJECTS = $(am_libi386_la_OBJECTS)
 @USE_LIBTOOL_TRUE@am_libi386_la_rpath =
@@ -177,15 +188,8 @@ STRIP = @STRIP@
 USE_LIBTOOL_FALSE = @USE_LIBTOOL_FALSE@
 USE_LIBTOOL_TRUE = @USE_LIBTOOL_TRUE@
 VERSION = @VERSION@
-ac_ct_AR = @ac_ct_AR@
-ac_ct_AS = @ac_ct_AS@
 ac_ct_CC = @ac_ct_CC@
-ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
-ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
-ac_ct_RANLIB = @ac_ct_RANLIB@
-ac_ct_READELF = @ac_ct_READELF@
-ac_ct_STRIP = @ac_ct_STRIP@
 aext = @aext@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
 am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
@@ -201,18 +205,23 @@ build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
 datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
 exec_prefix = @exec_prefix@
 host = @host@
 host_alias = @host_alias@
 host_cpu = @host_cpu@
 host_os = @host_os@
 host_vendor = @host_vendor@
+htmldir = @htmldir@
 includedir = @includedir@
 infodir = @infodir@
 install_sh = @install_sh@
 libdir = @libdir@
 libexecdir = @libexecdir@
 libm_machine_dir = @libm_machine_dir@
+localedir = @localedir@
 localstatedir = @localstatedir@
 lpfx = @lpfx@
 lt_ECHO = @lt_ECHO@
@@ -222,8 +231,10 @@ mkdir_p = @mkdir_p@
 newlib_basedir = @newlib_basedir@
 oext = @oext@
 oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
 prefix = @prefix@
 program_transform_name = @program_transform_name@
+psdir = @psdir@
 sbindir = @sbindir@
 sharedstatedir = @sharedstatedir@
 sys_dir = @sys_dir@
@@ -234,8 +245,12 @@ INCLUDES = -I $(newlib_basedir)/../newli
 AM_CCASFLAGS = $(INCLUDES)
 LIB_SOURCES = \
 	f_atan2.S f_atan2f.S f_exp.c f_expf.c \
-	f_frexp.S f_frexpf.S f_log.S f_logf.S f_log10.S f_log10f.S \
-	f_ldexp.S f_ldexpf.S f_pow.c f_powf.c f_tan.S f_tanf.S f_math.h i386mach.h
+	f_frexp.S f_frexpf.S f_llrint.c f_llrintf.c f_llrintl.c \
+	f_log.S f_logf.S f_log10.S f_log10f.S \
+	f_ldexp.S f_ldexpf.S f_lrint.c f_lrintf.c f_lrintl.c \
+	f_pow.c f_powf.c f_rint.c f_rintf.c f_rintl.c \
+	f_tan.S f_tanf.S f_math.h \
+	i386mach.h 
 
 libi386_la_LDFLAGS = -Xcompiler -nostdlib
 @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libi386.la
@@ -412,6 +427,42 @@ lib_a-f_expf.o: f_expf.c
 lib_a-f_expf.obj: f_expf.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_expf.obj `if test -f 'f_expf.c'; then $(CYGPATH_W) 'f_expf.c'; else $(CYGPATH_W) '$(srcdir)/f_expf.c'; fi`
 
+lib_a-f_llrint.o: f_llrint.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_llrint.o `test -f 'f_llrint.c' || echo '$(srcdir)/'`f_llrint.c
+
+lib_a-f_llrint.obj: f_llrint.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_llrint.obj `if test -f 'f_llrint.c'; then $(CYGPATH_W) 'f_llrint.c'; else $(CYGPATH_W) '$(srcdir)/f_llrint.c'; fi`
+
+lib_a-f_llrintf.o: f_llrintf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_llrintf.o `test -f 'f_llrintf.c' || echo '$(srcdir)/'`f_llrintf.c
+
+lib_a-f_llrintf.obj: f_llrintf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_llrintf.obj `if test -f 'f_llrintf.c'; then $(CYGPATH_W) 'f_llrintf.c'; else $(CYGPATH_W) '$(srcdir)/f_llrintf.c'; fi`
+
+lib_a-f_llrintl.o: f_llrintl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_llrintl.o `test -f 'f_llrintl.c' || echo '$(srcdir)/'`f_llrintl.c
+
+lib_a-f_llrintl.obj: f_llrintl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_llrintl.obj `if test -f 'f_llrintl.c'; then $(CYGPATH_W) 'f_llrintl.c'; else $(CYGPATH_W) '$(srcdir)/f_llrintl.c'; fi`
+
+lib_a-f_lrint.o: f_lrint.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_lrint.o `test -f 'f_lrint.c' || echo '$(srcdir)/'`f_lrint.c
+
+lib_a-f_lrint.obj: f_lrint.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_lrint.obj `if test -f 'f_lrint.c'; then $(CYGPATH_W) 'f_lrint.c'; else $(CYGPATH_W) '$(srcdir)/f_lrint.c'; fi`
+
+lib_a-f_lrintf.o: f_lrintf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_lrintf.o `test -f 'f_lrintf.c' || echo '$(srcdir)/'`f_lrintf.c
+
+lib_a-f_lrintf.obj: f_lrintf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_lrintf.obj `if test -f 'f_lrintf.c'; then $(CYGPATH_W) 'f_lrintf.c'; else $(CYGPATH_W) '$(srcdir)/f_lrintf.c'; fi`
+
+lib_a-f_lrintl.o: f_lrintl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_lrintl.o `test -f 'f_lrintl.c' || echo '$(srcdir)/'`f_lrintl.c
+
+lib_a-f_lrintl.obj: f_lrintl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_lrintl.obj `if test -f 'f_lrintl.c'; then $(CYGPATH_W) 'f_lrintl.c'; else $(CYGPATH_W) '$(srcdir)/f_lrintl.c'; fi`
+
 lib_a-f_pow.o: f_pow.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_pow.o `test -f 'f_pow.c' || echo '$(srcdir)/'`f_pow.c
 
@@ -424,6 +475,24 @@ lib_a-f_powf.o: f_powf.c
 lib_a-f_powf.obj: f_powf.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_powf.obj `if test -f 'f_powf.c'; then $(CYGPATH_W) 'f_powf.c'; else $(CYGPATH_W) '$(srcdir)/f_powf.c'; fi`
 
+lib_a-f_rint.o: f_rint.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_rint.o `test -f 'f_rint.c' || echo '$(srcdir)/'`f_rint.c
+
+lib_a-f_rint.obj: f_rint.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_rint.obj `if test -f 'f_rint.c'; then $(CYGPATH_W) 'f_rint.c'; else $(CYGPATH_W) '$(srcdir)/f_rint.c'; fi`
+
+lib_a-f_rintf.o: f_rintf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_rintf.o `test -f 'f_rintf.c' || echo '$(srcdir)/'`f_rintf.c
+
+lib_a-f_rintf.obj: f_rintf.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_rintf.obj `if test -f 'f_rintf.c'; then $(CYGPATH_W) 'f_rintf.c'; else $(CYGPATH_W) '$(srcdir)/f_rintf.c'; fi`
+
+lib_a-f_rintl.o: f_rintl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_rintl.o `test -f 'f_rintl.c' || echo '$(srcdir)/'`f_rintl.c
+
+lib_a-f_rintl.obj: f_rintl.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-f_rintl.obj `if test -f 'f_rintl.c'; then $(CYGPATH_W) 'f_rintl.c'; else $(CYGPATH_W) '$(srcdir)/f_rintl.c'; fi`
+
 mostlyclean-libtool:
 	-rm -f *.lo
 
Index: libm/machine/i386/f_llrint.c
===================================================================
RCS file: libm/machine/i386/f_llrint.c
diff -N libm/machine/i386/f_llrint.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_llrint.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,69 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#ifdef __GNUC__
+#if !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+FUNCTION
+<<llrint>>, <<llrintf>>, <<llrintl>>---round and convert to long long integer
+INDEX
+	llrint
+INDEX
+	llrintf
+INDEX
+	llrintl
+
+ANSI_SYNOPSIS
+	#include <math.h>
+	long long int llrint(double x);
+        long long int llrintf(float x);
+        long long int llrintl(long double x);
+
+TRAD_SYNOPSIS
+	ANSI-only.
+
+DESCRIPTION
+The <<llrint>>, <<llrintf>> and <<llrintl>> functions round <[x]> to the nearest integer value,
+according to the current rounding direction. If the rounded value is outside the
+range of the return type, the numeric result is unspecified. A range error may 
+occur if the magnitude of <[x]> is too large.
+
+RETURNS
+These functions return the rounded integer value of <[x]>.
+<<llrint>>, <<llrintf>> and <<llrintl>> return the result as a long long integer.
+
+PORTABILITY
+<<llrint>>, <<llrintf>> and <<llrintl>> are ANSI.
+<<llrint>>, <<llrintf>> and <<llrintl>> are only available on i386 platforms when
+hardware floating point support is available and when compiling with GCC.
+
+*/
+
+/*
+ * Fast math version of llrint(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+long long int llrint (double x)
+{
+  long long int _result;
+  asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st");
+  return _result;
+}
+
+#endif /* !_SOFT_FLOAT */
+#endif /* __GNUC__ */
Index: libm/machine/i386/f_llrintf.c
===================================================================
RCS file: libm/machine/i386/f_llrintf.c
diff -N libm/machine/i386/f_llrintf.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_llrintf.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,33 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#ifdef __GNUC__
+#if !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+ * Fast math version of llrintf(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+long long int _f_llrintf (float x)
+{
+  long long int _result;
+  asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st");
+  return _result;
+}
+
+#endif /* !_SOFT_FLOAT */
+#endif /* __GNUC__ */
Index: libm/machine/i386/f_llrintl.c
===================================================================
RCS file: libm/machine/i386/f_llrintl.c
diff -N libm/machine/i386/f_llrintl.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_llrintl.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,33 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#ifdef __GNUC__
+#if !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+ * Fast math version of llrintl(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+long long int _f_llrintl (long double x)
+{
+  long long int _result;
+  asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st");
+  return _result;
+}
+
+#endif /* !_SOFT_FLOAT */
+#endif /* __GNUC__ */
Index: libm/machine/i386/f_lrint.c
===================================================================
RCS file: libm/machine/i386/f_lrint.c
diff -N libm/machine/i386/f_lrint.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_lrint.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,69 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#if defined(__GNUC__) && !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+FUNCTION
+<<lrint>>, <<lrintf>>, <<lrintl>>---round and convert to long integer
+INDEX
+	lrint
+INDEX
+	lrintf
+INDEX
+	lrintl
+
+ANSI_SYNOPSIS
+	#include <math.h>
+	long int lrint(double x);
+        long int lrintf(float x);
+        long int lrintl(long double x);
+
+TRAD_SYNOPSIS
+	ANSI-only.
+
+DESCRIPTION
+The <<lrint>>, <<lrintf>> and <<lrintl>> functions round <[x]> to the nearest integer value,
+according to the current rounding direction. If the rounded value is outside the
+range of the return type, the numeric result is unspecified. A range error may 
+occur if the magnitude of <[x]> is too large.
+
+RETURNS
+These functions return the rounded integer value of <[x]>.
+<<lrint>>, <<lrintf>> and <<lrintl>> return the result as a long integer.
+
+PORTABILITY
+<<lrint>>, <<lrintf>>, and <<lrintl>> are ANSI.
+<<lrint>> and <<lrintf>> are available on all platforms.
+<<lrintl>> is only available on i386 platforms when hardware 
+floating point support is available and when compiling with GCC.
+
+*/
+
+/*
+ * Fast math version of lrint(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+long int _f_lrint (double x)
+{
+  long int _result;
+  asm ("fistpl %0" : "=m" (_result) : "t" (x) : "st");
+  return _result;
+}
+
+#endif  /* !__GNUC__ || _SOFT_FLOAT */
+
Index: libm/machine/i386/f_lrintf.c
===================================================================
RCS file: libm/machine/i386/f_lrintf.c
diff -N libm/machine/i386/f_lrintf.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_lrintf.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,32 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#if defined(__GNUC__) && !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+ * Fast math version of lrintf(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+long int _f_lrintf (float x)
+{
+  long int _result;
+  asm ("fistpl %0" : "=m" (_result) : "t" (x) : "st");
+  return _result;
+}
+
+#endif  /* !__GNUC__ || _SOFT_FLOAT */
+
Index: libm/machine/i386/f_lrintl.c
===================================================================
RCS file: libm/machine/i386/f_lrintl.c
diff -N libm/machine/i386/f_lrintl.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_lrintl.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,33 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#ifdef __GNUC__
+#if !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+ * Fast math version of lrintl(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+long int _f_lrintl (long double x)
+{
+  long int _result;
+  asm ("fistpl %0" : "=m" (_result) : "t" (x) : "st");
+  return _result;
+}
+
+#endif /* !_SOFT_FLOAT */
+#endif /* __GNUC__ */
Index: libm/machine/i386/f_rint.c
===================================================================
RCS file: libm/machine/i386/f_rint.c
diff -N libm/machine/i386/f_rint.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_rint.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,67 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#if defined(__GNUC__) && !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+FUNCTION
+<<rint>>, <<rintf>>, <<rintl>>---round to integer
+INDEX
+	rint
+INDEX
+	rintf
+INDEX
+	rintl
+
+ANSI_SYNOPSIS
+	#include <math.h>
+	double rint(double x);
+        float rintf(float x);
+        long double rintl(long double x);
+
+TRAD_SYNOPSIS
+	ANSI-only.
+
+DESCRIPTION
+The <<rint>>, <<rintf>> and <<rintl>> functions round <[x]> to an integer value
+in floating-point format, using the current rounding direction.  They may
+raise the inexact exception if the result differs in value from the argument.
+
+RETURNS
+These functions return the rounded integer value of <[x]>.
+
+PORTABILITY
+<<rint>>, <<rintf>> and <<rintl>> are ANSI.
+<<rint>> and <<rintf>> are available on all platforms.
+<<rintl>> is only available on i386 platforms when hardware 
+floating point support is available and when compiling with GCC.
+
+*/
+
+/*
+ * Fast math version of rint(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+double _f_rint (double x)
+{
+  double _result;
+  asm ("frndint" : "=t" (_result) : "0" (x));
+  return _result;
+}
+
+#endif  /* !__GNUC__ || _SOFT_FLOAT */
+
Index: libm/machine/i386/f_rintf.c
===================================================================
RCS file: libm/machine/i386/f_rintf.c
diff -N libm/machine/i386/f_rintf.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_rintf.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,32 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#if defined(__GNUC__) && !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+ * Fast math version of rintf(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+float _f_rintf (float x)
+{
+  float _result;
+  asm ("frndint" : "=t" (_result) : "0" (x));
+  return _result;
+}
+
+#endif  /* !__GNUC__ || _SOFT_FLOAT */
+
Index: libm/machine/i386/f_rintl.c
===================================================================
RCS file: libm/machine/i386/f_rintl.c
diff -N libm/machine/i386/f_rintl.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libm/machine/i386/f_rintl.c	18 Dec 2007 19:55:46 -0000
@@ -0,0 +1,33 @@
+/*
+ * ====================================================
+ * x87 FP implementation contributed to Newlib by
+ * Dave Korn, November 2007.  This file is placed in the
+ * public domain.  Permission to use, copy, modify, and 
+ * distribute this software is freely granted.
+ * ====================================================
+ */
+
+#ifdef __GNUC__
+#if !defined(_SOFT_FLOAT)
+
+#include <math.h>
+
+/*
+ * Fast math version of rintl(x)
+ * Return x rounded to integral value according to the prevailing
+ * rounding mode.
+ * Method:
+ *	Using inline x87 asms.
+ * Exception:
+ *	Governed by x87 FPCR.
+ */
+
+long double _f_rintl (long double x)
+{
+  long double _result;
+  asm ("frndint" : "=t" (_result) : "0" (x));
+  return _result;
+}
+
+#endif /* !_SOFT_FLOAT */
+#endif /* __GNUC__ */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]