From c55caac80eb5de1b1bf273e38c6f01c6308f01b3 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 20 Mar 1997 03:23:21 +0000 Subject: [PATCH] Add definition for `signbit' function. Future releases will have this function. --- sysdeps/libm-ieee754/w_pow.c | 12 ++++++++++++ sysdeps/libm-ieee754/w_powf.c | 12 ++++++++++++ sysdeps/libm-ieee754/w_powl.c | 12 ++++++++++++ 3 files changed, 36 insertions(+) diff --git a/sysdeps/libm-ieee754/w_pow.c b/sysdeps/libm-ieee754/w_pow.c index 1711d71bda0..f1a9b98dfdf 100644 --- a/sysdeps/libm-ieee754/w_pow.c +++ b/sysdeps/libm-ieee754/w_pow.c @@ -20,6 +20,18 @@ #include "math_private.h" +/* This is a quick hack for now. In version 2.1.x we'll have a real + function. */ +static inline int +signbit (double x) +{ + int32_t hx; + + GET_HIGH_WORD (hx, x); + return hx & 0x80000000; +} + + #ifdef __STDC__ double __pow(double x, double y) /* wrapper pow */ #else diff --git a/sysdeps/libm-ieee754/w_powf.c b/sysdeps/libm-ieee754/w_powf.c index 0b20822be8f..17da39cd030 100644 --- a/sysdeps/libm-ieee754/w_powf.c +++ b/sysdeps/libm-ieee754/w_powf.c @@ -25,6 +25,18 @@ static char rcsid[] = "$NetBSD: w_powf.c,v 1.3 1995/05/10 20:49:41 jtc Exp $"; #include "math_private.h" +/* This is a quick hack for now. In version 2.1.x we'll have a real + function. */ +static inline int +signbit (float x) +{ + int32_t hx; + + GET_FLOAT_WORD (hx, x); + return hx & 0x80000000; +} + + #ifdef __STDC__ float __powf(float x, float y) /* wrapper powf */ #else diff --git a/sysdeps/libm-ieee754/w_powl.c b/sysdeps/libm-ieee754/w_powl.c index aea572d905b..44924a99c15 100644 --- a/sysdeps/libm-ieee754/w_powl.c +++ b/sysdeps/libm-ieee754/w_powl.c @@ -22,6 +22,18 @@ #include "math_private.h" +/* This is a quick hack for now. In version 2.1.x we'll have a real + function. */ +static inline int +signbit (long double x) +{ + int32_t e; + + GET_LDOUBLE_EXP (e, x); + return e & 0x8000; +} + + #ifdef __STDC__ long double __powl(long double x, long double y)/* wrapper powl */ #else -- 2.47.2