VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / utils / CarlaMemUtils.hpp
blob3c51be23e389bf02f098d401c8448096e9bcf87e
1 /*
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>
25 #endif
27 // --------------------------------------------------------------------------------------------------------------------
29 static inline
30 bool carla_mlock(void* const ptr, const size_t size)
32 #if defined(CARLA_OS_WASM)
33 // unsupported
34 return false;
35 (void)ptr; (void)size;
36 #elif defined(CARLA_OS_WIN)
37 return ::VirtualLock(ptr, size) != FALSE;
38 #else
39 return ::mlock(ptr, size) == 0;
40 #endif
43 // --------------------------------------------------------------------------------------------------------------------
45 #endif // CARLA_MEM_UTILS_HPP_INCLUDED