2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1992-1995
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 This file implements macros for machine independent short and
27 #undef CAREFUL_ALIGNMENT
29 /* we know that the 386 can handle misalignment and has the "right"
32 #define CAREFUL_ALIGNMENT 0
35 #ifndef CAREFUL_ALIGNMENT
36 #define CAREFUL_ALIGNMENT 1
39 #define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
40 #define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
41 #define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
45 #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
46 #define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
47 #define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
48 #define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
49 #define SVALS(buf,pos) ((int16)SVAL(buf,pos))
50 #define IVALS(buf,pos) ((int32)IVAL(buf,pos))
51 #define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
52 #define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
53 #define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
54 #define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
56 /* this handles things for architectures like the 386 that can handle
59 WARNING: This section is dependent on the length of int16 and int32
62 #define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))
63 #define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
64 #define SVALS(buf,pos) (*(int16 *)((char *)(buf) + (pos)))
65 #define IVALS(buf,pos) (*(int32 *)((char *)(buf) + (pos)))
66 #define SSVAL(buf,pos,val) SVAL(buf,pos)=((uint16)(val))
67 #define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32)(val))
68 #define SSVALS(buf,pos,val) SVALS(buf,pos)=((int16)(val))
69 #define SIVALS(buf,pos,val) IVALS(buf,pos)=((int32)(val))