mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
core: Replace PA_PAGE_SIZE with pa_page_size()
PA_PAGE_SIZE using sysconf() may return a negative number CID 1137925, CID 1137926, CID 1138485 instead of calling sysconf() directly, add function pa_page_size() which uses the guestimate 4096 in case sysconf(_SC_PAGE_SIZE) fails using PA_ONCE to only evaluate sysconf() once
This commit is contained in:
parent
c99efbffd6
commit
45d9030638
10 changed files with 55 additions and 38 deletions
|
|
@ -44,17 +44,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PAGE_SIZE)
|
||||
#define PA_PAGE_SIZE ((size_t) PAGE_SIZE)
|
||||
#elif defined(PAGESIZE)
|
||||
#define PA_PAGE_SIZE ((size_t) PAGESIZE)
|
||||
#elif defined(HAVE_SYSCONF)
|
||||
#define PA_PAGE_SIZE ((size_t) (sysconf(_SC_PAGE_SIZE)))
|
||||
#else
|
||||
/* Let's hope it's like x86. */
|
||||
#define PA_PAGE_SIZE ((size_t) 4096)
|
||||
#endif
|
||||
|
||||
/* Rounds down */
|
||||
static inline void* PA_ALIGN_PTR(const void *p) {
|
||||
return (void*) (((size_t) p) & ~(sizeof(void*) - 1));
|
||||
|
|
@ -65,16 +54,6 @@ static inline size_t PA_ALIGN(size_t l) {
|
|||
return ((l + sizeof(void*) - 1) & ~(sizeof(void*) - 1));
|
||||
}
|
||||
|
||||
/* Rounds down */
|
||||
static inline void* PA_PAGE_ALIGN_PTR(const void *p) {
|
||||
return (void*) (((size_t) p) & ~(PA_PAGE_SIZE - 1));
|
||||
}
|
||||
|
||||
/* Rounds up */
|
||||
static inline size_t PA_PAGE_ALIGN(size_t l) {
|
||||
return (l + PA_PAGE_SIZE - 1) & ~(PA_PAGE_SIZE - 1);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define PA_UNUSED __attribute__ ((unused))
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue