mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-09 22:08:56 +08:00
fix(posix): keep PX4_STACK_ADJUSTED integer-typed for QURT/NuttX
The Windows compatibility commit replaced __SIZEOF_POINTER__ (an int
literal) with sizeof(void*) (size_t) in PX4_STACK_ADJUSTED so MSVC,
which does not predefine __SIZEOF_POINTER__, would compile. That
silently changed the macro's result type from int to size_t and broke
QURT's WorkQueueManager:
math::max(PTHREAD_STACK_MIN, PX4_STACK_ADJUSTED(wq->stacksize))
error: deduced conflicting types ('int' vs. 'unsigned int')
Define __SIZEOF_POINTER__ ourselves on MSVC (8 on _WIN64/_M_X64,
otherwise 4) and restore the original integer-arithmetic form of the
macro. NuttX, QURT, and Linux SITL keep the GCC/Clang predefine; only
MSVC sees the fallback.
Signed-off-by: Nuno Marques <n.marques21@hotmail.com>
This commit is contained in:
@@ -131,7 +131,14 @@ __END_DECLS
|
||||
// we often run out of stack space when pointers are larger than 4 bytes.
|
||||
// Double the stack size on posix when we're on a 64-bit architecture.
|
||||
// Most full-scale OS use 1-4K of memory from the stack themselves
|
||||
#define PX4_STACK_ADJUSTED(_s) ((_s) * (sizeof(void *) >> 2) + PX4_STACK_OVERHEAD)
|
||||
#ifndef __SIZEOF_POINTER__
|
||||
# if defined(_WIN64) || (defined(_MSC_VER) && defined(_M_X64))
|
||||
# define __SIZEOF_POINTER__ 8
|
||||
# else
|
||||
# define __SIZEOF_POINTER__ 4
|
||||
# endif
|
||||
#endif
|
||||
#define PX4_STACK_ADJUSTED(_s) ((_s) * (__SIZEOF_POINTER__ >> 2) + PX4_STACK_OVERHEAD)
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user