WPILibC++
2025.1.1
Loading...
Searching...
No Matches
pthreads_cross.h
Go to the documentation of this file.
1
/**
2
Copyright John Schember <john@nachtimwald.com>
3
4
Permission is hereby granted, free of charge, to any person obtaining a copy of
5
this software and associated documentation files (the "Software"), to deal in
6
the Software without restriction, including without limitation the rights to
7
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8
of the Software, and to permit persons to whom the Software is furnished to do
9
so, subject to the following conditions:
10
11
The above copyright notice and this permission notice shall be included in all
12
copies or substantial portions of the Software.
13
14
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
SOFTWARE.
21
*/
22
23
#ifndef __CPTHREAD_H__
24
#define __CPTHREAD_H__
25
26
#ifdef _WIN32
27
#include <stdbool.h>
28
#include <windows.h>
29
#else
30
#include <pthread.h>
31
#include <sched.h>
32
#endif
33
#include <
time.h
>
34
35
#ifdef _WIN32
36
37
typedef
CRITICAL_SECTION pthread_mutex_t;
38
typedef
void
pthread_mutexattr_t;
39
typedef
void
pthread_attr_t;
40
typedef
void
pthread_condattr_t;
41
typedef
void
pthread_rwlockattr_t;
42
typedef
HANDLE pthread_t;
43
typedef
CONDITION_VARIABLE
pthread_cond_t;
44
45
#ifdef __cplusplus
46
extern
"C"
{
47
#endif
48
int
pthread_create(pthread_t *thread, pthread_attr_t *attr,
void
*(*start_routine)(
void
*),
void
*
arg
);
49
int
pthread_join(pthread_t thread,
void
**value_ptr);
50
int
pthread_detach(pthread_t);
51
52
int
pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr);
53
int
pthread_mutex_destroy(pthread_mutex_t *mutex);
54
int
pthread_mutex_lock(pthread_mutex_t *mutex);
55
int
pthread_mutex_unlock(pthread_mutex_t *mutex);
56
57
int
pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr);
58
int
pthread_cond_destroy(pthread_cond_t *cond);
59
int
pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
60
int
pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
const
struct
timespec *abstime);
61
int
pthread_cond_signal(pthread_cond_t *cond);
62
int
pthread_cond_broadcast(pthread_cond_t *cond);
63
64
int
sched_yield(
void
);
65
#ifdef __cplusplus
66
}
67
#endif
68
#endif
69
70
71
#ifdef __cplusplus
72
extern
"C"
{
73
#endif
74
unsigned
int
pcthread_get_num_procs
(
void
);
75
76
void
ms_to_timespec
(
struct
timespec *ts,
unsigned
int
ms);
77
unsigned
int
timespec_to_ms
(
const
struct
timespec *abstime);
78
#ifdef __cplusplus
79
}
80
#endif
81
82
#endif
/* __CPTHREAD_H__ */
ms_to_timespec
void ms_to_timespec(struct timespec *ts, unsigned int ms)
timespec_to_ms
unsigned int timespec_to_ms(const struct timespec *abstime)
pcthread_get_num_procs
unsigned int pcthread_get_num_procs(void)
Copyright John Schember john@nachtimwald.com
time.h
CONDITION_VARIABLE
PVOID CONDITION_VARIABLE
Definition
win.h:215
arg
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Returns a named argument to be used in a formatting function.
Definition
base.h:2775
thirdparty
apriltag
include
common
pthreads_cross.h
Generated on Thu Jan 2 2025 00:19:43 for WPILibC++ by
1.12.0