/* PDCurses */

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE 1   /* kill nonsense warnings */
#endif

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE 1   /* kill nonsense warnings */
#endif

#if defined(PDC_WIDE) && !defined(UNICODE)
# define UNICODE
#endif

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef MOUSE_MOVED
#include <curspriv.h>

typedef struct {short r, g, b; bool mapped;} PDCCOLOR;

extern PDCCOLOR pdc_color[PDC_MAXCOL];

extern HANDLE pdc_con_out, pdc_con_in;
extern DWORD pdc_quick_edit;
extern DWORD pdc_last_blink;
extern short pdc_curstoreal[16], pdc_curstoansi[16];
extern short pdc_oldf, pdc_oldb, pdc_oldu;
extern bool pdc_conemu, pdc_wt, pdc_ansi;

extern void PDC_blink_text(void);

/* PDCurses */

#ifndef __PDC_WIN_H__
#define __PDC_WIN_H__

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE 1   /* kill nonsense warnings */
#endif

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE 1   /* kill nonsense warnings */
#endif

#if defined(PDC_WIDE) && !defined(UNICODE)
# define UNICODE
#endif

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef MOUSE_MOVED
#include <curspriv.h>

typedef struct {short r, g, b; bool mapped;} PDCCOLOR;

extern PDCCOLOR pdc_color[PDC_MAXCOL];

extern HANDLE pdc_con_out, pdc_con_in;
extern DWORD pdc_quick_edit;
extern DWORD pdc_last_blink;
extern short pdc_curstoreal[16], pdc_curstoansi[16];
extern short pdc_oldf, pdc_oldb, pdc_oldu;
extern bool pdc_conemu, pdc_wt, pdc_ansi;

extern void PDC_blink_text(void);

#endif

Add include guard to fix wincon compile.


#include "core/base/inc/LinkDef1.h"
#include "core/base/inc/LinkDef2.h"
#include "core/base/inc/LinkDef3.h"
#include "core/clib/inc/LinkDef.h"
#include "core/cont/inc/LinkDef.h"
#include "core/meta/inc/LinkDef.h"
#include "core/metautils/inc/LinkDef.h"
#include "core/textinput/inc/LinkDef.h"
#include "core/zip/inc/LinkDef.h"

#if defined(SYSTEM_TYPE_winnt)
#include "core/winnt/inc/LinkDef.h"
#elif defined(SYSTEM_TYPE_macosx)
#include "core/macosx/inc/LinkDef.h"
#include "core/unix/inc/LinkDef.h"
#else
#include "core/unix/inc/LinkDef.h"
#endif

#include "core/base/inc/LinkDef1.h"
#include "core/base/inc/LinkDef2.h"
#include "core/base/inc/LinkDef3.h"
#include "core/clib/inc/LinkDef.h"
#include "core/cont/inc/LinkDef.h"
#include "core/meta/inc/LinkDef.h"
#include "core/metautils/inc/LinkDef.h"
#include "core/textinput/inc/LinkDef.h"
#include "core/zip/inc/LinkDef.h"

#if defined(SYSTEM_TYPE_winnt)
#include "core/winnt/inc/LinkDef.h"
#elif defined(SYSTEM_TYPE_macosx)
#include "core/macosx/inc/LinkDef.h"
#include "core/unix/inc/LinkDef.h"
#elif defined(SYSTEM_TYPE_unix)
#include "core/unix/inc/LinkDef.h"
#else
# error "Unsupported system type."
#endif

Verify that one of SYSTEM_TYPE_... is set.


/*
 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef BL2_H__
#define BL2_H__

struct entry_point_info;

void bl2_main(void);
struct entry_point_info *bl2_load_images(void);

#endif /* BL2_H__ */

/*
 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef BL2_H__
#define BL2_H__

void bl2_main(void);

#endif /* BL2_H__ */

Fix MISRA rule 8.5 in common code

Fix MISRA rule 8.5 in common code

Rule 8.5: An external object or function shall be declared
          once in one and only one file.

Change-Id: I7c3d4ec7d3ba763fdb4600008ba10b4b93ecdfce
Signed-off-by: Roberto Vargas <d75e640c49defb97bd074f828210df57ed181e1f@arm.com>


#ifndef CJET_CONFIG_H
#define CJET_CONFIG_H

#define SERVER_PORT \
	11122
#define LISTEN_BACKLOG \
	40
/*
 * It is somehow beneficial if this size is 32 bit aligned.
 */
#define MAX_MESSAGE_SIZE \
	256

/* Linux specific configs */
#define MAX_EPOLL_EVENTS \
	100

#endif

#ifndef CJET_CONFIG_H
#define CJET_CONFIG_H

#define SERVER_PORT \
	11122
#define LISTEN_BACKLOG \
	40
/*
 * It is somehow beneficial if this size is 32 bit aligned.
 */
#define MAX_MESSAGE_SIZE \
	512

/* Linux specific configs */
#define MAX_EPOLL_EVENTS \
	100

#endif

Increase read and write buffer size per peer.


// REQUIRES: arm-registered-target
// RUN: %clang -target thumbv7-none-linux-gnueabihf \
// RUN:   -mcpu=cortex-a8 -mfloat-abi=hard \
// RUN:   -O3 -S -emit-llvm -o - %s | FileCheck %s

#include <arm_neon.h>

float32x2_t test_fma_order(float32x2_t accum, float32x2_t lhs, float32x2_t rhs) {
  return vfma_f32(accum, lhs, rhs);
// CHECK: call <2 x float> @llvm.fma.v2f32(<2 x float> %lhs, <2 x float> %rhs, <2 x float> %accum)
}

float32x4_t test_fmaq_order(float32x4_t accum, float32x4_t lhs, float32x4_t rhs) {
  return vfmaq_f32(accum, lhs, rhs);
// CHECK: call <4 x float> @llvm.fma.v4f32(<4 x float> %lhs, <4 x float> %rhs, <4 x float> %accum)
}

// REQUIRES: arm-registered-target
// RUN: %clang_cc1 -triple thumbv7-none-linux-gnueabihf \
// RUN:   -target-abi aapcs \
// RUN:   -target-cpu cortex-a8 \
// RUN:   -mfloat-abi hard \
// RUN:   -ffreestanding \
// RUN:   -O3 -S -emit-llvm -o - %s | FileCheck %s

#include <arm_neon.h>

float32x2_t test_fma_order(float32x2_t accum, float32x2_t lhs, float32x2_t rhs) {
  return vfma_f32(accum, lhs, rhs);
// CHECK: call <2 x float> @llvm.fma.v2f32(<2 x float> %lhs, <2 x float> %rhs, <2 x float> %accum)
}

float32x4_t test_fmaq_order(float32x4_t accum, float32x4_t lhs, float32x4_t rhs) {
  return vfmaq_f32(accum, lhs, rhs);
// CHECK: call <4 x float> @llvm.fma.v4f32(<4 x float> %lhs, <4 x float> %rhs, <4 x float> %accum)
}

Fix recent test for more diverse environments.

I think the main issue was the lack of -ffreestanding, which pulled in
the host's stdint.h. After that things went rapidly downhill.

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


#ifndef _TESTUTILS_H
#define _TESTUTILS_H
/*
 *  tslib/tests/testutils.h
 *
 *  Copyright (C) 2004 Michael Opdenacker <michaelo@handhelds.org>
 *
 * This file is placed under the LGPL.
 *
 *
 * Misc utils for ts test programs
 */

#define RESET   "\033[0m"
#define RED     "\033[31m"
#define GREEN   "\033[32m"
#define BLUE    "\033[34m"
#define YELLOW  "\033[33m"

struct ts_button {
	int x, y, w, h;
	char *text;
	int flags;
#define BUTTON_ACTIVE 0x00000001
};

void button_draw(struct ts_button *button);
int button_handle(struct ts_button *button, int x, int y, unsigned int pressure);
void getxy(struct tsdev *ts, int *x, int *y);
void ts_flush (struct tsdev *ts);
void print_ascii_logo(void);

#endif /* _TESTUTILS_H */

#ifndef _TESTUTILS_H
#define _TESTUTILS_H
/*
 *  tslib/tests/testutils.h
 *
 *  Copyright (C) 2004 Michael Opdenacker <michaelo@handhelds.org>
 *
 * This file is placed under the GPL.
 *
 * SPDX-License-Identifier: GPL-2.0+
 *
 *
 * Misc utils for ts test programs
 */

#define RESET   "\033[0m"
#define RED     "\033[31m"
#define GREEN   "\033[32m"
#define BLUE    "\033[34m"
#define YELLOW  "\033[33m"

struct ts_button {
	int x, y, w, h;
	char *text;
	int flags;
#define BUTTON_ACTIVE 0x00000001
};

void button_draw(struct ts_button *button);
int button_handle(struct ts_button *button, int x, int y, unsigned int pressure);
void getxy(struct tsdev *ts, int *x, int *y);
void ts_flush (struct tsdev *ts);
void print_ascii_logo(void);

#endif /* _TESTUTILS_H */

tests: Fix license statement in header comment and add SPDS identifier

This file had been copied around a long time ago, and included a wrong
license. All files in the tests directory (except for this small header)
are GPL licensed.

I actually doubt that the copyright notice is accurate here -.-

Signed-off-by: Martin Kepplinger <07ddf30bcca2a0d3056e54ffbfe155352a6af244@posteo.de>


#define FUNC		1
#define PARAM		2
#define PTR_PARAM	3

struct token {
	int		tok_type;
	char	*val;
};

struct node {
	int		node_type;
	char	*type_name;
	char	*id;
	int		is_ptr;
	int		is_const;
	int		is_mapped;
	int		is_array;
	int		extract;
	struct node	*next;
	struct node *prev;
};

union yystype {
	struct token tok;
	struct node *node;
};
#define YYSTYPE union yystype

#define FUNC		1
#define PARAM		2
#define PTR_PARAM	3

struct token {
	int		tok_type;
	char	*val;
};

struct node {
	int		node_type;
	char	*type_name;
	char	*id;
	int		is_ptr;
	int		is_const;
	int		is_const_ptr;
	int		is_mapped;
	int		is_array;
	int		in_param;
	int		out_param;
	int		extract;
	struct node	*next;
	struct node *prev;
};

struct p_mode {
	int		in;
	int		out;
};

union yystype {
	struct	token tok;
	struct	node *node;
	struct	p_mode param_mode;
	int		bool;
};
#define YYSTYPE union yystype

Add boolean type so yacc productions can return a boolean value. Add parameter mode type so we can tag parameters as IN, OUT, or BOTH.


// RUN: clang --emit-llvm-bc -o - %s | opt --std-compile-opts | llvm-dis > %t &&
// RUN: grep "ret i32" %t | count 1 &&
// RUN: grep "ret i32 1" %t | count 1
// PR2001

/* Test that the result of the assignment properly uses the value *in
   the bitfield* as opposed to the RHS. */
static int foo(int i) {
  struct {
    int f0 : 2;
  } x;
  return (x.f0 = i);
}

int bar() {
  return foo(-5) == -1;
}

Add test case for PR2001.

Add test case for PR2001.

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


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

Program:   Medical Imaging & Interaction Toolkit
Language:  C++
Date:      $Date: 2010-03-31 17:34:48 +0200 (Wed, 31 Mar 2010) $
Version:   $Revision: 21985 $

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notices for more information.

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

#ifndef mitkRenderingTestHelper_h
#define mitkRenderingTestHelper_h

#include <string>
#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <mitkRenderWindow.h>

class vtkRenderWindow;
class vtkRenderer;

namespace mitk
{
  class DataStorage;
}

class MITK_CORE_EXPORT mitkRenderingTestHelper
{
  public:
    mitkRenderingTestHelper(int width, int height, mitk::DataStorage* ds);

    ~mitkRenderingTestHelper();

    vtkRenderer* GetVtkRenderer();
    vtkRenderWindow* GetVtkRenderWindow();
    void SaveAsPNG(std::string fileName);

  protected:
    mitk::RenderWindow::Pointer m_RenderWindow;

};

#endif

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

Program:   Medical Imaging & Interaction Toolkit
Language:  C++
Date:      $Date: 2010-03-31 17:34:48 +0200 (Wed, 31 Mar 2010) $
Version:   $Revision: 21985 $

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notices for more information.

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

#ifndef mitkRenderingTestHelper_h
#define mitkRenderingTestHelper_h

#include <string>
#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <mitkRenderWindow.h>

class vtkRenderWindow;
class vtkRenderer;

namespace mitk
{
  class DataStorage;
}

class mitkRenderingTestHelper
{
  public:
    mitkRenderingTestHelper(int width, int height, mitk::DataStorage* ds);

    ~mitkRenderingTestHelper();

    vtkRenderer* GetVtkRenderer();
    vtkRenderWindow* GetVtkRenderWindow();
    void SaveAsPNG(std::string fileName);

  protected:
    mitk::RenderWindow::Pointer m_RenderWindow;

};

#endif

Fix linker warnings in rendering tests

Fix linker warnings in rendering tests


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

void print_address(const char *str, int n, ...) {
  fprintf(stderr, "%s", str);
  va_list ap;
  va_start(ap, n);
  while (n--) {
    void *p = va_arg(ap, void *);
#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
    // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
    // match to the format used in the diagnotic message.
    fprintf(stderr, "0x%012lx ", (unsigned long) p);
#elif defined(__i386__) || defined(__arm__)
    fprintf(stderr, "0x%8lx ", (unsigned long) p);
#elif defined(__mips64)
    fprintf(stderr, "0x%010lx ", (unsigned long) p);
#endif
  }
  fprintf(stderr, "\n");
}

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

void print_address(const char *str, int n, ...) {
  fprintf(stderr, "%s", str);
  va_list ap;
  va_start(ap, n);
  while (n--) {
    void *p = va_arg(ap, void *);
#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
    // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
    // match to the format used in the diagnotic message.
    fprintf(stderr, "0x%012lx ", (unsigned long) p);
#elif defined(__i386__) || defined(__arm__)
    fprintf(stderr, "0x%08lx ", (unsigned long) p);
#elif defined(__mips64)
    fprintf(stderr, "0x%010lx ", (unsigned long) p);
#endif
  }
  fprintf(stderr, "\n");
}

Use 0-padding for i386 and arm print format specifiers

Summary:
This is used for the other architectures in print_address, but is
missing from i386 and arm.

Reviewers: m.ostapenko, spetrovic

Subscribers: aemerson, rengolin, llvm-commits, kubamracek

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

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


/*
 * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file 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.
 */

#pragma once

#include <stdint.h>

#include "utils/s2n_blob.h"

#include "crypto/s2n_hmac.h"

extern int s2n_hkdf(struct s2n_hmac_state *hmac, s2n_hmac_algorithm alg, const struct s2n_blob *salt,
                    const struct s2n_blob *key, const struct s2n_blob *info, struct s2n_blob *output);

extern int s2n_hkdf_extract(struct s2n_hmac_state *hmac, s2n_hmac_algorithm alg, const struct s2n_blob *salt,
                            const struct s2n_blob *key, struct s2n_blob *pseudo_rand_key);

extern int s2n_hkdf_expand_label(struct s2n_hmac_state *hmac, s2n_hmac_algorithm alg, const struct s2n_blob *secret, const struct s2n_blob *label,
                                 const struct s2n_blob *context, struct s2n_blob *output);

Add missing header changes from previous commit


// RUN: not %clang_cc1 -emit-llvm %s -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s

// CHECK: error: Could not read profile:
// CHECK-NOT: Assertion failed

// RUN: not %clang_cc1 -emit-llvm %s -o - -fprofile-instr-use=%t.nonexistent.profdata 2>&1 | FileCheck %s

// CHECK: error: Could not read profile:
// CHECK-NOT: Assertion failed

Fix this test so it doesn't try to open a file to write to the source tree

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


// options to control how Micro Python is built

#define MICROPY_EMIT_CPYTHON        (1)
#define MICROPY_ENABLE_LEXER_UNIX   (1)
#define MICROPY_ENABLE_FLOAT        (1)

// type definitions for the specific machine

#ifdef __LP64__
typedef long machine_int_t; // must be pointer size
typedef unsigned long machine_uint_t; // must be pointer size
#else
// These are definitions for machines where sizeof(int) == sizeof(void*),
// regardless for actual size.
typedef int machine_int_t; // must be pointer size
typedef unsigned int machine_uint_t; // must be pointer size
#endif

#define BYTES_PER_WORD sizeof(machine_int_t)

typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size
typedef double machine_float_t;

machine_float_t machine_sqrt(machine_float_t x);

// options to control how Micro Python is built

#define MICROPY_EMIT_CPYTHON        (1)
#define MICROPY_ENABLE_LEXER_UNIX   (1)
#define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_DOUBLE)

// type definitions for the specific machine

#ifdef __LP64__
typedef long machine_int_t; // must be pointer size
typedef unsigned long machine_uint_t; // must be pointer size
#else
// These are definitions for machines where sizeof(int) == sizeof(void*),
// regardless for actual size.
typedef int machine_int_t; // must be pointer size
typedef unsigned int machine_uint_t; // must be pointer size
#endif

#define BYTES_PER_WORD sizeof(machine_int_t)

typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size
typedef double machine_float_t;

machine_float_t machine_sqrt(machine_float_t x);

unix-cpy: Switch to use MICROPY_FLOAT_IMPL config define.


//
// Created by Michael Kuck on 7/7/16.
// Copyright (c) 2016 Michael Kuck. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@class FIRDatabaseReference;
@class FIRDataSnapshot;

//============================================================
//== Public Interface
//============================================================
@interface MKFirebaseModel : NSObject

@property (nonatomic, readonly) FIRDatabaseReference *firebaseRef;
@property (nonatomic, readonly) NSString *identifier;

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithFirebaseRef:(FIRDatabaseReference *)firebaseRef snapshotValue:(NSDictionary *)snapshotValue NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithSnapshot:(FIRDataSnapshot *)snapshot;

@end

NS_ASSUME_NONNULL_END

//
// Created by Michael Kuck on 7/7/16.
// Copyright (c) 2016 Michael Kuck. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@class FIRDatabaseReference;
@class FIRDataSnapshot;

//============================================================
//== Public Interface
//============================================================
@interface MKFirebaseModel : NSObject

@property (nonatomic, readonly) FIRDatabaseReference *firebaseRef;
@property (nonatomic, readonly) NSString *identifier;

- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithFirebaseRef:(FIRDatabaseReference *)firebaseRef snapshotValue:(NSDictionary *)snapshotValue NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithSnapshot:(FIRDataSnapshot *)snapshot;

- (BOOL)isEqualToFirebaseModel:(MKFirebaseModel *)firebaseModel;

@end

NS_ASSUME_NONNULL_END

Add `isEqualToFirebaseModel:` to public header


/****************************************************************************
 * Copyright 2016 BlueMasters
 *
 * 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 SOLENOID__H
#define SOLENOID__H

#include <Arduino.h>
#include "StateMachine.h"
#include "LED.h"
#include "RFIDSensor.h"
#include "WolvesTypes.h"

enum solenoidState {
    SOLENOID_IDLE,
    SOLENOID_FROZEN,
    SOLENOID_FIRED,
    SOLENOID_WAITING
};

class Solenoid : public StateMachine {
public:
    Solenoid(int impulsePin, RFIDSensor sensor, LED led) :
        _impulsePin(impulsePin), _sensor(sensor), _led(led) {};
    void begin();
    void on();
    void off();
    void tick();

private:
    int _impulsePin;
    RFIDSensor _sensor;
    LED _led;
    solenoidState _state;
    long _timestamp;
    void fire(long t);
    void release(long t);
};

#endif

/****************************************************************************
 * Copyright 2016 BlueMasters
 *
 * 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 SOLENOID__H
#define SOLENOID__H

#include <Arduino.h>
#include "StateMachine.h"
#include "LED.h"
#include "RFIDSensor.h"
#include "WolvesTypes.h"

class Solenoid : public StateMachine {
public:
    Solenoid(int impulsePin, RFIDSensor sensor, LED led) :
        _impulsePin(impulsePin), _sensor(sensor), _led(led) {};
    void begin();
    void on();
    void off();
    void tick();

private:
    enum solenoidState {
        SOLENOID_IDLE,
        SOLENOID_FROZEN,
        SOLENOID_FIRED,
        SOLENOID_WAITING
    };
    int _impulsePin;
    RFIDSensor _sensor;
    LED _led;
    solenoidState _state;
    long _timestamp;
    void fire(long t);
    void release(long t);
};

#endif

Put states inside the class

Put states inside the class


#ifndef __itkImageFilterMultipleOutputs_h
#define __itkImageFilterMultipleOutputs_h

#include "itkImageToImageFilter.h"

namespace itk
{
template <class TImage>
class ImageFilterMultipleOutputs : public ImageToImageFilter<TImage, TImage>
{
public:
  /** Standard class type alias. */
  using Self = ImageFilterMultipleOutputs;
  using Superclass = ImageToImageFilter<TImage, TImage>;
  using Pointer = SmartPointer<Self>;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Run-time type information (and related methods). */
  itkTypeMacro(ImageFilterMultipleOutputs, ImageToImageFilter);

  TImage *
  GetOutput1();
  TImage *
  GetOutput2();

protected:
  ImageFilterMultipleOutputs();
  ~ImageFilterMultipleOutputs() override = default;

  /** Does the real work. */
  void
  GenerateData() override;

  /**  Create the Output */
  DataObject::Pointer
  MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx);

private:
  ImageFilterMultipleOutputs(const Self &) = delete; // purposely not implemented
  void
  operator=(const Self &) = delete; // purposely not implemented
};
} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
#  include "ImageFilterMultipleOutputs.hxx"
#endif

#endif // __itkImageFilterMultipleOutputs_h

#ifndef __itkImageFilterMultipleOutputs_h
#define __itkImageFilterMultipleOutputs_h

#include "itkImageToImageFilter.h"

namespace itk
{
template <class TImage>
class ImageFilterMultipleOutputs : public ImageToImageFilter<TImage, TImage>
{
public:
  /** Standard class type alias. */
  using Self = ImageFilterMultipleOutputs;
  using Superclass = ImageToImageFilter<TImage, TImage>;
  using Pointer = SmartPointer<Self>;

  /** Method for creation through the object factory. */
  itkNewMacro(Self);

  /** Run-time type information (and related methods). */
  itkTypeMacro(ImageFilterMultipleOutputs, ImageToImageFilter);

  TImage *
  GetOutput1();
  TImage *
  GetOutput2();

protected:
  ImageFilterMultipleOutputs();
  ~ImageFilterMultipleOutputs() override = default;

  /** Does the real work. */
  void
  GenerateData() override;

  /**  Create the Output */
  DataObject::Pointer
  MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override;

private:
  ImageFilterMultipleOutputs(const Self &) = delete; // purposely not implemented
  void
  operator=(const Self &) = delete; // purposely not implemented
};
} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
#  include "ImageFilterMultipleOutputs.hxx"
#endif

#endif // __itkImageFilterMultipleOutputs_h

Remove redundant void argument lists

STYLE: Remove redundant void argument lists

Find and remove redundant void argument lists.


#pragma once
#include <string>
#include <sstream>
#include <Eigen/Dense>

std::string output_matrices(Eigen::MatrixXd expected, Eigen::MatrixXd actual) {
    std::stringstream ss;
    ss << "expected:\n" << expected << "\nactual:\n" << actual << std::endl;
    return ss.str();
}

/*
 * allclose() function to match numpy.allclose
 * https://stackoverflow.com/questions/15051367/how-to-compare-vectors-approximately-in-eige://stackoverflow.com/questions/15051367/how-to-compare-vectors-approximately-in-eigen
 */
namespace test {

template<typename DerivedA, typename DerivedB>
bool allclose(const Eigen::DenseBase<DerivedA>& a, const Eigen::DenseBase<DerivedB>& b,
              const typename DerivedA::RealScalar& rtol
                = Eigen::NumTraits<typename DerivedA::RealScalar>::dummy_precision(),
              const typename DerivedA::RealScalar& atol
                = Eigen::NumTraits<typename DerivedA::RealScalar>::epsilon()) {
  return ((a.derived() - b.derived()).array().abs() <= (atol + rtol * b.derived().array().abs())).all();
}

} // namespace test

Add allclose function for testing

Add allclose function for testing

Compare relative and absolute tolerence of matrix elements. Eigen
isApprox() functions compare matrix norms.


#include "m-core.h"

// Stubs defined for the example. Real code will use soundio library.
struct SoundIo { int x; };
struct SoundIoDevice { int x; };
struct SoundIoOutStream { int x; };

static struct SoundIo *soundio_create(void) { return (struct SoundIo *) malloc(sizeof(struct SoundIo)); }
static void soundio_destroy(struct SoundIo *s) { free(s); }

static struct SoundIoDevice *soundio_get_device(struct SoundIo *io, int def) { (void) io; (void) def; return (struct SoundIoDevice *) malloc(sizeof(struct SoundIoDevice)); }
static void soundio_device_unref(struct SoundIoDevice *s) { free(s); }

static struct SoundIoOutStream *soundio_outstream_create(struct SoundIoDevice *device) { (void) device ; return (struct SoundIoOutStream *) malloc(sizeof(struct SoundIoOutStream)); }
static void soundio_outstream_destroy(struct SoundIoOutStream *s) { free(s); }

static bool soundio_wait_events(struct SoundIo *s) { (void) s; return false; }
// End of stubs

int main(void)
{
  int err = 1;

  /* Example of using M_LET_IF macro to simplify writing error handling code.
     The following code creates some object, test if the object creation succeeds, register the destructor, and print an error if something went wrong
  */
  M_LET_IF( struct SoundIo *soundio = soundio_create(), soundio != 0 , soundio_destroy(soundio) , fprintf(stderr, "out of memory for soundio\n") )
    M_LET_IF(struct SoundIoDevice *device = soundio_get_device(soundio, -1), device != 0, soundio_device_unref(device),  fprintf(stderr, "out of memory for device\n"))
    M_LET_IF(struct SoundIoOutStream *outstream = soundio_outstream_create(device), outstream != 0, soundio_outstream_destroy(outstream), fprintf(stderr, "out of memory for stream\n")) {
    err = 0;
    bool cont = true;
    while (cont)
      cont = soundio_wait_events(soundio);
  }
  return err;
}

Add an example of M_LET_IF

Add an example of M_LET_IF


#include "application.h"

#ifndef _INCL_MDNS
#define _INCL_MDNS

#include "Buffer.h"
#include "Label.h"
#include "Record.h"
#include <map>
#include <vector>

#define MDNS_PORT 5353

#define BUFFER_SIZE 512
#define HOSTNAME ""

class MDNS {
public:

  bool setHostname(String hostname);

  bool addService(String protocol, String service, uint16_t port, String instance, std::vector<String> subServices = std::vector<String>());

  void addTXTEntry(String key, String value = NULL);

  bool begin();

  bool processQueries();

private:

  struct QueryHeader {
    uint16_t id;
    uint16_t flags;
    uint16_t qdcount;
    uint16_t ancount;
    uint16_t nscount;
    uint16_t arcount;
  };

  UDP * udp = new UDP();
  Buffer * buffer = new Buffer(BUFFER_SIZE);

  Label * ROOT = new Label("");
  Label * LOCAL = new Label("local", ROOT);
  Label::Matcher * matcher = new Label::Matcher();

  ARecord * aRecord;
  TXTRecord * txtRecord;

  std::map<String, Label *> labels;
  std::vector<Record *> records;
  String status = "Ok";

  QueryHeader readHeader(Buffer * buffer);
  void getResponses();
  void writeResponses();
  bool isAlphaDigitHyphen(String string);
  bool isNetUnicode(String string);
};

#endif

#include "application.h"

#ifndef _INCL_MDNS
#define _INCL_MDNS

#include "Buffer.h"
#include "Label.h"
#include "Record.h"
#include <map>
#include <vector>

#define MDNS_PORT 5353

#define BUFFER_SIZE 512
#define HOSTNAME ""

class MDNS {
public:

  bool setHostname(String hostname);

  bool addService(String protocol, String service, uint16_t port, String instance, std::vector<String> subServices = std::vector<String>());

  void addTXTEntry(String key, String value = "");

  bool begin();

  bool processQueries();

private:

  struct QueryHeader {
    uint16_t id;
    uint16_t flags;
    uint16_t qdcount;
    uint16_t ancount;
    uint16_t nscount;
    uint16_t arcount;
  };

  UDP * udp = new UDP();
  Buffer * buffer = new Buffer(BUFFER_SIZE);

  Label * ROOT = new Label("");
  Label * LOCAL = new Label("local", ROOT);
  Label::Matcher * matcher = new Label::Matcher();

  ARecord * aRecord;
  TXTRecord * txtRecord;

  std::map<String, Label *> labels;
  std::vector<Record *> records;
  String status = "Ok";

  QueryHeader readHeader(Buffer * buffer);
  void getResponses();
  void writeResponses();
  bool isAlphaDigitHyphen(String string);
  bool isNetUnicode(String string);
};

#endif

Fix for particle firmware v0.6.2

Fix for particle firmware v0.6.2


#include <string.h>
#include "lib/minunit.h"
#include "acacia.h"

//#define TEST_KEY "abcd1111"
#define TEST_KEY "abcdefghijklmnopqrstuvwxyz"
#define TEST_VALUE "foo_bar_baz_111"

MU_TEST(test_check) {
	struct Node *cache = cache_init();
	cache_set(TEST_KEY, TEST_VALUE, cache);
	mu_check(strcmp(cache_get(TEST_KEY, cache), TEST_VALUE) == 0);
	cache_close(cache);
}

MU_TEST_SUITE(test_suite) {
	MU_RUN_TEST(test_check);
}

int main(int argc, const char *argv[])
{
	MU_RUN_SUITE(test_suite);
	MU_REPORT();
	return 0;
}

#include <string.h>
#include "lib/minunit.h"
#include "acacia.h"

#define TEST_KEY "abcdefghijklmnopqrstuvwxyz"
#define TEST_VALUE "foo_bar_baz_111"

MU_TEST(test_store_fetch_simple) {
	struct Node *cache = cache_init();
	cache_set(TEST_KEY, TEST_VALUE, cache);
	mu_check(strcmp(cache_get(TEST_KEY, cache), TEST_VALUE) == 0);
	cache_close(cache);
}

MU_TEST(test_store_fetch_empty_string) {
	struct Node *cache = cache_init();
	cache_set("foo", "", cache);
	mu_check(strcmp(cache_get("foo", cache), "") == 0);
	cache_close(cache);
}

MU_TEST_SUITE(test_suite) {
	MU_RUN_TEST(test_store_fetch_simple);
	MU_RUN_TEST(test_store_fetch_empty_string);
}

int main(int argc, const char *argv[])
{
	MU_RUN_SUITE(test_suite);
	MU_REPORT();
	return 0;
}

Add a test for caching an empty string

Add a test for caching an empty string


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

// Invokes a process, making sure that the state of the signal
// handlers has all been set back to the unix default.
int main(int argc, char **argv)
{
    int i;
    sigset_t blockedsigs;
    struct sigaction action;

    // unblock all signals
    sigemptyset(&blockedsigs);
    sigprocmask(SIG_BLOCK, NULL, NULL);

    // reset all signals to SIG_DFL
    memset(&action, 0, sizeof(action));
    action.sa_handler = SIG_DFL;
    action.sa_flags = 0;
    sigemptyset(&action.sa_mask);
    for(i = 0; i < NSIG; ++i)
        sigaction(i, &action, NULL);

    execv(argv[1], argv+1);
    fprintf(stderr, "failed to execv %s\n", argv[1]);
    return 0;
}

#include <signal.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>

// Invokes a process, making sure that the state of the signal
// handlers has all been set back to the unix default.
int main(int argc, char **argv)
{
    int i;
    sigset_t blockedsigs;
    struct sigaction action;

    // unblock all signals
    sigemptyset(&blockedsigs);
    sigprocmask(SIG_BLOCK, NULL, NULL);

    // reset all signals to SIG_DFL
    memset(&action, 0, sizeof(action));
    action.sa_handler = SIG_DFL;
    action.sa_flags = 0;
    sigemptyset(&action.sa_mask);
    for(i = 0; i < NSIG; ++i)
        sigaction(i, &action, NULL);

    execv(argv[1], argv+1);
    fprintf(stderr, "failed to execv %s\n", argv[1]);
    return 0;
}

Fix below warning by including "unistd.h" also

exec_signals_prepare.c:26:5: warning: implicit declaration of function 'execv' is invalid in C99
      [-Wimplicit-function-declaration]
    execv(argv[1], argv+1);
    ^
1 warning generated.


#ifndef LAND_H
#define LAND_H

#include <string>
#include "Plant.h"

class Land
{
	public:
		~Land();
		const std::string getPlantName() const { return isStood_? plant_->getName() : "Empty"; }
		bool put(Plant & plant);
        bool getStood()const{return isStood_;}

	private:
		Plant * plant_ = nullptr;
		bool isStood_ = false;
};

#endif // LAND_H

#ifndef MAP_H
#define MAP_H

#include <vector>

class Map
{
	public:
		// with this constructor, you could get a map with [land_num] empty land
		Map(int land_num);

		Land operator[] (int i) { return lands_[i]; }
		const Land operator[] (int i) const { return lands_[i]; }

		int size() { return lands_.size(); }
		bool put(Plant & plant, int position) { return lands_[position].put(plant); }

	private:
		constexpr static int max_land_num = 10;
		std::vector<Land> lands_;
};

#endif // MAP_H

#ifndef LAND_H
#define LAND_H

#include <string>
#include "Plant.h"

class Land
{
	public:
		~Land();
		bool put(Plant & plant);
		bool getStood()const{return isStood_;}
		Plant & getPlant() { return *plant_; }
		const Plant & getPlant() const { return *plant_; }

	private:
		Plant * plant_ = nullptr;
		bool isStood_ = false;
};

#endif // LAND_H

#ifndef MAP_H
#define MAP_H

#include <vector>

class Map
{
	public:
		// with this constructor, you could get a map with [land_num] empty land
		Map(int land_num);

		Land operator[] (int i) { return lands_[i]; }
		const Land operator[] (int i) const { return lands_[i]; }

		int size() { return lands_.size(); }
		bool put(Plant & plant, int position) { return lands_[position].put(plant); }

	private:
		constexpr static int max_land_num = 10;
		std::vector<Land> lands_;
};

#endif // MAP_H

Remove getPlantName metohod & Add getPlant mathod


/* Copyright (c) 2015, ENEA Software AB
 * Copyright (c) 2015, Nokia
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef __OFP_ODP_COMPAT__
#define __OFP_ODP_COMPAT__

#if ODP_VERSION == 102
#include "linux.h"
#else
#include "odp/helper/linux.h"
#endif /* odp_version == 102 */

#if ODP_VERSION < 105
typedef uint64_t odp_time_t;
#endif /* ODP_VERSION < 105 */

#if ODP_VERSION < 104 && ODP_VERSION > 101
#define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_def_worker(cpumask, num_workers)
#elif ODP_VERSION < 102
#define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_count(cpumask)
#define ODP_THREAD_WORKER
#define ODP_THREAD_CONTROL
#endif

#endif

/* Copyright (c) 2015, ENEA Software AB
 * Copyright (c) 2015, Nokia
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef __OFP_ODP_COMPAT__
#define __OFP_ODP_COMPAT__

#if ODP_VERSION == 102
#include "linux.h"
#else
#include "odp/helper/linux.h"
#endif /* odp_version == 102 */

#if ODP_VERSION < 105
typedef uint64_t odp_time_t;
#endif /* ODP_VERSION < 105 */

#if ODP_VERSION < 104 && ODP_VERSION > 101
#define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_def_worker(cpumask, num_workers)
#elif ODP_VERSION < 102
#define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_count(cpumask)
#define odp_init_local(x) odp_init_local()
#define ODP_THREAD_WORKER 0
#define ODP_THREAD_CONTROL 1
#endif

#endif

Define ODP_THREAD_WORKER and ODP_THREAD_CONTROL as in it's original enum, instead of mangling them.

Defining odp_init_local like this we can initialized properly the
values of ODP_THREAD_WORKER and ODP_THREAD_CONTROL. This is important
for the following patch where we need to define odp_threat_type_t.

Signed-off-by: José Pekkarinen <d7cb8761fb0e75b1a78c2fda4f1daed76cd46cfe@nokia.com>
Reviewed-and-tested-by: Sorin Vultureanu <8013ba55f8675034bc2ab0d6c3a1c9650437ca36@enea.com>


/***** Preamble block *********************************************************
*
* This file is part of h5py, a Python interface to the HDF5 library.
*
* http://www.h5py.org
*
* Copyright 2008-2013 Andrew Collette and contributors
*
* License:  Standard 3-clause BSD; see "license.txt" for full license terms
*           and contributor agreement.
*
****** End preamble block ****************************************************/

/* Contains compatibility macros and definitions for use by Cython code */

#ifndef H5PY_COMPAT
#define H5PY_COMPAT

#include <stddef.h>
#include "Python.h"
#include "numpy/arrayobject.h"
#include "hdf5.h"

/* The HOFFSET macro can't be used from Cython. */

#define h5py_size_n64 (sizeof(npy_complex64))
#define h5py_size_n128 (sizeof(npy_complex128))

#define h5py_offset_n64_real (HOFFSET(npy_complex64, real))
#define h5py_offset_n64_imag (HOFFSET(npy_complex64, imag))
#define h5py_offset_n128_real (HOFFSET(npy_complex128, real))
#define h5py_offset_n128_imag (HOFFSET(npy_complex128, imag))

#endif

/***** Preamble block *********************************************************
*
* This file is part of h5py, a Python interface to the HDF5 library.
*
* http://www.h5py.org
*
* Copyright 2008-2013 Andrew Collette and contributors
*
* License:  Standard 3-clause BSD; see "license.txt" for full license terms
*           and contributor agreement.
*
****** End preamble block ****************************************************/

/* Contains compatibility macros and definitions for use by Cython code */

#ifndef H5PY_COMPAT
#define H5PY_COMPAT

#if (MPI_VERSION < 3) && !defined(PyMPI_HAVE_MPI_Message)
typedef void *PyMPI_MPI_Message;
#define MPI_Message PyMPI_MPI_Message
#endif

#include <stddef.h>
#include "Python.h"
#include "numpy/arrayobject.h"
#include "hdf5.h"

/* The HOFFSET macro can't be used from Cython. */

#define h5py_size_n64 (sizeof(npy_complex64))
#define h5py_size_n128 (sizeof(npy_complex128))

#define h5py_offset_n64_real (HOFFSET(npy_complex64, real))
#define h5py_offset_n64_imag (HOFFSET(npy_complex64, imag))
#define h5py_offset_n128_real (HOFFSET(npy_complex128, real))
#define h5py_offset_n128_imag (HOFFSET(npy_complex128, imag))

#endif

Add conditional definition of PyMPI_MPI_Message and MPI_Message PyMPI_MPI_Message. This is needed for MPI_VERSION<3 and a recent version of mpi4py.

Follows gh-401 https://groups.google.com/d/topic/h5py/Uw5x3BKwJGU/discussion and https://groups.google.com/d/topic/mpi4py/xnDyYvawB-Q/discussion.


/*
 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
 *
 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 */

#define L_strlcpy
#define Wstrlcpy __strlcpy

#include "wstring.c"

strong_alias(__strlcpy, strlcpy)

#ifdef __LOCALE_C_ONLY
weak_alias(strlcpy, strxfrm)
#endif

#undef L_strlcpy

/*
 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
 *
 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 */

#define L_strlcpy
#define Wstrlcpy __strlcpy

#include "wstring.c"

strong_alias(__strlcpy, strlcpy)

#ifdef __LOCALE_C_ONLY
weak_alias(__strlcpy, __strxfrm)
strong_alias(__strxfrm, strxfrm)
#endif

#undef L_strlcpy

Use correct syntax, correct weak/strong for [__]strxfrm


#include <fcntl.h>
#include <k/sys.h>

int open(const char *path, int oflag, ...) {
    return MAKE_SYSCALL(open, path, oflag);
}

int fcntl(int fildes, int cmd, ...) {
    //FIXME for bash
    return MAKE_SYSCALL(unimplemented, "fcntl", false);
}

#include <fcntl.h>
#include <stdarg.h>
#include <k/sys.h>

int open(const char *path, int oflag, ...) {
    int mode = 0;
    if(oflag & O_CREAT) {
        va_list va;
        va_start(va, oflag);
        mode = va_arg(va, int);
        va_end(va);
    }
    return MAKE_SYSCALL(open, path, oflag, mode);
}

int fcntl(int fildes, int cmd, ...) {
    //FIXME for bash
    return MAKE_SYSCALL(unimplemented, "fcntl", false);
}

Fix open() syscall in libk

Fix open() syscall in libk


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

#ifndef BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
#define BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_

#import <Foundation/Foundation.h>

#include <string>

#include "base/mac/scoped_nsobject.h"
#include "brightray/browser/notification.h"

namespace brightray {

class CocoaNotification : public Notification {
 public:
  CocoaNotification(NotificationDelegate* delegate,
                    NotificationPresenter* presenter);
  ~CocoaNotification();

  // Notification:
  void Show(const base::string16& title,
            const base::string16& msg,
            const std::string& tag,
            const GURL& icon_url,
            const SkBitmap& icon,
            bool silent,
            const bool has_reply,
            const base::string16 reply_placeholder) override;
  void Dismiss() override;

  void NotificationDisplayed();
  void NotificationReplied(const std::string reply);

  NSUserNotification* notification() const { return notification_; }

 private:
  base::scoped_nsobject<NSUserNotification> notification_;

  DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
};

}  // namespace brightray

#endif  // BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_

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

#ifndef BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
#define BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_

#import <Foundation/Foundation.h>

#include <string>

#include "base/mac/scoped_nsobject.h"
#include "brightray/browser/notification.h"

namespace brightray {

class CocoaNotification : public Notification {
 public:
  CocoaNotification(NotificationDelegate* delegate,
                    NotificationPresenter* presenter);
  ~CocoaNotification();

  // Notification:
  void Show(const base::string16& title,
            const base::string16& msg,
            const std::string& tag,
            const GURL& icon_url,
            const SkBitmap& icon,
            bool silent,
            const bool has_reply,
            const base::string16& reply_placeholder) override;
  void Dismiss() override;

  void NotificationDisplayed();
  void NotificationReplied(const std::string reply);

  NSUserNotification* notification() const { return notification_; }

 private:
  base::scoped_nsobject<NSUserNotification> notification_;

  DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
};

}  // namespace brightray

#endif  // BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_

Fix reference typed reply placeholder

Fix reference typed reply placeholder


#ifndef AL_MATH_DEFS_H
#define AL_MATH_DEFS_H

#define F_PI    (3.14159265358979323846f)
#define F_PI_2  (1.57079632679489661923f)
#define F_TAU   (6.28318530717958647692f)

#ifndef FLT_EPSILON
#define FLT_EPSILON (1.19209290e-07f)
#endif

#define DEG2RAD(x)  ((ALfloat)(x) * (F_PI/180.0f))
#define RAD2DEG(x)  ((ALfloat)(x) * (180.0f/F_PI))

#endif /* AL_MATH_DEFS_H */

#ifndef AL_MATH_DEFS_H
#define AL_MATH_DEFS_H

#ifdef HAVE_FLOAT_H
#include <float.h>
#endif

#define F_PI    (3.14159265358979323846f)
#define F_PI_2  (1.57079632679489661923f)
#define F_TAU   (6.28318530717958647692f)

#ifndef FLT_EPSILON
#define FLT_EPSILON (1.19209290e-07f)
#endif

#define DEG2RAD(x)  ((ALfloat)(x) * (F_PI/180.0f))
#define RAD2DEG(x)  ((ALfloat)(x) * (180.0f/F_PI))

#endif /* AL_MATH_DEFS_H */

Include float.h if present before defining math stuff


/*

Copyright (c) 2011, Simon Howard

Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice appear
in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

 */

#ifndef LHASA_LHA_LH5_DECODER_H
#define LHASA_LHA_LH5_DECODER_H

#include "lha_decoder.h"

extern LHADecoderType lha_lh5_decoder;

#endif /* #ifndef LHASA_LHA_LH5_DECODER_H */

Add missing header for -lh5- decoder.

Add missing header for -lh5- decoder.


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

#include <haka/error.h>
#include <haka/regexp_module.h>

struct regexp_module *regexp_module_load(const char *module_name, struct parameters *args) {
	struct module *module = module_load(module_name, args);
	if (module == NULL || module->type != MODULE_REGEXP) {
		if (module != NULL) module_release(module);
		error(L"Module %s is not of type MODULE_REGEXP", module_name);
		return NULL;
	}

	return (struct regexp_module *)module;
}

void regexp_module_release(struct regexp_module *module)
{
	module_release((struct module *)module);
}

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

#include <haka/error.h>
#include <haka/regexp_module.h>

struct regexp_module *regexp_module_load(const char *module_name, struct parameters *args) {
	struct module *module = module_load(module_name, args);
	if (module == NULL || module->type != MODULE_REGEXP) {
		if (module != NULL) module_release(module);
		error(L"Module %s is not of type MODULE_REGEXP", module_name);
		return NULL;
	}

	return (struct regexp_module *)module;
}

void regexp_module_release(struct regexp_module *module)
{
	module_release(&module->module);
}

Replace cast by safer access

Replace cast by safer access


#include "cx/fileb.h"

static real
sum_line (FileB* f)
{
    real x = 0, y = 0;
    while (load_real_FileB (f, &y))
        x += y;
    return x;
}

int main ()
{
    DecloStack( FileB, f );
    FILE* in = stdin;
    FILE* out = stdout;

    init_FileB (f);
    f->f = in;
    f->byline = true;

    while (getline_FileB (f))
    {
        FileB olay;
        real x;

        olay_FileB (&olay, f);
        x = sum_line (&olay);
        fprintf (out, "%f\n", x);
        fflush (out);
    }

    return 0;
}

#include "cx/fileb.h"

static real
sum_line (FileB* f)
{
    real x = 0, y = 0;
    while (load_real_FileB (f, &y))
        x += y;
    f->good = true;
    skipds_FileB (f, 0);
    if (cstr_FileB (f) [0] != '\0')
        fputs ("Line is no good!\n", stderr);
    return x;
}

int main ()
{
    DecloStack( FileB, f );
    FILE* in = stdin;
    FILE* out = stdout;

    init_FileB (f);
    f->f = in;
    f->byline = true;

    while (getline_FileB (f))
    {
        FileB olay;
        real x;

        olay_FileB (&olay, f);
        x = sum_line (&olay);
        fprintf (out, "%f\n", x);
        fflush (out);
    }

    return 0;
}

Add utility gives a warning on bad parse


// itickable.h
//
// Interface definition of an object that is updated during the tick cycle.
//
#ifndef DEMO_ITICKABLE_H
#define DEMO_ITICKABLE_H

namespace demo
{

namespace obj
{

class ITickable
{
  public:
    // CONSTRUCTORS
    ~ITickable();

    // MEMBER FUNCTIONS
    /**
     * Prepare for the next tick cycle.
     */
    virtual void preTick() = 0;

    /**
     * Update the object.
     * @param dt The elapsed time.
     */
    virtual void tick( float dt ) = 0;

    /**
     * Clean up after the tick cycle.
     */
    virtual void postTick() = 0;
};

// CONSTRUCTORS
ITickable::~ITickable()
{
}

} // End nspc obj

} // End nspc demo

#endif // DEMO_ITICKABLE_H

// itickable.h
//
// Interface definition of an object that is updated during the tick cycle.
//
#ifndef DEMO_ITICKABLE_H
#define DEMO_ITICKABLE_H

namespace demo
{

namespace obj
{

class ITickable
{
  public:
    // CONSTRUCTORS
    /**
     * Destruct the tickable.
     */
    ~ITickable();

    // MEMBER FUNCTIONS
    /**
     * Prepare for the next tick cycle.
     */
    virtual void preTick() = 0;

    /**
     * Update the object.
     * @param dt The elapsed time in seconds.
     */
    virtual void tick( float dt ) = 0;

    /**
     * Clean up after the tick cycle.
     */
    virtual void postTick() = 0;
};

// CONSTRUCTORS
inline
ITickable::~ITickable()
{
}

} // End nspc obj

} // End nspc demo

#endif // DEMO_ITICKABLE_H

Clean up the tickable definition.

Clean up the tickable definition.


@import UIKit;

@protocol HYPScatterPlotDataSource;

@class HYPScatterPoint;
@class HYPScatterLabel;

@interface HYPScatterPlot : UIView

@property (nonatomic) UIColor *averageLineColor;
@property (nonatomic) UIColor *xAxisColor;
@property (nonatomic) UIColor *yAxisMidGradient;
@property (nonatomic) UIColor *yAxisEndGradient;

@property (nonatomic, weak) id<HYPScatterPlotDataSource> dataSource;

@end

@protocol HYPScatterPlotDataSource <NSObject>

@required

- (NSArray *)scatterPointsForScatterPlot:(HYPScatterPlot *)scatterPlot;
- (HYPScatterPoint *)maximumXValue:(HYPScatterPlot *)scatterPlot;
- (HYPScatterPoint *)minimumXValue:(HYPScatterPlot *)scatterPlot;
- (HYPScatterPoint *)maximumYValue:(HYPScatterPlot *)scatterPlot;
- (HYPScatterPoint *)minimumYValue:(HYPScatterPlot *)scatterPlot;

@optional

- (CGFloat)averageYValue:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)minimumYLabel:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)maximumYLabel:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)minimumXLabel:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)maximumXLabel:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)averageLabel:(HYPScatterPlot *)scatterPlot;

@end

@import UIKit;

@protocol HYPScatterPlotDataSource;

@class HYPScatterPoint;
@class HYPScatterLabel;

@interface HYPScatterPlot : UIView

@property (nonatomic) UIColor *averageLineColor;
@property (nonatomic) UIColor *xAxisColor;
@property (nonatomic) UIColor *yAxisMidGradient;
@property (nonatomic) UIColor *yAxisEndGradient;

@property (nonatomic, weak) id<HYPScatterPlotDataSource> dataSource;

@end

@protocol HYPScatterPlotDataSource <NSObject>

@required

/**

 @return should be a list of HYPScatterPoint objects
 */
- (NSArray *)scatterPointsForScatterPlot:(HYPScatterPlot *)scatterPlot;
- (HYPScatterPoint *)maximumXValue:(HYPScatterPlot *)scatterPlot;
- (HYPScatterPoint *)minimumXValue:(HYPScatterPlot *)scatterPlot;
- (HYPScatterPoint *)maximumYValue:(HYPScatterPlot *)scatterPlot;
- (HYPScatterPoint *)minimumYValue:(HYPScatterPlot *)scatterPlot;

@optional

- (CGFloat)averageYValue:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)minimumYLabel:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)maximumYLabel:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)minimumXLabel:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)maximumXLabel:(HYPScatterPlot *)scatterPlot;
- (HYPScatterLabel *)averageLabel:(HYPScatterPlot *)scatterPlot;

@end

Add an important info. for scatter datasource


#ifndef FLASH_WRITER_H
#define FLASH_WRITER_H

#include <stdint.h>
#include <stddef.h>

/** Unlocks the flash for programming. */
void flash_writer_unlock(void);

/** Locks the flash */
void flash_writer_lock(void);

/** Erases the flash page at given address. */
void flash_writer_page_erase(void *page);

/** Writes data to given location in flash. */
void flash_writer_page_write(void *page, uint8_t *data, size_t len);

#endif /* FLASH_WRITER_H */

#ifndef FLASH_WRITER_H
#define FLASH_WRITER_H

#include <stdint.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

/** Unlocks the flash for programming. */
void flash_writer_unlock(void);

/** Locks the flash */
void flash_writer_lock(void);

/** Erases the flash page at given address. */
void flash_writer_page_erase(void *page);

/** Writes data to given location in flash. */
void flash_writer_page_write(void *page, uint8_t *data, size_t len);

#ifdef __cplusplus
}
#endif

#endif /* FLASH_WRITER_H */

Add missing extern "C" statements

Add missing extern "C" statements


// RUN: clang -checker-simple -verify %s

int* f1() {
  int x = 0;
  return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}

int* f2(int y) {
  return &y;  // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}}
}

int* f3(int x, int *y) {
  int w = 0;

  if (x)
    y = &w;

  return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}}
}

unsigned short* compound_literal() {
  return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}}
}

// RUN: clang -checker-simple -verify %s

int* f1() {
  int x = 0;
  return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned.}} expected-warning{{address of stack memory associated with local variable 'x' returned}}
}

int* f2(int y) {
  return &y;  // expected-warning{{Address of stack memory associated with local variable 'y' returned.}} expected-warning{{address of stack memory associated with local variable 'y' returned}}
}

int* f3(int x, int *y) {
  int w = 0;

  if (x)
    y = &w;

  return y; // expected-warning{{Address of stack memory associated with local variable 'w' returned.}}
}

void* compound_literal(int x) {
  if (x)
    return &(unsigned short){((unsigned short)0x22EF)}; // expected-warning{{Address of stack memory}} expected-warning{{braces around scalar initializer}}

  struct s { int z; double y; int w; };
  return &((struct s){ 2, 0.4, 5 * 8 });
}

Improve compound literal test case.

Improve compound literal test case.

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


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_enableSizeButton_clicked();

private:
    Ui::MainWindow *ui;
    double **xnPlus, **xnMinus, **ynPlus, **ynMinus;
    double alpha, beta, epsilon, lyambda, fi;
    double tau, n;

private:
    void initArrays();
    void initTauComboBox();
    void initQwtPlot();
    double func1(double xn, double yn);
    double func2(double xn);
    void buildTrajectory(int numTraj);
};

#endif // MAINWINDOW_H

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_enableSizeButton_clicked();

private:
    Ui::MainWindow *ui;
    double **xnPlus, **xnMinus, **ynPlus, **ynMinus;

private:
    void initArrays();
    void initTauComboBox();
    void initQwtPlot();
    double func1(double xn, double yn);
    double func2(double xn);
    void buildTrajectory(int numTraj);
};

#endif // MAINWINDOW_H

Remove unnecessary fields in class.

Remove unnecessary fields in class.


//
//  HTMLNode+Private.h
//  HTMLKit
//
//  Created by Iska on 20/12/15.
//  Copyright © 2015 BrainCookie. All rights reserved.
//

///------------------------------------------------------
/// HTMLKit private header
///------------------------------------------------------

#import <HTMLKit/HTMLKit.h>

/**
 Private HTML Node methods which are not intended for public API.
 */
@interface HTMLNode ()

/**
 A read-write redeclaration of the same property in the public API.
 */
@property (nonatomic, weak) HTMLDocument *ownerDocument;

/**
 A read-write redeclaration of the same property in the public API.
 */
@property (nonatomic, weak) HTMLNode *parentNode;

/**
 Designated initializer of the HTML Node, which, however, should not be used directly. It is intended to be called only
 by subclasses.

 @abstract Use concrete subclasses of the HTML Node.

 @param name The node's name.
 @param type The node's type.
 @return A new instance of a HTML Node.
 */
- (instancetype)initWithName:(NSString *)name type:(HTMLNodeType)type NS_DESIGNATED_INITIALIZER;

/**
 Casts this node to a HTML Element. This cast should only be performed after the appropriate check.
 */
- (HTMLElement *)asElement;

/**
 Returns the same string representation of the DOM tree rooted at this node that is used by html5lib-tests.

 @disucssion This method is indended for testing purposes.
 */
- (NSString *)treeDescription;

@end

//
//  HTMLNode+Private.h
//  HTMLKit
//
//  Created by Iska on 20/12/15.
//  Copyright © 2015 BrainCookie. All rights reserved.
//

///------------------------------------------------------
/// HTMLKit private header
///------------------------------------------------------

#import "HTMLNode.h"

/**
 Private HTML Node methods which are not intended for public API.
 */
@interface HTMLNode ()

/**
 A read-write redeclaration of the same property in the public API.
 */
@property (nonatomic, weak) HTMLDocument *ownerDocument;

/**
 A read-write redeclaration of the same property in the public API.
 */
@property (nonatomic, weak) HTMLNode *parentNode;

/**
 Designated initializer of the HTML Node, which, however, should not be used directly. It is intended to be called only
 by subclasses.

 @abstract Use concrete subclasses of the HTML Node.

 @param name The node's name.
 @param type The node's type.
 @return A new instance of a HTML Node.
 */
- (instancetype)initWithName:(NSString *)name type:(HTMLNodeType)type NS_DESIGNATED_INITIALIZER;

/**
 Casts this node to a HTML Element. This cast should only be performed after the appropriate check.
 */
- (HTMLElement *)asElement;

/**
 Returns the same string representation of the DOM tree rooted at this node that is used by html5lib-tests.

 @disucssion This method is indended for testing purposes.
 */
- (NSString *)treeDescription;

@end

Fix import in private HTMLNode header

Fix import in private HTMLNode header


//
//  SGFeature.h
//  SimpleGeo
//
//  Created by Seth Fitzsimmons on 11/14/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "SGPoint.h"

@interface SGFeature : NSObject
{
    NSString* featureId;
    SGPoint* geometry;
    NSDictionary* properties;
    NSString* rawBody;
}

@property (readonly) NSString* featureId;
@property (readonly) SGPoint* geometry;
@property (readonly) NSDictionary* properties;
@property (readonly) NSString* rawBody;

+ (SGFeature *)featureWithId:(NSString *)id;
+ (SGFeature *)featureWithId:(NSString *)id
                        data:(NSDictionary *)data;
+ (SGFeature *)featureWithId:(NSString *)id
                        data:(NSDictionary *)data
                     rawBody:(NSString *)rawBody;
+ (SGFeature *)featureWithData:(NSDictionary *)data;
- (id)initWithId:(NSString *)id;
- (id)initWithId:(NSString *)id
            data:(NSDictionary *)data;
- (id)initWithId:(NSString *)id
            data:(NSDictionary *)data
         rawBody:(NSString *)rawBody;

@end

//
//  SGFeature.h
//  SimpleGeo
//
//  Created by Seth Fitzsimmons on 11/14/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "SGPoint.h"

@interface SGFeature : NSObject
{
    NSString* featureId;
    SGPoint* geometry;
    NSDictionary* properties;
    NSString* rawBody;
}

@property (retain,readonly) NSString* featureId;
@property (retain,readonly) SGPoint* geometry;
@property (retain,readonly) NSDictionary* properties;
@property (retain,readonly) NSString* rawBody;

+ (SGFeature *)featureWithId:(NSString *)id;
+ (SGFeature *)featureWithId:(NSString *)id
                        data:(NSDictionary *)data;
+ (SGFeature *)featureWithId:(NSString *)id
                        data:(NSDictionary *)data
                     rawBody:(NSString *)rawBody;
+ (SGFeature *)featureWithData:(NSDictionary *)data;
- (id)initWithId:(NSString *)id;
- (id)initWithId:(NSString *)id
            data:(NSDictionary *)data;
- (id)initWithId:(NSString *)id
            data:(NSDictionary *)data
         rawBody:(NSString *)rawBody;

@end

Revert "No reason for readonly properties to be retained"

This reverts commit eeed3d87ea740ab73995af2de8f044e3a9a3082d.


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

#include "trie.h"

#define char_index(c) c - 97

trie *
trie_init(void)
{
	trie *t = emalloc(sizeof(*t));
	memset(t, 0, sizeof(*t));
	t->children = emalloc(R_SIZE * sizeof(*(t->children)));
	memset(t->children, 0, sizeof(*(t->children)));
	return t;
}

void
trie_insert(trie *t, const char *key, size_t value)
{
	const char *c = key;
	trie *cur_node = t;
	while (*c) {
		if (cur_node->children[char_index(*c)] == NULL)
			cur_node->children[char_index(*c)] = trie_init();
		cur_node = cur_node->children[char_index(*c)];
		c++;
	}
	cur_node->count = value;
}

size_t
trie_get(trie *t, const char *key)
{
	const char *c = key;
	trie *cur_node = t;
	while (*c) {
		if (cur_node->children[char_index(*c)] == NULL)
			return 0;
		cur_node = cur_node->children[char_index(*c)];
		c++;
	}
	return cur_node->count;
}

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

#include "trie.h"

#define char_index(c) c - 97

trie *
trie_init(void)
{
	trie *t = emalloc(sizeof(*t));
	memset(t, 0, sizeof(*t));
	t->children = ecalloc(R_SIZE, sizeof(*(t->children)));
	return t;
}

void
trie_insert(trie *t, const char *key, size_t value)
{
	const char *c = key;
	trie *cur_node = t;
	while (*c) {
		if (cur_node->children[char_index(*c)] == NULL)
			cur_node->children[char_index(*c)] = trie_init();
		cur_node = cur_node->children[char_index(*c)];
		c++;
	}
	cur_node->count = value;
}

size_t
trie_get(trie *t, const char *key)
{
	const char *c = key;
	trie *cur_node = t;
	while (*c) {
		if (cur_node->children[char_index(*c)] == NULL)
			return 0;
		cur_node = cur_node->children[char_index(*c)];
		c++;
	}
	return cur_node->count;
}

Replace malloc + memset with calloc

Replace malloc + memset with calloc


/*
 * Copyright 2011-2016 Blender Foundation
 *
 * 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 __UTIL_VERSION_H__
#define __UTIL_VERSION_H__

/* Cycles version number */

CCL_NAMESPACE_BEGIN

#define CYCLES_VERSION_MAJOR 1
#define CYCLES_VERSION_MINOR 10
#define CYCLES_VERSION_PATCH 0

#define CYCLES_MAKE_VERSION_STRING2(a, b, c) #a "." #b "." #c
#define CYCLES_MAKE_VERSION_STRING(a, b, c) CYCLES_MAKE_VERSION_STRING2(a, b, c)
#define CYCLES_VERSION_STRING \
  CYCLES_MAKE_VERSION_STRING(CYCLES_VERSION_MAJOR, CYCLES_VERSION_MINOR, CYCLES_VERSION_PATCH)

CCL_NAMESPACE_END

#endif /* __UTIL_VERSION_H__ */

/*
 * Copyright 2011-2016 Blender Foundation
 *
 * 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 __UTIL_VERSION_H__
#define __UTIL_VERSION_H__

/* Cycles version number */

CCL_NAMESPACE_BEGIN

#define CYCLES_VERSION_MAJOR 1
#define CYCLES_VERSION_MINOR 11
#define CYCLES_VERSION_PATCH 0

#define CYCLES_MAKE_VERSION_STRING2(a, b, c) #a "." #b "." #c
#define CYCLES_MAKE_VERSION_STRING(a, b, c) CYCLES_MAKE_VERSION_STRING2(a, b, c)
#define CYCLES_VERSION_STRING \
  CYCLES_MAKE_VERSION_STRING(CYCLES_VERSION_MAJOR, CYCLES_VERSION_MINOR, CYCLES_VERSION_PATCH)

CCL_NAMESPACE_END

#endif /* __UTIL_VERSION_H__ */

Bump Cycles version to 1.11.0 (Blender 2.81)


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

#ifndef CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_
#define CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_
#pragma once

#import <Foundation/Foundation.h>

// You should think twice every single time you use anything from this
// namespace.
namespace ObjcEvilDoers {

// Enable zombies.  Returns NO if it fails to enable.
//
// When |zombieAllObjects| is YES, all objects inheriting from
// NSObject become zombies on -dealloc.  If NO, -shouldBecomeCrZombie
// is queried to determine whether to make the object a zombie.
//
// |zombieCount| controls how many zombies to store before freeing the
// oldest.  Set to 0 to free objects immediately after making them
// zombies.
BOOL ZombieEnable(BOOL zombieAllObjects, size_t zombieCount);

// Disable zombies.
void ZombieDisable();

}  // namespace ObjcEvilDoers

@interface NSObject (CrZombie)
- (BOOL)shouldBecomeCrZombie;
@end

#endif  // CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_

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

#ifndef CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_
#define CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_
#pragma once

#import <Foundation/Foundation.h>

// You should think twice every single time you use anything from this
// namespace.
namespace ObjcEvilDoers {

// Enable zombie object debugging. This implements a variant of Apple's
// NSZombieEnabled which can help expose use-after-free errors where messages
// are sent to freed Objective-C objects in production builds.
//
// Returns NO if it fails to enable.
//
// When |zombieAllObjects| is YES, all objects inheriting from
// NSObject become zombies on -dealloc.  If NO, -shouldBecomeCrZombie
// is queried to determine whether to make the object a zombie.
//
// |zombieCount| controls how many zombies to store before freeing the
// oldest.  Set to 0 to free objects immediately after making them
// zombies.
BOOL ZombieEnable(BOOL zombieAllObjects, size_t zombieCount);

// Disable zombies.
void ZombieDisable();

}  // namespace ObjcEvilDoers

@interface NSObject (CrZombie)
- (BOOL)shouldBecomeCrZombie;
@end

#endif  // CHROME_BROWSER_COCOA_NSOBJECT_ZOMBIE_H_

Add link to explanation of what we mean by zombie
The person triaging / debugging a zombie crash may never have heard of this before.

BUG=None
TEST=None

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

git-svn-id: http://src.chromium.org/svn/trunk/src@62723 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: afedf4fa79fedacfcd285d49f1c044ddd138951e


#ifndef ROS_BOOT_H
#define ROS_BOOT_H

/// PROJECT
#include <csapex/core/bootstrap_plugin.h>
#include <csapex/core/core_fwd.h>
#include <csapex/model/model_fwd.h>
#include <csapex/msg/msg_fwd.h>
#include <csapex/view/view_fwd.h>

/// SYSTEM
// clang-format off
#include <csapex/utility/suppress_warnings_start.h>
#include <pluginlib/class_loader.hpp>
#include <csapex/utility/suppress_warnings_end.h>
// clang-format on

namespace csapex
{
class RosBoot : public BootstrapPlugin
{
public:
    RosBoot();
    void boot(csapex::PluginLocator* locator);

private:
    std::vector<std::string> valid_plugin_xml_files_;

    pluginlib::ClassLoader<CorePlugin> loader_core_;
    pluginlib::ClassLoader<MessageProvider> loader_msg_;
    pluginlib::ClassLoader<MessageRenderer> loader_msg_renderer_;
    pluginlib::ClassLoader<Node> loader_node_;
    pluginlib::ClassLoader<NodeAdapterBuilder> loader_node_adapter_;
    pluginlib::ClassLoader<ParameterAdapterBuilder> loader_param_adapter_;
    pluginlib::ClassLoader<DragIOHandler> loader_drag_io_;
};

}  // namespace csapex
#endif  // ROS_BOOT_H

#ifndef ROS_BOOT_H
#define ROS_BOOT_H

/// PROJECT
#include <csapex/core/bootstrap_plugin.h>
#include <csapex/core/core_fwd.h>
#include <csapex/model/model_fwd.h>
#include <csapex/msg/msg_fwd.h>
#include <csapex/view/view_fwd.h>

/// SYSTEM
// clang-format off
#include <csapex/utility/suppress_warnings_start.h>
#if CLASS_LOADER_USES_HPP
#include <pluginlib/class_loader.hpp>
#else
#include <pluginlib/class_loader.h>
#endif
#include <csapex/utility/suppress_warnings_end.h>
// clang-format on

namespace csapex
{
class RosBoot : public BootstrapPlugin
{
public:
    RosBoot();
    void boot(csapex::PluginLocator* locator);

private:
    std::vector<std::string> valid_plugin_xml_files_;

    pluginlib::ClassLoader<CorePlugin> loader_core_;
    pluginlib::ClassLoader<MessageProvider> loader_msg_;
    pluginlib::ClassLoader<MessageRenderer> loader_msg_renderer_;
    pluginlib::ClassLoader<Node> loader_node_;
    pluginlib::ClassLoader<NodeAdapterBuilder> loader_node_adapter_;
    pluginlib::ClassLoader<ParameterAdapterBuilder> loader_param_adapter_;
    pluginlib::ClassLoader<DragIOHandler> loader_drag_io_;
};

}  // namespace csapex
#endif  // ROS_BOOT_H

Fix jade version of class_loader not containing class_loader.hpp


#ifndef GWKV_HT_WRAPPER
#define GWKV_HT_WRAPPER

#include <stdlib.h>
#include "../hashtable/hashtable.h"

/* Operations the table supports */
typedef enum {
        GET,
        SET
} method;

/* Defines for result codes */
#define STORED 0
#define NOT_STORED 1
#define EXISTS 2
#define NOT_FOUND 3

/* Datatype for wrapping datastore values */
struct {
        method method_type,
        const char* key,
        size_t key_length,
        const char* value,
        size_t value_length
} operation;

/**
 * Wrapper function to set a value in the hashtable
 * Returns either STORED or NOT_STORED (defined above)
 */
int
gwkv_server_set (memcached_st *ptr,
                 const char *key,
                 size_t key_length,
                 const char *value,
                 size_t value_length);

/**
 * Wrapper function to read a value from the hashtable
 * Returns the data if sucessful, or NULL on error
 * These correspond to the EXISTS and NOT_FOUND codes above
 */
char*
gwkv_server_get (memcached_st *ptr,
                 const char *key,
                 size_t key_length,
                 size_t *value_length);

#endif

#ifndef GWKV_HT_WRAPPER
#define GWKV_HT_WRAPPER

#include <stdlib.h>
#include "../hashtable/hashtable.h"

/* Types of hashing algorithms we support */
typedef enum {
        MD5
} hash_type;

/* All encompassing datatype for server datastore */
struct {
        ht* hashtable,
        hash_type hash
} gwkv_server;

/* Operations the table supports */
typedef enum {
        GET,
        SET
} method;

/* Defines for result codes */
#define STORED 0
#define NOT_STORED 1
#define EXISTS 2
#define NOT_FOUND 3

/* Datatype for wrapping datastore values */
struct {
        method method_type,
        const char* key,
        size_t key_length,
        const char* value,
        size_t value_length
} operation;

/* Initialize a new key/value datastore */
gwkv_server*
gwkv_server_init(hash_type hash_algorithm);

/**
 * Wrapper function to set a value in the hashtable
 * Returns either STORED or NOT_STORED (defined above)
 */
int
gwkv_server_set (memcached_st *ptr,
                 const char *key,
                 size_t key_length,
                 const char *value,
                 size_t value_length);

/**
 * Wrapper function to read a value from the hashtable
 * Returns the data if sucessful, or NULL on error
 * These correspond to the EXISTS and NOT_FOUND codes above
 */
char*
gwkv_server_get (memcached_st *ptr,
                 const char *key,
                 size_t key_length,
                 size_t *value_length);

/* Frees all memory associated with the datastore */
void
gwkv_server_free(gwkv_server* server);

#endif

Add struct to keep datastore things

Add struct to keep datastore things


static const char *docs_usage[] = {
"usage enchive [-p|--pubkey <file>] [-s|--seckey <file>]",
#if ENCHIVE_OPTION_AGENT
"              [-a|--agent[=seconds]] [-A|--no-agent]",
#endif
"              [--version] [--help]",
"              <command> [args]",
"",
"Commands (unique prefixes accepted):",
"  keygen        generate a new master keypair",
"  archive       archive using the public key",
"  extract       extract from an archive using the secret key",
"  fingerprint   print the master keypair fingerprint",
"",
"  -p, --pubkey <file>        set the public key file [~/.enchive.pub]",
"  -s, --seckey <file>        set the secret key file [~/.enchive.sec]",
#if ENCHIVE_OPTION_AGENT
"  -a, --agent[=seconds]      run key agent after reading a passphrase ["
     STR(ENCHIVE_AGENT_TIMEOUT) "]",
"  -A, --no-agent             don't run the key agent"
#  if ENCHIVE_AGENT_DEFAULT_ENABLED
    "",
#  else
    " (default)",
#  endif
#endif
"  --version                  display version information",
"  --help                     display this usage information",
"",
"Enchive archives files by encrypting them to yourself using your",
"public key. It uses ChaCha20, Curve25519, and HMAC-SHA256.",
0};

static const char *docs_usage[] = {
"usage enchive [-p|--pubkey <file>] [-s|--seckey <file>]",
#if ENCHIVE_OPTION_AGENT
"              [-a|--agent[=seconds]] [-A|--no-agent]",
#endif
"              [--version] [--help]",
"              <command> [args]",
"",
"Commands (unique prefixes accepted):",
"  keygen        generate a new master keypair",
"  archive       archive using the public key",
"  extract       extract from an archive using the secret key",
"  fingerprint   print the master keypair fingerprint",
"",
"  -p, --pubkey <file>        set the public key file",
"  -s, --seckey <file>        set the secret key file",
#if ENCHIVE_OPTION_AGENT
"  -a, --agent[=seconds]      run key agent after reading a passphrase ["
     STR(ENCHIVE_AGENT_TIMEOUT) "]",
"  -A, --no-agent             don't run the key agent"
#  if ENCHIVE_AGENT_DEFAULT_ENABLED
    "",
#  else
    " (default)",
#  endif
#endif
"  --version                  display version information",
"  --help                     display this usage information",
"",
"Enchive archives files by encrypting them to yourself using your",
"public key. It uses ChaCha20, Curve25519, and HMAC-SHA256.",
0};

Remove incorrect path defaults from --help


#include <stdio.h>

#include "aes.h"

static void aes_encrypt_block_openssl(const unsigned char *, unsigned char *, const AES_KEY *);
static void aes_encrypt_block_aesni(const unsigned char *, unsigned char *, const AES_KEY *);

int
use_aesni()
{
	return 0;
}

void
aes_encrypt_block(const unsigned char *in, unsigned char *out, const AES_KEY *key)
{
	if (use_aesni())
	{
		aes_encrypt_block_aesni(in, out, key);
	}
	else
	{
		aes_encrypt_block_openssl(in, out, key);
	}
}

static void
aes_encrypt_block_openssl(const unsigned char *in, unsigned char *out, const AES_KEY *key)
{
	AES_encrypt(in, out, key);
}

static void
aes_encrypt_block_aesni(const unsigned char *in, unsigned char *out, const AES_KEY *key)
{
	AES_encrypt(in, out, key);
}

#include <stdio.h>

#include "aes.h"

static void aes_encrypt_block_openssl(const unsigned char *, unsigned char *, const AES_KEY *);
static void aes_encrypt_block_aesni(const unsigned char *, unsigned char *, const AES_KEY *);

int
use_aesni()
{
	return 0;
}

void
aes_encrypt_block(const unsigned char *in, unsigned char *out, const AES_KEY *key)
{
	static int aesni;

	if (aesni == 0)
	{
		aesni = use_aesni();
	}

	if (aesni == 1)
	{
		aes_encrypt_block_aesni(in, out, key);
	}
	else
	{
		aes_encrypt_block_openssl(in, out, key);
	}
}

static void
aes_encrypt_block_openssl(const unsigned char *in, unsigned char *out, const AES_KEY *key)
{
	AES_encrypt(in, out, key);
}

static void
aes_encrypt_block_aesni(const unsigned char *in, unsigned char *out, const AES_KEY *key)
{
	AES_encrypt(in, out, key);
}

Use a static variable to track whether to use AES-NI


/*
 * detab: Replace tabs with blanks.
 */

#include <stdio.h>

#define MAXLINE 10000	/* Max input line length. */
#define TABSTOP	8	/* Set tab stop to eight characters. */

int	getaline(char *, int);
void	detab(char *);

/* detab:  Replace tabs with blanks. */
int
main(void)
{
	char	line[MAXLINE];	/* Current input line. */

	while (getaline(line, MAXLINE) > 0) {
		detab(line);
		printf("%s", line);
	}

	return 0;
}

/* getaline:  Read a line into `s'; return length. */
int
getaline(char *s, int lim)
{
	int c, i;

	c = 0;

	for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i)
		s[i] = c;
	if (c == '\n')
		s[i++] = c;
	s[i] = '\0';

	return i;
}

/* detab:  Replace tabs with blanks. */
void
detab(char *s)
{
	int i, j;

	for (i = 0; s[i] != '\0'; ++i) {
		if (s[i] == '\t') {
			for (j = 0; j <= (i % TABSTOP + TABSTOP); ++j)
				s[i + j] = ' ';
			i += j;
		}
	}
}

/*
 * detab: Replace tabs with blanks.
 */

#include <stdio.h>

#define TABSIZE	8

/* detab:  Replace tabs with blanks. */
int
main(void)
{
	int ch, i;

	for (i = 0; (ch = getchar()) != EOF; i++) {
		if (ch == '\n')
			i = 0;
		if (ch == '\t') {
			putchar(' ');
			while (i % TABSIZE) {
				putchar(' ');
				i++;
			}
		} else
			putchar(ch);
	}

	return 0;
}

Make detab actually work reliably.

Make detab actually work reliably.


//
//  HTMLText.h
//  HTMLKit
//
//  Created by Iska on 26/02/15.
//  Copyright (c) 2015 BrainCookie. All rights reserved.
//

#import "HTMLCharacterData.h"

NS_ASSUME_NONNULL_BEGIN

/**
 A HTML Text node
 */
@interface HTMLText : HTMLCharacterData

/**
 Initializes a new HTML text node.

 @param data The text string.
 @return A new isntance of a HTML text node.
 */
- (instancetype)initWithData:(NSString *)data;

/**
 Appends the string to this text node.

 @param string The string to append.
 */
- (void)appendString:(NSString *)string __attribute__((deprecated("Use the mutable data property instead.")));

@end

NS_ASSUME_NONNULL_END

//
//  HTMLText.h
//  HTMLKit
//
//  Created by Iska on 26/02/15.
//  Copyright (c) 2015 BrainCookie. All rights reserved.
//

#import "HTMLCharacterData.h"

NS_ASSUME_NONNULL_BEGIN

/**
 A HTML Text node
 */
@interface HTMLText : HTMLCharacterData

/**
 Initializes a new HTML text node.

 @param data The text string.
 @return A new isntance of a HTML text node.
 */
- (instancetype)initWithData:(NSString *)data;

/**
 Appends the string to this text node.

 @param string The string to append.
 */
- (void)appendString:(NSString *)string __attribute__((deprecated("Use `appendData:` instead.")));

@end

NS_ASSUME_NONNULL_END

Update deprecation message in HTML Text node


#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#include "parse.h"
#include "asm.h"

struct Asmbb {
    int id;
    char **lbls;
    size_t nlbls;
    Insn **insns;
    size_t ninsns;
    Bitset *livein;
    Bitset *liveout;
};

void adduses(Insn *i, Bitset *bs)
{
}

void subdefs(Insn *i, Bitset *bs)
{
}

Add in stubbing in of new register allocator.


#ifndef TOPVIEWSETTINGS_H
#define TOPVIEWSETTINGS_H

#include "smyrnadefs.h"

_BB void on_settingsOKBtn_clicked (GtkWidget *widget,gpointer user_data);
_BB void on_settingsCancelBtn_clicked (GtkWidget *widget,gpointer user_data);
int load_settings_from_graph(Agraph_t *g);
int update_graph_from_settings(Agraph_t *g);
int show_settings_form();

#endif

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

#ifndef TOPVIEWSETTINGS_H
#define TOPVIEWSETTINGS_H

#include "smyrnadefs.h"

_BB void on_settingsOKBtn_clicked(GtkWidget * widget, gpointer user_data);
_BB void on_settingsCancelBtn_clicked(GtkWidget * widget,
				      gpointer user_data);
extern int load_settings_from_graph(Agraph_t * g);
extern int update_graph_from_settings(Agraph_t * g);
extern int show_settings_form();

#endif

Clean up smyrna files: remove unnecessary globals modify libraries not to rely on code in cmd/smyrna remove static declarations from .h files remove unnecessary libraries mark unused code and clean up warnings


#ifndef RCR_LEVEL1PAYLOAD_SETUPABLE_H_
#define RCR_LEVEL1PAYLOAD_SETUPABLE_H_

#if defined(ARDUINO) && ARDUINO >= 100
	#include "arduino.h"
#else
	#include "WProgram.h"
#endif

namespace rcr {
namespace level1payload {

// An interface indicating a class requires construction (or constructor-like)
// logic to be delayed until Arduino setup() function.
class Setupable {
 public:
  // Setup this object. (Especially within the setup() function in the
  // Arduino program.)
  virtual void Setup() = 0;

  // Must provide virtual d'tor and body to prevent memory leak.
  virtual ~Setupable() {}
};

} // namespace level1_payload
} // namespace rcr

#endif // RCR_LEVEL1PAYLOAD_SETUPABLE_H_

Create an interface indicating a class requires construction (or constructor-like) logic to be delayed until Arduino setup() function


/****************************************************************************
 * Copyright (c) 2015, ARM Limited, All Rights Reserved
 * SPDX-License-Identifier: Apache-2.0
 *
 * 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 UNITY_CONFIG_H
#define UNITY_CONFIG_H

/* When using unity with the mbed RTOS printing to the serial port using the stdlib is not
   allowed as it causes a hardfault. Unity has the following define to control how failure
   messages are written:

   #ifndef UNITY_OUTPUT_CHAR
       #include <stdio.h>
       #define UNITY_OUTPUT_CHAR(a) (void)putchar(a)
   #endif

   To make this safe we can define our own version of UNITY_OUTPUT_CHAR and make sure it is
   thread safe.
*/
#ifndef UNITY_OUTPUT_CHAR
#define UNITY_OUTPUT_CHAR(a) utest_safe_putc(a)
#endif //UNITY_OUTPUT_CHAR

#endif // UNITY_CONFIG_H

Add configuration file. Unity provides the ability for the user to add this file in order to substitute built in Unity functions for user specific ones. In this case we are using it to redefine UNITY_OUTPUT_CHAR which is used by all the printing functions. By default it is directed to stdout, however to ensure the use of Unity is safe when used with the mbed RTOS the output char macros is redefined to a utest alternative. This alternative will only write a character to stdout if interrupts are enabled. NOTE to allow this configuration file to be used the following macro must be defined for the build: UNITY_INCLUDE_CONFIG_H


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

#include <gvc.h>
#include <pack.h>

int main (int argc, char* argv[])
{
    graph_t *g;
    graph_t *sg;
    FILE *fp;
    graph_t** cc;
    int       i, ncc;
    GVC_t *gvc;

    gvc = gvContext();

    if (argc > 1)
        fp = fopen(argv[1], "r");
    else
        fp = stdin;
    g = agread(fp);

    cc = ccomps(g, &ncc, (char*)0);

    for (i = 0; i < ncc; i++) {
        sg = cc[i];
        nodeInduce (sg);
        gvLayout(gvc, sg, "neato");
    }
    pack_graph (ncc, cc, g, 0);

    gvRender(gvc, g, "ps", stdout);

    for (i = 0; i < ncc; i++) {
        sg = cc[i];
        gvFreeLayout(gvc, sg);
        agdelete(g, sg);
    }

    agclose(g);

    return (gvFreeContext(gvc));

}

Add example using the pack library

Add example using the pack library


// The MIT License (MIT)
//
// Copyright(c) 2016 huan.wang
//
// 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,
//

#pragma once

#include <memory>

#include "net/http/context.h"

namespace net {
namespace http {

class Handler
{
public:
    virtual void ServeHTTP(std::shared_ptr<Context> ctx) = 0;
};

} // !namespace http
} // !namespace net

Add Handler for user to handle a http request.


#pragma once

template <typename T>
class Vector3 {
public:
	T x, y, z;

	Vector3(T x, T y, T z)
	{
		this->x = x;
		this->y = y;
		this->z = z;
	}
};

template <typename T>
class Vector4 {
public:
	T x, y, z, w;

	Vector4() {}

	Vector4(T x, T y, T z, T w)
	{
		this->x = x;
		this->y = y;
		this->z = z;
		this->w = w;
	}

	T &operator[](unsigned i)
	{
		return (&x)[i];
	}
};

#pragma once

template <typename T>
class Vector3 {
public:
	T x, y, z;

	Vector3(T x, T y, T z)
	{
		this->x = x;
		this->y = y;
		this->z = z;
	}

	T &operator[](unsigned i)
	{
		return (&x)[i];
	}
};

template <typename T>
class Vector4 {
public:
	T x, y, z, w;

	Vector4() {}

	Vector4(T x, T y, T z, T w)
	{
		this->x = x;
		this->y = y;
		this->z = z;
		this->w = w;
	}

	T &operator[](unsigned i)
	{
		return (&x)[i];
	}
};

Add subscript operator to Vector3

Add subscript operator to Vector3


#pragma once

namespace caprica {

template<typename T>
struct IntrusiveLinkedList final
{
  void push_back(T* val) {
    mSize++;
    if (front == nullptr) {
      front = back = val;
    } else {
      back->next = val;
      back = val;
    }
  }

  size_t size() const { return mSize; }

private:
  size_t mSize{ 0 };
  T* front{ nullptr };
  T* back{ nullptr };

  struct ConstIterator final
  {
    ConstIterator& operator ++() {
      if (cur == nullptr)
        return *this;
      cur = cur->next;
      return *this;
    }

    const T*& operator *() {
      return cur;
    }
    const T*& operator *() const {
      return cur;
    }
    const T*& operator ->() {
      return cur;
    }
    const T*& operator ->() const {
      return cur;
    }

    bool operator ==(const ConstIterator& other) const {
      return cur == other.cur;
    }

    bool operator !=(const ConstIterator& other) const {
      return !(*this == other);
    }

  private:
    friend IntrusiveLinkedList;
    const T* cur{ nullptr };

    ConstIterator() = default;
    ConstIterator(const T* front) : cur(front) { }
  };

  struct Iterator final
  {
    Iterator& operator ++() {
      if (cur == nullptr)
        return *this;
      cur = cur->next;
      return *this;
    }

    T*& operator *() {
      return cur;
    }
    const T*& operator *() const {
      return cur;
    }
    T*& operator ->() {
      return cur;
    }
    const T*& operator ->() const {
      return cur;
    }

    bool operator ==(const Iterator& other) const {
      return cur == other.cur;
    }

    bool operator !=(const Iterator& other) const {
      return !(*this == other);
    }

  private:
    friend IntrusiveLinkedList;
    T* cur{ nullptr };

    Iterator() = default;
    Iterator(T* front) : cur(front) { }
  };

public:
  ConstIterator begin() const {
    if (!mSize)
      return ConstIterator();
    return ConstIterator(front);
  }

  ConstIterator end() const {
    return ConstIterator();
  }

  Iterator begin() {
    if (!mSize)
      return Iterator();
    return Iterator(front);
  }

  Iterator end() {
    return Iterator();
  }
};

}

Add an intrusive linked list implementation to eliminate the heap allocations needed for the vectors.


/**
 ******************************************************************************
 * Xenia : Xbox 360 Emulator Research Project                                 *
 ******************************************************************************
 * Copyright 2013 Ben Vanik. All rights reserved.                             *
 * Released under the BSD license - see LICENSE in the root for more details. *
 ******************************************************************************
 */

#ifndef XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_
#define XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_

#include "xenia/kernel/xobject.h"
#include "xenia/xbox.h"

namespace xe {
namespace kernel {

struct X_SEMAPHORE {
  // TODO: Make this not empty!
};

class XSemaphore : public XObject {
 public:
  XSemaphore(KernelState* kernel_state);
  virtual ~XSemaphore();

  void Initialize(int32_t initial_count, int32_t maximum_count);
  void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header);

  int32_t ReleaseSemaphore(int32_t release_count);

  virtual void* GetWaitHandle() { return native_handle_; }

 private:
  HANDLE native_handle_;
};

}  // namespace kernel
}  // namespace xe

#endif  // XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_

/**
 ******************************************************************************
 * Xenia : Xbox 360 Emulator Research Project                                 *
 ******************************************************************************
 * Copyright 2013 Ben Vanik. All rights reserved.                             *
 * Released under the BSD license - see LICENSE in the root for more details. *
 ******************************************************************************
 */

#ifndef XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_
#define XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_

#include "xenia/kernel/xobject.h"
#include "xenia/xbox.h"

namespace xe {
namespace kernel {

struct X_SEMAPHORE {
  X_DISPATCH_HEADER header;
  // TODO: Make this not empty!
};

class XSemaphore : public XObject {
 public:
  XSemaphore(KernelState* kernel_state);
  virtual ~XSemaphore();

  void Initialize(int32_t initial_count, int32_t maximum_count);
  void InitializeNative(void* native_ptr, X_DISPATCH_HEADER& header);

  int32_t ReleaseSemaphore(int32_t release_count);

  virtual void* GetWaitHandle() { return native_handle_; }

 private:
  HANDLE native_handle_;
};

}  // namespace kernel
}  // namespace xe

#endif  // XENIA_KERNEL_XBOXKRNL_XSEMAPHORE_H_

Add the dispatch header to X_SEMAPHORE

Add the dispatch header to X_SEMAPHORE


#pragma once

#include "../definitions.h"

class ByteRegister {
public:
    ByteRegister() {};

    void set(const u8 new_value) { val = new_value; };
    u8 value() const { return val; };

    void increment() { val += 1; };
    void decrement() { val -= 1; };

private:
    u8 val;
};

class WordRegister {
public:
    WordRegister() {};

    void set(const u16 new_value) { val = new_value; };
    u16 value() const { return val; };

    u8 low() const;
    u8 high() const;

    void increment() { val += 1; };
    void decrement() { val -= 1; };

private:
    u16 val;
};

class RegisterPair {
public:
    RegisterPair(ByteRegister& high, ByteRegister& low);

    void set_low(const u8 byte);
    void set_high(const u8 byte);

    void set_low(const ByteRegister& byte);
    void set_high(const ByteRegister& byte);

    void set(const u16 word);

    u8 low() const;
    u8 high() const;

    u16 value() const;

    void increment();
    void decrement();

private:
    ByteRegister& low_byte;
    ByteRegister& high_byte;
};

class Offset {
public:
    Offset(u8 val) : val(val) {};
    Offset(ByteRegister& reg) : val(reg.value()) {};

    u8 value() { return val; }

private:
    u8 val;
};

#pragma once

#include "../definitions.h"

class ByteRegister {
public:
    ByteRegister() {}

    void set(const u8 new_value) { val = new_value; }
    u8 value() const { return val; }

    void increment() { val += 1; }
    void decrement() { val -= 1; }

private:
    u8 val;
};

class WordRegister {
public:
    WordRegister() {}

    void set(const u16 new_value) { val = new_value; }
    u16 value() const { return val; }

    u8 low() const;
    u8 high() const;

    void increment() { val += 1; }
    void decrement() { val -= 1; }

private:
    u16 val;
};

class RegisterPair {
public:
    RegisterPair(ByteRegister& high, ByteRegister& low);

    void set_low(const u8 byte);
    void set_high(const u8 byte);

    void set_low(const ByteRegister& byte);
    void set_high(const ByteRegister& byte);

    void set(const u16 word);

    u8 low() const;
    u8 high() const;

    u16 value() const;

    void increment();
    void decrement();

private:
    ByteRegister& low_byte;
    ByteRegister& high_byte;
};

class Offset {
public:
    Offset(u8 val) : val(val) {}
    Offset(ByteRegister& reg) : val(reg.value()) {}

    u8 value() { return val; }

private:
    u8 val;
};

Remove unnecessary semicolon after method definitions


#include "minunit.h"
#include <lcthw/sarray.h>

char *test_create_destroy()
{
    char test[] = "abracadabra";
    char test2[] = "acadabra";
    SuffixArray *sarry = SuffixArray_create(test, sizeof(test));
    mu_assert(sarry, "Failed to create.");

    int at = SuffixArray_find_suffix(sarry, test2, sizeof(test2));
    mu_assert(at != -1, "Failed to find the suffix.");

    at = SuffixArray_find_suffix(sarry, "yo", sizeof("yo"));
    mu_assert(at == -1, "Should fail to find yo.");

    SuffixArray_destroy(sarry);

    return NULL;
}

char *all_tests() {
    mu_suite_start();

    mu_run_test(test_create_destroy);

    return NULL;
}

RUN_TESTS(all_tests);

#include "minunit.h"
#include <lcthw/sarray.h>

static SuffixArray *sarry = NULL;
static char test[] = "abracadabra";
static char test2[] = "acadabra";

char *test_create()
{
    sarry = SuffixArray_create(test, sizeof(test));
    mu_assert(sarry, "Failed to create.");

    return NULL;
}

char *test_destroy()
{
    SuffixArray_destroy(sarry);

    return NULL;
}

char *test_find_suffix()
{
    int at = SuffixArray_find_suffix(sarry, test2, sizeof(test2));
    mu_assert(at != -1, "Failed to find the suffix.");

    at = SuffixArray_find_suffix(sarry, "yo", sizeof("yo"));
    mu_assert(at == -1, "Should fail to find yo.");

    return NULL;
}

char *all_tests() {
    mu_suite_start();

    mu_run_test(test_create);
    mu_run_test(test_find_suffix);
    mu_run_test(test_destroy);

    return NULL;
}

RUN_TESTS(all_tests);

Clean up suffix array tests.

Clean up suffix array tests.


#include <string.h>
#include <stdint.h>

/**
 * Efficient string hash function.
 */
static uint32_t string_hash(const char *str)
{
	uint32_t hash = 0;
	int32_t c;
	while ((c = *str++))
	{
		hash = c + (hash << 6) + (hash << 16) - hash;
	}
	return hash;
}

/**
 * Test two strings for equality.
 */
static int string_compare(const char *str1, const char *str2)
{
	if (str1 == str2)
	{
		return 1;
	}
	if (str2 == NULL)
	{
		return 0;
	}
	return strcmp(str1, str2) == 0;
}

#include <string.h>
#include <stdint.h>

/**
 * Efficient string hash function.
 */
__attribute__((unused))
static uint32_t string_hash(const char *str)
{
	uint32_t hash = 0;
	int32_t c;
	while ((c = *str++))
	{
		hash = c + (hash << 6) + (hash << 16) - hash;
	}
	return hash;
}

/**
 * Test two strings for equality.
 */
__attribute__((unused))
static int string_compare(const char *str1, const char *str2)
{
	if (str1 == str2)
	{
		return 1;
	}
	if (str2 == NULL)
	{
		return 0;
	}
	return strcmp(str1, str2) == 0;
}

Mark string functions unused, in case the header is included in files that only use one of them.


#ifndef CPP11_FEATURES_H
#define CPP11_FEATURES_H

#if defined(_MSC_VER) && (_MSC_FULL_VER >= 170050727)
// for (T t : collection) { }
#define CPP11_FOR_EACH
// enum class T {};
#define CPP11_ENUM_CLASS
#elif defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 6)
#define CPP11_FOR_EACH
#define CPP11_ENUM_CLASS
#endif

#endif // Include guard.

Add C++11 compliance check file.

Add C++11 compliance check file.