corotypes.h
Go to the documentation of this file.
/*
* Copyright (c) 2008 Allied Telesis Labs.
* Copyright (c) 2012 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Angus Salkeld (ahsalkeld@gmail.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef COROTYPES_H_DEFINED
#define COROTYPES_H_DEFINED
#include <stdint.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int64_t cs_time_t;
#define CS_FALSE 0
#define CS_TRUE !CS_FALSE
#define CS_MAX_NAME_LENGTH 256
#define CS_TIME_END ((cs_time_t)0x7FFFFFFFFFFFFFFFULL)
#define CS_MAX(x, y) (((x) > (y)) ? (x) : (y))
#define CS_PRI_NODE_ID "%" PRIu32
#define CS_PRI_NODE_ID_PADDED "%10" PRIu32
#define CS_PRI_RING_ID_SEQ "%" PRIx64
#define CS_PRI_RING_ID "%" PRIx32 ".%" PRIx64
typedef struct {
uint16_t length;
uint8_t value[CS_MAX_NAME_LENGTH];
} cs_name_t;
typedef struct {
char releaseCode;
unsigned char majorVersion;
unsigned char minorVersion;
} cs_version_t;
typedef enum {
CS_DISPATCH_ONE = 1,
CS_DISPATCH_ALL = 2,
CS_DISPATCH_BLOCKING = 3,
CS_DISPATCH_ONE_NONBLOCKING = 4
} cs_dispatch_flags_t;
#define CS_TRACK_CURRENT 0x01
#define CS_TRACK_CHANGES 0x02
#define CS_TRACK_CHANGES_ONLY 0x04
typedef enum {
CS_OK = 1,
CS_ERR_LIBRARY = 2,
CS_ERR_VERSION = 3,
CS_ERR_INIT = 4,
CS_ERR_TIMEOUT = 5,
CS_ERR_TRY_AGAIN = 6,
CS_ERR_INVALID_PARAM = 7,
CS_ERR_NO_MEMORY = 8,
CS_ERR_BAD_HANDLE = 9,
CS_ERR_BUSY = 10,
CS_ERR_ACCESS = 11,
CS_ERR_NOT_EXIST = 12,
CS_ERR_NAME_TOO_LONG = 13,
CS_ERR_EXIST = 14,
CS_ERR_NO_SPACE = 15,
CS_ERR_INTERRUPT = 16,
CS_ERR_NAME_NOT_FOUND = 17,
CS_ERR_NO_RESOURCES = 18,
CS_ERR_NOT_SUPPORTED = 19,
CS_ERR_BAD_OPERATION = 20,
CS_ERR_FAILED_OPERATION = 21,
CS_ERR_MESSAGE_ERROR = 22,
CS_ERR_QUEUE_FULL = 23,
CS_ERR_QUEUE_NOT_AVAILABLE = 24,
CS_ERR_BAD_FLAGS = 25,
CS_ERR_TOO_BIG = 26,
CS_ERR_NO_SECTIONS = 27,
CS_ERR_CONTEXT_NOT_FOUND = 28,
CS_ERR_TOO_MANY_GROUPS = 30,
CS_ERR_SECURITY = 100
} cs_error_t;
#define CS_IPC_TIMEOUT_MS -1
#define CS_TIME_MS_IN_SEC 1000ULL
#define CS_TIME_US_IN_SEC 1000000ULL
#define CS_TIME_NS_IN_SEC 1000000000ULL
#define CS_TIME_US_IN_MSEC 1000ULL
#define CS_TIME_NS_IN_MSEC 1000000ULL
#define CS_TIME_NS_IN_USEC 1000ULL
static inline uint64_t cs_timestamp_get(void)
{
uint64_t result;
#if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
struct timespec ts;
clock_gettime (CLOCK_MONOTONIC, &ts);
result = (ts.tv_sec * CS_TIME_NS_IN_SEC) + (uint64_t)ts.tv_nsec;
#else
struct timeval time_from_epoch;
gettimeofday (&time_from_epoch, 0);
result = ((time_from_epoch.tv_sec * CS_TIME_NS_IN_SEC) +
(time_from_epoch.tv_usec * CS_TIME_NS_IN_USEC));
#endif
return result;
}
cs_error_t qb_to_cs_error (int result);
const char * cs_strerror(cs_error_t err);
cs_error_t hdb_error_to_cs (int res);
#ifdef __cplusplus
}
#endif
#endif /* COROTYPES_H_DEFINED */
nodeid
unsigned int nodeid
Definition coroapi.h:0
CS_TIME_NS_IN_SEC
#define CS_TIME_NS_IN_SEC
Definition corotypes.h:135
cs_dispatch_flags_t
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
Definition corotypes.h:84
CS_DISPATCH_BLOCKING
@ CS_DISPATCH_BLOCKING
Definition corotypes.h:87
CS_DISPATCH_ONE
@ CS_DISPATCH_ONE
Definition corotypes.h:85
CS_DISPATCH_ONE_NONBLOCKING
@ CS_DISPATCH_ONE_NONBLOCKING
Definition corotypes.h:88
CS_DISPATCH_ALL
@ CS_DISPATCH_ALL
Definition corotypes.h:86
cs_time_t
int64_t cs_time_t
cs_time_t
Definition corotypes.h:51
qb_to_cs_error
cs_error_t qb_to_cs_error(int result)
qb_to_cs_error
cs_strerror
const char * cs_strerror(cs_error_t err)
cs_strerror
CS_MAX_NAME_LENGTH
#define CS_MAX_NAME_LENGTH
Definition corotypes.h:55
hdb_error_to_cs
cs_error_t hdb_error_to_cs(int res)
hdb_error_to_cs
CS_TIME_NS_IN_USEC
#define CS_TIME_NS_IN_USEC
Definition corotypes.h:138
cs_error_t
cs_error_t
The cs_error_t enum.
Definition corotypes.h:98
CS_ERR_CONTEXT_NOT_FOUND
@ CS_ERR_CONTEXT_NOT_FOUND
Definition corotypes.h:126
CS_ERR_NO_SECTIONS
@ CS_ERR_NO_SECTIONS
Definition corotypes.h:125
CS_ERR_NO_SPACE
@ CS_ERR_NO_SPACE
Definition corotypes.h:113
CS_ERR_MESSAGE_ERROR
@ CS_ERR_MESSAGE_ERROR
Definition corotypes.h:120
CS_ERR_NO_RESOURCES
@ CS_ERR_NO_RESOURCES
Definition corotypes.h:116
CS_ERR_NAME_TOO_LONG
@ CS_ERR_NAME_TOO_LONG
Definition corotypes.h:111
CS_ERR_ACCESS
@ CS_ERR_ACCESS
Definition corotypes.h:109
CS_ERR_NO_MEMORY
@ CS_ERR_NO_MEMORY
Definition corotypes.h:106
CS_ERR_BUSY
@ CS_ERR_BUSY
Definition corotypes.h:108
CS_ERR_TOO_MANY_GROUPS
@ CS_ERR_TOO_MANY_GROUPS
Definition corotypes.h:127
CS_ERR_TIMEOUT
@ CS_ERR_TIMEOUT
Definition corotypes.h:103
CS_ERR_BAD_HANDLE
@ CS_ERR_BAD_HANDLE
Definition corotypes.h:107
CS_ERR_TRY_AGAIN
@ CS_ERR_TRY_AGAIN
Definition corotypes.h:104
CS_OK
@ CS_OK
Definition corotypes.h:99
CS_ERR_INVALID_PARAM
@ CS_ERR_INVALID_PARAM
Definition corotypes.h:105
CS_ERR_QUEUE_NOT_AVAILABLE
@ CS_ERR_QUEUE_NOT_AVAILABLE
Definition corotypes.h:122
CS_ERR_LIBRARY
@ CS_ERR_LIBRARY
Definition corotypes.h:100
CS_ERR_NAME_NOT_FOUND
@ CS_ERR_NAME_NOT_FOUND
Definition corotypes.h:115
CS_ERR_INTERRUPT
@ CS_ERR_INTERRUPT
Definition corotypes.h:114
CS_ERR_FAILED_OPERATION
@ CS_ERR_FAILED_OPERATION
Definition corotypes.h:119
CS_ERR_VERSION
@ CS_ERR_VERSION
Definition corotypes.h:101
CS_ERR_NOT_EXIST
@ CS_ERR_NOT_EXIST
Definition corotypes.h:110
CS_ERR_INIT
@ CS_ERR_INIT
Definition corotypes.h:102
CS_ERR_QUEUE_FULL
@ CS_ERR_QUEUE_FULL
Definition corotypes.h:121
CS_ERR_BAD_OPERATION
@ CS_ERR_BAD_OPERATION
Definition corotypes.h:118
CS_ERR_BAD_FLAGS
@ CS_ERR_BAD_FLAGS
Definition corotypes.h:123
CS_ERR_TOO_BIG
@ CS_ERR_TOO_BIG
Definition corotypes.h:124
CS_ERR_SECURITY
@ CS_ERR_SECURITY
Definition corotypes.h:128
CS_ERR_EXIST
@ CS_ERR_EXIST
Definition corotypes.h:112
CS_ERR_NOT_SUPPORTED
@ CS_ERR_NOT_SUPPORTED
Definition corotypes.h:117
value
uint32_t value
Definition exec/votequorum.c:2
cs_name_t
The cs_name_t struct.
Definition corotypes.h:66
cs_name_t::length
uint16_t length
Definition corotypes.h:67
cs_version_t
The cs_version_t struct.
Definition corotypes.h:75
cs_version_t::majorVersion
unsigned char majorVersion
Definition corotypes.h:77
cs_version_t::minorVersion
unsigned char minorVersion
Definition corotypes.h:78
cs_version_t::releaseCode
char releaseCode
Definition corotypes.h:76