Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / kernel_wrap_dummy.cc
blob2f51f47fab9fe0ce0823e6d61672a807b2d31532
1 // Copyright (c) 2013 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.
5 // The Chromium build system defines __linux__ even for native client builds,
6 // so guard against __native_client__ being defined as well.
7 #if defined(WIN32) || defined(__APPLE__) || (defined(__linux__) && !defined(__native_client__))
9 #include <errno.h>
11 #include "nacl_io/kernel_wrap.h"
12 #include "nacl_io/kernel_wrap_real.h"
14 // "real" functions, i.e. the unwrapped original functions. For Windows/Linux
15 // host builds we don't wrap, so the real functions aren't accessible. In most
16 // cases, we just fail.
18 int _real_close(int fd) {
19 return ENOSYS;
22 int _real_fstat(int fd, struct stat* buf) {
23 return 0;
26 int _real_getdents(int fd, void* nacl_buf, size_t nacl_count, size_t* nread) {
27 return ENOSYS;
30 int _real_lseek(int fd, off_t offset, int whence, off_t* new_offset) {
31 return ENOSYS;
34 int _real_mkdir(const char* pathname, mode_t mode) {
35 return ENOSYS;
38 int _real_mmap(void** addr,
39 size_t length,
40 int prot,
41 int flags,
42 int fd,
43 off_t offset) {
44 return ENOSYS;
47 int _real_munmap(void* addr, size_t length) {
48 return ENOSYS;
51 int _real_open(const char* pathname, int oflag, mode_t mode, int* newfd) {
52 return ENOSYS;
55 int _real_open_resource(const char* file, int* fd) {
56 return ENOSYS;
59 int _real_read(int fd, void* buf, size_t count, size_t* nread) {
60 *nread = count;
61 return 0;
64 int _real_rmdir(const char* pathname) {
65 return ENOSYS;
68 int _real_write(int fd, const void* buf, size_t count, size_t* nwrote) {
69 int rtn = write(fd, buf, count);
70 if (rtn < 0)
71 return -1;
73 *nwrote = rtn;
74 return 0;
77 void _real_exit(int status) {
78 exit(status);
81 int _real_getcwd(char* pathname, size_t len) {
82 return ENOSYS;
85 int _real_isatty(int fd, int* result) {
86 *result = isatty(fd);
87 return *result ? 0 : -1;
90 #endif
92 // The Chromium build system defines __linux__ even for native client builds,
93 // so guard against __native_client__ being defined as well.
94 #if defined(__APPLE__) || defined(__linux__) && !defined(__native_client__)
96 void kernel_wrap_init() {
99 void kernel_wrap_uninit() {
102 #endif