Tiny protocol
0.7.0
Tiny communication protocol for microcontrollers
src
proto
hal
mingw32
tiny_defines.h
1
/*
2
Copyright 2016 (C) Alexey Dynda
3
4
This file is part of Tiny Protocol Library.
5
6
Protocol Library is free software: you can redistribute it and/or modify
7
it under the terms of the GNU Lesser General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
Protocol Library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public License
17
along with Protocol Library. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#ifndef _TINY_DEFINES_H_
21
#define _TINY_DEFINES_H_
22
23
#include <pthread.h>
24
#include <unistd.h>
25
#include <stdint.h>
26
#include <time.h>
27
#include <Windows.h>
28
29
#define PLATFORM_MUTEX pthread_mutex_t
30
31
#define MUTEX_INIT(x) pthread_mutex_init(&x, NULL)
32
33
#define MUTEX_LOCK(x) pthread_mutex_lock(&x)
34
35
#define MUTEX_TRY_LOCK(x) pthread_mutex_trylock(&x)
36
37
#define MUTEX_UNLOCK(x) pthread_mutex_unlock(&x)
38
39
#define MUTEX_DESTROY(x) pthread_mutex_destroy(&x)
40
41
#define PLATFORM_COND pthread_cond_t
42
43
#define COND_INIT(x) pthread_cond_init(&x, NULL)
44
45
#define COND_DESTROY(x) pthread_cond_destroy(&x)
46
47
#define COND_WAIT(cond, mutex) pthread_cond_wait(&cond, &mutex)
48
49
#define COND_SIGNAL(x) pthread_cond_signal(&x)
50
51
#define TASK_YIELD() Sleep(0)
52
53
54
static
inline
uint16_t PLATFORM_TICKS()
55
{
56
return
GetTickCount();
57
}
58
59
60
#endif
/* _TINY_DEFINES_H_ */
61
62
Generated by
1.8.13