File: hydra-time.c

package info (click to toggle)
hydra 9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 4,008 kB
  • sloc: ansic: 21,638; sh: 2,166; makefile: 110
file content (31 lines) | stat: -rw-r--r-- 522 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "hydra.h"

#ifndef _WIN32
#include <time.h>
int32_t sleepn(time_t seconds)
{
	struct timespec ts;
	ts.tv_sec = seconds;
	ts.tv_nsec = 0;
   return nanosleep(&ts, NULL);
}
int32_t usleepn(uint64_t milisec) {
	struct timespec ts;
	ts.tv_sec = milisec / 1000;
	ts.tv_nsec = (milisec % 1000) * 1000000L;
	return nanosleep(&ts, NULL);
}

#else

#include <windows.h>
int32_t sleepn(uint32_t seconds) 
{
 return SleepEx(milisec*1000,TRUE);
}

int32_t usleepn(uint32_t milisec) 
{
 return SleepEx(milisec,TRUE);
}
#endif