- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / mount_node_stream.cc
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.
4
5 #include "nacl_io/mount_node_stream.h"
6
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <pthread.h>
10 #include <string.h>
11
12 #include "nacl_io/ioctl.h"
13 #include "nacl_io/mount_stream.h"
14 #include "sdk_util/atomicops.h"
15
16
17 namespace nacl_io {
18
19 MountNodeStream::MountNodeStream(Mount* mnt)
20     : MountNode(mnt),
21       read_timeout_(-1),
22       write_timeout_(-1),
23       stream_state_flags_(0) {
24 }
25
26 Error MountNodeStream::Init(int open_flags) {
27   MountNode::Init(open_flags);
28   if (open_flags & O_NONBLOCK)
29     SetStreamFlags(SSF_NON_BLOCK);
30
31   return 0;
32 }
33
34 void MountNodeStream::SetStreamFlags(uint32_t bits) {
35   sdk_util::AtomicOrFetch(&stream_state_flags_, bits);
36 }
37
38 void MountNodeStream::ClearStreamFlags(uint32_t bits) {
39   sdk_util::AtomicAndFetch(&stream_state_flags_, ~bits);
40 }
41
42 uint32_t MountNodeStream::GetStreamFlags() {
43   return stream_state_flags_;
44 }
45
46 bool MountNodeStream::TestStreamFlags(uint32_t bits) {
47   return (stream_state_flags_ & bits) == bits;
48 }
49
50
51 void MountNodeStream::QueueInput() {}
52 void MountNodeStream::QueueOutput() {}
53
54 MountStream* MountNodeStream::mount_stream() {
55   return static_cast<MountStream*>(mount_);
56 }
57
58 }  // namespace nacl_io