struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / driverstruct.c
blob8ed8fc8b5b4db1292d08071af840a0e607379491
1 /** Tests a few features of a driver struct - a struct with
2 many function pointers.
3 */
4 #include <testfwk.h>
5 #include <stddef.h>
7 /* Set to one to show the bug */
8 #if 1
9 #define NAME(_a) _a
10 #else
11 #define NAME(_a)
12 #endif
14 typedef unsigned char uchar;
16 /* Originally from UZIX - http://uzix.sourceforge.net/
19 typedef struct s_devsw {
20 uchar minors; /* # of minor device numbers */
21 int (*dev_init)(uchar NAME(minor)) __reentrant;
22 int (*dev_open)(uchar NAME(minor)) __reentrant;
23 int (*dev_close)(uchar NAME(minor)) __reentrant;
24 int (*dev_read)(uchar NAME(minor), uchar NAME(w)) __reentrant;
25 int (*dev_write)(uchar NAME(minor), uchar NAME(w)) __reentrant;
26 int (*dev_ioctl)(uchar NAME(minor), int cmd, void *__data) __reentrant;
27 } devsw_t;
29 static int
30 _init (uchar minor) __reentrant
32 return minor;
35 static devsw_t _sillyDriver = {
37 _init,
38 NULL, NULL, NULL, NULL, NULL
41 int
42 initProxy (devsw_t *pdrv)
44 return (*pdrv->dev_init)(5);
47 void
48 testDriverStruct (void)
50 ASSERT (initProxy(&_sillyDriver) == 5);