From d0b2f91bede3bd5e3d24dd6803e56eee959c1797 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Thu, 20 Oct 2016 00:10:27 -0300 Subject: Linux-libre 4.8.2-gnu --- tools/lib/api/Build | 5 +++++ tools/lib/api/Makefile | 10 +++++++++- tools/lib/api/fd/array.c | 5 +++-- tools/lib/api/fd/array.h | 4 +++- tools/lib/api/fs/fs.c | 7 ++++++- tools/lib/api/fs/tracing_path.c | 3 ++- 6 files changed, 28 insertions(+), 6 deletions(-) (limited to 'tools/lib/api') diff --git a/tools/lib/api/Build b/tools/lib/api/Build index 954c644f7..6e2373db5 100644 --- a/tools/lib/api/Build +++ b/tools/lib/api/Build @@ -2,3 +2,8 @@ libapi-y += fd/ libapi-y += fs/ libapi-y += cpu.o libapi-y += debug.o +libapi-y += str_error_r.o + +$(OUTPUT)str_error_r.o: ../str_error_r.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c) diff --git a/tools/lib/api/Makefile b/tools/lib/api/Makefile index 316f308a6..0a6fda983 100644 --- a/tools/lib/api/Makefile +++ b/tools/lib/api/Makefile @@ -10,15 +10,23 @@ endif CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar +LD = $(CROSS_COMPILE)ld MAKEFLAGS += --no-print-directory LIBFILE = $(OUTPUT)libapi.a CFLAGS := $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC +CFLAGS += -ggdb3 -Wall -Wextra -std=gnu99 -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fPIC + +# Treat warnings as errors unless directed not to +ifneq ($(WERROR),0) + CFLAGS += -Werror +endif + CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 CFLAGS += -I$(srctree)/tools/lib/api +CFLAGS += -I$(srctree)/tools/include RM = rm -f diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c index 0e636c433..b0a035fc8 100644 --- a/tools/lib/api/fd/array.c +++ b/tools/lib/api/fd/array.c @@ -85,7 +85,8 @@ int fdarray__add(struct fdarray *fda, int fd, short revents) } int fdarray__filter(struct fdarray *fda, short revents, - void (*entry_destructor)(struct fdarray *fda, int fd)) + void (*entry_destructor)(struct fdarray *fda, int fd, void *arg), + void *arg) { int fd, nr = 0; @@ -95,7 +96,7 @@ int fdarray__filter(struct fdarray *fda, short revents, for (fd = 0; fd < fda->nr; ++fd) { if (fda->entries[fd].revents & revents) { if (entry_destructor) - entry_destructor(fda, fd); + entry_destructor(fda, fd, arg); continue; } diff --git a/tools/lib/api/fd/array.h b/tools/lib/api/fd/array.h index 45db01818..71287dddc 100644 --- a/tools/lib/api/fd/array.h +++ b/tools/lib/api/fd/array.h @@ -22,6 +22,7 @@ struct fdarray { struct pollfd *entries; union { int idx; + void *ptr; } *priv; }; @@ -34,7 +35,8 @@ void fdarray__delete(struct fdarray *fda); int fdarray__add(struct fdarray *fda, int fd, short revents); int fdarray__poll(struct fdarray *fda, int timeout); int fdarray__filter(struct fdarray *fda, short revents, - void (*entry_destructor)(struct fdarray *fda, int fd)); + void (*entry_destructor)(struct fdarray *fda, int fd, void *arg), + void *arg); int fdarray__grow(struct fdarray *fda, int extra); int fdarray__fprintf(struct fdarray *fda, FILE *fp); diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c index 08556cf2c..ba7094b94 100644 --- a/tools/lib/api/fs/fs.c +++ b/tools/lib/api/fs/fs.c @@ -283,6 +283,11 @@ int filename__read_int(const char *filename, int *value) return err; } +/* + * Parses @value out of @filename with strtoull. + * By using 0 for base, the strtoull detects the + * base automatically (see man strtoull). + */ int filename__read_ull(const char *filename, unsigned long long *value) { char line[64]; @@ -292,7 +297,7 @@ int filename__read_ull(const char *filename, unsigned long long *value) return -1; if (read(fd, line, sizeof(line)) > 0) { - *value = strtoull(line, NULL, 10); + *value = strtoull(line, NULL, 0); if (*value != ULLONG_MAX) err = 0; } diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c index a26bb5ea8..251b7c342 100644 --- a/tools/lib/api/fs/tracing_path.c +++ b/tools/lib/api/fs/tracing_path.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include "fs.h" @@ -118,7 +119,7 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename) } break; default: - snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf))); + snprintf(buf, size, "%s", str_error_r(err, sbuf, sizeof(sbuf))); break; } -- cgit v1.2.3-54-g00ecf