tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

linux_memfd_defs.h (2252B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef BASE_LINUX_MEMFD_DEFS_H
      8 #define BASE_LINUX_MEMFD_DEFS_H
      9 
     10 #include <sys/syscall.h>
     11 
     12 // glibc before 2.27 didn't have a memfd_create wrapper, and if the
     13 // build system is old enough then it won't have the syscall number
     14 // and various related constants either.
     15 
     16 #if defined(__x86_64__)
     17 #  define MEMFD_CREATE_NR 319
     18 #elif defined(__i386__)
     19 #  define MEMFD_CREATE_NR 356
     20 #elif defined(__aarch64__)
     21 #  define MEMFD_CREATE_NR 279
     22 #elif defined(__arm__)
     23 #  define MEMFD_CREATE_NR 385
     24 #elif defined(__powerpc__)
     25 #  define MEMFD_CREATE_NR 360
     26 #elif defined(__s390__)
     27 #  define MEMFD_CREATE_NR 350
     28 #elif defined(__mips__)
     29 #  include <sgidefs.h>
     30 #  if _MIPS_SIM == _MIPS_SIM_ABI32
     31 #    define MEMFD_CREATE_NR 4354
     32 #  elif _MIPS_SIM == _MIPS_SIM_ABI64
     33 #    define MEMFD_CREATE_NR 5314
     34 #  elif _MIPS_SIM == _MIPS_SIM_NABI32
     35 #    define MEMFD_CREATE_NR 6318
     36 #  endif  // mips subarch
     37 #endif    // arch
     38 
     39 #ifdef MEMFD_CREATE_NR
     40 #  ifdef SYS_memfd_create
     41 static_assert(MEMFD_CREATE_NR == SYS_memfd_create,
     42              "MEMFD_CREATE_NR should match the actual SYS_memfd_create value");
     43 #  else  // defined here but not in system headers
     44 #    define SYS_memfd_create MEMFD_CREATE_NR
     45 #  endif
     46 #endif
     47 
     48 #ifndef MFD_CLOEXEC
     49 #  define MFD_CLOEXEC 0x0001U
     50 #  define MFD_ALLOW_SEALING 0x0002U
     51 #endif
     52 
     53 #ifndef MFD_NOEXEC_SEAL
     54 #  define MFD_NOEXEC_SEAL 0x0008U
     55 #endif
     56 
     57 #ifndef F_ADD_SEALS
     58 #  ifndef F_LINUX_SPECIFIC_BASE
     59 #    define F_LINUX_SPECIFIC_BASE 1024
     60 #  endif
     61 #  define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
     62 #  define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
     63 #  define F_SEAL_SEAL 0x0001   /* prevent further seals from being set */
     64 #  define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
     65 #  define F_SEAL_GROW 0x0004   /* prevent file from growing */
     66 #  define F_SEAL_WRITE 0x0008  /* prevent writes */
     67 #endif
     68 
     69 #ifndef F_SEAL_FUTURE_WRITE
     70 #  define F_SEAL_FUTURE_WRITE 0x0010
     71 #endif
     72 
     73 #endif  // BASE_LINUX_MEMFD_DEFS_H