# 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],,,
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
*/
#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__)
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 ();
}
}
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;
}