Code Search for Developers
 
 
  

timer-win2.c from The Open2x Project at Krugle


Show timer-win2.c syntax highlighted

// Precise timer routines for WINDOWS

#include <windows.h>
#include <mmsystem.h>
#include "timer.h"

const char *timer_name = "Windows native";

// Returns current time in microseconds
unsigned int GetTimer(){
  return timeGetTime() * 1000;
}

// Returns current time in milliseconds
unsigned int GetTimerMS(){
  return timeGetTime() ;
}

int usec_sleep(int usec_delay){
  // Sleep(0) won't sleep for one clocktick as the unix usleep 
  // instead it will only make the thread ready
  // it may take some time until it actually starts to run again
  if(usec_delay<1000)usec_delay=1000;  
  Sleep( usec_delay/1000);
  return 0;
}

static DWORD RelativeTime = 0;

float GetRelativeTime(){
  DWORD t, r;
  t = GetTimer();
  r = t - RelativeTime;
  RelativeTime = t;
  return (float) r *0.000001F;
}

void InitTimer(){
  GetRelativeTime();
}




See more files for this project here

The Open2x Project

The Open2x project exists to provide an open source resource for the GP2X handheld console based on the MagicEyes MMSP2 processing platform and MP2520F SoC. The project hosts Linux kernel source for the GP2X, boot loader (U-Boot) source and more.

Project homepage: http://www.distant-earth.com/open2x
Programming language(s): Assembly,C,C++
License: other

  Makefile
  fseeko.c
  getch2-win.c
  getch2.c
  getch2.h
  gettimeofday.c
  glob-win.c
  glob.h
  kerneltwosix.h
  keycodes.h
  lrmi.c
  lrmi.h
  macosx_finder_args.c
  mplayer.rc
  scandir.c
  shmem.c
  shmem.h
  strl.c
  strsep.c
  swab.c
  timer-darwin.c
  timer-lx.c
  timer-win2.c
  timer.h
  vbelib.c
  vbelib.h
  vsscanf.c