| 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 <sys/types.h> // Include something that will define __GLIBC__. | 5 #include <sys/types.h> // Include something that will define __GLIBC__. |
| 6 | 6 |
| 7 // The entire file is wrapped in this #if. We do this so this .cc file can be | 7 // The entire file is wrapped in this #if. We do this so this .cc file can be |
| 8 // compiled, even on a non-newlib build. | 8 // compiled, even on a non-newlib build. |
| 9 #if defined(__native_client__) && !defined(__GLIBC__) | 9 #if defined(__native_client__) && !defined(__GLIBC__) |
| 10 | 10 |
| 11 #include "nacl_io/kernel_wrap.h" | 11 #include "nacl_io/kernel_wrap.h" |
| 12 | 12 |
| 13 #include <assert.h> | |
| 14 #include <dirent.h> | 13 #include <dirent.h> |
| 15 #include <errno.h> | 14 #include <errno.h> |
| 16 #include <irt.h> | 15 #include <irt.h> |
| 17 #include <sys/mman.h> | 16 #include <sys/mman.h> |
| 18 #include <sys/stat.h> | 17 #include <sys/stat.h> |
| 19 #include <sys/time.h> | 18 #include <sys/time.h> |
| 20 | 19 |
| 21 #include "nacl_io/kernel_intercept.h" | 20 #include "nacl_io/kernel_intercept.h" |
| 22 #include "nacl_io/kernel_wrap_real.h" | 21 #include "nacl_io/kernel_wrap_real.h" |
| 23 | 22 |
| 24 EXTERN_C_BEGIN | 23 EXTERN_C_BEGIN |
| 25 | 24 |
| 26 // Macro to get the REAL function pointer | 25 // Macro to get the REAL function pointer |
| 27 #define REAL(name) __nacl_irt_##name##_real | 26 #define REAL(name) __nacl_irt_##name##_real |
| 28 | 27 |
| 29 // Macro to get the WRAP function | 28 // Macro to get the WRAP function |
| 30 #define WRAP(name) __nacl_irt_##name##_wrap | 29 #define WRAP(name) __nacl_irt_##name##_wrap |
| 31 | 30 |
| 32 // Declare REAL function pointer. | 31 // Declare REAL function pointer. |
| 33 #define DECLARE_REAL_PTR(group, name) \ | 32 #define DECLARE_REAL_PTR(group, name) \ |
| 34 typeof(__libnacl_irt_##group.name) REAL(name); | 33 typeof(__libnacl_irt_##group.name) REAL(name); |
| 35 | 34 |
| 36 // Assign the REAL function pointer. | 35 // Assign the REAL function pointer. |
| 37 #define ASSIGN_REAL_PTR(group, name) \ | 36 #define ASSIGN_REAL_PTR(group, name) \ |
| 38 assert(__libnacl_irt_##group.name != NULL); \ | |
| 39 REAL(name) = __libnacl_irt_##group.name; | 37 REAL(name) = __libnacl_irt_##group.name; |
| 40 | 38 |
| 41 // Switch IRT's pointer to the REAL pointer | 39 // Switch IRT's pointer to the REAL pointer |
| 42 #define USE_REAL(group, name) \ | 40 #define USE_REAL(group, name) \ |
| 43 __libnacl_irt_##group.name = (typeof(REAL(name))) REAL(name); \ | 41 __libnacl_irt_##group.name = (typeof(REAL(name))) REAL(name); \ |
| 44 | 42 |
| 45 // Switch the IRT's pointer to the WRAP function | 43 // Switch the IRT's pointer to the WRAP function |
| 46 #define USE_WRAP(group, name) \ | 44 #define USE_WRAP(group, name) \ |
| 47 __libnacl_irt_##group.name = (typeof(REAL(name))) WRAP(name); \ | 45 __libnacl_irt_##group.name = (typeof(REAL(name))) WRAP(name); \ |
| 48 | 46 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 void kernel_wrap_uninit() { | 228 void kernel_wrap_uninit() { |
| 231 if (s_wrapped) { | 229 if (s_wrapped) { |
| 232 EXPAND_SYMBOL_LIST_OPERATION(USE_REAL) | 230 EXPAND_SYMBOL_LIST_OPERATION(USE_REAL) |
| 233 s_wrapped = false; | 231 s_wrapped = false; |
| 234 } | 232 } |
| 235 } | 233 } |
| 236 | 234 |
| 237 EXTERN_C_END | 235 EXTERN_C_END |
| 238 | 236 |
| 239 #endif // defined(__native_client__) && !defined(__GLIBC__) | 237 #endif // defined(__native_client__) && !defined(__GLIBC__) |
| OLD | NEW |