github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/include/jit/jit-vmem.h (about)

     1  /*
     2   * jit-vmem.h - Virtual memory routines.
     3   *
     4   * Copyright (C) 2011  Aleksey Demakov
     5   *
     6   * The libjit library is free software: you can redistribute it and/or
     7   * modify it under the terms of the GNU Lesser General Public License
     8   * as published by the Free Software Foundation, either version 2.1 of
     9   * the License, or (at your option) any later version.
    10   *
    11   * The libjit library is distributed in the hope that it will be useful,
    12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    14   * Lesser General Public License for more details.
    15   *
    16   * You should have received a copy of the GNU Lesser General Public
    17   * License along with the libjit library.  If not, see
    18   * <http://www.gnu.org/licenses/>.
    19   */
    20  
    21  #ifndef _JIT_VMEM_H
    22  #define	_JIT_VMEM_H
    23  
    24  #include <jit/jit-defs.h>
    25  
    26  #ifdef	__cplusplus
    27  extern "C" {
    28  #endif
    29  
    30  typedef enum {
    31  	JIT_PROT_NONE,
    32  	JIT_PROT_READ,
    33  	JIT_PROT_READ_WRITE,
    34  	JIT_PROT_EXEC_READ,
    35  	JIT_PROT_EXEC_READ_WRITE,
    36  } jit_prot_t;
    37  
    38  
    39  void jit_vmem_init(void);
    40  
    41  jit_uint jit_vmem_page_size(void);
    42  jit_nuint jit_vmem_round_up(jit_nuint value);
    43  jit_nuint jit_vmem_round_down(jit_nuint value);
    44  
    45  void *jit_vmem_reserve(jit_uint size);
    46  void *jit_vmem_reserve_committed(jit_uint size, jit_prot_t prot);
    47  int jit_vmem_release(void *addr, jit_uint size);
    48  
    49  int jit_vmem_commit(void *addr, jit_uint size, jit_prot_t prot);
    50  int jit_vmem_decommit(void *addr, jit_uint size);
    51  
    52  int jit_vmem_protect(void *addr, jit_uint size, jit_prot_t prot);
    53  
    54  #ifdef	__cplusplus
    55  }
    56  #endif
    57  
    58  #endif	/* _JIT_VMEM_H */