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

#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
  #define GR_TEST_UTILS 1
  #define SK_BUILD_FOR_ANDROID_FRAMEWORK
  #define SK_DEFAULT_FONT_CACHE_LIMIT   (768 * 1024)
  #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
  #define SK_USE_FREETYPE_EMBOLDEN

  // Disable these Ganesh features
  #define SK_DISABLE_REDUCE_OPLIST_SPLITTING
  // Check error is expensive. HWUI historically also doesn't check its allocations
  #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0

  // Legacy flags
  #define SK_IGNORE_GPU_DITHER
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Staging flags
  #define SK_LEGACY_PATH_ARCTO_ENDPOINT

  // Needed until we fix https://bug.skia.org/2440
  #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
  #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
  #define SK_SUPPORT_LEGACY_AA_CHOICE
  #define SK_SUPPORT_LEGACY_AAA_CHOICE

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

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

#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
  #define GR_TEST_UTILS 1
  #define SK_BUILD_FOR_ANDROID_FRAMEWORK
  #define SK_DEFAULT_FONT_CACHE_LIMIT   (768 * 1024)
  #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
  #define SK_USE_FREETYPE_EMBOLDEN

  // Disable these Ganesh features
  #define SK_DISABLE_REDUCE_OPLIST_SPLITTING
  // Check error is expensive. HWUI historically also doesn't check its allocations
  #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0

  // Legacy flags
  #define SK_IGNORE_GPU_DITHER
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Staging flags
  #define SK_LEGACY_PATH_ARCTO_ENDPOINT
  #define SK_SUPPORT_LEGACY_MATRIX_IMAGEFILTER

  // Needed until we fix https://bug.skia.org/2440
  #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
  #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
  #define SK_SUPPORT_LEGACY_AA_CHOICE
  #define SK_SUPPORT_LEGACY_AAA_CHOICE

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

Add flag to stage api change am: f83df73740

Original change: https://googleplex-android-review.googlesource.com/c/platform/external/skia/+/13451544

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I2856cdd8b51312e17468c6b5c5cdd98798d72f60


//
//  main.c
//  k-means
//
//  Created by Jamie Bullock on 24/08/2014.
//  Copyright (c) 2014 Jamie Bullock. All rights reserved.
//

#include "km.h"

#include <stdio.h>

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

    km_textfile textfile = km_textfile_new();

    RETURN_ON_ERROR(km_textfile_init(textfile));
    RETURN_ON_ERROR(km_textfile_read(textfile, "input-2.csv"));

    km_pointlist pointlist = km_pointlist_new(km_textfile_num_lines(textfile));

    RETURN_ON_ERROR(km_pointlist_fill(pointlist, textfile));

    km_pointlist_delete(pointlist);
    km_textfile_delete(textfile);

    return 0;
}

//
//  main.c
//  k-means
//
//  Created by Jamie Bullock on 24/08/2014.
//  Copyright (c) 2014 Jamie Bullock. All rights reserved.
//

#include "km.h"

#include <stdio.h>

enum cluster_id {
    Adam,
    Bob,
    Charley,
    David,
    Edward,
    km_num_cluster_ids_
};

void set_initial_cluster_centroids(km_pointlist pointlist)
{
    km_pointlist_update(pointlist, 0, Adam, -0.357, -0.253);
    km_pointlist_update(pointlist, 1, Bob, -0.055, 4.392);
    km_pointlist_update(pointlist, 2, Charley, 2.674, -0.001);
    km_pointlist_update(pointlist, 3, David, 1.044, -1.251);
    km_pointlist_update(pointlist, 3, Edward, -1.495, -0.090);
}

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

    km_textfile textfile = km_textfile_new();

    RETURN_ON_ERROR(km_textfile_init(textfile));
    RETURN_ON_ERROR(km_textfile_read(textfile, "input-2.csv"));

    km_pointlist pointlist = km_pointlist_new(km_textfile_num_lines(textfile));
    km_pointlist centroids = km_pointlist_new(km_num_cluster_ids_);

    RETURN_ON_ERROR(km_pointlist_fill(pointlist, textfile));

    set_initial_cluster_centroids(centroids);

    km_pointlist_delete(pointlist);
    km_textfile_delete(textfile);

    return 0;
}

Add setup code for initial centroids

Add setup code for initial centroids


/*
	 Copyright 2011 Michael Fortin

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

#include "Coord2D.h"
#include "Angle.h"

//! Basic 2D matrix
class Matrix2D
{
public:
	//! First row
	Coord2D row1;

	//! Second row
	Coord2D row2;

	//! Initialize as rotation matrix
	Matrix2D(const Angle &in_angle)
	: row1(cosf(in_angle.radians()), -sinf(in_angle.radians()))
	, row2(sinf(in_angle.radians()), cosf(in_angle.radians()))
	{}
};

//! Basic multiplication
Coord2D operator*(const Matrix2D &in_mat, const Coord2D &in_c2d)
{
	return Coord2D(dot(in_mat.row1, in_c2d), dot(in_mat.row2, in_c2d));
}

#endif

/*
	 Copyright 2011 Michael Fortin

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

#include "Coord2D.h"
#include "Angle.h"

//! Basic 2D matrix
class Matrix2D
{
public:
	//! First row
	Coord2D row1;

	//! Second row
	Coord2D row2;

	//! Initialize as rotation matrix
	Matrix2D(const Angle &in_angle)
	: row1(cosf(in_angle.radians()), -sinf(in_angle.radians()))
	, row2(sinf(in_angle.radians()), cosf(in_angle.radians()))
	{}

	//! Basic multiplication
	Coord2D operator*(const Coord2D &in_c2d) const
	{
		return Coord2D(dot(row1, in_c2d), dot(row2, in_c2d));
	}
};

#endif

Multiply now member of class - link errors when included in multiple cpp files


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

#ifndef CHROME_COMMON_NOTIFICATION_OBSERVER_H_
#define CHROME_COMMON_NOTIFICATION_OBSERVER_H_

class NotificationDetails;
class NotificationSource;
class NotificationType;

// This is the base class for notification observers. When a matching
// notification is posted to the notification service, Observe is called.
class NotificationObserver {
 public:
  virtual ~NotificationObserver();

  virtual void Observe(NotificationType type,
                       const NotificationSource& source,
                       const NotificationDetails& details) = 0;
};

#endif  // CHROME_COMMON_NOTIFICATION_OBSERVER_H_

Add forgotted notification observer header.

git-svn-id: http://src.chromium.org/svn/trunk/src@9021 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: b3590333382a99d18cc057bc509052629f21e87a


#ifndef __TIME_MACH_H__
#define __TIME_MACH_H__

#include "config.h"	// macros, bool, uint[XX]_t

#include <mach/clock.h>	// clock_serv_t, mach_timespec_t, etc.
#include <mach/mach.h>	// mach_port_deallocate

static inline uint64_t get_time(void)
{
	static float adj_const = 0.0F;

	// Cache the value (it doesn't change)
	if(adj_const == 0.0F)
	{
		mach_timebase_info_data_t ti;
		mach_timebase_info(&ti);

		adj_const = ti.numer / ti.denom;
	}

	return (uint64_t)mach_absolute_time() * adj_const;
}

#endif /*__TIME_MACH_H__*/

#ifndef __TIME_MACH_H__
#define __TIME_MACH_H__

#include "config.h"	// macros, bool, uint[XX]_t

#include <mach/clock.h>	// clock_serv_t, mach_timespec_t, etc.
#include <mach/mach.h>	// mach_port_deallocate
#include <mach/mach_time.h>

static inline uint64_t get_time(void)
{
	static float adj_const = 0.0F;

	// Cache the value (it doesn't change)
	if(adj_const == 0.0F)
	{
		mach_timebase_info_data_t ti;
		mach_timebase_info(&ti);

		adj_const = ti.numer / ti.denom;
	}

	return (uint64_t)mach_absolute_time() * adj_const;
}

#endif /*__TIME_MACH_H__*/

Fix build on OS X.

Fix build on OS X.


#pragma once

#include <nanogui/screen.h>
#include <nanogui/window.h>
#include <nanogui/theme.h>

class EditorGUI;
class Structure;

class DialogWindow : public nanogui::Window {
public:
	DialogWindow(EditorGUI *screen, nanogui::Theme *theme);
	nanogui::Window *getWindow() { return this; }

	Structure *structure() { return current_structure; }
	void setStructure( Structure *s);
	void loadStructure( Structure *s);
	void clear();
private:
	EditorGUI *gui;
	Structure *current_structure;
};

#pragma once

#include <nanogui/screen.h>
#include <nanogui/window.h>
#include <nanogui/theme.h>

class EditorGUI;
class Structure;

class DialogWindow : public nanogui::Window {
public:
	DialogWindow(EditorGUI *screen, nanogui::Theme *theme);
	nanogui::Window *getWindow() { return this; }

	Structure *structure() { return current_structure; }
	void setStructure( Structure *s);
	void loadStructure( Structure *s);
	void clear();
private:
	EditorGUI *gui = nullptr;
	Structure *current_structure = nullptr;
};

Fix crash due to uninitialised pointer when displaying a dialog


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

#ifndef ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_
#define ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_

#include <string>
#include <vector>

class CaptureClientGgpClient {
 public:
  CaptureClientGgpClient(std::string grpc_server_address);
  ~CaptureClientGgpClient();
  CaptureClientGgpClient(CaptureClientGgpClient&&);
  CaptureClientGgpClient& operator=(CaptureClientGgpClient&&);

  int StartCapture();
  int StopAndSaveCapture();
  int UpdateSelectedFunctions(std::vector<std::string> capture_functions);
  void ShutdownService();

 private:
  class CaptureClientGgpClientImpl;
  std::unique_ptr<CaptureClientGgpClientImpl> pimpl;
};

#endif  // ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_

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

#ifndef ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_
#define ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_

#include <memory>
#include <string>
#include <vector>

class CaptureClientGgpClient {
 public:
  CaptureClientGgpClient(std::string grpc_server_address);
  ~CaptureClientGgpClient();
  CaptureClientGgpClient(CaptureClientGgpClient&&);
  CaptureClientGgpClient& operator=(CaptureClientGgpClient&&);

  int StartCapture();
  int StopAndSaveCapture();
  int UpdateSelectedFunctions(std::vector<std::string> capture_functions);
  void ShutdownService();

 private:
  class CaptureClientGgpClientImpl;
  std::unique_ptr<CaptureClientGgpClientImpl> pimpl;
};

#endif  // ORBIT_CAPTURE_GGP_CLIENT_ORBIT_CAPTURE_GGP_CLIENT_H_

Solve build error in presubmit

Solve build error in presubmit

Missing include in file.


#define _CLC_OVERLOAD __attribute__((overloadable))
#define _CLC_DECL
#define _CLC_DEF __attribute__((always_inline))
#define _CLC_INLINE __attribute__((always_inline)) static inline

#define _CLC_OVERLOAD __attribute__((overloadable))
#define _CLC_DECL
#define _CLC_DEF __attribute__((always_inline))
#define _CLC_INLINE __attribute__((always_inline)) inline

Remove the static keyword from the _CLC_INLINE macro

static functions are not allowed in OpenCL C

git-svn-id: e7f1ab7c2a259259587475a3e7520e757882f167@184986 91177308-0d34-0410-b5e6-96231b3b80d8


#include <pal.h>

/*
 * sinh z = (exp z - exp(-z)) / 2
 */
static inline float _p_sinh(const float z)
{
    float exp_z;
    p_exp_f32(&z, &exp_z, 1);
    return 0.5f * (exp_z - 1.f / exp_z);
}

/**
 *
 * Calculates the hyperbolic sine of the vector 'a'. Angles are specified
 * in radians.
 *
 * @param a     Pointer to input vector
 *
 * @param c     Pointer to output vector
 *
 * @param n     Size of 'a' and 'c' vector.
 *
 * @return      None
 *
 */
void p_sinh_f32(const float *a, float *c, int n)
{
    int i;
    for (i = 0; i < n; i++) {
        c[i] = _p_sinh(a[i]);
    }
}

#include <pal.h>

#include "p_exp.h"

/*
 * sinh z = (exp z - exp(-z)) / 2
 */
static inline float _p_sinh(const float z)
{
    float exp_z = _p_exp(z);
    return 0.5f * (exp_z - 1.f / exp_z);
}

/**
 *
 * Calculates the hyperbolic sine of the vector 'a'. Angles are specified
 * in radians.
 *
 * @param a     Pointer to input vector
 *
 * @param c     Pointer to output vector
 *
 * @param n     Size of 'a' and 'c' vector.
 *
 * @return      None
 *
 */
void p_sinh_f32(const float *a, float *c, int n)
{
    int i;
    for (i = 0; i < n; i++) {
        c[i] = _p_sinh(a[i]);
    }
}

Use the inline exponential function.

math:sinh: Use the inline exponential function.

Signed-off-by: Mansour Moufid <ac5f6b12fab5e0d4efa7215e6c2dac9d55ab77dc@gmail.com>


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

#include <sys/types.h>
#include <sys/socket.h>
#include <net/ethernet.h>
#include <unistd.h>
#include <arpa/inet.h>

// The default size is enought to hold a whole ethernet frame (< 1524 bytes)
#ifndef PACKET_BUFFER_SIZE
#define PACKET_BUFFER_SIZE 2048
#endif

static void print_packet(const unsigned char *pkt, size_t pktlen)
{
	while (pktlen--) {
		printf("%02x", *pkt++);
	}

	putchar('\n');
}

int main(int argc, char *argv[])
{
	unsigned char pktbuf[PACKET_BUFFER_SIZE];
	int sockfd, res = 0;

	sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
	if (-1 == sockfd) {
        perror("socket");
		goto error;
	}

	while (1) {
        ssize_t pktlen = read(sockfd, pktbuf, sizeof(pktbuf));
        if (pktlen < 0) {
            perror("read");
            continue;
        }
        if (pktlen > 0) {
            print_packet(pktbuf, pktlen);
        }
	}

    close(sockfd);

out:
	return res;

error:
	res = 1;
	goto out;
}

Fix indentation by using tabs only

Fix indentation by using tabs only


#ifndef Pins_h
#define Pins_h

/*Motor pins*/
int PWMA = 9;
int AIN1 = 8;
int AIN2 = 7;

int PWMB = 10;
int BIN1 = 4;
int BIN2 = 5;

int STDBY = 6;

/*Encoder pins*/
int channelA = 3; //TX = 3
int channelB = 2; //RX = 2

/*Radio pins*/
int CE = A1; //pro micro
int CS = A0; //pro micro
//int CE = 3; //nano
//int CS = 2; //nano

#endif

Put all pin information in a single header.


#ifndef _ARTICLE_H
#define _ARTICLE_H

#include <string>
#include <vector>

/*!
 * represents a Wikipedia (Mediawiki) and its links
 */
class Article
{
public:
    typedef std::vector<Article*>                 ArticleLinkStorage;
    typedef std::vector<Article*>::const_iterator ArticleLinkIterator;

    /*! Create a new article from a title
     * \param title The title of the article
     */
    Article(std::string title)
        : title(title) {};

    //! Get the title of the article
    std::string getTitle() const
    {
        return title;
    }

    //! get the number of links the article has
    size_t getNumLinks() const;

    /*! Add a link to another article
     * \param[in] article Pointer to the article this article links
     * to
     */
    void addLink(Article* article)
    {
        links.push_back(article);
    }

    /*! Get const_iterator to first linked article */
    ArticleLinkIterator linkBegin() const
    {
        return links.cbegin();
    }

    /*! Get const_iterator to last linked article */
    ArticleLinkIterator linkEnd() const
    {
        return links.cend();
    }

private:
    std::string title;
    ArticleLinkStorage links;
};

#endif //_ARTICLE_H

#ifndef _ARTICLE_H
#define _ARTICLE_H

#include <string>
#include <vector>

/*!
 * represents a Wikipedia (Mediawiki) and its links
 */
class Article
{
public:
    //! representation of links to other articles
    typedef std::vector<Article*>                 ArticleLinkStorage;
    //! representation of iterator over links
    typedef std::vector<Article*>::iterator ArticleLinkIterator;
    //! representation of const iterator over links
    typedef std::vector<Article*>::const_iterator ArticleLinkConstIterator;

    /*! Create a new article from a title
     * \param title The title of the article
     */
    Article(std::string title)
        : title(title) {};

    //! Get the title of the article
    std::string getTitle() const
    {
        return title;
    }

    //! get the number of links the article has
    size_t getNumLinks() const;

    /*! Add a link to another article
     * \param[in] article Pointer to the article this article links
     * to
     */
    void addLink(Article* article)
    {
        links.push_back(article);
    }

    /*! Get const_iterator to first linked article */
    ArticleLinkConstIterator linkBegin() const
    {
        return links.cbegin();
    }

    /*! Get const_iterator to last linked article */
    ArticleLinkConstIterator linkEnd() const
    {
        return links.cend();
    }

private:
    std::string title;
    ArticleLinkStorage links;
};

#endif //_ARTICLE_H

Add modifying article link iterator typedef


#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>

void rsp_log(char* format, ...)
{
    char without_ms[64];
    char with_ms[64];
    struct timeval tv;
    struct tm *tm;

    gettimeofday(&tv, NULL);
    if ((tm = localtime(&tv.tv_sec)) != NULL)
    {
        strftime(without_ms, sizeof(without_ms), "%Y-%m-%d %H:%M:%S.%%06u %z", tm);
        snprintf(with_ms, sizeof(with_ms), without_ms, tv.tv_usec);
        fprintf(stdout, "[%s] ", with_ms);
    }

    va_list argptr;
    va_start(argptr, format);
    vfprintf(stdout, format, argptr);
    va_end(argptr);

    fflush(stdout);
}

void rsp_log_error(char* message)
{
    char* error = strerror(errno);

    char* full_message = malloc(strlen(message) + 3 + strlen(error));
    sprintf(full_message, "%s: %s", message, error);
    rsp_log(full_message);
    free(full_message);
}

#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>

void rsp_log(char* format, ...)
{
    char without_ms[64];
    char with_ms[64];
    struct timeval tv;
    struct tm *tm;

    gettimeofday(&tv, NULL);
    if ((tm = localtime(&tv.tv_sec)) != NULL)
    {
        strftime(without_ms, sizeof(without_ms), "%Y-%m-%d %H:%M:%S.%%06u %z", tm);
        snprintf(with_ms, sizeof(with_ms), without_ms, tv.tv_usec);
        fprintf(stdout, "[%s] ", with_ms);
    }

    va_list argptr;
    va_start(argptr, format);
    vfprintf(stdout, format, argptr);
    va_end(argptr);

    fprintf(stdout, "\n");

    fflush(stdout);
}

void rsp_log_error(char* message)
{
    char* error = strerror(errno);

    char* full_message = malloc(strlen(message) + 3 + strlen(error));
    sprintf(full_message, "%s: %s", message, error);
    rsp_log(full_message);
    free(full_message);
}

Add a newline to the end of our log messages


// RUN: %clang -S -emit-llvm %s  -o /dev/null
// XFAIL: mingw,win32

#include <setjmp.h>

sigjmp_buf B;
int foo() {
  sigsetjmp(B, 1);
  bar();
}

// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s  -o /dev/null

#define _JBLEN ((9 * 2) + 3 + 16)
typedef int sigjmp_buf[_JBLEN + 1];
int sigsetjmp(sigjmp_buf env, int savemask);
sigjmp_buf B;
int foo() {
  sigsetjmp(B, 1);
  bar();
}

Remove the need for a header and specify a triple so that the type
sizes make sense.

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


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

struct dummy {
	double d;
};

int main(int argc, char *argv[]) {
	struct dummy *d;
	char *p;

	(void) argc; (void) argv;

	/* This causes a warning with clang -Wcast-align:
	 *
	 * clang_cast_align.c:13:6: warning: cast from 'char *' to 'struct dummy *' increases required alignment
	 *       from 1 to 8 [-Wcast-align]
	 *         d = (struct dummy *) p;
	 *
	 * Note that malloc() alignment guarantees are enough to make the
	 * warning harmless, so it'd be nice to suppress.
	 */

	p = (char *) malloc(sizeof(struct dummy));
	d = (struct dummy *) p;

	/* Casting through a void pointer suppressed the warning for clang. */

	p = (char *) malloc(sizeof(struct dummy));
	d = (struct dummy *) (void *) p;

	return 0;
}

Add example of suppressing clang -Wcast-align


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

const char usage[] = "Usage: %s <filenname>\n";

#define READ_SIZE 2048

int main(int argc, char *argv[])
{
	if (argc != 2) {
		printf(usage, argv[0]);
		return 1;
	}

	//FILE *file = fopen(argv[1], "r");
	int fd = open(argv[1], O_RDONLY);
	char buf[READ_SIZE];
	ssize_t bytes;
	do {
		bytes = read(fd, buf, READ_SIZE);
		if (bytes == -1) {
			perror("error reading file");
			return 1;
		}

		write(STDOUT_FILENO, buf, bytes);
	} while (bytes == READ_SIZE);

	return 0;
}

Read file passed as argv[1]

Read file passed as argv[1]


#ifndef KERN_DIAG
#define KERN_DIAG

#include <stdarg.h>

void panic(const char* diagnostic_message, ...);
void shutdown() __attribute__((noreturn));

extern void hang_machine() __attribute__((noreturn));

#ifdef DEBUG
#define assert(x) if (!(x)) panic("Assertion failed: " __FILE__ ":%u: " #x, __LINE__)
#else
#define assert(x) (void) 0
#endif

#endif /* KERN_DIAG */

#ifndef KERN_DIAG
#define KERN_DIAG

#include <stdarg.h>

void panic(const char* diagnostic_message, ...) __attribute__((noreturn));
void shutdown() __attribute__((noreturn));

extern void hang_machine() __attribute__((noreturn));

#ifdef DEBUG
#define assert(x) if (!(x)) panic("Assertion failed: " __FILE__ ":%u: " #x, __LINE__)
#else
#define assert(x) (void) 0
#endif

#endif /* KERN_DIAG */

Declare panic function as noreturn

machine: Declare panic function as noreturn


#include "../git-compat-util.h"

void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
{
	HANDLE hmap;
	void *temp;
	size_t len;
	struct stat st;
	uint64_t o = offset;
	uint32_t l = o & 0xFFFFFFFF;
	uint32_t h = (o >> 32) & 0xFFFFFFFF;

	if (!fstat(fd, &st))
		len = xsize_t(st.st_size);
	else
		die("mmap: could not determine filesize");

	if ((length + offset) > len)
		length = len - offset;

	if (!(flags & MAP_PRIVATE))
		die("Invalid usage of mmap when built with USE_WIN32_MMAP");

	hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), 0, PAGE_WRITECOPY,
		0, 0, 0);

	if (!hmap)
		return MAP_FAILED;

	temp = MapViewOfFileEx(hmap, FILE_MAP_COPY, h, l, length, start);

	if (!CloseHandle(hmap))
		warning("unable to close file mapping handle\n");

	return temp ? temp : MAP_FAILED;
}

int git_munmap(void *start, size_t length)
{
	return !UnmapViewOfFile(start);
}

#include "../git-compat-util.h"

void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
{
	HANDLE hmap;
	void *temp;
	off_t len;
	struct stat st;
	uint64_t o = offset;
	uint32_t l = o & 0xFFFFFFFF;
	uint32_t h = (o >> 32) & 0xFFFFFFFF;

	if (!fstat(fd, &st))
		len = st.st_size;
	else
		die("mmap: could not determine filesize");

	if ((length + offset) > len)
		length = xsize_t(len - offset);

	if (!(flags & MAP_PRIVATE))
		die("Invalid usage of mmap when built with USE_WIN32_MMAP");

	hmap = CreateFileMapping((HANDLE)_get_osfhandle(fd), 0, PAGE_WRITECOPY,
		0, 0, 0);

	if (!hmap)
		return MAP_FAILED;

	temp = MapViewOfFileEx(hmap, FILE_MAP_COPY, h, l, length, start);

	if (!CloseHandle(hmap))
		warning("unable to close file mapping handle\n");

	return temp ? temp : MAP_FAILED;
}

int git_munmap(void *start, size_t length)
{
	return !UnmapViewOfFile(start);
}

Fix "Out of memory? mmap failed" for files larger than 4GB on Windows

The git_mmap implementation was broken for file sizes that wouldn't fit
into a size_t (32 bits).  This was caused by intermediate variables that
were only 32 bits wide when they should be 64 bits.

Signed-off-by: Johannes Sixt <fd432345609ae4d58c1aa629cb66ba96d1391622@kdbg.org>
Signed-off-by: Junio C Hamano <a6723cc3f76163bf7adb636a73ac3b0ceb3e6b9b@pobox.com>


// RUN: %llvmgcc -S %s -o - | grep "align 2" | count 6
struct A { char s, t, u, v; short a; };
void q() { struct A a, b; a = b; }

Check that the first and third characters, s and u,
are accessed with an alignment of 2 not 1.

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


#ifndef APPJS_WINDOW_H
#define APPJS_WINDOW_H
#pragma once

#include "appjs.h"

// GTK+ binding for linux
#if defined(__LINUX__)

#include "linux/mainwindow.h"

#endif /* end of linux */

// GTK+ binding for linux
#if defined(__WIN__)

#include "linux/mainwindow.h"

#endif /* end of linux */

namespace appjs {

using namespace v8;

class Window : public node::ObjectWrap {

  DECLARE_NODE_OBJECT_FACTORY(Window);

  DEFINE_CPP_METHOD(Show);
  DEFINE_CPP_METHOD(Hide);

};

} /* appjs */
#endif /* end of APPJS_WINDOW_H */

#ifndef APPJS_WINDOW_H
#define APPJS_WINDOW_H
#pragma once

#include "appjs.h"

// GTK+ binding for linux
#if defined(__LINUX__)

#include "linux/mainwindow.h"

#endif /* end of linux */

// Windows necessary files
#if defined(__WIN__)

#include "windows/mainwindow.h"

#endif /* end of windows */

namespace appjs {

using namespace v8;

class Window : public node::ObjectWrap {

  DECLARE_NODE_OBJECT_FACTORY(Window);

  DEFINE_CPP_METHOD(Show);
  DEFINE_CPP_METHOD(Hide);

};

} /* appjs */
#endif /* end of APPJS_WINDOW_H */

Copy paste always introduce bugs:|

Copy paste always introduce bugs:|


#include "board_id.h"

//FIXME rm
#include "iprintf.h"

#include <stdint.h>

/**
 * Returns an approximate GUID (in STM32 land) based on a bunch of fabrication-related metadata.
 *
 * See Technical Reference Manual pg933 ("Unique device ID register") for address and explanation.
 * First 32 bits are wafer X Y coordinates in BCD
 * Next 8 are wafer number
 * Next 56 are lot number in ASCII
 */
#define UNIQUE_ID_REG_ADDR            0x1FFFF7AC
#define UNIQUE_ID_REG_GET8(x)        ((x >= 0 && x < 12) ? (*(uint8_t *) (UNIQUE_ID_REG_ADDR + (x))) : 0)

uint32_t bid_GetID(void) {
   int i;
   for(i = 0; i < 12; i++) {
      //FIXME rm printing
      iprintf("ID #%d - 0x%x (%c)\n", i, UNIQUE_ID_REG_GET8(i), UNIQUE_ID_REG_GET8(i));
   }

   //use ASCII lot number as u32 board ID
   return   UNIQUE_ID_REG_GET8( 8) << 0 |
            UNIQUE_ID_REG_GET8( 9) << 8 |
            UNIQUE_ID_REG_GET8(10) << 16|
            UNIQUE_ID_REG_GET8(11) << 24;
}

#include "board_id.h"

//FIXME rm
#include "iprintf.h"

#include <stdint.h>

/**
 * Returns an approximate GUID (in STM32 land) based on a bunch of fabrication-related metadata.
 *
 * See Technical Reference Manual pg933 ("Unique device ID register") for address and explanation.
 * First 32 bits are wafer X Y coordinates in BCD
 * Next 8 are wafer number
 * Next 56 are lot number in ASCII
 */
#define UNIQUE_ID_REG_ADDR            0x1FFFF7AC
#define UNIQUE_ID_REG_GET8(x)        ((x >= 0 && x < 12) ? (*(uint8_t *) (UNIQUE_ID_REG_ADDR + (x))) : 0)

uint32_t bid_GetID(void) {
   int i;
   for(i = 0; i < 12; i++) {
      //FIXME rm printing
      iprintf("ID #%d - 0x%x (%c)\n", i, UNIQUE_ID_REG_GET8(i), UNIQUE_ID_REG_GET8(i));
   }

   // use wafer X/Y for ID. The tray I got all has the same lot number
   return   UNIQUE_ID_REG_GET8(0) << 0 |
            UNIQUE_ID_REG_GET8(1) << 8 |
            UNIQUE_ID_REG_GET8(2) << 16|
            UNIQUE_ID_REG_GET8(3) << 24;
}

Switch to wafer X/Y for board ID

Switch to wafer X/Y for board ID


/****************************************************************/
/*               DO NOT MODIFY THIS HEADER                      */
/* MOOSE - Multiphysics Object Oriented Simulation Environment  */
/*                                                              */
/*           (c) 2010 Battelle Energy Alliance, LLC             */
/*                   ALL RIGHTS RESERVED                        */
/*                                                              */
/*          Prepared by Battelle Energy Alliance, LLC           */
/*            Under Contract No. DE-AC07-05ID14517              */
/*            With the U. S. Department of Energy               */
/*                                                              */
/*            See COPYRIGHT for full restrictions               */
/****************************************************************/

#ifndef MESHCHANGEDINTERFACE_H
#define MESHCHANGEDINTERFACE_H

#include "InputParameters.h"
#include "ExecStore.h"
#include "MooseEnum.h"

// Forward declarations
class MeshChangedInterface;

template <>
InputParameters validParams<MeshChangedInterface>();

/**
 * Interface for notifications that the mesh has changed.
 */
class MeshChangedInterface
{
public:
  MeshChangedInterface(const InputParameters & params);
  virtual ~MeshChangedInterface() = default;

  /**
   * Called on this object when the mesh changes
   */
  virtual void meshChanged() {}

protected:
  /// Reference to FEProblemBase instance
  FEProblemBase & _mci_feproblem;
};

#endif /* MESHCHANGEDINTERFACE_H */

/****************************************************************/
/*               DO NOT MODIFY THIS HEADER                      */
/* MOOSE - Multiphysics Object Oriented Simulation Environment  */
/*                                                              */
/*           (c) 2010 Battelle Energy Alliance, LLC             */
/*                   ALL RIGHTS RESERVED                        */
/*                                                              */
/*          Prepared by Battelle Energy Alliance, LLC           */
/*            Under Contract No. DE-AC07-05ID14517              */
/*            With the U. S. Department of Energy               */
/*                                                              */
/*            See COPYRIGHT for full restrictions               */
/****************************************************************/

#ifndef MESHCHANGEDINTERFACE_H
#define MESHCHANGEDINTERFACE_H

#include "MooseEnum.h"

// Forward declarations
class FEProblemBase;
class InputParameters;
class MeshChangedInterface;

template <typename T>
InputParameters validParams();

template <>
InputParameters validParams<MeshChangedInterface>();

/**
 * Interface for notifications that the mesh has changed.
 */
class MeshChangedInterface
{
public:
  MeshChangedInterface(const InputParameters & params);
  virtual ~MeshChangedInterface() = default;

  /**
   * Called on this object when the mesh changes
   */
  virtual void meshChanged() {}

protected:
  /// Reference to FEProblemBase instance
  FEProblemBase & _mci_feproblem;
};

#endif /* MESHCHANGEDINTERFACE_H */

Remove unused header, switch header to fwd decl


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

#ifndef _UTILS_ASSUME_H
#define _UTILS_ASSUME_H

#include <utils/builtin.h>

/* This idiom is a way of passing extra information or hints to GCC. It is only
 * occasionally successful, so don't think of it as a silver optimisation
 * bullet.
 */
#define ASSUME(x) \
    do { \
        if (!(x)) { \
            __builtin_unreachable(); \
        } \
    } while (0)

#endif

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

#ifndef _UTILS_ASSUME_H
#define _UTILS_ASSUME_H

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

/* This idiom is a way of passing extra information or hints to GCC. It is only
 * occasionally successful, so don't think of it as a silver optimisation
 * bullet.
 */
#define ASSUME(x) \
    do { \
        if (!(x)) { \
            __builtin_unreachable(); \
        } \
    } while (0)

/* Indicate to the compiler that wherever this macro appears is a cold
 * execution path. That is, it is not performance critical and likely rarely
 * used. A perfect example is error handling code. This gives the compiler a
 * light hint to deprioritise optimisation of this path.
 */
#define COLD_PATH() \
    do { \
        JOIN(cold_path_, __COUNTER__): COLD UNUSED; \
    } while (0)

/* The opposite of `COLD_PATH`. That is, aggressively optimise this path,
 * potentially at the expense of others.
 */
#define HOT_PATH() \
    do { \
        JOIN(hot_path_, __COUNTER__): HOT UNUSED; \
    } while (0)

#endif

libutils: Add dedicated macros to indicate hot and cold execution paths.


//===----------------------------- config.h -------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//
//  Defines macros used within the libc++abi project.
//
//===----------------------------------------------------------------------===//

#ifndef LIBCXXABI_CONFIG_H
#define LIBCXXABI_CONFIG_H

#include <unistd.h>

#if defined(_POSIX_THREADS) && _POSIX_THREADS > 0
#  define LIBCXXABI_SINGLE_THREADED 0
#else
#  define LIBCXXABI_SINGLE_THREADED 1
#endif

// Set this in the CXXFLAGS when you need it, because otherwise we'd have to
// #if !defined(__linux__) && !defined(__APPLE__) && ...
// and so-on for *every* platform.
#ifndef LIBCXXABI_BAREMETAL
#  define LIBCXXABI_BAREMETAL 0
#endif

#endif // LIBCXXABI_CONFIG_H

//===----------------------------- config.h -------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//
//  Defines macros used within the libc++abi project.
//
//===----------------------------------------------------------------------===//

#ifndef LIBCXXABI_CONFIG_H
#define LIBCXXABI_CONFIG_H

#include <unistd.h>

#if !defined(LIBCXXABI_SINGLE_THREADED) && \
    defined(_POSIX_THREADS) && _POSIX_THREADS > 0
#  define LIBCXXABI_SINGLE_THREADED 0
#else
#  define LIBCXXABI_SINGLE_THREADED 1
#endif

// Set this in the CXXFLAGS when you need it, because otherwise we'd have to
// #if !defined(__linux__) && !defined(__APPLE__) && ...
// and so-on for *every* platform.
#ifndef LIBCXXABI_BAREMETAL
#  define LIBCXXABI_BAREMETAL 0
#endif

#endif // LIBCXXABI_CONFIG_H

Allow LIBCXXABI_SINGLE_THREADED to be defined by build scripts

git-svn-id: 6a9f6578bdee8d959f0ed58970538b4ab6004734@216952 91177308-0d34-0410-b5e6-96231b3b80d8


// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#pragma once

#include "IInteriorStreamingDialogView.h"
#include "InteriorsExplorerViewIncludes.h"
#include "AndroidNativeState.h"

namespace ExampleApp
{
    namespace InteriorsExplorer
    {
        namespace View
        {
            class InteriorStreamingDialogView : public IInteriorStreamingDialogView
            {
            public:
                AndroidNativeState& m_nativeState;
                jclass m_uiViewClass;
                jobject m_uiView;

                InteriorStreamingDialogView(AndroidNativeState& nativeState);

                ~InteriorStreamingDialogView();

                void Show();
                void Hide(bool interiorLoaded);
            };

        }

    }
}

// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

#pragma once

#include "IInteriorStreamingDialogView.h"
#include "InteriorsExplorerViewIncludes.h"
#include "AndroidNativeState.h"

namespace ExampleApp
{
    namespace InteriorsExplorer
    {
        namespace View
        {
            class InteriorStreamingDialogView : public IInteriorStreamingDialogView
            {
            public:
                InteriorStreamingDialogView(AndroidNativeState& nativeState);

                ~InteriorStreamingDialogView();

                void Show();
                void Hide(bool interiorLoaded);

            private:
                AndroidNativeState& m_nativeState;
                jclass m_uiViewClass;
                jobject m_uiView;
            };

        }

    }
}

Fix naming concern from previous commit. Buddy: Sam


#ifndef _CECP_FEATURES_H
#define _CECP_FEATURES_H

#include <stdio.h>

/* Features of the Chess Engine Communication Protocol supported by this program */
const char *cecp_features[] =
{
    "done=0",
    "usermove=1",
    "time=0",
    "draw=0",
    "sigint=0",
    "analyze=0",
    "variants=\"\"",
    "name=0",
    "nps=0",
    "debug=1",
    "smp=1",
    "done=1",
    0
};

#endif

#ifndef _CECP_FEATURES_H
#define _CECP_FEATURES_H

#include <stdio.h>

/* Features of the Chess Engine Communication Protocol supported by this program */
const char *cecp_features[] =
{
    "done=0",
    "usermove=1",
    "time=0",
    "draw=0",
    "sigint=0",
    "analyze=0",
    "variants=\"normal\"",
    "colors=0",
    "name=0",
    "nps=0",
    "debug=1",
    "smp=1",
    "done=1",
    0
};

#endif

Support variant 'normal' and don't expect xboard to send colors


///////////////////////////////////////////////////////////////////////
// File:        platform.h
// Description: Place holder
//
// (C) Copyright 2006, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////

#ifndef TESSERACT_PLATFORM_H_
#define TESSERACT_PLATFORM_H_

#ifndef TESS_API
# if defined(_WIN32) || defined(__CYGWIN__)
#  if defined(TESS_EXPORTS)
#    define TESS_API __declspec(dllexport)
#  elif defined(TESS_IMPORTS)
#    define TESS_API __declspec(dllimport)
#  else
#    define TESS_API
#  endif
# else
#  if defined(TESS_EXPORTS) || defined(TESS_IMPORTS)
#      define TESS_API __attribute__((visibility("default")))
#  endif
# endif
#endif

#endif  // TESSERACT_PLATFORM_H_

///////////////////////////////////////////////////////////////////////
// File:        platform.h
// Description: Place holder
//
// (C) Copyright 2006, Google Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///////////////////////////////////////////////////////////////////////

#ifndef TESSERACT_PLATFORM_H_
#define TESSERACT_PLATFORM_H_

#ifndef TESS_API
# if defined(_WIN32) || defined(__CYGWIN__)
#  if defined(TESS_EXPORTS)
#    define TESS_API __declspec(dllexport)
#  elif defined(TESS_IMPORTS)
#    define TESS_API __declspec(dllimport)
#  else
#    define TESS_API
#  endif
# else
#  if defined(TESS_EXPORTS) || defined(TESS_IMPORTS)
#    define TESS_API __attribute__((visibility("default")))
#  else
#    define TESS_API
#  endif
# endif
#endif

#endif  // TESSERACT_PLATFORM_H_

Add missing definition for TESS_API

Add missing definition for TESS_API

Signed-off-by: Stefan Weil <8d4c780fcfdc41841e5070f4c43da8958ba6aec0@weilnetz.de>


// XFAIL: hexagon
// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/body1.c
// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/body2.c
// RUN: %clang_cc1 -emit-obj -o /dev/null -ast-merge %t.1.ast -ast-merge %t.2.ast %s
// expected-no-diagnostics

Revert "[Hexagon] Test passes for hexagon target now that the backend correctly generates relocations."

This reverts commit r238754.

It depends on r238748, which was reverted.

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


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

#ifndef UI_APP_LIST_APP_LIST_EXPORT_H_
#define UI_APP_LIST_APP_LIST_EXPORT_H_
#pragma once

// Defines APP_LIST_EXPORT so that functionality implemented by the app_list
// module can be exported to consumers.

#if defined(COMPONENT_BUILD)
#if defined(WIN32)

#if defined(APP_LIST_IMPLEMENTATION)
#define APP_LIST_EXPORT __declspec(dllexport)
#else
#define APP_LIST_EXPORT __declspec(dllimport)
#endif  // defined(APP_LIST_IMPLEMENTATION)

#else  // defined(WIN32)
#define APP_LIST_EXPORT __attribute__((visibility("default")))
#endif

#else  // defined(COMPONENT_BUILD)
#define APP_LIST_EXPORT
#endif

#endif  // UI_APP_LIST_APP_LIST_EXPORT_H_

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

#ifndef UI_APP_LIST_APP_LIST_EXPORT_H_
#define UI_APP_LIST_APP_LIST_EXPORT_H_
#pragma once

// Defines APP_LIST_EXPORT so that functionality implemented by the app_list
// module can be exported to consumers.

#if defined(COMPONENT_BUILD)
#if defined(WIN32)

#if defined(APP_LIST_IMPLEMENTATION)
#define APP_LIST_EXPORT __declspec(dllexport)
#else
#define APP_LIST_EXPORT __declspec(dllimport)
#endif  // defined(APP_LIST_IMPLEMENTATION)

#else  // defined(WIN32)
#if defined(APP_LIST_IMPLEMENTATION)
#define APP_LIST_EXPORT __attribute__((visibility("default")))
#else
#define APP_LIST_EXPORT
#endif
#endif

#else  // defined(COMPONENT_BUILD)
#define APP_LIST_EXPORT
#endif

#endif  // UI_APP_LIST_APP_LIST_EXPORT_H_

Change the way _EXPORT macros look, app_list edition

I missed this in https://chromiumcodereview.appspot.com/10386108/ . Thanks to tfarina for noticing.

BUG=90078
TEST=none
TBR=ben

Review URL: https://chromiumcodereview.appspot.com/10377151

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


#ifndef MYPAINTTESTSURFACE_H
#define MYPAINTTESTSURFACE_H

#include <mypaint-surface.h>

typedef MyPaintSurface * (*MyPaintTestsSurfaceFactory)(gpointer user_data);

int
mypaint_test_surface_run(int argc, char **argv,
                      MyPaintTestsSurfaceFactory surface_factory,
                      gchar *title, gpointer user_data);

#endif // MYPAINTTESTSURFACE_H

#ifndef MYPAINTTESTSURFACE_H
#define MYPAINTTESTSURFACE_H

#include <mypaint-surface.h>
#include <mypaint-glib-compat.h>

G_BEGIN_DECLS

typedef MyPaintSurface * (*MyPaintTestsSurfaceFactory)(gpointer user_data);

int
mypaint_test_surface_run(int argc, char **argv,
                      MyPaintTestsSurfaceFactory surface_factory,
                      gchar *title, gpointer user_data);

G_END_DECLS

#endif // MYPAINTTESTSURFACE_H

brushlib/test: Add missing extern "C" declaration to header


#include <tommath.h>
#ifdef BN_MP_EXCH_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
 *
 * LibTomMath is a library that provides multiple-precision
 * integer arithmetic as well as number theoretic functionality.
 *
 * The library was designed directly after the MPI library by
 * Michael Fromberger but has been written from scratch with
 * additional optimizations in place.
 *
 * The library is free for all purposes without any express
 * guarantee it works.
 *
 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
 */

/* swap the elements of two integers, for cases where you can't simply swap the
 * mp_int pointers around
 */
void
mp_exch MPA(mp_int * a, mp_int * b)
{
  mp_int  t;

  if(MANAGED(a) || MANAGED(b)) {
    mp_init_copy(MPST, &t, a);
    mp_copy(MPST, a, b);
    mp_copy(MPST, b, &t);
    mp_clear(&t);
    return;
  }

  t  = *a;
  *a = *b;
  *b = t;
}
#endif

/* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/12/28 01:25:13 $ */

#include <tommath.h>
#ifdef BN_MP_EXCH_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
 *
 * LibTomMath is a library that provides multiple-precision
 * integer arithmetic as well as number theoretic functionality.
 *
 * The library was designed directly after the MPI library by
 * Michael Fromberger but has been written from scratch with
 * additional optimizations in place.
 *
 * The library is free for all purposes without any express
 * guarantee it works.
 *
 * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
 */

/* swap the elements of two integers, for cases where you can't simply swap the
 * mp_int pointers around
 */
void
mp_exch MPA(mp_int * a, mp_int * b)
{
  mp_int  t;

  if(MANAGED(a) || MANAGED(b)) {
    mp_init(&t);

    // copy a to t
    mp_copy(MPST, a, &t);

    // copy b to a
    mp_copy(MPST, b, a);

    // copy t to b
    mp_copy(MPST, &t, b);

    mp_clear(&t);
    return;
  }

  t  = *a;
  *a = *b;
  *b = t;
}
#endif

/* $Source: /cvs/libtom/libtommath/bn_mp_exch.c,v $ */
/* $Revision: 1.4 $ */
/* $Date: 2006/12/28 01:25:13 $ */

Fix argument order in mp_exch

Fix argument order in mp_exch


void dc_dump() {

    if (vexRT[Btn7U])
        dump_set(-127);
    else if (vexRT[Btn7D])
        dump_set(127);
    else
        dump_set(0);

}

void dc_dump() {

    if (vexRT[Btn6U])
        dump_set(-127);
    else if (vexRT[Btn6D])
        dump_set(127);
    else if (vexRT[Btn5U])
        dump_set(-15);
    else
        dump_set(0);

}

Change dump buttons and add hold button

Change dump buttons and add hold button


#include <stddef.h>
#include <kernel/port/heap.h>
#include <kernel/port/units.h>
#include <kernel/port/stdio.h>
#include <kernel/port/panic.h>

/* round_up returns `n` rounded to the next value that is zero
 * modulo `align`. */
static uintptr_t round_up(uintptr_t n, uintptr_t align) {
	if (n % align) {
		return n + (align - (n % align));
	}
	return n;
}

uintptr_t heap_next, heap_end;

void heap_init(uintptr_t start, uintptr_t end) {
	heap_next = start;
	heap_end = end;
}

void *kalloc_align(uintptr_t size, uintptr_t alignment) {
	heap_next = round_up(heap_next, alignment);
	uintptr_t ret = heap_next;
	heap_next += size;
	if(heap_next > heap_end) {
		panic("Out of space!");
	}
	return (void*)ret;
}

void *kalloc(uintptr_t size) {
	return kalloc_align(size, sizeof(uintptr_t));
}

void kfree(void *ptr, uintptr_t size) {
}

#include <stddef.h>
#include <kernel/port/heap.h>
#include <kernel/port/units.h>
#include <kernel/port/stdio.h>
#include <kernel/port/panic.h>
#include <kernel/arch/lock.h>

static mutex_t heap_lock;

/* round_up returns `n` rounded to the next value that is zero
 * modulo `align`. */
static uintptr_t round_up(uintptr_t n, uintptr_t align) {
	if (n % align) {
		return n + (align - (n % align));
	}
	return n;
}

uintptr_t heap_next, heap_end;

void heap_init(uintptr_t start, uintptr_t end) {
	heap_next = start;
	heap_end = end;
}

void *kalloc_align(uintptr_t size, uintptr_t alignment) {
	wait_acquire(&heap_lock);
	heap_next = round_up(heap_next, alignment);
	uintptr_t ret = heap_next;
	heap_next += size;
	if(heap_next > heap_end) {
		panic("Out of space!");
	}
	release(&heap_lock);
	return (void*)ret;
}

void *kalloc(uintptr_t size) {
	return kalloc_align(size, sizeof(uintptr_t));
}

void kfree(void *ptr, uintptr_t size) {
}

Put a lock around kalloc*

Put a lock around kalloc*


#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (!defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)) || \
    (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (!defined(__MAC_10_8) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8))
#define PT_DISPATCH_RETAIN_RELEASE 1
#endif

#if !defined(PT_DISPATCH_RETAIN_RELEASE)
#define PT_PRECISE_LIFETIME
#define PT_PRECISE_LIFETIME_UNUSED
#else
#define PT_PRECISE_LIFETIME __attribute__((objc_precise_lifetime))
#define PT_PRECISE_LIFETIME_UNUSED __attribute__((objc_precise_lifetime, unused))
#endif

#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && (!defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0)) || \
    (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && (!defined(__MAC_10_8) || __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8))
#define PT_DISPATCH_RETAIN_RELEASE 1
#endif

#if (!defined(PT_DISPATCH_RETAIN_RELEASE))
#define PT_PRECISE_LIFETIME __attribute__((objc_precise_lifetime))
#define PT_PRECISE_LIFETIME_UNUSED __attribute__((objc_precise_lifetime, unused))
#else
#define PT_PRECISE_LIFETIME
#define PT_PRECISE_LIFETIME_UNUSED
#endif

Fix header defines based on ARC version

Fix header defines based on ARC version


/**
 * @file
 *
 * @date Oct 21, 2013
 * @author Eldar Abusalimov
 */

#include <embox/test.h>

#include <util/bitmap.h>

EMBOX_TEST_SUITE("util/bitmap test");

#define TEST_BITMAP_SZ 100

TEST_CASE() {
	BITMAP_DECL(bitmap, TEST_BITMAP_SZ);

	bitmap_clear_all(bitmap, TEST_BITMAP_SZ);
	test_assert_equal(bitmap_find_first_set_bit(bitmap, TEST_BITMAP_SZ),
			TEST_BITMAP_SZ /* not found */ );

	for (int i = TEST_BITMAP_SZ-1; i >= 0; --i) {
		bitmap_set_bit(bitmap, i);

		test_assert_not_zero(bitmap_test_bit(bitmap, i));
		test_assert_equal(bitmap_find_first_set_bit(bitmap, TEST_BITMAP_SZ), i);
	}

}

/**
 * @file
 *
 * @date Oct 21, 2013
 * @author Eldar Abusalimov
 */

#include <embox/test.h>

#include <string.h>
#include <util/bitmap.h>

EMBOX_TEST_SUITE("util/bitmap test");

#define TEST_ALINGED_SZ    64
#define TEST_UNALINGED_SZ  100

TEST_CASE("aligned size with red zone after an array") {
	BITMAP_DECL(bitmap, TEST_ALINGED_SZ + 1);

	memset(bitmap, 0xAA, sizeof(bitmap));
	bitmap_clear_all(bitmap, TEST_ALINGED_SZ);

	test_assert_equal(bitmap_find_first_bit(bitmap, TEST_ALINGED_SZ),
			TEST_ALINGED_SZ /* not found */ );
}

TEST_CASE("unaligned size") {
	BITMAP_DECL(bitmap, TEST_UNALINGED_SZ);

	bitmap_clear_all(bitmap, TEST_UNALINGED_SZ);
	test_assert_equal(bitmap_find_first_bit(bitmap, TEST_UNALINGED_SZ),
			TEST_UNALINGED_SZ /* not found */ );

	for (int i = TEST_UNALINGED_SZ-1; i >= 0; --i) {
		bitmap_set_bit(bitmap, i);

		test_assert_not_zero(bitmap_test_bit(bitmap, i));
		test_assert_equal(bitmap_find_first_bit(bitmap, TEST_UNALINGED_SZ), i);
	}

}

Add bitmap test case which reveals a bug


// REQUIRES: powerpc-registered-target
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -S -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -fno-lax-vector-conversions -S -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -x c++ -S -o - %s | FileCheck %s

#include <altivec.h>

// Verify that simply including <altivec.h> does not generate any code
// (i.e. all inline routines in the header are marked "static")

// CHECK: .text
// CHECK-NEXT: .file
// CHECK-NEXT: {{^$}}
// CHECK-NEXT: .ident{{.*$}}
// CHECK-NEXT: .section ".note.GNU-stack","",@progbits
// CHECK-NOT: .

// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -emit-llvm -fno-lax-vector-conversions -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -faltivec -ffreestanding -emit-llvm -x c++ -o - %s | FileCheck %s

#include <altivec.h>

// Verify that simply including <altivec.h> does not generate any code
// (i.e. all inline routines in the header are marked "static")

// CHECK: target triple = "powerpc64-
// CHECK-NEXT: {{^$}}
// CHECK-NEXT: llvm.ident

Make this test not rely on a backend being registered.

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


#ifndef BigFix_Error_h
#define BigFix_Error_h

#include <exception>
#include <stddef.h>

namespace BigFix
{

class Error : public std::exception
{
public:
  template <size_t n>
  explicit Error( const char ( &literal )[n] )
    : m_what( literal )
  {
  }

  virtual const char* what() const throw();

private:
  const char* m_what;
};

}

#endif

#ifndef BigFix_Error_h
#define BigFix_Error_h

#include <exception>
#include <stddef.h>

namespace BigFix
{

class Error : public std::exception
{
public:
  template <size_t n>
  explicit Error( const char ( &literal )[n] ) throw()
    : m_what( literal )
  {
  }

  virtual const char* what() const throw();

private:
  const char* m_what;
};

}

#endif

Add throw() declaration to avoid dead code coverage


/*
 * This file is part of the KNOT Project
 *
 * Copyright (c) 2015, CESAR. 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 CESAR 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 CESAR 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 <errno.h>
#include <stdio.h>

#include "node.h"

static int nrf24_probe(void)
{
	return -ENOSYS;
}

static void nrf24_remove(void)
{
}

static int nrf24_listen(void)
{
	return -ENOSYS;
}

static int nrf24_accept(int srv_sockfd)
{
	return -ENOSYS;
}

static ssize_t nrf24_recv(int sockfd, void *buffer, size_t len)
{
	return -ENOSYS;
}

static ssize_t nrf24_send(int sockfd, const void *buffer, size_t len)
{
	return -ENOSYS;
}

static struct node_ops nrf24_ops = {
	.name = "Radio Head: nRF24",
	.probe = nrf24_probe,
	.remove = nrf24_remove,

	.listen = nrf24_listen,
	.accept = nrf24_accept,
	.recv = nrf24_recv,
	.send = nrf24_send
};

/*
 * The following functions MAY be implemented as plugins
 * initialization functions, avoiding function calls such
 * as manager@manager_start()->node@node_init()->
 * manager@node_ops_register()->node@node_probe()
 */
int node_init(void)
{
	return node_ops_register(&nrf24_ops);
}

void node_exit(void)
{
}

gw: Add RadioHead nRF24 node 'driver' skeleton

This patch adds a 'driver' to manage nRF24 radio supported by Radio
Head library.


// RUN: clang -checker-simple -verify %s

struct s {};

void f(void) {
  int a[10];
  int (*p)[10];
  p = &a;
  (*p)[3] = 1;

  struct s d;
  struct s *q;
  q = &d;
}

// RUN: clang -checker-simple -verify %s

struct s {
  int data;
  int data_array[10];
};

void f(void) {
  int a[10];
  int (*p)[10];
  p = &a;
  (*p)[3] = 1;

  struct s d;
  struct s *q;
  q = &d;
  q->data = 3;
  d.data_array[9] = 17;
}

Add random array and struct test code for SCA.

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


// Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)

#pragma once

#include "OSD.h"

class BrightnessOSD : public OSD {
public:
    BrightnessOSD();

    virtual void Hide();
    virtual void ProcessHotkeys(HotkeyInfo &hki);

private:
    MeterWnd _mWnd;

    virtual void OnDisplayChange();

    virtual LRESULT WndProc(HWND hWnd, UINT message,
        WPARAM wParam, LPARAM lParam);
};

// Copyright (c) 2015, Matthew Malensek.
// Distributed under the BSD 2-Clause License (see LICENSE.txt for details)

#pragma once

#include "OSD.h"

class BrightnessOSD : public OSD {
public:
    BrightnessOSD();

    virtual void Hide();
    virtual void ProcessHotkeys(HotkeyInfo &hki);

private:
    MeterWnd _mWnd;
    BrightnessController *_brightnessCtrl;

    virtual void OnDisplayChange();

    virtual LRESULT WndProc(HWND hWnd, UINT message,
        WPARAM wParam, LPARAM lParam);
};

Add member variable for brightness controller


// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s

// PR27085

typedef unsigned char uchar4  __attribute__ ((vector_size (4)));

// CHECK: @add2
// CHECK: add <4 x i8> {{.*}}, <i8 2, i8 2, i8 2, i8 2>
uchar4 add2(uchar4 v)
{
  return v + 2;
}

// CHECK: @sub2
// CHECK: sub <4 x i8> {{.*}}, <i8 2, i8 2, i8 2, i8 2>
uchar4 sub2(uchar4 v)
{
  return v - 2;
}

// CHECK: @mul2
// CHECK: mul <4 x i8> {{.*}}, <i8 2, i8 2, i8 2, i8 2>
uchar4 mul2(uchar4 v)
{
  return v * 2;
}

// CHECK: @div2
// CHECK: udiv <4 x i8> {{.*}}, <i8 2, i8 2, i8 2, i8 2>
uchar4 div2(uchar4 v)
{
  return v / 2;
}

typedef __attribute__(( ext_vector_type(4) )) unsigned char uchar4_ext;

// CHECK: @div3_ext
// CHECK: udiv <4 x i8> %{{.*}}, <i8 3, i8 3, i8 3, i8 3>
uchar4_ext div3_ext(uchar4_ext v)
{
  return v / 3;
}

Add vector add/sub/mul/div by scalar tests (PR27085)

Ensure the scalar is correctly splatted to all lanes

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


//
//  GITRepo+Protected.h
//  CocoaGit
//
//  Created by Geoffrey Garside on 05/08/2008.
//  Copyright 2008 ManicPanda.com. All rights reserved.
//

@interface GITRepo ()

- (NSString*)objectPathFromHash:(NSString*)hash;
- (NSData*)dataWithContentsOfHash:(NSString*)hash;
- (void)extractFromData:(NSData*)data
                   type:(NSString**)theType
                   size:(NSUInteger*)theSize
                andData:(NSData**)theData;

#pragma mark -
#pragma mark Object instanciation methods
- (id <GITObject>)objectWithHash:(NSString*)hash;
- (GITCommit*)commitWithHash:(NSString*)hash;
- (GITTag*)tagWithHash:(NSString*)hash;
- (GITTree*)treeWithHash:(NSString*)hash;
- (GITBlob*)blobWithHash:(NSString*)hash;

@end

//
//  GITRepo+Protected.h
//  CocoaGit
//
//  Created by Geoffrey Garside on 05/08/2008.
//  Copyright 2008 ManicPanda.com. All rights reserved.
//

@protocol GITObject;
@interface GITRepo ()

- (NSString*)objectPathFromHash:(NSString*)hash;
- (NSData*)dataWithContentsOfHash:(NSString*)hash;
- (void)extractFromData:(NSData*)data
                   type:(NSString**)theType
                   size:(NSUInteger*)theSize
                andData:(NSData**)theData;

#pragma mark -
#pragma mark Object instanciation methods
- (id <GITObject>)objectWithHash:(NSString*)hash;
- (GITCommit*)commitWithHash:(NSString*)hash;
- (GITTag*)tagWithHash:(NSString*)hash;
- (GITTree*)treeWithHash:(NSString*)hash;
- (GITBlob*)blobWithHash:(NSString*)hash;

@end

Add missing @protocol forward declaration


#ifndef _CSVWRITER_H_
#define _CSVWRITER_H_

#include <string>
#include <istream>
#include <stdexcept>

namespace CSV {
    class Writer {
        public:
            static const char CSV_SEP = '|';

            Writer(std::ostream& output);

            Writer operator<< (const std::string& data);

            Writer next();

        private:
            std::ostream& output;
            bool isFirstValue;

            std::string clean(const std::string&);
    };
}

#endif

#ifndef _CSVWRITER_H_
#define _CSVWRITER_H_

#include <string>
#include <istream>
#include <stdexcept>

namespace CSV {
    class Writer {
        public:
            static const char CSV_SEP = ',';

            /**
             * Construct a CSV::Writer that uses ',' as value separator.
             */
            Writer(std::ostream& output);

            /**
             * Write the given value to the csv file
             */
            Writer operator<< (const std::string& data);
            /**
             * Advance to the next line
             */
            Writer next();

        protected:
            /**
             * Clean up (escape) the given value to be used in this object.
             * Note: This is called internally in operator<<(const std::string&)
             */
            std::string clean(const std::string& data);

        private:
            std::ostream& output;
            bool isFirstValue;
    };
}

#endif

Improve and document CSV::Writer interface

',' is now the default value separator as in "comma-separated values".


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

@import Foundation;

/// PBManifest handles downloading and parsing a list of packages to fetch and install.
@interface PBManifest : NSObject

- (instancetype)init NS_UNAVAILABLE;

/// Designated initializer.
- (instancetype)initWithURL:(NSURL *)manifestURL NS_DESIGNATED_INITIALIZER;

/// Download and parse the manifest.
- (void)downloadManifest;

/// Return list of packages in the manifest for the given track.
- (NSArray *)packagesForTrack:(NSString *)track;

/// The NSURLSession to use for downloading packages. If not set, a default one will be used.
@property NSURLSession *session;

/// The number of seconds to allow downloading before timing out. Defaults to 300 (5 minutes).
@property NSUInteger downloadTimeoutSeconds;

/// The number of download attempts before giving up. Defaults to 5.
@property NSUInteger downloadAttemptsMax;

@end

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

@import Foundation;

/// PBManifest handles downloading and parsing a list of packages to fetch and install.
@interface PBManifest : NSObject

- (instancetype)init NS_UNAVAILABLE;

/// Designated initializer.
- (instancetype)initWithURL:(NSURL *)manifestURL NS_DESIGNATED_INITIALIZER;

/// Download and parse the manifest.
- (void)downloadManifest;

/// Return list of packages in the manifest for the given track.
- (NSArray *)packagesForTrack:(NSString *)track;

/// The NSURLSession to use for downloading packages. If not set, a default one will be used.
@property NSURLSession *session;

/// The number of seconds to allow downloading before timing out. Defaults to 300 (5 minutes).
/// TODO(nguyenphillip): use session config's timeoutIntervalForResource to handle timeouts, and
/// make session a required argument of initializer for both PBManifest and PBPackageInstaller.
@property NSUInteger downloadTimeoutSeconds;

/// The number of download attempts before giving up. Defaults to 5.
@property NSUInteger downloadAttemptsMax;

@end

Add TODO to replace downloadTimeoutSeconds property with session config timeout.


#pragma once
#ifdef _MSC_VER
#define SL_CALL __vectorcall
#else
#define SL_CALL
#endif

#pragma once
#include <string>

#if 0
int Stricmp(const char* str1, const char* str2) {
	int d;
	while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) {
		str1++;
		str2++;
	}
	return d;
}

int Strnicmp(const char* str1, const char* str2, int count) {
	int d = 0;
	while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) {
		str1++; str2++; count--;
	}
	return d;
}
#endif

#ifdef _MSC_VER
#define SL_CALL __vectorcall
#else
#define SL_CALL
#endif

#define COUNT_OF(X) (sizeof(X) / sizeof((X)[0]))
#define ZERO_MEM(X, Y) (memset(X, 0, Y));

Add own versions of _countof and ZeroMemory


// RUN: %ocheck 0 %s
// RUN: %check %s

__attribute((always_inline))
inline void *f(unsigned size)
{
	static char malloc_buf[16]; // CHECK: warning: mutable static variable in pure-inline function - may differ per file
	static void *ptr = malloc_buf; // CHECK: warning: mutable static variable in pure-inline function - may differ per file
	void *ret = ptr;

	ptr += size;

	return ret;
}

main()
{
	char *a = f(2);
	char *b = f(1);

	if(a + 2 != b)
		abort();

	return 0;
}

Check static locals aren't duplicated when inlined


#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H
#define SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H
#include "GameState.h"
#include "StartState.h"
#include "LevelSelectState.h"
#include <vector>

//#define START_WITHOUT_MENU

class GameStateHandler
{
private:
	std::vector<GameState*> m_stateStack;
	std::vector<GameState*> m_statesToRemove;
public:
	GameStateHandler();
	~GameStateHandler();

	int ShutDown();

	int Initialize(ComponentHandler* cHandler, Camera* cameraRef, std::string levelPath = NULL);

	int Update(float dt, InputHandler* inputHandler);

	//Push a state to the stack
	int PushStateToStack(GameState* state);
private:
};

#endif

#ifndef SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H
#define SSPAPPLICATION_GAMESTATES_GAMESTATEHANDLER_H
#include "GameState.h"
#include "StartState.h"
#include "LevelSelectState.h"
#include <vector>

#define START_WITHOUT_MENU

class GameStateHandler
{
private:
	std::vector<GameState*> m_stateStack;
	std::vector<GameState*> m_statesToRemove;
public:
	GameStateHandler();
	~GameStateHandler();

	int ShutDown();

	int Initialize(ComponentHandler* cHandler, Camera* cameraRef, std::string levelPath = NULL);

	int Update(float dt, InputHandler* inputHandler);

	//Push a state to the stack
	int PushStateToStack(GameState* state);
private:
};

#endif

ADD definition again to start without menu


/*
 * Copyright (c) 2006 Guillaume Poirier <gpoirier@mplayerhq.hu>
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg 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 FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

/***********************************************************************
 * Vector types
 **********************************************************************/
#define vec_u8_t  vector unsigned char
#define vec_s8_t  vector signed char
#define vec_u16_t vector unsigned short
#define vec_s16_t vector signed short
#define vec_u32_t vector unsigned int
#define vec_s32_t vector signed int

/***********************************************************************
 * Null vector
 **********************************************************************/
#define LOAD_ZERO const vec_u8_t zerov = vec_splat_u8( 0 )

#define zero_u8v  (vec_u8_t)  zerov
#define zero_s8v  (vec_s8_t)  zerov
#define zero_u16v (vec_u16_t) zerov
#define zero_s16v (vec_s16_t) zerov
#define zero_u32v (vec_u32_t) zerov
#define zero_s32v (vec_s32_t) zerov

Add useful Altivec types, taken from with permission from x264 authors

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@7125 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b


/*
 * This file is part of Kotaka, a mud library for DGD
 * http://github.com/shentino/kotaka
 *
 * Copyright (C) 2013  Raymond Jennings
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
float rnd()
{
	/* use 30 bits of randomness */
	return ldexp((float)random(1 << 30), -30);
}

float pi()
{
	return atan(1.0) * 4.0;
}

int dice(int faces, int count)
{
	int sum;

	while (count) {
		sum += random(faces) + 1;
		count--;
	}

	return sum;
}

/*
 * This file is part of Kotaka, a mud library for DGD
 * http://github.com/shentino/kotaka
 *
 * Copyright (C) 2013  Raymond Jennings
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
float rnd()
{
	/* use 30 bits of randomness */
	return ldexp((float)random(1 << 30), -30);
}

float bell_rnd(int degree)
{
	float sum;
	int i;

	for (i = 0; i < degree; i++) {
		sum += rnd();
	}

	return sum / (float)degree;
}

float pi()
{
	return atan(1.0) * 4.0;
}

int dice(int faces, int count)
{
	int sum;

	while (count) {
		sum += random(faces) + 1;
		count--;
	}

	return sum;
}

Add bell curve random number generator

Add bell curve random number generator


/*
 *******************************************************************************************************
 * Static pool maintained to avoid runtime mallocs.
 * It comprises of following pools:
 * 1. Pool for Arraylist
 * 2. Pool for Hashmap
 * 3. Pool for Strings
 * 4. Pool for Integers
 * 5. Pool for Bytes
 *******************************************************************************************************
 */
#define AS_MAX_STORE_SIZE 4096

typedef struct bytes_static_pool {
    as_bytes         bytes_pool[AS_MAX_STORE_SIZE];
    u_int32_t        current_bytes_id;
} as_static_pool;

#define BYTES_CNT(static_pool)                                                 \
    (((as_static_pool *)static_pool)->current_bytes_id)

#define BYTES_POOL(static_pool)                                                \
    ((as_static_pool *)static_pool)->bytes_pool

#define GET_BYTES_POOL(map_bytes, static_pool, err)                            \
    if (AS_MAX_STORE_SIZE > BYTES_CNT(static_pool)) {                          \
        map_bytes = &(BYTES_POOL(static_pool)[BYTES_CNT(static_pool)++]);      \
    } else {                                                                   \
        as_error_update(err, AEROSPIKE_ERR, "Cannot allocate as_bytes");       \
    }

#define POOL_DESTROY(static_pool)                                              \
	for (u_int32_t iter = 0; iter < BYTES_CNT(static_pool); iter++) {          \
		as_bytes_destroy(&BYTES_POOL(static_pool)[iter]);                      \
	}

/*
 *******************************************************************************************************
 * Static pool maintained to avoid runtime mallocs.
 * It comprises of following pools:
 * 1. Pool for Arraylist
 * 2. Pool for Hashmap
 * 3. Pool for Strings
 * 4. Pool for Integers
 * 5. Pool for Bytes
 *******************************************************************************************************
 */
#define AS_MAX_STORE_SIZE 4096

typedef struct bytes_static_pool {
    as_bytes         bytes_pool[AS_MAX_STORE_SIZE];
    uint32_t        current_bytes_id;
} as_static_pool;

#define BYTES_CNT(static_pool)                                                 \
    (((as_static_pool *)static_pool)->current_bytes_id)

#define BYTES_POOL(static_pool)                                                \
    ((as_static_pool *)static_pool)->bytes_pool

#define GET_BYTES_POOL(map_bytes, static_pool, err)                            \
    if (AS_MAX_STORE_SIZE > BYTES_CNT(static_pool)) {                          \
        map_bytes = &(BYTES_POOL(static_pool)[BYTES_CNT(static_pool)++]);      \
    } else {                                                                   \
        as_error_update(err, AEROSPIKE_ERR, "Cannot allocate as_bytes");       \
    }

#define POOL_DESTROY(static_pool)                                              \
	for (u_int32_t iter = 0; iter < BYTES_CNT(static_pool); iter++) {          \
		as_bytes_destroy(&BYTES_POOL(static_pool)[iter]);                      \
	}

Fix build on alpine linux. u_int32_t => uint32_t


/* linux/arch/arm/plat-s3c64xx/include/mach/regs-gpio-memport.h
 *
 * Copyright 2008 Openmoko, Inc.
 * Copyright 2008 Simtec Electronics
 *      Ben Dooks <ben@simtec.co.uk>
 *      http://armlinux.simtec.co.uk/
 *
 * S3C64XX - GPIO memory port register definitions
 */

#ifndef __ASM_PLAT_S3C64XX_REGS_GPIO_MEMPORT_H
#define __ASM_PLAT_S3C64XX_REGS_GPIO_MEMPORT_H __FILE__

#define S3C64XX_MEM0CONSTOP	S3C64XX_GPIOREG(0x1B0)
#define S3C64XX_MEM1CONSTOP	S3C64XX_GPIOREG(0x1B4)

#define S3C64XX_MEM0CONSLP0	S3C64XX_GPIOREG(0x1C0)
#define S3C64XX_MEM0CONSLP1	S3C64XX_GPIOREG(0x1C4)
#define S3C64XX_MEM1CONSLP	S3C64XX_GPIOREG(0x1C8)

#define S3C64XX_MEM0DRVCON	S3C64XX_GPIOREG(0x1D0)
#define S3C64XX_MEM1DRVCON	S3C64XX_GPIOREG(0x1D4)

#endif /* __ASM_PLAT_S3C64XX_REGS_GPIO_MEMPORT_H */

[ARM] S3C64XX: Add definitions for the GPIO memory port configurations

Add defines for the registers that control the GPIO pins that are
run the memory interface.

Signed-off-by: Ben Dooks <1177f64998f284a7348354b8e91cbbe575d9858a@fluff.org>


#include <stdio.h>

int main() {
  char palavrasecreta[20];

  sprintf(palavrasecreta, "MELANCIA");

  int acertou = 0;
  int enforcou = 0;

  do {
    // comecar o nosso jogo!!

  } while(!acertou && !enforcou);

}

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

int main() {
  char palavrasecreta[20];

  sprintf(palavrasecreta, "MELANCIA");

  int acertou = 0;
  int enforcou = 0;

  do {
    char chute;
    scanf("%c", &chute);

    for(int i = 0; i < strlen(palavrasecreta); i++) {
      if(palavrasecreta[i] == chute) {
        printf("A posição %d tem essa letra!\n", i);
      }
    }

  } while(!acertou && !enforcou);

}

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


#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>

#include "daemon.h"

void daemon_exit_handler(int sig)
{

    //Here we release resources

#ifdef  DAEMON_PID_FILE_NAME
    unlink(DAEMON_PID_FILE_NAME);
#endif

    _exit(EXIT_FAILURE);
}

void init_signals(void)
{

    struct sigaction sa;

    memset(&sa, 0, sizeof(sa));
    sa.sa_handler = daemon_exit_handler;
    if( sigaction(SIGTERM, &sa, NULL) != 0)
        daemon_error_exit("Can't set daemon_exit_handler: %m\n");

    signal(SIGCHLD, SIG_IGN); // ignore child
    signal(SIGTSTP, SIG_IGN); // ignore tty signals
    signal(SIGTTOU, SIG_IGN);
    signal(SIGTTIN, SIG_IGN);
    signal(SIGHUP, SIG_IGN);
}

int main(void)
{

    daemonize();
    init_signals();

    while(1)
    {

        // Here а routine of daemon

        printf("%s: daemon is run\n", DAEMON_NAME);
        sleep(10);
    }

    return EXIT_SUCCESS; // good job (we interrupted (finished) main loop)
}

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <signal.h>

#include "daemon.h"

void daemon_exit_handler(int sig)
{

    //Here we release resources

#ifdef  DAEMON_PID_FILE_NAME
    unlink(DAEMON_PID_FILE_NAME);
#endif

    _exit(EXIT_FAILURE);
}

void init_signals(void)
{

    struct sigaction sa;

    memset(&sa, 0, sizeof(sa));
    sa.sa_handler = daemon_exit_handler;
    if( sigaction(SIGTERM, &sa, NULL) != 0)
        daemon_error_exit("Can't set daemon_exit_handler: %m\n");

    signal(SIGCHLD, SIG_IGN); // ignore child
    signal(SIGTSTP, SIG_IGN); // ignore tty signals
    signal(SIGTTOU, SIG_IGN);
    signal(SIGTTIN, SIG_IGN);
    signal(SIGHUP, SIG_IGN);
}

int main(void)
{

    daemonize();
    init_signals();

    while(1)
    {

        // Here а routine of daemon

        printf("%s: daemon is run\n", DAEMON_NAME);
        sleep(10);
    }

    return EXIT_SUCCESS; // good job (we interrupted (finished) main loop)
}

template_3: Fix warning: implicit declaration of function memset


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

#include "matrix.h"

int main() {
    matrix *a = new_matrix(3, 4);
    int i; for (i = 0; i < a->rows; i++) {
        int j; for (j = 0; j < a->cols; j++) {
            a->contents[i][j] = i * a->cols + j;
        }
    }
    print_matrix(a);
    printf("\n\n");

    matrix *b = new_matrix(4, 5);
    for (i = 0; i < b->rows; i++) {
        int j; for (j = 0; j < b->cols; j++) {
            b->contents[i][j] = i * b->cols + j;
        }
    }
    print_matrix(b);
    printf("\n\n");

    matrix *c = cross_product(a, b);
    print_matrix(c);
    printf("\n\n");

    scalar_multiply(a, 3);
    print_matrix(a);

    free_matrix(a);
    free_matrix(b);
    free_matrix(c);
    return 0;
}

Add a test file for matrix functions

Add a test file for matrix functions


#ifndef CPR_MULTIPART_H
#define CPR_MULTIPART_H

#include <initializer_list>
#include <string>
#include <vector>

#include "defines.h"

namespace cpr {

struct File {
    template <typename StringType>
    File(StringType&& filepath) : filepath{CPR_FWD(filepath)} {}
    std::string filepath;
};

struct Part {
    Part(const std::string& name, const std::string& value, const std::string& content_type = {})
            : name{name}, value{value}, content_type{content_type}, is_file{false} {}
    Part(const std::string& name, const int& value, const std::string& content_type = {})
            : name{name}, value{std::to_string(value)}, content_type{content_type}, is_file{false} {
    }
    Part(const std::string& name, const File& file, const std::string& content_type = {})
            : name{name}, value{file.filepath}, content_type{content_type}, is_file{true} {}

    std::string name;
    std::string value;
    std::string content_type;
    bool is_file;
};

class Multipart {
  public:
    Multipart(const std::initializer_list<Part>& parts);

    std::vector<Part> parts;
};

} // namespace cpr

#endif

#ifndef CPR_MULTIPART_H
#define CPR_MULTIPART_H

#include <initializer_list>
#include <string>
#include <vector>

#include "defines.h"

namespace cpr {

struct File {
    template <typename StringType>
    explicit File(StringType&& filepath) : filepath{CPR_FWD(filepath)} {}
    std::string filepath;
};

struct Part {
    Part(const std::string& name, const std::string& value, const std::string& content_type = {})
            : name{name}, value{value}, content_type{content_type}, is_file{false} {}
    Part(const std::string& name, const int& value, const std::string& content_type = {})
            : name{name}, value{std::to_string(value)}, content_type{content_type}, is_file{false} {
    }
    Part(const std::string& name, const File& file, const std::string& content_type = {})
            : name{name}, value{file.filepath}, content_type{content_type}, is_file{true} {}

    std::string name;
    std::string value;
    std::string content_type;
    bool is_file;
};

class Multipart {
  public:
    Multipart(const std::initializer_list<Part>& parts);

    std::vector<Part> parts;
};

} // namespace cpr

#endif

Use explicit constructor for File to resolve template deductions


#include "telit_HE910.h"

namespace openxc {
namespace server_task {

void openxc::server_task::firmwareCheck(TelitDevice* device);
void openxc::server_task::flushDataBuffer(TelitDevice* device);
void openxc::server_task::commandCheck(TelitDevice* device);

}
}

#include "telit_he910.h"

namespace openxc {
namespace server_task {

void openxc::server_task::firmwareCheck(TelitDevice* device);
void openxc::server_task::flushDataBuffer(TelitDevice* device);
void openxc::server_task::commandCheck(TelitDevice* device);

}
}

Fix case of an include to support crossplatform compilation.


#include <stdio.h>
#include "player_key.h"

bool_t key_is_goalie(player_key_t *key)
{
  return key->position == 'G';
}

void show_key_player(player_key_t *key, size_t ofs_key)
{
  size_t i;

  printf("T: %2u NO: %2u POS: %c NAME: %-15s %-15s",
         key->team, key->jersey, key->position, key->first, key->last);

  printf(" OFS_KEY: %4x OFS_ATT: %4x OFS_CAR: %4x OFS_SEA: %4x",
         ofs_key, key->ofs_attributes, key->ofs_career_stats, key->ofs_season_stats);

  printf(" UNKNOWN: ");
  for (i = 0; i < sizeof(key->unknown); i++)
    {
      printf("%3u ", key->unknown[i]);
    }
}

#include <stdio.h>
#include "player_key.h"

bool_t key_is_goalie(player_key_t *key)
{
  return key->position == 'G';
}

void show_key_player(player_key_t *key, size_t ofs_key)
{
  size_t i;

  printf("T: %3u NO: %2u POS: %c NAME: %-15s %-15s",
         key->team, key->jersey, key->position, key->first, key->last);

  printf(" OFS_KEY: %4x OFS_ATT: %4x OFS_CAR: %4x OFS_SEA: %4x",
         ofs_key, key->ofs_attributes, key->ofs_career_stats, key->ofs_season_stats);

  printf(" UNKNOWN: ");
  for (i = 0; i < sizeof(key->unknown); i++)
    {
      printf("%3u ", key->unknown[i]);
    }
}

Align free agents (team index 255) with the rest


/*
Copyright (C) 2015 George White <stonehippo@gmail.com>, All rights reserved.

See https://raw.githubusercontent.com/stonehippo/sploder/master/LICENSE.txt for license details.
*/

// ******************* Timing helpers *******************
void startTimer(long &timer) {
  timer = millis();
}

boolean isTimerExpired(long &timer, int expiration) {
  long current = millis() - timer;
  return current > expiration;
}

void clearTimer(long &timer) {
  timer = 0;
}

/*
Copyright (C) 2015 George White <stonehippo@gmail.com>, All rights reserved.

See https://raw.githubusercontent.com/stonehippo/sploder/master/LICENSE.txt for license details.
*/

// ******************* Timing helpers *******************
void startTimer(long &timer) {
  timer = millis();
}

boolean isTimerExpired(long &timer, long expiration) {
  long current = millis() - timer;
  return current > expiration;
}

void clearTimer(long &timer) {
  timer = 0;
}

Fix bug in timer comparison

Fix bug in timer comparison

The expiration time was being cast to an int, truncating longer timeouts.


//
//  CCLoadingController.h
//  CCKit
//
//  Created by Leonardo Lobato on 3/15/13.
//  Copyright (c) 2013 Cliq Consulting. All rights reserved.
//

#import <UIKit/UIKit.h>

@protocol CCLoadingControllerDelegate;

@interface CCLoadingController : NSObject

@property (nonatomic, readonly) UIView *loadingView;
@property (nonatomic, weak) id<CCLoadingControllerDelegate> delegate;

- (void)showLoadingView:(BOOL)show animated:(BOOL)animated;

@end

@protocol CCLoadingControllerDelegate <NSObject>
- (UIView *)parentViewForLoadingController:(CCLoadingController *)controller;
@optional;
- (UIView *)loadingControllerShouldBeDisplayedBelowView:(CCLoadingController *)controller;
- (NSString *)titleForLoadingViewOnLoadingController:(CCLoadingController *)controller;
@end

//
//  CCLoadingController.h
//  CCKit
//
//  Created by Leonardo Lobato on 3/15/13.
//  Copyright (c) 2013 Cliq Consulting. All rights reserved.
//

#import <UIKit/UIKit.h>

@protocol CCLoadingControllerDelegate;

@interface CCLoadingController : NSObject

@property (nonatomic, readonly) UIView *loadingView;
#if __has_feature(objc_arc)
@property (nonatomic, weak) id<CCLoadingControllerDelegate> delegate;
#else
@property (nonatomic, assign) id<CCLoadingControllerDelegate> delegate;
#endif

- (void)showLoadingView:(BOOL)show animated:(BOOL)animated;

@end

@protocol CCLoadingControllerDelegate <NSObject>
- (UIView *)parentViewForLoadingController:(CCLoadingController *)controller;
@optional;
- (UIView *)loadingControllerShouldBeDisplayedBelowView:(CCLoadingController *)controller;
- (NSString *)titleForLoadingViewOnLoadingController:(CCLoadingController *)controller;
@end

Fix build for non-arc projects

Fix build for non-arc projects

Does **not** add no-arc support. Project will leak.


#ifndef CLIENTVERSION_H
#define CLIENTVERSION_H

//
// client versioning
//

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

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

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

#endif // CLIENTVERSION_H

#ifndef CLIENTVERSION_H
#define CLIENTVERSION_H

//
// client versioning
//

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

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

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

#endif // CLIENTVERSION_H

Switch version numbers to 0.8.1.99

Switch version numbers to 0.8.1.99


#ifndef CCSPEC_H_

#include "ccspec/expectation_target.h"
#include "ccspec/matcher.h"
#include "ccspec/matchers.h"

#endif // CCSPEC_H_

#ifndef CCSPEC_H_
#define CCSPEC_H_

#include "ccspec/expectation_target.h"
#include "ccspec/matcher.h"
#include "ccspec/matchers.h"

#endif // CCSPEC_H_

Add missing definition for include guard


// main.c
// Main Program for HWP Media Center
//
// Author : Weipeng He <heweipeng@gmail.com>
// Copyright (c) 2014, All rights reserved.

#include "utils.h"

#include <stdio.h>
#include <curl/curl.h>

size_t write_data(void *buffer, size_t size, size_t nmemb, void *dstr) {
  d_string* str = (d_string*) dstr;
  dstr_ncat(str, buffer, size * nmemb);
  return nmemb;
}

int main(int argc, char** argv) {
  CURL* curl;
  CURLcode res;

  curl = curl_easy_init();

  if (curl) {
    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);

    d_string* content = dstr_alloc();
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, content);

    res = curl_easy_perform(curl);
    if (res != CURLE_OK) {
      fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
    }

    printf("size=%d, cap=%d\n%s", content->size, content->cap, content->str);

    dstr_free(content);
    curl_easy_cleanup(curl);
  }

  return 0;
}

// main.c
// Main Program for HWP Media Center
//
// Author : Weipeng He <heweipeng@gmail.com>
// Copyright (c) 2014, All rights reserved.

#include "utils.h"

#include <stdio.h>
#include <curl/curl.h>

size_t write_data(void *buffer, size_t size, size_t nmemb, void *dstr) {
  d_string* str = (d_string*) dstr;
  dstr_ncat(str, buffer, size * nmemb);
  return nmemb;
}

int main(int argc, char** argv) {
  CURL* curl;
  CURLcode res;

  curl = curl_easy_init();

  if (curl) {
    curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
    curl_easy_setopt(curl, CURLOPT_USERAGENT, "hwp");

    d_string* content = dstr_alloc();
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
    curl_easy_setopt(curl, CURLOPT_WRITEDATA, content);

    res = curl_easy_perform(curl);
    if (res != CURLE_OK) {
      fprintf(stderr, "Failed to connect: %s\n", curl_easy_strerror(res));
    }

    printf("size=%d, cap=%d\n%s", content->size, content->cap, content->str);

    dstr_free(content);
    curl_easy_cleanup(curl);
  }

  return 0;
}

Add User-Agent to prevent from blocked by Douban.fm


//===-- llvm/ModuleProvider.h - Interface for module providers --*- C++ -*-===//
//
// This file provides an abstract interface for loading a module from some
// place.  This interface allows incremental or random access loading of
// functions from the file.  This is useful for applications like JIT compilers
// or interprocedural optimizers that do not need the entire program in memory
// at the same time.
//
//===----------------------------------------------------------------------===//

#ifndef MODULEPROVIDER_H
#define MODULEPROVIDER_H

class Function;
class Module;

class ModuleProvider {
protected:
  Module *TheModule;
  ModuleProvider();

public:
  virtual ~ModuleProvider();

  /// getModule - returns the module this provider is encapsulating.
  ///
  Module* getModule() { return TheModule; }

  /// materializeFunction - make sure the given function is fully read.
  ///
  virtual void materializeFunction(Function *F) = 0;

  /// materializeModule - make sure the entire Module has been completely read.
  ///
  void materializeModule();

  /// releaseModule - no longer delete the Module* when provider is destroyed.
  ///
  virtual Module* releaseModule() {
    // Since we're losing control of this Module, we must hand it back complete
    materializeModule();
    Module *tempM = TheModule;
    TheModule = 0;
    return tempM;
  }
};

#endif

//===-- llvm/ModuleProvider.h - Interface for module providers --*- C++ -*-===//
//
// This file provides an abstract interface for loading a module from some
// place.  This interface allows incremental or random access loading of
// functions from the file.  This is useful for applications like JIT compilers
// or interprocedural optimizers that do not need the entire program in memory
// at the same time.
//
//===----------------------------------------------------------------------===//

#ifndef MODULEPROVIDER_H
#define MODULEPROVIDER_H

class Function;
class Module;

class ModuleProvider {
protected:
  Module *TheModule;
  ModuleProvider();

public:
  virtual ~ModuleProvider();

  /// getModule - returns the module this provider is encapsulating.
  ///
  Module* getModule() { return TheModule; }

  /// materializeFunction - make sure the given function is fully read.
  ///
  virtual void materializeFunction(Function *F) = 0;

  /// materializeModule - make sure the entire Module has been completely read.
  ///
  Module* materializeModule();

  /// releaseModule - no longer delete the Module* when provider is destroyed.
  ///
  virtual Module* releaseModule() {
    // Since we're losing control of this Module, we must hand it back complete
    materializeModule();
    Module *tempM = TheModule;
    TheModule = 0;
    return tempM;
  }
};

#endif

Return the Module being materialized to avoid always calling getModule().

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


/* Copyright [2013-2018] [Aaron Springstroh, Minimal Graphics Library]

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

#if defined(_WIN32)

#include <min/win32_window.h>

namespace min
{
using window = min::win32_window;
}

#elif __linux__

#include <min/x_window.h>

namespace min
{
using window = min::x_window;
}

#endif

#endif

/* Copyright [2013-2018] [Aaron Springstroh, Minimal Graphics Library]

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

#if defined(_WIN32)

#include <min/win32_window.h>

namespace min
{
using window = min::win32_window;
}

#else

#include <min/x_window.h>

namespace min
{
using window = min::x_window;
}

#endif

#endif

MGL: Allow other operating systems that use X11 to use it


/*
 * Copyright (C) 2006 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 __CUTILS_PROPERTIES_H
#define __CUTILS_PROPERTIES_H

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

#ifdef __cplusplus
extern "C" {
#endif

#define PROPERTY_KEY_MAX   32
#define PROPERTY_VALUE_MAX  92

/* property_get: returns the length of the value which will never be
** greater than PROPERTY_VALUE_MAX - 1 and will always be zero terminated.
** (the length does not include the terminating zero).
**
** If the property read fails or returns an empty value, the default
** value is used (if nonnull).
*/
static inline int property_get(const char *key, char *value,
						const char *default_value)
{
	const char *env;

	env = getenv(key);
	if (!env)
		env = default_value;

	if (!value || !env)
		return 0;

	strncpy(value, env, PROPERTY_VALUE_MAX);

	return strlen(value);
}

/* property_set: returns 0 on success, < 0 on failure
*/
static inline int property_set(const char *key, const char *value)
{
	return setenv(key, value, 0);
}

#ifdef __cplusplus
}
#endif

#endif

/*
 * Copyright (C) 2006 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 __CUTILS_PROPERTIES_H
#define __CUTILS_PROPERTIES_H

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

#ifdef __cplusplus
extern "C" {
#endif

/* property_set: returns 0 on success, < 0 on failure
*/
static inline int property_set(const char *key, const char *value)
{
	return setenv(key, value, 0);
}

#ifdef __cplusplus
}
#endif

#endif

android: Remove not needed property_get function form cutils stubs

This is no longer used as daemon indicates its presence by connecting
socket.


#include "../../libtock/tock.h"
#include <stdio.h>

#define IPC_DRIVER 0x4c

static void rot13_callback(int pid, int len, int arg2, void* ud) {
  char* buf = (char*)arg2;
  int length = buf[0];
  if (length > len - 1) {
    length = len - 1;
  }
  buf++;
  for (int i = 0; i < len; ++i) {
    if (buf[i] >= 'a' && buf[i] <= 'z') {
      buf[i] = (((buf[i] - 'a') + 13) % 26) + 'a';
    } else if (buf[i] >= 'A' && buf[i] <= 'Z') {
      buf[i] = (((buf[i] - 'A') + 13) % 26) + 'A';
    }
  }
  command(IPC_DRIVER, pid, 0);
}

int main() {
  subscribe(IPC_DRIVER, 0, rot13_callback, 0);
  while (1) {
    yield();
  }
  return 0;
}

#include <tock.h>

#define IPC_DRIVER 0x4c

struct rot13_buf {
  int8_t length;
  char buf[31];
};

static void rot13_callback(int pid, int len, int buf, void* ud) {
  struct rot13_buf *rb = (struct rot13_buf*)buf;
  int length = rb->length;
  if (length > len - 1) {
    length = len - 1;
  }
  for (int i = 0; i < length; ++i) {
    if (rb->buf[i] >= 'a' && rb->buf[i] <= 'z') {
      rb->buf[i] = (((rb->buf[i] - 'a') + 13) % 26) + 'a';
    } else if (rb->buf[i] >= 'A' && rb->buf[i] <= 'Z') {
      rb->buf[i] = (((rb->buf[i] - 'A') + 13) % 26) + 'A';
    }
  }
  command(IPC_DRIVER, pid, 0);
}

int main() {
  subscribe(IPC_DRIVER, 0, rot13_callback, NULL);
  return 0;
}

Enforce IPC data sharing with MPU

Enforce IPC data sharing with MPU

Still pretty coarsely written but exposes only the shared buffer from a
client when enqueuing the callback to a service.


#include <libsccmn.h>
#include <openssl/rand.h>
#include <sys/mman.h>

#define FRAME_SIZE (3*4096)
#define MEMPAGE_SIZE (4096)

void _logging_init(void);

void _frame_init(struct frame * this, uint8_t * data, size_t capacity, struct frame_pool_zone * zone);

#include <libsccmn.h>
#include <openssl/rand.h>
#include <sys/mman.h>

// Frame size should be above 16kb, which is a maximum record size of 16kB for SSLv3/TLSv1
// See https://www.openssl.org/docs/manmaster/ssl/SSL_read.html
#define FRAME_SIZE (5*4096)
#define MEMPAGE_SIZE (4096)

void _logging_init(void);

void _frame_init(struct frame * this, uint8_t * data, size_t capacity, struct frame_pool_zone * zone);

Increase the size of the memory pool frame