Revert "Remove useless const qualifier"
[lttng-ust.git] / liblttng-ust / compat.h
CommitLineData
b728d87e
MD
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
48621a42
MD
17/*
18 * lttng_ust_getprocname.
19 */
20#ifdef __linux__
21
22#include <sys/prctl.h>
23
24#define LTTNG_UST_PROCNAME_LEN 17
25
26static inline
27void 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 */
45static inline
46void 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
e5757a90
MD
58#include <errno.h>
59
60#ifndef ENODATA
61#define ENODATA ENOMSG
62#endif
63
b728d87e 64#endif /* _UST_COMPAT_H */
This page took 0.025512 seconds and 4 git commands to generate.