]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
lib/uklock: Add static initializer for uk_rwlock
authorAndrei Tatar <andrei@unikraft.io>
Mon, 2 Oct 2023 19:07:40 +0000 (21:07 +0200)
committerSimon Kuenzer <simon@unikraft.io>
Tue, 28 Nov 2023 21:26:49 +0000 (22:26 +0100)
Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
GitHub-Closes: #1126

lib/uklock/include/uk/rwlock.h

index 0ceee2645de9e8534d4bcf596989a43ff8e15fe1..140ed7689bc8e54c2c086b2e8d269e58e49e8eb4 100644 (file)
@@ -54,6 +54,17 @@ void uk_rwlock_init_config(struct uk_rwlock *rwl, unsigned int config_flags);
 
 #define uk_rwlock_init(rwl) uk_rwlock_init_config(rwl, 0)
 
+#define UK_RWLOCK_INITIALIZER(name, flags) \
+       ((struct uk_rwlock){ \
+               .nactive = 0, \
+               .npending_reads = 0, \
+               .npending_writes = 0, \
+               .config_flags = flags, \
+               .sl = UK_SPINLOCK_INITIALIZER(), \
+               .shared = UK_WAIT_QUEUE_INITIALIZER((name).shared), \
+               .exclusive = UK_WAIT_QUEUE_INITIALIZER((name).exclusive), \
+       })
+
 /**
  * Acquire the reader-writer lock for reading. Multiple readers can
  * acquire the lock at the same time