From 74734bff81dc2e1a5b160d5621eeea35c5defabd Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 16 Apr 2023 13:13:52 +0100 Subject: libbb: don't build useless functions The functions ndelay_on(), ndelay_off() and close_on_exec_on() don't do anything useful because our fcntl(2) implementation doesn't support the features they require. Replace them with stubs. Saves 176-208 bytes. --- include/libbb.h | 6 ++++++ libbb/xfuncs.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/include/libbb.h b/include/libbb.h index 7683b3f63..a4eebab99 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -592,9 +592,15 @@ const char* endofname(const char *name) FAST_FUNC; char *is_prefixed_with(const char *string, const char *key) FAST_FUNC; char *is_suffixed_with(const char *string, const char *key) FAST_FUNC; +#if !ENABLE_PLATFORM_MINGW32 int ndelay_on(int fd) FAST_FUNC; int ndelay_off(int fd) FAST_FUNC; void close_on_exec_on(int fd) FAST_FUNC; +#else +static inline int ndelay_on(int fd UNUSED_PARAM) { return 0; } +static inline int ndelay_off(int fd UNUSED_PARAM) { return 0; } +static inline void close_on_exec_on(int fd UNUSED_PARAM) { return; } +#endif void xdup2(int, int) FAST_FUNC; void xmove_fd(int, int) FAST_FUNC; diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index cbeb24701..813985194 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c @@ -23,6 +23,7 @@ #include "libbb.h" /* Turn on nonblocking I/O on a fd */ +#if !ENABLE_PLATFORM_MINGW32 int FAST_FUNC ndelay_on(int fd) { int flags = fcntl(fd, F_GETFL); @@ -45,6 +46,7 @@ void FAST_FUNC close_on_exec_on(int fd) { fcntl(fd, F_SETFD, FD_CLOEXEC); } +#endif char* FAST_FUNC strncpy_IFNAMSIZ(char *dst, const char *src) { -- cgit v1.2.3-55-g6feb