@@ -482,24 +482,26 @@ pub unsafe trait HasWork<T, const ID: u64 = 0> {
482
482
/// use kernel::sync::Arc;
483
483
/// use kernel::workqueue::{self, impl_has_work, Work};
484
484
///
485
- /// struct MyStruct {
486
- /// work_field: Work<MyStruct, 17>,
485
+ /// struct MyStruct<'a, T, const N: usize> {
486
+ /// work_field: Work<MyStruct<'a, T, N>, 17>,
487
+ /// f: fn(&'a [T; N]),
487
488
/// }
488
489
///
489
490
/// impl_has_work! {
490
- /// impl HasWork<MyStruct, 17> for MyStruct { self.work_field }
491
+ /// impl{'a, T, const N: usize} HasWork<MyStruct<'a, T, N>, 17>
492
+ /// for MyStruct<'a, T, N> { self.work_field }
491
493
/// }
492
494
/// ```
493
495
#[ macro_export]
494
496
macro_rules! impl_has_work {
495
- ( $( impl $( < $( $implarg : ident ) , * > ) ?
497
+ ( $( impl $( { $( $generics : tt ) * } ) ?
496
498
HasWork <$work_type: ty $( , $id: tt) ?>
497
- for $self: ident $ ( <$ ( $selfarg : ident ) , * > ) ?
499
+ for $self: ty
498
500
{ self . $field: ident }
499
501
) * ) => { $(
500
502
// SAFETY: The implementation of `raw_get_work` only compiles if the field has the right
501
503
// type.
502
- unsafe impl $( <$( $implarg ) , * >) ? $crate:: workqueue:: HasWork <$work_type $( , $id) ?> for $self $ ( <$ ( $selfarg ) , * > ) ? {
504
+ unsafe impl $( <$( $generics ) + >) ? $crate:: workqueue:: HasWork <$work_type $( , $id) ?> for $self {
503
505
const OFFSET : usize = :: core:: mem:: offset_of!( Self , $field) as usize ;
504
506
505
507
#[ inline]
@@ -515,7 +517,7 @@ macro_rules! impl_has_work {
515
517
pub use impl_has_work;
516
518
517
519
impl_has_work ! {
518
- impl < T > HasWork <Self > for ClosureWork <T > { self . work }
520
+ impl { T } HasWork <Self > for ClosureWork <T > { self . work }
519
521
}
520
522
521
523
unsafe impl < T , const ID : u64 > WorkItemPointer < ID > for Arc < T >
0 commit comments