diff --git a/src/dos/dosirq.c b/src/dos/dosirq.c index 916def6..0a2a1dc 100644 --- a/src/dos/dosirq.c +++ b/src/dos/dosirq.c @@ -129,7 +129,7 @@ static void _free_iret_wrapper(_go32_dpmi_seginfo * info) free((void *)info->pm_offset); } -struct irq_handle *irq_hook(int irqno, irq_handler handler, void (*end)()) +struct irq_handle *irq_hook(int irqno, irq_handler handler, irq_handler end) { int interrupt; struct irq_handle *irq; @@ -215,7 +215,7 @@ void irq_unhook(struct irq_handle *irq) #elif defined(__WATCOMC__) -struct irq_handle *irq_hook(int irqno, irq_handler handler, void (*end)()) +struct irq_handle *irq_hook(int irqno, irq_handler handler, irq_handler end) { unsigned long size = (char *)end - (char near *)handler; int intno = (irqno > 7) ? (irqno + 104) : (irqno + 8); @@ -290,9 +290,6 @@ static void INTERRUPT_ATTRIBUTES NO_REORDER __irq##irqno##_handler () \ __irq_mask |= (1 << irqno); \ } \ irq_ack (__irqs [irqno]); \ -} \ -static void NO_REORDER __irq##irqno##_end(void) \ -{ \ } /* *INDENT-OFF* */ @@ -312,28 +309,28 @@ DECLARE_IRQ_HANDLER(12) DECLARE_IRQ_HANDLER(13) DECLARE_IRQ_HANDLER(14) DECLARE_IRQ_HANDLER(15) +static void INTERRUPT_ATTRIBUTES NO_REORDER __irq_end(void) { } /* *INDENT-ON* */ static struct { - irq_handler handler; - void (*end)(); + irq_handler handler, end; } __irq_handlers[16] = { - { __irq0_handler, __irq0_end }, - { __irq1_handler, __irq1_end }, - { __irq2_handler, __irq2_end }, - { __irq3_handler, __irq3_end }, - { __irq4_handler, __irq4_end }, - { __irq5_handler, __irq5_end }, - { __irq6_handler, __irq6_end }, - { __irq7_handler, __irq7_end }, - { __irq8_handler, __irq8_end }, - { __irq9_handler, __irq9_end }, - { __irq10_handler, __irq10_end }, - { __irq11_handler, __irq11_end }, - { __irq12_handler, __irq12_end }, - { __irq13_handler, __irq13_end }, - { __irq14_handler, __irq14_end }, - { __irq15_handler, __irq15_end } + { __irq0_handler, __irq1_handler }, + { __irq1_handler, __irq2_handler }, + { __irq2_handler, __irq3_handler }, + { __irq3_handler, __irq4_handler }, + { __irq4_handler, __irq5_handler }, + { __irq5_handler, __irq6_handler }, + { __irq6_handler, __irq7_handler }, + { __irq7_handler, __irq8_handler }, + { __irq8_handler, __irq9_handler }, + { __irq9_handler, __irq10_handler }, + { __irq10_handler, __irq11_handler }, + { __irq11_handler, __irq12_handler }, + { __irq12_handler, __irq13_handler }, + { __irq13_handler, __irq14_handler }, + { __irq14_handler, __irq15_handler }, + { __irq15_handler, __irq_end } }; void irq_detect_start(unsigned int irqs, int (*irq_confirm) (int irqno)) diff --git a/src/dos/dosirq.h b/src/dos/dosirq.h index 66bd4c4..69bf766 100644 --- a/src/dos/dosirq.h +++ b/src/dos/dosirq.h @@ -17,8 +17,8 @@ #define PIC1_BASE 0x20 /* PIC1 base */ #define PIC2_BASE 0xA0 /* PIC2 base */ -#ifdef __GNUC__ -#define NO_REORDER __attribute__((no_reorder)) +#if defined(__GNUC__) && (__GNUC__ >= 5) +#define NO_REORDER __attribute__((no_reorder,no_icf,noinline,noclone)) #else #define NO_REORDER #endif @@ -107,7 +107,7 @@ static inline int irq_check(struct irq_handle * irq) /* Hook a specific IRQ; NOTE: IRQ is disabled upon return, irq_enable() it */ extern struct irq_handle *irq_hook(int irqno, irq_handler handler, - void (*end)()); + irq_handler end); /* Unhook a previously hooked IRQ */ extern void irq_unhook(struct irq_handle * irq); /* Start IRQ detection process (IRQ list is given with irq mask) */ diff --git a/src/dos/dossb.c b/src/dos/dossb.c index 223b089..bd7c221 100644 --- a/src/dos/dossb.c +++ b/src/dos/dossb.c @@ -42,6 +42,13 @@ _func_noclone inportb(SB_DSP_RESET); } +#if defined(__WATCOMC__) +static void nop (void); +#pragma aux nop = "nop" +#else +#define nop() +#endif + static void INTERRUPT_ATTRIBUTES NO_REORDER sb_irq() { /* Make sure its not a spurious IRQ */ @@ -68,8 +75,9 @@ static void INTERRUPT_ATTRIBUTES NO_REORDER sb_irq() sb.timer_callback(); } -static void NO_REORDER sb_irq_end() +static void NO_REORDER INTERRUPT_ATTRIBUTES sb_irq_end() { + nop(); } static boolean __sb_reset() @@ -127,8 +135,9 @@ static void INTERRUPT_ATTRIBUTES NO_REORDER __sb_irq_dmadetect() irq_ack(sb.irq_handle); } -static void NO_REORDER __sb_irq_dmadetect_end() +static void INTERRUPT_ATTRIBUTES NO_REORDER __sb_irq_dmadetect_end() { + nop(); } static boolean __sb_detect() diff --git a/src/dos/dosutil.c b/src/dos/dosutil.c index 1d575f2..26c3c99 100644 --- a/src/dos/dosutil.c +++ b/src/dos/dosutil.c @@ -2,7 +2,7 @@ #if defined(__DJGPP__) -#include /* includes sys/version.h (djgpp >= 2.02) */ +#include #include #include @@ -10,7 +10,7 @@ * src/libc/dpmi/api/d0102.s loads the selector and allocsize * arguments in the wrong order. DJGPP >= 2.02 have it fixed. */ #if (!defined(__DJGPP_MINOR__) || (__DJGPP_MINOR__+0) < 2) -#warning __dpmi_resize_dos_memory() from DJGPP <= 2.01 is broken! +#error __dpmi_resize_dos_memory() from DJGPP <= 2.01 is broken! #endif int dpmi_allocate_dos_memory(int paragraphs, int *ret_selector_or_max) { diff --git a/src/dos/dosutil.h b/src/dos/dosutil.h index 1d2eccf..3d22e34 100644 --- a/src/dos/dosutil.h +++ b/src/dos/dosutil.h @@ -13,11 +13,14 @@ extern int dpmi_unlock_linear_region_base(void *address, unsigned long size); #ifdef __WATCOMC__ #include +extern int disable(); +extern int enable(); +#pragma aux disable = "cli" "mov eax,1" +#pragma aux enable = "sti" "mov eax,1" + #define inportb(x) inp(x) #define outportb(x,y) outp(x,y) -extern int enable(); -extern int disable(); #else #include #endif