New configure-based build system. Still work in progress, but much improved
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401365
This commit is contained in:
parent
1507846225
commit
d3805eef09
453 changed files with 3534 additions and 6707 deletions
|
@ -1,39 +0,0 @@
|
|||
|
||||
## Makefile.am for the SDL timer library
|
||||
|
||||
noinst_LTLIBRARIES = libtimer.la
|
||||
|
||||
ARCH_SUBDIRS = $(srcdir)/amigaos \
|
||||
$(srcdir)/beos \
|
||||
$(srcdir)/dc \
|
||||
$(srcdir)/epoc \
|
||||
$(srcdir)/linux \
|
||||
$(srcdir)/macos \
|
||||
$(srcdir)/mint \
|
||||
$(srcdir)/riscos \
|
||||
$(srcdir)/win32
|
||||
|
||||
# Include the architecture-independent sources
|
||||
COMMON_SRCS = SDL_timer.c SDL_timer_c.h SDL_systimer.h
|
||||
|
||||
# Include the architecture-specific sources
|
||||
if TARGET_MINT
|
||||
ARCH_SRCS = SDL_systimer.c mint/SDL_vbltimer.S mint/SDL_vbltimer_s.h
|
||||
else
|
||||
ARCH_SRCS = SDL_systimer.c
|
||||
endif
|
||||
|
||||
libtimer_la_SOURCES = $(COMMON_SRCS) $(ARCH_SRCS)
|
||||
|
||||
## Let automake know that it shouldn't distribute linked sources
|
||||
BUILT_SOURCES = $(ARCH_SRCS)
|
||||
|
||||
## Let automake know that it should remove these for distribution
|
||||
DISTCLEANFILES = $(ARCH_SRCS)
|
||||
|
||||
# The architecture specific directories need to be copied into place
|
||||
# when building a distribution.
|
||||
dist-hook:
|
||||
(cd $(distdir) && rm -f $(BUILT_SOURCES))
|
||||
cp -rp $(ARCH_SUBDIRS) $(distdir)
|
||||
(cd $(distdir) && rm -rf `find . -name CVS`)
|
|
@ -49,11 +49,7 @@ extern struct ExecBase *SysBase;
|
|||
static struct GfxBase *GfxBase;
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
|
||||
#if defined(DISABLE_THREADS) || defined(FORK_HACK)
|
||||
#define USE_ITIMER
|
||||
#endif
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
/* The first ticks value of the application */
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
static bigtime_t start;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
static unsigned start;
|
||||
|
||||
|
|
83
src/timer/dummy/SDL_systimer.c
Normal file
83
src/timer/dummy/SDL_systimer.c
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2006 Sam Lantinga
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
|
||||
void SDL_StartTicks(void)
|
||||
{
|
||||
}
|
||||
|
||||
Uint32 SDL_GetTicks (void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
||||
/* Data to handle a single periodic alarm */
|
||||
static int timer_alive = 0;
|
||||
static SDL_Thread *timer = NULL;
|
||||
|
||||
static int RunTimer(void *unused)
|
||||
{
|
||||
while ( timer_alive ) {
|
||||
if ( SDL_timer_running ) {
|
||||
SDL_ThreadedTimerCheck();
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* This is only called if the event thread is not running */
|
||||
int SDL_SYS_TimerInit(void)
|
||||
{
|
||||
timer_alive = 1;
|
||||
timer = SDL_CreateThread(RunTimer, NULL);
|
||||
if ( timer == NULL )
|
||||
return(-1);
|
||||
return(SDL_SetTimerThreaded(1));
|
||||
}
|
||||
|
||||
void SDL_SYS_TimerQuit(void)
|
||||
{
|
||||
timer_alive = 0;
|
||||
if ( timer ) {
|
||||
SDL_WaitThread(timer, NULL);
|
||||
timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_SYS_StartTimer(void)
|
||||
{
|
||||
SDL_SetError("Internal logic error: threaded timer in use");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void SDL_SYS_StopTimer(void)
|
||||
{
|
||||
return;
|
||||
}
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
#include "SDL_error.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
static TUint start = 0;
|
||||
static TInt tickPeriodMilliSeconds;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <LowMem.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
#define MS_PER_TICK (1000/60) /* MacOS tick = 1/60 second */
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <LowMem.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
#include "FastTimes.h"
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <mint/mintbind.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
#include "SDL_thread.h"
|
||||
|
||||
#include "mint/SDL_vbltimer_s.h"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
|
||||
#define TIME_WRAP_VALUE (~(DWORD)0)
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
#ifdef DISABLE_THREADS
|
||||
/* Timer start/reset time */
|
||||
#if SDL_THREADS_DISABLED
|
||||
/* Timer SDL_arraysize(Timer ),start/reset time */
|
||||
static Uint32 timerStart;
|
||||
/* Timer running function */
|
||||
void RISCOS_CheckTimer();
|
||||
|
@ -81,7 +81,7 @@ Uint32 SDL_GetTicks (void)
|
|||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
Uint32 now,then,elapsed;
|
||||
#ifndef DISABLE_THREADS
|
||||
#if !SDL_THREADS_DISABLED
|
||||
int is_event_thread;
|
||||
if (riscos_using_threads)
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ void SDL_Delay (Uint32 ms)
|
|||
|
||||
do {
|
||||
/* Do background tasks required while sleeping as we are not multithreaded */
|
||||
#ifdef DISABLE_THREADS
|
||||
#if SDL_THREADS_DISABLED
|
||||
RISCOS_BackgroundTasks();
|
||||
#else
|
||||
/* For threaded build only run background tasks in event thread */
|
||||
|
@ -116,7 +116,7 @@ void SDL_Delay (Uint32 ms)
|
|||
break;
|
||||
}
|
||||
ms -= elapsed;
|
||||
#ifndef DISABLE_THREADS
|
||||
#if !SDL_THREADS_DISABLED
|
||||
/* Need to yield to let other threads have a go */
|
||||
if (riscos_using_threads) pthread_yield();
|
||||
#endif
|
||||
|
@ -124,7 +124,7 @@ void SDL_Delay (Uint32 ms)
|
|||
} while ( 1 );
|
||||
}
|
||||
|
||||
#ifdef DISABLE_THREADS
|
||||
#if SDL_THREADS_DISABLED
|
||||
|
||||
/* Non-threaded version of timer */
|
||||
|
||||
|
@ -225,4 +225,4 @@ void SDL_SYS_StopTimer(void)
|
|||
return;
|
||||
}
|
||||
|
||||
#endif /* DISABLE_THREADS */
|
||||
#endif /* SDL_THREADS_DISABLED */
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
|
||||
RDTSC stuff by lompik (lompik@voila.fr) 20/03/2002
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -29,125 +27,40 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
/* The clock_gettime provides monotonous time, so we should use it if
|
||||
it's available. The clock_gettime function is behind ifdef
|
||||
for __USE_POSIX199309
|
||||
Tommi Kyntola (tommi.kyntola@ray.fi) 27/09/2005
|
||||
*/
|
||||
#if (defined _POSIX_TIMERS && _POSIX_TIMERS + 0 > 0)
|
||||
#if HAVE_CLOCK_GETTIME
|
||||
#include <time.h>
|
||||
/*
|
||||
* clock_gettime() is missing in my system's glibc, and apparently isn't
|
||||
* available before Linux kernel 2.6...you can uncomment the following
|
||||
* define to use it, since it may be a better solution than
|
||||
* gettimeofday() on systems that support the newer syscall. --ryan.
|
||||
*/
|
||||
/*#define USE_CLOCK_GETTIME*/
|
||||
#endif
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
|
||||
#if _POSIX_THREAD_SYSCALL_SOFT
|
||||
#if SDL_THREAD_PTH
|
||||
#include <pth.h>
|
||||
#elif _POSIX_THREAD_SYSCALL_SOFT
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#ifdef ENABLE_PTH
|
||||
#include <pth.h>
|
||||
#endif
|
||||
|
||||
#if defined(DISABLE_THREADS) || defined(FORK_HACK)
|
||||
#if SDL_THREADS_DISABLED
|
||||
#define USE_ITIMER
|
||||
#endif
|
||||
|
||||
/* The following defines should really be determined at configure time */
|
||||
|
||||
#if defined(linux)
|
||||
/* Linux select() changes its timeout parameter upon return to contain
|
||||
the remaining time. Most other unixen leave it unchanged or undefined. */
|
||||
#define SELECT_SETS_REMAINING
|
||||
#elif defined(__bsdi__) || defined(__FreeBSD__) || defined(__sun) || defined(MACOSX)
|
||||
#define USE_NANOSLEEP
|
||||
#endif
|
||||
|
||||
#if defined(i386) || defined(__i386__)
|
||||
/* This only works on pentium or newer x86 processors */
|
||||
/* Actually, this isn't reliable on multi-cpu systems, so is disabled */
|
||||
/*#define USE_RDTSC*/
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_RDTSC
|
||||
|
||||
/* The first ticks value of the application */
|
||||
static unsigned long long start;
|
||||
static float cpu_mhz1000 = 0.0f;
|
||||
|
||||
#if 1
|
||||
/* This is for old binutils version that don't recognize rdtsc mnemonics.
|
||||
But all binutils version supports this.
|
||||
*/
|
||||
#define rdtsc(t) asm __volatile__ (".byte 0x0f, 0x31; " : "=A" (t))
|
||||
#else
|
||||
#define rdtsc(t) asm __volatile__ ("rdtsc" : "=A" (t))
|
||||
#endif
|
||||
|
||||
static float calc_cpu_mhz(void)
|
||||
{
|
||||
float cpu_mhz;
|
||||
unsigned long long tsc_start;
|
||||
unsigned long long tsc_end;
|
||||
/* Slight code doubling here for the sake of readability */
|
||||
#ifdef USE_CLOCK_GETTIME
|
||||
struct timespec tv_start, tv_end;
|
||||
long usec_delay;
|
||||
|
||||
rdtsc(tsc_start);
|
||||
clock_gettime(CLOCK_MONOTONIC,&tv_start);
|
||||
sleep(1);
|
||||
rdtsc(tsc_end);
|
||||
clock_gettime(CLOCK_MONOTONIC,&tv_end);
|
||||
usec_delay = (1000000000L * (tv_end.tv_sec - tv_start.tv_sec) +
|
||||
(tv_end.tv_nsec - tv_start.tv_nsec)) / 1000;
|
||||
#else
|
||||
struct timeval tv_start, tv_end;
|
||||
long usec_delay;
|
||||
|
||||
rdtsc(tsc_start);
|
||||
gettimeofday(&tv_start, NULL);
|
||||
sleep(1);
|
||||
rdtsc(tsc_end);
|
||||
gettimeofday(&tv_end, NULL);
|
||||
usec_delay = 1000000L * (tv_end.tv_sec - tv_start.tv_sec) +
|
||||
(tv_end.tv_usec - tv_start.tv_usec);
|
||||
#endif /* USE_CLOCK_GETTIME */
|
||||
cpu_mhz = (float)(tsc_end-tsc_start) / usec_delay;
|
||||
#if 0
|
||||
printf("cpu MHz\t\t: %.3f\n", cpu_mhz);
|
||||
#endif
|
||||
return cpu_mhz;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* The first ticks value of the application */
|
||||
#ifdef USE_CLOCK_GETTIME
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
static struct timespec start;
|
||||
#else
|
||||
static struct timeval start;
|
||||
#endif /* USE_CLOCK_GETTIME */
|
||||
|
||||
#endif /* USE_RDTSC */
|
||||
#endif /* HAVE_CLOCK_GETTIME */
|
||||
|
||||
|
||||
void SDL_StartTicks(void)
|
||||
{
|
||||
/* Set first ticks value */
|
||||
#ifdef USE_RDTSC
|
||||
if ( ! cpu_mhz1000 ) {
|
||||
cpu_mhz1000 = calc_cpu_mhz() * 1000.0f;
|
||||
}
|
||||
rdtsc(start);
|
||||
#elif defined(USE_CLOCK_GETTIME)
|
||||
#if HAVE_CLOCK_GETTIME
|
||||
clock_gettime(CLOCK_MONOTONIC,&start);
|
||||
#else
|
||||
gettimeofday(&start, NULL);
|
||||
|
@ -156,14 +69,7 @@ void SDL_StartTicks(void)
|
|||
|
||||
Uint32 SDL_GetTicks (void)
|
||||
{
|
||||
#ifdef USE_RDTSC
|
||||
unsigned long long now;
|
||||
if ( ! cpu_mhz1000 ) {
|
||||
return 0; /* Shouldn't happen. BUG!! */
|
||||
}
|
||||
rdtsc(now);
|
||||
return (Uint32)((now-start)/cpu_mhz1000);
|
||||
#elif defined(USE_CLOCK_GETTIME)
|
||||
#if HAVE_CLOCK_GETTIME
|
||||
Uint32 ticks;
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC,&now);
|
||||
|
@ -180,7 +86,7 @@ Uint32 SDL_GetTicks (void)
|
|||
|
||||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
#ifdef ENABLE_PTH
|
||||
#if SDL_THREAD_PTH
|
||||
pth_time_t tv;
|
||||
tv.tv_sec = ms/1000;
|
||||
tv.tv_usec = (ms%1000)*1000;
|
||||
|
@ -188,20 +94,15 @@ void SDL_Delay (Uint32 ms)
|
|||
#else
|
||||
int was_error;
|
||||
|
||||
#ifdef USE_NANOSLEEP
|
||||
#if HAVE_NANOSLEEP
|
||||
struct timespec elapsed, tv;
|
||||
#else
|
||||
struct timeval tv;
|
||||
#ifndef SELECT_SETS_REMAINING
|
||||
Uint32 then, now, elapsed;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Set the timeout interval - Linux only needs to do this once */
|
||||
#ifdef SELECT_SETS_REMAINING
|
||||
tv.tv_sec = ms/1000;
|
||||
tv.tv_usec = (ms%1000)*1000;
|
||||
#elif defined(USE_NANOSLEEP)
|
||||
/* Set the timeout interval */
|
||||
#if HAVE_NANOSLEEP
|
||||
elapsed.tv_sec = ms/1000;
|
||||
elapsed.tv_nsec = (ms%1000)*1000000;
|
||||
#else
|
||||
|
@ -213,12 +114,11 @@ void SDL_Delay (Uint32 ms)
|
|||
#if _POSIX_THREAD_SYSCALL_SOFT
|
||||
pthread_yield_np();
|
||||
#endif
|
||||
#ifdef USE_NANOSLEEP
|
||||
#if HAVE_NANOSLEEP
|
||||
tv.tv_sec = elapsed.tv_sec;
|
||||
tv.tv_nsec = elapsed.tv_nsec;
|
||||
was_error = nanosleep(&tv, &elapsed);
|
||||
#else
|
||||
#ifndef SELECT_SETS_REMAINING
|
||||
/* Calculate the time interval left (in case of interrupt) */
|
||||
now = SDL_GetTicks();
|
||||
elapsed = (now-then);
|
||||
|
@ -229,11 +129,11 @@ void SDL_Delay (Uint32 ms)
|
|||
ms -= elapsed;
|
||||
tv.tv_sec = ms/1000;
|
||||
tv.tv_usec = (ms%1000)*1000;
|
||||
#endif
|
||||
|
||||
was_error = select(0, NULL, NULL, NULL, &tv);
|
||||
#endif /* USE_NANOSLEEP */
|
||||
#endif /* HAVE_NANOSLEEP */
|
||||
} while ( was_error && (errno == EINTR) );
|
||||
#endif /* ENABLE_PTH */
|
||||
#endif /* SDL_THREAD_PTH */
|
||||
}
|
||||
|
||||
#ifdef USE_ITIMER
|
|
@ -24,7 +24,7 @@
|
|||
#include <mmsystem.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#error This is WinCE. Please use src/timer/wince/SDL_systimer.c instead.
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <mmsystem.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_timer_c.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
static Uint64 start_date;
|
||||
static Uint64 start_ticks;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue