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

#ifndef ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_
#define ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

inline uint16_t bswap_16(uint16_t n) { return __builtin_bswap16(n); }

inline uint32_t bswap_32(uint32_t n) { return __builtin_bswap32(n); }

inline uint64_t bswap_64(uint64_t n) { return __builtin_bswap64(n); }

#ifdef __cplusplus
}
#endif

#endif  // ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_

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

#ifndef ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_
#define ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

static inline uint16_t bswap_16(uint16_t n) { return __builtin_bswap16(n); }

static inline uint32_t bswap_32(uint32_t n) { return __builtin_bswap32(n); }

static inline uint64_t bswap_64(uint64_t n) { return __builtin_bswap64(n); }

#ifdef __cplusplus
}
#endif

#endif  // ASYLO_PLATFORM_POSIX_INCLUDE_BYTESWAP_H_

Declare bswap functions as static inline

Change declaration to static inline to avoid multiple definition
during linking.

PiperOrigin-RevId: 207000800


#ifndef PATH_INTEGRATOR_H
#define PATH_INTEGRATOR_H

#include "surface_integrator.h"
#include "renderer/renderer.h"

/*
 * Surface integrator that uses Path tracing for computing illumination at a point on the surface
 */
class PathIntegrator : public SurfaceIntegrator {
	const int min_depth, max_depth;

public:
	/*
	 * Create the path tracing integrator and set the min and max depth for paths
	 * rays are randomly stopped by Russian roulette after reaching min_depth and are stopped
	 * at max_depth
	 */
	PathIntegrator(int min_depth, int max_depth);
	/*
	 * Compute the illumination at a point on a surface in the scene
	 */
	Colorf illumination(const Scene &scene, const Renderer &renderer, const RayDifferential &ray,
		DifferentialGeometry &dg, Sampler &sampler, MemoryPool &pool) const override;

private:
	/*
	 * Trace a camera path starting from the first hit at dg returning the throughput of the
	 * path and the BSDF of the last object hit and the direction we hit it from so that we
	 * can connect the path to a light path
	 */
	Colorf trace_camera(const Scene &scene, const Renderer &renderer, const RayDifferential &ray,
		DifferentialGeometry &dg, Sampler &sampler, MemoryPool &pool, BSDF *&bsdf, Vector &w_o) const;
	/*
	 * Trace a light path returning the illumination along the path and the BSDF of
	 * of the last object hit and the direction we hit it from so that we
	 */
	Colorf trace_light(const Scene &scene, const Renderer &renderer, Sampler &sampler,
		MemoryPool &pool, BSDF *&bsdf, Vector &w_o) const;
};

#endif

#ifndef PATH_INTEGRATOR_H
#define PATH_INTEGRATOR_H

#include "surface_integrator.h"
#include "renderer/renderer.h"

/*
 * Surface integrator that uses Path tracing for computing illumination at a point on the surface
 */
class PathIntegrator : public SurfaceIntegrator {
	const int min_depth, max_depth;

public:
	/*
	 * Create the path tracing integrator and set the min and max depth for paths
	 * rays are randomly stopped by Russian roulette after reaching min_depth and are stopped
	 * at max_depth
	 */
	PathIntegrator(int min_depth, int max_depth);
	/*
	 * Compute the illumination at a point on a surface in the scene
	 */
	Colorf illumination(const Scene &scene, const Renderer &renderer, const RayDifferential &ray,
		DifferentialGeometry &dg, Sampler &sampler, MemoryPool &pool) const override;
};

#endif

Remove the unused bidir functions from path tracer


/*
 * A solution to Exercise 1-2 in The C Programming Language (Second Edition).
 *
 * This file was written by Damien Dart, <damiendart@pobox.com>. This is free
 * and unencumbered software released into the public domain. For more
 * information, please refer to the accompanying "UNLICENCE" file.
 */

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

int main(void)
{
  puts("\\a produces an audible or visual alert: \a");
  puts("\\f produces a formfeed: \f");
  puts("\\r produces a carriage return: \rlololol");
  puts("\\v produces a vertical tab: \t");
  return EXIT_SUCCESS;
}

/*
 * A solution to Exercise 1-2 in The C Programming Language (Second Edition).
 *
 * This file was written by Damien Dart, <damiendart@pobox.com>. This is free
 * and unencumbered software released into the public domain. For more
 * information, please refer to the accompanying "UNLICENCE" file.
 */

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

int main(void)
{
  puts("An audible or visual alert: \a");
  puts("A form feed: \f");
  puts("A carriage return: \r");
  puts("A vertical tab: \v");
  return EXIT_SUCCESS;
}

Fix solution to Exercise 1-2.

Fix solution to Exercise 1-2.


/*
 * This file is part of buxton.
 *
 * Copyright (C) 2013 Intel Corporation
 *
 * buxton 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.
 */

#pragma once

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

#ifdef DEBUG
#define buxton_debug() buxton_log()
#else
#define buxton_debug do {} while(0);
#endif /* DEBUG */

void buxton_log(const char* fmt, ...);

/*
 * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 *
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
 * :indentSize=8:tabSize=8:noTabs=false:
 */

/*
 * This file is part of buxton.
 *
 * Copyright (C) 2013 Intel Corporation
 *
 * buxton 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.
 */

#pragma once

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

#ifdef DEBUG
#define buxton_debug(...) buxton_log(__VA_ARGS__)
#else
#define buxton_debug(...) do {} while(0);
#endif /* DEBUG */

void buxton_log(const char* fmt, ...);

/*
 * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 8
 * tab-width: 8
 * indent-tabs-mode: t
 * End:
 *
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
 * :indentSize=8:tabSize=8:noTabs=false:
 */

Fix the buxton_debug macro to support arguments


/*
 * system_res.h
 *
 * Author: Ben Lai, Ming Tsang, Peggy Lau
 * Copyright (c) 2014-2015 HKUST SmartCar Team
 * Refer to LICENSE for details
 */

namespace camera
{

struct SystemRes
{

};

}

/*
 * system_res.h
 *
 * Author: Ben Lai, Ming Tsang, Peggy Lau
 * Copyright (c) 2014-2015 HKUST SmartCar Team
 * Refer to LICENSE for details
 */

namespace camera
{

class Car;

}

namespace camera
{

struct SystemRes
{
	Car *car;
};

}

Add car to system res

Add car to system res


#ifndef EVENT_DETECTION_H
#    define EVENT_DETECTION_H

#    include "scrappie_structures.h"

typedef struct {
    size_t window_length1;
    size_t window_length2;
    float threshold1;
    float threshold2;
    float peak_height;
} detector_param;

static detector_param const event_detection_defaults = {
    .window_length1 = 3,
    .window_length2 = 6,
    .threshold1 = 1.4f,
    .threshold2 = 1.1f,
    .peak_height = 0.2f
};

event_table detect_events(raw_table const rt, detector_param const edparam);

#endif                          /* EVENT_DETECTION_H */

#ifndef EVENT_DETECTION_H
#    define EVENT_DETECTION_H

#    include "scrappie_structures.h"

typedef struct {
    size_t window_length1;
    size_t window_length2;
    float threshold1;
    float threshold2;
    float peak_height;
} detector_param;

static detector_param const event_detection_defaults = {
    .window_length1 = 3,
    .window_length2 = 6,
    .threshold1 = 1.4f,
    .threshold2 = 9.0f,
    .peak_height = 0.2f
};

event_table detect_events(raw_table const rt, detector_param const edparam);

#endif                          /* EVENT_DETECTION_H */

Update threshold for second window

Update threshold for second window


#pragma once

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

    __host__ __device__
    FixedVector() { }

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

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

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

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

#pragma once

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

    __host__ __device__
    FixedVector() : data() { }

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

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

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

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

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


#ifndef	FILE_DESCRIPTOR_H
#define	FILE_DESCRIPTOR_H

#include <io/channel.h>

class FileDescriptor : public Channel {
	LogHandle log_;
protected:
	int fd_;
public:
	FileDescriptor(int);
	~FileDescriptor();

	virtual Action *close(EventCallback *);
	virtual Action *read(size_t, EventCallback *);
	virtual Action *write(Buffer *, EventCallback *);

	virtual bool shutdown(bool, bool)
	{
		return (false);
	}
};

#endif /* !FILE_DESCRIPTOR_H */

#ifndef	FILE_DESCRIPTOR_H
#define	FILE_DESCRIPTOR_H

#include <io/channel.h>

class FileDescriptor : public Channel {
	LogHandle log_;
protected:
	int fd_;
public:
	FileDescriptor(int);
	~FileDescriptor();

	virtual Action *close(EventCallback *);
	virtual Action *read(size_t, EventCallback *);
	virtual Action *write(Buffer *, EventCallback *);

	virtual bool shutdown(bool, bool)
	{
		return (true);
	}
};

#endif /* !FILE_DESCRIPTOR_H */

Return success rather than failure from shutdown() on FileDescriptor, since it is entirely immaterial.


// RUN: %clang_analyze_cc1 -analyzer-checker=core \
// RUN:  -analyzer-dump-egraph=%t.dot %s
// RUN: cat %t.dot | FileCheck %s

// RUN: %clang_analyze_cc1 -analyzer-checker=core \
// RUN:  -analyzer-dump-egraph=%t.dot \
// RUN:  -trim-egraph %s
// RUN: cat %t.dot | FileCheck %s

// REQUIRES: asserts

int getJ();

int foo() {
  int *x = 0, *y = 0;
  char c = '\x13';

  return *x + *y;
}

// CHECK: \"program_points\": [\l    \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null, \"node_id\": 1, \"is_sink\":0, \"has_report\": 0 \}\l  ],\l  \"program_state\": null

// CHECK: \"program_points\": [\l    \{ \"kind\": \"BlockEntrance\", \"block_id\": 1

// CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, \"file\": \"{{(.+)}}dump_egraph.c\" \}

// CHECK: \"pretty\": \"'\\\\x13'\"

// CHECK: \"has_report\": 1

// RUN: %clang_analyze_cc1 -analyzer-checker=core \
// RUN:  -analyzer-dump-egraph=%t.dot %s
// RUN: cat %t.dot | FileCheck %s

// RUN: %clang_analyze_cc1 -analyzer-checker=core \
// RUN:  -analyzer-dump-egraph=%t.dot \
// RUN:  -trim-egraph %s
// RUN: cat %t.dot | FileCheck %s

// REQUIRES: asserts

int getJ();

int foo() {
  int *x = 0, *y = 0;
  char c = '\x13';

  return *x + *y;
}

// CHECK: \"program_points\": [\l    \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 \}\l  ],\l  \"program_state\": null

// CHECK: \"program_points\": [\l    \{ \"kind\": \"BlockEntrance\", \"block_id\": 1

// CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, \"file\": \"{{(.+)}}dump_egraph.c\" \}

// CHECK: \"pretty\": \"'\\\\x13'\"

// CHECK: \"has_report\": 1

Fix typo in r375186. Unbreaks tests.

[analyzer] exploded-graph-rewriter: Fix typo in r375186. Unbreaks tests.

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


#ifndef LOG_TESTFW_H
#define LOG_TESTFW_H

#include <stdio.h>

#define NEUTRAL "\x1B[0m"
#define GREEN   "\x1B[32m"
#define RED     "\x1B[31m"

void testfw_add(void (*)(int*), const char*);
int testfw_run();

#define TEST(name) void name(int*); void __attribute__((constructor)) pre_##name() {testfw_add(name, #name);} void name(int* __errors __attribute__((unused)))

#define FAILED(name) fprintf(stderr, "[ %sFAILED%s ] %s (%s:%d)\n", RED, NEUTRAL, name, __FILE__, __LINE__)
#define PASSED(name) printf("[ %sPASSED%s ] %s\n", GREEN, NEUTRAL, name);

#define ASSERT(stmt) if (!(stmt)) {++(*__errors); FAILED(__FUNCTION__);}

#endif

#ifndef LOG_TESTFW_H
#define LOG_TESTFW_H

#include <stdio.h>

#define NEUTRAL "\x1B[0m"
#define GREEN   "\x1B[32m"
#define RED     "\x1B[31m"

void testfw_add(void (*)(int*), const char*);
int testfw_run();

#define TEST(name) void name(int*); void __attribute__((constructor)) pre_##name() {testfw_add(name, #name);} void name(int* __errors __attribute__((unused)))

#define FAILED(name) fprintf(stderr, "[ %sFAILED%s ] %s (%s:%d)\n", RED, NEUTRAL, name, __FILE__, __LINE__)
#define PASSED(name) printf("[ %sPASSED%s ] %s\n", GREEN, NEUTRAL, name);

#define ASSERT(stmt) if (!(stmt)) {++(*__errors); FAILED(__func__);}

#endif

Use __func__ instead of __FUNCTION__

Use __func__ instead of __FUNCTION__

__FUNCTION__ does not work with gcc version 5.
https://gcc.gnu.org/gcc-5/porting_to.html.


/*
name: TEST062
description: Test for hexadecimal numbers in upper and lower case
error:
output:
G2	I	F	"main
{
\
	h	#I1
}
*/

int
main(void)
{
	return 0xa == 0xA &&
	       0xb == 0xB &&
	       0xc == 0xC &&
	       0xd == 0xD &&
	       0xe == 0xE &&
	       0xf == 0xF;
}

[cc1] Add test for hexadecimal numbers with upper and lower case


#include <testharness.h>
#include <stdio.h>

void BuildWord(char * pchWord) {
    int i;
    char * pch = pchWord;

    /* original code:
     * while ((i = *pch++) != '\0') { }
     */

    do {
      i = *pch;
      pch++;
    } while (i != '\0');

    printf("%s\n",pchWord);
}

int main() {
  char *test = "foo";

  BuildWord(test);

  SUCCESS;
}

#include <testharness.h>
#include <stdio.h>

void BuildWord(char * pchWord) {
    int i;
    char * pch = pchWord;

    /* original code:
     * while ((i = *pch++) != '\0') { }
     */

    do {
      i = *pch;
      // printf("i = '%c'\n",i);
      pch++;
    } while (i != '\0');

    printf("%s\n",pchWord);
}

int main() {
  char *test = "foo";

  test++;
  test--;

  BuildWord(test);

  SUCCESS;
}

Switch the world over to the new 'paper' solver. Local regression tests indicate that it shouldn't be that bad: new models and wrappers have been added to support it. INFERBOX=infer is now the new solver, INFERBOX=old gives the old behavior (will be removed later).


#ifndef _ZT_STDINT_H_
#define _ZT_STDINT_H_

#if !defined(_MSC_VER) || _MSC_VER >= 1600
#include <stdint.h>
#else
typedef __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif

#endif

#ifndef _ZT_STDINT_H_
#define _ZT_STDINT_H_

#if !defined(_MSC_VER) || _MSC_VER >= 1600
#include <stdint.h>
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif

#endif

Use integer types that are consistent with what tend to be the
underlying types for stdint typedefs

Windows treats signed char and __int8 as distinct types.


// This file contains default configuration settings for MicroPython.
// You can override any of these options using mpconfigport.h file located
// in a directory of your port.

#include <mpconfigport.h>

#ifndef INT_FMT
// printf format spec to use for machine_int_t and friends
#ifdef __LP64__
// Archs where machine_int_t == long, long != int
#define UINT_FMT "%lu"
#define INT_FMT "%ld"
#else
// Archs where machine_int_t == int
#define UINT_FMT "%u"
#define INT_FMT "%d"
#endif
#endif //INT_FMT

// Any options not explicitly set in mpconfigport.h will get default
// values below.

// Whether to collect memory allocation stats
#ifndef MICROPY_MEM_STATS
#define MICROPY_MEM_STATS (1)
#endif

// Whether to support slice object and correspondingly
// slice subscript operators
#ifndef MICROPY_ENABLE_SLICE
#define MICROPY_ENABLE_SLICE (1)
#endif

Enable slice support in config.

Enable slice support in config.


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <area51/hashmap.h>
#include <area51/list.h>
#include <area51/log.h>
#include <libxml/xmlreader.h>
#include <nre/reference.h>
#include <nre/schedule.h>

/*
 * Callback to add a schedule to the crs locations map
 */
static bool indexAll(void *k, void *v, void *c) {
    int *ridId = k;
    struct Schedule *sched = v;
    struct Schedules *s = c;

    Node *n = list_getHead(&sched->locations);
    while (list_isNode(n)) {
        struct SchedLoc *sl = (struct SchedLoc *) n;
        n = list_getNext(n);

        struct LocationRef *l = hashmapGet(s->ref->tiploc, &sl->tpl);
        if (l && l->crs > 0)
            hashmapAddList(s->crs, &l->crs, s);
    }

    return true;
}

/**
 * Index all schedules adding them to the crs hashmap so we have a list of entries for each station
 * @param s
 */
void indexSchedules(struct Schedules *s) {
    logconsole("Indexing %d schedules", hashmapSize(s->schedules));

    // Run through each crs
    hashmapForEach(s->schedules, indexAll, s);
}

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <area51/hashmap.h>
#include <area51/list.h>
#include <area51/log.h>
#include <nre/reference.h>
#include <nre/schedule.h>

/*
 * Callback to add a schedule to the crs locations map
 */
static bool indexAll(void *k, void *v, void *c) {
    int *ridId = k;
    struct Schedule *sched = v;
    struct Schedules *s = c;

    Node *n = list_getHead(&sched->locations);
    while (list_isNode(n)) {
        struct SchedLoc *sl = (struct SchedLoc *) n;
        n = list_getNext(n);

        struct LocationRef *l = hashmapGet(s->ref->tiploc, &sl->tpl);
        if (l && l->crs > 0)
            hashmapAddList(s->crs, &l->crs, sched);
    }

    return true;
}

/**
 * Index all schedules adding them to the crs hashmap so we have a list of entries for each station
 * @param s
 */
void indexSchedules(struct Schedules *s) {
    logconsole("Indexing %d schedules", hashmapSize(s->schedules));

    // Run through each crs
    hashmapForEach(s->schedules, indexAll, s);
}

Index schedule not the main struct

Index schedule not the main struct


//#define TREE

// A mapping of a chunk of an address space to
// a specific memory object.
enum vmatype { PRIVATE, COW};
struct vma {
  uptr va_start;               // start of mapping
  uptr va_end;                 // one past the last byte
  enum vmatype va_type;
  struct vmnode *n;
  struct spinlock lock;        // serialize fault/unmap
  char lockname[16];
};

// A memory object (physical pages or inode).
enum vmntype { EAGER, ONDEMAND};
struct vmnode {
  u64 npages;
  char *page[128];
  u64 ref;
  enum vmntype type;
  struct inode *ip;
  u64 offset;
  u64 sz;
};

// An address space: a set of vmas plus h/w page table.
// The elements of e[] are not ordered by address.
struct vmap {
#ifdef TREE
  // struct node* root;
  struct crange* cr;
#else
  struct vma* e[16];
#endif
  struct spinlock lock;        // serialize map/lookup/unmap
  u64 ref;
  u64 alloc;
  pml4e_t *pml4;               // Page table
  char lockname[16];
};

Disable crange while fixing bugs in other systems.


/*
 * Copyright (c) 1995 Ugen J.S.Antsilevich
 *
 * Redistribution and use in source forms, with and without modification,
 * are permitted provided that this entire comment appears intact.
 *
 * Redistribution in binary form may occur without any restrictions.
 * Obviously, it would be nice if you gave credit where credit is due
 * but requiring it would be too onerous.
 *
 * This software is provided ``AS IS'' without any warranties of any kind.
 *
 * Snoop stuff.
 *
 * $FreeBSD$
 */

#ifndef _SYS_SNOOP_H_
#define	_SYS_SNOOP_H_

#include <sys/ioccom.h>

/*
 * Theese are snoop io controls
 * SNPSTTY accepts 'struct snptty' as input.
 * If ever type or  unit set to -1,snoop device
 * detached from its current tty.
 */

#define SNPSTTY       _IOW('T', 90, dev_t)
#define SNPGTTY       _IOR('T', 89, dev_t)

/*
 * Theese values would be returned by FIONREAD ioctl
 * instead of number of characters in buffer in case
 * of specific errors.
 */
#define SNP_OFLOW		-1
#define SNP_TTYCLOSE		-2
#define SNP_DETACH		-3

#endif /* !_SYS_SNOOP_H_ */

/*
 * Copyright (c) 1995 Ugen J.S.Antsilevich
 *
 * Redistribution and use in source forms, with and without modification,
 * are permitted provided that this entire comment appears intact.
 *
 * Redistribution in binary form may occur without any restrictions.
 * Obviously, it would be nice if you gave credit where credit is due
 * but requiring it would be too onerous.
 *
 * This software is provided ``AS IS'' without any warranties of any kind.
 *
 * Snoop stuff.
 *
 * $FreeBSD$
 */

#ifndef _SYS_SNOOP_H_
#define	_SYS_SNOOP_H_

#ifndef _KERNEL
#include <sys/types.h>
#endif
#include <sys/ioccom.h>

/*
 * Theese are snoop io controls
 * SNPSTTY accepts 'struct snptty' as input.
 * If ever type or  unit set to -1,snoop device
 * detached from its current tty.
 */

#define SNPSTTY       _IOW('T', 90, dev_t)
#define SNPGTTY       _IOR('T', 89, dev_t)

/*
 * Theese values would be returned by FIONREAD ioctl
 * instead of number of characters in buffer in case
 * of specific errors.
 */
#define SNP_OFLOW		-1
#define SNP_TTYCLOSE		-2
#define SNP_DETACH		-3

#endif /* !_SYS_SNOOP_H_ */

Include <sys/types.h> in the !_KERNEL case so that this file is self-sufficient in that case (it needs dev_t). This is normal pollution for most headers that define ioctl numbers.


#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       0
#define CLIENT_VERSION_REVISION    1
#define CLIENT_VERSION_BUILD       0

// 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       0
#define CLIENT_VERSION_REVISION    0
#define CLIENT_VERSION_BUILD       0

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

Revert "client version to 1.0.1"

Revert "client version to 1.0.1"

This reverts commit 4d1baddde849c46969e1d189224cc1a507c33b01.


//#####################################################################
// Function Dot
//#####################################################################
#pragma once

namespace other {

template<class T,int d> class Vector;

inline float dot(const float a1,const float a2)
{return a1*a2;}

inline double dot(const double a1,const double a2)
{return a1*a2;}

template<class T,int d>
inline double dot_double_precision(const Vector<T,d>& v1,const Vector<T,d>& v2)
{return dot(v1,v2);}

inline double dot_double_precision(const float a1,const float a2)
{return a1*a2;}

inline double dot_double_precision(const double a1,const double a2)
{return a1*a2;}

}

//#####################################################################
// Function Dot
//#####################################################################
#pragma once

namespace other {

template<class T,int d> class Vector;

static inline float dot(const float a1,const float a2)
{return a1*a2;}

static inline double dot(const double a1,const double a2)
{return a1*a2;}

template<class T,int d>
static inline double dot_double_precision(const Vector<T,d>& v1,const Vector<T,d>& v2)
{return dot(v1,v2);}

static inline double dot_double_precision(const float a1,const float a2)
{return a1*a2;}

static inline double dot_double_precision(const double a1,const double a2)
{return a1*a2;}

}

Mark some functions static inline

vector/dot: Mark some functions static inline


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

int main(int argc, char* argv[]) {
  int f;
  if (argc > 1)
    f = open(argv[1], O_RDONLY);
  else
    f = open("aa", O_RDONLY);
  int i, readCount;
  char buffer[5];

  for(i = 5; i >= 1; --i) {
    execlp("wc", "wc", "-l", "aa", 0);
    lseek(f, -3, SEEK_END);
    readCount = read(f, buffer, i);
    write(1, buffer, readCount);
  }

  return 0;
}

Add old file from week1

Add old file from week1


#pragma once

#include <stdint.h>
#include <climits>

//#define TYPE_DOUBLE

#ifdef TYPE_DOUBLE
	using real = double;
#else
	using real = float;
#endif

#pragma once

#include <stdint.h>
#include <climits>

//#define TYPE_DOUBLE

#ifdef TYPE_DOUBLE
	using real = double;
	#define AT_IS_TYPE_DOUBLE	(true)
#else
	using real = float;
	#define AT_IS_TYPE_DOUBLE	(false)
#endif

Add macro to know if "real" is double.

Add macro to know if "real" is double.


/*
* License: BSD-style license
* Copyright: Radek Podgorny <radek@podgorny.cz>,
*            Bernd Schubert <bernd-schubert@gmx.de>
*/

#ifndef UNIONFS_H
#define UNIONFS_H

#define PATHLEN_MAX 1024
#define HIDETAG "_HIDDEN~"

#define METANAME ".unionfs-fuse"
#define METADIR (METANAME  "/") // string concetanation!

// fuse meta files, we might want to hide those
#define FUSE_META_FILE ".fuse_hidden"
#define FUSE_META_LENGTH 12

// file access protection mask
#define S_PROT_MASK (S_ISUID| S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)

typedef struct {
	char *path;
	int path_len;		// strlen(path)
	int fd;			 // used to prevent accidental umounts of path
	unsigned char rw;	 // the writable flag
} branch_entry_t;

#endif

/*
* License: BSD-style license
* Copyright: Radek Podgorny <radek@podgorny.cz>,
*            Bernd Schubert <bernd-schubert@gmx.de>
*/

#ifndef UNIONFS_H
#define UNIONFS_H

#define PATHLEN_MAX 1024
#define HIDETAG "_HIDDEN~"

#define METANAME ".unionfs"
#define METADIR (METANAME  "/") // string concetanation!

// fuse meta files, we might want to hide those
#define FUSE_META_FILE ".fuse_hidden"
#define FUSE_META_LENGTH 12

// file access protection mask
#define S_PROT_MASK (S_ISUID| S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)

typedef struct {
	char *path;
	int path_len;		// strlen(path)
	int fd;			 // used to prevent accidental umounts of path
	unsigned char rw;	 // the writable flag
} branch_entry_t;

#endif

Revert to old pre-1.0 meta directory

Revert to old pre-1.0 meta directory

Unionfs changed its meta directory from .unionfs to .unionfs-fuse with the
unionfs -> unionfs-fuse rename.  The rename later got reverted everywhere
but the meta directory, so now unionfs doesn't find the whiteout files from
older releases.

Revert back to the pre-1.0 behaviour to fix this.

Signed-off-by: Peter Korsgaard <4b8373d016f277527198385ba72fda0feb5da015@korsgaard.com>


#ifndef HEADER_OPENSSLV_H
#define HEADER_OPENSSLV_H

/* Numeric release version identifier:
 * MMNNFFRBB: major minor fix final beta/patch
 * For example:
 * 0.9.3-dev	  0x00903000
 * 0.9.3beta1	  0x00903001
 * 0.9.3beta2-dev 0x00903002
 * 0.9.3beta2     0x00903002 (same as ...beta2-dev)
 * 0.9.3	  0x00903100
 * 0.9.3a	  0x00903101
 * 0.9.4 	  0x00904100
 * 1.2.3z	  0x1020311a
 * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
 */
#define OPENSSL_VERSION_NUMBER	0x00905002L
#define OPENSSL_VERSION_TEXT	"OpenSSL 0.9.5beta2-dev 24 Feb 2000"
#define OPENSSL_VERSION_PTEXT	" part of " OPENSSL_VERSION_TEXT

#endif /* HEADER_OPENSSLV_H */

#ifndef HEADER_OPENSSLV_H
#define HEADER_OPENSSLV_H

/* Numeric release version identifier:
 * MMNNFFRBB: major minor fix final beta/patch
 * For example:
 * 0.9.3-dev	  0x00903000
 * 0.9.3beta1	  0x00903001
 * 0.9.3beta2-dev 0x00903002
 * 0.9.3beta2     0x00903002 (same as ...beta2-dev)
 * 0.9.3	  0x00903100
 * 0.9.3a	  0x00903101
 * 0.9.4 	  0x00904100
 * 1.2.3z	  0x1020311a
 * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.)
 */
#define OPENSSL_VERSION_NUMBER	0x00905002L
#define OPENSSL_VERSION_TEXT	"OpenSSL 0.9.5beta2 27 Feb 2000"
#define OPENSSL_VERSION_PTEXT	" part of " OPENSSL_VERSION_TEXT

#endif /* HEADER_OPENSSLV_H */

Change version string to reflect the release of beta 2.


#ifndef __BOOT_H__
#define __BOOT_H__

/* multiboot definitions */
#define MB_HEADER_MAGIC 0x1BADB002
#define MB_BOOT_MAGIC   0x2BADB002
#define MB_PAGE_ALIGN   0x00000001
#define MB_MEMORY_INFO  0x00000002

/* common boot definitions */
#define BOOT_TIME_STACK_SIZE 0x4000

#endif /*__BOOT_H__*/

#ifndef __BOOT_H__
#define __BOOT_H__

/* multiboot definitions */
#define MB_HEADER_MAGIC 0x1BADB002
#define MB_BOOT_MAGIC   0x2BADB002
#define MB_PAGE_ALIGN   0x00000001
#define MB_MEMORY_INFO  0x00000002

/* common boot definitions */
#define BOOT_TIME_STACK_SIZE 0x4000

#define BOOT_CS_ENTRY        1
#define BOOT_CS              (BOOT_CS_ENTRY << 3)
#define BOOT_DS_ENTRY        2
#define BOOT_DS              (BOOT_DS_ENTRY << 3)

#define PTE_INIT_ATTR        0x00000003
#define PDE_INIT_ATTR        0x00000003

#endif /*__BOOT_H__*/

Add code and data segments definitions.

Add code and data segments definitions.

This patch adds boot time data and code segments definitions.


/*
 * Unit tests for libkvkontakte.
 * Copyright (C) 2015  Alexander Potashev <aspotashev@gmail.com>
 *
 * This program 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 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef VKTESTBASE_H
#define VKTESTBASE_H

#include <libkvkontakte/apppermissions.h>

#include <QtCore/QObject>
#include <QtCore/QVector>

namespace Vkontakte {
    class VkApi;
}

class VkTestBase : public QObject
{
    Q_OBJECT

public:
    VkTestBase();
    ~VkTestBase();

protected:
    void authenticate(Vkontakte::AppPermissions::Value permissions);
    QString accessToken() const;

private:
    QString getSavedToken() const;

    Vkontakte::VkApi *m_vkapi;
};

#endif // VKTESTBASE_H

/*
 * Unit tests for libkvkontakte.
 * Copyright (C) 2015  Alexander Potashev <aspotashev@gmail.com>
 *
 * This program 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 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef VKTESTBASE_H
#define VKTESTBASE_H

#include <libkvkontakte/apppermissions.h>

#include <QtCore/QObject>
#include <QtCore/QVector>

namespace Vkontakte {
    class VkApi;
}

class VkTestBase : public QObject
{
    Q_OBJECT

public:
    VkTestBase();
    virtual ~VkTestBase();

protected:
    void authenticate(Vkontakte::AppPermissions::Value permissions);
    QString accessToken() const;

private:
    QString getSavedToken() const;

    Vkontakte::VkApi *m_vkapi;
};

#endif // VKTESTBASE_H

Fix memory leak by making dtor virtual

VkTestBase: Fix memory leak by making dtor virtual


#pragma once

#include "pixelboost/graphics/device/bufferFormats.h"

namespace pb
{

class GraphicsDevice;

struct Vertex_P3
{
    float position[3];
    float __padding;
};

struct Vertex_P3_UV
{
    float position[3];
    float uv[2];
    float __padding[3]; // for 32-byte alignment
};

struct Vertex_P3_C4
{
    float position[3];
    float color[4];
};

struct Vertex_P3_C4_UV
{
    float position[3];
    float uv[2];
    float color[4];
    float __padding[2]; // for 48-byte alignment
};

struct Vertex_P3_N3_UV
{
    float position[3];
    float normal[3];
    float uv[2];
};

struct Vertex_P3_N3_UV_BW
{
    float position[3];
    float normal[3];
    float uv[2];
    char bones[4];
    float boneWeights[4];
};

class VertexBuffer
{
protected:
    VertexBuffer(GraphicsDevice* device, BufferFormat bufferFormat, VertexFormat vertexFormat, int maxSize);
    ~VertexBuffer();

public:
    BufferFormat GetBufferFormat();
    VertexFormat GetVertexFormat();

    int GetMaxSize();
    int GetCurrentSize();

    void* GetData();

    void Lock();
    void Unlock(int numElements=-1);

private:
    GraphicsDevice* _Device;

    BufferFormat _BufferFormat;
    VertexFormat _VertexFormat;
    int _MaxSize;
    int _CurrentSize;

    void* _Data;

    int _Locked;

    friend class GraphicsDevice;
};

}

#pragma once

#include "pixelboost/graphics/device/bufferFormats.h"

namespace pb
{

class GraphicsDevice;

struct Vertex_P3
{
    float position[3];
};

struct Vertex_P3_UV
{
    float position[3];
    float uv[2];
};

struct Vertex_P3_C4
{
    float position[3];
    float color[4];
};

struct Vertex_P3_C4_UV
{
    float position[3];
    float uv[2];
    float color[4];
};

struct Vertex_P3_N3_UV
{
    float position[3];
    float normal[3];
    float uv[2];
};

struct Vertex_P3_N3_UV_BW
{
    float position[3];
    float normal[3];
    float uv[2];
    char bones[4];
    float boneWeights[4];
};

class VertexBuffer
{
protected:
    VertexBuffer(GraphicsDevice* device, BufferFormat bufferFormat, VertexFormat vertexFormat, int maxSize);
    ~VertexBuffer();

public:
    BufferFormat GetBufferFormat();
    VertexFormat GetVertexFormat();

    int GetMaxSize();
    int GetCurrentSize();

    void* GetData();

    void Lock();
    void Unlock(int numElements=-1);

private:
    GraphicsDevice* _Device;

    BufferFormat _BufferFormat;
    VertexFormat _VertexFormat;
    int _MaxSize;
    int _CurrentSize;

    void* _Data;

    int _Locked;

    friend class GraphicsDevice;
};

}

Remove padding from vertex buffers

Remove padding from vertex buffers


#include <chopsui.h>

void say_hi_clicked(sui_t *button, sui_event_t *event) {
	sui_alert("Hello world!");
}

void exit_clicked(sui_t *button, sui_event_t *event) {
	sui_exit();
}

int main(int argc, char **argv) {
	init_sui();
	sui_t *window = sui_load("window.sui");
	sui_load_css("window.css");
	sui_add_handler(window, exit_clicked);
	sui_add_handler(window, say_hi_clicked);
	sui_show(window);
	sui_run();
	return 0;
}

#include <chopsui.h>

void say_hi_clicked(sui_t *button, sui_event_t *event) {
	sui_alert("Hello world!");
}

void exit_clicked(sui_t *button, sui_event_t *event) {
	sui_exit();
}

int main(int argc, char **argv) {
	init_sui();
	sui_t *window = sui_load("window.sui");
	sui_css_t *css = sui_load_css("window.css");
	sui_add_handler(window, exit_clicked);
	sui_add_handler(window, say_hi_clicked);
	sui_style(window, css);
	sui_show(window);
	sui_run();
	return 0;
}

Change how CSS would be used

Change how CSS would be used


#include <alsa/asoundlib.h>

snd_seq_t *hdl;
static snd_midi_event_t *mbuf;
static int midiport;

/* open */
int
midiopen(void)
{
	snd_midi_event_new(32, &mbuf);
	if (snd_seq_open(&hdl, "default", SND_SEQ_OPEN_OUTPUT, 0) != 0) {
		return 1;
	} else {
		snd_seq_set_client_name(hdl, "svmidi");
		if ((midiport = snd_seq_create_simple_port(hdl, "svmidi",
			    SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ,
			    SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
			return 1;
		}
		return 0;
	}
}

/* send message */
void
_midisend(unsigned char message[], size_t count)
{
	snd_seq_event_t ev;

	snd_midi_event_encode(mbuf, message, count, &ev);

	snd_seq_ev_set_subs(&ev);
	snd_seq_ev_set_direct(&ev);
	snd_seq_ev_set_source(&ev, midiport);
	snd_seq_event_output_direct(hdl, &ev);
}

/* close */
void
midiclose(void)
{
	snd_midi_event_free(mbuf);
	snd_seq_close(hdl);
}

#include <alsa/asoundlib.h>

snd_seq_t *hdl;
static snd_midi_event_t *mbuf;
static int midiport;

/* open */
int
midiopen(void)
{
	snd_midi_event_new(32, &mbuf);
	if (snd_seq_open(&hdl, "default", SND_SEQ_OPEN_OUTPUT, 0) != 0) {
		return 1;
	} else {
		snd_seq_set_client_name(hdl, "svmidi");
		if ((midiport = snd_seq_create_simple_port(hdl, "svmidi",
			    SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ,
			    SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
			return 1;
		}
		return 0;
	}
}

/* send message */
void
midisend(unsigned char message[], size_t count)
{
	snd_seq_event_t ev;

	snd_midi_event_encode(mbuf, message, count, &ev);

	snd_seq_ev_set_subs(&ev);
	snd_seq_ev_set_direct(&ev);
	snd_seq_ev_set_source(&ev, midiport);
	snd_seq_event_output_direct(hdl, &ev);
}

/* close */
void
midiclose(void)
{
	snd_midi_event_free(mbuf);
	snd_seq_close(hdl);
}

Fix undefined reference to "midisend" when using ALSA

Signed-off-by: Henrique N. Lengler <6cdc851d94ddec54baafad133c2f9a87abb571af@openmailbox.org>


#pragma once

#include <pebble.h>

#include "simply/simply.h"

static inline ClickConfigProvider scroll_layer_click_config_provider_accessor(ClickConfigProvider provider) {
  static ClickConfigProvider s_provider;
  if (provider) {
    s_provider = provider;
  }
  return s_provider;
}

static inline void scroll_layer_click_config(void *context) {
  window_set_click_context(BUTTON_ID_UP, context);
  window_set_click_context(BUTTON_ID_DOWN, context);
  scroll_layer_click_config_provider_accessor(NULL)(context);
}

static inline void scroll_layer_set_click_config_provider_onto_window(ScrollLayer *scroll_layer,
    ClickConfigProvider click_config_provider, Window *window, void *context) {
  scroll_layer_set_click_config_onto_window(scroll_layer, window);
  scroll_layer_click_config_provider_accessor(window_get_click_config_provider(window));
  window_set_click_config_provider_with_context(window, click_config_provider, context);
}

Add scroll layer click config override helpers


#ifndef VAST_QUERY_SEARCH_H
#define VAST_QUERY_SEARCH_H

#include <unordered_map>
#include <cppa/cppa.hpp>
#include <ze/event.h>
#include <vast/query/query.h>

namespace vast {
namespace query {

class search : public cppa::sb_actor<search>
{
  friend class cppa::sb_actor<search>;

public:
  search(cppa::actor_ptr archive, cppa::actor_ptr index);

private:
  std::vector<cppa::actor_ptr> queries_;
  std::multimap<cppa::actor_ptr, cppa::actor_ptr> clients_;
  cppa::actor_ptr archive_;
  cppa::actor_ptr index_;
  cppa::behavior init_state;
};

} // namespace query
} // namespace vast

#endif

#ifndef VAST_QUERY_SEARCH_H
#define VAST_QUERY_SEARCH_H

#include <unordered_map>
#include <cppa/cppa.hpp>
#include <ze/event.h>
#include <vast/query/query.h>

namespace vast {
namespace query {

class search : public cppa::sb_actor<search>
{
  friend class cppa::sb_actor<search>;

public:
  search(cppa::actor_ptr archive, cppa::actor_ptr index);

private:
  std::vector<cppa::actor_ptr> queries_;
  std::unordered_multimap<cppa::actor_ptr, cppa::actor_ptr> clients_;
  cppa::actor_ptr archive_;
  cppa::actor_ptr index_;
  cppa::behavior init_state;
};

} // namespace query
} // namespace vast

#endif

Use an unordered map to track clients.

Use an unordered map to track clients.


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

#ifndef __UTIL_TIME_H__
#define __UTIL_TIME_H__

CCL_NAMESPACE_BEGIN

/* Give current time in seconds in double precision, with good accuracy. */

double time_dt();

/* Sleep for the specified number of seconds */

void time_sleep(double t);

class scoped_timer {
public:
	scoped_timer(double *value) : value_(value)
	{
		if(value_ != NULL) {
			time_start_ = time_dt();
		}
	}

	~scoped_timer()
	{
		if(value_ != NULL) {
			*value_ = time_dt() - time_start_;
		}
	}
protected:
	double *value_;
	double time_start_;
};

CCL_NAMESPACE_END

#endif

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

#ifndef __UTIL_TIME_H__
#define __UTIL_TIME_H__

CCL_NAMESPACE_BEGIN

/* Give current time in seconds in double precision, with good accuracy. */

double time_dt();

/* Sleep for the specified number of seconds */

void time_sleep(double t);

class scoped_timer {
public:
	scoped_timer(double *value) : value_(value)
	{
		time_start_ = time_dt();
	}

	~scoped_timer()
	{
		if(value_ != NULL) {
			*value_ = time_dt() - time_start_;
		}
	}
protected:
	double *value_;
	double time_start_;
};

CCL_NAMESPACE_END

#endif

Fix Uninitialized Value compiler warning in the scoped_timer

Although the code made it impossible to use time_start_ uninitialized, at least GCC did
still produce multiple warnings about it.
Since time_dt() is an extremely cheap operation and functionality does not change in any way when
removing the check in the constructor, this commit removes the check and therefore the warning.


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

#ifndef TESTING_PLATFORM_TEST_H_
#define TESTING_PLATFORM_TEST_H_

#include <gtest/gtest.h>

#if defined(GTEST_OS_MAC)
#ifdef __OBJC__
@class NSAutoreleasePool;
#else
class NSAutoreleasePool;
#endif

// The purpose of this class us to provide a hook for platform-specific
// operations across unit tests.  For example, on the Mac, it creates and
// releases an outer NSAutoreleasePool for each test case.  For now, it's only
// implemented on the Mac.  To enable this for another platform, just adjust
// the #ifdefs and add a platform_test_<platform>.cc implementation file.
class PlatformTest : public testing::Test {
 protected:
  PlatformTest();
  virtual ~PlatformTest();

 private:
  NSAutoreleasePool* pool_;
};
#else
typedef testing::Test PlatformTest;
#endif // GTEST_OS_MAC

#endif // TESTING_PLATFORM_TEST_H_

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

#ifndef TESTING_PLATFORM_TEST_H_
#define TESTING_PLATFORM_TEST_H_

#include <gtest/gtest.h>

#if defined(GTEST_OS_MAC)
#ifdef __OBJC__
@class NSAutoreleasePool;
#else
class NSAutoreleasePool;
#endif

// The purpose of this class us to provide a hook for platform-specific
// operations across unit tests.  For example, on the Mac, it creates and
// releases an outer NSAutoreleasePool for each test case.  For now, it's only
// implemented on the Mac.  To enable this for another platform, just adjust
// the #ifdefs and add a platform_test_<platform>.cc implementation file.
class PlatformTest : public testing::Test {
 public:
  virtual ~PlatformTest();

 protected:
  PlatformTest();

 private:
  NSAutoreleasePool* pool_;
};
#else
typedef testing::Test PlatformTest;
#endif // GTEST_OS_MAC

#endif // TESTING_PLATFORM_TEST_H_

Change visibility of the destructor to public.

PlatformTest's destructor was set as protected, though the parent class
testing::Test declares it public.

BUG=none

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

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


#include <stdint.h>

#define SKIP 77
struct status {
    uint32_t done;
    uint32_t _pad1;
    uint32_t returncode;
    uint32_t _pad2;
} __attribute__((packed));

volatile struct status *epiphany_status = (struct status *) 0x8f200000;
volatile char *epiphany_results = (char *) 0x8f300000;

int main(int argc, char *argv[])
{
    epiphany_status->returncode = SKIP;
    epiphany_status->done = 1;

    return SKIP;
}

#include <stdint.h>

#define SKIP 77
struct status {
    uint32_t done;
    uint32_t _pad1;
    uint32_t returncode;
    uint32_t _pad2;
} __attribute__((packed));

volatile struct status *epiphany_status = (struct status *) 0x8f200000;
volatile char *epiphany_results = (char *) 0x8f300000;

/* HACK: Provide symbol to work around GCC 5 link error for
 * math/check_p_{max,min} */
float *ai;

int main(int argc, char *argv[])
{
    epiphany_status->returncode = SKIP;
    epiphany_status->done = 1;

    return SKIP;
}

Fix Epiphany GCC 5 link error

tests: Fix Epiphany GCC 5 link error

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


// RUN: rm -fR %T/dir
// RUN: mkdir %T/dir
// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T/dir %s

// Currently this test mainly checks that the HTML diagnostics doesn't crash
// when handling macros will calls with macros.  We should actually validate
// the output, but that requires being able to match against a specifically
// generate HTML file.

#define DEREF(p) *p = 0xDEADBEEF

void has_bug(int *p) {
  DEREF(p);
}

#define CALL_HAS_BUG(q) has_bug(q)

void test_call_macro() {
  CALL_HAS_BUG(0);
}

// RUN: rm -fR %T/dir
// RUN: mkdir %T/dir
// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T/dir %s
// RUN: ls %T/dir | grep report

// PR16547: Test relative paths
// RUN: cd %T/dir
// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o testrelative %s
// RUN: ls %T/dir/testrelative | grep report

// REQUIRES: shell

// Currently this test mainly checks that the HTML diagnostics doesn't crash
// when handling macros will calls with macros.  We should actually validate
// the output, but that requires being able to match against a specifically
// generate HTML file.

#define DEREF(p) *p = 0xDEADBEEF

void has_bug(int *p) {
  DEREF(p);
}

#define CALL_HAS_BUG(q) has_bug(q)

void test_call_macro() {
  CALL_HAS_BUG(0);
}

Add a test case for r185707/PR16547.

Add a test case for r185707/PR16547.

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


/*-------------------------------------------------------------------------
 *
 *   FILE
 *	pqxx/util.h
 *
 *   DESCRIPTION
 *      Various utility definitions for libpqxx
 *
 * Copyright (c) 2001-2004, Jeroen T. Vermeulen <jtv@xs4all.nl>
 *
 * See COPYING for copyright license.  If you did not receive a file called
 * COPYING with this source code, please notify the distributor of this mistake,
 * or contact the author.
 *
 *-------------------------------------------------------------------------
 */
#ifndef PQXX_UTIL_H
#define PQXX_UTIL_H

#if defined(PQXX_HAVE_CPP_WARNING)
#warning "Deprecated libpqxx header included.  Use headers without '.h'"
#elif defined(PQXX_HAVE_CPP_PRAGMA_MESSAGE)
#pragma message("Deprecated libpqxx header included.  Use headers without '.h'")
#endif

#define PQXX_DEPRECATED_HEADERS
#include "pqxx/util"

#endif

/*-------------------------------------------------------------------------
 *
 *   FILE
 *	pqxx/util.h
 *
 *   DESCRIPTION
 *      Various utility definitions for libpqxx
 *
 * Copyright (c) 2001-2004, Jeroen T. Vermeulen <jtv@xs4all.nl>
 *
 * See COPYING for copyright license.  If you did not receive a file called
 * COPYING with this source code, please notify the distributor of this mistake,
 * or contact the author.
 *
 *-------------------------------------------------------------------------
 */
#ifndef PQXX_UTIL_H
#define PQXX_UTIL_H

#if !defined(PQXXYES_I_KNOW_DEPRECATED_HEADER)
#define PQXXYES_I_KNOW_DEPRECATED_HEADER
#if defined(PQXX_HAVE_CPP_WARNING)
#warning "Deprecated libpqxx header included.  Use headers without '.h'"
#elif defined(PQXX_HAVE_CPP_PRAGMA_MESSAGE)
#pragma message("Deprecated libpqxx header included.  Use headers without '.h'")
#endif
#endif

#define PQXX_DEPRECATED_HEADERS
#include "pqxx/util"

#endif

Allow suppression of "deprecated header" warning


/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Copyright 2013 LibreOffice contributors.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_TOUCH_TOUCH_H
#define INCLUDED_TOUCH_TOUCH_H

#include <config_features.h>

#if !HAVE_FEATURE_DESKTOP

// Functions to be implemented by the upper/medium layers on
// non-desktop touch-based platforms, with the same API on each such
// platform. Note that these are just declared here in this header in
// the "touch" module, the per-platform implementations are elsewhere.

#ifdef __cplusplus
extern "C" {
#endif

void lo_show_keyboard();
void lo_hide_keyboard();

#ifdef __cplusplus
}
#endif

#endif // HAVE_FEATURE_DESKTOP

#endif // INCLUDED_TOUCH_TOUCH_H

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Copyright 2013 LibreOffice contributors.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_TOUCH_TOUCH_H
#define INCLUDED_TOUCH_TOUCH_H

#include <config_features.h>

#if !HAVE_FEATURE_DESKTOP

// Functions to be implemented by the app-specifc upper or less
// app-specific but platform-specific medium layer on touch-based
// platforms. The same API is used on each such platform. There are
// called from low level LibreOffice code. Note that these are just
// declared here in this header in the "touch" module, the
// per-platform implementations are elsewhere.

#ifdef __cplusplus
extern "C" {
#endif

void lo_show_keyboard();
void lo_hide_keyboard();

// Functions to be implemented in the medium platform-specific layer
// to be called from the app-specific UI layer.

void lo_keyboard_did_hide();

#ifdef __cplusplus
}
#endif

#endif // HAVE_FEATURE_DESKTOP

#endif // INCLUDED_TOUCH_TOUCH_H

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Add lo_keyboard_did_hide() and improve comment

Change-Id: I20ae40fa03079d69f7ce9e71fa4ef6264e8d84a4


#if __GLASGOW_HASKELL__ < 604 || (__GLASGOW_HASKELL__==604 && __GHC_PATCHLEVEL__==0)
#include "WCsubst.c"
#endif

#if __GLASGOW_HASKELL__ < 605
#if __GLASGOW_HASKELL__ != 604 || __GHC_PATCHLEVEL__ == 0
#include "WCsubst.c"
#endif
#endif

Fix building with compilers which don't have an integer for a patch level


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

#include "logging.h"

int log_fail(char* msg) {
    perror(msg);
    // TODO fix log to file
    return 0;
}

int log_success(char* msg) {
    printf("%s\n", msg);
    return 0;
}

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

#include "logging.h"

int log_fail(char* msg) {
    perror(msg);
    // TODO fix log to file
    return 0;
}

int log_success(char* msg) {
    printf("SUCCESS: %s\n", msg);
    return 0;
}

Change of the default msg

Change of the default msg


#pragma once

#define NETWORK_MAX_MESSAGE_LENGTH 65535

#include <sys/types.h>

namespace pb
{

class NetworkMessage
{
public:
    NetworkMessage();
    NetworkMessage(const NetworkMessage& src);
    ~NetworkMessage();

    bool ReadChar(char& value);
    bool ReadByte(__uint8_t& value);
    bool ReadInt(__int32_t& value);
    bool ReadFloat(float& value);
    bool ReadString(const char*& value);

    bool WriteChar(char value);
    bool WriteByte(__uint8_t value);
    bool WriteInt(__int32_t value);
    bool WriteFloat(float value);
    bool WriteString(const char* value);

    bool SetData(__int32_t length, char* data);

    void SetProtocol(__uint32_t protocol);
    __uint32_t GetProtocol();

    int GetDataLength();
    int GetMessageLength();

    int ConstructMessage(char* buffer, __int32_t maxLength);

private:
    bool HasRemaining(__int32_t length);

    __uint32_t _Protocol;

    char* _Buffer;
    int _Offset;
    __int32_t _Length;
};

}

#pragma once

#define NETWORK_MAX_MESSAGE_LENGTH 262140

#include <sys/types.h>

namespace pb
{

class NetworkMessage
{
public:
    NetworkMessage();
    NetworkMessage(const NetworkMessage& src);
    ~NetworkMessage();

    bool ReadChar(char& value);
    bool ReadByte(__uint8_t& value);
    bool ReadInt(__int32_t& value);
    bool ReadFloat(float& value);
    bool ReadString(const char*& value);

    bool WriteChar(char value);
    bool WriteByte(__uint8_t value);
    bool WriteInt(__int32_t value);
    bool WriteFloat(float value);
    bool WriteString(const char* value);

    bool SetData(__int32_t length, char* data);

    void SetProtocol(__uint32_t protocol);
    __uint32_t GetProtocol();

    int GetDataLength();
    int GetMessageLength();

    int ConstructMessage(char* buffer, __int32_t maxLength);

private:
    bool HasRemaining(__int32_t length);

    __uint32_t _Protocol;

    char* _Buffer;
    int _Offset;
    __int32_t _Length;
};

}

Increase max length of a network message to support larger records


//
//  lineart.h
//  LineArt
//
//  Created by Allek Mott on 10/1/15.
//  Copyright © 2015 Loop404. All rights reserved.
//

#ifndef lineart_h
#define lineart_h

#include <stdio.h>

#define MAX_LINE_LENGTH 200

// data structure for line
// (x1, y1) = inital point
// (x2, y2) = final point
struct line {
    int x1;
    int y1;
    int x2;
    int y2;
};

// data structure for point (x, y)
struct point {
    int x;
    int y;
};

// Generate displacement value for new line
int genDifference();

// Easy line resetting/initialization
void easyLine(struct line *l, int x1, int y1, int x2, int y2);

// Calculates midpoint of line l,
// stores in point p
void getMidpoint(struct line *l, struct point *p);

// Generate next line in sequence
void genNextLine(struct line *previous, struct line *current, int lineNo);

#endif /* lineart_h */

//
//  lineart.h
//  LineArt
//
//  Created by Allek Mott on 10/1/15.
//  Copyright © 2015 Loop404. All rights reserved.
//

#ifndef lineart_h
#define lineart_h

#include <stdio.h>

#define MAX_LINE_LENGTH 200

// data structure for line
// (x1, y1) = inital point
// (x2, y2) = final point
struct line {
    int x1;
    int y1;
    int x2;
    int y2;
};

// data structure for point (x, y)
struct point {
    int x;
    int y;
};

// data structure for node
// in linked list of lines
struct node {
    struct line *line;
    struct node *next;
};

// Generate displacement value for new line
int genDifference();

// Easy line resetting/initialization
void easyLine(struct line *l, int x1, int y1, int x2, int y2);

// Calculates midpoint of line l,
// stores in point p
void getMidpoint(struct line *l, struct point *p);

// Generate next line in sequence
void genNextLine(struct line *previous, struct line *current, int lineNo);

void freeLineNode(struct node *node);

void freeLineList(struct node *root);

#endif /* lineart_h */

Add list function declarations, node structure


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

/* skey_getpass - read regular or s/key password */

char   *skey_getpass(prompt, pwd, pwok)
char   *prompt;
struct passwd *pwd;
int     pwok;
{
    static char buf[128];
    struct skey skey;
    char   *pass = "";
    char   *username = pwd ? pwd->pw_name : "nope";
    int     sflag;

    /* Attempt an s/key challenge. */
    sflag = skeyinfo(&skey, username, buf);
    if (!sflag)
	printf("%s\n", buf);

    if (!pwok) {
	printf("(s/key required)\n");
	if (sflag)
	    return (pass);
    }

    pass = getpass(prompt);

    /* Give S/Key users a chance to do it with echo on. */
    if (!sflag && !feof(stdin) && *pass == '\0') {
	fputs(" (turning echo on)\n", stdout);
	fputs(prompt, stdout);
	fflush(stdout);
	fgets(buf, sizeof(buf), stdin);
	rip(buf);
	return (buf);
    } else
	return (pass);
}

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

/* skey_getpass - read regular or s/key password */

char   *skey_getpass(prompt, pwd, pwok)
char   *prompt;
struct passwd *pwd;
int     pwok;
{
    static char buf[128];
    struct skey skey;
    char   *pass = "";
    char   *username = pwd ? pwd->pw_name : ":";
    int     sflag;

    /* Attempt an s/key challenge. */
    sflag = skeyinfo(&skey, username, buf);
    if (!sflag)
	printf("%s\n", buf);

    if (!pwok) {
	printf("(s/key required)\n");
	if (sflag)
	    return (pass);
    }

    pass = getpass(prompt);

    /* Give S/Key users a chance to do it with echo on. */
    if (!sflag && !feof(stdin) && *pass == '\0') {
	fputs(" (turning echo on)\n", stdout);
	fputs(prompt, stdout);
	fflush(stdout);
	fgets(buf, sizeof(buf), stdin);
	rip(buf);
	return (buf);
    } else
	return (pass);
}

Change "nope" to ":" Previous variant not work well, if you have a user with name nope


#ifndef CONSTBITS_H
#define CONSTBITS_H

#include "adt/obst.h"
#include "tv.h"

typedef struct bitinfo
{
	ir_tarval* z; /* safe zeroes, 0 = bit is zero,       1 = bit maybe is 1 */
	ir_tarval* o; /* safe ones,   0 = bit maybe is zero, 1 = bit is 1 */
} bitinfo;

/* Get analysis information for node irn */
bitinfo* get_bitinfo(ir_node const* const irn);

/* Set analysis information for node irn */
int set_bitinfo(ir_node* const irn, ir_tarval* const z, ir_tarval* const o);

/* Compute value range fixpoint aka which bits of value are constant zero/one.
 * The result is available via links to bitinfo*, allocated on client_obst. */
void constbits_analyze(ir_graph* const irg, struct obstack *client_obst);

/* Clears the bit information for the given graph.
 *
 * This does not affect the obstack passed to constbits_analyze.
 */
void constbits_clear(ir_graph* const irg);

#endif

#ifndef CONSTBITS_H
#define CONSTBITS_H

#include "adt/obst.h"
#include "tv.h"

typedef struct bitinfo
{
	ir_tarval* z; /* safe zeroes, 0 = bit is zero,       1 = bit maybe is 1 */
	ir_tarval* o; /* safe ones,   0 = bit maybe is zero, 1 = bit is 1 */
} bitinfo;

/* Get analysis information for node irn */
bitinfo* get_bitinfo(ir_node const* irn);

/* Set analysis information for node irn */
int set_bitinfo(ir_node* irn, ir_tarval* z, ir_tarval* o);

/* Compute value range fixpoint aka which bits of value are constant zero/one.
 * The result is available via links to bitinfo*, allocated on client_obst. */
void constbits_analyze(ir_graph* irg, struct obstack *client_obst);

/* Clears the bit information for the given graph.
 *
 * This does not affect the obstack passed to constbits_analyze.
 */
void constbits_clear(ir_graph* irg);

#endif

Remove pointless const from function declarations.


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

#ifndef WIDEVINE_CDM_VERSION_H_
#define WIDEVINE_CDM_VERSION_H_

#include "third_party/widevine/cdm/widevine_cdm_common.h"

// Indicates that the Widevine CDM is available.
#define WIDEVINE_CDM_AVAILABLE

// TODO(ddorwin): Remove when we have CDM availability detection
// (http://crbug.com/224793).
#define DISABLE_WIDEVINE_CDM_CANPLAYTYPE

// Indicates that ISO BMFF CENC support is available in the Widevine CDM.
// Must be enabled if any of the codecs below are enabled.
#define WIDEVINE_CDM_CENC_SUPPORT_AVAILABLE
// Indicates that AVC1 decoding is available for ISO BMFF CENC.
#define WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE
// Indicates that AAC decoding is available for ISO BMFF CENC.
#define WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE

#endif  // WIDEVINE_CDM_VERSION_H_

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

#ifndef WIDEVINE_CDM_VERSION_H_
#define WIDEVINE_CDM_VERSION_H_

#include "third_party/widevine/cdm/widevine_cdm_common.h"

// Indicates that the Widevine CDM is available.
#define WIDEVINE_CDM_AVAILABLE

// Indicates that AVC1 decoding is available for ISO BMFF CENC.
#define WIDEVINE_CDM_AVC1_SUPPORT_AVAILABLE
// Indicates that AAC decoding is available for ISO BMFF CENC.
#define WIDEVINE_CDM_AAC_SUPPORT_AVAILABLE

#endif  // WIDEVINE_CDM_VERSION_H_

Remove DISABLE_WIDEVINE_CDM_CANPLAYTYPE as we should start using canPlayType now

Passed the canplaytype check when tested with http://dash-mse-test.appspot.com/append-all.html?sd=1&keysystem=widevine

BUG=224793

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

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


//
//  NSCache+BlocksKit.h
//  %PROJECT
//

#import "BKGlobals.h"

/** NSCache with block adding of objects

 This category allows you to conditionally add objects to
 an instance of NSCache using blocks.  Both the normal
 delegation pattern and a block callback for NSCache's one
 delegate method are allowed.

 These methods emulate Rails caching behavior.

 Created by Igor Evsukov and contributed to BlocksKit.
 */

@interface NSCache (BlocksKit)

/** Returns the value associated with a given key. If there is no
 object for that key, it uses the result of the block, saves
 that to the cache, and returns it.

 This mimics the cache behavior of Ruby on Rails.  The following code:

     @products = Rails.cache.fetch('products') do
       Product.all
     end

 becomes:

     NSMutableArray *products = [cache objectForKey:@"products" withGetter:^id{
       return [Product all];
     }];

 @return The value associated with *key*, or the object returned
 by the block if no value is associated with *key*.
 @param key An object identifying the value.
 @param getterBlock A block used to get an object if there is no
 value in the cache.
 */
- (id)objectForKey:(id)key withGetter:(BKReturnBlock)getterBlock;

/** Called when an object is about to be evicted from the cache.

 This block callback is an analog for the cache:willEviceObject:
 method of NSCacheDelegate.
 */
@property (copy) BKSenderBlock willEvictBlock;

@end

//
//  NSCache+BlocksKit.h
//  %PROJECT
//

#import "BKGlobals.h"

/** NSCache with block adding of objects

 This category allows you to conditionally add objects to
 an instance of NSCache using blocks.  Both the normal
 delegation pattern and a block callback for NSCache's one
 delegate method are allowed.

 These methods emulate Rails caching behavior.

 Created by Igor Evsukov and contributed to BlocksKit.
 */

@interface NSCache (BlocksKit)

/** Returns the value associated with a given key. If there is no
 object for that key, it uses the result of the block, saves
 that to the cache, and returns it.

 This mimics the cache behavior of Ruby on Rails.  The following code:

     @products = Rails.cache.fetch('products') do
       Product.all
     end

 becomes:

     NSMutableArray *products = [cache objectForKey:@"products" withGetter:^id{
       return [Product all];
     }];

 @return The value associated with *key*, or the object returned
 by the block if no value is associated with *key*.
 @param key An object identifying the value.
 @param getterBlock A block used to get an object if there is no
 value in the cache.
 */
- (id)objectForKey:(id)key withGetter:(BKReturnBlock)getterBlock;

/** Called when an object is about to be evicted from the cache.

 This block callback is an analog for the cache:willEviceObject:
 method of NSCacheDelegate.
 */
@property (copy) void(^willEvictBlock)(NSCache *, id);

@end

Fix block property type in NSCache.

Fix block property type in NSCache.


#ifndef NEWSBOAT_QUEUEMANAGER_H_
#define NEWSBOAT_QUEUEMANAGER_H_

#include <memory>
#include <string>

namespace newsboat {

class ConfigContainer;
class ConfigPaths;
class RssFeed;

class QueueManager {
	ConfigContainer* cfg = nullptr;
	ConfigPaths* paths = nullptr;

public:
	QueueManager(ConfigContainer* cfg, ConfigPaths* paths);

	void enqueue_url(const std::string& url,
		const std::string& title,
		const time_t pubDate,
		std::shared_ptr<RssFeed> feed);

	void autoenqueue(std::shared_ptr<RssFeed> feed);

private:
	std::string generate_enqueue_filename(const std::string& url,
		const std::string& title,
		const time_t pubDate,
		std::shared_ptr<RssFeed> feed);
};

}

#endif /* NEWSBOAT_QUEUEMANAGER_H_ */

#ifndef NEWSBOAT_QUEUEMANAGER_H_
#define NEWSBOAT_QUEUEMANAGER_H_

#include <ctime>
#include <memory>
#include <string>

namespace newsboat {

class ConfigContainer;
class ConfigPaths;
class RssFeed;

class QueueManager {
	ConfigContainer* cfg = nullptr;
	ConfigPaths* paths = nullptr;

public:
	QueueManager(ConfigContainer* cfg, ConfigPaths* paths);

	void enqueue_url(const std::string& url,
		const std::string& title,
		const time_t pubDate,
		std::shared_ptr<RssFeed> feed);

	void autoenqueue(std::shared_ptr<RssFeed> feed);

private:
	std::string generate_enqueue_filename(const std::string& url,
		const std::string& title,
		const time_t pubDate,
		std::shared_ptr<RssFeed> feed);
};

}

#endif /* NEWSBOAT_QUEUEMANAGER_H_ */

Add missing header and fix build on FreeBSD

In file included from src/queuemanager.cpp:1:
include/queuemanager.h:22:9: error: unknown type name 'time_t'
                const time_t pubDate,
                      ^

Signed-off-by: Tobias Kortkamp <95411b5f3468a822bfbad7edd660475780680510@FreeBSD.org>


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

#include "input.h"

int
main(int argc, char **argv)
{
	unsigned long high, low, err;
	struct gpio_req req;
	int fd;
	int old;
	int res;
	struct hardware hw;

	res = read_hardware_parameters("hardware.txt", &hw);
	if (res)
		return res;

	fd = init_hardware(hw.pin);
	if (fd < 0)
		return fd; /* errno */

	high = low = err = 0;
	old = 0;
	for (;;) {
		req.gp_pin = hw.pin;
		if (ioctl(fd, GPIOGET, &req) < 0) {
			perror("ioctl(GPIOGET)"); /* whoops */
			exit(1);
		}
		if ((req.gp_value != old && old == 0) ||
		    (high + low > hw.freq)) {
			printf("%lu %lu %lu\n", err, high, low);
			high = low = 0;
		}
		if (req.gp_value == GPIO_PIN_HIGH)
			high++;
		else if (req.gp_value == GPIO_PIN_LOW)
			low++;
		else
			err++; /* Houston? */
		old = req.gp_value;
		(void)usleep(1000000.0 / hw.freq); /* us */
	}
	if (close(fd))
		perror("close");
	return 0;
}

Add a simple test program to read the GPIO signal.

The program reads the sampling frequency and GPIO pin number from
hardware.txt. It displays a new line and resets the LOW and HIGH counters
when a LOW->HIGH (new second) slope occurs.

Returns either all LOW or garbage on my hardware...


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

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

Update Skia milestone to 73

Update Skia milestone to 73

Bug: skia:
Change-Id: I4b8744f1f9d752a54429054d7539c46e24fcba82
Reviewed-on: https://skia-review.googlesource.com/c/173428
Reviewed-by: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>
Commit-Queue: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>


// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

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

#include "common.h"
#include "irq.h"
#include "rv_timer.h"
#include "uart.h"

static uint32_t intr_handling_success = 0;
static const uint32_t hart = 0;

int main(int argc, char **argv) {
  uint64_t cmp = 0x00000000000000FF;

  uart_init(UART_BAUD_RATE);

  irq_global_ctrl(true);
  irq_timer_ctrl(true);
  rv_timer_set_us_tick(hart);
  rv_timer_set_cmp(hart, cmp);
  rv_timer_ctrl(hart, true);
  rv_timer_intr_enable(hart, true);

  while (1) {
    if (intr_handling_success) {
      break;
    }
  }

  uart_send_str("PASS!\r\n");
  __asm__ volatile("wfi;");
}

// Override weak default function
void handler_irq_timer(void) {
  rv_timer_ctrl(hart, false);
  rv_timer_clr_all_intrs();
  intr_handling_success = 1;
}

// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0

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

#include "common.h"
#include "irq.h"
#include "rv_timer.h"
#include "uart.h"

static uint32_t intr_handling_success = 0;
static const uint32_t hart = 0;

int main(int argc, char **argv) {
  const uint64_t cmp = 0x000000000000000F;

  uart_init(UART_BAUD_RATE);

  irq_global_ctrl(true);
  irq_timer_ctrl(true);
  rv_timer_set_us_tick(hart);
  rv_timer_set_cmp(hart, cmp);
  rv_timer_ctrl(hart, true);
  rv_timer_intr_enable(hart, true);

  while (1) {
    if (intr_handling_success) {
      break;
    }
  }

  uart_send_str("PASS!\r\n");
  __asm__ volatile("wfi;");
}

// Override weak default function
void handler_irq_timer(void) {
  uart_send_str("In Interrupt handler!\r\n");
  rv_timer_ctrl(hart, false);
  rv_timer_clr_all_intrs();
  intr_handling_success = 1;
}

[test] Decrease compare value for faster testing


/**
 * \file	macros.h
 * \author	Thibaut Mattio <thibaut.mattio@gmail.com>
 * \date	28/06/2015
 * \copyright Copyright (c) 2015 Thibaut Mattio. All rights reserved.
 * Use of this source code is governed by the MIT license that can be
 * found in the LICENSE file.
 */

#ifndef ATLAS_MACROS_H_
#define ATLAS_MACROS_H_

#if (__cplusplus >= 201103L)
#define ATLAS_NOEXCEPT noexcept
#define ATLAS_NOEXCEPT_(x) noexcept(x)
#define ATLAS_NOEXCEPT_OR_FALSE(x) noexcept(x)
#else
#define ATLAS_NOEXCEPT throw()
#define ATLAS_NOEXCEPT_(x)
#define ATLAS_NOEXCEPT_OR_FALSE(x) false
#endif

#ifndef ATLAS_ALWAYS_INLINE
#define ATLAS_ALWAYS_INLINE \
  __attribute__((__visibility__("default"), __always_inline__)) inline
#endif

#endif  // ATLAS_MACROS_H_

/**
 * \file	macros.h
 * \author	Thibaut Mattio <thibaut.mattio@gmail.com>
 * \date	28/06/2015
 * \copyright Copyright (c) 2015 Thibaut Mattio. All rights reserved.
 * Use of this source code is governed by the MIT license that can be
 * found in the LICENSE file.
 */

#ifndef ATLAS_MACROS_H_
#define ATLAS_MACROS_H_

// Defining exception macros
#if (__cplusplus >= 201103L)
#define ATLAS_NOEXCEPT noexcept
#define ATLAS_NOEXCEPT_(x) noexcept(x)
#define ATLAS_NOEXCEPT_OR_FALSE(x) noexcept(x)
#else
#define ATLAS_NOEXCEPT throw()
#define ATLAS_NOEXCEPT_(x)
#define ATLAS_NOEXCEPT_OR_FALSE(x) false
#endif

// Defining inline macros
#ifndef ATLAS_ALWAYS_INLINE
#define ATLAS_ALWAYS_INLINE \
  __attribute__((__visibility__("default"), __always_inline__)) inline
#endif

// Defining OS variables
#if defined(_WIN32)
#	define OS_WINDOWS 1
#elif defined(__APPLE__)
#  define OS_DARWIN 1
#elif defined(__linux__)
#  define OS_LINUX 1
#endif

#endif  // ATLAS_MACROS_H_

Make ins provider compile on darwin os.

Make ins provider compile on darwin os.


#ifdef __GNUC__
  #if __clang__
    #if __cplusplus >= 201103L && !__has_include(<initializer_list>)
      #warning "Your compiler supports C++11 but your C++ standard library does not.  If your system has libc++ installed (as should be the case on e.g. Mac OSX), try adding -stdlib=libc++ to your CFLAGS (ignore the other warning that says to use CXXFLAGS)."
    #endif
  #endif
#endif

#include "capnp/dynamic.h"

static_assert(CAPNP_VERSION >= 5000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.4 and then re-install this python library");

#ifdef __GNUC__
  #if __clang__
    #if __cplusplus >= 201103L && !__has_include(<initializer_list>)
      #warning "Your compiler supports C++11 but your C++ standard library does not.  If your system has libc++ installed (as should be the case on e.g. Mac OSX), try adding -stdlib=libc++ to your CFLAGS (ignore the other warning that says to use CXXFLAGS)."
    #endif
  #endif
#endif

#include "capnp/dynamic.h"

static_assert(CAPNP_VERSION >= 5000, "Version of Cap'n Proto C++ Library is too old. Please upgrade to a version >= 0.5 and then re-install this python library");

Fix error message in version check

Fix error message in version check


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

int main (int argc, char ** argv)
{   CURL * handle;
    CURLcode res;

    curl_global_init(CURL_GLOBAL_ALL);
    handle = curl_easy_init();

    if ( handle )
    {   curl_easy_setopt(handle, CURLOPT_URL, "http://icanhazip.com");
        curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1);

        res = curl_easy_perform(handle);
        if ( ! res == CURLE_OK )
        {   curl_easy_cleanup(handle);
            curl_global_cleanup();
            fputs("Could not check IP address\n", stderr);
            exit(1);
        }
    }

    curl_easy_cleanup(handle);
    curl_global_cleanup();

    return 0;
}
// vim: set tabstop=4 shiftwidth=4 expandtab

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

int main ()
{   CURL * handle;
    CURLcode res;

    curl_global_init(CURL_GLOBAL_ALL);
    handle = curl_easy_init();

    if ( handle )
    {   curl_easy_setopt(handle, CURLOPT_URL, "http://icanhazip.com");
        curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1);

        res = curl_easy_perform(handle);
        if ( ! res == CURLE_OK )
        {   curl_easy_cleanup(handle);
            curl_global_cleanup();
            fputs("Could not check IP address\n", stderr);
            exit(1);
        }
    }

    curl_easy_cleanup(handle);
    curl_global_cleanup();

    return 0;
}
// vim: set tabstop=4 shiftwidth=4 expandtab

Remove arg{c,v} params for main() since they are unneeded


#define BINDINGS_FILE_TIMEOUT 3
#define BINDINGS_FILE_HEADER \
"# Multipath bindings, Version : 1.0\n" \
"# NOTE: this file is automatically maintained by the multipath program.\n" \
"# You should not need to edit this file in normal circumstances.\n" \
"#\n" \
"# Format:\n" \
"# alias wwid\n" \
"#\n"

char *get_user_friendly_alias(char *wwid, char *file);
char *get_user_friendly_wwid(char *alias, char *file);

#define BINDINGS_FILE_TIMEOUT 30
#define BINDINGS_FILE_HEADER \
"# Multipath bindings, Version : 1.0\n" \
"# NOTE: this file is automatically maintained by the multipath program.\n" \
"# You should not need to edit this file in normal circumstances.\n" \
"#\n" \
"# Format:\n" \
"# alias wwid\n" \
"#\n"

char *get_user_friendly_alias(char *wwid, char *file);
char *get_user_friendly_wwid(char *alias, char *file);

[lib] Increase bindings file lock timeout to avoid failure of user_friendly_names

On setups with a large number of paths / multipath maps, contention for
the advisory lock on the bindings file may take longer than 3 seconds,
and some multipath processes may create maps based on WWID despite having
user_friendly_names set.  Increasing the timeout is a simple fix that
gets us a bit further.


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

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

Update Skia milestone to 100

Update Skia milestone to 100

Change-Id: I9d435a7a68ef870ef027ee3c6acb79792773868b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/497609
Reviewed-by: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>
Auto-Submit: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>
Reviewed-by: Eric Boren <0e499112533c8544f0505ea0d08394fb5ad7d8fa@google.com>
Commit-Queue: Eric Boren <0e499112533c8544f0505ea0d08394fb5ad7d8fa@google.com>


#ifndef __IDX_H_ENTRY_H__
#define __IDX_H_ENTRY_H__

typedef struct {
   unsigned char header[4];
   int length;
   unsigned char *data;
} IDX1_DATA ;

typedef struct {
   unsigned char header[4];
   int nimages;
   int nrows;
   int ncols;
   unsigned char *data;
} IDX3_DATA ;

int fread_idx1_file( char *slabelfname, IDX1_DATA *idxdata);

#endif  /* __IDX_H_ENTRY_H__ */

#ifndef __IDX_H_ENTRY_H__
#define __IDX_H_ENTRY_H__

typedef struct {
   unsigned char header[4];
   int length;
   unsigned char *data;
} IDX1_DATA ;

typedef struct {
   unsigned char header[4];
   int nimages;
   int nrows;
   int ncols;
   int length;
   unsigned char *data;
} IDX3_DATA ;

int fread_idx1_file( char *slabelfname, IDX1_DATA *idxdata);

#endif  /* __IDX_H_ENTRY_H__ */

Add a length field to the IDX3_DATA structure.


#pragma once
#include "helpers.h"
#include "nvidia_interface_datatypes.h"
#include <vector>
#include <memory>

class NvidiaGPU;

class NVLIB_EXPORTED NvidiaApi
{
public:
    NvidiaApi();
    ~NvidiaApi();
    int getGPUCount();
    std::shared_ptr<NvidiaGPU> getGPU(int index);
private:
    bool GPUloaded = false;
    std::vector<std::shared_ptr<NvidiaGPU>> gpus;
    bool ensureGPUsLoaded();
};

class NVLIB_EXPORTED NvidiaGPU
{
public:
    friend class NvidiaApi;
    float getCoreClock();
    float getMemoryClock();
    float getGPUUsage();
    float getFBUsage();
    float getVidUsage();
    float getBusUsage();
private:
    NV_PHYSICAL_GPU_HANDLE handle;
    NvidiaGPU(NV_PHYSICAL_GPU_HANDLE handle);
    struct NVIDIA_CLOCK_FREQUENCIES frequencies;
    bool reloadFrequencies();
    float getClockForSystem(NVIDIA_CLOCK_SYSTEM system);
    float getUsageForSystem(NVIDIA_DYNAMIC_PSTATES_SYSTEM system);
};

#pragma once
#include "helpers.h"
#include "nvidia_interface_datatypes.h"
#include <vector>
#include <memory>

class NvidiaGPU;

class NVLIB_EXPORTED NvidiaApi
{
public:
    NvidiaApi();
    ~NvidiaApi();
    int getGPUCount();
    std::shared_ptr<NvidiaGPU> getGPU(int index);
private:
    std::vector<std::shared_ptr<NvidiaGPU>> gpus;
    bool ensureGPUsLoaded();
    bool GPUloaded = false;
};

class NVLIB_EXPORTED NvidiaGPU
{
public:
    friend class NvidiaApi;
    float getCoreClock();
    float getMemoryClock();
    float getGPUUsage();
    float getFBUsage();
    float getVidUsage();
    float getBusUsage();
private:
    NV_PHYSICAL_GPU_HANDLE handle;
    NvidiaGPU(NV_PHYSICAL_GPU_HANDLE handle);
    struct NVIDIA_CLOCK_FREQUENCIES frequencies;
    bool reloadFrequencies();
    float getClockForSystem(NVIDIA_CLOCK_SYSTEM system);
    float getUsageForSystem(NVIDIA_DYNAMIC_PSTATES_SYSTEM system);
};

Tweak a minor alignment issue.

Tweak a minor alignment issue.


#define PORTABLE_VERSION_TEXT "0.2.5"
#define PORTABLE_VERSION_MAJOR 0
#define PORTABLE_VERSION_MINOR 2
#define PORTABLE_VERSION_PATCH 5
/* 1 or 0 */
#define PORTABLE_VERSION_RELEASED 1

#define PORTABLE_VERSION_TEXT "0.2.6-pre"
#define PORTABLE_VERSION_MAJOR 0
#define PORTABLE_VERSION_MINOR 2
#define PORTABLE_VERSION_PATCH 6
/* 1 or 0 */
#define PORTABLE_VERSION_RELEASED 0

Bump portable version to 0.2.6-pre

Bump portable version to 0.2.6-pre


#define PORTABLE_VERSION_TEXT "0.2.4"
#define PORTABLE_VERSION_MAJOR 0
#define PORTABLE_VERSION_MINOR 2
#define PORTABLE_VERSION_PATCH 4
/* 1 or 0 */
#define PORTABLE_VERSION_RELEASED 1

#define PORTABLE_VERSION_TEXT "0.2.5-pre"
#define PORTABLE_VERSION_MAJOR 0
#define PORTABLE_VERSION_MINOR 2
#define PORTABLE_VERSION_PATCH 5
/* 1 or 0 */
#define PORTABLE_VERSION_RELEASED 0

Update portable version to unreleased

Update portable version to unreleased


/* lab4.c: Read integers and print out the sum of all even and odd
 * numbers separately */
#include <stdio.h>

int main() {
    int num = 0;
    int even_sum = 0;
    int odd_sum = 0;

     do {
        printf("Enter an integer: ");
        fflush(stdout);
        scanf("%d",&num);
        switch (num % 2) {
        case 0:
            even_sum += num;
            break;
        default:
            odd_sum += num;
        }
    } while (num != 0);

    printf("Sum of evens: %d\n", even_sum);
    printf("Sum of odds: %d\n", odd_sum);
    return 0;
}

Rewrite of odd/even number program for arbitrary number of inputs using switch statement


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

#include <termbox.h>

#include "editor.h"
#include "util.h"

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

  editor_t editor;
  cursor_t cursor;
  editor_init(&editor, &cursor, argc > 1 ? argv[1] : NULL);

  int err = tb_init();
  if (err) {
    fprintf(stderr, "tb_init() failed with error code %d\n", err);
    return 1;
  }
  atexit(tb_shutdown);

  editor_draw(&editor);

  struct tb_event ev;
  while (tb_poll_event(&ev)) {
    switch (ev.type) {
    case TB_EVENT_KEY:
      editor_handle_key_press(&editor, &ev);
      break;
    case TB_EVENT_RESIZE:
      editor_draw(&editor);
      break;
    default:
      break;
    }
  }

  return 0;
}

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

#include <signal.h>

#include <termbox.h>

#include "editor.h"
#include "util.h"

// termbox catches ctrl-z as a regular key event. To suspend the process as
// normal, manually raise SIGTSTP.
//
// Not 100% sure why we need to shutdown termbox, but the terminal gets all
// weird if we don't. Mainly copied this approach from here:
// https://github.com/nsf/godit/blob/master/suspend_linux.go
static void suspend(editor_t *editor) {
  tb_shutdown();

  raise(SIGTSTP);

  int err = tb_init();
  if (err) {
    fprintf(stderr, "tb_init() failed with error code %d\n", err);
    exit(1);
  }

  editor_draw(editor);
}

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

  editor_t editor;
  cursor_t cursor;
  editor_init(&editor, &cursor, argc > 1 ? argv[1] : NULL);

  int err = tb_init();
  if (err) {
    fprintf(stderr, "tb_init() failed with error code %d\n", err);
    return 1;
  }
  atexit(tb_shutdown);

  editor_draw(&editor);

  struct tb_event ev;
  while (tb_poll_event(&ev)) {
    switch (ev.type) {
    case TB_EVENT_KEY:
      if (ev.key == TB_KEY_CTRL_Z) {
        suspend(&editor);
      } else {
        editor_handle_key_press(&editor, &ev);
      }
      break;
    case TB_EVENT_RESIZE:
      editor_draw(&editor);
      break;
    default:
      break;
    }
  }

  return 0;
}

Handle Ctrl-Z to suspend the process.

Handle Ctrl-Z to suspend the process.


/* mbed Microcontroller Library
 * Copyright (c) 2006-2013 ARM Limited
 *
 * 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 "semihost_api.h"
#include "mbed_interface.h"

#ifdef TOOLCHAIN_GCC_CW
// TODO: Ideally, we would like to define directly "_ExitProcess"
void mbed_exit(int return_code) {
#else
void exit(int return_code) {
#endif

#if DEVICE_SEMIHOST
    if (mbed_interface_connected()) {
        semihost_exit();
    }
#endif
    if (return_code) {
        mbed_die();
    }

    while (1);
}

/* mbed Microcontroller Library
 * Copyright (c) 2006-2013 ARM Limited
 *
 * 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 "semihost_api.h"
#include "mbed_interface.h"
#include "toolchain.h"

#ifdef TOOLCHAIN_GCC_CW
// TODO: Ideally, we would like to define directly "_ExitProcess"
void mbed_exit(int return_code) {
#else
void exit(int return_code) {
#endif

#if DEVICE_SEMIHOST
    if (mbed_interface_connected()) {
        semihost_exit();
    }
#endif
    if (return_code) {
        mbed_die();
    }

    while (1);
}

WEAK void __cxa_pure_virtual(void);
WEAK void __cxa_pure_virtual(void) {
    exit(1);
}

Add __cxa_pure_virtual to avoid pulling in functions from the C++ library

Fixes PRMBED-859


#ifndef MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
#define MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H

#include <stdbool.h>
#include "py/gc.h"
#include "py/misc.h"
#include "supervisor/memory.h"

#define _PM_ALLOCATOR _PM_allocator_impl
#define _PM_FREE(x) (_PM_free_impl((x)), (x)=NULL, (void)0)

static inline void *_PM_allocator_impl(size_t sz) {
    if (gc_alloc_possible()) {
        return m_malloc(sz + sizeof(void*), true);
    } else {
        supervisor_allocation *allocation = allocate_memory(align32_size(sz), true);
        return allocation ? allocation->ptr : NULL;
    }
}

static inline void _PM_free_impl(void *ptr_in) {
    supervisor_allocation *allocation = allocation_from_ptr(ptr_in);

    if (allocation) {
        free_memory(allocation);
    }
}

#endif

#ifndef MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H
#define MICROPY_INCLUDED_SHARED_MODULE_PROTOMATTER_ALLOCATOR_H

#include <stdbool.h>
#include "py/gc.h"
#include "py/misc.h"
#include "supervisor/memory.h"

#define _PM_ALLOCATOR _PM_allocator_impl
#define _PM_FREE(x) (_PM_free_impl((x)), (x)=NULL, (void)0)

static inline void *_PM_allocator_impl(size_t sz) {
    if (gc_alloc_possible()) {
        return m_malloc(sz + sizeof(void*), true);
    } else {
        supervisor_allocation *allocation = allocate_memory(align32_size(sz), false);
        return allocation ? allocation->ptr : NULL;
    }
}

static inline void _PM_free_impl(void *ptr_in) {
    supervisor_allocation *allocation = allocation_from_ptr(ptr_in);

    if (allocation) {
        free_memory(allocation);
    }
}

#endif

Use low end of supervisor heap

protomatter: Use low end of supervisor heap

Per @tannewt, this area "sees more churn", so it's probably the right
choice here


// -*- C++ -*-
#ifndef _writer_verilog_task_h_
#define _writer_verilog_task_h_

#include "writer/verilog/resource.h"

namespace iroha {
namespace writer {
namespace verilog {

class Task : public Resource {
public:
  Task(const IResource &res, const Table &table);
  virtual void BuildResource();
  virtual void BuildInsn(IInsn *insn, State *st);
  static bool IsTask(const Table &table);
  static string TaskEnablePin(const ITable &tab, const ITable *caller);

  static const int kTaskEntryStateId;

private:
  void BuildTaskResource();
  void BuildTaskCallResource();
  void BuildCallWire(IResource *caller);
  void BuildTaskCallInsn(IInsn *insn, State *st);
  void AddPort(const IModule *mod, IResource *caller);
  void AddWire(const IModule *mod, IResource *caller);

  static string TaskPinPrefix(const ITable &tab, const ITable *caller);
  static string TaskAckPin(const ITable &tab, const ITable *caller);
};

}  // namespace verilog
}  // namespace writer
}  // namespace iroha

#endif  // _writer_verilog_task_h_

// -*- C++ -*-
#ifndef _writer_verilog_task_h_
#define _writer_verilog_task_h_

#include "writer/verilog/resource.h"

namespace iroha {
namespace writer {
namespace verilog {

class Task : public Resource {
public:
  Task(const IResource &res, const Table &table);
  virtual void BuildResource();
  virtual void BuildInsn(IInsn *insn, State *st);
  static bool IsTask(const Table &table);
  static string TaskEnablePin(const ITable &tab, const ITable *caller);

  static const int kTaskEntryStateId;

private:
  void BuildTaskResource();
  void BuildTaskCallResource();
  void BuildCallWire(IResource *caller);
  void BuildTaskCallInsn(IInsn *insn, State *st);
  void AddPort(const IModule *mod, IResource *caller, bool upward);
  void AddWire(const IModule *mod, IResource *caller);

  static string TaskPinPrefix(const ITable &tab, const ITable *caller);
  static string TaskAckPin(const ITable &tab, const ITable *caller);
};

}  // namespace verilog
}  // namespace writer
}  // namespace iroha

#endif  // _writer_verilog_task_h_

Fix a missed file in previous change.

Fix a missed file in previous change.


/* The Halfling Project - A Graphics Engine and Projects
 *
 * The Halfling Project is the legal property of Adrian Astley
 * Copyright Adrian Astley 2013
 */

#ifndef CRATE_DEMO_GAME_STATE_MANAGER_H
#define CRATE_DEMO_GAME_STATE_MANAGER_H

#include "common/game_state_manager_interface.h"

namespace CrateDemo {

class GameStateManager : public Common::IGameStateManager {
public:
	GameStateManager();

private:

public:
	bool Initialize();
	void Shutdown();
	/**
	 * Return the wanted period of time between update() calls.
	 *
	 * IE: If you want update to be called 20 times a second, this
	 * should return 50.
	 *
	 * NOTE: This should probably be inlined.
	 * NOTE: This will only be called at the beginning of HalflingEngine::Run()
	 * TODO: Contemplate the cost/benefit of calling this once per frame
	 *
	 * @return    The period in milliseconds
	 */
	inline double GetUpdatePeriod() { return 30.0; }
	/**
	 * Called every time the game logic should be updated. The frequency
	 * of this being called is determined by getUpdatePeriod()
	 */
	void Update();
	void GamePaused();
	void GameUnpaused();
};

} // End of namespace CrateDemo

#endif

/* The Halfling Project - A Graphics Engine and Projects
 *
 * The Halfling Project is the legal property of Adrian Astley
 * Copyright Adrian Astley 2013
 */

#ifndef CRATE_DEMO_GAME_STATE_MANAGER_H
#define CRATE_DEMO_GAME_STATE_MANAGER_H

#include "common/game_state_manager_base.h"

namespace CrateDemo {

class GameStateManager : public Common::GameStateManagerBase {
public:
	GameStateManager();

private:

public:
	bool Initialize();
	void Shutdown();
	/**
	 * Return the wanted period of time between update() calls.
	 *
	 * IE: If you want update to be called 20 times a second, this
	 * should return 50.
	 *
	 * NOTE: This should probably be inlined.
	 * NOTE: This will only be called at the beginning of HalflingEngine::Run()
	 * TODO: Contemplate the cost/benefit of calling this once per frame
	 *
	 * @return    The period in milliseconds
	 */
	inline double GetUpdatePeriod() { return 30.0; }
	/**
	 * Called every time the game logic should be updated. The frequency
	 * of this being called is determined by getUpdatePeriod()
	 */
	void Update();
	void GamePaused();
	void GameUnpaused();
};

} // End of namespace CrateDemo

#endif

CRATE_DEMO: Update GameStateManager to use new base class name


#include <stdio.h>
int i, v, num1 = 0, num2 = 1, temp;

int main() {
  // Enter here number of times fib number is calculated;
  scanf("%d", &v);
  printf("Fibonacci numbers:");

  for (i; i <= v; i++) {
    // This prints fibonacci number;
    printf("%d, ", num1);
    // This calculates fibonacci number;
    temp = num1 + num2;
    num1 = num2;
    num2 = temp;
  }
  return 0;
}

Add Fibonacci algorithm in C

Add Fibonacci algorithm in C


/*	opendatacon
*
*	Copyright (c) 2015:
*
*		DCrip3fJguWgVCLrZFfA7sIGgvx1Ou3fHfCxnrz4svAi
*		yxeOtDhDCXf1Z4ApgXvX5ahqQmzRfJ2DoX8S05SqHA==
*
*	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 DAEMONWRAPPER_H
#define DAEMONWRAPPER_H

void daemonp();
void daemon_install();
void daemon_remove();

#endif

Add actual code to interface

Add actual code to interface


#if defined(__cplusplus) && !defined(OSF1)	/* GNU G++ */
#	include "fix_gnu_fcntl.h"
#elif defined(AIX32)						/* AIX bsdcc */
	typedef unsigned short ushort;
#	include <fcntl.h>
#elif defined(HPUX9)						/* HPUX 9 */
#	define fcntl __condor_hide_fcntl
#	include <fcntl.h>
#	undef fcntl
	int fcntl( int fd, int req, int arg );
#else										/* Everybody else */
#	include <fcntl.h>
#endif

#if defined(__cplusplus) && !defined(OSF1)	/* GNU G++ */
#	include "fix_gnu_fcntl.h"
#elif defined(AIX32)						/* AIX bsdcc */
#	if !defined(_ALL_SOURCE)
		typedef ushort_t    ushort;
#	endif
#	include <fcntl.h>
#elif defined(HPUX9)						/* HPUX 9 */
#	define fcntl __condor_hide_fcntl
#	include <fcntl.h>
#	undef fcntl
	int fcntl( int fd, int req, int arg );
#else										/* Everybody else */
#	include <fcntl.h>
#endif

Make sure that for AIX 3.2 we get ushort defined when we need it, but not doubly defined...


#ifndef TURING_H_
#define TURING_H_

#define TAPE_LEN 1024

#define turing_error(...) fprintf(stderr, __VA_ARGS__);\
    return TURING_ERROR

typedef int bool;

typedef enum {
    TURING_OK,
    TURING_HALT,
    TURING_ERROR
} turing_status_t;

typedef struct Turing {
    bool *tape;
    bool *p;
} Turing;

Turing *init_turing();
void free_turing(Turing *turing);
turing_status_t move_head(Turing *turing, int direction);

turing_status_t execute_instruction(Turing *turing, char *program);
turing_status_t execute_definite_instruction(Turing *turing, char *program);

#endif //  TURING_H_

#ifndef TURING_H_
#define TURING_H_

#define TAPE_LEN 1024

#define turing_error(...) fprintf(stderr, __VA_ARGS__);\
    return TURING_ERROR
#define move_head_left(t) move_head(t, 0)
#define move_head_right(t) move_head(t, 1)

typedef int bool;

typedef enum {
    TURING_OK,
    TURING_HALT,
    TURING_ERROR
} turing_status_t;

typedef struct Turing {
    bool *tape;
    bool *p;
} Turing;

Turing *init_turing();
void free_turing(Turing *turing);
turing_status_t move_head(Turing *turing, int direction);

turing_status_t execute_instruction(Turing *turing, char *program);
turing_status_t execute_definite_instruction(Turing *turing, char *program);

#endif //  TURING_H_

Implement left and right macros

Implement left and right macros