configure.ac: check for both libuuid/libc uuid APIs
[lttng-ust.git] / liblttng-ust / compat.h
1 #ifndef _UST_COMPAT_H
2 #define _UST_COMPAT_H
3
4 /*
5 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 *
7 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
9 *
10 * Permission is hereby granted to use or copy this program
11 * for any purpose, provided the above notices are retained on all copies.
12 * Permission to modify the code and to distribute modified code is granted,
13 * provided the above notices are retained, and a notice that the code was
14 * modified is included with the above copyright notice.
15 */
16
17 /*
18 * lttng_ust_getprocname.
19 */
20 #ifdef __linux__
21
22 #include <sys/prctl.h>
23
24 #define LTTNG_UST_PROCNAME_LEN 17
25
26 static inline
27 void lttng_ust_getprocname(char *name)
28 {
29 (void) prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0);
30 }
31
32 #elif defined(__FreeBSD__)
33 #include <stdlib.h>
34 #include <string.h>
35
36 /*
37 * Limit imposed by Linux UST-sessiond ABI.
38 */
39 #define LTTNG_UST_PROCNAME_LEN 17
40
41 /*
42 * Acts like linux prctl, the string is not necessarily 0-terminated if
43 * 16-byte long.
44 */
45 static inline
46 void lttng_ust_getprocname(char *name)
47 {
48 const char *bsd_name;
49
50 bsd_name = getprogname();
51 if (!bsd_name)
52 name[0] = '\0';
53 memcpy(name, bsd_name, LTTNG_UST_PROCNAME_LEN - 1);
54 }
55
56 #endif
57
58 #include <errno.h>
59
60 #ifndef ENODATA
61 #define ENODATA ENOMSG
62 #endif
63
64 #endif /* _UST_COMPAT_H */
This page took 0.030675 seconds and 4 git commands to generate.