// Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//

#ifndef ArcGISRuntimeToolkit_H
#define ArcGISRuntimeToolkit_H

#include <QQmlExtensionPlugin>
#include "ToolkitCommon.h"

namespace Esri
{
namespace ArcGISRuntime
{
namespace Toolkit
{

class TOOLKIT_EXPORT ArcGISRuntimeToolkit : public QQmlExtensionPlugin
{
  Q_OBJECT
  Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)

public:
  explicit ArcGISRuntimeToolkit(QObject* parent = nullptr);

  void registerTypes(const char* uri);

  static void registerToolkitTypes(const char* uri = "Esri.ArcGISRuntime.Toolkit.CppApi");

private:
  static constexpr int s_versionMajor = 100;
  static constexpr int s_versionMinor = 2;
};

} // Toolkit
} // ArcGISRuntime
} // Esri

#endif // ArcGISRuntimeToolkit_H

// Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//

#ifndef ArcGISRuntimeToolkit_H
#define ArcGISRuntimeToolkit_H

#include <QQmlExtensionPlugin>
#include "ToolkitCommon.h"

namespace Esri
{
namespace ArcGISRuntime
{
namespace Toolkit
{

class TOOLKIT_EXPORT ArcGISRuntimeToolkit : public QQmlExtensionPlugin
{
  Q_OBJECT
  Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)

public:
  explicit ArcGISRuntimeToolkit(QObject* parent = nullptr);

  void registerTypes(const char* uri);

  static void registerToolkitTypes(const char* uri = "Esri.ArcGISRuntime.Toolkit.CppApi");

private:
  static constexpr int s_versionMajor = 100;
  static constexpr int s_versionMinor = 3;
};

} // Toolkit
} // ArcGISRuntime
} // Esri

#endif // ArcGISRuntimeToolkit_H

Update registration version for 100.3

Update registration version for 100.3


#include "Enesim.h"

int main(int argc, char **argv)
{
	Enesim_Renderer *r;
	Enesim_Surface *s;
	Enesim_Log *error = NULL;

	enesim_init();
	r = enesim_renderer_rectangle_new();
	enesim_renderer_shape_fill_color_set(r, 0xffffffff);
	/* we dont set any property to force the error */

	s = enesim_surface_new(ENESIM_FORMAT_ARGB8888, 320, 240);

	if (!enesim_renderer_draw(r, s, ENESIM_ROP_FILL, NULL, 0, 0, &error))
	{
		enesim_log_dump(error);
		enesim_log_delete(error);
	}

	enesim_shutdown();

	return 0;
}

#include "Enesim.h"

int main(int argc, char **argv)
{
	Enesim_Renderer *r;
	Enesim_Surface *s;
	Enesim_Log *error = NULL;

	enesim_init();
	r = enesim_renderer_rectangle_new();
	enesim_renderer_shape_fill_color_set(r, 0xffffffff);
	/* we dont set any property to force the error */

	s = enesim_surface_new(ENESIM_FORMAT_ARGB8888, 320, 240);

	if (!enesim_renderer_draw(r, s, ENESIM_ROP_FILL, NULL, 0, 0, &error))
	{
		enesim_log_dump(error);
		enesim_log_unref(error);
	}

	enesim_shutdown();

	return 0;
}

Use the new log API

Use the new log API


#include <mutex>
#include <deque>

#ifndef SRC_CONCURRENT_QUEUE_H
#define SRC_CONCURRENT_QUEUE_H

/* Concurrent queue
 * so far just make sure it is consisten, no performance optimizations
 * but interface should be general enought to replace queue with faster one
 */

template< typename T >
struct ConcurrentQueue {

    void enqueue( const T &data ) {
        Guard g{ _lock };
        _queue.push_back( data );
        g.unlock();
        _cond.notify_one();
    }

    /** get and pop head of queue, this will block if queue is empty
     */
    T dequeue() {
        Guard g{ _lock };
        while ( _queue.empty() )
            _cond.wait( g );
        T data = _queue.front();
        _queue.pop_front();
        return data;
    }

    /** not safe
     */
    bool empty() {
        Guard g{ _lock };
        return _queue.empty();
    }

  private:
    std::mutex _lock;
    std::deque< T > _queue;
    std::condition_variable _cond;
    using Guard = std::unique_lock< std::mutex >;
};

#endif // SRC_CONCURRENT_QUEUE_H

Add (prototype of) concurrent queue.

project: Add (prototype of) concurrent queue.


#include <pthread.h>

int g;
int *g1;
int *g2;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
  pthread_mutex_lock(&mutex);
  (*g1)++; // RACE!
  pthread_mutex_lock(&mutex);
  return NULL;
}

int main(void) {
  pthread_t id;
  int x;
  g1 = g2 = &g;

  pthread_create(&id, NULL, t_fun, NULL);

  (*g2)++; // RACE!

  pthread_join (id, NULL);
  return 0;
}

#include <pthread.h>

int g;
int *g1;
int *g2;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
  pthread_mutex_lock(&mutex);
  (*g1)++; // RACE!
  pthread_mutex_unlock(&mutex);
  return NULL;
}

int main(void) {
  pthread_t id;
  int x;
  g1 = g2 = &g;

  pthread_create(&id, NULL, t_fun, NULL);

  (*g2)++; // RACE!

  pthread_join (id, NULL);
  return 0;
}

Fix lock-unlock copy-paste mistake in 04/37


/* vi: set sw=4 ts=4: */
/*
 * getrusage() for uClibc
 *
 * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
 *
 * GNU Library General Public License (LGPL) version 2 or later.
 */

#include "syscalls.h"
#include <unistd.h>
#include <wait.h>
_syscall2(int, getrusage, int, who, struct rusage *, usage);

/* vi: set sw=4 ts=4: */
/*
 * getrusage() for uClibc
 *
 * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
 *
 * GNU Library General Public License (LGPL) version 2 or later.
 */

#include "syscalls.h"
#include <unistd.h>
#include <wait.h>
_syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage);

Correct type, gcc-3.4.5 fails, thanks nitinkg for reporting/testing


// REQUIRES: x86-registered-target

// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -S -o - | FileCheck %s --check-prefix=CHECK-ABSENT
// CHECK-ABSENT-NOT: section .stack_sizes

// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fstack-size-section %s -S -o - | FileCheck %s --check-prefix=CHECK-PRESENT
// CHECK-PRESENT: section .stack_sizes

int foo() { return 42; }

Fix test added in r321992 failing on some buildbots (again), test requires x86.

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


//
// pch.h
// Header for standard system include files.
//

#ifndef _divida_precompiled_header_h_
#define _divida_precompiled_header_h_

#ifdef WINDOWS

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include <windows.h>
#endif

#include <algorithm>
#include <iomanip>
#include <string>
#include <sstream>

#endif

//
// pch.h
// Header for standard system include files.
//

#ifndef _divida_precompiled_header_h_
#define _divida_precompiled_header_h_

#ifdef WINDOWS

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif

#include <windows.h>
#endif

#include <algorithm>
#include <iomanip>
#include <memory>
#include <string>
#include <sstream>

#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 9)
namespace std
{

template<typename T, typename ...Args>
unique_ptr<T> make_unique(Args&& ...args)
{
	return unique_ptr<T>(new T(std::forward<Args>(args)...));
}

}
#endif

#endif

Add backup implementation of std::make_unique.


#include "ambient_light.h"
#include "tock.h"

typedef struct {
  int intensity;
  bool fired;
} ambient_light_data_t;

// callback for synchronous reads
static void ambient_light_cb(int intensity,
                             __attribute__ ((unused)) int unused1,
                             __attribute__ ((unused)) int unused2, void* ud) {
  ambient_light_data_t* result = (ambient_light_data_t*)ud;
  result->intensity = intensity;
  result->fired     = true;
}

int ambient_light_read_intensity_sync(int* lux_value) {
  int err;
  ambient_light_data_t result = {0};
  result.fired = false;

  err = ambient_light_subscribe(ambient_light_cb, (void*)(&result));
  if (err < TOCK_SUCCESS) {
    return err;
  }

  err = ambient_light_start_intensity_reading();
  if (err < TOCK_SUCCESS) {
    return err;
  }

  yield_for(&result.fired);

  *lux_value = result.intensity;

  return TOCK_SUCCESS;
}

int ambient_light_subscribe(subscribe_cb callback, void* userdata) {
  return subscribe(DRIVER_NUM_AMBIENT_LIGHT, 0, callback, userdata);
}

int ambient_light_start_intensity_reading(void) {
  return command(DRIVER_NUM_AMBIENT_LIGHT, 1, 0, 0);
}

#include "ambient_light.h"
#include "tock.h"

typedef struct {
  int intensity;
  bool fired;
} ambient_light_data_t;

// internal callback for faking synchronous reads
static void ambient_light_cb(int intensity,
                             __attribute__ ((unused)) int unused1,
                             __attribute__ ((unused)) int unused2, void* ud) {
  ambient_light_data_t* result = (ambient_light_data_t*)ud;
  result->intensity = intensity;
  result->fired     = true;
}

int ambient_light_read_intensity_sync(int* lux_value) {
  int err;
  ambient_light_data_t result = {0};
  result.fired = false;

  err = ambient_light_subscribe(ambient_light_cb, (void*)(&result));
  if (err < TOCK_SUCCESS) {
    return err;
  }

  err = ambient_light_start_intensity_reading();
  if (err < TOCK_SUCCESS) {
    return err;
  }

  yield_for(&result.fired);

  *lux_value = result.intensity;

  return TOCK_SUCCESS;
}

int ambient_light_subscribe(subscribe_cb callback, void* userdata) {
  return subscribe(DRIVER_NUM_AMBIENT_LIGHT, 0, callback, userdata);
}

int ambient_light_start_intensity_reading(void) {
  return command(DRIVER_NUM_AMBIENT_LIGHT, 1, 0, 0);
}

Revert "Updating ambient light to 2.0 API."

This reverts commit 9a9df3a205dcebfcb358b60ef11df54698ec6dce.


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

#pragma once

#include "Stdafx.h"
#include "include/cef_string_visitor.h"

namespace CefSharp
{
    private class StringVisitor : public CefStringVisitor
    {
     private:
        gcroot<IStringVisitor^> _visitor;

    public:
        StringVisitor(IStringVisitor^ visitor) :
            _visitor(visitor)
        {
        }

        ~StringVisitor()
        {
            _visitor = nullptr;
        }

        virtual void Visit(const CefString& string) OVERRIDE;

        IMPLEMENT_REFCOUNTING(StringVisitor);
    };
}

Fix minor indentation issue (formatting)


#ifndef ALIPHOSPREPROCESSOR_H
#define ALIPHOSPREPROCESSOR_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id$ */

///////////////////////////////////////////////////////////////////////////////
// Class AliPHOSPreprocessor
///////////////////////////////////////////////////////////////////////////////

#include "AliPreprocessor.h"

class AliPHOSPreprocessor : public AliPreprocessor {
public:

  AliPHOSPreprocessor();
  AliPHOSPreprocessor(const char* detector, AliShuttleInterface* shuttle);

protected:

  virtual void Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
  virtual UInt_t Process(TMap* valueSet);

  ClassDef(AliPHOSPreprocessor,0);

};

#endif

#ifndef ALIPHOSPREPROCESSOR_H
#define ALIPHOSPREPROCESSOR_H
/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id$ */

///////////////////////////////////////////////////////////////////////////////
// Class AliPHOSPreprocessor
///////////////////////////////////////////////////////////////////////////////

#include "AliPreprocessor.h"

class AliPHOSPreprocessor : public AliPreprocessor {
public:

  AliPHOSPreprocessor();
  AliPHOSPreprocessor(const char* detector, AliShuttleInterface* shuttle);

protected:

  virtual UInt_t Process(TMap* valueSet);

  ClassDef(AliPHOSPreprocessor,0);

};

#endif

Remove declaration of unimplemented method


#ifndef SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_
#define SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_

namespace sorting {
namespace bubble {

template <class T>
void BubbleSort(T * const array, const int N)
/**
 * Bubble sort: Bubble sort
 * Scaling:
 *      Best case:
 *      Worst case:
 * Useful:
 *
 */
{

}

} // namespace bubble
} // namespace sorting

#endif // SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_

#ifndef SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_
#define SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_

namespace sorting {
namespace bubble {

template <class T>
void BubbleSort(T * const array, const int N)
/**
 * Bubble sort: Bubble sort
 * Scaling:
 *      Best case:
 *      Worst case:
 * Useful:
 *
 */
{
    int pass_count = 0;  // Number of pass over the array.
    int swap_count = 0;  // Number of swap for a single pass.

    // Pass over the array while the swap count is non-null.
    do
    {
        // It's a new pass; reset the count of swap.
        swap_count = 0;
        // Iterate over the array, skipping the last item
        for (int i = 0 ; i < N-1 ; i++)
        {
            // Swap elements if next one is "smaller" and register the swap.
            if (array[i] > array[i+1])
            {
                std::swap(array[i], array[i+1]);
                swap_count++;
            }
        }
        pass_count++;
    } while (swap_count != 0);
}

} // namespace bubble
} // namespace sorting

#endif // SORTING_INCLUDE_BUBBLESORTS_BUBBLE_INL_H_

Add working bubble sort implementation

Add working bubble sort implementation


// Patrick Yevsukov

// 2013 CC BY-NC-SA 4.0

// Excerpt From github.com/PatrickYevsukov/Statistics-Calculator

// I devised this algorithm to identify the statistical mode or
// modes of a dataset. It requires one pass through the set to
// identify the set's mode or mode's.

// This algorithm works by keeping track of the number of times a
// unique value occurs in the set. If a unique value has occurred
// more times than the ones before it, it is added to the list of
// modes. As the loop continues all values which occur this number
// of times are added to the list of modes, unless another unique
// value occurs more times than the currently identified modes. If
// this happens, the mode array indexing variable is reset to zero
// and the previously identified values are overwritten by the new
// modes. When finished, the mode array indexing variable will be
// one less than the number of modes.

// This algorithm requires a set of values in which all instances
// of a unique value are listed next to one another.

#include <stdio.h>
#include <stdlib.h>

#define MAX_SAMPLE 25

double *
SampleMode(double *, int *);

double *
SampleMode(double *sample, int *sample_size)
{
    int ii = 0;

    int kk = 0;

    int num_modes = 0;

    int previous_freq = 0;

    int current_freq = 1; // Every value must occur at least once

    double *modes = NULL;

    modes = (double *) malloc(MAX_SAMPLE * sizeof *modes);

    for (ii = 0; ii <= *sample_size - 1; ii++)
    {
        if (sample[ii] == sample[ii + 1])
        {
            current_freq++;
        }
        else
        {
            if (current_freq > previous_freq)
            {
                kk = 0; // Reset

                previous_freq = current_freq;

                modes[kk] = sample[ii];
            }

            else if (current_freq == previous_freq)
            {
                kk++;

                modes[kk] = sample[ii];
            }

            current_freq = 1; // Reset
        }
    }

    num_modes = kk + 1;

    return modes;
}

Add Statistical Mode Finding Algorithm

Add Statistical Mode Finding Algorithm

Implementation In C


#ifndef UNITS_UNIT_H_
#define UNITS_UNIT_H_

#include <SFML/Graphics.hpp>

#include "engine/instance.h"
#include "base/aliases.h"

class Unit : public Instance {
 public:
  Unit();
  virtual ~Unit();

  virtual void Step(sf::Time elapsed);

  void set_life(unsigned life) {
    life_ = life;
  }

  unsigned life() {
    return life_;
  }

  void set_position(Vec2f pos) {
    sprite_.set_position(pos);
  }

  Vec2f position() {
    return sprite_.getPosition();
  }

  void set_movement_speed(Vec2f movement_speed) {
    movement_speed_ = movement_speed;
  }

  void set_attack_speed(unsigned attack_speed) {
    attack_speed_ = attack_speed;
  }

 protected:
  unsigned life_;
  unsigned damage_;
  unsigned attack_speed_;
  Vec2f movement_speed_;
};

#endif  // UNITS_UNIT_H_

#ifndef UNITS_UNIT_H_
#define UNITS_UNIT_H_

#include <SFML/Graphics.hpp>

#include "engine/instance.h"
#include "base/aliases.h"

class Unit : public Instance {
 public:
  Unit();
  virtual ~Unit();

  virtual void Step(sf::Time elapsed);

  void set_life(unsigned life) {
    life_ = life;
  }

  unsigned life() {
    return life_;
  }

  void set_position(Vec2f pos) {
    sprite_.set_position(pos);
  }

  Vec2f position() {
    return sprite_.position();
  }

  void set_movement_speed(Vec2f movement_speed) {
    movement_speed_ = movement_speed;
  }

  void set_attack_speed(unsigned attack_speed) {
    attack_speed_ = attack_speed;
  }

 protected:
  unsigned life_;
  unsigned damage_;
  unsigned attack_speed_;
  Vec2f movement_speed_;
};

#endif  // UNITS_UNIT_H_

Rename function to the new version.

Rename function to the new version.


// These macros weren't added until v8 version 4.4
#include "node_wrapper.h"
#ifndef V8_MAJOR_VERSION
	#if NODE_MODULE_VERSION <= 11
		#define V8_MAJOR_VERSION 3
		#define V8_MINOR_VERSION 14
		#define V8_PATCH_LEVEL 0
	#elif V8_MAJOR_VERSION <= 14
		#define V8_MAJOR_VERSION 3
		#define V8_MINOR_VERSION 28
		#define V8_PATCH_LEVEL 0
	#else
		#error v8 version macros missing
	#endif
#endif

#define V8_AT_LEAST(major, minor, patch) (\
	V8_MAJOR_VERSION > (major) || \
	(V8_MAJOR_VERSION == (major) && V8_MINOR_VERSION >= (minor)) || \
	(V8_MAJOR_VERSION == (major) && V8_MINOR_VERSION == (minor) && V8_PATCH_LEVEL >= (patch)) \
)

#define NODE_MODULE_OR_V8_AT_LEAST(nodejs, v8_major, v8_minor, v8_patch) (\
	defined(NODE_MODULE_VERSION) ? NODE_MODULE_VERSION >= nodejs : V8_AT_LEAST(v8_major, v8_minor, v8_patch) \
)

// These macros weren't added until v8 version 4.4
#include "node_wrapper.h"
#ifndef V8_MAJOR_VERSION
	#if NODE_MODULE_VERSION <= 11
		#define V8_MAJOR_VERSION 3
		#define V8_MINOR_VERSION 14
		#define V8_PATCH_LEVEL 0
	#elif V8_MAJOR_VERSION <= 14
		#define V8_MAJOR_VERSION 3
		#define V8_MINOR_VERSION 28
		#define V8_PATCH_LEVEL 0
	#else
		#error v8 version macros missing
	#endif
#endif

#define V8_AT_LEAST(major, minor, patch) (\
	V8_MAJOR_VERSION > (major) || \
	(V8_MAJOR_VERSION == (major) && V8_MINOR_VERSION >= (minor)) || \
	(V8_MAJOR_VERSION == (major) && V8_MINOR_VERSION == (minor) && V8_PATCH_LEVEL >= (patch)) \
)

#ifdef NODE_MODULE_VERSION
#define NODE_MODULE_OR_V8_AT_LEAST(nodejs, v8_major, v8_minor, v8_patch) (NODE_MODULE_VERSION >= nodejs)
#else
#define NODE_MODULE_OR_V8_AT_LEAST(nodejs, v8_major, v8_minor, v8_patch) (V8_AT_LEAST(v8_major, v8_minor, v8_patch))
#endif

Fix msvc preprocessor error (omg)

Fix msvc preprocessor error (omg)


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

#pragma once

#include "metrics/jaccard.h"
#include "metrics/jaro.h"
#include "metrics/jaro_winkler.h"
#include "metrics/levenshtein.h"
#include "metrics/sorensen_dice.h"

Add include file for string metric

Add include file for string metric


//
//  FileSystem.h
//  arc
//
//  Created by Jerome Cheng on 19/3/13.
//  Copyright (c) 2013 nus.cs3217. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Folder.h"

@interface FileSystem : NSObject {
    @private
    Folder *_rootFolder; // The root folder.
}

// Returns the root folder of the entire file system.
- (Folder*)getRootFolder;

// Returns the single FileSystem instance.
+ (FileSystem*)getInstance;

@end

//
//  FileSystem.h
//  arc
//
//  Created by Jerome Cheng on 19/3/13.
//  Copyright (c) 2013 nus.cs3217. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Folder.h"

@interface FileSystem : NSObject {
    @private
    Folder *_rootFolder; // The root folder.
}

// Returns the root folder of the entire file system.
- (Folder*)getRootFolder;

// Returns the single FileSystem instance.
+ (FileSystem*)getInstance;

// Returns an NSArray of FileObjects, corresponding to the contents
// of the given folder.
- (NSArray*)getFolderContents:(Folder*)folder;

// Returns an NSString containing the contents of the given file.
- (NSString*)getFileContents:(File*)file;

@end

Add signatures for content retrieval methods.


#ifndef CERBERUS_H
#define CERBERUS_H

#include <iostream>
#include "ceres/ceres.h"

using namespace std;
using namespace ceres;

class Cerberus {
public:
  Cerberus();

  Solver::Options options;
  LossFunction *loss;
  Problem problem;
  Solver::Summary summary;

  void solve();

};

#endif

#ifndef CERBERUS_H
#define CERBERUS_H

#include <iostream>
#include "ceres/ceres.h"
#include "ceres/rotation.h"

using namespace std;
using namespace ceres;

class Cerberus {
public:
  Cerberus();

  Solver::Options options;
  LossFunction *loss;
  Problem problem;
  Solver::Summary summary;

  void solve();
};

// Rt is a 4x3 transformation matrix of the form [R|t]. result is a
// 6-dimensional vector with first three terms representing axis, magnitude
// angle, and the last three terms represent translation
template <typename T> void TransformationMatrixToAngleAxisAndTranslation(T *Rt, T *result) {
  RotationMatrixToAngleAxis<T>(MatrixAdapter<const T, 4, 1>(Rt), result);
  result[3] = Rt[3];
  result[4] = Rt[7];
  result[5] = Rt[11];
}

// At is a 6-dimensional vector with first three terms representing axis,
// magnitude angle, and the last three terms represent translation. Rt is a
// 4x3 transformation matrix of the form [R|t].
template <typename T> void AngleAxisAndTranslationToTransformationMatrix(const T *At, T *result) {
  AngleAxisToRotationMatrix<T>(At, MatrixAdapter<T, 4, 1>(result));
  result[3] = At[3];
  result[7] = At[4];
  result[11] = At[5];
}

#endif

Add utility functions for converting to and from AngleAxis


/* ---------------------------------------------------------------- */

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
#endif

/* ---------------------------------------------------------------- */

#define MPICH_SKIP_MPICXX 1
#define OMPI_SKIP_MPICXX 1

#include <petsc.h>

/* ---------------------------------------------------------------- */

#include "python_core.h"

#define PETSCMAT_DLL
#include "python_mat.c"
#undef  PETSCMAT_DLL

#define PETSCKSP_DLL
#include "python_ksp.c"
#undef PETSCKSP_DLL

#define PETSCKSP_DLL
#include "python_pc.c"
#undef PETSCKSP_DLL

#define PETSCSNES_DLL
#include "python_snes.c"
#undef PETSCSNES_DLL

#define PETSCTS_DLL
#include "python_ts.c"
#undef PETSCTS_DLL

/* ---------------------------------------------------------------- */

Fix build failure with Python<=2.4 and PETSc<=3.1


// RUN: not %clang_cc1 -E -dependency-file bla -MT %t/doesnotexist/bla.o -MP -o $t/doesnotexist/bla.o -x c /dev/null 2>&1 | FileCheck %s

// CHECK: error: unable to open output file

// rdar://9286457

// RUN: not %clang_cc1 -E -dependency-file bla -MT %t/doesnotexist/bla.o -MP -o %t/doesnotexist/bla.o -x c /dev/null 2>&1 | FileCheck %s

// CHECK: error: unable to open output file

// rdar://9286457

Fix typo in my last commit.

Fix typo in my last commit.

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


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

#ifndef LIBPORT_DETECT_WIN32_H
# define LIBPORT_DETECT_WIN32_H

# ifndef WIN32
#  if defined LIBPORT_WIN32 || defined _MSC_VER
#   define WIN32
#  endif
# endif

# ifdef WIN32

// Normalize to 1
#  undef WIN32
#  define WIN32 1

#  ifndef _WIN32_WINNT
#   define _WIN32_WINNT 0x0400
#  endif

# endif /* !WIN32 */

# ifdef WIN32
#  define WIN32_IF(Then, Else) Then
#  define EXEEXT ".exe"
# else
#  define WIN32_IF(Then, Else) Else
#  define EXEEXT ""
# endif

#endif // !LIBPORT_DETECT_WIN32_H

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

#ifndef LIBPORT_DETECT_WIN32_H
# define LIBPORT_DETECT_WIN32_H

# ifndef WIN32
#  if defined LIBPORT_WIN32 || defined _MSC_VER
#   define WIN32
#  endif
# endif

# ifdef WIN32

// Normalize to 1
#  undef WIN32
#  define WIN32 1

#  ifndef _WIN32_WINNT

// Boost 1.47 uses InitializeCriticalSectionAndSpinCount which is
// defined starting at 0x403
// (http://msdn.microsoft.com/en-us/library/windows/desktop/ms683476(v=vs.85).aspx).

#   define _WIN32_WINNT 0x0403
#  endif

# endif /* !WIN32 */

# ifdef WIN32
#  define WIN32_IF(Then, Else) Then
#  define EXEEXT ".exe"
# else
#  define WIN32_IF(Then, Else) Else
#  define EXEEXT ""
# endif

#endif // !LIBPORT_DETECT_WIN32_H

Boost 1.47 on Windows: require _WIN32_WINNT 0x0403.

	* include/libport/detect-win32.h: here.


//
//  PublicHeaders.h
//  Insider
//
//  Created by Alexandru Maimescu on 3/2/16.
//  Copyright © 2016 Alex Maimescu. All rights reserved.
//

#ifndef PublicHeaders_h
#define PublicHeaders_h

// GCDWebServer https://github.com/swisspol/GCDWebServer

#import <Insider/GCDWebServer.h>
#import <Insider/GCDWebServerURLEncodedFormRequest.h>
#import <Insider/GCDWebServerDataResponse.h>

// iOS-System-Services https://github.com/Shmoopi/iOS-System-Services

#import <Insider/SystemServices.h>

#endif /* PublicHeaders_h */

//
//  PublicHeaders.h
//  Insider
//
//  Created by Alexandru Maimescu on 3/2/16.
//  Copyright © 2016 Alex Maimescu. All rights reserved.
//

#ifndef PublicHeaders_h
#define PublicHeaders_h

// GCDWebServer https://github.com/swisspol/GCDWebServer

#import "GCDWebServer.h"
#import "GCDWebServerURLEncodedFormRequest.h"
#import "GCDWebServerDataResponse.h"

// iOS-System-Services https://github.com/Shmoopi/iOS-System-Services

#import "SystemServices.h"

#endif /* PublicHeaders_h */

Update imports in umbrella header.

Update imports in umbrella header.


/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2017/10/15     bernard      the first version
 */
#include <rtthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>

#include "libc.h"

#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif

int	_EXFUN(putenv,(char *__string));

int libc_system_init(void)
{
#if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE)
    rt_device_t dev_console;

    dev_console = rt_console_get_device();
    if (dev_console)
    {
    #if defined(RT_USING_POSIX)
        libc_stdio_set_console(dev_console->parent.name, O_RDWR);
    #else
        libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
    #endif
    }
#endif

    /* set PATH and HOME */
    putenv("PATH=/bin");
    putenv("HOME=/home");

#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
    pthread_system_init();
#endif

    return 0;
}
INIT_COMPONENT_EXPORT(libc_system_init);

/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2017/10/15     bernard      the first version
 */
#include <rtthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>

#include "libc.h"

#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif

int	_EXFUN(putenv,(char *__string));

int libc_system_init(void)
{
#if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE)
    rt_device_t dev_console;

    dev_console = rt_console_get_device();
    if (dev_console)
    {
    #if defined(RT_USING_POSIX)
        libc_stdio_set_console(dev_console->parent.name, O_RDWR);
    #else
        libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
    #endif
    }

    /* set PATH and HOME */
    putenv("PATH=/bin");
    putenv("HOME=/home");
#endif

#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
    pthread_system_init();
#endif

    return 0;
}
INIT_COMPONENT_EXPORT(libc_system_init);

Disable ENV when disable DFS.

[Libc] Disable ENV when disable DFS.


// RUN: clang-cc -Eonly optimize.c -DOPT_O2 -O2 -verify &&
#ifdef OPT_O2
  #ifndef __OPTIMIZE__
    #error "__OPTIMIZE__ not defined"
  #endif
  #ifdef __OPTIMIZE_SIZE
    #error "__OPTIMIZE_SIZE__ defined"
  #endif
#endif

// RUN: clang-cc -Eonly optimize.c -DOPT_O0 -O0 -verify &&
#ifdef OPT_O0
  #ifdef __OPTIMIZE__
    #error "__OPTIMIZE__ defined"
  #endif
  #ifdef __OPTIMIZE_SIZE
    #error "__OPTIMIZE_SIZE__ defined"
  #endif
#endif

// RUN: clang-cc -Eonly optimize.c -DOPT_OS -Os -verify
#ifdef OPT_OS
  #ifndef __OPTIMIZE__
    #error "__OPTIMIZE__ not defined"
  #endif
  #ifndef __OPTIMIZE_SIZE
    #error "__OPTIMIZE_SIZE__ not defined"
  #endif
#endif

// RUN: clang-cc -Eonly %s -DOPT_O2 -O2 -verify &&
#ifdef OPT_O2
  #ifndef __OPTIMIZE__
    #error "__OPTIMIZE__ not defined"
  #endif
  #ifdef __OPTIMIZE_SIZE
    #error "__OPTIMIZE_SIZE__ defined"
  #endif
#endif

// RUN: clang-cc -Eonly %s -DOPT_O0 -O0 -verify &&
#ifdef OPT_O0
  #ifdef __OPTIMIZE__
    #error "__OPTIMIZE__ defined"
  #endif
  #ifdef __OPTIMIZE_SIZE
    #error "__OPTIMIZE_SIZE__ defined"
  #endif
#endif

// RUN: clang-cc -Eonly %s -DOPT_OS -Os -verify
#ifdef OPT_OS
  #ifndef __OPTIMIZE__
    #error "__OPTIMIZE__ not defined"
  #endif
  #ifndef __OPTIMIZE_SIZE
    #error "__OPTIMIZE_SIZE__ not defined"
  #endif
#endif

Use %s in test, not hard coded name.

Use %s in test, not hard coded name.

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


#include "safe-c/safe_memory.h"

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

void* safe_malloc_function(size_t size, const char* calling_function)
{
    if (size == 0)
    {
        fprintf(stderr, "Error allocating memory: The function %s called "
                "'safe_malloc' and requested zero memory. The pointer should "
                "be explicitly set to NULL instead.\n",
                calling_function);
        exit(EXIT_FAILURE);
    }

    void* memory = malloc(size);
    if (!memory)
    {
        fprintf(stderr, "Error allocating memory: The function %s called "
                "'safe_malloc' requesting %zu bytes of memory, but an error "
                "occurred allocating this amount of memory. Exiting",
                calling_function, size);
        exit(EXIT_FAILURE);
    }
    memory = memset(memory, 0, size);
    return memory;
}

void safe_free_function(void** pointer_address)
{
    if (pointer_address != NULL)
    {
        free(*pointer_address);
        *pointer_address = NULL;
    }
}

#include "safe-c/safe_memory.h"

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

void* safe_malloc_function(size_t size, const char* calling_function)
{
    if (size == 0)
    {
        fprintf(stderr, "Error allocating memory: The function %s called "
                "'safe_malloc' and requested zero memory. The pointer should "
                "be explicitly set to NULL instead.\n",
                calling_function);
        exit(EXIT_FAILURE);
    }

    void* memory = malloc(size);
    if (!memory)
    {
        fprintf(stderr, "Error allocating memory: The function %s called "
                "'safe_malloc' requesting %zu bytes of memory, but an error "
                "occurred allocating this amount of memory.\n",
                calling_function, size);
        exit(EXIT_FAILURE);
    }
    memory = memset(memory, 0, size);
    return memory;
}

void safe_free_function(void** pointer_address)
{
    if (pointer_address != NULL)
    {
        free(*pointer_address);
        *pointer_address = NULL;
    }
}

Add newline to error message in safe_malloc.

The message that is printed when safe_malloc fails to allocate memory was missing a newline character.


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

#include "supervisor/board.h"
#include "mpconfigboard.h"
#include "hal/include/hal_gpio.h"

void board_init(void) {
}

bool board_requests_safe_mode(void) {
    return false;
}

void reset_board(void) {
}

void board_deinit(void) {
}

Add Cytron Maker Zero SAMD21

Add Cytron Maker Zero SAMD21


/*
 * This file is part of libbdplus
 * Copyright (C) 2015  VideoLAN
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 */

#ifndef FILE_DEFAULT_H_
#define FILE_DEFAULT_H_

#include "filesystem.h"

#include "util/attributes.h"

BD_PRIVATE BDPLUS_FILE_H *file_open_default(void *root_path, const char *file_name);

#endif /* FILE_DEFAULT_H_ */

/*
 * This file is part of libbdplus
 * Copyright (C) 2015  VideoLAN
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 */

#ifndef FILE_DEFAULT_H_
#define FILE_DEFAULT_H_

#include "util/attributes.h"

struct bdplus_file;
BD_PRIVATE struct bdplus_file *file_open_default(void *root_path, const char *file_name);

#endif /* FILE_DEFAULT_H_ */

Replace include with forward declaration


#pragma once

#include "AbsWrapperCodec.h"
#include "AddWrapperCodec.h"
#include "BillowWrapperCodec.h"
#include "BlendWrapperCodec.h"
#include "CacheWrapperCodec.h"
#include "CheckerboardWrapperCodec.h"
#include "ClampWrapperCodec.h"
#include "ConstWrapperCodec.h"
#include "CurveWrapperCodec.h"
#include "CylindersWrapperCodec.h"
#include "DisplaceWrapperCodec.h"
#include "ExponentWrapperCodec.h"
#include "InvertWrapperCodec.h"
#include "MaxWrapperCodec.h"
#include "MinWrapperCodec.h"
#include "MultiplyWrapperCodec.h"
#include "NoiseSourcesCodec.h"
#include "PerlinWrapperCodec.h"
#include "PowerWrapperCodec.h"
#include "RidgedMultiWrapperCodec.h"
#include "RotatePointWrapperCodec.h"
#include "ScaleBiasWrapperCodec.h"
#include "ScalePointCodec.h"
#include "SelectWrapperCodec.h"
#include "SpheresWrapperCodec.h"
#include "TerraceWrapperCodec.h"
#include "TranslatePointWrapperCodec.h"
#include "TurbulenceWrapperCodec.h"
#include "VoronoiWrapperCodec.h"

#pragma once

#include "AbsWrapperCodec.h"
#include "AddWrapperCodec.h"
#include "BillowWrapperCodec.h"
#include "BlendWrapperCodec.h"
#include "CacheWrapperCodec.h"
#include "CheckerboardWrapperCodec.h"
#include "ClampWrapperCodec.h"
#include "ConstWrapperCodec.h"
#include "CornerCombinerBaseWrapperCodec.h"
#include "CurveWrapperCodec.h"
#include "CylindersWrapperCodec.h"
#include "DisplaceWrapperCodec.h"
#include "ExpWrapperCodec.h"
#include "ExponentWrapperCodec.h"
#include "ForwardWrapperCodec.h"
#include "InvertWrapperCodec.h"
#include "MaxWrapperCodec.h"
#include "MinWrapperCodec.h"
#include "MultiplyWrapperCodec.h"
#include "NormLPQWrapperCodec.h"
#include "NoiseSourcesCodec.h"
#include "PerlinWrapperCodec.h"
#include "PowWrapperCodec.h"
#include "PowerWrapperCodec.h"
#include "RidgedMultiWrapperCodec.h"
#include "RotatePointWrapperCodec.h"
#include "ScaleBiasWrapperCodec.h"
#include "ScalePointCodec.h"
#include "SelectWrapperCodec.h"
#include "SpheresWrapperCodec.h"
#include "TerraceWrapperCodec.h"
#include "TranslatePointWrapperCodec.h"
#include "TurbulenceWrapperCodec.h"
#include "VoronoiWrapperCodec.h"

Put new codecs in module codec header

Put new codecs in module codec header


#ifndef APIMOCK_RESPONSEDATA_H
#define APIMOCK_RESPONSEDATA_H

#include <string>

namespace ApiMock {
	struct ResponseData {
		std::string body;
	};
}

#endif

#ifndef APIMOCK_RESPONSEDATA_H
#define APIMOCK_RESPONSEDATA_H

#include <string>
#include <unordered_map>
#include "statuscodes.h"

namespace ApiMock {
	struct ResponseData {
		std::string body;
		std::unordered_map<std::string, std::string> headers;
		HTTP_RESPONSE_CODE statusCode;
	};
}

#endif

Add headers and status code to response

Add headers and status code to response


#import "ArtsyToken.h"
#import "ArtsyAuthentication.h"
#import "ArtsyAuthentication+Facebook.h"
#import "ArtsyAuthentication+Twitter.h"

#import "ArtsyToken.h"
#import "ArtsyAuthentication.h"
#if __has_include("ArtsyAuthentication+Facebook.h")
#import "ArtsyAuthentication+Facebook.h"
#endif
#if __has_include("ArtsyAuthentication+Twitter.h")
#import "ArtsyAuthentication+Twitter.h"
#endif

Use if includes for fb/tiwtter

Use if includes for fb/tiwtter


#include <stdio.h>

#define MAXLINE 81
#define MAXLENGTH 1000

int getline(char line[]);

/* print line longer than 80 characters */

int main(void)
{
    int len;
    char line[MAXLENGTH];

    while ((len = getline(line)) > 0)
        if (len > MAXLINE) {
            printf("%s", line);
    }
return 0;
}

int getline(char s[]) {
    int c, i;

    for (i=0; (c=getchar()) != EOF && c!='\n'; ++i)
        s[i] = c;
    if (c== '\n') {
        s[i] = c;
        ++i;
    }
    s[i] = '\0';
    return i;
}

Print longer than 80 chars

Print longer than 80 chars


#pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_

#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"

namespace You {
namespace DataStore {
namespace UnitTests {}
class Transaction;
class DataStore {
	friend class Transaction;
public:
	static bool begin();

	// Modifying methods
	static bool post(TaskId, SerializedTask&);
	static bool put(TaskId, SerializedTask&);
	static bool erase(TaskId);

	static boost::variant<bool, SerializedTask> get(TaskId);
	static std::vector<SerializedTask>
		filter(const std::function<bool(SerializedTask)>&);
private:
	static DataStore& get();
	bool isServing = false;
	std::deque<Internal::IOperation> operationsQueue;
};
}  // namespace DataStore
}  // namespace You
#endif  // YOU_DATASTORE_DATASTORE_H_

#pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_

#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"

namespace You {
namespace DataStore {
namespace UnitTests {}
class Transaction;
class DataStore {
	friend class Transaction;
public:
	static bool begin();

	// Modifying methods
	static bool post(TaskId, SerializedTask&);
	static bool put(TaskId, SerializedTask&);
	static bool erase(TaskId);

	static std::vector<SerializedTask> getAllTask();
	static std::vector<SerializedTask>
		filter(const std::function<bool(SerializedTask)>&);
private:
	static DataStore& get();
	bool isServing = false;
	std::deque<Internal::IOperation> operationsQueue;
};
}  // namespace DataStore
}  // namespace You
#endif  // YOU_DATASTORE_DATASTORE_H_

Rename get(TaskId) to getAllTask (QueryEngine does not need it)


#include "libmypy.h"

char hellofunc_docs[] = "Hello world description.";

PyMethodDef helloworld_funcs[] = {
	{	"hello",
		(PyCFunction)hello,
		METH_NOARGS,
		hellofunc_docs},
	{	NULL}
};

struct PyModuleDef helloworld_mod = {
	PyModuleDef_HEAD_INIT,
	"helloworld",
	"This is hello world module.",
	-1,
	helloworld_funcs,
	NULL,
	NULL,
	NULL,
	NULL
};

void PyInit_helloworld(void) {
	PyModule_Create(&helloworld_mod);
}

#include "libmypy.h"

char hellofunc_docs[] = "Hello world description.";

PyMethodDef helloworld_funcs[] = {
	{	"hello",
		(PyCFunction)hello,
		METH_NOARGS,
		hellofunc_docs},
	{	NULL}
};

char helloworldmod_docs[] = "This is hello world module.";

PyModuleDef helloworld_mod = {
	PyModuleDef_HEAD_INIT,
	"helloworld",
	helloworldmod_docs,
	-1,
	helloworld_funcs,
	NULL,
	NULL,
	NULL,
	NULL
};

void PyInit_helloworld(void) {
	PyModule_Create(&helloworld_mod);
}

Make the codes in the order.

Make the codes in the order.


#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>

struct termios orig_termios;

void disableRawMode() {
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}

void enableRawMode() {
  tcgetattr(STDIN_FILENO, &orig_termios);
  atexit(disableRawMode);

  struct termios raw = orig_termios;
  raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
  raw.c_oflag &= ~(OPOST);
  raw.c_cflag |= (CS8);
  raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);

  tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}

int main() {
  enableRawMode();

  char c;
  while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q') {
    if (iscntrl(c)) {
      printf("%d\r\n", c);
    } else {
      printf("%d ('%c')\r\n", c, c);
    }
  }
  return 0;
}

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>

struct termios orig_termios;

void disableRawMode() {
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}

void enableRawMode() {
  tcgetattr(STDIN_FILENO, &orig_termios);
  atexit(disableRawMode);

  struct termios raw = orig_termios;
  raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
  raw.c_oflag &= ~(OPOST);
  raw.c_cflag |= (CS8);
  raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
  raw.c_cc[VMIN] = 0;
  raw.c_cc[VTIME] = 1;

  tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}

int main() {
  enableRawMode();

  while (1) {
    char c = '\0';
    read(STDIN_FILENO, &c, 1);
    if (iscntrl(c)) {
      printf("%d\r\n", c);
    } else {
      printf("%d ('%c')\r\n", c, c);
    }
    if (c == 'q') break;
  }
  return 0;
}

Add a timeout for read

Add a timeout for read


#ifndef MUTATION_RATE_GENE_H
#define MUTATION_RATE_GENE_H

#include "Gene.h"

#include <string>
#include <memory>
#include <map>

#include "Game/Color.h"

//! The gene controls how much of the genome mutates per Genome::mutate() event.
class Mutation_Rate_Gene : public Gene
{
    public:
        std::string name() const noexcept override;

        //! Controls how many changes a call to Genome::mutate() makes to the Gene collections.
        //
        //! \returns An integer number that determines the number of point mutations the Genome::mutate() makes.
        int mutation_count() const noexcept;

        void gene_specific_mutation() noexcept override;
        std::unique_ptr<Gene> duplicate() const noexcept override;

    protected:
        std::map<std::string, double> list_properties() const noexcept override;
        void load_properties(const std::map<std::string, double>& properties) override;

    private:
        double mutated_components_per_mutation = 100.0;

        double score_board(const Board& board, Color perspective, size_t prior_real_moves) const noexcept override;
};

#endif // MUTATION_RATE_GENE_H

#ifndef MUTATION_RATE_GENE_H
#define MUTATION_RATE_GENE_H

#include "Gene.h"

#include <string>
#include <memory>
#include <map>

#include "Game/Color.h"

//! The gene controls how much of the genome mutates per Genome::mutate() event.
class Mutation_Rate_Gene : public Gene
{
    public:
        std::string name() const noexcept override;

        //! Controls how many changes a call to Genome::mutate() makes to the Gene collections.
        //
        //! \returns An integer number that determines the number of point mutations the Genome::mutate() makes.
        int mutation_count() const noexcept;

        void gene_specific_mutation() noexcept override;
        std::unique_ptr<Gene> duplicate() const noexcept override;

    protected:
        std::map<std::string, double> list_properties() const noexcept override;
        void load_properties(const std::map<std::string, double>& properties) override;

    private:
        double mutated_components_per_mutation = 1.0;

        double score_board(const Board& board, Color perspective, size_t prior_real_moves) const noexcept override;
};

#endif // MUTATION_RATE_GENE_H

Reduce initial number of mutations

Reduce initial number of mutations


//
//  Constants.h
//  yamiHikariGame
//
//  Created by slightair on 2013/07/28.
//
//

#ifndef yamiHikariGame_Constants_h
#define yamiHikariGame_Constants_h

#define SpriteSheetImageFileName "spriteSheet.pvr.ccz"
#define DefaultFontName "mosamosa"
#define DefaultFontSize 24

#define StaminaMax 1000

#define SEItemGet "SE001.mp3"
#define SEGameOver "SE002.mp3"
#define SEBadItemGet "SE004.mp3"
#define SoundEffectVolume 0.15

#endif

//
//  Constants.h
//  yamiHikariGame
//
//  Created by slightair on 2013/07/28.
//
//

#ifndef yamiHikariGame_Constants_h
#define yamiHikariGame_Constants_h

#define SpriteSheetImageFileName "spriteSheet.pvr.ccz"
#define DefaultFontName "mosamosa.ttf"
#define DefaultFontSize 24

#define StaminaMax 1000

#define SEItemGet "SE001.mp3"
#define SEGameOver "SE002.mp3"
#define SEBadItemGet "SE004.mp3"
#define SoundEffectVolume 0.15

#endif

Fix to Use specified Font mosamosa.

Fix to Use specified Font mosamosa.


#ifndef GRAPH_H
#define GRAPH_H

#include <unordered_map>
#include <unordered_set>

template<typename T>
class Graph {

public:
    void connect(const T &a, const T &b);
    const std::unordered_set<T>& get_vertex_ids() const;

    inline const std::unordered_set<T>& get_neighbors(const T &vertex_id) const {
        return vertices_.at(vertex_id)->adjacent_ids_;
    }

    ~Graph();

private:
    struct Vertex {
        T id_;
        std::unordered_set<Vertex*> adjacent_;
        std::unordered_set<T> adjacent_ids_;

        Vertex(const T &id) : id_(id) {}

        bool has_neighbor(Vertex *v) const {
            return adjacent_.find(v) != adjacent_.end();
        }

        void add_neighbor(Vertex* v) {
            adjacent_.insert(v);
            adjacent_ids_.insert(v->id_);
        }
    };

    std::unordered_map<T, Vertex*> vertices_;
    std::unordered_set<T> vertex_ids;

    Vertex* get_vertex(const T &a) const;
    Vertex* get_or_insert(const T &a);
};

template class Graph<int>;

#endif

#ifndef GRAPH_H
#define GRAPH_H

#include <unordered_map>
#include <unordered_set>

template<typename T>
class Graph {

public:
    void connect(const T &a, const T &b);
    const std::unordered_set<T>& get_vertex_ids() const;

    inline const std::unordered_set<T>& get_neighbors(const T &vertex_id) const {
        return vertices_.at(vertex_id)->adjacent_ids_;
    }

    ~Graph();

private:
    struct Vertex {
        T id_;
        std::unordered_set<Vertex*> adjacent_;
        std::unordered_set<T> adjacent_ids_;

        Vertex(const T &id) : id_(id) {}

        bool has_neighbor(Vertex *v) const {
            return adjacent_.find(v) != adjacent_.end();
        }

        void add_neighbor(Vertex* v) {
            adjacent_.insert(v);
            adjacent_ids_.insert(v->id_);
        }
    };

    std::unordered_map<T, Vertex*> vertices_;
    std::unordered_set<T> vertex_ids;

    std::unordered_map<T, int> alias_id;
    std::vector<int> reverse_mapping;

    Vertex* get_vertex(const T &a) const;
    Vertex* get_or_insert(const T &a);
};

template class Graph<int>;

#endif

Add initial data structures for mapping

Add initial data structures for mapping


/* mbed Microcontroller Library
 * Copyright (c) 2018 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.
 */

#ifndef MBED_NFC_CONTROLLER_DRIVER_H
#define MBED_NFC_CONTROLLER_DRIVER_H

#include <stdint.h>
#include "events/EventQueue.h"

#include "stack/nfc_errors.h"
#include "stack/transceiver/transceiver.h"
#include "stack/platform/scheduler.h"

namespace mbed {
namespace nfc {

    struct NFCControllerDriver {
        virtual void initialize(scheduler_timer_t* pTimer) = 0;
        virtual transceiver_t* get_transceiver() const = 0;
    };

} // namespace nfc
} // namespace mbed

#endif

/* mbed Microcontroller Library
 * Copyright (c) 2018 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.
 */

#ifndef MBED_NFC_CONTROLLER_DRIVER_H
#define MBED_NFC_CONTROLLER_DRIVER_H

#include <stdint.h>
#include "events/EventQueue.h"

#include "stack/nfc_errors.h"
#include "stack/transceiver/transceiver.h"
#include "stack/platform/scheduler.h"

namespace mbed {
namespace nfc {

    struct NFCControllerDriver {
        virtual void initialize(scheduler_timer_t* pTimer) = 0;
        virtual transceiver_t* get_transceiver() const = 0;
        virtual nfc_rf_protocols_bitmask_t get_supported_rf_protocols() const = 0;
    };

} // namespace nfc
} // namespace mbed

#endif

Add get_supported_rf_protocols() method to driver


/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
 * by the Xiph.Org Foundation http://www.xiph.org/                  *
 *                                                                  *
 ********************************************************************

  function:
    last mod: $Id$

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

#if !defined(_quant_H)
# define _quant_H (1)
# include "theora/codec.h"
# include "ocintrin.h"

typedef ogg_uint16_t   oc_quant_table[64];
typedef oc_quant_table oc_quant_tables[64];

/*Maximum scaled quantizer value.*/
#define OC_QUANT_MAX          (1024<<2)

/*Minimum scaled DC coefficient frame quantizer value for intra and inter
   modes.*/
extern unsigned OC_DC_QUANT_MIN[2];
/*Minimum scaled AC coefficient frame quantizer value for intra and inter
   modes.*/
extern unsigned OC_AC_QUANT_MIN[2];

void oc_dequant_tables_init(oc_quant_table *_dequant[2][3],
 int _pp_dc_scale[64],const th_quant_info *_qinfo);

#endif

/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
 *                                                                  *
 * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
 * by the Xiph.Org Foundation http://www.xiph.org/                  *
 *                                                                  *
 ********************************************************************

  function:
    last mod: $Id$

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

#if !defined(_quant_H)
# define _quant_H (1)
# include "theora/codec.h"
# include "ocintrin.h"

typedef ogg_uint16_t   oc_quant_table[64];
typedef oc_quant_table oc_quant_tables[64];

/*Maximum scaled quantizer value.*/
#define OC_QUANT_MAX          (1024<<2)

void oc_dequant_tables_init(oc_quant_table *_dequant[2][3],
 int _pp_dc_scale[64],const th_quant_info *_qinfo);

#endif

Remove extern references for OC_*_QUANT_MIN.

These were exported for the use of the theora-exp encoder and are not
needed in trunk. Part of a patch from issue 1297.

git-svn-id: 8dbf393e6e9ab8d4979d29f9a341a98016792aa6@15322 0101bb08-14d6-0310-b084-bc0e0c8e3800


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

/* MCHP MEC specific ADC module for Chrome EC */

#ifndef __CROS_EC_ADC_CHIP_H
#define __CROS_EC_ADC_CHIP_H

/* Data structure to define ADC channels. */
struct adc_t {
	const char *name;
	int factor_mul;
	int factor_div;
	int shift;
	int channel;
};

/*
 * Boards must provide this list of ADC channel definitions.
 * This must match the enum adc_channel list provided by the board.
 */
extern const struct adc_t adc_channels[];

/* Minimum and maximum values returned by adc_read_channel(). */
#define ADC_READ_MIN 0
#define ADC_READ_MAX 1023

/* Just plain id mapping for code readability */
#define MCHP_ADC_CH(x) (x)

#endif /* __CROS_EC_ADC_CHIP_H */

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

/* MCHP MEC specific ADC module for Chrome EC */

#ifndef __CROS_EC_ADC_CHIP_H
#define __CROS_EC_ADC_CHIP_H

/* Data structure to define ADC channels. */
struct adc_t {
	const char *name;
	int factor_mul;
	int factor_div;
	int shift;
	int channel;
};

/* List of ADC channels */
enum chip_adc_channel {
	CHIP_ADC_CH0 = 0,
	CHIP_ADC_CH1,
	CHIP_ADC_CH2,
	CHIP_ADC_CH3,
	CHIP_ADC_CH4,
	CHIP_ADC_CH5,
	CHIP_ADC_CH6,
	CHIP_ADC_CH7,
	CHIP_ADC_COUNT,
};

/*
 * Boards must provide this list of ADC channel definitions.
 * This must match the enum adc_channel list provided by the board.
 */
extern const struct adc_t adc_channels[];

/* Minimum and maximum values returned by adc_read_channel(). */
#define ADC_READ_MIN 0
#define ADC_READ_MAX 1023

/* Just plain id mapping for code readability */
#define MCHP_ADC_CH(x) (x)

#endif /* __CROS_EC_ADC_CHIP_H */

Add ADC channel enumeration to chip

mchp: Add ADC channel enumeration to chip

Add a chip level ADC channel enumerated type.

BRANCH=none
BUG=b:177463787
TEST=Booted skylake RVP to Chrome OS

Signed-off-by: Scott Worley <186210b307f58d6c0a191337b635ed93ad075837@microchip.corp-partner.google.com>
Change-Id: If30a71698b1d084380c6695e4c4b8921f5b8eec2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2673019
Reviewed-by: Ravin Kumar <a0e97d6aca75c950342a3a8ebb8bd1c89d88be3e@microchip.com>
Reviewed-by: Aseda Aboagye <12c9b286316a940fd31c24070da5ab64cdd4d0e7@chromium.org>
Tested-by: Ravin Kumar <a0e97d6aca75c950342a3a8ebb8bd1c89d88be3e@microchip.com>


// PARAM: --disable ana.int.def_exc --enable ana.int.interval
// Ensures that the cast_to function handles casting for congruences correctly.
// TODO: Implement appropriate cast_to function, enable for congruences only and adjust test if necessary.
#include <assert.h>
#include <stdio.h>

int main(){
  int c = 128;
  for (int i = 0; i < 1; i++) {
      c = c - 150;
   }
  char k = (char) c;
  printf ("k: %d", k);
  assert (k == -22); //UNKNOWN

  k = k + 150;
  assert (k == 0); //UNKNOWN!

}

Add (deactivated) casting test for congruence domain


#ifndef _CONCAT_H_
#define _CONCAT_H_

/// Utitilies to make a unique variable name.
#define CONCAT_LINE(x) CONCAT(x, __LINE__)
#define CONCAT(a, b) CONCAT_INDIRECT(a, b)
#define CONCAT_INDIRECT(a, b) a ## b

#endif

#ifndef _CONCAT_H_
#define _CONCAT_H_

/// Utitilies to make a unique variable name.
#define CONCAT_LINE(x) CONCAT(x ## _foreach__, __LINE__)
#define CONCAT(a, b) CONCAT_INDIRECT(a, b)
#define CONCAT_INDIRECT(a, b) a ## b

#endif

Fix a __i386 bug in gcc

Fix a __i386 bug in gcc

In gcc, __i386 has special meaning for i386 CPU.
So we should avoid use __i386 as variable name.


#pragma once

#include <Windows.h>
#include "../Logger.h"
#include <math.h>
#include <algorithm>

#include <dwmapi.h>
#pragma comment(lib, "Dwmapi.lib")

class SystemColors {

    struct DWMColorizationParams {
        UINT ColorizationColor;
        UINT ColorizationAfterglow;
        UINT ColorizationColorBalance;
        UINT ColorizationAfterglowBalance;
        UINT ColorizationBlurBalance;
        UINT ColorizationGlassReflectionIntensity;
        UINT ColorizationOpaqueBlend;
    };

public:
    SystemColors() {
        HMODULE dwm = LoadLibrary(L"dwmapi.dll");
        HRESULT(WINAPI *DwmGetColorizationParameters) (DWMColorizationParams *colorparam);
        *(FARPROC *) &DwmGetColorizationParameters = GetProcAddress(dwm, (LPCSTR) 127);
        DWMColorizationParams params;
        DwmGetColorizationParameters(&params);

        CLOG(L"-> %x", params.ColorizationColor);
        CLOG(L"-> %x", params.ColorizationAfterglow);
        CLOG(L"-> %d", params.ColorizationColorBalance);
        CLOG(L"-> %d", params.ColorizationAfterglowBalance);
        CLOG(L"-> %x", params.ColorizationBlurBalance);
        CLOG(L"-> %x", params.ColorizationGlassReflectionIntensity);
        CLOG(L"-> %x", params.ColorizationOpaqueBlend);

        COLORREF base = RGB(217, 217, 217);

        DWORD val;
        BOOL opaque;
        DwmGetColorizationColor(&val, &opaque);

        CLOG(L"=> %x", val);

    }

};

Add class for retrieving system color scheme settings


//This Source Code Form is subject to the terms of the Mozilla Public
//License, v. 2.0. If a copy of the MPL was not distributed with this
//file, You can obtain one at http://mozilla.org/MPL/2.0/.

#pragma once

#include <stddef.h>
#include <string.h>

#include "Common.h"

namespace ej {

//! Represents a view on a list of C strings packed in an array
template <typename T = const char, size_t ALIGNMENT = alignof(T)>
class CStringsView {
public:
	typedef T value_type;
	typedef size_t size_type;

	static_assert((ALIGNMENT & (ALIGNMENT - 1)) == 0 && ALIGNMENT >= alignof(value_type));

private:
	value_type *Start;
	value_type *Finish;

public:
	constexpr CStringsView() noexcept : Start(nullptr), Finish(nullptr) {
	}
	constexpr CStringsView(value_type *start, value_type *finish) noexcept : Start(start), Finish(finish) {
	}
	template <size_t N>
	constexpr CStringsView(value_type (&a)[N]) noexcept : Start(a), Finish(a + N) {
	}

	constexpr void assign(value_type *start, value_type *finish) noexcept {
		Start = start;
		Finish = finish;
	}

	template <size_t N>
	constexpr void assign(value_type (&a)[N]) noexcept {
		assign(a, a + N);
	}

	constexpr size_type size() const noexcept {
		size_type n = 0;
		for (auto iter = Start, end = Finish; iter < end;) {
			auto length = strlen(iter);

			iter += length + 1;
			if constexpr (ALIGNMENT != alignof(value_type)) {
				iter = reinterpret_cast<value_type *>(((reinterpret_cast<uintptr_t>(iter) + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT);
			}
			n++;
		}
		return n;
	}

	constexpr bool empty() const noexcept {
		return Start == Finish;
	}

	template <typename Function>
	EJ_ALWAYS_INLINE void for_each(Function f) const noexcept {
		for (auto iter = Start, end = Finish; iter < end;) {
			auto n = strlen(iter);
			f(iter, n);

			iter += n + 1;
			if constexpr (ALIGNMENT != alignof(value_type)) {
				iter = reinterpret_cast<value_type *>(((reinterpret_cast<uintptr_t>(iter) + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT);
			}
		}
	}
};

}

Add a view for a packed array of C strings.


// Check that calling dispatch_once from a report callback works.

// RUN: %clang_tsan %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <dispatch/dispatch.h>

#include <pthread.h>
#include <stdio.h>

long g = 0;
long h = 0;
void f() {
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    g++;
  });
  h++;
}

void __tsan_on_report() {
  fprintf(stderr, "Report.\n");
  f();
}

int main() {
  fprintf(stderr, "Hello world.\n");

  f();

  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  pthread_mutex_unlock(&mutex); // Unlock of an unlocked mutex

  fprintf(stderr, "g = %ld.\n", g);
  fprintf(stderr, "h = %ld.\n", h);
  fprintf(stderr, "Done.\n");
}

// CHECK: Hello world.
// CHECK: Report.
// CHECK: g = 1
// CHECK: h = 2
// CHECK: Done.

// Check that calling dispatch_once from a report callback works.

// RUN: %clang_tsan %s -o %t
// RUN: not %env_tsan_opts=ignore_noninstrumented_modules=0 %run %t 2>&1 | FileCheck %s

#include <dispatch/dispatch.h>

#include <pthread.h>
#include <stdio.h>

long g = 0;
long h = 0;
void f() {
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    g++;
  });
  h++;
}

void __tsan_on_report() {
  fprintf(stderr, "Report.\n");
  f();
}

int main() {
  fprintf(stderr, "Hello world.\n");

  f();

  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  pthread_mutex_unlock(&mutex); // Unlock of an unlocked mutex

  fprintf(stderr, "g = %ld.\n", g);
  fprintf(stderr, "h = %ld.\n", h);
  fprintf(stderr, "Done.\n");
}

// CHECK: Hello world.
// CHECK: Report.
// CHECK: g = 1
// CHECK: h = 2
// CHECK: Done.

Fix test failing on Linux

[TSan] Fix test failing on Linux

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


/* mbed Microcontroller Library
 * Copyright (c) 2015-2017 Nuvoton
 *
 * 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.
 */

#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H

#include "NANO100Series.h"
#include "cmsis_nvic.h"

// Support linker-generated symbol as start of relocated vector table.
#if defined(__CC_ARM)
extern uint32_t Image$$ER_IRAMVEC$$ZI$$Base;
#elif defined(__ICCARM__)

#elif defined(__GNUC__)
extern uint32_t __start_vector_table__;
#endif

#endif

/* mbed Microcontroller Library
 * Copyright (c) 2015-2017 Nuvoton
 *
 * 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.
 */

#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H

#include "Nano100Series.h"
#include "cmsis_nvic.h"

// Support linker-generated symbol as start of relocated vector table.
#if defined(__CC_ARM)
extern uint32_t Image$$ER_IRAMVEC$$ZI$$Base;
#elif defined(__ICCARM__)

#elif defined(__GNUC__)
extern uint32_t __start_vector_table__;
#endif

#endif

[NANO130] Fix the file name case problem for building code in Linux system


#include "unity.h"
#include "cpuid.h"

void test_GetVendorName_should_ReturnGenuineIntel(void) {
  char expected[20] = "GenuineIntel";

  char actual[20];
  get_vendor_name(actual);

  TEST_ASSERT_EQUAL_STRING(expected, actual);
}

void test_GetVendorSignature_should_asdf(void) {
  uint32_t exp_ebx = 0x756e6547; // translates to "Genu"
  uint32_t exp_ecx = 0x6c65746e; // translates to "ineI"
  uint32_t exp_edx = 0x49656e69; // translates to "ntel"

  cpuid_info_t sig;
  sig = get_vendor_signature();

  TEST_ASSERT_EQUAL_UINT32(exp_ebx, sig.ebx);
  TEST_ASSERT_EQUAL_UINT32(exp_ecx, sig.ecx);
  TEST_ASSERT_EQUAL_UINT32(exp_edx, sig.edx);
}

void test_GetProcessorSignature_should_ReturnFamily6(void) {
  unsigned int expected = 0x6;

  unsigned int family;
  uint32_t processor_signature = get_processor_signature();
  family = (processor_signature >> 8) & 0xf;

  TEST_ASSERT_EQUAL_UINT(expected, family);
}

#include "unity.h"
#include "cpuid.h"

void test_GetVendorName_should_ReturnGenuineIntel(void) {
  char expected[20] = "GenuineIntel";

  char actual[20];
  get_vendor_name(actual);

  TEST_ASSERT_EQUAL_STRING(expected, actual);
}

void test_GetVendorSignature_should_ReturnCorrectCpuIdValues(void) {
  uint32_t exp_ebx = 0x756e6547; // translates to "Genu"
  uint32_t exp_ecx = 0x6c65746e; // translates to "ineI"
  uint32_t exp_edx = 0x49656e69; // translates to "ntel"

  cpuid_info_t sig;
  sig = get_vendor_signature();

  TEST_ASSERT_EQUAL_UINT32(exp_ebx, sig.ebx);
  TEST_ASSERT_EQUAL_UINT32(exp_ecx, sig.ecx);
  TEST_ASSERT_EQUAL_UINT32(exp_edx, sig.edx);
}

void test_GetProcessorSignature_should_ReturnFamily6(void) {
  unsigned int expected = 0x6;

  unsigned int family;
  uint32_t processor_signature = get_processor_signature();
  family = (processor_signature >> 8) & 0xf;

  TEST_ASSERT_EQUAL_UINT(expected, family);
}

Change method-name to something more appropriate


/*
 * print_helpers.h
 *
 *  Created on: Nov 29, 2014
 *      Author: Konstantin Gredeskoul
 *        Code: https://github.com/kigster
 *
 *  (c) 2014 All rights reserved, MIT License.
 */

#ifndef printv
#define printv(X,Y) (Serial.print(X) || Serial.println(Y))
#endif

#ifndef _printf
#define _printf(X,Y) (Serial.printf(X, Y))
#endif

Add probably useless _printf(x,y) macro

Add probably useless _printf(x,y) macro


/* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */

/**********************************************************
*      This software is part of the graphviz package      *
*                http://www.graphviz.org/                 *
*                                                         *
*            Copyright (c) 1994-2004 AT&T Corp.           *
*                and is licensed under the                *
*            Common Public License, Version 1.0           *
*                      by AT&T Corp.                      *
*                                                         *
*        Information and Software Systems Research        *
*              AT&T Research, Florham Park NJ             *
**********************************************************/

#ifdef __cplusplus
extern "C" {
#endif

/* Lefteris Koutsofios - AT&T Bell Laboratories */

#ifndef _PARSE_H
#define _PARSE_H
    typedef struct Psrc_t {
	int flag;
	char *s;
	FILE *fp;
	int tok;
	int lnum;
    } Psrc_t;

    void Pinit(void);
    void Pterm(void);
    Tobj Punit(Psrc_t *);
    Tobj Pfcall(Tobj, Tobj);
    Tobj Pfunction(char *, int);
#endif				/* _PARSE_H */

#ifdef __cplusplus
}
#endif

/* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */

/**********************************************************
*      This software is part of the graphviz package      *
*                http://www.graphviz.org/                 *
*                                                         *
*            Copyright (c) 1994-2004 AT&T Corp.           *
*                and is licensed under the                *
*            Common Public License, Version 1.0           *
*                      by AT&T Corp.                      *
*                                                         *
*        Information and Software Systems Research        *
*              AT&T Research, Florham Park NJ             *
**********************************************************/

#ifdef __cplusplus
extern "C" {
#endif

/* Lefteris Koutsofios - AT&T Labs Research */

#ifndef _PARSE_H
#define _PARSE_H
typedef struct Psrc_t {
    int flag;
    char *s;
    FILE *fp;
    int tok;
    int lnum;
} Psrc_t;

void Pinit (void);
void Pterm (void);
Tobj Punit (Psrc_t *);
Tobj Pfcall (Tobj, Tobj);
Tobj Pfunction (char *, int);
#endif /* _PARSE_H */

#ifdef __cplusplus
}
#endif

Update with new lefty, fixing many bugs and supporting new features


#include<stdio.h>

long long int fibonacci(long long int n)
{
	//Because first fibonacci number is 0 and second fibonacci number is 1.
	if(n==1 || n==2)
	{
		return (n-1);
	}
	else
	{
		//store last fibonacci number
		long long int a=1;
		//store second last fibonacci number
		long long int b=0;
		//store current fibonacci number
		long long int nth_Fib;
		for(long long int i=3;i<=n;i++)
		{
			nth_Fib = a+b;
			b = a;
			a = nth_Fib;
		}
		return nth_Fib;
	}
}

int main()
{
	long long int n;
	printf("Enter a Number : ");
	scanf("%lli",&n);
	if(n<1)
	{
		printf("Number must be greater than 0");
	}
	else
	{
		long long int nth_Fib = fibonacci(n);
		printf("Fibonacci Number is %lli",nth_Fib);
	}
	return 0;
}

Add Code For nth Fibonacci Number in c

Add Code For nth Fibonacci Number in c


#ifndef FIX_LIMITS_H
#define FIX_LIMITS_H

#if defined(HPUX9)
#   define select _hide_select
#endif

#include <limits.h>

#if defined(HPUX9)
#   undef select
#endif

#endif

Hide the system's version of the prototype for select(). We define it in "condor_fdset.h".


@import Foundation;

#import "HYPFormField.h"

@interface HYPFormsManager : NSObject

@property (nonatomic, strong) NSMutableArray *forms;
@property (nonatomic, strong) NSMutableDictionary *hiddenFields;
@property (nonatomic, strong) NSMutableDictionary *hiddenSections;
@property (nonatomic, strong) NSArray *disabledFieldsIDs;
@property (nonatomic, strong) NSMutableDictionary *values;

- (instancetype)initWithJSON:(id)JSON
               initialValues:(NSDictionary *)initialValues
            disabledFieldIDs:(NSArray *)disabledFieldIDs
                    disabled:(BOOL)disabled;

- (instancetype)initWithForms:(NSMutableArray *)forms
                initialValues:(NSDictionary *)initialValues;

- (NSArray *)invalidFormFields;

- (NSDictionary *)requiredFormFields;

- (NSMutableDictionary *)valuesForFormula:(HYPFormField *)field;

- (HYPFormField *)fieldWithID:(NSString *)fieldID
                withIndexPath:(BOOL)withIndexPath;

- (HYPFormField *)fieldWithID:(NSString *)fieldID
                withIndexPath:(BOOL)withIndexPath
                      inForms:(NSArray *)forms;

@end

@import Foundation;

#import "HYPFormField.h"

@interface HYPFormsManager : NSObject

@property (nonatomic, strong) NSMutableArray *forms;
@property (nonatomic, strong) NSMutableDictionary *hiddenFields;
@property (nonatomic, strong) NSMutableDictionary *hiddenSections;
@property (nonatomic, strong) NSArray *disabledFieldsIDs;
@property (nonatomic, strong) NSMutableDictionary *values;

- (instancetype)initWithJSON:(id)JSON
               initialValues:(NSDictionary *)initialValues
            disabledFieldIDs:(NSArray *)disabledFieldIDs
                    disabled:(BOOL)disabled;

- (instancetype)initWithForms:(NSMutableArray *)forms
                initialValues:(NSDictionary *)initialValues;

- (NSArray *)invalidFormFields;

- (NSDictionary *)requiredFormFields;

- (NSMutableDictionary *)valuesForFormula:(HYPFormField *)field;

- (HYPFormField *)fieldWithID:(NSString *)fieldID
                withIndexPath:(BOOL)withIndexPath;

@end

Remove fieldWithID:withIndexPath:inForms: from public header


#ifndef VRPSOLVER_CUSTOMER_H
#define VRPSOLVER_CUSTOMER_H

namespace VrpSolver {

    class Customer {
    public:
        Customer(unsigned int id, std::size_t demand)
            : id_(id), demand_(demand) {}

        unsigned int id() const {
            return id_;
        }

        std::size_t demand() const {
            return demand_;
        }

    private:
        Customer();
        unsigned int id_;
        std::size_t demand_;
    };

} // namespace VrpSolver

#endif // VRPSOLVER_CUSTOMER_H

#ifndef VRPSOLVER_CUSTOMER_H
#define VRPSOLVER_CUSTOMER_H

namespace VrpSolver {

    class Customer {
    public:
        Customer(std::size_t id, std::size_t demand)
            : id_(id), demand_(demand) {}

        std::size_t id() const {
            return id_;
        }

        std::size_t demand() const {
            return demand_;
        }

    private:
        Customer();
        std::size_t id_;
        std::size_t demand_;
    };

} // namespace VrpSolver

#endif // VRPSOLVER_CUSTOMER_H

Change the type of Customer::id to std::size_t


//
//  PBRequest.h
//  Pbind <https://github.com/wequick/Pbind>
//
//  Created by galen on 15/2/12.
//  Copyright (c) 2015-present, Wequick.net. All rights reserved.
//
//  This source code is licensed under the MIT-style license found in the
//  LICENSE file in the root directory of this source tree.
//

#import <Foundation/Foundation.h>

/**
 An instance of PBRequest defines the base factors of fetching a data.

 @discussion Cause the private ProtocolBuffer.framework use the same class name,
 we had to rename it as _PBRequest, but owe to the ability of `@compatibility_alias` annotation,
 we can also use PBRequest in our source code.
 */
@interface _PBRequest : NSObject

@property (nonatomic, strong) NSString *action; // Interface action.
@property (nonatomic, strong) NSString *method; // Interface action.
@property (nonatomic, strong) NSDictionary *params; // Major params.
@property (nonatomic, strong) NSDictionary *extParams; // Minor params.

/**
 Whether the response data should be mutable, default is NO.

 @discussion if set to YES then will convert all the response data from NSDictionary to PBDictionary in nested.
 */
@property (nonatomic, assign) BOOL requiresMutableResponse;

@end

@compatibility_alias PBRequest _PBRequest;

//
//  PBRequest.h
//  Pbind <https://github.com/wequick/Pbind>
//
//  Created by galen on 15/2/12.
//  Copyright (c) 2015-present, Wequick.net. All rights reserved.
//
//  This source code is licensed under the MIT-style license found in the
//  LICENSE file in the root directory of this source tree.
//

#import <Foundation/Foundation.h>

/**
 An instance of PBRequest defines the base factors of fetching a data.

 @discussion Cause the private ProtocolBuffer.framework use the same class name,
 we had to rename it as _PBRequest, but owe to the ability of `@compatibility_alias` annotation,
 we can also use PBRequest in our source code.
 */
@interface _PBRequest : NSObject

/**
 The API name for the request.
 */
@property (nonatomic, strong) NSString *action;

/**
 The method for the request which defined in RESTFul way.

 @discussion Include:
 - get
 - post
 - put
 - patch
 - delete
 */
@property (nonatomic, strong) NSString *method;

/**
 The parameters for the request.
 */
@property (nonatomic, strong) NSDictionary *params;

/**
 Whether the response data should be mutable, default is NO.

 @discussion if set to YES then will convert all the response data from NSDictionary to PBDictionary in nested.
 */
@property (nonatomic, assign) BOOL requiresMutableResponse;

@end

@compatibility_alias PBRequest _PBRequest;

Add comments for header file

Add comments for header file


#ifndef __MY_PARAMETERS_H__
#define __MY_PARAMETERS_H__

#define USE_GCLOCK
#define PER_CPU

const int AIO_DEPTH_PER_FILE = 32;

const int IO_QUEUE_SIZE = AIO_DEPTH_PER_FILE * 5;
const int MAX_FETCH_REQS = AIO_DEPTH_PER_FILE;
const int MSG_SEND_BUF_SIZE = 10;

/**
 * The number of requests issued by user applications
 * in one access.
 */
const int NUM_REQS_BY_USER = 100;

/**
 * The initial size of the queue for pending IO requests
 * in the global cache.
 */
const int INIT_GCACHE_PENDING_SIZE = NUM_REQS_BY_USER * 10;

/**
 * The min size of IO vector allocated for an IO request..
 */
const int MIN_NUM_ALLOC_IOVECS = 16;
const int NUM_EMBEDDED_IOVECS = 1;

/**
 * The maximal size of IO vector issued by the global cache.
 * The experiment shows AIO with 16 pages in a request can achieve
 * the best performance.
 */
const int MAX_NUM_IOVECS = 16;

#endif

#ifndef __MY_PARAMETERS_H__
#define __MY_PARAMETERS_H__

#define USE_GCLOCK
#define PER_CPU

const int AIO_DEPTH_PER_FILE = 32;

const int IO_QUEUE_SIZE = AIO_DEPTH_PER_FILE * 5;
const int MAX_FETCH_REQS = AIO_DEPTH_PER_FILE;
const int MSG_SEND_BUF_SIZE = 10;

/**
 * The number of requests issued by user applications
 * in one access.
 */
const int NUM_REQS_BY_USER = 100;

/**
 * The initial size of the queue for pending IO requests
 * in the global cache.
 */
const int INIT_GCACHE_PENDING_SIZE = NUM_REQS_BY_USER * 100;

/**
 * The min size of IO vector allocated for an IO request..
 */
const int MIN_NUM_ALLOC_IOVECS = 16;
const int NUM_EMBEDDED_IOVECS = 1;

/**
 * The maximal size of IO vector issued by the global cache.
 * The experiment shows AIO with 16 pages in a request can achieve
 * the best performance.
 */
const int MAX_NUM_IOVECS = 16;

#endif

Increase the default pending IO queue size in global cache.


/*
 *  rbcoremidi.c
 *  rbcoremidi
 *
 *  Created by cypher on 15.07.08.
 *  Copyright 2008 Nuclear Squid. All rights reserved.
 *
 */

#include <ruby.h>

VALUE crbCoreMidi;

void Init_rbcoremidi (void)
{
  // Add the initialization code of your module here.
}

/*
 *  Copyright 2008 Markus Prinz
 *  Released unter an MIT licence
 *
 */

#include <ruby.h>

VALUE crbCoreMidi;

void Init_rbcoremidi (void)
{
  // Add the initialization code of your module here.
}

Update header + licence information

Update header + licence information


#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
    pid_t pid;

    assert(argc > 0);

    if (argc < 2) {
        printf("usage: %s command [arguments...]\n", argv[0]);
        return 1;
    }

    pid = fork();
    if (pid < 0) {
        perror("fork");
        return 1;
    }

    if (pid == 0) {
        execvp(argv[1], argv + 1);
        perror("execvp");
        return 1;
    }

    assert(pid > 0);

    if (wait(NULL) != pid) {
        perror("wait");
        return 1;
    }

    return 0;
}

#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

int
main(int argc, char **argv)
{
    pid_t pid;

    assert(argc > 0);

    if (argc < 2) {
        printf("usage: %s command [arguments...]\n", argv[0]);
        return 1;
    }

    pid = fork();
    if (pid < 0) {
        perror("fork");
        return 1;
    }

    if (pid == 0) {
        execvp(argv[1], argv + 1);
        perror(argv[1]);
        return 1;
    }

    assert(pid > 0);

    if (wait(NULL) != pid) {
        perror("wait");
        return 1;
    }

    return 0;
}

Update execvp error message on file not found


//===--------------------------------------------------------------------------------*- C++ -*-===//
//                          _
//                         | |
//                       __| | __ ___      ___ ___
//                      / _` |/ _` \ \ /\ / / '_  |
//                     | (_| | (_| |\ V  V /| | | |
//                      \__,_|\__,_| \_/\_/ |_| |_| - Compiler Toolchain
//
//
//  This file is distributed under the MIT License (MIT).
//  See LICENSE.txt for details.
//
//===------------------------------------------------------------------------------------------===//

#ifndef DAWN_UNITTEST_UNITTESTLOGGER_H
#define DAWN_UNITTEST_UNITTESTLOGGER_H

#include "dawn/Support/Logging.h"

namespace dawn {

/// @brief Simple logger to std::cout for debugging purposes
class UnittestLogger : public LoggerInterface {
public:
  void log(LoggingLevel level, const std::string& message, const char* file, int line) override;
};

} // namespace dawn

#endif

//===--------------------------------------------------------------------------------*- C++ -*-===//
//                          _
//                         | |
//                       __| | __ ___      ___ ___
//                      / _` |/ _` \ \ /\ / / '_  |
//                     | (_| | (_| |\ V  V /| | | |
//                      \__,_|\__,_| \_/\_/ |_| |_| - Compiler Toolchain
//
//
//  This file is distributed under the MIT License (MIT).
//  See LICENSE.txt for details.
//
//===------------------------------------------------------------------------------------------===//

#ifndef DAWN_UNITTEST_UNITTESTLOGGER_H
#define DAWN_UNITTEST_UNITTESTLOGGER_H

#include "dawn/Support/Logging.h"

namespace dawn {

/// @brief Simple logger to `std::cout` for debugging purposes
/// @ingroup unittest
class UnittestLogger : public LoggerInterface {
public:
  void log(LoggingLevel level, const std::string& message, const char* file, int line) override;
};

} // namespace dawn

#endif

Add unittest to unittest group in doxygen


#pragma once

#include <QObject>
#include <QAbstractItemModel>
#include <QHash>

class SshSFtp;
class SshFilesystemNode;

class SshFilesystemModel : public QAbstractItemModel
{
    SshSFtp *m_provider;
    SshFilesystemNode *m_rootItem;
    QModelIndex m_root;
    QHash<int, QByteArray> m_roles;

public:
    enum Roles {
        FileIconRole = Qt::DecorationRole,
        FilePathRole = Qt::UserRole + 1,
        FileNameRole = Qt::UserRole + 2,
        FilePermissions = Qt::UserRole + 3
    };

    SshFilesystemModel(SshSFtp *provider);

    // Basic functionality:
    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
    QModelIndex parent(const QModelIndex &index) const;
    int rowCount(const QModelIndex &index = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    QHash<int, QByteArray> roleNames() const;

    void setRootPath(QString root = "/");
};

#pragma once

#include <QObject>
#include <QAbstractItemModel>
#include <QHash>

class SshSFtp;
class SshFilesystemNode;

class SshFilesystemModel : public QAbstractItemModel
{
    SshSFtp *m_provider;
    SshFilesystemNode *m_rootItem;
    QModelIndex m_root;
    QHash<int, QByteArray> m_roles;

public:
    enum Roles {
        FileNameRole = Qt::UserRole + 1,
        FilePathRole = Qt::UserRole + 2,
        FileBaseNameRole = Qt::UserRole + 3,
        FileSuffixRole = Qt::UserRole + 4,
        FileSizeRole = Qt::UserRole + 5,
        FileLastModifiedRole = Qt::UserRole + 6,
        FileLastReadRole = Qt::UserRole +7,
        FileIsDirRole = Qt::UserRole + 8,
        FileUrlRole = Qt::UserRole + 9
    };

    SshFilesystemModel(SshSFtp *provider);

    // Basic functionality:
    QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
    QModelIndex parent(const QModelIndex &index) const;
    int rowCount(const QModelIndex &index = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    QHash<int, QByteArray> roleNames() const;

    void setRootPath(QString root = "/");
};

Use same Roles as QQuickFolderListModel

SshFilesystemModel: Use same Roles as QQuickFolderListModel


// THIS FILE IS AUTO GENERATED, EDIT AT YOUR OWN RISK

//% L

#ifndef COMPONENTS_ENTITIES_H_
#define COMPONENTS_ENTITIES_H_

//% L

#include "Components.h"

//% L

{% for component in components %}
    #include "{{component.get_type_name()}}.h"
{% endfor %}

//% L
// Entity definitions
//% L

{% for entity in entities %}

    //% L
    // Definition of {{entity.get_type_name()}}
    //% L

    class {{entity.get_type_name()}}: public Entity {
            //* The vtables for each entities are statically defined
            static const MessageHandler messageHandlers[];
            static const int componentOffsets[];

            //% L

        public:
            //* Default constructor
            {{entity.get_type_name()}}(
                {% for (i, attrib) in enumerate(general.common_entity_attributes) %}
                    {% if i != 0 %}, {% endif %} {{attrib.get_declaration()}}
                {% endfor %}
            );
            virtual ~{{entity.get_type_name()}}();

            //% L

            //* The components
            {% for component in entity.get_components() %}
                {{component.get_type_name()}} {{component.get_variable_name()}};
            {% endfor %}
    };
    //% L
{% endfor %}

//% LL

#endif // COMPONENTS_ENTITIES_H_

//% L

// THIS FILE IS AUTO GENERATED, EDIT AT YOUR OWN RISK

//% L

#ifndef COMPONENTS_ENTITIES_H_
#define COMPONENTS_ENTITIES_H_

//% L

#include "Components.h"
#include "ComponentImplementationInclude.h"

//% L
// Entity definitions
//% L

{% for entity in entities %}

    //% L
    // Definition of {{entity.get_type_name()}}
    //% L

    class {{entity.get_type_name()}}: public Entity {
            //* The vtables for each entities are statically defined
            static const MessageHandler messageHandlers[];
            static const int componentOffsets[];

            //% L

        public:
            //* Default constructor
            {{entity.get_type_name()}}(
                {% for (i, attrib) in enumerate(general.common_entity_attributes) %}
                    {% if i != 0 %}, {% endif %} {{attrib.get_declaration()}}
                {% endfor %}
            );
            virtual ~{{entity.get_type_name()}}();

            //% L

            //* The components
            {% for component in entity.get_components() %}
                {{component.get_type_name()}} {{component.get_variable_name()}};
            {% endfor %}
    };
    //% L
{% endfor %}

//% LL

#endif // COMPONENTS_ENTITIES_H_

//% L

Include the component implementation include helper instead of the individual components in Components.h.


// RUN: %libomp-compile-and-run
#include <stdio.h>

int main()
{

  int i1 = 0;
  int i2 = 1;
  int i3 = 2;
  int i4 = 3;
  int i5 = 4;
  int i6 = 6;
  int i7 = 7;
  int i8 = 8;
  int i9 = 9;
  int i10 = 10;
  int i11 = 11;
  int i12 = 12;
  int i13 = 13;
  int i14 = 14;
  int i15 = 15;
  int i16 = 16;

  int r = 0;
  #pragma omp parallel for firstprivate(i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16) reduction(+:r)
  for (int i = 0; i < i16; i++) {
    r += i + i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 + i9 + i10 + i11 + i12 + i13 + i14 + i15 + i16;
  }

  int rf = 2216;
  if (r != rf) {
    fprintf(stderr, "r should be %d but instead equals %d\n", rf, r);
    return 1;
  }

  return 0;
}

Add a test case for microtask dispatch with many arguments

This is a cleaned-up version of the test case posted in the D19879 review.

git-svn-id: f99161ee8ccfe2101cbe1bdda2220bce2ed25485@270867 91177308-0d34-0410-b5e6-96231b3b80d8


// RUN: %clang_profgen -o %t -O3 %s
// RUN: touch %t.profraw
// RUN: chmod -w %t.profraw
// RUN: env LLVM_PROFILE_FILE=%t.profraw LLVM_PROFILE_VERBOSE_ERRORS=1 %run %t 1 2>&1 | FileCheck %s
// RUN: chmod +w %t.profraw

int main(int argc, const char *argv[]) {
  if (argc < 2)
    return 1;
  return 0;
}
// CHECK: LLVM Profile: Failed to write file

// RUN: %clang_profgen -o %t -O3 %s
// RUN: env LLVM_PROFILE_FILE="/" LLVM_PROFILE_VERBOSE_ERRORS=1 %run %t 1 2>&1 | FileCheck %s

int main(int argc, const char *argv[]) {
  if (argc < 2)
    return 1;
  return 0;
}
// CHECK: LLVM Profile: Failed to write file

[profile] Make a test work if run by the super-user

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


#pragma mark Forward Declarations

@class AFObjectProvider;

#pragma mark Type Definitions

typedef void (^AFObjectUpdateBlock)(AFObjectProvider *provider, id object, NSDictionary *values);

typedef id (^AFObjectCreateBlock)(AFObjectProvider *provider, NSDictionary *values);

#pragma mark - Class Interface

@interface AFObjectModel : NSObject

#pragma mark - Properties

@property (nonatomic, strong) Class myClass;
@property (nonatomic, copy) NSArray *idProperties;

@property (nonatomic, copy) NSDictionary *propertyKeyMap;
@property (nonatomic, copy) NSDictionary *collectionTypeMap;

@property (nonatomic, copy) AFObjectUpdateBlock updateBlock;
@property (nonatomic, copy) AFObjectCreateBlock createBlock;

#pragma mark - Constructors

- (id)initWithClass: (Class)myClass
	idProperties: (NSArray *)idProperties
	propertyKeyMap: (NSDictionary *)propertyKeyMap
	collectionTypeMap: (NSDictionary *)collectionTypeMap
	updateBlock: (AFObjectUpdateBlock)updateBlock
	createBlock: (AFObjectCreateBlock)createBlock;

#pragma mark - Static Methods

+ (id)objectModelWithClass: (Class)myClass
	idProperties: (NSArray *)idProperties
	propertyKeyMap: (NSDictionary *)propertyKeyMap
	collectionTypeMap: (NSDictionary *)collectionTypeMap
	updateBlock: (AFObjectUpdateBlock)updateBlock
	createBlock: (AFObjectCreateBlock)createBlock;

@end // @interface AFObjectModel

#pragma mark Forward Declarations

@class AFObjectProvider;

#pragma mark Type Definitions

typedef void (^AFObjectUpdateBlock)(id provider, id object, NSDictionary *values);

typedef id (^AFObjectCreateBlock)(id provider, NSDictionary *values);

#pragma mark - Class Interface

@interface AFObjectModel : NSObject

#pragma mark - Properties

@property (nonatomic, strong) Class myClass;
@property (nonatomic, copy) NSArray *idProperties;

@property (nonatomic, copy) NSDictionary *propertyKeyMap;
@property (nonatomic, copy) NSDictionary *collectionTypeMap;

@property (nonatomic, copy) AFObjectUpdateBlock updateBlock;
@property (nonatomic, copy) AFObjectCreateBlock createBlock;

#pragma mark - Constructors

- (id)initWithClass: (Class)myClass
	idProperties: (NSArray *)idProperties
	propertyKeyMap: (NSDictionary *)propertyKeyMap
	collectionTypeMap: (NSDictionary *)collectionTypeMap
	updateBlock: (AFObjectUpdateBlock)updateBlock
	createBlock: (AFObjectCreateBlock)createBlock;

#pragma mark - Static Methods

+ (id)objectModelWithClass: (Class)myClass
	idProperties: (NSArray *)idProperties
	propertyKeyMap: (NSDictionary *)propertyKeyMap
	collectionTypeMap: (NSDictionary *)collectionTypeMap
	updateBlock: (AFObjectUpdateBlock)updateBlock
	createBlock: (AFObjectCreateBlock)createBlock;

@end // @interface AFObjectModel

Update update and create block signatures.


#ifndef _LINUX_IRQRETURN_H
#define _LINUX_IRQRETURN_H

/**
 * enum irqreturn
 * @IRQ_NONE		interrupt was not from this device
 * @IRQ_HANDLED		interrupt was handled by this device
 * @IRQ_WAKE_THREAD	handler requests to wake the handler thread
 */
enum irqreturn {
	IRQ_NONE		= (0 << 0),
	IRQ_HANDLED		= (1 << 0),
	IRQ_WAKE_THREAD		= (1 << 1),
};

typedef enum irqreturn irqreturn_t;
#define IRQ_RETVAL(x)	((x) != IRQ_NONE)

#endif

#ifndef _LINUX_IRQRETURN_H
#define _LINUX_IRQRETURN_H

/**
 * enum irqreturn
 * @IRQ_NONE		interrupt was not from this device
 * @IRQ_HANDLED		interrupt was handled by this device
 * @IRQ_WAKE_THREAD	handler requests to wake the handler thread
 */
enum irqreturn {
	IRQ_NONE		= (0 << 0),
	IRQ_HANDLED		= (1 << 0),
	IRQ_WAKE_THREAD		= (1 << 1),
};

typedef enum irqreturn irqreturn_t;
#define IRQ_RETVAL(x)	((x) ? IRQ_HANDLED : IRQ_NONE)

#endif

genirq: Correct fuzzy and fragile IRQ_RETVAL() definition

commit bedd30d986a0 ("genirq: make irqreturn_t an enum") blindly replaced
"0" by "IRQ_NONE" in the "IRQ_RETVAL(x)" macro definition.

However, as "x" is a condition, "0" meant "boolean false", not an
irqreturn_t value.

All of this worked, and kept working after the addition of IRQ_WAKE_THREAD,
as
  - both "boolean false" and "IRQ_NONE" are "0" (for the comparison),
  - "boolean true" and "boolean false" nicely map to the correct values of
    "IRQ_HANDLED" and "IRQ_NONE" (for the return value).

Correct the macro definition for clarity and future-proofness.

Signed-off-by: Geert Uytterhoeven <0da414d9d963da4039c2a0525b1844228075aa58@linux-m68k.org>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>


/*
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <openssl/crypto.h>

#define DEFINE_RUN_ONCE(init)                   \
    static int init(void);                     \
    int init##_ossl_ret_ = 0;                   \
    void init##_ossl_(void)                     \
    {                                           \
        init##_ossl_ret_ = init();              \
    }                                           \
    static int init(void)
#define DECLARE_RUN_ONCE(init)                  \
    extern int init##_ossl_ret_;                \
    void init##_ossl_(void);

#define DEFINE_RUN_ONCE_STATIC(init)            \
    static int init(void);                     \
    static int init##_ossl_ret_ = 0;            \
    static void init##_ossl_(void)              \
    {                                           \
        init##_ossl_ret_ = init();              \
    }                                           \
    static int init(void)

/*
 * RUN_ONCE - use CRYPTO_THREAD_run_once, and check if the init succeeded
 * @once: pointer to static object of type CRYPTO_ONCE
 * @init: function name that was previously given to DEFINE_RUN_ONCE,
 *        DEFINE_RUN_ONCE_STATIC or DECLARE_RUN_ONCE.
 *
 * The return value is 1 on success or 0 in case of error.
 */
#define RUN_ONCE(once, init)                                            \
    (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0)

Define a few internal macros for easy use of run_once functions

Because pthread_once() takes a function taking no argument and
returning nothing, and we want to be able to check if they're
successful, we define a few internal macros to get around the issue.

Reviewed-by: Kurt Roeckx <bb87b47479d83cec3c76132206933257ded727b2@openssl.org>