00001 /*- 00002 * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer, 00010 * without modification. 00011 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 00012 * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any 00013 * redistribution must be conditioned upon including a substantially 00014 * similar Disclaimer requirement for further binary redistribution. 00015 * 3. Neither the names of the above-listed copyright holders nor the names 00016 * of any contributors may be used to endorse or promote products derived 00017 * from this software without specific prior written permission. 00018 * 00019 * Alternatively, this software may be distributed under the terms of the 00020 * GNU General Public License ("GPL") version 2 as published by the Free 00021 * Software Foundation. 00022 * 00023 * NO WARRANTY 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00025 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00026 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY 00027 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00028 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, 00029 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00030 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00031 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00032 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00033 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 00034 * THE POSSIBILITY OF SUCH DAMAGES. 00035 * 00036 * $Id: compat.h,v 1.1.1.1 2004/05/29 02:49:49 jbicket Exp $ 00037 */ 00038 #ifndef _ATH_COMPAT_H_ 00039 #define _ATH_COMPAT_H_ 00040 /* 00041 * BSD/Linux compatibility shims. These are used mainly to 00042 * minimize differences when importing necesary BSD code. 00043 */ 00044 #define NBBY 8 /* number of bits/byte */ 00045 00046 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ 00047 #define howmany(x, y) (((x)+((y)-1))/(y)) 00048 00049 /* Bit map related macros. */ 00050 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 00051 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 00052 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 00053 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 00054 00055 #define __packed __attribute__((__packed__)) 00056 #define __printflike(_a,_b) \ 00057 __attribute__ ((__format__ (__printf__, _a, _b))) 00058 00059 #ifndef ALIGNED_POINTER 00060 /* 00061 * ALIGNED_POINTER is a boolean macro that checks whether an address 00062 * is valid to fetch data elements of type t from on this architecture. 00063 * This does not reflect the optimal alignment, just the possibility 00064 * (within reasonable limits). 00065 * 00066 */ 00067 #define ALIGNED_POINTER(p,t) 1 00068 #endif 00069 00070 #define KASSERT(_condition, _x) 00071 #endif /* _ATH_COMPAT_H_ */