| 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 __BIONIC__. | 5 #include <sys/types.h> // Include something that will define __BIONIC__. |
| 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-bionic build. | 8 // compiled, even on a non-bionic build. |
| 9 | 9 |
| 10 #if defined(__native_client__) && defined(__BIONIC__) | 10 #if defined(__native_client__) && defined(__BIONIC__) |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 if (!assigned) { | 334 if (!assigned) { |
| 335 EXPAND_SYMBOL_LIST_OPERATION(ASSIGN_REAL_PTR) | 335 EXPAND_SYMBOL_LIST_OPERATION(ASSIGN_REAL_PTR) |
| 336 assigned = true; | 336 assigned = true; |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 #define CHECK_REAL(func) \ | 340 #define CHECK_REAL(func) \ |
| 341 if (!REAL(func)) \ | 341 if (!REAL(func)) \ |
| 342 assign_real_pointers(); | 342 assign_real_pointers(); |
| 343 | 343 |
| 344 #define CHECK_REAL_NOSYS(func) \ |
| 345 CHECK_REAL(func) \ |
| 346 if (!REAL(func)) \ |
| 347 return ENOSYS; |
| 348 |
| 344 // "real" functions, i.e. the unwrapped original functions. | 349 // "real" functions, i.e. the unwrapped original functions. |
| 345 | 350 |
| 346 int _real_close(int fd) { | 351 int _real_close(int fd) { |
| 347 CHECK_REAL(close); | 352 CHECK_REAL(close); |
| 348 return REAL(close)(fd); | 353 return REAL(close)(fd); |
| 349 } | 354 } |
| 350 | 355 |
| 351 void _real_exit(int status) { | 356 void _real_exit(int status) { |
| 352 REAL(exit)(status); | 357 REAL(exit)(status); |
| 353 } | 358 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 int _real_truncate(const char* pathname, int64_t len) { | 496 int _real_truncate(const char* pathname, int64_t len) { |
| 492 CHECK_REAL(truncate); | 497 CHECK_REAL(truncate); |
| 493 return REAL(truncate)(pathname, len); | 498 return REAL(truncate)(pathname, len); |
| 494 } | 499 } |
| 495 | 500 |
| 496 int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) { | 501 int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) { |
| 497 CHECK_REAL(write); | 502 CHECK_REAL(write); |
| 498 return REAL(write)(fd, buf, count, nwrote); | 503 return REAL(write)(fd, buf, count, nwrote); |
| 499 } | 504 } |
| 500 | 505 |
| 506 int _real_getcwd(char* pathname, size_t len) { |
| 507 CHECK_REAL_NOSYS(getcwd); |
| 508 return REAL(getcwd)(pathname, len); |
| 509 } |
| 510 |
| 501 static bool s_wrapped = false; | 511 static bool s_wrapped = false; |
| 512 |
| 502 void kernel_wrap_init() { | 513 void kernel_wrap_init() { |
| 503 if (!s_wrapped) { | 514 if (!s_wrapped) { |
| 504 assign_real_pointers(); | 515 assign_real_pointers(); |
| 505 EXPAND_SYMBOL_LIST_OPERATION(USE_WRAP) | 516 EXPAND_SYMBOL_LIST_OPERATION(USE_WRAP) |
| 506 s_wrapped = true; | 517 s_wrapped = true; |
| 507 } | 518 } |
| 508 } | 519 } |
| 509 | 520 |
| 510 void kernel_wrap_uninit() { | 521 void kernel_wrap_uninit() { |
| 511 if (s_wrapped) { | 522 if (s_wrapped) { |
| 512 EXPAND_SYMBOL_LIST_OPERATION(USE_REAL) | 523 EXPAND_SYMBOL_LIST_OPERATION(USE_REAL) |
| 513 s_wrapped = false; | 524 s_wrapped = false; |
| 514 } | 525 } |
| 515 } | 526 } |
| 516 | 527 |
| 517 EXTERN_C_END | 528 EXTERN_C_END |
| 518 | 529 |
| 519 #endif // defined(__native_client__) && defined(__GLIBC__) | 530 #endif // defined(__native_client__) && defined(__BIONIC__) |
| OLD | NEW |