Author: Dharanendiran <dharanendiran@timesys.com>
Date: Mon, 22 Dec 2025 10:35:29 +0530

Error log-1:

/tmp/ccqD2oaH.o: In function `pmt_counter_resize_':
/home/timesys/factory/build_x86_64-timesys-linux-gnu/linux-6.12/tools/power/x86/turbostat/turbostat.c:1553: undefined reference to `reallocarray'

Error log-2:

util/print-events.c:67:36: error: 'O_PATH' undeclared (first use in this function); did you mean '_CS_PATH'?
  int events_fd = open(events_path, O_PATH);

---
 tools/perf/util/print-events.c        |  4 ++++
 tools/power/x86/turbostat/turbostat.c | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/tools/perf/util/print-events.c b/tools/perf/util/print-events.c
index a1c71d979..2b604bbcd 100644
--- a/tools/perf/util/print-events.c
+++ b/tools/perf/util/print-events.c
@@ -33,6 +33,10 @@
 
 #define MAX_NAME_LEN 100
 
+#ifndef O_PATH
+#define O_PATH     	010000000
+#endif
+
 /** Strings corresponding to enum perf_type_id. */
 static const char * const event_type_descriptors[] = {
 	"Hardware event",
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 66f8581da..117dfc59a 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -71,6 +71,16 @@
 
 #define UNUSED(x) (void)(x)
 
+#if !defined(__GLIBC__) || (__GLIBC__ < 2) || \
+    (__GLIBC__ == 2 && __GLIBC_MINOR__ < 26)
+static inline void *reallocarray(void *ptr, size_t nmemb, size_t size)
+{
+	if (size && nmemb > SIZE_MAX / size)
+		return NULL;
+	return realloc(ptr, nmemb * size);
+}
+#endif
+
 /*
  * This list matches the column headers, except
  * 1. built-in only, the sysfs counters are not here -- we learn of those at run-time
-- 
2.34.1

