From 6c82efff8561f0abdaea3054a7170f0aa4605fd6 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Mon, 5 Sep 2011 10:56:35 +0200 Subject: [klibc] include: [sys/file.h] define flock(2) there SUSv3 is silent on that definition, but seen several userspace software that expects flock to be defined in that file and complain that it is missing in klibc. Current declaration is in unistd.h. Signed-off-by: maximilian attems --- usr/include/sys/file.h | 9 +++++++++ usr/include/unistd.h | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 usr/include/sys/file.h diff --git a/usr/include/sys/file.h b/usr/include/sys/file.h new file mode 100644 index 0000000000000..7b580f36672df --- /dev/null +++ b/usr/include/sys/file.h @@ -0,0 +1,9 @@ +#ifndef _SYS_FILE_H +#define _SYS_FILE_H + +/* LOCK_ definitions */ +#include + +__extern int flock(int, int); + +#endif /* _SYS_FILE_H */ diff --git a/usr/include/unistd.h b/usr/include/unistd.h index f286c332ca098..3eaeaee5a1aa2 100644 --- a/usr/include/unistd.h +++ b/usr/include/unistd.h @@ -105,7 +105,6 @@ __extern int dup(int); __extern int dup2(int, int); __extern int fcntl(int, int, ...); __extern int ioctl(int, int, void *); -__extern int flock(int, int); __extern int ftruncate(int, off_t); /* -- cgit 1.2.3-korg From 80b4ed3a639ffce0a7ea0bfeee524ccedb9cc348 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Wed, 7 Sep 2011 00:43:38 +0200 Subject: [klibc] include: [limits.h] define OPEN_MAX Usage seen in util-linux. Defined according to POSIX:2001 min. Signed-off-by: maximilian attems --- usr/include/limits.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr/include/limits.h b/usr/include/limits.h index 0d1069bf30b7b..8a2c6c027b2e2 100644 --- a/usr/include/limits.h +++ b/usr/include/limits.h @@ -5,6 +5,8 @@ #ifndef _LIMITS_H #define _LIMITS_H +#define OPEN_MAX 20 + #define CHAR_BIT 8 #define SHRT_BIT 16 #define INT_BIT 32 -- cgit 1.2.3-korg From 731d82caecbc309eea5e719ca0c6dfb03afd34c3 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Wed, 7 Sep 2011 12:26:19 +0200 Subject: [klibc] kbuild: add static to prototypes Warnings found via gcc -Wmissing-prototypes. Signed-off-by: Trevor Keith Acked-by: WANG Cong Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg [ ported 4356f4890792a678936c93c9196e8f7742e04535 to klibc + minor whitespaces ] Signed-off-by: maximilian attems --- scripts/basic/fixdep.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 5b6898028f410..fed4c7f13f650 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -123,14 +123,13 @@ char *target; char *depfile; char *cmdline; -void usage(void) - +static void usage(void) { fprintf(stderr, "Usage: fixdep \n"); exit(1); } -void print_cmdline(void) +static void print_cmdline(void) { printf("cmd_%s := %s\n\n", target, cmdline); } @@ -143,7 +142,7 @@ int len_config = 0; * Grow the configuration string to a desired length. * Usually the first growth is plenty. */ -void grow_config(int len) +static void grow_config(int len) { while (len_config + len > size_config) { if (size_config == 0) @@ -159,7 +158,7 @@ void grow_config(int len) /* * Lookup a value in the configuration string. */ -int is_defined_config(const char * name, int len) +static int is_defined_config(const char *name, int len) { const char * pconfig; const char * plast = str_config + len_config - len; @@ -175,7 +174,7 @@ int is_defined_config(const char * name, int len) /* * Add a new value to the configuration string. */ -void define_config(const char * name, int len) +static void define_config(const char *name, int len) { grow_config(len + 1); @@ -187,7 +186,7 @@ void define_config(const char * name, int len) /* * Clear the set of configuration strings. */ -void clear_config(void) +static void clear_config(void) { len_config = 0; define_config("", 0); @@ -196,7 +195,7 @@ void clear_config(void) /* * Record the use of a CONFIG_* word. */ -void use_config(char *m, int slen) +static void use_config(char *m, int slen) { char s[PATH_MAX]; char *p; @@ -217,7 +216,7 @@ void use_config(char *m, int slen) printf(" $(wildcard include/config/%s.h) \\\n", s); } -void parse_config_file(char *map, size_t len) +static void parse_config_file(char *map, size_t len) { int *end = (int *) (map + len); /* start at +1, so that p can never be < map */ @@ -247,7 +246,7 @@ void parse_config_file(char *map, size_t len) } /* test is s ends in sub */ -int strrcmp(char *s, char *sub) +static int strrcmp(char *s, char *sub) { int slen = strlen(s); int sublen = strlen(sub); @@ -258,7 +257,7 @@ int strrcmp(char *s, char *sub) return memcmp(s + slen - sublen, sub, sublen); } -void do_config_file(char *filename) +static void do_config_file(char *filename) { struct stat st; int fd; @@ -289,7 +288,7 @@ void do_config_file(char *filename) close(fd); } -void parse_dep_file(void *map, size_t len) +static void parse_dep_file(void *map, size_t len) { char *m = map; char *end = m + len; @@ -329,7 +328,7 @@ void parse_dep_file(void *map, size_t len) printf("$(deps_%s):\n", target); } -void print_deps(void) +static void print_deps(void) { struct stat st; int fd; @@ -361,7 +360,7 @@ void print_deps(void) close(fd); } -void traps(void) +static void traps(void) { static char test[] __attribute__((aligned(sizeof(int)))) = "CONF"; int *p = (int *)test; -- cgit 1.2.3-korg From 7f47891c1678874cccca66cd25e6a13486c86d78 Mon Sep 17 00:00:00 2001 From: Maciej Żenczykowski Date: Sun, 6 Nov 2011 14:33:40 -0800 Subject: [klibc] include: [sys/types.h] -> linux/types.h and __aligned_u64 When building klibc 1.5.25 against linux/master (ie. post 3.1) I'm seeing: klibc/generated/include/linux/if_packet.h:176: error: expected specifier-qualifier-list before '__aligned_u64' which seems to come from upstream commits: 0d4691ce112be025019999df5f2a5e00c03f03c2 remotes/linux/master~90^2~408 (origin) 96c131842aab45b5d139d0bcb417796819f5ee92 remotes/linux/master~90^2~169 (change from aligned_u64 to __aligned_u64) and collides with klibc/usr/include/sys/types.h /* Keeps linux/types.h from getting included elsewhere */ #define _LINUX_TYPES_H not defining __aligned_u64 like the kernel's include/linux/types.h does. Signed-off-by: maximilian attems --- usr/include/sys/types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr/include/sys/types.h b/usr/include/sys/types.h index 6780ed1a00e5b..3a4c738a897c2 100644 --- a/usr/include/sys/types.h +++ b/usr/include/sys/types.h @@ -100,6 +100,10 @@ typedef uint16_t __sum16; typedef uint32_t __sum32; typedef uint64_t __sum64; +#define __aligned_u64 __u64 __attribute__((aligned(8))) +#define __aligned_be64 __be64 __attribute__((aligned(8))) +#define __aligned_le64 __le64 __attribute__((aligned(8))) + /* * Some headers seem to require this... */ -- cgit 1.2.3-korg From 1c3e2f3c152ef2a55d47b7149c85f167fabd8f2f Mon Sep 17 00:00:00 2001 From: Greg Thelen Date: Wed, 30 Nov 2011 15:53:23 -0800 Subject: [klibc] ipconfig: check poll() return value Check the poll() return value for error before inspecting its output. Signed-off-by: Greg Thelen Signed-off-by: maximilian attems --- usr/kinit/ipconfig/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c index 8782ae7feb64d..37ca5734e6207 100644 --- a/usr/kinit/ipconfig/main.c +++ b/usr/kinit/ipconfig/main.c @@ -408,7 +408,7 @@ static int loop(void) prev = now; gettimeofday(&now, NULL); - if ((fds[0].revents & POLLRDNORM)) { + if ((nr > 0) && (fds[0].revents & POLLRDNORM)) { if (do_pkt_recv(pkt_fd, now.tv_sec) == 1) break; } -- cgit 1.2.3-korg From acf09ea80536ac49a0001249956fef999b8d35af Mon Sep 17 00:00:00 2001 From: Greg Thelen Date: Wed, 30 Nov 2011 15:55:57 -0800 Subject: [klibc] vsscanf: remove unused variables Removed unused local variable from vsscanf(). Signed-off-by: Greg Thelen "POSIX is quite explicit that the unsigned formats still accept signed input, and since klibc requires that signed and unsigned integer types are the same the only reason to track it would be to handle numeric overflow." -hpa Acked-by: "H. Peter Anvin" Signed-off-by: maximilian attems --- usr/klibc/vsscanf.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/usr/klibc/vsscanf.c b/usr/klibc/vsscanf.c index 51e50f7d0c916..b8f068cc087dc 100644 --- a/usr/klibc/vsscanf.c +++ b/usr/klibc/vsscanf.c @@ -88,7 +88,6 @@ int vsscanf(const char *buffer, const char *format, va_list ap) } state = st_normal; char *sarg = NULL; /* %s %c or %[ string argument */ enum bail bail = bail_none; - int sign; int converted = 0; /* Successful conversions */ unsigned long matchmap[((1 << CHAR_BIT) + (LONG_BIT - 1)) / LONG_BIT]; int matchinv = 0; /* Is match map inverted? */ @@ -177,33 +176,27 @@ int vsscanf(const char *buffer, const char *format, va_list ap) case 'p': /* Pointer */ rank = rank_ptr; base = 0; - sign = 0; goto scan_int; case 'i': /* Base-independent integer */ base = 0; - sign = 1; goto scan_int; case 'd': /* Decimal integer */ base = 10; - sign = 1; goto scan_int; case 'o': /* Octal integer */ base = 8; - sign = 0; goto scan_int; case 'u': /* Unsigned decimal integer */ base = 10; - sign = 0; goto scan_int; case 'x': /* Hexadecimal integer */ case 'X': base = 16; - sign = 0; goto scan_int; case 'n': /* # of characters consumed */ -- cgit 1.2.3-korg From 4791ba93559f7380701e817e82e36c74d4e94e56 Mon Sep 17 00:00:00 2001 From: maximilian attems Date: Sun, 4 Dec 2011 16:52:03 +0100 Subject: [klibc] Makefile: drop -2.6 suffix to linux source pathes No longer relevant these days of 3.X linux. Signed-off-by: maximilian attems --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d2cd57769dec9..25d32dc962b61 100644 --- a/Makefile +++ b/Makefile @@ -130,12 +130,12 @@ help: @echo 'test - Run klibc tests' @echo @echo 'Build options:' - @echo 'KLIBCKERNELSRC - Path to a configured linux-2.6 tree' + @echo 'KLIBCKERNELSRC - Path to a configured linux tree' @echo 'KLIBCKERNELOBJ - Path to kernel output dir (defaults to KLIBCKERNELSRC)' @echo 'make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' @echo @echo 'Sample invocation:' - @echo 'make KLIBCKERNELSRC=`pwd`/../linux-2.6' + @echo 'make KLIBCKERNELSRC=`pwd`/../linux' ### # allow one to say make dir/file.o -- cgit 1.2.3-korg