diff options
author | dg <dg@FreeBSD.org> | 1993-07-27 10:52:31 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1993-07-27 10:52:31 +0000 |
commit | ed0c2480407bece983d693e1753de8d830a5f5ba (patch) | |
tree | f74d745c1c162578afcb421239425fdd31e58e8a /sys/amd64/include | |
parent | 17f98e8cfc1b74c9d12ce4853fc1d7635a20dfb1 (diff) | |
download | FreeBSD-src-ed0c2480407bece983d693e1753de8d830a5f5ba.zip FreeBSD-src-ed0c2480407bece983d693e1753de8d830a5f5ba.tar.gz |
* Applied fixes from Bruce Evans to fix COW bugs, >1MB kernel loading,
profiling, and various protection checks that cause security holes
and system crashes.
* Changed min/max/bcmp/ffs/strlen to be static inline functions
- included from cpufunc.h in via systm.h. This change
improves performance in many parts of the kernel - up to 5% in the
networking layer alone. Note that this requires systm.h to be included
in any file that uses these functions otherwise it won't be able to
find them during the load.
* Fixed incorrect call to splx() in if_is.c
* Fixed bogus variable assignment to splx() in if_ed.c
Diffstat (limited to 'sys/amd64/include')
-rw-r--r-- | sys/amd64/include/cpu.h | 2 | ||||
-rw-r--r-- | sys/amd64/include/cpufunc.h | 111 |
2 files changed, 113 insertions, 0 deletions
diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h index 583d76c..9e09dd4 100644 --- a/sys/amd64/include/cpu.h +++ b/sys/amd64/include/cpu.h @@ -53,10 +53,12 @@ * these are defined to get generic functions * rather than inline or machine-dependent implementations */ +#if 0 #define NEED_MINMAX /* need {,i,l,ul}{min,max} functions */ #define NEED_FFS /* need ffs function */ #define NEED_BCMP /* need bcmp function */ #define NEED_STRLEN /* need strlen function */ +#endif #define cpu_exec(p) /* nothing */ diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index e3b4a8c..eb9a792 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -58,6 +58,116 @@ outb(u_int port, u_char data) __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port)); } +static __inline__ +imin(a, b) + int a, b; +{ + + return (a < b ? a : b); +} + +static __inline__ +imax(a, b) + int a, b; +{ + + return (a > b ? a : b); +} + +static __inline__ +unsigned int +min(a, b) + unsigned int a, b; +{ + + return (a < b ? a : b); +} + +static __inline__ +unsigned int +max(a, b) + unsigned int a, b; +{ + + return (a > b ? a : b); +} + +static __inline__ +long +lmin(a, b) + long a, b; +{ + + return (a < b ? a : b); +} + +static __inline__ +long +lmax(a, b) + long a, b; +{ + + return (a > b ? a : b); +} + +static __inline__ +unsigned long +ulmin(a, b) + unsigned long a, b; +{ + + return (a < b ? a : b); +} + +static __inline__ +unsigned long +ulmax(a, b) + unsigned long a, b; +{ + + return (a > b ? a : b); +} + +static __inline__ +ffs(mask) + register long mask; +{ + register int bit; + + if (!mask) + return(0); + for (bit = 1;; ++bit) { + if (mask&0x01) + return(bit); + mask >>= 1; + } +} + +static __inline__ +bcmp(v1, v2, len) + void *v1, *v2; + register unsigned len; +{ + register u_char *s1 = v1, *s2 = v2; + + while (len--) + if (*s1++ != *s2++) + return (1); + return (0); +} + +static __inline__ +size_t +strlen(s1) + register __const__ char *s1; +{ + register size_t len; + + for (len = 0; *s1++ != '\0'; len++) + ; + return (len); +} + #else /* not __GNUC__ */ int bdb __P((void)); @@ -80,3 +190,4 @@ really_void setidt __P((int idx, /*XXX*/caddr_t func, int typ, int dpl)); #undef really_u_int #undef really_void + |