Nonworking non-GNU OS port code moved to ports repository.
[glibc-ports.git] / sysdeps / alpha / fpu / cfloat-compat.h
blobd325a7650efc0fa9321e4cfc1e75b86786ac176d
1 /* Compatibility macros for old and new Alpha complex float ABI.
2 Copyright (C) 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 /* The behaviour of complex float changed between GCC 3.3 and 3.4.
22 In 3.3 and before (below, complex version 1, or "c1"), complex float
23 values were packed into one floating point register.
25 In 3.4 and later (below, complex version 2, or "c2"), GCC changed to
26 follow the official Tru64 ABI, which passes the components of a complex
27 as separate parameters. */
29 #if __GNUC_PREREQ(3,4)
30 typedef union { double d; _Complex float cf; } c1_compat;
31 # define c1_cfloat_decl(x) double x
32 # define c1_cfloat_real(x) __real__ c1_cfloat_value (x)
33 # define c1_cfloat_imag(x) __imag__ c1_cfloat_value (x)
34 # define c1_cfloat_value(x) (((c1_compat *)(void *)&x)->cf)
35 # define c1_cfloat_rettype double
36 # define c1_cfloat_return(x) ({ c1_compat _; _.cf = (x); _.d; })
37 # define c2_cfloat_decl(x) _Complex float x
38 # define c2_cfloat_real(x) __real__ x
39 # define c2_cfloat_imag(x) __imag__ x
40 # define c2_cfloat_value(x) x
41 # define c2_cfloat_rettype _Complex float
42 # define c2_cfloat_return(x) x
43 #else
44 # define c1_cfloat_decl(x) _Complex float x
45 # define c1_cfloat_real(x) __real__ x
46 # define c1_cfloat_imag(x) __imag__ x
47 # define c1_cfloat_value(x) x
48 # define c1_cfloat_rettype _Complex float
49 # define c1_cfloat_return(x) x
50 # define c2_cfloat_decl(x) float x ## r, float x ## i
51 # define c2_cfloat_real(x) x ## r
52 # define c2_cfloat_imag(x) x ## i
53 # define c2_cfloat_value(x) \
54 ({ _Complex float _; __real__ _ = x##r; __imag__ _ = x##i; _; })
55 # define c2_cfloat_rettype double _Complex
56 # define c2_cfloat_return(x) x
57 #endif
59 /* Get the proper symbol versions defined for each function. */
61 #include <shlib-compat.h>
63 #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_3_4)
64 #define cfloat_versions_compat(func) \
65 compat_symbol (libm, __c1_##func, func, GLIBC_2_1)
66 #else
67 #define cfloat_versions_compat(func)
68 #endif
70 #define cfloat_versions(func) \
71 cfloat_versions_compat(func); \
72 versioned_symbol (libm, __c2_##func, func, GLIBC_2_3_4); \
73 extern typeof(__c2_##func) __##func attribute_hidden; \
74 strong_alias (__c2_##func, __##func)