diff options
author | Niels de Vos <ndevos@redhat.com> | 2015-04-03 18:14:13 +0200 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-04-10 11:39:52 +0000 |
commit | 6eb27480b6559103e4437facd7aecbcd373479c9 (patch) | |
tree | 946b5531baddce4387ac7786f7230c3d52dd1161 /libglusterfs/src/compat-uuid.h | |
parent | 26cbd3bdf5dad190559afbdf0ac125262c4e90a6 (diff) |
build: make contrib/uuid dependency optional
On Linux systems we should use the libuuid from the distribution and not
bundle and statically link the contrib/uuid/ bits.
libglusterfs/src/compat-uuid.h has been introduced and should become an
abstraction layer for different UUID APIs. Non-Linux operating systems
should implement their compatibility layer there.
Once all operating systems have an implementation in compat-uuid.h, we
can remove contrib/uuid/ from the repository completely.
Change-Id: I345e5357644be2521685e00358bb8c83c4ea0577
BUG: 1206587
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/10129
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'libglusterfs/src/compat-uuid.h')
-rw-r--r-- | libglusterfs/src/compat-uuid.h | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/libglusterfs/src/compat-uuid.h b/libglusterfs/src/compat-uuid.h new file mode 100644 index 00000000000..4161b958508 --- /dev/null +++ b/libglusterfs/src/compat-uuid.h @@ -0,0 +1,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 */ |