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

const int image_width = 512;
const int image_height = 512;
const int image_size = 512*512;
const int color_depth = 255;

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

    if(argc != 3){
        printf("Useage: %s image n_threads\n", argv[0]);
        exit(-1);
    }
    int n_threads = atoi(argv[2]);

    unsigned char* image = read_bmp(argv[1]);
    unsigned char* output_image = malloc(sizeof(unsigned char) * image_size);

    int* histogram = (int*)calloc(sizeof(int), color_depth);
    for(int i = 0; i < image_size; i++){
        histogram[image[i]]++;
    }

    float* transfer_function = (float*)calloc(sizeof(float), color_depth);
    for(int i = 0; i < color_depth; i++){
        for(int j = 0; j < i+1; j++){
            transfer_function[i] += color_depth*((float)histogram[j])/(image_size);
        }
    }

    for(int i = 0; i < image_size; i++){
        output_image[i] = transfer_function[image[i]];
    }

    write_bmp(output_image, image_width, image_height);
}

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

const int image_width = 512;
const int image_height = 512;
const int image_size = 512*512;
const int color_depth = 255;

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

    if(argc != 3){
        printf("Useage: %s image n_threads\n", argv[0]);
        exit(-1);
    }
    int n_threads = atoi(argv[2]);

    unsigned char* image = read_bmp(argv[1]);
    unsigned char* output_image = malloc(sizeof(unsigned char) * image_size);

    int* histogram = (int*)calloc(sizeof(int), color_depth);
    #pragma omp parallel for
    for(int i = 0; i < image_size; i++){
        histogram[image[i]]++;
    }

    float* transfer_function = (float*)calloc(sizeof(float), color_depth);
    #pragma omp parallel for
    for(int i = 0; i < color_depth; i++){
        for(int j = 0; j < i+1; j++){
            transfer_function[i] += color_depth*((float)histogram[j])/(image_size);
        }
    }

    for(int i = 0; i < image_size; i++){
        output_image[i] = transfer_function[image[i]];
    }

    write_bmp(output_image, image_width, image_height);
}

Add paralellism with race conditions to omp


/******************************************************************************
 * Copyright (c) 2004, 2008 IBM Corporation
 * All rights reserved.
 * This program and the accompanying materials
 * are made available under the terms of the BSD License
 * which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/bsd-license.php
 *
 * Contributors:
 *     IBM Corporation - initial implementation
 *****************************************************************************/
#ifndef _TIME_H
#define _TIME_H

struct tm {
	int tm_sec;
	int tm_min;
	int tm_hour;
	int tm_mday;
	int tm_mon;
	int tm_year;

	/* unused in skiboot */
	int tm_wday;
	int tm_yday;
	int tm_isdst;
};

typedef long time_t;

struct timespec {
	time_t tv_sec;        /* seconds */
	long   tv_nsec;       /* nanoseconds */
};

struct tm *gmtime_r(const time_t *timep, struct tm *result);
time_t mktime(struct tm *tm);

/* Not implemented by libc but by hosting environment, however
 * this is where the prototype is expected
 */
int nanosleep(const struct timespec *req, struct timespec *rem);

#endif /* _TIME_H */

/******************************************************************************
 * Copyright (c) 2004, 2008 IBM Corporation
 * All rights reserved.
 * This program and the accompanying materials
 * are made available under the terms of the BSD License
 * which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/bsd-license.php
 *
 * Contributors:
 *     IBM Corporation - initial implementation
 *****************************************************************************/
#ifndef _TIME_H
#define _TIME_H

struct tm {
	int tm_sec;
	int tm_min;
	int tm_hour;
	int tm_mday;
	int tm_mon;
	int tm_year;
};

typedef long time_t;

struct timespec {
	time_t tv_sec;        /* seconds */
	long   tv_nsec;       /* nanoseconds */
};

struct tm *gmtime_r(const time_t *timep, struct tm *result);
time_t mktime(struct tm *tm);

/* Not implemented by libc but by hosting environment, however
 * this is where the prototype is expected
 */
int nanosleep(const struct timespec *req, struct timespec *rem);

#endif /* _TIME_H */

Remove unused struct tm elements

Remove unused struct tm elements

Better to error out than suddenly have places use uninitalized data.

Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>


#ifndef __AUDIO_TX_H__
#define __AUDIO_TX_H__

#include <stdint.h>

init_audio_tx(const char* outfile, int codec_id,
	      int sample_rate, int bit_rate, int payload_type);
int put_audio_samples_tx(int16_t* samples, int n_samples);
int finish_audio_tx();

#endif /* __AUDIO_TX_H__ */

#ifndef __AUDIO_TX_H__
#define __AUDIO_TX_H__

#include <stdint.h>

int init_audio_tx(const char* outfile, int codec_id,
	      int sample_rate, int bit_rate, int payload_type);
int put_audio_samples_tx(int16_t* samples, int n_samples);
int finish_audio_tx();

#endif /* __AUDIO_TX_H__ */

Add return type in definition of init_audio_tx function.


#pragma once

#include <memory>
#include <string>
#ifdef __cpp_lib_string_view
#include <string_view>
#endif

namespace oop
{

class Digest
{
 public:
  virtual ~Digest() {}
  virtual void update(const void* data, int len) = 0;
#ifdef __cpp_lib_string_view
  void update(std::string_view str) { update(str.data(), str.length());
#endif
  virtual std::string digest() = 0;
  virtual int length() const = 0;

  enum Type
  {
    SHA1 = 1,
    SHA256 = 2,
    MD5 = 5,
  };
  static std::unique_ptr<Digest> create(Type t);

 protected:
  Digest() {}

 private:
  Digest(const Digest&) = delete;
  void operator=(const Digest&) = delete;
};

}

#pragma once

#include <memory>
#include <string>
#ifdef __cpp_lib_string_view
#include <string_view>
#endif

namespace oop
{

class Digest
{
 public:
  virtual ~Digest() {}
  virtual void update(const void* data, int len) = 0;
#ifdef __cpp_lib_string_view
  void update(std::string_view str)
  {
    update(str.data(), str.length());
  }
#endif
  virtual std::string digest() = 0;
  virtual int length() const = 0;

  enum Type
  {
    SHA1 = 1,
    SHA256 = 2,
    MD5 = 5,
  };
  static std::unique_ptr<Digest> create(Type t);

 protected:
  Digest() {}

 private:
  Digest(const Digest&) = delete;
  void operator=(const Digest&) = delete;
};

}

Fix digest oop for C++17.

Fix digest oop for C++17.


// Copyright (c) 2017 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 QUICHE_QUIC_PLATFORM_API_QUIC_TEST_H_
#define QUICHE_QUIC_PLATFORM_API_QUIC_TEST_H_

#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/quic/platform/impl/quic_test_impl.h"

using QuicFlagSaver = QuicFlagSaverImpl;

// Defines the base classes to be used in QUIC tests.
using QuicTest = QuicTestImpl;
template <class T>
using QuicTestWithParam = QuicTestWithParamImpl<T>;

// Class which needs to be instantiated in tests which use threads.
using ScopedEnvironmentForThreads = ScopedEnvironmentForThreadsImpl;

#define QUIC_TEST_DISABLED_IN_CHROME(name) \
  QUIC_TEST_DISABLED_IN_CHROME_IMPL(name)

inline std::string QuicGetTestMemoryCachePath() {
  return QuicGetTestMemoryCachePathImpl();

#define EXPECT_QUIC_DEBUG_DEATH(condition, message) \
  EXPECT_QUIC_DEBUG_DEATH_IMPL(condition, message)
}

#define QUIC_SLOW_TEST(test) QUIC_SLOW_TEST_IMPL(test)

#endif  // QUICHE_QUIC_PLATFORM_API_QUIC_TEST_H_

// Copyright (c) 2017 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 QUICHE_QUIC_PLATFORM_API_QUIC_TEST_H_
#define QUICHE_QUIC_PLATFORM_API_QUIC_TEST_H_

#include "net/third_party/quiche/src/quic/platform/api/quic_logging.h"
#include "net/quic/platform/impl/quic_test_impl.h"

using QuicFlagSaver = QuicFlagSaverImpl;

// Defines the base classes to be used in QUIC tests.
using QuicTest = QuicTestImpl;
template <class T>
using QuicTestWithParam = QuicTestWithParamImpl<T>;

// Class which needs to be instantiated in tests which use threads.
using ScopedEnvironmentForThreads = ScopedEnvironmentForThreadsImpl;

#define QUIC_TEST_DISABLED_IN_CHROME(name) \
  QUIC_TEST_DISABLED_IN_CHROME_IMPL(name)

inline std::string QuicGetTestMemoryCachePath() {
  return QuicGetTestMemoryCachePathImpl();
}

#define EXPECT_QUIC_DEBUG_DEATH(condition, message) \
  EXPECT_QUIC_DEBUG_DEATH_IMPL(condition, message)

#define QUIC_SLOW_TEST(test) QUIC_SLOW_TEST_IMPL(test)

#endif  // QUICHE_QUIC_PLATFORM_API_QUIC_TEST_H_

Fix one curly brace placement in test code

gfe-relnote: n/a, test-only
PiperOrigin-RevId: 303203726
Change-Id: I26a7ad68cc83ecd85fe59c5af5998b318302c9a7


/**
 * rr_impl.c
 *
 * Implementation of functionality specific to round-robin scheduling.
 */

#include "rr_impl.h"

void rr_wake_worker(thread_info_t *info) {
  // TODO
}

void rr_wait_for_worker(sched_queue_t *queue) {
  // TODO
}

/**
 * rr_impl.c
 *
 * Implementation of functionality specific to round-robin scheduling.
 */

#include "rr_impl.h"

void rr_wake_worker(thread_info_t *info) {
  // TODO
}

void rr_wait(sched_queue_t *queue) {
  // TODO
}

Revert change to rr_wait name

Revert change to rr_wait name


/* Copyright (c) 2011 Google Inc.
 *
 * 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.
 */

//
//  GTLBatchQuery.h
//

#import "GTLQuery.h"

@interface GTLBatchQuery : NSObject <GTLQueryProtocol> {
 @private
  NSMutableArray *queries_;
  NSMutableDictionary *requestIDMap_;
  BOOL skipAuthorization_;
}

// Queries included in this batch.  Each query should have a unique requestID.
@property (retain) NSArray *queries;

// Clients may set this to NO to disallow authorization. Defaults to YES.
@property (assign) BOOL shouldSkipAuthorization;

+ (id)batchQuery;
+ (id)batchQueryWithQueries:(NSArray *)array;

- (void)addQuery:(GTLQuery *)query;

- (GTLQuery *)queryForRequestID:(NSString *)requestID;

@end

/* Copyright (c) 2011 Google Inc.
 *
 * 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.
 */

//
//  GTLBatchQuery.h
//

#import "GTLQuery.h"

@interface GTLBatchQuery : NSObject <GTLQueryProtocol> {
 @private
  NSMutableArray *queries_;
  NSMutableDictionary *requestIDMap_;
  BOOL skipAuthorization_;
}

// Queries included in this batch.  Each query should have a unique requestID.
@property (retain) NSArray *queries;

// Clients may set this to YES to disallow authorization. Defaults to NO.
@property (assign) BOOL shouldSkipAuthorization;

+ (id)batchQuery;
+ (id)batchQueryWithQueries:(NSArray *)array;

- (void)addQuery:(GTLQuery *)query;

- (GTLQuery *)queryForRequestID:(NSString *)requestID;

@end

Fix comment on shouldSkipAuthorization property


//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author:  Axel Naumann <axel@cern.ch>
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------

#ifndef CLING_CIFACTORY_H
#define CLING_CIFACTORY_H

#include "clang/Frontend/CompilerInstance.h"

#include "llvm/ADT/StringRef.h"

namespace llvm {
  class LLVMContext;
  class MemoryBuffer;
}

namespace clang {
  class DiagnosticsEngine;
}

namespace cling {
  class DeclCollector;
  class CIFactory {
  public:
    // TODO: Add overload that takes file not MemoryBuffer
    static clang::CompilerInstance* createCI(llvm::StringRef code,
                                             int argc,
                                             const char* const *argv,
                                             const char* llvmdir);

    static clang::CompilerInstance* createCI(llvm::MemoryBuffer* buffer,
                                             int argc,
                                             const char* const *argv,
                                             const char* llvmdir,
                                             DeclCollector* stateCollector);
  private:
    //---------------------------------------------------------------------
    //! Constructor
    //---------------------------------------------------------------------
    CIFactory() {}
    ~CIFactory() {}
    static void SetClingCustomLangOpts(clang::LangOptions& Opts);
    static void SetClingTargetLangOpts(clang::LangOptions& Opts,
                                       const clang::TargetInfo& Target);
  };
} // namespace cling
#endif // CLING_CIFACTORY_H

//--------------------------------------------------------------------*- C++ -*-
// CLING - the C++ LLVM-based InterpreterG :)
// author:  Axel Naumann <axel@cern.ch>
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------

#ifndef CLING_CIFACTORY_H
#define CLING_CIFACTORY_H

#include "clang/Frontend/CompilerInstance.h"

#include "llvm/ADT/StringRef.h"

namespace llvm {
  class LLVMContext;
  class MemoryBuffer;
}

namespace clang {
  class DiagnosticsEngine;
}

namespace cling {
  class DeclCollector;
  class CIFactory {
  public:
    // TODO: Add overload that takes file not MemoryBuffer
    static clang::CompilerInstance* createCI(llvm::StringRef code,
                                             int argc,
                                             const char* const *argv,
                                             const char* llvmdir);

    static clang::CompilerInstance* createCI(llvm::MemoryBuffer* buffer,
                                             int argc,
                                             const char* const *argv,
                                             const char* llvmdir,
                                             DeclCollector* stateCollector);
  private:
    //---------------------------------------------------------------------
    //! Constructor
    //---------------------------------------------------------------------
    CIFactory() = delete;
    ~CIFactory() = delete;
  };
} // namespace cling
#endif // CLING_CIFACTORY_H

Remove unneeded static member decls; mark c'tor, d'tor as deleted.


// PARAM: --set ana.activated[+] deadlock --enable sem.lock.fail
#include <pthread.h>
#include <stdio.h>

int g1, g2;
pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t mutex2 = PTHREAD_MUTEX_INITIALIZER;

void *t1(void *arg) {
  pthread_mutex_lock(&mutex1);
  pthread_mutex_lock(&mutex2); // DEADLOCK
  g1 = g2 + 1;
  pthread_mutex_unlock(&mutex2);
  pthread_mutex_unlock(&mutex1);
  return NULL;
}

void *t2(void *arg) {
  pthread_mutex_lock(&mutex2);
  pthread_mutex_lock(&mutex1); // DEADLOCK
  g2 = g1 + 1;
  pthread_mutex_unlock(&mutex1);
  pthread_mutex_unlock(&mutex2);
  return NULL;
}

int main(void) {
  pthread_t id1, id2;
  int i;
  for (i = 0; i < 10000; i++) {
    pthread_create(&id1, NULL, t1, NULL);
    pthread_create(&id2, NULL, t2, NULL);
    pthread_join (id1, NULL);
    pthread_join (id2, NULL);
    printf("%d: g1 = %d, g2 = %d.\n", i, g1, g2);
  }
  return 0;
}

Test mutexEvents based deadlock with failing locks


#import <Foundation/Foundation.h>

//! Project version number for Expecta.
FOUNDATION_EXPORT double ExpectaVersionNumber;

//! Project version string for Expecta.
FOUNDATION_EXPORT const unsigned char ExpectaVersionString[];

#import <Expecta/ExpectaObject.h>
#import <Expecta/ExpectaSupport.h>
#import <Expecta/EXPMatchers.h>

// Enable shorthand by default
#define expect(...) EXP_expect((__VA_ARGS__))
#define failure(...) EXP_failure((__VA_ARGS__))

Add newline to the end of the umbrella header


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

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

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

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (nonatomic, strong) UIWindow *window;

@end

Fix order of property attributes

Fix order of property attributes

Change-Id: I7a313d25a6707bada03328b0799300f07a26ba3b


#include <imageloader.h>

#include "context.h"

#include <stdio.h>
#include <stdarg.h>

void print_to_log(ImgloadContext ctx, ImgloadLogLevel level, const char* format, ...)
{
	if (!ctx->log.handler)
	{
		return;
	}

	if (level < ctx->log.minLevel)
	{
		return;
	}

	char buffer[1024];
	va_list args;
	va_start(args, format);
	vsnprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), format, args);

	ctx->log.handler(ctx->log.ud, level, buffer);

	va_end(args);
}

#include <imageloader.h>

#include "log.h"
#include "context.h"

#include <stdio.h>
#include <stdarg.h>

void print_to_log(ImgloadContext ctx, ImgloadLogLevel level, const char* format, ...)
{
	if (!ctx->log.handler)
	{
		return;
	}

	if (level < ctx->log.minLevel)
	{
		return;
	}

	char buffer[1024];
	va_list args;
	va_start(args, format);
	vsnprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), format, args);

	ctx->log.handler(ctx->log.ud, level, buffer);

	va_end(args);
}

Include the header in the source file

Include the header in the source file


#include <stdio.h>

#include "euler.h"

#define PROBLEM 7
#define ANSWER 104743

int
is_prime(int num)
{
    if(num < 2) {
        return 0;
    } else if(num == 2) {
        return 1;
    }

    for(int y = 2; y < num; y++) {
        if(num % y == 0) {
            return 0;
        }
    }
    return 1;
}

int
main(int argc, char **argv)
{
    int number = 0, found = 0;

    do {
        number++;
        if(is_prime(number)) {
            found++;
        }
    } while(found < 10001);
    return check(PROBLEM, ANSWER, number);
}

Add solution for problem 7

Add solution for problem 7


/*
 * Copyright 2012 Google Inc.
 *
 * 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.
 */

// Author: gagansingh@google.com (Gagan Singh)

#ifndef NET_INSTAWEB_UTIL_PUBLIC_RE2_H_
#define NET_INSTAWEB_UTIL_PUBLIC_RE2_H_

#include "net/instaweb/util/public/string_util.h"

#include "third_party/re2/src/re2/re2.h"

using re2::RE2;

// Converts a Google StringPiece into an RE2 StringPiece.  These are of course
// the same basic thing but are declared in distinct namespaces and as far as
// C++ type-checking is concerned they are incompatible.
//
// TODO(jmarantz): In the re2 code itself there are no references to
// re2::StringPiece, always just plain StringPiece, so if we can
// arrange to get the right definition #included we should be all set.
// We could somehow rewrite '#include "re2/stringpiece.h"' to
// #include Chromium's stringpiece then everything would just work.
inline re2::StringPiece StringPieceToRe2(StringPiece sp) {
  return re2::StringPiece(sp.data(), sp.size());
}

#endif  // NET_INSTAWEB_UTIL_PUBLIC_RE2_H_

/*
 * Copyright 2012 Google Inc.
 *
 * 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.
 */

// Author: gagansingh@google.com (Gagan Singh)

#ifndef NET_INSTAWEB_UTIL_PUBLIC_RE2_H_
#define NET_INSTAWEB_UTIL_PUBLIC_RE2_H_

// TODO(morlovich): Remove this forwarding header and change all references.
#include "pagespeed/kernel/util/re2.h"

#endif  // NET_INSTAWEB_UTIL_PUBLIC_RE2_H_

Make this a proper forwarding header rather than a duplication what's under pagespeed/util/


/*	$OpenBSD: vmparam.h,v 1.3 2011/03/23 16:54:35 pirofti Exp $ */
/* public domain */
#ifndef _MACHINE_VMPARAM_H_
#define _MACHINE_VMPARAM_H_

#define	VM_PHYSSEG_MAX		2 /* Max number of physical memory segments */
#define	VM_PHYSSEG_STRAT	VM_PSTRAT_BIGFIRST

#include <mips64/vmparam.h>

#endif	/* _MACHINE_VMPARAM_H_ */

/*	$OpenBSD: vmparam.h,v 1.4 2014/03/27 21:58:13 miod Exp $ */
/* public domain */
#ifndef _MACHINE_VMPARAM_H_
#define _MACHINE_VMPARAM_H_

#define	VM_PHYSSEG_MAX		3 /* Max number of physical memory segments */
#define	VM_PHYSSEG_STRAT	VM_PSTRAT_BIGFIRST

#include <mips64/vmparam.h>

#endif	/* _MACHINE_VMPARAM_H_ */

Increase VM_PHYSSEG_MAX, necessary for systems with non-contiguous memory (such as 2E and 3A systems).


#include "minunit.h"
#include <terror/file_utils.h>
#include <assert.h>

char *test_getlines()
{
  bstring str = bfromcstr("one\ntwo\nthree\nfour\nfive\n");
  struct bstrList *file = bsplit(str, '\n');

  DArray *lines = getlines(file, 2, 4);

  mu_assert(DArray_count(lines) == 3, "Wrong number of lines.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 0), bfromcstr("two")) == 0, "First line is wrong.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 1), bfromcstr("three")) == 0, "Second line is wrong.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 2), bfromcstr("four")) == 0, "Third line is wrong.");

  return NULL;
}

char *all_tests() {
  mu_suite_start();

  mu_run_test(test_getlines);

  return NULL;
}

RUN_TESTS(all_tests);

#include "minunit.h"
#include <terror/file_utils.h>
#include <assert.h>

char *test_getlines()
{
  bstring str = bfromcstr("one\ntwo\nthree\nfour\nfive\n");
  struct bstrList *file = bsplit(str, '\n');

  DArray *lines = getlines(file, 2, 4);

  bstring two = bfromcstr("two");
  bstring three = bfromcstr("three");
  bstring four = bfromcstr("four");

  mu_assert(DArray_count(lines) == 3, "Wrong number of lines.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 0), two) == 0, "First line is wrong.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 1), three) == 0, "Second line is wrong.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 2), four) == 0, "Third line is wrong.");

  bstrListDestroy(file);
  bdestroy(str);
  bdestroy(two);
  bdestroy(three);
  bdestroy(four);
  DArray_destroy(lines);

  return NULL;
}

char *all_tests() {
  mu_suite_start();

  mu_run_test(test_getlines);

  return NULL;
}

RUN_TESTS(all_tests);

Make file utils tests valgrind-kosher

Make file utils tests valgrind-kosher


// SKIP PARAM: --set ana.activated[+] apron --set ana.path_sens[+] threadflag --set ana.activated[+] threadJoins --sets ana.apron.privatization mutex-meet-tid --disable ana.thread.include-loc
#include <pthread.h>
#include <assert.h>

int g = 10;
pthread_mutex_t A = PTHREAD_MUTEX_INITIALIZER;

void *t_benign(void *arg) {
  pthread_mutex_lock(&A);
  g = 20;
  pthread_mutex_unlock(&A);
  return NULL;
}

int main(void) {
  int t;

  // Force multi-threaded handling
  pthread_t id2;

  if(t) {
    pthread_create(&id2, NULL, t_benign, NULL);
  } else {
    pthread_create(&id2, NULL, t_benign, NULL);
  }

  pthread_join(id2, NULL);

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

  pthread_mutex_lock(&A);
  assert(g == 12);
  pthread_mutex_unlock(&A);

  return 0;
}

Add example that gets more precise when the location is not part of the TID


#include <MozziGuts.h>
#include <Oscil.h>
#include <ADSR.h>
#include <mozzi_midi.h>

#include <tables/sin2048_int8.h>

#define applyGain(v, g)  ((v * g) >> 8)

class MalariaInstrument {
 public:
  MalariaInstrument() {};
  virtual void noteOn(byte note, byte velocity);
  virtual void noteOff(byte note, byte velocity);
  virtual void updateControl();
  virtual int updateAudio();
  virtual bool isPlaying();
 protected:
};

class FMBell : public MalariaInstrument {
 public:
  FMBell() {
    aCarrier.setTable(SIN2048_DATA);
    aModulator.setTable(SIN2048_DATA);
    aCarrier.setFreq(0);
    aModulator.setFreq(0);
    modEnv.setIdleLevel(0);
    modEnv.setLevels(255, 0, 0, 0);
    modEnv.setTimes(20, 2000, 0, 0);
    carEnv.setIdleLevel(0);
    carEnv.setLevels(255, 0, 0, 0);
    carEnv.setTimes(20, 2000, 0, 0);
    gate = false;
    gain = 0;
  }
  void noteOn(byte note, byte velocity) {
    float fundamentalHz = mtof(float(note));
    carrierFreq = float_to_Q16n16(fundamentalHz * 5.f);
    modulatorFreq = float_to_Q16n16(fundamentalHz * 7.f);
    deviation = (modulatorFreq>>16) * mod_index;
    aModulator.setFreq_Q16n16(modulatorFreq);
    aCarrier.setFreq_Q16n16(carrierFreq);
    modEnv.noteOn();
    carEnv.noteOn();
    gate = true;
    gain = velocity;
  }
  void noteOff(byte note, byte velocity) {
    gate = false;
  }
  void updateControl() {
    modEnv.update();
    carEnv.update();
  }
  int updateAudio() {
    if (gate) {
      Q15n16 modulation = applyGain(deviation, applyGain(aModulator.next(), modEnv.next()));
      return applyGain(applyGain(aCarrier.phMod(modulation), carEnv.next()), gain);
    } else {
      return 0;
    }
  }
  bool isPlaying() {
    return gate;
  }
 private:
  const Q8n8 mod_index = float_to_Q8n8(1.0f);
  Oscil<SIN2048_NUM_CELLS, AUDIO_RATE> aCarrier;
  Oscil<SIN2048_NUM_CELLS, AUDIO_RATE> aModulator;
  ADSR <CONTROL_RATE, AUDIO_RATE> modEnv;
  ADSR <CONTROL_RATE, AUDIO_RATE> carEnv;
  Q16n16 carrierFreq, modulatorFreq, deviation;
  byte gain;
  bool gate;
};

Add header for standard instruments.

Add header for standard instruments.


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

#ifndef BASE_SCOPED_HANDLE_H_
#define BASE_SCOPED_HANDLE_H_

#include "base/basictypes.h"

#if defined(OS_WIN)
#include "base/scoped_handle_win.h"
#endif

class ScopedStdioHandle {
 public:
  ScopedStdioHandle()
      : handle_(NULL) { }

  explicit ScopedStdioHandle(FILE* handle)
      : handle_(handle) { }

  ~ScopedStdioHandle() {
    Close();
  }

  void Close() {
    if (handle_) {
      fclose(handle_);
      handle_ = NULL;
    }
  }

  FILE* get() const { return handle_; }

  FILE* Take() {
    FILE* temp = handle_;
    handle_ = NULL;
    return temp;
  }

  void Set(FILE* newhandle) {
    Close();
    handle_ = newhandle;
  }

 private:
  FILE* handle_;

  DISALLOW_EVIL_CONSTRUCTORS(ScopedStdioHandle);
};

#endif // BASE_SCOPED_HANDLE_H_

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

#ifndef BASE_SCOPED_HANDLE_H_
#define BASE_SCOPED_HANDLE_H_

#include <stdio.h>

#include "base/basictypes.h"

#if defined(OS_WIN)
#include "base/scoped_handle_win.h"
#endif

class ScopedStdioHandle {
 public:
  ScopedStdioHandle()
      : handle_(NULL) { }

  explicit ScopedStdioHandle(FILE* handle)
      : handle_(handle) { }

  ~ScopedStdioHandle() {
    Close();
  }

  void Close() {
    if (handle_) {
      fclose(handle_);
      handle_ = NULL;
    }
  }

  FILE* get() const { return handle_; }

  FILE* Take() {
    FILE* temp = handle_;
    handle_ = NULL;
    return temp;
  }

  void Set(FILE* newhandle) {
    Close();
    handle_ = newhandle;
  }

 private:
  FILE* handle_;

  DISALLOW_EVIL_CONSTRUCTORS(ScopedStdioHandle);
};

#endif // BASE_SCOPED_HANDLE_H_

Add stdio to this file becasue we use FILE.

It starts failing with FILE, identifier not found, when
you remove the include for logging.h, which is included
in scoped_handle_win.h

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

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


/*
    Title:      Basic IO.

    Copyright (c) 2000 David C. J. Matthews

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

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

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

*/

#ifndef BASICIO_H
#define BASICIO_H

class SaveVecEntry;
typedef SaveVecEntry *Handle;
class TaskData;

extern Handle IO_dispatch_c(TaskData *mdTaskData, Handle args, Handle strm, Handle code);
extern Handle change_dirc(TaskData *mdTaskData, Handle name);

#ifndef WINDOWS_PC
extern void process_may_block(TaskData *taskData, int fd, int ioCall);
#endif

#endif /* BASICIO_H */

/*
    Title:      Basic IO.

    Copyright (c) 2000 David C. J. Matthews

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

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

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

*/

#ifndef BASICIO_H
#define BASICIO_H

class SaveVecEntry;
typedef SaveVecEntry *Handle;
class TaskData;

extern Handle IO_dispatch_c(TaskData *mdTaskData, Handle args, Handle strm, Handle code);
extern Handle change_dirc(TaskData *mdTaskData, Handle name);

#endif /* BASICIO_H */

Remove process_may_block since it's no longer used except in xwindows.cpp.

git-svn-id: 98787b36aaefbae4b30fa755be920954cd25e1e4@548 ae7d391e-3f74-4a2b-a0db-a8776840fd2a


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

#ifndef SkStippleMaskFilter_DEFINED
#define SkStippleMaskFilter_DEFINED

#include "SkMaskFilter.h"

/**
 * Simple MaskFilter that creates a screen door stipple pattern
 */
class SkStippleMaskFilter : public SkMaskFilter {
public:
    SkStippleMaskFilter() : INHERITED() {
    }

    virtual bool filterMask(SkMask* dst, const SkMask& src,
                            const SkMatrix& matrix,
                            SkIPoint* margin) SK_OVERRIDE;

    // getFormat is from SkMaskFilter
    virtual SkMask::Format getFormat() SK_OVERRIDE {
        return SkMask::kA8_Format;
    }

    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter);

protected:
    SkStippleMaskFilter::SkStippleMaskFilter(SkFlattenableReadBuffer& buffer)
    : SkMaskFilter(buffer) {
    }

private:
    typedef SkMaskFilter INHERITED;
};

#endif // SkStippleMaskFilter_DEFINED

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

#ifndef SkStippleMaskFilter_DEFINED
#define SkStippleMaskFilter_DEFINED

#include "SkMaskFilter.h"

/**
 * Simple MaskFilter that creates a screen door stipple pattern
 */
class SkStippleMaskFilter : public SkMaskFilter {
public:
    SkStippleMaskFilter() : INHERITED() {
    }

    virtual bool filterMask(SkMask* dst, const SkMask& src,
                            const SkMatrix& matrix,
                            SkIPoint* margin) SK_OVERRIDE;

    // getFormat is from SkMaskFilter
    virtual SkMask::Format getFormat() SK_OVERRIDE {
        return SkMask::kA8_Format;
    }

    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkStippleMaskFilter);

protected:
    SkStippleMaskFilter(SkFlattenableReadBuffer& buffer)
    : SkMaskFilter(buffer) {
    }

private:
    typedef SkMaskFilter INHERITED;
};

#endif // SkStippleMaskFilter_DEFINED

Fix for compiler error in r4154

Fix for compiler error in r4154

git-svn-id: e8541e15acce502a64c929015570ad1648e548cd@4155 2bbb7eff-a529-9590-31e7-b0007b416f81


#ifndef QCMAINTHREADRUNNER_H
#define QCMAINTHREADRUNNER_H

#include <QObject>
#include <QVariant>
#include <QEVent>
#include <QCoreApplication>

class QCMainThreadRunner
{

public:

    /// Run a function on main thread. If it is already in main thread, it will be executed in next tick.
    template <typename F>
    static void start(F func) {
        QObject tmp;
        QObject::connect(&tmp, &QObject::destroyed, QCoreApplication::instance(), std::move(func), Qt::QueuedConnection);
    }

    /// Run a function with custom data on main thread. If it is already in main thread, it will be executed in next tick.
    template <typename F,typename P1>
    static void start(F func,P1 p1) {
        auto wrapper = [=]() -> void{
            func(p1);
        };

        QObject tmp;
        QObject::connect(&tmp, &QObject::destroyed, QCoreApplication::instance(), std::move(wrapper), Qt::QueuedConnection);
    }

    template <typename F,typename P1, typename P2>
    static void start(F func,P1 p1, P2 p2) {
        auto wrapper = [=]() -> void{
            func(p1, p2);
        };

        QObject tmp;
        QObject::connect(&tmp, &QObject::destroyed, QCoreApplication::instance(), std::move(wrapper), Qt::QueuedConnection);
    }
};

#endif // QCMAINTHREADRUNNER_H

#ifndef QCMAINTHREADRUNNER_H
#define QCMAINTHREADRUNNER_H

#include <QObject>
#include <QCoreApplication>

class QCMainThreadRunner
{

public:

    /// Run a function on main thread. If it is already in main thread, it will be executed in next tick.
    template <typename F>
    static void start(F func) {
        QObject tmp;
        QObject::connect(&tmp, &QObject::destroyed, QCoreApplication::instance(), std::move(func), Qt::QueuedConnection);
    }

    /// Run a function with custom data on main thread. If it is already in main thread, it will be executed in next tick.
    template <typename F,typename P1>
    static void start(F func,P1 p1) {
        auto wrapper = [=]() -> void{
            func(p1);
        };

        QObject tmp;
        QObject::connect(&tmp, &QObject::destroyed, QCoreApplication::instance(), std::move(wrapper), Qt::QueuedConnection);
    }

    template <typename F,typename P1, typename P2>
    static void start(F func,P1 p1, P2 p2) {
        auto wrapper = [=]() -> void{
            func(p1, p2);
        };

        QObject tmp;
        QObject::connect(&tmp, &QObject::destroyed, QCoreApplication::instance(), std::move(wrapper), Qt::QueuedConnection);
    }
};

#endif // QCMAINTHREADRUNNER_H

Fix build issue for Linux

Fix build issue for Linux


#ifndef TEST_COLLISIONS_H
#define TEST_COLLISIONS_H

#include <kaztest/kaztest.h>

#include "spindash/spindash.h"
#include "spindash/collision/collide.h"
#include "spindash/collision/ray_box.h"

const SDVec2 box_points[] = {
    { -5, -5 },
    { 5, -5 },
    { 5, 0 },
    { -5, 0 }
};

class CollisionGeomTest : public TestCase {
public:
    void test_ray_box_floor_sensors() {
        RayBox ray_box(nullptr, 0.5f, 1.0f);
        ray_box.set_position(0, 0.5);

        Box floor(nullptr, 10.0f, 1.0f);
        floor.set_position(0, -0.5);

        std::vector<Collision> collisions = collide(&ray_box, &floor);

        assert_equal(2, collisions.size());
        assert_equal('A', collisions[0].a_ray);
        assert_equal('B', collisions[1].a_ray);
        assert_equal(0.0, collisions[0].point.y);
        assert_equal(0.0, collisions[1].point.y);
    }

private:

};

#endif // TEST_COLLISIONS_H

#ifndef TEST_COLLISIONS_H
#define TEST_COLLISIONS_H

#include <kaztest/kaztest.h>

#include "spindash/spindash.h"
#include "spindash/collision/collide.h"
#include "spindash/collision/ray_box.h"
#include "spindash/collision/box.h"

const SDVec2 box_points[] = {
    { -5, -5 },
    { 5, -5 },
    { 5, 0 },
    { -5, 0 }
};

class CollisionGeomTest : public TestCase {
public:
    void test_ray_box_floor_sensors() {
        RayBox ray_box(nullptr, 0.5f, 1.0f);
        ray_box.set_position(0, 0.5);

        Box floor(nullptr, 10.0f, 1.0f);
        floor.set_position(0, -0.5);

        std::vector<Collision> collisions = collide(&ray_box, &floor);

        assert_equal(2, collisions.size());
        assert_equal('A', collisions[0].a_ray);
        assert_equal('B', collisions[1].a_ray);
        assert_equal(0.0, collisions[0].point.y);
        assert_equal(0.0, collisions[1].point.y);
    }

private:

};

#endif // TEST_COLLISIONS_H

Add a missing header from one of the tests


#pragma once

#include "initiation/sipmessageprocessor.h"

#include "initiation/siptypes.h"

/* This class handles the authentication for this connection
 * should we receive a challenge */

class SIPAuthentication : public SIPMessageProcessor
{
  Q_OBJECT
public:
  SIPAuthentication();

public slots:

  // add credentials to request, if we have them
  virtual void processOutgoingRequest(SIPRequest& request, QVariant& content);

  // take challenge if they require authentication
  virtual void processIncomingResponse(SIPResponse& response, QVariant& content);

private:

  DigestResponse generateAuthResponse(DigestChallenge& challenge, QString username,
                                      SIP_URI& requestURI, SIPRequestMethod method,
                                      QVariant& content);

  void updateNonceCount(DigestChallenge& challenge, DigestResponse& response);

  // TODO: Test if these need to be separate

  QList<DigestChallenge> wwwChallenges_;
  QList<DigestChallenge> proxyChallenges_;

  QList<DigestResponse> authorizations_;
  QList<DigestResponse> proxyAuthorizations_;

  // key is realm and value current nonce
  std::map<QString, QString> realmToNonce_;
  std::map<QString, uint32_t> realmToNonceCount_;

  QByteArray a1_;
};

#pragma once

#include "initiation/sipmessageprocessor.h"

#include "initiation/siptypes.h"

/* This class handles the authentication for this connection
 * should we receive a challenge */

class SIPAuthentication : public SIPMessageProcessor
{
  Q_OBJECT
public:
  SIPAuthentication();

public slots:

  // add credentials to request, if we have them
  virtual void processOutgoingRequest(SIPRequest& request, QVariant& content);

  // take challenge if they require authentication
  virtual void processIncomingResponse(SIPResponse& response, QVariant& content);

private:

  DigestResponse generateAuthResponse(DigestChallenge& challenge, QString username,
                                      SIP_URI& requestURI, SIPRequestMethod method,
                                      QVariant& content);

  void updateNonceCount(DigestChallenge& challenge, DigestResponse& response);

  QList<DigestChallenge> wwwChallenges_;
  QList<DigestChallenge> proxyChallenges_;

  QList<DigestResponse> authorizations_;
  QList<DigestResponse> proxyAuthorizations_;

  // key is realm and value current nonce
  std::map<QString, QString> realmToNonce_;
  std::map<QString, uint32_t> realmToNonceCount_;

  QByteArray a1_;
};

cosmetic(Transport): Remove TODO. Tested common credentials, didn't work.


#ifndef PyMPI_COMPAT_DEINOMPI_H
#define PyMPI_COMPAT_DEINOMPI_H

/* ---------------------------------------------------------------- */

static int    PyMPI_DEINOMPI_argc    = 0;
static char **PyMPI_DEINOMPI_argv    = 0;
static char  *PyMPI_DEINOMPI_args[2] = {0, 0};

static void PyMPI_DEINOMPI_FixArgs(int **argc, char ****argv)
{
  if ((argc[0]==(int *)0) || (argv[0]==(char ***)0)) {
#ifdef Py_PYTHON_H
#if PY_MAJOR_VERSION >= 3
    PyMPI_DEINOMPI_args[0] = (char *) "python";
#else
    PyMPI_DEINOMPI_args[0] = Py_GetProgramName();
#endif
    PyMPI_DEINOMPI_argc = 1;
#endif
    PyMPI_DEINOMPI_argv = PyMPI_DEINOMPI_args;
    argc[0] = &PyMPI_DEINOMPI_argc;
    argv[0] = &PyMPI_DEINOMPI_argv;
  }
}

static int PyMPI_DEINOMPI_MPI_Init(int *argc, char ***argv)
{
  PyMPI_DEINOMPI_FixArgs(&argc, &argv);
  return MPI_Init(argc, argv);
}
#undef  MPI_Init
#define MPI_Init PyMPI_DEINOMPI_MPI_Init

static int PyMPI_DEINOMPI_MPI_Init_thread(int *argc, char ***argv,
                                          int required, int *provided)
{
  PyMPI_DEINOMPI_FixArgs(&argc, &argv);
  return MPI_Init_thread(argc, argv, required, provided);
}
#undef  MPI_Init_thread
#define MPI_Init_thread PyMPI_DEINOMPI_MPI_Init_thread

/* ---------------------------------------------------------------- */

#endif /* !PyMPI_COMPAT_DEINOMPI_H */

#ifndef PyMPI_COMPAT_DEINOMPI_H
#define PyMPI_COMPAT_DEINOMPI_H

#endif /* !PyMPI_COMPAT_DEINOMPI_H */

Remove hackery for DeinoMPI, release 1.1.0 seems to work just fine


/*
 *   ASXSoft Nuke - Operating System
 *   Copyright (C) 2009  Patrick Pokatilo
 *
 *   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/>.
 */

#include "stdint.h"
#include "stddef.h"
#include "gdt.h"

extern gdt_pointer_t gdt_pointer;

void start_rocket_engine()
{
	gdt_initialize();
	gdt_load();
	gdt_flush_registers(0x08, 0x18, 0x18, 0x00, 0x00, 0x18);

	while(1);
}

Set up GDT and load 32-Bit Segments

Rocket: Set up GDT and load 32-Bit Segments

Signed-off-by: Patrick Pokatilo <cdeca2a4be8a4e00f97216f8984b997a40d1b424@asxsoft.de>


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

typedef void (*fnct_ptr)(void);
typedef int (*open_t)(const char*,int,int);
typedef int (*ftruncate_t)(int,off_t);

// Goblint used to crash on this example because the number of supplied arguments for myopen is bigger than
// than the expected number of arguments for the library function descriptior of ftruncate.
//  -- "open" expects 3 arguments, while "ftruncate" expects only 2.
int main(){
    fnct_ptr ptr;
    int top;

    if (top){
        ptr = &open;
    } else {
        ptr = &ftruncate;
    }

    if (top) {
        // Some (nonsensical, but compiling) call to open
        open_t myopen;
        myopen = (open_t) ptr;
        myopen("some/path", O_CREAT, 0);
    } else {
        // Some (nonsensical, but compiling) call to ftruncate
        ftruncate_t myftruncate;
        myftruncate = (ftruncate_t) ptr;
        myftruncate(0, 100);
    }
    return 0;
}

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

typedef void (*fnct_ptr)(void);
typedef int (*open_t)(const char*,int,...);
typedef int (*ftruncate_t)(int,off_t);

// Goblint used to crash on this example because the number of supplied arguments for myopen is bigger than
// than the expected number of arguments for the library function descriptior of ftruncate.
//  -- "open" expects 3 arguments, while "ftruncate" expects only 2.
int main(){
    fnct_ptr ptr;
    int top, top2, top3;

    if (top){
        ptr = (fnct_ptr) &open;
        ftruncate_t myftruncate;
        myftruncate = (ftruncate_t) ptr;
        myftruncate(0, 100); //NOWARN
    } else {
        ptr = (fnct_ptr) &ftruncate;
    }

    if (top2) {
        open_t myopen;
        myopen = (open_t) ptr;
        // Warn about possible call to ftruncate with wrong number of arguments
        myopen("some/path", 0, 0); // WARN
    } else if(top3) {
        ftruncate_t myftruncate2;
        myftruncate2 = (ftruncate_t) ptr;
        off_t v = 100;
        // We (currently) only warn about wrong number of args, not wrong type
        // So no warning is emitted here about possibly calling the vararg function open.
        myftruncate2(0, v);
    } else {
        // Warn about potential calls to open and ftruncate with too few arguments,
        // and warn that none of the possible targets of the pointer fit as call targets.
        ptr(); // WARN
    }
    return 0;
}

Add WARN annotations and explanations to test, expand it with one case.


#ifndef CONSOLE_H
#define CONSOLE_H

#include <Cart.h>
#include <Controller.h>
#include <CPU.h>
#include <PPU.h>
#include <APU.h>

class Divider {
public:
    void setInterval(int interval) {
	this->interval = interval;
	clockCounter = interval - 1;
    }
    void tick() {
	clockCounter++;
	if (clockCounter == interval) {
	    clockCounter = 0;
	}
    }
    bool hasClocked() {
	return clockCounter == 0;
    }
private:
    int interval;
    int clockCounter;
};

class Console {
public:
  ~Console();
  void boot();
  void runForOneFrame();
  uint32_t *getFrameBuffer();

  Cart cart;
  Controller controller1;

private:
  void tick();

  CPU *cpu;
  PPU *ppu;
  APU apu;
  Divider cpuDivider;
};

#endif

#ifndef CONSOLE_H
#define CONSOLE_H

#include <Cart.h>
#include <Controller.h>
#include <CPU.h>
#include <PPU.h>
#include <APU.h>

class Divider {
public:
    Divider(int interval = 1) {
	setInterval(interval);
    }
    void setInterval(int interval) {
	this->interval = interval;
	clockCounter = interval - 1;
    }
    void tick() {
	clockCounter++;
	if (clockCounter == interval) {
	    clockCounter = 0;
	}
    }
    bool hasClocked() {
	return clockCounter == 0;
    }

private:
    int interval;
    int clockCounter;
};

class Console {
public:
  ~Console();
  void boot();
  void runForOneFrame();
  uint32_t *getFrameBuffer();

  Cart cart;
  Controller controller1;

private:
  void tick();

  CPU *cpu;
  PPU *ppu;
  APU apu;
  Divider cpuDivider;
};

#endif

Add divider constructor with interval default argument


/**
 * @file utils.h
 * @brief Storj utilities.
 *
 * Helper utilities
 */
#ifndef STORJ_UTILS_H
#define STORJ_UTILS_H

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#ifdef _WIN32
#include <windows.h>
#else
#include <sys/time.h>
#endif

int hex2str(unsigned length, uint8_t *data, char *buffer);

void print_int_array(uint8_t *array, unsigned length);

int str2hex(unsigned length, char *data, uint8_t *buffer);

void random_buffer(uint8_t *buf, size_t len);

uint64_t shard_size(int hops);

uint64_t get_time_milliseconds();

void memset_zero(void *v, size_t n);

#endif /* STORJ_UTILS_H */

/**
 * @file utils.h
 * @brief Storj utilities.
 *
 * Helper utilities
 */
#ifndef STORJ_UTILS_H
#define STORJ_UTILS_H

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

#ifdef _WIN32
#include <windows.h>
#include <time.h>
#else
#include <sys/time.h>
#endif

int hex2str(unsigned length, uint8_t *data, char *buffer);

void print_int_array(uint8_t *array, unsigned length);

int str2hex(unsigned length, char *data, uint8_t *buffer);

void random_buffer(uint8_t *buf, size_t len);

uint64_t shard_size(int hops);

uint64_t get_time_milliseconds();

void memset_zero(void *v, size_t n);

#endif /* STORJ_UTILS_H */

Fix implicit declaration of function ‘time’


#pragma once

#include "definitions.h"
#include "util/log.h"

inline u16 compose_bytes(const u8 high, const u8 low) {
    return (high << 8) + low;
}

inline bool check_bit(const u8 value, const int bit) {
    return (value & (1 << bit)) != 0;
}

inline u8 set_bit(const u8 value, const int bit) {
    return value | (1 << bit);
}

inline u8 clear_bit(const u8 value, const int bit) {
    return value & ~(1 << bit);
}

inline u8 set_bit_to(const u8 value, const int bit, bool bit_on) {
    if (bit_on) {
        return set_bit(value, bit);
    } else {
        return clear_bit(value, bit);
    }
}

#pragma once

#include "definitions.h"
#include "util/log.h"

inline u16 compose_bytes(const u8 high, const u8 low) {
    return static_cast<u16>((high << 8) + low);
}

inline bool check_bit(const u8 value, const u8 bit) {
    return (value & (1 << bit)) != 0;
}

inline u8 set_bit(const u8 value, const u8 bit) {
    auto value_set = value | (1 << bit);
    return static_cast<u8>(value_set);
}

inline u8 clear_bit(const u8 value, const u8 bit) {
    auto value_cleared = value & ~(1 << bit);
    return static_cast<u8>(value_cleared);
}

inline u8 set_bit_to(const u8 value, const u8 bit, bool bit_on) {
    if (bit_on) {
        return set_bit(value, bit);
    } else {
        return clear_bit(value, bit);
    }
}

Make conversions between integer sizes explicit


// RUN: %clang -ccc-echo -o %t %s 2> %t.log

// Make sure we used clang.
// RUN: grep 'clang" -cc1 .*hello.c' %t.log

// RUN: %t > %t.out
// RUN: grep "I'm a little driver, short and stout." %t.out

// FIXME: We don't have a usable assembler on Windows, so we can't build real
// apps yet.
// XFAIL: win32

#include <stdio.h>

int main() {
  printf("I'm a little driver, short and stout.");
  return 0;
}

// RUN: %clang -ccc-echo -o %t %s 2> %t.log

// Make sure we used clang.
// RUN: grep 'clang\(-[0-9.]\+\)\?" -cc1 .*hello.c' %t.log

// RUN: %t > %t.out
// RUN: grep "I'm a little driver, short and stout." %t.out

// FIXME: We don't have a usable assembler on Windows, so we can't build real
// apps yet.
// XFAIL: win32

#include <stdio.h>

int main() {
  printf("I'm a little driver, short and stout.");
  return 0;
}

Fix this test case for CMake builds after r126502, which sneakily  changed the actual executable name to clang-<version>.

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


#ifndef KISS_TEMPLATES_KISTE_H
#define KISS_TEMPLATES_KISTE_H

#include <kiste/terminal.h>
#include <kiste/raw.h>

namespace kiste
{
  struct terminal_t
  {
  };
  constexpr auto terminal = terminal_t{};

  struct raw
  {
    std::ostream& _os;

    template <typename T>
    auto operator()(T&& t) const -> void
    {
      _os << std::forward<T>(t);
    }
  };
}

#endif

#ifndef KISS_TEMPLATES_KISTE_H
#define KISS_TEMPLATES_KISTE_H

#include <kiste/terminal.h>
#include <kiste/raw.h>

#endif

Remove types left over from header split


//===-- MachineFunctionAnalysis.h - Owner of MachineFunctions ----*-C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the MachineFunctionAnalysis class.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H
#define LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H

#include "llvm/Pass.h"

namespace llvm {

class MachineFunction;
class TargetMachine;

/// MachineFunctionAnalysis - This class is a Pass that manages a
/// MachineFunction object.
struct MachineFunctionAnalysis : public FunctionPass {
private:
  const TargetMachine &TM;
  CodeGenOpt::Level OptLevel;
  MachineFunction *MF;

public:
  static char ID;
  explicit MachineFunctionAnalysis(const TargetMachine &tm,
                                   CodeGenOpt::Level OL = CodeGenOpt::Default);
  ~MachineFunctionAnalysis();

  MachineFunction &getMF() const { return *MF; }
  CodeGenOpt::Level getOptLevel() const { return OptLevel; }

private:
  virtual bool runOnFunction(Function &F);
  virtual void releaseMemory();
  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
};

} // End llvm namespace

#endif

//===-- MachineFunctionAnalysis.h - Owner of MachineFunctions ----*-C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file declares the MachineFunctionAnalysis class.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H
#define LLVM_CODEGEN_MACHINE_FUNCTION_ANALYSIS_H

#include "llvm/Pass.h"
#include "llvm/Target/TargetMachine.h"

namespace llvm {

class MachineFunction;

/// MachineFunctionAnalysis - This class is a Pass that manages a
/// MachineFunction object.
struct MachineFunctionAnalysis : public FunctionPass {
private:
  const TargetMachine &TM;
  CodeGenOpt::Level OptLevel;
  MachineFunction *MF;

public:
  static char ID;
  explicit MachineFunctionAnalysis(const TargetMachine &tm,
                                   CodeGenOpt::Level OL = CodeGenOpt::Default);
  ~MachineFunctionAnalysis();

  MachineFunction &getMF() const { return *MF; }
  CodeGenOpt::Level getOptLevel() const { return OptLevel; }

private:
  virtual bool runOnFunction(Function &F);
  virtual void releaseMemory();
  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
};

} // End llvm namespace

#endif

Revert 88957. This file uses CodeGenOpt, which is defined in TargetMachine.h.

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


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

#define QLA4XXX_DRIVER_VERSION	"5.04.00-k0"

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

#define QLA4XXX_DRIVER_VERSION	"5.04.00-k1"

Update driver version to 5.04.00-k1

[SCSI] qla4xxx: Update driver version to 5.04.00-k1

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


//===-- problems/Problem15.h ------------------------------------*- C++ -*-===//
//
// ProjectEuler.net solutions by Will Mitchell
//
// This file is distributed under the MIT License. See LICENSE for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief Problem 15: Lattice paths
///
//===----------------------------------------------------------------------===//
#ifndef PROBLEMS_PROBLEM15_H
#define PROBLEMS_PROBLEM15_H

#include <string>

#include <gmpxx.h>

#include "../Problem.h"

namespace problems {
class Problem15 : public Problem {
public:
  Problem15() : value(0), solved(false) {}
  ~Problem15() = default;
  std::string answer();
  std::string description() const;
  void solve();

  // Simple brute force solution
  unsigned long long bruteForce(const unsigned long long limit) const;

private:
  /// Cached answer
  mpz_class value;
  /// If cached answer is valid
  bool solved;
};
}

#endif

//===-- problems/Problem15.h ------------------------------------*- C++ -*-===//
//
// ProjectEuler.net solutions by Will Mitchell
//
// This file is distributed under the MIT License. See LICENSE for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief Problem 15: Lattice paths
///
//===----------------------------------------------------------------------===//
#ifndef PROBLEMS_PROBLEM15_H
#define PROBLEMS_PROBLEM15_H

#include <string>

#include <gmpxx.h>

#include "../Problem.h"

namespace problems {
class Problem15 : public Problem {
public:
  Problem15() : value(0), solved(false) {}
  ~Problem15() = default;
  std::string answer();
  std::string description() const;
  void solve();

private:
  /// Cached answer
  mpz_class value;
  /// If cached answer is valid
  bool solved;
};
}

#endif

Remove extraneous method in Problem 15

Remove extraneous method in Problem 15


#ifndef QMLDESIGNER_ABSTRACTSINGLESELECTIONTOOL_H
#define QMLDESIGNER_ABSTRACTSINGLESELECTIONTOOL_H

#include "abstractformeditortool.h"

namespace QmlDesigner {

class QMLDESIGNERCORE_EXPORT AbstractCustomTool : public QmlDesigner::AbstractFormEditorTool
{
public:
    AbstractCustomTool();

    void selectedItemsChanged(const QList<FormEditorItem *> &itemList) QTC_OVERRIDE;

    virtual int wantHandleItem(const ModelNode &modelNode) const QTC_OVERRIDE = 0;
};

} // namespace QmlDesigner

#endif // QMLDESIGNER_ABSTRACTSINGLESELECTIONTOOL_H

#ifndef QMLDESIGNER_ABSTRACTSINGLESELECTIONTOOL_H
#define QMLDESIGNER_ABSTRACTSINGLESELECTIONTOOL_H

#include "abstractformeditortool.h"

namespace QmlDesigner {

class QMLDESIGNERCORE_EXPORT AbstractCustomTool : public QmlDesigner::AbstractFormEditorTool
{
public:
    AbstractCustomTool();

    void selectedItemsChanged(const QList<FormEditorItem *> &itemList) QTC_OVERRIDE;

    virtual QString name() const = 0;

    virtual int wantHandleItem(const ModelNode &modelNode) const QTC_OVERRIDE = 0;
};

} // namespace QmlDesigner

#endif // QMLDESIGNER_ABSTRACTSINGLESELECTIONTOOL_H

Add name method to custom tools

QmlDesigner.FormEditor: Add name method to custom tools

Change-Id: Icabf454fc49444a5a88c1f5eb84847967f09078e
Reviewed-by: Thomas Hartmann <588ee739c05aab7547907becfd1420d2b7316069@digia.com>


//===-- llvm/CodeGen/Spiller.h - Spiller -*- C++ -*------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CODEGEN_SPILLER_H
#define LLVM_CODEGEN_SPILLER_H

#include <vector>

namespace llvm {

  /// Spiller interface.
  ///
  /// Implementations are utility classes which insert spill or remat code on
  /// demand.
  class Spiller {
  public:
    virtual ~Spiller() = 0;
    virtual std::vector<class LiveInterval*> spill(class LiveInterval *li) = 0;
  };

  /// Create and return a spiller object, as specified on the command line.
  Spiller* createSpiller(class MachineFunction *mf, class LiveIntervals *li,
                         class VirtRegMap *vrm);
}

#endif

//===-- llvm/CodeGen/Spiller.h - Spiller -*- C++ -*------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CODEGEN_SPILLER_H
#define LLVM_CODEGEN_SPILLER_H

#include <vector>

namespace llvm {
  struct LiveInterval;

  /// Spiller interface.
  ///
  /// Implementations are utility classes which insert spill or remat code on
  /// demand.
  class Spiller {
  public:
    virtual ~Spiller() = 0;
    virtual std::vector<LiveInterval*> spill(class LiveInterval *li) = 0;
  };

  /// Create and return a spiller object, as specified on the command line.
  Spiller* createSpiller(class MachineFunction *mf, class LiveIntervals *li,
                         class VirtRegMap *vrm);
}

#endif

Fix to compile on VS2008.

Fix to compile on VS2008.

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


#ifndef _NPY_ENDIAN_H_
#define _NPY_ENDIAN_H_

/* NPY_BYTE_ORDER is set to the same value as BYTE_ORDER set by glibc in
 * endian.h */

#ifdef NPY_HAVE_ENDIAN_H
        /* Use endian.h if available */
        #include <endian.h>
        #define NPY_BYTE_ODER __BYTE_ORDER
        #if (__BYTE_ORDER == __LITTLE_ENDIAN)
                #define NPY_LITTLE_ENDIAN
        #elif (__BYTE_ORDER == __BIG_ENDIAN)
                #define NPY_BYTE_ODER __BYTE_ORDER
        #else
                #error Unknown machine endianness detected.
        #endif
#else
        /* Set endianness info using target CPU */
        #include "cpuarch.h"

        #if defined(NPY_X86) || defined(NPY_AMD64)
                        #define NPY_LITTLE_ENDIAN
                        #define NPY_BYTE_ORDER 1234
        #elif defined(NPY_PPC) || defined(NPY_SPARC) || defined(NPY_S390) || \
              defined(NPY_PA_RISC)
                        #define NPY_BIG_ENDIAN
                        #define NPY_BYTE_ORDER 4321
        #endif
#endif

#endif

Add a (public) header to set cpu endianness when numpy headers are included instead of setting them at build time.


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

#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
  #define GR_TEST_UTILS 1
  #define SK_BUILD_FOR_ANDROID_FRAMEWORK
  #define SK_DEFAULT_FONT_CACHE_LIMIT   (768 * 1024)
  #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
  #define SK_USE_FREETYPE_EMBOLDEN

  // Disable these Ganesh features
  #define SK_DISABLE_REDUCE_OPLIST_SPLITTING
  // Check error is expensive. HWUI historically also doesn't check its allocations
  #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0

  // Legacy flags
  #define SK_IGNORE_GPU_DITHER
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Needed until we fix https://bug.skia.org/2440
  #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
  #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
  #define SK_SUPPORT_LEGACY_AA_CHOICE
  #define SK_SUPPORT_LEGACY_AAA_CHOICE

  #define SK_DISABLE_DAA  // skbug.com/6886

  #define SK_LEGACY_HEIF_API

#endif // SkUserConfigManual_DEFINED

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

#ifndef SkUserConfigManual_DEFINED
#define SkUserConfigManual_DEFINED
  #define GR_TEST_UTILS 1
  #define SK_BUILD_FOR_ANDROID_FRAMEWORK
  #define SK_DEFAULT_FONT_CACHE_LIMIT   (768 * 1024)
  #define SK_DEFAULT_GLOBAL_DISCARDABLE_MEMORY_POOL_SIZE (512 * 1024)
  #define SK_USE_FREETYPE_EMBOLDEN

  // Disable these Ganesh features
  #define SK_DISABLE_REDUCE_OPLIST_SPLITTING
  // Check error is expensive. HWUI historically also doesn't check its allocations
  #define GR_GL_CHECK_ALLOC_WITH_GET_ERROR 0

  // Legacy flags
  #define SK_IGNORE_GPU_DITHER
  #define SK_SUPPORT_DEPRECATED_CLIPOPS

  // Needed until we fix https://bug.skia.org/2440
  #define SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG
  #define SK_SUPPORT_LEGACY_EMBOSSMASKFILTER
  #define SK_SUPPORT_LEGACY_AA_CHOICE
  #define SK_SUPPORT_LEGACY_AAA_CHOICE

  #define SK_DISABLE_DAA  // skbug.com/6886

#endif // SkUserConfigManual_DEFINED

Remove SK_LEGACY_HEIF_API to enable animation in SkHeifCodec

bug: 78868457
bug: 120414514

test: local test with OpenGL Rendrerer Tests animation
demo and heifs files

Change-Id: I09a7667a57f545927dbe9ac24c1a6b405ff0006d


// Copyright 2015 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 SKY_SHELL_PLATFORM_VIEW_ANDROID_H_
#define SKY_SHELL_PLATFORM_VIEW_ANDROID_H_

#include "sky/shell/platform_view.h"

struct ANativeWindow;

namespace sky {
namespace shell {

class PlatformViewAndroid : public PlatformView {
 public:
  static bool Register(JNIEnv* env);
  ~PlatformViewAndroid() override;

  // Called from Java
  void Detach(JNIEnv* env, jobject obj);
  void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface);
  void SurfaceDestroyed(JNIEnv* env, jobject obj);

 private:
  void ReleaseWindow();

  ANativeWindow* window_;

  DISALLOW_COPY_AND_ASSIGN(PlatformViewAndroid);
};

}  // namespace shell
}  // namespace sky

#endif  // SKY_SHELL_PLATFORM_VIEW_ANDROID_H_

// Copyright 2015 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 SKY_SHELL_PLATFORM_VIEW_ANDROID_H_
#define SKY_SHELL_PLATFORM_VIEW_ANDROID_H_

#include "sky/shell/platform_view.h"

struct ANativeWindow;

namespace sky {
namespace shell {

class PlatformViewAndroid : public PlatformView {
 public:
  static bool Register(JNIEnv* env);
  ~PlatformViewAndroid() override;

  // Called from Java
  void Detach(JNIEnv* env, jobject obj);
  void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface);
  void SurfaceDestroyed(JNIEnv* env, jobject obj);

 private:
  void ReleaseWindow();

  DISALLOW_COPY_AND_ASSIGN(PlatformViewAndroid);
};

}  // namespace shell
}  // namespace sky

#endif  // SKY_SHELL_PLATFORM_VIEW_ANDROID_H_

Stop SkyShell from crashing on startup

Stop SkyShell from crashing on startup

R=chinmaygarde@google.com

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


/**
 * \brief Solve an instance of the "Variable Placement with Separation
 * Constraints" problem.
 *
 * Authors:
 *   Tim Dwyer <tgdwyer@gmail.com>
 *
 * Copyright (C) 2005 Authors
 *
 * This version is released under the CPL (Common Public License) with
 * the Graphviz distribution.
 * A version is also available under the LGPL as part of the Adaptagrams
 * project: http://sourceforge.net/projects/adaptagrams.
 * If you make improvements or bug fixes to this code it would be much
 * appreciated if you could also contribute those changes back to the
 * Adaptagrams repository.
 */
#ifndef SEEN_REMOVEOVERLAP_SOLVE_VPSC_H
#define SEEN_REMOVEOVERLAP_SOLVE_VPSC_H

#include <vector>
class Variable;
class Constraint;
class Blocks;

/**
 * Variable Placement with Separation Constraints problem instance
 */
class VPSC {
public:
	virtual void satisfy();
	virtual void solve();

	VPSC(const unsigned n, Variable *vs[], const unsigned m, Constraint *cs[]);
	virtual ~VPSC();
protected:
	Blocks *bs;
	Constraint **cs;
	unsigned m;
	void printBlocks();
private:
	void refine();
	bool constraintGraphIsCyclic(const unsigned n, Variable *vs[]);
	bool blockGraphIsCyclic();
};

class IncVPSC : VPSC {
public:
	unsigned splitCnt;
	void satisfy();
	void solve();
	void moveBlocks();
	void splitBlocks();
	IncVPSC(const unsigned n, Variable *vs[], const unsigned m, Constraint *cs[]);
private:
	typedef std::vector<Constraint*> ConstraintList;
	ConstraintList inactive;
	double mostViolated(ConstraintList &l,Constraint* &v);
};
#endif // SEEN_REMOVEOVERLAP_SOLVE_VPSC_H

Add the vpsc library for IPSEPCOLA features


#ifndef RBOSL_MOVE_H
#define RBOSL_MOVE_H

#include "ruby.h"
#include <osl/move.h>

extern  VALUE cMove;

using namespace osl;

void rb_move_free(Move* ptr);
static VALUE rb_move_s_new(VALUE self);

void Init_move(void);

#endif /* RBOSL_MOVE_H */

Add a missing include guard

Add a missing include guard


#ifndef FIX_UNISTD_H
#define FIX_UNISTD_H

#include <unistd.h>

/*
  For some reason the g++ include files on Ultrix 4.3 fail to provide
  these prototypes, even though the Ultrix 4.2 versions did...
*/
#if defined(ULTRIX43)

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

#if defined(__STDC__) || defined(__cplusplus)
	int symlink( const char *, const char * );
	char *sbrk( int );
	int gethostname( char *, int );
#else
	int symlink();
	char *sbrk();
	int gethostname();
#endif

#if defined(__cplusplus)
}
#endif

#endif	/* ULTRIX43 */

#endif

#ifndef FIX_UNISTD_H
#define FIX_UNISTD_H

#include <unistd.h>

/*
  For some reason the g++ include files on Ultrix 4.3 fail to provide
  these prototypes, even though the Ultrix 4.2 versions did...
  Once again, OSF1 also chokes, unless _AES_SOURCE(?) is defined JCP
*/
#if defined(ULTRIX43) || defined(OSF1)

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

#if defined(__STDC__) || defined(__cplusplus)
	int symlink( const char *, const char * );
	char *sbrk( int );
	int gethostname( char *, int );
#else
	int symlink();
	char *sbrk();
	int gethostname();
#endif

#if defined(__cplusplus)
}
#endif

#endif	/* ULTRIX43 */

#endif

Add OSF/1 to a pre-existing conditional compilation switch.


// PARAM: --enable ana.int.congruence --disable ana.int.def_exc
// This test ensures that operations on constant congr. classes (i.e. classes of the form {k} : arbitrary integer k) yield concrete vals

int main() {
    // basic arithmetic operators
    int a = 1;
    int b = 2;
    int c = -1;
    int d = -2;

    assert (a + b == 3); assert (a + d == -1);
    assert (a * b == 2); assert (b * c == -2);
    assert (a / b == 0); assert (d / c == 2);
    assert (b % a == 0); assert (d % c == 0);
    assert (-a == -1); assert (-d == 2);

    // logical operators
    int zero = 0;
    int one = 1;

    unsigned int uns_z = 0;

    assert ((zero || one) == 1); assert ((zero || zero) == 0); assert ((one || one) == 1);
    assert ((zero && one) == 0); assert ((zero && zero) == 0); assert ((one && one) == 1);
    assert (!one == 0); assert (!zero == 1);

    // bitwise operators
    assert ((zero & zero) == 0); assert ((zero & one) == 0); assert ((one & zero) == 0); assert ((one & one) == 1);
    assert ((zero | zero) == 0); assert ((zero | one) == 1); assert ((one | zero) == 1); assert ((one | one) == 1);
    assert ((zero ^ zero) == 0); assert ((zero ^ one) == 1); assert ((one ^ zero) == 1); assert ((one ^ one) == 0);
    assert (~zero == -1); assert (~uns_z == 4294967295);

    // shift-left
    unsigned char m = 136;
    assert ((m << 1) == 16);

    //shift-right missing as only top() is returned currently

    // comparisons
    assert ((a < b) == 1);
    assert ((a > b) == 0);
    assert ((a == b) == 0);
    assert ((a != b) == 1);

    return 0;
}

Add constant test for congruence domain

Add constant test for congruence domain


// Copyright (c) 2020 The Orbit 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 ORBIT_GL_GRAPH_TRACK_H
#define ORBIT_GL_GRAPH_TRACK_H

#include <limits>

#include "ScopeTimer.h"
#include "Track.h"

class TimeGraph;

class GraphTrack : public Track {
 public:
  explicit GraphTrack(TimeGraph* time_graph);
  Type GetType() const override { return kGraphTrack; }
  void Draw(GlCanvas* canvas, bool picking) override;
  void OnDrag(int x, int y) override;
  void AddTimer(const Timer& timer) override;
  float GetHeight() const override;

 protected:
  std::map<uint64_t, double> values_;
  double min_ = std::numeric_limits<double>::max();
  double max_ = std::numeric_limits<double>::min();
  double value_range_ = 0;
  double inv_value_range_ = 0;
};

#endif

// Copyright (c) 2020 The Orbit 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 ORBIT_GL_GRAPH_TRACK_H
#define ORBIT_GL_GRAPH_TRACK_H

#include <limits>

#include "ScopeTimer.h"
#include "Track.h"

class TimeGraph;

class GraphTrack : public Track {
 public:
  explicit GraphTrack(TimeGraph* time_graph);
  Type GetType() const override { return kGraphTrack; }
  void Draw(GlCanvas* canvas, bool picking) override;
  void OnDrag(int x, int y) override;
  void AddTimer(const Timer& timer) override;
  float GetHeight() const override;

 protected:
  std::map<uint64_t, double> values_;
  double min_ = std::numeric_limits<double>::max();
  double max_ = std::numeric_limits<double>::lowest();
  double value_range_ = 0;
  double inv_value_range_ = 0;
};

#endif

Use numeric_limits<double>::lowest instead of numeric_limits<double>::min


#define MICROPY_HW_BOARD_NAME "Adafruit QTPy RP2040"
#define MICROPY_HW_MCU_NAME "rp2040"

#define MICROPY_HW_NEOPIXEL (&pin_GPIO12)

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO25)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO24)

#define DEFAULT_SPI_BUS_SCK (&pin_GPIO6)
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO3)
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO4)

// #define DEFAULT_UART_BUS_RX (&pin_PA11)
// #define DEFAULT_UART_BUS_TX (&pin_PA10)

// Flash chip is GD25Q32 connected over QSPI
#define TOTAL_FLASH_SIZE (4 * 1024 * 1024)

#define MICROPY_HW_BOARD_NAME "Adafruit QTPy RP2040"
#define MICROPY_HW_MCU_NAME "rp2040"

#define MICROPY_HW_NEOPIXEL (&pin_GPIO12)

#define DEFAULT_I2C_BUS_SCL (&pin_GPIO25)
#define DEFAULT_I2C_BUS_SDA (&pin_GPIO24)

#define DEFAULT_SPI_BUS_SCK (&pin_GPIO6)
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO3)
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO4)

// #define DEFAULT_UART_BUS_RX (&pin_PA11)
// #define DEFAULT_UART_BUS_TX (&pin_PA10)

// Flash chip is GD25Q64 connected over QSPI
#define TOTAL_FLASH_SIZE (8 * 1024 * 1024)

Update QT Py flash size

Update QT Py flash size


#ifndef CJET_PEER_TESTING_H
#define CJET_PEER_TESTING_H

#ifdef TESTING

#ifdef __cplusplus
extern "C" {
#endif

int fake_read(int fd, void *buf, size_t count);
int fake_send(int fd, void *buf, size_t count, int flags);
int fake_writev(int fd, const struct iovec *iov, int iovcnt);

#ifdef __cplusplus
}
#endif

#define READ fake_read
#define SEND fake_send
#define WRITEV fake_writev
#else

#define READ read
#define SEND send
#define WRITEV writev

#endif

#endif

#ifndef CJET_PEER_TESTING_H
#define CJET_PEER_TESTING_H

#ifdef TESTING

#include <sys/uio.h>

#ifdef __cplusplus
extern "C" {
#endif

int fake_read(int fd, void *buf, size_t count);
int fake_send(int fd, void *buf, size_t count, int flags);
int fake_writev(int fd, const struct iovec *iov, int iovcnt);

#ifdef __cplusplus
}
#endif

#define READ fake_read
#define SEND fake_send
#define WRITEV fake_writev
#else

#define READ read
#define SEND send
#define WRITEV writev

#endif

#endif

Add include to provide type struct iovec.


// ImGui SDL2 binding with OpenGL ES 2
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and
// ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui

#ifndef IMGUI_IMPL_SDL_GL2
#define IMGUI_IMPL_SDL_GL2

#include "../../../../../../../imgui.h"

struct SDL_Window;
typedef union SDL_Event SDL_Event;

IMGUI_API bool ImGui_ImplSdlGLES2_Init(SDL_Window *window);
IMGUI_API void ImGui_ImplSdlGLES2_Shutdown();
IMGUI_API void ImGui_ImplSdlGLES2_NewFrame();
IMGUI_API bool ImGui_ImplSdlGLES2_ProcessEvent(SDL_Event *event);

// Use if you want to reset your rendering device without losing ImGui state.
IMGUI_API void ImGui_ImplSdlGLES2_InvalidateDeviceObjects();
IMGUI_API bool ImGui_ImplSdlGLES2_CreateDeviceObjects();

#endif // IMGUI_IMPL_SDL_GL2

// ImGui SDL2 binding with OpenGL ES 2
// You can copy and use unmodified imgui_impl_* files in your project.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and
// ImGui_ImplXXXX_Shutdown().
// See main.cpp for an example of using this.
// https://github.com/ocornut/imgui

#ifndef IMGUI_IMPL_SDL_GL2
#define IMGUI_IMPL_SDL_GL2

#include "imgui/imgui.h"

struct SDL_Window;
typedef union SDL_Event SDL_Event;

IMGUI_API bool ImGui_ImplSdlGLES2_Init(SDL_Window *window);
IMGUI_API void ImGui_ImplSdlGLES2_Shutdown();
IMGUI_API void ImGui_ImplSdlGLES2_NewFrame();
IMGUI_API bool ImGui_ImplSdlGLES2_ProcessEvent(SDL_Event *event);

// Use if you want to reset your rendering device without losing ImGui state.
IMGUI_API void ImGui_ImplSdlGLES2_InvalidateDeviceObjects();
IMGUI_API bool ImGui_ImplSdlGLES2_CreateDeviceObjects();

#endif // IMGUI_IMPL_SDL_GL2

Fix imgui include path in GLES renderer

Fix imgui include path in GLES renderer


//  Copyright © 2015 Outware Mobile. All rights reserved.

#import <Foundation/Foundation.h>

FOUNDATION_EXPORT double RegexVersionNumber;
FOUNDATION_EXPORT const unsigned char RegexVersionString[];

Remove an invalid copyright notice

Remove an invalid copyright notice


// Copyright 2015 Google Inc. 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 PINDROP_ASYNCHRONOUS_LOADER_FILE_LOADER_H_
#define PINDROP_ASYNCHRONOUS_LOADER_FILE_LOADER_H_

#include "fplbase/async_loader.h"

namespace pindrop {

class FileLoader;

class Resource : public fplbase::AsyncAsset {
 public:
  virtual ~Resource() {}

  void LoadFile(const char* filename, FileLoader* loader);

 private:
  virtual void Finalize() {};
};

class FileLoader {
 public:
  void StartLoading();

  bool TryFinalize();

  void QueueJob(Resource* resource);

 private:
  fplbase::AsyncLoader loader;
};

}  // namespace pindrop

#endif  // PINDROP_ASYNCHRONOUS_LOADER_FILE_LOADER_H_

// Copyright 2015 Google Inc. 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 PINDROP_ASYNCHRONOUS_LOADER_FILE_LOADER_H_
#define PINDROP_ASYNCHRONOUS_LOADER_FILE_LOADER_H_

#include "fplbase/async_loader.h"

namespace pindrop {

class FileLoader;

class Resource : public fplbase::AsyncAsset {
 public:
  virtual ~Resource() {}

  void LoadFile(const char* filename, FileLoader* loader);

 private:
  virtual bool Finalize() { return true; };
  virtual bool IsValid() { return true; };
};

class FileLoader {
 public:
  void StartLoading();

  bool TryFinalize();

  void QueueJob(Resource* resource);

 private:
  fplbase::AsyncLoader loader;
};

}  // namespace pindrop

#endif  // PINDROP_ASYNCHRONOUS_LOADER_FILE_LOADER_H_

Update Resource with latest changes to FPLBase.

AsyncAsset had some changes to virtual functions, so Resource,
which inherits from it, needs to be updated.

Tested on Linux.

Change-Id: Ic12854c7d24a04f0049673fa1df6e96a6d68aa15


// RUN: %clang_cc1 -triple x86_64-unknown %s -S -o - | FileCheck %s --check-prefix=CHECK-ABSENT
// CHECK-ABSENT-NOT: section .stack_sizes

// RUN: %clang_cc1 -triple x86_64-unknown -fstack-size-section %s -S -o - | FileCheck %s --check-prefix=CHECK-PRESENT
// CHECK-PRESENT: section .stack_sizes

int foo() { return 42; }

// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -S -o - | FileCheck %s --check-prefix=CHECK-ABSENT
// CHECK-ABSENT-NOT: section .stack_sizes

// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fstack-size-section %s -S -o - | FileCheck %s --check-prefix=CHECK-PRESENT
// CHECK-PRESENT: section .stack_sizes

int foo() { return 42; }

Fix test added in r321992 failing on some buildbots.

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


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

// StringPiece is a simple structure containing a pointer into some external
// storage and a size.  The user of a StringPiece must ensure that the slice
// is not used after the corresponding external storage has been
// deallocated.
//
// Multiple threads can invoke const methods on a StringPiece without
// external synchronization, but if any of the threads may call a
// non-const method, all threads accessing the same StringPiece must use
// external synchronization.

#ifndef TENSORFLOW_CORE_PLATFORM_STRINGPIECE_H_
#define TENSORFLOW_CORE_PLATFORM_STRINGPIECE_H_

#include "absl/strings/string_view.h"

namespace tensorflow {

using StringPiece = absl::string_view;

}  // namespace tensorflow

#endif  // TENSORFLOW_CORE_PLATFORM_STRINGPIECE_H_

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

// StringPiece is a simple structure containing a pointer into some external
// storage and a size.  The user of a StringPiece must ensure that the slice
// is not used after the corresponding external storage has been
// deallocated.
//
// Multiple threads can invoke const methods on a StringPiece without
// external synchronization, but if any of the threads may call a
// non-const method, all threads accessing the same StringPiece must use
// external synchronization.

#ifndef TENSORFLOW_CORE_PLATFORM_STRINGPIECE_H_
#define TENSORFLOW_CORE_PLATFORM_STRINGPIECE_H_

#include "absl/strings/string_view.h"  // IWYU pragma: export

namespace tensorflow {

using StringPiece = absl::string_view;

}  // namespace tensorflow

#endif  // TENSORFLOW_CORE_PLATFORM_STRINGPIECE_H_

Add IWYU tags to headers TF is re-exporting.

PiperOrigin-RevId: 291557362
Change-Id: If78efc5e990f203d5a36777e9531207c573c651a


#ifndef _ALLOCATOR_H
#define _ALLOCATOR_H

#include <stddef.h>

typedef struct allocator_t {
    void  (*cfree)(void *ptr);
} allocator;

#define omf_calloc(nmemb, size) \
    omf_calloc_real((nmemb), (size), __FILE__, __LINE__)
void *omf_calloc_real(size_t nmemb, size_t size, const char *file, int line);

#define omf_realloc(ptr, size) \
    omf_realloc_real((ptr), (size), __FILE__, __LINE__)
void *omf_realloc_real(void *ptr, size_t size, const char *file, int line);

#endif // _ALLOCATOR_H

#ifndef _ALLOCATOR_H
#define _ALLOCATOR_H

#include <stddef.h>

typedef struct allocator_t {
    void  (*cfree)(void *ptr);
} allocator;

#define omf_calloc(nmemb, size) \
    omf_calloc_real((nmemb), (size), __FILE__, __LINE__)
void *omf_calloc_real(size_t nmemb, size_t size, const char *file, int line);

#define omf_realloc(ptr, size) \
    omf_realloc_real((ptr), (size), __FILE__, __LINE__)
void *omf_realloc_real(void *ptr, size_t size, const char *file, int line);

#define omf_free(ptr) { \
    free(ptr);          \
    (ptr) = NULL;       \
}

#endif // _ALLOCATOR_H

utils: Add omf_free() to NULL the argument after free()


#pragma once

#include <iostream>

// The same as assert, but expression is always evaluated and result returned
#define CHECK(expr) (assert(expr), expr)

#if !defined(NDEBUG) // Debug

namespace dev
{
namespace evmjit
{

std::ostream& getLogStream(char const* _channel);

}
}

#define DLOG(CHANNEL) ::dev::evmjit::getLogStream(#CHANNEL)

#else // Release
	#define DLOG(CHANNEL) true ? std::cerr : std::cerr
#endif

#pragma once

#include <iostream>

// The same as assert, but expression is always evaluated and result returned
#define CHECK(expr) (assert(expr), expr)

#if !defined(NDEBUG) // Debug

namespace dev
{
namespace evmjit
{

std::ostream& getLogStream(char const* _channel);

}
}

#define DLOG(CHANNEL) ::dev::evmjit::getLogStream(#CHANNEL)

#else // Release

namespace dev
{
namespace evmjit
{

struct Voider
{
	void operator=(std::ostream const&) {}
};

}
}

#define DLOG(CHANNEL) true ? (void)0 : ::dev::evmjit::Voider{} = std::cerr

#endif

Reimplement no-op version of DLOG to avoid C++ compiler warning


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

#ifndef VISTK_PYTHON_HELPERS_PYTHON_WRAP_CONST_SHARED_PTR_H
#define VISTK_PYTHON_HELPERS_PYTHON_WRAP_CONST_SHARED_PTR_H

#include <boost/python/pointee.hpp>
#include <boost/shared_ptr.hpp>

// Retrieved from http://mail.python.org/pipermail/cplusplus-sig/2006-November/011329.html
namespace boost
{

namespace python
{

template <typename T>
inline
T*
get_pointer(boost::shared_ptr<T const> const& p)
{
  return const_cast<T*>(p.get());
}

template <typename T>
struct pointee<boost::shared_ptr<T const> >
{
  typedef T type;
};

}

}

#endif // VISTK_PYTHON_HELPERS_PYTHON_WRAP_CONST_SHARED_PTR_H

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

#ifndef VISTK_PYTHON_HELPERS_PYTHON_WRAP_CONST_SHARED_PTR_H
#define VISTK_PYTHON_HELPERS_PYTHON_WRAP_CONST_SHARED_PTR_H

#include <boost/python/pointee.hpp>
#include <boost/get_pointer.hpp>
#include <boost/shared_ptr.hpp>

// Retrieved from http://mail.python.org/pipermail/cplusplus-sig/2006-November/011329.html
namespace boost
{

namespace python
{

template <typename T>
inline
T*
get_pointer(boost::shared_ptr<T const> const& p)
{
  return const_cast<T*>(p.get());
}

template <typename T>
struct pointee<boost::shared_ptr<T const> >
{
  typedef T type;
};

// Don't hide other get_pointer instances.
using boost::python::get_pointer;
using boost::get_pointer;

}

}

#endif // VISTK_PYTHON_HELPERS_PYTHON_WRAP_CONST_SHARED_PTR_H

Bring other get_pointer instances into the scope


#ifndef WINDOW_H
#define WINDOW_H

#include <ncurses.h>
#include <array>

#include "../game.h"

// Used to define a datatype for calls to wborder
struct Border {
    chtype ls, rs, ts, bs;
    chtype tl, tr, bl, br;
};

class Window {
    public:
        Window(rect dim); // ctor
       ~Window();         // dtor

        void bindWin(WINDOW *newW);

        int getChar();

        void refresh();
        void update();
        void clear();
        void close();

        void cursorPos(vec2ui pos);

        void draw(vec2ui pos, char ch, chtype colo);
        void draw(vec2ui pos, char ch, chtype colo, int attr);
        void drawBorder();
        void drawBox();
        void write(std::string str);
        void write(vec2ui pos, std::string str);
        void coloSplash(chtype colo);

        rect getDim() { return dim; }

        void setBorder(Border b);

    protected:
        WINDOW *w;
        rect dim;
        Border border { 0,0,0,0,0,0,0,0 };  // Init to default

};

#endif

#ifndef WINDOW_H
#define WINDOW_H

#include <ncurses.h>
#include <string>
#include <array>

#include "../game.h"

// Used to define a datatype for calls to wborder
struct Border {
    chtype ls, rs, ts, bs;
    chtype tl, tr, bl, br;
};

class Window {
    public:
        Window(rect dim); // ctor
       ~Window();         // dtor

        void bindWin(WINDOW *newW);

        int getChar();

        void refresh();
        void update();
        void clear();
        void close();

        void cursorPos(vec2ui pos);

        void draw(vec2ui pos, char ch, chtype colo);
        void draw(vec2ui pos, char ch, chtype colo, int attr);
        void drawBorder();
        void drawBox();
        void write(std::string str);
        void write(vec2ui pos, std::string str);
        void coloSplash(chtype colo);

        rect getDim() { return dim; }

        void setBorder(Border b);

    protected:
        WINDOW *w;
        rect dim;
        Border border { 0,0,0,0,0,0,0,0 };  // Init to default

};

#endif

Fix missing string in namespace std compiler error

On some systems


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

int main() {
  int i,k,j;

  if (k == 5) {
    assert(k == 5);
    return 0;
  }
  assert(k != 5);

  // Signed overflows might occur in some of the following operations (e.g. the first assignment k could be MAX_INT).
  // Signed overflows are undefined behavior, so by default we go to top when they might occur.

  // simple arithmetic
  i = k + 1;
  assert(i != 6); // UNKNOWN!
  i = k - 1;
  assert(i != 4); // UNKNOWN!
  i = k * 3;
  assert(i != 15); // UNKNOWN!
  i = k * 2;
  assert(i != 10); // UNKNOWN! k could be -2147483643;
  i = k / 2;
  assert(i != 2); // UNKNOWN! k could be 4

  return 0;
}

Add test that by default signed overflow results in top


#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ function TPython::Exec;
#pragma link C++ function TPython::Eval;
#pragma link C++ function TPython::Bind;
#pragma link C++ function TPython::Prompt;

#endif

#ifdef __CINT__

#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;

#pragma link C++ class TPython;

#endif

Declare the class TPython instead of the static functions.
With this change, make map will add TPython in system.rootmap
and it is possible to do directly
root > TPython::Prompt()

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@9107 27541ba8-7e3a-0410-8455-c3a389f83636


#ifndef R300_PUBLIC_H
#define R300_PUBLIC_H

struct radeon_winsys;

struct pipe_screen* r300_screen_create(struct radeon_winsys *rws);

#endif

#ifndef R300_PUBLIC_H
#define R300_PUBLIC_H

#ifdef __cplusplus
extern "C" {
#endif

struct radeon_winsys;

struct pipe_screen* r300_screen_create(struct radeon_winsys *rws);

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

#endif

r300g: Fix build, invalid extern "C" around header inclusion.

A previous patch to fix header inclusion within extern "C" neglected
to fix the occurences of this pattern in r300 files.

When the helper to detect this issue was pushed to master, it broke
the build for the r300 driver.  This patch fixes the r300 build.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89477
Reviewed-by: Ilia Mirkin <bcbbb7aa705ec3a5fc5824c01a845186c3d62fca@alum.mit.edu>
Reviewed-by: Jose Fonseca <61b5a29db2c0650f7c8510f93eece059c1b09320@vmware.com>


/*
 * Copyright (C) 2016 Alexander Saprykin <xelfium@gmail.com>
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, see <http://www.gnu.org/licenses/>.
 */

#include "pmem.h"
#include "pspinlock.h"

#ifdef P_OS_VMS
#  include <builtins.h>
#else
#  include <machine/builtins.h>
#endif

struct PSpinLock_ {
	volatile pint spin;
};

P_LIB_API PSpinLock *
p_spinlock_new (void)
{
	PSpinLock *ret;

	if (P_UNLIKELY ((ret = p_malloc0 (sizeof (PSpinLock))) == NULL)) {
		P_ERROR ("PSpinLock::p_spinlock_new: failed to allocate memory");
		return NULL;
	}

	return ret;
}

P_LIB_API pboolean
p_spinlock_lock (PSpinLock *spinlock)
{
	if (P_UNLIKELY (spinlock == NULL))
		return FALSE;

	(void) __LOCK_LONG ((volatile void *) &(spinlock->spin));

	return TRUE;
}

P_LIB_API pboolean
p_spinlock_trylock (PSpinLock *spinlock)
{
	if (P_UNLIKELY (spinlock == NULL))
		return FALSE;

	return __LOCK_LONG_RETRY ((volatile void *) &(spinlock->spin), 1) == 1 ? TRUE : FALSE;
}

P_LIB_API pboolean
p_spinlock_unlock (PSpinLock *spinlock)
{
	if (P_UNLIKELY (spinlock == NULL))
		return FALSE;

	(void) __UNLOCK_LONG ((volatile void *) &(spinlock->spin));

	return TRUE;
}

P_LIB_API void
p_spinlock_free (PSpinLock *spinlock)
{
	p_free (spinlock);
}

Add spinlock model for DEC C compiler

Add spinlock model for DEC C compiler


#ifndef __STDLIB_H__
#define __STDLIB_H__

#include <types.h>

#define abs(ival)		(ival < 0? -ival : ival)

void *malloc(size_t size);
void free(void *addr);
struct task;
void __free(void *addr, struct task *task);

void *memcpy(void *dst, const void *src, size_t len);
void *memset(void *src, int c, size_t len);

#endif /* __STDLIB_H__ */

#ifndef __STDLIB_H__
#define __STDLIB_H__

#include <types.h>

#define abs(ival)		((ival) < 0? -(ival) : (ival))

void *malloc(size_t size);
void free(void *addr);
struct task;
void __free(void *addr, struct task *task);

void *memcpy(void *dst, const void *src, size_t len);
void *memset(void *src, int c, size_t len);

#endif /* __STDLIB_H__ */

Fix missing parenthesis in abs()

Fix missing parenthesis in abs()


#ifndef LOG_H
#define LOG_H

enum log_level {
    LOG_LEVEL_DEBUG = 10,
    LOG_LEVEL_MSG   = 20,
    LOG_LEVEL_WARN  = 30,
    LOG_LEVEL_ERR   = 40
};

void set_log_level(enum log_level threshold);

void log_debug(const char *fmt, ...);
void log_msg(const char *fmt, ...);
void log_warn(const char *fmt, ...);
void log_err(const char *fmt, ...);

void vplog(const int level, const char *fmt, va_list args);
void plog(const int level, const char *fmt, ...);

#endif

#ifndef LOG_H
#define LOG_H

#include <stdarg.h>

enum log_level {
    LOG_LEVEL_DEBUG = 10,
    LOG_LEVEL_MSG   = 20,
    LOG_LEVEL_WARN  = 30,
    LOG_LEVEL_ERR   = 40
};

void set_log_level(enum log_level threshold);

void log_debug(const char *fmt, ...);
void log_msg(const char *fmt, ...);
void log_warn(const char *fmt, ...);
void log_err(const char *fmt, ...);

void vplog(const int level, const char *fmt, va_list args);
void plog(const int level, const char *fmt, ...);

#endif

Fix an error on linux

Fix an error on linux


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

int myglobal;

void *t_fun(void *arg) {
  // awkward formatting to check that warning is just on condition expression, not entire if
  if // NORACE
    (myglobal > 0) { // RACE!
    printf("Stupid!");
    printf("Stupid!");
    printf("Stupid!");
    printf("Stupid!");
    printf("Stupid!");
    printf("Stupid!");
  }
  return NULL;
}

int main(void) {
  pthread_t id;
  pthread_create(&id, NULL, t_fun, NULL);
  myglobal=myglobal+1; // RACE!
  pthread_join (id, NULL);
  return 0;
}

Add test for if condition race location

Add test for if condition race location


#ifndef _OPENLIB_FINITE_H
#define _OPENLIB_FINITE_H

#include <sys/cdefs.h>

#define __BSD_VISIBLE 1

#include <../../build/extbld/third_party/lib/OpenLibm/install/openlibm_math.h>

static inline int finite(double x) {
	return isfinite(x);
}

static inline int finitef(float x) {
	return isfinite(x);
}

static inline int finitel(long double x) {
	return isfinite(x);
}

#if (defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199901L)
__BEGIN_DECLS
extern long long int llabs(long long int j);
__END_DECLS
#endif

#endif /* _OPENLIB_FINITE_H */

#ifndef _OPENLIB_FINITE_H
#define _OPENLIB_FINITE_H

#include <sys/cdefs.h>

#define __BSD_VISIBLE 1

#include <../../build/extbld/third_party/lib/OpenLibm/install/openlibm_math.h>

static inline int finite(double x) {
	return isfinite(x);
}

static inline int finitef(float x) {
	return isfinite(x);
}

static inline int finitel(long double x) {
	return isfinite(x);
}

#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
__BEGIN_DECLS
extern long long int llabs(long long int j);
__END_DECLS
#endif

#endif /* _OPENLIB_FINITE_H */

third-party: Fix openlibm compilation without defined macro __STDC__