| 1 | /* Compatibility macros for old and new Alpha complex float ABI. |
| 2 | Copyright (C) 2004-2024 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. |
| 4 | |
| 5 | The GNU C Library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | The GNU C Library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with the GNU C Library. If not, see |
| 17 | <https://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | /* The behaviour of complex float changed between GCC 3.3 and 3.4. |
| 20 | |
| 21 | In 3.3 and before (below, complex version 1, or "c1"), complex float |
| 22 | values were packed into one floating point register. |
| 23 | |
| 24 | In 3.4 and later (below, complex version 2, or "c2"), GCC changed to |
| 25 | follow the official Tru64 ABI, which passes the components of a complex |
| 26 | as separate parameters. */ |
| 27 | |
| 28 | typedef union { double d; _Complex float cf; } c1_compat; |
| 29 | # define c1_cfloat_decl(x) double x |
| 30 | # define c1_cfloat_real(x) __real__ c1_cfloat_value (x) |
| 31 | # define c1_cfloat_imag(x) __imag__ c1_cfloat_value (x) |
| 32 | # define c1_cfloat_value(x) (((c1_compat *)(void *)&x)->cf) |
| 33 | # define c1_cfloat_rettype double |
| 34 | # define c1_cfloat_return(x) ({ c1_compat _; _.cf = (x); _.d; }) |
| 35 | |
| 36 | # define c2_cfloat_decl(x) _Complex float x |
| 37 | # define c2_cfloat_real(x) __real__ x |
| 38 | # define c2_cfloat_imag(x) __imag__ x |
| 39 | # define c2_cfloat_value(x) x |
| 40 | # define c2_cfloat_rettype _Complex float |
| 41 | # define c2_cfloat_return(x) x |
| 42 | |
| 43 | /* Get the proper symbol versions defined for each function. */ |
| 44 | |
| 45 | #include <shlib-compat.h> |
| 46 | #include <libm-alias-float.h> |
| 47 | |
| 48 | #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_3_4) |
| 49 | #define cfloat_versions_compat(func) \ |
| 50 | compat_symbol (libm, __c1_##func, func, GLIBC_2_1) |
| 51 | #else |
| 52 | #define cfloat_versions_compat(func) |
| 53 | #endif |
| 54 | |
| 55 | #define cfloat_versions(func) \ |
| 56 | cfloat_versions_compat(func##f); \ |
| 57 | versioned_symbol (libm, __c2_##func##f, func##f, GLIBC_2_3_4); \ |
| 58 | extern typeof(__c2_##func##f) __##func##f attribute_hidden; \ |
| 59 | strong_alias (__c2_##func##f, __##func##f); \ |
| 60 | libm_alias_float_other (__##func, func) |
| 61 | |