/* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */

/**********************************************************
*      This software is part of the graphviz package      *
*                http://www.graphviz.org/                 *
*                                                         *
*            Copyright (c) 1994-2004 AT&T Corp.           *
*                and is licensed under the                *
*            Common Public License, Version 1.0           *
*                      by AT&T Corp.                      *
*                                                         *
*        Information and Software Systems Research        *
*              AT&T Research, Florham Park NJ             *
**********************************************************/

#ifdef __cplusplus
extern "C" {
#endif

#ifndef POLY_H
#define POLY_H

#include "geometry.h"

    typedef struct {
	Point origin;
	Point corner;
	int nverts;
	Point *verts;
	int kind;
    } Poly;

    extern void polyFree(void);
    extern int polyOverlap(Point, Poly *, Point, Poly *);
    extern void makePoly(Poly *, Agnode_t *, double);
    extern void breakPoly(Poly *);

#endif

#ifdef __cplusplus
}
#endif

/* $Id$ $Revision$ */
/* vim:set shiftwidth=4 ts=8: */

/**********************************************************
*      This software is part of the graphviz package      *
*                http://www.graphviz.org/                 *
*                                                         *
*            Copyright (c) 1994-2004 AT&T Corp.           *
*                and is licensed under the                *
*            Common Public License, Version 1.0           *
*                      by AT&T Corp.                      *
*                                                         *
*        Information and Software Systems Research        *
*              AT&T Research, Florham Park NJ             *
**********************************************************/

#ifdef __cplusplus
extern "C" {
#endif

#ifndef POLY_H
#define POLY_H

#include "geometry.h"

    typedef struct {
	Point origin;
	Point corner;
	int nverts;
	Point *verts;
	int kind;
    } Poly;

    extern void polyFree(void);
    extern int polyOverlap(Point, Poly *, Point, Poly *);
    extern void makePoly(Poly *, Agnode_t *, float, float);
    extern void makeAddPoly(Poly *, Agnode_t *, float, float);
    extern void breakPoly(Poly *);

#endif

#ifdef __cplusplus
}
#endif

Fix the sep and esep attributes to allow additive margins in addition to scaled margins.


/* internal.h

   Internal definitions used by Expat.  This is not needed to compile
   client code.

   The following definitions are made:

   FASTCALL -- Used for most internal functions to specify that the
               fastest possible calling convention be used.

   inline   -- Used for selected internal functions for which inlining
               may improve performance on some platforms.
*/

#if defined(__GNUC__)
#define FASTCALL __attribute__((stdcall, regparm(3)))
#elif defined(WIN32)
#define FASTCALL __fastcall
#else
#define FASTCALL
#endif

#ifndef XML_MIN_SIZE
#if !defined(__cplusplus) && !defined(inline)
#ifdef __GNUC__
#define inline __inline
#endif /* __GNUC__ */
#endif
#endif /* XML_MIN_SIZE */

#ifdef __cplusplus
#define inline inline
#else
#ifndef inline
#define inline
#endif
#endif

/* internal.h

   Internal definitions used by Expat.  This is not needed to compile
   client code.

   The following definitions are made:

   FASTCALL -- Used for most internal functions to specify that the
               fastest possible calling convention be used.

   inline   -- Used for selected internal functions for which inlining
               may improve performance on some platforms.
*/

#if defined(__GNUC__)
#define FASTCALL __attribute__((stdcall, regparm(3)))
#elif defined(WIN32)
/* XXX This seems to have an unexpected negative effect on Windows so
   we'll disable it for now on that platform.  It may be reconsidered
   for a future release if it can be made more effective.
*/
/* #define FASTCALL __fastcall */
#endif

#ifndef FASTCALL
#define FASTCALL
#endif

#ifndef XML_MIN_SIZE
#if !defined(__cplusplus) && !defined(inline)
#ifdef __GNUC__
#define inline __inline
#endif /* __GNUC__ */
#endif
#endif /* XML_MIN_SIZE */

#ifdef __cplusplus
#define inline inline
#else
#ifndef inline
#define inline
#endif
#endif

Disable FASTCALL on Windows since it turned out not to be as effective as hoped. Leaving the definition in the file so we'll know what it was that didn't work, and hopefully find something better in the future.


// SKIP PARAM:  --sets ana.activated[+] var_eq --sets ana.activated[+] region --sets ana.activated[+] var_eq --enable exp.region-offsets
#include <pthread.h>

int data[10];
pthread_mutex_t mutexes[10];

void safe_inc(int i) {
  pthread_mutex_lock(&mutexes[i]);
  data[i]++; // RACE
  pthread_mutex_unlock(&mutexes[i]);
}

void *t_fun(void *arg) {
  safe_inc(3);
  safe_inc(4);
  return NULL;
}

int main() {
  for (int i = 0; i < 10; i++)
    pthread_mutex_init(&mutexes[i], NULL);

  // Create thread
  pthread_t id;
  pthread_create(&id, NULL, t_fun, NULL);

  pthread_mutex_lock(&mutexes[4]);
  data[3]++; // RACE
  data[4]++; // NORACE
  pthread_mutex_unlock(&mutexes[4]);

  return 0;
}

Add example from website as skipped test


#include <winsock2.h>
#include <assert.h>

#define sassert assert

void dump() {
	int err;
	LPTSTR buf;
	err = WSAGetLastError();
	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, &buf, 0, NULL);
	printf("%d %s\n", err, buf);
	LocalFree(buf);
}

int main() {
	SOCKET s1, s2, s1d, s2d;
	int val, rv, size;
	WSADATA wsadata;
	WSAPROTOCOL_INFO pi;

	rv = WSAStartup(MAKEWORD(2, 2), &wsadata);
	assert(!rv);

	s1 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	assert(s1 > 0);
	val = 1;
	rv = setsockopt(s1, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
	dump();
	sassert(!rv);

	s2 = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	assert(s2 > 0);
	val = 0;
	rv = setsockopt(s2, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
	sassert(!rv);

	size = sizeof(val);
	rv = getsockopt(s1, SOL_SOCKET, SO_KEEPALIVE, &val, &size);
	assert(!rv);
	printf("%d\n", val);
	sassert(val == 1);

	rv = getsockopt(s2, SOL_SOCKET, SO_KEEPALIVE, &val, &size);
	assert(!rv);
	sassert(val == 0);

	rv = WSADuplicateSocket(s1, GetCurrentProcessId(), &pi);
	assert(!rv);
	s1d = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, &pi, 0, WSA_FLAG_OVERLAPPED);
	assert(s1d > 0);

	rv = getsockopt(s1d, SOL_SOCKET, SO_KEEPALIVE, &val, &size);
	assert(!rv);
	printf("%d\n", val);
	sassert(val == 1);

	rv = WSADuplicateSocket(s2, GetCurrentProcessId(), &pi);
	assert(!rv);
	s2d = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, &pi, 0, WSA_FLAG_OVERLAPPED);
	assert(s2d > 0);

	rv = getsockopt(s2d, SOL_SOCKET, SO_KEEPALIVE, &val, &size);
	assert(!rv);
	printf("%d\n", val);
	sassert(val == 0);
}

Test program for duplicating sockets in windows


/*
-------------------------------------------------------------------------------
Name:
	FPL-Demo | Console
Description:
	A Hello-World Console Application testing Console Output/Input
Requirements:
	No requirements
Author:
	Torsten Spaete
Changelog:
	## 2018-04-23:
	- Initial creation of this description block
	- Changed from C++ to C99
	- Forced Visual-Studio-Project to compile in C always
	- Added read char input
-------------------------------------------------------------------------------
*/

#define FPL_IMPLEMENTATION
#define FPL_NO_WINDOW
#define FPL_NO_VIDEO
#define FPL_NO_AUDIO
#include <final_platform_layer.h>

int main(int argc, char *args[]) {
	if (fplPlatformInit(fplInitFlags_All, NULL)) {
		fplConsoleOut("Hello World\n");
		fplConsoleFormatOut("%s %s %d\n", "Hello", "World", 42);
		fplConsoleError("Error: Hello World!\n");
		fplConsoleFormatError("Error: %s %s %d!\n", "Hello", "World", 42);
		fplConsoleOut("Press enter a key: ");
		int key = fplConsoleWaitForCharInput();
		fplConsoleFormatOut("You pressed '%c'\n", key);
		fplPlatformRelease();
	}
	return 0;
}

/*
-------------------------------------------------------------------------------
Name:
	FPL-Demo | Console
Description:
	A Hello-World Console Application testing Console Output/Input
Requirements:
	No requirements
Author:
	Torsten Spaete
Changelog:
	## 2018-04-23:
	- Initial creation of this description block
	- Changed from C++ to C99
	- Forced Visual-Studio-Project to compile in C always
	- Added read char input
-------------------------------------------------------------------------------
*/

#define FPL_IMPLEMENTATION
#define FPL_NO_WINDOW
#define FPL_NO_VIDEO
#define FPL_NO_AUDIO
#include <final_platform_layer.h>

int main(int argc, char *args[]) {
	if (fplPlatformInit(fplInitFlags_All, fpl_null)) {
		fplConsoleOut("Hello World\n");
		fplConsoleFormatOut("%s %s %d\n", "Hello", "World", 42);
		fplConsoleError("Error: Hello World!\n");
		fplConsoleFormatError("Error: %s %s %d!\n", "Hello", "World", 42);
		fplConsoleOut("Press enter a key: ");
		int key = fplConsoleWaitForCharInput();
		fplConsoleFormatOut("You pressed '%c'\n", key);
		fplPlatformRelease();
	}
	return 0;
}

Use fpl_null instead of NULL in console demo


// RUN: %llvmgcc %s -S -o - | llvm-as | llvm-dis | grep llvm.used | grep foo | grep X

int X __attribute__((used));
int Y;

void foo() __attribute__((used));

void foo() {}

// RUN: %llvmgcc %s -S -emit-llvm -o - | llvm-as | llvm-dis | grep llvm.used | grep foo | grep X

int X __attribute__((used));
int Y;

void foo() __attribute__((used));

void foo() {}

Use the -emit-llvm switch to generate LLVM assembly that can be parsed
by the test case.

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


#ifndef FIBONACCI_H
#define FIBONACCI_H

#include "../function.h"

namespace BuiltIn {
namespace Optimization {

// Class for finding minimum of function with Fibonacci method
class Fibonacci : public Function
{
public:
	Fibonacci();

	Rpn::Operand calculate(FunctionCalculator *calculator, QList<Rpn::Operand> actualArguments);
	QList<Rpn::Argument> requiredArguments();
	Rpn::OperandType returnValueType();

private:
	struct Interval {
		Number leftBorder;
		Number rightBorder;
	};

	Interval m_sourceInterval;
	FunctionCalculator* m_calculator;
	QString m_functionName;
	Number m_resultIntervalLength;
	Number m_differenceConstant;
	Number m_iterationsNumber;

	Number findMinimum();
	void initializeIterationsNumber();
	Number fibonacciNumber(int position);
	Number calculateFunction(Number argument);
};

} // namespace
} // namespace

#endif // FIBONACCI_H

#ifndef FIBONACCI_H
#define FIBONACCI_H

#include "../function.h"

namespace BuiltIn {
namespace Optimization {

// Class for finding minimum of function with Fibonacci method
class Fibonacci : public Function
{
public:
	Fibonacci();

	Rpn::Operand calculate(FunctionCalculator *calculator, QList<Rpn::Operand> actualArguments);
	QList<Rpn::Argument> requiredArguments();
	Rpn::OperandType returnValueType();

private:
	struct Interval {
		Number leftBorder;
		Number rightBorder;
	};

	Interval m_sourceInterval;
	FunctionCalculator* m_calculator;
	QString m_functionName;
	Number m_resultIntervalLength;
	Number m_differenceConstant;
	int m_iterationsNumber;

	Number findMinimum();
	void initializeIterationsNumber();
	Number fibonacciNumber(int position);
	Number calculateFunction(Number argument);
};

} // namespace
} // namespace

#endif // FIBONACCI_H

Fix for impicit conversions from double to int and vise versa.


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

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

Update Skia milestone to 61

Update Skia milestone to 61

BUG=skia:

Change-Id: I9602ddb0f5a08481365e7c74f1fc93836f7e5080
Reviewed-on: https://skia-review.googlesource.com/17920
Reviewed-by: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>
Commit-Queue: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>


#ifndef CLIENTVERSION_H
#define CLIENTVERSION_H

//
// client versioning and copyright year
//

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

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

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

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

#endif // CLIENTVERSION_H

#ifndef CLIENTVERSION_H
#define CLIENTVERSION_H

//
// client versioning and copyright year
//

// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR       1
#define CLIENT_VERSION_MINOR       0
#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  false

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

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

#endif // CLIENTVERSION_H

Update client version number and set false for prerelease


/*
 * Copyright (c) 2010-2012 Petri Lehtinen <petri@digip.org>
 *
 * Jansson is free software; you can redistribute it and/or modify
 * it under the terms of the MIT license. See LICENSE for details.
 *
 *
 * This file specifies a part of the site-specific configuration for
 * Jansson, namely those things that affect the public API in
 * jansson.h.
 *
 * The configure script copies this file to jansson_config.h and
 * replaces @var@ substitutions by values that fit your system. If you
 * cannot run the configure script, you can do the value substitution
 * by hand.
 */

#ifndef JANSSON_CONFIG_H
#define JANSSON_CONFIG_H

/* If your compiler supports the inline keyword in C, JSON_INLINE is
   defined to `inline', otherwise empty. In C++, the inline is always
   supported. */
#ifdef __cplusplus
#define JSON_INLINE inline
#else
#define JSON_INLINE inline
#endif

/* If your compiler supports the `long long` type and the strtoll()
   library function, JSON_INTEGER_IS_LONG_LONG is defined to 1,
   otherwise to 0. */
#define JSON_INTEGER_IS_LONG_LONG 1

/* If locale.h and localeconv() are available, define to 1,
   otherwise to 0. */
#define JSON_HAVE_LOCALECONV 1

#endif

Add a file that was required for building jansson from CMake.


/**
 *  For conditions of distribution and use, see copyright notice in license.txt
 *
 *  @file   WorldLogicInterface.h
 *  @brief
 */

#include "ServiceInterface.h"

#ifndef incl_Interfaces_WorldLogicInterface_h
#define incl_Interfaces_WorldLogicInterface_h

#include "ForwardDefines.h"

#include <QObject>

class QString;

namespace Foundation
{
    class WorldLogicInterface : public QObject, public ServiceInterface
    {
        Q_OBJECT

    public:
        /// Default constructor.
        WorldLogicInterface() {}

        /// Destructor.
        virtual ~WorldLogicInterface() {}

        /// Returns user's avatar entity.
        virtual Scene::EntityPtr GetUserAvatarEntity() const = 0;

        /// Returns currently active camera entity.
        virtual Scene::EntityPtr GetCameraEntity() const = 0;

        /// Returns entity with certain entity component in it or null if not found.
        /// @param entity_id Entity ID.
        /// @param component Type name of the component.
        virtual Scene::EntityPtr GetEntityWithComponent(uint entity_id, const QString &component) const = 0;

        /// Hack function for getting EC_AvatarAppearance info to UiModule
        virtual const QString &GetAvatarAppearanceProperty(const QString &name) const = 0;

    signals:
        /// Emitted just before we start to delete world (scene).
        void AboutToDeleteWorld();
    };
}

#endif

/**
 *  For conditions of distribution and use, see copyright notice in license.txt
 *
 *  @file   WorldLogicInterface.h
 *  @brief
 */

#ifndef incl_Interfaces_WorldLogicInterface_h
#define incl_Interfaces_WorldLogicInterface_h

#include "ServiceInterface.h"
#include "ForwardDefines.h"

#include <QObject>

class QString;

namespace Foundation
{
    class WorldLogicInterface : public QObject, public ServiceInterface
    {
        Q_OBJECT

    public:
        /// Default constructor.
        WorldLogicInterface() {}

        /// Destructor.
        virtual ~WorldLogicInterface() {}

        /// Returns user's avatar entity.
        virtual Scene::EntityPtr GetUserAvatarEntity() const = 0;

        /// Returns currently active camera entity.
        virtual Scene::EntityPtr GetCameraEntity() const = 0;

        /// Returns entity with certain entity component in it or null if not found.
        /// @param entity_id Entity ID.
        /// @param component Type name of the component.
        virtual Scene::EntityPtr GetEntityWithComponent(uint entity_id, const QString &component) const = 0;

        /// Hack function for getting EC_AvatarAppearance info to UiModule
        virtual const QString &GetAvatarAppearanceProperty(const QString &name) const = 0;

    signals:
        /// Emitted just before we start to delete world (scene).
        void AboutToDeleteWorld();
    };
}

#endif

Move include within include guards.

Move include within include guards.


#ifndef lilthumb
#define lilthumb

#include <ctime>
namespace lilthumb{
std::string timeString()
{
  time_t rawtime;
  struct tm * timeinfo;
  char buffer[80];

  time (&rawtime);
  timeinfo = localtime(&rawtime);

  strftime(buffer,80,"%d-%m-%Y %I:%M:%S",timeinfo);
  std::string str(buffer);

  return str;
}
}

#define logger(message) std::cerr << lilthumb::timeString() << " | "<< message << std::endl;
#endif

#ifndef lilthumb
#define lilthumb

#include <ctime>
namespace lilthumb{

std::string timeString()
{
  time_t rawtime;
  struct tm * timeinfo;
  char buffer[80];

  time (&rawtime);
  timeinfo = localtime(&rawtime);

  strftime(buffer,80,"%d-%m-%Y %I:%M:%S",timeinfo);
  std::string str(buffer);

  return str;
}
}

#define logger(stream,message) stream << lilthumb::timeString() << " | "<< message << std::endl;
#endif

Change macro to let user choose output stream


#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <exec/execbase.h>
#include <graphics/gfxbase.h>

#include "system/check.h"

bool SystemCheck() {
  bool kickv40 = SysBase->LibNode.lib_Version >= 40;
  bool chipaga = GfxBase->ChipRevBits0 & (GFXF_AA_ALICE|GFXF_AA_LISA);
  bool cpu68040 = SysBase->AttnFlags & AFF_68040;
  bool fpu68882 = SysBase->AttnFlags & AFF_68882;

  Printf("System check:\n");
  Printf(" - Kickstart v40 : %s\n", (ULONG)(kickv40 ? "yes" : "no"));
  Printf(" - ChipSet AGA : %s\n", (ULONG)(chipaga ? "yes" : "no"));
  Printf(" - CPU 68040 : %s\n", (ULONG)(cpu68040 ? "yes" : "no"));
  Printf(" - FPU 68882 : %s\n", (ULONG)(fpu68882 ? "yes" : "no"));

  return (kickv40 && cpu68040 && fpu68882 && chipaga);
}

#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <exec/execbase.h>
#include <graphics/gfxbase.h>

#include "system/check.h"

bool SystemCheck() {
  bool kickv40 = SysBase->LibNode.lib_Version >= 40;
  bool chipaga = GfxBase->ChipRevBits0 & (GFXF_AA_ALICE|GFXF_AA_LISA);
  bool cpu68040 = SysBase->AttnFlags & AFF_68040;
  bool fpu68882 = SysBase->AttnFlags & AFF_68882;

  Printf("System check:\r\n");
  Printf(" - Kickstart v40 : %s\r\n", (ULONG)(kickv40 ? "yes" : "no"));
  Printf(" - ChipSet AGA : %s\r\n", (ULONG)(chipaga ? "yes" : "no"));
  Printf(" - CPU 68040 : %s\r\n", (ULONG)(cpu68040 ? "yes" : "no"));
  Printf(" - FPU 68882 : %s\r\n", (ULONG)(fpu68882 ? "yes" : "no"));

  return (kickv40 && cpu68040 && fpu68882 && chipaga);
}

Break lines properly on serial console.

Break lines properly on serial console.


#pragma once

#include "Jitter.h"

#define TEST_VERIFY(a) if(!(a)) { int* p = 0; (*p) = 0; }

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

	virtual void	Run()						= 0;
	virtual void	Compile(Jitter::CJitter&)	= 0;

#ifdef _MSC_VER

	//Overload operator new and delete to make sure we get proper 16-byte aligned structures
	//C++11 has support for aligned struct/classes, but VC++2013 doesn't support them

	void* operator new(size_t allocSize)
	{
		return _aligned_malloc(allocSize, 16);
	}

	void operator delete(void* ptr)
	{
		_aligned_free(ptr);
	}

#endif
};

#pragma once

#include "AlignedAlloc.h"
#include "Jitter.h"

#define TEST_VERIFY(a) if(!(a)) { int* p = 0; (*p) = 0; }

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

	virtual void	Run()						= 0;
	virtual void	Compile(Jitter::CJitter&)	= 0;

	void* operator new(size_t allocSize)
	{
		return framework_aligned_alloc(allocSize, 0x10);
	}

	void operator delete(void* ptr)
	{
		framework_aligned_free(ptr);
	}
};

Use aligned alloc for test allocation.

Use aligned alloc for test allocation.


// ---------------------------------------------------------------------
//
// Copyright (C) 1998 - 2015 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, 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.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------

#ifndef dealii__tensor_accessors_h
#define dealii__tensor_accessors_h

#include <deal.II/base/config.h>
#include <deal.II/base/template_constraints.h>
#include <deal.II/base/table_indices.h>

DEAL_II_NAMESPACE_OPEN

/**
 * This namespace is a collection of algorithms working on generic
 * tensorial objects (of arbitrary rank).
 *
 * The rationale to implement such functionality in a generic fashion in a
 * separate namespace is
 *  - to easy code reusability and therefore avoid code duplication.
 *  - to have a well-defined interface that allows to exchange the low
 *    level implementation.
 *
 *
 * A tensorial object has the notion of a rank and allows a rank-times
 * recursive application of the index operator, e.g., if t is
 * a tensorial object of rank 4, the following access is valid:
 * @code
 *   t[1][2][1][4]
 * @endcode
 *
 * deal.II has its own implementation for tensorial objects such as
 * dealii::Tensor<rank, dim, Number> and
 * dealii::SymmetricTensor<rank, dim, Number>
 *
 * The methods and algorithms implemented in this namespace, however, are
 * fully generic. More precisely, it can operate on nested c-style arrays,
 * or on class types T with a minimal interface that provides
 * a local typedef value_type and an index operator
 * operator[](unsigned int) that returns a (const or
 * non-const) reference of value_type:
 * @code
 *   template<...>
 *   class T
 *   {
 *     typedef ... value_type;
 *     value_type & operator[](unsigned int);
 *     const value_type & operator[](unsigned int) const;
 *   };
 * @endcode
 *
 * This namespace provides primitves for access, reordering and contraction
 * of such objects.
 *
 * @ingroup geomprimitives
 */
namespace TensorAccessors
{

} /* namespace TensorAccessors */

DEAL_II_NAMESPACE_CLOSE

#endif /* dealii__tensor_accessors_h */

Add a new namespace TensorAccessors

Add a new namespace TensorAccessors

This namespace will contain a collection of algorithms working on generic
tensorial objects (of arbitrary rank).

The rationale to implement such functionality in a generic fashion in a
separate namespace is
 - to easy code reusability and therefore avoid code duplication.
 - to have a well-defined interface that allows to exchange the low
   level implementation.


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

#include "calc.h"
#include "input.h"

int main(void)
{
    while (1){
        char input[65536];
        double ans;

        read_line(input);
        if (strcmp(input, "exit") == 0 || strcmp(input, "quit") == 0){
            break;
        }
        ans = calc(input, 0);
        if (floor(ans) == ans){
            printf("%.0f\n", ans);
        }
        else{
            printf("%f\n", calc(input, 0));
        }
    }

    return (0);
}

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

#include "calc.h"
#include "input.h"

int main(void)
{
    while (1){
        char input[65536];
        double ans;

        read_line(input);
        if (strlen(input) == 0 || strcmp(input, "exit") == 0 || strcmp(input, "quit") == 0){
            break;
        }
        ans = calc(input, 0);
        if (floor(ans) == ans){
            printf("%.0f\n", ans);
        }
        else{
            printf("%f\n", calc(input, 0));
        }
    }

    return (0);
}

Exit when input line is empty

Exit when input line is empty


#include <stdio.h>
#include <float.h>

int
main(int argc, char *argv[])
{
  char *me;
  float qnan, zero;
  int i;

  me = argv[0];
  if (sizeof(float) != sizeof(int))
    {
    fprintf(stderr, "%s: MADNESS:  sizeof(float)=%d != sizeof(int)=%d\n",
            me, (int)sizeof(float), (int)sizeof(int));
    return -1;
    }

  zero = 0;
  qnan=zero/zero;
  i=*(int*)(&qnan);
  printf("-DTEEM_QNANHIBIT=%d\n", (i >> 22) & 1);
  return (int)((i >> 22) & 1);
}

#include <stdio.h>
#include <float.h>

#if defined(__BORLANDC__)
# include <math.h>
# include <float.h>
#endif

int
main(int argc, char *argv[])
{
#if defined(__BORLANDC__)
  // Disable floating point exceptions in Borland
  _control87(MCW_EM, MCW_EM);
#endif // defined(__BORLANDC__)

  char *me;
  float qnan, zero;
  int i;

  me = argv[0];
  if (sizeof(float) != sizeof(int))
    {
    fprintf(stderr, "%s: MADNESS:  sizeof(float)=%d != sizeof(int)=%d\n",
            me, (int)sizeof(float), (int)sizeof(int));
    return -1;
    }

  zero = 0;
  qnan=zero/zero;
  i=*(int*)(&qnan);
  printf("-DTEEM_QNANHIBIT=%d\n", (i >> 22) & 1);
  return (int)((i >> 22) & 1);
}

FIX: Disable floating point exceptions on Borland compiler


/** \file choices.h switches that control debugging in source code.
 *  Uncomment the defines below to allow a specific type of compilation
 */

#ifndef __choices_h__
#define __choices_h__

/** Turn on YACAS_DEBUG if you want to see run-time statistics
 * after typing Exit()
 */
//#define YACAS_DEBUG

/** Turn on USE_ASSERT to find programming errors through the asserts
 *  placed in various places of the application.
 */
//#define USE_ASSERT

/** Turn on NO_EXCEPTIONS if you want to disable run-time checking
 *  while executing commands.
 */
//#define NO_EXCEPTIONS

/** Enable long reference counts. This makes EVERY object 2 bytes
 larger, so use only if needed.
 */
//#define USE_LONG_REF_COUNTS

#endif

/** \file choices.h switches that control debugging in source code.
 *  Uncomment the defines below to allow a specific type of compilation
 */

#ifndef __choices_h__
#define __choices_h__

/** Turn on YACAS_DEBUG if you want to see run-time statistics
 * after typing Exit()
 */
//#define YACAS_DEBUG

/** Turn on USE_ASSERT to find programming errors through the asserts
 *  placed in various places of the application.
 */
//#define USE_ASSERT

/** Turn on NO_EXCEPTIONS if you want to disable run-time checking
 *  while executing commands.
 */
//#define NO_EXCEPTIONS

/** Enable long reference counts. This makes EVERY object 2 bytes
 larger, so use only if needed.
 */
#define USE_LONG_REF_COUNTS

#endif

Use at least 32 bits long reference counters by default to avoid nasty, hard to track segfaults when calculations get larger


#include <ugens.h>
#include <stdio.h>

/* these 3 defined in makegen.c */
extern double *farrays[];
extern int sizeof_farray[];
extern int f_goto[];

int
fsize(int genno)
/*   returns the size of function number genno */
{
	if(!sizeof_farray[f_goto[genno]]) {
	       fprintf(stderr,"fsize: You haven't allocated function %d yet!\n",genno);
		closesf();
	}
	return(sizeof_farray[f_goto[genno]]);
}

#include <ugens.h>
#include <stdio.h>

/* these 3 defined in makegen.c */
extern double *farrays[];
extern int sizeof_farray[];
extern int f_goto[];

/*   returns the size of function number genno */
int
fsize(int genno)
{
	if (!sizeof_farray[f_goto[genno]]) {
		die("fsize", "You haven't allocated function %d yet!", genno);
		return -1;
	}
	return sizeof_farray[f_goto[genno]];
}

Use die and return instead of exiting.

Use die and return instead of exiting.


/*
 * Copyright 2020 The Any Sketch Authors
 *
 * 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 SRC_MAIN_CC_ANY_SKETCH_UTIL_MACROS_H_
#define SRC_MAIN_CC_ANY_SKETCH_UTIL_MACROS_H_

#define RETURN_IF_ERROR(status)        \
  do {                                 \
    Status _status = (status);         \
    if (!_status.ok()) return _status; \
  } while (0)

#endif  // SRC_MAIN_CC_ANY_SKETCH_UTIL_MACROS_H_

Add LICENSE and source headers to any-sketch repo.

BUG=161899344
Change-Id: I201d5420c80f9e16b6832c1bc31adf6ca6ab8cb1


#ifndef PHP_SHMT_H
	#define PHP_SHMT_H

	#define PHP_SHMT_EXTNAME	"SHMT"
	#define PHP_SHMT_EXTVER		"1.0"

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

	extern zend_module_entry shmt_module_entry;
	#define phpext_shmt_ptr &shmt_module_entry;

#endif /* PHP_SHMT_H */

#ifndef PHP_SHMT_H
	#define PHP_SHMT_H

	#define PHP_SHMT_EXTNAME	"SHMT"
	#define PHP_SHMT_EXTVER		"1.0.1dev"

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

	extern zend_module_entry shmt_module_entry;
	#define phpext_shmt_ptr &shmt_module_entry;

#endif /* PHP_SHMT_H */

Modify the SHMT version to 1.0.1dev

Modify the SHMT version to 1.0.1dev


#pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_

#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
#include "transaction.h"

namespace You {
namespace DataStore {
namespace UnitTests {}

class DataStore {
	friend class Transaction;
public:
	Transaction&& begin();

	// Modifying methods
	static bool post(TaskId, SerializedTask&);
	static bool put(TaskId, SerializedTask&);
	static bool erase(TaskId);

	static std::vector<SerializedTask> getAllTask();

private:
	static DataStore& get();
	bool isServing = false;
	std::deque<Internal::IOperation> operationsQueue;
};
}  // namespace DataStore
}  // namespace You
#endif  // YOU_DATASTORE_DATASTORE_H_

#pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_

#include <deque>
#include <functional>
#include "boost/variant.hpp"
#include "task_typedefs.h"
#include "internal/operation.h"
#include "transaction.h"

namespace You {
namespace DataStore {
namespace UnitTests {}

class DataStore {
	friend class Transaction;
public:
	Transaction&& begin();

	// Modifying methods
	bool post(TaskId, SerializedTask&);
	bool put(TaskId, SerializedTask&);
	bool erase(TaskId);

	std::vector<SerializedTask> getAllTask();

private:
	static DataStore& get();
	bool isServing = false;
	std::deque<Internal::IOperation> operationsQueue;
};
}  // namespace DataStore
}  // namespace You
#endif  // YOU_DATASTORE_DATASTORE_H_

Change methods in DataStore to non-static anymore (it is alr a singleton)


/*
 * This file is part of buxton.
 *
 * Copyright (C) 2013 Intel Corporation
 *
 * buxton 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.
 */

#pragma once

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

#include "buxton.h"
#include "buxtonstring.h"

/**
 * Represents a data key in Buxton
 */
typedef struct BuxtonKey {
	BuxtonString group; /**<Value of the key's group */
	BuxtonString name; /**<Value of the key's name */
	BuxtonString layer; /**<Value of the key's layer */
	BuxtonDataType type; /**<Type of value associated with key */
} _BuxtonKey;

/*
 * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 *
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
 * :indentSize=8:tabSize=8:noTabs=false:
 */

shared: Add internal representation of a BuxtonKey

Keys will represent a single item identifying a value in buxton. The
key can contain any data needed to reference a value.


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

int main(int argc, char **argv) {
  const int sample = 10000;
  size_t size = sample * sizeof(int);
  int *restrict a1, *restrict a2, *restrict a3;
  a1 = (int*) malloc(size);
  a2 = (int*) malloc(size);
  a3 = (int*) malloc(size);
  int sum = 0;
  int i;
  #pragma acc data create(i, a1[0:sample], a2[0:sample], a3[0:sample]), copyin(sample), copy(sum)
  {
    #pragma acc parallel loop
    for (i = 0; i < sample; ++i) {
      a1[i] = a2[i] = 1;
    }

    #pragma acc parallel loop
    for (i = 0; i < sample; ++i) {
      a3[i] = a1[i] + a2[i];
    }

    #pragma acc parallel loop reduction(+:sum)
    for (i = 0; i < sample; ++i) {
      sum += a3[i];
    }
  }

  free(a1);
  free(a2);
  free(a3);

  printf("Sample size: %d | Sum: %d\n", sample, sum);
}

Add a more elaborate example of acc computation.


#include <gtk/gtk.h>

static void
test_type (GType t)
{
  GtkWidget *w;
  AtkObject *a;

  if (g_type_is_a (t, GTK_TYPE_WIDGET))
    {
      w = (GtkWidget *)g_object_new (t, NULL);
      a = gtk_widget_get_accessible (w);

      g_assert (GTK_IS_ACCESSIBLE (a));
      g_assert (gtk_accessible_get_widget (GTK_ACCESSIBLE (a)) == w);

      g_object_unref (w);
    }
}

int
main (int argc, char *argv[])
{
  GType *tp;
  gint i;

  gtk_init (&argc, &argv);

  tp = g_new0 (GType, 1000);
#undef GDK_WINDOWING_X11
#include "../gtktypefuncs.c"
  *tp = 0;

  for (i = 0; tp[i]; i++)
    test_type (tp[i]);

  return 0;
}

#include <gtk/gtk.h>

static void
test_type (GType t)
{
  GtkWidget *w;
  AtkObject *a;

  if (g_type_is_a (t, GTK_TYPE_WIDGET))
    {
      w = (GtkWidget *)g_object_new (t, NULL);
      a = gtk_widget_get_accessible (w);

      g_assert (GTK_IS_ACCESSIBLE (a));
      g_assert (gtk_accessible_get_widget (GTK_ACCESSIBLE (a)) == w);

      g_object_unref (w);
    }
}

int
main (int argc, char *argv[])
{
  const GType *tp;
  guint i, n;

  gtk_init (&argc, &argv);

  tp = gtk_test_list_all_types (&n);

  for (i = 0; i < n; n++)
    test_type (tp[i]);

  return 0;
}

tests: Use testing API instead of duplicating it


/*
 * This file is part of Kotaka, a mud library for DGD
 * http://github.com/shentino/kotaka
 *
 * Copyright (C) 2012  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/>.
 */
#include <kotaka/log.h>
#include <kotaka/paths.h>

inherit LIB_INITD;
inherit UTILITY_COMPILE;

static void create()
{
	LOGD->post_message("test", LOG_DEBUG, "Test subsystem loading...");

	load_dir("obj", 1);
	load_dir("sys", 1);

	LOGD->post_message("test", LOG_DEBUG, "Test subsystem loaded");
}

/*
 * This file is part of Kotaka, a mud library for DGD
 * http://github.com/shentino/kotaka
 *
 * Copyright (C) 2012  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/>.
 */
#include <kotaka/log.h>
#include <kotaka/paths.h>

inherit LIB_INITD;
inherit UTILITY_COMPILE;

static void create()
{
	KERNELD->set_global_access("Test", 1);

	LOGD->post_message("test", LOG_DEBUG, "Test subsystem loading...");

	load_dir("obj", 1);
	load_dir("sys", 1);

	LOGD->post_message("test", LOG_DEBUG, "Test subsystem loaded");
}

Add global access to test subsystem

Add global access to test subsystem


//
//  SMViewController.h
//  SMPageControl
//
//  Created by Jerry Jones on 10/13/12.
//  Copyright (c) 2012 Spaceman Labs. All rights reserved.
//

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

@interface SMViewController : UIViewController

@property (nonatomic, readonly) IBOutlet UIScrollView *scrollview;
@property (nonatomic, readonly) IBOutlet UIPageControl *pageControl;
@property (nonatomic, readonly) IBOutlet SMPageControl *spacePageControl1;
@property (nonatomic, readonly) IBOutlet SMPageControl *spacePageControl2;
@property (nonatomic, readonly) IBOutlet SMPageControl *spacePageControl3;
@property (nonatomic, readonly) IBOutlet SMPageControl *spacePageControl4;
@property (nonatomic, readonly) IBOutlet SMPageControl *spacePageControl5;
@property (nonatomic, readonly) IBOutlet SMPageControl *spacePageControl6;
@property (nonatomic, readonly) IBOutlet SMPageControl *spacePageControl7;
@property (nonatomic, readonly) IBOutlet SMPageControl *spacePageControl8;

@end

//
//  SMViewController.h
//  SMPageControl
//
//  Created by Jerry Jones on 10/13/12.
//  Copyright (c) 2012 Spaceman Labs. All rights reserved.
//

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

@interface SMViewController : UIViewController

@property (nonatomic, weak) IBOutlet UIScrollView *scrollview;
@property (nonatomic, weak) IBOutlet UIPageControl *pageControl;
@property (nonatomic, weak) IBOutlet SMPageControl *spacePageControl1;
@property (nonatomic, weak) IBOutlet SMPageControl *spacePageControl2;
@property (nonatomic, weak) IBOutlet SMPageControl *spacePageControl3;
@property (nonatomic, weak) IBOutlet SMPageControl *spacePageControl4;
@property (nonatomic, weak) IBOutlet SMPageControl *spacePageControl5;
@property (nonatomic, weak) IBOutlet SMPageControl *spacePageControl6;
@property (nonatomic, weak) IBOutlet SMPageControl *spacePageControl7;
@property (nonatomic, weak) IBOutlet SMPageControl *spacePageControl8;

@end

Change IBOutlet attributes from readonly to weak

This fixes the warning "readonly IBOutlet property when auto-synthesized may not work correctly with 'nib' loader".

Also, weak is better than assign when using weak references to objects, because weak prevents dangling pointers.


/** @file
  Header file that supports Framework extension to UEFI/PI for DXE modules.

  This header file must include Framework extension definitions common to DXE
  modules.

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

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

  Module Name:    FrameworkDxe.h

**/

#ifndef _FRAMEWORK_DXE_H_
#define _FRAMEWORK_DXE_H_

#include <FrameworkPei.h>

#include <Framework/DxeCis.h>

#include <Framework/FrameworkInternalFormRepresentation.h>

#endif

/** @file
  Header file that supports Framework extension to UEFI/PI for DXE modules.

  This header file must include Framework extension definitions common to DXE
  modules.

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

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

#ifndef _FRAMEWORK_DXE_H_
#define _FRAMEWORK_DXE_H_

#include <FrameworkPei.h>

#include <Framework/DxeCis.h>

#include <Framework/FrameworkInternalFormRepresentation.h>

#endif

Update Copyright. Delete erroneous "Module Name" line.

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


//
// This file is part of the Marble Desktop Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2006-2007 Torsten Rahn <tackat@kde.org>
// Copyright 2007      Inge Wallin  <ingwa@kde.org>
//

#ifndef MARBLE_LOCALE_H
#define MARBLE_LOCALE_H

#include "marble_export.h"
#include "global.h"

namespace Marble
{

class MarbleLocalePrivate;

/**
 * @short A class that contains all localization stuff for Marble.
 *
 * The class stores properties like the Distance Unit.
 */

class MARBLE_EXPORT MarbleLocale
{
 public:
    MarbleLocale();
    ~MarbleLocale();

    void setDistanceUnit( DistanceUnit distanceUnit );
    DistanceUnit distanceUnit() const;

    void setMeasureSystem( MeasureSystem measureSystem );
    MeasureSystem measureSystem() const;

    static QString languageCode();
    static QString simpleLanguageCode();

 private:
    Q_DISABLE_COPY( MarbleLocale )
    MarbleLocalePrivate  * const d;
};

}

#endif // MARBLE_LOCALE_H

//
// This file is part of the Marble Desktop Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2006-2007 Torsten Rahn <tackat@kde.org>
// Copyright 2007      Inge Wallin  <ingwa@kde.org>
//

#ifndef MARBLE_LOCALE_H
#define MARBLE_LOCALE_H

#include "marble_export.h"
#include "global.h"

namespace Marble
{

class MarbleLocalePrivate;

/**
 * @short A class that contains all localization stuff for Marble.
 *
 * The class stores properties like the Distance Unit.
 */

class MARBLE_EXPORT MarbleLocale
{
 public:
    MarbleLocale();
    ~MarbleLocale();

    void setDistanceUnit( DistanceUnit distanceUnit );
    DistanceUnit distanceUnit() const;

    void setMeasureSystem( MeasureSystem measureSystem );
    MeasureSystem measureSystem() const;

    static QString languageCode();

 private:
    Q_DISABLE_COPY( MarbleLocale )
    MarbleLocalePrivate  * const d;
};

}

#endif // MARBLE_LOCALE_H

Remove simpleLanguageCode (unused and not implemented).

svn path=/trunk/KDE/kdeedu/marble/; revision=1102505


#include <ifdhandler.h>

#include <stdio.h>

RESPONSECODE IFDHCreateChannelByName(DWORD Lun, LPSTR DeviceName)
{
	return IFD_NO_SUCH_DEVICE;
}

RESPONSECODE IFDHCreateChannel(DWORD Lun, DWORD Channel)
{
	char buf[40];
	snprintf(buf, sizeof(buf), "/dev/o2scr%d", Channel);
	return IFDHCreateChannelByName(Lun, buf);
}

RESPONSECODE IFDHCloseChannel(DWORD Lun)
{
	return IFD_SUCCESS;
}

RESPONSECODE IFDHGetCapabilities (DWORD Lun, DWORD Tag, PDWORD Length, PUCHAR Value)
{
	// FIXME
	(*Length) = 0;
	return IFD_ERROR_TAG;
}

RESPONSECODE IFDHSetCapabilities (DWORD Lun, DWORD Tag, DWORD Length, PUCHAR Value)
{
	return IFD_NOT_SUPPORTED;
}

RESPONSECODE IFDHPowerICC (DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength)
{
	return IFD_NOT_SUPPORTED;
}

RESPONSECODE IFDHTransmitToICC (DWORD Lun, SCARD_IO_HEADER SendPci, PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, PDWORD RxLength, PSCARD_IO_HEADER RecvPci)
{
	return IFD_NOT_SUPPORTED;
}

RESPONSECODE IFDHICCPresence (DWORD Lun)
{
	return IFD_ICC_NOT_PRESENT;
}

RESPONSECODE IFDHControl (DWORD Lun, DWORD dwControlCode, PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, DWORD RxLength, LPDWORD pdwBytesReturned)
{
	return IFD_NOT_SUPPORTED;
}

RESPONSECODE IFDHSetProtocolParameters (DWORD Lun, DWORD Protocol, UCHAR Flags, UCHAR PTS1, UCHAR PTS2, UCHAR PTS3)
{
	return IFD_NOT_SUPPORTED;
}

Add empty dummy implementation of ifd handler

Signed-off-by: Dmitry Eremin-Solenikov <b6edad08270b2e4ffbcb0879e25a0e29a48c5275@gmail.com>


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

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

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

#ifdef _WIN32
#include <Windows.h>
double current_time() {
    LARGE_INTEGER freq, t;
    QueryPerformanceCounter(&t);
    QueryPerformanceFrequency(&freq);
    return (t.QuadPart * 1000.0) / freq.QuadPart;
}
// Gross, these come from Windows.h
#undef max
#undef min
#else
#include <sys/time.h>
double current_time() {
    static bool first_call = true;
    static timeval reference_time;
    if (first_call) {
        first_call = false;
        gettimeofday(&reference_time, NULL);
        return 0.0;
    } else {
        timeval t;
        gettimeofday(&t, NULL);
        return ((t.tv_sec - reference_time.tv_sec)*1000.0 +
                (t.tv_usec - reference_time.tv_usec)/1000.0);
    }
}
#endif

Fix build of tutorials that require libpng under Visual Studio.

Former-commit-id: ca864cc2e2063756ba8e48de390d1cf947f2efad


#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include "common.h"

static void  reap(char *argv[]);
static pid_t spawn(char *argv[]);
extern void  init(char *argv[]);

int main(int argc, char *argv[])
{
    const char *name = getenv("PROCNAME");
    if (name && *name)
        setprocname(name, argv[0]);

    if (getpid() == 1) {
        /* parent process */
        reap(argv);
    } else {
        /* child process */
        prepare_env();
        init(argv + 1);
    }
    return 1;
}

static void reap(char *argv[])
{
    pid_t child = 0;
    for (;;) {
        if (!child)
            child = spawn(argv);

        pid_t died = wait(NULL);
        if (died > 0 && died == child)
            child = 0;
    }
}

static pid_t spawn(char *argv[])
{
    /* block signals so child process can't wreak havoc for parent */
    sigset_t sigs;
    sigfillset(&sigs);
    sigprocmask(SIG_BLOCK, &sigs, 0);

    pid_t pid = fork();
    if (!pid) {
        sigprocmask(SIG_UNBLOCK, &sigs, 0);
        execv(argv[0], argv);
    }

    return pid;
}

#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include "common.h"

static void  reap(char *argv[]);
static pid_t spawn(char *argv[]);
extern void  init(char *argv[]);

const char  *path;

int main(int argc, char *argv[])
{
    path = strdup(argv[0]);
    const char *name = getenv("PROCNAME");
    if (name && *name)
        setprocname(name, argv[0]);

    if (getpid() == 1) {
        /* parent process */
        reap(argv);
    } else {
        /* child process */
        prepare_env();
        init(argv + 1);
    }
    return 1;
}

static void reap(char *argv[])
{
    pid_t child = 0;
    for (;;) {
        if (!child)
            child = spawn(argv);

        pid_t died = wait(NULL);
        if (died > 0 && died == child)
            child = 0;
    }
}

static pid_t spawn(char *argv[])
{
    /* block signals so child process can't wreak havoc for parent */
    sigset_t sigs;
    sigfillset(&sigs);
    sigprocmask(SIG_BLOCK, &sigs, 0);

    pid_t pid = fork();
    if (!pid) {
        sigprocmask(SIG_UNBLOCK, &sigs, 0);
        execv(path, argv);
    }

    return pid;
}

Save program path before doing setprocname().


#if defined(__cplusplus)
extern "C" {
#endif

#include "generic.h"
#include "dict.h"
#include "vector.h"
#include "list.h"
#include "htbl.h"
#include "dsu.h"
#include "heap.h"
#include "bst.h"
#include "sort.h"
#include "heap.h"
#include "queue.h"
#include "mem.h"
#include "bitmap.h"
#include "string_utils.h"
#include "file_utils.h"

#if defined(__cplusplus)
}
#endif

Add a little bit of c++ awareness to the main header


#ifndef __LACO_H
#define __LACO_H

struct lua_State;

/* State of laco REPL */
struct LacoState;

/**
 * Makes a new LacoState.
 *
 * param          argument count (argc)
 * param          arguments      (argv)
 *
 * return a pointer to new LacoState.
 */
struct LacoState* laco_newLacoState(int, const char**);

/**
 * Destroys the internal variable, but doesn't try to free the LacoState
 * pointer itself.
 *
 * param          pointer to LacoState
 *
 * return 1 if pointer isn't NULL
 */
int laco_destroyLacoState(struct LacoState*);

struct lua_State* laco_getLacoLuaState(struct LacoState*);

const char* laco_getLacoVersion(struct LacoState*);

const char** laco_getLacoArgs(struct LacoState*);

int laco_getLacoStatus(struct LacoState*);
void laco_setLacoStatus(struct LacoState*, int);

#endif /* __LACO_H */

#ifndef __LACO_H
#define __LACO_H

struct lua_State;

/* State of laco REPL */
struct LacoState;

/**
 * Makes a new LacoState.
 *
 * param          argument count (argc)
 * param          arguments      (argv)
 *
 * return a pointer to new LacoState.
 */
struct LacoState* laco_newLacoState(int, const char**);

/**
 * Destroys the internal variable, but doesn't try to free the LacoState
 * pointer itself.
 *
 * param          pointer to LacoState
 *
 * return 1 if pointer isn't NULL
 */
int laco_destroyLacoState(struct LacoState*);

/**
 * Gets the lua state held with laco.
 *
 * param          pointer to LacoState
 *
 * return a pointer to lua_State
 */
struct lua_State* laco_getLacoLuaState(struct LacoState*);

/**
 * Gets the laco version held with laco.
 *
 * param          pointer to LacoState
 *
 * return a string of characters representing laco's version number
 */
const char* laco_getLacoVersion(struct LacoState*);

/**
 * Gets the arraying of arguments passed to laco.
 *
 * param          pointer to LacoState
 *
 * return an array of characters string passes into laco
 */
const char** laco_getLacoArgs(struct LacoState*);

/**
 * Get the current status of the laco repl.
 *
 * param          pointer to LacoState
 *
 * return the current status of laco
 */
int laco_getLacoStatus(struct LacoState*);

/**
 * Set the current status of laco.
 *
 * param          pointer to LacoState
 * param          status to be set
 */
void laco_setLacoStatus(struct LacoState*, int);

#endif /* __LACO_H */

Add documentation for new get and set functions


#import <Foundation/Foundation.h>
@class MWKSearchResult;

@interface WMFRelatedSearchResults : NSObject

@property (nonatomic, strong, readonly) NSURL *siteURL;
@property (nonatomic, strong, readonly) NSArray<MWKSearchResult *> *results;

- (instancetype)initWithURL:(NSURL *)URL results:(NSArray *)results;

@end

#import <Mantle/Mantle.h>
@class MWKSearchResult;

@interface WMFRelatedSearchResults : MTLModel

@property (nonatomic, strong, readonly) NSURL *siteURL;
@property (nonatomic, strong, readonly) NSArray<MWKSearchResult *> *results;

- (instancetype)initWithURL:(NSURL *)URL results:(NSArray *)results;

@end

Make search results storable in database as metadata

Just need to inherit from MTLModel for NSCoding


/*
 * Copyright 2015, Wink Saville
 *
 * 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.
 */

#include <sel4/printf.h>

/**
 * No parameters are passed to main, the return
 * value is ignored and the program hangs.
 */
int main(void) {
  seL4_Printf("Hello, World!\n");

  return 0;
}

Change indent to 4 spaces.

Change indent to 4 spaces.


// Copyright 2013 by Tetsuo Kiso
//
// 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 FAST_ALIGN_PORT_H_
#define FAST_ALIGN_PORT_H_

// As of OS X 10.9, it looks like C++ TR1 headers are removed from the
// search paths. Instead, we can include C++11 headers.
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
#include <unordered_map>
#include <functional>
#else // Assuming older OS X, Linux or similar platforms
#include <tr1/unordered_map>
#include <tr1/functional>
namespace std {
using tr1::unordered_map;
using tr1::hash;
} // namespace std
#endif

#endif // FAST_ALIGN_PORT_H_

// Copyright 2013 by Tetsuo Kiso
//
// 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 FAST_ALIGN_PORT_H_
#define FAST_ALIGN_PORT_H_

// As of OS X 10.9, it looks like C++ TR1 headers are removed from the
// search paths. Instead, we can include C++11 headers.
#if defined(__APPLE__)
#include <AvailabilityMacros.h>
#endif

#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_9) && \
  MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
#include <unordered_map>
#include <functional>
#else // Assuming older OS X, Linux or similar platforms
#include <tr1/unordered_map>
#include <tr1/functional>
namespace std {
using tr1::unordered_map;
using tr1::hash;
} // namespace std
#endif

#endif // FAST_ALIGN_PORT_H_

Include the OS X specific header to use OS specific macros.


#include "bst.h"

static void BST_Transplant(BST* T, BSTNode* u, BSTNode* v);

struct BSTNode
{
	BSTNode* left;
	BSTNode* right;
	BSTNode* p;
	void* k;
};

struct BST
{
	BSTNode* root;
};

BST* BST_Create(void)
{
	BST* T = (BST* )malloc(sizeof(BST));
	T->root = NULL;
	return T;
}

BSTNode* BSTNode_Create(void* k)
{
	BSTNode* n = (BSTNode* )malloc(sizeof(BSTNode));
	n->left = NULL;
	n->right = NULL;
	n->p = NULL;
	n->k = k;
}

Add BSTNode create function implementation


#include <stdlib.h>
#ifndef __BST_H__
#define __BST_H__
struct BSTNode;
struct BST;
typedef struct BSTNode BSTNode;
typedef struct BST BST;

BST* BST_Create(void);
BSTNode* BSTNode_Create(void* k);
void BST_Inorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Preorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Postorder_Tree_Walk(BST* T, void (f)(void*));
BSTNode* BST_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Iterative_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Tree_Minimum(BSTNode* n);
BSTNode* BST_Tree_Maximum(BSTNode* n);

#endif

#include <stdlib.h>
#ifndef __BST_H__
#define __BST_H__
struct BSTNode;
struct BST;
typedef struct BSTNode BSTNode;
typedef struct BST BST;

BST* BST_Create(void);
BSTNode* BSTNode_Create(void* k);
void BST_Inorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Preorder_Tree_Walk(BST* T, void (f)(void*));
void BST_Postorder_Tree_Walk(BST* T, void (f)(void*));
BSTNode* BST_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Iterative_Tree_Search(BST* T, void* k, int (f)(void*, void*), int (g)(void*, void*));
BSTNode* BST_Tree_Minimum(BSTNode* n);
BSTNode* BST_Tree_Maximum(BSTNode* n);
BSTNode* BST_Tree_Root(BST* T);

#endif

Add BST Tree Root function declaration

Add BST Tree Root function declaration


//
//  main.c
//  unique-characters
//
//  Created by Jack Zuban on 8/20/17.
//  Copyright © 2017 Jack Zuban. All rights reserved.
//

#include <stdio.h>

void printCharacters(char *inputString) {
    int dictinary[30] = {};

    while (*inputString) {
        dictinary[(int) *inputString]++;
        printf("Current character is: %c\n", *inputString);

        inputString++;
    }
}

int main(int argc, const char * argv[]) {
    void printCharacters(char *inputString);
    char inputString[80] = {};

    printf("Please enter your string: ");
    scanf("%s", inputString);

    // build a hash table with caracters
    printCharacters(inputString);

    printf("Your string is: %s\n", inputString);

    return 0;
}

//
//  main.c
//  Check if a string has all unique characters by counting how many times each character appears using its ASCII code
//
//  Created by Jack Zuban on 8/20/17.
//  Copyright © 2017 Jack Zuban. All rights reserved.
//

#include <stdio.h>

_Bool isUniqueChars(char *str) {
    int frequencyDictionary[127] = {};

    while(*str) {
        frequencyDictionary[(int) *str]++;

        if (frequencyDictionary[(int) *str] > 1) {
            return 0;
        }

        str++;
    }

    return 1;
}

int main(void) {
    _Bool isUniqueChars(char *string);
    char inputString[127] = {};

    printf("Please enter your string: ");
    fgets(inputString, 128, stdin);

    printf("This string with %s\n", isUniqueChars(inputString) ? "unique characters." : "duplicates.");

    return 0;
}

Check if a string has all unique characters algorithm


#include "generic.h"
#include "dict.h"
#include "vector.h"
#include "list.h"
#include "htbl.h"
#include "dsu.h"
#include "bst.h"
#include "sort.h"
#include "heap.h"
#include "queue.h"
#include "mem.h"
#include "string_utils.h"
#include "file_utils.h"

Add common header for library functions

Add common header for library functions


#import "RCTBridgeModule.h"

@interface RNFlurryAnalytics : NSObject <RCTBridgeModule>

@end

#import <React/RCTBridgeModule.h>

@interface RNFlurryAnalytics : NSObject <RCTBridgeModule>

@end

Update header include paths to support React Native 0.40


#include <stddef.h>
#include <stdint.h>
#include "./arch/x86/idt.h"
#include <terminal.h>
#include <kabort.h>
#include <kassert.h>

void kernel_main()
{
    term_initialize();
    idt_install();

    kputs("Interrupt?");
    int i = 0;
    int b = 128;
    int d = 1;

    d = b / i;

    while (1)
        ;
}

#include <stddef.h>
#include <stdint.h>
#include "./arch/x86/gdt.h"
#include "./arch/x86/idt.h"
#include <terminal.h>
#include <kabort.h>
#include <kassert.h>

void kernel_main()
{
    term_initialize();
    gdt_install();
    idt_install();

    kputs("Hello kernel!");

    while (1) {
    };
}

Install GDT and remove division by 0

Install GDT and remove division by 0


//
//  TGGeoPoint.h
//  tangram
//
//  Created by Karim Naaji on 10/27/16.
//
//

#ifndef TGGeoPoint_h
#define TGGeoPoint_h

struct TGGeoPoint {
    double longitude;
    double latitude;
};

typedef struct TGGeoPoint TGGeoPoint;

static inline TGGeoPoint TGGeoPointMake(double lat, double lon)
{
    TGGeoPoint p;
    p.latitude = lat;
    p.longitude = lon;
    return p;
}

#endif /* TGGeoPoint_h */

//
//  TGGeoPoint.h
//  tangram
//
//  Created by Karim Naaji on 10/27/16.
//
//

#pragma once

struct TGGeoPoint {
    double longitude;
    double latitude;
};

typedef struct TGGeoPoint TGGeoPoint;

static inline TGGeoPoint TGGeoPointMake(double lat, double lon)
{
    TGGeoPoint p;
    p.latitude = lat;
    p.longitude = lon;
    return p;
}

Update for pragma syntax - Only unsupported on older versions of GCC


#include "usbdmx.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char ** argv) {
    int result;
    int set_value;
    int count = 0;

    TDMXArray dmx_out;
    TDMXArray dmx_in;

    // Open Interface in Mode 6 (PC Out -> DMX Out & DMX In -> PC In)
    // See head of this file for details
    result = OpenInterface(&dmx_out, &dmx_in, 6);

    if(result == 0) {
        // Open failed
        printf("Unable to open Interface\n");
        exit(1);
    }

    while(1) {
        set_value = count % 256;
        dmx_out[0] = set_value;
        dmx_out[1] = set_value;
        dmx_out[2] = set_value;

        usleep(50000);  // Wait 50 ms

        if (  (dmx_in[0] != set_value) ||
              (dmx_in[1] != set_value) ||
              (dmx_out[2] != set_value)) {
            printf("FAIL %d\n", count);
        } else {
            count ++;
            printf("Still working %d\n", count);
        }
    }
    return 0;
}

#include "usbdmx.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char ** argv) {
    int result;
    int set_value;
    int count = 0;

    TDMXArray dmx_out;
    TDMXArray dmx_in;

    // Open Interface in Mode 6 (PC Out -> DMX Out & DMX In -> PC In)
    // See head of this file for details
    result = OpenInterface(&dmx_out, &dmx_in, 6);

    if(result == 0) {
        // Open failed
        printf("Unable to open Interface\n");
        exit(1);
    }

    while(1) {
        set_value = count % 256;
        dmx_out[0] = set_value;
        dmx_out[1] = set_value;
        dmx_out[2] = set_value;

        usleep(50000);  // Wait 50 ms

        if (  (dmx_in[0] != set_value) ||
              (dmx_in[1] != set_value) ||
              (dmx_in[2] != set_value)) {
            printf("FAIL %d\n", count);
        } else {
            count ++;
            printf("Still working %d\n", count);
        }
    }
    return 0;
}

Fix typo dmx_out instead of dmx_in

Fix typo dmx_out instead of dmx_in


#if defined TESTFLIGHT
#define TESTFLIGHT YES
#define DISTRIBUTION NO
#elif defined DEBUG
#define TESTFLIGHT NO
#define DISTRIBUTION NO
#else
#define TESTFLIGHT NO
#define DISTRIBUTION YES
#endif

#define CLIP(X,min,max) MIN(MAX(X, min), max)
#define white [UIColor whiteColor]
#define yellow [UIColor yellowColor]
#define transparent [UIColor clearColor]
#define black [UIColor blackColor]

#if defined __MAC_OS_X_VERSION_MAX_ALLOWED
#define PLATFORM_OSX
#define UIApplicationDelegate NSApplicationDelegate
#define UIView NSView
#define UIApplication NSApplication

#elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
#define PLATFORM_IOS
#endif

void error(NSError* err);
NSError* makeError(NSString* localMessage);

typedef void (^Block)();
typedef void (^Callback)(NSError* err, NSDictionary* res);
typedef void (^StringCallback)(NSError* err, NSString* res);
typedef void (^ArrayCallback)(NSError* err, NSArray* res);
typedef void (^DataCallback)(NSError* err, NSData* data);
typedef void (^ImageCallback)(NSError* err, UIImage* image);
typedef void (^ViewCallback)(NSError* err, UIView* view);

void after(CGFloat delayInSeconds, Block block);
void vibrateDevice();

NSString* concat(id arg1, ...);
NSNumber* num(int i);

#define MODE_DEV 1
#define MODE_TESTFLIGHT 2
#define MODE_DISTRIBUTION 3
#if defined TESTFLIGHT
    #define MODE MODE_TESTFLIGHT
#elif defined DEBUG
    #define MODE MODE_DEV
#else
    #define MODE MODE_DISTRIBUTION
#endif
#define IS_DISTRIBUTION (MODE == MODE_DISTRIBUTION)

#define CLIP(X,min,max) MIN(MAX(X, min), max)
#define white [UIColor whiteColor]
#define yellow [UIColor yellowColor]
#define transparent [UIColor clearColor]
#define black [UIColor blackColor]

#if defined __MAC_OS_X_VERSION_MAX_ALLOWED
#define PLATFORM_OSX
#define UIApplicationDelegate NSApplicationDelegate
#define UIView NSView
#define UIApplication NSApplication

#elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
#define PLATFORM_IOS
#endif

void error(NSError* err);
NSError* makeError(NSString* localMessage);

typedef void (^Block)();
typedef void (^Callback)(NSError* err, NSDictionary* res);
typedef void (^StringCallback)(NSError* err, NSString* res);
typedef void (^ArrayCallback)(NSError* err, NSArray* res);
typedef void (^DataCallback)(NSError* err, NSData* data);
typedef void (^ImageCallback)(NSError* err, UIImage* image);
typedef void (^ViewCallback)(NSError* err, UIView* view);

void after(CGFloat delayInSeconds, Block block);
void vibrateDevice();

NSString* concat(id arg1, ...);
NSNumber* num(int i);

Add macro MODE and MODE_DEV, MODE_TESTFLIGHT, MODE_DISTRIBUTION


#include <X11/Xft/Xft.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xrender.h>
#include <fontconfig/fontconfig.h>

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

int main(int argc, char** argv) {
  if (argc < 3) {
    printf("xftwidth font string\n");
    return 1;
  }

  Display *dpy;
  XftFont *fn;
  XGlyphInfo ext;
  FcChar8 *str;

  char *name = argv[1];
  size_t len = strlen(argv[2]) + 1;

  str = (FcChar8*) malloc(len * sizeof(FcChar8));

  strncpy((char*)str, argv[2], len);

  dpy = XOpenDisplay(NULL);
  fn = XftFontOpenName(dpy, 0, name);

  if (fn == NULL) {
    printf("Font not found.\n");
    return 1;
  }

  XftTextExtents8(dpy, fn, str, (int)len, &ext);
  printf("%d\n", ext.width);

  XCloseDisplay(dpy);
  free((void*)str);
  return 0;
}

#include <X11/Xft/Xft.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xrender.h>
#include <fontconfig/fontconfig.h>

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

int main(int argc, char** argv) {
  if (argc < 3) {
    printf("xftwidth font string\n");
    return 1;
  }

  Display *dpy;
  XftFont *fn;
  XGlyphInfo ext;
  FcChar8 *str;

  char *name = argv[1];
  size_t len = strlen(argv[2]);

  str = (FcChar8*) malloc(len * sizeof(FcChar8));

  strncpy((char*)str, argv[2], len);

  dpy = XOpenDisplay(NULL);
  fn = XftFontOpenName(dpy, 0, name);

  if (fn == NULL) {
    printf("Font not found.\n");
    return 1;
  }

  XftTextExtents8(dpy, fn, str, (int)len, &ext);
  printf("%d\n", ext.width);

  XCloseDisplay(dpy);
  free((void*)str);
  return 0;
}

Fix wrong result caused by newline character.


// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <optional>

namespace search::docsummary {

/*
 * Class filtering which fields to render in a struct field.
 */
class SlimeFillerFilter {
    vespalib::hash_map<vespalib::string, std::unique_ptr<SlimeFillerFilter>> _filter;
    std::optional<const SlimeFillerFilter*> get_filter(vespalib::stringref field_name) const;
public:
    SlimeFillerFilter();
    ~SlimeFillerFilter();
    static std::optional<const SlimeFillerFilter*> get_filter(const SlimeFillerFilter*, vespalib::stringref field_name);
    bool empty() const;
    SlimeFillerFilter& add(vespalib::stringref field_path);
};

}

// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/vespalib/stllike/string.h>
#include <vespa/vespalib/stllike/hash_map.h>
#include <optional>

namespace search::docsummary {

/*
 * Class filtering which fields to render in a struct field.
 */
class SlimeFillerFilter {
    vespalib::hash_map<vespalib::string, std::unique_ptr<SlimeFillerFilter>> _filter;
    std::optional<const SlimeFillerFilter*> get_filter(vespalib::stringref field_name) const;
public:
    SlimeFillerFilter();
    ~SlimeFillerFilter();
    /*
     * If field is blocked by the filter then the return value is not set,
     * otherwise it is set to the filter for the next level.
     */
    static std::optional<const SlimeFillerFilter*> get_filter(const SlimeFillerFilter* filter, vespalib::stringref field_name);
    bool empty() const;
    SlimeFillerFilter& add(vespalib::stringref field_path);
};

}

Add comment describing semantics of return value from SlimeFillerFilter::get_filter().


#ifndef LAGER_COMMON_SPHERICAL_COORDINATES_H
#define LAGER_COMMON_SPHERICAL_COORDINATES_H

/*
 * Code based on:
 * http://stackoverflow.com/questions/17016175/c-unordered-map-using-a-custom-class-type-as-the-key
 */
struct SphericalCoordinates {
	int phi;
	int theta;

	bool operator==(const SphericalCoordinates &other) const
	{
		return (phi == other.phi && theta == other.theta);
	}
};

/*
 * Code based on:
 * http://stackoverflow.com/questions/17016175/c-unordered-map-using-a-custom-class-type-as-the-key
 */
namespace std {
	template<>
	struct hash<SphericalCoordinates>
	{
		std::size_t operator()(const SphericalCoordinates& k) const
		{
			// Compute individual hash values for mPhi and mTheta
			// and combine them using XOR and bit shifting:
			return ((hash<int>()(k.phi) ^ (hash<int>()(k.theta) << 1)));
		}
	};
}

double DegreesToRadians(double degrees)
{
	return (degrees/180 * M_PI);
}

#endif /* LAGER_COMMON_SPHERICAL_COORDINATES_H */

#ifndef LAGER_COMMON_SPHERICAL_COORDINATES_H
#define LAGER_COMMON_SPHERICAL_COORDINATES_H

#include <math.h>

/*
 * Code based on:
 * http://stackoverflow.com/questions/17016175/c-unordered-map-using-a-custom-class-type-as-the-key
 */
struct SphericalCoordinates {
	int phi;
	int theta;

	bool operator==(const SphericalCoordinates &other) const
	{
		return (phi == other.phi && theta == other.theta);
	}
};

/*
 * Code based on:
 * http://stackoverflow.com/questions/17016175/c-unordered-map-using-a-custom-class-type-as-the-key
 */
namespace std {
	template<>
	struct hash<SphericalCoordinates>
	{
		std::size_t operator()(const SphericalCoordinates& k) const
		{
			// Compute individual hash values for mPhi and mTheta
			// and combine them using XOR and bit shifting:
			return ((hash<int>()(k.phi) ^ (hash<int>()(k.theta) << 1)));
		}
	};
}

double DegreesToRadians(double degrees)
{
	return (degrees/180 * M_PI);
}

#endif /* LAGER_COMMON_SPHERICAL_COORDINATES_H */

Common: Add missing math.h include for M_PHI definition


// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/document/annotation/span.h>
#include <vespa/document/serialization/util.h>

namespace vespalib {
    class nbostream;
}

namespace document {
class AlternateSpanList;
class Annotation;
class FixedTypeRepo;
class SpanList;
class SpanTree;
class SimpleSpanList;

class AnnotationDeserializer {
public:
    AnnotationDeserializer(const FixedTypeRepo &repo, vespalib::nbostream &stream, uint16_t version);

    std::unique_ptr<SpanTree> readSpanTree();
    std::unique_ptr<SpanNode> readSpanNode();
    // returns 0 if the annotation type is unknown.
    std::unique_ptr<AlternateSpanList> readAlternateSpanList();
    void readAnnotation(Annotation & annotation);
private:
    std::unique_ptr<SpanList> readSpanList();
    std::unique_ptr<SimpleSpanList> readSimpleSpanList();
    void readSpan(Span & span) {
        span.from(getInt1_2_4Bytes(_stream));
        span.length(getInt1_2_4Bytes(_stream));
    }

    const FixedTypeRepo    &_repo;
    vespalib::nbostream    &_stream;
    uint16_t                _version;
    std::vector<SpanNode *> _nodes;
};
}  // namespace document

// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/document/annotation/span.h>
#include <vespa/document/serialization/util.h>
#include <vector>

namespace vespalib {
    class nbostream;
}

namespace document {
class AlternateSpanList;
class Annotation;
class FixedTypeRepo;
class SpanList;
class SpanTree;
class SimpleSpanList;

class AnnotationDeserializer {
public:
    AnnotationDeserializer(const FixedTypeRepo &repo, vespalib::nbostream &stream, uint16_t version);

    std::unique_ptr<SpanTree> readSpanTree();
    std::unique_ptr<SpanNode> readSpanNode();
    // returns 0 if the annotation type is unknown.
    std::unique_ptr<AlternateSpanList> readAlternateSpanList();
    void readAnnotation(Annotation & annotation);
private:
    std::unique_ptr<SpanList> readSpanList();
    std::unique_ptr<SimpleSpanList> readSimpleSpanList();
    void readSpan(Span & span) {
        span.from(getInt1_2_4Bytes(_stream));
        span.length(getInt1_2_4Bytes(_stream));
    }

    const FixedTypeRepo    &_repo;
    vespalib::nbostream    &_stream;
    uint16_t                _version;
    std::vector<SpanNode *> _nodes;
};
}  // namespace document

Include what you need as gcc 6 provides less.


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

SLTM(CLI)
SLTM(SessionOpen)
SLTM(SessionClose)
SLTM(ClientAddr)
SLTM(Request)
SLTM(URL)
SLTM(Protocol)
SLTM(HD_Unknown)
SLTM(HD_Lost)
#define HTTPH(a, b, c, d, e, f, g)	SLTM(b)
#include "http_headers.h"
#undef HTTPH

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

SLTM(Debug)
SLTM(CLI)
SLTM(SessionOpen)
SLTM(SessionClose)
SLTM(ClientAddr)
SLTM(Request)
SLTM(URL)
SLTM(Protocol)
SLTM(HD_Unknown)
SLTM(HD_Lost)
#define HTTPH(a, b, c, d, e, f, g)	SLTM(b)
#include "http_headers.h"
#undef HTTPH

Add a Debug shmemlog tag.

Add a Debug shmemlog tag.

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


#ifndef __COMMON_H__
#define __COMMON_H__

#if NODE_VERSION_AT_LEAST(0,11,0)
#define __NODE_V0_11__
#endif

#endif

#ifndef __COMMON_H__
#define __COMMON_H__

#ifdef NODE_VERSION_AT_LEAST
#if NODE_VERSION_AT_LEAST(0,11,0)
#define __NODE_V0_11__
#endif
#endif

#endif

Fix build under node.js 0.10.0

Fix build under node.js 0.10.0


// Copyright (c) 2017 Shift Devices AG
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef LIBDBB_SAFEQUEUE_H
#define LIBDBB_SAFEQUEUE_H

#include <stdint.h>
#include <stdlib.h>

#include <atomic>
#include <queue>
#include <mutex>
#include <condition_variable>

// A threadsafe-queue.
template <class T>
class SafeQueue
{
public:
  SafeQueue(void)
    : q()
    , m()
    , c()
  {}

  ~SafeQueue(void)
  {}

  // Add an element to the queue.
  size_t size()
  {
    std::lock_guard<std::mutex> lock(m);
    return q.size();
  }

  // Add an element to the queue.
  void enqueue(T t)
  {
    std::lock_guard<std::mutex> lock(m);
    q.push(t);
    c.notify_one();
  }

  // Get the "front"-element.
  // If the queue is empty, wait till a element is avaiable.
  T dequeue(void)
  {
    std::unique_lock<std::mutex> lock(m);
    while(q.empty())
    {
      // release lock as long as the wait and reaquire it afterwards.
      c.wait(lock);
    }
    T val = q.front();
    q.pop();
    return val;
  }

private:
  std::queue<T> q;
  mutable std::mutex m;
  std::condition_variable c;
};

#endif // LIBDBB_SAFEQUEUE_H

Add thread safe queue class

Add thread safe queue class


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

#import <CoreData/CoreData.h>

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

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

@interface NSManagedObject (MagicalRecord_DataImport)

- (BOOL) MR_importValuesForKeysWithObject:(id)objectData;

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

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

@end

@interface NSManagedObject (MagicalRecord_DataImportControls)

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

@end

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

#import <CoreData/CoreData.h>

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

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

@interface NSManagedObject (MagicalRecord_DataImport)

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

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

@end

@interface NSManagedObject (MagicalRecord_DataImportControls)

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

@end

Remove unnecessarily public method from interface


// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

#if !defined(__COREFOUNDATION_CFASMMACROS__)
#define __COREFOUNDATION_CFASMMACROS__ 1

#define CONCAT(a,b) a##b
#define CONCAT_EXPANDED(a,b) CONCAT(a,b)
#define _C_LABEL(name) CONCAT_EXPANDED(__USER_LABEL_PREFIX__,name)

#if defined(__GNU__) || defined(__ANDROID__) || defined(__FreeBSD__)
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
#else
#define NO_EXEC_STACK_DIRECTIVE
#endif

#endif

// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//

#if !defined(__COREFOUNDATION_CFASMMACROS__)
#define __COREFOUNDATION_CFASMMACROS__ 1

#define CONCAT(a,b) a##b
#define CONCAT_EXPANDED(a,b) CONCAT(a,b)
#define _C_LABEL(name) CONCAT_EXPANDED(__USER_LABEL_PREFIX__,name)

#if defined(__GNU__) || defined(__GNUC__) || defined(__ANDROID__) || defined(__FreeBSD__)
#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits
#else
#define NO_EXEC_STACK_DIRECTIVE
#endif

#endif

Fix libFoundation.so being flagged as requiring executable stack

libFoundation.so is flagged as requiring an executable stack on Linux, although it does not. This is due to GNU as behavior.
Please see discussion at https://bugs.swift.org/browse/SR-2700?jql=text%20~%20%22executable%20stack%22

This was already intended to be solved by https://github.com/apple/swift-corelibs-foundation/pull/649/, but did not work as intended in Ubuntu. Checking for __GNUC__ in addition resolves the issue.


#include <h/mh.h>

const char *
read_line(void)
{
    char *cp;
    static char line[BUFSIZ];

    fflush(stdout);
    if (fgets(line, sizeof(line), stdin) == NULL)
            return NULL;
    if ((cp = strchr(line, '\n')))
	*cp = 0;
    return line;
}

#include <h/mh.h>
#include <h/utils.h>

const char *
read_line(void)
{
    static char line[BUFSIZ];

    fflush(stdout);
    if (fgets(line, sizeof(line), stdin) == NULL)
            return NULL;
    TrimSuffixC(line, '\n');

    return line; /* May not be a complete line. */
}

Replace strchr() condition with TrimSuffixC().


/** \file
 * This file only exists to contain the front-page of the documentation
 */

/** \mainpage Tiramisu Optimization Framework
 * Tiramisu is a library that is designed to simplify code optimization and code generation.  The user can express his code in the Tiramisu intermediate representation (Tiramisu IR), he can use the Tiramisu API to perform different optimizations and finaly he can generate an LLVM code from the optimized Tiramisu IR.
 *
 * Tiramisu provides few classes to enable users to represent their program:
 * - The \ref tiramisu::function class: a function is composed of multiple computations and a vector of arguments (functions arguments).
 * - The \ref tiramisu::computation class: a computation is composed of an expression and an iteration space but is not associated with any memory location.
 * - The \ref tiramisu::buffer class: a class to represent memory buffers.
 *
 * \example tutorials/tutorial_01.cpp
 * \example tutorials/tutorial_02.cpp
 * \example tutorials/tutorial_03.cpp
 * \example tutorials/tutorial_04.cpp
 * \example tutorials/tutorial_05.cpp
 * \example tutorials/tutorial_06.cpp
 */

/** \file
 * This file only exists to contain the front-page of the documentation
 */

/** \mainpage Documentation of the API if the Tiramisu Compiler
 *
 * Tiramisu provides few classes to enable users to represent their program:
 * - The \ref tiramisu::function class: a function in Tiramisu is equivalent to a function in C. It is composed of multiple computations. Each computation is the equivalent of a statement in C.
 * - The \ref tiramisu::input class: an input is used to represent inputs passed to Tiramisu.  An input can represent a buffer or a scalar.
 * - The \ref tiramisu::constant class: a constant is designed to represent constants that are supposed to be declared at the beginning of a Tiramisu function.
 * - The \ref tiramisu::computation class: a computation in Tiramisu is the equivalent of a statement in C. It is composed of an expression and an iteration domain.
 * - The \ref tiramisu::buffer class: a class to represent memory buffers.
 *
 */

Fix the documentation main page

Fix the documentation main page


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

#ifndef CRASHPAD_COMPAT_LINUX_SYS_USER_H_
#define CRASHPAD_COMPAT_LINUX_SYS_USER_H_

#include_next <sys/user.h>

#include <features.h>

// glibc for 64-bit ARM uses different names for these structs prior to 2.20.
#if defined(__aarch64__) && defined(__GLIBC__)
#if !__GLIBC_PREREQ(2, 20)
using user_regs_struct = user_pt_regs;
using user_fpsimd_struct = user_fpsimd_state;
#endif
#endif

#endif  // CRASHPAD_COMPAT_LINUX_SYS_USER_H_

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

#ifndef CRASHPAD_COMPAT_LINUX_SYS_USER_H_
#define CRASHPAD_COMPAT_LINUX_SYS_USER_H_

#include_next <sys/user.h>

#include <features.h>

// glibc for 64-bit ARM uses different names for these structs prior to 2.20.
// However, Debian's glibc 2.19-8 backported the change so it's not sufficient
// to only test the version. user_pt_regs and user_fpsimd_state are actually
// defined in <asm/ptrace.h> so we use the include guard here.
#if defined(__aarch64__) && defined(__GLIBC__)
#if !__GLIBC_PREREQ(2, 20) && defined(__ASM_PTRACE_H)
using user_regs_struct = user_pt_regs;
using user_fpsimd_struct = user_fpsimd_state;
#endif
#endif

#endif  // CRASHPAD_COMPAT_LINUX_SYS_USER_H_

Fix compilation issue on arm64 with Debian's glibc 2.19

Fuchsia's glibc is derived from Debian so it's causing issues on
Fuchsia.

Change-Id: I46368eb08f7cc7338783f115869e5c761f35e465
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2630288
Reviewed-by: Joshua Peraza <f5809a5e35ec7e1bd0e25cb0a0b68bb433cf6f17@chromium.org>
Commit-Queue: Joshua Peraza <f5809a5e35ec7e1bd0e25cb0a0b68bb433cf6f17@chromium.org>


/* From Listing 3 in "Test-Case Reduction for C Compiler Bugs" paper, avaiable
 * at http://www.cs.utah.edu/~regehr/papers/pldi12-preprint.pdf.
 */

int printf (const char *, ...);
struct {
	int f0;
	int f1;
	int f2;
} a, b = { 0, 0, 1 };

void fn1 () {
	a = b;
	a = a;
}

int main () {
	fn1 ();
	printf ("%d\n", a.f2);
	return 0;
}

Add test case on struct initialization and assignment


#pragma config(Sensor, S1,     ir,             sensorHiTechnicIRSeeker600)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main() {
	while (true) {
		nxtDisplayTextLine(0, "S:%d", SensorValue[ir]);
		nxtDisplayTextLine(1, "R:%d", SensorRaw[ir]);
	}
}

Add IR sensor debugging program, using robotc API


#include <erl_nif.h>

static ERL_NIF_TERM kinit(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
    return enif_make_atom(env, "true");
}

static ErlNifFunc nif_funcs[] = {
    {"kinit", 2, kinit}
};

ERL_NIF_INIT(kinit, nif_funcs, NULL, NULL, NULL, NULL)

#include <erl_nif.h>

static ERL_NIF_TERM kinit(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {
    return enif_make_atom(env, "true");
}

int noop(ErlNifEnv* env, void** priv_data, void** old_priv_data, ERL_NIF_TERM load_info) {
    return 0;
}

static ErlNifFunc nif_funcs[] = {
    {"kinit", 2, kinit}
};

ERL_NIF_INIT(kinit, nif_funcs, NULL, NULL, noop, NULL)

Add a noop for upgrade so we don't get the warning.


#include <stdio.h>
extern int print_is_on;

double m_open(float *, short, double *);

double
m_input(float *p,short n_args,double *pp)
{
	p[1] = (n_args > 1) ? p[1] : 0.;
	p[2] = 0;
	n_args = 3;
	if(print_is_on)
		fprintf(stderr,"Opening input file as unit %d\n",(int)p[1]);
	return m_open(p,n_args,pp);
}

double
m_output(float *p,short n_args,double *pp)
{
	int i;
	p[1] = (n_args > 1) ? p[1] : 1.;
	p[2] = 2;
	n_args = 3;
	i = p[0];
	if(print_is_on)
		fprintf(stderr,"Opening output file as unit %d\n",(int)p[1]);
    	return m_open(p,n_args,pp);
}

#include <globals.h>
#include <stdio.h>

extern double m_open(float *, short, double *);

double
m_input(float *p,short n_args,double *pp)
{
	p[1] = (n_args > 1) ? p[1] : 0.;
	p[2] = 0;
	n_args = 3;
	if(print_is_on)
		fprintf(stderr,"Opening input file as unit %d\n",(int)p[1]);
	return m_open(p,n_args,pp);
}

double
m_output(float *p,short n_args,double *pp)
{
	int i;
	p[1] = (n_args > 1) ? p[1] : 1.;
	p[2] = 2;
	n_args = 3;
	i = p[0];
	if(print_is_on)
		fprintf(stderr,"Opening output file as unit %d\n",(int)p[1]);
    	return m_open(p,n_args,pp);
}

Move some globals to globals.h.

Move some globals to globals.h.


#include <openssl/conf.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <string.h>
#include "shared.h"

int base64_decode
(char *src, bytes *dest)
{
	BIO *bio, *b64;
	unsigned int max_len = strlen(src) * 0.75;

	dest->data = malloc(max_len);
	if (dest->data == NULL) return -1;

	b64 = BIO_new(BIO_f_base64());
	bio = BIO_new_mem_buf(src, -1);
	bio = BIO_push(b64, bio);
	dest->length = (int)BIO_read(bio, dest->data, max_len);
	BIO_free_all(bio);

	return 0;
}

int base64_encode
(char *src, int src_len, char **dest)
{
	return -1;
}

#include <openssl/conf.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <string.h>
#include <stdio.h>
#include "shared.h"

int base64_decode
(char *src, bytes *dest)
{
	BIO *bio, *b64;
	unsigned int max_len = strlen(src) * 3 / 4;

	dest->data = malloc(max_len);
	if (dest->data == NULL) return -1;

	FILE* stream = fmemopen(src, strlen(src), "r");
	b64 = BIO_new(BIO_f_base64());
	bio = BIO_new_fp(stream, BIO_NOCLOSE);
	bio = BIO_push(b64, bio);
	BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
	dest->length = BIO_read(bio, dest->data, max_len);
	BIO_free_all(bio);

	return 0;
}

int base64_encode
(char *src, int src_len, char **dest)
{
	return -1;
}

Fix overflow bug in OpenSSL

Fix overflow bug in OpenSSL


typedef struct list {
    struct list *next;
    struct list *prev;
} list_t;

typedef struct record {
    int    data1;
    list_t node;
    int    data2;
} record_t;

#define container(p) ((record_t*)((int*)(p) - 1))

void init_record(list_t *p) {
    record_t *r = container(p);
    r->data2    = 42;
}

void init_all_records(list_t *p) {
    while (p != NULL) {
        init_record(p);
        p = p->next;
    }
}

Add Qadeer record init example

Add Qadeer record init example


#include "flags.h"

#include <stdio.h>

#include "laco.h"
#include "util.h"

static const char* version_matches[] = {"-v", "--version", NULL};
static const char* help_matches[]    = {"-h", "-?", "--help", NULL};

/* Print off the current version of laco */
static void handle_version(LacoState* laco, const char** arguments) {
  const char* version = laco_get_laco_version(laco);

  printf("laco version %s\n", version);
  laco_kill(laco, 0, NULL);
}

/* Print off the help screen */
static void handle_help(LacoState* laco, const char** arguments) {
  puts("A better REPL for Lua.\n");
  puts("Usage: laco [options]\n");
  puts("-h | -? | --help   \tPrint this help screen");
  puts("-v | --version     \tPrint current version");

  laco_kill(laco, 0, NULL);
}

static const struct LacoCommand flag_commands[] = {
  { version_matches, handle_version },
  { help_matches,    handle_help },
  { NULL, NULL}
};

/* External API */

void laco_handle_flag(LacoState* laco) {
  const char* command = laco_get_laco_args(laco)[1];

  laco_dispatch(flag_commands, laco, command, NULL);
}

#include "flags.h"

#include <stdio.h>

#include "laco.h"
#include "util.h"

static const char* version_matches[] = {"-v", "--version", NULL};
static const char* help_matches[]    = {"-h", "-?", "--help", NULL};

/* Print off the current version of laco */
static void handle_version(LacoState* laco, const char** arguments) {
  const char* version = laco_get_laco_version(laco);

  printf("laco version %s\n", version);
  laco_kill(laco, 0, NULL);
}

/* Print off the help screen */
static void handle_help(LacoState* laco, const char** arguments) {
  puts("A better REPL for Lua.\n");
  puts("Usage: laco [options]\n");
  puts("-h | -? | --help   \tPrint this help screen");
  puts("-v | --version     \tPrint current version");

  laco_kill(laco, 0, NULL);
}

static const struct LacoCommand flag_commands[] = {
  { version_matches, handle_version },
  { help_matches,    handle_help },
  { NULL, NULL }
};

/* External API */

void laco_handle_flag(LacoState* laco) {
  const char* command = laco_get_laco_args(laco)[1];

  laco_dispatch(flag_commands, laco, command, NULL);
}

Add a space to the terminating array entry


/**
 * log.h - Header of log class
 * includes 2 methods to show warrnings and errors
 * @author Pavel Kryukov
 * Copyright 2017 MIPT-MIPS team
 */

#ifndef LOG_H
#define LOG_H

#include <iostream>
#include <ostream>

class LogOstream
{
    const bool enable;
    std::ostream& stream;

public:
    struct Critical { };

    LogOstream(bool value, std::ostream& _out) : enable(value), stream(_out) { }

    friend LogOstream& operator<<(LogOstream&, const Critical&) {
         exit(-1);
    }

    LogOstream& operator<<(std::ostream& (*F)(std::ostream&)) {
        if ( enable)
            F(stream);
        return *this;
    }

    template<typename T>
    LogOstream& operator<<(const T& v) {
        if ( enable) {
            stream << v;
        }

        return *this;
    }
};

class Log
{
public:
    LogOstream sout;
    LogOstream serr;
    LogOstream::Critical critical;

    Log(bool value) : sout(value, std::cout), serr(true, std::cerr), critical() { }
    virtual ~Log() { }
};

#endif /* LOG_H */

/**
 * log.h - Header of log class
 * includes 2 methods to show warrnings and errors
 * @author Pavel Kryukov
 * Copyright 2017 MIPT-MIPS team
 */

#ifndef LOG_H
#define LOG_H

#include <iostream>
#include <ostream>

class LogOstream
{
    const bool enable;
    std::ostream& stream;

public:
    struct Critical { };

    LogOstream(bool value, std::ostream& _out) : enable(value), stream(_out) { }

    friend LogOstream& operator<<(LogOstream&, const Critical&) {
         exit(-1);
    }

    LogOstream& operator<<(std::ostream& (*F)(std::ostream&)) {
        if ( enable)
            F(stream);
        return *this;
    }

    template<typename T>
    LogOstream& operator<<(const T& v) {
        if ( enable) {
            stream << v;
        }

        return *this;
    }
};

class Log
{
public:
    mutable LogOstream sout;
    mutable LogOstream serr;
    const LogOstream::Critical critical;

    Log(bool value) : sout(value, std::cout), serr(true, std::cerr), critical() { }
    virtual ~Log() { }
};

#endif /* LOG_H */

Make serr and sout mutable to use them in const methods


Add hello world C example

Add hello world C example


//
//  MRHexKeyboard.h
//
//  Created by Mikk Rätsep on 02/10/13.
//  Copyright (c) 2013 Mikk Rätsep. All rights reserved.
//

@import UIKit;

@interface MRHexKeyboard : UIView <UITextFieldDelegate>

@property(nonatomic, assign) CGFloat height;

@property(nonatomic, assign) BOOL display0xButton;

@property(nonatomic, assign) BOOL add0x;

@end

//
//  MRHexKeyboard.h
//
//  Created by Mikk Rätsep on 02/10/13.
//  Copyright (c) 2013 Mikk Rätsep. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MRHexKeyboard : UIView <UITextFieldDelegate>

@property(nonatomic, assign) CGFloat height;

@property(nonatomic, assign) BOOL display0xButton;

@property(nonatomic, assign) BOOL add0x;

@end

Switch to importing framework header

Switch to importing framework header

Some Apps may not use modules


//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// util_export.h : Defines ANGLE_UTIL_EXPORT, a macro for exporting symbols.

#ifndef UTIL_EXPORT_H_
#define UTIL_EXPORT_H_

#if !defined(ANGLE_UTIL_EXPORT)
#    if defined(_WIN32)
#        if defined(LIBANGLE_UTIL_IMPLEMENTATION)
#            define ANGLE_UTIL_EXPORT __declspec(dllexport)
#        else
#            define ANGLE_UTIL_EXPORT __declspec(dllimport)
#        endif
#    elif defined(__GNUC__)
#        define ANGLE_UTIL_EXPORT __attribute__((visibility("default")))
#    else
#        define ANGLE_UTIL_EXPORT
#    endif
#endif  // !defined(ANGLE_UTIL_EXPORT)

#endif  // UTIL_EXPORT_H_

//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// util_export.h : Defines ANGLE_UTIL_EXPORT, a macro for exporting symbols.

#ifndef UTIL_EXPORT_H_
#define UTIL_EXPORT_H_

#if !defined(ANGLE_UTIL_EXPORT)
#    if defined(_WIN32)
#        if defined(LIBANGLE_UTIL_IMPLEMENTATION)
#            define ANGLE_UTIL_EXPORT __declspec(dllexport)
#        else
#            define ANGLE_UTIL_EXPORT __declspec(dllimport)
#        endif
#    elif defined(__GNUC__)
#        if defined(LIBANGLE_UTIL_IMPLEMENTATION)
#            define ANGLE_UTIL_EXPORT __attribute__((visibility("default")))
#        else
#            define ANGLE_UTIL_EXPORT
#        endif
#    else
#        define ANGLE_UTIL_EXPORT
#    endif
#endif  // !defined(ANGLE_UTIL_EXPORT)

#endif  // UTIL_EXPORT_H_

Revert "util: Always specify default visibility on exports."

This reverts commit 2bf23ea84e4f071c18f01b94748f3be7dccc4019.

Reason for revert: Probably not the right fix. Will export
all angle_utils symbols in places where they shouldn't be.

Original change's description:
> util: Always specify default visibility on exports.
>
> This fixes undefined behaviour with CFI.
>
> Bug: chromium:1015810
> Bug: angleproject:3162
> Change-Id: I58cfb78adabbff05e5b4560dfd70b190411fa26d
> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1869303
> Reviewed-by: Jamie Madill <7e492b4f1c8458024932de3ba475cbf015424c30@chromium.org>
> Commit-Queue: Jamie Madill <7e492b4f1c8458024932de3ba475cbf015424c30@chromium.org>

TBR=ynovikov@chromium.org,7e492b4f1c8458024932de3ba475cbf015424c30@chromium.org

Change-Id: Ie847a9e6506178eb2b14e63a1ee5e9a1775b4548
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1015810, angleproject:3162
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1869546
Reviewed-by: Jamie Madill <7e492b4f1c8458024932de3ba475cbf015424c30@chromium.org>
Commit-Queue: Jamie Madill <7e492b4f1c8458024932de3ba475cbf015424c30@chromium.org>