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