projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
folly: fix sysMembarrier() with newer kernel headers
[folly.git]
/
folly
/
portability
/
SysMembarrier.cpp
diff --git
a/folly/portability/SysMembarrier.cpp
b/folly/portability/SysMembarrier.cpp
index cc4b43ac827279dbf7f30a389c8f5c08b33ed5ff..9b3735c965603e8cbfa985aa7f4566522191b820 100644
(file)
--- a/
folly/portability/SysMembarrier.cpp
+++ b/
folly/portability/SysMembarrier.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
6
Facebook, Inc.
+ * Copyright 201
7
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-22,12
+22,18
@@
#include <folly/portability/SysSyscall.h>
#include <folly/portability/Unistd.h>
#include <folly/portability/SysSyscall.h>
#include <folly/portability/Unistd.h>
-#if !defined(__NR_membarrier) && FOLLY_X64 && !FOLLY_MOBILE && \
- defined(__linux__)
+#if FOLLY_X64 && !FOLLY_MOBILE && defined(__linux__)
+#define FOLLY_USE_SYS_MEMBARRIER 1
+#if !defined(__NR_membarrier)
#define __NR_membarrier 324
#define __NR_membarrier 324
+#endif
+#if FOLLY_HAVE_LINUX_MEMBARRIER_H
+#include <linux/membarrier.h> // @manual
+#else
#define MEMBARRIER_CMD_QUERY 0
#define MEMBARRIER_CMD_SHARED 1
#endif
#define MEMBARRIER_CMD_QUERY 0
#define MEMBARRIER_CMD_SHARED 1
#endif
+#endif
namespace folly {
namespace detail {
namespace folly {
namespace detail {
@@
-37,7
+43,7
@@
bool sysMembarrierAvailable() {
return false;
}
return false;
}
-#if
def __NR_membarrier
+#if
FOLLY_USE_SYS_MEMBARRIER
auto r = syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, /* flags = */ 0);
if (r == -1) {
return false;
auto r = syscall(__NR_membarrier, MEMBARRIER_CMD_QUERY, /* flags = */ 0);
if (r == -1) {
return false;
@@
-50,11
+56,11
@@
bool sysMembarrierAvailable() {
}
int sysMembarrier() {
}
int sysMembarrier() {
-#if
def __NR_membarrier
+#if
FOLLY_USE_SYS_MEMBARRIER
return syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, /* flags = */ 0);
#else
return -1;
#endif
}
return syscall(__NR_membarrier, MEMBARRIER_CMD_SHARED, /* flags = */ 0);
#else
return -1;
#endif
}
-}
-}
+}
// namespace detail
+}
// namespace folly