WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "platform.h"
#include "gnunet_util_lib.h"
#if __STDC_NO_ATOMICS__
+#define ATOMIC
#else
#ifdef HAVE_STDATOMIC_H
#include <stdatomic.h>
+#define ATOMIC _Atomic
#else
#define __STDC_NO_ATOMICS__ 1
+#define ATOMIC
#endif
#endif
* increasing. Guards against systems without an RTC or
* clocks running backwards and other nasty surprises. Does
* not guarantee that the returned time is near the current
- * time returned by #GNUNET_TIME_absolute_get(). Two
+ * time returned by #GNUNET_TIME_absolute_get(). Two
* subsequent calls (within a short time period) may return the
* same value. Persists the last returned time on disk to
* ensure that time never goes backwards. As a result, the
- * resulting value can be used to check if a message is the
+ * resulting value can be used to check if a message is the
* "most recent" value and replays of older messages (from
* the same origin) would be discarded.
- *
- * @param cfg configuration, used to determine where to
+ *
+ * @param cfg configuration, used to determine where to
* store the time; user can also insist RTC is working
* nicely and disable the feature
* @return monotonically increasing time
static const struct GNUNET_CONFIGURATION_Handle *last_cfg;
static struct GNUNET_TIME_Absolute last_time;
static struct GNUNET_DISK_MapHandle *map_handle;
- static uint64_t *map;
+ static ATOMIC volatile uint64_t *map;
struct GNUNET_TIME_Absolute now;
now = GNUNET_TIME_absolute_get ();
map_handle = NULL;
}
map = NULL;
-
+
last_cfg = cfg;
if ( (NULL != cfg) &&
(GNUNET_OK ==
filename);
}
else
- {
+ {
off_t size;
size = 0;
#else
atomic_store (map,
val);
-#endif
+#endif
}
return now;
}