#include <stdio.h>

#ifndef ENV_NAME
#  define ENV_NAME "host"
#endif

int main(int argc, char* argv)
{
    printf("Hello World from Rebuild environment " ENV_NAME "\n");
    return 0;
}

#include <stdio.h>

#ifndef ENV_NAME
#  define ENV_NAME "host"
#endif

int main(int argc, char** argv)
{
    printf("Hello World from Rebuild environment " ENV_NAME "\n");
    return 0;
}

tests: Fix main parameter of the test application

[ci skip]

Signed-off-by: Yan Vugenfirer <e958ec5a56cd9794647c3623b3aa5a85122e74a5@daynix.com>


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

#include "stm32746g_discovery.h"
#include "stm32746g_discovery_lcd.h"
#include "stm32746g_discovery_sdram.h"

#define LCD_FRAMEBUFFER  SDRAM_DEVICE_ADDR

static void lcd_test(void) {
	if (BSP_LCD_Init() != LCD_OK) {
		printf(">>> BSP_LCD_Init failed\n");
	}

	/* Initialize the LCD Layers */
	BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FRAMEBUFFER);

	  /* Set LCD Foreground Layer  */
	BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);

	BSP_LCD_SetFont(&LCD_DEFAULT_FONT);

	/* Clear the LCD */
	BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
	BSP_LCD_Clear(LCD_COLOR_WHITE);

	/* Set the LCD Text Color */
	BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);

	/* Display LCD messages */
	BSP_LCD_DisplayStringAt(0, 10, (uint8_t *)"STM32F746G BSP", CENTER_MODE);

	BSP_LCD_SetTextColor(LCD_COLOR_DARKGREEN);
	BSP_LCD_DisplayStringAt(0, 60, (uint8_t *)"Embox LCD example", CENTER_MODE);

	BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
	BSP_LCD_DisplayStringAt(0, 200, (uint8_t *)"All rights reserved", CENTER_MODE);
}

int main(int argc, char *argv[]) {
	printf("STM32F7 LCD test start\n");

	lcd_test();

	while (1) {
	}

	return 0;
}

Add new cube-based LCD test

stm32f7: Add new cube-based LCD test


// SKIP PARAM: --sets ana.activated[+] octApron --enable ana.int.interval
#include <assert.h>

void foo(int a, int *pb) {
  int b = *pb;
   // base knows a == 4 and b == 4, octApron only knows a == 4
  assert(a == b);
}

void main() {
  int x, y, z, a, b;
  if (x < y && y < z) {
    // base doesn't know anything, octApron knows x < y < z
    assert(x < y);
    assert(y < z);
    assert(x < z);

    if (3 <= x && z <= 5) {
      // base knows 3 <= x and z <= 5, octApron knows x == 3 and y == 4 and z == 5
      a = y; // base should now know a == 4 via EvalInt query

      assert(x == 3);
      assert(y == 4);
      assert(z == 5);
      assert(a == 4);

      b = 4;
      foo(a, &b); // base should add a == 4 and b == 4 to context, octApron only adds a == 4
    }
  }
}

Add octapron test where base gets precise value for variable from octapron via EvalInt query


//
//  AXTabBar.h
//  Pods
//

#import <UIKit/UIKit.h>

typedef enum : NSUInteger {
  AXTabBarStyleDefault = 0,
  AXTabBarStyleVariableWidthButton,
} AXTabBarStyle;

@class AXTabBar;

@protocol AXTabBarDelegate <NSObject>
@optional
- (BOOL)tabBar:(AXTabBar *)tabBar shouldSelectItem:(UITabBarItem *)item;
- (void)tabBar:(AXTabBar *)tabBar didSelectItem:(UITabBarItem *)item;
@end

@interface AXTabBar : UIView
@property (copy, nonatomic) NSArray *items;
@property (assign, nonatomic) UITabBarItem *selectedItem;
@property (assign, nonatomic) id<AXTabBarDelegate> delegate;
@property (strong, nonatomic) UIFont *tabBarButtonFont;

// TODO: implement this style option.
//@property (nonatomic) AXTabBarStyle tabBarStyle;
@end

//
//  AXTabBar.h
//  Pods
//

#import <UIKit/UIKit.h>

typedef enum : NSUInteger {
  AXTabBarStyleDefault = 0,
  AXTabBarStyleVariableWidthButton,
} AXTabBarStyle;

@class AXTabBar;

@protocol AXTabBarDelegate <NSObject>
@optional
- (BOOL)tabBar:(AXTabBar *)tabBar shouldSelectItem:(UITabBarItem *)item;
- (void)tabBar:(AXTabBar *)tabBar didSelectItem:(UITabBarItem *)item;
@end

@interface AXTabBar : UIView
@property (copy, nonatomic) NSArray *items;
@property (assign, nonatomic) UITabBarItem *selectedItem;
@property (assign, nonatomic) id<AXTabBarDelegate> delegate;
@property (strong, nonatomic) UIFont *tabBarButtonFont;

@property (nonatomic) AXTabBarStyle tabBarStyle;

@end

Allow tab bar style property

Allow tab bar style property


#include <stdio.h>

void calcula(int* c) {
  printf("calcula %d %d\n", (*c), c);
  (*c)++;
  printf("calcula %d %d\n", (*c), c);
}

int main() {

  int c = 10;

  printf("main %d %d\n", c, &c);
  calcula(&c);
  printf("main %d %d\n", c, &c);
}

Update files, Alura, Introdução a C - Parte 2, Aula 5.1


//
//  NSDictionary+BONEquality.h
//  BonMot
//
//  Created by Zev Eisenberg on 7/11/15.
//  Copyright © 2015 Zev Eisenberg. All rights reserved.
//

@import Foundation;

@import CoreGraphics.CGBase;

OBJC_EXTERN const CGFloat kBONCGFloatEpsilon;
OBJC_EXTERN BOOL BONCGFloatsCloseEnough(CGFloat float1, CGFloat float2);

// clang-format off
@interface NSDictionary <KeyType, ObjectType> (BONEquality)

- (BOOL)bon_isCloseEnoughEqualToDictionary : (NSDictionary<KeyType, ObjectType> *_Nullable)dictionary;

@end
// clang-format off

//
//  NSDictionary+BONEquality.h
//  BonMot
//
//  Created by Zev Eisenberg on 7/11/15.
//  Copyright © 2015 Zev Eisenberg. All rights reserved.
//

@import Foundation;

@import CoreGraphics.CGBase;

OBJC_EXTERN const CGFloat kBONCGFloatEpsilon;
OBJC_EXTERN BOOL BONCGFloatsCloseEnough(CGFloat float1, CGFloat float2);

// clang-format off
@interface NSDictionary <KeyType, ObjectType> (BONEquality)

- (BOOL)bon_isCloseEnoughEqualToDictionary : (NSDictionary<KeyType, ObjectType> *_Nullable)dictionary;

@end
// clang-format on

Fix copypasta to re-enable clang-format.


#include "lua.h"

#include "lua_debug.h"

int main() {
    return 0;
}

#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"

#include "lua_debug.h"

static const luaL_Reg STANDARD_LIBS[] = {
    { "_G", luaopen_base },
    { LUA_TABLIBNAME, luaopen_table },
    { LUA_STRLIBNAME, luaopen_string },
    { LUA_MATHLIBNAME, luaopen_math },
    { LUA_DBLIBNAME, luaopen_debug },
    { 0, 0 }
};

int main() {
    lua_State * l = (lua_State *)luaL_newstate();
    const luaL_Reg *lib;

    for (lib = STANDARD_LIBS; lib->func; ++lib) {
        luaL_requiref(l, lib->name, lib->func, 1);
        lua_pop(l, 1);
    }

    lua_debug_init(l, "/tmp/socket_lua_debug");
    return 0;
}

Add a test program with a bit more substance.


// Copyright 2014 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 CONTENT_COMMON_RESOURCE_DEVTOOLS_INFO_H_
#define CONTENT_COMMON_RESOURCE_DEVTOOLS_INFO_H_

#include <string>
#include <vector>

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"

namespace content {

struct ResourceDevToolsInfo : base::RefCounted<ResourceDevToolsInfo> {
  typedef std::vector<std::pair<std::string, std::string> >
      HeadersVector;

  CONTENT_EXPORT ResourceDevToolsInfo();

  int32 http_status_code;
  std::string http_status_text;
  HeadersVector request_headers;
  HeadersVector response_headers;
  std::string request_headers_text;
  std::string response_headers_text;

 private:
  friend class base::RefCounted<ResourceDevToolsInfo>;
  CONTENT_EXPORT ~ResourceDevToolsInfo();
};

}  // namespace content

#endif  // CONTENT_COMMON_RESOURCE_DEVTOOLS_INFO_H_

// Copyright 2014 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 CONTENT_COMMON_RESOURCE_DEVTOOLS_INFO_H_
#define CONTENT_COMMON_RESOURCE_DEVTOOLS_INFO_H_

#include <string>
#include <vector>

#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/strings/string_split.h"
#include "content/common/content_export.h"

namespace content {

struct ResourceDevToolsInfo : base::RefCounted<ResourceDevToolsInfo> {
  typedef base::StringPairs HeadersVector;

  CONTENT_EXPORT ResourceDevToolsInfo();

  int32 http_status_code;
  std::string http_status_text;
  HeadersVector request_headers;
  HeadersVector response_headers;
  std::string request_headers_text;
  std::string response_headers_text;

 private:
  friend class base::RefCounted<ResourceDevToolsInfo>;
  CONTENT_EXPORT ~ResourceDevToolsInfo();
};

}  // namespace content

#endif  // CONTENT_COMMON_RESOURCE_DEVTOOLS_INFO_H_

Use base::StringPairs where appropriate from /content

Because base/strings/string_split.h defines:
typedef std::vector<std::pair<std::string, std::string> > StringPairs;

BUG=412250

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

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


#ifndef _ASM_POWERPC_BYTEORDER_H
#define _ASM_POWERPC_BYTEORDER_H

/*
 * 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.
 */
#include <linux/byteorder/big_endian.h>

#endif /* _ASM_POWERPC_BYTEORDER_H */

#ifndef _ASM_POWERPC_BYTEORDER_H
#define _ASM_POWERPC_BYTEORDER_H

/*
 * 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.
 */
#ifdef __LITTLE_ENDIAN__
#include <linux/byteorder/little_endian.h>
#else
#include <linux/byteorder/big_endian.h>
#endif

#endif /* _ASM_POWERPC_BYTEORDER_H */

powerpc: Include the appropriate endianness header

This patch will have powerpc include the appropriate generic endianness
header depending on what the compiler reports.

Signed-off-by: Ian Munsie <2796b2a6f60f1cdadaf10e577f7c9240e2ad3d38@au1.ibm.com>
Signed-off-by: Anton Blanchard <14deb5e5e417133e888bf47bb6a3555c9bb7d81c@samba.org>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>


// from SV-COMP: nla-digbench-scaling/ps6-ll_valuebound5.c
// contains deep integer expressions that shouldn't cause extremely exponential slowdown
// when evaluated by base's eval_rv and EvalInt jointly
// runs (as unknown) under 0.1s

#include <assert.h>
void assume_abort_if_not(int cond) {
  if(!cond) {abort();}
}

int main() {
    short k;
    long long y, x, c;
    assume_abort_if_not(k>=0 && k<=5);
    assume_abort_if_not(k <= 256);

    y = 0;
    x = 0;
    c = 0;

    while (1) {
        assert(-2*y*y*y*y*y*y - 6 * y*y*y*y*y - 5 * y*y*y*y + y*y + 12*x == 0);

        if (!(c < k))
            break;

        c = c + 1;
        y = y + 1;
        x = y * y * y * y * y + x;
    }

    assert(-2*y*y*y*y*y*y - 6 * y*y*y*y*y - 5 * y*y*y*y + y*y + 12*x == 0);
    assert(k*y == y*y);
    return 0;
}

Add regression test with deep integer expressions


#pragma once

void draw_seconds(GContext *ctx, uint8_t seconds, Layer *layer);
void draw_minutes(GContext *ctx, uint8_t minutes, Layer *layer);
void draw_hours(GContext *ctx, uint8_t hours, Layer *layer);

#pragma once

/*
This header file declares drawing methods that are defined in rect.c or round.c,
depending on the platform being built. Since the methods share the same function
signature, they can share the same header file, even though the implementations
of the functions themselves are different.
*/

void draw_seconds(GContext *ctx, uint8_t seconds, Layer *layer);
void draw_minutes(GContext *ctx, uint8_t minutes, Layer *layer);
void draw_hours(GContext *ctx, uint8_t hours, Layer *layer);

Add comment to header file about change

Add comment to header file about change


#include "ring.h"

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

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

RING_FUNC(ring_get_gl_zero)
{
	RING_API_RETNUMBER(GL_ZERO);
}

RING_FUNC(ring_get_gl_false)
{
	RING_API_RETNUMBER(GL_FALSE);
}

RING_FUNC(ring_get_gl_logic_op)
{
	RING_API_RETNUMBER(GL_LOGIC_OP);
}

RING_FUNC(ring_get_gl_none)
{
	RING_API_RETNUMBER(GL_NONE);
}

RING_API void ringlib_init(RingState *pRingState)
{
	ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
	ring_vm_funcregister("get_gl_false",ring_get_gl_false);
	ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
	ring_vm_funcregister("get_gl_none",ring_get_gl_none);
}

#include "ring.h"

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

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

RING_FUNC(ring_get_gl_zero)
{
	RING_API_RETNUMBER(GL_ZERO);
}

RING_FUNC(ring_get_gl_false)
{
	RING_API_RETNUMBER(GL_FALSE);
}

RING_FUNC(ring_get_gl_logic_op)
{
	RING_API_RETNUMBER(GL_LOGIC_OP);
}

RING_FUNC(ring_get_gl_none)
{
	RING_API_RETNUMBER(GL_NONE);
}

RING_FUNC(ring_get_gl_texture_components)
{
	RING_API_RETNUMBER(GL_TEXTURE_COMPONENTS);
}

RING_API void ringlib_init(RingState *pRingState)
{
	ring_vm_funcregister("get_gl_zero",ring_get_gl_zero);
	ring_vm_funcregister("get_gl_false",ring_get_gl_false);
	ring_vm_funcregister("get_gl_logic_op",ring_get_gl_logic_op);
	ring_vm_funcregister("get_gl_none",ring_get_gl_none);
	ring_vm_funcregister("get_gl_texture_components",ring_get_gl_texture_components);
}

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


#include <linux/module.h>    // included for all kernel modules
#include <linux/kernel.h>    // included for KERN_INFO
#include <linux/init.h>      // included for __init and __exit macros
#include <linux/proc_fs.h>

#define MODULE_NAME "rootkit"

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Julia Evans");
MODULE_DESCRIPTION("The tiniest rootkit");

static struct file_operations handler_fops;
const struct file_operations *handler_original = 0;
struct proc_dir_entry *handler, *root;

static ssize_t make_pid_root (
        struct file *filp,
        const char __user *data,
        size_t sz,
        loff_t *l)
{
    printk("YOU HAVE BEEN HACKED\n");
    return -1;
}
/**
 * Infects /proc/buddyinfo with a device handler that sets
*/
void install_handler(struct proc_dir_entry *root) {
    struct proc_dir_entry *ptr = root->subdir;
    while(ptr && strcmp(ptr->name, "buddyinfo"))
        ptr = ptr->next;
    if(ptr) {
        handler = ptr;
        ptr->mode |= S_IWUGO;
        handler_original = (struct file_operations*)ptr->proc_fops;
        // create new handler
        handler_fops = *ptr->proc_fops;
        handler_fops.write = make_pid_root;
        ptr->proc_fops = &handler_fops;
    }
}

static int __init module_init_proc(void) {
  static struct file_operations fileops_struct = {0};
  struct proc_dir_entry *new_proc;
  // dummy to get proc_dir_entry of /proc
  new_proc = proc_create("dummy", 0644, 0, &fileops_struct);
  root = new_proc->parent;

  // install the handler to wait for orders...
  install_handler(root);

  // it's no longer required.
  remove_proc_entry("dummy", 0);
  return 0;
}

static int __init rootkit_init(void)
{
    module_init_proc();
    printk(KERN_INFO "Starting kernel module!\n");
    return 0;    // Non-zero return means that the module couldn't be loaded.
}

static void __exit rootkit_cleanup(void)
{
  handler->proc_fops = handler_original;
  printk(KERN_INFO "Cleaning up module.\n");
}

module_init(rootkit_init);
module_exit(rootkit_cleanup);

Add module that prints YOU HAVE BEEN HACKED when writing to /proc/buddyinfo


#ifndef _IRC_H
#define _IRC_H

#define NICK "slackboat"
#define SERVER "irc.what.cd"
#define PASSWORD "thisistheonlygoodbot"

void irc_notice_event(char *, char *, char *);
void irc_welcome_event(void);
void irc_privmsg_event(char *, char *, char *);
void irc_privmsg(const char *, const char *);
void irc_join_channel(const char *);

#endif

#ifndef _IRC_H
#define _IRC_H

#define NICK "slackboat"
#define SERVER "irc.what.cd"
#define PASSWORD "PASSWORD"

void irc_notice_event(char *, char *, char *);
void irc_welcome_event(void);
void irc_privmsg_event(char *, char *, char *);
void irc_privmsg(const char *, const char *);
void irc_join_channel(const char *);

#endif

Structure the program for minimum coupling


/* Copyright (c) 2016, Nokia
 * Copyright (c) 2016, ENEA Software AB
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef __OFP_EPOLL_H__
#define __OFP_EPOLL_H__

#include <stdint.h>

typedef union ofp_epoll_data {
	void    *ptr;
	int      fd;
	uint32_t u32;
	uint64_t u64;
} ofp_epoll_data_t;

struct ofp_epoll_event {
	uint32_t events;
	ofp_epoll_data_t data;
};

enum OFP_EPOLL_EVENTS {
	OFP_EPOLLIN = 0x001,
#define OFP_EPOLLIN OFP_EPOLLIN
};

#define OFP_EPOLL_CTL_ADD 1
#define OFP_EPOLL_CTL_DEL 2
#define OFP_EPOLL_CTL_MOD 3

int ofp_epoll_create(int size);

int ofp_epoll_ctl(int epfd, int op, int fd, struct ofp_epoll_event *event);

int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);

#endif

/* Copyright (c) 2016, Nokia
 * Copyright (c) 2016, ENEA Software AB
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef __OFP_EPOLL_H__
#define __OFP_EPOLL_H__

#include <stdint.h>

#if __GNUC__ >= 4
#pragma GCC visibility push(default)
#endif

typedef union ofp_epoll_data {
	void    *ptr;
	int      fd;
	uint32_t u32;
	uint64_t u64;
} ofp_epoll_data_t;

struct ofp_epoll_event {
	uint32_t events;
	ofp_epoll_data_t data;
};

enum OFP_EPOLL_EVENTS {
	OFP_EPOLLIN = 0x001,
#define OFP_EPOLLIN OFP_EPOLLIN
};

#define OFP_EPOLL_CTL_ADD 1
#define OFP_EPOLL_CTL_DEL 2
#define OFP_EPOLL_CTL_MOD 3

int ofp_epoll_create(int size);

int ofp_epoll_ctl(int epfd, int op, int fd, struct ofp_epoll_event *event);

int ofp_epoll_wait(int epfd, struct ofp_epoll_event *events, int maxevents, int timeout);

#if __GNUC__ >= 4
#pragma GCC visibility pop
#endif

#endif

Add visibility to epoll headers

Add visibility to epoll headers

The odp_epoll_* symbols were not visible in the final library built with
GCC.

Signed-off-by: Oriol Arcas <a98c9d4e37de3d71db2e1a293b51c579a914c4ae@starflownetworks.com>
Reviewed-by: Sorin Vultureanu <8013ba55f8675034bc2ab0d6c3a1c9650437ca36@enea.com>


#include <string.h>
#include <math.h>
#include <float.h>
#include <glib.h>
#include <json-glib/json-glib.h>

#define json_fuzzy_equals(n1,n2,epsilon) \
  (((n1) > (n2) ? ((n1) - (n2)) : ((n2) - (n1))) < (epsilon))

#define json_assert_fuzzy_equals(n1,n2,epsilon) \
  G_STMT_START { \
    double __n1 = (n1), __n2 = (n2), __epsilon = (epsilon); \
    if (json_fuzzy_equals (__n1, __n2, __epsilon)) ; else { \
      g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
                                  #n1 " == " #n2 " (+/- " #epsilon ")", \
                                  __n1, "==", __n2, 'f'); \
    } \
  } G_STMT_END

#define json_assert_almost_equals(n1,n2) \
  json_assert_fuzzy_equals (n1, n2, DBL_EPSILON)

Add float comparison utility macros for tests

We do compare floating point values elsewhere in our code, so we should
ensure that we're doing that with a certain amount of fuzziness.


/*
 *  Copyright (c) 2014, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in
 *  the LICENSE file in the root directory of this source tree. An
 *  additional grant of patent rights can be found in the PATENTS file
 *  in the same directory.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <arpa/inet.h>
#include <string.h>
#include "util.h"
#include "autocmd.h"
#include "fs.h"
#include "child.h"
#include "net.h"
#include "strutil.h"
#include "constants.h"

FORWARD(start_daemon);

#if !FBADB_MAIN
#include "stubdaemon.h"

int
start_daemon_main(const struct cmd_start_daemon_info* info)
{
    struct cmd_stub_info sinfo = {
        .stub.listen = true,
        .stub.daemonize = true,
        .stub.replace = info->start_daemon.replace,
    };

    return stub_main(&sinfo);
}

#endif

/*
 *  Copyright (c) 2014, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in
 *  the LICENSE file in the root directory of this source tree. An
 *  additional grant of patent rights can be found in the PATENTS file
 *  in the same directory.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#include <arpa/inet.h>
#include <string.h>
#include "util.h"
#include "autocmd.h"
#include "fs.h"
#include "child.h"
#include "net.h"
#include "strutil.h"
#include "constants.h"

FORWARD(start_daemon);

#if !FBADB_MAIN
#include "stubdaemon.h"

int
start_daemon_main(const struct cmd_start_daemon_info* info)
{
    SCOPED_RESLIST(rl);

    struct cmd_stub_info sinfo = {
        .stub.listen = true,
        .stub.daemonize = true,
        .stub.replace = info->start_daemon.replace,
    };

    set_prgname(xaprintf("%s stub", xbasename(orig_argv0)));
    return stub_main(&sinfo);
}

#endif

Set prgname to stub while in daemon

Set prgname to stub while in daemon


#include <stdio.h>

int int_func(void)
{
  return 42;
}

float float_func(void)
{
  return 13.5f;
}

int main(int argc, char *argv[])
{
  printf("calltest.c\n");

  printf("  Calling int   function: %d\n", int_func());
  printf("  Calling float function: %f\n", float_func());

  return 0;
}

#include <stdio.h>

int int_func(void)
{
  return 42;
}

float float_func(void)
{
  return 13.5f;
}

double double_func(void)
{
  return 13.5;
}

int main(int argc, char *argv[])
{
  printf("calltest.c\n");

  printf("  Calling int    function: %d\n", int_func());
  printf("  Calling float  function: %f\n", float_func());
  printf("  Calling double function: %f\n", double_func());

  return 0;
}

Add test for double call

Add test for double call

[r15890]


#include <stdio.h>

int main()
{
    printf("hello, world\n");
}

#include <stdio.h>

int main()
{
    printf("hello, world\n");
    return 0;
}

Fix gcc warning when -Wall (implicit return).

warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^


/**
 * @file
 * @brief Paranoia checks of doubly-linked lists
 *
 * @date 05.12.2013
 * @author Eldar Abusalimov
 */
#include <inttypes.h>
#include <assert.h>

#include <util/dlist.h>

#if DLIST_DEBUG_VERSION
void __dlist_debug_check(const struct dlist_head *head) {
	const struct dlist_head *p = head->prev;
	const struct dlist_head *n = head->next;
	uintptr_t poison = head->poison;

	assertf(((!poison || (void *) ~poison == head) &&
			n->prev == head &&
			p->next == head),
			"\n"
			"head: %p, poison: %p, ~poison: %p,\n"
			"n: %p, n->prev: %p,\n"
			"p: %p, p->next: %p\n",
			head, (void *)poison, (void *) ~poison,
			n, n->prev,
			p, p->next);
}
#endif

/**
 * @file
 * @brief Paranoia checks of doubly-linked lists
 *
 * @date 05.12.2013
 * @author Eldar Abusalimov
 */
#include <inttypes.h>
#include <assert.h>

#include <util/dlist.h>

#if DLIST_DEBUG_VERSION
void __dlist_debug_check(const struct dlist_head *head) {
#ifndef NDEBUG
	const struct dlist_head *p = head->prev;
	const struct dlist_head *n = head->next;
	uintptr_t poison = head->poison;

	assertf(((!poison || (void *) ~poison == head) &&
			n->prev == head &&
			p->next == head),
			"\n"
			"head: %p, poison: %p, ~poison: %p,\n"
			"n: %p, n->prev: %p,\n"
			"p: %p, p->next: %p\n",
			head, (void *)poison, (void *) ~poison,
			n, n->prev,
			p, p->next);
#endif
}
#endif

Fix dlist compilation with NDEBUG flag

minor: Fix dlist compilation with NDEBUG flag


// compile with clang:
// clang -march=skylake randbin.c
// or whatever architecture you have. It only works on certain architectures.

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

int main(int argc, char **argv) {
    int filesize = 0;
    char byte_multiplier = 0;
    if (argc <= 1) {
        filesize = 512 * 1024;
    } else {
        sscanf(argv[1], "%u%c", &filesize, &byte_multiplier);
    }

    switch (byte_multiplier) {
        case 'k':
        case 'K':
            filesize *= 1024;
            break;

        case 'm':
        case 'M':
            filesize *= 1024 * 1024;
            break;
    }

    FILE *fout = fopen("out.bin", "wb");

    if (filesize <= 4) {
        unsigned int a = 0;
        __builtin_ia32_rdrand32_step(&a);
        fwrite(&a, 1, filesize, fout);
    } else {
        int bytes = (int)floor((double)filesize / 4) + (filesize % 4);
        for (int i = 0; i < bytes; i++) {
            unsigned int a = 0;
            __builtin_ia32_rdrand32_step(&a);
            fwrite(&a, sizeof a, 1, fout);
        }
    }

    fclose(fout);
    return 0;
}

Add little program that generates random binaries

I uses the assembly instruction ```rdrand``` via the clang compiler's builtin.


#include <stdio.h>

const int N = 1e5;

int lis(int a[], int n) {
	int i, j;
	int dp[N];

	for(i = 0; i < n; ++i)
		dp[i] = 1;

	for(i = 0; i < n; ++i)
		for(j = 0; j < i; ++j)
			if(a[j] < a[i])
				if(dp[i] < dp[j] + 1)
					dp[i] = dp[j] + 1;

	int mx = 0;
	for(i = 0; i < n; ++i)
		if(mx < dp[i])
			mx = dp[i];

	return mx;
}

int main() {
	int n;
	scanf("%d", &n);

	int a[N];
	int i;
	for(i = 0; i < n; ++i)
		scanf("%d", &a[i]);

	printf("%d\n", lis(a, n));
}

Add longest increasing subsequence in C language.


#ifndef _PKG_UTIL_H
#define _PKG_UTIL_H

#include <sys/types.h>
#include <sys/sbuf.h>
#include <sys/param.h>

#define ARRAY_INIT {0, 0, NULL}

struct array {
	size_t cap;
	size_t len;
	void **data;
};

#define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)

#define ERROR_SQLITE(db) \
	EMIT_PKG_ERROR("sqlite: %s", sqlite3_errmsg(db))

int sbuf_set(struct sbuf **, const char *);
const char * sbuf_get(struct sbuf *);
void sbuf_reset(struct sbuf *);
void sbuf_free(struct sbuf *);

int mkdirs(const char *path);
int file_to_buffer(const char *, char **, off_t *);
int format_exec_cmd(char **, const char *, const char *, const char *);
int split_chr(char *, char);
int file_fetch(const char *, const char *);
int is_dir(const char *);
int is_conf_file(const char *path, char newpath[MAXPATHLEN]);

int sha256_file(const char *, char[65]);
void sha256_str(const char *, char[65]);
#endif

#ifndef _PKG_UTIL_H
#define _PKG_UTIL_H

#include <sys/types.h>
#include <sys/sbuf.h>
#include <sys/param.h>

#define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)

#define ERROR_SQLITE(db) \
	EMIT_PKG_ERROR("sqlite: %s", sqlite3_errmsg(db))

int sbuf_set(struct sbuf **, const char *);
const char * sbuf_get(struct sbuf *);
void sbuf_reset(struct sbuf *);
void sbuf_free(struct sbuf *);

int mkdirs(const char *path);
int file_to_buffer(const char *, char **, off_t *);
int format_exec_cmd(char **, const char *, const char *, const char *);
int split_chr(char *, char);
int file_fetch(const char *, const char *);
int is_dir(const char *);
int is_conf_file(const char *path, char newpath[MAXPATHLEN]);

int sha256_file(const char *, char[65]);
void sha256_str(const char *, char[65]);
#endif

Remove last occurences of the dead struct array


//===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// The GenericValue class is used to represent an LLVM value of arbitrary type.
//
//===----------------------------------------------------------------------===//

#ifndef GENERIC_VALUE_H
#define GENERIC_VALUE_H

#include "Support/DataTypes.h"

namespace llvm {

typedef uint64_t PointerTy;

union GenericValue {
  bool            BoolVal;
  unsigned char   UByteVal;
  signed   char   SByteVal;
  unsigned short  UShortVal;
  signed   short  ShortVal;
  unsigned int    UIntVal;
  signed   int    IntVal;
  uint64_t        ULongVal;
  int64_t         LongVal;
  double          DoubleVal;
  float           FloatVal;
  PointerTy       PointerVal;
  unsigned char   Untyped[8];

  GenericValue() {}
  GenericValue(void *V) {
    PointerVal = (PointerTy)(intptr_t)V;
  }
};

inline GenericValue PTOGV(void *P) { return GenericValue(P); }
inline void* GVTOP(const GenericValue &GV) {
  return (void*)(intptr_t)GV.PointerVal;
}

} // End llvm namespace
#endif

//===-- GenericValue.h - Represent any type of LLVM value -------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// The GenericValue class is used to represent an LLVM value of arbitrary type.
//
//===----------------------------------------------------------------------===//

#ifndef GENERIC_VALUE_H
#define GENERIC_VALUE_H

#include "Support/DataTypes.h"

namespace llvm {

typedef uintptr_t PointerTy;

union GenericValue {
  bool            BoolVal;
  unsigned char   UByteVal;
  signed   char   SByteVal;
  unsigned short  UShortVal;
  signed   short  ShortVal;
  unsigned int    UIntVal;
  signed   int    IntVal;
  uint64_t        ULongVal;
  int64_t         LongVal;
  double          DoubleVal;
  float           FloatVal;
  PointerTy       PointerVal;
  unsigned char   Untyped[8];

  GenericValue() {}
  GenericValue(void *V) {
    PointerVal = (PointerTy)(intptr_t)V;
  }
};

inline GenericValue PTOGV(void *P) { return GenericValue(P); }
inline void* GVTOP(const GenericValue &GV) {
  return (void*)(intptr_t)GV.PointerVal;
}

} // End llvm namespace
#endif

Use uintptr_t for pointer values in the ExecutionEngine.

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


//
//  NSDate+GTTimeAdditions.h
//  ObjectiveGitFramework
//
//  Created by Danny Greg on 27/03/2013.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "git2.h"

@interface NSDate (GTTimeAdditions)

// Creates a new `NSDate` from the provided `git_time`.
//
// time     - The `git_time` to base the returned date on.
// timeZone - The timezone used by the time passed in.
//
// Returns an `NSDate` object representing the passed in `time`.
+ (NSDate *)gt_dateFromGitTime:(git_time)time timeZone:(NSTimeZone **)timeZone;

// Converts the date to a `git_time`.
//
// timeZone - An `NSTimeZone` to describe the time offset. This is optional, if
//            `nil` the default time zone will be used.
- (git_time)gt_gitTimeUsingTimeZone:(NSTimeZone *)timeZone;

@end

@interface NSTimeZone (GTTimeAdditions)

// The difference, in minutes, between the current default timezone and GMT.
@property (nonatomic, readonly) int gt_gitTimeOffset;

@end

//
//  NSDate+GTTimeAdditions.h
//  ObjectiveGitFramework
//
//  Created by Danny Greg on 27/03/2013.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "git2.h"

@interface NSDate (GTTimeAdditions)

// Creates a new `NSDate` from the provided `git_time`.
//
// time     - The `git_time` to base the returned date on.
// timeZone - The timezone used by the time passed in. Optional.
//
// Returns an `NSDate` object representing the passed in `time`.
+ (NSDate *)gt_dateFromGitTime:(git_time)time timeZone:(NSTimeZone **)timeZone;

// Converts the date to a `git_time`.
//
// timeZone - An `NSTimeZone` to describe the time offset. This is optional, if
//            `nil` the default time zone will be used.
- (git_time)gt_gitTimeUsingTimeZone:(NSTimeZone *)timeZone;

@end

@interface NSTimeZone (GTTimeAdditions)

// The difference, in minutes, between the current default timezone and GMT.
@property (nonatomic, readonly) int gt_gitTimeOffset;

@end

Document the timeZone as being optional.


#include <stdlib.h>
#include <curses.h>
#include <time.h>

#include "game.h"
#include "ui.h"

static void shutdown(void);

int main(int argc, char ** argv)
{
    srand(time(NULL));

    initscr();
    cbreak();
    noecho();
    curs_set(0);
    keypad(stdscr, TRUE);

    start_color();
    init_pair(color_black,   COLOR_BLACK,   COLOR_BLACK);
    init_pair(color_yellow,  COLOR_YELLOW,  COLOR_BLACK);
    init_pair(color_blue,    COLOR_BLUE,    COLOR_BLACK);
    init_pair(color_red,     COLOR_RED,     COLOR_BLACK);
    init_pair(color_green,   COLOR_GREEN,   COLOR_BLACK);
    init_pair(color_cyan,    COLOR_CYAN,    COLOR_BLACK);
    init_pair(color_magenta, COLOR_MAGENTA, COLOR_BLACK);

    if (LINES < 24 || COLS < 80)
    {
        shutdown();
        printf("Terminal too small.");
        exit(1);
    }

    do
    {
      erase();
      new_game();
    }
    while (play());

    shutdown();

    return 0;
}

static void shutdown(void)
{
    endwin();
    return;
}

#include <stdlib.h>
#include <curses.h>
#include <time.h>

#include "game.h"
#include "ui.h"

static void shutdown(void);

int main(int argc, char ** argv)
{
    time_t random_seed = time(NULL);
    printf("Random game #%ld\n", random_seed);
    srand(random_seed);

    initscr();
    cbreak();
    noecho();
    curs_set(0);
    keypad(stdscr, TRUE);

    start_color();
    init_pair(color_black,   COLOR_BLACK,   COLOR_BLACK);
    init_pair(color_yellow,  COLOR_YELLOW,  COLOR_BLACK);
    init_pair(color_blue,    COLOR_BLUE,    COLOR_BLACK);
    init_pair(color_red,     COLOR_RED,     COLOR_BLACK);
    init_pair(color_green,   COLOR_GREEN,   COLOR_BLACK);
    init_pair(color_cyan,    COLOR_CYAN,    COLOR_BLACK);
    init_pair(color_magenta, COLOR_MAGENTA, COLOR_BLACK);

    if (LINES < 24 || COLS < 80)
    {
        shutdown();
        printf("Terminal too small.");
        exit(1);
    }

    do
    {
      erase();
      new_game();
    }
    while (play());

    shutdown();

    return 0;
}

static void shutdown(void)
{
    endwin();
    return;
}

Print random seed for sharing / debugging purposes


/* Main program for TGL (Text Generation Language). */

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

int main(int argc, char** argv) {
  printf("hello world\n");
  return 0;
}

/* Main program for TGL (Text Generation Language). */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>

/* BEGIN: String handling (strings may have NUL bytes within, and are not
 * NUL-terminated).
 */

/* Defines a length-prefixed string.
 * The string contents start at the byte after the struct itself.
 */
typedef struct string { unsigned len; }* string;
typedef unsigned char byte;

/* Returns a pointer to the beginning of character data of the given string. */
static inline byte* string_data(string s) {
  byte* c = (byte*)s;
  return c + sizeof(struct string);
}

/* Converts a C string to a TGL string.
 * The string must be free()d by the caller.
 */
static string covert_string(char* str) {
  unsigned int len = strlen(str);
  string result = malloc(sizeof(struct string) + len);
  result->len = len;
  memcpy(string_data(result), str, len);
  return result;
}

/* Duplicates the given TGL string.
 * The string must be free()d by the caller.
 */
static string dupe_string(string str) {
  string result = malloc(sizeof(struct string) + str->len);
  memcpy(result, str, sizeof(struct string) + str->len);
  return result;
}
/* END: String handling */

int main(int argc, char** argv) {
  printf("hello world\n");
  return 0;
}

Add length-prefixed string handling functions.


//
//  BBASearchSuggestionsResult.h
//  BBBAPI
//
//  Created by Owen Worley on 12/01/2015.
//  Copyright (c) 2015 Blinkbox Entertainment Ltd. All rights reserved.
//

#import <Foundation/Foundation.h>
@class FEMObjectMapping;

/**
 *  Represents data returned from the book search suggestions service (search/suggestions)
 */
@interface BBASearchSuggestionsResult : NSObject

@property (nonatomic, copy) NSString *type;
@property (nonatomic, copy) NSArray *items;

/**
 *  Describes the mapping of server search result data to `BBASearchSuggestionsResult`
 */
+ (FEMObjectMapping *) searchSuggestionsResultMapping;

@end

//
//  BBASearchSuggestionsResult.h
//  BBBAPI
//
//  Created by Owen Worley on 12/01/2015.
//  Copyright (c) 2015 Blinkbox Entertainment Ltd. All rights reserved.
//

#import <Foundation/Foundation.h>
@class FEMObjectMapping;

/**
 *  Represents data returned from the book search suggestions service (search/suggestions)
 */
@interface BBASearchSuggestionsResult : NSObject

@property (nonatomic, copy) NSString *type;
/**
 *  Contains `BBASearchServiceSuggestion` objects
 */
@property (nonatomic, copy) NSArray *items;

/**
 *  Describes the mapping of server search result data to `BBASearchSuggestionsResult`
 */
+ (FEMObjectMapping *) searchSuggestionsResultMapping;

@end

Document contents of items array

Document contents of items array


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

typedef struct Poly Poly;

struct Poly {
	int32_t coef;
	int32_t abc;
	Poly *link;
};

int	add(Poly *q, Poly *p);

Poly *avail;

int
main(int argc, char **argv)
{
	Poly *pool, *p;

	pool = calloc(500, sizeof(*pool));
	for(p = pool; p < pool+499; p++)
		p->link = p+1;
	p->link = NULL;
	avail = pool;

	exit(0);
}

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

typedef struct Poly Poly;

struct Poly {
	int32_t coef;
	int32_t abc;
	Poly *link;
};

int	add(Poly *q, Poly *p);

Poly *avail;

Poly*
makepoly(void)
{
	Poly *p;

	if(avail == NULL)
		return NULL;
	p = avail;
	avail = avail->link;
	p->abc = -1;
	p->coef = 0;
	p->link = p;
	return p;
}

int
addterm(Poly *p, int32_t coef, unsigned char a, unsigned char b, unsigned char c)
{
	Poly *q, *r;
	int32_t abc;

	abc = (a << 16) + (b << 8) + c;

	for(r = p->link; abc < r->abc; r = p->link)
		p = r;

	if(abc == r->abc) {
		r->coef += coef;
		return 0;
	}

	if(avail == NULL)
		return -1;
	q = avail;
	avail = avail->link;

	q->coef = coef;
	q->abc = abc;
	q->link = r;

	p->link = q;
	return 0;
}

int
main(int argc, char **argv)
{
	Poly *pool, *p;

	pool = calloc(500, sizeof(*pool));
	for(p = pool; p < pool+499; p++)
		p->link = p+1;
	p->link = NULL;
	avail = pool;

	exit(0);
}

Add infrastructure for constructing polynomials


//
//  ASFRequestBuilder.h
//  ASFFeedly
//
//  Created by Anton Simakov on 12/12/13.
//  Copyright (c) 2013 Anton Simakov. All rights reserved.
//

#import <Foundation/Foundation.h>

extern NSURL *ASFURLByAppendingParameters(NSURL *URL, NSDictionary *parameters);
extern NSString *ASFQueryFromURL(NSURL *URL);
extern NSString *ASFQueryFromParameters(NSDictionary *parameters);
extern NSString *ASFURLEncodedString(NSString *string);
extern NSString *ASFURLDecodedString(NSString *string);
extern NSDictionary *ASFParametersFromQuery(NSString *query);

@interface ASFRequestBuilder : NSObject

+ (NSMutableURLRequest *)requestWithMethod:(NSString *)method
                                 URLString:(NSString *)URLString
                                parameters:(NSDictionary *)parameters
                                     token:(NSString *)token
                                     error:(NSError *__autoreleasing *)error;

+ (NSMutableURLRequest *)requestWithURL:(NSURL *)URL
                                 method:(NSString *)method
                             parameters:(NSDictionary *)parameters
                                  error:(NSError *__autoreleasing *)error;

@end

//
//  ASFRequestBuilder.h
//  ASFFeedly
//
//  Created by Anton Simakov on 12/12/13.
//  Copyright (c) 2013 Anton Simakov. All rights reserved.
//

#import <Foundation/Foundation.h>

extern NSURL *ASFURLByAppendingParameters(NSURL *URL, NSDictionary *parameters);
extern NSString *ASFQueryFromURL(NSURL *URL);
extern NSString *ASFQueryFromParameters(NSDictionary *parameters);
extern NSString *ASFURLEncodedString(NSString *string);
extern NSString *ASFURLDecodedString(NSString *string);
extern NSDictionary *ASFParametersFromQuery(NSString *query);

@interface ASFRequestBuilder : NSObject

+ (NSMutableURLRequest *)requestWithMethod:(NSString *)method
                                 URLString:(NSString *)URLString
                                parameters:(NSDictionary *)parameters
                                     token:(NSString *)token
                                     error:(NSError *__autoreleasing *)error;

@end

Remove private method from the public interface


//
//  OCErrorMsg.h
//  Owncloud iOs Client
//
// Copyright (c) 2014 ownCloud (http://www.owncloud.org/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

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

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

#define kOCErrorServerUnauthorized 401
#define kOCErrorServerForbidden 403
#define kOCErrorServerPathNotFound 404
#define kOCErrorProxyAuth 407
#define kOCErrorServerTimeout 408

//
//  OCErrorMsg.h
//  Owncloud iOs Client
//
// Copyright (c) 2014 ownCloud (http://www.owncloud.org/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

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

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

#define kOCErrorServerUnauthorized 401
#define kOCErrorServerForbidden 403
#define kOCErrorServerPathNotFound 404
#define kOCErrorServerMethodNotPermitted 405c
#define kOCErrorProxyAuth 407
#define kOCErrorServerTimeout 408

Add error constant for not permmited methods in the server


#ifndef BITCOINADDRESSVALIDATOR_H
#define BITCOINADDRESSVALIDATOR_H

#include <QValidator>

/** Base48 entry widget validator.
   Corrects near-miss characters and refuses characters that are no part of base48.
 */
class BitcoinAddressValidator : public QValidator
{
    Q_OBJECT

public:
    explicit BitcoinAddressValidator(QObject *parent = 0);

    State validate(QString &input, int &pos) const;

    static const int MaxAddressLength = 35;
};

#endif // BITCOINADDRESSVALIDATOR_H

#ifndef BITCOINADDRESSVALIDATOR_H
#define BITCOINADDRESSVALIDATOR_H

#include <QValidator>

/** Base58 entry widget validator.
   Corrects near-miss characters and refuses characters that are not part of base58.
 */
class BitcoinAddressValidator : public QValidator
{
    Q_OBJECT

public:
    explicit BitcoinAddressValidator(QObject *parent = 0);

    State validate(QString &input, int &pos) const;

    static const int MaxAddressLength = 35;
};

#endif // BITCOINADDRESSVALIDATOR_H

Fix typo in a comment: it's base58, not base48.


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

#pragma once

#include <vespa/eval/eval/tensor_spec.h>
#include <vespa/eval/tensor/default_tensor_engine.h>
#include <vespa/vespalib/testkit/test_kit.h>

namespace vespalib::tensor::test {

template <typename T>
std::unique_ptr<T>
makeTensor(const vespalib::eval::TensorSpec &spec)
{
    auto value = DefaultTensorEngine::ref().from_spec(spec);
    const T *tensor = dynamic_cast<const T *>(value->as_tensor());
    ASSERT_TRUE(tensor);
    value.release();
    return std::unique_ptr<T>(const_cast<T *>(tensor));
}

}

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

#pragma once

#include <vespa/eval/eval/tensor_spec.h>
#include <vespa/eval/tensor/default_tensor_engine.h>
#include <vespa/vespalib/testkit/test_kit.h>

namespace vespalib::tensor::test {

template <typename T>
std::unique_ptr<const T>
makeTensor(const vespalib::eval::TensorSpec &spec)
{
    auto value = DefaultTensorEngine::ref().from_spec(spec);
    const T *tensor = dynamic_cast<const T *>(value->as_tensor());
    ASSERT_TRUE(tensor);
    value.release();
    return std::unique_ptr<const T>(tensor);
}

}

Return unique pointer to const tensor instead.


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

  Program:   Visualization Toolkit
  Module:    Tokenizer.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

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

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

/*
 * Copyright 2003 Sandia Corporation.
 * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
 * license for use of this work by or on behalf of the
 * U.S. Government. Redistribution and use in source and binary forms, with
 * or without modification, are permitted provided that this Notice and any
 * statement of authorship are reproduced on all copies.
 */

#include <vtkstd/string>

class Tokenizer
{
public:
  Tokenizer(const char *s, const char *delim = " \t\n");
  Tokenizer(const vtkstd::string &s, const char *delim = " \t\n");

  vtkstd::string GetNextToken();
  vtkstd::string GetRemainingString() const;
  bool HasMoreTokens() const;

  void Reset();

private:
  vtkstd::string FullString;
  vtkstd::string Delim;
  vtkstd::string::size_type Position;
};

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

  Program:   Visualization Toolkit
  Module:    Tokenizer.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

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

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

/*
 * Copyright 2003 Sandia Corporation.
 * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
 * license for use of this work by or on behalf of the
 * U.S. Government. Redistribution and use in source and binary forms, with
 * or without modification, are permitted provided that this Notice and any
 * statement of authorship are reproduced on all copies.
 */

#include <vtkstd/string>

class Tokenizer
{
public:
  Tokenizer(const char *s, const char *delim = " \t\n\r");
  Tokenizer(const vtkstd::string &s, const char *delim = " \t\n\r");

  vtkstd::string GetNextToken();
  vtkstd::string GetRemainingString() const;
  bool HasMoreTokens() const;

  void Reset();

private:
  vtkstd::string FullString;
  vtkstd::string Delim;
  vtkstd::string::size_type Position;
};

BUG: Add carriage return to the list of default delimiters to correctly handle
"windows-style" end of line on "unix-style" systems.


//
//  OEXRegistrationFieldValidation.h
//  edXVideoLocker
//
//  Created by Jotiram Bhagat on 03/03/15.
//  Copyright (c) 2015 edX. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "OEXRegistrationFormField.h"
@interface OEXRegistrationFieldValidator : NSObject
+(NSString *)validateField:(OEXRegistrationFormField *)field withText:(NSString *)currentValue;
@end

//
//  OEXRegistrationFieldValidation.h
//  edXVideoLocker
//
//  Created by Jotiram Bhagat on 03/03/15.
//  Copyright (c) 2015 edX. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "OEXRegistrationFormField.h"
@interface OEXRegistrationFieldValidator : NSObject
/// Returns an error string, or nil if no error
+(NSString *)validateField:(OEXRegistrationFormField *)field withText:(NSString *)currentValue;
@end

Add comment for validation method

Add comment for validation method


#ifndef FUSTATE_H
#define FUSTATE_H
#include <SFML/Window/Event.hpp>
#include <SFML/System/Time.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <memory>
class FUStateManager;

class FUState
{
public:
    struct FUContext
    {
        FUContext(std::shared_ptr<sf::RenderWindow> window)
            : renderWindow(window) {}
        std::shared_ptr<sf::RenderWindow> renderWindow;
    };

public:
    FUState(FUContext context);
    virtual ~FUState();
    virtual void handleEvent(sf::Event &event);
    virtual void update(sf::Time dt);
    virtual void draw();
    virtual void pause();
    virtual void resume();

protected:
    bool mIsPaused;
};

#endif // FUSTATE_H

#ifndef FUSTATE_H
#define FUSTATE_H
#include <SFML/Window/Event.hpp>
#include <SFML/System/Time.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
#include <memory>

class FUState
{
public:
    struct FUContext
    {
        FUContext(std::shared_ptr<sf::RenderWindow> window)
            : renderWindow(window) {}
        std::shared_ptr<sf::RenderWindow> renderWindow;
    };

public:
    FUState(FUContext context);
    virtual ~FUState();
    virtual void handleEvent(sf::Event &event);
    virtual void update(sf::Time dt);
    virtual void draw();
    virtual void pause();
    virtual void resume();

protected:
    bool mIsPaused;
};

#endif // FUSTATE_H

Delete an unnecessary forward decleration


#ifndef __HIREDIS_FMACRO_H
#define __HIREDIS_FMACRO_H

#if defined(__linux__)
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#endif

#if defined(__CYGWIN__)
#include <sys/cdefs.h>
#endif

#if defined(__sun__)
#define _POSIX_C_SOURCE 200112L
#else
#if !(defined(__APPLE__) && defined(__MACH__)) && !(defined(__FreeBSD__))
#define _XOPEN_SOURCE 600
#endif
#endif

#if defined(__APPLE__) && defined(__MACH__)
#define _OSX
#endif

#endif

#ifndef __HIREDIS_FMACRO_H
#define __HIREDIS_FMACRO_H

#if defined(__linux__)
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#endif

#if defined(__CYGWIN__)
#include <sys/cdefs.h>
#endif

#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define _XOPEN_SOURCE 600
#elif defined(__APPLE__) && defined(__MACH__)
#define _XOPEN_SOURCE
#elif defined(__FreeBSD__)
// intentionally left blank, don't define _XOPEN_SOURCE
#else
#define _XOPEN_SOURCE
#endif

#if defined(__sun__)
#define _POSIX_C_SOURCE 200112L
#endif

#if defined(__APPLE__) && defined(__MACH__)
#define _OSX
#endif

#endif

Make XOPEN_SOURCE definition explicit per architecture

Fixes #441


#pragma once

#include "../Controls/Controls.h"
#include "../Controls/TabPage.h"

///
/// Abstract class that encapsulates functionality for dealing with
/// property sheet pages (tabs).
///
class SettingsTab : public TabPage {
public:
    SettingsTab(HINSTANCE hInstance, LPCWSTR tabTemplate, LPCWSTR title = L"");
    ~SettingsTab();

    /// Processes messages sent to the tab page.
    virtual INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg,
        WPARAM wParam, LPARAM lParam);

    /// Persists changes made on the tab page
    virtual void SaveSettings() = 0;

protected:
    ///
    /// Performs intitialization for the tab page, similar to a constructor.
    /// Since tab page windows are created on demand, this method could be
    /// called much later than the constructor for the tab.
    ///
    virtual void Initialize() = 0;

    /// Applies the current settings state to the tab page.
    virtual void LoadSettings() = 0;
};

#pragma once

#include "../Controls/Controls.h"
#include "../Controls/TabPage.h"
#include "../resource.h"

///
/// Abstract class that encapsulates functionality for dealing with
/// property sheet pages (tabs).
///
class SettingsTab : public TabPage {
public:
    SettingsTab(HINSTANCE hInstance, LPCWSTR tabTemplate, LPCWSTR title = L"");
    ~SettingsTab();

    /// Processes messages sent to the tab page.
    virtual INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg,
        WPARAM wParam, LPARAM lParam);

    /// Persists changes made on the tab page
    virtual void SaveSettings() = 0;

protected:
    ///
    /// Performs intitialization for the tab page, similar to a constructor.
    /// Since tab page windows are created on demand, this method could be
    /// called much later than the constructor for the tab.
    ///
    virtual void Initialize() = 0;

    /// Applies the current settings state to the tab page.
    virtual void LoadSettings() = 0;
};

Include dialog resources to make things easier


#ifndef THM_CONFIG_HG
#define THM_CONFIG_HG

// Vertex ID type
// # of vertices < MAX(thm_Vid)
typedef unsigned long thm_Vid;

// Arc reference type
// # of arcs in any digraph <= MAX(thm_Arcref)
typedef unsigned long thm_Arcref;

// Block label type
// # of blocks < MAX(thm_Blklab)
typedef unsigned long thm_Blklab;

#endif

#ifndef THM_CONFIG_HG
#define THM_CONFIG_HG

// Block label type (must be unsigned)
// # of blocks <= MAX(thm_Blklab)
typedef uint32_t thm_Blklab;

#endif

Move typedef to digraph header

Move typedef to digraph header


#ifndef MEM_H__
#define MEM_H__

#include <stdlib.h>

void *xmalloc (size_t size);
void *xcalloc (size_t count, size_t size);
void *xrealloc (void *ptr, size_t size);
char *xstralloc (size_t len);
void *xmemdupz (const void *data, size_t len);
char *xstrndup (const char *str, size_t len);
void xfree (void *ptr);

void xmemreport (void);

#endif /* MEM_H__ */

/*
 Local Variables:
 mode: C
 tab-width: 2
 indent-tabs-mode: nil
 End:
 vim: sw=2:sts=2:expandtab
*/

#ifndef MEM_H__
#define MEM_H__

#include <stdlib.h>

void *xmalloc (size_t size);
void *xcalloc (size_t count, size_t size);
void *xrealloc (void *ptr, size_t size);
char *xstralloc (size_t len);
void *xmemdupz (const void *data, size_t len);
char *xstrndup (const char *str, size_t len);
void xfree (void *ptr);

size_t xmembytes();
size_t xmemnew();
size_t xmemfreed();
void xmemreport (void);

#endif /* MEM_H__ */

/*
 Local Variables:
 mode: C
 tab-width: 2
 indent-tabs-mode: nil
 End:
 vim: sw=2:sts=2:expandtab
*/

Add report functions for x*()

Add report functions for x*()

Signed-off-by: Olivier Mehani <9858fe98d2c7f5f35e0d2a08f134cfc58afd42d3@nicta.com.au>


#ifndef CPR_BODY_H
#define CPR_BODY_H

#include <cstring>

#include <initializer_list>
#include <string>

#include "defines.h"

namespace cpr {

class Body : public std::string {
  public:
    Body() = default;
    Body(const Body& rhs) = default;
    Body(Body&& rhs) = default;
    Body& operator=(const Body& rhs) = default;
    Body& operator=(Body&& rhs) = default;
    explicit Body(const char* raw_string) : std::string(raw_string) {}
    explicit Body(const char* raw_string, size_t length) : std::string(raw_string, length) {}
    explicit Body(size_t to_fill, char character) : std::string(to_fill, character) {}
    explicit Body(const std::string& std_string) : std::string(std_string) {}
    explicit Body(const std::string& std_string, size_t position, size_t length = std::string::npos)
            : std::string(std_string, position, length) {}
    explicit Body(std::initializer_list<char> il) : std::string(il) {}
    template <class InputIterator>
    explicit Body(InputIterator first, InputIterator last)
            : std::string(first, last) {}
};

} // namespace cpr

#endif

#ifndef CPR_BODY_H
#define CPR_BODY_H

#include <cstring>

#include <initializer_list>
#include <string>

#include "defines.h"

namespace cpr {

class Body : public std::string {
  public:
    Body() = default;
    Body(const Body& rhs) = default;
    Body(Body&& rhs) = default;
    Body& operator=(const Body& rhs) = default;
    Body& operator=(Body&& rhs) = default;
    explicit Body(const char* raw_string) : std::string(raw_string) {}
    explicit Body(const char* raw_string, size_t length) : std::string(raw_string, length) {}
    explicit Body(size_t to_fill, char character) : std::string(to_fill, character) {}
    explicit Body(const std::string& std_string) : std::string(std_string) {}
    explicit Body(const std::string& std_string, size_t position, size_t length = std::string::npos)
            : std::string(std_string, position, length) {}
    explicit Body(std::string&& std_string) : std::string(std::move(std_string)) {}
    explicit Body(std::initializer_list<char> il) : std::string(il) {}
    template <class InputIterator>
    explicit Body(InputIterator first, InputIterator last)
            : std::string(first, last) {}
};

} // namespace cpr

#endif

Move constructor from std::string for cpr::Body

Currently it uses only copy-stors.


#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"

#include "nv30_context.h"

void
nv30_clear(struct pipe_context *pipe, struct pipe_surface *ps,
	   unsigned clearValue)
{
	pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
}

#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_state.h"

#include "nv30_context.h"

void
nv30_clear(struct pipe_context *pipe, struct pipe_surface *ps,
	   unsigned clearValue)
{
	pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
	ps->status = PIPE_SURFACE_STATUS_CLEAR;
}

Set pipe status on clear

nv30: Set pipe status on clear


/*
 * 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 85
#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 86
#endif

Update Skia milestone to 86

Update Skia milestone to 86

Change-Id: Id81c58007f74816a8c2ac0831d61c041c5a7468c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298916
Reviewed-by: Heather Miller <2e22000c5d22374561fe5fba576a31095b72dc2e@google.com>


#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#include <setjmp.h>

jmp_buf try;

void handler(int sig) {
  static int i = 0;

  write(2, "stack overflow\n", 15);
  longjmp(try, ++i);
  _exit(1);
}

unsigned recurse(unsigned x) {
    return recurse(x)+1;
}

int main() {
  static char stack[SIGSTKSZ];
  stack_t ss = {
    .ss_size = SIGSTKSZ,
    .ss_sp = stack,
  };
  struct sigaction sa = {
    .sa_handler = handler,
    .sa_flags = SA_ONSTACK
  };

  sigaltstack(&ss, 0);
  sigfillset(&sa.sa_mask);
  sigaction(SIGSEGV, &sa, 0);
  if (setjmp(try) < 3) {
    recurse(0);
  } else {
    printf("caught exception!\n");
  }

  return 0;
}

#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#include <setjmp.h>

jmp_buf try;

void handler(int sig) {
  static int i = 0;

  write(2, "stack overflow\n", 15);
  longjmp(try, ++i);
  _exit(1);
}

unsigned recurse(unsigned x) {
    return recurse(x)+1;
}

int main() {
  char* stack;
  stack = malloc(sizeof(stack) * SIGSTKSZ);
  stack_t ss = {
    .ss_size = SIGSTKSZ,
    .ss_sp = stack,
  };
  struct sigaction sa = {
    .sa_handler = handler,
    .sa_flags = SA_ONSTACK
  };

  sigaltstack(&ss, 0);
  sigfillset(&sa.sa_mask);
  sigaction(SIGSEGV, &sa, 0);
  if (setjmp(try) < 3) {
    recurse(0);
  } else {
    printf("caught exception!\n");
  }

  return 0;
}

Put alternate stack on heap

Put alternate stack on heap


/*
 *  libpatts - Backend library for PATTS Ain't Time Tracking Software
 *  Copyright (C) 2014 Delwink, LLC
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation.
 *
 *  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 Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DELWINK_PATTS_ADMIN_H
#define DELWINK_PATTS_ADMIN_H

#include <cquel.h>

#ifdef __cplusplus
extern "C"
{
#endif

int patts_create_user(const struct dlist *info, const char *host,
        const char *passwd);
int patts_create_task(const struct dlist *info);

int patts_enable_user(const char *id);
int patts_enable_task(const char *id);

int patts_disable_user(const char *id);
int patts_disable_task(const char *id);

int patts_grant_admin(const char *id);
int patts_revoke_admin(const char *id);

#ifdef __cplusplus
}
#endif

#endif

/*
 *  libpatts - Backend library for PATTS Ain't Time Tracking Software
 *  Copyright (C) 2014 Delwink, LLC
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation.
 *
 *  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 Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DELWINK_PATTS_ADMIN_H
#define DELWINK_PATTS_ADMIN_H

#include <cquel.h>

#ifdef __cplusplus
extern "C"
{
#endif

int patts_create_user(const struct dlist *info, const char *host,
        const char *passwd);
int patts_create_task(const struct dlist *info);

int patts_delete_user(const char *id);
int patts_delete_task(const char *id);

int patts_grant_admin(const char *id);
int patts_revoke_admin(const char *id);

#ifdef __cplusplus
}
#endif

#endif

Change scope of state column

Change scope of state column


#ifndef UTILS_H
#define UTILS_H

#include <string>

/** \brief Convert given container to it's hex representation */
template< typename T >
std::string toHex( const T& data )
{
    static const char charTable[] = "0123456789abcdef";

    std::string ret;
    if ( data.size() > 1024 )
    {
        ret = "*** LARGE *** ";
        for ( size_t i=0; i<40; i++ )
        {
            ret.push_back( charTable[ ( data[i] >> 4 ) & 0xF ] );
            ret.push_back( charTable[ ( data[i] >> 0 ) & 0xF ] );
        }

        ret.append("...");

        for ( size_t i=data.size()-40; i<data.size(); i++ )
        {
            ret.push_back( charTable[ ( data[i] >> 4 ) & 0xF ] );
            ret.push_back( charTable[ ( data[i] >> 0 ) & 0xF ] );
        }
    }
    else
    {
        for ( const auto& val: data )
        {
            ret.push_back( charTable[ ( val >> 4 ) & 0xF ] );
            ret.push_back( charTable[ ( val >> 0 ) & 0xF ] );
        }
    }
    return ret;
}

#endif // UTILS_H

#ifndef UTILS_H
#define UTILS_H

#include <string>

/** \brief Convert given container to it's hex representation */
template< typename T >
std::string toHex( const T& data )
{
    static const char charTable[] = "0123456789abcdef";

    std::string ret;
    if ( data.size() > 80 )
    {
        ret = "*** LARGE *** ";
        for ( size_t i=0; i<40; i++ )
        {
            ret.push_back( charTable[ ( data[i] >> 4 ) & 0xF ] );
            ret.push_back( charTable[ ( data[i] >> 0 ) & 0xF ] );
        }

        ret.append("...");

        for ( size_t i=data.size()-40; i<data.size(); i++ )
        {
            ret.push_back( charTable[ ( data[i] >> 4 ) & 0xF ] );
            ret.push_back( charTable[ ( data[i] >> 0 ) & 0xF ] );
        }
    }
    else
    {
        for ( const auto& val: data )
        {
            ret.push_back( charTable[ ( val >> 4 ) & 0xF ] );
            ret.push_back( charTable[ ( val >> 0 ) & 0xF ] );
        }
    }
    return ret;
}

#endif // UTILS_H

Make the hex dump size limit much smaller


#ifndef VORTEX_HELPER_H
#define VORTEX_HELPER_H

#include "uranus_dp/control_mode_enum.h"

inline std::string controlModeString(ControlMode control_mode)
{
  std::string s;
  switch(control_mode)
  {
    case ControlModes::OPEN_LOOP:
    s = "Open Loop";
    break;

    case ControlModes::SIXDOF:
    s = "Six DOF";
    break;

    case ControlModes::RPY_DEPTH:
    s = "RPY Depth";
    break;

    case ControlModes::DEPTH_HOLD:
    s = "Depth Hold";
    break;

    default:
    s = "Invalid Control Mode";
    break;
  }
  return s;
}

#endif

Write control mode to string function

Write control mode to string function


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

#include "lexicon.h"
#include "hash.h"
#include "array.h"
#include "util.h"
#include "mem.h"

int main(int argc, char **argv)
{
  lexicon_pt l=read_lexicon_file(argv[1]);
  char s[4000];

  printf("Read %ld lexical entries.\n", (long int)hash_size(l->words));
  while (fgets(s, 1000, stdin))
    {
      word_pt w;
      int i, sl=strlen(s);

      for (sl--; sl>=0 && s[sl]=='\n'; sl--) { s[sl]='\0'; }
      w=hash_get(l->words, s);
      if (!w) { printf("No such word \"%s\".\n", s); continue; }

      printf("%s[%d,%s]:", s, w->defaulttag, tagname(l, w->defaulttag));
      for (i=0; w->sorter[i]>0; i++)
	{
	  printf("\t%s %d", (char *)array_get(l->tags, w->sorter[i]), w->tagcount[w->sorter[i]]);
	}
      printf("\n");
    }

  /* Free the memory held by util.c. */
  util_teardown();
}

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

#include "lexicon.h"
#include "hash.h"
#include "array.h"
#include "util.h"
#include "mem.h"

int main(int argc, char **argv)
{
  lexicon_pt l=read_lexicon_file(argv[1]);
  char s[4000];

  printf("Read %ld lexical entries.\n", (long int)hash_size(l->words));
  while (fgets(s, 1000, stdin))
    {
      word_pt w;
      int i, sl=strlen(s);

      for (sl--; sl>=0 && s[sl]=='\n'; sl--) { s[sl]='\0'; }
      w=hash_get(l->words, s);
      if (!w) { printf("No such word \"%s\".\n", s); continue; }

      printf("%s[%d,%s]:", s, w->defaulttag, tagname(l, w->defaulttag));
      for (i=0; w->sorter[i]>0; i++)
	{
	  printf("\t%s %d", (char *)array_get(l->tags, w->sorter[i]), w->tagcount[w->sorter[i]]);
	}
      printf("\n");
    }

  /* Free the memory held by util.c. */
  util_teardown();

  return 0;
}

Return 0 from main as it should.

Return 0 from main as it should.


#ifndef PACKET_QUEUE_H_INCLUDED__
#define PACKET_QUEUE_H_INCLUDED__

#include "radio.h"

#include <stdbool.h>

#define PACKET_QUEUE_SIZE 10

typedef struct
{
    radio_packet_t * head;
    radio_packet_t * tail;
    radio_packet_t packets[PACKET_QUEUE_SIZE];
} packet_queue_t;

uint32_t packet_queue_init(packet_queue_t * queue);

bool packet_queue_is_empty(packet_queue_t * queue);

bool packet_queue_is_full(packet_queue_t * queue);

uint32_t packet_queue_add(packet_queue_t * queue, radio_packet_t * packet);

uint32_t packet_queue_get(packet_queue_t * queue, radio_packet_t ** packet);

#endif

#ifndef PACKET_QUEUE_H_INCLUDED__
#define PACKET_QUEUE_H_INCLUDED__

#include "radio.h"

#include <stdbool.h>

#define PACKET_QUEUE_SIZE 10

typedef struct
{
    uint32_t head;
    uint32_t tail;
    radio_packet_t packets[PACKET_QUEUE_SIZE];
} packet_queue_t;

uint32_t packet_queue_init(packet_queue_t * queue);

bool packet_queue_is_empty(packet_queue_t * queue);

bool packet_queue_is_full(packet_queue_t * queue);

uint32_t packet_queue_add(packet_queue_t * queue, radio_packet_t * packet);

uint32_t packet_queue_get(packet_queue_t * queue, radio_packet_t ** packet);

#endif

Fix types of head and tail.

Fix types of head and tail.


/*
 * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg 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.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef AVUTIL_RANDOM_SEED_H
#define AVUTIL_RANDOM_SEED_H

#include <stdint.h>

/**
 * Gets a seed to use in conjuction with random functions.
 */
uint32_t ff_random_get_seed(void);

#endif /* AVUTIL_RANDOM_SEED_H */

/*
 * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg 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.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef AVUTIL_RANDOM_SEED_H
#define AVUTIL_RANDOM_SEED_H

#include <stdint.h>

/**
 * Gets a seed to use in conjunction with random functions.
 */
uint32_t ff_random_get_seed(void);

#endif /* AVUTIL_RANDOM_SEED_H */

Fix typo: 'conjuction' -> 'conjunction'.

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@17989 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b


/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/*
   Copyright (C) 2015 Red Hat, Inc.

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

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

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/

/* check statistics
 */

#include <config.h>
#include <glib.h>

typedef void test_func_t(void);

test_func_t stat_test1;
test_func_t stat_test2;
test_func_t stat_test3;
test_func_t stat_test4;

static test_func_t *test_funcs[] = {
    stat_test1,
    stat_test2,
    stat_test3,
    stat_test4,
    NULL
};

int main(void)
{
    test_func_t **func_p;

    for (func_p = test_funcs; *func_p; ++func_p) {
        (*func_p)();
    }
    return 0;
}

Remove empty line at EOF

syntax-check: Remove empty line at EOF

Acked-by: Christophe Fergeau <05b95054a663c388a4e33d95828cb30f0370f8ef@redhat.com>


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

#include "udc.h"
#include <stdlib.h>

struct gt_udc_backend gt_udc_backend_libusbg = {
	.udc = NULL,
};

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

#include <stdio.h>
#include <usbg/usbg.h>

#include "backend.h"
#include "udc.h"

static int udc_func(void *data)
{
	usbg_udc *u;
	const char *name;

	usbg_for_each_udc(u, backend_ctx.libusbg_state) {
		name = usbg_get_udc_name(u);
		if (name == NULL) {
			fprintf(stderr, "Error getting udc name\n");
			return -1;
		}

		puts(name);
	}

	return 0;
}

struct gt_udc_backend gt_udc_backend_libusbg = {
	.udc = udc_func,
};

udc: Add gadget udc command at libusbg backend

Change-Id: If1510069df2e6cd2620c89576ebba80685cb07d7
Signed-off-by: Pawel Szewczyk <1691dcf8dab804b326e5e4b9ab228a1c3b23a2f2@samsung.com>


// Check that calling dispatch_once from a report callback works.

// RUN: %clang_tsan %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <dispatch/dispatch.h>

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

long g = 0;
long h = 0;
void f() {
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    g++;
  });
  h++;
}

void __tsan_on_report() {
  fprintf(stderr, "Report.\n");
  f();
}

int main() {
  fprintf(stderr, "Hello world.\n");

  f();

  pthread_mutex_t mutex = {0};
  pthread_mutex_lock(&mutex);

  fprintf(stderr, "g = %ld.\n", g);
  fprintf(stderr, "h = %ld.\n", h);
  fprintf(stderr, "Done.\n");
}

// CHECK: Hello world.
// CHECK: Report.
// CHECK: g = 1
// CHECK: h = 2
// CHECK: Done.

// Check that calling dispatch_once from a report callback works.

// RUN: %clang_tsan %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s

#include <dispatch/dispatch.h>

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

long g = 0;
long h = 0;
void f() {
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    g++;
  });
  h++;
}

void __tsan_on_report() {
  fprintf(stderr, "Report.\n");
  f();
}

int main() {
  fprintf(stderr, "Hello world.\n");

  f();

  pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  pthread_mutex_unlock(&mutex); // Unlock of an unlocked mutex

  fprintf(stderr, "g = %ld.\n", g);
  fprintf(stderr, "h = %ld.\n", h);
  fprintf(stderr, "Done.\n");
}

// CHECK: Hello world.
// CHECK: Report.
// CHECK: g = 1
// CHECK: h = 2
// CHECK: Done.

Make test work on Linux, pt. 2

[TSan][libdispatch] Make test work on Linux, pt. 2

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


/// \file update_task.h
/// Defines action for updating tasks.
/// \author A0112054Y

#pragma once
#ifndef YOU_QUERYENGINE_INTERNAL_ACTION_FILTER_TASK_H_
#define YOU_QUERYENGINE_INTERNAL_ACTION_FILTER_TASK_H_

#include <functional>
#include "../../filter.h"
#include "../../api.h"

namespace You {
namespace QueryEngine {
namespace Internal {
namespace Action {

/// Define action for updating task
class FilterTask : public Query {
public:
	/// Constructor
	explicit FilterTask(const Filter& filter) : filter(filter) {}

	/// Destructor
	virtual ~FilterTask() = default;
private:
	/// Execute add task.
	Response execute(State& tasks) override;
	FilterTask& operator=(const FilterTask&) = delete;
	const Filter& filter;
};

}  // namespace Action
}  // namespace Internal
}  // namespace QueryEngine
}  // namespace You

#endif  // YOU_QUERYENGINE_INTERNAL_ACTION_FILTER_TASK_H_

/// \file update_task.h
/// Defines action for updating tasks.
/// \author A0112054Y

#pragma once
#ifndef YOU_QUERYENGINE_INTERNAL_ACTION_FILTER_TASK_H_
#define YOU_QUERYENGINE_INTERNAL_ACTION_FILTER_TASK_H_

#include <functional>
#include "../../filter.h"
#include "../../api.h"

namespace You {
namespace QueryEngine {
namespace Internal {
namespace Action {

/// Define action for updating task
class FilterTask : public Query {
public:
	/// Constructor
	explicit FilterTask(const Filter& filter) : filter(filter) {}

	/// Destructor
	virtual ~FilterTask() = default;
private:
	/// Execute add task.
	Response execute(State& tasks) override;
	FilterTask& operator=(const FilterTask&) = delete;
	Filter filter;
};

}  // namespace Action
}  // namespace Internal
}  // namespace QueryEngine
}  // namespace You

#endif  // YOU_QUERYENGINE_INTERNAL_ACTION_FILTER_TASK_H_

Store filter by value in FilterTask

Store filter by value in FilterTask


/*
** Copyright 1994 by Miron Livny, and Mike Litzkow
**
** Permission to use, copy, modify, and distribute this software and its
** documentation for any purpose and without fee is hereby granted,
** provided that the above copyright notice appear in all copies and that
** both that copyright notice and this permission notice appear in
** supporting documentation, and that the names of the University of
** Wisconsin and the copyright holders not be used in advertising or
** publicity pertaining to distribution of the software without specific,
** written prior permission.  The University of Wisconsin and the
** copyright holders make no representations about the suitability of this
** software for any purpose.  It is provided "as is" without express
** or implied warranty.
**
** THE UNIVERSITY OF WISCONSIN AND THE COPYRIGHT HOLDERS DISCLAIM ALL
** WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE UNIVERSITY OF
** WISCONSIN OR THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT
** OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
** OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
** OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
** OR PERFORMANCE OF THIS SOFTWARE.
**
** Author:  Mike Litzkow
**
*/

#define _POSIX_SOURCE
#include <signal.h>
#include "condor_debug.h"

static char *_FileName_ = __FILE__;

typedef void (*SIG_HANDLER)();

void
install_sig_handler( int sig, SIG_HANDLER handler )
{
	struct sigaction act;

	act.sa_handler = handler;
	sigemptyset( &act.sa_mask );
	act.sa_flags = 0;

	if( sigaction(sig,&act,0) < 0 ) {
		EXCEPT( "sigaction" );
	}
}

Install a sig handler using sigaction(), ensure that handler stays installed across invocations.


/**
@file

Copyright John Reid 2013

*/

#ifndef MYRRH_PYTHON_REGISTRY_H_
#define MYRRH_PYTHON_REGISTRY_H_

#ifdef _MSC_VER
# pragma once
#endif //_MSC_VER

namespace myrrh {
namespace python {

/**
 * Queries if the the type specified is in the registry.
 */
template< typename QueryT >
bool
in_registry() {
	namespace bp = boost::python;
	bp::type_info info = boost::python::type_id< QueryT >();
	bp::converter::registration * registration = boost::python::converter::registry::query( info );
	return registration != 0;
}

} //namespace myrrh
} //namespace python

#endif //MYRRH_PYTHON_REGISTRY_H_

/**
@file

Copyright John Reid 2013

*/

#ifndef MYRRH_PYTHON_REGISTRY_H_
#define MYRRH_PYTHON_REGISTRY_H_

#ifdef _MSC_VER
# pragma once
#endif //_MSC_VER

namespace myrrh {
namespace python {

/**
 * Queries if the the type specified is in the registry. This can be used to avoid registering
 * the same type more than once.
 */
template< typename QueryT >
const boost::python::converter::registration *
get_registration() {
	namespace bp = boost::python;
	const bp::type_info info = boost::python::type_id< QueryT >();
	const bp::converter::registration * registration = boost::python::converter::registry::query( info );
	// need to check for m_to_python converter: see http://stackoverflow.com/a/13017303/959926
	if( registration != 0 && registration->m_to_python != 0 ) {
		return registration;
	} else {
		return 0;
	}
}

} //namespace myrrh
} //namespace python

#endif //MYRRH_PYTHON_REGISTRY_H_

Fix for inner class registration check

Fix for inner class registration check


#include <stdio.h>

int main() {

  // imprime o cabecalho do nosso jogo
  printf("******************************************\n");
  printf("* Bem vindo ao nosso jogo de adivinhação *\n");
  printf("******************************************\n");

  int numerosecreto = 42;

  int chute;

  printf("Qual é o seu chute? ");
  scanf("%d", &chute);
  printf("Seu chute foi %d\n", chute);

  int acertou = chute == numerosecreto;

  if(acertou) {
    printf("Parabéns! Você acertou!\n");
    printf("Jogue de novo, você é um bom jogador!\n");
  } else {

    int maior = chute > numerosecreto;

    if(maior) {
      printf("Seu chute foi maior que o número secreto\n");
    } else {
      printf("Seu chute foi menor que o número secreto\n");
    }

    printf("Você errou!\n");
    printf("Mas não desanime, tente de novo!\n");
  }

}

#include <stdio.h>

int main() {

  // imprime o cabecalho do nosso jogo
  printf("******************************************\n");
  printf("* Bem vindo ao nosso jogo de adivinhação *\n");
  printf("******************************************\n");

  int numerosecreto = 42;

  int chute;

  for(int i = 1; i <= 3; i++) {

    printf("Tentativa %d de 3\n", i);
    printf("Qual é o seu chute? ");

    scanf("%d", &chute);
    printf("Seu chute foi %d\n", chute);

    int acertou = chute == numerosecreto;

    if(acertou) {
      printf("Parabéns! Você acertou!\n");
      printf("Jogue de novo, você é um bom jogador!\n");
    } else {

      int maior = chute > numerosecreto;

      if(maior) {
        printf("Seu chute foi maior que o número secreto\n");
      } else {
        printf("Seu chute foi menor que o número secreto\n");
      }

      printf("Você errou!\n");
      printf("Mas não desanime, tente de novo!\n");
    }

  }

  printf("Fim de jogo!\n");

}

Update files, Alura, Introdução a C, Aula 2.5


#include "../parse.h"

unsigned parse_stmt_equivalence(
	const sparse_t* src, const char* ptr,
	parse_stmt_t* stmt)
{
	unsigned i = parse_keyword(
		src, ptr, PARSE_KEYWORD_EQUIVALENCE);
	if (i == 0) return 0;

	stmt->type = PARSE_STMT_EQUIVALENCE;
	stmt->equivalence.count = 0;
	stmt->equivalence.group = NULL;

	unsigned len = parse_list(src, ptr,
		&stmt->equivalence.count,
		(void***)&stmt->equivalence.group,
		(void*)parse_lhs_list_bracketed,
		(void*)parse_lhs_list_delete);
	if (len == 0) return 0;
	i += len;

	return i;
}

#include "../parse.h"

unsigned parse_stmt_equivalence(
	const sparse_t* src, const char* ptr,
	parse_stmt_t* stmt)
{
	unsigned i = parse_keyword(
		src, ptr, PARSE_KEYWORD_EQUIVALENCE);
	if (i == 0) return 0;

	stmt->type = PARSE_STMT_EQUIVALENCE;
	stmt->equivalence.count = 0;
	stmt->equivalence.group = NULL;

	unsigned len = parse_list(src, &ptr[i],
		&stmt->equivalence.count,
		(void***)&stmt->equivalence.group,
		(void*)parse_lhs_list_bracketed,
		(void*)parse_lhs_list_delete);
	if (len == 0) return 0;
	i += len;

	return i;
}

Fix bug in EQUIVALENCE parsing

Fix bug in EQUIVALENCE parsing


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

#import <Foundation/Foundation.h>
#import <themis/themis.h>

@interface SKeygen : NSObject

{
  NSData* _priv_key;
  NSData* _pub_key;
}

- (id)init;
- (NSData*)priv_key: error:(NSError**)errorPtr;
- (NSData*)pub_key: error:(NSError**)errorPtr;

@end

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

#import <Foundation/Foundation.h>
#import <themis/themis.h>

@interface SMessage : NSObject

{
  NSMutableData* _priv_key;
  NSMutableData* _pub_key;
}

- (id)initWithPrivateKey: (NSData*)private_key peerPublicKey:(NSData*)peer_pub_key;
- (NSData*)wrap: (NSData*)message error:(NSError**)errorPtr;
- (NSData*)unwrap: (NSData*)message error:(NSError**)errorPtr;

@end

Add some correction to Obj-C wrappers

Add some correction to Obj-C wrappers


// Copyright (c) 2011 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 PRINTING_METAFILE_IMPL_H_
#define PRINTING_METAFILE_IMPL_H_

#if defined(OS_WIN)
#include "printing/emf_win.h"
#elif defined(OS_MACOSX)
#include "printing/pdf_metafile_cg_mac.h"
#elif defined(OS_POSIX)
#include "printing/pdf_metafile_cairo_linux.h"
#endif

#if !defined(OS_MACOSX) || defined(USE_SKIA)
#include "printing/pdf_metafile_skia.h"
#endif

namespace printing {

#if defined(OS_WIN)
typedef Emf NativeMetafile;
typedef PdfMetafileSkia PreviewMetafile;
#elif defined(OS_MACOSX)
#if defined(USE_SKIA)
typedef PdfMetafileSkia NativeMetafile;
typedef PdfMetafileSkia PreviewMetafile;
#else
typedef PdfMetafileCg NativeMetafile;
typedef PdfMetafileCg PreviewMetafile;
#endif
#elif defined(OS_POSIX)
typedef PdfMetafileCairo NativeMetafile;
typedef PdfMetafileSkia PreviewMetafile;
#endif

}  // namespace printing

#endif  // PRINTING_METAFILE_IMPL_H_

// Copyright (c) 2011 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 PRINTING_METAFILE_IMPL_H_
#define PRINTING_METAFILE_IMPL_H_

#if defined(OS_WIN)
#include "printing/emf_win.h"
#elif defined(OS_MACOSX)
#include "printing/pdf_metafile_cg_mac.h"
#elif defined(OS_POSIX)
#include "printing/pdf_metafile_cairo_linux.h"
#endif

#if !defined(OS_MACOSX) || defined(USE_SKIA)
#include "printing/pdf_metafile_skia.h"
#endif

namespace printing {

#if defined(OS_WIN)
typedef Emf NativeMetafile;
typedef PdfMetafileSkia PreviewMetafile;
#elif defined(OS_MACOSX)
#if defined(USE_SKIA)
typedef PdfMetafileSkia NativeMetafile;
typedef PdfMetafileSkia PreviewMetafile;
#else
typedef PdfMetafileCg NativeMetafile;
typedef PdfMetafileCg PreviewMetafile;
#endif
#elif defined(OS_POSIX)
typedef PdfMetafileSkia NativeMetafile;
typedef PdfMetafileSkia PreviewMetafile;
#endif

}  // namespace printing

#endif  // PRINTING_METAFILE_IMPL_H_

Switch the native print path on Linux and ChromeOS to use Skia instead of Cairo

BUG=
TEST=Pages printed via cloud print to raster based printers should successfully print images.

Review URL: http://codereview.chromium.org/7817007

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


/**
 * cpuid.c
 *
 * Checks if CPU has support of AES instructions
 *
 * @author kryukov@frtk.ru
 * @version 4.0
 *
 * For Putty AES NI project
 * http://putty-aes-ni.googlecode.com/
 */

#ifndef SILENT
#include <stdio.h>
#endif

#if defined(__clang__) || defined(__GNUC__)

#include <cpuid.h>
static int CheckCPUsupportAES()
{
    unsigned int CPUInfo[4];
    __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
    return (CPUInfo[2] & (1 << 25)) && (CPUInfo[2] & (1 << 19)); /* Check AES and SSE4.1 */
}

#else /* defined(__clang__) || defined(__GNUC__) */

static int CheckCPUsupportAES()
{
    unsigned int CPUInfo[4];
    __cpuid(CPUInfo, 1);
    return (CPUInfo[2] & (1 << 25)) && (CPUInfo[2] & (1 << 19)); /* Check AES and SSE4.1 */
}

#endif /* defined(__clang__) || defined(__GNUC__) */

int main(int argc, char ** argv)
{
    const int res = !CheckCPUsupportAES();
#ifndef SILENT
    printf("This CPU %s AES-NI\n", res ? "does not support" : "supports");
#endif
    return res;
}

/**
 * cpuid.c
 *
 * Checks if CPU has support of AES instructions
 *
 * @author kryukov@frtk.ru
 * @version 4.0
 *
 * For Putty AES NI project
 * http://putty-aes-ni.googlecode.com/
 */

#include <stdio.h>

#if defined(__clang__) || defined(__GNUC__)

#include <cpuid.h>
static int CheckCPUsupportAES()
{
    unsigned int CPUInfo[4];
    __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
    return (CPUInfo[2] & (1 << 25)) && (CPUInfo[2] & (1 << 19)); /* Check AES and SSE4.1 */
}

#else /* defined(__clang__) || defined(__GNUC__) */

static int CheckCPUsupportAES()
{
    unsigned int CPUInfo[4];
    __cpuid(CPUInfo, 1);
    return (CPUInfo[2] & (1 << 25)) && (CPUInfo[2] & (1 << 19)); /* Check AES and SSE4.1 */
}

#endif /* defined(__clang__) || defined(__GNUC__) */

int main(int argc, char ** argv)
{
    const int res = !CheckCPUsupportAES();
    printf("This CPU %s AES-NI\n", res ? "does not support" : "supports");
    return res;
}

Print CPUID result to output

Print CPUID result to output


#ifndef ALI_TRD_PREPROCESSOR_H
#define ALI_TRD_PREPROCESSOR_H

/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id$ */

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// TRD preprocessor for the database SHUTTLE                              //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

#include "AliPreprocessor.h"

class AliTRDPreprocessor : public AliPreprocessor
{

  public:

    AliTRDPreprocessor(AliShuttleInterface *shuttle);
    virtual ~AliTRDPreprocessor();

  protected:

    virtual void   Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
    virtual UInt_t Process(TMap* /*dcsAliasMap*/);

  private:

    ClassDef(AliTRDPreprocessor,0);

};

#endif

#ifndef ALI_TRD_PREPROCESSOR_H
#define ALI_TRD_PREPROCESSOR_H

/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id$ */

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// TRD preprocessor for the database SHUTTLE                              //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

#include "AliPreprocessor.h"

class AliTRDPreprocessor : public AliPreprocessor
{

  public:

    AliTRDPreprocessor(AliShuttleInterface *shuttle);
    virtual ~AliTRDPreprocessor();

  protected:

    virtual void   Initialize(Int_t run, UInt_t startTime, UInt_t endTime);
    virtual UInt_t Process(TMap* /*dcsAliasMap*/);

  private:

    ClassDef(AliTRDPreprocessor,0) // The SHUTTLE preprocessor for TRD

};

#endif

Add a comment behind ClassDef

Add a comment behind ClassDef


uniform sampler2D m_SamplerY;
uniform sampler2D m_SamplerU;
uniform sampler2D m_SamplerV;

uniform mat3 yuvCoeff;

// Y - 16, Cb - 128, Cr - 128
const mediump vec3 offsets = vec3(-0.0625, -0.5, -0.5);

lowp vec3 sampleRgb(vec2 loc)
{
  float y = texture2D(m_SamplerY, loc).r;
  float u = texture2D(m_SamplerU, loc).r;
  float v = texture2D(m_SamplerV, loc).r;
  return yuvCoeff * (vec3(y, u, v) + offsets);
}

uniform sampler2D m_SamplerY;
uniform sampler2D m_SamplerU;
uniform sampler2D m_SamplerV;

uniform mediump mat3 yuvCoeff;

// Y - 16, Cb - 128, Cr - 128
const mediump vec3 offsets = vec3(-0.0625, -0.5, -0.5);

lowp vec3 sampleRgb(vec2 loc)
{
  lowp float y = texture2D(m_SamplerY, loc).r;
  lowp float u = texture2D(m_SamplerU, loc).r;
  lowp float v = texture2D(m_SamplerV, loc).r;
  return yuvCoeff * (vec3(y, u, v) + offsets);
}

Add precision prefixes to shaders

Add precision prefixes to shaders

Co-Authored-By: Dan Balasescu <c9bd76907373126dff70d71f8b944159a669cbf1@smgi.me>


//===- llvm/Transforms/CleanupGCCOutput.h - Cleanup GCC Output ---*- C++ -*--=//
//
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_CLEANUPGCCOUTPUT_H
#define LLVM_TRANSFORMS_CLEANUPGCCOUTPUT_H

class Pass;
Pass *createCleanupGCCOutputPass();

#endif

//===- llvm/Transforms/CleanupGCCOutput.h - Cleanup GCC Output ---*- C++ -*--=//
//
// These passes are used to cleanup the output of GCC.  GCC's output is
// unneccessarily gross for a couple of reasons. This pass does the following
// things to try to clean it up:
//
// * Eliminate names for GCC types that we know can't be needed by the user.
// * Eliminate names for types that are unused in the entire translation unit
// * Fix various problems that we might have in PHI nodes and casts
// * Link uses of 'void %foo(...)' to 'void %foo(sometypes)'
//
// Note:  This code produces dead declarations, it is a good idea to run DCE
//        after this pass.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_TRANSFORMS_CLEANUPGCCOUTPUT_H
#define LLVM_TRANSFORMS_CLEANUPGCCOUTPUT_H

class Pass;

// CleanupGCCOutputPass - Perform all of the function body transformations.
//
Pass *createCleanupGCCOutputPass();

// FunctionResolvingPass - Go over the functions that are in the module and
// look for functions that have the same name.  More often than not, there will
// be things like:
//    void "foo"(...)
//    void "foo"(int, int)
// because of the way things are declared in C.  If this is the case, patch
// things up.
//
// This is an interprocedural pass.
//
Pass *createFunctionResolvingPass();

#endif

Split the CleanupGCCOutput pass into two passes, and add real life actual
documentation on when they do.

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


/* ISC license. */

#include <string.h>
#include <utmpx.h>

#include <skalibs/posixishard.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>

#include "hpr.h"

#ifndef UT_LINESIZE
#define UT_LINESIZE 32
#endif

void hpr_wall (char const *s)
{
  size_t n = strlen(s) ;
  char tty[10 + UT_LINESIZE] = "/dev/" ;
  char msg[n+1] ;
  memcpy(msg, s, n) ;
  msg[n++] = '\n' ;
  setutxent() ;
  for (;;)
  {
    size_t linelen ;
    int fd ;
    struct utmpx *utx = getutxent() ;
    if (!utx) break ;
    if (utx->ut_type != USER_PROCESS) continue ;
    linelen = strnlen(utx->ut_line, UT_LINESIZE) ;
    memcpy(tty + 5, utx->ut_line, linelen) ;
    tty[5 + linelen] = 0 ;
    fd = open_append(tty) ;
    if (fd == -1) continue ;
    allwrite(fd, msg, n) ;
    fd_close(fd) ;
  }
  endutxent() ;
}

/* ISC license. */

#include <string.h>
#include <utmpx.h>

#include <skalibs/allreadwrite.h>
#include <skalibs/strerr2.h>
#include <skalibs/djbunix.h>
#include <skalibs/posixishard.h>

#include "hpr.h"

#ifndef UT_LINESIZE
#define UT_LINESIZE 32
#endif

void hpr_wall (char const *s)
{
  size_t n = strlen(s) ;
  char tty[10 + UT_LINESIZE] = "/dev/" ;
  char msg[n+1] ;
  memcpy(msg, s, n) ;
  msg[n++] = '\n' ;
  setutxent() ;
  for (;;)
  {
    size_t linelen ;
    int fd ;
    struct utmpx *utx = getutxent() ;
    if (!utx) break ;
    if (utx->ut_type != USER_PROCESS) continue ;
    linelen = strnlen(utx->ut_line, UT_LINESIZE) ;
    memcpy(tty + 5, utx->ut_line, linelen) ;
    tty[5 + linelen] = 0 ;
    fd = open_append(tty) ;
    if (fd == -1) continue ;
    allwrite(fd, msg, n) ;
    fd_close(fd) ;
  }
  endutxent() ;
}

Include posixishard as late as possible

Include posixishard as late as possible


#include "visibility.h"
#include "objc/runtime.h"
#include "gc_ops.h"
#include "class.h"
#include <stdlib.h>
#include <stdio.h>

static id allocate_class(Class cls, size_t extraBytes)
{
	intptr_t *addr = calloc(cls->instance_size + extraBytes + sizeof(intptr_t), 1);
	return (id)(addr + 1);
}

static void free_object(id obj)
{
	free((void*)(((intptr_t)obj) - 1));
}

static void *alloc(size_t size)
{
	return calloc(size, 1);
}

PRIVATE struct gc_ops gc_ops_none =
{
	.allocate_class = allocate_class,
	.free_object    = free_object,
	.malloc         = alloc,
	.free           = free
};
PRIVATE struct gc_ops *gc = &gc_ops_none;

PRIVATE BOOL isGCEnabled = NO;

#ifndef ENABLE_GC
PRIVATE void enableGC(BOOL exclusive)
{
	fprintf(stderr, "Attempting to enable garbage collection, but your"
			"Objective-C runtime was built without garbage collection"
			"support\n");
	abort();
}
#endif

#include "visibility.h"
#include "objc/runtime.h"
#include "gc_ops.h"
#include "class.h"
#include <stdlib.h>
#include <stdio.h>

static id allocate_class(Class cls, size_t extraBytes)
{
	intptr_t *addr = calloc(cls->instance_size + extraBytes + sizeof(intptr_t), 1);
	return (id)(addr + 1);
}

static void free_object(id obj)
{
	free((void*)(((intptr_t*)obj) - 1));
}

static void *alloc(size_t size)
{
	return calloc(size, 1);
}

PRIVATE struct gc_ops gc_ops_none =
{
	.allocate_class = allocate_class,
	.free_object    = free_object,
	.malloc         = alloc,
	.free           = free
};
PRIVATE struct gc_ops *gc = &gc_ops_none;

PRIVATE BOOL isGCEnabled = NO;

#ifndef ENABLE_GC
PRIVATE void enableGC(BOOL exclusive)
{
	fprintf(stderr, "Attempting to enable garbage collection, but your"
			"Objective-C runtime was built without garbage collection"
			"support\n");
	abort();
}
#endif

Fix bug spotted by Justin Hibbits.

Fix bug spotted by Justin Hibbits.

git-svn-id: f6517e426f81db5247881cd92f7386583ace04fa@33751 72102866-910b-0410-8b05-ffd578937521


#include <stdio.h>

void fred(int x)
{
    switch (x)
    {
        case 1: printf("1\n"); return;
        case 2: printf("2\n"); break;
        case 3: printf("3\n"); return;
    }

    printf("out\n");
}

int main()
{
    fred(1);
    fred(2);
    fred(3);

    return 0;
}

Test for switch with return inside a case.

git-svn-id: 1b2893900746d3474b20c0dea7456040123c3b26@505 21eae674-98b7-11dd-bd71-f92a316d2d60