diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 471d0bcb3..1ea006e75 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,19 @@ +2007-12-19 Dave Korn + Jeff Johnston + + * libc/include/_ansi.h: Add _LONG_LONG definition. + * libc/include/math.h (llrint, llrintf, rintl, lrintl, llrintl): Add + prototypes. + * libc/machine/i386/machine/fastmath.h: Add support for new i386 + fast math versions of rint, lrint, and llrint family functions. + * libm/machine/i386/Makefile.am: Add new files. + * libm/machine/i386/Makefile.in: Regenerated. + * libm/machine/i386/f_llrint.c, libm/machine/i386/f_lrint.c, + libm/machine/i386/f_rint.c, libm/machine/i386/f_llrintf.c, + libm/machine/i386/f_lrintf.c, libm/machine/i386/f_rintf.c, + libm/machine/i386/f_llrintl.c, libm/machine/i386/f_lrintl.c, + libm/machine/i386/f_rintl.c: New files with fast math implementations. + 2007-12-19 Jeff Johnston * libc/include/sys/features.h: Add checks for C90 compilers using diff --git a/newlib/libc/include/_ansi.h b/newlib/libc/include/_ansi.h index 07bfd88eb..b84f37791 100644 --- a/newlib/libc/include/_ansi.h +++ b/newlib/libc/include/_ansi.h @@ -45,6 +45,9 @@ #ifndef _LONG_DOUBLE #define _LONG_DOUBLE long double #endif +#ifndef _LONG_LONG +#define _LONG_LONG long long +#endif #ifndef _PARAMS #define _PARAMS(paramlist) paramlist #endif @@ -62,6 +65,7 @@ #define _DEFUN_VOID(name) name() #define _CAST_VOID #define _LONG_DOUBLE double +#define _LONG_LONG long #ifndef _PARAMS #define _PARAMS(paramlist) () #endif diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index 9f9fe1b18..3f7001a0c 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -226,6 +226,7 @@ extern double scalbln _PARAMS((double, long int)); 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, long int)); 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) diff --git a/newlib/libc/machine/i386/machine/fastmath.h b/newlib/libc/machine/i386/machine/fastmath.h index 9a6753ec9..accfa8764 100644 --- a/newlib/libc/machine/i386/machine/fastmath.h +++ b/newlib/libc/machine/i386/machine/fastmath.h @@ -26,6 +26,7 @@ __extension__ double tan(double) #if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L + __extension__ float atan2f(float, float) __asm__(__U_L_PREFIX__ "_f_atan2f"); __extension__ float expf(float) @@ -34,12 +35,30 @@ __extension__ float frexpf(float, int*) __asm__(__U_L_PREFIX__ "_f_frexpf"); __extension__ float ldexpf(float, int) __asm__(__U_L_PREFIX__ "_f_ldexpf"); +__extension__ long long llrint(double) + __asm__(__U_L_PREFIX__ "_f_llrint"); +__extension__ long long llrintf(float) + __asm__(__U_L_PREFIX__ "_f_llrintf"); +__extension__ long long llrintl(long double) + __asm__(__U_L_PREFIX__ "_f_llrintl"); __extension__ float logf(float) __asm__(__U_L_PREFIX__ "_f_logf"); __extension__ float log10f(float) __asm__(__U_L_PREFIX__ "_f_log10f"); +__extension__ long lrint(double) + __asm__(__U_L_PREFIX__ "_f_lrint"); +__extension__ long lrintf(float) + __asm__(__U_L_PREFIX__ "_f_lrintf"); +__extension__ long lrintl(long double) + __asm__(__U_L_PREFIX__ "_f_lrintl"); __extension__ float powf(float, float) __asm__(__U_L_PREFIX__ "_f_powf"); +__extension__ double rint(double) + __asm__(__U_L_PREFIX__ "_f_rint"); +__extension__ float rintf(float) + __asm__(__U_L_PREFIX__ "_f_rintf"); +__extension__ long double rintl(long double) + __asm__(__U_L_PREFIX__ "_f_rintl"); __extension__ float tanf(float) __asm__(__U_L_PREFIX__ "_f_tanf"); #endif @@ -54,14 +73,6 @@ double EXFUN(_f_log,(double)); double EXFUN(_f_log10,(double)); double EXFUN(_f_pow,(double, double)); -float EXFUN(_f_atan2f,(float, float)); -float EXFUN(_f_expf,(float)); -float EXFUN(_f_frexpf,(float, int*)); -float EXFUN(_f_ldexpf,(float, int)); -float EXFUN(_f_logf,(float)); -float EXFUN(_f_log10f,(float)); -float EXFUN(_f_powf,(float, float)); - #define atan2(__y,__x) _f_atan2((__y),(__x)) #define exp(__x) _f_exp(__x) #define frexp(__x,__p) _f_frexp((__x),(__p)) @@ -71,13 +82,40 @@ float EXFUN(_f_powf,(float, float)); #define pow(__x,__y) _f_pow((__x),(__y)) #ifndef __STRICT_ANSI__ + +float EXFUN(_f_atan2f,(float, float)); +float EXFUN(_f_expf,(float)); +float EXFUN(_f_frexpf,(float, int*)); +float EXFUN(_f_ldexpf,(float, int)); +long long EXFUN(_f_llrint,(double)); +long long EXFUN(_f_llrintf,(float)); +long long EXFUN(_f_llrintl,(long double)); +float EXFUN(_f_logf,(float)); +float EXFUN(_f_log10f,(float)); +long EXFUN(_f_lrint,(double)); +long EXFUN(_f_lrintf,(float)); +long EXFUN(_f_lrintl,(long double)); +float EXFUN(_f_powf,(float, float)); +float EXFUN(_f_rint,(double)); +double EXFUN(_f_rintf,(float)); +long double EXFUN(_f_rintl,(long double)); + #define atan2f(__y,__x) _f_atan2f((__y),(__x)) #define expf(__x) _f_expf(__x) #define frexpf(__x,__p) _f_frexpf((__x),(__p)) #define ldexpf(__x,__e) _f_ldexpf((__x),(__e)) +#define llrint(__x) _f_llrint((__x)) +#define llrintf(__x) _f_llrintf((__x)) +#define llrintl(__x) _f_llrintl((__x)) #define logf(__x) _f_logf(__x) #define log10f(__x) _f_log10f(__x) +#define lrint(__x) _f_lrint((__x)) +#define lrintf(__x) _f_lrintf((__x)) +#define lrintl(__x) _f_lrintl((__x)) #define powf(__x,y) _f_powf((__x),(__y)) +#define rint(__x) _f_rint((__x)) +#define rintf(__x) _f_rintf((__x)) +#define rintl(__x) _f_rintl((__x)) #endif #endif /* GCC */ diff --git a/newlib/libm/machine/i386/Makefile.am b/newlib/libm/machine/i386/Makefile.am index c858ea414..6fade2d9a 100644 --- a/newlib/libm/machine/i386/Makefile.am +++ b/newlib/libm/machine/i386/Makefile.am @@ -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.shared ACLOCAL_AMFLAGS = -I ../../.. -I ../../../.. CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host + diff --git a/newlib/libm/machine/i386/Makefile.in b/newlib/libm/machine/i386/Makefile.in index 2a0f9fdb0..7c2c1e804 100644 --- a/newlib/libm/machine/i386/Makefile.in +++ b/newlib/libm/machine/i386/Makefile.in @@ -45,7 +45,11 @@ DIST_COMMON = $(srcdir)/../../../Makefile.shared \ $(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)/../newlib/libm/common $(NEWLIB_CFLAGS) $(CROSS_C 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 diff --git a/newlib/libm/machine/i386/f_llrint.c b/newlib/libm/machine/i386/f_llrint.c new file mode 100644 index 000000000..0fe27d7df --- /dev/null +++ b/newlib/libm/machine/i386/f_llrint.c @@ -0,0 +1,74 @@ +/* + * ==================================================== + * 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 + +/* +FUNCTION +<>, <>, <>---round and convert to long long integer +INDEX + llrint +INDEX + llrintf +INDEX + llrintl + +ANSI_SYNOPSIS + #include + 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 <>, <> and <> 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]>. +<>, <> and <> return the result as a long long integer. + +PORTABILITY +<>, <> and <> are ANSI. +<>, <> and <> 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 _f_llrint (double x) +{ + long long int _result; + asm ("fistpll %0" : "=m" (_result) : "t" (x) : "st"); + return _result; +} + +/* For now, we only have the fast math version. */ +long long int llrint (double x) { + return _f_llrint(x); +} + +#endif /* !_SOFT_FLOAT */ +#endif /* __GNUC__ */ diff --git a/newlib/libm/machine/i386/f_llrintf.c b/newlib/libm/machine/i386/f_llrintf.c new file mode 100644 index 000000000..6b2dfb39b --- /dev/null +++ b/newlib/libm/machine/i386/f_llrintf.c @@ -0,0 +1,38 @@ +/* + * ==================================================== + * 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 + +/* + * 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; +} + +/* For now, we only have the fast math version. */ +long long int llrintf (float x) { + return _f_llrintf(x); +} + +#endif /* !_SOFT_FLOAT */ +#endif /* __GNUC__ */ diff --git a/newlib/libm/machine/i386/f_llrintl.c b/newlib/libm/machine/i386/f_llrintl.c new file mode 100644 index 000000000..610270c3d --- /dev/null +++ b/newlib/libm/machine/i386/f_llrintl.c @@ -0,0 +1,38 @@ +/* + * ==================================================== + * 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 + +/* + * 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; +} + +/* For now, we only have the fast math version. */ +long long int llrintl (long double x) { + return _f_llrintl(x); +} + +#endif /* !_SOFT_FLOAT */ +#endif /* __GNUC__ */ diff --git a/newlib/libm/machine/i386/f_lrint.c b/newlib/libm/machine/i386/f_lrint.c new file mode 100644 index 000000000..b8cdabb5d --- /dev/null +++ b/newlib/libm/machine/i386/f_lrint.c @@ -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 + +/* +FUNCTION +<>, <>, <>---round and convert to long integer +INDEX + lrint +INDEX + lrintf +INDEX + lrintl + +ANSI_SYNOPSIS + #include + long int lrint(double x); + long int lrintf(float x); + long int lrintl(long double x); + +TRAD_SYNOPSIS + ANSI-only. + +DESCRIPTION +The <>, <> and <> 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]>. +<>, <> and <> return the result as a long integer. + +PORTABILITY +<>, <>, and <> are ANSI. +<> and <> are available on all platforms. +<> 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 */ + diff --git a/newlib/libm/machine/i386/f_lrintf.c b/newlib/libm/machine/i386/f_lrintf.c new file mode 100644 index 000000000..da8ffa62d --- /dev/null +++ b/newlib/libm/machine/i386/f_lrintf.c @@ -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 + +/* + * 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 */ + diff --git a/newlib/libm/machine/i386/f_lrintl.c b/newlib/libm/machine/i386/f_lrintl.c new file mode 100644 index 000000000..eae2bca28 --- /dev/null +++ b/newlib/libm/machine/i386/f_lrintl.c @@ -0,0 +1,38 @@ +/* + * ==================================================== + * 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 + +/* + * 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; +} + +/* For now, there is only the fast math version so we use it. */ +long int lrintl (long double x) { + return _f_lrintl(x); +} + +#endif /* !_SOFT_FLOAT */ +#endif /* __GNUC__ */ diff --git a/newlib/libm/machine/i386/f_rint.c b/newlib/libm/machine/i386/f_rint.c new file mode 100644 index 000000000..e335d463c --- /dev/null +++ b/newlib/libm/machine/i386/f_rint.c @@ -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 + +/* +FUNCTION +<>, <>, <>---round to integer +INDEX + rint +INDEX + rintf +INDEX + rintl + +ANSI_SYNOPSIS + #include + double rint(double x); + float rintf(float x); + long double rintl(long double x); + +TRAD_SYNOPSIS + ANSI-only. + +DESCRIPTION +The <>, <> and <> 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 +<>, <> and <> are ANSI. +<> and <> are available on all platforms. +<> 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 */ + diff --git a/newlib/libm/machine/i386/f_rintf.c b/newlib/libm/machine/i386/f_rintf.c new file mode 100644 index 000000000..a7dabb7f3 --- /dev/null +++ b/newlib/libm/machine/i386/f_rintf.c @@ -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 + +/* + * 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 */ + diff --git a/newlib/libm/machine/i386/f_rintl.c b/newlib/libm/machine/i386/f_rintl.c new file mode 100644 index 000000000..0e67739b5 --- /dev/null +++ b/newlib/libm/machine/i386/f_rintl.c @@ -0,0 +1,38 @@ +/* + * ==================================================== + * 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 + +/* + * 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; +} + +/* For now, we only have the fast math version. */ +long double rintl (long double x) { + return _f_rintl(x); +} + +#endif /* !_SOFT_FLOAT */ +#endif /* __GNUC__ */