$NetBSD$

--- tcc.c.orig	2004-11-23 23:23:04.000000000 +0100
+++ tcc.c	2004-11-23 23:29:44.000000000 +0100
@@ -44,6 +44,7 @@
 #define CONFIG_TCC_STATIC
 #endif
 #ifndef WIN32
+#include <sys/param.h>
 #include <sys/time.h>
 #include <sys/ucontext.h>
 #endif
@@ -701,7 +702,7 @@
 #define vsnprintf _vsnprintf
 #endif
 
-#if defined(WIN32) || defined(TCC_UCLIBC) || defined(__FreeBSD__)
+#if defined(WIN32) || defined(TCC_UCLIBC) || defined(BSD)
 /* currently incorrect */
 long double strtold(const char *nptr, char **endptr)
 {
@@ -9323,9 +9324,14 @@
 
 /* fix for glibc 2.1 */
 #ifndef REG_EIP
+#ifdef BSD
+#define REG_EIP _REG_EIP
+#define REG_EBP _REG_EBP
+#else
 #define REG_EIP EIP
 #define REG_EBP EBP
 #endif
+#endif
 
 /* return the PC at frame level 'level'. Return non zero if not found */
 static int rt_get_caller_pc(unsigned long *paddr, 
@@ -9337,6 +9343,8 @@
     if (level == 0) {
 #if defined(__FreeBSD__)
         *paddr = uc->uc_mcontext.mc_eip;
+#elif defined(__NetBSD__)
+	*paddr = uc->uc_mcontext.__gregs[REG_EIP];
 #elif defined(__dietlibc__)
         *paddr = uc->uc_mcontext.eip;
 #else
@@ -9346,6 +9354,8 @@
     } else {
 #if defined(__FreeBSD__) 
         fp = uc->uc_mcontext.mc_ebp;
+#elif defined(__NetBSD__)
+	fp = uc->uc_mcontext.__gregs[REG_EBP];
 #elif defined(__dietlibc__)
         fp = uc->uc_mcontext.ebp;
 #else
@@ -9492,7 +9502,11 @@
         struct sigaction sigact;
         /* install TCC signal handlers to print debug info on fatal
            runtime errors */
+#ifdef BSD
+        sigact.sa_flags = SA_RESETHAND;
+#else
         sigact.sa_flags = SA_SIGINFO | SA_RESETHAND;
+#endif
         sigact.sa_sigaction = sig_error;
         sigemptyset(&sigact.sa_mask);
         sigaction(SIGFPE, &sigact, NULL);
