From: guenther Date: Tue, 27 Oct 2015 05:54:49 +0000 (+0000) Subject: Wrap the remaining math functions in libc: __fpclassify*(), __flt_rounds(), X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=af3276d5e32f3e939032c022c530ad02a9ed9a1e;p=openbsd Wrap the remaining math functions in libc: __fpclassify*(), __flt_rounds(), and ldexp(). ok millert@ --- diff --git a/lib/libc/arch/alpha/gen/flt_rounds.c b/lib/libc/arch/alpha/gen/flt_rounds.c index 0aed2da75aa..71e96b549d3 100644 --- a/lib/libc/arch/alpha/gen/flt_rounds.c +++ b/lib/libc/arch/alpha/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.6 2012/06/25 17:01:09 deraadt Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.7 2015/10/27 05:54:49 guenther Exp $ */ /* $NetBSD: flt_rounds.c,v 1.1 1995/04/29 05:09:53 cgd Exp $ */ /* @@ -55,3 +55,4 @@ __flt_rounds() return map[(old >> 58) & 0x3]; } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/amd64/gen/flt_rounds.S b/lib/libc/arch/amd64/gen/flt_rounds.S index d313ed3d40e..b0def90d548 100644 --- a/lib/libc/arch/amd64/gen/flt_rounds.S +++ b/lib/libc/arch/amd64/gen/flt_rounds.S @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.S,v 1.4 2015/05/29 08:50:12 uebayasi Exp $ */ +/* $OpenBSD: flt_rounds.S,v 1.5 2015/10/27 05:54:49 guenther Exp $ */ /* $NetBSD: flt_rounds.S,v 1.2 2002/06/06 23:04:35 fvdl Exp $ */ /* @@ -6,7 +6,7 @@ * Public domain. */ -#include +#include "SYS.h" .text _ALIGN_TEXT @@ -28,4 +28,4 @@ ENTRY(__flt_rounds) movb _map(,%rax,1),%al #endif ret -END(__flt_rounds) +END_STRONG(__flt_rounds) diff --git a/lib/libc/arch/amd64/gen/fpclassifyl.c b/lib/libc/arch/amd64/gen/fpclassifyl.c index 19940cdd53d..01df203baa3 100644 --- a/lib/libc/arch/amd64/gen/fpclassifyl.c +++ b/lib/libc/arch/amd64/gen/fpclassifyl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpclassifyl.c,v 1.1 2008/09/07 20:36:07 martynas Exp $ */ +/* $OpenBSD: fpclassifyl.c,v 1.2 2015/10/27 05:54:49 guenther Exp $ */ /* * Copyright (c) 2008 Martynas Venckus * @@ -42,3 +42,4 @@ __fpclassifyl(long double e) return FP_NORMAL; } +DEF_STRONG(__fpclassifyl); diff --git a/lib/libc/arch/amd64/gen/ldexp.c b/lib/libc/arch/amd64/gen/ldexp.c index bfd89d8781c..e0bd213b8f1 100644 --- a/lib/libc/arch/amd64/gen/ldexp.c +++ b/lib/libc/arch/amd64/gen/ldexp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldexp.c,v 1.4 2015/01/04 16:12:42 daniel Exp $ */ +/* $OpenBSD: ldexp.c,v 1.5 2015/10/27 05:54:49 guenther Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -47,3 +47,4 @@ ldexp(double value, int exp) : "0" (value), "u" ((double)exp)); return (temp); } +DEF_STRONG(ldexp); diff --git a/lib/libc/arch/arm/gen/flt_rounds.c b/lib/libc/arch/arm/gen/flt_rounds.c index 820a07a8b48..98497051c16 100644 --- a/lib/libc/arch/arm/gen/flt_rounds.c +++ b/lib/libc/arch/arm/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.4 2015/10/18 19:30:39 guenther Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.5 2015/10/27 05:54:49 guenther Exp $ */ /* $NetBSD: flt_rounds.c,v 1.1 2000/12/29 20:13:48 bjh21 Exp $ */ /* @@ -74,3 +74,4 @@ __flt_rounds() { return(map[fpgetround()]); } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/hppa/gen/flt_rounds.c b/lib/libc/arch/hppa/gen/flt_rounds.c index 6defc4fb09e..68ee3a5c6f3 100644 --- a/lib/libc/arch/hppa/gen/flt_rounds.c +++ b/lib/libc/arch/hppa/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.5 2014/04/18 15:09:52 guenther Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.6 2015/10/27 05:54:49 guenther Exp $ */ /* * Written by Miodrag Vallat. Public domain. @@ -22,3 +22,4 @@ __flt_rounds() __asm__ volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); return map[(fpsr >> 41) & 0x03]; } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/hppa64/gen/flt_rounds.c b/lib/libc/arch/hppa64/gen/flt_rounds.c index 2947ce7e5c0..9323e81e29e 100644 --- a/lib/libc/arch/hppa64/gen/flt_rounds.c +++ b/lib/libc/arch/hppa64/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.3 2014/04/18 15:09:52 guenther Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.4 2015/10/27 05:54:49 guenther Exp $ */ /* * Written by Miodrag Vallat. Public domain. @@ -22,3 +22,4 @@ __flt_rounds() __asm__ volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); return map[(fpsr >> 41) & 0x03]; } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/i386/gen/flt_rounds.S b/lib/libc/arch/i386/gen/flt_rounds.S index 968d5a2eed3..e42ad93b214 100644 --- a/lib/libc/arch/i386/gen/flt_rounds.S +++ b/lib/libc/arch/i386/gen/flt_rounds.S @@ -1,10 +1,10 @@ -/* $OpenBSD: flt_rounds.S,v 1.4 2012/08/22 17:19:34 pascal Exp $ */ +/* $OpenBSD: flt_rounds.S,v 1.5 2015/10/27 05:54:49 guenther Exp $ */ /* * Written by J.T. Conklin, Apr 4, 1995 * Public domain. */ -#include +#include "SYS.h" .text .align 2 @@ -30,3 +30,4 @@ ENTRY(__flt_rounds) #endif addl $4,%esp ret +END_STRONG(__flt_rounds); diff --git a/lib/libc/arch/i386/gen/fpclassifyl.c b/lib/libc/arch/i386/gen/fpclassifyl.c index 19940cdd53d..01df203baa3 100644 --- a/lib/libc/arch/i386/gen/fpclassifyl.c +++ b/lib/libc/arch/i386/gen/fpclassifyl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpclassifyl.c,v 1.1 2008/09/07 20:36:07 martynas Exp $ */ +/* $OpenBSD: fpclassifyl.c,v 1.2 2015/10/27 05:54:49 guenther Exp $ */ /* * Copyright (c) 2008 Martynas Venckus * @@ -42,3 +42,4 @@ __fpclassifyl(long double e) return FP_NORMAL; } +DEF_STRONG(__fpclassifyl); diff --git a/lib/libc/arch/i386/gen/ldexp.c b/lib/libc/arch/i386/gen/ldexp.c index 7fc04aa619a..2df2b04b0d0 100644 --- a/lib/libc/arch/i386/gen/ldexp.c +++ b/lib/libc/arch/i386/gen/ldexp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldexp.c,v 1.8 2015/01/04 16:12:42 daniel Exp $ */ +/* $OpenBSD: ldexp.c,v 1.9 2015/10/27 05:54:49 guenther Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -46,3 +46,4 @@ ldexp(double value, int exp) : "0" (value), "u" ((double)exp)); return (temp); } +DEF_STRONG(ldexp); diff --git a/lib/libc/arch/m88k/gen/flt_rounds.c b/lib/libc/arch/m88k/gen/flt_rounds.c index c7dd499f27a..7017e75a5ce 100644 --- a/lib/libc/arch/m88k/gen/flt_rounds.c +++ b/lib/libc/arch/m88k/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.5 2013/01/05 11:20:55 miod Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.6 2015/10/27 05:54:49 guenther Exp $ */ /* * Written by J.T. Conklin, Apr 10, 1995 @@ -27,3 +27,4 @@ __flt_rounds() __asm__("fldcr %0, %%fcr63" : "=r" (x)); return map[(x >> 14) & 0x03]; } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/mips64/gen/flt_rounds.c b/lib/libc/arch/mips64/gen/flt_rounds.c index 6351de0df69..33daeac727b 100644 --- a/lib/libc/arch/mips64/gen/flt_rounds.c +++ b/lib/libc/arch/mips64/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.3 2012/06/25 17:01:11 deraadt Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.4 2015/10/27 05:54:49 guenther Exp $ */ /* * Written by J.T. Conklin, Apr 11, 1995 * Public domain. @@ -23,3 +23,4 @@ __flt_rounds() __asm__("nop"); return map[x & 0x03]; } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/mips64/gen/fpclassifyl.c b/lib/libc/arch/mips64/gen/fpclassifyl.c index 030e9c8aac4..2b2839d4578 100644 --- a/lib/libc/arch/mips64/gen/fpclassifyl.c +++ b/lib/libc/arch/mips64/gen/fpclassifyl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpclassifyl.c,v 1.1 2008/09/07 20:36:07 martynas Exp $ */ +/* $OpenBSD: fpclassifyl.c,v 1.2 2015/10/27 05:54:49 guenther Exp $ */ /* * Copyright (c) 2008 Martynas Venckus * @@ -42,3 +42,4 @@ __fpclassifyl(long double e) return FP_NORMAL; } +DEF_STRONG(__fpclassifyl); diff --git a/lib/libc/arch/mips64/gen/ldexp.S b/lib/libc/arch/mips64/gen/ldexp.S index 640406422c7..ba934bee580 100644 --- a/lib/libc/arch/mips64/gen/ldexp.S +++ b/lib/libc/arch/mips64/gen/ldexp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ldexp.S,v 1.6 2005/08/07 16:40:15 espie Exp $ */ +/* $OpenBSD: ldexp.S,v 1.7 2015/10/27 05:54:49 guenther Exp $ */ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -#include +#include "SYS.h" #define DEXP_INF 0x7ff #define DEXP_BIAS 1023 @@ -164,4 +164,4 @@ LEAF(ldexp, 0) 9: mov.d $f0, $f12 # yes, result is just x j ra -END(ldexp) +END_STRONG(ldexp) diff --git a/lib/libc/arch/powerpc/gen/flt_rounds.c b/lib/libc/arch/powerpc/gen/flt_rounds.c index a363eb1b1b2..d3976cede0a 100644 --- a/lib/libc/arch/powerpc/gen/flt_rounds.c +++ b/lib/libc/arch/powerpc/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.5 2014/04/17 09:01:25 guenther Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.6 2015/10/27 05:54:49 guenther Exp $ */ /* $NetBSD: flt_rounds.c,v 1.5 2001/05/25 12:14:05 simonb Exp $ */ /* @@ -56,3 +56,4 @@ __flt_rounds() return map[x & 0x03]; #endif } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/sh/gen/flt_rounds.c b/lib/libc/arch/sh/gen/flt_rounds.c index ae4b588223f..31fe8e2af30 100644 --- a/lib/libc/arch/sh/gen/flt_rounds.c +++ b/lib/libc/arch/sh/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.4 2014/04/18 15:09:52 guenther Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.5 2015/10/27 05:54:49 guenther Exp $ */ /* * Copyright (c) 2006 Miodrag Vallat. * @@ -39,3 +39,4 @@ __flt_rounds() return rndmap[fpgetround()]; #endif } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/sparc/gen/flt_rounds.c b/lib/libc/arch/sparc/gen/flt_rounds.c index ab80b2e137b..df39481949a 100644 --- a/lib/libc/arch/sparc/gen/flt_rounds.c +++ b/lib/libc/arch/sparc/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.6 2012/06/25 17:01:11 deraadt Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.7 2015/10/27 05:54:49 guenther Exp $ */ /* * Written by J.T. Conklin, Apr 10, 1995 * Public domain. @@ -22,3 +22,4 @@ __flt_rounds() __asm__("st %%fsr,%0" : "=m" (*&x)); return map[(x >> 30) & 0x03]; } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/sparc64/gen/flt_rounds.c b/lib/libc/arch/sparc64/gen/flt_rounds.c index b4f1a312a9f..3310902f2a9 100644 --- a/lib/libc/arch/sparc64/gen/flt_rounds.c +++ b/lib/libc/arch/sparc64/gen/flt_rounds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: flt_rounds.c,v 1.3 2012/06/25 17:01:11 deraadt Exp $ */ +/* $OpenBSD: flt_rounds.c,v 1.4 2015/10/27 05:54:49 guenther Exp $ */ /* $NetBSD: flt_rounds.c,v 1.1 1998/09/11 04:56:23 eeh Exp $ */ /* @@ -24,3 +24,4 @@ __flt_rounds() __asm__("st %%fsr,%0" : "=m" (*&x)); return map[(x >> 30) & 0x03]; } +DEF_STRONG(__flt_rounds); diff --git a/lib/libc/arch/sparc64/gen/fpclassifyl.c b/lib/libc/arch/sparc64/gen/fpclassifyl.c index d569ef90430..2b2839d4578 100644 --- a/lib/libc/arch/sparc64/gen/fpclassifyl.c +++ b/lib/libc/arch/sparc64/gen/fpclassifyl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpclassifyl.c,v 1.1 2008/09/07 20:36:08 martynas Exp $ */ +/* $OpenBSD: fpclassifyl.c,v 1.2 2015/10/27 05:54:49 guenther Exp $ */ /* * Copyright (c) 2008 Martynas Venckus * @@ -42,3 +42,4 @@ __fpclassifyl(long double e) return FP_NORMAL; } +DEF_STRONG(__fpclassifyl); diff --git a/lib/libc/arch/vax/gen/fpclassify.c b/lib/libc/arch/vax/gen/fpclassify.c index 59c7e3b1aa9..dc7b5e90b8f 100644 --- a/lib/libc/arch/vax/gen/fpclassify.c +++ b/lib/libc/arch/vax/gen/fpclassify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpclassify.c,v 1.6 2013/03/28 18:09:38 martynas Exp $ */ +/* $OpenBSD: fpclassify.c,v 1.7 2015/10/27 05:54:49 guenther Exp $ */ /* * Copyright (c) 2008 Martynas Venckus * @@ -29,6 +29,7 @@ __fpclassify(double d) return FP_NORMAL; } +DEF_STRONG(__fpclassify); int __fpclassifyf(float f) @@ -41,5 +42,7 @@ __fpclassifyf(float f) return FP_NORMAL; } +DEF_STRONG(__fpclassifyf); -__strong_alias(__fpclassifyl, __fpclassify); +MAKE_CLONE(__fpclassifyl, __fpclassify); +DEF_STRONG(__fpclassifyl); diff --git a/lib/libc/arch/vax/gen/ldexp.S b/lib/libc/arch/vax/gen/ldexp.S index b55d2083dda..e22491c9274 100644 --- a/lib/libc/arch/vax/gen/ldexp.S +++ b/lib/libc/arch/vax/gen/ldexp.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ldexp.S,v 1.10 2013/07/05 21:10:50 miod Exp $ */ +/* $OpenBSD: ldexp.S,v 1.11 2015/10/27 05:54:49 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -75,6 +75,7 @@ ENTRY(ldexp, R2) 1: movl $ ERANGE,_C_LABEL(errno) ret +END_STRONG(ldexp); .data huge: .word 0x7fff /* the largest number that can */ diff --git a/lib/libc/gen/fpclassify.c b/lib/libc/gen/fpclassify.c index b878d5ec921..33ae6922148 100644 --- a/lib/libc/gen/fpclassify.c +++ b/lib/libc/gen/fpclassify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fpclassify.c,v 1.8 2013/07/03 04:46:36 espie Exp $ */ +/* $OpenBSD: fpclassify.c,v 1.9 2015/10/27 05:54:49 guenther Exp $ */ /* * Copyright (c) 2008 Martynas Venckus * @@ -41,6 +41,7 @@ __fpclassify(double d) return FP_NORMAL; } +DEF_STRONG(__fpclassify); int __fpclassifyf(float f) @@ -63,7 +64,9 @@ __fpclassifyf(float f) return FP_NORMAL; } +DEF_STRONG(__fpclassifyf); #if LDBL_MANT_DIG == DBL_MANT_DIG -__strong_alias(__fpclassifyl, __fpclassify); +MAKE_CLONE(__fpclassifyl, __fpclassify); +DEF_STRONG(__fpclassifyl); #endif /* LDBL_MANT_DIG == DBL_MANT_DIG */ diff --git a/lib/libc/gen/ldexp.c b/lib/libc/gen/ldexp.c index eb0829e7007..ebe33f9df91 100644 --- a/lib/libc/gen/ldexp.c +++ b/lib/libc/gen/ldexp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldexp.c,v 1.9 2014/07/21 01:51:10 guenther Exp $ */ +/* $OpenBSD: ldexp.c,v 1.10 2015/10/27 05:54:49 guenther Exp $ */ /* @(#)s_scalbn.c 5.1 93/09/24 */ /* @(#)fdlibm.h 5.1 93/09/24 */ /* @@ -120,6 +120,7 @@ ldexp(double x, int n) SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x*twom54; } +DEF_STRONG(ldexp); #if LDBL_MANT_DIG == DBL_MANT_DIG __strong_alias(ldexpl, ldexp); diff --git a/lib/libc/hidden/float.h b/lib/libc/hidden/float.h new file mode 100644 index 00000000000..ea2cf5bae9a --- /dev/null +++ b/lib/libc/hidden/float.h @@ -0,0 +1,25 @@ +/* $OpenBSD: float.h,v 1.1 2015/10/27 05:54:49 guenther Exp $ */ +/* + * Copyright (c) 2015 Philip Guenther + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBC_FLOAT_H_ +#define _LIBC_FLOAT_H_ + +#include_next + +PROTO_NORMAL(__flt_rounds); + +#endif /* _LIBC_FLOAT_H_ */ diff --git a/lib/libc/hidden/math.h b/lib/libc/hidden/math.h new file mode 100644 index 00000000000..dd8e4f456e9 --- /dev/null +++ b/lib/libc/hidden/math.h @@ -0,0 +1,33 @@ +/* $OpenBSD: math.h,v 1.1 2015/10/27 05:54:49 guenther Exp $ */ +/* + * Copyright (c) 2015 Philip Guenther + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef _LIBC_MATH_H_ +#define _LIBC_MATH_H_ + +#include_next + +/* + * This file only wraps the handful of functions that are both + * defined and used by libc. + */ + +PROTO_NORMAL(__fpclassify); +PROTO_NORMAL(__fpclassifyf); +PROTO_NORMAL(__fpclassifyl); +PROTO_NORMAL(ldexp); + +#endif /* !_LIBC_MATH_H_ */