Following the license change, modify the boilerplates in include/ and crypto/include/
[openssl.git] / include / openssl / opensslconf.h.in
1 /*
2  * {- join("\n * ", @autowarntext) -}
3  *
4  * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
5  *
6  * Licensed under the Apache License 2.0 (the "License").  You may not use
7  * this file except in compliance with the License.  You can obtain a copy
8  * in the file LICENSE in the source distribution or at
9  * https://www.openssl.org/source/license.html
10  */
11
12 #include <openssl/opensslv.h>
13
14 #ifdef  __cplusplus
15 extern "C" {
16 #endif
17
18 #ifdef OPENSSL_ALGORITHM_DEFINES
19 # error OPENSSL_ALGORITHM_DEFINES no longer supported
20 #endif
21
22 /*
23  * OpenSSL was configured with the following options:
24  */
25
26 {- if (@{$config{openssl_sys_defines}}) {
27       foreach (@{$config{openssl_sys_defines}}) {
28         $OUT .= "#ifndef $_\n";
29         $OUT .= "# define $_ 1\n";
30         $OUT .= "#endif\n";
31       }
32     }
33     foreach (@{$config{openssl_api_defines}}) {
34         (my $macro, my $value) = $_ =~ /^(.*?)=(.*?)$/;
35         $OUT .= "#define $macro $value\n";
36     }
37     if (@{$config{openssl_feature_defines}}) {
38       foreach (@{$config{openssl_feature_defines}}) {
39         $OUT .= "#ifndef $_\n";
40         $OUT .= "# define $_\n";
41         $OUT .= "#endif\n";
42       }
43     }
44     "";
45 -}
46
47 /*
48  * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers
49  * don't like that.  This will hopefully silence them.
50  */
51 #define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy;
52
53 /*
54  * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
55  * declarations of functions deprecated in or before <version>.  If this is
56  * undefined, the value of the macro OPENSSL_API_MIN above is the default.
57  *
58  * For any version number up until version 1.1.x, <version> is expected to be
59  * the calculated version number 0xMNNFFPPSL.  For version numbers 3.0.0 and
60  * on, <version> is expected to be only the major version number (i.e. 3 for
61  * version 3.0.0).
62  */
63 #ifndef DECLARE_DEPRECATED
64 # define DECLARE_DEPRECATED(f)   f;
65 # ifdef __GNUC__
66 #  if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
67 #   undef DECLARE_DEPRECATED
68 #   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));
69 #  endif
70 # endif
71 #endif
72
73 /*
74  * We convert the OPENSSL_API_COMPAT value to an API level.  The API level
75  * is the major version number for 3.0.0 and on.  For earlier versions, it
76  * uses this scheme, which is close enough for our purposes:
77  *
78  *      0.x.y   0       (0.9.8 was the last release in this series)
79  *      1.0.x   1       (1.0.2 was the last release in this series)
80  *      1.1.x   2       (1.1.1 was the last release in this series)
81  */
82
83 /* In case someone defined both */
84 #if defined(OPENSSL_API_COMPAT) && defined(OPENSSL_API_LEVEL)
85 # error "Disallowed to defined both OPENSSL_API_COMPAT and OPENSSL_API_LEVEL"
86 #endif
87
88 #ifndef OPENSSL_API_COMPAT
89 # define OPENSSL_API_LEVEL OPENSSL_MIN_API
90 #else
91 # if (OPENSSL_API_COMPAT < 0x1000L) /* Major version numbers up to 16777215 */
92 #  define OPENSSL_API_LEVEL OPENSSL_API_COMPAT
93 # elif (OPENSSL_API_COMPAT & 0xF0000000L) == 0x00000000L
94 #  define OPENSSL_API_LEVEL 0
95 # elif (OPENSSL_API_COMPAT & 0xFFF00000L) == 0x10000000L
96 #  define OPENSSL_API_LEVEL 1
97 # elif (OPENSSL_API_COMPAT & 0xFFF00000L) == 0x10100000L
98 #  define OPENSSL_API_LEVEL 2
99 # else
100 / * Major number 3 to 15 */
101 #  define OPENSSL_API_LEVEL ((OPENSSL_API_COMPAT >> 28) & 0xF)
102 # endif
103 #endif
104
105 /*
106  * Do not deprecate things to be deprecated in version 4.0 before the
107  * OpenSSL version number matches.
108  */
109 #if OPENSSL_VERSION_MAJOR < 4
110 # define DEPRECATEDIN_4(f)       f;
111 # define OPENSSL_API_4 0
112 #elif OPENSSL_API_LEVEL < 4
113 # define DEPRECATEDIN_4(f)       DECLARE_DEPRECATED(f)
114 # define OPENSSL_API_4 0
115 #else
116 # define DEPRECATEDIN_4(f)
117 # define OPENSSL_API_4 1
118 #endif
119
120 #if OPENSSL_API_LEVEL < 3
121 # define DEPRECATEDIN_3(f)       DECLARE_DEPRECATED(f)
122 # define OPENSSL_API_3 0
123 #else
124 # define DEPRECATEDIN_3(f)
125 # define OPENSSL_API_3 1
126 #endif
127
128 #if OPENSSL_API_LEVEL < 2
129 # define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)
130 # define OPENSSL_API_1_1_0 0
131 #else
132 # define DEPRECATEDIN_1_1_0(f)
133 # define OPENSSL_API_1_1_0 1
134 #endif
135
136 #if OPENSSL_API_LEVEL < 1
137 # define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)
138 # define OPENSSL_API_1_0_0 0
139 #else
140 # define DEPRECATEDIN_1_0_0(f)
141 # define OPENSSL_API_1_0_0 1
142 #endif
143
144 #if OPENSSL_API_LEVEL < 0
145 # define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)
146 # define OPENSSL_API_0_9_8 0
147 #else
148 # define DEPRECATEDIN_0_9_8(f)
149 # define OPENSSL_API_0_9_8 1
150 #endif
151
152 #ifndef OPENSSL_FILE
153 # ifdef OPENSSL_NO_FILENAMES
154 #  define OPENSSL_FILE ""
155 #  define OPENSSL_LINE 0
156 # else
157 #  define OPENSSL_FILE __FILE__
158 #  define OPENSSL_LINE __LINE__
159 # endif
160 #endif
161
162 /* Generate 80386 code? */
163 {- $config{processor} eq "386" ? "#define" : "#undef" -} I386_ONLY
164
165 #undef OPENSSL_UNISTD
166 #define OPENSSL_UNISTD {- $target{unistd} -}
167
168 {- $config{export_var_as_fn} ? "#define" : "#undef" -} OPENSSL_EXPORT_VAR_AS_FUNCTION
169
170 /*
171  * The following are cipher-specific, but are part of the public API.
172  */
173 #if !defined(OPENSSL_SYS_UEFI)
174 {- $config{bn_ll} ? "# define" : "# undef" -} BN_LLONG
175 /* Only one for the following should be defined */
176 {- $config{b64l} ? "# define" : "# undef" -} SIXTY_FOUR_BIT_LONG
177 {- $config{b64}  ? "# define" : "# undef" -} SIXTY_FOUR_BIT
178 {- $config{b32}  ? "# define" : "# undef" -} THIRTY_TWO_BIT
179 #endif
180
181 #define RC4_INT {- $config{rc4_int} -}
182
183 #ifdef  __cplusplus
184 }
185 #endif