portability: Add support for QNX

This commit is contained in:
Ole André Vadla Ravnås 2022-03-24 01:33:06 +03:00
parent 4a87cff803
commit c3b596afb7
2 changed files with 10 additions and 2 deletions

View File

@ -60,7 +60,7 @@ elif host_arch == 'arm'
cdata.set('TCC_ARM_VFP', true)
is_hardfloat_src = '''
#ifndef __ARM_PCS_VFP
#if !(defined(__ARM_PCS_VFP) || defined(__QNX__))
# error Not hardfloat
#endif
'''

View File

@ -627,7 +627,9 @@ static void rt_exit(int code)
#ifndef _WIN32
# include <signal.h>
# ifndef __OpenBSD__
# if defined(__QNX__)
# include <ucontext.h>
# elif !defined(__OpenBSD__)
# include <sys/ucontext.h>
# endif
#else
@ -661,6 +663,9 @@ static void rt_getcontext(ucontext_t *uc, rt_context *rc)
# elif defined(__OpenBSD__)
rc->ip = uc->sc_eip;
rc->fp = uc->sc_ebp;
# elif defined(__QNX__)
rc->ip = uc->uc_mcontext.cpu.eip;
rc->fp = uc->uc_mcontext.cpu.ebp;
# elif !defined REG_EIP && defined EIP /* fix for glibc 2.1 */
rc->ip = uc->uc_mcontext.gregs[EIP];
rc->fp = uc->uc_mcontext.gregs[EBP];
@ -686,6 +691,9 @@ static void rt_getcontext(ucontext_t *uc, rt_context *rc)
# if defined(__APPLE__)
rc->ip = uc->uc_mcontext->__ss.__pc;
rc->fp = uc->uc_mcontext->__ss.__r[11];
# elif defined(__QNX__)
rc->ip = uc->uc_mcontext.cpu.gpr[15];
rc->fp = uc->uc_mcontext.cpu.gpr[11];
# else
rc->ip = uc->uc_mcontext.arm_pc;
rc->fp = uc->uc_mcontext.arm_fp;