OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Handle passing definitions for NaCl | 5 // Handle passing definitions for NaCl |
6 #ifndef CHROME_COMMON_NACL_TYPES_H_ | 6 #ifndef CHROME_COMMON_NACL_TYPES_H_ |
7 #define CHROME_COMMON_NACL_TYPES_H_ | 7 #define CHROME_COMMON_NACL_TYPES_H_ |
8 #pragma once | 8 #pragma once |
9 | 9 |
10 #include "base/native_library.h" // for HANDLE and OS_POSIX | |
11 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
12 #include "base/file_descriptor_posix.h" | 11 #include "base/file_descriptor_posix.h" |
13 #endif | 12 #endif |
14 | 13 |
15 // TODO(gregoryd): add a Windows definition for base::FileDescriptor | 14 // TODO(gregoryd): add a Windows definition for base::FileDescriptor |
16 namespace nacl { | 15 namespace nacl { |
17 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
18 // We assume that HANDLE always uses less than 32 bits | 17 // We assume that HANDLE always uses less than 32 bits |
19 typedef int FileDescriptor; | 18 typedef int FileDescriptor; |
20 inline HANDLE ToNativeHandle(const FileDescriptor& desc) { | 19 inline HANDLE ToNativeHandle(const FileDescriptor& desc) { |
21 return reinterpret_cast<HANDLE>(desc); | 20 return reinterpret_cast<HANDLE>(desc); |
22 } | 21 } |
23 #endif | 22 #elif defined(OS_POSIX) |
24 #if defined(OS_POSIX) | |
25 typedef base::FileDescriptor FileDescriptor; | 23 typedef base::FileDescriptor FileDescriptor; |
26 inline int ToNativeHandle(const FileDescriptor& desc) { | 24 inline int ToNativeHandle(const FileDescriptor& desc) { |
27 return desc.fd; | 25 return desc.fd; |
28 } | 26 } |
29 #endif | 27 #endif |
30 } | 28 } |
31 | 29 |
32 #endif // CHROME_COMMON_NACL_TYPES_H_ | 30 #endif // CHROME_COMMON_NACL_TYPES_H_ |
OLD | NEW |