From 0e214bdfd1dd2e963200875bc8f5ea31e5262503 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Fri, 1 Apr 2016 16:38:15 -0700 Subject: [PATCH] syscall_emul: factor out flag tables into common file The openFlagTable and mmapFlagTables for emulated Linux platforms are basically identical, but are specified repetitively for every platform. Use a common file that gets included for each platform so that we only have one copy, making them more consistent and simplifying changes (like adding #ifdefs). In the process, made some minor fixes that slipped through due to previous inconsistencies, and added more #ifdefs to try to fix building on alternative hosts. --- src/arch/alpha/linux/linux.cc | 94 +--------------- src/arch/arm/linux/linux.cc | 206 +--------------------------------- src/arch/mips/linux/linux.cc | 93 +-------------- src/arch/mips/linux/linux.hh | 1 + src/arch/power/linux/linux.cc | 99 +--------------- src/arch/sparc/linux/linux.cc | 94 +--------------- src/arch/sparc/linux/linux.hh | 3 +- src/arch/x86/linux/linux.cc | 198 ++------------------------------ src/kern/linux/flag_tables.hh | 156 +++++++++++++++++++++++++ 9 files changed, 179 insertions(+), 765 deletions(-) create mode 100644 src/kern/linux/flag_tables.hh diff --git a/src/arch/alpha/linux/linux.cc b/src/arch/alpha/linux/linux.cc index 7b747f127..07c90ea83 100644 --- a/src/arch/alpha/linux/linux.cc +++ b/src/arch/alpha/linux/linux.cc @@ -33,95 +33,5 @@ #include #include -// open(2) flags translation table -SyscallFlagTransTable AlphaLinux::openFlagTable[] = { -#ifdef _MSC_VER - { AlphaLinux::TGT_O_RDONLY, _O_RDONLY }, - { AlphaLinux::TGT_O_WRONLY, _O_WRONLY }, - { AlphaLinux::TGT_O_RDWR, _O_RDWR }, - { AlphaLinux::TGT_O_CREAT, _O_CREAT }, - { AlphaLinux::TGT_O_EXCL, _O_EXCL }, -#ifdef _O_NOCTTY - { AlphaLinux::TGT_O_NOCTTY, _O_NOCTTY }, -#endif - { AlphaLinux::TGT_O_TRUNC, _O_TRUNC }, - { AlphaLinux::TGT_O_APPEND, _O_APPEND }, -#ifdef _O_NONBLOCK - { AlphaLinux::TGT_O_NONBLOCK, _O_NONBLOCK }, -#endif -#ifdef _O_DSYNC - { AlphaLinux::TGT_O_DSYNC, _O_DSYNC }, -#endif - { AlphaLinux::TGT_FASYNC, _O_ASYNC }, - { AlphaLinux::TGT_O_DIRECT, _O_DIRECT }, - { AlphaLinux::TGT_O_LARGEFILE, _O_LARGEFILE }, - { AlphaLinux::TGT_O_DIRECTORY, _O_DIRECTORY }, - { AlphaLinux::TGT_O_NOFOLLOW, _O_NOFOLLOW }, - { AlphaLinux::TGT_O_NOATIME, _O_NOATIME }, -#ifdef _O_CLOEXEC - { AlphaLinux::TGT_O_CLOEXEC, _O_CLOEXEC }, -#endif -#ifdef _O_SYNC - { AlphaLinux::TGT_O_SYNC, _O_SYNC }, -#endif -#ifdef _O_PATH - { AlphaLinux::TGT_O_PATH, _O_PATH }, -#endif -#else /* !_MSC_VER */ - { AlphaLinux::TGT_O_RDONLY, O_RDONLY }, - { AlphaLinux::TGT_O_WRONLY, O_WRONLY }, - { AlphaLinux::TGT_O_RDWR, O_RDWR }, - { AlphaLinux::TGT_O_CREAT, O_CREAT }, - { AlphaLinux::TGT_O_EXCL, O_EXCL }, - { AlphaLinux::TGT_O_NOCTTY, O_NOCTTY }, - { AlphaLinux::TGT_O_TRUNC, O_TRUNC }, - { AlphaLinux::TGT_O_APPEND, O_APPEND }, - { AlphaLinux::TGT_O_NONBLOCK, O_NONBLOCK }, -#ifdef O_DSYNC - { AlphaLinux::TGT_O_DSYNC, O_DSYNC }, -#endif - { AlphaLinux::TGT_FASYNC, O_ASYNC }, - { AlphaLinux::TGT_O_DIRECT, O_DIRECT }, - { AlphaLinux::TGT_O_LARGEFILE, O_LARGEFILE }, - { AlphaLinux::TGT_O_DIRECTORY, O_DIRECTORY }, - { AlphaLinux::TGT_O_NOFOLLOW, O_NOFOLLOW }, - { AlphaLinux::TGT_O_NOATIME, O_NOATIME }, -#ifdef O_CLOEXEC - { AlphaLinux::TGT_O_CLOEXEC, O_CLOEXEC }, -#endif -#ifdef O_SYNC - { AlphaLinux::TGT_O_SYNC, O_SYNC }, -#endif -#ifdef O_PATH - { AlphaLinux::TGT_O_PATH, O_PATH }, -#endif -#endif /* _MSC_VER */ -}; - -const int AlphaLinux::NUM_OPEN_FLAGS = - (sizeof(AlphaLinux::openFlagTable)/sizeof(AlphaLinux::openFlagTable[0])); - -// mmap(2) flags translation table -SyscallFlagTransTable AlphaLinux::mmapFlagTable[] = { - { AlphaLinux::TGT_MAP_SHARED, MAP_SHARED }, - { AlphaLinux::TGT_MAP_PRIVATE, MAP_PRIVATE }, - { AlphaLinux::TGT_MAP_ANON, MAP_ANON }, - { AlphaLinux::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, - { AlphaLinux::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, - { AlphaLinux::TGT_MAP_FILE, MAP_FILE }, - { AlphaLinux::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, - { AlphaLinux::TGT_MAP_HUGETLB, MAP_HUGETLB }, - { AlphaLinux::TGT_MAP_LOCKED, MAP_LOCKED }, - { AlphaLinux::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, - { AlphaLinux::TGT_MAP_NORESERVE, MAP_NORESERVE }, - { AlphaLinux::TGT_MAP_POPULATE, MAP_POPULATE }, -#ifdef MAP_STACK - { AlphaLinux::TGT_MAP_STACK, MAP_STACK }, -#endif - { AlphaLinux::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, - { AlphaLinux::TGT_MAP_FIXED, MAP_FIXED }, -}; - -const unsigned AlphaLinux::NUM_MMAP_FLAGS = - sizeof(AlphaLinux::mmapFlagTable) / - sizeof(AlphaLinux::mmapFlagTable[0]); +#define TARGET AlphaLinux +#include "kern/linux/flag_tables.hh" diff --git a/src/arch/arm/linux/linux.cc b/src/arch/arm/linux/linux.cc index 3dde8c217..1c10d410c 100644 --- a/src/arch/arm/linux/linux.cc +++ b/src/arch/arm/linux/linux.cc @@ -46,205 +46,9 @@ #include #include -// open(2) flags translation table -SyscallFlagTransTable ArmLinux32::openFlagTable[] = { -#ifdef _MSC_VER - { ArmLinux32::TGT_O_RDONLY, _O_RDONLY }, - { ArmLinux32::TGT_O_WRONLY, _O_WRONLY }, - { ArmLinux32::TGT_O_RDWR, _O_RDWR }, - { ArmLinux32::TGT_O_CREAT, _O_CREAT }, - { ArmLinux32::TGT_O_EXCL, _O_EXCL }, -#ifdef _O_NOCTTY - { ArmLinux32::TGT_O_NOCTTY, _O_NOCTTY }, -#endif - { ArmLinux32::TGT_O_TRUNC, _O_TRUNC }, - { ArmLinux32::TGT_O_APPEND, _O_APPEND }, -#ifdef _O_NONBLOCK - { ArmLinux32::TGT_O_NONBLOCK, _O_NONBLOCK }, -#endif -#ifdef _O_DSYNC - { ArmLinux32::TGT_O_DSYNC, _O_DSYNC }, -#endif - { ArmLinux32::TGT_FASYNC, _O_ASYNC }, - { ArmLinux32::TGT_O_DIRECT, _O_DIRECT }, - { ArmLinux32::TGT_O_LARGEFILE, _O_LARGEFILE }, - { ArmLinux32::TGT_O_DIRECTORY, _O_DIRECTORY }, - { ArmLinux32::TGT_O_NOFOLLOW, _O_NOFOLLOW }, - { ArmLinux32::TGT_O_NOATIME, _O_NOATIME }, -#ifdef _O_CLOEXEC - { ArmLinux32::TGT_O_CLOEXEC, _O_CLOEXEC }, -#endif -#ifdef _O_SYNC - { ArmLinux32::TGT_O_SYNC, _O_SYNC }, -#endif -#ifdef _O_PATH - { ArmLinux32::TGT_O_PATH, _O_PATH }, -#endif -#else /* !_MSC_VER */ - { ArmLinux32::TGT_O_RDONLY, O_RDONLY }, - { ArmLinux32::TGT_O_WRONLY, O_WRONLY }, - { ArmLinux32::TGT_O_RDWR, O_RDWR }, - { ArmLinux32::TGT_O_CREAT, O_CREAT }, - { ArmLinux32::TGT_O_EXCL, O_EXCL }, - { ArmLinux32::TGT_O_NOCTTY, O_NOCTTY }, - { ArmLinux32::TGT_O_TRUNC, O_TRUNC }, - { ArmLinux32::TGT_O_APPEND, O_APPEND }, - { ArmLinux32::TGT_O_NONBLOCK, O_NONBLOCK }, -#ifdef O_DSYNC - { ArmLinux32::TGT_O_DSYNC, O_DSYNC }, -#endif - { ArmLinux32::TGT_FASYNC, O_ASYNC }, -#ifdef O_DIRECT - { ArmLinux32::TGT_O_DIRECT, O_DIRECT }, -#endif -#ifdef O_LARGEFILE - { ArmLinux32::TGT_O_LARGEFILE, O_LARGEFILE }, -#endif -#ifdef O_DIRECTORY - { ArmLinux32::TGT_O_DIRECTORY, O_DIRECTORY }, -#endif -#ifdef O_NOFOLLOW - { ArmLinux32::TGT_O_NOFOLLOW, O_NOFOLLOW }, -#endif - { ArmLinux32::TGT_O_NOATIME, O_NOATIME }, -#ifdef O_CLOEXEC - { ArmLinux32::TGT_O_CLOEXEC, O_CLOEXEC }, -#endif -#ifdef O_SYNC - { ArmLinux32::TGT_O_SYNC, O_SYNC }, -#endif -#ifdef O_PATH - { ArmLinux32::TGT_O_PATH, O_PATH }, -#endif -#endif /* _MSC_VER */ -}; - -const int ArmLinux32::NUM_OPEN_FLAGS = sizeof(ArmLinux32::openFlagTable) / - sizeof(ArmLinux32::openFlagTable[0]); - -// mmap(2) flags translation table -SyscallFlagTransTable ArmLinux32::mmapFlagTable[] = { - { ArmLinux32::TGT_MAP_SHARED, MAP_SHARED }, - { ArmLinux32::TGT_MAP_PRIVATE, MAP_PRIVATE }, - { ArmLinux32::TGT_MAP_ANON, MAP_ANON }, - { ArmLinux32::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, - { ArmLinux32::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, - { ArmLinux32::TGT_MAP_FILE, MAP_FILE }, - { ArmLinux32::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, - { ArmLinux32::TGT_MAP_HUGETLB, MAP_HUGETLB }, - { ArmLinux32::TGT_MAP_LOCKED, MAP_LOCKED }, - { ArmLinux32::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, - { ArmLinux32::TGT_MAP_NORESERVE, MAP_NORESERVE }, - { ArmLinux32::TGT_MAP_POPULATE, MAP_POPULATE }, -#ifdef MAP_STACK - { ArmLinux32::TGT_MAP_STACK, MAP_STACK }, -#endif - { ArmLinux32::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, - { ArmLinux32::TGT_MAP_FIXED, MAP_FIXED }, -}; - -const unsigned ArmLinux32::NUM_MMAP_FLAGS = - sizeof(ArmLinux32::mmapFlagTable) / - sizeof(ArmLinux32::mmapFlagTable[0]); - -// open(2) flags translation table -SyscallFlagTransTable ArmLinux64::openFlagTable[] = { -#ifdef _MSC_VER - { ArmLinux64::TGT_O_RDONLY, _O_RDONLY }, - { ArmLinux64::TGT_O_WRONLY, _O_WRONLY }, - { ArmLinux64::TGT_O_RDWR, _O_RDWR }, - { ArmLinux64::TGT_O_CREAT, _O_CREAT }, - { ArmLinux64::TGT_O_EXCL, _O_EXCL }, -#ifdef _O_NOCTTY - { ArmLinux64::TGT_O_NOCTTY, _O_NOCTTY }, -#endif - { ArmLinux64::TGT_O_TRUNC, _O_TRUNC }, - { ArmLinux64::TGT_O_APPEND, _O_APPEND }, -#ifdef _O_NONBLOCK - { ArmLinux64::TGT_O_NONBLOCK, _O_NONBLOCK }, -#endif -#ifdef _O_DSYNC - { ArmLinux64::TGT_O_DSYNC, _O_DSYNC }, -#endif - { ArmLinux64::TGT_FASYNC, _O_ASYNC }, - { ArmLinux64::TGT_O_DIRECT, _O_DIRECT }, - { ArmLinux64::TGT_O_LARGEFILE, _O_LARGEFILE }, - { ArmLinux64::TGT_O_DIRECTORY, _O_DIRECTORY }, - { ArmLinux64::TGT_O_NOFOLLOW, _O_NOFOLLOW }, - { ArmLinux64::TGT_O_NOATIME, _O_NOATIME }, -#ifdef _O_CLOEXEC - { ArmLinux64::TGT_O_CLOEXEC, _O_CLOEXEC }, -#endif -#ifdef _O_SYNC - { ArmLinux64::TGT_O_SYNC, _O_SYNC }, -#endif -#ifdef _O_PATH - { ArmLinux64::TGT_O_PATH, _O_PATH }, -#endif -#else /* !_MSC_VER */ - { ArmLinux64::TGT_O_RDONLY, O_RDONLY }, - { ArmLinux64::TGT_O_WRONLY, O_WRONLY }, - { ArmLinux64::TGT_O_RDWR, O_RDWR }, - { ArmLinux64::TGT_O_CREAT, O_CREAT }, - { ArmLinux64::TGT_O_EXCL, O_EXCL }, - { ArmLinux64::TGT_O_NOCTTY, O_NOCTTY }, - { ArmLinux64::TGT_O_TRUNC, O_TRUNC }, - { ArmLinux64::TGT_O_APPEND, O_APPEND }, - { ArmLinux64::TGT_O_NONBLOCK, O_NONBLOCK }, - { ArmLinux64::TGT_O_DSYNC, O_DSYNC }, -#ifdef FASYNC - { ArmLinux64::TGT_FASYNC, O_ASYNC }, -#endif -#ifdef O_DIRECT - { ArmLinux64::TGT_O_DIRECT, O_DIRECT }, -#endif -#ifdef O_LARGEFILE - { ArmLinux64::TGT_O_LARGEFILE, O_LARGEFILE }, -#endif -#ifdef O_DIRECTORY - { ArmLinux64::TGT_O_DIRECTORY, O_DIRECTORY }, -#endif -#ifdef O_NOFOLLOW - { ArmLinux64::TGT_O_NOFOLLOW, O_NOFOLLOW }, -#endif - { ArmLinux64::TGT_O_NOATIME, O_NOATIME }, -#ifdef O_CLOEXEC - { ArmLinux64::TGT_O_CLOEXEC, O_CLOEXEC }, -#endif -#ifdef O_SYNC - { ArmLinux64::TGT_O_SYNC, O_SYNC }, -#endif -#ifdef O_PATH - { ArmLinux64::TGT_O_PATH, O_PATH }, -#endif -#endif /* _MSC_VER */ -}; - -const int ArmLinux64::NUM_OPEN_FLAGS = sizeof(ArmLinux64::openFlagTable) / - sizeof(ArmLinux64::openFlagTable[0]); - -// mmap(2) flags translation table -SyscallFlagTransTable ArmLinux64::mmapFlagTable[] = { - { ArmLinux64::TGT_MAP_SHARED, MAP_SHARED }, - { ArmLinux64::TGT_MAP_PRIVATE, MAP_PRIVATE }, - { ArmLinux64::TGT_MAP_ANON, MAP_ANON }, - { ArmLinux64::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, - { ArmLinux64::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, - { ArmLinux64::TGT_MAP_FILE, MAP_FILE }, - { ArmLinux64::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, - { ArmLinux64::TGT_MAP_HUGETLB, MAP_HUGETLB }, - { ArmLinux64::TGT_MAP_LOCKED, MAP_LOCKED }, - { ArmLinux64::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, - { ArmLinux64::TGT_MAP_NORESERVE, MAP_NORESERVE }, - { ArmLinux64::TGT_MAP_POPULATE, MAP_POPULATE }, -#ifdef MAP_STACK - { ArmLinux64::TGT_MAP_STACK, MAP_STACK }, -#endif - { ArmLinux64::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, - { ArmLinux64::TGT_MAP_FIXED, MAP_FIXED }, -}; - -const unsigned ArmLinux64::NUM_MMAP_FLAGS = - sizeof(ArmLinux64::mmapFlagTable) / - sizeof(ArmLinux64::mmapFlagTable[0]); +#define TARGET ArmLinux32 +#include "kern/linux/flag_tables.hh" +#undef TARGET +#define TARGET ArmLinux64 +#include "kern/linux/flag_tables.hh" diff --git a/src/arch/mips/linux/linux.cc b/src/arch/mips/linux/linux.cc index 2f0ca6090..e99bd9810 100644 --- a/src/arch/mips/linux/linux.cc +++ b/src/arch/mips/linux/linux.cc @@ -33,94 +33,5 @@ #include #include -// open(2) flags translation table -SyscallFlagTransTable MipsLinux::openFlagTable[] = { -#ifdef _MSC_VER - { MipsLinux::TGT_O_RDONLY, _O_RDONLY }, - { MipsLinux::TGT_O_WRONLY, _O_WRONLY }, - { MipsLinux::TGT_O_RDWR, _O_RDWR }, - { MipsLinux::TGT_O_CREAT, _O_CREAT }, - { MipsLinux::TGT_O_EXCL, _O_EXCL }, -#ifdef _O_NOCTTY - { MipsLinux::TGT_O_NOCTTY, _O_NOCTTY }, -#endif - { MipsLinux::TGT_O_TRUNC, _O_TRUNC }, - { MipsLinux::TGT_O_APPEND, _O_APPEND }, -#ifdef _O_NONBLOCK - { MipsLinux::TGT_O_NONBLOCK, _O_NONBLOCK }, -#endif -#ifdef _O_DSYNC - { MipsLinux::TGT_O_DSYNC, _O_DSYNC }, -#endif - { MipsLinux::TGT_O_DIRECT, _O_DIRECT }, - { MipsLinux::TGT_O_LARGEFILE, _O_LARGEFILE }, - { MipsLinux::TGT_O_DIRECTORY, _O_DIRECTORY }, - { MipsLinux::TGT_O_NOFOLLOW, _O_NOFOLLOW }, - { MipsLinux::TGT_O_NOATIME, _O_NOATIME }, -#ifdef _O_CLOEXEC - { MipsLinux::TGT_O_CLOEXEC, _O_CLOEXEC }, -#endif -#ifdef _O_SYNC - { MipsLinux::TGT_O_SYNC, _O_SYNC }, -#endif -#ifdef _O_PATH - { MipsLinux::TGT_O_PATH, _O_PATH }, -#endif -#else /* !_MSC_VER */ - { MipsLinux::TGT_O_RDONLY, O_RDONLY }, - { MipsLinux::TGT_O_WRONLY, O_WRONLY }, - { MipsLinux::TGT_O_RDWR, O_RDWR }, - { MipsLinux::TGT_O_CREAT, O_CREAT }, - { MipsLinux::TGT_O_EXCL, O_EXCL }, - { MipsLinux::TGT_O_NOCTTY, O_NOCTTY }, - { MipsLinux::TGT_O_TRUNC, O_TRUNC }, - { MipsLinux::TGT_O_APPEND, O_APPEND }, - { MipsLinux::TGT_O_NONBLOCK, O_NONBLOCK }, -#ifdef O_DSYNC - { MipsLinux::TGT_O_DSYNC, O_DSYNC }, -#endif - { MipsLinux::TGT_O_DIRECT, O_DIRECT }, - { MipsLinux::TGT_O_LARGEFILE, O_LARGEFILE }, - { MipsLinux::TGT_O_DIRECTORY, O_DIRECTORY }, - { MipsLinux::TGT_O_NOFOLLOW, O_NOFOLLOW }, - { MipsLinux::TGT_O_NOATIME, O_NOATIME }, -#ifdef O_CLOEXEC - { MipsLinux::TGT_O_CLOEXEC, O_CLOEXEC }, -#endif -#ifdef O_SYNC - { MipsLinux::TGT_O_SYNC, O_SYNC }, -#endif -#ifdef O_PATH - { MipsLinux::TGT_O_PATH, O_PATH }, -#endif -#endif /* _MSC_VER */ -}; - -const int MipsLinux::NUM_OPEN_FLAGS = - (sizeof(MipsLinux::openFlagTable)/sizeof(MipsLinux::openFlagTable[0])); - -// mmap(2) flags translation table -SyscallFlagTransTable MipsLinux::mmapFlagTable[] = { - { MipsLinux::TGT_MAP_SHARED, MAP_SHARED }, - { MipsLinux::TGT_MAP_PRIVATE, MAP_PRIVATE }, - { MipsLinux::TGT_MAP_ANON, MAP_ANON }, - { MipsLinux::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, - { MipsLinux::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, - { MipsLinux::TGT_MAP_FILE, MAP_FILE }, - { MipsLinux::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, - { MipsLinux::TGT_MAP_HUGETLB, MAP_HUGETLB }, - { MipsLinux::TGT_MAP_LOCKED, MAP_LOCKED }, - { MipsLinux::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, - { MipsLinux::TGT_MAP_NORESERVE, MAP_NORESERVE }, - { MipsLinux::TGT_MAP_POPULATE, MAP_POPULATE }, -#ifdef MAP_STACK - { MipsLinux::TGT_MAP_STACK, MAP_STACK }, -#endif - { MipsLinux::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, - { MipsLinux::TGT_MAP_FIXED, MAP_FIXED }, -}; - -const unsigned MipsLinux::NUM_MMAP_FLAGS = - sizeof(MipsLinux::mmapFlagTable) / - sizeof(MipsLinux::mmapFlagTable[0]); - +#define TARGET MipsLinux +#include "kern/linux/flag_tables.hh" diff --git a/src/arch/mips/linux/linux.hh b/src/arch/mips/linux/linux.hh index f4b18397e..e0b785c76 100644 --- a/src/arch/mips/linux/linux.hh +++ b/src/arch/mips/linux/linux.hh @@ -91,6 +91,7 @@ class MipsLinux : public Linux static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND static const int TGT_O_NONBLOCK = 0x00000080; //!< O_NONBLOCK static const int TGT_O_DSYNC = 0x00000010; //!< O_DSYNC + static const int TGT_FASYNC = 0x00001000; //!< O_FASYNC static const int TGT_O_DIRECT = 0x00008000; //!< O_DIRECT static const int TGT_O_LARGEFILE = 0x00002000; //!< O_LARGEFILE static const int TGT_O_DIRECTORY = 0x00010000; //!< O_DIRECTORY diff --git a/src/arch/power/linux/linux.cc b/src/arch/power/linux/linux.cc index 6382ca72a..d569ec279 100644 --- a/src/arch/power/linux/linux.cc +++ b/src/arch/power/linux/linux.cc @@ -34,100 +34,5 @@ #include #include -// open(2) flags translation table -SyscallFlagTransTable PowerLinux::openFlagTable[] = { -#ifdef _MSC_VER - { PowerLinux::TGT_O_RDONLY, _O_RDONLY }, - { PowerLinux::TGT_O_WRONLY, _O_WRONLY }, - { PowerLinux::TGT_O_RDWR, _O_RDWR }, - { PowerLinux::TGT_O_CREAT, _O_CREAT }, - { PowerLinux::TGT_O_EXCL, _O_EXCL }, -#ifdef _O_NOCTTY - { PowerLinux::TGT_O_NOCTTY, _O_NOCTTY }, -#endif - { PowerLinux::TGT_O_TRUNC, _O_TRUNC }, - { PowerLinux::TGT_O_APPEND, _O_APPEND }, -#ifdef _O_NONBLOCK - { PowerLinux::TGT_O_NONBLOCK, _O_NONBLOCK }, -#endif -#ifdef _O_DSYNC - { PowerLinux::TGT_O_DSYNC, _O_DSYNC }, -#endif - { PowerLinux::TGT_FASYNC, _O_ASYNC }, - { PowerLinux::TGT_O_DIRECT, _O_DIRECT }, -#ifdef _O_LARGEFILE - { PowerLinux::TGT_O_LARGEFILE, _O_LARGEFILE }, -#endif - { PowerLinux::TGT_O_DIRECTORY, _O_DIRECTORY }, - { PowerLinux::TGT_O_NOFOLLOW, _O_NOFOLLOW }, - { PowerLinux::TGT_O_NOATIME, _O_NOATIME }, -#ifdef _O_CLOEXEC - { PowerLinux::TGT_O_CLOEXEC, _O_CLOEXEC }, -#endif -#ifdef _O_SYNC - { PowerLinux::TGT_O_SYNC, _O_SYNC }, -#endif -#ifdef _O_PATH - { PowerLinux::TGT_O_PATH, _O_PATH}, -#endif -#else /* !_MSC_VER */ - { PowerLinux::TGT_O_RDONLY, O_RDONLY }, - { PowerLinux::TGT_O_WRONLY, O_WRONLY }, - { PowerLinux::TGT_O_RDWR, O_RDWR }, - { PowerLinux::TGT_O_CREAT, O_CREAT }, - { PowerLinux::TGT_O_EXCL, O_EXCL }, - { PowerLinux::TGT_O_NOCTTY, O_NOCTTY }, - { PowerLinux::TGT_O_TRUNC, O_TRUNC }, - { PowerLinux::TGT_O_APPEND, O_APPEND }, - { PowerLinux::TGT_O_NONBLOCK, O_NONBLOCK }, -#ifdef O_DSYNC - { PowerLinux::TGT_O_DSYNC, O_DSYNC }, -#endif - { PowerLinux::TGT_FASYNC, O_ASYNC }, - { PowerLinux::TGT_O_DIRECT, O_DIRECT }, -#ifdef O_LARGEFILE - { PowerLinux::TGT_O_LARGEFILE, O_LARGEFILE }, -#endif - { PowerLinux::TGT_O_DIRECTORY, O_DIRECTORY }, - { PowerLinux::TGT_O_NOFOLLOW, O_NOFOLLOW }, - { PowerLinux::TGT_O_NOATIME, O_NOATIME }, -#ifdef O_CLOEXEC - { PowerLinux::TGT_O_CLOEXEC, O_CLOEXEC }, -#endif -#ifdef O_SYNC - { PowerLinux::TGT_O_SYNC, O_SYNC }, -#endif -#ifdef O_PATH - { PowerLinux::TGT_O_PATH, O_PATH}, -#endif -#endif /* _MSC_VER */ -}; - -const int PowerLinux::NUM_OPEN_FLAGS = - (sizeof(PowerLinux::openFlagTable)/sizeof(PowerLinux::openFlagTable[0])); - -// mmap(2) flags translation table -SyscallFlagTransTable PowerLinux::mmapFlagTable[] = { - { PowerLinux::TGT_MAP_SHARED, MAP_SHARED }, - { PowerLinux::TGT_MAP_PRIVATE, MAP_PRIVATE }, - { PowerLinux::TGT_MAP_ANON, MAP_ANON }, - { PowerLinux::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, - { PowerLinux::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, - { PowerLinux::TGT_MAP_FILE, MAP_FILE }, - { PowerLinux::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, - { PowerLinux::TGT_MAP_HUGETLB, MAP_HUGETLB }, - { PowerLinux::TGT_MAP_LOCKED, MAP_LOCKED }, - { PowerLinux::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, - { PowerLinux::TGT_MAP_NORESERVE, MAP_NORESERVE }, - { PowerLinux::TGT_MAP_POPULATE, MAP_POPULATE }, -#ifdef MAP_STACK - { PowerLinux::TGT_MAP_STACK, MAP_STACK }, -#endif - { PowerLinux::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, - { PowerLinux::TGT_MAP_FIXED, MAP_FIXED }, -}; - -const unsigned PowerLinux::NUM_MMAP_FLAGS = - sizeof(PowerLinux::mmapFlagTable) / - sizeof(PowerLinux::mmapFlagTable[0]); - +#define TARGET PowerLinux +#include "kern/linux/flag_tables.hh" diff --git a/src/arch/sparc/linux/linux.cc b/src/arch/sparc/linux/linux.cc index dbc7e9691..691124a69 100644 --- a/src/arch/sparc/linux/linux.cc +++ b/src/arch/sparc/linux/linux.cc @@ -33,95 +33,5 @@ #include #include -// open(2) flags translation table -SyscallFlagTransTable SparcLinux::openFlagTable[] = { -#ifdef _MSC_VER - { SparcLinux::TGT_O_RDONLY, _O_RDONLY }, - { SparcLinux::TGT_O_WRONLY, _O_WRONLY }, - { SparcLinux::TGT_O_RDWR, _O_RDWR }, - { SparcLinux::TGT_O_CREAT, _O_CREAT }, - { SparcLinux::TGT_O_EXCL, _O_EXCL }, -#ifdef _O_NOCTTY - { SparcLinux::TGT_O_NOCTTY, _O_NOCTTY }, -#endif - { SparcLinux::TGT_O_TRUNC, _O_TRUNC }, - { SparcLinux::TGT_O_APPEND, _O_APPEND }, -#ifdef _O_NONBLOCK - { SparcLinux::TGT_O_NONBLOCK, _O_NONBLOCK }, -#endif - { SparcLinux::TGT_O_DSYNC, _O_DSYNC }, - { SparcLinux::TGT_FASYNC, _O_ASYNC }, - { SparcLinux::TGT_O_DIRECT, _O_DIRECT }, - { SparcLinux::TGT_O_LARGEFILE, _O_LARGEFILE }, - { SparcLinux::TGT_O_DIRECTORY, _O_DIRECTORY }, - { SparcLinux::TGT_O_NOFOLLOW, _O_NOFOLLOW }, - { SparcLinux::TGT_O_NOATIME, _O_NOATIME }, -#ifdef _O_CLOEXEC - { SparcLinux::TGT_O_CLOEXEC, _O_CLOEXEC }, -#endif -#ifdef _O_SYNC - { SparcLinux::TGT_O_SYNC, _O_SYNC }, -#endif -#ifdef _O_PATH - { SparcLinux::TGT_O_PATH, _O_PATH }, -#endif -#else /* !_MSC_VER */ - { SparcLinux::TGT_O_RDONLY, O_RDONLY }, - { SparcLinux::TGT_O_WRONLY, O_WRONLY }, - { SparcLinux::TGT_O_RDWR, O_RDWR }, - { SparcLinux::TGT_O_CREAT, O_CREAT }, - { SparcLinux::TGT_O_EXCL, O_EXCL }, - { SparcLinux::TGT_O_NOCTTY, O_NOCTTY }, - { SparcLinux::TGT_O_TRUNC, O_TRUNC }, - { SparcLinux::TGT_O_APPEND, O_APPEND }, - { SparcLinux::TGT_O_NONBLOCK, O_NONBLOCK }, - { SparcLinux::TGT_FASYNC, O_ASYNC }, - { SparcLinux::TGT_O_DIRECT, O_DIRECT }, - { SparcLinux::TGT_O_LARGEFILE, O_LARGEFILE }, - { SparcLinux::TGT_O_DIRECTORY, O_DIRECTORY }, - { SparcLinux::TGT_O_NOFOLLOW, O_NOFOLLOW }, - { SparcLinux::TGT_O_NOATIME, O_NOATIME }, -#ifdef O_CLOEXEC - { SparcLinux::TGT_O_CLOEXEC, O_CLOEXEC }, -#endif -#ifdef O_SYNC - { SparcLinux::TGT_O_SYNC, O_SYNC }, -#endif -#ifdef _O_PATH - { SparcLinux::TGT_O_PATH, O_PATH }, -#endif -#endif /* _MSC_VER */ -}; - -const int SparcLinux::NUM_OPEN_FLAGS = - (sizeof(SparcLinux::openFlagTable)/sizeof(SparcLinux::openFlagTable[0])); - -// mmap(2) flags translation table -SyscallFlagTransTable SparcLinux::mmapFlagTable[] = { - { SparcLinux::TGT_MAP_SHARED, MAP_SHARED }, - { SparcLinux::TGT_MAP_PRIVATE, MAP_PRIVATE }, - { SparcLinux::TGT_MAP_ANON, MAP_ANON }, - { SparcLinux::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, - { SparcLinux::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, - { SparcLinux::TGT_MAP_FILE, MAP_FILE }, - { SparcLinux::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, - { SparcLinux::TGT_MAP_HUGETLB, MAP_HUGETLB }, - { SparcLinux::TGT_MAP_LOCKED, MAP_LOCKED }, - { SparcLinux::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, - { SparcLinux::TGT_MAP_NORESERVE, MAP_NORESERVE }, - { SparcLinux::TGT_MAP_POPULATE, MAP_POPULATE }, -#ifdef MAP_STACK - { SparcLinux::TGT_MAP_STACK, MAP_STACK }, -#endif - { SparcLinux::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, - { SparcLinux::TGT_MAP_FIXED, MAP_FIXED }, -#ifdef MAP_INHERIT - { SparcLinux::TGT_MAP_INHERIT, MAP_INHERIT }, -#endif - { SparcLinux::TGT_MAP_POPULATE, MAP_POPULATE }, -}; - -const unsigned SparcLinux::NUM_MMAP_FLAGS = - sizeof(SparcLinux::mmapFlagTable) / - sizeof(SparcLinux::mmapFlagTable[0]); - +#define TARGET SparcLinux +#include "kern/linux/flag_tables.hh" diff --git a/src/arch/sparc/linux/linux.hh b/src/arch/sparc/linux/linux.hh index d0631f82b..d209dcef0 100644 --- a/src/arch/sparc/linux/linux.hh +++ b/src/arch/sparc/linux/linux.hh @@ -106,11 +106,12 @@ class SparcLinux : public Linux static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY - static const int TGT_O_SYNC = 0x00002000; //!< O_SYNC + static const int TGT_O_DSYNC = 0x00002000; //!< O_DSYNC static const int TGT_O_LARGEFILE = 0x00040000; //!< O_LARGEFILE static const int TGT_O_DIRECT = 0x00100000; //!< O_DIRECT static const int TGT_O_NOATIME = 0x00200000; //!< O_NOATIME static const int TGT_O_CLOEXEC = 0x00400000; //!< O_CLOEXEC + static const int TGT_O_SYNC = 0x00802000; //!< O_SYNC static const int TGT_O_PATH = 0x01000000; //!< O_PATH static const int TGT_O_DIRECTORY = 000200000; //!< O_DIRECTORY diff --git a/src/arch/x86/linux/linux.cc b/src/arch/x86/linux/linux.cc index f51bb16e7..a7bf77300 100644 --- a/src/arch/x86/linux/linux.cc +++ b/src/arch/x86/linux/linux.cc @@ -42,196 +42,12 @@ #include #include -// open(2) flags translation table -SyscallFlagTransTable X86Linux64::openFlagTable[] = { -#ifdef _MSC_VER - { X86Linux64::TGT_O_RDONLY, _O_RDONLY }, - { X86Linux64::TGT_O_WRONLY, _O_WRONLY }, - { X86Linux64::TGT_O_RDWR, _O_RDWR }, - { X86Linux64::TGT_O_CREAT, _O_CREAT }, - { X86Linux64::TGT_O_EXCL, _O_EXCL }, -#ifdef _O_NOCTTY - { X86Linux64::TGT_O_NOCTTY, _O_NOCTTY }, -#endif - { X86Linux64::TGT_O_TRUNC, _O_TRUNC }, - { X86Linux64::TGT_O_APPEND, _O_APPEND }, -#ifdef _O_NONBLOCK - { X86Linux64::TGT_O_NONBLOCK, _O_NONBLOCK }, -#endif -#ifdef _O_DSYNC - { X86Linux64::TGT_O_DSYNC , _O_DSYNC }, -#endif - { X86Linux64::TGT_FASYNC, _O_ASYNC }, - { X86Linux64::TGT_O_DIRECT, _O_DIRECT }, - { X86Linux64::TGT_O_LARGEFILE, _O_LARGEFILE }, - { X86Linux64::TGT_O_DIRECTORY, _O_DIRECTORY }, - { X86Linux64::TGT_O_NOFOLLOW, _O_NOFOLLOW }, - { X86Linux64::TGT_O_NOATIME, _O_NOATIME }, -#ifdef _O_CLOEXEC - { X86Linux64::TGT_O_CLOEXEC, _O_CLOEXEC }, -#endif -#ifdef _O_SYNC - { X86Linux64::TGT_O_SYNC, _O_SYNC }, -#endif -#ifdef _O_PATH - { X86Linux64::TGT_O_PATH , _O_PATH }, -#endif -#else /* !_MSC_VER */ - { X86Linux64::TGT_O_RDONLY, O_RDONLY }, - { X86Linux64::TGT_O_WRONLY, O_WRONLY }, - { X86Linux64::TGT_O_RDWR, O_RDWR }, - { X86Linux64::TGT_O_CREAT, O_CREAT }, - { X86Linux64::TGT_O_EXCL, O_EXCL }, - { X86Linux64::TGT_O_NOCTTY, O_NOCTTY }, - { X86Linux64::TGT_O_TRUNC, O_TRUNC }, - { X86Linux64::TGT_O_APPEND, O_APPEND }, - { X86Linux64::TGT_O_NONBLOCK, O_NONBLOCK }, -#ifdef O_DSYNC - { X86Linux64::TGT_O_DSYNC, O_DSYNC }, -#endif - { X86Linux64::TGT_FASYNC, O_ASYNC }, - { X86Linux64::TGT_O_DIRECT, O_DIRECT }, - { X86Linux64::TGT_O_LARGEFILE, O_LARGEFILE }, - { X86Linux64::TGT_O_DIRECTORY, O_DIRECTORY }, - { X86Linux64::TGT_O_NOFOLLOW, O_NOFOLLOW }, - { X86Linux64::TGT_O_NOATIME, O_NOATIME }, -#ifdef O_CLOEXEC - { X86Linux64::TGT_O_CLOEXEC, O_CLOEXEC }, -#endif -#ifdef O_SYNC - { X86Linux64::TGT_O_SYNC, O_SYNC }, -#endif -#ifdef O_PATH - { X86Linux64::TGT_O_PATH, O_PATH }, -#endif -#endif /* _MSC_VER */ -}; +// true for both X86Linux32 and X86Linux64 +#define TARGET_HAS_MAP_32BIT -const int X86Linux64::NUM_OPEN_FLAGS = - sizeof(X86Linux64::openFlagTable) / - sizeof(X86Linux64::openFlagTable[0]); +#define TARGET X86Linux32 +#include "kern/linux/flag_tables.hh" -// mmap(2) flags translation table -SyscallFlagTransTable X86Linux64::mmapFlagTable[] = { - { X86Linux64::TGT_MAP_SHARED, MAP_SHARED }, - { X86Linux64::TGT_MAP_PRIVATE, MAP_PRIVATE }, - { X86Linux64::TGT_MAP_32BIT, MAP_32BIT}, - { X86Linux64::TGT_MAP_ANON, MAP_ANON }, - { X86Linux64::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, - { X86Linux64::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, - { X86Linux64::TGT_MAP_FILE, MAP_FILE }, - { X86Linux64::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, -#ifdef MAP_HUGETLB - { X86Linux64::TGT_MAP_HUGETLB, MAP_HUGETLB }, -#endif - { X86Linux64::TGT_MAP_LOCKED, MAP_LOCKED }, - { X86Linux64::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, - { X86Linux64::TGT_MAP_NORESERVE, MAP_NORESERVE }, - { X86Linux64::TGT_MAP_POPULATE, MAP_POPULATE }, -#ifdef MAP_STACK - { X86Linux64::TGT_MAP_STACK, MAP_STACK }, -#endif - { X86Linux64::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, - { X86Linux64::TGT_MAP_FIXED, MAP_FIXED }, -}; - -const unsigned X86Linux64::NUM_MMAP_FLAGS = - sizeof(X86Linux64::mmapFlagTable) / - sizeof(X86Linux64::mmapFlagTable[0]); - -// open(2) flags translation table -SyscallFlagTransTable X86Linux32::openFlagTable[] = { -#ifdef _MSC_VER - { X86Linux32::TGT_O_RDONLY, _O_RDONLY }, - { X86Linux32::TGT_O_WRONLY, _O_WRONLY }, - { X86Linux32::TGT_O_RDWR, _O_RDWR }, - { X86Linux32::TGT_O_CREAT, _O_CREAT }, - { X86Linux32::TGT_O_EXCL, _O_EXCL }, -#ifdef _O_NOCTTY - { X86Linux32::TGT_O_NOCTTY, _O_NOCTTY }, -#endif - { X86Linux32::TGT_O_TRUNC, _O_TRUNC }, - { X86Linux32::TGT_O_APPEND, _O_APPEND }, -#ifdef _O_NONBLOCK - { X86Linux32::TGT_O_NONBLOCK, _O_NONBLOCK }, -#endif -#ifdef O_DSYNC - { X86Linux32::TGT_O_DSYNC, _O_DSYNC }, -#endif - { X86Linux32::TGT_FASYNC, _O_ASYNC }, - { X86Linux32::TGT_O_DIRECT, _O_DIRECT }, - { X86Linux32::TGT_O_LARGEFILE, _O_LARGEFILE }, - { X86Linux32::TGT_O_DIRECTORY, _O_DIRECTORY }, - { X86Linux32::TGT_O_NOFOLLOW, _O_NOFOLLOW }, - { X86Linux32::TGT_O_NOATIME, _O_NOATIME }, -#ifdef _O_CLOEXEC - { X86Linux32::TGT_O_CLOEXEC, _O_CLOEXEC }, -#endif -#ifdef _O_SYNC - { X86Linux32::TGT_O_SYNC, _O_SYNC }, -#endif -#ifdef _O_PATH - { X86Linux32::TGT_O_PATH, _O_PATH }, -#endif -#else /* !_MSC_VER */ - { X86Linux32::TGT_O_RDONLY, O_RDONLY }, - { X86Linux32::TGT_O_WRONLY, O_WRONLY }, - { X86Linux32::TGT_O_RDWR, O_RDWR }, - { X86Linux32::TGT_O_CREAT, O_CREAT }, - { X86Linux32::TGT_O_EXCL, O_EXCL }, - { X86Linux32::TGT_O_NOCTTY, O_NOCTTY }, - { X86Linux32::TGT_O_TRUNC, O_TRUNC }, - { X86Linux32::TGT_O_APPEND, O_APPEND }, - { X86Linux32::TGT_O_NONBLOCK, O_NONBLOCK }, -#ifdef O_DSYNC - { X86Linux32::TGT_O_DSYNC, O_DSYNC }, -#endif - { X86Linux32::TGT_FASYNC, O_ASYNC }, - { X86Linux32::TGT_O_DIRECT, O_DIRECT }, - { X86Linux32::TGT_O_LARGEFILE, O_LARGEFILE }, - { X86Linux32::TGT_O_DIRECTORY, O_DIRECTORY }, - { X86Linux32::TGT_O_NOFOLLOW, O_NOFOLLOW }, - { X86Linux32::TGT_O_NOATIME, O_NOATIME }, -#ifdef O_CLOEXEC - { X86Linux32::TGT_O_CLOEXEC, O_CLOEXEC }, -#endif -#ifdef O_SYNC - { X86Linux32::TGT_O_SYNC, O_SYNC }, -#endif -#ifdef O_PATH - { X86Linux32::TGT_O_PATH, O_PATH }, -#endif -#endif /* _MSC_VER */ -}; - -const int X86Linux32::NUM_OPEN_FLAGS = - sizeof(X86Linux32::openFlagTable) / - sizeof(X86Linux32::openFlagTable[0]); - -// mmap(2) flags translation table -SyscallFlagTransTable X86Linux32::mmapFlagTable[] = { - { X86Linux32::TGT_MAP_SHARED, MAP_SHARED }, - { X86Linux32::TGT_MAP_PRIVATE, MAP_PRIVATE }, - { X86Linux32::TGT_MAP_32BIT, MAP_32BIT}, - { X86Linux32::TGT_MAP_ANON, MAP_ANON }, - { X86Linux32::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, - { X86Linux32::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, - { X86Linux32::TGT_MAP_FILE, MAP_FILE }, - { X86Linux32::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, -#ifdef MAP_HUGETLB - { X86Linux32::TGT_MAP_HUGETLB, MAP_HUGETLB }, -#endif - { X86Linux32::TGT_MAP_LOCKED, MAP_LOCKED }, - { X86Linux32::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, - { X86Linux32::TGT_MAP_NORESERVE, MAP_NORESERVE }, - { X86Linux32::TGT_MAP_POPULATE, MAP_POPULATE }, -#ifdef MAP_STACK - { X86Linux32::TGT_MAP_STACK, MAP_STACK }, -#endif - { X86Linux32::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, - { X86Linux32::TGT_MAP_FIXED, MAP_FIXED }, -}; - -const unsigned X86Linux32::NUM_MMAP_FLAGS = - sizeof(X86Linux32::mmapFlagTable) / - sizeof(X86Linux32::mmapFlagTable[0]); +#undef TARGET +#define TARGET X86Linux64 +#include "kern/linux/flag_tables.hh" diff --git a/src/kern/linux/flag_tables.hh b/src/kern/linux/flag_tables.hh new file mode 100644 index 000000000..30c8f54a5 --- /dev/null +++ b/src/kern/linux/flag_tables.hh @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2011 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * + * Copyright (c) 2003-2005, 2006 The Regents of The University of Michigan + * Copyright (c) 2007-2008 The Florida State University + * Copyright (c) 2009 The University of Edinburgh + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Korey Sewell + */ + +/* + * @file flag_tables.hh + * + * This file contains definitions of flag translation tables for the + * open() and mmap() system calls. Since the tables are nearly identical + * across target platforms (other than the values of the target flags), + * we use a single copy of the tables but include it separately for + * each target platform. The TARGET macro must be #defined before including + * to indicate the class for which the table is being defined. + * + * See src/arch/<*>/linux/linux.cc. + */ + +// open(2) flags translation table +SyscallFlagTransTable TARGET::openFlagTable[] = { +#ifdef _MSC_VER + { TARGET::TGT_O_RDONLY, _O_RDONLY }, + { TARGET::TGT_O_WRONLY, _O_WRONLY }, + { TARGET::TGT_O_RDWR, _O_RDWR }, + { TARGET::TGT_O_CREAT, _O_CREAT }, + { TARGET::TGT_O_EXCL, _O_EXCL }, + { TARGET::TGT_O_TRUNC, _O_TRUNC }, + { TARGET::TGT_O_APPEND, _O_APPEND }, +#else /* !_MSC_VER */ + { TARGET::TGT_O_RDONLY, O_RDONLY }, + { TARGET::TGT_O_WRONLY, O_WRONLY }, + { TARGET::TGT_O_RDWR, O_RDWR }, + { TARGET::TGT_O_CREAT, O_CREAT }, + { TARGET::TGT_O_EXCL, O_EXCL }, + { TARGET::TGT_O_TRUNC, O_TRUNC }, + { TARGET::TGT_O_APPEND, O_APPEND }, + { TARGET::TGT_O_NOCTTY, O_NOCTTY }, + { TARGET::TGT_O_NONBLOCK, O_NONBLOCK }, +#ifdef O_DSYNC + { TARGET::TGT_O_DSYNC, O_DSYNC }, +#endif +#ifdef O_ASYNC + { TARGET::TGT_FASYNC, O_ASYNC }, +#endif +#ifdef O_DIRECT + { TARGET::TGT_O_DIRECT, O_DIRECT }, +#endif +#ifdef O_LARGEFILE + { TARGET::TGT_O_LARGEFILE, O_LARGEFILE }, +#endif +#ifdef O_DIRECTORY + { TARGET::TGT_O_DIRECTORY, O_DIRECTORY }, +#endif +#ifdef O_NOFOLLOW + { TARGET::TGT_O_NOFOLLOW, O_NOFOLLOW }, +#endif +#ifdef O_NOATIME + { TARGET::TGT_O_NOATIME, O_NOATIME }, +#endif +#ifdef O_CLOEXEC + { TARGET::TGT_O_CLOEXEC, O_CLOEXEC }, +#endif +#ifdef O_SYNC + { TARGET::TGT_O_SYNC, O_SYNC }, +#endif +#ifdef O_PATH + { TARGET::TGT_O_PATH, O_PATH }, +#endif +#endif /* _MSC_VER */ +}; + +const int TARGET::NUM_OPEN_FLAGS = + sizeof(TARGET::openFlagTable) / sizeof(TARGET::openFlagTable[0]); + +// mmap(2) flags translation table +SyscallFlagTransTable TARGET::mmapFlagTable[] = { + { TARGET::TGT_MAP_SHARED, MAP_SHARED }, + { TARGET::TGT_MAP_PRIVATE, MAP_PRIVATE }, + { TARGET::TGT_MAP_FIXED, MAP_FIXED }, + { TARGET::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, + { TARGET::TGT_MAP_ANON, MAP_ANON }, + { TARGET::TGT_MAP_FILE, MAP_FILE }, +#if defined(MAP_32BIT) && defined(TARGET_HAS_MAP_32BIT) + { TARGET::TGT_MAP_32BIT, MAP_32BIT }, +#endif +#ifdef MAP_DENYWRITE + { TARGET::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, +#endif +#ifdef MAP_EXECUTABLE + { TARGET::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, +#endif +#ifdef MAP_GROWSDOWN + { TARGET::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, +#endif +#ifdef MAP_HUGETLB + { TARGET::TGT_MAP_HUGETLB, MAP_HUGETLB }, +#endif +#ifdef MAP_LOCKED + { TARGET::TGT_MAP_LOCKED, MAP_LOCKED }, +#endif +#ifdef MAP_NONBLOCK + { TARGET::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, +#endif +#ifdef MAP_NORESERVE + { TARGET::TGT_MAP_NORESERVE, MAP_NORESERVE }, +#endif +#ifdef MAP_POPULATE + { TARGET::TGT_MAP_POPULATE, MAP_POPULATE }, +#endif +#ifdef MAP_STACK + { TARGET::TGT_MAP_STACK, MAP_STACK }, +#endif +}; + +const unsigned TARGET::NUM_MMAP_FLAGS = + sizeof(TARGET::mmapFlagTable) / sizeof(TARGET::mmapFlagTable[0]); + -- 2.30.2