Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define MAP_ANONYMOUS if not defined #1500

Closed
wants to merge 1 commit into from
Closed

Define MAP_ANONYMOUS if not defined #1500

wants to merge 1 commit into from

Conversation

ryandesign
Copy link
Contributor

Building abseil on OS X 10.10 and earlier fails:

absl/debugging/internal/examine_stack.cc:58:34: error: use of undeclared identifier 'MAP_ANONYMOUS'
                   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
                                 ^
1 error generated.

The fix for this issue is to define MAP_ANONYMOUS to be equal to the older MAP_ANON if it is not already defined.

There are other places in the abseil code where this was already being done (see #120), just not everywhere.

In failure_signal_handler.cc, the fix was embedded in the middle of a function. It seems cleaner to have it near the top of the file, as it is in low_level_alloc.cc, so I added it to the top in the new files and moved it to the top in failure_signal_handler.cc.

In low_level_alloc.cc, the fix was restricted only to Apple platforms, and this had to be expanded to a second platform recently (see be85b34):

// 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
#define MAP_ANONYMOUS MAP_ANON
#endif // !MAP_ANONYMOUS
#endif // __APPLE__

There's no reason to restrict it by platform at all; just define it if it's not defined, on any platform. The comment about MAP_ANONYMOUS not existing on Darwin is also outdated; it does exist in Darwin on OS X 10.11 (released 2015) and later. So I've also removed these comments and restrictions and made this block the same as the others.

Maybe there is some central header where this could be addressed once instead of being copied into each file that uses MAP_ANONYMOUS but I don't know the abseil code well enough to determine that.

Feel free to edit the code or commit message as required for your standards.

@derekmauro derekmauro self-assigned this Aug 1, 2023
@copybara-service copybara-service bot closed this in 5b3b0ed Aug 1, 2023
@ryandesign ryandesign deleted the MAP_ANONYMOUS branch August 1, 2023 22:51
razmser pushed a commit to razmser/abseil-cpp that referenced this pull request Aug 31, 2023
Included are additional automated edits by clang-format on import.

Merge d748966 into 22091f4

Merging this change closes abseil#1500

COPYBARA_INTEGRATE_REVIEW=abseil#1500 from ryandesign:MAP_ANONYMOUS d748966
PiperOrigin-RevId: 552922776
Change-Id: I96a0395cb5e7156d7c7a889491c5d0b4cf755819
razmser pushed a commit to razmser/abseil-cpp that referenced this pull request Sep 12, 2023
Included are additional automated edits by clang-format on import.

Merge d748966 into 22091f4

Merging this change closes abseil#1500

COPYBARA_INTEGRATE_REVIEW=abseil#1500 from ryandesign:MAP_ANONYMOUS d748966
PiperOrigin-RevId: 552922776
Change-Id: I96a0395cb5e7156d7c7a889491c5d0b4cf755819
razmser pushed a commit to razmser/abseil-cpp that referenced this pull request Sep 12, 2023
Included are additional automated edits by clang-format on import.

Merge d748966 into 22091f4

Merging this change closes abseil#1500

COPYBARA_INTEGRATE_REVIEW=abseil#1500 from ryandesign:MAP_ANONYMOUS d748966
PiperOrigin-RevId: 552922776
Change-Id: I96a0395cb5e7156d7c7a889491c5d0b4cf755819
razmser pushed a commit to razmser/abseil-cpp that referenced this pull request Sep 14, 2023
Included are additional automated edits by clang-format on import.

Merge d748966 into 22091f4

Merging this change closes abseil#1500

COPYBARA_INTEGRATE_REVIEW=abseil#1500 from ryandesign:MAP_ANONYMOUS d748966
PiperOrigin-RevId: 552922776
Change-Id: I96a0395cb5e7156d7c7a889491c5d0b4cf755819
netkex pushed a commit to netkex/abseil-cpp that referenced this pull request Apr 3, 2024
Included are additional automated edits by clang-format on import.

Merge d748966 into 22091f4

Merging this change closes abseil#1500

COPYBARA_INTEGRATE_REVIEW=abseil#1500 from ryandesign:MAP_ANONYMOUS d748966
PiperOrigin-RevId: 552922776
Change-Id: I96a0395cb5e7156d7c7a889491c5d0b4cf755819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants