mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Introduce and start using microsecond sleep on Linux (#13445)
This commit is contained in:
parent
72ed8514c5
commit
53c594abe0
@ -4262,8 +4262,8 @@ void FpsControl::limit(IrrlichtDevice *device, f32 *dtime)
|
|||||||
|
|
||||||
if (busy_time < frametime_min) {
|
if (busy_time < frametime_min) {
|
||||||
sleep_time = frametime_min - busy_time;
|
sleep_time = frametime_min - busy_time;
|
||||||
if (sleep_time > 1000)
|
if (sleep_time > 0)
|
||||||
sleep_ms(sleep_time / 1000);
|
sleep_us(sleep_time);
|
||||||
} else {
|
} else {
|
||||||
sleep_time = 0;
|
sleep_time = 0;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define sleep_ms(x) Sleep(x)
|
#define sleep_ms(x) Sleep(x)
|
||||||
|
#define sleep_us(x) Sleep((x)/1000)
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstdint> //for uintptr_t
|
#include <cstdint> //for uintptr_t
|
||||||
@ -58,7 +59,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define sleep_ms(x) usleep(x*1000)
|
#define sleep_ms(x) usleep((x)*1000)
|
||||||
|
#define sleep_us(x) usleep(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
Loading…
Reference in New Issue
Block a user