~ubuntu-branches/ubuntu/precise/corosync/precise-proposed

« back to all changes in this revision

Viewing changes to include/corosync/mar_gen.h

  • Committer: Bazaar Package Importer
  • Author(s): Ante Karamatic
  • Date: 2009-08-21 09:29:56 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090821092956-w9qxxxx3zeoh8dem
Tags: 1.0.0-4ubuntu2
* debian/control:
  - 'Ubuntu Developers' instead of 'Ubuntu Core Developers'
    as maintainer
  - Bump debhelper dependecy to 7

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2006 Red Hat, Inc.
3
 
 * Copyright (c) 2006-2008 Red Hat, Inc.
 
2
 * Copyright (c) 2006-2009 Red Hat, Inc.
4
3
 *
5
4
 * All rights reserved.
6
5
 *
7
6
 * Author: Steven Dake (sdake@redhat.com)
8
7
 *
9
8
 * This software licensed under BSD license, the text of which follows:
10
 
 * 
 
9
 *
11
10
 * Redistribution and use in source and binary forms, with or without
12
11
 * modification, are permitted provided that the following conditions are met:
13
12
 *
33
32
 * THE POSSIBILITY OF SUCH DAMAGE.
34
33
 */
35
34
 
36
 
#ifndef AIS_MAR_GEN_H_DEFINED
37
 
#define AIS_MAR_GEN_H_DEFINED
 
35
#ifndef MAR_GEN_H_DEFINED
 
36
#define MAR_GEN_H_DEFINED
38
37
 
39
38
#ifndef COROSYNC_SOLARIS
40
39
#include <stdint.h>
43
42
#endif
44
43
#include <string.h>
45
44
 
46
 
#include <corosync/saAis.h>
 
45
#include <corosync/corotypes.h>
47
46
#include <corosync/swab.h>
48
47
 
49
48
typedef int8_t mar_int8_t;
98
97
 
99
98
typedef struct {
100
99
        mar_uint16_t length __attribute__((aligned(8)));
101
 
        mar_uint8_t value[SA_MAX_NAME_LENGTH] __attribute__((aligned(8)));
 
100
        mar_uint8_t value[CS_MAX_NAME_LENGTH] __attribute__((aligned(8)));
102
101
} mar_name_t;
103
102
 
104
 
static inline char *get_mar_name_t (mar_name_t *name) {
105
 
        return ((char *)name->value);
 
103
static inline const char *get_mar_name_t (const mar_name_t *name) {
 
104
        return ((const char *)name->value);
106
105
}
107
106
 
108
 
static inline int mar_name_match(mar_name_t *name1, mar_name_t *name2)
 
107
static inline int mar_name_match(const mar_name_t *name1, const mar_name_t *name2)
109
108
{
110
109
        if (name1->length == name2->length) {
111
 
                return ((strncmp ((char *)name1->value, (char *)name2->value,
 
110
                return ((strncmp ((const char *)name1->value,
 
111
                                  (const char *)name2->value,
112
112
                        name1->length)) == 0);
113
113
        }
114
114
        return 0;
121
121
}
122
122
 
123
123
static inline void marshall_from_mar_name_t (
124
 
        SaNameT *dest,
125
 
        mar_name_t *src)
 
124
        cs_name_t *dest,
 
125
        const mar_name_t *src)
126
126
{
127
127
        dest->length = src->length;
128
 
        memcpy (dest->value, src->value, SA_MAX_NAME_LENGTH);
 
128
        memcpy (dest->value, src->value, CS_MAX_NAME_LENGTH);
129
129
}
130
130
 
131
131
static inline void marshall_to_mar_name_t (
132
132
        mar_name_t *dest,
133
 
        SaNameT *src)
 
133
        const cs_name_t *src)
134
134
{
135
135
        dest->length = src->length;
136
 
        memcpy (dest->value, src->value, SA_MAX_NAME_LENGTH);
 
136
        memcpy (dest->value, src->value, CS_MAX_NAME_LENGTH);
137
137
}
138
138
 
139
139
typedef enum {
148
148
        swab_mar_uint64_t (to_swab);
149
149
}
150
150
 
151
 
#define MAR_TIME_END ((SaTimeT)0x7fffffffffffffffull)
 
151
#define MAR_TIME_END ((int64_t)0x7fffffffffffffffull)
152
152
#define MAR_TIME_BEGIN            0x0ULL
153
153
#define MAR_TIME_UNKNOWN          0x8000000000000000ULL
154
154
 
158
158
#define MAR_TIME_ONE_MINUTE      60000000000ULL
159
159
#define MAR_TIME_ONE_HOUR        3600000000000ULL
160
160
#define MAR_TIME_ONE_DAY         86400000000000ULL
161
 
#define MAR_TIME_MAX             SA_TIME_END
 
161
#define MAR_TIME_MAX             CS_TIME_END
162
162
 
163
163
#define MAR_TRACK_CURRENT 0x01
164
164
#define MAR_TRACK_CHANGES 0x02
177
177
{
178
178
        swab_mar_uint64_t (to_swab);
179
179
}
180
 
#endif /* AIS_MAR_GEN_TYPES_H_DEFINED */
 
180
 
 
181
static inline void swab_coroipc_request_header_t (coroipc_request_header_t *to_swab)
 
182
{
 
183
        swab_mar_int32_t (&to_swab->size);
 
184
        swab_mar_int32_t (&to_swab->id);
 
185
}
 
186
 
 
187
#endif /* MAR_GEN_H_DEFINED */