linux.cc revision 11383:5ac090acd180
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Korey Sewell 29 */ 30 31#include "arch/mips/linux/linux.hh" 32 33#include <fcntl.h> 34#include <sys/mman.h> 35 36// open(2) flags translation table 37SyscallFlagTransTable MipsLinux::openFlagTable[] = { 38#ifdef _MSC_VER 39 { MipsLinux::TGT_O_RDONLY, _O_RDONLY }, 40 { MipsLinux::TGT_O_WRONLY, _O_WRONLY }, 41 { MipsLinux::TGT_O_RDWR, _O_RDWR }, 42 { MipsLinux::TGT_O_CREAT, _O_CREAT }, 43 { MipsLinux::TGT_O_EXCL, _O_EXCL }, 44#ifdef _O_NOCTTY 45 { MipsLinux::TGT_O_NOCTTY, _O_NOCTTY }, 46#endif 47 { MipsLinux::TGT_O_TRUNC, _O_TRUNC }, 48 { MipsLinux::TGT_O_APPEND, _O_APPEND }, 49#ifdef _O_NONBLOCK 50 { MipsLinux::TGT_O_NONBLOCK, _O_NONBLOCK }, 51#endif 52#ifdef _O_DSYNC 53 { MipsLinux::TGT_O_DSYNC, _O_DSYNC }, 54#endif 55 { MipsLinux::TGT_O_DIRECT, _O_DIRECT }, 56 { MipsLinux::TGT_O_LARGEFILE, _O_LARGEFILE }, 57 { MipsLinux::TGT_O_DIRECTORY, _O_DIRECTORY }, 58 { MipsLinux::TGT_O_NOFOLLOW, _O_NOFOLLOW }, 59 { MipsLinux::TGT_O_NOATIME, _O_NOATIME }, 60#ifdef _O_CLOEXEC 61 { MipsLinux::TGT_O_CLOEXEC, _O_CLOEXEC }, 62#endif 63#ifdef _O_SYNC 64 { MipsLinux::TGT_O_SYNC, _O_SYNC }, 65#endif 66#ifdef _O_PATH 67 { MipsLinux::TGT_O_PATH, _O_PATH }, 68#endif 69#else /* !_MSC_VER */ 70 { MipsLinux::TGT_O_RDONLY, O_RDONLY }, 71 { MipsLinux::TGT_O_WRONLY, O_WRONLY }, 72 { MipsLinux::TGT_O_RDWR, O_RDWR }, 73 { MipsLinux::TGT_O_CREAT, O_CREAT }, 74 { MipsLinux::TGT_O_EXCL, O_EXCL }, 75 { MipsLinux::TGT_O_NOCTTY, O_NOCTTY }, 76 { MipsLinux::TGT_O_TRUNC, O_TRUNC }, 77 { MipsLinux::TGT_O_APPEND, O_APPEND }, 78 { MipsLinux::TGT_O_NONBLOCK, O_NONBLOCK }, 79#ifdef O_DSYNC 80 { MipsLinux::TGT_O_DSYNC, O_DSYNC }, 81#endif 82 { MipsLinux::TGT_O_DIRECT, O_DIRECT }, 83 { MipsLinux::TGT_O_LARGEFILE, O_LARGEFILE }, 84 { MipsLinux::TGT_O_DIRECTORY, O_DIRECTORY }, 85 { MipsLinux::TGT_O_NOFOLLOW, O_NOFOLLOW }, 86 { MipsLinux::TGT_O_NOATIME, O_NOATIME }, 87#ifdef O_CLOEXEC 88 { MipsLinux::TGT_O_CLOEXEC, O_CLOEXEC }, 89#endif 90#ifdef O_SYNC 91 { MipsLinux::TGT_O_SYNC, O_SYNC }, 92#endif 93#ifdef O_PATH 94 { MipsLinux::TGT_O_PATH, O_PATH }, 95#endif 96#endif /* _MSC_VER */ 97}; 98 99const int MipsLinux::NUM_OPEN_FLAGS = 100 (sizeof(MipsLinux::openFlagTable)/sizeof(MipsLinux::openFlagTable[0])); 101 102// mmap(2) flags translation table 103SyscallFlagTransTable MipsLinux::mmapFlagTable[] = { 104 { MipsLinux::TGT_MAP_SHARED, MAP_SHARED }, 105 { MipsLinux::TGT_MAP_PRIVATE, MAP_PRIVATE }, 106 { MipsLinux::TGT_MAP_ANON, MAP_ANON }, 107 { MipsLinux::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, 108 { MipsLinux::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, 109 { MipsLinux::TGT_MAP_FILE, MAP_FILE }, 110 { MipsLinux::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, 111 { MipsLinux::TGT_MAP_HUGETLB, MAP_HUGETLB }, 112 { MipsLinux::TGT_MAP_LOCKED, MAP_LOCKED }, 113 { MipsLinux::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, 114 { MipsLinux::TGT_MAP_NORESERVE, MAP_NORESERVE }, 115 { MipsLinux::TGT_MAP_POPULATE, MAP_POPULATE }, 116#ifdef MAP_STACK 117 { MipsLinux::TGT_MAP_STACK, MAP_STACK }, 118#endif 119 { MipsLinux::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, 120 { MipsLinux::TGT_MAP_FIXED, MAP_FIXED }, 121}; 122 123const unsigned MipsLinux::NUM_MMAP_FLAGS = 124 sizeof(MipsLinux::mmapFlagTable) / 125 sizeof(MipsLinux::mmapFlagTable[0]); 126 127