OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [tcpip/] [v2_0/] [include/] [lib/] [libkern/] [libkern.h] - Blame information for rev 27

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      include/lib/libkern/libkern.h
4
//
5
//      
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
 
33
/*      $OpenBSD: libkern.h,v 1.14 1997/11/30 21:47:45 mickey Exp $     */
34
/*      $NetBSD: libkern.h,v 1.7 1996/03/14 18:52:08 christos Exp $     */
35
 
36
/*-
37
 * Copyright (c) 1992, 1993
38
 *      The Regents of the University of California.  All rights reserved.
39
 *
40
 * Redistribution and use in source and binary forms, with or without
41
 * modification, are permitted provided that the following conditions
42
 * are met:
43
 * 1. Redistributions of source code must retain the above copyright
44
 *    notice, this list of conditions and the following disclaimer.
45
 * 2. Redistributions in binary form must reproduce the above copyright
46
 *    notice, this list of conditions and the following disclaimer in the
47
 *    documentation and/or other materials provided with the distribution.
48
 * 3. All advertising materials mentioning features or use of this software
49
 *    must display the following acknowledgement:
50
 *      This product includes software developed by the University of
51
 *      California, Berkeley and its contributors.
52
 * 4. Neither the name of the University nor the names of its contributors
53
 *    may be used to endorse or promote products derived from this software
54
 *    without specific prior written permission.
55
 *
56
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66
 * SUCH DAMAGE.
67
 *
68
 *      @(#)libkern.h   8.1 (Berkeley) 6/10/93
69
 */
70
 
71
#ifndef __LIBKERN_H__
72
#define __LIBKERN_H__
73
 
74
#ifdef __INSIDE_NET
75
 
76
#include <sys/types.h>
77
 
78
#ifndef LIBKERN_INLINE
79
#ifndef NO_LIBKERN_INLINE
80
#define LIBKERN_INLINE  static __inline
81
#define LIBKERN_BODY
82
#else
83
#define LIBKERN_INLINE
84
#endif
85
#endif
86
 
87
 
88
LIBKERN_INLINE int imax __P((int, int));
89
LIBKERN_INLINE int imin __P((int, int));
90
LIBKERN_INLINE u_int max __P((u_int, u_int));
91
LIBKERN_INLINE u_int min __P((u_int, u_int));
92
LIBKERN_INLINE long lmax __P((long, long));
93
LIBKERN_INLINE long lmin __P((long, long));
94
LIBKERN_INLINE u_long ulmax __P((u_long, u_long));
95
LIBKERN_INLINE u_long ulmin __P((u_long, u_long));
96
LIBKERN_INLINE int abs __P((int));
97
 
98
#ifdef LIBKERN_BODY
99
LIBKERN_INLINE int
100
imax(a, b)
101
        int a, b;
102
{
103
        return (a > b ? a : b);
104
}
105
LIBKERN_INLINE int
106
imin(a, b)
107
        int a, b;
108
{
109
        return (a < b ? a : b);
110
}
111
LIBKERN_INLINE long
112
lmax(a, b)
113
        long a, b;
114
{
115
        return (a > b ? a : b);
116
}
117
LIBKERN_INLINE long
118
lmin(a, b)
119
        long a, b;
120
{
121
        return (a < b ? a : b);
122
}
123
LIBKERN_INLINE u_int
124
max(a, b)
125
        u_int a, b;
126
{
127
        return (a > b ? a : b);
128
}
129
LIBKERN_INLINE u_int
130
min(a, b)
131
        u_int a, b;
132
{
133
        return (a < b ? a : b);
134
}
135
LIBKERN_INLINE u_long
136
ulmax(a, b)
137
        u_long a, b;
138
{
139
        return (a > b ? a : b);
140
}
141
LIBKERN_INLINE u_long
142
ulmin(a, b)
143
        u_long a, b;
144
{
145
        return (a < b ? a : b);
146
}
147
 
148
LIBKERN_INLINE int
149
abs(j)
150
        int j;
151
{
152
        return(j < 0 ? -j : j);
153
}
154
#endif
155
 
156
#ifndef __ECOS
157
#ifdef NDEBUG                                           /* tradition! */
158
#define assert(e)       ((void)0)
159
#else
160
#ifdef __STDC__
161
#define assert(e)       ((e) ? (void)0 :                                    \
162
                            __assert("", __FILE__, __LINE__, #e))
163
#else
164
#define assert(e)       ((e) ? (void)0 :                                    \
165
                            __assert("", __FILE__, __LINE__, "e"))
166
#endif
167
#endif
168
 
169
#ifndef DIAGNOSTIC
170
#define KASSERT(e)      ((void)0)
171
#else
172
#ifdef __STDC__
173
#define KASSERT(e)      ((e) ? (void)0 :                                    \
174
                            __assert("diagnostic ", __FILE__, __LINE__, #e))
175
#else
176
#define KASSERT(e)      ((e) ? (void)0 :                                    \
177
                            __assert("diagnostic ", __FILE__, __LINE__, "e"))
178
#endif
179
#endif
180
 
181
#ifndef DEBUG
182
#define KDASSERT(e)     ((void)0)
183
#else
184
#ifdef __STDC__
185
#define KDASSERT(e)     ((e) ? (void)0 :                                    \
186
                            __assert("debugging ", __FILE__, __LINE__, #e))
187
#else
188
#define KDASSERT(e)     ((e) ? (void)0 :                                    \
189
                            __assert("debugging ", __FILE__, __LINE__, "e"))
190
#endif
191
#endif
192
#endif
193
 
194
/* Prototypes for non-quad routines. */
195
#ifndef __ECOS
196
void     __assert __P((const char *, const char *, int, const char *))
197
            __attribute__ ((__noreturn__));
198
#endif
199
int      bcmp __P((const void *, const void *, size_t));
200
int      ffs __P((int));
201
int      locc __P((int, char *, u_int));
202
void    *memchr __P((const void *, int, size_t));
203
int      scanc __P((u_int, const u_char *, const u_char *, int));
204
int      skpc __P((int, size_t, u_char *));
205
size_t   strlen __P((const char *));
206
char    *strcat __P((char *, const char *));
207
char    *strcpy __P((char *, const char *));
208
char    *strncpy __P((char *, const char *, size_t));
209
int      strcmp __P((const char *, const char *));
210
int      strncmp __P((const char *, const char *, size_t));
211
int      strncasecmp __P((const char *, const char *, size_t));
212
int      getsn __P((char *, int));
213
 
214
extern u_int8_t const __bcd2bin[], __bin2bcd[];
215
#define bcd2bin(b)      (__bcd2bin[(b)&0xff])
216
#define bin2bcd(b)      (__bin2bcd[(b)&0xff])
217
 
218
#endif /* __INSIDE_NET */
219
 
220
#endif /* __LIBKERN_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.