MSVC fixes. MSVC cannot handle offsetof(struct, member[index]); once an

array is involved, it seems to think it is not a constant expression.

Added MDRV_DEVICE_CONFIG_DATA32_EXPLICIT() macro which takes an explicit
size and offset. Changed MDRV_DEVICE_CONFIG_DATA32() to be built off of
this macro. Added MDRV_DEVICE_CONFIG_DATA32_ARRAY() and
MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER() which do explicit computations
of the offset to work around MSVC's problems.

Replicated these changes for DATA64 and DATAPTR macros. Updated latch8.h
to use the new macros.
This commit is contained in:
Aaron Giles 2008-08-25 15:13:48 +00:00
parent 8e44428b07
commit 4db67471be
2 changed files with 58 additions and 32 deletions

View File

@ -65,19 +65,19 @@ struct _latch8_config
/* Write bit to discrete node */
#define MDRV_LATCH8_DISCRETE_NODE(_bit, _node) \
MDRV_DEVICE_CONFIG_DATA32(latch8_config, node_map[_bit], _node)
MDRV_DEVICE_CONFIG_DATA32_ARRAY(latch8_config, node_map, _bit, _node)
/* Upon read, replace bits by reading from another device handler */
#define MDRV_LATCH8_DEVREAD(_bit, _type, _tag, _handler, _from_bit) \
MDRV_DEVICE_CONFIG_DATA32(latch8_config, devread[_bit].from_bit, _from_bit) \
MDRV_DEVICE_CONFIG_DATAPTR(latch8_config, devread[_bit].type, _type) \
MDRV_DEVICE_CONFIG_DATAPTR(latch8_config, devread[_bit].tag, _tag) \
MDRV_DEVICE_CONFIG_DATAPTR(latch8_config, devread[_bit].devread_handler, _handler)
MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, from_bit, _from_bit) \
MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, type, _type) \
MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, tag, _tag) \
MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, devread_handler, _handler) \
/* Upon read, replace bits by reading from another machine handler */
#define MDRV_LATCH8_READ(_bit, _handler, _from_bit) \
MDRV_DEVICE_CONFIG_DATA32(latch8_config, devread[_bit].from_bit, _from_bit) \
MDRV_DEVICE_CONFIG_DATAPTR(latch8_config, devread[_bit].read_handler, _handler)
MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, from_bit, _from_bit) \
MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(latch8_config, devread, _bit, latch8_devread, read_handler, _handler) \
/* remove device */
#define MDRV_LATCH8_REMOVE(_tag) \
@ -102,36 +102,36 @@ DEVICE_GET_INFO( latch8 );
/* write & read full byte */
READ8_DEVICE_HANDLER( latch8_r);
WRITE8_DEVICE_HANDLER( latch8_w);
READ8_DEVICE_HANDLER( latch8_r );
WRITE8_DEVICE_HANDLER( latch8_w );
/* reset the latch */
WRITE8_DEVICE_HANDLER( latch8_reset);
WRITE8_DEVICE_HANDLER( latch8_reset );
/* read bit x */
/* return (latch >> x) & 0x01 */
READ8_DEVICE_HANDLER( latch8_bit0_r);
READ8_DEVICE_HANDLER( latch8_bit1_r);
READ8_DEVICE_HANDLER( latch8_bit2_r);
READ8_DEVICE_HANDLER( latch8_bit3_r);
READ8_DEVICE_HANDLER( latch8_bit4_r);
READ8_DEVICE_HANDLER( latch8_bit5_r);
READ8_DEVICE_HANDLER( latch8_bit6_r);
READ8_DEVICE_HANDLER( latch8_bit7_r);
READ8_DEVICE_HANDLER( latch8_bit0_r );
READ8_DEVICE_HANDLER( latch8_bit1_r );
READ8_DEVICE_HANDLER( latch8_bit2_r );
READ8_DEVICE_HANDLER( latch8_bit3_r );
READ8_DEVICE_HANDLER( latch8_bit4_r );
READ8_DEVICE_HANDLER( latch8_bit5_r );
READ8_DEVICE_HANDLER( latch8_bit6_r );
READ8_DEVICE_HANDLER( latch8_bit7_r );
/* read inverted bit x */
/* return (latch >> x) & 0x01 */
READ8_DEVICE_HANDLER( latch8_bit0_q_r);
READ8_DEVICE_HANDLER( latch8_bit1_q_r);
READ8_DEVICE_HANDLER( latch8_bit2_q_r);
READ8_DEVICE_HANDLER( latch8_bit3_q_r);
READ8_DEVICE_HANDLER( latch8_bit4_q_r);
READ8_DEVICE_HANDLER( latch8_bit5_q_r);
READ8_DEVICE_HANDLER( latch8_bit6_q_r);
READ8_DEVICE_HANDLER( latch8_bit7_q_r);
READ8_DEVICE_HANDLER( latch8_bit0_q_r );
READ8_DEVICE_HANDLER( latch8_bit1_q_r );
READ8_DEVICE_HANDLER( latch8_bit2_q_r );
READ8_DEVICE_HANDLER( latch8_bit3_q_r );
READ8_DEVICE_HANDLER( latch8_bit4_q_r );
READ8_DEVICE_HANDLER( latch8_bit5_q_r );
READ8_DEVICE_HANDLER( latch8_bit6_q_r );
READ8_DEVICE_HANDLER( latch8_bit7_q_r );
/* write bit x from data into bit determined by offset */
/* latch = (latch & ~(1<<offset)) | (((data >> x) & 0x01) << offset) */

View File

@ -219,26 +219,52 @@ union _machine_config_token
TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DEVICE_CONFIG, 8), \
TOKEN_PTR(voidptr, &(_config)),
#define MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) \
TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, 8, sizeof(((_struct *)NULL)->_field), 6, offsetof(_struct, _field), 12), \
#define structsizeof(_struct, _field) sizeof(((_struct *)NULL)->_field)
#define MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_size, _offset, _val) \
TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA32, 8, (_size), 6, (_offset), 12), \
TOKEN_UINT32((UINT32)(_val)),
#define MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) \
TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, 8, sizeof(((_struct *)NULL)->_field), 6, offsetof(_struct, _field), 12), \
#define MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val) \
MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val)
#define MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val) \
MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val)
#define MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \
MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val)
#define MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_size, _offset, _val) \
TOKEN_UINT32_PACK3(MCONFIG_TOKEN_DEVICE_CONFIG_DATA64, 8, (_size), 6, (_offset), 12), \
TOKEN_UINT64((UINT64)(_val)),
#define MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val) \
MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field), offsetof(_struct, _field), _val)
#define MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val) \
MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_struct, _field[0]), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]), _val)
#define MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) \
MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(structsizeof(_memstruct, _member), offsetof(_struct, _field) + (_index) * structsizeof(_struct, _field[0]) + offsetof(_memstruct, _member), _val)
#define MDRV_DEVICE_CONFIG_DATAFP32(_struct, _field, _val, _fixbits) \
TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, 8, sizeof(((_struct *)NULL)->_field), 6, _fixbits, 6, offsetof(_struct, _field), 12), \
TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP32, 8, structsizeof(_struct, _field), 6, _fixbits, 6, offsetof(_struct, _field), 12), \
TOKEN_UINT32((INT32)((float)(_val) * (float)(1 << (_fixbits)))),
#define MDRV_DEVICE_CONFIG_DATAFP64(_struct, _field, _val, _fixbits) \
TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP64, 8, sizeof(((_struct *)NULL)->_field), 6, _fixbits, 6, offsetof(_struct, _field), 12), \
TOKEN_UINT32_PACK4(MCONFIG_TOKEN_DEVICE_CONFIG_DATAFP64, 8, structsizeof(_struct, _field), 6, _fixbits, 6, offsetof(_struct, _field), 12), \
TOKEN_UINT64((INT64)((float)(_val) * (float)((UINT64)1 << (_fixbits)))),
#ifdef PTR64
#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA64_EXPLICIT(_struct, _size, _offset)
#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA64(_struct, _field, _val)
#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY(_struct, _field, _index, _val)
#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA64_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val)
#else
#define MDRV_DEVICE_CONFIG_DATAPTR_EXPLICIT(_struct, _size, _offset) MDRV_DEVICE_CONFIG_DATA32_EXPLICIT(_struct, _size, _offset)
#define MDRV_DEVICE_CONFIG_DATAPTR(_struct, _field, _val) MDRV_DEVICE_CONFIG_DATA32(_struct, _field, _val)
#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY(_struct, _field, _index, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY(_struct, _field, _index, _val)
#define MDRV_DEVICE_CONFIG_DATAPTR_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val) MDRV_DEVICE_CONFIG_DATA32_ARRAY_MEMBER(_struct, _field, _index, _memstruct, _member, _val)
#endif