- /*
- * Imported from <longjmp.h>. Unfortunately, we can't just include
- * this header because it typedefs jmp_buf to be an array of chars.
- * This would allow the compiler to place the buffer on an odd address.
- * The CPU _should_ be able to perform word accesses to
- * unaligned data, but there are *BUGS* in the 80196KC with
- * some combinations of opcodes and addressing modes. One of
- * these, "ST SP,[?GR]+" is used in the longjmp() implementation
- * provided by the IAR compiler ANSI C library. When ?GR contains
- * an odd address, surprisingly the CPU will copy the high order
- * byte of the source operand (SP) in the low order byte of the
- * destination operand (the memory location pointed to by ?GR).
- *
- * We also need to replace the library setjmp()/longjmp() with
- * our own versions because the IAR implementation "forgets" to
- * save the contents of local registers (?LR).
- */
- struct _JMP_BUF
- {
- void *sp; /* Stack pointer */
- void *return_addr; /* Return address */
- int lr[6]; /* 6 local registers */
- };
+ #if CPU_ARM
+
+ #define COMPILER_VARIADIC_MACROS 1
+
+ #define INTERRUPT(x) __irq __arm void x (void)
+ #define INLINE static inline
+
+ /* Include some standard C89/C99 stuff */
+ #include <stddef.h>
+ #include <stdint.h>
+ #include <stdbool.h>
+
+ #elif CPU_I196
+
+ // IAR has size_t as built-in type, but does not define this symbol.
+ #define _SIZE_T_DEFINED
+
+ #define INTERRUPT(x) interrupt [x]
+ #define REGISTER shortad
+ #define INLINE /* unsupported */
+
+ /*
+ * Imported from <longjmp.h>. Unfortunately, we can't just include
+ * this header because it typedefs jmp_buf to be an array of chars.
+ * This would allow the compiler to place the buffer on an odd address.
+ * The CPU _should_ be able to perform word accesses to
+ * unaligned data, but there are *BUGS* in the 80196KC with
+ * some combinations of opcodes and addressing modes. One of
+ * these, "ST SP,[?GR]+" is used in the longjmp() implementation
+ * provided by the IAR compiler ANSI C library. When ?GR contains
+ * an odd address, surprisingly the CPU will copy the high order
+ * byte of the source operand (SP) in the low order byte of the
+ * destination operand (the memory location pointed to by ?GR).
+ *
+ * We also need to replace the library setjmp()/longjmp() with
+ * our own versions because the IAR implementation "forgets" to
+ * save the contents of local registers (?LR).
+ */
+ struct _JMP_BUF
+ {
+ void *sp; /* Stack pointer */
+ void *return_addr; /* Return address */
+ int lr[6]; /* 6 local registers */
+ };
+
+ typedef struct _JMP_BUF jmp_buf[1];