Source-Changes-HG archive

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

[src/trunk]: src/common/lib/libc/atomic make some prototypes match the builti...



details:   https://anonhg.NetBSD.org/src/rev/8ae7d9ac39b5
branches:  trunk
changeset: 938362:8ae7d9ac39b5
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Sep 07 00:52:19 2020 +0000

description:
make some prototypes match the builtin properly.  GCC 9 complains
with the old version, GCC 8 is happy with this version.

tested on sparc.

diffstat:

 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c |  10 +++++-----
 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c |  10 +++++-----
 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c  |  10 +++++-----
 common/lib/libc/atomic/atomic_load.c                        |  10 +++++-----
 common/lib/libc/atomic/atomic_store.c                       |  10 +++++-----
 5 files changed, 25 insertions(+), 25 deletions(-)

diffs (157 lines):

diff -r 38466977c3fe -r 8ae7d9ac39b5 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c
--- a/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c       Mon Sep 07 00:48:45 2020 +0000
+++ b/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_16.c       Mon Sep 07 00:52:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic_c11_compare_exchange_cas_16.c,v 1.2 2014/11/04 19:56:44 joerg Exp $     */
+/*     $NetBSD: atomic_c11_compare_exchange_cas_16.c,v 1.3 2020/09/07 00:52:19 mrg Exp $       */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -36,15 +36,15 @@
 #endif
 #include <sys/atomic.h>
 
-bool __atomic_compare_exchange_2(volatile uint16_t *, uint16_t *, uint16_t,
+bool __atomic_compare_exchange_2(volatile void *, void *, uint16_t,
     bool, int, int);
 
 bool
-__atomic_compare_exchange_2(volatile uint16_t *mem,
-    uint16_t *expected, uint16_t desired,
+__atomic_compare_exchange_2(volatile void *mem,
+    void *expected, uint16_t desired,
     bool weak, int success, int failure)
 {
-       uint16_t old = *expected;
+       uint16_t old = *(uint16_t *)expected;
 
        /*
         * Ignore the details (weak, memory model on success and failure)
diff -r 38466977c3fe -r 8ae7d9ac39b5 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c
--- a/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c       Mon Sep 07 00:48:45 2020 +0000
+++ b/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_32.c       Mon Sep 07 00:52:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic_c11_compare_exchange_cas_32.c,v 1.2 2014/11/04 19:56:44 joerg Exp $     */
+/*     $NetBSD: atomic_c11_compare_exchange_cas_32.c,v 1.3 2020/09/07 00:52:19 mrg Exp $       */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -36,15 +36,15 @@
 #endif
 #include <sys/atomic.h>
 
-bool __atomic_compare_exchange_4(volatile uint32_t *, uint32_t *, uint32_t,
+bool __atomic_compare_exchange_4(volatile void *, void *, uint32_t,
     bool, int, int);
 
 bool
-__atomic_compare_exchange_4(volatile uint32_t *mem,
-    uint32_t *expected, uint32_t desired,
+__atomic_compare_exchange_4(volatile void *mem,
+    void *expected, uint32_t desired,
     bool weak, int success, int failure)
 {
-       uint32_t old = *expected;
+       uint32_t old = *(uint32_t *)expected;
 
        /*
         * Ignore the details (weak, memory model on success and failure)
diff -r 38466977c3fe -r 8ae7d9ac39b5 common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c
--- a/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c        Mon Sep 07 00:48:45 2020 +0000
+++ b/common/lib/libc/atomic/atomic_c11_compare_exchange_cas_8.c        Mon Sep 07 00:52:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic_c11_compare_exchange_cas_8.c,v 1.2 2014/11/04 19:56:44 joerg Exp $      */
+/*     $NetBSD: atomic_c11_compare_exchange_cas_8.c,v 1.3 2020/09/07 00:52:19 mrg Exp $        */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -36,15 +36,15 @@
 #endif
 #include <sys/atomic.h>
 
-bool __atomic_compare_exchange_1(volatile uint8_t *, uint8_t *, uint8_t,
+bool __atomic_compare_exchange_1(volatile void *, void *, uint8_t,
     bool, int, int);
 
 bool
-__atomic_compare_exchange_1(volatile uint8_t *mem,
-    uint8_t *expected, uint8_t desired,
+__atomic_compare_exchange_1(volatile void *mem,
+    void *expected, uint8_t desired,
     bool weak, int success, int failure)
 {
-       uint8_t old = *expected;
+       uint8_t old = *(uint8_t *)expected;
 
        /*
         * Ignore the details (weak, memory model on success and failure)
diff -r 38466977c3fe -r 8ae7d9ac39b5 common/lib/libc/atomic/atomic_load.c
--- a/common/lib/libc/atomic/atomic_load.c      Mon Sep 07 00:48:45 2020 +0000
+++ b/common/lib/libc/atomic/atomic_load.c      Mon Sep 07 00:52:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic_load.c,v 1.2 2014/07/06 01:19:45 joerg Exp $    */
+/*     $NetBSD: atomic_load.c,v 1.3 2020/09/07 00:52:19 mrg Exp $      */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: atomic_load.c,v 1.2 2014/07/06 01:19:45 joerg Exp $");
+__RCSID("$NetBSD: atomic_load.c,v 1.3 2020/09/07 00:52:19 mrg Exp $");
 
 #include "atomic_op_namespace.h"
 
@@ -35,13 +35,13 @@
 #include <sys/atomic.h>
 
 #define atomic_load_n(n,b) \
-uint ## b ## _t __atomic_load_ ## n(volatile uint ## b ## _t *, int); \
+uint ## b ## _t __atomic_load_ ## n(const volatile void *, int); \
 uint ## b ## _t \
-__atomic_load_ ## n(volatile uint ## b ## _t *ptr, int memmodel) \
+__atomic_load_ ## n(const volatile void *ptr, int memmodel) \
 { \
        uint## b ##_t val; \
        membar_enter(); \
-       val = *ptr; \
+       val = *(const volatile uint ## b ## _t *)ptr; \
        membar_exit(); \
        return val; \
 }
diff -r 38466977c3fe -r 8ae7d9ac39b5 common/lib/libc/atomic/atomic_store.c
--- a/common/lib/libc/atomic/atomic_store.c     Mon Sep 07 00:48:45 2020 +0000
+++ b/common/lib/libc/atomic/atomic_store.c     Mon Sep 07 00:52:19 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atomic_store.c,v 1.2 2014/07/06 01:19:45 joerg Exp $   */
+/*     $NetBSD: atomic_store.c,v 1.3 2020/09/07 00:52:19 mrg Exp $     */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: atomic_store.c,v 1.2 2014/07/06 01:19:45 joerg Exp $");
+__RCSID("$NetBSD: atomic_store.c,v 1.3 2020/09/07 00:52:19 mrg Exp $");
 
 #include "atomic_op_namespace.h"
 
@@ -35,13 +35,13 @@
 #include <sys/atomic.h>
 
 #define atomic_store_n(n,b) \
-void __atomic_store_ ## n(volatile uint ## b ## _t *, uint ## b ## _t, int); \
+void __atomic_store_ ## n(volatile void *, uint ## b ## _t, int); \
 void \
-__atomic_store_ ## n(volatile uint ## b ## _t *ptr, uint ## b ## _t val, \
+__atomic_store_ ## n(volatile void *ptr, uint ## b ## _t val, \
                      int memmodel) \
 { \
        membar_enter(); \
-       *ptr = val; \
+       *(volatile uint ## b ## _t *)ptr = val; \
        membar_exit(); \
 }
 



Home | Main Index | Thread Index | Old Index