folly/folly/portability/SysMembarrier.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * 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.
 */

#include <folly/portability/SysMembarrier.h>

#include <cassert>
#include <cerrno>

#include <folly/Portability.h>
#include <folly/portability/SysSyscall.h>

namespace folly {
namespace detail {

namespace {

constexpr long linux_syscall_nr_(long nr, long def) {}

//  __NR_membarrier or -1; always defined as v.s. __NR_membarrier
#if defined(__NR_membarrier)
constexpr long linux_syscall_nr_membarrier_ = __NR_membarrier;
#else
constexpr long linux_syscall_nr_membarrier_ =;
#endif

#if defined(__aarch64__)
constexpr long def_linux_syscall_nr_membarrier_ =;
#elif defined(__x86_64__) || defined(_M_X64)
constexpr long def_linux_syscall_nr_membarrier_ = 324;
#else
constexpr long def_linux_syscall_nr_membarrier_ = -1;
#endif

//  __NR_membarrier with hardcoded fallback where available or -1
constexpr long linux_syscall_nr_membarrier =;

//  linux_membarrier_cmd
//
//  Backport from the linux header, since older versions of the header may
//  define the enum but not all of the enum constants that we require.
//
//  mimic: membarrier_cmd, linux/membarrier.h
enum linux_membarrier_cmd {};

FOLLY_ERASE int call_membarrier(int cmd, unsigned int flags = 0) {}

} // namespace

bool sysMembarrierPrivateExpeditedAvailable() {}

int sysMembarrierPrivateExpedited() {}

} // namespace detail
} // namespace folly