ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

platform.h File Reference
#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>
Include dependency graph for platform.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  nullptr_t
 

Namespaces

 ucommon
 

Macros

#define _UCOMMON_PLATFORM_H_
 
#define UCOMMON_ABI   7
 
#define NEW_STDCPP
 
#define _UCOMMON_EXTENDED_
 
#define __THROW_SIZE(x)   throw std::length_error(x)
 
#define __THROW_RANGE(x)   throw std::out_of_range(x)
 
#define __THROW_RUNTIME(x)   throw std::runtime_error(x)
 
#define __THROW_ALLOC()   throw std::bad_alloc()
 
#define __THROW_DEREF(v)
 
#define __THROW_UNDEF(v, x)   if(v == nullptr) throw std::runtime_error(x)
 
#define UCOMMON_NAMESPACE   ucommon
 
#define NAMESPACE_UCOMMON   namespace ucommon {
 
#define END_NAMESPACE   }
 
#define _REENTRANT   1
 
#define _THREADSAFE   1
 
#define _POSIX_PTHREAD_SEMANTICS
 
#define UCOMMON_RTTI   1
 
#define __PROTOCOL   virtual
 
#define __GNUC_PREREQ__(maj, min)   0
 
#define __UNUSED(x)   (void)x
 
#define __ALIGNED(x)   __attribute__(align(x))
 
#define __FINAL
 
#define __OVERRIDE
 
#define __DELETED
 
#define __DELETE_COPY(x)
 
#define __DELETE_DEFAULTS(x)
 
#define __PRINTF(x, y)
 
#define __SCANF(x, y)
 
#define __MALLOC
 
#define NDEBUG
 
#define __EXPORT   __attribute__ ((visibility("default")))
 
#define __LOCAL   __attribute__ ((visibility("hidden")))
 
#define __SHARED   __attribute__ ((visibility("default")))
 
#define INVALID_SOCKET   -1
 
#define INVALID_HANDLE_VALUE   -1
 
#define __PROGRAM(c, v)   extern "C" int main(int c, char **v)
 
#define PROGRAM_MAIN(argc, argv)   extern "C" int main(int argc, char **argv)
 
#define PROGRAM_EXIT(code)   return code
 
#define __SERVICE(id, c, v)   void service_##id(int c, char **v)
 
#define SERVICE_MAIN(id, argc, argv)   void service_##id(int argc, char **argv)
 
#define crit(x, text)   if(!(x)) cpr_runtime_error(text)
 

Typedefs

typedef size_t socksize_t
 
typedef size_t stacksize_t
 
typedef int socket_t
 
typedef int fd_t
 
typedef void(* sighandler_t) (int)
 
typedef unsigned long timeout_t
 
typedef void(* cpr_service_t) (int argc, char **argv)
 
typedef long Integer
 
typedef unsigned long Unsigned
 
typedef double Real
 
typedef uint8_t ubyte_t
 

Functions

template<typename T , typename S >
protocol_cast (S *s)
 
template<class T >
T * init (T *memory)
 
void strfree (char *str)
 
template<class T , class S >
polypointer_cast (S *s)
 
template<class T , class S >
polyconst_cast (S *s)
 
template<class T , class S >
polystatic_cast (S *s)
 
template<class T , class S >
polydynamic_cast (S *s)
 
template<class T , class S >
T & polyreference_cast (S *s)
 
template<typename T >
T & reference_cast (T *pointer)
 
template<typename T >
const T immutable_cast (T p)
 

Variables

const class nullptr_t nullptr = {}
 

Detailed Description

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.

Macro Definition Documentation

◆ __ALIGNED

#define __ALIGNED (   x)    __attribute__(align(x))

Definition at line 152 of file platform.h.

◆ __DELETE_COPY

#define __DELETE_COPY (   x)
Value:
inline x(const x&);\
inline x& operator=(const x&)

Definition at line 160 of file platform.h.

◆ __DELETE_DEFAULTS

#define __DELETE_DEFAULTS (   x)
Value:
inline x();\
__DELETE_COPY(x)

Definition at line 162 of file platform.h.

◆ __DELETED

#define __DELETED

Definition at line 159 of file platform.h.

◆ __EXPORT

#define __EXPORT   __attribute__ ((visibility("default")))

Definition at line 297 of file platform.h.

◆ __FINAL

#define __FINAL

Definition at line 157 of file platform.h.

◆ __GNUC_PREREQ__

#define __GNUC_PREREQ__ (   maj,
  min 
)    0

Definition at line 133 of file platform.h.

◆ __LOCAL

#define __LOCAL   __attribute__ ((visibility("hidden")))

Definition at line 298 of file platform.h.

◆ __MALLOC

#define __MALLOC

Definition at line 201 of file platform.h.

◆ __OVERRIDE

#define __OVERRIDE

Definition at line 158 of file platform.h.

◆ __PRINTF

#define __PRINTF (   x,
 
)

Definition at line 199 of file platform.h.

◆ __PROGRAM

#define __PROGRAM (   c,
 
)    extern "C" int main(int c, char **v)

Definition at line 526 of file platform.h.

◆ __PROTOCOL

#define __PROTOCOL   virtual

Definition at line 112 of file platform.h.

◆ __SCANF

#define __SCANF (   x,
 
)

Definition at line 200 of file platform.h.

◆ __SERVICE

#define __SERVICE (   id,
  c,
 
)    void service_##id(int c, char **v)

Definition at line 532 of file platform.h.

◆ __SHARED

#define __SHARED   __attribute__ ((visibility("default")))

Definition at line 299 of file platform.h.

◆ __THROW_ALLOC

#define __THROW_ALLOC ( )    throw std::bad_alloc()

Definition at line 52 of file platform.h.

◆ __THROW_DEREF

#define __THROW_DEREF (   v)
Value:
if(v == nullptr) \
throw std::runtime_error("Dereference NULL")

Definition at line 53 of file platform.h.

◆ __THROW_RANGE

#define __THROW_RANGE (   x)    throw std::out_of_range(x)

Definition at line 50 of file platform.h.

◆ __THROW_RUNTIME

#define __THROW_RUNTIME (   x)    throw std::runtime_error(x)

Definition at line 51 of file platform.h.

◆ __THROW_SIZE

#define __THROW_SIZE (   x)    throw std::length_error(x)

Definition at line 49 of file platform.h.

◆ __THROW_UNDEF

#define __THROW_UNDEF (   v,
 
)    if(v == nullptr) throw std::runtime_error(x)

Definition at line 55 of file platform.h.

◆ __UNUSED

#define __UNUSED (   x)    (void)x

Definition at line 144 of file platform.h.

◆ _POSIX_PTHREAD_SEMANTICS

#define _POSIX_PTHREAD_SEMANTICS

Definition at line 89 of file platform.h.

◆ _REENTRANT

#define _REENTRANT   1

Definition at line 80 of file platform.h.

◆ _THREADSAFE

#define _THREADSAFE   1

Definition at line 85 of file platform.h.

◆ _UCOMMON_EXTENDED_

#define _UCOMMON_EXTENDED_

Definition at line 47 of file platform.h.

◆ _UCOMMON_PLATFORM_H_

#define _UCOMMON_PLATFORM_H_

Definition at line 40 of file platform.h.

◆ crit

#define crit (   x,
  text 
)    if(!(x)) cpr_runtime_error(text)

Definition at line 541 of file platform.h.

◆ END_NAMESPACE

#define END_NAMESPACE   }

Definition at line 77 of file platform.h.

◆ INVALID_HANDLE_VALUE

#define INVALID_HANDLE_VALUE   -1

Definition at line 417 of file platform.h.

◆ INVALID_SOCKET

#define INVALID_SOCKET   -1

Definition at line 416 of file platform.h.

◆ NAMESPACE_UCOMMON

#define NAMESPACE_UCOMMON   namespace ucommon {

Definition at line 76 of file platform.h.

◆ NDEBUG

#define NDEBUG

Definition at line 206 of file platform.h.

◆ NEW_STDCPP

#define NEW_STDCPP

Definition at line 45 of file platform.h.

◆ PROGRAM_EXIT

#define PROGRAM_EXIT (   code)    return code

Definition at line 528 of file platform.h.

◆ PROGRAM_MAIN

#define PROGRAM_MAIN (   argc,
  argv 
)    extern "C" int main(int argc, char **argv)

Definition at line 527 of file platform.h.

◆ SERVICE_MAIN

#define SERVICE_MAIN (   id,
  argc,
  argv 
)    void service_##id(int argc, char **argv)

Definition at line 533 of file platform.h.

◆ UCOMMON_ABI

#define UCOMMON_ABI   7

Definition at line 41 of file platform.h.

◆ UCOMMON_NAMESPACE

#define UCOMMON_NAMESPACE   ucommon

Definition at line 75 of file platform.h.

◆ UCOMMON_RTTI

#define UCOMMON_RTTI   1

Definition at line 94 of file platform.h.

Typedef Documentation

◆ cpr_service_t

typedef void(* cpr_service_t) (int argc, char **argv)

Definition at line 534 of file platform.h.

◆ fd_t

typedef int fd_t

Definition at line 415 of file platform.h.

◆ Integer

typedef long Integer

Definition at line 554 of file platform.h.

◆ Real

typedef double Real

Definition at line 556 of file platform.h.

◆ sighandler_t

typedef void(* sighandler_t) (int)

Convenient typedef for signal handlers.

Definition at line 451 of file platform.h.

◆ socket_t

typedef int socket_t

Definition at line 414 of file platform.h.

◆ socksize_t

typedef size_t socksize_t

Definition at line 296 of file platform.h.

◆ stacksize_t

typedef size_t stacksize_t

Definition at line 413 of file platform.h.

◆ timeout_t

typedef unsigned long timeout_t

Definition at line 453 of file platform.h.

◆ ubyte_t

typedef uint8_t ubyte_t

Definition at line 557 of file platform.h.

◆ Unsigned

typedef unsigned long Unsigned

Definition at line 555 of file platform.h.

Function Documentation

◆ immutable_cast()

template<typename T >
const T immutable_cast ( p)
inline

Definition at line 616 of file platform.h.

◆ init()

template<class T >
T* init ( T *  memory)
inline

Template function to initialize memory by invoking default constructor. If NULL is passed, then NULL is returned without any constructor called.

Parameters
memoryto initialize.
Returns
memory initialized.

Definition at line 551 of file platform.h.

Referenced by ucommon::Atomic::counter::counter(), and ost::DSO::loader().

◆ polyconst_cast()

template<class T , class S >
T polyconst_cast ( S *  s)
inline

Definition at line 581 of file platform.h.

◆ polydynamic_cast()

template<class T , class S >
T polydynamic_cast ( S *  s)
inline

Definition at line 593 of file platform.h.

◆ polypointer_cast()

template<class T , class S >
T polypointer_cast ( S *  s)
inline

Definition at line 567 of file platform.h.

References __THROW_DEREF.

◆ polyreference_cast()

template<class T , class S >
T& polyreference_cast ( S *  s)
inline

Definition at line 603 of file platform.h.

References __THROW_DEREF.

◆ polystatic_cast()

template<class T , class S >
T polystatic_cast ( S *  s)
inline

Definition at line 587 of file platform.h.

◆ protocol_cast()

template<typename T , typename S >
T protocol_cast ( S *  s)

Definition at line 114 of file platform.h.

◆ reference_cast()

template<typename T >
T& reference_cast ( T *  pointer)
inline

Definition at line 610 of file platform.h.

References __THROW_DEREF.

◆ strfree()

void strfree ( char *  str)
inline

Matching function for strdup().

Parameters
stringto release from allocated memory.

Definition at line 563 of file platform.h.

References ucommon::str().

Referenced by ucommon::Socket::address::set().

Variable Documentation

◆ nullptr

const class nullptr_t nullptr = {}