#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "distributed.h"
#include "stddefines.h"

void shm_init() {
	int fd;

	/* Map the shmem region */
	fd = open(SHM_DEV, O_RDWR);
	CHECK_ERROR(fd < 0);
	shm_base = mmap(SHM_LOC, SHM_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 1*getpagesize());
	CHECK_ERROR(shm_base == MAP_FAILED);
}

#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include "distributed.h"
#include "stddefines.h"

void shm_init() {
	int fd;

	/* Map the shmem region */
	fd = open(SHM_DEV, O_RDWR);
	CHECK_ERROR(fd < 0);
	shm_base = mmap(SHM_LOC, SHM_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 1*getpagesize());
	CHECK_ERROR(shm_base != SHM_LOC);
}

Check that the mmap goes in the right place.


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

#include <stdio.h>   /* Allows usage of printf() */
#include <stdbool.h> /* Allows usage of booleans */
#include <stdlib.h>  /* Allows usage of abs() */

struct oriented_arc_struct {
    int lenght;
    bool clockwise;
};

typedef struct oriented_arc_struct oriented_arc;
int circumference = 12;
int start_point;
int end_point;
oriented_arc arc;
char hrule[50] = "\t+-------+-----+----------+------------------+\n";
char header[50] = "\t| Start | End | Distance |     Direction    |\n";
char ring[100] = "\
\t\t      12\n\
\t\t    11   1\n\
\t\t  10  \\    2\n\
\t\t 9     o---  3\n\
\t\t   8       4\n\
\t\t     7   5\n\
\t\t       6\n";

oriented_arc min_ring_distance(int circumference, int start_point, int end_point) {
    int distance_1 = end_point - start_point;
    oriented_arc arc_1 = {abs(distance_1), (distance_1 >= 0) ? true : false};
    oriented_arc arc_2 = {circumference - arc_1.lenght, !arc_1.clockwise};
    if (arc_1.lenght <= arc_2.lenght) {
        return arc_1;
    } else {
        return arc_2;
    }
}

int main() {
    printf("%s", ring);
    printf("%s", hrule);
    printf("%s", header);
    printf("%s", hrule);
    for (start_point = 1; start_point <= circumference; start_point++) {
        for (end_point = 1; end_point <= circumference; end_point++) {
            arc = min_ring_distance(circumference,
                    start_point, end_point);
            printf("\t|  %4i |%4i |     %4i | %s |\n",
                    start_point, end_point,
                    arc.lenght, arc.clockwise ? "    Clockwise   " : "Counterclockwise");
        }
        printf("%s", hrule);
    }
}

Add ring oriented distance calculator

Add ring oriented distance calculator


#define _LP64 1
#define __8cc__ 1
#define __ELF__ 1
#define __LP64__ 1
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_LONG__ 8
#define __SIZEOF_POINTER__ 8
#define __SIZEOF_PTRDIFF_T__ 8
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_SIZE_T__ 8
#define __STDC_HOSTED__ 1
#define __STDC_NO_ATOMICS__ 1
#define __STDC_NO_COMPLEX__ 1
#define __STDC_NO_THREADS__ 1
#define __STDC_NO_VLA__ 1
#define __STDC_VERSION__ 201112L
#define __STDC__ 1
#define __amd64 1
#define __amd64__ 1
#define __gnu_linux__ 1
#define __linux 1
#define __linux__ 1
#define __unix 1
#define __unix__ 1
#define __x86_64 1
#define __x86_64__ 1
#define linux 1

#define __restrict restrict
#define __restrict__ restrict

Define __restrict__ and __restrict as synonyms for restrict.

C99/C11 defines only restrict, but popular compilers including GCC
define these synonyms (so that you can use __restrict in C++, in
which restrict keyword is not a part of the language standard).


/**
library core

Psuedo root of all pre-registered modules.

This is a fake module created to link together all of the modules that are
automatically loaded in the interpreter.

Except for the `builtin` module, all modules listed here can be imported from
any file inside of the interpreter. This is unlike other modules, which are
loaded using relative paths. These modules can be imported like `import sys`,
then used like `print(sys.argv)`.

The `builtin` module is unique because the classes, enums, and functions are the
foundation of the interpreter. Instead of requiring it to be imported, the
contents of `builtin` are instead available without a namespace.
*/

/**
PackageFiles
    lily_pkg_builtin.c
    lily_pkg_random.c
    lily_pkg_sys.c
    lily_pkg_time.c

*/

Add 'core' pseudo package for docgen to target.


// Copyright 2015-2017 Directive Games Limited - All Rights Reserved

#pragma once

#include "JsonArchive.h"
#include "IHttpRequest.h"

#include "Core.h"
#include "Interfaces/IHttpRequest.h"

RAPIDJSON_API DECLARE_LOG_CATEGORY_EXTERN(JsonUtilsLog, Log, All);

class RAPIDJSON_API JsonUtils
{
public:
    template<class T>
    static bool ParseResponse(FHttpResponsePtr response, T& parsed)
    {
        const auto respStr = response->GetContentAsString();

        bool success = JsonArchive::LoadObject(*respStr, parsed);

        if (!success)
        {
            UE_LOG(JsonUtilsLog, Error, TEXT("Failed to parse json response '%s'"), *respStr);
        }

        return success;
    }
};

// Copyright 2015-2017 Directive Games Limited - All Rights Reserved

#pragma once

#include "JsonArchive.h"
#include "IHttpRequest.h"

#include "Core.h"
#include "Interfaces/IHttpRequest.h"
#include "Interfaces/IHttpResponse.h"

RAPIDJSON_API DECLARE_LOG_CATEGORY_EXTERN(JsonUtilsLog, Log, All);

class RAPIDJSON_API JsonUtils
{
public:
    template<class T>
    static bool ParseResponse(FHttpResponsePtr response, T& parsed)
    {
        const auto respStr = response->GetContentAsString();

        bool success = JsonArchive::LoadObject(*respStr, parsed);

        if (!success)
        {
            UE_LOG(JsonUtilsLog, Error, TEXT("Failed to parse json response '%s'"), *respStr);
        }

        return success;
    }
};

Fix another Linux build error

Fix another Linux build error

- Was missing #include statements


//
//  OCTClient+Activity.h
//  OctoKit
//
//  Created by Piet Brauer on 14.02.14.
//  Copyright (c) 2014 GitHub. All rights reserved.
//
#import "OCTClient.h"

@class RACSignal;
@class OCTRepository;

@interface OCTClient (Activity)

// Check if the user starred the `repository`.
//
// repository - The repository used to check the starred status. Cannot be nil.
//
// Returns a signal, which will send completed on success. If the client
// is not `authenticated`, the signal will error immediately.
- (RACSignal *)hasUserStarredRepository:(OCTRepository *)repository;

// Star the given `repository`
//
// repository - The repository to star. Cannot be nil.
//
// Returns a signal, which will send completed on success. If the client
// is not `authenticated`, the signal will error immediately.
- (RACSignal *)starRepository:(OCTRepository *)repository;

// Unstar the given `repository`
//
// repository - The repository to unstar. Cannot be nil.
//
// Returns a signal, which will send completed on success. If the client
// is not `authenticated`, the signal will error immediately.
- (RACSignal *)unstarRepository:(OCTRepository *)repository;

@end

//
//  OCTClient+Activity.h
//  OctoKit
//
//  Created by Piet Brauer on 14.02.14.
//  Copyright (c) 2014 GitHub. All rights reserved.
//
#import "OCTClient.h"

@class RACSignal;
@class OCTRepository;

@interface OCTClient (Activity)

// Check if the user starred the `repository`.
//
// repository - The repository used to check the starred status. Cannot be nil.
//
// Returns a signal, which will send a NSNumber valued @YES or @NO.
// If the client is not `authenticated`, the signal will error immediately.
- (RACSignal *)hasUserStarredRepository:(OCTRepository *)repository;

// Star the given `repository`
//
// repository - The repository to star. Cannot be nil.
//
// Returns a signal, which will send completed on success. If the client
// is not `authenticated`, the signal will error immediately.
- (RACSignal *)starRepository:(OCTRepository *)repository;

// Unstar the given `repository`
//
// repository - The repository to unstar. Cannot be nil.
//
// Returns a signal, which will send completed on success. If the client
// is not `authenticated`, the signal will error immediately.
- (RACSignal *)unstarRepository:(OCTRepository *)repository;

@end

Change documentation to fit return of NSNumber


#import <UIKit/UIKit.h>

@interface BCBalancedMultilineLabel : UILabel

@end

#import <UIKit/UIKit.h>

/**
 * A simple label subclass that draws itself such that each of its
 * lines have as close to the same length as possible. It can be
 * used anywhere that you could use an ordinary `UILabel` by simply
 * changing the instantiated class.
 */
@interface BCBalancedMultilineLabel : UILabel

@end

Add Appledoc to the header

Add Appledoc to the header


/*
 * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
 * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
 */

#ifndef BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD
#define BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD

#if BX_PLATFORM_OSX

namespace bgfx { namespace gl
{
	struct SwapChainGL;

	struct GlContext
	{
		GlContext()
			: m_context(0)
		{
		}

		void create(uint32_t _width, uint32_t _height);
		void destroy();
		void resize(uint32_t _width, uint32_t _height, uint32_t _flags);

		uint64_t getCaps() const;
		SwapChainGL* createSwapChain(void* _nwh);
		void destroySwapChain(SwapChainGL*  _swapChain);
		void swap(SwapChainGL* _swapChain = NULL);
		void makeCurrent(SwapChainGL* _swapChain = NULL);

		void import();

		bool isValid() const
		{
			return 0 != m_context;
		}

		void* m_view;
		void* m_context;
	};
} /* namespace gl */ } // namespace bgfx

#endif // BX_PLATFORM_OSX

#endif // BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD

/*
 * Copyright 2011-2016 Branimir Karadzic. All rights reserved.
 * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
 */

#ifndef BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD
#define BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD

#if BX_PLATFORM_OSX

namespace bgfx { namespace gl
{
	struct SwapChainGL;

	struct GlContext
	{
		GlContext()
			: m_context(0)
			, m_view(0)
		{
		}

		void create(uint32_t _width, uint32_t _height);
		void destroy();
		void resize(uint32_t _width, uint32_t _height, uint32_t _flags);

		uint64_t getCaps() const;
		SwapChainGL* createSwapChain(void* _nwh);
		void destroySwapChain(SwapChainGL*  _swapChain);
		void swap(SwapChainGL* _swapChain = NULL);
		void makeCurrent(SwapChainGL* _swapChain = NULL);

		void import();

		bool isValid() const
		{
			return 0 != m_context;
		}

		void* m_view;
		void* m_context;
	};
} /* namespace gl */ } // namespace bgfx

#endif // BX_PLATFORM_OSX

#endif // BGFX_GLCONTEXT_NSGL_H_HEADER_GUARD

Set m_view to 0 in GlContext ctor

Set m_view to 0 in GlContext ctor


#define UTL_MAIN
#include "utl.h"

int main(int argc, char *argv[])
{
  logopen("t_logassert.log","w");

  logassert(5>10);
  logassert(utl_ret(0));
  logcheck(3/utl_ret(0) == 0);
  logclose();
}

Check that logassert() fails properly

Check that logassert() fails properly


//
//  Lottie.h
//  Pods
//
//  Created by brandon_withrow on 1/27/17.
//
//
@import Foundation;
#ifndef Lottie_h
#define Lottie_h

//! Project version number for Lottie.
FOUNDATION_EXPORT double LottieVersionNumber;

//! Project version string for Lottie.
FOUNDATION_EXPORT const unsigned char LottieVersionString[];

#import "LOTAnimationTransitionController.h"
#import "LOTAnimationView.h"

#endif /* Lottie_h */

//
//  Lottie.h
//  Pods
//
//  Created by brandon_withrow on 1/27/17.
//
//

#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif

#ifndef Lottie_h
#define Lottie_h

//! Project version number for Lottie.
FOUNDATION_EXPORT double LottieVersionNumber;

//! Project version string for Lottie.
FOUNDATION_EXPORT const unsigned char LottieVersionString[];

#import "LOTAnimationTransitionController.h"
#import "LOTAnimationView.h"

#endif /* Lottie_h */

Fix @import compatibility with .mm files


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

void nop( int delay ){
    int tmp,i;
    for( i=0; i<delay; i++ )
        tmp = i + tmp;
}

int main(int argc, char **argv) {
    int SEED = 2;
    int MEM_SIZE = 1024 * 1024; // *32 bits (number of ints)
    int DURATION = 6 * 1000 * 1000; //us
    int DELAY_OPS = 1000; //us between mem requests
    int count = 0;

    int opt;
    while( ( opt = getopt( argc, argv, "s:d:p:" ) ) != -1 ){
        switch( opt ){
            case 's':
                MEM_SIZE = 1024 * 1024 * atoi(optarg); // *32 MB
                break;
            case 'd':
                DURATION = atoi(optarg); // seconds
                break;
            case 'p':
                DELAY_OPS = atoi(optarg); // us
                break;
            default:
                break;
        }
    }

    int * mem = ( int* ) malloc( sizeof( int ) * MEM_SIZE );
    int elapsed = 0;
    int tmp;
    srand( SEED );

    while( elapsed < DURATION ){
        int read_addr  = count % MEM_SIZE;
        tmp = mem[read_addr];
        elapsed += DELAY_OPS;
        count += 16;
        //nop(DELAY_OPS);
    }

}

Add a benchmark for higher memory intensity


#include "../failing_allocs.h"

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

USE_FAILING_ALLOCS

typedef struct{
  int* some_ints;
  size_t count;
} Container;

Container* Container_create(size_t count)
{
  Container* new_container = calloc(1, sizeof(Container));
  if(!new_container) goto error;

  new_container->some_ints = malloc(5 * sizeof(int));
  if(!new_container->some_ints) goto error;

  int* new_ints = realloc(new_container->some_ints,
                          count * sizeof(int));
  if(!new_ints) goto error;
  new_container->some_ints = new_ints;

  new_container->count = count;

  return new_container;

error:
  if(new_container) {
    if(new_container->some_ints) free(new_container->some_ints);
    free(new_container);
  }
  return NULL;
}

void Container_delete(Container* container)
{
  if(container) {
    if(container->some_ints) free(container->some_ints);
    free(container);
  }
}

int main(void)
{
  int i = 0;
  for(i = 0; i < 10; i++) {
    Container* container = Container_create(100);
    if(!container) continue;
    assert(container->count == 100);
    Container_delete(container);
  }

  FREE_FAILING_ALLOCS

  return 0;
}

Add an example of code that uses failing_allocs.


#ifndef SOFAPYTHON_PYTHON_H
#define SOFAPYTHON_PYTHON_H

// This header simply includes Python.h, taking care of platform-specific stuff

// It should be included before any standard headers:
// "Since Python may define some pre-processor definitions which affect the
// standard headers on some systems, you must include Python.h before any
// standard headers are included."

#if defined(_MSC_VER) && defined(_DEBUG)
// undefine _DEBUG since we want to always link agains the release version of
// python and pyconfig.h automatically links debug version if _DEBUG is defined.
// ocarre: no we don't, in debug on Windows we cannot link with python release, if we want to build SofaPython in debug we have to compile python in debug
//#    undef _DEBUG
#    include <Python.h>
//#    define _DEBUG
#elif defined(__APPLE__) && defined(__MACH__)
#    include <Python/Python.h>
#else
#    include <Python.h>
#endif

#endif

#ifndef SOFAPYTHON_PYTHON_H
#define SOFAPYTHON_PYTHON_H

// This header simply includes Python.h, taking care of platform-specific stuff

// It should be included before any standard headers:
// "Since Python may define some pre-processor definitions which affect the
// standard headers on some systems, you must include Python.h before any
// standard headers are included."

#if defined(_WIN32)
#	define MS_NO_COREDLL // deactivate pragma linking on Win32 done in Python.h
#endif

#if defined(_MSC_VER) && defined(_DEBUG)
// undefine _DEBUG since we want to always link agains the release version of
// python and pyconfig.h automatically links debug version if _DEBUG is defined.
// ocarre: no we don't, in debug on Windows we cannot link with python release, if we want to build SofaPython in debug we have to compile python in debug
//#    undef _DEBUG
#    include <Python.h>
//#    define _DEBUG
#elif defined(__APPLE__) && defined(__MACH__)
#    include <Python/Python.h>
#else
#    include <Python.h>
#endif

#endif

Disable auto linking on windows so that CMake settings are not overriden.

Former-commit-id: 3e43e87772ab712bab8778502c22411288f0eb31


#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <Security/Security.h>

#import <NSBezierPath+IOS7RoundedRect.h>

static NSString * const kPluginBundleId = @"com.FerretSyndicate.ProvisionQL";
static NSString * const kDataType_ipa               = @"com.apple.itunes.ipa";
static NSString * const kDataType_app               = @"com.apple.application-bundle";
static NSString * const kDataType_ios_provision     = @"com.apple.mobileprovision";
static NSString * const kDataType_ios_provision_old = @"com.apple.iphone.mobileprovision";
static NSString * const kDataType_osx_provision     = @"com.apple.provisionprofile";

#define SIGNED_CODE 0

NSImage *roundCorners(NSImage *image);
NSImage *imageFromApp(NSURL *URL, NSString *dataType, NSString *fileName);
NSString *mainIconNameForApp(NSDictionary *appPropertyList);
int expirationStatus(NSDate *date, NSCalendar *calendar);

#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>

#import <Foundation/Foundation.h>
#import <Cocoa/Cocoa.h>
#import <Security/Security.h>

#import <NSBezierPath+IOS7RoundedRect.h>

static NSString * const kPluginBundleId = @"com.ealeksandrov.ProvisionQL";
static NSString * const kDataType_ipa               = @"com.apple.itunes.ipa";
static NSString * const kDataType_app               = @"com.apple.application-bundle";
static NSString * const kDataType_ios_provision     = @"com.apple.mobileprovision";
static NSString * const kDataType_ios_provision_old = @"com.apple.iphone.mobileprovision";
static NSString * const kDataType_osx_provision     = @"com.apple.provisionprofile";

#define SIGNED_CODE 0

NSImage *roundCorners(NSImage *image);
NSImage *imageFromApp(NSURL *URL, NSString *dataType, NSString *fileName);
NSString *mainIconNameForApp(NSDictionary *appPropertyList);
int expirationStatus(NSDate *date, NSCalendar *calendar);

Set bundle identifier constant to be identical to Info.plist


#pragma once

#include "uitypes.h"
#include <QtWidgets/QToolButton>
#include <QtCore/QParallelAnimationGroup>
#include <QtWidgets/QScrollArea>
#include <QtCore/QPropertyAnimation>

class BINARYNINJAUIAPI ExpandableGroup : public QWidget
{
	Q_OBJECT

  private:
	QToolButton* m_button;
	QParallelAnimationGroup* m_animation;
	QScrollArea* m_content;
	int m_duration = 100;

  private Q_SLOTS:
	void toggled(bool expanded);

  public:
	explicit ExpandableGroup(
	    QLayout* contentLayout, const QString& title = "", QWidget* parent = nullptr, bool expanded = false);
	void setupAnimation(QLayout* contentLayout);
	void setTitle(const QString& title) { m_button->setText(title); }
	void toggle(bool expanded);
};

#pragma once

#include "uitypes.h"
#include <QtWidgets/QLabel>
#include <QtWidgets/QToolButton>
#include <QtCore/QParallelAnimationGroup>
#include <QtWidgets/QScrollArea>
#include <QtCore/QPropertyAnimation>

class BINARYNINJAUIAPI ExpandableGroup : public QWidget
{
	Q_OBJECT

  private:
	QToolButton* m_button;
	QLabel* m_title;
	QParallelAnimationGroup* m_animation;
	QScrollArea* m_content;
	int m_duration = 100;

  private Q_SLOTS:
	void toggled(bool expanded);

  public:
	explicit ExpandableGroup(QLayout* contentLayout, const QString& title = "", QWidget* parent = nullptr, bool expanded = false);
	void setupAnimation(QLayout* contentLayout);
	void setTitle(const QString& title) { m_title->setText(title); }
	void toggle(bool expanded);
};

Fix UI arrow artifact in Cross References and Search widgets.


/*
 The MIT License (MIT)

 Copyright (c) 2016 tagener-noisu

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
*/

#ifndef SDL_IMAGE_WRAPPER_H
#define SDL_IMAGE_WRAPPER_H 1
//-------------------------------------------------------------------
#include <SDL_image.h>
#include "wrapper/exceptions.h"
//-------------------------------------------------------------------

namespace SDL {
namespace IMG {

static_assert(SDL_IMAGE_MAJOR_VERSION == 2,
	"Only version 2.x of SDL_image is supported");

template<class ErrorHandler =Throw>
class SdlImage {
	ErrorHandler handle_error;
public:
	SdlImage(int flags =0) {
		if ((IMG_Init(flags) & flags) != flags)
			handle_error(SDL_GetError());
	}

	~SdlImage() {
		IMG_Quit();
	}
};

template<>
class SdlImage<NoChecking> {
	int st;
public:
	SdlImage(int flags =0) :st {IMG_Init(flags)} {}

	int state() const { return st; }

	~SdlImage() {
		IMG_Quit();
	}
};

using SafeSdlImage = SdlImage<Throw>;
using UnsafeSdlImage = SdlImage<NoChecking>;

//-------------------------------------------------------------------

inline SDL_Surface* Load(const char* file) {
	return IMG_Load(file);
}

} // namespace
} // namespace
//-------------------------------------------------------------------
#endif

Add wrapper for SDL2_image lib

Add wrapper for SDL2_image lib


/***
 * Multi Timer
 * Copyright © 2013 Matthew Tole
 *
 * common.c
 ***/

#include <pebble.h>
#include "libs/xprintf.h"

void uppercase(char* str) {
  char* point = str;
  while (*point != '\0') {
    if (*point >= 97 && *point <= 122) {
      *point -= 32;
    }
    point += 1;
  }
}

int patoi(char* str) {
  long num;
  xatoi(&str, &num);
  return (int)num;
}

void timer_duration_str(int duration, bool showHours, char* str, int str_len) {
  int hours = duration / 3600;
  int minutes = (duration % 3600) / 60;
  int seconds = (duration % 3600) % 60;
  if (showHours) {
    snprintf(str, str_len, "%02d:%02d:%02d", hours, minutes, seconds);
  }
  else {
    snprintf(str, str_len, "%02d:%02d", minutes, seconds);
  }
}

/***
 * Multi Timer
 * Copyright © 2013 Matthew Tole
 *
 * common.c
 ***/

#include <pebble.h>
#include "libs/xprintf.h"

void uppercase(char* str) {
  char* point = str;
  while (*point != '\0') {
    if (*point >= 97 && *point <= 122) {
      *point -= 32;
    }
    point += 1;
  }
}

int patoi(char* str) {
  long num;
  xatoi(&str, &num);
  return (int)num;
}

void timer_duration_str(int duration, bool showHours, char* str, int str_len) {
  int hours = duration / 3600;
  int minutes = (showHours ? (duration % 3600) : duration) / 60;
  int seconds = (showHours ? (duration % 3600) : duration) % 60;
  if (showHours) {
    snprintf(str, str_len, "%02d:%02d:%02d", hours, minutes, seconds);
  }
  else {
    snprintf(str, str_len, "%02d:%02d", minutes, seconds);
  }
}

Fix bug in rendering of timer duration.

Fix bug in rendering of timer duration.


//
//  NSArray+EKFlatten.h
//  EnumeratorKit
//
//  Created by Adam Sharp on 23/07/13.
//  Copyright (c) 2013 Adam Sharp. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "NSArray+EKEnumerable.h"

/**
 * Extends NSArray with a single method `-flatten` to recursively
 * build a single-level array with all objects from all child arrays.
 */
@interface NSArray (EKFlatten)

/**
 * Recursively builds a new array by adding all objects from all child
 * arrays. The order of children is preserved. For example:
 *
 *     [@[@[@1, @2], @3] flatten] // => @[@1, @2, @3]
 *
 * and
 *
 *     @[@1, @[@2, @[@3, @4]], @5, @[@6]] // => @[@1, @2, @3, @4, @5, @6]
 */
- (NSArray *)flatten;

@end

//
//  NSArray+EKFlatten.h
//  EnumeratorKit
//
//  Created by Adam Sharp on 23/07/13.
//  Copyright (c) 2013 Adam Sharp. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "NSArray+EKEnumerable.h"

/**
 Extends NSArray with a single method `-flatten` to recursively build a
 single-level array with all objects from all child arrays.
 */
@interface NSArray (EKFlatten)

/**
 Recursively builds a new array by adding all objects from all child
 arrays. The order of children is preserved. For example:

    [@[@[@1, @2], @3] flatten] // => @[@1, @2, @3]

 and

    @[@1, @[@2, @[@3, @4]], @5, @[@6]] // => @[@1, @2, @3, @4, @5, @6]
 */
- (NSArray *)flatten;

@end

Improve [NSArray flatten] doc formatting


#ifndef IPC_H
#define IPC_H

#include "../process/process.h"

void current_fds(proc_t *proc);

#endif

#ifndef IPC_H
#define IPC_H

int current_fds(char *pidstr);

#endif

Adjust declaration for returning int

Adjust declaration for returning int


#ifndef _ACTIONBAR_H_
#define _ACTIONBAR_H_

#include <InputElement.h>

#include <Command.h>
#include <FWPlatform.h>

class ActionBar : public Element {
 public:
  ActionBar() { }

  bool isA(const std::string & className) override {
    if (className == "ActionBar") return true;
    return Element::isA(className);
  }

 protected:
  void initialize(FWPlatform * _platform) override {
    Element::initialize(_platform);
    Command c(Command::CREATE_ACTIONBAR, getParentInternalId(), getInternalId());
    sendCommand(c);
  }
};

#endif

#ifndef _ACTIONBAR_H_
#define _ACTIONBAR_H_

#include <InputElement.h>

#include <Command.h>
#include <FWPlatform.h>

class ActionBar : public Element {
 public:
  ActionBar() { }
  ActionBar(const char * _title) : title(_title) { }

  bool isA(const std::string & className) override {
    if (className == "ActionBar") return true;
    return Element::isA(className);
  }

 protected:
  void initialize(FWPlatform * _platform) override {
    Element::initialize(_platform);
    Command c(Command::CREATE_ACTIONBAR, getParentInternalId(), getInternalId());
    c.setTextValue(title);
    sendCommand(c);
  }

  const char * title;
};

#endif

Add constructor with title attached

Add constructor with title attached


// AnalyticsUtils.h
// Copyright (c) 2014 Segment.io. All rights reserved.

#import <Foundation/Foundation.h>

#define SEGStringize_helper(x) #x
#define SEGStringize(x) @SEGStringize_helper(x)

NSURL *SEGAnalyticsURLForFilename(NSString *filename);

// Async Utils
dispatch_queue_t seg_dispatch_queue_create_specific(const char *label, dispatch_queue_attr_t attr);
BOOL seg_dispatch_is_on_specific_queue(dispatch_queue_t queue);
void seg_dispatch_specific(dispatch_queue_t queue, dispatch_block_t block, BOOL waitForCompletion);
void seg_dispatch_specific_async(dispatch_queue_t queue, dispatch_block_t block);
void seg_dispatch_specific_sync(dispatch_queue_t queue, dispatch_block_t block);

// Logging

void SEGSetShowDebugLogs(BOOL showDebugLogs);
void SEGLog(NSString *format, ...);

// JSON Utils

NSDictionary *SEGCoerceDictionary(NSDictionary *dict);

NSString *SEGIDFA();

NSString *SEGEventNameForScreenTitle(NSString *title);

Fix "No new line at end of file" warning.


//
//  MapAnnotationList.h
//  GrizSpace
//
//  Created by Kevin Scott on 3/15/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

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

@interface MapAnnotationList : NSObject
{
    //int currentAnnotationIndex; //the currently selected annotation index
}

//@property (nonatomic, readwrite) bool currentAnnotationIndexSet; //used to determin if the current annotation index is set.
@property (nonatomic, readwrite) NSMutableArray* myAnnotationItems; //gets the list of annotation items

-(MapAnnotation*) GetNextAnnotation; //gets the next annotation item
-(MapAnnotation*) GetCurrentAnnotation; //gets the current annotation item

@end

Add space, commit to main

Add space, commit to main


//main
void cog_init();
void cog_mainloop();
void cog_destroy();

//anim
typedef struct cog_sprite
{
}cog_sprite;
cog_sprite* cog_add_anim(char* animimg, int milliseconds, ...);
void cog_play_anim(cog_sprite* sprite);

Test for animation which hasn't been implemented yet.


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

#if PROJECT == 1
#    include "project_1.h"
#else
#    error Unsupported project number in PROJECT macro. Valid values: 1
#endif

int main(int argc, char **argv)
{
    printf("Hello, world!\n");

#   if PROJECT == 1
    project_1_report();
#   endif

    return 0;
}

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

#if PROJECT == 0
#    // NOTE(bja, 2017-02): Building main with no project code.
#elif PROJECT == 1
#    include "project_1.h"
#else
#    error "Unsupported project number in PROJECT macro. Valid values: 0, 1"
#endif

int main(int argc, char **argv)
{
    printf("Hello, world!\n");

#   if PROJECT == 1
    project_1_report();
#   endif

    return 0;
}

Allow building executable without any project code.

Change the logic in main to allow building an executable without any project
code.

Testing: pass
  macOS:
    make clean; make test
    make clean; make project=0 test
    make clean; make project=1 test
    make clean; make project=2 test
    make clean; make platform=frdm project=0 all
    make clean; make platform=frdm project=1 all
    make clean; make platform=frdm project=2 all


#ifndef __EVIL_TEST_SYSCALLS_MOCK_H
#define __EVIL_TEST_SYSCALLS_MOCK_H

#include <gmock/gmock.h>

#include <string>
#include <stack>

#include "os/syscalls.h"

namespace evil {

class SyscallsMock
{
private:
    static thread_local std::stack<SyscallsMock *> _instance_stack;

public:
    SyscallsMock() { _instance_stack.push(this); }
    ~SyscallsMock() { _instance_stack.pop(); }

    static SyscallsMock *instance() { return _instance_stack.top(); }

    MOCK_METHOD2(_access, int(const char *path, int mode));
    MOCK_METHOD1(_close,  int(int fd));
    MOCK_METHOD1(_isatty, int(int fd));
    MOCK_METHOD2(_kill,   int(long pid, int sig));
    MOCK_METHOD3(_open,   int(const char *path, int flags, int mode));
    MOCK_METHOD0(_getpid, long(void));
    MOCK_METHOD3(_write,  ssize_t(int fd, const void *buf, size_t count));
    MOCK_METHOD1(_sbrk,   void *(ptrdiff_t increment));
    MOCK_METHOD1(_exit,   void(int exit_code));
};

} // namespace evil

#endif // __EVIL_TEST_SYSCALLS_MOCK_H

#ifndef __EVIL_TEST_SYSCALLS_MOCK_H
#define __EVIL_TEST_SYSCALLS_MOCK_H

#include <gmock/gmock.h>

#include <string>
#include <stack>

#include "os/syscalls.h"

namespace evil {

class SyscallsMock
{
private:
    static thread_local std::stack<SyscallsMock *> _instance_stack;

public:
    SyscallsMock() { _instance_stack.push(this); }
    ~SyscallsMock() { _instance_stack.pop(); }

    static SyscallsMock *instance() { return _instance_stack.top(); }

    MOCK_METHOD2(_access, int(const std::string &path, int mode));
    MOCK_METHOD1(_close,  int(int fd));
    MOCK_METHOD1(_isatty, int(int fd));
    MOCK_METHOD2(_kill,   int(long pid, int sig));
    MOCK_METHOD3(_open,   int(const std::string &path, int flags, int mode));
    MOCK_METHOD0(_getpid, long(void));
    MOCK_METHOD3(_write,  ssize_t(int fd, const void *buf, size_t count));
    MOCK_METHOD1(_sbrk,   void *(ptrdiff_t increment));
    MOCK_METHOD1(_exit,   void(int exit_code));
};

} // namespace evil

#endif // __EVIL_TEST_SYSCALLS_MOCK_H

Make mocked functions take std::string to allow == compare


#pragma once

#include <vector>
#include "types.h"

class MemoryBankController
{
public:
  MemoryBankController() = delete;
  MemoryBankController(const std::vector<u8> &rom, std::vector<u8> &ram) : rom(rom), ram(ram) {}
  virtual ~MemoryBankController() {}

  virtual u8 get8(uint address) const = 0;
  virtual void set8(uint address, u8 value) = 0;

  enum class BankingMode
  {
    ROM,
    RAM
  };

protected:
  const std::vector<u8> &rom;
  std::vector<u8> &ram;
  uint active_rom_bank = 1;
  uint active_ram_bank = 0;
  bool ram_enabled = false;
  BankingMode banking_mode = BankingMode::ROM;
};

class MBC1 final : public MemoryBankController
{
public:
  using MemoryBankController::MemoryBankController;

  u8 get8(uint address) const override;
  void set8(uint address, u8 value) override;
};

#pragma once

#include <vector>
#include "types.h"

class MemoryBankController
{
public:
  MemoryBankController() = delete;
  MemoryBankController(const std::vector<u8> &rom, std::vector<u8> &ram) : rom(rom), ram(ram) {}
  virtual ~MemoryBankController() {}

  virtual u8 get8(uint address) const = 0;
  virtual void set8(uint address, u8 value) = 0;

protected:
  const std::vector<u8> &rom;
  std::vector<u8> &ram;
  uint active_rom_bank = 1;
  uint active_ram_bank = 0;
  bool ram_enabled = false;
};

class MBC1 final : public MemoryBankController
{
  enum class BankingMode
  {
    ROM,
    RAM
  };

  BankingMode banking_mode = BankingMode::ROM;

public:
  using MemoryBankController::MemoryBankController;

  u8 get8(uint address) const override;
  void set8(uint address, u8 value) override;
};

MBC: Move BankingMode enum from base class to MBC1


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

#ifndef WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_
#define WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_

#include "ppapi/c/pp_var.h"

#define PPB_PRIVATE_INTERFACE "PPB_Private;1"

typedef enum _ppb_ResourceString {
  PPB_RESOURCE_STRING_PDF_GET_PASSWORD = 0,
} PP_ResourceString;

typedef struct _ppb_Private {
  // Returns a localized string.
  PP_Var (*GetLocalizedString)(PP_ResourceString string_id);
} PPB_Private;

#endif  // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_

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

#ifndef WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_
#define WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_

#include "third_party/ppapi/c/pp_var.h"

#define PPB_PRIVATE_INTERFACE "PPB_Private;1"

typedef enum _ppb_ResourceString {
  PPB_RESOURCE_STRING_PDF_GET_PASSWORD = 0,
} PP_ResourceString;

typedef struct _ppb_Private {
  // Returns a localized string.
  PP_Var (*GetLocalizedString)(PP_ResourceString string_id);
} PPB_Private;

#endif  // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE_H_

Add third_party/ prefix to ppapi include for checkdeps.

The only users of this ppb should be inside chrome so this should work fine.

TBR=jam@chromium.org

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

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


#ifndef JAGUAR_HELPER_H_
#define JAGUAR_HELPER_H_

#include <boost/detail/endian.hpp>
#include <stdint.h>
#include "jaguar_api.h"

#ifdef BOOST_LITTLE_ENDIAN
#define htole16(x) x
#define htole32(x) x
#define le16toh(x) x
#define le32toh(x) x
#elif BOOST_BIG_ENDIAN
#error big endian architectures are unsupported
#else
#error unknown endiannes
#endif

namespace jaguar {

int16_t  double_to_s8p8(double x);
uint16_t double_to_u8p8(double x);
int32_t  double_to_s16p16(double x);

double s8p8_to_double(int16_t x);
double s16p16_to_double(int32_t x);

uint32_t pack_id(uint8_t num, Manufacturer::Enum man, DeviceType::Enum type,
                 APIClass::Enum api_class, uint8_t api_index);

};

#endif

#ifndef JAGUAR_HELPER_H_
#define JAGUAR_HELPER_H_

#include <boost/detail/endian.hpp>
#include <stdint.h>
#include "jaguar_api.h"

#ifndef __GLIBC__
# ifdef BOOST_LITTLE_ENDIAN
#  define htole16(x) x
#  define htole32(x) x
#  define le16toh(x) x
#  define le32toh(x) x
# elif BOOST_BIG_ENDIAN
#  error big endian architectures are unsupported
# else
#  error unknown endiannes
# endif
#endif

namespace jaguar {

int16_t  double_to_s8p8(double x);
uint16_t double_to_u8p8(double x);
int32_t  double_to_s16p16(double x);

double s8p8_to_double(int16_t x);
double s16p16_to_double(int32_t x);

uint32_t pack_id(uint8_t num, Manufacturer::Enum man, DeviceType::Enum type,
                 APIClass::Enum api_class, uint8_t api_index);

};

#endif

Use provided byteorder convertions on GLIBC systems


#ifndef SUPPORT_TRACKED_VALUE_H
#define SUPPORT_TRACKED_VALUE_H

#include <cassert>

struct TrackedValue {
    enum State { CONSTRUCTED, MOVED_FROM, DESTROYED };
    State state;

    TrackedValue() : state(State::CONSTRUCTED) {}

    TrackedValue(TrackedValue const& t) : state(State::CONSTRUCTED) {
        assert(t.state != State::MOVED_FROM && "copying a moved-from object");
        assert(t.state != State::DESTROYED  && "copying a destroyed object");
    }

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    TrackedValue(TrackedValue&& t) : state(State::CONSTRUCTED) {
        assert(t.state != State::MOVED_FROM && "double moving from an object");
        assert(t.state != State::DESTROYED  && "moving from a destroyed object");
        t.state = State::MOVED_FROM;
    }
#endif

    TrackedValue& operator=(TrackedValue const& t) {
        assert(state != State::DESTROYED && "copy assigning into destroyed object");
        assert(t.state != State::MOVED_FROM && "copying a moved-from object");
        assert(t.state != State::DESTROYED  && "copying a destroyed object");
        state = t.state;
        return *this;
    }

#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
    TrackedValue& operator=(TrackedValue&& t) {
        assert(state != State::DESTROYED && "move assigning into destroyed object");
        assert(t.state != State::MOVED_FROM && "double moving from an object");
        assert(t.state != State::DESTROYED  && "moving from a destroyed object");
        state = t.state;
        t.state = State::MOVED_FROM;
        return *this;
    }
#endif

    ~TrackedValue() {
        assert(state != State::DESTROYED && "double-destroying an object");
        state = State::DESTROYED;
    }
};

#endif // SUPPORT_TRACKED_VALUE_H

Add TrackedValue to test/support. Thanks to Louis Dionne

git-svn-id: 756ef344af921d95d562d9e9f9389127a89a6314@231674 91177308-0d34-0410-b5e6-96231b3b80d8


#include "ruby.h"
#include "narray.h"

VALUE na_address(VALUE self) {
  struct NARRAY *ary;
  void * ptr;
  VALUE ret;

  GetNArray(self,ary);
  ptr = ary->ptr;
  ret = ULL2NUM( (unsigned long long int) ptr);
  return ret;
}

void Init_narray_ffi_c() {
  ID id;
  VALUE klass;
  id = rb_intern("NArray");
  klass = rb_const_get(rb_cObject, id);
  rb_define_private_method(klass, "address", na_address, 0);
}

#include "ruby.h"
#include "narray.h"

VALUE na_address(VALUE self) {
  struct NARRAY *ary;
  void * ptr;
  VALUE ret;

  GetNArray(self,ary);
  ptr = ary->ptr;
  ret = ULL2NUM( sizeof(ptr) == 4 ? (unsigned long long int) (unsigned long int) ptr : (unsigned long long int) ptr );
  return ret;
}

void Init_narray_ffi_c() {
  ID id;
  VALUE klass;
  id = rb_intern("NArray");
  klass = rb_const_get(rb_cObject, id);
  rb_define_private_method(klass, "address", na_address, 0);
}

Fix nasty sign propagation bug on gcc and 32 bit architectures.


/* Uncomment to compile with tcpd/libwrap support. */
//#define WITH_WRAP

/* Compile with database upgrading support? If disabled, mosquitto won't
 * automatically upgrade old database versions. */
//#define WITH_DB_UPGRADE

/* Compile with memory tracking support? If disabled, mosquitto won't track
 * heap memory usage nor export '$SYS/broker/heap/current size', but will use
 * slightly less memory and CPU time. */
#define WITH_MEMORY_TRACKING

/* Compile with the ability to upgrade from old style sqlite persistent
 * databases to the new mosquitto format. This means a dependency on sqlite. It
 * isn't needed for new installations. */
#define WITH_SQLITE_UPGRADE

Add compile option for sqlite db upgrades.


/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef SK_MILESTONE
#define SK_MILESTONE 91
#endif

/*
 * Copyright 2016 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#ifndef SK_MILESTONE
#define SK_MILESTONE 92
#endif

Update Skia milestone to 92

Update Skia milestone to 92

Change-Id: Ic8528149f531dfa78cfb994d9e6f080a4cc3139c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/393917
Reviewed-by: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>
Commit-Queue: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>
Auto-Submit: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>


#ifndef	CONFIG_EXPORTER_H
#define	CONFIG_EXPORTER_H

class ConfigClass;
class ConfigObject;
class ConfigValue;

class ConfigExporter {
protected:
	ConfigExporter(void)
	{ }

	~ConfigExporter()
	{ }

public:
	virtual void field(const ConfigValue *, const std::string&) = 0;
	virtual void object(const ConfigClass *, const ConfigObject *) = 0;
	virtual void value(const ConfigValue *, const std::string&) = 0;
};

#endif /* !CONFIG_EXPORTER_H */

#ifndef	CONFIG_EXPORTER_H
#define	CONFIG_EXPORTER_H

class ConfigClass;
class ConfigObject;
class ConfigValue;

class ConfigExporter {
protected:
	ConfigExporter(void)
	{ }

	virtual ~ConfigExporter()
	{ }

public:
	virtual void field(const ConfigValue *, const std::string&) = 0;
	virtual void object(const ConfigClass *, const ConfigObject *) = 0;
	virtual void value(const ConfigValue *, const std::string&) = 0;
};

#endif /* !CONFIG_EXPORTER_H */

Fix per Noris Datum's E-Mail.

Fix per Noris Datum's E-Mail.


#define SOCK_PATH "/var/run/devd.pipe"
#define REGEX "subsystem=CDEV type=(CREATE|DESTROY) cdev=(da[0-9]+[a-z]+[0-9]?[a-z]?)"

#define SOCK_PATH "/var/run/devd.pipe"
#define REGEX "subsystem=CDEV type=(CREATE|DESTROY) cdev=((da|mmcsd)[0-9]+[a-z]+[0-9]?[a-z]?)"

Support notifications for SD cards.

Support notifications for SD cards.

Tweak the regular expression a bit. SD cards are using device nodes such
as mmcsd0s1, so no notification would appear when we were looking for
da0s1 device nodes.


/*-
 * Copyright (c) 1997 John D. Polstra.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
 *
 * $FreeBSD$
 */

#ifndef	_ELF_H_
#define	_ELF_H_

#include <sys/types.h>
#include <machine/elf.h>

#endif /* !_ELF_H_ */

Add this header back, its existance is an SVR4-ELF tradition.
Our ELF hints bits are still a seperate file.

Requested by:	jdp


/*
 * 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_TYPES_H
#define __ARCH_TYPES_H

#include <assert.h>
#include <stdint.h>

compile_assert(long_is_32bits, sizeof(unsigned long) == 4)

typedef unsigned long word_t;
typedef word_t vptr_t;
typedef word_t paddr_t;
typedef word_t pptr_t;
typedef word_t cptr_t;
typedef word_t dev_id_t;
typedef word_t cpu_id_t;
typedef word_t node_id_t;
typedef word_t dom_t;

/* for libsel4 headers that the kernel shares */
typedef word_t seL4_Word;
typedef cptr_t seL4_CPtr;
typedef uint32_t seL4_Uint32;
typedef uint8_t seL4_Uint8;
typedef node_id_t seL4_NodeId;
typedef paddr_t seL4_PAddr;
typedef dom_t seL4_Domain;
#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_TYPES_H
#define __ARCH_TYPES_H

#include <config.h>
#include <assert.h>
#include <stdint.h>

#if defined(CONFIG_ARCH_IA32)
compile_assert(long_is_32bits, sizeof(unsigned long) == 4)
#elif defined(CONFIG_ARCH_X86_64)
compile_assert(long_is_64bits, sizeof(unsigned long) == 8)
#endif

typedef unsigned long word_t;
typedef word_t vptr_t;
typedef word_t paddr_t;
typedef word_t pptr_t;
typedef word_t cptr_t;
typedef word_t dev_id_t;
typedef word_t cpu_id_t;
typedef word_t node_id_t;
typedef word_t dom_t;

/* for libsel4 headers that the kernel shares */
typedef word_t seL4_Word;
typedef cptr_t seL4_CPtr;
typedef uint32_t seL4_Uint32;
typedef uint8_t seL4_Uint8;
typedef node_id_t seL4_NodeId;
typedef paddr_t seL4_PAddr;
typedef dom_t seL4_Domain;
#endif

Check size of unsigned long

x64: Check size of unsigned long


//
//  constants.h
//  AESTextEncryption
//
//  Created by Evgenii Neumerzhitckii on 21/02/2015.
//  Copyright (c) 2015 Evgenii Neumerzhitckii. All rights reserved.
//

#define aesCompactHeight 400

#define aesPasswordTopMargin 11
#define aesPasswordTopMargin_compact 4

#define aesMessageTopMargin 10
#define aesMessageTopMargin_compact 0

#define aesPasswordHeightMargin 40
#define aesPasswordHeightMargin_compact 30

Add compact mode for phone landscape orientation


// Parse diagnostic arguments in the driver
// PR12181

// RUN: !%clang -target x86_64-apple-darwin10 \
// RUN:   -fsyntax-only -fzyzzybalubah \
// RUN:   -Werror=unused-command-line-argument %s

// RUN: !%clang -target x86_64-apple-darwin10 \
// RUN:   -fsyntax-only -fzyzzybalubah -Werror %s

// Parse diagnostic arguments in the driver
// PR12181

// RUN: not %clang -target x86_64-apple-darwin10 \
// RUN:   -fsyntax-only -fzyzzybalubah \
// RUN:   -Werror=unused-command-line-argument %s

// RUN: not %clang -target x86_64-apple-darwin10 \
// RUN:   -fsyntax-only -fzyzzybalubah -Werror %s

Update test case to use not tool.

Update test case to use not tool.

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


#include "lorito.h"

#ifndef LORITO_INTERP_H_GUARD
#define LORITO_INTERP_H_GUARD

Lorito_Ctx *
lorito_ctx_init(Lorito_Ctx *next_ctx, Lorito_Codeseg *codeseg);

Lorito_Interp *
lorito_init();

int
lorito_run(Lorito_Interp *interp);

#endif /* LORITO_INTERP_H_GUARD */

#include "lorito.h"

#ifndef LORITO_INTERP_H_GUARD
#define LORITO_INTERP_H_GUARD

Lorito_Ctx *
lorito_ctx_init(Lorito_Ctx *next_ctx, Lorito_Codeseg *codeseg);

Lorito_PMC *
lorito_pmc_init(Lorito_Interp *interp, int size);

Lorito_Interp *
lorito_init();

int
lorito_run(Lorito_Interp *interp);

#endif /* LORITO_INTERP_H_GUARD */

Add lorito_pmc_init to the proper header.


#include "pocl_cl.h"
#include "pocl_timing.h"

CL_API_ENTRY cl_int CL_API_CALL
POname(clSetUserEventStatus)(cl_event event ,
                             cl_int   execution_status )
CL_API_SUFFIX__VERSION_1_1
{
  /* Must be a valid user event */
  POCL_RETURN_ERROR_COND((event == NULL), CL_INVALID_EVENT);
  POCL_RETURN_ERROR_COND((event->command_type != CL_COMMAND_USER), CL_INVALID_EVENT);
  /* Can only be set to CL_COMPLETE (0) or negative values */
  POCL_RETURN_ERROR_COND((execution_status > CL_COMPLETE), CL_INVALID_VALUE);
  /* Can only be done once */
  POCL_RETURN_ERROR_COND((event->status <= CL_COMPLETE), CL_INVALID_OPERATION);

  POCL_LOCK_OBJ (event);
  event->status = execution_status;
  if (execution_status == CL_COMPLETE)
    {
      pocl_broadcast (event);
    }
  POCL_UNLOCK_OBJ (event);
  return CL_SUCCESS;
}
POsym(clSetUserEventStatus)

#include "pocl_cl.h"
#include "pocl_timing.h"

CL_API_ENTRY cl_int CL_API_CALL
POname(clSetUserEventStatus)(cl_event event ,
                             cl_int   execution_status )
CL_API_SUFFIX__VERSION_1_1
{
  /* Must be a valid user event */
  POCL_RETURN_ERROR_COND((event == NULL), CL_INVALID_EVENT);
  POCL_RETURN_ERROR_COND((event->command_type != CL_COMMAND_USER), CL_INVALID_EVENT);
  /* Can only be set to CL_COMPLETE (0) or negative values */
  POCL_RETURN_ERROR_COND((execution_status > CL_COMPLETE), CL_INVALID_VALUE);
  /* Can only be done once */
  POCL_RETURN_ERROR_COND((event->status <= CL_COMPLETE), CL_INVALID_OPERATION);

  POCL_LOCK_OBJ (event);
  event->status = execution_status;
  if (execution_status == CL_COMPLETE)
    {
      pocl_broadcast (event);
      pocl_event_updated (event, CL_COMPLETE);
    }
  POCL_UNLOCK_OBJ (event);
  return CL_SUCCESS;
}
POsym(clSetUserEventStatus)

Make sure callbacks are called for user events


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

#ifndef LLVM_DEBUGINFO_DWARFRELOCMAP_H
#define LLVM_DEBUGINFO_DWARFRELOCMAP_H

#include "llvm/ADT/DenseMap.h"

namespace llvm {

typedef DenseMap<uint64_t, std::pair<uint8_t, int64_t> > RelocAddrMap;

} // namespace llvm

#endif // LLVM_DEBUGINFO_DWARFRELOCMAP_H

Fix a warning in the new DWARFheader. Add a new line at the end of the file.

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


// Machine types
typedef unsigned char		Byte;	   /* 8 bits */
typedef unsigned short		SWord;	   /* 16 bits */
typedef unsigned int		DWord;	   /* 32 bits */
typedef unsigned int		dword;	   /* 32 bits */
typedef unsigned int		Word;	   /* 32 bits */
typedef unsigned int		ADDRESS;   /* 32-bit unsigned */

#define STD_SIZE	32			// Standard size
#define NO_ADDRESS ((ADDRESS)-1)  // For invalid ADDRESSes

#ifndef _MSC_VER
typedef long unsigned long QWord;	// 64 bits
#else
typedef unsigned __int64   QWord;
#endif

#if defined(_MSC_VER)
#pragma warning(disable:4390)
#endif

#if defined(_MSC_VER) && _MSC_VER <= 1200
// For MSVC 5 or 6: warning about debug into truncated to 255 chars
#pragma warning(disable:4786)
#endif

/*
 * types.h: some often used basic type definitions
 * $Revision$
 */
#ifndef __TYPES_H__
#define __TYPES_H__

// Machine types
typedef unsigned char		Byte;		/* 8 bits */
typedef unsigned short		SWord;		/* 16 bits */
typedef unsigned int		DWord;		/* 32 bits */
typedef unsigned int		dword;		/* 32 bits */
typedef unsigned int		Word;		/* 32 bits */
typedef unsigned int		ADDRESS;	/* 32-bit unsigned */

#define STD_SIZE	32					// Standard size
// Note: there is a known name collision with NO_ADDRESS in WinSock.h
#ifdef NO_ADDRESS
#undef NO_ADDRESS
#endif
#define NO_ADDRESS ((ADDRESS)-1)		// For invalid ADDRESSes

#ifndef _MSC_VER
typedef long unsigned long QWord;		// 64 bits
#else
typedef unsigned __int64   QWord;
#endif

#if defined(_MSC_VER)
#pragma warning(disable:4390)
#endif

#if defined(_MSC_VER) && _MSC_VER <= 1200
// For MSVC 5 or 6: warning about debug into truncated to 255 chars
#pragma warning(disable:4786)
#endif

#endif	// #ifndef __TYPES_H__

Handle the name collision (with WinSock.h) for NO_ADDRESS


#pragma once
#include "bpftrace.h"
#include "log.h"
#include "pass_manager.h"
#include "visitors.h"

namespace bpftrace {
namespace ast {

class NodeCounter : public Visitor
{
public:
  void Visit(Node &node)
  {
    count_++;
    Visitor::Visit(node);
  }

  size_t get_count()
  {
    return count_;
  };

private:
  size_t count_ = 0;
};

Pass CreateCounterPass()
{
  auto fn = [](Node &n, PassContext &ctx) {
    NodeCounter c;
    c.Visit(n);
    auto node_count = c.get_count();
    auto max = ctx.b.ast_max_nodes_;
    if (bt_verbose)
    {
      LOG(INFO) << "node count: " << node_count;
    }
    if (node_count >= max)
    {
      LOG(ERROR) << "node count (" << node_count << ") exceeds the limit ("
                 << max << ")";
      return PassResult::Error("node count exceeded");
    }
    return PassResult::Success();
  };
  return Pass("NodeCounter", fn);
}

} // namespace ast
} // namespace bpftrace

#pragma once
#include "bpftrace.h"
#include "log.h"
#include "pass_manager.h"
#include "visitors.h"

namespace bpftrace {
namespace ast {

class NodeCounter : public Visitor
{
public:
  void Visit(Node &node) override
  {
    count_++;
    Visitor::Visit(node);
  }

  size_t get_count()
  {
    return count_;
  };

private:
  size_t count_ = 0;
};

Pass CreateCounterPass()
{
  auto fn = [](Node &n, PassContext &ctx) {
    NodeCounter c;
    c.Visit(n);
    auto node_count = c.get_count();
    auto max = ctx.b.ast_max_nodes_;
    if (bt_verbose)
    {
      LOG(INFO) << "node count: " << node_count;
    }
    if (node_count >= max)
    {
      LOG(ERROR) << "node count (" << node_count << ") exceeds the limit ("
                 << max << ")";
      return PassResult::Error("node count exceeded");
    }
    return PassResult::Success();
  };
  return Pass("NodeCounter", fn);
}

} // namespace ast
} // namespace bpftrace

Add override keyword to overridden method


// REQUIRES: mips-registered-target
// RUN: %clang -### -c -target mips-mti-elf %s -mgpopt 2>&1 | FileCheck -check-prefix=IMPLICIT %s
// IMPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with the implicit usage of-mabicalls

// RUN: %clang -### -c -target mips-mti-elf %s -mgpopt -mabicalls 2>&1 | FileCheck -check-prefix=EXPLICIT %s
// EXPLICIT: warning: ignoring '-mgpopt' option as it cannot be used with -mabicalls

Add warning test for -mgpopt option.

[mips] Add warning test for -mgpopt option.

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


/* Copyright (c) 2004 Timo Sirainen */

#include "lib.h"
#include "str.h"
#include "str-sanitize.h"

void str_sanitize_append(string_t *dest, const char *src, size_t max_len)
{
	const char *p;

	for (p = src; *p != '\0'; p++) {
		if ((unsigned char)*p < 32)
			break;
	}

	str_append_n(dest, src, (size_t)(p - src));
	for (; *p != '\0' && max_len > 0; p++, max_len--) {
		if ((unsigned char)*p < 32)
			str_append_c(dest, '?');
		else
			str_append_c(dest, *p);
	}

	if (*p != '\0') {
		str_truncate(dest, str_len(dest)-3);
		str_append(dest, "...");
	}
}

const char *str_sanitize(const char *src, size_t max_len)
{
	string_t *str;

	str = t_str_new(I_MIN(max_len, 256));
	str_sanitize_append(str, src, max_len);
	return str_c(str);
}

/* Copyright (c) 2004 Timo Sirainen */

#include "lib.h"
#include "str.h"
#include "str-sanitize.h"

void str_sanitize_append(string_t *dest, const char *src, size_t max_len)
{
	const char *p;

	for (p = src; *p != '\0'; p++) {
		if (((unsigned char)*p & 0x7f) < 32)
			break;
	}

	str_append_n(dest, src, (size_t)(p - src));
	for (; *p != '\0' && max_len > 0; p++, max_len--) {
		if (((unsigned char)*p & 0x7f) < 32)
			str_append_c(dest, '?');
		else
			str_append_c(dest, *p);
	}

	if (*p != '\0') {
		str_truncate(dest, str_len(dest)-3);
		str_append(dest, "...");
	}
}

const char *str_sanitize(const char *src, size_t max_len)
{
	string_t *str;

	str = t_str_new(I_MIN(max_len, 256));
	str_sanitize_append(str, src, max_len);
	return str_c(str);
}

Convert also 0x80..0x9f characters to '?'


#ifndef Magnum_Implementation_maxTextureSize_h
#define Magnum_Implementation_maxTextureSize_h
/*
    This file is part of Magnum.

    Copyright © 2010, 2011, 2012, 2013, 2014, 2015
              Vladimír Vondruš <mosra@centrum.cz>

    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the "Software"),
    to deal in the Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish, distribute, sublicense,
    and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.
*/

#include "Magnum/OpenGL.h"

namespace Magnum { namespace Implementation {

GLint maxTextureSideSize();
GLint max3DTextureDepth();
GLint maxTextureArrayLayers();
GLint maxCubeMapTextureSideSize();

}}

#endif

#ifndef Magnum_Implementation_maxTextureSize_h
#define Magnum_Implementation_maxTextureSize_h
/*
    This file is part of Magnum.

    Copyright © 2010, 2011, 2012, 2013, 2014, 2015
              Vladimír Vondruš <mosra@centrum.cz>

    Permission is hereby granted, free of charge, to any person obtaining a
    copy of this software and associated documentation files (the "Software"),
    to deal in the Software without restriction, including without limitation
    the rights to use, copy, modify, merge, publish, distribute, sublicense,
    and/or sell copies of the Software, and to permit persons to whom the
    Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included
    in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
    DEALINGS IN THE SOFTWARE.
*/

#include "Magnum/OpenGL.h"

namespace Magnum { namespace Implementation {

GLint maxTextureSideSize();
GLint max3DTextureDepth();
#ifndef MAGNUM_TARGET_GLES2
GLint maxTextureArrayLayers();
#endif
GLint maxCubeMapTextureSideSize();

}}

#endif

Hide internal function declaration on ES2 builds.

The implementation was already hidden so this is not needed too.


#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <getopt.h>
#include <sys/uio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>

#include "utils.h"
#include "logSpeed.h"

int keepRunning = 1;

int main(int argc, char *argv[]) {
  //  int index = handle_args(argc, argv);
  int index = 1;
  //  signal(SIGTERM, intHandler);
  //  signal(SIGINT, intHandler);

  for (size_t i = index; i < argc; i++) {
    int fd = open(argv[i], O_WRONLY | O_EXCL | O_DIRECT);
    if (fd >= 0) {
      size_t bdsize = blockDeviceSizeFromFD(fd);
      trimDevice(fd, argv[i], 0, bdsize); // only sending 1GiB for now
      close(fd);
    } else {
      perror("open");
    }
  }

  return 0;
}

#define _GNU_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <getopt.h>
#include <sys/uio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>

#include "utils.h"
#include "logSpeed.h"

int keepRunning = 1;

int main(int argc, char *argv[]) {
  //  int index = handle_args(argc, argv);
  int index = 1;
  //  signal(SIGTERM, intHandler);
  //  signal(SIGINT, intHandler);

  for (size_t i = index; i < argc; i++) {
    int fd = open(argv[i], O_RDWR | O_EXCL | O_DIRECT );
    if (fd >= 0) {
      size_t bdsize = blockDeviceSizeFromFD(fd);
      trimDevice(fd, argv[i], 0, bdsize - 512);
      close(fd);
    } else {
      perror("open");
    }
  }

  return 0;
}

Subtract one old school sector

Subtract one old school sector


#ifndef ALCONFIG_H
#define ALCONFIG_H

void ReadALConfig(void);
void FreeALConfig(void);

int ConfigValueExists(const char *devName, const char *blockName, const char *keyName);
const char *GetConfigValue(const char *devName, const char *blockName, const char *keyName, const char *def);
int GetConfigValueBool(const char *devName, const char *blockName, const char *keyName, int def);

int ConfigValueStr(const char *devName, const char *blockName, const char *keyName, const char **ret);
int ConfigValueInt(const char *devName, const char *blockName, const char *keyName, int *ret);
int ConfigValueUInt(const char *devName, const char *blockName, const char *keyName, unsigned int *ret);
int ConfigValueFloat(const char *devName, const char *blockName, const char *keyName, float *ret);
int ConfigValueBool(const char *devName, const char *blockName, const char *keyName, int *ret);

#endif /* ALCONFIG_H */

#ifndef ALCONFIG_H
#define ALCONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

void ReadALConfig(void);
void FreeALConfig(void);

int ConfigValueExists(const char *devName, const char *blockName, const char *keyName);
const char *GetConfigValue(const char *devName, const char *blockName, const char *keyName, const char *def);
int GetConfigValueBool(const char *devName, const char *blockName, const char *keyName, int def);

int ConfigValueStr(const char *devName, const char *blockName, const char *keyName, const char **ret);
int ConfigValueInt(const char *devName, const char *blockName, const char *keyName, int *ret);
int ConfigValueUInt(const char *devName, const char *blockName, const char *keyName, unsigned int *ret);
int ConfigValueFloat(const char *devName, const char *blockName, const char *keyName, float *ret);
int ConfigValueBool(const char *devName, const char *blockName, const char *keyName, int *ret);

#ifdef __cplusplus
} // extern "C"
#endif

#endif /* ALCONFIG_H */

Add another missing extern "C"

Add another missing extern "C"


#ifndef GLOBAL_FAKES_H_
#define GLOBAL_FAKES_H_

#include "../fff3.h"

void global_void_func(void);
DECLARE_FAKE_VOID_FUNC0(global_void_func);

#endif /* GLOBAL_FAKES_H_ */

#ifndef GLOBAL_FAKES_H_
#define GLOBAL_FAKES_H_

#include "../fff3.h"

////  Imaginary production code header file ///
void voidfunc1(int);
void voidfunc2(char, char);
long longfunc0();

enum MYBOOL { FALSE = 899, TRUE };
struct MyStruct {
    int x;
    int y;
};
enum MYBOOL enumfunc();
struct MyStruct structfunc();
////  End Imaginary production code header file ///

DECLARE_FAKE_VOID_FUNC1(voidfunc1, int);
DECLARE_FAKE_VOID_FUNC2(voidfunc2, char, char);
DECLARE_FAKE_VALUE_FUNC0(long, longfunc0);
DECLARE_FAKE_VALUE_FUNC0(enum MYBOOL, enumfunc0);
DECLARE_FAKE_VALUE_FUNC0(struct MyStruct, structfunc0);

#endif /* GLOBAL_FAKES_H_ */

Add fakes for common test cases

Add fakes for common test cases


// RUN: not %llvmgcc -std=gnu99 %s -S |& grep "error: alignment for"

int foo(int a)
{
  int var[a] __attribute__((__aligned__(32)));
  return 4;
}

// RUN: %llvmgcc_only -std=gnu99 %s -S |& grep "warning: alignment for"

int foo(int a)
{
  int var[a] __attribute__((__aligned__(32)));
  return 4;
}

Fix this up per llvm-gcc r109819.

Fix this up per llvm-gcc r109819.

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


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

#ifndef _MP4PARSE_RUST_H
#define _MP4PARSE_RUST_H

#ifdef __cplusplus
extern "C" {
#endif

struct mp4parse_state;

struct mp4parse_state* mp4parse_state_new(void);
void mp4parse_state_free(struct mp4parse_state* state);

int32_t mp4parse_state_feed(struct mp4parse_state* state, uint8_t *buffer, size_t size);

#ifdef __cplusplus
}
#endif

#endif

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

#ifndef _MP4PARSE_RUST_H
#define _MP4PARSE_RUST_H

#ifdef __cplusplus
extern "C" {
#endif

struct mp4parse_state;

struct mp4parse_state* mp4parse_new(void);
void mp4parse_free(struct mp4parse_state* state);

int32_t mp4parse_read(struct mp4parse_state* state, uint8_t *buffer, size_t size);

#ifdef __cplusplus
}
#endif

#endif

Update C header to match capi.rs function names.


#ifndef RWTE_COORDS_H
#define RWTE_COORDS_H

struct Cell
{
    int row, col;

    inline bool operator==(const Cell& other) const
    {
        return row == other.row && col == other.col;
    }

    inline bool operator!=(const Cell& other) const
    {
        return row != other.row || col != other.col;
    }

    inline bool operator< (const Cell& other) const
    {
        return row < other.row || col < other.col;
    }

    inline bool operator> (const Cell& other) const
    {
        return row > other.row || col > other.col;
    }

    inline bool operator<=(const Cell& other) const
    {
        return row < other.row || col < other.col ||
            (row == other.row && col == other.col);
    }

    inline bool operator>=(const Cell& other) const
    {
        return row > other.row || col > other.col ||
            (row == other.row && col == other.col);
    }
};

#endif // RWTE_COORDS_H

#ifndef RWTE_COORDS_H
#define RWTE_COORDS_H

struct Cell
{
    int row = 0;
    int col = 0;

    inline bool operator==(const Cell& other) const
    {
        return row == other.row && col == other.col;
    }

    inline bool operator!=(const Cell& other) const
    {
        return row != other.row || col != other.col;
    }

    inline bool operator< (const Cell& other) const
    {
        return row < other.row || col < other.col;
    }

    inline bool operator> (const Cell& other) const
    {
        return row > other.row || col > other.col;
    }

    inline bool operator<=(const Cell& other) const
    {
        return row < other.row || col < other.col ||
            (row == other.row && col == other.col);
    }

    inline bool operator>=(const Cell& other) const
    {
        return row > other.row || col > other.col ||
            (row == other.row && col == other.col);
    }
};

#endif // RWTE_COORDS_H

Set default values for Cell members.

Set default values for Cell members.


/*
 * $Id$
 *
 * Define the tags in the shared memory in a reusable format.
 * Whoever includes this get to define what the SLTM macro does.
 *
 */

SLTM(Debug)
SLTM(Error)
SLTM(CLI)
SLTM(SessionOpen)
SLTM(SessionReuse)
SLTM(SessionClose)
SLTM(BackendOpen)
SLTM(BackendXID)
SLTM(BackendReuse)
SLTM(BackendClose)
SLTM(HttpError)
SLTM(ClientAddr)
SLTM(Backend)
SLTM(Request)
SLTM(Response)
SLTM(Length)
SLTM(Status)
SLTM(URL)
SLTM(Protocol)
SLTM(Header)
SLTM(BldHdr)
SLTM(LostHeader)
SLTM(VCL_call)
SLTM(VCL_trace)
SLTM(VCL_return)
SLTM(XID)
SLTM(Hit)
SLTM(ExpBan)
SLTM(ExpPick)
SLTM(ExpKill)
SLTM(WorkThread)

/*
 * $Id$
 *
 * Define the tags in the shared memory in a reusable format.
 * Whoever includes this get to define what the SLTM macro does.
 *
 * REMEMBER to update the documentation (especially the varnishlog(1) man
 * page) whenever this list changes.
 */

SLTM(Debug)
SLTM(Error)
SLTM(CLI)
SLTM(SessionOpen)
SLTM(SessionReuse)
SLTM(SessionClose)
SLTM(BackendOpen)
SLTM(BackendXID)
SLTM(BackendReuse)
SLTM(BackendClose)
SLTM(HttpError)
SLTM(ClientAddr)
SLTM(Backend)
SLTM(Request)
SLTM(Response)
SLTM(Length)
SLTM(Status)
SLTM(URL)
SLTM(Protocol)
SLTM(Header)
SLTM(BldHdr)
SLTM(LostHeader)
SLTM(VCL_call)
SLTM(VCL_trace)
SLTM(VCL_return)
SLTM(XID)
SLTM(Hit)
SLTM(ExpBan)
SLTM(ExpPick)
SLTM(ExpKill)
SLTM(WorkThread)

Add a note to update varnishlog(1) whenever this list changes.

git-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@418 d4fa192b-c00b-0410-8231-f00ffab90ce4


const char *field_sep = "  \u2022  ";
const char *time_fmt  = "%x %I:%M %p";

const int update_period = 90;

char *
loadavg(void)
{
	double avgs[3];

	if (getloadavg(avgs, 3) < 0) {
		perror("getloadavg");
		exit(1);
	}

	return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
}

char *
prettytime(void)
{
	return mktimes(time_fmt, NULL);
}

static char *(*forder[])(void) = {
	loadavg,
	prettytime,
	NULL
};

const char *field_sep = "  \u2022  ";
const char *time_fmt  = "%x %I:%M %p";

const int update_period = 15;

char *
loadavg(void)
{
	double avgs[3];

	if (getloadavg(avgs, 3) < 0) {
		perror("getloadavg");
		exit(1);
	}

	return smprintf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]);
}

char *
prettytime(void)
{
	return mktimes(time_fmt, NULL);
}

static char *(*forder[])(void) = {
	loadavg,
	prettytime,
	NULL
};

Change update_period to 15 seconds

Change update_period to 15 seconds

On a laptop, 90 seconds between battery status updates can lead to
unnecessary worrying about whether or not the AC adapter is broken.


//
//  Copyright © 2019 Google. All rights reserved.
//

static NSString *const kGADMAdapterVungleVersion = @"6.4.2.1";
static NSString *const kGADMAdapterVungleApplicationID = @"application_id";
static NSString *const kGADMAdapterVunglePlacementID = @"placementID";
static NSString *const kGADMAdapterVungleErrorDomain =
    @"com.google.mediation.vungle";

//
//  Copyright © 2019 Google. All rights reserved.
//

static NSString *const kGADMAdapterVungleVersion = @"6.4.3.0";
static NSString *const kGADMAdapterVungleApplicationID = @"application_id";
static NSString *const kGADMAdapterVunglePlacementID = @"placementID";
static NSString *const kGADMAdapterVungleErrorDomain =
    @"com.google.mediation.vungle";

Update adapter version number to 6.4.3.0


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

// angleutils.h: Common ANGLE utilities.

#ifndef COMMON_ANGLEUTILS_H_
#define COMMON_ANGLEUTILS_H_

// A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
  TypeName(const TypeName&);               \
  void operator=(const TypeName&)

template <typename T, unsigned int N>
inline unsigned int ArraySize(T(&)[N])
{
    return N;
}

#if defined(_MSC_VER)
#define snprintf _snprintf
#endif

#define VENDOR_ID_AMD 0x1002
#define VENDOR_ID_INTEL 0x8086
#define VENDOR_ID_NVIDIA 0x10DE

#define GL_BGRA4_ANGLEX 0x6ABC
#define GL_BGR5_A1_ANGLEX 0x6ABD

#endif // COMMON_ANGLEUTILS_H_

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

// angleutils.h: Common ANGLE utilities.

#ifndef COMMON_ANGLEUTILS_H_
#define COMMON_ANGLEUTILS_H_

// A macro to disallow the copy constructor and operator= functions
// This must be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
  TypeName(const TypeName&);               \
  void operator=(const TypeName&)

template <typename T, unsigned int N>
inline unsigned int ArraySize(T(&)[N])
{
    return N;
}

template <typename T, unsigned int N>
void SafeRelease(T (&resourceBlock)[N])
{
    for (unsigned int i = 0; i < N; i++)
    {
        SafeRelease(resourceBlock[i]);
    }
}

template <typename T>
void SafeRelease(T& resource)
{
    if (resource)
    {
        resource->Release();
        resource = NULL;
    }
}

#if defined(_MSC_VER)
#define snprintf _snprintf
#endif

#define VENDOR_ID_AMD 0x1002
#define VENDOR_ID_INTEL 0x8086
#define VENDOR_ID_NVIDIA 0x10DE

#define GL_BGRA4_ANGLEX 0x6ABC
#define GL_BGR5_A1_ANGLEX 0x6ABD

#endif // COMMON_ANGLEUTILS_H_

Add helper functions to safely release Windows COM resources, and arrays of COM resources.

TRAC #22656

Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
Author: Jamie Madill

git-svn-id: 7288974629ec06eaf04ee103a0a5f761b9efd9a5@2076 736b8ea6-26fd-11df-bfd4-992fa37f6226


#ifndef _CONFIG_H_
#define _CONFIG_H_

#define DEBUG					0

#define BADGE_MINIMUM_ID		3000	/* Inclusive */
#define BADGE_MAXIMUM_ID		8000	/* Inclusive */

#define HISTORY_WINDOW_SIZE		128
	/** Optionally workaround a bug whereby sequence IDs are
	 * not held constant within a burst of identical packets
	 *
	 * Set to 0 to disable workaround, or 2 to ignore the bottom
	 * two bits of all sequence IDs, since badges send 4 packets
	 * at a time.
	 */
#define CONFIG_SEQUENCE_ID_SHIFT	2

#endif

#ifndef _CONFIG_H_
#define _CONFIG_H_

#define DEBUG					0

#define BADGE_MINIMUM_ID		3000	/* Inclusive */
#define BADGE_MAXIMUM_ID		8000	/* Inclusive */

#define HISTORY_WINDOW_SIZE		32
	/** Optionally workaround a bug whereby sequence IDs are
	 * not held constant within a burst of identical packets
	 *
	 * Set to 0 to disable workaround, or 2 to ignore the bottom
	 * two bits of all sequence IDs, since badges send 4 packets
	 * at a time.
	 */
#define CONFIG_SEQUENCE_ID_SHIFT	2

#endif

Reduce history size to 32 buckets

Reduce history size to 32 buckets


/* Try to drop the last supplemental group, and print a message to stdout
   describing what happened. */

#include <errno.h>
#include <grp.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

#define NGROUPS_MAX 32

int main()
{
   int group_ct;
   gid_t groups[NGROUPS_MAX];

   group_ct = getgroups(NGROUPS_MAX, groups);
   if (group_ct == -1) {
      printf("ERROR\tgetgroups(2) failed with errno=%d\n", errno);
      return 1;
   }

   fprintf(stderr, "found %d groups; trying to drop last group %d\n",
           group_ct, groups[group_ct - 1]);

   if (setgroups(group_ct - 1, groups)) {
      if (errno == EPERM) {
         printf("SAFE\tsetgroups(2) failed with EPERM\n");
         return 0;
      } else {
         printf("ERROR\tsetgroups(2) failed with errno=%d\n", errno);
         return 1;
      }
   } else {
      printf("RISK\tsetgroups(2) succeeded\n");
      return 1;
   }
}

/* Try to drop the last supplemental group, and print a message to stdout
   describing what happened. */

#include <errno.h>
#include <grp.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

#define NGROUPS_MAX 128

int main()
{
   int group_ct;
   gid_t groups[NGROUPS_MAX];

   group_ct = getgroups(NGROUPS_MAX, groups);
   if (group_ct == -1) {
      printf("ERROR\tgetgroups(2) failed with errno=%d\n", errno);
      return 1;
   }

   fprintf(stderr, "found %d groups; trying to drop last group %d\n",
           group_ct, groups[group_ct - 1]);

   if (setgroups(group_ct - 1, groups)) {
      if (errno == EPERM) {
         printf("SAFE\tsetgroups(2) failed with EPERM\n");
         return 0;
      } else {
         printf("ERROR\tsetgroups(2) failed with errno=%d\n", errno);
         return 1;
      }
   } else {
      printf("RISK\tsetgroups(2) succeeded\n");
      return 1;
   }
}

Raise maximum groups in chtest to the same number used in ch-run.

Signed-off-by: Oliver Freyermuth <297815a44ac0d229e08a814adf0f210787d04d87@googlemail.com>


/*
Copyright 2016 Andreas Bjerkeholt

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

#if defined(WIN32) || defined(_WIN32)
#define WINDOWS
#endif

#if defined(__unix) || defined(__unix__)
#define UNIX
#endif

#define FPS 60

extern bool debugViewBounds;
extern bool isLauncher;

#endif

/*
Copyright 2016 Andreas Bjerkeholt

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

#if defined(WIN32) || defined(_WIN32)
#define WINDOWS
#endif

#if defined(__unix) || defined(__unix__) || defined(__APPLE__)
#define UNIX
#endif

#define FPS 60

extern bool debugViewBounds;
extern bool isLauncher;

#endif

Add OSX-specific macro to the list of platforms detected as UNIX


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

#ifndef CHROME_BROWSER_THUMBNAIL_STORE_H_
#define CHROME_BROWSER_THUMBNAIL_STORE_H_

#include <vector>

#include "base/file_path.h"

class GURL;
class SkBitmap;
struct ThumbnailScore;
namespace base {
class Time;
}

// This storage interface provides storage for the thumbnails used
// by the new_tab_ui.
class ThumbnailStore {
 public:
  ThumbnailStore();
  ~ThumbnailStore();

  // Must be called after creation but before other methods are called.
  // file_path is where a new database should be created or the
  // location of an existing databse.
  // If false is returned, no other methods should be called.
  bool Init(const FilePath& file_path);

  // Stores the given thumbnail and score with the associated url.
  bool SetPageThumbnail(const GURL& url,
                        const SkBitmap& thumbnail,
                        const ThumbnailScore& score,
                        const base::Time& time);

  // Retrieves the thumbnail and score for the given url.
  // Returns false if there is not data for the given url or some other
  // error occurred.
  bool GetPageThumbnail(const GURL& url,
                        SkBitmap* thumbnail,
                        ThumbnailScore* score);

 private:
  // The location of the thumbnail store.
  FilePath file_path_;

  DISALLOW_COPY_AND_ASSIGN(ThumbnailStore);
};

#endif  // CHROME_BROWSER_THUMBNAIL_STORE_H_

Add an unused interface for storing thumbnails. This is to replace the history
system's thumbnail storage.

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


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

// Exercise 5-11
#define MAX 1000

int pop(void);
void push(int n);

int main(int argc, char *argv[])
{
  while (--argc > 0 && argv++ != NULL)
  {
    printf("%s\n", *argv);
    if(*argv[0] == '+')
    {
      push(pop() + pop());
    }
    else if(*argv[0] == '-')
    {
      int x = pop();
      push(pop() - x);
    }
    // else if(*argv[0] == '*')
    // {
    //   int x = pop();
    //   push(pop() * x);
    // }
    else if(*argv[0] == '/')
    {
      int x = pop();
      push(pop() / x);
    }
    else
    {
      push(atoi(*argv));
    }
  }

  printf("%i\n", pop());
  return 0;
}

// Push & Pop Functions
static int stack[MAX];
int *sp = stack;

int pop(void)
{
  return *--sp;
}

void push(int n)
{
  *sp++ = n;
}

Implement Exercise 5-10 for addition, subtraction, and division


#ifndef MUE__TEAMS_H
#define MUE__TEAMS_H

#include <iostream>

#include "config.h"

namespace mue {

class Team {
	private:
		Team_id _id;

		Team() {}
	public:
		Team(Team_id id)
		: _id(id)
		{}

		inline bool operator<(const Team& other)  const { return _id < other._id; }
		inline bool operator>(const Team& other)  const { return _id > other._id; }
		inline bool operator<=(const Team& other) const { return _id <= other._id; }
		inline bool operator>=(const Team& other) const { return _id >= other._id; }
		inline bool operator==(const Team& other) const { return _id == other._id; }
		inline bool operator!=(const Team& other) const { return _id != other._id; }

		inline bool operator<(const  Team_id other) const { return _id < other; }
		inline bool operator>(const  Team_id other) const { return _id > other; }
		inline bool operator<=(const Team_id other) const { return _id <= other; }
		inline bool operator>=(const Team_id other) const { return _id >= other; }
		inline bool operator==(const Team_id other) const { return _id == other; }
		inline bool operator!=(const Team_id other) const { return _id != other; }

		inline operator Team_id() const { return _id; }
		inline Team_id id() const { return _id; }

};

std::ostream& operator<<(std::ostream& os, Team const& team) { return os << int(team.id()); }

}
#endif

Add a wrapper for Team ids

Add a wrapper for Team ids

We can implement team specific functionality here if needed. At the
moment its only a wrapper for the team id.

Signed-off-by: Jan Losinski <577c4104c61edf9f052c616c0c23e67bef4a9955@wh2.tu-dresden.de>


// PARAM: --set ana.int.interval true --enable exp.partition-arrays.enabled
#include<stdlib.h>
#include<assert.h>

int main(void) {
    int *r = malloc(5 * sizeof(int));

    r[3] = 2;

    assert(r[4] == 2);
}

// PARAM: --set ana.int.interval true --enable exp.partition-arrays.enabled
#include<stdlib.h>
#include<assert.h>

int main(void) {
    int *r = malloc(5 * sizeof(int));

    r[3] = 2;

    assert(r[4] == 2);
    (* Here we only test our implementation. Concretely, accessing the uninitialised r[4] is undefined behavior.
    In our implementation we keep the whole memory allocated by malloc as one Blob and the whole Blob contains 2 after it was assigned to r[3].
    This is more useful than keeping the Blob unknown. *)
}

Add explanation to the regression test 02 44


#ifndef _AL_ERROR_H_
#define _AL_ERROR_H_

#include "alMain.h"

#ifdef __cplusplus
extern "C" {
#endif

extern ALboolean TrapALError;

ALvoid alSetError(ALCcontext *Context, ALenum errorCode);

#define SET_ERROR_AND_RETURN(ctx, err)  do {      \
    alSetError((ctx), (err));                     \
    return;                                       \
} while(0)

#define SET_AND_RETURN_ERROR(ctx, err)  do {      \
    alSetError((ctx), (err));                     \
    return (err);                                 \
} while(0)

#ifdef __cplusplus
}
#endif

#endif

#ifndef _AL_ERROR_H_
#define _AL_ERROR_H_

#include "alMain.h"

#ifdef __cplusplus
extern "C" {
#endif

extern ALboolean TrapALError;

ALvoid alSetError(ALCcontext *Context, ALenum errorCode);

#ifdef __cplusplus
}
#endif

#endif

Remove a duplicate and unused macro

Remove a duplicate and unused macro


// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR3459
struct bar {
  char n[1];
};

struct foo {
  char name[(int)&((struct bar *)0)->n];
  char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{array size is negative}}
};

// PR3430
struct s {
  struct st {
    int v;
  } *ts;
};

struct st;

int foo() {
  struct st *f;
  return f->v + f[0].v;
}

// PR3642, PR3671
struct pppoe_tag {
 short tag_type;
 char tag_data[];
};
struct datatag {
  struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}}
  char data;
};

// PR4092
struct s0 {
  char a;  // expected-note {{previous declaration is here}}
  char a;  // expected-error {{duplicate member 'a'}}
};

struct s0 f0(void) {}

// <rdar://problem/8177927> - This previously triggered an assertion failure.
struct x0 {
  unsigned int x1;
};

Add test case for <rdar://problem/8177927> (which triggered an assertion failure in SemaChecking).

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


#ifndef _TERMCAP_H
#define _TERMCAP_H	1

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

#include <sys/cdefs.h>

extern char PC;
extern char *UP;
extern char *BC;
extern short ospeed;

extern int tgetent __P((char *, const char *));
extern int tgetflag __P((const char *));
extern int tgetnum __P((const char *));
extern char *tgetstr __P((const char *, char **));

extern int tputs __P((const char *, int, int (*)(int)));

extern char *tgoto __P((const char *, int, int));
extern char *tparam __P((const char *, char *, int, ...));

#ifdef __cplusplus
}
#endif

#endif /* _TERMCAP_H */

#ifndef _TERMCAP_H
#define _TERMCAP_H	1

#include <sys/cdefs.h>

__BEGIN_DECLS

extern char PC;
extern char *UP;
extern char *BC;
extern short ospeed;

extern int tgetent __P((char *, const char *));
extern int tgetflag __P((const char *));
extern int tgetnum __P((const char *));
extern char *tgetstr __P((const char *, char **));

extern int tputs __P((const char *, int, int (*)(int)));

extern char *tgoto __P((const char *, int, int));
extern char *tparam __P((const char *, char *, int, ...));

__END_DECLS

#endif /* _TERMCAP_H */

Make this file more BSD-like

Make this file more BSD-like


//
//  INPopoverControllerDefines.h
//  Copyright 2011-2014 Indragie Karunaratne. All rights reserved.
//

typedef NS_ENUM(NSUInteger, INPopoverArrowDirection) {
	INPopoverArrowDirectionUndefined = 0,
	INPopoverArrowDirectionLeft = NSMaxXEdge,
	INPopoverArrowDirectionRight = NSMinXEdge,
	INPopoverArrowDirectionUp = NSMaxYEdge,
	INPopoverArrowDirectionDown = NSMinYEdge
};

typedef NS_ENUM(NSInteger, INPopoverAnimationType) {
	INPopoverAnimationTypePop = 0,	// Pop animation similar to NSPopover
	INPopoverAnimationTypeFadeIn,	// Fade in only, no fade out
	INPopoverAnimationTypeFadeOut,	// Fade out only, no fade in
	INPopoverAnimationTypeFadeInOut // Fade in and out
};

//
//  INPopoverControllerDefines.h
//  Copyright 2011-2014 Indragie Karunaratne. All rights reserved.
//

typedef NS_ENUM(NSUInteger, INPopoverArrowDirection) {
	INPopoverArrowDirectionUndefined = 0,
	INPopoverArrowDirectionLeft,
	INPopoverArrowDirectionRight,
	INPopoverArrowDirectionUp,
	INPopoverArrowDirectionDown
};

typedef NS_ENUM(NSInteger, INPopoverAnimationType) {
	INPopoverAnimationTypePop = 0,	// Pop animation similar to NSPopover
	INPopoverAnimationTypeFadeIn,	// Fade in only, no fade out
	INPopoverAnimationTypeFadeOut,	// Fade out only, no fade in
	INPopoverAnimationTypeFadeInOut // Fade in and out
};

Remove references to NS...Edge in enum

Remove references to NS...Edge in enum


#include "modlib.h"

uint16_t MODBUSSwapEndian( uint16_t Data )
{
    //Change big-endian to little-endian and vice versa

    unsigned char Swap;

	//Create 2 bytes long union
    union Conversion
    {
        uint16_t Data;
        unsigned char Bytes[2];
    } Conversion;

	//Swap bytes
    Conversion.Data = Data;
    Swap = Conversion.Bytes[0];
    Conversion.Bytes[0] = Conversion.Bytes[1];
    Conversion.Bytes[1] = Swap;

    return Conversion.Data;
}

uint16_t MODBUSCRC16( uint16_t *Data, uint16_t Length )
{
	//Calculate CRC16 checksum using given data and length

	uint16_t CRC = 0xFFFF;
	uint16_t i;
	unsigned char j;

	for ( i = 0; i < Length; i++ )
	{
		CRC ^= Data[i]; //XOR current data byte with CRC value

		for ( j = 8; j != 0; j-- )
		{
			//For each bit
			//Is least-significant-bit is set?
    		if ( ( CRC & 0x0001 ) != 0 )
			{
    			CRC >>= 1; //Shift to right and xor
    			CRC ^= 0xA001;
    		}
    		else                            // Else LSB is not set
    			CRC >>= 1;
		}
	}
	return CRC;
}

#include "modlib.h"

uint16_t MODBUSSwapEndian( uint16_t Data )
{
    //Change big-endian to little-endian and vice versa

    uint8_t Swap;

	//Create 2 bytes long union
    union Conversion
    {
        uint16_t Data;
        uint8_t Bytes[2];
    } Conversion;

	//Swap bytes
    Conversion.Data = Data;
    Swap = Conversion.Bytes[0];
    Conversion.Bytes[0] = Conversion.Bytes[1];
    Conversion.Bytes[1] = Swap;

    return Conversion.Data;
}

uint16_t MODBUSCRC16( uint16_t *Data, uint16_t Length )
{
	//Calculate CRC16 checksum using given data and length

	uint16_t CRC = 0xFFFF;
	uint16_t i;
	uint8_t j;

	for ( i = 0; i < Length; i++ )
	{
		CRC ^= Data[i]; //XOR current data byte with CRC value

		for ( j = 8; j != 0; j-- )
		{
			//For each bit
			//Is least-significant-bit is set?
    		if ( ( CRC & 0x0001 ) != 0 )
			{
    			CRC >>= 1; //Shift to right and xor
    			CRC ^= 0xA001;
    		}
    		else                            // Else LSB is not set
    			CRC >>= 1;
		}
	}
	return CRC;
}

Change 'unsigned character' type variables to 'uint8_t'


// Protocol Buffers - Google's data interchange format
// Copyright 2012 Google Inc.  All rights reserved.
// http://code.google.com/p/protobuf/
//
// 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 Google Inc. 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
// OWNER 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.

// This file is an internal atomic implementation, use atomicops.h instead.

#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_
#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_

namespace google {
namespace protobuf {
namespace internal {

inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
                                         Atomic32 old_value,
                                         Atomic32 new_value) {
  return __sync_val_compare_and_swap(ptr, old_value, new_value);
}

inline void MemoryBarrier() {
  __sync_synchronize();
}

inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
                                       Atomic32 old_value,
                                       Atomic32 new_value) {
  Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
  MemoryBarrier();
  return ret;
}

inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
  MemoryBarrier();
  *ptr = value;
}

inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
  Atomic32 value = *ptr;
  MemoryBarrier();
  return value;
}

}  // namespace internal
}  // namespace protobuf
}  // namespace google

#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_

Add the missing PNaCl atomicops support.

git-svn-id: 54a00c96d7caad0f188abf6e0ebede48f6547068@462 630680e5-0e50-0410-840e-4b1c322b438d


/* ****************************************************************
*
* Copyright 2019 NXP Semiconductors 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.
*
******************************************************************/

#include <tinyara/config.h>

#include <stdio.h>

extern void imxrt_log_print_kernelbuffer();

#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int nxp_demo_sample_main(int argc, char *argv[])
#endif
{
	printf("[New] nxp_demo_sample!!\n");

	imxrt_log_print_kernelbuffer();

	return 0;
}

/* ****************************************************************
*
* Copyright 2019 NXP Semiconductors 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.
*
******************************************************************/

#include <tinyara/config.h>

#include <stdio.h>

extern void imxrt_log_print_kernelbuffer();

#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int nxp_demo_sample_main(int argc, char *argv[])
#endif
{
	printf("[New] nxp_demo_sample!!\n");

#ifndef CONFIG_BUILD_PROTECTED
	imxrt_log_print_kernelbuffer();
#endif
	return 0;
}

Fix NXP example app for Protected build

apps/examples/nxp_example: Fix NXP example app for Protected build

Remove direct call to kernel API from NXP example app in case of
protected build.

Signed-off-by: Kishore S N <33058dcca7ce956a91a61ef5ae8fb790ece75b5f@samsung.com>


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

#include "http/http.h"

int main(int argc, char *argv[])
{
	http_sock *sock = open_http();
	if (sock == NULL)
		goto cleanup;

	// TODO: print port then fork
	uint32_t port = get_port_number(sock);
	printf("%u\n", port);

	while (1) {
		http_conn *conn = accept_conn(sock);
		if (conn == NULL) {
			ERR("Opening connection failed");
			goto conn_error;
		}

		message *msg = get_message(conn);
		if (msg == NULL) {
			ERR("Generating message failed");
			goto conn_error;
		}

		packet *pkt = get_packet(msg);
		if (pkt == NULL) {
			ERR("Receiving packet failed");
			goto conn_error;
		}

		printf("%.*s", (int)pkt->size, pkt->buffer);

	conn_error:
		if (conn != NULL)
			free(conn);
		if (msg != NULL)
			free(msg);
	}

cleanup:
	if (sock != NULL)
		close_http(sock);

	return 1;
}

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

#include "http/http.h"

int main(int argc, char *argv[])
{
	http_sock *sock = open_http();
	if (sock == NULL)
		goto cleanup;

	// TODO: print port then fork
	uint32_t port = get_port_number(sock);
	printf("%u\n", port);

	while (1) {
		http_conn *conn = accept_conn(sock);
		if (conn == NULL) {
			ERR("Opening connection failed");
			goto conn_error;
		}

		message *msg = get_message(conn);
		if (msg == NULL) {
			ERR("Generating message failed");
			goto conn_error;
		}

		packet *pkt = get_packet(msg);
		if (pkt == NULL) {
			ERR("Receiving packet failed");
			goto conn_error;
		}

		printf("%.*s", (int)pkt->size, pkt->buffer);

	conn_error:
		if (conn != NULL)
			free(conn);
		if (msg != NULL)
			free(msg);
	}

cleanup:
	if (sock != NULL)
		close_http(sock);

	return 0;
}

Fix main exiting with error code on error-less run

Comandline programs expect 0 as errror-less return
value. This is in contrast to C where we treat 0
or NULL as an error token.


/* Name: main.c
 * Author: <insert your name here>
 * Copyright: <insert your copyright message here>
 * License: <insert your license reference here>
 */

// A simple blinky program for ATtiny85
// Connect red LED at pin 2 (PB3)
//

#include <avr/io.h>
#include <util/delay.h>

int main (void)
{
    // set PB3 to be output
    DDRB = 0b00001000;
    while (1) {

        // flash# 1:
        // set PB3 high
        PORTB = 0b00001000;
        _delay_ms(200);
        // set PB3 low
        PORTB = 0b00000000;
        _delay_ms(200);

        // flash# 2:
        // set PB3 high
        PORTB = 0b00001000;
        _delay_ms(1000);
        // set PB3 low
        PORTB = 0b00000000;
        _delay_ms(1000);

        // flash# 3:
        // set PB3 high
        PORTB = 0b00001000;
        _delay_ms(3000);
        // set PB3 low
        PORTB = 0b00000000;
        _delay_ms(3000);
    }

    return 1;
}

/* Name: main.c
 * Author: <insert your name here>
 * Copyright: <insert your copyright message here>
 * License: <insert your license reference here>
 */

// A simple blinky program for ATtiny85
// Connect red LED at pin 3 (PB4)
//

#include <avr/io.h>
#include <util/delay.h>

int main (void)
{
    // set PB4 to be output
    DDRB = 0b00001000;
    while (1) {

        // flash# 1:
        // set PB4 high
        PORTB = 0b00010000;
        _delay_ms(200);
        // set PB4 low
        PORTB = 0b00000000;
        _delay_ms(200);

        // flash# 2:
        // set PB4 high
        PORTB = 0b00010000;
        _delay_ms(1000);
        // set PB4 low
        PORTB = 0b00000000;
        _delay_ms(1000);

        // flash# 3:
        // set PB4 high
        PORTB = 0b00010000;
        _delay_ms(3000);
        // set PB4 low
        PORTB = 0b00000000;
        _delay_ms(3000);
    }

    return 1;
}

Change blink program to use pb4 since that's the pin the test LED is wired to on my programming board