From aca8f5714544aa4ae09c3bda943a94386fbf7f6b Mon Sep 17 00:00:00 2001 From: tsutsui Date: Sun, 10 Sep 2006 11:12:20 +0000 Subject: [PATCH] Change dumb DELAY(9) macro into inline version with asm like other mips ports for gcc4's aggressive optimization. --- sys/arch/hpcmips/include/param.h | 14 +++++++++++--- sys/arch/mipsco/include/param.h | 12 ++++++++++-- sys/arch/pmax/include/param.h | 13 ++++++++++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/sys/arch/hpcmips/include/param.h b/sys/arch/hpcmips/include/param.h index 7b0c8c65eed7..d8a82c52460c 100644 --- a/sys/arch/hpcmips/include/param.h +++ b/sys/arch/hpcmips/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.10 2005/12/11 12:17:33 christos Exp $ */ +/* $NetBSD: param.h,v 1.11 2006/09/10 11:12:20 tsutsui Exp $ */ /* * Copyright (c) 1992, 1993 @@ -134,9 +134,17 @@ #ifdef _KERNEL #ifndef _LOCORE -extern void delay(int); +void delay(int); extern int cpuspeed; -#define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } +static __inline void __attribute__((__unused__)) +DELAY(int n) +{ + register int __N = cpuspeed * n; + + do { + __asm("addiu %0,%1,-1" : "=r" (__N) : "0" (__N)); + } while (__N > 0); +} #include diff --git a/sys/arch/mipsco/include/param.h b/sys/arch/mipsco/include/param.h index 70a0dab7f431..a3b7f46db0e1 100644 --- a/sys/arch/mipsco/include/param.h +++ b/sys/arch/mipsco/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.5 2005/12/11 12:18:13 christos Exp $ */ +/* $NetBSD: param.h,v 1.6 2006/09/10 11:12:20 tsutsui Exp $ */ /* * Copyright (c) 1992, 1993 @@ -136,7 +136,15 @@ extern void delay __P((int n)); extern int cpuspeed; -#define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } +static __inline void __attribute__((__unused__)) +DELAY(int n) +{ + register int __N = cpuspeed * n; + + do { + __asm("addiu %0,%1,-1" : "=r" (__N) : "0" (__N)); + } while (__N > 0); +} #endif /* !_LOCORE */ #endif /* _KERNEL */ diff --git a/sys/arch/pmax/include/param.h b/sys/arch/pmax/include/param.h index a98437b9c0a5..996661c1ff00 100644 --- a/sys/arch/pmax/include/param.h +++ b/sys/arch/pmax/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.37 2005/12/11 12:18:39 christos Exp $ */ +/* $NetBSD: param.h,v 1.38 2006/09/10 11:12:20 tsutsui Exp $ */ /* * Copyright (c) 1992, 1993 @@ -133,11 +133,18 @@ void delay __P((int n)); extern int cpuspeed; -#define DELAY(n) { int N = cpuspeed * (n); while (--N > 0); } +static __inline void __attribute__((__unused__)) +DELAY(int n) +{ + register int __N = cpuspeed * n; + + do { + __asm("addiu %0,%1,-1" : "=r" (__N) : "0" (__N)); + } while (__N > 0); +} #include - #endif /* !_LOCORE */ #endif /* _KERNEL */