linux.cc revision 10037
1/*
2 * Copyright (c) 2011 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder.  You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2003-2005 The Regents of The University of Michigan
15 * Copyright (c) 2007-2008 The Florida State University
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Authors: Stephen Hines
42 */
43
44#include <fcntl.h>
45
46#include "arch/arm/linux/linux.hh"
47
48// open(2) flags translation table
49OpenFlagTransTable ArmLinux32::openFlagTable[] = {
50#ifdef _MSC_VER
51  { ArmLinux32::TGT_O_RDONLY,     _O_RDONLY },
52  { ArmLinux32::TGT_O_WRONLY,     _O_WRONLY },
53  { ArmLinux32::TGT_O_RDWR,       _O_RDWR },
54  { ArmLinux32::TGT_O_APPEND,     _O_APPEND },
55  { ArmLinux32::TGT_O_CREAT,      _O_CREAT },
56  { ArmLinux32::TGT_O_TRUNC,      _O_TRUNC },
57  { ArmLinux32::TGT_O_EXCL,       _O_EXCL },
58#ifdef _O_NONBLOCK
59  { ArmLinux32::TGT_O_NONBLOCK,   _O_NONBLOCK },
60#endif
61#ifdef _O_NOCTTY
62  { ArmLinux32::TGT_O_NOCTTY,     _O_NOCTTY },
63#endif
64#ifdef _O_SYNC
65  { ArmLinux32::TGT_O_SYNC,       _O_SYNC },
66#endif
67#else /* !_MSC_VER */
68  { ArmLinux32::TGT_O_RDONLY,     O_RDONLY },
69  { ArmLinux32::TGT_O_WRONLY,     O_WRONLY },
70  { ArmLinux32::TGT_O_RDWR,       O_RDWR },
71  { ArmLinux32::TGT_O_CREAT,      O_CREAT },
72  { ArmLinux32::TGT_O_EXCL,       O_EXCL },
73  { ArmLinux32::TGT_O_NOCTTY,     O_NOCTTY },
74  { ArmLinux32::TGT_O_TRUNC,      O_TRUNC },
75  { ArmLinux32::TGT_O_APPEND,     O_APPEND },
76  { ArmLinux32::TGT_O_NONBLOCK,   O_NONBLOCK },
77#ifdef O_SYNC
78  { ArmLinux32::TGT_O_SYNC,       O_SYNC },
79#endif
80#ifdef FASYNC
81  { ArmLinux32::TGT_FASYNC,       FASYNC },
82#endif
83#ifdef O_DIRECT
84  { ArmLinux32::TGT_O_DIRECT,     O_DIRECT },
85#endif
86#ifdef O_LARGEFILE
87  { ArmLinux32::TGT_O_LARGEFILE,  O_LARGEFILE },
88#endif
89#ifdef O_DIRECTORY
90  { ArmLinux32::TGT_O_DIRECTORY,  O_DIRECTORY },
91#endif
92#ifdef O_NOFOLLOW
93  { ArmLinux32::TGT_O_NOFOLLOW,   O_NOFOLLOW },
94#endif
95#endif /* _MSC_VER */
96};
97
98const int ArmLinux32::NUM_OPEN_FLAGS = sizeof(ArmLinux32::openFlagTable) /
99                                       sizeof(ArmLinux32::openFlagTable[0]);
100
101// open(2) flags translation table
102OpenFlagTransTable ArmLinux64::openFlagTable[] = {
103#ifdef _MSC_VER
104  { ArmLinux64::TGT_O_RDONLY,     _O_RDONLY },
105  { ArmLinux64::TGT_O_WRONLY,     _O_WRONLY },
106  { ArmLinux64::TGT_O_RDWR,       _O_RDWR },
107  { ArmLinux64::TGT_O_APPEND,     _O_APPEND },
108  { ArmLinux64::TGT_O_CREAT,      _O_CREAT },
109  { ArmLinux64::TGT_O_TRUNC,      _O_TRUNC },
110  { ArmLinux64::TGT_O_EXCL,       _O_EXCL },
111#ifdef _O_NONBLOCK
112  { ArmLinux64::TGT_O_NONBLOCK,   _O_NONBLOCK },
113#endif
114#ifdef _O_NOCTTY
115  { ArmLinux64::TGT_O_NOCTTY,     _O_NOCTTY },
116#endif
117#ifdef _O_SYNC
118  { ArmLinux64::TGT_O_SYNC,       _O_SYNC },
119#endif
120#else /* !_MSC_VER */
121  { ArmLinux64::TGT_O_RDONLY,     O_RDONLY },
122  { ArmLinux64::TGT_O_WRONLY,     O_WRONLY },
123  { ArmLinux64::TGT_O_RDWR,       O_RDWR },
124  { ArmLinux64::TGT_O_CREAT,      O_CREAT },
125  { ArmLinux64::TGT_O_EXCL,       O_EXCL },
126  { ArmLinux64::TGT_O_NOCTTY,     O_NOCTTY },
127  { ArmLinux64::TGT_O_TRUNC,      O_TRUNC },
128  { ArmLinux64::TGT_O_APPEND,     O_APPEND },
129  { ArmLinux64::TGT_O_NONBLOCK,   O_NONBLOCK },
130#ifdef O_SYNC
131  { ArmLinux64::TGT_O_SYNC,       O_SYNC },
132#endif
133#ifdef FASYNC
134  { ArmLinux64::TGT_FASYNC,       FASYNC },
135#endif
136#ifdef O_DIRECT
137  { ArmLinux64::TGT_O_DIRECT,     O_DIRECT },
138#endif
139#ifdef O_LARGEFILE
140  { ArmLinux64::TGT_O_LARGEFILE,  O_LARGEFILE },
141#endif
142#ifdef O_DIRECTORY
143  { ArmLinux64::TGT_O_DIRECTORY,  O_DIRECTORY },
144#endif
145#ifdef O_NOFOLLOW
146  { ArmLinux64::TGT_O_NOFOLLOW,   O_NOFOLLOW },
147#endif
148#endif /* _MSC_VER */
149};
150
151const int ArmLinux64::NUM_OPEN_FLAGS = sizeof(ArmLinux64::openFlagTable) /
152                                       sizeof(ArmLinux64::openFlagTable[0]);
153
154