1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/*
This file is part of rt-app - https://launchpad.net/rt-app
Copyright (C) 2010 Giacomo Bagnoli <g.bagnoli@asidev.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _TIMESPEC_UTILS_H_
#define _TIMESPEC_UTILS_H_
#include <time.h>
#include <math.h>
#include <stdio.h>
#include "rt-app_types.h"
#ifndef LOG_PREFIX
#define LOG_PREFIX "[rt-app] "
#endif
#ifndef LOG_LEVEL
#define LOG_LEVEL 50
#endif
#define LOG_LEVEL_DEBUG 100
#define LOG_LEVEL_INFO 50
#define LOG_LEVEL_ERROR 10
#define LOG_LEVEL_CRITICAL 10
/* This prepend a string to a message */
#define rtapp_log_to(where, level, msg, args...) \
do { \
if (level <= LOG_LEVEL) { \
fprintf(where, LOG_PREFIX msg "\n", ##args); \
} \
} while (0);
#define log_info(msg, args...) \
do { \
rtapp_log_to(stderr, LOG_LEVEL_INFO, msg, ##args); \
} while (0);
#define log_error(msg, args...) \
do { \
rtapp_log_to(stderr, LOG_LEVEL_ERROR, msg, ##args); \
} while (0);
#define log_debug(msg, args...) \
do { \
rtapp_log_to(stderr, LOG_LEVEL_DEBUG, msg, ##args); \
} while (0);
#define log_critical(msg, args...) \
do { \
rtapp_log_to(stderr, LOG_LEVEL_CRITICAL, msg, ##args); \
} while (0);
unsigned int
timespec_to_msec(struct timespec *ts);
long
timespec_to_lusec(struct timespec *ts);
unsigned long
timespec_to_usec(struct timespec *ts);
struct timespec
usec_to_timespec(unsigned long usec);
struct timespec
usec_to_timespec(unsigned long usec);
struct timespec
msec_to_timespec(unsigned int msec);
struct timespec
timespec_add(struct timespec *t1, struct timespec *t2);
struct timespec
timespec_sub(struct timespec *t1, struct timespec *t2);
int
timespec_lower(struct timespec *what, struct timespec *than);
void
log_timing(FILE *handler, timing_point_t *t);
pid_t
gettid(void);
#endif // _TIMESPEC_UTILS_H_
/* vim: set ts=8 noexpandtab shiftwidth=8: */
|