From f952263bcd699f1067b568f2e17b2f5936efd9a1 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 22 Aug 2024 20:26:44 +0200 Subject: [PATCH] Fix Solaris 10 build: missing libproc.h (#15525) The libproc.h header file was added on Solaris as of 11.4. * Also add guard check to the entire function * When libproc.h isn't available also sys/procfs.h is redundant * Move the out of the guard * Exclude more stuff from Solaris 10 --- Zend/Zend.m4 | 5 ++++- Zend/zend_call_stack.c | 14 ++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index df75b4c9e99..47ea9c831d5 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -133,7 +133,10 @@ dnl AC_DEFUN([ZEND_INIT], [dnl AC_REQUIRE([AC_PROG_CC]) -AC_CHECK_HEADERS([cpuid.h]) +AC_CHECK_HEADERS(m4_normalize([ + cpuid.h + libproc.h +])) dnl Check for library functions. AC_CHECK_FUNCS(m4_normalize([ diff --git a/Zend/zend_call_stack.c b/Zend/zend_call_stack.c index f12323d0d9c..a2887d164f3 100644 --- a/Zend/zend_call_stack.c +++ b/Zend/zend_call_stack.c @@ -64,10 +64,12 @@ typedef int boolean_t; #include #endif #ifdef __sun -#define _STRUCTURED_PROC 1 -#include -#include -#include +# include +# ifdef HAVE_LIBPROC_H +# define _STRUCTURED_PROC 1 +# include +# include +# endif #include #endif @@ -699,6 +701,7 @@ static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack) return true; } +#ifdef HAVE_LIBPROC_H static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack) { char buffer[4096]; @@ -771,12 +774,15 @@ end: close(fd); return r; } +#endif static bool zend_call_stack_get_solaris(zend_call_stack *stack) { +#ifdef HAVE_LIBPROC_H if (_lwp_self() == 1) { return zend_call_stack_get_solaris_proc_maps(stack); } +#endif return zend_call_stack_get_solaris_pthread(stack); } #else