Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36da573d authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Copy OSI_NO_INTR to net/posix

This macro is provided by the gd header os/include/osi.h.
This change is made to remove dependencies from Rootcanal on gd's
runtime.

Bug: 256013143
Test: m root-canal
Change-Id: I5a003a6885cad58c7421c58527524c8a3ea36d3b
parent 501e52fe
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ cc_defaults {
        "include",
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
    generated_headers: [
@@ -149,13 +148,8 @@ cc_test_host {
        "libbluetooth_headers",
    ],
    local_include_dirs: [
        "include",
        ".",
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
    shared_libs: [
        "liblog",
    ],
@@ -188,7 +182,6 @@ cc_test_host {
        "include",
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
    shared_libs: [
@@ -312,7 +305,6 @@ cc_library_static {
        "libbt_init_flags_bridge_header",
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd",
    ],
}
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@
#include <memory>

#include "os/log.h"
#include "osi/include/osi.h"

namespace rootcanal {
using namespace bluetooth::hci;
+6 −4
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
#include <cerrno>

#include "os/log.h"
#include "osi/include/osi.h"

namespace rootcanal {

@@ -42,8 +41,8 @@ size_t H4Packetizer::Send(uint8_t type, const uint8_t* data, size_t length) {
                        {const_cast<uint8_t*>(data), length}};
  ssize_t ret = 0;
  do {
    OSI_NO_INTR(ret = writev(uart_fd_, iov, sizeof(iov) / sizeof(iov[0])));
  } while (-1 == ret && EAGAIN == errno);
    ret = writev(uart_fd_, iov, sizeof(iov) / sizeof(iov[0]));
  } while (-1 == ret && (EINTR == errno || EAGAIN == errno));

  if (ret == -1) {
    LOG_ERROR("Error writing to UART (%s)", strerror(errno));
@@ -60,7 +59,10 @@ void H4Packetizer::OnDataReady(int fd) {
  std::vector<uint8_t> buffer(bytes_to_read);

  ssize_t bytes_read;
  OSI_NO_INTR(bytes_read = read(fd, buffer.data(), bytes_to_read));
  do {
    bytes_read = read(fd, buffer.data(), bytes_to_read);
  } while (bytes_read == -1 && errno == EINTR);

  if (bytes_read == 0) {
    LOG_INFO("remote disconnected!");
    disconnected_ = true;
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

#include "device_boutique.h"
#include "os/log.h"
#include "osi/include/osi.h"
#include "phy.h"

using std::vector;
+5 −4
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@

#include "model/setup/async_manager.h"  // for AsyncManager
#include "os/log.h"                     // for LOG_INFO
#include "osi/include/osi.h"            // for OSI_NO_INTR

#ifdef _WIN32
#include "msvc-posix.h"
@@ -74,7 +73,8 @@ ssize_t PosixAsyncSocket::Recv(uint8_t* buffer, uint64_t bufferSize) {

  errno = 0;
  ssize_t res = 0;
  OSI_NO_INTR(res = read(fd_, buffer, bufferSize));
  REPEAT_UNTIL_NO_INTR(res = read(fd_, buffer, bufferSize));

  if (res < 0) {
    DD("Recv < 0: %s (%d)", strerror(errno), fd_);
  }
@@ -94,7 +94,8 @@ ssize_t PosixAsyncSocket::Send(const uint8_t* buffer, uint64_t bufferSize) {
  // the socket.
  const int sendFlags = 0;
#endif
  OSI_NO_INTR(res = send(fd_, buffer, bufferSize, sendFlags));

  REPEAT_UNTIL_NO_INTR(res = send(fd_, buffer, bufferSize, sendFlags));

  DD("%zd bytes (%d)", res, fd_);
  return res;
@@ -131,7 +132,7 @@ void PosixAsyncSocket::Close() {
             &error_code_size);

  // shutdown sockets if possible,
  OSI_NO_INTR(shutdown(fd_, SHUT_RDWR));
  REPEAT_UNTIL_NO_INTR(shutdown(fd_, SHUT_RDWR));

  error_code = ::close(fd_);
  if (error_code == -1) {
Loading