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

#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkRegion.h"
#include "SkSurface.h"

bool FuzzRegionDeserialize(sk_sp<SkData> bytes) {
    SkRegion region;
    if (!region.readFromMemory(bytes->data(), bytes->size())) {
        return false;
    }
    region.computeRegionComplexity();
    region.isComplex();
    SkRegion r2;
    if (region == r2) {
        region.contains(0,0);
    } else {
        region.contains(1,1);
    }
    auto s = SkSurface::MakeRasterN32Premul(1024, 1024);
    s->getCanvas()->drawRegion(region, SkPaint());
    SkDEBUGCODE(region.validate());
    return true;
}

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    auto bytes = SkData::MakeWithoutCopy(data, size);
    FuzzRegionDeserialize(bytes);
    return 0;
}
#endif

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

#include "SkCanvas.h"
#include "SkPaint.h"
#include "SkRegion.h"
#include "SkSurface.h"

bool FuzzRegionDeserialize(sk_sp<SkData> bytes) {
    SkRegion region;
    if (!region.readFromMemory(bytes->data(), bytes->size())) {
        return false;
    }
    region.computeRegionComplexity();
    region.isComplex();
    SkRegion r2;
    if (region == r2) {
        region.contains(0,0);
    } else {
        region.contains(1,1);
    }
    auto s = SkSurface::MakeRasterN32Premul(128, 128);
    if (!s) {
        // May return nullptr in memory-constrained fuzzing environments
        return false;
    }
    s->getCanvas()->drawRegion(region, SkPaint());
    SkDEBUGCODE(region.validate());
    return true;
}

#if defined(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    auto bytes = SkData::MakeWithoutCopy(data, size);
    FuzzRegionDeserialize(bytes);
    return 0;
}
#endif

Check for nullptrs when fuzzing region_deserialize

Bug: oss-fuzz:5629
Change-Id: I1129a6a9a68c69e07ab63e2e2be1c00cf0581962
Reviewed-on: https://skia-review.googlesource.com/102482
Reviewed-by: Mike Klein <14574f09dfa9b4e14759b88c3426a495a0e627b0@chromium.org>
Commit-Queue: Kevin Lubick <7cdab2cfab351f23814786ba39716e90eed69047@google.com>


#include <GL/glew.h>
#include <SDL2/SDL.h>

int main(void)
{
  int flags = SDL_WINDOW_OPENGL | SDL_RENDERER_PRESENTVSYNC;

  SDL_Init(SDL_INIT_EVERYTHING);
  auto window = SDL_CreateWindow("title", 0, 0, 320, 240, flags);
  auto context = SDL_GL_CreateContext(window);

  glewInit();
  glClearColor(0, 1, 0, 1);
  glClear(GL_COLOR_BUFFER_BIT);

  SDL_Event event;
  while (true)
  {
    while (SDL_PollEvent(&event))
      if (event.type == SDL_QUIT)
        goto quit;
      else if (event.type == SDL_KEYDOWN)
        switch (event.key.keysym.sym)
        {
          case SDLK_ESCAPE:
            goto quit;
            break;
        }
    SDL_Delay(10);
    SDL_GL_SwapWindow(window);
  }

quit:
  SDL_DestroyWindow(window);
  SDL_Quit();
  return 0;
}

#include <GL/glew.h>
#include <SDL2/SDL.h>

int main(void)
{
  int flags = SDL_WINDOW_OPENGL | SDL_RENDERER_PRESENTVSYNC;

  SDL_Init(SDL_INIT_EVERYTHING);
  auto window = SDL_CreateWindow("Warg", 0, 0, 320, 240, flags);
  auto context = SDL_GL_CreateContext(window);

  glewInit();
  glClearColor(0, 1, 0, 1);
  glClear(GL_COLOR_BUFFER_BIT);

  SDL_Event event;
  while (true)
  {
    while (SDL_PollEvent(&event))
      if (event.type == SDL_QUIT)
        goto quit;
      else if (event.type == SDL_KEYDOWN)
        switch (event.key.keysym.sym)
        {
          case SDLK_ESCAPE:
            goto quit;
            break;
        }
    SDL_Delay(10);
    SDL_GL_SwapWindow(window);
  }

quit:
  SDL_DestroyWindow(window);
  SDL_Quit();
  return 0;
}

Change window title to 'Warg'

Change window title to 'Warg'


/**
 * \file
 * \brief lowLevelInitialization() implementation for ARMv6-M and ARMv7-M
 *
 * \author Copyright (C) 2015 Kamil Szczygiel http://www.distortec.com http://www.freddiechopin.info
 *
 * \par License
 * 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 "distortos/architecture/lowLevelInitialization.hpp"

#include "distortos/chip/CMSIS-proxy.h"

namespace distortos
{

namespace architecture
{

/*---------------------------------------------------------------------------------------------------------------------+
| global functions
+---------------------------------------------------------------------------------------------------------------------*/

void lowLevelInitialization()
{
#if __FPU_PRESENT == 1 && __FPU_USED == 1
	SCB->CPACR |= (3 << 10 * 2) | (3 << 11 * 2);	// full access to CP10 and CP11
#endif	// __FPU_PRESENT == 1 && __FPU_USED == 1
}

}	// namespace architecture

}	// namespace distortos

/**
 * \file
 * \brief lowLevelInitialization() implementation for ARMv6-M and ARMv7-M
 *
 * \author Copyright (C) 2015 Kamil Szczygiel http://www.distortec.com http://www.freddiechopin.info
 *
 * \par License
 * 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 "distortos/architecture/lowLevelInitialization.hpp"

#include "distortos/chip/CMSIS-proxy.h"

namespace distortos
{

namespace architecture
{

/*---------------------------------------------------------------------------------------------------------------------+
| global functions
+---------------------------------------------------------------------------------------------------------------------*/

void lowLevelInitialization()
{
#ifdef CONFIG_ARCHITECTURE_ARM_CORTEX_M3_R1P1
	SCB->CCR |= SCB_CCR_STKALIGN_Msk;
#endif	// def CONFIG_ARCHITECTURE_ARM_CORTEX_M3_R1P1
#if __FPU_PRESENT == 1 && __FPU_USED == 1
	SCB->CPACR |= (3 << 10 * 2) | (3 << 11 * 2);	// full access to CP10 and CP11
#endif	// __FPU_PRESENT == 1 && __FPU_USED == 1
}

}	// namespace architecture

}	// namespace distortos

Set STKALIGN bit in SCB->CCR for ARM Cortex-M3 r1p1

This bit is set by default on all other ARM Cortex-M cores.


#include <iostream>
#include <string>
#include <utility>

#include "pool.h"

void Pool::add_machine(const Machine& new_machine)
{
    const std::string& machine_name = new_machine.get_name();

    std::cout << "Adding machine to pool: " << machine_name << std::endl;
    machines.insert(std::make_pair(machine_name, new_machine));
}

void Pool::add_job(const Job& new_job)
{
    const int job_id = new_job.get_id();
    const std::string& machine_name = new_job.get_machine();

    std::cout << "Adding job to pool: " << job_id << " (" << machine_name << ")" << std::endl;
    jobs.insert(std::make_pair(job_id, new_job));

    std::map<std::string, Machine>::iterator iter = machines.find(machine_name);
    if (iter != machines.end()) {
        std::cout << "Adding job to machine: " << machine_name << std::endl;
        iter->second.add_job(new_job);
    }
}

#include <iostream>
#include <string>
#include <utility>

#include "pool.h"

void Pool::add_machine(const Machine& new_machine)
{
    const std::string& machine_name = new_machine.get_name();

    std::cout << "Adding machine to pool: " << machine_name << std::endl;
    machines.insert(std::make_pair(machine_name, new_machine));
}

void Pool::add_job(const Job& new_job)
{
    const int job_id = new_job.get_id();
    const std::string& machine_name = new_job.get_machine();

    std::cout << "Adding job to pool: " << job_id << " (" << machine_name << ")" << std::endl;
    jobs.insert(std::make_pair(job_id, new_job));

    auto iter = machines.find(machine_name);
    if (iter != machines.end()) {
        std::cout << "Adding job to machine: " << machine_name << std::endl;
        iter->second.add_job(new_job);
    }
}

Use 'auto' for iterator type.

Use 'auto' for iterator type.

Avoid spelling out the type of the map iterator, which can be deduced by
the compiler. The const int job_id and const std::string& machine_name
are probably better off with their types explicitly given, though.


// 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 "views/controls/menu/menu_config.h"

#include "grit/app_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"

namespace views {

// static
MenuConfig* MenuConfig::Create() {
  MenuConfig* config = new MenuConfig();
  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
  config->font = rb.GetFont(ResourceBundle::BaseFont);
  config->arrow_width = rb.GetBitmapNamed(IDR_MENU_ARROW)->width();
  // Add 4 to force some padding between check and label.
  config->check_width = rb.GetBitmapNamed(IDR_MENU_CHECK)->width() + 4;
  config->check_height = rb.GetBitmapNamed(IDR_MENU_CHECK)->height();
  return config;
}

}  // namespace views

// 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 "views/controls/menu/menu_config.h"

#include "grit/app_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/resource/resource_bundle.h"

namespace views {

// static
MenuConfig* MenuConfig::Create() {
  MenuConfig* config = new MenuConfig();
  ResourceBundle& rb = ResourceBundle::GetSharedInstance();
#if defined(TOUCH_UI)
  config->font = rb.GetFont(ResourceBundle::LargeFont);
#else
  config->font = rb.GetFont(ResourceBundle::BaseFont);
#endif
  config->arrow_width = rb.GetBitmapNamed(IDR_MENU_ARROW)->width();
  // Add 4 to force some padding between check and label.
  config->check_width = rb.GetBitmapNamed(IDR_MENU_CHECK)->width() + 4;
  config->check_height = rb.GetBitmapNamed(IDR_MENU_CHECK)->height();
  return config;
}

}  // namespace views

Increase the base font size for touch ui

BUG=none
TEST=none

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

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@77349 4ff67af0-8c30-449e-8e8b-ad334ec8d88c


// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s
// expected-no-diagnostics

bool PR14634(int x) {
  double y = (double)x;
  return !y;
}

bool PR14634_implicit(int x) {
  double y = (double)x;
  return y;
}

void intAsBoolAsSwitchCondition(int c) {
  switch ((bool)c) {
  case 0:
    break;
  }
}

// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s

bool PR14634(int x) {
  double y = (double)x;
  return !y;
}

bool PR14634_implicit(int x) {
  double y = (double)x;
  return y;
}

void intAsBoolAsSwitchCondition(int c) {
  switch ((bool)c) { // expected-warning {{switch condition has boolean value}}
  case 0:
    break;
  }

  switch ((int)(bool)c) { // no-warning
    case 0:
      break;
  }
}

[analyzer] Fix test in previous commit to account for compiler warning.

--analyze passes -w, but -cc1 -analyze doesn't. Oops!

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


// RUN: %clang_cc1 -emit-llvm  -triple=armv7-apple-darwin -std=c++11 %s -o - -O1 \
// RUN:    | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -triple=armv7-apple-darwin -std=c++11 %s -o - -O1 \
// RUN:    -discard-value-names | FileCheck %s --check-prefix=DISCARDVALUE

extern "C" void branch();

bool test(bool pred) {
  // DISCARDVALUE: br i1 %0, label %2, label %3
  // CHECK: br i1 %pred, label %if.then, label %if.end

  if (pred) {
    // DISCARDVALUE: ; <label>:2:
    // DISCARDVALUE-NEXT: tail call void @branch()
    // DISCARDVALUE-NEXT: br label %3

    // CHECK: if.then:
    // CHECK-NEXT: tail call void @branch()
    // CHECK-NEXT: br label %if.end
    branch();
  }

  // DISCARDVALUE: ; <label>:3:
  // DISCARDVALUE-NEXT: ret i1 %0

  // CHECK: if.end:
  // CHECK-NEXT: ret i1 %pred
  return pred;
}

// RUN: %clang_cc1 -emit-llvm  -triple=armv7-apple-darwin -std=c++11 %s -o - -O1 \
// RUN:    | FileCheck %s
// RUN: %clang_cc1 -emit-llvm -triple=armv7-apple-darwin -std=c++11 %s -o - -O1 \
// RUN:    -discard-value-names | FileCheck %s --check-prefix=DISCARDVALUE

extern "C" void branch();

bool test(bool pred) {
  // DISCARDVALUE: br i1 %0, label %2, label %3
  // CHECK: br i1 %pred, label %if.then, label %if.end

  if (pred) {
    // DISCARDVALUE: 2:
    // DISCARDVALUE-NEXT: tail call void @branch()
    // DISCARDVALUE-NEXT: br label %3

    // CHECK: if.then:
    // CHECK-NEXT: tail call void @branch()
    // CHECK-NEXT: br label %if.end
    branch();
  }

  // DISCARDVALUE: 3:
  // DISCARDVALUE-NEXT: ret i1 %0

  // CHECK: if.end:
  // CHECK-NEXT: ret i1 %pred
  return pred;
}

IR: Support parsing numeric block ids, and emit them in textual output.

Just as as llvm IR supports explicitly specifying numeric value ids
for instructions, and emits them by default in textual output, now do
the same for blocks.

This is a slightly incompatible change in the textual IR format.

Previously, llvm would parse numeric labels as string names. E.g.
  define void @f() {
    br label %"55"
  55:
    ret void
  }
defined a label *named* "55", even without needing to be quoted, while
the reference required quoting. Now, if you intend a block label which
looks like a value number to be a name, you must quote it in the
definition too (e.g. `"55":`).

Previously, llvm would print nameless blocks only as a comment, and
would omit it if there was no predecessor. This could cause confusion
for readers of the IR, just as unnamed instructions did prior to the
addition of "%5 = " syntax, back in 2008 (PR2480).

Now, it will always print a label for an unnamed block, with the
exception of the entry block. (IMO it may be better to print it for
the entry-block as well. However, that requires updating many more
tests.)

Thus, the following is supported, and is the canonical printing:
  define i32 @f(i32, i32) {
    %3 = add i32 %0, %1
    br label %4

  4:
    ret i32 %3
  }

New test cases covering this behavior are added, and other tests
updated as required.

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

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


// RUN: %clang_cc1 -x c++-module-map %s -fmodule-name=a -verify
module a {
  module b {
    requires cplusplus11
  }
}
#pragma clang module contents
// expected-error@3 {{module 'a.b' requires feature 'cplusplus11'}}
#pragma clang module begin a.b // expected-note {{entering module 'a' due to this pragma}}
int f();
int g() { f(); }
#pragma clang module end // expected-error {{no matching '#pragma clang module begin'}}

// RUN: %clang_cc1 -x c++-module-map %s -fmodule-name=a -verify -std=c++98
module a {
  module b {
    requires cplusplus11
  }
}
#pragma clang module contents
// expected-error@3 {{module 'a.b' requires feature 'cplusplus11'}}
#pragma clang module begin a.b // expected-note {{entering module 'a' due to this pragma}}
int f();
int g() { f(); }
#pragma clang module end // expected-error {{no matching '#pragma clang module begin'}}

Add an explicit -std= to test to unbreak on PS4 targets.

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


// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "osfhandle.h"

#include <io.h>

#include "v8-profiler.h"
#include "v8-inspector.h"

namespace node {

int open_osfhandle(intptr_t osfhandle, int flags) {
  return _open_osfhandle(osfhandle, flags);
}

int close(int fd) {
  return _close(fd);
}

void ReferenceSymbols() {
  // Following symbols are used by electron.exe but got stripped by compiler,
  // for some reason, adding them to ForceSymbolReferences does not work,
  // probably because of VC++ bugs.
  v8::TracingCpuProfiler::Create(nullptr);
  reinterpret_cast<v8_inspector::V8InspectorClient*>(nullptr)->unmuteMetrics(0);
}

}  // namespace node

// Copyright (c) 2016 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.

#include "osfhandle.h"

#include <io.h>

#include "v8-profiler.h"
#include "v8-inspector.h"

namespace node {

int open_osfhandle(intptr_t osfhandle, int flags) {
  return _open_osfhandle(osfhandle, flags);
}

int close(int fd) {
  return _close(fd);
}

void ReferenceSymbols() {
  // Following symbols are used by electron.exe but got stripped by compiler,
  // for some reason, adding them to ForceSymbolReferences does not work,
  // probably because of VC++ bugs.
  v8::TracingCpuProfiler::Create(nullptr);
  reinterpret_cast<v8_inspector::V8InspectorSession*>(nullptr)->
      canDispatchMethod(v8_inspector::StringView());
  reinterpret_cast<v8_inspector::V8InspectorClient*>(nullptr)->unmuteMetrics(0);
}

}  // namespace node

Fix missing of symbols when linking win32 build


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

#include "chrome/browser/idle_query_linux.h"

#include <X11/Xlib.h>
#include <X11/extensions/scrnsaver.h>

namespace browser {

class IdleData {
 public:
  IdleData() {
    int event_base;
    int error_base;
    display = XOpenDisplay(NULL);
    if (XScreenSaverQueryExtension(display, &event_base, &error_base)) {
      mit_info = XScreenSaverAllocInfo();
    } else {
      mit_info = NULL;
    }
  }

  ~IdleData() {
    if (display) {
      XCloseDisplay(display);
      display = NULL;
    }
    if (mit_info)
      XFree(mit_info);
  }

  XScreenSaverInfo *mit_info;
  Display *display;
};

IdleQueryLinux::IdleQueryLinux() : idle_data_(new IdleData()) {}

IdleQueryLinux::~IdleQueryLinux() {}

int IdleQueryLinux::IdleTime() {
  if (!idle_data_->mit_info || !idle_data_->display)
    return 0;

  if (XScreenSaverQueryInfo(idle_data_->display,
                            RootWindow(idle_data_->display, 0),
                            idle_data_->mit_info)) {
    return (idle_data_->mit_info->idle) / 1000;
  } else {
    return 0;
  }
}

}  // namespace browser

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

#include "chrome/browser/idle_query_linux.h"

#include <X11/extensions/scrnsaver.h>
#include "ui/base/x/x11_util.h"

namespace browser {

class IdleData {
 public:
  IdleData() {
    int event_base;
    int error_base;
    if (XScreenSaverQueryExtension(ui::GetXDisplay(), &event_base,
                                   &error_base)) {
      mit_info = XScreenSaverAllocInfo();
    } else {
      mit_info = NULL;
    }
  }

  ~IdleData() {
    if (mit_info)
      XFree(mit_info);
  }

  XScreenSaverInfo *mit_info;
};

IdleQueryLinux::IdleQueryLinux() : idle_data_(new IdleData()) {}

IdleQueryLinux::~IdleQueryLinux() {}

int IdleQueryLinux::IdleTime() {
  if (!idle_data_->mit_info)
    return 0;

  if (XScreenSaverQueryInfo(ui::GetXDisplay(),
                            RootWindow(ui::GetXDisplay(), 0),
                            idle_data_->mit_info)) {
    return (idle_data_->mit_info->idle) / 1000;
  } else {
    return 0;
  }
}

}  // namespace browser

Use GetXDisplay() instead of XOpenDisplay() in IdleQueryLinux.

We weren't checking that XOpenDisplay was actually succeeding before
attempting to use the display.

BUG=82308
TEST=none

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

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


#include <QString>
#include <QtTest>
#include <execinfo.h>
#include <signal.h>
#include <unistd.h>
#include <TestRunner>
#include <QtQuickTest>
#include "example.h"
#include "asyncfuturetests.h"
#include "bugtests.h"

void handleBacktrace(int sig) {
    void *array[100];
    size_t size;

    // get void*'s for all entries on the stack
    size = backtrace(array, 100);

    // print out all the frames to stderr
    fprintf(stderr, "Error: signal %d:\n", sig);
    backtrace_symbols_fd(array, size, STDERR_FILENO);
    exit(1);
}

static void waitForFinished(QThreadPool *pool)
{
    QEventLoop loop;

    while (!pool->waitForDone(10)) {
        loop.processEvents();
    }
}

int main(int argc, char *argv[])
{
    signal(SIGSEGV, handleBacktrace);

    QCoreApplication app(argc, argv);

    TestRunner runner;
    runner.add<AsyncFutureTests>();
    runner.add<BugTests>();
    runner.add<Example>();

    bool error = runner.exec(app.arguments());

    if (!error) {
        qDebug() << "All test cases passed!";
    }

    waitForFinished(QThreadPool::globalInstance());

    return error;
}

#include <QString>
#include <QtTest>
#include <TestRunner>
#include <QtQuickTest>
#include "example.h"
#include "asyncfuturetests.h"
#include "bugtests.h"

#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
#include <execinfo.h>
#include <signal.h>
#include <unistd.h>
void handleBacktrace(int sig) {
  void *array[100];
  size_t size;

  // get void*'s for all entries on the stack
  size = backtrace(array, 100);

  // print out all the frames to stderr
  fprintf(stderr, "Error: signal %d:\n", sig);
  backtrace_symbols_fd(array, size, STDERR_FILENO);
  exit(1);
}
#endif

static void waitForFinished(QThreadPool *pool)
{
    QEventLoop loop;

    while (!pool->waitForDone(10)) {
        loop.processEvents();
    }
}

int main(int argc, char *argv[])
{
#if defined(Q_OS_MAC) || defined(Q_OS_LINUX)
    signal(SIGSEGV, handleBacktrace);
#endif

    QCoreApplication app(argc, argv);

    TestRunner runner;
    runner.add<AsyncFutureTests>();
    runner.add<BugTests>();
    runner.add<Example>();

    bool error = runner.exec(app.arguments());

    if (!error) {
        qDebug() << "All test cases passed!";
    }

    waitForFinished(QThreadPool::globalInstance());

    return error;
}

Fix a build problem in AppVeyor

Fix a build problem in AppVeyor


#include <cstdio>

int f() {
  int x, y[1024][1024];
  scanf("%d", &x);            // hidden store
  scanf("%d", &y[0][0]);      // hidden store
  x += y[0][0];               // store 0, load 0, load 1 (WAR load 1 - store 0)
  return x;                   // load 2                  (RAW: store 0)
}

int g() {
  int x, y[1024][1024];
  scanf("%d", &x);            // hidden store
  scanf("%d", &y[0][0]);      // hidden store
  x += y[0][0];               // store 1, load 3, load 4 (WAR load 4 - store 1)
                              //   *** interference: *** (RAW: store 0 - load 4)
                              //   *** interference: *** (WAW: store 0 - store 1)
                              //   *** interference: *** (WAR: load 2 - store 1)
  return x;                   // load 5                  (RAW: store 1)
}

int main() {
  printf("%d\n", f() + g());
  return 0;
}

Add alias and dependence tests

Add alias and dependence tests


#include <rmc++.h>

void mp_send(rmc<int> *flag, rmc<int> *data) {
    VEDGE(wdata, wflag);
    L(wdata, *data = 42);
    L(wflag, *flag = 1);
}

int mp_recv(rmc<int> *flag, int *data) {
    XEDGE(rflag, rdata);
    while (L(rflag, *flag) == 0)
        continue;
    return L(rdata, *data);
}

int cas(rmc<int> *p) {
    int i = 0;
    return p->compare_exchange_strong(i, 1);
}

int xadd_int(rmc<int> *p) {
    return p->fetch_add(10);
}

int *xadd_ptr(rmc<int *> *p) {
    return p->fetch_add(10);
}

// Make sure it works with longs also... (long overlaps with
// fetch_add on pointers so this depends on doing something to
// avoid the overlap)
long xadd_long(rmc<long> *p) {
    return p->fetch_add(10);
}

Add another simple test of C++ rmc

Add another simple test of C++ rmc


#include "AutonomousCommandGroup.h"
#include "MoveElevator.h"
#include "Move2Container.h"
#include "AdjustAngle.h"
#include "BringBurden.h"
#include "PivotCommand.h"

#include "../RobotMap.h"

AutonomousCommandGroup::AutonomousCommandGroup()
{
	//AddSequential(new PivotCommand(-90));

	AddSequential(new MoveElevator(3.0,true));
	AddSequential(new Move2Container());
	AddSequential(new AdjustAngle());
	AddSequential(new BringBurden());

}

#include "AutonomousCommandGroup.h"
#include "MoveElevator.h"
#include "Move2Container.h"
#include "AdjustAngle.h"
#include "BringBurden.h"
#include "PivotCommand.h"

#include "../RobotMap.h"

AutonomousCommandGroup::AutonomousCommandGroup()
{

	AddSequential(new MoveElevator(3.0,true));
	AddSequential(new Move2Container());
	AddSequential(new AdjustAngle());
	AddSequential(new BringBurden());
	AddSequential(new PivotCommand(-90));
	AddSequential(new MoveElevator(3.0,false));
}

Add Command 2 Commad Group

Add Command 2 Commad Group


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

#include "common/content_client.h"

#include "common/application_info.h"

#include "base/stringprintf.h"
#include "base/string_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/user_agent/user_agent_util.h"

namespace brightray {

ContentClient::ContentClient() {
}

ContentClient::~ContentClient() {
}

std::string ContentClient::GetProduct() const {
  auto name = GetApplicationName();
  RemoveChars(name, kWhitespaceASCII, &name);
  return base::StringPrintf("%s/%s", name.c_str(), GetApplicationVersion().c_str());
}

std::string ContentClient::GetUserAgent() const {
  return webkit_glue::BuildUserAgentFromProduct(GetProduct());
}

base::StringPiece ContentClient::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const {
  return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor);
}

gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const {
  return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
}

}

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

#include "common/content_client.h"

#include "common/application_info.h"

#include "base/stringprintf.h"
#include "base/string_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "webkit/common/user_agent/user_agent_util.h"

namespace brightray {

ContentClient::ContentClient() {
}

ContentClient::~ContentClient() {
}

std::string ContentClient::GetProduct() const {
  auto name = GetApplicationName();
  RemoveChars(name, kWhitespaceASCII, &name);
  return base::StringPrintf("%s/%s", name.c_str(), GetApplicationVersion().c_str());
}

std::string ContentClient::GetUserAgent() const {
  return webkit_glue::BuildUserAgentFromProduct(GetProduct());
}

base::StringPiece ContentClient::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const {
  return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(resource_id, scale_factor);
}

gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const {
  return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
}

}

Update for webkit header moves

Update for webkit header moves


#import <node.h>
#import "nan.h"
#import "scrollbar-style-observer.h"

using namespace v8;

void ScrollbarStyleObserver::Init(Handle<Object> target) {
  NanScope();
  Local<FunctionTemplate> newTemplate = FunctionTemplate::New(ScrollbarStyleObserver::New);
  newTemplate->SetClassName(NanSymbol("ScrollbarStyleObserver"));
  newTemplate->InstanceTemplate()->SetInternalFieldCount(1);
  Local<ObjectTemplate> proto = newTemplate->PrototypeTemplate();
  NODE_SET_METHOD(proto, "getPreferredScrollbarStyle", ScrollbarStyleObserver::GetPreferredScrollbarStyle);
  target->Set(NanSymbol("ScrollbarStyleObserver"), newTemplate->GetFunction());
}

NODE_MODULE(scrollbar_style_observer, ScrollbarStyleObserver::Init)

NAN_METHOD(ScrollbarStyleObserver::New) {
  NanScope();

  Local<Function> callbackHandle = args[0].As<Function>();
  NanCallback *callback = new NanCallback(callbackHandle);

  ScrollbarStyleObserver *observer = new ScrollbarStyleObserver(callback);
  observer->Wrap(args.This());
  NanReturnUndefined();
}

ScrollbarStyleObserver::ScrollbarStyleObserver(NanCallback *callback) : callback(callback) {
}

ScrollbarStyleObserver::~ScrollbarStyleObserver() {
  delete callback;
};

void ScrollbarStyleObserver::HandleScrollbarStyleChanged() {
}

NAN_METHOD(ScrollbarStyleObserver::GetPreferredScrollbarStyle) {
  NanScope();
  NanReturnValue(String::New("legacy"));
}

#include <node.h>
#include "nan.h"
#include "scrollbar-style-observer.h"

using namespace v8;

void ScrollbarStyleObserver::Init(Handle<Object> target) {
  NanScope();
  Local<FunctionTemplate> newTemplate = FunctionTemplate::New(ScrollbarStyleObserver::New);
  newTemplate->SetClassName(NanSymbol("ScrollbarStyleObserver"));
  newTemplate->InstanceTemplate()->SetInternalFieldCount(1);
  Local<ObjectTemplate> proto = newTemplate->PrototypeTemplate();
  NODE_SET_METHOD(proto, "getPreferredScrollbarStyle", ScrollbarStyleObserver::GetPreferredScrollbarStyle);
  target->Set(NanSymbol("ScrollbarStyleObserver"), newTemplate->GetFunction());
}

NODE_MODULE(scrollbar_style_observer, ScrollbarStyleObserver::Init)

NAN_METHOD(ScrollbarStyleObserver::New) {
  NanScope();

  Local<Function> callbackHandle = args[0].As<Function>();
  NanCallback *callback = new NanCallback(callbackHandle);

  ScrollbarStyleObserver *observer = new ScrollbarStyleObserver(callback);
  observer->Wrap(args.This());
  NanReturnUndefined();
}

ScrollbarStyleObserver::ScrollbarStyleObserver(NanCallback *callback) : callback(callback) {
}

ScrollbarStyleObserver::~ScrollbarStyleObserver() {
  delete callback;
};

void ScrollbarStyleObserver::HandleScrollbarStyleChanged() {
}

NAN_METHOD(ScrollbarStyleObserver::GetPreferredScrollbarStyle) {
  NanScope();
  NanReturnValue(String::New("legacy"));
}

Use include instead of import

Use include instead of import


Modify gpio example to run it on TI LM4F120XL board.


/**
 * Coverity Scan model
 *
 * Manage false positives by giving coverity some hints.
 *
 * Updates to this file must be manually submitted by an admin to:
 *
 *   https://scan.coverity.com/projects/1222
 *
 */

// When tag is 1 or 2, let coverity know that execution is halting. Those
// tags correspond to INT_FATAL and USR_FATAL respectively.
//
// INT_FATAL, et al, work by calling setupError and then
// handleError. setupError simply sets some static globals, then handleError
// looks at those to decide how to error. For example, when INT_FATAL calls
// handleError it will abort execution because exit_immediately is true.
//
// Here we're fibbing to coverity by telling it that setupError results in
// abort (as opposed to handleError), but the effect should be the same.
void setupError(const char *filename, int lineno, int tag) {
  if (tag == 1 || tag == 2) {
    __coverity_panic__();
  }
}

//==============================
// runtime
//

// chpl_error() ends execution
void chpl_error(const char* message, int32_t lineno, c_string filename) {
  __coverity_panic__();
}

// chpl_internal_error() ends execution
void chpl_internal_error(const char* message) {
  __coverity_panic__();
}

Add chpl_error() and chpl_internal_error(), indicating they halt execution.

These will help Coverity Scan's analysis of NULL pointer dereferences.
Currently it is saying that we might dereference a NULL pointer because
it doesn't realize that a NULL test that does chpl_error() if true will
result in a halt.  It thinks execution will proceed through that.


// Copyright 2014-present Bill Fisher. All rights reserved.

#include "ofp/yaml/yllvm.h"
#include "ofp/yaml/ycontrollermaxlen.h"

using namespace ofp;
using ofp::yaml::EnumConverterSparse;

#define OFP_NAME(s) \
  { OFPCML_##s, #s }

OFP_BEGIN_IGNORE_GLOBAL_CONSTRUCTOR

static std::pair<OFPControllerMaxLen, llvm::StringRef> sControllerMaxLen[] = {
    OFP_NAME(NO_BUFFER),
};

EnumConverterSparse<OFPControllerMaxLen>
    llvm::yaml::ScalarTraits<ofp::ControllerMaxLen>::converter{
        sControllerMaxLen};

OFP_END_IGNORE_GLOBAL_CONSTRUCTOR

// Copyright 2014-present Bill Fisher. All rights reserved.

#include "ofp/yaml/yllvm.h"
#include "ofp/yaml/ycontrollermaxlen.h"

using namespace ofp;
using ofp::yaml::EnumConverterSparse;

#define OFP_NAME(s) \
  { OFPCML_##s, #s }

OFP_BEGIN_IGNORE_GLOBAL_CONSTRUCTOR

static std::pair<OFPControllerMaxLen, llvm::StringRef> sControllerMaxLen[] = {
    OFP_NAME(MAX),
    OFP_NAME(NO_BUFFER),
};

EnumConverterSparse<OFPControllerMaxLen>
    llvm::yaml::ScalarTraits<ofp::ControllerMaxLen>::converter{
        sControllerMaxLen};

OFP_END_IGNORE_GLOBAL_CONSTRUCTOR

Add 'MAX' to ControllerMaxLen enum set.

Add 'MAX' to ControllerMaxLen enum set.


//=-- lsan_linux.cc -------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of LeakSanitizer. Linux-specific code.
//
//===----------------------------------------------------------------------===//

#if SANITIZER_LINUX

#include "lsan_allocator.h"

namespace __lsan {

static THREADLOCAL AllocatorCache allocator_cache;
AllocatorCache *GetAllocatorCache() { return &allocator_cache; }

} // namespace __lsan

#endif // SANITIZER_LINUX

//=-- lsan_linux.cc -------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file is a part of LeakSanitizer. Linux-specific code.
//
//===----------------------------------------------------------------------===//

#include "sanitizer_common/sanitizer_platform.h"

#if SANITIZER_LINUX

#include "lsan_allocator.h"

namespace __lsan {

static THREADLOCAL AllocatorCache allocator_cache;
AllocatorCache *GetAllocatorCache() { return &allocator_cache; }

} // namespace __lsan

#endif // SANITIZER_LINUX

Fix missing sanitizer platform include

Fix missing sanitizer platform include

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


#include <puppet/compiler/evaluation/functions/alert.hpp>
#include <puppet/compiler/evaluation/functions/call_context.hpp>
#include <puppet/compiler/evaluation/scope.hpp>
#include <puppet/logging/logger.hpp>

using namespace std;
using namespace puppet::runtime;

namespace puppet { namespace compiler { namespace evaluation { namespace functions {

    values::value log(logging::logger& logger, scope const& current, logging::level level, values::array const& arguments)
    {
        // Format the message based on the arguments
        ostringstream ss;
        arguments.join(ss, " ");
        auto message = ss.str();

        // Log the message
        if (logger.would_log(level)) {
            logger.log(level, (boost::format("%1%: %2%") % current % message).str());
        }
        return message;
    }

    descriptor alert::create_descriptor()
    {
        functions::descriptor descriptor{ "alert" };

        descriptor.add("Callable", [](call_context& context) {
            auto& evaluation_context = context.context();
            return log(evaluation_context.node().logger(), *evaluation_context.calling_scope(), logging::level::alert, context.arguments());
        });
        return descriptor;
    }

}}}}  // namespace puppet::compiler::evaluation::functions

#include <puppet/compiler/evaluation/functions/alert.hpp>
#include <puppet/compiler/evaluation/functions/call_context.hpp>
#include <puppet/compiler/evaluation/scope.hpp>
#include <puppet/logging/logger.hpp>

using namespace std;
using namespace puppet::runtime;

namespace puppet { namespace compiler { namespace evaluation { namespace functions {

    values::value log(logging::logger& logger, scope const& current, logging::level level, values::array const& arguments)
    {
        // Format the message based on the arguments
        ostringstream ss;
        arguments.join(ss, " ");
        auto message = ss.str();

        // Log the message
        if (logger.would_log(level)) {
            if (!current.resource()) {
                logger.log(level, message);
            } else {
                logger.log(level, (boost::format("%1%: %2%") % current % message).str());
            }
        }
        return message;
    }

    descriptor alert::create_descriptor()
    {
        functions::descriptor descriptor{ "alert" };

        descriptor.add("Callable", [](call_context& context) {
            auto& evaluation_context = context.context();
            return log(evaluation_context.node().logger(), *evaluation_context.calling_scope(), logging::level::alert, context.arguments());
        });
        return descriptor;
    }

}}}}  // namespace puppet::compiler::evaluation::functions

Remove output of scope without a resource from logging functions.

When the logging functions are used from a scope without a resource (i.e. not
compiling a catalog), then they print "Scope(main)" for the scope.

This commit removes that prefix so only the logged messages come through.


// Test header and library paths when Clang is used with Android standalone
// toolchain.
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN:     -target arm-linux-androideabi \
// RUN:     -B%S/Inputs/basic_android_tree \
// RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
// RUN:   | FileCheck  %s
// CHECK: clang" "-cc1"
// CHECK: "-internal-isystem" "{{.*}}/arm-linux-androideabi/include/c++/4.4.3"
// CHECK: "-internal-isystem" "{{.*}}/arm-linux-androideabi/include/c++/4.4.3/arm-linux-androideabi"
// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
// CHECK: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.4.3"
// CHECK: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib"
// CHECK: "-L{{.*}}/sysroot/usr/lib"

// Test header and library paths when Clang is used with Android standalone
// toolchain.
//
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN:     -target arm-linux-androideabi \
// RUN:     -B%S/Inputs/basic_android_tree \
// RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
// RUN:   | FileCheck  %s
// CHECK: {{.*}}clang{{(.exe)?}}" "-cc1"
// CHECK: "-internal-isystem" "{{.*}}/arm-linux-androideabi/include/c++/4.4.3"
// CHECK: "-internal-isystem" "{{.*}}/arm-linux-androideabi/include/c++/4.4.3/arm-linux-androideabi"
// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/include"
// CHECK: "-internal-externc-isystem" "{{.*}}/sysroot/usr/include"
// CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
// CHECK: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.4.3"
// CHECK: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/lib"
// CHECK: "-L{{.*}}/sysroot/usr/lib"

Fix test failure on Windowns.

Fix test failure on Windowns.

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


// 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/basictypes.h"
#include "base/file_path.h"
#include "build/build_config.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/ui/ui_test.h"
#include "net/base/net_util.h"

class DefaultPluginUITest : public UITest {
 public:
  DefaultPluginUITest() {
    dom_automation_enabled_ = true;
  }
};

TEST_F(DefaultPluginUITest, DefaultPluginLoadTest) {
  // Open page with default plugin.
  FilePath test_file(test_data_directory_);
  test_file = test_file.AppendASCII("default_plugin.html");
  NavigateToURL(net::FilePathToFileURL(test_file));

  // Check that the default plugin was loaded. It executes a bit of javascript
  // in the HTML file which replaces the innerHTML of div |result| with "DONE".
  scoped_refptr<TabProxy> tab(GetActiveTab());
  std::wstring out;
  ASSERT_TRUE(tab->ExecuteAndExtractString(L"",
      L"domAutomationController.send("
      L"document.getElementById('result').innerHTML)", &out));
  ASSERT_EQ(L"DONE", out);
}

// 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/basictypes.h"
#include "base/file_path.h"
#include "build/build_config.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/ui/ui_test.h"
#include "net/base/net_util.h"

class DefaultPluginUITest : public UITest {
 public:
  DefaultPluginUITest() {
    dom_automation_enabled_ = true;
  }
};

#if defined(OS_WIN)
#define MAYBE_DefaultPluginLoadTest DISABLED_DefaultPluginLoadTest
#else
#define MAYBE_DefaultPluginLoadTest DefaultPluginLoadTest
#endif
TEST_F(DefaultPluginUITest, MAYBE_DefaultPluginLoadTest) {
  // Open page with default plugin.
  FilePath test_file(test_data_directory_);
  test_file = test_file.AppendASCII("default_plugin.html");
  NavigateToURL(net::FilePathToFileURL(test_file));

  // Check that the default plugin was loaded. It executes a bit of javascript
  // in the HTML file which replaces the innerHTML of div |result| with "DONE".
  scoped_refptr<TabProxy> tab(GetActiveTab());
  std::wstring out;
  ASSERT_TRUE(tab->ExecuteAndExtractString(L"",
      L"domAutomationController.send("
      L"document.getElementById('result').innerHTML)", &out));
  ASSERT_EQ(L"DONE", out);
}

Disable DefaultPluginUITest::DefaultPluginLoadTest on windows as it crashes.

BUG=57952
TEST=none
TBR=thakis@chromium.org

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


// RUN: %clang  -g -S -fverbose-asm %s -o - | FileCheck %s

// CHECK: TAG_namespace
namespace A {
  enum numbers {
    ZERO,
    ONE
  };
}

using namespace A;
numbers n;

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

namespace A {
int i;
}

// CHECK: [[FILE:![0-9]*]] = {{.*}} ; [ DW_TAG_file_type ] [{{.*}}/test/CodeGenCXX/debug-info-namespace.cpp]
// CHECK: [[VAR:![0-9]*]] = {{.*}}, metadata [[NS:![0-9]*]], metadata !"i", {{.*}} ; [ DW_TAG_variable ] [i]
// CHECK: [[NS]] = {{.*}}, metadata [[FILE]], {{.*}} ; [ DW_TAG_namespace ] [A] [line 3]

Make front-end debug info namespace test frontend-only & more specific without overconstraining it

The backend portion of this test will be committed to LLVM's test suite.

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


//===-- PluginLoader.cpp - Implement -load command line option ------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the -load <plugin> command line option handler.
//
//===----------------------------------------------------------------------===//

#define DONT_GET_PLUGIN_LOADER_OPTION
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/DynamicLibrary.h"
#include <ostream>
#include <vector>
using namespace llvm;

static std::vector<std::string> *Plugins;

void PluginLoader::operator=(const std::string &Filename) {
  if (!Plugins)
    Plugins = new std::vector<std::string>();

  std::string Error;
  if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
    cerr << "Error opening '" << Filename << "': " << Error
         << "\n  -load request ignored.\n";
  } else {
    Plugins->push_back(Filename);
  }
}

unsigned PluginLoader::getNumPlugins() {
  return Plugins ? Plugins->size() : 0;
}

std::string &PluginLoader::getPlugin(unsigned num) {
  assert(Plugins && num < Plugins->size() && "Asking for an out of bounds plugin");
  return (*Plugins)[num];
}

//===-- PluginLoader.cpp - Implement -load command line option ------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the -load <plugin> command line option handler.
//
//===----------------------------------------------------------------------===//

#define DONT_GET_PLUGIN_LOADER_OPTION
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/DynamicLibrary.h"
#include <ostream>
#include <vector>
using namespace llvm;

static ManagedStatic<std::vector<std::string> > Plugins;

void PluginLoader::operator=(const std::string &Filename) {
  std::string Error;
  if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
    cerr << "Error opening '" << Filename << "': " << Error
         << "\n  -load request ignored.\n";
  } else {
    Plugins->push_back(Filename);
  }
}

unsigned PluginLoader::getNumPlugins() {
  return Plugins.isConstructed() ? Plugins->size() : 0;
}

std::string &PluginLoader::getPlugin(unsigned num) {
  assert(Plugins.isConstructed() && num < Plugins->size() &&
         "Asking for an out of bounds plugin");
  return (*Plugins)[num];
}

Fix for PR2881: fix a small leak exposed by valgrind, using a ManagedStatic.

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


#include "BracketedSentenceWidget.hh"

#include <QDebug>
#include <QPainter>
#include <QTextEdit>
#include <QSettings>

BracketedSentenceWidget::BracketedSentenceWidget(QWidget *parent)
:
    QTextEdit(parent),
    d_stylesheet(":/stylesheets/bracketed-sentence.xsl"),
    d_transformer(d_stylesheet)
{
    QFontMetrics m(font());
    int ruleHeight = m.lineSpacing();
    setFixedHeight(2 * ruleHeight + (2 * document()->documentMargin()));
    setReadOnly(true);
}

void BracketedSentenceWidget::setParse(QString const &parse)
{
    d_parse = parse;
    updateText();
}

void BracketedSentenceWidget::updateText()
{
    if (!d_parse.isEmpty())
    {
        QString sentence = transformXML(d_parse);
        setText(sentence.trimmed());
    }
}

QString BracketedSentenceWidget::transformXML(QString const &xml) const
{
    QHash<QString, QString> params;
    return d_transformer.transform(xml, params);
}

#include "BracketedSentenceWidget.hh"

#include <QDebug>
#include <QPainter>
#include <QTextEdit>
#include <QSettings>

BracketedSentenceWidget::BracketedSentenceWidget(QWidget *parent)
:
    QTextEdit(parent),
    d_stylesheet(":/stylesheets/bracketed-sentence.xsl"),
    d_transformer(d_stylesheet)
{
    QFontMetrics m(document()->defaultFont());
    int ruleHeight = m.lineSpacing();
    setFixedHeight(2 * ruleHeight + (2 * document()->documentMargin()));
    setReadOnly(true);
}

void BracketedSentenceWidget::setParse(QString const &parse)
{
    d_parse = parse;
    updateText();
}

void BracketedSentenceWidget::updateText()
{
    if (!d_parse.isEmpty())
    {
        QString sentence = transformXML(d_parse);
        setText(sentence.trimmed());
    }
}

QString BracketedSentenceWidget::transformXML(QString const &xml) const
{
    QHash<QString, QString> params;
    return d_transformer.transform(xml, params);
}

Use document font in BracketedWindow.

Use document font in BracketedWindow.


#include <boost/mpi.hpp>
#include <iostream>
#include <string>
#include <set>
#include <boost/serialization/string.hpp>
#include "InstrumentFactories.h"
#include "Stochastic.h"
#include "Ising.h"
#include "Measurement.h"

namespace mpi = boost::mpi;

int main(int argc, char* argv[])
{
    mpi::environment env(argc, argv);
    mpi::communicator world;
    char hostname[256];
    int requester;
    const int dimension = 50;
    const int iterations = 1000;

    gethostname(hostname,255);
    std::clog << "Hello world from host " << hostname << std::endl;

    ReservoirFactory *rFactory = new DefaultArgsReservoirFactory<StochasticReservoir>;
    SystemFactory *sFactory = new BinomialSystemFactory;
    Experiment::range work;
    Experiment experiment;
    experiment.iterations = iterations;
    experiment.dimension = dimension;
    experiment.sfactory=sFactory;
    experiment.rfactory=rFactory;

    for (int k=world.rank(); k<iterations; k+=world.size()) {
        MeasurementResult result = experiment.performIteration(k);
        printf("%s\n",outputString(result).c_str());
    }

    std::clog<<"Node "<<world.rank()<<" finished.\n";
    return 0;
}

#include <boost/mpi.hpp>
#include <iostream>
#include <string>
#include <set>
#include <boost/serialization/string.hpp>
#include "InstrumentFactories.h"
#include "Stochastic.h"
#include "Ising.h"
#include "Measurement.h"

namespace mpi = boost::mpi;

int main(int argc, char* argv[])
{
    mpi::environment env(argc, argv);
    mpi::communicator world;
    char hostname[256];
    int requester;
    const int dimension = 50;
    const int iterations = 1000;

    gethostname(hostname,255);
    std::clog << "Hello world from host " << hostname << std::endl;

    ReservoirFactory *rFactory = new DefaultArgsReservoirFactory<StochasticReservoir>;
    SystemFactory *sFactory = new BinomialSystemFactory;
    Experiment::range work;
    Experiment experiment;
    experiment.iterations = iterations;
    experiment.dimension = dimension;
    experiment.sfactory=sFactory;
    experiment.rfactory=rFactory;

    for (int k=world.rank(); k<dimension*dimension; k+=world.size()) {
        MeasurementResult result = experiment.performIteration(k);
        printf("%s\n",outputString(result).c_str());
    }

    std::clog<<"Node "<<world.rank()<<" finished.\n";
    return 0;
}

Use correct bound for static work allocation.


#include "tree.hh"
#include "tree-entry.hh"

namespace mimosa
{
  namespace git
  {
    Tree::Tree(git_repository * repo,
               const git_oid *  id)
      : tree_(nullptr)
    {
      if (id)
        git_tree_lookup(&tree_, repo, id);
    }

    Tree::Tree(git_repository *    repo,
               const git_oid *     id,
               const std::string & directory)
      : tree_(nullptr)
    {
      if (directory.empty()) {
        git_tree_lookup(&tree_, repo, id);
        return;
      }

      Tree      root(repo, id);
      TreeEntry entry;
      if (git_tree_entry_bypath(entry.ref(), root, directory.c_str()))
        return;

      if (git_tree_entry_type(entry) != GIT_OBJ_TREE)
        return;

      git_tree_lookup(&tree_, repo, git_tree_entry_id(entry));
    }

    Tree::~Tree()
    {
      git_tree_free(tree_);
    }
  }
}

#include "tree.hh"
#include "tree-entry.hh"

namespace mimosa
{
  namespace git
  {
    Tree::Tree(git_repository * repo,
               const git_oid *  id)
      : tree_(nullptr)
    {
      if (id)
        git_tree_lookup(&tree_, repo, id);
    }

    Tree::Tree(git_repository *    repo,
               const git_oid *     id,
               const std::string & directory)
      : tree_(nullptr)
    {
      if (directory.empty()) {
        git_tree_lookup(&tree_, repo, id);
        return;
      }

      Tree      root(repo, id);
      TreeEntry entry;
      if (git_tree_entry_bypath(entry.ref(), root, directory.c_str()))
        return;

      if (git_tree_entry_type(entry) != GIT_OBJECT_TREE)
        return;

      git_tree_lookup(&tree_, repo, git_tree_entry_id(entry));
    }

    Tree::~Tree()
    {
      git_tree_free(tree_);
    }
  }
}

Fix compilation against recent libigt2

Fix compilation against recent libigt2


#include "stdafx.h"
#include <dukat/timermanager.h>

namespace dukat
{
    Timer* TimerManager::create_timer(float interval, std::function<void(void)> callback, bool recurring)
    {
        auto timer = std::make_unique<Timer>(++last_id, interval, callback, recurring);
        auto res = timer.get();
        timers.push_back(std::move(timer));
		return res;
    }

    void TimerManager::cancel_timer(Timer* timer)
    {
        auto it = std::find_if(timers.begin(), timers.end(), [timer](const std::unique_ptr<Timer>& ptr) {
            return ptr.get() == timer;
        });
        if (it != timers.end())
        {
            timers.erase(it);
        }
    }

    void TimerManager::update(float delta)
    {
        for (auto it = timers.begin(); it != timers.end(); )
        {
            (*it)->remaining -= delta;
            // check if timer has expired
            if ((*it)->remaining <= 0.0f)
            {
                if ((*it)->callback)
                {
                    (*it)->callback();
                }

                if ((*it)->recurring)
                {
                    (*it)->remaining = (*it)->interval;
                }
                else
                {
                    it = timers.erase(it);
                    continue;
                }
            }

            ++it;
        }
    }
}

#include "stdafx.h"
#include <dukat/timermanager.h>

namespace dukat
{
    Timer* TimerManager::create_timer(float interval, std::function<void(void)> callback, bool recurring)
    {
        auto timer = std::make_unique<Timer>(++last_id, interval, callback, recurring);
        auto res = timer.get();
        timers.push_back(std::move(timer));
		return res;
    }

    void TimerManager::cancel_timer(Timer* timer)
    {
        auto it = std::find_if(timers.begin(), timers.end(), [timer](const std::unique_ptr<Timer>& ptr) {
            return ptr.get() == timer;
        });
        if (it != timers.end())
        {
            timers.erase(it);
        }
    }

    void TimerManager::update(float delta)
    {
		const auto max_id = last_id;
        for (auto it = timers.begin(); it != timers.end(); )
        {
			// only process timers up to current max during this frame
			if ((*it)->id > max_id)
				break;

            (*it)->remaining -= delta;
            // check if timer has expired
            if ((*it)->remaining <= 0.0f)
            {
                if ((*it)->callback)
                {
                    (*it)->callback();
                }

                if ((*it)->recurring)
                {
                    (*it)->remaining = (*it)->interval;
                }
                else
                {
                    it = timers.erase(it);
                    continue;
                }
            }

            ++it;
        }
    }
}

Fix timer manager update loop

Fix timer manager update loop


/*
 * Chemharp, an efficient IO library for chemistry file formats
 * Copyright (C) 2015 Guillaume Fraux
 *
 * 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 "chemharp-python.hpp"

void register_trajectory() {
    /* Trajectory class *******************************************************/
    py::class_<Trajectory, boost::noncopyable>("Trajectory",
            py::init<string, py::optional<string, string>>())
        .def("read_next_step", &Trajectory::read_next_step)
        .def("read_at_step", &Trajectory::read_at_step)
        .def("write_step", &Trajectory::write_step)
        .def("done", &Trajectory::done)
        .def("close", &Trajectory::close)
        .def("nsteps", &Trajectory::nsteps)
        .def("topology",
            static_cast<void (Trajectory::*)(const Topology&)>(&Trajectory::topology))
        .def("topology",
            static_cast<void (Trajectory::*)(const string&)>(&Trajectory::topology))
    ;
}

/*
 * Chemharp, an efficient IO library for chemistry file formats
 * Copyright (C) 2015 Guillaume Fraux
 *
 * 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 "chemharp-python.hpp"

void register_trajectory() {
    /* Trajectory class *******************************************************/
    py::class_<Trajectory, boost::noncopyable>("Trajectory",
            py::init<string, py::optional<string, string>>())
        .def("read", &Trajectory::read)
        .def("read_at", &Trajectory::read_at)
        .def("write", &Trajectory::write)
        .def("done", &Trajectory::done)
        .def("close", &Trajectory::close)
        .def("nsteps", &Trajectory::nsteps)
        .def("topology",
            static_cast<void (Trajectory::*)(const Topology&)>(&Trajectory::topology))
        .def("topology",
            static_cast<void (Trajectory::*)(const string&)>(&Trajectory::topology))
    ;
}

Update the Python interface with the new names


/*****************************************************************************
 *
 * X testing environment - Google Test environment feat. dummy x server
 *
 * Copyright (C) 2011 Canonical Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 ****************************************************************************/

#include <xorg/gtest/test.h>

using namespace xorg::testing;

/**
 * @example xorg-gtest.cpp
 *
 * This is an example for using the fixture
 * xorg::testing::Test for your own tests. Please
 * make sure that you have the X.org dummy display
 * driver installed on your system and that you execute
 * the test with root privileges.
 */
TEST_F(Test, DummyXorgServerTest) {

  EXPECT_NE(0, DefaultRootWindow(Display()));

}

Remove license header from example

Remove license header from example

It clutters up the example and is unnecessary for such a small file.


// Copyright 2015 Matt Heard
// http://mattheard.net
// matt@mattheard.net
// @mattheard

#include <opencv2/opencv.hpp>
#include <iostream>
#include <string>

int main(int argc, char **argv) {
    using std::string;
    const int expectedNumArgs = 3;
    if (argc != expectedNumArgs) {
        const string cmdName = "ConvertToGrey";
        const string argsDesc = " <Image_Path> <Reduce_By>";
        std::cout << "Usage: " << cmdName << argsDesc << std::endl;
        return -1;
    }
    const string inputFilename = argv[1];
    const cv::Mat srcImg = cv::imread(inputFilename);
    if (!srcImg.data) {
        const string err = "No image data";
        std::cerr << err << std::cout;
        return -1;
    }
    const int divideWith = atoi(argv[2]);
    if (divideWith < 1) {
        std::cout << "Invalid number entered for dividing." << std::endl;
        return -1;
    }
    return 0;
}

// Copyright 2015 Matt Heard
// http://mattheard.net
// matt@mattheard.net
// @mattheard

#include <opencv2/opencv.hpp>
#include <iostream>
#include <string>

using cv::Mat;

Mat buildLookUpTable(const int divideWith) {
    return Mat();
}

int main(int argc, char **argv) {
    using std::string;
    const int expectedNumArgs = 3;
    if (argc != expectedNumArgs) {
        const string cmdName = "ConvertToGrey";
        const string argsDesc = " <Image_Path> <Reduce_By>";
        std::cout << "Usage: " << cmdName << argsDesc << std::endl;
        return -1;
    }
    const string inputFilename = argv[1];
    const Mat srcImg = cv::imread(inputFilename);
    if (!srcImg.data) {
        const string err = "No image data";
        std::cerr << err << std::cout;
        return -1;
    }
    const int divideWith = atoi(argv[2]);
    if (divideWith < 1) {
        std::cout << "Invalid number entered for dividing." << std::endl;
        return -1;
    }
    const Mat lookUpTable = buildLookUpTable(divideWith);
    return 0;
}

Add call to build lookup table

Add call to build lookup table


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

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/compiler/tf2xla/tf2xla_util.h"
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/core/framework/kernel_def.pb.h"

namespace tensorflow {

bool GpuOpFilter(KernelDef* kdef) {
  // TODO(b/26783907): The GPU backend currently does not implement sort.
  if (kdef->op() == "XlaSort" || kdef->op() == "TopKV2") {
    return false;
  }
  if (kdef->op() == "Const") {
    AddDtypeToKernalDefConstraint("dtype", DT_STRING, kdef);
  }
  if (kdef->op() == "Assert") {
    AddDtypeToKernalDefConstraint("T", DT_STRING, kdef);
  }
  return true;
}

REGISTER_XLA_BACKEND(DEVICE_GPU_XLA_JIT, kGpuAllTypes, GpuOpFilter);

}  // namespace tensorflow

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

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/compiler/tf2xla/tf2xla_util.h"
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/core/framework/kernel_def.pb.h"

namespace tensorflow {

bool GpuOpFilter(KernelDef* kdef) {
  if (kdef->op() == "Const") {
    AddDtypeToKernalDefConstraint("dtype", DT_STRING, kdef);
  }
  if (kdef->op() == "Assert") {
    AddDtypeToKernalDefConstraint("T", DT_STRING, kdef);
  }
  return true;
}

REGISTER_XLA_BACKEND(DEVICE_GPU_XLA_JIT, kGpuAllTypes, GpuOpFilter);

}  // namespace tensorflow

Enable Sort for the XLA GPU backend.

Enable Sort for the XLA GPU backend.

We now have an implementation of sort for the XLA GPU backend.

PiperOrigin-RevId: 206537201


#include <bits/stdc++.h>

using namespace std;

struct Fenwick {
	vector<int> data;
	int len;

	Fenwick(int l) {
		len = l;
		data.assign(l + 1, 0);
	}

	void update(int at, int by) {
		while (at < len) {
			data[at] += by;
			at |= (at + 1);
		}
	}

	int query(int at) {
		int res = 0;
		while (at >= 0) {
			res += data[at];
			at = (at & (at + 1)) - 1;
		}
		return res;
	}

	int queryRange(int l, int r) {
		return data[r] - data[l-1];
	}
};

int main() {

}

#include <bits/stdc++.h>

using namespace std;

class Fenwick {

private:
	vector<int> data;
	vector<int> dataMul;
	int len;
	bool range;

	void internalUpdate(int at, int mul, int add) {
		while (at < len) {
			dataMul[at] += mul;
			data[at] += add;
			at |= (at + 1);
		}
	}

	int queryStd(int at) {
		int res = 0;
		while (at >= 0) {
			res += data[at];
			at = (at & (at + 1)) - 1;
		}
		return res;
	}

	int queryIfRange(int at) {
		int mul = 0;
		int add = 0;
		int start = at;

		while (at >= 0) {
			mul += dataMul[at];
			add += data[at];
			at = (at & (at + 1)) - 1;
		}
		return mul * start + add;
	}

public:
	Fenwick(int len, bool range = false) {
		this->len = len;
		this->range = range;
		data.assign(len + 1, 0);
		if (range) dataMul.assign(len + 1, 0);
	}

	void update(int at, int by) {
		if (range) throw;
		while (at < len) {
			data[at] += by;
			at |= (at + 1);
		}
	}

	void updateRange(int left, int right, int by) {
		if (!range) throw;
		internalUpdate(left, by, -by * (left -1));
		internalUpdate(right, -by, by * right);
	}

	int query(int at) {
		return range ? queryIfRange(at) : queryStd(at);
	}

	int queryRange(int l, int r) {
		return query(r) - query(l-1);
	}
};

int main() {

}

Add range update to Fenwick

Add range update to Fenwick


/* Main Process for CLI tlisp */
/* Compile using g++ -std=c++11 -Wall main.cpp -o tlisp */

#include <iostream>
#include <string>
#include <iomanip>

/* OSX / Linux Libraries */
// #include <readline.h>
// #include <editline/history.h>

using std::cin;
using std::cout;
using std::endl;
using std::setw;
using std::string;

/* Globals... for now */
string input;

int main(int argc, char** argv) {
  /* Very basic REPL */
  cout << "tlisp Version 0.0.0.1" << endl;
  cout << "Press 'CTRL-c' to exit." << endl;

  while (true) {
    /* Prompt line */
    cout << "tlisp >> ";
    getline(cin,input);

    if (input == "exit") {
      cout << "Have a nice day!";
      break;
    }

    cout << "You entered: " << input << endl;
  }
  return 0;
}

/* Main Process for CLI tlisp */
/* Compile using g++ -std=c++11 -Wall main.cpp -o tlisp */

#include <iostream>
#include <iomanip>
#include <string.h>

/* OSX / Linux Libraries */
// #include <readline.h>
// #include <editline/history.h>

using std::cin;
using std::cout;
using std::endl;
using std::setw;

void remove_whitespace(char* str) {
  /* A small function to remove spaces and tabs from a C-string */
  size_t idx = 0;  // 'Copy to' string index
  size_t jdx = 0;  // 'Copy from' string index

  while((*(str + idx) = *(str + jdx++)) != '\0')
    if (*(str + idx) != ' ' && *(str + idx) != '\t')  // Remove spaces and tabs
      idx++;
  return;
}

int main(int argc, char** argv) {
  /* Very basic REPL */
  const size_t MAX = 2048;
  char input_buffer[MAX];

  cout << "tlisp Version 0.0.0.1" << endl;
  cout << "Press 'CTRL-c' to exit." << endl;

  while (true) {
    /* Prompt line */
    cout << "tlisp >> ";
    cin.get(input_buffer, MAX).get();

    /* REPL Exit check */
    /* TODO: Currently if exit is anywhere in the buffer, the REPL will
             exit. It should only exit if the user enters 'exit' only.
             Need to fix this */
    if (sizeof(strstr(input_buffer, "exit"))) {
      cout << endl << "Have a nice day!" << endl;
      break;
    }

    cout << "You entered: " << input_buffer << endl;
    cout << "Remove the whitespace!" << endl;
    remove_whitespace(input_buffer);
    cout << "This is better: " << input_buffer << endl;
  }
  return 0;
}

Add function to remove whitespace from input buffer.


//
// Copyright (c) 2018 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation.  All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include <ssl.h>
#include "mbedtls.h"

int  ssl_write_internal( int sd, const char* data, size_t req_len)
{
    mbedTLS_NFContext* context= (mbedTLS_NFContext*)SOCKET_DRIVER.GetSocketSslData(sd);
    mbedtls_ssl_context *ssl = context->ssl;

    int ret;

    // Loop until all data has been sent or error
    size_t req_offset = 0;
    do {
        ret = mbedtls_ssl_write( ssl, (const unsigned char *)(data + req_offset), req_len - req_offset);
        if (ret > 0)
            req_offset += static_cast<size_t>(ret);
    }
    while( req_offset < req_len &&
           (ret > 0 ||
           ret == MBEDTLS_ERR_SSL_WANT_WRITE ||
           ret == MBEDTLS_ERR_SSL_WANT_READ) );

    if (ret < 0) {
        //mbedtls_printf("mbedtls_ssl_write() returned -0x%04X\n", -ret);
        return 0;
    }

    return req_len;
}

//
// Copyright (c) 2018 The nanoFramework project contributors
// Portions Copyright (c) Microsoft Corporation.  All rights reserved.
// See LICENSE file in the project root for full license information.
//

#include <ssl.h>
#include "mbedtls.h"

int  ssl_write_internal( int sd, const char* data, size_t req_len)
{
    mbedTLS_NFContext* context= (mbedTLS_NFContext*)SOCKET_DRIVER.GetSocketSslData(sd);
    mbedtls_ssl_context *ssl = context->ssl;

    int ret;

    // Loop until all data has been sent or error
    size_t req_offset = 0;
    do
    {
        ret = mbedtls_ssl_write( ssl, (const unsigned char *)(data + req_offset), req_len - req_offset);
        if (ret > 0)
        {
            req_offset += static_cast<size_t>(ret);
        }
    }
    while( req_offset < req_len &&
           (ret > 0 ||
           ret == MBEDTLS_ERR_SSL_WANT_WRITE ||
           ret == MBEDTLS_ERR_SSL_WANT_READ) );

    if (ret < 0)
    {
        //mbedtls_printf("mbedtls_ssl_write() returned -0x%04X\n", -ret);
        return 0;
    }

    return req_len;
}

Tidy code to follow guidelines

Tidy code to follow guidelines

Signed-off-by: José Simões <1616ff7a83d123f98f8f38fa2524eab406644781@eclo.solutions>


#include "ofMain.h"
#include "ofApp.h"
#include <stdlib.h>

int main(int argc, char* argv[]){
    if (argc < 2) {
        exit(1);
        return 0;
    } else {
        ofSetupOpenGL(1024,768,OF_FULLSCREEN);
        ofRunApp(new ofApp(argv[1]));
    }
}

#include "ofMain.h"
#include "ofApp.h"
#include <iostream>
#include <stdlib.h>

int main(int argc, char* argv[]){
    if (argc < 2) {
        cerr << "Usage: interface <socket path>";
        exit(1);
        return 0;
    } else {
        ofSetupOpenGL(1024,768,OF_FULLSCREEN);
        ofRunApp(new ofApp(argv[1]));
    }
}

Add error message for missing socket.

Add error message for missing socket.


//
//  StaticAnalyser.cpp
//  Clock Signal
//
//  Created by Thomas Harte on 14/04/2018.
//  Copyright 2018 Thomas Harte. All rights reserved.
//

#include "StaticAnalyser.hpp"
#include "Target.hpp"

Analyser::Static::TargetList Analyser::Static::AppleII::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) {
	auto target = std::make_unique<Target>();
	target->media = media;

	if(!target->media.disks.empty())
		target->disk_controller = Target::DiskController::SixteenSector;

	TargetList targets;
	targets.push_back(std::move(target));
	return targets;
}

//
//  StaticAnalyser.cpp
//  Clock Signal
//
//  Created by Thomas Harte on 14/04/2018.
//  Copyright 2018 Thomas Harte. All rights reserved.
//

#include "StaticAnalyser.hpp"
#include "Target.hpp"

Analyser::Static::TargetList Analyser::Static::AppleII::GetTargets(const Media &media, const std::string &, TargetPlatform::IntType) {
	auto target = std::make_unique<Target>();
	target->media = media;

	// If any disks are present, attach a Disk II.
	if(!target->media.disks.empty()) {
		target->disk_controller = Target::DiskController::SixteenSector;
	}

	// The emulated SCSI card requires a IIe, so upgrade to that if
	// any mass storage is present.
	if(!target->media.mass_storage_devices.empty()) {
		target->model = Target::Model::EnhancedIIe;
	}

	TargetList targets;
	targets.push_back(std::move(target));
	return targets;
}

Upgrade to an Enhanced IIe if hard drives are present.


#include "precompiled.hpp"
#include "ui/docks/OpenGLStateWidget.hpp"

#include "gl/OpenGLPointers.hpp"

namespace balls {

OpenGLStateWidget::OpenGLStateWidget(OpenGLPointers& gl, QWidget* parent)
  : QWidget(parent),
    m_blendState(gl),
    m_clipOptions(gl),
    m_colorOptions(gl),
    m_depthOptions(gl),
    m_geometryOptions(gl),
    m_hints(gl),
    m_implementationInfo(gl),
    m_sampleOptions(gl),
    m_stencilOptions(gl) {
  ui.setupUi(this);
}
}

#include "precompiled.hpp"
#include "ui/docks/OpenGLStateWidget.hpp"

#include "gl/OpenGLPointers.hpp"

namespace balls {

OpenGLStateWidget::OpenGLStateWidget(OpenGLPointers& gl, QWidget* parent)
  : QWidget(parent),
    m_blendState(gl),
    m_clipOptions(gl),
    m_colorOptions(gl),
    m_depthOptions(gl),
    m_geometryOptions(gl),
    m_hints(gl),
    m_implementationInfo(gl),
    m_sampleOptions(gl),
    m_stencilOptions(gl) {
  ui.setupUi(this);

  ui.openGlProperties->addObject(&m_blendState);
  ui.openGlProperties->addObject(&m_clipOptions);
  ui.openGlProperties->addObject(&m_colorOptions);
  ui.openGlProperties->addObject(&m_depthOptions);
  ui.openGlProperties->addObject(&m_geometryOptions);
  ui.openGlProperties->addObject(&m_hints);
  ui.openGlProperties->addObject(&m_implementationInfo);
  ui.openGlProperties->addObject(&m_sampleOptions);
  ui.openGlProperties->addObject(&m_stencilOptions);
}
}

Add the OpenGL state objects to the property manager


/*
    Copyright (C) 2008  Paul Richards.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"

#include "DebugOutputCallbacks.h"

namespace Proffy {
    DebugOutputCallbacks::~DebugOutputCallbacks()
    {
    }

    HRESULT __stdcall DebugOutputCallbacks::QueryInterface(REFIID interfaceId, PVOID* result)
    {
        *result = NULL;

        if (IsEqualIID(interfaceId, __uuidof(IUnknown)) ||
            IsEqualIID(interfaceId, __uuidof(IDebugEventCallbacks))) {
            *result = this;
            AddRef();
            return S_OK;
        } else {
            return E_NOINTERFACE;
        }
    }

    ULONG __stdcall DebugOutputCallbacks::AddRef(void)
    {
        return 1;
    }

    ULONG __stdcall DebugOutputCallbacks::Release(void)
    {
        return 1;
    }

    HRESULT __stdcall DebugOutputCallbacks::Output(ULONG /*mask*/, PCSTR text)
    {
        std::cout << text;
        return S_OK;
    }
}

/*
    Copyright (C) 2008  Paul Richards.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"

#include "DebugOutputCallbacks.h"

namespace Proffy {
    DebugOutputCallbacks::~DebugOutputCallbacks()
    {
    }

    HRESULT __stdcall DebugOutputCallbacks::QueryInterface(REFIID interfaceId, PVOID* result)
    {
        *result = NULL;

        if (IsEqualIID(interfaceId, __uuidof(IUnknown)) ||
            IsEqualIID(interfaceId, __uuidof(IDebugOutputCallbacks))) {
            *result = this;
            AddRef();
            return S_OK;
        } else {
            return E_NOINTERFACE;
        }
    }

    ULONG __stdcall DebugOutputCallbacks::AddRef(void)
    {
        return 1;
    }

    ULONG __stdcall DebugOutputCallbacks::Release(void)
    {
        return 1;
    }

    HRESULT __stdcall DebugOutputCallbacks::Output(ULONG /*mask*/, PCSTR text)
    {
        std::cout << text;
        return S_OK;
    }
}

Fix typo spotted by Phil.  Still doesn't fix the assertion.

git-svn-id: 8f4169f362aa98d77d2b69c890b9cda3cf6a6d2c@451 8e395407-42ff-0310-94d9-ec183df6106f


//===- lld/unittest/UniversalDriverTest.cpp -------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief Universal driver tests that depend on the value of argv[0].
///
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"

#include "lld/Driver/Driver.h"

#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;
using namespace lld;

TEST(UniversalDriver, flavor) {
  const char *args[] = { "ld" };

  std::string diags;
  raw_string_ostream os(diags);
  UniversalDriver::link(array_lengthof(args), args, os);
  EXPECT_EQ(os.str().find("failed to determine driver flavor"),
            std::string::npos);
  EXPECT_NE(os.str().find("No input files"),
            std::string::npos);
}

//===- lld/unittest/UniversalDriverTest.cpp -------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief Universal driver tests that depend on the value of argv[0].
///
//===----------------------------------------------------------------------===//

#include "gtest/gtest.h"

#include "lld/Driver/Driver.h"

#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;
using namespace lld;

TEST(UniversalDriver, flavor) {
  const char *args[] = { "gnu-ld" };

  std::string diags;
  raw_string_ostream os(diags);
  UniversalDriver::link(array_lengthof(args), args, os);
  EXPECT_EQ(os.str().find("failed to determine driver flavor"),
            std::string::npos);
  EXPECT_NE(os.str().find("No input files"),
            std::string::npos);
}

Fix unit test now that 'ld' is host specific

git-svn-id: f6089bf0e6284f307027cef4f64114ee9ebb0424@217114 91177308-0d34-0410-b5e6-96231b3b80d8


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

#include "chrome/browser/extensions/api/guest_view/guest_view_internal_api.h"

#include "chrome/browser/guest_view/guest_view_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/guest_view_internal.h"
#include "extensions/common/permissions/permissions_data.h"

namespace extensions {

GuestViewInternalAllocateInstanceIdFunction::
    GuestViewInternalAllocateInstanceIdFunction() {
}

bool GuestViewInternalAllocateInstanceIdFunction::RunAsync() {
  EXTENSION_FUNCTION_VALIDATE(!args_->GetSize());

  // Check if we have "webview" permission.
  CHECK(GetExtension()->permissions_data()->HasAPIPermission(
            APIPermission::kWebView));

  int instanceId = GuestViewManager::FromBrowserContext(browser_context())
                       ->GetNextInstanceID();
  SetResult(base::Value::CreateIntegerValue(instanceId));
  SendResponse(true);
  return true;
}

}  // namespace extensions

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

#include "chrome/browser/extensions/api/guest_view/guest_view_internal_api.h"

#include "chrome/browser/guest_view/guest_view_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/guest_view_internal.h"
#include "extensions/common/permissions/permissions_data.h"

namespace {
const char* kWebViewPermissionRequiredError =
    "\"webview\" permission is required for allocating instance ID.";
}  // namespace

namespace extensions {

GuestViewInternalAllocateInstanceIdFunction::
    GuestViewInternalAllocateInstanceIdFunction() {
}

bool GuestViewInternalAllocateInstanceIdFunction::RunAsync() {
  EXTENSION_FUNCTION_VALIDATE(!args_->GetSize());

  if (!GetExtension()->permissions_data()->HasAPIPermission(
          APIPermission::kWebView)) {
    LOG(ERROR) << kWebViewPermissionRequiredError;
    error_ = kWebViewPermissionRequiredError;
    SendResponse(false);
    return false;
  }

  int instanceId = GuestViewManager::FromBrowserContext(browser_context())
                       ->GetNextInstanceID();
  SetResult(base::Value::CreateIntegerValue(instanceId));
  SendResponse(true);
  return true;
}

}  // namespace extensions

Remove a hard CHECK when allocating instance ID would fail.

A CHECK here seems too intrusive to me, I've changed it
to send error response instead.
A compromised renderer should not take down the whole browser process.

BUG=364141
Test=None, internal clean up.

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

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


// 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 = "";
	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()
{
	RESTART:
	string input = "";
	ConsoleOutCheck(input);
	CheckForInt(input);
	CheckForIntAfterMath(input);
	CHECKFORIOSTREAM(input);
	getline(cin, input);
	goto RESTART;
}

Add some missing function initializers.

Add some missing function initializers.

These functions are used to take data from the string input and read the
C++ code from it.


#include "settings.h"

int N_POLY_POINTS = 6;
int N_COLOR_VAR = 5;
int N_POS_VAR = 10;
int SHAPE_OPT_FREQ = 0;
int GUI_REFRESH_RATE = 1;
int AUTOFOCUS_RES = 2;
int N_CORES = 4;

int FOCUS_LEFT=0, FOCUS_RIGHT=100, FOCUS_TOP=0, FOCUS_BOTTOM=100;

int POLYS_MIN=5, POLYS_MAX=150000;

// Rates of mutation in % of odds per generation
int POLYS_ADD_RATE=20;
int POLYS_REMOVE_RATE=20;
int POLYS_REORDER_RATE=20;
int POINT_MOVE_RATE=20;
int POINT_ADD_RATE=10;
int POINT_DELETE_RATE=10;

#include "settings.h"

int N_POLY_POINTS = 6;
int N_COLOR_VAR = 5;
int N_POS_VAR = 10;
int SHAPE_OPT_FREQ = 0;
int GUI_REFRESH_RATE = 1;
int AUTOFOCUS_RES = 2;
int N_CORES = 4;

int FOCUS_LEFT=0, FOCUS_RIGHT=100, FOCUS_TOP=0, FOCUS_BOTTOM=100;

int POLYS_MIN=15000, POLYS_MAX=150000;

// Rates of mutation in % of odds per generation
int POLYS_ADD_RATE=20;
int POLYS_REMOVE_RATE=20;
int POLYS_REORDER_RATE=20;
int POINT_MOVE_RATE=20;
int POINT_ADD_RATE=10;
int POINT_DELETE_RATE=10;

Disable new mutations for the moment

Disable new mutations for the moment

Keep piling polys in master until we have a decent replacement.


#include "settings.h"

int N_POLY_POINTS = 6;
int N_COLOR_VAR = 5;
int N_POS_VAR = 10;
int SHAPE_OPT_FREQ = 0;
int GUI_REFRESH_RATE = 1;
int AUTOFOCUS_RES = 2;
int N_CORES = 4;

int FOCUS_LEFT=0, FOCUS_RIGHT=100, FOCUS_TOP=0, FOCUS_BOTTOM=100;

int POLYS_MIN=5, POLYS_MAX=100;

// Rates of mutation in % of odds per generation
int POLYS_ADD_RATE=20;
int POLYS_REMOVE_RATE=20;
int POLYS_REORDER_RATE=20;
int POINT_MOVE_RATE=20;
int POINT_ADD_RATE=10;
int POINT_DELETE_RATE=10;

#include "settings.h"

int N_POLY_POINTS = 6;
int N_COLOR_VAR = 5;
int N_POS_VAR = 10;
int SHAPE_OPT_FREQ = 0;
int GUI_REFRESH_RATE = 1;
int AUTOFOCUS_RES = 2;
int N_CORES = 4;

int FOCUS_LEFT=0, FOCUS_RIGHT=100, FOCUS_TOP=0, FOCUS_BOTTOM=100;

int POLYS_MIN=5, POLYS_MAX=150000;

// Rates of mutation in % of odds per generation
int POLYS_ADD_RATE=20;
int POLYS_REMOVE_RATE=20;
int POLYS_REORDER_RATE=20;
int POINT_MOVE_RATE=20;
int POINT_ADD_RATE=10;
int POINT_DELETE_RATE=10;

Set sane(r) default poly min/max limits

Set sane(r) default poly min/max limits


#include "kronrodLaurieGautschi.h"
#include "kronrodPiessensBurkardt.h"

#include <iostream>
#include <iomanip>

using namespace Kronrod;
using namespace Eigen;
using namespace std;

int main()
{
    Array<double,Dynamic,2> ans;
    int n = 10;
    ans = multiPrecisionKronrod(n);

    cout << "Laurie/Gautschi:" << endl;
    cout << setprecision(15);
    cout << ans << endl;
    cout << endl << endl;

    cout << "PiessensBurkardt" << endl;

    Array<double, Dynamic, 1> xGK;
    Array<double, Dynamic, 1> wGK;
    Array<double, Dynamic, 1> wG;

    kronrod(n, xGK,  wGK, wG);

    cout << xGK << endl << endl;
    cout << wGK << endl << endl;
    cout << wG << endl << endl;
    return 0;
}

#include "kronrodLaurieGautschi.h"
#include "kronrodPiessens.h"

#include <iostream>
#include <iomanip>

using namespace Kronrod;
using namespace Eigen;
using namespace std;

int main()
{
    Array<double,Dynamic,2> ans;
    int n = 10;
    ans = multiPrecisionKronrod(n);

    cout << "Laurie/Gautschi:" << endl;
    cout << setprecision(15);
    cout << ans << endl;
    cout << endl << endl;

    cout << "Piessens" << endl;

    Array<double, Dynamic, 1> xGK;
    Array<double, Dynamic, 1> wGK;
    Array<double, Dynamic, 1> wG;

    kronrod(n, xGK,  wGK, wG);

    cout << xGK << endl << endl;
    cout << wGK << endl << endl;
    cout << wG << endl << endl;
    return 0;
}

Correct error introduced by file rename.


#include <stdio.h>

#include "video.h"

int main(int argc, char* argv[])
{
	if (argc < 3)
	{
	 printf("missing filename\n");
	 exit(0);
	}
	gst_init (NULL,NULL);

	int k;
	sscanf(argv[2], "%d", &k);
	for (int q = 0; q < k; q++) {
	video testvideo(argv[1]);

	while (testvideo.getvisible())
	{
		testvideo.update();
	}
	}

	gst_deinit();
}

/* Copyright 2014, Adrien Destugues <pulkomandy@pulkomandy.tk>
 * Distributed under the terms of the MIT license
 */
#include <stdio.h>

#include <sys/time.h>
#include <sys/resource.h>

#include "video.h"

int main(int argc, char* argv[])
{
	if (argc < 3)
	{
		printf("missing filename\n");
		exit(EXIT_FAILURE);
	}

	gst_init (NULL,NULL);

	struct rusage usage;

	int k;
	sscanf(argv[2], "%d", &k);

	for (int q = 0; q < k; q++) {
		getrusage(RUSAGE_CHILDREN, &usage);
		printf("Loop %d: maxrss=%d\n", q, usage.ru_maxrss);

		video testvideo(argv[1]);

		while (testvideo.getvisible())
		{
			testvideo.update();
		}
	}

	gst_deinit();
	exit(EXIT_SUCCESS);
}

Print maxrss before playing each video.

Print maxrss before playing each video.


#include "company.hpp"
#include <ref/DescriptorsImpl.ipp>

template class ref::ClassDescriptorImpl< example::Company >;

#include "company.hpp"
#include <ref/DescriptorsImpl.ipp>

template struct ref::ClassDescriptorImpl< example::Company >;

Fix compilation error with clang.

Fix compilation error with clang.


// RUN: %clangxx_tsan -O1 -DTEST_ERROR=ERANGE %s -o %t && %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYS %s
// RUN: %clangxx_tsan -O1 -DTEST_ERROR=-1 %s -o %t && not %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-USER %s

#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>

char buffer[1000];

void *Thread(void *p) {
  return strerror_r(TEST_ERROR, buffer, sizeof(buffer));
}

int main() {
  pthread_t th[2];
  pthread_create(&th[0], 0, Thread, 0);
  pthread_create(&th[1], 0, Thread, 0);
  pthread_join(th[0], 0);
  pthread_join(th[1], 0);
  fprintf(stderr, "DONE\n");
}

// CHECK-USER: WARNING: ThreadSanitizer: data race
// CHECK-SYS-NOT: WARNING: ThreadSanitizer: data race

// CHECK: DONE

// RUN: %clangxx_tsan -O1 -DTEST_ERROR=ERANGE %s -o %t && %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-SYS %s
// RUN: %clangxx_tsan -O1 -DTEST_ERROR=-1 %s -o %t && not %run %t 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-USER %s

#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>

char buffer[1000];

void *Thread(void *p) {
  (void)strerror_r(TEST_ERROR, buffer, sizeof(buffer));
  return p;
}

int main() {
  pthread_t th[2];
  pthread_create(&th[0], 0, Thread, 0);
  pthread_create(&th[1], 0, Thread, 0);
  pthread_join(th[0], 0);
  pthread_join(th[1], 0);
  fprintf(stderr, "DONE\n");
}

// CHECK-USER: WARNING: ThreadSanitizer: data race
// CHECK-SYS-NOT: WARNING: ThreadSanitizer: data race

// CHECK: DONE

Fix tsan test for Darwin. NFCI.

Fix tsan test for Darwin. NFCI.

On Darwin, strerror_r returns an int, not a char*. I don't think this
test really depends on what strerror_r returns, so I've used something
else in place of the result of the call to strerror_r.

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


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

enum X : short { A, B };
extern decltype(+A) x;
extern int x;

enum Y : long { C, D };
extern decltype(+C) y;
extern long y;

// An enum with a fixed underlying type has an integral promotion to that type,
// and to its promoted type.
enum B : bool { false_, true_ };
template<bool> struct T {};
T<false_> f;
T<true_> t;
T<+true_> t; // expected-error {{conversion from 'int' to 'bool'}}

enum B2 : bool {
  a = false,
  b = true,
  c = false_,
  d = true_,
  e = +false_ // expected-error {{conversion from 'int' to 'bool'}} \
              // FIXME: expected-error {{enumerator value 2 is not representable}}
};

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

enum X : short { A, B };
extern decltype(+A) x;
extern int x;

enum Y : long { C, D };
extern decltype(+C) y;
extern long y;

// An enum with a fixed underlying type has an integral promotion to that type,
// and to its promoted type.
enum B : bool { false_, true_ };
template<bool> struct T {};
T<false_> f;
T<true_> t;
// FIXME: DR1407 will make this ill-formed for a different reason.
T<+true_> q; // desired-error {{conversion from 'int' to 'bool'}}

enum B2 : bool {
  a = false,
  b = true,
  c = false_,
  d = true_,
  // FIXME: DR1407 will make this ill-formed
  e = +false_ // desired-error {{conversion from 'int' to 'bool'}}
};

Fix up after r163846. Sorry!

Fix up after r163846. Sorry!

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


#include "Game.h"

int main(int argc, char** argv) { // A * token followed by another * token in this case is a pointer to a pointer. In this case, argv is a pointer to an array of char*. It is equivalent to (int argc, char* argv[]).
    Game::Start();

    return 0;
}

#include "Game.h"
#include <SFML/Graphics.hpp>

int main(int argc, char** argv) { // A * token followed by another * token in this case is a pointer to a pointer. In this case, argv is a pointer to an array of char*. It is equivalent to (int argc, char* argv[]).
    Game::Start();

    return 0;
}

Change style of the code and file name

Change style of the code and file name


#include "GLResource.h"
#include "renderers/utils/GLResourceManager.h"

#include <thread>

namespace carto {

    GLResource::~GLResource() {
    }

    bool GLResource::isValid() const {
        if (_manager.lock()) {
            return true;
        }
        return false;
    }

    GLResource::GLResource(const std::weak_ptr<GLResourceManager>& manager) :
        _manager(manager)
    {
    }

}

#include "GLResource.h"
#include "renderers/utils/GLResourceManager.h"

#include <thread>

namespace carto {

    GLResource::~GLResource() {
    }

    bool GLResource::isValid() const {
        if (auto manager = _manager.lock()) {
            return manager->getGLThreadId() != std::thread::id();
        }
        return false;
    }

    GLResource::GLResource(const std::weak_ptr<GLResourceManager>& manager) :
        _manager(manager)
    {
    }

}

Make lost GL context checking more robust, fixes thread race between layers and renderers


#include <paparazzi/SysTime.h>

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

void printCallBack (uint8_t a) {
    std::cout << "Call !" << std::endl ;
}

int main () {

    SysTime *systime = SysTime::getSysTime () ;

    tid_t mainID = systime->registerTimer (0.5, printCallBack);
    tid_t stopID = systime->registerTimer (10, 0) ;

    while (!systime->checkAndAckTimer(stopID)) {
        usleep(10) ;
    }

    return 0 ;

}

#include "../src/SysTime.h"

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

void printCallBack (uint8_t a) {
    std::cout << "Call !" << std::endl ;
}

int main () {

    SysTime *systime = SysTime::getSysTime () ;

    tid_t mainID = systime->registerTimer (0.5, printCallBack);
    tid_t stopID = systime->registerTimer (10, 0) ;

    while (!systime->checkAndAckTimer(stopID)) {
        usleep(10) ;
    }

    return 0 ;

}

Update folder include for SysTime.h.

Update folder include for SysTime.h.


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

// REQUIRES: modules-support

// RUN: %build_module

#include <clocale>

#define TEST(...) do { using T = decltype( __VA_ARGS__ ); } while(false)

int main() {
  std::lconv l; ((void)l);

  TEST(std::setlocale(0, ""));
  TEST(std::localeconv());
}

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

// REQUIRES: modules-support
// UNSUPPORTED: c++98, c++03

// RUN: %build_module

#include <clocale>

#define TEST(...) do { using T = decltype( __VA_ARGS__ ); } while(false)

int main() {
  std::lconv l; ((void)l);

  TEST(std::setlocale(0, ""));
  TEST(std::localeconv());
}

Mark test as unsupported in C++03

Mark test as unsupported in C++03

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


#include <mettle.hpp>
using namespace mettle;

struct my_type {};

namespace my_namespace {
  struct another_type {};
}

suite<> test_type_name("type_name()", [](auto &_) {
  _.test("primitives", []() {
    expect(type_name<int>(), equal_to("int"));
    expect(type_name<int &>(), equal_to("int &"));
    expect(type_name<int &&>(), equal_to("int &&"));
    expect(type_name<const int>(), equal_to("const int"));
    expect(type_name<volatile int>(), equal_to("volatile int"));
    expect(type_name<const volatile int>(), equal_to("const volatile int"));
  });

  _.test("custom types", []() {
    expect(type_name<my_type>(), equal_to("my_type"));
    expect(type_name<my_namespace::another_type>(),
           equal_to("my_namespace::another_type"));
  });
});

#include <mettle.hpp>
using namespace mettle;

struct my_type {};

namespace my_namespace {
  struct another_type {};
}

suite<> test_type_name("type_name()", [](auto &_) {
  _.test("primitives", []() {
    expect(type_name<int>(), equal_to("int"));
    expect(type_name<int &>(), regex_match("int\\s*&"));
    expect(type_name<int &&>(), regex_match("int\\s*&&"));
    expect(type_name<const int>(), equal_to("const int"));
    expect(type_name<volatile int>(), equal_to("volatile int"));
    expect(type_name<const volatile int>(), equal_to("const volatile int"));
  });

  _.test("custom types", []() {
    expect(type_name<my_type>(), equal_to("my_type"));
    expect(type_name<my_namespace::another_type>(),
           equal_to("my_namespace::another_type"));
  });
});

Use regex_match to be more flexible with checking type_name's result


/*
 * The MIT License (MIT)
 *
 * Copyright (c) <2016> <Stephan Gatzka>
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <stdbool.h>

#include "authenticate.h"

extern "C" {

	bool credentials_ok(const char *user, char *passwd)
	{
		(void)user;
		(void)passwd;
		return true;
	}
}

/*
 * The MIT License (MIT)
 *
 * Copyright (c) <2016> <Stephan Gatzka>
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <stdbool.h>

#include "authenticate.h"

extern "C" {

	const cJSON *credentials_ok(const char *user, char *passwd)
	{
		(void)user;
		(void)passwd;
		return NULL;
	}
}

Correct function prototype of stub function.