-
- Downloads
target: provide container_of()
Provide a cleaner way to handle single inheritance of targets
in C, using the same model Linux does: structs containing other
structs, un-nested via calls to a "container_of()" macro that
are packaged in typesafe inline functions.
Targets already use this containment idiom, but make it much
more complicated because they un-nest using embedded "void *"
pointers ... in chains of up to five per target, which is all
pure needless complication. (Example: arm92x core, arm9tdmi,
arm7_9, armv4_5 ... on top of the base "target" class.)
Applying this scheme consistently simplifies things, and gets
rid of many error-prone untyped pointers. It won't change any
part of the type model though -- it just simplifies things.
(And facilitates more cleanup later on.)
Rule of thumb: where there's an X->arch_info void* pointer,
access to that pointer can and should be removed. It may be
convenient to set up pointers to some of the embedded structs;
and shrink their current "*_common" names (annoyingly long).
Signed-off-by:
David Brownell <dbrownell@users.sourceforge.net>
Showing
- src/target/arm720t.h 7 additions, 0 deletionssrc/target/arm720t.h
- src/target/arm7_9_common.h 7 additions, 0 deletionssrc/target/arm7_9_common.h
- src/target/arm920t.h 7 additions, 0 deletionssrc/target/arm920t.h
- src/target/arm926ejs.h 8 additions, 0 deletionssrc/target/arm926ejs.h
- src/target/arm966e.h 7 additions, 0 deletionssrc/target/arm966e.h
- src/target/armv4_5.h 6 additions, 0 deletionssrc/target/armv4_5.h
- src/target/armv7a.h 7 additions, 0 deletionssrc/target/armv7a.h
- src/target/armv7m.h 6 additions, 0 deletionssrc/target/armv7m.h
- src/target/cortex_a8.h 7 additions, 0 deletionssrc/target/cortex_a8.h
- src/target/cortex_m3.h 7 additions, 0 deletionssrc/target/cortex_m3.h
- src/target/target.h 15 additions, 0 deletionssrc/target/target.h
- src/target/xscale.h 7 additions, 0 deletionssrc/target/xscale.h
Please register or sign in to comment