Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Remove strange padding #define and replace with anon...



details:   https://anonhg.NetBSD.org/src/rev/791e8f503ebd
branches:  trunk
changeset: 953931:791e8f503ebd
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Mar 25 08:18:03 2021 +0000

description:
Remove strange padding #define and replace with anonymous struct/union

diffstat:

 sys/net/pktqueue.c |  20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diffs (47 lines):

diff -r e68bc70dd7cf -r 791e8f503ebd sys/net/pktqueue.c
--- a/sys/net/pktqueue.c        Thu Mar 25 07:31:56 2021 +0000
+++ b/sys/net/pktqueue.c        Thu Mar 25 08:18:03 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pktqueue.c,v 1.12 2020/09/11 14:29:00 riastradh Exp $  */
+/*     $NetBSD: pktqueue.c,v 1.13 2021/03/25 08:18:03 skrll Exp $      */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v 1.12 2020/09/11 14:29:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pktqueue.c,v 1.13 2021/03/25 08:18:03 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -52,21 +52,19 @@
 
 #include <net/pktqueue.h>
 
-/*
- * WARNING: update this if struct pktqueue changes.
- */
-#define        PKTQ_CLPAD      \
-    MAX(COHERENCY_UNIT, COHERENCY_UNIT - sizeof(kmutex_t) - sizeof(u_int))
-
 struct pktqueue {
        /*
         * The lock used for a barrier mechanism.  The barrier counter,
         * as well as the drop counter, are managed atomically though.
         * Ensure this group is in a separate cache line.
         */
-       kmutex_t        pq_lock;
-       volatile u_int  pq_barrier;
-       uint8_t         _pad[PKTQ_CLPAD];
+       union {
+               struct {
+                       kmutex_t        pq_lock;
+                       volatile u_int  pq_barrier;
+               };
+               uint8_t  _pad[COHERENCY_UNIT];
+       };
 
        /* The size of the queue, counters and the interrupt handler. */
        u_int           pq_maxlen;



Home | Main Index | Thread Index | Old Index