#include "writer/verilog/dataflow_in.h"

#include "iroha/i_design.h"
#include "iroha/resource_class.h"
#include "writer/module_template.h"
#include "writer/verilog/insn_writer.h"
#include "writer/verilog/module.h"
#include "writer/verilog/shared_reg.h"

namespace iroha {
namespace writer {
namespace verilog {

DataFlowIn::DataFlowIn(const IResource &res, const Table &table)
  : Resource(res, table) {
}

void DataFlowIn::BuildResource() {
}

void DataFlowIn::BuildInsn(IInsn *insn, State *st) {
  IResource *res = insn->GetResource();
  IResource *parent = res->GetParentResource();
  if (insn->outputs_.size() == 1 && parent != nullptr &&
      resource::IsSharedReg(*(parent->GetClass()))) {
    ostream &ws = tmpl_->GetStream(kInsnWireValueSection);
    ws << "  assign " << InsnWriter::InsnOutputWireName(*insn, 0)
       << " = " << SharedReg::RegName(*parent) << ";\n";
  }
}

}  // namespace verilog
}  // namespace writer
}  // namespace iroha

#include "writer/verilog/dataflow_in.h"

#include "iroha/i_design.h"
#include "iroha/resource_class.h"
#include "writer/module_template.h"
#include "writer/verilog/insn_writer.h"
#include "writer/verilog/module.h"
#include "writer/verilog/shared_reg.h"

namespace iroha {
namespace writer {
namespace verilog {

DataFlowIn::DataFlowIn(const IResource &res, const Table &table)
  : Resource(res, table) {
}

void DataFlowIn::BuildResource() {
}

void DataFlowIn::BuildInsn(IInsn *insn, State *st) {
  IResource *res = insn->GetResource();
  IResource *parent = res->GetParentResource();
  if (parent != nullptr &&
      resource::IsSharedReg(*(parent->GetClass()))) {
    int s = 0;
    for (int i = 0; i < insn->outputs_.size(); ++i) {
      ostream &ws = tmpl_->GetStream(kInsnWireValueSection);
      ws << "  assign " << InsnWriter::InsnOutputWireName(*insn, i)
	 << " = " << SharedReg::RegName(*parent);
      if (insn->outputs_.size() > 1) {
	IRegister *reg = insn->outputs_[i];
	int w = reg->value_type_.GetWidth();
	ws << "[" << (s + w - 1) << ":" << s << "]";
	s += w;
      }
      ws << ";\n";
    }
  }
}

}  // namespace verilog
}  // namespace writer
}  // namespace iroha

Allow dataflow-in to accept multiple values.


#include "AboutDarkThemePluginDialog.h"
#include "ui_AboutDarkThemePluginDialog.h"

using namespace libqdark;

AboutDarkThemePluginDialog::AboutDarkThemePluginDialog(QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::AboutDarkThemePluginDialog)
{
    ui->setupUi(this);

    //ui->nameLabel->setText(m_ui->nameLabel->text() + " " + KEEPASSX_VERSION);

    auto nameLabelFont = ui->nameLabel->font();
    nameLabelFont.setBold(true);
    nameLabelFont.setPointSize(nameLabelFont.pointSize() + 4);
    ui->nameLabel->setFont(nameLabelFont);
}

AboutDarkThemePluginDialog::~AboutDarkThemePluginDialog() = default;

#include "AboutDarkThemePluginDialog.h"
#include "ui_AboutDarkThemePluginDialog.h"

#include <string>

using namespace libqdark;

AboutDarkThemePluginDialog::AboutDarkThemePluginDialog(QWidget* parent)
    : QDialog(parent)
    , ui(new Ui::AboutDarkThemePluginDialog)
{
    ui->setupUi(this);

    ui->nameLabel->setText(ui->nameLabel->text() + " " + LIBQDARK_VERSION);

    auto nameLabelFont = ui->nameLabel->font();
    nameLabelFont.setBold(true);
    nameLabelFont.setPointSize(nameLabelFont.pointSize() + 4);
    ui->nameLabel->setFont(nameLabelFont);

    QString commitHash;
    if (!QString(GIT_VERSION).isEmpty()) {
        commitHash = GIT_VERSION;
    }

    if (!commitHash.isEmpty()) {
        QString labelText = tr("Revision").append(": ").append(commitHash);
        ui->label_git->setText(labelText);
    }

    auto libs = QString("%1\n- Qt %2")
            .arg(ui->label_libs->text())
            .arg(QString::fromLocal8Bit(qVersion()));
    ui->label_libs->setText(libs);
}

AboutDarkThemePluginDialog::~AboutDarkThemePluginDialog() = default;

Add to about dialog info about current version


//#include <iostream>
#include SPECIFIC_HEADER

int main(int /*argc*/, char** /*argv*/)
{
  unsigned out {};
  constexpr unsigned num_runs = 1e7;
  for (unsigned run_id {} ; run_id != num_runs ; ++run_id)
  {
    out += most_significant_position(run_id);
  }
  //std::cout << out;
  bool success = out == unsigned(223222785);
  return !success;
}

//#include <iostream>
#include SPECIFIC_HEADER

int main(int /*argc*/, char** /*argv*/)
{
  unsigned out {};
  constexpr unsigned num_runs = 10000000;
  for (unsigned run_id {} ; run_id != num_runs ; ++run_id)
  {
    out += most_significant_position(run_id);
  }
  //std::cout << out;
  bool success = out == unsigned(223222785);
  return !success;
}

Fix compile double to unsigned

[most-significant-bit-position][vs] Fix compile double to unsigned


#include "Topology.hpp"
#include "Host.hpp"
#include "Hop.hpp"

using namespace std;

/*nmap -oX traceroute_all_subnet.xml -O -sV localhost*/
int main(int argc, char **argv)
{
  if(argc < 1)
  {
    cout << "Invalid number of program arguments: ";
    cout << "Usage ./build_topology <traceroute_file.xml>" << endl;
    exit(EXIT_FAILURE);
  }
  Host host(argv[1]);
  Hop hop(argv[2]);
  host.load();
  hop.load();
  host.print_vulnerabilities();
  cout << host.toJSON() << endl;
  cout << hop.toJSON() << endl;
  return 0;
}

#include "Topology.hpp"
#include "Host.hpp"
#include "Hop.hpp"
#include <fstream>

using namespace std;

/*nmap -oX traceroute_all_subnet.xml -O -sV localhost*/
int main(int argc, char **argv)
{
  if(argc < 1)
  {
    cout << "Invalid number of program arguments: ";
    cout << "Usage ./build_topology <traceroute_file.xml>" << endl;
    exit(EXIT_FAILURE);
  }
  Host host(argv[1]);
  Hop hop(argv[2]);
  host.load();
  hop.load();
  ofstream services, topology;
  services.open("services.json");
  topology.open("topology.json");
  //host.print_vulnerabilities();
  services << host.toJSON() << endl;
  topology << hop.toJSON() << endl;
  services.close();
  topology.close();
  return 0;
}

Write services and topology JSONs to file


#include <os>
#include "../x86_pc/idt.hpp"

void __arch_poweroff()
{
  asm("cli; hlt;");
  __builtin_unreachable();
}

void __platform_init()
{
  // setup CPU exception handlers
  x86::idt_initialize_for_cpu(0);
}

// not supported!
int64_t __arch_now() { return 0; }

void __arch_reboot(){}
void __arch_enable_legacy_irq(unsigned char){}
void __arch_disable_legacy_irq(unsigned char){}

void SMP::global_lock() noexcept {}
void SMP::global_unlock() noexcept {}
int SMP::cpu_id() noexcept { return 0; }
int SMP::cpu_count() noexcept { return 1; }

// Support for the boot_logger plugin.
__attribute__((weak))
bool os_enable_boot_logging = false;

#include <os>
#include "../x86_pc/idt.hpp"

void __arch_poweroff()
{
  asm("cli; hlt;");
  __builtin_unreachable();
}

void __platform_init()
{
  // setup CPU exception handlers
  x86::idt_initialize_for_cpu(0);
}

// not supported!
int64_t __arch_time_now() noexcept {
  return 0;
}

void __arch_reboot(){}
void __arch_enable_legacy_irq(unsigned char){}
void __arch_disable_legacy_irq(unsigned char){}

void SMP::global_lock() noexcept {}
void SMP::global_unlock() noexcept {}
int SMP::cpu_id() noexcept { return 0; }
int SMP::cpu_count() noexcept { return 1; }

// Support for the boot_logger plugin.
__attribute__((weak))
bool os_enable_boot_logging = false;

Fix arch_time_now wrong function name

x86_nano: Fix arch_time_now wrong function name


#include "primitives.hpp"
#include "event.hpp"
#include "gen/includes.hpp"

namespace rubinius {
  bool Primitives::unknown_primitive(STATE, VMExecutable* exec, Task* task, Message& msg) {
    std::cout << "\n";
    state->print_backtrace();
    std::cout << "Called unbound/invalid primitive: " << *msg.name->to_str(state) <<"\n";
    abort();
  }

#include "gen/primitives_glue.gen.cpp"
}

#include "primitives.hpp"
#include "event.hpp"
#include "gen/includes.hpp"

namespace rubinius {
  bool Primitives::unknown_primitive(STATE, VMExecutable* exec, Task* task, Message& msg) {
    std::cout << "\n";
    state->print_backtrace();
    std::cout << "Called unbound or invalid primitive from: " << *msg.name->to_str(state) <<"\n";
    abort();
  }

#include "gen/primitives_glue.gen.cpp"
}

Improve error message about primitive failures


#include <Python.h>

#include "module_lock.h"

#include "classad/classad.h"

using namespace condor;

pthread_mutex_t ModuleLock::m_mutex = PTHREAD_MUTEX_INITIALIZER;

ModuleLock::ModuleLock()
    : m_release_gil(!classad::ClassAdGetExpressionCaching()),
      m_owned(false)
{
    acquire();
}

void
ModuleLock::acquire()
{
    if (m_release_gil && !m_owned)
    {
        m_save = PyEval_SaveThread();
        pthread_mutex_lock(&m_mutex);
        m_owned = true;
    }
}

ModuleLock::~ModuleLock()
{
    release();
}

void
ModuleLock::release()
{
    if (m_release_gil && m_owned)
    {
        pthread_mutex_unlock(&m_mutex);
        PyEval_RestoreThread(m_save);
    }
}

#include <Python.h>

#include "module_lock.h"

#include "classad/classad.h"

using namespace condor;

pthread_mutex_t ModuleLock::m_mutex = PTHREAD_MUTEX_INITIALIZER;

ModuleLock::ModuleLock()
    : m_release_gil(!classad::ClassAdGetExpressionCaching()),
      m_owned(false), m_save(0)
{
    acquire();
}

void
ModuleLock::acquire()
{
    if (m_release_gil && !m_owned)
    {
        m_save = PyEval_SaveThread();
        pthread_mutex_lock(&m_mutex);
        m_owned = true;
    }
}

ModuleLock::~ModuleLock()
{
    release();
}

void
ModuleLock::release()
{
    if (m_release_gil && m_owned)
    {
        pthread_mutex_unlock(&m_mutex);
        PyEval_RestoreThread(m_save);
    }
}

Fix minor coverity unitialized ptr warning


#include "test.h"
#include "vast/util/visitor.h"

struct base;
struct t1;
struct t2;

typedef vast::util::const_visitor<base, t1, t2> concrete_visitor;

struct base
{
  VAST_ACCEPT(concrete_visitor)
  VAST_ACCEPT_CONST(concrete_visitor)
};

struct t1 : base
{
  VAST_ACCEPT(concrete_visitor)
  VAST_ACCEPT_CONST(concrete_visitor)

  int i = 42;
};

struct t2 : base
{
  VAST_ACCEPT(concrete_visitor)
  VAST_ACCEPT_CONST(concrete_visitor)

  double d = 4.2;
};

struct printer : concrete_visitor
{
  virtual void visit(base const& x)
  {
    BOOST_CHECK(! "should not be invoked");
  }

  virtual void visit(t1 const& x)
  {
    BOOST_CHECK_EQUAL(x.i, 42);
  }

  virtual void visit(t2 const& x)
  {
    BOOST_CHECK_EQUAL(x.d, 4.2);
  }
};

BOOST_AUTO_TEST_CASE(visitor)
{
  t1 x;
  t2 y;

  base* b1 = &x;
  base* b2 = &y;

  printer p;
  b1->accept(p);
  b2->accept(p);
}

#include "test.h"
#include "vast/util/visitor.h"

struct base;
struct t1;
struct t2;

typedef vast::util::const_visitor<base, t1, t2> concrete_visitor;

struct base
{
  VAST_ACCEPT(concrete_visitor)
  VAST_ACCEPT_CONST(concrete_visitor)
};

struct t1 : base
{
  VAST_ACCEPT(concrete_visitor)
  VAST_ACCEPT_CONST(concrete_visitor)

  int i = 42;
};

struct t2 : base
{
  VAST_ACCEPT(concrete_visitor)
  VAST_ACCEPT_CONST(concrete_visitor)

  double d = 4.2;
};

struct printer : concrete_visitor
{
  virtual void visit(base const&)
  {
    BOOST_CHECK(! "should not be invoked");
  }

  virtual void visit(t1 const& x)
  {
    BOOST_CHECK_EQUAL(x.i, 42);
  }

  virtual void visit(t2 const& x)
  {
    BOOST_CHECK_EQUAL(x.d, 4.2);
  }
};

BOOST_AUTO_TEST_CASE(visitor)
{
  t1 x;
  t2 y;

  base* b1 = &x;
  base* b2 = &y;

  printer p;
  b1->accept(p);
  b2->accept(p);
}

Fix warning about unused parameter.

Fix warning about unused parameter.


// Ensure that we have a quiet startup when we don't have the XRay
// instrumentation sleds.
//
// RUN: %clangxx -std=c++11 %s -o %t %xraylib
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1" %run %t 2>&1 | \
// RUN:    FileCheck %s --check-prefix NOISY
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=0" %run %t 2>&1 | \
// RUN:    FileCheck %s --check-prefix QUIET
// RUN: XRAY_OPTIONS="" %run %t 2>&1 | FileCheck %s --check-prefix DEFAULT
//
// FIXME: Understand how to make this work on other platforms
// REQUIRES: built-in-llvm-tree
// REQUIRES: x86_64-linux
#include <iostream>

using namespace std;

int main(int, char**) {
  // NOISY: {{.*}}XRay instrumentation map missing. Not initializing XRay.
  // QUIET-NOT: {{.*}}XRay instrumentation map missing. Not initializing XRay.
  // DEFAULT-NOT: {{.*}}XRay instrumentation map missing. Not initializing XRay.
  cout << "Hello, XRay!" << endl;
  // NOISY-NEXT: Hello, XRay!
  // QUIET: Hello, XRay!
  // DEFAULT: Hello, XRay!
}

// Ensure that we have a quiet startup when we don't have the XRay
// instrumentation sleds.
//
// RUN: %clangxx -std=c++11 %s -o %t %xraylib
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1" %run %t 2>&1 | \
// RUN:    FileCheck %s --check-prefix NOISY
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=0" %run %t 2>&1 | \
// RUN:    FileCheck %s --check-prefix QUIET
// RUN: XRAY_OPTIONS="" %run %t 2>&1 | FileCheck %s --check-prefix DEFAULT
//
// FIXME: Understand how to make this work on other platforms
// REQUIRES: built-in-llvm-tree
// REQUIRES: x86_64-linux
#include <iostream>

using namespace std;

int main(int, char**) {
  // NOISY: {{.*}}XRay instrumentation map missing. Not initializing XRay.
  // QUIET-NOT: {{.*}}XRay instrumentation map missing. Not initializing XRay.
  // DEFAULT-NOT: {{.*}}XRay instrumentation map missing. Not initializing XRay.
  cout << "Hello, XRay!" << endl;
  // NOISY: Hello, XRay!
  // QUIET: Hello, XRay!
  // DEFAULT: Hello, XRay!
}

[XRay][compiler-rt] Fix test to not be too strict with output order.

Follow-up to D35789.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@309543 91177308-0d34-0410-b5e6-96231b3b80d8


#include "DoorEntity.h"

DoorEntity::DoorEntity()
{
}

DoorEntity::~DoorEntity()
{
}

int DoorEntity::Initialize(int entityID, PhysicsComponent * pComp, GraphicsComponent * gComp)
{
	this->InitializeBase(entityID, pComp, gComp);

	this->m_isOpened = false;

	return 0;
}

int DoorEntity::Update(float dT, InputHandler * inputHandler)
{
	this->SyncComponents();

	return 0;
}

int DoorEntity::React(int entityID, EVENT reactEvent)
{
	if (reactEvent == EVENT::BUTTON_PRESSED)
	{
		if (!this->m_isOpened)
		{
			this->m_isOpened = true;
			this->m_pComp->PC_rotation = DirectX::XMVectorSet(0.f, 3.f, 0.f, 0.f);
		}
		else
		{
			this->m_isOpened = false;
			this->m_pComp->PC_rotation = DirectX::XMVectorSet(0.f, 0.f, 0.f, 0.f);
		}
	}

	return 0;
}

#include "DoorEntity.h"

DoorEntity::DoorEntity()
{
}

DoorEntity::~DoorEntity()
{
}

int DoorEntity::Initialize(int entityID, PhysicsComponent * pComp, GraphicsComponent * gComp)
{
	this->InitializeBase(entityID, pComp, gComp);

	this->m_isOpened = false;

	return 0;
}

int DoorEntity::Update(float dT, InputHandler * inputHandler)
{
	return 0;
}

int DoorEntity::React(int entityID, EVENT reactEvent)
{
	if (reactEvent == EVENT::BUTTON_PRESSED)
	{
		if (!this->m_isOpened)
		{
			this->m_isOpened = true;
			this->m_pComp->PC_rotation = DirectX::XMVectorSet(0.f, 3.f, 0.f, 0.f);
		}
		else
		{
			this->m_isOpened = false;
			this->m_pComp->PC_rotation = DirectX::XMVectorSet(0.f, 0.f, 0.f, 0.f);
		}
		this->SyncComponents();
	}

	return 0;
}

UPDATE moved component sync from update to react


#include <Pith/Config.hpp>
#include <Pith/Version.hpp>
#include <iostream>

extern "C" int pith_main(int argc, char** argv) {
	std::cout << "Pith version " << Pith::Version::STRING << " " << Pith::Version::COMMIT
		  << std::endl;
	return 0;
}

/// When no main is defined, pith defines a main that prints version information.
// int main (int argc, char** argv) __attribute__((weak alias("pith_main")));
#pragma weak main = pith_main

#include <Pith/Config.hpp>
#include <Pith/Version.hpp>
#include <iostream>

extern "C" auto pith_main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) -> int {
	std::cout << "Pith version " << Pith::Version::STRING << " " << Pith::Version::COMMIT
		  << std::endl;
	return 0;
}

/// When no main is defined, pith defines a main that prints version information.
// int main (int argc, char** argv) __attribute__((weak alias("pith_main")));
#pragma weak main = pith_main

Mark parameters of weak main as unused

Mark parameters of weak main as unused

Signed-off-by: Robert Young <42c59959a3f4413d6a1b4d7b4f99db457d199e49@gmail.com>


#include <Halide.h>
#include <stdio.h>
#include <stdlib.h>

using namespace Halide;

int main() {
    // This test must be run with an OpenGL target
    const Target &target = get_jit_target_from_environment();
    if (!target.has_feature(Target::OpenGL))  {
        fprintf(stderr,"ERROR: This test must be run with an OpenGL target, e.g. by setting HL_JIT_TARGET=host-opengl.\n");
        return 1;
    }

    Func f;
    Var x, y, c;

    f(x, y, c) = cast<uint8_t>(select(c == 0, 10*x + y,
                                      c == 1, 127, 12));

    Image<uint8_t> out(10, 10, 3);
    f.bound(c, 0, 3).glsl(x, y, c);
    f.realize(out);

    out.copy_to_host();
    for (int y=0; y<out.height(); y++) {
        for (int x=0; x<out.width(); x++) {
            if (!(out(x, y, 0) == 10*x+y && out(x, y, 1) == 127 && out(x, y, 2) == 12)) {
                fprintf(stderr, "Incorrect pixel (%d, %d, %d) at x=%d y=%d.\n",
                        out(x, y, 0), out(x, y, 1), out(x, y, 2),
                        x, y);
                return 1;
            }
        }
    }

    printf("Success!\n");
    return 0;
}

#include <Halide.h>
#include <stdio.h>
#include <stdlib.h>

using namespace Halide;

int main() {
    // This test must be run with an OpenGL target
    const Target &target = get_jit_target_from_environment();
    if (!target.has_feature(Target::OpenGL))  {
        fprintf(stderr,"ERROR: This test must be run with an OpenGL target, e.g. by setting HL_JIT_TARGET=host-opengl.\n");
        return 1;
    }

    Func f;
    Var x, y, c;

    f(x, y, c) = cast<uint8_t>(42);

    Image<uint8_t> out(10, 10, 3);
    f.bound(c, 0, 3).glsl(x, y, c);
    f.realize(out);

    out.copy_to_host();
    for (int y=0; y<out.height(); y++) {
        for (int x=0; x<out.width(); x++) {
            for (int z=0; x<out.channels(); x++) {
                if (!(out(x, y, z) == 42)) {
                    fprintf(stderr, "Incorrect pixel (%d) at x=%d y=%d z=%d.\n",
                            out(x, y, z), x, y, z);
                    return 1;
                }
            }
        }
    }

    printf("Success!\n");
    return 0;
}

Add a trivial write only GLSL test.

Add a trivial write only GLSL test.


// RUN: %clang_cc1 -std=c++17 -verify -emit-llvm-only %s

// expected-no-diagnostics

template <class T> void bar(const T &t) { foo(t); }

template <class>
struct HasFriend {
  template <class T>
  friend void foo(const HasFriend<T> &m) noexcept(false);
};

template <class T>
void foo(const HasFriend<T> &m) noexcept(false) {}

void f() {
  HasFriend<int> x;
  foo(x);
  bar(x);
}

namespace PR39742 {
template<typename>
struct wrapper {
  template<typename>
  friend void friend_function_template() {}
};

wrapper<bool> x;
wrapper<int> y;
}

// RUN: %clang_cc1 -std=c++17 -verify -emit-llvm-only %s

// expected-no-diagnostics

template <class T> void bar(const T &t) { foo(t); }

template <class>
struct HasFriend {
  template <class T>
  friend void foo(const HasFriend<T> &m) noexcept(false);
};

template <class T>
void foo(const HasFriend<T> &m) noexcept(false) {}

void f() {
  HasFriend<int> x;
  foo(x);
  bar(x);
}

namespace PR39742 {
template<typename>
struct wrapper {
  template<typename>
  friend void friend_function_template() {}
};

wrapper<bool> x;
// FIXME: We should really error here because of the redefinition of
// friend_function_template.
wrapper<int> y;
}

Address a post-commit review comment on r348325.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@348388 91177308-0d34-0410-b5e6-96231b3b80d8


/*
 * Copyright 2016 - 2019 gtalent2@gmail.com
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <cstdio>

#include "../media.hpp"

namespace nostalgia::core {

uint8_t *loadRom(const char *path) {
	auto file = fopen(path, "r");
	if (file) {
		fseek(file, 0, SEEK_END);
		const auto size = ftell(file);
		rewind(file);
		auto buff = new uint8_t[size];
		fread(buff, size, 1, file);
		fclose(file);
		return buff;
	} else {
		return nullptr;
	}
}

void unloadRom(uint8_t *rom) {
	delete rom;
}

}

/*
 * Copyright 2016 - 2019 gtalent2@gmail.com
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <fstream>

#include <ox/std/trace.hpp>

#include "../media.hpp"

namespace nostalgia::core {

uint8_t *loadRom(const char *path) {
	std::ifstream file(path, std::ios::binary | std::ios::ate);
	if (!file.good()) {
		oxTrace("nostalgia::core::userland::loadRom") << "Read failed:" << path;
		return nullptr;
	}

	const std::size_t size = file.tellg();
	file.seekg(0, std::ios::beg);
	auto buff = new uint8_t[size];
	file.read(reinterpret_cast<char*>(buff), size);
	return buff;
}

void unloadRom(uint8_t *rom) {
	delete rom;
}

}

[nostalgia/core/userland] Replace C file I/O with C++ file I/O to comply with handbook


#include "catch.hpp"
#include "../src/Board.h"

TEST_CASE("Board class tests", "[Board]")
{
  SECTION("The constructor properly sets width and height of the board")
  {
    const int desired_width = 11;
    const int desired_height = 12;
    Board b(desired_width, desired_height);
    REQUIRE(desired_width == b.width());
    REQUIRE(desired_height == b.height());
  }
}

#include "catch.hpp"
#include "../src/Board.h"

TEST_CASE("Board class tests", "[Board]")
{
  SECTION("The constructor properly sets width and height of the board")
  {
    const int desired_width = 11;
    const int desired_height = 12;
    Board b(desired_height, desired_width);
    REQUIRE(desired_height == b.height());
    REQUIRE(desired_width == b.width());
  }
}

Fix the order of parameters in Board class tests

The height should be passed as a first parameter, and the width
as the second one. It used to be the other way, causing one of the test
to (rightly so!) fail. This commit fixes the order of both parameters
in order to reflect a recent change in Board implementation.


#include <tightdb/row.hpp>
#include <tightdb/table.hpp>

using namespace std;
using namespace tightdb;

void RowBase::attach(Table* table, size_t row_ndx)
{
    if (table) {
        table->register_row_accessor(this); // Throws
        m_table.reset(table);
        m_row_ndx = row_ndx;
    }
}

void RowBase::reattach(Table* table, size_t row_ndx)
{
    if (m_table.get() != table) {
        if (table)
            table->register_row_accessor(this); // Throws
        if (m_table)
            m_table->unregister_row_accessor(this);
        m_table.reset(table);
    }
    m_row_ndx = row_ndx;
}

void RowBase::impl_detach() TIGHTDB_NOEXCEPT
{
    if (m_table) {
        m_table->unregister_row_accessor(this);
        m_table.reset();
    }
}

#include <tightdb/row.hpp>
#include <tightdb/table.hpp>

using namespace std;
using namespace tightdb;

void RowBase::attach(Table* table, size_t row_ndx)
{
    if (table) {
        table->register_row_accessor(this); // Throws
        m_table.reset(table);
        m_row_ndx = row_ndx;
    }
}

void RowBase::reattach(Table* table, size_t row_ndx)
{
    if (m_table.get() != table) {
        if (m_table)
            m_table->unregister_row_accessor(this);
        if (table)
            table->register_row_accessor(this); // Throws
        m_table.reset(table);
    }
    m_row_ndx = row_ndx;
}

void RowBase::impl_detach() TIGHTDB_NOEXCEPT
{
    if (m_table) {
        m_table->unregister_row_accessor(this);
        m_table.reset();
    }
}

Detach table accessors before attaching to a new table


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/cancellation_flag.h"

#include "base/logging.h"

namespace base {

void CancellationFlag::Set() {
#if !defined(NDEBUG)
  DCHECK(set_on_ == PlatformThread::CurrentId());
#endif
  base::subtle::Release_Store(&flag_, 1);
}

bool CancellationFlag::IsSet() const {
  return base::subtle::Acquire_Load(&flag_) != 0;
}

}  // namespace base

// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/cancellation_flag.h"

#include "base/logging.h"

namespace base {

void CancellationFlag::Set() {
#if !defined(NDEBUG)
  DCHECK_EQ(set_on_, PlatformThread::CurrentId());
#endif
  base::subtle::Release_Store(&flag_, 1);
}

bool CancellationFlag::IsSet() const {
  return base::subtle::Acquire_Load(&flag_) != 0;
}

}  // namespace base

Replace a DCHECK with DCHECK_EQ.

Replace a DCHECK with DCHECK_EQ.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2919013

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@52429 0039d316-1c4b-4281-b951-d872f2087c98


#include "SerialCommand.h"
#include "anyware_serial.h"

void unrecognized(const char *cmd)
{
  printError(F("unrecognized command"), cmd);
}

/*!
  RESET [<bool>]
*/
void reset_action()
{
  char *debugarg = sCmd.next();
  bool debug = false;
  if (debugarg) debug = atoi(debugarg);
  reset(debug);
}

/*!
  IDENTITY <userid>
*/
void identity_action()
{
  char *userarg = sCmd.next();
  if (!userarg) {
    printError(F("protocol error"), F("wrong # of parameters to IDENTITY"));
    return;
  }
  global_userid = getUserIdArg(userarg);
  // FIXME: Validity check?

  if (global_debug) {
    Serial.print(F("DEBUG Identity set, userid="));
    Serial.println(global_userid);
  }
}

void setupCommonCommands()
{
  sCmd.addCommand("RESET", reset_action);
  sCmd.addCommand("IDENTITY", identity_action);
  sCmd.setDefaultHandler(unrecognized);
}

#include "SerialCommand.h"
#include "anyware_serial.h"

void unrecognized(const char *cmd)
{
  printError(F("unrecognized command"), cmd);
}

/*!
  RESET [<bool>]
*/
void reset_action()
{
  char *debugarg = sCmd.next();
  bool debug = false;
  if (debugarg) debug = atoi(debugarg);
  reset(debug);
}

/*!
  IDENTITY <userid>
*/
void identity_action()
{
  char *userarg = sCmd.next();
  if (!userarg) {
    printError(F("protocol error"), F("wrong # of parameters to IDENTITY"));
    return;
  }
  uint8_t userid = getUserIdArg(userarg);
  if (userid > 2) {
    printError(F("protocol error"), F("Illegal userid argument"));
    return;
  }
  global_userid = userid;

  if (global_debug) {
    Serial.print(F("DEBUG Identity set, userid="));
    Serial.println(global_userid);
  }
}

void setupCommonCommands()
{
  sCmd.addCommand("RESET", reset_action);
  sCmd.addCommand("IDENTITY", identity_action);
  sCmd.setDefaultHandler(unrecognized);
}

Validate userid for IDENTITY command

Validate userid for IDENTITY command


#include "memory.h"

namespace EPITOME
{
	template <typename T>
	Room<T>::Room() {}

	template <typename T>
	Room<T>::~Room()
	{
		Empty();
	}

	template <typename T>
	Room<T>::Room(Room&& other)
	{
		items = other.items;
		other.items.clear();
	}

	template<typename T>
	void Room<T>::Add(T* item)
	{
		items.push_back(item);
	}

	template <typename T>
	void Room<T>::Empty()
	{
		for (T* a : items)
		{
			a->Dispose();
			delete a;
		}
		items.clear();
	}

	template <typename T>
	Disposable<T>::Disposable(T item)
	{
		this->item = item;
	}

	template <typename T>
	Disposable<T>::Dispose() {}
}

#include "memory.h"

namespace EPITOME
{
	template <typename T>
	Room<T>::Room() {}

	template <typename T>
	Room<T>::~Room()
	{
		Empty();
	}

	template <typename T>
	Room<T>::Room(Room&& other)
	{
		items = other.items;
		other.items.clear();
	}

	template<typename T>
	void Room<T>::Add(T* item)
	{
		items.push_back(item);
	}

	template <typename T>
	void Room<T>::Empty()
	{
		for (T* a : items)
		{
			a->Dispose();
			delete a;
		}
		items.clear();
	}

	template <typename T>
	Disposable<T>::Disposable(T item)
	{
		this->item = item;
	}

	template <typename T>
	void Disposable<T>::Dispose() {}
}

Add void to fix error

Add void to fix error


#include "core.h"
#include "main.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(main_tests)

BOOST_AUTO_TEST_CASE(subsidy_limit_test)
{
    uint64_t nSum = 0;
    for (int nHeight = 0; nHeight < 7000000; nHeight += 1000) {
        uint64_t nSubsidy = GetBlockValue(nHeight, 0);
        BOOST_CHECK(nSubsidy <= 50 * COIN);
        nSum += nSubsidy * 1000;
        BOOST_CHECK(MoneyRange(nSum));
    }
    BOOST_CHECK(nSum == 2099999997690000ULL);
}

BOOST_AUTO_TEST_SUITE_END()

#include "core.h"
#include "main.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_SUITE(main_tests)

BOOST_AUTO_TEST_CASE(subsidy_limit_test)
{
    uint64_t nSum = 0;
    for (int nHeight = 0; nHeight < 14000000; nHeight += 1000) {
        uint64_t nSubsidy = GetBlockValue(nHeight, 0);
        BOOST_CHECK(nSubsidy <= 50 * COIN);
        nSum += nSubsidy * 1000;
        BOOST_CHECK(MoneyRange(nSum));
    }
    BOOST_CHECK(nSum == 2099999997690000ULL);
}

BOOST_AUTO_TEST_SUITE_END()

Edit subsidy_limit_test to account for BIP42

Because no one wants 4 gold mines being discovered every mibillenium.


// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "v8.h"

#include "function-tester.h"

using namespace v8::internal;
using namespace v8::internal::compiler;

TEST(TurboSimpleDeopt) {
  FLAG_allow_natives_syntax = true;
  FLAG_turbo_deoptimization = true;

  FunctionTester T(
      "(function f(a) {"
      "var b = 1;"
      "if (!%IsOptimized()) return 0;"
      "%DeoptimizeFunction(f);"
      "if (%IsOptimized()) return 0;"
      "return a + b; })");

  T.CheckCall(T.Val(2), T.Val(1));
}

TEST(TurboTrivialDeopt) {
  FLAG_allow_natives_syntax = true;
  FLAG_turbo_deoptimization = true;

  FunctionTester T(
      "(function foo() {"
      "%DeoptimizeFunction(foo);"
      "return 1; })");

  T.CheckCall(T.Val(1));
}

// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/v8.h"

#include "test/cctest/compiler/function-tester.h"

using namespace v8::internal;
using namespace v8::internal::compiler;

TEST(TurboSimpleDeopt) {
  FLAG_allow_natives_syntax = true;
  FLAG_turbo_deoptimization = true;

  FunctionTester T(
      "(function f(a) {"
      "var b = 1;"
      "if (!%IsOptimized()) return 0;"
      "%DeoptimizeFunction(f);"
      "if (%IsOptimized()) return 0;"
      "return a + b; })");

  T.CheckCall(T.Val(2), T.Val(1));
}

TEST(TurboTrivialDeopt) {
  FLAG_allow_natives_syntax = true;
  FLAG_turbo_deoptimization = true;

  FunctionTester T(
      "(function foo() {"
      "%DeoptimizeFunction(foo);"
      "return 1; })");

  T.CheckCall(T.Val(1));
}

Fix relative include path in cctest case.

R=jarin@chromium.org, titzer@chromium.org

Review URL: https://codereview.chromium.org/426233003

git-svn-id: f98b9d40cb02301bc76fa9e1b46ee668158567fd@22721 ce2b1a6d-e550-0410-aec6-3dcde31c8c00


// Copyright 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ozone/ui/desktop_aura/desktop_factory_wayland.h"

#include "ozone/ui/desktop_aura/desktop_screen_wayland.h"
#include "ozone/ui/desktop_aura/desktop_window_tree_host_wayland.h"
#include "ozone/wayland/display.h"

namespace views {

DesktopFactoryWayland::DesktopFactoryWayland() : views::DesktopFactoryOzone(),
    desktop_screen_(NULL) {
  LOG(INFO) << "Ozone: DesktopFactoryWayland";
  DesktopFactoryOzone::SetInstance(this);
}

DesktopFactoryWayland::~DesktopFactoryWayland() {
  DesktopFactoryOzone::SetInstance(NULL);
  delete desktop_screen_;
}

DesktopWindowTreeHost* DesktopFactoryWayland::CreateWindowTreeHost(
    internal::NativeWidgetDelegate* native_widget_delegate,
    DesktopNativeWidgetAura* desktop_native_widget_aura) {
  return new DesktopWindowTreeHostWayland(native_widget_delegate,
                                          desktop_native_widget_aura);
}

gfx::Screen* DesktopFactoryWayland::CreateDesktopScreen() {
  if (!desktop_screen_) {
    desktop_screen_ = new DesktopScreenWayland();
    ozonewayland::WaylandDisplay::LookAheadOutputGeometry();
  }

  return desktop_screen_;
}

}  // namespace views

// Copyright 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ozone/ui/desktop_aura/desktop_factory_wayland.h"

#include "ozone/ui/desktop_aura/desktop_screen_wayland.h"
#include "ozone/ui/desktop_aura/desktop_window_tree_host_wayland.h"
#include "ozone/ui/gfx/ozone_display.h"

namespace views {

DesktopFactoryWayland::DesktopFactoryWayland() : views::DesktopFactoryOzone(),
    desktop_screen_(NULL) {
  LOG(INFO) << "Ozone: DesktopFactoryWayland";
  DesktopFactoryOzone::SetInstance(this);
}

DesktopFactoryWayland::~DesktopFactoryWayland() {
  DesktopFactoryOzone::SetInstance(NULL);
  delete desktop_screen_;
}

DesktopWindowTreeHost* DesktopFactoryWayland::CreateWindowTreeHost(
    internal::NativeWidgetDelegate* native_widget_delegate,
    DesktopNativeWidgetAura* desktop_native_widget_aura) {
  return new DesktopWindowTreeHostWayland(native_widget_delegate,
                                          desktop_native_widget_aura);
}

gfx::Screen* DesktopFactoryWayland::CreateDesktopScreen() {
  if (!desktop_screen_) {
    desktop_screen_ = new DesktopScreenWayland();
    gfx::OzoneDisplay::GetInstance()->LookAheadOutputGeometry();
  }

  return desktop_screen_;
}

}  // namespace views

desktop_aura: Prepare to build desktop_aura/ as part of views only.

Replace the usage of WaylandDisplay class with OzoneDisplay, so we dont
have to build Ozone-Wayland as part of views but rather have it as it's
dependency.


//
// Created by Timo on 18.04.2016.
//

#include <cmath>
#include "fixed_point.h"

fixed_point::fixed_point(float x) {
    q = x * std::pow(2, 16);
}

fixed_point::operator int() const {
    return q / std::pow(2, 16);
}

fixed_point::operator float() const {
    return q / std::pow(2, 16);
}

fixed_point abs(fixed_point fixedPoint) {
    float temp = (float) fixedPoint;
    if (temp >= 0) {
        return fixed_point(temp);
    } else {
        return fixed_point(-temp);
    }
}

bool fixed_point::operator==(fixed_point rhs) const {
    return q == rhs.q;
}

bool fixed_point::operator!=(fixed_point rhs) const {
    return q != rhs.q;
}

bool fixed_point::operator<(fixed_point rhs) const {
    return q < rhs.q;
}

bool fixed_point::operator>(fixed_point rhs) const {
    return q > rhs.q;
}

bool fixed_point::operator<=(fixed_point rhs) const {
    return q <= rhs.q;
}

bool fixed_point::operator>=(fixed_point rhs) const {
    return q >= rhs.q;
}

//
// Created by Timo on 18.04.2016.
//

#include <cmath>
#include "fixed_point.h"

fixed_point::fixed_point(float x) {
    q = x * std::pow(2, 16);
}

fixed_point::operator int() const {
    return q / std::pow(2, 16);
}

fixed_point::operator float() const {
    return q / std::pow(2, 16);
}

fixed_point abs(fixed_point fixedPoint) {
    if (fixedPoint >= 0) {
        return fixedPoint;
    } else {
        return -fixedPoint;
    }
}

bool fixed_point::operator==(fixed_point rhs) const {
    return q == rhs.q;
}

bool fixed_point::operator!=(fixed_point rhs) const {
    return q != rhs.q;
}

bool fixed_point::operator<(fixed_point rhs) const {
    return q < rhs.q;
}

bool fixed_point::operator>(fixed_point rhs) const {
    return q > rhs.q;
}

bool fixed_point::operator<=(fixed_point rhs) const {
    return q <= rhs.q;
}

bool fixed_point::operator>=(fixed_point rhs) const {
    return q >= rhs.q;
}

Update abs() to not use float.

Update abs() to not use float.


#include <QtCore/QCoreApplication>
#include "signalwatcher.h"

static SignalWatcher* g_instance = 0;

SignalWatcher::SignalWatcher(void)
	: QObject(qApp)
{
}

bool SignalWatcher::watch(int sig)
{
	Q_UNUSED(sig)
	return false;
}

bool SignalWatcher::unwatch(int sig)
{
	Q_UNUSED(sig)
	return false;
}

SignalWatcher::~SignalWatcher(void)
{
	g_instance = 0;
}

SignalWatcher* SignalWatcher::instance(void)
{
	if (!g_instance) {
		g_instance = new SignalWatcher();
	}

	return g_instance;
}

#include <QtCore/QCoreApplication>
#include "signalwatcher.h"

class SignalWatcherPrivate {}

static SignalWatcher* g_instance = 0;

SignalWatcher::SignalWatcher(void)
	: QObject(qApp)
{
}

bool SignalWatcher::watch(int sig)
{
	Q_UNUSED(sig)
	return false;
}

bool SignalWatcher::unwatch(int sig)
{
	Q_UNUSED(sig)
	return false;
}

SignalWatcher::~SignalWatcher(void)
{
	g_instance = 0;
}

SignalWatcher* SignalWatcher::instance(void)
{
	if (!g_instance) {
		g_instance = new SignalWatcher();
	}

	return g_instance;
}

Fix for really weird compile time configurations


#include <Zmey/Components/TransformManager.h>

#include <nlohmann/json.hpp>

#include <Zmey/Components/ComponentRegistry.h>

namespace Zmey
{
namespace Components
{

void TransformComponentToBlob(const nlohmann::json& rawJson, IDataBlob& blob)
{
	//float position[3];
	//position[0] = rawJson["Position"][0];
	//position[1] = rawJson["Position"][1];
	//position[2] = rawJson["Position"][2];
	//blob.WriteData("Position", reinterpret_cast<uint8_t*>(position), sizeof(position));
	//
	//float rotation[4];
	//rotation[0] = rawJson["Rotation"][0];
	//rotation[1] = rawJson["Rotation"][1];
	//rotation[2] = rawJson["Rotation"][2];
	//rotation[2] = rawJson["Rotation"][3];
	//blob.WriteData("Rotation", reinterpret_cast<uint8_t*>(rotation), sizeof(rotation));
	//
	//float scale[3];
	//scale[0] = rawJson["Scale"][0];
	//scale[1] = rawJson["Scale"][1];
	//scale[2] = rawJson["Scale"][2];
	//blob.WriteData("Scale", reinterpret_cast<uint8_t*>(scale), sizeof(scale));
}

}
}
REGISTER_COMPONENT_MANAGER(Transform, nullptr, nullptr); // Replace with correct implementations

#include <Zmey/Components/TransformManager.h>

#include <nlohmann/json.hpp>

#include <Zmey/Components/ComponentRegistry.h>

namespace Zmey
{
namespace Components
{

void TransformComponentToBlob(const nlohmann::json& rawJson, IDataBlob& blob)
{
	float position[3];
	position[0] = rawJson["Position"][0];
	position[1] = rawJson["Position"][1];
	position[2] = rawJson["Position"][2];
	blob.WriteData("Position", reinterpret_cast<uint8_t*>(position), sizeof(position));

	float rotation[4];
	rotation[0] = rawJson["Rotation"][0];
	rotation[1] = rawJson["Rotation"][1];
	rotation[2] = rawJson["Rotation"][2];
	rotation[2] = rawJson["Rotation"][3];
	blob.WriteData("Rotation", reinterpret_cast<uint8_t*>(rotation), sizeof(rotation));

	float scale[3];
	scale[0] = rawJson["Scale"][0];
	scale[1] = rawJson["Scale"][1];
	scale[2] = rawJson["Scale"][2];
	blob.WriteData("Scale", reinterpret_cast<uint8_t*>(scale), sizeof(scale));
}

}
}
REGISTER_COMPONENT_MANAGER(Transform, &Zmey::Components::TransformComponentToBlob, nullptr); // Replace with correct implementations

Implement ComponentToBlob for the transform manager.


// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chrome_browser_main_aura.h"

#include "base/logging.h"

ChromeBrowserMainPartsAura::ChromeBrowserMainPartsAura(
    const MainFunctionParams& parameters) {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PreEarlyInitialization() {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PostMainMessageLoopStart() {
  NOTIMPLEMENTED();
}

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chrome_browser_main_aura.h"

#include "base/logging.h"

ChromeBrowserMainPartsAura::ChromeBrowserMainPartsAura(
    const MainFunctionParams& parameters)
  : ChromeBrowserMainParts(parameters) {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PreEarlyInitialization() {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PostMainMessageLoopStart() {
  NOTIMPLEMENTED();
}

Fix Aura compile error. My bad.

Fix Aura compile error. My bad.

TBR=ben@chromium.org
BUG=none
TEST=none

Review URL: http://codereview.chromium.org/8098014

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@103581 0039d316-1c4b-4281-b951-d872f2087c98


#define BOOST_ERROR_CODE_HEADER_ONLY
#include <Combaseapi.h>
#include <boost/system/error_code.hpp>

#define BOOST_ERROR_CODE_HEADER_ONLY
#include <boost/system/error_code.hpp>

Remove (unnecessary) win32 only header.

Remove (unnecessary) win32 only header.


/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkNullCanvas.h"

#include "SkCanvas.h"
#include "SKNWayCanvas.h"

SkCanvas* SkCreateNullCanvas() {
    // An N-Way canvas forwards calls to N canvas's. When N == 0 it's
    // effectively a null canvas.
    return SkNEW(SkNWayCanvas);
}

/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "SkNullCanvas.h"

#include "SkCanvas.h"
#include "SKNWayCanvas.h"

SkCanvas* SkCreateNullCanvas() {
    // An N-Way canvas forwards calls to N canvas's. When N == 0 it's
    // effectively a null canvas.
    return SkNEW(SkNWayCanvas(0,0));
}

Fix SkNWayCanvas cons call when creating null canvas.

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@4223 2bbb7eff-a529-9590-31e7-b0007b416f81


#include "mytablemodel.h"

int MyTableModel::rowCount(const QModelIndex &parent) const
{
    return m_data.size();
}

int MyTableModel::columnCount(const QModelIndex &parent) const
{
    return 2;
}

QVariant MyTableModel::data(const QModelIndex &index, int role) const
{
    Record const& dataElem = m_data[index.row()];

    if (index.column() == 0)
        return QVariant(dataElem.label);
    else
        return QVariant(dataElem.number);
}

bool MyTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    return false;
}

Qt::ItemFlags MyTableModel::flags(const QModelIndex &index) const
{
    return Qt::ItemFlags();
}

void MyTableModel::insertRow()
{
    m_data.push_back({ "label", 0 });
}

#include "mytablemodel.h"

int MyTableModel::rowCount(const QModelIndex &parent) const
{
    return m_data.size();
}

int MyTableModel::columnCount(const QModelIndex &parent) const
{
    return 2;
}

QVariant MyTableModel::data(const QModelIndex &index, int role) const
{
    Record const& dataElem = m_data[index.row()];

    if (index.column() == 0)
        return QVariant(dataElem.label);
    else
        return QVariant(dataElem.number);
}

bool MyTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    return false;
}

Qt::ItemFlags MyTableModel::flags(const QModelIndex &index) const
{
    return Qt::ItemFlags();
}

void MyTableModel::insertRow()
{
    m_data.push_back({ "label", 0 });
    emit layoutChanged();
}

Update table view on add row

Update table view on add row


#include "perf_precomp.hpp"

using namespace std;
using namespace cv;
using namespace perf;

typedef TestBaseWithParam< pair<string, string> > ImagePair;

pair<string, string> impair(const char* im1, const char* im2)
{
    return make_pair(string(im1), string(im2));
}

PERF_TEST_P(ImagePair, OpticalFlowDual_TVL1, testing::Values(impair("cv/optflow/RubberWhale1.png", "cv/optflow/RubberWhale2.png")))
{
    declare.time(40);

    Mat frame1 = imread(getDataPath(GetParam().first), IMREAD_GRAYSCALE);
    Mat frame2 = imread(getDataPath(GetParam().second), IMREAD_GRAYSCALE);
    ASSERT_FALSE(frame1.empty());
    ASSERT_FALSE(frame2.empty());

    Mat flow;

    OpticalFlowDual_TVL1 tvl1;

    TEST_CYCLE()
    {
        tvl1(frame1, frame2, flow);
    }

    SANITY_CHECK(flow);
}

#include "perf_precomp.hpp"

using namespace std;
using namespace cv;
using namespace perf;

typedef TestBaseWithParam< pair<string, string> > ImagePair;

pair<string, string> impair(const char* im1, const char* im2)
{
    return make_pair(string(im1), string(im2));
}

PERF_TEST_P(ImagePair, OpticalFlowDual_TVL1, testing::Values(impair("cv/optflow/RubberWhale1.png", "cv/optflow/RubberWhale2.png")))
{
    declare.time(40);

    Mat frame1 = imread(getDataPath(GetParam().first), IMREAD_GRAYSCALE);
    Mat frame2 = imread(getDataPath(GetParam().second), IMREAD_GRAYSCALE);
    ASSERT_FALSE(frame1.empty());
    ASSERT_FALSE(frame2.empty());

    Mat flow;

    OpticalFlowDual_TVL1 tvl1;

    TEST_CYCLE()
    {
        tvl1(frame1, frame2, flow);
    }

    SANITY_CHECK(flow, 0.02);
}

Set sanity threshold for TVL1 optical flow to 0.02


#include "stagestack.h"

namespace OpenApoc {

void StageStack::Push(std::shared_ptr<Stage> newStage)
{

	// Pause any current stage
	if(this->Current())
		this->Current()->Pause();

	this->Stack.push(newStage);
	newStage->Begin();
}

std::shared_ptr<Stage> StageStack::Pop()
{
	std::shared_ptr<Stage> result = this->Current();

	if (result)
	{
		Stack.pop();
	}

	// If there's still an item on the stack, resume it
	if( this->Current() )
		this->Current()->Resume();

	return result;
}

std::shared_ptr<Stage> StageStack::Current()
{
	if (this->Stack.empty())
		return nullptr;
	else
		return this->Stack.top();
}

bool StageStack::IsEmpty()
{
	return this->Stack.empty();
}

void StageStack::Clear()
{
	while (!this->Stack.empty())
		this->Stack.pop();
}

}; //namespace OpenApoc

#include "stagestack.h"

namespace OpenApoc {

void StageStack::Push(std::shared_ptr<Stage> newStage)
{

	// Pause any current stage
	if(this->Current())
		this->Current()->Pause();

	this->Stack.push(newStage);
	newStage->Begin();
}

std::shared_ptr<Stage> StageStack::Pop()
{
	std::shared_ptr<Stage> result = this->Current();

	if (result)
	{
		result->Finish();
		Stack.pop();
	}

	// If there's still an item on the stack, resume it
	if( this->Current() )
		this->Current()->Resume();

	return result;
}

std::shared_ptr<Stage> StageStack::Current()
{
	if (this->Stack.empty())
		return nullptr;
	else
		return this->Stack.top();
}

bool StageStack::IsEmpty()
{
	return this->Stack.empty();
}

void StageStack::Clear()
{
	while (!this->IsEmpty())
		this->Pop();
}

}; //namespace OpenApoc

Call Finish() on Stages removed from the stack


// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/tools/test_shell/test_shell_test.h"

using WebKit::WebView;

class WebViewTest : public TestShellTest {
};

TEST_F(WebViewTest, GetContentAsPlainText) {
  WebView* view = test_shell_->webView();
  ASSERT_TRUE(view != 0);

  view->setIsActive(true);
  EXPECT_TRUE(view->isActive());

  view->setIsActive(false);
  EXPECT_FALSE(view->isActive());

  view->setIsActive(true);
  EXPECT_TRUE(view->isActive());
}

// TODO(viettrungluu): add more tests

// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/tools/test_shell/test_shell_test.h"

using WebKit::WebView;

class WebViewTest : public TestShellTest {
};

TEST_F(WebViewTest, ActiveState) {
  WebView* view = test_shell_->webView();
  ASSERT_TRUE(view != 0);

  view->setIsActive(true);
  EXPECT_TRUE(view->isActive());

  view->setIsActive(false);
  EXPECT_FALSE(view->isActive());

  view->setIsActive(true);
  EXPECT_TRUE(view->isActive());
}

// TODO(viettrungluu): add more tests

Rename unit test: WebViewTest.GetContentAsPlainText -> WebViewTest.ActiveState.

I'm responsible for misnaming it in the first place (cut-and-paste error). Oops.

BUG=23501
TEST=none

Review URL: http://codereview.chromium.org/414034

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@32612 4ff67af0-8c30-449e-8e8b-ad334ec8d88c


// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/test/test_timeouts.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/application/application_test_base_chromium.h"
#include "mojo/public/c/system/main.h"

MojoResult MojoMain(MojoHandle handle) {
  // An AtExitManager instance is needed to construct message loops.
  base::AtExitManager at_exit;

  // Initialize test timeouts, which requires CommandLine::ForCurrentProcess().
  // TODO(msw): Plumb relevant command line args before initializing timeouts.
  mojo::ApplicationRunnerChromium::InitBaseCommandLine();
  TestTimeouts::Initialize();

  return mojo::test::RunAllTests(handle);
}

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/test/test_timeouts.h"
#include "mojo/application/application_runner_chromium.h"
#include "mojo/application/application_test_base_chromium.h"
#include "mojo/public/c/system/main.h"

MojoResult MojoMain(MojoHandle handle) {
  // An AtExitManager instance is needed to construct message loops.
  base::AtExitManager at_exit;

  // Initialize the current process Commandline and test timeouts.
  mojo::ApplicationRunnerChromium::InitBaseCommandLine();
  TestTimeouts::Initialize();

  return mojo::test::RunAllTests(handle);
}

Update the application_test_main CommandLine comment.

BUG=NONE
TEST=NONE
TBR=sky@chromium.org

Review URL: https://codereview.chromium.org/1097783003

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#326183}


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/renderer/renderer_logging.h"

#include "base/logging.h"
#include "googleurl/src/gurl.h"

namespace renderer_logging {

// Sets the URL that is logged if the renderer crashes. Use GURL() to clear
// the URL.
void SetActiveRendererURL(const GURL& url) {
  // TODO(port): Once breakpad is integrated we can turn this on.
  NOTIMPLEMENTED();
}

}  // namespace renderer_logging

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/renderer/renderer_logging.h"

#include "base/logging.h"
#include "googleurl/src/gurl.h"

namespace renderer_logging {

// Sets the URL that is logged if the renderer crashes. Use GURL() to clear
// the URL.
void SetActiveRendererURL(const GURL& url) {
  // crbug.com/9646
}

}  // namespace renderer_logging

Comment out a very annoying NOTIMPLEMENTED().

Review URL: http://codereview.chromium.org/56183

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@13024 0039d316-1c4b-4281-b951-d872f2087c98


#include "photoeffects.hpp"
#include "stdio.h"

using namespace cv;

int tint(InputArray src, OutputArray dst,
        const Vec3b &colorTint, float density)
{
    CV_Assert(src.type() == CV_8UC3);
    CV_Assert(density >= 0.0f && density <= 1.0f);
    dst.create(src.size(), CV_8UC3);
    Mat image = src.getMat(), outputImage = dst.getMat();

    float negDen = 1 - density;
    for (int i = 0; i < image.rows; i++)
    {
        for (int j = 0; j < image.cols; j++)
        {
            Vec3b colorDest = image.at<Vec3b>(i, j);
            colorDest = colorTint * density + negDen * colorDest;
            outputImage.at<Vec3b>(i, j) = colorDest;
        }
    }
    return 0;
}

#include "photoeffects.hpp"
#include "stdio.h"

using namespace cv;

int tint(InputArray src, OutputArray dst,
        const Vec3b &colorTint, float density)
{
    CV_Assert(src.type() == CV_8UC3);
    CV_Assert(density >= 0.0f && density <= 1.0f);
    dst.create(src.size(), CV_8UC3);
    Mat image = src.getMat(), outputImage = dst.getMat();
    Mat matColTint(src.size(), CV_8UC3, Scalar(colorTint[0], colorTint[1], colorTint[2]));

    outputImage = matColTint * density + image * (1 - density);
    return 0;
}

Change to operations with Mat

Change to operations with Mat


#include "RedisClient.h"

#include <string>
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;

    REDIS_ENDPOINT endpoints[1] = {
        { "127.0.0.1", 6379 },
        //{ "127.0.0.1", 6380 },
        //{ "127.0.0.1", 6381 },
    };

    REDIS_CONFIG conf = {
        (REDIS_ENDPOINT*)&endpoints,
        1,
        10000,
        5000,
        20,
        1,
    };

    RedisClient client(conf);

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    string res = client.set("key0", "value0");
    cout << "SET: " << res << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    res = client.get("key0");
    cout << "GET: " << res << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    client.set("count0", "0");
    long long count0;
    for (long long i = 0; i < 1000; i++) {
        count0 = client.incr("count0");
    }
    cout << "INCR count0 to " << count0 << endl;

    return 0;
}

#include "RedisClient.h"

#include <string>
#include <iostream>

using namespace std;

int main(int argc, char** argv)
{
    (void)argc;
    (void)argv;

    REDIS_ENDPOINT endpoints[1] = {
        { "127.0.0.1", 6379 },
        //{ "127.0.0.1", 6380 },
        //{ "127.0.0.1", 6381 },
    };

    REDIS_CONFIG conf = {
        (REDIS_ENDPOINT*)&endpoints,
        1,
        10000,
        5000,
        20,
        1,
    };

    RedisClient client(conf);

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    string res = client.set("key0", "value0");
    cout << "SET: " << res << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    res = client.get("key0");
    cout << "GET: " << res << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    client.set("count0", "0");
    long long count0;
    for (long long i = 0; i < 1000; i++) {
        count0 = client.incr("count0");
    }
    cout << "INCR count0 to " << count0 << endl;

    cout << "Press <ENTER> to continue..." << endl;
    cin.get();

    {
        RedisReplyPtr reply = client.redisCommand("PING");
        cout << "PING: " << reply->str << endl;
        // reply will be freed out of scope.
    }

    return 0;
}

Add example to use client.redisCommand directly.


#include <string>
#include <map>

#include "CalController.h"
#include "TEMLogger.h"

BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(my_cal_logger, severity_channel_logger_t) {
  return severity_channel_logger_t(keywords::channel = "CALIB");
}

severity_channel_logger_t& CalController::clg = my_cal_logger::get();

std::string CalController::getUserCommand() {
  std::string ui = "";
  while( !(commands.count(ui)) ) {
    std::cout << "What now?> ";
    std::getline(std::cin, ui);
    std::cin.clear();
  }
  return ui;
}
void CalController::showCalibrationControlMenu() {

  std::string m = "Entering calibration controller....\n"
                  "\n"
                  "-------------- Menu -----------------\n"
                  "Choose one of the following options:\n";

  std::map<std::string, std::string>::const_iterator citer;
  for(citer = commands.begin(); citer != commands.end(); ++citer) {
    m += citer->first;
    m += " - ";
    m += citer->second;
  }

  BOOST_LOG_SEV(clg, info) << m;

}

#include <string>
#include <map>

#include "CalController.h"
#include "TEMLogger.h"

BOOST_LOG_INLINE_GLOBAL_LOGGER_INIT(my_cal_logger, severity_channel_logger_t) {
  return severity_channel_logger_t(keywords::channel = "CALIB");
}

severity_channel_logger_t& CalController::clg = my_cal_logger::get();

std::string CalController::getUserCommand() {
  std::string ui = "";
  while( !(commands.count(ui)) ) {
    std::cout << "What now?> ";
    std::getline(std::cin, ui);
    std::cin.clear();
  }
  return ui;
}
void CalController::showCalibrationControlMenu() {

  std::string m = "Entering calibration controller....\n"
                  "\n"
                  "-------------- Menu -----------------\n"
                  "Choose one of the following options:\n";

  std::map<std::string, std::string>::const_iterator citer;
  for(citer = commands.begin(); citer != commands.end(); ++citer) {
    m += citer->first;
    m += " - ";
    m += citer->second;
    m += "\n";
  }

  BOOST_LOG_SEV(clg, info) << m;

}

Fix missing newline in cal controller menu


#include "test_env.h"
#include "TMP102.h"

#if defined(TARGET_KL25Z)
TMP102 temperature(PTC9, PTC8, 0x90);

#elif defined(TARGET_LPC812)
TMP102 temperature(D10, D11, 0x90);

#elif defined(TARGET_LPC4088)
TMP102 temperature(p9, p10, 0x90);

#elif defined(TARGET_LPC2368)
TMP102 temperature(p28, p27, 0x90);

#else
TMP102 temperature(p28, p27, 0x90);
#endif

int main()
{
    float t = temperature.read();

    printf("TMP102: Temperature: %f\n\r", t);
    // In our test environment (ARM office) we should get a temperature within
    // the range ]15, 30[C
    bool result = (t > 15.0) && (t < 30.0);
    notify_completion(result);
}

#include "test_env.h"
#include "TMP102.h"

#if defined(TARGET_KL25Z)
TMP102 temperature(PTC9, PTC8, 0x90);

#elif defined(TARGET_LPC812)
TMP102 temperature(D10, D11, 0x90);

#elif defined(TARGET_LPC4088)
TMP102 temperature(p9, p10, 0x90);

#elif defined(TARGET_LPC2368)
TMP102 temperature(p28, p27, 0x90);

#elif defined(TARGET_NUCLEO_F103RB) || \
    defined(TARGET_NUCLEO_L152RE) || \
    defined(TARGET_NUCLEO_F302R8) || \
    defined(TARGET_NUCLEO_F030R8) || \
    defined(TARGET_NUCLEO_F401RE) || \
    defined(TARGET_NUCLEO_F411RE) || \
    defined(TARGET_NUCLEO_F072RB) || \
    defined(TARGET_NUCLEO_F334R8) || \
    defined(TARGET_NUCLEO_L053R8)
TMP102 temperature(I2C_SDA, I2C_SCL, 0x90);

#else
TMP102 temperature(p28, p27, 0x90);
#endif

int main()
{
    float t = temperature.read();

    printf("TMP102: Temperature: %f\n\r", t);
    // In our test environment (ARM office) we should get a temperature within
    // the range ]15, 30[C
    bool result = (t > 15.0) && (t < 30.0);
    notify_completion(result);
}

Add NUCLEOs targets in TMP102 test

Add NUCLEOs targets in TMP102 test


/*
 * Copyright © 2017 Collabora Ltd.
 *
 * This file is part of vkmark.
 *
 * vkmark is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * vkmark is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with vkmark. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *   Alexandros Frantzis <alexandros.frantzis@collabora.com>
 */

#include "default_benchmarks.h"

std::vector<std::string> DefaultBenchmarks::get()
{
    return std::vector<std::string>{
        "vertex:device-local=true",
        "vertex:device-local=false",
        "texture:anisotropy=0",
        "texture:anisotropy=16",
        "shading:shading=gouraud",
        "shading:shading=blinn-phong-inf",
        "shading:shading=phong",
        "shading:shading=cel",
        "cube",
        "clear"
    };
}

/*
 * Copyright © 2017 Collabora Ltd.
 *
 * This file is part of vkmark.
 *
 * vkmark is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation, either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * vkmark is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with vkmark. If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *   Alexandros Frantzis <alexandros.frantzis@collabora.com>
 */

#include "default_benchmarks.h"

std::vector<std::string> DefaultBenchmarks::get()
{
    return std::vector<std::string>{
        "vertex:device-local=true",
        "vertex:device-local=false",
        "texture:anisotropy=0",
        "texture:anisotropy=16",
        "shading:shading=gouraud",
        "shading:shading=blinn-phong-inf",
        "shading:shading=phong",
        "shading:shading=cel",
        "desktop",
        "cube",
        "clear"
    };
}

Add 'desktop' to default benchmarks

main: Add 'desktop' to default benchmarks


#include "drivers/ublox_neo7.hpp"

#include "chprintf.h"
#include "unit_config.hpp"

void UBloxNEO7::init() {
}

GPSReading UBloxNEO7::readGPS() {
  GPSReading reading;

  // Read all available bytes until the newline character.
  std::size_t len = readUntil('\n');

  // Check if a full line is ready to be processed
  if(len > 0) {
    // TODO: Run parser
  }

  // TODO
  reading.lat = 1.2f;
  reading.lon = 3.4f;

  //char dbg_buf[16];
  //chsnprintf(dbg_buf, 12, "%12c", rxbuf.data());
  //chnWriteTimeout((BaseChannel*)&SD4, (uint8_t*)dbg_buf, 12, MS2ST(20));

  return reading;
}

#include "drivers/ublox_neo7.hpp"

#include "chprintf.h"
#include "unit_config.hpp"

void UBloxNEO7::init() {
}

GPSReading UBloxNEO7::readGPS() {
  GPSReading reading;

  // Read all available bytes until the newline character. NMEA dictates that
  // messages should end with a CRLF, but we'll only look for the LF.
  std::size_t len = readUntil('\n');

  // Check if a full line is ready to be processed
  if(len > 0) {
    // TODO: Run parser
  }

  // TODO
  reading.lat = 1.2f;
  reading.lon = 3.4f;

  //char dbg_buf[16];
  //chsnprintf(dbg_buf, 12, "%12c", rxbuf.data());
  //chnWriteTimeout((BaseChannel*)&SD4, (uint8_t*)dbg_buf, 12, MS2ST(20));

  return reading;
}

Add comment about NMEA CRLF.

Add comment about NMEA CRLF.


/*
 * Copyright (c) 2016 Luke San Antonio
 * All rights reserved.
 *
 * This file provides the implementation for the engine's C interface,
 * specifically tailored for LuaJIT's FFI facilities.
 */

#include "redcrane.hpp"

namespace redc
{
  struct Model_Visitor : boost::static_visitor<glm::mat4>
  {
    glm::mat4 operator()(Mesh_Object const& msh) const
    {
      return msh.model;
    }
    glm::mat4 operator()(Cam_Object const& cam) const
    {
      return gfx::camera_model_matrix(cam.cam);
    }
  };

  glm::mat4 object_model(Object const& obj)
  {
    // Find current
    auto this_model = boost::apply_visitor(Model_Visitor{}, obj.obj);

    // Find parent
    glm::mat4 parent_model(1.0f);
    if(obj.parent)
    {
      parent_model = object_model(*obj.parent);
    }

    // First apply the child transformations then the parent transformations.
    return parent_model * this_model;
  }
}

/*
 * Copyright (c) 2016 Luke San Antonio
 * All rights reserved.
 *
 * This file provides the implementation for the engine's C interface,
 * specifically tailored for LuaJIT's FFI facilities.
 */

#include "redcrane.hpp"

namespace redc
{
  struct Model_Visitor : boost::static_visitor<glm::mat4>
  {
    glm::mat4 operator()(Mesh_Object const& msh) const
    {
      return msh.model;
    }
    glm::mat4 operator()(Cam_Object const& cam) const
    {
      return glm::inverse(gfx::camera_view_matrix(cam.cam));
    }
  };

  glm::mat4 object_model(Object const& obj)
  {
    // Find current
    auto this_model = boost::apply_visitor(Model_Visitor{}, obj.obj);

    // Find parent
    glm::mat4 parent_model(1.0f);
    if(obj.parent)
    {
      parent_model = object_model(*obj.parent);
    }

    // First apply the child transformations then the parent transformations.
    return parent_model * this_model;
  }
}

Fix objects parented to the camera

Fix objects parented to the camera


// torch4microscopic.cpp : R\[ AvP[ṼGg |Cg`܂B
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
	return 0;
}

// torch4microscopic.cpp : R\[ AvP[ṼGg |Cg`܂B
//

#include "stdafx.h"

#include <iostream>
#include <vector>
#include <fstream>
#include <boost/program_options.hpp>

using namespace std;
using namespace boost::program_options;

int main(int argc, char* argv[])
{
	//IvV`
	options_description inout_options("path setting");
	options_description calc_options("calculation option");

	inout_options.add_options()
		("input,i", value<string>(), "input path")
		("output,o", value<string>(), "output path");

	calc_options.add_options()
		("amp_exp", "enable amplifier (exponential growth method)")
		("cutback", "enable subtraction for cutback (average lowest pixel)");

	variables_map cmd_values;

	try
	{
		options_description option_marged("");
		option_marged.add(inout_options).add(calc_options);

		if (!cmd_values.count("input") || cmd_values.count("output"))
		{
			cout << option_marged << endl;
		}

		store(parse_command_line(argc, argv, option_marged), cmd_values);
		notify(cmd_values);

	}
	catch (exception &e)
	{
		cout << e.what() << endl;
	}

	return 0;
}

Add for processing command line option.

Add for processing command line option.

コマンドラインオプションパーサーを boost/program_options.hpp を使って記述


// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/aura/toplevel_window_container.h"

#include "base/utf_string_conversions.h"
#include "ui/aura/toplevel_window_event_filter.h"

namespace aura {

ToplevelWindowContainer::ToplevelWindowContainer()
    : Window(NULL) {
  set_name("ToplevelWindowContainer");
  SetEventFilter(new ToplevelWindowEventFilter(this));
}

ToplevelWindowContainer::~ToplevelWindowContainer() {
}

Window* ToplevelWindowContainer::GetTopmostWindowToActivate(
    Window* ignore) const {
  for (Window::Windows::const_reverse_iterator i = children().rbegin();
       i != children().rend(); ++i) {
         Window* w = *i;
    if (*i != ignore && (*i)->CanActivate())
      return *i;
  }
  return NULL;
}

ToplevelWindowContainer* ToplevelWindowContainer::AsToplevelWindowContainer() {
  return this;
}

const ToplevelWindowContainer*
    ToplevelWindowContainer::AsToplevelWindowContainer() const {
  return this;
}
}  // namespace aura

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/aura/toplevel_window_container.h"

#include "base/utf_string_conversions.h"
#include "ui/aura/toplevel_window_event_filter.h"

namespace aura {

ToplevelWindowContainer::ToplevelWindowContainer()
    : Window(NULL) {
  set_name("ToplevelWindowContainer");
  SetEventFilter(new ToplevelWindowEventFilter(this));
}

ToplevelWindowContainer::~ToplevelWindowContainer() {
}

Window* ToplevelWindowContainer::GetTopmostWindowToActivate(
    Window* ignore) const {
  for (Window::Windows::const_reverse_iterator i = children().rbegin();
       i != children().rend(); ++i) {
    if (*i != ignore && (*i)->CanActivate())
      return *i;
  }
  return NULL;
}

ToplevelWindowContainer* ToplevelWindowContainer::AsToplevelWindowContainer() {
  return this;
}

const ToplevelWindowContainer*
    ToplevelWindowContainer::AsToplevelWindowContainer() const {
  return this;
}
}  // namespace aura

Fix aura bustage on linux.

Fix aura bustage on linux.

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@104575 0039d316-1c4b-4281-b951-d872f2087c98


/*-------------------------------------------------------------------------
 * Vulkan CTS Framework
 * --------------------
 *
 * Copyright (c) 2018 The Khronos Group Inc.
 * Copyright (c) 2019 Intel Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *//*!
 * \file
 * \brief Stub no-op version of RenderDocUtil class
 *//*--------------------------------------------------------------------*/

#include "vkRenderDocUtil.hpp"

namespace vk
{

struct RenderDocPrivate
{
};

RenderDocUtil::RenderDocUtil (void)
{
}

RenderDocUtil::~RenderDocUtil (void)
{
}

bool RenderDocUtil::isValid (void)
{
	return false;
}

void RenderDocUtil::startFrame (vk::VkInstance instance)
{
}

void RenderDocUtil::endFrame (vk::VkInstance instance)
{
}

} // vk

/*-------------------------------------------------------------------------
 * Vulkan CTS Framework
 * --------------------
 *
 * Copyright (c) 2018 The Khronos Group Inc.
 * Copyright (c) 2019 Intel Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 *//*!
 * \file
 * \brief Stub no-op version of RenderDocUtil class
 *//*--------------------------------------------------------------------*/

#include "vkRenderDocUtil.hpp"

namespace vk
{

struct RenderDocPrivate
{
};

RenderDocUtil::RenderDocUtil (void)
{
}

RenderDocUtil::~RenderDocUtil (void)
{
}

bool RenderDocUtil::isValid (void)
{
	return false;
}

void RenderDocUtil::startFrame (vk::VkInstance instance)
{
	DE_UNREF(instance);
}

void RenderDocUtil::endFrame (vk::VkInstance instance)
{
	DE_UNREF(instance);
}

} // vk

Fix build by adding DE_UNREF

Fix build by adding DE_UNREF

Function parameters weren't being used in the renderdoc stub interface,
so the warnings should be silenced.

Components: Framework

Change-Id: I0f060c344c6b5959028efcc2489d1bc30b43fb9f


// RUN: %clang -emit-llvm -g -S %s -o - | FileCheck %s

struct X {
  X(int v);

  int value;
};

X::X(int v) {
  // CHECK_TEMPORARILY_DISABLED: call void @_ZN1XC2Ei(%struct.X* %this1, i32 %tmp), !dbg
  // TEMPORARY CHECK: X
  value = v;
}

// RUN: %clang -march=x86_64-apple-darwin10 -emit-llvm -g -S %s -o - | FileCheck %s

struct X {
  X(int v);

  int value;
};

X::X(int v) {
  // CHECK: call void @_ZN1XC2Ei(%struct.X* %this1, i32 %tmp), !dbg
  value = v;
}

Make this test darwin only.

Make this test darwin only.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@110936 91177308-0d34-0410-b5e6-96231b3b80d8


#include <cstdint>

#include <APU.h>

static int null_dmc_reader(void*, unsigned int)
{
	return 0x55; // causes dmc sample to be flat
}

APU::APU()
{
	time = 0;
	frameLength = 29780;
	apu.dmc_reader(null_dmc_reader, NULL);
	apu.output(&buf);
	buf.clock_rate(1789773);
	buf.sample_rate(96000);
}

void APU::setDmcCallback(int (*f)(void* user_data, unsigned int), void* p)
{
	apu.dmc_reader(f, p);
}

void APU::writeRegister(uint16_t addr, uint8_t data)
{
	apu.write_register(clock(), addr, data);
}

int APU::getStatus()
{
	return apu.read_status(clock());
}

void APU::endFrame()
{
	time = 0;
	frameLength ^= 1;
	apu.end_frame(frameLength);
	buf.end_frame(frameLength);
}

long APU::samplesAvailable() const
{
	return buf.samples_avail();
}

long APU::readSamples(sample_t* buffer, long bufferSize)
{
	return buf.read_samples(buffer, bufferSize);
}

#include <cstdint>

#include <APU.h>

static int null_dmc_reader(void*, unsigned int)
{
	return 0x55; // causes dmc sample to be flat
}

APU::APU()
{
	time = 0;
	frameLength = 29780;
	apu.dmc_reader(null_dmc_reader, NULL);
	apu.output(&buf);
	buf.clock_rate(1789773);
	buf.sample_rate(44100);
}

void APU::setDmcCallback(int (*f)(void* user_data, unsigned int), void* p)
{
	apu.dmc_reader(f, p);
}

void APU::writeRegister(uint16_t addr, uint8_t data)
{
	apu.write_register(clock(), addr, data);
}

int APU::getStatus()
{
	return apu.read_status(clock());
}

void APU::endFrame()
{
	time = 0;
	frameLength ^= 1;
	apu.end_frame(frameLength);
	buf.end_frame(frameLength);
}

long APU::samplesAvailable() const
{
	return buf.samples_avail();
}

long APU::readSamples(sample_t* buffer, long bufferSize)
{
	return buf.read_samples(buffer, bufferSize);
}

Set apu default sample rate to 44100

Set apu default sample rate to 44100


//
// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
//

#include "gettime.h"

// for best accuracy, getTime is implemented platform dependent.
// to avoid a global include of windows.h, this is a separate file.

#if defined(_WIN32)

#include <windows.h>

// returns a point in time in milliseconds (can only be used for time differences, not an absolute time)
double getTime() noexcept
{
    LARGE_INTEGER time;
    QueryPerformanceCounter(&time);
    LARGE_INTEGER freq;
    QueryPerformanceFrequency(&freq);

    return (static_cast<double>(time.LowPart) * 1000.0) / static_cast<double>(freq.LowPart);
}

#else

#include <sys/time.h>
double getTime()
{
    timeval t;
    gettimeofday(&t, nullptr);

    return (t.tv_sec * 1000000.0 + t.tv_usec) / 1000.0;
}

#endif

//
// (C) Jan de Vaan 2007-2010, all rights reserved. See the accompanying "License.txt" for licensed use.
//

#include "gettime.h"

// for best accuracy, getTime is implemented platform dependent.
// to avoid a global include of windows.h, this is a separate file.

#if defined(_WIN32)

#include <windows.h>

// returns a point in time in milliseconds (can only be used for time differences, not an absolute time)
double getTime() noexcept
{
    LARGE_INTEGER time;
    QueryPerformanceCounter(&time);
    LARGE_INTEGER freq;
    QueryPerformanceFrequency(&freq);

    return (static_cast<double>(time.LowPart) * 1000.0) / static_cast<double>(freq.LowPart);
}

#else

#include <sys/time.h>
double getTime() noexcept
{
    timeval t;
    gettimeofday(&t, nullptr);

    return (t.tv_sec * 1000000.0 + t.tv_usec) / 1000.0;
}

#endif

Add noexcept for getTime() in Linux build


/**
 * $ g++ solution.cpp && ./a.out < input.txt
 */
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

/**
 * O(n^2) word-by-word comparison
 */
bool validate_line(string line) {
    string input1, input2;
    stringstream stream1(line);
    int counter1 = 0;
    while (stream1 >> input1) {
        stringstream stream2(line);
        int counter2 = 0;
        while (stream2 >> input2) {
            if (counter1 == counter2) {
                counter2++;
                continue;
            }
            if (input1 == input2) {
                return false;
            }
            counter2++;
        }
        counter1++;
    }
    return true;
}

int part1() {
    int total = 0;
    string line;
    while (getline(cin, line)) {
        if (validate_line(line)) {
            total++;
        }
    }
    return total;
}

int main() {
    cout << "Day 4!\n";
    cout << "Part 1: " << part1() << "\n";
}

/**
 * $ g++ solution.cpp && ./a.out < input.txt
 */
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

/**
 * O(n^2) word-by-word comparison
 */
bool part1_validate(string line) {
    string input1, input2;
    stringstream stream1(line);
    int counter1 = 0;
    while (stream1 >> input1) {
        stringstream stream2(line);
        int counter2 = 0;
        while (stream2 >> input2) {
            if (counter1 == counter2) {
                counter2++;
                continue;
            }
            if (input1 == input2) {
                return false;
            }
            counter2++;
        }
        counter1++;
    }
    return true;
}

int main() {
    cout << "Day 4!\n";
    int part1_total = 0;
    string line;
    while (getline(cin, line)) {
        if (part1_validate(line)) {
            part1_total++;
        }
    }
    cout << "Part 1: " << part1_total << "\n";
}

Rework to call part1-specific stuff line by line

Prep for part 2


// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chrome_browser_main_aura.h"

#include "base/logging.h"

ChromeBrowserMainPartsAura::ChromeBrowserMainPartsAura(
    const MainFunctionParams& parameters) {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PreEarlyInitialization() {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PostMainMessageLoopStart() {
  NOTIMPLEMENTED();
}

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/chrome_browser_main_aura.h"

#include "base/logging.h"

ChromeBrowserMainPartsAura::ChromeBrowserMainPartsAura(
    const MainFunctionParams& parameters)
  : ChromeBrowserMainParts(parameters) {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PreEarlyInitialization() {
  NOTIMPLEMENTED();
}

void ChromeBrowserMainPartsAura::PostMainMessageLoopStart() {
  NOTIMPLEMENTED();
}

Fix Aura compile error. My bad.


#include "hiker.hpp"
#define BOOST_TEST_MODULE HikerTest
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(Life_the_universe_and_everything)
{
    // The initial code and test files are completely
    // *unrelated* to the chosen exercise. They are
    // merely a simple example to start you off.
    // You should now delete this comment!
    BOOST_REQUIRE(42, answer());
}

#include "hiker.hpp"
#define BOOST_TEST_MODULE HikerTest
#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(Life_the_universe_and_everything)
{
    // The initial code and test files are completely
    // *unrelated* to the chosen exercise. They are
    // merely a simple example to start you off.
    // You should now delete this comment!
    BOOST_REQUIRE_EQUAL(42, answer());
}

Use require equal for testing equality

Use require equal for testing equality


#include <assert.h>
#include <stdio.h>

#include "utility.h"
#include "quadraticsieve.h"

void quadratic_sieve(long long& result, long long input, int& err)
{

}

Add a stub for the quadratic_sieve(...) procedure.


//===-- project_euler/Problem5.cpp ------------------------------*- C++ -*-===//
//
// ProjectEuler.net solutions by Will Mitchell
//
// This file is distributed under the MIT License. See LICENSE for details.
//
//===----------------------------------------------------------------------===//
///
/// \class project_euler::Problem5
/// \brief Smallest multiple
///
/// Question
/// --------
/// A palindromic number reads the same both ways. The largest palindrome made
/// from the product of two 2-digit numbers is 9009 = 91 * 99.
///
/// Find the largest palindrome made from the product of two 3-digit numbers.
///
//===----------------------------------------------------------------------===//
#include "Problem5.h"

#include <sstream>
using std::stringstream;
#include <string>
using std::string;

#include <gmpxx.h>

string project_euler::Problem5::answer() {
  if (!solved)
    solve();

  stringstream ss;

  ss << "The smallest positive number that is evenly divisible by all of the "
        "numbers from 1 to 20 is " << lcm;

  return ss.str();
}

std::string project_euler::Problem5::description() const {
  return "Problem 5: Smallest multiple";
}

void project_euler::Problem5::solve() {
  lcm = 1;

  for (unsigned long i = 1ul; i <= 20ul; ++i)
    mpz_lcm_ui(lcm.get_mpz_t(), lcm.get_mpz_t(), i);

  solved = true;
}

//===-- project_euler/Problem5.cpp ------------------------------*- C++ -*-===//
//
// ProjectEuler.net solutions by Will Mitchell
//
// This file is distributed under the MIT License. See LICENSE for details.
//
//===----------------------------------------------------------------------===//
///
/// \class project_euler::Problem5
/// \brief Smallest multiple
///
/// Question
/// --------
/// 2520 is the smallest number that can be divided by each of the numbers from
/// 1 to 10 without any remainder.
///
/// What is the smallest positive number that is evenly divisible by all of the
/// numbers from 1 to 20?
///
//===----------------------------------------------------------------------===//
#include "Problem5.h"

#include <sstream>
using std::stringstream;
#include <string>
using std::string;

#include <gmpxx.h>

string project_euler::Problem5::answer() {
  if (!solved)
    solve();

  stringstream ss;

  ss << "The smallest positive number that is evenly divisible by all of the "
        "numbers from 1 to 20 is "
     << lcm;

  return ss.str();
}

std::string project_euler::Problem5::description() const {
  return "Problem 5: Smallest multiple";
}

void project_euler::Problem5::solve() {
  lcm = 1;

  for (unsigned long i = 1ul; i <= 20ul; ++i)
    mpz_lcm_ui(lcm.get_mpz_t(), lcm.get_mpz_t(), i);

  solved = true;
}

Correct problem statement for problem 5

Correct problem statement for problem 5


// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/ui_test_utils.h"
#include "googleurl/src/gurl.h"
#include "net/test/test_server.h"

// Tests that we throw errors when you try using extension APIs that aren't
// supported in content scripts.
//
// If you have added a new API to extension_api.json and this test starts
// failing, most likely you need to either mark it as "unprivileged" (if it
// should be available in content scripts) or update the list of privileged APIs
// in renderer_extension_bindings.js.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Stubs) {
  ASSERT_TRUE(test_server()->Start());

  ASSERT_TRUE(RunExtensionTest("stubs")) << message_;

  // Navigate to a simple http:// page, which should get the content script
  // injected and run the rest of the test.
  GURL url(test_server()->GetURL("file/extensions/test_file.html"));
  ui_test_utils::NavigateToURL(browser(), url);

  ResultCatcher catcher;
  ASSERT_TRUE(catcher.GetNextResult());
}

// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/ui_test_utils.h"
#include "googleurl/src/gurl.h"
#include "net/test/test_server.h"

// Tests that we throw errors when you try using extension APIs that aren't
// supported in content scripts.
//
// If you have added a new API to extension_api.json and this test starts
// failing, most likely you need to either mark it as "unprivileged" (if it
// should be available in content scripts) or update the list of privileged APIs
// in renderer_extension_bindings.js.
// Timey-outy on mac. http://crbug.com/89116
#if defined(OS_MACOSX)
#define MAYBE_Stubs DISABLED_Stubs
#else
#define MAYBE_Stubs Stubs
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Stubs) {
  ASSERT_TRUE(test_server()->Start());

  ASSERT_TRUE(RunExtensionTest("stubs")) << message_;

  // Navigate to a simple http:// page, which should get the content script
  // injected and run the rest of the test.
  GURL url(test_server()->GetURL("file/extensions/test_file.html"));
  ui_test_utils::NavigateToURL(browser(), url);

  ResultCatcher catcher;
  ASSERT_TRUE(catcher.GetNextResult());
}

Mark ExtensionApiTest.Stubs as disabled on mac due to timeouts.

TBR=nirnimesh@chromium.org
BUG=89116
TEST=

Review URL: http://codereview.chromium.org/7356004

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@92273 0039d316-1c4b-4281-b951-d872f2087c98


// Copyright 2016 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 44
// Coded triangle numbers

namespace problem_44 {

long nth_pentagonal_number(const long n) {
	return n * (3 * n - 1) / 2;
}

bool is_pentagonal(const long n) {
	const long limit = n / 2 + 1;
	const long two_n = n * 2;
	for (long i = 0; i <= limit; ++i) {
		if (i * (3 * i - 1) == two_n) {
			return true;
		}
	}
	return false;
}

long solve() {
	return 1;
}

} // namespace problem_44

// Copyright 2016 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 44
// Coded triangle numbers

#include <cstdio>
#include <cmath>

namespace problem_44 {

long nth_pentagonal_number(const long n) {
	return n * (3 * n - 1) / 2;
}

bool is_pentagonal(const long n) {
	const long limit = n / 2 + 1;
	const long two_n = n * 2;
	for (long i = 0; i <= limit; ++i) {
		if (i * (3 * i - 1) == two_n) {
			return true;
		}
	}
	return false;
}

long solve() {
	for (long i = 1; true; ++i) {
		const long n = nth_pentagonal_number(i);
		printf("trying %ld\n", n);

		const long limit_j = (n-1)/3;
		for (long j = 1; j <= limit_j; ++j) {
			const long first = nth_pentagonal_number(j);
			for (long k = (long)(1 + sqrt(1+24*(n+first)))/6+1; true; ++k) {
				const long second = nth_pentagonal_number(k);
				const long diff = second - first;
				// printf("%ld - %ld = %ld\n", second, first, diff);
				if (diff == n) {
					if (is_pentagonal(first + second)) {
						return n;
					}
					break;
				}
				if (diff > n) {
					break;
				}
			}
		}
	}
}

} // namespace problem_44

Work on Problem 44 some more

Work on Problem 44 some more


/******************************************************************************
 * The MIT License (MIT)
 *
 * Copyright (c) 2016-2017 Baldur Karlsson
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ******************************************************************************/

#include "os/posix/posix_hook.h"

void PosixHookInit()
{
}

void PosixHookLibrary(const char *name, dlopenCallback cb)
{
}

/******************************************************************************
 * The MIT License (MIT)
 *
 * Copyright (c) 2016-2017 Baldur Karlsson
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ******************************************************************************/

#include "os/posix/posix_hook.h"

#include <dlfcn.h>

void PosixHookInit()
{
}

void PosixHookLibrary(const char *name, dlopenCallback cb)
{
  cb(dlopen(name, RTLD_NOW));
}

Load wrapped library early in case of Android

On newer Android it is not possible to use the
LD_PRELOAD functionality. The target application
should be directly linked with the RenderDoc library.
However in that case we also need to load the
target library early, so a simple implementation
for the PosixHookLibrary is added.


//===-- MSP430MCAsmInfo.cpp - MSP430 asm properties -----------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declarations of the MSP430MCAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "MSP430MCAsmInfo.h"
using namespace llvm;

MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) {
  AlignmentIsInBytes = false;
  AllowNameToStartWithDigit = true;
}

//===-- MSP430MCAsmInfo.cpp - MSP430 asm properties -----------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declarations of the MSP430MCAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "MSP430MCAsmInfo.h"
using namespace llvm;

MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, const StringRef &TT) {
  AlignmentIsInBytes = false;
  AllowNameToStartWithDigit = true;
  PrivateGlobalPrefix = ".L";
}

Use '.L' for global private prefix (as mspgcc)

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@86380 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "sandbox/linux/seccomp-bpf/trap.h"

#include <signal.h>

#include "sandbox/linux/tests/unit_tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace sandbox {
namespace {

SANDBOX_TEST_ALLOW_NOISE(Trap, SigSysAction) {
  // This creates a global Trap instance, and registers the signal handler
  // (Trap::SigSysAction).
  Trap::Registry();

  // Send SIGSYS to self. If signal handler (SigSysAction) is not registered,
  // the process will be terminated with status code -SIGSYS.
  // Note that, SigSysAction handler would output an error message
  // "Unexpected SIGSYS received." so it is necessary to allow the noise.
  raise(SIGSYS);
}

}  // namespace
}  // namespace sandbox

// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "sandbox/linux/seccomp-bpf/trap.h"

#include <signal.h>

#include "sandbox/linux/tests/unit_tests.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace sandbox {
namespace {

#if !defined(THREAD_SANITIZER)
SANDBOX_TEST_ALLOW_NOISE(Trap, SigSysAction) {
  // This creates a global Trap instance, and registers the signal handler
  // (Trap::SigSysAction).
  Trap::Registry();

  // Send SIGSYS to self. If signal handler (SigSysAction) is not registered,
  // the process will be terminated with status code -SIGSYS.
  // Note that, SigSysAction handler would output an error message
  // "Unexpected SIGSYS received." so it is necessary to allow the noise.
  raise(SIGSYS);
}
#endif

}  // namespace
}  // namespace sandbox

Disable the failing Trap.SigSysAction test under TSan.

BUG=481297
TBR=hidehiko@chromium.org,mdempsky@chromium.org

Review URL: https://codereview.chromium.org/1104813008

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#326952}


/****************************************************************************
 * Copyright (c) 2012-2019 by the DataTransferKit authors                   *
 * All rights reserved.                                                     *
 *                                                                          *
 * This file is part of the DataTransferKit library. DataTransferKit is     *
 * distributed under a BSD 3-clause license. For the licensing terms see    *
 * the LICENSE file in the top-level directory.                             *
 *                                                                          *
 * SPDX-License-Identifier: BSD-3-Clause                                    *
 ****************************************************************************/

#include <DTK_Search_Exception.hpp>

#include <boost/test/unit_test.hpp>

#define BOOST_TEST_MODULE DesignByContract

BOOST_AUTO_TEST_CASE( dumb )
{
    using namespace DataTransferKit;
    BOOST_CHECK_NO_THROW( DTK_SEARCH_ASSERT( true ) );
    BOOST_CHECK_THROW( DTK_SEARCH_ASSERT( false ), SearchException );
    std::string const prefix = "DTK Search exception: ";
    std::string const message = "Keep calm and chive on!";
    BOOST_CHECK_EXCEPTION( throw SearchException( message ), SearchException,
                           [&]( SearchException const &e ) {
                               return prefix + message == e.what();
                           } );
}

/****************************************************************************
 * Copyright (c) 2012-2019 by the DataTransferKit authors                   *
 * All rights reserved.                                                     *
 *                                                                          *
 * This file is part of the DataTransferKit library. DataTransferKit is     *
 * distributed under a BSD 3-clause license. For the licensing terms see    *
 * the LICENSE file in the top-level directory.                             *
 *                                                                          *
 * SPDX-License-Identifier: BSD-3-Clause                                    *
 ****************************************************************************/

#include <DTK_Search_Exception.hpp>

#include <boost/test/unit_test.hpp>

#define BOOST_TEST_MODULE DesignByContract

BOOST_AUTO_TEST_CASE( dumb )
{
    using namespace DataTransferKit;
    BOOST_CHECK_NO_THROW( DTK_SEARCH_ASSERT( true ) );
    std::string const prefix = "DTK Search exception: ";
    BOOST_CHECK_EXCEPTION(
        DTK_SEARCH_ASSERT( false ), SearchException,
        [&]( std::exception const &e ) {
            std::string const message = e.what();
            bool const message_starts_with_prefix = message.find( prefix ) == 0;
            bool const message_contains_filename =
                message.find( __FILE__ ) != std::string::npos;
            return message_starts_with_prefix && message_contains_filename;
        } );
    std::string const message = "Keep calm and chive on!";
    BOOST_CHECK_EXCEPTION( throw SearchException( message ), SearchException,
                           [&]( SearchException const &e ) {
                               return prefix + message == e.what();
                           } );
}

Check assertion macro message starts with prefix and contains filename


//Some useful equations
int main(){
  //area portion of a circle
  A = pi*r^2 * (theta/(2*pi))
  //area chord of a circle
  A = R * R * acos((R - h)/R) - (R - h) * sqrt(2 * R * h - h * h)
    // h is the height of the chord

}

//Some useful equations
int main(){
  //area portion of a circle
  A = pi*r^2 * (theta/(2*pi))
  //area chord of a circle
  A = R * R * acos((R - h)/R) - (R - h) * sqrt(2 * R * h - h * h)
    // h is the height of the chord h = R - hypot(x,y)
  // rotation matrix counnterclockwise
  [x' y'] = [[cost -sint] [sint cost]][x y]
  // rotation matrix clockwise
  [x' y'] = [[cost sint] [-sint cost]][x y]
}

Add rotation matrix , clockwise and counterclockwise.