Skip to content

File porting.h

FileList > base > porting.h

Go to the source code of this file

  • #include "config.h"
  • #include <type_traits>
  • #include <utility>

Public Types

Type Name
typedef void(* SIGNAL_HANDLER_FUNCTION
typedef int SOCKET

Public Functions

Type Name
int asprintf (char ** ptr, const char * format, ...)
char * basename (const char * path)
int basename_r (const char * path, char * pathbuf, size_t buflen)
void check_is_array (const T & a)
int cub_dirname_r (const char * path, char * pathbuf, size_t buflen)
char * dirname (const char * path)
char * getuserid (char * string, int size)
int itona (int i, char * s, size_t n)
int msleep (const long msec)
int os_rename_file (const char * src_path, const char * dest_path)
void os_send_signal (const int sig_no)
SIGNAL_HANDLER_FUNCTION os_set_signal_handler (const int sig_no, SIGNAL_HANDLER_FUNCTION sig_handler)
int parse_bigint (INT64 * ret_p, const char * str_p, int base)
int parse_int (int * ret_p, const char * str_p, int base)
void port_close_memstream (FILE * fp, char ** ptr, size_t * sizeloc)
FILE * port_open_memstream (char ** ptr, size_t * sizeloc)
int str_to_double (double * ret_p, char ** end_p, const char * str_p)
int str_to_float (float * ret_p, char ** end_p, const char * str_p)
int str_to_int32 (int * ret_p, char ** end_p, const char * str_p, int base)
int str_to_int64 (INT64 * ret_p, char ** end_p, const char * str_p, int base)
int str_to_uint32 (unsigned int * ret_p, char ** end_p, const char * str_p, int base)
int str_to_uint64 (UINT64 * ret_p, char ** end_p, const char * str_p, int base)
char * strdup (const char * str)
char * stristr (const char * s, const char * find)
size_t strlcpy (char * dst, const char * src, size_t siz)
int timeval_add_msec (struct timeval * added_time, const struct timeval * start_time, int msec)
INT64 timeval_diff_in_msec (const struct timeval * end_time, const struct timeval * start_time)
int timeval_to_timespec (struct timespec * to, const struct timeval * from)
int utona (unsigned int u, char * s, size_t n)
int vasprintf (char ** ptr, const char * format, va_list ap)

Macros

Type Name
define CAST_BUFLEN ([**int**](broker__monitor_8c.md#function-timeout))
define CAST_STRLEN ([**int**](broker__monitor_8c.md#function-timeout))
define CONST_CAST (dest_type, expr) [**const\_cast**](broker__monitor_8c.md#function-timeout)&lt;[**dest\_type**](broker__monitor_8c.md#function-timeout)&gt;(expr)
define COPYMEM (type, dst, src) /* multi line expression */
define CTIME_MAX 64
define CUB_MAXHOSTNAMELEN 256 /\* 255 + 1([**for**](dynamic__load_8c.md#function-for) [**NULL**](freelistheap_8h.md#define-null) [**terminator**](broker__monitor_8c.md#function-timeout)) \*/
define DYNAMIC_CAST (dest_type, expr) [**dynamic\_cast**](broker__monitor_8c.md#function-timeout)&lt;[**dest\_type**](broker__monitor_8c.md#function-timeout)&gt;(expr)
define EXPORT_IMPORT
define FINITE (x) [**finite**](broker__monitor_8c.md#function-timeout)([**x**](broker__monitor_8c.md#function-timeout))
define GETHOSTNAME (p, l) [**css\_gethostname**](tcp_8c.md#function-css_gethostname)([**p**](dynamic__load_8c.md#variable-p), l)
define INVALID_SOCKET (-1)
define IS_ABS_PATH (p) [**IS\_PATH\_SEPARATOR**](porting_8h.md#define-is_path_separator)(([**p**](dynamic__load_8c.md#variable-p))[0])
define IS_INVALID_SOCKET (socket) (([**socket**](broker__monitor_8c.md#function-timeout)) &lt; 0)
define IS_PATH_SEPARATOR (c) ((c) == [**PATH\_SEPARATOR**](porting_8h.md#define-path_separator))
define LLONG_MAX 9223372036854775807[**LL**](broker__monitor_8c.md#function-timeout)
define LLONG_MIN (-[**LLONG\_MAX**](porting_8h.md#define-llong_max) - 1[**LL**](broker__monitor_8c.md#function-timeout))
define LONGJMP [**\_longjmp**](broker__monitor_8c.md#function-timeout)
define L_cuserid 9
define MEM_SIZE_IS_VALID (size) /* multi line expression */
define OFF_T_MAX [**LLONG\_MAX**](porting_8h.md#define-llong_max)
define ONE_G 1073741824
define ONE_HOUR 3600000
define ONE_K 1024
define ONE_M 1048576
define ONE_MIN 60000
define ONE_P 1125899906842624[**LL**](broker__monitor_8c.md#function-timeout)
define ONE_SEC 1000
define ONE_T 1099511627776[**LL**](broker__monitor_8c.md#function-timeout)
define PATH_CURRENT '.'
define PATH_SEPARATOR '/'
define PORTABLE_FUNC_NAME [**\_\_func\_\_**](broker__monitor_8c.md#function-timeout)
define PREFETCH_CACHE_L1 3
define PREFETCH_CACHE_L2 2
define PREFETCH_CACHE_L3 1
define PREFETCH_CACHE_NEVER 0
define PREFETCH_READ 0
define PREFETCH_WRITE 1
define REFPTR (T, name) T \*& name
define REINTERPRET_CAST (dest_type, expr) [**reinterpret\_cast**](broker__monitor_8c.md#function-timeout)&lt;[**dest\_type**](broker__monitor_8c.md#function-timeout)&gt;(expr)
define SETJMP [**\_setjmp**](broker__monitor_8c.md#function-timeout)
define STATIC_CAST (dest_type, expr) [**static\_cast**](broker__monitor_8c.md#function-timeout)&lt;[**dest\_type**](broker__monitor_8c.md#function-timeout)&gt;(expr)
define SUPPRESS_STRLEN_WARNING
define THREAD_CALLING_CONVENTION
define THREAD_RET_T [**void**](broker__monitor_8c.md#function-timeout)\*
define ULLONG_MAX 18446744073709551615[**ULL**](broker__monitor_8c.md#function-timeout)
define UNUSED (x) [**UNUSED\_**](broker__monitor_8c.md#function-timeout) ## [**x**](broker__monitor_8c.md#function-timeout) [**\_\_attribute\_\_**](broker__monitor_8c.md#function-timeout)(([**\_\_unused\_\_**](broker__monitor_8c.md#function-timeout)))
define UNUSED_FUNCTION (x) [**\_\_attribute\_\_**](broker__monitor_8c.md#function-timeout)(([**\_\_unused\_\_**](broker__monitor_8c.md#function-timeout))) [**UNUSED\_**](broker__monitor_8c.md#function-timeout) ## [**x**](broker__monitor_8c.md#function-timeout)
define difftime64 (time1, time2) [**difftime**](broker__monitor_8c.md#function-timeout)([**time1**](broker__monitor_8c.md#function-timeout), [**time2**](broker__monitor_8c.md#function-timeout))
define err (fd, ...) [**do**](dynamic__load_8c.md#variable-do) { [**fprintf**](broker__monitor_8c.md#function-timeout)([**stderr**](broker__monitor_8c.md#function-timeout), [**\_\_VA\_ARGS\_\_**](broker__monitor_8c.md#function-timeout)); [**exit**](broker__monitor_8c.md#function-timeout)(1); } [**while**](dynamic__load_8c.md#function-while) (0)
define errx (fd, ...) [**do**](dynamic__load_8c.md#variable-do) { [**fprintf**](broker__monitor_8c.md#function-timeout)([**stderr**](broker__monitor_8c.md#function-timeout), [**\_\_VA\_ARGS\_\_**](broker__monitor_8c.md#function-timeout)); [**exit**](broker__monitor_8c.md#function-timeout)(1); } [**while**](dynamic__load_8c.md#function-while) (0)
define likely (x) [**\_\_builtin\_expect**](broker__monitor_8c.md#function-timeout)(!!([**x**](broker__monitor_8c.md#function-timeout)), 1)
define os_send_kill () [**os\_send\_signal**](porting_8c.md#function-os_send_signal)([**SIGKILL**](broker__monitor_8c.md#function-timeout))
define prefetch (x, y, z) [**\_\_builtin\_prefetch**](broker__monitor_8c.md#function-timeout)(([**x**](broker__monitor_8c.md#function-timeout)), ([**y**](broker__monitor_8c.md#function-timeout)), ([**z**](broker__monitor_8c.md#function-timeout)))
define snprintf_dots_truncate (dest, max_len, ...) /* multi line expression */
define string_to_double (str, end_ptr) [**strtod**](broker__monitor_8c.md#function-timeout)((str), ([**end\_ptr**](broker__monitor_8c.md#function-timeout)))
define strncpy_bufsize (buf, str) [**strncpy\_size**](porting_8h.md#define-strncpy_size) (buf, str, [**sizeof**](broker__monitor_8c.md#function-timeout) (buf)); [**check\_is\_array**](porting_8h.md#function-check_is_array) (buf)
define strncpy_size (buf, str, size) [**strncpy**](broker__monitor_8c.md#function-timeout) (buf, str, size); buf[(size) - 1] = '\0'
define unlikely (x) [**\_\_builtin\_expect**](broker__monitor_8c.md#function-timeout)(!!([**x**](broker__monitor_8c.md#function-timeout)), 0)

Public Types Documentation

typedef SIGNAL_HANDLER_FUNCTION

typedef void(* SIGNAL_HANDLER_FUNCTION) (int sig_no);

typedef SOCKET

typedef int SOCKET;

Public Functions Documentation

function asprintf

int asprintf (
    char ** ptr,
    const  char * format,
    ...
) 

function basename

char * basename (
    const  char * path
) 

function basename_r

int basename_r (
    const  char * path,
    char * pathbuf,
    size_t buflen
) 

function check_is_array

template<typename T>
inline void check_is_array (
    const T & a
) 

function cub_dirname_r

int cub_dirname_r (
    const  char * path,
    char * pathbuf,
    size_t buflen
) 

function dirname

char * dirname (
    const  char * path
) 

function getuserid

char * getuserid (
    char * string,
    int size
) 

function itona

int itona (
    int i,
    char * s,
    size_t n
) 

function msleep

int msleep (
    const  long msec
) 

function os_rename_file

int os_rename_file (
    const  char * src_path,
    const  char * dest_path
) 

function os_send_signal

void os_send_signal (
    const  int sig_no
) 

function os_set_signal_handler

SIGNAL_HANDLER_FUNCTION os_set_signal_handler (
    const  int sig_no,
    SIGNAL_HANDLER_FUNCTION sig_handler
) 

function parse_bigint

int parse_bigint (
    INT64 * ret_p,
    const  char * str_p,
    int base
) 

function parse_int

int parse_int (
    int * ret_p,
    const  char * str_p,
    int base
) 

function port_close_memstream

void port_close_memstream (
    FILE * fp,
    char ** ptr,
    size_t * sizeloc
) 

function port_open_memstream

FILE * port_open_memstream (
    char ** ptr,
    size_t * sizeloc
) 

function str_to_double

int str_to_double (
    double * ret_p,
    char ** end_p,
    const  char * str_p
) 

function str_to_float

int str_to_float (
    float * ret_p,
    char ** end_p,
    const  char * str_p
) 

function str_to_int32

int str_to_int32 (
    int * ret_p,
    char ** end_p,
    const  char * str_p,
    int base
) 

function str_to_int64

int str_to_int64 (
    INT64 * ret_p,
    char ** end_p,
    const  char * str_p,
    int base
) 

function str_to_uint32

int str_to_uint32 (
    unsigned  int * ret_p,
    char ** end_p,
    const  char * str_p,
    int base
) 

function str_to_uint64

int str_to_uint64 (
    UINT64 * ret_p,
    char ** end_p,
    const  char * str_p,
    int base
) 

function strdup

char * strdup (
    const  char * str
) 

function stristr

char * stristr (
    const  char * s,
    const  char * find
) 

function strlcpy

size_t strlcpy (
    char * dst,
    const  char * src,
    size_t siz
) 

function timeval_add_msec

int timeval_add_msec (
    struct  timeval * added_time,
    const  struct  timeval * start_time,
    int msec
) 

function timeval_diff_in_msec

INT64 timeval_diff_in_msec (
    const  struct  timeval * end_time,
    const  struct  timeval * start_time
) 

function timeval_to_timespec

int timeval_to_timespec (
    struct  timespec * to,
    const  struct  timeval * from
) 

function utona

int utona (
    unsigned  int u,
    char * s,
    size_t n
) 

function vasprintf

int vasprintf (
    char ** ptr,
    const  char * format,
    va_list ap
) 

Macro Definition Documentation

define CAST_BUFLEN

#define CAST_BUFLEN `( int )`

define CAST_STRLEN

#define CAST_STRLEN `( int )`

define CONST_CAST

#define CONST_CAST (
    dest_type,
    expr
) `const_cast < dest_type >(expr)`

define COPYMEM

#define COPYMEM (
    type,
    dst,
    src
) `/* multi line expression */`

define CTIME_MAX

#define CTIME_MAX `64`

define CUB_MAXHOSTNAMELEN

#define CUB_MAXHOSTNAMELEN `256 /* 255 + 1( for  NULL  terminator ) */`

RFC1123 - Section 2.1 https://tools.ietf.org/html/rfc1123

Host software MUST handle host names of up to 63 characters and SHOULD handle host names of up to 255 characters.


define DYNAMIC_CAST

#define DYNAMIC_CAST (
    dest_type,
    expr
) `dynamic_cast < dest_type >(expr)`

define EXPORT_IMPORT

#define EXPORT_IMPORT 

define FINITE

#define FINITE (
    x
) `finite ( x )`

define GETHOSTNAME

#define GETHOSTNAME (
    p,
    l
) `css_gethostname ( p , l)`

define INVALID_SOCKET

#define INVALID_SOCKET `(-1)`

define IS_ABS_PATH

#define IS_ABS_PATH (
    p
) `IS_PATH_SEPARATOR (( p )[0])`

define IS_INVALID_SOCKET

#define IS_INVALID_SOCKET (
    socket
) `(( socket ) < 0)`

define IS_PATH_SEPARATOR

#define IS_PATH_SEPARATOR (
    c
) `((c) == PATH_SEPARATOR )`

define LLONG_MAX

#define LLONG_MAX `9223372036854775807 LL`

define LLONG_MIN

#define LLONG_MIN `(- LLONG_MAX - 1 LL )`

define LONGJMP

#define LONGJMP `_longjmp`

define L_cuserid

#define L_cuserid `9`

define MEM_SIZE_IS_VALID

#define MEM_SIZE_IS_VALID (
    size
) `/* multi line expression */`

define OFF_T_MAX

#define OFF_T_MAX `LLONG_MAX`

define ONE_G

#define ONE_G `1073741824`

define ONE_HOUR

#define ONE_HOUR `3600000`

define ONE_K

#define ONE_K `1024`

define ONE_M

#define ONE_M `1048576`

define ONE_MIN

#define ONE_MIN `60000`

define ONE_P

#define ONE_P `1125899906842624 LL`

define ONE_SEC

#define ONE_SEC `1000`

define ONE_T

#define ONE_T `1099511627776 LL`

define PATH_CURRENT

#define PATH_CURRENT `'.'`

define PATH_SEPARATOR

#define PATH_SEPARATOR `'/'`

define PORTABLE_FUNC_NAME

#define PORTABLE_FUNC_NAME `__func__`

define PREFETCH_CACHE_L1

#define PREFETCH_CACHE_L1 `3`

define PREFETCH_CACHE_L2

#define PREFETCH_CACHE_L2 `2`

define PREFETCH_CACHE_L3

#define PREFETCH_CACHE_L3 `1`

define PREFETCH_CACHE_NEVER

#define PREFETCH_CACHE_NEVER `0`

define PREFETCH_READ

#define PREFETCH_READ `0`

define PREFETCH_WRITE

#define PREFETCH_WRITE `1`

define REFPTR

#define REFPTR (
    T,
    name
) `T *& name`

define REINTERPRET_CAST

#define REINTERPRET_CAST (
    dest_type,
    expr
) `reinterpret_cast < dest_type >(expr)`

define SETJMP

#define SETJMP `_setjmp`

define STATIC_CAST

#define STATIC_CAST (
    dest_type,
    expr
) `static_cast < dest_type >(expr)`

define SUPPRESS_STRLEN_WARNING

#define SUPPRESS_STRLEN_WARNING 

define THREAD_CALLING_CONVENTION

#define THREAD_CALLING_CONVENTION 

define THREAD_RET_T

#define THREAD_RET_T `void *`

define ULLONG_MAX

#define ULLONG_MAX `18446744073709551615 ULL`

define UNUSED

#define UNUSED (
    x
) `UNUSED_ ## x  __attribute__ (( __unused__ ))`

define UNUSED_FUNCTION

#define UNUSED_FUNCTION (
    x
) `__attribute__ (( __unused__ )) UNUSED_ ## x`

define difftime64

#define difftime64 (
    time1,
    time2
) `difftime ( time1 , time2 )`

define err

#define err (
    fd,
    ...
) `do { fprintf ( stderr , __VA_ARGS__ ); exit (1); } while (0)`

define errx

#define errx (
    fd,
    ...
) `do { fprintf ( stderr , __VA_ARGS__ ); exit (1); } while (0)`

define likely

#define likely (
    x
) `__builtin_expect (!!( x ), 1)`

define os_send_kill

#define os_send_kill (

) `os_send_signal ( SIGKILL )`

define prefetch

#define prefetch (
    x,
    y,
    z
) `__builtin_prefetch (( x ), ( y ), ( z ))`

define snprintf_dots_truncate

#define snprintf_dots_truncate (
    dest,
    max_len,
    ...
) `if ( snprintf (dest, max_len, __VA_ARGS__ ) < 0) \ snprintf (dest + max_len - 4, 4, "...")`

define string_to_double

#define string_to_double (
    str,
    end_ptr
) `strtod ((str), ( end_ptr ))`

define strncpy_bufsize

#define strncpy_bufsize (
    buf,
    str
) `strncpy_size (buf, str, sizeof (buf)); check_is_array (buf)`

define strncpy_size

#define strncpy_size (
    buf,
    str,
    size
) `strncpy (buf, str, size); buf[(size) - 1] = '\0'`

define unlikely

#define unlikely (
    x
) `__builtin_expect (!!( x ), 0)`


The documentation for this class was generated from the following file cubrid/src/base/porting.h