xref: /netbsd-src/lib/libm/src/s_expl.c (revision 3f3b0ded092b378b433be0bc7541910db5a04ce4)
1*3f3b0dedSchristos /*	$NetBSD: s_expl.c,v 1.2 2024/01/23 15:45:07 christos Exp $	*/
2cfe182f3Schristos 
3cfe182f3Schristos /*-
4cfe182f3Schristos  * Copyright (c) 2023 The NetBSD Foundation, Inc.
5cfe182f3Schristos  * All rights reserved.
6cfe182f3Schristos  *
7cfe182f3Schristos  * This code is derived from software contributed to The NetBSD Foundation
8cfe182f3Schristos  * by Christos Zoulas.
9cfe182f3Schristos  *
10cfe182f3Schristos  * Redistribution and use in source and binary forms, with or without
11cfe182f3Schristos  * modification, are permitted provided that the following conditions
12cfe182f3Schristos  * are met:
13cfe182f3Schristos  * 1. Redistributions of source code must retain the above copyright
14cfe182f3Schristos  *    notice, this list of conditions and the following disclaimer.
15cfe182f3Schristos  * 2. Redistributions in binary form must reproduce the above copyright
16cfe182f3Schristos  *    notice, this list of conditions and the following disclaimer in the
17cfe182f3Schristos  *    documentation and/or other materials provided with the distribution.
18cfe182f3Schristos  *
19cfe182f3Schristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20cfe182f3Schristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21cfe182f3Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22cfe182f3Schristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23cfe182f3Schristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24cfe182f3Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25cfe182f3Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26cfe182f3Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27cfe182f3Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28cfe182f3Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29cfe182f3Schristos  * POSSIBILITY OF SUCH DAMAGE.
30cfe182f3Schristos  */
31cfe182f3Schristos #include <sys/cdefs.h>
32cfe182f3Schristos #if defined(LIBM_SCCS) && !defined(lint)
33*3f3b0dedSchristos __RCSID("$NetBSD: s_expl.c,v 1.2 2024/01/23 15:45:07 christos Exp $");
34cfe182f3Schristos #endif
35cfe182f3Schristos 
36cfe182f3Schristos #include "namespace.h"
37cfe182f3Schristos #include "math.h"
38cfe182f3Schristos #include <machine/float.h>
39*3f3b0dedSchristos #include <machine/ieee.h>
40cfe182f3Schristos 
41cfe182f3Schristos #ifdef __weak_alias
42cfe182f3Schristos __weak_alias(expl, _expl)
43cfe182f3Schristos __weak_alias(expm1l, _expm1l)
44cfe182f3Schristos #endif
45cfe182f3Schristos 
46cfe182f3Schristos #ifdef __HAVE_LONG_DOUBLE
47cfe182f3Schristos 
48cfe182f3Schristos #if LDBL_MANT_DIG == 64
49cfe182f3Schristos #include "../ld80/s_expl.c"
50cfe182f3Schristos #elif LDBL_MANT_DIG == 113
51cfe182f3Schristos #include "../ld128/s_expl.c"
52cfe182f3Schristos #else
53cfe182f3Schristos #error "Unsupported long double format"
54cfe182f3Schristos #endif
55cfe182f3Schristos 
56cfe182f3Schristos #else
57cfe182f3Schristos 
58cfe182f3Schristos long double
59cfe182f3Schristos expl(long double d)
60cfe182f3Schristos {
61cfe182f3Schristos 	return exp(d);
62cfe182f3Schristos }
63cfe182f3Schristos 
64cfe182f3Schristos long double
65cfe182f3Schristos expm1l(long double d)
66cfe182f3Schristos {
67cfe182f3Schristos 	return expm1(d);
68cfe182f3Schristos }
69cfe182f3Schristos 
70cfe182f3Schristos #endif
71