// Thanks to JeraTech for this minimalist TDD code,
// which I've modified to resemble AngularJS's a bit more.
// http://www.jera.com/techinfo/jtns/jtn002.html

int tests_run = 0;
#define _it_should(message, test) do { if (!(test)) return message; } while (0)
#define _run_test(test) do { char *message = test(); tests_run++; if (message) return message; } while (0)

Define a minimal unit testing framework.


//
//  ENAPI_utils.h
//  libechonest
//
//  Created by Art Gillespie on 3/15/11. art@tapsquare.com
//

#import "NSMutableDictionary+QueryString.h"
#import "NSData+MD5.h"
#import "ENAPI.h"

#define CHECK_API_KEY if (nil == [ENAPI apiKey]) { @throw [NSException exceptionWithName:@"APIKeyNotSetException" reason:@"Set the API key before calling this method" userInfo:nil]; }

static NSString __attribute__((unused)) * const ECHONEST_API_URL = @"http://developer.echonest.com/api/v4/";

//
//  ENAPI_utils.h
//  libechonest
//
//  Created by Art Gillespie on 3/15/11. art@tapsquare.com
//

#import "NSMutableDictionary+QueryString.h"
#import "NSData+MD5.h"
#import "ENAPI.h"

#define CHECK_API_KEY if (nil == [ENAPI apiKey]) { @throw [NSException exceptionWithName:@"APIKeyNotSetException" reason:@"Set the API key before calling this method" userInfo:nil]; }

#define CHECK_OAUTH_KEYS if (nil == [ENAPI consumerKey] && nil == [ENAPI sharedSecret]) { @throw [NSException exceptionWithName:@"OAuthKeysNotSetException" reason:@"Set the consumer key & shared secret before calling this method" userInfo:nil]; }

static NSString __attribute__((unused)) * const ECHONEST_API_URL = @"http://developer.echonest.com/api/v4/";

Add macro for checking OAuth keys.

Add macro for checking OAuth keys.


//
//  ViewController.h
//  AAChartKit
//
//  Created by An An on 17/3/13.
//  Copyright © 2017年 An An. All rights reserved.
//  source code ----*** https://github.com/AAChartModel/AAChartKit ***--- source code
//

#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger,ENUM_secondeViewController_chartType){
    ENUM_secondeViewController_chartTypeColumn =0,
    ENUM_secondeViewController_chartTypeBar,
    ENUM_secondeViewController_chartTypeArea,
    ENUM_secondeViewController_chartTypeAreaspline,
    ENUM_secondeViewController_chartTypeLine,
    ENUM_secondeViewController_chartTypeSpline,
    ENUM_secondeViewController_chartTypeScatter,

};

@interface SecondViewController : UIViewController
@property(nonatomic,assign)NSInteger ENUM_secondeViewController_chartType;
@property(nonatomic,copy)NSString *receivedChartType;

@end

//
//  ViewController.h
//  AAChartKit
//
//  Created by An An on 17/3/13.
//  Copyright © 2017年 An An. All rights reserved.
//  source code ----*** https://github.com/AAChartModel/AAChartKit ***--- source code
//

#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger,SecondeViewControllerChartType){
    SecondeViewControllerChartTypeColumn =0,
    SecondeViewControllerChartTypeBar,
    SecondeViewControllerChartTypeArea,
    SecondeViewControllerChartTypeAreaspline,
    SecondeViewControllerChartTypeLine,
    SecondeViewControllerChartTypeSpline,
    SecondeViewControllerChartTypeScatter,

};

@interface SecondViewController : UIViewController
@property(nonatomic,assign)NSInteger SecondeViewControllerChartType;
@property(nonatomic,copy)NSString *receivedChartType;

@end

Correct the naming notations of enumeration


#ifndef TAGREADER_H
#define TAGREADER_H

#include <taglib/fileref.h>
#include <taglib/tag.h>
#include <taglib/mpegfile.h>
#include <taglib/id3v2tag.h>
#include <taglib/attachedpictureframe.h>

#include <QString>
#include <QImage>

class TagReader
{
public:
    TagReader(const QString &file);
    ~TagReader();

    bool isValid() const;
    bool hasAudioProperties() const;

    QString title() const;
    QString album() const;
    QString artist() const;
    int track() const;
    int year() const;
    QString genre() const;
    QString comment() const;

    int length() const;
    int bitrate() const;
    int sampleRate() const;
    int channels() const;

    QImage thumbnailImage() const;
    QByteArray thumbnail() const;

private:
    TagLib::FileRef m_fileRef;
    TagLib::Tag *m_tag;
    TagLib::AudioProperties *m_audioProperties;
};

#endif // TAGREADER_H

#ifndef TAGREADER_H
#define TAGREADER_H

#include "taglib/fileref.h"
#include "taglib/tag.h"
#include "taglib/mpeg/mpegfile.h"
#include "taglib/mpeg/id3v2/id3v2tag.h"
#include "taglib/mpeg/id3v2/frames/attachedpictureframe.h"

#include <QString>
#include <QImage>

class TagReader
{
public:
    TagReader(const QString &file);
    ~TagReader();

    bool isValid() const;
    bool hasAudioProperties() const;

    QString title() const;
    QString album() const;
    QString artist() const;
    int track() const;
    int year() const;
    QString genre() const;
    QString comment() const;

    int length() const;
    int bitrate() const;
    int sampleRate() const;
    int channels() const;

    QImage thumbnailImage() const;
    QByteArray thumbnail() const;

private:
    TagLib::FileRef m_fileRef;
    TagLib::Tag *m_tag;
    TagLib::AudioProperties *m_audioProperties;
};

#endif // TAGREADER_H

Use our package taglib headers and not the hosts!


// RUN: %check -e %s

main()
{
	struct A
	{
		int i;
	} a, b, c;

	a = b ? : c; // CHECK: error: struct involved in if-expr
}

// RUN: %check -e %s

main()
{
	struct A
	{
		int i;
	} a, b, c;

	a = b ? : c; // CHECK: error: struct involved in ?:
}

Fix struct if-expression test warning

Fix struct if-expression test warning


#include "mode.h"

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

#include <termbox.h>

#include "buf.h"
#include "editor.h"

// TODO(isbadawi): Command mode needs a cursor, but modes don't affect drawing.
static void command_mode_key_pressed(editor_t *editor, struct tb_event *ev) {
  char ch;
  switch (ev->key) {
  case TB_KEY_ESC:
    buf_printf(editor->status, "");
    editor->mode = normal_mode();
    return;
  case TB_KEY_BACKSPACE2:
    buf_delete(editor->status, editor->status->len - 1, 1);
    if (editor->status->len == 0) {
      editor->mode = normal_mode();
      return;
    }
    return;
  case TB_KEY_ENTER: {
    char *command = strdup(editor->status->buf + 1);
    editor_execute_command(editor, command);
    free(command);
    editor->mode = normal_mode();
    return;
  }
  case TB_KEY_SPACE:
    ch = ' ';
    break;
  default:
    ch = ev->ch;
  }
  char s[2] = {ch, '\0'};
  buf_append(editor->status, s);
}

static editing_mode_t impl = {command_mode_key_pressed};

editing_mode_t *command_mode(void) {
  return &impl;
}

#include "mode.h"

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

#include <termbox.h>

#include "buf.h"
#include "editor.h"

// TODO(isbadawi): Command mode needs a cursor, but modes don't affect drawing.
static void command_mode_key_pressed(editor_t *editor, struct tb_event *ev) {
  char ch;
  switch (ev->key) {
  case TB_KEY_ESC:
    buf_printf(editor->status, "");
    editor->mode = normal_mode();
    return;
  case TB_KEY_BACKSPACE2:
    buf_delete(editor->status, editor->status->len - 1, 1);
    if (editor->status->len == 0) {
      editor->mode = normal_mode();
      return;
    }
    return;
  case TB_KEY_ENTER: {
    if (editor->status->len > 1) {
      char *command = strdup(editor->status->buf + 1);
      editor_execute_command(editor, command);
      free(command);
    }
    editor->mode = normal_mode();
    return;
  }
  case TB_KEY_SPACE:
    ch = ' ';
    break;
  default:
    ch = ev->ch;
  }
  char s[2] = {ch, '\0'};
  buf_append(editor->status, s);
}

static editing_mode_t impl = {command_mode_key_pressed};

editing_mode_t *command_mode(void) {
  return &impl;
}

Fix segfault on empty : command.

Fix segfault on empty : command.


// A currentTime function for use in the tests.

#ifdef _WIN32
extern "C" bool QueryPerformanceCounter(uint64_t *);
extern "C" bool QueryPerformanceFrequency(uint64_t *);
double currentTime() {
    uint64_t t, freq;
    QueryPerformanceCounter(&t);
    QueryPerformanceFrequency(&freq);
    return (t * 1000.0) / freq;
}
#else
#include <sys/time.h>
double currentTime() {
    static bool first_call = true;
    static timeval reference_time;
    if (first_call) {
        first_call = false;
        gettimeofday(&reference_time, NULL);
        return 0.0;
    } else {
        timeval t;
        gettimeofday(&t, NULL);
        return ((t.tv_sec - reference_time.tv_sec)*1000.0 +
                (t.tv_usec - reference_time.tv_usec)/1000.0);
    }
}
#endif

// A currentTime function for use in the tests.
// Returns time in milliseconds.

#ifdef _WIN32
extern "C" bool QueryPerformanceCounter(uint64_t *);
extern "C" bool QueryPerformanceFrequency(uint64_t *);
double currentTime() {
    uint64_t t, freq;
    QueryPerformanceCounter(&t);
    QueryPerformanceFrequency(&freq);
    return (t * 1000.0) / freq;
}
#else
#include <sys/time.h>
double currentTime() {
    static bool first_call = true;
    static timeval reference_time;
    if (first_call) {
        first_call = false;
        gettimeofday(&reference_time, NULL);
        return 0.0;
    } else {
        timeval t;
        gettimeofday(&t, NULL);
        return ((t.tv_sec - reference_time.tv_sec)*1000.0 +
                (t.tv_usec - reference_time.tv_usec)/1000.0);
    }
}
#endif

Add a comment that currentTime returns result in milliseconds.

Former-commit-id: 397c814dcee2df63ded6cbf17b63b601a10984e2


/* COR:a.bc PE:a.bc
   BAC:a.bc         */

void lcd_voltage() {

    string top, bottom;
    sprintf(top, "COR:%1.2f PE:%1.2f", nImmediateBatteryLevel * 0.001, SensorValue(PowerExpanderBattery) / 280);
    sprintf(bottom, "BAC:%1.2f", BackupBatteryLevel * 0.001);
    displayLCDString(LCD_LINE_TOP, 0, top);
    displayLCDString(LCD_LINE_BOTTOM, 0, bottom);

}

void lcd_clear() {

    clearLCDLine(LCD_LINE_TOP);
    clearLCDLine(LCD_LINE_BOTTOM);

}

/* COR:a.bc PE:a.bc
   BAC:a.bc         */

void lcd_voltage() {

    string top, bottom;
    sprintf(top, "COR:%1.2f PE:%1.2f", nImmediateBatteryLevel * 0.001, SensorValue(PowerExpanderBattery) / 280.0);
    sprintf(bottom, "BAC:%1.2f", BackupBatteryLevel * 0.001);
    displayLCDString(LCD_LINE_TOP, 0, top);
    displayLCDString(LCD_LINE_BOTTOM, 0, bottom);

}

void lcd_clear() {

    clearLCDLine(LCD_LINE_TOP);
    clearLCDLine(LCD_LINE_BOTTOM);

}

Change power expander to float

Change power expander to float


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

struct URI {
    char * scheme;
    char * user;
    char * password;
    char * host;
    char * port;
    char * path;
    char * query;
    char * fragment;
};

struct rule {
    char * name;
    char * rule;
    char * levels;
    char * priority;
};

struct URP {
    struct URI uri;
    struct rule * rules;
};

struct URI * parse_uri(char * raw_uri) {
    struct URI *uri = malloc (sizeof (struct URI));

    int scheme_found = 0;
    int scheme_end = 0;
    char * tmp_uriptr;
    for (tmp_uriptr = raw_uri; *tmp_uriptr != '\0'; ++tmp_uriptr) {
        if (*tmp_uriptr == ':') {
            if (!scheme_found) {
                scheme_end = tmp_uriptr - raw_uri;
                uri->scheme = (char *) malloc(scheme_end);
                strncpy(uri->scheme, raw_uri, scheme_end);
                scheme_found = 1;
            }
        }
    }
    return uri;
}

int main() {
    char * raw_uri = "scheme://dir1/dir2/dir3";
    struct URI * parsed_uri;
    parsed_uri = parse_uri(raw_uri);
    printf("%s\n", parsed_uri->scheme);
}

CREATE start of di in C

CREATE start of di in C


//
//  IFTTTAnimator.h
//  JazzHands
//
//  Created by Devin Foley on 9/28/13.
//  Copyright (c) 2013 IFTTT Inc. All rights reserved.
//

@protocol IFTTTAnimatable;

@interface IFTTTAnimator : NSObject

- (void)addAnimation:(id<IFTTTAnimatable>)animation;
- (void)animate:(CGFloat)time;

@end

//
//  IFTTTAnimator.h
//  JazzHands
//
//  Created by Devin Foley on 9/28/13.
//  Copyright (c) 2013 IFTTT Inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@protocol IFTTTAnimatable;

@interface IFTTTAnimator : NSObject

- (void)addAnimation:(id<IFTTTAnimatable>)animation;
- (void)animate:(CGFloat)time;

@end

Add UIKit import to allow for compiling without precompiled header


/*
 *  Constants.h
 *  phonegap-mac
 *
 *  Created by shazron on 10-04-08.
 *  Copyright 2010 Nitobi Software Inc. All rights reserved.
 *
 */

#define kStartPage @"index.html"

//Sencha Demos
#define kStartFolder @"www/sencha"

// PhoneGap Docs Only
//#define kStartFolder @"www/phonegap-docs/template/phonegap/"

/*
 *  Constants.h
 *  phonegap-mac
 *
 *  Created by shazron on 10-04-08.
 *  Copyright 2010 Nitobi Software Inc. All rights reserved.
 *
 */

#define kStartPage @"index.html"

//Sencha Demos
//#define kStartFolder @"www/sencha"

// PhoneGap Docs Only
#define kStartFolder @"www/phonegap-docs/template/phonegap/"

Revert "kStartFolder switch back to Sencha configuration"

This reverts commit 034cbb7f82a7c034ac8fe83c991ed6838b9a03b2.


//===--- CommentBriefParser.h - Dumb comment parser -------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines a very simple Doxygen comment parser.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_AST_BRIEF_COMMENT_PARSER_H
#define LLVM_CLANG_AST_BRIEF_COMMENT_PARSER_H

#include "clang/AST/CommentLexer.h"

namespace clang {
namespace comments {

/// A very simple comment parser that extracts "a brief description".
///
/// Due to a variety of comment styles, it considers the following as "a brief
/// description", in order of priority:
/// \li a \\brief or \\short command,
/// \li the first paragraph,
/// \li a \\result or \\return or \\returns paragraph.
class BriefParser {
  Lexer &L;

  const CommandTraits &Traits;

  /// Current lookahead token.
  Token Tok;

  SourceLocation ConsumeToken() {
    SourceLocation Loc = Tok.getLocation();
    L.lex(Tok);
    return Loc;
  }

public:
  BriefParser(Lexer &L, const CommandTraits &Traits);

  /// Return \\brief paragraph, if it exists; otherwise return the first
  /// paragraph.
  std::string Parse();
};

} // end namespace comments
} // end namespace clang

#endif

//===--- CommentBriefParser.h - Dumb comment parser -------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines a very simple Doxygen comment parser.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_AST_BRIEF_COMMENT_PARSER_H
#define LLVM_CLANG_AST_BRIEF_COMMENT_PARSER_H

#include "clang/AST/CommentLexer.h"

namespace clang {
namespace comments {

/// A very simple comment parser that extracts "a brief description".
///
/// Due to a variety of comment styles, it considers the following as "a brief
/// description", in order of priority:
/// \li a \\brief or \\short command,
/// \li the first paragraph,
/// \li a \\result or \\return or \\returns paragraph.
class BriefParser {
  Lexer &L;

  const CommandTraits &Traits;

  /// Current lookahead token.
  Token Tok;

  SourceLocation ConsumeToken() {
    SourceLocation Loc = Tok.getLocation();
    L.lex(Tok);
    return Loc;
  }

public:
  BriefParser(Lexer &L, const CommandTraits &Traits);

  /// Return the best "brief description" we can find.
  std::string Parse();
};

} // end namespace comments
} // end namespace clang

#endif

Update comment to match the reality.

Update comment to match the reality.

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


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

#if defined(DEVICE_TRNG)
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#endif

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

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

#if defined(DEVICE_TRNG)
#define MBEDTLS_ENTROPY_HARDWARE_ALT
#endif

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

Move mbed TLS configuration symbol to macro section

The configuration option for the mbed TLS specific hardware acceleration
has to be in the macro section and not in the device capabilities
section in targets.json.

The option has also been renamed to better reflect its function.


#ifndef AREA_H
#define AREA_H
#include "base.h"

typedef struct area area;
struct area{
  char name[10];
  int capacity;
  int areasAround;
  char ** adjec; // STRINGS SIZE ARE ALWAYS 10
};

void listAreas(area * a, int size);
void addArea(area * a, int size);
void deleteArea(area * a, int size);

#endif

#ifndef AREA_H
#define AREA_H
#include "base.h"

typedef struct area area;
struct area{
  char name[10];
  int capacity;
  int areasAround;
  char ** adjec; // STRINGS SIZE ARE ALWAYS 10
};

void listAreas(area * a, int size);
void addArea(area ** a, int *size);
void deleteArea(area ** a, int *size);

int checkAreaExist(area * z, int zSize, char * areaName);
int getAreaCapacity(area * z, int zSize, char * areaName);

#endif

Add Area capacity functions. Add addArea function


/*
name: TEST036
description: Duff's device
output:

*/

/* Disgusting, no?  But it compiles and runs just fine.  I feel a combination of
   pride and revulsion at this discovery.  If no one's thought of it before,
   I think I'll name it after myself.
   It amazes me that after 10 years of writing C there are still
   little corners that I haven't explored fully.
   - Tom Duff */

send(to, from, count)
	register short *to, *from;
	register count;
{
	register n=(count+7)/8;
	switch(count%8){
	case 0:      do{*to = *from++;
	case 7:           *to = *from++;
	case 6:           *to = *from++;
	case 5:           *to = *from++;
	case 4:           *to = *from++;
	case 3:           *to = *from++;
	case 2:           *to = *from++;
	case 1:           *to = *from++;
	                    }while(--n>0);
	}
}

Add test for Duff device

Add test for Duff device


#ifndef _POLYGON_H_
#define _POLYGON_H_

/*
 * geometric properties of the polygon meant for solving
 *
 * The default C pre-processor configuration here is to solve triangles.
 */

#define POLYGON_DEPTH           3
#if (POLYGON_DEPTH < 3)
#error You cannot have a polygon with fewer than 3 sides!
#endif
#if (POLYGON_DEPTH > 'Z' - 'A')
#error Angle labels are currently lettered.  Sorry for this limitation.
#endif

/*
 * All polygons have a fixed limit to the total measure of their angles.
 * For example, the angles of a triangle always sum up to 180 degrees.
 */
#define INTERIOR_DEGREES        (180 * ((POLYGON_DEPTH) - 2))

/*
 * Geometric lengths cannot be negative or zero.
 * We will reserve non-positive measures to indicate un-solved "unknowns".
 */
#define KNOWN(measure)          ((measure) > 0)

extern int solve_polygon(double * angles, double * sides);
extern int already_solved(double * angels, double * sides);

extern int find_angle(double * angles);
extern int find_side(double * sides, const double * angles);
extern int arc_find_angles(double * angles, const double * sides);

#endif

#ifndef _POLYGON_H_
#define _POLYGON_H_

/*
 * geometric properties of the polygon meant for solving
 *
 * The default C pre-processor configuration here is to solve triangles.
 */
#ifndef POLYGON_DEPTH
#define POLYGON_DEPTH           3
#endif

#if (POLYGON_DEPTH < 3)
#error You cannot have a polygon with fewer than 3 sides!
#endif
#if (POLYGON_DEPTH > 'Z' - 'A')
#error Angle labels are currently lettered.  Sorry for this limitation.
#endif

/*
 * All polygons have a fixed limit to the total measure of their angles.
 * For example, the angles of a triangle always sum up to 180 degrees.
 */
#define INTERIOR_DEGREES        (180 * ((POLYGON_DEPTH) - 2))

/*
 * Geometric lengths cannot be negative or zero.
 * We will reserve non-positive measures to indicate un-solved "unknowns".
 */
#define KNOWN(measure)          ((measure) > 0)

extern int solve_polygon(double * angles, double * sides);
extern int already_solved(double * angels, double * sides);

extern int find_angle(double * angles);
extern int find_side(double * sides, const double * angles);
extern int arc_find_angles(double * angles, const double * sides);

#endif

Allow POLYGON_DEPTH to be configurable by compile commands.


//
//  ASN1Decoder.h
//  ASN1Decoder
//
//  Created by Filippo Maguolo on 8/29/17.
//  Copyright © 2017 Filippo Maguolo. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for ASN1Decoder.
FOUNDATION_EXPORT double ASN1DecoderVersionNumber;

//! Project version string for ASN1Decoder.
FOUNDATION_EXPORT const unsigned char ASN1DecoderVersionString[];

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

Remove double whitespace on header file

Remove double whitespace on header file


/*
 * Copyright 2014, General Dynamics C4 Systems
 *
 * This software may be distributed and modified according to the terms of
 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
 * See "LICENSE_GPLv2.txt" for details.
 *
 * @TAG(GD_GPL)
 */

#ifndef __ARCH_MACHINE_CPU_REGISTERS_H
#define __ARCH_MACHINE_CPU_REGISTERS_H

#define CR0_MONITOR_COPROC  BIT(1)  /* Trap on FPU "WAIT" commands. */
#define CR0_EMULATION       BIT(2)  /* Enable OS emulation of FPU. */
#define CR0_TASK_SWITCH     BIT(3)  /* Trap on any FPU usage, for lazy FPU. */
#define CR0_NUMERIC_ERROR   BIT(5)  /* Internally handle FPU problems. */
#define CR4_OSFXSR          BIT(9)  /* Enable SSE et. al. features. */
#define CR4_OSXMMEXCPT      BIT(10) /* Enable SSE exceptions. */

/* We use a dummy variable to synchronize reads and writes to the control registers.
 * this allows us to write inline asm blocks that do not have enforced memory
 * clobbers for ordering. */
static unsigned long control_reg_order;

#include <mode/machine/cpu_registers.h>

#endif

/*
 * Copyright 2014, General Dynamics C4 Systems
 *
 * This software may be distributed and modified according to the terms of
 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
 * See "LICENSE_GPLv2.txt" for details.
 *
 * @TAG(GD_GPL)
 */

#ifndef __ARCH_MACHINE_CPU_REGISTERS_H
#define __ARCH_MACHINE_CPU_REGISTERS_H

#define CR0_MONITOR_COPROC  BIT(1)  /* Trap on FPU "WAIT" commands. */
#define CR0_EMULATION       BIT(2)  /* Enable OS emulation of FPU. */
#define CR0_TASK_SWITCH     BIT(3)  /* Trap on any FPU usage, for lazy FPU. */
#define CR0_NUMERIC_ERROR   BIT(5)  /* Internally handle FPU problems. */
#define CR4_OSFXSR          BIT(9)  /* Enable SSE et. al. features. */
#define CR4_OSXMMEXCPT      BIT(10) /* Enable SSE exceptions. */
#define CR4_OSXSAVE         BIT(18) /* Enavle XSAVE feature set */

/* We use a dummy variable to synchronize reads and writes to the control registers.
 * this allows us to write inline asm blocks that do not have enforced memory
 * clobbers for ordering. */
static unsigned long control_reg_order;

#include <mode/machine/cpu_registers.h>

#endif

Add missing CR4 bit definition

x86: Add missing CR4 bit definition


//
//  CWStatusBarNotification
//  CWNotificationDemo
//
//  Created by Cezary Wojcik on 11/15/13.
//  Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface CWStatusBarNotification : NSObject

enum {
    CWNotificationStyleStatusBarNotification,
    CWNotificationStyleNavigationBarNotification
};

enum {
    CWNotificationAnimationStyleTop,
    CWNotificationAnimationStyleBottom,
    CWNotificationAnimationStyleLeft,
    CWNotificationAnimationStyleRight
};

@property (strong, nonatomic) UIColor *notificationLabelBackgroundColor;
@property (strong, nonatomic) UIColor *notificationLabelTextColor;

@property (nonatomic) NSInteger notificationStyle;
@property (nonatomic) NSInteger notificationAnimationInStyle;
@property (nonatomic) NSInteger notificationAnimationOutStyle;
@property (nonatomic) BOOL notificationIsShowing;

- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration;
- (void)displayNotificationWithMessage:(NSString *)message completion:(void (^)(void))completion;
- (void)dismissNotification;

@end

//
//  CWStatusBarNotification
//  CWNotificationDemo
//
//  Created by Cezary Wojcik on 11/15/13.
//  Copyright (c) 2013 Cezary Wojcik. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface CWStatusBarNotification : NSObject

typedef NS_ENUM(NSInteger, CWNotificationStyle){
    CWNotificationStyleStatusBarNotification,
    CWNotificationStyleNavigationBarNotification
};

typedef NS_ENUM(NSInteger, CWNotificationAnimationStyle) {
    CWNotificationAnimationStyleTop,
    CWNotificationAnimationStyleBottom,
    CWNotificationAnimationStyleLeft,
    CWNotificationAnimationStyleRight
};

@property (strong, nonatomic) UIColor *notificationLabelBackgroundColor;
@property (strong, nonatomic) UIColor *notificationLabelTextColor;

@property (nonatomic) CWNotificationStyle notificationStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationInStyle;
@property (nonatomic) CWNotificationAnimationStyle notificationAnimationOutStyle;
@property (nonatomic) BOOL notificationIsShowing;

- (void)displayNotificationWithMessage:(NSString *)message forDuration:(CGFloat)duration;
- (void)displayNotificationWithMessage:(NSString *)message completion:(void (^)(void))completion;
- (void)dismissNotification;

@end

Make types for enums, add types to properties


/*
 *  Machine specific IO port address definition for generic.
 *  Written by Osamu Tomita <tomita@cinet.co.jp>
 */
#ifndef _MACH_IO_PORTS_H
#define _MACH_IO_PORTS_H

/* i8253A PIT registers */
#define PIT_MODE		0x43
#define PIT_CH0			0x40
#define PIT_CH2			0x42

/* i8259A PIC registers */
#define PIC_MASTER_CMD		0x20
#define PIC_MASTER_IMR		0x21
#define PIC_MASTER_ISR		PIC_MASTER_CMD
#define PIC_MASTER_POLL		PIC_MASTER_ISR
#define PIC_MASTER_OCW3		PIC_MASTER_ISR
#define PIC_SLAVE_CMD		0xa0
#define PIC_SLAVE_IMR		0xa1

/* i8259A PIC related value */
#define PIC_CASCADE_IR		2
#define MASTER_ICW4_DEFAULT	0x01
#define SLAVE_ICW4_DEFAULT	0x01
#define PIC_ICW4_AEOI		2

extern void setup_pit_timer(void);

#endif /* !_MACH_IO_PORTS_H */

/*
 *  Machine specific IO port address definition for generic.
 *  Written by Osamu Tomita <tomita@cinet.co.jp>
 */
#ifndef __ASM_I8253_H
#define __ASM_I8253_H

/* i8253A PIT registers */
#define PIT_MODE		0x43
#define PIT_CH0			0x40
#define PIT_CH2			0x42

/* i8259A PIC registers */
#define PIC_MASTER_CMD		0x20
#define PIC_MASTER_IMR		0x21
#define PIC_MASTER_ISR		PIC_MASTER_CMD
#define PIC_MASTER_POLL		PIC_MASTER_ISR
#define PIC_MASTER_OCW3		PIC_MASTER_ISR
#define PIC_SLAVE_CMD		0xa0
#define PIC_SLAVE_IMR		0xa1

/* i8259A PIC related value */
#define PIC_CASCADE_IR		2
#define MASTER_ICW4_DEFAULT	0x01
#define SLAVE_ICW4_DEFAULT	0x01
#define PIC_ICW4_AEOI		2

extern void setup_pit_timer(void);

#endif /* __ASM_I8253_H */

[MIPS] Fix include wrapper symbol to something sane.

And why are there i8253.h and 8253pit.h ...

Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>


/*
 * controldata_utils.h
 *		Common code for pg_controldata output
 *
 *	Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
 *	Portions Copyright (c) 1994, Regents of the University of California
 *
 *	src/include/common/controldata_utils.h
 */
#ifndef COMMON_CONTROLDATA_UTILS_H
#define COMMON_CONTROLDATA_UTILS_H

extern ControlFileData *get_controlfile(char *DataDir, const char *progname);

#endif   /* COMMON_CONTROLDATA_UTILS_H */

/*
 * controldata_utils.h
 *		Common code for pg_controldata output
 *
 *	Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
 *	Portions Copyright (c) 1994, Regents of the University of California
 *
 *	src/include/common/controldata_utils.h
 */
#ifndef COMMON_CONTROLDATA_UTILS_H
#define COMMON_CONTROLDATA_UTILS_H

#include "catalog/pg_control.h"

extern ControlFileData *get_controlfile(char *DataDir, const char *progname);

#endif   /* COMMON_CONTROLDATA_UTILS_H */

Add missing include for self-containment


/// @file
/// @brief Defines SpeciesDialog class.

#ifndef SPECIES_DIALOG_H
#define SPECIES_DIALOG_H

#include <memory>

#include <QWidget>
#include <QDialog>

#include "fish_detector/common/species.h"

namespace Ui {
  class SpeciesDialog;
}

namespace fish_detector {

class SpeciesDialog : public QDialog {
  Q_OBJECT
#ifndef NO_TESTING
  friend class TestSpeciesDialog;
#endif
public:
  /// @brief Constructor.
  ///
  /// @param parent Parent widget.
  explicit SpeciesDialog(QWidget *parent = 0);

  /// @brief Returns a Species object corresponding to the dialog values.
  ///
  /// @return Species object corresponding to the dialog values.
  Species getSpecies();

private slots:
  /// @brief Emits the accepted signal.
  void on_ok_clicked();

  /// @brief Emits the rejected signal.
  void on_cancel_clicked();

  /// @brief Removes currently selected subspecies.
  void on_removeSubspecies_clicked();

  /// @brief Adds a new subspecies.
  void on_addSubspecies_clicked();

private:
  /// @brief Widget loaded from ui file.
  std::unique_ptr<Ui::SpeciesDialog> ui_;
};

} // namespace fish_detector

#endif // SPECIES_DIALOG_H

/// @file
/// @brief Defines SpeciesDialog class.

#ifndef SPECIES_DIALOG_H
#define SPECIES_DIALOG_H

#include <memory>

#include <QWidget>
#include <QDialog>

#include "fish_detector/common/species.h"

namespace Ui {
  class SpeciesDialog;
}

namespace fish_detector {

class SpeciesDialog : public QDialog {
  Q_OBJECT
public:
  /// @brief Constructor.
  ///
  /// @param parent Parent widget.
  explicit SpeciesDialog(QWidget *parent = 0);

  /// @brief Returns a Species object corresponding to the dialog values.
  ///
  /// @return Species object corresponding to the dialog values.
  Species getSpecies();

private slots:
  /// @brief Calls inherited accept function.
  void on_ok_clicked();

  /// @brief Calls inherited reject function.
  void on_cancel_clicked();

  /// @brief Removes currently selected subspecies.
  void on_removeSubspecies_clicked();

  /// @brief Adds a new subspecies.
  void on_addSubspecies_clicked();

private:
  /// @brief Widget loaded from ui file.
  std::unique_ptr<Ui::SpeciesDialog> ui_;
};

} // namespace fish_detector

#endif // SPECIES_DIALOG_H

Remove unused friend class declaration

Remove unused friend class declaration


//
//  STTweetLabel.h
//  STTweetLabel
//
//  Created by Sebastien Thiebaud on 09/29/13.
//  Copyright (c) 2013 Sebastien Thiebaud. All rights reserved.
//

typedef enum {
    STTweetHandle = 0,
    STTweetHashtag,
    STTweetLink
} STTweetHotWord;

@interface STTweetLabel : UILabel

@property (nonatomic, strong) NSArray *validProtocols;
@property (nonatomic, assign) BOOL leftToRight;
@property (nonatomic, assign) BOOL textSelectable;
@property (nonatomic, strong) UIColor *selectionColor;
@property (nonatomic, copy) void (^detectionBlock)(STTweetHotWord hotWord, NSString *string, NSString *protocol, NSRange range);

- (void)setAttributes:(NSDictionary *)attributes;
- (void)setAttributes:(NSDictionary *)attributes hotWord:(STTweetHotWord)hotWord;

- (NSDictionary *)attributes;
- (NSDictionary *)attributesForHotWord:(STTweetHotWord)hotWord;

- (CGSize)suggestedFrameSizeToFitEntireStringConstraintedToWidth:(CGFloat)width;

@end

//
//  STTweetLabel.h
//  STTweetLabel
//
//  Created by Sebastien Thiebaud on 09/29/13.
//  Copyright (c) 2013 Sebastien Thiebaud. All rights reserved.
//

typedef NS_ENUM(NSInteger, STTweetHotWord) {
    STTweetHandle = 0,
    STTweetHashtag,
    STTweetLink
};

@interface STTweetLabel : UILabel

@property (nonatomic, strong) NSArray *validProtocols;
@property (nonatomic, assign) BOOL leftToRight;
@property (nonatomic, assign) BOOL textSelectable;
@property (nonatomic, strong) UIColor *selectionColor;
@property (nonatomic, copy) void (^detectionBlock)(STTweetHotWord hotWord, NSString *string, NSString *protocol, NSRange range);

- (void)setAttributes:(NSDictionary *)attributes;
- (void)setAttributes:(NSDictionary *)attributes hotWord:(STTweetHotWord)hotWord;

- (NSDictionary *)attributes;
- (NSDictionary *)attributesForHotWord:(STTweetHotWord)hotWord;

- (CGSize)suggestedFrameSizeToFitEntireStringConstraintedToWidth:(CGFloat)width;

@end

Make enum available to swift

Make enum available to swift


//
//  MenuItemKit.h
//  MenuItemKit
//
//  Created by CHEN Xian’an on 1/16/16.
//  Copyright © 2016 lazyapps. All rights reserved.
//

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

//! Project version number for MenuItemKit.
FOUNDATION_EXPORT double MenuItemKitVersionNumber;

//! Project version string for MenuItemKit.
FOUNDATION_EXPORT const unsigned char MenuItemKitVersionString[];

//
//  MenuItemKit.h
//  MenuItemKit
//
//  Created by CHEN Xian’an on 1/16/16.
//  Copyright © 2016 lazyapps. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <MenuItemKit/Headers.h>

//! Project version number for MenuItemKit.
FOUNDATION_EXPORT double MenuItemKitVersionNumber;

//! Project version string for MenuItemKit.
FOUNDATION_EXPORT const unsigned char MenuItemKitVersionString[];

Use brackets for headers as Xcode suggested


//
//  RMGallery.h
//  RMGallery
//
//  Created by Hermés Piqué on 16/05/14.
//  Copyright (c) 2014 Robot Media. All rights reserved.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//

#import "RMGalleryViewController.h"
#import "RMGalleryTransition.h"

Add new line at end of file to fix build


//
//  FTFountainiOS.h
//  FTFountain
//
//  Created by Tobias Kräntzer on 18.07.15.
//  Copyright (c) 2015 Tobias Kräntzer. All rights reserved.
//

// Adapter
#import "FTTableViewAdapter.h"
#import "FTCollectionViewAdapter.h"

//
//  FTFountainiOS.h
//  FTFountain
//
//  Created by Tobias Kräntzer on 18.07.15.
//  Copyright (c) 2015 Tobias Kräntzer. All rights reserved.
//

// Adapter
#import "FTTableViewAdapter.h"
#import "FTTableViewAdapter+Subclassing.h"
#import "FTCollectionViewAdapter.h"
#import "FTCollectionViewAdapter+Subclassing.h"

Add subclassing headers for the table and collection view adapter to the umbrella header


#pragma once

#include "SDL.h"
#include "Component.h"
#include "Point.h"

#define NUM_MOUSE_BUTTONS 5
#define CONTROLLER_JOYSTICK_DEATHZONE 8000

class Input
{
public:
	Input();
	~Input();

	void Poll(const SDL_Event& e);

	bool IsKeyPressed(SDL_Scancode key);
	bool IsKeyHeld(SDL_Scancode key) const;
	bool IsKeyReleased(SDL_Scancode key);

	SDL_GameController *controller1 = nullptr;
	SDL_GameController *controller2 = nullptr;
	bool IsControllerButtonPressed(SDL_GameController* controller, SDL_GameControllerButton button);
	bool IsControllerButtonHeld(SDL_GameController* controller, SDL_GameControllerButton button) const;
	bool IsControllerButtonReleased(SDL_GameController* controller, SDL_GameControllerButton button);

	bool IsMouseButtonPressed(int button) const;
	bool IsMouseButtonHeld(int button) const;
	bool IsMouseButtonReleased(int button) const;

	float MouseX() const;
	float MouseY() const;

	Point GetMousePosition(Point& position) const;

private:
	bool keys[SDL_NUM_SCANCODES];
	bool lastKeys[SDL_NUM_SCANCODES];

	bool lastControllerButtons[SDL_CONTROLLER_BUTTON_MAX];
	void OpenControllers();

	bool mouseButtons[NUM_MOUSE_BUTTONS];
	bool lastMouseButtons[NUM_MOUSE_BUTTONS];
};

#pragma once

#include "SDL.h"
#include "Component.h"
#include "Point.h"

#define NUM_MOUSE_BUTTONS 5
#define CONTROLLER_JOYSTICK_DEATHZONE 8000

class Input
{
public:
	Input();
	~Input();

	void Poll(const SDL_Event& e);

	bool IsKeyPressed(SDL_Scancode key);
	bool IsKeyHeld(SDL_Scancode key) const;
	bool IsKeyReleased(SDL_Scancode key);

	SDL_GameController *controller1 = nullptr;
	SDL_GameController *controller2 = nullptr;
	bool IsControllerButtonPressed(SDL_GameController* controller, SDL_GameControllerButton button);
	bool IsControllerButtonHeld(SDL_GameController* controller, SDL_GameControllerButton button) const;
	bool IsControllerButtonReleased(SDL_GameController* controller, SDL_GameControllerButton button);

	bool IsMouseButtonPressed(int button) const;
	bool IsMouseButtonHeld(int button) const;
	bool IsMouseButtonReleased(int button) const;

	float MouseX() const;
	float MouseY() const;

	Point GetMousePosition(Point& position) const;

private:
	bool keys[SDL_NUM_SCANCODES];
	bool lastKeys[SDL_NUM_SCANCODES];

	bool lastControllerButtons[SDL_CONTROLLER_BUTTON_MAX];
	void OpenControllers();

	bool mouseButtons[NUM_MOUSE_BUTTONS];
	bool lastMouseButtons[NUM_MOUSE_BUTTONS];

	//Might need SDL_MouseMotionEvent instead
	//Point mousePosition;
};

Add mousePosition as Point, now commented for reworking


#include <stdio.h>
#include <linux/types.h>
#include <unistd.h>
#include <fcntl.h>

int main (int argc, char * argv [])
{
    __u64 rdtsc = 0;
    __u64 i     = 0;
    int fileStat = open (argv [1], O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
    while (read (fileStat, &rdtsc,  sizeof (rdtsc) ) > 0) {
        printf ("%llu:\t%llu\n", ++i, rdtsc);
    }
    close (fileStat);
}

#include <stdio.h>
#include <linux/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>

int main (int argc, char * argv [])
{
    __u64 rdtsc = 0;
    __u64 i     = 0;
    int fileStat = open (argv [1], O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
    while (read (fileStat, &rdtsc,  sizeof (rdtsc) ) > 0) {
        printf ("%llu:\t%llu\n", ++i, rdtsc);
    }
    close (fileStat);

    return EXIT_SUCCESS;
}

Fix trivial error: return void in main function.


#define _FILE_OFFSET_BITS 64

#include <fcntl.h>

int native_fallocate(int fd, uint64_t len) {
    fstore_t fstore;
    fstore.fst_flags = F_ALLOCATECONTIG;
    fstore.fst_posmode = F_PEOFPOSMODE;
    fstore.fst_offset = 0;
    fstore.fst_length = len;
    fstore.fst_bytesalloc = 0;
    return fcntl(fd, F_PREALLOCATE, &fstore);
}

#define _FILE_OFFSET_BITS 64

#include <fcntl.h>
#include <stdint.h>

int native_fallocate(int fd, uint64_t len) {
    fstore_t fstore;
    fstore.fst_flags = F_ALLOCATECONTIG;
    fstore.fst_posmode = F_PEOFPOSMODE;
    fstore.fst_offset = 0;
    fstore.fst_length = len;
    fstore.fst_bytesalloc = 0;
    return fcntl(fd, F_PREALLOCATE, &fstore);
}

Add proper header for darwin build

Add proper header for darwin build


// RUN: clang -emit-llvm -S -o %t1.ll %s &&
// RUN: clang -emit-ast -o %t.ast %s &&
// RUN: clang -emit-llvm -S -o %t2.ll %t.ast &&
// RUN: diff %t1.ll %t2.ll
// XFAIL: *

int main() {
  return 0;
}

Add an XFAIL test which compiles differently from a .ast.

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


//use a different header for this section as it needs
//the boost pre-processor

//next step is to convert the boost mpl types back to a worklet
//signature. To get this to work with all functor we need to use
//boost pre-processor
#if !BOOST_PP_IS_ITERATING
# ifndef __buildSignature_
# define __buildSignature_

#  include <boost/mpl/at.hpp>
#  include <boost/preprocessor/iteration/iterate.hpp>
#  include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#  include <boost/preprocessor/repetition/enum_shifted.hpp>

#  define _arg_enum___(x)      BOOST_PP_ENUM_SHIFTED(BOOST_PP_ITERATION(), _arg_enum_, x)
#  define _arg_enum_(z,n,x)    x(n)
#  define _MPL_ARG_(n) typename boost::mpl::at_c<T,n>::type

namespace detail
  {
  template<int N, typename T> struct BuildSig;

# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 11, "BuildSignature.h"))
# include BOOST_PP_ITERATE()
  }

template<typename T>
struct BuildSignature
{
  typedef boost::mpl::size<T> Size;

  typedef typename ::detail::BuildSig<Size::value,T>::type type;
};

# endif

#else
  template<typename T> struct BuildSig<BOOST_PP_ITERATION(), T>
  {
    typedef typename boost::mpl::at_c<T,0>::type type(_arg_enum___(_MPL_ARG_));

  };
#endif

Add code to build arbitrary length function signature from mpl.


// Copyright 2016 Mitchell Kember. Subject to the MIT License.

#include "translate.h"
#include "transmit.h"
#include "util.h"

#include <stdio.h>
#include <unistd.h>

int main(int argc, char **argv) {
	setup_util(argv[0]);

	// Initialize the default mode.
	int mode = 'e';

	// Get command line options.
	int c;
	extern char *optarg;
	extern int optind, optopt;
	while ((c = getopt(argc, argv, "hedt")) != -1) {
		switch (c) {
		case 'h':
			print_usage(stdout);
			return 0;
		case 'e':
		case 'd':
		case 't':
			mode = c;
			break;
		case '?':
			return 1;
		}
	}
	// Make sure all arguments were processed.
	if (optind != argc) {
		print_usage(stderr);
		return 1;
	}

	// Dispatch to the chosen subprogram.
	switch (mode) {
	case 'e':
		return encode();
	case 'd':
		return decode();
	case 't':
		return transmit();
	}
}

// Copyright 2016 Mitchell Kember. Subject to the MIT License.

#include "translate.h"
#include "transmit.h"
#include "util.h"

#include <stdio.h>
#include <unistd.h>

int main(int argc, char **argv) {
	setup_util(argv[0]);

	// Initialize the default mode.
	int mode = 'e';

	// Get command line options.
	int c;
	extern char *optarg;
	extern int optind, optopt;
	while ((c = getopt(argc, argv, "hedt")) != -1) {
		switch (c) {
		case 'h':
			print_usage(stdout);
			return 0;
		case 'e':
		case 'd':
		case 't':
			mode = c;
			break;
		case '?':
			print_usage(stderr);
			return 1;
		}
	}
	// Make sure all arguments were processed.
	if (optind != argc) {
		print_usage(stderr);
		return 1;
	}

	// Dispatch to the chosen subprogram.
	switch (mode) {
	case 'e':
		return encode();
	case 'd':
		return decode();
	case 't':
		return transmit();
	}
}

Print usage message on getopt error

Print usage message on getopt error


// PARAM: --sets solver td3 --enable ana.int.congruence --disable ana.int.def_exc
int main(){
    // A refinement of a congruence class should only take place for the == and != operator.
    int i;
    if (i==0){
      assert(i==0);
    } else {
      assert(i!=0); //UNKNOWN!
    }

    int j;
    if (j != 0){
      assert (j != 0); //UNKNOWN!
    } else {
      assert (j == 0);
    }

    int k;
    if (k > 0) {
      assert (k == 0); //UNKNOWN!
    } else {
      assert (k != 0); //UNKNOWN!
    }

    return 0;
}

Add branching test for congruence domain


#ifndef LOCK_H
#define LOCK_H

enum lockstat
{
	GET_LOCK_NOT_GOT=0,
	GET_LOCK_ERROR,
	GET_LOCK_GOT
};

typedef struct lock lock_t;

struct lock
{
	int fd;
	enum lockstat status;
	char *path;
	lock_t *next;
};

extern struct lock *lock_alloc(void);
extern int lock_init(struct lock *lock, const char *path);
extern struct lock *lock_alloc_and_init(const char *path);
extern void lock_free(struct lock **lock);

// Need to test lock->status to find out what happened when calling these.
extern void lock_get_quick(struct lock *lock);
extern void lock_get(struct lock *lock);

extern int lock_test(const char *path);
extern int lock_release(struct lock *lock);

extern void lock_add_to_list(struct lock **locklist, struct lock *lock);
extern void locks_release_and_free(struct lock **locklist);

#endif

#ifndef LOCK_H
#define LOCK_H

enum lockstat
{
	GET_LOCK_NOT_GOT=0,
	GET_LOCK_ERROR,
	GET_LOCK_GOT
};

struct lock
{
	int fd;
	enum lockstat status;
	char *path;
	struct lock *next;
};

extern struct lock *lock_alloc(void);
extern int lock_init(struct lock *lock, const char *path);
extern struct lock *lock_alloc_and_init(const char *path);
extern void lock_free(struct lock **lock);

// Need to test lock->status to find out what happened when calling these.
extern void lock_get_quick(struct lock *lock);
extern void lock_get(struct lock *lock);

extern int lock_test(const char *path);
extern int lock_release(struct lock *lock);

extern void lock_add_to_list(struct lock **locklist, struct lock *lock);
extern void locks_release_and_free(struct lock **locklist);

#endif

Fix a build issue on Solaris

Fix a build issue on Solaris


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

#ifndef SkSpinlock_DEFINED
#define SkSpinlock_DEFINED

#include <atomic>

class SkSpinlock {
public:
    void acquire() {
        // To act as a mutex, we need an acquire barrier when we acquire the lock.
        if (fLocked.exchange(true, std::memory_order_acquire)) {
            // Lock was contended.  Fall back to an out-of-line spin loop.
            this->contendedAcquire();
        }
    }

    void release() {
        // To act as a mutex, we need a release barrier when we release the lock.
        fLocked.store(false, std::memory_order_release);
    }

private:
    void contendedAcquire();

    std::atomic<bool> fLocked{false};
};

#endif//SkSpinlock_DEFINED

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

#ifndef SkSpinlock_DEFINED
#define SkSpinlock_DEFINED

#include "SkTypes.h"
#include <atomic>

class SkSpinlock {
public:
    void acquire() {
        // To act as a mutex, we need an acquire barrier when we acquire the lock.
        if (fLocked.exchange(true, std::memory_order_acquire)) {
            // Lock was contended.  Fall back to an out-of-line spin loop.
            this->contendedAcquire();
        }
    }

    void release() {
        // To act as a mutex, we need a release barrier when we release the lock.
        fLocked.store(false, std::memory_order_release);
    }

private:
    SK_API void contendedAcquire();

    std::atomic<bool> fLocked{false};
};

#endif//SkSpinlock_DEFINED

Make Cmake work with debug build

Make Cmake work with debug build

Before this CL, the following failed to link:

    cd .../skia
    git fetch
    git checkout origin/master
    git clean -ffdx
    SKIA="$PWD"
    cd $(mktemp -d);
    cmake "${SKIA}/cmake" -DCMAKE_BUILD_TYPE=Debug -G Ninja
    ninja
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1757993006

Review URL: https://codereview.chromium.org/1757993006


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * 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.
 */

#ifndef NRFX_CONFIG_H__
#define NRFX_CONFIG_H__

#if NRF52
#include "../../nrf52xxx-compat/include/nrfx52_config.h"
#elif NRF52840_XXAA
#include "../../nrf52xxx-compat/include/nrfx52840_config.h"
#else
#error Unsupported chip selected
#endif

#endif // NRFX_CONFIG_H__

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * 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.
 */

#ifndef NRFX_CONFIG_H__
#define NRFX_CONFIG_H__

#if NRF52
#include "nrfx52_config.h"
#elif NRF52840_XXAA
#include "nrfx52840_config.h"
#else
#error Unsupported chip selected
#endif

#endif // NRFX_CONFIG_H__

Fix weird includes in compat package

hw/mcu/nordic: Fix weird includes in compat package


#include <string>
#include <vector>
#ifndef __hpux
using namespace std;
#endif

#pragma create TClass vector<bool>;
#pragma create TClass vector<char>;
#pragma create TClass vector<short>;
#pragma create TClass vector<long>;
#pragma create TClass vector<unsigned char>;
#pragma create TClass vector<unsigned short>;
#pragma create TClass vector<unsigned int>;
#pragma create TClass vector<unsigned long>;
#pragma create TClass vector<float>;
#pragma create TClass vector<double>;
#pragma create TClass vector<char*>;
#pragma create TClass vector<const char*>;
#pragma create TClass vector<string>;

#if (!(G__GNUC==3 && G__GNUC_MINOR==1)) && !defined(G__KCC) && (!defined(G__VISUAL) || G__MSC_VER<1300)
// gcc3.1,3.2 has a problem with iterator<void*,...,void&>
#pragma create TClass vector<void*>;
#endif

#include <string>
#include <vector>
#ifndef __hpux
using namespace std;
#endif

#pragma create TClass vector<bool>;
#pragma create TClass vector<char>;
#pragma create TClass vector<short>;
#pragma create TClass vector<long>;
#pragma create TClass vector<unsigned char>;
#pragma create TClass vector<unsigned short>;
#pragma create TClass vector<unsigned int>;
#pragma create TClass vector<unsigned long>;
#pragma create TClass vector<float>;
#pragma create TClass vector<double>;
#pragma create TClass vector<char*>;
#pragma create TClass vector<const char*>;
#pragma create TClass vector<string>;
#pragma create TClass vector<Long64_t>;
#pragma create TClass vector<ULong64_t>;

#if (!(G__GNUC==3 && G__GNUC_MINOR==1)) && !defined(G__KCC) && (!defined(G__VISUAL) || G__MSC_VER<1300)
// gcc3.1,3.2 has a problem with iterator<void*,...,void&>
#pragma create TClass vector<void*>;
#endif

Add missing TClass creation for vector<Long64_t> and vector<ULong64_t>

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@38659 27541ba8-7e3a-0410-8455-c3a389f83636


//===-- memory.c - String functions for the LLVM libc Library ----*- C -*-===//
//
// A lot of this code is ripped gratuitously from glibc and libiberty.
//
//===----------------------------------------------------------------------===//

#include <stdlib.h>

void *malloc(size_t) __attribute__((weak));
void free(void *) __attribute__((weak));
void *memset(void *, int, size_t) __attribute__((weak));
void *calloc(size_t nelem, size_t elsize) __attribute__((weak));

void *calloc(size_t nelem, size_t elsize) {
  void *Result = malloc(nelem*elsize);
  return memset(Result, 0, nelem*elsize);
}

//===-- memory.c - String functions for the LLVM libc Library ----*- C -*-===//
//
// A lot of this code is ripped gratuitously from glibc and libiberty.
//
//===---------------------------------------------------------------------===//

#include <stdlib.h>

// If we're not being compiled with GCC, turn off attributes. Question is how
// to handle overriding of memory allocation functions in that case.
#ifndef __GNUC__
#define __attribute__(X)
#endif

// For now, turn off the weak linkage attribute on Mac OS X.
#if defined(__GNUC__) && defined(__APPLE_CC__)
#define __ATTRIBUTE_WEAK__
#elif defined(__GNUC__)
#define __ATTRIBUTE_WEAK__ __attribute__((weak))
#else
#define __ATTRIBUTE_WEAK__
#endif

void *malloc(size_t) __ATTRIBUTE_WEAK__;
void free(void *) __ATTRIBUTE_WEAK__;
void *memset(void *, int, size_t) __ATTRIBUTE_WEAK__;
void *calloc(size_t nelem, size_t elsize) __ATTRIBUTE_WEAK__;

void *calloc(size_t nelem, size_t elsize) {
  void *Result = malloc(nelem*elsize);
  return memset(Result, 0, nelem*elsize);
}

Disable __attribute__((weak)) on Mac OS X and other lame platforms.

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


/*===-- EdgeProfiling.c - Support library for edge profiling --------------===*\
|*
|*                     The LLVM Compiler Infrastructure
|*
|* This file was developed by the LLVM research group and is distributed under
|* the University of Illinois Open Source License. See LICENSE.TXT for details.
|*
|*===----------------------------------------------------------------------===*|
|*
|* This file implements the call back routines for the edge profiling
|* instrumentation pass.  This should be used with the -insert-edge-profiling
|* LLVM pass.
|*
\*===----------------------------------------------------------------------===*/

#include "Profiling.h"
#include <stdlib.h>

static unsigned *ArrayStart;
static unsigned NumElements;

/* EdgeProfAtExitHandler - When the program exits, just write out the profiling
 * data.
 */
static void EdgeProfAtExitHandler() {
  /* Note that if this were doing something more intellegent with the
     instrumentation, that we could do some computation here to expand what we
     collected into simple edge profiles.  Since we directly count each edge, we
     just write out all of the counters directly.
  */
  write_profiling_data(Edge, ArrayStart, NumElements);
}

/* llvm_start_edge_profiling - This is the main entry point of the edge
 * profiling library.  It is responsible for setting up the atexit handler.
 */
int llvm_start_edge_profiling(int argc, const char **argv,
                              unsigned *arrayStart, unsigned numElements) {
  int Ret = save_arguments(argc, argv);
  ArrayStart = arrayStart;
  NumElements = numElements;
  atexit(EdgeProfAtExitHandler);
  return Ret;
}

Add edge profiling support to the runtime library

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


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

void *t_fun(int arg) {
  assert(arg == 3); // TODO (cast through void*)
  return NULL;
}

int main(void) {
  int x = 3;

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

  return 0;
}

Add octApron test where thread function has tracked arg


//
//  TrackingControllerDefs.h
//
//  Created by Matt Martel on 02/20/09
//  Copyright Mundue LLC 2008-2011. All rights reserved.
//

// Create an account at http://www.flurry.com
// Code and integration instructions at
// http://dev.flurry.com/createProjectSelectPlatform.do
#define USES_FLURRY
#define kFlurryAPIKey @"YOUR_FLURRY_API_KEY"

// Create an account at http://www.localytics.com
// Code and integration instructions at
//  http://wiki.localytics.com/doku.php
#define USES_LOCALYTICS
#define kLocalyticsAppKey @"YOUR_LOCALITICS_APP_KEY"

// Create an account at http://www.google.com/analytics
// Code and integration instructions at
// http://code.google.com/mobile/analytics/docs/iphone/
#define USES_GANTRACKER
#define kGANAccountIDKey @"YOUR_GOOGLE_ANALYTICS_ACCOUNT_ID"
#define kGANCategoryKey @"YOUR_APP_NAME"

//
//  TrackingControllerDefs.h
//
//  Created by Matt Martel on 02/20/09
//  Copyright Mundue LLC 2008-2011. All rights reserved.
//

// Create an account at http://www.flurry.com
// Code and integration instructions at
// http://dev.flurry.com/createProjectSelectPlatform.do
// Uncomment the following two lines to use Flurry
//#define USES_FLURRY
//#define kFlurryAPIKey @"YOUR_FLURRY_API_KEY"

// Create an account at http://www.localytics.com
// Code and integration instructions at
//  http://wiki.localytics.com/doku.php
// Uncomment the following two lines to use Localytics
//#define USES_LOCALYTICS
//#define kLocalyticsAppKey @"YOUR_LOCALITICS_APP_KEY"

// Create an account at http://www.google.com/analytics
// Code and integration instructions at
// http://code.google.com/mobile/analytics/docs/iphone/
// Uncomment the following three lines to use Google Analytics
//#define USES_GANTRACKER
//#define kGANAccountIDKey @"YOUR_GOOGLE_ANALYTICS_ACCOUNT_ID"
//#define kGANCategoryKey @"YOUR_APP_NAME"

Comment out services by default

Comment out services by default


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

#ifndef __CROS_EC_IOEXPANDER_PCA9555_H
#define __CROS_EC_IOEXPANDER_PCA9555_H

#include "i2c.h"

#define PCA9555_CMD_INPUT_PORT_0		0
#define PCA9555_CMD_INPUT_PORT_1		1
#define PCA9555_CMD_OUTPUT_PORT_0		2
#define PCA9555_CMD_OUTPUT_PORT_1		3
#define PCA9555_CMD_POLARITY_INVERSION_PORT_0	4
#define PCA9555_CMD_POLARITY_INVERSION_PORT_1	5
#define PCA9555_CMD_CONFIGURATION_PORT_0	6
#define PCA9555_CMD_CONFIGURATION_PORT_1	7

#define PCA9555_IO_0	(1 << 0)
#define PCA9555_IO_1	(1 << 1)
#define PCA9555_IO_2	(1 << 2)
#define PCA9555_IO_3	(1 << 3)
#define PCA9555_IO_4	(1 << 4)
#define PCA9555_IO_5	(1 << 5)
#define PCA9555_IO_6	(1 << 6)
#define PCA9555_IO_7	(1 << 7)

static inline int pca9555_read(int port, int addr, int reg, int *data_ptr)
{
	return i2c_read8(port, addr, reg, data_ptr);
}

static inline int pca9555_write(int port, int addr, int reg, int data)
{
	return i2c_write8(port, addr, reg, data);
}

#endif /* __CROS_EC_IOEXPANDER_PCA9555_H */

driver: Add driver header for PCA9555 I/O port controller

BUG=b:64394037
BRANCH=glkrvp
TEST=Manually tested on GLKRVP, i2cxfer works

Change-Id: If65e5039987ecbb7fa2a3a5eeeef5af6d73ab66a
Signed-off-by: Vijay Hiremath <006c712879a3af08bfdb5c2b8491a8b2d5fd73cd@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/603987
Commit-Ready: Vijay P Hiremath <006c712879a3af08bfdb5c2b8491a8b2d5fd73cd@intel.com>
Tested-by: Vijay P Hiremath <006c712879a3af08bfdb5c2b8491a8b2d5fd73cd@intel.com>
Reviewed-by: Aaron Durbin <af0622ab041e8b0f8e5819838dcc93898196e71f@chromium.org>
Reviewed-by: Aseda Aboagye <12c9b286316a940fd31c24070da5ab64cdd4d0e7@chromium.org>


#include <stdio.h>

int main() {
    int d, dd, h, hh, m, mm, s, ss;

    scanf("Dia %d", &d);
    scanf("%d : %d : %d\n", &h, &m, &s);
    scanf("Dia %d", &dd);
    scanf("%d : %d : %d", &hh, &mm, &ss);

    s = ss - s;
    m = mm - m;
    h = hh - h;
    d = dd - d;

    if (s < 0) {
        s += 60;
        m--;
    }

    if (m < 0) {
        m += 60;
        h--;
    }

    if (h < 0) {
        h += 24;
        d--;
    }

    printf("%d dia(s)\n", d);
    printf("%d hora(s)\n", h);
    printf("%d minuto(s)\n", m);
    printf("%d segundo(s)\n", s);

    return 0;
}

Solve Event Time in c

Solve Event Time in c


/* Tests for preprocessor rules, comments, line continuations, etc.*/

#include <sys/neutrino.h>   // comment
#include <sys/mman.h>       // comment

#include <xxx.h> // comment \
	comment
REGULAR LINE

#include <xxx.h> // comment \

REGULAR LINE

#include \
<xxx.h>
<REGULAR LINE>

#define macro // comment \
	comment
#define macro() /* block comment \
	comment */ body \
#define NOT_A_NAME, still the body \
	void not_a_function(void) {}

#define exprintf(expr,         \
		/* optional */ msg...) \
	__exprintf(#expr,  \
		(int) (expr),  \
		"%s: %d\n" msg)
#define __exprintf(str_expr, \
		expr, fmt, args...)  \
	printf(fmt, \
		str_expr, expr, ##args)

#if 0
#define COMMENT
comment
#endif

// comment \
// comment \
still a comment
REGULAR LINE

// comment /* block */ comment

#assert <- DEPRECATED
#sdfasd <- INVALID
#line

Add a test for line-based rules

lex-continuation: Add a test for line-based rules

I.e. # preprocessor directives, // line comments, \ line continuations
and their inter-op.


#ifndef __TRAIN_MASTER_H__
#define __TRAIN_MASTER_H__

void __attribute__ ((noreturn)) train_master();

typedef enum {
    MASTER_CHANGE_SPEED,
    MASTER_REVERSE,  // step 1
    MASTER_REVERSE2, // step 2 (used by delay courier)
    MASTER_REVERSE3, // step 3 (used by delay courier)
    MASTER_WHERE_ARE_YOU,
    MASTER_STOP_AT_SENSOR,
    MASTER_GOTO_LOCATION,
    MASTER_DUMP_VELOCITY_TABLE,

    MASTER_UPDATE_FEEDBACK_THRESHOLD,
    MASTER_UPDATE_FEEDBACK_ALPHA,
    MASTER_UPDATE_STOP_OFFSET,
    MASTER_UPDATE_CLEARANCE_OFFSET,

    MASTER_ACCELERATION_COMPLETE,
    MASTER_NEXT_NODE_ESTIMATE,

    MASTER_SENSOR_FEEDBACK,
    MASTER_UNEXPECTED_SENSOR_FEEDBACK
} master_req_type;

typedef struct {
    master_req_type type;
    int  arg1;
    int  arg2;
    int  arg3;
} master_req;

#endif

#ifndef __TRAIN_MASTER_H__
#define __TRAIN_MASTER_H__

void __attribute__ ((noreturn)) train_master();

typedef enum {
    MASTER_CHANGE_SPEED,
    MASTER_REVERSE,  // step 1
    MASTER_REVERSE2, // step 2 (used by delay courier)
    MASTER_REVERSE3, // step 3 (used by delay courier)
    MASTER_WHERE_ARE_YOU,
    MASTER_STOP_AT_SENSOR,
    MASTER_GOTO_LOCATION,
    MASTER_DUMP_VELOCITY_TABLE,

    MASTER_UPDATE_FEEDBACK_THRESHOLD,
    MASTER_UPDATE_FEEDBACK_ALPHA,
    MASTER_UPDATE_STOP_OFFSET,
    MASTER_UPDATE_CLEARANCE_OFFSET,

    MASTER_ACCELERATION_COMPLETE,
    MASTER_NEXT_NODE_ESTIMATE,

    MASTER_SENSOR_FEEDBACK,
    MASTER_UNEXPECTED_SENSOR_FEEDBACK
} master_req_type;

typedef struct {
    master_req_type type;
    int  arg1;
    int  arg2;
} master_req;

#endif

Remove unused argument space from master req


//
//  BotKit.h
//  BotKit
//
//  Created by Mark Adams on 9/28/12.
//  Copyright (c) 2012 thoughtbot. All rights reserved.
//

#import "BKCoreDataManager.h"
#import "BKManagedViewController.h"
#import "BKManagedTableViewController.h"
#import "NSObject+BKCoding.h"
#import "NSArray+ObjectAccess.h"
#import "NSDate+RelativeDates.h"
#import "UIColor+AdjustColor.h"
#import "UIColor+Serialization.h"

/*

TODOS:

BKImageLoader
 -imageWithContentsOfURL:completionHandler:
 -imageWithContentsOFURLPath:completionHandler:

UIImage:
 +imageWithContentsOfURLPath:

NSURLRequest:
 +requestWithString:
 +requestWithURL:

NSDate:
 -dateStringWithFormat:
 -dateStringWithStyle:

*/

//
//  BotKit.h
//  BotKit
//
//  Created by Mark Adams on 9/28/12.
//  Copyright (c) 2012 thoughtbot. All rights reserved.
//

#import "BKCoreDataManager.h"
#import "BKManagedViewController.h"
#import "BKManagedTableViewController.h"
#import "NSObject+BKCoding.h"
#import "NSArray+ObjectAccess.h"
#import "NSDate+RelativeDates.h"
#import "UIColor+AdjustColor.h"
#import "UIColor+Serialization.h"
#import "NSData+Base64Encoding.h"

/*

TODOS:

BKImageLoader
 -imageWithContentsOfURL:completionHandler:
 -imageWithContentsOFURLPath:completionHandler:

UIImage:
 +imageWithContentsOfURLPath:

NSURLRequest:
 +requestWithString:
 +requestWithURL:

NSDate:
 -dateStringWithFormat:
 -dateStringWithStyle:

*/

Add NSData+Base64Encoding.h to main header


#include "log.h"
#include "timeutil.h"
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static bool flushAfterLog = false;

void proxyLogSetFlush(bool enabled)
{
  flushAfterLog = enabled;
}

void proxyLog(const char* format, ...)
{
  va_list args;

  va_start(args, format);

  printTimeString();
  printf(" ");
  vprintf(format, args);
  printf("\n");

  if (flushAfterLog)
  {
    fflush(stdout);
  }

  va_end(args);
}

#include "log.h"
#include "timeutil.h"
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static bool flushAfterLog = false;

void proxyLogSetFlush(bool enabled)
{
  flushAfterLog = enabled;
}

void proxyLog(const char* format, ...)
{
  va_list args;

  va_start(args, format);

  printTimeString();
  putchar(' ');
  vprintf(format, args);
  putchar('\n');

  if (flushAfterLog)
  {
    fflush(stdout);
  }

  va_end(args);
}

Use putchar instead of printf.

Use putchar instead of printf.


#include <stdio.h>
#include <mpi.h>
#include <Python.h>

const char helloworld[] = \
  "from mpi4py import MPI				 \n"
  "hwmess = 'Hello, World! I am process %d of %d on %s.' \n"
  "myrank = MPI.COMM_WORLD.Get_rank()			 \n"
  "nprocs = MPI.COMM_WORLD.Get_size()			 \n"
  "procnm = MPI.Get_processor_name()			 \n"
  "print (hwmess % (myrank, nprocs, procnm))             \n"
  "";

int main(int argc, char *argv[])
{
  int ierr, rank, size;

  ierr = MPI_Init(&argc, &argv);
  ierr = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  ierr = MPI_Comm_size(MPI_COMM_WORLD, &size);

  MPI_Barrier(MPI_COMM_WORLD);
  Py_Initialize();
  PyRun_SimpleString(helloworld);
  Py_Finalize();
  MPI_Barrier(MPI_COMM_WORLD);

  if (rank == 0) {
    printf("\n");
    fflush(stdout);
    fflush(stderr);
  }

  MPI_Barrier(MPI_COMM_WORLD);
  Py_Initialize();
  PyRun_SimpleString(helloworld);
  Py_Finalize();
  MPI_Barrier(MPI_COMM_WORLD);

  ierr = MPI_Finalize();
  return 0;
}

/*
 *  You can use safely use mpi4py between multiple
 *  Py_Initialize()/Py_Finalize() calls ...
 *  but do not blame me for the memory leaks ;-)
 *
 */

#include <mpi.h>
#include <Python.h>

const char helloworld[] = \
  "from mpi4py import MPI				 \n"
  "hwmess = 'Hello, World! I am process %d of %d on %s.' \n"
  "myrank = MPI.COMM_WORLD.Get_rank()			 \n"
  "nprocs = MPI.COMM_WORLD.Get_size()			 \n"
  "procnm = MPI.Get_processor_name()			 \n"
  "print (hwmess % (myrank, nprocs, procnm))             \n"
  "";

int main(int argc, char *argv[])
{
  int i,n=5;

  MPI_Init(&argc, &argv);

  for (i=0; i<n; i++) {
    Py_Initialize();
    PyRun_SimpleString(helloworld);
    Py_Finalize();
  }

  MPI_Finalize();

  return 0;
}

Update and simplify embedding demo

Update and simplify embedding demo


#pragma once

namespace mmh {

template <typename Size, typename Object>
constexpr Size sizeof_t()
{
    return gsl::narrow<Size>(sizeof Object);
}

template <typename Size, typename Value>
constexpr Size sizeof_t(const Value& value)
{
    return gsl::narrow<Size>(sizeof value);
}

} // namespace mmh

#pragma once

namespace mmh {

template <typename Size, typename Object>
constexpr Size sizeof_t()
{
    return gsl::narrow<Size>(sizeof(Object));
}

template <typename Size, typename Value>
constexpr Size sizeof_t(const Value& value)
{
    return gsl::narrow<Size>(sizeof value);
}

} // namespace mmh

Add missing brackets needed for Clang

Add missing brackets needed for Clang


#include <pebble.h>
#include "pebcessing/pebcessing.h"

static Window *window = NULL;

static void init(void)
{
  window = window_create();

  window_set_fullscreen(window, true);

  window_stack_push(window, true);
}

static void deinit(void)
{
  window_destroy(window);
}

int main(void)
{
  init();

  init_pebcessing(window, window_get_root_layer(window));

  app_event_loop();

  deinit_pebcessing();

  deinit();

  return 0;
}

#include <pebble.h>
#include "pebcessing/pebcessing.h"

static Window *window = NULL;

static void init(void)
{
  window = window_create();

// Make the window fullscreen.
// All Windows are fullscreen-only on the Basalt platform.
#ifdef PBL_PLATFORM_APLITE
  window_set_fullscreen(window, true);
#endif

  window_stack_push(window, true);
}

static void deinit(void)
{
  window_destroy(window);
}

int main(void)
{
  init();

  init_pebcessing(window, window_get_root_layer(window));

  app_event_loop();

  deinit_pebcessing();

  deinit();

  return 0;
}

Change so that window_set_fullscreen() is called only on the Aplite platform


#ifndef SKBUFF_H_
#define SKBUFF_H_

#include "netdev.h"
#include "dst.h"
#include "list.h"
#include <pthread.h>

struct sk_buff {
    struct list_head list;
    struct dst_entry *dst;
    struct netdev *netdev;
    uint16_t protocol;
    uint32_t len;
    uint8_t *tail;
    uint8_t *end;
    uint8_t *head;
    uint8_t *data;
};

struct sk_buff_head {
    struct list_head head;

    uint32_t qlen;
    pthread_mutex_t lock;
};

struct sk_buff *alloc_skb(unsigned int size);
void free_skb(struct sk_buff *skb);
uint8_t *skb_push(struct sk_buff *skb, unsigned int len);
uint8_t *skb_head(struct sk_buff *skb);
void *skb_reserve(struct sk_buff *skb, unsigned int len);
void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst);

static inline void skb_queue_init(struct sk_buff_head *list)
{
    list_init(&list->head);
    list->qlen = 0;
    pthread_mutex_init(&list->lock, NULL);
}

#endif

#ifndef SKBUFF_H_
#define SKBUFF_H_

#include "netdev.h"
#include "dst.h"
#include "list.h"
#include <pthread.h>

struct sk_buff {
    struct list_head list;
    struct dst_entry *dst;
    struct netdev *netdev;
    uint16_t protocol;
    uint32_t len;
    uint8_t *tail;
    uint8_t *end;
    uint8_t *head;
    uint8_t *data;
};

struct sk_buff_head {
    struct list_head head;

    uint32_t qlen;
    pthread_mutex_t lock;
};

struct sk_buff *alloc_skb(unsigned int size);
void free_skb(struct sk_buff *skb);
uint8_t *skb_push(struct sk_buff *skb, unsigned int len);
uint8_t *skb_head(struct sk_buff *skb);
void *skb_reserve(struct sk_buff *skb, unsigned int len);
void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst);

static inline uint32_t skb_queue_len(const struct sk_buff_head *list)
{
    return list->qlen;
}

static inline void skb_queue_init(struct sk_buff_head *list)
{
    list_init(&list->head);
    list->qlen = 0;
    pthread_mutex_init(&list->lock, NULL);
}

#endif

Add skb queue length getter

Add skb queue length getter


// RUN: %check --only --prefix=linux %s -target x86_64-linux
// RUN: %check --prefix=darwin %s -target x86_64-darwin

int printf(const char *, ...)
	__attribute((format(printf, 1, 2)));

typedef unsigned long size_t;
typedef long ptrdiff_t;
typedef unsigned long uintptr_t;
typedef long intptr_t;

int main()
{
	// TODO:
	// [ ] test all these
	// [ ] truncations part way
	// [ ] bad length modifiers

	// modifiers: "#0- +'"
	// field width: 0-9 | *
	// precision: . ( 0-9 | * )
	// length modifiers: 'h' 'l' 'L' 'j' 't' 'z'
	// format char
	// %m on {,non-}linux

	printf("%#f", 5.2f);
	printf("%0f", 5.2f);
	printf("%-f", 5.2f);
	printf("% f", 5.2f);
	printf("%+f", 5.2f);
	printf("%'f", 5.2f);
	printf("%#0' +f", 21.f);

	printf("%23d", 5);
	printf("%35a", 5.2);
	printf("%35.a", 5.2);
	printf("%*.g", 3, 5.2);
	printf("%'.*g", 3, 5.2);
	printf("%#2.*g", 3, 5.2);
	printf("%+*.1e", 3, 5.2);

	printf("%m\n"); // CHECK-darwin: warning: %m used on non-linux system

	printf("%+*.1q", 3, 5.2); // CHECK-linux: warning: invalid conversion character

	printf("%#"); // CHECK-linux: warning: invalid modifier character

	printf("%23"); // CHECK-linux: warning: invalid field width
	printf("%35."); // CHECK-linux: warning: incomplete format specifier (missing precision)
	printf("%*"); // CHECK-linux: warning: invalid field width
	printf("%'.*"); // CHECK-linux: warning: invalid precision
	printf("%+*.1"); // CHECK-linux: warning: invalid precision
}

Test precision and field-width format handling


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

int main(int argc, char* argv[]){

}

Add main C file with standard includes

Add main C file with standard includes


/* ISC license. */

#include <sys/mman.h>
#include <skalibs/cdb.h>

extern void cdb_free (struct cdb *c)
{
  if (c->map) munmap(c->map, c->size) ;
  *c = cdb_zero ;
}

/* ISC license. */

#include <sys/mman.h>
#include <errno.h>

#include <skalibs/cdb.h>

extern void cdb_free (struct cdb *c)
{
  if (c->map)
  {
    int e = errno ;
    munmap(c->map, c->size) ;
    errno = e ;
  }
  *c = cdb_zero ;
}

Save errno when freeing a cdb

 Save errno when freeing a cdb

Signed-off-by: Laurent Bercot <3aa9adbbb49a4d5ab9c798d5e366f54570870800@appnovation.com>


/**
 * @file
 *
 * @date 21.04.2016
 * @author Anton Bondarev
 */

#ifndef TTYS_H_
#define TTYS_H_

#include <fs/idesc.h>
#include <drivers/tty.h>

struct uart;

struct tty_uart {
	struct idesc idesc;
	struct tty tty;
	struct uart *uart;
};

#endif /* TTYS_H_ */

/**
 * @file
 *
 * @date 21.04.2016
 * @author Anton Bondarev
 */

#ifndef TTYS_H_
#define TTYS_H_

#include <fs/idesc.h>
#include <drivers/tty.h>
#include <drivers/char_dev.h>

struct uart;
struct tty_uart {
	struct idesc idesc;
	struct tty tty;
	struct uart *uart;
};

extern struct idesc *uart_cdev_open(struct dev_module *cdev, void *priv);

#define TTYS_DEF(name, uart) \
		CHAR_DEV_DEF(name, uart_cdev_open, NULL, NULL, uart)

#endif /* TTYS_H_ */

Add TTYS_DEF macro to oldfs

drivers: Add TTYS_DEF macro to oldfs


#define STAT_SIZE sizeof(struct stat)
#define STATFS_SIZE sizeof(struct statfs)
#define GID_T_SIZE sizeof(gid_t)
#define INT_SIZE sizeof(int)
#define LONG_SIZE sizeof(long)
#define FD_SET_SIZE sizeof(fd_set)
#define TIMEVAL_SIZE sizeof(struct timeval)
#define TIMEVAL_ARRAY_SIZE (sizeof(struct timeval) * 2)
#define TIMEZONE_SIZE sizeof(struct timezone)
#define FILEDES_SIZE sizeof(struct filedes)
#define RLIMIT_SIZE sizeof(struct rlimit)
#define UTSNAME_SIZE sizeof(struct utsname)
#define POLLFD_SIZE sizeof(struct pollfd)
#define RUSAGE_SIZE sizeof(struct rusage)
#define MAX_STRING 1024
#define EIGHT 8
#define STATFS_ARRAY_SIZE (rval * sizeof(struct statfs))
#define PROC_SIZE sizeof(PROC)
#define SIZE_T_SIZE sizeof(size_t)
#define U_SHORT_SIZE sizeof(u_short)

Add macros for sized of "size_t" and "u_short".


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

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

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

/*
 * tuple.h - define data structure for tuples
 */
#ifndef _TUPLE_H_
#define _TUPLE_H_

#define MAX_TUPLE_SIZE 4096

union Tuple {
    unsigned char bytes[MAX_TUPLE_SIZE];
    char *ptrs[MAX_TUPLE_SIZE/sizeof(char *)];
};

#endif /* _TUPLE_H_ */

Add BSD 3-clause open source header

Add BSD 3-clause open source header


#include <stdio.h>

int main() {
    float a, b, c, d, e, m;

    scanf("%f %f %f %f", &a, &b, &c, &d);

    m = (a * 2 + b * 3 + c * 4 + d) / 10;

    printf("Media: %.1f\n", m);

    if (m >= 7.0) {
        printf("Aluno aprovado.\n");
    } else if (m >= 5.0) {
        printf("Aluno em exame.\n");

        scanf("%f", &e);

        printf("Nota do exame: %.1f\n", e);

        if (e + m / 2.0 > 5.0) {
            printf("Aluno aprovado.\n");
        } else {
            printf("Aluno reprovado.\n");
        }

        printf("Media final: %.1f\n", (e + m) / 2.0);
    } else {
        printf("Aluno reprovado.\n");
    }

    return 0;
}

Solve Average 3 in c

Solve Average 3 in c


/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2010 Red Hat, Inc.
 * Copyright (C) 2010 Collabora Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <config.h>

#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <gio/gio.h>

#include "cc-empathy-accounts-panel.h"

void
g_io_module_load (GIOModule *module)
{
  textdomain (GETTEXT_PACKAGE);

  cc_empathy_accounts_panel_register (module);
}

void
g_io_module_unload (GIOModule *module)
{
}

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2010 Red Hat, Inc.
 * Copyright (C) 2010 Collabora Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <config.h>

#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <gio/gio.h>

#include "cc-empathy-accounts-panel.h"

void
g_io_module_load (GIOModule *module)
{
  cc_empathy_accounts_panel_register (module);
}

void
g_io_module_unload (GIOModule *module)
{
}

Remove call to textdomain ()

accounts-module: Remove call to textdomain ()

This shouldn't be called in shared module.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=617262


int main()
{
	int b = 2, c = 3, d = 4;
	int a = b + c;
	b = a - d;
	int e = b + c;
	int f = a - d;
	return 0;
}

Add test case for single block

Add test case for single block


// SKIP PARAM: --set ana.activated[+] apron --set ana.apron.domain octagon --enable ana.apron.threshold_widening
// TODO: why needs threshold widening to succeed when queuesize doesn't?
#include <pthread.h>
#include <assert.h>

#define CAPACITY 1000

int used;
int free;
pthread_mutex_t Q = PTHREAD_MUTEX_INITIALIZER;

void pop() {
  pthread_mutex_lock(&Q);
  assert(free >= 0);
  assert(free <= CAPACITY);
  assert(used >= 0);
  assert(used <= CAPACITY);
  assert(used + free == CAPACITY);

  if (used >= 1) {
    used--;
    free++;
  }

  assert(free >= 0);
  assert(free <= CAPACITY);
  assert(used >= 0);
  assert(used <= CAPACITY);
  assert(used + free == CAPACITY);
  pthread_mutex_unlock(&Q);
}

void push() {
  pthread_mutex_lock(&Q);
  assert(free >= 0);
  assert(free <= CAPACITY);
  assert(used >= 0);
  assert(used <= CAPACITY);
  assert(used + free == CAPACITY);

  if (free >= 1) {
    free--;
    used++;
  }

  assert(free >= 0);
  assert(free <= CAPACITY);
  assert(used >= 0);
  assert(used <= CAPACITY);
  assert(used + free == CAPACITY);
  pthread_mutex_unlock(&Q);
}

void *worker(void *arg) {
  while (1)
    pop();
  return NULL;
}

int main() {
  free = CAPACITY;
  used = 0;

  assert(free >= 0);
  assert(free <= CAPACITY);
  assert(used >= 0);
  assert(used <= CAPACITY);
  assert(used + free == CAPACITY);

  pthread_t worker1;
  pthread_t worker2;
  pthread_create(&worker1, NULL, worker, NULL);
  pthread_create(&worker2, NULL, worker, NULL);

  while (1)
    push();

  return 0;
}

Add queuesize test with constant capacity

This can be verified using octagon.


#pragma once

#include "llvm/ADT/StringRef.h"
#include <set>
#include <map>

#include "Types.h"

// TODO: This shouldn't really be here. More restructuring needed...
struct hipCounter {
    llvm::StringRef hipName;
    ConvTypes countType;
    ApiTypes countApiType;
    int unsupported;
};

#define HIP_UNSUPPORTED -1

/// Macros to ignore.
extern const std::set<llvm::StringRef> CUDA_EXCLUDES;

/// Maps cuda header names to hip header names.
extern const std::map<llvm::StringRef, hipCounter> CUDA_INCLUDE_MAP;

/// Maps the names of CUDA types to the corresponding hip types.
extern const std::map<llvm::StringRef, hipCounter> CUDA_TYPE_NAME_MAP;

/// Map all other CUDA identifiers (function/macro names, enum values) to hip versions.
extern const std::map<llvm::StringRef, hipCounter> CUDA_IDENTIFIER_MAP;

/**
 * The union of all the above maps.
 *
 * This should be used rarely, but is still needed to convert macro definitions (which can
 * contain any combination of the above things). AST walkers can usually get away with just
 * looking in the lookup table for the type of element they are processing, however, saving
 * a great deal of time.
 */
const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP();

#pragma once

#include "llvm/ADT/StringRef.h"
#include <set>
#include <map>

#include "Types.h"

// TODO: This shouldn't really be here. More restructuring needed...
struct hipCounter {
    llvm::StringRef hipName;
    ConvTypes countType;
    ApiTypes countApiType;
    bool unsupported;
};

#define HIP_UNSUPPORTED true

/// Macros to ignore.
extern const std::set<llvm::StringRef> CUDA_EXCLUDES;

/// Maps cuda header names to hip header names.
extern const std::map<llvm::StringRef, hipCounter> CUDA_INCLUDE_MAP;

/// Maps the names of CUDA types to the corresponding hip types.
extern const std::map<llvm::StringRef, hipCounter> CUDA_TYPE_NAME_MAP;

/// Map all other CUDA identifiers (function/macro names, enum values) to hip versions.
extern const std::map<llvm::StringRef, hipCounter> CUDA_IDENTIFIER_MAP;

/**
 * The union of all the above maps.
 *
 * This should be used rarely, but is still needed to convert macro definitions (which can
 * contain any combination of the above things). AST walkers can usually get away with just
 * looking in the lookup table for the type of element they are processing, however, saving
 * a great deal of time.
 */
const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP();

Make `unsupported` actually be a bool...


// Title:  sleep
// Name:   sleep.c
// Author: Matayoshi
// Date:   2010/06/20
// Ver:    1.0.0

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

int main(int argc, char* argv[]) {
	// `FbN
	if(argc < 2) {
		fprintf(stdout, "Usage: %s msec\n", argv[0]);
		exit(1);
	} else {
		char buf[16];
		int wait = 0;

		// 񂩂琔lɕϊ
		sscanf(argv[1], "%15c", buf);
		if(sscanf(buf, "%d", &wait) != 1) {
			fprintf(stdout, "Usage: %s msec\n", argv[0]);
			exit(1);
		}

		// Ŏw肳ꂽ msec  sleep(wait)
		Sleep(wait);
	}
	return 0;
}

// Title:  sleep
// Name:   sleep.c
// Author: Matayoshi
// Date:   2010/06/20
// Ver:    1.0.0

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

int main(int argc, char* argv[]) {
	// 引数チェック
	if(argc < 2) {
		fprintf(stdout, "Usage: %s msec\n", argv[0]);
		exit(1);
	} else {
		char buf[16];
		int wait = 0;

		// 文字列から数値に変換
		sscanf(argv[1], "%15c", buf);
		if(sscanf(buf, "%d", &wait) != 1) {
			fprintf(stdout, "Usage: %s msec\n", argv[0]);
			exit(1);
		}

		// 引数で指定された msec だけ sleep(wait)
		Sleep(wait);
	}
	return 0;
}

Change character encoding.(Shift_JIS -> UTF-8)


/*
 * Copyright 2016, 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)
 */

#pragma once

/* macros for forcing the compiler to leave in statments it would
 * normally optimize away */

#include <utils/attribute.h>
#include <utils/stringify.h>

/* Macro for doing dummy reads
 *
 * Expands to a volatile, unused variable which is set to the value at
 * a given address. It's volatile to prevent the compiler optimizing
 * away a variable that is written but never read, and it's unused to
 * prevent warnings about a variable that's never read.
 */
#define FORCE_READ(address) \
        volatile UNUSED typeof(*address) JOIN(__force__read, __COUNTER__) = *(address)

/*
 * Copyright 2016, 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)
 */

#pragma once

/* macros for forcing the compiler to leave in statments it would
 * normally optimize away */

#include <utils/attribute.h>
#include <utils/stringify.h>

/* Macro for doing dummy reads
 *
 * Forces a memory read access to the given address.
 */
#define FORCE_READ(address) \
    do { \
        typeof(*(address)) *_ptr = (address); \
        asm volatile ("" : "=m"(*_ptr) : "r"(*_ptr)); \
    } while (0)

libutils: Rephrase FORCE_READ into something safer.

This commit rephrases the `FORCE_READ` macro to avoid an unorthodox use of
`volatile`. The change makes the read less malleable from the compiler's point
of view.

It also has the unintended side effect of slightly optimising this operation. On
x86, an optimising compiler now generates a single load, rather than a load
followed by a store to the (unused) local variable. On ARM, there is a similar
improvement, but we also save two instructions for stack pointer manipulation
depending on the context in which the macro is expanded.


const char *s0 = m0;
int s1 = m1;
const char *s2 = m0;

// FIXME: This test fails inexplicably on Windows in a manner that makes it
// look like standard error isn't getting flushed properly.

// RUN: true
// RUNx: echo '#define m0 ""' > %t.h
// RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h
// RUNx: echo '' > %t.h
// RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
// RUNx: grep "modified" %t.stderr

// RUNx: echo '#define m0 000' > %t.h
// RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h
// RUNx: echo '' > %t.h
// RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
// RUNx: grep "modified" %t.stderr

// RUNx: echo '#define m0 000' > %t.h
// RUNx: echo "#define m1 'abcd'" >> %t.h
// RUNx: %clang_cc1 -emit-pch -o %t.h.pch %t.h
// RUNx: echo '' > %t.h
// RUNx: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
// RUNx: grep "modified" %t.stderr

const char *s0 = m0;
int s1 = m1;
const char *s2 = m0;

// FIXME: This test fails inexplicably on Windows in a manner that makes it
// look like standard error isn't getting flushed properly.

// RUN: false
// XFAIL: *

// RUN: echo '#define m0 ""' > %t.h
// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
// RUN: echo '' > %t.h
// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
// RUN: grep "modified" %t.stderr

// RUN: echo '#define m0 000' > %t.h
// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
// RUN: echo '' > %t.h
// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
// RUN: grep "modified" %t.stderr

// RUN: echo '#define m0 000' > %t.h
// RUN: echo "#define m1 'abcd'" >> %t.h
// RUN: %clang_cc1 -emit-pch -o %t.h.pch %t.h
// RUN: echo '' > %t.h
// RUN: not %clang_cc1 -include-pch %t.h.pch %s 2> %t.stderr
// RUN: grep "modified" %t.stderr

Use Daniel's trick for XFAIL'd tests

Use Daniel's trick for XFAIL'd tests

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


#include "listHelper.h"

int intersectNode(struct linkList *l1,  struct linkList *l2, int m, int n) {

	/*     l1
		\    l2
		 \  /
		  \/
		   |
		   |
	l1 is list1 with length m
	l2 is list2 with length n
	here, m is 5 and n is 4
	so diff = abs(m-n) = 1
	we need to hop 1 step on l1 to reach l2's length.
	from here on, we loop till end of list and verify id l1 == l2
	if l1 == l2 somewhere, we have a Y list
	*/

	int diff = abs (m -n );
	if ( m > n) {
		while ( diff ) {
			diff--;
			l1 = l1->next;
		}
	}
	if ( n > m ) {
		while ( diff ) {
			diff--;
			l2 = l2->next;
		}
	}

	while (l1 != NULL || l2 != NULL ) {
		if ( l1 == l2)
			return l1->data;
		else {
			l1 = l1->next;
			l2 = l2->next;
		}
	}
}

void
main() {

        int dat;
        struct linkList *list1 = NULL, *list2 = NULL;

        InsertLinkedList(&list1, 21, 1);         /*Insert node in Beginning */
        InsertLinkedList(&list1, 31, 2);         /*Insert at position 2 */
        InsertLinkedList(&list1, 41, 3);
        InsertLinkedList(&list1, 51, 4);
        InsertLinkedList(&list1, 61, 5);
        InsertLinkedList(&list1, 72, 6);
        InsertLinkedList(&list1, 87, 7);

        InsertLinkedList(&list2, 91, 1);
        InsertLinkedList(&list2, 92, 2);
        InsertLinkedList(&list2, 93, 3);
        InsertLinkedList(&list2, 94, 4);
        displayList(list1);
        displayList(list2);

	/* build a Y list */
	list2->next->next->next->next = list1->next->next->next;
        displayList(list1);
        displayList(list2);

	printf ( "Intersecting node is %d\n", intersectNode(list1, list2, 7, 8));
}

Verify if two lists intersect at Y point.


#ifndef DRAUPNIR_H__
#define DRAUPNIR_H__

#include <cstdint>

#include "Sponge.h"
#include "CrcSponge.h"
#include "CrcSpongeBuilder.h"
#include "Constants.h"

namespace Draupnir {

  // utility typedefs
  typedef CrcSponge<std::uint64_t> CrcSponge64;
  typedef CrcSponge<std::uint32_t> CrcSponge32;
  typedef CrcSponge<std::uint16_t> CrcSponge16;
  typedef CrcSponge<std::uint8_t> CrcSponge8;

  typedef CrcSpongeBuilder<std::uint64_t> CrcSponge64Builder;
  typedef CrcSpongeBuilder<std::uint32_t> CrcSponge32Builder;
  typedef CrcSpongeBuilder<std::uint16_t> CrcSponge16Builder;
  typedef CrcSpongeBuilder<std::uint8_t> CrcSponge8Builder;

}

#endif /* DRAUPNIR_H__ */

#ifndef DRAUPNIR_H__
#define DRAUPNIR_H__

#include <cstdint>

#include "Sponge.h"
#include "CrcSponge.h"
#include "CrcSpongeBuilder.h"
#include "Constants.h"

namespace Draupnir {

  // utility typedefs
  using CrcSponge64 = CrcSponge<std::uint64_t>;
  using CrcSponge32 = CrcSponge<std::uint32_t>;
  using CrcSponge16 = CrcSponge<std::uint16_t>;
  using CrcSponge8  = CrcSponge<std::uint8_t >;

  using CrcSponge64Builder = CrcSpongeBuilder<std::uint64_t>;
  using CrcSponge32Builder = CrcSpongeBuilder<std::uint32_t>;
  using CrcSponge16Builder = CrcSpongeBuilder<std::uint16_t>;
  using CrcSponge8Builder  = CrcSpongeBuilder<std::uint8_t >;

}

#endif /* DRAUPNIR_H__ */

Use using instead of typedef

Use using instead of typedef


// PARAM:  --enable exp.partition-arrays.enabled
#include <pthread.h>

pthread_t t_ids[10000];

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

int main(void) {
  for (int i = 0; i < 10000; i++)
    pthread_create(&t_ids[i], NULL, t_fun, NULL);
  for (int i = 0; i < 10000; i++)
    pthread_join (t_ids[i], NULL);
  return 0;
}

// PARAM: --set ana.activated[+] thread --enable exp.partition-arrays.enabled
#include <pthread.h>

pthread_t t_ids[10000];

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

int main(void) {
  for (int i = 0; i < 10000; i++)
    pthread_create(&t_ids[i], NULL, t_fun, NULL);
  for (int i = 0; i < 10000; i++)
    pthread_join (t_ids[i], NULL);
  return 0;
}

Fix missing thread analysis in 10/24

Fix missing thread analysis in 10/24


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

#ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H
#define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H

#include <HeaderMapCollector.h>

namespace clang {
namespace find_all_symbols {

const HeaderMapCollector::HeaderMap* getSTLPostfixHeaderMap();

} // namespace find_all_symbols
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H

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

#ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H
#define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H

#include "HeaderMapCollector.h"

namespace clang {
namespace find_all_symbols {

const HeaderMapCollector::HeaderMap* getSTLPostfixHeaderMap();

} // namespace find_all_symbols
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_TOOL_STL_POSTFIX_HEADER_MAP_H

Include local header with quotes instead of angle brackets.

This works by accident because we pass '-I.'

git-svn-id: a34e9779ed74578ad5922b3306b3d80a0c825546@270701 91177308-0d34-0410-b5e6-96231b3b80d8


#ifndef CLIENTVERSION_H
#define CLIENTVERSION_H

//
// client versioning and copyright year
//

// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR       0
#define CLIENT_VERSION_MINOR       9
#define CLIENT_VERSION_REVISION    0
#define CLIENT_VERSION_BUILD       0

// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE  true

// Copyright year (2009-this)
// Todo: update this when changing our copyright comments in the source
#define COPYRIGHT_YEAR 2014

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
#define STRINGIZE(X) DO_STRINGIZE(X)
#define DO_STRINGIZE(X) #X

#endif // CLIENTVERSION_H

#ifndef CLIENTVERSION_H
#define CLIENTVERSION_H

//
// client versioning and copyright year
//

// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR       0
#define CLIENT_VERSION_MINOR       9
#define CLIENT_VERSION_REVISION    1
#define CLIENT_VERSION_BUILD       0

// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE  true

// Copyright year (2009-this)
// Todo: update this when changing our copyright comments in the source
#define COPYRIGHT_YEAR 2014

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
#define STRINGIZE(X) DO_STRINGIZE(X)
#define DO_STRINGIZE(X) #X

#endif // CLIENTVERSION_H

Bump version for openssl security updates


/*
 * Copyright 2014 MongoDB, 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 MONGOC_IOVEC_H
#define MONGOC_IOVEC_H

#include <bson.h>

#ifndef _WIN32
# include <sys/uio.h>
#endif

BSON_BEGIN_DECLS

#ifdef _WIN32
typedef struct
{
   u_long  iov_len;
   char   *iov_base;
} mongoc_iovec_t;
#else
typedef struct iovec mongoc_iovec_t;
#endif

BSON_END_DECLS

#endif /* MONGOC_IOVEC_H */

/*
 * Copyright 2014 MongoDB, 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 MONGOC_IOVEC_H
#define MONGOC_IOVEC_H

#include <bson.h>

#ifdef _WIN32
# include <stddef.h>
#else
# include <sys/uio.h>
#endif

BSON_BEGIN_DECLS

#ifdef _WIN32
typedef struct
{
   u_long  iov_len;
   char   *iov_base;
} mongoc_iovec_t;

BSON_STATIC_ASSERT(sizeof(mongoc_iovec_t) == sizeof(WSABUF));
BSON_STATIC_ASSERT(offsetof(mongoc_iovec_t, iov_base) == offsetof(WSABUF, buf));
BSON_STATIC_ASSERT(offsetof(mongoc_iovec_t, iov_len) == offsetof(WSABUF, len));

#else
typedef struct iovec mongoc_iovec_t;
#endif

BSON_END_DECLS

#endif /* MONGOC_IOVEC_H */

CDRIVER-756: Make sure our iovec abstraction is compatible with Windows WSABUF

We cast mongoc_iovec_t to LPWSABUF in our sendmsg() wrapper