Skip to main content

portability.h File

Library portability helper definitions. More...

Included Headers

#include <cstdint> #include <sys/types.h>

Classes Index

classp1_ostream

Typedefs Index

typedefssize_t p1_ssize_t

Operators Index

template <class T>
p1_ostream &operator<< (p1_ostream &stream, const T &)

Macro Definitions Index

#defineP1_ALIGNAS(N)   alignas(N)
#defineP1_CONSTEXPR_FUNC   inline
#defineP1_EXPORT
#defineP1_HAVE_MULTILINE_CONSTEXPR_FUNC   (__cplusplus >= 201402L)
#defineP1_HAVE_STD_FUNCTION   1
#defineP1_HAVE_STD_OSTREAM   1
#defineP1_HAVE_STD_SMART_PTR   1
#defineP1_HIDDEN

Description

Library portability helper definitions.

Typedefs

p1_ssize_t

typedef ssize_t p1_ssize_t

Definition at line 67 of file portability.h.

67typedef ssize_t p1_ssize_t;

Operators

operator<<()

template <class T>
p1_ostream & operator<< (p1_ostream & stream, const T &)
inline

Definition at line 82 of file portability.h.

82inline p1_ostream& operator<<(p1_ostream& stream, const T&) {
83 return stream;
84}

Macro Definitions

P1_ALIGNAS

#define P1_ALIGNAS(N)   alignas(N)

Definition at line 57 of file portability.h.

57# define P1_ALIGNAS(N) alignas(N)

P1_CONSTEXPR_FUNC

#define P1_CONSTEXPR_FUNC   inline

Definition at line 105 of file portability.h.

105# define P1_CONSTEXPR_FUNC inline

P1_EXPORT

#define P1_EXPORT

Definition at line 33 of file portability.h.

33# define P1_EXPORT

P1_HAVE_MULTILINE_CONSTEXPR_FUNC

#define P1_HAVE_MULTILINE_CONSTEXPR_FUNC   (__cplusplus >= 201402L)

Definition at line 98 of file portability.h.

98# define P1_HAVE_MULTILINE_CONSTEXPR_FUNC (__cplusplus >= 201402L)

P1_HAVE_STD_FUNCTION

#define P1_HAVE_STD_FUNCTION   1

Definition at line 88 of file portability.h.

88# define P1_HAVE_STD_FUNCTION 1

P1_HAVE_STD_OSTREAM

#define P1_HAVE_STD_OSTREAM   1

Definition at line 71 of file portability.h.

71# define P1_HAVE_STD_OSTREAM 1

P1_HAVE_STD_SMART_PTR

#define P1_HAVE_STD_SMART_PTR   1

Definition at line 92 of file portability.h.

92# define P1_HAVE_STD_SMART_PTR 1

P1_HIDDEN

#define P1_HIDDEN

Definition at line 34 of file portability.h.

34# define P1_HIDDEN

File Listing

The file content with the documentation metadata removed is:

1/**************************************************************************/ /**
2 * @brief Library portability helper definitions.
3 * @file
4 ******************************************************************************/
5
6#pragma once
7
8#include <cstdint>
9
10// References:
11// - https://gcc.gnu.org/wiki/Visibility.
12// - https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/port_def.inc
13#if defined(_WIN32) || defined(_MSC_VER) || defined(__CYGWIN__)
14# ifdef BUILDING_DLL
15# ifdef __GNUC__
16# define P1_EXPORT __attribute__((dllexport))
17# else
18# define P1_EXPORT __declspec(dllexport)
19# endif
20# else
21# ifdef __GNUC__
22# define P1_EXPORT __attribute__((dllimport))
23# else
24# define P1_EXPORT __declspec(dllimport)
25# endif
26# endif
27# define P1_HIDDEN
28#else
29# if __GNUC__ >= 4
30# define P1_EXPORT __attribute__((visibility("default")))
31# define P1_HIDDEN __attribute__((visibility("hidden")))
32# else
33# define P1_EXPORT
34# define P1_HIDDEN
35# endif
36#endif
37
38// Support ARM CC quirks
39#ifdef __CC_ARM
40// The cstdint included with Keil ARM CC does not appear to include stdint.h
41// or to define most of the stdint types (uint8_t, etc.), even though it should.
42# include <stdint.h>
43// Fixes bug in macro used Keil's math.h header where they define NAN (see
44// http://www.keil.com/forum/60227/).
45# define __ESCAPE__(__x) (__x)
46# define P1_HAVE_STD_FUNCTION 0
47# define P1_HAVE_STD_OSTREAM 0
48# define P1_HAVE_STD_SMART_PTR 0
49# define P1_NO_LOGGING 1
50#endif
51
52// Different compilers support different ways of specifying default struct
53// alignment. Since there's no universal method, a macro is used instead.
54#ifdef __CC_ARM
55# define P1_ALIGNAS(N) __attribute__((aligned(N)))
56#else
57# define P1_ALIGNAS(N) alignas(N)
58#endif
59
60// ssize_t is a POSIX extension and is not supported on Windows/ARM CC.
61#if defined(_WIN32) || defined(__CC_ARM)
62typedef int32_t p1_ssize_t;
63#elif defined(_MSC_VER)
64typedef int64_t p1_ssize_t;
65#else
66# include <sys/types.h> // For ssize_t
67typedef ssize_t p1_ssize_t;
68#endif
69
70#ifndef P1_HAVE_STD_OSTREAM
71# define P1_HAVE_STD_OSTREAM 1
72#endif
73#if P1_HAVE_STD_OSTREAM
74# include <ostream>
75using p1_ostream = std::ostream;
76#else
77class p1_ostream {
78 public:
79 p1_ostream() = default;
80};
81template <class T>
82inline p1_ostream& operator<<(p1_ostream& stream, const T&) {
83 return stream;
84}
85#endif
86
87#ifndef P1_HAVE_STD_FUNCTION
88# define P1_HAVE_STD_FUNCTION 1
89#endif
90
91#ifndef P1_HAVE_STD_SMART_PTR
92# define P1_HAVE_STD_SMART_PTR 1
93#endif
94
95// Support for multi-statement constexpr functions was not added until C++14.
96// When compiling with C++11, we'll simply use inline instead.
97#ifndef P1_HAVE_MULTILINE_CONSTEXPR_FUNC
98# define P1_HAVE_MULTILINE_CONSTEXPR_FUNC (__cplusplus >= 201402L)
99#endif
100
101#ifndef P1_CONSTEXPR_FUNC
102# if P1_HAVE_MULTILINE_CONSTEXPR_FUNC
103# define P1_CONSTEXPR_FUNC constexpr
104# else
105# define P1_CONSTEXPR_FUNC inline
106# endif
107#endif

Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.9.8.