gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: make sure mono time uses at


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: make sure mono time uses atomics
Date: Thu, 13 Dec 2018 17:58:44 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 63462a4dd make sure mono time uses atomics
63462a4dd is described below

commit 63462a4dddd238e439360e2e70ecaa9366066fc5
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Dec 13 17:58:39 2018 +0100

    make sure mono time uses atomics
---
 configure.ac    |  2 +-
 po/POTFILES.in  |  3 +++
 src/util/time.c | 39 ++++++++++++++++++++++++++++++++++++---
 3 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 35b2ef659..5d570ddad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -992,7 +992,7 @@ AC_CHECK_HEADERS([fcntl.h math.h errno.h ctype.h limits.h 
stdio.h stdlib.h strin
 
 
 # Checks for headers that are only required on some systems or opional (and 
where we do NOT abort if they are not there)
-AC_CHECK_HEADERS([malloc.h malloc/malloc.h malloc/malloc_np.h langinfo.h 
sys/param.h sys/mount.h sys/statvfs.h sys/select.h sockLib.h sys/mman.h 
sys/msg.h sys/vfs.h arpa/inet.h fcntl.h libintl.h netdb.h netinet/in.h 
sys/ioctl.h sys/socket.h sys/time.h unistd.h kstat.h sys/sysinfo.h kvm.h 
sys/file.h sys/resource.h ifaddrs.h mach/mach.h stddef.h sys/timeb.h terminos.h 
argz.h ucred.h sys/ucred.h endian.h sys/endian.h execinfo.h byteswap.h])
+AC_CHECK_HEADERS([stdatomic.h malloc.h malloc/malloc.h malloc/malloc_np.h 
langinfo.h sys/param.h sys/mount.h sys/statvfs.h sys/select.h sockLib.h 
sys/mman.h sys/msg.h sys/vfs.h arpa/inet.h fcntl.h libintl.h netdb.h 
netinet/in.h sys/ioctl.h sys/socket.h sys/time.h unistd.h kstat.h sys/sysinfo.h 
kvm.h sys/file.h sys/resource.h ifaddrs.h mach/mach.h stddef.h sys/timeb.h 
terminos.h argz.h ucred.h sys/ucred.h endian.h sys/endian.h execinfo.h 
byteswap.h])
 
 # FreeBSD requires something more funky for netinet/in_systm.h and 
netinet/ip.h...
 AC_CHECK_HEADERS([sys/types.h netinet/in_systm.h netinet/in.h netinet/ip.h],,,
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 57160115c..1cc880b2e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,12 +14,15 @@ src/ats/gnunet-ats-solver-eval.c
 src/ats/gnunet-service-ats_addresses.c
 src/ats/gnunet-service-ats.c
 src/ats/gnunet-service-ats_connectivity.c
+src/ats/gnunet-service-ats-new.c
 src/ats/gnunet-service-ats_normalization.c
 src/ats/gnunet-service-ats_performance.c
 src/ats/gnunet-service-ats_plugins.c
 src/ats/gnunet-service-ats_preferences.c
 src/ats/gnunet-service-ats_reservations.c
 src/ats/gnunet-service-ats_scheduling.c
+src/ats/plugin_ats2_common.c
+src/ats/plugin_ats2_simple.c
 src/ats/plugin_ats_mlp.c
 src/ats/plugin_ats_proportional.c
 src/ats/plugin_ats_ril.c
diff --git a/src/util/time.c b/src/util/time.c
index 46d3a2b65..741ca1ad2 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -23,6 +23,14 @@
  */
 #include "platform.h"
 #include "gnunet_util_lib.h"
+#if __STDC_NO_ATOMICS__
+#else
+#ifdef HAVE_STDATOMIC_H
+#include <stdatomic.h>
+#else
+#define __STDC_NO_ATOMICS__ 1
+#endif
+#endif
 
 #define LOG(kind,...) GNUNET_log_from (kind, "util-time", __VA_ARGS__)
 
@@ -780,7 +788,7 @@ GNUNET_TIME_absolute_get_monotonic (const struct 
GNUNET_CONFIGURATION_Handle *cf
   static const struct GNUNET_CONFIGURATION_Handle *last_cfg;
   static struct GNUNET_TIME_Absolute last_time;
   static struct GNUNET_DISK_MapHandle *map_handle;
-  static struct GNUNET_TIME_AbsoluteNBO *map;
+  static uint64_t *map;
   struct GNUNET_TIME_Absolute now;
 
   now = GNUNET_TIME_absolute_get ();
@@ -859,13 +867,38 @@ GNUNET_TIME_absolute_get_monotonic (const struct 
GNUNET_CONFIGURATION_Handle *cf
     }
   }
   if (NULL != map)
-    last_time = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_ntoh (*map),
+  {
+    struct GNUNET_TIME_AbsoluteNBO mt;
+
+#if __STDC_NO_ATOMICS__
+#if __GNUC__
+    mt.abs_value_us__ = __sync_fetch_and_or (map, 0);
+#else
+    mt.abs_value_us__ = *map; /* godspeed, pray this is atomic */
+#endif
+#else
+    mt.abs_value_us__ = atomic_load (map);
+#endif
+    last_time = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_ntoh (mt),
                                          last_time);
+  }
   if (now.abs_value_us <= last_time.abs_value_us)
     now.abs_value_us = last_time.abs_value_us+1;
   last_time = now;
   if (NULL != map)
-    *map = GNUNET_TIME_absolute_hton (now);
+  {
+    uint64_t val = GNUNET_TIME_absolute_hton (now).abs_value_us__;
+#if __STDC_NO_ATOMICS__
+#if __GNUC__
+    (void) __sync_lock_test_and_set (map, val);
+#else
+    *map = val;  /* godspeed, pray this is atomic */
+#endif
+#else
+    atomic_store (map,
+                 val);
+#endif                              
+  }
   return now;
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]