Skip to content

Commit

Permalink
Fix Clang builds regarding undefined function call
Browse files Browse the repository at this point in the history
While MSVC is apparently fine using `_AddressOfReturnAddress()` without
including intrin.h, Clang complains that the function is undefined.  So
we include the header, if `_MSC_VER` is defined, what is the case for
MSVC and clang-cl, but not for some other compilers on Windows (e.g.
GCC).
  • Loading branch information
cmb69 committed Jan 20, 2025
1 parent 6bd2b8d commit ce53dab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Zend/zend_call_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
# include <pthread.h>
#endif

#ifdef _MSC_VER
#include <intrin.h>
#endif

#ifdef ZEND_CHECK_STACK_LIMIT

typedef struct _zend_call_stack {
Expand All @@ -38,7 +42,7 @@ ZEND_API bool zend_call_stack_get(zend_call_stack *stack);

/** Returns an approximation of the current stack position */
static zend_always_inline void *zend_call_stack_position(void) {
#ifdef ZEND_WIN32
#ifdef _MSC_VER
return _AddressOfReturnAddress();
#elif defined(PHP_HAVE_BUILTIN_FRAME_ADDRESS)
return __builtin_frame_address(0);
Expand Down

0 comments on commit ce53dab

Please sign in to comment.