Line data Source code
1 : /**
2 : * Copyright Notice:
3 : * Copyright 2022 DMTF. All rights reserved.
4 : * License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/libspdm/blob/main/LICENSE.md
5 : **/
6 :
7 : #include <base.h>
8 : #include <stdlib.h>
9 : #include <sys/time.h>
10 : #include <errno.h>
11 :
12 : /**
13 : * Suspends the execution of the current thread until the time-out interval elapses.
14 : *
15 : * @param microseconds The time interval for which execution is to be suspended, in microseconds.
16 : *
17 : **/
18 73 : void libspdm_sleep(uint64_t microseconds)
19 : {
20 : struct timeval tv;
21 : int err;
22 :
23 73 : tv.tv_sec = microseconds / 1000000;
24 73 : tv.tv_usec = (microseconds % 1000000);
25 :
26 : do {
27 73 : err=select(0, NULL, NULL, NULL, &tv);
28 73 : } while(err<0 && errno==EINTR);
29 73 : }
|