byteorder.h

説明を見る。
00001 /* 
00002    simple byteorder handling
00003    Copyright (C) Andrew Tridgell 1992-1995
00004    
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009    
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014    
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #undef CAREFUL_ALIGNMENT
00021 
00022 /* we know that the x86 can handle misalignment and has the "right" 
00023    byteorder */
00024 #ifdef __i386__
00025 #define CAREFUL_ALIGNMENT 0
00026 #endif
00027 
00028 #ifndef CAREFUL_ALIGNMENT
00029 #define CAREFUL_ALIGNMENT 1
00030 #endif
00031 
00032 #define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
00033 #define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
00034 #define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
00035 
00036 
00037 #if CAREFUL_ALIGNMENT
00038 #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
00039 #define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
00040 #define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
00041 #define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
00042 #define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
00043 #else
00044 /* this handles things for architectures like the 386 that can handle
00045    alignment errors */
00046 /*
00047    WARNING: This section is dependent on the length of int32
00048    being correct. set CAREFUL_ALIGNMENT if it is not.
00049 */
00050 #define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
00051 #define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32)(val))
00052 #endif
00053 
00054 

rsyncに対してSat Dec 5 19:45:40 2009に生成されました。  doxygen 1.4.7