#ifndef OUTPUTBITMAP_H
#define OUTPUTBITMAP_H

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

using std::ostream;

class OutputBitmap {
	protected:
		unsigned int width, height;
		OutputBitmap(unsigned int width, unsigned int height) : width(width), height(height) {};

	public:
		unsigned int getWidth() const { return width; };
		unsigned int getHeight() const { return height; };

		void setPixel(unsigned int x, unsigned int y, const color& c) = 0;
		void getPixel(unsigned int x, unsigned int y, color& c) = 0;
		color getPixel(unsigned int x, unsigned int y) = 0;

		void commit() = 0;

		void write(ostream& output) = 0;
};

operator << (ofstream& output, OutputBitmap bitmap) {
	bitmap.write(output);
}

Add an abstract bitmap class.

Add an abstract bitmap class.


#include <libterm_internal.h>

void term_update(term_t_i *term)
{
    if( term->dirty.exists && term->update != NULL ) {
        term->update(TO_H(term), term->dirty.x, term->dirty.y, term->dirty.width, term->dirty.height);
        term->dirty.exists = false;
    }
}

void term_cursor_update(term_t_i *term)
{
    if( term->dirty_cursor.exists && term->cursor_update != NULL ) {
        term->cursor_update(TO_H(term), term->dirty_cursor.old_ccol, term->dirty_cursor.old_crow - (term->grid.history - term->grid.height), term->ccol, term->crow - (term->grid.history - term->grid.height));
        term->dirty_cursor.exists = false;
        term->dirty_cursor.old_ccol = term->ccol;
        term->dirty_cursor.old_crow = term->crow;
    }
}

#include <libterm_internal.h>

void term_update(term_t_i *term)
{
    if( term->dirty.exists && term->update != NULL ) {
        term->update(TO_H(term), term->dirty.x, term->dirty.y - (term->grid.history - term->grid.height), term->dirty.width, term->dirty.height);
        term->dirty.exists = false;
    }
}

void term_cursor_update(term_t_i *term)
{
    if( term->dirty_cursor.exists && term->cursor_update != NULL ) {
        term->cursor_update(TO_H(term), term->dirty_cursor.old_ccol, term->dirty_cursor.old_crow - (term->grid.history - term->grid.height), term->ccol, term->crow - (term->grid.history - term->grid.height));
        term->dirty_cursor.exists = false;
        term->dirty_cursor.old_ccol = term->ccol;
        term->dirty_cursor.old_crow = term->crow;
    }
}

Fix update callback position to be grid-relative not scrollback-relative.


/*
 * File:   rbffi.h
 * Author: wayne
 *
 * Created on August 27, 2008, 5:40 PM
 */

#ifndef _RBFFI_H
#define	_RBFFI_H

#include <ruby.h>

#ifdef	__cplusplus
extern "C" {
#endif

#define MAX_PARAMETERS (32)

extern void rb_FFI_AbstractMemory_Init();
extern void rb_FFI_MemoryPointer_Init();
extern void rb_FFI_Buffer_Init();
extern void rb_FFI_Callback_Init();
extern void rb_FFI_Invoker_Init();
extern VALUE rb_FFI_AbstractMemory_class;

#ifdef	__cplusplus
}
#endif

#endif	/* _RBFFI_H */

Remove comment at top of file

Remove comment at top of file


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

#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"

/* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */
void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation,
                                 const int16_t* seq1,
                                 const int16_t* seq2,
                                 int16_t dim_seq,
                                 int16_t dim_cross_correlation,
                                 int right_shifts,
                                 int step_seq2) {
  int i = 0, j = 0;

  for (i = 0; i < dim_cross_correlation; i++) {
    int32_t corr = 0;
    /* Unrolling doesn't seem to improve performance. */
    for (j = 0; j < dim_seq; j++) {
      // It's not clear why casting |right_shifts| here helps performance.
      corr += (seq1[j] * seq2[j]) >> (int16_t)right_shifts;
    }
    seq2 += step_seq2;
    *cross_correlation++ = corr;
  }
}

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

#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"

/* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */
void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation,
                                 const int16_t* seq1,
                                 const int16_t* seq2,
                                 int16_t dim_seq,
                                 int16_t dim_cross_correlation,
                                 int right_shifts,
                                 int step_seq2) {
  int i = 0, j = 0;

  for (i = 0; i < dim_cross_correlation; i++) {
    int32_t corr = 0;
    /* Unrolling doesn't seem to improve performance. */
    for (j = 0; j < dim_seq; j++)
      corr += (seq1[j] * seq2[j]) >> right_shifts;
    seq2 += step_seq2;
    *cross_correlation++ = corr;
  }
}

Test whether removing a cast still hurts performance.

BUG=499241
TEST=none
TBR=andrew

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

Cr-Original-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#9491}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 6bfc82aaf18e42fcc7328b81ffb3ec3cf360d732


#pragma once
#include "ThreadState.h"

#include <atomic>
#include <mutex>
#include <thread>

// Lightweight wrapper for std::thread to provide extensibility
namespace AscEmu { namespace Threading
{
    class AEThread
    {
        typedef std::function<void(AEThread&)> ThreadFunc;

        static std::atomic<unsigned int> ThreadIdCounter;
        const long long m_longSleepDelay = 64;

        // Meta
        std::string m_name;
        unsigned int m_id;
        ThreadFunc m_func;
        std::chrono::milliseconds m_interval;

        // State
        std::mutex m_mtx;
        std::thread m_thread;
        bool m_killed;
        bool m_done;
        bool m_longSleep;

        void threadRunner();
        void killThread();
    public:
        AEThread(std::string name, ThreadFunc func, std::chrono::milliseconds intervalMs, bool autostart = false);
        ~AEThread();

        std::chrono::milliseconds getInterval() const;
        std::chrono::milliseconds setInterval(std::chrono::milliseconds val);
        std::chrono::milliseconds unsafeSetInterval(std::chrono::milliseconds val);

        std::string getName() const;

        unsigned int getId() const;

        bool isKilled() const;
        void requestKill();
        void join();

        void reboot();

        void lock();
        void unlock();
    };
}}

#pragma once
#include "ThreadState.h"

#include <atomic>
#include <mutex>
#include <thread>

// Lightweight wrapper for std::thread to provide extensibility
namespace AscEmu { namespace Threading
{
    class AEThread
    {
        typedef std::function<void(AEThread&)> ThreadFunc;

        static std::atomic<unsigned int> ThreadIdCounter;
        const long long m_longSleepDelay = 64;

        // Meta
        std::string m_name;
        unsigned int m_id;
        ThreadFunc m_func;
        std::chrono::milliseconds m_interval;

        // State
        std::mutex m_mtx;
        std::thread m_thread;
        bool m_killed;
        bool m_done;
        bool m_longSleep;

        void threadRunner();
        void killThread();
    public:
        AEThread(std::string name, ThreadFunc func, std::chrono::milliseconds intervalMs, bool autostart = true);
        ~AEThread();

        std::chrono::milliseconds getInterval() const;
        std::chrono::milliseconds setInterval(std::chrono::milliseconds val);
        std::chrono::milliseconds unsafeSetInterval(std::chrono::milliseconds val);

        std::string getName() const;

        unsigned int getId() const;

        bool isKilled() const;
        void requestKill();
        void join();

        void reboot();

        void lock();
        void unlock();
    };
}}

Make threads autostart by default

Make threads autostart by default


#ifndef _PKG_ERROR_H
#define _PKG_ERROR_H

#ifdef DEBUG
#	define pkg_error_set(code, fmt, ...) \
		_pkg_error_set(code, fmt " [at %s:%d]", ##__VA_ARGS__, __FILE__, __LINE__)
#else
#	define pkg_error_set _pkg_error_set
#endif

#define ERROR_BAD_ARG(name) \
	pkg_error_set(EPKG_FATAL, "Bad argument `%s` in %s", name, __FUNCTION__)

#define ERROR_SQLITE(db) \
	pkg_error_set(EPKG_FATAL, "%s (sqlite at %s:%d)", sqlite3_errmsg(db), __FILE__, __LINE__)

pkg_error_t _pkg_error_set(pkg_error_t, const char *, ...);

#endif

#ifndef _PKG_ERROR_H
#define _PKG_ERROR_H

#ifdef DEBUG
#	define pkg_error_set(code, fmt, ...) \
		_pkg_error_set(code, fmt " [at %s:%d]", ##__VA_ARGS__, __FILE__, __LINE__)
#else
#	define pkg_error_set _pkg_error_set
#endif

#define ERROR_BAD_ARG(name) \
	pkg_error_set(EPKG_FATAL, "Bad argument `%s` in %s", name, __FUNCTION__)

#define ERROR_SQLITE(db) \
	pkg_error_set(EPKG_FATAL, "%s (sqlite)", sqlite3_errmsg(db))

pkg_error_t _pkg_error_set(pkg_error_t, const char *, ...);

#endif

Revert "Indicate the location of sqlite failures."

This reverts commit 2686383409d98488ae7b2c39d531af9ef380e21a.


/**
 * This is used to setup the UART device on an AVR unit.
 */

#pragma once

#include <avr/io.h>

#ifndef BAUD
#  define BAUD 9600
#  warning BAUD rate not set.  Setting BAUD rate to 9600.
#endif // BAUD

#define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)

static inline void uart_enable(void) {
  UBRR0H = BAUDRATE >> 8;
  UBRR0L = BAUDRATE;
  UCSR0B |= _BV(TXEN0) | _BV(RXEN0);
  UCSR0C |= _BV(UMSEL00) | _BV(UCSZ01) | _BV(UCSZ00);
}

static inline void uart_transmit(unsigned char data) {
  while (!(UCSR0A & _BV(UDRE0)));
  UDR0 = data;
}

static inline unsigned char uart_receive(void) {
  while (!(UCSR0A & _BV(RXC0)));
  return UDR0;
}

/**
 * This is used to setup the UART device on an AVR unit.
 */

#pragma once

#include <avr/io.h>

#ifndef BAUD
#  define BAUD 9600
#  warning BAUD rate not set.  Setting BAUD rate to 9600.
#endif // BAUD

#define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)

static inline void uart_enable(void) {
  UBRR0H = BAUDRATE >> 8;
  UBRR0L = BAUDRATE;

  // Set RX/TN enabled
  UCSR0B |= _BV(TXEN0) | _BV(RXEN0);

  // Set asynchronous USART
  // Set frame format: 8-bit data, 2-stop bit
  UCSR0C |= _BV(USBS0) | _BV(UCSZ01) | _BV(UCSZ00);
}

static inline void uart_transmit(unsigned char data) {
  while (!(UCSR0A & _BV(UDRE0)));
  UDR0 = data;
}

static inline unsigned char uart_receive(void) {
  while (!(UCSR0A & _BV(RXC0)));
  return UDR0;
}

Correct the frame format and async mode for the UART. Add useful comments.


#include <stdio.h>

char input[] = "Burning 'em, if you ain't quick and nimble\nI go crazy when I hear a cymbal";
char key[] = "ICE";
char lookup[] = "0123456789abcdef";

int main()
{
  for(unsigned int i = 0; i < (sizeof(input) - 1); ++i)
  {
    char num = input[i] ^ key[i % (sizeof(key) - 1)];
    printf("%c%c", lookup[(num >> 4)], lookup[num & 0x0F]);
  }
  return 0;
}

Set 1 challenge 5 Implement repeating-key XOR


#include "common.h"

int main(int argc, char **argv) {
	return 0;
}

#include "common.h"

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

internal
void usage() {
	fprintf(stderr,
	        "usage: mepa <command> [<options>] [<args>]\n"
	        "\n"
	        "Commands:\n"
	        "    help             - show this usage text\n"
	        "    format [<file>]  - reformat code\n");
}

internal __attribute__((noreturn))
void die() {
	perror("mepa");
	exit(1);
}

internal
void *nonnull_or_die(void *ptr) {
	if (ptr == NULL) {
		die();
	}
	return ptr;
}

internal
int help_main(int argc, char **argv) {
	(void) argc;
	(void) argv;
	usage();
	return 0;
}

internal
int format_main(int argc, char **argv) {
	FILE *file;
	if (argc == 2 || strcmp(argv[2], "-") == 0) {
		file = stdin;
	} else {
		file = nonnull_or_die(fopen(argv[2], "r"));
	}
	u32 cap = 4096;
	u32 size = 0;
	u8 *contents = malloc(cap);
	while (true) {
		u32 wanted = cap - size;
		usize result = fread(contents + size, 1, wanted, file);
		if (result != wanted) {
			if (ferror(file)) {
				die();
			}
			size += result;
			break;
		}
		size += result;
		cap += cap >> 1;
		contents = realloc(contents, cap);
	}
	contents = realloc(contents, size);
	fclose(file);
	fwrite(contents, 1, size, stdout);
	return 0;
}

typedef struct {
	char *command;
	int (*func)(int, char**);
} Command;

internal
Command commands[] = {
	{"help",   help_main},
	{"-h",     help_main},
	{"--help", help_main},
	{"-help",  help_main},
	{"format", format_main},
};

int main(int argc, char **argv) {
	if (argc == 1) {
		return help_main(argc, argv);
	}
	for (u32 i = 0; i < array_count(commands); i++) {
		if (strcmp(argv[1], commands[i].command) == 0) {
			return commands[i].func(argc, argv);
		}
	}
	fprintf(stderr, "Unknown command %s\n", argv[1]);
	usage();
	return 1;
}

Add basic argument parsing and file reading


#include <stdio.h>

#include "src/sea.h"

int main(int argc, char* argv[]) {
    // parse arguments
    while((opt = getopt(argc, argv, "d:")) != -1) {
        switch(opt) {
            case 'd': {
                extern int yydebug;
                yydebug = 1;
            }
            default: {
                fprintf(stderr, "Usage: %s [-d] input_filename\n", argv[0]);
                exit(EXIT_FAILURE);
            }
        }
    }

    if (optind >= argc) {
        fprintf(stderr, "Expected argument after options\n");
        exit(EXIT_FAILURE);
    }

    // use arguments
    char* filename = argv[optind];
    FILE* input_file;
    int is_stdin = strcmp(filename, "-") == 0;

    input_file = is_stdin ? stdin : fopen(filename, "rb");
    if (!input_file) {
        perror("An error occured whilst reading from the input file");
        return -1;
    }

    // main part of program
    sea* s = create_sea();
    int stat = execute_file(s, input_file);
    free_sea(s);

    // cleanup
    if (!is_stdin) {
        if (ferror(input_file)) {
            fprintf(stderr, "An error occured during reading from the file\n");
        }
        fclose(input_file);
    }

    if (stat != 0) {
        fprintf(stderr, "An occured during parsing\n");
        return stat;
    } else {
        return 0;
    }
}

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

#include "src/sea.h"

int main(int argc, char* argv[]) {
    // parse arguments
    char opt;
    extern int optind;
    while((opt = getopt(argc, argv, "d")) != -1) {
        switch(opt) {
            case 'd': {
                extern int yydebug;
                yydebug = 1;
                break;
            }
            case '?': {
                fprintf(stderr, "Usage: %s [-d] input_filename\n", argv[0]);
                exit(EXIT_FAILURE);
            }
        }
    }

    if (optind >= argc) {
        fprintf(stderr, "Expected argument after options\n");
        exit(EXIT_FAILURE);
    }

    // use arguments
    char* filename = argv[optind];
    FILE* input_file;
    int is_stdin = strcmp(filename, "-") == 0;

    input_file = is_stdin ? stdin : fopen(filename, "rb");
    if (!input_file) {
        perror("An error occured whilst reading from the input file");
        return -1;
    }

    // main part of program
    sea* s = create_sea();
    int stat = execute_file(s, input_file);
    free_sea(s);

    // cleanup
    if (!is_stdin) {
        if (ferror(input_file)) {
            fprintf(stderr, "An error occured during reading from the file\n");
        }
        fclose(input_file);
    }

    if (stat != 0) {
        fprintf(stderr, "An occured during parsing\n");
        return stat;
    } else {
        return 0;
    }
}

Mend command line flag parsing

Mend command line flag parsing


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

#pragma once
#include <cstddef>  // for size_t

namespace paddle {
namespace framework {
namespace details {

struct ExecutionStrategy {
  enum ExecutorType { kDefault = 0, kExperimental = 1 };

  size_t num_threads_{0};
  bool use_cuda_{true};
  bool allow_op_delay_{false};
  size_t num_iteration_per_drop_scope_{100};
  ExecutorType type_{kDefault};
  bool dry_run_{false};
};

}  //  namespace details
}  //  namespace framework
}  //  namespace paddle

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

#pragma once
#include <cstddef>  // for size_t

namespace paddle {
namespace framework {
namespace details {

struct ExecutionStrategy {
  enum ExecutorType { kDefault = 0, kExperimental = 1 };

  size_t num_threads_{0};
  bool use_cuda_{true};
  bool allow_op_delay_{false};
  size_t num_iteration_per_drop_scope_{1};
  ExecutorType type_{kDefault};
  bool dry_run_{false};
};

}  //  namespace details
}  //  namespace framework
}  //  namespace paddle

Change default value to align with the original react

test=develop


#ifndef _LOG_SINGLETON_H_
#define _LOG_SINGLETON_H_

#include "log.h"
#include "basedefs.h"

namespace anp
{

class LogSingleton: public anp::Log
{
public:
	static LogSingleton &getInstance();
	static void releaseInstance();
private:
	LogSingleton() { }
	~LogSingleton() { }

	static uint32 m_refCount;
	static LogSingleton *m_instance;
};

/**
	Makes sure that LogSingleton::releaseInstance() gets called.
*/
class LogSingletonHelper
{
public:
	LogSingletonHelper():
	m_log(LogSingleton::getInstance())
	{

	}
	~LogSingletonHelper()
	{
		LogSingleton::releaseInstance();
	}
	void addMessage(const anp::dstring &message)
	{
		m_log.addMessage(message);
	}
private:
	LogSingleton &m_log;
};

}

#endif // _LOG_SINGLETON_H_

#ifndef _LOG_SINGLETON_H_
#define _LOG_SINGLETON_H_

#include "log.h"
#include "basedefs.h"

namespace anp
{

class LogSingleton: public anp::Log
{
public:
	static LogSingleton &getInstance();
	static void releaseInstance();
private:
	LogSingleton() { }
	~LogSingleton() { }

	static uint32 m_refCount;
	static LogSingleton *m_instance;
};

/**
	Makes sure that LogSingleton::releaseInstance() gets called.
*/
class LogSingletonHelper
{
public:
	LogSingletonHelper():
	m_log(LogSingleton::getInstance())
	{

	}
	~LogSingletonHelper()
	{
		LogSingleton::releaseInstance();
	}
	void addMessage(const anp::dstring &message)
	{
		m_log.addMessage(message);
	}

	void operator()(const anp::dstring message)
	{
		m_log.addMessage(message);
	}
private:
	LogSingleton &m_log;
};

#define LOG_SINGLETON_MSG(message) LogSingleton::getInstance().addMessage(message);\
									LogSingleton::releaseInstance();

}

#endif // _LOG_SINGLETON_H_

Add overloaded () operator to LogSingletonHelper.


/*
 * Copyright (c) 2015, Vsevolod Stakhov
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *	 * Redistributions of source code must retain the above copyright
 *	   notice, this list of conditions and the following disclaimer.
 *	 * Redistributions in binary form must reproduce the above copyright
 *	   notice, this list of conditions and the following disclaimer in the
 *	   documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY AUTHOR ''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 AUTHOR BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
#ifndef LEARN_CACHE_H_
#define LEARN_CACHE_H_

#include "config.h"
#include "ucl.h"

typedef enum rspamd_learn_cache_result {
	RSPAMD_LEARN_OK = 0,
	RSPAMD_LEARN_UNLEARN,
	RSPAMD_LEARN_INGORE
} rspamd_learn_t;

struct rspamd_stat_cache {
	const char *name;
	gpointer (*init)(struct rspamd_stat_ctx *ctx, struct rspamd_config *cfg);
	rspamd_learn_t (*process)(GTree *input, gboolean is_spam, gpointer ctx);
	gpointer ctx;
};

#endif /* LEARN_CACHE_H_ */

Add preliminary API definition for learn cache.


extern int printf(char *, ...);

void (^pb)() = ^{ return; };

int i, j;

int *(^funcs[])() = {
	[0 ... 1] = ^{ printf("1!\n"); return &i; },
	^{ printf("2!\n"); return &j; },
};

void *f(int x)
{
	return funcs[x]();
}

main()
{
	printf("&i = %p\n", &i);
	printf("&j = %p\n", &j);
	for(int i = 0; i < 3; i++)
		printf("f(%d) = %p\n", i, f(i));
}

Test case for static storage blocks

Test case for static storage blocks


// RUN: %clang_analyze_cc1 -w -x c -analyzer-checker=core -analyzer-output=text -verify %s

// Avoid the crash when finding the expression for tracking the origins
// of the null pointer for path notes. Apparently, not much actual tracking
// needs to be done in this example.
void pr34373() {
  int *a = 0; // expected-note{{'a' initialized to a null pointer value}}
  (a + 0)[0]; // expected-warning{{Array access results in a null pointer dereference}}
              // expected-note@-1{{Array access results in a null pointer dereference}}
}

// RUN: %clang_analyze_cc1 -w -x c -analyzer-checker=core -analyzer-output=text -verify %s

// Avoid the crash when finding the expression for tracking the origins
// of the null pointer for path notes.
void pr34373() {
  int *a = 0; // expected-note{{'a' initialized to a null pointer value}}
  (a + 0)[0]; // expected-warning{{Array access results in a null pointer dereference}}
              // expected-note@-1{{Array access results in a null pointer dereference}}
}

Fix an outdated comment in a test. NFC.

[analyzer] Fix an outdated comment in a test. NFC.

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


#pragma once

class UnicodeUtf16StringSearcher
{
private:
	const wchar_t* m_Pattern;
	uint32_t m_PatternLength;

public:
	UnicodeUtf16StringSearcher() :
		m_Pattern(nullptr)
	{
	}

	void Initialize(const wchar_t* pattern, size_t patternLength)
	{
		if (patternLength > std::numeric_limits<uint32_t>::max() / 2)
			__fastfail(1);

		m_Pattern = pattern;
		m_PatternLength = static_cast<uint32_t>(patternLength);
	}

	template <typename TextIterator>
	bool HasSubstring(TextIterator textBegin, TextIterator textEnd)
	{
		while (textEnd - textBegin >= m_PatternLength)
		{
			auto comparisonResult = CompareStringEx(LOCALE_NAME_SYSTEM_DEFAULT, NORM_IGNORECASE, textBegin, static_cast<int>(textEnd - textBegin), m_Pattern, static_cast<int>(m_PatternLength), nullptr, nullptr, 0);
			if (comparisonResult == CSTR_EQUAL)
				return true;

			textBegin++;
		}

		return false;
	}
};

#pragma once

class UnicodeUtf16StringSearcher
{
private:
	const wchar_t* m_Pattern;
	uint32_t m_PatternLength;

public:
	UnicodeUtf16StringSearcher() :
		m_Pattern(nullptr)
	{
	}

	void Initialize(const wchar_t* pattern, size_t patternLength)
	{
		if (patternLength > std::numeric_limits<uint32_t>::max() / 2)
			__fastfail(1);

		m_Pattern = pattern;
		m_PatternLength = static_cast<uint32_t>(patternLength);
	}

	template <typename TextIterator>
	bool HasSubstring(TextIterator textBegin, TextIterator textEnd)
	{
		while (textEnd - textBegin >= m_PatternLength)
		{
			auto comparisonResult = CompareStringEx(LOCALE_NAME_SYSTEM_DEFAULT, NORM_IGNORECASE, textBegin, static_cast<int>(m_PatternLength), m_Pattern, static_cast<int>(m_PatternLength), nullptr, nullptr, 0);
			if (comparisonResult == CSTR_EQUAL)
				return true;

			textBegin++;
		}

		return false;
	}
};

Fix case insensitive UTF16 string search.


#ifndef CHARMAP_H
#define CHARMAP_H

#include <unordered_map>

class Charmap {
    public:
        void cfToAscii();
        void asciiToCf();

    private:
        std::unordered_map<uint8_t, uint8_t> map;
};

#endif

Add character mapper stub class

Add character mapper stub class


// PARAM: --enable ana.int.interval --sets exp.solver.td3.side_widen cycle_self
#include <pthread.h>
#include <assert.h>

int g = 6;
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t B = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
  int x = 1;
  pthread_mutex_lock(&A);
  assert(g == 6);
  assert(x == 1);
  g = 5;
  assert(g == 5);
  assert(x == 1);
  pthread_mutex_lock(&B);
  assert(g == 5);
  assert(x == 1);
  pthread_mutex_unlock(&B);
  assert(g == 5);
  assert(x == 1);
  x = g;
  assert(x == 5);
  g = x + 1;
  assert(g == 6);
  pthread_mutex_unlock(&A);
  assert(x == 5);
  return NULL;
}

int main(void) {
  pthread_t id;
  assert(g == 6);
  pthread_create(&id, NULL, t_fun, NULL);
  assert(5 <= g);
  assert(g <= 6);
  pthread_join(id, NULL);
  return 0;
}

Add example from traces paper

Add example from traces paper


#ifndef QGC_CONFIGURATION_H
#define QGC_CONFIGURATION_H

#include <QString>

/** @brief Polling interval in ms */
#define SERIAL_POLL_INTERVAL 4

/** @brief Heartbeat emission rate, in Hertz (times per second) */
#define MAVLINK_HEARTBEAT_DEFAULT_RATE 1
#define WITH_TEXT_TO_SPEECH 1

// If you need to make an incompatible changes to stored settings, bump this version number
// up by 1. This will caused store settings to be cleared on next boot.
#define QGC_SETTINGS_VERSION 4

#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_ORG_NAME "QGroundControl.org"
#define QGC_ORG_DOMAIN "org.qgroundcontrol"

#define QGC_APPLICATION_VERSION_MAJOR 2
#define QGC_APPLICATION_VERSION_MINOR 3

// The following #definess can be overriden from the command line so that automated build systems can
// add additional build identification.

// Only comes from command line
//#define QGC_APPLICATION_VERSION_COMMIT "..."

#ifndef QGC_APPLICATION_VERSION_BUILDNUMBER
#define QGC_APPLICATION_VERSION_BUILDNUMBER 0
#endif

#ifndef QGC_APPLICATION_VERSION_BUILDTYPE
#define QGC_APPLICATION_VERSION_BUILDTYPE "(Developer Build)"
#endif

#endif // QGC_CONFIGURATION_H

#ifndef QGC_CONFIGURATION_H
#define QGC_CONFIGURATION_H

#include <QString>

/** @brief Polling interval in ms */
#define SERIAL_POLL_INTERVAL 4

/** @brief Heartbeat emission rate, in Hertz (times per second) */
#define MAVLINK_HEARTBEAT_DEFAULT_RATE 1
#define WITH_TEXT_TO_SPEECH 1

// If you need to make an incompatible changes to stored settings, bump this version number
// up by 1. This will caused store settings to be cleared on next boot.
#define QGC_SETTINGS_VERSION 4

#define QGC_APPLICATION_NAME "QGroundControl"
#define QGC_ORG_NAME "QGroundControl.org"
#define QGC_ORG_DOMAIN "org.qgroundcontrol"

#define QGC_APPLICATION_VERSION_MAJOR 2
#define QGC_APPLICATION_VERSION_MINOR 3

// The following #definess can be overriden from the command line so that automated build systems can
// add additional build identification.

// Only comes from command line
//#define QGC_APPLICATION_VERSION_COMMIT "..."

#ifndef QGC_APPLICATION_VERSION_BUILDNUMBER
#define QGC_APPLICATION_VERSION_BUILDNUMBER 0
#endif

#ifndef QGC_APPLICATION_VERSION_BUILDTYPE
#define QGC_APPLICATION_VERSION_BUILDTYPE "(Stable)"
#endif

#endif // QGC_CONFIGURATION_H

Switch to Stable V2.3 Release Candidates


#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <US/unitscript.h>
#include <US/logging.h>

int us_syslog_redirect( struct us_unitscript* unit, int priority ){

  int fds[2];

  if( pipe(fds) ){
    perror("pipe failed");
    return -1;
  }

  int ret = fork();
  if( ret == -1 ){
    perror("fork failed\n");
    close(fds[0]);
    close(fds[1]);
    return -1;
  }
  if( ret ){
    close(fds[0]);
    return fds[1];
  }
  close(fds[1]);

  const char* file = strrchr(unit->file,'/');
  if(!file){
    file = unit->file;
  }else{
    file++;
  }
  openlog(file,0,LOG_DAEMON);

  do {
    char msg[1024*4];
    size_t i = 0;
    while( i<sizeof(msg)-1 && ( ( (ret=read(fds[0],msg+i,1)) == -1 && errno == EAGAIN ) || ( ret==1 && msg[i] != '\n' ) ) )
      i++;
    msg[i] = 0;
    if(i) syslog( priority, "%s", msg );
  } while(ret);

  us_free(unit);
  exit(0);
}

#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <US/unitscript.h>
#include <US/logging.h>

int us_syslog_redirect( struct us_unitscript* unit, int priority ){
  int fds[2];

  if( pipe(fds) ){
    perror("pipe failed");
    return -1;
  }

  int ret = fork();
  if( ret == -1 ){
    perror("fork failed\n");
    close(fds[0]);
    close(fds[1]);
    return -1;
  }
  if( ret ){
    close(fds[0]);
    return fds[1];
  }
  close(fds[1]);

  const char* file = strrchr(unit->file,'/');
  if(!file){
    file = unit->file;
  }else{
    file++;
  }
  openlog(file,0,LOG_DAEMON);
  us_free(unit);

  do {
    char msg[1024*4];
    size_t i = 0;
    while( i<sizeof(msg)-1 && ( ( (ret=read(fds[0],msg+i,1)) == -1 && errno == EAGAIN ) || ( ret==1 && msg[i] != '\n' ) ) )
      i++;
    msg[i] = 0;
    if(i) syslog( priority, "%s", msg );
  } while(ret);

  exit(0);
}

Reduce memory usage of us_syslog_redirect


/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef EXAMPLE_PROTOCOL_H
#define EXAMPLE_PROTOCOL_H

#include <daemon/settings.h>
#include <memcached/engine.h>

#ifdef __cplusplus
extern "C" {
#endif
    MEMCACHED_PUBLIC_API
    EXTENSION_ERROR_CODE memcached_extensions_initialize(const char *config,
                                                         GET_SERVER_API get_server_api);
#ifdef __cplusplus
}

MEMCACHED_PUBLIC_API
EXTENSION_ERROR_CODE file_logger_initialize(const LoggerConfig& config,
                                            GET_SERVER_API get_server_api);

#endif

#endif

/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
#ifndef EXAMPLE_PROTOCOL_H
#define EXAMPLE_PROTOCOL_H

#include <daemon/settings.h>
#include <memcached/engine.h>

#ifdef __cplusplus
extern "C" {
#endif
    MEMCACHED_PUBLIC_API
    EXTENSION_ERROR_CODE memcached_extensions_initialize(const char *config,
                                                         GET_SERVER_API get_server_api);
    MEMCACHED_PUBLIC_API
    EXTENSION_ERROR_CODE file_logger_initialize(const LoggerConfig& config,
                                                GET_SERVER_API get_server_api);
#ifdef __cplusplus
}

#endif

#endif

Fix dlsym error 'Could not find symbol "file_logger_initialize"'

Wrap file_logger_initialize into extern "C" to prevent name mangling,
which caused the error above.

Change-Id: I8c8e1e61599f2afb6dedf4e0b71c0a5a013ccbb7
Reviewed-on: http://review.couchbase.org/86829
Tested-by: Build Bot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Dave Rigby <a09264da4832c7ff1d3bf1608a19f4b870f93750@couchbase.com>


/**
 * @file    target.c
 * @brief   Target information for the kl46z
 *
 * DAPLink Interface Firmware
 * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
 * SPDX-License-Identifier: Apache-2.0
 *
 * 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.
 */

#include "target_config.h"

// The file flash_blob.c must only be included in target.c
#include "flash_blob.c"

// target information
target_cfg_t target_device = {
    .sector_size    = 1024,
    .sector_cnt     = (KB(96) / 1024),
    .flash_start    = 0,
    .flash_end      = KB(128),
    .ram_start      = 0x1FFFA000,
    .ram_end        = 0x2002000,
    .flash_algo     = (program_target_t *) &flash,
};

/**
 * @file    target.c
 * @brief   Target information for the kl46z
 *
 * DAPLink Interface Firmware
 * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
 * SPDX-License-Identifier: Apache-2.0
 *
 * 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.
 */

#include "target_config.h"

// The file flash_blob.c must only be included in target.c
#include "flash_blob.c"

// target information
target_cfg_t target_device = {
    .sector_size    = 1024,
    .sector_cnt     = (KB(96) / 1024),
    .flash_start    = 0,
    .flash_end      = KB(128),
    .ram_start      = 0x1FFFA000,
    .ram_end        = 0x20012000,
    .flash_algo     = (program_target_t *) &flash,
};

Fix ram end for kl82z

Fix ram end for kl82z

Fix typo in target_device for the kl82z. This fixes programming
for this device.


// This uses a headermap with this entry:
//   someheader.h -> Product/someheader.h

// RUN: %clang_cc1 -v -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H
// RUN: %clang_cc1 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H 2> %t.out
// RUN: FileCheck %s -input-file %t.out

// CHECK: Product/someheader.h
// CHECK: system/usr/include/someheader.h
// CHECK: system/usr/include/someheader.h

#include "someheader.h"
#include <someheader.h>
#include <someheader.h>

// This uses a headermap with this entry:
//   someheader.h -> Product/someheader.h

// RUN: %clang_cc1 -triple x86_64-apple-darwin13 -v -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H
// RUN: %clang_cc1 -triple x86_64-apple-darwin13 -fsyntax-only %s -iquote %S/Inputs/headermap-rel2/project-headers.hmap -isysroot %S/Inputs/headermap-rel2/system -I %S/Inputs/headermap-rel2 -H 2> %t.out
// RUN: FileCheck %s -input-file %t.out

// CHECK: Product/someheader.h
// CHECK: system/usr/include/someheader.h
// CHECK: system/usr/include/someheader.h

#include "someheader.h"
#include <someheader.h>
#include <someheader.h>

Add a triple to the test.

[test] Add a triple to the test.

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


#include "src/math/reinterpret.h"
#include <math.h>
#include <stdint.h>
#include <assert.h>

double __trunctfdf2(long double);

static _Bool run(double x)
{
    return reinterpret(uint64_t, x) == reinterpret(uint64_t, __trunctfdf2(x));
}

int main(void)
{
    const uint64_t step = 0x00000034CBF126F8;

    assert(run(INFINITY));
    assert(run(-INFINITY));

    for (uint64_t i = 0; i < 0x7FF0000000000000; i += step) {
        double x = reinterpret(double, i);
        assert(run(x));
        assert(run(-x));
    }

    for (uint64_t i = 0x7FF0000000000001; i < 0x8000000000000000; i += step) {
        double x = reinterpret(double, i);
        assert(isnan(__trunctfdf2(x)));
        assert(isnan(__trunctfdf2(-x)));
    }
}

Test double -> long double

Test double -> long double


/*
 Copyright 2020 The Matrix.org Foundation C.I.C

 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.
 */

#import "MXSecretStorage.h"

@class MXSession;

NS_ASSUME_NONNULL_BEGIN

@interface MXSecretStorage ()

/**
 Constructor.

 @param mxSession the related 'MXSession' instance.
 */
- (instancetype)initWithMatrixSession:(MXSession *)mxSession  processingQueue:(dispatch_queue_t)processingQueue;

@end

NS_ASSUME_NONNULL_END

/*
 Copyright 2020 The Matrix.org Foundation C.I.C

 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.
 */

#import "MXSecretStorage.h"

@class MXSession;
@class MXEncryptedSecretContent;

NS_ASSUME_NONNULL_BEGIN

@interface MXSecretStorage ()

/**
 Constructor.

 @param mxSession the related 'MXSession' instance.
 */
- (instancetype)initWithMatrixSession:(MXSession *)mxSession  processingQueue:(dispatch_queue_t)processingQueue;

- (nullable MXEncryptedSecretContent *)encryptedZeroStringWithPrivateKey:(NSData*)privateKey iv:(nullable NSData*)iv error:(NSError**)error;

- (nullable MXEncryptedSecretContent *)encryptSecret:(NSString*)unpaddedBase64Secret withSecretId:(nullable NSString*)secretId privateKey:(NSData*)privateKey iv:(nullable NSData*)iv error:(NSError**)error;

- (nullable NSString *)decryptSecretWithSecretId:(NSString*)secretId
                                   secretContent:(MXEncryptedSecretContent*)secretContent
                                  withPrivateKey:(NSData*)privateKey
                                           error:(NSError**)error;

@end

NS_ASSUME_NONNULL_END

Make aes-hmac-sha2 encryption methods from `MXSecretStorage` available in SDK


#pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_

#include <memory>
#include "task_typedefs.h"
#include "transaction.h"

namespace You {
namespace DataStore {
namespace UnitTests {}

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

	static DataStore& get();

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

	std::vector<SerializedTask> getAllTask();

private:
	bool isServing = false;
};
}  // namespace DataStore
}  // namespace You
#endif  // YOU_DATASTORE_DATASTORE_H_

#pragma once
#ifndef YOU_DATASTORE_DATASTORE_H_
#define YOU_DATASTORE_DATASTORE_H_

#include <memory>
#include "task_typedefs.h"
#include "transaction.h"

namespace You {
namespace DataStore {
namespace UnitTests {}

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

	static DataStore& get();

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

	std::vector<SerializedTask> getAllTask();

private:
	bool isServing = false;
	std::unique_ptr<Transaction> activeTransaction;
};
}  // namespace DataStore
}  // namespace You
#endif  // YOU_DATASTORE_DATASTORE_H_

Add active transaction member variable to DataStore


/******************************************************************************/
/**
@file
@author		AUTHOR NAME HERE.
@brief		BRIEF HERE.
@copyright	Copyright 2016
				The University of British Columbia,
				IonDB Project Contributors (see @ref AUTHORS.md)
@par
			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
@par
			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.
*/
/******************************************************************************/

#if !defined(CHANGE_ME_H)
#define CHANGE_ME_H

#if defined(__cplusplus)
extern “ C ” {
#endif

/* Actual header file contents go in here. */

#if defined(__cplusplus)
}
#endif

#endif

/******************************************************************************/
/**
@file
@author		AUTHOR NAME HERE.
@brief		BRIEF HERE.
@copyright	Copyright 2016
				The University of British Columbia,
				IonDB Project Contributors (see @ref AUTHORS.md)
@par
			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
@par
			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.
*/
/******************************************************************************/

#if !defined(CHANGE_ME_H)
#define CHANGE_ME_H

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

/* Actual header file contents go in here. */

#if defined(__cplusplus)
}
#endif

#endif

Fix smart quote in file template

Fix smart quote in file template


#pragma once

#include "rapidcheck/seq/Operations.h"

namespace rc {
namespace test {

//! Forwards Seq a random amount and copies it to see if it is equal to the
//! original.
template<typename T>
void assertEqualCopies(Seq<T> seq)
{
    std::size_t len = seq::length(seq);
    std::size_t n = *gen::ranged<std::size_t>(0, len * 2);
    while (n--)
        seq.next();
    const auto copy = seq;
    RC_ASSERT(copy == seq);
}

} // namespace test
} // namespace rc

#pragma once

#include "rapidcheck/seq/Operations.h"

namespace rc {
namespace test {

//! Forwards Seq a random amount and copies it to see if it is equal to the
//! original. Must not be infinite, of course.
template<typename T>
void assertEqualCopies(Seq<T> seq)
{
    std::size_t len = seq::length(seq);
    std::size_t n = *gen::ranged<std::size_t>(0, len * 2);
    while (n--)
        seq.next();
    const auto copy = seq;
    RC_ASSERT(copy == seq);
}

} // namespace test
} // namespace rc

Add clarifying comment for assertEqualCopies


#include <anerley/anerley-tp-feed.h>

#include <libmissioncontrol/mission-control.h>
#include <glib.h>
#include <dbus/dbus-glib.h>

int
main (int    argc,
      char **argv)
{
  GMainLoop *main_loop;
  MissionControl *mc;
  McAccount *account;
  AnerleyTpFeed *feed;
  DBusGConnection *conn;

  if (argc < 2)
  {
    g_print ("Usage: ./test-tp-feed <account-name>");
    return 1;
  }

  g_type_init ();

  main_loop = g_main_loop_new (NULL, FALSE);
  conn = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
  mc = mission_control_new (conn);
  account = mc_account_lookup (argv[1]);
  feed = anerley_tp_feed_new (mc, account);

  g_main_loop_run (main_loop);

  return 0;
}

#include <anerley/anerley-tp-feed.h>

#include <libmissioncontrol/mission-control.h>
#include <glib.h>
#include <dbus/dbus-glib.h>

int
main (int    argc,
      char **argv)
{
  GMainLoop *main_loop;
  MissionControl *mc;
  McAccount *account;
  AnerleyTpFeed *feed;
  DBusGConnection *conn;

  if (argc < 2)
  {
    g_print ("Usage: ./test-tp-feed <account-name>\n");
    return 1;
  }

  g_type_init ();

  main_loop = g_main_loop_new (NULL, FALSE);
  conn = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
  mc = mission_control_new (conn);
  account = mc_account_lookup (argv[1]);
  feed = anerley_tp_feed_new (mc, account);

  g_main_loop_run (main_loop);

  return 0;
}

Add missing newline to usage print call.


#ifndef LOCK_H
#define LOCK_H

enum lockstat
{
	GET_LOCK_NOT_GOT=0,
	GET_LOCK_ERROR,
	GET_LOCK_GOT
};

typedef struct lock lock_t;

struct lock
{
	int fd;
	enum lockstat status;
	char *path;
	lock_t *next;
};

extern struct lock *lock_alloc(void);
extern int lock_init(struct lock *lock, const char *path);
extern struct lock *lock_alloc_and_init(const char *path);
extern void lock_free(struct lock **lock);

// Need to test lock->status to find out what happened when calling these.
extern void lock_get_quick(struct lock *lock);
extern void lock_get(struct lock *lock);

extern int lock_test(const char *path);
extern int lock_release(struct lock *lock);

extern void lock_add_to_list(struct lock **locklist, struct lock *lock);
extern void locks_release_and_free(struct lock **locklist);

#endif

#ifndef LOCK_H
#define LOCK_H

enum lockstat
{
	GET_LOCK_NOT_GOT=0,
	GET_LOCK_ERROR,
	GET_LOCK_GOT
};

struct lock
{
	int fd;
	enum lockstat status;
	char *path;
	struct lock *next;
};

extern struct lock *lock_alloc(void);
extern int lock_init(struct lock *lock, const char *path);
extern struct lock *lock_alloc_and_init(const char *path);
extern void lock_free(struct lock **lock);

// Need to test lock->status to find out what happened when calling these.
extern void lock_get_quick(struct lock *lock);
extern void lock_get(struct lock *lock);

extern int lock_test(const char *path);
extern int lock_release(struct lock *lock);

extern void lock_add_to_list(struct lock **locklist, struct lock *lock);
extern void locks_release_and_free(struct lock **locklist);

#endif

Fix a build issue on Solaris

Fix a build issue on Solaris


//
//  UINavigationBar+Fix.h
//  LYCategory
//
//  Created by Luo Yu on 2017/02/11.
//  Copyright (c) 2014 Luo Yu. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UINavigationBar (Fix)

@end

Add : navigation bar fix

Add : navigation bar fix


// PARAM: --enable ana.int.congruence
#include <goblint.h>
// #include <assert.h>
// #define __goblint_check(e) assert(e)

int basic(){
	unsigned int two_pow_16 = 65536;
	unsigned int a;
	unsigned int b;

	if (a % two_pow_16 == 3)
	{
		if (b % two_pow_16 == 5)
		{
			__goblint_check(a % two_pow_16 == 3);
			__goblint_check(b % two_pow_16 == 5);

			int e = a * b;
			__goblint_check(e % two_pow_16 == 15);
			__goblint_check(e == 15); // UNKNOWN!
		}
	}
}

int special(){
	unsigned int two_pow_18 = 262144;
	unsigned int two_pow_17 = 131072;

	unsigned int a;
	unsigned int b;

	if (a % two_pow_18 == two_pow_17)
	{
		if (b % two_pow_18 == two_pow_17)
		{
			__goblint_check(a % two_pow_18 == two_pow_17);
			__goblint_check(b % two_pow_18 == two_pow_17);

			int e = a * b;
			__goblint_check(e == 0);
		}
	}

	// Hint why the above works:
	__goblint_check( two_pow_17 * two_pow_17 == 0);
}

int special2(){
	unsigned int two_pow_30 = 1073741824;
	unsigned int two_pow_18 = 262144;
	unsigned int two_pow_17 = 131072;
	unsigned int two_pow_16 = 65536;
	unsigned int two_pow_15 = 32768;

	unsigned int x = two_pow_17 + two_pow_15;

	unsigned int a;
	unsigned int b;

	if (a % two_pow_18 == x)
	{
		if (b % two_pow_18 == x)
		{
			__goblint_check(a % two_pow_18 == x);
			__goblint_check(b % two_pow_18 == x);

			int e = a * b;
			__goblint_check(e == two_pow_30);
		}
	}

	// Hint why the above holds:
	__goblint_check( x * x  == two_pow_30);
}

int main()
{
	basic();
	special();
	special2();
}

Add additional test case for handling of overflows in congruence domain.


//
//  main.c
//  d16-asm
//
//  Created by Michael Nolan on 6/17/16.
//  Copyright © 2016 Michael Nolan. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include "parser.h"
#include "assembler.h"
#include <string.h>
#include "instruction.h"
#include <unistd.h>
extern int yyparse (FILE* output_file);
extern FILE* yyin;
extern int yydebug;
int main(int argc, char * const argv[]) {
    FILE *f,*o;
    opterr = 0;
    int c;
    while ((c=getopt(argc,argv,"o:")) != -1){
        switch(c){
            case 'o':
                o = fopen(optarg,"wb");

        }
    }
    if(optind<argc) f = fopen(argv[optind],"r");
    else{
        fprintf(stderr,"d16: No input files specified\n");
        exit(-1);
    }
    if(o==NULL){
        o=fopen("a.out","wb");
    }

    yyin = f;

	  init_hash_table();
    do {
        yyparse(o);
    } while (!feof(yyin));
    fclose(f);
    fclose(o);
    return 0;
}

//
//  main.c
//  d16-asm
//
//  Created by Michael Nolan on 6/17/16.
//  Copyright © 2016 Michael Nolan. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include "parser.h"
#include "assembler.h"
#include <string.h>
#include "instruction.h"
#include <unistd.h>
extern int yyparse (FILE* output_file);
extern FILE* yyin;
extern int yydebug;
bool binary_mode = false;
int main(int argc, char * const argv[]) {
    FILE *f,*o;
    opterr = 0;
    int c;
    while ((c=getopt(argc,argv,"o:bh")) != -1){
        switch(c){
            case 'o':
                o = fopen(optarg,"wb");
                break;
            case 'b':
                binary_mode = true;
                break;
            case 'h':
                puts("Usage: d16 [-bh] -o [outputfile] [input]\n");
                exit(0);
                break;
        }
    }
    if(optind<argc) f = fopen(argv[optind],"r");
    else{
        fprintf(stderr,"d16: No input files specified\n");
        exit(-1);
    }
    if(o==NULL){
        o=fopen("a.out","wb");
    }

    yyin = f;

	  init_hash_table();
    do {
        yyparse(o);
    } while (!feof(yyin));
    fclose(f);
    fclose(o);
    return 0;
}

Add help and binary options

Add help and binary options


/*
 *	CAST-128 in C
 *	Written by Steve Reid <sreid@sea-to-sky.net>
 *	100% Public Domain - no warranty
 *	Released 1997.10.11
 */

#ifndef _CAST_H_
#define _CAST_H_

typedef unsigned char u8;	/* 8-bit unsigned */
typedef unsigned long u32;	/* 32-bit unsigned */

typedef struct {
	u32 xkey[32];	/* Key, after expansion */
	int rounds;		/* Number of rounds to use, 12 or 16 */
} cast_key;

void cast_setkey(cast_key* key, u8* rawkey, int keybytes);
void cast_encrypt(cast_key* key, u8* inblock, u8* outblock);
void cast_decrypt(cast_key* key, u8* inblock, u8* outblock);

#endif /* ifndef _CAST_H_ */

/*
 *	CAST-128 in C
 *	Written by Steve Reid <sreid@sea-to-sky.net>
 *	100% Public Domain - no warranty
 *	Released 1997.10.11
 */

#ifndef _CAST_H_
#define _CAST_H_

#include <stdint.h>

typedef uint8_t u8;	/* 8-bit unsigned */
typedef uint32_t u32;	/* 32-bit unsigned */

typedef struct {
        u32 xkey[32];	/* Key, after expansion */
        int rounds;		/* Number of rounds to use, 12 or 16 */
} cast_key;

void cast_setkey(cast_key* key, u8* rawkey, int keybytes);
void cast_encrypt(cast_key* key, u8* inblock, u8* outblock);
void cast_decrypt(cast_key* key, u8* inblock, u8* outblock);

#endif /* ifndef _CAST_H_ */

Use stdint.h in CAST to implement 32 bit and 8 bit unsigned integers.


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

CCL_NAMESPACE_BEGIN

ccl_device_inline void debug_data_init(DebugData *debug_data)
{
	debug_data->num_bvh_traversal_steps = 0;
}

ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
                                                 ccl_global float *buffer,
                                                 PathState *state,
                                                 DebugData *debug_data,
                                                 int sample)
{
	kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversal_steps,
	                        sample,
	                        debug_data->num_bvh_traversal_steps);
}

CCL_NAMESPACE_END

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

CCL_NAMESPACE_BEGIN

ccl_device_inline void debug_data_init(DebugData *debug_data)
{
	debug_data->num_bvh_traversal_steps = 0;
}

ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
                                                 ccl_global float *buffer,
                                                 PathState *state,
                                                 DebugData *debug_data,
                                                 int sample)
{
	int flag = kernel_data.film.pass_flag;
	if(flag & PASS_BVH_TRAVERSAL_STEPS) {
		kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversal_steps,
		                        sample,
		                        debug_data->num_bvh_traversal_steps);
	}
}

CCL_NAMESPACE_END

Cycles: Fix for viewport rendering with debug enabled


/*
 * Copyright (C) 2006 Apple Computer, Inc.  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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
 */

#include <math.h>

#if PLATFORM(WIN)

inline float roundf(float num)
{
    return num > 0 ? floorf(num + 0.5f) : ceilf(num - 0.5f);
}

inline long lroundf(float num)
{
    return num > 0 ? num + 0.5f : ceilf(num - 0.5f);
}

#endif

Add mathextras.h to wtf to give win32 roundf/lroundf support.

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@14506 bbb929c8-8fbe-4397-9dbb-9b2b20218538


//
//  ObjectiveRocks.h
//  ObjectiveRocks
//
//  Created by Iska on 20/11/14.
//  Copyright (c) 2014 BrainCookie. All rights reserved.
//

#import "RocksDB.h"
#import "RocksDBOptions.h"
#import "RocksDBReadOptions.h"
#import "RocksDBWriteOptions.h"
#import "RocksDBWriteBatch.h"
#import "RocksDBIterator.h"
#import "RocksDBSnapshot.h"
#import "RocksDBComparator.h"
#import "RocksDBMergeOperator.h"

Add RocksDB merge operator import to the main public header


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

#ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_UI_H_
#define CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_UI_H_

class Browser;
class ExtensionService;

// Only enable the external install UI on Windows and Mac, because those
// are the platforms where external installs are the biggest issue.
#if defined(OS_WINDOWS) || defined(OS_MACOSX)
#define ENABLE_EXTERNAL_INSTALL_UI 1
#else
#define ENABLE_EXTERNAL_INSTALL_UI 0
#endif

namespace extensions {

class Extension;

// Adds/Removes a global error informing the user that an external extension
// was installed.
bool AddExternalInstallError(ExtensionService* service,
                             const Extension* extension);
void RemoveExternalInstallError(ExtensionService* service);

// Used for testing.
bool HasExternalInstallError(ExtensionService* service);

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_UI_H_

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

#ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_UI_H_
#define CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_UI_H_

#include "build/build_config.h"

class Browser;
class ExtensionService;

// Only enable the external install UI on Windows and Mac, because those
// are the platforms where external installs are the biggest issue.
#if defined(OS_WIN) || defined(OS_MACOSX)
#define ENABLE_EXTERNAL_INSTALL_UI 1
#else
#define ENABLE_EXTERNAL_INSTALL_UI 0
#endif

namespace extensions {

class Extension;

// Adds/Removes a global error informing the user that an external extension
// was installed.
bool AddExternalInstallError(ExtensionService* service,
                             const Extension* extension);
void RemoveExternalInstallError(ExtensionService* service);

// Used for testing.
bool HasExternalInstallError(ExtensionService* service);

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_EXTERNAL_INSTALL_UI_H_

Fix external extension install (post-sideload) restriction on Windows.

I had #ifdef'd it to OS_WINDOWS. It should be OS_WIN.

BUG=156727

Review URL: https://codereview.chromium.org/11238042

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


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

#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"

/* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */
void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation,
                                 const int16_t* seq1,
                                 const int16_t* seq2,
                                 int16_t dim_seq,
                                 int16_t dim_cross_correlation,
                                 int right_shifts,
                                 int step_seq2) {
  int i = 0, j = 0;

  for (i = 0; i < dim_cross_correlation; i++) {
    int32_t corr = 0;
    // Linux 64-bit performance is improved by the int16_t cast below.
    // Presumably this is some sort of compiler bug, as there's no obvious
    // reason why that should result in better code.
    for (j = 0; j < dim_seq; j++)
      corr += (seq1[j] * seq2[j]) >> (int16_t)right_shifts;
    seq2 += step_seq2;
    *cross_correlation++ = corr;
  }
}

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

#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"

/* C version of WebRtcSpl_CrossCorrelation() for generic platforms. */
void WebRtcSpl_CrossCorrelationC(int32_t* cross_correlation,
                                 const int16_t* seq1,
                                 const int16_t* seq2,
                                 int16_t dim_seq,
                                 int16_t dim_cross_correlation,
                                 int right_shifts,
                                 int step_seq2) {
  int i = 0, j = 0;

  for (i = 0; i < dim_cross_correlation; i++) {
    int32_t corr = 0;
    for (j = 0; j < dim_seq; j++)
      corr += (seq1[j] * seq2[j]) >> right_shifts;
    seq2 += step_seq2;
    *cross_correlation++ = corr;
  }
}

Remove a cast again, after it was shown to worsen Windows perf.

This will hurt Linux x64 perf, but we think that's a compiler bug and we're
willing to take the hit for the better clarity of the code sans cast as well as
the better Windows perf.  Hopefully eventually the compiler will improve.

BUG=504813
TEST=none
TBR=andrew

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

Cr-Original-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#9516}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 3c60d614636a858e18fda9e52045fd1192517b8d


#ifndef UTIL_H
#define UTIL_H

#include "fibrile.h"

/** Atomics. */
#define fence() fibrile_fence()
#define fadd(ptr, n) __sync_fetch_and_add(ptr, n)
#define cas(...) __sync_val_compare_and_swap(__VA_ARGS__)

/** Lock. */
#define lock(ptr)   fibrile_lock(ptr)
#define unlock(ptr) fibrile_unlock(ptr)
#define trylock(ptr) (!__sync_lock_test_and_set(ptr, 1))

/** Barrier. */
static inline void barrier(int n)
{
  static volatile int count = 0;
  static volatile int sense = 0;

  int local_sense = !fibrile_deq.sense;

  if (fadd(&count, 1) == n - 1) {
    count = 0;
    sense = local_sense;
  }

  while (sense != local_sense);
}

/** Others. */

typedef struct _frame_t {
  void * rsp;
  void * rip;
} frame_t;

#define this_frame() ((frame_t *) __builtin_frame_address(0))
#define unreachable() __builtin_unreachable()

#define adjust(addr, offset) ((void *) addr - offset)

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

#ifndef UTIL_H
#define UTIL_H

#include "fibrile.h"

/** Atomics. */
#define fence() fibrile_fence()
#define fadd(ptr, n) __sync_fetch_and_add(ptr, n)
#define cas(...) __sync_val_compare_and_swap(__VA_ARGS__)

/** Lock. */
#define lock(ptr)   fibrile_lock(ptr)
#define unlock(ptr) fibrile_unlock(ptr)
#define trylock(ptr) (!__sync_lock_test_and_set(ptr, 1))

/** Barrier. */
static inline void barrier(int n)
{
  static volatile int count = 0;
  static volatile int sense = 0;

  int local_sense = !fibrile_deq.sense;

  if (fadd(&count, 1) == n - 1) {
    count = 0;
    sense = local_sense;
  }

  while (sense != local_sense);
  fence();
}

/** Others. */

typedef struct _frame_t {
  void * rsp;
  void * rip;
} frame_t;

#define this_frame() ((frame_t *) __builtin_frame_address(0))
#define unreachable() __builtin_unreachable()

#define adjust(addr, offset) ((void *) addr - offset)

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

Add a fence in barrier.

Add a fence in barrier.


/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * 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 INCLUDE_DATA_SOURCE_H_
#define INCLUDE_DATA_SOURCE_H_

#include <jni.h>
#include <sys/types.h>

class DataSource {
 public:
  // Returns the number of bytes read, or -1 on failure. It's not an error if
  // this returns zero; it just means the given offset is equal to, or
  // beyond, the end of the source.
  virtual ssize_t readAt(off64_t offset, void* const data, size_t size) = 0;
};

#endif  // INCLUDE_DATA_SOURCE_H_

/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * 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 INCLUDE_DATA_SOURCE_H_
#define INCLUDE_DATA_SOURCE_H_

#include <jni.h>
#include <sys/types.h>

class DataSource {
 public:
  virtual ~DataSource() {}
  // Returns the number of bytes read, or -1 on failure. It's not an error if
  // this returns zero; it just means the given offset is equal to, or
  // beyond, the end of the source.
  virtual ssize_t readAt(off64_t offset, void* const data, size_t size) = 0;
};

#endif  // INCLUDE_DATA_SOURCE_H_

Remove ndk-build from [] flac build rules

Android NDK r9 in [] is deprecated (see []

Update the ExoPlayer flac extensions to use android_jni_library.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182017669


//
//  NSDate+RFC1123.h
//  MKNetworkKit
//
//  Created by Marcus Rohrmoser
//  http://blog.mro.name/2009/08/nsdateformatter-http-header/
//  http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1

//  No obvious license attached

/**
 Convert RFC1123 format dates

 */

@interface NSDate (RFC1123)

/**
 * @name Convert a string to NSDate
 */

/**
 * Convert a RFC1123 'Full-Date' string
 * (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1)
 * into NSDate.
 *
 * @param value_ NSString* the string to convert
 * @return NSDate*
 */
+(NSDate*)dateFromRFC1123:(NSString*)value_;

/**
 * @name Retrieve NSString value of the current date
 */

/**
 * Convert NSDate into a RFC1123 'Full-Date' string
 * (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1).
 *
 * @return NSString*
 */
@property (nonatomic, readonly, copy) NSString *rfc1123String;

@end

//
//  NSDate+RFC1123.h
//  MKNetworkKit
//
//  Created by Marcus Rohrmoser
//  http://blog.mro.name/2009/08/nsdateformatter-http-header/
//  http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1

//  No obvious license attached

#import <Foundation/Foundation.h>

/**
 Convert RFC1123 format dates
 */

@interface NSDate (RFC1123)

/**
 * @name Convert a string to NSDate
 */

/**
 * Convert a RFC1123 'Full-Date' string
 * (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1)
 * into NSDate.
 *
 * @param value_ NSString* the string to convert
 * @return NSDate*
 */
+(NSDate*)dateFromRFC1123:(NSString*)value_;

/**
 * @name Retrieve NSString value of the current date
 */

/**
 * Convert NSDate into a RFC1123 'Full-Date' string
 * (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1).
 *
 * @return NSString*
 */
@property (nonatomic, readonly, copy) NSString *rfc1123String;

@end

Add explicit Foundation import to NSDate extension (for spm compatibility)


#include "gtk2hs_macros.h"
#include <gtksourceview/gtksourcebuffer.h>
#if GTK_MAJOR_VERSION < 3
#include <gtksourceview/gtksourceiter.h>
#endif
#include <gtksourceview/gtksourcelanguage.h>
#include <gtksourceview/gtksourcelanguagemanager.h>
#include <gtksourceview/gtksourcestyle.h>
#include <gtksourceview/gtksourcestylescheme.h>
#include <gtksourceview/gtksourcestyleschememanager.h>
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourceview-typebuiltins.h>
#include <gtksourceview/gtksourceundomanager.h>
#include <gtksourceview/gtksourcecompletionitem.h>
#include <gtksourceview/gtksourcegutter.h>
#include <gtksourceview/gtksourcecompletionprovider.h>
#include <gtksourceview/gtksourcecompletionproposal.h>
#include <gtksourceview/gtksourcemark.h>
#include <gtksourceview/gtksourcecompletioninfo.h>

Fix for new versions of gtksourceview provided by Oleg Chiruhin


//PARAM: --disable ana.int.def_exc --enable ana.int.interval
int main() {
    int x;

    if(!x) {
        assert(x==0);
    } else {
        assert(x==1); //UNKNOWN!
    }
}

//PARAM: --disable ana.int.def_exc --enable ana.int.interval
int main() {
    int x;

    if(!x) {
    } else {
        assert(x==1); //UNKNOWN!
    }
}

27/04: Remove assert that is unknown when runinng only with interval


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

#import "OMValidationFailure.h"
#import "NSObject+OMValidation.h"
#import "NSString+OMValidation.h"
#import "NSNumber+OMValidation.h"
#import "OMValidate.h"

#ifdef OMVALIDATION_PROMISES_AVAILABLE
#import "OMValidationTask.h"
#endif

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

#import "OMValidationFailure.h"
#import "NSObject+OMValidation.h"
#import "NSString+OMValidation.h"
#import "NSNumber+OMValidation.h"
#import "NSArray+OMValidation.h"
#import "OMValidate.h"

#ifdef OMVALIDATION_PROMISES_AVAILABLE
#import "OMValidationTask.h"
#endif

Include NSArray category into main header


//
// Copyright (C) 2008 SIPez LLC.
// Licensed to SIPfoundry under a Contributor Agreement.
//
// Copyright (C) 2008 SIPfoundry Inc.
// Licensed by SIPfoundry under the LGPL license.
//
// $$
///////////////////////////////////////////////////////////////////////////////

#ifndef _MprnRtpStreamActivityMsg_h_
#define _MprnRtpStreamActivityMsg_h_

// SYSTEM INCLUDES

// APPLICATION INCLUDES
#include "os/OsMsg.h"
#include "utl/UtlString.h"
#include "MpResNotificationMsg.h"

// DEFINES
// MACROS
// EXTERNAL FUNCTIONS
// EXTERNAL VARIABLES
// CONSTANTS
// STRUCTS
// TYPEDEFS
// FORWARD DECLARATIONS

/**
*  Notification used to communicate RTP stream activity.
*/
class MprnRtpStreamActivityMsg : public MpResNotificationMsg
{
/* //////////////////////////// PUBLIC //////////////////////////////////// */
public:

/* ============================ CREATORS ================================== */
///@name Creators
//@{

   enum StreamState {
      STREAM_START,  ///< Stream have been started
      STREAM_STOP,   ///< Stream have been stopped
      STREAM_CHANGE  ///< Stream attributes have been changed
   };

     /// Constructor
   MprnRtpStreamActivityMsg(const UtlString& namedResOriginator,
                            StreamState state,
                            RtpSRC ssrc,
                            unsigned address,
                            int port,
                            MpConnectionID connId = MP_INVALID_CONNECTION_ID,
                            int streamId = -1);

     /// Copy constructor
   MprnRtpStreamActivityMsg(const MprnRtpStreamActivityMsg& rMsg);

     /// Create a copy of this msg object (which may be of a derived type)
   virtual OsMsg* createCopy() const;

     /// Destructor
   virtual ~MprnRtpStreamActivityMsg();

//@}

/* ============================ MANIPULATORS ============================== */
///@name Manipulators
//@{

     /// Assignment operator
   MprnRtpStreamActivityMsg& operator=(const MprnRtpStreamActivityMsg& rhs);

//@}

/* ============================ ACCESSORS ================================= */
///@name Accessors
//@{

     /// Get the stream state.
   StreamState getState() const;

     /// Get the stream SSRC.
   unsigned getSsrc() const;

     /// Get IP address of the stream source/destination.
   unsigned getAddress() const;

     /// Get port of the stream source/destination.
   int getPort() const;

//@}

/* ============================ INQUIRY =================================== */
///@name Inquiry
//@{

//@}

/* //////////////////////////// PROTECTED ///////////////////////////////// */
protected:
   StreamState mState;  ///< Stream state to be reported.
   RtpSRC mSsrc;        ///< SSRC of the stream.
   unsigned mAddress;   ///< IP of the stream source/destination.
   int mPort;           ///< Port of the stream source/destination.

/* //////////////////////////// PRIVATE /////////////////////////////////// */
private:
};

/* ============================ INLINE METHODS ============================ */

#endif  // _MprnRtpStreamActivityMsg_h_

Add notification message which will be used to notify about voice activity.

git-svn-id: f26ccc5efe72c2bd8e1c40f599fe313f2692e4de@10875 a612230a-c5fa-0310-af8b-88eea846685b


// RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64
// REQUIRES: linux
typedef int a;

// RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64, powerpc64le-
// REQUIRES: linux
typedef int a;

Update XFAIL line after r294781.

Update XFAIL line after r294781.

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


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

#ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_
#define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_
#pragma once

namespace gfx {
class Point;
}

namespace views {

class View;

////////////////////////////////////////////////////////////////////////////////
//
// MenuButtonDelegate
//
// An interface that allows a component to tell a View about a menu that it
// has constructed that the view can show (e.g. for MenuButton views, or as a
// context menu.)
//
////////////////////////////////////////////////////////////////////////////////
class MenuButtonDelegate {
 public:
  // Creates and shows a menu at the specified position. |source| is the view
  // the MenuButtonDelegate was set on.
  virtual void RunMenu(View* source, const gfx::Point& point) = 0;

 protected:
  virtual ~MenuButtonDelegate() {}
};

}  // namespace views

#endif  // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_

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

#ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_
#define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_
#pragma once

#include "ui/views/views_export.h"

namespace gfx {
class Point;
}

namespace views {

class View;

////////////////////////////////////////////////////////////////////////////////
//
// MenuButtonDelegate
//
// An interface that allows a component to tell a View about a menu that it
// has constructed that the view can show (e.g. for MenuButton views, or as a
// context menu.)
//
////////////////////////////////////////////////////////////////////////////////
class VIEWS_EXPORT MenuButtonDelegate {
 public:
  // Creates and shows a menu at the specified position. |source| is the view
  // the MenuButtonDelegate was set on.
  virtual void RunMenu(View* source, const gfx::Point& point) = 0;

 protected:
  virtual ~MenuButtonDelegate() {}
};

}  // namespace views

#endif  // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_DELEGATE_H_

views: Fix win builder by tagging MenuButtonDelegate with VIEWS_EXPORT.

BUG=117092
TBR=sky@chromium.org

Review URL: https://chromiumcodereview.appspot.com/9647003

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


#pragma once

class IElfRelocator;

enum class Endianness { Big, Little };

class CArchitecture
{
public:
	virtual void AssembleOpcode(const std::wstring& name, const std::wstring& args) = 0;
	virtual bool AssembleDirective(const std::wstring& name, const std::wstring& args) = 0;
	virtual void NextSection() = 0;
	virtual void Pass2() = 0;
	virtual void Revalidate() = 0;
	virtual int GetWordSize() = 0;
	virtual IElfRelocator* getElfRelocator() = 0;
	virtual Endianness getEndianness() = 0;
};

class CInvalidArchitecture: public CArchitecture
{
public:
	virtual void AssembleOpcode(const std::wstring& name, const std::wstring& args);
	virtual bool AssembleDirective(const std::wstring& name, const std::wstring& args);
	virtual void NextSection();
	virtual void Pass2();
	virtual void Revalidate();
	virtual int GetWordSize();
	virtual IElfRelocator* getElfRelocator();
	virtual Endianness getEndianness() { return Endianness::Little; };
};

extern CInvalidArchitecture InvalidArchitecture;

#pragma once

class IElfRelocator;
class CAssemblerCommand;
class Tokenizer;

enum class Endianness { Big, Little };

class CArchitecture
{
public:
	virtual void AssembleOpcode(const std::wstring& name, const std::wstring& args) = 0;
	virtual bool AssembleDirective(const std::wstring& name, const std::wstring& args) = 0;
	virtual CAssemblerCommand* parseDirective(Tokenizer& tokenizer) { return nullptr; };
	virtual CAssemblerCommand* parseOpcode(Tokenizer& tokenizer) { return nullptr; };
	virtual void NextSection() = 0;
	virtual void Pass2() = 0;
	virtual void Revalidate() = 0;
	virtual int GetWordSize() = 0;
	virtual IElfRelocator* getElfRelocator() = 0;
	virtual Endianness getEndianness() = 0;
};

class CInvalidArchitecture: public CArchitecture
{
public:
	virtual void AssembleOpcode(const std::wstring& name, const std::wstring& args);
	virtual bool AssembleDirective(const std::wstring& name, const std::wstring& args);
	virtual void NextSection();
	virtual void Pass2();
	virtual void Revalidate();
	virtual int GetWordSize();
	virtual IElfRelocator* getElfRelocator();
	virtual Endianness getEndianness() { return Endianness::Little; };
};

extern CInvalidArchitecture InvalidArchitecture;

Extend interfaces with new parsing functions


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

#pragma once

#include "compact/compact_tensor.h"
#include "compact/compact_tensor_builder.h"

namespace vespalib {
namespace tensor {

struct DefaultTensor {
    using type = CompactTensor;
    using builder = CompactTensorBuilder;
};

} // namespace vespalib::tensor
} // namespace vespalib

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

#pragma once

#include "compact/compact_tensor_v2.h"
#include "compact/compact_tensor_v2_builder.h"

namespace vespalib {
namespace tensor {

struct DefaultTensor {
    using type = CompactTensorV2;
    using builder = CompactTensorV2Builder;
};

} // namespace vespalib::tensor
} // namespace vespalib

Change to using CompactTensorV2 as default impl for sparse tensors.


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

#include "error.h"
#include "memory.h"

#define READ_SIZE 0x4000

static void usage(void)
{
	fprintf(stderr, "usage: tmpgb <file>");
	exit(EXIT_FAILURE);
}

static void load_rom(const char *rom)
{
	FILE *fp;
	unsigned char *buffer[READ_SIZE];
	size_t nread;
	int i = -1;

	fp = fopen(rom, "rb");

	if (fp == NULL) {
		fprintf(stderr, "Could not open %s", rom);
		exit(EXIT_FAILURE);
	}

	while (!feof(fp)) {
		nread = fread(buffer, READ_SIZE, 1, fp);

		if (nread == 0) {
			if (ferror(fp)) {
				fprintf(stderr, "Error reading %s", rom);
				exit(EXIT_FAILURE);
			}
		}
		read_rom(buffer, i);
	}

	fclose(fp);
}

static void run(void)
{
	int ret;

	if ((ret = init_memory()) != 0) {
		errnr = ret;
		exit_error();
	}
}

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

	if (argc != 2)
		usage();

	rom = argv[1];
	load_rom(rom);

	run();

	return 0;
}

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

#include "error.h"
#include "memory.h"

#define READ_SIZE 0x4000

static void usage(void)
{
	fprintf(stderr, "usage: tmpgb <file>");
	exit(EXIT_FAILURE);
}

static void load_rom(const char *rom)
{
	FILE *fp;
	unsigned char buffer[READ_SIZE];
	size_t nread;
	int i = -1;

	fp = fopen(rom, "rb");

	if (fp == NULL) {
		fprintf(stderr, "Could not open %s", rom);
		exit(EXIT_FAILURE);
	}

	while (!feof(fp)) {
		nread = fread(buffer, READ_SIZE, 1, fp);

		if (nread == 0) {
			if (ferror(fp)) {
				fprintf(stderr, "Error reading %s", rom);
				exit(EXIT_FAILURE);
			}
		}
		read_rom(buffer, i);
	}

	fclose(fp);
}

static void run(void)
{
	int ret;

	if ((ret = init_memory()) != 0) {
		errnr = ret;
		exit_error();
	}
}

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

	if (argc != 2)
		usage();

	rom = argv[1];
	load_rom(rom);

	run();

	return 0;
}

Fix error with char pointer

Fix error with char pointer


#pragma once

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

#include <check.h>
#include <pal.h>
#include "../../src/base/pal_base_private.h"
#include <common.h>

/* Max allowed diff against expected value */
#define EPSILON_MAX 0.001f
#define EPSILON_RELMAX 0.00001f

struct gold {
    float ai;
    float bi;
    float res;
    float gold;
};

extern float *ai, *bi, *res, *ref;

/* Functions that can be overridden by individual tests */

/* Compare two values */
bool compare(float x, float y);

/* Allow individual tests to add more test cases, e.g. against a reference
 * function */
void add_more_tests(TCase *tcase);

/* Needs to be implemented by tests that define REF_FUNCTION */
void generate_ref(float *out, size_t n);

#pragma once

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

#include <check.h>
#include <pal.h>
#include "../../src/base/pal_base_private.h"
#include <common.h>

/* Max allowed diff against expected value */
#ifndef EPSILON_MAX
#define EPSILON_MAX 0.001f
#endif
#ifndef EPSILON_RELMAX
#define EPSILON_RELMAX 0.00001f
#endif

struct gold {
    float ai;
    float bi;
    float res;
    float gold;
};

extern float *ai, *bi, *res, *ref;

/* Functions that can be overridden by individual tests */

/* Compare two values */
bool compare(float x, float y);

/* Allow individual tests to add more test cases, e.g. against a reference
 * function */
void add_more_tests(TCase *tcase);

/* Needs to be implemented by tests that define REF_FUNCTION */
void generate_ref(float *out, size_t n);

Allow tests to override error tolerance

tests: Allow tests to override error tolerance

Signed-off-by: Ola Jeppsson <793f970c52ded1276b9264c742f19d1888cbaf73@adapteva.com>


// 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


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

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

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

#define EXTERN
#include "types.h"
#include "globals.h"

/* Default layout values, possibly set via command line; -1 indicates unset */
fdpParms_t fdp_parms = {
    1,                          /* useGrid */
    1,                          /* useNew */
    -1,                         /* numIters */
    50,                         /* unscaled */
    0.0,                        /* C */
    1.0,                        /* Tfact */
    -1.0,                       /* K - set in initParams; used in init_edge */
    -1.0,                       /* T0 */
};

Make sure fdp global parameters are statically initialized. This avoids making the algorithm independent of processing argv[].


#ifndef LPSLCD_VALIDATOR_H
#define LPSLCD_VALIDATOR_H

#include "generator.h"

class Validator
{
    public:
        static bool Validate (const Code & code)
        {
            // | N - k            |
            // | ____             |
            // | \     a + a      | < L
            // | /___   i   i + k |
            // | i = 1            |
            //
            // k - 0 < k < N;
            // N - length of sequence.
            // L - limit of sidelobe level.

            const ssize_t  sideLobeLimit = code.size () < 14 ? 1 : floor (code.size () / 14.0f);

            for (size_t shift = 1; shift < code.size (); ++shift) {
                ssize_t sideLobe = 0;
                for (size_t i = 0; i < code.size () - shift; ++i) {
                    sideLobe += (code [i + shift] == '+' ? 1 : -1) *
                                (code [i        ] == '+' ? 1 : -1);
                }
                if (std::abs (sideLobe) > sideLobeLimit) {
                    return false;
                }
            }

            return true;
        };
};

#endif//LPSLCD_VALIDATOR_H

#ifndef LPSLCD_VALIDATOR_H
#define LPSLCD_VALIDATOR_H

#include "generator.h"
#include <cmath>

class Validator
{
    public:
        static bool Validate (const Code & code)
        {
            // | N - k            |
            // | ____             |
            // | \     a + a      | < L
            // | /___   i   i + k |
            // | i = 1            |
            //
            // k - 0 < k < N;
            // N - length of sequence.
            // L - limit of sidelobe level.

            const ssize_t  sideLobeLimit = code.size () < 14 ? 1 : std::floor (code.size () / 14.0f);

            for (size_t shift = 1; shift < code.size (); ++shift) {
                ssize_t sideLobe = 0;
                for (size_t i = 0; i < code.size () - shift; ++i) {
                    sideLobe += (code [i + shift] == '+' ? 1 : -1) *
                                (code [i        ] == '+' ? 1 : -1);
                }
                if (std::abs (sideLobe) > sideLobeLimit) {
                    return false;
                }
            }

            return true;
        };
};

#endif//LPSLCD_VALIDATOR_H

Fix compile error on gcc 6.3.0.

Fix compile error on gcc 6.3.0.


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

int main() {
    double r1, x1, y1, r2, x2, y2;
    double distance;

    while (scanf("%lf %lf %lf %lf %lf %lf", &r1, &x1, &y1, &r2, &x2, &y2) != EOF) {
        distance = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));

        if (r1 >= distance + r2) {
            puts("RICO");
        } else {
            puts("MORTO");
        }
    }

    return 0;
}

Solve Fire Flowers in c

Solve Fire Flowers in c


#ifndef FIX_TYPES_H
#define FIX_TYPES_H

#include <sys/types.h>

/*
The system include file defines this in terms of bzero(), but ANSI says
we should use memset().
*/
#if defined(OSF1)
#undef FD_ZERO
#define FD_ZERO(p)     memset((char *)(p), 0, sizeof(*(p)))
#endif

/*
Various non-POSIX conforming files which depend on sys/types.h will
need these extra definitions...
*/

typedef unsigned int u_int;

#if defined(ULTRIX42) ||  defined(ULTRIX43)
typedef char * caddr_t;
#endif

#endif

#ifndef FIX_TYPES_H
#define FIX_TYPES_H

#include <sys/types.h>

/*
The system include file defines this in terms of bzero(), but ANSI says
we should use memset().
*/
#if defined(OSF1)
#undef FD_ZERO
#define FD_ZERO(p)     memset((char *)(p), 0, sizeof(*(p)))
#endif

/*
Various non-POSIX conforming files which depend on sys/types.h will
need these extra definitions...
*/

typedef unsigned int u_int;

#if defined(AIX32)
typedef unsigned short ushort;
#endif

#if defined(ULTRIX42) ||  defined(ULTRIX43)
typedef char * caddr_t;
#endif

#if defined(AIX32)
typedef unsigned long rlim_t;
#endif

#endif

Add types "ushort" and "rlim_t" for AIX.


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

void runStep(struct stack_node node, struct stack_node *top) {
  switch( node.data.type ) {
  case 0:
    struct stack_node push;
    push.cdr = top;
    push.data = node.data;
    *top = push;
    break;
  }
}

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

void runStep(struct stack_node node, struct stack_node *top) {
  switch( node.data.type ) {
  case T_INT: push(node, top);
    break;
  case T_SBRTN:
    push(node, top);
    break;
  case T_char 1:
    switch( nonde.data.numval ) {
    case '+':
      int x = pop(top);
      int y = pop(top);
      push(x + y);
      break;
    case '_':
      push(0);
    case '-':
      int x = pop(top);
      int y = pop(top);
      push(x - y);
      break;
    case '*':
      int x = pop(top);
      int y = pop(top);
      push(x * y);
      break;
    case '/':
      int x = pop(top);
      int y = pop(top);
      push(x / y);
      break;
    case '=':
      int x = pop(top);
      int y = pop(top);
      if(x == y)
	push(-1);
      else
	push(0);
      break;
    case '<':
      int x = pop(top);
      int y = pop(top);
      if(x < y)
	push(-1);
      else
	push(0);
      break;
    case '~':
      int x = pop(top);
      int y = pop(top);
      if(x == y):
	push(0);
      else
	push(-1);
    }
  }
}

struct stack_node pop(struct stack_node *top) {
  struct stack_node pop = *top;
  *top = *(pop.cdr);
  return pop;
}

void push(struct stack_node node, struct stack_node *top) {
  node.cdr = top;
  *top = node;
}

Implement interpretation of basic arithmetic and comparatory functions.


/*	$OpenBSD: loadfile_machdep.h,v 1.1 2013/10/18 10:55:33 miod Exp $	*/

/*-
 * Copyright (c) 1999 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by Christos Zoulas.
 *
 * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#define BOOT_ELF

#define LOAD_KERNEL		LOAD_ALL
#define COUNT_KERNEL		COUNT_ALL

#define LOADADDR(a)		(((u_long)(a)) + offset)
#define ALIGNENTRY(a)		((u_long)(a) & ~0x0fff)
#define READ(f, b, c)		read((f), (void *)LOADADDR(b), (c))
#define BCOPY(s, d, c)		memcpy((void *)LOADADDR(d), (void *)(s), (c))
#define BZERO(d, c)		memset((void *)LOADADDR(d), 0, (c))
#define	WARN(a)			(void)(printf a, \
				    printf((errno ? ": %s\n" : "\n"), \
				    strerror(errno)))
#define PROGRESS(a)		(void) printf a
#define ALLOC(a)		alloc(a)
#define FREE(a, b)		free(a, b)

Add configuration for MI libsa loadfile, to be used soon.


#pragma once

#include <spotify/json.hpp>
#include <spotify/json/codec/boost.hpp>

#include "noise/module/NoiseSources.h"

namespace spotify
{
namespace json
{

template<>
struct default_codec_t<noise::module::NoiseSources>
{
    typedef noise::module::NoiseSources NoiseSources;
    static codec::object_t<NoiseSources> codec()
    {
        auto codec = codec::object<NoiseSources>();
        auto single_module_codec = codec::string();
        auto module_list_codec = codec::array<std::vector<std::string>>(single_module_codec);
        auto optional_single_module_codec = codec::optional(single_module_codec);
        auto optional_module_list_codec = codec::optional(module_list_codec);
        codec.optional("SourceModule", &NoiseSources::sourceModules, optional_module_list_codec);
        codec.optional("ControlModule", &NoiseSources::controlModule, optional_single_module_codec);
        codec.optional("DisplaceModule", &NoiseSources::displaceModules, optional_module_list_codec);
        return codec;
    }
};

}
}

#pragma once

#include <spotify/json.hpp>
#include <spotify/json/codec/boost.hpp>

#include "noise/module/NoiseSources.h"

namespace spotify
{
namespace json
{

template<>
struct default_codec_t<noise::module::NoiseSources>
{
    typedef noise::module::NoiseSources NoiseSources;
    static codec::object_t<NoiseSources> codec()
    {
        auto codec = codec::object<NoiseSources>();
        auto single_module_codec = codec::string();
        auto module_list_codec = codec::array<std::vector<std::string>>(single_module_codec);
        auto optional_single_module_codec = codec::optional(single_module_codec);
        auto optional_module_list_codec = codec::optional(module_list_codec);
        codec.optional("SourceModule", &NoiseSources::sourceModules, optional_module_list_codec);
        codec.optional("ControlModule", &NoiseSources::controlModule, optional_single_module_codec);
        codec.optional("DisplaceModules", &NoiseSources::displaceModules, optional_module_list_codec);
        return codec;
    }
};

}
}

Correct name of "DisplaceModules" field

Correct name of "DisplaceModules" field