// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s

// REQUIRES: compiler-rt-optimized
// UNSUPPORTED: android

#include <string.h>
int main(int argc, char **argv) {
  char a1[] = {static_cast<char>(argc), 2, 3, 4};
  char a2[] = {1, static_cast<char>(2 * argc), 3, 4};
  int res = bcmp(a1, a2, 4 + argc); // BOOM
  // CHECK: AddressSanitizer: stack-buffer-overflow
  // CHECK: {{#1.*bcmp}}
  // CHECK: {{#2.*main}}
  return res;
}

// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s

// REQUIRES: compiler-rt-optimized
// UNSUPPORTED: android
// XFAIL: darwin

#include <string.h>
int main(int argc, char **argv) {
  char a1[] = {static_cast<char>(argc), 2, 3, 4};
  char a2[] = {1, static_cast<char>(2 * argc), 3, 4};
  int res = bcmp(a1, a2, 4 + argc); // BOOM
  // CHECK: AddressSanitizer: stack-buffer-overflow
  // CHECK: {{#1.*bcmp}}
  // CHECK: {{#2.*main}}
  return res;
}

[compiler-rt] Disable failing test on darwin during investigation.

/Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/projects/compiler-rt/test/asan/TestCases/Posix/bcmp_test.cc:14:12: error: CHECK: expected string not found in input
 // CHECK: {{#1.*bcmp}}
           ^
<stdin>:2:57: note: scanning from here
==34677==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffee93777c4 at pc 0x0001068a7285 bp 0x7ffee9377770 sp 0x7ffee9376ef8
                                                        ^
<stdin>:6:20: note: possible intended match here
 #2 0x106888e77 in main bcmp_test.cc:12
                   ^

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


// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trymacro.cpp %s | FileCheck %s

// CHECK: Z3fn1v:
void fn1() try { return; } // CHECK: [[@LINE]]:12 -> [[@LINE+1]]:14 = #1
catch(...) {}              // CHECK: [[@LINE]]:12 -> [[@LINE]]:14 = #2

#define RETURN_BLOCK { return; }

// CHECK: Z3fn2v:
void fn2() try RETURN_BLOCK // CHECK: [[@LINE]]:12 -> [[@LINE+1]]:14 = #1
catch(...) {}               // CHECK: [[@LINE]]:12 -> [[@LINE]]:14 = #2

#define TRY try
#define CATCH(x) catch (x)

// CHECK: Z3fn3v:
void fn3() TRY { return; } // CHECK: [[@LINE]]:12 -> [[@LINE+1]]:14 = #1
CATCH(...) {}              // CHECK: [[@LINE]]:12 -> [[@LINE]]:14 = #2

int main() {
  fn1();
  fn2();
  fn3();
}

// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++11 -fexceptions -fcxx-exceptions -fprofile-instr-generate -fcoverage-mapping -dump-coverage-mapping -emit-llvm-only -main-file-name trymacro.cpp %s | FileCheck %s

// CHECK: Z3fn1v:
void fn1() try { return; } // CHECK: [[@LINE]]:12 -> [[@LINE+1]]:14 = #1
catch(...) {}              // CHECK: [[@LINE]]:12 -> [[@LINE]]:14 = #2

#define RETURN_BLOCK { return; }

// CHECK: Z3fn2v:
void fn2() try RETURN_BLOCK // CHECK: [[@LINE]]:12 -> [[@LINE+1]]:14 = #1
catch(...) {}               // CHECK: [[@LINE]]:12 -> [[@LINE]]:14 = #2

#define TRY try
#define CATCH(x) catch (x)

// CHECK: Z3fn3v:
void fn3() TRY { return; } // CHECK: [[@LINE]]:15 -> [[@LINE+1]]:14 = #1
CATCH(...) {}              // CHECK: [[@LINE]]:12 -> [[@LINE]]:14 = #2

int main() {
  fn1();
  fn2();
  fn3();
}

Fix a typo in the test for r243066

InstrProf: Fix a typo in the test for r243066

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


/*
 * rngs
 * ECE 541 Project 2
 * Kashev Dalmia - dalmia3
 * David Huang   - huang157
 */

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

namespace rng
{
    RANLUX32::RANLUX32() :
        RandomNumberGenerator(),
        prev(0),
        count(0),
        state(),
        index(0)
    {}

    void RANLUX32::seed(fuint seed_num) {
        state[0] = seed_num;

        /*
         * Initialize seed vector using MINSTD
         */
        static constexpr uint64_t g = 48271;
        static constexpr uint64_t n = (1UL << 48UL); // 2^49
        for(size_t i = 1; i < state.size(); ++i)
        {
            state[i] = static_cast<fuint>((static_cast<uint64_t>(state[i-1]) * g) % n);
        }
    }

    fuint RANLUX32::operator()() {
        if(count == discard) {
            count = 0;
            for(uint i = 0; i < block_size-discard; ++i) {
                next_state();
            }
        }
        uint64_t output = next_state();
        count++;
        return static_cast<fuint>(output);
    }
}

/*
 * rngs
 * ECE 541 Project 2
 * Kashev Dalmia - dalmia3
 * David Huang   - huang157
 */

#include "ranlux32.h"

namespace rng
{
    RANLUX32::RANLUX32() :
        RandomNumberGenerator(),
        prev(0),
        count(0),
        state(),
        index(0)
    {}

    void RANLUX32::seed(fuint seed_num) {
        state[0] = seed_num;

        /*
         * Initialize seed vector using MINSTD
         */
        static constexpr uint64_t g = 48271;
        static constexpr uint64_t n = (1UL << 48UL); // 2^49
        for(size_t i = 1; i < state.size(); ++i)
        {
            state[i] = static_cast<fuint>((static_cast<uint64_t>(state[i-1]) * g) % n);
        }
    }

    fuint RANLUX32::operator()() {
        if(count == discard) {
            count = 0;
            for(uint i = 0; i < block_size-discard; ++i) {
                next_state();
            }
        }
        uint64_t output = next_state();
        count++;
        return static_cast<fuint>(output);
    }
}

Remove iostream inclusion in RANLUX

Remove iostream inclusion in RANLUX


//===-- ARMTargetAsmInfo.cpp - ARM asm properties ---------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by James M. Laskey and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declarations of the ARMTargetAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "ARMTargetAsmInfo.h"

using namespace llvm;

ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
  Data16bitsDirective = "\t.half\t";
  Data32bitsDirective = "\t.word\t";
  Data64bitsDirective = 0;
  ZeroDirective = "\t.skip\t";
  CommentString = "@";
  ConstantPoolSection = "\t.text\n";
  AlignmentIsInBytes = false;
  WeakRefDirective = "\t.weak\t";
}

//===-- ARMTargetAsmInfo.cpp - ARM asm properties ---------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by James M. Laskey and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the declarations of the ARMTargetAsmInfo properties.
//
//===----------------------------------------------------------------------===//

#include "ARMTargetAsmInfo.h"

using namespace llvm;

ARMTargetAsmInfo::ARMTargetAsmInfo(const ARMTargetMachine &TM) {
  Data16bitsDirective = "\t.half\t";
  Data32bitsDirective = "\t.word\t";
  Data64bitsDirective = 0;
  ZeroDirective = "\t.skip\t";
  CommentString = "@";
  ConstantPoolSection = "\t.text\n";
  AlignmentIsInBytes = false;
  WeakRefDirective = "\t.weak\t";
  StaticCtorsSection = "\t.section .ctors,\"aw\",%progbits";
  StaticDtorsSection = "\t.section .dtors,\"aw\",%progbits";
}

Define StaticCtorsSection and StaticDtorsSection for ARM.

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


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

using namespace std;

string make_outfile(string namefile);

int main(int argc, char* argv[])
{
        Word word;

        if (argc < 2) {
                cerr << "Usage: si [origin].si [destination].cpp" << endl;
                exit(EXIT_FAILURE);
        }
        else if (argc == 2) {
                string outfile = make_outfile(argv[1]);
                word.set_out(outfile);
        }
        else if (argc > 2)
                word.set_out(argv[2]);

        word.set_in(argv[1]);
        word.write();

        word.close_files();
}

/* if no destination file is provided, this will take the
 * first argument and turn its contents in to the name
 * of the destination file in .cpp format
 */
string make_outfile(string namefile)
{
        string name = "";
        for (int i = 0; i < (int)namefile.length(); i++) {
                if (namefile[i] == '.') {
                        name = namefile.substr(0,i);
                        name += ".cpp";
                        break;
                }
        }
        if (name == "") {
                cerr << "No .si file found\n";
                exit(EXIT_FAILURE);
        }
        return name;
}

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

using namespace std;

string make_outfile(string namefile);

int main(int argc, char* argv[])
{
        Word word;

        if (argc < 2) {
                cerr << "Usage: si origin.si [destination.cpp]" << endl;
                exit(EXIT_FAILURE);
        }
        else if (argc == 2) {
                ifstream inputFile(argv[1]);
                if (!inputFile) {
                        cerr << "ERROR: Input file could not be read." << endl;
                        exit(EXIT_FAILURE);
                } else {
                        string outfile = make_outfile(argv[1]);
                        word.set_out(outfile);
                }
        }
        else if (argc > 2) {
                ifstream inputFile(argv[1]);
                if (!inputFile) {
                        cerr << "ERROR: Input file could not be read." << endl;
                        exit(EXIT_FAILURE);
                } else {
                        word.set_out(argv[2]);
                }

        }

        word.set_in(argv[1]);
        word.write();

        word.close_files();
}

/* if no destination file is provided, this will take the
 * first argument and turn its contents in to the name
 * of the destination file in .cpp format
 */
string make_outfile(string namefile)
{
        string name = "";
        for (int i = 0; i < (int)namefile.length(); i++) {
                if (namefile[i] == '.') {
                        name = namefile.substr(0,i);
                        name += ".cpp";
                        break;
                }
        }
        if (name == "") {
                cerr << "No .si file found\n";
                exit(EXIT_FAILURE);
        }
        return name;
}

Add a sanity check for the input file

Add a sanity check for the input file


#include <iostream>
#include <string>

#include "job.h"

Job::Job(int id, std::string machine_name)
    : job_id(id), state(State::Moveable), machine(machine_name)
{
    std::cout << "Created new job: " << id << std::endl;
}

int Job::get_id() const
{
    return job_id;
}

const std::string& Job::get_machine() const
{
    return machine;
}

bool Job::moveable() const
{
    return state == State::Moveable;
}

#include <iostream>
#include <string>

#include "job.h"

Job::Job(int id, std::string machine_name)
    : job_id(id), machine(machine_name), state(State::Moveable)
{
    std::cout << "Created new job: " << id << std::endl;
}

int Job::get_id() const
{
    return job_id;
}

const std::string& Job::get_machine() const
{
    return machine;
}

bool Job::moveable() const
{
    return state == State::Moveable;
}

Change the order of variables in the constructor init list

Member variables are always initialised in the order in which they were
declared in the class. If an initialiser list uses a different order,
the initialisations will be re-ordered by the compiler to match the
order of declaration. In some cases, this can lead to unexpected
behaviour when it looks like a variable is being used after
initialisation, but is in fact being used before initialisation.

This particular instance had no such issue, but it is better to keep the
constructor init list ordered to avoid any chance of this happening.


#include <GL/glx.h>

#include "linuxwindow.hh"
#include "system/openglcontext.hh"

#include <iostream>

class LinuxOpenGLContext : public System::OpenGLContext
{
public:
    LinuxOpenGLContext(System::Window *window)
        : _window((LinuxWindow *)window)
    {
        Display *display = _window->getDisplay();
        ::Window windowHandle = _window->getWindowHandle();
        GLint attributes[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
        XVisualInfo *visualInfo = glXChooseVisual(display, 0, attributes);
        Colormap colorMap = XCreateColormap(display, windowHandle, visualInfo->visual, AllocNone);

        _context = glXCreateContext(display, visualInfo, NULL, GL_TRUE);

        glXMakeCurrent(display, windowHandle, _context);
    }

    ~LinuxOpenGLContext()
    {
    }

    void SwapBuffers()
    {
    }

private:
    LinuxWindow *_window;
    GLXContext _context;
};

System::OpenGLContext *System::OpenGLContext::Create(System::Window *window)
{
    return new LinuxOpenGLContext(window);
}

#include <GL/glx.h>

#include "linuxwindow.hh"
#include "system/openglcontext.hh"

class LinuxOpenGLContext : public System::OpenGLContext
{
public:
    LinuxOpenGLContext(System::Window *window)
        : _window((LinuxWindow *)window)
    {
        Display *display = _window->getDisplay();
        ::Window windowHandle = _window->getWindowHandle();
        GLint attributes[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };

        XVisualInfo *visualInfo = glXChooseVisual(display, 0, attributes);
        Colormap colorMap = XCreateColormap(display, windowHandle, visualInfo->visual, AllocNone);

        _context = glXCreateContext(display, visualInfo, NULL, GL_TRUE);

        glXMakeCurrent(display, windowHandle, _context);
    }

    ~LinuxOpenGLContext()
    {
    }

    void SwapBuffers()
    {
    }

private:
    LinuxWindow *_window;
    GLXContext _context;
};

System::OpenGLContext *System::OpenGLContext::Create(System::Window *window)
{
    return new LinuxOpenGLContext(window);
}

Clean up a couple things

Clean up a couple things


#include <libclientserver.h>

RateLimit::RateLimit()
{
	m_last = {0, 0};
}

RateLimit::~RateLimit()
{

}

void RateLimit::SetTimeout(const struct timespec *tv)
{
	memcpy(&m_timeout, tv, sizeof(*tv));
}

bool RateLimit::Check()
{
	struct timespec now;
	struct timespec when;
	Time::MonoTonic(&now);
	Time::Add(&now, &m_timeout, &when);

	if (Time::IsGreater(&now, &when))
	{
		memcpy(&m_last, &now, sizeof(now));
		return true;
	}
	return false;

}

#include <libclientserver.h>

RateLimit::RateLimit()
{
	m_last.tv_sec = 0;
	m_last.tv_nsec = 0;
}

RateLimit::~RateLimit()
{

}

void RateLimit::SetTimeout(const struct timespec *tv)
{
	memcpy(&m_timeout, tv, sizeof(*tv));
}

bool RateLimit::Check()
{
	struct timespec now;
	struct timespec when;
	Time::MonoTonic(&now);
	Time::Add(&now, &m_timeout, &when);

	if (Time::IsGreater(&now, &when))
	{
		memcpy(&m_last, &now, sizeof(now));
		return true;
	}
	return false;

}

Fix compiler warning which is not support until c++11


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

#include "chrome/browser/extensions/extension_apitest.h"

// Flaky, http://crbug.com/19866. Please consult phajdan.jr before re-enabling.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_Bookmarks) {
  ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
}

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

#include "chrome/browser/extensions/extension_apitest.h"

// Flaky, http://crbug.com/19866. Please consult phajdan.jr before re-enabling.
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, FLAKY_Bookmarks) {
  ASSERT_TRUE(RunExtensionTest("bookmarks")) << message_;
}

Move ExtensionApiTest.Bookmarks from DISABLED to FLAKY since it doesn't
crash.

BUG=19866
TEST=ExtensionApiTest.Bookmarks

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

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


#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    int t;
    if(a > b) t = a, a = b, b = t;
    if(b > c) t = b, b = c, c = t;
    if(a > b) t = a, a = b, b = t;

    printf("%d %d %d\n", a, b, c);
    return 0;
}

#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if(a > b) { int tmp = a; a = b; b = tmp; }
    if(b > c) { int tmp = b; b = c; c = tmp; }
    if(a > b) { int tmp = a; a = b; b = tmp; }

    printf("%d %d %d\n", a, b, c);
    return 0;
}

Reduce a scope of the temporary variable


#include <sdk/config.h>

#ifndef SCHEDULER_CORO_OSTHREAD
# include "Coro.c"
#endif

Include sdk/config.h before testing configuration macros.

	* src/scheduler/libcoroutine/Coro.cc: Here.


// 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 "base/path_service.h"
#include "chrome/test/remoting/qunit_browser_test_runner.h"

#if defined(OS_MACOSX)
#include "base/mac/foundation_util.h"
#endif // !defined(OS_MACOSX)

namespace remoting {

IN_PROC_BROWSER_TEST_F(QUnitBrowserTestRunner, Remoting_Webapp_Js_Unittest) {
  base::FilePath base_dir;
  ASSERT_TRUE(PathService::Get(base::DIR_EXE, &base_dir));

#if defined(OS_MACOSX)
  if (base::mac::AmIBundled()) {
    // If we are inside a mac bundle, navigate up to the output directory
    base_dir = base::mac::GetAppBundlePath(base_dir).DirName();
  }
#endif // !defined(OS_MACOSX)
  RunTest(
      base_dir.Append(FILE_PATH_LITERAL("remoting/unittests/unittest.html")));
}

}  // namespace remoting

// 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 "base/path_service.h"
#include "chrome/test/remoting/qunit_browser_test_runner.h"

#if defined(OS_MACOSX)
#include "base/mac/foundation_util.h"
#endif // !defined(OS_MACOSX)

namespace remoting {

IN_PROC_BROWSER_TEST_F(QUnitBrowserTestRunner, Remoting_Webapp_Js_Unittest) {
  base::FilePath base_dir;
  ASSERT_TRUE(PathService::Get(base::DIR_EXE, &base_dir));

#if defined(OS_MACOSX)
  if (base::mac::AmIBundled()) {
    // If we are inside a mac bundle, navigate up to the output directory
    base_dir = base::mac::GetAppBundlePath(base_dir).DirName();
  }
#endif // !defined(OS_MACOSX)
  RunTest(
      base_dir.Append(FILE_PATH_LITERAL("remoting/unittests/unittests.html")));
}

}  // namespace remoting

Fix path to remoting webapp unittest results.

This was missed in the cleanup in crrev.com/984203003, leading to a
mismatch between the generated unittests.html and the filename expected
by the browser-test driver, and thereby breaking the tests once a build
clobber had removed the old-named file.

BUG=466752

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

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


/*
 * MRustC - Rust Compiler
 * - By John Hodge (Mutabah/thePowersGang)
 *
 * expand/rustc_diagnostics.cpp
 * - Stubbed handling for __register_diagnostic and __diagnostic_used
 */
#include <synext.hpp>
#include <parse/common.hpp>  // TokenTree etc
#include <parse/ttstream.hpp>

class CExpanderRegisterDiagnostic:
    public ExpandProcMacro
{
    ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
    {
        return box$( TTStreamO(TokenTree()) );
    }
};
class CExpanderDiagnosticUsed:
    public ExpandProcMacro
{
    ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
    {
        return box$( TTStreamO(TokenTree()) );
    }
};

STATIC_MACRO("__register_diagnostic", CExpanderRegisterDiagnostic)
STATIC_MACRO("__diagnostic_used", CExpanderDiagnosticUsed)

/*
 * MRustC - Rust Compiler
 * - By John Hodge (Mutabah/thePowersGang)
 *
 * expand/rustc_diagnostics.cpp
 * - Stubbed handling for __register_diagnostic and __diagnostic_used
 */
#include <synext.hpp>
#include <parse/common.hpp>  // TokenTree etc
#include <parse/ttstream.hpp>

class CExpanderRegisterDiagnostic:
    public ExpandProcMacro
{
    ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
    {
        return box$( TTStreamO(TokenTree()) );
    }
};
class CExpanderDiagnosticUsed:
    public ExpandProcMacro
{
    ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
    {
        return box$( TTStreamO(TokenTree()) );
    }
};
class CExpanderBuildDiagnosticArray:
    public ExpandProcMacro
{
    ::std::unique_ptr<TokenStream> expand(const Span& sp, const AST::Crate& crate, const ::std::string& ident, const TokenTree& tt, AST::Module& mod) override
    {
        return box$( TTStreamO(TokenTree()) );
    }
};

STATIC_MACRO("__register_diagnostic", CExpanderRegisterDiagnostic)
STATIC_MACRO("__diagnostic_used", CExpanderDiagnosticUsed)
STATIC_MACRO("__build_diagnostic_array", CExpanderBuildDiagnosticArray)

Expand - Handle another rustc internal macro


//===-- TargetOptionsCommandFlags.cpp ---------------------------*- C++ -*-===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file exists as a place for global variables defined in LLVM's
// CodeGen/CommandFlags.h. By putting the resulting object file in
// an archive and linking with it, the definitions will automatically be
// included when needed and skipped when already present.
//
//===----------------------------------------------------------------------===//

#include "lld/Common/TargetOptionsCommandFlags.h"

#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/Target/TargetOptions.h"

// Define an externally visible version of
// InitTargetOptionsFromCodeGenFlags, so that its functionality can be
// used without having to include llvm/CodeGen/CommandFlags.h, which
// would lead to multiple definitions of the command line flags.
llvm::TargetOptions lld::InitTargetOptionsFromCodeGenFlags() {
  return ::InitTargetOptionsFromCodeGenFlags();
}

llvm::Optional<llvm::CodeModel::Model> lld::GetCodeModelFromCMModel() {
  return getCodeModel();
}

//===-- TargetOptionsCommandFlags.cpp ---------------------------*- C++ -*-===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file exists as a place for global variables defined in LLVM's
// CodeGen/CommandFlags.def. By putting the resulting object file in
// an archive and linking with it, the definitions will automatically be
// included when needed and skipped when already present.
//
//===----------------------------------------------------------------------===//

#include "lld/Common/TargetOptionsCommandFlags.h"

#include "llvm/CodeGen/CommandFlags.def"
#include "llvm/Target/TargetOptions.h"

// Define an externally visible version of
// InitTargetOptionsFromCodeGenFlags, so that its functionality can be
// used without having to include llvm/CodeGen/CommandFlags.def, which
// would lead to multiple definitions of the command line flags.
llvm::TargetOptions lld::InitTargetOptionsFromCodeGenFlags() {
  return ::InitTargetOptionsFromCodeGenFlags();
}

llvm::Optional<llvm::CodeModel::Model> lld::GetCodeModelFromCMModel() {
  return getCodeModel();
}

Fix for file renaming in LLVM (CommandFlags.h -> CommandFlags.def)

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


/*
 *  Copyright (C) 2017  Mario Alviano (mario@alviano.net)
 *
 *  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 "Propagator.h"

#include "GlucoseWrapper.h"

namespace zuccherino {

Propagator::Propagator(GlucoseWrapper& solver_) : solver(solver_) {
    solver.add(this);
}

Propagator::Propagator(GlucoseWrapper& solver_, const Propagator& init) : solver(solver_) {
    solver.add(this);
}

}

/*
 *  Copyright (C) 2017  Mario Alviano (mario@alviano.net)
 *
 *  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 "Propagator.h"

#include "GlucoseWrapper.h"

namespace zuccherino {

Propagator::Propagator(GlucoseWrapper& solver_) : solver(solver_) {
    solver.add(this);
}

Propagator::Propagator(GlucoseWrapper& solver_, const Propagator& /*init*/) : solver(solver_) {
    solver.add(this);
}

}

Fix warning for nonused parameter.

Fix warning for nonused parameter.


// RUN: clang-cc %s -emit-llvm -o - -std=c++0x

class A {
public:
  virtual void foo();
};

static_assert (sizeof (A) == (sizeof(void *)), "vtable pointer layout");

// RUN: clang-cc -triple x86_64-apple-darwin -frtti=0 -std=c++0x -S %s -o %t-64.s &&
// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
// RUN: clang-cc -triple i386-apple-darwin -frtti=0 -std=c++0x -S %s -o %t-32.s &&
// RUN: FileCheck -check-prefix LP32 -input-file=%t-32.s %s &&
// RUN: true

class A {
public:
  virtual void foo1();
  virtual void foo2();
  A() { }
} *a;

static_assert (sizeof (A) == (sizeof(void *)), "vtable pointer layout");

int main() {
  A a;
}

// CHECK-LP64: __ZTV1A:
// CHECK-LP64: .space 8
// CHECK-LP64: .space 8
// CHECK-LP64: .quad __ZN1A4foo1Ev
// CHECK-LP64: .quad __ZN1A4foo2Ev

// CHECK-LP32: __ZTV1A:
// CHECK-LP32: .space 4
// CHECK-LP32: .space 4
// CHECK-LP32: .long __ZN1A4foo1Ev
// CHECK-LP32: .long __ZN1A4foo2Ev

Test cases for some recent work.

Test cases for some recent work.

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


/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#include "ComponentDescriptorProviderRegistry.h"

namespace facebook {
namespace react {

void ComponentDescriptorProviderRegistry::add(
    ComponentDescriptorProvider provider) const {
  std::unique_lock<better::shared_mutex> lock(mutex_);
  componentDescriptorProviders_.insert({provider.handle, provider});

  for (auto const &weakRegistry : componentDescriptorRegistries_) {
    auto registry = weakRegistry.lock();
    if (!registry) {
      continue;
    }

    registry->add(provider);
  }
}

void ComponentDescriptorProviderRegistry::remove(
    ComponentDescriptorProvider provider) const {
  std::unique_lock<better::shared_mutex> lock(mutex_);
  componentDescriptorProviders_.erase(provider.handle);

  for (auto const &weakRegistry : componentDescriptorRegistries_) {
    auto registry = weakRegistry.lock();
    if (!registry) {
      continue;
    }

    registry->remove(provider);
  }
}

ComponentDescriptorRegistry::Shared
ComponentDescriptorProviderRegistry::createComponentDescriptorRegistry(
    ComponentDescriptorParameters const &parameters) const {
  std::shared_lock<better::shared_mutex> lock(mutex_);

  auto registry =
      std::make_shared<ComponentDescriptorRegistry const>(parameters);

  for (auto const &pair : componentDescriptorProviders_) {
    registry->add(pair.second);
  }

  return registry;
}

} // namespace react
} // namespace facebook

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#include "ComponentDescriptorProviderRegistry.h"

namespace facebook {
namespace react {

void ComponentDescriptorProviderRegistry::add(
    ComponentDescriptorProvider provider) const {
  std::unique_lock<better::shared_mutex> lock(mutex_);
  componentDescriptorProviders_.insert({provider.handle, provider});

  for (auto const &weakRegistry : componentDescriptorRegistries_) {
    auto registry = weakRegistry.lock();
    if (!registry) {
      continue;
    }

    registry->add(provider);
  }
}

void ComponentDescriptorProviderRegistry::remove(
    ComponentDescriptorProvider provider) const {
  std::unique_lock<better::shared_mutex> lock(mutex_);
  componentDescriptorProviders_.erase(provider.handle);

  for (auto const &weakRegistry : componentDescriptorRegistries_) {
    auto registry = weakRegistry.lock();
    if (!registry) {
      continue;
    }

    registry->remove(provider);
  }
}

ComponentDescriptorRegistry::Shared
ComponentDescriptorProviderRegistry::createComponentDescriptorRegistry(
    ComponentDescriptorParameters const &parameters) const {
  std::shared_lock<better::shared_mutex> lock(mutex_);

  auto registry =
      std::make_shared<ComponentDescriptorRegistry const>(parameters);

  for (auto const &pair : componentDescriptorProviders_) {
    registry->add(pair.second);
  }

  componentDescriptorRegistries_.push_back(registry);

  return registry;
}

} // namespace react
} // namespace facebook

Fix creation of new ComponentDescriptorRegistry when switching surface

Summary:
# Problem:
I enabled Fabric for "Profile About", when I navigate to "Marketplace Home" from "Profile About", I get following warning "<Component> is not Fabric compatible yet". Even though the component has been migrated to Fabric and is getting registered. The component works if I navigate straight to "Marketplace Home".

{F172219008}

# How it was solved:

It turns out, there was a missing call that added newly created registry to `componentDescriptorRegistries_`.

Reviewed By: shergin

Differential Revision: D16542109

fbshipit-source-id: 22a315333cfff0895ce77e8439816f4e7bf34d35


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

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

#include "..\..\ToDoList_Dev\Interfaces\UITheme.h"
#include "..\..\ToDoList_Dev\Interfaces\IContentControl.h"

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

using namespace Abstractspoon::Tdl::PluginHelpers;

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

ContentControl::ParentNotify::ParentNotify(IntPtr hwndParent) : m_hwndParent(NULL), m_hwndFrom(NULL)
{
	m_hwndParent = static_cast<HWND>(hwndParent.ToPointer());
}

ContentControl::ParentNotify::ParentNotify(IntPtr hwndParent, IntPtr hwndFrom) : m_hwndParent(NULL), m_hwndFrom(NULL)
{
	m_hwndParent = static_cast<HWND>(hwndParent.ToPointer());
	m_hwndFrom = static_cast<HWND>(hwndFrom.ToPointer());
}

bool ContentControl::ParentNotify::NotifyChange()
{
	if (!IsWindow(m_hwndParent))
		return false;

	::SendMessage(m_hwndParent, WM_ICC_COMMENTSCHANGE, 0, (LPARAM)m_hwndFrom);
	return true;
}

bool ContentControl::ParentNotify::NotifyKillFocus()
{
	if (!IsWindow(m_hwndParent))
		return false;

	::SendMessage(m_hwndParent, WM_ICC_COMMENTSKILLFOCUS, 0, (LPARAM)m_hwndFrom);
	return true;
}

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

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

#include "..\..\ToDoList_Dev\Interfaces\UITheme.h"
#include "..\..\ToDoList_Dev\Interfaces\IContentControl.h"

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

using namespace Abstractspoon::Tdl::PluginHelpers;

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

ContentControl::ParentNotify::ParentNotify(IntPtr hwndParent) : m_hwndParent(NULL), m_hwndFrom(NULL)
{
	m_hwndParent = static_cast<HWND>(hwndParent.ToPointer());
}

ContentControl::ParentNotify::ParentNotify(IntPtr hwndParent, IntPtr hwndFrom) : m_hwndParent(NULL), m_hwndFrom(NULL)
{
	m_hwndParent = static_cast<HWND>(hwndParent.ToPointer());
	m_hwndFrom = static_cast<HWND>(hwndFrom.ToPointer());
}

bool ContentControl::ParentNotify::NotifyChange()
{
	if (!IsWindow(m_hwndParent))
		return false;

	::SendMessage(m_hwndParent, WM_ICC_CONTENTCHANGE, 0, (LPARAM)m_hwndFrom);
	return true;
}

bool ContentControl::ParentNotify::NotifyKillFocus()
{
	if (!IsWindow(m_hwndParent))
		return false;

	::SendMessage(m_hwndParent, WM_ICC_KILLFOCUS, 0, (LPARAM)m_hwndFrom);
	return true;
}

Fix change in message names

Fix change in message names


#include "HotkeyInput.h"

#include "../../3RVX/Logger.h"
#include "../Controls/Controls.h"
#include "KeyGrabber.h"

HotkeyInput::HotkeyInput(HWND parent) :
Dialog(parent, MAKEINTRESOURCE(IDD_HOTKEYPROMPT)) {

}

void HotkeyInput::Initialize() {
    _prompt = new Label(LBL_PROMPT, *this);
}

#include "HotkeyInput.h"

#include "../../3RVX/Logger.h"
#include "../Controls/Controls.h"
#include "KeyGrabber.h"

HotkeyInput::HotkeyInput(HWND parent) :
Dialog(parent, MAKEINTRESOURCE(IDD_HOTKEYPROMPT)) {

}

void HotkeyInput::Initialize() {
    _prompt = new Label(LBL_PROMPT, *this);
    KeyGrabber::Instance()->SetHwnd(DialogHandle());
    KeyGrabber::Instance()->Grab();
}

Set the dest hwnd and start grabbing keys during init


/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <sys/sysinfo.h>

#include "test/gtest_and_gmock.h"

namespace perfetto {

TEST(PerfettoDeviceFeatureTest, TestMaxCpusForAtraceChmod) {
  // Check that there are no more than 16 CPUs so that the assumption in the
  // atrace.rc for clearing CPU buffers is valid.
  ASSERT_LE(sysconf(_SC_NPROCESSORS_CONF), 16);
}

}  // namespace perfetto

/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <sys/sysinfo.h>

#include "test/gtest_and_gmock.h"

namespace perfetto {

TEST(PerfettoDeviceFeatureTest, TestMaxCpusForAtraceChmod) {
  // Check that there are no more than 24 CPUs so that the assumption in the
  // atrace.rc for clearing CPU buffers is valid.
  ASSERT_LE(sysconf(_SC_NPROCESSORS_CONF), 24);
}

}  // namespace perfetto

Increase core count for PerfettoDeviceFeatureTest am: 542f1ede9d

Original change: https://android-review.googlesource.com/c/platform/external/perfetto/+/1872395

Change-Id: I9e7d754c0ddc74f3750d94f8a89a71ddda760eed


//===- Support/FileUtilities.cpp - File System Utilities ------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements a family of utility functions which are useful for doing
// various things with files.
//
//===----------------------------------------------------------------------===//

#include "FDHandle.h"
#include <unistd.h>

using namespace llvm;

//===----------------------------------------------------------------------===//
// FDHandle class implementation
//

FDHandle::~FDHandle() throw() {
  if (FD != -1)
    ::close(FD);
}

FDHandle &FDHandle::operator=(int fd) throw() {
  if (FD != -1)
    ::close(FD);
  FD = fd;
  return *this;
}

//===- lib/Debugger/FDHandle.cpp - File Descriptor Handle -----------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements a class for ensuring that Unix file handles get closed.
//
//===----------------------------------------------------------------------===//

#include "FDHandle.h"
#include <unistd.h>

using namespace llvm;

//===----------------------------------------------------------------------===//
// FDHandle class implementation
//

FDHandle::~FDHandle() throw() {
  if (FD != -1)
    ::close(FD);
}

FDHandle &FDHandle::operator=(int fd) throw() {
  if (FD != -1)
    ::close(FD);
  FD = fd;
  return *this;
}

Correct the comments and file header.

Correct the comments and file header.

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


#include "caffe2/operators/accumulate_op.h"

namespace caffe2 {
namespace {
REGISTER_CPU_OPERATOR(Accumulate, AccumulateOp<float, CPUContext>);

OPERATOR_SCHEMA(Accumulate)
  .NumInputs(1)
  .NumOutputs(1)
  // TODO: add Shape inference function (bootcamp)
  .SetDoc(R"DOC(
Accumulate operator accumulates the input tensor to the output tensor. If the
output tensor already has the right size, we add to it; otherwise, we first
initialize the output tensor to all zeros, and then do accumulation. Any
further calls to the operator, given that no one else fiddles with the output
in the interim, will do simple accumulations.
Accumulation is done using Axpby operation as shown:
  Y = 1*X + gamma*Y
where X is the input tensor, Y is the output tensor and gamma is the multiplier
argument.
)DOC")
  .Arg("gamma", "(float, default 1.0) Accumulation multiplier")
  .Input(0, "input", "The input tensor that has to be accumulated to the "
         "output tensor. If the output size is not the same as input size, the "
         "output tensor is first reshaped and initialized to zero, and only "
         "then, accumulation is done.")
  .Output(0, "output", "Accumulated output tensor");

SHOULD_NOT_DO_GRADIENT(Accumulate);
}  // namespace
}  // namespace caffe2

#include "caffe2/operators/accumulate_op.h"

namespace caffe2 {
namespace {
REGISTER_CPU_OPERATOR(Accumulate, AccumulateOp<float, CPUContext>);

OPERATOR_SCHEMA(Accumulate)
  .NumInputs(1)
  .NumOutputs(1)
  .IdenticalTypeAndShape()
  .SetDoc(R"DOC(
Accumulate operator accumulates the input tensor to the output tensor. If the
output tensor already has the right size, we add to it; otherwise, we first
initialize the output tensor to all zeros, and then do accumulation. Any
further calls to the operator, given that no one else fiddles with the output
in the interim, will do simple accumulations.
Accumulation is done using Axpby operation as shown:
  Y = 1*X + gamma*Y
where X is the input tensor, Y is the output tensor and gamma is the multiplier
argument.
)DOC")
  .Arg("gamma", "(float, default 1.0) Accumulation multiplier")
  .Input(0, "input", "The input tensor that has to be accumulated to the "
         "output tensor. If the output size is not the same as input size, the "
         "output tensor is first reshaped and initialized to zero, and only "
         "then, accumulation is done.")
  .Output(0, "output", "Accumulated output tensor");

SHOULD_NOT_DO_GRADIENT(Accumulate);
}  // namespace
}  // namespace caffe2

Implement shape inference function for AccumulateOp

Summary: Implemented the sharp inference function for AccmulateOp. The output shape and type should be same as the input.

Differential Revision: D4518812

fbshipit-source-id: 11fc7ec4fad1fe3049c5a35d13c371627f9e3d11


#include "HelloWorld.h"

void HelloWorld::respond()
{
	out << "Content-type: text/html\r\n\r\n" << flush;
	out << "
hello, world
";
	dumpHash(tr("Get variables"), request.getData());
	dumpHash(tr("Server variables"), request.serverData());
}

void HelloWorld::dumpHash(const QString& label, const QHash<QString, QString>& data)
{
	// Print out server variables
	out << "
" << label << "
" << endl;

	out << "
" << endl;

	for(
		QHash<QString, QString>::ConstIterator it = data.constBegin();
		it != data.constEnd();
		++it
	)
	{
		out << "
" << it.key() << "	" << it.value() << "
" << endl;
	}

	out << "
" << endl;

}

#include "HelloWorld.h"

void HelloWorld::respond()
{
	out << "Content-type: text/html\r\n\r\n" << flush;
	out << "
hello, world
";
	dumpHash(tr("Get variables"), request.getData());
	dumpHash(tr("Post variables"), request.postData());
	dumpHash(tr("Server variables"), request.serverData());
}

void HelloWorld::dumpHash(const QString& label, const QHash<QString, QString>& data)
{
	// Print out server variables
	out << "
" << label << "
" << endl;

	out << "
" << endl;

	for(
		QHash<QString, QString>::ConstIterator it = data.constBegin();
		it != data.constEnd();
		++it
	)
	{
		out << "
" << it.key() << "	" << it.value() << "
" << endl;
	}

	out << "
" << endl;

}

Make helloworld example also dump post data


#include <test.hpp>

TEST_CASE("exceptions messages for pbf exception") {
    protozero::exception e;
    REQUIRE(std::string{e.what()} == std::string{"pbf exception"});
}

TEST_CASE("exceptions messages for varint too long") {
    protozero::varint_too_long_exception e;
    REQUIRE(std::string{e.what()} == std::string{"varint too long exception"});
}

TEST_CASE("exceptions messages for unknown pbf field type") {
    protozero::unknown_pbf_wire_type_exception e;
    REQUIRE(std::string{e.what()} == std::string{"unknown pbf field type exception"});
}

TEST_CASE("exceptions messages for end of buffer") {
    protozero::end_of_buffer_exception e;
    REQUIRE(std::string{e.what()} == std::string{"end of buffer exception"});
}

TEST_CASE("exceptions messages for invalid tag") {
    protozero::invalid_tag_exception e;
    REQUIRE(std::string{e.what()} == std::string{"invalid tag exception"});
}

TEST_CASE("exceptions messages for invalid length") {
    protozero::invalid_length_exception e;
    REQUIRE(std::string{e.what()} == std::string{"invalid length exception"});
}

Add some tests for new exceptions.

Add some tests for new exceptions.


#ifdef STAN_OPENCL

#include <stan/math/opencl/opencl.hpp>
#include <stan/math/opencl/kernel_cl.hpp>
#include <gtest/gtest.h>

using stan::math::matrix_cl;
using stan::math::opencl_kernels::in_buffer;
using stan::math::opencl_kernels::in_out_buffer;
using stan::math::opencl_kernels::internal::assign_events;
using stan::math::opencl_kernels::out_buffer;

TEST(assign_event, correct_vectors) {
  matrix_cl m;
  // pointers not set up to work yet; TBD if needed
  // matrix_cl *mp = &m;
  cl::Event e;
  assign_events<in_buffer>(e, m);
  EXPECT_EQ(m.in_events().size(), 1);
  EXPECT_EQ(m.out_events().size(), 0);

  assign_events<out_buffer>(e, m);
  EXPECT_EQ(m.in_events().size(), 1);
  EXPECT_EQ(m.out_events().size(), 1);

  assign_events<in_out_buffer>(e, m);
  EXPECT_EQ(m.in_events().size(), 2);
  EXPECT_EQ(m.out_events().size(), 2);
}
#endif

#ifdef STAN_OPENCL

#include <stan/math/opencl/opencl.hpp>
#include <stan/math/opencl/kernel_cl.hpp>
#include <gtest/gtest.h>

using stan::math::matrix_cl;
using stan::math::opencl_kernels::in_buffer;
using stan::math::opencl_kernels::in_out_buffer;
using stan::math::opencl_kernels::internal::assign_events;
using stan::math::opencl_kernels::out_buffer;

TEST(assign_event, correct_vectors) {
  matrix_cl m;
  // pointers not set up to work yet; TBD if needed
  // matrix_cl *mp = &m;
  cl::Event e;
  assign_events<in_buffer>(e, m);
  EXPECT_EQ(m.read_events().size(), 1);
  EXPECT_EQ(m.write_events().size(), 0);

  assign_events<out_buffer>(e, m);
  EXPECT_EQ(m.read_events().size(), 1);
  EXPECT_EQ(m.write_events().size(), 1);

  assign_events<in_out_buffer>(e, m);
  EXPECT_EQ(m.read_events().size(), 2);
  EXPECT_EQ(m.write_events().size(), 2);
}
#endif

Revert "Forgot to update test for assign_event"

This reverts commit 7256c1fbc6e3dfde24d49a73a93fb4011dd16934.


#include "thingspeakSender.h"

#include "ThingSpeak.h"
#define USE_WIFI101_SHIELD
#include "BridgeClient.h"
BridgeClient client;

void ThingspeakSender::init()
{
  ThingSpeak.begin(client);

  Serial.println("\nconnected to ThingSpeak!");
}

void ThingspeakSender::sendCounter(int counter)
{
  //send '1' to the IoT server on the channel
  ThingSpeak.writeField(channelNumber, 1, counter, writeAPIKey);
}

#include "thingspeakSender.h"

#include "ThingSpeak.h"
#define USE_WIFI101_SHIELD
#include "BridgeClient.h"
BridgeClient client;

void ThingspeakSender::init()
{
  ThingSpeak.begin(client);

  Serial.println("\nBottle-Opener is now connected to ThingSpeak!");
}

void ThingspeakSender::sendCounter(int counter)
{
  //send '1' to the IoT server on the channel
  ThingSpeak.writeField(channelNumber, 1, counter, writeAPIKey);
}

Extend log when connected to the IoT platform


#include "DirListMapModel.h"

#include <QtCore/QDebug>
#include <QtCore/QDir>

namespace web
{
namespace page
{
namespace model
{

DirListMapModel::DirListMapModel(const QString & dirPath, const QString & addressPath, QObject *parent) :
    AbstractListModel(parent)
{
    generateAllModels(dirPath, addressPath);
}

void DirListMapModel::load()
{
    AbstractListModel * model = m_listModels.value(m_loadingModelsName);
    model->load();
}

void DirListMapModel::unload()
{
    AbstractListModel * model = m_listModels.value(m_loadingModelsName);
    model->unload();
}

QList<AbstractModel *> DirListMapModel::models()
{
    AbstractListModel * model = m_listModels.value(m_loadingModelsName);
    return model->models();
}

void DirListMapModel::generateAllModels(const QString & dirPath, const QString & addressPath)
{
    QDir dir(dirPath);
    dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
    QStringList allFiles = dir.entryList();
    for ( QString dir : allFiles ) {
            QString entry = addressPath + QDir::separator() + dir + QDir::separator();
            QString path = dirPath + dir;
            AbstractListModel * model = new DirListModel(path, entry);
            m_listModels.insert(entry, model);
    }
}

}
}
}

#include "DirListMapModel.h"

#include <QtCore/QDebug>
#include <QtCore/QDir>

namespace web
{
namespace page
{
namespace model
{

DirListMapModel::DirListMapModel(const QString & dirPath, const QString & addressPath, QObject *parent) :
    AbstractListModel(parent)
{
    generateAllModels(dirPath, addressPath);
}

void DirListMapModel::load()
{
    AbstractListModel * model = m_listModels.value(m_loadingModelsName);
    if (model) model->load();
}

void DirListMapModel::unload()
{
    AbstractListModel * model = m_listModels.value(m_loadingModelsName);
    if (model) model->unload();
}

QList<AbstractModel *> DirListMapModel::models()
{
    AbstractListModel * model = m_listModels.value(m_loadingModelsName);
    return (model) ? model->models() : QList<AbstractModel *>();
}

void DirListMapModel::generateAllModels(const QString & dirPath, const QString & addressPath)
{
    QDir dir(dirPath);
    dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
    QStringList allFiles = dir.entryList();
    for ( QString dir : allFiles ) {
            QString entry = addressPath + QDir::separator() + dir + QDir::separator();
            QString path = dirPath + dir;
            AbstractListModel * model = new DirListModel(path, entry);
            m_listModels.insert(entry, model);
    }
}

}
}
}

Check if there is a valid model

Check if there is a valid model


#include "Game.h"
#include "SFML/Graphics.hpp"
#include "SFML/Window.hpp"

void Game::start() {
    if (s_game_state != Uninitialized) {
        return;
    }

    s_main_window.create(sf::VideoMode(1024, 768, 32), "Pang!");
    s_game_state = Game::Playing;

    while(!is_exiting()) {
        game_loop();
    }

    s_main_window.close();
}

bool Game::is_exiting() {
    if (s_game_state == Game::Exiting) {
        return true;
    } else {
        return false;
    }
}

void Game::game_loop() {

}

Game::GameState Game::s_game_state = Uninitialized;
sf::RenderWindow Game::s_main_window;

#include "Game.h"
#include "SFML/Graphics.hpp"
#include "SFML/Window.hpp"

void Game::start() {
    if (s_game_state != Uninitialized) {
        return;
    }

    s_main_window.create(sf::VideoMode(1024, 768, 32), "Pang!");
    s_game_state = Game::Playing;

    while(!is_exiting()) {
        game_loop();
    }

    s_main_window.close();
}

bool Game::is_exiting() {
    if (s_game_state == Game::Exiting) {
        return true;
    } else {
        return false;
    }
}

void Game::game_loop() {
    sf::Event currentEvent;
    while(s_main_window.pollEvent(currentEvent)) {
        switch(s_game_state) {
            case Game::Playing:
                {
                    s_main_window.clear(sf::Color(255, 0, 0));
                    s_main_window.display();
                }

                if(currentEvent.type == sf::Event::Closed) {
                    s_game_state = Game::Exiting;
                }
                break;
        }
    }

}

Game::GameState Game::s_game_state = Uninitialized;
sf::RenderWindow Game::s_main_window;

Add game loop - when the program is run, the screen is red


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

#include "chrome/browser/prerender/prerender_config.h"

namespace prerender {

Config::Config() : max_bytes(150 * 1024 * 1024),
                   max_link_concurrency(1),
                   max_link_concurrency_per_launcher(1),
                   rate_limit_enabled(true),
                   max_wait_to_launch(base::TimeDelta::FromMinutes(4)),
                   time_to_live(base::TimeDelta::FromMinutes(5)),
                   abandon_time_to_live(base::TimeDelta::FromSeconds(30)),
                   default_tab_bounds(640, 480),
                   is_overriding_user_agent(false) {
}

Config::~Config() { }

}  // namespace prerender

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

#include "chrome/browser/prerender/prerender_config.h"

namespace prerender {

Config::Config() : max_bytes(150 * 1024 * 1024),
                   max_link_concurrency(1),
                   max_link_concurrency_per_launcher(1),
                   rate_limit_enabled(true),
                   max_wait_to_launch(base::TimeDelta::FromMinutes(4)),
                   time_to_live(base::TimeDelta::FromMinutes(5)),
                   abandon_time_to_live(base::TimeDelta::FromSeconds(3)),
                   default_tab_bounds(640, 480),
                   is_overriding_user_agent(false) {
}

Config::~Config() { }

}  // namespace prerender

Drop prerender abandon timeout to 3 seconds.

30 seconds is too long to keep a missed prerender around for. Per
Prerender.AbandonTimeUntilUsed, prerenders swap in well under 3 seconds of them
being abandoned.

BUG=356290

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

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


#include "Genes/Draw_Value_Gene.h"

#include <string>
#include <map>

#include "Game/Color.h"
#include "Utility/Random.h"

class Board;

std::string Draw_Value_Gene::name() const noexcept
{
    return "Draw Value Gene";
}

double Draw_Value_Gene::draw_value() const noexcept
{
    return value_of_draw_in_centipawns;
}

double Draw_Value_Gene::score_board(const Board&, Piece_Color, size_t, double) const noexcept
{
    return 0.0;
}

void Draw_Value_Gene::gene_specific_mutation() noexcept
{
    value_of_draw_in_centipawns += Random::random_laplace(1.0);
}

void Draw_Value_Gene::adjust_properties(std::map<std::string, double>& properties) const noexcept
{
    properties.erase("Priority - Opening");
    properties.erase("Priority - Endgame");
    properties["Draw Value"] = value_of_draw_in_centipawns/100.0;
}

void Draw_Value_Gene::load_gene_properties(const std::map<std::string, double>& properties)
{
    value_of_draw_in_centipawns = properties.at("Draw Value")*100.;
}

#include "Genes/Draw_Value_Gene.h"

#include <string>
#include <map>

#include "Game/Color.h"
#include "Utility/Random.h"

class Board;

std::string Draw_Value_Gene::name() const noexcept
{
    return "Draw Value Gene";
}

double Draw_Value_Gene::draw_value() const noexcept
{
    return value_of_draw_in_centipawns;
}

double Draw_Value_Gene::score_board(const Board&, Piece_Color, size_t, double) const noexcept
{
    return 0.0;
}

void Draw_Value_Gene::gene_specific_mutation() noexcept
{
    value_of_draw_in_centipawns += Random::random_laplace(3.0);
}

void Draw_Value_Gene::adjust_properties(std::map<std::string, double>& properties) const noexcept
{
    properties.erase("Priority - Opening");
    properties.erase("Priority - Endgame");
    properties["Draw Value"] = value_of_draw_in_centipawns/100.0;
}

void Draw_Value_Gene::load_gene_properties(const std::map<std::string, double>& properties)
{
    value_of_draw_in_centipawns = properties.at("Draw Value")*100.;
}

Increase draw value mutation rate

Increase draw value mutation rate


#include "tutorial_storage_facility.h"

namespace tutorial_storage {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Tutorial_storageFacility::Tutorial_storageFacility(cyclus::Context* ctx) : cyclus::Facility(ctx) {}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
std::string Tutorial_storageFacility::str() {
  return Facility::str();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Tutorial_storageFacility::Tick() {}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Tutorial_storageFacility::Tock() {}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
extern "C" cyclus::Agent* ConstructTutorial_storageFacility(cyclus::Context* ctx) {
  return new Tutorial_storageFacility(ctx);
}

}  // namespace tutorial_storage

#include "tutorial_storage_facility.h"

namespace tutorial_storage {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Tutorial_storageFacility::Tutorial_storageFacility(cyclus::Context* ctx) : cyclus::Facility(ctx) {}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
std::string Tutorial_storageFacility::str() {
  return Facility::str();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Tutorial_storageFacility::Tick() {

  LOG(cyclus::LEV_INFO1,"tutorial_storage") << "Hello...";
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Tutorial_storageFacility::Tock() {

  LOG(cyclus::LEV_INFO1,"tutorial_storage") << "World!";
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
extern "C" cyclus::Agent* ConstructTutorial_storageFacility(cyclus::Context* ctx) {
  return new Tutorial_storageFacility(ctx);
}

}  // namespace tutorial_storage

Add LOGGER messages as hello world to Tick and Tock.


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

#include "SkTypes.h"

static const size_t kBufferSize = 2048;

#include <stdarg.h>
#include <stdio.h>
#include <windows.h>

void SkDebugf(const char format[], ...) {
    char    buffer[kBufferSize + 1];
    va_list args;

    va_start(args, format);
    vprintf(format, args);
    va_end(args);
    // When we crash on Windows we often are missing a lot of prints. Since we don't really care
    // about SkDebugf performance we flush after every print.
//    fflush(stdout);

    va_start(args, format);
    vsnprintf(buffer, kBufferSize, format, args);
    va_end(args);

    OutputDebugStringA(buffer);
}

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

#include "SkTypes.h"

static const size_t kBufferSize = 2048;

#include <stdarg.h>
#include <stdio.h>
#include <windows.h>

void SkDebugf(const char format[], ...) {
    char    buffer[kBufferSize + 1];
    va_list args;

    va_start(args, format);
    vfprintf(stderr, format, args);
    va_end(args);
    fflush(stderr);

    va_start(args, format);
    vsnprintf(buffer, kBufferSize, format, args);
    va_end(args);

    OutputDebugStringA(buffer);
}

Send SkDebugf through stderr and flush on Windows too.

This makes it consistent with Linux/Mac.  There, stderr is not buffered, so the flush is not needed / implicit.

BUG=skia:

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


/*
* This file is part of ATLAS. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this distribution.
* (Also avialable at http://www.apache.org/licenses/LICENSE-2.0.txt)
* You may not use this file except in compliance with the License.
*/
#include <iostream>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include "AssimpImporter.hpp"

namespace AssimpWorker {

	AssimpImporter::AssimpImporter() :
		importer()
	{
		return;
	}

	AssimpImporter::~AssimpImporter(){
		return;
	}

	const aiScene* AssimpImporter::importSceneFromFile(std::string fileName, Log& log){
		importer.SetPropertyBool(AI_CONFIG_PP_FD_REMOVE, true); //remove degenerate polys
		importer.SetPropertyBool(AI_CONFIG_IMPORT_NO_SKELETON_MESHES, true); //do not import skeletons
		importer.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT); //Drop all primitives that aren't triangles
		const aiScene* scene = importer.ReadFile(fileName, aiProcessPreset_TargetRealtime_Quality);
		if (!scene) {
			log.error("Scene not imported: "+fileName);
		}
		log.error(importer.GetErrorString());
		return scene;
	}

}

/*
* This file is part of ATLAS. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this distribution.
* (Also avialable at http://www.apache.org/licenses/LICENSE-2.0.txt)
* You may not use this file except in compliance with the License.
*/
#include <iostream>
#include <assimp/postprocess.h>
#include <assimp/scene.h>
#include "AssimpImporter.hpp"

namespace AssimpWorker {

	AssimpImporter::AssimpImporter() :
		importer()
	{
		return;
	}

	AssimpImporter::~AssimpImporter(){
		return;
	}

	const aiScene* AssimpImporter::importSceneFromFile(std::string fileName, Log& log){
		importer.SetPropertyBool(AI_CONFIG_PP_FD_REMOVE, true); //remove degenerate polys
		importer.SetPropertyBool(AI_CONFIG_IMPORT_NO_SKELETON_MESHES, true); //do not import skeletons
		importer.SetPropertyBool(AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION, true);
		importer.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT); //Drop all primitives that aren't triangles
		const aiScene* scene = importer.ReadFile(fileName, aiProcessPreset_TargetRealtime_Quality);
		if (!scene) {
			log.error("Scene not imported: "+fileName);
		}
		log.error(importer.GetErrorString());
		return scene;
	}

}

Set assimp flag to ignore up direction in collada files


/**
 * This file is part of the CernVM File System.
 */

#include "lease_path_util.h"

namespace receiver {

bool IsPathInLease(const PathString& lease, const PathString& path) {
  // If lease is "", any path falls within item
  if (!strcmp(lease.c_str(), "")) {
    return true;
  }

  // Is the lease string is the prefix of the path string and the next
  // character of the path string is a "/".
  if (path.StartsWith(lease) && path.GetChars()[lease.GetLength()] == '/') {
    return true;
  }

  // The lease is a prefix of the path and the last char of the lease is a "/"
  if (path.StartsWith(lease) &&
      lease.GetChars()[lease.GetLength() - 1] == '/') {
    return true;
  }

  // If the path string is exactly the lease path return true (allow the
  // creation of the leased directory during the lease itself)
  if (lease == path) {
    return true;
  }

  return false;
}

}  // namespace receiver

/**
 * This file is part of the CernVM File System.
 */

#include "lease_path_util.h"

namespace receiver {

bool IsPathInLease(const PathString& lease, const PathString& path) {

  // If lease is "", then any path is a subpath
  if (lease.GetLength() == 0) {
    return true;
  }

  // If the lease string is the prefix of the path string and either
  // the strings are identical or the separator character is a "/",
  // then the path is a subpath
  if (path.StartsWith(lease) &&
      ((path.GetLength() == lease.GetLength()) ||
       (path.GetChars()[lease.GetLength()] == '/') ||
       (path.GetChars()[lease.GetLength() - 1] == '/'))) {
    return true;
  }

  return false;
}

}  // namespace receiver

Remove redundant string comparisons in IsPathInLease()

Signed-off-by: Michael Brown <2a36638259b3302298d1519e970c48ecd5dbd43e@fensystems.co.uk>


// Copyright (c) 2020 The Orbit 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 "ProcessServiceImpl.h"

#include <memory>
#include <string>

using grpc::ServerContext;
using grpc::Status;

Status ProcessServiceImpl::GetProcessList(ServerContext*,
                                          const GetProcessListRequest*,
                                          GetProcessListResponse* response) {
  process_list_.Refresh();
  for (const std::shared_ptr<Process> process : process_list_.GetProcesses()) {
    ProcessInfo* process_info = response->add_processes();
    process_info->set_pid(process->GetID());
    process_info->set_name(process->GetName());
    process_info->set_cpu_usage(process->GetCpuUsage());
    process_info->set_full_path(process->GetFullPath());
    process_info->set_command_line(process->GetCmdLine());
    process_info->set_is_64_bit(process->GetIs64Bit());
  }

  return Status::OK;
}

// Copyright (c) 2020 The Orbit 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 "ProcessServiceImpl.h"

#include <memory>
#include <string>

using grpc::ServerContext;
using grpc::Status;

Status ProcessServiceImpl::GetProcessList(ServerContext*,
                                          const GetProcessListRequest*,
                                          GetProcessListResponse* response) {
  process_list_.Refresh();
  process_list_.UpdateCpuTimes();
  for (const std::shared_ptr<Process> process : process_list_.GetProcesses()) {
    ProcessInfo* process_info = response->add_processes();
    process_info->set_pid(process->GetID());
    process_info->set_name(process->GetName());
    process_info->set_cpu_usage(process->GetCpuUsage());
    process_info->set_full_path(process->GetFullPath());
    process_info->set_command_line(process->GetCmdLine());
    process_info->set_is_64_bit(process->GetIs64Bit());
  }

  return Status::OK;
}

Update cpu times when refreshing the process list.

Bug: http://b/156339188
Test: start client and check that cpu-times are not all 0


#include <iostream>

#include "fixed_point.hpp"

int main() {
    auto g1 = [](double x) -> double {
        return (x * x + 2) / 3;
    };

    auto g2 = [](double x) -> double {
        return std::sqrt(3 * x - 2);
    };

    auto g3 = [](double x) -> double {
        return 3 - (2 / x);
    };

    auto g4 = [](double x) -> double {
        return (x * x  - 2) / (2 * x - 3);
    };

    std::vector<std::function<double(double)>> vec {g1, g2, g3, g4};
    std::vector<std::string> filenames {"g1.txt", "g2.txt", "g3.txt", "g4.txt"};
    std::vector<std::string> funcnames {"g1", "g2", "g3", "g4"};
    const double x0 = 0;
    const double abstol = 5e-7;

    for (auto i = 0; i < vec.size(); ++i) {
        fp::test_fixed_point(vec[i], x0, abstol, funcnames[i], filenames[i]);
    }
}

#include <iostream>

#include "fixed_point.hpp"

int main() {
    auto g1 = [](double x) -> double {
        return (x * x + 2) / 3;
    };

    // will result in NaNs because the value under the square root
    // will become negative at some point.
    auto g2 = [](double x) -> double {
        return std::sqrt(3 * x - 2);
    };

    auto g3 = [](double x) -> double {
        return 3 - (2 / x);
    };

    auto g4 = [](double x) -> double {
        return (x * x  - 2) / (2 * x - 3);
    };

    std::vector<std::function<double(double)>> vec {g1, g2, g3, g4};
    std::vector<std::string> filenames {"g1.txt", "g2.txt", "g3.txt", "g4.txt"};
    std::vector<std::string> funcnames {"g1", "g2", "g3", "g4"};
    const double x0 = 0;
    const double abstol = 5e-7;

    for (auto i = 0; i < vec.size(); ++i) {
        fp::test_fixed_point(vec[i], x0, abstol, funcnames[i], filenames[i]);
    }
}

Comment as to why the code for g2 actually doesn’t work yet.


/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) University College London (UCL).
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "CommandLineModulesViewControls.h"
#include <QIcon>
#include <QSize>
#include <QHBoxLayout>

//-----------------------------------------------------------------------------
CommandLineModulesViewControls::CommandLineModulesViewControls(QWidget *parent)
{
  this->setupUi(parent);
  this->m_RunButton->setIcon(QIcon(":/CommandLineModulesResources/run.png"));
  this->m_RestoreDefaults->setIcon(QIcon(":/CommandLineModulesResources/undo.png"));
}

//-----------------------------------------------------------------------------
CommandLineModulesViewControls::~CommandLineModulesViewControls()
{

}

/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) University College London (UCL).
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

===================================================================*/

#include "CommandLineModulesViewControls.h"
#include <QIcon>
#include <QSize>
#include <QHBoxLayout>

//-----------------------------------------------------------------------------
CommandLineModulesViewControls::CommandLineModulesViewControls(QWidget *parent)
{
  this->setupUi(parent);
  this->m_ChooseLabel->setVisible(false);
  this->m_ComboBox->setToolTip("Choose a command line module");
  this->m_RunButton->setIcon(QIcon(":/CommandLineModulesResources/run.png"));
  this->m_RestoreDefaults->setIcon(QIcon(":/CommandLineModulesResources/undo.png"));
}

//-----------------------------------------------------------------------------
CommandLineModulesViewControls::~CommandLineModulesViewControls()
{

}

Improve minimum width: Remove choose label, and use tool tip instead


/* mbed Microcontroller Library
 * Copyright (c) 2013-2014 ARM Limited
 *
 * 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 "mbed.h"
#include "minar/minar.h"
#include "test_env.h"

void runTest(){
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(detect_auto);
    MBED_HOSTTEST_DESCRIPTION(Simple detect test);
    MBED_HOSTTEST_START("DTCT_1");

    notify_start();
    printf("MBED: Target '%s'\r\n", TEST_SUITE_TARGET_NAME);
    printf("MBED: Test ID '%s'\r\n", TEST_SUITE_TEST_ID);
    printf("MBED: UUID '%s'\r\n", TEST_SUITE_UUID);
    MBED_HOSTTEST_RESULT(true);
}

void app_start(int, char*[]) {
    minar::Scheduler::postCallback(&runTest);
}

/* mbed Microcontroller Library
 * Copyright (c) 2013-2014 ARM Limited
 *
 * 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 "mbed.h"
#include "minar/minar.h"
#include "test_env.h"

void runTest(){
    MBED_HOSTTEST_TIMEOUT(10);
    MBED_HOSTTEST_SELECT(detect_auto);
    MBED_HOSTTEST_DESCRIPTION(Simple detect test);
    MBED_HOSTTEST_START("DTCT_1");

    printf("MBED: Target '%s'\r\n", TEST_SUITE_TARGET_NAME);
    printf("MBED: Test ID '%s'\r\n", TEST_SUITE_TEST_ID);
    printf("MBED: UUID '%s'\r\n", TEST_SUITE_UUID);
    MBED_HOSTTEST_RESULT(true);
}

void app_start(int, char*[]) {
    minar::Scheduler::postCallback(&runTest);
}

Test - fix detect test - remove notify function call


#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>

#include "world.hpp"

int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    app.setApplicationName("Headway");

#ifdef Q_OS_WINDOWS
    QQuickStyle::setStyle("Universal");
#else
    QQuickStyle::setStyle("Basic");
#endif

    QQmlApplicationEngine engine;
    qmlRegisterType<Headway::World>("Headway", 4, 1, "World");
    engine.load(QUrl(QStringLiteral("qrc:/MainWindow.qml")));

    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}

#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>

#include "world.hpp"

int main(int argc, char** argv)
{
    QApplication app(argc, argv);
    app.setApplicationName("Headway");

#ifdef Q_OS_WINDOWS
    QQuickStyle::setStyle("Universal");
#endif

    QQmlApplicationEngine engine;
    qmlRegisterType<Headway::World>("Headway", 4, 1, "World");
    engine.load(QUrl(QStringLiteral("qrc:/MainWindow.qml")));

    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}

Use Default style on non-Windows

Use Default style on non-Windows


#include <iostream>

using namespace std;

int main()
{
	cout << "Hello world!" << endl;
}

#include <iostream>
#include <ncurses.h>

using namespace std;

int main()
{
	cout << "Hello world!" << endl;
}

Add an include to trigger Travis

Add an include to trigger Travis


#include "models/bucket.h"
#include "views/session_view.h"

SessionView::SessionView(Session* session, QWidget* parent)
	: QWidget(parent),
	  m_session(session)
{
	m_hostFileSystem = new QFileSystemModel(this);
	m_hostFileSystem->setRootPath(QDir::rootPath());

	m_hostBrowser = new QTreeView;
	m_hostBrowser->setModel(m_hostFileSystem);
	m_hostBrowser->setRootIndex(m_hostFileSystem->index(QDir::rootPath()));

	m_remoteBrowser = new QTreeView;

	m_splitter = new QSplitter;
	m_splitter->addWidget(m_hostBrowser);
	m_splitter->addWidget(m_remoteBrowser);

	m_topLayout = new QVBoxLayout(this);
	m_topLayout->addWidget(m_splitter);

	setLayout(m_topLayout);

	m_client = new Client(m_session->GetHost(),
			      m_session->GetPort(),
			      m_session->GetAccessId(),
			      m_session->GetSecretKey());

	ds3_get_service_response* response = m_client->GetService();
	Bucket* bucket = new Bucket(response);
	m_remoteBrowser->setModel(bucket);
}

SessionView::~SessionView()
{
	delete m_client;
}

#include "models/bucket.h"
#include "views/session_view.h"

SessionView::SessionView(Session* session, QWidget* parent)
	: QWidget(parent),
	  m_session(session)
{
	m_hostFileSystem = new QFileSystemModel(this);
	m_hostFileSystem->setRootPath(QDir::rootPath());

	m_hostBrowser = new QTreeView;
	m_hostBrowser->setModel(m_hostFileSystem);
	m_hostBrowser->setRootIndex(m_hostFileSystem->index(QDir::rootPath()));
	// Remove the focus rectangle around the tree view on OSX.
	m_hostBrowser->setAttribute(Qt::WA_MacShowFocusRect, 0);

	m_remoteBrowser = new QTreeView;
	// Remove the focus rectangle around the tree view on OSX.
	m_remoteBrowser->setAttribute(Qt::WA_MacShowFocusRect, 0);

	m_splitter = new QSplitter;
	m_splitter->addWidget(m_hostBrowser);
	m_splitter->addWidget(m_remoteBrowser);

	m_topLayout = new QVBoxLayout(this);
	m_topLayout->addWidget(m_splitter);

	setLayout(m_topLayout);

	m_client = new Client(m_session->GetHost(),
			      m_session->GetPort(),
			      m_session->GetAccessId(),
			      m_session->GetSecretKey());

	ds3_get_service_response* response = m_client->GetService();
	Bucket* bucket = new Bucket(response);
	m_remoteBrowser->setModel(bucket);
}

SessionView::~SessionView()
{
	delete m_client;
}

Remove the focus rectangles that are rendered around the host/remote tree view widgets on OSX. Windows doesn't render this same focus rectangle so no change is necessary there.


// Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#include "platform/globals.h"
#if defined(TARGET_OS_FUCHSIA)

#include "vm/native_symbol.h"

#include <dlfcn.h>  // NOLINT

namespace dart {

void NativeSymbolResolver::InitOnce() {
}

void NativeSymbolResolver::ShutdownOnce() {
}

char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc, uintptr_t* start) {
  Dl_info info;
  int r = dladdr(reinterpret_cast<void*>(pc), &info);
  if (r == 0) {
    return NULL;
  }
  if (info.dli_sname == NULL) {
    return NULL;
  }
  if (start != NULL) {
    *start = reinterpret_cast<uintptr_t>(info.dli_saddr);
  }
  return strdup(info.dli_sname);
}

void NativeSymbolResolver::FreeSymbolName(char* name) {
  free(name);
}

}  // namespace dart

#endif  // defined(TARGET_OS_FUCHSIA)

// Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

#include "vm/globals.h"
#if defined(TARGET_OS_FUCHSIA)

#include "platform/memory_sanitizer.h"
#include "vm/native_symbol.h"

#include <cxxabi.h>  // NOLINT
#include <dlfcn.h>  // NOLINT

namespace dart {

void NativeSymbolResolver::InitOnce() {
}

void NativeSymbolResolver::ShutdownOnce() {
}

char* NativeSymbolResolver::LookupSymbolName(uintptr_t pc, uintptr_t* start) {
  Dl_info info;
  int r = dladdr(reinterpret_cast<void*>(pc), &info);
  if (r == 0) {
    return NULL;
  }
  if (info.dli_sname == NULL) {
    return NULL;
  }
  if (start != NULL) {
    *start = reinterpret_cast<uintptr_t>(info.dli_saddr);
  }
  int status = 0;
  size_t len = 0;
  char* demangled = abi::__cxa_demangle(info.dli_sname, NULL, &len, &status);
  MSAN_UNPOISON(demangled, len);
  if (status == 0) {
    return demangled;
  }
  return strdup(info.dli_sname);
}

void NativeSymbolResolver::FreeSymbolName(char* name) {
  free(name);
}

}  // namespace dart

#endif  // defined(TARGET_OS_FUCHSIA)

Fuchsia: Add C++ demangle to the native symbol resolver

R=johnmccutchan@google.com

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


/*
 * Justin's Awesome Game Engine
 * or *
 * Just Another Game Engine
 *
 * Copyright 2016 Justin White
 *
 * See included LICENSE file for distribution and reuse.
*/

#include <Engine.hpp>

static std::unique_ptr<Engine> theGame;

int success(const std::string& msg);
int fail(const std::string& msg);

int main(const int argc, const char** argv) {
    std::cout << "Start" << std::endl;
    theGame = std::make_unique<Engine>(argc, argv);
    if (not theGame->ready()) {
        return fail("Could not initialize Engine, quitting.");
    }
    if (not theGame->run()) {
        return fail("Error running Engine, quitting.");
    }
    return success("Done");
}

int success(const std::string& msg) {
    theGame.release();
    std::cout << msg << std::endl;
    return EXIT_SUCCESS;
}

int fail(const std::string& msg) {
    theGame.release();
    std::cerr << msg << std::endl;
    return EXIT_FAILURE;
}

/*
 * Justin's Awesome Game Engine
 * or *
 * Just Another Game Engine
 *
 * Copyright 2016 Justin White
 *
 * See included LICENSE file for distribution and reuse.
*/

#include <Engine.hpp>

int done(std::unique_ptr<Engine> theGame, int exitCode, const std::string& msg = "Done");

int main(const int argc, const char** argv) {
    std::cout << "Start" << std::endl;
    auto theGame = std::make_unique<Engine>(argc, argv);
    if (not theGame->ready()) {
        return done(std::move(theGame), EXIT_FAILURE, "Could not initialize Engine, quitting.");
    }
    if (not theGame->run()) {
        return done(std::move(theGame), EXIT_FAILURE, "Error running Engine, quitting.");
    }
    return done(std::move(theGame), EXIT_SUCCESS);
}

int done(std::unique_ptr<Engine> theGame, int exitCode, const std::string& msg) {
    // shutdown the Engine
    theGame.release();
    std::string fullMsg;
    if (exitCode == EXIT_SUCCESS) {
        fullMsg = "Success: " + msg;
    } else { //EXIT_FAILURE
        fullMsg = "Error: " + msg;
    }
    std::cout << fullMsg << std::endl;
    return exitCode;
}

Consolidate main() helpers a bit.

Consolidate main() helpers a bit.


// Copyright (c) 2014 eeGeo. All rights reserved.
#import <EegeoWorld.h>
#include "TrafficCongestionExample.h"

namespace Examples
{
    TrafficCongestionExample::TrafficCongestionExample(
            Eegeo::TrafficCongestion::ITrafficCongestionService& trafficCongestionService,
            Eegeo::EegeoWorld& world) :
    m_trafficCongestionService(trafficCongestionService),
    m_world(world),
    m_hasCalled(false)
    {

    }

    void TrafficCongestionExample::Update(float dt)
    {
        if(!m_hasCalled && !m_world.Initialising())
        {
            m_hasCalled = true;

            bool success = m_trafficCongestionService.TrySetCongestionFor(
                    Eegeo::Streaming::MortonKey::CreateFromString("01131232132001"),
                    0,
                    Eegeo::TrafficCongestion::CongestionLevel::Heavy);

            Eegeo_ASSERT(success, "should've worked");
        }
    }
}

// Copyright (c) 2014 eeGeo. All rights reserved.
#import <EegeoWorld.h>
#include "TrafficCongestionExample.h"

namespace Examples
{
    TrafficCongestionExample::TrafficCongestionExample(
            Eegeo::TrafficCongestion::ITrafficCongestionService& trafficCongestionService,
            Eegeo::EegeoWorld& world) :
    m_trafficCongestionService(trafficCongestionService),
    m_world(world),
    m_hasCalled(false)
    {

    }

    void TrafficCongestionExample::Update(float dt)
    {
        if(!m_hasCalled && !m_world.Initialising())
        {
            m_hasCalled = true;

            const int roadId = 0;

            Eegeo::Streaming::MortonKey key = Eegeo::Streaming::MortonKey::CreateFromString("01131232132001");

            bool success = m_trafficCongestionService.TrySetCongestionFor(
                    key,
                    roadId,
                    Eegeo::TrafficCongestion::CongestionLevel::Heavy);

            Eegeo_TTY("%s congestion level on road id %d for morton key %s\n",
                    success ? "Successfully set" : "Failed to set",
                    roadId,
                    key.ToString().c_str());
        }
    }
}

Update example using a TTY instead of assert. Buddy: Malc


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

#include "sky/engine/tonic/dart_error.h"

#include "base/logging.h"

namespace blink {

namespace DartError {

const char kInvalidArgument[] = "Invalid argument.";

}  // namespace DartError

bool LogIfError(Dart_Handle handle) {
  if (Dart_IsError(handle)) {
    // Only unhandled exceptions have stacktraces.
    if (!Dart_ErrorHasException(handle)) {
      LOG(ERROR) << Dart_GetError(handle);
      return true;
    }

    Dart_Handle stacktrace = Dart_ErrorGetStacktrace(handle);
    const char* stacktrace_cstr = "";
    Dart_StringToCString(Dart_ToString(stacktrace), &stacktrace_cstr);
    LOG(ERROR) << "Unhandled exception:";
    LOG(ERROR) << stacktrace_cstr;
    return true;
  }
  return false;
}

}  // namespace blink

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

#include "sky/engine/tonic/dart_error.h"

#include "base/logging.h"

namespace blink {
namespace DartError {
const char kInvalidArgument[] = "Invalid argument.";
}  // namespace DartError

bool LogIfError(Dart_Handle handle) {
  if (Dart_IsError(handle)) {
    LOG(ERROR) << Dart_GetError(handle);
    return true;
  }
  return false;
}

}  // namespace blink

Switch to the other stack trace printer

Switch to the other stack trace printer


#include "variant/digital_platform.hpp"

#include "hal.h"

DigitalPlatform::DigitalPlatform() {
  palSetPadMode(GPIOA, 4, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOC, 4, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOC, 5, PAL_MODE_OUTPUT_PUSHPULL);

  palClearPad(GPIOA, 4);
  palClearPad(GPIOA, 5);
  palClearPad(GPIOC, 4);
  palClearPad(GPIOC, 5);
}

void DigitalPlatform::set(std::uint8_t ch, bool on) {
  switch (ch) {
  case 0:
    palWritePad(GPIOA, 4, on);
    break;
  case 1:
    palWritePad(GPIOA, 5, on);
    break;
  case 2:
    palWritePad(GPIOC, 4, on);
    break;
  case 3:
    palWritePad(GPIOC, 5, on);
    break;
  default:
    break;
  }
}

#include "variant/digital_platform.hpp"

#include "hal.h"

DigitalPlatform::DigitalPlatform() {
  palSetPadMode(GPIOA, 4, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOC, 4, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOC, 5, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOA, 12, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOA, 15, PAL_MODE_OUTPUT_PUSHPULL);
  palSetPadMode(GPIOB, 2, PAL_MODE_OUTPUT_PUSHPULL);

  palClearPad(GPIOA, 4);
  palClearPad(GPIOA, 5);
  palClearPad(GPIOC, 4);
  palClearPad(GPIOC, 5);
  palClearPad(GPIOA, 12);
  palClearPad(GPIOA, 15);
  palClearPad(GPIOB, 2);
}

void DigitalPlatform::set(std::uint8_t ch, bool on) {
  switch (ch) {
    case 0: palWritePad(GPIOA, 4, on); break;
    case 1: palWritePad(GPIOA, 5, on); break;
    case 2: palWritePad(GPIOC, 4, on); break;
    case 3: palWritePad(GPIOC, 5, on); break;
    case 4: palWritePad(GPIOA, 12, on); break;
    case 5: palWritePad(GPIOA, 15, on); break;
    case 6: palWritePad(GPIOB, 2, on); break;
    default: break;
  }
}

Add debug LEDs to digital platform setup.


/*
 * Podrios.cpp
 *
 *  Created on: 2014年10月23日
 *      Author: nemo
 */

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
	cout << "Show Message." << endl;

	system("pause");
	return 0;
}

/*
 * Podrios.cpp
 *
 *  Created on: 2014年10月23日
 *      Author: nemo
 */

#include <iostream>

using namespace std;

int main()
{
	cout << "Show Message." << endl;

	return 0;
}

Remove system pause, Linux doesn't have this function.


#include <QTest>
#include <QObject>

#include "uritests.h"

// This is all you need to run all the tests
int main(int argc, char *argv[])
{
    URITests test1;
    QTest::qExec(&test1);
}

#include <QTest>
#include <QObject>

#include "uritests.h"

// This is all you need to run all the tests
int main(int argc, char *argv[])
{
    bool fInvalid = false;

    URITests test1;
    if (QTest::qExec(&test1) != 0)
        fInvalid = true;

    return fInvalid;
}

Return !0 when qt tests fail.

Return !0 when qt tests fail.


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

#include "SkColorMatrixFilter.h"

static SkScalar byte_to_scale(U8CPU byte) {
    if (0xFF == byte) {
        // want to get this exact
        return 1;
    } else {
        return byte * 0.00392156862745f;
    }
}

SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor add) {
    SkColorMatrix matrix;
    matrix.setScale(byte_to_scale(SkColorGetR(mul)),
                    byte_to_scale(SkColorGetG(mul)),
                    byte_to_scale(SkColorGetB(mul)),
                    1);
    matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
                         SkIntToScalar(SkColorGetG(add)),
                         SkIntToScalar(SkColorGetB(add)),
                         0);
    return SkColorMatrixFilter::Create(matrix);
}

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

#include "SkColorMatrixFilter.h"

static SkScalar byte_to_scale(U8CPU byte) {
    if (0xFF == byte) {
        // want to get this exact
        return 1;
    } else {
        return byte * 0.00392156862745f;
    }
}

SkColorFilter* SkColorMatrixFilter::CreateLightingFilter(SkColor mul, SkColor add) {
    if (0 == add) {
        return SkColorFilter::CreateModeFilter(mul | SK_ColorBLACK,
                                               SkXfermode::Mode::kModulate_Mode);
    }
    SkColorMatrix matrix;
    matrix.setScale(byte_to_scale(SkColorGetR(mul)),
                    byte_to_scale(SkColorGetG(mul)),
                    byte_to_scale(SkColorGetB(mul)),
                    1);
    matrix.postTranslate(SkIntToScalar(SkColorGetR(add)),
                         SkIntToScalar(SkColorGetG(add)),
                         SkIntToScalar(SkColorGetB(add)),
                         0);
    return SkColorMatrixFilter::Create(matrix);
}

Simplify LightingFilter in add-free case

bug:28519669

Change-Id: Id55b51c92468a53e7623c34bb23081283da18655


#include<math.h>
#include<stdio.h>
/*#include<iostream>

using namespace std;*/

int isPrimeBruteForce(int x)
{
	if (x < 2)
		return false;
	double sqroot_x;
	sqroot_x = sqrt (x);
	for(int i=0; i <= sqroot_x; i++) { /* If there were only factors above the square root of x, they would be bigger than x itself. */
		if (x%i==0)
			return 0;
	}
	return 1;
}

int main(int argc, char* argv[])
{
	int result;
/*	int number;
	cout << "Enter number to test if it's prime: ";
	cin >> number;
	result = isPrimeBruteForce(number);
	if (result) {
		cout << number << " is a prime number.";
	} else {
		cout << number << " is not a prime number.";
	}*/
	result = isPrimeBruteForce(37);
	printf("Is 37 a prime number? %i", result);
	return 0;
}

#include <iostream>
#include <cmath>
//using namespace std;

int isPrimeBruteForce(int x)
{
	if (x < 2)
		return false;
	double sqroot_x;
	double square = x;
	sqroot_x = std::sqrt(square);
	for(int i=0; i <= sqroot_x; i++) { /* If there were only factors above the square root of x, they would be bigger than x itself. */
		if (x%i==0)
			return 0;
	}
	return 1;
}

int main(int argc, char* argv[])
{
	int result;
	int number;
	std::cout << "Enter number to test if it's prime: " << std::endl;
	std::cin >> number;
	result = isPrimeBruteForce(number);
	std::cout << std::endl;
	if (result == 1) {
		std::cout << number << " is a prime number." << std::endl;
	} else {
		std::cout << number << " is not a prime number." << std::endl;
	}
/*	result = isPrimeBruteForce(37);
	printf("Is 37 a prime number? %i", result);*/
	return 0;
}

Change preprocessors and namespaces to c++ std library; make data types consistent (at least trying to)


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

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

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

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

#include "tensorflow/core/platform/cuda_libdevice_path.h"

#include <stdlib.h>
#include <vector>

#if !defined(PLATFORM_GOOGLE)
#include "third_party/gpus/cuda/cuda_config.h"
#endif
#include "tensorflow/core/platform/logging.h"

namespace tensorflow {

std::vector<string> CandidateCudaRoots() {
  VLOG(3) << "CUDA root = " << TF_CUDA_TOOLKIT_PATH;
  return {TF_CUDA_TOOLKIT_PATH};
}

}  // namespace tensorflow

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

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

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

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

#include "tensorflow/core/platform/cuda_libdevice_path.h"

#include <stdlib.h>
#include <vector>

#if !defined(PLATFORM_GOOGLE)
#include "third_party/gpus/cuda/cuda_config.h"
#endif
#include "tensorflow/core/platform/logging.h"

namespace tensorflow {

std::vector<string> CandidateCudaRoots() {
  VLOG(3) << "CUDA root = " << TF_CUDA_TOOLKIT_PATH;
  return {TF_CUDA_TOOLKIT_PATH, string("/usr/local/cuda")};
}

}  // namespace tensorflow

Add /usr/local/cuda to the list of CUDA data directories that XLA searches by default.

My installation of JAX chose /usr/local/cuda-11.2 as its default CUDA data directory. That's a fine first choice, but the problem with it is that it names a specific CUDA version, when CUDA 11.1+ are backwards compatible between minor releases. So we would also like to try looking in an unversioned path, and /usr/local/cuda is a very popular choice.

This change is in preparation for JAX reducing the number of CUDA wheel variants that it ships.

PiperOrigin-RevId: 369961339
Change-Id: I45a22ecc465a169112337292071f24f29866a3e7


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

using namespace std;
/* So I guess I should use arrays? Seems like quite good idea, hopefully it'll work as intended.
 * Also I'm still not sure how to avoid duplicates...
*/

void lotto::lotek(){
    for(int i = 0; i < 6; i++) {
        int a = rand()%49+1;
        cout << '\t' << a << " " << endl;
    }
}

void lotto::multilotek() {
    for(int i = 0; i < 20; i++) {
        int a = rand()%80+1;
        cout << a << endl;
    }
}

void lotto::simpleMenu() {
    cout << "Bardzo prosty program używający generator liczb pseudolosowych.\n" << endl;
    cout << "1. Lotto (bez plusa i innych super szans)\n2. Multi multi (bez plusa i super szansy)\n3. Koniec (kończy program)" << endl;
}

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

using namespace std;
/* So I guess I should use arrays? Seems like quite good idea, hopefully it'll work as intended.
 * Also I'm still not sure how to avoid duplicates...
*/

void lotto::lotek(){
   int lotteryPool[50];
   for(int x = 0; x < 50; x++) {
       lotteryPool[x] = x + 1;
   }
   srand (time(NULL));
   int random;
   int y = 0;
   while(y < 6) {
       random = rand()%50;
       if(lotteryPool[random] != 0) {
           cout << lotteryPool[random] << " ";
           lotteryPool[random] = 0;
           y++;
       }
   }

}

void lotto::multilotek() {
    for(int i = 0; i < 20; i++) {
        int a = rand()%80+1;
        cout << a << endl;
    }
}

void lotto::simpleMenu() {
    cout << "Bardzo prosty program używający generator liczb pseudolosowych.\n" << endl;
    cout << "1. Lotto (bez plusa i innych super szans)\n2. Multi multi (bez plusa i super szansy)\n3. Koniec (kończy program)" << endl;
}

Add changes to first option

Add changes to first option

Somehow it's working, gotta change second part later


/* The Halfling Project - A Graphics Engine and Projects
 *
 * The Halfling Project is the legal property of Adrian Astley
 * Copyright Adrian Astley 2013
 */

#include "halfling/halfling_engine.h"

#include "deferred_shading_demo/graphics_manager.h"
#include "deferred_shading_demo/game_state_manager.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	DeferredShadingDemo::GameStateManager gameStateManager;
	DeferredShadingDemo::GraphicsManager graphicsManager(&gameStateManager);

	Halfling::HalflingEngine engine(hInstance, &graphicsManager, &gameStateManager);

	engine.Initialize(L"Lighting Demo", 800, 600, false);
	engine.Run();

	engine.Shutdown();

	return 0;
}

/* The Halfling Project - A Graphics Engine and Projects
 *
 * The Halfling Project is the legal property of Adrian Astley
 * Copyright Adrian Astley 2013
 */

#include "halfling/halfling_engine.h"

#include "deferred_shading_demo/graphics_manager.h"
#include "deferred_shading_demo/game_state_manager.h"

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	DeferredShadingDemo::GameStateManager gameStateManager;
	DeferredShadingDemo::GraphicsManager graphicsManager(&gameStateManager);

	Halfling::HalflingEngine engine(hInstance, &graphicsManager, &gameStateManager);

	engine.Initialize(L"Deferred Shading Demo", 800, 600, false);
	engine.Run();

	engine.Shutdown();

	return 0;
}

Change the title bar caption

DEFERRED_SHADING_DEMO: Change the title bar caption


/*
Author: vpetrigo
Task:

  0.
     ,
,   ,
   .

   ,
 0 (  0    ,      ).

   .

Sample Input 1:
4
4
2
3
0
Sample Output 1:
4

Sample Input 2:
2
1
0
Sample Output 2:
1

*/

#include <iostream>

using namespace std;

int main() {
    int n;
    int max = -1;
    int s_max = -1;

    while (cin >> n && n != 0) {
        if (max < n) {
            max = n;
        }

        if (n <= max && s_max < n) {
            s_max = n;
        }
    }

    cout << s_max;

    return 0;
}

/*
Author: vpetrigo
Task:

  0.
     ,
,   ,
   .

   ,
 0 (  0    ,      ).

   .

Sample Input 1:
4
4
2
3
0
Sample Output 1:
4

Sample Input 2:
2
1
0
Sample Output 2:
1

*/

#include <iostream>

using namespace std;

int main() {
    int n;
    int max = -1;
    int s_max = -1;

    while (cin >> n && n != 0) {
        if (max <= n) {
            s_max = max;
            max = n;
        }
        else if (s_max < n) {
            s_max = n;
        }
    }

    cout << s_max;

    return 0;
}

Revert "Revert "Solution for week 3, task 9""

This reverts commit a280465d0b09e0aa9f9ec3b403b1bf3785b7d75a.