blob: ced884ba5cb7f20f8f9315f5c9d794ff229fd79a [file] [log] [blame]
Josh Gao1bbdd252018-04-05 17:55:25 -07001/*
2 * Copyright (C) 2018 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#pragma once
18
19#include <sys/types.h>
20
Josh Gao90228a62019-04-25 14:04:57 -070021#include "adb_unique_fd.h"
22
Josh Gao1bbdd252018-04-05 17:55:25 -070023#if defined(_WIN32)
24
25// Layout of this struct must match struct WSABUF (verified via static assert in sysdeps_win32.cpp)
26struct adb_iovec {
27 size_t iov_len;
28 void* iov_base;
29};
30
Josh Gao90228a62019-04-25 14:04:57 -070031ssize_t adb_writev(borrowed_fd fd, const adb_iovec* iov, int iovcnt);
Josh Gao1bbdd252018-04-05 17:55:25 -070032
33#else
34
35#include <sys/uio.h>
36using adb_iovec = struct iovec;
Josh Gao90228a62019-04-25 14:04:57 -070037inline ssize_t adb_writev(borrowed_fd fd, const adb_iovec* iov, int iovcnt) {
38 return writev(fd.get(), iov, iovcnt);
39}
Josh Gao1bbdd252018-04-05 17:55:25 -070040
41#endif
42
43#pragma GCC poison writev