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