83 lines · c
1/*===- WindowsMMap.h - Support library for PGO instrumentation ------------===*\2|*3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4|* See https://llvm.org/LICENSE.txt for license information.5|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6|*7\*===----------------------------------------------------------------------===*/8 9#ifndef PROFILE_INSTRPROFILING_WINDOWS_MMAP_H10#define PROFILE_INSTRPROFILING_WINDOWS_MMAP_H11 12#if defined(_WIN32)13 14#include <basetsd.h>15#include <io.h>16#include <sys/types.h>17 18/*19 * mmap() flags20 */21#define PROT_READ 0x122#define PROT_WRITE 0x223#define PROT_EXEC 0x024 25#define MAP_FILE 0x0026#define MAP_SHARED 0x0127#define MAP_PRIVATE 0x0228#define MAP_ANONYMOUS 0x2029#define MAP_ANON MAP_ANONYMOUS30#define MAP_FAILED ((void *) -1)31 32/*33 * msync() flags34 */35#define MS_ASYNC 0x0001 /* return immediately */36#define MS_INVALIDATE 0x0002 /* invalidate all cached data */37#define MS_SYNC 0x0010 /* msync synchronously */38 39/*40 * madvise() flags41 */42 43#define MADV_NORMAL 0 /* no special treatment */44#define MADV_WILLNEED 3 /* expect access in the near future */45#define MADV_DONTNEED 4 /* do not expect access in the near future */46 47/*48 * flock() operations49 */50#define LOCK_SH 1 /* shared lock */51#define LOCK_EX 2 /* exclusive lock */52#define LOCK_NB 4 /* don't block when locking */53#define LOCK_UN 8 /* unlock */54 55#ifdef __USE_FILE_OFFSET6456# define DWORD_HI(x) (x >> 32)57# define DWORD_LO(x) ((x) & 0xffffffff)58#else59# define DWORD_HI(x) (0)60# define DWORD_LO(x) (x)61#endif62 63#define mmap __llvm_profile_mmap64#define munmap __llvm_profile_munmap65#define msync __llvm_profile_msync66#define madvise __llvm_profile_madvise67#define flock __llvm_profile_flock68 69void *mmap(void *start, size_t length, int prot, int flags, int fd,70 off_t offset);71 72void munmap(void *addr, size_t length);73 74int msync(void *addr, size_t length, int flags);75 76int madvise(void *addr, size_t length, int advice);77 78int flock(int fd, int operation);79 80#endif /* _WIN32 */81 82#endif /* PROFILE_INSTRPROFILING_WINDOWS_MMAP_H */83