#include "logger.h"

Logger::Level Logger::logLevel = Logger::Level::ERROR;

void Logger::Error(std::string msg) {
	std::cerr << "[Error]: " << msg.c_str() << std::endl;
}

void Logger::Warn(std::string msg) {
	if (Logger::logLevel >= Logger::Level::WARN) {
		std::cout << "[Warn]: " << msg.c_str() << std::endl;
	}
}

void Logger::Info(std::string msg) {
	if (Logger::logLevel >= Logger::Level::INFO) {
		std::cout << "[Info]: " << msg.c_str() << std::endl;
	}
}

void Logger::Debug(std::string msg) {
	if (Logger::logLevel == Logger::Level::DEBUG) {
		std::cout << "[Debug]: " << msg.c_str() << std::endl;
	}
}

#include "logger.h"

Logger::Level Logger::logLevel = Logger::Level::WARN;

void Logger::Error(std::string msg) {
	std::cerr << "[Error]: " << msg.c_str() << std::endl;
}

void Logger::Warn(std::string msg) {
	if (Logger::logLevel >= Logger::Level::WARN) {
		std::cout << "[Warn]: " << msg.c_str() << std::endl;
	}
}

void Logger::Info(std::string msg) {
	if (Logger::logLevel >= Logger::Level::INFO) {
		std::cout << "[Info]: " << msg.c_str() << std::endl;
	}
}

void Logger::Debug(std::string msg) {
	if (Logger::logLevel == Logger::Level::DEBUG) {
		std::cout << "[Debug]: " << msg.c_str() << std::endl;
	}
}

Change default log level to WARN


/*
 * Copyright (c) 1998-2005, Index Data.
 * See the file LICENSE for details.
 *
 * $Id: tstquery.cpp,v 1.2 2006-03-29 13:14:15 adam Exp $
 */

#include <stdlib.h>
#include <yazpp/z-query.h>

using namespace yazpp_1;

void tst1(const char *query_str_in, const char *query_expected)
{
    Yaz_Z_Query q;

    q = query_str_in;

    Yaz_Z_Query q2;

    q2 = q;

    char query_str_out[100];
    q2.print(query_str_out, sizeof(query_str_out)-1);

    if (strcmp(query_str_out, query_expected))
    {
	fprintf(stderr, "tstquery: query mismatch out=%s expected=%s\n",
		query_str_out, query_expected);
	exit(1);
    }
}

int main(int argc, char **argv)
{
    tst1("", "");
    tst1("x", "RPN: @attrset Bib-1 x");
    tst1("@and a b", "RPN: @attrset Bib-1 @and a b");
}

/*
 * Local variables:
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 * vim: shiftwidth=4 tabstop=8 expandtab
 */

/*
 * Copyright (c) 1998-2006, Index Data.
 * See the file LICENSE for details.
 *
 * $Id: tstquery.cpp,v 1.3 2006-07-07 12:57:15 adam Exp $
 */

#include <stdlib.h>
#include <yazpp/z-query.h>

using namespace yazpp_1;

void tst1(const char *query_str_in, const char *query_expected)
{
    Yaz_Z_Query q;

    q = query_str_in;

    Yaz_Z_Query q2;

    q2 = q;

    char query_str_out[100];
    q2.print(query_str_out, sizeof(query_str_out)-1);

    if (strcmp(query_str_out, query_expected))
    {
	fprintf(stderr, "tstquery: query mismatch out=%s expected=%s\n",
		query_str_out, query_expected);
	exit(1);
    }
}

int main(int argc, char **argv)
{
    tst1("", "");
    tst1("x", "RPN @attrset Bib-1 x");
    tst1("@and a b", "RPN @attrset Bib-1 @and a b");
}

/*
 * Local variables:
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 * vim: shiftwidth=4 tabstop=8 expandtab
 */

Update test becuase yaz_query_to_wrbuf now omits : before query type in string output.


#include "board.hpp"
#include "gtest/gtest.h"

class BoardTest : public ::testing::Test {
protected:
    BoardTest() : board_(1, 2) {
    }
    virtual ~BoardTest() {
    }

    virtual void SetUp() {
    }

    Quoridor::Board board_;
};

TEST_F(BoardTest, set_size)
{
    board_.set_size(10, 11);
    EXPECT_EQ(10, board_.row_num());
    EXPECT_EQ(11, board_.col_num());
}

int main(int argc, char **argv)
{
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

#include "board.hpp"
#include "exception.hpp"
#include "gtest/gtest.h"

class BoardTest : public ::testing::Test {
protected:
    BoardTest() : board_(1, 2) {
    }

    Quoridor::Board board_;
};

TEST_F(BoardTest, ctor)
{
    EXPECT_EQ(1, board_.row_num());
    EXPECT_EQ(2, board_.col_num());
    // test invalid Board construction
    EXPECT_THROW(Quoridor::Board(-1, 1), Quoridor::Exception);
    EXPECT_THROW(Quoridor::Board(8, 0), Quoridor::Exception);
}

TEST_F(BoardTest, set_size)
{
    // test invalid Board sizes
    EXPECT_THROW(board_.set_size(0, 0), Quoridor::Exception);
    EXPECT_THROW(board_.set_size(0, 1), Quoridor::Exception);
    EXPECT_THROW(board_.set_size(1, 0), Quoridor::Exception);
    EXPECT_THROW(board_.set_size(-1, -1), Quoridor::Exception);
    EXPECT_THROW(board_.set_size(-1, 1), Quoridor::Exception);
    EXPECT_THROW(board_.set_size(1, -1), Quoridor::Exception);

    board_.set_size(10, 11);
    EXPECT_EQ(10, board_.row_num());
    EXPECT_EQ(11, board_.col_num());
}

int main(int argc, char **argv)
{
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

Add failure tests into Board unittests.


/*
 * ============================================================================
 *       Filename:  server_main.cc
 *    Description:  Server main for testing
 *        Version:  1.0
 *        Created:  04/25/2015 06:37:53 PM
 *       Revision:  none
 *       Compiler:  gcc
 *         Author:  Rafael Gozlan, rafael.gozlan@epita.fr
 *   Organization:  Flihabi
 * ============================================================================
 */
#include <stdlib.h>
#include <unistd.h>

#include "server.hh"

#define NB_TESTS 10

int main()
{
    Server *s = new Server();
    int ids[NB_TESTS];
    for (int i = 0; i < NB_TESTS; ++i)
        ids[i] = s->execBytecode("This is some bytecode");
    Result *r;
    for (int i = 0; i < NB_TESTS; ++i)
    {
        while ((r = s->getResult(ids[i])) == NULL)
        {
            std::cout << "Server: Waiting for result";
            sleep(1);
        }
        std::cout << "Server received: " << r->value << std::endl;
    }
}

/*
 * ============================================================================
 *       Filename:  server_main.cc
 *    Description:  Server main for testing
 *        Version:  1.0
 *        Created:  04/25/2015 06:37:53 PM
 *       Revision:  none
 *       Compiler:  gcc
 *         Author:  Rafael Gozlan, rafael.gozlan@epita.fr
 *   Organization:  Flihabi
 * ============================================================================
 */
#include <stdlib.h>
#include <unistd.h>

#include "server.hh"

#define NB_TESTS 10

int main()
{
    Server *s = new Server();
    int ids[NB_TESTS];
    std::string string = "This is some bytecode";
    string += '\0';
    string += "This is something else";
    for (int i = 0; i < NB_TESTS; ++i)
        ids[i] = s->execBytecode(string);
    Result *r;
    for (int i = 0; i < NB_TESTS; ++i)
    {
        while ((r = s->getResult(ids[i])) == NULL)
        {
            std::cout << "Server: Waiting for result";
            sleep(1);
        }
        std::cout << "Server received: " << r->value << std::endl;
    }
}

Add stronger test for server


// FIXME: Disabled, appears to have undefined behavior, and needs to be updated to match new warnings.
// RUN: clang-cc -fsyntax-only -verify %s
// XFAIL: *

namespace A {
    int VA;
    void FA() {}
    struct SA { int V; };
}

using A::VA;
using A::FA;
using typename A::SA;

void main()
{
    VA = 1;
    FA();
    SA x;   //Still needs handling.
}

struct B {
    void f(char){};
    void g(char){};
};
struct D : B {
    using B::f;
    void f(int);
    void g(int);
};
void D::f(int) { f('c'); } // calls B::f(char)
void D::g(int) { g('c'); } // recursively calls D::g(int)

namespace E {
    template <typename TYPE> int funcE(TYPE arg) { return(arg); }
}

using E::funcE<int>; // expected-error{{use of template specialization in using directive not allowed}}

namespace F {
    struct X;
}

using F::X;
// Should have some errors here.  Waiting for implementation.
void X(int);
struct X *x;

// RUN: clang-cc -fsyntax-only -verify %s
// XFAIL: *

namespace A {
    int VA;
    void FA() {}
    struct SA { int V; };
}

using A::VA;
using A::FA;
using typename A::SA;

int main()
{
    VA = 1;
    FA();
    SA x;   //Still needs handling.
}

struct B {
    void f(char){};
    void g(char){};
};
struct D : B {
    using B::f;
    void f(int);
    void g(int);
};
void D::f(int) { f('c'); } // calls B::f(char)
void D::g(int) { g('c'); } // recursively calls D::g(int)

namespace E {
    template <typename TYPE> int funcE(TYPE arg) { return(arg); }
}

using E::funcE<int>; // expected-error{{using declaration can not refer to a template specialization}}

namespace F {
    struct X;
}

using F::X;
// Should have some errors here.  Waiting for implementation.
void X(int);
struct X *x;

Tweak expected error to match what should happen, once using declarations work


#include "stdafx.h"
#include "CppUnitTest.h"

#include "datastore.h"
#include "transaction.h"
#include "internal/operations/post_operation.h"
#include "dummy_values.h"

using Assert = Microsoft::VisualStudio::CppUnitTestFramework::Assert;

namespace You {
namespace DataStore {
namespace UnitTests {
TEST_CLASS(DataStoreApiTest) {
public:
	TEST_METHOD(pushOperationToTransaction) {
		Transaction sut;
		Internal::PostOperation postOp(0, task1);
		sut.push(std::shared_ptr<Internal::IOperation>(&postOp));
	}
};

}  // namespace UnitTests
}  // namespace DataStore
}  // namespace You

#include "stdafx.h"
#include "CppUnitTest.h"

#include "datastore.h"
#include "transaction.h"
#include "internal/operations/post_operation.h"
#include "dummy_values.h"

using Assert = Microsoft::VisualStudio::CppUnitTestFramework::Assert;

namespace You {
namespace DataStore {
namespace UnitTests {
TEST_CLASS(DataStoreApiTest) {
public:
	TEST_METHOD(pushOperationToTransaction) {
		Transaction sut;
		Internal::PostOperation postOp(0, task1);
		sut.push(std::shared_ptr<Internal::IOperation>(&postOp));
		Assert::AreEqual(boost::lexical_cast<size_t>(1), sut.operationsQueue.size());
	}
};

}  // namespace UnitTests
}  // namespace DataStore
}  // namespace You

Add assert statement for unit test


//===- llvm/unittest/IR/AttributesTest.cpp - Attributes unit tests --------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/IR/Attributes.h"
#include "llvm/IR/LLVMContext.h"
#include "gtest/gtest.h"
using namespace llvm;

namespace {

TEST(Attributes, Uniquing) {
  LLVMContext C;

  Attribute AttrA = Attribute::get(C, Attribute::AlwaysInline);
  Attribute AttrB = Attribute::get(C, Attribute::AlwaysInline);
  EXPECT_EQ(AttrA, AttrB);

  AttributeWithIndex AWIs[] = {
    AttributeWithIndex::get(C, 1, Attribute::ZExt),
    AttributeWithIndex::get(C, 2, Attribute::SExt)
  };

  AttributeSet SetA = AttributeSet::get(C, AWIs);
  AttributeSet SetB = AttributeSet::get(C, AWIs);
  EXPECT_EQ(SetA, SetB);
}

} // end anonymous namespace

//===- llvm/unittest/IR/AttributesTest.cpp - Attributes unit tests --------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/IR/Attributes.h"
#include "llvm/IR/LLVMContext.h"
#include "gtest/gtest.h"
using namespace llvm;

namespace {

TEST(Attributes, Uniquing) {
  LLVMContext C;

  Attribute AttrA = Attribute::get(C, Attribute::AlwaysInline);
  Attribute AttrB = Attribute::get(C, Attribute::AlwaysInline);
  EXPECT_EQ(AttrA, AttrB);

  AttributeSet ASs[] = {
    AttributeSet::get(C, 1, Attribute::ZExt),
    AttributeSet::get(C, 2, Attribute::SExt)
  };

  AttributeSet SetA = AttributeSet::get(C, ASs);
  AttributeSet SetB = AttributeSet::get(C, ASs);
  EXPECT_EQ(SetA, SetB);
}

} // end anonymous namespace

Fix test to not use the AttributeSet's AttributeWithIndex creation method.


/**
 * Tests of str_rope and rope_node.
 *
 * @author Jean-Claude Paquin
 **/

#include <catch.hpp>
#include <primitives/str_rope.h>

TEST_CASE("Empty rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>();

    SECTION("Empty node has nullptr left & right") {
        REQUIRE(!node->data.left);
        REQUIRE(!node->data.right);
    }

    SECTION("Empty node to string") {
        REQUIRE(*node->to_string().get() == "");
    }
}

TEST_CASE("String rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>(std::string("wow!"));
}

TEST_CASE("Copy constructor for rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>(std::string("that's a low price!"));

    std::unique_ptr<rope_node> dupl = std::make_unique<rope_node>(*node.get());

    REQUIRE(*dupl->to_string().get() == *node->to_string().get());
}

/**
 * Tests of str_rope and rope_node.
 *
 * @author Jean-Claude Paquin
 **/

#include <catch.hpp>
#include <primitives/str_rope.h>

TEST_CASE("Empty rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>();

    SECTION("Empty node has nullptr left & right") {
        REQUIRE(!node->data.left);
        REQUIRE(!node->data.right);
    }

    SECTION("Empty node to string") {
        REQUIRE(*node->to_string().get() == "");
    }

    SECTION("Empty node is not a leaf") {
        REQUIRE(!node->is_leaf);
    }
}

TEST_CASE("String rope_node", "[rope_node]") {
    std::unique_ptr<rope_node> node = std::make_unique<rope_node>(std::string("wow!"));

    SECTION("String node is a leaf") {
        REQUIRE(node->is_leaf);
    }
}

TEST_CASE("Copy constructor for rope_node", "[rope_node]") {
    SECTION("Copied node is a leaf node") {
        std::unique_ptr<rope_node> node = std::make_unique<rope_node>(std::string("that's a low price!"));

        std::unique_ptr<rope_node> dupl = std::make_unique<rope_node>(*node.get());

        REQUIRE(*dupl->to_string().get() == *node->to_string().get());
        REQUIRE(dupl->is_leaf);
    }

    SECTION("Copied node is not a leaf node") {
        rope_node node;
        rope_node dupl(node);

        REQUIRE(!dupl.is_leaf);
    }
}

Add more tests for rope_node


// RUN: %clang_cc1 -g -S -masm-verbose -o - %s | FileCheck %s

// CHECK: abbrev_begin:
// CHECK: DW_AT_accessibility
// CHECK-NEXT: DW_FORM_data1

class A {
public:
  int p;
private:
  int pr;
};

A a;

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

// CHECK: [ DW_TAG_member ] [p] [{{[^]]*}}] [from int]
// CHECK: [ DW_TAG_member ] [pr] [{{[^]]*}}] [private] [from int]

class A {
public:
  int p;
private:
  int pr;
};

A a;

Fix test case due to r196394 and improve it to not rely on LLVM code generation either.


// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: echo "42" | %run %t 2>&1 | FileCheck %s

#include <iostream>

int main() {
  int i;
  std::cout << "Type i: ";
  std::cin >> i;
  return 0;
// CHECK: Type i:
// CHECK-NOT: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
}

// First, check this works with the default blacklist:
// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: echo "42" | %run %t 2>&1 | FileCheck %s
//
// Then, make sure it still works when a user uses his own blacklist file:
// RUN: %clang_cl_asan -O0 %s -fsanitize-blacklist=%p/../Helpers/initialization-blacklist.txt -Fe%t2
// RUN: echo "42" | %run %t2 2>&1 | FileCheck %s

#include <iostream>

int main() {
  int i;
  std::cout << "Type i: ";
  std::cin >> i;
  return 0;
// CHECK: Type i:
// CHECK-NOT: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
}

Add a test case for PR22431


#include <ionCore.h>
#include <catch.hpp>

TEST_CASE("ionStandardLibrary::String::Build")
{
	REQUIRE(String::Build("") == string());
	REQUIRE(String::Build("Test") == "Test");
	REQUIRE(String::Build("Hello %d", 123) == "Hello 123");
	REQUIRE(String::Build("%c %d %X %s", 'a', 42, 0xABCD, "foo") == "a 42 ABCD foo");
}

#include <ionCore.h>
#include <catch.hpp>

TEST_CASE("ionStandardLibrary::ConditionalMapAccess")
{
	map<int, int *> Test;
	REQUIRE(! ConditionalMapAccess(Test, 0));
	REQUIRE(! ConditionalMapAccess(Test, 1));
	REQUIRE(! ConditionalMapAccess(Test, 2));

	int X, Y;

	Test[0] = & X;
	Test[1] = & Y;
	Test[2] = & Y;
	REQUIRE(! ConditionalMapAccess(Test, -1));
	REQUIRE(& X == ConditionalMapAccess(Test, 0));
	REQUIRE(& Y == ConditionalMapAccess(Test, 1));
	REQUIRE(& Y == ConditionalMapAccess(Test, 2));
	REQUIRE(! ConditionalMapAccess(Test, 3));
	REQUIRE(! ConditionalMapAccess(Test, 4));
}

TEST_CASE("ionStandardLibrary::String::Build")
{
	REQUIRE(String::Build("") == string());
	REQUIRE(String::Build("Test") == "Test");
	REQUIRE(String::Build("Hello %d", 123) == "Hello 123");
	REQUIRE(String::Build("%c %d %X %s", 'a', 42, 0xABCD, "foo") == "a 42 ABCD foo");
}

Add Conditional Map Access test


#include "ButtonEntity.h"

ButtonEntity::ButtonEntity()
{
}

ButtonEntity::~ButtonEntity()
{
}

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

int ButtonEntity::React(int entityID, EVENT reactEvent)
{
	int result = 0;
	return result;
}

int ButtonEntity::Initialize(int entityID, PhysicsComponent * pComp, GraphicsComponent * gComp)
{
	int result = 0;
	return result;
}

#include "ButtonEntity.h"

ButtonEntity::ButtonEntity()
{
}

ButtonEntity::~ButtonEntity()
{
}

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

int ButtonEntity::React(int entityID, EVENT reactEvent)
{
	int result = 0;
	return result;
}

int ButtonEntity::Initialize(int entityID, PhysicsComponent * pComp, GraphicsComponent * gComp)
{
	int result = 0;
	this->InitializeBase(entityID, pComp, gComp);
	return result;
}

UPDATE Initialize now calls InitializeBase as expected


#include "protect.hpp"
#include "../Exception.hpp"
#include "../Jump_Tag.hpp"

#ifndef TAG_RAISE
#define TAG_RAISE 0x6
#endif

VALUE Rice::detail::
protect(
    RUBY_VALUE_FUNC f,
    VALUE arg)
{
  int state = 0;
  VALUE retval = rb_protect(f, arg, &state);
  if(state != 0)
  {
    if(state == TAG_RAISE && ruby_errinfo != Qnil)
    {
      // TODO: convert NoMemoryError into bad_alloc?
      throw Rice::Exception(ruby_errinfo);
    }
    throw Jump_Tag(state);
  }
  return retval;
}

#include "protect.hpp"
#include "../Exception.hpp"
#include "../Jump_Tag.hpp"

#ifndef TAG_RAISE
#define TAG_RAISE 0x6
#endif

VALUE Rice::detail::
protect(
    RUBY_VALUE_FUNC f,
    VALUE arg)
{
  int state = 0;
  VALUE retval = rb_protect(f, arg, &state);
  if(state != 0)
  {
    if(state == TAG_RAISE && RTEST(ruby_errinfo))
    {
      // TODO: convert NoMemoryError into bad_alloc?
      VALUE err = ruby_errinfo;
      ruby_errinfo = 0;
      throw Rice::Exception(err);
    }
    throw Jump_Tag(state);
  }
  return retval;
}

Reset ruby_errinfo when catching exceptions, otherwise exceptions can strangely be resurrected.


#include "vsteventkeeper.h"

#include <cstdint>

namespace Airwave {

VstEventKeeper::VstEventKeeper() :
	events_(nullptr),
	data_(nullptr)
{
}

VstEventKeeper::~VstEventKeeper()
{
	delete [] events_;
}

void VstEventKeeper::reload(int count, const VstEvent events[])
{
	if(!events_ || events_->numEvents < count) {
		delete [] events_;

		size_t size = sizeof(VstEvents) + count * (sizeof(VstEvent*) +
				sizeof(VstEvent));

		uint8_t* buffer = new uint8_t[size];
		events_ = reinterpret_cast<VstEvents*>(buffer);

		size_t offset = sizeof(VstEvents) + count * sizeof(VstEvent*);
		data_ = reinterpret_cast<VstEvent*>(buffer + offset);
	}

	events_->numEvents = count;
	events_->reserved = 0;

	for(int i = 0; i < count; ++i) {
		data_[i] = events[i];
		events_->events[i] = &data_[i];
	}
}

VstEvents* VstEventKeeper::events()
{
	return events_;
}

} // namespace Airwave

#include "vsteventkeeper.h"

#include <algorithm>
#include <cstdint>

namespace Airwave {

VstEventKeeper::VstEventKeeper() :
	events_(nullptr),
	data_(nullptr)
{
}

VstEventKeeper::~VstEventKeeper()
{
	delete [] events_;
}

void VstEventKeeper::reload(int count, const VstEvent events[])
{
	if(!events_ || events_->numEvents < count) {
		delete [] events_;

		int extraCount = std::max(count - 2, 0);

		size_t size = sizeof(VstEvents) + extraCount * sizeof(VstEvent*) +
				count * sizeof(VstEvent);

		uint8_t* buffer = new uint8_t[size];
		events_ = reinterpret_cast<VstEvents*>(buffer);

		size_t offset = sizeof(VstEvents) + extraCount * sizeof(VstEvent*);
		data_ = reinterpret_cast<VstEvent*>(buffer + offset);
	}

	events_->numEvents = count;
	events_->reserved = 0;

	for(int i = 0; i < count; ++i) {
		data_[i] = events[i];
		events_->events[i] = &data_[i];
	}
}

VstEvents* VstEventKeeper::events()
{
	return events_;
}

} // namespace Airwave

Fix buffer size and memory offset calculations in VstEventKeeper


#include "configuration.h"
#include "AboutDialog.h"
#include "ui_AboutDialog.h"

#define define2string_p(x) #x
#define define2string(x) define2string_p(x)

AboutDialog::AboutDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AboutDialog)
{
    ui->setupUi(this);
    connect(ui->okButton, SIGNAL(clicked()), this, SLOT(accept()));

    ui->appnameLabel->setText(tr("%1 %2").arg(QGC_APPLICATION_NAME).arg(QGC_APPLICATION_VERSION));
    QString hash = QString(define2string(GIT_HASH));
    hash.truncate(8);
    ui->versionLabel->setText(tr("(%1-%2)").arg(hash)
                               .arg(define2string(GIT_COMMIT)));
}

AboutDialog::~AboutDialog()
{
    delete ui;
}

#include "configuration.h"
#include "AboutDialog.h"
#include "ui_AboutDialog.h"

#define define2string_p(x) #x
#define define2string(x) define2string_p(x)

AboutDialog::AboutDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AboutDialog)
{
    ui->setupUi(this);
    connect(ui->okButton, SIGNAL(clicked()), this, SLOT(accept()));

    ui->appnameLabel->setText(tr("%1 %2").arg(QGC_APPLICATION_NAME).arg(QGC_APPLICATION_VERSION));
    QString hash = QString(define2string(GIT_HASH));
    hash.truncate(8);
    ui->versionLabel->setText(tr("(%1-%2)").arg(hash)
                               .arg(define2string(GIT_COMMIT)));
    ui->linkLabel->setOpenExternalLinks(true);
}

AboutDialog::~AboutDialog()
{
    delete ui;
}

Enable http link in about box to launch system web browser


// Copyright (c) 2020-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <tinyformat.h>
#include <util/syserror.h>

#include <cstring>

std::string SysErrorString(int err)
{
    char buf[256];
    /* Too bad there are three incompatible implementations of the
     * thread-safe strerror. */
    const char *s = nullptr;
#ifdef WIN32
    if (strerror_s(buf, sizeof(buf), err) == 0) s = buf;
#else
#ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */
    s = strerror_r(err, buf, sizeof(buf));
#else /* POSIX variant always returns message in buffer */
    if (strerror_r(err, buf, sizeof(buf)) == 0) s = buf;
#endif
#endif
    if (s != nullptr) {
        return strprintf("%s (%d)", s, err);
    } else {
        return strprintf("Unknown error (%d)", err);
    }
}

// Copyright (c) 2020-2022 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <tinyformat.h>
#include <util/syserror.h>

#include <cstring>

std::string SysErrorString(int err)
{
    char buf[1024];
    /* Too bad there are three incompatible implementations of the
     * thread-safe strerror. */
    const char *s = nullptr;
#ifdef WIN32
    if (strerror_s(buf, sizeof(buf), err) == 0) s = buf;
#else
#ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */
    s = strerror_r(err, buf, sizeof(buf));
#else /* POSIX variant always returns message in buffer */
    if (strerror_r(err, buf, sizeof(buf)) == 0) s = buf;
#endif
#endif
    if (s != nullptr) {
        return strprintf("%s (%d)", s, err);
    } else {
        return strprintf("Unknown error (%d)", err);
    }
}

Increase buffer size to 1024 in SysErrorString


//===- MCSchedule.cpp - Scheduling ------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the default scheduling model.
//
//===----------------------------------------------------------------------===//

#include "llvm/MC/MCSchedule.h"

using namespace llvm;

static_assert(std::is_pod<MCSchedModel>::value,
              "We shouldn't have a static constructor here");
const MCSchedModel MCSchedModel::Default = {DefaultIssueWidth,
                                            DefaultMicroOpBufferSize,
                                            DefaultLoopMicroOpBufferSize,
                                            DefaultLoadLatency,
                                            DefaultHighLatency,
                                            DefaultMispredictPenalty,
                                            false,
                                            true,
                                            0,
                                            nullptr,
                                            nullptr,
                                            0,
                                            0,
                                            nullptr};

//===- MCSchedule.cpp - Scheduling ------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the default scheduling model.
//
//===----------------------------------------------------------------------===//

#include "llvm/MC/MCSchedule.h"
#include <type_traits>

using namespace llvm;

static_assert(std::is_pod<MCSchedModel>::value,
              "We shouldn't have a static constructor here");
const MCSchedModel MCSchedModel::Default = {DefaultIssueWidth,
                                            DefaultMicroOpBufferSize,
                                            DefaultLoopMicroOpBufferSize,
                                            DefaultLoadLatency,
                                            DefaultHighLatency,
                                            DefaultMispredictPenalty,
                                            false,
                                            true,
                                            0,
                                            nullptr,
                                            nullptr,
                                            0,
                                            0,
                                            nullptr};

Add <type_traits> for is_pod, fixing r241947


#include "builtin/class.hpp"
#include "builtin/atomic.hpp"
#include "ontology.hpp"

namespace rubinius {
  void AtomicReference::init(STATE) {
    GO(atomic_ref).set(ontology::new_class(state,
          "AtomicReference", G(object), G(rubinius)));

    G(atomic_ref)->set_object_type(state, AtomicReferenceType);
  }

  AtomicReference* AtomicReference::allocate(STATE) {
    return state->new_object<AtomicReference>(G(atomic_ref));
  }

  Object* AtomicReference::compare_and_set(STATE, Object* old, Object* new_) {
    Object** pp = &value_;
    return atomic::compare_and_swap((void**)pp, old, new_) ? cTrue : cFalse;
  }
}

#include "builtin/class.hpp"
#include "builtin/atomic.hpp"
#include "ontology.hpp"

namespace rubinius {
  void AtomicReference::init(STATE) {
    GO(atomic_ref).set(ontology::new_class(state,
          "AtomicReference", G(object), G(rubinius)));

    G(atomic_ref)->set_object_type(state, AtomicReferenceType);
  }

  AtomicReference* AtomicReference::allocate(STATE) {
    return state->new_object<AtomicReference>(G(atomic_ref));
  }

  Object* AtomicReference::compare_and_set(STATE, Object* old, Object* new_) {
    Object** pp = &value_;

    if (atomic::compare_and_swap((void**)pp, old, new_)) {
      if(mature_object_p()) this->write_barrier(state, new_);
      return cTrue;
    } else {
      return cFalse;
    }
  }
}

Fix GC-related SEGV when heavily using AtomicReference


#include <stdio.h>

#define MAX_LOOP    10000

double formula(const double x, const double k)
{
    return (x * x) / ((2 * k - 1) * (2 * k));
}

int main(void)
{
    double x;
    printf("Enter x= ");
    scanf("%lf", &x);

    double cosx = 1,
           sinx = x;

    int k = 2;
    while(k < MAX_LOOP)
    {
        cosx = cosx - cosx * formula(x, k++);
        sinx = sinx - sinx * formula(x, k++);
        cosx = cosx + cosx * formula(x, k++);
        sinx = sinx + sinx * formula(x, k++);
    }

    printf("Result is: cosx=%f sinx=%f\n", cosx, sinx);

    return 0;
}

#include <stdio.h>

#define MAX_LOOP    100

double cosine_formula(const double x, const double k)
{
    if(k == 0) return 1;
    return (x * x) / ((2 * k - 1) * (2 * k));
}

double sine_formula(const double x, const double k)
{
    if(k == 0) return x;
    return (x * x) / ((2 * k) * (2 * k + 1));
}

int main(void)
{
    double x;
    printf("Enter x= ");
    scanf("%lf", &x);

    double cosx = 0, sinx = 0;

    {
        double cosx_cache = 1, sinx_cache = 1;
        for(int k = 0; k < MAX_LOOP; ++k)
        {
            cosx_cache *= cosine_formula(x, k);
            (k % 2 == 0) ? cosx += cosx_cache : cosx -= cosx_cache;

            sinx_cache *= sine_formula(x, k);
            (k % 2 == 0) ? sinx += sinx_cache : sinx -= sinx_cache;
        }
    }

    printf("Result is: cosx=%f sinx=%f\n", cosx, sinx);

    return 0;
}

Fix the incorrect output bug


#include "arithmetics.hpp"

namespace arithmetics
{
	int add(int a, int b)
	{
		return a + b;
	}

	int add_buggy(int a, int b)
	{
		return a + b + 1;
	}
}

#include "arithmetics.hpp"

namespace arithmetics
{
	int add(int a, int b)
	{
		return a + b;
	}

	int add_buggy(int a, int b)
	{
		return a + b;
	}
}

Fix bug to see efect for Travis


#include "other.hpp"
using namespace LD22;

Other::~Other()
{ }

void Other::advance()
{
    Walker::advance();
}

#include "other.hpp"
#include "item.hpp"
using namespace LD22;

Other::~Other()
{ }

void Other::advance()
{
    scanItems();
    if (m_item) {
        int wx = centerx(), wy = centery();
        int ix = m_item->centerx(), iy = m_item->centery();
        int dx = ix - wx, dy = iy - wy;
        if (dx < -20)
            m_xpush = -PUSH_SCALE;
        else if (dx > 20)
            m_xpush = PUSH_SCALE;
        else
            m_xpush = 0;
        (void) dy;
    } else {
        m_xpush = 0;
    }
    Walker::advance();
}

Make Other chase after items


// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "lid_reuse_delayer_config.h"
#include <vespa/searchcore/proton/server/documentdbconfig.h>

namespace proton::documentmetastore {

LidReuseDelayerConfig::LidReuseDelayerConfig(const DocumentDBConfig & configSnapshot)
    : _visibilityDelay(configSnapshot.getMaintenanceConfigSP()->getVisibilityDelay()),
      _allowEarlyAck(configSnapshot.getMaintenanceConfigSP()->allowEarlyAck()),
      _hasIndexedOrAttributeFields(configSnapshot.getSchemaSP()->getNumIndexFields() > 0 ||
                                   configSnapshot.getSchemaSP()->getNumAttributeFields() > 0)
{
}

LidReuseDelayerConfig::LidReuseDelayerConfig()
    : LidReuseDelayerConfig(vespalib::duration::zero(), false)
{}

LidReuseDelayerConfig::LidReuseDelayerConfig(vespalib::duration visibilityDelay, bool hasIndexedOrAttributeFields_in)
    : _visibilityDelay(visibilityDelay),
      _allowEarlyAck(visibilityDelay > 1ms),
      _hasIndexedOrAttributeFields(hasIndexedOrAttributeFields_in)
{
}

}

// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "lid_reuse_delayer_config.h"
#include <vespa/searchcore/proton/server/documentdbconfig.h>

namespace proton::documentmetastore {

LidReuseDelayerConfig::LidReuseDelayerConfig(const DocumentDBConfig & configSnapshot)
    : _visibilityDelay(configSnapshot.getMaintenanceConfigSP()->getVisibilityDelay()),
      _allowEarlyAck(configSnapshot.getMaintenanceConfigSP()->allowEarlyAck()),
      _hasIndexedOrAttributeFields(configSnapshot.getSchemaSP()->getNumIndexFields() > 0 ||
                                   configSnapshot.getSchemaSP()->getNumAttributeFields() > 0)
{
}

LidReuseDelayerConfig::LidReuseDelayerConfig()
    : LidReuseDelayerConfig(vespalib::duration::zero(), false)
{}

LidReuseDelayerConfig::LidReuseDelayerConfig(vespalib::duration visibilityDelay, bool hasIndexedOrAttributeFields_in)
    : _visibilityDelay(visibilityDelay),
      _allowEarlyAck(visibilityDelay > vespalib::duration::zero()),
      _hasIndexedOrAttributeFields(hasIndexedOrAttributeFields_in)
{
}

}

Allow early ack on non-zero visibility delay.


// ------------------------------------------------------------------
// ofxTPSprite.cpp
// ofxTexturePacker - https://www.github.com/danoli3/ofxTexturePacker
// Created by Daniel Rosser and Colin Friend on 9/06/2014.
// ------------------------------------------------------------------
#include "ofxTPSprite.h"

ofxTPSprite::ofxTPSprite(ofxTPSpriteData* theData) {
    data = theData;
}

void ofxTPSprite::draw(int x, int y) {
    if(data->getRotated()) {
        ofPushMatrix();
        ofRotate(90);
    }
    texture->drawSubsection(x+data->getOffsetX(), y+data->getOffsetY(),
                            data->getW(), data->getH(), data->getX(), data->getY());
    if(data->getRotated()) {
        ofPopMatrix();
    }
}

// ------------------------------------------------------------------
// ofxTPSprite.cpp
// ofxTexturePacker - https://www.github.com/danoli3/ofxTexturePacker
// Created by Daniel Rosser and Colin Friend on 9/06/2014.
// ------------------------------------------------------------------
#include "ofxTPSprite.h"

ofxTPSprite::ofxTPSprite(ofxTPSpriteData* theData) {
    data = theData;
}

void ofxTPSprite::draw(int x, int y) {
    if(data->getRotated()) {
        ofPushMatrix();
        ofRotate(90);
    }
    texture->drawSubsection(x+data->getOffsetX(), y+data->getOffsetY(), data->getW(), data->getH(), data->getX(), data->getY(), data->getW(), data->getH());
    if(data->getRotated()) {
        ofPopMatrix();
    }
}

Fix for 0.9.0 texture issues


/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.

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.
==============================================================================*/
#include "absl/memory/memory.h"
#include "tensorflow/core/profiler/internal/gpu/cupti_interface.h"
#include "tensorflow/core/profiler/internal/gpu/cupti_wrapper.h"

#if defined(PLATFORM_GOOGLE)
#include "tensorflow/core/profiler/internal/gpu/cupti_error_manager.h"
#endif

namespace tensorflow {
namespace profiler {

CuptiInterface* GetCuptiInterface() {
  static CuptiInterface* cupti_interface =
#if defined(PLATFORM_GOOGLE)
      new CuptiErrorManager(absl::make_unique<CuptiWrapper>());
#else
      new CuptiWrapper();
#endif
  return cupti_interface;
}

}  // namespace profiler
}  // namespace tensorflow

/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.

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.
==============================================================================*/
#include "absl/memory/memory.h"
#include "tensorflow/core/profiler/internal/gpu/cupti_interface.h"
#include "tensorflow/core/profiler/internal/gpu/cupti_wrapper.h"
#include "tensorflow/core/profiler/internal/gpu/cupti_error_manager.h"

namespace tensorflow {
namespace profiler {

CuptiInterface* GetCuptiInterface() {
  static CuptiInterface* cupti_interface =
      new CuptiErrorManager(absl::make_unique<CuptiWrapper>());
  return cupti_interface;
}

}  // namespace profiler
}  // namespace tensorflow

Enable usage of CuptiErrorManager on all the platforms.


/*
 * 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 <QApplication>
#include <QDebug>
#include <ox/clargs/clargs.hpp>
#include "mainwindow.hpp"

using namespace nostalgia::studio;

int main(int argc, char **args) {
	ox::ClArgs clargs(argc, const_cast<const char**>(args));
	QString argProfilePath = clargs.getString("profile").c_str();

	QApplication app(argc, args);
	app.setAttribute(Qt::AA_UseHighDpiPixmaps);

	try {
		MainWindow w(argProfilePath);
		app.setApplicationName(w.windowTitle());
		w.show();
		QObject::connect(&app, &QApplication::aboutToQuit, &w, &MainWindow::onExit);
		return app.exec();
	} catch (ox::Error err) {
		oxPanic(err, "Unhandled ox::Error");
	}
}

/*
 * 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 <QApplication>
#include <QDebug>
#include <ox/clargs/clargs.hpp>
#include "mainwindow.hpp"

using namespace nostalgia::studio;

int main(int argc, char **args) {
	ox::ClArgs clargs(argc, const_cast<const char**>(args));
	QString argProfilePath = clargs.getString("profile").c_str();

	QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
	QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
	QApplication app(argc, args);

	try {
		MainWindow w(argProfilePath);
		app.setApplicationName(w.windowTitle());
		w.show();
		QObject::connect(&app, &QApplication::aboutToQuit, &w, &MainWindow::onExit);
		return app.exec();
	} catch (ox::Error err) {
		oxPanic(err, "Unhandled ox::Error");
	}
}

Fix timing of setting HiDPI options


/******************************************************************************
* Turbo C++11 metaprogramming Library                                         *
*                                                                             *
* Copyright (C) 2013 - 2014, Manuel Sánchez Pérez                             *
*                                                                             *
* This file is part of The Turbo Library.                                     *
*                                                                             *
* The Turbo Library 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, version 2 of the License.                     *
*                                                                             *
* The Turbo Library 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 The Turbo Library. If not, see <http://www.gnu.org/licenses/>.   *
******************************************************************************/

//#include "manu343726/turbo_core/turbo_core.hpp"
#include "manu343726/turbo_computing/float.hpp"

#include <type_traits>
#include <iostream>
#include <iomanip>

using a = FLOAT(2.54);

int main()
{
    //std::cout << tml::to_string<decltype("hello")>() << std::endl;
}

/******************************************************************************
* Turbo C++11 metaprogramming Library                                         *
*                                                                             *
* Copyright (C) 2013 - 2014, Manuel Sánchez Pérez                             *
*                                                                             *
* This file is part of The Turbo Library.                                     *
*                                                                             *
* The Turbo Library 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, version 2 of the License.                     *
*                                                                             *
* The Turbo Library 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 The Turbo Library. If not, see <http://www.gnu.org/licenses/>.   *
******************************************************************************/

#include "manu343726/turbo_core/turbo_core.hpp"
//#include "manu343726/turbo_computing/float.hpp"

#include <type_traits>
#include <iostream>
#include <iomanip>

int main()
{
    std::cout << tml::to_string<decltype("hello")>() << std::endl;
}

Revert "Testing -lPUBLIC error using turbo_computing blockdependencies"


//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <memory>

// unique_ptr

// Test unique_ptr default ctor

// default unique_ptr ctor should require default Deleter ctor

#include <memory>

class Deleter
{

    Deleter() {}

public:

    Deleter(Deleter&) {}
    Deleter& operator=(Deleter&) {}

    void operator()(void*) const {}
};

int main()
{
    std::unique_ptr<int[], Deleter> p;
}

//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// <memory>

// unique_ptr

// Test unique_ptr default ctor

// default unique_ptr ctor should require default Deleter ctor

#include <memory>

class Deleter
{

    Deleter() {}

public:

    Deleter(Deleter&) {}
    Deleter& operator=(Deleter&) { return *this; }

    void operator()(void*) const {}
};

int main()
{
    std::unique_ptr<int[], Deleter> p;
}

Add return statement to a test class's assignment operator. Defect found by Coverity Scan.


#include "BenchmarkStack.h"
#include "StackAllocator.h"

BenchmarkStack::BenchmarkStack(const int runtime)
	: Benchmark(runtime) {
}

BenchmarkResults BenchmarkStack::allocation() {
	setStartTimer();

	StackAllocator stackAllocator(1e10);

	int operations = 0;
	while(!outOfTime()){
		stackAllocator.Allocate(sizeof(int), alignof(int));			// 4  -> 4
		stackAllocator.Allocate(sizeof(bool), alignof(bool));		// 1  -> 5
																	// 3  -> 8
		stackAllocator.Allocate(sizeof(foo), alignof(foo));			// 16 -> 24

		++operations;
	}

	BenchmarkResults results = buildResults(operations, m_runtime, 0, 0);

	printResults(results);

	return results;
}

BenchmarkResults BenchmarkStack::free() {
	return buildResults(0, 0, 0, 0);
}

BenchmarkResults BenchmarkStack::read() {
	return buildResults(0, 0, 0, 0);
}

BenchmarkResults BenchmarkStack::write() {
	return buildResults(0, 0, 0, 0);
}

BenchmarkResults BenchmarkStack::all() {
	return buildResults(0, 0, 0, 0);
}

#include "BenchmarkStack.h"
#include "StackAllocator.h"

BenchmarkStack::BenchmarkStack(const int runtime)
	: Benchmark(runtime) {
}

BenchmarkResults BenchmarkStack::allocation() {
	setStartTimer();

	StackAllocator stackAllocator(1e10);

	int operations = 0;
	while(!outOfTime()){
		stackAllocator.Allocate(sizeof(int), alignof(int));			// 4  -> 4
		stackAllocator.Allocate(sizeof(bool), alignof(bool));		// 1  -> 5
																	// 3  -> 8
		stackAllocator.Allocate(sizeof(foo), alignof(foo));			// 16 -> 24

		++operations;
	}

	BenchmarkResults results = buildResults(operations, m_runtime, 0, 0);

	printResults(results);
	stackAllocator.Reset();
	return results;
}

BenchmarkResults BenchmarkStack::free() {
	return buildResults(0, 0, 0, 0);
}

BenchmarkResults BenchmarkStack::read() {
	return buildResults(0, 0, 0, 0);
}

BenchmarkResults BenchmarkStack::write() {
	return buildResults(0, 0, 0, 0);
}

BenchmarkResults BenchmarkStack::all() {
	return buildResults(0, 0, 0, 0);
}

Reset stack before benchmark finishes.


// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify -fms-extensions %s
typedef long HRESULT;
typedef unsigned long ULONG;
typedef struct _GUID {
  unsigned long Data1;
  unsigned short Data2;
  unsigned short Data3;
  unsigned char Data4[8];
} GUID;
typedef GUID IID;

// remove stdcall, since the warnings have nothing to do with
// what is being tested.
#define __stdcall

extern "C" {
extern "C++" {
// expected-warning@+1 {{__declspec attribute 'novtable'}}
struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable)
    IUnknown {
public:
  virtual HRESULT __stdcall QueryInterface(
      const IID &riid,
      void **ppvObject) = 0;

  virtual ULONG __stdcall AddRef(void) = 0;

  virtual ULONG __stdcall Release(void) = 0;

  template <class Q>
  HRESULT __stdcall QueryInterface(Q **pp) {
    return QueryInterface(__uuidof(Q), (void **)pp);
  }
};
}
}

__interface ISfFileIOPropertyPage : public IUnknown{};

// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
// expected-no-diagnostics
typedef long HRESULT;
typedef unsigned long ULONG;
typedef struct _GUID {
  unsigned long Data1;
  unsigned short Data2;
  unsigned short Data3;
  unsigned char Data4[8];
} GUID;
typedef GUID IID;

// remove stdcall, since the warnings have nothing to do with
// what is being tested.
#define __stdcall

extern "C" {
extern "C++" {
struct __declspec(uuid("00000000-0000-0000-C000-000000000046"))
    IUnknown {
public:
  virtual HRESULT __stdcall QueryInterface(
      const IID &riid,
      void **ppvObject) = 0;

  virtual ULONG __stdcall AddRef(void) = 0;

  virtual ULONG __stdcall Release(void) = 0;

  template <class Q>
  HRESULT __stdcall QueryInterface(Q **pp) {
    return QueryInterface(__uuidof(Q), (void **)pp);
  }
};
}
}

__interface ISfFileIOPropertyPage : public IUnknown{};

Update IUnknown lit test to pass on Win32


#include <pangolin/video/video_help.h>
#include <pangolin/video/video_interface.h>

namespace pangolin
{

void PrintPixelFormats(std::ostream& out, bool color)
{
    const std::string c_normal = color ? "\033[0m"  : "";
    const std::string c_alias  = color ? "\033[32m" : "";

   out << "Supported pixel format codes (and their respective bits-per-pixel):" << std::endl;
   std::vector<pangolin::PixelFormat> pixelFormats = pangolin::GetSupportedPixelFormats();
   for(const auto& format: pixelFormats ){
       out << c_alias << format.format << c_normal << " (" << format.bpp << "), ";
   }
   out << std::endl;
}

void VideoHelp( std::ostream& out, const std::string& scheme_filter, HelpVerbosity verbosity)
{
#ifndef _WIN32_
    const bool use_color = true;
#else
    const bool use_color = false;
#endif

    if( verbosity >= HelpVerbosity::SYNOPSIS ) {
        PrintSchemeHelp(out, use_color);
        out << std::endl;
    }

    PrintFactoryRegistryDetails(out, *FactoryRegistry::I(), typeid(VideoInterface), scheme_filter, verbosity, use_color);

    if( verbosity >= HelpVerbosity::PARAMS ) {
        PrintPixelFormats(out, use_color);
    }
}

}

#include <pangolin/video/video_help.h>
#include <pangolin/video/video_interface.h>

#include <pangolin/factory/RegisterFactoriesVideoInterface.h>
#include <pangolin/factory/RegisterFactoriesVideoOutputInterface.h>

namespace pangolin
{

void PrintPixelFormats(std::ostream& out, bool color)
{
    const std::string c_normal = color ? "\033[0m"  : "";
    const std::string c_alias  = color ? "\033[32m" : "";

   out << "Supported pixel format codes (and their respective bits-per-pixel):" << std::endl;
   std::vector<pangolin::PixelFormat> pixelFormats = pangolin::GetSupportedPixelFormats();
   for(const auto& format: pixelFormats ){
       out << c_alias << format.format << c_normal << " (" << format.bpp << "), ";
   }
   out << std::endl;
}

void VideoHelp( std::ostream& out, const std::string& scheme_filter, HelpVerbosity verbosity)
{
    RegisterFactoriesVideoInterface();

#ifndef _WIN32_
    const bool use_color = true;
#else
    const bool use_color = false;
#endif

    if( verbosity >= HelpVerbosity::SYNOPSIS ) {
        PrintSchemeHelp(out, use_color);
        out << std::endl;
    }

    PrintFactoryRegistryDetails(out, *FactoryRegistry::I(), typeid(VideoInterface), scheme_filter, verbosity, use_color);

    if( verbosity >= HelpVerbosity::PARAMS ) {
        PrintPixelFormats(out, use_color);
    }
}

}

Fix help system which was not registering factory methods before trying to enumerate them.


//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// type_traits

// is_swappable

// IMPORTANT: The include order is part of the test. We want to pick up
// the following definitions in this order:
//   1) is_swappable, is_nothrow_swappable
//   2) iter_swap, swap_ranges
//   3) swap(T (&)[N], T (&)[N])
// This test checks that (1) and (2) see forward declarations
// for (3).
#include <type_traits>
#include <algorithm>
#include <utility>

#include "test_macros.h"

int main()
{
    // Use a builtin type so we don't get ADL lookup.
    typedef double T[17][29];
    {
        LIBCPP_STATIC_ASSERT(std::__is_swappable<T>::value, "");
#if TEST_STD_VER > 14
        static_assert(std::is_swappable_v<T>);
#endif
    }
    {
        T t1 = {};
        T t2 = {};
       std::iter_swap(t1, t2);
       std::swap_ranges(t1, t1 + 17, t2);
    }
}

//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// type_traits

// is_swappable

// IMPORTANT: The include order is part of the test. We want to pick up
// the following definitions in this order:
//   1) is_swappable, is_nothrow_swappable
//   2) iter_swap, swap_ranges
//   3) swap(T (&)[N], T (&)[N])
// This test checks that (1) and (2) see forward declarations
// for (3).
#include <type_traits>
#include <algorithm>
#include <utility>

#include "test_macros.h"

int main()
{
    // Use a builtin type so we don't get ADL lookup.
    typedef double T[17][29];
    {
        LIBCPP_STATIC_ASSERT(std::__is_swappable<T>::value, "");
#if TEST_STD_VER > 14
        static_assert(std::is_swappable_v<T>, "");
#endif
    }
    {
        T t1 = {};
        T t2 = {};
       std::iter_swap(t1, t2);
       std::swap_ranges(t1, t1 + 17, t2);
    }
}

Fix use of terse static assert. Patch from STL@microsoft.com


struct C {
        int A, B;
        ~C() {}

	void operator^(C b) const { }
};

void test(C *P) {
        *P ^ *P;
}

// Non-POD classes cannot be passed into a function by component, because their
// dtors must be run.  Instead, pass them in by reference.  The C++ front-end
// was mistakenly "thinking" that 'foo' took a structure by component.

struct C {
        int A, B;
        ~C() {}
};

void foo(C b);

void test(C *P) {
	foo(*P);
}

Simplify test, include problem analysis


#include <memory>

#include "Vec2i.h"
#include "IMapElement.h"
#include "CActor.h"

namespace WizardOfGalicia {
  CActor::CActor() {
    emission = 0;
    stance = Stance::STANDING;
    attack = 0;
    defence = 0;
    hp = 0;
    direction = Direction::N;
  }

  bool CActor::canMove() {
    return true;
  }

  bool CActor::canAttack() {
    return true;
  }

  void CActor::turnLeft() {

    if ( direction == Direction::N ) {
      direction = Direction::W;
    } else {
      direction = static_cast<Direction>( static_cast<int>(direction) - 1);
    }
  }

  void CActor::turnRight() {
    if ( direction == Direction::W ) {
      direction = Direction::N;
    } else {
      direction = static_cast<Direction>( static_cast<int>(direction) + 1);
    }
  }

  void CActor::onMove() {
  }

  void CActor::onAttack() {
  }

  void CActor::endOfTurn() {
  }

  void CActor::performAttack( std::shared_ptr<CActor> other ) {

    if ( abs( magicEnergy ) < abs( other->magicEnergy ) ) {
      return;
    }

    onAttack();

    int diff = ( attack - other->defence );

    if ( diff > 0 ) {
        other->hp -= diff;
    }

    int deltaEnergy = (magicEnergy + other->magicEnergy) / 2;

    magicEnergy += deltaEnergy;
  }
}

#include <memory>

#include "Vec2i.h"
#include "IMapElement.h"
#include "CActor.h"

namespace WizardOfGalicia {
  CActor::CActor() {
    emission = 0;
    stance = Stance::STANDING;
    attack = 0;
    defence = 0;
    hp = 0;
    direction = Direction::N;
  }

  bool CActor::canMove() {
    return true;
  }

  bool CActor::canAttack() {
    return true;
  }

  void CActor::turnLeft() {

    if ( direction == Direction::N ) {
      direction = Direction::W;
    } else {
      direction = static_cast<Direction>( static_cast<int>(direction) - 1);
    }
  }

  void CActor::turnRight() {
    if ( direction == Direction::W ) {
      direction = Direction::N;
    } else {
      direction = static_cast<Direction>( static_cast<int>(direction) + 1);
    }
  }

  void CActor::onMove() {
  }

  void CActor::onAttack() {
  }

  void CActor::endOfTurn() {
  }

  void CActor::performAttack( std::shared_ptr<CActor> other ) {

    if ( abs( magicEnergy ) < abs( other->magicEnergy ) ) {
      return;
    }

    onAttack();

    int diff = ( attack - other->defence );

    if ( diff > 0 ) {
        other->hp -= diff;
    }

    int deltaEnergy = (other->magicEnergy) / 2;

    magicEnergy += deltaEnergy;
  }
}

Change energy absorption, so you only absorb part of the enemy energy


#include <gtest/gtest.h>

#include "keystore.h"
#include "zcash/Address.hpp"

TEST(keystore_tests, store_and_retrieve_spending_key) {
    CBasicKeyStore keyStore;

    std::set<libzcash::PaymentAddress> addrs;
    keyStore.GetPaymentAddresses(addrs);
    ASSERT_EQ(0, addrs.size());

    auto sk = libzcash::SpendingKey::random();
    keyStore.AddSpendingKey(sk);

    auto addr = sk.address();
    ASSERT_TRUE(keyStore.HaveSpendingKey(addr));

    libzcash::SpendingKey skOut;
    keyStore.GetSpendingKey(addr, skOut);
    ASSERT_EQ(sk, skOut);

    keyStore.GetPaymentAddresses(addrs);
    ASSERT_EQ(1, addrs.size());
    ASSERT_EQ(1, addrs.count(addr));
}

#include <gtest/gtest.h>

#include "keystore.h"
#include "zcash/Address.hpp"

TEST(keystore_tests, store_and_retrieve_spending_key) {
    CBasicKeyStore keyStore;
    libzcash::SpendingKey skOut;

    std::set<libzcash::PaymentAddress> addrs;
    keyStore.GetPaymentAddresses(addrs);
    ASSERT_EQ(0, addrs.size());

    auto sk = libzcash::SpendingKey::random();
    auto addr = sk.address();

    // Sanity-check: we can't get a key we haven't added
    ASSERT_FALSE(keyStore.HaveSpendingKey(addr));
    ASSERT_FALSE(keyStore.GetSpendingKey(addr, skOut));

    keyStore.AddSpendingKey(sk);
    ASSERT_TRUE(keyStore.HaveSpendingKey(addr));
    ASSERT_TRUE(keyStore.GetSpendingKey(addr, skOut));
    ASSERT_EQ(sk, skOut);

    keyStore.GetPaymentAddresses(addrs);
    ASSERT_EQ(1, addrs.size());
    ASSERT_EQ(1, addrs.count(addr));
}

Rework test to check for failure to return a spending key


/* Copyright 2014-2015 Juhani Numminen
 *
 * 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.
 */

#include <clocale>
#include <cstring>
#include <exception>
#include <iostream>

#include "config.hpp"
#include "game.hpp"
#include "i18n.hpp"

int main(int argc, char *argv[]) {
  std::setlocale(LC_ALL, "");
  bindtextdomain("pong--11", LOCALEDIR);
  textdomain("pong--11");

  try {
    if (argc > 1 && std::strcmp(argv[1], "-s") == 0)
      Game{}.run(true);
    else
      Game{}.run(false);
  }
  catch (const std::exception& e) {
    std::cerr << _("Exception: ") << e.what() << std::endl;
    return EXIT_FAILURE;
  }
}

/* Copyright 2014-2015 Juhani Numminen
 *
 * 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.
 */

#include <clocale>
#include <cstring>
#include <exception>
#include <iostream>

#include "config.hpp"
#include "game.hpp"
#include "i18n.hpp"

int main(int argc, char *argv[]) {
  std::setlocale(LC_ALL, "");
  bindtextdomain("pong--11", LOCALEDIR);
  textdomain("pong--11");

  bool isSingleplayer = false;

  if (argc > 1) {
    for (int i = 1; i < argc; ++i) {
      if (std::strcmp(argv[i], "-s") == 0) {
        isSingleplayer = true;
      }
      else {
        std::fprintf(stderr, _("Invalid option: '%s'\n"), argv[i]);
        return EXIT_FAILURE;
      }
    }
  }

  try {
    Game{}.run(isSingleplayer);
  }
  catch (const std::exception& e) {
    std::cerr << _("Exception: ") << e.what() << std::endl;
    return EXIT_FAILURE;
  }
}

Add a simple option parser


#include "DownloadManager.h"

#include <cstdio>
#include <iostream>
#include <string>

using namespace tinydm;

int main(int argc, char **argv) {
  if (argc < 2) {
    std::cerr << "Usage: tinydm [threads]" << std::endl;
    return EXIT_FAILURE;
  }

  int threads = std::atoi(argv[1]);
  if (threads == 0) {
    std::cerr << "Invalid number of threads specified" << std::endl;
    return EXIT_FAILURE;
  }

  DownloadManager dm(threads);
  std::string line;
  while (std::getline(std::cin, line)) {
    if (line.empty()) break;
    dm.download(line);
  }

  return EXIT_SUCCESS;
}

#include "DownloadManager.h"

#include <cstdio>
#include <iostream>
#include <string>

using namespace tinydm;

int main(int argc, char **argv) {
  if (argc < 2) {
    std::cerr << "Usage: tinydm [threads]" << std::endl;
    return EXIT_FAILURE;
  }

  int threads = std::atoi(argv[1]);
  if (threads <= 0) {
    std::cerr << "Invalid number of threads specified" << std::endl;
    return EXIT_FAILURE;
  }

  DownloadManager dm(threads);
  std::string line;
  while (std::getline(std::cin, line)) {
    if (line.empty()) break;
    dm.download(line);
  }

  return EXIT_SUCCESS;
}

Check for positive number of threads.


// Copyright 2008 Paul Hodge

#include "common_headers.h"

#include "circa.h"
#include "tests/common.h"

namespace circa {
namespace primitive_type_tests {

void strings()
{
    Branch* branch = new Branch();
    Term* str1 = constant_string(branch, "one");
    Term* str2 = constant_string(branch, "two");

    test_assert(as_string(str1) == "one");
    test_assert(as_string(str2) == "two");

    duplicate_value(str1,str2);

    test_assert(as_string(str1) == "one");
    test_assert(as_string(str2) == "one");
}

} // namespace primitive_type_tests

void register_primitive_type_tests()
{
    REGISTER_TEST_CASE(primitive_type_tests::strings);
}

} // namespace circa

// Copyright 2008 Paul Hodge

#include "common_headers.h"

#include "circa.h"
#include "tests/common.h"

namespace circa {
namespace primitive_type_tests {

void strings()
{
    Branch* branch = new Branch();
    Term* str1 = constant_string(branch, "one");
    Term* str2 = constant_string(branch, "two");

    test_assert(as_string(str1) == "one");
    test_assert(as_string(str2) == "two");

    duplicate_value(str1,str2);

    test_assert(as_string(str1) == "one");
    test_assert(as_string(str2) == "one");
}

void builtin_objects()
{
    test_assert(KERNEL->findNamed("int") == INT_TYPE);
    test_assert(KERNEL->findNamed("float") == FLOAT_TYPE);
    test_assert(KERNEL->findNamed("string") == STRING_TYPE);
    test_assert(KERNEL->findNamed("bool") == BOOL_TYPE);
}

} // namespace primitive_type_tests

void register_primitive_type_tests()
{
    REGISTER_TEST_CASE(primitive_type_tests::strings);
    REGISTER_TEST_CASE(primitive_type_tests::builtin_objects);
}

} // namespace circa

Add a test case for some builtin objects


//===-- PluginLoader.cpp - Implement -load command line option ------------===//
//
// This file implements the -load <plugin> command line option processor.  When
// linked into a program, this new command line option is available that allows
// users to load shared objects into the running program.
//
// Note that there are no symbols exported by the .o file generated for this
// .cpp file.  Because of this, a program must link against support.o instead of
// support.a: otherwise this translation unit will not be included.
//
//===----------------------------------------------------------------------===//

#include "Support/CommandLine.h"
#include "Config/dlfcn.h"
#include "Config/link.h"
#include <iostream>

namespace {
  struct PluginLoader {
    void operator=(const std::string &Filename) {
      if (dlopen(Filename.c_str(), RTLD_NOW|RTLD_GLOBAL) == 0)
        std::cerr << "Error opening '" << Filename << "': " << dlerror()
                  << "\n  -load request ignored.\n";
    }
  };
}

// This causes operator= above to be invoked for every -load option.
static cl::opt<PluginLoader, false, cl::parser<std::string> >
LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"),
        cl::desc("Load the specified plugin"));

//===-- PluginLoader.cpp - Implement -load command line option ------------===//
//
// This file implements the -load <plugin> command line option processor.  When
// linked into a program, this new command line option is available that allows
// users to load shared objects into the running program.
//
// Note that there are no symbols exported by the .o file generated for this
// .cpp file.  Because of this, a program must link against support.o instead of
// support.a: otherwise this translation unit will not be included.
//
//===----------------------------------------------------------------------===//

#include "Support/DynamicLinker.h"
#include "Support/CommandLine.h"
#include "Config/dlfcn.h"
#include "Config/link.h"
#include <iostream>

namespace {
  struct PluginLoader {
    void operator=(const std::string &Filename) {
      std::string ErrorMessage;
      if (LinkDynamicObject (Filename.c_str (), &ErrorMessage))
        std::cerr << "Error opening '" << Filename << "': " << ErrorMessage
                  << "\n  -load request ignored.\n";
    }
  };
}

// This causes operator= above to be invoked for every -load option.
static cl::opt<PluginLoader, false, cl::parser<std::string> >
LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"),
        cl::desc("Load the specified plugin"));

Change to use LinkDynamicObject instead of dlopen.


/**
 * This test checks whether we detect a deadlock arising from a parent thread
 * trying to join a child who requires a lock held by its parent in order to
 * finish.
 */

#include <d2mock.hpp>

int main(int argc, char const* argv[]) {
    d2mock::mutex G;

    d2mock::thread t1([&] {
        G.lock();
        G.unlock();
    });

    d2mock::thread t0([&] {
        t1.start();
        // if t0 acquires G before t1 does, t1 can never be joined
        G.lock();
        t1.join();
        G.unlock();
    });

    auto test_main = [&] {
        t0.start();
        t0.join();
    };

    // Right now, we have no way of encoding these kinds of deadlocks,
    // and we're obviously not detecting them too. For now, we'll always
    // make the test fail.
#if 1
    return EXIT_FAILURE;
#else
    return d2mock::check_scenario(test_main, argc, argv, {
                {
                    // t0 holds G, and waits for t1 to join
                    {t0, G, join(t1)},
                    // t1 waits for G, and will never be joined
                    {t1, G}
                }
            });
#endif
}

/**
 * This test checks whether we detect a deadlock arising from a parent thread
 * trying to join a child who requires a lock held by its parent in order to
 * finish.
 */

#include <d2mock.hpp>

int main(int argc, char const* argv[]) {
    d2mock::mutex G;

    d2mock::thread t1([&] {
        G.lock();
        G.unlock();
    });

    d2mock::thread t0([&] {
        t1.start();
        // if t0 acquires G before t1 does, t1 can never be joined
        G.lock();
        t1.join();
        G.unlock();
    });

    auto test_main = [&] {
        t0.start();
        t0.join();
    };

    // Right now, we have no way of encoding these kinds of deadlocks,
    // and we're obviously not detecting them too. For now, we'll always
    // make the test fail.
#if 1
    (void)test_main;
    return EXIT_FAILURE;
#else
    return d2mock::check_scenario(test_main, argc, argv, {
                {
                    // t0 holds G, and waits for t1 to join
                    {t0, G, join(t1)},
                    // t1 waits for G, and will never be joined
                    {t1, G}
                }
            });
#endif
}

Fix unused variable warning in a scenario.


#include <omp.h>

#include "proctor/detector.h"
#include "proctor/proctor.h"
#include "proctor/scanning_model_source.h"
#include "proctor/basic_proposer.h"

using pcl::proctor::Detector;
//using pcl::proctor::ProctorMPI;
using pcl::proctor::Proctor;
using pcl::proctor::ScanningModelSource;
using pcl::proctor::BasicProposer;

int main(int argc, char **argv) {
  unsigned int model_seed = 2;
  unsigned int test_seed = 0; //time(NULL);

  if (argc >= 2)
  {
    model_seed = atoi(argv[1]);
  }

  if (argc >= 3)
  {
    test_seed = atoi(argv[2]);
  }

  Detector detector;
  Proctor proctor;

  BasicProposer::Ptr proposer(new BasicProposer);
  detector.setProposer(proposer);

  ScanningModelSource model_source("Princeton", "/home/justin/Documents/benchmark/db");
  model_source.loadModels();

  //detector.enableVisualization();
  proctor.setModelSource(&model_source);
  proctor.train(detector);
  proctor.test(detector, test_seed);
  proctor.printResults(detector);

  sleep(100000);

  return 0;
}

Remove unneeded OpenMP header import.


/*
 * RandMeasure.cpp
 *
 *  Created on: 19.01.2013
 *      Author: Christian Staudt (christian.staudt@kit.edu)
 */

#include "NodeStructuralRandMeasure.h"

namespace NetworKit {

double NodeStructuralRandMeasure::getDissimilarity(const Graph& G, const Partition& first, const Partition& second) {

	count n = G.numberOfNodes();
	assert (n > 0);

	count s11 = 0; 	// number of node pairs for which clusterings aggree
	count s00 = 0;	// number of node pairs for which clusterings disagree

	G.forNodePairs([&](node u, node v){
		if ((first[u] == first[v]) && (second[u] == second[v])) {
			s11 += 1;
		} else if ((first[u] != first[v]) && (second[u] != second[v])) {
			s00 += 1;
		}
	});

	double rand = 1 - ((2 * (s11 + s00)) / (n * (n-1)));

	// assert range [0, 1]
	assert (rand <= 1.0);
	assert (rand >= 0.0);
	return rand;
}

} /* namespace NetworKit */

/*
 * RandMeasure.cpp
 *
 *  Created on: 19.01.2013
 *      Author: Christian Staudt (christian.staudt@kit.edu)
 */

#include "NodeStructuralRandMeasure.h"

namespace NetworKit {

double NodeStructuralRandMeasure::getDissimilarity(const Graph& G, const Partition& first, const Partition& second) {

	count n = G.numberOfNodes();
	assert (n > 0);

	count s11 = 0; 	// number of node pairs for which clusterings aggree
	count s00 = 0;	// number of node pairs for which clusterings disagree

	G.forNodePairs([&](node u, node v){
		if ((first[u] == first[v]) && (second[u] == second[v])) {
			s11 += 1;
		} else if ((first[u] != first[v]) && (second[u] != second[v])) {
			s00 += 1;
		}
	});

	double rand = 1 - ((2 * (s11 + s00)) * 1.0 / (n * (n-1)));

	// assert range [0, 1]
	assert (rand <= 1.0);
	assert (rand >= 0.0);
	return rand;
}

} /* namespace NetworKit */

Fix node-structural Rand measure to not to be binary


// For conditions of distribution and use, see copyright notice in license.txt

#include "UpdateModuleMac.h"

#include "Framework.h"
#include "CoreDefines.h"
#include "Application.h"

UpdateModule::UpdateModule() :
    IModule("UpdateModule"),
    updater_(0)
{
}

UpdateModule::~UpdateModule()
{
}

void UpdateModule::Initialize()
{
    CocoaInitializer initializer;
    updater_ = new SparkleAutoUpdater("http://adminotech.data.s3.amazonaws.com/clients/tundra2/appcast.xml");
}

void UpdateModule::RunUpdater(QString parameter)
{
    if (updater_)
        updater_->checkForUpdates();
}

extern "C"
{
    DLLEXPORT void TundraPluginMain(Framework *fw)
    {
        Framework::SetInstance(fw); // Inside this DLL, remember the pointer to the global framework object.
        IModule *module = new UpdateModule();
        fw->RegisterModule(module);
    }
}

// For conditions of distribution and use, see copyright notice in license.txt

#include "UpdateModuleMac.h"

#include "Framework.h"
#include "CoreDefines.h"
#include "Application.h"

UpdateModule::UpdateModule() :
    IModule("UpdateModule"),
    updater_(0)
{
}

UpdateModule::~UpdateModule()
{
}

void UpdateModule::Initialize()
{
    CocoaInitializer initializer;
    updater_ = new SparkleAutoUpdater("http://adminotech.data.s3.amazonaws.com/clients/tundra2/appcast.xml");

    if (updater_)
        updater_->checkForUpdates();
}

void UpdateModule::RunUpdater(QString parameter)
{
    if (updater_)
        updater_->checkForUpdates();
}

extern "C"
{
    DLLEXPORT void TundraPluginMain(Framework *fw)
    {
        Framework::SetInstance(fw); // Inside this DLL, remember the pointer to the global framework object.
        IModule *module = new UpdateModule();
        fw->RegisterModule(module);
    }
}

Check for updates on startup


#include <QApplication>
#include <QSettings>
#include <QLocale>
#include <QTranslator>
#include <QLibraryInfo>

#include "trayicon.h"

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QApplication::setOrganizationName("Restnotifier");
    app.setQuitOnLastWindowClosed(false);

    // Set language
    QSettings settings;
    QString lang;
    QTranslator translator, qtTranslator;
    if (settings.contains("lang"))
        lang = settings.value("lang").toString();
    else
    {
        lang = QLocale::system().name();
        lang.truncate(lang.indexOf('_'));
    }
    if (lang == "ru")
    {
        QLocale::setDefault(QLocale("ru"));

        // install qt translator
#if defined Q_WS_X11
        const QString loc = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#elif defined Q_WS_WIN
        const QString loc;
#endif
        qtTranslator.load("qt_ru", loc);
        app.installTranslator(&qtTranslator);

        // install app translator
        QString translationsPath = settings.value("tr_path", QString()).toString();
        translator.load("restnotifier_ru", translationsPath);
        app.installTranslator(&translator);
    }

    TrayIcon *trayIcon = new TrayIcon();
    trayIcon->show();
    QObject::connect(trayIcon, SIGNAL(quitScheduled()), &app, SLOT(quit()));
    int code = app.exec();
    delete trayIcon;
    return code;
}

#include <QApplication>
#include <QSettings>
#include <QLocale>
#include <QTranslator>
#include <QLibraryInfo>

#include "trayicon.h"

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QApplication::setOrganizationName("Restnotifier");
    app.setQuitOnLastWindowClosed(false);

    // Set language
    QSettings settings;
    QString lang;
    QTranslator translator, qtTranslator;
    if (settings.contains("lang"))
        lang = settings.value("lang").toString();
    else
    {
        lang = QLocale::system().name();
        lang.truncate(lang.indexOf('_'));
    }
    if (lang == "ru")
    {
        QLocale::setDefault(QLocale("ru"));

        // install qt translator
#if defined Q_OS_WIN
        const QString loc;
#else
        const QString loc = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#endif
        qtTranslator.load("qt_ru", loc);
        app.installTranslator(&qtTranslator);

        // install app translator
        QString translationsPath = settings.value("tr_path", QString()).toString();
        translator.load("restnotifier_ru", translationsPath);
        app.installTranslator(&translator);
    }

    TrayIcon *trayIcon = new TrayIcon();
    trayIcon->show();
    QObject::connect(trayIcon, SIGNAL(quitScheduled()), &app, SLOT(quit()));
    int code = app.exec();
    delete trayIcon;
    return code;
}

Improve preprocessor usage a bit


/*
 * rngs
 * ECE 541 Project 2
 * Kashev Dalmia - dalmia3
 * David Huang   - huang157
 */

#include "ranlux32.h"

namespace rng
{
    RANLUX32::RANLUX32() :
        RandomNumberGenerator(),
        prev(0),
        count(0),
        state(),
        index(0)
    {}

    void RANLUX32::seed(fuint seed_num) {
        state[0] = seed_num;

        /*
         * Initialize seed vector using MINSTD
         */
        static constexpr uint64_t g = 48271;
        static constexpr uint64_t n = (1UL << 48UL); // 2^49
        for(size_t i = 1; i < state.size(); ++i)
        {
            state[i] = static_cast<fuint>((static_cast<uint64_t>(state[i-1]) * g) % n);
        }
    }

    fuint RANLUX32::operator()() {
        if(count == discard) {
            count = 0;
            for(uint i = 0; i < block_size-discard; ++i) {
                next_state();
            }
        }
        uint64_t output = next_state();
        count++;
        return static_cast<fuint>(output);
    }
}

/*
 * rngs
 * ECE 541 Project 2
 * Kashev Dalmia - dalmia3
 * David Huang   - huang157
 */

#include "ranlux32.h"

namespace rng
{
    RANLUX32::RANLUX32() :
        RandomNumberGenerator(),
        prev(0),
        count(0),
        state(),
        index(0)
    {}

    void RANLUX32::seed(fuint seed_num) {
        state[0] = seed_num;

        /*
         * Initialize seed vector using MINSTD
         */
        static constexpr uint64_t g = 48271;
        static constexpr uint64_t n = (1UL << 31UL) - 1UL; // 2^32 -1
        fuint first, second;
        for(size_t i = 1; i < state.size(); ++i)
        {
            first = static_cast<fuint>((static_cast<uint64_t>(state[i-1]) * g) % n);
            second = static_cast<fuint>((static_cast<uint64_t>(first) * g) % n);
            state[i] = ((static_cast<uint64_t>(first)) << 32UL) << second;
        }
    }

    fuint RANLUX32::operator()() {
        if(count == discard) {
            count = 0;
            for(uint i = 0; i < block_size-discard; ++i) {
                next_state();
            }
        }
        uint64_t output = next_state();
        count++;
        return static_cast<fuint>(output);
    }
}

Change seed generation using MINSTD


VectorXf v;
v.setLinSpaced(5,0.5f,1.5f).transpose();
cout << v << endl;

VectorXf v;
v.setLinSpaced(5,0.5f,1.5f);
cout << v << endl;

Remove confusing transpose() in setLinSpaced() docs.


#include "edge.h"

void Dictionary::Add(MonoObject* _this, const char* name, MonoObject* value)
{
    static MonoMethod* add;

    if(!add) {
        add = mono_class_get_method_from_name(mono_object_get_class(_this),
            "System.Collections.Generic.IDictionary<string,object>.Add", -1);
    }

    void* params[2];
    params[0] = mono_string_new(mono_domain_get(), name);
    params[1] = value;

    mono_runtime_invoke(add, _this, params, NULL);
}

#include "edge.h"

void Dictionary::Add(MonoObject* _this, const char* name, MonoObject* value)
{
    static MonoMethod* add;
    if(!add) {
        add = mono_class_get_method_from_name(mono_object_get_class(_this),
             "System.Collections.Generic.IDictionary<string,object>.Add", -1);

        // This is to work around a crash due to updating to MONO 5.0.
        // We still need the previous call to be backwards compatible.
        if (add == NULL)
        {

            add = mono_class_get_method_from_name(mono_object_get_class(_this),
                "System.Collections.Generic.IDictionary<System.String,System.Object>.Add", -1);
        }

    }

    void* params[2];
    params[0] = mono_string_new(mono_domain_get(), name);
    params[1] = value;

    mono_runtime_invoke(add, _this, params, NULL);
}

Fix crash for mono 5.0.


#include "stdafx.h"
#include "CppUnitTest.h"

#include "datastore.h"
#include "transaction.h"
#include "internal/operations/post_operation.h"
#include "dummy_values.h"

using Assert = Microsoft::VisualStudio::CppUnitTestFramework::Assert;

namespace You {
namespace DataStore {
namespace UnitTests {
TEST_CLASS(DataStoreApiTest) {
public:
	TEST_METHOD(pushOperationToTransaction) {
		Transaction sut;
		std::shared_ptr<Internal::IOperation> postOp =
			std::make_shared<Internal::PostOperation>(0, task1);
		sut.push(postOp);
		Assert::AreEqual(boost::lexical_cast<size_t>(1), sut.operationsQueue.size());
	}
};

}  // namespace UnitTests
}  // namespace DataStore
}  // namespace You

#include "stdafx.h"
#include "CppUnitTest.h"

#include "datastore.h"
#include "transaction.h"
#include "internal/operations/post_operation.h"
#include "internal/operations/put_operation.h"
#include "internal/operations/erase_operation.h"
#include "dummy_values.h"

using Assert = Microsoft::VisualStudio::CppUnitTestFramework::Assert;

namespace You {
namespace DataStore {
namespace UnitTests {
TEST_CLASS(DataStoreApiTest) {
public:
	TEST_METHOD(pushOperationsToTransaction) {
		Transaction sut;

		std::shared_ptr<Internal::IOperation> postOp =
			std::make_shared<Internal::PostOperation>(0, task1);
		sut.push(postOp);
		Assert::AreEqual(boost::lexical_cast<size_t>(1), sut.operationsQueue.size());

		std::shared_ptr<Internal::IOperation> putOp =
			std::make_shared<Internal::PutOperation>(0, task2);
		sut.push(putOp);
		Assert::AreEqual(boost::lexical_cast<size_t>(2), sut.operationsQueue.size());

		std::shared_ptr<Internal::IOperation> eraseOp =
			std::make_shared<Internal::EraseOperation>(0);
		sut.push(eraseOp);
		Assert::AreEqual(boost::lexical_cast<size_t>(3), sut.operationsQueue.size());
	}

};

}  // namespace UnitTests
}  // namespace DataStore
}  // namespace You

Add more tests for Transaction


#include <zombye/gameplay/states/menu_state.hpp>
#include <zombye/rendering/camera_component.hpp>

using namespace std::string_literals;

zombye::menu_state::menu_state(zombye::state_machine *sm) : sm_(sm) {

}

void zombye::menu_state::enter() {
    zombye::log("enter menu state");
}

void zombye::menu_state::leave() {
    zombye::log("leave menu state");
}

void zombye::menu_state::update(float delta_time) {
    sm_->use(GAME_STATE_PLAY);
}

#include <zombye/gameplay/states/menu_state.hpp>
#include <zombye/rendering/camera_component.hpp>

using namespace std::string_literals;

zombye::menu_state::menu_state(zombye::state_machine *sm) : sm_(sm) {

}

void zombye::menu_state::enter() {
    zombye::log("enter menu state");
    auto& camera = sm_->get_game()->entity_manager().emplace(glm::vec3{-2.f, 2.f, -3.0f}, glm::quat{}, glm::vec3{});
    camera.emplace<camera_component>(glm::vec3{}, glm::vec3{0.f, 1.f, 0.f});
    sm_->get_game()->rendering_system().activate_camera(camera.id());
    sm_->get_game()->entity_manager().emplace("dummy", glm::vec3{}, glm::quat{}, glm::vec3{1});
}

void zombye::menu_state::leave() {
    zombye::log("leave menu state");
}

void zombye::menu_state::update(float delta_time) {
    sm_->use(GAME_STATE_PLAY);
}

Revert "remove georgs fancy camera and mesh stuff"


/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.

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.
==============================================================================*/

#include "tensorflow/core/platform/cuda_libdevice_path.h"

#include <stdlib.h>

#include <vector>

#include "tensorflow/core/platform/platform.h"

#if !defined(PLATFORM_GOOGLE)
#include "third_party/gpus/cuda/cuda_config.h"
#endif
#include "tensorflow/core/platform/logging.h"

namespace tensorflow {

std::vector<string> CandidateCudaRoots() {
#if !defined(PLATFORM_GOOGLE)
  VLOG(3) << "CUDA root = " << TF_CUDA_TOOLKIT_PATH;
  return {TF_CUDA_TOOLKIT_PATH, string("/usr/local/cuda")};
#else
  return {string("/usr/local/cuda")};
#endif
}

bool PreferPtxasFromPath() { return true; }

}  // namespace tensorflow

/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.

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.
==============================================================================*/

#include "tensorflow/core/platform/cuda_libdevice_path.h"

#include <stdlib.h>

#include <string>
#include <vector>

#include "tensorflow/core/platform/platform.h"

#if !defined(PLATFORM_GOOGLE)
#include "third_party/gpus/cuda/cuda_config.h"
#endif
#include "tensorflow/core/platform/logging.h"

namespace tensorflow {

std::vector<std::string> CandidateCudaRoots() {
#if !defined(PLATFORM_GOOGLE)
  VLOG(3) << "CUDA root = " << TF_CUDA_TOOLKIT_PATH;
  return {TF_CUDA_TOOLKIT_PATH, std::string("/usr/local/cuda")};
#else
  return {std::string("/usr/local/cuda")};
#endif
}

bool PreferPtxasFromPath() { return true; }

}  // namespace tensorflow

Fix missing qualifier for std::string


// Copyright (c) 2015 The Bitcoin Core developers
// Copyright (c) 2015-2018 The Bitcoin Unlimited developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "bench.h"
#include "main.h"
#include "utiltime.h"

// Sanity test: this should loop ten times, and
// min/max/average should be close to 100ms.
static void Sleep100ms(benchmark::State &state)
{
    while (state.KeepRunning())
    {
        MilliSleep(100);
    }
}

BENCHMARK(Sleep100ms);

// Extremely fast-running benchmark:
#include <math.h>

volatile double sum = 0.0; // volatile, global so not optimized away

static void Trig(benchmark::State &state)
{
    double d = 0.01;
    while (state.KeepRunning())
    {
        sum += sin(d);
        d += 0.000001;
    }
}

BENCHMARK(Trig);

// Copyright (c) 2015 The Bitcoin Core developers
// Copyright (c) 2015-2018 The Bitcoin Unlimited developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "bench.h"
#include "utiltime.h"

// Sanity test: this should loop ten times, and
// min/max/average should be close to 100ms.
static void Sleep100ms(benchmark::State &state)
{
    while (state.KeepRunning())
    {
        MilliSleep(100);
    }
}

BENCHMARK(Sleep100ms);

// Extremely fast-running benchmark:
#include <math.h>

volatile double sum = 0.0; // volatile, global so not optimized away

static void Trig(benchmark::State &state)
{
    double d = 0.01;
    while (state.KeepRunning())
    {
        sum += sin(d);
        d += 0.000001;
    }
}

BENCHMARK(Trig);

Remove useless include from Example.cpp


//===- ChainedDiagnosticConsumer.cpp - Chain Diagnostic Clients -*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "clang/Frontend/ChainedDiagnosticConsumer.h"

using namespace clang;

void ChainedDiagnosticConsumer::anchor() { }

//===- ChainedDiagnosticConsumer.cpp - Chain Diagnostic Clients -----------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "clang/Frontend/ChainedDiagnosticConsumer.h"

using namespace clang;

void ChainedDiagnosticConsumer::anchor() { }

Remove spurious mode marker from .cpp file.


/**
 * @file       main.cpp
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Mar 2015
 * @brief
 */

//#define BLYNK_DEBUG
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
  #include <BlynkApiWiringPi.h>
#else
  #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);

static const char *auth, *serv;
static uint16_t port;

#include <BlynkWidgets.h>

BLYNK_WRITE(V1)
{
    printf("Got a value: %s\n", param[0].asStr());
}

void setup()
{
    Blynk.begin(auth, serv, port);
}

void loop()
{
    Blynk.run();
}

int main(int argc, char* argv[])
{
    parse_options(argc, argv, auth, serv, port);

    setup();
    while(true) {
        loop();
    }

    return 0;
}

/**
 * @file       main.cpp
 * @author     Volodymyr Shymanskyy
 * @license    This project is released under the MIT License (MIT)
 * @copyright  Copyright (c) 2015 Volodymyr Shymanskyy
 * @date       Mar 2015
 * @brief
 */

//#define BLYNK_DEBUG
#define BLYNK_PRINT stdout
#ifdef RASPBERRY
  #include <BlynkApiWiringPi.h>
#else
  #include <BlynkApiLinux.h>
#endif
#include <BlynkSocket.h>
#include <BlynkOptionsParser.h>

static BlynkTransportSocket _blynkTransport;
BlynkSocket Blynk(_blynkTransport);

static const char *auth, *serv;
static uint16_t port;

#include <BlynkWidgets.h>

BlynkTimer tmr;

BLYNK_WRITE(V1)
{
    printf("Got a value: %s\n", param[0].asStr());
}

void setup()
{
    Blynk.begin(auth, serv, port);
    tmr.setInterval(1000, [](){
      Blynk.virtualWrite(V0, BlynkMillis()/1000);
    });
}

void loop()
{
    Blynk.run();
    tmr.run();
}

int main(int argc, char* argv[])
{
    parse_options(argc, argv, auth, serv, port);

    setup();
    while(true) {
        loop();
    }

    return 0;
}

Add timer to Linux example


// 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 "base/test/test_suite.h"
#include "media/base/media.h"

int main(int argc, char** argv) {
  base::TestSuite suite(argc, argv);

  media::InitializeMediaLibraryForTesting();

  return suite.Run();
}

// Copyright (c) 2012 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/logging.h"
#include "base/test/test_suite.h"
#include "media/base/media.h"

class TestSuiteNoAtExit : public base::TestSuite {
 public:
  TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv, false) {}
  virtual ~TestSuiteNoAtExit() {}
};

int main(int argc, char** argv) {
  // By default command-line parsing happens only in TestSuite::Run(), but
  // that's too late to get VLOGs and so on from
  // InitializeMediaLibraryForTesting() below.  Instead initialize logging
  // explicitly here (and have it get re-initialized by TestSuite::Run()).
  CommandLine::Init(argc, argv);
  CHECK(logging::InitLogging(
      NULL,
      logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
      logging::DONT_LOCK_LOG_FILE,
      logging::APPEND_TO_OLD_LOG_FILE,
      logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS));
  base::AtExitManager exit_manager;

  media::InitializeMediaLibraryForTesting();

  return TestSuiteNoAtExit(argc, argv).Run();
}

Initialize logging early enough to see VLOGs emitted by InitializeMediaLibraryForTesting(). (specifically, this makes ffmpeg_stubs.cc VLOGs actually get emitted if -v=1 is specified)


#include "ConnectCallVisitor.h"

bool ConnectCallVisitor::VisitCallExpr(clang::CallExpr *expr)
{
	return true;
}

#include <iostream>

#include "ConnectCallVisitor.h"

namespace
{
	bool isQObjectConnect(clang::CallExpr *expr)
	{
		// These are needed a lot so keep them around
		static const clang::StringRef expectedMethodName("connect");
		static const clang::StringRef expectedClassName("QObject");

		const clang::Decl *calleeDecl = expr->getCalleeDecl();

		// Assume this is a method
		const auto *methodDecl = clang::dyn_cast_or_null<clang::CXXMethodDecl>(calleeDecl);

		if (!methodDecl)
		{
			// Nope
			return false;
		}

		if (!methodDecl->isStatic())
		{
			// XXX: We only handle the static version for now
			return false;
		}

		// Check the name of the class and methond
		if (methodDecl->getName() != expectedMethodName)
		{
			return false;
		}

		if (methodDecl->getParent()->getName() != expectedClassName)
		{
			return false;
		}

		return true;
	}
}

bool ConnectCallVisitor::VisitCallExpr(clang::CallExpr *expr)
{
	if (!isQObjectConnect(expr))
	{
		return true;
	}

	std::cout << "Found QObject::connect" << std::endl;

	return true;
}

Add heuristics for finding QObject::connect


#include "RNG.h"
#include "Utils.h"
#include <cmath>

namespace DNest4
{

RNG::RNG()
:uniform(0., 1.)
,normal(0., 1.)
{

}

void RNG::set_seed(unsigned int seed)
{
	twister.seed(seed);
}

double RNG::rand()
{
	return uniform(twister);
}

double RNG::randn()
{
	return normal(twister);
}

double RNG::randh()
{
	return pow(10.0, 1.5 - 3*std::abs(tan(M_PI*(this->rand() - 0.5))))
                        *this->randn();
}

int RNG::rand_int(int N)
{
	return static_cast<int>(floor(N*this->rand()));
}

} // namespace DNest4

#include "RNG.h"
#include "Utils.h"
#include <cmath>

namespace DNest4
{

RNG::RNG()
:uniform(0., 1.)
,normal(0., 1.)
{

}

void RNG::set_seed(unsigned int seed)
{
	twister.seed(seed);
}

double RNG::rand()
{
	return uniform(twister);
}

double RNG::randn()
{
	return normal(twister);
}

double RNG::randh()
{
    // t-distribution with 2 degrees of freedom (less ridiculous than Cauchy)
    double T = this->randn()/
                sqrt((pow(this->randn(), 2) + pow(this->randn(), 2))/2);
	return pow(10.0, 1.5 - 3*std::abs(T))*this->randn();
}

int RNG::rand_int(int N)
{
	return static_cast<int>(floor(N*this->rand()));
}

} // namespace DNest4

Use t(nu=2) instead of Cauchy


#include "gameboy.h"
#include "cartridge.h"
#include "video/screen.h"
#include "util/log.h"

#include "video/screens/null_screen.h"
#include "video/screens/sfml_screen.h"

int main(int argc, char* argv[]) {
    log_set_level(LogLevel::Trace);

    if (argc < 2) {
        log_error("Please provide a ROM file to run")
        return 1;
    }

    bool should_debug = (argc == 3);
    if (should_debug) {
        log_info("Enabling debugger...");
    }

    std::string rom_name = argv[1];
    Cartridge cartridge(rom_name);

    SFMLScreen screen;

    Gameboy gameboy(screen, cartridge, should_debug);
    gameboy.run();
}

#include "gameboy.h"
#include "cartridge.h"
#include "video/screen.h"
#include "util/log.h"

#include "video/screens/null_screen.h"
#include "video/screens/sfml_screen.h"

int main(int argc, char* argv[]) {
    log_set_level(LogLevel::Debug);

    if (argc < 2) {
        log_error("Please provide a ROM file to run")
        return 1;
    }

    bool should_debug = (argc == 3);
    if (should_debug) {
        log_info("Enabling debugger...");
    }

    std::string rom_name = argv[1];
    Cartridge cartridge(rom_name);

    SFMLScreen screen;

    Gameboy gameboy(screen, cartridge, should_debug);
    gameboy.run();
}

Set log level to Debug by default


//===--------------------- cxa_thread_atexit_test.cpp ---------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// REQUIRES: linux2

#include <assert.h>
#include <cxxabi.h>

static bool AtexitImplCalled = false;

extern "C" int __cxa_thread_atexit_impl(void (*dtor)(void *), void *obj,
                                        void *dso_symbol) {
  assert(dtor == reinterpret_cast<void (*)(void *)>(1));
  assert(obj == reinterpret_cast<void *>(2));
  assert(dso_symbol == reinterpret_cast<void *>(3));
  AtexitImplCalled = true;
  return 4;
}

int main() {
  int RV = __cxxabiv1::__cxa_thread_atexit(
      reinterpret_cast<void (*)(void *)>(1), reinterpret_cast<void *>(2),
      reinterpret_cast<void *>(3));
  assert(RV = 4);
  assert(AtexitImplCalled);
  return 0;
}

//===--------------------- cxa_thread_atexit_test.cpp ---------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// REQUIRES: linux

#include <assert.h>
#include <cxxabi.h>

static bool AtexitImplCalled = false;

extern "C" int __cxa_thread_atexit_impl(void (*dtor)(void *), void *obj,
                                        void *dso_symbol) {
  assert(dtor == reinterpret_cast<void (*)(void *)>(1));
  assert(obj == reinterpret_cast<void *>(2));
  assert(dso_symbol == reinterpret_cast<void *>(3));
  AtexitImplCalled = true;
  return 4;
}

int main() {
  int RV = __cxxabiv1::__cxa_thread_atexit(
      reinterpret_cast<void (*)(void *)>(1), reinterpret_cast<void *>(2),
      reinterpret_cast<void *>(3));
  assert(RV = 4);
  assert(AtexitImplCalled);
  return 0;
}

Make test require 'linux' instead of 'linux2'


#include "ihex.h"

#include <stdlib.h>

int main(int argc, char* argv[])
{
	if (argc != 4)
	{
		std::cerr << argv[0] << " input.hex keyfile output.hex\n"
			<< "Encrypts or decrypts the data in an Intel Hex file.\n"
			<< "Addresses are unchanged, but checksum is updated.\n";
		exit(-1);
	}

	IntelHex file;

	file.Read(argv[1]);

	std::ifstream keyfile;
	keyfile.open(argv[2], std::ios::in | std::ios::binary | std::ios::ate);

	if(!keyfile.is_open()) {
		std::cerr << "Error reading keyfile.\n";
		exit(-2);
	}

	keyfile.seekg(0, std::ios::end);
	int size = keyfile.tellg();
	keyfile.seekg(0, std::ios::beg);

	uint8_t key[size];
	keyfile.read((char*)key, size);
	file.Cipher(key, size);

	file.Write(argv[3]);
}

#include "ihex.h"

#include <stdlib.h>

int main(int argc, char* argv[])
{
	if (argc != 4)
	{
		std::cerr << argv[0] << " input.hex keyfile output.hex\n"
			"Encrypts or decrypts the data in an Intel Hex file.\n"
			"Addresses are unchanged, but checksum is updated.\n\n"
			"The [keyfile] is a raw binary file with the key data. The whole file is\n"
			"used as key data, and can be of arbitrary size.\n"
			;
		exit(-1);
	}

	IntelHex file;

	file.Read(argv[1]);

	std::ifstream keyfile;
	keyfile.open(argv[2], std::ios::in | std::ios::binary | std::ios::ate);

	if(!keyfile.is_open()) {
		std::cerr << "Error reading keyfile.\n";
		exit(-2);
	}

	keyfile.seekg(0, std::ios::end);
	int size = keyfile.tellg();
	keyfile.seekg(0, std::ios::beg);

	uint8_t key[size];
	keyfile.read((char*)key, size);
	file.Cipher(key, size);

	file.Write(argv[3]);
}

Add information about the keyfile "format".