Lines Matching +full:mem +full:- +full:array
1 // SPDX-License-Identifier: GPL-2.0
8 use core::mem::MaybeUninit;
13 /// guarantee (at compile-time) zero-termination of device id tables provided by drivers.
17 /// Implementers must ensure that `Self` is layout-compatible with [`RawDeviceId::RawType`];
29 /// Id tables created from [`Self`] are going to hold this type in its zero-terminated array.
36 /// that is used to store a pointer-sized value (e.g., an index or context pointer).
52 fn index(&self) -> usize; in index()
55 /// A zero-terminated device id array.
64 pub const fn size(&self) -> usize { in size()
65 core::mem::size_of::<Self>() in size()
69 /// A zero-terminated device id array, followed by context data.
77 /// Creates a new instance of the array.
85 /// - `data_offset` must be the correct offset (in bytes) to the context/data field
87 /// - The field at `data_offset` must be correctly sized to hold a `usize`.
88 const unsafe fn build(ids: [(T, U); N], data_offset: Option<usize>) -> Self { in build()
95 // layout-wise compatible with `RawType`.
96 raw_ids[i] = unsafe { core::mem::transmute_copy(&ids[i].0) };
115 core::mem::forget(ids);
122 ids: unsafe { core::mem::transmute_copy(&raw_ids) },
127 id_infos: unsafe { core::mem::transmute_copy(&infos) },
131 /// Creates a new instance of the array without writing index values.
135 pub const fn new_without_index(ids: [(T, U); N]) -> Self { in new_without_index()
142 pub const fn raw_ids(&self) -> &RawIdArray<T, N> { in raw_ids()
148 /// Creates a new instance of the array.
151 pub const fn new(ids: [(T, U); N]) -> Self { in new()
167 fn as_ptr(&self) -> *const T::RawType; in as_ptr()
170 fn id(&self, index: usize) -> &T::RawType; in id()
172 /// Obtain the pointer to the driver-specific information from an index.
173 fn info(&self, index: usize) -> &U; in info()
177 fn as_ptr(&self) -> *const T::RawType { in as_ptr()
183 fn id(&self, index: usize) -> &T::RawType { in id()
187 fn info(&self, index: usize) -> &U { in info()
203 static $module_table_name: [::core::mem::MaybeUninit<u8>; $table_name.raw_ids().size()] =
204 unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) };