| 1 | #pragma once |
| 2 | /* |
| 3 | * Copyright (C) 2005-2011 Team XBMC |
| 4 | * http://www.xbmc.org |
| 5 | * |
| 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) |
| 9 | * any later version. |
| 10 | * |
| 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. |
| 15 | * |
| 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/>. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #define _FILE_OFFSET_BITS 64 |
| 22 | #include <stdlib.h> |
| 23 | #include <stdio.h> |
| 24 | #include <stdarg.h> |
| 25 | #include <string.h> |
| 26 | #include <stdint.h> |
| 27 | #include <unistd.h> |
| 28 | #include <errno.h> |
| 29 | #include <fcntl.h> |
| 30 | #include <sys/types.h> |
| 31 | #include <sys/time.h> |
| 32 | #include <sys/timeb.h> |
| 33 | #include <sys/resource.h> |
| 34 | #include <sys/syscall.h> |
| 35 | #ifndef __APPLE__ |
| 36 | #include <sys/prctl.h> |
| 37 | #endif |
| 38 | #include <pthread.h> |
| 39 | #include <poll.h> |
| 40 | #include <semaphore.h> |
| 41 | |
| 42 | #define LIBTYPE |
| 43 | #define DECLSPEC |
| 44 | |
| 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; } |
| 50 | #endif |
| 51 | |
| 52 | /*! |
| 53 | * @return the current time in seconds since unix epoch. |
| 54 | */ |
| 55 | static inline uint64_t getcurrenttime(void) |
| 56 | { |
| 57 | struct timeval t; |
| 58 | gettimeofday(&t, NULL); |
| 59 | return ((uint64_t)t.tv_sec * 1000) + (t.tv_usec / 1000); |
| 60 | } |