2009-02-09 21:15:56 +00:00
|
|
|
/* ZeroSPU2
|
2010-01-16 16:08:17 +00:00
|
|
|
* Copyright (C) 2006-2010 zerofrog
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
|
|
|
* 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
|
2010-07-04 22:49:00 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2009-02-09 21:15:56 +00:00
|
|
|
*/
|
2009-06-18 08:20:19 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-08-03 18:11:22 +00:00
|
|
|
#ifdef __linux__
|
2009-02-09 21:15:56 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <sys/timeb.h> // ftime(), struct timeb
|
|
|
|
|
|
|
|
#define Sleep(ms) usleep(1000*ms)
|
|
|
|
|
2009-05-17 21:57:24 +00:00
|
|
|
inline u32 timeGetTime()
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
_timeb t;
|
|
|
|
_ftime(&t);
|
|
|
|
#else
|
|
|
|
timeb t;
|
|
|
|
ftime(&t);
|
|
|
|
#endif
|
|
|
|
|
2009-05-17 21:57:24 +00:00
|
|
|
return (u32)(t.time*1000+t.millitm);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
2009-06-18 09:32:35 +00:00
|
|
|
#define InterlockedExchangeAdd _InterlockedExchangeAdd
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
#else
|
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
|
|
|
|
|
|
|
#include <sys/timeb.h> // ftime(), struct timeb
|
|
|
|
#endif
|
|
|
|
|
|
|
|
inline u64 GetMicroTime()
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
extern LARGE_INTEGER g_counterfreq;
|
|
|
|
LARGE_INTEGER count;
|
|
|
|
QueryPerformanceCounter(&count);
|
|
|
|
return count.QuadPart * 1000000 / g_counterfreq.QuadPart;
|
|
|
|
#else
|
|
|
|
timeval t;
|
|
|
|
gettimeofday(&t, NULL);
|
|
|
|
return t.tv_sec*1000000+t.tv_usec;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-08-17 11:03:43 +00:00
|
|
|
#if !defined(_MSC_VER)
|
2011-01-12 23:05:46 +00:00
|
|
|
// declare linux equivalents (alignment must be power of 2 (1,2,4...2^15)
|
2014-08-17 11:03:43 +00:00
|
|
|
static __forceinline void* _aligned_malloc(size_t size, size_t alignment) {
|
|
|
|
void *result=0;
|
|
|
|
posix_memalign(&result, alignment, size);
|
|
|
|
return result;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2014-08-17 11:03:43 +00:00
|
|
|
static __forceinline void _aligned_free(void* p) {
|
|
|
|
free(p);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
#endif
|