OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sandbox/linux/seccomp-bpf/syscall.h" | 5 #include "sandbox/linux/seccomp-bpf/syscall.h" |
6 | 6 |
7 #include <asm/unistd.h> | 7 #include <asm/unistd.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 ); // asm | 174 ); // asm |
175 | 175 |
176 } // namespace | 176 } // namespace |
177 | 177 |
178 intptr_t Syscall::Call(int nr, | 178 intptr_t Syscall::Call(int nr, |
179 intptr_t p0, | 179 intptr_t p0, |
180 intptr_t p1, | 180 intptr_t p1, |
181 intptr_t p2, | 181 intptr_t p2, |
182 intptr_t p3, | 182 intptr_t p3, |
183 intptr_t p4, | 183 intptr_t p4, |
184 intptr_t p5) { | 184 intptr_t p5, |
185 intptr_t p6, | |
186 intptr_t p7) { | |
185 // We rely on "intptr_t" to be the exact size as a "void *". This is | 187 // We rely on "intptr_t" to be the exact size as a "void *". This is |
186 // typically true, but just in case, we add a check. The language | 188 // typically true, but just in case, we add a check. The language |
187 // specification allows platforms some leeway in cases, where | 189 // specification allows platforms some leeway in cases, where |
188 // "sizeof(void *)" is not the same as "sizeof(void (*)())". We expect | 190 // "sizeof(void *)" is not the same as "sizeof(void (*)())". We expect |
189 // that this would only be an issue for IA64, which we are currently not | 191 // that this would only be an issue for IA64, which we are currently not |
190 // planning on supporting. And it is even possible that this would work | 192 // planning on supporting. And it is even possible that this would work |
191 // on IA64, but for lack of actual hardware, I cannot test. | 193 // on IA64, but for lack of actual hardware, I cannot test. |
192 COMPILE_ASSERT(sizeof(void*) == sizeof(intptr_t), | 194 COMPILE_ASSERT(sizeof(void*) == sizeof(intptr_t), |
193 pointer_types_and_intptr_must_be_exactly_the_same_size); | 195 pointer_types_and_intptr_must_be_exactly_the_same_size); |
194 | 196 |
197 // TODO(nedeljko): Enable use of more than six parameters on architectures | |
mdempsky
2014/07/01 21:53:17
Would it make sense to add DCHECK()s to make sure
nedeljko
2014/07/02 10:46:19
Done.
| |
198 // where that makes sense. | |
195 const intptr_t args[6] = {p0, p1, p2, p3, p4, p5}; | 199 const intptr_t args[6] = {p0, p1, p2, p3, p4, p5}; |
196 | 200 |
197 // Invoke our file-scope assembly code. The constraints have been picked | 201 // Invoke our file-scope assembly code. The constraints have been picked |
198 // carefully to match what the rest of the assembly code expects in input, | 202 // carefully to match what the rest of the assembly code expects in input, |
199 // output, and clobbered registers. | 203 // output, and clobbered registers. |
200 #if defined(__i386__) | 204 #if defined(__i386__) |
201 intptr_t ret = nr; | 205 intptr_t ret = nr; |
202 asm volatile( | 206 asm volatile( |
203 "call SyscallAsm\n" | 207 "call SyscallAsm\n" |
204 // N.B. These are not the calling conventions normally used by the ABI. | 208 // N.B. These are not the calling conventions normally used by the ABI. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 ); | 263 ); |
260 ret = inout; | 264 ret = inout; |
261 } | 265 } |
262 #else | 266 #else |
263 #error "Unimplemented architecture" | 267 #error "Unimplemented architecture" |
264 #endif | 268 #endif |
265 return ret; | 269 return ret; |
266 } | 270 } |
267 | 271 |
268 } // namespace sandbox | 272 } // namespace sandbox |
OLD | NEW |