Home | History | Annotate | Download | only in system

Lines Matching defs:options

5 // Functions to help with verifying various |Mojo...Options| structs from the
27 template <class Options>
30 // Constructor from a |const* Options| (which it checks -- this constructor
34 explicit UserOptionsReader(const Options* options) {
35 CHECK(options && IsAligned<MOJO_ALIGNOF(Options)>(options));
36 options_ = GetSizeForReader(options) == 0 ? nullptr : options;
37 static_assert(offsetof(Options, struct_size) == 0,
38 "struct_size not first member of Options");
40 // static_assert(sizeof(Options::struct_size) == sizeof(uint32_t),
41 // "Options::struct_size not a uint32_t");
47 const Options& options() const {
52 // Checks that the given (variable-size) |options| passed to the constructor
58 // from |offsetof(Options, some_member)| and |sizeof(Options::some_member)|,
60 return options().struct_size >= offset + size;
64 static inline size_t GetSizeForReader(const Options* options) {
65 uint32_t struct_size = *reinterpret_cast<const uint32_t*>(options);
69 return std::min(static_cast<size_t>(struct_size), sizeof(Options));
77 const Options* options_;
82 // Macro to invoke |UserOptionsReader<Options>::HasMember()| parametrized by
88 // TODO(vtl): With C++11, use |sizeof(Options::member)| instead of (the
89 // contortion below). We might also be able to pull out the type |Options| from
91 #define OPTIONS_STRUCT_HAS_MEMBER(Options, member, reader) \
92 reader.HasMember(offsetof(Options, member), sizeof(reader.options().member))