-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwtype.h
70 lines (61 loc) · 1.69 KB
/
wtype.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef DBXS_WTYPE_H
#define DBXS_WTYPE_H
/*
* The data type to use.
*
* This should be the largest native integer type available, but also needs
* to be portable and compile on ancient and wacky compilers.
*
* I used to just use 'unsigned long' and let things fall where they will.
*
* What I've decided to do in this version is to leverage as much of Perl's
* code as possible. This is in perl.h and config.h (included by perl.h).
*/
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifndef U32_CONST
/* From perl.h, wrapped in PERL_CORE */
# if INTSIZE >= 4
# define U32_CONST(x) ((U32TYPE)x##U)
# else
# define U32_CONST(x) ((U32TYPE)x##UL)
# endif
#endif
#ifndef U64_CONST
# ifdef HAS_QUAD
# if INTSIZE >= 8
# define U64_CONST(x) ((U64TYPE)x##U)
# elif LONGSIZE >= 8
# define U64_CONST(x) ((U64TYPE)x##UL)
# elif QUADKIND == QUAD_IS_LONG_LONG
# define U64_CONST(x) ((U64TYPE)x##ULL)
# else /* best guess we can make */
# define U64_CONST(x) ((U64TYPE)x##UL)
# endif
# endif
#endif
#ifdef HAS_QUAD
typedef U64TYPE WTYPE;
#define W_CONST(c) U64_CONST(c)
#define WTYPE_IS_64BIT 1
#define BITS_PER_WORD 64
#elif LONGSIZE >= 8
/* Should we be doing this? */
typedef unsigned long WTYPE
#define W_CONST(c) ((U64TYPE)x##UL)
#define WTYPE_IS_64BIT 1
#define BITS_PER_WORD 64
#else
typedef U32TYPE WTYPE;
#define W_CONST(c) U32_CONST(c)
#define WTYPE_IS_64BIT 0
#define BITS_PER_WORD 32
#endif
#define W_ZERO W_CONST(0)
#define W_ONE W_CONST(1)
#define W_FFFF W_CONST(~0)
#define MAXBIT (BITS_PER_WORD-1)
#define NWORDS(bits) ( ((bits)+BITS_PER_WORD-1) / BITS_PER_WORD )
#define NBYTES(bits) ( ((bits)+8-1) / 8 )
#endif