daemon: add nice value in service file to improve performance
[platform/upstream/pulseaudio.git] / src / pulsecore / mem.h
1 #ifndef foopulsememhfoo
2 #define foopulsememhfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2016 Ahmed S. Darwish <darwish.07@gmail.com>
8
9   PulseAudio is free software; you can redistribute it and/or modify
10   it under the terms of the GNU Lesser General Public License as
11   published by the Free Software Foundation; either version 2.1 of the
12   License, or (at your option) any later version.
13
14   PulseAudio is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   Lesser General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public
20   License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <stdbool.h>
24
25 #include <pulsecore/creds.h>
26 #include <pulsecore/macro.h>
27
28 typedef enum pa_mem_type {
29     PA_MEM_TYPE_SHARED_POSIX,         /* Data is shared and created using POSIX shm_open() */
30     PA_MEM_TYPE_SHARED_MEMFD,         /* Data is shared and created using Linux memfd_create() */
31     PA_MEM_TYPE_PRIVATE,              /* Data is private and created using classic memory allocation
32                                          (posix_memalign(), malloc() or anonymous mmap()) */
33 } pa_mem_type_t;
34
35 static inline const char *pa_mem_type_to_string(pa_mem_type_t type) {
36     switch (type) {
37     case PA_MEM_TYPE_SHARED_POSIX:
38         return "shared posix-shm";
39     case PA_MEM_TYPE_SHARED_MEMFD:
40         return "shared memfd";
41     case PA_MEM_TYPE_PRIVATE:
42         return "private";
43     }
44
45     pa_assert_not_reached();
46 }
47
48 static inline bool pa_mem_type_is_shared(pa_mem_type_t t) {
49     return (t == PA_MEM_TYPE_SHARED_POSIX) || (t == PA_MEM_TYPE_SHARED_MEMFD);
50 }
51
52 static inline bool pa_memfd_is_locally_supported(void) {
53 #if defined(HAVE_CREDS) && defined(HAVE_MEMFD)
54     return true;
55 #else
56     return false;
57 #endif
58 }
59
60 #endif