Last change
on this file since 536 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.1 KB
|
Line | |
---|
1 | /* Support files for GNU libc. Files in the C namespace go here. |
---|
2 | Files in the system namespace (ie those that start with an underscore) |
---|
3 | go in syscalls.c. |
---|
4 | |
---|
5 | Note: These functions are in a seperate file so that OS providers can |
---|
6 | overrride the system call stubs (defined in syscalls.c) without having |
---|
7 | to provide libc funcitons as well. */ |
---|
8 | |
---|
9 | #include "swi.h" |
---|
10 | #include <errno.h> |
---|
11 | #include <unistd.h> |
---|
12 | |
---|
13 | unsigned __attribute__((weak)) |
---|
14 | alarm (unsigned seconds) |
---|
15 | { |
---|
16 | (void)seconds; |
---|
17 | return 0; |
---|
18 | } |
---|
19 | |
---|
20 | clock_t _clock(void); |
---|
21 | clock_t __attribute__((weak)) |
---|
22 | clock(void) |
---|
23 | { |
---|
24 | return _clock(); |
---|
25 | } |
---|
26 | |
---|
27 | int _isatty(int fildes); |
---|
28 | int __attribute__((weak)) |
---|
29 | isatty(int fildes) |
---|
30 | { |
---|
31 | return _isatty(fildes); |
---|
32 | } |
---|
33 | |
---|
34 | int __attribute__((weak)) |
---|
35 | pause(void) |
---|
36 | { |
---|
37 | errno = ENOSYS; |
---|
38 | return -1; |
---|
39 | } |
---|
40 | |
---|
41 | #include <sys/types.h> |
---|
42 | #include <time.h> |
---|
43 | |
---|
44 | unsigned __attribute__((weak)) |
---|
45 | sleep(unsigned seconds) |
---|
46 | { |
---|
47 | clock_t t0 = _clock(); |
---|
48 | clock_t dt = seconds * CLOCKS_PER_SEC; |
---|
49 | |
---|
50 | while (_clock() - t0 < dt); |
---|
51 | return 0; |
---|
52 | } |
---|
53 | |
---|
54 | int __attribute__((weak)) |
---|
55 | usleep(useconds_t useconds) |
---|
56 | { |
---|
57 | clock_t t0 = _clock(); |
---|
58 | clock_t dt = useconds / (1000000/CLOCKS_PER_SEC); |
---|
59 | |
---|
60 | while (_clock() - t0 < dt); |
---|
61 | return 0; |
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.