diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-01-24 00:29:55 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-01-24 00:29:55 +0100 |
commit | e9a40e3b91f699c08053d7307bf50b0764811b8e (patch) | |
tree | 790f2cae8fbca16cfa2b5c1f5ed98d4c4afdf198 | |
parent | dc6cd12569e6ac3775b11f6285ccc1bb81b13af0 (diff) | |
download | busybox-w32-e9a40e3b91f699c08053d7307bf50b0764811b8e.tar.gz busybox-w32-e9a40e3b91f699c08053d7307bf50b0764811b8e.tar.bz2 busybox-w32-e9a40e3b91f699c08053d7307bf50b0764811b8e.zip |
libbb: make ndelay_no/off a bit more clever. +14 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | include/libbb.h | 6 | ||||
-rw-r--r-- | libbb/xfuncs.c | 18 |
2 files changed, 15 insertions, 9 deletions
diff --git a/include/libbb.h b/include/libbb.h index 55510316b..6e37b8d04 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -348,9 +348,9 @@ extern char *bb_get_last_path_component_strip(char *path) FAST_FUNC; | |||
348 | /* "abc/def/" -> "" and it never modifies 'path' */ | 348 | /* "abc/def/" -> "" and it never modifies 'path' */ |
349 | extern char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC; | 349 | extern char *bb_get_last_path_component_nostrip(const char *path) FAST_FUNC; |
350 | 350 | ||
351 | int ndelay_on(int fd) FAST_FUNC; | 351 | void ndelay_on(int fd) FAST_FUNC; |
352 | int ndelay_off(int fd) FAST_FUNC; | 352 | void ndelay_off(int fd) FAST_FUNC; |
353 | int close_on_exec_on(int fd) FAST_FUNC; | 353 | void close_on_exec_on(int fd) FAST_FUNC; |
354 | void xdup2(int, int) FAST_FUNC; | 354 | void xdup2(int, int) FAST_FUNC; |
355 | void xmove_fd(int, int) FAST_FUNC; | 355 | void xmove_fd(int, int) FAST_FUNC; |
356 | 356 | ||
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index a02a504b0..23f27516f 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -25,19 +25,25 @@ | |||
25 | #include "libbb.h" | 25 | #include "libbb.h" |
26 | 26 | ||
27 | /* Turn on nonblocking I/O on a fd */ | 27 | /* Turn on nonblocking I/O on a fd */ |
28 | int FAST_FUNC ndelay_on(int fd) | 28 | void FAST_FUNC ndelay_on(int fd) |
29 | { | 29 | { |
30 | return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK); | 30 | int flags = fcntl(fd, F_GETFL); |
31 | if (flags & O_NONBLOCK) | ||
32 | return; | ||
33 | fcntl(fd, F_SETFL, flags | O_NONBLOCK); | ||
31 | } | 34 | } |
32 | 35 | ||
33 | int FAST_FUNC ndelay_off(int fd) | 36 | void FAST_FUNC ndelay_off(int fd) |
34 | { | 37 | { |
35 | return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NONBLOCK); | 38 | int flags = fcntl(fd, F_GETFL); |
39 | if (!(flags & O_NONBLOCK)) | ||
40 | return; | ||
41 | fcntl(fd, F_SETFL, flags & ~O_NONBLOCK); | ||
36 | } | 42 | } |
37 | 43 | ||
38 | int FAST_FUNC close_on_exec_on(int fd) | 44 | void FAST_FUNC close_on_exec_on(int fd) |
39 | { | 45 | { |
40 | return fcntl(fd, F_SETFD, FD_CLOEXEC); | 46 | fcntl(fd, F_SETFD, FD_CLOEXEC); |
41 | } | 47 | } |
42 | 48 | ||
43 | char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) | 49 | char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) |