diff --git a/tcc.c b/tcc.c index 4f4eb623..c2bb0dd0 100644 --- a/tcc.c +++ b/tcc.c @@ -171,6 +171,8 @@ static const char version[] = " Darwin" #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) " FreeBSD" +#elif defined(__OpenBSD__) + " OpenBSD" #else " Linux" #endif diff --git a/tcc.h b/tcc.h index 5fd27b97..7bfac8b9 100644 --- a/tcc.h +++ b/tcc.h @@ -45,6 +45,9 @@ /* XXX: need to define this to use them in non ISOC99 context */ extern float strtof (const char *__nptr, char **__endptr); extern long double strtold (const char *__nptr, char **__endptr); +# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +extern char **environ; +# endif #endif #ifdef _WIN32 diff --git a/tccrun.c b/tccrun.c index 17f1eebc..f453f3f3 100644 --- a/tccrun.c +++ b/tccrun.c @@ -648,6 +648,9 @@ static void rt_getcontext(ucontext_t *uc, rt_context *rc) # elif defined(__NetBSD__) rc->ip = uc->uc_mcontext.__gregs[_REG_RIP]; rc->fp = uc->uc_mcontext.__gregs[_REG_RBP]; +# elif defined(__OpenBSD__) + rc->ip = uc->sc_rip; + rc->fp = uc->sc_rbp; # else rc->ip = uc->uc_mcontext.gregs[REG_RIP]; rc->fp = uc->uc_mcontext.gregs[REG_RBP];