// STL
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
// DSIM
#include <dsim/DSIM_Service.hpp>
#include <dsim/config/dsim-paths.hpp>

// ///////// M A I N ////////////
int main (int argc, char* argv[]) {

  try {

    // Output log File
    std::string lLogFilename ("simulate.log");

    // Set the log parameters
    std::ofstream logOutputFile;
    // Open and clean the log outputfile
    logOutputFile.open (lLogFilename.c_str());
    logOutputFile.clear();

    // Initialise the list of classes/buckets
    DSIM::DSIM_Service dsimService (logOutputFile);

    // Perform a simulation
    dsimService.simulate();

  } catch (const std::exception& stde) {
    std::cerr << "Standard exception: " << stde.what() << std::endl;
    return -1;

  } catch (...) {
    return -1;
  }

  return 0;
}

// STL
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
// DSIM
#include <dsim/DSIM_Service.hpp>
#include <dsim/config/dsim-paths.hpp>

// ///////// M A I N ////////////
int main (int argc, char* argv[]) {

  try {

    // Schedule input file name
    std::string lScheduleInputFilename ("../samples/schedule01.csv");

    // Output log File
    std::string lLogFilename ("simulate.log");

    // Set the log parameters
    std::ofstream logOutputFile;
    // Open and clean the log outputfile
    logOutputFile.open (lLogFilename.c_str());
    logOutputFile.clear();

    // Initialise the list of classes/buckets
    DSIM::DSIM_Service dsimService (lScheduleInputFilename, logOutputFile);

    // Perform a simulation
    dsimService.simulate();

  } catch (const std::exception& stde) {
    std::cerr << "Standard exception: " << stde.what() << std::endl;
    return -1;

  } catch (...) {
    return -1;
  }

  return 0;
}

[Test] Update the test with the schedule input filename.

git-svn-id: 543967457c07248534c6537446d108cd8c20cdb5@33 e67a024f-d144-4c12-b96e-b057add9d369


// Copyright (c) 2018 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

// We are making my contributions/submissions to this project solely in our
// personal capacity and are not conveying any rights to any intellectual
// property of any third parties.

#include <hspp/Tasks/SimpleTasks/IncludeTask.hpp>

namespace Hearthstonepp::SimpleTasks
{
TaskID IncludeTask::GetTaskID() const
{
    return TaskID::INCLUDE;
}

std::vector<Entity*> IncludeTask::GetEntities(EntityType entityType,
                                              Player& player)
{
    std::vector<Entity*> entities;

    switch (entityType)
    {
        case EntityType::HERO:
            entities.emplace_back(player.GetHero());
            break;
        case EntityType::FRIENDS:
            for (auto& minion : player.GetField())
            {
                entities.emplace_back(minion);
            }
            entities.emplace_back(player.GetHero());
            break;
        case EntityType::ENEMIES:
            for (auto& minion : player.GetOpponent().GetField())
            {
                entities.emplace_back(minion);
            }
            entities.emplace_back(player.GetOpponent().GetHero());
            break;
        default:
            throw std::exception("Not implemented");
    }

    return entities;
}

MetaData IncludeTask::Impl(Player&)
{
    return MetaData::INCLUDE_SUCCESS;
}
}  // namespace Hearthstonepp::SimpleTasks

// Copyright (c) 2018 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

// We are making my contributions/submissions to this project solely in our
// personal capacity and are not conveying any rights to any intellectual
// property of any third parties.

#include <hspp/Tasks/SimpleTasks/IncludeTask.hpp>

#include <stdexcept>

namespace Hearthstonepp::SimpleTasks
{
TaskID IncludeTask::GetTaskID() const
{
    return TaskID::INCLUDE;
}

std::vector<Entity*> IncludeTask::GetEntities(EntityType entityType,
                                              Player& player)
{
    std::vector<Entity*> entities;

    switch (entityType)
    {
        case EntityType::HERO:
            entities.emplace_back(player.GetHero());
            break;
        case EntityType::FRIENDS:
            for (auto& minion : player.GetField())
            {
                entities.emplace_back(minion);
            }
            entities.emplace_back(player.GetHero());
            break;
        case EntityType::ENEMIES:
            for (auto& minion : player.GetOpponent().GetField())
            {
                entities.emplace_back(minion);
            }
            entities.emplace_back(player.GetOpponent().GetHero());
            break;
        default:
            throw std::domain_error("Invalid entity type");
    }

    return entities;
}

MetaData IncludeTask::Impl(Player&)
{
    return MetaData::INCLUDE_SUCCESS;
}
}  // namespace Hearthstonepp::SimpleTasks

fix: Correct compile error on Linux and macOS

- no matching function for call to 'std::exception::exception(const char [16])'


#include <test.hpp>

TEST_CASE("basic") {

    SECTION("default constructed pbf message is okay") {
        mapbox::util::pbf item;
        REQUIRE(!item.next());
    }

    SECTION("empty buffer is okay") {
        std::string buffer;
        mapbox::util::pbf item(buffer.data(), 0);
        REQUIRE(!item.next());
    }

    SECTION("check every possible value for single byte in buffer") {
        char buffer[1];
        for (int i = 0; i <= 255; ++i) {
            *buffer = static_cast<char>(i);
            mapbox::util::pbf item(buffer, 1);

            REQUIRE_THROWS({
                item.next();
                item.skip();
            });
        }
    }

}

#include <test.hpp>

TEST_CASE("basic") {

    SECTION("default constructed pbf message is okay") {
        mapbox::util::pbf item;
        REQUIRE(!item.next());
    }

    SECTION("empty buffer is okay") {
        std::string buffer;
        mapbox::util::pbf item(buffer.data(), 0);
        REQUIRE(!item); // test operator bool()
        REQUIRE(!item.next());
    }

    SECTION("check every possible value for single byte in buffer") {
        char buffer[1];
        for (int i = 0; i <= 255; ++i) {
            *buffer = static_cast<char>(i);
            mapbox::util::pbf item(buffer, 1);

            REQUIRE(!!item); // test operator bool()
            REQUIRE_THROWS({
                item.next();
                item.skip();
            });
        }
    }

}

Add tests for operator bool().

Add tests for operator bool().


#include "Rainback.hpp"

#include <lua-cxx/LuaEnvironment.hpp>
#include <lua-cxx/LuaValue.hpp>
#include <QFile>

int main(int argc, char* argv[])
{
    Lua lua;
    rainback::Rainback rainback(lua);

    std::string srcdir(getenv("srcdir"));
    QFile testRunner(QString(srcdir.c_str()) + "/test_lua.lua");
    return (bool)lua(testRunner) ? 0 : 1;
}

#include "Rainback.hpp"

#include <lua-cxx/LuaEnvironment.hpp>
#include <lua-cxx/LuaValue.hpp>
#include <QFile>
#include <QCoreApplication>

int main(int argc, char* argv[])
{
    QCoreApplication app(argc, argv);

    Lua lua;
    rainback::Rainback rainback(lua);

    std::string srcdir(getenv("srcdir"));
    QFile testRunner(QString(srcdir.c_str()) + "/test_lua.lua");
    return (bool)lua(testRunner) ? 0 : 1;
}

Create a QCoreApplication when testing Lua


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

#include "content/renderer/scheduler/renderer_scheduler.h"

#include "content/renderer/scheduler/null_renderer_scheduler.h"

namespace content {

RendererScheduler::RendererScheduler() {
}

RendererScheduler::~RendererScheduler() {
}

// static
scoped_ptr<RendererScheduler> RendererScheduler::Create() {
  // TODO(rmcilroy): Use the RendererSchedulerImpl when the scheduler is enabled
  return make_scoped_ptr(new NullRendererScheduler());
}

}  // namespace content

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

#include "content/renderer/scheduler/renderer_scheduler.h"

#include "base/command_line.h"
#include "base/message_loop/message_loop_proxy.h"
#include "content/public/common/content_switches.h"
#include "content/renderer/scheduler/null_renderer_scheduler.h"
#include "content/renderer/scheduler/renderer_scheduler_impl.h"

namespace content {

RendererScheduler::RendererScheduler() {
}

RendererScheduler::~RendererScheduler() {
}

// static
scoped_ptr<RendererScheduler> RendererScheduler::Create() {
  CommandLine* command_line = base::CommandLine::ForCurrentProcess();
  if (command_line->HasSwitch(switches::kDisableBlinkScheduler)) {
    return make_scoped_ptr(new NullRendererScheduler());
  } else {
    return make_scoped_ptr(
        new RendererSchedulerImpl(base::MessageLoopProxy::current()));
  }
}

}  // namespace content

content: Enable the RendererScheduler by default.

BUG=391005

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

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


#include "gns/test_util/random_number.h"

namespace gns {
namespace test_util {
  RandomNumber::RandomNumber(const size_t seed)
  : engine_(), distribution_()
  {
  }

  double RandomNumber::operator()()
  {
    return distribution_(engine_);
  }

  double RandomNumber::operator()(const double min, const double max)
  {
    const int diff = max - min;
    return (*this)() * diff + min;
  }
} // namespace test_util
} // namespace gns

#include "gns/test_util/random_number.h"

namespace gns {
namespace test_util {
  RandomNumber::RandomNumber(const size_t seed)
  : engine_(), distribution_()
  {
    engine_.seed(seed);
  }

  double RandomNumber::operator()()
  {
    return distribution_(engine_);
  }

  double RandomNumber::operator()(const double min, const double max)
  {
    const int diff = max - min;
    return (*this)() * diff + min;
  }
} // namespace test_util
} // namespace gns

Fix error in Travic CI

Fix error in Travic CI


/** @example user_touche.cpp
 Touche example.
 */

#include <ESP.h>

BinaryIntArraySerialStream stream(0, 115200, 160);
GestureRecognitionPipeline pipeline;

void setup()
{
    useInputStream(stream);

    pipeline.addFeatureExtractionModule(TimeseriesBuffer(1, 160));
    pipeline.setClassifier(SVM(SVM::POLY_KERNEL, SVM::C_SVC, false, true, true, 0.1, 1.0, 0, 0.5, 2));
    usePipeline(pipeline);
}

/** @example user_touche.cpp
 Touche example.
 */

#include <ESP.h>

BinaryIntArraySerialStream stream(0, 115200, 160);
GestureRecognitionPipeline pipeline;

void setup()
{
    useInputStream(stream);

    pipeline.setClassifier(SVM(SVM::POLY_KERNEL, SVM::C_SVC, false, true, true, 0.1, 1.0, 0, 0.5, 2));
    usePipeline(pipeline);
}

Remove Touche feature extraction module.

It didn’t actually do anything. It was just because we display high
dimensional features as snapshots of a single point in time.


#include "Logger.h"
#include <iostream>

//
// (plesslie)
// posix_time_zone is just parsing the "-XX" portion and subtracting that from UTC meaning
// that it isn't adjusting for daylight savings time.  not sure how to fix that, and I don't
// really care for now.
//
Logger::Logger() : ss_(), tz_(new boost::local_time::posix_time_zone("CST-05")), output_facet_(new boost::local_time::local_time_facet()), input_facet_(new boost::local_time::local_time_input_facet())  {
	ss_.imbue(std::locale(std::locale::classic(), output_facet_));
	ss_.imbue(std::locale(ss_.getloc(), input_facet_));
	output_facet_->format(boost::local_time::local_time_facet::iso_time_format_extended_specifier);
}

Logger::~Logger() {
	delete output_facet_;
	delete input_facet_;
}

Logger& Logger::instance() {
	static Logger logger;
	return logger;
}

#include "Logger.h"
#include <iostream>

//
// (plesslie)
// posix_time_zone is just parsing the "-XX" portion and subtracting that from UTC meaning
// that it isn't adjusting for daylight savings time.  not sure how to fix that, and I don't
// really care for now.
//
Logger::Logger() : ss_(), tz_(new boost::local_time::posix_time_zone("CST-05")), output_facet_(new boost::local_time::local_time_facet()), input_facet_(new boost::local_time::local_time_input_facet())  {
	ss_.imbue(std::locale(std::locale::classic(), output_facet_));
	ss_.imbue(std::locale(ss_.getloc(), input_facet_));
	output_facet_->format(boost::local_time::local_time_facet::iso_time_format_extended_specifier);
}

Logger::~Logger() {
	delete input_facet_;
	delete output_facet_;
}

Logger& Logger::instance() {
	static Logger logger;
	return logger;
}

Fix delete ordering for input/output facets


// PluginHelpers.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "pluginhelpers.h"

////////////////////////////////////////////////////////////////////////////////////////////////

using namespace Abstractspoon::Tdl::PluginHelpers;

////////////////////////////////////////////////////////////////////////////////////////////////

MarshalledString::MarshalledString(String^ str) : m_wszGlobal(NULL)
{
	m_wszGlobal = (LPCWSTR)Marshal::StringToHGlobalUni(str).ToPointer();
}

MarshalledString::~MarshalledString()
{
	Marshal::FreeHGlobal((IntPtr)(void*)m_wszGlobal);
}

MarshalledString::operator LPCWSTR()
{
	return m_wszGlobal;
}

////////////////////////////////////////////////////////////////////////////////////////////////

void DialogUtils::SetFont(System::Windows::Forms::Control^ ctrl, System::Drawing::Font^ font)
{
	ctrl->Font = font;

	SetFont(ctrl->Controls, font);
}

void DialogUtils::SetFont(System::Windows::Forms::Control::ControlCollection^ ctrls, System::Drawing::Font^ font)
{
	int nCtrl = ctrls->Count;

	while (nCtrl--)
		SetFont(ctrls[nCtrl], font); // RECURSIVE CALL
}

////////////////////////////////////////////////////////////////////////////////////////////////

// PluginHelpers.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "pluginhelpers.h"

////////////////////////////////////////////////////////////////////////////////////////////////

using namespace Abstractspoon::Tdl::PluginHelpers;

////////////////////////////////////////////////////////////////////////////////////////////////

class ModuleInitialiser
{
public:
	ModuleInitialiser()
	{
		System::Windows::Forms::Application::SetCompatibleTextRenderingDefault(false);
	}
};

static ModuleInitialiser* _init = new ModuleInitialiser();

////////////////////////////////////////////////////////////////////////////////////////////////

MarshalledString::MarshalledString(String^ str) : m_wszGlobal(NULL)
{
	m_wszGlobal = (LPCWSTR)Marshal::StringToHGlobalUni(str).ToPointer();
}

MarshalledString::~MarshalledString()
{
	Marshal::FreeHGlobal((IntPtr)(void*)m_wszGlobal);
}

MarshalledString::operator LPCWSTR()
{
	return m_wszGlobal;
}

////////////////////////////////////////////////////////////////////////////////////////////////

void DialogUtils::SetFont(System::Windows::Forms::Control^ ctrl, System::Drawing::Font^ font)
{
	ctrl->Font = font;

	SetFont(ctrl->Controls, font);
}

void DialogUtils::SetFont(System::Windows::Forms::Control::ControlCollection^ ctrls, System::Drawing::Font^ font)
{
	int nCtrl = ctrls->Count;

	while (nCtrl--)
		SetFont(ctrls[nCtrl], font); // RECURSIVE CALL
}

////////////////////////////////////////////////////////////////////////////////////////////////

Use legacy font rendering for consistency


/* Copyright 2020 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_lite_support/cc/task/core/error_reporter.h"

#include <cstdarg>
#include <cstdio>
#include <cstring>

#include "tensorflow/lite/minimal_logging.h"

namespace tflite {
namespace task {
namespace core {

int ErrorReporter::Report(const char* format, va_list args) {
  last_message_[0] = '\0';
  int num_characters = vsnprintf(last_message_, kBufferSize, format, args);
  // To mimic tflite::StderrReporter.
  tflite::logging_internal::MinimalLogger::Log(TFLITE_LOG_ERROR, last_message_);
  return num_characters;
}

std::string ErrorReporter::message() { return last_message_; }

}  // namespace core
}  // namespace task
}  // namespace tflite

/* Copyright 2020 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_lite_support/cc/task/core/error_reporter.h"

#include <cstdarg>
#include <cstdio>
#include <cstring>

#include "tensorflow/lite/minimal_logging.h"

namespace tflite {
namespace task {
namespace core {

int ErrorReporter::Report(const char* format, va_list args) {
  last_message_[0] = '\0';
  int num_characters = vsnprintf(last_message_, kBufferSize, format, args);
  // To mimic tflite::StderrReporter.
  tflite::logging_internal::MinimalLogger::Log(TFLITE_LOG_ERROR, "%s",
                                               last_message_);
  return num_characters;
}

std::string ErrorReporter::message() { return last_message_; }

}  // namespace core
}  // namespace task
}  // namespace tflite

Fix bug where it was assuming that error messages won't contain format strings.

It was passing a C string to the tflite::logging_internal::MinimalLogger::Log() function, which takes a format string and arguments, but wasn't using "%s".
As a result, the error message was being interpreted as a format string,
which could have undesirable effects (e.g. crashing) if the error message happens
to contain '%' characters.

PiperOrigin-RevId: 365769953


#include <stdlib.h>
#include <string>

// include the sql parser
#include "SQLParser.h"

// contains printing utilities
#include "sqlhelper.h"

int main(int argc, char *argv[]) {
    if (argc <= 1) {
        fprintf(stderr, "Usage: ./example \"SELECT * FROM test;\"\n");
        return -1;
    }
    std::string query = argv[1];

    // parse a given query
    hsql::SQLParserResult* result = hsql::SQLParser::parseSQLString(query);

    // check whether the parsing was successful
    if (result->isValid()) {
        printf("Parsed successfully!\n");
        printf("Number of statements: %lu\n", result->size());

        for (uint i = 0; i < result->size(); ++i) {
            // Print a statement summary.
            hsql::printStatementInfo(result->getStatement(i));
        }

        delete result;
        return 0;
    } else {
        fprintf(stderr, "Given string is not a valid SQL query.\n");
        fprintf(stderr, "%s (L%d:%d)\n",
                result->errorMsg(),
                result->errorLine(),
                result->errorColumn());
        delete result;
        return -1;
    }
}

#include <stdlib.h>
#include <string>

// include the sql parser
#include "SQLParser.h"

// contains printing utilities
#include "sqlhelper.h"

int main(int argc, char *argv[]) {
    if (argc <= 1) {
        fprintf(stderr, "Usage: ./example \"SELECT * FROM test;\"\n");
        return -1;
    }
    std::string query = argv[1];

    // parse a given query
    hsql::SQLParserResult* result = hsql::SQLParser::parseSQLString(query);

    // check whether the parsing was successful
    if (!result) {
        return -1;
    }

    if (result->isValid()) {
        printf("Parsed successfully!\n");
        printf("Number of statements: %lu\n", result->size());

        for (uint i = 0; i < result->size(); ++i) {
            // Print a statement summary.
            hsql::printStatementInfo(result->getStatement(i));
        }

        delete result;
        return 0;
    } else {
        fprintf(stderr, "Given string is not a valid SQL query.\n");
        fprintf(stderr, "%s (L%d:%d)\n",
                result->errorMsg(),
                result->errorLine(),
                result->errorColumn());
        delete result;
        return -1;
    }
}

Check NULL value of result.

Check NULL value of result.


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

#include "../client/gles2_lib.h"
#include "../common/thread_local.h"

namespace gles2 {
namespace {
gpu::ThreadLocalKey g_gl_context_key;
}  // namespace anonymous

void Initialize() {
  g_gl_context_key = gpu::ThreadLocalAlloc();
}

void Terminate() {
  gpu::ThreadLocalFree(g_gl_context_key);
  g_gl_context_key = 0;
}

gpu::gles2::GLES2Implementation* GetGLContext() {
  return static_cast<gpu::gles2::GLES2Implementation*>(
    gpu::ThreadLocalGetValue(g_gl_context_key));
}

void SetGLContext(gpu::gles2::GLES2Implementation* context) {
  gpu::ThreadLocalSetValue(g_gl_context_key, context);
}
}  // namespace gles2

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

#include "../client/gles2_lib.h"
#include "../common/thread_local.h"

namespace gles2 {
// TODO(kbr): the use of this anonymous namespace core dumps the
// linker on Mac OS X 10.6 when the symbol ordering file is used
// namespace {
static gpu::ThreadLocalKey g_gl_context_key;
// }  // namespace anonymous

void Initialize() {
  g_gl_context_key = gpu::ThreadLocalAlloc();
}

void Terminate() {
  gpu::ThreadLocalFree(g_gl_context_key);
  g_gl_context_key = 0;
}

gpu::gles2::GLES2Implementation* GetGLContext() {
  return static_cast<gpu::gles2::GLES2Implementation*>(
    gpu::ThreadLocalGetValue(g_gl_context_key));
}

void SetGLContext(gpu::gles2::GLES2Implementation* context) {
  gpu::ThreadLocalSetValue(g_gl_context_key, context);
}
}  // namespace gles2

Work around bug in gcc's name mangling causing linker to crash on Mac
OS X.

BUG=40845
TEST=none
TBR=gman

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

git-svn-id: http://src.chromium.org/svn/trunk/src@47225 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: ae8adbcc1f483d676036368d627f4a464561a2df


// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// 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 <service>

extern "C" __attribute__((noreturn))
void panic(const char* reason);

__attribute__((noreturn))
extern "C" void abort(){
  panic("Abort called");
}

const char* service_name__ = SERVICE_NAME;
const char* service_binary_name__ = SERVICE;

// This file is a part of the IncludeOS unikernel - www.includeos.org
//
// Copyright 2015 Oslo and Akershus University College of Applied Sciences
// and Alfred Bratterud
//
// 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 <service>

extern "C" __attribute__((noreturn))
void panic(const char* reason);

extern "C" __attribute__((noreturn))
void abort(){
  panic("Abort called");
}

const char* service_name__ = SERVICE_NAME;
const char* service_binary_name__ = SERVICE;

Fix compile error when using test_ukvm.sh

Moved `extern "C"` to correct location. Otherwise, when executing `./test_ukvm.sh` the following compile error is generated:
```
includeos/src/service_name.cpp:24:8: error: expected unqualified-id before string constant
 extern "C"
        ^
```


Return update ever 50 ms (if idle)

Return update ever 50 ms (if idle)


//C++ header - Open Scene Graph Simulation - Copyright (C) 1998-2002 Robert Osfield
// Distributed under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation.
//
// All software using osgSim must be GPL'd or excempted via the
// purchase of the Open Scene Graph Professional License (OSGPL)
// for further information contact robert@openscenegraph.com.

#include <osgSim/BlinkSequence>

#include <stdlib.h>

using namespace osgSim;

BlinkSequence::BlinkSequence():
    Referenced(),
    _pulsePeriod(0.0),
    _phaseShift(0.0),
    _pulseData(),
    _sequenceGroup(0) {}

BlinkSequence::BlinkSequence(const BlinkSequence& bs):
    Referenced(),
    _pulsePeriod(bs._pulsePeriod),
    _phaseShift(bs._phaseShift),
    _pulseData(bs._pulseData),
    _sequenceGroup(bs._sequenceGroup) {}

BlinkSequence::SequenceGroup::SequenceGroup():
    Referenced()
{
    // set a random base time between 0 and 1000.0
    _baseTime = ((double)rand()/(double)RAND_MAX)*1000.0;
}

BlinkSequence::SequenceGroup::SequenceGroup(double baseTime):
    Referenced(),
    _baseTime(baseTime) {}

//C++ header - Open Scene Graph Simulation - Copyright (C) 1998-2002 Robert Osfield
// Distributed under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation.
//
// All software using osgSim must be GPL'd or excempted via the
// purchase of the Open Scene Graph Professional License (OSGPL)
// for further information contact robert@openscenegraph.com.

#include <osgSim/BlinkSequence>

#include <stdlib.h>

using namespace osgSim;

BlinkSequence::BlinkSequence():
    _pulsePeriod(0.0),
    _phaseShift(0.0),
    _pulseData(),
    _sequenceGroup(0)
{
}

BlinkSequence::BlinkSequence(const BlinkSequence& bs):
    _pulsePeriod(bs._pulsePeriod),
    _phaseShift(bs._phaseShift),
    _pulseData(bs._pulseData),
    _sequenceGroup(bs._sequenceGroup)
{
}

BlinkSequence::SequenceGroup::SequenceGroup()
{
    // set a random base time between 0 and 1000.0
    _baseTime = ((double)rand()/(double)RAND_MAX)*1000.0;
}

BlinkSequence::SequenceGroup::SequenceGroup(double baseTime):
    _baseTime(baseTime)
{
}

Fix for compile problems under IRIX.

Fix for compile problems under IRIX.


#include "runtime_internal.h"

#ifdef BITS_64
#define WIN32API
#else
#define WIN32API __stdcall
#endif

extern "C" {

WIN32API void *LoadLibrary(const char *);
WIN32API void *GetProcAddress(void *, const char *);

WEAK void *halide_get_symbol(const char *name) {
    return GetProcAddress(NULL, name);
}

WEAK void *halide_load_library(const char *name) {
    return LoadLibrary(name);
}

WEAK void *halide_get_library_symbol(void *lib, const char *name) {
    return GetProcAddress(lib, name);
}

}

#include "runtime_internal.h"

#ifdef BITS_64
#define WIN32API
#else
#define WIN32API __stdcall
#endif

extern "C" {

WIN32API void *LoadLibraryA(const char *);
WIN32API void *GetProcAddress(void *, const char *);

WEAK void *halide_get_symbol(const char *name) {
    return GetProcAddress(NULL, name);
}

WEAK void *halide_load_library(const char *name) {
    return LoadLibraryA(name);
}

WEAK void *halide_get_library_symbol(void *lib, const char *name) {
    return GetProcAddress(lib, name);
}

}

Fix missing LoadLibrary symbol on windows.


#include "FileOperations.h"
#include <QFile>
#include <QtGlobal>

template <class InputIterator1, class InputIterator2>
bool FileOperations::equal(InputIterator1 first1, InputIterator1 last1,
                           InputIterator2 first2, InputIterator2 last2) {
  while ((first1 != last1) && (first2 != last2)) {
    if (*first1 != *first2) {
      return false;
    }

    ++first1;
    ++first2;
  }

  return (first1 == last1) && (first2 == last2);
}

bool FileOperations::filesEqual(const QString& filePath1,
                                const QString& filePath2) {
  bool equivalent = false;

  QFile file1(filePath1);
  QFile file2(filePath2);

  if (file1.exists() && file2.exists()) {
    file1.open(QFile::ReadOnly);
    uchar* fileMemory1 = file1.map(0, file1.size());

    file2.open(QFile::ReadOnly);
    uchar* fileMemory2 = file2.map(0, file2.size());

    equivalent = equal(fileMemory1, fileMemory1 + file1.size(),
                       fileMemory2, fileMemory2 + file2.size());
  }

  return equivalent;
}

#include "FileOperations.h"
#include <QFile>
#include <QtGlobal>

bool FileOperations::filesEqual(const QString& filePath1,
                                const QString& filePath2) {
  bool equivalent = false;

  QFile file1(filePath1);
  QFile file2(filePath2);

  if (file1.exists() && file2.exists()) {
    file1.open(QFile::ReadOnly);
    file2.open(QFile::ReadOnly);

    while (!file1.atEnd()) {
      QByteArray file1Buffer;

      const qint64 file1BytesRead = file1.read(file1Buffer.data(), 16384);

      if (-1 == file1BytesRead) {
        break;
      }

      QByteArray file2Buffer;

      const qint64 file2BytesRead = file2.read(file2Buffer.data(), 16384);

      if (-1 == file1BytesRead) {
        break;
      }

      if (file1Buffer != file2Buffer) {
        break;
      }

      if (file1.atEnd() && !file2.atEnd()) {
        break;
      }

      if (file1.atEnd() && file2.atEnd()) {
        equivalent = true;
      }
    }
  }

  return equivalent;
}

Use QFile to do file comparison

Use QFile to do file comparison


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

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

#if defined(TOOLKIT_VIEWS)
// Need to port ExtensionInfoBarDelegate::CreateInfoBar() to other platforms.
// See http://crbug.com/39916 for details.
#define MAYBE_GetViews GetViews
#else
#define MAYBE_GetViews DISABLED_GetViews
#endif

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_GetViews) {
  // TODO(finnur): Remove once infobars are no longer experimental (bug 39511).
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("get_views")) << message_;
}

// 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/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, GetViews) {
  // TODO(finnur): Remove once infobars are no longer experimental (bug 39511).
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("get_views")) << message_;
}

Enable ExtensionApiTest.GetViews on all platforms.

BUG=none
TEST=passes everywhere

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

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


/*
 * Copyright (C) 2009, Gostai S.A.S.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

/// \file libuco/urbi-main.cc

#include <libport/cli.hh>
#include <libport/containers.hh>
#include <urbi/umain.hh>

extern "C"
{
  int urbi_main(int argc, const char* argv[],
                bool block, bool errors)
  {
    return urbi::main(argc, argv, block, errors);
  }

  int urbi_main_args(const libport::cli_args_type& args,
                     bool block, bool errors)
  {
    return urbi::main(args, block, errors);
  }
}

namespace urbi
{

  int
  main(int argc, const char* argv[], bool block, bool errors)
  {
    libport::cli_args_type args;
    // For some reason, I failed to use std::copy here.
    for (int i = 0; i < argc; ++i)
      args << std::string(argv[i]);
    return main(args, block, errors);
  }

}

/*
 * Copyright (C) 2009, Gostai S.A.S.
 *
 * This software is provided "as is" without warranty of any kind,
 * either expressed or implied, including but not limited to the
 * implied warranties of fitness for a particular purpose.
 *
 * See the LICENSE file for more information.
 */

/// \file libuco/urbi-main.cc

#include <libport/cli.hh>
#include <libport/containers.hh>
#include <urbi/umain.hh>

extern "C"
{
  int urbi_main(int argc, const char* argv[],
                bool block, bool errors)
  {
    libport::program_initialize(argc, const_cast<char**>(argv));

    return urbi::main(argc, argv, block, errors);
  }

  int urbi_main_args(const libport::cli_args_type& args,
                     bool block, bool errors)
  {
    libport::program_initialize(args);

    return urbi::main(args, block, errors);
  }
}

namespace urbi
{

  int
  main(int argc, const char* argv[], bool block, bool errors)
  {
    libport::program_initialize(argc, const_cast<char**>(argv));

    libport::cli_args_type args;
    // For some reason, I failed to use std::copy here.
    for (int i = 0; i < argc; ++i)
      args << std::string(argv[i]);
    return main(args, block, errors);
  }

}

Call libport::program_initialize in every entry point.

	* src/libuco/urbi-main.cc: Here.


#include "gpio.h"
#include "nvic.h"
#include "driver/timer.hpp"

extern "C" void __cxa_pure_virtual() {
    while (1);
}

namespace {

int counter = 0;

void toggle_leds() {
    ++counter;

    auto gpio_n = 17 + (counter & 3);
    gpio_toggle(0, (1 << gpio_n));
}

}

int main(void) {
    nvic_init();

    auto* rtc = driver::Timer::get_by_id(driver::Timer::ID::RTC0);

    rtc->set_prescaler(0xfff - 1);
    rtc->set_irq_handler(toggle_leds);
    rtc->enable_tick_interrupt();
    rtc->start();

    while (1);
}

#include "gpio.h"
#include "nvic.h"
#include "driver/timer.hpp"

#include "memio.h"

namespace {

int counter = 0;

void toggle_leds(int) {
    auto gpio_n = 17 + (counter++ & 3);
    gpio_toggle(0, (1 << gpio_n));
}

}

int main(void) {
    nvic_init();

    gpio_set_option(0, (1 << 17) | (1 << 18) | (1 << 19) | (1 << 20), GPIO_OPT_OUTPUT);

    auto* rtc = driver::Timer::get_by_id(driver::Timer::ID::RTC0);

    rtc->stop();
    rtc->set_prescaler(0xffd);
    rtc->add_event_handler(0, toggle_leds);
    rtc->enable_tick_interrupt();
    rtc->start();

    while (1);
}

Use new API in rtc-blinker app

Use new API in rtc-blinker app

The rtc-blinker app now uses new event API for RTC and also
new API for GPIO.


// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s

template<typename... Types> struct Tuple;

// FIXME: Many more bullets to go

// In a template-argument-list (14.3); the pattern is a template-argument.
template<typename ...Types>
struct tuple_of_refs {
  typedef Tuple<Types& ...> types;
};

Tuple<int&, float&> *t_int_ref_float_ref;
tuple_of_refs<int&, float&>::types *t_int_ref_float_ref_2 =  t_int_ref_float_ref;

// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s

template<typename... Types> struct tuple;

// FIXME: Many more bullets to go

// In a template-argument-list (14.3); the pattern is a template-argument.
template<typename ...Types>
struct tuple_of_refs {
  typedef tuple<Types& ...> types;
};

tuple<int&, float&> *t_int_ref_float_ref;
tuple_of_refs<int&, float&>::types *t_int_ref_float_ref_2 =  t_int_ref_float_ref;

template<typename ...Types>
struct extract_nested_types {
  typedef tuple<typename Types::type...> types;
};

template<typename T>
struct identity {
  typedef T type;
};

tuple<int, float> *t_int_float;
extract_nested_types<identity<int>, identity<float> >::types *t_int_float_2
  = t_int_float;

Test template instantiation of pack expansions where the parameter pack is in a nested-name-specifier

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


#include <iostream>
#include <limits.h>
#include <thread>
#include <unistd.h>

int main() {
    char name[_POSIX_HOST_NAME_MAX + 1];
    gethostname(name, sizeof(name));
    std::cout << "Host name: " << name << std::endl;

    unsigned int cores = std::thread::hardware_concurrency();
    std::cout << "Total cores: " << cores << std::endl;

    return 0;
}

#include <iostream>
#include <limits.h>
#include <thread>

int main() {
    unsigned int cores = std::thread::hardware_concurrency();
    std::cout << "Total cores: " << cores << std::endl;

    return 0;
}

Fix Windows build issues by removing posix only code.


#include "Uniforms.h"

namespace ion
{
	namespace Graphics
	{

		template <>
		EValueType IUniformTyped<float>::GetType() const
		{
			return EValueType::Float;
		}

		template <>
		EValueType IUniformTyped<vec2f>::GetType() const
		{
			return EValueType::Float2;
		}

		template <>
		EValueType IUniformTyped<vec3f>::GetType() const
		{
			return EValueType::Float3;
		}

		template <>
		EValueType IUniformTyped<vec4f>::GetType() const
		{
			return EValueType::Float4;
		}

		template <>
		EValueType IUniformTyped<color3f>::GetType() const
		{
			return EValueType::Float3;
		}

		template <>
		EValueType IUniformTyped<color4f>::GetType() const
		{
			return EValueType::Float4;
		}

		template <>
		EValueType IUniformTyped<glm::mat4>::GetType() const
		{
			return EValueType::Matrix4x4;
		}

		template <>
		EValueType IUniformTyped<int>::GetType() const
		{
			return EValueType::SignedInt32;
		}

	}
}

#include "Uniforms.h"

namespace ion
{
	namespace Graphics
	{

		template <>
		EValueType IUniformTyped<float>::GetType() const
		{
			return EValueType::Float;
		}

		template <>
		EValueType IUniformTyped<vec2f>::GetType() const
		{
			return EValueType::Float2;
		}

		template <>
		EValueType IUniformTyped<vec3f>::GetType() const
		{
			return EValueType::Float3;
		}

		template <>
		EValueType IUniformTyped<vec4f>::GetType() const
		{
			return EValueType::Float4;
		}

		template <>
		EValueType IUniformTyped<color3f>::GetType() const
		{
			return EValueType::Float3;
		}

		template <>
		EValueType IUniformTyped<color4f>::GetType() const
		{
			return EValueType::Float4;
		}

		template <>
		EValueType IUniformTyped<glm::mat4>::GetType() const
		{
			return EValueType::Matrix4x4;
		}

		template <>
		EValueType IUniformTyped<int>::GetType() const
		{
			return EValueType::SignedInt32;
		}

		template <>
		EValueType IUniformTyped<uint>::GetType() const
		{
			return EValueType::UnsignedInt32;
		}

	}
}

Add support for uint uniforms

Add support for uint uniforms


#include <legato.h>
#include <thread>
#include <string>
#include <list>
#include <iostream>

#ifndef MUST_BE_DEFINED
#error MUST_BE_DEFINED was not defined.
#endif

COMPONENT_INIT
{
    LE_INFO("Hello world, from thread 1.");

    std::thread newThread([]()
        {
            le_thread_InitLegatoThreadData("thread 2");

            // This will crash if the Legato thread-specific data has not been initialized.
            le_thread_GetCurrent();

            LE_INFO("Hello world, from %s.", le_thread_GetMyName());

            le_thread_CleanupLegatoThreadData();
        });

    LE_INFO("Thead 2 stared, and waiting for it to complete.");
    newThread.join();

    LE_INFO("Thead 2 ended, all done with init.");

    std::list<std::string> stuff;

    // C++ 11
    for (auto s : stuff)
    {
        std::cout << "stuff: " << s << std::endl;
    }

    exit(EXIT_SUCCESS);
}

#include <legato.h>
#include <thread>
#include <string>
#include <list>
#include <iostream>

#ifndef MUST_BE_DEFINED
#error MUST_BE_DEFINED was not defined.
#endif

COMPONENT_INIT
{
    LE_INFO("Hello world, from thread 1.");

    std::thread newThread([]()
        {
            le_thread_InitLegatoThreadData("thread 2");

            // This will crash if the Legato thread-specific data has not been initialized.
            le_thread_GetCurrent();

            LE_INFO("Hello world, from %s.", le_thread_GetMyName());

            le_thread_CleanupLegatoThreadData();
        });

    LE_INFO("Thead 2 stared, and waiting for it to complete.");
    newThread.join();

    LE_INFO("Thead 2 ended, all done with init.");

    std::list<std::string> stuff;

    // C++ 11
    for (auto const &s : stuff)
    {
        std::cout << "stuff: " << s << std::endl;
    }

    exit(EXIT_SUCCESS);
}

Fix klocwork issues with uninitialized variables in the "apps" module.

Resolves: LE-9400
Change-Id: I4500613cf3d1f7f849b3f0b74ca6f5b3485757c3


#include "HM3Pointers.h"

HM3Pointers::HM3Pointers(HM3Version version)
{
	Setup(version);
}

HM3Pointers::~HM3Pointers()
{

}

void HM3Pointers::Setup(HM3Version version)
{
	uint8_t** difficultyPtr = nullptr;
	uint8_t** timePtr = nullptr;
	switch (version)
	{
	case HM3_GOG:
		m_Stats = (HM3Stats*)0x009B3B38;
		difficultyPtr = (uint8_t**)0x0082083C;
		timePtr = (uint8_t**)0x00820820;
		break;
	case HM3_STEAM:
		m_Stats = (HM3Stats*)0x009B2538;
		difficultyPtr = (uint8_t**)0x0081F83C;
		timePtr = (uint8_t**)0x0081F820;
		break;
	case HM3_UNKNOWN:
		m_Stats = nullptr;
		break;
	}

	m_Difficulty = difficultyPtr != nullptr ? *difficultyPtr + 0x6664 : nullptr;
	m_Time = timePtr != nullptr ? *timePtr + 0x48 : nullptr;
}

#include "HM3Pointers.h"

struct DataAddresses
{
	uint32_t Stats;
	uint32_t DifficultyPtr;
	uint32_t TimePtr;
};

static const DataAddresses DataVersions[]
{
	{ 0x00000000, 0x00000000, 0x00000000 }, // Unknown version
	{ 0x009B2538, 0x0081F83C, 0x0081F820 }, // Steam
	{ 0x009B3B38, 0x0082083C, 0x00820820 }  // GOG
};

HM3Pointers::HM3Pointers(HM3Version version)
{
	Setup(version);
}

HM3Pointers::~HM3Pointers()
{

}

void HM3Pointers::Setup(HM3Version version)
{
	const DataAddresses& addresses(DataVersions[version]);

	m_Stats = (HM3Stats*)addresses.Stats;
	uint8_t** difficultyPtr = (uint8_t**)addresses.DifficultyPtr;
	uint8_t** timePtr = (uint8_t**)addresses.TimePtr;

	m_Difficulty = difficultyPtr != nullptr ? *difficultyPtr + 0x6664 : nullptr;
	m_Time = timePtr != nullptr ? *timePtr + 0x48 : nullptr;
}

Improve structure of encoding different version addresses


//
// Copyright (c) 2018 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

#include "nf_networking_sntp.h"

static const CLR_RT_MethodHandler method_lookup[] =
{
    NULL,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::Start___STATIC__VOID,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::Stop___STATIC__VOID,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::UpdateNow___STATIC__VOID,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::get_IsStarted___STATIC__BOOLEAN,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::get_Server1___STATIC__STRING,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::set_Server1___STATIC__VOID__STRING,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::get_Server2___STATIC__STRING,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::set_Server2___STATIC__VOID__STRING,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Networking_Sntp =
{
    "nanoFramework.Networking.Sntp",
    0x733B4551,
    method_lookup,
    { 1, 0, 2, 48 }
};

//
// Copyright (c) 2018 The nanoFramework project contributors
// See LICENSE file in the project root for full license information.
//

#include "nf_networking_sntp.h"

static const CLR_RT_MethodHandler method_lookup[] =
{
    NULL,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::Start___STATIC__VOID,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::Stop___STATIC__VOID,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::UpdateNow___STATIC__VOID,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::get_IsStarted___STATIC__BOOLEAN,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::get_Server1___STATIC__STRING,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::set_Server1___STATIC__VOID__STRING,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::get_Server2___STATIC__STRING,
    Library_nf_networking_sntp_nanoFramework_Networking_Sntp::set_Server2___STATIC__VOID__STRING,
};

const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_Networking_Sntp =
{
    "nanoFramework.Networking.Sntp",
    0x733B4551,
    method_lookup,
    { 1, 0, 2, 49 }
};

Update nanoFramework.Networking.Sntp version to 1.0.2-preview-049 ***NO_CI***


#include "Script.hpp"

using namespace Component;

Script::Script(Entity* entity) : SuperComponent(entity) {

}

Json::Value Script::Save() const {
    Json::Value component;
    return component;
}

void Script::Load(const Json::Value& node) {

}

#include "Script.hpp"

using namespace Component;

Script::Script(Entity* entity) : SuperComponent(entity) {

}

Json::Value Script::Save() const {
    Json::Value component;
    component["placeholderValue"] = "";
    return component;
}

void Script::Load(const Json::Value& node) {

}

Add placeholder value to script component


#include "Isosurface.h"

Vector3D Isosurface::gradientAt(float x, float y, float z) const
{
    const float epsilon = 0.0001;

    float dx = valueAt(x + epsilon, y, z) - valueAt(x - epsilon, y, z);
    float dy = valueAt(x, y + epsilon, z) - valueAt(x, y - epsilon, z);
    float dz = valueAt(x, y, z + epsilon) - valueAt(x, y, z - epsilon);

    Vector3D result = { dx, dy, dz };
    normalize(result);
    return result;
}

Isosurface::~Isosurface() {
}

Fix a brace style inconsistency

Fix a brace style inconsistency


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

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents1) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation1")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents2) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation2")) << message_;
}

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

#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigation) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/api")) << message_;
}

// Disabled, flakily exceeds timeout, http://crbug.com/72165.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WebNavigationEvents1) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation1")) << message_;
}

IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationEvents2) {
  CommandLine::ForCurrentProcess()->AppendSwitch(
      switches::kEnableExperimentalExtensionApis);

  ASSERT_TRUE(RunExtensionTest("webnavigation/navigation2")) << message_;
}

Disable ExtensionApiTest.WebNavigationEvents1, flakily exceeds test timeout

TBR=jochen

BUG=72165
TEST=browser_tests
Review URL: http://codereview.chromium.org/6286142

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


#include "mettle.hpp"
using namespace mettle;

suite<suites_list> test_suite("test suite", [](auto &_) {

  _.test("create a test suite", [](suites_list &suites) {
    suite<> inner("inner test suite", [](auto &_){
      _.test("inner test", []() {});
    }, suites);

    expect(suites, array(&inner));
  });

  _.test("create a test suite with fixture", [](suites_list &suites) {
    suite<int> inner("inner test suite", [](auto &_){
      _.test("inner test", [](int &) {});
    }, suites);

    expect(suites, array(&inner));
  });

});

#include "mettle.hpp"
using namespace mettle;

suite<suites_list> test_suite("test suite", [](auto &_) {

  _.test("create a test suite", [](suites_list &suites) {
    suite<> inner("inner test suite", [](auto &_){
      _.test("inner test", []() {});
    }, suites);

    expect(suites, array(&inner));
  });

  _.test("create a test suite with fixture", [](suites_list &suites) {
    suite<int> inner("inner test suite", [](auto &_){
      _.test("inner test", [](int &) {});
    }, suites);

    expect(suites, array(&inner));
  });

  _.test("create a test suite that throws", [](suites_list &suites) {
    try {
      suite<int> inner("broken test suite", [](auto &){
        throw "bad";
      }, suites);
    } catch(...) {}

    expect(suites, array());
  });

});

Test that test suites with broken initializers don't get added to the list of suites


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

#include "content/renderer/scheduler/renderer_scheduler.h"

#include "base/command_line.h"
#include "base/message_loop/message_loop_proxy.h"
#include "content/public/common/content_switches.h"
#include "content/renderer/scheduler/null_renderer_scheduler.h"
#include "content/renderer/scheduler/renderer_scheduler_impl.h"

namespace content {

RendererScheduler::RendererScheduler() {
}

RendererScheduler::~RendererScheduler() {
}

// static
scoped_ptr<RendererScheduler> RendererScheduler::Create() {
  CommandLine* command_line = base::CommandLine::ForCurrentProcess();
  if (command_line->HasSwitch(switches::kDisableBlinkScheduler)) {
    return make_scoped_ptr(new NullRendererScheduler());
  } else {
    return make_scoped_ptr(
        new RendererSchedulerImpl(base::MessageLoopProxy::current()));
  }
}

}  // namespace content

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

#include "content/renderer/scheduler/renderer_scheduler.h"

#include "content/renderer/scheduler/null_renderer_scheduler.h"

namespace content {

RendererScheduler::RendererScheduler() {
}

RendererScheduler::~RendererScheduler() {
}

// static
scoped_ptr<RendererScheduler> RendererScheduler::Create() {
  // TODO(rmcilroy): Use the RendererSchedulerImpl when the scheduler is enabled
  return make_scoped_ptr(new NullRendererScheduler());
}

}  // namespace content

Revert "content: Enable the RendererScheduler by default."

This reverts commit ddff43275d41109c2acb07aa6dd52e114bafca11.

Speculative revert to see if it fixes Debug layout test failures:
inspector/console/console-format.html
http/tests/appcache/fallback.html
e.g., http://build.chromium.org/p/chromium.webkit/builders/WebKit%20Linux%20(dbg)/builds/23616

TBR=rmcilroy
BUG=391005

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

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


/*
    Copyright Sven Bergström 2014
    created for snow https://github.com/underscorediscovery/snow
    MIT license
*/

#ifdef HX_WINDOWS

#include <windows.h>
#include "SDL.h"
#include "SDL_syswm.h"

namespace snow {
    namespace platform {
        namespace window {

            void load_icon(SDL_Window* _window) {

                SDL_SysWMinfo wminfo;
                SDL_VERSION(&wminfo.version)
                if (SDL_GetWindowWMInfo(_window,&wminfo)) {

                	HINSTANCE handle = ::GetModuleHandle(NULL);
                	HWND hwnd = wminfo.info.win.window;
                	HICON icon = ::LoadIcon(handle, "IDI_MAIN_ICON");

                	::SetClassLong(hwnd, GCL_HICON, (LONG) icon);
                }

            } //load_icon

        } //window
    } //platform namespace
} //snow namespace

#endif //HX_WINDOWS

/*
    Copyright Sven Bergström 2014
    created for snow https://github.com/underscorediscovery/snow
    MIT license
*/

#ifdef HX_WINDOWS

#include <windows.h>
#include "SDL.h"
#include "SDL_syswm.h"

namespace snow {
    namespace platform {
        namespace window {

            void load_icon(SDL_Window* _window) {

                SDL_SysWMinfo wminfo;
                SDL_VERSION(&wminfo.version)
                if (SDL_GetWindowWMInfo(_window,&wminfo)) {

                	HINSTANCE handle = ::GetModuleHandle(NULL);
                	HWND hwnd = wminfo.info.win.window;
                	HICON icon = ::LoadIcon(handle, "IDI_MAIN_ICON");

                	::SetClassLong(hwnd, GCLP_HICON, (LONG) icon);
                }

            } //load_icon

        } //window
    } //platform namespace
} //snow namespace

#endif //HX_WINDOWS

Fix msvc windows 64 build; Add windows 64 bit prebuilt lib


// Copyright 2019 The Marl Authors
//
// 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
//
//     https://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 "marl/blockingcall.h"

#include "marl/defer.h"

#include "marl_test.h"

#include <mutex>

TEST_P(WithBoundScheduler, BlockingCall) {
  auto mutex = std::make_shared<std::mutex>();
  mutex->lock();

  marl::WaitGroup wg(100);
  for (int i = 0; i < 100; i++) {
    marl::schedule([=] {
      defer(wg.done());
      marl::blocking_call([=] {
        mutex->lock();
        defer(mutex->unlock());
      });
    });
  }

  marl::schedule([=] { mutex->unlock(); });
  wg.wait();
}

// Copyright 2019 The Marl Authors
//
// 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
//
//     https://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 "marl/blockingcall.h"

#include "marl/defer.h"

#include "marl_test.h"

#include <mutex>

TEST_P(WithBoundScheduler, BlockingCall) {
  auto mutex = std::make_shared<std::mutex>();
  mutex->lock();

  marl::WaitGroup wg(100);
  for (int i = 0; i < 100; i++) {
    marl::schedule([=] {
      defer(wg.done());
      marl::blocking_call([=] {
        mutex->lock();
        defer(mutex->unlock());
      });
    });
  }

  mutex->unlock();
  wg.wait();
}

Fix TSAN issue with BlockingCall test.

Fix TSAN issue with BlockingCall test.

The mutex was being unlocked on the a different thread, causing TSAN upset.


//============================================================================
// Name        : TimeSeriesStatisticsDemo.cpp
// Author      : Dominik Skoda <skoda@d3s.mff.cuni.cz>
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdlib>
#include "TimeSeries.h"
#include "StudentsDistribution.h"

using namespace std;

int main() {
	cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!

	TimeSeries<10000,1000> s;
	for(size_t i = 0; i < 20; ++i){
		s.addSample(i%5, i*300);
	}
	StudentsDistribution d = s.getMean();

	cout << d.isLessThan(2, 0.95) << endl;

	return 0;
}

//============================================================================
// Name        : TimeSeriesStatisticsDemo.cpp
// Author      : Dominik Skoda <skoda@d3s.mff.cuni.cz>
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdlib>
#include "TimeSeries.h"
#include "StudentsDistribution.h"
#include "TDistribution.h"

using namespace std;

int main() {
	cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!

	TimeSeries<10000,1000> s;
	for(size_t i = 0; i < 20; ++i){
		s.addSample(i%5, i*300);
	}
	StudentsDistribution d = s.getMean();

	cout << d.isLessThan(2, 0.95) << endl;

	TDistribution td;
	int err;
	for(size_t i = 0; i < 100; ++i){
		double t = td.tnc(0.975, i, 0, &err);
		if(err){
			cout << "err " << err << endl;
		}
		cout << t << endl;
	}

	return 0;
}

Test of the tnc function.

Test of the tnc function.


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

// UNSUPPORTED: c++98, c++03, c++11, c++14

// aligned allocation functions are not provided prior to macosx10.13
// XFAIL: macosx10.12
// XFAIL: macosx10.11
// XFAIL: macosx10.10
// XFAIL: macosx10.9
// XFAIL: macosx10.8
// XFAIL: macosx10.7

#include <new>

#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
#   error "libc++ should have aligned allocation in C++17 and up when targeting a platform that supports it"
#endif

int main() { }

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

// UNSUPPORTED: c++98, c++03, c++11, c++14

// aligned allocation functions are not provided prior to macosx10.13
// UNSUPPORTED: macosx10.12
// UNSUPPORTED: macosx10.11
// UNSUPPORTED: macosx10.10
// UNSUPPORTED: macosx10.9
// UNSUPPORTED: macosx10.8
// UNSUPPORTED: macosx10.7

#include <new>

#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION
#   error "libc++ should have aligned allocation in C++17 and up when targeting a platform that supports it"
#endif

int main() { }

Disable the aligned allocation test on old mac versions instead of XFAILing it

It looks like this test XPASSes when the deployment target is older than
the OS of the system the test is running on. It looks like we run the
tests with -mmacosx-version-min=10.12, and that makes the test expect to
fail, but it passes.

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@340427 91177308-0d34-0410-b5e6-96231b3b80d8


#include "application.h"
#include "mainwindow.h"

#include <QApplication>
#include <QMainWindow>

int main(int argc, char *argv[])
{
//    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication app(argc, argv);
    app.setOrganizationName("lpd8-editor");
    app.setApplicationName("lpd8-editor");
    app.setApplicationVersion("0.0.0");

    Application application;

    MainWindow win(&application);
    win.show();

//    Application app;

    return app.exec();
}

#include "application.h"
#include "mainwindow.h"

#include <QApplication>
#include <QMainWindow>

int main(int argc, char *argv[])
{
#if QT_VERSION >= 0x050600
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
    QApplication app(argc, argv);
    app.setOrganizationName("lpd8-editor");
    app.setApplicationName("lpd8-editor");
    app.setApplicationVersion("0.0.0");

    Application application;

    MainWindow win(&application);
    win.show();

    return app.exec();
}

Enable HiDPI rendering if supported

Enable HiDPI rendering if supported


/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

#include "../lib.hh"
#include "catch.hpp"

using namespace vick;
using vick::move::mvcol;

TEST_CASE("mvcol", "[mvcol]") {
    contents contents({"asert"});

    visual_setup _;
    mvcol(contents, 3);
    CHECK(contents.y == 0);
    CHECK(contents.x == 3);

    mvcol(contents, 10); // doesn't do anything
    CHECK(contents.y == 0);
    CHECK(contents.y == 0);

    mvcol(contents, 0);
    CHECK(contents.y == 0);
    CHECK(contents.x == 0);
}

/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

#include "../lib.hh"
#include "catch.hpp"

using namespace vick;
using vick::move::mvcol;

TEST_CASE("mvcol", "[mvcol]") {
    contents contents({"asert"});

    visual_setup _;
    mvcol(contents, 3);
    CHECK(contents.y == 0);
    CHECK(contents.x == 3);

    mvcol(contents, 10); // doesn't do anything
    CHECK(contents.y == 0);
    CHECK(contents.x == 3);

    mvcol(contents, 0);
    CHECK(contents.y == 0);
    CHECK(contents.x == 0);
}

Fix testing same condition twice (copy paste)


// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify

namespace ExplicitConv {
  struct X { }; // expected-note 2{{candidate constructor}}

  struct Y {
    explicit operator X() const;
  };

  void test(const Y& y) {
    X x(static_cast<X>(y));
    X x2((X)y);
    X x3 = y; // expected-error{{no viable conversion from 'const ExplicitConv::Y' to 'ExplicitConv::X'}}
  }
}

namespace DR899 {
  struct C { }; // expected-note 2 {{candidate constructor}}

  struct A {
    explicit operator int() const;
    explicit operator C() const;
  };

  struct B {
    int i;
    B(const A& a): i(a) { }
  };

  int main() {
    A a;
    int i = a; // expected-error{{no viable conversion}}
    int j(a);
    C c = a; // expected-error{{no viable conversion}}
    C c2(a);
  }
}

Add test for C++ DR899.

Add test for C++ DR899.

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


#include <fstream>

#include <VBE/system/sdl2/StorageImpl.hpp>

// static
std::unique_ptr<std::istream> StorageImpl::openAsset(const std::string& filename) {
	// Open in binary mode so Windows doesn't change LF to CRLF,
	// which will corrupt binary files such as images.
	return std::unique_ptr<std::istream>(new std::ifstream("assets/"+filename, std::ios::binary));
}

#include <fstream>

#include <VBE/system/sdl2/StorageImpl.hpp>
#include <VBE/system/Log.hpp>

// static
std::unique_ptr<std::istream> StorageImpl::openAsset(const std::string& filename) {
	// Open in binary mode so Windows doesn't change LF to CRLF,
	// which will corrupt binary files such as images.
	std::ifstream* stream = new std::ifstream("assets/"+filename, std::ios::binary);

	VBE_ASSERT(stream->good(), "Could not open asset: "+filename);
	return std::unique_ptr<std::istream>(stream);
}

Check that assets are opened properly.

Check that assets are opened properly.


#include "common.th"

// c <- multiplicand
// d <- multiplier
// b -> product
.global imul
imul:
#if IMUL_EARLY_EXITS
    b <- c == 0
    d <- d &~ b     // d = (c == 0) ? 0 : d
    b <- d == 0
    p <- @+L_done & b + p
#endif

    o <- o - 3
    h -> [o + (3 - 0)]
    i -> [o + (3 - 1)]
    j -> [o + (3 - 2)]

    b <- 0
    h <- 1

    j <- d >> 31    // save sign bit in j
    d <- d ^ j      // adjust multiplier
    d <- d - j

L_top:
    // use constant 1 in h to combine instructions
    i <- d & h - 1
    i <- c &~ i
    b <- b + i
    c <- c << 1
    d <- d >> 1
    i <- d == 0
    p <- @+L_top &~ i + p

    b <- b ^ j      // adjust product for signed math
    b <- b - j

    o <- o + 3
    j <- [o - 2]
    i <- [o - 1]
    h <- [o - 0]
L_done:
    o <- o + 1
    p <- [o]

#include "common.th"

// c <- multiplicand
// d <- multiplier
// b -> product
.global imul
imul:
    o <- o - 3
    h -> [o + (3 - 0)]
    i -> [o + (3 - 1)]
    j -> [o + (3 - 2)]

    b <- 0
    h <- 1

    j <- d >> 31    // save sign bit in j
    d <- d ^ j      // adjust multiplier
    d <- d - j

L_top:
    // use constant 1 in h to combine instructions
    i <- d & h - 1
    i <- c &~ i
    b <- b + i
    c <- c << 1
    d <- d >> 1
    i <- d == 0
    p <- @+L_top &~ i + p

    b <- b ^ j      // adjust product for signed math
    b <- b - j

    o <- o + 3
    j <- [o - 2]
    i <- [o - 1]
    h <- [o - 0]
L_done:
    o <- o + 1
    p <- [o]

Remove optimization dependent on cpp

Remove optimization dependent on cpp


#include "common.th"

// c <- multiplicand
// d <- multiplier
// b -> product
.global imul
imul:
#if IMUL_EARLY_EXITS
    b <- c == 0
    d <- d &~ b     // d = (c == 0) ? 0 : d
    b <- d <> 0
    jzrel(b, L_done)
#endif

    pushall(h,i,j)

    b <- 0
    h <- 1

    j <- d >> 31    // save sign bit in j
    j <- -j         // convert sign to flag
    d <- d ^ j      // adjust multiplier
    d <- d - j

L_top:
    // use constant 1 in h to combine instructions
    i <- d & h - 1
    i <- c &~ i
    b <- b + i
    c <- c << 1
    d <- d >> 1
    i <- d <> 0
    jnzrel(i, L_top)

    b <- b ^ j      // adjust product for signed math
    b <- b - j

    popall(h,i,j)
L_done:
    ret

#include "common.th"

// c <- multiplicand
// d <- multiplier
// b -> product
.global imul
imul:
#if IMUL_EARLY_EXITS
    b <- c == 0
    d <- d &~ b     // d = (c == 0) ? 0 : d
    b <- d <> 0
    jzrel(b, L_done)
#endif

    pushall(h,i,j)

    b <- 0
    h <- 1

    j <- d >>> 31   // save sign bit in j
    d <- d ^ j      // adjust multiplier
    d <- d - j

L_top:
    // use constant 1 in h to combine instructions
    i <- d & h - 1
    i <- c &~ i
    b <- b + i
    c <- c << 1
    d <- d >> 1
    i <- d <> 0
    jnzrel(i, L_top)

    b <- b ^ j      // adjust product for signed math
    b <- b - j

    popall(h,i,j)
L_done:
    ret

Use arithmetic right-shift in imul

Use arithmetic right-shift in imul


#include "gmock/gmock.h"

#include "tcframe/experimental/runner.hpp"

using ::testing::Test;

namespace tcframe {

class FakeProblem : public BaseProblem {
protected:
    void InputFormat() {}
};

class FakeGenerator : public BaseGenerator<FakeProblem> {};

class RunnerTests : public Test {
protected:
    int argc = 1;
    char* argv[1] = {const_cast<char*>("./runner")};

    Runner<FakeProblem> runner = Runner<FakeProblem>(argc, argv);
};

TEST_F(RunnerTests, CompilationSuccessful) {
    runner.setGenerator(new FakeGenerator());
}

}

#include "gmock/gmock.h"

#include "tcframe/experimental/runner.hpp"

using ::testing::Test;

namespace tcframe {

class FakeProblem : public BaseProblem {
protected:
    void InputFormat() {}
};

class FakeGenerator : public BaseGenerator<FakeProblem> {};

class RunnerTests : public Test {
protected:
    int argc = 1;
    char* argv[1] = {toChar("./runner")};

    Runner<FakeProblem> runner = Runner<FakeProblem>(argc, argv);

private:
    static char* toChar(const string& str) {
        char* cstr = new char[str.length() + 1];
        strcpy(cstr, str.c_str());
        return cstr;
    }
};

TEST_F(RunnerTests, CompilationSuccessful) {
    runner.setGenerator(new FakeGenerator());
}

}

Use safer cast from const char* literal to char*


/*
 * Copyright 2004-2014 Cray Inc.
 * Other additional copyright holders may be indicated within.
 *
 * The entirety of this work is 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 <cstdio>
#include "driver.h"
#include "version.h"
#include "version_num.h"

void
get_version(char *v) {
  v += sprintf(v, "%d.%s.%s", MAJOR_VERSION, MINOR_VERSION, UPDATE_VERSION);
  if (strcmp(BUILD_VERSION, "") || developer)
    sprintf(v, ".%s", BUILD_VERSION);
}

/*
 * Copyright 2004-2014 Cray Inc.
 * Other additional copyright holders may be indicated within.
 *
 * The entirety of this work is 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 <cstdio>
#include "driver.h"
#include "version.h"
#include "version_num.h"

void
get_version(char *v) {
  v += sprintf(v, "%d.%s.%s", MAJOR_VERSION, MINOR_VERSION, UPDATE_VERSION);
  if (!strcmp(BUILD_VERSION, "") || developer)
    sprintf(v, ".%s", BUILD_VERSION);
}

Fix boolean expectation from strcmp.

Fix boolean expectation from strcmp.


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

#include <test/fuzz/fuzz.h>
#include <util/bip32.h>

void test_one_input(const std::vector<uint8_t>& buffer)
{
    const std::string keypath_str(buffer.begin(), buffer.end());
    std::vector<uint32_t> keypath;
    (void)ParseHDKeypath(keypath_str, keypath);
}

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

#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
#include <test/fuzz/util.h>
#include <util/bip32.h>

#include <cstdint>
#include <vector>

void test_one_input(const std::vector<uint8_t>& buffer)
{
    const std::string keypath_str(buffer.begin(), buffer.end());
    std::vector<uint32_t> keypath;
    (void)ParseHDKeypath(keypath_str, keypath);

    FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
    const std::vector<uint32_t> random_keypath = ConsumeRandomLengthIntegralVector<uint32_t>(fuzzed_data_provider);
    (void)FormatHDKeypath(random_keypath);
    (void)WriteHDKeypath(random_keypath);
}

tests: Add fuzzing coverage for FormatHDKeypath(...) and WriteHDKeypath(...)


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

#include "base/cancellation_flag.h"

#include "base/logging.h"

namespace base {

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

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

}  // namespace base

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

#include "base/cancellation_flag.h"

#include "base/logging.h"

namespace base {

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

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

}  // namespace base

Replace a DCHECK with DCHECK_EQ.

Replace a DCHECK with DCHECK_EQ.

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

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


//===- llvm/unittest/Support/TimeValueTest.cpp - Time Value tests ---------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "llvm/Support/TimeValue.h"
#include <time.h>

using namespace llvm;
namespace {

TEST(TimeValue, time_t) {
  sys::TimeValue now = sys::TimeValue::now();
  time_t now_t = time(NULL);
  EXPECT_TRUE(abs(static_cast<long>(now_t - now.toEpochTime())) < 2);
}

TEST(TimeValue, Win32FILETIME) {
  uint64_t epoch_as_filetime = 0x19DB1DED53E8000ULL;
  uint32_t ns = 765432100;
  sys::TimeValue epoch;

  // FILETIME has 100ns of intervals.
  uint64_t ft1970 = epoch_as_filetime + ns / 100;
  epoch.fromWin32Time(ft1970);

  // The "seconds" part in Posix time may be expected as zero.
  EXPECT_EQ(0u, epoch.toEpochTime());
  EXPECT_EQ(ns, static_cast<uint32_t>(epoch.nanoseconds()));

  // Confirm it reversible.
  EXPECT_EQ(ft1970, epoch.toWin32Time());
}

}

//===- llvm/unittest/Support/TimeValueTest.cpp - Time Value tests ---------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"
#include "llvm/Support/TimeValue.h"
#include <time.h>

using namespace llvm;
namespace {

TEST(TimeValue, time_t) {
  sys::TimeValue now = sys::TimeValue::now();
  time_t now_t = time(NULL);
  EXPECT_TRUE(std::abs(static_cast<long>(now_t - now.toEpochTime())) < 2);
}

TEST(TimeValue, Win32FILETIME) {
  uint64_t epoch_as_filetime = 0x19DB1DED53E8000ULL;
  uint32_t ns = 765432100;
  sys::TimeValue epoch;

  // FILETIME has 100ns of intervals.
  uint64_t ft1970 = epoch_as_filetime + ns / 100;
  epoch.fromWin32Time(ft1970);

  // The "seconds" part in Posix time may be expected as zero.
  EXPECT_EQ(0u, epoch.toEpochTime());
  EXPECT_EQ(ns, static_cast<uint32_t>(epoch.nanoseconds()));

  // Confirm it reversible.
  EXPECT_EQ(ft1970, epoch.toWin32Time());
}

}

Use the overloaded std::abs rather than C's abs(int) to address Clang's -Wabsolute-value

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


/******************************************************************************

  nomlib - C++11 cross-platform game engine

Copyright (c) 2013, Jeffrey Carpenter <jeffrey.carp@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

******************************************************************************/

// This file is auto-generated by CMake at build time
#include "nomlib/version.hpp"

const std::string NOMLIB_INSTALL_PREFIX = "/Users/jeff/Library/Frameworks";
const std::string NOMLIB_BUNDLE_IDENTIFIER = "org.i8degrees.nomlib";

/******************************************************************************

  nomlib - C++11 cross-platform game engine

Copyright (c) 2013, Jeffrey Carpenter <jeffrey.carp@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

******************************************************************************/

// This file is auto-generated by CMake at build time
#include "nomlib/version.hpp"

#if defined (NOM_PLATFORM_WINDOWS)
  const std::string NOMLIB_INSTALL_PREFIX = "C:/";
#endif

const std::string NOMLIB_BUNDLE_IDENTIFIER = "org.i8degrees.nomlib";

Add conditional preprocessor for nomlib's install prefix under Windows


/*
Copyright 2017 Google Inc. 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 "ofMain.h"
#include "ofApp.h"

//========================================================================
int main(){
	ofSetupOpenGL(1024, 768, OF_WINDOW);
	ofRunApp(new ofApp());
}

/*
Copyright 2017 Google Inc. 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 "ofMain.h"
#include "ofApp.h"

//========================================================================
int main(){
	ofSetupOpenGL(126, 64, OF_WINDOW);
	ofRunApp(new ofApp());
}

Decrease window size to use less screen space

Removes large black empty rectangle that draws over CLI + X server (if installed).


// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// RosettaStone is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Actions/Generic.hpp>
#include <Rosetta/Tasks/SimpleTasks/IncludeTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/ReturnHandTask.hpp>

namespace RosettaStone::SimpleTasks
{
ReturnHandTask::ReturnHandTask(EntityType entityType) : ITask(entityType)
{
    // Do nothing
}

TaskID ReturnHandTask::GetTaskID() const
{
    return TaskID::RETURN_HAND;
}

TaskStatus ReturnHandTask::Impl(Player& player)
{
    auto entities =
        IncludeTask::GetEntities(m_entityType, player, m_source, m_target);

    for (auto& entity : entities)
    {
        Generic::RemoveMinionFromField(m_target->GetOwner(),
                                       dynamic_cast<Minion*>(entity));
        entity->Reset();
        Generic::AddCardToHand(m_target->GetOwner(), entity);
    }

    return TaskStatus::COMPLETE;
}
}  // namespace RosettaStone::SimpleTasks

// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// RosettaStone is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon

#include <Rosetta/Actions/Generic.hpp>
#include <Rosetta/Tasks/SimpleTasks/IncludeTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/ReturnHandTask.hpp>

namespace RosettaStone::SimpleTasks
{
ReturnHandTask::ReturnHandTask(EntityType entityType) : ITask(entityType)
{
    // Do nothing
}

TaskID ReturnHandTask::GetTaskID() const
{
    return TaskID::RETURN_HAND;
}

TaskStatus ReturnHandTask::Impl(Player& player)
{
    auto entities =
        IncludeTask::GetEntities(m_entityType, player, m_source, m_target);

    for (auto& entity : entities)
    {
        Generic::RemoveMinionFromField(entity->GetOwner(),
                                       dynamic_cast<Minion*>(entity));
        entity->Reset();
        Generic::AddCardToHand(entity->GetOwner(), entity);
    }

    return TaskStatus::COMPLETE;
}
}  // namespace RosettaStone::SimpleTasks

fix: Correct nullptr problem (change 'm_target' to 'entity')


/**
 * Appcelerator Kroll - licensed under the Apache Public License 2
 * see LICENSE in the root folder for details on the license.
 * Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved.
 */

#include "utils.h"

#include <cstdio>

namespace UTILS_NS
{
namespace PlatformUtils
{
	std::string GetFirstMACAddress()
	{
		MACAddress address;
		memset(&address, 0, sizeof(MACAddress));

		try
		{
			PlatformUtils::GetFirstMACAddressImpl(address);
		}
		catch(...)
		{
			// Just return zeros.
		}

		char result[18];
		std::sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
			address[0], address[1], address[2], address[3],
			address[4], address[5]);
		return std::string(result);
	}

	std::string GetMachineId()
	{
        static std::string machineID;
        if (machineID.empty())
            machineID = DataUtils::HexMD5(GetFirstMACAddress());
        return machineID;
	}
}
}

/**
 * Appcelerator Kroll - licensed under the Apache Public License 2
 * see LICENSE in the root folder for details on the license.
 * Copyright (c) 2009 Appcelerator, Inc. All Rights Reserved.
 */

#include "utils.h"

#include <stdio.h>
#include <string.h>

namespace UTILS_NS
{
namespace PlatformUtils
{
	std::string GetFirstMACAddress()
	{
		MACAddress address;
		memset(&address, 0, sizeof(MACAddress));

		try
		{
			PlatformUtils::GetFirstMACAddressImpl(address);
		}
		catch(...)
		{
			// Just return zeros.
		}

		char result[18];
		std::sprintf(result, "%02x:%02x:%02x:%02x:%02x:%02x",
			address[0], address[1], address[2], address[3],
			address[4], address[5]);
		return std::string(result);
	}

	std::string GetMachineId()
	{
        static std::string machineID;
        if (machineID.empty())
            machineID = DataUtils::HexMD5(GetFirstMACAddress());
        return machineID;
	}
}
}

Fix build error on Linux.

Fix build error on Linux.


#include "fnv_param.hpp"
#include "fnv_algo.hpp"
#include "constraint.hpp"
#include "fnv_solver.hpp"
#include <vector>
#include <iostream>
#include <boost/foreach.hpp>

int main(int argc, char** argv)
{
  const std::vector<FNVParam> fnvParams = FNVParam::getAll();
  const std::vector<FNVAlgo> fnvAlgos = FNVAlgo::getAll();
  const std::vector<Constraint> constraints = Constraint::getAll();

  BOOST_FOREACH(const FNVParam& fnvParam, fnvParams)
  {
    std::cout << "Problem size: " << fnvParam.getWidth() << std::endl;

    BOOST_FOREACH(const FNVAlgo& fnvAlgo, fnvAlgos)
    {
      std::cout << "Algorithm: FNV-" << fnvAlgo.getName() << std::endl;

      const Constraint nullConstraint = Constraint::getNull();
      std::cout << "Constraint: " << nullConstraint.getName() << std::endl;
      FNVSolver solver(fnvParam, fnvAlgo, nullConstraint);
      solver.solve();
      const int solutionLength = solver.getSolutionLength();

      BOOST_FOREACH(const Constraint& constraint, constraints)
      {
        std::cout << "Constraint: " << constraint.getName() << std::endl;
        FNVSolver solver(fnvParam, fnvAlgo, constraint, solutionLength);
        solver.solve();
      }
    }
  }
}

#include "fnv_param.hpp"
#include "fnv_algo.hpp"
#include "constraint.hpp"
#include "fnv_solver.hpp"
#include <vector>
#include <iostream>
#include <boost/foreach.hpp>

int main(int argc, char** argv)
{
  const std::vector<FNVParam> fnvParams = FNVParam::getAll();
  const std::vector<FNVAlgo> fnvAlgos = FNVAlgo::getAll();
  const std::vector<Constraint> constraints = Constraint::getAll();

  BOOST_FOREACH(const FNVParam& fnvParam, fnvParams)
  {
    std::cout << "Problem size: " << fnvParam.getWidth() << std::endl;

    BOOST_FOREACH(const FNVAlgo& fnvAlgo, fnvAlgos)
    {
      std::cout << "Algorithm: FNV-" << fnvAlgo.getName() << std::endl;

      const Constraint nullConstraint = Constraint::getNull();
      std::cout << "Constraint: " << nullConstraint.getName() << std::endl;
      FNVSolver solver(fnvParam, fnvAlgo, nullConstraint);
      solver.solve();
      const int solutionLength = solver.getSolutionLength();

      BOOST_FOREACH(const Constraint& constraint, constraints)
      {
        std::cout << "Constraint: " << constraint.getName() << std::endl;
        FNVSolver solver(fnvParam, fnvAlgo, constraint, solutionLength);
        solver.solve();
      }
    }

    std::cout << std::endl;
  }
}

Add slightly more spacing in output.

Add slightly more spacing in output.

Monotone-Parent: 6b99470e62e578d124e0fbbf7a434da82aeb3a5b
Monotone-Revision: 605fe263cd8d7dada4205b576819b218d4ddb8df


/*
 *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */
#include "webrtc/base/checks.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h"
#include "webrtc/system_wrappers/include/clock.h"

namespace webrtc {

void FuzzOneInput(const uint8_t* data, size_t size) {
  RTCPUtility::RTCPParserV2 rtcp_parser(data, size, true);
  if (!rtcp_parser.IsValid())
    return;

  webrtc::SimulatedClock clock(1234);
  RTCPReceiver receiver(&clock, false, nullptr, nullptr, nullptr, nullptr,
                        nullptr);

  RTCPHelp::RTCPPacketInformation rtcp_packet_information;
  receiver.IncomingRTCPPacket(rtcp_packet_information, &rtcp_parser);
}
}  // namespace webrtc

/*
 *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */
#include "webrtc/base/checks.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_receiver.h"
#include "webrtc/system_wrappers/include/clock.h"

namespace webrtc {
namespace {

class NullModuleRtpRtcp : public RTCPReceiver::ModuleRtpRtcp {
 public:
  void SetTmmbn(std::vector<rtcp::TmmbItem>) override {}
  void OnRequestSendReport() override {}
  void OnReceivedNack(const std::vector<uint16_t>&) override {};
  void OnReceivedRtcpReportBlocks(const ReportBlockList&) override {};
};

}

void FuzzOneInput(const uint8_t* data, size_t size) {
  NullModuleRtpRtcp rtp_rtcp_module;
  SimulatedClock clock(1234);

  RTCPReceiver receiver(&clock, false, nullptr, nullptr, nullptr, nullptr,
                        &rtp_rtcp_module);

  receiver.IncomingPacket(data, size);
}
}  // namespace webrtc

Update rtcp receiver fuzzer to use generic function
IncomingPacket(const uint8_t* packet, size_t size)
instead of implementation specific
IncomingRTCPPacket(PacketInfo* out, Parser* in)
This would allow switch parse implementation

BUG=webrtc:5260
R=stefan@webrtc.org

Review URL: https://codereview.webrtc.org/2334643002 .

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


// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-apple-darwin10 | FileCheck %s
// RUN: %clang_cc1 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
// RUN: diff %t.ll  %t-c++11.ll

// rdar://12897704

struct sAFSearchPos {
    unsigned char *pos;
    unsigned char count;
};

static volatile struct sAFSearchPos testPositions;
// CHECK: @_ZL13testPositions = internal global %struct.sAFSearchPos zeroinitializer

static volatile struct sAFSearchPos arrayPositions[100][10][5];
// CHECK: @_ZL14arrayPositions = internal global [100 x [10 x [5 x %struct.sAFSearchPos]]] zeroinitializer

int main() {
  return testPositions.count + arrayPositions[10][4][3].count;
}

// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o %t-c++11.ll %s -triple x86_64-apple-darwin10
// RUN: FileCheck %s < %t-c++11.ll
// RUN: %clang_cc1  -std=c++98 -S -emit-llvm -o %t.ll %s -triple x86_64-apple-darwin10
// RUN: diff %t.ll  %t-c++11.ll

// rdar://12897704

struct sAFSearchPos {
    unsigned char *pos;
    unsigned char count;
};

static volatile struct sAFSearchPos testPositions;
// CHECK: @_ZL13testPositions = internal global %struct.sAFSearchPos zeroinitializer

static volatile struct sAFSearchPos arrayPositions[100][10][5];
// CHECK: @_ZL14arrayPositions = internal global [100 x [10 x [5 x %struct.sAFSearchPos]]] zeroinitializer

int main() {
  return testPositions.count + arrayPositions[10][4][3].count;
}

Add -std=c++98 to the test and minor improvment in addition.

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


#include <algorithm>
#include <cctype>
#include <fstream>
#include <iostream>
#include <string>

int main(int argc, char ** argv)
{
    std::ifstream input{argv[1]};
    std::string line;

    std::getline(input, line);
    while(input)
    {
        std::for_each(std::begin(line), std::end(line), [](char c) {
            std::cout << static_cast<char>(std::tolower(c));
        });
        std::cout << '\n';
        std::getline(input, line);
    }
    return 0;
}

#include <algorithm>
#include <cctype>
#include <fstream>
#include <iostream>
#include <string>

int main(int argc, char ** argv)
{
    std::ifstream input{argv[1]};
    std::string line;

    std::getline(input, line);
    while(input)
    {
        std::transform(std::begin(line), std::end(line), std::begin(line), [](char c) {
            return static_cast<char>(std::tolower(c));
        });
        std::cout << line << '\n';
        std::getline(input, line);
    }
    return 0;
}

Use transform instead of for_each

Use transform instead of for_each


/** @file
    @brief Implementation

    @date 2014

    @author
    Ryan Pavlik
    <ryan@sensics.com>
    <http://sensics.com>
*/

// Copyright 2014 Sensics, Inc.
//
// All rights reserved.
//
// (Final version intended to be licensed under
// the Apache License, Version 2.0)

// Internal Includes
#include <ogvr/ClientKit/ContextC.h>

// Library/third-party includes
// - none

// Standard includes
#include <iostream>

int main() {
    OGVR_ClientContext ctx =
        ogvrClientInit("org.opengoggles.exampleclients.MinimalInit");
    std::cout << "OK, library initialized, now going to shut it down."
              << std::endl;
    ogvrClientShutdown(ctx);
    std::cout << "Library shut down, exiting." << std::endl;
    return 0;
}

/** @file
    @brief Implementation

    @date 2014

    @author
    Ryan Pavlik
    <ryan@sensics.com>
    <http://sensics.com>
*/

// Copyright 2014 Sensics, Inc.
//
// All rights reserved.
//
// (Final version intended to be licensed under
// the Apache License, Version 2.0)

// Internal Includes
#include <ogvr/ClientKit/ContextC.h>

// Library/third-party includes
// - none

// Standard includes
#include <iostream>

int main() {
    OGVR_ClientContext ctx =
        ogvrClientInit("org.opengoggles.exampleclients.MinimalInit");
    std::cout << "OK, library initialized." << std::endl;

    // Pretend that this is your application's mainloop.
    for (int i = 0; i < 1000000; ++i) {
        ogvrClientUpdate(ctx);
    }

    ogvrClientShutdown(ctx);

    std::cout << "Library shut down, exiting." << std::endl;
    return 0;
}

Add mainloop to minimal init

Add mainloop to minimal init


/*
 * Copyright (C) 2016 Luke San Antonio
 * All rights reserved.
 */

// Include the implementation first so that it actually works. We have to do
// this because our header file includes the header as well, we might as well
// put the implementation here.
#define TINYGLTF_LOADER_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "../../gltf/tiny_gltf_loader.h"

#include "minigltf.h"

#include <cstdio>
#include "../common/log.h"

namespace redc
{
  boost::optional<tinygltf::Scene> load_gltf_file(std::string name)
  {
    std::string err;
    tinygltf::Scene scene;

    tinygltf::TinyGLTFLoader loader;

    if(!loader.LoadASCIIFromFile(&scene, &err, name))
    {
      log_e("Error in '%': %", name, err);
      return boost::none;
    }

    return std::move(scene);
  }
}

/*
 * Copyright (C) 2016 Luke San Antonio
 * All rights reserved.
 */

// Include the implementation first so that it actually works. We have to do
// this because our header file includes the header as well, we might as well
// put the implementation here.
#define TINYGLTF_LOADER_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#include "../../gltf/tiny_gltf_loader.h"

#include "minigltf.h"

#include <cstdio>
#include "../common/log.h"

namespace redc
{
  boost::optional<tinygltf::Scene> load_gltf_file(std::string name)
  {
    std::string err;
    tinygltf::Scene scene;

    tinygltf::TinyGLTFLoader loader;

    if(!loader.LoadASCIIFromFile(&scene, &err, name))
    {
      log_e("Error in '%': %", name, err);
      return boost::none;
    }
    else
    {
      log_i("Information loading '%': %", name, err);
    }

    return std::move(scene);
  }
}

Print debugging information from tinygltfloader

This happens even if the parse is successful now.


//
// Created by monty on 08/12/16.
//
#include <string>
#include <iostream>
#include <fstream>

#include "IFileLoaderDelegate.h"
#include "CPlainFileLoader.h"

namespace Knights {
	std::string CPlainFileLoader::loadFileFromPath( const std::string& path ) {
		std::string entry;
		std::ifstream fileToLoad(path);

		char buffer;

		while (!fileToLoad.eof()) {
			fileToLoad >> buffer;
			entry += buffer;
		}

		return entry;
	}

	std::string CPlainFileLoader::getFilePathPrefix() {
		return "res/";
	}
}

//
// Created by monty on 08/12/16.
//
#include <string>
#include <iostream>
#include <fstream>

#include "IFileLoaderDelegate.h"
#include "CPlainFileLoader.h"

namespace Knights {
	std::string CPlainFileLoader::loadFileFromPath( const std::string& path ) {
		std::string entry;
		std::ifstream fileToLoad(path);

		char buffer;

		while (!fileToLoad.eof()) {
			fileToLoad >> buffer;
			entry.push_back(buffer);
		}

		return entry;
	}

	std::string CPlainFileLoader::getFilePathPrefix() {
		return "res/";
	}
}

Replace the += operator with push_back on file loading operations


#include "picturemodel.h"

#include <QFile>

PictureModel::PictureModel(QObject *parent)
    : MediaModel(MediaModel::Picture, parent)
{
    QHash<int, QByteArray> roleNames = MediaModel::roleNames();
    setRoleNames(roleNames);
}

PictureModel::~PictureModel()
{
}

QVariant PictureModel::data(MediaInfo *mediaInfo, int role) const
{
    if (role == Qt::DisplayRole)
        return mediaInfo->name;
    return QVariant();
}

QImage PictureModel::decoration(MediaInfo *info) const
{
    QImage thumbnail = (static_cast<PictureInfo *>(info))->thumbnail;
    if (thumbnail.isNull())
        return QImage(themeResourcePath() + "/media/Fanart_Fallback_Picture_Small.jpg"); // FIXME: Make this configurable
    return thumbnail;
}

MediaInfo *PictureModel::readMediaInfo(const QString &filePath)
{
    QImage image(filePath);

    PictureInfo *info = new PictureInfo;
    info->thumbnail = image;

    return info;
}

#include "picturemodel.h"

#include <QFile>
#include <QImageReader>

PictureModel::PictureModel(QObject *parent)
    : MediaModel(MediaModel::Picture, parent)
{
    QHash<int, QByteArray> roleNames = MediaModel::roleNames();
    setRoleNames(roleNames);
}

PictureModel::~PictureModel()
{
}

QVariant PictureModel::data(MediaInfo *mediaInfo, int role) const
{
    if (role == Qt::DisplayRole)
        return mediaInfo->name;
    return QVariant();
}

QImage PictureModel::decoration(MediaInfo *info) const
{
    return (static_cast<PictureInfo *>(info))->thumbnail;
}

MediaInfo *PictureModel::readMediaInfo(const QString &filePath)
{
    QImageReader imageReader(filePath);
    if (!imageReader.canRead())
        return 0;

    QImage image = imageReader.read();
    if (image.isNull())
        return 0;

    PictureInfo *info = new PictureInfo;
    info->thumbnail = image;

    return info;
}

Use ImageReader to read the images

Use ImageReader to read the images