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