xsthread.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef XSTHREAD_H
66 #define XSTHREAD_H
67 
68 #include "xstime.h"
69 #if defined(XSENS_DEBUG) && defined(_MSC_VER)
70  #pragma warning (disable: 4985)
71  #include <intrin.h>
72 #endif
73 
74 #ifndef __GNUC__
75  #pragma warning(disable: 4127)
76 #endif
77 
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
81 
82 #ifdef XSENS_WINDOWS
83 #ifndef WINVER // Allow use of features specific to Windows XP or later.
84 #define WINVER 0x0502 // Change this to the appropriate value to target other versions of Windows.
85 #endif
86 
87 #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
88 #define _WIN32_WINNT 0x0502 // Change this to the appropriate value to target other versions of Windows.
89 #endif
90 
91 #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
92 #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
93 #endif
94 
95 #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
96 #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
97 #endif
98 
99 #include <windows.h>
100 
106 enum XsThreadPriority
107 {
108  XS_THREAD_PRIORITY_LOWEST = THREAD_PRIORITY_IDLE,
109  XS_THREAD_PRIORITY_LOWER = THREAD_PRIORITY_LOWEST,
110  XS_THREAD_PRIORITY_LOW = THREAD_PRIORITY_BELOW_NORMAL,
111  XS_THREAD_PRIORITY_NORMAL = THREAD_PRIORITY_NORMAL,
112  XS_THREAD_PRIORITY_HIGH = THREAD_PRIORITY_ABOVE_NORMAL,
113  XS_THREAD_PRIORITY_HIGHER = THREAD_PRIORITY_HIGHEST,
114  XS_THREAD_PRIORITY_HIGHEST = THREAD_PRIORITY_TIME_CRITICAL
115 };
118 // The components of the type of a thread function
119 #define XSENS_THREAD_RETURN DWORD
120 #define XSENS_THREAD_TYPE WINAPI
121 #define XSENS_THREAD_PARAM LPVOID
122 
123 #define XSENS_INVALID_THREAD INVALID_HANDLE_VALUE
124 
131 #define xsYield() Sleep(0)
132 
134 typedef HANDLE XsThread;
135 #ifdef __cplusplus
136 typedef ::DWORD XsThreadId;
137 #else
138 typedef DWORD XsThreadId;
139 #endif
140 
142 #define xsStartThread(func,param,pid) CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) func,param,0,pid)
143 
144 XSTYPES_DLL_API void xsNameThisThread(const char* threadName);
145 
146 #define xsGetCurrentThreadId() GetCurrentThreadId()
147 #define xsSuspendThread(thrd) SuspendThread(thrd)
148 #define xsResumeThread(thrd) ResumeThread(thrd)
149 #define xsSetThreadPriority(thrd,prio) SetThreadPriority(thrd,prio)
150 #define xsGetThreadPriority(thrd) GetThreadPriority(thrd)
151 
152 #else
153 #include <pthread.h>
154 #include <semaphore.h>
155 #include <errno.h>
156 
163 {
164  XS_THREAD_PRIORITY_LOWEST = 0, //THREAD_PRIORITY_IDLE,
165  XS_THREAD_PRIORITY_LOWER = 1, //THREAD_PRIORITY_LOWEST,
166  XS_THREAD_PRIORITY_LOW = 2, //THREAD_PRIORITY_BELOW_NORMAL,
167  XS_THREAD_PRIORITY_NORMAL = 3, //THREAD_PRIORITY_NORMAL,
168  XS_THREAD_PRIORITY_HIGH = 4, //THREAD_PRIORITY_ABOVE_NORMAL,
169  XS_THREAD_PRIORITY_HIGHER = 5, //THREAD_PRIORITY_HIGHEST,
170  XS_THREAD_PRIORITY_HIGHEST = 6 //THREAD_PRIORITY_TIME_CRITICAL
171 };
174 // The components of the type of a thread function
175 #define XSENS_THREAD_RETURN void* // DWORD
176 #define XSENS_THREAD_TYPE // WINAPI
177 #define XSENS_THREAD_PARAM void* // LPVOID
178 
179 #define XSENS_INVALID_THREAD 0 // INVALID_HANDLE_VALUE
180 
182 #define xsYield() sched_yield()
183 
184 XSTYPES_DLL_API void xsNameThisThread(const char* threadName);
186 typedef pthread_t XsThread;
187 typedef pthread_t XsThreadId;
188 
190 pthread_t xsStartThread(void* (func)(void*), void* param, void* pid);
191 #define xsGetCurrentThreadId() pthread_self()
192 #define xsSuspendThread(thrd)
193 #define xsResumeThread(thrd)
194 #define xsSetThreadPriority(thrd,prio)
195 
196 #endif // _WIN32
197 
198 #if !defined(XSENS_USE_POSIX_LOCKING)
199 #if defined(XSENS_WINDOWS)
200 #define XSENS_USE_POSIX_LOCKING 0
201 #else
202 #define XSENS_USE_POSIX_LOCKING 1
203 #endif
204 #endif
205 
206 #ifndef __GNUC__
207 #pragma warning(default: 4127)
208 #endif
209 
210 #ifdef __cplusplus
211 } // extern "C"
212 #endif
213 
215 
216 #endif
XsThreadId
pthread_t XsThreadId
Definition: xsthread.h:187
XS_THREAD_PRIORITY_LOWER
@ XS_THREAD_PRIORITY_LOWER
Definition: xsthread.h:165
XS_THREAD_PRIORITY_HIGH
@ XS_THREAD_PRIORITY_HIGH
Definition: xsthread.h:168
xsNameThisThread
XSTYPES_DLL_API void xsNameThisThread(const char *threadName)
Set the name of the current thread to threadName.
Definition: xsthread.c:140
XS_THREAD_PRIORITY_HIGHER
@ XS_THREAD_PRIORITY_HIGHER
Definition: xsthread.h:169
XsThread
pthread_t XsThread
A handle for a thread.
Definition: xsthread.h:186
XS_THREAD_PRIORITY_NORMAL
@ XS_THREAD_PRIORITY_NORMAL
Definition: xsthread.h:167
xsStartThread
pthread_t xsStartThread(void *(func)(void *), void *param, void *pid)
Start a function as a thread.
Definition: xsthread.c:156
XsThreadPriority
XsThreadPriority
Thread priorities for xsSetThreadPriority() and xsGetThreadPriority()
Definition: xsthread.h:162
XSTYPES_DLL_API
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:65
xstime.h
XS_THREAD_PRIORITY_LOW
@ XS_THREAD_PRIORITY_LOW
Definition: xsthread.h:166
XS_THREAD_PRIORITY_LOWEST
@ XS_THREAD_PRIORITY_LOWEST
Definition: xsthread.h:164
XS_THREAD_PRIORITY_HIGHEST
@ XS_THREAD_PRIORITY_HIGHEST
Definition: xsthread.h:170


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20