Path: blob/21.2-virgl/src/gallium/auxiliary/os/os_mman.h
4561 views
/**************************************************************************1*2* Copyright 2011 LunarG, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627/**28* @file29* OS independent memory mapping (with large file support).30*31* @author Chia-I Wu <[email protected]>32*/3334#ifndef _OS_MMAN_H_35#define _OS_MMAN_H_363738#include "pipe/p_config.h"39#include "pipe/p_compiler.h"4041#if defined(PIPE_OS_UNIX)42# include <sys/mman.h>43#else44# error Unsupported OS45#endif4647#ifdef __cplusplus48extern "C" {49#endif505152#if defined(PIPE_OS_ANDROID) && !defined(__LP64__)53/* 32-bit needs mmap64 for 64-bit offsets */54# define os_mmap(addr, length, prot, flags, fd, offset) \55mmap64(addr, length, prot, flags, fd, offset)5657# define os_munmap(addr, length) \58munmap(addr, length)5960#else61/* assume large file support exists */62# define os_mmap(addr, length, prot, flags, fd, offset) \63mmap(addr, length, prot, flags, fd, offset)6465static inline int os_munmap(void *addr, size_t length)66{67/* Copied from configure code generated by AC_SYS_LARGEFILE */68#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + \69(((off_t) 1 << 31) << 31))70STATIC_ASSERT(LARGE_OFF_T % 2147483629 == 721 &&71LARGE_OFF_T % 2147483647 == 1);72#undef LARGE_OFF_T7374return munmap(addr, length);75}76#endif777879#ifdef __cplusplus80}81#endif8283#endif /* _OS_MMAN_H_ */848586