1 /***************************************************************************
2 array.h - 0x88 and bounds-checked static array
4 begin : Sun Sep 23 2007
5 copyright : (C) 2007 by Maurizio Monge
6 email : monge@linuz.sns.it
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
23 template<typename T
, int S
>
30 T
& operator[](unsigned int index
) const {
32 return ((T
*)data
)[index
];
42 class PACKED A88Data
{
45 uint8_t& operator[](unsigned int index
) const {
46 ASSERT(!(index
& (uint8_t)0x08));
48 return ((uint8_t*)data
)[index
];
55 A88(uint8_t *p
) : ptr(p
) {}
56 A88(const A88Data
& d
) : ptr((uint8_t*)d
.data
) {}
57 uint8_t& operator[](unsigned int index
) const {
58 ASSERT(!(index
& (uint8_t)0x08));
60 return ((uint8_t*)ptr
)[index
];
63 #define DEF2_A88(a,b) A88Data a; A88Data b
68 #define DEF2_A88(a,b) union { uint8_t a[128]; struct { uint8_t _pad_for_##b[8]; uint8_t b[120]; }; }
72 inline void zero_a88(A88 d
)
74 register uint64_t *z
= (uint64_t*)&d
[0];