src/timer/haiku/SDL_systimer.c
author Sam Lantinga <slouken@libsdl.org>
Tue, 26 May 2015 06:27:46 -0700
changeset 9619 b94b6d0bff0f
parent 8268 3f8410f20405
child 9998 f67cf37e9cd4
permissions -rw-r--r--
Updated the copyright year to 2015
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9619
     3
  Copyright (C) 1997-2015 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@0
    22
icculus@7981
    23
#ifdef SDL_TIMER_HAIKU
slouken@1635
    24
icculus@7981
    25
#include <os/kernel/OS.h>
slouken@0
    26
slouken@0
    27
#include "SDL_timer.h"
slouken@0
    28
slouken@0
    29
static bigtime_t start;
urkle@7649
    30
static SDL_bool ticks_started = SDL_FALSE;
slouken@0
    31
slouken@1895
    32
void
slouken@8268
    33
SDL_TicksInit(void)
slouken@0
    34
{
urkle@7649
    35
    if (ticks_started) {
urkle@7649
    36
        return;
urkle@7649
    37
    }
urkle@7649
    38
    ticks_started = SDL_TRUE;
urkle@7649
    39
slouken@1895
    40
    /* Set first ticks value */
slouken@1895
    41
    start = system_time();
slouken@0
    42
}
slouken@0
    43
slouken@8268
    44
void
slouken@8268
    45
SDL_TicksQuit(void)
slouken@8268
    46
{
slouken@8268
    47
    ticks_started = SDL_FALSE;
slouken@8268
    48
}
slouken@8268
    49
slouken@1895
    50
Uint32
slouken@1895
    51
SDL_GetTicks(void)
slouken@0
    52
{
urkle@7649
    53
    if (!ticks_started) {
slouken@8268
    54
        SDL_TicksInit();
urkle@7649
    55
    }
urkle@7649
    56
slouken@1895
    57
    return ((system_time() - start) / 1000);
slouken@0
    58
}
slouken@0
    59
slouken@5514
    60
Uint64
slouken@5514
    61
SDL_GetPerformanceCounter(void)
slouken@5514
    62
{
slouken@5514
    63
    return system_time();
slouken@5514
    64
}
slouken@5514
    65
slouken@5514
    66
Uint64
slouken@5514
    67
SDL_GetPerformanceFrequency(void)
slouken@5514
    68
{
slouken@5514
    69
    return 1000000;
slouken@5514
    70
}
slouken@5514
    71
slouken@1895
    72
void
slouken@1895
    73
SDL_Delay(Uint32 ms)
slouken@0
    74
{
slouken@1895
    75
    snooze(ms * 1000);
slouken@0
    76
}
slouken@0
    77
icculus@7981
    78
#endif /* SDL_TIMER_HAIKU */
slouken@0
    79
slouken@1895
    80
/* vi: set ts=4 sw=4 expandtab: */