00001 #ifndef _SYS_TYPES_H_ 00002 #define _SYS_TYPES_H_ 00003 00004 /* 00005 * Copyright (C) 2001-2002 by egnite Software GmbH. All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. All advertising materials mentioning features or use of this 00017 * software must display the following acknowledgement: 00018 * 00019 * This product includes software developed by egnite Software GmbH 00020 * and its contributors. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS 00023 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE 00026 * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00029 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00030 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00032 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00033 * SUCH DAMAGE. 00034 * 00035 * For additional information see http://www.ethernut.de/ 00036 * 00037 * - 00038 * Portions Copyright (c) 1983, 1993 by 00039 * The Regents of the University of California. All rights reserved. 00040 * 00041 * Redistribution and use in source and binary forms, with or without 00042 * modification, are permitted provided that the following conditions 00043 * are met: 00044 * 1. Redistributions of source code must retain the above copyright 00045 * notice, this list of conditions and the following disclaimer. 00046 * 2. Redistributions in binary form must reproduce the above copyright 00047 * notice, this list of conditions and the following disclaimer in the 00048 * documentation and/or other materials provided with the distribution. 00049 * 3. All advertising materials mentioning features or use of this software 00050 * must display the following acknowledgement: 00051 * This product includes software developed by the University of 00052 * California, Berkeley and its contributors. 00053 * 4. Neither the name of the University nor the names of its contributors 00054 * may be used to endorse or promote products derived from this software 00055 * without specific prior written permission. 00056 * 00057 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00058 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00059 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00060 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00061 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00062 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00063 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00064 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00065 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00066 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00067 * SUCH DAMAGE. 00068 */ 00069 00070 /* 00071 * $Log: types.h,v $ 00072 * Revision 1.2 2003/01/24 12:01:07 przemko 00073 * Obciecie dosowych znakow konca lini 00074 * 00075 * Revision 1.1.1.1 2002/12/07 07:16:53 marwi 00076 * 00077 * 00078 * Revision 1.2 2002/08/01 19:50:38 harald 00079 * First public release 00080 * 00081 * Revision 1.1 2002/08/01 17:34:30 harald 00082 * First check in 00083 * 00084 */ 00085 00094 00096 typedef unsigned char u_char; 00098 typedef unsigned short u_short; 00100 typedef unsigned int u_int; 00102 typedef unsigned long u_long; 00104 typedef unsigned long long u_longlong; 00106 typedef void * HANDLE; 00107 00108 00109 /* 00110 * Conversion of 16 bit value to network order. 00111 */ 00112 static inline u_short __byte_swap2(u_short val) 00113 { 00114 asm volatile( 00115 "mov __tmp_reg__, %A0\n\t" 00116 "mov %A0, %B0\n\t" 00117 "mov %B0, __tmp_reg__\n\t" 00118 : "=r" (val) 00119 : "0" (val) 00120 ); 00121 return val; 00122 } 00123 00124 /* 00125 * Conversion of 32 bit value to network order. 00126 */ 00127 static inline u_long __byte_swap4(u_long val) 00128 { 00129 asm volatile( 00130 "mov __tmp_reg__, %A0\n\t" 00131 "mov %A0, %D0\n\t" 00132 "mov %D0, __tmp_reg__\n\t" 00133 "mov __tmp_reg__, %B0\n\t" 00134 "mov %B0, %C0\n\t" 00135 "mov %C0, __tmp_reg__\n\t" 00136 : "=r" (val) 00137 : "0" (val) 00138 ); 00139 return val; 00140 } 00141 00145 #define htons(x) __byte_swap2(x) 00146 00150 #define htonl(x) __byte_swap4(x) 00151 00155 #define ntohs(x) __byte_swap2(x) 00156 00160 #define ntohl(x) __byte_swap4(x) 00161 00164 #endif