Refactor file writing - rewrite crypto/opensslconf.h.in as template
[openssl.git] / crypto / opensslconf.h.in
1 /* opensslconf.h */
2 /* WARNING: Generated automatically from opensslconf.h.in by Configure. */
3
4 #ifdef  __cplusplus
5 extern "C" {
6 #endif
7 /* OpenSSL was configured with the following options: */
8 {-
9     if (@{$config{openssl_sys_defines}}) {
10       foreach (@{$config{openssl_sys_defines}}) {
11         $OUT .= "#ifndef $_\n";
12         $OUT .= "# define $_ 1\n";
13         $OUT .= "#endif\n";
14       }
15     }
16     "";
17 -}
18 #ifndef OPENSSL_DOING_MAKEDEPEND
19
20 {-
21     if (@{$config{openssl_experimental_defines}}) {
22       foreach (@{$config{openssl_experimental_defines}}) {
23         (my $ex = $_) =~ s/_NO_/_EXPERIMENTAL_/;
24         $OUT .= "#ifndef $ex\n";
25         $OUT .= "# ifndef $_\n";
26         $OUT .= "#  define $_\n";
27         $OUT .= "# endif\n";
28         $OUT .= "#endif\n";
29       }
30     }
31     "";
32 -}
33 {-
34     foreach (@{$config{openssl_api_defines}}) {
35         (my $macro, my $value) = $_ =~ /^(.*?)=(.*?)$/;
36         $OUT .= "#define OPENSSL_MIN_API $value\n";
37     }
38 -}
39 {-
40     if (@{$config{openssl_algorithm_defines}}) {
41       foreach (@{$config{openssl_algorithm_defines}}) {
42         $OUT .= "#ifndef $_\n";
43         $OUT .= "# define $_\n";
44         $OUT .= "#endif\n";
45       }
46     } else {
47       "   /* no ciphers excluded */\n";
48     }
49 -}
50
51 #endif /* OPENSSL_DOING_MAKEDEPEND */
52
53 {-
54     if (@{$config{openssl_thread_defines}}) {
55       foreach (@{$config{openssl_thread_defines}}) {
56         $OUT .= "#ifndef $_\n";
57         $OUT .= "# define $_\n";
58         $OUT .= "#endif\n";
59       }
60     }
61     "";
62 -}
63 {-
64     if (@{$config{openssl_other_defines}}) {
65       foreach (@{$config{openssl_other_defines}}) {
66         $OUT .= "#ifndef $_\n";
67         $OUT .= "# define $_\n";
68         $OUT .= "#endif\n";
69       }
70     }
71     "";
72 -}
73
74 /* The OPENSSL_NO_* macros are also defined as NO_* if the application
75    asks for it.  This is a transient feature that is provided for those
76    who haven't had the time to do the appropriate changes in their
77    applications.  */
78 #ifdef OPENSSL_ALGORITHM_DEFINES
79 {-
80     if (@{$config{openssl_algorithm_defines}}) {
81       foreach (@{$config{openssl_algorithm_defines}}) {
82         (my $ex = $_) =~ s/^OPENSSL_//;
83         $OUT .= "# if defined($_) \&\& !defined($ex)\n";
84         $OUT .= "#  define $ex\n";
85         $OUT .= "# endif\n";
86       }
87     }
88     "";
89 -}
90 #endif
91
92 {- $target{cpuid_obj} ne "mem_clr.o" ? "#define OPENSSL_CPUID_OBJ" : "" -}
93
94 /*
95  * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the
96  * declarations of functions deprecated in or before <version>. Otherwise, they
97  * still won't see them if the library has been built to disable deprecated
98  * functions.
99  */
100 #if defined(OPENSSL_NO_DEPRECATED)
101 # define DECLARE_DEPRECATED(f)
102 #elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
103 # define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));
104 #else
105 # define DECLARE_DEPRECATED(f)   f;
106 #endif
107
108 #ifndef OPENSSL_MIN_API
109 #define OPENSSL_MIN_API 0
110 #endif
111
112 #if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API
113 #undef OPENSSL_API_COMPAT
114 #define OPENSSL_API_COMPAT OPENSSL_MIN_API
115 #endif
116
117 #if OPENSSL_API_COMPAT < 0x10100000L
118 # define DEPRECATEDIN_1_1_0(f)   DECLARE_DEPRECATED(f)
119 #else
120 # define DEPRECATEDIN_1_1_0(f)
121 #endif
122
123 #if OPENSSL_API_COMPAT < 0x10000000L
124 # define DEPRECATEDIN_1_0_0(f)   DECLARE_DEPRECATED(f)
125 #else
126 # define DEPRECATEDIN_1_0_0(f)
127 #endif
128
129 #if OPENSSL_API_COMPAT < 0x00908000L
130 # define DEPRECATEDIN_0_9_8(f)   DECLARE_DEPRECATED(f)
131 #else
132 # define DEPRECATEDIN_0_9_8(f)
133 #endif
134
135 /* Generate 80386 code? */
136 {- $config{processor} eq "386" ? "#define" : "#undef" -} I386_ONLY
137
138 #if !(defined(VMS) || defined(__VMS)) /* VMS uses logical names instead */
139 #if defined(HEADER_CRYPTLIB_H) && !defined(OPENSSLDIR)
140 #define ENGINESDIR {- quotify1($config{enginesdir}) -}
141 #define OPENSSLDIR {- quotify1($config{openssldir}) -}
142 #endif
143 #endif
144
145 #undef OPENSSL_UNISTD
146 #define OPENSSL_UNISTD {- $target{unistd} -}
147
148 #undef OPENSSL_EXPORT_VAR_AS_FUNCTION
149 {- $config{export_var_as_fn} ? "#define OPENSSL_EXPORT_VAR_AS_FUNCTION" : "" -}
150
151 #if defined(HEADER_IDEA_H) && !defined(IDEA_INT)
152 #define IDEA_INT {- $config{idea_int} -}
153 #endif
154
155 #if defined(HEADER_MD2_H) && !defined(MD2_INT)
156 #define MD2_INT {- $config{md2_int} -}
157 #endif
158
159 #if defined(HEADER_RC2_H) && !defined(RC2_INT)
160 /* I need to put in a mod for the alpha - eay */
161 #define RC2_INT {- $config{rc2_int} -}
162 #endif
163
164 #if defined(HEADER_RC4_H)
165 #if !defined(RC4_INT)
166 /* using int types make the structure larger but make the code faster
167  * on most boxes I have tested - up to %20 faster. */
168 /*
169  * I don't know what does "most" mean, but declaring "int" is a must on:
170  * - Intel P6 because partial register stalls are very expensive;
171  * - elder Alpha because it lacks byte load/store instructions;
172  */
173 #define RC4_INT {- $config{rc4_int} -}
174 #endif
175 #if !defined(RC4_CHUNK)
176 /*
177  * This enables code handling data aligned at natural CPU word
178  * boundary. See crypto/rc4/rc4_enc.c for further details.
179  */
180 {-
181     $config{rc4_chunk}
182       ? "#define RC4_CHUNK ".$config{rc4_chunk}
183       : "#undef RC4_CHUNK";
184 -}
185 #endif
186 #endif
187
188 #ifndef OSSL_DES_LONG
189 /* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
190  * %20 speed up (longs are 8 bytes, int's are 4). */
191 #ifndef OSSL_DES_LONG
192 #define OSSL_DES_LONG {- $config{des_int} -}
193 #endif
194 #endif
195
196 #if defined(HEADER_BN_H) && !defined(CONFIG_HEADER_BN_H) && !defined(OPENSSL_SYS_UEFI)
197 #define CONFIG_HEADER_BN_H
198 {- $config{bn_ll} ? "#define" : "#undef" -} BN_LLONG
199
200 /* Should we define BN_DIV2W here? */
201
202 /* Only one for the following should be defined */
203 {- $config{b64l} ? "#define" : "#undef" -} SIXTY_FOUR_BIT_LONG
204 {- $config{b64}  ? "#define" : "#undef" -} SIXTY_FOUR_BIT
205 {- $config{b32}  ? "#define" : "#undef" -} THIRTY_TWO_BIT
206 #endif
207
208 #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
209 #define CONFIG_HEADER_RC4_LOCL_H
210 /* if this is defined data[i] is used instead of *data, this is a %20
211  * speedup on x86 */
212 {- $config{rc4_idx} ? "#define" : "#undef" -} RC4_INDEX
213 #endif
214
215 #if defined(HEADER_BF_LOCL_H) && !defined(CONFIG_HEADER_BF_LOCL_H)
216 #define CONFIG_HEADER_BF_LOCL_H
217 {-
218     if ($config{bf_ptr} == 0) {
219       "#undef BF_PTR";
220     } elsif ($config{bf_ptr} == 1) {
221       "#define BF_PTR";
222     } elsif ($config{bf_ptr} == 2) {
223       "#define BF_PTR2";
224     }
225 -}
226 #endif /* HEADER_BF_LOCL_H */
227
228 #if defined(HEADER_DES_LOCL_H) && !defined(CONFIG_HEADER_DES_LOCL_H)
229 #define CONFIG_HEADER_DES_LOCL_H
230 #ifndef DES_DEFAULT_OPTIONS
231 /* the following is tweaked from a config script, that is why it is a
232  * protected undef/define */
233 #ifndef DES_PTR
234 {- $config{des_ptr} ? "#define" : "#undef" -} DES_PTR
235 #endif
236
237 /* This helps C compiler generate the correct code for multiple functional
238  * units.  It reduces register dependancies at the expense of 2 more
239  * registers */
240 #ifndef DES_RISC1
241 {- $config{des_risc1} ? "#define" : "#undef" -} DES_RISC1
242 #endif
243
244 #ifndef DES_RISC2
245 {- $config{des_risc2} ? "#define" : "#undef" -} DES_RISC2
246 #endif
247
248 #if defined(DES_RISC1) && defined(DES_RISC2)
249 #error YOU SHOULD NOT HAVE BOTH DES_RISC1 AND DES_RISC2 DEFINED!!!!!
250 #endif
251
252 /* Unroll the inner loop, this sometimes helps, sometimes hinders.
253  * Very mucy CPU dependant */
254 #ifndef DES_UNROLL
255 {- $config{des_unroll} ? "#define" : "#undef" -} DES_UNROLL
256 #endif
257
258 /* These default values were supplied by
259  * Peter Gutman <pgut001@cs.auckland.ac.nz>
260  * They are only used if nothing else has been defined */
261 #if !defined(DES_PTR) && !defined(DES_RISC1) && !defined(DES_RISC2) && !defined(DES_UNROLL)
262 /* Special defines which change the way the code is built depending on the
263    CPU and OS.  For SGI machines you can use _MIPS_SZLONG (32 or 64) to find
264    even newer MIPS CPU's, but at the moment one size fits all for
265    optimization options.  Older Sparc's work better with only UNROLL, but
266    there's no way to tell at compile time what it is you're running on */
267  
268 #if defined(sparc) || defined(__sparc__)        /* Newer Sparc's */
269 #  define DES_PTR
270 #  define DES_RISC1
271 #  define DES_UNROLL
272 #elif defined( __ultrix )       /* Older MIPS */
273 #  define DES_PTR
274 #  define DES_RISC2
275 #  define DES_UNROLL
276 #elif defined( __osf1__ )       /* Alpha */
277 #  define DES_PTR
278 #  define DES_RISC2
279 #elif defined ( _AIX )          /* RS6000 */
280   /* Unknown */
281 #elif defined( __hpux )         /* HP-PA */
282   /* Unknown */
283 #elif defined( __aux )          /* 68K */
284   /* Unknown */
285 #elif defined( __sgi )          /* Newer MIPS */
286 #  define DES_PTR
287 #  define DES_RISC2
288 #  define DES_UNROLL
289 #elif defined(i386) || defined(__i386__)        /* x86 boxes, should be gcc */
290 #  define DES_PTR
291 #  define DES_RISC1
292 #  define DES_UNROLL
293 #endif /* Systems-specific speed defines */
294 #endif
295
296 #endif /* DES_DEFAULT_OPTIONS */
297 #endif /* HEADER_DES_LOCL_H */
298 #ifdef  __cplusplus
299 }
300 #endif