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

Commit 1e2a6a86 authored by Zach Johnson's avatar Zach Johnson
Browse files

Format gd/os with new clang-format

find os -regex '.*\.\(cc\|h\|tpp\)' -exec clang-format -style=file -i {} \;

Test: cert/run --host
Bug: 156858180
Tag: #gd-refactor
Change-Id: I567f20faa1dee599bda4d9d6e7a8a16586574d6c
parent e89d955f
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#include <unordered_map>

#include "benchmark/benchmark.h"

#include "common/bind.h"
#include "os/alarm.h"
#include "os/repeating_alarm.h"
@@ -117,7 +116,9 @@ BENCHMARK_DEFINE_F(BM_ReactableAlarm, periodic_accuracy)(State& state) {
    task_length_ = state.range(1);
    task_interval_ = state.range(2);
    start_time_ = std::chrono::steady_clock::now();
    repeating_alarm_->Schedule(Bind(&BM_ReactableAlarm_periodic_accuracy_Benchmark::AlarmSleepAndCountDelayedTime,
    repeating_alarm_->Schedule(
        Bind(
            &BM_ReactableAlarm_periodic_accuracy_Benchmark::AlarmSleepAndCountDelayedTime,
            bluetooth::common::Unretained(this)),
        std::chrono::milliseconds(task_interval_));
    promise_.get_future().get();
+2 −0
Original line number Diff line number Diff line
@@ -15,8 +15,10 @@
 */

#include "os/fuzz/fake_timerfd.h"

#include <sys/eventfd.h>
#include <unistd.h>

#include <map>

namespace bluetooth {
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once

#include <sys/timerfd.h>

#include <cstdint>

namespace bluetooth {
+6 −6
Original line number Diff line number Diff line
@@ -53,15 +53,15 @@ class Handler : public common::IPostableContext {
  void WaitUntilStopped(std::chrono::milliseconds timeout);

  template <typename Functor, typename... Args>
  common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, Args...>> BindOnce(Functor&& functor,
                                                                                        Args&&... args) {
  common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, Args...>> BindOnce(
      Functor&& functor, Args&&... args) {
    return common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, Args...>>(
        common::BindOnce(std::forward<Functor>(functor), std::forward<Args>(args)...), this);
  }

  template <typename Functor, typename T, typename... Args>
  common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, T, Args...>> BindOnceOn(T* obj, Functor&& functor,
                                                                                             Args&&... args) {
  common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, T, Args...>> BindOnceOn(
      T* obj, Functor&& functor, Args&&... args) {
    return common::ContextualOnceCallback<common::MakeUnboundRunType<Functor, T, Args...>>(
        common::BindOnce(std::forward<Functor>(functor), common::Unretained(obj), std::forward<Args>(args)...), this);
  }
@@ -73,8 +73,8 @@ class Handler : public common::IPostableContext {
  }

  template <typename Functor, typename T, typename... Args>
  common::ContextualCallback<common::MakeUnboundRunType<Functor, T, Args...>> BindOn(T* obj, Functor&& functor,
                                                                                     Args&&... args) {
  common::ContextualCallback<common::MakeUnboundRunType<Functor, T, Args...>> BindOn(
      T* obj, Functor&& functor, Args&&... args) {
    return common::ContextualCallback<common::MakeUnboundRunType<Functor, T, Args...>>(
        common::Bind(std::forward<Functor>(functor), common::Unretained(obj), std::forward<Args>(args)...), this);
  }
+5 −7
Original line number Diff line number Diff line
@@ -17,9 +17,10 @@
#include "os/alarm.h"

#include <sys/timerfd.h>
#include <cstring>
#include <unistd.h>

#include <cstring>

#include "common/bind.h"
#include "os/linux_generic/linux.h"
#include "os/log.h"
@@ -39,8 +40,8 @@ using common::OnceClosure;
Alarm::Alarm(Handler* handler) : handler_(handler), fd_(TIMERFD_CREATE(ALARM_CLOCK, 0)) {
  ASSERT_LOG(fd_ != -1, "cannot create timerfd: %s", strerror(errno));

  token_ = handler_->thread_->GetReactor()->Register(fd_, common::Bind(&Alarm::on_fire, common::Unretained(this)),
                                                     Closure());
  token_ = handler_->thread_->GetReactor()->Register(
      fd_, common::Bind(&Alarm::on_fire, common::Unretained(this)), Closure());
}

Alarm::~Alarm() {
@@ -54,10 +55,7 @@ Alarm::~Alarm() {
void Alarm::Schedule(OnceClosure task, std::chrono::milliseconds delay) {
  std::lock_guard<std::mutex> lock(mutex_);
  long delay_ms = delay.count();
  itimerspec timer_itimerspec{
    {/* interval for periodic timer */},
    {delay_ms / 1000, delay_ms % 1000 * 1000000}
  };
  itimerspec timer_itimerspec{{/* interval for periodic timer */}, {delay_ms / 1000, delay_ms % 1000 * 1000000}};
  int result = TIMERFD_SETTIME(fd_, 0, &timer_itimerspec, nullptr);
  ASSERT(result == 0);

Loading