#ifndef Q_VIDEO_FRAME_SCOPE_MAP
#define Q_VIDEO_FRAME_SCOPE_MAP 1

// TODO: move to QVideoFrameScope
struct QVideoFrameScopeMap
{
    QVideoFrameScopeMap(QVideoFrame *frame, QAbstractVideoBuffer::MapMode mode) : frame(frame)
    {
        if(frame)
        {
            status = frame->map(mode);
            if (!status)
            {
                qWarning("Can't map!");
            }
        }
    }
    ~QVideoFrameScopeMap()
    {
        if(frame)
        {
            frame->unmap();
        }
    }
    operator bool() const { return status; }
    QVideoFrame *frame = nullptr;
    bool status = false;
};

#endif // Q_VIDEO_FRAME_SCOPE_MAP

Move the QVideoFrame scope lock to a header file


#if defined(WINDOWS) || defined(WIN32) || defined(WIN64)
#include "CNFGWinDriver.c"
#elif defined( __android__ )
#include "CNFGOGLEGLDriver.c"
#else
#include "CNFGXDriver.c"
#endif

Add feature letting you include one .c file which automatically selects the driver.


//
//  Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "STKAudioPlayer.h"

Remove old audio player header

[ios] Remove old audio player header


// RUN: %clangxx_asan -std=c++11 -O0 %s -o %t
// RUN: not %run %t       2>&1 | FileCheck %s --check-prefix=READ
// RUN: not %run %t write 2>&1 | FileCheck %s --check-prefix=WRITE
// REQUIRES: x86-target-arch

#include <sys/mman.h>

static volatile int sink;
__attribute__((noinline)) void Read(int *ptr) { sink = *ptr; }
__attribute__((noinline)) void Write(int *ptr) { *ptr = 0; }
int main(int argc, char **argv) {
  // Writes to shadow are detected as reads from shadow gap (because of how the
  // shadow mapping works). This is kinda hard to fix. Test a random address in
  // the application part of the address space.
  void *volatile p =
      mmap(nullptr, 4096, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
  munmap(p, 4096);
  if (argc == 1)
    Read((int *)p);
  else
    Write((int *)p);
}
// READ: AddressSanitizer: SEGV on unknown address
// READ: The signal is caused by a READ memory access.
// WRITE: AddressSanitizer: SEGV on unknown address
// WRITE: The signal is caused by a WRITE memory access.

// RUN: %clangxx_asan -std=c++11 -O0 %s -o %t
// RUN: not %run %t       2>&1 | FileCheck %s --check-prefix=READ
// RUN: not %run %t write 2>&1 | FileCheck %s --check-prefix=WRITE
// REQUIRES: x86-target-arch

#include <sys/mman.h>

static volatile int sink;
__attribute__((noinline)) void Read(int *ptr) { sink = *ptr; }
__attribute__((noinline)) void Write(int *ptr) { *ptr = 0; }
int main(int argc, char **argv) {
  // Writes to shadow are detected as reads from shadow gap (because of how the
  // shadow mapping works). This is kinda hard to fix. Test a random address in
  // the application part of the address space.
  void *volatile p =
      mmap(nullptr, 4096, PROT_READ, MAP_PRIVATE | MAP_ANON, 0, 0);
  munmap(p, 4096);
  if (argc == 1)
    Read((int *)p);
  else
    Write((int *)p);
}
// READ: AddressSanitizer: SEGV on unknown address
// READ: The signal is caused by a READ memory access.
// WRITE: AddressSanitizer: SEGV on unknown address
// WRITE: The signal is caused by a WRITE memory access.

[test/asan] Update a test case to work with old Darwin SDK's

On Darwin, MAP_ANONYMOUS is a synonym for MAP_ANON. However, some SDK's
don't define MAP_ANONYMOUS. Use MAP_ANON to work around this.

(As a point of interest, the situation is exactly reversed on Linux.)

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


#pragma once
#include <string>
#include <iostream>

struct Customer
{
    int id;
    std::string name;
};

inline std::ostream& operator<<(std::ostream& os, const Customer& obj)
{
    os << "Customer (id: " << obj.id << ", name: " << obj.name << ")";
    return os;
}

Add a new line to satisfy clang.

Add a new line to satisfy clang.


/* $FreeBSD$ */
static int ___fake_library___;

/* $FreeBSD$ */

/* libxpg4 is obsolete in FreeBSD 6 -- library has been merged into libc. */
#define	OBSOLETE_IN_6

#include <sys/param.h>

static int ___fake_library___;

Mark libxpg4 as OBSOLETE_IN_6: it has been empty since its contents were merged into libc in 4.5-RELEASE.


#import <WebKit/WebKit.h>

typedef NS_ENUM (NSInteger, WMFWKScriptMessageType) {
    WMFWKScriptMessagePeek,
    WMFWKScriptMessageConsoleMessage,
    WMFWKScriptMessageClickLink,
    WMFWKScriptMessageClickImage,
    WMFWKScriptMessageClickReference,
    WMFWKScriptMessageClickEdit,
    WMFWKScriptMessageNonAnchorTouchEndedWithoutDragging,
    WMFWKScriptMessageLateJavascriptTransform,
    WMFWKScriptMessageArticleState,
    WMFWKScriptMessageUnknown
};

@interface WKScriptMessage (WMFScriptMessage)

+ (WMFWKScriptMessageType)wmf_typeForMessageName:(NSString*)name;
+ (Class)wmf_expectedMessageBodyClassForType:(WMFWKScriptMessageType)type;

@end

#import <WebKit/WebKit.h>

typedef NS_ENUM (NSInteger, WMFWKScriptMessageType) {
    WMFWKScriptMessageUnknown,
    WMFWKScriptMessagePeek,
    WMFWKScriptMessageConsoleMessage,
    WMFWKScriptMessageClickLink,
    WMFWKScriptMessageClickImage,
    WMFWKScriptMessageClickReference,
    WMFWKScriptMessageClickEdit,
    WMFWKScriptMessageNonAnchorTouchEndedWithoutDragging,
    WMFWKScriptMessageLateJavascriptTransform,
    WMFWKScriptMessageArticleState
};

@interface WKScriptMessage (WMFScriptMessage)

+ (WMFWKScriptMessageType)wmf_typeForMessageName:(NSString*)name;
+ (Class)wmf_expectedMessageBodyClassForType:(WMFWKScriptMessageType)type;

@end

Move unknown enum entry to top.

Move unknown enum entry to top.


#include <limits.h>
#include "utils/random.h"

// A simple psuedorandom number generator

static struct random_t rand_state = { 1 };

void random_seed(struct random_t *r, uint32_t seed) {
    r->seed = seed;
}

uint32_t random_get_seed(struct random_t *r) {
    return r->seed;
}

uint32_t random_int(struct random_t *r, uint32_t upperbound) {
    return random_intmax(r) % upperbound;
}

uint32_t random_intmax(struct random_t *r) {
    r->seed = r->seed * 1664525 + 1013904223;
    return r->seed;
}

float random_float(struct random_t *r) {
    return (float)random_intmax(r) / UINT_MAX;
}

void rand_seed(uint32_t seed) { random_seed(&rand_state, seed); }
uint32_t rand_get_seed(void) { return random_get_seed(&rand_state); }
uint32_t rand_int(uint32_t upperbound) { return random_int(&rand_state, upperbound); }
uint32_t rand_intmax(void) { return random_intmax(&rand_state);  }
float rand_float(void) { return random_float(&rand_state); }

#include <limits.h>
#include "utils/random.h"

// A simple psuedorandom number generator

static struct random_t rand_state = { 1 };

void random_seed(struct random_t *r, uint32_t seed) {
    r->seed = seed;
}

uint32_t random_get_seed(struct random_t *r) {
    return r->seed;
}

uint32_t random_int(struct random_t *r, uint32_t upperbound) {
    return random_intmax(r) % upperbound;
}

uint32_t random_intmax(struct random_t *r) {
    r->seed = r->seed * 1664525 + 1013904223;
    return r->seed;
}

float random_float(struct random_t *r) {
    return (float)random_intmax(r) / (float)UINT_MAX;
}

void rand_seed(uint32_t seed) { random_seed(&rand_state, seed); }
uint32_t rand_get_seed(void) { return random_get_seed(&rand_state); }
uint32_t rand_int(uint32_t upperbound) { return random_int(&rand_state, upperbound); }
uint32_t rand_intmax(void) { return random_intmax(&rand_state);  }
float rand_float(void) { return random_float(&rand_state); }

Fix build warning with clang 10.0.1

utils: Fix build warning with clang 10.0.1

---
/[...]/openomf/src/utils/random.c:26:38: warning: implicit conversion from 'unsigned int' to 'float' changes value from 4294967295 to 4294967296 [-Wimplicit-int-float-conversion]
    return (float)random_intmax(r) / UINT_MAX;
                                   ~ ^~~~~~~~
/usr/lib64/clang/10.0.1/include/limits.h:56:37: note: expanded from macro 'UINT_MAX'
                   ~~~~~~~~~~~~~~~~~^~~
---


/* trace.h
 *  Copyright: (When this is determined...it will go here)
 *  CVS Info
 *     $Id$
 *  Overview:
 *     Tracing support for runops_cores.c.
 *  Data Structure and Algorithms:
 *  History:
 *  Notes:
 *  References:
 */

#ifndef PARROT_TRACE_H_GUARD
#define PARROT_TRACE_H_GUARD

#include "parrot/parrot.h"

void trace_op_dump(struct Parrot_Interp *interpreter, opcode_t *code_start,
                   opcode_t *pc);

void trace_op(struct Parrot_Interp *interpreter, opcode_t *code_start,
              opcode_t *code_end, opcode_t *pc);

void trace_op_b0(struct Parrot_Interp *interpreter, opcode_t *code_start,
                 opcode_t *pc);

void trace_op_b1(struct Parrot_Interp *interpreter, opcode_t *code_start,
                 opcode_t *code_end, code_t *pc);

#endif

/*
 * Local variables:
 * c-indentation-style: bsd
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 *
 * vim: expandtab shiftwidth=4:
*/

/* trace.h
 *  Copyright: (When this is determined...it will go here)
 *  CVS Info
 *     $Id$
 *  Overview:
 *     Tracing support for runops_cores.c.
 *  Data Structure and Algorithms:
 *  History:
 *  Notes:
 *  References:
 */

#ifndef PARROT_TRACE_H_GUARD
#define PARROT_TRACE_H_GUARD

#include "parrot/parrot.h"

void trace_op_dump(struct Parrot_Interp *interpreter, opcode_t *code_start,
                   opcode_t *pc);

void trace_op(struct Parrot_Interp *interpreter, opcode_t *code_start,
              opcode_t *code_end, opcode_t *pc);

void trace_op_b0(struct Parrot_Interp *interpreter, opcode_t *code_start,
                 opcode_t *pc);

void trace_op_b1(struct Parrot_Interp *interpreter, opcode_t *code_start,
                 opcode_t *code_end, opcode_t *pc);

#endif

/*
 * Local variables:
 * c-indentation-style: bsd
 * c-basic-offset: 4
 * indent-tabs-mode: nil
 * End:
 *
 * vim: expandtab shiftwidth=4:
*/

Fix a typo in the argument type.

Fix a typo in the argument type.

Patch from <daniel.ritz@gmx.ch>

git-svn-id: 6e74a02f85675cec270f5d931b0f6998666294a3@1106 d31e2699-5ff4-0310-a27c-f18f2fbe73fe


#include "custom-type.h"
#include "cmd.h"
#include "common.h"

#include <string.h>
#include <hiredis/hiredis.h>
#include <hiredis/async.h>

void
custom_type_reply(redisAsyncContext *c, void *r, void *privdata) {

	redisReply *reply = r;
	struct cmd *cmd = privdata;
	(void)c;

	if(reply == NULL) {
		evhttp_send_reply(cmd->rq, 404, "Not Found", NULL);
		return;
	}

	if(cmd->mime) { /* use the given content-type, but only for strings */
		switch(reply->type) {

			case REDIS_REPLY_NIL: /* or nil values */
				format_send_reply(cmd, "", 0, cmd->mime);
				return;

			case REDIS_REPLY_STRING:
				format_send_reply(cmd, reply->str, reply->len, cmd->mime);
				return;
		}
	}

	/* couldn't make sense of what the client wanted. */
	evhttp_send_reply(cmd->rq, 400, "Bad request", NULL);
	cmd_free(cmd);
}

#include "custom-type.h"
#include "cmd.h"
#include "common.h"

#include <string.h>
#include <hiredis/hiredis.h>
#include <hiredis/async.h>

void
custom_type_reply(redisAsyncContext *c, void *r, void *privdata) {

	redisReply *reply = r;
	struct cmd *cmd = privdata;
	(void)c;
	char int_buffer[50];
	int int_len;

	if(reply == NULL) {
		evhttp_send_reply(cmd->rq, 404, "Not Found", NULL);
		return;
	}

	if(cmd->mime) { /* use the given content-type, but only for strings */
		switch(reply->type) {

			case REDIS_REPLY_NIL: /* or nil values */
				format_send_reply(cmd, "", 0, cmd->mime);
				return;

			case REDIS_REPLY_STRING:
				format_send_reply(cmd, reply->str, reply->len, cmd->mime);
				return;

			case REDIS_REPLY_INTEGER:
				int_len = sprintf(int_buffer, "%lld", reply->integer);
				format_send_reply(cmd, int_buffer, int_len, cmd->mime);
				return;
		}
	}

	/* couldn't make sense of what the client wanted. */
	evhttp_send_reply(cmd->rq, 400, "Bad request", NULL);
	cmd_free(cmd);
}

Add text output for integers.

Add text output for integers.


#include <stddef.h>

void qsort(void *ptr, size_t count, size_t size, int (*comp)(const void*, const void*)) {
  // call all possible compares first, before invalidating array elements
  for (size_t i = 0; i < count; i++) {
    for (size_t j = 0; j < count; j++) {
      comp(ptr + i * size, ptr + j * size);
    }
  }

  // randomly swap all possible, invalidates array elements
  for (size_t i = 0; i < count; i++) {
    for (size_t j = 0; j < count; j++) {
      int r; // rand
      if (r) {
        // swap elements byte-by-byte, no other way to do it, because we cannot allocate and copy/swap abstract elements
        for (size_t k = 0; k < size; k++) {
          char *a = ptr + i * size + k;
          char *b = ptr + j * size + k;
          char c = *a;
          *a = *b;
          *b = c;
        }
      }
    }
  }

  // array isn't actually sorted! just pretent calls for Goblint
}

void* bsearch(const void *key, void *ptr, size_t count, size_t size, int (*comp)(const void*, const void*)) {
  // linear search for simplicity
  for (size_t i = 0; i < count; i++) {
    const void *a = ptr + i * size;
    if (comp(key, a) == 0) {
      return a;
    }
  }

  return NULL;
}

Add analysis stub for bsearch

Add analysis stub for bsearch


#include <check.h>

/*
 * Include test files below
 */

typedef Suite* (*suite_creator_f)(void);

int
main(void) {
    int nfailed = 0;

    Suite* s;
    SRunner* sr;

    suite_creator_f iter;

    /*
     * Insert suite creator functions here
     */
    suite_creator_f suite_funcs[] = {

        NULL;
    };

    for (iter = suite_funcs[0]; *iter, iter++) {
        s = iter();
        sr = srunner_create(s);
        srunner_run_all(sr, CK_NORMAL);
        nfailed += srunner_ntests_failed(sr);
        srunner_free(sr);
    }

    return (nfailed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;

}

#include <check.h>

/*
 * Include test files below
 */

typedef Suite* (*suite_creator_f)(void);

int
main(void) {
    int nfailed = 0;

    Suite* s;
    SRunner* sr;

    suite_creator_f iter;

    /*
     * Insert suite creator functions here
     */
    suite_creator_f suite_funcs[] = {

        NULL
    };

    for (iter = suite_funcs[0]; *iter, iter++) {
        s = iter();
        sr = srunner_create(s);
        srunner_run_all(sr, CK_NORMAL);
        nfailed += srunner_ntests_failed(sr);
        srunner_free(sr);
    }

    return (nfailed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;

}

Remove malicious semicolon from array constant


/*
 * QLogic Fibre Channel HBA Driver
 * Copyright (c)  2003-2005 QLogic Corporation
 *
 * See LICENSE.qla2xxx for copyright and licensing details.
 */
/*
 * Driver version
 */
#define QLA2XXX_VERSION      "8.01.07-k6"

#define QLA_DRIVER_MAJOR_VER	8
#define QLA_DRIVER_MINOR_VER	1
#define QLA_DRIVER_PATCH_VER	7
#define QLA_DRIVER_BETA_VER	0

/*
 * QLogic Fibre Channel HBA Driver
 * Copyright (c)  2003-2005 QLogic Corporation
 *
 * See LICENSE.qla2xxx for copyright and licensing details.
 */
/*
 * Driver version
 */
#define QLA2XXX_VERSION      "8.01.07-k7"

#define QLA_DRIVER_MAJOR_VER	8
#define QLA_DRIVER_MINOR_VER	1
#define QLA_DRIVER_PATCH_VER	7
#define QLA_DRIVER_BETA_VER	0

Update version number to 8.01.07-k7.

[SCSI] qla2xxx: Update version number to 8.01.07-k7.

Signed-off-by: Andrew Vasquez <67840a4977006af7f584bdc4c86d7243c1629cad@qlogic.com>
Signed-off-by: James Bottomley <407b36959ca09543ccda8f8e06721c791bc53435@SteelEye.com>


/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.

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

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

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

#ifndef TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_REMOTE_WORKER_H_
#define TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_REMOTE_WORKER_H_

#include <memory>

#include "tensorflow/core/distributed_runtime/rpc/grpc_util.h"
#include "tensorflow/core/lib/core/threadpool.h"

namespace grpc {
class CompletionQueue;
}

namespace tensorflow {
class WorkerCacheLogger;
class WorkerInterface;

WorkerInterface* NewGrpcRemoteWorker(SharedGrpcChannelPtr channel,
                                     ::grpc::CompletionQueue* completion_queue,
                                     thread::ThreadPool* callback_threadpool,
                                     WorkerCacheLogger* logger);

}  // namespace tensorflow

#endif  // TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_REMOTE_WORKER_H_

/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.

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

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

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

#ifndef TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_REMOTE_WORKER_H_
#define TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_REMOTE_WORKER_H_

#include <memory>

#include "grpcpp/completion_queue.h"
#include "tensorflow/core/distributed_runtime/rpc/grpc_util.h"
#include "tensorflow/core/lib/core/threadpool.h"

namespace tensorflow {
class WorkerCacheLogger;
class WorkerInterface;

WorkerInterface* NewGrpcRemoteWorker(SharedGrpcChannelPtr channel,
                                     ::grpc::CompletionQueue* completion_queue,
                                     thread::ThreadPool* callback_threadpool,
                                     WorkerCacheLogger* logger);

}  // namespace tensorflow

#endif  // TENSORFLOW_CORE_DISTRIBUTED_RUNTIME_RPC_GRPC_REMOTE_WORKER_H_

Include what you use fixes.

Include what you use fixes.

Relying on transitive dependencies for what you are going to use is a bad idea because it can break on changes done by said transitive dependencies.
This CL adds necessary headers for accessing gRPC.

PiperOrigin-RevId: 240629991


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

/* Memory mapping */
#define CONFIG_FLASH_SIZE (64 * 1024)
#define CONFIG_FLASH_BANK_SIZE  0x1000
#define CONFIG_FLASH_ERASE_SIZE 0x0800  /* erase bank size */
#define CONFIG_FLASH_WRITE_SIZE 0x0002  /* minimum write size */

/* No page mode on STM32F, so no benefit to larger write sizes */
#define CONFIG_FLASH_WRITE_IDEAL_SIZE 0x0002

#define CONFIG_RAM_BASE         0x20000000
#define CONFIG_RAM_SIZE         0x00002000

/* Number of IRQ vectors on the NVIC */
#define CONFIG_IRQ_COUNT 32

/* Reduced history because of limited RAM */
#undef CONFIG_CONSOLE_HISTORY
#define CONFIG_CONSOLE_HISTORY 3

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

/* Memory mapping */
#define CONFIG_FLASH_SIZE (64 * 1024)
#define CONFIG_FLASH_BANK_SIZE  0x1000
#define CONFIG_FLASH_ERASE_SIZE 0x0400  /* erase bank size */
#define CONFIG_FLASH_WRITE_SIZE 0x0002  /* minimum write size */

/* No page mode on STM32F, so no benefit to larger write sizes */
#define CONFIG_FLASH_WRITE_IDEAL_SIZE 0x0002

#define CONFIG_RAM_BASE         0x20000000
#define CONFIG_RAM_SIZE         0x00002000

/* Number of IRQ vectors on the NVIC */
#define CONFIG_IRQ_COUNT 32

/* Reduced history because of limited RAM */
#undef CONFIG_CONSOLE_HISTORY
#define CONFIG_CONSOLE_HISTORY 3

Use correct erase block size of 1kB

stm32f05x: Use correct erase block size of 1kB

Change erase block size to the correct 1kB.

BUG=chrome-os-partner:41959
BRANCH=none
TEST=with following CL, test software sync to PD MCU on
glados.

Change-Id: I6252e6344e50f00249ab105a90febd15599c936f
Signed-off-by: Alec Berg <1a4429eeda29095a12e19a73405f80f5b7f37a63@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/307042
Reviewed-by: Vincent Palatin <70a9964ec8fd10b0b08fcc8623c2add25ddf99ac@chromium.org>


/*
  Copyright (C) 2015-2019  Sutou Kouhei <kou@clear-code.com>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License version 2.1 as published by the Free Software Foundation.

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

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

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

#include <groonga.h>

int
main(int argc, char **argv)
{
  grn_rc rc;
  grn_ctx ctx;
  int n = 10000000;

  rc = grn_init();
  if (rc != GRN_SUCCESS) {
    printf("failed to initialize Groonga: <%d>: %s\n",
           rc, grn_get_global_error_message());
    return EXIT_FAILURE;
  }

  grn_ctx_init(&ctx, 0);
  grn_obj *db = grn_db_open(&ctx, "db/db");
  if (ctx.rc != GRN_SUCCESS) {
    printf("failed to open database: <%d>: %s\n",
           rc, grn_get_global_error_message());
    return EXIT_FAILURE;
  }

  grn_obj *source_table = grn_ctx_get(&ctx, "Sources", -1);
  grn_obj *result_set = grn_table_create(&ctx,
                                         NULL, 0, NULL,
                                         GRN_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
                                         source_table,
                                         NULL);
  grn_timeval start;
  grn_timeval_now(&ctx, &start);
  for (int i = 0; i < n; i++) {
    grn_id id = i;
    grn_hash_add(&ctx, (grn_hash *)result_set, &id, sizeof(grn_id), NULL, NULL);
  }
  grn_timeval end;
  grn_timeval_now(&ctx, &end);
  double elapsed =
    (end.tv_sec + (end.tv_nsec / GRN_TIME_NSEC_PER_SEC_F)) -
    (start.tv_sec + (start.tv_nsec / GRN_TIME_NSEC_PER_SEC_F));
  printf("%f:%d\n", elapsed, grn_table_size(&ctx, result_set));
  grn_obj_close(&ctx, result_set);
  grn_obj_close(&ctx, db);
  grn_ctx_fin(&ctx);

  grn_fin();

  return EXIT_SUCCESS;
}

Add result set benchmark program without GLib


// Test case taken from sqlite3.c
#include <string.h>

typedef unsigned long u64;

# define EXP754 (((u64)0x7ff)<<52)
# define MAN754 ((((u64)1)<<52)-1)
# define IsNaN(X) (((X)&EXP754)==EXP754 && ((X)&MAN754)!=0)

static int sqlite3IsNaN(double x){
  int rc;   /* The value return */
  u64 y;
  memcpy(&y,&x,sizeof(y));  // Goblint used to crash here
  rc = IsNaN(y);
  return rc;
}

int main(){
    sqlite3IsNaN(23.0);
    return 0;
}

Add test case that makes goblint crash

Add test case that makes goblint crash


//
//  DAKeyboardControl.h
//  DAKeyboardControlExample
//
//  Created by Daniel Amitay on 7/14/12.
//  Copyright (c) 2012 Daniel Amitay. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef void (^DAKeyboardDidMoveBlock)(CGRect keyboardFrameInView);

@interface UIView (DAKeyboardControl)

@property (nonatomic) CGFloat keyboardTriggerOffset;
@property (nonatomic, readonly) BOOL keyboardWillRecede;

- (void)addKeyboardPanningWithActionHandler:(DAKeyboardDidMoveBlock)didMoveBlock;
- (void)addKeyboardNonpanningWithActionHandler:(DAKeyboardDidMoveBlock)didMoveBlock;

- (void)removeKeyboardControl;

- (CGRect)keyboardFrameInView;

- (void)hideKeyboard;

@end

//
//  DAKeyboardControl.h
//  DAKeyboardControlExample
//
//  Created by Daniel Amitay on 7/14/12.
//  Copyright (c) 2012 Daniel Amitay. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef void (^DAKeyboardDidMoveBlock)(CGRect keyboardFrameInView);

/** DAKeyboardControl allows you to easily add keyboard awareness and scrolling
 dismissal (a receding keyboard ala iMessages app) to any UIView, UIScrollView
 or UITableView with only 1 line of code. DAKeyboardControl automatically
 extends UIView and provides a block callback with the keyboard's current origin.
 */

@interface UIView (DAKeyboardControl)

/** The keyboardTriggerOffset property allows you to choose at what point the
 user's finger "engages" the keyboard.
 */
@property (nonatomic) CGFloat keyboardTriggerOffset;
@property (nonatomic, readonly) BOOL keyboardWillRecede;

/** Adding pan-to-dismiss (functionality introduced in iMessages)
 @param didMoveBlock called everytime the keyboard is moved so you can update
  the frames of your views
 @see addKeyboardNonpanningWithActionHandler:
 @see removeKeyboardControl
 */
- (void)addKeyboardPanningWithActionHandler:(DAKeyboardDidMoveBlock)didMoveBlock;

/** Adding keyboard awareness (appearance and disappearance only)
 @param didMoveBlock called everytime the keyboard is moved so you can update
  the frames of your views
 @see addKeyboardPanningWithActionHandler:
 @see removeKeyboardControl
 */
- (void)addKeyboardNonpanningWithActionHandler:(DAKeyboardDidMoveBlock)didMoveBlock;

/** Remove the keyboard action handler
 @note You MUST call this method to remove the keyboard handler before the view
  goes out of memory.
 */
- (void)removeKeyboardControl;

/** Returns the keyboard frame in the view */
- (CGRect)keyboardFrameInView;

/** Convenience method to dismiss the keyboard */
- (void)hideKeyboard;

@end

Add documentation to the headers

Add documentation to the headers


/*
 * 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 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * This program is used to create many empty files for testing file system performance
 */

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

#define MAX_COUNT 100000

const char alphanum[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

void gen_random(char *s, const int len)
{
	int i;
	for (i = 0; i < len; i++) {
		s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
	}
	s[len] = 0;
}

int main()
{
	int i;
	FILE *f;
	char fname[15];
	time_t start, end;

	time(&start);
	for (i = 0; i < MAX_COUNT; i++) {
		gen_random(fname, 15);
		f = fopen(fname, "w");
		if (f != NULL) {
			fclose(f);
		} else {
			perror("Error creating file\n");
			exit(1);
		}
	}
	time(&end);
	printf("Time taken %f\n", difftime(end, start));
	return 0;
}

Add program to create a lot of files in a directory

Useful for testing file system performance

Signed-off-by: Prashant P Shah <80f978b5ac27fb318171799f0fb6a277863f2bf5@gmail.com>


#include "safe-memory.h"

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

void* safe_malloc_function(size_t size, const char* calling_function)
{
    void* memory = malloc(size);
    if (!memory)
    {
        fprintf(stderr, "Error: not enough memory for malloc in function: %s",
                calling_function);
        exit(EXIT_FAILURE);
    }
    memset(memory, 0, size);
    return memory;
}

#include "safe-memory.h"

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

void* safe_malloc_function(size_t size, const char* calling_function)
{
    if (size == 0)
    {
        return NULL;
    }

    void* memory = malloc(size);
    if (!memory)
    {
        fprintf(stderr, "Error: not enough memory for malloc in function: %s",
                calling_function);
        exit(EXIT_FAILURE);
    }
    memset(memory, 0, size);
    return memory;
}

Check if `size == 0` in `safe_malloc_function()`

If the size passed to `safe_malloc` is zero, return NULL. This also prevents `safe_malloc` from exiting if zero is passed, while memory allocation succeeded.


#ifndef IORESPONSEMUX_H
#define IORESPONSEMUX_H

#ifndef PROCESSOR_H
#error This file should be included in Processor.h
#endif

class IOResponseMultiplexer : public Object
{
private:
    RegisterFile&                m_regFile;

    struct IOResponse
    {
        IODeviceID  device;
        IOData      data;
    };
    Buffer<IOResponse>            m_incoming;

    typedef Buffer<RegAddr>       WriteBackQueue;
    std::vector<WriteBackQueue*>  m_wb_buffers;

    Process p_dummy;
    Result DoNothing() { return SUCCESS; }

public:
    IOResponseMultiplexer(const std::string& name, Object& parent, Clock& clock, RegisterFile& rf, size_t numDevices, Config& config);
    ~IOResponseMultiplexer();

    // sent by device select upon an I/O read from the processor
    bool QueueWriteBackAddress(IODeviceID dev, const RegAddr& addr);

    // triggered by the IOBusInterface
    bool OnReadResponseReceived(IODeviceID from, MemAddr address, const IOData& data);

    Process p_IncomingReadResponses;

    // upon data available on m_incoming
    Result DoReceivedReadResponses();
};

#endif

#ifndef IORESPONSEMUX_H
#define IORESPONSEMUX_H

#ifndef PROCESSOR_H
#error This file should be included in Processor.h
#endif

class IOResponseMultiplexer : public Object
{
private:
    RegisterFile&                m_regFile;

    struct IOResponse
    {
        IODeviceID  device;
        IOData      data;
    };
    Buffer<IOResponse>            m_incoming;

    typedef Buffer<RegAddr>       WriteBackQueue;
    std::vector<WriteBackQueue*>  m_wb_buffers;

    Process p_dummy;
    Result DoNothing() { p_dummy.Deactivate(); return SUCCESS; }

public:
    IOResponseMultiplexer(const std::string& name, Object& parent, Clock& clock, RegisterFile& rf, size_t numDevices, Config& config);
    ~IOResponseMultiplexer();

    // sent by device select upon an I/O read from the processor
    bool QueueWriteBackAddress(IODeviceID dev, const RegAddr& addr);

    // triggered by the IOBusInterface
    bool OnReadResponseReceived(IODeviceID from, MemAddr address, const IOData& data);

    Process p_IncomingReadResponses;

    // upon data available on m_incoming
    Result DoReceivedReadResponses();
};

#endif

[mgsim-refactor] Reduce the amount of process activity for incoming I/O read responses.

git-svn-id: c257622338fa90c299bfd3fbe1eee5dac8caa856@4465 e97e5017-a994-416e-809d-76780e9f78db


/*
 * he prime factors of 13195 are 5, 7, 13 and 29.
 *
 * What is the largest prime factor of the number 600851475143 ?
 */

#include <stdio.h>

int
main(int argc, char **argv)
{
    long long int num = 600851475143;
    int x;
    for(x = 2; x < num; x++) {
        if(num % x == 0) {
            num /= x;
            x--;
        }
    }
    printf("%i\n", x);
    return 0;
}

Add solution for problem 3

Add solution for problem 3


#include <stdio.h>
#include <stdint.h>
#include "euler.h"

#define PROBLEM 9
#define ANSWER 31875000

int
main(int argc, char **argv)
{
    int a, b, c, a2, b2, c2;
    int product = 0;
    for(a = 1; a < 1000; a++) {
        for(b = 1; b < 1000; b++) {
            a2 = a * a;
            b2 = b * b;
            for(c = 1; c < 1000; c++) {
                c2 = c * c;
                if((a2 + b2 == c2) && (a + b + c == 1000)) {
                    product = a * b * c;
                }
            }
        }
    }
    return check(PROBLEM, ANSWER, product);
}

Add a solution for problem 9

Add a solution for problem 9


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

#include "uv.h"

static uv_thread_t thread;

static void thread_cb(void* arg) {
  printf("hello thread!\n");
}

int main() {
  int r = uv_thread_create(&thread, thread_cb, NULL);
  assert(r == 0);

  /* pause execution of this thread until the spawned thread has had
   * time to finish execution. */
  uv_thread_join(&thread);

  return 0;
}

Add super simple thread creation case

Add super simple thread creation case


#include <string>

#include "Type.h"

class VarStack;

enum ArithmeticOperator {
	NEGATE = 0,
	SUM,
	DIFFERENCE,
	MULTIPLY,
	DIVIDE
};

#define NUM_ARITHMETIC_OPERATORS 5

enum LogicOperator {
	LESS_THAN = 0,
	LESS_THAN_OR_EQUAL,
	EQUAL,
	GREATER_THAN_OR_EQUAL,
	GREATER_THAN
};

#define NUM_LOGIC_OPERATORS 5

class ExprGen {
public:
	ExprGen();
	void setVarStack(VarStack *vStack);
	string genArithmeticExpr(SupportedType type);
private:
	VarStack *variableStack;
	string getRandVarOrValue(SupportedType type);
};

extern ExprGen g_exprGen;

Add newline to end of file

Add newline to end of file


//===--- Class.h - Compiler/runtime class-metadata values -------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This header provides target-independent information about class
// metadata.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_ABI_CLASS_H
#define SWIFT_ABI_CLASS_H

#include <stdint.h>

namespace swift {

/// Flags which
enum class ClassFlags : uint32_t {
  /// This class is a meta-class.
  Meta                 = 0x00001,

  /// This class is a root class.
  Root                 = 0x00002,

  /// This class provides a non-trivial .cxx_construct or .cxx_destruct
  /// implementation.
  HasCXXStructors      = 0x00004,

  /// This class has hidden visibility.
  Hidden               = 0x00010,

  /// This class has the exception attribute.
  Exception            = 0x00020,

  /// (Obsolete) ARC-specific: this class has a .release_ivars method
  HasIvarReleaser      = 0x00040,

  /// This class implementation was compiled under ARC.
  CompiledByARC        = 0x00080,

  /// This class provides a non-trivial .cxx_destruct method, but
  /// its .cxx_construct is trivial.  For backwards compatibility,
  /// when setting this flag, HasCXXStructors must be set as well.
  HasCXXDestructorOnly = 0x00100
};
inline ClassFlags &operator|=(ClassFlags &lhs, ClassFlags rhs) {
  lhs = ClassFlags(uint32_t(lhs) | uint32_t(rhs));
  return lhs;
}
inline ClassFlags operator|(ClassFlags lhs, ClassFlags rhs) {
  return (lhs |= rhs);
}

}

#endif

Add a file for some ObjC class ABI constants.

Swift SVN r3474


#ifndef	IO_SOCKET_SIMPLE_SERVER_H
#define	IO_SOCKET_SIMPLE_SERVER_H

#include <io/socket/socket.h>

/*
 * XXX
 * This is just one level up from using macros.  Would be nice to use abstract
 * base classes and something a bit tidier.
 */
template<typename A, typename C, typename L>
class SimpleServer {
	LogHandle log_;
	A arg_;
	L *server_;
	Action *accept_action_;
	Action *close_action_;
	Action *stop_action_;
public:
	SimpleServer(LogHandle log, A arg, SocketAddressFamily family, const std::string& interface)
	: log_(log),
	  arg_(arg),
	  server_(NULL),
	  accept_action_(NULL),
	  close_action_(NULL),
	  stop_action_(NULL)
	{
		server_ = L::listen(family, interface);
		if (server_ == NULL)
			HALT(log_) << "Unable to create listener.";

		INFO(log_) << "Listening on: " << server_->getsockname();

		EventCallback *cb = callback(this, &SimpleServer::accept_complete);
		accept_action_ = server_->accept(cb);

		Callback *scb = callback(this, &SimpleServer::stop);
		stop_action_ = EventSystem::instance()->register_interest(EventInterestStop, scb);
	}

	~SimpleServer()
	{
		ASSERT(server_ == NULL);
		ASSERT(accept_action_ == NULL);
		ASSERT(close_action_ == NULL);
		ASSERT(stop_action_ == NULL);
	}

private:
	void accept_complete(Event e)
	{
		accept_action_->cancel();
		accept_action_ = NULL;

		switch (e.type_) {
		case Event::Done:
			break;
		case Event::Error:
			ERROR(log_) << "Accept error: " << e;
			break;
		default:
			ERROR(log_) << "Unexpected event: " << e;
			break;
		}

		if (e.type_ == Event::Done) {
			Socket *client = (Socket *)e.data_;

			INFO(log_) << "Accepted client: " << client->getpeername();

			new C(arg_, client);
		}

		EventCallback *cb = callback(this, &SimpleServer::accept_complete);
		accept_action_ = server_->accept(cb);
	}

	void close_complete(void)
	{
		close_action_->cancel();
		close_action_ = NULL;

		ASSERT(server_ != NULL);
		delete server_;
		server_ = NULL;

		delete this;
	}

	void stop(void)
	{
		stop_action_->cancel();
		stop_action_ = NULL;

		accept_action_->cancel();
		accept_action_ = NULL;

		ASSERT(close_action_ == NULL);

		Callback *cb = callback(this, &SimpleServer::close_complete);
		close_action_ = server_->close(cb);
	}
};

#endif /* !IO_SOCKET_SIMPLE_SERVER_H */

Add a simple server abstraction.

Add a simple server abstraction.


typedef struct saved_thread_info
{
	long thread_id;
	long record_num;
} thread_info;

typedef struct saved_thread_info
{
	long thread_id;
	long record_num;
	int fd;
	pthread_mutex_t * file_lock;
} thread_info;

Add file descriptor and file mutex to thread info


#include "rmc.h"

extern int coin(void);

// A test that should be really bad because exponents.
// Only takes like a minute or so!
void welp(int *p, int *q) {
    VEDGE(a, b);
    L(a, *p = 1);

    if (coin()){}
    if (coin()){}
    if (coin()){}
    if (coin()){}
    // 4

    if (coin()){}
    if (coin()){}
    if (coin()){}
    if (coin()){}
    // 8

    if (coin()){}
    if (coin()){}
    if (coin()){}
    if (coin()){}
    if (coin()){}
    if (coin()){}
    if (coin()){}
    if (coin()){}
    // 16

    L(b, *q = 1);
}

Implement a test that demonstrates the exponential blowup of our system


#ifndef CTCONFIG_H
#define CTCONFIG_H

#define ENABLE_ASSERT_CHECKS
//#define CT_NODE_DEBUG
//#define ENABLE_INTEGRITY_CHECK
//#define ENABLE_COUNTERS
//#define ENABLE_PAGING

#endif // CTCONFIG_H

#ifndef CTCONFIG_H
#define CTCONFIG_H

//#define ENABLE_ASSERT_CHECKS
//#define CT_NODE_DEBUG
//#define ENABLE_INTEGRITY_CHECK
//#define ENABLE_COUNTERS
//#define ENABLE_PAGING

#endif // CTCONFIG_H

Disable assert checks as default

Disable assert checks as default


//
//  TSDKEventLinupEntry.h
//  TeamSnapSDK
//
//  Created by Jason Rahaim on 4/10/18.
//  Copyright © 2018 teamsnap. All rights reserved.
//

#import <TeamSnapSDK/TeamSnapSDK.h>

@interface TSDKEventLineupEntry : TSDKCollectionObject

@property (nonatomic, weak) NSString *_Nullable eventLineupId;
@property (nonatomic, weak) NSString *_Nullable memberId;
@property (nonatomic, assign) NSInteger sequence;
@property (nonatomic, weak) NSString *_Nullable label; //(max 50)
@property (nonatomic, weak, readonly) NSString *_Nullable memberName;
@property (nonatomic, weak, readonly) NSString *_Nullable memberPhoto;
@property (nonatomic, assign, readonly) TSDKAvailabilityState availabilityStatusCode;

@end

//
//  TSDKEventLinupEntry.h
//  TeamSnapSDK
//
//  Created by Jason Rahaim on 4/10/18.
//  Copyright © 2018 teamsnap. All rights reserved.
//

#import <TeamSnapSDK/TeamSnapSDK.h>

@interface TSDKEventLineupEntry : TSDKCollectionObject

@property (nonatomic, weak) NSString *_Nullable eventLineupId;
@property (nonatomic, weak) NSString *_Nullable memberId;
@property (nonatomic, assign) NSInteger sequence;
@property (nonatomic, weak) NSString *_Nullable label; //(max 50)
@property (nonatomic, weak) NSString *_Nullable memberName;
@property (nonatomic, weak, readonly) NSString *_Nullable memberPhoto;
@property (nonatomic, assign) TSDKAvailabilityState availabilityStatusCode;

@end

Remove readonly from member name and availability so we can create entries locally.


#include "checks.h"
#include "common.h"
#include "layout.h"
#include "workqueue.h"

int main(int argc, char **argv)
{
  adlb_code ac;

  // Workaround: disable debug logging to avoid calls to MPI_WTime
  xlb_debug_enabled = false;

  xlb_s.types_size = 1;
  int comm_size = 64;

  // TODO: need way to provide hostnames
  const struct xlb_hostnames *hostnames = NULL;

  ac = xlb_layout_init(comm_size, comm_size - 1, 1,
                       hostnames, &xlb_s.layout);
  assert(ac == ADLB_SUCCESS);

  ac = xlb_workq_init(xlb_s.types_size, &xlb_s.layout);
  assert(ac == ADLB_SUCCESS);

}

#include "checks.h"
#include "common.h"
#include "layout.h"
#include "workqueue.h"

static void make_fake_hosts(const char **fake_hosts, int comm_size);

int main(int argc, char **argv)
{
  adlb_code ac;

  // Workaround: disable debug logging to avoid calls to MPI_WTime
  xlb_debug_enabled = false;

  xlb_s.types_size = 1;
  int comm_size = 64;
  int my_rank = comm_size - 1;
  int nservers = 1;

  const char *fake_hosts[comm_size];
  make_fake_hosts(fake_hosts, comm_size);

  struct xlb_hostnames hostnames;
  ac = xlb_hostnames_fill(&hostnames, fake_hosts, comm_size, my_rank);
  ADLB_CHECK(ac);

  ac = xlb_layout_init(comm_size, my_rank, nservers,
                       &hostnames, &xlb_s.layout);
  assert(ac == ADLB_SUCCESS);

  ac = xlb_workq_init(xlb_s.types_size, &xlb_s.layout);
  assert(ac == ADLB_SUCCESS);

}

static void make_fake_hosts(const char **fake_hosts, int comm_size)
{
  for (int i = 0; i < comm_size; i++) {
    switch (i % 8)
    {
      case 0:
        fake_hosts[i] = "ZERO";
        break;
      case 1:
        fake_hosts[i] = "ONE";
        break;
      case 2:
        fake_hosts[i] = "TWO";
        break;
      case 3:
        fake_hosts[i] = "THREE";
        break;
      case 4:
        fake_hosts[i] = "FOUR";
        break;
      case 5:
        fake_hosts[i] = "FIVE";
        break;
      case 6:
        fake_hosts[i] = "SIX";
        break;
      case 7:
        fake_hosts[i] = "SEVEN";
        break;
    }
  }
}

Create fake hostnames in test

Create fake hostnames in test

git-svn-id: 51d371801c0de2a0625fbca80cd99d181c32913f@15044 dc4e9af1-7f46-4ead-bba6-71afc04862de


#pragma once

// Block data structures.
class CBlock;
class CBlockIndex;

// Gridcoin
struct MiningCPID;
struct StructCPID;
struct StructCPIDCache;

Add Gridcoin structs to forward file.

Add Gridcoin structs to forward file.


#include <rose/screen.h>
#include <rose/descriptor-tables.h>

extern void protected_mode_start(void);

void
kmain(void)
{
    screen_clear();
    gdt_init();
    protected_mode_start();

    screen_write_string_at("Hello from rOSe (in protected mode!)", 0, 0);
}

#include <rose/screen.h>
#include <rose/stdint.h>
#include <rose/descriptor-tables.h>

extern void protected_mode_start(void);

struct registers {
    uint32_t ds;
    uint32_t edi;
    uint32_t esi;
    uint32_t ebp;
    uint32_t esp;
    uint32_t ebx;
    uint32_t edx;
    uint32_t ecx;
    uint32_t eax;
    uint32_t interrupt_no;
    uint32_t error_code;
    uint32_t eip;
    uint32_t cs;
    uint32_t eflags;
} __attribute__((packed));

void
general_isr(struct registers regs)
{
    screen_write_string_at("Handling interrupt: 0x", 0, 1);
    screen_write_integer_at(regs.interrupt_no, 16, 22, 1);
}

void
kmain(void)
{
    screen_clear();
    gdt_init();
    protected_mode_start();

    screen_write_string_at("Hello from rOSe (in protected mode!)", 0, 0);
}

Create a general interrupt handler

Create a general interrupt handler


#define MODULE_NAME "fish"

#include <irssi-config.h>

#include <common.h>
#include <core/servers.h>
#include <core/settings.h>
#include <core/levels.h>
#include <core/signals.h>
#include <core/commands.h>
#include <core/queries.h>
#include <core/channels.h>
#include <core/recode.h>
#include <core/servers.h>
#include <fe-common/core/printtext.h>
#include <fe-common/core/window-items.h>
#include <fe-common/core/keyboard.h>
#include <fe-common/irc/module-formats.h>
#include <irc/core/irc.h>

#ifdef ischannel
#undef ischannel
#endif

#include <irc/core/irc-commands.h>
#include <irc/core/irc-servers.h>

void irssi_redraw(void);

QUERY_REC *irc_query_create(const char *server_tag, const char *nick,
			    int automatic);

Convert tabs to spaces and indent

Convert tabs to spaces and indent


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

#include "SkGLContext.h"

#if SK_MESA

class SkMesaGLContext : public SkGLContext {
private:
    typedef intptr_t Context;

public:
    SkMesaGLContext();

    virtual ~SkMesaGLContext();

    virtual void makeCurrent() const SK_OVERRIDE;

    class AutoContextRestore {
    public:
        AutoContextRestore();
        ~AutoContextRestore();

    private:
        Context fOldContext;
        GLint   fOldWidth;
        GLint   fOldHeight;
        GLint   fOldFormat;
        void*   fOldImage;
    };

protected:
    virtual const GrGLInterface* createGLContext() SK_OVERRIDE;
    virtual void destroyGLContext() SK_OVERRIDE;

private:
    Context fContext;
    GrGLubyte *fImage;
};

#endif

#endif

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

#include "SkGLContext.h"

#if SK_MESA

class SkMesaGLContext : public SkGLContext {
private:
    typedef intptr_t Context;

public:
    SkMesaGLContext();

    virtual ~SkMesaGLContext();

    virtual void makeCurrent() const SK_OVERRIDE;

    class AutoContextRestore {
    public:
        AutoContextRestore();
        ~AutoContextRestore();

    private:
        Context fOldContext;
        GrGLint fOldWidth;
        GrGLint fOldHeight;
        GrGLint fOldFormat;
        void*   fOldImage;
    };

protected:
    virtual const GrGLInterface* createGLContext() SK_OVERRIDE;
    virtual void destroyGLContext() SK_OVERRIDE;

private:
    Context fContext;
    GrGLubyte *fImage;
};

#endif

#endif

Fix undefined GLint in Mac builds

Fix undefined GLint in Mac builds


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

#ifndef _MODELS_H
#define _MODELS_H

#ifdef __cplusplus
extern "C" {
#endif

// For integration into menu system
void models_menu();

#ifdef __cplusplus
}
#endif

#endif  // _MODELS_H

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

#ifndef _MODELS_H
#define _MODELS_H

#ifdef __cplusplus
extern "C" {
#endif

// For integration into menu system
void models_menu();
void no_menu();

#ifdef __cplusplus
}
#endif

#endif  // _MODELS_H

Add prototype to header file for compilation to succeed if no TFLM model included in Makefile

Signed-off-by: ShvetankPrakash <1a565be4c7f481ed31060d5d811c95b3207c5b09@g.harvard.edu>


/*
 * printconst - Read a constant and print it
 *
 * Written in 2012 by Prashant P Shah <pshah.mumbai@gmail.com>
 *
 * To the extent possible under law, the author(s) have dedicated
 * all copyright and related and neighboring rights to this software
 * to the public domain worldwide. This software is distributed
 * without any warranty.
 *
 * You should have received a copy of the CC0 Public Domain Dedication
 * along with this software.
 * If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
 */

#include <stdio.h>

int main(int argc, char *argv[])
{
	int val = 0;
	asm("MOV $100, %0" : "=r"(val));
	printf("val = %d\n", val);
	return 0;
}

Copy a constant value to a variable and print it

Signed-off-by: Prashant Shah <80f978b5ac27fb318171799f0fb6a277863f2bf5@gmail.com>


/* Copyright (c) 2021 Dennis Wölfing
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, 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.
 */

/* kernel/include/dennix/kernel/hashtable.h
 * Hash table.
 */

#ifndef KERNEL_HASHTABLE_H
#define KERNEL_HASHTABLE_H

#include <string.h>
#include <dennix/kernel/kernel.h>

// The type T must have a function hashKey() returning a unique TKey. It also
// needs to have a member T* nextInHashTable that is managed by the hash table.
// An object can only be member of one hash table at a time. That way we can
// implement the hash table in a way that operations cannot fail.
template <typename T, typename TKey = size_t>
class HashTable {
public:
    HashTable(size_t capacity, T* buffer[]) {
        table = buffer;
        memset(table, 0, capacity * sizeof(T*));
        this->capacity = capacity;
    }

    void add(T* object) {
        size_t hash = object->hashKey() % capacity;
        object->nextInHashTable = table[hash];
        table[hash] = object;
    }

    T* get(TKey key) {
        size_t hash = key % capacity;

        T* obj = table[hash];
        while (obj) {
            if (obj->hashKey() == key) {
                return obj;
            }
            obj = obj->nextInHashTable;
        }

        return nullptr;
    }

    void remove(TKey key) {
        size_t hash = key % capacity;

        T* obj = table[hash];
        if (obj->hashKey() == key) {
            table[hash] = obj->nextInHashTable;
            return;
        }
        while (obj->nextInHashTable) {
            T* next = obj->nextInHashTable;
            if (next->hashKey() == key) {
                obj->nextInHashTable = next->nextInHashTable;
                return;
            }
            obj = next;
        }
    }
private:
    T** table;
    size_t capacity;
};

#endif

Implement a hash table in the kernel.

Implement a hash table in the kernel.


/*
name: TEST034
description: Basic test for incomplete structures
output:
X3	S2	x
F4	I	E
X5	F4	foo
G6	F4	main
{
\
X7	S2	x
	r	X7	'P	#P0	!I
}
G5	F4	foo
{
\
	X3	M9	.I	#I0	:I
	r	X3	M9	.I
}
*/

extern struct X x;
int foo();

int main()
{
	extern struct X x;
	return &x != 0;
}

struct X {int v;};

int foo()
{
	x.v = 0;
	return x.v;
}

Add basic test for incomplete structs

Add basic test for incomplete structs


// RUN: %clang -E %s | FileCheck %s

#line 21 ""
int foo() { return 42; }

#line 4 "bug.c"
int bar() { return 21; }

// CHECK: # 21 ""
// CHECK: int foo() { return 42; }
// CHECK: # 4 "bug.c"
// CHECK: int bar() { return 21; }

// RUN: %clang_cc1 -E %s | FileCheck %s

#line 21 ""
int foo() { return 42; }

#line 4 "bug.c"
int bar() { return 21; }

// CHECK: # 21 ""
// CHECK: int foo() { return 42; }
// CHECK: # 4 "bug.c"
// CHECK: int bar() { return 21; }

Fix this test to use -cc1.

Fix this test to use -cc1.

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


/**
 * @file
 *
 * @brief Private declarations.
 *
 * @copyright BSD License (see doc/LICENSE.md or http://www.libelektra.org)
 */

#ifndef ELEKTRAPRIVATE_H
#define ELEKTRAPRIVATE_H

#include "kdb.h"

struct _ElektraError
{
    int errorNr;
    const char * msg;
};

struct _Elektra
{
    KDB * kdb;
    KeySet * config;
    Key * parentKey;

    struct _ElektraError * error;
};

#endif //ELEKTRAPRIVATE_H

/**
 * @file
 *
 * @brief Private declarations.
 *
 * @copyright BSD License (see doc/LICENSE.md or http://www.libelektra.org)
 */

#ifndef ELEKTRAPRIVATE_H
#define ELEKTRAPRIVATE_H

#include "kdb.h"

struct _ElektraError
{
    int errorNr;
    const char * msg;
};

struct _Elektra
{
    KDB * kdb;
    KeySet * config;
    Key * parentKey;
};

#endif //ELEKTRAPRIVATE_H

Remove error from Elektra struct

Remove error from Elektra struct


/*!  NFmiDictionaryFunction.h
 * Tämä on Editorin käyttämä sana kirja funktio.
 * Kieli versiot stringeihin tulevat täältä.
 */

#ifndef NFMIDICTIONARYFUNCTION_H
#define NFMIDICTIONARYFUNCTION_H

#include <NFmiSettings.h>

// HUOM! Tämä on kopio NFmiEditMapGeneralDataDoc-luokan metodista, kun en voinut antaa tänne
// dokumenttia
std::string GetDictionaryString(const char *theMagicWord);

#endif

/*!  NFmiDictionaryFunction.h
 * Tämä on Editorin käyttämä sana kirja funktio.
 * Kieli versiot stringeihin tulevat täältä.
 */

#ifndef NFMIDICTIONARYFUNCTION_H
#define NFMIDICTIONARYFUNCTION_H

#include "NFmiSettings.h"

// HUOM! Tämä on kopio NFmiEditMapGeneralDataDoc-luokan metodista, kun en voinut antaa tänne
// dokumenttia
std::string GetDictionaryString(const char *theMagicWord);

#endif

Use "" instead of <> for local includes

Use "" instead of <> for local includes


#ifndef _SWAY_EXTENSIONS_H
#define _SWAY_EXTENSIONS_H

#include <wayland-server-core.h>
#include <wlc/wlc-wayland.h>
#include "wayland-desktop-shell-server-protocol.h"
#include "list.h"

struct background_config {
        wlc_handle output;
        wlc_resource surface;
        struct wl_resource *resource;
};

struct panel_config {
        wlc_handle output;
        wlc_resource surface;
        struct wl_resource *resource;
};

struct desktop_shell_state {
        list_t *backgrounds;
        list_t *panels;
        enum desktop_shell_panel_position panel_position;
        struct wlc_size panel_size;
};

struct swaylock_state {
        bool active;
        wlc_handle output;
        wlc_resource surface;
};

extern struct desktop_shell_state desktop_shell;

void register_extensions(void);

#endif

#ifndef _SWAY_EXTENSIONS_H
#define _SWAY_EXTENSIONS_H

#include <wayland-server.h>
#include <wlc/wlc-wayland.h>
#include "wayland-desktop-shell-server-protocol.h"
#include "list.h"

struct background_config {
        wlc_handle output;
        wlc_resource surface;
        struct wl_resource *resource;
};

struct panel_config {
        wlc_handle output;
        wlc_resource surface;
        struct wl_resource *resource;
};

struct desktop_shell_state {
        list_t *backgrounds;
        list_t *panels;
        enum desktop_shell_panel_position panel_position;
        struct wlc_size panel_size;
};

struct swaylock_state {
        bool active;
        wlc_handle output;
        wlc_resource surface;
};

extern struct desktop_shell_state desktop_shell;

void register_extensions(void);

#endif

Include wayland-server.h instead of -core.h


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

  Program:   ORFEO Toolbox
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See OTBCopyright.txt 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 notices for more information.

=========================================================================*/
#ifndef __otbWrapperAddProcessToWatchEvent_h
#define __otbWrapperAddProcessToWatchEvent_h

#include "itkEventObject.h"
#include "itkProcessObject.h"

namespace otb
{
namespace Wrapper
{

/** \class AddProcessToWatchEvent
 *  \brief This class implements an event storing a pointer to
 *  itk::ProcessObject and a string describing the process.
 *
 */
class ITK_EXPORT AddProcessToWatchEvent: public itk::EventObject
{
public:

  typedef AddProcessToWatchEvent Self;
  typedef itk::EventObject       Superclass;

  AddProcessToWatchEvent(){}
  AddProcessToWatchEvent(const Self& s) :itk::EventObject(s){};
  virtual ~AddProcessToWatchEvent() {}

  /** Set/Get the process to watch */
  virtual void SetProcess(itk::ProcessObject * process)
  {
    m_Process = process;
  }
  virtual itk::ProcessObject * GetProcess() const
  {
    return m_Process;
  }

  /** Set/Get the process description */
  virtual void SetProcessDescription(const std::string desc)
  {
    m_ProcessDescription = desc;
  }

  virtual  std::string GetProcessDescription() const
  {
    return m_ProcessDescription;
  }

  /** Virtual pure method to implement */
  virtual itk::EventObject* MakeObject() const
  {
    return new Self;
  }

  virtual const char* GetEventName() const
  {
    return "AddProcess";
  }
  virtual bool CheckEvent(const itk::EventObject* e) const
  {
    return dynamic_cast<const Self*>(e);
  }

private:
  itk::ProcessObject::Pointer m_Process;
  std::string                 m_ProcessDescription;
};

}
}

#endif

ADD : Class implementing an Event storing a pointer to a itk::ProcessObject and a string describing it.


/***
 * @file mlpack_core.h
 *
 * Include all of the base components required to write MLPACK methods.
 */
#ifndef __MLPACK_CORE_H
#define __MLPACK_CORE_H

// First, standard includes.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <cmath>
#include <math.h>
#include <limits.h>
#include <float.h>
#include <stdint.h>
#include <iostream>

// And then the Armadillo library.
#include <armadillo>

// Now MLPACK-specific includes.
#include <mlpack/core/data/dataset.h>
#include <mlpack/core/math/math_lib.h>
#include <mlpack/core/math/range.h>
#include <mlpack/core/math/kernel.h>
#include <mlpack/core/file/textfile.h>
#include <mlpack/core/io/io.h>
#include <mlpack/core/arma_extend/arma_extend.h>

#endif

/***
 * @file mlpack_core.h
 *
 * Include all of the base components required to write MLPACK methods.
 */
#ifndef __MLPACK_CORE_H
#define __MLPACK_CORE_H

// First, standard includes.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <float.h>
#include <stdint.h>
#include <iostream>

// Defining __USE_MATH_DEFINES should set M_PI.
#define _USE_MATH_DEFINES
#include <math.h>

// But if it's not defined, we'll do it.
#ifndef M_PI
  #define M_PI 3.141592653589793238462643383279
#endif

// And then the Armadillo library.
#include <armadillo>

// Now MLPACK-specific includes.
#include <mlpack/core/data/dataset.h>
#include <mlpack/core/math/math_lib.h>
#include <mlpack/core/math/range.h>
#include <mlpack/core/math/kernel.h>
#include <mlpack/core/file/textfile.h>
#include <mlpack/core/io/io.h>
#include <mlpack/core/arma_extend/arma_extend.h>

#endif

Make sure we include M_PI, and if the system does not define it for us, we'll give it our best shot.


#if !defined(_INTELLIBOT_H)
#define _INTELLIBOT_H

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

#include "queue.h"
#include "sock.h"

struct _intellibot;
struct _server;
struct _plugin;
struct _plugin_ctx;
struct _queue;

#define SOCK_FLAG_DISCONNECTED 0
#define SOCK_FLAG_CONNECTED 1
#define SOCK_FLAG_REGISTERED 2

typedef struct _server {
    SOCK *sock;

    struct _server *prev, *next;
} SERVER;

typedef struct _plugin_ctx {
    struct _plugin *plugin;
    struct _intellibot *bot;
    void *ctx;
} PLUGIN_CTX;

typedef struct _plugin {
    void *handle;
    void *ctx;

    QUEUE *queue;

    struct _plugin *prev, *next;
} PLUGIN;

typedef struct _intellibot {
    PLUGIN *plugins;
    SERVER *servers;
} INTELLIBOT;

#endif

#if !defined(_INTELLIBOT_H)
#define _INTELLIBOT_H

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

#include "queue.h"
#include "sock.h"

struct _intellibot;
struct _server;
struct _plugin;
struct _plugin_ctx;
struct _queue;

#define SOCK_FLAG_DISCONNECTED 0
#define SOCK_FLAG_CONNECTED 1
#define SOCK_FLAG_REGISTERED 2

typedef struct _server {
    SOCK *sock;

    struct _server *prev, *next;
} SERVER;

typedef struct _plugin_ctx {
    struct _plugin *plugin;
    struct _intellibot *bot;
    void *ctx;
} PLUGIN_CTX;

#define SUBSCRIPTION_JOIN       0x00000001
#define SUBSCRIPTION_PART       0x00000002
#define SUBSCRIPTION_CONNECT    0x00000004
#define SUBSCRIPTION_DISCONNECT 0x00000008
#define SUBSCRIPTION_PRIVMSG    0x00000010

typedef struct _plugin {
    pthread_t tid;
    void *handle;
    void *ctx;
    unsigned int subscriptions;

    QUEUE *queue;
    int (*run)(struct _plugin *, char *);

    struct _plugin *prev, *next;
} PLUGIN;

typedef struct _intellibot {
    PLUGIN *plugins;
    SERVER *servers;
} INTELLIBOT;

#endif

Add fields to the plugin struct

Add fields to the plugin struct


#include "sim-hab.h"
#include <stdlib.h>

int poll_arduino()
{
    char response[256];
    uint32_t content;
    bionet_resource_t *res;
    bionet_node_t *node;

    node = bionet_hab_get_node_by_index(hab, 0);

    // send command 100. requests analog0's value
    // read value and set resource
    arduino_write(100);
    arduino_read_until(response, '\n');
    content = atoi(response);
    res = bionet_node_get_resource_by_index(node, 24);
    bionet_resource_set_uint32(res, content, NULL);

    // send command 101. requests analog1's value
    // read value and set resource
    arduino_write(101);
    arduino_read_until(response, '\n');
    content = atoi(response);
    res = bionet_node_get_resource_by_index(node, 25);
    bionet_resource_set_uint32(res, content, NULL);

    // testing
    arduino_write(200);
    arduino_read_until(response, '\n');
    content = atoi(response);
    printf("digital 0: %d\n", content);

    // report new data
    hab_report_datapoints(node);

    return 1;
}

#include "sim-hab.h"
#include <stdlib.h>

int poll_arduino()
{
    char response[256];
    uint32_t content;
    bionet_resource_t *res;
    bionet_node_t *node;

    node = bionet_hab_get_node_by_index(hab, 0);

    // send command 100. requests analog0's value
    // read value and set resource
    arduino_write(100);
    arduino_read_until(response, '\n');
    content = atoi(response);
    res = bionet_node_get_resource_by_index(node, 24);
    bionet_resource_set_uint32(res, content, NULL);

    // send command 101. requests analog1's value
    // read value and set resource
    arduino_write(101);
    arduino_read_until(response, '\n');
    content = atoi(response);
    res = bionet_node_get_resource_by_index(node, 25);
    bionet_resource_set_uint32(res, content, NULL);

    // send command 200. requests the 8 digital values
    // read values and set resource
    arduino_write(200);
    arduino_read_until(response, '\n');
    for(int i=0; i<8; i++)
    {
        content = atoi(&response[i]);
        res = bionet_node_get_resource_by_index(node, 16+i);
        bionet_resource_set_binary(res, content, NULL);
    }

    // report new data
    hab_report_datapoints(node);

    return 1;
}

Modify sim-hab so that the digital inputs are accounted for.


// Copyright (c) 2006-2009 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 NET_SOCKET_SSL_CLIENT_SOCKET_H_
#define NET_SOCKET_SSL_CLIENT_SOCKET_H_

#include "net/socket/client_socket.h"

namespace net {

class SSLCertRequestInfo;
class SSLInfo;

// A client socket that uses SSL as the transport layer.
//
// NOTE: The SSL handshake occurs within the Connect method after a TCP
// connection is established.  If a SSL error occurs during the handshake,
// Connect will fail.
//
class SSLClientSocket : public ClientSocket {
 public:
  // Gets the SSL connection information of the socket.
  virtual void GetSSLInfo(SSLInfo* ssl_info) = 0;

  // Gets the SSL CertificateRequest info of the socket after Connect failed
  // with ERR_SSL_CLIENT_AUTH_CERT_NEEDED.
  virtual void GetSSLCertRequestInfo(
      SSLCertRequestInfo* cert_request_info) = 0;
};

}  // namespace net

#endif  // NET_SOCKET_SSL_CLIENT_SOCKET_H_

// Copyright (c) 2006-2009 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 NET_SOCKET_SSL_CLIENT_SOCKET_H_
#define NET_SOCKET_SSL_CLIENT_SOCKET_H_

#include "net/socket/client_socket.h"

namespace net {

class SSLCertRequestInfo;
class SSLInfo;

// A client socket that uses SSL as the transport layer.
//
// NOTE: The SSL handshake occurs within the Connect method after a TCP
// connection is established.  If a SSL error occurs during the handshake,
// Connect will fail.
//
class SSLClientSocket : public ClientSocket {
 public:
  // Next Protocol Negotiation (NPN), if successful, results in agreement on an
  // application-level string that specifies the application level protocol to
  // use over the TLS connection. NextProto enumerates the application level
  // protocols that we recognise.
  enum NextProto {
    kProtoUnknown = 0,
    kProtoHTTP11 = 1,
    kProtoSPDY = 2,
  };

  // Gets the SSL connection information of the socket.
  virtual void GetSSLInfo(SSLInfo* ssl_info) = 0;

  // Gets the SSL CertificateRequest info of the socket after Connect failed
  // with ERR_SSL_CLIENT_AUTH_CERT_NEEDED.
  virtual void GetSSLCertRequestInfo(
      SSLCertRequestInfo* cert_request_info) = 0;

  static NextProto NextProtoFromString(const std::string& proto_string) {
    if (proto_string == "http1.1") {
      return kProtoHTTP11;
    } else if (proto_string == "spdy") {
      return kProtoSPDY;
    } else {
      return kProtoUnknown;
    }
  }
};

}  // namespace net

#endif  // NET_SOCKET_SSL_CLIENT_SOCKET_H_

Add static function to convert NPN strings to an enum.

http://codereview.chromium.org/487012

git-svn-id: http://src.chromium.org/svn/trunk/src@34287 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

Former-commit-id: 2a63eef748fa1910eddb0b772eb24344e6705fdc


//  SDLAbstractProtocol.h
//

@class SDLAbstractTransport;
@class SDLRPCMessage;
@class SDLRPCRequest;

#import "SDLProtocolListener.h"
#import "SDLTransportDelegate.h"

@interface SDLAbstractProtocol : NSObject <SDLTransportDelegate>

@property (strong) NSString *debugConsoleGroupName;
@property (weak) SDLAbstractTransport *transport;
@property (weak) NSHashTable *protocolDelegateTable; // table of id<SDLProtocolListener>

// Sending
- (void)sendStartSessionWithType:(SDLServiceType)serviceType;
- (void)sendEndSessionWithType:(SDLServiceType)serviceType;
- (void)sendRPC:(SDLRPCMessage *)message;
- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest __deprecated_msg(("Use sendRPC: instead"));
- (void)sendHeartbeat;
- (void)sendRawDataStream:(NSInputStream *)inputStream withServiceType:(SDLServiceType)serviceType;
- (void)sendRawData:(NSData *)data withServiceType:(SDLServiceType)serviceType;

// Recieving
- (void)handleBytesFromTransport:(NSData *)receivedData;
- (void)dispose;

@end

//  SDLAbstractProtocol.h
//

@class SDLAbstractTransport;
@class SDLRPCMessage;
@class SDLRPCRequest;

#import "SDLProtocolListener.h"
#import "SDLTransportDelegate.h"

@interface SDLAbstractProtocol : NSObject <SDLTransportDelegate>

@property (strong) NSString *debugConsoleGroupName;
@property (weak) SDLAbstractTransport *transport;
@property (strong) NSHashTable *protocolDelegateTable; // table of id<SDLProtocolListener>

// Sending
- (void)sendStartSessionWithType:(SDLServiceType)serviceType;
- (void)sendEndSessionWithType:(SDLServiceType)serviceType;
- (void)sendRPC:(SDLRPCMessage *)message;
- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest __deprecated_msg(("Use sendRPC: instead"));
- (void)sendHeartbeat;
- (void)sendRawDataStream:(NSInputStream *)inputStream withServiceType:(SDLServiceType)serviceType;
- (void)sendRawData:(NSData *)data withServiceType:(SDLServiceType)serviceType;

// Recieving
- (void)handleBytesFromTransport:(NSData *)receivedData;
- (void)dispose;

@end

Fix SDLProtocol delegate table being released too early


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

int gcd(int a, int b) {
    int32_t x;

    while (b > 0) {
        x = b;
        b = a % b;
        a = x;
    }

    return a;
}

int main() {
    int32_t n, a, b;

    scanf("%d", &n);

    while (n--) {
        scanf("%d %d", &a, &b);

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

    return 0;
}

Solve Collectable Cards in c

Solve Collectable Cards in c


#ifdef __WIN32__
#include <windows.h>

int wmain(int argc, wchar_t **argv)
{
    char* sep = "";
    int len;

    /*
     * Echo all arguments separated with '::', so that we can check that
     * quotes are interpreted correctly.
     */

    while (argc-- > 1) {
	char *utf8;
	len = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
	utf8 = malloc(len*sizeof(char));
	WideCharToMultiByte(CP_UTF8, 0, argv++[1], -1, utf8, len, NULL, NULL);
	printf("%s%s", sep, utf8);
	free(utf8);
	sep = "::";
    }
    putchar('\n');
    return 0;
}
#else

#include <stdio.h>

int
main(int argc, char** argv)
{
    char* sep = "";

    /*
     * Echo all arguments separated with '::', so that we can check that
     * quotes are interpreted correctly.
     */

    while (argc-- > 1) {
	printf("%s%s", sep, argv++[1]);
	sep = "::";
    }
    putchar('\n');
    return 0;
}
#endif

#include <stdio.h>
#ifdef __WIN32__
#include <windows.h>

int wmain(int argc, wchar_t **argv)
{
    char* sep = "";
    int len;

    /*
     * Echo all arguments separated with '::', so that we can check that
     * quotes are interpreted correctly.
     */

    while (argc-- > 1) {
	char *utf8;
	len = WideCharToMultiByte(CP_UTF8, 0, argv[1], -1, NULL, 0, NULL, NULL);
	utf8 = malloc(len*sizeof(char));
	WideCharToMultiByte(CP_UTF8, 0, argv++[1], -1, utf8, len, NULL, NULL);
	printf("%s%s", sep, utf8);
	free(utf8);
	sep = "::";
    }
    putchar('\n');
    return 0;
}
#else

int
main(int argc, char** argv)
{
    char* sep = "";

    /*
     * Echo all arguments separated with '::', so that we can check that
     * quotes are interpreted correctly.
     */

    while (argc-- > 1) {
	printf("%s%s", sep, argv++[1]);
	sep = "::";
    }
    putchar('\n');
    return 0;
}
#endif

Fix os_SUITE compilation issue on win32

kernel: Fix os_SUITE compilation issue on win32


#ifndef SSPAPPLICATION_COMPONENTHANDLER_H
#define SSPAPPLICATION_COMPONENTHANDLER_H

#include "../GraphicsDLL/GraphicsHandler.h"
//#include "ComponentStructs.h"
#include "../GraphicsDLL/GraphicsHandler.h"
#include "../physicsDLL/PhysicsHandler.h"
#include "../AIDLL/AIHandler.h"

class ComponentHandler
{
private:
	GraphicsHandler* m_graphicsHandler;
	PhysicsHandler* m_physicsHandler;
	AIHandler* m_aiHandler;
public:
	ComponentHandler();
	~ComponentHandler();

	//Returns 0 if the graphicsHandler or physicshandler is a nullptr
	int Initialize(GraphicsHandler* graphicsHandler, PhysicsHandler* physicsHandler, AIHandler* aiHandler);

	GraphicsComponent* GetGraphicsComponent();
	PhysicsComponent* GetPhysicsComponent();
	void UpdateGraphicsComponents();
	void SetGraphicsComponentListSize(int gCompSize);

	//temporary function
	PhysicsHandler* GetPhysicsHandler() const;
};

#endif

#ifndef SSPAPPLICATION_COMPONENTHANDLER_H
#define SSPAPPLICATION_COMPONENTHANDLER_H

//#include "ComponentStructs.h"
#include "../GraphicsDLL/GraphicsHandler.h"
#include "../physicsDLL/PhysicsHandler.h"
#include "../AIDLL/AIHandler.h"

class ComponentHandler
{
private:
	GraphicsHandler* m_graphicsHandler;
	PhysicsHandler* m_physicsHandler;
	AIHandler* m_aiHandler;
public:
	ComponentHandler();
	~ComponentHandler();

	//Returns 0 if the graphicsHandler or physicshandler is a nullptr
	int Initialize(GraphicsHandler* graphicsHandler, PhysicsHandler* physicsHandler, AIHandler* aiHandler);

	GraphicsComponent* GetGraphicsComponent();
	PhysicsComponent* GetPhysicsComponent();
	void UpdateGraphicsComponents();
	void SetGraphicsComponentListSize(int gCompSize);

	//temporary function
	PhysicsHandler* GetPhysicsHandler() const;
};

#endif

FIX duplicate includes of GraphicsHandler


/**
 * \file   string_hash.c
 * \brief  Computes a hash value for a string.
 * \author Copyright (c) 2012-2014 Jason Perkins and the Premake project
 */

#include "premake.h"
#include <string.h>

int string_hash(lua_State* L)
{
	const char* str = luaL_checkstring(L, 1);
	unsigned long seed = luaL_optint(L, 2, 0);
	lua_pushnumber(L, do_hash(str, seed));
	return 1;
}

unsigned long do_hash(const char* str, int seed)
{
	/* DJB2 hashing; see http://www.cse.yorku.ca/~oz/hash.html */

	unsigned long hash = 5381;

	if (seed != 0) {
		hash = hash * 33 + seed;
	}

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

	return hash;
}

/**
 * \file   string_hash.c
 * \brief  Computes a hash value for a string.
 * \author Copyright (c) 2012-2014 Jason Perkins and the Premake project
 */

#include "premake.h"
#include <string.h>

int string_hash(lua_State* L)
{
	const char* str = luaL_checkstring(L, 1);
	unsigned long seed = luaL_optint(L, 2, 0);
	lua_pushnumber(L, (lua_Number)do_hash(str, seed));
	return 1;
}

unsigned long do_hash(const char* str, int seed)
{
	/* DJB2 hashing; see http://www.cse.yorku.ca/~oz/hash.html */

	unsigned long hash = 5381;

	if (seed != 0) {
		hash = hash * 33 + seed;
	}

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

	return hash;
}

Fix implicit conversion warning when building with floating point Lua


// RUN: clang -verify %s
//
// This example was reduced from actual code in Wine 1.1.13.  GCC accepts this
// code, while the correct behavior is to reject it.
//

typedef struct _IRP {
  union {
    struct {
      union {} u; // expected-note{{previous declaration is here}}
      struct {
        union {} u; // expected-error{{error: member of anonymous struct redeclares 'u'}}
      };
    } Overlay;
  } Tail;
} IRP;

Add test case for PR 3675.

Add test case for PR 3675.

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


// RUN: clang -ccc-host-triple armv6-unknown-unknown -emit-llvm -S -o %t %s

void test0(void) {
	asm volatile("mov r0, r0" :: );
}
void test1(void) {
	asm volatile("mov r0, r0" :::
				 "cc", "memory" );
}
void test2(void) {
	asm volatile("mov r0, r0" :::
				 "r0", "r1", "r2", "r3");
	asm volatile("mov r0, r0" :::
				 "r4", "r5", "r6", "r8");
}
void test3(void) {
	asm volatile("mov r0, r0" :::
				 "a1", "a2", "a3", "a4");
	asm volatile("mov r0, r0" :::
				 "v1", "v2", "v3", "v5");
}

// RUN: clang-cc -triple armv6-unknown-unknown -emit-llvm -o %t %s

void test0(void) {
	asm volatile("mov r0, r0" :: );
}
void test1(void) {
	asm volatile("mov r0, r0" :::
				 "cc", "memory" );
}
void test2(void) {
	asm volatile("mov r0, r0" :::
				 "r0", "r1", "r2", "r3");
	asm volatile("mov r0, r0" :::
				 "r4", "r5", "r6", "r8");
}
void test3(void) {
	asm volatile("mov r0, r0" :::
				 "a1", "a2", "a3", "a4");
	asm volatile("mov r0, r0" :::
				 "v1", "v2", "v3", "v5");
}

Use clang-cc in this test.

Use clang-cc in this test.

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


// RUN: %clang_cc1 -emit-llvm -o - %s

// PR4610
#pragma pack(4)
struct ref {
        struct ref *next;
} refs;

// RUN: %clang_cc1 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s

// PR4610
#pragma pack(4)
struct ref {
        struct ref *next;
} refs;

// PR13580
struct S
{
  char a[3];
#pragma pack(1)
  struct T
  {
    char b;
    int c;
  } d;
#pragma pack()
  struct T2
  {
    char b;
    int c;
  } d2;
} ss;

// CHECK: [[struct_ref:%[a-zA-Z0-9_.]+]] = type <{ [[struct_ref]]* }>
// CHECK: [[struct_S:%[a-zA-Z0-9_.]+]] = type { [3 x i8], [[struct_T:%[a-zA-Z0-9_.]+]], [[struct_T2:%[a-zA-Z0-9_.]+]] }
// CHECK: [[struct_T]] = type <{ i8, i32 }>
// CHECK: [[struct_T2]] = type { i8, i32 }

// CHECK: @refs = common global [[struct_ref]]
// CHECK: @ss = common global [[struct_S]]

Add IRGen test case for r179743.

Add IRGen test case for r179743.

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


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

#if ODP_VERSION < 105
typedef uint64_t odp_time_t;
#endif /* ODP_VERSION < 105 */

#if ODP_VERSION < 104 && ODP_VERSION > 101
#define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_def_worker(cpumask, num_workers)
#elif ODP_VERSION < 102
#define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_count(cpumask)
#endif

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

#if ODP_VERSION < 105
typedef uint64_t odp_time_t;
#endif /* ODP_VERSION < 105 */

#if ODP_VERSION < 104 && ODP_VERSION > 101
#define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_def_worker(cpumask, num_workers)
#elif ODP_VERSION < 102
#define odp_cpumask_default_worker(cpumask, num_workers) odp_cpumask_count(cpumask)
#define ODP_THREAD_WORKER
#define ODP_THREAD_CONTROL
#endif

Define ODP_THREAD_WORKER and ODP_THREAD_CONTROL for odp versions < 102.

Signed-off-by: José Pekkarinen <d7cb8761fb0e75b1a78c2fda4f1daed76cd46cfe@nokia.com>
Reviewed-and-tested-by: Sorin Vultureanu <8013ba55f8675034bc2ab0d6c3a1c9650437ca36@enea.com>


#pragma once

template <typename T>
class Vector3 {
public:
	T x, y, z;

	Vector3(T x, T y, T z)
	{
		this->x = x;
		this->y = y;
		this->z = z;
	}

	Vector3() : Vector3(0, 0, 0)
	{
	}

	T &operator[](unsigned i)
	{
		return (&x)[i];
	}
};

static_assert(sizeof(Vector3<float>) == 12);

template <typename T>
class Vector4 {
public:
	T x, y, z, w;

	Vector4() {}

	Vector4(T x, T y, T z, T w)
	{
		this->x = x;
		this->y = y;
		this->z = z;
		this->w = w;
	}

	T &operator[](unsigned i)
	{
		return (&x)[i];
	}
};

#pragma once

template <typename T>
class Vector3 {
public:
	T x, y, z;

	Vector3(T x, T y, T z)
	{
		this->x = x;
		this->y = y;
		this->z = z;
	}

	Vector3() : Vector3(0, 0, 0)
	{
	}

	T &operator[](unsigned i)
	{
		return (&x)[i];
	}

	bool operator==(const Vector3 &v) const
	{
		return x == v.x && y == v.y && z == v.z;
	}
};

static_assert(sizeof(Vector3<float>) == 12);

template <typename T>
class Vector4 {
public:
	T x, y, z, w;

	Vector4() {}

	Vector4(T x, T y, T z, T w)
	{
		this->x = x;
		this->y = y;
		this->z = z;
		this->w = w;
	}

	T &operator[](unsigned i)
	{
		return (&x)[i];
	}
};

Add "equal to" operator to Vector3

Add "equal to" operator to Vector3


#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <sched.h>
#include <stdlib.h>

#define CHILD_STACK_SIZE 16384

int variable;

int do_something() {
   printf("Running...\n");
   variable = 1337;
   _exit(0);
}

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

   child_stack = malloc(CHILD_STACK_SIZE);
   child_stack_top = child_stack + CHILD_STACK_SIZE;

   variable = 42;
   printf("The variable was %d\n", variable);

   clone(do_something, child_stack_top, CLONE_THREAD, NULL);
   sleep(10);

   printf("The variable is now %d\n", variable);
   return 0;
}

Add test of clone syscall with CLONE_THREAD


//
//  SMRPreprocessor.h
//  MicroReasoner
//
//  Created by Ivano Bilenchi on 05/05/16.
//  Copyright © 2016 SisInf Lab. All rights reserved.
//

#ifndef SMRPreprocessor_h
#define SMRPreprocessor_h

// Pseudo-abstract class convenience macros.

#define ABSTRACT_METHOD {\
@throw [NSException exceptionWithName:NSInternalInconsistencyException \
reason:@"This method should be overridden in a subclass." \
userInfo:nil]; \
}

#endif /* SMRPreprocessor_h */

//
//  SMRPreprocessor.h
//  MicroReasoner
//
//  Created by Ivano Bilenchi on 05/05/16.
//  Copyright © 2016 SisInf Lab. All rights reserved.
//

#ifndef SMRPreprocessor_h
#define SMRPreprocessor_h

/**
 * Use this directive to mark method implementations that should be overridden
 * by concrete subclasses.
 */
#define ABSTRACT_METHOD {\
@throw [NSException exceptionWithName:NSInternalInconsistencyException \
reason:@"This method should be overridden in a subclass." \
userInfo:nil]; \
}

/**
 * Use this directive in place of @synthesize to automatically create a
 * lazy getter for the specified property. Example syntax:
 *
 * SYNTHESIZE_LAZY(NSMutableString, myMutableString) {
 *     return [NSMutableString stringWithString:@"my mutable string"];
 * }
 *
 * @param type The type of the property.
 * @param name The name of the property.
 */
#define SYNTHESIZE_LAZY(type, name) \
@synthesize name = _##name; \
- (type *)name { \
if (_##name == nil) { _##name = [self __##name##LazyInit]; } \
return _##name; \
} \
- (type *)__##name##LazyInit

/**
 * Use this directive in place of @synthesize to automatically create a
 * lazy getter for the specified property. The getter calls the default
 * 'init' constructor.
 *
 * @param type The type of the property.
 * @param name The name of the property.
 */
#define SYNTHESIZE_LAZY_INIT(type, name) \
@synthesize name = _##name; \
- (type *)name { \
if (_##name == nil) { _##name = [[type alloc] init]; } \
return _##name; \
}

#endif /* SMRPreprocessor_h */

Add lazy property synthesis directives

Add lazy property synthesis directives


// RUN: %clang_cc1 -analyze -analyzer-checker=unix,core,experimental.security.taint -w -verify %s

// Make sure we don't crash when someone redefines a system function we reason about.

char memmove ();
char malloc();
char system();
char stdin();
char memccpy();
char free();
char strdup();
char atoi();

int foo () {
  return memmove() + malloc() + system + stdin() + memccpy() + free() + strdup() + atoi();

}

[analyzer] Test case for r154451 (redefining system functions).

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


#pragma once

#include <Windows.h>
#include <unordered_map>

#include "../Controls/Control.h"
#include "../Controls/Controls.h"

class UIContext;

#define INIT_CONTROL(ctrlId, ctrlType, var) { \
    var = ctrlType(ctrlId, _hWnd); \
    _controlMap[ctrlId] = &var; \
}

///
/// Abstract class that encapsulates functionality for dealing with
/// property sheet pages (tabs).
///
class Tab {
public:
    Tab();
    ~Tab();

    /// Processes messages sent to the tab page.
    virtual DLGPROC TabProc(
        HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

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

protected:
    /// Window handle of this tab.
    HWND _hWnd;

    /// Maps control IDs to their respective instances.
    std::unordered_map<int, Control *> _controlMap;

    ///
    /// 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 <Windows.h>
#include <unordered_map>

#include "../Controls/Control.h"
#include "../Controls/Controls.h"

#define INIT_CONTROL(ctrlId, ctrlType, var) { \
    var = ctrlType(ctrlId, _hWnd); \
    _controlMap[ctrlId] = &var; \
}

///
/// Abstract class that encapsulates functionality for dealing with
/// property sheet pages (tabs).
///
class Tab {
public:
    Tab();
    ~Tab();

    /// Processes messages sent to the tab page.
    virtual DLGPROC TabProc(
        HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);

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

protected:
    /// Window handle of this tab.
    HWND _hWnd;

    /// Maps control IDs to their respective instances.
    std::unordered_map<int, Control *> _controlMap;

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

Remove old UIContext class declaration

Remove old UIContext class declaration


#pragma once

#include "jwt.h"

#include <ostream>

namespace JWTXX
{

std::ostream& operator<<(std::ostream& stream, const Algorithm& alg)
{
    stream << algToString(alg);
    return stream;
}

}

Add separate header for stream operators.


#ifndef _OBJC_MESSAGE_H_
#define _OBJC_MESSAGE_H_

#if defined(__x86_64) || defined(__i386) || defined(__arm__) || \
	defined(__mips_n64) || defined(__mips_n32)
/**
 * Standard message sending function.  This function must be cast to the
 * correct types for the function before use.  The first argument is the
 * receiver and the second the selector.
 *
 * Note that this function is not available on all architectures.  For a more
 * portable solution to sending arbitrary messages, consider using
 * objc_msg_lookup_sender() and then calling the returned IMP directly.
 *
 * This version of the function is used for all messages that return either an
 * integer, a pointer, or a small structure value that is returned in
 * registers.  Be aware that calling conventions differ between operating
 * systems even within the same architecture, so take great care if using this
 * function for small (two integer) structures.
 */
id objc_msgSend(id self, SEL _cmd, ...);
/**
 * Standard message sending function.  This function must be cast to the
 * correct types for the function before use.  The first argument is the
 * receiver and the second the selector.
 *
 * Note that this function is not available on all architectures.  For a more
 * portable solution to sending arbitrary messages, consider using
 * objc_msg_lookup_sender() and then calling the returned IMP directly.
 *
 * This version of the function is used for all messages that return a
 * structure that is not returned in registers.  Be aware that calling
 * conventions differ between operating systems even within the same
 * architecture, so take great care if using this function for small (two
 * integer) structures.
 */
#ifdef __cplusplus
id objc_msgSend_stret(id self, SEL _cmd, ...);
#else
void objc_msgSend_stret(id self, SEL _cmd, ...);
#endif
/**
 * Standard message sending function.  This function must be cast to the
 * correct types for the function before use.  The first argument is the
 * receiver and the second the selector.
 *
 * Note that this function is not available on all architectures.  For a more
 * portable solution to sending arbitrary messages, consider using
 * objc_msg_lookup_sender() and then calling the returned IMP directly.
 *
 * This version of the function is used for all messages that return floating
 * point values.
 */
long double objc_msgSend_fpret(id self, SEL _cmd, ...);

#endif

#endif //_OBJC_MESSAGE_H_

Fix clang's stupid warning to work around a bug in OS X headers...

git-svn-id: a68838e7bd575144b7122a20f5a950e65beaf589@35962 72102866-910b-0410-8b05-ffd578937521


#include <wlr/backend/multi.h>
#include <wlr/backend/wayland.h>
#include <wlr/backend/x11.h>
#include "sway/commands.h"
#include "sway/server.h"
#include "log.h"

static void create_output(struct wlr_backend *backend, void *data) {
	bool *done = data;
	if (*done) {
		return;
	}

	if (wlr_backend_is_wl(backend)) {
		wlr_wl_output_create(backend);
		*done = true;
	} else if (wlr_backend_is_x11(backend)) {
		wlr_x11_output_create(backend);
		*done = true;
	}
}

/**
 * This command is intended for developer use only.
 */
struct cmd_results *cmd_create_output(int argc, char **argv) {
	sway_assert(wlr_backend_is_multi(server.backend),
			"Expected a multi backend");

	bool done = false;
	wlr_multi_for_each_backend(server.backend, create_output, &done);

	if (!done) {
		return cmd_results_new(CMD_INVALID, "create_output",
				"Can only create outputs for Wayland or X11 backends");
	}

	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}

#include <wlr/config.h>
#include <wlr/backend/multi.h>
#include <wlr/backend/wayland.h>
#ifdef WLR_HAS_X11_BACKEND
#include <wlr/backend/x11.h>
#endif
#include "sway/commands.h"
#include "sway/server.h"
#include "log.h"

static void create_output(struct wlr_backend *backend, void *data) {
	bool *done = data;
	if (*done) {
		return;
	}

	if (wlr_backend_is_wl(backend)) {
		wlr_wl_output_create(backend);
		*done = true;
	}
#ifdef WLR_HAS_X11_BACKEND
	else if (wlr_backend_is_x11(backend)) {
		wlr_x11_output_create(backend);
		*done = true;
	}
#endif
}

/**
 * This command is intended for developer use only.
 */
struct cmd_results *cmd_create_output(int argc, char **argv) {
	sway_assert(wlr_backend_is_multi(server.backend),
			"Expected a multi backend");

	bool done = false;
	wlr_multi_for_each_backend(server.backend, create_output, &done);

	if (!done) {
		return cmd_results_new(CMD_INVALID, "create_output",
				"Can only create outputs for Wayland or X11 backends");
	}

	return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}

Fix compilation against wlroots without X11 backend


#ifndef HELPER_H
#define HELPER_H

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

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

//Helper function for calculating contraints of a float
float constrain(float x, float lowerBound, float upperBound){
	if(x<lowerBound){
		return lowerBound;
	}else if(x>upperBound){
		return upperBound;
	}else{
		return x;
	}
}

#endif

#ifndef HELPER_H
#define HELPER_H
#pragma systemFile

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

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

//Helper function for calculating contraints of a float
float constrain(float x, float lowerBound, float upperBound){
	if(x<lowerBound){
		return lowerBound;
	}else if(x>upperBound){
		return upperBound;
	}else{
		return x;
	}
}

#endif

Add systemFile declaration to helper library


/** @file
  The file contain all library function for Ifr Operations.

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

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

**/

#ifndef _IFRLIBRARY_INTERNAL_H_
#define _IFRLIBRARY_INTERNAL_H_

#include <Uefi.h>

#include <Guid/GlobalVariable.h>
#include <Protocol/DevicePath.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiString.h>

#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/IfrSupportLib.h>
#include <Library/PcdLib.h>

#include <MdeModuleHii.h>

extern EFI_GUID mIfrVendorGuid;

#endif

/** @file
  The file contain all library function for Ifr Operations.

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

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

**/

#ifndef _IFRLIBRARY_INTERNAL_H_
#define _IFRLIBRARY_INTERNAL_H_

#include <Uefi.h>

#include <Protocol/DevicePath.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiString.h>

#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/BaseLib.h>
#include <Library/DevicePathLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/IfrSupportLib.h>
#include <Library/PcdLib.h>

#include <MdeModuleHii.h>

extern EFI_GUID mIfrVendorGuid;

#endif

Remove over specific header file.

Remove over specific header file.

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


// Start of tuning.h.

static char* load_tuning_file(const char *fname,
                              void *cfg,
                              int (*set_size)(void*, const char*, size_t)) {
  const int max_line_len = 1024;
  char* line = (char*) malloc(max_line_len);

  FILE *f = fopen(fname, "r");

  if (f == NULL) {
    snprintf(line, max_line_len, "Cannot open file: %s", strerror(errno));
    return line;
  }

  int lineno = 0;
  while (fgets(line, max_line_len, f) != NULL) {
    lineno++;
    char *eql = strstr(line, "=");
    if (eql) {
      *eql = 0;
      int value = atoi(eql+1);
      if (set_size(cfg, line, value) != 0) {
        strncpy(eql+1, line, max_line_len-strlen(line)-1);
        snprintf(line, max_line_len, "Unknown name '%s' on line %d.", eql+1, lineno);
        return line;
      }
    } else {
      snprintf(line, max_line_len, "Invalid line %d (must be of form 'name=int').",
               lineno);
      return line;
    }
  }

  free(line);

  return NULL;
}

// End of tuning.h.

// Start of tuning.h.

static char* load_tuning_file(const char *fname,
                              void *cfg,
                              int (*set_size)(void*, const char*, size_t)) {
  const int max_line_len = 1024;
  char* line = (char*) malloc(max_line_len);

  FILE *f = fopen(fname, "r");

  if (f == NULL) {
    snprintf(line, max_line_len, "Cannot open file: %s", strerror(errno));
    return line;
  }

  int lineno = 0;
  while (fgets(line, max_line_len, f) != NULL) {
    lineno++;
    char *eql = strstr(line, "=");
    if (eql) {
      *eql = 0;
      int value = atoi(eql+1);
      if (set_size(cfg, line, value) != 0) {
        char* err = (char*) malloc(max_line_len + 50);
        snprintf(err, max_line_len + 50, "Unknown name '%s' on line %d.", line, lineno);
        free(line);
        return err;
      }
    } else {
      snprintf(line, max_line_len, "Invalid line %d (must be of form 'name=int').",
               lineno);
      return line;
    }
  }

  free(line);

  return NULL;
}

// End of tuning.h.

Fix error for short names

Fix error for short names


// +build cortexm3 cortexm4 cortexm4f

static inline
uint bits$leadingZeros32(uint32 u) {
	uint n;
	asm volatile ("clz %0, %1" : "=r" (n) : "r" (u));
	return n;
}

static inline
uint bits$leadingZerosPtr(uintptr u) {
	uint n;
	asm volatile ("clz %0, %1" : "=r" (n) : "r" (u));
	return n;
}

static inline
uint bits$leadingZeros64(uint64 u) {
	uint n;
	asm volatile (
		"clz %0, %R1\n\t"
		"cmp %0, 32\n\t"
		"itt eq\n\t"
		"clzeq %0, %Q1\n\t"
		"addeq %0, 32\n\t"
		: "=&r" (n)
		: "r" (u)
		: "cc"
	);
	return n;
}

// +build cortexm3 cortexm4 cortexm4f

uint
bits$leadingZeros32(uint32 u) {
	uint n;
	asm volatile ("clz %0, %1":"=r" (n):"r"(u));
	return n;
}

uint
bits$leadingZerosPtr(uintptr u) {
	uint n;
	asm volatile ("clz %0, %1":"=r" (n):"r"(u));
	return n;
}

uint
bits$leadingZeros64(uint64 u) {
	uint n;
	asm volatile ("clz %0, %R1\n\t"
		"cmp %0, 32\n\t"
		"itt eq\n\t"
		"clzeq %0, %Q1\n\t"
		"addeq %0, 32\n\t"
		:"=&r" (n)
		:"r"(u)
		:"cc");
	return n;
}

Remove "static inline" from C code.

bits: Remove "static inline" from C code.