2 * Carla shared memory utils
3 * Copyright (C) 2023 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_MEM_UTILS_HPP_INCLUDED
19 #define CARLA_MEM_UTILS_HPP_INCLUDED
21 #include "CarlaUtils.hpp"
23 #if !defined(CARLA_OS_WASM) && !defined(CARLA_OS_WIN)
24 # include <sys/mman.h>
27 // --------------------------------------------------------------------------------------------------------------------
30 bool carla_mlock(void* const ptr
, const size_t size
)
32 #if defined(CARLA_OS_WASM)
35 (void)ptr
; (void)size
;
36 #elif defined(CARLA_OS_WIN)
37 return ::VirtualLock(ptr
, size
) != FALSE
;
39 return ::mlock(ptr
, size
) == 0;
43 // --------------------------------------------------------------------------------------------------------------------
45 #endif // CARLA_MEM_UTILS_HPP_INCLUDED