/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1998, 1999, 2003 by Ralf Baechle
 */
#ifndef _ASM_TIMEX_H
#define _ASM_TIMEX_H

#ifdef __KERNEL__

#include <asm/mipsregs.h>

/*
 * This is the clock rate of the i8253 PIT.  A MIPS system may not have
 * a PIT by the symbol is used all over the kernel including some APIs.
 * So keeping it defined to the number for the PIT is the only sane thing
 * for now.
 */
#define CLOCK_TICK_RATE 1193182

/*
 * Standard way to access the cycle counter.
 * Currently only used on SMP for scheduling.
 *
 * Only the low 32 bits are available as a continuously counting entity.
 * But this only means we'll force a reschedule every 8 seconds or so,
 * which isn't an evil thing.
 *
 * We know that all SMP capable CPUs have cycle counters.
 */

typedef unsigned int cycles_t;

static inline cycles_t get_cycles(void)
{
	return read_c0_count();
}

#endif /* __KERNEL__ */

#endif /*  _ASM_TIMEX_H */

/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1998, 1999, 2003 by Ralf Baechle
 */
#ifndef _ASM_TIMEX_H
#define _ASM_TIMEX_H

#ifdef __KERNEL__

#include <asm/mipsregs.h>

/*
 * This is the clock rate of the i8253 PIT.  A MIPS system may not have
 * a PIT by the symbol is used all over the kernel including some APIs.
 * So keeping it defined to the number for the PIT is the only sane thing
 * for now.
 */
#define CLOCK_TICK_RATE 1193182

/*
 * Standard way to access the cycle counter.
 * Currently only used on SMP for scheduling.
 *
 * Only the low 32 bits are available as a continuously counting entity.
 * But this only means we'll force a reschedule every 8 seconds or so,
 * which isn't an evil thing.
 *
 * We know that all SMP capable CPUs have cycle counters.
 */

typedef unsigned int cycles_t;

static inline cycles_t get_cycles(void)
{
	return 0;
}

#endif /* __KERNEL__ */

#endif /*  _ASM_TIMEX_H */

Change get_cycles to always return 0.

[MIPS] Change get_cycles to always return 0.

This avoids us executing an mfc0 c0_count instruction on processors which
don't have but also on certain R4000 and R4400 versions where reading from
the count register just in the very moment when its value equals
c0_compare will result in the timer interrupt getting lost.

There is still a number of users of get_cycles remaining outside the
arch code:

crypto/tcrypt.c:                start = get_cycles();
crypto/tcrypt.c:                end = get_cycles();
crypto/tcrypt.c:                start = get_cycles();
crypto/tcrypt.c:                end = get_cycles();
crypto/tcrypt.c:                start = get_cycles();
crypto/tcrypt.c:                end = get_cycles();
drivers/char/hangcheck-timer.c: return get_cycles();
drivers/char/hangcheck-timer.c: printk("Hangcheck: Using get_cycles().\n");
drivers/char/random.c:  sample.cycles = get_cycles();
drivers/input/joystick/analog.c:#define GET_TIME(x)     do { x = get_cycles(); }
include/linux/arcdevice.h:          _x = get_cycles(); \
include/linux/arcdevice.h:          _y = get_cycles(); \
mm/slub.c:      if (!s->defrag_ratio || get_cycles() % 1024 > s->defrag_ratio)
mm/slub.c:      p += 64 + (get_cycles() & 0xff) * sizeof(void *);

Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>


// Variant of nested.c with a counter.
void main()
{
   int z = 0;
   for (int i=0; i<10 ; i++)
     {
	z = z+1;
	for (int j = 0; j < 10 ; j++) ;
           z = z+1;
     }
   return ;
}

// Variant of nested.c with a counter.
void main()
{
  int z = 0;
  for (int i=0; i<10 ; i++) {
	  z = z+1;
	  for (int j = 0; j < 10 ; j++) ;
    z = z+1; // was this intended to be inner loop?
  }
  return ;
}

Indent file; maybe delete it?

Indent file; maybe delete it?


/*=============================================================================

  Library: XNAT/Core

  Copyright (c) German Cancer Research Center,
    Division of Medical and Biological Informatics

  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 CTKXNATLISTMODEL_H
#define CTKXNATLISTMODEL_H

#include "QAbstractListModel"

#include "ctkXNATCoreExport.h"

class ctkXnatObject;

/**
 * @ingroup XNAT_Core
 */
class CTK_XNAT_CORE_EXPORT ctkXnatListModel : public QAbstractListModel
{
  Q_OBJECT

public:
  ctkXnatListModel();
  void setRootObject(ctkXnatObject* root);
  ctkXnatObject* rootObject();

  int rowCount(const QModelIndex &parent) const;
  QVariant data(const QModelIndex &index, int role) const;
  QVariant headerData(int section, Qt::Orientation orientation, int role) const;

private:
  ctkXnatObject* RootObject;
};

#endif // CTKXNATLISTMODEL_H

/*=============================================================================

  Library: XNAT/Core

  Copyright (c) German Cancer Research Center,
    Division of Medical and Biological Informatics

  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 CTKXNATLISTMODEL_H
#define CTKXNATLISTMODEL_H

#include "QAbstractListModel"

#include "ctkXNATCoreExport.h"

class ctkXnatObject;

/**
 * @ingroup XNAT_Core
 */
class CTK_XNAT_CORE_EXPORT ctkXnatListModel : public QAbstractListModel
{
  Q_OBJECT

public:
  ctkXnatListModel();
  void setRootObject(ctkXnatObject* root);
  ctkXnatObject* rootObject();

  int rowCount(const QModelIndex &parent) const;
  QVariant data(const QModelIndex &index, int role) const;
  QVariant headerData(int section, Qt::Orientation orientation, int role) const;

protected:
  ctkXnatObject* RootObject;
};

#endif // CTKXNATLISTMODEL_H

Make root object protected to allow access to the root object from within subclasses.


//
//  RZCollectionList.h
//  RZCollectionList
//
//  Created by Nick Donaldson on 6/21/13.
//  Copyright (c) 2013 Raizlabs. All rights reserved.
//

/************************************************************
 *
 * Include this file to get all the collection lists you need!
 *
 ************************************************************/

#import "RZCollectionListProtocol.h"
#import "RZArrayCollectionList.h"
#import "RZFetchedCollectionList.h"
#import "RZFilteredCollectionList.h"
#import "RZSortedCollectionList.h"
#import "RZCompositeCollectionList.h"
#import "RZCollectionListTableViewDataSource.h"

#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0)
    #import "RZcollectionListCollectionViewDataSource.h"
#endif

// Category for helping construct fetch requests
#import "NSFetchRequest+RZCreationHelpers.h"

//
//  RZCollectionList.h
//  RZCollectionList
//
//  Created by Nick Donaldson on 6/21/13.
//  Copyright (c) 2013 Raizlabs. All rights reserved.
//

/************************************************************
 *
 * Include this file to get all the collection lists at once
 *
 ************************************************************/

#import "RZArrayCollectionList.h"
#import "RZFetchedCollectionList.h"
#import "RZFilteredCollectionList.h"
#import "RZSortedCollectionList.h"
#import "RZCompositeCollectionList.h"
#import "RZCollectionListTableViewDataSource.h"

#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0)
    #import "RZcollectionListCollectionViewDataSource.h"
#endif

// Category for helping construct fetch requests
#import "NSFetchRequest+RZCreationHelpers.h"

Remove protocol from umbrella header

Remove protocol from umbrella header


#ifndef _json_inttypes_h_
#define _json_inttypes_h_

#include "json_config.h"

#if defined(_MSC_VER) && _MSC_VER <= 1700

/* Anything less than Visual Studio C++ 10 is missing stdint.h and inttypes.h */
typedef __int32 int32_t;
#define INT32_MIN    ((int32_t)_I32_MIN)
#define INT32_MAX    ((int32_t)_I32_MAX)
typedef __int64 int64_t;
#define INT64_MIN    ((int64_t)_I64_MIN)
#define INT64_MAX    ((int64_t)_I64_MAX)
#define PRId64 "I64d"
#define SCNd64 "I64d"

#else

#ifdef JSON_C_HAVE_INTTYPES_H
#include <inttypes.h>
#endif
/* inttypes.h includes stdint.h */

#endif

#endif

#ifndef _json_inttypes_h_
#define _json_inttypes_h_

#include "json_config.h"

#ifdef JSON_C_HAVE_INTTYPES_H
/* inttypes.h includes stdint.h */
#include <inttypes.h>

#else
#include <stdint.h>

#define PRId64 "I64d"
#define SCNd64 "I64d"

#endif

#endif

Define macros from inttypes.h when not available


Print format if the length is longer than printf max length


#include <kernel/panic.h>

#include <macros.h>
#include <stdio.h>
#include <types.h>

#define MAX_STACK_FRAME 10000

/*
 * Walk up the stack and print the locations of each stack frame base.
 */
void bt(void) {
	u32 *ebp, *eip;
	unsigned int sf = 0;

	/* Start form the current stack base */
	asm volatile("mov %%ebp, %0" : "=r" (ebp));

	/* Continue until you reach a zeroed stack base pointer. The initial ebp
	 * value is zeroed at boot, but note that this could be corrupted in the
	 * case of serious memory corruption. To protect against this, we keep
	 * track of the frame number and break if it exceeds a reasonable
	 * maximum value. */
	while (ebp) {
		eip = ebp + 1;
		printf("#%d  [0x%x]\n", sf, *eip);
		ebp = (u32*)*ebp;
		sf++;

		/* break if exceeded maximum */
		if (sf > MAX_STACK_FRAME)
			break;
	}
}

#include <kernel/panic.h>

#include <elf.h>
#include <macros.h>
#include <stdio.h>
#include <types.h>

#define MAX_STACK_FRAME 10000

/*
 * Walk up the stack and print the locations of each stack frame base.
 */
void bt(void) {
	u32 *ebp, *eip;
	unsigned int sf = 0;

	/* Start form the current stack base */
	asm volatile("mov %%ebp, %0" : "=r" (ebp));

	/* Continue until you reach a zeroed stack base pointer. The initial ebp
	 * value is zeroed at boot, but note that this could be corrupted in the
	 * case of serious memory corruption. To protect against this, we keep
	 * track of the frame number and break if it exceeds a reasonable
	 * maximum value. */
	while (ebp) {
		eip = ebp + 1;
		printf("#%d  [0x%x] %s\n",
		       sf, *eip, symbol_from_elf(&kelf, *eip));
		ebp = (u32*)*ebp;
		sf++;

		/* break if exceeded maximum */
		if (sf > MAX_STACK_FRAME)
			break;
	}
}

Print symbol names in backtrace

arch/x86: Print symbol names in backtrace

This transforms:

#0  [0x1018C7]
#1  [0x101636]
#2  [0x100231]

into:

#0  [0x1018C7] panic
#1  [0x101636] k_main
#2  [0x100231] start


/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
 * Copyright (C) 2008 Wind River Systems,
 *   written by Ralf Baechle
 * Copyright (C) 1999 Silicon Graphics, Inc.
 */
#ifndef _ASM_TYPES_H
#define _ASM_TYPES_H

#include <asm-generic/int-ll64.h>
#include <uapi/asm/types.h>

/*
 * These aren't exported outside the kernel to avoid name space clashes
 */
#ifndef __ASSEMBLY__

/*
 * Don't use phys_addr_t.  You've been warned.
 */
#ifdef CONFIG_PHYS_ADDR_T_64BIT
typedef unsigned long long phys_addr_t;
#else
typedef unsigned long phys_addr_t;
#endif

#endif /* __ASSEMBLY__ */

#endif /* _ASM_TYPES_H */

/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1994, 1995, 1996, 1999 by Ralf Baechle
 * Copyright (C) 2008 Wind River Systems,
 *   written by Ralf Baechle
 * Copyright (C) 1999 Silicon Graphics, Inc.
 */
#ifndef _ASM_TYPES_H
#define _ASM_TYPES_H

#include <asm-generic/int-ll64.h>
#include <uapi/asm/types.h>

#endif /* _ASM_TYPES_H */

Remove now unused definition of phys_t.

MIPS: Remove now unused definition of phys_t.

Signed-off-by: Ralf Baechle <92f48d309cda194c8eda36aa8f9ae28c488fa208@linux-mips.org>


//
//  OCAObject.h
//  Objective-Chain
//
//  Created by Martin Kiss on 30.12.13.
//  Copyright © 2014 Martin Kiss. All rights reserved.
//

#import <Foundation/Foundation.h>

#define OCA_atomic  atomic

#define OCALazyGetter(TYPE, PROPERTY) \
@synthesize PROPERTY = _##PROPERTY; \
- (TYPE)PROPERTY { \
    if ( ! self->_##PROPERTY) { \
        self->_##PROPERTY = [self oca_lazyGetter_##PROPERTY]; \
    } \
    return self->_##PROPERTY; \
} \
- (TYPE)oca_lazyGetter_##PROPERTY \

#if !defined(NS_BLOCK_ASSERTIONS)

    #define OCAAssert(CONDITION, MESSAGE, ...) \
if ( ! (CONDITION) && (( [[NSAssertionHandler currentHandler] \
                           handleFailureInFunction: [NSString stringWithUTF8String:__PRETTY_FUNCTION__] \
                           file: [NSString stringWithUTF8String:__FILE__] \
                           lineNumber: __LINE__ \
                           description: (MESSAGE), ##__VA_ARGS__], YES)) ) // Will NOT execute appended code, if exception is thrown.

#else

#define OCAAssert(CONDITION, MESSAGE, ...)\
    if ( ! (CONDITION) && (( NSLog(@"*** Assertion failure in %s, %s:%d, Condition not satisfied: %s, reason: '" MESSAGE "'", __PRETTY_FUNCTION__, __FILE__, __LINE__, #CONDITION, ##__VA_ARGS__), YES)) ) // Will execute appended code.

#endif

@interface OCAObject : NSObject

@end

Fix indentation of Assert macros

Fix indentation of Assert macros


#pragma once

#ifndef DUKTAPE_H_INCLUDED
    #error Duktape.h should be included before this header
#endif

#include <vector>

namespace dukbind
{
    template< typename _Type_ >
    void Push( duk_context * ctx, const std::vector<_Type_> & table )
    {
        size_t index, end = table.size();
        duk_idx_t arr_idx = duk_push_array( ctx );
        for( index = 0; index < end; ++index )
        {
            Push( ctx, table[ index ], (_Type_*)0 );
            duk_put_prop_index( ctx, arr_idx, index );
        }
    }

    std::string Get( duk_context * ctx, const int index, const std::string * );
    void Push( duk_context * ctx, const std::string & value );
}

#pragma once

#ifndef DUKTAPE_H_INCLUDED
    #error Duktape.h should be included before this header
#endif

#include <vector>

namespace dukbind
{
    template< typename _Type_ >
    void Push( duk_context * ctx, const std::vector<_Type_> & table )
    {
        size_t index, end = table.size();
        duk_idx_t arr_idx = duk_push_array( ctx );
        for( index = 0; index < end; ++index )
        {
            Push( ctx, table[ index ] );
            duk_put_prop_index( ctx, arr_idx, index );
        }
    }

    std::string Get( duk_context * ctx, const int index, const std::string * );
    void Push( duk_context * ctx, const std::string & value );
}

Fix for new Push signature

Fix for new Push signature


// Copyright (c) <2015> <lummax>
// Licensed under MIT (http://opensource.org/licenses/MIT)

#ifndef RCIMMIXCONS_H
#define RCIMMIXCONS_H

#include <stdint.h>
#include <stdlib.h>

typedef struct {
    size_t reference_count;
    uint8_t spans_lines;
    uint8_t forwarded;
    uint8_t logged;
    uint8_t marked;
    uint8_t new;
} GCHeader;

typedef struct {
    size_t object_size;
    size_t num_members;
} GCRTTI;

typedef struct {
    GCHeader header;
    GCRTTI* rtti;
} GCObject;

typedef struct {} RCImmixCons;

RCImmixCons* rcx_create();
GCObject* rcx_allocate(RCImmixCons* collector, GCRTTI* rtti);
void rcx_collect(RCImmixCons* collector, uint8_t evacuation, uint8_t cycle_collect);
void rcx_write_barrier(RCImmixCons* collector, GCObject* object);
void rcx_destroy(RCImmixCons* collector);

#endif

// Copyright (c) <2015> <lummax>
// Licensed under MIT (http://opensource.org/licenses/MIT)

#ifndef RCIMMIXCONS_H
#define RCIMMIXCONS_H

#include <stdint.h>
#include <stdlib.h>

typedef struct {
    size_t reference_count;
    uint8_t spans_lines;
    uint8_t forwarded;
    uint8_t logged;
    uint8_t marked;
    uint8_t pinned;
    uint8_t new;
} GCHeader;

typedef struct {
    size_t object_size;
    size_t num_members;
} GCRTTI;

typedef struct {
    GCHeader header;
    GCRTTI* rtti;
} GCObject;

typedef struct {} RCImmixCons;

RCImmixCons* rcx_create();
GCObject* rcx_allocate(RCImmixCons* collector, GCRTTI* rtti);
void rcx_collect(RCImmixCons* collector, uint8_t evacuation, uint8_t cycle_collect);
void rcx_write_barrier(RCImmixCons* collector, GCObject* object);
void rcx_destroy(RCImmixCons* collector);

#endif

Fix C-FFI: added pinned mark

Fix C-FFI: added pinned mark


// Copyright eeGeo Ltd (2012-2014), All Rights Reserved

#pragma once

#include "Types.h"

#if defined(EEGEO_DROID)
#include <android/log.h>
#define EXAMPLE_LOG(...) __android_log_print(ANDROID_LOG_INFO,"Eegeo_Examples",__VA_ARGS__)
#else
#define EXAMPLE_LOG(...) printf(__VA_ARGS__)
#endif

// Copyright eeGeo Ltd (2012-2014), All Rights Reserved

#pragma once

#define EXAMPLE_LOG(...) printf(__VA_ARGS__)

Remove references to Android from iOS API logger.


//
// Copyright 2012 Ludovic Landry - http://about.me/ludoviclandry
//
// 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 <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "QRootElement.h"

@interface QImageElement : QEntryElement

@property (nonatomic, strong) UIImage *imageValue;
@property (nonatomic, strong) NSString *imageValueNamed;
@property (nonatomic, assign) float imageMaxLength;
@property(nonatomic) enum UIImagePickerControllerSourceType source;

- (QImageElement *)initWithTitle:(NSString *)title detailImage:(UIImage *)image;

@end

//
// Copyright 2012 Ludovic Landry - http://about.me/ludoviclandry
//
// 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 <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "QRootElement.h"

@interface QImageElement : QEntryElement

@property (nonatomic, strong) UIImage *imageValue;
@property (nonatomic, strong) NSString *imageValueNamed;
@property (nonatomic, assign) float imageMaxLength;
@property(nonatomic) UIImagePickerControllerSourceType source;

- (QImageElement *)initWithTitle:(NSString *)title detailImage:(UIImage *)image;

@end

Fix bug that was causing error building pod in RubyMotion project


#pragma config(Motor,  port2,           shooterleft,   tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port3,           shooterright,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           spinnyintakeofdoomnumber1,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port5,           garry,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           therollmodel, tmotorVex393_MC29, openLoop)

#include "controller.h"
#include "drive.h"

#include "drive.c"

task main()
{
	while(1) {
		motor[shooterleft] = motor[shooterright] = 127;
		motor[spinnyintakeofdoomnumber1] = motor[garry] = motor[therollmodel] = 127;
	}
}

#pragma config(Motor,  port2,           shooterleft,   tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port3,           shooterright,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port4,           spinnyintakeofdoomnumber1,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port5,           garry,   tmotorVex393_MC29, openLoop)
#pragma config(Motor,  port6,           therollmodel, tmotorVex393_MC29, openLoop)

#include "controller.h"
#include "drive.h"

/* "Link" with other files */
#include "drive.c"

task main()
{
	while(1) {
		motor[shooterleft] = motor[shooterright] = 127;
		motor[spinnyintakeofdoomnumber1] = motor[garry] = motor[therollmodel] = 127;
	}
}

Add comment about ROBOTC "linking"

Add comment about ROBOTC "linking"


#include "terminal.h"
#include "multiboot.h"
#include "pic.h"
#include "keyboard.h"
#include "frame_allocator.h"
#include "paging.h"

#include "assert.h"

//Calling convention on x86-64 System V ABI
//rdi, rsi, rdx, rcx for ints

void kernel_main(uintptr_t pmultiboot) {
	init_terminal();

	pic_init(0x20, 0x28);
	pic_enable_interrupts();

	keyboard_init();
	add_interrupt_handler(0x21, keyboard_interrupt);

	init_multiboot_data(pmultiboot);

	init_allocator(&data);

	//test();

	while(1) {
		// struct frame f;
		// allocate_frame(&f);

		// print_text("Alloc frame num: ");
		// print_hex_number(f.number);
		// print_newline();
		int foo = 10;
		int bar = 0xdeadbeef;
		size_t baz = 0xcafebabecafebabe;
		//terminal_printf("\ntest\ntest2\ntest3\n%x\n%3X\n%#x\n%X\n%zx", foo, foo, bar, bar, baz);

		for(int k = 0; k < 50000000; ++k) {}
	}
}

#include "terminal.h"
#include "multiboot.h"
#include "pic.h"
#include "keyboard.h"
#include "frame_allocator.h"
#include "paging.h"

#include "assert.h"

//Calling convention on x86-64 System V ABI
//rdi, rsi, rdx, rcx for ints

void page_fault(void) {
	terminal_printf("Fault");
	assert(0!=0);
}

void kernel_main(uintptr_t pmultiboot) {
	init_terminal();

	pic_init(0x20, 0x28);
	pic_enable_interrupts();

	keyboard_init();
	add_interrupt_handler(0x21, keyboard_interrupt);

	add_interrupt_handler(0x0e, page_fault);

	init_multiboot_data(pmultiboot);

	init_allocator(&data);

	remap_kernel();
	//test();

	while(1) {
		// struct frame f;
		// allocate_frame(&f);

		// print_text("Alloc frame num: ");
		// print_hex_number(f.number);
		// print_newline();
		int foo = 10;
		int bar = 0xdeadbeef;
		size_t baz = 0xcafebabecafebabe;
		//terminal_printf("\ntest\ntest2\ntest3\n%x\n%3X\n%#x\n%X\n%zx", foo, foo, bar, bar, baz);

		for(int k = 0; k < 50000000; ++k) {}
	}
}

Add page fault handler to abort on page fault.


#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

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

	int fd = open("inputcap", O_RDONLY);
	memset(buf, 0, 4096);
	int ret = read(fd, buf, 4000);
	if (ret < 0) exit(0);
	int i;
	int count;
    for (i = 0; i < 4000; ++i)
    {
		char byte = buf[i];
		int mask = 0x80;
		while (mask)
		{
			if (mask & byte) ++count;
			mask >>= 1;
		}
	}
	printf("Distance = %6d us, %6.2f inches\n", count, (float)count / 148.0f);

}

#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

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

	int fd = open("inputcap", O_RDONLY);
	memset(buf, 0, 4096);
	int ret = read(fd, buf, 4000);
	if (ret < 0) exit(0);
	int i;
	int count;
    for (i = 0; i < 4000; ++i)
    {
		char byte = buf[i];
		int mask = 0x80;
		while (mask)
		{
			if (mask & byte) ++count;
			mask >>= 1;
		}
	}
	printf("Distance = %6d us, %6.2f inches\n", count, (float)count / 148.0f);

	return 0;
}

Fix warning for lack of return from main.


#pragma once

#include <spotify/json.hpp>

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

namespace spotify
{
namespace json
{

template<>
struct default_codec_t<noise::module::Wrapper<noise::module::Forward>>
{
    using ForwardWrapper = noise::module::Wrapper<noise::module::Forward>;
    static codec::object_t<ForwardWrapper> codec()
    {
        auto codec = codec::object<ForwardWrapper>();
        codec.required("type", codec::eq<std::string>("Forward"));
        codec.required("SourceModule", codec::ignore_t<int>());
        return codec;
    }
};
}
}

#pragma once

#include <spotify/json.hpp>

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

namespace spotify
{
namespace json
{

template<>
struct default_codec_t<noise::module::Wrapper<noise::module::Forward>>
{
    using ForwardWrapper = noise::module::Wrapper<noise::module::Forward>;
    static codec::object_t<ForwardWrapper> codec()
    {
        auto codec = codec::object<ForwardWrapper>();
        codec.required("type", codec::eq<std::string>("Forward"));
        codec.required("SourceModule", codec::ignore_t<int>());
        return codec;
    }
};
}
}

Add missing header to Forward codec

Add missing header to Forward codec


#ifndef _RELAY_EXP_H_
#define _RELAY_EXP_H_

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

#include <onion-mcp23008-driver.h>

#define RELAY_EXP_ADDR_SWITCH_NUM			3
#define RELAY_EXP_ADDR_SWITCH_DEFAULT_VAL	"000"

// type definitions
typedef enum e_RelayDriverChannels {
	RELAY_EXP_CHANNEL0 		= 0,
	RELAY_EXP_CHANNEL1,
	RELAY_EXP_NUM_CHANNELS,
} ePwmDriverAddr;

int 	relayDriverInit 		(int addr);
int 	relayCheckInit 			(int addr, int *bInitialized);

int 	relaySetChannel			(int addr, int channel, int state);
int 	relaySetAllChannels		(int addr, int state);

#endif // _RELAY_EXP_H_

#ifndef _RELAY_EXP_H_
#define _RELAY_EXP_H_

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

#include <onion-mcp23008-driver.h>

#define RELAY_EXP_ADDR_SWITCH_NUM			3
#define RELAY_EXP_ADDR_SWITCH_DEFAULT_VAL	"000"

// type definitions
typedef enum e_RelayDriverChannels {
	RELAY_EXP_CHANNEL0 		= 0,
	RELAY_EXP_CHANNEL1,
	RELAY_EXP_NUM_CHANNELS,
} eRelayDriverChannels;

int 	relayDriverInit 		(int addr);
int 	relayCheckInit 			(int addr, int *bInitialized);

int 	relaySetChannel			(int addr, int channel, int state);
int 	relaySetAllChannels		(int addr, int state);

#endif // _RELAY_EXP_H_

Fix typo on e_RelayDriverChannels declaration


#include "mbb/test.h"
#include "mbb/queue.h"
#include "mbb/debug.h"

char *test_enqueue_dequeue()
{
	int i;

	MQUE_DEFINE_STRUCT(int, 5) queue;

	MQUE_INITIALISE(&queue);

	MUNT_ASSERT(MQUE_IS_EMPTY(&queue));

	for (i = 1; i <= 5; i++) {
		MUNT_ASSERT(!MQUE_IS_FULL(&queue));
		MQUE_ENQUEUE(&queue, i);
	}

	for (i = 1; i <= 5; i++) {
		int head;

		MUNT_ASSERT(!MQUE_IS_EMPTY(&queue));

		head = MQUE_HEAD(&queue);
		MQUE_DEQUEUE(&queue);;
	}

	MUNT_ASSERT(MQUE_IS_EMPTY(&queue));

	return 0;
}

#include "mbb/test.h"
#include "mbb/queue.h"
#include "mbb/debug.h"

char *test_enqueue_dequeue()
{
	int i;

	MQUE_DEFINE_STRUCT(int, 5) queue;

	MQUE_INITIALISE(&queue);

	MUNT_ASSERT(MQUE_IS_EMPTY(&queue));

	for (i = 1; i <= 5; i++) {
		MUNT_ASSERT(!MQUE_IS_FULL(&queue));
		MQUE_ENQUEUE(&queue, i);
	}

	for (i = 1; i <= 5; i++) {
		int head;

		MUNT_ASSERT(!MQUE_IS_EMPTY(&queue));

		head = MQUE_HEAD(&queue);
		MQUE_DEQUEUE(&queue);;

		MUNT_ASSERT(head == i);
	}

	MUNT_ASSERT(MQUE_IS_EMPTY(&queue));

	return 0;
}

Check enqueued values in unit test

Check enqueued values in unit test


#pragma once

#include <pebble.h>

#define BG_COLOR GColorWhite

#ifdef PBL_ROUND
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 12)
#else
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 2)
#endif

#define BPM_DEFAULT_BPM_T 1200

#define BPM_FONT FONT_KEY_BITHAM_42_BOLD
#define BPM_FONT_HEIGHT 42

#define BPM_TEXT_INVALID "---"
#define BPM_TEXT_BUFFER_SIZE 10

#define BPM_HINT_FONT FONT_KEY_GOTHIC_24_BOLD
#define BPM_HINT_FONT_HEIGHT 24
#define BPM_HINT_TEXT "Current BPM:"

#define METRONOME_HINT_FONT FONT_KEY_GOTHIC_18_BOLD
#define METRONOME_HINT_FONT_HEIGHT 18
#define METRONOME_HINT_TEXT "Metronome BPM:"

#define METRONOME_VIBE_DURATION_MS 50

#define METRONOME_EDIT_TAP_REPEAT_MS 30

#define TAP_TIMEOUT_SECONDS 2

#pragma once

#include <pebble.h>

#define BG_COLOR GColorWhite

#ifdef PBL_ROUND
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 12)
#else
#define ACTION_BAR_WIDTH_WITH_GAP (ACTION_BAR_WIDTH + 2)
#endif

#define BPM_DEFAULT_BPM_T 1200

#define BPM_FONT FONT_KEY_BITHAM_42_BOLD
#define BPM_FONT_HEIGHT 42

#define BPM_TEXT_INVALID "---"
#define BPM_TEXT_BUFFER_SIZE 10

#define BPM_HINT_FONT FONT_KEY_GOTHIC_24_BOLD
#define BPM_HINT_FONT_HEIGHT 24
#define BPM_HINT_TEXT "Current BPM:"

#ifdef PBL_ROUND
#define METRONOME_HINT_FONT FONT_KEY_GOTHIC_18_BOLD
#define METRONOME_HINT_FONT_HEIGHT 18
#else
#define METRONOME_HINT_FONT FONT_KEY_GOTHIC_14_BOLD
#define METRONOME_HINT_FONT_HEIGHT 14
#endif
#define METRONOME_HINT_TEXT "Metronome BPM:"

#define METRONOME_VIBE_DURATION_MS 50

#define METRONOME_EDIT_TAP_REPEAT_MS 30

#define TAP_TIMEOUT_SECONDS 2

Fix font size on rectangular watches

Fix font size on rectangular watches


#ifndef _CONFIG_H
#define _CONFIG_H

#define ENABLE_COUNTERMOVE_HISTORY 0
#define ENABLE_LMP_MIN_MOVES 0
#define ENABLE_HISTORY_PRUNE_DEPTH 4
#define ENABLE_NNUE 0
#define ENABLE_NNUE_SIMD 0

#endif

#ifndef _CONFIG_H
#define _CONFIG_H

#define ENABLE_COUNTERMOVE_HISTORY 0
#define ENABLE_LMP_MIN_MOVES 4
#define ENABLE_HISTORY_PRUNE_DEPTH 4
#define ENABLE_NNUE 0
#define ENABLE_NNUE_SIMD 0

#endif

Enable late move pruning at min 4

Enable late move pruning at min 4


#include "motion.h"

//Utilities
int threshold(int value, int threshold);
void reset_I2C_sensors(void);

//Driving
void drive(int y, int t = 0){
	//y - Forwards/Backwards
	//t - Turning (optional parameter)
	motor[driveLeftFront] = y+t;
	motor[driveRightFront] = y-t;
}

//Mogo (mobile goal lift)
void mogo(int power){
	motor[mobilegoal] = power;
}

//Lift
void lift(int power){
	motor[liftLeftSplit] = power;
}

//Utilities
int threshold(int value, int threshold){
	return abs(value) > threshold ? value : 0;
}

void reset_I2C_sensors(void){
	SensorValue[I2C_1] = SensorValue[I2C_2] = SensorValue[I2C_3] = SensorValue[I2C_4] = 0;
}

#include "motion.h"

//Utilities
int threshold(int value, int threshold);
void reset_I2C_sensors(void);

//Driving
void drive(int y, int t = 0){
	//y - Forwards/Backwards
	//t - Turning (optional parameter)
	motor[driveLeftFront] = y+t;
	motor[driveRightFront] = y-t;
}

//Mogo (mobile goal lift)
void mogo(int power){
	motor[mobilegoal] = power;
}

//Lift
void lift(int power){
	motor[liftLeftSplit] = power;
}

//Utilities
int threshold(int value, int threshold){
	return abs(value) > abs(threshold) ? value : 0;
}

void reset_I2C_sensors(void){
	SensorValue[I2C_1] = SensorValue[I2C_2] = SensorValue[I2C_3] = SensorValue[I2C_4] = 0;
}

Make threshold function use absolute value of threshold value


#include <stdint.h>

#define STRIP_BLACK 0x8000
#define STRIP_PIXELS 50

#define USART_BAUD_RATE 115200

extern uint16_t* const strip_data;

void init();
void set_led(uint8_t state);
uint8_t get_button();

uint16_t get_voltage();
uint16_t get_current();

void strip_flush();
uint16_t pack_RGB(uint8_t red, uint8_t green, uint8_t blue);
void strip_refresh();
void strip_refresh_nowait();
void send_str(uint8_t* mem,uint16_t cnt);
int16_t get_char();

#include <stdint.h>

#define STRIP_BLACK 0x8000
#define STRIP_PIXELS 50

//#define USART_BAUD_RATE 115200
#define USART_BAUD_RATE 3000000

extern uint16_t* const strip_data;

void init();
void set_led(uint8_t state);
uint8_t get_button();

uint16_t get_voltage();
uint16_t get_current();

void strip_flush();
uint16_t pack_RGB(uint8_t red, uint8_t green, uint8_t blue);
void strip_refresh();
void strip_refresh_nowait();
void send_str(uint8_t* mem,uint16_t cnt);
int16_t get_char();

Change baud rate to 3mbps

Change baud rate to 3mbps


/**
 * @file libARSAL/ARSAL.h
 * @brief Library global header for libARSAL
 * @date 04/12/2013
 * @author nicolas.brulez@parrot.com
 */
#ifndef _ARSAL_H_
#define _ARSAL_H_

#include <libARSAL/ARSAL_Endianness.h>
#include <libARSAL/ARSAL_Ftw.h>
#include <libARSAL/ARSAL_Mutex.h>
#include <libARSAL/ARSAL_Print.h>
#include <libARSAL/ARSAL_Sem.h>
#include <libARSAL/ARSAL_Socket.h>
#include <libARSAL/ARSAL_Thread.h>
#include <libARSAL/ARSAL_Time.h>

#endif /* _ARSAL_H_ */

/**
 * @file libARSAL/ARSAL.h
 * @brief Library global header for libARSAL
 * @date 04/12/2013
 * @author nicolas.brulez@parrot.com
 */
#ifndef _ARSAL_H_
#define _ARSAL_H_

#include <libARSAL/ARSAL_Endianness.h>
//#include <libARSAL/ARSAL_Ftw.h>
#include <libARSAL/ARSAL_Mutex.h>
#include <libARSAL/ARSAL_Print.h>
#include <libARSAL/ARSAL_Sem.h>
#include <libARSAL/ARSAL_Socket.h>
#include <libARSAL/ARSAL_Thread.h>
#include <libARSAL/ARSAL_Time.h>

#endif /* _ARSAL_H_ */

Comment file for the moment.

Comment file for the moment.


extern void __VERIFIER_error() __attribute__ ((__noreturn__));
extern int __VERIFIER_nondet_int();

int main()
{
    int x, y;
    if (__VERIFIER_nondet_int())
    {
        x = 0;
        y = 1;
    }
    else
    {
        x = 1;
        y = 0;
    }

    // if (!(x + y == 1))
    if (x + y != 1)
        __VERIFIER_error();
    return 0;
}

// ./goblint --enable ana.sv-comp --enable ana.wp --enable exp.uncilwitness --disable ana.int.def_exc --enable ana.int.interval --set ana.activated '["base"]' --set phases '[{}, {"ana": {"activated": ["base", "observer"], "path_sens": ["observer"]}}]' --html tests/sv-comp/observer/path_nofun_true-unreach-call.c

// /goblint --enable ana.sv-comp --enable ana.wp --enable exp.uncilwitness --disable ana.int.def_exc --enable ana.int.interval --set ana.activated '["base"]' --html tests/sv-comp/observer/path_nofun_true-unreach-call.c

extern void __VERIFIER_error() __attribute__ ((__noreturn__));
extern int __VERIFIER_nondet_int();

int main()
{
    int x, y;
    if (__VERIFIER_nondet_int())
    {
        x = 0;
        y = 1;
    }
    else
    {
        x = 1;
        y = 0;
    }

    // if (!(x + y == 1))
    if (x + y != 1)
        __VERIFIER_error();
    return 0;
}

// ./goblint --enable ana.sv-comp --enable ana.wp --enable exp.uncilwitness --disable ana.int.def_exc --enable ana.int.interval --set ana.activated '["base"]' --set phases '[{}, {"ana": {"activated": ["base", "observer"], "path_sens": ["observer"]}}]' --html tests/sv-comp/observer/path_nofun_true-unreach-call.c

// ./goblint --enable ana.sv-comp --enable ana.wp --enable exp.uncilwitness --disable ana.int.def_exc --enable ana.int.interval --set ana.activated '["base"]' --html tests/sv-comp/observer/path_nofun_true-unreach-call.c

Fix command in path_nofun SV-COMP example


#import <React/RCTBridgeModule.h>

@interface RNI18n : NSObject <RCTBridgeModule>
@end

#if __has_include("RCTBridgeModule.h")
#import "RCTBridgeModule.h"
#else
#import <React/RCTBridgeModule.h>
#endif

@interface RNI18n : NSObject <RCTBridgeModule>
@end

Add support for react-native < 0.40

Add support for react-native < 0.40


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

#include_next <sys/wait.h>

#ifndef ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_
#define ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_

#ifdef __cplusplus
extern "C" {
#endif

#define WNOHANG 1

pid_t wait3(int *wstatus, int options, struct rusage *rusage);

#ifdef __cplusplus
}  // extern "C"
#endif

#endif  // ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_

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

#include_next <sys/wait.h>

#ifndef ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_
#define ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_

#include <sys/resource.h>

#ifdef __cplusplus
extern "C" {
#endif

#define WNOHANG 1

pid_t wait3(int *wstatus, int options, struct rusage *rusage);

#ifdef __cplusplus
}  // extern "C"
#endif

#endif  // ASYLO_PLATFORM_POSIX_INCLUDE_SYS_WAIT_H_

Include sys/resource.h for struct rusage

Used in wait3 signature.

PiperOrigin-RevId: 269667008
Change-Id: Ie6e3a9b334861c78722bbae806352216d57ac437


#ifndef JIVE_ARCH_REGISTERS_H
#define JIVE_ARCH_REGISTERS_H

typedef struct jive_cpureg jive_cpureg;
typedef struct jive_regcls jive_regcls;

struct jive_cpureg {
	const char name[32];
};

#endif

#ifndef JIVE_ARCH_REGISTERS_H
#define JIVE_ARCH_REGISTERS_H

typedef struct jive_cpureg jive_cpureg;
typedef struct jive_regcls jive_regcls;

struct jive_cpureg {
	const jive_regcls * regcls;
	const char name[32];
};

#endif

Add reference to register class to cpureg

Arch support is still incomplete, but this bit is required
for other target-independent code.


// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s 2>&1 | FileCheck %s
#pragma clang __debug parser_crash
// CHECK: Preprocessed source(s) and associated run script(s) are located at:
// CHECK: diagnostic msg: {{.*}}Output{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c

// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s
#pragma clang __debug parser_crash
// CHECK: Preprocessed source(s) and associated run script(s) are located at:
// CHECK: diagnostic msg: {{.*}}{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c

Update crash diagnostics test to avoid attempting to write into various
directories if possible and to not require %t to have "Output" in the name.

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


/*
 * QLogic iSCSI HBA Driver
 * Copyright (c)  2003-2010 QLogic Corporation
 *
 * See LICENSE.qla4xxx for copyright and licensing details.
 */

#define QLA4XXX_DRIVER_VERSION	"5.02.00-k14"

/*
 * QLogic iSCSI HBA Driver
 * Copyright (c)  2003-2010 QLogic Corporation
 *
 * See LICENSE.qla4xxx for copyright and licensing details.
 */

#define QLA4XXX_DRIVER_VERSION	"5.02.00-k15"

Update driver version to 5.02.00-k15

[SCSI] qla4xxx: Update driver version to 5.02.00-k15

Signed-off-by: Vikas Chaudhary <c251871a64d7d31888eace0406cb3d4c419d5f73@qlogic.com>
Signed-off-by: James Bottomley <1acebbdca565c7b6b638bdc23b58b5610d1a56b8@Parallels.com>


/*
 * Copyright 2014, NICTA
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(NICTA_BSD)
 */

#ifndef _UTILS_BUILTIN_H
#define _UTILS_BUILTIN_H
/* macros for accessing compiler builtins */

#include <assert.h>

#define CTZ(x) __builtin_ctz(x)
#define CLZ(x) __builtin_clz(x)
#define OFFSETOF(type, member) __builtin_offsetof(type, member)
#define TYPES_COMPATIBLE(t1, t2) __builtin_types_compatible_p(t1, t2)
#define CHOOSE_EXPR(cond, x, y) __builtin_choose_expr(cond, x, y)
#define IS_CONSTANT(expr) __builtin_constant_p(expr)
#define POPCOUNT(x) __builtin_popcount(x)
#define UNREACHABLE() \
    do { \
        assert(!"unreachable"); \
        __builtin_unreachable(); \
    } while (0)

#endif /* _UTILS_BUILTIN_H */

/*
 * Copyright 2014, NICTA
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(NICTA_BSD)
 */

#ifndef _UTILS_BUILTIN_H
#define _UTILS_BUILTIN_H
/* macros for accessing compiler builtins */

#include <assert.h>

#define CTZ(x) __builtin_ctz(x)
#define CLZ(x) __builtin_clz(x)
#define OFFSETOF(type, member) __builtin_offsetof(type, member)
#define TYPES_COMPATIBLE(t1, t2) __builtin_types_compatible_p(t1, t2)
#define CHOOSE_EXPR(cond, x, y) __builtin_choose_expr(cond, x, y)
#define IS_CONSTANT(expr) __builtin_constant_p(expr)
#define POPCOUNT(x) __builtin_popcount(x)
#define UNREACHABLE() \
    do { \
        assert(!"unreachable"); \
        __builtin_unreachable(); \
    } while (0)

/* Borrowed from linux/include/linux/compiler.h */
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)

#endif /* _UTILS_BUILTIN_H */

Add likely and unlikely macros.

Add likely and unlikely macros.


#ifndef __OBJ_APPLIED_SUB_H
#define __OBJ_APPLIED_SUB_H

#include "obj.h"

// stub object relating to ranger herbalism

class TASubstance : public TObj {
  public:
    virtual void assignFourValues(int, int, int, int) { }
    virtual void getFourValues(int *a, int *b, int *c, int *d) const { *a = *b = *c = *d = 0; }
    virtual sstring statObjInfo() const { return sstring(""); }

    virtual itemTypeT itemType() const {return ITEM_APPLIED_SUB; }

    TASubstance() { }
    TASubstance(const TASubstance &a) { }
    TASubstance & operator=(const TASubstance &a) {
      if (this == &a) return *this;
      TObj::operator=(a);
      return *this;
    }
    virtual ~TASubstance() { }
};

#endif

#ifndef __OBJ_APPLIED_SUB_H
#define __OBJ_APPLIED_SUB_H

#include "obj.h"

// stub object relating to ranger herbalism

class TASubstance : public TObj {
  public:
    virtual void assignFourValues(int, int, int, int) { }
    virtual void getFourValues(int *a, int *b, int *c, int *d) const { *a = *b = *c = *d = 0; }
    virtual sstring statObjInfo() const { return sstring(""); }
    virtual itemTypeT itemType() const {return ITEM_APPLIED_SUB; }
};

#endif

Remove empty constructors etc from TASubstance


/* */
#undef  VERSION
#define VERSION "1.37.17"
#define BDATE   "06 May 2005"
#define LSMDATE "06May05"

/* Debug flags */
#undef  DEBUG
#define DEBUG 1
#define TRACEBACK 1
#define SMCHECK
#define TRACE_FILE 1

/* If this is set stdout will not be closed on startup */
#define DEVELOPER 1

/* Debug flags not normally turned on */

/* #define TRACE_JCR_CHAIN 1 */
/* #define TRACE_RES 1 */
/* #define DEBUG_MEMSET 1 */
/* #define DEBUG_MUTEX 1 */

/* Check if header of tape block is zero before writing */
#define DEBUG_BLOCK_ZEROING 1

/* #define FULL_DEBUG 1 */   /* normally on for testing only */

/* Turn this on ONLY if you want all Dmsg() to append to the
 *   trace file. Implemented mainly for Win32 ...
 */
/*  #define SEND_DMSG_TO_FILE 1 */

/* The following are turned on for performance testing */
/* #define NO_ATTRIBUTES_TEST 1 */
/* #define NO_TAPE_WRITE_TEST 1 */
/* #define FD_NO_SEND TEST 1 */

/* */
#undef  VERSION
#define VERSION "1.37.17"
#define BDATE   "07 May 2005"
#define LSMDATE "07May05"

/* Debug flags */
#undef  DEBUG
#define DEBUG 1
#define TRACEBACK 1
#define SMCHECK
#define TRACE_FILE 1

/* If this is set stdout will not be closed on startup */
#define DEVELOPER 1

/* Debug flags not normally turned on */

/* #define TRACE_JCR_CHAIN 1 */
/* #define TRACE_RES 1 */
/* #define DEBUG_MEMSET 1 */
/* #define DEBUG_MUTEX 1 */

/* Check if header of tape block is zero before writing */
#define DEBUG_BLOCK_ZEROING 1

/* #define FULL_DEBUG 1 */   /* normally on for testing only */

/* Turn this on ONLY if you want all Dmsg() to append to the
 *   trace file. Implemented mainly for Win32 ...
 */
/*  #define SEND_DMSG_TO_FILE 1 */

/* The following are turned on for performance testing */
/* #define NO_ATTRIBUTES_TEST 1 */
/* #define NO_TAPE_WRITE_TEST 1 */
/* #define FD_NO_SEND TEST 1 */

Fix Win32 build for TLS

Fix Win32 build for TLS

git-svn-id: bb0627f6f70d46b61088c62c6186faa4b96a9496@2001 91ce42f0-d328-0410-95d8-f526ca767f89


// SKIP PARAM: --sets ana.activated[+] octApron --sets exp.solver.td3.side_widen cycle_self
// requires cycle_self to pass with protection
#include <pthread.h>
#include <assert.h>

int g = 25; // matches write in main
int h = 12; // matches write in main
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;

void *t_fun(void *arg) {
  int x; // rand
  pthread_mutex_lock(&A);
  g = x;
  h = x - 12;
  pthread_mutex_unlock(&A);
  return NULL;
}

int main(void) {
  int x, y;

  pthread_t id;
  pthread_create(&id, NULL, t_fun, NULL);

  pthread_mutex_lock(&A);
  g = 25;
  h = 12;
  pthread_mutex_unlock(&A);

  pthread_mutex_lock(&A);
  x = g;
  y = h;
  assert(x >= y); // write would fail this due to disjunctive reading from local and global
  pthread_mutex_unlock(&A);
  return 0;
}

Add relational traces example where write would fail


#include <libk/klog.h>

void initialize_klog() {
    initialize_serial_port(COM1);
    kputs("initing");
    write_serial_string(COM1, "Logger initialized\n");
    kputs("inited");
}
void klog(char *message) {
    write_serial_string(COM1, message);
}

#include <libk/klog.h>

void initialize_klog() {
    initialize_serial_port(COM1);
    write_serial_string(COM1, "Logger initialized!\n");
}
void klog(char *message) {
    write_serial_string(COM1, message);
}

Remove debugging lines from kernel logger


#pragma once

#include <type_traits>
#include <iostream>

namespace rc {
namespace detail {
namespace sfinae {

template<typename T, typename = decltype(std::declval<T>() == std::declval<T>())>
std::true_type isEqualityComparable(const T &);
std::false_type isEqualityComparable(...);

template<typename T, typename = decltype(std::cout << std::declval<T>())>
std::true_type isStreamInsertible(const T &);
std::false_type isStreamInsertible(...);

} // namespace sfinae

template<typename T>
using IsEqualityComparable = decltype(
    sfinae::isEqualityComparable(std::declval<T>()));

template<typename T>
using IsStreamInsertible = decltype(
    sfinae::isStreamInsertible(std::declval<T>()));

} // namespace detail
} // namespace rc

#pragma once

#include <type_traits>
#include <iostream>

namespace rc {
namespace detail {

#define RC_SFINAE_TRAIT(Name, expression)                               \
    namespace sfinae {                                                  \
    template<typename T, typename = expression>                         \
        std::true_type test##Name(const T &);                           \
        std::false_type test##Name(...);                                \
    }                                                                   \
                                                                        \
    template<typename T>                                                \
    using Name = decltype(sfinae::test##Name(std::declval<T>()));

RC_SFINAE_TRAIT(IsEqualityComparable,
                        decltype(std::declval<T>() == std::declval<T>()))

RC_SFINAE_TRAIT(IsStreamInsertible,
                        decltype(std::cout << std::declval<T>()))

} // namespace detail
} // namespace rc

Add macro to declare SFINAE based traits


/*
    This file is part of Android File Transfer For Linux.
    Copyright (C) 2015  Vladimir Menshakov

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

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

    You should have received a copy of the GNU General Public License
    along with Android File Transfer For Linux.
    If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef USB_USB_H
#define USB_USB_H

#include <usb/Exception.h>
#include <usb/usb.h>

#define USB_CALL(...) do { int _r_ = (__VA_ARGS__); if (_r_ != kIOReturnSuccess) throw mtp::usb::Exception(#__VA_ARGS__, _r_) ; } while(false)

#endif

/*
    This file is part of Android File Transfer For Linux.
    Copyright (C) 2015  Vladimir Menshakov

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

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

    You should have received a copy of the GNU General Public License
    along with Android File Transfer For Linux.
    If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef USB_USB_H
#define USB_USB_H

#include <usb/Exception.h>
#include <usb/usb.h>
#include <mtp/usb/DeviceNotFoundException.h>

#define USB_CALL(...) \
	do { int _r_ = (__VA_ARGS__); \
		switch(_r_) { \
			case kIOReturnSuccess  : break; \
			case kIOReturnNoDevice : throw mtp::usb::DeviceNotFoundException(); \
			default: throw mtp::usb::Exception(#__VA_ARGS__, _r_) ; \
		} \
	} while(false)

#endif

Add DeviceNotFoundException throw on mac


/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/*
 * Copyright (C) 2014 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
#ifndef __PHODAV_PATH_H__
#define __PHODAV_PATH_H__

#include "phodav-priv.h"

G_BEGIN_DECLS

struct _Path
{
  gchar         *path;
  GList         *locks;
  guint32        refs;
};

Path *                  path_ref                    (Path *path);
void                    path_unref                  (Path *path);
void                    path_remove_lock            (Path *path, DAVLock *lock);
void                    path_add_lock               (Path *path, DAVLock *lock);

G_END_DECLS

#endif /* __PHODAV_LOCK_H__ */

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
/*
 * Copyright (C) 2014 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
#ifndef __PHODAV_PATH_H__
#define __PHODAV_PATH_H__

#include "phodav-priv.h"

G_BEGIN_DECLS

struct _Path
{
  gchar         *path;
  GList         *locks;
  guint32        refs;
};

Path *                  path_ref                    (Path *path);
void                    path_unref                  (Path *path);
void                    path_remove_lock            (Path *path, DAVLock *lock);
void                    path_add_lock               (Path *path, DAVLock *lock);

G_END_DECLS

#endif /* __PHODAV_PATH_H__ */

libphodav: Fix the wrong comment on the header guard


/* A solution to Exercise 2-1 in The C Programming Language (Second Edition).
 */

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

int main(void)
{
  puts("Using macros from standard headers:");
  printf("  Range of \"char\": %d to %d\n", SCHAR_MIN, SCHAR_MAX);
  printf("  Range of \"unsigned char\": %d to %u\n", 0, UCHAR_MAX);
  printf("  Range of \"short\": %d to %d\n", SHRT_MIN, SHRT_MAX);
  printf("  Range of \"unsigned short\": %d to %u\n", 0, USHRT_MAX);
  printf("  Range of \"int\": %d to %d\n", INT_MIN, INT_MAX);
  printf("  Range of \"unsigned int\": %d to %u\n", 0, UINT_MAX);
  printf("  Range of \"long\": %ld to %ld\n", LONG_MIN, LONG_MAX);
  printf("  Range of \"unsigned long\": %d to %lu\n", 0, ULONG_MAX);
  printf("  Range of \"float\": %e to %e\n", FLT_MIN, FLT_MAX);
  printf("  Range of \"double\": %e to %e\n", DBL_MIN, DBL_MAX);
  printf("  Range of \"long double\": %Le to %Le\n", LDBL_MIN, LDBL_MAX);
  /* TODO: Compute ranges. */
  return EXIT_SUCCESS;
}

Add solution to Exercise 2-1.

Add solution to Exercise 2-1.


#include "local-loop.h"
#include "../voxtrees/search.h"

void vox_local_loop (struct vox_node *tree, int n, void (*action) (vox_rnd_context*), \
                     void (*inc) (vox_rnd_context*), vox_rnd_context *ctx)
{
    int i, state, pn;
    int depth = 1;
    vox_tree_path path;

    pn = vox_ray_tree_intersection (tree, ctx->origin, ctx->dir, ctx->inter, 1, path);
    state = pn;
    if (state) action (ctx);
    inc (ctx);

    for (i=0; i<n; i++)
    {
        if (state)
        {
            depth = vox_local_rays_tree_intersection (path, ctx->origin, ctx->dir, ctx->inter, depth, pn);
            state = depth;
        }
        if (!(state)) depth = vox_ray_tree_intersection (tree, ctx->origin, ctx->dir, ctx->inter, 1, path);

        if (depth) action (ctx);
        inc (ctx);
    }
}

#include "local-loop.h"
#include "../voxtrees/search.h"

void vox_local_loop (struct vox_node *tree, int n, void (*action) (vox_rnd_context*), \
                     void (*inc) (vox_rnd_context*), vox_rnd_context *ctx)
{
    int i, state, pn;
    int depth = 1;
    vox_tree_path path;

    pn = vox_ray_tree_intersection (tree, ctx->origin, ctx->dir, ctx->inter, 1, path);
    state = pn;
    if (state) action (ctx);
    inc (ctx);

    for (i=1; i<n; i++)
    {
        if (state)
        {
            depth = vox_local_rays_tree_intersection (path, ctx->origin, ctx->dir, ctx->inter, depth, pn);
            state = depth;
        }
        if (!(state)) depth = vox_ray_tree_intersection (tree, ctx->origin, ctx->dir, ctx->inter, 1, path);

        if (depth) action (ctx);
        inc (ctx);
    }
}

Make renderer to work properly

Make renderer to work properly


/*
 * This program handles SIGINT and forwards it to another process.
 * It is intended to be run as PID 1.
 *
 * Docker starts processes with "docker run" as PID 1.
 * On Linux, the default signal handler for PID 1 ignores any signals.
 * Therefore Ctrl-C aka SIGINT is ignored per default.
 */

#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>

int pid = 0;

void
handle_sigint (int signum)
{
  if(pid)
    kill(pid, SIGINT);
}

int main(int argc, char *argv[]){
  struct sigaction new_action;
  int status = -1;

  /* Set up the structure to specify the new action. */
  new_action.sa_handler = handle_sigint;
  sigemptyset (&new_action.sa_mask);
  new_action.sa_flags = 0;

  sigaction (SIGINT, &new_action, (void*)0);

  pid = fork();
  if(pid){
    wait(&status);
    return WEXITSTATUS(status);
  }else{
    status = execvp(argv[1], &argv[1]);
    perror("exec");
    return status;
  }
}

/*
 * This program handles SIGINT and forwards it to another process.
 * It is intended to be run as PID 1.
 *
 * Docker starts processes with "docker run" as PID 1.
 * On Linux, the default signal handler for PID 1 ignores any signals.
 * Therefore Ctrl-C aka SIGINT is ignored per default.
 */

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

int pid = 0;

void
handle_sigint (int signum)
{
  if(pid)
    kill(pid, SIGINT);
}

int main(int argc, char *argv[]){
  struct sigaction new_action;
  int status = -1;

  /* Set up the structure to specify the new action. */
  new_action.sa_handler = handle_sigint;
  sigemptyset (&new_action.sa_mask);
  new_action.sa_flags = 0;

  sigaction (SIGINT, &new_action, (void*)0);

  pid = fork();
  if(pid){
    wait(&status);
    return WEXITSTATUS(status);
  }else{
    status = execvp(argv[1], &argv[1]);
    perror("exec");
    return status;
  }
}

Add missing includes for fork() and perror()


Fix warnings and errors brought up by VS2012 code analyzer.


/**************************************************************************************************
 * File name    : ViewController.h
 * Description  : Define the ViewController class.
 * Creator      : Frederick Hsu
 * Creation date: Thu.  23 Feb. 2017
 * Copyright(C  2017    All rights reserved.
 *
 **************************************************************************************************/

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

    + (void)initialize;
    - (instancetype)init;
    - (instancetype)initWithCoder:(NSCoder *)coder;
    - (void)awakeFromNib;
    - (void)loadView;
    - (void)viewDidLoad;
    - (void)viewWillLayoutSubviews;
    - (void)viewDidLayoutSubviews;
    - (void)didReceiveMemoryWarning;
    - (void)viewDidAppear:(BOOL)animated;
    - (void)viewWillAppear:(BOOL)animated;
    - (void)viewWillDisappear:(BOOL)animated;
    - (void)viewDidDisappear:(BOOL)animated;
    - (void)dealloc;

    - (void)changeColor;

@end

/**************************************************************************************************
 * File name    : ViewController.h
 * Description  : Define the ViewController class.
 * Creator      : Frederick Hsu
 * Creation date: Thu.  23 Feb. 2017
 * Copyright(C  2017    All rights reserved.
 *
 **************************************************************************************************/

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController

    @property (atomic, readwrite) UILabel *switchOnLabel;
    @property (atomic, readwrite) UILabel *switchOffLabel;

    + (void)initialize;
    - (instancetype)init;
    - (instancetype)initWithCoder:(NSCoder *)coder;
    - (void)awakeFromNib;
    - (void)loadView;
    - (void)viewDidLoad;
    - (void)viewWillLayoutSubviews;
    - (void)viewDidLayoutSubviews;
    - (void)didReceiveMemoryWarning;
    - (void)viewDidAppear:(BOOL)animated;
    - (void)viewWillAppear:(BOOL)animated;
    - (void)viewWillDisappear:(BOOL)animated;
    - (void)viewDidDisappear:(BOOL)animated;
    - (void)dealloc;

    - (void)changeColor;
    - (void)changeHint:(UISwitch *)userSwitch;

@end

Insert 2 UILabel as property : *switchOnLabel, *switchOffLabel, allow the action function - (void)changeHint:(UISwitch *)userSwitch; to access them.


/*=========================================================================

  Program: GDCM (Grassroots DICOM). A DICOM library
  Module:  $URL$

  Copyright (c) 2006-2010 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#ifndef GDCM_ZLIB_H
#define GDCM_ZLIB_H

/* Use the zlib library configured for gdcm.  */
#include "gdcmTypes.h"
#ifdef GDCM_USE_SYSTEM_ZLIB
// $ dpkg -S /usr/include/zlib.h
// zlib1g-dev: /usr/include/zlib.h
# include <zlib.h>
#else
# include <gdcmzlib/zlib.h>
#endif

#endif

/*=========================================================================

  Program: GDCM (Grassroots DICOM). A DICOM library
  Module:  $URL$

  Copyright (c) 2006-2010 Mathieu Malaterre
  All rights reserved.
  See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
#ifndef GDCM_ZLIB_H
#define GDCM_ZLIB_H

/* Use the zlib library configured for gdcm.  */
#include "gdcmTypes.h"
#ifdef GDCM_USE_SYSTEM_ZLIB
// $ dpkg -S /usr/include/zlib.h
// zlib1g-dev: /usr/include/zlib.h
# include <itk_zlib.h>
#else
# include <gdcmzlib/zlib.h>
#endif

#endif

Make sure to use proper name mangling

Make sure to use proper name mangling


#ifndef CLIENTVERSION_H
#define CLIENTVERSION_H

//
// client versioning
//

// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR       1
#define CLIENT_VERSION_MINOR       2
#define CLIENT_VERSION_REVISION    0
#define CLIENT_VERSION_BUILD       0

// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE  true

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
#define STRINGIZE(X) DO_STRINGIZE(X)
#define DO_STRINGIZE(X) #X

#endif // CLIENTVERSION_H

#ifndef CLIENTVERSION_H
#define CLIENTVERSION_H

//
// client versioning
//

// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR       1
#define CLIENT_VERSION_MINOR       2
#define CLIENT_VERSION_REVISION    0
#define CLIENT_VERSION_BUILD       1

// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE  true

// Converts the parameter X to a string after macro replacement on X has been performed.
// Don't merge these into one macro!
#define STRINGIZE(X) DO_STRINGIZE(X)
#define DO_STRINGIZE(X) #X

#endif // CLIENTVERSION_H

Update Client Version for New Code Base

Update Client Version for New Code Base


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

#pragma once

#include <Windows.h>

#include "../HotkeyProcessor.h"
#include "../MeterWnd/MeterWnd.h"
#include "../Settings.h"
#include "../Window.h"
#include "OSDType.h"

class Monitor;

class OSD : HotkeyProcessor, protected Window {
public:
    OSD(LPCWSTR className, HINSTANCE hInstance = NULL);

    virtual void Hide() = 0;
    virtual void ProcessHotkeys(HotkeyInfo &hki);

    bool Enabled();
    void Enabled(bool enabled);

protected:
    HWND _masterWnd;
    Settings *_settings;

    void HideOthers(OSDType except);

    void InitMeterWnd(MeterWnd &mWnd);

    std::vector<Monitor> ActiveMonitors();
    void PositionWindow(Monitor monitor, LayeredWnd &lWnd);
    void CenterWindowX(Monitor monitor, LayeredWnd &lWnd);
    void CenterWindowY(Monitor monitor, LayeredWnd &lWnd);

    virtual LRESULT WndProc(HWND hWnd, UINT message,
        WPARAM wParam, LPARAM lParam);

private:
    bool _enabled;
};

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

#pragma once

#include <Windows.h>

#include "../HotkeyProcessor.h"
#include "../MeterWnd/MeterWnd.h"
#include "../Settings.h"
#include "../Window.h"
#include "OSDType.h"

class Monitor;

class OSD : HotkeyProcessor, protected Window {
public:
    OSD(LPCWSTR className, HINSTANCE hInstance = NULL);

    virtual void Hide() = 0;
    virtual void ProcessHotkeys(HotkeyInfo &hki);

    bool Enabled();
    void Enabled(bool enabled);

    /// <summary>
    /// This method is called when the system display configuration has changed,
    /// which includes monitors being removed or plugged in.
    /// </summary>
    virtual void OnDisplayChange() = 0;

protected:
    HWND _masterWnd;
    Settings *_settings;

    void HideOthers(OSDType except);

    void InitMeterWnd(MeterWnd &mWnd);

    std::vector<Monitor> ActiveMonitors();
    void PositionWindow(Monitor monitor, LayeredWnd &lWnd);
    void CenterWindowX(Monitor monitor, LayeredWnd &lWnd);
    void CenterWindowY(Monitor monitor, LayeredWnd &lWnd);

    virtual LRESULT WndProc(HWND hWnd, UINT message,
        WPARAM wParam, LPARAM lParam);

private:
    bool _enabled;
};

Add the interface method for OnDisplayChange


// Harshad Kasture
//
// This file declares the user level message passing functions used in multithreaded applications
// for the multicore simulator.

#ifndef CAPI_H
#define CAPI_H

typedef int CAPI_return_t;

typedef int CAPI_endpoint_t;

// externed so the names don't get name-mangled
//extern "C" {

   CAPI_return_t CAPI_Initialize(int *rank);

   CAPI_return_t CAPI_rank(int * rank);

   CAPI_return_t CAPI_message_send_w(CAPI_endpoint_t send_endpoint, CAPI_endpoint_t receive_endpoint,
                                     char * buffer, int size);

   CAPI_return_t CAPI_message_receive_w(CAPI_endpoint_t send_endpoint, CAPI_endpoint_t receive_endpoint,
                                        char * buffer, int size);
//}

#endif

// Harshad Kasture
//
// This file declares the user level message passing functions used in multithreaded applications
// for the multicore simulator.

#ifndef CAPI_H
#define CAPI_H

typedef int CAPI_return_t;

typedef int CAPI_endpoint_t;

#ifdef __cplusplus
// externed so the names don't get name-mangled
extern "C" {
#endif

   CAPI_return_t CAPI_Initialize(int *rank);

   CAPI_return_t CAPI_rank(int * rank);

   CAPI_return_t CAPI_message_send_w(CAPI_endpoint_t send_endpoint, CAPI_endpoint_t receive_endpoint,
                                     char * buffer, int size);

   CAPI_return_t CAPI_message_receive_w(CAPI_endpoint_t send_endpoint, CAPI_endpoint_t receive_endpoint,
                                        char * buffer, int size);

#ifdef __cplusplus
}
#endif

#endif

Add guarded 'extern "C"' attributes so that this header files can be used from both C and C++ programs.


#include <stdio.h>
#include <sys/select.h>

/* pselect loop test */
int main(int argc, char *argv[])
{
	struct timespec timeout;
	fd_set readfds;
	int fdcount;

	while(1){
		FD_ZERO(&readfds);
		FD_SET(0, &readfds);
		timeout.tv_sec = 1;
		timeout.tv_nsec = 0;

		fdcount = pselect(1, &readfds, NULL, NULL, &timeout, NULL);
		printf("loop %d\n", fdcount);
	}
	return 0;
}

#include <stdio.h>
#include <sys/select.h>

/* pselect loop test */
int main(int argc, char *argv[])
{
	struct timespec timeout;
	fd_set readfds;
	int fdcount;
	char buf[1024];

	while(1){
		FD_ZERO(&readfds);
		FD_SET(0, &readfds);
		timeout.tv_sec = 1;
		timeout.tv_nsec = 0;

		fdcount = pselect(1, &readfds, NULL, NULL, &timeout, NULL);
		printf("loop %d\n", fdcount);

		if(FD_ISSET(0, &readfds)){
			read(0, buf, 1024);
			printf("buf: %s\n", buf);
		}
	}
	return 0;
}

Watch for input from stdin and print it.


#ifndef	EVENT_SYSTEM_H
#define	EVENT_SYSTEM_H

#include <event/event_thread.h>

/*
 * XXX
 * This is kind of an awful shim while we move
 * towards something thread-oriented.
 */

class EventSystem {
	EventThread td_;
private:
	EventSystem(void)
	: td_()
	{ }

	~EventSystem()
	{ }

public:
	Action *poll(const EventPoll::Type& type, int fd, EventCallback *cb)
	{
		return (td_.poll(type, fd, cb));
	}

	Action *register_interest(const EventInterest& interest, Callback *cb)
	{
		return (td_.register_interest(interest, cb));
	}

	Action *schedule(Callback *cb)
	{
		return (td_.schedule(cb));
	}

	Action *timeout(unsigned ms, Callback *cb)
	{
		return (td_.timeout(ms, cb));
	}

	void start(void)
	{
		td_.start();

		td_.join();
	}

	static EventSystem *instance(void)
	{
		static EventSystem *instance;

		if (instance == NULL)
			instance = new EventSystem();
		return (instance);
	}
};

#endif /* !EVENT_SYSTEM_H */

Add EventSystem shim missed in r588.

Add EventSystem shim missed in r588.

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


// Copyright 2020 Google LLC
//
// 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
//
//      https://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.

// This file defines a helper to trigger the registration of all translations
// in and out of MLIR to the system.
//
// Based on MLIR's InitAllTranslations but without translations we don't care
// about.

#ifndef IREE_TOOLS_INIT_TRANSLATIONS_H_
#define IREE_TOOLS_INIT_TRANSLATIONS_H_

namespace mlir {

void registerFromLLVMIRTranslation();
void registerToLLVMIRTranslation();
void registerToSPIRVTranslation();

// This function should be called before creating any MLIRContext if one
// expects all the possible translations to be made available to the context
// automatically.
inline void registerMlirTranslations() {
  static bool init_once = []() {
    registerFromLLVMIRTranslation();
    registerToLLVMIRTranslation();
    registerToSPIRVTranslation();
    return true;
  }();
  (void)init_once;
}
}  // namespace mlir

#endif  // IREE_TOOLS_INIT_TRANSLATIONS_H_

Implement forked registerAllTranslations() as registerMlirTranslations()

With https://reviews.llvm.org/D77515, the need for static global ctors is removed from `mlir-translate` and thus can be also removed from `iree-translate`. This already forks the header file `mlir/include/mlir/InitAllTranslations.h` and removes translations not used so far within IREE.

Closes https://github.com/google/iree/pull/1395

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/iree/pull/1395 from iml130:init_translations b7688209ed86e78ef1ac19fde17eb1d5e172a21c
PiperOrigin-RevId: 305148353


#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
	int val;
	struct Node *next;
}Node;

Node* Push(Node *p, int val){
	Node *temp = (struct Node*)malloc(sizeof(struct Node));
	temp->val = val;
	temp->next = p;
	p = temp;
	return p;
}

void Pop(Node *p){
	if(p == NULL)
		return;
	printf("%p\n",p);
	Node *temp = p;
	p = p->next;
	printf("%p\n",p);
	free(temp);
	printf("%p\n",temp);
}

void PRINT(Node *p){
	Node *temp = p;
	while(temp != NULL){
		printf("%d ",temp->val);
		temp = 	temp->next;
	}
	printf("\n");
}

int main(){
	Node *head = NULL;
	head = Push(head,3);
	head = Push(head,6);
	head = Push(head,2);
	head = Push(head,1);
	head = Push(head,9);
	PRINT(head);
	head = Pop(head);
	head = Pop(head);
	head = Pop(head);
	PRINT(head);
}

#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
	int val;
	struct Node *next;
}Node;

Node* Push(Node *p, int val){
	Node *temp = (struct Node*)malloc(sizeof(struct Node));
	temp->val = val;
	temp->next = p;
	p = temp;
	return p;
}

Node* Pop(Node *p){
	if(p == NULL)
		return;
	Node *temp = p;
	p = p->next;
	free(temp);
	return p;
}

void PRINT(Node *p){
	Node *temp = p;
	while(temp != NULL){
		printf("%d ",temp->val);
		temp = 	temp->next;
	}
	printf("\n");
}

int main(){
	Node *head = NULL;
	head = Push(head,3);
	head = Push(head,6);
	head = Push(head,2);
	head = Push(head,1);
	head = Push(head,9);
	PRINT(head);
	head = Pop(head);
	head = Pop(head);
	head = Pop(head);
	PRINT(head);
}

Implement stack with single linked list

Implement stack with single linked list


//
//  MBImageRequest.h
//  MBRequest
//
//  Created by Sebastian Celis on 3/6/12.
//  Copyright (c) 2012 Mobiata, LLC. All rights reserved.
//

#if __IPHONE_OS_VERSION_MIN_REQUIRED
#import <UIKit/UIKit.h>
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#import <Cocoa/Cocoa.h>
#endif

#import "MBHTTPRequest.h"

#if __IPHONE_OS_VERSION_MIN_REQUIRED
typedef void (^MBRequestImageCompletionHandler)(UIImage *image, NSError *error);
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
typedef void (^MBRequestImageCompletionHandler)(NSImage *image, NSError *error);
#endif

@interface MBImageRequest : MBHTTPRequest

// The image returned in the response.
@property (atomic, retain, readonly) UIImage *responseImage;

// Performs a basic request and notifies the caller with any data downloaded.
- (void)performImageRequest:(NSURLRequest *)request completionHandler:(MBRequestImageCompletionHandler)completionHandler;

// The callback for image requests.
@property (nonatomic, copy, readonly) MBRequestImageCompletionHandler imageCompletionHandler;

@end

//
//  MBImageRequest.h
//  MBRequest
//
//  Created by Sebastian Celis on 3/6/12.
//  Copyright (c) 2012 Mobiata, LLC. All rights reserved.
//

#if __IPHONE_OS_VERSION_MIN_REQUIRED
#import <UIKit/UIKit.h>
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
#import <Cocoa/Cocoa.h>
#endif

#import "MBHTTPRequest.h"

#if __IPHONE_OS_VERSION_MIN_REQUIRED
typedef void (^MBRequestImageCompletionHandler)(UIImage *image, NSError *error);
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
typedef void (^MBRequestImageCompletionHandler)(NSImage *image, NSError *error);
#endif

@interface MBImageRequest : MBHTTPRequest

// The image returned in the response.
#if __IPHONE_OS_VERSION_MIN_REQUIRED
@property (atomic, retain, readonly) UIImage *responseImage;
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
@property (atomic, retain, readonly) NSImage *responseImage;
#endif

// Performs a basic request and notifies the caller with any data downloaded.
- (void)performImageRequest:(NSURLRequest *)request completionHandler:(MBRequestImageCompletionHandler)completionHandler;

// The callback for image requests.
@property (nonatomic, copy, readonly) MBRequestImageCompletionHandler imageCompletionHandler;

@end

Fix reference to UIImage when compiled for OS X.


#ifndef __ASM_SH_FTRACE_H
#define __ASM_SH_FTRACE_H

#ifdef CONFIG_FUNCTION_TRACER

#define MCOUNT_INSN_SIZE	4 /* sizeof mcount call */
#define FTRACE_SYSCALL_MAX	(NR_syscalls - 1)

#ifndef __ASSEMBLY__
extern void mcount(void);

#define MCOUNT_ADDR		((long)(mcount))

#ifdef CONFIG_DYNAMIC_FTRACE
#define CALL_ADDR		((long)(ftrace_call))
#define STUB_ADDR		((long)(ftrace_stub))
#define GRAPH_ADDR		((long)(ftrace_graph_call))
#define CALLER_ADDR		((long)(ftrace_caller))

#define MCOUNT_INSN_OFFSET	((STUB_ADDR - CALL_ADDR) - 4)
#define GRAPH_INSN_OFFSET	((CALLER_ADDR - GRAPH_ADDR) - 4)

struct dyn_arch_ftrace {
	/* No extra data needed on sh */
};

#endif /* CONFIG_DYNAMIC_FTRACE */

static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
	/* 'addr' is the memory table address. */
	return addr;
}

#endif /* __ASSEMBLY__ */
#endif /* CONFIG_FUNCTION_TRACER */

#endif /* __ASM_SH_FTRACE_H */

#ifndef __ASM_SH_FTRACE_H
#define __ASM_SH_FTRACE_H

#ifdef CONFIG_FUNCTION_TRACER

#define MCOUNT_INSN_SIZE	4 /* sizeof mcount call */
#define FTRACE_SYSCALL_MAX	NR_syscalls

#ifndef __ASSEMBLY__
extern void mcount(void);

#define MCOUNT_ADDR		((long)(mcount))

#ifdef CONFIG_DYNAMIC_FTRACE
#define CALL_ADDR		((long)(ftrace_call))
#define STUB_ADDR		((long)(ftrace_stub))
#define GRAPH_ADDR		((long)(ftrace_graph_call))
#define CALLER_ADDR		((long)(ftrace_caller))

#define MCOUNT_INSN_OFFSET	((STUB_ADDR - CALL_ADDR) - 4)
#define GRAPH_INSN_OFFSET	((CALLER_ADDR - GRAPH_ADDR) - 4)

struct dyn_arch_ftrace {
	/* No extra data needed on sh */
};

#endif /* CONFIG_DYNAMIC_FTRACE */

static inline unsigned long ftrace_call_adjust(unsigned long addr)
{
	/* 'addr' is the memory table address. */
	return addr;
}

#endif /* __ASSEMBLY__ */
#endif /* CONFIG_FUNCTION_TRACER */

#endif /* __ASM_SH_FTRACE_H */

Fix an off-by-1 in FTRACE_SYSCALL_MAX.

sh: Fix an off-by-1 in FTRACE_SYSCALL_MAX.

This is supposed to be the equivalent of __NR_syscalls, not
__NR_syscalls -1. The x86 code this was based on had simply fallen
out of sync at the time this was implemented. Fix it up now.

As a result, tracing of __NR_perf_counter_open works as advertised.

Signed-off-by: Paul Mundt <38b52dbb5f0b63d149982b6c5de788ec93a89032@linux-sh.org>


//
//  LolayHttpClientGlobals.h
//  LolayHttpClientGlobals
//
//  Created by Bruce Johnson on 5/9/14.
//  Copyright (c) 2014 Lolay. All rights reserved.
//

#if DEBUG
#	define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#	define NSLog(...) NSLog(__VA_ARGS__)
#else
#	define DLog(fmt, ...) {}
#	define NSLog(...) {}
#endif

//
//  LolayHttpClientGlobals.h
//  LolayHttpClientGlobals
//
//  Created by Bruce Johnson on 5/9/14.
//  Copyright (c) 2014 Lolay. All rights reserved.
//

#ifndef DLog
#if DEBUG
#	define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#	define NSLog(...) NSLog(__VA_ARGS__)
#else
#	define DLog(fmt, ...) {}
#	define NSLog(...) {}
#endif
#endif

Add a check to see if DLog is already defined.


#include<stdio.h>

/* CALC GREATEST COMMON DIVISOR BY EUCLIDES ALGORITHM
 * r -> remainder
 * q -> quotient
 */
int calc_gcd(int n1, int n2, int r, int q){
    if (r == 0)
        return n2;
    return calc_gcd(n2,r,n2 % r, n2 / r);
}

/* FIRE UP THE FUNCTION GCD
 */
int gcd(int n1, int n2){
    if ( n1 > n2 )
        return calc_gcd(n1, n2, n1 % n2, n1 / n2);
    return calc_gcd(n2, n1, n2 % n1, n2 / n1);
}

int main(){
    int n1=2366, n2=273;
    printf("gcd= %d ",gcd(n1,n2));
    return 0;
}

#include<stdio.h>

/* CALC GREATEST COMMON DIVISOR BY EUCLIDES ALGORITHM
 * r -> remainder
 * q -> quotient
 */
int calc_gcd(int n1, int n2, int r, int q){
    if (r == 0)
        return n2;
    return calc_gcd(n2,r,n2 % r, n2 / r);
}

/* FIRE UP THE FUNCTION GCD
 */
int gcd(int n1, int n2){
    if ( n1 > n2 )
        return calc_gcd(n1, n2, n1 % n2, n1 / n2);
    return calc_gcd(n2, n1, n2 % n1, n2 / n1);
}

/*
int main(){
    int n1=2366, n2=273;
    printf("gcd= %d ",gcd(n1,n2));
    return 0;
}
*/

Comment the main for import as a library in the function of the least common divisor (LCD)


/*ckwg +5
 * Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
 * KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
 * Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
 */

#ifndef VISTK_TEST_TEST_COMMON_H
#define VISTK_TEST_TEST_COMMON_H

#define EXPECT_EXCEPTION(exc, code, action)        \
  do                                               \
  {                                                \
    bool got_exception = false;                    \
                                                   \
    try                                            \
    {                                              \
      code;                                        \
    }                                              \
    catch (exc& e)                                 \
    {                                              \
      got_exception = true;                        \
                                                   \
      (void)e.what();                              \
    }                                              \
    catch (std::exception& e)                      \
    {                                              \
      std::cerr << "Error: Unexpected exception: " \
                << e.what() << std::endl;          \
                                                   \
      got_exception = true;                        \
    }                                              \
                                                   \
    if (!got_exception)                            \
    {                                              \
      std::cerr << "Error: Did not get "           \
                   "expected exception when "      \
                << action << std::endl;            \
    }                                              \
  } while (false)

#endif // VISTK_TEST_TEST_COMMON_H

/*ckwg +5
 * Copyright 2011 by Kitware, Inc. All Rights Reserved. Please refer to
 * KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
 * Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
 */

#ifndef VISTK_TEST_TEST_COMMON_H
#define VISTK_TEST_TEST_COMMON_H

#define TEST_ERROR(msg)                         \
  do                                            \
  {                                             \
    std::cerr << "Error: " << msg << std::endl; \
  } while (false)

#define EXPECT_EXCEPTION(ex, code, action)  \
  do                                        \
  {                                         \
    bool got_exception = false;             \
                                            \
    try                                     \
    {                                       \
      code;                                 \
    }                                       \
    catch (ex& e)                           \
    {                                       \
      got_exception = true;                 \
                                            \
      (void)e.what();                       \
    }                                       \
    catch (std::exception& e)               \
    {                                       \
      TEST_ERROR("Unexpected exception: "   \
                 << e.what());              \
                                            \
      got_exception = true;                 \
    }                                       \
                                            \
    if (!got_exception)                     \
    {                                       \
      TEST_ERROR("Did not get "             \
                 "expected exception when " \
                 << action);                \
    }                                       \
  } while (false)

#endif // VISTK_TEST_TEST_COMMON_H

Add macro for errors in tests

Add macro for errors in tests


//! \file

#ifndef JSONSERIALIZER_H
#define JSONSERIALIZER_H

#include <iostream>

#include "ArticleCollection.h"

namespace WikiWalker
{
  /*! Serialize AricleCollection from and to a custom JSON format
   */
  class JsonSerializer
  {
  public:
    /*! Serialize ArticleCollection to JSON in an output stream
     * \param a pointer to article to be output
     * \param os out stream to putput to.
     * YOU are responsible for opening and closing the stream
     */
    void serialize(const ArticleCollection& collection,
                   std::ostream& outstream);
  };
}
#endif  // JSONSERIALIZER_H

//! \file

#ifndef WIKIWALKER_JSONSERIALIZER_H
#define WIKIWALKER_JSONSERIALIZER_H

#include <iostream>

#include "ArticleCollection.h"

namespace WikiWalker
{
  /*! Serialize AricleCollection from and to a custom JSON format
   */
  class JsonSerializer
  {
  public:
    /*! Serialize ArticleCollection to JSON in an output stream
     * \param a pointer to article to be output
     * \param os out stream to putput to.
     * YOU are responsible for opening and closing the stream
     */
    void serialize(const ArticleCollection& collection,
                   std::ostream& outstream);
  };
}
#endif  // WIKIWALKER_JSONSERIALIZER_H

Apply prefix to include guard

Apply prefix to include guard


#ifndef MATH_CONTAINER
#define MATH_CONTAINER

#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cmath>

/********************************/
/*Find the index during the sort*/
/********************************/
template<typename T> class CompareIndicesByAnotherVectorValues
{
    const std::vector<T>* values;
    public:
    CompareIndicesByAnotherVectorValues(const std::vector<T>* val) : values(val) {}
    bool operator() (const size_t & a, const size_t & b) const { return (*values)[a] < (*values)[b]; }
};

template <typename T>
std::vector<size_t> sort_indexes(const std::vector<T> &v)
{
    // initialize original index locations
    std::vector<size_t> idx(v.size());
    for (size_t i = 0; i != idx.size(); ++i) idx[i] = i;

    CompareIndicesByAnotherVectorValues<T> idex_comp(&v);
    // sort indexes based on comparing values in v
    std::sort(idx.begin(), idx.end(), idex_comp);

    return idx;
}

/******************************************************/
/*solve the equation cosh(x)=exp(y), input y, return x*/
/******************************************************/
std::complex<double> coshx_eq_expy(double y);

#endif

#ifndef MATH_CONTAINER_H
#define MATH_CONTAINER_H

#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cmath>

/********************************/
/*Find the index during the sort*/
/********************************/
template<typename T> class CompareIndicesByAnotherVectorValues
{
    const std::vector<T>* values;
    public:
    CompareIndicesByAnotherVectorValues(const std::vector<T>* val) : values(val) {}
    bool operator() (const size_t & a, const size_t & b) const { return (*values)[a] < (*values)[b]; }
};

template <typename T>
std::vector<size_t> sort_indexes(const std::vector<T> &v)
{
    // initialize original index locations
    std::vector<size_t> idx(v.size());
    for (size_t i = 0; i != idx.size(); ++i) idx[i] = i;

    CompareIndicesByAnotherVectorValues<T> idex_comp(&v);
    // sort indexes based on comparing values in v
    std::sort(idx.begin(), idx.end(), idex_comp);

    return idx;
}

/******************************************************/
/*solve the equation cosh(x)=exp(y), input y, return x*/
/******************************************************/
std::complex<double> coshx_eq_expy(double y);

#endif

Set the header protection to end with _H.


#ifndef SCHEME_BASIC_TYPES_H
#define SCHEME_BASIC_TYPES_H

#include "SchemeType.h"

extern const SchemeType SchemeBool;
extern const SchemeCons *const SchemeBoolTrue;
extern const SchemeCons *const SchemeBoolFalse;
extern const SchemeType SchemeTuple;
extern const SchemeCons *const SchemeTupleTuple;
extern const SchemeType SchemeList;
extern const SchemeCons *const SchemeListCons;
extern const SchemeCons *const SchemeListEmpty;
extern const SchemeType SchemeOption;
extern const SchemeCons *const SchemeOptionNone;
extern const SchemeCons *const SchemeOptionSome;
extern const SchemeType SchemeEither;

#endif /* !SCHEME_BASIC_TYPES_H */

#ifndef SCHEME_BASIC_TYPES_H
#define SCHEME_BASIC_TYPES_H

#include "SchemeType.h"

extern const SchemeType SchemeBool;
extern const SchemeCons *const SchemeBoolTrue;
extern const SchemeCons *const SchemeBoolFalse;
extern const SchemeType SchemeTuple;
extern const SchemeCons *const SchemeTupleTuple;
extern const SchemeType SchemeList;
extern const SchemeCons *const SchemeListCons;
extern const SchemeCons *const SchemeListEmpty;
extern const SchemeType SchemeOption;
extern const SchemeCons *const SchemeOptionNone;
extern const SchemeCons *const SchemeOptionSome;
extern const SchemeType SchemeEither;

static void
SchemeMarshalBool(Scheme *context, bool value)
{
  SchemeObj *val = &context->value;
  val->hdr.kind = SCHEME_KIND_VAL;
  val->hdr.variant = value ?
    SchemeBoolTrue->hdr.variant : SchemeBoolFalse->hdr.variant;
  val->hdr.size = 0;
  val->word.type = &SchemeBool;
}

#endif /* !SCHEME_BASIC_TYPES_H */

Add function for marshaling C booleans into Scheme.


//
//  LRImageOperation+Private.h
//  iShows
//
//  Created by Luis Recuenco on 19/05/13.
//  Copyright (c) 2013 Luis Recuenco. All rights reserved.
//

#import "LRImageOperation.h"

@interface LRImageOperation (Private)

// Inputs
@property (nonatomic, strong, readonly) NSURL *url;
@property (nonatomic, assign, readonly) CGSize size;
@property (nonatomic, assign, readonly) BOOL diskCache;
@property (nonatomic, assign, readonly) LRCacheStorageOptions storageOptions;
@property (nonatomic, strong, readonly) NSMutableArray *completionHandlers;

// Outputs
@property (nonatomic, strong, readonly) UIImage *image;
@property (nonatomic, strong, readonly) NSError *error;

@end

Move LRImageOperation inputs and outputs to an appropriate category


//===--- CodeGen/ModuleBuilder.h - Build LLVM from ASTs ---------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines the ModuleBuilder interface.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_CODEGEN_MODULEBUILDER_H
#define LLVM_CLANG_CODEGEN_MODULEBUILDER_H

#include "clang/AST/ASTConsumer.h"
#include <string>

namespace llvm {
  class LLVMContext;
  class Module;
}

namespace clang {
  class Diagnostic;
  class LangOptions;
  class CodeGenOptions;

  class CodeGenerator : public ASTConsumer {
  public:
    virtual llvm::Module* GetModule() = 0;
    virtual llvm::Module* ReleaseModule() = 0;
  };

  CodeGenerator *CreateLLVMCodeGen(Diagnostic &Diags,
                                   const std::string &ModuleName,
                                   const CodeGenOptions &CGO,
                                   llvm::LLVMContext& C);
}

#endif

//===--- CodeGen/ModuleBuilder.h - Build LLVM from ASTs ---------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines the ModuleBuilder interface.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_CODEGEN_MODULEBUILDER_H
#define LLVM_CLANG_CODEGEN_MODULEBUILDER_H

#include "clang/AST/ASTConsumer.h"
#include <string>

namespace llvm {
  class LLVMContext;
  class Module;
}

namespace clang {
  class Diagnostic;
  class LangOptions;
  class CodeGenOptions;

  class CodeGenerator : public ASTConsumer {
  public:
    virtual llvm::Module* GetModule() = 0;
    virtual llvm::Module* ReleaseModule() = 0;
  };

  /// CreateLLVMCodeGen - Create a CodeGenerator instance.
  /// It is the responsibility of the caller to call delete on
  /// the allocated CodeGenerator instance.
  CodeGenerator *CreateLLVMCodeGen(Diagnostic &Diags,
                                   const std::string &ModuleName,
                                   const CodeGenOptions &CGO,
                                   llvm::LLVMContext& C);
}

#endif

Add a comment to mention the memory ownership situation.

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


/** @file
  Base Library CPU Functions for all architectures.

  Copyright (c) 2006 - 2008, Intel Corporation<BR>
  All rights reserved. This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#include <Base.h>
#include <Library/BaseLib.h>

/**
  Executes an infinite loop.

  Forces the CPU to execute an infinite loop. A debugger may be used to skip
  past the loop and the code that follows the loop must execute properly. This
  implies that the infinite loop must not cause the code that follow it to be
  optimized away.

**/
VOID
EFIAPI
CpuDeadLoop (
  VOID
  )
{
  volatile UINTN  Index;

  for (Index = 0; 0 == Index;);
}

/** @file
  Base Library CPU Functions for all architectures.

  Copyright (c) 2006 - 2008, Intel Corporation<BR>
  All rights reserved. This program and the accompanying materials
  are licensed and made available under the terms and conditions of the BSD License
  which accompanies this distribution.  The full text of the license may be found at
  http://opensource.org/licenses/bsd-license.php

  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#include <Base.h>
#include <Library/BaseLib.h>

/**
  Executes an infinite loop.

  Forces the CPU to execute an infinite loop. A debugger may be used to skip
  past the loop and the code that follows the loop must execute properly. This
  implies that the infinite loop must not cause the code that follow it to be
  optimized away.

**/
VOID
EFIAPI
CpuDeadLoop (
  VOID
  )
{
  volatile UINTN  Index;

  for (Index = 0; Index == 0;);
}

Change style 0 == Index to Index == 0

Change style 0 == Index to Index == 0

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@7493 6f19259b-4bc3-4df7-8a09-765794883524


#ifndef TLSCA_SVR__ALL_H_
#define TLSCA_SVR__ALL_H_

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

#include <ft.h>
#include <tlsca.h>
#include <seacatcc.h>

struct sca_app;
extern struct sca_app sca_app;

#include "config.h"
#include "app.h"
#include "reactor.h"
#include "cntl.h"

#endif //TLSCA_SVR__ALL_H_

#ifndef TLSCA_SVR__ALL_H_
#define TLSCA_SVR__ALL_H_

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

#include <ft.h>
#include <tlsca.h>
#include <seacatcc.h>

struct sca_app;
extern struct sca_app sca_app;

#include "config.h"
#include "app.h"
#include "reactor.h"
#include "cntl.h"

enum sca_frame_type
{
	FT_FRAME_TYPE_SEACATCC_WRITE = 0xFFFFF001,
	FT_FRAME_TYPE_SEACATCC_READ  = 0xFFFFF002,
};

#endif //TLSCA_SVR__ALL_H_

Add a new frame types.

Add a new frame types.


//
//  NSSortDescriptor+Essentials.h
//  Essentials
//
//  Created by Martin Kiss on 11.4.14.
//  Copyright (c) 2014 iAdverti. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum : BOOL {
    ESSSortDescending = NO,
    ESSSortAscending = YES,
} ESSSort;

@interface NSSortDescriptor (Essentials)

+ (instancetype)sortAscending:(BOOL)ascending;
+ (instancetype)sortAscending:(BOOL)ascending selector:(SEL)selector;

+ (instancetype)randomSortDescriptor;

+ (instancetype)sortDescriptorForViewOriginX;
+ (instancetype)sortDescriptorForViewOriginY;

@end

#define ESSSort(Class, keyPath, ascend) \
(NSSortDescriptor *)({ \
    [NSSortDescriptor sortDescriptorWithKey:@#keyPath ascending:ESSSort##ascend]; \
})

#define ESSSortUsing(Class, keyPath, ascend, compareSelector) \
(NSSortDescriptor *)({ \
    if (NO) { \
        Class *object = nil; \
        __unused NSComparisonResult r = [object.keyPath compareSelector object.keyPath]; \
    } \
    SEL selector = NSSelectorFromString(@#compareSelector); \
    [NSSortDescriptor sortDescriptorWithKey:@#keyPath ascending:ESSSort##ascend selector:selector]; \
})

//
//  NSSortDescriptor+Essentials.h
//  Essentials
//
//  Created by Martin Kiss on 11.4.14.
//  Copyright (c) 2014 iAdverti. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum : BOOL {
    ESSSortDescending = NO,
    ESSSortAscending = YES,
} ESSSort;

@interface NSSortDescriptor (Essentials)

+ (instancetype)sortAscending:(BOOL)ascending;
+ (instancetype)sortAscending:(BOOL)ascending selector:(SEL)selector;

+ (instancetype)randomSortDescriptor;

+ (instancetype)sortDescriptorForViewOriginX;
+ (instancetype)sortDescriptorForViewOriginY;

@end

#define ESSSort(Class, keyPath, ascend) \
(NSSortDescriptor *)({ \
    if (NO) { \
        Class *object = nil; \
        (void)object.keyPath; \
    } \
    [NSSortDescriptor sortDescriptorWithKey:@#keyPath ascending:ESSSort##ascend]; \
})

#define ESSSortUsing(Class, keyPath, ascend, compareSelector) \
(NSSortDescriptor *)({ \
    if (NO) { \
        Class *object = nil; \
        (void)object.keyPath; \
    } \
    SEL selector = NSSelectorFromString(@#compareSelector); \
    [NSSortDescriptor sortDescriptorWithKey:@#keyPath ascending:ESSSort##ascend selector:selector]; \
})

Fix ESSSort to work with non-object properties


#import "Expecta.h"

EXPMatcherInterface(_equal, (id expected));
EXPMatcherInterface(equal, (id expected)); // to aid code completion
#define equal(expected) _equal(EXPObjectify((expected)))

#import "Expecta.h"

EXPMatcherInterface(_equal, (id expected));
EXPMatcherInterface(equal, (id expected)); // to aid code completion
#define equal(...) _equal(EXPObjectify((__VA_ARGS__)))

Make usage of NSArray literals a little bit simpler in equal()

This allows to write something like expect(array).to.equal(@[ @"a", @"b", @"c" ]) without additional parentheses around the array literal.


#ifndef __PROCEDURALMAZE_H__
#define __PROCEDURALMAZE_H__

#include "maze.h"
#include <map>

class ProceduralMaze
{
	private:
		int width;
		int height;

	public:
		std::map<std::tuple<int, int>, int> grid;
		ProceduralMaze(int width, int height);

		void generate();
		void clearGrid();
		std::vector<std::tuple<int, int>> getAdjCells(std::tuple<int, int> center, Tile tile_state);
};

#endif

#ifndef __PROCEDURALMAZE_H__
#define __PROCEDURALMAZE_H__

#include "maze.h"
#include <map>

class ProceduralMaze
{
	private:
		int width;
		int height;
		std::map<std::tuple<int, int>, int> grid;

		void clearGrid();
		std::vector<std::tuple<int, int>> getAdjCells(std::tuple<int, int> center, Tile tile_state);

	public:
		ProceduralMaze(int width, int height);

		void generate();
		void print();
		std::map<std::tuple<int, int>, int> getGrid() { return grid; }
};

#endif

Move some ProceduralMaze public methods to private


#include <stdio.h>

int main() {
    // Declare a variable named 'input_string' to hold our input.
    char input_string[105];

    // Read a full line of input from stdin and save it to our variable, input_string.
    scanf("%[^\n]", input_string);

    // Print a string literal saying "Hello, World." to stdout using printf.
    printf("Hello, World.\n");

    // TODO: Write a line of code here that prints the contents of input_string to stdout.
    printf("%s", input_string);

    return 0;
}

Add 30 Days of Code Day 0 in C.

Add 30 Days of Code Day 0 in C.