// StackTrace.cpp

// Implements the functions to print current stack traces

#include "Globals.h"
#include "StackTrace.h"
#ifdef _WIN32
	#include "../StackWalker.h"
#else
	#include <execinfo.h>
	#include <unistd.h>
#endif

// FreeBSD uses size_t for the return type of backtrace()
#if defined(__FreeBSD__) && (__FreeBSD__ >= 10)
	#define btsize size_t
#else
	#define btsize int
#endif

void PrintStackTrace(void)
{
	#ifdef _WIN32
		// Reuse the StackWalker from the LeakFinder project already bound to MCS
		// Define a subclass of the StackWalker that outputs everything to stdout
		class PrintingStackWalker :
			public StackWalker
		{
			virtual void OnOutput(LPCSTR szText) override
			{
				puts(szText);
			}
		} sw;
		sw.ShowCallstack();
	#else
		// Use the backtrace() function to get and output the stackTrace:
		// Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes
		void * stackTrace[30];
		btsize numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace));
		backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO);
	#endif
}

// StackTrace.cpp

// Implements the functions to print current stack traces

#include "Globals.h"
#include "StackTrace.h"
#ifdef _WIN32
	#include "../StackWalker.h"
#else
	#include <execinfo.h>
	#include <unistd.h>
#endif

// FreeBSD uses size_t for the return type of backtrace()
#if defined(__FreeBSD__) && (__FreeBSD__ >= 10)
	#define btsize size_t
#else
	#define btsize int
#endif

void PrintStackTrace(void)
{
	#ifdef _WIN32
		// Reuse the StackWalker from the LeakFinder project already bound to MCS
		// Define a subclass of the StackWalker that outputs everything to stdout
		class PrintingStackWalker :
			public StackWalker
		{
			virtual void OnOutput(LPCSTR szText) override
			{
				puts(szText);
			}
		} sw;
		sw.ShowCallstack();
	#else
		#ifdef __GLIBC__
			// Use the backtrace() function to get and output the stackTrace:
			// Code adapted from http://stackoverflow.com/questions/77005/how-to-generate-a-stacktrace-when-my-gcc-c-app-crashes
			void * stackTrace[30];
			btsize numItems = backtrace(stackTrace, ARRAYCOUNT(stackTrace));
			backtrace_symbols_fd(stackTrace, numItems, STDERR_FILENO);
		#endif
	#endif
}

Define stacktrace functions only if __GLIBC__ is defined


/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */

#include "stdafx.h"

#ifndef __cplusplus_cli
int main (int argc, char **argv) {
	CAbstractTest::Main (argc, argv);
	return 0;
}
#endif /* ifndef __cplusplus_cli */

/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */

#include "stdafx.h"
#include "Service/Service.h"

#ifndef __cplusplus_cli
int main (int argc, char **argv) {
	if ((argc == 3) && !strcmp (argv[1], "jvm")) {
		return ServiceTestJVM (argv[2]) ? 0 : 1;
	}
	CAbstractTest::Main (argc, argv);
	return 0;
}
#endif /* ifndef __cplusplus_cli */

[PLAT-3017] Verify JVM libraries found in the filesystem as being 1.7 or higher during tests.


#include <occa/defines.hpp>
#include <occa/modes/metal/registration.hpp>

namespace occa {
  namespace metal {
    modeInfo::modeInfo() {}

    bool modeInfo::init() {
      return OCCA_METAL_ENABLED;
    }

    styling::section& modeInfo::getDescription() {
      static styling::section section("Metal");
      if (section.size() == 0) {
        int deviceCount = api::metal::getDeviceCount();
        for (int deviceId = 0; deviceId < deviceCount; ++deviceId) {
          api::metal::device_t device = api::metal::getDevice(deviceId);

          udim_t bytes = device.getMemorySize();
          std::string bytesStr = stringifyBytes(bytes);

          section
              .add("Device Name", device.getName())
              .add("Device ID"  , toString(deviceId))
              .add("Memory"     , bytesStr)
              .addDivider();
        }
        // Remove last divider
        section.groups.pop_back();
      }
      return section;
    }

    occa::mode<metal::modeInfo,
               metal::device> mode("Metal");
  }
}

#include <occa/defines.hpp>
#include <occa/modes/metal/registration.hpp>

namespace occa {
  namespace metal {
    modeInfo::modeInfo() {}

    bool modeInfo::init() {
#if OCCA_METAL_ENABLED
      // Only consider metal enabled if there is a device
      return api::metal::getDeviceCount();
#else
      return false;
#endif
    }

    styling::section& modeInfo::getDescription() {
      static styling::section section("Metal");
      if (section.size() == 0) {
        int deviceCount = api::metal::getDeviceCount();
        for (int deviceId = 0; deviceId < deviceCount; ++deviceId) {
          api::metal::device_t device = api::metal::getDevice(deviceId);

          udim_t bytes = device.getMemorySize();
          std::string bytesStr = stringifyBytes(bytes);

          section
              .add("Device Name", device.getName())
              .add("Device ID"  , toString(deviceId))
              .add("Memory"     , bytesStr)
              .addDivider();
        }
        // Remove last divider
        section.groups.pop_back();
      }
      return section;
    }

    occa::mode<metal::modeInfo,
               metal::device> mode("Metal");
  }
}

[Metal] Check device count before claiming to be enabled


#include "rdb_protocol/configured_limits.hpp"
#include <limits>
#include "rdb_protocol/wire_func.hpp"
#include "rdb_protocol/func.hpp"

namespace ql {
configured_limits_t
from_optargs(rdb_context_t *ctx, signal_t *interruptor, global_optargs_t *arguments)
{
    if (arguments->has_optarg("array_limit")) {
        // Fake an environment with no arguments.  We have to fake it
        // because of a chicken/egg problem; this function gets called
        // before there are any extant environments at all.  Only
        // because we use an empty argument list do we prevent an
        // infinite loop.
        env_t env(ctx, interruptor, std::map<std::string, wire_func_t>(),
                  nullptr);
        int64_t limit = arguments->get_optarg(&env, "array_limit")->as_int();
        rcheck_datum(limit > 1, base_exc_t::GENERIC,
                     strprintf("Illegal array size limit `%ld`.", limit));
        return configured_limits_t(limit);
    } else {
        return configured_limits_t();
    }
}

RDB_IMPL_ME_SERIALIZABLE_1(configured_limits_t, array_size_limit_);
INSTANTIATE_SERIALIZABLE_SELF_FOR_CLUSTER(configured_limits_t);

const configured_limits_t configured_limits_t::unlimited(std::numeric_limits<size_t>::max());

} // namespace ql

#include "rdb_protocol/configured_limits.hpp"
#include <limits>
#include "rdb_protocol/wire_func.hpp"
#include "rdb_protocol/func.hpp"

namespace ql {
configured_limits_t
from_optargs(rdb_context_t *ctx, signal_t *interruptor, global_optargs_t *arguments)
{
    if (arguments->has_optarg("array_limit")) {
        // Fake an environment with no arguments.  We have to fake it
        // because of a chicken/egg problem; this function gets called
        // before there are any extant environments at all.  Only
        // because we use an empty argument list do we prevent an
        // infinite loop.
        env_t env(ctx, interruptor, std::map<std::string, wire_func_t>(),
                  nullptr);
        int64_t limit = arguments->get_optarg(&env, "array_limit")->as_int();
        rcheck_datum(limit > 1, base_exc_t::GENERIC,
                     strprintf("Illegal array size limit `%" PRIi64 "`.", limit));
        return configured_limits_t(limit);
    } else {
        return configured_limits_t();
    }
}

RDB_IMPL_ME_SERIALIZABLE_1(configured_limits_t, array_size_limit_);
INSTANTIATE_SERIALIZABLE_SELF_FOR_CLUSTER(configured_limits_t);

const configured_limits_t configured_limits_t::unlimited(std::numeric_limits<size_t>::max());

} // namespace ql

Use PRIi64 macro to work around clang weirdness.


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

#include "testing/gtest/include/gtest/gtest.h"

#include "base/basictypes.h"
#include "net/http/http_auth_handler_basic.h"

namespace net {

TEST(HttpAuthHandlerBasicTest, GenerateCredentials) {
  static const struct {
    const wchar_t* username;
    const wchar_t* password;
    const char* expected_credentials;
  } tests[] = {
    { L"foo", L"bar", "Basic Zm9vOmJhcg==" },
    // Empty password
    { L"anon", L"", "Basic YW5vbjo=" },
  };
  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
    std::string challenge = "Basic realm=\"Atlantis\"";
    HttpAuthHandlerBasic basic;
    basic.InitFromChallenge(challenge.begin(), challenge.end(),
                            HttpAuth::AUTH_SERVER);
    std::string credentials = basic.GenerateCredentials(tests[i].username,
                                                        tests[i].password,
                                                        NULL, NULL);
    EXPECT_STREQ(tests[i].expected_credentials, credentials.c_str());
  }
}

} // namespace net

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

#include "testing/gtest/include/gtest/gtest.h"

#include "base/basictypes.h"
#include "net/http/http_auth_handler_basic.h"

namespace net {

TEST(HttpAuthHandlerBasicTest, GenerateCredentials) {
  static const struct {
    const wchar_t* username;
    const wchar_t* password;
    const char* expected_credentials;
  } tests[] = {
    { L"foo", L"bar", "Basic Zm9vOmJhcg==" },
    // Empty username
    { L"", L"foobar", "Basic OmZvb2Jhcg==" },
    // Empty password
    { L"anon", L"", "Basic YW5vbjo=" },
  };
  for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
    std::string challenge = "Basic realm=\"Atlantis\"";
    HttpAuthHandlerBasic basic;
    basic.InitFromChallenge(challenge.begin(), challenge.end(),
                            HttpAuth::AUTH_SERVER);
    std::string credentials = basic.GenerateCredentials(tests[i].username,
                                                        tests[i].password,
                                                        NULL, NULL);
    EXPECT_STREQ(tests[i].expected_credentials, credentials.c_str());
  }
}

} // namespace net

Add an HTTP basic auth unit test for an empty username.

R=eroman
BUG=297
Review URL: http://codereview.chromium.org/8859

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


#include <stdint.h>
#include <ncurses.h>

#include "display/Screen.h"

Screen::Screen()
{
	//Initialized the screen
	initscr();
	//Start with a clean slate
	clear();
	//Don't echo entered characters on the screen
	noecho();

	//Hide the cursor
	curs_set(false);

	//Refresh the screen (to our blank state)
	/// @todo Why does it seem necessary to refresh() before we draw anything?
	///       Only required when going straight into multiple windows?
	refresh();

	//Get our height and width for later
	getmaxyx(stdscr, _height, _width);
}

Screen::~Screen()
{
	endwin();
}

uint32_t Screen::getHeight()
{
	return _height;
}

uint32_t Screen::getWidth()
{
	return _width;
}

#include <stdint.h>
#include <ncurses.h>

#include "display/Screen.h"

Screen::Screen()
{
	//Initialized the screen
	initscr();
	//Start with a clean slate
	clear();
	//Don't echo entered characters on the screen
	noecho();
	//Enable getting function keys
	keypad(stdscr, true);

	//Hide the cursor
	curs_set(false);

	//Refresh the screen (to our blank state)
	/// @todo Why does it seem necessary to refresh() before we draw anything?
	///       Only required when going straight into multiple windows?
	refresh();

	//Get our height and width for later
	getmaxyx(stdscr, _height, _width);
}

Screen::~Screen()
{
	endwin();
}

uint32_t Screen::getHeight()
{
	return _height;
}

uint32_t Screen::getWidth()
{
	return _width;
}

Enable function keys in ncurses mode.

Enable function keys in ncurses mode.

This required simply a call to keypad(), and now the full range of keyboard keys becomes available to the game.


// Copyright (C) 2009, 2010 by Florent Lamiraux, Thomas Moulard, JRL.
//
// This file is part of the hpp-corbaserver.
//
// This software is provided "as is" without warranty of any kind,
// either expressed or implied, including but not limited to the
// implied warranties of fitness for a particular purpose.
//
// See the COPYING file for more information.

#include <iostream>
#include <hpp/util/debug.hh>
#include "hpp/corbaserver/server.hh"

using hpp::corbaServer::Server;

int
main (int argc, const char* argv[])
{
  hpp::core::ProblemSolverPtr_t problemSolver = new hpp::core::ProblemSolver;
  Server server (problemSolver, argc, argv, true);

  server.startCorbaServer ();
  server.processRequest(true);
}

// Copyright (C) 2009, 2010 by Florent Lamiraux, Thomas Moulard, JRL.
//
// This file is part of the hpp-corbaserver.
//
// This software is provided "as is" without warranty of any kind,
// either expressed or implied, including but not limited to the
// implied warranties of fitness for a particular purpose.
//
// See the COPYING file for more information.

#include <iostream>
#include <hpp/util/debug.hh>
#include "hpp/corbaserver/server.hh"

using hpp::corbaServer::Server;

int
main (int argc, const char* argv[])
{
  hpp::core::ProblemSolverPtr_t problemSolver =
    hpp::core::ProblemSolver::create ();
  Server server (problemSolver, argc, argv, true);

  server.startCorbaServer ();
  server.processRequest(true);
}

Create ProblemSolver instance with method create.


/**
* Dynamically Loaded Engine
* (C) 2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/

#include <botan/dyn_engine.h>
#include <botan/internal/dyn_load.h>

namespace Botan {

namespace {

extern "C" {
   typedef Engine* (*creator_function)(void);
   typedef void (*destructor_function)(Engine*);
}

}

Dynamically_Loaded_Engine::Dynamically_Loaded_Engine(
   const std::string& library_path) :
   engine(0)
   {
   lib = new Dynamically_Loaded_Library(library_path);

   try
      {
      creator_function creator = lib->resolve<creator_function>("create_engine");

      engine = creator();

      if(!engine)
         throw std::runtime_error("Creator function in " + library_path + " failed");
      }
   catch(...)
      {
      delete lib;
      lib = 0;
      throw;
      }
   }

Dynamically_Loaded_Engine::~Dynamically_Loaded_Engine()
   {
   if(lib && engine)
      {
      try
         {
         destructor_function destroy =
            lib->resolve<destructor_function>("destroy_engine");
         destroy(engine);
         }
      catch(...)
         {
         delete lib;
         lib = 0;
         throw;
         }
      }

   if(lib)
      delete lib;
   }

}

/**
* Dynamically Loaded Engine
* (C) 2010 Jack Lloyd
*
* Distributed under the terms of the Botan license
*/

#include <botan/dyn_engine.h>
#include <botan/internal/dyn_load.h>

namespace Botan {

namespace {

extern "C" {
   typedef Engine* (*creator_function)(void);
   typedef void (*destructor_function)(Engine*);
   typedef u32bit (*module_version)(void);
}

}

Dynamically_Loaded_Engine::Dynamically_Loaded_Engine(
   const std::string& library_path) :
   engine(0)
   {
   lib = new Dynamically_Loaded_Library(library_path);

   try
      {
      module_version version =
         lib->resolve<module_version>("module_version");

      u32bit mod_version = version();

      if(mod_version != 20100728)
         throw std::runtime_error("Unexpected or incompatible version in " +
                                  library_path);

      creator_function creator =
         lib->resolve<creator_function>("create_engine");

      engine = creator();

      if(!engine)
         throw std::runtime_error("Creator function in " + library_path + " failed");
      }
   catch(...)
      {
      delete lib;
      lib = 0;
      throw;
      }
   }

Dynamically_Loaded_Engine::~Dynamically_Loaded_Engine()
   {
   if(lib && engine)
      {
      try
         {
         destructor_function destroy =
            lib->resolve<destructor_function>("destroy_engine");
         destroy(engine);
         }
      catch(...)
         {
         delete lib;
         lib = 0;
         throw;
         }
      }

   if(lib)
      delete lib;
   }

}

Add a version info function which returns a u32bit. The currently expected value is 20100728 (ie, today). This will allow for checking for and/or working around changes to interfaces.


/*
 * Copyright 2017 Facebook, 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 <folly/CpuId.h>

#include <folly/portability/GTest.h>

using namespace folly;

TEST(CpuId, Simple) {
  // All CPUs should support MMX
  CpuId id;
  EXPECT_TRUE(id.mmx());
}

/*
 * Copyright 2017-present Facebook, 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 <folly/CpuId.h>

#include <folly/portability/GTest.h>

using namespace folly;

TEST(CpuId, Simple) {
  CpuId id;
  // All x64 CPUs should support MMX
  EXPECT_EQ(kIsArchAmd64, id.mmx());
}

Update cpuid test to expect failure on non intel cpu

Summary: Found that testing would fail on aarch64 since mmx is an Intel thing.  Changed it to just check for x64.

Reviewed By: yfeldblum

Differential Revision: D6670050

fbshipit-source-id: 6ce4b45bb5ef02d65305636d6ac28be7631ddf1b


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

// Started failing with r29947. WebKit merge 49961:49992.
IN_PROC_BROWSER_TEST_F(DISABLED_ExtensionApiTest, Storage) {
  ASSERT_TRUE(RunExtensionTest("storage")) << message_;
}

Disable test failing since r29947.

Disable test failing since r29947.

TBR=tony@chromium.org
Review URL: http://codereview.chromium.org/338006

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


#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->SliderBgImg("volume");
    BackgroundImage(bg);

    _knob = skin->Knob("volume");
    _vertical = _knob->Vertical();

    std::list<Meter*> meters = skin->VolumeSliderMeters();
    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;
}

#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->SliderBgImg("volume");
    BackgroundImage(bg);

    Gdiplus::Bitmap *mask = skin->SliderMask("volume");
    if (mask != NULL) {
        CLOG(L"Applying glass to eject OSD");
        GlassMask(mask);
    }

    _knob = skin->Knob("volume");
    _vertical = _knob->Vertical();

    std::list<Meter*> meters = skin->VolumeSliderMeters();
    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;
}

Apply glass to volume slider

Apply glass to volume slider


#include <gtest/gtest.h>

/**
 * A test case that leaks memory, to check that we can spot this in valgrind
 */
TEST(Leak, ThisTestLeaks) { EXPECT_TRUE(new int[45]); }

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

#include <gtest/gtest.h>

/**
 * A test case that leaks memory, to check that we can spot this in valgrind
 */
TEST(Leak, ThisTestLeaks) {
  int* temp = new int[45];
  int temp2 = *temp++;
  std::cout << temp2;
}

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

Fix the leak test (so that it keeps leaking).

It appears that gcc 9 fixes the leak automatically, so valgrind doesn't
detect it. Now we actually use the leaky variable, which seems to do the
trick.

Signed-off-by: Patrick Vacek <a38520cbbe2e974bc8b7ea86877dd3c7115ca2d7@gmail.com>


#include <avahi-client/client.h>
#include <dns_sd.h>

int main(int argc, char** argv) {
}

#include <avahi-client/client.h>
#include <avahi-compat-libdns_sd/dns_sd.h>

int main(int argc, char** argv) {
}

Fix inclusion path as suggested by @ruslo.


// RUN: %llvmgcc %s -fasm-blocks -S -o - | FileCheck %s
// Complicated expression as jump target
// XFAIL: *
// XTARGET: x86,i386,i686

void Method3()
{
// CHECK: Method3
// CHECK-NOT: msasm
    asm("foo:");
// CHECK: return
}

void Method4()
{
// CHECK: Method4
// CHECK: msasm
  asm {
    bar:
  }
// CHECK: return
}

// RUN: %llvmgxx %s -fasm-blocks -S -o - | FileCheck %s
// Complicated expression as jump target
// XFAIL: *
// XTARGET: x86,i386,i686

void Method3()
{
// CHECK: Method3
// CHECK-NOT: msasm
    asm("foo:");
// CHECK: return
}

void Method4()
{
// CHECK: Method4
// CHECK: msasm
  asm {
    bar:
  }
// CHECK: return
}

Use llvmgxx for C++ test.

Use llvmgxx for C++ test.

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


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

// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
//	#define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]

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

#define _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
#include <__config>

_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }

int main ()
{
	foo();	// no error here!
}

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

// Test that _LIBCPP_NODISCARD_AFTER_CXX17 works
//	#define _LIBCPP_NODISCARD_AFTER_CXX17 [[nodiscard]]

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

// MODULES_DEFINES: _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
#define _LIBCPP_DISABLE_NODISCARD_AFTER_CXX17
#include <__config>

_LIBCPP_NODISCARD_AFTER_CXX17 int foo() { return 6; }

int main ()
{
	foo();	// no error here!
}

Fix nodiscard test when modules are enabled

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


//===- StackSlots.cpp  - Specialize LLVM code for target machine ---------===//
//
// This pass adds 2 empty slots at the top of function stack.  These two slots
// are later used during code reoptimization for spilling the register values
// when rewriting branches.
//
//===----------------------------------------------------------------------===//

#include "llvm/CodeGen/StackSlots.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineInstrInfo.h"
#include "llvm/Constant.h"
#include "llvm/Function.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Pass.h"
#include "llvm/CodeGen/MachineFunction.h"

class StackSlots : public FunctionPass {
  const TargetMachine &Target;
public:
  StackSlots (const TargetMachine &T) : Target(T) {}

  const char *getPassName() const {
    return "Stack Slot Insertion for profiling code";
  }

  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
    AU.setPreservesCFG();
  }

  bool runOnFunction(Function &F) {
    const Type *PtrInt = PointerType::get(Type::IntTy);
    unsigned Size = Target.DataLayout.getTypeSize(PtrInt);

    MachineFunction &mcInfo = MachineFunction::get(&F);
    Value *V = Constant::getNullValue(Type::IntTy);
    mcInfo.allocateLocalVar(Target, V, 2*Size);
    return true;
  }
};

Pass *createStackSlotsPass(const TargetMachine &Target) {
  return new StackSlots(Target);
}

//===- StackSlots.cpp  - Specialize LLVM code for target machine ---------===//
//
// This pass adds 2 empty slots at the top of function stack.  These two slots
// are later used during code reoptimization for spilling the register values
// when rewriting branches.
//
//===----------------------------------------------------------------------===//

#include "llvm/CodeGen/StackSlots.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineInstrInfo.h"
#include "llvm/Constant.h"
#include "llvm/Function.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Pass.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionInfo.h"

namespace {
  class StackSlots : public FunctionPass {
    const TargetMachine &Target;
  public:
    StackSlots(const TargetMachine &T) : Target(T) {}

    const char *getPassName() const {
      return "Stack Slot Insertion for profiling code";
    }

    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
      AU.setPreservesCFG();
    }

    bool runOnFunction(Function &F) {
      const Type *PtrInt = PointerType::get(Type::IntTy);
      unsigned Size = Target.getTargetData().getTypeSize(PtrInt);

      Value *V = Constant::getNullValue(Type::IntTy);
      MachineFunction::get(&F).getInfo()->allocateLocalVar(V, 2*Size);
      return true;
    }
  };
}

Pass *createStackSlotsPass(const TargetMachine &Target) {
  return new StackSlots(Target);
}

Put class in anonymous namespace

Put class in anonymous namespace

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


#include "aboutwindow.h"
#include "ui_aboutwindow.h"

AboutWindow::AboutWindow(const QString &version, QWidget *parent)
	: QDialog(parent), ui(new Ui::AboutWindow)
{
	setAttribute(Qt::WA_DeleteOnClose);
	ui->setupUi(this);

	ui->labelCurrent->setText(version);
	ui->labelCreator->setText(ui->labelCreator->text().replace("{website}", PROJECT_WEBSITE_URL));
	setFixedSize(400, 228);

	connect(&m_updater, &ProgramUpdater::finished, this, &AboutWindow::finished);
	m_updater.checkForUpdates();
}

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

void AboutWindow::finished(const QString &newVersion, bool available)
{
	const QString msg = available ? tr("A new version is available: %1").arg(newVersion) : tr("Grabber is up to date");
	ui->labelMessage->setText("
" + msg + "
");
}

#include "aboutwindow.h"
#include "ui_aboutwindow.h"

AboutWindow::AboutWindow(const QString &version, QWidget *parent)
	: QDialog(parent), ui(new Ui::AboutWindow)
{
	setAttribute(Qt::WA_DeleteOnClose);
	ui->setupUi(this);

	// Set window title according to the current build
	QString labelVersion = version;
	#ifdef NIGHTLY
		QString commit(NIGHTLY_COMMIT);
		if (!commit.isEmpty())
			labelVersion += QString(" - nightly (%1)").arg(commit.left(8));
		else
			labelVersion += " - nightly";
	#endif
	ui->labelCurrent->setText(labelVersion);

	ui->labelCreator->setText(ui->labelCreator->text().replace("{website}", PROJECT_WEBSITE_URL));
	setFixedSize(400, 228);

	connect(&m_updater, &ProgramUpdater::finished, this, &AboutWindow::finished);
	m_updater.checkForUpdates();
}

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

void AboutWindow::finished(const QString &newVersion, bool available)
{
	const QString msg = available ? tr("A new version is available: %1").arg(newVersion) : tr("Grabber is up to date");
	ui->labelMessage->setText("
" + msg + "
");
}

Add nightly version in about window

Add nightly version in about window


#import <iostream>

class Room {
  private:
	const int width;
	const int height;
  public:

	Room(){}
	Room(int w, int h) {
		width = w;
		height = h;
	}

	void print_dimensions();
};

void Room::print_dimensions() {
	std::cout << width << "x" << height << std::endl;
}

int main() {
	Room a_room(25,25);

	a_room.print_dimensions();

	return 0;
}

#import <iostream>

class Room {
  private:
	const int width;
	const int height;
  public:

	Room(){}
	Room(int w, int h) {
		width = w;
		height = h;
	}

	void print_dimensions();
	bool loadFromXMLFile();
};

void Room::print_dimensions() {
	std::cout << width << "x" << height << std::endl;
}

bool Room::loadFromXMLFile (const char* filename) {
	// Create xml dom
	TiXmlDocument doc(filename);

	// Load the document
	if (!doc.LoadFile()) {
		cerr << "File " << filename << " not found" << endl;
		return false;
	}

	// Get root element
	TiXmlElement* root = doc.FirstChildElement();
	if (root == NULL) {
		cerr << "XML Error: No root element" << endl;
		return false;
	}

	// Root element should be 'veld'
	if (root->Value() !== "VELD") {
		cerr << "XML Error: Root element has to be called 'veld'" << endl;
		return false;
	}

	// Parse the tags 'NAAM', 'LENGTE', 'BREEDTE', 'SPELER', 'OBSTAKEL'
	for (TiXmlElement* elem = root->FirstChildElement(); elem != NULL; elem = elem->NextSiblingElement()) {
		string elemName = elem->Value();

		if (elemName == "NAAM" || elemName == "LENGTE" || elemName == "BREEDTE") {
			// Get the text between the name, length and width tags
			TiXmlNode* node = elem->FirstChild();
			TiXmlText* text = node->ToText();
			string str = text->Value();

			if (elemName == "NAAM") this->set_name(str);
			if (elemName == "LENGTE") this->set_length(stoi(str));
			if (elemName == "BREEDTE") this->set_width(stoi(str));
		}

		if (elemName == "OBSTAKEL") {

		}

		if (elemName == "SPELER") {

		}
	}

	return true;
}

int main() {
	Room a_room(25,25);

	a_room.print_dimensions();

	return 0;
}

Add start of xml parser for room

Add start of xml parser for room


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

// <optional>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: libcpp-no-deduction-guides

// template<class T>
//   optional(T) -> optional<T>;

#include <optional>
#include <cassert>

struct A {};

int main()
{
//  Test the explicit deduction guides
    {
//	optional(T)
    std::optional opt(5);
    static_assert(std::is_same_v<decltype(opt), std::optional<int>>, "");
	assert(static_cast<bool>(opt));
	assert(*opt == 5);
    }

    {
//	optional(T)
    std::optional opt(A{});
    static_assert(std::is_same_v<decltype(opt), std::optional<A>>, "");
	assert(static_cast<bool>(opt));
    }

//  Test the implicit deduction guides

}

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

// <optional>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: libcpp-no-deduction-guides

// template<class T>
//   optional(T) -> optional<T>;

#include <optional>
#include <cassert>

struct A {};

int main()
{
//  Test the explicit deduction guides
    {
//  optional(T)
    std::optional opt(5);
    static_assert(std::is_same_v<decltype(opt), std::optional<int>>, "");
    assert(static_cast<bool>(opt));
    assert(*opt == 5);
    }

    {
//  optional(T)
    std::optional opt(A{});
    static_assert(std::is_same_v<decltype(opt), std::optional<A>>, "");
    assert(static_cast<bool>(opt));
    }

//  Test the implicit deduction guides

    {
//  optional(const optional &);
    std::optional<char> source('A');
    std::optional opt(source);
    static_assert(std::is_same_v<decltype(opt), std::optional<char>>, "");
    assert(static_cast<bool>(opt) == static_cast<bool>(source));
    assert(*opt == *source);
    }

}

Add one more test for optional

Add one more test for optional

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


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

// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
// CHECK-NOT:              DIFlagFwdDecl
// CHECK-SAME:             ){{$}}
class A {
public:
  int z;
};

A *foo (A* x) {
  A *a = new A(*x);
  return a;
}

// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B"
// CHECK-SAME:             flags: DIFlagFwdDecl

class B {
public:
  int y;
};

extern int bar(B *b);
int baz(B *b) {
  return bar(b);
}

// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "C"
// CHECK-SAME:             flags: DIFlagFwdDecl

struct C {
};

C (*x)(C);

// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s
// RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck --check-prefix=CHECK-C %s

// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A"
// CHECK-NOT:              DIFlagFwdDecl
// CHECK-SAME:             ){{$}}
class A {
public:
  int z;
};

A *foo (A* x) {
  A *a = new A(*x);
  return a;
}

// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "B"
// CHECK-SAME:             flags: DIFlagFwdDecl

class B {
public:
  int y;
};

extern int bar(B *b);
int baz(B *b) {
  return bar(b);
}

// CHECK-C: !DICompositeType(tag: DW_TAG_structure_type, name: "C"
// CHECK-C-SAME:             flags: DIFlagFwdDecl

struct C {
};

C (*x)(C);

Fix testcase for MSVC targets where the output ordering is different.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@266449 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 2785c796d94f1b17157cf4fa9f6f7eda10efc9f6)


//===-- ColorSettings.cpp - Stylistic Setup for Colors ------------- c++ --===//
//
//                               UWH Timer
//
//           This file is distributed under the BSD 3-Clause License.
//                      See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "uwhd/display/GameDisplay.h"
#include "uwhd/display/TimeDisplay.h"

#include <graphics.h>

using namespace rgb_matrix;

const Color GameDisplay::Background   = Color(  0,   0,   0);
const Color GameDisplay::WhiteTeamFG  = Color(200, 200, 200);
const Color GameDisplay::BlackTeamFG  = Color(  0,   0,   0);
const Color GameDisplay::WhiteTeamBG  = Background;
const Color GameDisplay::BlackTeamBG  = Color(  0,   0, 255);

const Color TimeDisplay::SecondsColor = Color(  0, 255,   0);
const Color TimeDisplay::MinutesColor = Color(  0, 255,   0);
const Color TimeDisplay::ColonColor   = Color(  0, 255,   0);
const Color TimeDisplay::RingColor    = Color(  0,   0,   0);
const Color TimeDisplay::Background   = GameDisplay::Background;

//===-- ColorSettings.cpp - Stylistic Setup for Colors ------------- c++ --===//
//
//                               UWH Timer
//
//           This file is distributed under the BSD 3-Clause License.
//                      See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "uwhd/display/GameDisplay.h"
#include "uwhd/display/TimeDisplay.h"

#include <graphics.h>

using namespace rgb_matrix;

const Color GameDisplay::Background   = Color(  0,   0,   0);
const Color GameDisplay::WhiteTeamFG  = Color(255, 255, 255);
const Color GameDisplay::BlackTeamFG  = Color(  0,   0, 255);
const Color GameDisplay::WhiteTeamBG  = Background;
const Color GameDisplay::BlackTeamBG  = Background;

const Color TimeDisplay::SecondsColor = Color(  0, 255,   0);
const Color TimeDisplay::MinutesColor = Color(  0, 255,   0);
const Color TimeDisplay::ColonColor   = Color(  0, 255,   0);
const Color TimeDisplay::RingColor    = Color(  0,   0,   0);
const Color TimeDisplay::Background   = GameDisplay::Background;

Fix the color inversion on the black score


#include <iostream>

void dummy();

int main()
{
    dummy();
}

void dummy() {
    std::cout<<"Welcome to the yield calculator \n";
}

#include <iostream>
#include <map>

using namespace std;

double timeInYears(const string period);

double cashDiscountValue(const string period, double rate);

int main()
{
    map<string, double> yields;
    // 1) Assignment using array index notation
    yields["1W"] = 0.445060000;
    yields["1M"] = 0.526890000;
    yields["2M"] = 0.669670000;
    yields["3M"] = 0.852220000;

    cout << "Map size: " << yields.size() << endl;

    for( map<string,double >::iterator ii=yields.begin(); ii!=yields.end(); ++ii)
    {

        cout << (*ii).first << ": " << (*ii).second << " ==== " << (cashDiscountValue((*ii).first, (*ii).second)) << endl;
    }
}

double cashDiscountValue(const string period, double rate) { return 1 / (1 + timeInYears(period) * rate / 100); }

double timeInYears(const string period)
{
    double businessDaysInYear = 360.0;
    if(period == "1W")
    {
        return 7.0 / businessDaysInYear;
    }
    if(period == "1M")
    {
        return 30.0 / businessDaysInYear;
    }
    if(period == "2M")
    {
        return 60.0 / businessDaysInYear;
    }
    if(period =="3M" ||period =="3M-6M" || period =="6M-9M" || period =="9M-12M" ||
       period =="12M-15M" || period =="15M-18M" || period =="18M-21M")
    {
        return 90.0 / businessDaysInYear;
    }
    return 0;
}

Add code to calculate yield for cash instruments


// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/self-referencing-lambda %s -verify -emit-obj -o %t2.o
// expected-no-diagnostics

#include "a.h"

// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/self-referencing-lambda %s -verify -emit-obj -std=c++14 -o %t2.o
// expected-no-diagnostics

#include "a.h"

[Modules] Update test to mention it requires C++14.

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


#include "./labels.h"
#include <vector>

std::function<void()>
Labels::subscribe(std::function<void(Action action, const Label &)> subscriber)
{
  int erasePosition = subscribers.size();
  subscribers.push_back(subscriber);

  return [this, erasePosition]()
  {
    subscribers.erase(subscribers.begin() + erasePosition);
  };
}

void Labels::add(Label label)
{
  labels[label.id] = label;
  notify(Action::Add, label);
}

void Labels::update(Label label)
{
  bool notifyChanges = labels[label.id] != label;

  labels[label.id] = label;

  if (notifyChanges)
    notify(Action::Update, label);
}

void Labels::remove(Label label)
{
  labels.erase(labels.find(label.id));
  notify(Action::Delete, label);
}

std::vector<Label> Labels::getLabels()
{
  std::vector<Label> result;
  for (auto &pair : labels)
    result.push_back(pair.second);

  return result;
}

Label Labels::getById(int id)
{
  return labels[id];
}

int Labels::count()
{
  return labels.size();
}

void Labels::notify(Action action, const Label &label)
{
  for (auto &subscriber : subscribers)
    subscriber(action, label);
}

#include "./labels.h"
#include <vector>

std::function<void()>
Labels::subscribe(std::function<void(Action action, const Label &)> subscriber)
{
  int erasePosition = subscribers.size();
  subscribers.push_back(subscriber);

  return [this, erasePosition]()
  {
    subscribers.erase(subscribers.begin() + erasePosition);
  };
}

void Labels::add(Label label)
{
  labels[label.id] = label;
  notify(Action::Add, label);
}

void Labels::update(Label label)
{
  bool notifyChanges = labels[label.id] != label;

  labels[label.id] = label;

  if (notifyChanges)
    notify(Action::Update, label);
}

void Labels::remove(Label label)
{
  labels.erase(labels.find(label.id));
  notify(Action::Delete, label);
}

std::vector<Label> Labels::getLabels()
{
  std::vector<Label> result;
  for (auto &pair : labels)
    result.push_back(pair.second);

  return result;
}

Label Labels::getById(int id)
{
  if (labels.count(id))
    return labels[id];

  return Label();
}

int Labels::count()
{
  return labels.size();
}

void Labels::notify(Action action, const Label &label)
{
  for (auto &subscriber : subscribers)
    subscriber(action, label);
}

Fix Labels::getById so that it doesn't insert default labes.

This was the case when calling getById with a not existing id.


#include "SetOutputPacket.h"

IPOCS::SetOutputPacket::SetOutputPacket()
{
  this->RNID_PACKET = 13;
}

IPOCS::Packet* IPOCS::SetOutputPacket::create()
{
  return new IPOCS::SetOutputPacket();
}

uint8_t IPOCS::SetOutputPacket::parseSpecific(uint8_t buffer[])
{
  this->RQ_OUTPUT_COMMAND = (SetOutputPacket::E_RQ_OUTPUT_COMMAND)buffer[0];
  this->RT_DURATION = (buffer[1] << 8) + buffer[2];
  return 3;
}

uint8_t IPOCS::SetOutputPacket::serializeSpecific(uint8_t buffer[])
{
  buffer[0] = this->RQ_OUTPUT_COMMAND;
  buffer[1] = this->RT_DURATION >> 8;
  buffer[2] = this->RT_DURATION & 0x100;
  return 3;
}

__attribute__((constructor))
static void initialize_packet_throwpoints() {
  IPOCS::Packet::registerCreator(13, &IPOCS::SetOutputPacket::create);
}

#include "SetOutputPacket.h"

IPOCS::SetOutputPacket::SetOutputPacket()
{
  this->RNID_PACKET = 13;
}

IPOCS::Packet* IPOCS::SetOutputPacket::create()
{
  return new IPOCS::SetOutputPacket();
}

uint8_t IPOCS::SetOutputPacket::parseSpecific(uint8_t buffer[])
{
  this->RQ_OUTPUT_COMMAND = (SetOutputPacket::E_RQ_OUTPUT_COMMAND)buffer[0];
  this->RT_DURATION = (buffer[1] << 8) + buffer[2];
  return 3;
}

uint8_t IPOCS::SetOutputPacket::serializeSpecific(uint8_t buffer[])
{
  buffer[0] = this->RQ_OUTPUT_COMMAND;
  buffer[1] = this->RT_DURATION >> 8;
  buffer[2] = this->RT_DURATION & 0xFF;
  return 3;
}

__attribute__((constructor))
static void initialize_packet_throwpoints() {
  IPOCS::Packet::registerCreator(13, &IPOCS::SetOutputPacket::create);
}

Fix set order serialization bug

Fix set order serialization bug


/* BEGIN_COMMON_COPYRIGHT_HEADER
 * (c)LGPL2+
 *
 * LXDE-Qt - a lightweight, Qt based, desktop toolset
 * http://razor-qt.org
 *
 * Copyright: 2013 Razor team
 * Authors:
 *   Kuzma Shapran <kuzma.shapran@gmail.com>
 *
 * This program or library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * END_COMMON_COPYRIGHT_HEADER */

#include <lxqt/lxqtapplication.h>
#include "lxqttranslate.h"

#include "main_window.h"

int main(int argc, char *argv[])
{
    LxQt::Application a(argc, argv);
    TRANSLATE_APP;

    MainWindow w;
    w.show();

    return a.exec();
}

/* BEGIN_COMMON_COPYRIGHT_HEADER
 * (c)LGPL2+
 *
 * LXDE-Qt - a lightweight, Qt based, desktop toolset
 * http://razor-qt.org
 *
 * Copyright: 2013 Razor team
 * Authors:
 *   Kuzma Shapran <kuzma.shapran@gmail.com>
 *
 * This program or library is free software; you can redistribute it
 * and/or modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * END_COMMON_COPYRIGHT_HEADER */

#include <LXQt/Application>
#include "lxqttranslate.h"

#include "main_window.h"

int main(int argc, char *argv[])
{
    LxQt::Application a(argc, argv);
    TRANSLATE_APP;

    MainWindow w;
    w.show();

    return a.exec();
}

Use new LXQt header files.

Use new LXQt header files.


/* Copyright (c) 2013-2019 Jeffrey Pfau
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "RotatedHeaderView.h"

#include <QPainter>

using namespace QGBA;

RotatedHeaderView::RotatedHeaderView(Qt::Orientation orientation, QWidget* parent)
	: QHeaderView(orientation, parent)
{
}

void RotatedHeaderView::paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const {
	painter->save();
	painter->translate(rect.x() + rect.width(), rect.y());
	painter->rotate(90);
	QHeaderView::paintSection(painter, QRect(0, 0, rect.height(), rect.width()), logicalIndex);
	painter->restore();
}

QSize RotatedHeaderView::sectionSizeFromContents(int logicalIndex) const {
	return QHeaderView::sectionSizeFromContents(logicalIndex).transposed();
}

/* Copyright (c) 2013-2019 Jeffrey Pfau
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "RotatedHeaderView.h"

#include <QPainter>

using namespace QGBA;

RotatedHeaderView::RotatedHeaderView(Qt::Orientation orientation, QWidget* parent)
	: QHeaderView(orientation, parent)
{
	int margin = 2 * style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
	setMinimumSectionSize(fontMetrics().height() + margin);
}

void RotatedHeaderView::paintSection(QPainter* painter, const QRect& rect, int logicalIndex) const {
	painter->save();
	painter->translate(rect.x() + rect.width(), rect.y());
	painter->rotate(90);
	QHeaderView::paintSection(painter, QRect(0, 0, rect.height(), rect.width()), logicalIndex);
	painter->restore();
}

QSize RotatedHeaderView::sectionSizeFromContents(int logicalIndex) const {
	return QHeaderView::sectionSizeFromContents(logicalIndex).transposed();
}

Fix logging config section width

Qt: Fix logging config section width


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

#include "chromeos/system/devicetype.h"

#include <string>

#include "base/sys_info.h"

namespace chromeos {

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

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

  return DeviceType::kUnknown;
}

}  // namespace chromeos

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

#include "chromeos/system/devicetype.h"

#include <string>

#include "base/sys_info.h"

namespace chromeos {

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

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

  return DeviceType::kUnknown;
}

}  // namespace chromeos

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

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

BUG=341356

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

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


#include "Mocks.hpp"

namespace testing {

enum level : std::uint8_t { debug, info, warn, error };

} // namespace testing

namespace blackhole { namespace sink {

template<>
struct priority_traits<testing::level> {
    static inline
    priority_t map(testing::level lvl) {
        switch (lvl) {
        case testing::level::debug:
            return priority_t::debug;
        case testing::level::info:
            return priority_t::info;
        case testing::level::warn:
            return priority_t::warning;
        case testing::level::error:
            return priority_t::err;
        }
    }
};

} } // namespace blackhole::sink

TEST(Functional, SyslogConfiguredVerboseLogger) {
    verbose_logger_t<testing::level> log;

    typedef formatter::string_t formatter_type;
    typedef sink::syslog_t<testing::level> sink_type;

    auto formatter = std::make_unique<formatter_type>("%(message)s [%(...L)s]");
    auto sink = std::make_unique<sink_type>("testing");
    auto frontend = std::make_unique<frontend_t<formatter_type, sink_type, testing::level>>(std::move(formatter), std::move(sink));
    log.add_frontend(std::move(frontend));

    log::record_t record = log.open_record(level::error);
    if (record.valid()) {
        record.attributes["message"] = { utils::format("Some message from: '%s'!", "Hell") };
        // Add another attributes.
        log.push(std::move(record));
    }
}

#include "Mocks.hpp"

namespace testing {

enum level : std::uint8_t { debug, info, warn, error };

} // namespace testing

namespace blackhole { namespace sink {

template<>
struct priority_traits<testing::level> {
    static inline
    priority_t map(testing::level lvl) {
        switch (lvl) {
        case testing::level::debug:
            return priority_t::debug;
        case testing::level::info:
            return priority_t::info;
        case testing::level::warn:
            return priority_t::warning;
        case testing::level::error:
            return priority_t::err;
        }
    }
};

} } // namespace blackhole::sink

TEST(Functional, SyslogConfiguredVerboseLogger) {
    verbose_logger_t<testing::level> log;

    typedef formatter::string_t formatter_type;
    typedef sink::syslog_t<testing::level> sink_type;

    auto formatter = std::make_unique<formatter_type>("%(message)s [%(...L)s]");
    auto sink = std::make_unique<sink_type>("testing");
    auto frontend = std::make_unique<frontend_t<formatter_type, sink_type, testing::level>>(std::move(formatter), std::move(sink));
    log.add_frontend(std::move(frontend));

    log::record_t record = log.open_record(level::error);
    if (record.valid()) {
        record.attributes["message"] = { utils::format("Some message from: '%s'!", "Hell"), log::attribute::scope::event };
        log.push(std::move(record));
    }
}

Fix message scope level for functional test.


#include "devicethread.h"

DeviceThread::DeviceThread()
{
  exit = false;
}

void DeviceThread::finish()
{
  exit = true;
}

DeviceThread::run()
{
  int ret;
  while(!exit)
  {
    if(!board.isConnected())
    {
      ret = board.attachDevice();
      if(ret < 0)
      {
        //Failed to attach
        wait(3000);
        notConnected();
        continue;
      }
      else
        connected();
    }

    //Connected, do actual work in this thread...

    //Update status
    getBacklightState();

    //Process command queue
    while(!cmd.isEmpty())
    {
      Command_t c = cmd.dequeue();
      if(!IS_GET(c.cmd))
        board.sendCmd(c.cmd, c.arg1, c.arg2, c.arg3);
      else
      {
        //TODO:
      }
    }

    //Wait for some time period. Number chosen at random as prime.
    wait(635);
  }
}

void DeviceThread::enqueue(const Command_t & c)
{
  cmd.enqueue(c);
}

#include "devicethread.h"

DeviceThread::DeviceThread()
{
  exit = false;
}

void DeviceThread::finish()
{
  exit = true;
}

DeviceThread::run()
{
  int ret;
  while(!exit)
  {
    if(!board.isConnected())
    {
      ret = board.attachDevice();
      if(ret < 0)
      {
        //Failed to attach
        wait(3000);
        notConnected();
        continue;
      }
      else
        connected();
    }

    //Connected, do actual work in this thread...

    //Update status
    getBacklightState();

    //Process command queue
    while(!cmd.isEmpty())
    {
      Command_t c = cmd.dequeue();
      if(!IS_GET(c.cmd))
        board.sendCmd(c.cmd, c.arg1, c.arg2, c.arg3);
      else
      {
        uint8_t buf[EP_LEN];
        board.sendCmd(c.cmd, c.arg1, c.arg2, c.arg3, &buf);
        if(buf[0] == CMD_RES && buf[1] == CMD_BL_GET_STATE)
          emit(backlightResponse(buf[2], buf[3]));
      }
    }

    //Wait for some time period. Number chosen at random as prime.
    wait(635);
  }
}

void DeviceThread::enqueue(const Command_t & c)
{
  cmd.enqueue(c);
}

Handle get command response parsin

Handle get command response parsin


// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <sys/mman.h>

#if defined(__FreeBSD__)
// The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
// that, it was never implemented.  So just define it to zero.
#undef  MAP_NORESERVE
#define MAP_NORESERVE 0
#endif

int main() {
#ifdef __x86_64__
  const size_t kLog2Size = 39;
#elif defined(__mips64) || defined(__aarch64__)
  const size_t kLog2Size = 32;
#endif
  const uintptr_t kLocation = 0x40ULL << kLog2Size;
  void *p = mmap(
      reinterpret_cast<void*>(kLocation),
      1ULL << kLog2Size,
      PROT_READ|PROT_WRITE,
      MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,
      -1, 0);
  fprintf(stderr, "DONE %p %d\n", p, errno);
  return p == MAP_FAILED;
}

// CHECK: DONE

// RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <sys/mman.h>

#if defined(__FreeBSD__)
// The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
// that, it was never implemented.  So just define it to zero.
#undef  MAP_NORESERVE
#define MAP_NORESERVE 0
#endif

int main() {
#ifdef __x86_64__
  const size_t kLog2Size = 39;
#elif defined(__mips64) || defined(__aarch64__)
  const size_t kLog2Size = 32;
#endif
  const uintptr_t kLocation = 0x40ULL << kLog2Size;
  void *p = mmap(
      reinterpret_cast<void*>(kLocation),
      1ULL << kLog2Size,
      PROT_READ|PROT_WRITE,
      MAP_PRIVATE|MAP_ANON|MAP_NORESERVE,
      -1, 0);
  fprintf(stderr, "DONE %p %d\n", p, errno);
  return p == MAP_FAILED;
}

// CHECK: DONE

Use MAP_ANON instead of MAP_ANONYMOUS

[tsan] Use MAP_ANON instead of MAP_ANONYMOUS

In mmap_large.cc, let's use MAP_ANON instead of MAP_ANONYMOUS, because MAP_ANONYMOUS is only available on OS X 10.11 and later.

Differential Revision: http://reviews.llvm.org/D15180

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


#include <hal.h>

#include <pwm_config.hpp>

PWMDriver *pwmPlatformInit(void) {
  pwmStart(&PWMD8, &motor_pwm_config);
  palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 7, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 8, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 9, PAL_MODE_ALTERNATE(4));
  return &PWMD8;
}

// TODO(yoos): process multiple drivers
void pwmPlatformSet(uint8_t ch, float dc) {
  pwmcnt_t width = PWM_PERCENTAGE_TO_WIDTH(&PWMD8, dc * 10000);
  pwmEnableChannel(&PWMD8, ch, width);
}

#include <hal.h>

#include <pwm_config.hpp>

PWMDriver *pwmPlatformInit(void) {
  pwmStart(&PWMD8, &motor_pwm_config);
  palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 7, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 8, PAL_MODE_ALTERNATE(4));
  palSetPadMode(GPIOC, 9, PAL_MODE_ALTERNATE(4));
  return &PWMD8;
}

// TODO(yoos): process multiple drivers
void pwmPlatformSet(uint8_t ch, float dc) {
  pwmcnt_t width = PWM_PERCENTAGE_TO_WIDTH(&PWMD8, dc * 10000.0f);
  pwmEnableChannel(&PWMD8, ch, width);
}

Use `f` suffix on floating point numbers.


// Copyright (C) 2012-2015 Leap Motion, Inc. All rights reserved.
#include "stdafx.h"
#include <autowiring/auto_tuple.h>
#include <string>

class TupleTest:
  public testing::Test
{};

TEST_F(TupleTest, CallTest) {
  autowiring::tuple<int, int, std::string> t(101, 102, "Hello world!");

  ASSERT_EQ(101, autowiring::get<0>(t)) << "First tuple value was invalid";
  ASSERT_EQ(102, autowiring::get<1>(t)) << "Second tuple value was invalid";
}

TEST_F(TupleTest, TieTest) {
  std::unique_ptr<int> val(new int(22));

  autowiring::tuple<std::unique_ptr<int>&> tup(val);
  ASSERT_EQ(22, *autowiring::get<0>(tup)) << "Tied tuple did not retrieve the expected value";
}

TEST_F(TupleTest, AddressTest) {
  autowiring::tuple<std::unique_ptr<int>> tup;
  std::unique_ptr<int>& v = autowiring::get<0>(tup);

  ASSERT_EQ(&tup.value, &v) << "Get operation did not provide a correct reference to the underlying tuple value";
}

Add a test to verify get's return value behavior

This is a pretty critical trait for `autowiring::get` to have, it should be guaranteed via a test.


// Tests -fsanitize-coverage=inline-8bit-counters
//
// REQUIRES: has_sancovcc,stable-runtime
// UNSUPPORTED: i386-darwin, x86_64-darwin, x86_64h-darwin
//
// RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters 2>&1

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

const char *first_counter;

extern "C"
void __sanitizer_cov_8bit_counters_init(const char *start, const char *end) {
  printf("INIT: %p %p\n", start, end);
  assert(end - start > 1);
  first_counter = start;
}

int main() {
  assert(first_counter);
  assert(*first_counter == 1);
}

// Tests -fsanitize-coverage=inline-8bit-counters
//
// REQUIRES: has_sancovcc,stable-runtime
// UNSUPPORTED: i386-darwin
//
// RUN: %clangxx -O0 %s -fsanitize-coverage=inline-8bit-counters 2>&1

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

const char *first_counter;

extern "C"
void __sanitizer_cov_8bit_counters_init(const char *start, const char *end) {
  printf("INIT: %p %p\n", start, end);
  assert(end - start > 1);
  first_counter = start;
}

int main() {
  assert(first_counter);
  assert(*first_counter == 1);
}

[sanitizer-coverage] Stop marking this test as unsupported on Darwin

The bug that was causing this to fail was fixed in r305429.

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


// Native C++ Libraries
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

// C++ Interpreter Libraries
#include <Console.h>
#include <Varible.h>
#include <Include.h>

using namespace std;

int main()
{
	RESTART:
	string input = "";
	ConsoleOutCheck(input);
	CheckForInt(input);
	CheckForIntAfterMath(input);
	CHECKFORIOSTREAM(input);
	getline(cin, input);
	goto RESTART;
}

// Native C++ Libraries
#include <iostream>
#include <string>
#include <sstream>
#include <vector>

// C++ Interpreter Libraries
#include <Console.h>
#include <Varible.h>
#include <Include.h>

using namespace std;

int main()
{
	cout << "CPP Interpreter v0.1. Here you can type C++ code in the terminal and get instant feedback from it.\n\n\n";
	RESTART:
	cout << "--->";
	string input = "";
	ConsoleOutCheck(input);
	CheckForInt(input);
	CheckForIntAfterMath(input);
	CHECKFORIOSTREAM(input);
	getline(cin, input);
	goto RESTART;
}

Add a message on the start of CPP-Interpreter.

Add a greeting message to show on the beginning of the program. Also add
a current command pointer.


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

// <chrono>

// treat_as_floating_point

#include <chrono>
#include <type_traits>

#include "test_macros.h"

template <class T>
void
test()
{
    static_assert((std::is_base_of<std::is_floating_point<T>,
                                   std::chrono::treat_as_floating_point<T> >::value), "");
#if TEST_STD_VER > 14
    static_assert((std::is_base_of<std::is_floating_point<T>,
                                   std::chrono::treat_as_floating_point_v<T> >), "");
#endif
}

struct A {};

int main()
{
    test<int>();
    test<unsigned>();
    test<char>();
    test<bool>();
    test<float>();
    test<double>();
    test<long double>();
    test<A>();
}

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

// <chrono>

// treat_as_floating_point

#include <chrono>
#include <type_traits>

#include "test_macros.h"

template <class T>
void
test()
{
    static_assert((std::is_base_of<std::is_floating_point<T>,
                                   std::chrono::treat_as_floating_point<T> >::value), "");
#if TEST_STD_VER > 14
    static_assert(std::is_floating_point<T>::value ==
                                  std::chrono::treat_as_floating_point_v<T>, "");
#endif
}

struct A {};

int main()
{
    test<int>();
    test<unsigned>();
    test<char>();
    test<bool>();
    test<float>();
    test<double>();
    test<long double>();
    test<A>();
}

Fix bad test that was previously getting ifdef-ed away

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


// Copyright 2017, Dawid Kurek, <dawikur@gmail.com>

#include "lel.hpp"

#include "gtest/gtest.h"

class sizeof_lambdas_test : public ::testing::Test {
 protected:
  LeL::Placeholder<'x'> _x;
  LeL::Placeholder<'y'> _y;
};

TEST_F(sizeof_lambdas_test, base_placeholder_is_1) {
  ASSERT_EQ(1, sizeof(_x));
}

TEST_F(sizeof_lambdas_test, DISABLED_placeholder_with_one_int_equals_size_of_int) {
  ASSERT_EQ(sizeof(1), sizeof(_x + 1));
}

TEST_F(sizeof_lambdas_test, DISABLED_placeholder_with_two_ints_equals_sizof_to_ints) {
  ASSERT_EQ(sizeof(1) + sizeof(5), sizeof(_x + 1 < 5));
}

TEST_F(sizeof_lambdas_test, DISABLED_multiple_base_placehlder_is_1) {
  ASSERT_EQ(1, sizeof(_x < _y));
}

Add tests on sizeof lambdas

Add tests on sizeof lambdas

Most of them are disabled for now; they will be fine to run when
Empty Base Optimization will be implemented


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

struct D;
struct B {
 virtual D& operator = (const D&);
};
struct D : B { D(); virtual void a(); };
void D::a() {}

// CHECK: @_ZTV1D = {{.*}} @_ZN1DaSERKS_
// CHECK: define linkonce_odr {{.*}} @_ZN1DaSERKS_

Tweak test to check for a bit more.

Tweak test to check for a bit more.

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


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

#include <stdio.h>

char bigchunk[1 << 30];

int main() {
  printf("Hello, world!\n");
  scanf("%s", bigchunk);
// CHECK-NOT: Hello, world!
// CHECK: Shadow memory range interleaves with an existing memory mapping.
// CHECK: ASan shadow was supposed to be located in the [0x2fff0000-0x{{.*}}ffff] range.
// CHECK: Dumping process modules:
// CHECK-DAG: 0x{{[0-9a-f]*}}-0x{{[0-9a-f]*}} {{.*}}shadow_mapping_failure
// CHECK-DAG: 0x{{[0-9a-f]*}}-0x{{[0-9a-f]*}} {{.*}}ntdll.dll
}

// RUN: %clang_cl_asan -O0 %s -Fe%t
// RUN: not %run %t 2>&1 | FileCheck %s
// REQUIRES: asan-32-bits

#include <stdio.h>

char bigchunk[1 << 30];

int main() {
  printf("Hello, world!\n");
  scanf("%s", bigchunk);
// CHECK-NOT: Hello, world!
// CHECK: Shadow memory range interleaves with an existing memory mapping.
// CHECK: ASan shadow was supposed to be located in the [0x2fff0000-0x{{.*}}ffff] range.
// CHECK: Dumping process modules:
// CHECK-DAG: 0x{{[0-9a-f]*}}-0x{{[0-9a-f]*}} {{.*}}shadow_mapping_failure
// CHECK-DAG: 0x{{[0-9a-f]*}}-0x{{[0-9a-f]*}} {{.*}}ntdll.dll
}

Disable irrelevant unittest on win64

[compiler-rt/asan] Disable irrelevant unittest on win64

Summary:
This test is allocating a 1gig chunk to make shadow allocation failed,
but on 64-bits architecture the test is working.

Reviewers: rnk

Subscribers: kubabrecka, llvm-commits, wang0109, chrisha

Differential Revision: https://reviews.llvm.org/D22553

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


#include <UnitTest++.h>

#include "../src/ToJsonWriter.h"

SUITE(ArticleToJsonWriterTests)
{
    TEST(WriteArticleWithoutLinks)
    {
        ToJsonWriter atj;
        Article a("Farm");
        CHECK_EQUAL("{\"Farm\":[]}", atj.convertToJson(&a));
    }

    TEST(WriteArticleWithOneLink)
    {
        ToJsonWriter atj;
        Article a("Farm");
        a.addLink(new Article("Animal"));
        CHECK_EQUAL("{\"Farm\":[\"Animal\"]}", atj.convertToJson(&a));
    }

    TEST(WriteArticleWithMultipleLinks)
    {
        ToJsonWriter atj;
        Article a("Farm");
        a.addLink(new Article("Animal"));
        a.addLink(new Article("Pig"));
        a.addLink(new Article("Equality"));
        CHECK_EQUAL("{\"Farm\":[\"Animal\",\"Pig\",\"Equality\"]}", atj.convertToJson(&a));
    }

    TEST(WriteEmptyArticleCollection)
    {
        ToJsonWriter atj;
        ArticleCollection ac;
        CHECK_EQUAL("{}", atj.convertToJson(ac));
    }

    TEST(WriteArticleCollection_OneArticleWithoutLinks)
    {
        ToJsonWriter atj;
        ArticleCollection ac;
        ac.add(new Article("Foo"));
        CHECK_EQUAL("{\"Foo\":[]}", atj.convertToJson(ac));
    }
}

#include <UnitTest++.h>

#include "../src/ToJsonWriter.h"

SUITE(ArticleToJsonWriterTests)
{
    TEST(WriteArticleWithoutLinks)
    {
        ToJsonWriter atj;
        Article a("Farm");
        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[]}}", atj.convertToJson(&a));
    }

    TEST(WriteArticleWithOneLink)
    {
        ToJsonWriter atj;
        Article a("Farm");
        a.addLink(new Article("Animal"));
        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[\"Animal\"]}}", atj.convertToJson(&a));
    }

    TEST(WriteArticleWithMultipleLinks)
    {
        ToJsonWriter atj;
        Article a("Farm");
        a.addLink(new Article("Animal"));
        a.addLink(new Article("Pig"));
        a.addLink(new Article("Equality"));
        CHECK_EQUAL("{\"Farm\":{\"forward_links\":[\"Animal\",\"Pig\",\"Equality\"]}}", atj.convertToJson(&a));
    }

    TEST(WriteEmptyArticleCollection)
    {
        ToJsonWriter atj;
        ArticleCollection ac;
        CHECK_EQUAL("{}", atj.convertToJson(ac));
    }

    TEST(WriteArticleCollection_OneArticleWithoutLinks)
    {
        ToJsonWriter atj;
        ArticleCollection ac;
        ac.add(new Article("Foo"));
        CHECK_EQUAL("{\"Foo\":{\"forward_links\":[]}}", atj.convertToJson(ac));
    }
}

Change requirements for json writer:

Change requirements for json writer:

  must not include links as "plain array", but inside another object.
  so later, I can add e.g. "reverse links".


// Chapter 23, Try This 1: replace 333 in example with 10

#include<iostream>
#include<iomanip>

int main()
{
    float x = 1.0/10;
    float sum = 0;
    for (int i = 0; i<10; ++i) sum += x;
    std::cout << std::setprecision(15) << sum << '\n';
}

// Chapter 24, Try This 1: replace 333 in example with 10

#include<iostream>
#include<iomanip>

int main()
{
    float x = 1.0/10;
    float sum = 0;
    for (int i = 0; i<10; ++i) sum += x;
    std::cout << std::setprecision(15) << sum << '\n';
}

Correct typo (23 to 24)

Correct typo (23 to 24)


/*
 * auxiliary.cpp - Auxiliary public functions
 *
 *   Copyright 2010 Jesús Torres <jmtorres@ull.es>
 *
 * 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>
#include <vector>

#include <boost/shared_array.hpp>

#include <cli/auxiliary.hpp>

#include "fileno.hpp"

namespace cli { namespace auxiliary
{

    boost::shared_array<const char*>
    stdVectorStringToArgV(const std::vector<std::string> &strings)
    {
        int length = strings.size();
        boost::shared_array<const char*> argv =
            boost::shared_array<const char*>(new const char*[length]);
        for (int i = 0; i < length; i++) {
            argv[i] = strings[i].c_str();
        }
        return argv;
    }

}}

/*
 * auxiliary.cpp - Auxiliary public functions
 *
 *   Copyright 2010 Jesús Torres <jmtorres@ull.es>
 *
 * 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>
#include <vector>

#include <boost/shared_array.hpp>

#include <cli/auxiliary.hpp>

#include "fileno.hpp"

namespace cli { namespace auxiliary
{

    boost::shared_array<const char*>
    stdVectorStringToArgV(const std::vector<std::string> &strings)
    {
        int length = strings.size();
        boost::shared_array<const char*> argv =
            boost::shared_array<const char*>(new const char*[length + 1]);
        for (int i = 0; i < length; i++) {
            argv[i] = strings[i].c_str();
        }
        argv[length] = NULL;
        return argv;
    }

}}

Add null at the of argv when converting from std::vector<std:string>


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

#include "SkTypes.h"

#if !defined(__has_feature)
    #define __has_feature(x) 0
#endif

#if __has_feature(address_sanitizer)

extern "C" {

    const char* __lsan_default_suppressions();
    const char* __lsan_default_suppressions() {
        return "leak:libfontconfig\n"       // FontConfig looks like it leaks, but it doesn't.
               "leak:libGL.so\n"            // For NVidia driver.
               "leak:libGLX_nvidia.so\n"    // For NVidia driver.
               "leak:libnvidia-glcore.so\n" // For NVidia driver.
               "leak:__strdup\n"            // An eternal mystery, skia:2916.
               ;
    }

}

#endif

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

#include "SkTypes.h"

#if !defined(__has_feature)
    #define __has_feature(x) 0
#endif

#if __has_feature(address_sanitizer)

extern "C" {

    const char* __lsan_default_suppressions();
    const char* __lsan_default_suppressions() {
        return "leak:libfontconfig\n"       // FontConfig looks like it leaks, but it doesn't.
               "leak:libGL.so\n"            // For NVidia driver.
               "leak:libGLX_nvidia.so\n"    // For NVidia driver.
               "leak:libnvidia-glcore.so\n" // For NVidia driver.
               "leak:libnvidia-tls.so\n"    // For NVidia driver.
               "leak:__strdup\n"            // An eternal mystery, skia:2916.
               ;
    }

}

#endif

Add another NVIDIA LSAN suppression.

Add another NVIDIA LSAN suppression.

Change-Id: Ied919cacc0fde26b75a12b469bc4850d6f8a2f40
Reviewed-on: https://skia-review.googlesource.com/c/177804
Auto-Submit: Ben Wagner <3ef7217be91069877d94f7907ce5479000772cd3@google.com>
Commit-Queue: Ben Wagner <3ef7217be91069877d94f7907ce5479000772cd3@google.com>
Commit-Queue: Eric Boren <0e499112533c8544f0505ea0d08394fb5ad7d8fa@google.com>
Reviewed-by: Eric Boren <0e499112533c8544f0505ea0d08394fb5ad7d8fa@google.com>


Matrix2f M = Matrix2f::Random();
Matrix2f m;
m = M;
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Now we want to replace m by its own transpose." << endl;
cout << "If we do m = m.transpose(), then m becomes:" << endl;
m = m.transpose() * 1;
cout << m << endl << "which is wrong!" << endl;
cout << "Now let us instead do m = m.transpose().eval(). Then m becomes" << endl;
m = M;
m = m.transpose().eval();
cout << m << endl << "which is right." << endl;

Matrix2f M = Matrix2f::Random();
Matrix2f m;
m = M;
cout << "Here is the matrix m:" << endl << m << endl;
cout << "Now we want to copy a column into a row." << endl;
cout << "If we do m.col(1) = m.row(0), then m becomes:" << endl;
m.col(1) = m.row(0);
cout << m << endl << "which is wrong!" << endl;
cout << "Now let us instead do m.col(1) = m.row(0).eval(). Then m becomes" << endl;
m = M;
m.col(1) = m.row(0).eval();
cout << m << endl << "which is right." << endl;

Make snippet run successfully again: the snippet for 'eval' was taking m=m.transpose() as an example of code that needs an explicit call to eval(), but that doesn't work anymore now that we have the clever assert detecting aliasing issues.


#include "mainwindow.hpp"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setApplicationName("KShare");
    a.setOrganizationName("ArsenArsen");
    a.setApplicationVersion("1.0");

    MainWindow w;
    w.show();
    return a.exec();
}

#include "mainwindow.hpp"
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include <stdio.h>

bool verbose = false;

void handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    QByteArray localMsg = msg.toLocal8Bit();
    switch (type)
    {
    case QtDebugMsg:
        if (verbose)
            fprintf(stdout, "DEBUG %s:%s(%d): %s\n", context.file, context.function, context.line, localMsg.constData());
        break;
    case QtInfoMsg:
        fprintf(stdout, "INFO %s:%s(%d): %s\n", context.file, context.function, context.line, localMsg.constData());
        break;
    case QtWarningMsg:
        fprintf(stderr, "WARN %s:%s(%d): %s\n", context.file, context.function, context.line, localMsg.constData());
        break;
    case QtCriticalMsg:
        fprintf(stderr, "CRIT %s:%s(%d): %s\n", context.file, context.function, context.line, localMsg.constData());
        break;
    case QtFatalMsg:
        fprintf(stderr, "FATAL %s:%s(%d): %s\n", context.file, context.function, context.line, localMsg.constData());
        break;
    }
}

int main(int argc, char *argv[])
{
    qInstallMessageHandler(handler);
    QApplication a(argc, argv);
    a.setApplicationName("KShare");
    a.setOrganizationName("ArsenArsen");
    a.setApplicationVersion("1.0");

    QCommandLineParser parser;
    parser.addHelpOption();

    QCommandLineOption h({ "b", "background" }, "Does not show the main window, starts in tray.");
    QCommandLineOption v({ "v", "verbose" }, "Enables QtDebugMsg outputs");
    parser.addOption(h);
    parser.addOption(v);
    parser.process(a);
    verbose = parser.isSet(v);

    MainWindow w;
    if (!parser.isSet(h)) w.show();
    return a.exec();
}

Add command line options. WE GOING 1.0

Add command line options. WE GOING 1.0


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

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

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

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

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

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

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

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

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

Enable ExtensionApiTest.GetViews on all platforms.

BUG=none
TEST=passes everywhere

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

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


/* Copyright (c) 2013-2014 Jeffrey Pfau
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GBAApp.h"
#include "Window.h"

#ifdef QT_STATIC
#include <QtPlugin>
#ifdef _WIN32
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
Q_IMPORT_PLUGIN(QWindowsAudioPlugin);
#endif
#endif

int main(int argc, char* argv[]) {
	QGBA::GBAApp application(argc, argv);
	return application.exec();
}

/* Copyright (c) 2013-2014 Jeffrey Pfau
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GBAApp.h"
#include "Window.h"

#ifdef QT_STATIC
#include <QtPlugin>
#ifdef _WIN32
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#ifdef BUILD_QT_MULTIMEDIA
Q_IMPORT_PLUGIN(QWindowsAudioPlugin);
#endif
#endif
#endif

int main(int argc, char* argv[]) {
	QGBA::GBAApp application(argc, argv);
	return application.exec();
}

Qt: Fix Windows build when Qt Multimedia is disabled


#include "OI.h"
#include "Commands/DefaultDrive.h"
#include "Subsystems/Chassis.h"
#include "Misc/ToggleClass.h"

/// Default constructor of the class.
DefaultDrive::DefaultDrive()
{
	Requires(Chassis::GetInstance());
	shifterToggle = new Toggle<bool>(false, true);
}

/// Called just before this Command runs the first time.
void DefaultDrive::Initialize()
{
	Chassis::GetInstance()->ReleaseAngle();
}

//Pass values from joysticks to the Drive subsystem
void DefaultDrive::Execute()
{
	OI* oi = OI::GetInstance();
	double moveSpeed = -oi->gamepad->GetRawAxis(LST_AXS_LJOYSTICKY);
	double turnSpeed = -oi->gamepad->GetRawAxis(LST_AXS_RJOYSTICKX);

	// Only driving manual should require Quadratic inputs. By default it should be turned off
	// Therefore here we turn it on explicitly.
	Chassis::GetInstance()->DriveArcade(moveSpeed, turnSpeed, true);
}

/// Make this return true when this Command no longer needs to run execute().
/// \return always false since this is the default command and should never finish.
bool DefaultDrive::IsFinished()
{
	return false;
}

/// Called once after isFinished returns true
void DefaultDrive::End()
{
}

/// Called when another command which requires one or more of the same
/// subsystems is scheduled to run
void DefaultDrive::Interrupted()
{
}

#include "OI.h"
#include "Commands/DefaultDrive.h"
#include "Subsystems/Chassis.h"
#include "Misc/ToggleClass.h"

/// Default constructor of the class.
DefaultDrive::DefaultDrive()
{
	Requires(Chassis::GetInstance());
	shifterToggle = new Toggle<bool>(false, true);
}

/// Called just before this Command runs the first time.
void DefaultDrive::Initialize()
{
	Chassis::GetInstance()->ReleaseAngle();
}

//Pass values from joysticks to the Drive subsystem
void DefaultDrive::Execute()
{
	OI* oi = OI::GetInstance();
	double moveSpeed = -oi->stickL->GetY();
	double turnSpeed = -oi->stickR->GetX();

	// Only driving manual should require Quadratic inputs. By default it should be turned off
	// Therefore here we turn it on explicitly.
	Chassis::GetInstance()->DriveArcade(moveSpeed, turnSpeed, true);
}

/// Make this return true when this Command no longer needs to run execute().
/// \return always false since this is the default command and should never finish.
bool DefaultDrive::IsFinished()
{
	return false;
}

/// Called once after isFinished returns true
void DefaultDrive::End()
{
}

/// Called when another command which requires one or more of the same
/// subsystems is scheduled to run
void DefaultDrive::Interrupted()
{
}

Return to driving on Joysticks

Return to driving on Joysticks


//===========================================
//  Lumina-DE source code
//  Copyright (c) 2015, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
#include "LHomeButton.h"
#include "../../LSession.h"

#include <LuminaX11.h>

LHomeButtonPlugin::LHomeButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){
  button = new QToolButton(this);
    button->setAutoRaise(true);
    button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

    connect(button, SIGNAL(clicked()), this, SLOT(showDesktop()));
    this->layout()->setContentsMargins(0,0,0,0);
    this->layout()->addWidget(button);

  QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes
}

LHomeButtonPlugin::~LHomeButtonPlugin(){

}

void LHomeButtonPlugin::updateButtonVisuals(){
  button->setIcon( LXDG::findIcon("go-home", "") );
}

// ========================
//    PRIVATE FUNCTIONS
// ========================
void LHomeButtonPlugin::showDesktop(){
  QList<WId> wins = LSession::handle()->XCB->WindowList();
  for(int i=0; i<wins.length(); i++){
    if( LXCB::INVISIBLE != LSession::handle()->XCB->WindowState(wins[i]) ){
      LSession::handle()->XCB->MinimizeWindow(wins[i]);
    }
  }
}

//===========================================
//  Lumina-DE source code
//  Copyright (c) 2015, Ken Moore
//  Available under the 3-clause BSD license
//  See the LICENSE file for full details
//===========================================
#include "LHomeButton.h"
#include "../../LSession.h"

#include <LuminaX11.h>

LHomeButtonPlugin::LHomeButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){
  button = new QToolButton(this);
    button->setAutoRaise(true);
    button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

    connect(button, SIGNAL(clicked()), this, SLOT(showDesktop()));
    this->layout()->setContentsMargins(0,0,0,0);
    this->layout()->addWidget(button);

  QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes
}

LHomeButtonPlugin::~LHomeButtonPlugin(){

}

void LHomeButtonPlugin::updateButtonVisuals(){
  button->setIcon( LXDG::findIcon("user-desktop", "") );
}

// ========================
//    PRIVATE FUNCTIONS
// ========================
void LHomeButtonPlugin::showDesktop(){
  QList<WId> wins = LSession::handle()->XCB->WindowList();
  for(int i=0; i<wins.length(); i++){
    if( LXCB::INVISIBLE != LSession::handle()->XCB->WindowState(wins[i]) ){
      LSession::handle()->XCB->MinimizeWindow(wins[i]);
    }
  }
}

Change the icon for the "showdesktop" plugin to be an image of the desktop (user-desktop) instead of a house.


/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2013 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */

#include "BasicListItem.h"

using namespace bb::cascades;

BasicListItem::BasicListItem() {
    item_ = new StandardListItem();
    setRoot(item_);
}

void BasicListItem::setData(QObject* data) {
    updateImage(data->property("leftImage").value<QUrl>());
    updateTitle(data->property("title").toString());
    connect(data, SIGNAL(leftImageChanged(const QUrl&)), SLOT(updateImage(const QUrl&)));
    connect(data, SIGNAL(titleChanged(const QString&)), SLOT(updateTitle(const QString&)));
    data_->disconnect(this);
    data_ = data;
}

void BasicListItem::updateImage(const QUrl& url) {
    item_->setImage(Image(url));
}

void BasicListItem::updateTitle(const QString& title) {
    item_->setTitle(title);
}

/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2013 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */

#include "BasicListItem.h"

using namespace bb::cascades;

BasicListItem::BasicListItem() {
    item_ = new StandardListItem();
    setRoot(item_);
}

void BasicListItem::setData(QObject* data) {
    updateImage(data->property("leftImage").value<QUrl>());
    updateTitle(data->property("title").toString());
    connect(data, SIGNAL(leftImageChanged(const QUrl&)), SLOT(updateImage(const QUrl&)));
    connect(data, SIGNAL(titleChanged(const QString&)), SLOT(updateTitle(const QString&)));
    data_->disconnect(this);
    data_ = data;
}

void BasicListItem::updateImage(const QUrl& url) {
    if (url.isEmpty()) {
        item_->resetImage();
        return;
    }
    item_->setImage(Image(url));
}

void BasicListItem::updateTitle(const QString& title) {
    item_->setTitle(title);
}

Reset list item image when setting empty URL.

This fixes an issue with empty space appearing
where the left image would go when no image is provided.


/**
 * @file
 *      sum_two_sales_data.cpp
 * @author
 *      Henrik Samuelsson
 */
#include <iostream>
#include "Sales_item.h"

/**
 * @brief
 *      Reads two sales_item's objects prints the sum.
 * @note
 *      The exercise instructions in the book state that the two objects have
 *      the same ISBN. It is assumed that it is up to the user to enter objects
 *      with the same ISBN, the program will not check this.
 * @return
 *      0 upon correct and completed execution
 */
int main() {
    Sales_item item1, item2;
    std::cin >> item1 >> item2;
    std::cout << item1 + item2;
    return 0;
}

/**
 * @file
 *      sum_two_sales_data.cpp
 * @author
 *      Henrik Samuelsson
 */
#include <iostream>
#include "Sales_item.h"

/**
 * @brief
 *      Reads two sales_item's objects and prints the sum.
 * @note
 *      The exercise instructions in the book state that the two objects have
 *      the same ISBN. It is assumed that it is up to the user to enter objects
 *      with the same ISBN, the program will not check this.
 * @return
 *      0 upon correct and completed execution
 */
int main() {
    Sales_item item1, item2;
    std::cin >> item1 >> item2;
    std::cout << item1 + item2;
    return 0;
}

Edit of comments in 1.21.

Edit of comments in 1.21.


#include "../common_includes.h"
#include "blend.h"

using namespace ogles_gpgpu;

const char *BlendProc::fshaderBlendSrc = OG_TO_STR
(
#if defined(OGLES_GPGPU_OPENGLES)
 precision highp float;
#endif

 varying vec2 textureCoordinate;
 varying vec2 textureCoordinate2;

 uniform sampler2D inputImageTexture;
 uniform sampler2D inputImageTexture2;
 uniform float alpha;

 void main()
 {
    vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
    vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate);
    gl_FragColor = mix(textureColor, textureColor2, alpha);
 });

BlendProc::BlendProc(float alpha) : alpha(alpha)
{

}

void BlendProc::getUniforms()
{
    TwoInputProc::getUniforms();
    shParamUAlpha = shader->getParam(UNIF, "alpha");
}

void BlendProc::setUniforms()
{
    TwoInputProc::setUniforms();
    glUniform1f(shParamUAlpha, alpha);
}

int BlendProc::render(int position)
{
    // Always render on position == 0
    if(position == 0)
    {
        FilterProcBase::render(position);
    }
    return position;
}

#include "../common_includes.h"
#include "blend.h"

using namespace ogles_gpgpu;

const char *BlendProc::fshaderBlendSrc = OG_TO_STR
(
#if defined(OGLES_GPGPU_OPENGLES)
 precision highp float;
#endif

 varying vec2 textureCoordinate;
 varying vec2 textureCoordinate2;

 uniform sampler2D inputImageTexture;
 uniform sampler2D inputImageTexture2;
 uniform float alpha;

 void main()
 {
    vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
    vec4 textureColor2 = texture2D(inputImageTexture2, textureCoordinate);
    gl_FragColor = mix(textureColor, textureColor2, alpha);
 });

BlendProc::BlendProc(float alpha) : alpha(alpha)
{

}

void BlendProc::getUniforms()
{
    TwoInputProc::getUniforms();
    shParamUAlpha = shader->getParam(UNIF, "alpha");
}

void BlendProc::setUniforms()
{
    TwoInputProc::setUniforms();
    glUniform1f(shParamUAlpha, alpha);
}

int BlendProc::render(int position)
{
    // Always render on position == 0
    TwoInputProc::render(position);
    return position;
}

Update filter for newer TwoInptProc::render() mechanism

Filter previously required tex1 and tex2 to be provided in specific order


#include "signal_handlers.h"

#include <cstring>

#include <iostream>

#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>

namespace keron {
namespace server {
std::atomic_int stop(0);

static BOOL handler(DWORD fdwCtrlType)
{

	switch (fdwCtrlType) {
		case CTRL_C_EVENT:
		case CTRL_CLOSE_EVENT:
			std::cout << "The server is going DOWN!" << std::endl;
			stop = 1;
			return TRUE;
		case CTRL_BREAK_EVENT:
		case CTRL_LOGOFF_EVENT:
		case CTRL_SHUTDOWN_EVENT:
			std::cout << "The server is going DOWN!" << std::endl;
			stop = 1;
			// Same return as the default case.
		default:
			return FALSE;
	}
}

int register_signal_handlers()
{
	return SetConsoleCtrlHandler((PHANDLER_ROUTINE)handler, TRUE) == TRUE;
}

} // namespace server
} // namespace keron

#include "signal_handlers.h"

#include <cstring>

#include <iostream>

#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>

namespace keron {
namespace server {
std::atomic_int stop(0);

static BOOL handler(DWORD fdwCtrlType)
{

	switch (fdwCtrlType) {
		case CTRL_C_EVENT:
		case CTRL_CLOSE_EVENT:
			std::cout << "The server is going DOWN!" << std::endl;
			stop.store(1);
			return TRUE;
		case CTRL_BREAK_EVENT:
		case CTRL_LOGOFF_EVENT:
		case CTRL_SHUTDOWN_EVENT:
			std::cout << "The server is going DOWN!" << std::endl;
			stop.store(1);
			// Same return as the default case.
		default:
			return FALSE;
	}
}

int register_signal_handlers()
{
	return SetConsoleCtrlHandler((PHANDLER_ROUTINE)handler, TRUE) == TRUE;
}

} // namespace server
} // namespace keron

Use store instead of "=" for atomic.

Use store instead of "=" for atomic.


// 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 "crypto/ec_signature_creator.h"

#include "base/logging.h"

namespace crypto {

// static
ECSignatureCreator* ECSignatureCreator::Create(ECPrivateKey* key) {
  NOTIMPLEMENTED();
  return NULL;
}

ECSignatureCreator::ECSignatureCreator(ECPrivateKey* key,
                                       HASH_HashType hash_type)
    : key_(key),
      hash_type_(hash_type) {
  NOTIMPLEMENTED();
}

ECSignatureCreator::~ECSignatureCreator() { }

bool ECSignatureCreator::Sign(const uint8* data,
                              int data_len,
                              std::vector<uint8>* signature) {
  NOTIMPLEMENTED();
  return false;
}

}  // namespace crypto

// 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 "crypto/ec_signature_creator.h"

#include "base/logging.h"

namespace crypto {

// static
ECSignatureCreator* ECSignatureCreator::Create(ECPrivateKey* key) {
  NOTIMPLEMENTED();
  return NULL;
}

ECSignatureCreator::ECSignatureCreator(ECPrivateKey* key)
    : key_(key) {
  NOTIMPLEMENTED();
}

ECSignatureCreator::~ECSignatureCreator() { }

bool ECSignatureCreator::Sign(const uint8* data,
                              int data_len,
                              std::vector<uint8>* signature) {
  NOTIMPLEMENTED();
  return false;
}

}  // namespace crypto

Remove wrong parameter from ECSignatureCreator's constructor in openssl implement.

The wrong parameter was unused and broke the linux redux build.

TBR=wtc
BUG=None.
TEST=Linux redux bot should be green.
Review URL: https://chromiumcodereview.appspot.com/9234024

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


// 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 "ppapi/shared_impl/instance_impl.h"

#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_input_event.h"

namespace ppapi {

InstanceImpl::~InstanceImpl() {
}

int32_t InstanceImpl::ValidateRequestInputEvents(bool is_filtering,
                                                 uint32_t event_classes) {
  // See if any bits are set we don't know about.
  if (event_classes &
      ~static_cast<uint32_t>(PP_INPUTEVENT_CLASS_MOUSE |
                             PP_INPUTEVENT_CLASS_KEYBOARD |
                             PP_INPUTEVENT_CLASS_WHEEL |
                             PP_INPUTEVENT_CLASS_TOUCH |
                             PP_INPUTEVENT_CLASS_IME))
    return PP_ERROR_NOTSUPPORTED;

  // See if the keyboard is requested in non-filtering mode.
  if (!is_filtering && (event_classes & PP_INPUTEVENT_CLASS_KEYBOARD))
    return PP_ERROR_NOTSUPPORTED;

  // Everything else is valid.
  return PP_OK;
}

}  // namespace ppapi

// 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 "ppapi/shared_impl/instance_impl.h"

#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_input_event.h"

namespace ppapi {

InstanceImpl::~InstanceImpl() {
}

int32_t InstanceImpl::ValidateRequestInputEvents(bool is_filtering,
                                                 uint32_t event_classes) {
  // See if any bits are set we don't know about.
  if (event_classes &
      ~static_cast<uint32_t>(PP_INPUTEVENT_CLASS_MOUSE |
                             PP_INPUTEVENT_CLASS_KEYBOARD |
                             PP_INPUTEVENT_CLASS_WHEEL |
                             PP_INPUTEVENT_CLASS_TOUCH |
                             PP_INPUTEVENT_CLASS_IME))
    return PP_ERROR_NOTSUPPORTED;

  // Everything else is valid.
  return PP_OK;
}

}  // namespace ppapi

Fix return value when unfiltered keyboard events are registered.

BUG=None
TEST=None

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

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