P99
p99_c99.h
Go to the documentation of this file.
1 /* This may look like nonsense, but it really is -*- mode: C; coding: utf-8 -*- */
2 /* */
3 /* Except for parts copied from previous work and as explicitly stated below, */
4 /* the authors and copyright holders for this work are as follows: */
5 /* (C) copyright 2011 Emmanuel Jeanvoine, INRIA, France */
6 /* (C) copyright 2010-2014 Jens Gustedt, INRIA, France */
7 /* */
8 /* This file is free software; it is part of the P99 project. */
9 /* */
10 /* Licensed under the Apache License, Version 2.0 (the "License"); */
11 /* you may not use this file except in compliance with the License. */
12 /* You may obtain a copy of the License at */
13 /* */
14 /* http://www.apache.org/licenses/LICENSE-2.0 */
15 /* */
16 /* Unless required by applicable law or agreed to in writing, software */
17 /* distributed under the License is distributed on an "AS IS" BASIS, */
18 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
19 /* See the License for the specific language governing permissions and */
20 /* limitations under the License. */
21 /* */
22 #ifndef P99_C99_H_
23 # define P99_C99_H_
24 
35 #ifndef __STDC_WANT_LIB_EXT1__
36 # define __STDC_WANT_LIB_EXT1__ 1
37 #endif
38 
39 #include "p99_compiler.h"
40 
41 #if p99_has_feature(complex_h)
42 # include <complex.h>
43 #endif
44 #if p99_has_feature(ctype_h)
45 # include <ctype.h>
46 #endif
47 #if p99_has_feature(errno_h)
48 # include <errno.h>
49 #endif
50 #if p99_has_feature(fenv_h)
51 # include <fenv.h>
52 #endif
53 #if p99_has_feature(inttypes_h)
54 # include <inttypes.h>
55 #endif
56 #if p99_has_feature(locale_h)
57 # include <locale.h>
58 #endif
59 #if p99_has_feature(math_h)
60 # include <math.h>
61 #endif
62 #if p99_has_feature(setjmp_h)
63 # include <setjmp.h>
64 #endif
65 #if p99_has_feature(signal_h)
66 # include <signal.h>
67 #endif
68 #if p99_has_feature(stdio_h)
69 # include <stdio.h>
70 #endif
71 #if p99_has_feature(stdlib_h)
72 # include <stdlib.h>
73 #endif
74 #if p99_has_feature(string_h)
75 # include <string.h>
76 #endif
77 #if p99_has_feature(tgmath_h)
78 # include <tgmath.h>
79 #endif
80 #if p99_has_feature(time_h)
81 # include <time.h>
82 #endif
83 
84 /* Additions by C11 */
85 #if p99_has_feature(stdatomic_h)
86 # include <stdatomic.h>
87 #endif
88 #if p99_has_feature(threads_h)
89 # include <threads.h>
90 #endif
91 #ifndef __STDC_NO_COMPLEX__
92 /* The CMPLX macros expand to an expression of the specified complex
93  * type, with the real part having the (converted) value of x and the
94  * imaginary part having the (converted) value of y. The resulting
95  * expression shall be suitable for use as an initializer for an
96  * object with static or thread storage duration, provided both
97  * arguments are likewise suitable.
98  */
99 # ifndef CMPLXF
100 # define CMPLXF(A, B) ((float _Complex)((float)(A) + _Complex_I * (float)(B)))
101 # endif
102 # ifndef CMPLX
103 # define CMPLX(A, B) ((double _Complex)((double)(A) + _Complex_I * (double)(B)))
104 # endif
105 # ifndef CMPLXL
106 # define CMPLXL(A, B) ((long double _Complex)((long double)(A) + _Complex_I * (long double)(B)))
107 # endif
108 # if __STDC_VERSION__ > 201100L
109 # define p99_creall creall
110 # define p99_crealf crealf
111 # define p99_creal creal
112 # define p99_cimagl cimagl
113 # define p99_cimagf cimagf
114 # define p99_cimag cimag
115 # else
116 /* Each complex type has the same representation and alignment
117  * requirements as an array type containing exactly two elements of
118  * the corresponding real type; the first element is equal to the real
119  * part, and the second element to the imaginary part, of the complex
120  * number. */
121 # define P00_COMPLEX_PARTIAL(T, A, I) \
122  (((const union { \
123  T _Complex p00_c; \
124  T p00_r[2]; \
125  }){ .p00_c = (A) }).p00_r[I])
126 
127 P99_CONST_FUNCTION p99_inline float p99_crealf(float _Complex p00_c) { return P00_COMPLEX_PARTIAL(float, p00_c, 0); }
128 P99_CONST_FUNCTION p99_inline double p99_creal(double _Complex p00_c) { return P00_COMPLEX_PARTIAL(double, p00_c, 0); }
129 P99_CONST_FUNCTION p99_inline long double p99_creall(long double _Complex p00_c) { return P00_COMPLEX_PARTIAL(long double, p00_c, 0); }
130 P99_CONST_FUNCTION p99_inline float p99_cimagf(float _Complex p00_c) { return P00_COMPLEX_PARTIAL(float, p00_c, 1); }
131 P99_CONST_FUNCTION p99_inline double p99_cimag(double _Complex p00_c) { return P00_COMPLEX_PARTIAL(double, p00_c, 1); }
132 P99_CONST_FUNCTION p99_inline long double p99_cimagl(long double _Complex p00_c) { return P00_COMPLEX_PARTIAL(long double, p00_c, 1); }
133 # undef P00_COMPLEX_PARTIAL
134 # endif
135 # endif
136 #endif /* !P99_C99_H_ */
p99_cimagf
P99_CONST_FUNCTION float p99_cimagf(float _Complex p00_c)
Definition: p99_c99.h:130
p99_compiler.h
Group compiler dependencies together in one file.
p99_cimagl
P99_CONST_FUNCTION long double p99_cimagl(long double _Complex p00_c)
Definition: p99_c99.h:132
p99_inline
#define p99_inline
Try to force a function always to be inlined.
Definition: p99_compiler.h:496
P99_CONST_FUNCTION
#define P99_CONST_FUNCTION
On architectures that support this, assert that a function is "const", i.e only depends on parameters...
Definition: p99_compiler.h:622
p99_creall
P99_CONST_FUNCTION long double p99_creall(long double _Complex p00_c)
Definition: p99_c99.h:129
p99_cimag
P99_CONST_FUNCTION double p99_cimag(double _Complex p00_c)
Definition: p99_c99.h:131
p99_creal
P99_CONST_FUNCTION double p99_creal(double _Complex p00_c)
Definition: p99_c99.h:128
p99_crealf
P99_CONST_FUNCTION float p99_crealf(float _Complex p00_c)
Definition: p99_c99.h:127