silcruntime.h: include stdarg.h by default
[runtime.git] / lib / silcutil / silcruntime.h.in
1 /*
2
3   silcruntime.h
4
5   Author: Pekka Riikonen <priikone@silcnet.org>
6
7   Copyright (C) 2008 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; version 2 of the License.
12
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License for more details.
17
18 */
19
20 /****h* silcutil/Runtime Toolkit Interface
21  *
22  * DESCRIPTION
23  *
24  * The SILC Runtime Toolkit API is used to initialize and uninitialize the
25  * Runtime Toolkit.  The application should call silc_runtime_init at the
26  * very start of the application and the silc_runtime_uninit at the very end
27  * of the application before it is exited.
28  *
29  ***/
30
31 #ifndef SILCRUNTIME_H
32 #define SILCRUNTIME_H
33
34 /* Version check macro.  Use this to check that package is of specific
35    version compile time.  Use the __SILC_XXX_VERSION below in comparison.
36    Example:
37
38    #if __SILC_RUNTIME_VERSION < SILC_VERSION(1,2,0)
39      ...
40    #endif
41 */
42 #ifndef SILC_VERSION
43 #define SILC_VERSION(a, b, c) (((a) << 24) + ((b) << 16) + ((c) << 8)
44 #endif /* !SILC_VERSION */
45
46 /* SILC Runtime Toolkit version */
47 @__RUNTIME_PACKAGE_VERSION@
48
49 /* Compilation time defines, for third-party software.  Use these to check
50    in configuration/compilation time how the SILC Runtime Toolkit was
51    configured/compiled. */
52 @__SILC_HAVE_PTHREAD@
53 @__SILC_ENABLE_DEBUG@
54 @__SILC_ENABLE_STACKTRACE@
55 @__SILC_VA_COPY@
56
57 /* Types */
58 #define SILC_SIZEOF_LONG_LONG @SILC_SIZEOF_LONG_LONG@
59 #define SILC_SIZEOF_LONG @SILC_SIZEOF_LONG@
60 #define SILC_SIZEOF_INT @SILC_SIZEOF_INT@
61 #define SILC_SIZEOF_SHORT @SILC_SIZEOF_SHORT@
62 #define SILC_SIZEOF_CHAR @SILC_SIZEOF_CHAR@
63 #define SILC_SIZEOF_VOID_P @SILC_SIZEOF_VOID_P@
64
65 /* Detect OS */
66 #define SILC_UNIX
67
68 #ifdef WIN32
69 #ifndef SILC_WIN32
70 #define SILC_WIN32
71 #undef SILC_UNIX
72 #endif
73 #endif
74
75 #if defined(__EPOC32__) || defined(__SYMBIAN32__)
76 #ifndef SILC_SYMBIAN
77 #define SILC_SYMBIAN
78 #undef SILC_UNIX
79 #undef SILC_WIN32
80 #endif
81 #endif
82
83 #if defined(__MACH__) && defined(__APPLE__)
84 #ifndef SILC_MACOSX
85 #define SILC_MACOSX
86 #undef SILC_WIN32
87 #undef SILC_SYMBIAN
88 #endif
89 #endif
90
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94
95 /* Platform specific includes */
96 #if defined(SILC_WIN32)
97 #include <silcwin32.h>
98 #endif
99
100 #if defined(SILC_SYMBIAN)
101 #include <silcsymbian.h>
102 #endif
103
104 #ifndef DLLAPI
105 #define DLLAPI
106 #endif
107
108 /* We except all systems to have these include files */
109 #include <stdio.h>
110 #include <stdlib.h>
111 #include <string.h>
112 #include <stdarg.h>
113
114 #if defined(HAVE_RUNTIMEDEFS_H)
115
116 /* Automatically generated configuration header.  These are included only
117    when the SILC Runtime Toolkit itself is compiled. */
118 #ifndef SILC_SYMBIAN
119 #include "runtimedefs.h"
120 #else
121 #include "../../symbian/silcdefs.h"
122 #endif /* SILC_SYMBIAN */
123 #include "silcdistdefs.h"
124 #include "silccompile.h"
125
126 #else
127
128 /* Autodetect CPU so that inline assembly in headers are enabled */
129
130 #if defined(__i386__)
131 #undef SILC_I386
132 #undef SILC_I486
133 #define SILC_I386
134 #define SILC_I486
135 #endif /* __i386__ */
136
137 #if defined(__i486__)
138 #undef SILC_I386
139 #undef SILC_I486
140 #define SILC_I386
141 #define SILC_I486
142 #endif /* __i486__ */
143
144 #if defined(__i586__)
145 #undef SILC_I386
146 #undef SILC_I486
147 #undef SILC_I586
148 #define SILC_I386
149 #define SILC_I486
150 #define SILC_I586
151 #endif /* __i586__ */
152
153 #if defined(__i686__)
154 #undef SILC_I386
155 #undef SILC_I486
156 #undef SILC_I586
157 #undef SILC_I686
158 #define SILC_I386
159 #define SILC_I486
160 #define SILC_I586
161 #define SILC_I686
162 #endif /* __i686__ */
163
164 #if defined(__x86_64__)
165 #undef SILC_X86_64
166 #define SILC_X86_64
167 #endif /* __x86_64__ */
168
169 #if defined(__ia64__)
170 #undef SILC_IA64
171 #define SILC_IA64
172 #endif /* __ia64__ */
173
174 #if defined(__ppc__) || defined(__ppc64__)
175 #undef SILC_POWERPC
176 #define SILC_POWERPC
177 #endif /* __ppc__ || __ppc64__ */
178
179 #ifndef SILC_ALIGNMENT
180 #define SILC_ALIGNMENT SILC_SIZEOF_VOID_P
181 #endif /* SILC_ALIGNMENT */
182
183 #endif /* HAVE_RUNTIMEDEFS_H */
184
185 /* Feature defines */
186 #ifdef __SILC_HAVE_PTHREAD
187 #undef SILC_THREADS
188 #define SILC_THREADS 1
189 #endif /* __SILC_HAVE_PTHREAD */
190
191 #ifdef __SILC_ENABLE_DEBUG
192 #undef SILC_DEBUG
193 #define SILC_DEBUG 1
194 #endif /* __SILC_ENABLE_DEBUG */
195
196 #ifdef __SILC_ENABLE_STACKTRACE
197 #undef SILC_STACKTRACE
198 #define SILC_STACKTRACE 1
199 #endif /* __SILC_ENABLE_STACKTRACE */
200
201 /* SILC Runtime Toolkit includes */
202 #include <silctypes.h>
203 #include <silcerrno.h>
204 #include <silcbitops.h>
205 #include <silcmutex.h>
206 #include <silcatomic.h>
207 #include <silcgetopt.h>
208 #include <silcstack.h>
209 #include <silcmemory.h>
210 #include <silclist.h>
211 #include <silcdlist.h>
212 #include <silctree.h>
213 #include <silcsnprintf.h>
214 #include <silctime.h>
215 #include <silctimer.h>
216 #include <silccond.h>
217 #include <silcglobal.h>
218 #include <silcthread.h>
219 #include <silcthreadqueue.h>
220 #include <silcschedule.h>
221 #include <silclog.h>
222 #include <silcfileutil.h>
223 #include <silcdir.h>
224 #include <silcbuffer.h>
225 #include <silcbuffmt.h>
226 #include <silcasync.h>
227 #include <silcregex.h>
228 #include <silcenv.h>
229 #include <silcdll.h>
230 #include <silchashtable.h>
231 #include <silcstream.h>
232 #include <silcnet.h>
233 #include <silcbase64.h>
234 #include <silcstrutil.h>
235 #include <silcutf8.h>
236 #include <silcstringprep.h>
237 #include <silcutil.h>
238 #include <silcconfig.h>
239 #include <silcfsm.h>
240 #include <silcsocketstream.h>
241 #include <silcfdstream.h>
242 #include <silcmime.h>
243 #include <silcrand.h>
244 #include <silcbufferstream.h>
245 #include <silclocalnetstream.h>
246 #include <silcxml.h>
247 #include <silchttpserver.h>
248 #include <silchttpphp.h>
249
250 /* Runtime Toolkit API */
251
252 /****f* silcutil/silc_runtime_init
253  *
254  * SYNOPSIS
255  *
256  *    static inline void silc_runtime_init(void)
257  *
258  * DESCRIPTION
259  *
260  *    Initializes the Runtime Toolkit.  Application should call this as the
261  *    very first call to the Runtime Toolkit.  The function initializes some
262  *    of the Toolkit features.
263  *
264  ***/
265 static inline
266 void silc_runtime_init(void)
267 {
268   /* For now we don't have much here.  Strictly speaking, calling this
269      currently isn't required.  But in the future we may have something that
270      really must be initialized at the very start.  Even the Tls doesn't
271      actually require initialization since any routine using Tls currently
272      takes care of that. */
273
274   /* Initialize Tls for this thread (probably main process thread). */
275   silc_thread_tls_init();
276 }
277
278 /****f* silcutil/silc_runtime_uninit
279  *
280  * SYNOPSIS
281  *
282  *    static inline void silc_runtime_uninit(void)
283  *
284  * DESCRIPTION
285  *
286  *    Uninitializes the Runtime Toolkit.  Application should call this as the
287  *    very last call to the Runtime Toolkit.  The function uninitializes and
288  *    frees all allocated resources.
289  *
290  ***/
291 static inline
292 void silc_runtime_uninit(void)
293 {
294   /* Uninitialize the whole Tls system (not just one thread). */
295   silc_thread_tls_uninit();
296 }
297
298 #ifdef __cplusplus
299 }
300 #endif
301
302 #endif /* SILCRUNTIME_H */