Mercurial > flash_v2
comparison packages/io/common/current/src/iosys.c @ 1595:05e490add1fb
* src/iosys.c (cyg_io_lookup): Use union to avoid aliasing problems
with compiler.
| author | jlarmour |
|---|---|
| date | Fri, 16 Apr 2004 03:33:40 +0000 |
| parents | d2c90368aeef |
| children |
comparison
equal
deleted
inserted
replaced
| 1594:edb4ac2e0d6b | 1595:05e490add1fb |
|---|---|
| 122 // | 122 // |
| 123 | 123 |
| 124 Cyg_ErrNo | 124 Cyg_ErrNo |
| 125 cyg_io_lookup(const char *name, cyg_io_handle_t *handle) | 125 cyg_io_lookup(const char *name, cyg_io_handle_t *handle) |
| 126 { | 126 { |
| 127 cyg_devtab_entry_t *t, *st; | 127 union devtab_entry_handle_union { |
| 128 cyg_devtab_entry_t *st; | |
| 129 cyg_io_handle_t h; | |
| 130 } stunion; | |
| 131 cyg_devtab_entry_t *t; | |
| 128 Cyg_ErrNo res; | 132 Cyg_ErrNo res; |
| 129 const char *name_ptr; | 133 const char *name_ptr; |
| 130 for (t = &__DEVTAB__[0]; t != &__DEVTAB_END__; t++) { | 134 for (t = &__DEVTAB__[0]; t != &__DEVTAB_END__; t++) { |
| 131 if (cyg_io_compare(name, t->name, &name_ptr)) { | 135 if (cyg_io_compare(name, t->name, &name_ptr)) { |
| 132 // FUTURE: Check 'avail'/'online' here | 136 // FUTURE: Check 'avail'/'online' here |
| 133 if (t->dep_name) { | 137 if (t->dep_name) { |
| 134 res = cyg_io_lookup(t->dep_name, (cyg_io_handle_t *)&st); | 138 res = cyg_io_lookup(t->dep_name, &stunion.h); |
| 135 if (res != ENOERR) { | 139 if (res != ENOERR) { |
| 136 return res; | 140 return res; |
| 137 } | 141 } |
| 138 } else { | 142 } else { |
| 139 st = (cyg_devtab_entry_t *)0; | 143 stunion.st = NULL; |
| 140 } | 144 } |
| 141 if (t->lookup) { | 145 if (t->lookup) { |
| 142 // This indirection + the name pointer allows the lookup routine | 146 // This indirection + the name pointer allows the lookup routine |
| 143 // to return a different 'devtab' handle. This will provide for | 147 // to return a different 'devtab' handle. This will provide for |
| 144 // 'pluggable' devices, file names, etc. | 148 // 'pluggable' devices, file names, etc. |
| 145 res = (t->lookup)(&t, st, name_ptr); | 149 res = (t->lookup)(&t, stunion.st, name_ptr); |
| 146 if (res != ENOERR) { | 150 if (res != ENOERR) { |
| 147 return res; | 151 return res; |
| 148 } | 152 } |
| 149 } | 153 } |
| 150 *handle = (cyg_io_handle_t)t; | 154 *handle = (cyg_io_handle_t)t; |
