#include <stdlib.h>
#include <stdio.h>
#include "bomalloc.h"
#include "dummy.h"

#define NUM_ROUNDS 500000

size_t class_for_rnd(int rnd) {
  return ALIGN(CLASS_TO_SIZE(rnd % NUM_CLASSES) - sizeof(block_t));
}

typedef struct {
  int * space;
  size_t size;
} record_t;

int main() {
  int rnd;
  size_t alloc_size;

  srand(0);

  for (rnd = 0; rnd < NUM_ROUNDS; rnd++) {
    alloc_size = class_for_rnd(rnd);
    bomalloc_malloc(alloc_size);
  }
  printf("Performance test complete\n");
  print_bomalloc_stats();
}

#include <stdlib.h>
#include <stdio.h>
#include "bomalloc.h"
#include "dummy.h"

#define NUM_ROUNDS 500

size_t class_for_rnd(int rnd) {
  return ALIGN(CLASS_TO_SIZE(rnd % NUM_CLASSES) - sizeof(block_t));
}

typedef struct {
  int * space;
  size_t size;
} record_t;

int main() {
  int rnd;
  size_t alloc_size;

  srand(0);

  for (rnd = 0; rnd < NUM_ROUNDS; rnd++) {
    alloc_size = class_for_rnd(rnd);
    bomalloc_malloc(alloc_size);
  }
  printf("Performance test complete\n");
  print_bomalloc_stats();
}

Change perf. test to reasonable number

[test] Change perf. test to reasonable number


/*
 * ostream_log_strategy.h
 *
 * Author: Ming Tsang
 * Copyright (c) 2014 Ming Tsang
 * Refer to LICENSE for details
 */

#pragma once

#include <ostream>

#include "libutils/io/log_strategy.h"

namespace utils
{
namespace io
{

template<typename CharT_>
class OstreamLogStrategy : public LogStrategy<CharT_>
{
public:
	void Flush()
	{
		GetStream().flush();
	}

protected:
	explicit OstreamLogStrategy(std::basic_ostream<CharT_> *stream)
			: OstreamLogStrategy(stream, true)
	{}
	OstreamLogStrategy(std::basic_ostream<CharT_> *stream, const bool is_owner);
	virtual ~OstreamLogStrategy();

	std::basic_ostream<CharT_>& GetStream()
	{
		return *m_stream;
	}

private:
	std::basic_ostream<CharT_> *m_stream;
	bool m_is_owner;
};

}
}

#include "ostream_log_strategy.tcc"

/*
 * ostream_log_strategy.h
 *
 * Author: Ming Tsang
 * Copyright (c) 2014 Ming Tsang
 * Refer to LICENSE for details
 */

#pragma once

#include <ostream>

#include "libutils/io/log_strategy.h"

namespace utils
{
namespace io
{

template<typename CharT_>
class OstreamLogStrategy : public LogStrategy<CharT_>
{
public:
	void Flush()
	{
		GetStream().flush();
	}

protected:
	explicit OstreamLogStrategy(std::basic_ostream<CharT_> *stream)
			: OstreamLogStrategy(stream, true)
	{}
	OstreamLogStrategy(std::basic_ostream<CharT_> *stream, const bool is_owner);
	OstreamLogStrategy(const OstreamLogStrategy&) = delete;
	OstreamLogStrategy(OstreamLogStrategy&&) = delete;
	virtual ~OstreamLogStrategy();

	std::basic_ostream<CharT_>& GetStream()
	{
		return *m_stream;
	}

private:
	std::basic_ostream<CharT_> *m_stream;
	bool m_is_owner;
};

}
}

#include "ostream_log_strategy.tcc"

Delete copy and move constructor

Delete copy and move constructor


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

extern char **environ;

/******************************************************************************/
int main(
    int argc,
    char *argv[]
)
{
    FILE * conf_fd;
    config_parse_res_t res;

    if(argc != 2)
    {
        printf("usage: config_parse file\n");
        return EXIT_FAILURE;
    }

    conf_fd = fopen(argv[1], "r");

    if(NULL != conf_fd)
    {
        res = config_parse(conf_fd, 1);
        if(CONFIG_PARSE_OK == res)
        {
            char **env;
            for (env = environ; *env; ++env)
                printf("%s\n", *env);
        }
        else
        {
            printf("Error no. %d while processing file \n", res);
        }

        fclose(conf_fd);
    }
    else
    {
        printf("Could not open the specified file.\n");
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

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

extern char **environ;

/******************************************************************************/
int main(
    int argc,
    char *argv[]
)
{
    FILE * conf_fd;
    config_parse_res_t res;

    if(argc != 2)
    {
        printf("usage: config_parse file ('-' for stdin)\n");
        return EXIT_FAILURE;
    }

    if(0 == strcmp("-", argv[1]))
    {
        conf_fd = stdin;
    }
    else
    {
        conf_fd = fopen(argv[1], "r");
    }

    if(NULL != conf_fd)
    {
        res = config_parse(conf_fd, 1);
        if(CONFIG_PARSE_OK == res)
        {
            char **env;
            for (env = environ; *env; ++env)
                printf("%s\n", *env);
        }
        else
        {
            printf("Error no. %d while processing file \n", res);
        }

        fclose(conf_fd);
    }
    else
    {
        printf("Could not open the specified file.\n");
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

Add option to read from stdin

Add option to read from stdin


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

/*
    psimpl-c
    Copyright (c) 2013 Jamie Bullock <jamie@jamiebullock.com>

    Based on psimpl
    Copyright (c) 2010-2011 Elmar de Koning <edekoning@gmail.com>
*/

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

double *psimpl_simplify_douglas_peucker(
                                        uint8_t dimensions,
                                        double tolerance,
                                        double *original_points,
                                        double *simplified_points
                                        );

#ifdef __cplusplus
}
#endif

Add initial C interface with support for Douglas-Peucker


/* OCaml promise library
 * http://www.ocsigen.org/lwt
 * Copyright (C) 2009-2010 Jérémie Dimino
 *               2009 Mauricio Fernandez
 *               2010 Pierre Chambart
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, with linking exceptions;
 * either version 2.1 of the License, or (at your option) any later
 * version. See COPYING file for details.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#pragma once
#include "lwt_config.h"

#if !defined(LWT_ON_WINDOWS)

#include <caml/mlvalues.h>
#include <caml/unixsupport.h>

int socket_domain(int fd);
#endif

/* OCaml promise library
 * http://www.ocsigen.org/lwt
 * Copyright (C) 2009-2010 Jérémie Dimino
 *               2009 Mauricio Fernandez
 *               2010 Pierre Chambart
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, with linking exceptions;
 * either version 2.1 of the License, or (at your option) any later
 * version. See COPYING file for details.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 */

#pragma once
#include "lwt_config.h"

/*
 * Included in:
 * - unix_mcast_modify_membership.c
 * - unix_mcast_set_loop.c
 * - unix_mcast_set_ttl.c
 * - unix_mcast_utils.c
 */

#if !defined(LWT_ON_WINDOWS)

#include <caml/mlvalues.h>
#include <caml/unixsupport.h>

int socket_domain(int fd);
#endif

Add in comments the files that uses this header


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

/*
 * MAW 3.25.a Write the routines to implement queues using: Linked Lists
 *
 * We use a header node at the very beginning of the linked list.
 *
 * Front: | header node | -> | data node | -> | data node | :Rear
 */
#ifndef _QUEUE_H
#define _QUEUE_H

typedef int ET;

struct QueueRecord;
struct QueueCDT;
typedef struct QueueRecord* PtrToNode;
typedef struct QueueCDT* QueueADT; // naming convention: https://www.cs.bu.edu/teaching/c/queue/linked-list/types.html

int isEmpty(QueueADT Q);
QueueADT createQueue();
void disposeQueue(QueueADT Q);
void makeEmpty(QueueADT Q);
void enqueue(ET elem, QueueADT Q);
ET front(QueueADT Q);
void dequeue(QueueADT Q);
ET frontAndDequeue(QueueADT Q);

QueueADT initializeQueue(ET array[], int lengthArray);
void printQueue(QueueADT Q);

#endif

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

/*
 * MAW 3.25.a Write the routines to implement queues using: Linked Lists
 *
 * We use a header node at the very beginning of the linked list.
 *
 * Front: | header node | -> | data node | -> | data node | :Rear
 */
#ifndef _QUEUE_H
#define _QUEUE_H

typedef int ET;

struct QueueRecord;
struct QueueCDT;
typedef struct QueueRecord* PtrToNode;

// CDT: concrete-type-of-a-queue
// ADT: abstract-type-of-a-queue
typedef struct QueueCDT* QueueADT; // naming convention: https://www.cs.bu.edu/teaching/c/queue/linked-list/types.html

int isEmpty(QueueADT Q);
QueueADT createQueue();
void disposeQueue(QueueADT Q);
void makeEmpty(QueueADT Q);
void enqueue(ET elem, QueueADT Q);
ET front(QueueADT Q);
void dequeue(QueueADT Q);
ET frontAndDequeue(QueueADT Q);

QueueADT initializeQueue(ET array[], int lengthArray);
void printQueue(QueueADT Q);

#endif

Add comment remarks to CDT & ADT

Add comment remarks to CDT & ADT


#pragma once
#ifdef _WIN32
#else
#include <android_native_app_glue.h>
#endif
#include <vector>
#include "BaseGesture.h"

namespace star
{
	struct WinInputState;

	class GestureManager {
	public:
		GestureManager();
		~GestureManager();
		void Update(const Context& context);
		void AddGesture(BaseGesture* gesture);
		void RemoveGesture(BaseGesture* gesture);

#ifdef _WIN32
		void OnUpdateWinInputState();
#else
		void OnTouchEvent(AInputEvent* pEvent);
#endif
	private:
		std::vector<BaseGesture*> m_GestureVec;
		double m_dTime;
		double m_TotalTime;

		GestureManager(const GestureManager& t);
		GestureManager(GestureManager&& t);
		GestureManager& operator=(const GestureManager& t);
	};
}

#pragma once
#ifdef _WIN32
#else
#include <android_native_app_glue.h>
#endif
#include <vector>
#include "BaseGesture.h"

namespace star
{
	struct WinInputState

	// [COMMENT] Gesture-Tags
	// Gestures should also be given a user-defined tag
	// when added to the the manager.

	// this way the user can look them up by tag, rather then
	// on pointer ( for adding one, or removing one, or getting one )
	// Part of the beauty of this kind of managing concept is
	// that the user doesn't have to bother about the pointers
	// as that's all managed inside the manager.

	// On a side note... It's probably a good practice that the user defines
	// these gestures in the Game class, as scenes get created
	// and deleted everytime the screen rotates on android.

	class GestureManager {
	public:
		GestureManager();
		~GestureManager();
		void Update(const Context& context);
		void AddGesture(BaseGesture* gesture);
		void RemoveGesture(BaseGesture* gesture);

#ifdef _WIN32
		void OnUpdateWinInputState();
#else
		void OnTouchEvent(AInputEvent* pEvent);
#endif
	private:
		std::vector<BaseGesture*> m_GestureVec;
		double m_dTime;
		double m_TotalTime;

		GestureManager(const GestureManager& t);
		GestureManager(GestureManager&& t);
		GestureManager& operator=(const GestureManager& t);
	};
}

Comment for pieter in Gesture manager. Read && fix


// Copyright (c) 2015, Cloudera, inc.
// Confidential Cloudera Information: Covered by NDA.

#ifndef KUDU_UTIL_SHARED_PTR_UTIL_H_
#define KUDU_UTIL_SHARED_PTR_UTIL_H_

#include <cstddef>
#include <tr1/memory>

namespace kudu {

// This is needed on TR1. With C++11, std::hash<std::shared_ptr<>> is provided.
template <class T>
struct SharedPtrHashFunctor {
  std::size_t operator()(const std::tr1::shared_ptr<T>& key) const {
    return reinterpret_cast<std::size_t>(key.get());
  }
};

} // namespace kudu

#endif // KUDU_UTIL_SHARED_PTR_UTIL_H_

Add hash function for std::tr1::shared_ptr<>

This exists as a std::hash<> specialization for std::shared_ptr in C++11
but it does not ship with TR1.

Change-Id: Id342f8e9c45f93a2b22e530a689ca18ebf8534b1
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/5998
Tested-by: Michael Percy <e07a1fd797b473a9c849e618aa2ce06d8055760b@cloudera.com>
Reviewed-by: Todd Lipcon <2c763d726a8c2f6afda9be7e0e56a2caa6bb5e6b@cloudera.com>


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

#define NVIC_RAM_VECTOR_ADDRESS   (0x20000000)  // Location of vectors in RAM
#define NVIC_FLASH_VECTOR_ADDRESS (0x0)         // Initial vector position in flash

void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
    uint32_t *vectors = (uint32_t*)SCB->VTOR;
    uint32_t i;

    // Copy and switch to dynamic vectors if the first time called
    if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
        uint32_t *old_vectors = vectors;
        vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
        for (i=0; i<NVIC_NUM_VECTORS; i++) {
            vectors[i] = old_vectors[i];
        }
        SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
    }
    vectors[IRQn + 16] = vector;
}

uint32_t NVIC_GetVector(IRQn_Type IRQn) {
    uint32_t *vectors = (uint32_t*)SCB->VTOR;
    return vectors[IRQn + 16];
}

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

#define NVIC_RAM_VECTOR_ADDRESS   (0x20000000)  // Location of vectors in RAM

static unsigned char vtor_relocated;

void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
    uint32_t *vectors = (uint32_t*)SCB->VTOR;
    uint32_t i;

    // Copy and switch to dynamic vectors if the first time called
    if (!vtor_relocated) {
        uint32_t *old_vectors = vectors;
        vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
        for (i=0; i<NVIC_NUM_VECTORS; i++) {
            vectors[i] = old_vectors[i];
        }
        SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
        vtor_relocated = 1;
    }
    vectors[IRQn + 16] = vector;
}

uint32_t NVIC_GetVector(IRQn_Type IRQn) {
    uint32_t *vectors = (uint32_t*)SCB->VTOR;
    return vectors[IRQn + 16];
}

Fix relocation of vector on STM32.

Fix relocation of vector on STM32.


/**********************************************************************
 * Copyright (c) 2013, 2014 Pieter Wuille                             *
 * Distributed under the MIT software license, see the accompanying   *
 * file COPYING or http://www.opensource.org/licenses/mit-license.php.*
 **********************************************************************/

#ifndef BITCOIN_LIBSECP256K1_CONFIG_H
#define BITCOIN_LIBSECP256K1_CONFIG_H

#undef USE_ASM_X86_64
#undef USE_ENDOMORPHISM
#undef USE_FIELD_10X26
#undef USE_FIELD_5X52
#undef USE_FIELD_INV_BUILTIN
#undef USE_FIELD_INV_NUM
#undef USE_NUM_GMP
#undef USE_NUM_NONE
#undef USE_SCALAR_4X64
#undef USE_SCALAR_8X32
#undef USE_SCALAR_INV_BUILTIN
#undef USE_SCALAR_INV_NUM

#define USE_NUM_NONE 1
#define USE_FIELD_INV_BUILTIN 1
#define USE_SCALAR_INV_BUILTIN 1
#define USE_FIELD_10X26 1
#define USE_SCALAR_8X32 1

#endif /* BITCOIN_LIBSECP256K1_CONFIG_H */

/**********************************************************************
 * Copyright (c) 2013, 2014 Pieter Wuille                             *
 * Distributed under the MIT software license, see the accompanying   *
 * file COPYING or http://www.opensource.org/licenses/mit-license.php.*
 **********************************************************************/

#ifndef BITCOIN_LIBSECP256K1_CONFIG_H
#define BITCOIN_LIBSECP256K1_CONFIG_H

#undef USE_ASM_X86_64
#undef USE_ENDOMORPHISM
#undef USE_FIELD_10X26
#undef USE_FIELD_5X52
#undef USE_FIELD_INV_BUILTIN
#undef USE_FIELD_INV_NUM
#undef USE_NUM_GMP
#undef USE_NUM_NONE
#undef USE_SCALAR_4X64
#undef USE_SCALAR_8X32
#undef USE_SCALAR_INV_BUILTIN
#undef USE_SCALAR_INV_NUM

#define USE_NUM_NONE 1
#define USE_FIELD_INV_BUILTIN 1
#define USE_SCALAR_INV_BUILTIN 1
#define USE_FIELD_10X26 1
#define USE_SCALAR_8X32 1

#define ECMULT_GEN_PREC_BITS 4
#define ECMULT_WINDOW_SIZE 15

#endif /* BITCOIN_LIBSECP256K1_CONFIG_H */

Update MSVC build config for libsecp256k1


#include <stdio.h>
int main() {
	int a = 0;
	while(1) {
		printf("%d\t",a);
		printf("a = 0x%x\n",a);
		int temp;
		scanf("%d",&temp);
		if(temp == 0) {
			continue;
		}
		else {
			a = temp;
		}
		printf("%d\t",a);
		printf("a changed 0x%x\n",a);
	}
	return 0;
}

Test file tab to space

Test file tab to space


/*===- RectConfinementForce.h - libSimulation -=================================
*
*                                  DEMON
*
* This file is distributed under the BSD Open Source License. See LICENSE.TXT
* for details.
*
*===-----------------------------------------------------------------------===*/

#ifndef RECTCONFINEMENTFORCE_H
#define RECTCONFINEMENTFORCE_H

#include "Force.h"
#include "VectorCompatibility.h"

class RectConfinementForce : public Force
{
public:
	RectConfinementForce(Cloud * const myCloud, double confineConstX, double confineConstY); // confinement consts must be positive!
	~RectConfinementForce() {} // destructor

// public functions:
	// Note: currentTime parameter is necessary (due to parent class) but unused
	void force1(const double currentTime); // rk substep 1
	void force2(const double currentTime); // rk substep 2
	void force3(const double currentTime); // rk substep 3
	void force4(const double currentTime); // rk substep 4

	void writeForce(fitsfile * const file, int * const error) const;
	void readForce(fitsfile * const file, int * const error);

private:
// private variables:
	double confineX;
	double confineY;

// private functions:
	void force(const unsigned int currentParticle, const __m128d currentPositionX, const __m128d currentPositionY);
};

#endif // RECTCONFINEMENTFORCE_H

/*===- RectConfinementForce.h - libSimulation -=================================
*
*                                  DEMON
*
* This file is distributed under the BSD Open Source License. See LICENSE.TXT
* for details.
*
*===-----------------------------------------------------------------------===*/

#ifndef RECTCONFINEMENTFORCE_H
#define RECTCONFINEMENTFORCE_H

#include "Force.h"
#include "VectorCompatibility.h"

class RectConfinementForce : public Force
{
public:
	RectConfinementForce(Cloud * const myCloud, double confineConstX, double confineConstY);
	// IMPORTANT: In the above constructor, confineConst_'s must be positive!
	~RectConfinementForce() {} // destructor

// public functions:
	// Note: currentTime parameter is necessary (due to parent class) but unused
	void force1(const double currentTime); // rk substep 1
	void force2(const double currentTime); // rk substep 2
	void force3(const double currentTime); // rk substep 3
	void force4(const double currentTime); // rk substep 4

	void writeForce(fitsfile * const file, int * const error) const;
	void readForce(fitsfile * const file, int * const error);

private:
// private variables:
	double confineX;
	double confineY;

// private functions:
	void force(const unsigned int currentParticle, const __m128d currentPositionX, const __m128d currentPositionY);
};

#endif // RECTCONFINEMENTFORCE_H

Reword comment to be consistent with comment in ConfinementForce.


/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
   Copyright (C) 2009 Red Hat, Inc.

   This library 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.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __MACROS_H
#define __MACROS_H

#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
#define SPICE_ATTR_PRINTF(a,b)                               \
    __attribute__((format(printf,a,b)))
#else
#define SPICE_ATTR_PRINTF(a,b)
#endif /* __GNUC__ */

#if    __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)
#define SPICE_ATTR_NORETURN                                  \
    __attribute__((noreturn))
#else
#define SPICE_ATTR_NORETURN
#endif /* __GNUC__ */

#endif /* __MACROS_H */

/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
   Copyright (C) 2009 Red Hat, Inc.

   This library 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.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __MACROS_H
#define __MACROS_H

#if    __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)
#define SPICE_ATTR_NORETURN                                  \
    __attribute__((noreturn))
#define SPICE_ATTR_PRINTF(a,b)                               \
    __attribute__((format(printf,a,b)))
#else
#define SPICE_ATTR_NORETURN
#define SPICE_ATTR_PRINTF
#endif /* __GNUC__ */

#endif /* __MACROS_H */

Fix min gcc version for __attribute__(format)

We currently use it only on gcc 4.5 or newer, but it was actually
introduced much earlier than that. It's documented in gcc 2.95.3
manual:
http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC84
and glib uses starting from gcc 2.2.5.
This commit uses the same minimum version as glib.

This was causing warnings on RHEL6 systems which have gcc 4.4.7


#ifndef __MENU_STATE_H__
#define __MENU_STATE_H__

#include <vector>
#include "Game_state.h"
#include "Game_object.h"

class Menu_state : public Game_state {
public:
	void update();
	void render();

	bool on_enter();
	bool on_exit();

	const std::string get_state_id() const { return s_menu_id; };
private:
	static const std::string s_menu_id;
	std::vector<Game_object*> m_game_objects;
	static void menu_to_play();
	static void menu_to_exit();
};

#endif

#ifndef __MENU_STATE_H__
#define __MENU_STATE_H__

#include <vector>
#include "Game_state.h"
#include "Game_object.h"

class Menu_state : public Game_state {
public:
	void update();
	void render();

	bool on_enter();
	bool on_exit();

	const std::string get_state_id() const { return s_menu_id; };
private:
	static const std::string s_menu_id;
	std::vector<Game_object*> m_game_objects;
};

#endif

Revert "added button callback functions"

This reverts commit 8962b70fe01cbbd0bd4a82a8c68208ab276add31.


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

#ifndef WEBKIT_GLUE_FORM_DATA_H__
#define WEBKIT_GLUE_FORM_DATA_H__

#include <vector>

#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/form_field.h"

namespace webkit_glue {

// Holds information about a form to be filled and/or submitted.
struct FormData {
  // The name of the form.
  string16 name;
  // GET or POST.
  string16 method;
  // The URL (minus query parameters) containing the form.
  GURL origin;
  // The action target of the form.
  GURL action;
  // true if this form was submitted by a user gesture and not javascript.
  bool user_submitted;
  // A vector of all the input fields in the form.
  std::vector<FormField> fields;

  // Used by FormStructureTest.
  inline bool operator==(const FormData& form) const {
    return (name == form.name &&
            StringToLowerASCII(method) == StringToLowerASCII(form.method) &&
            origin == form.origin &&
            action == form.action &&
            user_submitted == form.user_submitted &&
            fields == form.fields);
  }
};

}  // namespace webkit_glue

#endif  // WEBKIT_GLUE_FORM_DATA_H__

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

#ifndef WEBKIT_GLUE_FORM_DATA_H__
#define WEBKIT_GLUE_FORM_DATA_H__

#include <vector>

#include "base/string_util.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/form_field.h"

namespace webkit_glue {

// Holds information about a form to be filled and/or submitted.
struct FormData {
  // The name of the form.
  string16 name;
  // GET or POST.
  string16 method;
  // The URL (minus query parameters) containing the form.
  GURL origin;
  // The action target of the form.
  GURL action;
  // true if this form was submitted by a user gesture and not javascript.
  bool user_submitted;
  // A vector of all the input fields in the form.
  std::vector<FormField> fields;

  FormData() : user_submitted(false) {}

  // Used by FormStructureTest.
  inline bool operator==(const FormData& form) const {
    return (name == form.name &&
            StringToLowerASCII(method) == StringToLowerASCII(form.method) &&
            origin == form.origin &&
            action == form.action &&
            user_submitted == form.user_submitted &&
            fields == form.fields);
  }
};

}  // namespace webkit_glue

#endif  // WEBKIT_GLUE_FORM_DATA_H__

AutoFill: Add a default constructor for FormData. There are too many places
that create FormDatas, and we shouldn't need to initialize user_submitted for
each call site.

BUG=50423
TEST=none

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

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


//
//  GLKMath.h
//  GLKit
//
//  Copyright (c) 2011, Apple Inc. All rights reserved.
//

#include <GLKit/GLKMathTypes.h>

#include <GLKit/GLKMatrix3.h>
#include <GLKit/GLKMatrix4.h>
#include <GLKit/GLKVector2.h>
#include <GLKit/GLKVector3.h>
#include <GLKit/GLKVector4.h>
#include <GLKit/GLKQuaternion.h>

#include <GLKit/GLKMatrixStack.h>

#include <GLKit/GLKMathUtils.h>

//
//  GLKMath.h
//  GLKit
//
//  Copyright (c) 2011, Apple Inc. All rights reserved.
//

#include <GLKit/GLKMathTypes.h>

#include <GLKit/GLKMatrix3.h>
#include <GLKit/GLKMatrix4.h>
#include <GLKit/GLKVector2.h>
#include <GLKit/GLKVector3.h>
#include <GLKit/GLKVector4.h>
#include <GLKit/GLKQuaternion.h>

//#include <GLKit/GLKMatrixStack.h>

#include <GLKit/GLKMathUtils.h>

Remove GLKMatrixStack ... thanks Twilight! :D


// Copyright (c) 2015 The BitCoin Core developers
// Copyright (c) 2016 The Silk Network developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

/**
 * Functionality for communicating with Tor.
 */
#ifndef SILK_TORCONTROL_H
#define SILK_TORCONTROL_H

#include "scheduler.h"

extern const std::string DEFAULT_TOR_CONTROL;
static const bool DEFAULT_LISTEN_ONION = true;

void StartTorControl(boost::thread_group& threadGroup, CScheduler& scheduler);
void InterruptTorControl();
void StopTorControl();

#endif /* SILK_TORCONTROL_H */

// Copyright (c) 2015 The BitCoin Core developers
// Copyright (c) 2016 The Silk Network developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

/**
 * Functionality for communicating with Tor.
 */
#ifndef SILK_TORCONTROL_H
#define SILK_TORCONTROL_H

#include "scheduler.h"

extern const std::string DEFAULT_TOR_CONTROL;
static const bool DEFAULT_LISTEN_ONION = false;

void StartTorControl(boost::thread_group& threadGroup, CScheduler& scheduler);
void InterruptTorControl();
void StopTorControl();

#endif /* SILK_TORCONTROL_H */

Set Tor Default Monitoring to False

Set Tor Default Monitoring to False


/*===- count.c - The 'count' testing tool ---------------------------------===*\
 *
 *                     The LLVM Compiler Infrastructure
 *
 * This file is distributed under the University of Illinois Open Source
 * License. See LICENSE.TXT for details.
 *
\*===----------------------------------------------------------------------===*/

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

int main(int argc, char **argv) {
  unsigned Count, NumLines, NumRead;
  char Buffer[4096], *End;

  if (argc != 2) {
    fprintf(stderr, "usage: %s <expected line count>\n", argv[0]);
    return 2;
  }

  Count = strtol(argv[1], &End, 10);
  if (*End != '\0' && End != argv[1]) {
    fprintf(stderr, "%s: invalid count argument '%s'\n", argv[0], argv[1]);
    return 2;
  }

  NumLines = 0;
  while ((NumRead = fread(Buffer, 1, sizeof(Buffer), stdin))) {
    unsigned i;

    for (i = 0; i != NumRead; ++i)
      if (Buffer[i] == '\n')
        ++NumLines;
  }

  if (!feof(stdin)) {
    fprintf(stderr, "%s: error reading stdin\n", argv[0]);
    return 3;
  }

  if (Count != NumLines) {
    fprintf(stderr, "Expected %d lines, got %d.\n", Count, NumLines);
    return 1;
  }

  return 0;
}

/*===- count.c - The 'count' testing tool ---------------------------------===*\
 *
 *                     The LLVM Compiler Infrastructure
 *
 * This file is distributed under the University of Illinois Open Source
 * License. See LICENSE.TXT for details.
 *
\*===----------------------------------------------------------------------===*/

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

int main(int argc, char **argv) {
  unsigned Count, NumLines, NumRead;
  char Buffer[4096], *End;

  if (argc != 2) {
    fprintf(stderr, "usage: %s <expected line count>\n", argv[0]);
    return 2;
  }

  Count = strtol(argv[1], &End, 10);
  if (*End != '\0' && End != argv[1]) {
    fprintf(stderr, "%s: invalid count argument '%s'\n", argv[0], argv[1]);
    return 2;
  }

  NumLines = 0;
  do {
    unsigned i;

    NumRead = fread(Buffer, 1, sizeof(Buffer), stdin);

    for (i = 0; i != NumRead; ++i)
      if (Buffer[i] == '\n')
        ++NumLines;
  } while (NumRead == sizeof(Buffer));

  if (!feof(stdin)) {
    fprintf(stderr, "%s: error reading stdin\n", argv[0]);
    return 3;
  }

  if (Count != NumLines) {
    fprintf(stderr, "Expected %d lines, got %d.\n", Count, NumLines);
    return 1;
  }

  return 0;
}

Fix extra fread after EOF, non-wires-crossed version.

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


//
//  BugsnagSink.h
//
//  Created by Conrad Irwin on 2014-10-01.
//
//  Copyright (c) 2014 Bugsnag, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall remain in place
// in this source code.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import <Foundation/Foundation.h>
#import <KSCrash/KSCrash.h>

@interface BugsnagSink : NSObject <KSCrashReportFilter>

@end

//
//  BugsnagSink.h
//
//  Created by Conrad Irwin on 2014-10-01.
//
//  Copyright (c) 2014 Bugsnag, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall remain in place
// in this source code.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import <Foundation/Foundation.h>
#import <KSCrash/KSCrashReportFilter.h>

@interface BugsnagSink : NSObject <KSCrashReportFilter>

@end

Update import to be compatible with KSCrash 1.8.8+


/*
 * cocos2d for iPhone: http://www.cocos2d-iphone.org
 *
 * Copyright (c) 2013-2014 Cocos2D Authors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
#import "CCActionManager.h"

@interface CCActionManager ()
-(void)migrateActions:(id)target from:(CCActionManager*)oldManager;
@end

/*
 * cocos2d for iPhone: http://www.cocos2d-iphone.org
 *
 * Copyright (c) 2013-2014 Cocos2D Authors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
#import "CCActionManager.h"

@interface CCActionManager ()
// TODO eliminate file
@end

Remove unneeded method from private header


#ifndef	FILE_DESCRIPTOR_H
#define	FILE_DESCRIPTOR_H

#include <io/channel.h>

class FileDescriptor : public Channel {
	LogHandle log_;
protected:
	int fd_;
public:
	FileDescriptor(int);
	~FileDescriptor();

	virtual Action *close(EventCallback *);
	virtual Action *read(size_t, EventCallback *);
	virtual Action *write(Buffer *, EventCallback *);

	virtual bool shutdown(bool, bool)
	{
		return (false);
	}
};

#endif /* !FILE_DESCRIPTOR_H */

#ifndef	FILE_DESCRIPTOR_H
#define	FILE_DESCRIPTOR_H

#include <io/channel.h>

class FileDescriptor : public Channel {
	LogHandle log_;
protected:
	int fd_;
public:
	FileDescriptor(int);
	~FileDescriptor();

	virtual Action *close(EventCallback *);
	virtual Action *read(size_t, EventCallback *);
	virtual Action *write(Buffer *, EventCallback *);

	virtual bool shutdown(bool, bool)
	{
		return (true);
	}
};

#endif /* !FILE_DESCRIPTOR_H */

Return success rather than failure from shutdown() on FileDescriptor, since it
is entirely immaterial.

git-svn-id: 9e2532540f1574e817ce42f20b9d0fb64899e451@333 4068ffdb-0463-0410-8185-8cc71e3bd399


typedef struct {
	int		cluster;				/* Condor Cluster # */
	int		proc;					/* Condor Proc # */
	int		job_class;				/* STANDARD, VANILLA, PVM, PIPE, ... */
	uid_t	uid;					/* Execute job under this UID */
	gid_t	gid;					/* Execute job under this pid */
	pid_t	virt_pid;				/* PVM virt pid of this process */
	int		soft_kill_sig;			/* Use this signal for a soft kill */
	char	*a_out_name;			/* Where to get executable file */
	char	*cmd;					/* Command name given by the user */
	char	*args;					/* Command arguments given by the user */
	char	*env;					/* Environment variables */
	char	*iwd;					/* Initial working directory */
	BOOLEAN	ckpt_wanted;			/* Whether user wants checkpointing */
	BOOLEAN	is_restart;				/* Whether this run is a restart */
	BOOLEAN	coredump_limit_exists;	/* Whether user wants to limit core size */
	int		coredump_limit;			/* Limit in bytes */
} STARTUP_INFO;

Structure defining information starter needs from the shadow to start up a user job.


#pragma once

#include "../definitions.h"
#include "log.h"

namespace bitwise {

inline u16 compose_bytes(const u8 high, const u8 low) {
    return static_cast<u16>((high << 8) + low);
}

inline bool check_bit(const u8 value, const u8 bit) {
    return (value & (1 << bit)) != 0;
}

inline u8 set_bit(const u8 value, const u8 bit) {
    auto value_set = value | (1 << bit);
    return static_cast<u8>(value_set);
}

inline u8 clear_bit(const u8 value, const u8 bit) {
    auto value_cleared = value & ~(1 << bit);
    return static_cast<u8>(value_cleared);
}

inline u8 set_bit_to(const u8 value, const u8 bit, bool bit_on) {
    return bit_on ? set_bit(value, bit) : clear_bit(value, bit);
}

} // namespace bitwise

#pragma once

#include "../definitions.h"
#include "log.h"

namespace bitwise {

inline u16 compose_bytes(const u8 high, const u8 low) {
    return static_cast<u16>((high << 8) + low);
}

inline bool check_bit(const u8 value, const u8 bit) {
    return (value & (1 << bit)) != 0;
}

inline u8 bit_value(const u8 value, const u8 bit) {
    return (value >> bit) & 1;
}

inline u8 set_bit(const u8 value, const u8 bit) {
    auto value_set = value | (1 << bit);
    return static_cast<u8>(value_set);
}

inline u8 clear_bit(const u8 value, const u8 bit) {
    auto value_cleared = value & ~(1 << bit);
    return static_cast<u8>(value_cleared);
}

inline u8 set_bit_to(const u8 value, const u8 bit, bool bit_on) {
    return bit_on ? set_bit(value, bit) : clear_bit(value, bit);
}

} // namespace bitwise

Add a bit_value function for the numeric value of a single bit


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

/**
 * @addtogroup  core_util
 * @{
 *
 * @file        crash.h
 * @brief       Crash handling header
 *
 * Define a panic() function that allows to stop/reboot the system
 *  when an unrecoverable problem has occured.
 *
 * @author      Kévin Roussel <Kevin.Roussel@inria.fr>
 */

#ifndef __CRASH_H
#define __CRASH_H

#include "kernel.h"

/** Handle an unrecoverable error by halting or rebooting the system.
    A numeric code indicating the failure reason can be given
    as the ::crash_code parameter.
    Detailing the failure is possible using the ::message parameter.
    This function should serve a similar purpose than the panic()
    function of Unix/Linux kernels.

    if DEVELHELP macro is defined, system will be halted;
    system will be rebooted otherwise.

    WARNING: this function NEVER returns! */
NORETURN void core_panic(int crash_code, const char *message);

/** @} */
#endif /* __CRASH_H */

Add a mechanism for handling fatal errors (and reboots)


#pragma once

#include "../Controls/Dialog.h"
#include "../resource.h"

class ProgressWindow : public Dialog {
public:
    ProgressWindow() :
    Dialog(L"3RVX-UpdateProgress", MAKEINTRESOURCE(IDD_DOWNLOAD)) {
        ShowWindow(Dialog::DialogHandle(), SW_SHOWNORMAL);
    }

};

Add class for the progress window

Add class for the progress window


// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited -dwarf-ext-refs \
// RUN:     -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \
// RUN:     %s -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
#include "DebugSubmoduleA.h"
#include "DebugSubmoduleB.h"

// CHECK: !DICompileUnit
// CHECK-NOT: !DICompileUnit
// CHECK: !DIModule(scope: ![[PARENT:.*]], name: "DebugSubmoduleA"
// CHECK: [[PARENT]] = !DIModule(scope: null, name: "DebugSubmodules"
// CHECK: !DIModule(scope: ![[PARENT]], name: "DebugSubmoduleB"
// CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}DebugSubmodules
// CHECK-SAME:                 dwoId:
// CHECK-NOT: !DICompileUnit

// RUN: rm -rf %t
// RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited -dwarf-ext-refs \
// RUN:     -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \
// RUN:     %s -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
//
// RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited -dwarf-ext-refs \
// RUN:     -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \
// RUN:     -fmodules-local-submodule-visibility \
// RUN:     %s -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
#include "DebugSubmoduleA.h"
#include "DebugSubmoduleB.h"

// CHECK: !DICompileUnit
// CHECK-NOT: !DICompileUnit
// CHECK: !DIModule(scope: ![[PARENT:.*]], name: "DebugSubmoduleA"
// CHECK: [[PARENT]] = !DIModule(scope: null, name: "DebugSubmodules"
// CHECK: !DIModule(scope: ![[PARENT]], name: "DebugSubmoduleB"
// CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}DebugSubmodules
// CHECK-SAME:                 dwoId:
// CHECK-NOT: !DICompileUnit

Add a test that local submodule visibility has no effect on debug info

rdar://problem/27876262

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


#include <gmp.h>

#include "m-array.h"
#include "m-algo.h"

ARRAY_DEF(mpz, mpz_t, M_CLASSIC_OPLIST(mpz))
ALGO_DEF(array_mpz, ARRAY_OPLIST(mpz, M_CLASSIC_OPLIST(mpz)))

static inline void my_mpz_inc(mpz_t d, const mpz_t a){
  mpz_add(d, d, a);
}
static inline void my_mpz_sqr(mpz_t d, const mpz_t a){
  mpz_mul(d, a, a);
}

int main(void)
{
  mpz_t z;
  mpz_init_set_ui(z, 1);
  array_mpz_t a;
  array_mpz_init(a);
  array_mpz_push_back(a, z);
  for(size_t i = 2 ; i < 1000; i++) {
    mpz_mul_ui(z, z, i);
    array_mpz_push_back(a, z);
  }
  /* z = sum (a[i]^2) */
  array_mpz_map_reduce (&z, a, my_mpz_inc, my_mpz_sqr);
  gmp_printf ("Z=%Zd\n", z);
  array_mpz_clear(a);
  mpz_clear(z);
}

#include <gmp.h>

#include "m-array.h"
#include "m-algo.h"

ARRAY_DEF(mpz, mpz_t, M_CLASSIC_OPLIST(mpz))
ALGO_DEF(array_mpz, ARRAY_OPLIST(mpz, M_CLASSIC_OPLIST(mpz)))

static inline void my_mpz_inc(mpz_t *d, const mpz_t a){
  mpz_add(*d, *d, a);
}
static inline void my_mpz_sqr(mpz_t *d, const mpz_t a){
  mpz_mul(*d, a, a);
}

int main(void)
{
  mpz_t z;
  mpz_init_set_ui(z, 1);
  array_mpz_t a;
  array_mpz_init(a);
  array_mpz_push_back(a, z);
  for(size_t i = 2 ; i < 1000; i++) {
    mpz_mul_ui(z, z, i);
    array_mpz_push_back(a, z);
  }
  /* z = sum (a[i]^2) */
  array_mpz_map_reduce (&z, a, my_mpz_inc, my_mpz_sqr);
  gmp_printf ("Z=%Zd\n", z);
  array_mpz_clear(a);
  mpz_clear(z);
}

Update example with new constraints on map/reduce prototype.


#ifndef util_h
#define util_h

#define min(a,b) ((a)<(b)?(a):(b))

int warn(const char *s);

void v();

#endif /*util_h*/

#ifndef util_h
#define util_h

#define min(a,b) ((a)<(b)?(a):(b))

int warn(const char *s);

void v();

#ifdef DEBUG
#define dprintf(fmt, args...) fprintf(stderr, fmt, ##args)
#else
#define dprintf(fmt, ...) (0)
#endif

#endif /*util_h*/

Add a debugging print macro.

Add a debugging print macro.


/* Copyright 2017 IBM Corp.
 *
 * 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 __PRD_FW_MSG_H
#define __PRD_FW_MSG_H

#include <types.h>

/* Messaging structure for the opaque channel between OPAL and HBRT. This
 * format is used for the firmware_request and firmware_notify interfaces
 */
enum {
	PRD_FW_MSG_TYPE_REQ_NOP = 0,
	PRD_FW_MSG_TYPE_RESP_NOP = 1,
};

struct prd_fw_msg {
	__be64		type;
};

#define PRD_FW_MSG_BASE_SIZE	sizeof(__be64)

#endif /* __PRD_FW_MSG_H */

/* Copyright 2017 IBM Corp.
 *
 * 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 __PRD_FW_MSG_H
#define __PRD_FW_MSG_H

#include <types.h>

/* Messaging structure for the opaque channel between OPAL and HBRT. This
 * format is used for the firmware_request and firmware_notify interfaces
 */
enum {
	PRD_FW_MSG_TYPE_REQ_NOP = 0,
	PRD_FW_MSG_TYPE_RESP_NOP = 1,
	PRD_FW_MSG_TYPE_RESP_GENERIC = 2,
	PRD_FW_MSG_TYPE_REQ_HCODE_UPDATE = 3,
	PRD_FW_MSG_TYPE_HBRT_FSP = 4,
	PRD_FW_MSG_TYPE_ERROR_LOG = 5,
	PRD_FW_MSG_TYPE_FSP_HBRT = 6,
};

struct prd_fw_msg {
	__be64		type;
	union {
		struct {
			__be64	status;
		} generic_resp;
	};
};

#define PRD_FW_MSG_BASE_SIZE	sizeof(__be64)

#endif /* __PRD_FW_MSG_H */

prd: Add generic response structure inside prd_fw_msg

This patch adds generic response structure. Also sync prd_fw_msg type
macros with hostboot.

Next patch makes use of this structure/macro.

CC: Jeremy Kerr <68a658b44bbaefab3ef5cd231967195fc0ff9d69@ozlabs.org>
Signed-off-by: Vasant Hegde <a6d753843573f7bfed5075c1e875b0be8007a0ab@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>


#include "QuadCopterConfig.h"
#include "mavlink.h"

#define MAV_MAX_LEN 263

struct waypoint_t mission_wp_list = {0};
int waypoint_cnt = 0;
int cur_waypoint = 0;

mavlink_message_t msg;
uint8_t buf[MAV_MAX_LEN];

void mission_read_waypoint_list()
{
}

void mission_write_waypoint_list()
{
}

void mission_clear_waypoint()
{
	mavlink_msg_mission_ack_pack(1, 200, &msg, 255, 0, 0);
	send_package(buf, &msg);
}

void mission_set_new_current_waypoint()
{
}

#include "QuadCopterConfig.h"
#include "mavlink.h"

#define MAV_MAX_LEN 263

struct waypoint_t mission_wp_list = {0};
int waypoint_cnt = 0;
int cur_waypoint = 0;

mavlink_message_t msg;
uint8_t buf[MAV_MAX_LEN];

void push_waypoint_node(struct waypoint_t *waypoint)
{
}

void free_waypoint_list(struct waypoint_t *waypoint)
{
}

void mission_read_waypoint_list()
{
}

void mission_write_waypoint_list()
{
}

void mission_clear_waypoint()
{
	mavlink_msg_mission_ack_pack(1, 200, &msg, 255, 0, 0);
	send_package(buf, &msg);
}

void mission_set_new_current_waypoint()
{
}

Create the waypoint structure operating function prototype


/* custom ftoption.h which selects the minimum features needed by mupdf */

#include <freetype/config/ftoption.h>

#undef FT_CONFIG_OPTION_USE_LZW
#undef FT_CONFIG_OPTION_USE_ZLIB
#undef FT_CONFIG_OPTION_USE_BZIP2
#undef FT_CONFIG_OPTION_USE_PNG
#undef FT_CONFIG_OPTION_USE_HARFBUZZ
#undef FT_CONFIG_OPTION_MAC_FONTS
#undef FT_CONFIG_OPTION_INCREMENTAL

#undef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#undef TT_CONFIG_OPTION_SFNT_NAMES
#undef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#undef TT_CONFIG_OPTION_BDF

#undef T1_CONFIG_OPTION_NO_AFM
#undef T1_CONFIG_OPTION_NO_MM_SUPPORT

#undef CFF_CONFIG_OPTION_OLD_ENGINE

/* custom ftoption.h which selects the minimum features needed by mupdf */

#include <freetype/config/ftoption.h>

#undef FT_CONFIG_OPTION_USE_LZW
#undef FT_CONFIG_OPTION_USE_ZLIB
#undef FT_CONFIG_OPTION_USE_BZIP2
#undef FT_CONFIG_OPTION_USE_PNG
#undef FT_CONFIG_OPTION_USE_HARFBUZZ
#undef FT_CONFIG_OPTION_MAC_FONTS
#undef FT_CONFIG_OPTION_INCREMENTAL
#define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT

#undef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
#undef TT_CONFIG_OPTION_SFNT_NAMES
#undef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#undef TT_CONFIG_OPTION_BDF

#undef T1_CONFIG_OPTION_NO_AFM
#undef T1_CONFIG_OPTION_NO_MM_SUPPORT

#undef CFF_CONFIG_OPTION_OLD_ENGINE

Disable freetype stream support, avoiding FILE interface.


#ifndef FIX_UNISTD_H
#define FIX_UNISTD_H

#include <unistd.h>

/*
  For some reason the g++ include files on Ultrix 4.3 fail to provide
  these prototypes, even though the Ultrix 4.2 versions did...
  Once again, OSF1 also chokes, unless _AES_SOURCE(?) is defined JCP
*/
#if defined(ULTRIX43) || defined(SUNOS41) || defined(OSF1)

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

#if defined(SUNOS41) || defined(ULTRIX43)
	typedef unsigned long ssize_t;
#endif

#if defined(__STDC__) || defined(__cplusplus)
	int symlink( const char *, const char * );
	void *sbrk( ssize_t );
	int gethostname( char *, int );
#else
	int symlink();
	char *sbrk();
	int gethostname();
#endif

#if defined(__cplusplus)
}
#endif

#endif	/* ULTRIX43 */

#endif

#ifndef FIX_UNISTD_H
#define FIX_UNISTD_H

#if defined(SUNOS41)
#	define read _hide_read
#	define write _hide_write
#endif

#include <unistd.h>

#if defined(SUNOS41)
#	undef read
#	undef write
#endif

/*
  For some reason the g++ include files on Ultrix 4.3 fail to provide
  these prototypes, even though the Ultrix 4.2 versions did...
  Once again, OSF1 also chokes, unless _AES_SOURCE(?) is defined JCP
*/
#if defined(ULTRIX43) || defined(SUNOS41) || defined(OSF1)

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

#if defined(SUNOS41) || defined(ULTRIX43)
	typedef unsigned long ssize_t;
#endif

#if defined(__STDC__) || defined(__cplusplus)
	int symlink( const char *, const char * );
	void *sbrk( ssize_t );
	int gethostname( char *, int );
#	if defined(SUNOS41)
		ssize_t read( int, void *, size_t );
		ssize_t write( int, const void *, size_t );
#	endif
#else
	int symlink();
	char *sbrk();
	int gethostname();
#endif

#if defined(__cplusplus)
}
#endif

#endif	/* ULTRIX43 */

#endif

Fix up prototypes for read() and write() on Suns.


#include <stdio.h>

int main(int argc, char *argv[]){
  int s, a, b, c;
  s = 0;
  a = 1;
  b = 1;
  c = a + b;
  while(c < 4000000L){
    s += c;
    a = b + c;
    b = a + c;
    c = a + b;
  }
  printf("%d\n", s);
}

Add C implementation for problem 2

Add C implementation for problem 2


#ifndef hcidumpinternal_H
#define hcidumpinternal_H

#include <stdbool.h>
#include <stdint.h>

typedef struct beacon_info {
    char uuid[20];
    int32_t code;
    int32_t manufacturer;
    int32_t major;
    int32_t minor;
    int32_t power;
    int32_t calibrated_power;
    int32_t rssi;
    int64_t time;
} beacon_info;

// The callback function invoked for each beacon event seen by hcidumpinternal
// const char * uuid, int32_t code, int32_t manufacturer, int32_t major, int32_t minor, int32_t power, int32_t rssi, int64_t time
typedef bool (*beacon_event)(const beacon_info *);

// The function hcidumpinternal exports
int32_t scan_frames(int32_t dev, beacon_event callback);
#endif

#ifndef hcidumpinternal_H
#define hcidumpinternal_H

#include <stdbool.h>
#include <stdint.h>

typedef struct beacon_info {
    char uuid[36];
    int32_t code;
    int32_t manufacturer;
    int32_t major;
    int32_t minor;
    int32_t power;
    int32_t calibrated_power;
    int32_t rssi;
    int64_t time;
} beacon_info;

// The callback function invoked for each beacon event seen by hcidumpinternal
// const char * uuid, int32_t code, int32_t manufacturer, int32_t major, int32_t minor, int32_t power, int32_t rssi, int64_t time
typedef bool (*beacon_event)(const beacon_info *);

// The function hcidumpinternal exports
int32_t scan_frames(int32_t dev, beacon_event callback);
#endif

Correct the allowed size of the uuid code


#pragma once

#include <spotify/json.hpp>

#include <noise/noise.h>
#include "noise/module/Wrapper.h"
#include "noise/module/CornerCombinerBase.h"

namespace spotify
{
namespace json
{

template<>
struct default_codec_t<noise::module::Wrapper<noise::module::CornerCombinerBase>>
{
    using CornerCombinerBaseWrapper = noise::module::Wrapper<noise::module::CornerCombinerBase>;
    static codec::object_t<CornerCombinerBaseWrapper> codec()
    {
        auto codec = codec::object<CornerCombinerBaseWrapper>();
        codec.required("type", codec::eq<std::string>("CornerCombinerBase"));
        codec.optional("Power",
                       [](CornerCombinerBase CornerCombinerBaseWrapper& mw) {return mw.module.GetPower(); },
                       [](CornerCombinerBaseWrapper& mw, double power) {mw.module.SetPower(power); });
        return codec;
    }
};
}
}

#pragma once

#include <spotify/json.hpp>

#include <noise/noise.h>
#include "noise/module/Wrapper.h"
#include "noise/module/CornerCombinerBase.h"

namespace spotify
{
namespace json
{

template<>
struct default_codec_t<noise::module::Wrapper<noise::module::CornerCombinerBase>>
{
    using CornerCombinerBaseWrapper = noise::module::Wrapper<noise::module::CornerCombinerBase>;
    static codec::object_t<CornerCombinerBaseWrapper> codec()
    {
        auto codec = codec::object<CornerCombinerBaseWrapper>();
        codec.required("type", codec::eq<std::string>("CornerCombinerBase"));
        codec.optional("Power",
                       [](const CornerCombinerBaseWrapper& mw) {return mw.module.GetPower(); },
                       [](CornerCombinerBaseWrapper& mw, double power) {mw.module.SetPower(power); });
        return codec;
    }
};
}
}

Fix find&replace error in CornerCombinerBase codec


#include <stdlib.h>

/**
 * @author: Hendrik Werner
 */

#define BOARD_HEIGHT 50
#define BOARD_WIDTH 50

typedef struct Position {
	int row;
	int col;
} Position;

typedef enum Cell {
	EMPTY
	,SNAKE
	,FOOD
} Cell;

typedef Cell Board[BOARD_HEIGHT][BOARD_WIDTH];

typedef enum Direction {LEFT, UP, RIGHT, DOWN} Direction;

int main() {
	return EXIT_SUCCESS;
}

#include <stdlib.h>

/**
 * @author: Hendrik Werner
 */

#define BOARD_HEIGHT 50
#define BOARD_WIDTH 50

typedef struct Position {
	int row;
	int col;
} Position;

typedef enum Cell {
	EMPTY
	,SNAKE
	,FOOD
} Cell;

typedef Cell Board[BOARD_HEIGHT][BOARD_WIDTH];

typedef enum Direction {LEFT, UP, RIGHT, DOWN} Direction;

/**
 * Represent a cell using a character.
 *
 * @return A character representing the content of the cell provided.
 */
char representCell(const Cell c) {
	switch (c) {
		case SNAKE: return 'S';
		case FOOD: return 'F';
		default: return '.';
	}
}

int main() {
	return EXIT_SUCCESS;
}

Add a function to represents cells as characters.


/*
 Copyright 2012 Moblico Solutions LLC

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this work except in compliance with the License.
 You may obtain a copy of the License in the LICENSE file, or at:

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

#import <MoblicoSDK/MLCService.h>
@class MLCSettings;
NS_ASSUME_NONNULL_BEGIN

typedef void(^MLCSettingsServiceCompletionHandler)(id _Nullable MLCSettings,  NSError * _Nullable error, NSHTTPURLResponse * _Nullable response);

@interface MLCSettingsService : MLCService

+ (instancetype)readSettings:(MLCSettingsServiceCompletionHandler)handler;
+ (MLCSettings *)settings;
+ (void)overrideSettings:(NSDictionary *)settings;

@end

@interface MLCSettings : NSObject

- (nullable id)objectForKey:(NSString *)key;
- (nullable id)objectForKeyedSubscript:(NSString *)key;

@end

NS_ASSUME_NONNULL_END

/*
 Copyright 2012 Moblico Solutions LLC

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this work except in compliance with the License.
 You may obtain a copy of the License in the LICENSE file, or at:

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

#import <MoblicoSDK/MLCService.h>
@class MLCSettings;
NS_ASSUME_NONNULL_BEGIN

typedef void(^MLCSettingsServiceCompletionHandler)(id _Nullable MLCSettings,  NSError * _Nullable error, NSHTTPURLResponse * _Nullable response);

@interface MLCSettingsService : MLCService

+ (instancetype)readSettings:(MLCSettingsServiceCompletionHandler)handler;
+ (MLCSettings *)settings;
+ (void)overrideSettings:(nullable NSDictionary *)settings;

@end

@interface MLCSettings : NSObject

- (nullable id)objectForKey:(NSString *)key;
- (nullable id)objectForKeyedSubscript:(NSString *)key;

@end

NS_ASSUME_NONNULL_END

Allow overrideSettings to take a nil value.


//
//  EKNAppDelegate.h
//  EdKeyNote
//
//  Created by canviz on 9/22/14.
//  Copyright (c) 2014 canviz. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "EKNDeskTopViewController.h"
#import "EKNLoginViewController.h"

@interface EKNAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) EKNLoginViewController *viewController;
@property (strong, nonatomic) UINavigationController *naviController;

@end

//
//  EKNAppDelegate.h
//  EdKeyNote
//
//  Created by canviz on 9/22/14.
//  Copyright (c) 2014 canviz. All rights reserved.
//

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

@interface EKNAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@property (strong, nonatomic) EKNLoginViewController *viewController;
@property (strong, nonatomic) UINavigationController *naviController;

@end

Remove the import for EKNDeskTopViewController.h


/*
** Config file for dynamically-loaded ppc/cfm68k plugin modules.
*/

/* #define USE_GUSI1		/* Stdio implemented with GUSI */
#define USE_GUSI2		/* Stdio implemented with GUSI */
#define WITH_THREAD		/* Use thread support (needs GUSI 2, not GUSI 1) */
#define USE_MSL			/* Use MSL libraries */
#ifdef USE_MSL
#define MSL_USE_PRECOMPILED_HEADERS 0	/* Don't use precomp headers: we include our own */
#include <ansi_prefix.mac.h>
#endif

/*
** Config file for dynamically-loaded ppc/cfm68k plugin modules.
*/

/* #define USE_GUSI1		/* Stdio implemented with GUSI */
#define USE_GUSI2		/* Stdio implemented with GUSI */
#if defined(USE_GUSI1) || defined(USE_GUSI2)
#define USE_GUSI
#endif
#define WITH_THREAD		/* Use thread support (needs GUSI 2, not GUSI 1) */
#define USE_MSL			/* Use MSL libraries */
#ifdef USE_MSL
#define MSL_USE_PRECOMPILED_HEADERS 0	/* Don't use precomp headers: we include our own */
#include <ansi_prefix.mac.h>
#endif

Define USE_GUSI if USE_GUSI1 or USE_GUSI2 is defined.


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

#ifndef LLVM_CLANG_SEMA_CODECOMPLETEOPTIONS_H
#define LLVM_CLANG_SEMA_CODECOMPLETEOPTIONS_H

/// Options controlling the behavior of code completion.
class CodeCompleteOptions {
public:
  ///< Show macros in code completion results.
  unsigned IncludeMacros : 1;

  ///< Show code patterns in code completion results.
  unsigned IncludeCodePatterns : 1;

  ///< Show top-level decls in code completion results.
  unsigned IncludeGlobals : 1;

  ///< Show brief documentation comments in code completion results.
  unsigned IncludeBriefComments : 1;

  CodeCompleteOptions() :
      IncludeMacros(0),
      IncludeCodePatterns(0),
      IncludeGlobals(1),
      IncludeBriefComments(0)
  { }
};

#endif

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

#ifndef LLVM_CLANG_SEMA_CODECOMPLETEOPTIONS_H
#define LLVM_CLANG_SEMA_CODECOMPLETEOPTIONS_H

/// Options controlling the behavior of code completion.
class CodeCompleteOptions {
public:
  /// Show macros in code completion results.
  unsigned IncludeMacros : 1;

  /// Show code patterns in code completion results.
  unsigned IncludeCodePatterns : 1;

  /// Show top-level decls in code completion results.
  unsigned IncludeGlobals : 1;

  /// Show brief documentation comments in code completion results.
  unsigned IncludeBriefComments : 1;

  CodeCompleteOptions() :
      IncludeMacros(0),
      IncludeCodePatterns(0),
      IncludeGlobals(1),
      IncludeBriefComments(0)
  { }
};

#endif

Fix comments: these are not trailing comments

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


#pragma once
#include <gsl/gsl_byte>
#include <gsl/span>

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

		virtual size_t getSerializedSize() = 0;
		virtual void serializeTo(gsl::span<gsl::byte> dst) = 0;
	};
}

#pragma once
#include <gsl/gsl>

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

		virtual size_t getSerializedSize() = 0;
		virtual void serializeTo(gsl::span<gsl::byte> dst) = 0;
	};
}

Change include to fix compilation.

Change include  to fix compilation.


//===- Transforms/Instrumentation.h - Instrumentation passes ----*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This files defines constructor functions for instrumentation passes.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_H
#define LLVM_TRANSFORMS_INSTRUMENTATION_H

namespace llvm {

class Pass;

//===----------------------------------------------------------------------===//
// Support for inserting LLVM code to print values at basic block and function
// exits.
//
Pass *createTraceValuesPassForFunction();     // Just trace function entry/exit
Pass *createTraceValuesPassForBasicBlocks();  // Trace BB's and methods

} // End llvm namespace

#endif

//===- Transforms/Instrumentation.h - Instrumentation passes ----*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This files defines constructor functions for instrumentation passes.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_H
#define LLVM_TRANSFORMS_INSTRUMENTATION_H

namespace llvm {

class ModulePass;
class FunctionPass;

// Reoptimizer support pass: add instrumentation calls to back-edges of loops
ModulePass *createLoopInstrumentationPass ();

// Reoptimizer support pass: combine multiple back-edges w/ same target into one
FunctionPass *createCombineBranchesPass();

// Reoptimizer support pass: emit table of global functions
FunctionPass *createEmitFunctionTablePass ();

//===----------------------------------------------------------------------===//
// Support for inserting LLVM code to print values at basic block and function
// exits.
//

// Just trace function entry/exit
FunctionPass *createTraceValuesPassForBasicBlocks();

// Trace BB's and methods
FunctionPass *createTraceValuesPassForFunction();

} // End llvm namespace

#endif

Add accessor function prototypes for reoptimizer support passes.
Make accessors return FunctionPass* as appropriate.

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


#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040"
#define MICROPY_HW_MCU_NAME "rp2040"

#define MICROPY_HW_NEOPIXEL (&pin_GPIO16)

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2)

#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18)
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19)
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO20)

// #define DEFAULT_UART_BUS_RX (&pin_PA11)
// #define DEFAULT_UART_BUS_TX (&pin_PA10)

// Flash chip is GD25Q32 connected over QSPI
#define TOTAL_FLASH_SIZE (4 * 1024 * 1024)

#define MICROPY_HW_BOARD_NAME "Adafruit Feather RP2040"
#define MICROPY_HW_MCU_NAME "rp2040"

#define MICROPY_HW_NEOPIXEL (&pin_GPIO16)

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO3)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO2)

#define DEFAULT_SPI_BUS_SCK (&pin_GPIO18)
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO19)
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO20)

// #define DEFAULT_UART_BUS_RX (&pin_PA11)
// #define DEFAULT_UART_BUS_TX (&pin_PA10)

// Flash chip is GD25Q64 connected over QSPI
#define TOTAL_FLASH_SIZE (8 * 1024 * 1024)

Update Feather RP2040 to 8MB

Update Feather RP2040 to 8MB


#ifndef _SERIAL_H_
#define _SERIAL_H_

#include "hardware/packet.h"

#define SERIAL_SUCCESS 1
#define SERIAL_ERROR !SERIAL_SUCCESS

unsigned int serial_connect(char device[]);
unsigned int serial_transmit(struct Packet packet);
unsigned int serial_close();

#endif

#ifndef _SERIAL_H_
#define _SERIAL_H_

#include "hardware/packet.h"

#define SERIAL_SUCCESS 1
#define SERIAL_ERROR (!SERIAL_SUCCESS)

unsigned int serial_connect(char device[]);
unsigned int serial_transmit(struct Packet packet);
unsigned int serial_close();

#endif

Add brackets around SERIAL_ERROR definition for compatibility


#ifndef PECTOR_MALLOC_ALLOCATOR_COMPAT_H
#define PECTOR_MALLOC_ALLOCATOR_COMPAT_H

#ifdef __APPLE__
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif

#if defined __GNUC__ || defined _WIN32 || defined __APPLE__

#define PT_SIZE_AWARE_COMPAT

#if defined __GNUC__ && !defined _WIN32 && !defined __APPLE__
#define PT_MALLOC_USABLE_SIZE(p) malloc_usable_size(p)
#elif defined _WIN32
#define PT_MALLOC_USABLE_SIZE(p) _msize(p)
#elif defined __APPLE__
#define PTçMALLOC_USABLE_SIZE(p) malloc_size(p)
#endif

#endif // defined __GNUC__ || defined _WIN32 || defined __APPLE__

#endif

#ifndef PECTOR_MALLOC_ALLOCATOR_COMPAT_H
#define PECTOR_MALLOC_ALLOCATOR_COMPAT_H

#ifdef __APPLE__
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif

#if defined __GNUC__ || defined _WIN32 || defined __APPLE__ || defined __FreeBSD__

#define PT_SIZE_AWARE_COMPAT

#if defined _WIN32
#define PT_MALLOC_USABLE_SIZE(p) _msize(p)
#elif defined __APPLE__
#define PT_MALLOC_USABLE_SIZE(p) malloc_size(p)
#elif defined __GNUC__ || defined __FreeBSD__
#define PT_MALLOC_USABLE_SIZE(p) malloc_usable_size(p)
#endif

#endif // defined __GNUC__ || defined _WIN32 || defined __APPLE__

#endif

Add FreeBSD as platform supporting malloc_usable_size


/******************************
* AUTHOR : GUSTAVO MARTINS
* USE AS YOU WISH
* DATE : 11/25/2015
* LANG : ANSI C
* DESCR : A VERY SIMPLE
* 3D VECTOR LIBRARY
******************************/

#ifndef TVECTOR_H
#define TVECTOR_H

typedef struct SVector *TVector;

TVector createVector(double x, double y, double z);
TVector createNullVector();
void freeVector(TVector vec);

double getX(TVector vec);
double getY(TVector vec);
double getZ(TVector vec);

void setX(TVector vec, double x);
void setY(TVector vec, double y);
void setZ(TVector vec, double z);

double getLength(TVector vec);
void normalizeVector(TVector vec);

double doDotProduct(TVector vecA, TVector vecB, double angle);
TVector doScalarProduct(TVector vec, double scalar);
TVector doCrossProduct(TVector vecA, TVector vecB);
TVector doNormalize(TVector vec);

TVector createCopyVector(TVector vec);

#endif

/******************************
* AUTHOR : GUSTAVO MARTINS
* USE AS YOU WISH
* DATE : 11/25/2015
* LANG : ANSI C
* DESCR : A VERY SIMPLE
* 3D VECTOR LIBRARY
******************************/

#ifndef TVECTOR_H
#define TVECTOR_H

typedef struct SVector *TVector;

TVector createVector(double x, double y, double z);
TVector createNullVector();
void freeVector(TVector vec);

double getX(TVector vec);
double getY(TVector vec);
double getZ(TVector vec);

void setX(TVector vec, double x);
void setY(TVector vec, double y);
void setZ(TVector vec, double z);

double getLength(TVector vec);
void normalizeVector(TVector vec);

double doDotProduct(TVector vecA, TVector vecB, double angle);
TVector doScalarProduct(TVector vec, double scalar);
TVector doCrossProduct(TVector vecA, TVector vecB);
TVector doSum(TVector vecA, TVector vecB);
TVector doSub(TVector vecA, TVector vecB);
TVector doNormalize(TVector vec);

TVector createCopyVector(TVector vec);

#endif

Add new functions to header

Add new functions to header


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

suspect_context("Euler's Method",
	suspect_test("Predicts y_{n+1} to within the expected threshhold",
		suspect_assert("Expected 1 < 0", -1 < 0);
	)

	suspect_test("Does not explode",
		suspect_assert("Expected -1 < 0", -1 < 0);
	)

	suspect_test("Knows about Tony",
		suspect_assert("Tony is a dork", 2 < 1);
	)
)

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

suspect_context("Euler's Method",
	suspect_test("Expect actual to be within epsilon of target",
		float actual = 5.426;
		float epsilon = 0.01;
		float target = 5.00;
		suspect_epsilon(actual,epsilon,target);
	)

	suspect_test("Does not explode",
		suspect_assert("Expected -1 < 0", -1 < 0);
	)

	suspect_test("Knows about Tony",
		suspect_assert("Tony is a dork", 2 < 1);
	)
)

Include use case of epsilon

Include use case of epsilon


#include <stdio.h>

float K_5_BY_9 = 5.0 / 9.0;
float K_32 = 32;

int main(void)
{
    float fahr, celsius;
    int lower, upper, step;

    lower = 0;
    upper = 300;
    step = 20;

    printf("|-----------|\n");
    printf("|%4s|%6s|\n", "F", "C");
    printf("|-----------|\n");

    fahr = lower;
    while (fahr <= upper) {
        celsius = K_5_BY_9 * (fahr - K_32);
        printf("|%4.0f|%6.1f|\n", fahr, celsius);
        fahr = fahr + step;
    }

    printf("|-----------|\n");

    return 0;
}

#include <stdio.h>

float K_5_BY_9 = 5.0 / 9.0;
float K_32 = 32;

int SUCCESS = 0;

int main(void)
{
    float fahrenheit, celsius;
    int lower, upper, step;

    lower = 0;
    upper = 300;
    step = 20;

    printf("|-----------|\n");
    printf("|%4s|%6s|\n", "F", "C");
    printf("|-----------|\n");

    fahrenheit = lower;
    while (fahrenheit <= upper) {
        celsius = K_5_BY_9 * (fahrenheit - K_32);
        printf("|%4.0f|%6.1f|\n", fahrenheit, celsius);
        fahrenheit = fahrenheit + step;
    }

    printf("|-----------|\n");

    return SUCCESS;
}

Update ch1/ex3 v2 exercise with more readable code


/* node.h : interface to node functions, private to libsvn_fs
 *
 * ====================================================================
 * Copyright (c) 2000 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */

#ifndef SVN_LIBSVN_FS_TXN_H
#define SVN_LIBSVN_FS_TXN_H

/* Create a new `transactions' table for the new filesystem FS.
   FS->env must already be open; this sets FS->nodes.  */
svn_error_t *svn_fs__create_transactions (svn_fs_t *fs);

/* Open the existing `transactions' table for the filesystem FS.
   FS->env must already be open; this sets FS->nodes.  */
svn_error_t *svn_fs__open_transactions (svn_fs_t *fs);

/* Return a pointer to the ID of TXN.  The return value is live for as
   long as TXN is.  */
char *svn_fs__txn_id (svn_fs_txn_t *txn);

#endif /* SVN_LIBSVN_FS_TXN_H */

/*
 * local variables:
 * eval: (load-file "../svn-dev.el")
 * end:
 */

/* txn.h : interface to Subversion transactions, private to libsvn_fs
 *
 * ====================================================================
 * Copyright (c) 2000 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */

#ifndef SVN_LIBSVN_FS_TXN_H
#define SVN_LIBSVN_FS_TXN_H

/* Create a new `transactions' table for the new filesystem FS.
   FS->env must already be open; this sets FS->nodes.  */
svn_error_t *svn_fs__create_transactions (svn_fs_t *fs);

/* Open the existing `transactions' table for the filesystem FS.
   FS->env must already be open; this sets FS->nodes.  */
svn_error_t *svn_fs__open_transactions (svn_fs_t *fs);

/* Return a pointer to the ID of TXN.  The return value is live for as
   long as TXN is.  */
char *svn_fs__txn_id (svn_fs_txn_t *txn);

#endif /* SVN_LIBSVN_FS_TXN_H */

/*
 * local variables:
 * eval: (load-file "../svn-dev.el")
 * end:
 */

Fix descriptive comment at top of file.

Fix descriptive comment at top of file.


/*
 * Copyright (C) 2015 Luke San Antonio
 * All rights reserved.
 */
#pragma once
#include "../common/id_map.hpp"
#include "boat.h"
#include "../collisionlib/motion.h"
namespace redc { namespace sail
{
  struct Player
  {
    std::string name;
    bool spawned;

    Hull_Desc boat_config;
    collis::Motion boat_motion;
  };

  struct Game
  {
    ID_Map<Player> players;
  };
} }

/*
 * Copyright (C) 2015 Luke San Antonio
 * All rights reserved.
 */
#pragma once
#include "../common/id_map.hpp"
#include "boat.h"
#include "../collisionlib/motion.h"
namespace redc { namespace sail
{
  struct Player
  {
    std::string name;
    bool spawned;

    Hull_Desc boat_config;
    collis::Motion boat_motion;

    void* userdata;
  };

  struct Game
  {
    ID_Map<Player> players;
  };
} }

Add user data to Game struct

Add user data to Game struct


/* $Id$ */

#include "ruby_libxml.h"

VALUE cXMLState;
VALUE LIBXML_STATE = Qnil;

static int dummy = 0;

void
ruby_xml_state_free(int dummy) {
  xmlCleanupParser();
  LIBXML_STATE = Qnil;
}

VALUE
ruby_xml_state_alloc() {
  #ifdef DEBUG
  fprintf(stderr, "Allocating state");
  #endif

  xmlInitParser();

  return Data_Wrap_Struct(cXMLState,
			  NULL, ruby_xml_state_free,
			  &dummy);
}

// Rdoc needs to know
#ifdef RDOC_NEVER_DEFINED
  mXML = rb_define_module("XML");
#endif

void
ruby_init_state(void) {
  VALUE rb_mSingleton;
  cXMLState = rb_define_class_under(mXML, "State", rb_cObject);

  /* Mixin singleton so only one xml state object can be created. */
  rb_require("singleton");
  rb_mSingleton = rb_const_get(rb_cObject, rb_intern("Singleton"));
  rb_include_module(cXMLState, rb_mSingleton);

  rb_define_alloc_func(cXMLState, ruby_xml_state_alloc);

  /* Create one instance of the state object that is used
     to initalize and cleanup libxml. Then register it with
     the garbage collector so its not freed until the process
     exists.*/
  LIBXML_STATE = rb_class_new_instance(0, NULL, cXMLState);
  rb_global_variable(&LIBXML_STATE);
}

/* $Id$ */

#include "ruby_libxml.h"

VALUE cXMLState;
VALUE LIBXML_STATE = Qnil;

static int dummy = 0;

void
ruby_xml_state_free(int dummy) {
  xmlCleanupParser();
  LIBXML_STATE = Qnil;
}

VALUE
ruby_xml_state_alloc(VALUE klass) {
  #ifdef DEBUG
  fprintf(stderr, "Allocating state");
  #endif

  xmlInitParser();

  return Data_Wrap_Struct(cXMLState,
			  NULL, ruby_xml_state_free,
			  &dummy);
}

// Rdoc needs to know
#ifdef RDOC_NEVER_DEFINED
  mXML = rb_define_module("XML");
#endif

void
ruby_init_state(void) {
  VALUE rb_mSingleton;
  cXMLState = rb_define_class_under(mXML, "State", rb_cObject);

  /* Mixin singleton so only one xml state object can be created. */
  rb_require("singleton");
  rb_mSingleton = rb_const_get(rb_cObject, rb_intern("Singleton"));
  rb_include_module(cXMLState, rb_mSingleton);

  rb_define_alloc_func(cXMLState, ruby_xml_state_alloc);

  /* Create one instance of the state object that is used
     to initalize and cleanup libxml. Then register it with
     the garbage collector so its not freed until the process
     exists.*/
  LIBXML_STATE = rb_class_new_instance(0, NULL, cXMLState);
  rb_global_variable(&LIBXML_STATE);
}

Fix declaration of alloc function.

Fix declaration of alloc function.


#include <miknet/miknet.h>

int mikpeer (miknode_t *n)
{
	int sock, i, pos = 0;
	struct sockaddr_storage addr;
	socklen_t addrlen;

	sock = accept(n->tcp, (struct sockaddr *)&addr, &addrlen);
	if (sock < 0)
		return mik_debug(ERR_SOCKET);

	if (n->peerc >= n->peermax) {
		close(sock);
		return ERR_PEER_MAX;
	}

	n->peerc++;

	for (i = 0; i < n->peermax; ++i) {
		if (n->peers[i].state == MIK_DISC) {
			pos = i;
			break;
		}
	}

	n->peers[pos].state = MIK_CONN;
	n->peers[pos].tcp = sock;
	n->peers[pos].addr = addr;
	n->peers[pos].addrlen = addrlen;
	n->peers[pos].sent = 0;
	n->peers[pos].recvd = 0;

	return 0;
}

int mikpeer_close (mikpeer_t *p)
{
	close(p->tcp);
	memset(&p->addr, 0, sizeof(struct sockaddr_storage));

	p->state = MIK_DISC;
	p->tcp = 0;
	p->addrlen = 0;
	p->sent = 0;
	p->recvd = 0;

	return 0;
}

Create a constructor and deconstructor for the peer structure.

Peers are created over the SOCK_STREAM socket, and so that is preferred.
The array which holds all the peers of a node, node.peers, determines whether
a slot is empty or occupied by the state of the peer. MIK_CONN is active, and
MIK_DISC is an empty slot.


#pragma once

#include "jwtxx/jwt.h"

#include <string>

namespace JWTXX
{

struct Key::Impl
{
    virtual std::string sign(const void* data, size_t size) const = 0;
    virtual bool verify(const void* data, size_t size, const std::string& signature) const = 0;
};

}

#pragma once

#include "jwtxx/jwt.h"

#include <string>

namespace JWTXX
{

struct Key::Impl
{
    virtual ~Impl() {}
    virtual std::string sign(const void* data, size_t size) const = 0;
    virtual bool verify(const void* data, size_t size, const std::string& signature) const = 0;
};

}

Fix memory leak in key implementations.

Fix memory leak in key implementations.


#pragma once

#include <cstdio>

namespace happyntrain {

#define LOG(message, level, ...) \
  printf("[" level "] %s-%d " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
#define INFO(message, ...) LOG(message, "INFO", ##__VA_ARGS__);
#define DEBUG(message, ...) LOG(message, "DEBUG", ##__VA_ARGS__);
#define ERROR(message, ...) LOG(message, "ERROR", ##__VA_ARGS__);

// end happyntrain
}

#pragma once

#include <cstdio>

namespace happyntrain {

#define LOG(message, level, ...)                                     \
  printf("[%5s] %s-%d " message "\n", level, __FILENAME__, __LINE__, \
         ##__VA_ARGS__);

#define INFO(message, ...) LOG(message, "INFO", ##__VA_ARGS__);
#define DEBUG(message, ...) LOG(message, "DEBUG", ##__VA_ARGS__);
#define ERROR(message, ...) \
  LOG("\x1b[31m" message "\x1b[0m", "ERROR", ##__VA_ARGS__);

// end happyntrain
}

Add color for error log

Add color for error log


#include <stdio.h>
#include <stdlib.h>
#include <wayland-client.h>
#include <time.h>
#include "client.h"
#include "log.h"

struct client_state *state;

void sway_terminate(void) {
	client_teardown(state);
	exit(1);
}

int main(int argc, char **argv) {
	init_log(L_INFO);
	state = client_setup();

	uint8_t r = 0, g = 0, b = 0;

	long last_ms = 0;
	int rs;
	do {
		struct timespec spec;
		clock_gettime(CLOCK_MONOTONIC, &spec);
		long ms = round(spec.tv_nsec / 1.0e6);

		cairo_set_source_rgb(state->cairo, r, g, b);
		cairo_rectangle(state->cairo, 0, 0, 100, 100);
		cairo_fill(state->cairo);

		rs = client_render(state);

		if (ms - last_ms > 100) {
			r++;
			if (r == 0) {
				g++;
				if (g == 0) {
					b++;
				}
			}
			ms = last_ms;
		}
	} while (rs);

	client_teardown(state);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <wayland-client.h>
#include <time.h>
#include "client.h"
#include "log.h"

struct client_state *state;

void sway_terminate(void) {
	client_teardown(state);
	exit(1);
}

int main(int argc, char **argv) {
	init_log(L_INFO);
	if (!(state = client_setup())) {
		return -1;
	}

	uint8_t r = 0, g = 0, b = 0;

	long last_ms = 0;
	int rs;
	do {
		struct timespec spec;
		clock_gettime(CLOCK_MONOTONIC, &spec);
		long ms = round(spec.tv_nsec / 1.0e6);

		cairo_set_source_rgb(state->cairo, r, g, b);
		cairo_rectangle(state->cairo, 0, 0, 100, 100);
		cairo_fill(state->cairo);

		rs = client_render(state);

		if (ms - last_ms > 100) {
			r++;
			if (r == 0) {
				g++;
				if (g == 0) {
					b++;
				}
			}
			ms = last_ms;
		}
	} while (rs);

	client_teardown(state);
	return 0;
}

Check the client_setup() return value

Check the client_setup() return value


/*
    Copyright (C) 2010  George Kiagiadakis <kiagiadakis.george@gmail.com>

    This library 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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QGSTTEST_H
#define QGSTTEST_H

#include <QtTest/QtTest>
#include <gst/gst.h>

class QGstTest : public QObject
{
    Q_OBJECT
private Q_SLOTS:
    void initTestCase() { gst_init(NULL, NULL); }
    void cleanupTestCase() { gst_deinit(); }
};

#endif

/*
    Copyright (C) 2010  George Kiagiadakis <kiagiadakis.george@gmail.com>

    This library 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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QGSTTEST_H
#define QGSTTEST_H

#include <QtTest/QtTest>
#include <QGst/Global>
#include <gst/gst.h>

class QGstTest : public QObject
{
    Q_OBJECT
private Q_SLOTS:
    void initTestCase() { QGst::init(); }
    void cleanupTestCase() { QGst::cleanup(); }
};

#endif

Use QGst::init/cleanup in the tests to properly register the ValueVTables for the gstreamer types.


// Make sure __asan_gen_* strings do not end up in the symbol table.

// RUN: %clang_asan %s -o %t.exe
// RUN: nm %t.exe | grep __asan_gen_ || exit 0

int x, y, z;
int main() { return 0; }

[ASan] Make sure none of the __asan_gen_ global strings end up in the symbol table, add a test.

This should fix http://llvm.org/bugs/show_bug.cgi?id=17976
Another test checking for the global variables' locations and prefixes on Darwin will be committed separately.

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@198017 91177308-0d34-0410-b5e6-96231b3b80d8


/*
 * Multiples of 3 and 5
 *
 * If we list all the natural numbers below 10 that are multiples of 3 or 5,
 * we get 3, 5, 6 and 9. The sum of these multiples is 23.
 *
 * Find the sum of all the multiples of 3 or 5 below 1000
 */

#include <stdio.h>

int
main(void)
{
    int sum = 0, i = 0;
    while (i < 1000) {
        if (i % 3 == 0 || i % 5 == 0)
            sum += i;
        i++;
    }
    printf("%i\n", sum);
    return 0;
}

Add solution for problem 1

Add solution for problem 1


/*
 * OLSRd Quagga plugin
 *
 * Copyright (C) 2006-2008 Immo 'FaUl' Wehrenberg <immo@chaostreff-dortmund.de>
 * Copyright (C) 2007-2010 Vasilis Tsiligiannis <acinonyxs@yahoo.gr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation or - at your option - under
 * the terms of the GNU General Public Licence version 2 but can be
 * linked to any BSD-Licenced Software with public available sourcecode
 *
 */

/* -------------------------------------------------------------------------
 * File               : common.h
 * Description        : common header file
 * ------------------------------------------------------------------------- */

#define OPTION_EXPORT 1

/* Zebra route types */
#define ZEBRA_ROUTE_OLSR		11
#define ZEBRA_ROUTE_MAX			13

struct zebra {
  char status;                         // internal status
  char options;                        // internal options
  int sock;                            // Socket to zebra...
  char redistribute[ZEBRA_ROUTE_MAX];
  char distance;
  char flags;
  char *sockpath;
  unsigned int port;
  char version;
};

extern struct zebra zebra;

/*
 * Local Variables:
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * End:
 */

/*
 * OLSRd Quagga plugin
 *
 * Copyright (C) 2006-2008 Immo 'FaUl' Wehrenberg <immo@chaostreff-dortmund.de>
 * Copyright (C) 2007-2010 Vasilis Tsiligiannis <acinonyxs@yahoo.gr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation or - at your option - under
 * the terms of the GNU General Public Licence version 2 but can be
 * linked to any BSD-Licenced Software with public available sourcecode
 *
 */

/* -------------------------------------------------------------------------
 * File               : common.h
 * Description        : common header file
 * ------------------------------------------------------------------------- */

#define OPTION_EXPORT 1

/* Zebra route types */
#define ZEBRA_ROUTE_OLSR		11
#define ZEBRA_ROUTE_MAX			13

struct zebra {
  unsigned char status;
  unsigned char options;
  int sock;
  unsigned char redistribute[ZEBRA_ROUTE_MAX];
  unsigned char distance;
  unsigned char flags;
  char *sockpath;
  unsigned int port;
  unsigned char version;
};

extern struct zebra zebra;

/*
 * Local Variables:
 * c-basic-offset: 2
 * indent-tabs-mode: nil
 * End:
 */

Change some char type variables to unsigned char


//
//  GeocodeItem.h
//  bikepath
//
//  Created by Farheen Malik on 8/19/14.
//  Copyright (c) 2014 Bike Path. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface GeocodeItem : NSObject

@end

//
//  GeocodeItem.h
//  bikepath
//
//  Created by Farheen Malik on 8/19/14.
//  Copyright (c) 2014 Bike Path. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <MapKit/MapKit.h>
#import <GoogleMaps/GoogleMaps.h>

@interface GeocodeItem : NSObject

@property NSString *latitude;
@property NSString *longitude;
@property CLLocation *position;
@property NSString *address;
@property (readonly) NSDate *creationDate;

@end

Add address property to object

Add address property to object


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

// From swift's include/swift/Runtime/Debug.h file.
struct RuntimeErrorDetails {
  uintptr_t version;
  const char *errorType;
  const char *currentStackDescription;
  uintptr_t framesToSkip;
  void *memoryAddress;

  struct Thread {
    const char *description;
    uint64_t threadID;
    uintptr_t numFrames;
    void **frames;
  };

  uintptr_t numExtraThreads;
  Thread *threads;

  struct FixIt {
    const char *filename;
    uintptr_t startLine;
    uintptr_t startColumn;
    uintptr_t endLine;
    uintptr_t endColumn;
    const char *replacementText;
  };

  struct Note {
    const char *description;
    uintptr_t numFixIts;
    FixIt *fixIts;
  };

  uintptr_t numFixIts;
  FixIt *fixIts;

  uintptr_t numNotes;
  Note *notes;
};

enum: uintptr_t {
  RuntimeErrorFlagNone = 0,
  RuntimeErrorFlagFatal = 1 << 0
};

extern "C"
void _swift_runtime_on_report(uintptr_t flags, const char *message, RuntimeErrorDetails *details);

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

#include <stdint.h>

// From swift's include/swift/Runtime/Debug.h file.
struct RuntimeErrorDetails {
  uintptr_t version;
  const char *errorType;
  const char *currentStackDescription;
  uintptr_t framesToSkip;
  void *memoryAddress;

  struct Thread {
    const char *description;
    uint64_t threadID;
    uintptr_t numFrames;
    void **frames;
  };

  uintptr_t numExtraThreads;
  Thread *threads;

  struct FixIt {
    const char *filename;
    uintptr_t startLine;
    uintptr_t startColumn;
    uintptr_t endLine;
    uintptr_t endColumn;
    const char *replacementText;
  };

  struct Note {
    const char *description;
    uintptr_t numFixIts;
    FixIt *fixIts;
  };

  uintptr_t numFixIts;
  FixIt *fixIts;

  uintptr_t numNotes;
  Note *notes;
};

enum: uintptr_t {
  RuntimeErrorFlagNone = 0,
  RuntimeErrorFlagFatal = 1 << 0
};

extern "C"
void _swift_runtime_on_report(uintptr_t flags, const char *message, RuntimeErrorDetails *details);

[testsuite] Include the necessary headers to make the swift-runtime-reporting test work.


// This is a placeholder to allow include-path compatibility with code written
// inside Google.

#ifndef STRINGS_STRINGPIECE_UTILS_H_
#define STRINGS_STRINGPIECE_UTILS_H_
#endif  // STRINGS_STRINGPIECE_UTILS_H_

Add a temporary dummy header file to make an internal refactoring process go more smoothly.


/*
 * Common powerpc suspend code for 32 and 64 bits
 *
 * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#include <linux/sched.h>
#include <asm/system.h>
#include <asm/current.h>
#include <asm/mmu_context.h>

void save_processor_state(void)
{
	/*
	 * flush out all the special registers so we don't need
	 * to save them in the snapshot
	 */
	flush_fp_to_thread(current);
	flush_altivec_to_thread(current);
	flush_spe_to_thread(current);

#ifdef CONFIG_PPC64
	hard_irq_disable();
#endif

}

void restore_processor_state(void)
{
#ifdef CONFIG_PPC32
	switch_mmu_context(NULL, current->active_mm);
#endif
}

/*
 * Common powerpc suspend code for 32 and 64 bits
 *
 * Copyright 2007	Johannes Berg <johannes@sipsolutions.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 */

#include <linux/sched.h>
#include <asm/system.h>
#include <asm/current.h>
#include <asm/mmu_context.h>

void save_processor_state(void)
{
	/*
	 * flush out all the special registers so we don't need
	 * to save them in the snapshot
	 */
	flush_fp_to_thread(current);
	flush_altivec_to_thread(current);
	flush_spe_to_thread(current);

#ifdef CONFIG_PPC64
	hard_irq_disable();
#endif

}

void restore_processor_state(void)
{
#ifdef CONFIG_PPC32
	switch_mmu_context(current->active_mm, current->active_mm);
#endif
}

powerpc/mm: Fix the call trace when resumed from hibernation

	In SMP mode, the kernel would produce call trace when resumed
	from hibernation. The reason is when the function destroy_context
	is called to drop the resuming mm context, the mm->context.active
	is 1 which is wrong and should be zero.
	We pass the current->active_mm as previous mm context to function
	switch_mmu_context to decrease the context.active by 1.

	In UP mode, there is no effect.

Signed-off-by: Tang Yuantian <90efaaf7e50af80e074b01e59775908135eef9b3@freescale.com>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>


/* Copyright 2016 Streampunk Media Ltd.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/

#ifndef PERSIST_H
#define PERSIST_H

namespace streampunk {

class Persist {
public:
  static std::unique_ptr<Persist> makeNew(Local<Object> object) {
    return std::make_unique<Persist>(object);
  }

  Persist(Local<Object> object)
    : mPersistObj(object) {}
  ~Persist() { mPersistObj.Reset(); }

private:
  Nan::Persistent<Object> mPersistObj;
};

} // namespace streampunk

#endif

/* Copyright 2016 Streampunk Media Ltd.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/

#ifndef PERSIST_H
#define PERSIST_H

#include <memory>

namespace streampunk {

class Persist {
public:
  static std::unique_ptr<Persist> makeNew(Local<Object> object) {
    return std::make_unique<Persist>(object);
  }

  Persist(Local<Object> object)
    : mPersistObj(object) {}
  ~Persist() { mPersistObj.Reset(); }

private:
  Nan::Persistent<Object> mPersistObj;
};

} // namespace streampunk

#endif

Add missing include for make_unique

Add missing include for make_unique


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

#include <cl_list.h>
#include <cl_iterator.h>

#define QTD 100

void print_list_iter(cl_list_root *list) {
	iterator_c *i = cl_iter_create(list, FORWARD);
	printf("[");
	if (i != NULL) {
		do {
			printf("'%d', ", *((int *) cl_iter_item(i)));
		} while (cl_iter_next(i) && cl_iter_is_item(i, list->head));
	};
	printf("]\n");
	cl_iter_free(i);
}

int main() {

	return EXIT_SUCCESS;
}

Add list_iter for circular list test.

Add list_iter for circular list test.