Changed silcdefs.h to runtimedefs.h, fixed silccruntime.h.
[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
55 /* Types */
56 #define SILC_SIZEOF_LONG_LONG @SILC_SIZEOF_LONG_LONG@
57 #define SILC_SIZEOF_LONG @SILC_SIZEOF_LONG@
58 #define SILC_SIZEOF_INT @SILC_SIZEOF_INT@
59 #define SILC_SIZEOF_SHORT @SILC_SIZEOF_SHORT@
60 #define SILC_SIZEOF_CHAR @SILC_SIZEOF_CHAR@
61 #define SILC_SIZEOF_VOID_P @SILC_SIZEOF_VOID_P@
62
63 /* Detect OS */
64 #define SILC_UNIX
65
66 #ifdef WIN32
67 #ifndef SILC_WIN32
68 #define SILC_WIN32
69 #undef SILC_UNIX
70 #endif
71 #endif
72
73 #if defined(__EPOC32__) || defined(__SYMBIAN32__)
74 #ifndef SILC_SYMBIAN
75 #define SILC_SYMBIAN
76 #undef SILC_UNIX
77 #undef SILC_WIN32
78 #endif
79 #endif
80
81 #if defined(__MACH__) && defined(__APPLE__)
82 #ifndef SILC_MACOSX
83 #define SILC_MACOSX
84 #undef SILC_WIN32
85 #undef SILC_SYMBIAN
86 #endif
87 #endif
88
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92
93 /* Platform specific includes */
94 #if defined(SILC_WIN32)
95 #include <silcwin32.h>
96 #endif
97
98 #if defined(SILC_SYMBIAN)
99 #include <silcsymbian.h>
100 #endif
101
102 #ifndef DLLAPI
103 #define DLLAPI
104 #endif
105
106 /* We except all systems to have these include files */
107 #include <stdio.h>
108 #include <stdlib.h>
109 #include <string.h>
110
111 #if defined(HAVE_RUNTIMEDEFS_H)
112
113 /* Automatically generated configuration header.  These are included only
114    when the SILC Runtime Toolkit itself is compiled. */
115 #ifndef SILC_SYMBIAN
116 #include "runtimedefs.h"
117 #else
118 #include "../../symbian/silcdefs.h"
119 #endif /* SILC_SYMBIAN */
120 #include "silcdistdefs.h"
121 #include "silccompile.h"
122
123 #else
124
125 /* Autodetect CPU so that inline assembly in headers are enabled */
126
127 #if defined(__i386__)
128 #undef SILC_I386
129 #undef SILC_I486
130 #define SILC_I386
131 #define SILC_I486
132 #endif /* __i386__ */
133
134 #if defined(__i486__)
135 #undef SILC_I386
136 #undef SILC_I486
137 #define SILC_I386
138 #define SILC_I486
139 #endif /* __i486__ */
140
141 #if defined(__i586__)
142 #undef SILC_I386
143 #undef SILC_I486
144 #undef SILC_I586
145 #define SILC_I386
146 #define SILC_I486
147 #define SILC_I586
148 #endif /* __i586__ */
149
150 #if defined(__i686__)
151 #undef SILC_I386
152 #undef SILC_I486
153 #undef SILC_I586
154 #undef SILC_I686
155 #define SILC_I386
156 #define SILC_I486
157 #define SILC_I586
158 #define SILC_I686
159 #endif /* __i686__ */
160
161 #if defined(__x86_64__)
162 #undef SILC_X86_64
163 #define SILC_X86_64
164 #endif /* __x86_64__ */
165
166 #if defined(__ia64__)
167 #undef SILC_IA64
168 #define SILC_IA64
169 #endif /* __ia64__ */
170
171 #if defined(__ppc__) || defined(__ppc64__)
172 #undef SILC_POWERPC
173 #define SILC_POWERPC
174 #endif /* __ppc__ || __ppc64__ */
175
176 #ifndef SILC_ALIGNMENT
177 #define SILC_ALIGNMENT SILC_SIZEOF_VOID_P
178 #endif /* SILC_ALIGNMENT */
179
180 #endif /* HAVE_RUNTIMEDEFS_H */
181
182 /* Feature defines */
183 #ifdef __SILC_HAVE_PTHREAD
184 #undef SILC_THREADS
185 #define SILC_THREADS 1
186 #endif /* __SILC_HAVE_PTHREAD */
187
188 #ifdef __SILC_ENABLE_DEBUG
189 #undef SILC_DEBUG
190 #define SILC_DEBUG 1
191 #endif /* __SILC_ENABLE_DEBUG */
192
193 /* SILC Runtime Toolkit includes */
194 #include <silcerrno.h>
195 #include <silctypes.h>
196 #include <silcbitops.h>
197 #include <silcmutex.h>
198 #include <silcatomic.h>
199 #include <silcgetopt.h>
200 #include <silcstack.h>
201 #include <silcmemory.h>
202 #include <silclist.h>
203 #include <silcdlist.h>
204 #include <silcsnprintf.h>
205 #include <silctime.h>
206 #include <silctimer.h>
207 #include <silccond.h>
208 #include <silcglobal.h>
209 #include <silcthread.h>
210 #include <silcthreadqueue.h>
211 #include <silcschedule.h>
212 #include <silclog.h>
213 #include <silcfileutil.h>
214 #include <silcdir.h>
215 #include <silcbuffer.h>
216 #include <silcbuffmt.h>
217 #include <silcasync.h>
218 #include <silcregex.h>
219 #include <silcenv.h>
220 #include <silcdll.h>
221 #include <silchashtable.h>
222 #include <silcstream.h>
223 #include <silcnet.h>
224 #include <silcbase64.h>
225 #include <silcstrutil.h>
226 #include <silcutf8.h>
227 #include <silcstringprep.h>
228 #include <silcutil.h>
229 #include <silcconfig.h>
230 #include <silcfsm.h>
231 #include <silcsocketstream.h>
232 #include <silcfdstream.h>
233 #include <silcmime.h>
234 #include <silcrand.h>
235
236 /* Runtime Toolkit API */
237
238 /****f* silcutil/silc_runtime_init
239  *
240  * SYNOPSIS
241  *
242  *    static inline void silc_runtime_init(void)
243  *
244  * DESCRIPTION
245  *
246  *    Initializes the Runtime Toolkit.  Application should call this as the
247  *    very first call to the Runtime Toolkit.  The function initializes some
248  *    of the Toolkit features.
249  *
250  ***/
251 static inline
252 void silc_runtime_init(void)
253 {
254   /* For now we don't have much here.  Strictly speaking, calling this
255      currently isn't required.  But in the future we may have something that
256      really must be initialized at the very start.  Even the Tls doesn't
257      actually require initialization since any routine using Tls currently
258      takes care of that. */
259
260   /* Initialize Tls for this thread (probably main process thread). */
261   silc_thread_tls_init();
262 }
263
264 /****f* silcutil/silc_runtime_uninit
265  *
266  * SYNOPSIS
267  *
268  *    static inline void silc_runtime_uninit(void)
269  *
270  * DESCRIPTION
271  *
272  *    Uninitializes the Runtime Toolkit.  Application should call this as the
273  *    very last call to the Runtime Toolkit.  The function uninitializes and
274  *    frees all allocated resources.
275  *
276  ***/
277 static inline
278 void silc_runtime_uninit(void)
279 {
280   /* Uninitialize the whole Tls system (not just one thread). */
281   silc_thread_tls_uninit();
282 }
283
284 #ifdef __cplusplus
285 }
286 #endif
287
288 #endif /* SILCRUNTIME_H */