lua: avoid gcc -Wreturn-local-addr bug
Avoid a bug with gcc's -Wreturn-local-addr warning with some obfuscation. In buggy versions of gcc, if a return value is an expression that involves the address of a local variable, and even if that address is legally converted to a non-pointer type, a warning may be emitted and the value of the address may be replaced with zero. Howerver, buggy versions don't emit the warning or replace the value when simply returning a local variable of non-pointer type. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90737 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Libby <rlibby@FreeBSD.org> Closes #11337
This commit is contained in:
parent
1fbda9caee
commit
ee49d9e02b
|
@ -33,14 +33,16 @@
|
||||||
#if defined (_KERNEL) && defined(__linux__)
|
#if defined (_KERNEL) && defined(__linux__)
|
||||||
#include <asm/current.h>
|
#include <asm/current.h>
|
||||||
static intptr_t stack_remaining(void) {
|
static intptr_t stack_remaining(void) {
|
||||||
char local;
|
intptr_t local;
|
||||||
return (intptr_t)(&local - (char *)current->stack);
|
local = (intptr_t)&local - (intptr_t)current->stack;
|
||||||
|
return local;
|
||||||
}
|
}
|
||||||
#elif defined (_KERNEL) && defined(__FreeBSD__)
|
#elif defined (_KERNEL) && defined(__FreeBSD__)
|
||||||
#include <sys/pcpu.h>
|
#include <sys/pcpu.h>
|
||||||
static intptr_t stack_remaining(void) {
|
static intptr_t stack_remaining(void) {
|
||||||
char local;
|
intptr_t local;
|
||||||
return (intptr_t)(&local - (char *)curthread->td_kstack);
|
local = (intptr_t)&local - (intptr_t)curthread->td_kstack;
|
||||||
|
return local;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static intptr_t stack_remaining(void) {
|
static intptr_t stack_remaining(void) {
|
||||||
|
|
Loading…
Reference in New Issue