blob: 1ce57b99e8957fdf2da5cf70068a995550740b44 [file] [log] [blame]
Jason Sams7a22e102011-05-06 14:14:30 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "rsFifoSocket.h"
18#include "utils/Timers.h"
19#include "utils/StopWatch.h"
20
21#include <stdio.h>
22#include <stdlib.h>
23#include <ctype.h>
24#include <unistd.h>
25#include <sys/types.h>
26#include <sys/socket.h>
27
28using namespace android;
29using namespace android::renderscript;
30
31FifoSocket::FifoSocket() {
32 sequence = 1;
33}
34
35FifoSocket::~FifoSocket() {
36
37}
38
39bool FifoSocket::init() {
40 int ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sv);
41 return false;
42}
43
44void FifoSocket::shutdown() {
45}
46
47void FifoSocket::writeAsync(const void *data, size_t bytes) {
48 size_t ret = ::write(sv[0], data, bytes);
49 rsAssert(ret == bytes);
50}
51
52void FifoSocket::writeWaitReturn(void *retData, size_t retBytes) {
53 size_t ret = ::read(sv[1], retData, retBytes);
54 rsAssert(ret == retBytes);
55}
56
57size_t FifoSocket::read(void *data, size_t bytes) {
58 size_t ret = ::read(sv[0], data, bytes);
59 rsAssert(ret == bytes);
60 return ret;
61}
62
63void FifoSocket::readReturn(const void *data, size_t bytes) {
64 size_t ret = ::write(sv[1], data, bytes);
65 rsAssert(ret == bytes);
66}
67
68
69void FifoSocket::flush() {
70}
71
72