SDL 2.0
SDL_systimer.c
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "../../SDL_internal.h"
22
23#ifdef SDL_TIMERS_PSP
24
25#include "SDL_thread.h"
26#include "SDL_timer.h"
27#include "SDL_error.h"
28#include "../SDL_timer_c.h"
29#include <stdlib.h>
30#include <time.h>
31#include <sys/time.h>
32#include <pspthreadman.h>
33
34static struct timeval start;
35static SDL_bool ticks_started = SDL_FALSE;
36
37void
38SDL_TicksInit(void)
39{
40 if (ticks_started) {
41 return;
42 }
43 ticks_started = SDL_TRUE;
44
45 gettimeofday(&start, NULL);
46}
47
48void
49SDL_TicksQuit(void)
50{
51 ticks_started = SDL_FALSE;
52}
53
55{
56 if (!ticks_started) {
58 }
59
60 struct timeval now;
62
63 gettimeofday(&now, NULL);
64 ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
65 return(ticks);
66}
67
70{
71 return SDL_GetTicks();
72}
73
76{
77 return 1000;
78}
79
80void SDL_Delay(Uint32 ms)
81{
82 const Uint32 max_delay = 0xffffffffUL / 1000;
83 if(ms > max_delay)
84 ms = max_delay;
85 sceKernelDelayThreadCB(ms * 1000);
86}
87
88#endif /* SDL_TIMERS_PSP */
89
90/* vim: ts=4 sw=4
91 */
#define SDL_GetPerformanceCounter
#define SDL_Delay
GLuint start
Definition: SDL_opengl.h:1571
SDL_bool
Definition: SDL_stdinc.h:162
@ SDL_TRUE
Definition: SDL_stdinc.h:164
@ SDL_FALSE
Definition: SDL_stdinc.h:163
uint32_t Uint32
Definition: SDL_stdinc.h:203
uint64_t Uint64
Definition: SDL_stdinc.h:216
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
Uint64 SDL_GetPerformanceFrequency(void)
Get the count per second of the high resolution counter.
void SDL_TicksQuit(void)
void SDL_TicksInit(void)
#define NULL
Definition: begin_code.h:167
static int ticks
Definition: testtimer.c:24