Page MenuHomePhabricator

[pstl] Add macro guards to PSTL
Needs RevisionPublic

Authored by philnik on May 15 2022, 9:02 AM.

Details

Reviewers
ldionne
Mordante
var-const
Group Reviewers
Restricted Project
Summary

Currently some of the libc++ tests fail because the header isn't guarded against min/max macros.

Diff Detail

Event Timeline

philnik created this revision.May 15 2022, 9:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2022, 9:02 AM
philnik requested review of this revision.May 15 2022, 9:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 15 2022, 9:02 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne requested changes to this revision.May 18 2022, 12:49 PM
ldionne added inline comments.
pstl/include/pstl/internal/algorithm_impl.h
19

Instead, we need to make the PSTL freestanding (in the sense that it should work whether it is used with libc++ or with another stdlib, not in the usual freestanding sense). So I'd do something like this inside pstl_config.h:

#if defined(_PSTL_COMPILER_MSVC)
#   define _PSTL_PUSH_MACROS        \
        __pragma(push_macro("min")) \
        __pragma(push_macro("max"))
#   define _PSTL_POP_MACROS         \
        __pragma(pop_macro("min"))  \
        __pragma(pop_macro("max"))
#else
#   define _PSTL_PUSH_MACROS            \
        _Pragma("push_macro(\"min\")")  \
        _Pragma("push_macro(\"max\")")
#   define _PSTL_POP_MACROS             \
        _Pragma("pop_macro(\"min\")")   \
        _Pragma("pop_macro(\"max\")")
#endif
#define _PSTL_UNDEF_MACROS <__pstl_undef_macros>
This revision now requires changes to proceed.May 18 2022, 12:49 PM
philnik retitled this revision from [pstl][libc++] Add macro guards to PSTL and enable them for libc++ to [pstl] Add macro guards to PSTL.May 20 2022, 7:59 AM