summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/compat-uuid.h
blob: 4161b958508099a3caabb97bb43c8e55c15c4c28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
 * Copyright (c) 2015 Red Hat, Inc. <http://www.redhat.com>
 * This file is part of GlusterFS.
 *
 * This file is licensed to you under your choice of the GNU Lesser
 * General Public License, version 3 or any later version (LGPLv3 or
 * later), or the GNU General Public License, version 2 (GPLv2), in all
 * cases as published by the Free Software Foundation.
 */

#ifndef _GF_UUID_H
#define _GF_UUID_H

#if defined(HAVE_LIBUUID) /* Linux like libuuid.so */

#include <uuid.h>

static inline void
gf_uuid_clear (uuid_t uuid)
{
        uuid_clear (uuid);
}

static inline int
gf_uuid_compare (uuid_t u1, uuid_t u2)
{
        return uuid_compare (u1, u2);
}

static inline void
gf_uuid_copy (uuid_t dst, uuid_t src)
{
        uuid_copy (dst, src);
}

static inline void
gf_uuid_generate (uuid_t uuid)
{
        uuid_generate  (uuid);
}

static inline int
gf_uuid_is_null (uuid_t uuid)
{
        return uuid_is_null (uuid);
}

static inline int
gf_uuid_parse (const char *in, uuid_t uuid)
{
        return uuid_parse (in, uuid);
}

static inline void
gf_uuid_unparse (const uuid_t uuid, char *out)
{
        uuid_unparse (uuid, out);
}

/* TODO: add more uuid APIs, use constructs like this:
#elif defined(__NetBSD__) * NetBSD libc *

#include <string.h>

static inline void
gf_uuid_clear (uuid_t uuid)
{
        memset (uuid, 0, sizeof (uuid_t));
}

*/

#else /* use bundled Linux like libuuid from contrib/uuid/ */

#include "uuid.h"

#endif /* HAVE_UUID */
#endif /* _GF_UUID_H */