From 0bd3e695505633bb68f2de99ffbe4da295d617c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Thu, 13 Oct 2022 08:23:21 +0700 Subject: [PATCH] papi: fix build with gcc-12 --- srcpkgs/papi/patches/use-after-realloc.patch | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 srcpkgs/papi/patches/use-after-realloc.patch diff --git a/srcpkgs/papi/patches/use-after-realloc.patch b/srcpkgs/papi/patches/use-after-realloc.patch new file mode 100644 index 00000000000..27c88d36191 --- /dev/null +++ b/srcpkgs/papi/patches/use-after-realloc.patch @@ -0,0 +1,56 @@ +Index: papi-5.7.0/src/libpfm4/lib/pfmlib_perf_event_pmu.c +=================================================================== +--- papi-5.7.0.orig/src/libpfm4/lib/pfmlib_perf_event_pmu.c ++++ papi-5.7.0/src/libpfm4/lib/pfmlib_perf_event_pmu.c +@@ -23,6 +23,7 @@ + */ + #include + #include ++#include + #include + #include + #include +@@ -254,6 +255,7 @@ static perf_event_t * + perf_table_alloc_event(void) + { + perf_event_t *new_pe; ++ ptrdiff_t offset; + + retry: + if (perf_pe_free < perf_pe_end) +@@ -261,11 +263,12 @@ retry: + + perf_pe_count += PERF_ALLOC_EVENT_COUNT; + ++ offset = perf_pe_free - perf_pe; + new_pe = realloc(perf_pe, perf_pe_count * sizeof(perf_event_t)); + if (!new_pe) + return NULL; + +- perf_pe_free = new_pe + (perf_pe_free - perf_pe); ++ perf_pe_free = new_pe + offset; + perf_pe_end = perf_pe_free + PERF_ALLOC_EVENT_COUNT; + perf_pe = new_pe; + +@@ -290,6 +293,7 @@ static perf_umask_t * + perf_table_alloc_umask(void) + { + perf_umask_t *new_um; ++ ptrdiff_t offset; + + retry: + if (perf_um_free < perf_um_end) +@@ -297,11 +301,12 @@ retry: + + perf_um_count += PERF_ALLOC_UMASK_COUNT; + ++ offset = perf_um_free - perf_um; + new_um = realloc(perf_um, perf_um_count * sizeof(*new_um)); + if (!new_um) + return NULL; + +- perf_um_free = new_um + (perf_um_free - perf_um); ++ perf_um_free = new_um + offset; + perf_um_end = perf_um_free + PERF_ALLOC_UMASK_COUNT; + perf_um = new_um; +