#include <string.h>

#include "roman_convert_to_int.h"

int roman_convert_to_int(const char *numeral)
{
	if (!numeral)
	{
		return -1;
	}
	const char first_letter = *numeral;
	switch (first_letter)
	{
		case 'I':
			return 1;
		case 'V':
			return 5;
		case 'X':
			return 10;
		case 'L':
			return 50;
		case 'C':
			return 100;
		case 'D':
			return 500;
		case 'M':
			return 1000;
		default:
			return -1;
	}
}

#include <string.h>

#include "roman_convert_to_int.h"

int roman_convert_to_int(const char *numeral)
{
	const char first_letter = numeral ? *numeral : '?';
	switch (first_letter)
	{
		case 'I':
			return 1;
		case 'V':
			return 5;
		case 'X':
			return 10;
		case 'L':
			return 50;
		case 'C':
			return 100;
		case 'D':
			return 500;
		case 'M':
			return 1000;
		default:
			return -1;
	}
}

Simplify error handling for missing/unknown numerals


// PARAM: --set ana.activated "['base','mallocWrapper','threadflag']"
#include <pthread.h>
int g = 10;

void* t(void *v) {
  int* p = (int*) v;
  *p = 4711;
}

int main(void){
  int l = 42;

  pthread_t tid;
  pthread_create(&tid, NULL, t, (void *)&l);
  pthread_join(tid, NULL);

  assert(l==42); //UNKNOWN!
  return 0;
}

Add failing test without threadescape

Add failing test without threadescape


/* Copyright (C) 2002 Timo Sirainen */

#include "common.h"
#include "mail-namespace.h"
#include "commands.h"

bool cmd_create(struct client_command_context *cmd)
{
	struct mail_namespace *ns;
	const char *mailbox, *full_mailbox;
	bool directory;
	size_t len;

	/* <mailbox> */
	if (!client_read_string_args(cmd, 1, &mailbox))
		return FALSE;
	full_mailbox = mailbox;

	ns = client_find_namespace(cmd, &mailbox);
	if (ns == NULL)
		return TRUE;

	len = strlen(full_mailbox);
	if (len == 0 || full_mailbox[len-1] != ns->sep)
		directory = FALSE;
	else {
		/* name ends with hierarchy separator - client is just
		   informing us that it wants to create children under this
		   mailbox. */
                directory = TRUE;
		mailbox = t_strndup(mailbox, len-1);
		full_mailbox = t_strndup(full_mailbox, strlen(full_mailbox)-1);
	}

	if (!client_verify_mailbox_name(cmd, full_mailbox, FALSE, TRUE))
		return TRUE;

	if (mail_storage_mailbox_create(ns->storage, mailbox, directory) < 0)
		client_send_storage_error(cmd, ns->storage);
	else
		client_send_tagline(cmd, "OK Create completed.");
	return TRUE;
}

/* Copyright (C) 2002 Timo Sirainen */

#include "common.h"
#include "mail-namespace.h"
#include "commands.h"

bool cmd_create(struct client_command_context *cmd)
{
	struct mail_namespace *ns;
	const char *mailbox, *full_mailbox;
	bool directory;
	size_t len;

	/* <mailbox> */
	if (!client_read_string_args(cmd, 1, &mailbox))
		return FALSE;
	full_mailbox = mailbox;

	ns = client_find_namespace(cmd, &mailbox);
	if (ns == NULL)
		return TRUE;

	len = strlen(full_mailbox);
	if (len == 0 || full_mailbox[len-1] != ns->sep)
		directory = FALSE;
	else {
		/* name ends with hierarchy separator - client is just
		   informing us that it wants to create children under this
		   mailbox. */
                directory = TRUE;
		mailbox = t_strndup(mailbox, strlen(mailbox)-1);
		full_mailbox = t_strndup(full_mailbox, len-1);
	}

	if (!client_verify_mailbox_name(cmd, full_mailbox, FALSE, TRUE))
		return TRUE;

	if (mail_storage_mailbox_create(ns->storage, mailbox, directory) < 0)
		client_send_storage_error(cmd, ns->storage);
	else
		client_send_tagline(cmd, "OK Create completed.");
	return TRUE;
}

CREATE ns_prefix/box/ didn't work right when namespace prefix existed.


/*
Copyright (C) 2021 The Falco Authors.

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

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

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

// The version of rules/filter fields/etc supported by this Falco
// engine.
#define FALCO_ENGINE_VERSION (11)

// This is the result of running "falco --list -N | sha256sum" and
// represents the fields supported by this version of Falco. It's used
// at build time to detect a changed set of fields.
#define FALCO_FIELDS_CHECKSUM "9822482ceda8c4ee3475e698ba35a74c5e7abf971deb4e989e26415434bbd89b"

/*
Copyright (C) 2021 The Falco Authors.

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

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

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

// The version of rules/filter fields/etc supported by this Falco
// engine.
#define FALCO_ENGINE_VERSION (11)

// This is the result of running "falco --list -N | sha256sum" and
// represents the fields supported by this version of Falco. It's used
// at build time to detect a changed set of fields.
#define FALCO_FIELDS_CHECKSUM "4de812495f8529ac20bda2b9774462b15911a51df293d59fe9ccb6b922fdeb9d"

Update fields checksum (no changes, order only)

With the new implementation of list_fields(), the order of fields
changed slightly. So update the checksum.

Signed-off-by: Mark Stemm <1b6cbc2e568a933a16c6fa30b73e50cd507debf7@gmail.com>


void multiply_by_diagonal(const int rows, const int cols,
                          double* restrict diagonal, double* restrict matrix) {
        /*
         * Multiply a matrix by a diagonal matrix (represented as a flat array
         * of n values). The diagonal structure is exploited (so that we use
         * n^2 multiplications instead of n^3); the product looks something
         * like
         *
         *     sage: A = matrix([[a,b,c], [d,e,f],[g,h,i]]);
         *     sage: w = matrix([[z1,0,0],[0,z2,0],[0,0,z3]]);
         *     sage: A * w
         *      => [a*z1 b*z2 c*z3]
         *         [d*z1 e*z2 f*z3]
         *         [g*z1 h*z2 i*z3]
         */
        int i, j;
        /* traverse the matrix in the correct order. */
#ifdef USE_COL_MAJOR
        for (j = 0; j < cols; j++)
                for (i = 0; i < rows; i++)
#else
        for (i = 0; i < rows; i++)
                for (j = 0; j < cols; j++)
#endif
                        matrix[ORDER(i, j, rows, cols)] *= diagonal[j];
}

REFACTOR removed duplicates and created own file for this


#ifndef SCHED_H
#define SCHED_H

#include <Input.h>
#include <Watch.h>
#include <Display.h>

#include <unistd.h>	// for sleep()

class Sched
{
	public:
	Sched(Input* input, Watch* watch, Display* display)
		: input_(input)
		, watch_(watch)
		, display_(display)
	{}

	public:
	void run()
	{
		while(!shouldStop())
		{
			sleep(1);
			input_->frame();
		 // watch_->frame();
		 // display_->frame();
		}
	}

	bool shouldStop() const
	{ return input_->shouldStop(); }

	private:
	Input* input_;
	Watch* watch_;
	Display* display_;
};

#endif

#ifndef SCHED_H
#define SCHED_H

#include <Input.h>
#include <Watch.h>
#include <Display.h>

#include <unistd.h>	// for sleep()
#include <iostream>

class Sched
{
	public:
	Sched(Input* input, Watch* watch, Display* display)
		: input_(input)
		, watch_(watch)
		, display_(display)
	{}

	public:
	void run()
	{
		while(!shouldStop())
		{
			sleep(1);

			// clear screen, normally this should be done in Display
			// but we want to fsm debug output to be shown (and not wiped away by this
			// clear screen)
			std::cout << "\x1B[2J\x1B[H";
			input_->frame();
		 // watch_->frame();
		 // display_->frame();
		}
	}

	bool shouldStop() const
	{ return input_->shouldStop(); }

	private:
	Input* input_;
	Watch* watch_;
	Display* display_;
};

#endif

Clear screen before each cycle

Clear screen before each cycle


/*
 * Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
 *
 * 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 __VOTCA_CSG_LAMMPSDUMPWRITER_H
#define __VOTCA_CSG_LAMMPSDUMPWRITER_H

#include <stdio.h>
#include <votca/csg/topology.h>
#include <votca/csg/trajectorywriter.h>

namespace votca {
namespace csg {

class LAMMPSDumpWriter : public TrajectoryWriter {
 public:
  void Open(std::string file, bool bAppend = false) override;
  void Close() override;

  void Write(Topology *conf) override;

 private:
  FILE *_out;
};

}  // namespace csg
}  // namespace votca

#endif  // __VOTCA_CSG_LAMMPSDUMPWRITER_H

/*
 * Copyright 2009-2019 The VOTCA Development Team (http://www.votca.org)
 *
 * 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 __VOTCA_CSG_LAMMPSDUMPWRITER_H
#define __VOTCA_CSG_LAMMPSDUMPWRITER_H

#include <stdio.h>
#include <votca/csg/topology.h>
#include <votca/csg/trajectorywriter.h>
#include <votca/tools/unitconverter.h>

namespace votca {
namespace csg {

class LAMMPSDumpWriter : public TrajectoryWriter {
 public:
  void Open(std::string file, bool bAppend = false) override;
  void Close() override;

  void Write(Topology *conf) override;

 private:
  FILE *_out;
};

}  // namespace csg
}  // namespace votca

#endif  // __VOTCA_CSG_LAMMPSDUMPWRITER_H

Add unit converter include to lammps dump writer


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 _GUAC_PARSER_CONSTANTS_H
#define _GUAC_PARSER_CONSTANTS_H

/**
 * Constants related to the Guacamole protocol parser.
 *
 * @file parser-constants.h
 */

/**
 * The maximum number of characters per instruction.
 */
#define GUAC_INSTRUCTION_MAX_LENGTH 8192

/**
 * The maximum number of digits to allow per length prefix.
 */
#define GUAC_INSTRUCTION_MAX_DIGITS 5

/**
 * The maximum number of elements per instruction, including the opcode.
 */
#define GUAC_INSTRUCTION_MAX_ELEMENTS 64

#endif

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 _GUAC_PARSER_CONSTANTS_H
#define _GUAC_PARSER_CONSTANTS_H

/**
 * Constants related to the Guacamole protocol parser.
 *
 * @file parser-constants.h
 */

/**
 * The maximum number of characters per instruction.
 */
#define GUAC_INSTRUCTION_MAX_LENGTH 8192

/**
 * The maximum number of digits to allow per length prefix.
 */
#define GUAC_INSTRUCTION_MAX_DIGITS 5

/**
 * The maximum number of elements per instruction, including the opcode.
 */
#define GUAC_INSTRUCTION_MAX_ELEMENTS 128

#endif

GUACAMOLE-587: Merge changes allowing up to 128 elements per Guacamole instruction.


//! \file WikiWalker.h

#ifndef WIKIWALKER_H
#define WIKIWALKER_H

#include <string>

#include "CurlWikiGrabber.h"
#include "Walker.h"

namespace WikiWalker
{
  //! main "app" class
  class WikiWalker : public Walker
  {
  public:
    /*! given an URL, start collecting links
     * \param url start point for analysis
     */
    void startWalking(const std::string& url);

    /*! fetch not only requested article, but also linked ones.
     * \param depth whether to fetch linked articles as well
     */
    void setDeep(bool depth)
    {
      fetchGenerator = depth;
    }

    /*! Read data from cache file.
     * Used for initialization.
     * \param cacheFile file name of the cache.
     */
    void readCache(const std::string& cacheFile);

    /*! Write data to cache file.
     * \param cacheFile file name of the cache.
     */
    void writeCache(const std::string& cacheFile);

  private:
    CurlWikiGrabber grabber;
    bool fetchGenerator;
  };
}  // namespace WikiWalker
#endif  // WIKIWALKER_H

//! \file WikiWalker.h

#ifndef WIKIWALKER_H
#define WIKIWALKER_H

#include <string>

#include "CurlWikiGrabber.h"
#include "Walker.h"

namespace WikiWalker
{
  //! main "app" class
  class WikiWalker : public Walker
  {
  public:
    //! Creates a new instance
    WikiWalker() : Walker(), fetchGenerator(false), grabber()
    {
    }

    /*! given an URL, start collecting links
     * \param url start point for analysis
     */
    void startWalking(const std::string& url);

    /*! fetch not only requested article, but also linked ones.
     * \param depth whether to fetch linked articles as well
     */
    void setDeep(bool depth)
    {
      fetchGenerator = depth;
    }

    /*! Read data from cache file.
     * Used for initialization.
     * \param cacheFile file name of the cache.
     */
    void readCache(const std::string& cacheFile);

    /*! Write data to cache file.
     * \param cacheFile file name of the cache.
     */
    void writeCache(const std::string& cacheFile);

  private:
    CurlWikiGrabber grabber;
    bool fetchGenerator;
  };
}  // namespace WikiWalker
#endif  // WIKIWALKER_H

Add contructor to initialize fetchGenerator correctly


#ifndef __VIDEO_RX_H__
#define __VIDEO_RX_H__

#include "libavformat/avformat.h"

typedef struct DecodedFrame {
	AVFrame* pFrameRGB;
	uint8_t *buffer;
} DecodedFrame;

typedef struct FrameManager {
	enum PixelFormat pix_fmt;
	void (*put_video_frame_rx)(uint8_t *data, int width, int height, int nframe);
	DecodedFrame* (*get_decoded_frame_buffer)(int width, int height);
	void (*release_decoded_frame_buffer)(void);
} FrameManager;

int start_video_rx(const char* sdp, int maxDelay, FrameManager *frame_manager);
int stop_video_rx();

#endif /* __VIDEO_RX_H__ */

#ifndef __VIDEO_RX_H__
#define __VIDEO_RX_H__

#include "libavformat/avformat.h"

typedef struct DecodedFrame {
	AVFrame* pFrameRGB;
	uint8_t *buffer;
	void *priv_data; /* User private data */
} DecodedFrame;

typedef struct FrameManager {
	enum PixelFormat pix_fmt;
	void (*put_video_frame_rx)(uint8_t *data, int width, int height, int nframe);
	DecodedFrame* (*get_decoded_frame_buffer)(int width, int height);
	void (*release_decoded_frame_buffer)(void);
} FrameManager;

int start_video_rx(const char* sdp, int maxDelay, FrameManager *frame_manager);
int stop_video_rx();

#endif /* __VIDEO_RX_H__ */

Add priv_data field in DecodedFrame struct.


/* Challenging example:
   To keep the relationship x = y - 1 while x <= 31 is easy.
   The tricky part is when x = 32:
     - We add one to x so the relationship between x and y is x = y so
       the assertion still holds.
     - Set err to 1.
   Once err is one we don't update x or y anymore.

   After the switch we lose whether err is 0 or 1 so we will
   keep incrementing x and y.
*/
extern int nd(void);
extern void __VERIFIER_error(void) __attribute__((noreturn));
#define assert(X) if(!(X)){__VERIFIER_error();}
extern void __VERIFIER_assume (int v);
#define assume(X) __VERIFIER_assume(X)

int main(){
    // Constructor
    int x = 0;
    int y = 1;

    while (nd()) {
        int fid = nd();
        // We create snapshots for all state variables.
        int nx = x;
        int ny = y;
        int err = 0;
        switch (fid) {
        case 0:
	  if (nx < 32) {
	    nx += 2;
	    ny += 2;
	  } else {
	    nx++;
	    err = 1;
	  }
	  break;
	default:;;
        }
        if (err == 0) {
            // Commit state changes.
            x = nx;
            y = ny;
        }
    }
    assert(x <= y);
    return 0;
}

Add test that is unprovable for now

Add test that is unprovable for now


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

#define LIMIT 2000000

unsigned long solution(){
    unsigned long n;
    unsigned long total_sum = 0L;
    n = 2L;

    while(n <= LIMIT){
        if(is_prime(n) == 1){
            total_sum = total_sum + n;
        }
        n += 1L;
    }

    return total_sum;
}

int main(int argc, char *argv[]){
    unsigned_long_time_it(solution);
    return 0;
}

Add C implementation for problem 10

Add C implementation for problem 10


// This file is part of nbind, copyright (C) 2014-2015 BusFaster Ltd.
// Released under the MIT license, see LICENSE.

#pragma once

#ifdef BUILDING_NODE_EXTENSION

#include "Binding.h"

#define NBIND_ERR(message) nbind::Bindings::setError(message)

#define NBIND_CLASS(Name) \
	template<class Bound> struct BindInvoker { \
		BindInvoker(); \
		nbind::BindClass<Name> linkage; \
		nbind::BindDefiner<Name> definer; \
	}; \
	static struct BindInvoker<Name> bindInvoker##Name; \
	template<class Bound> BindInvoker<Bound>::BindInvoker():definer(#Name)

#define method(name) definer.function(#name, &Bound::name)
#define constructor definer.constructor

#define NBIND_INIT(moduleName) NODE_MODULE(moduleName, nbind::Bindings::initModule)

#else

#define NBIND_ERR(message)

#endif

// This file is part of nbind, copyright (C) 2014-2015 BusFaster Ltd.
// Released under the MIT license, see LICENSE.

#pragma once

#ifdef BUILDING_NODE_EXTENSION

#include "Binding.h"

#define NBIND_ERR(message) nbind::Bindings::setError(message)

#define NBIND_CLASS(Name) \
	template<class Bound> struct BindInvoker { \
		BindInvoker(); \
		nbind::BindClass<Name> linkage; \
		nbind::BindDefiner<Name> definer; \
	}; \
	static struct BindInvoker<Name> bindInvoker##Name; \
	template<class Bound> BindInvoker<Bound>::BindInvoker():definer(#Name)

#define method(name) definer.function(#name, &Bound::name)
#define construct definer.constructor

#define NBIND_INIT(moduleName) NODE_MODULE(moduleName, nbind::Bindings::initModule)

#else

#define NBIND_ERR(message)

#endif

Fix GCC keyword conflict with simpler API.


/*
 *  Copyright 2008-2009 NVIDIA Corporation
 *
 *  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.
 */

/*! \file casts.h
 *  \brief Unsafe casts for internal use.
 */

#pragma once

#include <thrust/iterator/iterator_traits.h>

namespace thrust
{

namespace detail
{

namespace dispatch
{

template<typename TrivialIterator>
  typename thrust::iterator_traits<TrivialIterator>::value_type *
    raw_pointer_cast(TrivialIterator i,
                     thrust::random_access_host_iterator_tag)
{
  typedef typename thrust::iterator_traits<TrivialIterator>::value_type * Pointer;

  // cast away constness
  return const_cast<Pointer>(&*i);
} // end raw_pointer_cast()

// this path will work for device_ptr & device_vector::iterator
template<typename TrivialIterator>
  typename thrust::iterator_traits<TrivialIterator>::value_type *
    raw_pointer_cast(TrivialIterator i,
                     thrust::random_access_device_iterator_tag)
{
  typedef typename thrust::iterator_traits<TrivialIterator>::value_type * Pointer;

  // cast away constness
  return const_cast<Pointer>((&*i).get());
} // end raw_pointer_cast()

} // end dispatch

template<typename TrivialIterator>
  typename thrust::iterator_traits<TrivialIterator>::value_type *raw_pointer_cast(TrivialIterator i)
{
  return detail::dispatch::raw_pointer_cast(i, thrust::iterator_traits<TrivialIterator>::iterator_category());
} // end raw_pointer_cast()

} // end detail

} // end thrust

Add git r done version of detail::raw_pointer_cast


//===--- Once.h - Runtime support for lazy initialization ------*- C++ -*--===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Swift runtime functions in support of lazy initialization.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_RUNTIME_ONCE_H
#define SWIFT_RUNTIME_ONCE_H

#include "swift/Runtime/HeapObject.h"

namespace swift {

#ifdef __APPLE__

// On OS X and iOS, swift_once_t matches dispatch_once_t.
typedef long swift_once_t;

#else

// On other platforms swift_once_t is pointer-sized.
typedef int swift_once_t;

#endif

/// Runs the given function with the given context argument exactly once.
/// The predicate argument must point to a global or static variable of static
/// extent of type swift_once_t.
extern "C"
void swift_once(swift_once_t *predicate, void (*fn)(HeapObject *ctx),
                HeapObject *ctx);

}

#endif

//===--- Once.h - Runtime support for lazy initialization ------*- C++ -*--===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Swift runtime functions in support of lazy initialization.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_RUNTIME_ONCE_H
#define SWIFT_RUNTIME_ONCE_H

#include "swift/Runtime/HeapObject.h"

namespace swift {

#ifdef __APPLE__

// On OS X and iOS, swift_once_t matches dispatch_once_t.
typedef long swift_once_t;

#else

// On other platforms swift_once_t is pointer-sized.
typedef void *swift_once_t;

#endif

/// Runs the given function with the given context argument exactly once.
/// The predicate argument must point to a global or static variable of static
/// extent of type swift_once_t.
extern "C"
void swift_once(swift_once_t *predicate, void (*fn)(HeapObject *ctx),
                HeapObject *ctx);

}

#endif

Change swift_once_t to be actually pointer-sized on non-Darwin

Swift SVN r22384


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

int main() {
  int x = 42;
  printf("&x = %p\n", &x); // doesn't invalidate x despite taking address
  assert(x == 42);
  return 0;
}

Add test where printf shouldn't invalidate pointer argument


// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s
#include <stdint.h>

#define ldrex_func(p, rl, rh) \
  __asm__ __volatile__( \
		       "ldrexd%[_rl], %[_rh], [%[_p]]" \
		       : [_rl] "=&r" (rl), [_rh] "=&r" (rh) \
		       : [_p] "p" (p) : "memory")

int64_t foo(int64_t v, volatile int64_t *p)
{
  register uint32_t rl asm("r1");
  register uint32_t rh asm("r2");

  int64_t r;
  uint32_t t;

  __asm__ __volatile__(							\
		       "ldrexd%[_rl], %[_rh], [%[_p]]"			\
		       : [_rl] "=&r" (rl), [_rh] "=&r" (rh)		\
		       : [_p] "p" (p) : "memory");

  // CHECK: %0 = call %0 asm sideeffect "ldrexd$0, $1, [$2]", "={r1},={r2},r,~{memory}"(i64* %tmp)

  return r;
}

// RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s
#include <stdint.h>

#define ldrex_func(p, rl, rh) \
  __asm__ __volatile__( \
		       "ldrexd%[_rl], %[_rh], [%[_p]]" \
		       : [_rl] "=&r" (rl), [_rh] "=&r" (rh) \
		       : [_p] "p" (p) : "memory")

int64_t foo(int64_t v, volatile int64_t *p)
{
  register uint32_t rl asm("r1");
  register uint32_t rh asm("r2");

  int64_t r;
  uint32_t t;

  __asm__ __volatile__(							\
		       "ldrexd%[_rl], %[_rh], [%[_p]]"			\
		       : [_rl] "=&r" (rl), [_rh] "=&r" (rh)		\
		       : [_p] "p" (p) : "memory");

  // CHECK: %0 = call %0 asm sideeffect "ldrexd$0, $1, [$2]", "={r1},={r2},r,~{memory}"(i64*

  return r;
}

Make this test suitable for optimized builds by avoiding the name.

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


//
//  KRCloudSyncBlocks.h
//  CloudSync
//
//  Created by allting on 12. 10. 19..
//  Copyright (c) 2012년 allting. All rights reserved.
//

#ifndef CloudSync_KRCloudSyncBlocks_h
#define CloudSync_KRCloudSyncBlocks_h

@class KRSyncItem;

typedef void (^KRCloudSyncStartBlock)(NSArray* syncItems);
typedef void (^KRCloudSyncProgressBlock)(KRSyncItem* synItem, float progress);
typedef void (^KRCloudSyncCompletedBlock)(NSArray* syncItems, NSError* error);

typedef void (^KRCloudSyncResultBlock)(BOOL succeeded, NSError* error);

typedef void (^KRCloudSyncPublishingURLBlock)(NSURL* url, BOOL succeeded, NSError* error);

typedef void (^KRResourcesCompletedBlock)(NSArray* resources, NSError* error);

typedef void (^KRServiceAvailableBlock)(BOOL available);
typedef void (^KRiCloudRemoveFileBlock)(BOOL succeeded, NSError* error);

#endif

//
//  KRCloudSyncBlocks.h
//  CloudSync
//
//  Created by allting on 12. 10. 19..
//  Copyright (c) 2012년 allting. All rights reserved.
//

#ifndef CloudSync_KRCloudSyncBlocks_h
#define CloudSync_KRCloudSyncBlocks_h

@class KRSyncItem;

typedef void (^KRCloudSyncStartBlock)(NSArray* syncItems);
typedef void (^KRCloudSyncProgressBlock)(KRSyncItem* synItem, CGFloat progress);
typedef void (^KRCloudSyncCompletedBlock)(NSArray* syncItems, NSError* error);

typedef void (^KRCloudSyncResultBlock)(BOOL succeeded, NSError* error);

typedef void (^KRCloudSyncPublishingURLBlock)(NSURL* url, BOOL succeeded, NSError* error);

typedef void (^KRResourcesCompletedBlock)(NSArray* resources, NSError* error);

typedef void (^KRServiceAvailableBlock)(BOOL available);
typedef void (^KRiCloudRemoveFileBlock)(BOOL succeeded, NSError* error);

#endif

Support amd64. Release 2.3.5. Replace crittercism sdk.(ver 4.3.7)


#ifndef PLUGIN_H_
#define PLUGIN_H_

#include <windows.h>

#define EXPORT_CALLING __stdcall
#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 <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

Switch to __cdecl till we get --kill-at to work

With this build, 32-bit windows DLL loads and checks out, but we really
want to use __stdcall for the DLL entry points.


#ifndef _COMMON_H
#define _COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#ifdef _LINUX
#include <bsd/string.h>
#endif

#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlsave.h>
#include <libxml/encoding.h>
#include <libxml/xmlstring.h>

#include <openssl/bio.h>
#include <openssl/evp.h>

#ifndef _READLINE
#include <histedit.h>
#else
#include <readline/readline.h>
#include <readline/history.h>
#endif

#define	NAME	"kc"
#define	VERSION	"2.2.0"
#define	USAGE	"[-k database file] [-r] [-p password file] [-m cipher mode] [-b] [-v] [-h]"

#define	PASSWORD_MAXLEN	64

enum {
	KC_GENERATE_IV = 1,
	KC_GENERATE_SALT = 1 << 1,
	KC_GENERATE_KEY = 1 << 2
};

#ifndef _READLINE
const char	*el_prompt_null(void);
#endif
const char	*prompt_str(void);
int		malloc_check(void *);
void		version(void);
void		quit(int);

#endif

#ifndef _COMMON_H
#define _COMMON_H

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#ifdef _LINUX
#include <bsd/string.h>
#endif

#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlsave.h>
#include <libxml/encoding.h>
#include <libxml/xmlstring.h>

#include <openssl/bio.h>
#include <openssl/evp.h>

#ifndef _READLINE
#include <histedit.h>
#else
#include <readline/readline.h>
#include <readline/history.h>
#endif

#define	NAME	"kc"
#define	VERSION	"2.2.0rc2"
#define	USAGE	"[-k database file] [-r] [-p password file] [-m cipher mode] [-b] [-v] [-h]"

#define	PASSWORD_MAXLEN	64

enum {
	KC_GENERATE_IV = 1,
	KC_GENERATE_SALT = 1 << 1,
	KC_GENERATE_KEY = 1 << 2
};

#ifndef _READLINE
const char	*el_prompt_null(void);
#endif
const char	*prompt_str(void);
int		malloc_check(void *);
void		version(void);
void		quit(int);

#endif

Call this version what it is. Missed in earlier.


#ifndef PICAM_CONFIG_H
#define PICAM_CONFIG_H

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

// Even if we specify 30 FPS, Raspberry Pi Camera provides slighly lower FPS.
#define TARGET_FPS 30
#define GOP_SIZE TARGET_FPS

#define H264_BIT_RATE 3000 * 1000  // 3 Mbps

// 1600x900 is the upper limit if you don't use tunnel from camera to video_encode.
// 720p (1280x720) is good enough for most cases.
#define WIDTH 1280
#define HEIGHT 720

// Choose the value that results in non-repeating decimal when divided by 90000.
// e.g. 48000 and 32000 are fine, but 44100 and 22050 are bad.
#define AUDIO_SAMPLE_RATE 48000

#define AAC_BIT_RATE 40000  // 40 kbps

// Set this value to 1 if you want to produce audio-only stream for debugging.
#define AUDIO_ONLY 0

#if defined(__cplusplus)
}
#endif

#endif

#ifndef PICAM_CONFIG_H
#define PICAM_CONFIG_H

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

// 1600x900 is the upper limit if you don't use tunnel from camera to video_encode.
// 720p (1280x720) is good enough for most cases.
#define WIDTH 1280
#define HEIGHT 720

// Even if we specify 30 FPS, Raspberry Pi Camera provides slighly lower FPS.
#define TARGET_FPS 30

// Distance between two key frames
#define GOP_SIZE TARGET_FPS

#define H264_BIT_RATE 2000 * 1000  // 2 Mbps

// Choose the value that results in non-repeating decimal when divided by 90000.
// e.g. 48000 and 32000 are fine, but 44100 and 22050 are bad.
#define AUDIO_SAMPLE_RATE 48000

#define AAC_BIT_RATE 40000  // 40 Kbps

// Set this value to 1 if you want to produce audio-only stream for debugging.
#define AUDIO_ONLY 0

#if defined(__cplusplus)
}
#endif

#endif

Change video bitrate to 2 Mbps

Change video bitrate to 2 Mbps


/*
 *  Copyright (c) 2014, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in
 *  the LICENSE file in the root directory of this source tree. An
 *  additional grant of patent rights can be found in the PATENTS file
 *  in the same directory.
 *
 */
#pragma once
#include <stddef.h>
size_t argv_count(const char* const* argv);

const char** argv_concat(const char* const* argv1, ...);
const char** argv_concat_deepcopy(const char* const* argv1, ...);
extern const char* const empty_argv[];

#define ARGV(...) ((const char*[]){__VA_ARGS__ , NULL})
#define ARGV_CONCAT(...) argv_concat(__VA_ARGS__ , NULL)

Add ARGV and ARGV_CONCAT macros

Add ARGV and ARGV_CONCAT macros


// Copyright 2016, Jeffrey E. Bedard

#include "xstatus.h"
#include "config.h"

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

static const char * helptext =
"DESCRIPTION:  Simple X toolbar for minimalistic"
" window managers.\n"
"USAGE: xstatus [-d DELAY][-f FILE][-h]\n"
"\t-d DELAY     Set delay between status updates,"
" in seconds.\n"
"\t-f FILE      Set FILE to be continuously polled and"
" displayed.\n"
"\t-h           Print this usage information.  \n"
"Copyright 2016, Jeffrey E. Bedard <jefbed@gmail.com>\n"
"Project page:  https://github.com/jefbed/xstatus\n";

int main(int argc, char ** argv)
{
	char *filename=DEFAULTF;
	uint8_t delay=1;
	int opt;
	while((opt = getopt(argc, argv, "d:f:h")) != -1) {
		switch(opt) {
		case 'd':
			delay=atoi(optarg);
			break;
		case 'f':
			filename=optarg;
			break;
		case 'h':
		default:
			fprintf(stdout, "%s", helptext);
			exit(0);
		}
	}
	run_xstatus(filename, delay);
}

// Copyright 2016, Jeffrey E. Bedard

#include "xstatus.h"
#include "config.h"

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

static const char helptext[] =
"DESCRIPTION:  Simple X toolbar for minimalistic"
" window managers.\n"
"USAGE: xstatus [-d DELAY][-f FILE][-h]\n"
"\t-d DELAY     Set delay between status updates,"
" in seconds.\n"
"\t-f FILE      Set FILE to be continuously polled and"
" displayed.\n"
"\t-h           Print this usage information.  \n"
"Copyright 2016, Jeffrey E. Bedard <jefbed@gmail.com>\n"
"Project page:  https://github.com/jefbed/xstatus\n";

int main(int argc, char ** argv)
{
	char *filename=DEFAULTF;
	uint8_t delay=1;
	int opt;
	while((opt = getopt(argc, argv, "d:f:h")) != -1) {
		switch(opt) {
		case 'd':
			delay=atoi(optarg);
			break;
		case 'f':
			filename=optarg;
			break;
		case 'h':
		default:
			write(2, helptext, sizeof(helptext));
			exit(0);
		}
	}
	run_xstatus(filename, delay);
}

Use write(2) to display helptext.

Use write(2) to display helptext.


//
//  SDLMacros.h
//  SmartDeviceLink-iOS
//
//  Created by Muller, Alexander (A.) on 10/17/16.
//  Copyright © 2016 smartdevicelink. All rights reserved.
//

#ifndef SDLMacros_h
#define SDLMacros_h

// Resolves issue of pre-xcode 8 versions due to NS_STRING_ENUM unavailability.
#ifndef SDL_SWIFT_ENUM
    #if __has_attribute(NS_STRING_ENUM)
        #define SDL_SWIFT_ENUM NS_STRING_ENUM
    #else
        #define SDL_SWIFT_ENUM
    #endif
#endif

#endif /* SDLMacros_h */

//
//  SDLMacros.h
//  SmartDeviceLink-iOS
//
//  Created by Muller, Alexander (A.) on 10/17/16.
//  Copyright © 2016 smartdevicelink. All rights reserved.
//

#ifndef SDLMacros_h
#define SDLMacros_h

// Resolves issue of pre-xcode 8 versions due to NS_STRING_ENUM unavailability.
#ifndef SDL_SWIFT_ENUM
    #if __has_attribute(swift_wrapper)
        #define SDL_SWIFT_ENUM NS_STRING_ENUM
    #else
        #define SDL_SWIFT_ENUM
    #endif
#endif

#endif /* SDLMacros_h */

Revert "Changed macro to look specifically for NS_STRING_ENUM"

This reverts commit de01a9f7b3ed63f683604d3595568bacf5f54a5e.


typedef struct
{
	uint8_t Length; //Length of frame, if it's equal to 0, frame is not ready
	uint8_t *Frame; //Response frame content
} MODBUSResponseStatus; //Type containing information about frame that is set up at slave side

typedef struct
{
	uint8_t Address;
	uint16_t *Registers;
	uint16_t RegisterCount;
	MODBUSResponseStatus Response;
} MODBUSSlaveStatus; //Type containing slave device configuration data

Move types declarations to new file

Move types declarations to new file


#pragma once

#include "address.h"
#include "options.h"
#include "cartridge/cartridge.h"

#include <vector>
#include <memory>

class Video;
class CPU;
class Serial;
class Input;
class Timer;

class MMU {
public:
    MMU(std::shared_ptr<Cartridge> inCartridge, CPU& inCPU, Video& inVideo, Input& input, Serial& serial, Timer& timer, Options& options);

    auto read(const Address& address) const -> u8;
    void write(const Address& address, u8 byte);

private:
    auto boot_rom_active() const -> bool;

    auto read_io(const Address& address) const -> u8;
    void write_io(const Address& address, u8 byte);

    auto memory_read(const Address& address) const -> u8;
    void memory_write(const Address& address, u8 byte);

    void dma_transfer(const u8 byte);

    std::shared_ptr<Cartridge> cartridge;
    CPU& cpu;
    Video& video;
    Input& input;
    Serial& serial;
    Timer& timer;
    Options& options;

    std::vector<u8> memory;

    friend class Debugger;
};

#pragma once

#include "address.h"
#include "options.h"
#include "cartridge/cartridge.h"

#include <vector>
#include <memory>

class Video;
class CPU;
class Serial;
class Input;
class Timer;

class MMU {
public:
    MMU(std::shared_ptr<Cartridge> inCartridge, CPU& inCPU, Video& inVideo, Input& input, Serial& serial, Timer& timer, Options& options);

    auto read(const Address& address) const -> u8;
    void write(const Address& address, u8 byte);

private:
    auto boot_rom_active() const -> bool;

    auto read_io(const Address& address) const -> u8;
    void write_io(const Address& address, u8 byte);

    auto memory_read(const Address& address) const -> u8;
    void memory_write(const Address& address, u8 byte);

    void dma_transfer(u8 byte);

    std::shared_ptr<Cartridge> cartridge;
    CPU& cpu;
    Video& video;
    Input& input;
    Serial& serial;
    Timer& timer;
    Options& options;

    std::vector<u8> memory;

    friend class Debugger;
};

Remove unnecessary const qualifier in function declaration


// Copyright 2016 ELIFE. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
#pragma once

#include <inform/dist.h>
#include <inform/entropy.h>
#include <inform/state_encoding.h>

#include <inform/active_info.h>
#include <inform/entropy_rate.h>
#include <inform/transfer_entropy.h>

// Copyright 2016 ELIFE. All rights reserved.
// Use of this source code is governed by a MIT
// license that can be found in the LICENSE file.
#pragma once

#include <inform/dist.h>
#include <inform/shannon.h>
#include <inform/state_encoding.h>

#include <inform/active_info.h>
#include <inform/entropy_rate.h>
#include <inform/transfer_entropy.h>

Include shannon.h instead of entropy.h

Include shannon.h instead of entropy.h


/*
 * Copyright (c) 2020, NXP
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_

#define MCUX_FLEXCOMM0_CLK		0
#define MCUX_FLEXCOMM1_CLK		1
#define MCUX_FLEXCOMM2_CLK		2
#define MCUX_FLEXCOMM3_CLK		3
#define MCUX_FLEXCOMM4_CLK		4
#define MCUX_FLEXCOMM5_CLK		5
#define MCUX_FLEXCOMM6_CLK		6
#define MCUX_FLEXCOMM7_CLK		7
#define MCUX_HS_SPI_CLK		8

#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_MCUX_LPC_SYSCON_H_ */

Add NXP LPC clock control driver

include: Add NXP LPC clock control driver

DTS bindings file for NXP LPC clock control driver that
uses the MCUX SDK drivers

Signed-off-by: Mahesh Mahadevan <7f315ec3481825d543f8bec256ad86a4adc9dd8a@nxp.com>


//
//  RandomnessDelegate.h
//  jdemon
//
//  Created by Mark Larus on 3/19/13.
//  Copyright (c) 2013 Kenyon College. All rights reserved.
//

#ifndef __jdemon__RandomnessDelegate__
#define __jdemon__RandomnessDelegate__

#include <gsl/gsl_rng.h>
#include <stdexcept>

namespace Randomness {
    class Delegate {
    protected:
        Delegate() {}
    public:
        virtual bool binaryEventWithProbability(double probabilityOfHappening) = 0;
        virtual int randomIntegerFromInclusiveRange(int begin, int end) = 0;
    };

    class GSLDelegate : public Delegate {
        gsl_rng *RNG;
    public:
        bool binaryEventWithProbability( double probabilityOfHappening ) {
            return gsl_rng_get(RNG) < probabilityOfHappening ? 1 : 0;
        };
        int randomIntegerFromInclusiveRange(int begin, int end) {
            if (end<begin) {
                throw std::runtime_error("Invalid RNG range. 'begin' must be less than 'end'");
            }
            return (int)gsl_rng_uniform_int(RNG, end-begin) + begin;
        }
        GSLDelegate(gsl_rng *r) : RNG(r) {}
    };
}

#endif /* defined(__jdemon__RandomnessDelegate__) */

//
//  RandomnessDelegate.h
//  jdemon
//
//  Created by Mark Larus on 3/19/13.
//  Copyright (c) 2013 Kenyon College. All rights reserved.
//

#ifndef __jdemon__RandomnessDelegate__
#define __jdemon__RandomnessDelegate__

#include <gsl/gsl_rng.h>
#include <stdexcept>

namespace Randomness {
    class Delegate {
    protected:
        Delegate() {}
    public:
        virtual bool binaryEventWithProbability(double probabilityOfHappening) = 0;
        virtual int randomIntegerFromInclusiveRange(int begin, int end) = 0;
    };

    class GSLDelegate : public Delegate {
        gsl_rng *RNG;
    public:
        bool binaryEventWithProbability( double probabilityOfHappening ) {
            return gsl_rng_uniform(RNG) < probabilityOfHappening ? 1 : 0;
        };
        int randomIntegerFromInclusiveRange(int begin, int end) {
            if (end<begin) {
                throw std::runtime_error("Invalid RNG range. 'begin' must be less than 'end'");
            }
            return (int)gsl_rng_uniform_int(RNG, end-begin) + begin;
        }
        GSLDelegate(gsl_rng *r) : RNG(r) {}
    };
}

#endif /* defined(__jdemon__RandomnessDelegate__) */

Use gsl_rng_uniform instead of gsl_rng_get


// RUN: %clang_cfi -lm -o %t1 %s
// RUN: %t1 c 1 2>&1 | FileCheck --check-prefix=CFI %s
// RUN: %t1 s 2 2>&1 | FileCheck --check-prefix=CFI %s

// This test uses jump tables containing PC-relative references to external
// symbols, which the Mach-O object writer does not currently support.
// XFAIL: darwin

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

int main(int argc, char **argv) {
  // CFI: 1
  fprintf(stderr, "1\n");

  double (*fn)(double);
  if (argv[1][0] == 's')
    fn = sin;
  else
    fn = cos;

  fn(atof(argv[2]));

  // CFI: 2
  fprintf(stderr, "2\n");
}

// RUN: %clang_cfi -lm -o %t1 %s
// RUN: %t1 c 1 2>&1 | FileCheck --check-prefix=CFI %s
// RUN: %t1 s 2 2>&1 | FileCheck --check-prefix=CFI %s

// This test uses jump tables containing PC-relative references to external
// symbols, which the Mach-O object writer does not currently support.
// The test passes on i386 Darwin and fails on x86_64, hence unsupported instead of xfail.
// UNSUPPORTED: darwin

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

int main(int argc, char **argv) {
  // CFI: 1
  fprintf(stderr, "1\n");

  double (*fn)(double);
  if (argv[1][0] == 's')
    fn = sin;
  else
    fn = cos;

  fn(atof(argv[2]));

  // CFI: 2
  fprintf(stderr, "2\n");
}

Mark a test as unsupported on darwin.

[cfi] Mark a test as unsupported on darwin.

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


#include <argparse.h>
#include <stdio.h>

int main(int argc, char **argv) {
    args *args = args_new();

    args_add_option(args, option_new("f", "feature", "description of feature"));
    args_help(args, stdout);

    args_free(args);
}

Add example for help output

Add example for help output


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

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

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

  // Legacy flags
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Staging flags
  #define SK_LEGACY_PATH_ARCTO_ENDPOINT

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

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

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

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

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

  // Legacy flags
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Staging flags
  #define SK_LEGACY_PATH_ARCTO_ENDPOINT

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

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

Add flags to stage Skia API changes

Add flags to stage Skia API changes

Test: make

Bug: 178700363
Change-Id: I5d214f8fd69f7419f8b98f61a6e2f26f08587ff7


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

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

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

  // Legacy flags
  #define SK_IGNORE_GPU_DITHER
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Staging flags
  #define SK_LEGACY_PATH_ARCTO_ENDPOINT

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

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

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

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

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

  // Legacy flags
  #define SK_IGNORE_GPU_DITHER
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Staging flags
  #define SK_LEGACY_PATH_ARCTO_ENDPOINT
  #define SK_SUPPORT_LEGACY_PAINT_QUALITY_APIS

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

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

Add flag to stage api change

Add flag to stage api change

Related skia cl: https://skia-review.googlesource.com/c/skia/+/358736

Test: make

Change-Id: Ic02219b27117280addfd083481a1ae2440584d65


#ifndef GPIOLIB_H
#define GPIOLIB_H

#define FORWARD 1
#define BACKWARD 0

namespace GPIO
{
	int init();

	//direction is either FORWARD or BACKWARD. speed can be an integer ranging from 0 to 100.
	int controlLeft(int direction,int speed);
	int controlRight(int direction,int speed);
	int stopLeft();
	int stopRight();

	int resetCounter();
	void getCounter(int *countLeft,int *countRight);
	//angle is available in the range of -90 to 90.
	int turnTo(int angle);

	void delay(int milliseconds);
}
#endif

#ifndef GPIOLIB_H
#define GPIOLIB_H

#define FORWARD 1
#define BACKWARD 0

namespace GPIO
{
	int init();

	int controlLeft(int direction,int speed);
	int controlRight(int direction,int speed);
	int stopLeft();
	int stopRight();

	int resetCounter();
	void getCounter(int *countLeft,int *countRight);
	int turnTo(int angle);

	void delay(int milliseconds);
}
#endif

Remove texts for unserstanding to Wiki pages


/* $Id: wUuid.h,v 1.1.2.2 2012/03/20 11:15:17 emmapollock Exp $
 *
 * OpenMAMA: The open middleware agnostic messaging API
 * Copyright (C) 2011 NYSE Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */
#ifndef WUUID_H__
#define WUUID_H__

#include "wombat/port.h"

typedef int wUuid;

COMMONExpDLL
void wUuid_generate_time (wUuid myUuid);

COMMONExpDLL
void wUuid_unparse (wUuid myUuid, char* out);

#endif /* WUUID_H__ */

/* $Id: wUuid.h,v 1.1.2.2 2012/03/20 11:15:17 emmapollock Exp $
 *
 * OpenMAMA: The open middleware agnostic messaging API
 * Copyright (C) 2011 NYSE Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */
#ifndef WUUID_H__
#define WUUID_H__

#include "wombat/port.h"

typedef char* wUuid;

COMMONExpDLL
void wUuid_generate_time (wUuid myUuid);

COMMONExpDLL
void wUuid_unparse (wUuid myUuid, char* out);

#endif /* WUUID_H__ */

[common] Change uuid to char* from int for Windows


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

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

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

  // Legacy flags
  #define SK_IGNORE_GPU_DITHER
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

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

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

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

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

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

  // Legacy flags
  #define SK_IGNORE_GPU_DITHER
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

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

  #define SK_DISABLE_DAA  // skbug.com/6886

  // b/145995037
  #define SK_LEGACY_WEBP_LOOP_COUNT

#endif // SkUserConfigManual_DEFINED

Maintain the legacy behavior for WebP loop count

Bug: 145995037
Test: No change in behavior; no new tests

https://skia-review.googlesource.com/c/skia/+/259161 updates Skia to
report the proper number of repetitions for a WebP file. This build flag
ensures that we stick with the existing behavior until we're ready to
switch.

Change-Id: Ib70615e9d7655264badcd5c63a54d2813c86bc32


#define _SLAVEREGISTERS

#include <inttypes.h>

//Functions needed from other modules
extern void MODBUSBuildException( uint8_t, uint8_t );

//Functions for parsing requests
extern void MODBUSParseRequest03( union MODBUSParser *Parser );
extern void MODBUSParseRequest06( union MODBUSParser *Parser );
extern void MODBUSParseRequest16( union MODBUSParser *Parser );

//Functions for building responses
extern void MODBUSBuildResponse03( union MODBUSParser *Parser );
extern void MODBUSBuildResponse06( union MODBUSParser *Parser );
extern void MODBUSBuildResponse16( union MODBUSParser *Parser );

Add prototypes of response-building functions


/*************************************************
* Configuration Handling Header File             *
* (C) 1999-2007 Jack Lloyd                       *
*************************************************/

#ifndef BOTAN_POLICY_CONF_H__
#define BOTAN_POLICY_CONF_H__

#include <botan/mutex.h>
#include <string>
#include <vector>
#include <map>

namespace Botan {

/*************************************************
* Library Configuration Settings                 *
*************************************************/
class BOTAN_DLL Config
   {
   public:
      Config();
      ~Config();

      void load_defaults();

      std::string get(const std::string&, const std::string&) const;
      bool is_set(const std::string&, const std::string&) const;
      void set(const std::string&, const std::string&,
               const std::string&, bool = true);

      std::string option(const std::string&) const;
      u32bit option_as_time(const std::string&) const;

      void set_option(const std::string, const std::string&);

      void add_alias(const std::string&, const std::string&);
      std::string deref_alias(const std::string&) const;

      void load_inifile(const std::string&);
   private:
      Config(const Config&) {}
      Config& operator=(const Config&) { return (*this); }

      std::map<std::string, std::string> settings;
      Mutex* mutex;
   };

/*************************************************
* Hook for the global config                     *
*************************************************/
BOTAN_DLL Config& global_config();

}

#endif

/*************************************************
* Configuration Handling Header File             *
* (C) 1999-2008 Jack Lloyd                       *
*************************************************/

#ifndef BOTAN_POLICY_CONF_H__
#define BOTAN_POLICY_CONF_H__

#include <botan/mutex.h>
#include <string>
#include <map>

namespace Botan {

/*************************************************
* Library Configuration Settings                 *
*************************************************/
class BOTAN_DLL Config
   {
   public:
      Config();
      ~Config();

      void load_defaults();

      std::string get(const std::string&, const std::string&) const;
      bool is_set(const std::string&, const std::string&) const;
      void set(const std::string&, const std::string&,
               const std::string&, bool = true);

      std::string option(const std::string&) const;
      u32bit option_as_time(const std::string&) const;

      void set_option(const std::string, const std::string&);

      void add_alias(const std::string&, const std::string&);
      std::string deref_alias(const std::string&) const;

      void load_inifile(const std::string&);
   private:
      Config(const Config&) {}
      Config& operator=(const Config&) { return (*this); }

      std::map<std::string, std::string> settings;
      Mutex* mutex;
   };

/*************************************************
* Hook for the global config                     *
*************************************************/
BOTAN_DLL Config& global_config();

}

#endif

Remove unused include of <vector>

Remove unused include of <vector>


#include "modlib.h"

uint16_t MODBUSSwapEndian( uint16_t Data )
{
    //Change big-endian to little-endian and vice versa

    unsigned char Swap;

	//Create 2 bytes long union
    union Conversion
    {
        uint16_t Data;
        unsigned char Bytes[2];
    } Conversion;

	//Swap bytes
    Conversion.Data = Data;
    Swap = Conversion.Bytes[0];
    Conversion.Bytes[0] = Conversion.Bytes[1];
    Conversion.Bytes[1] = Swap;

    return Conversion.Data;
}

uint16_t CRC16( uint16_t *Data, uint16_t Length )
{
	//Calculate CRC16 checksum using given data and length

	uint16_t CRC = 0xFFFF;
	uint16_t i;
	unsigned char j;

	for ( i = 0; i < Length; i++ )
	{
		CRC ^= Data[i]; //XOR current data byte with CRC value

		for ( j = 8; j != 0; j-- )
		{
			//For each bit
			//Is least-significant-bit is set?
    		if ( ( CRC & 0x0001 ) != 0 )
			{
    			CRC >>= 1; //Shift to right and xor
    			CRC ^= 0xA001;
    		}
    		else                            // Else LSB is not set
    			CRC >>= 1;
		}
	}
	return CRC;
}

Add CRC16 checksum calculation function

Add CRC16 checksum calculation function


#ifndef _INC_UTILS_H
#define _INC_UTILS_H

#include "basetypes.h"

void *advancePtr(void *vp, SizeType len) {
    return (void*)((unsigned char *)(vp) + len);
}

const void *advancePtr(const void *vp, SizeType len) {
    return (void*)((unsigned char *)(vp) + len);
}

#endif//_INC_UTILS_H

#ifndef _INC_UTILS_H
#define _INC_UTILS_H

#include "basetypes.h"

inline void *advancePtr(void *vp, SizeType len) {
    return (void*)((unsigned char *)(vp) + len);
}

inline const void *advancePtr(const void *vp, SizeType len) {
    return (void*)((unsigned char *)(vp) + len);
}

#endif//_INC_UTILS_H

Fix header methods to be inline

Fix header methods to be inline


// RUN: %ucc -Xprint %s 2>/dev/null | grep 'typeof' | %output_check -w "/typeof\(int \*\) ip.*/" "/typeof\(int \*\) \*a1.*/" "/typeof\(int \*\) a2\[2\].*/" "/typeof\(int \*\) a3\(\).*/" "typeof(expr: identifier) (aka 'long *') xyz()"

long *x;

__typeof(int *) ip;

__typeof(int *) *a1;
__typeof(int *) a2[2];
__typeof(int *) a3();

__typeof(x) xyz()
{
}

// RUN: %ucc -Xprint %s 2>/dev/null | grep 'typeof' | %output_check -w "/typeof\(int \*\) ip.*/" "/typeof\(int \*\) \*a1.*/" "/typeof\(int \*\) a2\[2\].*/" "/typeof\(int \*\) a3\(\).*/" "typeof(expr: identifier) (aka 'long *') abc()" "typeof(expr: identifier) (aka 'long *') xyz()"

long *x;

__typeof(int *) ip;

__typeof(int *) *a1;
__typeof(int *) a2[2];
__typeof(int *) a3();

auto abc() -> __typeof(x)
{
}

__typeof(x) xyz()
{
}

Add trailing return type to type printing test


/* Bernstein's hash */
int djb_hash(const char* str, int len, int hash) {

  while (len--) {
    hash = (hash * 33) ^ *str++;
  }

  return hash;
}

/* Bernstein's hash */
int djb_hash(const unsigned char* str, int len, int hash) {

  while (len--) {
    hash = (hash * 33) ^ *str++;
  }

  return hash;
}

Fix the handling of signedness, which caused a nasty bug


/* Bernstein's hash */
int hashByteString(const char* str, int len) {
  int hash = 0;

  while (len--) {
    hash = (hash * 33) ^ *str++;
  }

  return hash;
}

Document where our hash function comes from


/* libcopy -- journal support
 * (c) 2011 Michał Górny
 * 2-clause BSD-licensed
 */

#pragma once
#ifndef _ATOMIC_INSTALL_JOURNAL_H
#define _ATOMIC_INSTALL_JOURNAL_H

typedef struct ai_journal *journal_t;

int ai_journal_create(const char *journal_path, const char *location);

int ai_journal_open(const char *journal_path, journal_t *ret);
int ai_journal_close(journal_t j);

const char *ai_journal_get_files(journal_t j);

#endif /*_ATOMIC_INSTALL_COPY_H*/

/* libcopy -- journal support
 * (c) 2011 Michał Górny
 * 2-clause BSD-licensed
 */

#pragma once
#ifndef _ATOMIC_INSTALL_JOURNAL_H
#define _ATOMIC_INSTALL_JOURNAL_H

typedef struct ai_journal *journal_t;

int ai_journal_create(const char *journal_path, const char *location);

int ai_journal_open(const char *journal_path, journal_t *ret);
int ai_journal_close(journal_t j);

const char *ai_journal_get_files(journal_t j);

#endif /*_ATOMIC_INSTALL_JOURNAL_H*/

Fix comment in header guard.

Fix comment in header guard.


#include <openssl/aes.h>
#include <openssl/rand.h>
#include <stdio.h>
#include <string.h>

#include "crypt.h"

typedef unsigned char aes_t;

void generate_bytes(aes_t *buf) {
    if (!RAND_bytes(buf, sizeof(buf))) {
        fprintf(stderr, "[!] Could not generate key");
    }
}

aes_t *encrypt(char *plaintext, aes_t *key, aes_t *iv) {
    aes_t *ciphertext = (aes_t *) malloc(BUFFER_SIZE);
    AES_KEY wctx;
    AES_set_encrypt_key(key, KEY_SIZE * 8, &wctx);
    AES_cbc_encrypt((aes_t *)plaintext, ciphertext, sizeof(ciphertext), &wctx, iv, AES_ENCRYPT);
    memset(iv, 0x00, AES_BLOCK_SIZE);
    return ciphertext;
}

char *decrypt(aes_t *ciphertext, aes_t *key, aes_t *iv) {
    aes_t *plaintext = (aes_t *) malloc(BUFFER_SIZE);
    AES_KEY wctx;
    AES_set_decrypt_key(key, KEY_SIZE * 8, &wctx);
    AES_cbc_encrypt(ciphertext, plaintext, sizeof(plaintext), &wctx, iv, AES_DECRYPT);
    memset(iv, 0x00, AES_BLOCK_SIZE);
    return (char *) plaintext;
}

#include <openssl/aes.h>
#include <openssl/rand.h>
#include <stdio.h>
#include <string.h>

#include "crypt.h"

typedef unsigned char aes_t;

void generate_bytes(aes_t *buf) {
    if (!RAND_bytes(buf, sizeof(buf))) {
        fprintf(stderr, "[!] Could not generate key");
    }
}

aes_t *encrypt(char *plaintext, aes_t *key, aes_t *iv) {
    aes_t *ciphertext = (aes_t *) malloc(BUFFER_SIZE);
    AES_KEY wctx;
    AES_set_encrypt_key(key, KEY_SIZE * 8, &wctx);
    AES_cbc_encrypt((aes_t *)plaintext, ciphertext, strlen(plaintext), &wctx, iv, AES_ENCRYPT);
    memset(iv, 0x00, AES_BLOCK_SIZE);
    return ciphertext;
}

char *decrypt(aes_t *ciphertext, aes_t *key, aes_t *iv) {
    aes_t *plaintext = (aes_t *) malloc(BUFFER_SIZE);
    AES_KEY wctx;
    AES_set_decrypt_key(key, KEY_SIZE * 8, &wctx);
    AES_cbc_encrypt(ciphertext, plaintext, strlen((char *)ciphertext), &wctx, iv, AES_DECRYPT);
    memset(iv, 0x00, AES_BLOCK_SIZE);
    return (char *) plaintext;
}

Use strlen instead of sizeof

Use strlen instead of sizeof


#ifndef QFAPPSCRIPTDISPATCHERWRAPPER_H
#define QFAPPSCRIPTDISPATCHERWRAPPER_H

#include <QQuickItem>
#include <QPointer>
#include "qfappdispatcher.h"

class QFAppScriptDispatcherWrapper : public QQuickItem
{
    Q_OBJECT
public:
    QFAppScriptDispatcherWrapper();

    QString type() const;
    void setType(const QString &type);

    QFAppDispatcher *dispatcher() const;
    void setDispatcher(QFAppDispatcher *dispatcher);

public slots:
    void dispatch(QJSValue arguments);

private:
    QString m_type;
    QPointer<QFAppDispatcher> m_dispatcher;

};

#endif // QFAPPSCRIPTDISPATCHERWRAPPER_H

#ifndef QFAPPSCRIPTDISPATCHERWRAPPER_H
#define QFAPPSCRIPTDISPATCHERWRAPPER_H

#include <QQuickItem>
#include <QPointer>
#include "qfappdispatcher.h"

class QFAppScriptDispatcherWrapper : public QObject
{
    Q_OBJECT
public:
    QFAppScriptDispatcherWrapper();

    QString type() const;
    void setType(const QString &type);

    QFAppDispatcher *dispatcher() const;
    void setDispatcher(QFAppDispatcher *dispatcher);

public slots:
    void dispatch(QJSValue arguments);

private:
    QString m_type;
    QPointer<QFAppDispatcher> m_dispatcher;

};

#endif // QFAPPSCRIPTDISPATCHERWRAPPER_H

Change parent of QFAppScriptDispatcherWrapper from QQuickItem to QObject


int sum = 0;

void test_sum(){
    if(sum == 45)
        printf("Ok!\n");
    else
        printf("Wrong!\n");
    sum = 0;
}

int main(){
    int x;

    for(int x; x < 10; x++)
        sum += x;

    test_sum();

    for(x = 0; x < 10; x++)
        sum += x;

    test_sum();

    x = 0;
    for(;x < 10; x++)
        sum += x;

    test_sum();

    x = 0;
    for(;; x++){
        if( x >= 10) break;
        sum += x;
    }

    test_sum();

    x = 0;
    for(;;){
        if( x >= 10) break;
        sum += x;
        x++;
    }

    test_sum();

    x = 0;
    for(;x < 10;){
        sum += x;
        x++;
    }

    test_sum();

    sum = 0;

    for(int x = 0;;x++){
        if( x >= 10) break;
        sum += x;
    }

    test_sum();

    for(x = 0;;x++){
        if( x >= 10) break;
        sum += x;
    }

    test_sum();

    sum = 0;

    for(int x = 0;x < 10;){
        sum += x;
        x++;
    }

    test_sum();

    sum = 0;

    for(x = 0;x < 10;){
        sum += x;
        x++;
    }

    test_sum();

    for(int x;;){
        if( x >= 10) break;
        sum += x;
        x++;
    }

    test_sum();

    for(x = 0;;){
        if( x >= 10) break;
        sum += x;
        x++;
    }

    test_sum();

    return 0;
}

Add file testing all forms of for loop

Add file testing all forms of for loop


// REQUIRES: clang-driver
// REQUIRES: powerpc-registered-target
// REQUIRES: nvptx-registered-target

//
// Verify that CUDA device commands do not get OpenMP flags.
//
// RUN: %clang -no-canonical-prefixes -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \
// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
//
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:      clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:      -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ld" {{.*}}"-m" "elf64lppc"

// REQUIRES: clang-driver
// REQUIRES: powerpc-registered-target
// REQUIRES: nvptx-registered-target

//
// Verify that CUDA device commands do not get OpenMP flags.
//
// RUN: %clang -no-canonical-prefixes -### -x cuda -target powerpc64le-linux-gnu -std=c++11 --cuda-gpu-arch=sm_35 -fopenmp=libomp %s 2>&1 \
// RUN: | FileCheck %s --check-prefix NO-OPENMP-FLAGS-FOR-CUDA-DEVICE
//
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:      clang{{.*}}" "-cc1" "-triple" "nvptx64-nvidia-cuda"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NOT:  -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: ptxas" "-m64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: fatbinary" "--cuda" "-64"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux-gnu"
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE:      -fopenmp
// NO-OPENMP-FLAGS-FOR-CUDA-DEVICE-NEXT: {{ld(.exe)?"}} {{.*}}"-m" "elf64lppc"

Allow .exe extension to ld to fix test with mingw.

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


/*-
 * This file is in the public domain.
 */
/* $FreeBSD$ */

#include <i386/param.h>

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

#define MACHINE		"pc98"

#include <i386/param.h>

Switch MACHINE to "pc98" on FreeBSD/pc98.
Add copyright.

Approved by:	FreeBSD/pc98 development team.


/*
====================================================================
Copyright (c) 2008 Ian Blumel.  All rights reserved.

This software is licensed as described in the file LICENSE, which
you should have received as part of this distribution.
====================================================================
File: test_basic.c

Provides a dumping ground for basic tests of fct.
*/

#include "fct.h"

FCT_BGN()
{
}
FCT_END();

Add missing 'empty' test program.

Add missing 'empty' test program.


// RUN: clang -checker-simple -verify %s
// RUN: clang -checker-simple -analyzer-store-region -verify %s

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

typedef struct {
  int data;
} STYPE;

void g1(struct s* p);

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

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

void f2() {
  char *p = "/usr/local";
  char (*q)[4];
  q = &"abc";
}

void f3() {
  STYPE s;
}

void f4() {
  int a[] = { 1, 2, 3};
  int b[3] = { 1, 2 };
}

void f5() {
  struct s data;
  g1(&data);
}

void f6() {
  char *p;
  p = __builtin_alloca(10);
  p[1] = 'a';
}

struct s2;

void g2(struct s2 *p);

void f7() {
  struct s2 *p = __builtin_alloca(10);
  g2(p);
}

void f8() {
  int a[10];
  a[sizeof(a) - 1] = 1;
}

void f9() {
  struct s a[10];
}

Add test cast for struct array.

Add test cast for struct array.

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


#ifndef HELPER_H
#define HELPER_H

/*Helper function for calculating ABSOLUTE maximum of two floats
  Will return maximum absolute value (ignores sign) */
float helpFindMaxAbsFloat(float a, float b) {
	float aAbs = abs(a);
	float bAbs = abs(b);
	if (aAbs > bAbs) {
		return aAbs;
	} else {
		return bAbs;
	}
}

//Helper function for calculating ABSOLUTE minimum of two floats
//Will return minimum absolute value (ignores sign)
float helpFindMinAbsFloat(float a, float b) {
	float aAbs = abs(a);
	float bAbs = abs(b);
	if (aAbs < bAbs) {
		return aAbs;
	} else {
		return bAbs;
	}
}

//Returns sign of float
int helpFindSign(float x) {
	if (x > 0.0) {
		return 1;
	} else if (x < 0.0) {
		return -1;
	} else {
		return 0;
	}
}

int helpRoundFloat(float x) {
	if (x > 0) {
		return (int)(x+0.5);
	} else {
		return (int)(x-0.5);
	}
}

#endif

#ifndef HELPER_H
#define HELPER_H

/*Helper function for calculating ABSOLUTE maximum of two floats
  Will return maximum absolute value (ignores sign) */
float helpFindMaxAbsFloat(float a, float b) {
	float aAbs = abs(a);
	float bAbs = abs(b);
	if (aAbs > bAbs) {
		return aAbs;
	} else {
		return bAbs;
	}
}

//Helper function for calculating ABSOLUTE minimum of two floats
//Will return minimum absolute value (ignores sign)
float helpFindMinAbsFloat(float a, float b) {
	float aAbs = abs(a);
	float bAbs = abs(b);
	if (aAbs < bAbs) {
		return aAbs;
	} else {
		return bAbs;
	}
}

//Returns sign of int
int helpFindSign(int x) {
	if (x > 0.0) {
		return 1;
	} else if (x < 0.0) {
		return -1;
	} else {
		return 0;
	}
}

int helpRoundFloat(float x) {
	if (x > 0) {
		return (int)(x+0.5);
	} else {
		return (int)(x-0.5);
	}
}

#endif

Fix helpFindSign (floats don't have signs....)


#include <stdio.h>

#define SWAP(x, y) {        \
        typeof (x) tmp = y; \
        y = x;              \
        x = tmp;            \
    }

int main() {
    int a = 1;
    int b = 2;
    SWAP(a, b);
    printf("a: %d, b: %d\n", a, b);

    return 0;
}

#include <stdio.h>

#define SWAP(x, y) {        \
        typeof (x) tmp = y; \
        y = x;              \
        x = tmp;            \
    }

int main() {
    int a = 1;
    int b = 2;
    SWAP(a, b);
    printf("a: %d, b: %d\n", a, b);

    float arr[2] = {3.0, 4.0};
    SWAP(arr[0], arr[1]);
    printf("arr[0]: %f, arr[1]: %f\n", arr[0], arr[1]);

    return 0;
}

Test we work with other, more complex types.


/**
 * Phase 01 - Get a Window that works and can be closed.
 *
 * This code won't be structured very well, just trying to get stuff working.
 */
#include <stdlib.h>

int main(int argc, char *argv[])
{
  return EXIT_SUCCESS;
}

/**
 * Phase 01 - Get a Window that works and can be closed.
 *
 * This code won't be structured very well, just trying to get stuff working.
 */
#include <stdlib.h>
#include <X11/Xlib.h>

int main(int argc, char *argv[])
{
  Display *dpy = XOpenDisplay(NULL);

  if (dpy == NULL) {
    return EXIT_FAILURE;
  }

  XCloseDisplay(dpy);
  dpy = NULL;

  return EXIT_SUCCESS;
}

Create the display, free it at the end, exit with failure if the display doesn't open


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

#ifndef DocFormats_DFTypes_h
#define DocFormats_DFTypes_h

#ifdef _MSC_VER
#define ATTRIBUTE_ALIGNED(n)
#define ATTRIBUTE_FORMAT(archetype,index,first)
#else
#define ATTRIBUTE_ALIGNED(n) __attribute__ ((aligned (n)))
#define ATTRIBUTE_FORMAT(archetype,index,first) __attribute__((format(archetype,index,first)))
#endif

#include <sys/types.h>
#include <stdint.h>
#include <stdarg.h>

#endif

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

#ifndef DocFormats_DFTypes_h
#define DocFormats_DFTypes_h

#ifdef _MSC_VER
#define ATTRIBUTE_ALIGNED(n)
#define ATTRIBUTE_FORMAT(archetype,index,first)
#else
#define ATTRIBUTE_ALIGNED(n) __attribute__ ((aligned (n)))
#define ATTRIBUTE_FORMAT(archetype,index,first) __attribute__((format(archetype,index,first)))
#endif

#ifdef WIN32
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <sys/types.h>
#include <stdint.h>
#include <stdarg.h>

#endif

Win32: Disable warnings about insecure functions

Set the _CRT_SECURE_NO_WARNINGS macro so that VC++ doesn't complain
about commonly-used functions like open and vsnprintf that it considers
"unsafe". The alternatives it suggests are not available on Unix-based
platforms, and they're used extensively throughout the codebase.


#ifndef TACHYON_TEST_UTILS_MOCK_QUEUE_H_
#define TACHYON_TEST_UTILS_MOCK_QUEUE_H_

#include "gmock/gmock.h"

#include "lib/queue_interface.h"

namespace tachyon {
namespace testing {

// Mock class for queues.
template <class T>
class MockQueue : public QueueInterface<T> {
 public:
  MOCK_METHOD1_T(Enqueue, bool(const T &item));
  MOCK_METHOD1_T(EnqueueBlocking, bool(const T &item));

  MOCK_METHOD1_T(DequeueNext, bool(T *item));
  MOCK_METHOD1_T(DequeueNextBlocking, void(T *item));

  MOCK_METHOD0_T(GetOffset, int());
  MOCK_METHOD0_T(FreeQueue, void());
};

}  // namespace testing
}  // namespace tachyon

#endif  // TACHYON_TEST_UTILS_MOCK_QUEUE_H_

#ifndef TACHYON_TEST_UTILS_MOCK_QUEUE_H_
#define TACHYON_TEST_UTILS_MOCK_QUEUE_H_

#include "gmock/gmock.h"

#include "lib/queue_interface.h"

namespace tachyon {
namespace testing {

// Mock class for queues.
template <class T>
class MockQueue : public QueueInterface<T> {
 public:
  MOCK_METHOD1_T(Enqueue, bool(const T &item));
  MOCK_METHOD1_T(EnqueueBlocking, bool(const T &item));

  MOCK_METHOD1_T(DequeueNext, bool(T *item));
  MOCK_METHOD1_T(DequeueNextBlocking, void(T *item));

  MOCK_CONST_METHOD0_T(GetOffset, int());
  MOCK_METHOD0_T(FreeQueue, void());
};

}  // namespace testing
}  // namespace tachyon

#endif  // TACHYON_TEST_UTILS_MOCK_QUEUE_H_

Fix issue with mock method.

Fix issue with mock method.


// RUN: %layout_check %s
// RUN: %check %s

struct A
{
}; // CHEKC: /warning: empty struct/

struct Containter
{
	struct A a;
};

struct Pre
{
	int i;
	struct A a;
	int j;
};

struct Pre p = { 1, /* warn */ 2 }; // CHECK: /warning: missing {} initialiser for empty struct/
struct Pre q = { 1, {}, 2 };

main()
{
	struct A a = { 5 }; // CHECK: /warning: missing {} initialiser for empty struct/
	struct A b = {};

	struct Containter c = {{}};

	c.a = (struct A){};
}

// RUN: %layout_check %s
// RUN: %check %s

struct A
{
}; // CHECK: /warning: empty struct/

struct Container
{
	struct A a;
};

struct Pre
{
	int i;
	struct A a;
	int j;
};

struct Pre p = { 1, /* warn */ 2 }; // CHECK: /warning: missing {} initialiser for empty struct/
struct Pre q = { 1, {}, 2 };

main()
{
	struct A a = { 5 }; // CHECK: /warning: missing {} initialiser for empty struct/
	struct A b = {};

	struct Container c = {{}};

	c.a = (struct A){};
}

Fix typo in empty struct test check

Fix typo in empty struct test check


#include "target-helpers/inline_wrapper_sw_helper.h"
#include "target-helpers/inline_debug_helper.h"
#include "state_tracker/drm_driver.h"
#include "i915/drm/i915_drm_public.h"
#include "i915/i915_public.h"

static struct pipe_screen *
create_screen(int fd)
{
   struct brw_winsys_screen *bws;
   struct pipe_screen *screen;

   bws = i915_drm_winsys_screen_create(fd);
   if (!bws)
      return NULL;

   screen = i915_screen_create(bws);
   if (!screen)
      return NULL;

   screen = debug_screen_wrap(screen);

   return screen;
}

PUBLIC
DRM_DRIVER_DESCRIPTOR("i915", "i915", create_screen)

Add missing egl pipe file

i915g: Add missing egl pipe file


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

#ifndef VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_
#define VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_

#include "verilog/tools/kythe/kythe_facts.h"
#include "verilog/tools/kythe/kythe_facts_extractor.h"

namespace verilog {
namespace kythe {

class KytheProtoOutput : public KytheOutput {
 public:
  KytheProtoOutput() = default;

  // Output all Kythe facts from the indexing data in proto format.
  void Emit(const KytheIndexingData& indexing_data);
};

}  // namespace kythe
}  // namespace verilog

#endif  // VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_

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

#ifndef VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_
#define VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_

#include "verilog/tools/kythe/kythe_facts.h"
#include "verilog/tools/kythe/kythe_facts_extractor.h"

namespace verilog {
namespace kythe {

class KytheProtoOutput : public KytheOutput {
 public:
  // Output all Kythe facts from the indexing data in proto format.
  void Emit(const KytheIndexingData& indexing_data);
};

}  // namespace kythe
}  // namespace verilog

#endif  // VERIBLE_VERILOG_TOOLS_KYTHE_KYTHE_PROTO_OUTPUT_H_

[kythe] Remove unnecessary default constructor from KytheProtoOutput


// Copyright 2016, Jeffrey E. Bedard
#include "temperature.h"
#include "config.h"
#include "font.h"
#include "util.h"
#include <stdio.h>
#include <string.h>
// Returns x offset for next item
uint16_t draw_temp(xcb_connection_t * xc, const uint16_t offset)
{
	const uint8_t v
		= xstatus_system_value(XSTATUS_SYSFILE_TEMPERATURE)/1000;
	uint8_t sz = 4;
	char buf[sz];
	const struct JBDim f = xstatus_get_font_size();
	sz = snprintf(buf, sz, "%dC", v);
	xcb_image_text_8(xc, sz, xstatus_get_window(xc),
		xstatus_get_gc(xc), offset + XSTATUS_CONST_WIDE_PAD, f.h, buf);
	return f.w * strlen(buf) + offset + XSTATUS_CONST_WIDE_PAD
		+ XSTATUS_CONST_PAD;
}

// Copyright 2016, Jeffrey E. Bedard
#include "temperature.h"
#include "config.h"
#include "font.h"
#include "util.h"
#include <stdio.h>
static uint16_t get_offset(const uint16_t fw, const uint16_t offset,
	const uint8_t len)
{
	return fw * len + offset + XSTATUS_CONST_WIDE_PAD
		+ XSTATUS_CONST_PAD;
}
// Returns x offset for next item
uint16_t draw_temp(xcb_connection_t * xc, const uint16_t offset)
{
	const uint8_t v
		= xstatus_system_value(XSTATUS_SYSFILE_TEMPERATURE)/1000;
	uint8_t sz = 4;
	char buf[sz];
	const struct JBDim f = xstatus_get_font_size();
	sz = snprintf(buf, sz, "%dC", v);
	xcb_image_text_8(xc, sz, xstatus_get_window(xc),
		xstatus_get_gc(xc), offset + XSTATUS_CONST_WIDE_PAD, f.h, buf);
	return get_offset(f.w, offset, sz);
}

Split out get_offset(). Eliminated unnecessary call to strlen().


//
//  CDZThingsHubErrorDomain.h
//  thingshub
//
//  Created by Chris Dzombak on 1/14/14.
//  Copyright (c) 2014 Chris Dzombak. All rights reserved.
//

#import "CDZThingsHubApplication.h"

extern NSString * const kThingsHubErrorDomain;

typedef NS_ENUM(NSInteger, CDZErrorCode) {
    CDZErrorCodeConfigurationValidationError = CDZThingsHubApplicationReturnCodeConfigError,
    CDZErrorCodeTestError = -1,
};

//
//  CDZThingsHubErrorDomain.h
//  thingshub
//
//  Created by Chris Dzombak on 1/14/14.
//  Copyright (c) 2014 Chris Dzombak. All rights reserved.
//

#import "CDZThingsHubApplication.h"

extern NSString * const kThingsHubErrorDomain;

typedef NS_ENUM(NSInteger, CDZErrorCode) {
    CDZErrorCodeTestError = 0,
    CDZErrorCodeAuthError = CDZThingsHubApplicationReturnCodeAuthError,
    CDZErrorCodeConfigurationValidationError = CDZThingsHubApplicationReturnCodeConfigError,
    CDZErrorCodeSyncFailure = CDZThingsHubApplicationReturnCodeSyncFailed,
};

Make error domain constants mirror app return codes


//
//  IRLSizePrivate.h
//  IRLSize
//
//  Created by Jeff Kelley on 6/29/16.
//  Copyright © 2016 Detroit Labs. All rights reserved.
//

#ifndef IRLSizePrivate_h
#define IRLSizePrivate_h

typedef float RawLengthMeasurement; // meters

typedef struct {
    RawLengthMeasurement width;
    RawLengthMeasurement height;
} RawSize;

#define RAW_SIZE_UNIT [NSUnitLength meters]

#endif /* IRLSizePrivate_h */

//
//  IRLSizePrivate.h
//  IRLSize
//
//  Created by Jeff Kelley on 6/29/16.
//  Copyright © 2016 Detroit Labs. All rights reserved.
//

#ifndef IRLSizePrivate_h
#define IRLSizePrivate_h

typedef float RawLengthMeasurement; // meters

typedef struct {
    RawLengthMeasurement width;
    RawLengthMeasurement height;
} RawSize;

#define RAW_SIZE_UNIT NSUnitLength.meters

#endif /* IRLSizePrivate_h */

Use the class property instead of getter method


#include <gdomdebug.h>
#include <glib/gprintf.h>

static gboolean debug_enabled = FALSE;

void
gdom_debug (char const *format, ...)
{
	va_list args;

	if (!debug_enabled)
		return;

	va_start (args, format);
	g_vprintf (format, args);
	g_printf ("\n");
	va_end (args);
}

void
gdom_debug_enable (void)
{
	debug_enabled = TRUE;
}

#include <gdomdebug.h>
#include <glib/gprintf.h>
#include <stdlib.h>

static gboolean debug_checked = FALSE;
static gboolean debug_enabled = FALSE;

static gboolean
_is_debug_enabled ()
{
	const char *debug_var;

	if (debug_checked)
		return debug_enabled;

	debug_var = g_getenv ("GMATHML_DEBUG");

	debug_enabled = debug_var != NULL ? atoi (debug_var) != 0 : FALSE;

	debug_checked = TRUE;

	return debug_enabled;
}

void
gdom_debug (char const *format, ...)
{
	va_list args;

	if (!_is_debug_enabled())
		return;

	va_start (args, format);
	g_vprintf (format, args);
	g_printf ("\n");
	va_end (args);
}

void
gdom_debug_enable (void)
{
	debug_enabled = TRUE;
	debug_checked = TRUE;
}

[debug] Allow debug messages using GMATHML_DEBUG environment variable.


/* libunwind - a platform-independent unwind library
   Copyright (C) 2004 Hewlett-Packard Co
	Contributed by David Mosberger-Tang <davidm@hpl.hp.com>

This file is part of libunwind.

Copyright (c) 2003 Hewlett-Packard Co.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */

#include <stdio.h>

#include <libunwind.h>

extern int verbose;

static void *funcs[] =
  {
    (void *) &unw_get_reg,
    (void *) &unw_get_fpreg,
    (void *) &unw_set_reg,
    (void *) &unw_set_fpreg,
    (void *) &unw_resume,
    (void *) &unw_create_addr_space,
    (void *) &unw_destroy_addr_space,
    (void *) &unw_get_accessors,
    (void *) &unw_flush_cache,
    (void *) &unw_set_caching_policy,
    (void *) &unw_regname,
    (void *) &unw_get_proc_info,
    (void *) &unw_get_save_loc,
    (void *) &unw_is_signal_frame,
    (void *) &unw_get_proc_name
  };

int
test_generic (void)
{
  unw_cursor_t c;

  if (verbose)
    printf (__FILE__": funcs[0]=%p\n", funcs[0]);

#ifndef UNW_REMOTE_ONLY
  {
    ucontext_t uc;

    unw_getcontext (&uc);
    unw_init_local (&c, &uc);
    unw_init_remote (&c, unw_local_addr_space, &uc);
  }
  return unw_step (&c);
#else
  return 0;
#endif
}

(test_generic): Clean it up so it compiles cleanly and works for
	REMOTE_ONLY case.

(Logical change 1.158)


#pragma once
#include <string>

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

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

#ifdef _MSC_VER
  #if _MSC_VER >= 1800
    #define SL_CALL __vectorcall
  #else
    #define SL_CALL __cdecl
  #endif
#else
#define SL_CALL
#endif

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

// For this to work, at least one .cpp file using this macro
// needs to be compiled on _every_ build, otherwise it is outdated.
#define SL_BUILD_DATE __DATE__ __TIME__

#pragma once
#include <string>

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

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

#ifdef _MSC_VER
  #if _MSC_VER >= 1800
    #define SL_CALL __vectorcall
  #else
    #define SL_CALL __cdecl
  #endif
#else
#define SL_CALL
#endif

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

// For this to work, at least one .cpp file using this macro
// needs to be compiled on _every_ build, otherwise it is outdated.
#define SL_BUILD_DATE __DATE__ " " __TIME__

Add space between date and time

Add space between date and time


#include "input.h"

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

void read_line(char *p)
{
    if (fgets(p, MAX_SIZE, stdin) == NULL){
        p[0] = '\0';
        return;
    }
    remove_space(p);
}

int is_exit(const char* p)
{
    const char* exit_words[] = {
        "exit",
        "quit",
    };
    int len = (int)(sizeof(exit_words) / sizeof(char*));
    int i;

    if (strlen(p) == 0){
        return (1);
    }
    for (i = 0; i < len; i++){
        if (strcmp(p, exit_words[i]) == 0){
            return (1);
        }
    }
    return (0);
}

void remove_space(char* p)
{
    int i, j;

    i = j = 0;
    while (p[i] != '\0'){
        while (isspace(p[j])){
            j++;
        }
        while (!isspace(p[j])){
            p[i] = p[j];
            if (p[i] == '\0'){
                break;
            }
            else {
                i++;
                j++;
            }
        }
    }
}

#include "input.h"

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

void read_line(char *p)
{
    if (fgets(p, MAX_SIZE, stdin) == NULL){
        p[0] = '\0';
        return;
    }
    remove_space(p);
}

int is_exit(const char* p)
{
    const char* exit_words[] = {
        "exit",
        "quit",
        "bye",
    };
    int len = (int)(sizeof(exit_words) / sizeof(char*));
    int i;

    if (strlen(p) == 0){
        return (1);
    }
    for (i = 0; i < len; i++){
        if (strcmp(p, exit_words[i]) == 0){
            return (1);
        }
    }
    return (0);
}

void remove_space(char* p)
{
    int i, j;

    i = j = 0;
    while (p[i] != '\0'){
        while (isspace(p[j])){
            j++;
        }
        while (!isspace(p[j])){
            p[i] = p[j];
            if (p[i] == '\0'){
                break;
            }
            else {
                i++;
                j++;
            }
        }
    }
}

Add bye to exit words

Add bye to exit words


/* Generator object interface */

#ifndef Py_LIMITED_API
#ifndef Py_GENOBJECT_H
#define Py_GENOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif

struct _frame; /* Avoid including frameobject.h */

typedef struct {
    PyObject_HEAD
    /* The gi_ prefix is intended to remind of generator-iterator. */

    /* Note: gi_frame can be NULL if the generator is "finished" */
    struct _frame *gi_frame;

    /* True if generator is being executed. */
    int gi_running;

    /* The code object backing the generator */
    PyObject *gi_code;

    /* List of weak reference. */
    PyObject *gi_weakreflist;
} PyGenObject;

PyAPI_DATA(PyTypeObject) PyGen_Type;

#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)

PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
PyAPI_FUNC(int) PyGen_FetchStopIterationValue(PyObject **);

#ifdef __cplusplus
}
#endif
#endif /* !Py_GENOBJECT_H */
#endif /* Py_LIMITED_API */

/* Generator object interface */

#ifndef Py_LIMITED_API
#ifndef Py_GENOBJECT_H
#define Py_GENOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif

struct _frame; /* Avoid including frameobject.h */

typedef struct {
    PyObject_HEAD
    /* The gi_ prefix is intended to remind of generator-iterator. */

    /* Note: gi_frame can be NULL if the generator is "finished" */
    struct _frame *gi_frame;

    /* True if generator is being executed. */
    char gi_running;

    /* The code object backing the generator */
    PyObject *gi_code;

    /* List of weak reference. */
    PyObject *gi_weakreflist;
} PyGenObject;

PyAPI_DATA(PyTypeObject) PyGen_Type;

#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)

PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
PyAPI_FUNC(int) PyGen_FetchStopIterationValue(PyObject **);

#ifdef __cplusplus
}
#endif
#endif /* !Py_GENOBJECT_H */
#endif /* Py_LIMITED_API */

Fix regression after c8d1df9ac987 (PPC buildbot)


//
//  UIColor+Speed.h
//  LYCategory
//
//  CREATED BY LUO YU ON 26/10/2016.
//  COPYRIGHT © 2016 LUO YU. ALL RIGHTS RESERVED.
//

#import <UIKit/UIKit.h>

@interface UIColor (Speed)

- (UIColor *)colorWithR:(CGFloat)redValue G:(CGFloat)greenValue B:(CGFloat)blueValue;

@end

//
//  UIColor+Speed.h
//  LYCategory
//
//  CREATED BY LUO YU ON 26/10/2016.
//  COPYRIGHT © 2016 LUO YU. ALL RIGHTS RESERVED.
//

#import <UIKit/UIKit.h>

@interface UIColor (Speed)

/**
 generate color object with red-green-blue values

 @param redValue red color value, 0~255
 @param greenValue green color value, 0~255
 @param blueValue blue color value, 0~255
 @return color object
 */
- (UIColor *)colorWithR:(CGFloat)redValue G:(CGFloat)greenValue B:(CGFloat)blueValue;

@end

Modify : doc for color

Modify : doc for color


#include <stdio.h>
#include "stb_image.c"

#define FILENAME "wikipedia_barcode.png"

int main(int argc, char **argv)
{
	int width, height, bytes_per_pixel;
	unsigned char *data = stbi_load(FILENAME, &width, &height, &bytes_per_pixel, STBI_default);

    if (data) {
	    // Run through every pixel and print its greyscale value.
		for (int row = 0; row < height; row++) {
			int row_offset = row * width;

			for (int col = 0; col < width; col++) {
				char grey = data[row_offset + col];
				printf("row %d, col %d: %d\n", row, col, grey);
			}
		}

		stbi_image_free(data);

		printf("width: %d\nheight: %d\nbytes per pixel: %d\n", width, height, bytes_per_pixel);
    } else {
    	printf("stbi_load() failed with error: \"%s\"\n", stbi_failure_reason());
    }

	return 0;
}

#include <stdio.h>
#include "stb_image.c"

#define FILENAME "wikipedia_barcode.png"

int main(int argc, char **argv)
{
	int width, height, bytes_per_pixel;
	unsigned char *data = stbi_load(FILENAME, &width, &height, &bytes_per_pixel, STBI_default);

    if (data) {
	    // Run through every pixel and print its greyscale value.
		for (int row = 0; row < height; row++) {
			int row_offset = row * width;

			for (int col = 0; col < width; col++) {
				char grey = data[row_offset + col];
				printf("row %d, col %d: %u\n", row, col, grey);
			}
		}

		stbi_image_free(data);

		printf("width: %d\nheight: %d\nbytes per pixel: %d\n", width, height, bytes_per_pixel);
    } else {
    	printf("stbi_load() failed with error: \"%s\"\n", stbi_failure_reason());
    }

	return 0;
}

Print grey pixel value as unsigned

Print grey pixel value as unsigned