Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CarlaMemUtils.hpp 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Carla shared memory utils
  3. * Copyright (C) 2023 Filipe Coelho <falktx@falktx.com>
  4. *
  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.
  9. *
  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.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_MEM_UTILS_HPP_INCLUDED
  18. #define CARLA_MEM_UTILS_HPP_INCLUDED
  19. #include "CarlaUtils.hpp"
  20. #if !defined(CARLA_OS_WASM) && !defined(CARLA_OS_WIN)
  21. # include <sys/mman.h>
  22. #endif
  23. // --------------------------------------------------------------------------------------------------------------------
  24. static inline
  25. bool carla_mlock(void* const ptr, const size_t size)
  26. {
  27. #if defined(CARLA_OS_WASM)
  28. // unsupported
  29. return false;
  30. (void)ptr; (void)size;
  31. #elif defined(CARLA_OS_WIN)
  32. return ::VirtualLock(ptr, size) != FALSE;
  33. #else
  34. return ::mlock(ptr, size) == 0;
  35. #endif
  36. }
  37. // --------------------------------------------------------------------------------------------------------------------
  38. #endif // CARLA_MEM_UTILS_HPP_INCLUDED