#ifndef _BSD_SETJMP_H
#define _BSD_SETJMP_H
-#include <machine/setjmp.h>
+#include <sys/cdefs.h>
+
+#if defined(__x86_64__)
+/*
+ * _JBLEN is number of ints required to save the following:
+ * rflags, rip, rbp, rsp, rbx, r12, r13, r14, r15... these are 8 bytes each
+ * mxcsr, fp control word, sigmask... these are 4 bytes each
+ * add 16 ints for future expansion needs...
+ */
+#define _JBLEN ((9 * 2) + 3 + 16)
+typedef int jmp_buf[_JBLEN];
+typedef int sigjmp_buf[_JBLEN + 1];
+
+#elif defined(__i386__)
+
+/*
+ * _JBLEN is number of ints required to save the following:
+ * eax, ebx, ecx, edx, edi, esi, ebp, esp, ss, eflags, eip,
+ * cs, de, es, fs, gs == 16 ints
+ * onstack, mask = 2 ints
+ */
+
+#define _JBLEN (18)
+typedef int jmp_buf[_JBLEN];
+typedef int sigjmp_buf[_JBLEN + 1];
+
+#elif defined(__arm__)
+
+#include <machine/signal.h>
+
+/*
+ * _JBLEN is number of ints required to save the following:
+ * r4-r8, r10, fp, sp, lr, sig == 10 register_t sized
+ * s16-s31 == 16 register_t sized + 1 int for FSTMX
+ * 1 extra int for future use
+ */
+#define _JBLEN (10 + 16 + 2)
+#define _JBLEN_MAX _JBLEN
+
+typedef int jmp_buf[_JBLEN];
+typedef int sigjmp_buf[_JBLEN + 1];
+
+#else
+# error Undefined platform for setjmp
+#endif
+
+__BEGIN_DECLS
+extern int setjmp(jmp_buf);
+extern void longjmp(jmp_buf, int) __dead2;
+
+#ifndef _ANSI_SOURCE
+int _setjmp(jmp_buf);
+void _longjmp(jmp_buf, int) __dead2;
+int sigsetjmp(sigjmp_buf, int);
+void siglongjmp(sigjmp_buf, int) __dead2;
+#endif /* _ANSI_SOURCE */
+
+#if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
+void longjmperror(void);
+#endif /* neither ANSI nor POSIX */
+__END_DECLS
#endif /* _BSD_SETJMP_H */