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

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


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

Remove unneeded OpenMP header import.

git-svn-id: 1af002208e930b4d920e7c2b948d1e98a012c795@3877 a9d63959-f2ad-4865-b262-bf0e56cfafb6


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

Before this fix, the node-structural rand-measure returned 0 for
completely identical clusterings and 1 otherwise.


// 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

UpdateModule: 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

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

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.

--HG--
extra : transplant_source : %F0%11%00%02%C1%9C%CF%B3%8F%E9%DC%2B%97%DD%5C%7C%06%7C%21%3B


#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.

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

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"

This reverts commit 29c1a554537053a40cc66e712d5ec1ab23bcba4f.


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

Fix missing qualifier for std::string

PiperOrigin-RevId: 471087779


// 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

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.

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


/**
 * @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

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)

BUG=none
TEST=none

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

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


#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

This still doesn't do anything but identify likely connect() calls


#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

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

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'

git-svn-id: 6a9f6578bdee8d959f0ed58970538b4ab6004734@228073 91177308-0d34-0410-b5e6-96231b3b80d8


#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".

It's obvious, but even more so when it's written down!


#include "VolumeSlider.h"

#include "Skin.h"

VolumeSlider::VolumeSlider(HINSTANCE hInstance, Settings &settings) :
OSD(hInstance, L"3RVX-VolumeSlider", settings),
_mWnd(hInstance, L"3RVX-VolumeSliderWnd", L"3RVX Volume Slider") {

    std::wstring skinXML = settings.SkinXML();
    Skin skin(skinXML);

    long styles = GetWindowLongPtr(_mWnd.HWnd(), GWL_EXSTYLE);
    styles &= ~(WS_EX_NOACTIVATE | WS_EX_TRANSPARENT);
    SetWindowLongPtr(_mWnd.HWnd(), GWL_EXSTYLE, styles);

    Gdiplus::Bitmap *bg = skin.ControllerBgImg("volume");
    _mWnd.BackgroundImage(bg);
    _mWnd.Update();
    _mWnd.Show();

}

void VolumeSlider::Hide() {
    _mWnd.Hide(false);
}

#include "VolumeSlider.h"

#include "Skin.h"

VolumeSlider::VolumeSlider(HINSTANCE hInstance, Settings &settings) :
OSD(hInstance, L"3RVX-VolumeSlider", settings),
_sWnd(hInstance, L"3RVX-VolumeSliderWnd", L"3RVX Volume Slider") {

    std::wstring skinXML = settings.SkinXML();
    Skin skin(skinXML);

    Gdiplus::Bitmap *bg = skin.ControllerBgImg("volume");
    _sWnd.BackgroundImage(bg);
    _sWnd.Update();
    _sWnd.Show();
}

void VolumeSlider::Hide() {
    _sWnd.Hide(false);
}

Update for new SliderWnd class

Update for new SliderWnd class


#include "mainwindow.h"

#include "bucketlist.h"

#include <QLabel>
#include <QBoxLayout>
#include <QtWebKit>
#include <QSettings>
#include <QInputDialog>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    QWidget *central = new QWidget;
    setCentralWidget(central);

    QBoxLayout *topLayout = new QHBoxLayout(central);

    BucketList *bucketList = new BucketList;
    topLayout->addWidget(bucketList);

    m_view = new QWebView;
    topLayout->addWidget(m_view);

    getServerPath();

    connect(&m_server, SIGNAL(started()), SLOT(loadView()));
    m_server.start();
}

MainWindow::~MainWindow()
{
    m_server.stop();
}

void MainWindow::getServerPath()
{
    QSettings settings;

    QString path = settings.value("view/path").toString();
    if (path.isEmpty()) {
        path = QInputDialog::getText(this, "View path", "Enter base path of view for web server");
    }
    settings.setValue("view/path", path);

    m_server.setPath(path);
}

void MainWindow::loadView()
{
    m_view->setUrl(QUrl("http://localhost:8765"));
    m_view->show();
}

#include "mainwindow.h"

#include "bucketlist.h"

#include <QLabel>
#include <QBoxLayout>
#include <QtWebKit>
#include <QSettings>
#include <QInputDialog>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    QWidget *central = new QWidget;
    setCentralWidget(central);

    QBoxLayout *topLayout = new QHBoxLayout(central);

    BucketList *bucketList = new BucketList;
    topLayout->addWidget(bucketList);

    m_view = new QWebView;
    topLayout->addWidget(m_view, 1);
    m_view->setMinimumSize(1000, 540);

    getServerPath();

    connect(&m_server, SIGNAL(started()), SLOT(loadView()));
    m_server.start();
}

MainWindow::~MainWindow()
{
    m_server.stop();
}

void MainWindow::getServerPath()
{
    QSettings settings;

    QString path = settings.value("view/path").toString();
    if (path.isEmpty()) {
        path = QInputDialog::getText(this, "View path", "Enter base path of view for web server");
    }
    settings.setValue("view/path", path);

    m_server.setPath(path);
}

void MainWindow::loadView()
{
    m_view->setUrl(QUrl("http://localhost:8765"));
    m_view->show();
}

Make widget always fit the view

Make widget always fit the view


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

#include "chromeos/system/devicetype.h"

#include <string>

#include "base/sys_info.h"

namespace chromeos {

namespace {
const char kDeviceType[] = "CHROMEOS_DEVICE_TYPE";
}

DeviceType GetDeviceType() {
  std::string value;
  if (base::SysInfo::GetLsbReleaseValue(kDeviceType, &value)) {
    if (value == "CHROMEBASE")
      return DeviceType::kChromebase;
    else if (value == "CHROMEBIT")
      return DeviceType::kChromebit;
    // Most devices are Chromebooks, so we will also consider reference boards
    // as chromebooks.
    else if (value == "CHROMEBOOK" || value == "REFERENCE")
      return DeviceType::kChromebook;
    else if (value == "CHROMEBOX")
      return DeviceType::kChromebox;
    else
      LOG(ERROR) << "Unknown device type \"" << value << "\"";
  }

  return DeviceType::kUnknown;
}

}  // namespace chromeos

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

#include "chromeos/system/devicetype.h"

#include <string>

#include "base/sys_info.h"

namespace chromeos {

namespace {
const char kDeviceType[] = "DEVICETYPE";
}

DeviceType GetDeviceType() {
  std::string value;
  if (base::SysInfo::GetLsbReleaseValue(kDeviceType, &value)) {
    if (value == "CHROMEBASE")
      return DeviceType::kChromebase;
    else if (value == "CHROMEBIT")
      return DeviceType::kChromebit;
    // Most devices are Chromebooks, so we will also consider reference boards
    // as chromebooks.
    else if (value == "CHROMEBOOK" || value == "REFERENCE")
      return DeviceType::kChromebook;
    else if (value == "CHROMEBOX")
      return DeviceType::kChromebox;
    else
      LOG(ERROR) << "Unknown device type \"" << value << "\"";
  }

  return DeviceType::kUnknown;
}

}  // namespace chromeos

Use the correct lsb key when fetching the CrOS device type.

This fixes a typo where the wrong key was used. The data is exposed under
a different key.

BUG=341356

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

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


Add a beter commit message

TODO: Add a beter commit message


Fix that bug where things didn't work but now they should


Put the thingie in the thingie

Put the thingie in the thingie


#include <3ds.h>
#include <stdio.h>

void shutdown3DS()
{
	Handle nssHandle = 0;
	Result result = srvGetServiceHandle(&nssHandle, "ns:s");
	if (result != 0)
		return;

	// http://3dbrew.org/wiki/NSS:ShutdownAsync

	u32 *commandBuffer = getThreadCommandBuffer();
	commandBuffer[0] = 0x000E0000;

	svcSendSyncRequest(nssHandle);
	svcCloseHandle(nssHandle);
}

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

	// Hack: the 3ds crashes ("An error has occcurred.") for some reason
	// without one iteration of the APT main loop.
	aptMainLoop();
	return 0;
}

#include <3ds.h>
#include <stdio.h>

// http://3dbrew.org/wiki/NSS:ShutdownAsync
void NSS_ShutdownAsync(void)
{
	Handle nssHandle = 0;
	Result result = srvGetServiceHandle(&nssHandle, "ns:s");
	if (result != 0)
		return;

	u32 *commandBuffer = getThreadCommandBuffer();
	commandBuffer[0] = 0x000E0000;

	svcSendSyncRequest(nssHandle);
	svcCloseHandle(nssHandle);
}

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

	// Hack: the 3ds crashes ("An error has occcurred.") for some reason
	// without one iteration of the APT main loop.
	aptMainLoop();
	return 0;
}

Call it NSS_ShutdownAsync instead of shutdown3DS.


#include "Name.h"

bool Name::init(String name) {
    size = name.length() + 1;

    data = (uint8_t *) malloc(size);

    if (data != NULL) {
        uint8_t lastDot = size;

        for (uint8_t i = size - 1; i > 0; i--) {
            uint8_t c = name.charAt(i - 1);

            if (c == '.') {
                data[i] = lastDot - i - 1;
                lastDot = i;
            } else {
                data[i] = c;
            }
        }

        data[0] = lastDot - 1;
    }

    return data != NULL;
}

uint8_t Name::getSize() {
    return size;
}

bool Name::match(uint8_t c) {
    matches &= data[matchOffset++] = c;

    return matches;
}

void Name::write(Buffer buffer) {
    if (writtenOffset == 0) {
        writtenOffset = buffer.getOffset();

        for (int i = 0; i < size; i++) {
            buffer.writeUInt8(data[i]);
        }
    } else {
        buffer.writeUInt16((BACK_REF << 8) | writtenOffset);
    }
}

void Name::reset() {
    matches = true;
    matchOffset = 0;
    writtenOffset = 0;
}

#include "Name.h"

bool Name::init(String name) {
    size = name.length() + 1;

    data = (uint8_t *) malloc(size);

    if (data != NULL) {
        uint8_t lastDot = size;

        for (uint8_t i = size - 1; i > 0; i--) {
            uint8_t c = name.charAt(i - 1);

            if (c == '.') {
                data[i] = lastDot - i - 1;
                lastDot = i;
            } else {
                data[i] = c;
            }
        }

        data[0] = lastDot - 1;
    }

    return data != NULL;
}

uint8_t Name::getSize() {
    return size;
}

bool Name::match(uint8_t c) {
    matches = matches && matchOffset < size && data[matchOffset++] == c;

    return matches;
}

void Name::write(Buffer buffer) {
    if (writtenOffset == 0) {
        writtenOffset = buffer.getOffset();

        for (int i = 0; i < size; i++) {
            buffer.writeUInt8(data[i]);
        }
    } else {
        buffer.writeUInt16((BACK_REF << 8) | writtenOffset);
    }
}

void Name::reset() {
    matches = true;
    matchOffset = 0;
    writtenOffset = 0;
}

Correct buffer overflow in match(...)

Correct buffer overflow in match(...)


#include "./Sphere.hpp"
#include "./misc.hpp"
#include <algorithm>
#include <cmath>

namespace yks {

	Optional<float> intersect(const vec3& origin, float radius, const Ray& r) {
		const vec3 o = r.origin - origin;
		const vec3 v = r.direction;

		float t1, t2;
		const int solutions = solve_quadratic(dot(v, v), 2*dot(o, v), dot(o, o) - radius*radius, t1, t2);

		if (solutions == 0) {
			return Optional<float>();
		} else if (solutions == 1) {
			return make_optional<float>(t1);
		} else {
			return make_optional<float>(std::min(t1, t2));
		}
	}

	vec3 uniform_point_on_sphere(float a, float b) {
		const float y = 2.0f * a - 1.0f;
		const float latitude = std::asin(y);
		const float longitude = b * two_pi;

		return mvec3(cos(latitude) * cos(longitude), y, cos(latitude) * sin(longitude));
	}

}

#include "./Sphere.hpp"
#include "./misc.hpp"
#include <algorithm>
#include <cmath>

namespace yks {

	Optional<float> intersect(const vec3& origin, float radius, const Ray& r) {
		const vec3 o = r.origin - origin;
		const vec3 v = r.direction;

		float t1, t2;
		const int solutions = solve_quadratic(dot(v, v), 2*dot(o, v), dot(o, o) - radius*radius, t1, t2);

		if (solutions == 0) {
			return Optional<float>();
		} else if (solutions == 1) {
			return make_optional<float>(t1);
		} else {
			return make_optional<float>(std::min(t1, t2));
		}
	}

	vec3 uniform_point_on_sphere(float a, float b) {
		const float y = 2.0f * a - 1.0f;
		const float latitude = std::asin(y);
		const float longitude = b * two_pi;
		const float cos_latitude = std::cos(latitude);

		return mvec3(cos_latitude * cos(longitude), y, cos_latitude * sin(longitude));
	}

}

Remove duplicated call to std::cos

Remove duplicated call to std::cos


// RUN: %clang -### -Wlarge-by-value-copy %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_DEFAULT %s
// LARGE_VALUE_COPY_DEFAULT: -Wlarge-by-value-copy=64
// RUN: %clang -### -Wlarge-by-value-copy=128 %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_JOINED %s
// LARGE_VALUE_COPY_JOINED: -Wlarge-by-value-copy=128

// RUN: %clang -### -c -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \
// RUN:        -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s
// CHECK: unknown warning option '-Wmonkey'
// CHECK: unknown warning option '-Wno-monkey'
// CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'?

// FIXME: Remove this together with -Warc-abi once an Xcode is released that doesn't pass this flag.
// RUN: %clang -### -Warc-abi -Wno-arc-abi %s 2>&1 | FileCheck -check-prefix=ARCABI %s
// ARCABI-NOT: unknown warning option '-Warc-abi'
// ARCABI-NOT: unknown warning option '-Wno-arc-abi'

Add a test for -Warc-abi as requested by Fariborz.

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


#include "rdb_protocol/configured_limits.hpp"
#include "rdb_protocol/wire_func.hpp"
#include "rdb_protocol/func.hpp"

namespace ql {
configured_limits_t
from_optargs(const std::map<std::string, wire_func_t> &arguments)
{
    auto p = arguments.find("arrayLimit");
    if (p != arguments.end()) {
        // Fake an environment with no arguments.
        cond_t cond;
        rdb_context_t context;
        // Can't use the original arguments, because it will cause an infinite loop.
        env_t env(&context, &cond, std::map<std::string, wire_func_t>(),
                  profile_bool_t::DONT_PROFILE);
        return configured_limits_t((*p).second.compile_wire_func()->call(&env)->as_int());
    } else {
        return configured_limits_t();
    }
}

} // namespace ql

#include "rdb_protocol/configured_limits.hpp"
#include "rdb_protocol/wire_func.hpp"
#include "rdb_protocol/func.hpp"

namespace ql {
configured_limits_t
from_optargs(const std::map<std::string, wire_func_t> &arguments)
{
    auto p = arguments.find("arrayLimit");
    if (p != arguments.end()) {
        // Fake an environment with no arguments.  We have to fake it
        // because of a chicken/egg problem; this function gets called
        // before there are any extant environments at all.  Only
        // because we use an empty argument list do we prevent an
        // infinite loop.
        cond_t cond;
        rdb_context_t context;
        env_t env(&context, &cond, std::map<std::string, wire_func_t>(),
                  profile_bool_t::DONT_PROFILE);
        return configured_limits_t((*p).second.compile_wire_func()->call(&env)->as_int());
    } else {
        return configured_limits_t();
    }
}

} // namespace ql

Expand on why we need a fake, here.

Expand on why we need a fake, here.