/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#ifndef GUAC_SSH_TTYMODE_H
#define GUAC_SSH_TTYMODE_H

#include "config.h"

#define GUAC_SSH_TTY_OP_END 0
#define GUAC_SSH_TTY_OP_VERASE 3

#define GUAC_SSH_TERM_DEFAULT_BACKSPACE 127

extern const char GUAC_SSH_TTY_MODES[6];

#endif

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#ifndef GUAC_SSH_TTYMODE_H
#define GUAC_SSH_TTYMODE_H

#include "config.h"

/**
 * The SSH TTY mode encoding opcode that terminates
 * the list of TTY modes.
 */
#define GUAC_SSH_TTY_OP_END 0

/**
 * The SSH tty mode encoding opcode that configures
 * the TTY erase code to configure the server
 * backspace key.
 */
#define GUAC_SSH_TTY_OP_VERASE 3

/**
 * The default ASCII code to send for the backspace
 * key that will be sent to the SSH server.
 */
#define GUAC_SSH_TERM_DEFAULT_BACKSPACE 127

/**
 * The array of TTY mode encoding data to send to the
 * SSH server.  These consist of pairs of byte codes
 * and uint32 (4-byte) values, with a 0 to terminate
 * the list.
 */
extern const char GUAC_SSH_TTY_MODES[6];

#endif

GUACAMOLE-269: Add documentation for the defines and variables.


$OpenBSD: patch-Modules__ssl_c,v 1.2 2018/03/17 22:30:04 sthen Exp $

XXX maybe the second hunk can go away now we have auto-init, I'm not sure
exactly what python's lock protects

Index: Modules/_ssl.c
--- Modules/_ssl.c.orig
+++ Modules/_ssl.c
@@ -99,7 +99,8 @@ struct py_ssl_library_code {
 /* Include generated data (error codes) */
 #include "_ssl_data.h"

-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && !defined(LIBRESSL_VERSION_NUMBER)
+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) && \
+    (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER >= 0x2070000fL)
 #  define OPENSSL_VERSION_1_1 1
 #endif

@@ -133,6 +134,9 @@ struct py_ssl_library_code {
 /* OpenSSL 1.1.0+ */
 #ifndef OPENSSL_NO_SSL2
 #define OPENSSL_NO_SSL2
+#endif
+#if defined(LIBRESSL_VERSION_NUMBER) && defined(WITH_THREAD)
+#define HAVE_OPENSSL_CRYPTO_LOCK
 #endif
 #else /* OpenSSL < 1.1.0 */
 #if defined(WITH_THREAD)

Fix libressl patch python 3.6

Fix libressl patch python 3.6


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

int
main (int argc, char *argv[])
{
  int rank, size, length;
  char name[BUFSIZ];

  MPI_Init (&argc, &argv);
  MPI_Comm_rank (MPI_COMM_WORLD, &rank);
  MPI_Comm_size (MPI_COMM_WORLD, &size);
  MPI_Get_processor_name (name, &length);

  printf ("%s: hello world from process %d of %d\n", name, rank, size);

  MPI_Finalize ();

  return EXIT_SUCCESS;
}

Add missing file for the MPI test.

Add missing file for the MPI test.

git-svn-id: 71c8032c709790ec749031c4215f8515ac00dc5a@27337 70bd8c7a-acb8-0310-9f0d-9cc1c95dcdbb


#define PY_SSIZE_T_CLEAN
#include <Python.h>

static PyObject* websocket_mask(PyObject* self, PyObject* args) {
    const char* mask;
    Py_ssize_t mask_len;
    const char* data;
    Py_ssize_t data_len;
    Py_ssize_t i;
    PyObject* result;
    char* buf;

    if (!PyArg_ParseTuple(args, "s#s#", &mask, &mask_len, &data, &data_len)) {
        return NULL;
    }

    result = PyBytes_FromStringAndSize(NULL, data_len);
    if (!result) {
        return NULL;
    }
    buf = PyBytes_AsString(result);
    for (i = 0; i < data_len; i++) {
        buf[i] = data[i] ^ mask[i % 4];
    }

    return result;
}

static PyMethodDef methods[] = {
    {"websocket_mask",  websocket_mask, METH_VARARGS, ""},
    {NULL, NULL, 0, NULL}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef speedupsmodule = {
   PyModuleDef_HEAD_INIT,
   "speedups",
   NULL,
   -1,
   methods
};

PyMODINIT_FUNC
PyInit_speedups() {
    return PyModule_Create(&speedupsmodule);
}
#else  // Python 2.x
PyMODINIT_FUNC
initspeedups() {
    Py_InitModule("tornado.speedups", methods);
}
#endif

#define PY_SSIZE_T_CLEAN
#include <Python.h>

static PyObject* websocket_mask(PyObject* self, PyObject* args) {
    const char* mask;
    Py_ssize_t mask_len;
    const char* data;
    Py_ssize_t data_len;
    Py_ssize_t i;
    PyObject* result;
    char* buf;

    if (!PyArg_ParseTuple(args, "s#s#", &mask, &mask_len, &data, &data_len)) {
        return NULL;
    }

    result = PyBytes_FromStringAndSize(NULL, data_len);
    if (!result) {
        return NULL;
    }
    buf = PyBytes_AsString(result);
    for (i = 0; i < data_len; i++) {
        buf[i] = data[i] ^ mask[i % 4];
    }

    return result;
}

static PyMethodDef methods[] = {
    {"websocket_mask",  websocket_mask, METH_VARARGS, ""},
    {NULL, NULL, 0, NULL}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef speedupsmodule = {
   PyModuleDef_HEAD_INIT,
   "speedups",
   NULL,
   -1,
   methods
};

PyMODINIT_FUNC
PyInit_speedups(void) {
    return PyModule_Create(&speedupsmodule);
}
#else  // Python 2.x
PyMODINIT_FUNC
initspeedups(void) {
    Py_InitModule("tornado.speedups", methods);
}
#endif

Add void to empty function parameter

Add void to empty function parameter

This fixes the gcc warning:

tornado/speedups.c:49:1: warning: function declaration isn’t a prototype
[-Wstrict-prototypes]
 initspeedups() {
 ^


//
//  FlatUIKit.h
//  FlatUI
//
//  Created by Keisuke Kimura on 6/8/13.
//  Copyright (c) 2013 Keisuke Kimura. All rights reserved.
//

#ifndef FlatUI_FlatUIKit_h
#define FlatUI_FlatUIKit_h

#ifndef __IPHONE_5_0
#error "FlatUIKit uses features only available in iOS SDK 5.0 and later."
#endif

#if TARGET_OS_IPHONE
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif

#endif

#import "FUIAlertView.h"
#import "FUIButton.h"
#import "FUICellBackgroundView.h"
#import "FUISegmentedControl.h"
#import "FUISwitch.h"
#import "UIBarButtonItem+FlatUI.h"
#import "UIColor+FlatUI.h"
#import "UIFont+FlatUI.h"
#import "UIImage+FlatUI.h"
#import "UINavigationBar+FlatUI.h"
#import "UIProgressView+FlatUI.h"
#import "UISlider+FlatUI.h"
#import "UITabBar+FlatUI.h"
#import "UITableViewCell+FlatUI.h"

#ifdef __IPHONE_6_0
#import "UIStepper+FlatUI.h"
#endif

//
//  FlatUIKit.h
//  FlatUI
//
//  Created by Keisuke Kimura on 6/8/13.
//  Copyright (c) 2013 Keisuke Kimura. All rights reserved.
//

#ifndef FlatUI_FlatUIKit_h
#define FlatUI_FlatUIKit_h

#ifndef __IPHONE_5_0
#error "FlatUIKit uses features only available in iOS SDK 5.0 and later."
#endif

#if TARGET_OS_IPHONE
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif

#endif

#import "FUIAlertView.h"
#import "FUIButton.h"
#import "FUICellBackgroundView.h"
#import "FUISegmentedControl.h"
#import "FUISwitch.h"
#import "UIBarButtonItem+FlatUI.h"
#import "UIColor+FlatUI.h"
#import "UIFont+FlatUI.h"
#import "UIImage+FlatUI.h"
#import "UINavigationBar+FlatUI.h"
#import "UIProgressView+FlatUI.h"
#import "UIStepper+FlatUI.h"
#import "UISlider+FlatUI.h"
#import "UITabBar+FlatUI.h"
#import "UITableViewCell+FlatUI.h"

Remove OSVersion check of import "UIStepper+FlatUI.h"


int sum_of_even_squares(int* a, unsigned int length) {
    int total = 0;
    for (unsigned int i = 0; i < length; i++) {
        if (a[i] % 2 == 0) {
            total += a[i] * a[i];
        }
    }
    return total;
}

#include <assert.h>

static int a[] = {7, 3, -8, 4, 1, 0, 11, 2};

int main() {
    assert(sum_of_even_squares(a, 0) == 0);
    assert(sum_of_even_squares(a, 1) == 0);
    assert(sum_of_even_squares(a, 2) == 0);
    assert(sum_of_even_squares(a, 3) == 64);
    assert(sum_of_even_squares(a, 4) == 80);
    assert(sum_of_even_squares(a, 5) == 80);
    assert(sum_of_even_squares(a, 6) == 80);
    assert(sum_of_even_squares(a, 7) == 80);
    assert(sum_of_even_squares(a, 8) == 84);
    return 0;
}

Add asserts to C sum of even squares

Add asserts to C sum of even squares


#ifndef __TYPES_H__
#define __TYPES_H__

#include <rtthread.h>

typedef long    	off_t;
typedef rt_size_t 	size_t;
typedef signed long ssize_t;		/* Used for a count of bytes or an error indication. */

typedef rt_uint8_t 	u_char;
typedef rt_uint16_t u_short;
typedef rt_ubase_t 	u_int;
typedef rt_uint32_t u_long;

typedef rt_time_t time_t;
typedef int mode_t;

typedef unsigned long clockid_t;
typedef int pid_t;

#ifndef NULL
#define NULL RT_NULL
#endif

#define __u_char_defined

#endif

#ifndef __TYPES_H__
#define __TYPES_H__

#include <rtthread.h>

typedef long    	off_t;
typedef __SIZE_TYPE__ 	size_t;
typedef signed long ssize_t;		/* Used for a count of bytes or an error indication. */

typedef rt_uint8_t 	u_char;
typedef rt_uint16_t u_short;
typedef rt_ubase_t 	u_int;
typedef rt_uint32_t u_long;

typedef rt_time_t time_t;
typedef int mode_t;

typedef unsigned long clockid_t;
typedef int pid_t;

#ifndef NULL
#define NULL RT_NULL
#endif

#define __u_char_defined

#endif

[libc] Use __SIZE_TYPE__ instead of rt_size_t in minilibc.


/*
 * CIS 314 Fall 2015 Lab 1
 * Assigned project
 *
 * This program reads a sorted array from a file and finds a requested number
 *    using recursive or iterative binary search. The array is read from a file
 *    defined by FILE_NAME, which should be written as the number of elements
 *    followed by the elements themselses. each number can be deliniated with
 *    any whitepace character. Also, the maximum size of the array is defined
 *    as MAX_SIZE.
 *
 * NOTE: The array must be sorted!!
 *
 */

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

#define MAX_SIZE 150
#define FILE_NAME "array.dat" //must include quotes

// Implement the rest of the program

int main(void) {

   FILE *in_file;
   int array[MAX_SIZE];
   int size;
   char in_file_name[] = FILE_NAME;

   printf("\n\n=== CIS314 Fall 2014 - Lab 1: Part 2: Program 2 ===\n\n");

   printf("\n\n");

   return 0;
}

int recursiveBinarySearch(int list_of_numbers[], int desired_number, int low_number, int high_number) {

}

int iterativeBinarySearch(int list_of_numbers[], int desired_number) {

}

/*
 * CIS 314 Fall 2015 Lab 1
 * Assigned project
 *
 * This program reads a sorted array from a file and finds a requested number
 *    using recursive or iterative binary search. The array is read from a file
 *    defined by FILE_NAME, which should be written as the number of elements
 *    followed by the elements themselses. each number can be deliniated with
 *    any whitepace character. Also, the maximum size of the array is defined
 *    as MAX_SIZE.
 *
 * NOTE: The array must be sorted!!
 *
 */

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

#define MAX_SIZE 150
#define FILE_NAME "array.dat" //must include quotes

// Implement the rest of the program

int main(void) {

   FILE *in_file;
   int array[MAX_SIZE];
   int size;
   char in_file_name[] = FILE_NAME;

   printf("\n\n=== CIS314 Fall 2014 - Lab 1: Part 2: Program 2 ===\n\n");

   printf("\n\n");

   return 0;
}

int recursiveBinarySearch(int list_of_numbers[], int desired_number, int low_number, int high_number) {

}

int iterativeBinarySearch(int list_of_numbers[], int desired_number) {
	int low = 0;
	int high = (sizeof(list_of_numbers)/sizeof(list_of_numbers[0])) - 1
}

Add high and low in iterative

Add high and low in iterative


/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*     Copyright 2014 Couchbase, Inc.
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*/
#pragma once

#include <stdarg.h>

#include <platform/visibility.h>

PLATFORM_PUBLIC_API
int asprintf(char **ret, const char *format, ...);

PLATFORM_PUBLIC_API
int vasprintf(char **ret, const char *format, va_list ap);

/*
* We have a fair amount of use of this file in our code base.
* Let's just make a dummy file to aviod a lot of #ifdefs
*/
#ifndef strcasecmp
#define strcasecmp(a, b) _stricmp(a, b)
#endif

#ifndef snprintf
#define snprintf _snprintf
#endif

/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
*     Copyright 2014 Couchbase, Inc.
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*/
#pragma once

#include <stdarg.h>

#include <platform/visibility.h>

#ifdef __cplusplus
extern "C" {
#endif

PLATFORM_PUBLIC_API
int asprintf(char **ret, const char *format, ...);

PLATFORM_PUBLIC_API
int vasprintf(char **ret, const char *format, va_list ap);

#ifdef __cplusplus
}
#endif

/*
* We have a fair amount of use of this file in our code base.
* Let's just make a dummy file to aviod a lot of #ifdefs
*/
#ifndef strcasecmp
#define strcasecmp(a, b) _stricmp(a, b)
#endif

#ifndef snprintf
#define snprintf _snprintf
#endif

Set C linkage for win32 [v]asprintf

Set C linkage for win32 [v]asprintf

Change-Id: I7f82255467c05936baa702fa1d532156b0caba12
Reviewed-on: http://review.couchbase.org/52114
Reviewed-by: Dave Rigby <a09264da4832c7ff1d3bf1608a19f4b870f93750@couchbase.com>
Tested-by: buildbot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>


#pragma once

#pragma comment(lib, "gdiplus.lib")

#include <Windows.h>
#include <gdiplus.h>
#include <vector>

#include "../MeterWnd/Meter.h"

class OSDSkin {
public:
    OSDSkin(Gdiplus::Bitmap *background, Gdiplus::Bitmap *mask,
        std::vector<Meter *> meters, std::vector<HICON> iconset) :
    background(background),
    mask(mask),
    meters(meters),
    iconset(iconset) {

    }

    const Gdiplus::Bitmap *background;
    const Gdiplus::Bitmap *mask;
    const std::vector<Meter *> meters;
    const std::vector<HICON> iconset;
};

Add new class to track OSD assets

Add new class to track OSD assets


#ifndef POISSON_DISK_SAMPLING_H
#define POISSON_DISK_SAMPLING_H

#include <vector>

class PoissonDiskSampling
{
public:
	PoissonDiskSampling() = default;

	~PoissonDiskSampling() = default;

	PoissonDiskSampling(const PoissonDiskSampling& rhs) = default;
	PoissonDiskSampling(const PoissonDiskSampling&& rhs) = default;

	PoissonDiskSampling& operator=(const PoissonDiskSampling& rhs) = default;
	PoissonDiskSampling& operator=(const PoissonDiskSampling&& rhs) = default;

public:
	PoissonDiskSampling(int pointWidth, int pointHeight, double pointMinDist, double pointCount);

	std::vector<std::pair<double, double>> Generate();
};

#endif

#ifndef POISSON_DISK_SAMPLING_H
#define POISSON_DISK_SAMPLING_H

#include <vector>

class PoissonDiskSampling
{
public:
	PoissonDiskSampling() = default;
	PoissonDiskSampling(int pointWidth, int pointHeight, double pointMinDist, double pointCount);

	~PoissonDiskSampling() = default;

	PoissonDiskSampling(const PoissonDiskSampling& pds) = delete;
	PoissonDiskSampling(PoissonDiskSampling&& pds) = delete;

	PoissonDiskSampling& operator=(const PoissonDiskSampling& rhs) = delete;
	PoissonDiskSampling& operator=(PoissonDiskSampling&& rhs) = delete;

	std::vector<std::pair<double, double>> Generate();

	struct Point
	{
		Point() : x(0.0), y(0.0) { }
		Point(double _x, double _y) : x(_x), y(_y) { }

		~Point() = default;

		Point(const Point& p) : x(p.x), y(p.y) { }
		Point(Point&& p) : x(p.x), y(p.y) { }

		Point& operator=(const Point& rhs)
		{
			if (this == &rhs)
			{
				return;
			}

			x = rhs.x;
			y = rhs.y;

			return *this;
		}
		Point& operator=(Point&& rhs)
		{
			if (this == &rhs)
			{
				return;
			}

			x = rhs.x;
			y = rhs.y;

			return *this;
		}

		double x, y;
	};
};

#endif

Fix grammer error and implement Point structure


/*
	OpenLieroX

	reader for IpToCountry database

	code under LGPL
	by Albert Zeyer and Dark Charlie
*/

#ifndef __IPTOCOUNTRY_H__
#define	__IPTOCOUNTRY_H__

#include <string>
#include "SmartPointer.h"
#include "InternDataClass.h"
#include "GeoIPDatabase.h"

struct SDL_Surface;

typedef GeoRecord IpInfo;

INTERNDATA_CLASS_BEGIN(IpToCountryDB)
private:
	GeoIPDatabase *m_database;
public:
	IpToCountryDB(const std::string& dbfile);
	void LoadDBFile(const std::string& dbfile);
	IpInfo GetInfoAboutIP(const std::string& Address);
	SmartPointer<SDL_Surface> GetCountryFlag(const std::string& shortcut);
	int	GetProgress() { return 100; }
	bool Loaded()  { return true; }
INTERNDATA_CLASS_END

extern char *IP_TO_COUNTRY_FILE;
extern  IpToCountryDB	*tIpToCountryDB;

#endif

/*
	OpenLieroX

	reader for IpToCountry database

	code under LGPL
	by Albert Zeyer and Dark Charlie
*/

#ifndef __IPTOCOUNTRY_H__
#define	__IPTOCOUNTRY_H__

#include <string>
#include "SmartPointer.h"
#include "InternDataClass.h"
#include "GeoIPDatabase.h"

struct SDL_Surface;

typedef GeoRecord IpInfo;

INTERNDATA_CLASS_BEGIN(IpToCountryDB)
private:
	GeoIPDatabase *m_database;
public:
	IpToCountryDB(const std::string& dbfile);
	void LoadDBFile(const std::string& dbfile);
	IpInfo GetInfoAboutIP(const std::string& Address);
	SmartPointer<SDL_Surface> GetCountryFlag(const std::string& shortcut);
	int	GetProgress() { return 100; }
	bool Loaded()  { return m_database != NULL && m_database->loaded(); }
INTERNDATA_CLASS_END

extern char *IP_TO_COUNTRY_FILE;
extern  IpToCountryDB	*tIpToCountryDB;

#endif

Fix for checking if the database is loaded


#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <unistd.h>
#include "log.h"
#include "globals.h"

void my_log(int priority, const char *format, ...)
{
	va_list ap;
	va_start(ap, format);

#ifndef MINIMALISTIC_BUILD
	if (globals.no_syslog) {
#endif
		time_t now;
		struct tm* timeinfo;
		char timestring[32];

		time(&now);
		timeinfo = localtime(&now);
		strftime(timestring, sizeof(timestring), "%Y-%m-%d %H:%M:%S", timeinfo);
		fprintf(
			stderr,
			"%s %s[%d]: ",
			timestring,
#ifndef MINIMALISTIC_BUILD
			globals.daemon_name,
#else
			"ssh-honeypotd",
#endif
			getpid()
		);

		#pragma GCC diagnostic push
		#pragma GCC diagnostic ignored "-Wformat-nonliteral"
		vfprintf(stderr, format, ap);
		#pragma GCC diagnostic pop
		fprintf(stderr, "\n");
#ifndef MINIMALISTIC_BUILD
	}
	else {
		#pragma GCC diagnostic push
		#pragma GCC diagnostic ignored "-Wformat-nonliteral"
		vsyslog(priority, format, ap);
		#pragma GCC diagnostic pop
	}
#endif

	va_end(ap);
}

#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <unistd.h>
#include "log.h"
#include "globals.h"

void my_log(int priority, const char *format, ...)
{
	va_list ap;
	va_start(ap, format);

#ifndef MINIMALISTIC_BUILD
	if (globals.no_syslog) {
#endif
		time_t now;
		struct tm timeinfo;
		char timestring[32];

		time(&now);
		localtime_r(&now, &timeinfo);
		strftime(timestring, sizeof(timestring), "%Y-%m-%d %H:%M:%S", &timeinfo);
		fprintf(
			stderr,
			"%s %s[%d]: ",
			timestring,
#ifndef MINIMALISTIC_BUILD
			globals.daemon_name,
#else
			"ssh-honeypotd",
#endif
			getpid()
		);

		#pragma GCC diagnostic push
		#pragma GCC diagnostic ignored "-Wformat-nonliteral"
		vfprintf(stderr, format, ap);
		#pragma GCC diagnostic pop
		fprintf(stderr, "\n");
#ifndef MINIMALISTIC_BUILD
	}
	else {
		#pragma GCC diagnostic push
		#pragma GCC diagnostic ignored "-Wformat-nonliteral"
		vsyslog(priority, format, ap);
		#pragma GCC diagnostic pop
	}
#endif

	va_end(ap);
}

Address issues found by LGTM

Address issues found by LGTM


#import <Foundation/Foundation.h>

//! Project version number for Quick.
FOUNDATION_EXPORT double QuickVersionNumber;

//! Project version string for Quick.
FOUNDATION_EXPORT const unsigned char QuickVersionString[];

#import <Quick/QuickSpec.h>

#import <Foundation/Foundation.h>

//! Project version number for Quick.
FOUNDATION_EXPORT double QuickVersionNumber;

//! Project version string for Quick.
FOUNDATION_EXPORT const unsigned char QuickVersionString[];

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

#import <Quick/QuickSpec.h>
#import <Quick/QCKDSL.h>
#import <Quick/QuickConfiguration.h>

Revert "Remove public headers from umbrella header"

This reverts commit 3c5ab51a235a400427b364a608e679d91390f96a.


//
//  BlockExamples.h
//  ObjcNullability
//
//  Created by Bryan Luby on 5/21/15.
//  Copyright (c) 2015 Bryan Luby. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void(^TestBlock)(NSString * __nonnull stuff);
typedef void(^TestBlock2)(NSString * __nullable otherStuff);

NS_ASSUME_NONNULL_BEGIN
typedef void(^TestBlock3)(NSString *aString);
NS_ASSUME_NONNULL_END

@interface BlockExamples : NSObject

- (void)methodThatTakesABlock:(nullable TestBlock)block;
- (void)anotherMethodThatTakesABlock:(nonnull TestBlock2)block;

@end

//
//  BlockExamples.h
//  ObjcNullability
//
//  Created by Bryan Luby on 5/21/15.
//  Copyright (c) 2015 Bryan Luby. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void(^TestBlock)(NSString * __nonnull stuff);
typedef void(^TestBlock2)(NSString * __nullable otherStuff);

NS_ASSUME_NONNULL_BEGIN
typedef void(^TestBlock3)(NSString *aString);
NS_ASSUME_NONNULL_END

typedef NSString *__nonnull(^TestBlock4)(NSString *__nonnull aString);

@interface BlockExamples : NSObject

- (void)methodThatTakesABlock:(nullable TestBlock)block;
- (void)anotherMethodThatTakesABlock:(nonnull TestBlock2)block;

@end

Add typedef block with return value

Add typedef block with return value


#include "HsFFI.h"

void writeIntOffPtr(HsPtr arg1, HsInt arg2, HsInt arg3)
{
  ((typeof(arg3)*)arg1)[arg2] = arg3;
}

HsInt readIntOffPtr(HsPtr arg1, HsInt arg2)
{
  return ((typeof(readIntOffPtr(arg1,arg2))*)arg1)[arg2];
}

void writeCharOffPtr(HsPtr arg1, HsInt arg2, HsChar arg3)
{
  ((typeof(arg3)*)arg1)[arg2] = arg3;
}

HsChar readCharOffPtr(HsPtr arg1, HsInt arg2)
{
  return ((typeof(readCharOffPtr(arg1,arg2))*)arg1)[arg2];
}

Support code for Storable.hs - defines teh read/writeFooOffPtr functions.

In writing this code, some attempt was made to make it easier to cut
and paste definitions so that it would be easier to generate the
missing definitions.  It'd probably be easier to use the more obvious
technique of using cpp to do the job.


#ifndef __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C
#define __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C

#include <pt/pt.h>

class RCoRoutineRunner
{
public:
  RCoRoutineRunner();
  virtual
  ~RCoRoutineRunner();

  virtual char
  run();

public:
  struct pt mPt;
};

#endif // __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C

#ifndef __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C
#define __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C

#include <pt/pt.h>

class RCoRoutineRunner
{
public:
  RCoRoutineRunner();
  virtual
  ~RCoRoutineRunner();

  virtual char
  run() = 0;

public:
  struct pt mPt;
};

#endif // __INCLUDED_ECE554E80AF211E7AA6EA088B4D1658C

Mark run() as pure virtual function

Mark run() as pure virtual function


#include "prefix.h"
#include "preamble.h"
int wibble(int);

// RUN: %clang -x c-header -o %t.pch %S/Inputs/prefix.h
// RUN: CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -I %S/Inputs -include %t %s | FileCheck %s
// CHECK: preamble.c:3:5: FunctionDecl=wibble:3:5 Extent=[3:5 - 3:16]
// CHECK: preamble.c:3:15: ParmDecl=:3:15 (Definition) Extent=[3:12 - 3:16]

#include "prefix.h"
#include "preamble.h"
int wibble(int);

// RUN: %clang -x c-header -o %t.pch %S/Inputs/prefix.h
// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -I %S/Inputs -include %t %s | FileCheck %s
// CHECK: preamble.c:3:5: FunctionDecl=wibble:3:5 Extent=[3:5 - 3:16]
// CHECK: preamble.c:3:15: ParmDecl=:3:15 (Definition) Extent=[3:12 - 3:16]

Use env instead of assuming bash.

tests: Use env instead of assuming bash.

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


/* Copyright (c) 2016 PaddlePaddle Authors. 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. */

#pragma once

#ifdef __GNUC__
#define GCC_VERSION \
  (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION
#endif

#if GCC_VERSION >= 30400
#define __must_check __attribute__((warn_unused_result))
#else
#define __must_check
#endif

/* Copyright (c) 2016 PaddlePaddle Authors. 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. */

#pragma once
/**
 * This header defines some useful attribute by each compiler. It is the
 * abstract layer of compilers.
 */
#ifdef __GNUC__
#define GCC_VERSION \
  (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION
#endif

/**
 * __must_check macro. It make the function's return value must be used,
 * otherwise it will raise a compile warning. And also Paddle treat all compile
 * warnings as errors.
 */
#if GCC_VERSION >= 30400
#define __must_check __attribute__((warn_unused_result))
#else
#define __must_check
#endif

Add some comments to compiler.h

Add some comments to compiler.h


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

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

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

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

	// Initialize options to default values.
	int mode = 'e';
	int time_unit = 0;

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

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

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

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

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

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

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

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

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

Remove option argument for transmit mode


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

#include "choices.h"
#include "config.h"
#include "io.h"
#include "ui.h"

void usage();
void version();

int
main(int argc,char **argv)
{
	int ch;
	struct choices *cs;

	while ((ch = getopt(argc, argv, "hv")) != -1)
		switch (ch) {
		case 'v':
			version();
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	cs = get_choices();
	put_choice(get_selected(cs));
	choices_free(cs);
	return EX_OK;
}

void
usage()
{
	fprintf(stderr, "usage: pick [-h]\n");
	fprintf(stderr, "    -h      display this help message and exit\n");
	fprintf(stderr, "    -v      display the version and exit\n");
	exit(EX_USAGE);
}

void
version()
{
	printf("%s\n", PACKAGE_VERSION);
	exit(EX_OK);
}

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

#include "choices.h"
#include "config.h"
#include "io.h"
#include "ui.h"

void usage();
void version();

int
main(int argc,char **argv)
{
	int ch;
	struct choices *cs;

	while ((ch = getopt(argc, argv, "hv")) != -1)
		switch (ch) {
		case 'v':
			version();
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	cs = get_choices();
	put_choice(get_selected(cs));
	choices_free(cs);
	return EX_OK;
}

void
usage()
{
	fprintf(stderr, "usage: pick [-h] [-v]\n");
	fprintf(stderr, "    -h      display this help message and exit\n");
	fprintf(stderr, "    -v      display the version and exit\n");
	exit(EX_USAGE);
}

void
version()
{
	printf("%s\n", PACKAGE_VERSION);
	exit(EX_OK);
}

Correct usage message option list.

Correct usage message option list.


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

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

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "timer.h"
#include "ports.h"

int main(int argc, char *argv[]) {
    int prt, time;
    mach_port_t port;
    tcp_timer_t timer;
    char buffer[4096];
    typeinfo_t tpinfo;
    timer_message_t* msg = (timer_message_t*)buffer;

    mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port);
    timer = start_timer_thread(port);

    while(1) {
        scanf("%d", &prt);
        scanf("%d", &time);
        if(time == 0) break;
        add_timer(timer, time, prt, (uintptr_t)(argv[prt % argc]));
    }

    while(1) {
        if(!receive_data(&port, &tpinfo, buffer, 1024)) continue;
        printf("Received : %d -> \"%s\"\n", msg->port, (char*)msg->data);
        if(msg->port == 42) break;
    }

    return 0;
}

Create code to test timer

Create code to test timer


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

#pragma once

#include "Stdafx.h"
#include "include/cef_scheme.h"
#include "Internals/AutoLock.h"

using namespace System;
using namespace System::IO;
using namespace System::Collections::Specialized;

namespace CefSharp
{
    private class SchemeHandlerFactoryWrapper : public CefSchemeHandlerFactory
    {
        gcroot<ISchemeHandlerFactory^> _factory;

    public:
        SchemeHandlerFactoryWrapper(ISchemeHandlerFactory^ factory)
            : _factory(factory) {}

        ~SchemeHandlerFactoryWrapper()
        {
            _factory = nullptr;
        }

        virtual CefRefPtr<CefResourceHandler> SchemeHandlerFactoryWrapper::Create(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& scheme_name, CefRefPtr<CefRequest> request) OVERRIDE
        {
            auto handler = _factory->Create();
            CefRefPtr<ResourceHandlerWrapper> wrapper = new ResourceHandlerWrapper(handler);
            return static_cast<CefRefPtr<CefResourceHandler>>(wrapper);
        }

        IMPLEMENT_REFCOUNTING(SchemeHandlerFactoryWrapper);
    };
}

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

#pragma once

#include "Stdafx.h"
#include "include/cef_scheme.h"
#include "Internals/AutoLock.h"

using namespace System;
using namespace System::IO;
using namespace System::Collections::Specialized;

namespace CefSharp
{
    private class SchemeHandlerFactoryWrapper : public CefSchemeHandlerFactory
    {
        gcroot<ISchemeHandlerFactory^> _factory;

    public:
        SchemeHandlerFactoryWrapper(ISchemeHandlerFactory^ factory)
            : _factory(factory) {}

        ~SchemeHandlerFactoryWrapper()
        {
            _factory = nullptr;
        }

        virtual CefRefPtr<CefResourceHandler> Create(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& scheme_name, CefRefPtr<CefRequest> request) OVERRIDE
        {
            auto handler = _factory->Create();
            CefRefPtr<ResourceHandlerWrapper> wrapper = new ResourceHandlerWrapper(handler);
            return static_cast<CefRefPtr<CefResourceHandler>>(wrapper);
        }

        IMPLEMENT_REFCOUNTING(SchemeHandlerFactoryWrapper);
    };
}

Remove redundant method prefix (cpp)

Remove redundant method prefix (cpp)


/* +---------------------------------------------------------------------------+
   |                     Mobile Robot Programming Toolkit (MRPT)               |
   |                          http://www.mrpt.org/                             |
   |                                                                           |
   | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file        |
   | See: http://www.mrpt.org/Authors - All rights reserved.                   |
   | Released under BSD License. See details in http://www.mrpt.org/License    |
   +---------------------------------------------------------------------------+ */

#pragma once

/** \file Macros to help implementing the PIMPL idiom and make all
 * declarations easier to read and less error-prone.
 */

#define PIMPL_DECLARE_TYPE(_TYPE, _VAR_NAME)  void *_VAR_NAME

#define PIMPL_CTOR_INIT(_TYPE, _VAR_NAME)  _VAR_NAME(NULL)

#define PIMPL_DESTROY(_TYPE,_VAR_NAME)  \
	if (_VAR_NAME) { delete reinterpret_cast<_TYPE*>(_VAR_NAME); _VAR_NAME=NULL; }

#define PIMPL_CONSTRUCT(_TYPE,_VAR_NAME)  \
	PIMPL_DESTROY(_TYPE,_VAR_NAME) \
	_VAR_NAME = new _TYPE();

#define PIMPL_GET_REF(_TYPE, _VAR_NAME)  (*reinterpret_cast<_TYPE*>(_VAR_NAME))
#define PIMPL_GET_CONSTREF(_TYPE, _VAR_NAME)  (*reinterpret_cast<const _TYPE*>(_VAR_NAME))

Add header with PIMPL helper macros

Add header with PIMPL helper macros


/*
 * Copyright (C) 2015 Eistec AB
 *
 * This file is subject to the terms and conditions of the GNU Lesser General
 * Public License v2.1. See the file LICENSE in the top level directory for more
 * details.
 */

/**
 * @defgroup    nvram Non-volatile RAM
 * @ingroup     drivers
 * @brief       Non-volatile RAM interface
 *
 * This API is designed around non-volatile memories which do not need blockwise
 * erase, such as ferro-electric RAM (FRAM) or magneto-resistive RAM (MRAM).
 *
 * This interface is not suitable for flash memories.
 *
 * @{
 *
 * @file
 *
 * @brief       Generic non-volatile RAM driver interface
 * @author      Joakim Gebart <joakim.gebart@eistec.se>
 */

#ifndef DRIVERS_NVRAM_H_
#define DRIVERS_NVRAM_H_

#include <stdint.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Forward declaration in order to declare function pointers which take this
 * type as a parameter within the struct. */
struct nvram;

/**
 * @brief Device descriptor for generic NVRAM devices.
 */
typedef struct nvram {
    /**
     * @brief Pointer to device-specific read function
     *
     * Copy data from system memory to NVRAM.
     *
     * @param[in]  dev   Pointer to NVRAM device descriptor
     * @param[out] dst   Pointer to the first byte in the system memory address space
     * @param[in]  src   Starting address in the NVRAM device address space
     * @param[in]  len   Number of bytes to copy
     *
     * @return           Number of bytes read on success
     * @return           <0 on errors
     */
    int (*read)(struct nvram *dev, uint8_t *dst, uint32_t src, size_t size);

    /**
     * @brief Pointer to device-specific write function
     *
     * Copy data from NVRAM to system memory.
     *
     * @param[in]  dev   Pointer to NVRAM device descriptor
     * @param[in]  src   Pointer to the first byte in the system memory address space
     * @param[in]  dst   Starting address in the NVRAM device address space
     * @param[in]  len   Number of bytes to copy
     *
     * @return           Number of bytes written on success
     * @return           <0 on errors
     */
    int (*write)(struct nvram *dev, uint8_t *src, uint32_t dst, size_t size);

    /** @brief Device capacity */
    size_t size;

    /** @brief Device-specific parameters, if any. */
    void *extra;
} nvram_t;

#ifdef __cplusplus
}
#endif

#endif /* DRIVERS_NVRAM_H_ */
/** @} */

drivers: Add API for NVRAM devices with byte level erase.


#ifndef BALL_CONCEPT_STDITERATORWRAPPER_H
#define BALL_CONCEPT_STDITERATORWRAPPER_H

#define IteratorWrapper(type)\
	template<typename T>\
	class type##IteratorWrapper\
	{\
		public:\
			type##IteratorWrapper(T* c) : container_(c) {}\
			type##Iterator begin() { return container_->begin##type(); }\
			type##Iterator end() { return container_->end##type(); }\
\
		private:\
			T* container_;\
	};

#define ConstIteratorWrapper(type)\
	template<typename T>\
	class type##ConstIteratorWrapper\
	{\
		public:\
			type##ConstIteratorWrapper(const T* c) : container_(c) {}\
			type##ConstIterator begin() { return container_->begin##type(); }\
			type##ConstIterator end() { return container_->end##type(); }\
\
		private:\
			const T* container_;\
	};

#define BALL_DECLARE_STD_ITERATOR_WRAPPER(container, type, method_name)\
	type##IteratorWrapper< container > method_name () {\
		return type##IteratorWrapper< container >(this);\
	}\
	type##ConstIteratorWrapper< container > method_name () const {\
		return type##ConstIteratorWrapper< container >(this);\
	}

#endif //BALL_CONCEPT_STDITERATORWRAPPER_H

Add macros that provide an iterator wrapper

This allows us to wrap e.g. begin/endAtom() calls into an object
that provides begin() and end() functions. This in turn allows the
use range based for loops in C++11.

Example:

for(auto& it : system.atoms()) {
	std::cout << it->getFullName() << std::endl;
}

Here atoms was generated using the wrapper code.


// Make sure instrumentation data from available_externally functions doesn't
// get thrown out and are emitted with the expected linkage.
// RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s

// CHECK: @__profc_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
// CHECK: @__profd_foo = linkonce_odr hidden global {{.*}} i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0){{.*}}, section "__DATA,__llvm_prf_data", align 8
inline int foo(void) { return 1; }

int main(void) {
  return foo();
}

// Make sure instrumentation data from available_externally functions doesn't
// get thrown out and are emitted with the expected linkage.
// RUN: %clang_cc1 -O2 -triple x86_64-apple-macosx10.9 -main-file-name c-linkage-available_externally.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s

// CHECK: @__profc_foo = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8
// CHECK: @__profd_foo = linkonce_odr hidden global {{.*}} i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i32 0, i32 0){{.*}}, section "__DATA,__llvm_prf_data,regular,live_support", align 8
inline int foo(void) { return 1; }

int main(void) {
  return foo();
}

Update testcase for r283948 (NFC)

[Profile] Update testcase for r283948 (NFC)

Old: "__DATA,__llvm_prf_data"
New: "__DATA,__llvm_prf_data,regular,live_support"

This should fix the following bot failure:

  http://bb.pgr.jp/builders/cmake-clang-x86_64-linux/builds/55158

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@283949 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 88f1ce548a1e06c1d40dea57346dcd654f718fb7)


/* mbed Microcontroller Library - cmsis_nvic
 * Copyright (c) 2009-2011 ARM Limited. All rights reserved.
 *
 * CMSIS-style functionality to support dynamic vectors
 */

#ifndef MBED_CMSIS_NVIC_H
#define MBED_CMSIS_NVIC_H

#include <stdint.h>

#if defined(STM32F407xx)
 #define MCU_NUM_PERIPH_VECTORS 82
#elif defined(STM32F401xE)
 #define MCU_NUM_PERIPH_VECTORS 85
#elif defined(STM32F427xx) || defined(STM32F429xx)
 #define MCU_NUM_PERIPH_VECTORS 91
#elif defined(STM32F413xx)
 #define MCU_NUM_PERIPH_VECTORS 102
#else
 #error "Number of peripheral vectors not defined for this MCU."
#endif

#define NVIC_USER_IRQ_OFFSET  16
#define NVIC_NUM_VECTORS      (16 + MCU_NUM_PERIPH_VECTORS)

#include "stm32f4xx.h"

#ifdef __cplusplus
extern "C" {
#endif

void NVIC_Relocate(void);
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
uint32_t NVIC_GetVector(IRQn_Type IRQn);

#ifdef __cplusplus
}
#endif

#endif

/* mbed Microcontroller Library - cmsis_nvic
 * Copyright (c) 2009-2011 ARM Limited. All rights reserved.
 *
 * CMSIS-style functionality to support dynamic vectors
 */

#ifndef MBED_CMSIS_NVIC_H
#define MBED_CMSIS_NVIC_H

#include <stdint.h>

#if defined(STM32F401xE) || defined(STM32F407xx)
 #define MCU_NUM_PERIPH_VECTORS 82
#elif defined(STM32F427xx) || defined(STM32F429xx)
 #define MCU_NUM_PERIPH_VECTORS 91
#elif defined(STM32F413xx)
 #define MCU_NUM_PERIPH_VECTORS 102
#else
 #error "Number of peripheral vectors not defined for this MCU."
#endif

#define NVIC_USER_IRQ_OFFSET  16
#define NVIC_NUM_VECTORS      (16 + MCU_NUM_PERIPH_VECTORS)

#include "stm32f4xx.h"

#ifdef __cplusplus
extern "C" {
#endif

void NVIC_Relocate(void);
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
uint32_t NVIC_GetVector(IRQn_Type IRQn);

#ifdef __cplusplus
}
#endif

#endif

Fix number of peripheral vectors for stm32f401xE


// SKIP: Low Priority -- this compiles with warnings, but goblint crashes.
#include <pthread.h>

int data[10];

void *t_fun(int i) {
  int *x = &data[i];
  return NULL;
}

int main() {
  pthread_t id;
  int n = 0;
  pthread_create(&id, NULL, t_fun, (int*) n);
  return 0;
}

Add a stupid test (skipped) where goblint crashes.


#define _XOPEN_SOURCE 500
#include "os_common.h"

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

char *os_find_self(const char *argv0)
{
    (void)argv0;
    // PATH_MAX (used by readlink(2)) is not necessarily available
    size_t size = 2048, used = 0;
    char *path = NULL;
    do {
        size *= 2;
        path = realloc(path, size);
        used = readlink("/proc/self/exe", path, size);
        path[used - 1] = '\0';
    } while (used >= size); // path has already been dereferencd - can't be NULL

    return path;
}

#define _XOPEN_SOURCE 500
#include "os_common.h"

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

char *os_find_self(const char *argv0)
{
    (void)argv0;
    // PATH_MAX (used by readlink(2)) is not necessarily available
    size_t size = 2048, used = 0;
    char *path = NULL;
    do {
        size *= 2;
        path = realloc(path, size);
        used = readlink("/proc/self/exe", path, size);
        path[used] = '\0';
    } while (used >= size); // path has already been dereferencd - can't be NULL

    return path;
}

Correct off-by-one error in os_find_self on Linux


// homerun.h
// HDHomeRun Wrapper

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

#ifndef HOMERUN_H
#define HOMERUN_H

int verifyHomerunTuner(int);
struct hdhomerun_discover_device_t getValidDevice();

#endif

// network.h
// hdpirun
//
// HDHomeRun wrapper. Wraps library functionality for use
//
// Author: Robbie Duncan
// Copyright: Copyright (c) 2016 Robbie Duncan
// License: See LICENSE
//
#include <stdint.h>
#include "libhdhomerun.h"
//
#ifndef HOMERUN_H
#define HOMERUN_H

int verifyHomerunTuner(int);
//
// Constructs a packet to use to respond to a discovery request. The caller is responsible for destroying the packet
struct hdhomerun_pkt_t* getDiscoveryReplyPacket();
struct hdhomerun_discover_device_t getValidDevice();

#endif

Move discovery reply packet construction to the correct file


/* Get artist by id.
 *
 * Usage:
 *  getartist 'artist id'
 *
 * $Id$
 */

#include <stdio.h>
#include <musicbrainz3/mb_c.h>

int
main(int argc, char **argv)
{
	MBQuery query;
	MBArtist artist;
	char data[256];

	if (argc < 2) {
		printf("Usage: getartist 'artist id'\n");
		return 1;
	}

	mb_webservice_init();

	query = mb_query_new(NULL, NULL);

	artist = mb_query_get_artist_by_id(query, argv[1], NULL);
	if (!artist) {
		printf("No artist returned.\n");
		mb_query_free(query);
		return 1;
	}

	mb_artist_get_id(artist, data, 256);
	printf("Id      : %s\n", data);

	mb_artist_get_type(artist, data, 256);
	printf("Type	: %s\n", data);

	mb_artist_get_name(artist, data, 256);
	printf("Name	: %s\n", data);

	mb_artist_get_sortname(artist, data, 256);
	printf("SortName: %s\n", data);

	mb_artist_free(artist);

	mb_query_free(query);

	return 0;
}

/* Get artist by id.
 *
 * Usage:
 *  getartist 'artist id'
 *
 * $Id$
 */

#include <stdio.h>
#include <musicbrainz3/mb_c.h>

int
main(int argc, char **argv)
{
	MbQuery query;
	MbArtist artist;
	char data[256];

	if (argc < 2) {
		printf("Usage: getartist 'artist id'\n");
		return 1;
	}

	mb_webservice_init();

	query = mb_query_new(NULL, NULL);

	artist = mb_query_get_artist_by_id(query, argv[1], NULL);
	if (!artist) {
		printf("No artist returned.\n");
		mb_query_free(query);
		return 1;
	}

	mb_artist_get_id(artist, data, 256);
	printf("Id      : %s\n", data);

	mb_artist_get_type(artist, data, 256);
	printf("Type	: %s\n", data);

	mb_artist_get_name(artist, data, 256);
	printf("Name	: %s\n", data);

	mb_artist_get_sortname(artist, data, 256);
	printf("SortName: %s\n", data);

	mb_artist_free(artist);

	mb_query_free(query);

	return 0;
}

Rename MBArtist to MbArtist to make it compile.

git-svn-id: 493edb1aabd9361e12d1b994f475f0ee8eea41ad@7847 b0b80210-5d09-0410-99dd-b4bd03f891c0


/*******************************************************************************
 * Copyright 2014 Trevor Robinson
 *
 * 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 <stddef.h> // size_t

#ifdef _MSC_VER

typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;

# define SIZE_T_FORMAT "%Iu"

#else

# include <stdint.h>

# define SIZE_T_FORMAT "%zu"

#endif

/*******************************************************************************
 * Copyright 2014 Trevor Robinson
 *
 * 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 <stddef.h> // size_t

#if defined(_MSC_VER) && _MSC_VER < 1600 // stdint.h added in MSVC 2010

typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;

#else

# include <stdint.h>

#endif

#if defined(_MSC_VER) && _MSC_VER < 1900 // MSVC 2015

# define SIZE_T_FORMAT "%Iu"

#else

# define SIZE_T_FORMAT "%zu"

#endif

Use platform stdint.h and standard size_t printf format in newer versions of MSVC


#include <libopencm3/stm32/flash.h>
#include "flash_writer.h"
#include <stdio.h>

void flash_writer_unlock(void)
{
    flash_unlock();
}

void flash_writer_lock(void)
{
    flash_lock();
}

void flash_writer_page_erase(void *page)
{
    flash_wait_for_last_operation();

    FLASH_CR |= FLASH_CR_PER;
    FLASH_AR = (uint32_t) page;
    FLASH_CR |= FLASH_CR_STRT;

    flash_wait_for_last_operation();

    FLASH_CR &= ~FLASH_CR_PER;
}

static void flash_write_half_word(uint16_t *flash, uint16_t half_word)
{
    /* select flash programming */
    FLASH_CR |= FLASH_CR_PG;

    /* perform half-word write */
    *flash = half_word;

    flash_wait_for_last_operation();
}

/* page address is assumed to be half-word aligned */
void flash_writer_page_write(void *page, void *data, size_t len)
{
    uint8_t *bytes = (uint8_t *) data;
    uint16_t *flash = (uint16_t *) page;
    uint16_t half_word;

    flash_wait_for_last_operation();

    size_t count;
    for (count = len; count > 1; count -= 2) {

        half_word = *bytes++;
        half_word |= (uint16_t)*bytes++ << 8;

        flash_write_half_word(flash++, half_word);
    }

    if (count == 1) {
        half_word = *bytes;
        /* preserve value of adjacent byte */
        half_word |= (uint16_t)(*(uint8_t *)flash) << 8;

        flash_write_half_word(flash, half_word);
    }

    /* reset flags */
    FLASH_CR &= ~FLASH_CR_PG;
    FLASH_SR |= FLASH_SR_EOP;
}

Add flash writer code for STM32F3.

Add flash writer code for STM32F3.


#pragma once

namespace Halley
{
	class HTTPResponse {
	public:
		virtual ~HTTPResponse() {}

		virtual int getResponseCode() const = 0;
		virtual const Bytes& getBody() const = 0;
	};

	class HTTPRequest {
	public:
		virtual ~HTTPRequest() {}
		virtual void setPostData(const String& contentType, const Bytes& data) = 0;
		virtual Future<std::unique_ptr<HTTPResponse>> send() = 0;
	};

	class AuthorisationToken {
	public:
		virtual ~AuthorisationToken() {}

		virtual String getType() const = 0;
		virtual bool isSingleUse() const = 0;
		virtual bool isCancellable() const = 0;

		virtual void cancel() = 0;
		virtual const Bytes& getData() const = 0;
	};

	class PlatformAPI
	{
	public:
		virtual ~PlatformAPI() {}

		virtual void update() = 0;

		virtual std::unique_ptr<HTTPRequest> makeHTTPRequest(const String& method, const String& url) = 0;

		virtual bool canProvideAuthToken() const = 0;
		virtual Future<std::unique_ptr<AuthorisationToken>> getAuthToken() = 0;
	};
}

#pragma once

namespace Halley
{
	class HTTPResponse {
	public:
		virtual ~HTTPResponse() {}

		virtual int getResponseCode() const = 0;
		virtual const Bytes& getBody() const = 0;
	};

	class HTTPRequest {
	public:
		virtual ~HTTPRequest() {}
		virtual void setPostData(const String& contentType, const Bytes& data) = 0;
		virtual void setHeader(const String& headerName, const String& headerValue) = 0;
		virtual Future<std::unique_ptr<HTTPResponse>> send() = 0;
	};

	class AuthorisationToken {
	public:
		virtual ~AuthorisationToken() {}

		virtual String getType() const = 0;
		virtual bool isSingleUse() const = 0;
		virtual bool isCancellable() const = 0;

		virtual void cancel() = 0;
		virtual const Bytes& getData() const = 0;
	};

	class PlatformAPI
	{
	public:
		virtual ~PlatformAPI() {}

		virtual void update() = 0;

		virtual std::unique_ptr<HTTPRequest> makeHTTPRequest(const String& method, const String& url) = 0;

		virtual bool canProvideAuthToken() const = 0;
		virtual Future<std::unique_ptr<AuthorisationToken>> getAuthToken() = 0;
	};
}

Add setHeader to HTTPRequest API

Add setHeader to HTTPRequest API


/* Return the copyright string.  This is updated manually. */

#include "Python.h"

static char cprt[] =
"Copyright (c) 2000 BeOpen.com; All Rights Reserved.\n\
Copyright (c) 1995-2000 Corporation for National Research Initiatives;\n\
All Rights Reserved.\n\
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam;\n\
All Rights Reserved.";

const char *
Py_GetCopyright(void)
{
	return cprt;
}

/* Return the copyright string.  This is updated manually. */

#include "Python.h"

static char cprt[] =
"Copyright (c) 2000 BeOpen.com.  All Rights Reserved.\n\
Copyright (c) 1995-2000 Corporation for National Research Initiatives.\n\
All Rights Reserved.\n\
Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n\
All Rights Reserved.";

const char *
Py_GetCopyright(void)
{
	return cprt;
}

Use periods, not semicolons between Copyright and All Rights Reserved.


#ifndef _EVENT_H_
#define _EVENT_H_

#include "dataStackEntry.h"

typedef struct event Event;

Event *ev_create(char *name, char *eventData, unsigned long nAUs);
Event *ev_reference(Event *event);
void  ev_release(Event *event);
char  *ev_data(Event *event);
char  *ev_topic(Event *event);
int   ev_theData(Event *event, DataStackEntry **dse);
void  ev_dump(Event *event);

#endif /* _EVENT_H_ */

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

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

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

#include "dataStackEntry.h"

typedef struct event Event;

Event *ev_create(char *name, char *eventData, unsigned long nAUs);
Event *ev_reference(Event *event);
void  ev_release(Event *event);
char  *ev_data(Event *event);
char  *ev_topic(Event *event);
int   ev_theData(Event *event, DataStackEntry **dse);
void  ev_dump(Event *event);

#endif /* _EVENT_H_ */

Add BSD 3-clause open source header

Add BSD 3-clause open source header


// LAF OS Library
// Copyright (C) 2018-2020  Igara Studio S.A.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.

#ifndef OS_WIN_COLOR_SPACE_H_INCLUDED
#define OS_WIN_COLOR_SPACE_H_INCLUDED
#pragma once

#include "os/color_space.h"

#ifdef __OBJC__
#include <Cocoa/Cocoa.h>
#endif

#include <vector>

namespace os {

std::string get_hmonitor_icc_filename(HMONITOR monitor);
os::ColorSpaceRef get_colorspace_from_icc_file(const std::string& iccFilename);
os::ColorSpaceRef get_hmonitor_colorspace(HMONITOR monitor);
void list_display_colorspaces(std::vector<os::ColorSpaceRef>& list);

} // namespace os

#endif

// LAF OS Library
// Copyright (C) 2018-2021  Igara Studio S.A.
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.

#ifndef OS_WIN_COLOR_SPACE_H_INCLUDED
#define OS_WIN_COLOR_SPACE_H_INCLUDED
#pragma once

#include "os/color_space.h"

#include <vector>

namespace os {

std::string get_hmonitor_icc_filename(HMONITOR monitor);
os::ColorSpaceRef get_colorspace_from_icc_file(const std::string& iccFilename);
os::ColorSpaceRef get_hmonitor_colorspace(HMONITOR monitor);
void list_display_colorspaces(std::vector<os::ColorSpaceRef>& list);

} // namespace os

#endif

Remove macOS header from Win32 impl

Remove macOS header from Win32 impl


/*
 * Copyright (c) 2013-2016 Apple Inc. All rights reserved.
 *
 * @APPLE_APACHE_LICENSE_HEADER_START@
 *
 * 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.
 *
 * @APPLE_APACHE_LICENSE_HEADER_END@
 */

#include "internal.h"
#include "shims.h"

#if !HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t size) {
	size_t res = strlen(dst) + strlen(src) + 1;
	if (size > 0) {
		size_t n = size - 1;
		strncpy(dst, src, n);
		dst[n] = 0;
	}
	return res;
}
#endif

Fix formatting to match libdispatch coding style.


#ifndef __RXE_H
#define __RXE_H

#define MAXBYTES 8
#define MAXBITS 64

void encrypt(char*, char *, char *);
void decrypt(char*, char *, char *);

#endif /* !__RXE_H */

#ifndef __RXE_H
#define __RXE_H

#define MAXBYTES 8
#define MAXBITS MAXBYTES*8

void encrypt(char* in, char *out, char *key);
void decrypt(char* in, char *out, char *key);

#endif /* !__RXE_H */

Make the header more descriptive

Make the header more descriptive


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

#include "common.h"
#include "sku.h"
#include "system.h"
#include "usbc_ppc.h"

void board_hibernate(void)
{
	int i;

	if (!board_is_clamshell()) {
		/*
		 * Sensors are unpowered in hibernate. Apply PD to the
		 * interrupt lines such that they don't float.
		 */
		gpio_set_flags(GPIO_ACCEL_GYRO_INT_L,
			       GPIO_INPUT | GPIO_PULL_DOWN);
		gpio_set_flags(GPIO_LID_ACCEL_INT_L,
			       GPIO_INPUT | GPIO_PULL_DOWN);
	}

	/*
	 * Board rev 5+ has the hardware fix. Don't need the following
	 * workaround. Limozeen's BRD_ID is not monotonically increasing.
         * 4 is the earliest revision.
	 */
	if ((system_get_board_version() >= 5) ||
		(board_is_clamshell() && ((system_get_board_version() != 4))))
		return;

	/*
	 * Enable the PPC power sink path before EC enters hibernate;
	 * otherwise, ACOK won't go High and can't wake EC up. Check the
	 * bug b/170324206 for details.
	 */
	for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
		ppc_vbus_sink_enable(i, 1);
}

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

#include "common.h"
#include "sku.h"
#include "system.h"
#include "usbc_ppc.h"

void board_hibernate(void)
{
	int i;

	if (!board_is_clamshell()) {
		/*
		 * Sensors are unpowered in hibernate. Apply PD to the
		 * interrupt lines such that they don't float.
		 */
		gpio_set_flags(GPIO_ACCEL_GYRO_INT_L,
			       GPIO_INPUT | GPIO_PULL_DOWN);
		gpio_set_flags(GPIO_LID_ACCEL_INT_L,
			       GPIO_INPUT | GPIO_PULL_DOWN);
	}

	/*
	 * Board rev 5+ has the hardware fix. Don't need the following
	 * workaround.
	 */
	if (system_get_board_version() >= 5)
		return;

	/*
	 * Enable the PPC power sink path before EC enters hibernate;
	 * otherwise, ACOK won't go High and can't wake EC up. Check the
	 * bug b/170324206 for details.
	 */
	for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
		ppc_vbus_sink_enable(i, 1);
}

Revert "limozeen: Refine the BRD_ID check"

This reverts commit 4860dccf9a0ea7c5ecba92d984491bd7151a31f0.

Reason for revert: lomozeen pvt buck ic board version change to 8.

Original change's description:
> limozeen: Refine the BRD_ID check
>
> Limozeen's BRD_ID is not monotonically increasing.
> The earliest revision is 4. The next BRD_ID after 7 is 0.
> Not support PPC workaround when BRD_ID 0 on limozeen.
>
> BUG=b:190250108
> BRANCH=trogdor
> TEST=make buildall success.
>
> Signed-off-by: David Huang <0bee89a4ff99f17b7e64fbf6530169dc03ff1a24@quanta.corp-partner.google.com>
> Change-Id: I16d7ff081306812c14aa31ce2b19af8e2d50ff76
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2952802
> Reviewed-by: Wai-Hong Tam <04b587fdf5845741a0c5a8b9cd59ca72d73ef8fc@google.com>
> Commit-Queue: Wai-Hong Tam <04b587fdf5845741a0c5a8b9cd59ca72d73ef8fc@google.com>

Bug: b:190250108
Change-Id: Ib15e4d0b7b783c86541775955d5b74c51f2bbce2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2965811
Bot-Commit: Rubber Stamper <d516c4cc2192058ab8dae3d306acbdaf2ce6574f@appspot.gserviceaccount.com>
Auto-Submit: David Huang <0bee89a4ff99f17b7e64fbf6530169dc03ff1a24@quanta.corp-partner.google.com>
Commit-Queue: Wai-Hong Tam <04b587fdf5845741a0c5a8b9cd59ca72d73ef8fc@google.com>


#ifndef YAWOT_VERSION_H
#define YAWOT_VERSION_H

namespace yawot
{

/**
 * Return the version of the *library* as an
 * unsigned integer.  The format is XXYYZZ
 * XX - major version
 * YY - minor version
 * ZZ - patch version
 */
unsigned int version();

}

#endif /* YAWOT_VERSION_H */

Add header define block to stop multiple header file inclusion.


#include "analyzerfactoryfactory.h"

#ifdef STRIGI_IMPORT_API
 #ifdef WIN32
  #define STRIGI_PLUGIN_API __declspec(dllexport)
 #else
  #define STRIGI_PLUGIN_API
 #endif
#else
  #error "You should add STRIGI_IMPORT_API to the top of you plugin, you should not include this header if your code is not a plugin"
#endif
#define STRIGI_ANALYZER_FACTORY(CLASS) extern "C" { \
    const AnalyzerFactoryFactory* getStrigiAnalyzerFactory() { \
        return new CLASS(); \
    } \
    void deleteStrigiAnalyzerFactory(const AnalyzerFactoryFactory* f) { \
        delete f; \
    } \
}

#include "analyzerfactoryfactory.h"

#ifdef STRIGI_IMPORT_API
 #ifdef WIN32
  #define STRIGI_PLUGIN_API __declspec(dllexport)
 #else
  #define STRIGI_PLUGIN_API
 #endif
#else
  #error "You should add STRIGI_IMPORT_API to the top of you plugin, you should not include this header if your code is not a plugin"
#endif
#define STRIGI_ANALYZER_FACTORY(CLASS) extern "C" { \
    const jstreams::AnalyzerFactoryFactory* getStrigiAnalyzerFactory() { \
        return new CLASS(); \
    } \
    void deleteStrigiAnalyzerFactory(const jstreams::AnalyzerFactoryFactory* f) { \
        delete f; \
    } \
}

Use jstreams namespace in macro definition (not everybody uses the "using" keyword.

svn path=/trunk/playground/base/strigi/; revision=611538


/*
 *  BPFoundationExtensions.h
 *  BPFoundation
 *
 *  Created by Jon Olson on 7/9/09.
 *  Copyright 2009 Ballistic Pigeon, LLC. All rights reserved.
 *
 */

#ifndef _BPFOUNDATION_EXTENSIONS_H_
#define _BPFOUNDATION_EXTENSIONS_H_

#import "NSArray+BPFoundationExtensions.h"
#import "NSMutableArray+BPFoundationExtensions.h"
#import "NSSet+BPFoundationExtensions.h"
#import "NSDictionary+BPFoundationExtensions.h"
#import "NSThread+BPFoundationExtensions.h"

#endif

/*
 *  BPFoundationExtensions.h
 *  BPFoundation
 *
 *  Created by Jon Olson on 7/9/09.
 *  Copyright 2009 Ballistic Pigeon, LLC. All rights reserved.
 *
 */

#ifndef _BPFOUNDATION_EXTENSIONS_H_
#define _BPFOUNDATION_EXTENSIONS_H_

#import "NSArray+BPFoundationExtensions.h"
#import "NSMutableArray+BPFoundationExtensions.h"
#import "NSSet+BPFoundationExtensions.h"
#import "NSDictionary+BPFoundationExtensions.h"
#import "NSThread+BPFoundationExtensions.h"
#import "BPPrimitiveArray.h"

#endif

Add primitive array to library header.

Add primitive array to library header.


int printf(const char *, ...);

/* "Duff's Device", adapted from
 * https://groups.google.com/forum/#!msg/net.lang.c/3KFq-67DzdQ/TKl64DiBAGYJ
 */
void send(short *to, short *from, int count) {
    int n = (count + 7)/8;
    switch (count % 8) {
    case 0: do  {   *to += *from++;
    case 7:         *to += *from++;
    case 6:         *to += *from++;
    case 5:         *to += *from++;
    case 4:         *to += *from++;
    case 3:         *to += *from++;
    case 2:         *to += *from++;
    case 1:         *to += *from++;
            } while (--n > 0);
    }
}

static int result(short *to, short *from, int count) {
    int i;
    for (i = 0; i < count; ++i) {
        printf("(%d, %d)", to[i], from[i]);
        if (i < count - 1) {
            printf(", ");
        }
    }
    printf("\n");
    return 0;
}

static short p[16] = {1, 2, 3, 4, 5, 6, 7, 8, 3, 8, 5, 1, 0, 0, 9, 2};
static short q[16] = {4, 2, 7, 2, 1, 2, 5, 7, 2, 6, 8, 0, 4, 2, 6, 3};

int main(void) {
    send(p + 2, q, 16);
    send(p + 5, q, 13);
    send(p + 7, p, 5);

    return result(p, q, 16);
}

Add Duff's Device adaptation to test suite


#include <pal.h>

/**
 *
 * Calculates the inverse square root of the input vector 'a'.
 *
 * @param a     Pointer to input vector
 *
 * @param c     Pointer to output vector
 *
 * @param n     Size of 'a' and 'c' vector.
 *
 * @param p     Number of processor to use (task parallelism)
 *
 * @param team  Team to work with
 **
 * @return      None
 *
 */
#include <math.h>
void p_invsqrt_f32(const float *a, float *c, int n, int p, p_team_t team)
{
    int i;
    for (i = 0; i < n; i++) {
        *(c + i) = 1.0f / sqrtf(*(a + i));
    }
}

#include <pal.h>

/**
 *
 * Calculates the inverse square root of the input vector 'a'.
 *
 * This function uses a method of computing the inverse square root
 * made popular by the Quake 3 source code release. Chris Lomont has
 * provided an exhaustive analysis here:
 * http://www.lomont.org/Math/Papers/2003/InvSqrt.pdf
 *
 * @param a     Pointer to input vector
 *
 * @param c     Pointer to output vector
 *
 * @param n     Size of 'a' and 'c' vector.
 *
 * @param p     Number of processor to use (task parallelism)
 *
 * @param team  Team to work with
 **
 * @return      None
 *
 */
#include <math.h>
void p_invsqrt_f32(const float *a, float *c, int n, int p, p_team_t team)
{
    // This union allows us to type-pun between integers and floats
    // with fewer strict aliasing concerns than the pointer casts
    // used in the original source.
    union
    {
        int32_t i;
        float f;
    } u;

    int i;
    for (i = 0; i < n; i++) {
        float x = *(a + i);
        float x2 = x * 0.5f;

        // Use some bit hacks to get a decent first approximation
        u.f = x;
        u.i = 0x5f375a86 - (u.i >> 1);
        x = u.f;

        // Perform a couple steps of Newton's method to refine our guess
        x = x * (1.5f - (x2 * x * x));
        x = x * (1.5f - (x2 * x * x));

        *(c + i) = x;
    }
}

Implement faster inverse square root function

Signed-off-by: Warren Moore <4fdbf0932cf8fc9903ee31afa97cf723d35eb3f3@warrenmoore.net>


#pragma once

#include "preprocessor/llvm_includes_start.h"
#include <llvm/IR/IRBuilder.h>
#include "preprocessor/llvm_includes_end.h"

namespace dev
{
namespace eth
{
namespace jit
{
class RuntimeManager;

/// Base class for compiler helpers like Memory, GasMeter, etc.
class CompilerHelper
{
protected:
	CompilerHelper(llvm::IRBuilder<>& _builder);

	CompilerHelper(const CompilerHelper&) = delete;
	CompilerHelper& operator=(CompilerHelper) = delete;

	/// Reference to the IR module being compiled
	llvm::Module* getModule();

	/// Reference to the main module function
	llvm::Function* getMainFunction();

	/// Reference to parent compiler IR builder
	llvm::IRBuilder<>& m_builder;
	llvm::IRBuilder<>& getBuilder() { return m_builder; }

	llvm::CallInst* createCall(llvm::Function* _func, std::initializer_list<llvm::Value*> const& _args);

	friend class RuntimeHelper;
};

/// Compiler helper that depends on runtime data
class RuntimeHelper : public CompilerHelper
{
protected:
	RuntimeHelper(RuntimeManager& _runtimeManager);

	RuntimeManager& getRuntimeManager() { return m_runtimeManager; }

private:
	RuntimeManager& m_runtimeManager;
};

using InsertPointGuard = llvm::IRBuilderBase::InsertPointGuard;

}
}
}

#pragma once

#include "preprocessor/llvm_includes_start.h"
#include <llvm/IR/IRBuilder.h>
#include "preprocessor/llvm_includes_end.h"

namespace dev
{
namespace eth
{
namespace jit
{
class RuntimeManager;

/// Base class for compiler helpers like Memory, GasMeter, etc.
class CompilerHelper
{
protected:
	CompilerHelper(llvm::IRBuilder<>& _builder);

	CompilerHelper(const CompilerHelper&) = delete;
	CompilerHelper& operator=(CompilerHelper) = delete;

	/// Reference to the IR module being compiled
	llvm::Module* getModule();

	/// Reference to the main module function
	llvm::Function* getMainFunction();

	/// Reference to parent compiler IR builder
	llvm::IRBuilder<>& m_builder;
	llvm::IRBuilder<>& getBuilder() { return m_builder; }

	llvm::CallInst* createCall(llvm::Function* _func, std::initializer_list<llvm::Value*> const& _args);

	friend class RuntimeHelper;
};

/// Compiler helper that depends on runtime data
class RuntimeHelper : public CompilerHelper
{
protected:
	RuntimeHelper(RuntimeManager& _runtimeManager);

	RuntimeManager& getRuntimeManager() { return m_runtimeManager; }

private:
	RuntimeManager& m_runtimeManager;
};

struct InsertPointGuard
{
	explicit InsertPointGuard(llvm::IRBuilderBase& _builder): m_builder(_builder), m_insertPoint(_builder.saveIP()) {}
	~InsertPointGuard() { m_builder.restoreIP(m_insertPoint); }

private:
	llvm::IRBuilderBase& m_builder;
	decltype(m_builder.saveIP()) m_insertPoint;
};

}
}
}

Reimplement InsertPointGuard to avoid LLVM ABI incompatibility.

In general, the NDEBUG flag should match cpp-ethereum and LLVM builds. But this is hard to satisfy as we usually have one system-wide build of LLVM and different builds of cpp-ethereum. This ABI incompatibility hit OSX only in release builds as LLVM is built by homebrew with assertions by default.


#ifndef ENTRY_H
#define ENTRY_H

#include <string>
#include <memory>

namespace diaryengine {
  class Entry
  {
    public:
      Entry();
      ~Entry();

      void setTitle(std::string title);
      std::string title();

    private:
      struct Implementation;
      std::unique_ptr<Implementation> inside_;
  };

}
#endif // ENTRY_H

#ifndef ENTRY_H
#define ENTRY_H

#include <string>
#include <memory>

namespace diaryengine {
  class Entry
  {
    public:
      Entry();
      ~Entry();

      void setTitle(std::string title);
      std::string title();

    private:
      struct Implementation;
      std::unique_ptr<Implementation> _inside;
  };

}
#endif // ENTRY_H

Rename the implementation pointer to respect naming convention


/*!
@file main.c
@brief A simple test program for the C library code.
*/

#include "stdio.h"

#include "verilog_parser.h"

int main(int argc, char ** argv)
{
    if(argc < 2)
    {
        printf("ERROR. Please supply at least one file path argument.\n");
        return 1;
    }
    else
    {
        int F = 0;

        for(F = 1; F < argc; F++)
        {
            printf("%s", argv[F]);fflush(stdout);

            // Load the file.
            FILE * fh = fopen(argv[F], "r");

            // Instance the parser.
            verilog_parser parser = verilog_file_parse(fh);
            printf(" parser built ");fflush(stdout);

            // Parse the file and store the result.
            int result = verilog_parse_buffer(parser);
            printf(" parser finished");fflush(stdout);

            verilog_free_parser(parser);
            printf(" parser freed");fflush(stdout);
            fclose(fh);

            if(result == 0)
            {
                printf(" - Parse successful\n");
            }
            else
            {
                printf(" - Parse failed for\n");
            }
        }
    }
    return 0;
}

/*!
@file main.c
@brief A simple test program for the C library code.
*/

#include "stdio.h"

#include "verilog_parser.h"

int main(int argc, char ** argv)
{
    if(argc < 2)
    {
        printf("ERROR. Please supply at least one file path argument.\n");
        return 1;
    }
    else
    {
        int F = 0;

        for(F = 1; F < argc; F++)
        {
            printf("%s", argv[F]);fflush(stdout);

            // Load the file.
            FILE * fh = fopen(argv[F], "r");

            // Instance the parser.
            verilog_parser parser = verilog_file_parse(fh);
            printf(" parser built ");fflush(stdout);

            // Parse the file and store the result.
            int result = verilog_parse_buffer(parser);
            printf(" parser finished");fflush(stdout);

            verilog_free_parser(parser);
            printf(" parser freed");fflush(stdout);
            fclose(fh);

            if(result == 0)
            {
                printf(" - Parse successful\n");
            }
            else
            {
                printf(" - Parse failed for\n");
                if(argc<=2) return 1;
            }
        }
    }
    return 0;
}

Fix incorrect reporting of successful parsing.
 On branch master
 Your branch is ahead of 'github/master' by 3 commits.
   (use "git push" to publish your local commits)

 Changes to be committed:
	modified:   src/main.c


#include <stdarg.h>
#include <stdio.h>

#include <whitgl/logging.h>

#define LOG_BUFFER_MAX (256)
char _buffer[LOG_BUFFER_MAX];

void whitgl_logit(const char *file, const int line, const char *str, ...)
{
	va_list args;
	va_start(args, str);
	vsnprintf(_buffer, LOG_BUFFER_MAX, str, args);
	printf("%24s:%03d  %s\n", file, line, _buffer);
}

void whitgl_panic(const char *file, const int line, const char *str, ...)
{
	va_list args;
	va_start(args, str);
	vsnprintf(_buffer, LOG_BUFFER_MAX, str, args);
	printf("PANIC %24s:%03d  %s\n", file, line, _buffer);
	__builtin_trap();
}

#include <stdarg.h>
#include <stdio.h>

#include <whitgl/logging.h>

#define LOG_BUFFER_MAX (256)
char _buffer[LOG_BUFFER_MAX];

void whitgl_logit(const char *file, const int line, const char *str, ...)
{
	va_list args;
	va_start(args, str);
	vsnprintf(_buffer, LOG_BUFFER_MAX, str, args);
	printf("%24s:%03d  %s\n", file, line, _buffer);
}

void whitgl_panic(const char *file, const int line, const char *str, ...)
{
	va_list args;
	va_start(args, str);
	vsnprintf(_buffer, LOG_BUFFER_MAX, str, args);
	printf("PANIC %24s:%03d  %s\n", file, line, _buffer);
	fflush(stdout);
	__builtin_trap();
}

Make sure stdout is flushed before trapping in panic


//
//  NSManagedObject+JSONHelpers.h
//
//  Created by Saul Mora on 6/28/11.
//  Copyright 2011 Magical Panda Software LLC. All rights reserved.
//

#import <CoreData/CoreData.h>

extern NSString * const kMagicalRecordImportCustomDateFormatKey;
extern NSString * const kMagicalRecordImportDefaultDateFormatString;
extern NSString * const kMagicalRecordImportUnixTimeString;
extern NSString * const kMagicalRecordImportAttributeKeyMapKey;
extern NSString * const kMagicalRecordImportAttributeValueClassNameKey;

extern NSString * const kMagicalRecordImportRelationshipMapKey;
extern NSString * const kMagicalRecordImportRelationshipLinkedByKey;
extern NSString * const kMagicalRecordImportRelationshipTypeKey;

@interface NSManagedObject (MagicalRecord_DataImport)

- (BOOL) MR_importValuesForKeysWithObject:(id)objectData;

+ (instancetype) MR_importFromObject:(id)data;
+ (instancetype) MR_importFromObject:(id)data inContext:(NSManagedObjectContext *)context;

+ (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData;
+ (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData inContext:(NSManagedObjectContext *)context;

@end

@interface NSManagedObject (MagicalRecord_DataImportControls)

- (BOOL) shouldImport:(id)data;
- (void) willImport:(id)data;
- (void) didImport:(id)data;

@end

//
//  NSManagedObject+JSONHelpers.h
//
//  Created by Saul Mora on 6/28/11.
//  Copyright 2011 Magical Panda Software LLC. All rights reserved.
//

#import <CoreData/CoreData.h>

extern NSString * const kMagicalRecordImportCustomDateFormatKey;
extern NSString * const kMagicalRecordImportDefaultDateFormatString;
extern NSString * const kMagicalRecordImportUnixTimeString;
extern NSString * const kMagicalRecordImportAttributeKeyMapKey;
extern NSString * const kMagicalRecordImportAttributeValueClassNameKey;

extern NSString * const kMagicalRecordImportRelationshipMapKey;
extern NSString * const kMagicalRecordImportRelationshipLinkedByKey;
extern NSString * const kMagicalRecordImportRelationshipTypeKey;

@interface NSManagedObject (MagicalRecord_DataImport)

+ (instancetype) MR_importFromObject:(id)data;
+ (instancetype) MR_importFromObject:(id)data inContext:(NSManagedObjectContext *)context;

+ (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData;
+ (NSArray *) MR_importFromArray:(NSArray *)listOfObjectData inContext:(NSManagedObjectContext *)context;

@end

@interface NSManagedObject (MagicalRecord_DataImportControls)

- (BOOL) shouldImport:(id)data;
- (void) willImport:(id)data;
- (void) didImport:(id)data;

@end

Remove unnecessarily public method from interface


//
//  TLLayoutTransitioning.h
//  TLLayoutTransitioning
//
//  Created by Tim Moose on 6/29/15.
//  Copyright (c) 2015 Tractable Labs. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for TLLayoutTransitioning.
FOUNDATION_EXPORT double TLLayoutTransitioningVersionNumber;

//! Project version string for TLLayoutTransitioning.
FOUNDATION_EXPORT const unsigned char TLLayoutTransitioningVersionString[];

<TLLayoutTransitioning/TLTransitionLayout.h>
<TLLayoutTransitioning/UICollectionView+TLTransitioning.h>

//
//  TLLayoutTransitioning.h
//  TLLayoutTransitioning
//
//  Created by Tim Moose on 6/29/15.
//  Copyright (c) 2015 Tractable Labs. All rights reserved.
//

#import <UIKit/UIKit.h>

//! Project version number for TLLayoutTransitioning.
FOUNDATION_EXPORT double TLLayoutTransitioningVersionNumber;

//! Project version string for TLLayoutTransitioning.
FOUNDATION_EXPORT const unsigned char TLLayoutTransitioningVersionString[];

#import <TLLayoutTransitioning/TLTransitionLayout.h>
#import <TLLayoutTransitioning/UICollectionView+TLTransitioning.h>

Fix typo in umbrella header

Fix typo in umbrella header


#include <unistd.h>
#include <limits.h>

char *os_find_self(void)
{
    // Using PATH_MAX is generally bad, but that's what readlink() says it uses.
    size_t size = PATH_MAX;
    char *path = malloc(size);
    if (readlink("/proc/self/exe", path, size) == 0) {
        return path;
    } else {
        free(path);
        return NULL;
    }
}

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

char *os_find_self(void)
{
    // PATH_MAX (used by readlink(2)) is not necessarily available
    size_t size = 4096;
    char *path = malloc(size);
    size_t used = readlink("/proc/self/exe", path, size);
    // need strictly less than size, or else we probably truncated
    if (used < size) {
        return path;
    } else {
        free(path);
        return NULL;
    }
}

Mend improper use of readlink(2)

Mend improper use of readlink(2)

The return-code checking for readlink(2) would never succeed before this
change.

Also avoid referencing a PATH_MAX that may be missing.


// Copyright 2016 ELIFE. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
#pragma once

#include <inform/dist.h>
#include <inform/entropy.h>
#include <inform/state_encoding.h>
#include <inform/time_series.h>

Create an "include all" header for the project


//
//  MGSFragariaTextViewDelegate.h
//  Fragaria
//
//  Created by Jim Derry on 2/22/15.
//
//

/**
 *  This protocol defines an interface for delegates that wish
 *  to receive notifications from Fragaria's text view.
 **/
#pragma mark - MGSFragariaTextViewDelegate Protocol
@protocol MGSFragariaTextViewDelegate <NSObject>
@optional

/**
 * This notification is send when the paste has been accepted. You can use
 * this delegate method to query the pasteboard for additional pasteboard content
 * that may be relevant to the application: eg: a plist that may contain custom data.
 * @param note is an NSNotification instance.
 **/
- (void)mgsTextDidPaste:(NSNotification *)note;

@end

//
//  MGSFragariaTextViewDelegate.h
//  Fragaria
//
//  Created by Jim Derry on 2/22/15.
//
//

/**
 *  This protocol defines an interface for delegates that wish
 *  to receive notifications from Fragaria's text view.
 **/
#pragma mark - MGSFragariaTextViewDelegate Protocol
@protocol MGSFragariaTextViewDelegate <NSTextViewDelegate>
@optional

/**
 * This notification is send when the paste has been accepted. You can use
 * this delegate method to query the pasteboard for additional pasteboard content
 * that may be relevant to the application: eg: a plist that may contain custom data.
 * @param note is an NSNotification instance.
 **/
- (void)mgsTextDidPaste:(NSNotification *)note;

@end

Make Fragaria's text view delegate protocol compatible with NSTextViewDelegate.


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

#include "weecrypt.h"

void print_factorial(unsigned n);

int
main(void)
{
	char buf[512];
	mpi_t fib;
	mpi_init(fib);

	while (printf("Enter N: ") &&
		   fgets(buf, sizeof(buf), stdin)) {
		unsigned n = (unsigned)strtoul(buf, NULL, 10);
		if (!n)
			break;
		print_factorial(n);
	}

	return 0;
}

void print_factorial(unsigned n)
{
	mpi_t f;
	mpi_init_u32(f, n);
	for (unsigned m = 2; m < n; ++m) {
		mpi_mul_u32(f, m, f);
	}
	printf("%u! = ", n), mpi_print_dec(f), printf("\n");
	printf("As double: %g\n", mpi_get_d(f));
	mpi_free(f);
}

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

#include "weecrypt.h"

void print_factorial(unsigned n);

int
main(void)
{
	char buf[512];
	mpi_t fib;
	mpi_init(fib);

	while (printf("Enter N: ") &&
		   fgets(buf, sizeof(buf), stdin)) {
		unsigned n = (unsigned)strtoul(buf, NULL, 10);
		if (!n)
			break;
		print_factorial(n);
	}

	return 0;
}

void print_factorial(unsigned n)
{
	mpi_t f;
	mpi_init_u32(f, n);
	printf("%u! = ", n);
	fflush(stdout);
	for (unsigned m = 2; m < n; ++m) {
		mpi_mul_u32(f, m, f);
	}
	mpi_print_dec(f), printf("\n");
	printf("As double: %g\n", mpi_get_d(f));
	mpi_free(f);
}

Print N before computing F(N)

Print N before computing F(N)


// Copyright 2012-2014 UX Productivity Pty Ltd
//
// 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 DocFormats_DFTypes_h
#define DocFormats_DFTypes_h

#ifdef _MSC_VER
#define ATTRIBUTE_ALIGNED(n)
#define ATTRIBUTE_FORMAT(archetype,index,first)
#else
#define ATTRIBUTE_ALIGNED(n) __attribute__ ((aligned (n)))
#define ATTRIBUTE_FORMAT(archetype,index,first) __attribute__((format(archetype,index,first)))
#endif

#ifdef WIN32
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <sys/types.h>
#include <stdint.h>
#include <stdarg.h>

#endif

// Copyright 2012-2014 UX Productivity Pty Ltd
//
// 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 DocFormats_DFTypes_h
#define DocFormats_DFTypes_h

#ifdef _MSC_VER
#define ATTRIBUTE_ALIGNED(n)
#define ATTRIBUTE_FORMAT(archetype,index,first)
#else
#define ATTRIBUTE_ALIGNED(n) __attribute__ ((aligned (n)))
#define ATTRIBUTE_FORMAT(archetype,index,first) __attribute__((format(archetype,index,first)))
#endif

#ifdef WIN32
#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#endif

#include <sys/types.h>
#include <stdint.h>
#include <stdarg.h>

#endif

Win32: Include windows.h (indirectly) in all files


/**************************************************************************/
/*                                                                        */
/*                                 OCaml                                  */
/*                                                                        */
/*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           */
/*                                                                        */
/*   Copyright 1997 Institut National de Recherche en Informatique et     */
/*     en Automatique.                                                    */
/*                                                                        */
/*   All rights reserved.  This file is distributed under the terms of    */
/*   the GNU Lesser General Public License version 2.1, with the          */
/*   special exception on linking described in the file LICENSE.          */
/*                                                                        */
/**************************************************************************/

#include <caml/fail.h>
#include <caml/mlvalues.h>
#include "unixsupport.h"
#ifdef HAS_UNISTD
#include <unistd.h>
#endif

CAMLprim value unix_setsid(value unit)
{
#ifdef HAS_SETSID
  return Val_int(setsid());
#else
  invalid_argument("setsid not implemented");
  return Val_unit;
#endif
}

/**************************************************************************/
/*                                                                        */
/*                                 OCaml                                  */
/*                                                                        */
/*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           */
/*                                                                        */
/*   Copyright 1997 Institut National de Recherche en Informatique et     */
/*     en Automatique.                                                    */
/*                                                                        */
/*   All rights reserved.  This file is distributed under the terms of    */
/*   the GNU Lesser General Public License version 2.1, with the          */
/*   special exception on linking described in the file LICENSE.          */
/*                                                                        */
/**************************************************************************/

#include <caml/fail.h>
#include <caml/mlvalues.h>
#include "unixsupport.h"
#ifdef HAS_UNISTD
#include <unistd.h>
#endif

CAMLprim value unix_setsid(value unit)
{
#ifdef HAS_SETSID
  return Val_int(setsid());
#else
  caml_invalid_argument("setsid not implemented");
  return Val_unit;
#endif
}

Remove use of compatibility macros in Cygwin-specific code.

This fixes PR #892 (commit 13945a71ed2616df9a4672cfc83f8f450ec437a8):
there was one compatibility macro remaining in Cygwin-specific code.


// SPDX-License-Identifier: Apache-2.0
// Copyright 2018 Eotvos Lorand University, Budapest, Hungary

#include "test.h"

fake_cmd_t t4p4s_testcase_test[][RTE_MAX_LCORE] = {
    {
        // table lookup hits
        {FAKE_PKT, 0, 1, FDATA("AA00"), 200, 123, FDATA("AA22")},
        // table lookup misses
        {FAKE_PKT, 0, 1, FDATA("BB00"), 200, 123, FDATA("BB44")},

        FEND,
    },
    {
        FEND,
    },
};

testcase_t t4p4s_test_suite[MAX_TESTCASES] = {
    { "test",           &t4p4s_testcase_test },
    TEST_SUITE_END,
};

// SPDX-License-Identifier: Apache-2.0
// Copyright 2018 Eotvos Lorand University, Budapest, Hungary

#include "test.h"

fake_cmd_t t4p4s_testcase_test[][RTE_MAX_LCORE] =
    SINGLE_LCORE(
        // table lookup hits
        FAST(1, 123, INOUT("AA00", "AA22")),
        WAIT_FOR_CTL,
        WAIT_FOR_CTL,
        WAIT_FOR_CTL,
        // table lookup misses
        FAST(1, 123, INOUT("BB00", "BB11"))
    );

testcase_t t4p4s_test_suite[MAX_TESTCASES] = {
    { "test",           &t4p4s_testcase_test },
    TEST_SUITE_END,
};

Simplify and fix test case

Simplify and fix test case


/* $Id$ */
/* Copyright (c) 2008-2014 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS System libSystem */
/* This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#ifndef LIBSYSTEM_SYSTEM_PLUGIN_H
# define LIBSYSTEM_SYSTEM_PLUGIN_H

# include "string.h"

/* Plugin */
typedef void Plugin;

/* functions */
Plugin * plugin_new(String const * libdir, String const * package,
		String const * type, String const * name);
Plugin * plugin_new_self(void);
void plugin_delete(Plugin * plugin);

/* useful */
void * plugin_lookup(Plugin * plugin, String const * symbol);

#endif /* !LIBSYSTEM_SYSTEM_PLUGIN_H */

/* $Id$ */
/* Copyright (c) 2008-2014 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS System libSystem */
/* This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. */

#ifndef LIBSYSTEM_SYSTEM_PLUGIN_H
# define LIBSYSTEM_SYSTEM_PLUGIN_H

# include "license.h"
# include "string.h"

/* Plugin */
typedef void Plugin;

typedef struct _PluginHeader
{
	char const * name;
	char const * icon;
	char const * description;
	LicenseFlags license;
} PluginHeader;

/* functions */
Plugin * plugin_new(String const * libdir, String const * package,
		String const * type, String const * name);
Plugin * plugin_new_self(void);
void plugin_delete(Plugin * plugin);

/* useful */
void * plugin_lookup(Plugin * plugin, String const * symbol);

#endif /* !LIBSYSTEM_SYSTEM_PLUGIN_H */

Define a standard header for plug-ins

Define a standard header for plug-ins


/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * 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 INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_
#define INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_

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

namespace protozero {

// Keep this struct trivially constructible (no ctors, no default initializers).
struct ContiguousMemoryRange {
  uint8_t* begin;
  uint8_t* end;  // STL style: one byte past the end of the buffer.

  inline bool is_valid() const { return begin != nullptr; }
  inline void reset() { begin = nullptr; }
  inline size_t size() { return static_cast<size_t>(end - begin); }
};

}  // namespace protozero

#endif  // INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_

/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * 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 INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_
#define INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_

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

namespace protozero {

// Keep this struct trivially constructible (no ctors, no default initializers).
struct ContiguousMemoryRange {
  uint8_t* begin;
  uint8_t* end;  // STL style: one byte past the end of the buffer.

  inline bool is_valid() const { return begin != nullptr; }
  inline void reset() { begin = nullptr; }
  inline size_t size() const { return static_cast<size_t>(end - begin); }
};

}  // namespace protozero

#endif  // INCLUDE_PERFETTO_PROTOZERO_CONTIGUOUS_MEMORY_RANGE_H_

Mark ContiguousMemoryRange::size as const. am: f2c28cd765 am: 1b5ab79b0b

Change-Id: I7516d6d8ab17209681d1925c9c2dacde0c2fcef1


#ifndef PRIMITIV_C_CUDA_DEVICE_H_
#define PRIMITIV_C_CUDA_DEVICE_H_

#include <primitiv/c/define.h>
#include <primitiv/c/device.h>

/**
 * Creates a new Device object.
 * @param device_id ID of the physical GPU.
 * @param device Pointer to receive a handler.
 * @return Status code.
 * @remarks The random number generator is initialized using
 *          `std::random_device`.
 */
extern PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_new(
    uint32_t device_id, primitiv_Device **device);

/**
 * Creates a new Device object.
 * @param device_id ID of the physical GPU.
 * @param rng_seed The seed value of the random number generator.
 * @param device Pointer to receive a handler.
 * @return Status code.
 */
extern PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_new_with_seed(
    uint32_t device_id, uint32_t rng_seed, primitiv_Device **device);

/**
 * Retrieves the number of active hardwares.
 * @param num_devices Pointer to receive the number of active hardwares.
 * @return Status code.
 */
extern PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_num_devices(
    uint32_t *num_devices);

#endif  // PRIMITIV_C_CUDA_DEVICE_H_

#ifndef PRIMITIV_C_CUDA_DEVICE_H_
#define PRIMITIV_C_CUDA_DEVICE_H_

#include <primitiv/c/define.h>
#include <primitiv/c/device.h>

/**
 * Creates a new Device object.
 * @param device_id ID of the physical GPU.
 * @param device Pointer to receive a handler.
 * @return Status code.
 * @remarks The random number generator is initialized using
 *          `std::random_device`.
 */
PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_new(
    uint32_t device_id, primitiv_Device **device);

/**
 * Creates a new Device object.
 * @param device_id ID of the physical GPU.
 * @param rng_seed The seed value of the random number generator.
 * @param device Pointer to receive a handler.
 * @return Status code.
 */
PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_new_with_seed(
    uint32_t device_id, uint32_t rng_seed, primitiv_Device **device);

/**
 * Retrieves the number of active hardwares.
 * @param num_devices Pointer to receive the number of active hardwares.
 * @return Status code.
 */
PRIMITIV_C_API PRIMITIV_C_STATUS primitiv_devices_CUDA_num_devices(
    uint32_t *num_devices);

#endif  // PRIMITIV_C_CUDA_DEVICE_H_

Fix calling conventions around CUDA.

Fix calling conventions around CUDA.