Instruction stringlengths 14 778 | input_code stringlengths 0 4.24k | output_code stringlengths 1 5.44k |
|---|---|---|
Fix mixed-mode debugging on release PTVS builds. | /* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
* ***************************************************************************/
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <stdio.h>
// Used by debugger to detect when DLL is fully loaded and initialized and TraceFunc can be registered.
extern "C" {
__declspec(dllexport)
volatile char isInitialized;
__declspec(dllexport)
void OnInitialized() {
volatile char dummy = 0;
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
isInitialized = 1;
OnInitialized();
}
return TRUE;
}
| /* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Apache License, Version 2.0. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Apache License, Version 2.0, please send an email to
* vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Apache License, Version 2.0.
*
* You must not remove this notice, or any other, from this software.
*
* ***************************************************************************/
// dllmain.cpp : Defines the entry point for the DLL application.
#include "stdafx.h"
#include <stdio.h>
// Used by debugger to detect when DLL is fully loaded and initialized and TraceFunc can be registered.
extern "C" {
__declspec(dllexport)
volatile char isInitialized;
__declspec(dllexport) __declspec(noinline)
void OnInitialized() {
volatile char dummy = 0;
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
isInitialized = 1;
OnInitialized();
}
return TRUE;
}
|
Include the size of the array in the array memory layout | //=======================================================================
// Copyright Baptiste Wicht 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#include "il/GlobalArray.hpp"
#include "AssemblyFileWriter.hpp"
using namespace eddic;
GlobalArray::GlobalArray(std::string n, BaseType t, int s) : name(n), type(t), size(s) {}
void GlobalArray::write(AssemblyFileWriter& writer){
writer.stream() << "VA" << name << ":" <<std::endl;
writer.stream() << ".rept " << size << std::endl;
if(type == BaseType::INT){
writer.stream() << ".long 0" << std::endl;
} else if(type == BaseType::STRING){
writer.stream() << ".long S3" << std::endl;
writer.stream() << ".long 0" << std::endl;
}
writer.stream() << ".endr" << std::endl;
}
| //=======================================================================
// Copyright Baptiste Wicht 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//=======================================================================
#include "il/GlobalArray.hpp"
#include "AssemblyFileWriter.hpp"
using namespace eddic;
GlobalArray::GlobalArray(std::string n, BaseType t, int s) : name(n), type(t), size(s) {}
void GlobalArray::write(AssemblyFileWriter& writer){
writer.stream() << "VA" << name << ":" <<std::endl;
writer.stream() << ".long " << size << std::endl;
writer.stream() << ".rept " << size << std::endl;
if(type == BaseType::INT){
writer.stream() << ".long 0" << std::endl;
} else if(type == BaseType::STRING){
writer.stream() << ".long S3" << std::endl;
writer.stream() << ".long 0" << std::endl;
}
writer.stream() << ".endr" << std::endl;
}
|
Fix typo in include due to case insensitivity | /*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file is part of the wikidata_cpp project:
* https://github.com/radupopescu/wikidata_cpp
*/
#include "data.h"
#include <rapidjson/Document.h>
#include <iostream>
namespace rj = rapidjson;
namespace data {
bool parseItem(const Languages& languages, const std::string& line, WikidataElement& elem)
{
rj::Document j;
j.Parse(line.substr(0, line.size() - 1).c_str());
if (! j.HasParseError()) {
if (j.HasMember("id")) {
elem.id = j["id"].GetString();
if (j.HasMember("sitelinks")) {
const auto& s = j["sitelinks"].GetObject();
for (const auto& l : languages) {
const auto sitelink = l + "wiki";
if (s.HasMember(sitelink.c_str())) {
if (s[sitelink.c_str()].HasMember("title")) {
elem.sites[l] = s[sitelink.c_str()]["title"].GetString();
}
}
}
return elem.sites.size() == languages.size();
}
}
}
return false;
}
}
| /*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file is part of the wikidata_cpp project:
* https://github.com/radupopescu/wikidata_cpp
*/
#include "data.h"
#include <rapidjson/document.h>
#include <iostream>
namespace rj = rapidjson;
namespace data {
bool parseItem(const Languages& languages, const std::string& line, WikidataElement& elem)
{
rj::Document j;
j.Parse(line.substr(0, line.size() - 1).c_str());
if (! j.HasParseError()) {
if (j.HasMember("id")) {
elem.id = j["id"].GetString();
if (j.HasMember("sitelinks")) {
const auto& s = j["sitelinks"].GetObject();
for (const auto& l : languages) {
const auto sitelink = l + "wiki";
if (s.HasMember(sitelink.c_str())) {
if (s[sitelink.c_str()].HasMember("title")) {
elem.sites[l] = s[sitelink.c_str()]["title"].GetString();
}
}
}
return elem.sites.size() == languages.size();
}
}
}
return false;
}
}
|
Use paramter to set yaw rate. | #include <ros/ros.h>
#include <sensor_msgs/Imu.h>
int main(int argc, char **argv) {
// Initialize ROS
ros::init(argc, argv, "test_imu");
ros::NodeHandle nh;
// Create a publisher object
ros::Publisher imuPub = nh.advertise<sensor_msgs::Imu>("imu/data",1);
// Create an Imu message object
sensor_msgs::Imu imuMsg;
imuMsg.header.frame_id = "base_imu";
// Create variables for yaw rate
double yawRate = 0;
imuMsg.header.stamp = ros::Time::now();
imuMsg.angular_velocity.z = yawRate;
imuPub.publish(imuMsg);
ros::Rate loop_rate(30);
while (ros::ok())
{
yawRate = 0;
imuMsg.header.stamp = ros::Time::now();
imuMsg.angular_velocity.z = yawRate;
imuPub.publish(imuMsg);
loop_rate.sleep();
}
return 0;
}
| #include <ros/ros.h>
#include <sensor_msgs/Imu.h>
int main(int argc, char **argv) {
// Initialize ROS
ros::init(argc, argv, "test_imu");
ros::NodeHandle nh;
ros::NodeHandle private_nh("~");
// Create variables for yaw rate
double yawRate;
if(!private_nh.getParam("rate", yawRate)) {
yawRate = 0;
ROS_WARN_STREAM("No rate was recieved. Using 0.0");
}
else {
ROS_WARN_STREAM("Rate is " << yawRate);
}
// Create a publisher object
ros::Publisher imuPub = nh.advertise<sensor_msgs::Imu>("imu/data",1);
// Create an Imu message object
sensor_msgs::Imu imuMsg;
imuMsg.header.frame_id = "base_imu";
imuMsg.header.stamp = ros::Time::now();
imuMsg.angular_velocity.z = yawRate;
imuPub.publish(imuMsg);
ros::Rate loop_rate(30);
while (ros::ok())
{
imuMsg.header.stamp = ros::Time::now();
imuMsg.angular_velocity.z = yawRate;
imuPub.publish(imuMsg);
loop_rate.sleep();
}
return 0;
}
|
Rename 'res' variable to 'test_result' | /// \file main.cpp
#include "HelloTriangleApplication.hpp"
#include "VDeleter.hpp"
// waf-generated header
#include "config.hpp"
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
int res{0};
#ifndef DOCTEST_CONFIG_DISABLE
doctest::Context context;
context.setOption("no-run", true);
context.applyCommandLine(argc, argv);
using namespace std::literals::string_literals;
auto begin_argv = argv + 1;
auto end_argv = argv + argc;
if (end_argv != std::find(begin_argv, end_argv, "--test"s)) {
context.setOption("no-run", false);
context.setOption("exit", true);
}
res = context.run();
if (context.shouldExit()) return res;
#endif
HelloTriangleApplication app;
try {
app.run();
}
catch (const std::runtime_error& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS + res;
}
// vim:set et ts=2 sw=2 sts=2:
| /// \file main.cpp
#include "HelloTriangleApplication.hpp"
#include "VDeleter.hpp"
// waf-generated header
#include "config.hpp"
#define DOCTEST_CONFIG_IMPLEMENT
#include "doctest.h"
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
int test_result{0};
#ifndef DOCTEST_CONFIG_DISABLE
doctest::Context context;
context.setOption("no-run", true);
context.applyCommandLine(argc, argv);
using namespace std::literals::string_literals;
auto begin_argv = argv + 1;
auto end_argv = argv + argc;
if (end_argv != std::find(begin_argv, end_argv, "--test"s)) {
context.setOption("no-run", false);
context.setOption("exit", true);
}
test_result = context.run();
if (context.shouldExit()) return test_result;
#endif
HelloTriangleApplication app;
try {
app.run();
}
catch (const std::runtime_error& e) {
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS + test_result;
}
// vim:set et ts=2 sw=2 sts=2:
|
Remove comments originating from Helloworld Pro... | #include <QtQuick>
#include <sailfishapp.h>
#include <QScopedPointer>
#include <QQuickView>
#include <QQmlEngine>
#include <QGuiApplication>
#include "factor.h"
int main(int argc, char *argv[])
{
// For this example, wizard-generates single line code would be good enough,
// but very soon it won't be enough for you anyway, so use this more detailed example from start
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
QScopedPointer<QQuickView> view(SailfishApp::createView());
Factorizer fact;
#ifdef QT_QML_DEBUG
runUnitTests();
#endif
// Here's how you will add QML components whenever you start using them
// Check https://github.com/amarchen/Wikipedia for a more full example
// view->engine()->addImportPath(SailfishApp::pathTo("qml/components").toString());
view->engine()->rootContext()->setContextProperty("fact", &fact);
view->setSource(SailfishApp::pathTo("qml/main.qml"));
view->setTitle("Sailfactor");
app->setApplicationName("harbour-sailfactor");
app->setApplicationDisplayName("Sailfactor");
view->show();
return app->exec();
}
| #include <QtQuick>
#include <sailfishapp.h>
#include <QScopedPointer>
#include <QQuickView>
#include <QQmlEngine>
#include <QGuiApplication>
#include "factor.h"
int main(int argc, char *argv[])
{
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
QScopedPointer<QQuickView> view(SailfishApp::createView());
Factorizer fact;
#ifdef QT_QML_DEBUG
runUnitTests();
#endif
view->engine()->rootContext()->setContextProperty("fact", &fact);
view->setSource(SailfishApp::pathTo("qml/main.qml"));
view->setTitle("Sailfactor");
app->setApplicationName("harbour-sailfactor");
app->setApplicationDisplayName("Sailfactor");
view->show();
return app->exec();
}
|
Terminate debugger if an assert was hit | //===--------------------- LLDBAssert.cpp ------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Utility/LLDBAssert.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
using namespace lldb_private;
void lldb_private::lldb_assert(bool expression, const char *expr_text,
const char *func, const char *file,
unsigned int line) {
if (expression)
;
else {
errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
expr_text, func, file, line);
errs() << "backtrace leading to the failure:\n";
llvm::sys::PrintStackTrace(errs());
errs() << "please file a bug report against lldb reporting this failure "
"log, and as many details as possible\n";
}
}
| //===--------------------- LLDBAssert.cpp ------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Utility/LLDBAssert.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
using namespace lldb_private;
void lldb_private::lldb_assert(bool expression, const char *expr_text,
const char *func, const char *file,
unsigned int line) {
if (LLVM_LIKELY(expression))
return;
errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
expr_text, func, file, line);
errs() << "backtrace leading to the failure:\n";
llvm::sys::PrintStackTrace(errs());
errs() << "please file a bug report against lldb reporting this failure "
"log, and as many details as possible\n";
abort();
}
|
Use dark theme in cgwhite |
#if defined(WIN32) && !defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:WINDOWS /entry:mainCRTStartup")
#endif
#include "Application.h"
#include <memory>
#include <gloperate-qtapplication/Viewer.h>
int main(int argc, char * argv[])
{
Application app(argc, argv);
std::unique_ptr<gloperate_qtapplication::Viewer> viewer(new gloperate_qtapplication::Viewer()); // make_unique is C++14
viewer->show();
return app.exec();
}
|
#if defined(WIN32) && !defined(_DEBUG)
#pragma comment(linker, "/SUBSYSTEM:WINDOWS /entry:mainCRTStartup")
#endif
#include "Application.h"
#include <memory>
#include <gloperate-qtapplication/Viewer.h>
#include <widgetzeug/dark_fusion_style.hpp>
int main(int argc, char * argv[])
{
Application app(argc, argv);
widgetzeug::enableDarkFusionStyle();
std::unique_ptr<gloperate_qtapplication::Viewer> viewer(new gloperate_qtapplication::Viewer()); // make_unique is C++14
viewer->show();
return app.exec();
}
|
Fix errors reported by Travis on Linux | #include <cstdlib>
#include <string.h>
#include <iostream>
int main() {
#ifdef __APPLE__
const char* name = "DYLD_LIBRARY_PATH";
#else
const char* name = "LD_LIBRARY_PATH";
#endif
const char* cetLDPathValue = getenv("CETD_LIBRARY_PATH");
int res = setenv("DYLD_LIBRARY_PATH", cetLDPathValue, 1);
const char* localLDPathValue = getenv(name);
if(strcmp(localLDPathValue,cetLDPathValue) != 0) {
return 1;
}
std::cout << localLDPathValue << std::endl;
return 0;
}
| #include <cstdlib>
#include <string.h>
#include <iostream>
int main() {
#ifdef __APPLE__
const char* name = "DYLD_LIBRARY_PATH";
#else
const char* name = "LD_LIBRARY_PATH";
#endif
const char* cetLDPathValue = getenv("CETD_LIBRARY_PATH");
int res = setenv(name, cetLDPathValue, 1);
if (res != 0) {
std::cerr << "could not set " << name << std::endl;
return 1;
}
const char* localLDPathValue = getenv(name);
if(strcmp(localLDPathValue,cetLDPathValue) != 0) {
return 1;
}
std::cout << localLDPathValue << std::endl;
return 0;
}
|
Fix prevent issue - uncaught exception | /*
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
*
* 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 <dali/public-api/dali-core.h>
#include <application.h>
#include <adaptor.h>
#include <render-surface.h>
#include <orientation.h>
#include <timer.h>
using namespace Dali;
/*****************************************************************************
* Test to see if the dali-adaptor is linking correctly.
*/
class LinkerApp : public ConnectionTracker
{
public:
LinkerApp(Application &app)
{
app.InitSignal().Connect(this, &LinkerApp::Create);
}
public:
void Create(Application& app)
{
}
};
/*****************************************************************************/
int
main(int argc, char **argv)
{
Application app = Application::New(&argc, &argv);
LinkerApp linkerApp (app);
app.MainLoop();
return 0;
}
| /*
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
*
* 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 <dali/public-api/dali-core.h>
#include <application.h>
#include <adaptor.h>
#include <render-surface.h>
#include <orientation.h>
#include <timer.h>
#include <iostream>
using namespace Dali;
/*****************************************************************************
* Test to see if the dali-adaptor is linking correctly.
*/
class LinkerApp : public ConnectionTracker
{
public:
LinkerApp(Application &app)
{
app.InitSignal().Connect(this, &LinkerApp::Create);
}
public:
void Create(Application& app)
{
}
};
/*****************************************************************************/
int
main(int argc, char **argv)
{
Application app = Application::New(&argc, &argv);
try
{
LinkerApp linkerApp (app);
app.MainLoop();
}
catch(...)
{
std::cout << "Exception caught";
}
return 0;
}
|
Remove misleading comment from a test file | // The main caffe test code. Your test cpp code should include this hpp
// to allow a main function to be compiled into the binary.
#include "caffe/caffe.hpp"
#include "caffe/test/test_caffe_main.hpp"
namespace caffe {
#ifndef CPU_ONLY
cudaDeviceProp CAFFE_TEST_CUDA_PROP;
#endif
}
#ifndef CPU_ONLY
using caffe::CAFFE_TEST_CUDA_PROP;
#endif
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
caffe::GlobalInit(&argc, &argv);
#ifndef CPU_ONLY
// Before starting testing, let's first print out a few cuda defice info.
int device;
cudaGetDeviceCount(&device);
cout << "Cuda number of devices: " << device << endl;
if (argc > 1) {
// Use the given device
device = atoi(argv[1]);
cudaSetDevice(device);
cout << "Setting to use device " << device << endl;
} else if (CUDA_TEST_DEVICE >= 0) {
// Use the device assigned in build configuration; but with a lower priority
device = CUDA_TEST_DEVICE;
}
cudaGetDevice(&device);
cout << "Current device id: " << device << endl;
cudaGetDeviceProperties(&CAFFE_TEST_CUDA_PROP, device);
cout << "Current device name: " << CAFFE_TEST_CUDA_PROP.name << endl;
#endif
// invoke the test.
return RUN_ALL_TESTS();
}
| #include "caffe/caffe.hpp"
#include "caffe/test/test_caffe_main.hpp"
namespace caffe {
#ifndef CPU_ONLY
cudaDeviceProp CAFFE_TEST_CUDA_PROP;
#endif
}
#ifndef CPU_ONLY
using caffe::CAFFE_TEST_CUDA_PROP;
#endif
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
caffe::GlobalInit(&argc, &argv);
#ifndef CPU_ONLY
// Before starting testing, let's first print out a few cuda defice info.
int device;
cudaGetDeviceCount(&device);
cout << "Cuda number of devices: " << device << endl;
if (argc > 1) {
// Use the given device
device = atoi(argv[1]);
cudaSetDevice(device);
cout << "Setting to use device " << device << endl;
} else if (CUDA_TEST_DEVICE >= 0) {
// Use the device assigned in build configuration; but with a lower priority
device = CUDA_TEST_DEVICE;
}
cudaGetDevice(&device);
cout << "Current device id: " << device << endl;
cudaGetDeviceProperties(&CAFFE_TEST_CUDA_PROP, device);
cout << "Current device name: " << CAFFE_TEST_CUDA_PROP.name << endl;
#endif
// invoke the test.
return RUN_ALL_TESTS();
}
|
Work around bug in gcc's name mangling causing linker to crash on Mac OS X. | // 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
|
Switch to better variable name | #include <iostream>
static constexpr unsigned getSequenceLength(unsigned number) noexcept
{
unsigned length = 0;
while (number != 1) {
if ((number & 1) == 0) {
number >>= 1;
} else {
number = 3 * number + 1;
}
++length;
}
return length;
}
int main(int count, char *arguments[])
{
unsigned number = 999999;
unsigned maximum = 0;
for (unsigned i = 999999; i > 0; --i) {
unsigned length = getSequenceLength(i);
if (length > maximum) {
maximum = length;
number = i;
}
}
std::cout << number << '\n';
return 0;
} | #include <iostream>
static constexpr unsigned getSequenceLength(unsigned number) noexcept
{
unsigned length = 0;
while (number != 1) {
if ((number & 1) == 0) {
number >>= 1;
} else {
number = 3 * number + 1;
}
++length;
}
return length;
}
int main(int count, char *arguments[])
{
unsigned number = 999999;
unsigned sequenceLength = 0;
for (unsigned i = 999999; i > 0; --i) {
unsigned length = getSequenceLength(i);
if (length > sequenceLength) {
number = i;
sequenceLength = length;
}
}
std::cout << number << '\n';
return 0;
} |
Correct invalid capture (reference -> value) | // 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/Conditions/SelfCondition.hpp>
#include <Rosetta/Games/Game.hpp>
#include <utility>
namespace RosettaStone
{
SelfCondition::SelfCondition(std::function<bool(Entity*)> func)
: m_func(std::move(func))
{
// Do nothing
}
SelfCondition SelfCondition::IsControllingRace(Race race)
{
return SelfCondition([&](Entity* entity) -> bool {
for (auto& minion : entity->GetOwner().GetField().GetAllMinions())
{
if (minion->card.race == race)
{
return true;
}
}
return false;
});
}
bool SelfCondition::Evaluate(Entity* entity) const
{
return m_func(entity);
}
} // namespace RosettaStone
| // 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/Conditions/SelfCondition.hpp>
#include <Rosetta/Games/Game.hpp>
#include <utility>
namespace RosettaStone
{
SelfCondition::SelfCondition(std::function<bool(Entity*)> func)
: m_func(std::move(func))
{
// Do nothing
}
SelfCondition SelfCondition::IsControllingRace(Race race)
{
return SelfCondition([=](Entity* entity) -> bool {
for (auto& minion : entity->GetOwner().GetField().GetAllMinions())
{
if (minion->card.race == race)
{
return true;
}
}
return false;
});
}
bool SelfCondition::Evaluate(Entity* entity) const
{
return m_func(entity);
}
} // namespace RosettaStone
|
Add reference to _printf_float and _scanf_float so they are linked by linker | // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <stdio.h>
#include "Arduino.h"
extern "C" {
size_t _write(int handle, const unsigned char *buf, size_t bufSize)
{
/* Check for the command to flush all handles */
if (handle == -1) {
return 0;
}
/* Check for stdout and stderr (only necessary if FILE descriptors are enabled.) */
if (handle != 1 && handle != 2) {
return -1;
}
size_t nChars = 0;
for (; bufSize > 0; --bufSize, ++buf, ++nChars) {
Serial.write(*buf);
}
return nChars;
}
}
| // Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <stdio.h>
#include "Arduino.h"
asm(".global _printf_float");
asm(".global _scanf_float");
extern "C" {
size_t _write(int handle, const unsigned char *buf, size_t bufSize)
{
/* Check for the command to flush all handles */
if (handle == -1) {
return 0;
}
/* Check for stdout and stderr (only necessary if FILE descriptors are enabled.) */
if (handle != 1 && handle != 2) {
return -1;
}
size_t nChars = 0;
for (; bufSize > 0; --bufSize, ++buf, ++nChars) {
Serial.write(*buf);
}
return nChars;
}
}
|
Test for map that check objectgroup | #include "gtest\gtest.h"
#include "TiledFixture.h"
TEST_F(TiledFixture, map_attributes_should_be_parsed)
{
ASSERT_EQ("1.0", _parsedMap->get_version());
ASSERT_EQ("1.0.3", _parsedMap->get_tiledVersion());
ASSERT_EQ(Orientation::ORTOGNAL, _parsedMap->get_orientation());
ASSERT_EQ(RenderOrder::RIGHT_DOWN, _parsedMap->get_renderOrder());
ASSERT_EQ(10, _parsedMap->get_width());
ASSERT_EQ(10, _parsedMap->get_height());
ASSERT_EQ(32, _parsedMap->get_tileWidth());
ASSERT_EQ(32, _parsedMap->get_tileHeight());
}
| #include "gtest\gtest.h"
#include "TiledFixture.h"
TEST_F(TiledFixture, map_attributes_should_be_parsed)
{
ASSERT_EQ("1.0", _parsedMap->get_version());
ASSERT_EQ("1.0.3", _parsedMap->get_tiledVersion());
ASSERT_EQ(Orientation::ORTOGNAL, _parsedMap->get_orientation());
ASSERT_EQ(RenderOrder::RIGHT_DOWN, _parsedMap->get_renderOrder());
ASSERT_EQ(10, _parsedMap->get_width());
ASSERT_EQ(10, _parsedMap->get_height());
ASSERT_EQ(32, _parsedMap->get_tileWidth());
ASSERT_EQ(32, _parsedMap->get_tileHeight());
}
TEST_F(TiledFixture, map_should_have_TestObject_parsed)
{
auto group = _parsedMap->getObjectGroup("TestObject");
ASSERT_EQ(group.get_name(), "TestObject");
}
|
Use new version ToString method | #include "About.h"
#include "../resource.h"
#include "../Updater/Updater.h"
#include "../Updater/Version.h"
void About::Initialize() {
INIT_CONTROL(LBL_TITLE, Label, _title);
std::wstring version = Updater::MainAppVersionString();
_title.Text(L"3RVX " + version);
}
void About::LoadSettings() {
}
void About::SaveSettings() {
}
| #include "About.h"
#include "../resource.h"
#include "../Updater/Updater.h"
#include "../Updater/Version.h"
void About::Initialize() {
INIT_CONTROL(LBL_TITLE, Label, _title);
std::wstring version = Updater::MainAppVersion().ToString();
_title.Text(L"3RVX " + version);
}
void About::LoadSettings() {
}
void About::SaveSettings() {
}
|
Fix engine initialization on Linux | // Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.
#include "ApplicationLinux.h"
int main(int argc, char* argv[])
{
ouzel::ApplicationLinux application(argc, argv);
return application.run();
}
| // Copyright (C) 2017 Elviss Strazdins
// This file is part of the Ouzel engine.
#include "EngineLinux.h"
int main(int argc, char* argv[])
{
ouzel::EngineLinux engine(argc, argv);
return engine.run();
}
|
Fix session bus issue under service mode. | // Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "xwalk/dbus/dbus_manager.h"
#include <glib.h>
#include <string>
#include "base/bind.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread.h"
#include "dbus/bus.h"
namespace xwalk {
DBusManager::DBusManager() {}
DBusManager::~DBusManager() {
if (session_bus_)
session_bus_->ShutdownOnDBusThreadAndBlock();
}
scoped_refptr<dbus::Bus> DBusManager::session_bus() {
if (!session_bus_) {
base::Thread::Options thread_options;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
std::string thread_name = "Crosswalk D-Bus thread";
dbus_thread_.reset(new base::Thread(thread_name.c_str()));
dbus_thread_->StartWithOptions(thread_options);
dbus::Bus::Options options;
options.dbus_task_runner = dbus_thread_->message_loop_proxy();
// On Tizen 2.x DBUS_SESSION_ADDRESS points to a wrong path, so we set
// the correct one here.
options.bus_type = dbus::Bus::CUSTOM_ADDRESS;
options.address = base::StringPrintf(
"unix:path=/run/user/%s/dbus/user_bus_socket", g_get_user_name());
session_bus_ = new dbus::Bus(options);
}
return session_bus_;
}
} // namespace xwalk
| // Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "xwalk/dbus/dbus_manager.h"
#include <glib.h>
#include <string>
#include "base/bind.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread.h"
#include "dbus/bus.h"
namespace xwalk {
DBusManager::DBusManager() {}
DBusManager::~DBusManager() {
if (session_bus_)
session_bus_->ShutdownOnDBusThreadAndBlock();
}
scoped_refptr<dbus::Bus> DBusManager::session_bus() {
if (!session_bus_) {
base::Thread::Options thread_options;
thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
std::string thread_name = "Crosswalk D-Bus thread";
dbus_thread_.reset(new base::Thread(thread_name.c_str()));
dbus_thread_->StartWithOptions(thread_options);
dbus::Bus::Options options;
options.dbus_task_runner = dbus_thread_->message_loop_proxy();
session_bus_ = new dbus::Bus(options);
}
return session_bus_;
}
} // namespace xwalk
|
Write test results to a file for easier examination | #include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include "Suite.h"
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
setUpSuite();
// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
// Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );
// Add a listener that print dots as test run.
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener( &progress );
// Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
runner.run( controller );
// Print test in a compiler compatible format.
CPPUNIT_NS::CompilerOutputter* outputter =
CPPUNIT_NS::CompilerOutputter::defaultOutputter(&result, std::cout);
outputter->write();
delete outputter;
tearDownSuite();
return result.wasSuccessful() ? 0 : 1;
}
| #include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include "Suite.h"
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
setUpSuite();
// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
// Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );
// Add a listener that print dots as test run.
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener( &progress );
// Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
runner.run( controller );
// Print test results to a file
std::ofstream ofile("OgreTestResults.log");
CPPUNIT_NS::CompilerOutputter* outputter =
CPPUNIT_NS::CompilerOutputter::defaultOutputter(&result, ofile);
outputter->write();
delete outputter;
tearDownSuite();
return result.wasSuccessful() ? 0 : 1;
}
|
Test that we correctly deal with multiple copy constructors when detecting non-trivial special members for varargs calls. | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct X1 {
X1();
};
struct X2 {
X2();
~X2();
};
void vararg(...);
void f(X1 x1, X2 x2) {
vararg(x1); // okay
vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}}
}
namespace PR11131 {
struct S;
S &getS();
void f(...);
void g() {
(void)sizeof(f(getS()));
}
}
| // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct X1 {
X1();
};
struct X2 {
X2();
~X2();
};
struct X3 {
X3(const X3&) = default;
};
struct X4 {
X4(const X4&) = default;
X4(X4&);
};
void vararg(...);
void f(X1 x1, X2 x2, X3 x3, X4 x4) {
vararg(x1); // OK
vararg(x2); // expected-error{{cannot pass object of non-trivial type 'X2' through variadic function; call will abort at runtime}}
vararg(x3); // OK
vararg(x4); // expected-error{{cannot pass object of non-trivial type 'X4' through variadic function; call will abort at runtime}}
}
namespace PR11131 {
struct S;
S &getS();
void f(...);
void g() {
(void)sizeof(f(getS()));
}
}
|
Add first parameter when launching executable for unix | #include "ExecutableLauncherUnix.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <cstdlib>
using namespace clt::filesystem::operations;
void ExecutableLauncherUnix::execute(const entities::Path & path)
{
pid_t cpid;
cpid = fork();
switch (cpid) {
case -1: perror("fork");
break;
case 0:
execl(path.getValue().c_str(), ""); /* this is the child */
_exit(EXIT_FAILURE);
break;
default: waitpid(cpid, NULL, 0);
}
} | #include "ExecutableLauncherUnix.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <cstdlib>
using namespace clt::filesystem::operations;
void ExecutableLauncherUnix::execute(const entities::Path & path)
{
pid_t cpid;
cpid = fork();
switch (cpid) {
case -1: perror("fork");
break;
case 0:
execl(path.getValue().c_str(), path.getValue().c_str(), NULL, NULL); /* this is the child */
_exit(EXIT_FAILURE);
break;
default: waitpid(cpid, NULL, 0);
}
} |
Fix the not matching function declaration | #include "heapsort.hpp"
#include "heap.hpp"
#include "swap.hpp"
void heapsort(int *data, const int size_of_data)
{
binary_max_heap(data, size_of_data - 1);
do_heapsort(data, size_of_data - 1);
}
void do_heapsort(int *data, const int end)
{
if(end <= 0) return;
int k = 0;
swap(data[k], data[end]); /* data[end] has been sorted and from now, should NOT touch */
while(true)
{
if(2 * k + 2 < end) /* Have two child nodes */
{
if(data[k] < data[2 * k + 1] && data[2 * k + 1] >= data[2 * k + 2])
{
swap(data[k], data[2 * k + 1]);
k = 2 * k + 1;
}
else if(data[k] < data[2 * k + 2])
{
swap(data[k], data[2 * k + 2]);
k = 2 * k + 2;
}
else break;
}
else if(2 * k + 1 < end && data[k] < data[2 * k + 1]) /* Have one leaf node */
{
swap(data[k], data[2 * k + 1]);
k = 2 * k + 1;
}
else break;
}
return do_heapsort(data, end - 1);
}
| #include "heapsort.hpp"
#include "heap.hpp"
#include "swap.hpp"
void heapsort(int *data, const int size_of_data)
{
convert_to_binary_max_heap(data, size_of_data);
do_heapsort(data, size_of_data - 1);
}
void do_heapsort(int *data, const int end)
{
if(end <= 0) return;
int k = 0;
swap(data[k], data[end]); /* data[end] has been sorted and from now, should NOT touch */
while(true)
{
if(2 * k + 2 < end) /* Have two child nodes */
{
if(data[k] < data[2 * k + 1] && data[2 * k + 1] >= data[2 * k + 2])
{
swap(data[k], data[2 * k + 1]);
k = 2 * k + 1;
}
else if(data[k] < data[2 * k + 2])
{
swap(data[k], data[2 * k + 2]);
k = 2 * k + 2;
}
else break;
}
else if(2 * k + 1 < end && data[k] < data[2 * k + 1]) /* Have one leaf node */
{
swap(data[k], data[2 * k + 1]);
k = 2 * k + 1;
}
else break;
}
return do_heapsort(data, end - 1);
}
|
Fix tests after cache tweaks | #define BOOST_TEST_MODULE Bitcoin Test Suite
#include <boost/test/unit_test.hpp>
#include "db.h"
#include "txdb.h"
#include "main.h"
#include "wallet.h"
CWallet* pwalletMain;
CClientUIInterface uiInterface;
extern bool fPrintToConsole;
extern void noui_connect();
struct TestingSetup {
CCoinsViewDB *pcoinsdbview;
TestingSetup() {
fPrintToDebugger = true; // don't want to write to debug.log file
noui_connect();
bitdb.MakeMock();
pblocktree = new CBlockTreeDB(true);
pcoinsdbview = new CCoinsViewDB(true);
pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
LoadBlockIndex();
bool fFirstRun;
pwalletMain = new CWallet("wallet.dat");
pwalletMain->LoadWallet(fFirstRun);
RegisterWallet(pwalletMain);
}
~TestingSetup()
{
delete pwalletMain;
pwalletMain = NULL;
delete pcoinsTip;
delete pcoinsdbview;
delete pblocktree;
bitdb.Flush(true);
}
};
BOOST_GLOBAL_FIXTURE(TestingSetup);
void Shutdown(void* parg)
{
exit(0);
}
void StartShutdown()
{
exit(0);
}
| #define BOOST_TEST_MODULE Bitcoin Test Suite
#include <boost/test/unit_test.hpp>
#include "db.h"
#include "txdb.h"
#include "main.h"
#include "wallet.h"
CWallet* pwalletMain;
CClientUIInterface uiInterface;
extern bool fPrintToConsole;
extern void noui_connect();
struct TestingSetup {
CCoinsViewDB *pcoinsdbview;
TestingSetup() {
fPrintToDebugger = true; // don't want to write to debug.log file
noui_connect();
bitdb.MakeMock();
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
LoadBlockIndex();
bool fFirstRun;
pwalletMain = new CWallet("wallet.dat");
pwalletMain->LoadWallet(fFirstRun);
RegisterWallet(pwalletMain);
}
~TestingSetup()
{
delete pwalletMain;
pwalletMain = NULL;
delete pcoinsTip;
delete pcoinsdbview;
delete pblocktree;
bitdb.Flush(true);
}
};
BOOST_GLOBAL_FIXTURE(TestingSetup);
void Shutdown(void* parg)
{
exit(0);
}
void StartShutdown()
{
exit(0);
}
|
Make let_stuff_happen() wait longer under valgrind. | #include "mock/unittest_utils.hpp"
#include <stdlib.h>
#include "errors.hpp"
#include <boost/bind.hpp>
#include "arch/timing.hpp"
#include "arch/runtime/starter.hpp"
#include "utils.hpp" // randint
namespace mock {
temp_file_t::temp_file_t(const char *tmpl) {
size_t len = strlen(tmpl);
filename.init(len + 1);
memcpy(filename.data(), tmpl, len+1);
int fd = mkstemp(filename.data());
guarantee_err(fd != -1, "Couldn't create a temporary file");
close(fd);
}
temp_file_t::~temp_file_t() {
unlink(filename.data());
}
void let_stuff_happen() {
nap(100);
}
int randport() {
return 10000 + randint(20000);
}
void run_in_thread_pool(const boost::function<void()>& fun, int num_workers) {
::run_in_thread_pool(fun, num_workers);
}
} // namespace mock
| #include "mock/unittest_utils.hpp"
#include <stdlib.h>
#include "errors.hpp"
#include <boost/bind.hpp>
#include "arch/timing.hpp"
#include "arch/runtime/starter.hpp"
#include "utils.hpp" // randint
namespace mock {
temp_file_t::temp_file_t(const char *tmpl) {
size_t len = strlen(tmpl);
filename.init(len + 1);
memcpy(filename.data(), tmpl, len+1);
int fd = mkstemp(filename.data());
guarantee_err(fd != -1, "Couldn't create a temporary file");
close(fd);
}
temp_file_t::~temp_file_t() {
unlink(filename.data());
}
void let_stuff_happen() {
#ifdef VALGRIND
nap(2000);
#else
nap(100);
#endif
}
int randport() {
return 10000 + randint(20000);
}
void run_in_thread_pool(const boost::function<void()>& fun, int num_workers) {
::run_in_thread_pool(fun, num_workers);
}
} // namespace mock
|
Fix error: invalid static_cast from type ‘int(lua_State*)’ to type ‘void*’ | #include "lua.h"
extern "C"
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CODEGEARC__)
__declspec(dllimport)
#endif
int luaopen_luapbintf(lua_State* L);
int main() {
void * p = static_cast<void*>(luaopen_luapbintf);
return 0;
}
| #include "lua.h"
extern "C"
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__CODEGEARC__)
__declspec(dllimport)
#endif
int luaopen_luapbintf(lua_State* L);
int main() {
int (*pFun)(lua_State*);
pFun = luaopen_luapbintf;
return 0;
}
|
Add ConcatV2 to the list of same scale ops | /* Copyright 2022 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/compiler/mlir/quantization/tensorflow/utils/quant_spec.h"
#include <memory>
#include "tensorflow/compiler/mlir/lite/quantization/quantization_utils.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
namespace mlir {
namespace quant {
std::unique_ptr<OpQuantScaleSpec> GetTfQuantScaleSpec(Operation* op) {
auto scale_spec = std::make_unique<OpQuantScaleSpec>();
if (llvm::isa<
// clang-format off
// go/keep-sorted start
TF::IdentityOp,
TF::MaxPoolOp,
TF::ReshapeOp
// go/keep-sorted end
// clang-format on
>(op)) {
scale_spec->has_same_scale_requirement = true;
}
return scale_spec;
}
} // namespace quant
} // namespace mlir
| /* Copyright 2022 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/compiler/mlir/quantization/tensorflow/utils/quant_spec.h"
#include <memory>
#include "tensorflow/compiler/mlir/lite/quantization/quantization_utils.h"
#include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h"
namespace mlir {
namespace quant {
std::unique_ptr<OpQuantScaleSpec> GetTfQuantScaleSpec(Operation* op) {
auto scale_spec = std::make_unique<OpQuantScaleSpec>();
if (llvm::isa<
// clang-format off
// go/keep-sorted start
TF::ConcatV2Op,
TF::IdentityOp,
TF::MaxPoolOp,
TF::ReshapeOp
// go/keep-sorted end
// clang-format on
>(op)) {
scale_spec->has_same_scale_requirement = true;
}
return scale_spec;
}
} // namespace quant
} // namespace mlir
|
Make "duktape" the default javascript backend | #include <scriptzeug/ScriptContext.h>
#include <scriptzeug/Backend/AbstractScriptContext.h>
#include "BackendDuktape/DuktapeScriptContext.h"
#ifdef LIBZEUG_USE_V8
#include "BackendJavaScript/JSScriptContext.h"
#endif
using namespace reflectionzeug;
namespace scriptzeug
{
ScriptContext::ScriptContext(const std::string & backend)
: m_backend(nullptr)
{
// Create backend
if (backend == "duktape")
m_backend = new DuktapeScriptContext(this);
#ifdef LIBZEUG_USE_V8
if (backend == "javascript")
m_backend = new JSScriptContext(this);
#endif
}
ScriptContext::~ScriptContext()
{
// Release backend
if (m_backend)
delete m_backend;
}
void ScriptContext::registerObject(reflectionzeug::PropertyGroup * obj)
{
if (m_backend)
m_backend->registerObject(obj);
}
Variant ScriptContext::evaluate(const std::string & code)
{
if (m_backend)
return m_backend->evaluate(code);
else
return Variant();
}
} // namespace scriptzeug
| #include <scriptzeug/ScriptContext.h>
#include <scriptzeug/Backend/AbstractScriptContext.h>
#include "BackendDuktape/DuktapeScriptContext.h"
#ifdef LIBZEUG_USE_V8
#include "BackendJavaScript/JSScriptContext.h"
#endif
using namespace reflectionzeug;
namespace scriptzeug
{
ScriptContext::ScriptContext(const std::string & backend)
: m_backend(nullptr)
{
// Create backend
// Javascript (default: duktape)
// Duktape
if (backend == "duktape" || backend == "javascript" || backend == "js") {
m_backend = new DuktapeScriptContext(this);
}
// V8
#ifdef LIBZEUG_USE_V8
else if (backend == "v8") {
m_backend = new JSScriptContext(this);
}
#endif
}
ScriptContext::~ScriptContext()
{
// Release backend
if (m_backend)
delete m_backend;
}
void ScriptContext::registerObject(reflectionzeug::PropertyGroup * obj)
{
if (m_backend)
m_backend->registerObject(obj);
}
Variant ScriptContext::evaluate(const std::string & code)
{
if (m_backend)
return m_backend->evaluate(code);
else
return Variant();
}
} // namespace scriptzeug
|
Make it easier to disable tracing | //
// Copyright (c) 2002-2010 The ANGLE 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.
//
// debug.cpp: Debugging utilities.
#include "common/debug.h"
#include <stdio.h>
#include <stdarg.h>
namespace gl
{
void trace(const char *format, ...)
{
if (true)
{
if (format)
{
FILE *file = fopen("debug.txt", "a");
if (file)
{
va_list vararg;
va_start(vararg, format);
vfprintf(file, format, vararg);
va_end(vararg);
fclose(file);
}
}
}
}
}
| //
// Copyright (c) 2002-2010 The ANGLE 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.
//
// debug.cpp: Debugging utilities.
#include "common/debug.h"
#include <stdio.h>
#include <stdarg.h>
static bool trace_on = true;
namespace gl
{
void trace(const char *format, ...)
{
if (trace_on)
{
if (format)
{
FILE *file = fopen("debug.txt", "a");
if (file)
{
va_list vararg;
va_start(vararg, format);
vfprintf(file, format, vararg);
va_end(vararg);
fclose(file);
}
}
}
}
}
|
Check for some code gen. for PR6641 test. | // RUN: %clang_cc1 -emit-llvm-only -verify %s
// PR6641
extern "C" int printf(const char *, ...);
struct Foo {
Foo() : iFoo (2) {
printf("%p\n", this);
}
int iFoo;
};
typedef Foo (*T)[3][4];
T bar() {
return new Foo[2][3][4];
}
T bug(int i) {
return new Foo[i][3][4];
}
void pr(T a) {
for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++)
printf("%p\n", a[i][j]);
}
Foo *test() {
return new Foo[5];
}
int main() {
T f = bar();
pr(f);
f = bug(3);
pr(f);
Foo * g = test();
for (int i = 0; i < 5; i++)
printf("%d\n", g[i].iFoo);
return 0;
}
| // RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
// PR6641
extern "C" int printf(const char *, ...);
struct Foo {
Foo() : iFoo (2) {
printf("%p\n", this);
}
int iFoo;
};
typedef Foo (*T)[3][4];
T bar() {
return new Foo[2][3][4];
}
T bug(int i) {
return new Foo[i][3][4];
}
void pr(T a) {
for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++)
printf("%p\n", a[i][j]);
}
Foo *test() {
return new Foo[5];
}
int main() {
T f = bar();
pr(f);
f = bug(3);
pr(f);
Foo * g = test();
for (int i = 0; i < 5; i++)
printf("%d\n", g[i].iFoo);
return 0;
}
// CHECK: call noalias i8* @_Znam
// CHECK: call noalias i8* @_Znam
// CHECK: call noalias i8* @_Znam
|
Add TODO for C++17 non-const data() | // Copyright 2015, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Björn Buchhold (buchhold@informatik.uni-freiburg.de)
#include <algorithm>
#include "DocsDB.h"
#include "../global/Constants.h"
// _____________________________________________________________________________
void DocsDB::init(const string& fileName) {
_dbFile.open(fileName.c_str(), "r");
if (_dbFile.empty()) {
_size = 0;
} else {
off_t posLastOfft = _dbFile.getLastOffset(&_startOfOffsets);
_size = (posLastOfft - _startOfOffsets) / sizeof(off_t);
}
}
// _____________________________________________________________________________
string DocsDB::getTextExcerpt(Id cid) const {
off_t ft[2];
off_t& from = ft[0];
off_t& to = ft[1];
off_t at = _startOfOffsets + cid * sizeof(off_t);
at += _dbFile.read(ft, sizeof(ft), at);
while(to == from) {
at += _dbFile.read(&to, sizeof(off_t), at);
}
assert(to > from);
size_t nofBytes = static_cast<size_t>(to - from);
string line(nofBytes, '\0');
_dbFile.read(&line.front(), nofBytes, from);
return line;
}
| // Copyright 2015, University of Freiburg,
// Chair of Algorithms and Data Structures.
// Author: Björn Buchhold (buchhold@informatik.uni-freiburg.de)
#include <algorithm>
#include "DocsDB.h"
#include "../global/Constants.h"
// _____________________________________________________________________________
void DocsDB::init(const string& fileName) {
_dbFile.open(fileName.c_str(), "r");
if (_dbFile.empty()) {
_size = 0;
} else {
off_t posLastOfft = _dbFile.getLastOffset(&_startOfOffsets);
_size = (posLastOfft - _startOfOffsets) / sizeof(off_t);
}
}
// _____________________________________________________________________________
string DocsDB::getTextExcerpt(Id cid) const {
off_t ft[2];
off_t& from = ft[0];
off_t& to = ft[1];
off_t at = _startOfOffsets + cid * sizeof(off_t);
at += _dbFile.read(ft, sizeof(ft), at);
while(to == from) {
at += _dbFile.read(&to, sizeof(off_t), at);
}
assert(to > from);
size_t nofBytes = static_cast<size_t>(to - from);
string line(nofBytes, '\0');
// TODO in C++17 we'll get non-const pointer std::string::data() use it the
_dbFile.read(&line.front(), nofBytes, from);
return line;
}
|
Test the ability to compare value types. | #include "gtest/gtest.h"
TEST(TestValues, Length)
{
ASSERT_TRUE(false);
}
| #include "gtest/gtest.h"
TEST(TestValues, Length)
{
ASSERT_TRUE(false);
Meters myFirstLength();
Meters mySecondLength(1.53);
Centimeters myThirdLength(153.0);
// Test equality between mySecondLength and myThirdLength.
}
|
Make heartbeat LED pattern for aerial_v3 fancier. | #include <platform_config.hpp>
#include <hal_config.hpp>
namespace platform {
MPU6000 imu(&SPID1, &mpu6000_spicfg);
DefaultMultirotorVehicleSystem system(&imu, &imu);
void init() {
// Initialize platform HAL
i2cPlatformInit();
pwmPlatformInit();
spiPlatformInit();
usartPlatformInit();
// Initialize platform devices
imu.init();
system.init();
palSetPadMode(GPIOA, 6, PAL_MODE_OUTPUT_PUSHPULL);
}
msg_t HeartbeatThread::main(void) {
while(true) {
palSetPad(GPIOA, 6);
sleep(MS2ST(50));
palClearPad(GPIOA, 6);
sleep(MS2ST(950));
}
return 0;
}
}
| #include <platform_config.hpp>
#include <hal_config.hpp>
namespace platform {
MPU6000 imu(&SPID1, &mpu6000_spicfg);
DefaultMultirotorVehicleSystem system(&imu, &imu);
void init() {
// Initialize platform HAL
i2cPlatformInit();
pwmPlatformInit();
spiPlatformInit();
usartPlatformInit();
// Initialize platform devices
imu.init();
system.init();
palSetPadMode(GPIOA, 6, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOA, 7, PAL_MODE_OUTPUT_PUSHPULL);
}
msg_t HeartbeatThread::main(void) {
while(true) {
palSetPad(GPIOA, 6);
sleep(MS2ST(50));
palClearPad(GPIOA, 6);
palSetPad(GPIOA, 7);
sleep(MS2ST(50));
palClearPad(GPIOA, 7);
sleep(MS2ST(900));
}
return 0;
}
}
|
Use vector of bool instead of bitset that need to know their size at compile time | #include <omp.h>
#include "dispar.h"
#include "tournament.h"
template<typename T>
matrix createRandomTournamentPool(T container,
const size_t nbGroup,
const size_t poolSize) {
std::bitset<1> bs(container.size());
matrix pools(nbGroup);
size_t cardinality = 0;
for (auto&& pool: pools) {
pool.reserve(poolSize);
}
while(cardinality < nbGroup * poolSize) {
//int v = rand.nextInt(container.size());
int v = 0;
if(!bs[v]) {
bs[v];
cardinality++;
pools[cardinality / poolSize][cardinality % poolSize] = v;
}
}
return pools;
}
template<typename T, typename Alloc, template <typename, typename> class TT>
std::vector<int> selection(const size_t targetSize,
TT<T, Alloc> container,
std::function<void (const T&, const T&)> comparator) {
const size_t nbGroup = 1;
const size_t poolSize = 5;
std::vector<int> selected_keys;
selected_keys.reserve(targetSize);
matrix pools = createRandomTournamentPool(container, nbGroup, poolSize);
#pragma omp parallel for
for (int i = 0; i < pools.size(); i++) {
selected_keys.push_back(tournament<TT, T>(container, pools[i], comparator));
}
return selected_keys;
}
| #include <omp.h>
#include "dispar.h"
#include "tournament.h"
template<typename T>
matrix createRandomTournamentPool(T container,
const size_t nbGroup,
const size_t poolSize) {
std::vector<bool> bs(size);
matrix pools(nbGroup);
size_t cardinality = 0;
for (auto&& pool: pools) {
pool.reserve(poolSize);
}
while(cardinality < nbGroup * poolSize) {
//int v = rand.random_int(offset, size - 1);
int v = 0;
if(!bs[v]) {
bs[v];
bs[v] = true;
pools[cardinality / poolSize][cardinality % poolSize] = v;
cardinality++;
}
}
return pools;
}
template<typename T, typename Alloc, template <typename, typename> class TT>
std::vector<int> selection(const size_t targetSize,
TT<T, Alloc> container,
std::function<void (const T&, const T&)> comparator) {
const size_t nbGroup = 1;
const size_t poolSize = 5;
std::vector<int> selected_keys;
selected_keys.reserve(targetSize);
matrix pools = createRandomTournamentPool(container, nbGroup, poolSize);
#pragma omp parallel for
for (int i = 0; i < pools.size(); i++) {
selected_keys.push_back(tournament<TT, T>(container, pools[i], comparator));
}
return selected_keys;
}
|
Set returned mat to empty in base getDepthMat | #include "mediain.hpp"
MediaIn::MediaIn()
{
}
int MediaIn::frameCount(void) const
{
return -1;
}
int MediaIn::frameCounter(void) const
{
return -1;
}
void MediaIn::frameCounter(int frameCount)
{
(void)frameCount;
}
bool MediaIn::getDepthMat(cv::Mat &depthMat)
{
(void)depthMat;
return false;
}
double MediaIn::getDepth(int x, int y)
{
(void)x;
(void)y;
return -1000.;
}
| #include "mediain.hpp"
MediaIn::MediaIn()
{
}
int MediaIn::frameCount(void) const
{
return -1;
}
int MediaIn::frameCounter(void) const
{
return -1;
}
void MediaIn::frameCounter(int frameCount)
{
(void)frameCount;
}
bool MediaIn::getDepthMat(cv::Mat &depthMat)
{
depthMat = Mat(); // return empty mat to indicate no depth info
return false; // in addition to returning false
}
double MediaIn::getDepth(int x, int y)
{
(void)x;
(void)y;
return -1000.;
}
|
Disable a test until inlining CXXConstructExprs is fully investigated. | // RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
struct A {
int x;
A(int a) { x = a; }
int getx() const { return x; }
};
void f1() {
A x(3);
if (x.getx() == 3) {
int *p = 0;
*p = 3; // expected-warning{{Dereference of null pointer}}
} else {
int *p = 0;
*p = 3; // no-warning
}
}
void f2() {
const A &x = A(3);
if (x.getx() == 3) {
int *p = 0;
*p = 3; // expected-warning{{Dereference of null pointer}}
} else {
int *p = 0;
*p = 3; // no-warning
}
}
| // RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
// XFAIL: *
struct A {
int x;
A(int a) { x = a; }
int getx() const { return x; }
};
void f1() {
A x(3);
if (x.getx() == 3) {
int *p = 0;
*p = 3; // expected-warning{{Dereference of null pointer}}
} else {
int *p = 0;
*p = 3; // no-warning
}
}
void f2() {
const A &x = A(3);
if (x.getx() == 3) {
int *p = 0;
*p = 3; // expected-warning{{Dereference of null pointer}}
} else {
int *p = 0;
*p = 3; // no-warning
}
}
void f3() {
const A &x = (A)3;
if (x.getx() == 3) {
int *p = 0;
*p = 3; // expected-warning{{Dereference of null pointer}}
} else {
int *p = 0;
*p = 3; // no-warning
}
}
|
Fix SkNWayCanvas cons call when creating null canvas. | /*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkNullCanvas.h"
#include "SkCanvas.h"
#include "SKNWayCanvas.h"
SkCanvas* SkCreateNullCanvas() {
// An N-Way canvas forwards calls to N canvas's. When N == 0 it's
// effectively a null canvas.
return SkNEW(SkNWayCanvas);
}
| /*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkNullCanvas.h"
#include "SkCanvas.h"
#include "SKNWayCanvas.h"
SkCanvas* SkCreateNullCanvas() {
// An N-Way canvas forwards calls to N canvas's. When N == 0 it's
// effectively a null canvas.
return SkNEW(SkNWayCanvas(0,0));
}
|
Mark ExtensionApiTest.Storage as failing, it always fails on Windows after r110181. | // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_apitest.h"
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Storage) {
ASSERT_TRUE(RunExtensionTest("storage")) << message_;
}
| // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_apitest.h"
#if defined(OS_WIN)
// Always fails on Windows after r110181: http://crbug.com/104419.
#define MAYBE_Storage FAILS_Storage
#else
#define MAYBE_Storage Storage
#endif
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, MAYBE_Storage) {
ASSERT_TRUE(RunExtensionTest("storage")) << message_;
}
|
Undo previous - hard to distinguish errors | // friend class as template parameter
// originally found in package 'zipios'
// typechecking results:
// errors: 0
// warnings: 0
// error: k0069.cc:15:12: internal error: found dependent type `Friend' in non-template
// ERR-MATCH: internal error: found dependent type `[^(].*?' in non-template
template< class Type > struct T {
friend struct Friend ;
};
struct Friend;
typedef T< Friend > T1 ;
| // friend class as template parameter
// originally found in package 'zipios'
// typechecking results:
// errors: 0
// warnings: 0
// error: k0069.cc:15:12: internal error: found dependent type `Friend' in non-template
// ERR-MATCH: internal error: found dependent type `.*?' in non-template
template< class Type > struct T {
friend struct Friend ;
};
struct Friend;
typedef T< Friend > T1 ;
|
Remove unused constants causing warnings | #include "o2gft.h"
#include "o2google.h"
static const char *GftScope = "https://www.googleapis.com/auth/fusiontables";
static const char *GftEndpoint = "https://accounts.google.com/o/oauth2/auth";
static const char *GftTokenUrl = "https://accounts.google.com/o/oauth2/token";
static const char *GftRefreshUrl = "https://accounts.google.com/o/oauth2/token";
O2Gft::O2Gft(QObject *parent): O2Google(parent) {
setScope(GftScope);
}
| #include "o2gft.h"
#include "o2google.h"
static const char *GftScope = "https://www.googleapis.com/auth/fusiontables";
O2Gft::O2Gft(QObject *parent): O2Google(parent) {
setScope(GftScope);
}
|
Fix the constructor of Mutex_State_Error | /*************************************************
* Mutex Source File *
* (C) 1999-2006 The Botan Project *
*************************************************/
#include <botan/mutex.h>
namespace Botan {
/*************************************************
* Mutex_Holder Constructor *
*************************************************/
Mutex_Holder::Mutex_Holder(Mutex* m) : mux(m)
{
if(!mux)
throw Invalid_Argument("Mutex_Holder: Argument was NULL");
mux->lock();
}
/*************************************************
* Mutex_Holder Destructor *
*************************************************/
Mutex_Holder::~Mutex_Holder()
{
mux->unlock();
}
/*************************************************
* Default Mutex Factory *
*************************************************/
Mutex* Mutex_Factory::make()
{
class Default_Mutex : public Mutex
{
public:
class Mutex_State_Error : public Internal_Error
{
public:
Mutex_State_Error(const std::string& where)
{
set_msg("Default_Mutex::" + where + ": Mutex is already " +
where + "ed");
}
};
void lock()
{
if(locked)
throw Mutex_State_Error("lock");
locked = true;
}
void unlock()
{
if(!locked)
throw Mutex_State_Error("unlock");
locked = false;
}
Default_Mutex() { locked = false; }
private:
bool locked;
};
return new Default_Mutex;
}
}
| /*************************************************
* Mutex Source File *
* (C) 1999-2006 The Botan Project *
*************************************************/
#include <botan/mutex.h>
namespace Botan {
/*************************************************
* Mutex_Holder Constructor *
*************************************************/
Mutex_Holder::Mutex_Holder(Mutex* m) : mux(m)
{
if(!mux)
throw Invalid_Argument("Mutex_Holder: Argument was NULL");
mux->lock();
}
/*************************************************
* Mutex_Holder Destructor *
*************************************************/
Mutex_Holder::~Mutex_Holder()
{
mux->unlock();
}
/*************************************************
* Default Mutex Factory *
*************************************************/
Mutex* Mutex_Factory::make()
{
class Default_Mutex : public Mutex
{
public:
class Mutex_State_Error : public Internal_Error
{
public:
Mutex_State_Error(const std::string& where) :
Internal_Error("Default_Mutex::" + where + ": " +
"Mutex is already " + where + "ed") {}
};
void lock()
{
if(locked)
throw Mutex_State_Error("lock");
locked = true;
}
void unlock()
{
if(!locked)
throw Mutex_State_Error("unlock");
locked = false;
}
Default_Mutex() { locked = false; }
private:
bool locked;
};
return new Default_Mutex;
}
}
|
Handle inability to open a resource |
#include "Config.hpp"
#include <fstream>
#ifndef INSTALL_PREFIX
#error CMake has not defined INSTALL_PREFIX!
#endif
Json::Value Config::getQuorumNode()
{
return loadFile(INSTALL_PREFIX + "/lib/tor-onions/quorum.json");
}
Json::Value Config::getMirror()
{
return loadFile(INSTALL_PREFIX + "/lib/tor-onions/mirrors.json");
}
Json::Value Config::loadFile(const std::string& path)
{
Json::Value value;
std::ifstream file(path, std::ifstream::binary);
file >> value;
return value;
}
|
#include "Config.hpp"
#include "Log.hpp"
#include <fstream>
#ifndef INSTALL_PREFIX
#error CMake has not defined INSTALL_PREFIX!
#endif
Json::Value Config::getQuorumNode()
{
return loadFile(INSTALL_PREFIX + "/lib/tor-onions/quorum.json");
}
Json::Value Config::getMirror()
{
return loadFile(INSTALL_PREFIX + "/lib/tor-onions/mirrors.json");
}
Json::Value Config::loadFile(const std::string& path)
{
Json::Value value;
std::ifstream file;
file.open(path, std::ifstream::binary);
if (file.is_open())
file >> value;
else
Log::get().error("Cannot open resource " + path);
return value;
}
|
Remove window display. There is no X server on travis. | #include <iostream>
#include <gtest/gtest.h>
#include <GLFW/glfw3.h>
static void error_callback(int error, const char* description)
{
FAIL() << "GLFW Failed (" << error << "): " << description;
}
TEST(GLFWTests, BuildInvisibleWindow)
{
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
FAIL() << "GLFW failed to initialize";
glfwWindowHint(GLFW_VISIBLE, 0);
window = glfwCreateWindow(640, 480, "Invisible Example", NULL, NULL);
if (!window)
{
glfwTerminate();
FAIL() << "Failed to create glfw window";
}
glfwDestroyWindow(window);
glfwTerminate();
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
| #include <iostream>
#include <gtest/gtest.h>
#include <GLFW/glfw3.h>
static void error_callback(int error, const char* description)
{
FAIL() << "GLFW Failed (" << error << "): " << description;
}
TEST(GLFWTests, BuildInvisibleWindow)
{
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
if (!glfwInit())
FAIL() << "GLFW failed to initialize";
//glfwWindowHint(GLFW_VISIBLE, 0);
//window = glfwCreateWindow(640, 480, "Invisible Example", NULL, NULL);
//if (!window)
//{
// glfwTerminate();
// FAIL() << "Failed to create glfw window";
//}
//glfwDestroyWindow(window);
glfwTerminate();
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
Add the threadID viewing in the output | #include <sstream>
#include <boost/format.hpp>
#include "Colors.h"
#include "Trace.h"
Trace::Trace()
{
}
Trace::~Trace()
{
}
/* Add an instruction in the trace */
void Trace::addInstruction(Inst *instruction)
{
this->instructions.push_back(instruction);
}
/* Returns the instructions list in the trace */
std::list<Inst *> &Trace::getInstructions()
{
return this->instructions;
}
void Trace::display(std::ostream &os)
{
boost::format outputInstruction("%1% %|15t| %2% %|55t|");
for (auto inst : this->instructions){
uint64_t count = 0;
if (inst != nullptr) {
std::stringstream expr(""), colr(ENDC);
for (auto se : inst->getSymbolicElements()){
if (count == 0) expr << se->getExpression()->str();
else expr << std::endl << boost::format(outputInstruction) % "" % "" << se->getExpression()->str();
if (se->isTainted)
colr.str(GREEN);
count++;
}
os << colr.str()
<< boost::format(outputInstruction)
% boost::io::group(std::hex, std::showbase, inst->getAddress())
% inst->getDisassembly()
<< expr.str()
<< ENDC
<< std::endl;
}
}
}
| #include <sstream>
#include <boost/format.hpp>
#include "Colors.h"
#include "Trace.h"
Trace::Trace()
{
}
Trace::~Trace()
{
}
/* Add an instruction in the trace */
void Trace::addInstruction(Inst *instruction)
{
this->instructions.push_back(instruction);
}
/* Returns the instructions list in the trace */
std::list<Inst *> &Trace::getInstructions()
{
return this->instructions;
}
void Trace::display(std::ostream &os)
{
boost::format outputInstruction("[%1%] %|3t| %2% %|21t| %3% %|61t|");
boost::format outputExpression("%|61t|");
for (auto inst : this->instructions){
uint64_t count = 0;
if (inst != nullptr) {
std::stringstream expr(""), colr(ENDC);
for (auto se : inst->getSymbolicElements()){
if (count == 0) expr << se->getExpression()->str();
else expr << std::endl << boost::format(outputExpression) << se->getExpression()->str();
if (se->isTainted)
colr.str(GREEN);
count++;
}
os << colr.str()
<< boost::format(outputInstruction)
% std::to_string(inst->getThreadId())
% boost::io::group(std::hex, std::showbase, inst->getAddress())
% inst->getDisassembly()
<< expr.str()
<< ENDC
<< std::endl;
}
}
}
|
Remove GCC fix that is not needed | #include <exception>
//#if (__GLIBCXX__ / 10000) == 2014
namespace std {
inline bool uncaught_exception() noexcept(true)
{ return current_exception() != nullptr; }
} // namespace std
//#endif
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
| #define CATCH_CONFIG_MAIN
#include <catch.hpp>
|
Use --new-profile-management to set all related flags. | // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/profile_management_switches.h"
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "chrome/common/chrome_switches.h"
namespace {
const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";
bool CheckProfileManagementFlag(std::string command_switch, bool active_state) {
std::string trial_type =
base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
if (!trial_type.empty()) {
if (trial_type == "Enabled")
return active_state;
if (trial_type == "Disabled")
return !active_state;
}
return CommandLine::ForCurrentProcess()->HasSwitch(command_switch);
}
} // namespace
namespace switches {
bool IsEnableWebBasedSignin() {
return CheckProfileManagementFlag(switches::kEnableWebBasedSignin, false);
}
bool IsGoogleProfileInfo() {
return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true);
}
bool IsNewProfileManagement() {
return CheckProfileManagementFlag(switches::kNewProfileManagement, true);
}
} // namespace switches
| // Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/profile_management_switches.h"
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
#include "chrome/common/chrome_switches.h"
namespace {
const char kNewProfileManagementFieldTrialName[] = "NewProfileManagement";
bool CheckProfileManagementFlag(std::string command_switch, bool active_state) {
// Individiual flag settings take precedence.
if (CommandLine::ForCurrentProcess()->HasSwitch(command_switch)) {
return true;
}
// --new-profile-management flag always affects all switches.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kNewProfileManagement)) {
return active_state;
}
// NewProfileManagement experiment acts like above flag.
std::string trial_type =
base::FieldTrialList::FindFullName(kNewProfileManagementFieldTrialName);
if (!trial_type.empty()) {
if (trial_type == "Enabled")
return active_state;
if (trial_type == "Disabled")
return !active_state;
}
return false;
}
} // namespace
namespace switches {
bool IsEnableWebBasedSignin() {
return CheckProfileManagementFlag(switches::kEnableWebBasedSignin, false);
}
bool IsGoogleProfileInfo() {
return CheckProfileManagementFlag(switches::kGoogleProfileInfo, true);
}
bool IsNewProfileManagement() {
return CheckProfileManagementFlag(switches::kNewProfileManagement, true);
}
} // namespace switches
|
Delete code to call Destroy() method | // 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/DamageTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/DestroyTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/IncludeTask.hpp>
namespace RosettaStone::SimpleTasks
{
DamageTask::DamageTask(EntityType entityType, std::size_t damage,
bool isSpellDamage)
: ITask(entityType), m_damage(damage), m_isSpellDamage(isSpellDamage)
{
// Do nothing
}
TaskID DamageTask::GetTaskID() const
{
return TaskID::DAMAGE;
}
TaskStatus DamageTask::Impl(Player& player)
{
auto entities =
IncludeTask::GetEntities(m_entityType, player, m_source, m_target);
for (auto& entity : entities)
{
auto character = dynamic_cast<Character*>(entity);
Generic::TakeDamageToCharacter(
m_source, character, static_cast<int>(m_damage), m_isSpellDamage);
}
for (auto& entity : entities)
{
if (entity->isDestroyed)
{
entity->Destroy();
}
}
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/DamageTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/DestroyTask.hpp>
#include <Rosetta/Tasks/SimpleTasks/IncludeTask.hpp>
namespace RosettaStone::SimpleTasks
{
DamageTask::DamageTask(EntityType entityType, std::size_t damage,
bool isSpellDamage)
: ITask(entityType), m_damage(damage), m_isSpellDamage(isSpellDamage)
{
// Do nothing
}
TaskID DamageTask::GetTaskID() const
{
return TaskID::DAMAGE;
}
TaskStatus DamageTask::Impl(Player& player)
{
auto entities =
IncludeTask::GetEntities(m_entityType, player, m_source, m_target);
for (auto& entity : entities)
{
auto character = dynamic_cast<Character*>(entity);
Generic::TakeDamageToCharacter(
m_source, character, static_cast<int>(m_damage), m_isSpellDamage);
}
return TaskStatus::COMPLETE;
}
} // namespace RosettaStone::SimpleTasks
|
Add comment explaining test failure | // RUN: %clangxx -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// REQUIRES: stable-runtime
// XFAIL: ubsan
// FIXME(dliew): Make this test work on Darwin with LSan
// XFAIL: darwin && lsan
#include <sanitizer/common_interface_defs.h>
#include <stdio.h>
volatile char *zero = 0;
void Death() {
fprintf(stderr, "DEATH CALLBACK EXECUTED\n");
}
// CHECK: DEATH CALLBACK EXECUTED
char global;
volatile char *sink;
__attribute__((noinline))
void MaybeInit(int *uninitialized) {
if (zero)
*uninitialized = 1;
}
__attribute__((noinline))
void Leak() {
// Trigger lsan report. Two attempts in case the address of the first
// allocation remained on the stack.
sink = new char[100];
sink = new char[100];
}
int main(int argc, char **argv) {
int uninitialized;
__sanitizer_set_death_callback(Death);
MaybeInit(&uninitialized);
if (uninitialized) // trigger msan report.
global = 77;
sink = new char[100];
delete[] sink;
global = sink[0]; // use-after-free: trigger asan/tsan report.
Leak();
sink = 0;
}
| // RUN: %clangxx -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// REQUIRES: stable-runtime
// XFAIL: ubsan
// FIXME: On Darwin, LSAn detects the leak, but does not invoke the death_callback.
// XFAIL: darwin && lsan
#include <sanitizer/common_interface_defs.h>
#include <stdio.h>
volatile char *zero = 0;
void Death() {
fprintf(stderr, "DEATH CALLBACK EXECUTED\n");
}
// CHECK: DEATH CALLBACK EXECUTED
char global;
volatile char *sink;
__attribute__((noinline))
void MaybeInit(int *uninitialized) {
if (zero)
*uninitialized = 1;
}
__attribute__((noinline))
void Leak() {
// Trigger lsan report. Two attempts in case the address of the first
// allocation remained on the stack.
sink = new char[100];
sink = new char[100];
}
int main(int argc, char **argv) {
int uninitialized;
__sanitizer_set_death_callback(Death);
MaybeInit(&uninitialized);
if (uninitialized) // trigger msan report.
global = 77;
sink = new char[100];
delete[] sink;
global = sink[0]; // use-after-free: trigger asan/tsan report.
Leak();
sink = 0;
}
|
Add texture scene variants to default benchmarks | /*
* Copyright © 2017 Collabora Ltd.
*
* This file is part of vkmark.
*
* vkmark is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 2.1 of the License, or (at your option) any later version.
*
* vkmark is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with vkmark. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Alexandros Frantzis <alexandros.frantzis@collabora.com>
*/
#include "default_benchmarks.h"
std::vector<std::string> DefaultBenchmarks::get()
{
return std::vector<std::string>{
"vertex:device-local=true",
"vertex:device-local=false",
"shading:shading=gouraud",
"shading:shading=blinn-phong-inf",
"shading:shading=phong",
"shading:shading=cel",
"cube",
"clear"
};
}
| /*
* Copyright © 2017 Collabora Ltd.
*
* This file is part of vkmark.
*
* vkmark is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 2.1 of the License, or (at your option) any later version.
*
* vkmark is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with vkmark. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Alexandros Frantzis <alexandros.frantzis@collabora.com>
*/
#include "default_benchmarks.h"
std::vector<std::string> DefaultBenchmarks::get()
{
return std::vector<std::string>{
"vertex:device-local=true",
"vertex:device-local=false",
"texture:anisotropy=0",
"texture:anisotropy=16",
"shading:shading=gouraud",
"shading:shading=blinn-phong-inf",
"shading:shading=phong",
"shading:shading=cel",
"cube",
"clear"
};
}
|
Correct find_if_not predicate compile error. | //
// Copyright 2020 Google Inc.
//
// 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 "string_utils.h"
namespace gtx {
std::string TrimWhitespace(std::string str) {
auto first_nonwhitespace_iter =
std::find_if_not(str.begin(), str.end(), std::isspace);
auto trimmed_leading = str.substr(first_nonwhitespace_iter - str.begin(),
str.end() - first_nonwhitespace_iter);
auto last_nonwhitespace_iter = std::find_if_not(
trimmed_leading.rbegin(), trimmed_leading.rend(), std::isspace);
return trimmed_leading.substr(
0, trimmed_leading.rend() - last_nonwhitespace_iter);
}
} // namespace gtx
| //
// Copyright 2020 Google Inc.
//
// 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 "string_utils.h"
namespace gtx {
std::string TrimWhitespace(std::string str) {
auto first_nonwhitespace_iter = std::find_if_not(
str.begin(), str.end(), [](char c) { return std::isspace(c); });
auto trimmed_leading = str.substr(first_nonwhitespace_iter - str.begin(),
str.end() - first_nonwhitespace_iter);
auto last_nonwhitespace_iter =
std::find_if_not(trimmed_leading.rbegin(), trimmed_leading.rend(),
[](char c) { return std::isspace(c); });
return trimmed_leading.substr(
0, trimmed_leading.rend() - last_nonwhitespace_iter);
}
} // namespace gtx
|
Improve mixer test, no firm checks yet | #include <systemlib/mixer/mixer.h>
#include <systemlib/err.h>
#include "../../src/systemcmds/tests/tests.h"
int main(int argc, char *argv[]) {
warnx("Host execution started");
char* args[] = {argv[0], "../../ROMFS/px4fmu_common/mixers/IO_pass.mix",
"../../ROMFS/px4fmu_common/mixers/FMU_quad_w.mix"};
test_mixer(3, args);
test_conv(1, args);
}
| #include <systemlib/mixer/mixer.h>
#include <systemlib/err.h>
#include "../../src/systemcmds/tests/tests.h"
int main(int argc, char *argv[]) {
int ret;
warnx("Host execution started");
char* args[] = {argv[0], "../ROMFS/px4fmu_common/mixers/IO_pass.mix",
"../ROMFS/px4fmu_common/mixers/FMU_quad_w.mix"};
if (ret = test_mixer(3, args));
test_conv(1, args);
return 0;
}
|
Remove ClassImp as done for other classes in !139 | // local
#include "Object.hpp"
#include "core/utils/exceptions.h"
using namespace corryvreckan;
Object::Object() : m_detectorID(), m_timestamp(0) {}
Object::Object(std::string detectorID) : m_detectorID(detectorID), m_timestamp(0) {}
Object::Object(double timestamp) : m_detectorID(), m_timestamp(timestamp) {}
Object::Object(std::string detectorID, double timestamp) : m_detectorID(detectorID), m_timestamp(timestamp) {}
Object::~Object() {}
ClassImp(Object)
| // local
#include "Object.hpp"
#include "core/utils/exceptions.h"
using namespace corryvreckan;
Object::Object() : m_detectorID(), m_timestamp(0) {}
Object::Object(std::string detectorID) : m_detectorID(detectorID), m_timestamp(0) {}
Object::Object(double timestamp) : m_detectorID(), m_timestamp(timestamp) {}
Object::Object(std::string detectorID, double timestamp) : m_detectorID(detectorID), m_timestamp(timestamp) {}
Object::~Object() {}
|
Fix window title and initial size | #include "window_configuration.h"
const char *kFlutterWindowTitle = "taqo_client";
const unsigned int kFlutterWindowWidth = 1280;
const unsigned int kFlutterWindowHeight = 720;
| #include "window_configuration.h"
const char *kFlutterWindowTitle = "Taqo";
const unsigned int kFlutterWindowWidth = 1024;
const unsigned int kFlutterWindowHeight = 768;
|
Exit the pancake test with success instead of failure and print the hash values too. | /**
* \file PancakeTest.cpp
*
* Some simple tests to make sure the pancake domain works properly.
*
* \author eaburns
* \date 18-01-2010
*/
#include "pancake/PancakeTypes.hpp"
#include "pancake/PancakeState.hpp"
#include <stdlib.h>
int main(void)
{
boost::array<Pancake, 14> cakes;
for (unsigned int i = 0; i < 14; i += 1)
cakes[i] = i + 1;
PancakeState14 s(cakes);
std::cout << s << std::endl;
std::cout << s.flip(4) << std::endl;
std::cout << s.flip(5) << std::endl;
return EXIT_FAILURE;
}
| /**
* \file PancakeTest.cpp
*
* Some simple tests to make sure the pancake domain works properly.
*
* \author eaburns
* \date 18-01-2010
*/
#include "pancake/PancakeTypes.hpp"
#include "pancake/PancakeState.hpp"
#include <stdlib.h>
int main(void)
{
boost::array<Pancake, 14> cakes;
for (unsigned int i = 0; i < 14; i += 1)
cakes[i] = i + 1;
PancakeState14 s(cakes);
std::cout << s.get_hash_value() << ": " << s << std::endl;
std::cout << s s.get_hash_value() << ": " <<.flip(4) << std::endl;
std::cout << s s.get_hash_value() << ": " <<.flip(5) << std::endl;
return EXIT_SUCCESS;
}
|
Use File::create() instead of File::output_file_check() | /*
Copyright 2008 Brain Research Institute, Melbourne, Australia
Written by Robert E. Smith, 04/08/14.
This file is part of MRtrix.
MRtrix is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MRtrix is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MRtrix. If not, see <http://www.gnu.org/licenses/>.
*/
#include "file/ofstream.h"
#include "file/utils.h"
namespace MR
{
namespace File
{
void OFStream::open (const std::string& path, const std::ios_base::openmode mode)
{
if (!(mode & std::ios_base::app) && !(mode & std::ios_base::ate) && !(mode & std::ios_base::in))
if (!File::is_tempfile (path))
File::output_file_check (path);
std::ofstream::open (path.c_str(), mode);
if (std::ofstream::operator!())
throw Exception ("error opening output file \"" + path + "\": " + std::strerror (errno));
}
}
}
| /*
Copyright 2008 Brain Research Institute, Melbourne, Australia
Written by Robert E. Smith, 04/08/14.
This file is part of MRtrix.
MRtrix is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MRtrix is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MRtrix. If not, see <http://www.gnu.org/licenses/>.
*/
#include "file/ofstream.h"
#include "file/utils.h"
namespace MR
{
namespace File
{
void OFStream::open (const std::string& path, const std::ios_base::openmode mode)
{
if (!(mode & std::ios_base::app) && !(mode & std::ios_base::ate) && !(mode & std::ios_base::in)) {
if (!File::is_tempfile (path))
File::create (path);
}
std::ofstream::open (path.c_str(), mode);
if (std::ofstream::operator!())
throw Exception ("error opening output file \"" + path + "\": " + std::strerror (errno));
}
}
}
|
Convert to use Handlers. Could be simpler. | #include <unistd.h>
#include <event/event_callback.h>
#include <event/event_main.h>
#include <io/stream_handle.h>
class Sink {
LogHandle log_;
StreamHandle fd_;
Action *action_;
public:
Sink(int fd)
: log_("/sink"),
fd_(fd),
action_(NULL)
{
EventCallback *cb = callback(this, &Sink::read_complete);
action_ = fd_.read(0, cb);
}
~Sink()
{
ASSERT(log_, action_ == NULL);
}
void read_complete(Event e)
{
action_->cancel();
action_ = NULL;
switch (e.type_) {
case Event::Done:
case Event::EOS:
break;
default:
HALT(log_) << "Unexpected event: " << e;
return;
}
if (e.type_ == Event::EOS) {
SimpleCallback *cb = callback(this, &Sink::close_complete);
action_ = fd_.close(cb);
return;
}
EventCallback *cb = callback(this, &Sink::read_complete);
action_ = fd_.read(0, cb);
}
void close_complete(void)
{
action_->cancel();
action_ = NULL;
}
};
int
main(void)
{
Sink sink(STDIN_FILENO);
event_main();
}
| #include <unistd.h>
#include <event/callback_handler.h>
#include <event/event_callback.h>
#include <event/event_handler.h>
#include <event/event_main.h>
#include <io/stream_handle.h>
class Sink {
LogHandle log_;
StreamHandle fd_;
CallbackHandler close_handler_;
EventHandler read_handler_;
public:
Sink(int fd)
: log_("/sink"),
fd_(fd),
read_handler_()
{
read_handler_.handler(Event::Done, this, &Sink::read_done);
read_handler_.handler(Event::EOS, this, &Sink::read_eos);
close_handler_.handler(this, &Sink::close_done);
read_handler_.wait(fd_.read(0, read_handler_.callback()));
}
~Sink()
{ }
void read_done(Event)
{
read_handler_.wait(fd_.read(0, read_handler_.callback()));
}
void read_eos(Event)
{
close_handler_.wait(fd_.close(close_handler_.callback()));
}
void close_done(void)
{ }
};
int
main(void)
{
Sink sink(STDIN_FILENO);
event_main();
}
|
Fix triple / REQUIRES in test from r193685 | // RUN: c-index-test -test-load-source all -triple x86_64-apple-darwin10 -fasm-blocks -Wno-microsoft %s 2>&1 | FileCheck %s
// Test that we diagnose when the application hasn't initialized LLVM targets
// supporting the MS-style inline asm parser.
void Break() {
__asm { int 3 }
}
// CHECK: error: MS-style inline assembly is not available
| // REQUIRES: x86-registered-target
// RUN: c-index-test -test-load-source all -fasm-blocks -Wno-microsoft %s 2>&1 | FileCheck %s
// Test that we diagnose when the application hasn't initialized LLVM targets
// supporting the MS-style inline asm parser.
void Break() {
__asm { int 3 }
}
// CHECK: error: MS-style inline assembly is not available
|
Add interface for new Generate member functions | #include "gen.h"
#include "interface.h"
#include <iostream>
int main(int argc, char *argv[])
{
Generate Gen;
std::string Args;
int i;
for (i = 1; i < argc; i++) {
if (argv[i] != NULL)
Args = argv[1];
if (argv[i] == NULL) {
}
if ((Args == "-new") || (Args == "--new") || (Args == "-n")) {
Gen.GenBlankConfig();
return 1;
}
if ((Args == "-help") || (Args == "--help") || (Args == "-h")) {
printHelp();
}
if ((Args == "-debug") || (Args == "--debug")) {
Gen.CheckMake();
Gen.CheckFiles();
}
}
return 0;
}
| #include <iostream>
#include "gen.h"
#include "interface.h"
int main(int argc, char *argv[])
{
Generate Gen;
std::string Args;
int i;
for (i = 1; i < argc; i++) {
if (argv[i] != NULL)
Args = argv[1];
if (argv[i] == NULL) {
}
if ((Args == "-new") || (Args == "--new") || (Args == "-n")) {
Gen.GenBlankConfig();
return 1;
}
if ((Args == "-help") || (Args == "--help") || (Args == "-h")) {
printHelp();
}
if ((Args == "-debug") || (Args == "--debug")) {
Gen.CheckMake();
Gen.WriteMake();
Gen.GenMakeFromTemplate();
Gen.WalkDir(Gen.currentDir, ".\\.cpp$", FS_DEFAULT | FS_MATCHDIRS);
Gen.WalkDir(Gen.currentDir, ".\\.h$", FS_DEFAULT | FS_MATCHDIRS);
}
}
return 0;
}
|
Fix strcmp include in lib | // Copyright 2014 Toggl Desktop developers.
#include "./client.h"
#include <sstream>
namespace kopsik {
std::string Client::String() {
std::stringstream ss;
ss << "ID=" << id_
<< " local_id=" << local_id_
<< " name=" << name_
<< " wid=" << wid_
<< " guid=" << guid_;
return ss.str();
}
void Client::SetID(Poco::UInt64 value) {
if (id_ != value) {
id_ = value;
dirty_ = true;
}
}
void Client::SetName(std::string value) {
if (name_ != value) {
name_ = value;
dirty_ = true;
}
}
void Client::SetUID(Poco::UInt64 value) {
if (uid_ != value) {
uid_ = value;
dirty_ = true;
}
}
void Client::SetGUID(std::string value) {
if (guid_ != value) {
guid_ = value;
dirty_ = true;
}
}
void Client::SetWID(Poco::UInt64 value) {
if (wid_ != value) {
wid_ = value;
dirty_ = true;
}
}
bool CompareClientByName(Client *a, Client *b) {
return (strcmp(a->Name().c_str(), b->Name().c_str()) < 0);
}
} // namespace kopsik
| // Copyright 2014 Toggl Desktop developers.
#include "./client.h"
#include <sstream>
#include <cstring>
namespace kopsik {
std::string Client::String() {
std::stringstream ss;
ss << "ID=" << id_
<< " local_id=" << local_id_
<< " name=" << name_
<< " wid=" << wid_
<< " guid=" << guid_;
return ss.str();
}
void Client::SetID(Poco::UInt64 value) {
if (id_ != value) {
id_ = value;
dirty_ = true;
}
}
void Client::SetName(std::string value) {
if (name_ != value) {
name_ = value;
dirty_ = true;
}
}
void Client::SetUID(Poco::UInt64 value) {
if (uid_ != value) {
uid_ = value;
dirty_ = true;
}
}
void Client::SetGUID(std::string value) {
if (guid_ != value) {
guid_ = value;
dirty_ = true;
}
}
void Client::SetWID(Poco::UInt64 value) {
if (wid_ != value) {
wid_ = value;
dirty_ = true;
}
}
bool CompareClientByName(Client *a, Client *b) {
return (strcmp(a->Name().c_str(), b->Name().c_str()) < 0);
}
} // namespace kopsik
|
Return the correct Rect value for the anchor. | //
// simple_item.cc
// GameEngine
//
// Created by Jon Sharkey on 2010-04-30.
// Copyright 2010 Sharkable. All rights reserved.
//
#include "gameengine/entities/simple_item.h"
#include "gameengine/resource_loader.h"
using std::vector;
SimpleItem::SimpleItem()
: Animatable(),
sprite_(0) {
}
SimpleItem::SimpleItem(Sprite sprite, GamePoint position)
: Animatable(position),
sprite_(0) {
sprites_.push_back(sprite);
}
SimpleItem::SimpleItem(vector<Sprite> sprites, GamePoint position)
: Animatable(position),
sprites_(sprites),
sprite_(0) {
}
SimpleItem::~SimpleItem() {
for (int i = 0; i < sprites_.size(); i++) {
// TODO ResourceLoader::Instance().ReleaseResource(sprites_[i].texture());
}
}
#pragma mark - ViewEntity
void SimpleItem::Render(GamePoint render_offset, float render_angle) {
sprites_[sprite_].Draw(position() + render_offset, angle() + render_angle, alpha(), zoom());
}
GameRect SimpleItem::Rect() {
return game_rect_make(position(), sprites_[sprite_].content_size());
}
| //
// simple_item.cc
// GameEngine
//
// Created by Jon Sharkey on 2010-04-30.
// Copyright 2010 Sharkable. All rights reserved.
//
#include "gameengine/entities/simple_item.h"
#include "gameengine/resource_loader.h"
using std::vector;
SimpleItem::SimpleItem()
: Animatable(),
sprite_(0) {
}
SimpleItem::SimpleItem(Sprite sprite, GamePoint position)
: Animatable(position),
sprite_(0) {
sprites_.push_back(sprite);
}
SimpleItem::SimpleItem(vector<Sprite> sprites, GamePoint position)
: Animatable(position),
sprites_(sprites),
sprite_(0) {
}
SimpleItem::~SimpleItem() {
for (int i = 0; i < sprites_.size(); i++) {
// TODO ResourceLoader::Instance().ReleaseResource(sprites_[i].texture());
}
}
#pragma mark - ViewEntity
void SimpleItem::Render(GamePoint render_offset, float render_angle) {
sprites_[sprite_].Draw(position() + render_offset, angle() + render_angle, alpha(), zoom());
}
GameRect SimpleItem::Rect() {
SpriteAnchor anchor = sprites_[sprite_].anchor();
switch (anchor) {
case kSpriteAnchorTopLeft:
return game_rect_make(position(), sprites_[sprite_].content_size());
case kSpriteAnchorCenter:
GameSize content_size = sprites_[sprite_].content_size();
GamePoint origin = position() - game_point_make(content_size.width / 2.f,
content_size.height / 2.f);
return game_rect_make(origin, content_size);
}
}
|
Change to traditional style for function return type declarations rather than new trailing return type syntax - it is more consistent with rest of example code and shorter | // C++11 passing exceptions around using std::exception_ptr
#include <exception>
#include <thread>
#include <iostream>
#include <cassert>
std::exception_ptr g_stashed_exception_ptr;
auto bad_task() -> void
{
try
{
std::thread().detach(); // Oops !!
}
catch ( ... )
{
g_stashed_exception_ptr = std::current_exception();
}
}
auto main() -> int
{
assert( g_stashed_exception_ptr == nullptr );
assert( !g_stashed_exception_ptr );
std::thread task( bad_task );
task.join();
assert( g_stashed_exception_ptr != nullptr );
assert( g_stashed_exception_ptr );
try
{
std::rethrow_exception( g_stashed_exception_ptr );
}
catch ( std::exception & e )
{
std::cerr << "Task failed exceptionally: " << e.what() << "\n";
}
}
| // C++11 passing exceptions around using std::exception_ptr
#include <exception>
#include <thread>
#include <iostream>
#include <cassert>
std::exception_ptr g_stashed_exception_ptr;
void bad_task()
{
try
{
std::thread().detach(); // Oops !!
}
catch ( ... )
{
g_stashed_exception_ptr = std::current_exception();
}
}
int main()
{
assert( g_stashed_exception_ptr == nullptr );
assert( !g_stashed_exception_ptr );
std::thread task( bad_task );
task.join();
assert( g_stashed_exception_ptr != nullptr );
assert( g_stashed_exception_ptr );
try
{
std::rethrow_exception( g_stashed_exception_ptr );
}
catch ( std::exception & e )
{
std::cerr << "Task failed exceptionally: " << e.what() << "\n";
}
}
|
Check that the ExtensionFunction has a callback for attempting to send a response. | // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_function.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
void ExtensionFunction::SendResponse(bool success) {
if (success) {
dispatcher_->SendResponse(this);
} else {
// TODO(aa): In case of failure, send the error message to an error
// callback.
}
}
| // Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/extension_function.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
void ExtensionFunction::SendResponse(bool success) {
if (success) {
if (has_callback()) {
dispatcher_->SendResponse(this);
}
} else {
// TODO(aa): In case of failure, send the error message to an error
// callback.
}
}
|
Change include on generated C++ | #include <cpp/tasks.hh>
namespace cpp
{
void cpp_generator()
{
assert(ast::program_ast && "No ast to transform to cpp");
std::cout << "#include <repy/repy.hh>" << std::endl;
CodeGenerator cgen(std::cout);
cgen.visit(ast::program_ast);
cgen.generate_main();
}
void header_generator()
{
assert(ast::program_ast && "No ast to transform to cpp header");
HeaderGenerator hgen(std::cout);
hgen.visit(ast::program_ast);
}
} // namespace cpp
| #include <cpp/tasks.hh>
namespace cpp
{
void cpp_generator()
{
assert(ast::program_ast && "No ast to transform to cpp");
CodeGenerator cgen(std::cout);
cgen.visit(ast::program_ast);
cgen.generate_main();
}
void header_generator()
{
assert(ast::program_ast && "No ast to transform to cpp header");
std::cout << "#include <repy/repy.hh>" << std::endl;
HeaderGenerator hgen(std::cout);
hgen.visit(ast::program_ast);
}
} // namespace cpp
|
Revert part of my last commit. the mingw32 build bot doesn't seem to like it. | //===-- MCAsmInfoCOFF.cpp - COFF asm properties -----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines target asm properties related what form asm statements
// should take in general on COFF-based targets
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCAsmInfoCOFF.h"
#include "llvm/ADT/SmallVector.h"
using namespace llvm;
MCAsmInfoCOFF::MCAsmInfoCOFF() {
GlobalPrefix = "_";
COMMDirectiveAlignmentIsInBytes = false;
HasLCOMMDirective = true;
HasSetDirective = false;
HasDotTypeDotSizeDirective = false;
HasSingleParameterDotFile = false;
PrivateGlobalPrefix = "L"; // Prefix for private global symbols
WeakRefDirective = "\t.weak\t";
LinkOnceDirective = "\t.linkonce discard\n";
// Doesn't support visibility:
HiddenVisibilityAttr = ProtectedVisibilityAttr = MCSA_Invalid;
// Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
SupportsDebugInformation = true;
DwarfSectionOffsetDirective = "\t.secrel32\t";
HasMicrosoftFastStdCallMangling = true;
}
| //===-- MCAsmInfoCOFF.cpp - COFF asm properties -----------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines target asm properties related what form asm statements
// should take in general on COFF-based targets
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCAsmInfoCOFF.h"
#include "llvm/ADT/SmallVector.h"
using namespace llvm;
MCAsmInfoCOFF::MCAsmInfoCOFF() {
GlobalPrefix = "_";
COMMDirectiveAlignmentIsInBytes = false;
HasLCOMMDirective = true;
HasDotTypeDotSizeDirective = false;
HasSingleParameterDotFile = false;
PrivateGlobalPrefix = "L"; // Prefix for private global symbols
WeakRefDirective = "\t.weak\t";
LinkOnceDirective = "\t.linkonce discard\n";
// Doesn't support visibility:
HiddenVisibilityAttr = ProtectedVisibilityAttr = MCSA_Invalid;
// Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
SupportsDebugInformation = true;
DwarfSectionOffsetDirective = "\t.secrel32\t";
HasMicrosoftFastStdCallMangling = true;
}
|
Make so it reads from stdin if no argument is given | #include <iostream>
#include <vector>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
// printes the hex (in ascii) of an ascii message
int main(int argc, char* argv[])
{
if(argc < 2) {
cerr << "Usage: " << argv[0] << " m, where m is a string " << endl;
return -1;
}
std::string m(argv[1]);
if(m.length() < 1)
{
cerr << "m must have length > 0" << endl;
return -1;
}
for(int i = 0; i < m.size(); ++i)
{
unsigned char ch = m[i];
cout << hex << setw(2) << setfill('0') << (unsigned int)ch;
}
cout << dec << endl;
return 0;
}
| #include <iostream>
#include <vector>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
// printes the hex (in ascii) of an ascii message
int main(int argc, char* argv[])
{
if(argc < 1 || (argc>=2 && strcmp(argv[1],"-h")==0)) {
cerr << "Usage: " << argv[0] << " [-h] [m], where m is a string." << endl;
cerr << "If no argument is given, string is read from stdin" << endl;
return -1;
}
std::string m;
if(argc >= 2)
{
m = argv[1];
}
else
{
getline(cin, m);
}
if(m.length() < 1)
{
cerr << "m must have length > 0" << endl;
return -1;
}
for(int i = 0; i < m.size(); ++i)
{
unsigned char ch = m[i];
cout << hex << setw(2) << setfill('0') << (unsigned int)ch;
}
cout << dec << endl;
return 0;
}
|
Add support for .caf extension | #include "audioutil.h"
#include <QFileInfo>
namespace AudioUtil {
QStringList audioExtensions = { "wav", "aif", "ogg", "flac", "iff", "svx" };
bool isAudioFileName(QString file)
{
return audioExtensions.contains(QFileInfo(file).suffix().toLower());
}
QString audioFileFilter()
{
QString f = "Audio Files (";
for (int i = 0; i < audioExtensions.length(); i++)
{
if (i > 0) {
f.append(" ");
}
f.append("*.");
f.append(audioExtensions[i]);
}
f.append(")");
return f;
}
}
| #include "audioutil.h"
#include <QFileInfo>
namespace AudioUtil {
QStringList audioExtensions = { "wav", "caf", "aif", "ogg", "flac", "iff", "svx" };
bool isAudioFileName(QString file)
{
return audioExtensions.contains(QFileInfo(file).suffix().toLower());
}
QString audioFileFilter()
{
QString f = "Audio Files (";
for (int i = 0; i < audioExtensions.length(); i++)
{
if (i > 0) {
f.append(" ");
}
f.append("*.");
f.append(audioExtensions[i]);
}
f.append(")");
return f;
}
}
|
Fix test breakage due to example not being built. | // RUN: rm -rf %t
// RUN: mkdir %t
// RUN: echo '[{"directory":".","command":"clang++ '$(llvm-config --cppflags all)' -c %s","file":"%s"}]' > %t/compile_commands.json
// RUN: remove-cstr-calls %t %s | FileCheck %s
#include <string>
namespace llvm { struct StringRef { StringRef(const char *p); }; }
void f1(const std::string &s) {
f1(s.c_str()); // CHECK:remove-cstr-calls.cpp:11:6:11:14:s
}
void f2(const llvm::StringRef r) {
std::string s;
f2(s.c_str()); // CHECK:remove-cstr-calls.cpp:15:6:15:14:s
}
void f3(const llvm::StringRef &r) {
std::string s;
f3(s.c_str()); // CHECK:remove-cstr-calls.cpp:19:6:19:14:s
}
| // RUN: rm -rf %t
// RUN: mkdir %t
// RUN: echo '[{"directory":".","command":"clang++ '$(llvm-config --cppflags all)' -c %s","file":"%s"}]' > %t/compile_commands.json
// RUN: remove-cstr-calls %t %s | FileCheck %s
// XFAIL: *
#include <string>
namespace llvm { struct StringRef { StringRef(const char *p); }; }
void f1(const std::string &s) {
f1(s.c_str()); // CHECK:remove-cstr-calls.cpp:11:6:11:14:s
}
void f2(const llvm::StringRef r) {
std::string s;
f2(s.c_str()); // CHECK:remove-cstr-calls.cpp:15:6:15:14:s
}
void f3(const llvm::StringRef &r) {
std::string s;
f3(s.c_str()); // CHECK:remove-cstr-calls.cpp:19:6:19:14:s
}
|
Clean up main entry point. | #include "tests-base.hpp"
#include "utf8rewind.h"
int main(int argc, char** argv)
{
const char* input = "Hello World!";
static const size_t output_size = 256;
char output[output_size];
wchar_t output_wide[output_size];
const char* input_seek;
size_t converted_size;
int32_t errors;
memset(output, 0, output_size * sizeof(char));
memset(output_wide, 0, output_size * sizeof(wchar_t));
/*
Convert input to uppercase:
"Hello World!" -> "HELLO WORLD!"
*/
converted_size = utf8toupper(
input, strlen(input),
output, output_size - 1,
&errors);
if (converted_size == 0 ||
errors != UTF8_ERR_NONE)
{
return -1;
}
/*
Convert UTF-8 input to wide (UTF-16 or UTF-32) encoded text:
"HELLO WORLD!" -> L"HELLO WORLD!"
*/
converted_size = utf8towide(
output, strlen(output),
output_wide, (output_size - 1) * sizeof(wchar_t),
&errors);
if (converted_size == 0 ||
errors != UTF8_ERR_NONE)
{
return -1;
}
/*
Seek in input:
"Hello World!" -> "World!"
*/
input_seek = utf8seek(input, input, 6, SEEK_SET);
::testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
return result;
} | #include "tests-base.hpp"
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
if (result != 0)
{
std::cout << "Press any key to continue.";
int wait = 0;
std::cin >> wait;
}
return result;
} |
Include "build/build_config.h" explicitly because we test the OS_WIN macro. | // 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/histogram.h"
#include "net/base/net_test_suite.h"
#if defined(OS_WIN)
#include "net/socket/ssl_client_socket_nss_factory.h"
#endif
int main(int argc, char** argv) {
// Record histograms, so we can get histograms data in tests.
StatisticsRecorder recorder;
NetTestSuite test_suite(argc, argv);
#if defined(OS_WIN)
// Use NSS for SSL on Windows. TODO(wtc): this should eventually be hidden
// inside DefaultClientSocketFactory::CreateSSLClientSocket.
net::ClientSocketFactory::SetSSLClientSocketFactory(
net::SSLClientSocketNSSFactory);
// We want to be sure to init NSPR on the main thread.
base::EnsureNSPRInit();
#endif
// TODO(phajdan.jr): Enforce test isolation, http://crbug.com/12710.
return test_suite.Run();
}
| // 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 "build/build_config.h"
#include "base/histogram.h"
#include "net/base/net_test_suite.h"
#if defined(OS_WIN)
#include "net/socket/ssl_client_socket_nss_factory.h"
#endif
int main(int argc, char** argv) {
// Record histograms, so we can get histograms data in tests.
StatisticsRecorder recorder;
NetTestSuite test_suite(argc, argv);
#if defined(OS_WIN)
// Use NSS for SSL on Windows. TODO(wtc): this should eventually be hidden
// inside DefaultClientSocketFactory::CreateSSLClientSocket.
net::ClientSocketFactory::SetSSLClientSocketFactory(
net::SSLClientSocketNSSFactory);
// We want to be sure to init NSPR on the main thread.
base::EnsureNSPRInit();
#endif
// TODO(phajdan.jr): Enforce test isolation, http://crbug.com/12710.
return test_suite.Run();
}
|
Add more test cases to packaged_task copyability test | //===----------------------------------------------------------------------===//
//
// 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: libcpp-has-no-threads
// UNSUPPORTED: c++98, c++03
// <future>
// class packaged_task<R(ArgTypes...)>
// template <class F>
// packaged_task(F&& f);
// These constructors shall not participate in overload resolution if
// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
#include <future>
#include <cassert>
struct A {};
typedef std::packaged_task<A(int, char)> PT;
typedef volatile std::packaged_task<A(int, char)> VPT;
int main()
{
VPT init{};
PT p{init}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task<A (int, char)>')}}
// expected-note@future:* 1 {{candidate template ignored: disabled by 'enable_if'}}
}
| //===----------------------------------------------------------------------===//
//
// 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: libcpp-has-no-threads
// UNSUPPORTED: c++98, c++03
// <future>
// class packaged_task<R(ArgTypes...)>
// template <class F>
// packaged_task(F&& f);
// These constructors shall not participate in overload resolution if
// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
#include <future>
#include <cassert>
struct A {};
typedef std::packaged_task<A(int, char)> PT;
typedef volatile std::packaged_task<A(int, char)> VPT;
int main()
{
VPT init{};
auto const& c_init = init;
PT p1{init}; // expected-error {{no matching constructor}}
PT p2{c_init}; // expected-error {{no matching constructor}}
PT p3{std::move(init)}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task<A (int, char)>')}}
}
|
Fix test on Android i686/fugu | // RUN: %clangxx_asan %s -o %t && %run %t | FileCheck %s
#include <stdio.h>
static void foo() {
printf("foo\n");
}
int main() {
return 0;
}
__attribute__((section(".preinit_array")))
void (*call_foo)(void) = &foo;
__attribute__((section(".init_array")))
void (*call_foo_2)(void) = &foo;
__attribute__((section(".fini_array")))
void (*call_foo_3)(void) = &foo;
// CHECK: foo
// CHECK: foo
// CHECK: foo
| // RUN: %clangxx_asan %s -o %t && %run %t | FileCheck %s
#include <stdio.h>
int c = 0;
static void foo() {
++c;
}
static void fini() {
printf("fini\n");
}
int main() {
printf("c=%d\n", c);
return 0;
}
__attribute__((section(".preinit_array")))
void (*call_foo)(void) = &foo;
__attribute__((section(".init_array")))
void (*call_foo_2)(void) = &foo;
__attribute__((section(".fini_array")))
void (*call_foo_3)(void) = &fini;
// CHECK: c=2
// CHECK: fini
|
Call agclose when clearing the graph | #include "QGVGraphPrivate.h"
QGVGraphPrivate::QGVGraphPrivate(Agraph_t *graph)
{
setGraph(graph);
}
void QGVGraphPrivate::setGraph(Agraph_t *graph)
{
_graph = graph;
}
Agraph_t* QGVGraphPrivate::graph() const
{
return _graph;
}
| #include "QGVGraphPrivate.h"
QGVGraphPrivate::QGVGraphPrivate(Agraph_t *graph)
: _graph (NULL)
{
setGraph(graph);
}
void QGVGraphPrivate::setGraph(Agraph_t *graph)
{
if (_graph != NULL)
agclose(_graph);
_graph = graph;
}
Agraph_t* QGVGraphPrivate::graph() const
{
return _graph;
}
|
Fix post, put, erase for tasks to follow the changes | #include "stdafx.h"
#include "internal/internal_datastore.h"
#include "internal/constants.h"
#include "datastore.h"
namespace You {
namespace DataStore {
DataStore& DataStore::get() {
static DataStore ds;
return ds;
}
Transaction DataStore::begin() {
return Internal::DataStore::get().begin();
}
void DataStore::post(TaskId taskId, const KeyValuePairs& task) {
Internal::DataStore::get().post(taskId, task);
}
void DataStore::put(TaskId taskId, const KeyValuePairs& task) {
Internal::DataStore::get().put(taskId, task);
}
void DataStore::erase(TaskId taskId) {
Internal::DataStore::get().erase(taskId);
}
std::vector<KeyValuePairs> DataStore::getAllTasks() {
return Internal::DataStore::get().getAll(Internal::TASKS_NODE);
}
std::vector<KeyValuePairs> DataStore::getAllResources() {
return Internal::DataStore::get().getAll(Internal::RESOURCES_NODE);
}
} // namespace DataStore
} // namespace You
| #include "stdafx.h"
#include "internal/internal_datastore.h"
#include "internal/constants.h"
#include "datastore.h"
namespace You {
namespace DataStore {
DataStore& DataStore::get() {
static DataStore ds;
return ds;
}
Transaction DataStore::begin() {
return Internal::DataStore::get().begin();
}
void DataStore::post(TaskId taskId, const KeyValuePairs& task) {
std::wstring stringId = boost::lexical_cast<std::wstring>(taskId);
Internal::DataStore::get().post(Internal::TASKS_NODE, stringId, task);
}
void DataStore::put(TaskId taskId, const KeyValuePairs& task) {
std::wstring stringId = boost::lexical_cast<std::wstring>(taskId);
Internal::DataStore::get().put(Internal::TASKS_NODE, stringId, task);
}
void DataStore::erase(TaskId taskId) {
std::wstring stringId = boost::lexical_cast<std::wstring>(taskId);
Internal::DataStore::get().erase(Internal::TASKS_NODE, stringId);
}
std::vector<KeyValuePairs> DataStore::getAllTasks() {
return Internal::DataStore::get().getAll(Internal::TASKS_NODE);
}
std::vector<KeyValuePairs> DataStore::getAllResources() {
return Internal::DataStore::get().getAll(Internal::RESOURCES_NODE);
}
} // namespace DataStore
} // namespace You
|
Change sanity check for perfomance test of bilateral filter | #include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace perf;
using namespace testing;
using std::tr1::make_tuple;
using std::tr1::get;
CV_ENUM(Mat_Type, CV_8UC1, CV_8UC3, CV_32FC1, CV_32FC3)
typedef TestBaseWithParam< tr1::tuple<Size, int, Mat_Type> > TestBilateralFilter;
PERF_TEST_P( TestBilateralFilter, BilateralFilter,
Combine(
Values( szVGA, sz1080p ), // image size
Values( 3, 5 ), // d
Mat_Type::all() // image type
)
)
{
Size sz;
int d, type;
const double sigmaColor = 1., sigmaSpace = 1.;
sz = get<0>(GetParam());
d = get<1>(GetParam());
type = get<2>(GetParam());
Mat src(sz, type);
Mat dst(sz, type);
declare.in(src, WARMUP_RNG).out(dst).time(20);
TEST_CYCLE() bilateralFilter(src, dst, d, sigmaColor, sigmaSpace, BORDER_DEFAULT);
SANITY_CHECK(dst);
}
| #include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace perf;
using namespace testing;
using std::tr1::make_tuple;
using std::tr1::get;
CV_ENUM(Mat_Type, CV_8UC1, CV_8UC3, CV_32FC1, CV_32FC3)
typedef TestBaseWithParam< tr1::tuple<Size, int, Mat_Type> > TestBilateralFilter;
PERF_TEST_P( TestBilateralFilter, BilateralFilter,
Combine(
Values( szVGA, sz1080p ), // image size
Values( 3, 5 ), // d
Mat_Type::all() // image type
)
)
{
Size sz;
int d, type;
const double sigmaColor = 1., sigmaSpace = 1.;
sz = get<0>(GetParam());
d = get<1>(GetParam());
type = get<2>(GetParam());
Mat src(sz, type);
Mat dst(sz, type);
declare.in(src, WARMUP_RNG).out(dst).time(20);
TEST_CYCLE() bilateralFilter(src, dst, d, sigmaColor, sigmaSpace, BORDER_DEFAULT);
SANITY_CHECK(dst, .01, ERROR_RELATIVE);
}
|
Fix name of class and constructor | #include <ncurses.h>
#include "lightsout.hpp"
namespace roadagain
{
lightsout::lightsout(int width, int height) : width(width), height(height)
{
lights = new bool*[height + 2]();
for (int i = 0; i < height + 2; i++){
lights[i] = new bool[width + 2]();
}
}
lightsout::~lightsout()
{
;
}
}
| #include <ncurses.h>
#include "lightsout.hpp"
namespace roadagain
{
board::board(int width, int height) : width(width), height(height)
{
lights = new bool*[height + 2]();
for (int i = 0; i < height + 2; i++){
lights[i] = new bool[width + 2]();
}
}
board::~board()
{
;
}
}
|
Remove output_spontaneous use for now. | #include <common/buffer.h>
#include <event/action.h>
#include <event/callback.h>
#include <event/event_system.h>
#include <io/pipe.h>
#include <xcodec/xcodec.h>
#include <xcodec/xcodec_encoder.h>
#include <xcodec/xcodec_encoder_pipe.h>
XCodecEncoderPipe::XCodecEncoderPipe(XCodec *codec)
: PipeSimple("/xcodec/encoder/pipe"),
encoder_(codec)
{
encoder_.set_pipe(this);
}
XCodecEncoderPipe::~XCodecEncoderPipe()
{
encoder_.set_pipe(NULL);
}
void
XCodecEncoderPipe::output_ready(void)
{
PipeSimple::output_spontaneous();
}
bool
XCodecEncoderPipe::process(Buffer *out, Buffer *in)
{
encoder_.encode(out, in);
return (true);
}
| #include <common/buffer.h>
#include <event/action.h>
#include <event/callback.h>
#include <event/event_system.h>
#include <io/pipe.h>
#include <xcodec/xcodec.h>
#include <xcodec/xcodec_encoder.h>
#include <xcodec/xcodec_encoder_pipe.h>
XCodecEncoderPipe::XCodecEncoderPipe(XCodec *codec)
: PipeSimple("/xcodec/encoder/pipe"),
encoder_(codec)
{
encoder_.set_pipe(this);
}
XCodecEncoderPipe::~XCodecEncoderPipe()
{
encoder_.set_pipe(NULL);
}
void
XCodecEncoderPipe::output_ready(void)
{
}
bool
XCodecEncoderPipe::process(Buffer *out, Buffer *in)
{
encoder_.encode(out, in);
return (true);
}
|
Add a HelloBuilder unit test. | #include "ofp/unittest.h"
#include "ofp/hello.h"
using namespace ofp;
TEST(hello, HelloBuilder1) {
HelloBuilder msg{ProtocolVersions{1, 2, 3, 4}};
MemoryChannel channel{99};
msg.send(&channel);
EXPECT_EQ(0x10, channel.size());
EXPECT_HEX("0400-0010-00000001 00010008-0000001E", channel.data(),
channel.size());
}
TEST(hello, HelloBuilder2) {
HelloBuilder msg{ProtocolVersions{1, 4}};
MemoryChannel channel{OFP_VERSION_1};
msg.send(&channel);
EXPECT_EQ(0x10, channel.size());
EXPECT_HEX("0400-0010-00000001 00010008-00000012", channel.data(),
channel.size());
}
TEST(hello, HelloBuilder3) {
HelloBuilder msg{ProtocolVersions{1}};
MemoryChannel channel{OFP_VERSION_4};
msg.send(&channel);
EXPECT_EQ(0x08, channel.size());
EXPECT_HEX("0100-0008-00000001", channel.data(), channel.size());
}
| #include "ofp/unittest.h"
#include "ofp/hello.h"
using namespace ofp;
TEST(hello, HelloBuilder1) {
HelloBuilder msg{ProtocolVersions{1, 2, 3, 4}};
MemoryChannel channel{99};
msg.send(&channel);
EXPECT_EQ(0x10, channel.size());
EXPECT_HEX("0400-0010-00000001 00010008-0000001E", channel.data(),
channel.size());
}
TEST(hello, HelloBuilder2) {
HelloBuilder msg{ProtocolVersions{1, 4}};
MemoryChannel channel{OFP_VERSION_1};
msg.send(&channel);
EXPECT_EQ(0x10, channel.size());
EXPECT_HEX("0400-0010-00000001 00010008-00000012", channel.data(),
channel.size());
}
TEST(hello, HelloBuilder3) {
HelloBuilder msg{ProtocolVersions{1}};
MemoryChannel channel{OFP_VERSION_4};
msg.send(&channel);
EXPECT_EQ(0x08, channel.size());
EXPECT_HEX("0100-0008-00000001", channel.data(), channel.size());
}
TEST(hello, HelloBuilder4) {
HelloBuilder msg{OFP_VERSION_1};
MemoryChannel channel{0};
msg.send(&channel);
EXPECT_EQ(0x08, channel.size());
EXPECT_HEX("0100-0008-00000001", channel.data(), channel.size());
}
|
Make lambda capture *pointer* to ``this`` by value | #include <map>
#include <ncurses.h>
#include <string>
#include "file_contents.hh"
#include "mode.hh"
#include "show_message.hh"
#include "prefix.hh"
prefix::prefix(std::string message)
: message(message) { }
void prefix::push_back(char ch, std::function<void(contents&, boost::optional<int>)> fun) {
this->map[ch] = fun;
}
void prefix::operator()(contents& cont, boost::optional<int> op) {
show_message(message + "-");
char ch = getch();
auto it = map.find(ch);
if(it == map.end()) {
show_message(std::string("Didn't recognize key sequence: '")
+ message + '-' + ch + '\'');
} else {
it->second(cont, op);
showing_message = false;
}
}
prefix::operator std::function < void ( contents&,
boost::optional<int> ) > () {
return std::function < void ( contents&,
boost::optional<int> ) >
([&,this] (contents& cont, boost::optional<int> op)
{
(*this)(cont,op);
});
}
| #include <map>
#include <ncurses.h>
#include <string>
#include "file_contents.hh"
#include "mode.hh"
#include "show_message.hh"
#include "prefix.hh"
prefix::prefix(std::string message)
: message(message) { }
void prefix::push_back(char ch, std::function<void(contents&, boost::optional<int>)> fun) {
this->map[ch] = fun;
}
void prefix::operator()(contents& cont, boost::optional<int> op) {
show_message(message + "-");
char ch = getch();
auto it = map.find(ch);
if(it == map.end()) {
show_message(std::string("Didn't recognize key sequence: '")
+ message + '-' + ch + '\'');
} else {
it->second(cont, op);
showing_message = false;
}
}
prefix::operator std::function < void ( contents&,
boost::optional<int> ) > () {
return std::function < void ( contents&,
boost::optional<int> ) >
([this] (contents& cont, boost::optional<int> op)
{
(*this)(cont,op);
});
}
|
Add StaticRandom component to registration. | #include "Registration.hpp"
#include "comp/StaticObjRefID.hpp"
#include "comp/Transform.hpp"
#include "comp/ConstantRotation.hpp"
#include "comp/CameraSelect.hpp"
#include "comp/ClickBox2D.hpp"
#include "comp/StaticCamera.hpp"
#include "comp/StaticOrthoCamera.hpp"
#include "comp/StaticMouseInput.hpp"
#include "comp/StaticKeyboardInput.hpp"
#include "comp/StaticScreenDims.hpp"
#include "comp/StaticGlobalTime.hpp"
#include "systems/ConstantRotationSys.hpp"
#include "systems/ClickBox2DSys.hpp"
namespace gen {
void registerAll(CPM_ES_CEREAL_NS::CerealCore& core)
{
// Register systems
registerSystem_ConstantRotation();
registerSystem_ClickBox2D();
// Register components
core.registerComponent<ConstantRotation>();
core.registerComponent<Transform>();
core.registerComponent<CameraSelect>();
core.registerComponent<ClickBox2D>();
core.registerComponent<StaticMouseInput>();
core.registerComponent<StaticKeyboardInput>();
core.registerComponent<StaticScreenDims>();
core.registerComponent<StaticGlobalTime>();
core.registerComponent<StaticCamera>();
core.registerComponent<StaticOrthoCamera>();
core.registerComponent<StaticObjRefID>();
}
} // namespace gen
| #include "Registration.hpp"
#include "comp/StaticObjRefID.hpp"
#include "comp/Transform.hpp"
#include "comp/ConstantRotation.hpp"
#include "comp/CameraSelect.hpp"
#include "comp/ClickBox2D.hpp"
#include "comp/StaticCamera.hpp"
#include "comp/StaticOrthoCamera.hpp"
#include "comp/StaticMouseInput.hpp"
#include "comp/StaticKeyboardInput.hpp"
#include "comp/StaticScreenDims.hpp"
#include "comp/StaticGlobalTime.hpp"
#include "comp/StaticRandom.hpp"
#include "systems/ConstantRotationSys.hpp"
#include "systems/ClickBox2DSys.hpp"
namespace gen {
void registerAll(CPM_ES_CEREAL_NS::CerealCore& core)
{
// Register systems
registerSystem_ConstantRotation();
registerSystem_ClickBox2D();
// Register components
core.registerComponent<ConstantRotation>();
core.registerComponent<Transform>();
core.registerComponent<CameraSelect>();
core.registerComponent<ClickBox2D>();
core.registerComponent<StaticMouseInput>();
core.registerComponent<StaticKeyboardInput>();
core.registerComponent<StaticScreenDims>();
core.registerComponent<StaticGlobalTime>();
core.registerComponent<StaticCamera>();
core.registerComponent<StaticOrthoCamera>();
core.registerComponent<StaticObjRefID>();
core.registerComponent<StaticRandom>();
}
} // namespace gen
|
Fix intentional bug in example module | #include "core/example_module.hpp"
using namespace core;
int ExampleModule::getme(void){
return -value;
}
void ExampleModule::setme(int newvalue){
value = newvalue;
}
| #include "core/example_module.hpp"
using namespace core;
int ExampleModule::getme(void){
return value;
}
void ExampleModule::setme(int newvalue){
value = newvalue;
}
|
Update leetcode solution for problem 226 | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode *invertTree(TreeNode *root) {
if (!root || (!root->left && !root->right))
return root;
auto t = root->left;
root->left = root->right;
root->right = t;
if (root->left)
invertTree(root->left);
if (root->right)
invertTree(root->right);
return root;
}
}; | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode *invertTree(TreeNode *root) {
if (!root || (!root->left && !root->right)) {
return root;
}
auto t = root->left;
root->left = root->right;
root->right = t;
invertTree(root->left);
invertTree(root->right);
return root;
}
}; |
Fix the dash pattern examples in the documentation of QPen | //! [0]
QPainter painter(this);
QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
painter.setPen(pen);
//! [0]
//! [1]
QPainter painter(this);
QPen pen(); // creates a default pen
pen.setStyle(Qt::DashDotLine);
pen.setWidth(3);
pen.setBrush(Qt::green);
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
painter.setPen(pen);
//! [1]
//! [2]
QPen pen;
QVector<qreal> dashes;
qreal space = 4;
dashes << 1 << space << 3 << space << 9 << space
<< 27 << space << 9;
pen.setDashPattern(dashes);
//! [2]
//! [3]
QPen pen;
QVector<qreal> dashes;
qreal space = 4;
dashes << 1 << space << 3 << space << 9 << space
<< 27 << space << 9;
pen.setDashPattern(dashes);
//! [3]
| //! [0]
QPainter painter(this);
QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin);
painter.setPen(pen);
//! [0]
//! [1]
QPainter painter(this);
QPen pen(); // creates a default pen
pen.setStyle(Qt::DashDotLine);
pen.setWidth(3);
pen.setBrush(Qt::green);
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
painter.setPen(pen);
//! [1]
//! [2]
QPen pen;
QVector<qreal> dashes;
qreal space = 4;
dashes << 1 << space << 3 << space << 9 << space
<< 27 << space << 9 << space;
pen.setDashPattern(dashes);
//! [2]
//! [3]
QPen pen;
QVector<qreal> dashes;
qreal space = 4;
dashes << 1 << space << 3 << space << 9 << space
<< 27 << space << 9 << space;
pen.setDashPattern(dashes);
//! [3]
|
Remove dependency on Google argument parsing. |
#include "client.h"
DEFINE_string(config_filename, "", "Where to find the config file.");
int main(int argc, char* argv[]) {
InitGoogle(argv[0], &argc, &argv, true);
grr::Client::StaticInit();
grr::Client client(FLAGS_config_filename);
client.Run();
return 0;
}
|
#include "client.h"
int main(int argc, char* argv[]) {
grr::Client::StaticInit();
if (argc != 2) {
GOOGLE_LOG(FATAL) << "Usage is: client <config>";
}
grr::Client client(argv[1]);
client.Run();
return 0;
}
|
Make slider the foreground window upon Show() | #include "VolumeSlider.h"
#include "..\Controllers\Volume\CoreAudio.h"
#include "..\Error.h"
#include "..\Settings.h"
#include "..\Skin.h"
#include "SliderKnob.h"
VolumeSlider::VolumeSlider(CoreAudio &volumeCtrl) :
SliderWnd(L"3RVX-VolumeSlider", L"3RVX Volume Slider"),
_settings(*Settings::Instance()),
_volumeCtrl(volumeCtrl) {
Skin *skin = _settings.CurrentSkin();
Gdiplus::Bitmap *bg = skin->ControllerBgImg("volume");
BackgroundImage(bg);
_knob = skin->Knob("volume");
_vertical = _knob->Vertical();
std::list<Meter*> meters = skin->Meters("volume");
for (Meter *m : meters) {
AddMeter(m);
}
Knob(_knob);
}
void VolumeSlider::SliderChanged() {
_volumeCtrl.Volume(_knob->Value());
}
void VolumeSlider::MeterLevels(float level) {
if (Visible() && _dragging == false) {
MeterWnd::MeterLevels(level);
Update();
}
_level = level;
}
void VolumeSlider::Show() {
MeterWnd::MeterLevels(_level);
Update();
SliderWnd::Show();
}
bool VolumeSlider::Visible() {
return _visible;
} | #include "VolumeSlider.h"
#include "..\Controllers\Volume\CoreAudio.h"
#include "..\Error.h"
#include "..\Settings.h"
#include "..\Skin.h"
#include "SliderKnob.h"
VolumeSlider::VolumeSlider(CoreAudio &volumeCtrl) :
SliderWnd(L"3RVX-VolumeSlider", L"3RVX Volume Slider"),
_settings(*Settings::Instance()),
_volumeCtrl(volumeCtrl) {
Skin *skin = _settings.CurrentSkin();
Gdiplus::Bitmap *bg = skin->ControllerBgImg("volume");
BackgroundImage(bg);
_knob = skin->Knob("volume");
_vertical = _knob->Vertical();
std::list<Meter*> meters = skin->Meters("volume");
for (Meter *m : meters) {
AddMeter(m);
}
Knob(_knob);
}
void VolumeSlider::SliderChanged() {
_volumeCtrl.Volume(_knob->Value());
}
void VolumeSlider::MeterLevels(float level) {
if (Visible() && _dragging == false) {
MeterWnd::MeterLevels(level);
Update();
}
_level = level;
}
void VolumeSlider::Show() {
MeterWnd::MeterLevels(_level);
Update();
SliderWnd::Show();
SetActiveWindow(_hWnd);
SetForegroundWindow(_hWnd);
}
bool VolumeSlider::Visible() {
return _visible;
} |
Make imul early exits optional, disabled | #include "common.th"
// c <- multiplicand
// d <- multiplier
// b -> product
.global imul
imul:
pushall(h,i,j)
b <- 0
i <- d == 0
i <- c == 0 + i
i <- i <> 0
jnzrel(i, L_done)
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
L_done:
popall(h,i,j)
ret
| #include "common.th"
// c <- multiplicand
// d <- multiplier
// b -> product
.global imul
imul:
pushall(h,i,j)
b <- 0
#if IMUL_EARLY_EXITS
i <- d == 0
i <- c == 0 + i
i <- i <> 0
jnzrel(i, L_done)
#endif
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
L_done:
popall(h,i,j)
ret
|
Use std::transform in Curve codec | #pragma once
#include "CurveWrapperCodec.h"
namespace spotify
{
namespace json
{
using CurveWrapper = noise::module::Wrapper<noise::module::Curve>;
codec::object_t<CurveWrapper> default_codec_t<CurveWrapper>::codec()
{
auto codec = codec::object<CurveWrapper>();
codec.required("type", codec::eq<std::string>("Curve"));
codec.required("SourceModule", codec::ignore_t<int>());
codec.optional("ControlPoints",
[](const CurveWrapper& mw)
{
std::vector<std::pair<double, double>> all_control_points;
const noise::module::ControlPoint* raw_control_points = mw.module->GetControlPointArray();
const int control_point_count = mw.module->GetControlPointCount();
for (int i = 0; i < control_point_count; i++)
{
const noise::module::ControlPoint control_point = raw_control_points[i];
all_control_points.push_back({control_point.inputValue, control_point.outputValue});
}
return all_control_points;
},
[](CurveWrapper& mw, std::vector<std::pair<double, double>> all_control_points)
{
for (std::pair<double, double> control_point : all_control_points)
{
mw.module->AddControlPoint(control_point.first, control_point.second);
}
},
default_codec<std::vector<std::pair<double, double>>>());
return codec;
}
}
}
| #pragma once
#include "CurveWrapperCodec.h"
namespace spotify
{
namespace json
{
using CurveWrapper = noise::module::Wrapper<noise::module::Curve>;
codec::object_t<CurveWrapper> default_codec_t<CurveWrapper>::codec()
{
auto codec = codec::object<CurveWrapper>();
codec.required("type", codec::eq<std::string>("Curve"));
codec.required("SourceModule", codec::ignore_t<int>());
codec.optional("ControlPoints",
[](const CurveWrapper& mw)
{
std::vector<std::pair<double, double>> all_control_points;
const noise::module::ControlPoint* raw_control_points = mw.module->GetControlPointArray();
const int control_point_count = mw.module->GetControlPointCount();
std::transform(raw_control_points,
raw_control_points + control_point_count,
std::inserter(all_control_points, all_control_points.begin()),
[](noise::module::ControlPoint control_point)
{
return std::make_pair(control_point.inputValue, control_point.outputValue);
});
return all_control_points;
},
[](CurveWrapper& mw, std::vector<std::pair<double, double>> all_control_points)
{
for (std::pair<double, double> control_point : all_control_points)
{
mw.module->AddControlPoint(control_point.first, control_point.second);
}
},
default_codec<std::vector<std::pair<double, double>>>());
return codec;
}
}
}
|
Update test case to deal with name variable change (NFC) | // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instrument=clang | FileCheck %s
struct Member {
~Member();
};
struct A {
virtual ~A();
};
struct B : A {
Member m;
virtual ~B();
};
// Base dtor
// CHECK: @__profn__ZN1BD2Ev = private constant [9 x i8] c"_ZN1BD2Ev"
// Complete dtor must not be instrumented
// CHECK-NOT: @__profn__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"
// Deleting dtor must not be instrumented
// CHECK-NOT: @__profn__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"
// Base dtor counters and profile data
// CHECK: @__profc__ZN1BD2Ev = private global [1 x i64] zeroinitializer
// CHECK: @__profd__ZN1BD2Ev =
// Complete dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD1Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD1Ev =
// Deleting dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD0Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD0Ev =
B::~B() { }
| // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -main-file-name cxx-virtual-destructor-calls.cpp %s -o - -fprofile-instrument=clang | FileCheck %s
struct Member {
~Member();
};
struct A {
virtual ~A();
};
struct B : A {
Member m;
virtual ~B();
};
// Base dtor counters and profile data
// CHECK: @__profc__ZN1BD2Ev = private global [1 x i64] zeroinitializer
// CHECK: @__profd__ZN1BD2Ev =
// Complete dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD1Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD1Ev =
// Deleting dtor counters and profile data must absent
// CHECK-NOT: @__profc__ZN1BD0Ev = private global [1 x i64] zeroinitializer
// CHECK-NOT: @__profd__ZN1BD0Ev =
B::~B() { }
|
Change AuthProvider to be handled by unique_ptr. | #include "CuteHMILockScreenQMLPlugin.hpp"
#include "cutehmi/lock_screen/Auth.hpp"
#include <QtQml>
void CuteHMILockScreenQMLPlugin::registerTypes(const char * uri)
{
Q_ASSERT(uri == QLatin1String("CuteHMI.LockScreen"));
qmlRegisterSingletonType<cutehmi::lockscreen::Auth>(uri, 1, 0, "Auth", AuthProvider);
}
QObject * CuteHMILockScreenQMLPlugin::AuthProvider(QQmlEngine * engine, QJSEngine * scriptEngine)
{
Q_UNUSED(scriptEngine)
cutehmi::lockscreen::Auth *interface = new cutehmi::lockscreen::Auth();
engine->setObjectOwnership(interface, QQmlEngine::CppOwnership);
return interface;
}
| #include "CuteHMILockScreenQMLPlugin.hpp"
#include "cutehmi/lock_screen/Auth.hpp"
#include <QtQml>
#include <memory>
void CuteHMILockScreenQMLPlugin::registerTypes(const char * uri)
{
Q_ASSERT(uri == QLatin1String("CuteHMI.LockScreen"));
qmlRegisterSingletonType<cutehmi::lockscreen::Auth>(uri, 1, 0, "Auth", AuthProvider);
}
QObject * CuteHMILockScreenQMLPlugin::AuthProvider(QQmlEngine * engine, QJSEngine * scriptEngine)
{
Q_UNUSED(scriptEngine)
Q_UNUSED(engine)
std::unique_ptr<cutehmi::lockscreen::Auth> instance(new cutehmi::lockscreen::Auth);
return instance.release();
}
|
Fix findbar visibility when switching between tabs. | // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/dropdown_bar_host.h"
#include "base/logging.h"
#include "ui/aura/window.h"
#include "ui/views/widget/widget.h"
using content::WebContents;
NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent(
const WebContents* contents,
const views::KeyEvent& key_event) {
return NativeWebKeyboardEvent(key_event.native_event());
}
void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos,
bool no_redraw) {
if (!host_->IsVisible())
host_->GetNativeView()->Show();
host_->GetNativeView()->SetBounds(new_pos);
}
| // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/dropdown_bar_host.h"
#include "base/logging.h"
#include "ui/aura/window.h"
#include "ui/views/widget/widget.h"
using content::WebContents;
NativeWebKeyboardEvent DropdownBarHost::GetKeyboardEvent(
const WebContents* contents,
const views::KeyEvent& key_event) {
return NativeWebKeyboardEvent(key_event.native_event());
}
void DropdownBarHost::SetWidgetPositionNative(const gfx::Rect& new_pos,
bool no_redraw) {
if (!host_->IsVisible())
host_->GetNativeView()->Show();
host_->GetNativeView()->SetBounds(new_pos);
host_->StackAtTop();
}
|
Add missing output directory creation | #include "OptionsManager.h"
#include <fstream>
#include <spotify/json.hpp>
#include "codecs/OptionsCodec.h"
OptionsManager::OptionsManager(std::string filename)
{
std::ifstream ifs(filename);
if (!ifs.good())
{
throw std::runtime_error("Could not open options file");
}
std::string str{std::istreambuf_iterator<char>(ifs),
std::istreambuf_iterator<char>()};
mOptions = spotify::json::decode<Options>(str.c_str());
mOptions.filename = filename;
}
void OptionsManager::loadOptions(std::string filename)
{
std::ifstream ifs(filename);
if (!ifs.good())
{
throw std::runtime_error("Could not open options file");
}
std::string str{std::istreambuf_iterator<char>(ifs),
std::istreambuf_iterator<char>()};
Options options = spotify::json::decode<Options>(str.c_str());
options.filename = filename;
}
const Options& OptionsManager::getOptions() const
{
return mOptions;
}
| #include "OptionsManager.h"
#include <fstream>
#include <boost/filesystem.hpp>
#include <spotify/json.hpp>
#include "codecs/OptionsCodec.h"
OptionsManager::OptionsManager(std::string filename)
{
std::ifstream ifs(filename);
if (!ifs.good())
{
throw std::runtime_error("Could not open options file");
}
std::string str{std::istreambuf_iterator<char>(ifs),
std::istreambuf_iterator<char>()};
mOptions = spotify::json::decode<Options>(str.c_str());
mOptions.filename = filename;
// TODO(hryniuk): move it elsewhere
auto outputDirectory = mOptions.outputDirectory;
boost::filesystem::path p(filename);
p.remove_filename();
p.append(outputDirectory);
boost::filesystem::create_directories(p);
auto relativeOutputDirectory = p.string();
mOptions.relativeOutputDirectory = relativeOutputDirectory;
}
void OptionsManager::loadOptions(std::string filename)
{
std::ifstream ifs(filename);
if (!ifs.good())
{
throw std::runtime_error("Could not open options file");
}
std::string str{std::istreambuf_iterator<char>(ifs),
std::istreambuf_iterator<char>()};
Options options = spotify::json::decode<Options>(str.c_str());
options.filename = filename;
}
const Options& OptionsManager::getOptions() const
{
return mOptions;
}
|
Add license header to this file | #include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton *hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
| /****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the tools applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton *hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
|
Add OnConnection callback for echo tcp server | #include <evpp/exp.h>
#include <evpp/tcp_server.h>
#include <evpp/buffer.h>
#include <evpp/tcp_conn.h>
void OnMessage(const evpp::TCPConnPtr& conn,
evpp::Buffer* msg,
evpp::Timestamp ts) {
std::string s = msg->NextAllString();
LOG_INFO << "Received a message [" << s << "]";
conn->Send(s);
if (s == "quit" || s == "exit") {
conn->Close();
}
}
int main(int argc, char* argv[]) {
std::string port = "9099";
if (argc == 2) {
port = argv[1];
}
std::string addr = std::string("0.0.0.0:") + port;
evpp::EventLoop loop;
evpp::TCPServer server(&loop, addr, "TCPEcho", 0);
server.SetMessageCallback(&OnMessage);
server.Start();
loop.Run();
return 0;
}
#ifdef WIN32
#include "winmain-inl.h"
#endif
| #include <evpp/exp.h>
#include <evpp/tcp_server.h>
#include <evpp/buffer.h>
#include <evpp/tcp_conn.h>
#ifdef _WIN32
#include "winmain-inl.h"
#endif
void OnMessage(const evpp::TCPConnPtr& conn,
evpp::Buffer* msg,
evpp::Timestamp ts) {
std::string s = msg->NextAllString();
LOG_INFO << "Received a message [" << s << "]";
conn->Send(s);
if (s == "quit" || s == "exit") {
conn->Close();
}
}
void OnConnection(const evpp::TCPConnPtr& conn) {
if (conn->IsConnected()) {
LOG_INFO << "Accept a new connection from " << conn->remote_addr();
} else {
LOG_INFO << "Disconnected from " << conn->remote_addr();
}
}
int main(int argc, char* argv[]) {
std::string port = "9099";
if (argc == 2) {
port = argv[1];
}
std::string addr = std::string("0.0.0.0:") + port;
evpp::EventLoop loop;
evpp::TCPServer server(&loop, addr, "TCPEcho", 0);
server.SetMessageCallback(&OnMessage);
server.SetConnectionCallback(&OnConnection);
server.Start();
loop.Run();
return 0;
}
|
Increase core count for PerfettoDeviceFeatureTest | /*
* Copyright (C) 2018 The Android Open Source Project
*
* 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 <sys/sysinfo.h>
#include "test/gtest_and_gmock.h"
namespace perfetto {
TEST(PerfettoDeviceFeatureTest, TestMaxCpusForAtraceChmod) {
// Check that there are no more than 16 CPUs so that the assumption in the
// atrace.rc for clearing CPU buffers is valid.
ASSERT_LE(sysconf(_SC_NPROCESSORS_CONF), 16);
}
} // namespace perfetto
| /*
* Copyright (C) 2018 The Android Open Source Project
*
* 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 <sys/sysinfo.h>
#include "test/gtest_and_gmock.h"
namespace perfetto {
TEST(PerfettoDeviceFeatureTest, TestMaxCpusForAtraceChmod) {
// Check that there are no more than 24 CPUs so that the assumption in the
// atrace.rc for clearing CPU buffers is valid.
ASSERT_LE(sysconf(_SC_NPROCESSORS_CONF), 24);
}
} // namespace perfetto
|
Fix compilation error with Qt 5.4. | /*
* The MIT License (MIT)
*
* Copyright (c) 2017 Nathan Osman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <nitroshare/application.h>
#include "trayplugin.h"
void TrayPlugin::initialize(Application *application)
{
mIcon = new QSystemTrayIcon;
mMenu = new QMenu;
mIcon->setContextMenu(mMenu);
mMenu->addAction(tr("Quit"), application, &Application::quit);
}
void TrayPlugin::cleanup(Application *)
{
delete mMenu;
delete mIcon;
}
| /*
* The MIT License (MIT)
*
* Copyright (c) 2017 Nathan Osman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#include <nitroshare/application.h>
#include "trayplugin.h"
void TrayPlugin::initialize(Application *application)
{
mIcon = new QSystemTrayIcon;
mMenu = new QMenu;
mIcon->setContextMenu(mMenu);
mMenu->addAction(tr("Quit"), application, SLOT(quit()));
}
void TrayPlugin::cleanup(Application *)
{
delete mMenu;
delete mIcon;
}
|
Add stub entityx classes to sample. | #include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class EntityCreationApp : public App {
public:
void setup() override;
void mouseDown( MouseEvent event ) override;
void update() override;
void draw() override;
};
void EntityCreationApp::setup()
{
}
void EntityCreationApp::mouseDown( MouseEvent event )
{
}
void EntityCreationApp::update()
{
}
void EntityCreationApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
}
CINDER_APP( EntityCreationApp, RendererGl )
| #include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"
#include "cinder/gl/gl.h"
#include "entityx/System.h"
using namespace ci;
using namespace ci::app;
using namespace std;
class EntityCreationApp : public App {
public:
EntityCreationApp();
void setup() override;
void mouseDown( MouseEvent event ) override;
void update() override;
void draw() override;
private:
entityx::EventManager events;
entityx::EntityManager entities;
entityx::SystemManager systems;
};
EntityCreationApp::EntityCreationApp()
: entities(events),
systems(entities, events)
{}
void EntityCreationApp::setup()
{
}
void EntityCreationApp::mouseDown( MouseEvent event )
{
}
void EntityCreationApp::update()
{
}
void EntityCreationApp::draw()
{
gl::clear( Color( 0, 0, 0 ) );
}
CINDER_APP( EntityCreationApp, RendererGl )
|
Fix help print to reflect parameter changes | #include <stdio.h>
#include "interface.h"
void printHelp()
{
printf("Usage: yabs [options]\n\n"
"yabs, a simple build system.\n"
"Options:\n"
"\t-new\tCreate a new yabs build file\n"
"\t-help\tPrint this dialog\n");
}
| #include <stdio.h>
#include "interface.h"
void printHelp()
{
printf("Usage: yabs [options]\n\n"
"yabs, a simple build system.\n"
"Options:\n"
"\t-n\tCreate a new yabs build file\n"
"\t-h\tPrint this dialog\n");
}
|
Fix crash when loading UE editor with custom UI scaling |
#include "FlareScalingRule.h"
float UFlareScalingRule::GetDPIScaleBasedOnSize(FIntPoint Size) const
{
float NominalAspectRatio = (16.0f / 9.0f);
// Wide screen : scale 1 at 1920, scale 2 at 3840...
if (Size.X / Size.Y > NominalAspectRatio)
{
return (Size.Y / 1080.0f);
}
// Square ratio : scale 1 at 1080p
else
{
return (Size.X / 1920.0f);
}
}
|
#include "FlareScalingRule.h"
float UFlareScalingRule::GetDPIScaleBasedOnSize(FIntPoint Size) const
{
float NominalAspectRatio = (16.0f / 9.0f);
// Loading game
if (Size.X == 0 || Size.Y == 0)
{
return 1;
}
// Wide screen : scale 1 at 1920, scale 2 at 3840...
else if (Size.X / Size.Y > NominalAspectRatio)
{
return (Size.Y / 1080.0f);
}
// Square ratio : scale 1 at 1080p
else
{
return (Size.X / 1920.0f);
}
}
|
Allow atomic file writes from Android on the UI thread. | // Copyright 2013 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/android/important_file_writer_android.h"
#include <string>
#include "base/android/jni_string.h"
#include "base/files/important_file_writer.h"
#include "jni/ImportantFileWriterAndroid_jni.h"
namespace base {
namespace android {
static jboolean WriteFileAtomically(JNIEnv* env,
jclass /* clazz */,
jstring file_name,
jbyteArray data) {
std::string native_file_name;
base::android::ConvertJavaStringToUTF8(env, file_name, &native_file_name);
base::FilePath path(native_file_name);
int data_length = env->GetArrayLength(data);
jbyte* native_data = env->GetByteArrayElements(data, NULL);
std::string native_data_string(reinterpret_cast<char *>(native_data),
data_length);
bool result = base::ImportantFileWriter::WriteFileAtomically(
path, native_data_string);
env->ReleaseByteArrayElements(data, native_data, JNI_ABORT);
return result;
}
bool RegisterImportantFileWriterAndroid(JNIEnv* env) {
return RegisterNativesImpl(env);
}
} // namespace android
} // namespace base
| // Copyright 2013 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/android/important_file_writer_android.h"
#include <string>
#include "base/android/jni_string.h"
#include "base/files/important_file_writer.h"
#include "base/threading/thread_restrictions.h"
#include "jni/ImportantFileWriterAndroid_jni.h"
namespace base {
namespace android {
static jboolean WriteFileAtomically(JNIEnv* env,
jclass /* clazz */,
jstring file_name,
jbyteArray data) {
// This is called on the UI thread during shutdown to save tab data, so
// needs to enable IO.
base::ThreadRestrictions::ScopedAllowIO();
std::string native_file_name;
base::android::ConvertJavaStringToUTF8(env, file_name, &native_file_name);
base::FilePath path(native_file_name);
int data_length = env->GetArrayLength(data);
jbyte* native_data = env->GetByteArrayElements(data, NULL);
std::string native_data_string(reinterpret_cast<char *>(native_data),
data_length);
bool result = base::ImportantFileWriter::WriteFileAtomically(
path, native_data_string);
env->ReleaseByteArrayElements(data, native_data, JNI_ABORT);
return result;
}
bool RegisterImportantFileWriterAndroid(JNIEnv* env) {
return RegisterNativesImpl(env);
}
} // namespace android
} // namespace base
|
Fix double definition of a function. | //===-- sanitizer_common_nolibc.cc ----------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains stubs for libc function to facilitate optional use of
// libc in no-libcdep sources.
//===----------------------------------------------------------------------===//
#include "sanitizer_platform.h"
#include "sanitizer_common.h"
namespace __sanitizer {
void WriteToSyslog(const char *buffer) {}
}
| //===-- sanitizer_common_nolibc.cc ----------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains stubs for libc function to facilitate optional use of
// libc in no-libcdep sources.
//===----------------------------------------------------------------------===//
#include "sanitizer_platform.h"
#include "sanitizer_common.h"
namespace __sanitizer {
#if SANITIZER_LINUX
void WriteToSyslog(const char *buffer) {}
#endif
}
|
Add missing comment block at top of file. | // =============================================================================
// Authors: Radu Serban, Justin Madsen
// =============================================================================
//
// Base class for a vehicle wheel.
// A wheel subsystem does not own a body. Instead, when attached to a suspension
// subsystem, the wheel's mass properties are used to update those of the
// spindle body owned by the suspension.
// A concrete wheel subsystem can optionally carry its own visualization assets
// and/or contact geometry (which are associated with the suspension's spindle
// body).
// =============================================================================
namespace chrono {
} // end namespace chrono
| // =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All right reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Radu Serban, Justin Madsen
// =============================================================================
//
// Base class for a vehicle wheel.
// A wheel subsystem does not own a body. Instead, when attached to a suspension
// subsystem, the wheel's mass properties are used to update those of the
// spindle body owned by the suspension.
// A concrete wheel subsystem can optionally carry its own visualization assets
// and/or contact geometry (which are associated with the suspension's spindle
// body).
// =============================================================================
namespace chrono {
} // end namespace chrono
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.