#include "filters_api.h"

static PF_FILTER_RESULT demo_filter_keyboard_event(connectionInfo* info, void* param)
{
	proxyKeyboardEventInfo* event_data = (proxyKeyboardEventInfo*) param;
	return FILTER_PASS;
}

static PF_FILTER_RESULT demo_filter_mouse_event(connectionInfo* info, void* param)
{
	proxyMouseEventInfo* event_data = (proxyMouseEventInfo*) param;

    if (event_data->x % 100 == 0)
    {
        return FILTER_DROP;
    }

	return FILTER_PASS;
}

bool filter_init(proxyEvents* events)
{
	events->KeyboardEvent = demo_filter_keyboard_event;
	events->MouseEvent = demo_filter_mouse_event;
}

#include "filters_api.h"

static PF_FILTER_RESULT demo_filter_keyboard_event(connectionInfo* info, void* param)
{
	proxyKeyboardEventInfo* event_data = (proxyKeyboardEventInfo*) param;
	return FILTER_PASS;
}

static PF_FILTER_RESULT demo_filter_mouse_event(connectionInfo* info, void* param)
{
	proxyMouseEventInfo* event_data = (proxyMouseEventInfo*) param;

    if (event_data->x % 100 == 0)
    {
        return FILTER_DROP;
    }

	return FILTER_PASS;
}

bool filter_init(proxyEvents* events)
{
	events->KeyboardEvent = demo_filter_keyboard_event;
	events->MouseEvent = demo_filter_mouse_event;

	return true;
}

Add return statement in demo_filter.c

server/proxy: Add return statement in demo_filter.c


#import <Foundation/Foundation.h>

@class WKInterfaceController;
@class FakeInterfaceController;

@protocol TestableWKInterfaceController <NSObject>

- (void)awakeWithContext:(id)context;
- (void)willActivate;
- (void)didDeactivate;

@optional

- (void)pushControllerWithName:(NSString *)name context:(id)context;
- (void)presentControllerWithName:(NSString *)name context:(id)context;

@end

#import <Foundation/Foundation.h>

@class WKInterfaceController;
@class FakeInterfaceController;

@protocol TestableWKInterfaceController <NSObject>

- (void)awakeWithContext:(id)context;
- (void)willActivate;
- (void)didDeactivate;

@optional

- (NSArray *)sent_messages;
- (void)pushControllerWithName:(NSString *)name context:(id)context;
- (void)presentControllerWithName:(NSString *)name context:(id)context;

@end

Add sent_messages array to testable controller interface


#include <stdio.h>

main() {
    float fahr, celsius;
    float lower, upper, step;

    lower = 0;
    upper = 300;
    step = 20;

    celsius = lower;

    printf("%6s\t%3s\n", "celsius", "fahr");

    while (celsius <= upper) {
        fahr = celsius * (9.0/5.0) + 32.0;
        printf("%6.1f\t%3.0f\n", celsius, fahr);
        celsius = celsius + step;
    }
}

Add chapter 1 extra exercises

Add chapter 1 extra exercises


// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/vespalib/util/threadstackexecutorbase.h>

namespace proton {

class ExecutorThreadingServiceStats {
public:
    using Stats = vespalib::ThreadStackExecutorBase::Stats;

private:
    Stats _masterExecutorStats;
    Stats _indexExecutorStats;
    Stats _summaryExecutorStats;
    Stats _indexFieldInverterExecutorStats;
    Stats _indexFieldWriterExecutorStats;
    Stats _attributeFieldWriterExecutorStats;
public:
    ExecutorThreadingServiceStats(Stats masterExecutorStats,
                                  Stats indexExecutorStats,
                                  Stats summaryExecutorStats,
                                  Stats indexFieldInverterExecutorStats,
                                  Stats indexFieldWriterExecutorStats,
                                  Stats attributeFieldWriterExecutorStats);
    ~ExecutorThreadingServiceStats();

    const Stats &getMasterExecutorStats() const { return _masterExecutorStats; }
    const Stats &getIndexExecutorStats() const { return _indexExecutorStats; }
    const Stats &getSummaryExecutorStats() const { return _summaryExecutorStats; }
    const Stats &getIndexFieldInverterExecutorStats() const { return _indexFieldInverterExecutorStats; }
    const Stats &getIndexFieldWriterExecutorStats() const { return _indexFieldWriterExecutorStats; }
    const Stats &getAttributeFieldWriterExecutorStats() const { return _attributeFieldWriterExecutorStats; }
};

}

// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <cstddef>
#include <vespa/vespalib/util/executor_stats.h>

namespace proton {

/*
 * This class contains executor stats for the executors used by a
 * document db.
 */
class ExecutorThreadingServiceStats {
public:
    using Stats = vespalib::ExecutorStats;

private:
    Stats _masterExecutorStats;
    Stats _indexExecutorStats;
    Stats _summaryExecutorStats;
    Stats _indexFieldInverterExecutorStats;
    Stats _indexFieldWriterExecutorStats;
    Stats _attributeFieldWriterExecutorStats;
public:
    ExecutorThreadingServiceStats(Stats masterExecutorStats,
                                  Stats indexExecutorStats,
                                  Stats summaryExecutorStats,
                                  Stats indexFieldInverterExecutorStats,
                                  Stats indexFieldWriterExecutorStats,
                                  Stats attributeFieldWriterExecutorStats);
    ~ExecutorThreadingServiceStats();

    const Stats &getMasterExecutorStats() const { return _masterExecutorStats; }
    const Stats &getIndexExecutorStats() const { return _indexExecutorStats; }
    const Stats &getSummaryExecutorStats() const { return _summaryExecutorStats; }
    const Stats &getIndexFieldInverterExecutorStats() const { return _indexFieldInverterExecutorStats; }
    const Stats &getIndexFieldWriterExecutorStats() const { return _indexFieldWriterExecutorStats; }
    const Stats &getAttributeFieldWriterExecutorStats() const { return _attributeFieldWriterExecutorStats; }
};

}

Add class comment. Reduce indirections in using statement.


#include "test_parser.h"

void one_or_more_one(void **state) {
  grammar_t *grammar = grammar_init(
    non_terminal("One"),
    rule_init(
      "One",
      one_or_more(
        terminal("11")
      )
    ), 1
  );

  parse_t *result = parse("11", grammar);
  assert_non_null(result);

  assert_int_equal(result->length, 2);
  assert_int_equal(result->n_children, 1);
}

void one_or_more_many(void **state) {
  grammar_t *grammar = grammar_init(
    non_terminal("One"),
    rule_init(
      "One",
      one_or_more(
        terminal("11")
      )
    ), 1
  );

  parse_t *result = parse("1111111", grammar);
  assert_non_null(result);

  assert_int_equal(result->length, 6);
  assert_int_equal(result->n_children, 3);
}

void one_or_more_failure(void **state) {
  grammar_t *grammar = grammar_init(
    non_terminal("One"),
    rule_init(
      "One",
      one_or_more(
        terminal("11")
      )
    ), 1
  );

  parse_t *result = parse("1", grammar);
  assert_null(result);
}

#include "test_parser.h"

void one_or_more_one(void **state) {
  grammar_t *grammar = grammar_init(
    non_terminal("One"),
    rule_init(
      "One",
      one_or_more(
        terminal("11")
      )
    ), 1
  );

  parse_result_t *result = parse("11", grammar);
  assert_non_null(result);
  assert_true(is_success(result));

  parse_t *suc = result->data.result;
  assert_int_equal(suc->length, 2);
  assert_int_equal(suc->n_children, 1);
}

void one_or_more_many(void **state) {
  grammar_t *grammar = grammar_init(
    non_terminal("One"),
    rule_init(
      "One",
      one_or_more(
        terminal("11")
      )
    ), 1
  );

  parse_result_t *result = parse("1111111", grammar);
  assert_non_null(result);
  assert_true(is_success(result));

  parse_t *suc = result->data.result;
  assert_int_equal(suc->length, 6);
  assert_int_equal(suc->n_children, 3);
}

void one_or_more_failure(void **state) {
  grammar_t *grammar = grammar_init(
    non_terminal("One"),
    rule_init(
      "One",
      one_or_more(
        terminal("11")
      )
    ), 1
  );

  parse_result_t *result = parse("1", grammar);
  assert_non_null(result);
  assert_true(is_error(result));
}

Use new API on one or more tests

Use new API on one or more tests


#include <stdio.h>
#include "jpeglib.h"
#include <setjmp.h>

struct error_mgr2 {
  struct jpeg_error_mgr pub;	/* "public" fields */

  jmp_buf setjmp_buffer;	/* for return to caller */
};

typedef struct error_mgr2 * error_ptr2;

/*
 * Here's the routine that will replace the standard error_exit method:
 */

void error_exit (j_common_ptr cinfo)
{
  /* cinfo->err really points to a error_mgr2 struct, so coerce pointer */
  error_ptr2 myerr = (error_ptr2) cinfo->err;

  /* Return control to the setjmp point */
  longjmp(myerr->setjmp_buffer, 1);
}

Remove nasty character at end of file that prevents compiles

git-svn-id: f18ccec24f938f15aa42574278fe0cc52f637e81@72 fa1542d4-bde8-0310-ad64-8ed1123d492a


#pragma once

#ifdef bool
#undef bool
#endif

typedef char bool;
#define true 1
#define false 0

typedef struct carp_thread* carp_thread_t;
typedef void(*carp_thread_routine)(void* arg);

typedef struct carp_library* carp_library_t;

/* Init/shutdown */

void carp_platform_init();

void carp_platform_shutdown();

/* --- Threads --- */

carp_thread_t carp_thread_create(carp_thread_routine thread_routine, void* arg);

void carp_thread_destroy(carp_thread_t thread);

/* --- Timing --- */

int carp_millitime();

/* --- Libraries --- */

carp_library_t carp_load_library(const char* name);

int carp_unload_library(carp_library_t lib);

void* carp_find_symbol(carp_library_t lib, const char * name);

char* carp_get_load_library_error();

/* -- misc -- */

void carp_sleep(int millis);

typedef enum CARP_PLATFORM {
	CARP_PLATFORM_OSX = 0,
	CARP_PLATFORM_WINDOWS = 1,
	CARP_PLATFORM_LINUX = 2,
	CARP_PLATFORM_UNKNOWN = 100
} CARP_PLATFORM;

CARP_PLATFORM carp_get_platform();

typedef struct {
  int count;
  void *data;
} Array;

#pragma once

#ifdef bool
#undef bool
#endif

typedef int bool;
#define true 1
#define false 0

typedef struct carp_thread* carp_thread_t;
typedef void(*carp_thread_routine)(void* arg);

typedef struct carp_library* carp_library_t;

/* Init/shutdown */

void carp_platform_init();

void carp_platform_shutdown();

/* --- Threads --- */

carp_thread_t carp_thread_create(carp_thread_routine thread_routine, void* arg);

void carp_thread_destroy(carp_thread_t thread);

/* --- Timing --- */

int carp_millitime();

/* --- Libraries --- */

carp_library_t carp_load_library(const char* name);

int carp_unload_library(carp_library_t lib);

void* carp_find_symbol(carp_library_t lib, const char * name);

char* carp_get_load_library_error();

/* -- misc -- */

void carp_sleep(int millis);

typedef enum CARP_PLATFORM {
	CARP_PLATFORM_OSX = 0,
	CARP_PLATFORM_WINDOWS = 1,
	CARP_PLATFORM_LINUX = 2,
	CARP_PLATFORM_UNKNOWN = 100
} CARP_PLATFORM;

CARP_PLATFORM carp_get_platform();

typedef struct {
  int count;
  void *data;
} Array;

Change size of bool to 4

Change size of bool to 4


//Copyright (c) 2020 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef FMATRIX3X3_H
#define FMATRIX3X3_H

namespace cura
{

class Point3;
class FPoint3;

class FMatrix3x3
{
public:
    double m[3][3];

    FMatrix3x3();

    Point3 apply(const FPoint3& p) const;
};

} //namespace cura
#endif //FMATRIX3X3_H

//Copyright (c) 2020 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.

#ifndef FMATRIX3X3_H
#define FMATRIX3X3_H

namespace cura
{

class Point3;
class FPoint3;

/*!
 * A 3x3 linear transformation matrix.
 */
class FMatrix3x3
{
public:
	/*!
	 * The matrix data, row-endian.
	 *
	 * The first index is the column. The second index is the row.
	 */
    double m[3][3];

	/*!
	 * Construct an identity matrix.
	 */
    FMatrix3x3();

	/*!
	 * Apply this transformation to a coordinate.
	 *
	 * The result will also be converted to an integer-based coordinate
	 * (``Point3``).
	 * \param p The coordinate to transform.
	 * \return A transformed coordinate.
	 */
    Point3 apply(const FPoint3& p) const;
};

} //namespace cura
#endif //FMATRIX3X3_H

Document the transformation matrix class

Brief, but just the gist of what people need to know to use this class.

Contributes to issue CURA-7118.


#ifndef TEST_LINEAR_HASH_H_
#define TEST_LINEAR_HASH_H_

#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "../../../planckunit/src/planck_unit.h"
#include "../../../../dictionary/linear_hash/linear_hash.h"

#ifdef  __cplusplus
extern "C" {
#endif

void
runalltests_linear_hash();

#ifdef  __cplusplus
}
#endif

#endif

#ifndef TEST_LINEAR_HASH_H_
#define TEST_LINEAR_HASH_H_

#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include "../../../planckunit/src/planck_unit.h"
#include "../../../../dictionary/linear_hash/linear_hash.h"

#ifdef  __cplusplus
extern "C" {
#endif

void
runalltests_linear_hash();

#ifdef  __cplusplus
}
#endif

#endif

Add include for math.h to lin hash

Add include for math.h to lin hash


// RUN: clang-cc -emit-llvm %s -o -
typedef short __v4hi __attribute__ ((__vector_size__ (8)));

void f()
{
    __v4hi A = (__v4hi)0LL;
}

__v4hi x = {1,2,3};
__v4hi y = {1,2,3,4};

typedef int x __attribute((vector_size(16)));
int a() { x b; return b[2LL]; }

// RUN: clang-cc -emit-llvm %s -o -
typedef short __v4hi __attribute__ ((__vector_size__ (8)));

void f()
{
    __v4hi A = (__v4hi)0LL;
}

__v4hi x = {1,2,3};
__v4hi y = {1,2,3,4};

typedef int vty __attribute((vector_size(16)));
int a() { vty b; return b[2LL]; }

Fix silly mistake in test.

Fix silly mistake in test.

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


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

#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <time.h>
#include "riak.h"

void
test_log(void            *ptr,
         riak_log_level_t level,
         const char      *file,
         riak_size_t      filelen,
         const char      *func,
         riak_size_t      funclen,
         riak_uint32_t    line,
         const char      *format,
         va_list          args) {
    time_t ltime;
    struct tm result;
    char stime[32];
    char output[2048];

    ltime = time(NULL);
    localtime_r(&ltime, &result);
    strftime(stime, sizeof(stime), "%F %X %Z", &result);
    riak_size_t wrote = snprintf(output, sizeof(output), "%s %s ", stime, riak_log_level_description(level));
    char *pos = output + wrote;
    wrote += vsnprintf(pos, sizeof(output)-wrote, format, args);
    if (wrote < sizeof(output)-1) {
        strcat(output, "\n");
    }
    // Just spew any output to stderr
    fprintf(stderr, "%s", output);
}

Add GET message integration test - Make unit testing write fuller test objects - Make the number of buckets/keys in dummy object configurable - Add several helper functions like comparing binaries and objects - Improve error reporting in testing async callbacks


#import <Foundation/Foundation.h>
#import <GHUnit/GHUnit.h>
//#import <SenTestingKit/SenTestingKit.h>

#define COCOAGIT_REPO @"."
#define TEST_RESOURCES_PATH @"../../UnitTests/Resources/"

#define DOT_GIT TEST_RESOURCES_PATH @"dot_git/"
#define DELTA_REF_PACK TEST_RESOURCES_PATH @"packs/cg-0.2.5-deltaref-be5a15ac583f7ed1e431f03bd444bbde6511e57c.pack"
#define DELTA_OFS_PACK TEST_RESOURCES_PATH @"packs/cg-0.2.5-deltaofs-be5a15ac583f7ed1e431f03bd444bbde6511e57c.pack"

@interface GITTestHelper : NSObject
{}
+ (NSString *) createTempRepoWithDotGitDir:(NSString *)clonePath;
+ (BOOL) removeTempRepoAtPath:(NSString *)aPath;
+ (NSDictionary *)packedObjectInfo;
@end

#import <Foundation/Foundation.h>
#import <GHUnit/GHUnit.h>
//#import <SenTestingKit/SenTestingKit.h>

#define COCOAGIT_REPO @"."
#define TEST_RESOURCES_PATH @"../../UnitTests/Resources/"
#define TEST_FIXTURES_PATH TEST_RESOURCES_PATH @"fixtures/"

#define DOT_GIT TEST_RESOURCES_PATH @"dot_git/"
#define DELTA_REF_PACK TEST_RESOURCES_PATH @"packs/cg-0.2.5-deltaref-be5a15ac583f7ed1e431f03bd444bbde6511e57c.pack"
#define DELTA_OFS_PACK TEST_RESOURCES_PATH @"packs/cg-0.2.5-deltaofs-be5a15ac583f7ed1e431f03bd444bbde6511e57c.pack"

@interface GITTestHelper : NSObject
{}
+ (NSString *) createTempRepoWithDotGitDir:(NSString *)clonePath;
+ (BOOL) removeTempRepoAtPath:(NSString *)aPath;
+ (NSDictionary *)packedObjectInfo;
@end

Add 'fixtures' path definition to test helper.


/**
 * "Aim lights" light script
 *
 * Turn on all the lights for 30 seconds so they can be aimed
 */

// Copied from todbot
// format of light script lines: duration, command, arg1,arg2,arg3
typedef struct _blinkm_script_line {
  uint8_t dur;
  uint8_t cmd[4];    // cmd,arg1,arg2,arg3
} blinkm_script_line;

// start dark, lighten to mid-day, then slowly fade away
blinkm_script_line script_lines[] = {
 {  1,  {'f', 1,00,00}},        // fade speed (slow)
 {  1,  {'t', 1,0,0}},          // time adjust (slower)
 { 300, {'c', 0xff,0xff,0xff}},  // stay bright for mid-day
 { 100, {'c', 0x00,0x00,0x00}},  // fade to black
};

Set one LED group on for light aiming

Set one LED group on for light aiming


/** @file
  Define the variable data structures used for physical presence storage data.

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

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

**/

#ifndef __TCG_PHYSICAL_PRESENCE_STORAGE_DATA_GUID_H__
#define __TCG_PHYSICAL_PRESENCE_STORAGE_DATA_GUID_H__

#define EFI_TCG_PHYSICAL_PRESENCE_STORAGE_DATA_GUID \
  { \
    0x2EBE3E34, 0xB3CD, 0x471A, { 0xBF, 0x87, 0xB3, 0xC6, 0x6E, 0xE0, 0x74, 0x9A} \
  }

//
// This variable is used to save TCG2 Management Flags and corresponding operations.
// It should be protected from malicious software (e.g. Set it as read-only variable).
//
#define TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS_VARIABLE  L"TcgPhysicalPresenceStorageFlags"
typedef struct {
  UINT32  PPFlags;
} EFI_TCG_PHYSICAL_PRESENCE_STORAGE_FLAGS;

extern EFI_GUID  gEfiTcgPhysicalPresenceStorageGuid;

#endif

SecurityPkg: Add definition for Physical Presence storage flag.

Reviewed-by: Jiewen Yao <364a90bfebd1f362ebb7b48e4bf8ec010adef203@intel.com>
Reviewed-by: Chao Zhang <fed49a7a524fbe970930fd44cd2de5a9d4952d81@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <fa9eeec52367040ac98013bc4b2913db170588f8@intel.com>


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

char* find(char *haystack, char needle);

int main(){
	char input[401]={'\0'}, symbol, *result;

	fgets(input, 401, stdin);
	symbol=getchar();

	result=find(input, symbol);

	if(result!=NULL){
	printf("%ld", result - input);
	}
	else{
		printf("-1");
	}

	return 0;

}

char* find(char *haystack, char needle){
	int i;
	char *result=NULL;
	for(i=0; i<400 && haystack[i]!='\0'; i++){
		if(haystack[i]==needle){
	 		result=&haystack[i];
 			break;
 	}
	}
	return result;

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

char* find(char *haystack, char needle);

int main(){
	char input[401]={'\0'}, symbol, *result;

	fgets(input, 401, stdin);
	symbol=getchar();

	result=find(input, symbol);

	if(result!=NULL){
	printf("%d", (int)(result - input));
	}
	else{
		printf("-1");
	}

	return 0;

}

char* find(char *haystack, char needle){
	int i;
	char *result=NULL;
	for(i=0; i<400 && haystack[i]!='\0'; i++){
		if(haystack[i]==needle){
	 		result=&haystack[i];
 			break;
 	}
	}
	return result;
}

Add closing bracket to open function in task 02 homework 02


/*
 * example2.c
 *
 *  Created on: 3 May 2016
 *      Author: nick
 */

#include "ndm.h"
#include <mpi.h>
#include <stdio.h>

void recvFunction(void*, NDM_Metadata);

int main(int argc, char* argv[]) {
  int provided;
  MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
  ndmInit();

  char uuid[10];
  int data = 10;
  ndmReduce(&data, 1, NDM_INT, NDM_SUM, recvFunction, 0, NDM_GLOBAL_GROUP, "a");
  ndmGroupRank(NDM_GLOBAL_GROUP, &data);
  ndmAllReduce(&data, 1, NDM_INT, NDM_MAX, recvFunction, NDM_GLOBAL_GROUP, "maxrank");
  ndmFinalise();
  MPI_Finalize();
  return 0;
}

void recvFunction(void* buffer, NDM_Metadata metaData) {
  printf("Got reduction data '%d' with uuid %s on pid %d\n", *((int*)buffer), metaData.unique_id, metaData.my_rank);
}

/*
 * example2.c
 *
 *  Created on: 3 May 2016
 *      Author: nick
 */

#include "ndm.h"
#include <mpi.h>
#include <stdio.h>

void recvFunction(void*, NDM_Metadata);
void additiveRecvFunction(void*, NDM_Metadata);

int main(int argc, char* argv[]) {
  int provided;
  MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
  ndmInit();

  char uuid[10];
  int data = 10;
  ndmReduce(&data, 1, NDM_INT, NDM_SUM, recvFunction, 0, NDM_GLOBAL_GROUP, "a");
  ndmGroupRank(NDM_GLOBAL_GROUP, &data);
  ndmAllReduce(&data, 1, NDM_INT, NDM_MAX, recvFunction, NDM_GLOBAL_GROUP, "maxrank");
  data = 5;
  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
  ndmReduceAdditive(&data, 1, NDM_INT, 12, 1, 0, NDM_SUM, additiveRecvFunction, 0, NDM_GLOBAL_GROUP, "additive");
  ndmFinalise();
  MPI_Finalize();
  return 0;
}

void recvFunction(void* buffer, NDM_Metadata metaData) {
  printf("Got reduction data '%d' with uuid %s on pid %d\n", *((int*)buffer), metaData.unique_id, metaData.my_rank);
}

void additiveRecvFunction(void* buffer, NDM_Metadata metaData) { printf("Got additive data '%d'\n", *((int*)buffer)); }

Reduce example uses additive calls

Reduce example uses additive calls


#ifndef __JniHelpersCommon_h__
#define __JniHelpersCommon_h__

// Disable some annoying compiler warnings
#if WIN32
#pragma warning(disable: 4996) // "Security" warnings for vsnprintf
#endif

#if WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif

#include <jni.h>

#define kTypeInt "I"
#define kTypeLong "J"
#define kTypeFloat "F"
#define kTypeDouble "D"
#define kTypeBool "Z"
#define kTypeByte "B"
#define kTypeVoid "V"

// Common Java classes
#define kTypeJavaClass(x) "Ljava/lang/" #x ";"
#define kTypeJavaException "L/java/lang/Exception"
#define kTypeJavaString "Ljava/lang/String"

// Array builder macro
#define kTypeArray(x) "[" x

#endif // __JniHelpersCommon_h__

#ifndef __JniHelpersCommon_h__
#define __JniHelpersCommon_h__

// Disable some annoying compiler warnings
#if WIN32
#pragma warning(disable: 4996) // "Security" warnings for vsnprintf
#endif

#if WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif

#include <jni.h>

#define kTypeInt "I"
#define kTypeLong "J"
#define kTypeFloat "F"
#define kTypeDouble "D"
#define kTypeBool "Z"
#define kTypeByte "B"
#define kTypeVoid "V"

// Common Java classes
#define kTypeJavaClass(x) "Ljava/lang/" #x ";"
#define kTypeJavaException "Ljava/lang/Exception;"
#define kTypeJavaString "Ljava/lang/String;"

// Array builder macro
#define kTypeArray(x) "[" x

#endif // __JniHelpersCommon_h__

Fix type signatures for some java bulit-ins


/*
 * conf_imu_rev4.h
 *
 * Created: 20/11/2013 22:21:49
 *  Author: sfx
 */

#ifndef CONF_IMU_REV4_H_
#define CONF_IMU_REV4_H_

#define RAW_GYRO_X 0
#define RAW_GYRO_Y 1
#define RAW_GYRO_Z 2

#define RAW_ACC_X 0
#define RAW_ACC_Y 1
#define RAW_ACC_Z 2

#define RAW_COMPASS_X 2
#define RAW_COMPASS_Y 0
#define RAW_COMPASS_Z 1

// from datasheet: FS 2000dps --> 70 mdps/digit
// scale = 1/(0.07 * PI / 180.0) = 818.5111
#define RAW_GYRO_X_SCALE  818.5111
#define RAW_GYRO_Y_SCALE  818.5111
#define RAW_GYRO_Z_SCALE  818.5111

#define GYRO_AXIS_X  1.0
#define GYRO_AXIS_Y -1.0
#define GYRO_AXIS_Z -1.0

#define RAW_ACC_X_SCALE  4033.35
#define RAW_ACC_Y_SCALE  3997.92
#define RAW_ACC_Z_SCALE  4081.49

#define ACC_BIAIS_X  -123.22
#define ACC_BIAIS_Y   143.87
#define ACC_BIAIS_Z   207.7505405

#define ACC_AXIS_X  1.0
#define ACC_AXIS_Y -1.0
#define ACC_AXIS_Z -1.0

#define RAW_MAG_X_SCALE 619.57
#define RAW_MAG_Y_SCALE 638.39
#define RAW_MAG_Z_SCALE 563.41

#define MAG_BIAIS_X   -121.169232
#define MAG_BIAIS_Y   -189.6727777
#define MAG_BIAIS_Z   -162.58148486

#define MAG_AXIS_X -1.0
#define MAG_AXIS_Y -1.0
#define MAG_AXIS_Z -1.0

#endif /* CONF_IMU_REV4_H_ */

Add calibration file for board J2 (MAV102)


/*
 * Permission to use, copy, modify, distribute, and sell this software
 * and its documentation for any purpose is hereby granted without
 * fee, provided that the above copyright notice appear in all copies
 * and that both that copyright notice and this permission notice
 * appear in supporting documentation, and that the name of Red Hat
 * not be used in advertising or publicity pertaining to distribution
 * of the software without specific, written prior permission.  Red
 * Hat makes no representations about the suitability of this software
 * for any purpose.  It is provided "as is" without express or implied
 * warranty.
 *
 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#ifndef	_SYNAPTICS_H_
#define _SYNAPTICS_H_

#include <X11/Xdefs.h>

/******************************************************************************
 *		Public definitions.
 *			Used by driver and the shared memory configurator
 *****************************************************************************/

#define SHM_SYNAPTICS 23947
typedef struct _SynapticsSHM {
    int version;                /* Driver version */

    /* Current device state */
    int x, y;                   /* actual x, y coordinates */
    int z;                      /* pressure value */
    int numFingers;             /* number of fingers */
    int fingerWidth;            /* finger width value */
    int left, right, up, down;  /* left/right/up/down buttons */
    Bool multi[8];
    Bool middle;
} SynapticsSHM;

/*
 * Minimum and maximum values for scroll_button_repeat
 */
#define SBR_MIN 10
#define SBR_MAX 1000

#endif                          /* _SYNAPTICS_H_ */

Put SynapticsSHM back into the driver to be able to use synclient -m once again


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

void abertura() {
  printf("*******************\n");
  printf("*  Jogo de Forca  *\n");
  printf("*******************\n\n");
}

int main() {
  char palavrasecreta[20];

  sprintf(palavrasecreta, "MELANCIA");

  int acertou = 0;
  int enforcou = 0;

  char chutes[26];
  int tentativas = 0;

  abertura();

  do {

    for(int i = 0; i < strlen(palavrasecreta); i++) {

      int achou = 0;

      for(int j = 0; j < tentativas; j++) {
        if(chutes[j] == palavrasecreta[i]) {
          achou = 1;
          break;
        }
      }

      if(achou) {
        printf("%c ", palavrasecreta[i]);
      } else {
        printf("_ ");
      }
    }

    printf("\n");

    char chute;
    printf("Qual letra? ");
    scanf(" %c", &chute);

    chutes[tentativas] = chute;
    tentativas++;

  } while(!acertou && !enforcou);

}

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

void abertura() {
  printf("*******************\n");
  printf("*  Jogo de Forca  *\n");
  printf("*******************\n\n");
}

void chuta() {
  char chute;
  printf("Qual letra? ");
  scanf(" %c", &chute);

  chutes[tentativas] = chute;
  tentativas++;
}

int main() {
  char palavrasecreta[20];

  sprintf(palavrasecreta, "MELANCIA");

  int acertou = 0;
  int enforcou = 0;

  char chutes[26];
  int tentativas = 0;

  abertura();

  do {

    // imprime a palavra secreta
    for(int i = 0; i < strlen(palavrasecreta); i++) {

      int achou = 0;

      // a letra ja foi chutada?
      for(int j = 0; j < tentativas; j++) {
        if(chutes[j] == palavrasecreta[i]) {
          achou = 1;
          break;
        }
      }

      if(achou) {
        printf("%c ", palavrasecreta[i]);
      } else {
        printf("_ ");
      }
    }

    printf("\n");

    chuta();

  } while(!acertou && !enforcou);

}

Update files, Alura, Introdução a C - Parte 2, Aula 4.2


#ifndef COMPAT_H
#define COMPAT_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifndef __dead
#define __dead
#endif

#ifndef HAVE_REALLOCARRAY

void	*reallocarray(void *, size_t, size_t);

#endif /* !HAVE_REALLOCARRAY */

#endif /* COMPAT_H */

#ifndef COMPAT_H
#define COMPAT_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifdef __FreeBSD__
#define __dead __dead2
#endif /* __FreeBSD__ */

#if defined(__linux__) || defined(__CYGWIN__)
#ifndef __dead
#ifdef __GNUC__
#define __dead		__attribute__((__noreturn__))
#else
#define __dead
#endif
#endif
#endif /* __linux__ || __CYGWIN__ */

#ifndef HAVE_REALLOCARRAY

void	*reallocarray(void *, size_t, size_t);

#endif /* !HAVE_REALLOCARRAY */

#endif /* COMPAT_H */

Revert "Only define __dead if it's missing"

This reverts commit 7f5694ac1cf3a68b462a9f22e03a12a719249ee5.

Partial fix to #202.


// RUN: %llvmgcc %s -S -o - | llvm-as | llvm-dis | grep llvm.annotation

int main() {
  int x = 0;
  return __builtin_annotation(x, "annotate");
}

Test case for annotate builtin.

Test case for annotate builtin.

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


// Copyright 2015 Smartling, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this work 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.

//
//  SmartlingLib.h
//  SmartlingLib
//
//  Created by Pavel Ivashkov on 2015-05-15.
//

#import <UIKit/UIKit.h>

//! Project version number for SmartlingLib.
FOUNDATION_EXPORT double SmartlingLibVersionNumber;

//! Project version string for SmartlingLib.
FOUNDATION_EXPORT const unsigned char SmartlingLibVersionString[];

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

#import <SmartlingLib/SLLocalization.h>

// Copyright 2015 Smartling, Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this work 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.

//
//  SmartlingLib.h
//  SmartlingLib
//
//  Created by Pavel Ivashkov on 2015-05-15.
//

#import <UIKit/UIKit.h>

//! Project version number for SmartlingLib.
FOUNDATION_EXPORT double SmartlingLibVersionNumber;

//! Project version string for SmartlingLib.
FOUNDATION_EXPORT const unsigned char SmartlingLibVersionString[];

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

#import "SLLocalization.h"

Fix import to be able to use Smartling.i18n as dynamic framework via cocoapods


// Spellable.h
#ifndef SPELLABLE_H
#define SPELLABLE_H

#include <string>

template <class T>
class Spellable {
	T* value;
public:
	Spellable() {};
	Spellable(T* value): value(value) {}
	Spellable(T v) { value = new T(v); }

	void SetValue(T* v) { value = v; }
	void SetValue(T v) { value = new T(v); }

	T GetValue() const { return *value; }

	std::string spell();

	// Let's do arithmetic!
	Spellable & operator=(const T &rhs) {
		SetValue(rhs);
	}

	Spellable & operator+=(const T &rhs) {
		*value += rhs;
		return *this;
	}

	bool operator==(const T &other) const {
		return *value == other;
	}

	bool operator==(const std::string &other) const {
		return spell() == other;
	}
};

// http://www.codeproject.com/Articles/48575/How-to-define-a-template-class-in-a-h-file-and-imp
// The linker gets confused if we don't include the implementation here.
#include "Spellable.cpp"

#endif // Spellable.h

// Spellable.h
#ifndef SPELLABLE_H
#define SPELLABLE_H

#include <string>

template <class T>
class Spellable {
	T* value;
public:
	// TODO: new values are never deleted!
	Spellable() { value = NULL; };
	Spellable(T* value): value(value) {}
	Spellable(T v) { value = new T(v); }

	void SetValue(T* v) { value = v; }
	void SetValue(T v) { value = new T(v); }

	T GetValue() const { return *value; }

	std::string spell();

	// Let's do arithmetic!
	Spellable & operator=(const T &rhs) {
		SetValue(rhs);
	}

	Spellable & operator+=(const T &rhs) {
    	*value += rhs;
		return *this;
	}

	bool operator==(const T &other) const {
		return *value == other;
	}

	bool operator==(const std::string &other) const {
		return spell() == other;
	}
protected:
	std::string spellFraction();
};

// http://www.codeproject.com/Articles/48575/How-to-define-a-template-class-in-a-h-file-and-imp
// The linker gets confused if we don't include the implementation here.
#include "Spellable.cpp"

#endif // Spellable.h

Handle precision of fractions better

Handle precision of fractions better


/**
* Win32 EntropySource Header File
* (C) 1999-2008 Jack Lloyd
*/

#ifndef BOTAN_ENTROPY_SRC_WIN32_H__
#define BOTAN_ENTROPY_SRC_WIN32_H__

#include <botan/entropy_src.h>

namespace Botan {

/**
* Win32 Entropy Source
*/
class BOTAN_DLL Win32_EntropySource : public EntropySource
   {
   public:
      std::string name() const { return "Win32 Statistics"; }
      void fast_poll(byte buf[], u32bit length);
      void slow_poll(byte buf[], u32bit length);
   };

}

#endif

/**
* Win32 EntropySource Header File
* (C) 1999-2008 Jack Lloyd
*/

#ifndef BOTAN_ENTROPY_SRC_WIN32_H__
#define BOTAN_ENTROPY_SRC_WIN32_H__

#include <botan/entropy_src.h>

namespace Botan {

/**
* Win32 Entropy Source
*/
class BOTAN_DLL Win32_EntropySource : public EntropySource
   {
   public:
      std::string name() const { return "Win32 Statistics"; }

      u32bit fast_poll(byte buf[], u32bit length);
      u32bit slow_poll(byte buf[], u32bit length);
   };

}

#endif

Fix return types in declaration

Fix return types in declaration


/*
Copyright (c) 2015, Intel Corporation
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
 */

// count trailing zeros with llvm semantics
int cgen_cttz_int(int n)
{
    if(n==0) return sizeof(int);
    return __builtin_ctz(n);
}

int cgen_flipsign_int(int64_t x, int64_t y)
{
    return (y >= 0 ? x : -x);
}

/*
Copyright (c) 2015, Intel Corporation
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
  this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
 */

// count trailing zeros with llvm semantics
int64_t cgen_cttz_int(int64_t n)
{
    if(n==0) return sizeof(int64_t);
    return __builtin_ctz(n);
}

int64_t cgen_flipsign_int(int64_t x, int64_t y)
{
    return (y >= 0 ? x : -x);
}

Use int64_t for cgen intrinsics

Use int64_t for cgen intrinsics


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>

off_t get_file_size(const char *filename) {
    struct stat buffer;
    return (stat(filename, &buffer)==0 ? buffer.st_size : -1);
}

int file_is_readable(char *filename) {
    if ( access(filename, R_OK) != -1 ) {
        return 1;
    } else {
        return 0;
    }
}

int main(int argc, char *argv[]) {
    clock_t t0, t1;

    if (argc <= 1) {
        printf("Usage: %s [arguments]\n", argv[0]);
         return EXIT_FAILURE;
    }

    t0 = clock();
    printf("Hello World!\n");
    if (file_is_readable(argv[1])) {
        printf("Input File = '%s'\n", argv[1]);
    } else {
        printf("Input File = '%s' (file does not exist or read permissions absent)\n", argv[1]);
    }
    t1 = clock();
    printf("Time elapsed = %f (ms)\n", (t1-t0)*1000/(double)CLOCKS_PER_SEC );
    return EXIT_SUCCESS;
}

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>

off_t get_file_size(const char *filename) {
    struct stat buffer;
    return (stat(filename, &buffer)==0 ? buffer.st_size : -1);
}

int file_is_readable(char *filename) {
    if ( access(filename, R_OK) != -1 ) {
        return 1;
    } else {
        return 0;
    }
}

int main(int argc, char *argv[]) {
    clock_t t0, t1;

    if (argc <= 1) {
        printf("Usage: %s [arguments]\n", argv[0]);
        return EXIT_FAILURE;
    }

    t0 = clock();
    printf("Hello World!\n");
    if (file_is_readable(argv[1])) {
        printf("Input File = '%s'\n", argv[1]);
        printf("File size is %lld\n", get_file_size(argv[1]));
    } else {
        printf("Input File = '%s' (file does not exist or read permissions absent)\n", argv[1]);
    }
    t1 = clock();
    printf("Time elapsed = %f (ms)\n", (t1-t0)*1000/(double)CLOCKS_PER_SEC );
    return EXIT_SUCCESS;
}

Add printing of file size

Add printing of file size


Fix a typo (thanks to Robert Hatcher)

Fix a typo (thanks to Robert Hatcher)

git-svn-id: ecbadac9c76e8cf640a0bca86f6bd796c98521e3@10919 27541ba8-7e3a-0410-8455-c3a389f83636


//
//  ServiceMBTA_sensitive.h
//  MBTA-APIs
//
//  Created by Steve Caine on 01/05/115.
//  Copyright (c) 2015 Steve Caine. All rights reserved.
//

// your private key to the MBTA-v2 API goes here

#define key_MBTA_v2_API	@""

// you should not commit any version of this file that contains the key
// to any source-control repository that will be made public or otherwise shared

//
//  ServiceMBTA_sensitive.h
//  MBTA-APIs
//
//  Created by Steve Caine on 01/05/15.
//  Copyright (c) 2015 Steve Caine. All rights reserved.
//

// your private key to the MBTA-v2 API goes here

#define key_MBTA_v2_API	@""

// you should not commit any version of this file that contains the key
// to any source-control repository that will be made public or otherwise shared

Fix typo in created date.

Fix typo in created date.


#ifndef SHELL_H
#define SHELL_H

#include <stdbool.h>

#define report_error() fprintf(stderr, "[%s: %s():%d] %s\n", __FILE__, \
        	__FUNCTION__, \
        	__LINE__, \
        	strerror(errno));

#define sizeof_array(x) (sizeof(x) / sizeof(*x))

#define DEFAULT_PROMPT 	"$ "
#define DEFAULT_PATH 	"/bin:/usr/bin/:/sbin/:/usr/local/bin"
#define DEFAULT_HOME 	"/"

typedef struct command_t{
    	char **array;
    	unsigned int elements;
}command_t;

typedef struct shell_t{
	bool running;
	struct environ_t *env;
	pid_t shell_pid;
	char *pwd;
}shell_t;

char *copy_string(const char *str);
unsigned int count_token(char *string, const char *token_string);
void free_command(command_t *command);
command_t *parse(char *line);
int change_shell_dir(char *path);
int execute_builtins(char **input);
int execute_command(command_t *c);

#endif

#ifndef SHELL_H
#define SHELL_H

#include <stdbool.h>

#define report_error() fprintf(stderr, "[%s: %s():%d] %s\n", __FILE__, \
        	__FUNCTION__, \
        	__LINE__, \
        	strerror(errno));

#define sizeof_array(x) (sizeof(x) / sizeof(*x))

typedef struct command_t{
    	char **array;
    	unsigned int elements;
}command_t;

typedef struct shell_t{
	bool running;
	struct environ_t *env;
	pid_t shell_pid;
	char *pwd;
}shell_t;

char *copy_string(const char *str);
unsigned int count_token(char *string, const char *token_string);
void free_command(command_t *command);
command_t *parse(char *line);
int change_shell_dir(char *path);
int execute_builtins(char **input);
int execute_command(command_t *c);

#endif

Remove double definition of default env variables


// Copyright 2016, Jeffrey E. Bedard
#include "temperature.h"
#include "config.h"
#include "font.h"
#include "util.h"
#include <stdio.h>
uint8_t get_temp(void)
{
	return xstatus_system_value(XSTATUS_SYSFILE_TEMPERATURE) / 1000;
}
// Returns x offset for next item
uint16_t draw_temp(xcb_connection_t * xc, const uint16_t offset)
{
	uint8_t sz = 4;
	const struct JBDim f = xstatus_get_font_size();
	const int16_t x = offset + XSTATUS_CONST_PAD;
	{ // buf scope
		char buf[sz];
		sz = snprintf(buf, sz, "%dC", get_temp());
		xcb_image_text_8(xc, sz, xstatus_get_window(xc),
			xstatus_get_gc(xc), x, f.h, buf);
	}
	return x + f.w * sz + XSTATUS_CONST_PAD;
}

// Copyright 2016, Jeffrey E. Bedard
#include "temperature.h"
#include "config.h"
#include "font.h"
#include "util.h"
#include <stdio.h>
static uint8_t get_temp(void)
{
	return xstatus_system_value(XSTATUS_SYSFILE_TEMPERATURE) / 1000;
}
static uint8_t format(char * restrict buf, const uint8_t sz)
{
	return snprintf(buf, sz, "%dC", get_temp());
}
// Returns x offset for next item
uint16_t draw_temp(xcb_connection_t * xc, const uint16_t offset)
{
	uint8_t sz = 4;
	const struct JBDim f = xstatus_get_font_size();
	const int16_t x = offset + XSTATUS_CONST_PAD;
	{ // buf scope
		char buf[sz];
		sz = format(buf, sz);
		xcb_image_text_8(xc, sz, xstatus_get_window(xc),
			xstatus_get_gc(xc), x, f.h, buf);
	}
	return x + f.w * sz + XSTATUS_CONST_PAD;
}

Make get_temp() static. Split out format().


// RUN: %ocheck 1 '-DNULL=(void *)0'
// RUN: %ocheck 0 '-DNULL=0'

int null_is_ptr_type()
{
	char s[1][1+(int)NULL];
	int i = 0;
	sizeof s[i++];
	return i;
}

main()
{
	return null_is_ptr_type();
}

// RUN: %ocheck 1 %s '-DNULL=(void *)0'
// RUN: %ocheck 0 %s '-DNULL=0'

int null_is_ptr_type()
{
	char s[1][1+(int)NULL];
	int i = 0;
	sizeof s[i++];
	return i;
}

main()
{
	return null_is_ptr_type();
}

Fix standard-nonconst vla test commands

Fix standard-nonconst vla test commands


#pragma once

#include "jwtxx/jwt.h"

#include <string>

namespace JWTXX
{

struct Key::Impl
{
    virtual ~Impl() {}
    virtual std::string sign(const void* data, size_t size) const = 0;
    virtual bool verify(const void* data, size_t size, const std::string& signature) const = 0;
};

}

#pragma once

#include "jwtxx/jwt.h"

#include <string>

namespace JWTXX
{

struct Key::Impl
{
    // Need this for polymorphic behavior.
    virtual ~Impl() = default;
    // Need this due to the Rule of Five.
    Impl() = default;
    Impl(const Impl&) = delete;
    Impl& operator=(const Impl&) = delete;
    Impl(Impl&&) = default;
    Impl& operator=(Impl&&) = default;

    virtual std::string sign(const void* data, size_t size) const = 0;
    virtual bool verify(const void* data, size_t size, const std::string& signature) const = 0;
};

}

Enable move and disable copy for key implementations.


//
//  ProfileViewController.h
//  PlayPlan
//
//  Created by Zeacone on 15/11/8.
//  Copyright © 2015年 Zeacone. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "PlayPlan.h"

@interface ProfileViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

@end

//
//  ProfileViewController.h
//  PlayPlan
//
//  Created by Zeacone on 15/11/8.
//  Copyright © 2015年 Zeacone. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "PlayPlan.h"

@class ProfileViewController;

@protocol MainDelegate <NSObject>

- (void)dismissViewController:(MainViewController *)mainViewController;

@end

@interface ProfileViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

@end

Add delegate for profile view controller.


// RUN: %check -e %s

#define always_inline __attribute((always_inline))

always_inline hidden(int);

void always_inline __attribute((noinline)) noinline(void)
{
}

always_inline void print(const char *fmt, ...)
{
}

always_inline void old(a, b)
	int a, b;
{
}

always_inline void addr(int x)
{
	int *p = &x;
	*p = 3;
}

always_inline void write(int x)
{
	x++;
}

always_inline void rec(int depth)
{
	if(depth < 5)
		rec(depth + 1); // CHECK: can't always_inline function: can't see function
}

always_inline int should_inline()
{
	return 3;
}

main()
{
	should_inline(); // CHECK: !/warn|error/

	rec(0); // CHECK: !/warn|error/

	hidden(3); // CHECK: error: can't always_inline function: can't see function
	noinline(); // CHECK: error: can't always_inline noinline function
	print("hi", 3); // CHECK: error: can't always_inline function: variadic function
	print("hi"); // CHECK: error: can't always_inline function: variadic function
	old(3, 1); // CHECK: error: can't always_inline function: unspecified argument count function
	addr(5); // CHECK: error: can't always_inline function: argument written or addressed
	write(2); // CHECK: error: can't always_inline function: argument written or addressed
}

Test inability to inline certain functions


/** @file
  Provides a secure platform-specific method to detect physically present user.

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

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

**/

/**

  This function provides a platform-specific method to detect whether the platform
  is operating by a physically present user.

  Programmatic changing of platform security policy (such as disable Secure Boot,
  or switch between Standard/Custom Secure Boot mode) MUST NOT be possible during
  Boot Services or after exiting EFI Boot Services. Only a physically present user
  is allowed to perform these operations.

  NOTE THAT: This function cannot depend on any EFI Variable Service since they are
  not available when this function is called in AuthenticateVariable driver.

  @retval  TRUE       The platform is operated by a physically present user.
  @retval  FALSE      The platform is NOT operated by a physically present user.

**/
BOOLEAN
EFIAPI
UserPhysicalPresent (
  VOID
  )
{
  return FALSE;
}

/** @file
  Provides a secure platform-specific method to detect physically present user.

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

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

**/

/**

  This function provides a platform-specific method to detect whether the platform
  is operating by a physically present user.

  Programmatic changing of platform security policy (such as disable Secure Boot,
  or switch between Standard/Custom Secure Boot mode) MUST NOT be possible during
  Boot Services or after exiting EFI Boot Services. Only a physically present user
  is allowed to perform these operations.

  NOTE THAT: This function cannot depend on any EFI Variable Service since they are
  not available when this function is called in AuthenticateVariable driver.

  @retval  TRUE       The platform is operated by a physically present user.
  @retval  FALSE      The platform is NOT operated by a physically present user.

**/
BOOLEAN
EFIAPI
UserPhysicalPresent (
  VOID
  )
{
  return TRUE;
}

Update the default return value of UserPhysicalPresent to TRUE.

Signed-off-by: Fu, Siyuan <siyuan.fu@intel.com>
Reviewed-by: Dong, Guo <guo.dong@intel.com>

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


// RUN: %clang_cc1 -fsyntax-only -verify

// PR9137
void f0(int x) : {};
void f1(int x) try {};

// RUN: %clang_cc1 -fsyntax-only -verify %s

// PR9137
void f0(int x) : {}; // expected-error{{expected function body after function declarator}}
void f1(int x) try {}; // expected-error{{expected function body after function declarator}}

Fix test for previous commit

Fix test for previous commit

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


//
//  MFSideMenuShadow.h
//  MFSideMenuDemoSearchBar
//
//  Created by Michael Frederick on 5/13/13.
//  Copyright (c) 2013 Frederick Development. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface MFSideMenuShadow : NSObject

@property (nonatomic, assign) BOOL enabled;
@property (nonatomic, assign) CGFloat radius;
@property (nonatomic, assign) CGFloat opacity;
@property (nonatomic, strong) UIColor *color;
@property (nonatomic, weak) UIView *shadowedView;

+ (MFSideMenuShadow *)shadowWithView:(UIView *)shadowedView;
+ (MFSideMenuShadow *)shadowWithColor:(UIColor *)color radius:(CGFloat)radius opacity:(CGFloat)opacity;

- (void)draw;
- (void)shadowedViewWillRotate;
- (void)shadowedViewDidRotate;

@end

//
//  MFSideMenuShadow.h
//  MFSideMenuDemoSearchBar
//
//  Created by Michael Frederick on 5/13/13.
//  Copyright (c) 2013 Frederick Development. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface MFSideMenuShadow : NSObject

@property (nonatomic, assign) BOOL enabled;
@property (nonatomic, assign) CGFloat radius;
@property (nonatomic, assign) CGFloat opacity;
@property (nonatomic, strong) UIColor *color;
@property (nonatomic, assign) UIView *shadowedView;

+ (MFSideMenuShadow *)shadowWithView:(UIView *)shadowedView;
+ (MFSideMenuShadow *)shadowWithColor:(UIColor *)color radius:(CGFloat)radius opacity:(CGFloat)opacity;

- (void)draw;
- (void)shadowedViewWillRotate;
- (void)shadowedViewDidRotate;

@end

Change weak reference to assign for backwards compatibility


// RUN: llvm-gcc %s -S -o -
// PR854
  struct kernel_symbol {
    unsigned long value;
  };
  unsigned long loops_per_jiffy = (1<<12);
  static const char __kstrtab_loops_per_jiffy[]
__attribute__((section("__ksymtab_strings"))) = "loops_per_jiffy";
  static const struct kernel_symbol __ksymtab_loops_per_jiffy
__attribute__((__used__)) __attribute__((section("__ksymtab"))) = { (unsigned
long)&loops_per_jiffy, __kstrtab_loops_per_jiffy };

// RUN: %llvmgcc% %s -S -o -
// PR854
  struct kernel_symbol {
    unsigned long value;
  };
  unsigned long loops_per_jiffy = (1<<12);
  static const char __kstrtab_loops_per_jiffy[]
__attribute__((section("__ksymtab_strings"))) = "loops_per_jiffy";
  static const struct kernel_symbol __ksymtab_loops_per_jiffy
__attribute__((__used__)) __attribute__((section("__ksymtab"))) = { (unsigned
long)&loops_per_jiffy, __kstrtab_loops_per_jiffy };

Use the %llvm-gcc% variable to find llvm-gcc for those of us that don't
have it in our path and to ensure it uses the configured llvm-gcc not just
any one randomly placed in the path.

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


#define OBSCURE(X) X
#define DECORATION

typedef int T;
void OBSCURE(func)(int x) {
  OBSCURE(T) DECORATION value;
}

// RUN: c-index-test -cursor-at=%s:1:11 %s | FileCheck -check-prefix=CHECK-1 %s
// CHECK-1: macro definition=OBSCURE
// RUN: c-index-test -cursor-at=%s:2:14 %s | FileCheck -check-prefix=CHECK-2 %s
// CHECK-2: macro definition=DECORATION
// RUN: c-index-test -cursor-at=%s:5:7 %s | FileCheck -check-prefix=CHECK-3 %s
// CHECK-3: macro instantiation=OBSCURE:1:9
// RUN: c-index-test -cursor-at=%s:6:6 %s | FileCheck -check-prefix=CHECK-4 %s
// CHECK-4: macro instantiation=OBSCURE:1:9
// RUN: c-index-test -cursor-at=%s:6:19 %s | FileCheck -check-prefix=CHECK-5 %s
// CHECK-5: macro instantiation=DECORATION:2:9

#define OBSCURE(X) X
#define DECORATION

typedef int T;
void OBSCURE(func)(int x) {
  OBSCURE(T) DECORATION value;
}

#include "a.h"

// RUN: c-index-test -cursor-at=%s:1:11 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-1 %s
// CHECK-1: macro definition=OBSCURE
// RUN: c-index-test -cursor-at=%s:2:14 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-2 %s
// CHECK-2: macro definition=DECORATION
// RUN: c-index-test -cursor-at=%s:5:7 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-3 %s
// CHECK-3: macro instantiation=OBSCURE:1:9
// RUN: c-index-test -cursor-at=%s:6:6 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-4 %s
// CHECK-4: macro instantiation=OBSCURE:1:9
// RUN: c-index-test -cursor-at=%s:6:19 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-5 %s
// CHECK-5: macro instantiation=DECORATION:2:9
// RUN: c-index-test -cursor-at=%s:9:10 -I%S/Inputs %s | FileCheck -check-prefix=CHECK-6 %s
// CHECK-6: inclusion directive=a.h

Update clang_getCursor() test to check searches on include directives

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


#ifndef SUBDOC_PATH_H
#define SUBDOC_PATH_H

#include "subdoc-api.h"
#include "jsonsl_header.h"

#ifdef __cplusplus
extern "C" {
#endif

#define COMPONENTS_ALLOC 32
typedef struct subdoc_PATH_st {
    struct jsonsl_jpr_st jpr_base;
    struct jsonsl_jpr_component_st components_s[COMPONENTS_ALLOC];
    int has_negix; /* True if there is a negative array index in the path */
} subdoc_PATH;

struct subdoc_PATH_st *subdoc_path_alloc(void);
void subdoc_path_free(struct subdoc_PATH_st*);
void subdoc_path_clear(struct subdoc_PATH_st*);
int subdoc_path_parse(struct subdoc_PATH_st *nj, const char *path, size_t len);
jsonsl_error_t subdoc_path_add_arrindex(subdoc_PATH *pth, size_t ixnum);
#define subdoc_path_pop_component(pth) do { \
    (pth)->jpr_base.ncomponents--; \
} while (0);

#ifdef __cplusplus
}
#endif
#endif

#ifndef SUBDOC_PATH_H
#define SUBDOC_PATH_H

#include "subdoc-api.h"
#include "jsonsl_header.h"

#ifdef __cplusplus
extern "C" {
#endif

// Maximum number of components in a path. Set to 33 to allow 32 'actual'
// components plus the implicit root element.
#define COMPONENTS_ALLOC 33

typedef struct subdoc_PATH_st {
    struct jsonsl_jpr_st jpr_base;
    struct jsonsl_jpr_component_st components_s[COMPONENTS_ALLOC];
    int has_negix; /* True if there is a negative array index in the path */
} subdoc_PATH;

struct subdoc_PATH_st *subdoc_path_alloc(void);
void subdoc_path_free(struct subdoc_PATH_st*);
void subdoc_path_clear(struct subdoc_PATH_st*);
int subdoc_path_parse(struct subdoc_PATH_st *nj, const char *path, size_t len);
jsonsl_error_t subdoc_path_add_arrindex(subdoc_PATH *pth, size_t ixnum);
#define subdoc_path_pop_component(pth) do { \
    (pth)->jpr_base.ncomponents--; \
} while (0);

#ifdef __cplusplus
}
#endif
#endif

Allow access to documents of depth 32

Allow access to documents of depth 32


#ifndef __BITOPS_H__
#define __BITOPS_H__

#include <asm/bitops.h>
#include <types.h>

static inline int fls(int x)
{
        return WORD_BITS - __clz(x);
}

static inline int ffs(int x)
{
	/* mask the least significant bit only */
	return fls(x & -x);
}

static inline int log2(int x)
{
	if (!x)
		return INF;

	int sign = 1;

	if (x < 0) {
		sign = -sign;
		x = -x;
	}

	return (fls(x) - 1) * sign;
}

#endif /* __BITOPS_H__ */

#ifndef __BITOPS_H__
#define __BITOPS_H__

#include <asm/bitops.h>
#include <types.h>

static inline int fls(int x)
{
        return WORD_BITS - __clz(x);
}

static inline int ffs(int x)
{
	/* mask the least significant bit only */
	return fls(x & -x);
}

static inline int digits(const unsigned int n)
{
	assert(sizeof(n) == 4);

	const int tbl[] = {
		10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 5,
		5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1,
		0 };
	const unsigned int base[] = {
		0,
		10,
		100,
		1000,
		10000,
		100000,
		1000000,
		10000000,
		100000000,
		1000000000 };
	int digits = tbl[__clz(n)];

	if (base[digits] <= n)
		digits++;

	return digits;
}

static inline int log2(int x)
{
	if (!x)
		return INF;

	int sign = 1;

	if (x < 0) {
		sign = -sign;
		x = -x;
	}

	return (fls(x) - 1) * sign;
}

#endif /* __BITOPS_H__ */

Add digits() to count digits of `unsigned int` value


/* $FreeBSD$ */

/* XXX: Depend on our system headers protecting against multiple includes. */
#include <paths.h>
#undef _PATH_FTPUSERS

#include <pwd.h>

#define _DIAGASSERT(x)

#include <sys/_types.h>
#ifndef _SIZE_T_DECLARED
typedef	__size_t	size_t;
#define	_SIZE_T_DECLARED
#endif
long long strsuftollx(const char *, const char *,
    long long, long long, char *, size_t);

/*
 * IEEE Std 1003.1c-95, adopted in X/Open CAE Specification Issue 5 Version 2
 */
#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 500
#define	LOGIN_NAME_MAX	MAXLOGNAME	/* max login name length (incl. NUL) */
#endif

Deal with the LOGIN_NAME_MAX issue in the NetBSD->FreeBSD translation^H^H^Hhack layer.


#define T_INT 0
#define T_CHR 1
#define T_RTN 2

struct stack_node {
    struct stack_node *cdr;
    union node_data data;
    char type;
}

union node_data {
    struct routine routine;
    int numval;
}

struct routine {
    struct routine *parent;
    struct iq_node *nodes;
    int num_nodes;
}

struct iq_node {
    struct iq_node *next;
    union node_data instr;
    char type;
}

#define T_INT 0
#define T_CHR 1
#define T_RTN 2

struct stack_node {
    struct stack_node *cdr;
    union node_data data;
    char type;
}

union node_data {
    struct routine routine;
    int numval;
}

struct routine {
    struct routine *parent;
    struct iq_node *nodes;
}

struct iq_node {
    struct iq_node *next;
    union node_data instr;
    char type;
}

Remove unused node-counter in routines

Remove unused node-counter in routines


//
//  SEEngineProtocol.h
//  Pods
//
//  Created by Danil Tulin on 3/14/16.
//
//

#import <Foundation/Foundation.h>

@protocol EngineProtocol <NSObject>

- (void)feedBGRAImageData:(u_int8_t *)data
					width:(NSUInteger)width
				  heieght:(NSUInteger)height;

@property (nonatomic) CGFloat progress;

@end

//
//  SEEngineProtocol.h
//  Pods
//
//  Created by Danil Tulin on 3/14/16.
//
//

#import <Foundation/Foundation.h>

@protocol EngineProtocol <NSObject>

@required

- (void)feedBGRAImageData:(u_int8_t *)data
					width:(NSUInteger)width
				  heieght:(NSUInteger)height;

@property (nonatomic) float progress;

@end

Add required and CGFloat -> float

Add required and CGFloat -> float


/* for MAX_TXT_SEG_BYTES & MAX_TXT_SEG_LEN */
#include "txt-seg/config.h"
#define MAX_TERM_BYTES MAX_TXT_SEG_BYTES

/* consider both math & term */
#define MAX_QUERY_BYTES     (MAX_TXT_SEG_BYTES * 32)
#define MAX_QUERY_WSTR_LEN  (MAX_TXT_SEG_LEN * 32)

#define MAX_MERGE_POSTINGS 4096

#define SNIPPET_PADDING    80
#define MAX_SNIPPET_SZ     4096

//#define DEBUG_SNIPPET

//#define DEBUG_POST_MERGE

/* max mark score, type of mnc_score_t */
#define MNC_MARK_SCORE 99

/*
#define MNC_DEBUG
#define MNC_SMALL_BITMAP
*/

//#define DEBUG_MATH_EXPR_SEARCH

#define RANK_SET_DEFAULT_VOL 45
#define DEFAULT_RES_PER_PAGE 10

//#define DEBUG_PROXIMITY
#define ENABLE_PROXIMITY_SCORE

#define MAX_HIGHLIGHT_OCCURS 8
//#define DEBUG_HILIGHT_SEG_OFFSET
//#define DEBUG_HILIGHT_SEG

//#define DEBUG_MATH_SCORE_POSTING
//#define VERBOSE_SEARCH

//#define DEBUG_MATH_SEARCH

//#define DEBUG_PRINT_TARGET_DOC_MATH_SCORE

/* for MAX_TXT_SEG_BYTES & MAX_TXT_SEG_LEN */
#include "txt-seg/config.h"
#define MAX_TERM_BYTES MAX_TXT_SEG_BYTES

/* consider both math & term */
#define MAX_QUERY_BYTES     (MAX_TXT_SEG_BYTES * 32)
#define MAX_QUERY_WSTR_LEN  (MAX_TXT_SEG_LEN * 32)

#define MAX_MERGE_POSTINGS 4096

#define SNIPPET_PADDING    320
#define MAX_SNIPPET_SZ     8192

//#define DEBUG_SNIPPET

//#define DEBUG_POST_MERGE

/* max mark score, type of mnc_score_t */
#define MNC_MARK_SCORE 99

/*
#define MNC_DEBUG
#define MNC_SMALL_BITMAP
*/

//#define DEBUG_MATH_EXPR_SEARCH

#define RANK_SET_DEFAULT_VOL 155
#define DEFAULT_RES_PER_PAGE 10

//#define DEBUG_PROXIMITY
#define ENABLE_PROXIMITY_SCORE

#define MAX_HIGHLIGHT_OCCURS 8
//#define DEBUG_HILIGHT_SEG_OFFSET
//#define DEBUG_HILIGHT_SEG

//#define DEBUG_MATH_SCORE_POSTING
//#define VERBOSE_SEARCH

//#define DEBUG_MATH_SEARCH

//#define DEBUG_PRINT_TARGET_DOC_MATH_SCORE

Enlarge snippet size and rank volumn.

Enlarge snippet size and rank volumn.


// JPet User - JPetUser.h
#ifndef JPET_USER_H
#define JPET_USER_H

#include "TNamed.h"

class JPetUser: public TNamed
{
protected:
  int m_id;
  std::string m_name;
  std::string m_lastName;
  std::string m_login;
  std::string m_password;
  bool m_isRoot;
  std::string m_creationDate;
  std::string m_lastLoginDate;

  static bool m_isUserLogged;
  inline void toggleUserLoggedStatus()
  {
    m_isUserLogged = (m_isUserLogged == true) ? false : true;
  }
  virtual std::string password(void) const;

public:
  JPetUser(int p_id, std::string p_name, std::string p_lastName, std::string p_login, std::string p_password, bool p_isRoot);
  virtual ~JPetUser(void);

  static bool isUserLogged(void);
  virtual bool logIn(void);
  virtual bool logOut(void);
  virtual bool changeLogin(void);
  virtual bool changePassword(void);

  virtual int id(void) const;
  virtual std::string name(void) const;
  virtual std::string lastName(void) const;
  virtual std::string login(void) const;
  virtual bool isRoot(void) const;
  virtual std::string creationDate(void) const;
  virtual std::string lastLoginDate(void) const;

private:
  ClassDef(JPetUser, 1);
};

#endif // JPET_USER_H

// JPet User - JPetUser.h
#ifndef JPET_USER_H
#define JPET_USER_H

#include "TNamed.h"

class JPetUser: public TNamed
{
protected:
  int m_id;
  std::string m_name;
  std::string m_lastName;
  std::string m_login;
  std::string m_password;
  bool m_isRoot;
  std::string m_creationDate;
  std::string m_lastLoginDate;

  static bool m_isUserLogged;
  inline void toggleUserLoggedStatus()
  {
    m_isUserLogged = !m_isUserLogged;
  }
  virtual std::string password(void) const;

public:
  JPetUser(int p_id, std::string p_name, std::string p_lastName, std::string p_login, std::string p_password, bool p_isRoot);
  virtual ~JPetUser(void);

  static bool isUserLogged(void);
  virtual bool logIn(void);
  virtual bool logOut(void);
  virtual bool changeLogin(void);
  virtual bool changePassword(void);

  virtual int id(void) const;
  virtual std::string name(void) const;
  virtual std::string lastName(void) const;
  virtual std::string login(void) const;
  virtual bool isRoot(void) const;
  virtual std::string creationDate(void) const;
  virtual std::string lastLoginDate(void) const;

private:
  ClassDef(JPetUser, 1);
};

#endif // JPET_USER_H

Change body of the toggleUserLoggedStatus method.


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

// declare main so that it takes input from command line
int main(int argc, string argv[])
{
    for (int i = 1; i < argc; i++)
    {
        for (int j = 0, k = strlen(argv[i]); j < k; j++)
        {
            if (j % 2 == 0)
            {
                printf("%c", toupper(argv[i][j]));
            }
            else
            {
                printf("%c", tolower(argv[i][j]));
            }
            printf(" ");
        }
        printf(" ");
    }

    printf("\n");
}

Add additional string iteration program example


/*  Chapter 27, drill
    1. Write a Hello World program
    2. Define two variables holding "Hello" and "World!", concatenate them with
       a space in between and output them as "Hello World!"
    3. Define a function taking a char* p and an int x, print their values in
       the format "p is 'foo' and x is 7". Call it with a few argument pairs. */

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

void my_func(char* p, int x)
{
    printf("p is \"%s\" and x is %i\n",p,x);
}

int main()
{
    printf("Hello World!\n");

    char* hello = "Hello";
    char* world = "World!";
    char* hello_world = (char*) malloc(strlen(hello)+strlen(world)+2);
    strcpy(hello_world,hello);
    hello_world[strlen(hello)] = ' ';
    strcpy(hello_world+strlen(hello)+1,world);
    printf("%s\n",hello_world);

    my_func("foo",7);
    my_func("Scott Meyers",42);
    my_func("Bjarne Stroustrup",99);
}

/*  Chapter 27, drill
    1. Write a Hello World program
    2. Define two variables holding "Hello" and "World!", concatenate them with
       a space in between and output them as "Hello World!"
    3. Define a function taking a char* p and an int x, print their values in
       the format "p is 'foo' and x is 7". Call it with a few argument pairs. */

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

void my_func(char* p, int x)
{
    printf("p is \"%s\" and x is %i\n",p,x);
}

int main()
{
    printf("Hello World!\n");
    {
        char* hello = "Hello";
        char* world = "World!";
        char* hello_world = (char*) malloc(strlen(hello)+strlen(world)+2);
        strcpy(hello_world,hello);
        hello_world[strlen(hello)] = ' ';
        strcpy(hello_world+strlen(hello)+1,world);
        printf("%s\n",hello_world);
    }
    my_func("foo",7);
    my_func("Scott Meyers",42);
    my_func("Bjarne Stroustrup",99);
}

Modify Chapter 27, drill to comply with C89 standard


#include <QtGlobal>

#if defined Q_WS_X11
#include <X11/extensions/scrnsaver.h>
#endif

// return idle time in seconds
int getIdleSecs()
{
#if defined Q_WS_X11
    int code, idle_sec;
    XScreenSaverInfo *ssinfo = XScreenSaverAllocInfo();
    if (!ssinfo)
        goto fail;
    Display *display = XOpenDisplay(0);
    if (!display)
        goto fail;
    code = XScreenSaverQueryInfo(display, DefaultRootWindow(display), ssinfo);
    if (!code)
        goto fail;
    idle_sec = ssinfo->idle / 1000;
    XFree(ssinfo);
    XCloseDisplay(display);
    return idle_sec;

fail:
    if (ssinfo)
        XFree(ssinfo);
    if (display)
        XCloseDisplay(display);
    return -1;
#else
    return -1;
#endif
}

#include <QtGlobal>

// headers
#if defined Q_WS_X11
#include <X11/extensions/scrnsaver.h>

#elif defined Q_WS_WIN
#include <windows.h>

#endif
// ^ headers

// return idle time in seconds
int getIdleSecs()
{
// linux
#if defined Q_WS_X11
    int code, idle_sec;
    XScreenSaverInfo *ssinfo = XScreenSaverAllocInfo();
    if (!ssinfo)
        goto fail;
    Display *display = XOpenDisplay(0);
    if (!display)
        goto fail;
    code = XScreenSaverQueryInfo(display, DefaultRootWindow(display), ssinfo);
    if (!code)
        goto fail;
    idle_sec = ssinfo->idle / 1000;
    XFree(ssinfo);
    XCloseDisplay(display);
    return idle_sec;

fail:
    if (ssinfo)
        XFree(ssinfo);
    if (display)
        XCloseDisplay(display);
    return -1;
// ^ linux

// windows
#elif defined Q_WS_WIN
    BOOL ok;
    LASTINPUTINFO plii;
    DWORD msec;
    plii.cbSize = sizeof(LASTINPUTINFO);
    plii.dwTime = 0;
    ok = GetLastInputInfo(&plii);
    if (!ok)
        return -1;
    msec = GetTickCount();
    msec -= plii.dwTime;
    msec /= 1000;
    return msec;
// ^ windows

#else
    return -1;
#endif
}

Add idle time function for windows

Add idle time function for windows


extern void __VERIFIER_error() __attribute__ ((__noreturn__));
extern int __VERIFIER_nondet_int();
void __VERIFIER_assert(int cond) {
    if (!(cond)) {
        ERROR: __VERIFIER_error();
    }
    return;
}

int main()
{
    int x = __VERIFIER_nondet_int();
    if (x > 0 && x < 2)
        __VERIFIER_assert(x == 1);
    else
        __VERIFIER_assert(1); // arbitrary node in else branch to see invariant
    return 0;
}

Add test about witness un-CIL invariant being incorrect when branches joined


#ifndef LOADER_H
#define LOADER_H

#include "../../../libwiiu/src/coreinit.h"
#include "../../../libwiiu/src/socket.h"
#include "../../../libwiiu/src/types.h"

void _start();

void _entryPoint();

/* Arbitrary kernel write syscall */
void kern_write(void *addr, uint32_t value);

#endif /* LOADER_H */

#ifndef LOADER_H
#define LOADER_H

#include "../../../libwiiu/src/coreinit.h"
#include "../../../libwiiu/src/socket.h"
#include "../../../libwiiu/src/types.h"

/* Kernel address table */
#if VER == 200
	#define KERN_ADDRESS_TBL		0x0
#elif VER == 210
	#define KERN_ADDRESS_TBL		0x0
#elif VER == 300
	#define KERN_ADDRESS_TBL		0xFFEB66E4
#elif VER == 310
	#define KERN_ADDRESS_TBL		0x0
#elif VER == 400
	#define KERN_ADDRESS_TBL		0x0
#elif VER == 410
	#define KERN_ADDRESS_TBL		0xffeb902c
#elif VER == 500
	#define KERN_ADDRESS_TBL		0xffea9e4c
#elif VER == 532
	#define KERN_ADDRESS_TBL		0xFFEAAA10
#else
#error "Unsupported Wii U software version"
#endif

void _start();

void _entryPoint();

/* Arbitrary kernel write syscall */
void kern_write(void *addr, uint32_t value);

#endif /* LOADER_H */

Add KERN_ADDRESS_TBL for each version

Add KERN_ADDRESS_TBL for each version


/* ISC license. */

#ifndef S6RC_CONSTANTS_H
#define S6RC_CONSTANTS_H

#define S6RC_COMPILED_BASE "/etc/s6-rc/compiled"
#define S6RC_LIVE_BASE "/s6/s6-rc"

#define S6RC_COMPILED_DIR_LEN 32

#define S6RC_ONESHOT_RUNNER "s6rc-oneshot-runner"
#define S6RC_ONESHOT_RUNNER_LEN (sizeof S6RC_ONESHOT_RUNNER - 1)

#endif

/* ISC license. */

#ifndef S6RC_CONSTANTS_H
#define S6RC_CONSTANTS_H

#define S6RC_COMPILED_BASE "/etc/s6-rc/compiled"
#define S6RC_LIVE_BASE "/run/s6-rc"

#define S6RC_COMPILED_DIR_LEN 32

#define S6RC_ONESHOT_RUNNER "s6rc-oneshot-runner"
#define S6RC_ONESHOT_RUNNER_LEN (sizeof S6RC_ONESHOT_RUNNER - 1)

#endif

Change default live to /run/s6-rc

Change default live to /run/s6-rc


/// @file sapi-dylink.h
/// @brief Define the record used for runtime linking.

/// This structure allows forth to easily look up things on the C
/// side of the world.
///
/// Special Rules:
/// - The very first item is the size of the record.
///

// This could be packed more tightly, but its now exactly
// 16 bytes per record, which is nice.  Make sure that doesn't
// change.

typedef struct {
	// This union is a bit crazy, but its the simplest way of
	// getting the compiler to shut up.
	union {
		void (*fp) (void);
		int*  ip;
		unsigned int    ui;
		unsigned int*  uip;
		unsigned long* ulp;
		} p;   ///< Pointer to the object of interest
	int16_t size;  ///< Size in bytes
	int16_t count; ///< How many
	int8_t kind;   ///< Is this a variable or a constant?
	int8_t strlen;   ///< Length of the string
	char  *name; ///< Null-Terminated C string.
	} runtimelink_t;

/// Helper Macro.
#define FORTHNAME(x) (sizeof(x)-1),x

extern const runtimelink_t dynamiclinks[];

/// @file sapi-dylink.h
/// @brief Define the record used for runtime linking.

/// This structure allows forth to easily look up things on the C
/// side of the world.
///
/// Special Rules:
/// - The very first item is the size of the record.
///

// This could be packed more tightly, but its now exactly
// 16 bytes per record, which is nice.  Make sure that doesn't
// change.

// Conventions:
// Size is the size of the fundamental thing in bytes,
// and count is the number of them.
// char array[64] = 1,64
// struct { a, b } s; sizeof(s),1

typedef struct {
	// This union is a bit crazy, but its the simplest way of
	// getting the compiler to shut up.
	union {
		void (*fp) (void);
		int*  ip;
		unsigned int    ui;
		unsigned int*  uip;
		unsigned long* ulp;
		} p;   ///< Pointer to the object of interest
	int16_t size;  ///< Size in bytes
	int16_t count; ///< How many
	int8_t kind;   ///< Is this a variable or a constant?
	int8_t strlen;   ///< Length of the string
	char  *name; ///< Null-Terminated C string.
	} runtimelink_t;

/// Helper Macro.
#define FORTHNAME(x) (sizeof(x)-1),x

extern const runtimelink_t dynamiclinks[];

Clarify the dynamic linking structure.

Clarify the dynamic linking structure.


#import <UIKit/UIKit.h>

@protocol UITableViewDataSourceDynamicSizing;

@interface UITableView (DynamicSizing)
- (void)registerClass:(Class)cellClass forDynamicCellReuseIdentifier:(NSString *)identifier;
- (void)registerNib:(UINib *)nib forDynamicCellReuseIdentifier:(NSString *)identifier;
- (CGFloat)minimumHeightForCellWithReuseIdentifier:(NSString*)reuseIdentifier atIndexPath:(NSIndexPath*)indexPath;
@end

@protocol UITableViewDataSourceDynamicSizing <UITableViewDataSource>
- (void)tableView:(UITableView*)tableView configureCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath;
@end

#import <UIKit/UIKit.h>

@protocol UITableViewDataSourceDynamicSizing;

@interface UITableView (DynamicSizing)
- (void)registerClass:(Class)cellClass forDynamicCellReuseIdentifier:(NSString *)identifier;
- (void)registerNib:(UINib *)nib forDynamicCellReuseIdentifier:(NSString *)identifier;
- (CGFloat)minimumHeightForCellWithReuseIdentifier:(NSString*)reuseIdentifier atIndexPath:(NSIndexPath*)indexPath;
@end

@protocol UITableViewDataSourceDynamicSizing <UITableViewDataSource>
@required
- (void)tableView:(UITableView*)tableView configureCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath;
@end

Make sure to mark all the methods in the dynamic sizing data source as required


#include <setjmp.h>

/*
  Portability: A single method works on all the platforms we have tried
  so far, but this may not be true for all platforms.
*/
#if defined(ULTRIX42) || defined(ULTRIX43) || defined(SUNOS41)
#	define SETJMP _setjmp
#	define LONGJMP _longjmp
	extern "C" {
		int SETJMP( jmp_buf env );
		void LONGJMP( jmp_buf env, int retval );
	}
#else
	// Unknown platforms fall through to here, generating compile time error
#	error
#endif

int data_start_addr();
int data_end_addr();
int stack_start_addr();
int stack_end_addr();
void ExecuteOnTmpStk( void (*func)() );

#include <setjmp.h>
#include <sys/param.h>
#include <sys/vmparam.h>

/*
  Portability: A single method works on all the platforms we have tried
  so far, but this may not be true for all platforms.
*/
#if defined(ULTRIX42) || defined(ULTRIX43) || defined(SUNOS41)
#	define SETJMP _setjmp
#	define LONGJMP _longjmp
	extern "C" {
		int SETJMP( jmp_buf env );
		void LONGJMP( jmp_buf env, int retval );
	}
#else
	// Unknown platforms fall through to here, generating compile time error
#	error
#endif

int data_start_addr();
int data_end_addr();
int stack_start_addr();
int stack_end_addr();
void ExecuteOnTmpStk( void (*func)() );

Include both <sys/param.h> and <sys/vmparam.h> since both SUNOS and ULTRIX will need them.


// RUN: clang -emit-llvm < %s 2>&1 | grep 'addrspace(1)' | count 5
int foo __attribute__((address_space(1)));
int ban[10] __attribute__((address_space(1)));

int bar() { return foo; }

int baz(int i) { return ban[i]; }

Add ending newline to test.

Add ending newline to test.

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


// Copyright (c) 2007, 2008 libmv authors.
//
// 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 LIBMV_ID_GENERATOR_H
#define LIBMV_ID_GENERATOR_H

namespace libmv {

class IdGenerator {
 public:
  IdGenerator() : next_(0) {}
  uint Generate() { return next_++; }
 private:
  uint next_;
};

}  // namespace libmv

#endif  // LIBMV_ID_GENERATOR_H

Add another missing file :(

Add another missing file :(


#ifdef HAVE_FORK
#define HAVE_FORK 1
#endif

#if HAVE_FORK
# if TARGET_OS_IPHONE || APPLE_SDK_IPHONEOS
#  define HAVE_SYSTEM 0
# else
#  define HAVE_SYSTEM 1
# endif
#else
# define HAVE_SYSTEM 0
#endif

#if HAVE_SYSTEM
#include "p/sh.h"
#endif

#include "p/spp.h"
#include "p/acr.h"
#include "p/pod.h"
#include "p/cpp.h"

struct Proc *procs[] = {
	&spp_proc,
	&cpp_proc,
	&pod_proc,
	&acr_proc,
#if HAVE_SYSTEM
	&sh_proc,
#endif
	NULL
};

DEFAULT_PROC(spp)

#define DEBUG 0

#ifdef HAVE_FORK
#define HAVE_FORK 1
#endif

#if HAVE_FORK
# if TARGET_OS_IPHONE || APPLE_SDK_IPHONEOS || APPLE_SDK_IPHONESIMULATOR
#  define HAVE_SYSTEM 0
# else
#  define HAVE_SYSTEM 1
# endif
#else
# define HAVE_SYSTEM 0
#endif

#if HAVE_SYSTEM
#include "p/sh.h"
#endif

#include "p/spp.h"
#include "p/acr.h"
#include "p/pod.h"
#include "p/cpp.h"

struct Proc *procs[] = {
	&spp_proc,
	&cpp_proc,
	&pod_proc,
	&acr_proc,
#if HAVE_SYSTEM
	&sh_proc,
#endif
	NULL
};

DEFAULT_PROC(spp)

#define DEBUG 0

Fix build for the iPhone Simulator

Fix build for the iPhone Simulator


//-----------------------------------------------------------------------------
// Constructors
//-----------------------------------------------------------------------------

template<class T>
matrix<T>::matrix():data_(),rows_(0),cols_(0){}
template<class T>
matrix<T>::matrix( std::size_t rows, std::size_t cols ):
    data_(rows*cols),rows_(rows),cols_(cols){}
template<class T>
matrix<T>::matrix( std::initializer_list<std::initializer_list<T>> init_list):
    data_( init_list.size() * init_list.begin()->size() ),
    rows_(init_list.size()),cols_( init_list.begin()->size() ){
  // TODO: copy values
}
/*
template<class T>
matrix<T>::matrix( const matrix& );
template<class T>
matrix<T>::matrix( matrix&& );
*/

//-----------------------------------------------------------------------------
// Constructors
//-----------------------------------------------------------------------------

template<class T>
matrix<T>::matrix():data_(),rows_(0),cols_(0){}
template<class T>
matrix<T>::matrix( std::size_t rows, std::size_t cols ):
    data_(rows*cols),rows_(rows),cols_(cols){}
template<class T>
matrix<T>::matrix( std::initializer_list<std::initializer_list<T>> init_list):
    data_( init_list.size() * init_list.begin()->size() ),
    rows_(init_list.size()),cols_( init_list.begin()->size() ){
  // TODO: copy values
  // Or create concat function for init_list and use it to initialize
  // data_ vector.
}
/*
template<class T>
matrix<T>::matrix( const matrix& );
template<class T>
matrix<T>::matrix( matrix&& );
*/

Add comment about init_list constructor.


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

typedef struct n
{
  int data;
  struct n * next;
} node;

/* Print Linked list values */
void showList(node * list){
  int i = 1;
  while( list != NULL){
    printf("#%d. node, data: %d at pointed: %p, and points to %p\n", i, list->data, list, list->next);
    list = list->next;
    i++;
  }
}

int main(){

  node * root;
  /* First Node Allocation */
  root = (node *) malloc(sizeof(node));
  root->data = 0;
  root->next = NULL;
  /* Create another 9 nodes in the list. */
  node * iter = root;
  for(int i = 1; i < 10; i++){
    iter->next = (node *) malloc(sizeof(node));
    iter = iter->next;
    iter->data = i*10;
    iter->next = NULL;
  }
  showList(root);
  return 0;
}

/*
-- Resulted as --
#1. node, data: 0 at pointed: 00541738, and points to 00541768
#2. node, data: 10 at pointed: 00541768, and points to 00541778
#3. node, data: 20 at pointed: 00541778, and points to 00541788
#4. node, data: 30 at pointed: 00541788, and points to 00541798
#5. node, data: 40 at pointed: 00541798, and points to 005417A8
#6. node, data: 50 at pointed: 005417A8, and points to 005417B8
#7. node, data: 60 at pointed: 005417B8, and points to 005417C8
#8. node, data: 70 at pointed: 005417C8, and points to 005417D8
#9. node, data: 80 at pointed: 005417D8, and points to 005417E8
#10. node, data: 90 at pointed: 005417E8, and points to 00000000
*/

Add another nodes by for loop way.

Add another nodes by for loop way.


#ifndef _LINUX_ERR_H
#define _LINUX_ERR_H

#include <linux/compiler.h>

#include <asm/errno.h>

/*
 * Kernel pointers have redundant information, so we can use a
 * scheme where we can return either an error code or a dentry
 * pointer with the same return value.
 *
 * This should be a per-architecture thing, to allow different
 * error and pointer decisions.
 */
#define MAX_ERRNO	4095

#ifndef __ASSEMBLY__

#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)

static inline void *ERR_PTR(long error)
{
	return (void *) error;
}

static inline long PTR_ERR(const void *ptr)
{
	return (long) ptr;
}

static inline long IS_ERR(const void *ptr)
{
	return IS_ERR_VALUE((unsigned long)ptr);
}

#endif

#endif /* _LINUX_ERR_H */

#ifndef _LINUX_ERR_H
#define _LINUX_ERR_H

#include <linux/compiler.h>

#include <asm/errno.h>

/*
 * Kernel pointers have redundant information, so we can use a
 * scheme where we can return either an error code or a dentry
 * pointer with the same return value.
 *
 * This should be a per-architecture thing, to allow different
 * error and pointer decisions.
 */
#define MAX_ERRNO	4095

#ifndef __ASSEMBLY__

#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)

static inline void *ERR_PTR(long error)
{
	return (void *) error;
}

static inline long PTR_ERR(const void *ptr)
{
	return (long) ptr;
}

static inline long IS_ERR(const void *ptr)
{
	return IS_ERR_VALUE((unsigned long)ptr);
}

/**
 * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type
 * @ptr: The pointer to cast.
 *
 * Explicitly cast an error-valued pointer to another pointer type in such a
 * way as to make it clear that's what's going on.
 */
static inline void *ERR_CAST(const void *ptr)
{
	/* cast away the const */
	return (void *) ptr;
}

#endif

#endif /* _LINUX_ERR_H */

Add an ERR_CAST() function to complement ERR_PTR and co.

Add an ERR_CAST() function to complement ERR_PTR and co.  for the purposes
of casting an error entyped as one pointer type to an error of another
pointer type whilst making it explicit as to what is going on.

This provides a replacement for the ERR_PTR(PTR_ERR(p)) construct.

Signed-off-by: David Howells <ebac1d06c1688626821bb0e574a037a7a5354e49@redhat.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>


#ifndef __THREAD_INFO_H
#define __THREAD_INFO_H

#include "globals.h"
#include "sift_writer.h"
#include "bbv_count.h"

#include "pin.H"
#include <deque>

typedef struct {
   Sift::Writer *output;
   ADDRINT dyn_addresses[Sift::MAX_DYNAMIC_ADDRESSES];
   UINT32 num_dyn_addresses;
   Bbv *bbv;
   UINT64 thread_num;
   ADDRINT bbv_base;
   UINT64 bbv_count;
   ADDRINT bbv_last;
   BOOL bbv_end;
   UINT64 blocknum;
   UINT64 icount;
   UINT64 icount_cacheonly;
   UINT64 icount_cacheonly_pending;
   UINT64 icount_detailed;
   UINT64 icount_reported;
   ADDRINT last_syscall_number;
   ADDRINT last_syscall_returnval;
   UINT64 flowcontrol_target;
   ADDRINT tid_ptr;
   ADDRINT last_routine;
   ADDRINT last_call_site;
   BOOL last_syscall_emulated;
   BOOL running;
} __attribute__((packed,aligned(LINE_SIZE_BYTES))) thread_data_t;

extern thread_data_t *thread_data;

void initThreads();

#endif // __THREAD_INFO_H

#ifndef __THREAD_INFO_H
#define __THREAD_INFO_H

#include "globals.h"
#include "sift_writer.h"
#include "bbv_count.h"

#include "pin.H"
#include <deque>

typedef struct {
   Sift::Writer *output;
   UINT64 dyn_addresses[Sift::MAX_DYNAMIC_ADDRESSES];
   UINT32 num_dyn_addresses;
   Bbv *bbv;
   UINT64 thread_num;
   ADDRINT bbv_base;
   UINT64 bbv_count;
   ADDRINT bbv_last;
   BOOL bbv_end;
   UINT64 blocknum;
   UINT64 icount;
   UINT64 icount_cacheonly;
   UINT64 icount_cacheonly_pending;
   UINT64 icount_detailed;
   UINT64 icount_reported;
   ADDRINT last_syscall_number;
   ADDRINT last_syscall_returnval;
   UINT64 flowcontrol_target;
   ADDRINT tid_ptr;
   ADDRINT last_routine;
   ADDRINT last_call_site;
   BOOL last_syscall_emulated;
   BOOL running;
} __attribute__((packed,aligned(LINE_SIZE_BYTES))) thread_data_t;

extern thread_data_t *thread_data;

void initThreads();

#endif // __THREAD_INFO_H

[recorder] Fix 32-bit compile by making the per-thread address data 64-bit


/*
 *  Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef COMMON_VIDEO_INTERFACE_TEXTURE_VIDEO_FRAME_H
#define COMMON_VIDEO_INTERFACE_TEXTURE_VIDEO_FRAME_H

#include "webrtc/common_video/interface/i420_video_frame.h"

// TODO(magjed): Remove this when all external dependencies are updated.
namespace webrtc {

typedef I420VideoFrame TextureVideoFrame;

}  // namespace webrtc

#endif  // COMMON_VIDEO_INTERFACE_TEXTURE_VIDEO_FRAME_H

Add intermediate TextureVideoFrame typedef for Chromium

BUG=1128
R=perkj@webrtc.org
TBR=stefan

Review URL: https://webrtc-codereview.appspot.com/42239004

git-svn-id: 03ae4fbe531b1eefc9d815f31e49022782c42458@8630 4adac7df-926f-26a2-2b94-8c16560cd09d


#include <math.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "fake-lock-screen-pattern.h"

void flsp_draw_circle(cairo_t *context, gint x, gint y,
                      gint radius, GdkRGBA circle, GdkRGBA border)
{
  cairo_set_line_width(context, 9);
  cairo_set_source_rgb(context, border.red, border.green, border.blue);
  cairo_arc(context, x, y, radius, 0, 2 * M_PI);
  cairo_stroke_preserve(context);
  cairo_set_source_rgb(context, circle.red, circle.green, circle.blue);
  cairo_fill(context);
}

Implement function to draw circle

Implement function to draw circle


/* Copyright (C) 2003 Timo Sirainen */

#include "lib.h"
#include "ioloop-internal.h"

#ifdef IOLOOP_NOTIFY_NONE

struct io *io_loop_notify_add(struct ioloop *ioloop __attr_unused__,
			      const char *path __attr_unused__,
			      io_callback_t *callback __attr_unused__,
			      void *context __attr_unused__)
{
	return NULL;
}

void io_loop_notify_remove(struct ioloop *ioloop __attr_unused__,
			   struct io *io __attr_unused__)
{
}

void io_loop_notify_handler_init(struct ioloop *ioloop __attr_unused__)
{
}

void io_loop_notify_handler_deinit(struct ioloop *ioloop __attr_unused__)
{
}

#endif

/* Copyright (C) 2003 Timo Sirainen */

#include "lib.h"
#include "ioloop-internal.h"

#ifdef IOLOOP_NOTIFY_NONE

#undef io_add_notify
struct io *io_add_notify(const char *path __attr_unused__,
			 io_callback_t *callback __attr_unused__,
			 void *context __attr_unused__)
{
	return NULL;
}

void io_loop_notify_remove(struct ioloop *ioloop __attr_unused__,
			   struct io *io __attr_unused__)
{
}

void io_loop_notify_handler_deinit(struct ioloop *ioloop __attr_unused__)
{
}

#endif

Fix for building without notify

Fix for building without notify


/*
 * Copyright 2014, NICTA
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(NICTA_BSD)
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sel4/sel4.h>

long sys_sched_yield(va_list ap)
{
    seL4_Yield();
    return 0;
}

/*
 * Copyright 2014, NICTA
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(NICTA_BSD)
 */

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sel4/sel4.h>

long sys_sched_yield(va_list ap)
{
    /* won't work */
    return 0;
}

Remove seL4_Yield() since it's removed from the RT kernel.

JIRA CAMKES-429


// Copyright (c) 2016 Sift Science. All rights reserved.

@import Foundation;

/** Debug output that can be turned on/off by SF_DEBUG_ENABLE macro. */
#ifdef SF_DEBUG_ENABLE
#define SF_DEBUG(FORMAT, ...) NSLog(@"%s:%d " FORMAT, __FUNCTION__, __LINE__, ## __VA_ARGS__)
#else
#define SF_DEBUG(...)
#endif

/** Log messages to console that are important to the SDK users. */
#ifdef DEBUG
#define SF_IMPORTANT(FORMAT, ...) NSLog(@"%s:%d " FORMAT, __FUNCTION__, __LINE__, ## __VA_ARGS__)
#endif

// Copyright (c) 2016 Sift Science. All rights reserved.

@import Foundation;

/** Debug output that can be turned on/off by SF_DEBUG_ENABLE macro. */
#ifdef SF_DEBUG_ENABLE
#define SF_DEBUG(FORMAT, ...) NSLog(@"%s:%d " FORMAT, __FUNCTION__, __LINE__, ## __VA_ARGS__)
#else
#define SF_DEBUG(...)
#endif

/** Log messages to console that are important to the SDK users. */
#ifdef DEBUG
#define SF_IMPORTANT(FORMAT, ...) NSLog(@"%s:%d " FORMAT, __FUNCTION__, __LINE__, ## __VA_ARGS__)
#else
#define SF_IMPORTANT(...)
#endif

Add empty SF_IMPORTANT macro for release build


/* stddef.h */

/*
 * Copyright (c) 2014 Wind River Systems, Inc.
 *
 * 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 __INC_stddef_h__
#define __INC_stddef_h__

#include <bits/null.h>
#include <bits/size_t.h>

#if !defined(__ptrdiff_t_defined)
#define __ptrdiff_t_defined
typedef int  ptrdiff_t;
#endif

#define offsetof(type, member) ((size_t) (&((type *) NULL)->member))

#endif /* __INC_stddef_h__ */

/* stddef.h */

/*
 * Copyright (c) 2014 Wind River Systems, Inc.
 *
 * 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 __INC_stddef_h__
#define __INC_stddef_h__

#include <bits/null.h>
#include <bits/size_t.h>

#if !defined(__ptrdiff_t_defined)
#define __ptrdiff_t_defined
typedef int  ptrdiff_t;
#endif

#if defined(__GNUC__)
#define offsetof(type, member)  __builtin_offsetof(type, member)
#else
#define offsetof(type, member) ((size_t) (&((type *) NULL)->member))
#endif

#endif /* __INC_stddef_h__ */

Use offsetof() builtin with GCC

lib: Use offsetof() builtin with GCC

The default offsetof() implementation generates a warning
(variably modified <variable> at file scope) when used in
to define the size of an array. By using this builtin with
GCC we avoid the warning and make sure no variable-size
arrays are used.

Change-Id: Iae215f777241f7daaa061067230086dffaa8311d
Signed-off-by: Carles Cufi <853081dc8dca4fe6a7e3c984752718b5db36e060@nordicsemi.no>


#include <stddef.h>
#include <unistd.h>

int main(int argc, char *argv[]) {
    const char *args[2] = {"T7037", NULL};
    execv("./T7037", args);
}

#include <stddef.h>
#include <unistd.h>

int main(int argc, char *argv[]) {
#ifdef __MINGW32__
    const
#endif
    char * args[2] = {"T7037", NULL};
    execv("./T7037", args);
}

Make T7037 work on both Windows and other platforms


/*
 * startup.h
 *
 *  Created on: Nov 15, 2016
 *      Author: RoyerAriel
 */

#ifndef STARTUP_C_
#define STARTUP_C_
#include "Timer.h"

void startup()
{
  //Start Systick Timer at 1ms
  Systick_Startup();
  AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE; //0x2000000

}

#endif /* STARTUP_C_ */

/*
 * startup.h
 *
 *  Created on: Nov 15, 2016
 *      Author: RoyerAriel
 */

#ifndef STARTUP_C_
#define STARTUP_C_
#include "Timer.h"

void startup()
{
  //Start Systick Timer at 1ms
  Systick_Startup();
  AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_JTAGDISABLE; //0x2000000disable jtag

}

#endif /* STARTUP_C_ */

Disable Jtag came enable by default

Disable Jtag came enable by default

Disable Jtag came enable by default and use GPIOB P04,P03 and P05


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

#define STTY "/bin/stty "
const char RAW[] = STTY "raw";
const char COOKED[] = STTY "cooked";

const char default_str[] = "I AM AN IDIOT ";

int main(int argc, char **argv) {
  system(RAW);

  const char *str;
  if ( argc == 2 )
    str = argv[1];
  else
    str = default_str;

  size_t len = strlen(str);

  while ( 1 ) {
    for ( size_t i = 0 ; i < len ; i++ ) {
      getchar();
      printf("\b%c", str[i]);
    }
    system(COOKED);
    printf("\n");
    system(RAW);
  }

  return 0;
}

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

#define STTY "/bin/stty "
const char RAW[] = STTY "raw";
const char COOKED[] = STTY "cooked";

const char default_str[] = "I AM AN IDIOT ";

int main(int argc, char **argv) {
  system(RAW);

  const char *str;
  if ( argc == 2 )
    str = argv[1];
  else
    str = default_str;

  size_t len = strlen(str);

  while ( 1 ) {
    for ( size_t i = 0 ; i < len ; i++ ) {
      getchar();
      printf("\r");
      for ( size_t j = 0 ; j <= i ; j++ ) {
	printf("%c", str[j]);
      }
    }
    system(COOKED);
    printf("\n");
    system(RAW);
  }

  return 0;
}

Allow non printing chars to also work well


/*
 * Copyright 2016, Data61
 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
 * ABN 41 687 119 230.
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(D61_BSD)
 */

#pragma once

/* Prevent the compiler from re-ordering any read or write across the fence. */
#define COMPILER_MEMORY_FENCE() __atomic_signal_fence(__ATOMIC_ACQ_REL)

/* Prevent the compiler from re-ordering any write which follows the fence
 * in program order with any read or write which preceeds the fence in
 * program order. */
#define COMPILER_MEMORY_RELEASE() __atomic_signal_fence(__ATOMIC_RELEASE)

/* Prevent the compiler from re-ordering any read which preceeds the fence
 * in program order with any read or write which follows the fence in
 * program order */.
#define COMPILER_MEMORY_ACQUIRE() __atomic_signal_fence(__ATOMIC_ACQUIRE)

/*
 * Copyright 2016, Data61
 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
 * ABN 41 687 119 230.
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(D61_BSD)
 */

#pragma once

/* Prevent the compiler from re-ordering any read or write across the fence. */
#define COMPILER_MEMORY_FENCE() __atomic_signal_fence(__ATOMIC_ACQ_REL)

/* Prevent the compiler from re-ordering any write which follows the fence
 * in program order with any read or write which preceeds the fence in
 * program order. */
#define COMPILER_MEMORY_RELEASE() __atomic_signal_fence(__ATOMIC_RELEASE)

/* Prevent the compiler from re-ordering any read which preceeds the fence
 * in program order with any read or write which follows the fence in
 * program order. */
#define COMPILER_MEMORY_ACQUIRE() __atomic_signal_fence(__ATOMIC_ACQUIRE)

Move trailing . inside comment

libutils: Move trailing . inside comment