UCommon
|
Various miscellaneous platform specific headers and defines. More...
#include <cstdlib>
#include <cstddef>
#include <stdexcept>
#include <pthread.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <cctype>
#include <climits>
#include <cerrno>
#include <new>
#include <assert.h>
Go to the source code of this file.
Namespaces | |
namespace | ucommon |
Common namespace for all ucommon objects. | |
Macros | |
#define | __ALIGNED(x) __attribute__(align(x)) |
#define | __DELETE_COPY(x) |
#define | __DELETE_DEFAULTS(x) |
#define | __DELETED |
#define | __EXPORT __attribute__ ((visibility("default"))) |
#define | __FINAL |
#define | __GNUC_PREREQ__(maj, min) 0 |
#define | __LOCAL __attribute__ ((visibility("hidden"))) |
#define | __MALLOC |
#define | __OVERRIDE |
#define | __PRINTF(x, y) |
#define | __PROGRAM(c, v) extern "C" int main(int c, char **v) |
#define | __PROTOCOL virtual |
#define | __SCANF(x, y) |
#define | __SERVICE(id, c, v) void service_##id(int c, char **v) |
#define | __SHARED __attribute__ ((visibility("default"))) |
#define | __THROW_ALLOC() throw std::bad_alloc() |
#define | __THROW_DEREF(v) |
#define | __THROW_RANGE(x) throw std::out_of_range(x) |
#define | __THROW_RUNTIME(x) throw std::runtime_error(x) |
#define | __THROW_SIZE(x) throw std::length_error(x) |
#define | __THROW_UNDEF(v, x) if(v == nullptr) throw std::runtime_error(x) |
#define | __UNUSED(x) (void)x |
#define | _POSIX_PTHREAD_SEMANTICS |
#define | _REENTRANT 1 |
#define | _THREADSAFE 1 |
#define | _UCOMMON_EXTENDED_ |
#define | _UCOMMON_PLATFORM_H_ |
#define | crit(x, text) if(!(x)) cpr_runtime_error(text) |
#define | END_NAMESPACE } |
#define | INVALID_HANDLE_VALUE -1 |
#define | INVALID_SOCKET -1 |
#define | NAMESPACE_UCOMMON namespace ucommon { |
#define | NDEBUG |
#define | PROGRAM_EXIT(code) return code |
#define | PROGRAM_MAIN(argc, argv) extern "C" int main(int argc, char **argv) |
#define | SERVICE_MAIN(id, argc, argv) void service_##id(int argc, char **argv) |
#define | UCOMMON_ABI 7 |
#define | UCOMMON_NAMESPACE ucommon |
#define | UCOMMON_RTTI 1 |
Typedefs | |
typedef void(* | cpr_service_t) (int argc, char **argv) |
typedef int | fd_t |
typedef long | Integer |
typedef double | Real |
typedef void(* | sighandler_t) (int) |
Convenient typedef for signal handlers. | |
typedef int | socket_t |
typedef size_t | socksize_t |
typedef size_t | stacksize_t |
typedef unsigned long | timeout_t |
typedef uint8_t | ubyte_t |
typedef unsigned long | Unsigned |
Functions | |
template<typename T > | |
const T | immutable_cast (T p) |
template<class T > | |
T * | init (T *memory) |
Template function to initialize memory by invoking default constructor. | |
template<class T , class S > | |
T | polyconst_cast (S *s) |
template<class T , class S > | |
T | polydynamic_cast (S *s) |
template<class T , class S > | |
T | polypointer_cast (S *s) |
template<class T , class S > | |
T & | polyreference_cast (S *s) |
template<class T , class S > | |
T | polystatic_cast (S *s) |
template<typename T , typename S > | |
T | protocol_cast (S *s) |
template<typename T > | |
T & | reference_cast (T *pointer) |
void | strfree (char *str) |
Matching function for strdup(). | |
Variables | |
const class nullptr_t | nullptr = {} |
Various miscellaneous platform specific headers and defines.
This is used to support ucommon on different platforms. The ucommon library assumes at least a real posix threading library is present or will build thread support native on Microsoft Windows legacy platform. This header also deals with issues related to common base types.
Definition in file platform.h.
#define __ALIGNED | ( | x | ) | __attribute__(align(x)) |
Definition at line 167 of file platform.h.
#define __DELETE_COPY | ( | x | ) |
Definition at line 175 of file platform.h.
#define __DELETE_DEFAULTS | ( | x | ) |
Definition at line 177 of file platform.h.
#define __DELETED |
Definition at line 174 of file platform.h.
#define __EXPORT __attribute__ ((visibility("default"))) |
Definition at line 312 of file platform.h.
#define __FINAL |
Definition at line 172 of file platform.h.
#define __GNUC_PREREQ__ | ( | maj, | |
min | |||
) | 0 |
Definition at line 148 of file platform.h.
#define __LOCAL __attribute__ ((visibility("hidden"))) |
Definition at line 313 of file platform.h.
#define __MALLOC |
Definition at line 216 of file platform.h.
#define __OVERRIDE |
Definition at line 173 of file platform.h.
#define __PRINTF | ( | x, | |
y | |||
) |
Definition at line 214 of file platform.h.
#define __PROGRAM | ( | c, | |
v | |||
) | extern "C" int main(int c, char **v) |
Definition at line 541 of file platform.h.
#define __PROTOCOL virtual |
Definition at line 127 of file platform.h.
#define __SCANF | ( | x, | |
y | |||
) |
Definition at line 215 of file platform.h.
#define __SERVICE | ( | id, | |
c, | |||
v | |||
) | void service_##id(int c, char **v) |
Definition at line 547 of file platform.h.
#define __SHARED __attribute__ ((visibility("default"))) |
Definition at line 314 of file platform.h.
#define __THROW_ALLOC | ( | ) | throw std::bad_alloc() |
Definition at line 67 of file platform.h.
#define __THROW_DEREF | ( | v | ) |
Definition at line 68 of file platform.h.
#define __THROW_RANGE | ( | x | ) | throw std::out_of_range(x) |
Definition at line 65 of file platform.h.
#define __THROW_RUNTIME | ( | x | ) | throw std::runtime_error(x) |
Definition at line 66 of file platform.h.
#define __THROW_SIZE | ( | x | ) | throw std::length_error(x) |
Definition at line 64 of file platform.h.
#define __THROW_UNDEF | ( | v, | |
x | |||
) | if(v == nullptr) throw std::runtime_error(x) |
Definition at line 70 of file platform.h.
#define __UNUSED | ( | x | ) | (void)x |
Definition at line 159 of file platform.h.
#define _POSIX_PTHREAD_SEMANTICS |
Definition at line 104 of file platform.h.
#define _REENTRANT 1 |
Definition at line 95 of file platform.h.
#define _THREADSAFE 1 |
Definition at line 100 of file platform.h.
#define _UCOMMON_EXTENDED_ |
Definition at line 62 of file platform.h.
#define _UCOMMON_PLATFORM_H_ |
Definition at line 55 of file platform.h.
#define crit | ( | x, | |
text | |||
) | if(!(x)) cpr_runtime_error(text) |
Definition at line 556 of file platform.h.
#define END_NAMESPACE } |
Definition at line 92 of file platform.h.
#define INVALID_HANDLE_VALUE -1 |
Definition at line 432 of file platform.h.
#define INVALID_SOCKET -1 |
Definition at line 431 of file platform.h.
#define NAMESPACE_UCOMMON namespace ucommon { |
Definition at line 91 of file platform.h.
#define NDEBUG |
Definition at line 221 of file platform.h.
#define PROGRAM_EXIT | ( | code | ) | return code |
Definition at line 543 of file platform.h.
#define PROGRAM_MAIN | ( | argc, | |
argv | |||
) | extern "C" int main(int argc, char **argv) |
Definition at line 542 of file platform.h.
#define SERVICE_MAIN | ( | id, | |
argc, | |||
argv | |||
) | void service_##id(int argc, char **argv) |
Definition at line 548 of file platform.h.
#define UCOMMON_ABI 7 |
Definition at line 56 of file platform.h.
#define UCOMMON_NAMESPACE ucommon |
Definition at line 90 of file platform.h.
#define UCOMMON_RTTI 1 |
Definition at line 109 of file platform.h.
typedef void(* cpr_service_t) (int argc, char **argv) |
Definition at line 549 of file platform.h.
typedef int fd_t |
Definition at line 430 of file platform.h.
typedef long Integer |
Definition at line 569 of file platform.h.
typedef double Real |
Definition at line 571 of file platform.h.
typedef void(* sighandler_t) (int) |
Convenient typedef for signal handlers.
Definition at line 466 of file platform.h.
typedef int socket_t |
Definition at line 429 of file platform.h.
typedef size_t socksize_t |
Definition at line 311 of file platform.h.
typedef size_t stacksize_t |
Definition at line 428 of file platform.h.
typedef unsigned long timeout_t |
Definition at line 468 of file platform.h.
typedef uint8_t ubyte_t |
Definition at line 572 of file platform.h.
typedef unsigned long Unsigned |
Definition at line 570 of file platform.h.
|
inline |
Definition at line 631 of file platform.h.
|
inline |
Template function to initialize memory by invoking default constructor.
If NULL is passed, then NULL is returned without any constructor called.
memory | to initialize. |
Definition at line 566 of file platform.h.
|
inline |
Definition at line 596 of file platform.h.
|
inline |
Definition at line 608 of file platform.h.
|
inline |
Definition at line 582 of file platform.h.
|
inline |
Definition at line 618 of file platform.h.
|
inline |
Definition at line 602 of file platform.h.
T protocol_cast | ( | S * | s | ) |
Definition at line 129 of file platform.h.
|
inline |
Definition at line 625 of file platform.h.
|
inline |
Matching function for strdup().
string | to release from allocated memory. |
Definition at line 578 of file platform.h.