1c8ad88661ecdd1d4cce17dcea27cdbf28461d36
[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 #if defined(HAVE_SILCDEFS_H)
103
104 /* Automatically generated configuration header.  These are included only
105    when the SILC Runtime Toolkit itself is compiled. */
106 #ifndef SILC_SYMBIAN
107 #include "silcdefs.h"
108 #else
109 #include "../../symbian/silcdefs.h"
110 #endif /* SILC_SYMBIAN */
111 #include "silcdistdefs.h"
112 #include "silccompile.h"
113
114 #else
115
116 /* Autodetect CPU so that inline assembly in headers are enabled */
117
118 #if defined(__i386__)
119 #undef SILC_I386
120 #undef SILC_I486
121 #define SILC_I386
122 #define SILC_I486
123 #endif /* __i386__ */
124
125 #if defined(__i486__)
126 #undef SILC_I386
127 #undef SILC_I486
128 #define SILC_I386
129 #define SILC_I486
130 #endif /* __i486__ */
131
132 #if defined(__i586__)
133 #undef SILC_I386
134 #undef SILC_I486
135 #undef SILC_I586
136 #define SILC_I386
137 #define SILC_I486
138 #define SILC_I586
139 #endif /* __i586__ */
140
141 #if defined(__i686__)
142 #undef SILC_I386
143 #undef SILC_I486
144 #undef SILC_I586
145 #undef SILC_I686
146 #define SILC_I386
147 #define SILC_I486
148 #define SILC_I586
149 #define SILC_I686
150 #endif /* __i686__ */
151
152 #if defined(__x86_64__)
153 #undef SILC_X86_64
154 #define SILC_X86_64
155 #endif /* __x86_64__ */
156
157 #if defined(__ia64__)
158 #undef SILC_IA64
159 #define SILC_IA64
160 #endif /* __ia64__ */
161
162 #if defined(__ppc__) || defined(__ppc64__)
163 #undef SILC_POWERPC
164 #define SILC_POWERPC
165 #endif /* __ppc__ || __ppc64__ */
166
167 #ifndef SILC_ALIGNMENT
168 #define SILC_ALIGNMENT SILC_SIZEOF_VOID_P
169 #endif /* SILC_ALIGNMENT */
170
171 #endif /* HAVE_SILCDEFS_H */
172
173 /* SILC Runtime Toolkit includes */
174 #include <silcerrno.h>
175 #include <silctypes.h>
176 #include <silcbitops.h>
177 #include <silcmutex.h>
178 #include <silcatomic.h>
179 #include <silcgetopt.h>
180 #include <silcstack.h>
181 #include <silcmemory.h>
182 #include <silclist.h>
183 #include <silcdlist.h>
184 #include <silcsnprintf.h>
185 #include <silctime.h>
186 #include <silctimer.h>
187 #include <silccond.h>
188 #include <silcglobal.h>
189 #include <silcthread.h>
190 #include <silcthreadqueue.h>
191 #include <silcschedule.h>
192 #include <silclog.h>
193 #include <silcfileutil.h>
194 #include <silcdir.h>
195 #include <silcbuffer.h>
196 #include <silcbuffmt.h>
197 #include <silcasync.h>
198 #include <silcregex.h>
199 #include <silcenv.h>
200 #include <silcdll.h>
201 #include <silchashtable.h>
202 #include <silcstream.h>
203 #include <silcnet.h>
204 #include <silcbase64.h>
205 #include <silcstrutil.h>
206 #include <silcutf8.h>
207 #include <silcstringprep.h>
208 #include <silcutil.h>
209 #include <silcconfig.h>
210 #include <silcfsm.h>
211 #include <silcsocketstream.h>
212 #include <silcfdstream.h>
213 #include <silcmime.h>
214 #include <silcrand.h>
215
216 /* Runtime Toolkit API */
217
218 /****f* silcutil/silc_runtime_init
219  *
220  * SYNOPSIS
221  *
222  *    static inline void silc_runtime_init(void)
223  *
224  * DESCRIPTION
225  *
226  *    Initializes the Runtime Toolkit.  Application should call this as the
227  *    very first call to the Runtime Toolkit.  The function initializes some
228  *    of the Toolkit features.
229  *
230  ***/
231 static inline
232 void silc_runtime_init(void)
233 {
234   /* For now we don't have much here.  Strictly speaking, calling this
235      currently isn't required.  But in the future we may have something that
236      really must be initialized at the very start.  Even the Tls doesn't
237      actually require initialization since any routine using Tls currently
238      takes care of that. */
239
240   /* Initialize Tls for this thread (probably main process thread). */
241   silc_thread_tls_init();
242 }
243
244 /****f* silcutil/silc_runtime_uninit
245  *
246  * SYNOPSIS
247  *
248  *    static inline void silc_runtime_uninit(void)
249  *
250  * DESCRIPTION
251  *
252  *    Uninitializes the Runtime Toolkit.  Application should call this as the
253  *    very last call to the Runtime Toolkit.  The function uninitializes and
254  *    frees all allocated resources.
255  *
256  ***/
257 static inline
258 void silc_runtime_uninit(void)
259 {
260   /* Uninitialize the whole Tls system (not just one thread). */
261   silc_thread_tls_uninit();
262 }
263
264 #ifdef __cplusplus
265 }
266 #endif
267
268 #endif /* SILCRUNTIME_H */