Back to index

glibc  2.9
cfloat-compat.h
Go to the documentation of this file.
00001 /* Compatibility macros for old and new Alpha complex float ABI.
00002    Copyright (C) 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 /* The behaviour of complex float changed between GCC 3.3 and 3.4.  
00021 
00022    In 3.3 and before (below, complex version 1, or "c1"), complex float
00023    values were packed into one floating point register.
00024 
00025    In 3.4 and later (below, complex version 2, or "c2"), GCC changed to
00026    follow the official Tru64 ABI, which passes the components of a complex
00027    as separate parameters.  */
00028 
00029 #if __GNUC_PREREQ(3,4)
00030   typedef union { double d; _Complex float cf; } c1_compat;
00031 # define c1_cfloat_decl(x)  double x
00032 # define c1_cfloat_real(x)  __real__ c1_cfloat_value (x)
00033 # define c1_cfloat_imag(x)  __imag__ c1_cfloat_value (x)
00034 # define c1_cfloat_value(x) (((c1_compat *)(void *)&x)->cf)
00035 # define c1_cfloat_rettype  double
00036 # define c1_cfloat_return(x)       ({ c1_compat _; _.cf = (x); _.d; })
00037 # define c2_cfloat_decl(x)  _Complex float x
00038 # define c2_cfloat_real(x)  __real__ x
00039 # define c2_cfloat_imag(x)  __imag__ x
00040 # define c2_cfloat_value(x) x
00041 # define c2_cfloat_rettype  _Complex float
00042 # define c2_cfloat_return(x)       x
00043 #else
00044 # define c1_cfloat_decl(x)  _Complex float x
00045 # define c1_cfloat_real(x)  __real__ x
00046 # define c1_cfloat_imag(x)  __imag__ x
00047 # define c1_cfloat_value(x) x
00048 # define c1_cfloat_rettype  _Complex float
00049 # define c1_cfloat_return(x)       x
00050 # define c2_cfloat_decl(x)  float x ## r, float x ## i
00051 # define c2_cfloat_real(x)  x ## r
00052 # define c2_cfloat_imag(x)  x ## i
00053 # define c2_cfloat_value(x) \
00054     ({ _Complex float _; __real__ _ = x##r; __imag__ _ = x##i; _; })
00055 # define c2_cfloat_rettype  double _Complex
00056 # define c2_cfloat_return(x)       x
00057 #endif
00058 
00059 /* Get the proper symbol versions defined for each function.  */
00060 
00061 #include <shlib-compat.h>
00062 
00063 #if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_3_4)
00064 #define cfloat_versions_compat(func) \
00065   compat_symbol (libm, __c1_##func, func, GLIBC_2_1)
00066 #else
00067 #define cfloat_versions_compat(func)
00068 #endif
00069 
00070 #define cfloat_versions(func) \
00071   cfloat_versions_compat(func); \
00072   versioned_symbol (libm, __c2_##func, func, GLIBC_2_3_4); \
00073   extern typeof(__c2_##func) __##func attribute_hidden; \
00074   strong_alias (__c2_##func, __##func)