Commit 9d4e8129 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot 3

Add an Atomic portability header

Summary: Because there are situations where we need to do an atomic write to a plain pointer, rather than an atomic value. Unfortunately, there is no support in the standard library for this, so different compilers implement the primitives differently. This specifically implements an `int64_t` overload for `__sync_fetch_and_add` for use in the atomic hash map test.

Reviewed By: yfeldblum

Differential Revision: D3571830

fbshipit-source-id: c27d8d2a5238bbc9aba6a9e48e4b3412a199288f
parent 4592f5e8
......@@ -252,6 +252,7 @@ nobase_follyinclude_HEADERS = \
PicoSpinLock.h \
Portability.h \
portability/Asm.h \
portability/Atomic.h \
portability/Builtins.h \
portability/Config.h \
portability/Constexpr.h \
......
/*
* Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#ifdef _WIN32
#include <stdint.h>
#include <folly/Portability.h>
// The intrinsics we need are in Windows.h :(
#include <folly/portability/Windows.h>
FOLLY_ALWAYS_INLINE int64_t __sync_fetch_and_add(int64_t* ptr, int64_t value) {
return InterlockedExchangeAdd64(ptr, value);
}
#endif
......@@ -23,6 +23,7 @@
#include <memory>
#include <folly/Benchmark.h>
#include <folly/Conv.h>
#include <folly/portability/Atomic.h>
#include <folly/portability/SysTime.h>
using std::vector;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment