File: littypes.h

package info (click to toggle)
convlit 1.8-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 612 kB
  • sloc: ansic: 8,141; makefile: 58
file content (56 lines) | stat: -rw-r--r-- 2,163 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

/*****************************************************************************/
/*--[littypes.h]---------------------------------------------------------------
 | Copyright (C) 2002 Dan A. Jackson 
 |
 | This file is part of the "openclit" library for processing .LIT files.
 |
 | "Openclit" is free software; you can redistribute it and/or modify
 | it under the terms of the GNU General Public License as published by
 | the Free Software Foundation; either version 2 of the License, or
 | (at your option) any later version.
 |
 | This program is distributed in the hope that it will be useful,
 | but WITHOUT ANY WARRANTY; without even the implied warranty of
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | GNU General Public License for more details.
 |
 | You should have received a copy of the GNU General Public License
 | along with this program; if not, write to the Free Software
 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
 | The GNU General Public License may also be available at the following
 | URL: http://www.gnu.org/licenses/gpl.html
*/
#ifndef LITTYPES_H
#define LITTYPES_H

typedef     unsigned char       U8;
typedef     unsigned short int  U16;
typedef     unsigned long int   U32;
#ifdef _MSC_VER
typedef     unsigned __int64    U64;
#else
typedef     unsigned long long  U64;
#endif

#define READ_U32(pv) (  (U32)*((U8 *)(pv))                + \
                        ((U32)(*((U8 *)(pv) + 1)) <<  8)  + \
                        ((U32)(*((U8 *)(pv) + 2)) << 16)  + \
                        ((U32)(*((U8 *)(pv) + 3)) << 24)  )

#define READ_INT32(pv)  ((int)(READ_U32(pv)&0x7FFFFFFF))

#define READ_U16(pv) (int)((U16)*((U8 *)(pv))                + \
                           ((U16)(*((U8 *)(pv) + 1)) <<  8)  )
                        

#define WRITE_U32(p,x) ( *((p)+0)=(U8)((x)&0xff),      \
                         *((p)+1)=(U8)(((x)>>8)&0xff), \
                         *((p)+2)=(U8)(((x)>>16)&0xff),\
                         *((p)+3)=(U8)(((x)>>24)&0xff) )

#define WRITE_U16(p,x) ( *((p)+0)=(U8)((x)&0xff),      \
                         *((p)+1)=(U8)(((x)>>8)&0xff)  )

#endif