2 * Include file for GNU world compatibility with reactos include files for libcaptive
3 * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 /* NEVER protect this include file with #ifndef/#define/#endif
21 * wrapper as we need to be included multiple times
22 * Despite this we still #define the symbol to be able to check it
24 #ifdef _CAPTIVE_REACTOS_COMPAT_H
25 #undef _CAPTIVE_REACTOS_COMPAT_H
26 #define _CAPTIVE_REACTOS_COMPAT_H 2
28 #define _CAPTIVE_REACTOS_COMPAT_H 1
31 /* NEVER use #include in this file before all the #define-s are done
32 * as we pretend any nested #include "reactos/compat.h" automatically as 'succeeded'.
33 * NEVER use any #include inside !REACTOS_COMPAT condition branches.
34 * We never nest as the include is protected by #ifdef from reactos/?*.h includes.
36 #ifdef _CAPTIVE_REACTOS_COMPAT_H_INSIDE
37 #error "$(top_srcdir)/src/libcaptive/include/reactos/compat.h MUST NOT NEST!"
39 #define _CAPTIVE_REACTOS_COMPAT_H_INSIDE 1
42 /* reactos uses __declspec(dllimport) and __declspec(dllexport)
43 * which gets expanded to __attribute__($2) by -D in their Makefile GCC commandline.
46 #define __declspec(type)
51 /* It gets defined to __attribute__((fastcall)) by "ddk/ntddk.h". */
58 /* It gets defined to __attribute__((stdcall)) by "base.h" and "ntos/types.h". */
65 /* It gets defined to __attribute__((cdecl)) by "base.h" and "ntos/types.h"; should not hurt. */
72 /* Get the system declarations as their original names.
73 * reactos will use the redefined ones below.
74 * If we would include <string.h> later the system declarations would have captive_reactos_*
75 * names and system vs. reactos declarations would conflict again - just named captive_reactos_*.
76 * FIXME: Unfortunately we cannot include <string.h> twice.
77 * If we do "reactos/X.h" include from libcaptive (not reactos)
78 * we already lost the possibility to use the optimized
79 * system macros as they are #define-d and we #undef them here.
80 * Fortunately there should also be a system declarations with the same
81 * name and we are satisfied with their non-inlined (=non-#define-d) versions.
86 #define wcscpy captive_reactos_wcscpy
92 #define wcscat captive_reactos_wcscat
98 #define wcschr captive_reactos_wcschr
103 #ifdef REACTOS_COMPAT
104 #define wcsrchr captive_reactos_wcsrchr
109 #ifdef REACTOS_COMPAT
110 #define wcslen captive_reactos_wcslen
115 #ifdef REACTOS_COMPAT
116 #define wcscmp captive_reactos_wcscmp
121 #ifdef REACTOS_COMPAT
122 #define _wcsicmp captive_reactos__wcsicmp
127 #ifdef REACTOS_COMPAT
128 #define wcsncmp captive_reactos_wcsncmp
133 #ifdef REACTOS_COMPAT
135 #define memchr captive_reactos_memchr
140 #ifdef REACTOS_COMPAT
142 #define memcpy captive_reactos_memcpy
147 #ifdef REACTOS_COMPAT
149 #define memmove captive_reactos_memmove
154 #ifdef REACTOS_COMPAT
156 #define memset captive_reactos_memset
161 #ifdef REACTOS_COMPAT
163 #define strcat captive_reactos_strcat
168 #ifdef REACTOS_COMPAT
170 #define strchr captive_reactos_strchr
175 #ifdef REACTOS_COMPAT
177 #define strcmp captive_reactos_strcmp
182 #ifdef REACTOS_COMPAT
184 #define strcpy captive_reactos_strcpy
189 #ifdef REACTOS_COMPAT
191 #define strlen captive_reactos_strlen
196 #ifdef REACTOS_COMPAT
198 #define strncat captive_reactos_strncat
203 #ifdef REACTOS_COMPAT
205 #define strncmp captive_reactos_strncmp
210 #ifdef REACTOS_COMPAT
212 #define strncpy captive_reactos_strncpy
217 #ifdef REACTOS_COMPAT
219 #define strrchr captive_reactos_strrchr
224 #ifdef REACTOS_COMPAT
226 #define strspn captive_reactos_strspn
231 #ifdef REACTOS_COMPAT
233 #define strstr captive_reactos_strstr
238 #ifdef REACTOS_COMPAT
240 #define iswdigit captive_reactos_iswdigit
245 #ifdef REACTOS_COMPAT
247 #define iswlower captive_reactos_iswlower
252 #ifdef REACTOS_COMPAT
254 #define iswxdigit captive_reactos_iswxdigit
259 #ifdef REACTOS_COMPAT
261 #define towlower captive_reactos_towlower
266 #ifdef REACTOS_COMPAT
268 #define towupper captive_reactos_towupper
273 /* Place BEFORE "internal/debug.h" include as there is
274 * internal/debug.h->internal/ntoskrnl.h->ddk/ntddk.h->REACTOS_UCS2()
276 #ifdef REACTOS_COMPAT
277 #include <stddef.h> /* for wchar_t; Prevent <stddef.h> declaration while REACTOS_COMPAT is active */
278 /* You MUST include "captive/unicode_reactos.h" before wchar_t redefinition! */
279 #include "captive/unicode_reactos.h" /* for captive_ucs4_to_ucs2_const() for crtdll/string.h/REACTOS_UCS2() and captive_ucs2 */
280 #define wchar_t captive_ucs2
281 #define REACTOS_UCS2(string_wchar32) (captive_wchar32_to_ucs2_const((string_wchar32)))
287 /* for internal/debug.h */
288 #ifdef REACTOS_COMPAT
294 /* Defined platform as _WIN32 as it is checked by some reactos include files.
295 * I expect it is set by MingW32 as I didn't find it defined anywhere in reactos distribution.
297 #ifdef REACTOS_COMPAT
305 /* reactos/ntos/security.h/'PACCESS_MODE' does not get defined if !__NT(OSKRNL|HAL)__
307 #if _CAPTIVE_REACTOS_COMPAT_H == 1
308 #if !defined(__NTOSKRNL__) && !defined(__NTHAL__)
309 typedef /* ULONG: */ unsigned long ACCESS_MODE, *PACCESS_MODE;
314 /* -------------------------------- #include-s permitted now, #define-s forbidden
315 * See above #define _CAPTIVE_REACTOS_COMPAT_H_INSIDE in this file.
319 /* Define CAPTIVE_CDECL and CAPTIVE_STDCALL call types macros.
320 * They do not need to be undefed as they are common to reactos and non-reactos code.
321 * These macros have to be #ifdef-ed inside reactos itself.
323 #ifdef REACTOS_COMPAT
324 #include "captive/calltype_reactos.h" /* for CAPTIVE_CDECL and CAPTIVE_STDCALL */
327 /* Place AFTER REACTOS_UCS2 definition as there is
328 * internal/debug.h->internal/ntoskrnl.h->ddk/ntddk.h->REACTOS_UCS2()
329 * Some sources (reactos/ntoskrnl/ldr/loader.c) define NDEBUG themselves!
330 * We have to pre-define all the non-NDEBUG (=debug) macros for such source files.
332 #ifdef REACTOS_COMPAT
333 #ifdef __NTOSKRNL__ /* Don't pollute the namespace outside ntoskrnl. */
334 #include "reactos/internal/debug.h"
338 #ifdef REACTOS_COMPAT
339 /* All invalid reactos definitions go to captive_reactos_* as trash */
340 #define _KPCR captive_reactos__KPCR
341 #define KPCR captive_reactos_KPCR
342 #define PKPCR captive_reactos_PKPCR
343 #define _IKPCR captive_reactos__IKPCR
344 #define IKPCR captive_reactos_IKPCR
345 #define PIKPCR captive_reactos_PIKPCR
346 #define KeGetCurrentKPCR captive_reactos_KeGetCurrentKPCR
347 #include "reactos/internal/i386/ps.h"
354 #undef KeGetCurrentKPCR
355 /* Usable libcaptive definition for reactos go to captive_*.
356 * Note we don't leave any defintion under its original symbol name
357 * just to make the whole mess a bit more sane.
359 #include "captive/ps_reactos.h"
360 #define _KPCR captive__KPCR
361 #define KPCR captive_KPCR
362 #define PKPCR captive_PKPCR
363 #define _IKPCR captive__KPCR
364 #define IKPCR captive_KPCR
365 #define PIKPCR captive_PKPCR
366 #define KeGetCurrentKPCR captive_KeGetCurrentKPCR
374 #undef KeGetCurrentKPCR
378 #undef _CAPTIVE_REACTOS_COMPAT_H_INSIDE