Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Add missing open_memstream() prototype for systems lacking it

There are systems such as the Android NDK API level 24 has the
open_memstream() function but doesn't provide a prototype, adding noise
to the build:

builtin-timechart.c: In function 'cat_backtrace':
builtin-timechart.c:486:2: warning: implicit declaration of function 'open_memstream' [-Wimplicit-function-declaration]
FILE *f = open_memstream(&p, &p_len);
^
builtin-timechart.c:486:2: warning: nested extern declaration of 'open_memstream' [-Wnested-externs]
builtin-timechart.c:486:12: warning: initialization makes pointer from integer without a cast
FILE *f = open_memstream(&p, &p_len);
^

Define a LACKS_OPEN_MEMSTREAM_PROTOTYPE define so that code needing that
can get a prototype.

Checked in the bionic git repo to be available since level 23:

https://android.googlesource.com/platform/bionic/+/master/libc/include/stdio.h#241

FILE* open_memstream(char** __ptr, size_t* __size_ptr) __INTRODUCED_IN(23);

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-343ashae97e5bq6vizusyfno@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+5
+1
tools/perf/Makefile.config
··· 295 295 ifeq ($(feature-bionic), 1) 296 296 BIONIC := 1 297 297 CFLAGS += -DLACKS_SIGQUEUE_PROTOTYPE 298 + CFLAGS += -DLACKS_OPEN_MEMSTREAM_PROTOTYPE 298 299 EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) 299 300 EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) 300 301 endif
+4
tools/perf/builtin-timechart.c
··· 43 43 #include "util/data.h" 44 44 #include "util/debug.h" 45 45 46 + #ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE 47 + FILE *open_memstream(char **ptr, size_t *sizeloc); 48 + #endif 49 + 46 50 #define SUPPORT_OLD_POWER_EVENTS 1 47 51 #define PWR_EVENT_EXIT -1 48 52