RTEMS CPU Kit with SuperCore  4.11.3
libkern.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 1992, 1993
3  * The Regents of the University of California. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 4. Neither the name of the University nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * @(#)libkern.h 8.1 (Berkeley) 6/10/93
30  * $FreeBSD: src/sys/sys/libkern.h,v 1.48 2005/02/10 20:39:39 glebius Exp $
31  */
32 
33 
34 #ifndef _SYS_LIBKERN_H_
35 #define _SYS_LIBKERN_H_
36 
37 #include <sys/cdefs.h>
38 #include <sys/types.h>
39 
40 /* BCD conversions. */
41 extern u_char const bcd2bin_data[];
42 extern u_char const bin2bcd_data[];
43 extern char const hex2ascii_data[];
44 
45 #define bcd2bin(bcd) (bcd2bin_data[bcd])
46 #define bin2bcd(bin) (bin2bcd_data[bin])
47 #define hex2ascii(hex) (hex2ascii_data[hex])
48 
49 static __inline int imax(int a, int b) { return (a > b ? a : b); }
50 static __inline int imin(int a, int b) { return (a < b ? a : b); }
51 static __inline long lmax(long a, long b) { return (a > b ? a : b); }
52 static __inline long lmin(long a, long b) { return (a < b ? a : b); }
53 static __inline u_int max(u_int a, u_int b) { return (a > b ? a : b); }
54 static __inline u_int min(u_int a, u_int b) { return (a < b ? a : b); }
55 static __inline quad_t qmax(quad_t a, quad_t b) { return (a > b ? a : b); }
56 static __inline quad_t qmin(quad_t a, quad_t b) { return (a < b ? a : b); }
57 static __inline u_long ulmax(u_long a, u_long b) { return (a > b ? a : b); }
58 static __inline u_long ulmin(u_long a, u_long b) { return (a < b ? a : b); }
59 
60 /* Prototypes for non-quad routines. */
61 int bcmp(const void *, const void *, size_t);
62 #ifndef HAVE_INLINE_FFS
63 int ffs(int);
64 #endif
65 #ifndef HAVE_INLINE_FLS
66 int fls(int);
67 #endif
68 int locc(int, char *, u_int);
69 void qsort(void *base, size_t nmemb, size_t size,
70  int (*compar)(const void *, const void *));
71 #if defined(__rtems__)
72 u_long rtems_bsdnet_random(void);
73 #define random() rtems_bsdnet_random()
74 #else
75 u_long random(void);
76 #endif
77 char *index(const char *, int);
78 char *rindex(const char *, int);
79 int scanc(u_int, const u_char *, const u_char *, int);
80 int skpc(int, int, char *);
81 void srandom(u_long);
82 char *strcat(char * __restrict, const char * __restrict);
83 int strcmp(const char *, const char *);
84 char *strdup(const char *s);
85 char *strcpy(char * __restrict, const char * __restrict);
86 size_t strlen(const char *);
87 int strncmp(const char *, const char *, size_t);
88 char *strncpy(char * __restrict, const char * __restrict, size_t);
89 char *strerror(int errnum);
90 
91 #endif /* !_SYS_LIBKERN_H_ */