src/timer/psp/SDL_systimer.c
author Sam Lantinga
Sun, 26 May 2013 11:34:04 -0700
changeset 7223 76fa20889de8
parent 7191 75360622e65f
child 7649 4f801cd08f3f
permissions -rw-r--r--
Fixed compile errors building with mingw64
kimonline@7009
     1
/*
kimonline@7009
     2
  Simple DirectMedia Layer
kimonline@7009
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
kimonline@7009
     4
kimonline@7009
     5
  This software is provided 'as-is', without any express or implied
kimonline@7009
     6
  warranty.  In no event will the authors be held liable for any damages
kimonline@7009
     7
  arising from the use of this software.
kimonline@7009
     8
kimonline@7009
     9
  Permission is granted to anyone to use this software for any purpose,
kimonline@7009
    10
  including commercial applications, and to alter it and redistribute it
kimonline@7009
    11
  freely, subject to the following restrictions:
kimonline@7009
    12
kimonline@7009
    13
  1. The origin of this software must not be misrepresented; you must not
kimonline@7009
    14
     claim that you wrote the original software. If you use this software
kimonline@7009
    15
     in a product, an acknowledgment in the product documentation would be
kimonline@7009
    16
     appreciated but is not required.
kimonline@7009
    17
  2. Altered source versions must be plainly marked as such, and must not be
kimonline@7009
    18
     misrepresented as being the original software.
kimonline@7009
    19
  3. This notice may not be removed or altered from any source distribution.
kimonline@7009
    20
*/
kimonline@7009
    21
kimonline@7009
    22
#include "SDL_thread.h"
kimonline@7009
    23
#include "SDL_timer.h"
kimonline@7009
    24
#include "SDL_error.h"
kimonline@7009
    25
#include "../SDL_timer_c.h"
kimonline@7009
    26
#include <stdlib.h>
kimonline@7009
    27
#include <time.h>
kimonline@7009
    28
#include <sys/time.h>
kimonline@7009
    29
#include <pspthreadman.h>
kimonline@7009
    30
kimonline@7009
    31
static struct timeval start;
kimonline@7009
    32
kimonline@7009
    33
void SDL_StartTicks(void)
kimonline@7009
    34
{
slouken@7191
    35
    gettimeofday(&start, NULL);
kimonline@7009
    36
}
kimonline@7009
    37
kimonline@7009
    38
Uint32 SDL_GetTicks(void)
kimonline@7009
    39
{
slouken@7191
    40
    struct timeval now;
slouken@7191
    41
    Uint32 ticks;
kimonline@7009
    42
slouken@7191
    43
    gettimeofday(&now, NULL);
slouken@7191
    44
    ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
slouken@7191
    45
    return(ticks);
kimonline@7009
    46
}
kimonline@7009
    47
kimonline@7009
    48
Uint64
kimonline@7009
    49
SDL_GetPerformanceCounter(void)
kimonline@7009
    50
{
kimonline@7009
    51
    return SDL_GetTicks();
kimonline@7009
    52
}
kimonline@7009
    53
kimonline@7009
    54
Uint64
kimonline@7009
    55
SDL_GetPerformanceFrequency(void)
kimonline@7009
    56
{
kimonline@7009
    57
    return 1000;
kimonline@7009
    58
}
kimonline@7009
    59
kimonline@7009
    60
void SDL_Delay(Uint32 ms)
kimonline@7009
    61
{
slouken@7191
    62
    const Uint32 max_delay = 0xffffffffUL / 1000;
slouken@7191
    63
    if(ms > max_delay)
slouken@7191
    64
        ms = max_delay;
slouken@7191
    65
    sceKernelDelayThreadCB(ms * 1000);
kimonline@7009
    66
}
kimonline@7009
    67
kimonline@7009
    68
/* vim: ts=4 sw=4
kimonline@7009
    69
 */