diff --git a/lib/C/GlobalSet.pm b/lib/C/GlobalSet.pm index 341479b..d02093a 100644 --- a/lib/C/GlobalSet.pm +++ b/lib/C/GlobalSet.pm @@ -14,8 +14,13 @@ with 'C::Parse'; has '+set' => (isa => 'ArrayRef[C::Global]'); my %type_alias = ( - DEFINE_SPINLOCK => 'spinlock_t', - DEFINE_MUTEX => 'struct mutex', + DEFINE_SPINLOCK => 'spinlock_t', + DEFINE_MUTEX => 'struct mutex', + DEFINE_SRCU => 'struct srcu_struct', + DEFINE_STATIC_SRCU => { + modifier => 'static', + type => 'struct srcu_struct' + }, DEFINE_RWLOCK => 'rwlock_t', DECLARE_WAIT_QUEUE_HEAD => 'wait_queue_head_t', DECLARE_WORK => 'struct work_struct', @@ -100,7 +105,7 @@ sub parse | (?(?>${simple_type}|${complex_type})\(${s}*+\*${s}*+${name}${array}?${s}*+\)${s}*+${fargs})(*SKIP)${optional_asm}${optional_init} | - (?\b(?:DEFINE_(?:SPINLOCK|RWLOCK|MUTEX)|LIST_HEAD)|DECLARE_WAIT_QUEUE_HEAD)${s}*+\(${s}*+${name}${s}*+\) + (?\b(?:DEFINE_(?:SPINLOCK|RWLOCK|MUTEX|SRCU|STATIC_SRCU)|LIST_HEAD)|DECLARE_WAIT_QUEUE_HEAD)${s}*+\(${s}*+${name}${s}*+\) | (?\bDEFINE_DEBUGFS_ATTRIBUTE)${s}*+\(${s}*+${name}${s}*+,[^)]++\) | diff --git a/t/parse/GlobalSet.t b/t/parse/GlobalSet.t index 05e1127..1eab2ba 100755 --- a/t/parse/GlobalSet.t +++ b/t/parse/GlobalSet.t @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 28; +use Test::More tests => 29; use Test::Deep; use C::GlobalSet; @@ -15,7 +15,9 @@ $g{$_->name} = $_ foreach @{$set->set}; cmp_deeply( [sort keys %g], - [qw(chroot_count cpu_stop current_stack_pointer current_task fs_type read_f socket_update_slock unix_socket_table)], + [ + qw(chroot_count chroot_srcu cpu_stop current_stack_pointer current_task fs_type read_f socket_update_slock unix_socket_table) + ], 'globals' ); @@ -24,8 +26,9 @@ is($g{fs_type}->type, 'struct file_system_type ', 'type test 2'); is($g{socket_update_slock}->type, 'spinlock_t', 'type test 3'); is($g{current_task}->type, 'struct task_struct *', 'type test 4'); is($g{read_f}->type, 'int (*read_f[SYM_NUM]) (struct policydb *p, struct hashtab *h, void *fp)', 'type test 5'); -is($g{current_stack_pointer}->type, 'unsigned long ', 'type test 6'); -is($g{chroot_count}->type, 'atomic_t ', 'type test 7'); +is($g{current_stack_pointer}->type, 'unsigned long ', 'type test 6'); +is($g{chroot_count}->type, 'atomic_t ', 'type test 7'); +is($g{chroot_srcu}->type, 'struct srcu_struct', 'type test 8'); ok($g{unix_socket_table}->extern, 'extern test true 1'); ok($g{current_task}->extern, 'extern test true 2'); @@ -69,8 +72,9 @@ is($g{chroot_count}->initializer, 'ATOMIC_INIT(0)', 'initializer test 5'); cmp_deeply( $set->ids, bag( - ["unix_socket_table"], ["fs_type"], ["socket_update_slock"], ["current_task"], - ["cpu_stop"], ["read_f"], ["current_stack_pointer"], ["chroot_count"] + ["unix_socket_table"], ["fs_type"], ["socket_update_slock"], ["current_task"], + ["cpu_stop"], ["read_f"], ["current_stack_pointer"], ["chroot_count"], + ["chroot_srcu"] ), 'ids' ); @@ -90,7 +94,8 @@ cmp_deeply( "sens_read", "cat_read" ], ["_ASM_SP"], - ["atomic_t", "__read_mostly", "ATOMIC_INIT"] + ["atomic_t", "__read_mostly", "ATOMIC_INIT"], + ["DEFINE_SRCU"] ), 'tags' ); @@ -127,3 +132,5 @@ static int (*read_f[SYM_NUM]) (struct policydb *p, struct hashtab *h, void *fp) register unsigned long current_stack_pointer asm(_ASM_SP); atomic_t chroot_count __read_mostly = ATOMIC_INIT(0); + +DEFINE_SRCU(chroot_srcu);