1 // Copyright 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 #include "nacl_io/stream/stream_node.h"
12 #include "nacl_io/ioctl.h"
13 #include "nacl_io/stream/stream_fs.h"
14 #include "sdk_util/atomicops.h"
18 StreamNode::StreamNode(Filesystem
* fs
)
19 : Node(fs
), read_timeout_(-1), write_timeout_(-1), stream_state_flags_(0) {
22 Error
StreamNode::Init(int open_flags
) {
23 Node::Init(open_flags
);
24 if (open_flags
& O_NONBLOCK
)
25 SetStreamFlags(SSF_NON_BLOCK
);
30 void StreamNode::SetStreamFlags(uint32_t bits
) {
31 sdk_util::AtomicOrFetch(&stream_state_flags_
, bits
);
34 void StreamNode::ClearStreamFlags(uint32_t bits
) {
35 sdk_util::AtomicAndFetch(&stream_state_flags_
, ~bits
);
38 uint32_t StreamNode::GetStreamFlags() {
39 return stream_state_flags_
;
42 bool StreamNode::TestStreamFlags(uint32_t bits
) {
43 return (stream_state_flags_
& bits
) == bits
;
46 void StreamNode::QueueInput() {
48 void StreamNode::QueueOutput() {
51 StreamFs
* StreamNode::stream() {
52 return static_cast<StreamFs
*>(filesystem_
);
55 } // namespace nacl_io