summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjca <jca@openbsd.org>2020-04-12 17:47:25 +0000
committerjca <jca@openbsd.org>2020-04-12 17:47:25 +0000
commit7b4d0a09cadba65d5bf063cfa55261bee856fd6d (patch)
treef9199544aba8906c38d1c56eb0cba78a8f255a1f
parentIn sosplice(), temporarily release the socket lock before calling (diff)
downloadwireguard-openbsd-7b4d0a09cadba65d5bf063cfa55261bee856fd6d.tar.xz
wireguard-openbsd-7b4d0a09cadba65d5bf063cfa55261bee856fd6d.zip
Turn those spinlock and seqlock inline functions to macros
They're macros on Linux because they save state in their flags parameter. Turning them to static inline functions creates a lot of -Wuninitialized warnings, so just use macros which set their flags argument. ok kettenis@
-rw-r--r--sys/dev/pci/drm/include/linux/seqlock.h12
-rw-r--r--sys/dev/pci/drm/include/linux/spinlock.h31
2 files changed, 25 insertions, 18 deletions
diff --git a/sys/dev/pci/drm/include/linux/seqlock.h b/sys/dev/pci/drm/include/linux/seqlock.h
index 7e3ba8dc136..63490a20d93 100644
--- a/sys/dev/pci/drm/include/linux/seqlock.h
+++ b/sys/dev/pci/drm/include/linux/seqlock.h
@@ -99,12 +99,16 @@ write_seqlock(seqlock_t *sl)
}
static inline void
-write_seqlock_irqsave(seqlock_t *sl, __unused long flags)
+__write_seqlock_irqsave(seqlock_t *sl)
{
mtx_enter(&sl->lock);
sl->seq++;
membar_producer();
}
+#define write_seqlock_irqsave(_sl, _flags) do { \
+ _flags = 0; \
+ __write_seqlock_irqsave(_sl); \
+ } while (0)
static inline void
write_sequnlock(seqlock_t *sl)
@@ -115,12 +119,16 @@ write_sequnlock(seqlock_t *sl)
}
static inline void
-write_sequnlock_irqrestore(seqlock_t *sl, __unused long flags)
+__write_sequnlock_irqrestore(seqlock_t *sl)
{
membar_producer();
sl->seq++;
mtx_leave(&sl->lock);
}
+#define write_sequnlock_irqrestore(_sl, _flags) do { \
+ (void)(_flags); \
+ __write_sequnlock_irqrestore(_sl); \
+ } while (0)
static inline unsigned int
read_seqbegin(seqlock_t *sl)
diff --git a/sys/dev/pci/drm/include/linux/spinlock.h b/sys/dev/pci/drm/include/linux/spinlock.h
index 14dc60ebfe2..e40d2872d00 100644
--- a/sys/dev/pci/drm/include/linux/spinlock.h
+++ b/sys/dev/pci/drm/include/linux/spinlock.h
@@ -8,22 +8,21 @@
#include <linux/preempt.h>
#include <linux/bottom_half.h>
-static inline void
-spin_lock_irqsave(struct mutex *mtxp, __unused unsigned long flags)
-{
- mtx_enter(mtxp);
-}
-static inline void
-spin_lock_irqsave_nested(struct mutex *mtxp, __unused unsigned long flags,
- __unused int subclass)
-{
- mtx_enter(mtxp);
-}
-static inline void
-spin_unlock_irqrestore(struct mutex *mtxp, __unused unsigned long flags)
-{
- mtx_leave(mtxp);
-}
+#define spin_lock_irqsave(_mtxp, _flags) do { \
+ _flags = 0; \
+ mtx_enter(_mtxp); \
+ } while (0)
+
+#define spin_lock_irqsave_nested(_mtxp, _flags, _subclass) do { \
+ (void)(_subclass); \
+ _flags = 0; \
+ mtx_enter(_mtxp); \
+ } while (0)
+
+#define spin_unlock_irqrestore(_mtxp, _flags) do { \
+ (void)(_flags); \
+ mtx_leave(_mtxp); \
+ } while (0)
#define spin_lock(mtxp) mtx_enter(mtxp)
#define spin_lock_nested(mtxp, l) mtx_enter(mtxp)