libkern.h revision 1.6 1 /* $NetBSD: libkern.h,v 1.6 1996/02/13 23:48:26 christos Exp $ */
2
3 /*-
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)libkern.h 8.1 (Berkeley) 6/10/93
36 */
37
38 #include <sys/types.h>
39
40 static __inline int imax __P((int, int));
41 static __inline int imin __P((int, int));
42 static __inline u_int max __P((u_int, u_int));
43 static __inline u_int min __P((u_int, u_int));
44 static __inline long lmax __P((long, long));
45 static __inline long lmin __P((long, long));
46 static __inline u_long ulmax __P((u_long, u_long));
47 static __inline u_long ulmin __P((u_long, u_long));
48 static __inline int abs __P((int));
49
50 static __inline int
51 imax(a, b)
52 int a, b;
53 {
54 return (a > b ? a : b);
55 }
56 static __inline int
57 imin(a, b)
58 int a, b;
59 {
60 return (a < b ? a : b);
61 }
62 static __inline long
63 lmax(a, b)
64 long a, b;
65 {
66 return (a > b ? a : b);
67 }
68 static __inline long
69 lmin(a, b)
70 long a, b;
71 {
72 return (a < b ? a : b);
73 }
74 static __inline u_int
75 max(a, b)
76 u_int a, b;
77 {
78 return (a > b ? a : b);
79 }
80 static __inline u_int
81 min(a, b)
82 u_int a, b;
83 {
84 return (a < b ? a : b);
85 }
86 static __inline u_long
87 ulmax(a, b)
88 u_long a, b;
89 {
90 return (a > b ? a : b);
91 }
92 static __inline u_long
93 ulmin(a, b)
94 u_long a, b;
95 {
96 return (a < b ? a : b);
97 }
98
99 static __inline int
100 abs(j)
101 int j;
102 {
103 return(j < 0 ? -j : j);
104 }
105
106 /* Prototypes for non-quad routines. */
107 int bcmp __P((const void *, const void *, size_t));
108 int ffs __P((int));
109 int locc __P((int, char *, u_int));
110 u_long random __P((void));
111 char *rindex __P((const char *, int));
112 int scanc __P((u_int, u_char *, u_char *, int));
113 int skpc __P((int, int, char *));
114 size_t strlen __P((const char *));
115 char *strcat __P((char *, const char *));
116 char *strcpy __P((char *, const char *));
117 char *strncpy __P((char *, const char *, size_t));
118 int strcmp __P((const char *, const char *));
119 int strncmp __P((const char *, const char *, size_t));
120 int strncasecmp __P((const char *, const char *, size_t));
121