/*
 * Copyright (C) 2015 Luke San Antonio
 * All rights reserved.
 */
#pragma once
#include "rapidjson/document.h"
#include "glm/glm.hpp"
namespace redc
{
  inline glm::vec3 vec3_from_js_object(rapidjson::Value const& v) noexcept
  {
    return glm::vec3{v["x"].GetDouble(),v["y"].GetDouble(),v["z"].GetDouble()};
  }
  inline glm::vec3 vec3_from_js_array(rapidjson::Value const& v) noexcept
  {
    return glm::vec3{v[0].GetDouble(),v[1].GetDouble(),v[2].GetDouble()};
  }
}

/*
 * Copyright (C) 2015 Luke San Antonio
 * All rights reserved.
 */
#pragma once
#include "rapidjson/document.h"
#include "glm/glm.hpp"
namespace redc
{
  inline glm::vec3 vec3_from_js_object(rapidjson::Value const& v) noexcept
  {
    return glm::vec3{v["x"].GetDouble(),v["y"].GetDouble(),v["z"].GetDouble()};
  }
  inline glm::vec3 vec3_from_js_array(rapidjson::Value const& v) noexcept
  {
    return glm::vec3{v[0].GetDouble(),v[1].GetDouble(),v[2].GetDouble()};
  }
  inline bool load_js_vec3(rapidjson::Value const& v, glm::vec3& vec,
                           std::string* err)
  {
    if(v.IsArray())
    {
      vec = vec3_from_js_array(v);
      return true;
    }
    else if(v.IsObject())
    {
      vec = vec3_from_js_object(v);
      return true;
    }
    else
    {
      if(err) (*err) = "Invalid JSON; expected Vec3 (object or array)";
      return false;
    }
  }
}

Support loading vec3s from JSON objects or arrays


#pragma once

#ifndef __AVR_ARCH__

#include <unistd.h>

#define _BV(bit) (1<<(bit))

inline void _delay_ms(int ms) { usleep(ms*1000); }
inline void _delay_us(int us) { usleep(us); }

extern unsigned char UCSR0B;
extern unsigned char DDRB;
extern unsigned char DDRD;
extern unsigned char PINB;
extern unsigned char PIND;
extern unsigned char PORTB;
extern unsigned char PORTD;

#endif

#pragma once

#ifndef __AVR_ARCH__

#include <unistd.h>

#define _BV(bit) (1<<(bit))

inline void _delay_ms(int ms) { usleep(ms*1000); }
inline void _delay_us(int us) { usleep(us); }

extern unsigned char UCSR0A;
extern unsigned char UCSR0B;
extern unsigned char UCSR0C;
extern unsigned char UBRR0H;
extern unsigned char UBRR0L;
extern unsigned char DDRB;
extern unsigned char DDRD;
extern unsigned char PINB;
extern unsigned char PIND;
extern unsigned char PORTB;
extern unsigned char PORTD;
extern unsigned char UDR0;

#define U2X0 1
#define RXEN0 4
#define TXEN0 3

#endif

Add some more common ports and pins

Add some more common ports and pins


/*
 *  extobjc.h
 *  extobjc
 *
 *  Created by Justin Spahr-Summers on 2010-11-09.
 *  Released into the public domain.
 */

#import "EXTADT.h"
#import "EXTAspect.h"
#import "EXTBlockMethod.h"
#import "EXTBlockTarget.h"
#import "EXTConcreteProtocol.h"
#import "EXTDispatchObject.h"
#import "EXTFinalMethod.h"
#import "EXTKeyPathCoding.h"
#import "EXTMaybe.h"
#import "EXTMixin.h"
#import "EXTMultiObject.h"
#import "EXTNil.h"
#import "EXTPrivateMethod.h"
#import "EXTProtocolCategory.h"
#import "EXTSafeCategory.h"
#import "EXTScope.h"
#import "EXTSwizzle.h"
#import "EXTTuple.h"
#import "EXTVarargs.h"
#import "NSInvocation+EXT.h"
#import "NSMethodSignature+EXT.h"

/*
 *  extobjc.h
 *  extobjc
 *
 *  Created by Justin Spahr-Summers on 2010-11-09.
 *  Released into the public domain.
 */

#import "EXTADT.h"
#import "EXTAspect.h"
#import "EXTBlockMethod.h"
#import "EXTBlockTarget.h"
#import "EXTConcreteProtocol.h"
#import "EXTDispatchObject.h"
#import "EXTFinalMethod.h"
#import "EXTKeyPathCoding.h"
#import "EXTMaybe.h"
#import "EXTMixin.h"
#import "EXTMultimethod.h"
#import "EXTMultiObject.h"
#import "EXTNil.h"
#import "EXTPrivateMethod.h"
#import "EXTProtocolCategory.h"
#import "EXTSafeCategory.h"
#import "EXTScope.h"
#import "EXTSwizzle.h"
#import "EXTTuple.h"
#import "EXTVarargs.h"
#import "NSInvocation+EXT.h"
#import "NSMethodSignature+EXT.h"

Add EXTMultimethod to umbrella header

Add EXTMultimethod to umbrella header


#ifndef _MEM_H_
#define _MEM_H_

#include <config.h>

#ifdef _MSC_VER
#include <sql_config.h>
#endif

#include <stdio.h>
#include <assert.h>

#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif

#define NEW( type ) (type*)malloc(sizeof(type) )
#define NEW_ARRAY( type, size ) (type*)malloc((size)*sizeof(type))
#define RENEW_ARRAY( type,ptr,size) (type*)realloc((void*)ptr,(size)*sizeof(type))
#define NEWADT( size ) (adt*)malloc(size)
#define _DELETE( ptr )	free(ptr)
#define _strdup( ptr )	strdup((char*)ptr)

#endif /*_MEM_H_*/

#ifndef _MEM_H_
#define _MEM_H_

#include <config.h>

#include <sql_config.h>

#include <stdio.h>
#include <assert.h>

#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif

#define NEW( type ) (type*)malloc(sizeof(type) )
#define NEW_ARRAY( type, size ) (type*)malloc((size)*sizeof(type))
#define RENEW_ARRAY( type,ptr,size) (type*)realloc((void*)ptr,(size)*sizeof(type))
#define NEWADT( size ) (adt*)malloc(size)
#define _DELETE( ptr )	free(ptr)
#define _strdup( ptr )	strdup((char*)ptr)

#endif /*_MEM_H_*/

Include sql_config.h always so that we get HAVE_TERMIOS_H, so that the password doesn't get echoed.


#include <signal.h>
#include "sig.h"
#include "sysdeps.h"

#define SIGMAX _NSIG

void sig_all_catch(signalfn fn)
{
  int i;
  for (i = 1; i < SIGMAX; i++)
    if (i != SIGPROF)
      sig_catch(i, fn);
}

void sig_all_default(void)
{
  int i;
  for (i = 1; i < SIGMAX; i++)
    if (i != SIGPROF)
      sig_default(i);
}

void sig_all_block(void)
{
  int i;
#ifdef HASSIGPROCMASK
  sigset_t set;
  sigemptyset(&set);
  for (i = 1; i < SIGMAX; i++)
    if (i != SIGPROF)
      sigaddset(&set, i);
  sigprocmask(SIG_BLOCK, &set, 0);
#else
  sigblock(~(1 << (SIGPROF-1)));
#endif
}

void sig_all_unblock(void)
{
#ifdef HASSIGPROCMASK
  sigset_t set;
  sigemptyset(&set);
  sigprocmask(SIG_UNBLOCK, &set, 0);
#else
  sigsetmask(0);
#endif
}

#include <signal.h>
#include "sig.h"
#include "sysdeps.h"

#ifdef _SIG_MAXSIG
#define SIGMAX _SIG_MAXSIG
#else
#ifdef _NSIG
#define SIGMAX _NSIG
#else
#define SIGMAX 32
#endif
#endif

void sig_all_catch(signalfn fn)
{
  int i;
  for (i = 1; i < SIGMAX; i++)
    if (i != SIGPROF)
      sig_catch(i, fn);
}

void sig_all_default(void)
{
  int i;
  for (i = 1; i < SIGMAX; i++)
    if (i != SIGPROF)
      sig_default(i);
}

void sig_all_block(void)
{
  int i;
#ifdef HASSIGPROCMASK
  sigset_t set;
  sigemptyset(&set);
  for (i = 1; i < SIGMAX; i++)
    if (i != SIGPROF)
      sigaddset(&set, i);
  sigprocmask(SIG_BLOCK, &set, 0);
#else
  sigblock(~(1 << (SIGPROF-1)));
#endif
}

void sig_all_unblock(void)
{
#ifdef HASSIGPROCMASK
  sigset_t set;
  sigemptyset(&set);
  sigprocmask(SIG_UNBLOCK, &set, 0);
#else
  sigsetmask(0);
#endif
}

Work on systems that don't define _NSIG

Work on systems that don't define _NSIG


/* EFL-Egueb Egueb based EFL extensions
 * Copyright (C) 2013 - 2014 Jorge Luis Zapata
 *
 * 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/>.
 */
#include "efl_egueb_private.h"
#include "efl_egueb_main.h"
/* Put the common interfaces with EFL here, like:
 * - Animation
 * - IO
 * - Render?
 */
/*============================================================================*
 *                                  Local                                     *
 *============================================================================*/
/*============================================================================*
 *                                 Global                                     *
 *============================================================================*/
/*============================================================================*
 *                                   API                                      *
 *============================================================================*/

Add the future file for common interfaces


#ifndef VAST_ALIASES_H
#define VAST_ALIASES_H

#include <cstdint>

namespace vast {

/// Uniquely identifies a VAST event.
using event_id = uint64_t;

/// Uniquely identifies a VAST type.
using type_id = uint64_t;

} // namespace vast

#endif

#ifndef VAST_ALIASES_H
#define VAST_ALIASES_H

#include <cstdint>
#include <limits>

namespace vast {

/// Uniquely identifies a VAST event.
using event_id = uint64_t;

/// The smallest possible event ID.
static constexpr event_id min_event_id = 1;

/// The largest possible event ID.
static constexpr event_id max_event_id =
  std::numeric_limits<event_id>::max() - 1;

/// Uniquely identifies a VAST type.
using type_id = uint64_t;

} // namespace vast

#endif

Add names for ID space boundaries.

Add names for ID space boundaries.


#include "postgres.h"
#include "executor/spi.h"
#include "commands/trigger.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "utils/syscache.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"

PG_MODULE_MAGIC;

PG_FUNCTION_INFO_V1(plparrot_call_handler);

Datum
plparrot_call_handler(PG_FUNCTION_ARGS)
{
    PG_RETURN_VOID();
}

#include "postgres.h"
#include "executor/spi.h"
#include "commands/trigger.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "utils/syscache.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"

PG_MODULE_MAGIC;

Datum plparrot_call_handler(PG_FUNCTION_ARGS);
void plparrot_elog(int level, char *message);

PG_FUNCTION_INFO_V1(plparrot_call_handler);

Datum
plparrot_call_handler(PG_FUNCTION_ARGS)
{
    PG_RETURN_VOID();
}

void
plparrot_elog(int level, char *message)
{
    elog(level, "%s", message);
}

Add simple function to interact with pgsql APIs, and make something for the NQP bits to export


#include <errno.h>
#include "readstat.h"
#include "readstat_iconv.h"
#include "readstat_convert.h"

readstat_error_t readstat_convert(char *dst, size_t dst_len, const char *src, size_t src_len, iconv_t converter) {
    /* strip off spaces from the input because the programs use ASCII space
     * padding even with non-ASCII encoding. */
    while (src_len && src[src_len-1] == ' ') {
        src_len--;
    }
    if (converter) {
        size_t dst_left = dst_len;
        char *dst_end = dst;
        size_t status = iconv(converter, (readstat_iconv_inbuf_t)&src, &src_len, &dst_end, &dst_left);
        if (status == (size_t)-1) {
            if (errno == E2BIG) {
                return READSTAT_ERROR_CONVERT_LONG_STRING;
            } else if (errno == EILSEQ) {
                return READSTAT_ERROR_CONVERT_BAD_STRING;
            } else if (errno != EINVAL) { /* EINVAL indicates improper truncation; accept it */
                return READSTAT_ERROR_CONVERT;
            }
        }
        dst[dst_len - dst_left] = '\0';
    } else {
        memcpy(dst, src, src_len);
        dst[src_len] = '\0';
    }
    return READSTAT_OK;
}

#include <errno.h>
#include "readstat.h"
#include "readstat_iconv.h"
#include "readstat_convert.h"

readstat_error_t readstat_convert(char *dst, size_t dst_len, const char *src, size_t src_len, iconv_t converter) {
    /* strip off spaces from the input because the programs use ASCII space
     * padding even with non-ASCII encoding. */
    while (src_len && src[src_len-1] == ' ') {
        src_len--;
    }
    if (converter) {
        size_t dst_left = dst_len;
        char *dst_end = dst;
        size_t status = iconv(converter, (readstat_iconv_inbuf_t)&src, &src_len, &dst_end, &dst_left);
        if (status == (size_t)-1) {
            if (errno == E2BIG) {
                return READSTAT_ERROR_CONVERT_LONG_STRING;
            } else if (errno == EILSEQ) {
                return READSTAT_ERROR_CONVERT_BAD_STRING;
            } else if (errno != EINVAL) { /* EINVAL indicates improper truncation; accept it */
                return READSTAT_ERROR_CONVERT;
            }
        }
        dst[dst_len - dst_left] = '\0';
    } else if (src_len + 1 > dst_len) {
        return READSTAT_ERROR_CONVERT_LONG_STRING;
    } else {
        memcpy(dst, src, src_len);
        dst[src_len] = '\0';
    }
    return READSTAT_OK;
}

Fix out of bounds writes during charset conversion

Fixes #128. Thanks to Google Autofuzz Project


#ifndef HALIDE_BUF_SIZE_H
#define HALIDE_BUF_SIZE_H

// TODO: in new buffer_t, add an inline method to do this and kill this file.

// Compute the total amount of memory we'd need to allocate on gpu to
// represent a given buffer (using the same strides as the host
// allocation).
WEAK size_t buf_size(const buffer_t *buf) {
    size_t size = buf->elem_size;
    for (size_t i = 0; i < sizeof(buf->stride) / sizeof(buf->stride[0]); i++) {
        size_t positive_stride;
        if (buf->stride[i] < 0) {
            positive_stride = (size_t)-buf->stride[i];
        } else {
            positive_stride = (size_t)buf->stride[i];
        }
        size_t total_dim_size = buf->elem_size * buf->extent[i] * positive_stride;
        if (total_dim_size > size) {
            size = total_dim_size;
        }
    }
    return size;
}

#endif // HALIDE_BUF_SIZE_H

Add new file that was forgotten.

Add new file that was forgotten.


//
//  MRSVisit.h
//  OpenMRS-iOS
//
//  Created by Parker Erway on 12/2/14.
//  Copyright (c) 2014 Erway Software. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface MRSVisit : NSObject
@property (nonatomic, strong) NSString *displayName;
@property (nonatomic, strong) NSString *UUID;
@property (nonatomic) BOOL active;
@end

//
//  MRSVisit.h
//  OpenMRS-iOS
//
//  Created by Parker Erway on 12/2/14.
//  Copyright (c) 2014 Erway Software. All rights reserved.
//

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

@class MRSVisitType;
@interface MRSVisit : NSObject
@property (nonatomic, strong) NSString *displayName;
@property (nonatomic, strong) NSString *UUID;
@property (nonatomic, strong) NSString *startDateTime;
@property (nonatomic, strong) MRSVisitType *visitType;
@property (nonatomic, strong) MRSLocation *location;
@property (nonatomic) BOOL active;
@end

Add new attributes to Visit class

Add new attributes to Visit class


#ifndef __TIMER_H__
#define __TIMER_H__

#include "SDL/include/SDL.h"

class SimpleTimer
{
public:
	SimpleTimer()
	{
		pausedTicks = 0, runTicks = 0;
		running = false;
	}

	void Start()
	{
		running = true;
		runTicks = SDL_GetTicks();
	}

	void Stop()
	{
		if(running)
		{
			running = false;
			pausedTicks = SDL_GetTicks() - runTicks;
		}
	}

	void Resume()
	{
		if(!running)
		{
			running = true;
			runTicks = SDL_GetTicks() - pausedTicks;
			pausedTicks = 0;
		}
	}

	void Clear()
	{
		running = false;
		runTicks = 0;
		pausedTicks = 0;
	}

	int GetTimerTicks() const
	{
		if (running)
			return SDL_GetTicks() - runTicks;
		return 0;
	}

	bool IsRunning() const
	{
		return running;
	}

private:
	int pausedTicks, runTicks;
	bool running;
};

#endif // __TIMER_H__

#ifndef __TIMER_H__
#define __TIMER_H__

#include "SDL/include/SDL.h"

class SimpleTimer
{
public:
	SimpleTimer()
	{
		pausedTicks = 0, runTicks = 0;
		running = false;
	}

	void Start()
	{
		running = true;
		runTicks = SDL_GetTicks();
	}

	int Stop()
	{
		if(running)
		{
			running = false;
			return pausedTicks = SDL_GetTicks() - runTicks;
		}
		return 0;
	}

	void Resume()
	{
		if(!running)
		{
			running = true;
			runTicks = SDL_GetTicks() - pausedTicks;
			pausedTicks = 0;
		}
	}

	void Clear()
	{
		running = false;
		runTicks = 0;
		pausedTicks = 0;
	}

	unsigned int GetTimerTicks() const
	{
		if (running)
			return SDL_GetTicks() - runTicks;
		return 0;
	}

	unsigned int GetPausedTicks() const
	{
		if (!running)
			return pausedTicks;
		return 0;
	}

	bool IsRunning() const
	{
		return running;
	}

private:
	unsigned int pausedTicks, runTicks;
	bool running;
};

#endif // __TIMER_H__

Change int to unsigned int

Change int to unsigned int


#ifndef DTKSINGLETON_H
#define DTKSINGLETON_H

#include <QtCore/QMutex>

template <class T> class dtkSingleton
{
public:
    static T& instance(void)
    {
        static QMutex mutex;

        if(!s_instance) {

            mutex.lock();

            if(!s_instance)
                s_instance = new T;

            mutex.unlock();
        }

        return s_instance;
    }

private:
     dtkSingleton(void) {};
    ~dtkSingleton(void) {};

private:
    Q_DISABLE_COPY(dtkSingleton)

private:
    static T *s_instance;
};

template <class T> T *dtkSingleton<T>::s_instance = NULL;

#define DTK_IMPLEMENT_SINGLETON(T)              \
    T *T::instance()                            \
    {                                           \
        return &(dtkSingleton<T>::instance());  \
    }

#endif //DTKSINGLETON

#ifndef DTKSINGLETON_H
#define DTKSINGLETON_H

#include <QtCore/QMutex>

template <class T> class dtkSingleton
{
public:
    static T& instance(void)
    {
        static QMutex mutex;

        if(!s_instance) {

            mutex.lock();

            if(!s_instance)
                s_instance = new T;

            mutex.unlock();
        }

        return (*s_instance);
    }

private:
     dtkSingleton(void) {};
    ~dtkSingleton(void) {};

private:
    Q_DISABLE_COPY(dtkSingleton)

private:
    static T *s_instance;
};

template <class T> T *dtkSingleton<T>::s_instance = NULL;

#define DTK_IMPLEMENT_SINGLETON(T)              \
    T *T::instance()                            \
    {                                           \
        return &(dtkSingleton<T>::instance());  \
    }

#endif //DTKSINGLETON

Fix generic singleton accessor syntax.

Fix generic singleton accessor syntax.


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

int main()
{
  // Read string from a file
  FILE* file_ptr = fopen("test.txt", "r");

  if (file_ptr == NULL)
    return 1;

  char* string = malloc(256);

  fscanf(file_ptr, "%s", string);

  // Solution

  int length = sprintf(string, "%s", string);

  int front = 0;
  int back = length - 1;

  while(front < back)
  {
    // swap 2 characters
    char tmp = string[front];
    string[front] = string[back];
    string[back] = tmp;

    ++front;
    --back;
  }

  printf("%s\n", string);

  return 0;
}

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

void reverse(char* string)
{
  char* back = string;
  char tmp;

  while(*back)
    ++back;

  // Move from the null terminator
  --back;

  while (string < back)
  {
    char tmp = *string;
    *string = *back;
    *back = tmp;

    ++string;
    --back;
  }
}

int main()
{
  // Read string from a file
  FILE* file_ptr = fopen("test.txt", "r");

  if (file_ptr == NULL)
    return 1;

  char* string = malloc(256);

  fscanf(file_ptr, "%s", string);

  // Solution
  reverse(string);
  printf("%s\n", string);

  return 0;
}

Handle null terminator in string reverse


#ifndef _POINTER_H
#define	_POINTER_H

#ifdef	__cplusplus
extern "C" {
#endif

#include "AbstractMemory.h"

extern void rbffi_Pointer_Init(VALUE moduleFFI);
extern void rbffi_NullPointer_Init(VALUE moduleFFI);
extern VALUE rbffi_Pointer_NewInstance(void* addr);
extern VALUE rbffi_PointerClass;
extern VALUE rbffi_NullPointerClass;
extern VALUE rbffi_NullPointerSingleton;
extern MemoryOps rbffi_NullPointerOps;

#ifdef	__cplusplus
}
#endif

#endif	/* _POINTER_H */

/*
 * Copyright (c) 2008, 2009, Wayne Meissner
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright notice
 *   this list of conditions and the following disclaimer in the documentation
 *   and/or other materials provided with the distribution.
 * * The name of the author or authors may not be used to endorse or promote
 *   products derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef RBFFI_POINTER_H
#define	RBFFI_POINTER_H

#ifdef	__cplusplus
extern "C" {
#endif

#include "AbstractMemory.h"

extern void rbffi_Pointer_Init(VALUE moduleFFI);
extern VALUE rbffi_Pointer_NewInstance(void* addr);
extern VALUE rbffi_PointerClass;
extern VALUE rbffi_NullPointerSingleton;

#ifdef	__cplusplus
}
#endif

#endif	/* RBFFI_POINTER_H */

Remove some leftover null pointer vars

Remove some leftover null pointer vars


// Due to ln -sf:
// REQUIRES: shell
// RUN: rm -rf %t.real
// RUN: mkdir -p %t.real
// RUN: cd %t.real
// RUN: ln -sf %clang test-clang
// RUN: cd ..
// Important to remove %t.fake: If it already is a symlink to %t.real when
// `ln -sf %t.real %t.fake` runs, then that would symlink %t.real to itself,
// forming a cycle.
// RUN: rm -rf %t.fake
// RUN: ln -sf %t.real %t.fake
// RUN: cd %t.fake
// RUN: ./test-clang -v -S %s 2>&1 | FileCheck --check-prefix=CANONICAL %s
// RUN: ./test-clang -v -S %s -no-canonical-prefixes 2>&1 | FileCheck --check-prefix=NON-CANONICAL %s
//
// FIXME: This should really be '.real'.
// CANONICAL: InstalledDir: {{.*}}.fake
// CANONICAL: {{[/|\\]*}}clang{{.*}}" -cc1
//
// NON-CANONICAL: InstalledDir: .{{$}}
// NON-CANONICAL: test-clang" -cc1

// Due to ln -sf:
// REQUIRES: shell
// RUN: mkdir -p %t.real
// RUN: cd %t.real
// RUN: ln -sf %clang test-clang
// RUN: cd ..
// If %.fake already is a symlink to %t.real when `ln -sf %t.real %t.fake`
// runs, then that would symlink %t.real to itself, forming a cycle.
// The `-n` flag prevents this.
// RUN: ln -sfn %t.real %t.fake
// RUN: cd %t.fake
// RUN: ./test-clang -v -S %s 2>&1 | FileCheck --check-prefix=CANONICAL %s
// RUN: ./test-clang -v -S %s -no-canonical-prefixes 2>&1 | FileCheck --check-prefix=NON-CANONICAL %s
//
// FIXME: This should really be '.real'.
// CANONICAL: InstalledDir: {{.*}}.fake
// CANONICAL: {{[/|\\]*}}clang{{.*}}" -cc1
//
// NON-CANONICAL: InstalledDir: .{{$}}
// NON-CANONICAL: test-clang" -cc1

Use `ln -n` to prevent forming a symlink cycle, instead of rm'ing the source

This is a better fix for the problem fixed in r334972.

Also remove the rm'ing of the symlink destination that was there to
clean up the bots -- it's over a year later, bots should be happy now.

Differential Revision: https://reviews.llvm.org/D64301

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


extern void denoise(void*, int, const uint32_t *in, uint32_t *out, int h, int w);
extern void *kernelInit(void);
extern void kernelFinalize(void*);

enum {
	SPATIAL,
	TEMPORAL_AVG,
	KNN,
	AKNN,
	ADAPTIVE_TEMPORAL_AVG,
	DIFF,
	SOBEL,
	MOTION,
};

extern void denoise(void*, int, const uint32_t *in, uint32_t *out, int h, int w);
extern void *kernelInit(void);
extern void kernelFinalize(void*);

enum {
	// "Real" filters
	SPATIAL,
	TEMPORAL_AVG,
	ADAPTIVE_TEMPORAL_AVG,
	KNN,
	AKNN,
	// Helpers
	DIFF,
	SOBEL,
	MOTION,

	NFILTERS,
};

Add comments for filter enums

Add comments for filter enums


#ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
#  define E_SMART_MONITOR_H

Evas_Object *e_smart_monitor_add(Evas *evas);

# endif
#endif

#ifdef E_TYPEDEFS
#else
# ifndef E_SMART_MONITOR_H
#  define E_SMART_MONITOR_H

Evas_Object *e_smart_monitor_add(Evas *evas);
void e_smart_monitor_crtc_set(Evas_Object *obj, E_Randr_Crtc_Config *crtc);
void e_smart_monitor_output_set(Evas_Object *obj, E_Randr_Output_Config *output);

# endif
#endif

Add function prototypes for setting monitor crtc and output config.

Signed-off-by: Christopher Michael <cp.michael@samsung.com>

SVN revision: 84129


/* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
   Released under the terms of the MIT License. See LICENSE for details. */

#include <stdlib.h>

#include "src/config.h"
#include "src/logging.h"
#include "src/rom.h"

/*
    Main function.
*/
int main(int argc, char *argv[])
{
    Config *config;
    ROM *rom;
    int retval;

    retval = config_create(&config, argc, argv);
    if (retval != CONFIG_OK)
        return retval == CONFIG_EXIT_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;

    printf("crater: a Sega Game Gear emulator\n\n");

#ifdef DEBUG_MODE
    config_dump_args(config);
#endif

    if (!(rom = rom_open(config->rom_path))) {
        if (errno == ENOMEM)
            OUT_OF_MEMORY()
        else
            FATAL_ERRNO("couldn't load ROM image '%s'", config->rom_path)
    }
    printf("Loaded ROM image: %s.\n", rom->name);

    // TODO: start from here

    rom_close(rom);
    config_destroy(config);
    return EXIT_SUCCESS;
}

/* Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
   Released under the terms of the MIT License. See LICENSE for details. */

#include <stdlib.h>

#include "src/config.h"
#include "src/logging.h"
#include "src/rom.h"

/*
    Main function.
*/
int main(int argc, char *argv[])
{
    Config *config;
    int retval;

    retval = config_create(&config, argc, argv);
    if (retval != CONFIG_OK)
        return retval == CONFIG_EXIT_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;

#ifdef DEBUG_MODE
    config_dump_args(config);
#endif

    if (config->assemble) {
        printf("Running assembler: %s -> %s.\n",config->src_path, config->dst_path);
    } else if (config->disassemble) {
        printf("Running disassembler: %s -> %s.\n", config->src_path, config->dst_path);
    } else {
        ROM *rom;

        printf("crater: a Sega Game Gear emulator\n\n");
        if (!(rom = rom_open(config->rom_path))) {
            if (errno == ENOMEM)
                OUT_OF_MEMORY()
            else
                FATAL_ERRNO("couldn't load ROM image '%s'", config->rom_path)
        }
        printf("Loaded ROM image: %s.\n", rom->name);

        // TODO: start from here
        rom_close(rom);
    }

    config_destroy(config);
    return EXIT_SUCCESS;
}

Call different stuff for the assembler/disassembler.


#ifndef PWARNINGS_H
#define PWARNINGS_H

#if defined(_MSC_VER)
/* Needed when flagging code in or out and more. */
#pragma warning(disable: 4127) /* conditional expression is constant */
/* happens also in MS's own headers. */
#pragma warning(disable: 4668) /* preprocessor name not defined */
/* MSVC does not respect double parenthesis for intent */
#pragma warning(disable: 4706) /* assignment within conditional expression */
/* `inline` only advisory anyway. */
#pragma warning(disable: 4710) /* function not inlined */
/* Well, we don't intend to add the padding manually. */
#pragma warning(disable: 4820) /* x bytes padding added in struct */

/* Define this in the build as `-D_CRT_SECURE_NO_WARNINGS`, it has no effect here. */
/* #define _CRT_SECURE_NO_WARNINGS don't warn that fopen etc. are unsafe */

/*
 * Anonymous union in struct is valid in C11 and has been supported in
 * GCC and Clang for a while, but it is not C99. MSVC also handles it,
 * but warns. Truly portable code should perhaps not use this feature,
 * but this is not the place to complain about it.
 */
#pragma warning(disable: 4201) /* nonstandard extension used: nameless struct/union */
#endif

#endif PWARNINGS_H

#ifndef PWARNINGS_H
#define PWARNINGS_H

#if defined(_MSC_VER)
/* Needed when flagging code in or out and more. */
#pragma warning(disable: 4127) /* conditional expression is constant */
/* happens also in MS's own headers. */
#pragma warning(disable: 4668) /* preprocessor name not defined */
/* MSVC does not respect double parenthesis for intent */
#pragma warning(disable: 4706) /* assignment within conditional expression */
/* `inline` only advisory anyway. */
#pragma warning(disable: 4710) /* function not inlined */
/* Well, we don't intend to add the padding manually. */
#pragma warning(disable: 4820) /* x bytes padding added in struct */

/* Define this in the build as `-D_CRT_SECURE_NO_WARNINGS`, it has no effect here. */
/* #define _CRT_SECURE_NO_WARNINGS don't warn that fopen etc. are unsafe */

/*
 * Anonymous union in struct is valid in C11 and has been supported in
 * GCC and Clang for a while, but it is not C99. MSVC also handles it,
 * but warns. Truly portable code should perhaps not use this feature,
 * but this is not the place to complain about it.
 */
#pragma warning(disable: 4201) /* nonstandard extension used: nameless struct/union */
#endif

#endif /* PWARNINGS_H */

Fix warning in header disabling some warnings (sigh)


#ifndef __DFB_TYPES_H__
#define __DFB_TYPES_H__

#ifdef USE_KOS

#include <sys/types.h>

typedef uint8 u8;
typedef uint16 u16;
typedef uint32 u32;
typedef uint64 u64;

typedef sint8 s8;
typedef sint16 s16;
typedef sint32 s32;
typedef sint64 s64;

#else

#include <stdint.h>

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

#endif

#endif

#ifndef __DFB_TYPES_H__
#define __DFB_TYPES_H__

#ifdef USE_KOS

#include <sys/types.h>

typedef uint8 u8;
typedef uint16 u16;
typedef uint32 u32;
typedef uint64 u64;

typedef sint8 s8;
typedef sint16 s16;
typedef sint32 s32;
typedef sint64 s64;

#else

#include <stdint.h>

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;

typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

#endif

#ifndef DIRECTFB_NO_CRUFT
#define __u8   u8
#define __u16  u16
#define __u32  u32
#define __u64  u64
#define __s8   s8
#define __s16  s16
#define __s32  s32
#define __s64  s64
#endif

#endif

Define compatibility macros for __ types unless DIRECTFB_NO_CRUFT is defined.


int test(int a, int b, int c, int d, int e);

typedef (*funcCall)();

short array = {0x61c1};

int main()
{
	((funcCall)array)();

	return test(1, 2, 3, 4, 5);
}

int test(int a, int b, int c, int d, int e)
{
	return (e + (a + b + c) * a / d) + (a * 6);
}

int test(int a, int b, int c, int d, int e);

typedef (*funcCall)();

short array = {0x61c1};

int main()
{
	((funcCall)array)();

	int some_var = 3;

	int ret = test(1, 2, 3, 4, 5);

	return some_var + ret;
}

int foo(int a)
{
	return 9 + a;
}

int test(int a, int b, int c, int d, int e)
{
	a = foo(a);
	return ((a  + b + c) * d / a) + (d * e);
}

Make example a bit more advanced

Make example a bit more advanced


//
//  FragariaAppDelegate.h
//  Fragaria
//
//  Created by Jonathan on 30/04/2010.
//  Copyright 2010 mugginsoft.com. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <MGSFragaria/MGSFragariaTextViewDelegate.h>
#import <MGSFragaria/SMLSyntaxColouringDelegate.h>

@class SMLTextView;
@class MGSFragaria;
@class MGSSimpleBreakpointDelegate;

@interface FragariaAppDelegate : NSObject <NSApplicationDelegate, MGSFragariaTextViewDelegate, SMLSyntaxColouringDelegate>

- (IBAction)showPreferencesWindow:(id)sender;
- (IBAction)copyToPasteBoard:(id)sender;
- (IBAction)reloadString:(id)sender;

@property (weak) IBOutlet NSWindow *window;

@property (weak) IBOutlet NSView *editView;

@property (nonatomic,assign) NSString *syntaxDefinition;

@end

//
//  FragariaAppDelegate.h
//  Fragaria
//
//  Created by Jonathan on 30/04/2010.
//  Copyright 2010 mugginsoft.com. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <MGSFragaria/MGSFragariaTextViewDelegate.h>
#import <MGSFragaria/SMLSyntaxColouringDelegate.h>
#import <MGSFragaria/MGSDragOperationDelegate.h>

@class SMLTextView;
@class MGSFragaria;
@class MGSSimpleBreakpointDelegate;

@interface FragariaAppDelegate : NSObject <NSApplicationDelegate, MGSFragariaTextViewDelegate, SMLSyntaxColouringDelegate, MGSDragOperationDelegate>

- (IBAction)showPreferencesWindow:(id)sender;
- (IBAction)copyToPasteBoard:(id)sender;
- (IBAction)reloadString:(id)sender;

@property (weak) IBOutlet NSWindow *window;

@property (weak) IBOutlet NSView *editView;

@property (nonatomic,assign) NSString *syntaxDefinition;

@end

Fix simple example delegate's protocol compliance.


/*
 * waysome - wayland based window manager
 *
 * Copyright in alphabetical order:
 *
 * Copyright (C) 2014-2015 Julian Ganz
 * Copyright (C) 2014-2015 Manuel Messner
 * Copyright (C) 2014-2015 Marcel Müller
 * Copyright (C) 2014-2015 Matthias Beyer
 * Copyright (C) 2014-2015 Nadja Sommerfeld
 *
 * This file is part of waysome.
 *
 * waysome 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.
 *
 * waysome 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 waysome. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __WS_STORAGE_MODULE_H__
#define __WS_STORAGE_MODULE_H__

#endif // __WS_STORAGE_MODULE_H__

/*
 * waysome - wayland based window manager
 *
 * Copyright in alphabetical order:
 *
 * Copyright (C) 2014-2015 Julian Ganz
 * Copyright (C) 2014-2015 Manuel Messner
 * Copyright (C) 2014-2015 Marcel Müller
 * Copyright (C) 2014-2015 Matthias Beyer
 * Copyright (C) 2014-2015 Nadja Sommerfeld
 *
 * This file is part of waysome.
 *
 * waysome 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.
 *
 * waysome 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 waysome. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @addtogroup storage "Storage"
 *
 * @{
 */

#ifndef __WS_STORAGE_MODULE_H__
#define __WS_STORAGE_MODULE_H__

#endif // __WS_STORAGE_MODULE_H__

/**
 * @}
 */

Add storage files to storage documentation group


/* IPOLICE_FLAGS: DONT_REMOVE */

#define RTPP_SW_VERSION "rel.20160514172346"

Add IPOLICE_FLAGS: DONT_REMOVE, bump RTPP_SW_VERSION forward.


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

#include "cem/utils.h"

static void test_set_periodic_multiple_of_4(void) {
  const int len = 12;
  int array[12] =    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
  int expected[12] = {6, 7, 8, 3, 4, 5, 6, 7, 8, 3,  4,  5};

  apply_periodic_boundary(array, sizeof(int), len);

  g_assert_cmpmem(array, len, expected, len);
}

static void test_set_periodic_even_width(void) {
  const int len = 10;
  int array[10] =    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  int expected[10] = {5, 6, 2, 3, 4, 5, 6, 2, 3, 4};

  apply_periodic_boundary(array, sizeof(int), len);

  g_assert_cmpmem(array, len, expected, len);
}

static void test_set_periodic_odd_width(void) {
  const int len = 11;
  int array[11] =    {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  int expected[11] = {5, 6, 7, 3, 4, 5, 6, 7, 3, 4,  5};

  apply_periodic_boundary(array, sizeof(int), len);

  g_assert_cmpmem(array, len, expected, len);
}

int main(int argc, char* argv[]) {
  g_test_init(&argc, &argv, NULL);
  g_test_add_func("/cem/utils/set_periodic_4", &test_set_periodic_multiple_of_4);
  g_test_add_func("/cem/utils/set_periodic_even", &test_set_periodic_even_width);
  g_test_add_func("/cem/utils/set_periodic_odd", &test_set_periodic_odd_width);

  return g_test_run();
}

Add unit tests for utils.c functions.

Add unit tests for utils.c functions.


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

#ifndef CHROME_COMMON_NOTIFICATION_OBSERVER_H_
#define CHROME_COMMON_NOTIFICATION_OBSERVER_H_

class NotificationDetails;
class NotificationSource;
class NotificationType;

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

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

#endif  // CHROME_COMMON_NOTIFICATION_OBSERVER_H_

Add forgotted notification observer header.

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@9021 4ff67af0-8c30-449e-8e8b-ad334ec8d88c


#ifndef HALIDE_TOOLS_IMAGE_H
#define HALIDE_TOOLS_IMAGE_H

/*

This allows code that relied on halide_image.h and Halide::Tools::Image to
continue to work with newer versions of Halide where HalideBuffer.h and
Halide::Buffer are the way to work with data.

Besides mapping Halide::Tools::Image to Halide::Buffer, it defines
USING_HALIDE_BUFFER to allow code to conditionally compile for one or the
other.

It is intended as a stop-gap measure until the code can be updated.

*/

#include "HalideBuffer.h"

namespace Halide {
namespace Tools {

#define USING_HALIDE_BUFFER

template< typename T >
using Image = Buffer<T>;

}   // namespace Tools
}   // mamespace Halide

#endif  // #ifndef HALIDE_TOOLS_IMAGE_H

#ifndef HALIDE_TOOLS_IMAGE_H
#define HALIDE_TOOLS_IMAGE_H

/** \file
 *
 * This allows code that relied on halide_image.h and
 * Halide::Tools::Image to continue to work with newer versions of
 * Halide where HalideBuffer.h and Halide::Buffer are the way to work
 * with data.
 *
 * Besides mapping Halide::Tools::Image to Halide::Buffer, it defines
 * USING_HALIDE_BUFFER to allow code to conditionally compile for one
 * or the other.
 *
 * It is intended as a stop-gap measure until the code can be updated.
 */

#include "HalideBuffer.h"

namespace Halide {
namespace Tools {

#define USING_HALIDE_BUFFER

template< typename T >
using Image = Buffer<T>;

}   // namespace Tools
}   // mamespace Halide

#endif  // #ifndef HALIDE_TOOLS_IMAGE_H

Reformat comment into Doxygen comment for file.


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

/**
 * To use GoogleMapsDemos, please register an API Key for your application and set it here. Your
 * API Key should be kept private.
 *
 * See documentation on getting an API Key for your API Project here:
 * https://developers.google.com/maps/documentation/ios/start#get-key
 */

//#error Register for API Key and insert here. Then delete this line.
static NSString *const kAPIKey = @";ajlksdf";

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

/**
 * To use GoogleMapsDemos, please register an API Key for your application and set it here. Your
 * API Key should be kept private.
 *
 * See documentation on getting an API Key for your API Project here:
 * https://developers.google.com/maps/documentation/ios/start#get-key
 */

#error Register for API Key and insert here. Then delete this line.
static NSString *const kAPIKey = @"";

Use empty string as the default kAPIKey

fix: Use empty string as the default kAPIKey


// RUN: llvm-gcc %s -o - -S -emit-llvm -O3 | grep {i8 sext}
// PR1513

struct s{
long a;
long b;
};

void f(struct s a, char *b, char C) {

}

// RUN: %llvmgcc %s -o - -S -emit-llvm -O3 | grep {i8 sext}
// PR1513

struct s{
long a;
long b;
};

void f(struct s a, char *b, char C) {

}

Fix this test to not rely on the path but to use the
configured llvm-gcc instead.

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


//
//  PINRemoteImageMacros.h
//  PINRemoteImage
//
//  Created by Brian Dorfman on 10/15/15.
//  Copyright © 2015 Pinterest. All rights reserved.
//

#ifndef PINRemoteImageMacros_h
#define PINRemoteImageMacros_h

#define PINRemoteImageLogging                0
#if PINRemoteImageLogging
#define PINLog(args...) NSLog(args)
#else
#define PINLog(args...)
#endif

#if __has_include(<FLAnimatedImage/FLAnimatedImage.h>)
#define USE_FLANIMATED_IMAGE    1
#else
#define USE_FLANIMATED_IMAGE    0
#define FLAnimatedImage NSObject
#endif

#define BlockAssert(condition, desc, ...)	\
do {				\
__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS \
if (!(condition)) {		\
[[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd \
object:strongSelf file:[NSString stringWithUTF8String:__FILE__] \
lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; \
}				\
__PRAGMA_POP_NO_EXTRA_ARG_WARNINGS \
} while(0);

#endif /* PINRemoteImageMacros_h */

//
//  PINRemoteImageMacros.h
//  PINRemoteImage
//

#ifndef PINRemoteImageMacros_h
#define PINRemoteImageMacros_h

#define PINRemoteImageLogging                0
#if PINRemoteImageLogging
#define PINLog(args...) NSLog(args)
#else
#define PINLog(args...)
#endif

#if __has_include(<FLAnimatedImage/FLAnimatedImage.h>)
#define USE_FLANIMATED_IMAGE    1
#else
#define USE_FLANIMATED_IMAGE    0
#define FLAnimatedImage NSObject
#endif

#define BlockAssert(condition, desc, ...)	\
do {				\
__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS \
if (!(condition)) {		\
[[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd \
object:strongSelf file:[NSString stringWithUTF8String:__FILE__] \
lineNumber:__LINE__ description:(desc), ##__VA_ARGS__]; \
}				\
__PRAGMA_POP_NO_EXTRA_ARG_WARNINGS \
} while(0);

#endif /* PINRemoteImageMacros_h */

Remove my name from xcode's auto gen header template


/* Manages interaction with the buttons */
#ifndef BUTTON_H
#define BUTTON_H

const unsigned char BUTTON_NONE = 100;

bool button_isPressed(int buttonNumber);
void button_wait(int buttonNumber);
void button_ISR();

#endif

/* Manages interaction with the buttons */
#ifndef BUTTON_H
#define BUTTON_H

#include <Arduino.h>

const unsigned char BUTTON_NONE = 100;

bool button_isPressed(uint8_t buttonNumber);
void button_wait(uint8_t buttonNumber);
void button_ISR();

#endif

Fix header to be the same as cpp

Fix header to be the same as cpp


#ifndef _ASM_POWERPC_PAGE_32_H
#define _ASM_POWERPC_PAGE_32_H
#ifdef __KERNEL__

#define VM_DATA_DEFAULT_FLAGS	VM_DATA_DEFAULT_FLAGS32

#define PPC_MEMSTART	0

#ifndef __ASSEMBLY__
/*
 * The basic type of a PTE - 64 bits for those CPUs with > 32 bit
 * physical addressing.  For now this just the IBM PPC440.
 */
#ifdef CONFIG_PTE_64BIT
typedef unsigned long long pte_basic_t;
#define PTE_SHIFT	(PAGE_SHIFT - 3)	/* 512 ptes per page */
#else
typedef unsigned long pte_basic_t;
#define PTE_SHIFT	(PAGE_SHIFT - 2)	/* 1024 ptes per page */
#endif

struct page;
extern void clear_pages(void *page, int order);
static inline void clear_page(void *page) { clear_pages(page, 0); }
extern void copy_page(void *to, void *from);

#include <asm-generic/page.h>

#endif /* __ASSEMBLY__ */

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_PAGE_32_H */

#ifndef _ASM_POWERPC_PAGE_32_H
#define _ASM_POWERPC_PAGE_32_H
#ifdef __KERNEL__

#define VM_DATA_DEFAULT_FLAGS	VM_DATA_DEFAULT_FLAGS32

#define PPC_MEMSTART	0

#ifdef CONFIG_NOT_COHERENT_CACHE
#define ARCH_KMALLOC_MINALIGN	L1_CACHE_BYTES
#endif

#ifndef __ASSEMBLY__
/*
 * The basic type of a PTE - 64 bits for those CPUs with > 32 bit
 * physical addressing.  For now this just the IBM PPC440.
 */
#ifdef CONFIG_PTE_64BIT
typedef unsigned long long pte_basic_t;
#define PTE_SHIFT	(PAGE_SHIFT - 3)	/* 512 ptes per page */
#else
typedef unsigned long pte_basic_t;
#define PTE_SHIFT	(PAGE_SHIFT - 2)	/* 1024 ptes per page */
#endif

struct page;
extern void clear_pages(void *page, int order);
static inline void clear_page(void *page) { clear_pages(page, 0); }
extern void copy_page(void *to, void *from);

#include <asm-generic/page.h>

#endif /* __ASSEMBLY__ */

#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_PAGE_32_H */

[POWERPC] Fix kmalloc alignment on non-coherent DMA platforms

On platforms doing non-coherent DMA (4xx, 8xx, ...), it's important
that the kmalloc minimum alignment is set to the cache line size, to
avoid sharing cache lines between different objects, so that DMA to
one of the objects doesn't corrupt the other.

Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>
Signed-off-by: Paul Mackerras <19a0ba370c443ba08d20b5061586430ab449ee8c@samba.org>


/* --------------------------------------------------------------------------
 *    Name: errors.h
 * Purpose: Error type and constants
 * ----------------------------------------------------------------------- */

#ifndef ERRORS_H
#define ERRORS_H

typedef unsigned long int error;

#define error_OK                  0
#define error_EXISTS              1
#define error_NOT_FOUND           2
#define error_OOM                 3
#define error_STOP_WALK           4
#define error_CLASHES             5   /* key would clash with existing one */
#define error_NOT_IMPLEMENTED     6

#define error_KEYLEN_REQUIRED     200
#define error_KEYCOMPARE_REQUIRED 201
#define error_KEYHASH_REQIURED    202

#define error_QUEUE_FULL          300
#define error_QUEUE_EMPTY         301

#define error_TEST_FAILED         400

#define error_HASH_END            500
#define error_HASH_BAD_CONT       501

#endif /* ERRORS_H */

/* --------------------------------------------------------------------------
 *    Name: errors.h
 * Purpose: Error type and constants
 * ----------------------------------------------------------------------- */

#ifndef ERRORS_H
#define ERRORS_H

typedef unsigned long int error;

/* Generic errors */

#define error_OK                    0ul /* No error */
#define error_OOM                   1ul /* Out of memory */
#define error_NOT_IMPLEMENTED       2ul /* Function not implemented */
#define error_NOT_FOUND             3ul /* Item not found */
#define error_EXISTS                4ul /* Item already exists */
#define error_STOP_WALK             5ul /* Callback was cancelled */

/* Data structure errors */

#define error_CLASHES             100ul /* Key would clash with existing one */

#define error_QUEUE_FULL          110ul
#define error_QUEUE_EMPTY         111ul

#define error_HASH_END            120ul
#define error_HASH_BAD_CONT       121ul

/* Container errors */

#define error_KEYLEN_REQUIRED     200ul
#define error_KEYCOMPARE_REQUIRED 201ul
#define error_KEYHASH_REQIURED    202ul

/* Test errors */

#define error_TEST_FAILED         300ul

#endif /* ERRORS_H */

Make error constants unsigned longs.

Make error constants unsigned longs.


#include "util.h"

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

#include "laco.h"

static inline void ignore_extra(const char chr, char** string_ptr) {
  if(*string_ptr == NULL) return;

  while(**string_ptr == chr) {
    *string_ptr += 1;
  }
}

/* External API */

void laco_kill(LacoState* laco, int status, const char* message) {
  laco_destroy_laco_state(laco);

  if(message != NULL) {
    fprintf(stderr, "%s\n", message);
  }

  exit(status);
}

bool laco_is_match(const char** matches, const char* test_string) {
  int i;
  char* match;

  for(i = 0; (match = (char*) matches[i]); i++) {
    if(strcmp(test_string, match) == 0) {
      return true;
    }
  }

  return false;
}

char** laco_split_by(const char split_with, char* string,
                     int ignore_repeats) {
  if(string == NULL) return NULL;

  char** result = calloc(16, sizeof(char*));
  size_t i = 0;

  while(1) {
    result[i] = strsep(&string, &split_with);

    if(result[i] == NULL) break;

    if(ignore_repeats) ignore_extra(split_with, &string);

    i += 1;
  }

  return result;
}

#include "util.h"

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

#include "laco.h"

static inline void ignore_extra(const char chr, char** string_ptr) {
  if(*string_ptr == NULL) return;

  while(**string_ptr == chr) {
    *string_ptr += 1;
  }
}

/* External API */

void laco_kill(LacoState* laco, int status, const char* message) {
  laco_destroy_laco_state(laco);

  if(message != NULL) {
    fprintf(stderr, "%s\n", message);
  }

  exit(status);
}

bool laco_is_match(const char** matches, const char* test_string) {
  int i;
  const char* match;

  for(i = 0; (match = matches[i]); i++) {
    if(strcmp(test_string, match) == 0) {
      return true;
    }
  }

  return false;
}

char** laco_split_by(const char split_with, char* string,
                     int ignore_repeats) {
  if(string == NULL) return NULL;

  char** result = calloc(16, sizeof(char*));
  size_t i = 0;

  while(1) {
    result[i] = strsep(&string, &split_with);

    if(result[i] == NULL) break;

    if(ignore_repeats) ignore_extra(split_with, &string);

    i += 1;
  }

  return result;
}

Change type from `char*` to `const char*`

This is to gets rid of the explicit type conversation every iteration of the
loop.


// RUN: %clang -### -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
// RUN: %clang -### -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s

// CHECK-OPTIONS1: -fobjc-no-arc-runtime
// CHECK-OPTIONS2-NOT: -fobjc-no-arc-runtime

// RUN: %clang -### -ccc-host-triple i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s
// RUN: %clang -### -ccc-host-triple i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s
//

// CHECK-OPTIONS1: -fobjc-no-arc-runtime
// CHECK-OPTIONS2-NOT: -fobjc-no-arc-runtime

Make this test pretend to be on a darwin host.

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


#ifndef __PLASP__PDDL__TRANSLATION__PREDICATE_H
#define __PLASP__PDDL__TRANSLATION__PREDICATE_H

#include <plasp/output/Formatting.h>
#include <plasp/pddl/expressions/DerivedPredicate.h>
#include <plasp/pddl/expressions/Predicate.h>
#include <plasp/pddl/expressions/PredicateDeclaration.h>
#include <plasp/pddl/translation/Variables.h>

namespace plasp
{
namespace pddl
{
namespace translation
{

////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Predicate
//
////////////////////////////////////////////////////////////////////////////////////////////////////

void printPredicateName(output::ColorStream &outputStream, const expressions::PredicateDeclaration &predicateDeclaration);
void printDerivedPredicateName(output::ColorStream &outputStream, const expressions::DerivedPredicate &derivedPredicate);

////////////////////////////////////////////////////////////////////////////////////////////////////

inline void printPredicateName(output::ColorStream &outputStream, const expressions::PredicateDeclaration &predicateDeclaration)
{
	outputStream << output::Keyword("variable") << "(";

	if (predicateDeclaration.parameters().empty())
	{
		outputStream << output::String(predicateDeclaration.name().c_str()) << ")";
		return;
	}

	outputStream << "(" << output::String(predicateDeclaration.name().c_str());
	translation::translateVariablesForRuleHead(outputStream, predicateDeclaration.parameters());
	outputStream << "))";
}

////////////////////////////////////////////////////////////////////////////////////////////////////

inline void printDerivedPredicateName(output::ColorStream &outputStream, const expressions::DerivedPredicate &derivedPredicate)
{
	outputStream << output::Keyword("derivedVariable") << "(";

	const auto id = derivedPredicate.id();

	if (derivedPredicate.parameters().empty())
	{
		outputStream << output::Number<decltype(id)>(id) << ")";
		return;
	}

	outputStream << "(" << output::Number<decltype(id)>(id);
	translation::translateVariablesForRuleHead(outputStream, derivedPredicate.parameters());
	outputStream << "))";
}

////////////////////////////////////////////////////////////////////////////////////////////////////

}
}
}

#endif

Put functions related to translation of predicates in separate file.


/*
 * Copyright (c) 2014 Sippy Software, Inc., http://www.sippysoft.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#define RTPP_QUERY_NSTATS    5

struct rtpp_session_obj;

int handle_query(struct cfg *, struct rtpp_command *, struct rtpp_session_obj *, int);

/*
 * Copyright (c) 2014 Sippy Software, Inc., http://www.sippysoft.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#define RTPP_QUERY_NSTATS    5

struct rtpp_pipe;

int handle_query(struct cfg *, struct rtpp_command *, struct rtpp_pipe *, int);

Change from working on "session" to working on "pipes".


# ifndef COMMONPARAMS_H
# define COMMONPARAMS_H

struct CommonParams{

   int nx,ny,nz;
   int NX,NY,NZ;
   int rank;
   int np;
   int xOff;
   int iskip;
   int jskip;
   int kskip;
   int nstep;
   int numOutputs;
   double dx,dy,dz;
   double LX,LY,LZ;
   double dt;

};

# endif  // COMMONPARAMS_H

# ifndef COMMONPARAMS_H
# define COMMONPARAMS_H

struct CommonParams{

   int nx,ny,nz;
   int NX,NY,NZ;
   int rank;
   int np;
   int nbrL;
   int nbrR;
   int xOff;
   int iskip;
   int jskip;
   int kskip;
   int nstep;
   int numOutputs;
   double dx,dy,dz;
   double LX,LY,LZ;
   double dt;

};

# endif  // COMMONPARAMS_H

Add SfieldFD class and TIPS3 and TIPS4 classes to phase_field app


#ifndef KAI_CONFIG_COMPILER_H
#	define KAI_CONFIG_COMPILER_H
#
#	if defined(BOOST_MSVC)
#		define KAI_COMPILER_MSVC
#	endif
#
#	undef KAI_HAVE_PRAGMA_ONCE
#
#	ifdef KAI_COMPILER_MSVC
#		ifndef KAI_HAVE_PRAGMA_ONCE
#			define KAI_HAVE_PRAGMA_ONCE
#		endif

#	endif // KAI_COMPILER_MSVC
#endif // KAI_CONFIG_COMPILER_H

//EOF

#ifndef KAI_CONFIG_COMPILER_H
#	define KAI_CONFIG_COMPILER_H
#
#	if defined(BOOST_MSVC)
#		define KAI_COMPILER_MSVC
#	endif
#
#	undef KAI_HAVE_PRAGMA_ONCE

#pragma warning (disable: 4458 4456)

#
#	ifdef KAI_COMPILER_MSVC
#		ifndef KAI_HAVE_PRAGMA_ONCE
#			define KAI_HAVE_PRAGMA_ONCE
#		endif

#	endif // KAI_COMPILER_MSVC
#endif // KAI_CONFIG_COMPILER_H

//EOF

Apply fixes required to work with VS 2015 Community.

Former-commit-id: 11fb6880db2d2d53bb8bf126a58e2eba7d0806d3
Former-commit-id: 6923894e1f89726caee9cecd8e43d078c17ce070


// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=region
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=basic

#include <fcntl.h>

void test_open(const char *path) {
  int fd;
  fd = open(path, O_RDONLY); // no-warning
  if (!fd)
    close(fd);

  fd = open(path, O_CREAT); // expected-warning{{Call to 'open' requires a third argument when the 'O_CREAT' flag is set}}
  if (!fd)
    close(fd);
}

// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=region
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -analyzer-store=basic

#ifndef O_CREAT
#define O_CREAT 0x0200
#define O_RDONLY 0x0000
#endif
int open(const char *, int, ...);

void test_open(const char *path) {
  int fd;
  fd = open(path, O_RDONLY); // no-warning
  if (!fd)
    close(fd);

  fd = open(path, O_CREAT); // expected-warning{{Call to 'open' requires a third argument when the 'O_CREAT' flag is set}}
  if (!fd)
    close(fd);
}

Remove test case dependancy on platform headers.

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


#include <stdio.h>

const char* output_hash(void);
int getValue(void);

int main(int argc, char **argv) {

    printf("%s%d\n", output_hash(), getValue());

    return 0;
}

#include <stdio.h>

const char* output_hash(void);
int getValue(void);

int main(void) {

    printf("%s%d\n", output_hash(), getValue());

    return 0;
}

Fix shared_lib_toc test on Android

Fix shared_lib_toc test on Android

In the shared_libs_toc test, the compiler complains about unused
arguments to main(), so just declare it with a void parameter list.

Change-Id: I5c5074c1012fec7c84d11fa1d8e5b7a0b74959b4
Signed-off-by: David Kilroy <159cd46f289d7961b38b0171b53c05be4aaef0b6@arm.com>


#pragma once

#include <sstream>

#include <rapidcheck.h>
#include <catch.hpp>

namespace rc {

/// For use with `catch.hpp`. Use this function wherever you would use a
/// `SECTION` for convenient checking of properties.
///
/// @param description  A description of the property.
/// @param testable     The object that implements the property.
template <typename Testable>
void prop(const std::string &description, Testable &&testable) {
  using namespace detail;

#ifdef CATCH_CONFIG_PREFIX_ALL
  CATCH_SECTION(description) {
#else
  SECTION(description) {
#endif

    const auto result = checkTestable(std::forward<Testable>(testable));

    if (result.template is<SuccessResult>()) {
      const auto success = result.template get<SuccessResult>();
      if (!success.distribution.empty()) {
        std::cout << "- " << description << std::endl;
        printResultMessage(result, std::cout);
        std::cout << std::endl;
      }
    } else {
      std::ostringstream ss;
      printResultMessage(result, ss);
#ifdef CATCH_CONFIG_PREFIX_ALL
      CATCH_INFO(ss.str() << "\n");
      CATCH_FAIL();
#else
      INFO(ss.str() << "\n");
      FAIL();
#endif
    }
  }
}

} // namespace rc

Include the rapidcheck header at top-level


/*  Chapter 27, Try This: test cat(), find and remove performance error, add
    comments */

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

struct A {
    int x;
};

char* cat(const char* id, const char* addr)
{
    int len_id = strlen(id);        /* so it has to be calculated only once */
    int sz = len_id + strlen(addr) + 2; /* add extra space for terminating 0 */
    char* res = (char*) malloc(sz);
    strcpy(res,id);
    res[len_id] = '@';          /* and not len_id + 1 */
    strcpy(res+len_id+1,addr);  /* and not len_id + 2 */
    res[sz-1] = 0;              /* terminate string */
    return res;
}

int main()
{
    A a;
    char* id = "scott.meyers";
    char* addr = "aristeia.com";
    char* s = cat(id,addr);
    printf("%s\n",s);
}

Add Chapter 27, Try This

Add Chapter 27, Try This


// This will load a lorito bytecode file into a lorito codeseg

// Since this is temporary, and we'll end up throwing it away in favor of
//  integrating with parrot's packfile format, this will be real simple.
//
// Integer: segment type (0 = code, 1 = data)
//   Integer: Size of segement name
//   String: segment name, null terminated
//   Integer: Count (in 8 bytes, so a count of 1 == 8 bytes)
//   Data

Document the mini pack format.

Document the mini pack format.

Sadly, I mangled some nomenclature and called something a segment that
isn't in the parrot world.  Will need to fix that sometime.  Sorry.


// PARAM: --enable ana.int.interval
int main()
{
  unsigned int top;
  unsigned int start = 0;
  unsigned int count = 0;

  if(start + count > top) {
     return 1;
  }

  return 0;
}

Enable interval analysis for test

Enable interval analysis for test


#ifndef _hashable_siphash_h
#define _hashable_siphash_h

#include <stdint.h>

typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;

#define SIPHASH_ROUNDS 2
#define SIPHASH_FINALROUNDS 4

u64 hashable_siphash(int, int, u64, u64, const u8 *, size_t);
u64 hashable_siphash24(u64, u64, const u8 *, size_t);

#if defined(__i386)
u64 hashable_siphash24_sse2(u64, u64, const u8 *, size_t);
u64 hashable_siphash24_sse41(u64, u64, const u8 *, size_t);
#endif

#endif /* _hashable_siphash_h */

#ifndef _hashable_siphash_h
#define _hashable_siphash_h

#include <stdint.h>

typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;

#define SIPHASH_ROUNDS 2
#define SIPHASH_FINALROUNDS 4

u64 hashable_siphash(int, int, u64, u64, const u8 *, size_t);
u64 hashable_siphash24(u64, u64, const u8 *, size_t);

#if defined(__i386) || defined(__x86_64)

/* To use SSE instructions on Windows, we have to adjust the stack
   from its default of 4-byte alignment to use 16-byte alignment. */

# if defined(_WIN32)
#  define ALIGNED_STACK __attribute__((force_align_arg_pointer))
# else
#  define ALIGNED_STACK
# endif

u64 hashable_siphash24_sse2(u64, u64, const u8 *, size_t) ALIGNED_STACK;
u64 hashable_siphash24_sse41(u64, u64, const u8 *, size_t) ALIGNED_STACK;
#endif

#endif /* _hashable_siphash_h */

Use 16-byte stack alignment on Windows, if using SSE


#ifndef HALIDE_CPLUSPLUS_MANGLE_H
#define HALIDE_CPLUSPLUS_MANGLE_H

/** \file
 *
 * A simple function to get a C++ mangled function name for a function.
 */

#include <string>
#include "IR.h"
#include "Target.h"

namespace Halide {
namespace Internal {

/** Return the mangled C++ name for a function.
 * The target parameter is used to decide on the C++
 * ABI/mangling style to use.
 */
std::string cplusplus_function_mangled_name(const std::string &name, const std::vector<std::string> &namespaces,
                                            Type return_type, const std::vector<ExternFuncArgument> &args,
                                            const Target &target);

void cplusplus_mangle_test();

}

}

#endif

#ifndef HALIDE_CPLUSPLUS_MANGLE_H
#define HALIDE_CPLUSPLUS_MANGLE_H

/** \file
 *
 * A simple function to get a C++ mangled function name for a function.
 */

#include <string>
#include "IR.h"
#include "Target.h"

namespace Halide {
namespace Internal {

/** Return the mangled C++ name for a function.
 * The target parameter is used to decide on the C++
 * ABI/mangling style to use.
 */
EXPORT std::string cplusplus_function_mangled_name(const std::string &name, const std::vector<std::string> &namespaces,
                                                   Type return_type, const std::vector<ExternFuncArgument> &args,
                                                   const Target &target);

EXPORT void cplusplus_mangle_test();

}

}

#endif

Add some EXPORT qualifiers for msvc

Add some EXPORT qualifiers for msvc

Former-commit-id: d0593d880573052e6ae2790328a336a6a9865cc3


#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

#define MAXLINE 4096

int main(int argc, char *argv[]) {
    char buf[MAXLINE];
    pid_t pid;
    int status;

    printf("%% ");
    while (fgets(buf, MAXLINE, stdin) != NULL) {
        buf[strlen(buf) - 1] = 0;

        if ((pid = fork()) < 0) {
            printf("fork error");
        } else if (pid == 0) { /* child */
            execlp(buf, buf, (char*)0);
            printf("couldn't execute: %s\n", buf);
            return -1;
        }

        if ((pid = waitpid(pid, &status, 0)) < 0) {
            printf("waitpid error");
        }

        printf("%% ");
    }

    return 0;
}

Add read and execute command from stdin demo


#ifndef VolViz_Geometry_h
#define VolViz_Geometry_h

#include "Types.h"

namespace VolViz {

enum MoveMask : uint8_t {
  None = 0x00,
  X = 0x01,
  Y = 0x02,
  Z = 0x04,
  All = 0x07
};

struct GeometryDescriptor {
  bool movable{true};
  Color color{Colors::White()};
};

struct AxisAlignedPlaneDescriptor : public GeometryDescriptor {
  Length intercept{0 * meter};
  Axis axis{Axis::X};
};

} // namespace VolViz

#endif // VolViz_Geometry_h

#ifndef VolViz_Geometry_h
#define VolViz_Geometry_h

#include "Types.h"

namespace VolViz {

enum MoveMask : uint8_t {
  None = 0x00,
  X = 0x01,
  Y = 0x02,
  Z = 0x04,
  All = 0x07
};

inline Vector3f maskToUnitVector(MoveMask mask) noexcept {
  Vector3f v = Vector3f::Zero();
  auto maskRep = static_cast<uint8_t>(mask);

  Expects(maskRep <= 0x07);

  int idx{0};
  while (maskRep != 0) {
    if (maskRep & 0x01) v(idx) = 1.f;
    maskRep >>= 1;
    ++idx;
  }

  return v;
}

struct GeometryDescriptor {
  bool movable{true};
  Color color{Colors::White()};
};

struct AxisAlignedPlaneDescriptor : public GeometryDescriptor {
  Length intercept{0 * meter};
  Axis axis{Axis::X};
};

} // namespace VolViz

#endif // VolViz_Geometry_h

Add function to convert MoveMak to mask vector


#ifndef __HIREDIS_FMACRO_H
#define __HIREDIS_FMACRO_H

#if defined(__linux__)
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#endif

#if defined(__CYGWIN__)
#include <sys/cdefs.h>
#endif

#if defined(__sun__)
#define _POSIX_C_SOURCE 200112L
#else
#if !(defined(__APPLE__) && defined(__MACH__))
#define _XOPEN_SOURCE 600
#endif
#endif

#if defined(__APPLE__) && defined(__MACH__)
#define _OSX
#endif

#endif

#ifndef __HIREDIS_FMACRO_H
#define __HIREDIS_FMACRO_H

#if defined(__linux__)
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#endif

#if defined(__CYGWIN__)
#include <sys/cdefs.h>
#endif

#if defined(__sun__)
#define _POSIX_C_SOURCE 200112L
#else
#if !(defined(__APPLE__) && defined(__MACH__)) && !(defined(__FreeBSD__))
#define _XOPEN_SOURCE 600
#endif
#endif

#if defined(__APPLE__) && defined(__MACH__)
#define _OSX
#endif

#endif

Fix compilation on FreeBSD 10.3 with default compiler


#import "FoundationAdditions/TDTLog.h"
#import "FoundationAdditions/TDTAssert.h"
#import "FoundationAdditions/TDTSuppressPerformSelectorLeakWarning.h"
#import "FoundationAdditions/NSArray+TDTFunctionalAdditions.h"
#import "FoundationAdditions/NSSet+TDTFunctionalAdditions.h"
#import "FoundationAdditions/TDTObjectOrDefault.h"
#import "FoundationAdditions/NSArray+TDTAdditions.h"
#import "FoundationAdditions/NSString+TDTAdditions.h"
#import "FoundationAdditions/NSData+TDTStringEncoding.h"
#import "FoundationAdditions/NSDate+TDTAdditions.h"
#import "FoundationAdditions/NSDate+TDTComparisons.h"
#import "FoundationAdditions/NSDateFormatter+TDTISO8601Formatting.h"
#import "FoundationAdditions/NSFileManager+TDTAdditions.h"
#import "FoundationAdditions/NSProcessInfo+TDTEnvironmentAdditions.h"
#import "FoundationAdditions/TDTBlockAdditions.h"
#import "FoundationAdditions/TDTKeychain.h"

#import "FoundationAdditions/TDTLog.h"
#import "FoundationAdditions/TDTAssert.h"
#import "FoundationAdditions/TDTSuppressPerformSelectorLeakWarning.h"
#import "FoundationAdditions/NSArray+TDTFunctionalAdditions.h"
#import "FoundationAdditions/NSSet+TDTFunctionalAdditions.h"
#import "FoundationAdditions/TDTObjectOrDefault.h"
#import "FoundationAdditions/NSArray+TDTAdditions.h"
#import "FoundationAdditions/NSString+TDTAdditions.h"
#import "FoundationAdditions/NSData+TDTStringEncoding.h"
#import "FoundationAdditions/NSDate+TDTAdditions.h"
#import "FoundationAdditions/NSDate+TDTComparisons.h"
#import "FoundationAdditions/NSDateFormatter+TDTISO8601Formatting.h"
#import "FoundationAdditions/NSFileManager+TDTAdditions.h"
#import "FoundationAdditions/NSProcessInfo+TDTEnvironmentDetection.h"
#import "FoundationAdditions/TDTBlockAdditions.h"

Fix header paths in FoundationAdditions umbrella header


#include "hardware/packet.h"
#include "serial.h"

void btoa(int num, char *buf, int digits) {
    int shift = digits - 1;
    int current = pow(2, shift);

    char digit[2];

    while (current > 0) {
        sprintf(digit, "%d", ((num & current) >> shift) & 1);
        strncat(buf, digit, 1);

        shift--;
        current /= 2;
    }

    strcat(buf, "\0");
}

int main(int argc, char *argv[]) {
    // 0: device
    // 1: group
    // 2: plug
    // 3: status

    char device[] = "\\\\.\\\\COM5";

    if (serial_connect(device) == SERIAL_ERROR) {
        printf("Failed to connect to serial device \"%s\"\n", device);
        return 1;
    }

    struct Packet packet = { 0, 0, 0 };

    if (serial_transmit(packet) == SERIAL_ERROR) {
        printf("Failed to send data to serial device \"%s\"\n", device);
        return 1;
    }

    serial_close(device);

    return 0;
}

#include "hardware/packet.h"
#include "serial.h"

void btoa(int num, char *buf, int digits) {
    int shift = digits - 1;
    int current = pow(2, shift);

    char digit[2];

    while (current > 0) {
        sprintf(digit, "%d", ((num & current) >> shift) & 1);
        strncat(buf, digit, 1);

        shift--;
        current /= 2;
    }

    strcat(buf, "\0");
}

int main(int argc, char *argv[]) {
    // 0: device
    // 1: group
    // 2: plug
    // 3: status

    char device[] = "\\\\.\\\\COM5";

    if (serial_connect(device) == SERIAL_ERROR) {
        printf("Failed to connect to serial device \"%s\"\n", device);
        return 1;
    }

    struct Packet packet = { 1, 0, 3 };

    if (serial_transmit(packet) == SERIAL_ERROR) {
        printf("Failed to send data to serial device \"%s\"\n", device);
        return 1;
    }

    serial_close();

    return 0;
}

Add test packet data and fix invalid serial_close call


/* @author Denis Deryugin
 * @date 17 Mar 2015
 *
 * Dumb VFS
 */

#ifndef _DVFS_H_
#define _DVFS_H_

#include <fs/file_system.h>
#include <util/dlist.h>

/*****************
 New VFS prototype
 *****************/

#define DENTRY_NAME_LEN 16
#define FS_NAME_LEN     16

struct super_block;
struct inode;
struct dentry;
struct dumb_fs_driver;

struct super_block {
	struct dumb_fs_driver *fs_drv; /* Assume that all FS have single driver */
	struct block_dev *bdev;

	struct dentry     *root;
	struct dlist_head *inode_list;

	struct super_block_operations *sb_ops;

	void *sb_data;
};

struct super_block_operations {
	struct inode *(*inode_alloc)(struct super_block *sb);
	int           (*destroy_inode)(struct inode *inode);
	int           (*write_inode)(struct inode *inode);
	int           (*umount_begin)(struct super_block *sb);
};

struct inode {
	int    i_no;
	int    start_pos; /* location on disk */
	size_t length;

	struct inode_operations	*i_ops;

	void *i_data;
};

struct inode_operations {
	struct inode *(*create)(struct dentry *d_new, struct dentry *d_dir, int mode);
	struct inode *(*lookup)(char *name, struct dentry *dir);
	int           (*mkdir)(struct dentry *d_new, struct dentry *d_parent);
	int           (*rmdir)(struct dentry *dir);
	int           (*truncate)(struct inode *inode, size_t len);
	int           (*pathname)(struct inode *inode, char *buf);
};

struct dentry {
	char name[DENTRY_NAME_LEN];

	struct inode *inode;

	struct dentry     *parent;
	struct dlist_head *next;     /* Next element in this directory */
	struct dlist_head *children; /* Subelemtnts of directory */
};

struct file {
	struct dentry *f_dentry;

	off_t pos;

	struct file_operations *f_ops;
};

struct file_operations {
	int    (*open)(struct node *node, struct file *file_desc, int flags);
	int    (*close)(struct file *desc);
	size_t (*read)(struct file *desc, void *buf, size_t size);
	size_t (*write)(struct file *desc, void *buf, size_t size);
	int    (*ioctl)(struct file *desc, int request, ...);
};

struct dumb_fs_driver {
	const char name[FS_NAME_LEN];
};

#endif

Add initial implementation of new VFS header


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

#include "deps/util.h"
#include "deps/rcswitch.h"

#define PIN_RC PB2

#include "deps/softuart.h"
#include "packet.h"

int main(void) {
    // initialize serial
    softuart_init();

    // enable interrupts
    sei();

    delay_ms(1000);

    softuart_puts("Starting...\r\n");

    // enable the rc switch
    rcswitch_enable(PIN_RC);

    while (1) {

        // if there is some data waiting for us
        if (softuart_kbhit()) {

            // parse the data
            struct Packet packet;

            binary_to_packet(&packet, softuart_getchar());

            // handle the packet
            if (packet.status) {
                rcswitch_switch_on(packet.group + 1, packet.plug + 1);
            } else {
                rcswitch_switch_off(packet.group + 1, packet.plug + 1);
            }
        }
    }

    return 0;
}

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

#include "deps/util.h"
#include "deps/rcswitch.h"

#define PIN_RC PB2

#include "deps/softuart.h"
#include "packet.h"

int main(void) {
    // initialize serial
    softuart_init();

    // enable interrupts
    sei();

    // enable the rc switch
    rcswitch_enable(PIN_RC);

    while (1) {

        // if there is some data waiting for us
        if (softuart_kbhit()) {

            // parse the data
            struct Packet packet;

            binary_to_packet(&packet, softuart_getchar());

            // handle the packet
            if (packet.status) {
                rcswitch_switch_on(packet.group + 1, packet.plug + 1);
            } else {
                rcswitch_switch_off(packet.group + 1, packet.plug + 1);
            }
        }
    }

    return 0;
}

Remove startup delay and messages

Remove startup delay and messages


/****************************************************************************
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** If you have questions regarding the use of this file, please
** contact Nokia at http://www.qtsoftware.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTMESSAGING_H
#define QTMESSAGING_H

#include "qmessageglobal.h"
#include "qmessageaccount.h"
#include "qmessageaccountfilterkey.h"
#include "qmessageaccountid.h"
#include "qmessageaccountsortkey.h"
#include "qmessagefolder.h"
#include "qmessagefolderfilterkey.h"
#include "qmessagefolderid.h"
#include "qmessagefoldersortkey.h"
#include "qmessage.h"
#include "qmessagefilterkey.h"
#include "qmessageid.h"
#include "qmessagesortkey.h"
#include "qmessagecontentcontainer.h"
#include "qmessagecontentcontainerid.h"
#include "qmessageaddress.h"
#include "qmessageserviceaction.h"
#include "qmessagestore.h"

#endif

Add header for including messaging module.


/*
 * Copyright 2015-2016 Yury Gribov
 *
 * Use of this source code is governed by MIT license that can be
 * found in the LICENSE.txt file.
 */

#ifndef FLAGS_H
#define FLAGS_H

enum CheckFlags {
  CHECK_BASIC        = 1 << 0,
  CHECK_REFLEXIVITY  = 1 << 1,
  CHECK_SYMMETRY     = 1 << 2,
  CHECK_TRANSITIVITY = 1 << 3,
  CHECK_SORTED       = 1 << 4,
  CHECK_GOOD_BSEARCH = 1 << 5,
  CHECK_UNIQUE       = 1 << 6,
  // Do not check reflexivity because it's normally not important (CHECK_REFLEXIVITY).
  // Do not assume bsearch is commutative (CHECK_GOOD_BSEARCH).
  CHECK_DEFAULT      = CHECK_BASIC | CHECK_SYMMETRY
                       | CHECK_TRANSITIVITY | CHECK_SORTED,
  CHECK_ALL          = 0xffffffff,
};

typedef struct {
  char debug : 1;
  char report_error : 1;
  char print_to_syslog : 1;
  char raise : 1;
  unsigned max_errors;
  unsigned sleep;
  unsigned checks;
  const char *out_filename;
} Flags;

int parse_flags(char *opts, Flags *flags);

#endif

/*
 * Copyright 2015-2016 Yury Gribov
 *
 * Use of this source code is governed by MIT license that can be
 * found in the LICENSE.txt file.
 */

#ifndef FLAGS_H
#define FLAGS_H

enum CheckFlags {
  CHECK_BASIC        = 1 << 0,
  CHECK_REFLEXIVITY  = 1 << 1,
  CHECK_SYMMETRY     = 1 << 2,
  CHECK_TRANSITIVITY = 1 << 3,
  CHECK_SORTED       = 1 << 4,
  CHECK_GOOD_BSEARCH = 1 << 5,
  CHECK_UNIQUE       = 1 << 6,
  // Do not check reflexivity because it's normally not important (CHECK_REFLEXIVITY).
  // Do not assume bsearch is commutative (CHECK_GOOD_BSEARCH).
  CHECK_DEFAULT      = CHECK_BASIC | CHECK_SYMMETRY
                       | CHECK_TRANSITIVITY | CHECK_SORTED,
  CHECK_ALL          = 0xffffffff,
};

typedef struct {
  unsigned char debug : 1;
  unsigned char report_error : 1;
  unsigned char print_to_syslog : 1;
  unsigned char raise : 1;
  unsigned max_errors;
  unsigned sleep;
  unsigned checks;
  const char *out_filename;
} Flags;

int parse_flags(char *opts, Flags *flags);

#endif

Make bitfield signs explicitly signed (detected by Semmle).


// SKIP PARAM: --sets ana.activated[+] apron
#include <assert.h>

void main() {
  int x, y, z;

  // TODO: make these asserts after distinction
  __goblint_commit(x < y); // U NKNOWN! (refines)
  __goblint_commit(y < z); // U NKNOWN! (refines)

  __goblint_commit(3 <= x); // U NKNOWN! (refines)
  __goblint_commit(z <= 5); // U NKNOWN! (refines)

  assert(x == 3);
  assert(y == 4);
  assert(z == 5);
}

Add test where octApron assert should refine


#pragma once

template <typename T, unsigned int N>
struct FixedVector
{
    T data[N];

    __host__ __device__
    FixedVector() { }

    __host__ __device__
    FixedVector(T init)
    {
        for(unsigned int i = 0; i < N; i++)
            data[i] = init;
    }

    __host__ __device__
    FixedVector operator+(const FixedVector& bs) const
    {
        FixedVector output;
        for(unsigned int i = 0; i < N; i++)
            output.data[i] = data[i] + bs.data[i];
        return output;
    }

    __host__ __device__
    bool operator<(const FixedVector& bs) const
    {
        for(unsigned int i = 0; i < N; i++)
        {
            if(data[i] < bs.data[i])
                return true;
            else if(bs.data[i] < data[i])
                return false;
        }
        return false;
    }

    __host__ __device__
    bool operator==(const FixedVector& bs) const
    {
        for(unsigned int i = 0; i < N; i++)
        {
            if(!(data[i] == bs.data[i]))
                return false;
        }
        return true;
    }
};

#pragma once

template <typename T, unsigned int N>
struct FixedVector
{
    T data[N];

    __host__ __device__
    FixedVector() : data() { }

    __host__ __device__
    FixedVector(T init)
    {
        for(unsigned int i = 0; i < N; i++)
            data[i] = init;
    }

    __host__ __device__
    FixedVector operator+(const FixedVector& bs) const
    {
        FixedVector output;
        for(unsigned int i = 0; i < N; i++)
            output.data[i] = data[i] + bs.data[i];
        return output;
    }

    __host__ __device__
    bool operator<(const FixedVector& bs) const
    {
        for(unsigned int i = 0; i < N; i++)
        {
            if(data[i] < bs.data[i])
                return true;
            else if(bs.data[i] < data[i])
                return false;
        }
        return false;
    }

    __host__ __device__
    bool operator==(const FixedVector& bs) const
    {
        for(unsigned int i = 0; i < N; i++)
        {
            if(!(data[i] == bs.data[i]))
                return false;
        }
        return true;
    }
};

Initialize FixedVector's member in its null constructor to eliminate a Wall warning.


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

inherit LIB_INITD;
inherit UTILITY_COMPILE;

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

	load_dir("sys");

	LOGD->post_message("account", LOG_DEBUG, "Hello world from the account subsystem");
}

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

inherit LIB_INITD;
inherit UTILITY_COMPILE;

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

	load_dir("sys");
}

Remove spammy hello world from account system


/** \file
 *
 *  \brief            Inclusion of all utility function headers
 *
 *  \date             Created:  Jul 12, 2014
 *  \date             Modified: $Date$
 *
 *  \authors          mauro <mauro@iis.ee.ethz.ch>
 *
 *  \version          $Revision$
 */
#ifndef LINALG_UTILITIES_UTILITIES_H_
#define LINALG_UTILITIES_UTILITIES_H_

// Keep this in alphabetical order
#include "buffer.h"
#include "checks.h"
#include "copy_array.h"
#include "CSR.h"
#include "format_convert.h"
#include "IJV.h"
#include "memory_allocation.h"
#include "misc.h"
#include "stringformat.h"
#include "timer.h"

#endif /* LINALG_UTILITIES_UTILITIES_H_ */

/** \file
 *
 *  \brief            Inclusion of all utility function headers
 *
 *  \date             Created:  Jul 12, 2014
 *  \date             Modified: $Date$
 *
 *  \authors          mauro <mauro@iis.ee.ethz.ch>
 *
 *  \version          $Revision$
 */
#ifndef LINALG_UTILITIES_UTILITIES_H_
#define LINALG_UTILITIES_UTILITIES_H_

// Keep this in alphabetical order
#include "buffer_helper.h"
#include "checks.h"
#include "copy_array.h"
#include "CSR.h"
#include "format_convert.h"
#include "IJV.h"
#include "memory_allocation.h"
#include "misc.h"
#include "stringformat.h"
#include "timer.h"

#endif /* LINALG_UTILITIES_UTILITIES_H_ */

Rename buffer.h to buffer_helper.h, part II


/**
 * @file
 *
 * @brief tests if compilation works (include and build paths set correct, etc...)
 *
 * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
 *
 */

#include <openssl/evp.h>

int main (void)
{
	EVP_CIPHER_CTX * opensslSpecificType;
	return 0;
}

/**
 * @file
 *
 * @brief tests if compilation works (include and build paths set correct, etc...)
 *
 * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
 *
 */

#include <openssl/evp.h>

EVP_CIPHER_CTX * nothing (void)
{
	return NULL;
}

int main (void)
{
	nothing ();
	return 0;
}

OpenSSL: Fix detection of lib if we use `-Werror`

Before this update detecting OpenSSL would fail, if we treated warnings
as errors (`-Werror`). The cause of this problem was that compiling
`compile_openssl.cpp` produced a warning about an unused variable.


/*
 *
 * SOS Source Code
 * __________________
 *
 *  [2009] - [2013] Samuel Steven Truscott
 *  All Rights Reserved.
 */
#include "time_manager.h"

#include "kernel/kernel_assert.h"
#include "time.h"

static int64_t __time_system_time_ns;
static __clock_device_t * __time_system_clock;

void __time_initialise(void)
{
	__time_system_time_ns = 0;
	__time_system_clock = NULL;
}

void __time_set_system_clock(__clock_device_t * const device)
{
	__time_system_clock = device;
}

sos_time_t __time_get_system_time(void)
{
	sos_time_t time = SOS_ZERO_TIME;

	if (__time_system_clock)
	{
		__time_system_time_ns = (int64_t)__time_system_clock->get_time();
		time.seconds = (int32_t)__time_system_time_ns / ONE_SECOND_AS_NANOSECONDS;
		time.nanoseconds = (int64_t)(__time_system_time_ns - ((int64_t)time.seconds * ONE_SECOND_AS_NANOSECONDS));
	}

	return time;
}

/*
 *
 * SOS Source Code
 * __________________
 *
 *  [2009] - [2013] Samuel Steven Truscott
 *  All Rights Reserved.
 */
#include "time_manager.h"

#include "kernel/kernel_assert.h"
#include "time.h"

static uint64_t __time_system_time_ns;
static __clock_device_t * __time_system_clock;

void __time_initialise(void)
{
	__time_system_time_ns = 0;
	__time_system_clock = NULL;
}

void __time_set_system_clock(__clock_device_t * const device)
{
	__time_system_clock = device;
}

sos_time_t __time_get_system_time(void)
{
	sos_time_t time = SOS_ZERO_TIME;

	if (__time_system_clock)
	{
		__time_system_time_ns = __time_system_clock->get_time();
		time.seconds = __time_system_time_ns / ONE_SECOND_AS_NANOSECONDS;
		time.nanoseconds = (int64_t)(__time_system_time_ns - ((int64_t)time.seconds * ONE_SECOND_AS_NANOSECONDS));
	}

	return time;
}

Fix the powerpc clock from the tbr.

Fix the powerpc clock from the tbr.


#include <assert.h>
#include <stdio.h>

int main(){
    unsigned int x  = 1;

    unsigned int y = -x;

    assert(y == 4294967295);
    printf("y: %u\n", y);
    return 0;
}

Add testcase: retain precision when negating unsigned value


#pragma once
#ifndef YOU_DATASTORE_INTERNAL_INTERNAL_TRANSACTION_H_
#define YOU_DATASTORE_INTERNAL_INTERNAL_TRANSACTION_H_

#include <memory>
#include <boost/ptr_container/ptr_deque.hpp>

#include "operation.h"

namespace You {
namespace DataStore {
namespace UnitTests { class DataStoreApiTest; }
namespace Internal {

/// The actual class that contains the logic for managing transactions.
class Transaction {
	friend class DataStore;
	friend class UnitTests::DataStoreApiTest;

public:
	/// Default constructor. This is meant to be called by \ref DataStore.
	Transaction() = default;

	/// Commits the set of operations made.
	void commit();

	/// Rolls back all the operations made.
	void rollback();

	/// Pushes a transaction onto the stack. This is meant to be called by
	/// \ref DataStore.
	///
	/// \param[in] operation The operation to push.
	void push(std::unique_ptr<IOperation> operation);

private:
	/// The set of operations that need to be executed when the transaction is
	/// committed.
	boost::ptr_deque<IOperation> operationsQueue;
};

}  // namespace Internal
}  // namespace DataStore
}  // namespace You

#endif  // YOU_DATASTORE_INTERNAL_INTERNAL_TRANSACTION_H_

#pragma once
#ifndef YOU_DATASTORE_INTERNAL_INTERNAL_TRANSACTION_H_
#define YOU_DATASTORE_INTERNAL_INTERNAL_TRANSACTION_H_

#include <memory>
#include <boost/ptr_container/ptr_deque.hpp>

#include "operation.h"

namespace You {
namespace DataStore {
namespace UnitTests { class DataStoreApiTest; }
namespace Internal {

/// The actual class that contains the logic for managing transactions.
class Transaction {
	friend class DataStore;
	friend class UnitTests::DataStoreApiTest;

public:
	/// Default constructor. This is meant to be called by \ref DataStore.
	Transaction() = default;

	/// Commits the set of operations made.
	void commit();

	/// Rolls back all the operations made.
	void rollback();

	/// Pushes a transaction onto the stack. This is meant to be called by
	/// \ref DataStore.
	///
	/// \param[in] operation The operation to push.
	void push(std::unique_ptr<IOperation> operation);

	/// Merges the operationsQueue of the next transaction that is committed
	/// earlier.
	///
	/// \param[in] queue The operations queue
	void mergeQueue(boost::ptr_deque<IOperation>& queue);

private:
	/// The set of operations that need to be executed when the transaction is
	/// committed.
	boost::ptr_deque<IOperation> operationsQueue;

	boost::ptr_deque<IOperation> mergedOperationsQueue;
};

}  // namespace Internal
}  // namespace DataStore
}  // namespace You

#endif  // YOU_DATASTORE_INTERNAL_INTERNAL_TRANSACTION_H_

Add mergedOperationsQueue and mergeQueue to ensure correctness of file being modified


//===--- TokenKinds.h - Token Kinds Interface -------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 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
//
//===----------------------------------------------------------------------===//
//
//  This file defines the Token kinds.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_TOKENKINDS_H
#define SWIFT_TOKENKINDS_H

namespace swift {
enum class tok {
#define TOKEN(X) X,
#include "swift/Syntax/TokenKinds.def"

  NUM_TOKENS
};

/// Check whether a token kind is known to have any specific text content.
/// e.g., tol::l_paren has determined text however tok::identifier doesn't.
bool isTokenTextDetermined(tok kind);

/// If a token kind has determined text, return the text; otherwise assert.
StringRef getTokenText(tok kind);

void dumpTokenKind(llvm::raw_ostream &os, tok kind);
} // end namespace swift

#endif // SWIFT_TOKENKINDS_H

//===--- TokenKinds.h - Token Kinds Interface -------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 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
//
//===----------------------------------------------------------------------===//
//
//  This file defines the Token kinds.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_TOKENKINDS_H
#define SWIFT_TOKENKINDS_H

#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"

namespace swift {
enum class tok {
#define TOKEN(X) X,
#include "swift/Syntax/TokenKinds.def"

  NUM_TOKENS
};

/// Check whether a token kind is known to have any specific text content.
/// e.g., tol::l_paren has determined text however tok::identifier doesn't.
bool isTokenTextDetermined(tok kind);

/// If a token kind has determined text, return the text; otherwise assert.
StringRef getTokenText(tok kind);

void dumpTokenKind(llvm::raw_ostream &os, tok kind);
} // end namespace swift

#endif // SWIFT_TOKENKINDS_H

Prepare the header for stand-alone usage.


// RUN: clang-cc %s -Eonly 2>&1 | grep error

#define COMM1 / ## /
COMM1

// RUN: clang-cc %s -Eonly -fms-extensions=0 2>&1 | grep error

#define COMM1 / ## /
COMM1

Disable Microsoft extensions to fix failure on Windows.

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


#ifndef OPTHELPERS_H
#define OPTHELPERS_H

#ifdef __has_builtin
#define HAS_BUILTIN __has_builtin
#else
#define HAS_BUILTIN(x) (0)
#endif

#ifdef __GNUC__
/* LIKELY optimizes the case where the condition is true. The condition is not
 * required to be true, but it can result in more optimal code for the true
 * path at the expense of a less optimal false path.
 */
#define LIKELY(x) __builtin_expect(!!(x), !0)
/* The opposite of LIKELY, optimizing the case where the condition is false. */
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
/* Unlike LIKELY, ASSUME requires the condition to be true or else it invokes
 * undefined behavior. It's essentially an assert without actually checking the
 * condition at run-time, allowing for stronger optimizations than LIKELY.
 */
#if HAS_BUILTIN(__builtin_assume)
#define ASSUME __builtin_assume
#else
#define ASSUME(x) do { if(!(x)) __builtin_unreachable(); } while(0)
#endif

#else /* __GNUC__ */

#define LIKELY(x) (!!(x))
#define UNLIKELY(x) (!!(x))
#ifdef _MSC_VER
#define ASSUME __assume
#else
#define ASSUME(x) ((void)0)
#endif /* _MSC_VER */
#endif /* __GNUC__ */

#endif /* OPTHELPERS_H */

#ifndef OPTHELPERS_H
#define OPTHELPERS_H

#ifdef __has_builtin
#define HAS_BUILTIN __has_builtin
#else
#define HAS_BUILTIN(x) (0)
#endif

#ifdef __GNUC__
/* LIKELY optimizes the case where the condition is true. The condition is not
 * required to be true, but it can result in more optimal code for the true
 * path at the expense of a less optimal false path.
 */
#define LIKELY(x) __builtin_expect(!!(x), !false)
/* The opposite of LIKELY, optimizing the case where the condition is false. */
#define UNLIKELY(x) __builtin_expect(!!(x), false)
/* Unlike LIKELY, ASSUME requires the condition to be true or else it invokes
 * undefined behavior. It's essentially an assert without actually checking the
 * condition at run-time, allowing for stronger optimizations than LIKELY.
 */
#if HAS_BUILTIN(__builtin_assume)
#define ASSUME __builtin_assume
#else
#define ASSUME(x) do { if(!(x)) __builtin_unreachable(); } while(0)
#endif

#else /* __GNUC__ */

#define LIKELY(x) (!!(x))
#define UNLIKELY(x) (!!(x))
#ifdef _MSC_VER
#define ASSUME __assume
#else
#define ASSUME(x) ((void)0)
#endif /* _MSC_VER */
#endif /* __GNUC__ */

#endif /* OPTHELPERS_H */

Use false instead of 0 for a boolean

Use false instead of 0 for a boolean