//
// Created by Scott Stark on 6/12/15.
//

#ifndef NATIVESCANNER_BEACONMAPPER_H
#define NATIVESCANNER_BEACONMAPPER_H

#include <map>
#include <string>

using namespace std;

/**
 * Map a beacon id to the registered user by querying the application registration rest api
 */
class BeaconMapper {
private:
    map<int, string> beaconToUser;

public:
    /**
     * Query the current user registrations to update the beacon minorID to name mappings
     */
    void refresh();

    string lookupUser(int minorID);
};

#endif //NATIVESCANNER_BEACONMAPPER_H

//
// Created by Scott Stark on 6/12/15.
//

#ifndef NATIVESCANNER_BEACONMAPPER_H
#define NATIVESCANNER_BEACONMAPPER_H

#include <map>
#include <string>

using namespace std;

/**
 * Map a beacon id to the registered user by querying the application registration rest api
 *
 * Relies on:
 * git clone https://github.com/open-source-parsers/jsoncpp.git
 * cd jsoncpp/
 * mkdir build
 * cd build/
 * cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_STATIC_LIBS=ON ..
 * make
 * make install
 *
 * git clone https://github.com/mrtazz/restclient-cpp.git
 * apt-get install autoconf
 * apt-get install libtool
 * apt-get install libcurl4-openssl-dev
 * cd restclient-cpp/
 * ./autogen.sh
 * ./configure
 * make
 * make install
 */
class BeaconMapper {
private:
    map<int, string> beaconToUser;

public:
    /**
     * Query the current user registrations to update the beacon minorID to name mappings
     */
    void refresh();

    string lookupUser(int minorID);
};

#endif //NATIVESCANNER_BEACONMAPPER_H

Document full requirements for the beacon mapper


#ifndef VAST_TEST_UNIT_EVENT_FIXTURE_H
#define VAST_TEST_UNIT_EVENT_FIXTURE_H

#include <vector>
#include "vast/event.h"

struct event_fixture
{
  event_fixture();
  std::vector<vast::event> events;
};

#endif

Add missing event fixture file.

Add missing event fixture file.


//
//  RNSketchManager.m
//  RNSketch
//
//  Created by Jeremy Grancher on 28/04/2016.
//  Copyright © 2016 Jeremy Grancher. All rights reserved.
//

#import "RCTViewManager.h"
#import "RNSketch.h"

@interface RNSketchManager : RCTViewManager

@property (strong) RNSketch *sketchView;

@end;

//
//  RNSketchManager.m
//  RNSketch
//
//  Created by Jeremy Grancher on 28/04/2016.
//  Copyright © 2016 Jeremy Grancher. All rights reserved.
//

#if __has_include(<React/RCTViewManager.h>)
// React Native >= 0.40
#import <React/RCTViewManager.h>
#else
// React Native <= 0.39
#import "RCTViewManager.h"
#endif
#import "RNSketch.h"

@interface RNSketchManager : RCTViewManager

@property (strong) RNSketch *sketchView;

@end;

Support RN 0.40 headers while retaining backwards compatibility.

Use #if to conditionally import React headers.


//  Copyright (c) 2014 Rob Rix. All rights reserved.

#import <Foundation/Foundation.h>

@protocol REDIterable <NSObject>

@property (readonly) id(^red_iterator)(void);

@end

//  Copyright (c) 2014 Rob Rix. All rights reserved.

#import <Foundation/Foundation.h>

/// A nullary block iterating the elements of a collection over successive calls.
///
/// \return The next object in the collection, or nil if it has iterated the entire collection.
typedef id (^REDIteratingBlock)(void);

/// A collection which can be iterated.
@protocol REDIterable <NSObject>

/// An iterator for this collection.
@property (readonly) REDIteratingBlock red_iterator;

@end

Add a typedef for iterators.

Add a typedef for iterators.


// RUN: %check %s

#pragma STDC FENV_ACCESS on
_Pragma("STDC FENV_ACCESS on"); // CHECK: warning: unhandled STDC pragma
// CHECK: ^warning: extra ';' at global scope

#define LISTING(x) PRAGMA(listing on #x)
#define PRAGMA(x) _Pragma(#x)

LISTING(../listing) // CHECK: warning: unknown pragma 'listing on "../listing"'

_Pragma(L"STDC CX_LIMITED_RANGE off") // CHECK: warning: unhandled STDC pragma
// CHECK: ^!/warning: extra ';'/

#pragma STDC FP_CONTRACT off

main()
{
}

// RUN: %check %s

#pragma STDC FENV_ACCESS ON
_Pragma("STDC FENV_ACCESS ON"); // CHECK: warning: unhandled STDC pragma
// CHECK: ^warning: extra ';' at global scope

#define LISTING(x) PRAGMA(listing on #x)
#define PRAGMA(x) _Pragma(#x)

LISTING(../listing) // CHECK: warning: unknown pragma 'listing on "../listing"'

_Pragma(L"STDC CX_LIMITED_RANGE OFF") // CHECK: warning: unhandled STDC pragma
// CHECK: ^!/warning: extra ';'/

#pragma STDC FP_CONTRACT OFF

int main()
{
}

Correct case of STDC pragmas

Correct case of STDC pragmas


#import "RCTBridgeModule.h"

@interface KCKeepAwake : NSObject <RCTBridgeModule>
@end

#import <React/RCTBridgeModule.h>

@interface KCKeepAwake : NSObject <RCTBridgeModule>
@end

Correct import path to match RN 0.40

Correct import path to match RN 0.40


#include "kremlib.h"
#include "kremstr.h"

/******************************************************************************/
/* Implementation of FStar.String and FStar.HyperIO                           */
/******************************************************************************/

/* FStar.h is generally kept for the program we wish to compile, meaning that
 * FStar.h contains extern declarations for the functions below. This provides
 * their implementation, and since the function prototypes are already in
 * FStar.h, we don't need to put these in the header, they will be resolved at
 * link-time. */

Prims_nat FStar_String_strlen(Prims_string s) {
  return strlen(s);
}

Prims_string FStar_String_strcat(Prims_string s0, Prims_string s1) {
  char *dest = calloc(strlen(s0) + strlen(s1) + 1, 1);
  strcat(dest, s0);
  strcat(dest, s1);
  return (Prims_string)dest;
}

Prims_string Prims_strcat(Prims_string s0, Prims_string s1) {
  return FStar_String_strcat(s0, s1);
}

void FStar_IO_debug_print_string(Prims_string s) {
  printf("%s", s);
}

bool __eq__Prims_string(Prims_string s1, Prims_string s2) {
  return (strcmp(s1, s2) == 0);
}

#include "kremlib.h"
#include "kremstr.h"

/******************************************************************************/
/* Implementation of FStar.String and FStar.HyperIO                           */
/******************************************************************************/

/* FStar.h is generally kept for the program we wish to compile, meaning that
 * FStar.h contains extern declarations for the functions below. This provides
 * their implementation, and since the function prototypes are already in
 * FStar.h, we don't need to put these in the header, they will be resolved at
 * link-time. */

Prims_nat FStar_String_strlen(Prims_string s) {
  return strlen(s);
}

Prims_string FStar_String_strcat(Prims_string s0, Prims_string s1) {
  char *dest = calloc(strlen(s0) + strlen(s1) + 1, 1);
  strcat(dest, s0);
  strcat(dest, s1);
  return (Prims_string)dest;
}

Prims_string Prims_strcat(Prims_string s0, Prims_string s1) {
  return FStar_String_strcat(s0, s1);
}

void FStar_HyperStack_IO_print_string(Prims_string s) {
  printf("%s", s);
}

void FStar_IO_debug_print_string(Prims_string s) {
  printf("%s", s);
}

bool __eq__Prims_string(Prims_string s1, Prims_string s2) {
  return (strcmp(s1, s2) == 0);
}

Revert "Try to catch up on upstream F* changes"

This reverts commit 5b09f1f43b155df40caa8d8716075ccd7d08af26.


/*
 * A solution to Exercise 1-12 in The C Programming Language (Second Edition).
 *
 * This file was written by Damien Dart <damiendart@pobox.com>. This is free
 * and unencumbered software released into the public domain. For more
 * information, please refer to the accompanying "UNLICENCE" file.
 */

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

int main(void)
{
  int16_t character = 0;
  bool in_whitespace = false;
  while ((character = getchar()) != EOF) {
    if ((character == ' ') || (character == '\t')) {
      if (in_whitespace == false) {
        putchar('\n');
        in_whitespace = true;
      }
    } else {
      putchar(character);
      in_whitespace = false;
    }
  }
  return EXIT_SUCCESS;
}

/*
 * A solution to Exercise 1-12 in The C Programming Language (Second Edition).
 *
 * This file was written by Damien Dart <damiendart@pobox.com>. This is free
 * and unencumbered software released into the public domain. For more
 * information, please refer to the accompanying "UNLICENCE" file.
 */

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

int main(void)
{
  int16_t character = 0;
  bool in_whitespace = false;
  while ((character = getchar()) != EOF) {
    if ((character == ' ') || (character == '\t' || character == '\n')) {
      if (in_whitespace == false) {
        putchar('\n');
        in_whitespace = true;
      }
    } else {
      putchar(character);
      in_whitespace = false;
    }
  }
  return EXIT_SUCCESS;
}

Fix solution to Exercise 1-12.

Fix solution to Exercise 1-12.

Fix solution to Exercise 1-12 so that newline characters are processed correctly.


/*-------------------------------------------------------------------------
 *
 * pgtz.c
 *	  Timezone Library Integration Functions
 *
 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
 *	  $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.5 2004/05/01 01:38:53 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */

#include "pgtz.h"
#include "tzfile.h"

static char tzdir[MAXPGPATH];
static int	done_tzdir = 0;
char *
pg_TZDIR(void)
{
	char	   *p;

	if (done_tzdir)
		return tzdir;

#ifndef WIN32
	StrNCpy(tzdir, PGDATADIR, MAXPGPATH);
#else
	if (GetModuleFileName(NULL, tzdir, MAXPGPATH) == 0)
		return NULL;
#endif

	canonicalize_path(tzdir);
#if 0
	if ((p = last_path_separator(tzdir)) == NULL)
		return NULL;
	else
		*p = '\0';
#endif

	strcat(tzdir, "/timezone");

	done_tzdir = 1;
	return tzdir;
}

/*-------------------------------------------------------------------------
 *
 * pgtz.c
 *	  Timezone Library Integration Functions
 *
 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
 *	  $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.6 2004/05/01 22:07:03 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */

#include "pgtz.h"
#include "tzfile.h"

static char tzdir[MAXPGPATH];
static int	done_tzdir = 0;
char *
pg_TZDIR(void)
{
	char	   *p;

	if (done_tzdir)
		return tzdir;

#ifndef WIN32
	StrNCpy(tzdir, PGDATADIR, MAXPGPATH);
#else
	if (GetModuleFileName(NULL, tzdir, MAXPGPATH) == 0)
		return NULL;
#endif

	canonicalize_path(tzdir);
#ifdef WIN32
	/* trim off binary name, then go up a directory */
	if ((p = last_path_separator(tzdir)) == NULL)
		return NULL;
	else
		*p = '\0';
	strcat(tzdir, "/../share/timezone");
#endif
	strcat(tzdir, "/timezone");

	done_tzdir = 1;
	return tzdir;
}

Fix timezone data path for Unix and win32.


// RUN: %clang -target aarch64-linux-gnuabi %s -O3 -S -emit-llvm -o - | FileCheck %s
#include <complex.h>

complex long double a, b, c, d;
void test_fp128_compound_assign(void) {
  // CHECK: tail call { fp128, fp128 } @__multc3
  a *= b;
  // CHECK: tail call { fp128, fp128 } @__divtc3
  c /= d;
}

// RUN: %clang -target aarch64-linux-gnuabi %s -O3 -S -emit-llvm -o - | FileCheck %s

_Complex long double a, b, c, d;
void test_fp128_compound_assign(void) {
  // CHECK: tail call { fp128, fp128 } @__multc3
  a *= b;
  // CHECK: tail call { fp128, fp128 } @__divtc3
  c /= d;
}

Remove including <complex.h> in test case, and change to use _Complex instead.

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


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

#if defined(DEVICE_TRNG)
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#endif

#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
#include "mbedtls_device.h"
#endif

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

#if defined(DEVICE_TRNG)
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#endif

#if defined(DEVICE_RTC)
#define MBEDTLS_HAVE_TIME_DATE
#endif

#if defined(MBEDTLS_CONFIG_HW_SUPPORT)
#include "mbedtls_device.h"
#endif

Integrate mbed OS RTC with mbed TLS

Integrate mbed OS RTC with mbed TLS

The integration is simply to define the macro MBEDTLS_HAVE_TIME_DATE
in the features/mbedtls/platform/inc/platform_mbed.h. The default
implementation of the mbedtls_time() function provided by mbed TLS is
sufficient to work with mbed OS because both use POSIX functions.


#ifndef CELL_H
#define CELL_H

#include <map>
#include <vector>

#include "number.h"

class Cell {
public:
    Cell();
    explicit Cell(const Cell &rhs);
    explicit Cell(Cell *value);
    explicit Cell(bool value);
    explicit Cell(Number value);
    explicit Cell(const std::string &value);
    explicit Cell(const char *value);
    explicit Cell(const std::vector<Cell> &value);
    explicit Cell(const std::map<std::string, Cell> &value);
    Cell &operator=(const Cell &rhs);
    bool operator==(const Cell &rhs) const;

    Cell *address_value;
    bool boolean_value;
    Number number_value;
    std::string string_value;
    std::vector<Cell> array_value;
    std::map<std::string, Cell> dictionary_value;
};

#endif

#ifndef CELL_H
#define CELL_H

#include <map>
#include <vector>

#include "number.h"

class Cell {
public:
    Cell();
    Cell(const Cell &rhs);
    explicit Cell(Cell *value);
    explicit Cell(bool value);
    explicit Cell(Number value);
    explicit Cell(const std::string &value);
    explicit Cell(const char *value);
    explicit Cell(const std::vector<Cell> &value);
    explicit Cell(const std::map<std::string, Cell> &value);
    Cell &operator=(const Cell &rhs);
    bool operator==(const Cell &rhs) const;

    Cell *address_value;
    bool boolean_value;
    Number number_value;
    std::string string_value;
    std::vector<Cell> array_value;
    std::map<std::string, Cell> dictionary_value;
};

#endif

Remove 'explicit' on copy constructor

Remove 'explicit' on copy constructor


#ifndef QUAZIP_TEST_QUAZIP_H
#define QUAZIP_TEST_QUAZIP_H

#include <QObject>

class TestQuaZip: public QObject {
    Q_OBJECT
private slots:
    void getFileList_data();
    void getFileList();
    void getZip();
};

#endif // QUAZIP_TEST_QUAZIP_H

#ifndef QUAZIP_TEST_QUAZIP_H
#define QUAZIP_TEST_QUAZIP_H

#include <QObject>

class TestQuaZip: public QObject {
    Q_OBJECT
private slots:
    void getFileList_data();
    void getFileList();
};

#endif // QUAZIP_TEST_QUAZIP_H

Remove getZip() which got there by mistake

git-svn-id: 8ee2d06cc183b55da409a55e9abc82a01a576498@113 bf82bb6f-4128-0410-aed8-a7a134390cb4


#ifndef _FAKE_LOCK_SCREEN_PATTERN_H_
#define _FAKE_LOCK_SCREEN_PATTERN_H_

#include <gtk/gtk.h>

#if !GTK_CHECK_VERSION(3, 0, 0)
typedef struct {
  gdouble red;
  gdouble green;
  gdouble blue;
  gdouble alpha;
} GdkRGBA;
#endif

typedef struct _FakeLockOption {
  void *module;
  gchar *real;
  gchar *dummy;
} FakeLockOption;

typedef struct {
  gboolean marked;
  gint value;
  GdkPoint top_left;
  GdkPoint bottom_right;
} FakeLockPatternPoint;

typedef enum {
  FLSP_ONE_STROKE,
  FLSP_ON_BOARD,
  FLSP_N_PATTERN,
} FakeLockScreenPattern;

void flsp_draw_circle(cairo_t *context,
                      gint x, gint y, gint radius,
                      GdkRGBA circle, GdkRGBA border);

gboolean is_marked(gint x, gint y,
                   gint *marked, void *user_data);

#endif

#ifndef _FAKE_LOCK_SCREEN_PATTERN_H_
#define _FAKE_LOCK_SCREEN_PATTERN_H_

#include <gtk/gtk.h>

#if !GTK_CHECK_VERSION(3, 0, 0)
typedef struct {
  gdouble red;
  gdouble green;
  gdouble blue;
  gdouble alpha;
} GdkRGBA;
#endif

typedef struct _FakeLockOption {
  void *module;
  gchar *real;
  gchar *dummy;
} FakeLockOption;

typedef struct {
  gint mark;
  gint value;
  GdkPoint top_left;
  GdkPoint bottom_right;
} FakeLockPatternPoint;

typedef enum {
  FLSP_ONE_STROKE,
  FLSP_ON_BOARD,
  FLSP_N_PATTERN,
} FakeLockScreenPattern;

void flsp_draw_circle(cairo_t *context,
                      gint x, gint y, gint radius,
                      GdkRGBA circle, GdkRGBA border);

gboolean is_marked(gint x, gint y,
                   gint *marked, void *user_data);

#endif

Use gint to store index

Use gint to store index


#ifndef _WISH_COMMANDER
#define _WISH_COMMANDER

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

char *exit_color;

int execute(char *path, char *arg_arr[]) {
    int pid;
    if (!(pid = fork())) {
        execvp(path, arg_arr);
        // This is only reached if the execvp function fails
        exit(-1);
    } else {
        int status;
        wait(&status);
        return status;
    }
}

int get_and_run_userin() {
    char buff[256];
    fgets(buff, sizeof(buff), stdin);

    // Buff will have space-separated command line arguments, then a newline,
    // then a terminating null. We can use strsep to get rid of the newline.
    // Since fgets will terminate on the first newline, we can be certain there
    // is no next command after it

    char *ptr_to_buff = buff;
    char *command = strsep(&ptr_to_buff, "\n");
    // Blank lines should just return 0, since a blank command doesn't 'crash'
    if (!(*command)) {
        return 0;
    }
    int num_args = 1;
    int i; for (i = 0; command[i]; i++) {
        if (command[i] == ' ') num_args++;
    }
    char *args[num_args + 1];
    for (i = 0; i < num_args; i++) {
        args[i] = strsep(&command, " ");
    }
    args[num_args] = NULL;

    return execute(args[0], args);
}

#endif

Add file to handle executing commands from stdin


/* Copyright 2021 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.
 */

#if !defined(__CROS_EC_HOST_COMMAND_H) || \
	defined(__CROS_EC_ZEPHYR_HOST_COMMAND_H)
#error "This file must only be included from host_command.h. " \
	"Include host_command.h directly"
#endif
#define __CROS_EC_ZEPHYR_HOST_COMMAND_H

#include <init.h>

#ifdef CONFIG_PLATFORM_EC_HOSTCMD

/**
 * See include/host_command.h for documentation.
 */
#define DECLARE_HOST_COMMAND(_command, _routine, _version_mask)            \
	STRUCT_SECTION_ITERABLE(host_command, _cros_hcmd_##_command) = {   \
		.command = _command,                                       \
		.handler = _routine,                                       \
		.version_mask = _version_mask,                             \
	}
#else /* !CONFIG_PLATFORM_EC_HOSTCMD */
#ifdef __clang__
#define DECLARE_HOST_COMMAND(command, routine, version_mask)
#else
#define DECLARE_HOST_COMMAND(command, routine, version_mask)         \
	enum ec_status (routine)(struct host_cmd_handler_args *args) \
		__attribute__((unused))
#endif /* __clang__ */
#endif /* CONFIG_PLATFORM_EC_HOSTCMD */

/* Copyright 2021 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.
 */

#if !defined(__CROS_EC_HOST_COMMAND_H) || \
	defined(__CROS_EC_ZEPHYR_HOST_COMMAND_H)
#error "This file must only be included from host_command.h. " \
	"Include host_command.h directly"
#endif
#define __CROS_EC_ZEPHYR_HOST_COMMAND_H

#include <init.h>

#ifdef CONFIG_PLATFORM_EC_HOSTCMD

/**
 * See include/host_command.h for documentation.
 */
#define DECLARE_HOST_COMMAND(_command, _routine, _version_mask)            \
	STRUCT_SECTION_ITERABLE(host_command, _cros_hcmd_##_command) = {   \
		.command = _command,                                       \
		.handler = _routine,                                       \
		.version_mask = _version_mask,                             \
	}
#else /* !CONFIG_PLATFORM_EC_HOSTCMD */

/*
 * Create a fake routine to call the function. The linker should
 * garbage-collect it since it is behind 'if (0)'
 */
#define DECLARE_HOST_COMMAND(command, routine, version_mask)		\
	int __remove_ ## command(void)					\
	{								\
		if (0)							\
			routine(NULL);					\
		return 0;						\
	}

#endif /* CONFIG_PLATFORM_EC_HOSTCMD */

zephyr: Use a different way of handling no host commands

When CONFIG_PLATFORM_EC_HOSTCMD is not enabled we want to silently drop
the handler routines from the build. The current approach works for gcc
but not for clang.

Use an exported function instead.

BUG=b:208648337
BRANCH=none
TEST=CQ and gitlab

Signed-off-by: Simon Glass <c00b0378376498bd9cd974c388df8854c0131d27@chromium.org>
Change-Id: I63f74e8081556c726472782f60bddbbfbc3e9bf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3313320
Reviewed-by: Jeremy Bettis <4df7b5147fee087dca33c181f288ee7dbf56e022@chromium.org>


#import <Foundation/Foundation.h>
#import "Nocilla.h"
#import "LSHTTPRequest.h"

@class LSStubRequest;
@class LSStubResponse;

extern NSString * const LSUnexpectedRequest;

@interface LSNocilla : NSObject
+ (LSNocilla *)sharedInstance;

@property (nonatomic, strong, readonly) NSArray *stubbedRequests;
- (void)start;
- (void)stop;
- (void)addStubbedRequest:(LSStubRequest *)request;
- (void)clearStubs;

- (LSStubResponse *)responseForRequest:(id<LSHTTPRequest>)request;
@end

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

@class LSStubRequest;
@class LSStubResponse;
@protocol LSHTTPRequest;

extern NSString * const LSUnexpectedRequest;

@interface LSNocilla : NSObject
+ (LSNocilla *)sharedInstance;

@property (nonatomic, strong, readonly) NSArray *stubbedRequests;
- (void)start;
- (void)stop;
- (void)addStubbedRequest:(LSStubRequest *)request;
- (void)clearStubs;

- (LSStubResponse *)responseForRequest:(id<LSHTTPRequest>)request;
@end

Replace import with forward declaration.


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
/* This is Queue Implementation using Array */

#define MAXSIZE 101
#define BOOL_PRINT(bool_expr) "%s\n", (bool_expr) ? "true" : "false"

int A[MAXSIZE];
int front_q = -1;
int end_q = -1;

void enq(int data){

	if(isEmpty()){
		A[++end_q]=data;
		front_q ++;
		return;
	}
	if (end_q < MAXSIZE-1){
		A[++end_q] = data;
	}
	else{
		printf("Error: Queue is full \n");
		return;
	}
}

int deq(){
	if(front_q != -1 && front_q <= end_q){
	return A[front_q++];
	}

	else{
		printf("Error: Queue is empty \n");
		return -1;
	}
}

int isEmpty(){
	if(front_q!= -1) return false;
	else return true;
}

void q_print(){
	printf("Queue is : ");
	int i,data;
	int count =end_q;
	int start = front_q;

	for(i =start; i<=count;i++){
		 data = deq();
		printf("%d ", data);
	}
	printf("\n");
}

int main(){

	int i;
	printf("is queue empty? \n");
	printf(BOOL_PRINT(isEmpty()));

	enq(10);
	printf("front_q is at %d end_q is at %d \n",front_q,end_q);

	enq(11);
	printf("front_q is at %d end_q is at %d \n",front_q,end_q);
	enq(12);
	printf("front_q is at %d end_q is at %d \n",front_q,end_q);
	enq(15);
	printf("front_q is at %d end_q is at %d \n",front_q,end_q);

	i = deq();
	printf("Popped data is %d\n",i );

	printf("front_q is at %d end_q is at %d \n",front_q,end_q);

	q_print(); // Note: this is just for vizualizing and this actually results in loss of queue data

	return 0;
}

Add array implementation of queue

Add array implementation of queue


/*	Copyright (c) 2013 Adam Dej

	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 __DISPLAY_DEVICE_H
#define __DISPLAY_DEVICE_H

#include <stdint.h>
#include <stdbool.h>

#ifdef EMBDEGFX_16
	typedef uint16_t uintpix;
#else
	typedef uint8_t uintpix;
#endif

typedef struct {
	void *data;
	bool (*set_pixel)(uintpix x, uintpix y, void *data);
	bool (*unset_pixel)(uintpix x, uintpix y, void *data);
	bool (*clear_display)(void *data);
	bool (*commit)(void *data);
} DISPLAY_1BIT;

typedef struct {
	//TODO
} DISPLAY_8BIT;

typedef struct {
	//TODO
} DISPLAY_24BIT;

//If none of those modes is suitable feel free to add your own

#endif

Add header with structs representing basic display types


// RUN: %clang_profgen -o %t -O3 -flto  %s
// RUN: env LLVM_PROFILE_FILE=%t.profraw %t
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s

int main(int argc, const char *argv[]) {
  // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof !1
  if (argc)
    return 0;
  return 1;
}
// CHECK: !1 = metadata !{metadata !"branch_weights", i32 2, i32 1}

// RUN: %clang_profgen -o %t -O3 %s
// RUN: env LLVM_PROFILE_FILE=%t.profraw %t
// RUN: llvm-profdata merge -o %t.profdata %t.profraw
// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s

int main(int argc, const char *argv[]) {
  // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof !1
  if (argc)
    return 0;
  return 1;
}
// CHECK: !1 = metadata !{metadata !"branch_weights", i32 2, i32 1}

Remove LTO dependency from test

InstrProf: Remove LTO dependency from test

The -flto flag relies on linker features that are not available on all
platforms.

<rdar://problem/16458307>

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


//
//  SAMCategories.h
//  SAMCategories
//
//  Created by Sam Soffes on 7/17/13.
//  Copyright 2013 Sam Soffes. All rights reserved.
//

// Foundation
#import "NSArray+SAMAdditions.h"
#import "NSData+SAMAdditions.h"
#import "NSDate+SAMAdditions.h"
#import "NSDictionary+SAMAdditions.h"
#import "NSNumber+SAMAdditions.h"
#import "NSObject+SAMAdditions.h"
#import "NSString+SAMAdditions.h"
#import "NSURL+SAMAdditions.h"

// UIKit
#if TARGET_OS_IPHONE
	#import "UIApplication+SAMAdditions.h"
	#import "UIColor+SAMAdditions.h"
	#import "UIDevice+SAMAdditions.h"
	#import "UIScreen+SAMAdditions.h"
	#import "UIScrollView+SAMAdditions.h"
	#import "UIView+SAMAdditions.h"
	#import "UIViewController+SAMAdditions.h"
#endif

//
//  SAMCategories.h
//  SAMCategories
//
//  Created by Sam Soffes on 7/17/13.
//  Copyright 2013 Sam Soffes. All rights reserved.
//

// Foundation
#import "NSArray+SAMAdditions.h"
#import "NSData+SAMAdditions.h"
#import "NSDate+SAMAdditions.h"
#import "NSDictionary+SAMAdditions.h"
#import "NSNumber+SAMAdditions.h"
#import "NSObject+SAMAdditions.h"
#import "NSString+SAMAdditions.h"
#import "NSURL+SAMAdditions.h"

// UIKit
#if TARGET_OS_IPHONE
	#import "UIApplication+SAMAdditions.h"
	#import "UIColor+SAMAdditions.h"
	#import "UIControl+SAMAdditions.h"
	#import "UIDevice+SAMAdditions.h"
	#import "UIScreen+SAMAdditions.h"
	#import "UIScrollView+SAMAdditions.h"
	#import "UIView+SAMAdditions.h"
	#import "UIViewController+SAMAdditions.h"
#endif

Add missing import for UIControl+SAMAdditions.h


//
//  SwiftDevHints.h
//  SwiftDevHints
//
//  Created by ZHOU DENGFENG on 15/7/17.
//  Copyright © 2017 ZHOU DENGFENG DEREK. All rights reserved.
//

#import <UIKit/UIKit.h>

#import <CommonCrypto/CommonCrypto.h>

//! Project version number for SwiftDevHints.
FOUNDATION_EXPORT double SwiftDevHintsVersionNumber;

//! Project version string for SwiftDevHints.
FOUNDATION_EXPORT const unsigned char SwiftDevHintsVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <SwiftDevHints/PublicHeader.h>

//
//  SwiftDevHints.h
//  SwiftDevHints
//
//  Created by ZHOU DENGFENG on 15/7/17.
//  Copyright © 2017 ZHOU DENGFENG DEREK. All rights reserved.
//

@import Foundation;

#import <CommonCrypto/CommonCrypto.h>

//! Project version number for SwiftDevHints.
FOUNDATION_EXPORT double SwiftDevHintsVersionNumber;

//! Project version string for SwiftDevHints.
FOUNDATION_EXPORT const unsigned char SwiftDevHintsVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <SwiftDevHints/PublicHeader.h>

Remove UIKit import to support macOS

Remove UIKit import to support macOS


#include "src/math/reinterpret.h"
#include <assert.h>

long double __addtf3(long double, long double);

static _Bool equivalent(long double x, long double y)
{
    if (x != x)
        return y != y;

    return reinterpret(unsigned __int128, x) == reinterpret(unsigned __int128, y);
}

static _Bool run(long double x, long double y)
{
    return equivalent(x + y, __addtf3(x, y));
}

#define TEST(x, y) do { \
    _Static_assert(__builtin_constant_p((long double)(x) + (long double)(y)), "This test requires compile-time constants"); \
    assert(run(x, y)); \
} while (0)

#include "src/math/reinterpret.h"
#include <math.h>
#include <assert.h>

long double __addtf3(long double, long double);

static _Bool run(long double x, long double y)
{
    return reinterpret(unsigned __int128, x + y) == reinterpret(unsigned __int128, __addtf3(x, y));
}

int main(void)
{
    assert(isnan(__addtf3(NAN, NAN)));
    assert(isnan(__addtf3(NAN, INFINITY)));
    assert(isnan(__addtf3(NAN, 0x1.23456789abcdefp+3L)));
    assert(isnan(__addtf3(INFINITY, -INFINITY)));

    assert(run(INFINITY, INFINITY));
    assert(run(INFINITY, -0x1.23456789abcdefp+3849L));
}

Test non-finite soft float addition

Test non-finite soft float addition


#ifndef __CLAR_TEST_ATTR_EXPECT__
#define __CLAR_TEST_ATTR_EXPECT__

enum attr_expect_t {
	EXPECT_FALSE,
	EXPECT_TRUE,
	EXPECT_UNDEFINED,
	EXPECT_STRING
};

struct attr_expected {
	const char *path;
	const char *attr;
	enum attr_expect_t expected;
	const char *expected_str;
};

static inline void attr_check_expected(
	enum attr_expect_t expected,
	const char *expected_str,
	const char *value)
{
	switch (expected) {
	case EXPECT_TRUE:
		cl_assert(GIT_ATTR_TRUE(value));
		break;

	case EXPECT_FALSE:
		cl_assert(GIT_ATTR_FALSE(value));
		break;

	case EXPECT_UNDEFINED:
		cl_assert(GIT_ATTR_UNSPECIFIED(value));
		break;

	case EXPECT_STRING:
		cl_assert_strequal(expected_str, value);
		break;
	}
}

#endif

#ifndef __CLAR_TEST_ATTR_EXPECT__
#define __CLAR_TEST_ATTR_EXPECT__

enum attr_expect_t {
	EXPECT_FALSE,
	EXPECT_TRUE,
	EXPECT_UNDEFINED,
	EXPECT_STRING
};

struct attr_expected {
	const char *path;
	const char *attr;
	enum attr_expect_t expected;
	const char *expected_str;
};

GIT_INLINE(void) attr_check_expected(
	enum attr_expect_t expected,
	const char *expected_str,
	const char *value)
{
	switch (expected) {
	case EXPECT_TRUE:
		cl_assert(GIT_ATTR_TRUE(value));
		break;

	case EXPECT_FALSE:
		cl_assert(GIT_ATTR_FALSE(value));
		break;

	case EXPECT_UNDEFINED:
		cl_assert(GIT_ATTR_UNSPECIFIED(value));
		break;

	case EXPECT_STRING:
		cl_assert_strequal(expected_str, value);
		break;
	}
}

#endif

Fix the build on Windows

Fix the build on Windows


/*
 * Copyright (C) 2011 by Nelson Elhage
 *
 * 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.
 */

#define REPTYR_VERSION "0.4"

int attach_child(pid_t pid, const char *pty, int force_stdio);
#define __printf __attribute__((format(printf, 1, 2)))
void __printf die(const char *msg, ...);
void __printf debug(const char *msg, ...);
void __printf error(const char *msg, ...);

/*
 * Copyright (C) 2011 by Nelson Elhage
 *
 * 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.
 */

#define REPTYR_VERSION "0.4dev"

int attach_child(pid_t pid, const char *pty, int force_stdio);
#define __printf __attribute__((format(printf, 1, 2)))
void __printf die(const char *msg, ...);
void __printf debug(const char *msg, ...);
void __printf error(const char *msg, ...);

Bump the version number for development.


//
//  EditPatientForm.h
//  OpenMRS-iOS
//
//  Created by Yousef Hamza on 7/5/15.
//  Copyright (c) 2015 Erway Software. All rights reserved.
//

#import "XLForm.h"
#import "XLFormViewController.h"
#import "MRSPatient.h"

@interface EditPatientForm : XLFormViewController <UIAlertViewDelegate>

- (instancetype)initWithPatient:(MRSPatient *)patient;
@property (nonatomic, strong) MRSPatient *patient;

@end

//
//  EditPatientForm.h
//  OpenMRS-iOS
//
//  Created by Yousef Hamza on 7/5/15.
//  Copyright (c) 2015 Erway Software. All rights reserved.
//

#import "XLForm.h"
#import "XLFormViewController.h"
#import "MRSPatient.h"

@interface EditPatientForm : XLFormViewController <UIAlertViewDelegate>

@property (nonatomic, strong) MRSPatient *patient;

- (instancetype)initWithPatient:(MRSPatient *)patient;

@end

Move method after property declaration

Move method after property declaration


/*	$OpenBSD: setjmp.h,v 1.6 2001/08/12 12:03:02 heko Exp $	*/

/*
 * machine/setjmp.h: machine dependent setjmp-related information.
 */
#ifndef __MACHINE_SETJMP_H__
#define __MACHINE_SETJMP_H__
#define	_JBLEN	22		/* size, in longs, of a jmp_buf */
#endif /* __MACHINE_SETJMP_H__ */

/*	$OpenBSD: setjmp.h,v 1.7 2003/08/01 07:41:33 miod Exp $	*/

/*
 * machine/setjmp.h: machine dependent setjmp-related information.
 */
#ifndef __MACHINE_SETJMP_H__
#define __MACHINE_SETJMP_H__
#define	_JBLEN	21		/* size, in longs, of a jmp_buf */
#endif /* __MACHINE_SETJMP_H__ */

Fix the *longjmp() behaviour - it is legal to reuse a jmp_buf several times. Gets us a working perl 5.8.


/**
 * \brief A block structure defined over the variables
 *
 * A block structure defined over the variables such that each block contains
 * 1 or more variables, with the invariant that all constraints inside a block
 * are satisfied by keeping the variables fixed relative to one another
 *
 * Authors:
 *   Tim Dwyer <tgdwyer@gmail.com>
 *
 * Copyright (C) 2005 Authors
 *
 * This version is released under the CPL (Common Public License) with
 * the Graphviz distribution.
 * A version is also available under the LGPL as part of the Adaptagrams
 * project: http://sourceforge.net/projects/adaptagrams.
 * If you make improvements or bug fixes to this code it would be much
 * appreciated if you could also contribute those changes back to the
 * Adaptagrams repository.
 */

#ifndef SEEN_REMOVEOVERLAP_BLOCKS_H
#define SEEN_REMOVEOVERLAP_BLOCKS_H

#ifdef RECTANGLE_OVERLAP_LOGGING
#define LOGFILE "cRectangleOverlap.log"
#endif

#include <set>
#include <list>

class Block;
class Variable;
class Constraint;
/**
 * A block structure defined over the variables such that each block contains
 * 1 or more variables, with the invariant that all constraints inside a block
 * are satisfied by keeping the variables fixed relative to one another
 */
class Blocks : public std::set<Block*>
{
public:
	Blocks(const int n, Variable *vs[]);
	~Blocks(void);
	void mergeLeft(Block *r);
	void mergeRight(Block *l);
	void split(Block *b, Block *&l, Block *&r, Constraint *c);
	std::list<Variable*> *totalOrder();
	void cleanup();
	double cost();
private:
	void dfsVisit(Variable *v, std::list<Variable*> *order);
	void removeBlock(Block *doomed);
	Variable **vs;
	int nvs;
};

extern long blockTimeCtr;
#endif // SEEN_REMOVEOVERLAP_BLOCKS_H

Add the vpsc library for IPSEPCOLA features


//===-- lldb-python.h --------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_lldb_python_h_
#define LLDB_lldb_python_h_

// Python.h needs to be included before any system headers in order to avoid redefinition of macros

#ifdef LLDB_DISABLE_PYTHON

// Python is disabled in this build

#else

#include <Python/Python.h>

#endif // LLDB_DISABLE_PYTHON

#endif  // LLDB_lldb_python_h_

//===-- lldb-python.h --------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_lldb_python_h_
#define LLDB_lldb_python_h_

// Python.h needs to be included before any system headers in order to avoid redefinition of macros

#ifdef LLDB_DISABLE_PYTHON

// Python is disabled in this build

#else

#ifdef __FreeBSD__
#include <Python.h>
#else
#include <Python/Python.h>
#endif

#endif // LLDB_DISABLE_PYTHON

#endif  // LLDB_lldb_python_h_

Fix build on FreeBSD after r196141

Fix build on FreeBSD after r196141

This should probably be replaced with build infrastructure support for
a platform-specific canonical Python include path, but for now it should
restore the FreeBSD buildbot.

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@196167 91177308-0d34-0410-b5e6-96231b3b80d8


#include <pal.h>

/**
 *
 * Converts integer values in 'a' to floating point values.
 *
 * @param a     Pointer to input vector
 *
 * @param c     Pointer to output vector
 *
 * @param n     Size of 'a' and 'c' vector.
 *
 * @param p     Number of processor to use (task parallelism)
 *
 * @param team  Team to work with
 *
 * @return      None
 *
 */
#include <math.h>
void p_itof(int *a, float *c, int n, int p, p_team_t team) {
	int i;
	for(i = 0; i < n; i++) {
		*(c + i) = (float)(*(a + i));
	}
}

#include <pal.h>

/**
 *
 * Converts integer values in 'a' to floating point values.
 *
 * @param a     Pointer to input vector
 *
 * @param c     Pointer to output vector
 *
 * @param n     Size of 'a' and 'c' vector.
 *
 * @param p     Number of processor to use (task parallelism)
 *
 * @param team  Team to work with
 *
 * @return      None
 *
 */
#include <math.h>
void p_itof(int *a, float *c, int n, int p, p_team_t team) {
	for(int i = 0; i < n; i++) {
		*(c + i) = (float)(*(a + i));
	}
}

Initialize variable in the declaration

Initialize variable in the declaration

Google style guide http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Local_Variables
"Place a function's variables in the narrowest scope possible, and initialize variables in the declaration."

Signed-off-by: Tom Anderson <bd28f8d49b61b0565f68fcded57d716070757017@email.com>


/*

 Lunatic Python
 --------------

 Copyright (c) 2002-2005  Gustavo Niemeyer <gustavo@niemeyer.net>

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

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

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/
#ifndef PYTHONINLUA_H
#define PYTHONINLUA_H

#define POBJECT "POBJECT"

int py_convert(lua_State *L, PyObject *o, int withnone);

typedef struct {
	PyObject *o;
	int asindx;
} py_object;

void stackDump(lua_State *L);
void tableDump(lua_State *L, int t);

py_object *check_py_object(lua_State *L, int ud);

LUA_API int luaopen_python(lua_State *L);

#endif

/*

 Lunatic Python
 --------------

 Copyright (c) 2002-2005  Gustavo Niemeyer <gustavo@niemeyer.net>

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

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

 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/
#ifndef PYTHONINLUA_H
#define PYTHONINLUA_H

#define POBJECT "PyObject"

int py_convert(lua_State *L, PyObject *o, int withnone);

typedef struct {
	PyObject *o;
	int asindx;
} py_object;

void stackDump(lua_State *L);
void tableDump(lua_State *L, int t);

py_object *check_py_object(lua_State *L, int ud);

LUA_API int luaopen_python(lua_State *L);

#endif

Change Lua registry key to PythonObject.


#ifdef __CINT__

#pragma link off all glols;
#pragma link off all classes;
#pragma link off all functions;

#endif

#ifdef __CINT__

#pragma link off all glols;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class AliD0toKpi+;
#pragma link C++ class AliD0toKpiAnalysis+;
#pragma link C++ class AliBtoJPSItoEle+;
#pragma link C++ class AliBtoJPSItoEleAnalysis+;

#endif

Move AliD0toKpi* and AliBtoJPSI* from libPWG3base to libPWG3 (Andrea)


#include <stdio.h>

unsigned int x;
char in;

void input(void);

void main(void){
  x = 0;
  input();
}

void input(void){
  printf(">> "); /* Bash-like input */
  scanf("%c", &in); /* Get char input */

  /* Boundary checks */
  if(x == 256 || x == -1) x = 0;

  /* Operators */
  switch(in){
    case 'i': case 'x':
      x++;
    case 'd':
      x--;
    case 'o': case 'c':
      printf("%d\n", x);
    case 's': case 'k':
      x = x*x;
    default:
      printf("\n");
  }

  input(); /* Loop */
}

#include <stdio.h>

unsigned int x;
char in;

void input(void);
void run(char c);

void main(void){
  x = 0;
  input();
}

void input(void){
  printf(">> "); /* Bash-like input */
  scanf("%c", &in); /* Get char input */
  run(in);
  input(); /* Loop */
}

void run(char c){
 /* Boundary checks */
  if(x == 256 || x == -1) x = 0;

  /* Operators */
  switch(in){
    case 'i': case 'x':
      x++;
    case 'd':
      x--;
    case 'o': case 'c':
      printf("%d\n", x);
    case 's': case 'k':
      x = x*x;
    default:
      printf("\n");
  }
}

Move run into new method

Move run into new method


/*
 * LSAPIC Interrupt Controller
 *
 * This takes care of interrupts that are generated by the CPU's
 * internal Streamlined Advanced Programmable Interrupt Controller
 * (LSAPIC), such as the ITC and IPI interrupts.
    *
 * Copyright (C) 1999 VA Linux Systems
 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
 * Copyright (C) 2000 Hewlett-Packard Co
 * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
 */

#include <linux/sched.h>
#include <linux/irq.h>

static unsigned int
lsapic_noop_startup (unsigned int irq)
{
	return 0;
}

static void
lsapic_noop (unsigned int irq)
{
	/* nothing to do... */
}

static int lsapic_retrigger(unsigned int irq)
{
	ia64_resend_irq(irq);

	return 1;
}

struct irq_chip irq_type_ia64_lsapic = {
	.name =		"LSAPIC",
	.startup =	lsapic_noop_startup,
	.shutdown =	lsapic_noop,
	.enable =	lsapic_noop,
	.disable =	lsapic_noop,
	.ack =		lsapic_noop,
	.retrigger =	lsapic_retrigger,
};

/*
 * LSAPIC Interrupt Controller
 *
 * This takes care of interrupts that are generated by the CPU's
 * internal Streamlined Advanced Programmable Interrupt Controller
 * (LSAPIC), such as the ITC and IPI interrupts.
    *
 * Copyright (C) 1999 VA Linux Systems
 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
 * Copyright (C) 2000 Hewlett-Packard Co
 * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
 */

#include <linux/sched.h>
#include <linux/irq.h>

static unsigned int
lsapic_noop_startup (struct irq_data *data)
{
	return 0;
}

static void
lsapic_noop (struct irq_data *data)
{
	/* nothing to do... */
}

static int lsapic_retrigger(struct irq_data *data)
{
	ia64_resend_irq(data->irq);

	return 1;
}

struct irq_chip irq_type_ia64_lsapic = {
	.name =			"LSAPIC",
	.irq_startup =		lsapic_noop_startup,
	.irq_shutdown =		lsapic_noop,
	.irq_enable =		lsapic_noop,
	.irq_disable =		lsapic_noop,
	.irq_ack =		lsapic_noop,
	.irq_retrigger =	lsapic_retrigger,
};

ia64: Convert lsapic to new irq_chip functions

Signed-off-by: Thomas Gleixner <00e4cf8f46a57000a44449bf9dd8cbbcc209fd2a@linutronix.de>


#ifndef _PURCHASEEVENT_H_
#define _PURCHASEEVENT_H_

#include <Event.h>

class PurchaseEvent : public Event {
public:
  enum Type {
    PURCHASE_STATUS
  };
 PurchaseEvent(double _timestamp, int _productId, Type _type, bool _newPurchase) : Event(_timestamp), type(_type), newPurchase(_newPurchase), productId(_productId) { }

  Event * dup() const override { return new PurchaseEvent(*this); }
  void dispatch(EventHandler & element) override;
  bool isBroadcast() const override { return true; }

  Type getType() { return type; }
  bool isNew() { return newPurchase; }
  int getProductId() { return productId; }

 private:
  Type type;
  bool newPurchase;
  int productId;
};

#endif

#ifndef _PURCHASEEVENT_H_
#define _PURCHASEEVENT_H_

#include <Event.h>

class PurchaseEvent : public Event {
public:
  enum Type {
    PURCHASE_STATUS
  };
 PurchaseEvent(double _timestamp, std::string _productId, Type _type, bool _newPurchase) : Event(_timestamp), type(_type), newPurchase(_newPurchase), productId(_productId) { }

  Event * dup() const override { return new PurchaseEvent(*this); }
  void dispatch(EventHandler & element) override;
  bool isBroadcast() const override { return true; }

  Type getType() { return type; }
  bool isNew() { return newPurchase; }
  std::string getProductId() { return productId; }

 private:
  Type type;
  bool newPurchase;
  std::string productId;
};

#endif

Change product Id to string

Change product Id to string


#pragma once
#include <Engine.h>
#include "StubUObject.generated.h"

// This class is only here to make sure we're visible to UHT.
// We need to be visible to UHT so that UE4HaxeExternGenerator works correctly
// (as any script generator must return a module name that is visible to UHT)
// see IScriptGeneratorPluginInterface::GetGeneratedCodeModuleName for the related code
UCLASS()
class HAXEINIT_API UObjectStub : public UObject {
  GENERATED_BODY()
};

Add uobject stub to make the script generator plugin happy


// REQUIRES: x86-64-registered-target
// RUN: %clang_cc1 %s -verify -fasm-blocks

#define M __asm int 0x2c
#define M2 int

void t1(void) { M }
void t2(void) { __asm int 0x2c }
void t3(void) { __asm M2 0x2c }
void t4(void) { __asm mov eax, fs:[0x10] }
void t5() {
  __asm {
    int 0x2c ; } asm comments are fun! }{
  }
  __asm {}
}
int t6() {
  __asm int 3 ; } comments for single-line asm
  __asm {}

  __asm int 4
  return 10;
}
void t7() {
  __asm {
    push ebx
    mov ebx, 0x07
    pop ebx
  }
}
void t8() {
  __asm nop __asm nop __asm nop
}
void t9() {
  __asm nop __asm nop ; __asm nop
}
int t_fail() { // expected-note {{to match this}}
  __asm
  __asm { // expected-error 3 {{expected}} expected-note {{to match this}}

Add x86 requirement to hopefully fix ppc bots.

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


// The Mordax Microkernel
// (c) Kristian Klomsten Skordal 2013 <kristian.skordal@gmail.com>
// Report bugs and issues on <http://github.com/skordal/mordax/issues>

#ifndef MORDAX_TYPES_H
#define MORDAX_TYPES_H

#include <stdint.h>

/** Object size type. */
typedef uint32_t size_t;

/** Physical pointer type. */
typedef void * physical_ptr;

/** 64-bit generic big endian type. */
typedef uint64_t be64;
/** 32-bit generic big endian type. */
typedef uint32_t be32;

/** 64-bit generic little endian type. */
typedef uint64_t le64;
/** 32-bit generic little endian type. */
typedef uint32_t le32;

#endif

// The Mordax Microkernel
// (c) Kristian Klomsten Skordal 2013 <kristian.skordal@gmail.com>
// Report bugs and issues on <http://github.com/skordal/mordax/issues>

#ifndef MORDAX_TYPES_H
#define MORDAX_TYPES_H

#include <stdbool.h>
#include <stdint.h>

/** Object size type. */
typedef uint32_t size_t;

/** Physical pointer type. */
typedef void * physical_ptr;

/** 64-bit generic big endian type. */
typedef uint64_t be64;
/** 32-bit generic big endian type. */
typedef uint32_t be32;

/** 64-bit generic little endian type. */
typedef uint64_t le64;
/** 32-bit generic little endian type. */
typedef uint32_t le32;

#endif

Add stdbool to the datatype header

Add stdbool to the datatype header


#include "bmmap.h"
#include "vty.h"

void bmmap_init() {
}

void bmmap_print() {
  vty_puts("BIOS memory map:\n");
  vty_printf("%d entries at %p\n",
             *bios_memmap_entries_ptr,
             bios_memmap_ptr);
  vty_printf("ADDR LOW   ADDR HI   LEN LOW    LEN HI      TYPE  RESERVED\n");
  for(int i = 0; i < *bios_memmap_entries_ptr; i++) {
    BmmapEntry * entry = &(*bios_memmap_ptr)[i];
    vty_printf("%08x  %08x  %08x  %08x  %08x  %08x\n",
               entry->base_addr_low,
               entry->base_addr_high,
               entry->length_low,
               entry->length_high,
               entry->type,
               entry->reserved);
  }
}

#include "bmmap.h"
#include "vty.h"

void bmmap_init() {
}

void bmmap_print() {
  vty_puts("BIOS memory map:\n");
  vty_printf("%d entries at %p\n",
             *bios_memmap_entries_ptr,
             bios_memmap_ptr);
  vty_printf("       ADDR               LEN           TYPE    RESERVED\n");
  for(int i = 0; i < *bios_memmap_entries_ptr; i++) {
    BmmapEntry * entry = &(*bios_memmap_ptr)[i];
    vty_printf("%08x:%08x  %08x:%08x  %08x  %08x\n",
               entry->base_addr_high,
               entry->base_addr_low,
               entry->length_high,
               entry->length_low,
               entry->type,
               entry->reserved);
  }
}

Tweak display of BIOS memory map

Tweak display of BIOS memory map


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

#ifndef CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
#define CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
#pragma once

#include "content/browser/renderer_host/render_view_host_observer.h"

class GURL;
struct DesktopNotificationHostMsg_Show_Params;

// Per-tab Desktop notification handler. Handles desktop notification IPCs
// coming in from the renderer.
class DesktopNotificationHandler : public RenderViewHostObserver {
 public:
  explicit DesktopNotificationHandler(RenderViewHost* render_view_host);
  virtual ~DesktopNotificationHandler();

 private:
  // RenderViewHostObserver implementation.
  virtual bool OnMessageReceived(const IPC::Message& message);

  // IPC handlers.
  void OnShow(const DesktopNotificationHostMsg_Show_Params& params);
  void OnCancel(int notification_id);
  void OnRequestPermission(const GURL& origin, int callback_id);

 private:
  DISALLOW_COPY_AND_ASSIGN(DesktopNotificationHandler);
};

#endif  // CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_

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

#ifndef CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
#define CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_
#pragma once

#include "content/browser/renderer_host/render_view_host_observer.h"

class GURL;
struct DesktopNotificationHostMsg_Show_Params;

// Per-tab Desktop notification handler. Handles desktop notification IPCs
// coming in from the renderer.
class DesktopNotificationHandler : public RenderViewHostObserver {
 public:
  explicit DesktopNotificationHandler(RenderViewHost* render_view_host);
  virtual ~DesktopNotificationHandler();

 private:
  // RenderViewHostObserver implementation.
  bool OnMessageReceived(const IPC::Message& message);

  // IPC handlers.
  void OnShow(const DesktopNotificationHostMsg_Show_Params& params);
  void OnCancel(int notification_id);
  void OnRequestPermission(const GURL& origin, int callback_id);

 private:
  DISALLOW_COPY_AND_ASSIGN(DesktopNotificationHandler);
};

#endif  // CHROME_BROWSER_DESKTOP_NOTIFICATION_HANDLER_H_

Revert 80939 - Fix clang error
TBR=jam@chromium.org

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


#ifndef REFLECTIONCOEFFICIENT_H
#define REFLECTIONCOEFFICIENT_H

#include "SidePostprocessor.h"
#include "MooseVariableInterface.h"

class ReflectionCoefficient;

template <>
InputParameters validParams<ReflectionCoefficient>();

class ReflectionCoefficient : public SidePostprocessor, public MooseVariableInterface<Real>
{
public:
  ReflectionCoefficient(const InputParameters & parameters);

  virtual void initialize() override;
  virtual void execute() override;
  virtual PostprocessorValue getValue() override;

  virtual void threadJoin(const UserObject & y) override;

protected:
  virtual Real computeReflection();

  const VariableValue & _u;

  unsigned int _qp;

private:
  const VariableValue & _coupled_imag;

  Real _theta;

  Real _length;

  Real _k;

  Real _coeff;

  Real _reflection_coefficient;
};

#endif // REFLECTIONCOEFFICIENT_H

#pragma once

#include "SidePostprocessor.h"
#include "MooseVariableInterface.h"

class ReflectionCoefficient;

template <>
InputParameters validParams<ReflectionCoefficient>();

class ReflectionCoefficient : public SidePostprocessor, public MooseVariableInterface<Real>
{
public:
  ReflectionCoefficient(const InputParameters & parameters);

  virtual void initialize() override;
  virtual void execute() override;
  virtual PostprocessorValue getValue() override;

  virtual void threadJoin(const UserObject & y) override;

protected:
  virtual Real computeReflection();

  const VariableValue & _u;

  unsigned int _qp;

private:
  const VariableValue & _coupled_imag;

  Real _theta;

  Real _length;

  Real _k;

  Real _coeff;

  Real _reflection_coefficient;
};

Convert postprocessors to pragma once

Convert postprocessors to pragma once

refs #21085


/*

Entry point for the Windows NT DLL.

About the only reason for having this, is so initall() can automatically
be called, removing that burden (and possible source of frustration if
forgotten) from the programmer.

*/
#include "windows.h"

/* NT and Python share these */
#undef INCREF
#undef DECREF
#include "config.h"
#include "allobjects.h"

HMODULE PyWin_DLLhModule = NULL;

BOOL	WINAPI	DllMain (HANDLE hInst,
						ULONG ul_reason_for_call,
						LPVOID lpReserved)
{
	switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
			PyWin_DLLhModule = hInst;
			initall();
			break;
		case DLL_PROCESS_DETACH:
			break;
	}
	return TRUE;
}

/*

Entry point for the Windows NT DLL.

About the only reason for having this, is so initall() can automatically
be called, removing that burden (and possible source of frustration if
forgotten) from the programmer.

*/
#include "windows.h"

/* NT and Python share these */
#include "config.h"
#include "Python.h"

HMODULE PyWin_DLLhModule = NULL;

BOOL	WINAPI	DllMain (HANDLE hInst,
						ULONG ul_reason_for_call,
						LPVOID lpReserved)
{
	switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
			PyWin_DLLhModule = hInst;
			//initall();
			break;
		case DLL_PROCESS_DETACH:
			break;
	}
	return TRUE;
}

Use Python.h, not allobjects.h. Don't call initall() (Experimental incompatible change!!!!!!)


/*
 * Copyright (C) 2014-2015 Pavel Dolgov
 *
 * See the LICENSE file for terms of use.
 */

#include <stdio.h>

#define TOWER1 1
#define TOWER2 3

void hanoi(int a, int n1, int n2) {
     if (a == 1) { // end of recursion
        printf("%d %d %d\n", a, n1, n2);
     } else {
        int x, na;
        for (x = TOWER1; x <= TOWER2; x++) {
             if ((x != n1) && (x != n2)) {
                 na = x;
                 break;
             }
        }
        hanoi(a - 1, n1, na); // recursion
        printf("%d %d %d\n", a, n1, n2);
        hanoi(a - 1, na, n2); // recursion
    }
}

int main() {
    int n;
    scanf("%d", &n);
    hanoi(n, TOWER1, TOWER2);
}

Fix layout (delete empty string)

Fix layout (delete empty string)


#pragma once // This guarantees that the code is included only once in the game.
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"

class Game {
    public:
        // Objects declared static are allocated storage in static storage area, and have scope till the end of the program.
        static void Start();
    private:
        static bool IsExiting();
        static void GameLoop();

        enum GameState {
            Uninitialized, ShowingSplash, Paused, ShowingMenu, Playing, Exiting
        }; // Represents the various states the game can be in. An enum is a user-defined type consisting of a set of named constants called enumerators.

        static GameState _gameState;
        static sf::RenderWindow _mainWindow;
};

#ifndef GAME_H // This guarentees that the code is included only once in the game.
#define GAME_H

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

class Game {
    public:
        // Objects declared static are allocated storage in static storage area, and have scope till the end of the program.
        static void start();
    private:
        static bool is_exiting();
        static void game_loop();

        enum game_state {
            Uninitialized, ShowingSplash, Paused, ShowingMenu, Playing, Exiting
        }; // Represents the various states the game can be in. An enum is a user-defined type consisting of a set of named constants called enumerators.

        static game_state s_game_state;
        static sf::RenderWindow s_main_window;
};

#endif

Change styling convention of the variable names


#ifndef ELASTIC_H
#define ELASTIC_H

#include "MaterialModel.h"

// Forward declarations
class ElasticityTensor;
class Elastic;

template<>
InputParameters validParams<Elastic>();

class Elastic : public MaterialModel
{
public:
  Elastic( const std::string & name,
           InputParameters parameters );
  virtual ~Elastic();

protected:

  /// Compute the stress (sigma += deltaSigma)
  virtual void computeStress();

};

#endif

Update new files with SymmTensor changes

r5226


/*
 * dremf() wrapper for remainderf().
 *
 * Written by J.T. Conklin, <jtc@wimsey.com>
 * Placed into the Public Domain, 1994.
 */

#include "math.h"
#include "math_private.h"

float
dremf(x, y)
	float x, y;
{
	return remainderf(x, y);
}

/*
 * dremf() wrapper for remainderf().
 *
 * Written by J.T. Conklin, <jtc@wimsey.com>
 * Placed into the Public Domain, 1994.
 */
/* $FreeBSD$ */

#include "math.h"
#include "math_private.h"

float
dremf(float x, float y)
{
	return remainderf(x, y);
}

Work around known GCC 3.4.x problem and use ANSI prototype for dremf().


#include <stdio.h>

#define MAXLINE 10/*00*/  /* maximum input size */

int _getline(char line[], int maxline);
/* getline is a library function in POSIX; unfortunately on OS X the -ansi flag
   doesn't help */
void copy(char to[], char from[]);

main() {
    int len;
    int max;
    char line[MAXLINE];
    char longest[MAXLINE];

    max = 0;
    while ((len = _getline(line, MAXLINE)) > 0)
        if (len > max) {
            max = len;
            copy(longest, line);
        }
    if (max > 0) {  /* there was a line */
        printf("%d\n", max);
        printf("%s", longest);
    }
    return 0;
}

/* _getline: read a line into s, return length */
int _getline(char s[], int lim) {
    int c, i, length;

    i = length = 0;
    while ((c = getchar()) != EOF) {
        ++length;
        if (i < lim - 1) {
            s[i] = c;
            ++i;
        }
        if (c == '\n') {
            break;
        }
    }
    s[i-1] = '\n';
    s[i] = '\0';
    return length;
}

/* copy: copy 'from' into 'to'; assume to is big enough */
void copy(char to[], char from[]) {
    int i;

    i = 0;
    while ((to[i] = from[i]) != '\0')
        ++i;
}

Add solution for exercise 16.

Add solution for exercise 16.


#include <stddef.h>

extern int debug;

#ifndef NDEBUG
#define DBG(...) dbg(__VA_ARGS__)
#define DBGON() (debug = 1)
#else
#define DBG(...)
#define DBGON()
#endif

#define TINT        long long
#define TUINT       unsigned long long
#define TFLOAT      double

struct items {
	char **s;
	unsigned n;
};

typedef struct alloc Alloc;

extern void die(const char *fmt, ...);
extern void dbg(const char *fmt, ...);
extern void newitem(struct items *items, char *item);
extern void *xmalloc(size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
extern char *xstrdup(const char *s);
extern void *xrealloc(void *buff, register size_t size);
extern Alloc *alloc(size_t size, size_t nmemb);
extern void dealloc(Alloc *allocp);
extern void *new(Alloc *allocp);
extern void delete(Alloc *allocp, void *p);
extern int casecmp(const char *s1, const char *s2);
extern int lpack(unsigned char *dst, char *fmt, ...);
extern int lunpack(unsigned char *src, char *fmt, ...);

#include <stddef.h>

extern int debug;

#ifndef NDEBUG
#define DBG(...) dbg(__VA_ARGS__)
#define DBGON() (debug = 1)
#else
#define DBG(...)
#define DBGON()
#endif

#define TINT        long long
#define TUINT       unsigned long long
#define TUINT_MAX   ULLONG_MAX
#define TINT_MAX    LLONG_MAX
#define TFLOAT      double

struct items {
	char **s;
	unsigned n;
};

typedef struct alloc Alloc;

extern void die(const char *fmt, ...);
extern void dbg(const char *fmt, ...);
extern void newitem(struct items *items, char *item);
extern void *xmalloc(size_t size);
extern void *xcalloc(size_t nmemb, size_t size);
extern char *xstrdup(const char *s);
extern void *xrealloc(void *buff, register size_t size);
extern Alloc *alloc(size_t size, size_t nmemb);
extern void dealloc(Alloc *allocp);
extern void *new(Alloc *allocp);
extern void delete(Alloc *allocp, void *p);
extern int casecmp(const char *s1, const char *s2);
extern int lpack(unsigned char *dst, char *fmt, ...);
extern int lunpack(unsigned char *src, char *fmt, ...);

Add limits macros for TUINT and TINT

Add limits macros for TUINT and TINT


// SKIP PARAM: --sets ana.activated[+] octApron
#include <assert.h>

void main() {
  int x;
  if (x <= 10) {
    assert((x / 3) <= 3);
  }
}

Add test where octApron derives non-integer bounds


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

#include "greatest.h"

TEST standalone_pass(void) {
    PASS();
}

/* Add all the definitions that need to be in the test runner's main file. */
GREATEST_MAIN_DEFS();

int main(int argc, char **argv) {
    (void)argc;
    (void)argv;

    /* Initialize greatest, but don't build the CLI test runner code. */
    GREATEST_INIT();

    RUN_TEST(standalone_pass);

    /* Print report, but do not exit. */
    printf("\nStandard report, as printed by greatest:\n");
    GREATEST_PRINT_REPORT();

    struct greatest_report_t report;
    greatest_get_report(&report);

    printf("\nCustom report:\n");
    printf("pass %u, fail %u, skip %u, assertions %u\n",
        report.passed, report.failed, report.skipped, report.assertions);

    if (report.failed > 0) {
        return 1;
    }

    return 0;
}

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

#include "greatest.h"

TEST standalone_pass(void) {
    PASS();
}

/* Add all the definitions that need to be in the test runner's main file. */
GREATEST_MAIN_DEFS();

int main(int argc, char **argv) {
    struct greatest_report_t report;
    (void)argc;
    (void)argv;

    /* Initialize greatest, but don't build the CLI test runner code. */
    GREATEST_INIT();

    RUN_TEST(standalone_pass);

    /* Print report, but do not exit. */
    printf("\nStandard report, as printed by greatest:\n");
    GREATEST_PRINT_REPORT();

    greatest_get_report(&report);

    printf("\nCustom report:\n");
    printf("pass %u, fail %u, skip %u, assertions %u\n",
        report.passed, report.failed, report.skipped, report.assertions);

    if (report.failed > 0) {
        return 1;
    }

    return 0;
}

Fix warning for mixing declarations and code in ISO C90.


#ifndef LIBTRADING_BYTE_ORDER_H
#define LIBTRADING_BYTE_ORDER_H

#include "libtrading/types.h"

#include <arpa/inet.h>

static inline be16 cpu_to_be16(u16 value)
{
	return htons(value);
}

static inline be32 cpu_to_be32(u32 value)
{
	return htonl(value);
}

static inline u16 be16_to_cpu(be16 value)
{
	return ntohs(value);
}

static inline u32 be32_to_cpu(be32 value)
{
	return ntohl(value);
}

#endif

#ifndef LIBTRADING_BYTE_ORDER_H
#define LIBTRADING_BYTE_ORDER_H

#include <endian.h>

/*
 * Little Endian
 */

static inline le16 cpu_to_le16(u16 value)
{
	return htole16(value);
}

static inline le32 cpu_to_le32(u32 value)
{
	return htole32(value);
}

static inline le64 cpu_to_le64(u64 value)
{
	return htole64(value);
}

static inline u16 le16_to_cpu(le16 value)
{
	return le16toh(value);
}

static inline u32 le32_to_cpu(le32 value)
{
	return le32toh(value);
}

static inline u64 le64_to_cpu(le64 value)
{
	return le64toh(value);
}

/*
 * Big Endian
 */

static inline be16 cpu_to_be16(u16 value)
{
	return htobe16(value);
}

static inline be32 cpu_to_be32(u32 value)
{
	return htobe32(value);
}

static inline be64 cpu_to_be64(u64 value)
{
	return htobe64(value);
}

static inline u16 be16_to_cpu(be16 value)
{
	return be16toh(value);
}

static inline u32 be32_to_cpu(be32 value)
{
	return be32toh(value);
}

static inline u64 be64_to_cpu(be64 value)
{
	return be64toh(value);
}

#endif

Use <endian.h> for byte order helpers

Use <endian.h> for byte order helpers

Also add missing helper functions.

Signed-off-by: Pekka Enberg <add4fcd06328a394f0ad91feda7ee057316dc5ed@kernel.org>


/*
 * Copyright (c) 2006 KATO Kazuyoshi <kzys@8-p.info>
 * This source code is released under the MIT license.
 */

#import <Cocoa/Cocoa.h>

@interface WildcardPattern : NSObject {
	NSString* pattern_;
}

- (id) initWithString: (NSString*) s;
- (BOOL) isMatch: (NSString*) s;

@end

Add copyright and license header.

Add copyright and license header.


#ifndef LACO_UTIL_H
#define LACO_UTIL_H

struct LacoState;
struct lua_State;

/**
 * Load a line into the lua stack to be evaluated later
 *
 * param          pointer to LacoState
 *
 * return -1 if there is no line input to load
 */
int laco_load_line(struct LacoState* laco);

/**
 * Called after laco_load_line, this evaluated the line as a function and
 * hands of the result for printing
 *
 * param          pointer to LacoState
 */
void laco_handle_line(struct LacoState* laco);

/**
 * Kills the loop with exiting message if specified
 *
 * param          pointer to LacoState
 * param          exit with status
 * param          error message
 */
void laco_kill(struct LacoState* laco, int status, const char* message);

/**
 * When there is a value on the lua stack, it will print out depending on
 * the type it is
 *
 * param          pointer to lua_State
 *
 * return LUA_ERRSYNTAX if the value has some error
 */
int laco_print_type(struct lua_State* L);

/**
 * Prints out and pops off errors pushed into the lua stack
 *
 * param          pointer to lua_State
 * param          incoming lua stack status
 */
void laco_report_error(struct lua_State* L, int status);

int laco_is_match(const char** matches, const char* test_string);

#endif /* LACO_UTIL_H */

#ifndef LACO_UTIL_H
#define LACO_UTIL_H

struct LacoState;

/**
 * Load a line into the lua stack to be evaluated later
 *
 * param          pointer to LacoState
 *
 * return -1 if there is no line input to load
 */
int laco_load_line(struct LacoState* laco);

/**
 * Called after laco_load_line, this evaluated the line as a function and
 * hands of the result for printing
 *
 * param          pointer to LacoState
 */
void laco_handle_line(struct LacoState* laco);

/**
 * Kills the loop with exiting message if specified
 *
 * param          pointer to LacoState
 * param          exit with status
 * param          error message
 */
void laco_kill(struct LacoState* laco, int status, const char* message);

/**
 * When there is a value on the lua stack, it will print out depending on
 * the type it is
 *
 * param          pointer to lua_State
 *
 * return LUA_ERRSYNTAX if the value has some error
 */
int laco_print_type(struct LacoState* laco);

/**
 * Prints out and pops off errors pushed into the lua stack
 *
 * param          pointer to lua_State
 * param          incoming lua stack status
 */
void laco_report_error(struct LacoState* laco, int status);

int laco_is_match(const char** matches, const char* test_string);

#endif /* LACO_UTIL_H */

Change lua_State pointer to LacoState

Change lua_State pointer to LacoState

Mostly for consistency in the API.


/*
Copyright 2019 Google Inc. 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.
*/

/*!
 *\brief Process group placeholder.
 *
 * Does nothing except sitting around until killed. Spawned as extra process in
 * our process groups so that we can control on our own when the process group
 * ID is reclaimed to the kernel, namely by killing the entire process group.
 * This prevents a race condition of our process group getting reclaimed before
 * we try to kill possibly remaining processes in it, after which we would
 * possibly kill something else.
 *
 * Must be a separate executable so F_CLOEXEC applies as intended.
 */

#include <unistd.h>

int main() {
  for (;;) {
    pause();
  }
  return 0;
}

/*
Copyright 2019 Google Inc. 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.
*/

/*!
 *\brief Process group placeholder.
 *
 * Does nothing except sitting around until killed. Spawned as extra process in
 * our process groups so that we can control on our own when the process group
 * ID is reclaimed to the kernel, namely by killing the entire process group.
 * This prevents a race condition of our process group getting reclaimed before
 * we try to kill possibly remaining processes in it, after which we would
 * possibly kill something else.
 *
 * Must be a separate executable so F_CLOEXEC applies as intended.
 */

#include <stdlib.h>
#include <unistd.h>

int main() {
  for (;;) {
    pause();
  }
  // Cannot get here.
  abort();
}

Return failure if the unexitable loop ever exits ;)

(cleaner)


/**
 * magical invsqrt function from Quake III code
 * see: http://www.codemaestro.com/reviews/9
 */

float InvSqrt(float x)
{
	float xhalf = 0.5f*x;
	int i = *(int*)&x;
	i = 0x5f3759df - (i>>1);
	x = *(float*)&i;
	x = x*(1.5f-xhalf*x*x);
	return x;
}

int main(void) {
	int result = InvSqrt(0.00056);
	printf("Result: %d (should be 42)", result);
	return result != 42;
}

Test case for historical reasons

Test case for historical reasons

[r22410]


#ifndef DEBUGGER_H
#define DEBUGGER_H

enum DebuggerState {
	DEBUGGER_PAUSED,
	DEBUGGER_RUNNING,
	DEBUGGER_EXITING
};

struct ARMDebugger {
	enum DebuggerState state;
	struct ARMCore* cpu;

	char* lastCommand;
};

void ARMDebuggerInit(struct ARMDebugger*, struct ARMCore*);
void ARMDebuggerRun(struct ARMDebugger*);
void ARMDebuggerEnter(struct ARMDebugger*);

#endif

#ifndef DEBUGGER_H
#define DEBUGGER_H

enum DebuggerState {
	DEBUGGER_PAUSED,
	DEBUGGER_RUNNING,
	DEBUGGER_EXITING
};

struct ARMDebugger {
	enum DebuggerState state;
	struct ARMCore* cpu;

	char* lastCommand;
	struct DebugBreakpoint* breakpoints;
};

void ARMDebuggerInit(struct ARMDebugger*, struct ARMCore*);
void ARMDebuggerRun(struct ARMDebugger*);
void ARMDebuggerEnter(struct ARMDebugger*);

#endif

Add missing field for breakpoints

Add missing field for breakpoints


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

#include "obc.h"
#include "system.h"
#include "terminal.h"

void I2CTestCommandHandler(uint16_t argc, char* argv[])
{
    UNREFERENCED_PARAMETER(argc);

    I2CBus* bus;

    if (strcmp(argv[0], "system") == 0)
    {
        bus = Main.I2C.System;
    }
    else if (strcmp(argv[0], "payload") == 0)
    {
        bus = Main.I2C.Payload;
    }
    else
    {
        TerminalPuts("Unknown bus\n");
    }

    const uint8_t device = (uint8_t)atoi(argv[1]);
    const uint8_t* data = (uint8_t*)argv[2];
    const size_t dataLength = strlen(argv[2]);

    uint8_t output[20] = {0};
    size_t outputLength = dataLength;

    const I2CResult result = bus->WriteRead(bus, device, data, dataLength, output, outputLength);

    if (result == I2CResultOK)
    {
        TerminalPuts((char*)output);
    }
    else
    {
        TerminalPrintf("Error %d\n", result);
    }
}

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

#include "obc.h"
#include "system.h"
#include "terminal.h"

void I2CTestCommandHandler(uint16_t argc, char* argv[])
{
    UNREFERENCED_PARAMETER(argc);

    if (argc != 3)
    {
        TerminalPuts("i2c <system|payload> <device> <data>\n");
        return;
    }

    I2CBus* bus;

    if (strcmp(argv[0], "system") == 0)
    {
        bus = Main.I2C.System;
    }
    else if (strcmp(argv[0], "payload") == 0)
    {
        bus = Main.I2C.Payload;
    }
    else
    {
        TerminalPuts("Unknown bus\n");
    }

    const uint8_t device = (uint8_t)atoi(argv[1]);
    const uint8_t* data = (uint8_t*)argv[2];
    const size_t dataLength = strlen(argv[2]);

    uint8_t output[20] = {0};
    size_t outputLength = dataLength;

    const I2CResult result = bus->WriteRead(bus, device, data, dataLength, output, outputLength);

    if (result == I2CResultOK)
    {
        TerminalPuts((char*)output);
    }
    else
    {
        TerminalPrintf("Error %d\n", result);
    }
}

Check args count in test i2c terminal command


/*
 Copyright (c) 2012 Curtis Hard - GeekyGoodness
 */

/*
 Modified by Denis Zamataev. 2014
 */

#import <Foundation/Foundation.h>

#import <HTMLReader.h>

#import "DZReadability_constants.h"

typedef void (^GGReadabilityParserCompletionHandler)( NSString * content );
typedef void (^GGReadabilityParserErrorHandler)( NSError * error );

@interface GGReadabilityParser : NSObject {

    float loadProgress;

@private
    GGReadabilityParserErrorHandler errorHandler;
    GGReadabilityParserCompletionHandler completionHandler;
    GGReadabilityParserOptions options;
    NSURL * URL;
    NSURL * baseURL;
    long long dataLength;
    NSMutableData * responseData;
    NSURLConnection * URLConnection;
    NSURLResponse * URLResponse;

}

@property ( nonatomic, assign ) float loadProgress;

- (id)initWithOptions:(GGReadabilityParserOptions)parserOptions;
- (id)initWithURL:(NSURL *)aURL
          options:(GGReadabilityParserOptions)parserOptions
completionHandler:(GGReadabilityParserCompletionHandler)cHandler
     errorHandler:(GGReadabilityParserErrorHandler)eHandler;

- (void)cancel;
- (void)render;
- (void)renderWithString:(NSString *)string;

- (HTMLElement *)processXMLDocument:(HTMLDocument *)XML baseURL:(NSURL *)theBaseURL error:(NSError **)error;
@end

/*
 Copyright (c) 2012 Curtis Hard - GeekyGoodness
 */

/*
 Modified by Denis Zamataev. 2014
 */

#import <Foundation/Foundation.h>

#import "HTMLReader.h"

#import "DZReadability_constants.h"

typedef void (^GGReadabilityParserCompletionHandler)( NSString * content );
typedef void (^GGReadabilityParserErrorHandler)( NSError * error );

@interface GGReadabilityParser : NSObject {

    float loadProgress;

@private
    GGReadabilityParserErrorHandler errorHandler;
    GGReadabilityParserCompletionHandler completionHandler;
    GGReadabilityParserOptions options;
    NSURL * URL;
    NSURL * baseURL;
    long long dataLength;
    NSMutableData * responseData;
    NSURLConnection * URLConnection;
    NSURLResponse * URLResponse;

}

@property ( nonatomic, assign ) float loadProgress;

- (id)initWithOptions:(GGReadabilityParserOptions)parserOptions;
- (id)initWithURL:(NSURL *)aURL
          options:(GGReadabilityParserOptions)parserOptions
completionHandler:(GGReadabilityParserCompletionHandler)cHandler
     errorHandler:(GGReadabilityParserErrorHandler)eHandler;

- (void)cancel;
- (void)render;
- (void)renderWithString:(NSString *)string;

- (HTMLElement *)processXMLDocument:(HTMLDocument *)XML baseURL:(NSURL *)theBaseURL error:(NSError **)error;
@end

Fix HTMLReader include when using dynamic frameworks


//
// Created by Borin Ouch on 2016-03-22.
//

#ifndef SFML_TEST_GAME_STATE_H
#define SFML_TEST_GAME_STATE_H

#include "game.h"

class GameState {

public:
    Game* game;

    virtual void draw(const float dt) = 0;
    virtual void update(const float dt) = 0;
    virtual void handleInput() = 0;
};

#endif //SFML_TEST_GAME_STATE_H

//
// Created by Borin Ouch on 2016-03-22.
//

#ifndef SFML_TEST_GAME_STATE_H
#define SFML_TEST_GAME_STATE_H

#include "game.h"

class GameState {

public:
    Game* game;

    virtual void draw(const float dt) = 0;
    virtual void update(const float dt) = 0;
    virtual void handleInput() = 0;

    virtual ~GameState() {};
};

#endif //SFML_TEST_GAME_STATE_H

Add virtual destructor to game state

Add virtual destructor to game state


#ifndef __SH_COMMON_H__
#define __SH_COMMON_H__

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

// ensure is kinda like assert but it is always executed
#define ensure(p, msg)                                            \
do {                                                              \
    if (!(p)) {                                                   \
        burst_into_flames(__FILE__, __LINE__, msg);               \
    }                                                             \
} while(0)

void burst_into_flames(const char* file, int line, const char* msg) {
    printf("%s - %s:%d", msg, file, line);
    abort();
}

#endif

Add ensure for runtime assertion checking


// This is a queue that can be accessed from multiple threads safely.
//
// It's not well optimized, and requires obtaining a lock every time you check for a new value.

#pragma once

#include <condition_variable>
#include <mutex>
#include <optional>
#include <queue>

template <class T>
class SynchronizedQueue {
    std::condition_variable cv_;
    std::mutex lock_;
    std::queue<T> q_;
public:

    void push(T && t) {
        std::unique_lock l(lock_);
        q_.push(std::move(t));
        cv_.notify_one();
    }

    std::optional<T> get() {
        std::unique_lock l(lock_);
        if(q_.empty()) {
            return std::nullopt;
        }

        T t = std::move(q_.front());
        q_.pop();
        return t;
    }

    T get_blocking() {
        std::unique_lock l(lock_);
        while(q_.empty()) {
            cv_.wait(l);
        }

        T t = std::move(q_.front());
        q_.pop();
        return std::move(t);
    }
};

// This is a queue that can be accessed from multiple threads safely.
//
// It's not well optimized, and requires obtaining a lock every time you check for a new value.

#pragma once

#include <condition_variable>
#include <mutex>
#include <optional>
#include <queue>

template <class T>
class SynchronizedQueue {
    std::condition_variable cv_;
    std::mutex lock_;
    std::queue<T> q_;
    std::atomic_uint64_t input_count{0}, output_count{0};
public:

    void push(T && t) {
        std::unique_lock l(lock_);
        q_.push(std::move(t));
        input_count++;
        cv_.notify_one();
    }

    std::optional<T> get() {
        if(input_count == output_count) {
            return std::nullopt;
        }
        {
            std::unique_lock l(lock_);
            if(q_.empty()) {
                return std::nullopt;
            }

            output_count++;
            T t = std::move(q_.front());
            q_.pop();
            return t;
        }
    }

    T get_blocking() {
        std::unique_lock l(lock_);
        while(q_.empty()) {
            cv_.wait(l);
        }

        output_count++;
        T t = std::move(q_.front());
        q_.pop();
        return std::move(t);
    }
};

Increase the efficiency of multithreading. This should slightly slightly increase frame rate.


#ifndef __GTK_COMPAT_H__
#define __GTK_COMPAT_H__

#include <gtk/gtk.h>

/* Provide a compatibility layer for accessor functions introduced
 * in GTK+ 2.21.1 which we need to build with sealed GDK.
 * That way it is still possible to build with GTK+ 2.20.
 */

#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 21) \
	|| (GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION < 1)

#define gdk_drag_context_get_actions(context)          (context)->actions
#define gdk_drag_context_get_suggested_action(context) (context)->suggested_action
#define gdk_drag_context_get_selected_action(context)  (context)->action

#endif

#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION == 1
#define gdk_drag_context_get_selected_action(context)  gdk_drag_context_get_action(context)
#endif

#endif /* __GTK_COMPAT_H__ */

#ifndef __GTK_COMPAT_H__
#define __GTK_COMPAT_H__

#include <gtk/gtk.h>

/* Provide a compatibility layer for accessor functions introduced
 * in GTK+ 2.21.1 which we need to build with sealed GDK.
 * That way it is still possible to build with GTK+ 2.20.
 */

#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION < 21) \
	|| (GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION < 1)

#define gdk_drag_context_get_actions(context)          (context)->actions
#define gdk_drag_context_get_suggested_action(context) (context)->suggested_action
#define gdk_drag_context_get_selected_action(context)  (context)->action

#endif

#if GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION == 21 && GTK_MICRO_VERSION == 1
#define gdk_drag_context_get_selected_action(context)  gdk_drag_context_get_action(context)
#endif

#if GTK_CHECK_VERSION (2,90,5)

/* Recreate GdkRegion until we drop GTK2 compatibility. */

#define GdkRegion cairo_region_t

#define gdk_region_destroy(region) \
	(cairo_region_destroy (region))

#define gdk_region_point_in(region, x, y) \
	(cairo_region_contains_point ((region), (x), (y)))

#define gdk_region_rectangle(rectangle) \
	(((rectangle)->width <= 0 || (rectangle->height <= 0)) ? \
	cairo_region_create () : cairo_region_create_rectangle (rectangle))

#endif

#endif /* __GTK_COMPAT_H__ */

Work around sudden disappearance of GdkRegion in GTK+ 2.90.5.

API was deprecated and removed in less than two hours!  Sheesh!


#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "wclock.h"
#ifdef _WIN32
# include <windows.h>
static unsigned int sleep(unsigned int x) { Sleep(x * 1000); return 0; }
#else
# include <unistd.h>
#endif

int main(void)
{
    double res, t1, t2;
    wclock clock;

    if (wclock_init(&clock)) {
        abort();
    }

    res = wclock_get_res(&clock);
    printf("%.17g\n", res);
    assert(res > 0);
    assert(res < 2e-3);  /* presumably the clock has at least ms precision! */

    t1 = wclock_get(&clock);
    printf("%.17g\n", t1);

    sleep(1);

    t2 = wclock_get(&clock);
    printf("%.17g\n", t2);
    printf("%.17g\n", t2 - t1);
    assert(fabs(t2 - t1 - 1.) < 1e-1);

    return 0;
}

#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include "wclock.h"
#ifdef _WIN32
# include <windows.h>
static unsigned int sleep(unsigned int x) { Sleep(x * 1000); return 0; }
#else
# include <unistd.h>
#endif

int main(void)
{
    double res, t1, t2;
    wclock clock;

    if (wclock_init(&clock)) {
        abort();
    }

    res = wclock_get_res(&clock);
    printf("%.17g\n", res);
    assert(res > 0);
    assert(res < 2e-3);  /* presumably the clock has at least ms precision! */

    t1 = wclock_get(&clock);
    printf("%.17g\n", t1);

    sleep(1);

    t2 = wclock_get(&clock);
    printf("%.17g\n", t2);
    printf("%.17g\n", t2 - t1);
    assert(t2 - t1 >= 0.9 && t2 - t1 < 1.4);

    return 0;
}

Increase time tolerance to reduce flakiness on slow systems


#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>

#include <cmocka.h>

#include "cbor.h"

#ifndef ASSERTIONS_H_
#define ASSERTIONS_H_

void assert_uint8(cbor_item_t* item, uint8_t num);
void assert_uint16(cbor_item_t* item, uint16_t num);
void assert_uint32(cbor_item_t* item, uint32_t num);
void assert_uint64(cbor_item_t* item, uint64_t num);

void assert_decoder_result(size_t, enum cbor_decoder_status,
                           struct cbor_decoder_result);

// TODO: Docs
void assert_decoder_result_nedata(size_t, struct cbor_decoder_result);

/**
 * Check that the streaming decoder will returns a correct CBOR_DECODER_NEDATA
 * result for all inputs from data[0..1] through data[0..(expected-1)].
 */
void assert_minimum_input_size(size_t expected, cbor_data data);

#endif

#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>

#include <cmocka.h>

#include "cbor.h"

#ifndef ASSERTIONS_H_
#define ASSERTIONS_H_

void assert_uint8(cbor_item_t* item, uint8_t num);
void assert_uint16(cbor_item_t* item, uint16_t num);
void assert_uint32(cbor_item_t* item, uint32_t num);
void assert_uint64(cbor_item_t* item, uint64_t num);

/** Assert that result `status` and `read` are equal. */
void assert_decoder_result(size_t read, enum cbor_decoder_status status,
                           struct cbor_decoder_result result);

/**
 * Assert that the result is set to CBOR_DECODER_NEDATA with the given
 * `cbor_decoder_result.required` value.
 */
void assert_decoder_result_nedata(size_t required,
                                  struct cbor_decoder_result result);

/**
 * Check that the streaming decoder returns a correct CBOR_DECODER_NEDATA
 * result for all inputs from data[0..1] through data[0..(expected-1)].
 */
void assert_minimum_input_size(size_t expected, cbor_data data);

#endif

Add inline docs for asserts

Add inline docs for asserts


/* setfattr.c - sets user extended attributes for a file.
 *
 * This program can be viewed as a much simpler version of setfattr(1) utility,
 * used to set, remove and list a file's extended attributes. All this program
 * can do, however, is to set user EAs.
 *
 * Usage
 *
 *    $ ./setfattr <name> <value> <file>
 *
 *    <name>  - the name of the EA to be set. Note that the `user.` namespace
 *    is added automatically.
 *    <value> - the value to be set.
 *    <file>  - the file to which the program should add the EA.
 *
 * Author: Renato Mascarenhas Costa
 */

#include <unistd.h>
#include <sys/types.h>
#include <sys/xattr.h>

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

static void helpAndLeave(const char *progname, int status);
static void pexit(const char *fCall);

int
main(int argc, char *argv[]) {
  if (argc != 4) {
    helpAndLeave(argv[0], EXIT_FAILURE);
  }

  char ea_name[BUFSIZ];
  char *name, *value, *file;

  name  = argv[1];
  value = argv[2];
  file  = argv[3];

  snprintf(ea_name, BUFSIZ, "user.%s", name);

  if (setxattr(file, ea_name, value, strlen(ea_name), 0) == -1) {
    pexit("setxattr");
  }

  exit(EXIT_SUCCESS);
}

static void
helpAndLeave(const char *progname, int status) {
  FILE *stream = stderr;

  if (status == EXIT_SUCCESS) {
    stream = stdout;
  }

  fprintf(stream, "Usage: %s <name> <value> <file>\n", progname);
  exit(status);
}

static void
pexit(const char *fCall) {
  perror(fCall);
  exit(EXIT_FAILURE);
}

Add or replace user extended attributes on a file.

Chapter 16, exercise 1.


#include <sys/types.h>
#include <pthread.h>
#include "vendor/simclist.h"

#ifndef BUZZLOCK_H_
#define BUZZLOCK_H_

#define BZZ_BLACK 1
#define BZZ_GOLD  0

typedef int useconds_t;

typedef struct {
	pid_t id;
	int color;
	double waiting_since;
} bzz_thread_t;

typedef struct {
	pthread_mutex_t mutex;
	pthread_cond_t  cond;
	int max_active_threads;
	int active_threads;
	useconds_t timeout;
	list_t threads;
	list_t waiting_gold_threads;
	list_t waiting_black_threads;
} bzz_t;

#include "buzz.h"

void* get_thread(int, bzz_t);
int full_active_threads(bzz_t);
int is_black(bzz_thread_t*);
int is_gold(bzz_thread_t*);
int is_old(bzz_thread_t*, bzz_t);
void add_to_waiting_threads(bzz_thread_t*, bzz_t);
void wait(bzz_t);
double time_with_usec();
unsigned int num_black_waiting(bzz_t);
unsigned int num_gold_waiting(bzz_t);
unsigned int num_old_gold_waiting(bzz_t);
void add_active(bzz_thread_t*, bzz_t);
#endif

#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#include "vendor/simclist.h"

#ifndef BUZZLOCK_H_
#define BUZZLOCK_H_

#define BZZ_BLACK 1
#define BZZ_GOLD  0

typedef struct {
	pid_t id;
	int color;
	double waiting_since;
} bzz_thread_t;

typedef struct {
	pthread_mutex_t mutex;
	pthread_cond_t  cond;
	int max_active_threads;
	int active_threads;
	useconds_t timeout;
	list_t threads;
	list_t waiting_gold_threads;
	list_t waiting_black_threads;
} bzz_t;

#include "buzz.h"

void* get_thread(int, bzz_t);
int full_active_threads(bzz_t);
int is_black(bzz_thread_t*);
int is_gold(bzz_thread_t*);
int is_old(bzz_thread_t*, bzz_t);
void add_to_waiting_threads(bzz_thread_t*, bzz_t);
void wait(bzz_t);
double time_with_usec();
unsigned int num_black_waiting(bzz_t);
unsigned int num_gold_waiting(bzz_t);
unsigned int num_old_gold_waiting(bzz_t);
void add_active(bzz_thread_t*, bzz_t);
#endif

Use typedef of useconds_t in unistd

Use typedef of useconds_t in unistd


// Copyright 2011 Google Inc. 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 NINJA_UTIL_H_
#define NINJA_UTIL_H_
#pragma once

#include <string>

// Dump a backtrace to stderr.
// |skip_frames| is how many frames to skip;
// DumpBacktrace implicitly skips itself already.
void DumpBacktrace(int skip_frames);

// Log a fatal message, dump a backtrace, and exit.
void Fatal(const char* msg, ...);

// Canonicalize a path like "foo/../bar.h" into just "bar.h".
bool CanonicalizePath(std::string* path, std::string* err);

#endif  // NINJA_UTIL_H_

// Copyright 2011 Google Inc. 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 NINJA_UTIL_H_
#define NINJA_UTIL_H_
#pragma once

#include <string>

// Log a fatal message, dump a backtrace, and exit.
void Fatal(const char* msg, ...);

// Canonicalize a path like "foo/../bar.h" into just "bar.h".
bool CanonicalizePath(std::string* path, std::string* err);

#endif  // NINJA_UTIL_H_

Remove the declaration of DumpBacktrace.

This function was removed on 01880fb3a2a13f9071e9729c3a13752846828ed2.


//
//  UIKitCategory.h
//  WWCategory
//
//  Created by ww on 2016. 1. 10..
//  Copyright © 2016년 Won Woo Choi. All rights reserved.
//

#import "UIApplication+Keyboard.h"
#import "UIBezierPath+Drawing.h"
#import "UIColor+CreateColor.h"
#import "UIImage+CreateImage.h"
#import "UIImage+ImageProcessing.h"
#import "UIImageView+CreateImageView.h"
#import "UIScreen+Size.h"
#import "UIStoryboard+GetInstance.h"
#import "UITextField+Color.h"
#import "UIView+Capture.h"
#import "UIView+Rounding.h"

//
//  UIKitCategory.h
//  WWCategory
//
//  Created by ww on 2016. 1. 10..
//  Copyright © 2016년 Won Woo Choi. All rights reserved.
//

#import "UIApplication+Keyboard.h"
#import "UIApplication+TopmostViewController.h"
#import "UIBarButtonItem+Block.h"
#import "UIBezierPath+Drawing.h"
#import "UIButton+Align.h"
#import "UICollectionView+Register.h"
#import "UIColor+CreateColor.h"
#import "UIImage+CreateImage.h"
#import "UIImage+ImageProcessing.h"
#import "UIImageView+CreateImageView.h"
#import "UIScreen+Size.h"
#import "UIStoryboard+GetInstance.h"
#import "UITableView+Register.h"
#import "UITextField+Color.h"
#import "UIView+Capture.h"
#import "UIView+Rounding.h"
#import "UIViewController+Present.h"

Add category headers to global header.

Add category headers to global header.


/*
 * Copyright (C) 2015 Luke San Antonio
 * All rights reserved.
 */
#pragma once
#include "../common/id_map.hpp"
#include "boat.h"
#include "../collisionlib/motion.h"
namespace redc { namespace sail
{
  struct Player
  {
    std::string name;
    bool spawned;

    Hull_Desc boat_config;
    collis::Motion boat_motion;
  };

  struct Game
  {
    ID_Map<Player> players;
  };
} }

Add unified state of the game

Add unified state of the game


/**
 * \file inet_ntop
 * inet_ntop emulation based on inet_ntoa.
 * \author Matthias Andree
 *
 */
#include "config.h"
#ifndef HAVE_INET_NTOP
#include "leafnode.h"
#include "mastring.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>

#ifdef WITH_DMALLOC
#include <dmalloc.h>
#endif

#include <string.h>

const char *
inet_ntop(int af, const void *s, char *dst, int x)
{
    switch (af) {
    case AF_INET:
	mastrncpy(dst, inet_ntoa(*(const struct in_addr *)s), x);
	return dst;
	break;
    default:
	errno = EINVAL;
	return 0;
	break;
    }
}
#endif

/**
 * \file inet_ntop
 * inet_ntop emulation based on inet_ntoa.
 * \author Matthias Andree
 *
 */
#include "config.h"
#if !HAVE_INET_NTOP
#include "leafnode.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>

#include <string.h>

const char *
inet_ntop(int af, const void *s, char *dst, int x)
{
    switch (af) {
    case AF_INET:
	strncpy(dst, inet_ntoa(*(const struct in_addr *)s), x);
	if (x) dst[x-1] = '\0';
	return dst;
	break;
    default:
	errno = EINVAL;
	return 0;
	break;
    }
}
#endif

Drop dmalloc.h, not needed. Drop dmalloc.h, not needed. Use strncpy for portability, we do not want this function to rely on mastring.