diff --git a/src/kernel/libroot/posix/math/arch/Jamfile b/src/kernel/libroot/posix/math/arch/Jamfile index e4c0f3eefc..1432f0abe2 100644 --- a/src/kernel/libroot/posix/math/arch/Jamfile +++ b/src/kernel/libroot/posix/math/arch/Jamfile @@ -1,3 +1,3 @@ SubDir OBOS_TOP src kernel libroot posix math arch ; -SubInclude OBOS_TOP src kernel libroot posix math arch $(OBOS_TARGET_DIR) ; +SubInclude OBOS_TOP src kernel libroot posix math arch $(OBOS_ARCH) ; diff --git a/src/kernel/libroot/posix/math/arch/ppc/Jamfile b/src/kernel/libroot/posix/math/arch/ppc/Jamfile new file mode 100644 index 0000000000..d72a27b612 --- /dev/null +++ b/src/kernel/libroot/posix/math/arch/ppc/Jamfile @@ -0,0 +1,10 @@ +SubDir OBOS_TOP src kernel libroot posix math arch ppc ; + +KernelMergeObject posix_math_arch_$(OBOS_ARCH).o : + <$(SOURCE_GRIST)>fabs.c + <$(SOURCE_GRIST)>frexp.c + <$(SOURCE_GRIST)>isinf.c + <$(SOURCE_GRIST)>ldexp.c + : + -fPIC -DPIC + ; diff --git a/src/kernel/libroot/posix/math/arch/ppc/fabs.c b/src/kernel/libroot/posix/math/arch/ppc/fabs.c new file mode 100644 index 0000000000..2257840453 --- /dev/null +++ b/src/kernel/libroot/posix/math/arch/ppc/fabs.c @@ -0,0 +1,18 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include + + +double +fabs(double value) +{ + // ToDo: that's a slow, generic implementation + if (value > 0) + return value; + + return -value; +} diff --git a/src/kernel/libroot/posix/math/arch/ppc/frexp.c b/src/kernel/libroot/posix/math/arch/ppc/frexp.c new file mode 100644 index 0000000000..e5417f1057 --- /dev/null +++ b/src/kernel/libroot/posix/math/arch/ppc/frexp.c @@ -0,0 +1,60 @@ +/* Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include + +double +frexp(value, eptr) + double value; + int *eptr; +{ + union { + double v; + struct { + unsigned u_mant2 : 32; + unsigned u_mant1 : 20; + unsigned u_exp : 11; + unsigned u_sign : 1; + } s; + } u; + + if (value) { + u.v = value; + *eptr = u.s.u_exp - 1022; + u.s.u_exp = 1022; + return(u.v); + } else { + *eptr = 0; + return((double)0); + } +} diff --git a/src/kernel/libroot/posix/math/arch/ppc/isinf.c b/src/kernel/libroot/posix/math/arch/ppc/isinf.c new file mode 100644 index 0000000000..b060e9304d --- /dev/null +++ b/src/kernel/libroot/posix/math/arch/ppc/isinf.c @@ -0,0 +1,68 @@ +/* Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +/* ToDo: on BeOS/x86, these are defined as __isnan(), and __isinf() - the + * isnan()/isinf() are only macros - we will have to reflect this here. + */ + +int isnan(double); +int isinf(double); + +int +isnan(double d) +{ + register struct IEEEdp { + unsigned manl : 32; + unsigned manh : 20; + unsigned exp : 11; + unsigned sign : 1; + } *p = (struct IEEEdp *)&d; + + return p->exp == 2047 && (p->manh || p->manl); +} + + +int +isinf(double d) +{ + register struct IEEEdp { + u_int manl : 32; + u_int manh : 20; + u_int exp : 11; + u_int sign : 1; + } *p = (struct IEEEdp *)&d; + + return p->exp == 2047 && !p->manh && !p->manl; +} diff --git a/src/kernel/libroot/posix/math/arch/ppc/ldexp.c b/src/kernel/libroot/posix/math/arch/ppc/ldexp.c new file mode 100644 index 0000000000..b454cd80b0 --- /dev/null +++ b/src/kernel/libroot/posix/math/arch/ppc/ldexp.c @@ -0,0 +1,19 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include + + +double +ldexp(double value, int exp) +{ + // ToDo: that's a slow, generic implementation + double power = 1.; + while (exp-- > 0) + power *= 2.; + + return value * power; +}