1*4afb647cSTimo Kreuzer
2*4afb647cSTimo Kreuzer /*******************************************************************************
3*4afb647cSTimo Kreuzer MIT License
4*4afb647cSTimo Kreuzer -----------
5*4afb647cSTimo Kreuzer
6*4afb647cSTimo Kreuzer Copyright (c) 2002-2019 Advanced Micro Devices, Inc.
7*4afb647cSTimo Kreuzer
8*4afb647cSTimo Kreuzer Permission is hereby granted, free of charge, to any person obtaining a copy
9*4afb647cSTimo Kreuzer of this Software and associated documentaon files (the "Software"), to deal
10*4afb647cSTimo Kreuzer in the Software without restriction, including without limitation the rights
11*4afb647cSTimo Kreuzer to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12*4afb647cSTimo Kreuzer copies of the Software, and to permit persons to whom the Software is
13*4afb647cSTimo Kreuzer furnished to do so, subject to the following conditions:
14*4afb647cSTimo Kreuzer
15*4afb647cSTimo Kreuzer The above copyright notice and this permission notice shall be included in
16*4afb647cSTimo Kreuzer all copies or substantial portions of the Software.
17*4afb647cSTimo Kreuzer
18*4afb647cSTimo Kreuzer THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19*4afb647cSTimo Kreuzer IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20*4afb647cSTimo Kreuzer FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21*4afb647cSTimo Kreuzer AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22*4afb647cSTimo Kreuzer LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23*4afb647cSTimo Kreuzer OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24*4afb647cSTimo Kreuzer THE SOFTWARE.
25*4afb647cSTimo Kreuzer *******************************************************************************/
26*4afb647cSTimo Kreuzer
27*4afb647cSTimo Kreuzer #include "libm.h"
28*4afb647cSTimo Kreuzer #include "libm_util.h"
29*4afb647cSTimo Kreuzer
30*4afb647cSTimo Kreuzer /* Returns the absolute value of x with the sign of y.
31*4afb647cSTimo Kreuzer NaNs are not considered special; their sign bits are handled
32*4afb647cSTimo Kreuzer the same as for any other number. */
33*4afb647cSTimo Kreuzer
FN_PROTOTYPE(_copysignf)34*4afb647cSTimo Kreuzer float FN_PROTOTYPE(_copysignf)(float x, float y)
35*4afb647cSTimo Kreuzer {
36*4afb647cSTimo Kreuzer unsigned int ux, uy;
37*4afb647cSTimo Kreuzer GET_BITS_SP32(x, ux);
38*4afb647cSTimo Kreuzer GET_BITS_SP32(y, uy);
39*4afb647cSTimo Kreuzer if ((ux ^ uy) & SIGNBIT_SP32)
40*4afb647cSTimo Kreuzer PUT_BITS_SP32(ux ^ SIGNBIT_SP32, x);
41*4afb647cSTimo Kreuzer return x;
42*4afb647cSTimo Kreuzer }
43