Skip to content

Commit b253078

Browse files
authored
Merge pull request #8 from iphydf/posix-source
Use nanosleep instead of usleep.
2 parents 48fba6d + 766d57f commit b253078

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

README.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,29 @@ start with, therefore getting familiar with the project.
99

1010
## Features
1111

12-
1. Single File and Small Codebase;
13-
2. Fully Standalone(No 3rd library needed, only rely on toxcore and system c lib);
14-
3. Covered most apis of Friend&Group, and more to go;
15-
4. Fun to play with(Colored text, Async REPL, etc.).
12+
1. Single file and small codebase;
13+
2. Fully standalone (No 3rd library needed, only rely on toxcore and system C library);
14+
3. Covered most APIs of friend & group, and more to come;
15+
4. Fun to play with (colored text, async REPL, etc.).
1616

1717
## Build
1818

19-
If [toxcore](https://github.com/TokTok/c-toxcore) has been installed into system path, Use
19+
If [toxcore](https://github.com/TokTok/c-toxcore) has been installed into the
20+
system path, use
2021

2122
```sh
2223
make
2324
```
2425

25-
Or link it manually (assume libtoxcore.so in TOX\_LIB\_DIR, tox.h in TOX\_H\_DIR/tox):
26+
Or link it manually (assuming `libtoxcore.so` exists in `TOX_LIB_DIR`, and
27+
`tox.h` in `TOX_H_DIR/tox`):
2628

2729
```sh
2830
$ gcc -o minitox minitox.c -I TOX_H_DIR -L TOX_LIB_DIR -Wl,-rpath TOX_LIB_DIR -ltoxcore
2931
```
3032

3133
## Config
3234

33-
To keep simple, `minitox` does not provid command line options,except for `-h` and `--help`.
34-
To change its behaviour, you are encouraged to modify the source file and rebuild. The source
35-
file has been heavily commented.
35+
To keep things simple, `minitox` does not provide command line options, except
36+
for `-h` and `--help`. To change its behaviour, you are encouraged to modify
37+
the source file and rebuild. The source file has been heavily commented.

minitox.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
* MiniTox - A minimal client for Tox
33
*/
44

5+
#ifndef _POSIX_C_SOURCE
6+
#define _POSIX_C_SOURCE 200809L
7+
#endif
8+
59
#include <stdio.h>
610
#include <stdint.h>
711
#include <stdlib.h>
@@ -1342,7 +1346,11 @@ int main(int argc, char **argv) {
13421346
tox_iterate(tox, NULL);
13431347
uint32_t v = tox_iteration_interval(tox);
13441348
msecs += v;
1345-
usleep(v * 1000);
1349+
1350+
struct timespec pause;
1351+
pause.tv_sec = 0;
1352+
pause.tv_nsec = v * 1000 * 1000;
1353+
nanosleep(&pause, NULL);
13461354
}
13471355

13481356
return 0;

0 commit comments

Comments
 (0)