• R/O
  • SSH

libctools: Commit

This library contains code that extends and simplifies different operations
for C language based programs.


Commit MetaInfo

Revisiónf2d965665e338b6a9418d6933e620434639dc1da (tree)
Tiempo2017-01-23 07:10:52
Autors.gusarov
Commiters.gusarov

Log Message

Added windows.h wrapper

Cambiar Resumen

Diferencia incremental

diff -r 5b1913a9e3d1 -r f2d965665e33 include/ctools/os/mutex.h
--- a/include/ctools/os/mutex.h Sun Jan 15 04:16:30 2017 +0300
+++ b/include/ctools/os/mutex.h Mon Jan 23 01:10:52 2017 +0300
@@ -17,6 +17,7 @@
1717 #include "ctools/predef/os.h"
1818 #include "ctools/namespace.h"
1919
20+
2021 #ifdef CT_MUTEX_AVAILABLE
2122 # error CT_MUTEX_AVAILABLE must be undefined
2223 #endif
@@ -39,9 +40,7 @@
3940 # if defined (CT_COMPL_MSVC)
4041 # define CT_MUTEX_AVAILABLE
4142
42-CT_BEGIN_EXTERNAL_HEADERS
43-# include <windows.h>
44-CT_END_EXTERNAL_HEADERS
43+# include "ctools/std/windows/windows.h"
4544
4645
4746 CT_BEGIN_NAMESPACE
diff -r 5b1913a9e3d1 -r f2d965665e33 include/ctools/os/thread.h
--- a/include/ctools/os/thread.h Sun Jan 15 04:16:30 2017 +0300
+++ b/include/ctools/os/thread.h Mon Jan 23 01:10:52 2017 +0300
@@ -13,22 +13,25 @@
1313
1414 #include "ctools/predef/cxx11_attributes.h"
1515 #include "ctools/predef/c11_threads.h"
16-#include "ctools/predef/external_headers.h"
1716 #include "ctools/predef/os.h"
1817 #include "ctools/namespace.h"
1918
19+
2020 #ifdef CT_THREAD_AVAILABLE
2121 # error CT_THREAD_AVAILABLE must be undefined
2222 #endif
2323
2424 #if defined (CT_C11_THREADES_H_AVAILABLE)
25-# define CT_THREAD_AVAILABLE
25+
26+#include "ctools/predef/external_headers.h"
2627
2728 CT_BEGIN_EXTERNAL_HEADERS
2829 # include <threads.h>
2930 CT_END_EXTERNAL_HEADERS
3031
3132
33+# define CT_THREAD_AVAILABLE
34+
3235 CT_BEGIN_NAMESPACE
3336
3437 typedef thrd_t* ThreadPointer;
@@ -37,15 +40,14 @@
3740
3841 #else
3942 # 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+
4048 # define CT_THREAD_AVAILABLE
4149 # define CT_KILL_THREAD_AVAILABLE
4250
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-
4951 CT_BEGIN_NAMESPACE
5052
5153 typedef HANDLE ThreadPointer; // void*
@@ -53,14 +55,17 @@
5355 CT_END_NAMESPACE
5456
5557 # 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"
5860
5961 CT_BEGIN_EXTERNAL_HEADERS
6062 # include <pthread.h>
6163 CT_END_EXTERNAL_HEADERS
6264
6365
66+# define CT_THREAD_AVAILABLE
67+# define CT_KILL_THREAD_AVAILABLE
68+
6469 CT_BEGIN_NAMESPACE
6570
6671 typedef pthread_t* ThreadPointer;
diff -r 5b1913a9e3d1 -r f2d965665e33 include/ctools/std/inttypes.h
--- a/include/ctools/std/inttypes.h Sun Jan 15 04:16:30 2017 +0300
+++ b/include/ctools/std/inttypes.h Mon Jan 23 01:10:52 2017 +0300
@@ -37,4 +37,4 @@
3737 # include <inttypes.h>
3838 CT_END_EXTERNAL_HEADERS
3939
40-#endif
40+#endif // defined (CT_COMPL_MSVC)
diff -r 5b1913a9e3d1 -r f2d965665e33 include/ctools/std/windows/windows.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/include/ctools/std/windows/windows.h Mon Jan 23 01:10:52 2017 +0300
@@ -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)
diff -r 5b1913a9e3d1 -r f2d965665e33 include/ctools/trace_ext.h
--- a/include/ctools/trace_ext.h Sun Jan 15 04:16:30 2017 +0300
+++ b/include/ctools/trace_ext.h Mon Jan 23 01:10:52 2017 +0300
@@ -108,13 +108,15 @@
108108
109109 # ifdef CT_OS_UNIX
110110 # include <syslog.h>
111-# elif defined CT_OS_WINDOWS
111+# endif
112+CT_END_EXTERNAL_HEADERS
113+
114+# if defined CT_OS_WINDOWS
112115 // UNICODE is needed here for FormatMessage()/WideCharToMultiByte()
113116 # define UNICODE
114-# include <windows.h>
117+# include "ctools/std/windows/windows.h"
115118 # undef UNICODE
116119 # endif
117-CT_END_EXTERNAL_HEADERS
118120
119121 #include "ctools/predef/attributes.h"
120122 #include "ctools/predef/cxx11_attributes.h"
diff -r 5b1913a9e3d1 -r f2d965665e33 tests/src/std/windows/test_windows.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/src/std/windows/test_windows.c Mon Jan 23 01:10:52 2017 +0300
@@ -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+}
Show on old repository browser