1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2014
3 //              David Freese, W1HKJ
4 //
5 // This file is part of flmsg
6 //
7 // fldigi is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // fldigi is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20 
21 #ifndef TIMEOPS_H_
22 #define TIMEOPS_H_
23 
24 #include <config.h>
25 #include <time.h>
26 #include <sys/time.h>
27 #ifdef __MINGW32__
28 #  include "compat.h"
29 #  include <pthread.h>
30 //#endif
31 #else
32 #  if !HAVE_CLOCK_GETTIME
33 enum clockid_t { CLOCK_REALTIME, CLOCK_MONOTONIC };
34 int clock_gettime(clockid_t clock_id, struct timespec* tp);
35 #  endif
36 #endif
37 
38 struct timespec operator+(const struct timespec &t0, const double &t);
39 struct timespec operator-(const struct timespec &t0, const struct timespec &t1);
40 struct timespec& operator-=(struct timespec &t0, const struct timespec &t1);
41 bool operator>(const struct timespec &t0, const struct timespec &t1);
42 bool operator==(const struct timespec &t0, const struct timespec &t1);
43 
44 struct timeval operator+(const struct timeval &t0, const double &t);
45 struct timeval operator-(const struct timeval &t0, const struct timeval &t1);
46 struct timeval& operator-=(struct timeval &t0, const struct timeval &t1);
47 bool operator>(const struct timeval &t0, const struct timeval &t1);
48 bool operator==(const struct timeval &t0, const struct timeval &t1);
49 
50 #ifndef GMTIME_R
51 extern struct tm *gmtime_r(const time_t *timer, struct tm *tmbuf);
52 extern struct tm *localtime_r(const time_t *_Time,struct tm *_Tm);
53 #endif
54 
55 #endif // TIMEOPS_H_
56