Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1360)

Side by Side Diff: components/nacl/loader/nonsfi/irt_util.h

Issue 1409633002: Non-SFI mode: Remove old Non-SFI code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_NACL_LOADER_NONSFI_IRT_UTIL_H_
6 #define COMPONENTS_NACL_LOADER_NONSFI_IRT_UTIL_H_
7
8 #include <errno.h>
9
10 namespace nacl {
11 namespace nonsfi {
12
13 // For IRT implementation, the following simple pattern is commonly used.
14 //
15 // if (syscall(...) < 0)
16 // return errno;
17 // return 0;
18 //
19 // This function is a utility to write it in a line as follows:
20 //
21 // return CheckError(syscall(...));
22 inline int CheckError(int result) {
23 return result < 0 ? errno : 0;
24 }
25
26 // For IRT implementation, another but a similar pattern is also commonly used.
27 //
28 // T result = syscall(...);
29 // if (result < 0)
30 // return errno;
31 // *output = result;
32 // return 0;
33 //
34 // This function is a utility to write it in a line as follows:
35 //
36 // retrun CheckErrorWithResult(syscall(...), output);
37 //
38 // Here, T1 must be a signed integer value, and T2 must be convertible from
39 // T1.
40 template<typename T1, typename T2>
41 int CheckErrorWithResult(const T1& result, T2* out) {
42 if (result < 0)
43 return errno;
44
45 *out = result;
46 return 0;
47 }
48
49 } // namespace nonsfi
50 } // namespace nacl
51
52 #endif // COMPONENTS_NACL_LOADER_NONSFI_IRT_UTIL_H_
OLDNEW
« no previous file with comments | « components/nacl/loader/nonsfi/irt_thread.cc ('k') | components/nacl/loader/nonsfi/nonsfi_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698