This library contains code that extends and simplifies different operations
for C language based programs.
Revisión | f2d965665e338b6a9418d6933e620434639dc1da (tree) |
---|---|
Tiempo | 2017-01-23 07:10:52 |
Autor | s.gusarov |
Commiter | s.gusarov |
Added windows.h wrapper
@@ -17,6 +17,7 @@ | ||
17 | 17 | #include "ctools/predef/os.h" |
18 | 18 | #include "ctools/namespace.h" |
19 | 19 | |
20 | + | |
20 | 21 | #ifdef CT_MUTEX_AVAILABLE |
21 | 22 | # error CT_MUTEX_AVAILABLE must be undefined |
22 | 23 | #endif |
@@ -39,9 +40,7 @@ | ||
39 | 40 | # if defined (CT_COMPL_MSVC) |
40 | 41 | # define CT_MUTEX_AVAILABLE |
41 | 42 | |
42 | -CT_BEGIN_EXTERNAL_HEADERS | |
43 | -# include <windows.h> | |
44 | -CT_END_EXTERNAL_HEADERS | |
43 | +# include "ctools/std/windows/windows.h" | |
45 | 44 | |
46 | 45 | |
47 | 46 | CT_BEGIN_NAMESPACE |
@@ -13,22 +13,25 @@ | ||
13 | 13 | |
14 | 14 | #include "ctools/predef/cxx11_attributes.h" |
15 | 15 | #include "ctools/predef/c11_threads.h" |
16 | -#include "ctools/predef/external_headers.h" | |
17 | 16 | #include "ctools/predef/os.h" |
18 | 17 | #include "ctools/namespace.h" |
19 | 18 | |
19 | + | |
20 | 20 | #ifdef CT_THREAD_AVAILABLE |
21 | 21 | # error CT_THREAD_AVAILABLE must be undefined |
22 | 22 | #endif |
23 | 23 | |
24 | 24 | #if defined (CT_C11_THREADES_H_AVAILABLE) |
25 | -# define CT_THREAD_AVAILABLE | |
25 | + | |
26 | +#include "ctools/predef/external_headers.h" | |
26 | 27 | |
27 | 28 | CT_BEGIN_EXTERNAL_HEADERS |
28 | 29 | # include <threads.h> |
29 | 30 | CT_END_EXTERNAL_HEADERS |
30 | 31 | |
31 | 32 | |
33 | +# define CT_THREAD_AVAILABLE | |
34 | + | |
32 | 35 | CT_BEGIN_NAMESPACE |
33 | 36 | |
34 | 37 | typedef thrd_t* ThreadPointer; |
@@ -37,15 +40,14 @@ | ||
37 | 40 | |
38 | 41 | #else |
39 | 42 | # if defined (CT_COMPL_MSVC) |
43 | + | |
44 | +// TODO: Processthreadsapi.h on Windows 8 and Windows Server 2012 | |
45 | +# include "ctools/std/windows/windows.h" | |
46 | + | |
47 | + | |
40 | 48 | # define CT_THREAD_AVAILABLE |
41 | 49 | # define CT_KILL_THREAD_AVAILABLE |
42 | 50 | |
43 | -CT_BEGIN_EXTERNAL_HEADERS | |
44 | -// TODO: Processthreadsapi.h on Windows 8 and Windows Server 2012 | |
45 | -# include <windows.h> | |
46 | -CT_END_EXTERNAL_HEADERS | |
47 | - | |
48 | - | |
49 | 51 | CT_BEGIN_NAMESPACE |
50 | 52 | |
51 | 53 | typedef HANDLE ThreadPointer; // void* |
@@ -53,14 +55,17 @@ | ||
53 | 55 | CT_END_NAMESPACE |
54 | 56 | |
55 | 57 | # elif defined (CT_COMPL_GCC_EMULATION) |
56 | -# define CT_THREAD_AVAILABLE | |
57 | -# define CT_KILL_THREAD_AVAILABLE | |
58 | + | |
59 | +#include "ctools/predef/external_headers.h" | |
58 | 60 | |
59 | 61 | CT_BEGIN_EXTERNAL_HEADERS |
60 | 62 | # include <pthread.h> |
61 | 63 | CT_END_EXTERNAL_HEADERS |
62 | 64 | |
63 | 65 | |
66 | +# define CT_THREAD_AVAILABLE | |
67 | +# define CT_KILL_THREAD_AVAILABLE | |
68 | + | |
64 | 69 | CT_BEGIN_NAMESPACE |
65 | 70 | |
66 | 71 | typedef pthread_t* ThreadPointer; |
@@ -37,4 +37,4 @@ | ||
37 | 37 | # include <inttypes.h> |
38 | 38 | CT_END_EXTERNAL_HEADERS |
39 | 39 | |
40 | -#endif | |
40 | +#endif // defined (CT_COMPL_MSVC) |
@@ -0,0 +1,36 @@ | ||
1 | +/* | |
2 | + * @author Sergey Gusarov <laborer2008 (at) gmail.com> | |
3 | + * @section LICENSE | |
4 | + * This Source Code Form is subject to the terms of the Mozilla Public | |
5 | + * License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | + * | |
8 | + * @section DESCRIPTION | |
9 | + * This file helps to use std::min() and std::max() with Visual C++ | |
10 | + */ | |
11 | + | |
12 | +#pragma once | |
13 | + | |
14 | +#include "ctools/predef/compiler.h" | |
15 | +#include "ctools/predef/external_headers.h" | |
16 | + | |
17 | + | |
18 | +#if defined (CT_COMPL_MSVC) && defined (__cplusplus) | |
19 | + | |
20 | +# if !defined (NOMINMAX) | |
21 | +# define NOMINMAX | |
22 | +# endif | |
23 | + | |
24 | +CT_BEGIN_EXTERNAL_HEADERS | |
25 | +# include <windows.h> | |
26 | +CT_END_EXTERNAL_HEADERS | |
27 | + | |
28 | +# undef NOMINMAX | |
29 | + | |
30 | +#else | |
31 | + | |
32 | +CT_BEGIN_EXTERNAL_HEADERS | |
33 | +# include <windows.h> | |
34 | +CT_END_EXTERNAL_HEADERS | |
35 | + | |
36 | +#endif // defined (CT_COMPL_MSVC) && defined (__cplusplus) |
@@ -108,13 +108,15 @@ | ||
108 | 108 | |
109 | 109 | # ifdef CT_OS_UNIX |
110 | 110 | # include <syslog.h> |
111 | -# elif defined CT_OS_WINDOWS | |
111 | +# endif | |
112 | +CT_END_EXTERNAL_HEADERS | |
113 | + | |
114 | +# if defined CT_OS_WINDOWS | |
112 | 115 | // UNICODE is needed here for FormatMessage()/WideCharToMultiByte() |
113 | 116 | # define UNICODE |
114 | -# include <windows.h> | |
117 | +# include "ctools/std/windows/windows.h" | |
115 | 118 | # undef UNICODE |
116 | 119 | # endif |
117 | -CT_END_EXTERNAL_HEADERS | |
118 | 120 | |
119 | 121 | #include "ctools/predef/attributes.h" |
120 | 122 | #include "ctools/predef/cxx11_attributes.h" |
@@ -0,0 +1,27 @@ | ||
1 | +/* | |
2 | + * @author Sergey Gusarov <laborer2008 (at) gmail.com> | |
3 | + * @section LICENSE | |
4 | + * This Source Code Form is subject to the terms of the Mozilla Public | |
5 | + * License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | + * | |
8 | + * @section DESCRIPTION | |
9 | + * | |
10 | + */ | |
11 | + | |
12 | +#include "tests/unity_headers.h" | |
13 | + | |
14 | +#include <ctools/std/windows/windows.h> | |
15 | + | |
16 | + | |
17 | +void setUp(void) | |
18 | +{ | |
19 | +} | |
20 | + | |
21 | +void tearDown(void) | |
22 | +{ | |
23 | +} | |
24 | + | |
25 | +void testCompile(void) | |
26 | +{ | |
27 | +} |