Define MAP_ANONYMOUS if not defined

This commit is contained in:
Ryan Schmidt
2023-07-30 23:27:32 -05:00
parent c9c0fd5185
commit d74896699f
5 changed files with 16 additions and 10 deletions

View File

@@ -57,14 +57,9 @@
#include "absl/base/internal/raw_logging.h"
#include "absl/base/internal/spinlock.h"
// MAP_ANONYMOUS
#if defined(__APPLE__) || defined(__hexagon__)
// For mmap, Linux defines both MAP_ANONYMOUS and MAP_ANON and says MAP_ANON is
// deprecated. In Darwin, MAP_ANON is all there is.
#if !defined MAP_ANONYMOUS
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif // !MAP_ANONYMOUS
#endif // __APPLE__
#endif
namespace absl {
ABSL_NAMESPACE_BEGIN

View File

@@ -31,6 +31,9 @@
#ifdef ABSL_HAVE_MMAP
#include <sys/mman.h>
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
#endif
#ifdef __linux__
@@ -157,9 +160,6 @@ static bool SetupAlternateStackOnce() {
#ifdef ABSL_HAVE_MMAP
#ifndef MAP_STACK
#define MAP_STACK 0
#endif
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
sigstk.ss_sp = mmap(nullptr, sigstk.ss_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);

View File

@@ -24,6 +24,9 @@
#ifdef ABSL_HAVE_MMAP
#include <sys/mman.h>
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
#endif
#if defined(__linux__) || defined(__APPLE__)

View File

@@ -26,6 +26,10 @@
#include "absl/base/attributes.h"
#include "absl/base/internal/raw_logging.h"
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace debugging_internal {

View File

@@ -40,6 +40,10 @@
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif
using testing::Contains;
#ifdef _WIN32