Path: blob/main/contrib/llvm-project/compiler-rt/lib/profile/WindowsMMap.h
35233 views
/*===- WindowsMMap.h - Support library for PGO instrumentation ------------===*\1|*2|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3|* See https://llvm.org/LICENSE.txt for license information.4|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5|*6\*===----------------------------------------------------------------------===*/78#ifndef PROFILE_INSTRPROFILING_WINDOWS_MMAP_H9#define PROFILE_INSTRPROFILING_WINDOWS_MMAP_H1011#if defined(_WIN32)1213#include <basetsd.h>14#include <io.h>15#include <sys/types.h>1617/*18* mmap() flags19*/20#define PROT_READ 0x121#define PROT_WRITE 0x222#define PROT_EXEC 0x02324#define MAP_FILE 0x0025#define MAP_SHARED 0x0126#define MAP_PRIVATE 0x0227#define MAP_ANONYMOUS 0x2028#define MAP_ANON MAP_ANONYMOUS29#define MAP_FAILED ((void *) -1)3031/*32* msync() flags33*/34#define MS_ASYNC 0x0001 /* return immediately */35#define MS_INVALIDATE 0x0002 /* invalidate all cached data */36#define MS_SYNC 0x0010 /* msync synchronously */3738/*39* madvise() flags40*/4142#define MADV_NORMAL 0 /* no special treatment */43#define MADV_WILLNEED 3 /* expect access in the near future */44#define MADV_DONTNEED 4 /* do not expect access in the near future */4546/*47* flock() operations48*/49#define LOCK_SH 1 /* shared lock */50#define LOCK_EX 2 /* exclusive lock */51#define LOCK_NB 4 /* don't block when locking */52#define LOCK_UN 8 /* unlock */5354#ifdef __USE_FILE_OFFSET6455# define DWORD_HI(x) (x >> 32)56# define DWORD_LO(x) ((x) & 0xffffffff)57#else58# define DWORD_HI(x) (0)59# define DWORD_LO(x) (x)60#endif6162#define mmap __llvm_profile_mmap63#define munmap __llvm_profile_munmap64#define msync __llvm_profile_msync65#define madvise __llvm_profile_madvise66#define flock __llvm_profile_flock6768void *mmap(void *start, size_t length, int prot, int flags, int fd,69off_t offset);7071void munmap(void *addr, size_t length);7273int msync(void *addr, size_t length, int flags);7475int madvise(void *addr, size_t length, int advice);7677int flock(int fd, int operation);7879#endif /* _WIN32 */8081#endif /* PROFILE_INSTRPROFILING_WINDOWS_MMAP_H */828384