3 * Copyright (C) 2005-2011 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program 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 General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #define _FILE_OFFSET_BITS 64
30 #include <sys/types.h>
32 #include <sys/timeb.h>
33 #include <sys/resource.h>
34 #include <sys/syscall.h>
36 #include <sys/prctl.h>
40 #include <semaphore.h>
45 #ifndef _STL_ALGOBASE_H
46 template<class T
> inline T
min(T a
, T b
) { return a
<= b
? a
: b
; }
47 template<class T
> inline T
max(T a
, T b
) { return a
>= b
? a
: b
; }
48 template<class T
> inline int sgn(T a
) { return a
< 0 ? -1 : a
> 0 ? 1 : 0; }
49 template<class T
> inline void swap(T
&a
, T
&b
) { T t
= a
; a
= b
; b
= t
; }
53 * @return the current time in seconds since unix epoch.
55 static inline uint64_t getcurrenttime(void)
58 gettimeofday(&t
, NULL
);
59 return ((uint64_t)t
.tv_sec
* 1000) + (t
.tv_usec
/ 1000);