/*
 * Copyright (C) 2000  Internet Software Consortium.
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 */

#include <stdio.h>
#include <sys/socket.h>
#include <lwres/netdb.h>

static void
print_he(struct hostent *he, int error, const char *fun, const char *name) {
	char **c;
	int i;

	if (he != NULL) {
		 printf("%s(%s):\n", fun, name);
		 printf("\tname = %s\n", he->h_name);
		 printf("\taddrtype = %d\n", he->h_addrtype);
		 printf("\tlength = %d\n", he->h_length);
		 c = he->h_aliases;
		 i = 1;
		 while (*c != NULL) {
			printf("\talias[%d] = %s\n", i, *c);
			i++;
			c++;
		 }
		 c = he->h_addr_list;
		 i = 1;
		 while (*c != NULL) {
			char buf[128];
			inet_ntop(he->h_addrtype, c, buf, sizeof (buf));
			printf("\taddress[%d] = %s\n", i, buf);
			c++;
			i++;
		}
	} else {
		printf("%s(%s): error = %d\n", fun, name, error);
	}
}

int
main(int argc, char **argv) {
	struct hostent *he;
	char **c;
	int error;

	while (argv[1] != NULL) {
		he = gethostbyname(argv[1]);
		print_he(he, 0 /* XXX h_errno */, "gethostbyname", argv[1]);

		he = getipnodebyname(argv[1], AF_INET, AI_DEFAULT|AI_ALL,
				     &error);
		print_he(he, error, "getipnodebyname", argv[1]);
		if (he != NULL)
			freehostent(he);
		argv++;
	}
	exit(0);
}

Test getipnodebyname() & gethostbyname() implementations.


// Compile with:
// $ gcc -Wall -Werror -o putc_example putc_example.c
//
// 1. Warm up: Make the program print out the string backwards
// 2. $ rm -f putc_example  (remove the compiled program)
//    Comment out all of the #include headers in this file and re-run the
//    compile command.  You should see warnings, and no ouput file is generated.
//    Try to get the program to compile/generate an output file without
//    adding the include files back in.  (There are two different ways that
//    I can think of to do this).
// 3. In C, arrays and pointers are the same thing.  Rewrite the "loop"
//    section below using pointers instead of arrays (ie, dont use the [ ]
//    syntax).
//    See: http://www.google.com/search?q=c+pointers+arrays

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

int main(int argc, char* argv[]) {
  if (argc != 2) {
    printf("Usage: %s <string>\n", argv[0]);
    return 0;
  }

  // This code is equivalent to printf("%s\n", argv[1]);
  const char* string_argument = argv[1];
  int length = strlen(string_argument);
  int i;
  for (i = 0; i < length; i++) {
    char c = string_argument[i];
    putchar(c);
  }
  putchar('\n');

  return 0;
}

// Compile with:
// $ gcc -Wall -Werror -o putc_example putc_example.c
//
// 1. Warm up: Make the program print out the string backwards
// 2. $ rm -f putc_example  (remove the compiled program)
//    Comment out all of the #include headers in this file and re-run the
//    compile command.  You should see warnings, and no ouput file is generated.
//    Try to get the program to compile/generate an output file without
//    adding the include files back in.  (There are two different ways that
//    I can think of to do this).
// 3. In C, arrays and pointers are the same thing.  Rewrite the "loop"
//    section below using pointers instead of arrays (ie, dont use the [ ]
//    syntax).
//    See: http://www.google.com/search?q=c+pointers+arrays

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

int main(int argc, char* argv[]) {
  if (argc != 2) {
    printf("Usage: %s <string>\n", argv[0]);
    return 0;
  }

  // This code is equivalent to printf("%s\n", argv[1]);
  const char* string_argument = argv[1];
  size_t length = strlen(string_argument);
  int i;
  for (i = 0; i < length; i++) {
    char c = string_argument[i];
    putchar(c);
  }
  putchar('\n');

  return 0;
}

Use size_t for strlen result, so it matches the man page.


#ifndef FILE_UTILS_H
#define FILE_UTILS_H

#include <stdint.h>
#include <string.h>
#include <dirent.h>

#define PATHLEN 32
#define MAXPATH 1024

#define PROC "/proc/"

#define MEMINFO "/proc/meminfo"
#define STATUS "/proc/%s/status"

#define IO_STAT "/proc/%s/io"

#define STAT "/proc/%s/stat"
#define STAT_BUFFER 4096

#define COMM "/proc/%s/comm"
#define COMM_LEN strlen(COMM)

#define FD "/proc/%s/fd"

#define UID "Uid:\t"

char *parse_stat(char *pid, int field);

char *parse_proc(char *path, char *field);

int is_pid(const struct dirent *directory);

char *strip(char *stat);

char *calculate_size(char *field_total, int byte_idx);

uint64_t value_from_string(char *ps_field_value);

#endif

#ifndef FILE_UTILS_H
#define FILE_UTILS_H

#include <stdint.h>
#include <string.h>
#include <dirent.h>

#define PATHLEN 32
#define MAXPATH 1024
#define PROC_SIZE 1024

#define PROC "/proc/"

#define MEMINFO "/proc/meminfo"
#define STATUS "/proc/%s/status"

#define IO_STAT "/proc/%s/io"

#define STAT "/proc/%s/stat"
#define STAT_BUFFER 4096

#define COMM "/proc/%s/comm"
#define COMM_LEN strlen(COMM)

#define FD "/proc/%s/fd"

#define UID "Uid:\t"

char *parse_stat(char *pid, int field);

char *parse_proc(char *path, char *field);

int is_pid(const struct dirent *directory);

char *strip(char *stat);

char *calculate_size(char *field_total, int byte_idx);

uint64_t value_from_string(char *ps_field_value);

#endif

Define macro for size of proc parser

Define macro for size of proc parser


//
//  UIAlertView+RACCommandSupport.h
//  ReactiveCocoa
//
//  Created by Henrik Hodne on 6/16/13.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@class RACCommand;

@interface UIAlertView (RACCommandSupport)

// Sets the alert view's command. When a button on the alert view is pressed,
// the command is executed with the index of the button that was pressed.
@property (nonatomic, strong) RACCommand *rac_command;

@end

//
//  UIAlertView+RACCommandSupport.h
//  ReactiveCocoa
//
//  Created by Henrik Hodne on 6/16/13.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@class RACCommand;

@interface UIAlertView (RACCommandSupport)

// Sets the alert view's command. When a button on the alert view is pressed,
// the command is executed with the index of the button that was pressed.
//
// This will override the alert view's delegate, so you can't use this together
// with a custom delegate.
@property (nonatomic, strong) RACCommand *rac_command;

@end

Document that UIAlertView.rac_command overrides the delegate


//
//  HTMLKit.h
//  HTMLKit
//
//  Created by Iska on 15/09/14.
//  Copyright (c) 2014 BrainCookie. All rights reserved.
//

#import <Foundation/Foundation.h>

//! Project version number for HTMLKit.
extern double HTMLKitVersionNumber;

//! Project version string for HTMLKit.
extern const unsigned char HTMLKitVersionString[];

#import "HTMLDOM.h"
#import "HTMLParser.h"
#import "HTMLKitErrorDomain.h"
#import "HTMLOrderedDictionary.h"

#import "CSSSelectors.h"
#import "CSSSelectorParser.h"
#import "CSSNthExpressionParser.h"

#import "NSString+HTMLKit.h"
#import "NSCharacterSet+HTMLKit.h"

Add imports for the public categories in the umbrella header


#ifndef JOINABLE_IMPL
#define JOINABLE_IMPL

#include "joinable_types.h"
#include "types/MediaObjectImpl.h"

using ::com::kurento::kms::api::Joinable;
using ::com::kurento::kms::api::Direction;
using ::com::kurento::kms::api::StreamType;

namespace com { namespace kurento { namespace kms {

class JoinableImpl : public virtual Joinable, public virtual MediaObjectImpl {
public:
	JoinableImpl();
	~JoinableImpl() throw() {};

	std::vector<StreamType::type> getStreams(const Joinable& joinable);

	void join(const JoinableImpl& to, const Direction::type direction);
	void unjoin(const JoinableImpl& to);

	void join(const JoinableImpl& to, const StreamType::type stream, const Direction::type direction);
	void unjoin(const JoinableImpl& to, const StreamType::type stream);

	std::vector<Joinable> &getJoinees();
	std::vector<Joinable> &getDirectionJoiness(const Direction::type direction);

	std::vector<Joinable> &getJoinees(const StreamType::type stream);
	std::vector<Joinable> &getDirectionJoiness(const StreamType::type stream, const Direction::type direction);
};

}}} // com::kurento::kms

#endif /* JOINABLE_IMPL */

Add new line at end of file

Add new line at end of file


// SKIP PARAM: --set ana.activated[+] apron
extern int __VERIFIER_nondet_int();

#include <pthread.h>
#include <assert.h>

int g = 5;
int h = 5;
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
  return NULL;
}

int main() {
  int r = __VERIFIER_nondet_int();
  pthread_t id;

  if (r) {
    pthread_create(&id, NULL, t_fun, NULL);
  }
  else {
    h = 10;
  }
  // sync join needs to publish globals also to protected/mutex_inits like enter_multithreaded
  // might need join strengthening to reveal unsoundness instead of going to top directly

  pthread_mutex_lock(&m);
  assert(g == h); // UNKNOWN!
  pthread_mutex_unlock(&m);

  return 0;
}

Add Apron branched thread creation privatization test, where protected is unsound


//
//  Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "OpenMRSAPIManager.h"
#import "LocationListTableViewController.h"
#import "UIAlertView+Blocks.h"
#import "MRSHelperFunctions.h"

Add MRSHelper functions to Bridging Header


//! \file CommandLineParser.h

#ifndef _COMMANDLINEPARSER_H
#define _COMMANDLINEPARSER_H

#include <string>

//! Abstract base class for parsing command line arguments
class CommandLineParser
{
public:
    /*! Parses command line args and stores results internally.
     * May throw an exception in case of error
     * \param argc number of arguments
     * \param argv arguments as passed to main
     */
    virtual void parse(int argc, char** argv) = 0;

    /*! Query whether a specific flag was set on command line.
     * \param flag Command line switch without leading dash
     * \return whether specified flag was set on command line
     */
    virtual bool hasSet(std::string flag) = 0;

    /*! get argument of switch (if available)
     * \param option command line switch without leading dash
     * \returns value as string
    */
    virtual std::string getValue(std::string option) = 0;

    /*! Print usage help
     */
    virtual void printHelp() = 0;
};

#endif // _COMMANDLINEPARSER_H

//! \file CommandLineParser.h

#ifndef _COMMANDLINEPARSER_H
#define _COMMANDLINEPARSER_H

#include <string>

//! Abstract base class for parsing command line arguments
class CommandLineParser
{
public:
    virtual ~CommandLineParser() {};

    /*! Parses command line args and stores results internally.
     * May throw an exception in case of error
     * \param argc number of arguments
     * \param argv arguments as passed to main
     */
    virtual void parse(int argc, char** argv) = 0;

    /*! Query whether a specific flag was set on command line.
     * \param flag Command line switch without leading dash
     * \return whether specified flag was set on command line
     */
    virtual bool hasSet(std::string flag) = 0;

    /*! get argument of switch (if available)
     * \param option command line switch without leading dash
     * \returns value as string
    */
    virtual std::string getValue(std::string option) = 0;

    /*! Print usage help
     */
    virtual void printHelp() = 0;
};

#endif // _COMMANDLINEPARSER_H

Make Command line parser d'tor virtual

Make Command line parser d'tor virtual


/*
PubSubClient_JSON.h - ArduinoJson support for PubSubClient
Copyright (C) 2016 Ian Tester

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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#pragma once

#include <ArduinoJson.h>

namespace MQTT {
  class PublishJSON : public Publish {
  public:
    //! Publish a JSON object from the ArduinoJson library
    /*!
      \param topic Topic of the message
      \param payload Object of the message
    */
    PublishJSON(String topic, ArduinoJson::JsonObject& object) :
      Publish(topic, NULL, object.measureLength() + 1)
    {
      _payload = new uint8_t[_payload_len];
      if (_payload != NULL)
	object.printTo((char*)_payload, _payload_len);
    }

    //! Publish a JSON array from the ArduinoJson library
    /*!
      \param topic Topic of the message
      \param payload Array of the message
    */
    PublishJSON(String topic, ArduinoJson::JsonArray& array) :
      Publish(topic, NULL, array.measureLength() + 1)
    {
      _payload = new uint8_t[_payload_len];
      if (_payload != NULL)
	array.printTo((char*)_payload, _payload_len);
    }

  };

};

Add header file for publishing ArduinoJson objects and arrays


inline string
get_file_contents(char *filename)
{
	ifstream file(filename, ios::in | ios::ate);
	if (!file.is_open())
		return string();
	streampos sz = file.tellg();
	file.seekg(0, ios::beg);
	vector<char> v(sz);
	file.read(&v[0], sz);
	file.close();
	string data(v.empty() ? string() : string (v.begin(), v.end()).c_str());
	return data;
}

inline string
get_file_contents(const char *filename)
{
	ifstream file(filename, ios::in | ios::ate);
	if (!file.is_open())
		return string();
	streampos sz = file.tellg();
	file.seekg(0, ios::beg);
	vector<char> v(sz);
	file.read(&v[0], sz);
	file.close();
	string data(v.empty() ? string() : string (v.begin(), v.end()).c_str());
	return data;
}

Fix compiler warnings in the test suite

Fix compiler warnings in the test suite


#ifndef __NEW_ITERATOR_PYWRAP_H
#define __NEW_ITERATOR_PYWRAP_H

NPY_NO_EXPORT PyObject *
NpyIter_NestedIters(PyObject *NPY_UNUSED(self),
                    PyObject *args, PyObject *kwds);

#endif

#ifndef __NDITER_PYWRAP_H
#define __NDITER_PYWRAP_H

NPY_NO_EXPORT PyObject *
NpyIter_NestedIters(PyObject *NPY_UNUSED(self),
                    PyObject *args, PyObject *kwds);

#endif

Make include flag name match file name.

STY: Make include flag name match file name.


#ifndef __PLAYER_H__
#define __PLAYER_H__

#include<iostream>
#include"GameObject.h"

class PLayer: public GameObject
{
    public:
        void update();
        void clean()
        {
            GameObject::clean();
            std::cout << "clean PLayer";
        }
};

#endif

#ifndef __PLAYER_H__
#define __PLAYER_H__

#include<iostream>
#include"GameObject.h"

class Player: public GameObject
{
    public:
        void update();
        void clean()
        {
            std::cout << "clean PLayer";
        }
};

#endif

Fix class name and remove GameObject::clean call.


//===-- DIContext.h ---------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines DIContext, and abstract data structure that holds
// debug information data.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_DEBUGINFO_DICONTEXT_H
#define LLVM_DEBUGINFO_DICONTEXT_H

#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DILineInfo.h"

namespace llvm {

class raw_ostream;

class DIContext {
public:
  virtual ~DIContext();

  /// getDWARFContext - get a context for binary DWARF data.
  static DIContext *getDWARFContext(bool isLittleEndian,
                                    StringRef infoSection,
                                    StringRef abbrevSection,
                                    StringRef aRangeSection = StringRef(),
                                    StringRef lineSection = StringRef(),
                                    StringRef stringSection = StringRef());

  virtual void dump(raw_ostream &OS) = 0;
};

}

#endif

//===-- DIContext.h ---------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines DIContext, and abstract data structure that holds
// debug information data.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_DEBUGINFO_DICONTEXT_H
#define LLVM_DEBUGINFO_DICONTEXT_H

#include "llvm/ADT/StringRef.h"

namespace llvm {

class raw_ostream;

class DIContext {
public:
  virtual ~DIContext();

  /// getDWARFContext - get a context for binary DWARF data.
  static DIContext *getDWARFContext(bool isLittleEndian,
                                    StringRef infoSection,
                                    StringRef abbrevSection,
                                    StringRef aRangeSection = StringRef(),
                                    StringRef lineSection = StringRef(),
                                    StringRef stringSection = StringRef());

  virtual void dump(raw_ostream &OS) = 0;
};

}

#endif

Remove include of header that doesn't exist (yet).

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


/*
 * mhcachesbr.h -- definitions for manipulating MIME content cache
 */

/*
 * various cache policies
 */
static struct swit caches[] = {
#define CACHE_NEVER    0
    { "never", 0, 0 },
#define CACHE_PRIVATE  1
    { "private", 0, 0 },
#define CACHE_PUBLIC   2
    { "public", 0, 0 },
#define CACHE_ASK      3
    { "ask", 0, 0 },
    { NULL, 0, 0 }
};

/*
 * mhcachesbr.h -- definitions for manipulating MIME content cache
 */

/*
 * various cache policies
 */

#define CACHE_SWITCHES \
    X("never", 0, CACHE_NEVER) \
    X("private", 0, CACHE_PRIVATE) \
    X("public", 0, CACHE_PUBLIC) \
    X("ask", 0, CACHE_ASK) \

#define X(sw, minchars, id) id,
DEFINE_SWITCH_ENUM(CACHE);
#undef X

#define X(sw, minchars, id) { sw, minchars, id },
DEFINE_SWITCH_ARRAY(CACHE, caches);
#undef X

Convert the MIME content cache switches over to the smatch() New World Order.


// InstructionCounter.h (Oclgrind)
// Copyright (c) 2013-2016, James Price and Simon McIntosh-Smith,
// University of Bristol. All rights reserved.
//
// This program is provided under a three-clause BSD license. For full
// license terms please see the LICENSE file distributed with this
// source code.

#include "core/Plugin.h"

namespace llvm
{
  class Function;
}

namespace oclgrind
{
  class InstructionCounter : public Plugin
  {
  public:
    InstructionCounter(const Context *context) : Plugin(context){};

    virtual void instructionExecuted(const WorkItem *workItem,
                                     const llvm::Instruction *instruction,
                                     const TypedValue& result) override;
    virtual void kernelBegin(const KernelInvocation *kernelInvocation) override;
    virtual void kernelEnd(const KernelInvocation *kernelInvocation) override;
    virtual void workGroupBegin(const WorkGroup *workGroup) override;
    virtual void workGroupComplete(const WorkGroup *workGroup) override;

  private:
    std::vector<size_t> m_instructionCounts;
    std::vector<size_t> m_memopBytes;
    std::vector<const llvm::Function*> m_functions;

    struct WorkerState
    {
      std::vector<size_t> *instCounts;
      std::vector<size_t> *memopBytes;
      std::vector<const llvm::Function*> *functions;
    };
    static THREAD_LOCAL WorkerState m_state;

    std::mutex m_mtx;

    std::string getOpcodeName(unsigned opcode) const;
  };
}

// InstructionCounter.h (Oclgrind)
// Copyright (c) 2013-2016, James Price and Simon McIntosh-Smith,
// University of Bristol. All rights reserved.
//
// This program is provided under a three-clause BSD license. For full
// license terms please see the LICENSE file distributed with this
// source code.

#include "core/Plugin.h"

#include <mutex>

namespace llvm
{
  class Function;
}

namespace oclgrind
{
  class InstructionCounter : public Plugin
  {
  public:
    InstructionCounter(const Context *context) : Plugin(context){};

    virtual void instructionExecuted(const WorkItem *workItem,
                                     const llvm::Instruction *instruction,
                                     const TypedValue& result) override;
    virtual void kernelBegin(const KernelInvocation *kernelInvocation) override;
    virtual void kernelEnd(const KernelInvocation *kernelInvocation) override;
    virtual void workGroupBegin(const WorkGroup *workGroup) override;
    virtual void workGroupComplete(const WorkGroup *workGroup) override;

  private:
    std::vector<size_t> m_instructionCounts;
    std::vector<size_t> m_memopBytes;
    std::vector<const llvm::Function*> m_functions;

    struct WorkerState
    {
      std::vector<size_t> *instCounts;
      std::vector<size_t> *memopBytes;
      std::vector<const llvm::Function*> *functions;
    };
    static THREAD_LOCAL WorkerState m_state;

    std::mutex m_mtx;

    std::string getOpcodeName(unsigned opcode) const;
  };
}

Add missing mutex header include

Add missing mutex header include


#ifndef _NODE_H_
#define _NODE_H_

template <class T>
struct Node
{
	T data;
	Node<T> *left;
	Node<T> *right;

	Node(const T& data, Node<T> *left = nullptr, Node<T> *right = nullptr)
		: data(data), left(left), right(right) {}
};

#endif // _NODE_H_

#ifndef _NODE_H_
#define _NODE_H_

template <class T>
struct Node
{
	T data;
	Node<T> *left;
	Node<T> *right;
	Node<T> *parent;

	Node(const T& data, Node<T> *left = nullptr, Node<T> *right = nullptr, Node<T> *parent = nullptr)
		: data(data), left(left), right(right), parent(parent) {}
};

#endif // _NODE_H_

Update Trees/Node structure to have parent


// Derived from blog post at http://www.ermicro.com/blog/?p=1239

#ifndef __MCP23008_H__
#define __MCP23008_H__

#include <compat/twi.h>
#include "i2c_utils.h"

#define MCP23008_ID    0x40  // MCP23008 I2C Device Identifier (0100, fixed)
#define MCP23008_ADDR  0x00  // MCP23008 I2C Address (000-111 in bits 3..1)
#define MCP23008_IODIR 0x00  // MCP23008 I/O Direction Register
#define MCP23008_GPIO  0x09  // MCP23008 General Purpose I/O Register
#define MCP23008_OLAT  0x0A  // MCP23008 Output Latch Register

void write_mcp23008(unsigned char reg_addr,unsigned char data);
unsigned char read_mcp23008(unsigned char reg_addr);

#endif /*__MCP23008_H__*/

// I/O functions for MCP23008 port expander using I2C/TWI protocol
// Derived from blog post at http://www.ermicro.com/blog/?p=1239

#ifndef __MCP23008_H__
#define __MCP23008_H__

#include <compat/twi.h>
#include "i2c_utils.h"

// About the 7-bit I2C slave address MCP23008:
//  - The high bits 7..4 are fixed at 0100.
//  - Bits 3..1 are for further addressing (e.g. eeprom page, jumpered pads)
//  - Bit 0 is disregarded (the R/W direction is handled separately).
// See http://www.avrbeginners.net/architecture/twi/twi.html#addressing

#define MCP23008       0x40  // MCP23008 I2C device address
#define MCP23008_IODIR 0x00  // MCP23008 I/O Direction Register
#define MCP23008_GPIO  0x09  // MCP23008 General Purpose I/O Register
#define MCP23008_OLAT  0x0A  // MCP23008 Output Latch Register

void write_mcp23008(uint8_t reg_addr, uint8_t data);
uint8_t read_mcp23008(uint8_t reg_addr);

#endif /*__MCP23008_H__*/

Add info on I2C address

Add info on I2C address


#pragma once

#include <string>
#include <ostream>
#include <iomanip>
#include <iostream>

struct Hex
{
    Hex(char *buffer, size_t size)
        : m_buffer(buffer)
        , m_size(size)
    {
    }

    friend std::ostream& operator <<(std::ostream &os, const Hex &obj)
    {
        unsigned char* aschar = (unsigned char*)obj.m_buffer;
        for (size_t i = 0; i < obj.m_size; ++i) {
            if (isprint(aschar[i]))  {
                os << aschar[i];
            } else {
                os << std::hex << std::setw(2) << std::setfill('0') << static_cast<unsigned int> (aschar[i]);
            }
        }
        return os;
    }

private:
    char *m_buffer;
    size_t m_size;
};

#pragma once

#include <string>
#include <ostream>
#include <iomanip>
#include <iostream>

struct Hex
{
    Hex(char *buffer, size_t size)
        : m_buffer(buffer)
        , m_size(size)
    {
    }

    friend std::ostream& operator <<(std::ostream &os, const Hex &obj)
    {
        unsigned char* aschar = (unsigned char*)obj.m_buffer;
        for (size_t i = 0; i < obj.m_size; ++i) {
            if (isprint(aschar[i]))  {
                os << aschar[i];
            } else {
                os << "\\x" << std::hex << std::setw(2) << std::setfill('0') << static_cast<unsigned int> (aschar[i]);
            }
        }
        return os;
    }

private:
    char *m_buffer;
    size_t m_size;
};

Add "\x" for hex part.

Add "\x" for hex part.


#include "gdt.h"
#include "idt.h"
#include "vga.h"
#include "term_printf.h"

void kernel_main()
{
	init_term();
	term_puts(NAME " booting...");

	term_puts("Initializing GDT...");
	init_gdt();
	term_puts("Initializing IDT...");
	init_idt();

	term_printf("term_printf is %d%% p%cre %s\n", 100, 'u', "awesome");

	__asm__ volatile ("int $2");
}

#include "gdt.h"
#include "idt.h"
#include "vga.h"
#include "term_printf.h"

void notify(void (*func)(), char *str)
{
	term_putsn(str);
	func();
	term_puts(" done");
}

void kernel_main()
{
	init_term();
	term_puts(NAME " booting...");

	notify(init_gdt, "Initializing GDT...");
	notify(init_idt, "Initializing IDT...");

	term_printf("term_printf is %d%% p%cre %s\n", 100, 'u', "awesome");

	__asm__ volatile ("int $2");
}

Add notify() function to print message around function call


// test for r305179
// RUN: %clang_cc1 -emit-llvm -O -mllvm -print-after-all %s -o %t 2>&1 | grep '*** IR Dump After Function Integration/Inlining ***'
void foo() {}

// test for r305179
// RUN: %clang_cc1 -emit-llvm -O -mllvm -print-after-all %s -o %t 2>&1 | FileCheck %s
// CHECK: *** IR Dump After Function Integration/Inlining ***
void foo() {}

Address David Blaikie comment by replacing grep with FileCheck.

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


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

#ifndef PPAPI_CPP_MODULE_IMPL_H_
#define PPAPI_CPP_MODULE_IMPL_H_

#include "ppapi/cpp/module.h"

namespace {

template <typename T> class DeviceFuncs {
 public:
  explicit DeviceFuncs(const char* ifname) : ifname_(ifname) {}

  operator T const*() {
    if (!funcs_) {
      funcs_ = reinterpret_cast<T const*>(
          pp::Module::Get()->GetBrowserInterface(ifname_));
    }
    return funcs_;
  }

  // This version doesn't check for existence of the function object. It is
  // used so that, for DeviceFuncs f, the expression:
  // if (f) f->doSomething();
  // checks the existence only once.
  T const* operator->() const { return funcs_; }

 private:
  DeviceFuncs(const DeviceFuncs&other);
  DeviceFuncs &operator=(const DeviceFuncs &other);

  const char* ifname_;
  T const* funcs_;
};

}  // namespace

#endif  // PPAPI_CPP_MODULE_IMPL_H_

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

#ifndef PPAPI_CPP_MODULE_IMPL_H_
#define PPAPI_CPP_MODULE_IMPL_H_

#include "ppapi/cpp/module.h"

namespace {

template <typename T> class DeviceFuncs {
 public:
  explicit DeviceFuncs(const char* ifname) : ifname_(ifname), funcs_(NULL) {}

  operator T const*() {
    if (!funcs_) {
      funcs_ = reinterpret_cast<T const*>(
          pp::Module::Get()->GetBrowserInterface(ifname_));
    }
    return funcs_;
  }

  // This version doesn't check for existence of the function object. It is
  // used so that, for DeviceFuncs f, the expression:
  // if (f) f->doSomething();
  // checks the existence only once.
  T const* operator->() const { return funcs_; }

 private:
  DeviceFuncs(const DeviceFuncs&other);
  DeviceFuncs &operator=(const DeviceFuncs &other);

  const char* ifname_;
  T const* funcs_;
};

}  // namespace

#endif  // PPAPI_CPP_MODULE_IMPL_H_

Initialize DeviceFuncs::ifuncs_ to zero in constructor


int getCursorPosition(int *rows, int *cols)
{
}

//
// Use the ESC [6n escape sequence to query the horizontal cursor position
// and return it. On error -1 is returned, on success the position of the
// cursor is stored at *rows and *cols and 0 is returned.
//

int getCursorPosition(int ifd, int ofd, int *rows, int *cols) {
    char buf[32];
    unsigned int i = 0;

    /* Report cursor location */
    if (write(ofd, "\x1b[6n", 4) != 4) return -1;

    /* Read the response: ESC [ rows ; cols R */
    while (i < sizeof(buf)-1) {
        if (read(ifd,buf+i,1) != 1) break;
        if (buf[i] == 'R') break;
        i++;
    }
    buf[i] = '\0';

    /* Parse it. */
    if (buf[0] != ESC || buf[1] != '[') return -1;
    if (sscanf(buf+2,"%d;%d",rows,cols) != 2) return -1;
    return 0;
}

Add changes to correct changes

Add changes to correct changes


/**
 * @file
 * @brief
 *
 * @date 16.05.12
 * @author Anton Bondarev
 * @author Ilia Vaprol
 */
#include <limits.h>
#include <stdint.h>

#define MASK_DWORD  (uint64_t)1 << ((WORD_BIT * 2) - 1)

uint64_t __udivdi3(uint64_t num, uint64_t den) {
	uint64_t result = 0;
	int steps;

	if (den == 0) {
		return 0;
	}

	steps = 0;
	result = 0;

	while (!(den & MASK_DWORD)) {
		den <<= 1;
		++steps;
	}

	do {
		result <<= 1;
		if (num >= den) {
			result |= 1;
			num -= den;
		}
		den >>= 1;
	} while (steps--);

	return result;
}

/**
 * @file
 * @brief
 *
 * @date 16.05.12
 * @author Anton Bondarev
 * @author Ilia Vaprol
 */

#include <stdint.h>

uint64_t __udivdi3(uint64_t num, uint64_t den) {
	uint64_t result = 0;
	int steps;

	if (den == 0) {
		return 0;
	}

	steps = 0;
	result = 0;

	while (!(den & 0x8000000000000000)) {
		den <<= 1;
		++steps;
	}

	do {
		result <<= 1;
		if (num >= den) {
			result |= 1;
			num -= den;
		}
		den >>= 1;
	} while (steps--);

	return result;
}

Revert __udivi3 (word in compiler always 32 bit)


/*
 * Author: hx1997
 * Desc: жһȻǷΪƽԸβ
 */

#include <stdio.h>

int is_automorphic(long int num) {
	long int sqrd = num * num;
	int lsig_digit, lsig_digit_sqrd;

	if(num > 44720) return -1;

	for(; num > 0; num /= 10, sqrd /= 10) {
		lsig_digit = num % 10;
		lsig_digit_sqrd = sqrd % 10;
		if(lsig_digit != lsig_digit_sqrd) return 0;
	}

	return 1;
}

int main(void) {
	int num_to_check;

	printf("Input a non-negative integer less than 44720: ");
	scanf(" %d", &num_to_check);

	if(num_to_check > 44720)
		printf("Invalid input.\n");
	else
		printf("%d is%s an automorphic number.\n", num_to_check, (is_automorphic(num_to_check) ? "" : " not"));

	return 0;
}

/*
 * Author: hx1997
 * Desc: жһȻǷΪƽԸβ
 */

#include <stdio.h>

int is_automorphic(int num) {
	int sqrd = num * num;
	int lsig_digit; int lsig_digit_sqrd;

	if(num > 44720) return -1;

	for(; num > 0; num /= 10, sqrd /= 10) {
		lsig_digit = num % 10;
		lsig_digit_sqrd = sqrd % 10;
		if(lsig_digit != lsig_digit_sqrd) return 0;
	}

	return 1;
}

int main(void) {
	int num_to_check;

	printf("Input a non-negative integer less than 44720: ");
	scanf(" %d", &num_to_check);

	if(num_to_check > 44720)
		printf("Invalid input.\n");
	else
		printf("%d is%s an automorphic number.\n", num_to_check, (is_automorphic(num_to_check) ? "" : " not"));

	return 0;
}

Change long int to int

Automorphic: Change long int to int


// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=true -analyzer-output=text -verify %s
// expected-no-diagnostics

int *returnNull() { return 0; }
int coin();

// Use a float parameter to ensure that the value is unknown. This will create
// a cycle in the generated ExplodedGraph.
void testCycle(float i) {
  int *x = returnNull();
  int y;
  while (i > 0) {
    x = returnNull();
    y = 2;
    i -= 1;
  }
  *x = 1; // no-warning
  y += 1;
}

[analyzer] Add a test case for diagnostic suppression on a graph with cycles.

(see previous commit)

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


//
//  SideMenu.h
//  PlayPlan
//
//  Created by Zeacone on 15/11/19.
//  Copyright © 2015年 Zeacone. All rights reserved.
//

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

@interface SideMenu : UIView

@end

//
//  SideMenu.h
//  PlayPlan
//
//  Created by Zeacone on 15/11/19.
//  Copyright © 2015年 Zeacone. All rights reserved.
//

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

@protocol SideMenuDelegate <NSObject>

- (void)sideMenu:(UIButton *)menu title:(NSString *)title;

@end

@interface SideMenu : UIView

@property (nonatomic, assign) id<SideMenuDelegate> delegate;

@end

Add delegate for side menu.

Add delegate for side menu.


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

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

Update Skia milestone to 102

Update Skia milestone to 102

Change-Id: Ie332216b5338b1538de9ef07a34a28854c7c805a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/522137
Reviewed-by: Kevin Lubick <7cdab2cfab351f23814786ba39716e90eed69047@google.com>


// Defines the generic Parser interface for the Casper parser generator library.
//
#ifndef HITTOP_PARSER_PARSER_H
#define HITTOP_PARSER_PARSER_H

#include "hittop/parser/parse_error.h"

#include "hittop/util/fallible.h"

namespace hittop {
namespace parser {

using util::Fallible;

/// The form of a Parser class.  There is no generic implementation of Parser,
/// only partial and full specializations that define how to parse specific
/// grammars.
template <typename Grammar> class Parser;

/// Convenience wrapper around defining a new Parser object and invoking it on
/// the given input range.  Allows the invocation operator defined on
/// Parser<Grammer> to be non-const, as the parser instance created within this
/// function is itself non-const.
template <typename Grammar, typename Range>
auto Parse(const Range &input)
    -> decltype(std::declval<Parser<Grammar>>()(input)) {
  Parser<Grammar> parser;
  return parser(input);
}

} // namespace parser
} // namespace hittop

#endif // HITTOP_PARSER_PARSER_H

// Defines the generic Parser interface for the Casper parser generator library.
//
#ifndef HITTOP_PARSER_PARSER_H
#define HITTOP_PARSER_PARSER_H

#include "boost/range/as_literal.hpp"

#include "hittop/parser/parse_error.h"

#include "hittop/util/fallible.h"

namespace hittop {
namespace parser {

using util::Fallible;

/// The form of a Parser class.  There is no generic implementation of Parser,
/// only partial and full specializations that define how to parse specific
/// grammars.
template <typename Grammar> class Parser;

/// Convenience wrapper around defining a new Parser object and invoking it on
/// the given input range.  Allows the invocation operator defined on
/// Parser<Grammer> to be non-const, as the parser instance created within this
/// function is itself non-const.
template <typename Grammar, typename Range>
auto Parse(const Range &input)
    -> decltype(std::declval<Parser<Grammar>>()(input)) {
  Parser<Grammar> parser;
  return parser(input);
}

/// Convenience function that parsers a C string as a literal character range.
template <typename Grammar>
auto Parse(const char *input)
    -> decltype(Parse<Grammar>(boost::as_literal(input))) {
  return Parse<Grammar>(boost::as_literal(input));
}

} // namespace parser
} // namespace hittop

#endif // HITTOP_PARSER_PARSER_H

Add convenience overload of Parse that accepts c-string literals


// RUN: %ocheck 3 %s

g()
{
	return 3;
}

main()
{
	if(0){
		f(); // shouldn't hit a linker error here - dead code
a:
		return g();
	}

	goto a;
}

// RUN: %ocheck 3 %s -g
// test debug emission too

g()
{
	return 3;
}

main()
{
	if(0){
		int i;
		f(); // shouldn't hit a linker error here - dead code
a:
		i = 2;
		return g(i);
	}

	goto a;
}

Test debug label emission with local variables


#ifndef ROOT_RVersion
#define ROOT_RVersion

/* Version information automatically generated by installer. */

/*
 * These macros can be used in the following way:
 *
 *    #if ROOT_VERSION_CODE >= ROOT_VERSION(2,23,4)
 *       #include <newheader.h>
 *    #else
 *       #include <oldheader.h>
 *    #endif
 *
*/

#define ROOT_RELEASE "5.34/22"
#define ROOT_RELEASE_DATE "Oct 10 2014"
#define ROOT_RELEASE_TIME "15:29:14"
#define ROOT_SVN_REVISION 49361
#define ROOT_GIT_COMMIT "v5-34-21-104-gf821c17"
#define ROOT_GIT_BRANCH "heads/v5-34-00-patches"
#define ROOT_VERSION_CODE 336406
#define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

#endif

#ifndef ROOT_RVersion
#define ROOT_RVersion

/* Version information automatically generated by installer. */

/*
 * These macros can be used in the following way:
 *
 *    #if ROOT_VERSION_CODE >= ROOT_VERSION(2,23,4)
 *       #include <newheader.h>
 *    #else
 *       #include <oldheader.h>
 *    #endif
 *
*/

#define ROOT_RELEASE "5.34/23"
#define ROOT_RELEASE_DATE "Nov  7 2014"
#define ROOT_RELEASE_TIME "15:06:58"
#define ROOT_SVN_REVISION 49361
#define ROOT_GIT_COMMIT "v5-34-22-106-g4a0dea3"
#define ROOT_GIT_BRANCH "heads/v5-34-00-patches"
#define ROOT_VERSION_CODE 336407
#define ROOT_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))

#endif

Update ROOT version files to v5.34/23.

Update ROOT version files to v5.34/23.


/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#ifdef E_TYPEDEFS
#else
#ifndef E_INT_CONFIG_THEME_H
#define E_INT_CONFIG_THEME_H

EAPI E_Config_Dialog *e_int_config_theme(E_Container *con, const char *params __UNUSED__);

EAPI void             e_int_config_theme_import_done(E_Config_Dialog *dia);
EAPI void             e_int_config_theme_update(E_Config_Dialog *dia, char *file);

#endif
#endif

/*
 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
 */
#ifdef E_TYPEDEFS
#else
#ifndef E_INT_CONFIG_THEME_H
#define E_INT_CONFIG_THEME_H

EAPI E_Config_Dialog *e_int_config_theme(E_Container *con, const char *params __UNUSED__);

EAPI void             e_int_config_theme_import_done(E_Config_Dialog *dia);
EAPI void             e_int_config_theme_update(E_Config_Dialog *dia, char *file);
EAPI void             e_int_config_theme_web_done(E_Config_Dialog *dia);

#endif
#endif

Declare public function in header.

Declare public function in header.

SVN revision: 35475


#include "ring.h"

/*
	OpenGL 1.1 Extension
	Copyright (c) 2017 Mahmoud Fayed <msfclipper@yahoo.com>
*/

#include <GL/glew.h>
#include <GL/glut.h>

RING_FUNC(ring_get_gl_zero)
{
	RING_API_RETNUMBER(GL_ZERO);
}

RING_API void ringlib_init(RingState *pRingState)
{
	ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
}

Update RingOpenGL 1.1 - Add Constant (Source Code) : GL_ZERO


#ifndef PHYSICAL_ALLOCATOR_H
#define PHYSICAL_ALLOCATOR_H

typedef uint32_t page_frame_t;

#define PAGE_FRAME_CACHE_SIZE 32
#define PAGE_FRAME_MAP_SIZE (PHYS_MEMORY_SIZE/8/PAGE_SIZE)

// Linear search of page frame bitmap
page_frame_t alloc_frame_helper();

void free_frame(page_frame_t frame);

page_frame_t alloc_frame();

void use_frame(page_frame_t frame);

#endif

#ifndef PHYSICAL_ALLOCATOR_H
#define PHYSICAL_ALLOCATOR_H

#include <stdint.h>
#include <stddef.h>
#include <libk/kabort.h>
#include <libk/kassert.h>
#include <libk/kputs.h>

#ifdef ARCH_X86
#include <arch/x86/memlayout.h>
#endif

#ifdef ARCH_USERLAND
#include "tests/memlayout.h"
#endif

typedef uint32_t page_frame_t;

#define BIT_INDEX(x) (1 << ((x) % 8))
#define BYTE_INDEX(x) ((x)/8)
#define PAGE_FRAME_CACHE_SIZE 32
#define PAGE_FRAME_MAP_SIZE (PHYS_MEMORY_SIZE/8/PAGE_SIZE)

// Linear search of page frame bitmap
page_frame_t alloc_frame_helper();

void free_frame(page_frame_t frame);

page_frame_t alloc_frame();

void use_frame(page_frame_t frame);

#endif

Create macros for certain repetitive shifts


/**************************************************************************
 *
 * Copyright 2015 Jose Fonseca
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. NO EVENT SHALL
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OF OR CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS THE SOFTWARE.
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 **************************************************************************/

#include <windows.h>

int CALLBACK
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    RaiseException(100, EXCEPTION_NONCONTINUABLE, 0, NULL);

    return 0;
}

/**************************************************************************
 *
 * Copyright 2015 Jose Fonseca
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. NO EVENT SHALL
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OF OR CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS THE SOFTWARE.
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 **************************************************************************/

#include <windows.h>

int CALLBACK
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    RaiseException(0xE0000001, EXCEPTION_NONCONTINUABLE, 0, NULL);

    return 0;
}

Use a better custom exception code.

test/apps: Use a better custom exception code.


/*
 * Copyright (c) 2017 Contributors as noted in the AUTHORS file
 *
 * This file is part of Solo5, a unikernel base layer.
 *
 * Permission to use, copy, modify, and/or distribute this software
 * for any purpose with or without fee is hereby granted, provided
 * that the above copyright notice and this permission notice appear
 * in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include "../kernel.h"

/* ukvm block interface */
int solo5_blk_write_sync(uint64_t sec __attribute__((unused)),
                         uint8_t *data __attribute__((unused)),
                         int n __attribute__((unused)))
{
    return -1;
}

int solo5_blk_read_sync(uint64_t sec __attribute__((unused)),
                        uint8_t *data __attribute__((unused)),
                        int *n __attribute__((unused)))
{
    return -1;
}

int solo5_blk_sector_size(void)
{
    return -1;
}

uint64_t solo5_blk_sectors(void)
{
    return 0;
}

int solo5_blk_rw(void)
{
    return -1;
}

Add dummy block implementation for Muen

Add dummy block implementation for Muen

For now there is no support for block devices on the Muen platform.


// PARAM: --set ana.activated[+] "'var_eq'"
// Copy of 04/45 with var_eq enabled
// octApron needs to be included again and fixed
#include <pthread.h>
#include <stdio.h>

pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
  int *p = (int *) arg;
  pthread_mutex_lock(&mutex1);
  (*p)++;
  pthread_mutex_unlock(&mutex1);
  return NULL;
}

int main(void) {
  pthread_t id;
  int i = 0;
  pthread_create(&id, NULL, t_fun, (void *) &i);
  pthread_mutex_lock(&mutex2);
  assert(i == 0); // UNKNOWN!
  pthread_mutex_unlock(&mutex2);
  pthread_join (id, NULL);
  return 0;
}

// PARAM: --set ana.activated[+] "'var_eq'"
// Copy of 04/45 with var_eq enabled
#include <pthread.h>
#include <stdio.h>

pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
  int *p = (int *) arg;
  pthread_mutex_lock(&mutex1);
  (*p)++;
  pthread_mutex_unlock(&mutex1);
  return NULL;
}

int main(void) {
  pthread_t id;
  int i = 0;
  pthread_create(&id, NULL, t_fun, (void *) &i);
  pthread_mutex_lock(&mutex2);
  assert(i == 0); // UNKNOWN!
  pthread_mutex_unlock(&mutex2);
  pthread_join (id, NULL);
  return 0;
}

Remove outdated octApron comment from 06/24


// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s
// PR6913

#include <stdio.h>

int main()
{
   int x[10][10];
   int (*p)[] = x;

   int i;

   for(i = 0; i < 10; ++i)
   {
       p[i][i] = i; // expected-error {{subscript of pointer to incomplete type 'int []'}}
   }
}

// rdar://13705391
void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}

// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s
// PR6913

int main()
{
   int x[10][10];
   int (*p)[] = x;

   int i;

   for(i = 0; i < 10; ++i)
   {
       p[i][i] = i; // expected-error {{subscript of pointer to incomplete type 'int []'}}
   }
}

// rdar://13705391
void foo(int a[*][2]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo1(int a[2][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo2(int a[*][*]) {(void)a[0][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo3(int a[2][*][2]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}
void foo4(int a[2][*][*]) {(void)a[0][1][1]; } // expected-error {{variable length array must be bound in function definition}}

Remove an old stdio.h include from the invalid-array test

This should get it up and running on win and other builders without system
headers.

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


/*
 * File:   executeStage.h
 * Author: Alex Savarda
 */

#define INSTR_COUNT     16   // Possible size of the instruction set

#ifndef EXECUTESTAGE_H
#define	EXECUTESTAGE_H

typedef struct {
    unsigned int stat;
    unsigned int icode;
    unsigned int ifun;
    unsigned int valC;
    unsigned int valA;
    unsigned int valB;
    unsigned int dstE;
    unsigned int dstM;
    unsigned int srcA;
    unsigned int srcB;
} eregister;

struct E {
    unsigned int stat;
    unsigned int icode;
    unsigned int ifun;
    unsigned int valC;
    unsigned int valA;
    unsigned int valB;
    unsigned int dstE;
    unsigned int dstM;
    unsigned int srcA;
    unsigned int srcB;
};

// Function prototypes
eregister getEregister(void);
void clearEregister(void);
void executeStage();
void initFuncPtrArray(void);
void updateEregister(unsigned int stat, unsigned int icode, unsigned int ifun,
                     unsigned int valC, unsigned int valA, unsigned int valB,
                     unsigned int dstE, unsigned int dstM, unsigned int srcA,
                     unsigned int srcB);
#endif	/* EXECUTESTAGE_H */

Convert a tab into a space

Convert a tab into a space


/* This is main header file that is ought to be included as library */

//Include proper header files
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>

#include "parser.h"

//Function prototypes
extern uint16_t MODBUSSwapEndian( uint16_t );
extern uint16_t MODBUSCRC16( uint16_t *, uint16_t );

/* This is main header file that is ought to be included as library */

//Include proper header files
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>

//Function prototypes
extern uint16_t MODBUSSwapEndian( uint16_t );
extern uint16_t MODBUSCRC16( uint8_t *, uint16_t );

Remove inclusion of 'parser.h' and fix pointer type


#include "Components.h"

class HealthComponent : public HealthComponentBase {
public:
    HealthComponent(Entity* entity, int maxHealth, int startHealth, const int& Health): HealthComponentBase(entity, maxHealth, startHealth, Health) {
    }

    void OnHeal(int amount) {
    }
    void OnDamage(int amount) {
    }
    void AttribHealth(int health) {
    }
};
class MonsterDieComponent : public MonsterDieComponentBase {
public:
    MonsterDieComponent(Entity* entity): MonsterDieComponentBase(entity) {
    }

    void OnDie() {
    }
};

#include "Components.h"

class HealthComponent : public HealthComponentBase {
public:
    HealthComponent(Entity* entity, int maxHealth, int startHealth, const int& Health): HealthComponentBase(entity, maxHealth, startHealth, Health) {
    }

    void HandleHeal(int amount) {
    }
    void HandleDamage(int amount) {
    }
    void AttribHealth(int health) {
    }
};
class MonsterDieComponent : public MonsterDieComponentBase {
public:
    MonsterDieComponent(Entity* entity): MonsterDieComponentBase(entity) {
    }

    void HandleDie() {
    }
};

Fix the small test to use Handle instead of On


#include <stdio.h>

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

  //create two arrays we care about
  int ages[] = {23,55,15,34,78,12};
  char *names[] = {
    "Feinb", "Fhilp", "Wastan", "Wustak","Henris","Abkar"
  };

  //safely get the size of ages
  int count = sizeof(ages) / sizeof(int);

  int i = 0;

  //first way using indexing
  for(i = 0; i < count; i++){
    printf("%s had lived for %d years.\n", names[i], ages[i]);
  }

  printf("---\n");

  return 0;
}

#include <stdio.h>

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

  //create two arrays we care about
  int ages[] = {23,55,15,34,78,12};
  char *names[] = {
    "Feinb", "Fhilp", "Wastan", "Wustak","Henris","Abkar"
  };

  //safely get the size of ages
  int count = sizeof(ages) / sizeof(int);

  int i = 0;

  //first way using indexing
  for(i = 0; i < count; i++){
    printf("%s has lived for %d years.\n", names[i], ages[i]);
  }

  printf("---\n");

  //setup pointers to the start of the arrays
  int *cur_age = ages;
  char **cur_name = names;

  // second way using pointers
  for(i = 0; i < count; i++){
    printf("%s is %d years old.\n",
      *(cur_name+i), *(cur_age+i));
  }

  printf("---\n");

  return 0;
}

Use pointers to start of arrays

Use pointers to start of arrays


#ifndef IFILE_H
#define IFILE_H

#include <vector>
#include <memory>

#include "IMediaLibrary.h"
#include "ITrackInformation.h"

class IAlbumTrack;
class IShowEpisode;
class ITrackInformation;

class IFile
{
    public:
        enum Type
        {
            VideoType, // Any video file, not being a tv show episode
            AudioType, // Any kind of audio file, not being an album track
            ShowEpisodeType,
            AlbumTrackType,
            UnknownType,
        };
        virtual ~IFile() {}

        virtual unsigned int id() const = 0;
        virtual AlbumTrackPtr albumTrack() = 0;
        virtual bool setAlbumTrack(AlbumTrackPtr albumTrack ) = 0;
        virtual unsigned int duration() const = 0;
        virtual std::shared_ptr<IShowEpisode> showEpisode() = 0;
        virtual bool setShowEpisode( ShowEpisodePtr showEpisode ) = 0;
        virtual int playCount() const = 0;
        virtual const std::string& mrl() const = 0;
        virtual bool addLabel( LabelPtr label ) = 0;
        virtual bool removeLabel( LabelPtr label ) = 0;
        virtual MoviePtr movie() = 0;
        virtual bool setMovie( MoviePtr movie ) = 0;
        virtual std::vector<std::shared_ptr<ILabel> > labels() = 0;
};

#endif // IFILE_H

#ifndef IFILE_H
#define IFILE_H

#include <vector>
#include <memory>

#include "IMediaLibrary.h"
#include "ITrackInformation.h"

class IAlbumTrack;
class IShowEpisode;
class ITrackInformation;

class IFile
{
    public:
        enum Type
        {
            VideoType, // Any video file, not being a tv show episode
            AudioType, // Any kind of audio file, not being an album track
            ShowEpisodeType,
            AlbumTrackType,
            UnknownType
        };
        virtual ~IFile() {}

        virtual unsigned int id() const = 0;
        virtual AlbumTrackPtr albumTrack() = 0;
        virtual bool setAlbumTrack(AlbumTrackPtr albumTrack ) = 0;
        virtual unsigned int duration() const = 0;
        virtual std::shared_ptr<IShowEpisode> showEpisode() = 0;
        virtual bool setShowEpisode( ShowEpisodePtr showEpisode ) = 0;
        virtual int playCount() const = 0;
        virtual const std::string& mrl() const = 0;
        virtual bool addLabel( LabelPtr label ) = 0;
        virtual bool removeLabel( LabelPtr label ) = 0;
        virtual MoviePtr movie() = 0;
        virtual bool setMovie( MoviePtr movie ) = 0;
        virtual std::vector<std::shared_ptr<ILabel> > labels() = 0;
};

#endif // IFILE_H

Fix a warning with -pedantic on some old gcc versions


/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

/******************************************************************

 iLBC Speech Coder ANSI-C Source Code

 WebRtcIlbcfix_NearestNeighbor.c

******************************************************************/

#include "defines.h"

void WebRtcIlbcfix_NearestNeighbor(size_t* index,
                                   const size_t* array,
                                   size_t value,
                                   size_t arlength) {
  size_t min_diff = (size_t)-1;
  for (size_t i = 0; i < arlength; i++) {
    const size_t diff =
        (array[i] < value) ? (value - array[i]) : (array[i] - value);
    if (diff < min_diff) {
      *index = i;
      min_diff = diff;
    }
  }
}

/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

/******************************************************************

 iLBC Speech Coder ANSI-C Source Code

 WebRtcIlbcfix_NearestNeighbor.c

******************************************************************/

#include "defines.h"

void WebRtcIlbcfix_NearestNeighbor(size_t* index,
                                   const size_t* array,
                                   size_t value,
                                   size_t arlength) {
  size_t i;
  size_t min_diff = (size_t)-1;
  for (i = 0; i < arlength; i++) {
    const size_t diff =
        (array[i] < value) ? (value - array[i]) : (array[i] - value);
    if (diff < min_diff) {
      *index = i;
      min_diff = diff;
    }
  }
}

Fix ChromeOS build (C99 break)

Fix ChromeOS build (C99 break)

BUG=5016
TBR=henrik.lundin@webrtc.org

Review URL: https://codereview.webrtc.org/1354163002

Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#9992}


/*
 * chewing-compat.h
 *
 * Copyright (c) 2014
 *      libchewing Core Team. See ChangeLog for details.
 *
 * See the file "COPYING" for information on usage and redistribution
 * of this file.
 */

#ifndef _CHEWING_COMPAT_
#define _CHEWING_COMPAT_

/** @brief indicate the internal encoding of data processing.
 *  @since 0.3.0
 */
#define LIBCHEWING_ENCODING "UTF-8"

/* deprecated function. for API compatibility */
CHEWING_API int chewing_zuin_Check(ChewingContext *ctx) DEPRECATED_FOR(chewing_bopomofo_Check);
CHEWING_API char *chewing_zuin_String(ChewingContext *,
                                      int *zuin_count) DEPRECATED_FOR(chewing_bopomofo_String_static);

CHEWING_API int chewing_Init(const char *dataPath, const char *hashPath) DEPRECATED;
CHEWING_API void chewing_Terminate() DEPRECATED;
CHEWING_API int chewing_Configure(ChewingContext *ctx, ChewingConfigData * pcd) DEPRECATED_FOR(chewing_set_*);
CHEWING_API void chewing_set_hsuSelKeyType(ChewingContext *ctx, int mode) DEPRECATED_FOR(chewing_set_selKey);
CHEWING_API int chewing_get_hsuSelKeyType(ChewingContext *ctx) DEPRECATED_FOR(chewing_get_selKey);

#endif

/*
 * chewing-compat.h
 *
 * Copyright (c) 2014
 *      libchewing Core Team. See ChangeLog for details.
 *
 * See the file "COPYING" for information on usage and redistribution
 * of this file.
 */

/* *INDENT-OFF* */
#ifndef _CHEWING_COMPAT_
#define _CHEWING_COMPAT_
/* *INDENT-ON* */

/** @brief indicate the internal encoding of data processing.
 *  @since 0.3.0
 */
#define LIBCHEWING_ENCODING "UTF-8"

/* deprecated function. for API compatibility */
CHEWING_API int chewing_zuin_Check(ChewingContext *ctx) DEPRECATED_FOR(chewing_bopomofo_Check);
CHEWING_API char *chewing_zuin_String(ChewingContext *,
                                      int *zuin_count) DEPRECATED_FOR(chewing_bopomofo_String_static);

CHEWING_API int chewing_Init(const char *dataPath, const char *hashPath) DEPRECATED;
CHEWING_API void chewing_Terminate() DEPRECATED;
CHEWING_API int chewing_Configure(ChewingContext *ctx, ChewingConfigData * pcd) DEPRECATED_FOR(chewing_set_*);
CHEWING_API void chewing_set_hsuSelKeyType(ChewingContext *ctx, int mode) DEPRECATED_FOR(chewing_set_selKey);
CHEWING_API int chewing_get_hsuSelKeyType(ChewingContext *ctx) DEPRECATED_FOR(chewing_get_selKey);

/* *INDENT-OFF* */
#endif
/* *INDENT-ON* */

Add indent comment for header guard

Add indent comment for header guard


#include <stdio.h>

typedef struct {
    int hands[2][2];
    int turn;
} Sticks;

void sticks_create(Sticks *sticks) {
    sticks->hands[0][0] = 1;
    sticks->hands[0][1] = 1;
    sticks->hands[1][0] = 1;
    sticks->hands[1][1] = 1;
    sticks->turn = 0;
}

void sticks_play(Sticks *sticks, int actor, int target) {
    sticks->hands[!sticks->turn][target] += sticks->hands[sticks->turn][actor];
    sticks->turn = !sticks->turn;
}

int main(void) {
    Sticks sticks;
    sticks_create(&sticks);
    printf("%d\n", sticks.hands[0][0]);
    printf("%d\n", sticks.turn);
    sticks_play(&sticks, 0, 1);
    printf("%d\n", sticks.hands[1][1]);
    printf("%d\n", sticks.turn);
}

#include <stdio.h>

typedef struct {
    int hands[2][2];
    int turn;
} Sticks;

void sticks_create(Sticks *sticks) {
    sticks->hands[0][0] = 1;
    sticks->hands[0][1] = 1;
    sticks->hands[1][0] = 1;
    sticks->hands[1][1] = 1;
    sticks->turn = 0;
}

void sticks_play(Sticks *sticks, int actor, int target) {
    sticks->hands[!sticks->turn][target] += sticks->hands[sticks->turn][actor];
    if (sticks->hands[!sticks->turn][target] >= 5) {
        sticks->hands[!sticks->turn][target] = 0;
    }
    sticks->turn = !sticks->turn;
}

int main(void) {
    Sticks sticks;
    sticks_create(&sticks);
    printf("%d\n", sticks.hands[0][0]);
    printf("%d\n", sticks.turn);
    sticks_play(&sticks, 0, 1);
    printf("%d\n", sticks.hands[1][1]);
    printf("%d\n", sticks.turn);
}

Kill hands that reach five fingers

Kill hands that reach five fingers


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

#pragma once

class VolumeTransformation;

class VolumeController {
public:
    struct DeviceInfo {
        std::wstring name;
        std::wstring id;
    };

    /// <summary>
    /// Retrieves the current volume level as a float, ranging from 0.0 - 1.0
    /// </summary>
    virtual float Volume() = 0;

    /// <summary>Sets the volume level. Valid range: 0.0 - 1.0</summary>
    virtual void Volume(float vol) = 0;

    virtual bool Muted() = 0;
    virtual void Muted(bool mute) = 0;
    virtual void ToggleMute() {
        (Muted() == true) ? Muted(false) : Muted(true);
    }

    virtual void AddTransformation(VolumeTransformation *transform) = 0;
    virtual void RemoveTransformation(VolumeTransformation *transform) = 0;

public:
    static const int MSG_VOL_CHNG = WM_APP + 1080;
    static const int MSG_VOL_DEVCHNG = WM_APP + 1081;

};

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

#pragma once

class VolumeTransformation;

class VolumeController {
public:
    struct DeviceInfo {
        std::wstring name;
        std::wstring id;
    };

    /// <summary>
    /// Retrieves the current volume level as a float, ranging from 0.0 - 1.0
    /// </summary>
    virtual float Volume() = 0;

    /// <summary>Sets the volume level. Valid range: 0.0 - 1.0</summary>
    virtual void Volume(float vol) = 0;

    virtual bool Muted() = 0;
    virtual void Muted(bool mute) = 0;
    virtual void ToggleMute() {
        (Muted() == true) ? Muted(false) : Muted(true);
    }

    virtual void Enabled() = 0;

    virtual void AddTransformation(VolumeTransformation *transform) = 0;
    virtual void RemoveTransformation(VolumeTransformation *transform) = 0;

public:
    static const int MSG_VOL_CHNG = WM_APP + 1080;
    static const int MSG_VOL_DEVCHNG = WM_APP + 1081;

};

Add method to check audio device state

Add method to check audio device state


// PARAM: --enable ana.int.interval
// Copied & modified from 13/24.
#include <pthread.h>
#include <assert.h>

int g2;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t __global_lock = PTHREAD_MUTEX_INITIALIZER;

void *t2_fun(void *arg) {
  pthread_mutex_lock(&mutex2);
  pthread_mutex_lock(&__global_lock);
  g2++;
  pthread_mutex_unlock(&__global_lock); // Write Mine influence: [[g2, __global_lock], t2_fun, {mutex2}] -> 1
  pthread_mutex_lock(&__global_lock);
  g2--;
  pthread_mutex_unlock(&__global_lock); // Write Mine influence: [[g2, __global_lock], t2_fun, {mutex2}] -> 0
  pthread_mutex_unlock(&mutex2);
  return NULL;
}

int main(void) {
  pthread_t id2;
  pthread_create(&id2, NULL, t2_fun, NULL);

  pthread_mutex_lock(&mutex1);
  pthread_mutex_lock(&__global_lock); // Read & join to g2 Mine influence: [[g2, __global_lock], t2_fun, {mutex2}] -> (0 join 1 = Unknown)
  assert(0 <= g2); // TODO (widening)
  assert(g2 <= 1);
  pthread_mutex_unlock(&__global_lock);

  pthread_mutex_lock(&mutex2);
  pthread_mutex_lock(&__global_lock);
  assert(g2 == 0);
  pthread_mutex_unlock(&__global_lock);
  pthread_mutex_unlock(&mutex2);

  pthread_mutex_unlock(&mutex1);

  pthread_join(id2, NULL);
  return 0;
}

Add Vesal's version of 13/24 where mutex-oplus and mutex-meet are more precise than old and mine


#import "AsyncActualValue.h"

namespace CedarAsync {
    template<typename T>
    struct InTimeMarker {
        T(^actualExpression)(void);
        const char *fileName;
        int lineNumber;
    };

    template<typename T>
    const AsyncActualValue<T> operator,(const InTimeMarker<T> & marker, const Cedar::Matchers::ActualValueMarker & _) {
        return AsyncActualValue<T>(marker.fileName, marker.lineNumber, marker.actualExpression);
    }

    template<typename T>
    const AsyncActualValueMatchProxy<T> operator,(const AsyncActualValue<T> & actualValue, bool negate) {
        return negate ? actualValue.to_not : actualValue.to;
    }

    template<typename T, typename MatcherType>
    void operator,(const AsyncActualValueMatchProxy<T> & matchProxy, const MatcherType & matcher) {
        matchProxy(matcher);
    }
}

#ifndef CEDAR_ASYNC_DISALLOW_IN_TIME
#define in_time(x) (InTimeMarker<typeof(x)>){^{return x;}, __FILE__, __LINE__}
#endif

#import "AsyncActualValue.h"

namespace CedarAsync {
    template<typename T>
    struct InTimeMarker {
        T(^actualExpression)(void);
        const char *fileName;
        int lineNumber;
    };

    template<typename T>
    const AsyncActualValue<T> operator,(const InTimeMarker<T> & marker, const Cedar::Matchers::ActualValueMarker & _) {
        return AsyncActualValue<T>(marker.fileName, marker.lineNumber, marker.actualExpression);
    }

    template<typename T>
    const AsyncActualValueMatchProxy<T> operator,(const AsyncActualValue<T> & actualValue, bool negate) {
        return negate ? actualValue.to_not : actualValue.to;
    }

    template<typename T, typename MatcherType>
    void operator,(const AsyncActualValueMatchProxy<T> & matchProxy, const MatcherType & matcher) {
        matchProxy(matcher);
    }
}

#ifndef CEDAR_ASYNC_DISALLOW_IN_TIME
#define in_time(x) (InTimeMarker<__typeof__(x)>){^{return x;}, __FILE__, __LINE__}
#endif

Use __typeof__ since typeof is unavailable in our build


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

#ifndef SSL_PRIVATE_H
#define SSL_PRIVATE_H

/* OpenSSL headers */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/x509v3.h>
/* Avoid tripping over an engine build installed globally and detected
 * when the user points at an explicit non-engine flavor of OpenSSL
 */
#if defined(HAVE_OPENSSL_ENGINE_H) && defined(HAVE_ENGINE_INIT)
#include <openssl/engine.h>
#endif

#endif /* SSL_PRIVATE_H */

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

#ifndef SSL_PRIVATE_H
#define SSL_PRIVATE_H

/* OpenSSL headers */
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/x509.h>
#include <openssl/pem.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
#include <openssl/x509v3.h>
/* Avoid tripping over an engine build installed globally and detected
 * when the user points at an explicit non-engine flavor of OpenSSL
 */
#ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h>
#endif

#endif /* SSL_PRIVATE_H */

Use OpenSSL engine by default.

Use OpenSSL engine by default.

git-svn-id: b819289d3a0e8888cd070d2ae628b7cf730b797f@300663 13f79535-47bb-0310-9956-ffa450edef68


#pragma once

#include "onnx/onnx_pb.h"
#include "onnx/ir.h"

namespace onnx { namespace optimization {

enum class API_TYPE {
  PROTO, IR
};

struct OptimizePass {

  std::string name;
  API_TYPE type;

  explicit OptimizePass(const std::string name, API_TYPE type)
    : name(name), type(type) {
  }

  virtual void optimize(onnx::ModelProto& mp) {}

  virtual void optimize(Graph& graph) {}

};

}} // namespace onnx::optimization

#pragma once

#include "onnx/onnx_pb.h"
#include "onnx/ir.h"

namespace onnx { namespace optimization {

enum class API_TYPE {
  PROTO, IR
};

struct OptimizePass {

  std::string name;
  API_TYPE type;

  explicit OptimizePass(const std::string& name, API_TYPE type)
    : name(name), type(type) {
  }

  virtual void optimize(onnx::ModelProto& mp) {}

  virtual void optimize(Graph& graph) {}

};

}} // namespace onnx::optimization

Fix the constructor of OptimizePass

Fix the constructor of OptimizePass


#ifndef _AUTOMATON_H_
#define _AUTOMATON_H_

/*
 * type and function definitions for an automaton
 */

#include "event.h"
#include "srpc/srpc.h"

typedef struct automaton Automaton;

void          au_init(void);
Automaton     *au_create(char *program, RpcConnection rpc, char *ebuf);
int           au_destroy(unsigned long id);
void          au_publish(unsigned long id, Event *event);
unsigned long au_id(Automaton *au);
Automaton     *au_au(unsigned long id);
RpcConnection au_rpc(Automaton *au);

#endif /* _AUTOMATON_H_ */

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

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

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

/*
 * type and function definitions for an automaton
 */

#include "event.h"
#include "srpc/srpc.h"

typedef struct automaton Automaton;

void          au_init(void);
Automaton     *au_create(char *program, RpcConnection rpc, char *ebuf);
int           au_destroy(unsigned long id);
void          au_publish(unsigned long id, Event *event);
unsigned long au_id(Automaton *au);
Automaton     *au_au(unsigned long id);
RpcConnection au_rpc(Automaton *au);

#endif /* _AUTOMATON_H_ */

Add BSD 3-clause open source header

Add BSD 3-clause open source header


#include "DefSoundDeviceState.h"
#include "AudioEndPointLibraryImpl.h"

// This class is exported from the AudioEndPointLibrary.dll
namespace AudioEndPoint {

    class AUDIOENDPOINTLIBRARY_API CAudioEndPointLibrary {
    public:
        ~CAudioEndPointLibrary();
        HRESULT OnDeviceStateChanged(LPCWSTR pwstr_device_id, DWORD dw_new_state) const;
        HRESULT OnDeviceAdded(LPCWSTR pwstr_device_id) const;
        HRESULT OnDeviceRemoved(LPCWSTR pwstr_device_id) const;
        HRESULT OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstr_default_device_id) const;
        static CAudioEndPointLibrary& GetInstance();
        AudioDeviceList GetPlaybackDevices(DefSound::EDeviceState state) const;
        AudioDeviceList GetRecordingDevices(DefSound::EDeviceState state) const;
        HRESULT RegisterNotificationClient() const;
        HRESULT UnRegisterNotificationClient() const;

        AudioEndPointLibrarySignals* m_signals1() const
        {
            return m_signals;
        }

        __declspec(property(get = m_signals1)) AudioEndPointLibrarySignals* Signals;

    private:
        CAudioEndPointLibrary(void);
        CAudioEndPointLibrary(CAudioEndPointLibrary const&) = delete;
        void operator=(CAudioEndPointLibrary const&) = delete;
        void Refresh() const;

        struct AudioEndPointLibraryImpl;
        struct AudioEndPointLibraryDevicesImpl;

        AudioEndPointLibraryImpl* m_container;
        AudioEndPointLibrarySignals* m_signals;
        AudioEndPointLibraryDevicesImpl* m_devices_lists;
    };

}

#include "DefSoundDeviceState.h"
#include "AudioEndPointLibraryImpl.h"

// This class is exported from the AudioEndPointLibrary.dll
namespace AudioEndPoint {

    class AUDIOENDPOINTLIBRARY_API CAudioEndPointLibrary {
    public:
        ~CAudioEndPointLibrary();
        HRESULT OnDeviceStateChanged(LPCWSTR pwstr_device_id, DWORD dw_new_state) const;
        HRESULT OnDeviceAdded(LPCWSTR pwstr_device_id) const;
        HRESULT OnDeviceRemoved(LPCWSTR pwstr_device_id) const;
        HRESULT OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstr_default_device_id) const;
        static CAudioEndPointLibrary& GetInstance();
        AudioDeviceList GetPlaybackDevices(DefSound::EDeviceState state) const;
        AudioDeviceList GetRecordingDevices(DefSound::EDeviceState state) const;

        AudioEndPointLibrarySignals* m_signals1() const
        {
            return m_signals;
        }

        __declspec(property(get = m_signals1)) AudioEndPointLibrarySignals* Signals;

    private:
        CAudioEndPointLibrary(void);
        CAudioEndPointLibrary(CAudioEndPointLibrary const&) = delete;
        void operator=(CAudioEndPointLibrary const&) = delete;
        void Refresh() const;
        HRESULT RegisterNotificationClient() const;
        HRESULT UnRegisterNotificationClient() const;

        struct AudioEndPointLibraryImpl;
        struct AudioEndPointLibraryDevicesImpl;

        AudioEndPointLibraryImpl* m_container;
        AudioEndPointLibrarySignals* m_signals;
        AudioEndPointLibraryDevicesImpl* m_devices_lists;
    };

}

Make the registering and unregistering of the Notification private


/* GTK - The GIMP Toolkit
 * Copyright (C) 2011 Chun-wei Fan <fanc999@yahoo.com.tw>
 *
 * Author: Chun-wei Fan <fanc999@yahoo.com.tw>
 *
 * 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 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, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <math.h>

/* Workaround for round() for non-GCC/non-C99 compilers */
#ifndef HAVE_ROUND
static inline double
round (double x)
{
  if (x >= 0)
    return floor (x + 0.5);
  else
    return ceil (x - 0.5);
}
#endif

/* Workaround for rint() for non-GCC/non-C99 compilers */
#ifndef HAVE_RINT
static inline double
rint (double x)
{
  if (ceil (x + 0.5) == floor (x + 0.5))
  {
    int a;
    a = (int) ceil (x);
    if (a % 2 == 0)
      return ceil (x);
    else
      return floor (x);
  }
  else
  {
    if (x >= 0)
      return floor (x + 0.5);
    else
      return ceil (x - 0.5);
  }
}
#endif

Add fallback implemetation for rint()/round()

Add an implementation for rint() and round() for compilers that do not
define one or both of them.  Note that this file should be included
after config.h was included.


// RUN: %clang_cc1 "-triple" "x86_64-apple-darwin3.0.0-iphoneos" -fsyntax-only -verify %s

void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1)));
void f1(int) __attribute__((availability(ios,introduced=2.1)));
void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0)));
void f3(int) __attribute__((availability(ios,introduced=3.0)));
void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}

void test() {
  f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}}
  f1(0);
  f2(0); // expected-warning{{'f2' is deprecated: first deprecated in iOS 3.0}}
  f3(0);
  f4(0); // expected-error{{f4' is unavailable: obsoleted in iOS 3.0}}
}

// RUN: %clang_cc1 "-triple" "x86_64-apple-darwin3.0.0-iphoneos" -fsyntax-only -verify %s

void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1)));
void f1(int) __attribute__((availability(ios,introduced=2.1)));
void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0)));
void f3(int) __attribute__((availability(ios,introduced=3.0)));
void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}

void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0)));
void f6(int) __attribute__((availability(ios,deprecated=3.0)));
void f6(int) __attribute__((availability(ios,introduced=2.0)));

void test() {
  f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}}
  f1(0);
  f2(0); // expected-warning{{'f2' is deprecated: first deprecated in iOS 3.0}}
  f3(0);
  f4(0); // expected-error{{f4' is unavailable: obsoleted in iOS 3.0}}
  f5(0); // expected-warning{{'f5' is deprecated: first deprecated in iOS 3.0}}
  f6(0); // expected-warning{{'f6' is deprecated: first deprecated in iOS 3.0}}
}

Test attribute merging for the availability attribute.

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


#pragma once
#ifndef YOU_DATASTORE_INTERNAL_OPERATION_H_
#define YOU_DATASTORE_INTERNAL_OPERATION_H_

#include <unordered_map>
#include "../ds_task_typedefs.h"

namespace You {
namespace DataStore {

/// A pure virtual class of operations to be put into transaction stack
class IOperation {
public:
	/// The constructor
	/// \param stask the serialized task the operation need to work with
	explicit IOperation(SerializedTask& stask);
	virtual ~IOperation();

	/// Executes the operation
	virtual void run() = 0;
};

}   // namespace DataStore
}   // namespace You

#endif  // YOU_DATASTORE_INTERNAL_OPERATION_H_

#pragma once
#ifndef YOU_DATASTORE_INTERNAL_OPERATION_H_
#define YOU_DATASTORE_INTERNAL_OPERATION_H_

#include <unordered_map>
#include "../ds_task_typedefs.h"

namespace You {
namespace DataStore {

/// A pure virtual class of operations to be put into transaction stack
class IOperation {
public:
	/// The constructor
	/// \param stask the serialized task the operation need to work with
	explicit IOperation(SerializedTask& stask);
	virtual ~IOperation();

	/// Executes the operation
	virtual bool run() = 0;
protected:
	TaskId taskId;
	SerializedTask task;
};

}   // namespace DataStore
}   // namespace You

#endif  // YOU_DATASTORE_INTERNAL_OPERATION_H_

Change return value of run to bool

Change return value of run to bool

Conflicts:
	You-DataStore/internal/operation.h
	You-DataStore/internal/operations/post_operation.h


// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#ifndef _BLE_LIMITS_H_
#define _BLE_LIMITS_H_

#include <stdlib.h>

#ifndef __AVR__

#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif

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

#endif

#if defined(NRF51) || defined(__RFduino__)

#define BLE_ADVERTISEMENT_DATA_MAX_VALUE_LENGTH    26
#define BLE_SCAN_DATA_MAX_VALUE_LENGTH             29
#define BLE_EIR_DATA_MAX_VALUE_LENGTH              29
#define BLE_ATTRIBUTE_MAX_VALUE_LENGTH             20
#define BLE_REMOTE_ATTRIBUTE_MAX_VALUE_LENGTH      22

#else

#define BLE_ADVERTISEMENT_DATA_MAX_VALUE_LENGTH    20
#define BLE_SCAN_DATA_MAX_VALUE_LENGTH             20
#define BLE_EIR_DATA_MAX_VALUE_LENGTH              20
#define BLE_ATTRIBUTE_MAX_VALUE_LENGTH             20
#define BLE_REMOTE_ATTRIBUTE_MAX_VALUE_LENGTH      22

#endif

#endif

// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#ifndef _BLE_LIMITS_H_
#define _BLE_LIMITS_H_

#include <stdlib.h>

#ifndef __AVR__

#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif

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

#endif

#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)

#define BLE_ADVERTISEMENT_DATA_MAX_VALUE_LENGTH    26
#define BLE_SCAN_DATA_MAX_VALUE_LENGTH             29
#define BLE_EIR_DATA_MAX_VALUE_LENGTH              29
#define BLE_ATTRIBUTE_MAX_VALUE_LENGTH             20
#define BLE_REMOTE_ATTRIBUTE_MAX_VALUE_LENGTH      22

#else

#define BLE_ADVERTISEMENT_DATA_MAX_VALUE_LENGTH    20
#define BLE_SCAN_DATA_MAX_VALUE_LENGTH             20
#define BLE_EIR_DATA_MAX_VALUE_LENGTH              20
#define BLE_ATTRIBUTE_MAX_VALUE_LENGTH             20
#define BLE_REMOTE_ATTRIBUTE_MAX_VALUE_LENGTH      22

#endif

#endif

Fix length issues with nRF52

Fix length issues with nRF52


/*
  This file is part of ethash.

  ethash is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

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

  You should have received a copy of the GNU General Public License
  along with ethash.  If not, see <http://www.gnu.org/licenses/>.
*/
/** @file util.h
 * @author Tim Hughes <tim@twistedfury.com>
 * @date 2015
 */
#pragma once
#include <stdint.h>
#include "compiler.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _MSC_VER
void debugf(char const* str, ...);
#else
#define debugf printf
#endif

static inline uint32_t min_u32(uint32_t a, uint32_t b)
{
	return a < b ? a : b;
}

static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_)
{
	return x < min_ ? min_ : (x > max_ ? max_ : x);
}

#ifdef __cplusplus
}
#endif

/*
  This file is part of ethash.

  ethash is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

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

  You should have received a copy of the GNU General Public License
  along with ethash.  If not, see <http://www.gnu.org/licenses/>.
*/
/** @file util.h
 * @author Tim Hughes <tim@twistedfury.com>
 * @date 2015
 */
#pragma once
#include <stdint.h>
#include "compiler.h"

#ifdef __cplusplus
extern "C" {
#endif

//#ifdef _MSC_VER
void debugf(char const* str, ...);
//#else
//#define debugf printf
//#endif

static inline uint32_t min_u32(uint32_t a, uint32_t b)
{
	return a < b ? a : b;
}

static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_)
{
	return x < min_ ? min_ : (x > max_ ? max_ : x);
}

#ifdef __cplusplus
}
#endif

Comment out conflicting debug macro

Comment out conflicting debug macro


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

float f(float x) {
    return 1/x;
}

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

    // Integral (1 to 6) of 1/x
    float integral;
    float a = 1, b = 6;
    int n = 2000;
    float h;
    float x;

    h = (b-a)/n;

    integral = (f(a) + f(b)) / 2.0;
    x = a;

    for (int i = 1; i <= n - 1; i++) {
        x = x + h;
        integral = integral + f(x);
    }

    integral = integral * h;

    float expected = 1.79175946923;
    printf("Integral (%.0f to %.0f) of 1/x \n\n", a, b);
    printf("Expected  result  = %.11f\n", expected);
    printf("Estimated result  = %.11f\n", integral);
    printf("                    -------------\n");

    float difference = expected - integral;
    difference = fabsf(difference); // absolute value (no minus sign)
    printf("Difference        = %.11f\n", difference);

    return 0;
}

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

double f(double x) { return 1 / x; }

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

    // Integral (1 to 6) of 1/x
    double integral;
    int a = 1, b = 6;
    int n = 2000;
    double h;
    double x;

    h = (double)(b-a)/n;

    integral = (f(a) + f(b)) / 2.0;
    x = a;

    for (int i = 1; i < n; i++) {
        x = x + h;
        integral = integral + f(x);
    }

    integral = integral * h;

    double expected = 1.79175946923;
    printf("Integral (%d to %d) of 1/x \n\n", a, b);
    printf("Expected  result  = %.11f\n", expected);
    printf("Estimated result  = %.11f\n", integral);
    printf("                    -------------\n");

    double difference = expected - integral;
    difference = fabsf(difference); // absolute value (no minus sign)
    printf("Difference        = %.11f\n", difference);

    return 0;
}

Use double instead of float

Use double instead of float

Float was not able to maintain data precision


#pragma once

#include <string>
#include <vector>
#include <sqltypes.h>

namespace cpp_odbc { namespace level2 {

/**
 * @brief This class represents a buffer for u16strings for use with the unixodbc C API.
 */
class u16string_buffer {
public:
    /**
     * @brief Constructs a new string buffer with the given capacity, i.e., maximum size
     * @param capacity Capacity of the buffer
     */
    u16string_buffer(signed short int capacity);

    /**
     * @brief Retrieve the capacity of the buffer (in characters) in a format suitable for passing
     *        to unixodbc API functions.
     */
    signed short int capacity() const;

    /**
     * @brief Retrieve a pointer to the internal buffer suitable for passing to unixodbc API functions.
     *        This buffer contains the actual string data. Do not exceed the allocated capacity!
     */
    SQLWCHAR * data_pointer();

    /**
     * @brief Retrieve a pointer to a size buffer suitable for passing to unixodbc API functions.
     *        This buffer contains the number of significant bytes in the buffer returned by
     *        data_pointer().
     */
    signed short int * size_pointer();

    /**
     * @brief Conversion operator. Retrieve the buffered data as a string. Bad things will happen if
     *        the value of size_pointer is larger than the capacity!
     */
    operator std::u16string() const;

private:
    std::vector<SQLWCHAR> data_;
    signed short int used_size_;
};

} }

#pragma once

#include <string>
#include <vector>
#include <sql.h>

namespace cpp_odbc { namespace level2 {

/**
 * @brief This class represents a buffer for u16strings for use with the unixodbc C API.
 */
class u16string_buffer {
public:
    /**
     * @brief Constructs a new string buffer with the given capacity, i.e., maximum size
     * @param capacity Capacity of the buffer
     */
    u16string_buffer(signed short int capacity);

    /**
     * @brief Retrieve the capacity of the buffer (in characters) in a format suitable for passing
     *        to unixodbc API functions.
     */
    signed short int capacity() const;

    /**
     * @brief Retrieve a pointer to the internal buffer suitable for passing to unixodbc API functions.
     *        This buffer contains the actual string data. Do not exceed the allocated capacity!
     */
    SQLWCHAR * data_pointer();

    /**
     * @brief Retrieve a pointer to a size buffer suitable for passing to unixodbc API functions.
     *        This buffer contains the number of significant bytes in the buffer returned by
     *        data_pointer().
     */
    signed short int * size_pointer();

    /**
     * @brief Conversion operator. Retrieve the buffered data as a string. Bad things will happen if
     *        the value of size_pointer is larger than the capacity!
     */
    operator std::u16string() const;

private:
    std::vector<SQLWCHAR> data_;
    signed short int used_size_;
};

} }

Use different header to be yet more compatible with Windows


#ifndef SHUTDOWN_I6F54URD

#define SHUTDOWN_I6F54URD

void ArchShutdown(void);

#endif /* end of include guard: SHUTDOWN_I6F54URD */

#ifndef SHUTDOWN_I6F54URD

#define SHUTDOWN_I6F54URD

void ArchBreak(void);
void ArchShutdown(void);

#endif /* end of include guard: SHUTDOWN_I6F54URD */

Add ArchBreak to the header.

Add ArchBreak to the header.


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

#ifndef SURGSIM_FRAMEWORK_CONVERT_H
#define SURGSIM_FRAMEWORK_CONVERT_H

#include "SurgSim/Framework/Log.h"

/// \note HS-2013-dec-23 The gcc and msvc compilers seem to have different requirements when a template class
///       needs to be passed template parameters in a specialization, that extend the original template interface
///       gcc needs the template<> statement before the new template parameters, msvc does not like it at all.
#ifdef _GNUC_
#define SURGSIM_DOUBLE_SPECIALIZATION template<>
#else
#define SURGSIM_DOUBLE_SPECIALIZATION
#endif

namespace SurgSim
{
namespace Serialize
{
	/// Logger name for Serialization
	const std::string serializeLogger = "Serialization";

};
};

#endif // SURGSIM_FRAMEWORK_CONVERT_H

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

#ifndef SURGSIM_FRAMEWORK_CONVERT_H
#define SURGSIM_FRAMEWORK_CONVERT_H

#include "SurgSim/Framework/Log.h"
#include <yaml-cpp/yaml.h>

/// \note HS-2013-dec-23 The gcc and msvc compilers seem to have different requirements when a template class
///       needs to be passed template parameters in a specialization, that extend the original template interface
///       gcc needs the template<> statement before the new template parameters, msvc does not like it at all.
#ifdef _GNUC_
#define SURGSIM_DOUBLE_SPECIALIZATION template<>
#else
#define SURGSIM_DOUBLE_SPECIALIZATION
#endif

namespace SurgSim
{
namespace Serialize
{
	/// Logger name for Serialization
	const std::string serializeLogger = "Serialization";

};
};

#endif // SURGSIM_FRAMEWORK_CONVERT_H

Add back yaml-cpp/yaml.h header file for convert<> class template.


/**
 * @file
 * @brief
 *
 * @date    29.03.2017
 * @author  Alex Kalmuk
 */
#include <unistd.h>
#include <util/log.h>
#include <drivers/i2c/i2c.h>

#include "gy_30.h"

#define GY30_ADDR       0x46

uint16_t gy_30_read_light_level(unsigned char id) {
	uint16_t level = 0;

	/* It would be better do not hang here but return error code */
	while (0 > i2c_bus_read(id, GY30_ADDR, (uint8_t *) &level, 2))
		;

	/* The actual value in lx is level / 1.2 */
	return (((uint32_t) level) * 5) / 6;
}

void gy_30_setup_mode(unsigned char id, uint8_t mode) {
	while (0 > i2c_bus_write(id, GY30_ADDR, &mode, 1))
		;

	/* Documentation says that we need to wait approximately 180 ms here.*/
	usleep(180000);

	log_debug("%s\n", "gy_30_setup_mode OK!\n");
}

/**
 * @file
 * @brief
 *
 * @date    29.03.2017
 * @author  Alex Kalmuk
 */
#include <unistd.h>
#include <util/log.h>
#include <drivers/i2c/i2c.h>

#include "gy_30.h"

/* http://www.elechouse.com/elechouse/images/product/Digital%20light%20Sensor/bh1750fvi-e.pdf */
#define GY30_ADDR       0x23

uint16_t gy_30_read_light_level(unsigned char id) {
	uint16_t level = 0;

	/* It would be better do not hang here but return error code */
	while (0 > i2c_bus_read(id, GY30_ADDR, (uint8_t *) &level, 2))
		;

	/* The actual value in lx is level / 1.2 */
	return (((uint32_t) level) * 5) / 6;
}

void gy_30_setup_mode(unsigned char id, uint8_t mode) {
	while (0 > i2c_bus_write(id, GY30_ADDR, &mode, 1))
		;

	/* Documentation says that we need to wait approximately 180 ms here.*/
	usleep(180000);

	log_debug("%s\n", "gy_30_setup_mode OK!\n");
}

Fix gy-30 light sensor i2c address

drivers: Fix gy-30 light sensor i2c address


/// Umbrella header for the Hub Framework

#import "HUBManager.h"
#import "HUBComponent.h"
#import "HUBComponentModel.h"
#import "HUBComponentRegistry.h"
#import "HUBComponentFallbackHandler.h"

/// Umbrella header for the Hub Framework

#import "HUBManager.h"
#import "HUBComponent.h"
#import "HUBComponentModel.h"
#import "HUBComponentModelBuilder.h"
#import "HUBComponentImageData.h"
#import "HUBComponentImageDataBuilder.h"
#import "HUBComponentRegistry.h"
#import "HUBComponentFallbackHandler.h"

Add new API files to umbrella header

Add new API files to umbrella header


#ifndef PLUGIN_H_
#define PLUGIN_H_

#include "plugin_portable.h"

#include <windows.h>

// TODO use __stdcall
#define EXPORT_CALLING __cdecl
#define EXPORT __declspec(dllexport) EXPORT_CALLING

#include "common.h"

// just defined to make compilation work ; ignored
#define RTLD_DEFAULT NULL
#define RTLD_LOCAL   -1
#define RTLD_LAZY    -1

static inline void *dlopen(const char *name, int flags)
{
    // TODO use LoadLibraryEx() and flags ?
    return LoadLibrary(name);
}

static inline void *dlsym(void *handle, const char *name)
{
    FARPROC g = GetProcAddress(handle, name);
    void *h;
    *(FARPROC*)&h = g;
    return h;
}

static inline char *dlerror(void)
{
    static __thread char buf[1024];

    FormatMessage(
        FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,
        NULL,
        GetLastError(),
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR)&buf,
        sizeof buf, NULL);

    return buf;
}

static inline int dlclose(void *handle)
{
    return !FreeLibrary(handle);
}

#endif

#ifndef PLUGIN_H_
#define PLUGIN_H_

#include "plugin_portable.h"

#include <windows.h>

// TODO use __stdcall
#define EXPORT_CALLING __cdecl
#define EXPORT __declspec(dllexport) EXPORT_CALLING

#include "common.h"

// just defined to make compilation work ; ignored
#define RTLD_DEFAULT NULL
#define RTLD_LOCAL   -1
#define RTLD_LAZY    -1
#define RTLD_NOW     -1

static inline void *dlopen(const char *name, int flags)
{
    (void)flags;
    // TODO use LoadLibraryEx() and flags ?
    return LoadLibrary(name);
}

static inline void *dlsym(void *handle, const char *name)
{
    FARPROC g = GetProcAddress(handle, name);
    void *h;
    *(FARPROC*)&h = g;
    return h;
}

static inline char *dlerror(void)
{
    static __thread char buf[1024];

    FormatMessage(
        FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,
        NULL,
        GetLastError(),
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR)&buf,
        sizeof buf, NULL);

    return buf;
}

static inline int dlclose(void *handle)
{
    return !FreeLibrary(handle);
}

#endif

Mend Win32 build broken by 8e1c4386

Mend Win32 build broken by 8e1c4386