All Classes Namespaces Files Functions Variables Enumerations Enumerator
libs/system/c/urg_delay.c
Go to the documentation of this file.
00001 
00010 #include "detect_os.h"
00011 #if defined(WINDOWS_OS)
00012 #include <windows.h>
00013 #include <time.h>
00014 #else
00015 #include <unistd.h>
00016 #include <sys/time.h>
00017 #endif
00018 
00019 #if defined(MSC)
00020 #pragma comment(lib, "winmm.lib")
00021 #endif
00022 
00023 enum {
00024   False = 0,
00025   True,
00026 };
00027 
00028 #if defined(WINDOWS_OS)
00029 static int is_initialized_ = False;
00030 #endif
00031 
00032 
00033 void urg_delay(int msec)
00034 {
00035 #if defined(WINDOWS_OS)
00036   if (is_initialized_ == False) {
00037     timeBeginPeriod(1);
00038     is_initialized_ = True;
00039   }
00040   Sleep(msec);
00041 
00042 #else
00043   // !!! Mac で動作しないようならば、調整する
00044   usleep(1000 * msec);
00045 #endif
00046 }