Deleted Added
full compact
1/*
2 * Functions to provide access to special i386 instructions.
3 * XXX - bezillions more are defined in locore.s but are not declared anywhere.
4 *
5 * $Id: cpufunc.h,v 1.4 1993/11/07 17:42:47 wollman Exp $
6 */
7
8#ifndef _MACHINE_CPUFUNC_H_
9#define _MACHINE_CPUFUNC_H_ 1
10
11#include <sys/cdefs.h>
12#include <sys/types.h>
13
14#ifdef __GNUC__
15
16static inline int bdb(void)
17{
18 extern int bdb_exists;
19
20 if (!bdb_exists)
21 return (0);
22 __asm("int $3");
23 return (1);
24}
25
26static inline void
27disable_intr(void)
28{
29 __asm __volatile("cli");
30}
31
32static inline void
33enable_intr(void)
34{
35 __asm __volatile("sti");
36}
37
38/*
39 * This roundabout method of returning a u_char helps stop gcc-1.40 from
40 * generating unnecessary movzbl's.
41 */
42#define inb(port) ((u_char) u_int_inb(port))
43
44static inline u_int
45u_int_inb(u_int port)
46{
47 u_char data;
48 /*
49 * We use %%dx and not %1 here because i/o is done at %dx and not at
50 * %edx, while gcc-2.2.2 generates inferior code (movw instead of movl)
51 * if we tell it to load (u_short) port.
52 */
53 __asm __volatile("inb %%dx,%0" : "=a" (data) : "d" (port));
54 return data;
55}
56
57static inline void
58outb(u_int port, u_char data)
59{
60 register u_char al asm("ax");
61
62 al = data; /* help gcc-1.40's register allocator */
63 __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
64}
65
66static inline
67int
68imin(a, b)
69 int a, b;
70{
71
72 return (a < b ? a : b);
73}
74
75static inline
76int
77imax(a, b)
78 int a, b;
79{
80
81 return (a > b ? a : b);
82}
83
84static inline
85unsigned int
86min(a, b)
87 unsigned int a, b;
88{
89
90 return (a < b ? a : b);
91}
92
93static inline
94unsigned int
95max(a, b)
96 unsigned int a, b;
97{
98
99 return (a > b ? a : b);
100}
101
102static inline
103long
104lmin(a, b)
105 long a, b;
106{
107
108 return (a < b ? a : b);
109}
110
111static inline
112long
113lmax(a, b)
114 long a, b;
115{
116
117 return (a > b ? a : b);
118}
119
120static inline
121unsigned long
122ulmin(a, b)
123 unsigned long a, b;
124{
125
126 return (a < b ? a : b);
127}
128
129static inline
130unsigned long
131ulmax(a, b)
132 unsigned long a, b;
133{
134
135 return (a > b ? a : b);
136}
137
138static inline
139int
140ffs(mask)
141 register long mask;
142{
143 register int bit;
144
145 if (!mask)
146 return(0);
147 for (bit = 1;; ++bit) {
148 if (mask&0x01)
149 return(bit);
150 mask >>= 1;
151 }
152}
153
154static inline
155int
156bcmp(v1, v2, len)
157 void *v1, *v2;
158 register unsigned len;
159{
160 register u_char *s1 = v1, *s2 = v2;
161
162 while (len--)
163 if (*s1++ != *s2++)
164 return (1);
165 return (0);
166}
167
168static inline
169size_t
170strlen(s1)
171 register const char *s1;
172{
173 register size_t len;
174
175 for (len = 0; *s1++ != '\0'; len++)
176 ;
177 return (len);
178}
179

--- 24 unchanged lines hidden ---