typedef struct {
	int		cluster;				/* Condor Cluster # */
	int		proc;					/* Condor Proc # */
	int		job_class;				/* STANDARD, VANILLA, PVM, PIPE, ... */
	uid_t	uid;					/* Execute job under this UID */
	gid_t	gid;					/* Execute job under this pid */
	pid_t	virt_pid;				/* PVM virt pid of this process */
	int		soft_kill_sig;			/* Use this signal for a soft kill */
	char	*a_out_name;			/* Where to get executable file */
	char	*cmd;					/* Command name given by the user */
	char	*args;					/* Command arguments given by the user */
	char	*env;					/* Environment variables */
	char	*iwd;					/* Initial working directory */
	BOOLEAN	ckpt_wanted;			/* Whether user wants checkpointing */
	BOOLEAN	is_restart;				/* Whether this run is a restart */
	BOOLEAN	coredump_limit_exists;	/* Whether user wants to limit core size */
	int		coredump_limit;			/* Limit in bytes */
} STARTUP_INFO;

/*
Should eliminate starter knowing the a.out name.  Should go to
shadow for instructions on how to fetch the executable - e.g. local file
with name <name> or get it from TCP port <x> on machine <y>.
*/

Add comment saying that even though the a.out file name is here, it really shouldn't be.


// $Id$
// Category: sector
//
// Enum AliMpStationType
// ---------------------
// Enumeration for refering to bending and non-bending planes.
//
// Authors: David Guez, Ivana Hrivnacova; IPN Orsay

#ifndef ALI_MP_STATION_TYPE_H
#define ALI_MP_STATION_TYPE_H

enum AliMpStationType
{
  kStation1, // station 1
  kStation2, // station 2
};

#endif //ALI_MP_STATION_TYPE_H

Update for station2: Initial version (I.Hrivnacova)


#ifndef LLIST_H
#define LLIST_H

/* Doubly linked list */
#define DLLIST_PREPEND(list, item) STMT_START { \
	(item)->prev = NULL; \
	(item)->next = *(list); \
	if (*(list) != NULL) (*(list))->prev = (item); \
	*(list) = (item); \
	} STMT_END

#define DLLIST_REMOVE(list, item) STMT_START { \
	if ((item)->prev == NULL) \
		*(list) = (item)->next; \
	else \
		(item)->prev->next = (item)->next; \
	if ((item)->next != NULL) \
		(item)->next->prev = (item)->prev; \
	} STMT_END

#endif

#ifndef LLIST_H
#define LLIST_H

/* Doubly linked list */
#define DLLIST_PREPEND(list, item) STMT_START { \
	(item)->prev = NULL; \
	(item)->next = *(list); \
	if (*(list) != NULL) (*(list))->prev = (item); \
	*(list) = (item); \
	} STMT_END

#define DLLIST_REMOVE(list, item) STMT_START { \
	if ((item)->prev == NULL) \
		*(list) = (item)->next; \
	else \
		(item)->prev->next = (item)->next; \
	if ((item)->next != NULL) { \
		(item)->next->prev = (item)->prev; \
		(item)->next = NULL; \
	} \
	(item)->prev = NULL; \
	} STMT_END

#endif

DLLIST_REMOVE(): Set removed item's prev/next pointers to NULL.

--HG--
branch : HEAD


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

int vasprintf(char **ret, const char *fmt, va_list ap)
{
	char *buf;
	int len;
	size_t buflen;
	va_list ap2;

#ifdef _MSC_VER
	ap2 = ap;
	len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( )
#else
	va_copy(ap2, ap);
	len = vsnprintf(NULL, 0, fmt, ap2);
#endif

	if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
		len = vsnprintf(buf, buflen, fmt, ap);
		*ret = buf;
	} else {
		*ret = NULL;
		len = -1;
	}

	va_end(ap2);
	return len;
}

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

int vasprintf(char **ret, const char *fmt, va_list ap)
{
	char *buf;
	int len;
	size_t buflen;
	va_list ap2;

#if defined(_MSC_VER) || defined(__MINGW64_VERSION_MAJOR)
	ap2 = ap;
	len = _vscprintf(fmt, ap2); // NOTE MS specific extension ( :-( )
#else
	va_copy(ap2, ap);
	len = vsnprintf(NULL, 0, fmt, ap2);
#endif

	if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
		len = vsnprintf(buf, buflen, fmt, ap);
		*ret = buf;
	} else {
		*ret = NULL;
		len = -1;
	}

	va_end(ap2);
	return len;
}

Use _vscprintf() for mingw-w64 compilers

The mingw-w64 compilers implement a vsnprintf() function that do not
conform to the C99 standard (just like MSVC).


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

#pragma once

#include "Stdafx.h"

using namespace CefSharp;

namespace CefSharp
{
    namespace Internals
    {
        public ref class CefRequestCallbackWrapper : public IRequestCallback
        {
        private:
            MCefRefPtr<CefRequestCallback> _callback;
            CefRequestWrapper^ _requestWrapper;

        internal:
            CefRequestCallbackWrapper(CefRefPtr<CefRequestCallback> &callback)
                : CefRequestCallbackWrapper(callback, nullptr)
            {
            }

            CefRequestCallbackWrapper(CefRefPtr<CefRequestCallback> &callback, CefRequestWrapper^ requestWrapper)
                : _callback(callback), _requestWrapper(requestWrapper)
            {
            }

            !CefRequestCallbackWrapper()
            {
                _callback = NULL;
            }

            ~CefRequestCallbackWrapper()
            {
                this->!CefRequestCallbackWrapper();
                if (_requestWrapper != nullptr)
                {
                    delete _requestWrapper;
                }
            }

        public:
            virtual void Continue(bool allow)
            {
                _callback->Continue(allow);
                delete this;
            }

            virtual void Cancel()
            {
                _callback->Cancel();
                delete this;
            }
        };
    }
}

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

#pragma once

#include "Stdafx.h"

using namespace CefSharp;

namespace CefSharp
{
    namespace Internals
    {
        public ref class CefRequestCallbackWrapper : public IRequestCallback
        {
        private:
            MCefRefPtr<CefRequestCallback> _callback;
            IRequest^ _request;

        internal:
            CefRequestCallbackWrapper(CefRefPtr<CefRequestCallback> &callback)
                : CefRequestCallbackWrapper(callback, nullptr)
            {
            }

            CefRequestCallbackWrapper(CefRefPtr<CefRequestCallback> &callback, IRequest^ request)
                : _callback(callback), _request(request)
            {
            }

            !CefRequestCallbackWrapper()
            {
                _callback = NULL;
            }

            ~CefRequestCallbackWrapper()
            {
                this->!CefRequestCallbackWrapper();
                if (_request != nullptr)
                {
                    delete _request;
                }
            }

        public:
            virtual void Continue(bool allow)
            {
                _callback->Continue(allow);
                delete this;
            }

            virtual void Cancel()
            {
                _callback->Cancel();
                delete this;
            }
        };
    }
}

Change to use IRequest instead (use interfaces for classes where possible)


// Scintilla source code edit control
/** @file PlatWin.h
 ** Implementation of platform facilities on Windows.
 **/
// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.

extern bool IsNT();
extern void Platform_Initialise(void *hInstance);
extern void Platform_Finalise();

#if defined(_MSC_VER)
extern bool LoadD2D();
extern ID2D1Factory *pD2DFactory;
extern IDWriteFactory *pIDWriteFactory;
#endif

// Scintilla source code edit control
/** @file PlatWin.h
 ** Implementation of platform facilities on Windows.
 **/
// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.

extern bool IsNT();
extern void Platform_Initialise(void *hInstance);
extern void Platform_Finalise();

#if defined(USE_D2D)
extern bool LoadD2D();
extern ID2D1Factory *pD2DFactory;
extern IDWriteFactory *pIDWriteFactory;
#endif

Allow choice of D2D on compiler command line.


//
//  SecretConstant.example.h
//  PHPHub
//
//  Created by Aufree on 9/30/15.
//  Copyright (c) 2015 ESTGroup. All rights reserved.
//

#if DEBUG
#define Client_id       @"kHOugsx4dmcXwvVbmLkd"
#define Client_secret   @"PuuFCrF94MloSbSkxpwS"
#else
#define Client_id       @"Set up a client id for production env"
#define Client_secret   @"Set up a client secret for production env"
#endif

#define UMENG_APPKEY    @"Set up UMEng App Key"
#define UMENG_QQ_ID     @"Set up qq id"
#define UMENG_QQ_APPKEY @"Set up qq appkey"
#define WX_APP_ID       @"Set up weixin app id"
#define WX_APP_SECRET   @"Set up weixin app secret"
#define TRACKING_ID     @"Set up google anlytics tracking id"

//
//  SecretConstant.example.h
//  PHPHub
//
//  Created by Aufree on 9/30/15.
//  Copyright (c) 2015 ESTGroup. All rights reserved.
//

#if DEBUG
#define Client_id       @"kHOugsx4dmcXwvVbmLkd"
#define Client_secret   @"PuuFCrF94MloSbSkxpwS"
#else
#define Client_id       @"" // Set up a client id for production environment
#define Client_secret   @"" // Set up a client secret for production environment
#endif

#define UMENG_APPKEY    @"" // Set up UMEng App Key
#define UMENG_QQ_ID     @"" // Set up QQ id
#define UMENG_QQ_APPKEY @"" // Set up QQ appkey
#define WX_APP_ID       @"" // Set up wechat app id
#define WX_APP_SECRET   @"" // Set up wechat app secret
#define JPush_APP_KEY   @"" // Set up Jpush App Key
#define TRACKING_ID     @"" // Set up google anlytics tracking id

Update comments of SecretConstant file

Update comments of SecretConstant file


#ifndef ANN_H
#define ANN_H

#define INPUTS 3
#define HIDDEN 5
#define OUTPUTS 2
#define ROWS 5

typedef struct {
    double input[HIDDEN][INPUTS + 1];
    double hidden[ROWS - 3][HIDDEN][HIDDEN + 1];
    double output[OUTPUTS][HIDDEN + 1];
} Links;

typedef struct {
    int input[INPUTS];
    int hidden[ROWS - 2][HIDDEN];
    int output[OUTPUTS];
} Neurons;

typedef struct {
    Links weights;
    Links slopes;
    Neurons values;
} ANN;

void ann_create(ANN *ann)

void ann_mutate(ANN *ann, double increment)

void ann_calculate(ANN *ann, double increment)

void ann_save(ANN *ann, char *filename)

void ann_load(ANN *ann, char *filename)

#endif

Create contents of .h file

Create contents of .h file


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

#define STTY "/bin/stty "
const char RAW[] = STTY "raw";
const char COOKED[] = STTY "cooked";

int main() {
  system(RAW);

  char str[] = "I AM AN IDIOT ";
  size_t len = strlen(str);

  while ( 1 ) {
    for ( size_t i = 0 ; i < len ; i++ ) {
      getchar();
      printf("\b%c", str[i]);
    }
    system(COOKED);
    printf("\n");
    system(RAW);
  }

  return 0;
}

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

#define STTY "/bin/stty "
const char RAW[] = STTY "raw";
const char COOKED[] = STTY "cooked";

const char default_str[] = "I AM AN IDIOT ";

int main(int argc, char **argv) {
  system(RAW);

  const char *str;
  if ( argc == 2 )
    str = argv[1];
  else
    str = default_str;

  size_t len = strlen(str);

  while ( 1 ) {
    for ( size_t i = 0 ; i < len ; i++ ) {
      getchar();
      printf("\b%c", str[i]);
    }
    system(COOKED);
    printf("\n");
    system(RAW);
  }

  return 0;
}

Allow user to choose if they want :)

Allow user to choose if they want :)


//
//  TKDApp.h
//  Tokaido
//
//  Created by Mucho Besos on 10/25/12.
//  Copyright (c) 2012 Tilde. All rights reserved.
//

#import <Cocoa/Cocoa.h>

typedef enum : NSUInteger {
    TKDAppOff,
    TKDAppBooting,
    TKDAppOn,
    TKDAppShuttingDown
} TKDAppState;

@interface TKDApp : MTLModel

@property (nonatomic, copy) NSString *appName;
@property (nonatomic, copy) NSString *appDirectoryPath;
@property (nonatomic, copy) NSString *appHostname;
@property (nonatomic, copy) NSString *appIconPath;

@property (nonatomic, assign) TKDAppState state;
@property (nonatomic, assign) BOOL usesYAMLfile;

/**

 This can be used to init an TKD app instance with a directory, provided the
 directory includes a Tokaido.yaml file with the following entries:

 app_name: App Name
 hostname: app.local
 app_icon: ./icon.png

 */

- (id)initWithTokaidoDirectory:(NSURL *)url;

- (void)showInFinder;
- (void)openInBrowser;
- (void)serializeToYAML;

@end

//
//  TKDApp.h
//  Tokaido
//
//  Created by Mucho Besos on 10/25/12.
//  Copyright (c) 2012 Tilde. All rights reserved.
//

#import <Cocoa/Cocoa.h>

typedef enum : NSUInteger {
    TKDAppOff,
    TKDAppBooting,
    TKDAppOn,
    TKDAppShuttingDown
} TKDAppState;

typedef enum : NSUInteger {
    TKDAppBundling,
    TKDAppBundleFailed,
    TKDAppStartingServer
} TKDAppBootingSubstate;

@interface TKDApp : MTLModel

@property (nonatomic, copy) NSString *appName;
@property (nonatomic, copy) NSString *appDirectoryPath;
@property (nonatomic, copy) NSString *appHostname;
@property (nonatomic, copy) NSString *appIconPath;

@property (nonatomic, assign) TKDAppState state;
@property (nonatomic, assign) TKDAppBootingSubstate bootingSubstate;
@property (nonatomic, assign) BOOL usesYAMLfile;

/**

 This can be used to init an TKD app instance with a directory, provided the
 directory includes a Tokaido.yaml file with the following entries:

 app_name: App Name
 hostname: app.local
 app_icon: ./icon.png

 */

- (id)initWithTokaidoDirectory:(NSURL *)url;

- (void)showInFinder;
- (void)openInBrowser;
- (void)serializeToYAML;

@end

Add booting substate for message

Add booting substate for message


#include "coro.h"
#include "stack.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>

coro *coro_spawn(coro *me, coro_func f, size_t ssize) {
  coro *c = (coro*)malloc(sizeof(coro));
  assert(c != NULL);
  c->running = 0;
  c->base = malloc(ssize);
  assert(c->base != NULL);
  c->stack = c->base + ssize;
  memset(c->base, 0, ssize);
  makestack(&me->stack, &c->stack, f, c);
  return c;
}

coro *coro_init() {
  coro *me = (coro*)malloc(sizeof(coro));
  me->running = 1;
  // We don't need to free this (it's just the main stack segment)
  // so ignore it.
  me->base = NULL;
  // This'll get overridden when we swapstacks out of here.
  me->stack = NULL;
  return me;
}

void destroy_coro(coro *c) {
  free(c->base);
  free(c);
}

#include "coro.h"
#include "stack.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>

coro *coro_spawn(coro *me, coro_func f, size_t ssize) {
  coro *c = (coro*)malloc(sizeof(coro));
  assert(c != NULL);
  c->running = 0;
  c->base = malloc(ssize);
  assert(c->base != NULL);
  c->stack = (char*) c->base + ssize;
  memset(c->base, 0, ssize);
  makestack(&me->stack, &c->stack, f, c);
  return c;
}

coro *coro_init() {
  coro *me = (coro*)malloc(sizeof(coro));
  me->running = 1;
  // We don't need to free this (it's just the main stack segment)
  // so ignore it.
  me->base = NULL;
  // This'll get overridden when we swapstacks out of here.
  me->stack = NULL;
  return me;
}

void destroy_coro(coro *c) {
  free(c->base);
  free(c);
}

Make pointer arithmetic warning go away

Make pointer arithmetic warning go away


#ifndef SEQUENCE_H
#define SEQUENCE_H

#include "object.h"

typedef enum IterType_ {ITERLIST, ITERVECTOR} IterType;

typedef struct Iter_ {
    IterType type;
    union {
        struct {
            Object *node;
            bool first;
        } list;
        struct {
            Object *object;
            int index;
        } vec;
    } u;
} Iter;

bool object_isseq(Object *object);
Iter seq_iter(Object *object);
Object *iter_next(Iter *iter);
int seq_len(Object *object);
Object *seq_nth(Object *object, int n);

#endif

#ifndef SEQUENCE_H
#define SEQUENCE_H

#include "object.h"

typedef enum IterType_ {ITERLIST, ITERVECTOR} IterType;

typedef struct Iter_ {
    IterType type;
    union {
        struct {
            Object *node;
            bool first;
        } list;
        struct {
            Object *object;
            int index;
        } vec;
    } u;
} Iter;

bool object_isseq(Object *object) __attribute__ ((pure));
Iter seq_iter(Object *object);
Object *iter_next(Iter *iter);
int seq_len(Object *object) __attribute__ ((pure));
Object *seq_nth(Object *object, int n) __attribute__ ((pure));

#endif

Mark some functions as pure

Mark some functions as pure


#pragma once
#include <unistd.h>

#include <iostream>
#include <list>
#include <map>
#include <mutex>
#include <unordered_map>
#include <queue>
#include <sstream>
#include <thread>
#include <tuple>
#include <vector>

#pragma once
#include <unistd.h>

#include <iostream>
#include <list>
#include <map>
#include <mutex>
#include <unordered_map>
#include <queue>
#include <sstream>
#include <set>
#include <thread>
#include <tuple>
#include <vector>

Include missing necessary include <set>

Include missing necessary include <set>


/*
 *  xabicc.c - platform-agnostic root for ALien call-outs and callbacks.
 *
 * Support for Call-outs and Call-backs from the IA32ABI Plugin.
 * The plgin is misnamed.  It should be the AlienPlugin, but its history
 * dictates otherwise.
 */
#if i386|i486|i586|i686
# include "ia32abicc.c"
#elif powerpc|ppc
# include "ppcia32abicc.c"
#elif x86_64|x64
# include "x64ia32abicc.o"
#endif

/*
 *  xabicc.c - platform-agnostic root for ALien call-outs and callbacks.
 *
 * Support for Call-outs and Call-backs from the IA32ABI Plugin.
 * The plgin is misnamed.  It should be the AlienPlugin, but its history
 * dictates otherwise.
 */
#if i386|i486|i586|i686
# include "ia32abicc.c"
#elif powerpc|ppc
# include "ppcia32abicc.c"
#elif x86_64|x64|__x86_64|__x86_64__
# include "x64ia32abicc.c"
#endif

Make the list of x64 processor names inclusive enough to compile the Alien
plugin on 64-bit linux.

git-svn-id: http://squeakvm.org/svn/squeak/trunk@3237 fa1542d4-bde8-0310-ad64-8ed1123d492a

Former-commit-id: 600bd5e36821553d6b9391d8bbd8d75d4ad10a85


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

void MatMulC(int rows, int len, double *a, double *b, double *c)
{
  int i,j,k;

  for( i = 0; i < rows; i++ ) {
    for( j = 0; j < rows; j+=2 ) {
      double sum0 = 0.0;
      double sum1 = 0.0;
      for( k = 0; k < rows; k++ ) {
        sum0 += a[i*rows+k] * b[k*rows + j];
        sum1 += a[i*rows+k] * b[k*rows + j + 1];
      }
      c[i*rows + j] = sum0;
      c[i*rows + j+1] = sum1;
    }
  }
}

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

void MatMulC(int rows, int len, double *a, double *bin, double *c)
{
  int i,j,k;
  double *b = malloc(len * sizeof(double));

  // Transpose bin with result in b.
  for(int n = 0; n < len; n++ ) {
    b[n] = bin[rows * (n % rows) + (n / rows)];
  }

  for( i = 0; i < rows; i++ ) {
    for( j = 0; j < rows; j+=2 ) {
      double sum0 = 0.0;
      double sum1 = 0.0;
      for( k = 0; k < rows; k++ ) {
        sum0 += a[i*rows+k] * b[j*rows + k];
        sum1 += a[i*rows+k] * b[(j + 1)*rows + k];
      }
      c[i*rows + j] = sum0;
      c[i*rows + j+1] = sum1;
    }
  }

  free(b);
}

Transpose the second matrix in the C reference for MatMul.


#ifndef _LINEARLAYOUT_H_
#define _LINEARLAYOUT_H_

#include <Element.h>
#include <Command.h>

#define FW_VERTICAL	1
#define FW_HORIZONTAL	2

class LinearLayout : public Element {
 public:
  LinearLayout(int _direction, int _id) : Element(_id), direction(_direction) { }

  bool isA(const std::string & className) override {
    if (className == "LinearLayout") return true;
    return Element::isA(className);
  }

 protected:
  void create() override {
    Command c(Command::CREATE_LINEAR_LAYOUT, getParentInternalId(), getInternalId());
    c.setValue(direction);
    sendCommand(c);
  }

 private:
  int direction = FW_VERTICAL;
};

#endif

#ifndef _LINEARLAYOUT_H_
#define _LINEARLAYOUT_H_

#include <Element.h>
#include <Command.h>

#define FW_VERTICAL	1
#define FW_HORIZONTAL	2

class LinearLayout : public Element {
 public:
  LinearLayout(int _direction, int _id = 0) : Element(_id), direction(_direction) { }

  bool isA(const std::string & className) override {
    if (className == "LinearLayout") return true;
    return Element::isA(className);
  }

 protected:
  void create() override {
    Command c(Command::CREATE_LINEAR_LAYOUT, getParentInternalId(), getInternalId());
    c.setValue(direction);
    sendCommand(c);
  }

 private:
  int direction = FW_VERTICAL;
};

#endif

Add default value to id on constructor

Add default value to id on constructor


#ifndef NEWSBOAT_SCOPEMEASURE_H_
#define NEWSBOAT_SCOPEMEASURE_H_

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

#include "logger.h"

namespace newsboat {

class ScopeMeasure {
public:
	ScopeMeasure(const std::string& func, Level ll = Level::DEBUG);
	~ScopeMeasure();
	void stopover(const std::string& son = "");

private:
	struct timeval tv1, tv2;
	std::string funcname;
	Level lvl;
};

} // namespace newsboat

#endif /* NEWSBOAT_SCOPEMEASURE_H_ */

#ifndef NEWSBOAT_SCOPEMEASURE_H_
#define NEWSBOAT_SCOPEMEASURE_H_

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

#include "logger.h"

namespace newsboat {

class ScopeMeasure {
public:
	ScopeMeasure(const std::string& func, Level ll = Level::DEBUG);
	~ScopeMeasure();
	void stopover(const std::string& son = "");

private:
	struct timeval tv1 = {}, tv2 = {};
	std::string funcname;
	Level lvl = Level::DEBUG;
};

} // namespace newsboat

#endif /* NEWSBOAT_SCOPEMEASURE_H_ */

Initialize all members of ScopeMeasure

Initialize all members of ScopeMeasure

Problem spotted by PVS Studio.


#ifndef TGBOT_EXPORT_H
#define TGBOT_EXPORT_H

#ifndef TGBOT_API
    #ifdef TGBOT_DLL
        #if defined _WIN32 || defined __CYGWIN__
            #define TGBOT_HELPER_DLL_IMPORT __declspec(dllimport)
            #define TGBOT_HELPER_DLL_EXPORT __declspec(dllexport)
        #else
            #if __GNUC__ >= 4
                #define TGBOT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
                #define TGBOT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
            #else
                #define TGBOT_HELPER_DLL_IMPORT
                #define TGBOT_HELPER_DLL_EXPORT
            #endif
        #endif
        #ifdef TgBot_EXPORTS
            #define TGBOT_API TGBOT_HELPER_DLL_EXPORT
        #else
            #define FOX_API TGBOT_HELPER_DLL_IMPORT
        #endif
    #else
        #define TGBOT_API
    #endif
#endif

#endif //TGBOT_EXPORT_H

#ifndef TGBOT_EXPORT_H
#define TGBOT_EXPORT_H

#ifndef TGBOT_API
    #ifdef TGBOT_DLL
        #if defined _WIN32 || defined __CYGWIN__
            #define TGBOT_HELPER_DLL_EXPORT __declspec(dllexport)
            #define TGBOT_HELPER_DLL_IMPORT __declspec(dllimport)
        #else
            #if __GNUC__ >= 4
                #define TGBOT_HELPER_DLL_EXPORT __attribute__ ((visibility ("default")))
                #define TGBOT_HELPER_DLL_IMPORT __attribute__ ((visibility ("default")))
            #else
                #define TGBOT_HELPER_DLL_EXPORT
                #define TGBOT_HELPER_DLL_IMPORT
            #endif
        #endif
        #ifdef TgBot_EXPORTS
            #define TGBOT_API TGBOT_HELPER_DLL_EXPORT
        #else
            #define TGBOT_API TGBOT_HELPER_DLL_IMPORT
        #endif
    #else
        #define TGBOT_API
    #endif
#endif

#endif //TGBOT_EXPORT_H

Fix mistake FOX and reorder EXPORT/IMPORT


#include <atomic>
#include <thread>

typedef std::atomic<int> pseudo_barrier_t;

static inline void pseudo_barrier_wait(pseudo_barrier_t &barrier) {
  --barrier;
  while (barrier > 0)
    std::this_thread::yield();
}

static inline void pseudo_barrier_init(pseudo_barrier_t &barrier, int count) {
  barrier = count;
}

#include <atomic>

// Note that although hogging the CPU while waiting for a variable to change
// would be terrible in production code, it's great for testing since it avoids
// a lot of messy context switching to get multiple threads synchronized.

typedef std::atomic<int> pseudo_barrier_t;

#define pseudo_barrier_wait(barrier)        \
    do                                      \
    {                                       \
        --(barrier);                        \
        while ((barrier).load() > 0)        \
            ;                               \
    } while (0)

#define pseudo_barrier_init(barrier, count) \
    do                                      \
    {                                       \
        (barrier) = (count);                \
    } while (0)

Revert "[test] Address TestConcurrentMany*.py flakiness on macOS"

This reverts my change to pseudo_barrier.h which isn't necessary anymore
after Fred's fix to debugserver and caused TestThreadStepOut to fail.

git-svn-id: 4c4cc70b1ef44ba2b7963015e681894188cea27e@370963 91177308-0d34-0410-b5e6-96231b3b80d8


//
//  StatesController+DragNDrop.h
//  States
//
//  Created by Dmitry Rodionov on 13/06/16.
//  Copyright © 2016 Internals Exposed. All rights reserved.
//

#import "StatesController.h"

@interface StatesController (DragNDrop)

@end

//
//  StatesController+DragNDrop.h
//  States
//
//  Created by Dmitry Rodionov on 13/06/16.
//  Copyright © 2016 Internals Exposed. All rights reserved.
//

#import "StatesController.h"

@interface StatesController (DragNDrop)

// This category implements the following NSTableViewDataSources methods:

- (BOOL)tableView: (NSTableView *)tableView writeRowsWithIndexes: (NSIndexSet *)rowIndexes toPasteboard: (NSPasteboard *)pboard;

- (NSDragOperation)tableView: (NSTableView *)tableView validateDrop: (id <NSDraggingInfo>)info proposedRow: (NSInteger)row proposedDropOperation: (NSTableViewDropOperation)dropOperation;

- (BOOL)tableView: (NSTableView *)tableView acceptDrop: (id <NSDraggingInfo>)info row: (NSInteger)row dropOperation: (NSTableViewDropOperation)dropOperation;

@end

Add missing header into for DragNDrop category on StatesContoller


//@author A0094446X
#pragma once
#ifndef YOU_GUI_STDAFX_H_
#define YOU_GUI_STDAFX_H_
#include <QtWidgets>
#endif  // YOU_GUI_STDAFX_H_

//@author A0094446X
#pragma once
#ifndef YOU_GUI_STDAFX_H_
#define YOU_GUI_STDAFX_H_

#include <memory>
#include <QApplication>
#include <QList>
#include <QWidget>
#include <QtWidgets>

#include <boost/date_time/gregorian/greg_month.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

#endif  // YOU_GUI_STDAFX_H_

Add more files to the PCH for faster compiles.


#pragma once

#include "Control.h"

#include "Button.h"
#include "Checkbox.h"
#include "ComboBox.h"
#include "Label.h"
#include "ListView.h"
#include "Spinner.h"
#include "EditBox.h"

#pragma once

#include "Control.h"

#include "Button.h"
#include "Checkbox.h"
#include "ComboBox.h"
#include "GroupBox.h"
#include "Label.h"
#include "ListView.h"
#include "Spinner.h"
#include "EditBox.h"

Add groupbox to control header

Add groupbox to control header


// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | grep -c {align 1} | grep 2
// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | llvm-as | llc

struct p {
  char a;
  int b;
} __attribute__ ((packed));

struct p t = { 1, 10 };
struct p u;

int main () {
  int tmp = t.b;
  u.b = tmp;
  return tmp;

}

Add a test for the load/store alignment.

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


#include <pygobject.h>
#include <clutter/clutter.h>

void pynbtk_register_classes (PyObject *d);
void pynbtk_add_constants (PyObject *module, const gchar *prefix);

extern PyMethodDef pynbtk_functions[];

DL_EXPORT(void)
init_nbtk(void)
{
    PyObject *m, *d;

    init_pygobject_check (2, 12, 0);

    m = Py_InitModule ("_nbtk", pynbtk_functions);
    d = PyModule_GetDict (m);

    pynbtk_register_classes (d);
    pynbtk_add_constants (m, "NBTK_");

    if (PyErr_Occurred ()) {
        Py_FatalError ("can't initialise module nbtk");
    }
}

#include <pygobject.h>
#include <nbtk/nbtk.h>

void pynbtk_register_classes (PyObject *d);
void pynbtk_add_constants (PyObject *module, const gchar *prefix);

extern PyMethodDef pynbtk_functions[];

static void
sink_nbtkaction (GObject *object)
{
  if (g_object_is_floating (object))
    g_object_ref_sink (object);
}

DL_EXPORT(void)
init_nbtk(void)
{
    PyObject *m, *d;

    init_pygobject_check (2, 12, 0);

    pygobject_register_sinkfunc (NBTK_TYPE_ACTION, sink_nbtkaction);

    m = Py_InitModule ("_nbtk", pynbtk_functions);
    d = PyModule_GetDict (m);

    pynbtk_register_classes (d);
    pynbtk_add_constants (m, "NBTK_");

    if (PyErr_Occurred ()) {
        Py_FatalError ("can't initialise module nbtk");
    }
}

Add a sink function for nbtk.Action

Add a sink function for nbtk.Action

NbtkAction is a GInitiallyUnowned, so we need to register a sinkfunc.


//
//  ADLivelyCollectionView.h
//  ADLivelyCollectionView
//
//  Created by Romain Goyet on 18/04/12.
//  Copyright (c) 2012 Applidium. All rights reserved.
//

#import <UIKit/UIKit.h>

extern NSTimeInterval ADLivelyDefaultDuration;
typedef NSTimeInterval (^ADLivelyTransform)(CALayer * layer, float speed);

extern ADLivelyTransform ADLivelyTransformCurl;
extern ADLivelyTransform ADLivelyTransformFade;
extern ADLivelyTransform ADLivelyTransformFan;
extern ADLivelyTransform ADLivelyTransformFlip;
extern ADLivelyTransform ADLivelyTransformHelix;
extern ADLivelyTransform ADLivelyTransformTilt;
extern ADLivelyTransform ADLivelyTransformWave;
extern ADLivelyTransform ADLivelyTransformGrow;

@interface ADLivelyCollectionView : UICollectionView <UICollectionViewDelegate, UICollectionViewDataSource> {
    id <UICollectionViewDelegate>  _preLivelyDelegate;
    id <UICollectionViewDataSource> _preLivelyDataSource;
    CGPoint _lastScrollPosition;
    CGPoint _currentScrollPosition;
    ADLivelyTransform _transformBlock;
}
- (CGPoint)scrollSpeed;
- (void)setInitialCellTransformBlock:(ADLivelyTransform)block;

@property (nonatomic, assign) CGFloat speedThreshold;
@end

//
//  ADLivelyCollectionView.h
//  ADLivelyCollectionView
//
//  Created by Romain Goyet on 18/04/12.
//  Copyright (c) 2012 Applidium. All rights reserved.
//

#import <UIKit/UIKit.h>

extern NSTimeInterval ADLivelyDefaultDuration;
typedef NSTimeInterval (^ADLivelyTransform)(CALayer * layer, float speed);

extern ADLivelyTransform ADLivelyTransformCurl;
extern ADLivelyTransform ADLivelyTransformFade;
extern ADLivelyTransform ADLivelyTransformFan;
extern ADLivelyTransform ADLivelyTransformFlip;
extern ADLivelyTransform ADLivelyTransformHelix;
extern ADLivelyTransform ADLivelyTransformTilt;
extern ADLivelyTransform ADLivelyTransformWave;
extern ADLivelyTransform ADLivelyTransformGrow;

@interface ADLivelyCollectionView : UICollectionView <UICollectionViewDelegate, UICollectionViewDataSource> {
    id <UICollectionViewDelegate>  _preLivelyDelegate;
    id <UICollectionViewDataSource> _preLivelyDataSource;
    CGPoint _lastScrollPosition;
    CGPoint _currentScrollPosition;
    ADLivelyTransform _transformBlock;
}
- (CGPoint)scrollSpeed;
- (void)setInitialCellTransformBlock:(ADLivelyTransform)block;

@property (nonatomic, assign) CGFloat speedThreshold; // optional, disables animations when exceeding this speed
@end

Add comment for the speed threshold

Add comment for the speed threshold


#include "mode.h"

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

#include <termbox.h>

#include "buf.h"
#include "editor.h"

static void command_mode_key_pressed(editor_t *editor, struct tb_event *ev) {
  char ch;
  switch (ev->key) {
  case TB_KEY_ESC:
    buf_printf(editor->status, "");
    editor->mode = normal_mode();
    return;
  case TB_KEY_BACKSPACE2:
    buf_delete(editor->status, editor->status->len - 1, 1);
    if (editor->status->len == 0) {
      editor->mode = normal_mode();
      return;
    }
    return;
  case TB_KEY_ENTER: {
    char *command = strdup(editor->status->buf + 1);
    editor_execute_command(editor, command);
    free(command);
    editor->mode = normal_mode();
    return;
  }
  case TB_KEY_SPACE:
    ch = ' ';
    break;
  default:
    ch = ev->ch;
  }
  char s[2] = {ch, '\0'};
  buf_insert(editor->status, s, editor->status->len);
}

static editing_mode_t impl = {command_mode_key_pressed};

editing_mode_t *command_mode(void) {
  return &impl;
}

#include "mode.h"

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

#include <termbox.h>

#include "buf.h"
#include "editor.h"

// TODO(isbadawi): Command mode needs a cursor, but modes don't affect drawing.
static void command_mode_key_pressed(editor_t *editor, struct tb_event *ev) {
  char ch;
  switch (ev->key) {
  case TB_KEY_ESC:
    buf_printf(editor->status, "");
    editor->mode = normal_mode();
    return;
  case TB_KEY_BACKSPACE2:
    buf_delete(editor->status, editor->status->len - 1, 1);
    if (editor->status->len == 0) {
      editor->mode = normal_mode();
      return;
    }
    return;
  case TB_KEY_ENTER: {
    char *command = strdup(editor->status->buf + 1);
    editor_execute_command(editor, command);
    free(command);
    editor->mode = normal_mode();
    return;
  }
  case TB_KEY_SPACE:
    ch = ' ';
    break;
  default:
    ch = ev->ch;
  }
  char s[2] = {ch, '\0'};
  buf_insert(editor->status, s, editor->status->len);
}

static editing_mode_t impl = {command_mode_key_pressed};

editing_mode_t *command_mode(void) {
  return &impl;
}

Add TODO re: command mode cursor.

Add TODO re: command mode cursor.

This will also be an issue for visual mode.


//
//  UIActionSheet+RACSignalSupport.h
//  ReactiveCocoa
//
//  Created by Dave Lee on 2013-06-22.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@class RACDelegateProxy;
@class RACSignal;

@interface UIActionSheet (RACSignalSupport)

// A delegate proxy which will be set as the receiver's delegate when any of the
// methods in this category are used.
@property (nonatomic, strong, readonly) RACDelegateProxy *rac_delegateProxy;

// Creates a signal for button clicks on the receiver.
//
// When this method is invoked, the receiver's `delegate` will be set to
// the `rac_delegateProxy` if it is not already. Any existing delegate will be
// set as the proxy's `rac_proxiedDelegate`.
//
// Returns a signal which will send the index of the specific button clicked.
// The signal will complete when the receiver is deallocated.
- (RACSignal *)rac_buttonClickedSignal;

@end

//
//  UIActionSheet+RACSignalSupport.h
//  ReactiveCocoa
//
//  Created by Dave Lee on 2013-06-22.
//  Copyright (c) 2013 GitHub, Inc. All rights reserved.
//

#import <UIKit/UIKit.h>

@class RACDelegateProxy;
@class RACSignal;

@interface UIActionSheet (RACSignalSupport)

// A delegate proxy which will be set as the receiver's delegate when any of the
// methods in this category are used.
@property (nonatomic, strong, readonly) RACDelegateProxy *rac_delegateProxy;

// Creates a signal for button clicks on the receiver.
//
// When this method is invoked, the `rac_delegateProxy` will become the
// receiver's delegate. Any previous delegate will become the -[RACDelegateProxy
// rac_proxiedDelegate], so that it receives any messages that the proxy doesn't
// know how to handle. Setting the receiver's `delegate` afterward is
// considered undefined behavior.
//
// Returns a signal which will send the index of the specific button clicked.
// The signal will complete when the receiver is deallocated.
- (RACSignal *)rac_buttonClickedSignal;

@end

Copy documentation wording from UITextView+RACSignalSupport.h


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

static int RegisterFile[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

int main() {

	int data_memory[1024];
	char string_memeory[2014];
}

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

static int RegisterFile[32] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

int main() {

	int data_memory[1024];
	char* string_memory[2014];
	char* instructions[100];

}

Fix typos, add instruction memory

Fix typos, add instruction memory


#include <stddef.h>
#include "atomic.h"
#include "rmc.h"

///
// Needs to live somewhere else at some point
// Argh, what do we name these.
#include "stdatomic.h"

#define atomic_fixup(e) ((_Atomic(__typeof__(*e))*)(e))

#define rmc_compare_exchange_strong(object, expected, desired)          \
 atomic_compare_exchange_strong_explicit(atomic_fixup(object), expected, \
                         desired, memory_order_relaxed, memory_order_relaxed)
#define rmc_compare_exchange_weak(object, expected, desired)            \
 atomic_compare_exchange_weak_explicit(atomic_fixup(object), expected, \
                         desired, memory_order_relaxed, memory_order_relaxed)
#define rmc_exchange(object, desired)                                   \
 atomic_exchange_explicit(atomic_fixup(object), desired, memory_order_relaxed)
#define rmc_fetch_add(object, operand)                               \
 atomic_fetch_add_explicit(atomic_fixup(object), operand, memory_order_relaxed)
#define rmc_fetch_and(object, operand)                               \
 atomic_fetch_and_explicit(atomic_fixup(object), operand, memory_order_relaxed)
#define rmc_fetch_or(object, operand)                                \
 atomic_fetch_or_explicit(atomic_fixup(object), operand, memory_order_relaxed)
#define rmc_fetch_sub(object, operand)                               \
 atomic_fetch_sub_explicit(atomic_fixup(object), operand, memory_order_relaxed)
#define rmc_fetch_xor(object, operand)                               \
 atomic_fetch_xor_explicit(atomic_fixup(object), operand, memory_order_relaxed)

///

typedef struct mutex_t {
    int locked;
} mutex_t;

void mutex_lock_bad(mutex_t *lock)
{
    XEDGE(lock, post);
    int expected;
    do {
        expected = 0;
    } while (!L(lock, rmc_compare_exchange_weak(&lock->locked, &expected, 1)));
}

void mutex_lock(mutex_t *lock)
{
    XEDGE(lock, loop_out);
    XEDGE(loop_out, post);
    int expected;
    do {
        expected = 0;
    } while (L(lock, rmc_compare_exchange_weak(&lock->locked, &expected, 1)) == 0);
    L(loop_out, 0);
}

void mutex_unlock(mutex_t *lock)
{
    VEDGE(pre, unlock);
    L(unlock, lock->locked = 0);
}

int nus(int *x) {
    return rmc_fetch_and(x, 1337);
}

Add some tests with RMWs

Add some tests with RMWs


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

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

Update Skia milestone to 109

Update Skia milestone to 109

Change-Id: I6acfef789b38f71183304cc3741c119265561b3c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/591477
Reviewed-by: Rakshit Sharma <e91e6cdce3825eaad0fa11b55195605cfed87fab@google.com>
Owners-Override: Kevin Lubick <7cdab2cfab351f23814786ba39716e90eed69047@google.com>
Auto-Submit: Rakshit Sharma <e91e6cdce3825eaad0fa11b55195605cfed87fab@google.com>
Reviewed-by: Kevin Lubick <7cdab2cfab351f23814786ba39716e90eed69047@google.com>
Commit-Queue: Kevin Lubick <7cdab2cfab351f23814786ba39716e90eed69047@google.com>


#pragma once

#include <spotify/json.hpp>

#include "TileLocation.h"

using namespace spotify::json::codec;

namespace spotify
{
namespace json
{

template<>
struct default_codec_t<TileLocation>
{
    static object_t<TileLocation> codec()
    {
        auto codec = object<TileLocation>();
        codec.required("filename", &TileLocation::filename);
        codec.required("x", &TileLocation::x);
        codec.required("y", &TileLocation::y);
        return codec;
    }
};

}
}

Add a codec for TileLocation

Add a codec for TileLocation


#ifndef AC_TLM_BUS_H_
#define AC_TLM_BUS_H_

#include <systemc>
#include "ac_tlm_protocol.H"
#include "ac_tlm_port.H"
#include "ac_memport.H"

// using statements
using tlm::tlm_transport_if;

//#define DEBUG

/// Namespace to isolate bus from ArchC
namespace user
{

/// A TLM bus
class ac_tlm_bus :
  public sc_module,
  public ac_tlm_transport_if // Using ArchC TLM protocol
{
public:
  // Memory communication port
  ac_tlm_port DM_port;

  /// Exposed port with ArchC interface
  sc_export< ac_tlm_transport_if > target_export[4];

  /**
   * Implementation of TLM transport method that
   * handle packets of the protocol doing apropriate actions.
   * This method must be implemented (required by SystemC TLM).
   * @param request is a received request packet
   * @return A response packet to be send
  */
  ac_tlm_rsp transport( const ac_tlm_req &request ) {
    return DM_port->transport(request);
  }

  /**
   * Default constructor.
   */
  ac_tlm_bus(sc_module_name module_name);

  /**
   * Default destructor.
   */
  ~ac_tlm_bus();
};

};

#endif //AC_TLM_BUS_H_

#ifndef AC_TLM_BUS_H_
#define AC_TLM_BUS_H_

#include <systemc>
#include "ac_tlm_protocol.H"
#include "ac_tlm_port.H"
#include "ac_memport.H"

// using statements
using tlm::tlm_transport_if;

//#define DEBUG

/// Namespace to isolate bus from ArchC
namespace user
{

/// A TLM bus
class ac_tlm_bus :
  public sc_module,
  public ac_tlm_transport_if // Using ArchC TLM protocol
{
public:
  // Memory communication port
  ac_tlm_port DM_port;

  /// Exposed port with ArchC interface
  sc_export< ac_tlm_transport_if > target_export[8];

  /**
   * Implementation of TLM transport method that
   * handle packets of the protocol doing apropriate actions.
   * This method must be implemented (required by SystemC TLM).
   * @param request is a received request packet
   * @return A response packet to be send
  */
  ac_tlm_rsp transport( const ac_tlm_req &request ) {
    return DM_port->transport(request);
  }

  /**
   * Default constructor.
   */
  ac_tlm_bus(sc_module_name module_name);

  /**
   * Default destructor.
   */
  ~ac_tlm_bus();
};

};

#endif //AC_TLM_BUS_H_

Make room for 8 processors in the bus.

Make room for 8 processors in the bus.


/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for   *
*  details. If they are missing then this copy is in violation of    *
*  the copyright conditions.                                        */

/*
**	lib_insdel.c
**
**	The routine winsdel(win, n).
**  positive n insert n lines above current line
**  negative n delete n lines starting from current line
**
*/

#include <stdlib.h>
#include "curses.priv.h"
#include "terminfo.h"

int
winsdelln(WINDOW *win, int n)
{
	int ret, sscroll, stop, sbot;

	T(("winsdel(%x,%d) called", win, n));

	if (n == 0)
		return OK;
	if (n < 0 && win->_cury - n >= win->_maxy)
		/* request to delete too many lines */
		/* should we truncate to an appropriate number? */
		return ERR;

	sscroll = win->_scroll;
	stop = win->_regtop;
	sbot = win->_regbottom;

	win->_scroll = TRUE;
	win->_regtop = win->_cury;
	if (win->_regtop > win->_regbottom)
		win->_regbottom = win->_maxy;

	ret = wscrl(win, -n);

	win->_scroll = sscroll;
	win->_regtop = stop;
	win->_regbottom = sbot;

	return ret;
}

/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for   *
*  details. If they are missing then this copy is in violation of    *
*  the copyright conditions.                                        */

/*
**	lib_insdel.c
**
**	The routine winsdel(win, n).
**  positive n insert n lines above current line
**  negative n delete n lines starting from current line
**
*/

#include <stdlib.h>
#include "curses.priv.h"
#include "terminfo.h"

int
winsdelln(WINDOW *win, int n)
{
	int ret, sscroll, stop, sbot;

	T(("winsdel(%x,%d) called", win, n));

	if (n == 0)
		return OK;
	if (n == -1 && win->_cury == win->_maxy)
		return wclrtoeol(win);
	if (n < 0 && win->_cury - n > win->_maxy)
		/* request to delete too many lines */
		/* should we truncate to an appropriate number? */
		return ERR;

	sscroll = win->_scroll;
	stop = win->_regtop;
	sbot = win->_regbottom;

	win->_scroll = TRUE;
	win->_regtop = win->_cury;
	if (win->_regtop > win->_regbottom)
		win->_regbottom = win->_maxy;

	ret = wscrl(win, -n);

	win->_scroll = sscroll;
	win->_regtop = stop;
	win->_regbottom = sbot;

	return ret;
}

Handle the condition where BS is typed while the cursor is
at the first position on either of the last two lines of the
screen.  Ie. append contents of current line to the previous
line and scroll the next line's contents up.

PR:		5392
Submitted by:	Kouichi Hirabayashi <kh@mogami-wire.co.jp>


#include <stdio.h>
#include "common.h"
#include "wisp.h"
#include "lisp.h"

/* parser crap */
extern FILE *yyin;
int yyparse ();
void parser_init ();
extern int interactive;
extern char *prompt;

/* Initilize all the systems. */
void init ()
{
  /* These *must* be called in this order. */
  object_init ();
  symtab_init ();
  cons_init ();
  eval_init ();
  lisp_init ();
  parser_init ();
}

int main (int argc, char **argv)
{
  (void) argc;
  (void) argv;
  init ();

  /* Load core lisp code. */
  interactive = 0;
  yyin = fopen ("core.wisp", "r");
  if (yyin == NULL)
    {
      fprintf (stderr, "error: could not load core lisp.\n");
      exit (EXIT_FAILURE);
    }
  yyparse ();
  fclose (yyin);
  /* yy_flush_buffer(); */

  /* Run interaction. */
  interactive = 1;
  printf ("Happy hacking!\n%s", prompt);
  yyin = stdin;
  yyparse ();
}

#include <stdio.h>
#include "common.h"
#include "wisp.h"
#include "lisp.h"

/* parser crap */
extern FILE *yyin;
int yyparse ();
void parser_init ();
extern int interactive;
extern char *prompt;

/* Initilize all the systems. */
void init ()
{
  /* These *must* be called in this order. */
  object_init ();
  symtab_init ();
  cons_init ();
  eval_init ();
  lisp_init ();
  parser_init ();
}

int main (int argc, char **argv)
{
  (void) argc;
  (void) argv;
  init ();

  /* Load core lisp code. */
  interactive = 0;
  yyin = fopen ("core.wisp", "r");
  if (yyin == NULL)
    {
      fprintf (stderr, "error: could not load core lisp.\n");
      exit (EXIT_FAILURE);
    }
  yyparse ();
  fclose (yyin);
  /* yy_flush_buffer(); */

  /* Run interaction. */
  interactive = 1;
  printf ("Happy hacking!\n%s", prompt);
  yyin = stdin;
  yyparse ();
  printf ("\n");
}

Print newline on clean exit.

Print newline on clean exit.


// ucc -g tim.c

_Noreturn void abort()
{
	__builtin_unreachable();
}

void realloc()
{
	int local = 5;
	abort();
}

Debug label inline function bug

Debug label inline function bug


#define typename(x) _Generic((x),                                                 \
        _Bool: "_BoolÓ,                  unsigned char: "unsigned charÓ,          \
         char: "char",                     signed char: "signed char",            \
       void *: "pointer to voidÓ,                int *: "pointer to int",         \
      default: "other")

#define typename(x) _Generic((x),                                                 \
        _Bool: "_Bool",                  unsigned char: "unsigned char",          \
         char: "char",                     signed char: "signed char",            \
       void *: "pointer to void",                int *: "pointer to int",         \
      default: "other")

Remove unicode from cpp bug example

Remove unicode from cpp bug example


#include "goontools.h"

void usage(char* prog)
{
    fprintf(stderr, "\n");
    fprintf(stderr, "Usage: %s <subcommand> <subcommand arguments>\n", prog);
    fprintf(stderr, "\n");
    fprintf(stderr, "subcommands:\n");
    fprintf(stderr, "    index    index file\n");
    fprintf(stderr, "    sort     sort file\n");
    fprintf(stderr, "    view     view/slice file\n");
    fprintf(stderr, "\n");
}

int dispatch(int argc, char *argv[])
{
    char *subcommands[] = {
        "index",
        "view",
        "sort",
        NULL // sentinel
    };
    Subcommand dispatch[] = {
        &goonindex,
        &goonview,
        &goonsort
    };
    char **s;

    for (s = subcommands; *s != NULL; s += 1) {
        if (strcmp(argv[1], *s) == 0) {
            break;
        }
    }

    if (*s == NULL) {
        usage(argv[0]);
        return -1;
    }

    return dispatch[s-subcommands](argc-2, argv+2);
}

int main(int argc, char *argv[])
{
    if (argc == 1) {
        usage(argv[0]);
        return EXIT_FAILURE;
    }

    if (dispatch(argc, argv) != 0) {
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

#include "goontools.h"

void usage(char* prog)
{
    fprintf(stderr, "\n");
    fprintf(stderr, "Usage: %s <subcommand> <subcommand arguments>\n", prog);
    fprintf(stderr, "\n");
    fprintf(stderr, "subcommands:\n");
    fprintf(stderr, "    index    index file\n");
    fprintf(stderr, "    sort     sort file\n");
    fprintf(stderr, "    view     view/slice file\n");
    fprintf(stderr, "\n");
}

int dispatch(int argc, char *argv[])
{
    char *subcommands[] = {
        "index",
        "view",
        "sort",
        NULL // sentinel
    };
    Subcommand dispatch[] = {
        &goonindex,
        &goonview,
        &goonsort
    };
    char **s;

    for (s = subcommands; *s != NULL; s += 1) {
        if (strcmp(argv[1], *s) == 0) {
            break;
        }
    }

    if (*s == NULL) {
        usage(argv[0]);
        return -1;
    }

    return dispatch[s-subcommands](argc-1, argv+1);
}

int main(int argc, char *argv[])
{
    if (argc == 1) {
        usage(argv[0]);
        return EXIT_FAILURE;
    }

    if (dispatch(argc, argv) != 0) {
        return EXIT_FAILURE;
    }

    return EXIT_SUCCESS;
}

Make subcommands' argc/argv compatible with getopt


#ifndef TIME_HAO
#define TIME_HAO

#include <time.h>

class Timer_hao
{
   public:
    double seconds;
    int    timing_flag;
    time_t timerinit,timerend;
    Timer_hao();
    Timer_hao(double);
    Timer_hao(const Timer_hao& );
    ~Timer_hao();

    Timer_hao& operator  = (const Timer_hao&);

    void init();
    void end();
    void print_init() const;
    void print_end() const;
    void print_accumulation() const;
};

struct tm second_to_tm(double);
#endif

#ifndef TIME_HAO_H
#define TIME_HAO_H

#include <time.h>

class Timer_hao
{
   public:
    double seconds;
    int    timing_flag;
    time_t timerinit,timerend;
    Timer_hao();
    Timer_hao(double);
    Timer_hao(const Timer_hao& );
    ~Timer_hao();

    Timer_hao& operator  = (const Timer_hao&);

    void init();
    void end();
    void print_init() const;
    void print_end() const;
    void print_accumulation() const;
};

struct tm second_to_tm(double);
#endif

Set the header protection to end with _H.


// This program is free software licenced under MIT Licence. You can
// find a copy of this licence in LICENCE.txt in the top directory of
// source code.
//

#ifndef SETTINGS_H_INCLUDED
#define SETTINGS_H_INCLUDED

#include <vector>
#include <tuple>

/**
 * This file contains gereral configuration and thing whoch should be in the
 * global scope
 */

using AdjencyList = std::vector<std::vector<int>>;
using Placements = std::vector<std::pair<int, int>>;
using Movements = std::vector<std::tuple<int, int, int>>;

#define NEUTRAL_ARMIES 2
#define WASTELAND_ARMIES 10

enum class Player {
    ME,
    ENEMY,
    NEUTRAL
};

enum class Request {
    NONE,
    PICK_STARTING_REGION,
    PLACE_ARMIES,
    ATTACK_TRANSFER
};

#endif // MAIN_H_INCLUDED

// This program is free software licenced under MIT Licence. You can
// find a copy of this licence in LICENCE.txt in the top directory of
// source code.
//

#ifndef SETTINGS_H_INCLUDED
#define SETTINGS_H_INCLUDED

#include <vector>
#include <tuple>

/**
 * This file contains gereral configuration and thing whoch should be in the
 * global scope
 */

using AdjencyList = std::vector<std::vector<int>>;
using Placements = std::vector<std::pair<int, int>>;
using Movements = std::vector<std::tuple<int, int, int>>;

#define NEUTRAL_ARMIES 2
#define WASTELAND_ARMIES 6

enum class Player {
    ME,
    ENEMY,
    NEUTRAL
};

enum class Request {
    NONE,
    PICK_STARTING_REGION,
    PLACE_ARMIES,
    ATTACK_TRANSFER
};

#endif // MAIN_H_INCLUDED

Update number of armies on wastelands

Update number of armies on wastelands


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

@import MatrixSDK;
@import MatrixKit;

#import "WebViewViewController.h"
#import "RiotNavigationController.h"
#import "ThemeService.h"
#import "TableViewCellWithCheckBoxAndLabel.h"
#import "RecentsDataSource.h"
#import "AvatarGenerator.h"
#import "EncryptionInfoView.h"
#import "EventFormatter.h"
#import "MediaPickerViewController.h"
#import "AppDelegate.h"
#import "RoomBubbleCellData.h"
#import "MXKRoomBubbleTableViewCell+Riot.h"

Add RoomBubbleCellData.h and MXKRoomBubbleTableViewCell+Riot.h to Objective-C bridging header.


#ifndef CILKPLUS_H
#define CILKPLUS_H

#include <cilk/cilk.h>

#define fibril
#define fibril_t __attribute__((unused)) int
#define fibril_init(fp)
#define fibril_join(fp) cilk_sync

#define fibril_fork_nrt(fp, fn, ag)     cilk_spawn fn ag
#define fibril_fork_wrt(fp, rt, fn, ag) rt = cilk_spawn fn ag

#define fibril_rt_init(n)
#define fibril_rt_exit()
#define fibril_rt_nprocs(n) \
  (n > 0 ? __cilkrts_set_param("nworkers", #n) : __cilkrts_get_nworkers())

#endif /* end of include guard: CILKPLUS_H */

#ifndef CILKPLUS_H
#define CILKPLUS_H

#include <cilk/cilk.h>

#define fibril
#define fibril_t __attribute__((unused)) int
#define fibril_init(fp)
#define fibril_join(fp) cilk_sync

#define fibril_fork_nrt(fp, fn, ag)     cilk_spawn fn ag
#define fibril_fork_wrt(fp, rt, fn, ag) rt = cilk_spawn fn ag

#define fibril_rt_init(n) (__cilkrts_set_param("stack size", "0x800000"))
#define fibril_rt_exit()
#define fibril_rt_nprocs(n) \
  (n > 0 ? __cilkrts_set_param("nworkers", #n) : __cilkrts_get_nworkers())

#endif /* end of include guard: CILKPLUS_H */

Use 8MB as the default stack size in CilkPlus.


#include <stdio.h>

void SpinYetAgain()
{
    volatile unsigned int count = 0;
    for(int i=0; i<1000; i++)
    {
        count++;
    }
}

void SpinSomeMore()
{
    volatile unsigned int count = 0;
    for(int i=0; i<1000; i++)
    {
        count++;
    }

    SpinYetAgain();
}

void Spin()
{
    volatile unsigned int count = 0;
    for(int i=0; i<1000; i++)
    {
        count++;
    }

    SpinSomeMore();
}

int main(int argc, char* argv[])
{
    while(1)
    {
        Spin();
    }
}

#include <stdio.h>

void SpinYetAgain()
{
    volatile unsigned int count = 0;
    int i;
    for(i=0; i<1000; i++)
    {
        count++;
    }
}

void SpinSomeMore()
{
    volatile unsigned int count = 0;
    int i;
    for(i=0; i<1000; i++)
    {
        count++;
    }

    SpinYetAgain();
}

void Spin()
{
    volatile unsigned int count = 0;
    int i;
    for(i=0; i<1000; i++)
    {
        count++;
    }

    SpinSomeMore();
}

int main(int argc, char* argv[])
{
    while(1)
    {
        Spin();
    }
}

Fix C declaration errors on ARM.

Fix C declaration errors on ARM.


// project-specific definitions for otaa sensor
//#define CFG_eu868 1
//#define CFG_us915 1
//#define CFG_au921 1
#define CFG_as923 1
#define LMIC_COUNTRY_CODE   LMIC_COUNTRY_CODE_JP
//#define CFG_in866 1
#define CFG_sx1276_radio 1
//#define LMIC_USE_INTERRUPTS
#define LMIC_DEBUG_LEVEL 2
#define LMIC_DEBUG_PRINTF_FN lmic_printf

Set debug level to 2 and use a suitable printf function


#ifndef KVAZAAR_INTERNAL_H_
#define KVAZAAR_INTERNAL_H_
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
* COPYING file).
*
* Kvazaar 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.
*
* Kvazaar 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 General Public License along
* with Kvazaar.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#include "kvazaar.h"

// Forward declarations.
typedef struct encoder_state_t encoder_state_t;
typedef struct encoder_control_t encoder_control_t;

typedef struct kvz_encoder {
  encoder_control_t* control;
  encoder_state_t* states;
  unsigned num_encoder_states;
  unsigned cur_state_num;
  unsigned frames_started;
  unsigned frames_done;

  size_t bitstream_length;
} kvz_encoder;

#endif // KVAZAAR_INTERNAL_H_

#ifndef KVAZAAR_INTERNAL_H_
#define KVAZAAR_INTERNAL_H_
/*****************************************************************************
* This file is part of Kvazaar HEVC encoder.
*
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
* COPYING file).
*
* Kvazaar 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.
*
* Kvazaar 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 General Public License along
* with Kvazaar.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#include "kvazaar.h"

// Forward declarations.
struct encoder_state_t;
struct encoder_control_t;

struct kvz_encoder {
  struct encoder_control_t* control;
  struct encoder_state_t* states;
  unsigned num_encoder_states;
  unsigned cur_state_num;
  unsigned frames_started;
  unsigned frames_done;

  size_t bitstream_length;
};

#endif // KVAZAAR_INTERNAL_H_

Fix compilation warnings when using clang.

Removes typedef redefinitions in kvazaar_internal.h.


//
//  AMShortcutsPreferencesViewController.h
//  Amethyst
//
//  Created by Ian Ynda-Hummel on 4/26/14.
//  Copyright (c) 2014 Ian Ynda-Hummel. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <MASPreferences/MASPreferencesViewController.h>

@interface AMShortcutsPreferencesViewController : NSViewController

@end

//
//  AMShortcutsPreferencesViewController.h
//  Amethyst
//
//  Created by Ian Ynda-Hummel on 4/26/14.
//  Copyright (c) 2014 Ian Ynda-Hummel. All rights reserved.
//

#import <Cocoa/Cocoa.h>

@interface AMShortcutsPreferencesViewController : NSViewController

@end

Remove import from previously-removed MASPreferences


#include <stdlib.h>
#ifndef __STACK_H__
#define __STACK_H__
struct Stack;
typedef struct Stack Stack;
#endif

#include <stdlib.h>
#ifndef __STACK_H__
#define __STACK_H__
struct Stack;
typedef struct Stack Stack;

void Push(Stack s, void* e);
void* Pop(Stack s);
int Stack_Empty(Stack s);
#endif

Add basic operation function declaration


/*
 * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
 *
 * This program is distributed under the terms of the MIT license.
 * See the included MIT-LICENSE file for the terms of this license.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include "common.h"

/* OpenGL 3DFX extensions */

/* #208 - GL_3DFX_tbuffer */
GL_FUNC_LOAD_1(TbufferMask3DFX,GLvoid, GLuint, "GL_3DFX_tbuffer")

void gl_init_functions_ext_3dfx(VALUE module)
{
/* #208 - GL_3DFX_tbuffer */
	rb_define_module_function(module, "glTbufferMask3DFX", gl_TbufferMask3DFX, 1);
}

/*
 * Copyright (C) 2007 Jan Dvorak <jan.dvorak@kraxnet.cz>
 *
 * This program is distributed under the terms of the MIT license.
 * See the included MIT-LICENSE file for the terms of this license.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#include "common.h"

/* OpenGL 3DFX extensions */

/* #208 - GL_3DFX_tbuffer */
GL_FUNC_LOAD_1(TbufferMask3DFX,GLvoid, GLuint, "GL_3DFX_tbuffer")

void gl_init_functions_ext_3dfx(VALUE klass)
{
/* #208 - GL_3DFX_tbuffer */
	rb_define_method(klass, "glTbufferMask3DFX", gl_TbufferMask3DFX, 1);
}

Change remaining glTbufferMask3DFX to an instance method.


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

int isPrime(unsigned long x)
{
    if (sqrt(x) - (unsigned long)sqrt(x) == 0)
        return 0;
    for (unsigned long i = 2; i < ceil(sqrt(x)); i++)
        if (x % i == 0)
            return 0;
    return 1;
}

int main( int argc, char** argv)
{
    unsigned long max = atol(argv[1]);
    unsigned long *a = malloc(sizeof(unsigned long) * max);
    unsigned long x = 2;
    for (unsigned long i = 0; i < max; x++)
        if (isPrime(x))
            a[i++] = x;
    for (unsigned long i = 0; i < max; i++)
        printf("%lu\n", (unsigned long)a[i]);
    return 0;
}

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

int isPrime(unsigned int x)
{
    if (sqrt(x) - (unsigned int)sqrt(x) == 0)
        return 0;
    for (unsigned int i = 2; i < ceil(sqrt(x)); i++)
        if (x % i == 0)
            return 0;
    return 1;
}

int main( int argc, char** argv)
{
    unsigned int max = atol(argv[1]);
    unsigned int *a = malloc(sizeof(unsigned int) * max);
    unsigned int x = 2;
    for (unsigned int i = 0; i < max; x++)
        if (isPrime(x))
            a[i++] = x;
    for (unsigned int i = 0; i < max; i++)
        printf("%u\n", (unsigned int)a[i]);
    return 0;
}

Replace long with int in the C version to improve performance.


#ifdef _WIN32
#define DL_EXPORT __declspec( dllexport )
#else
#define DL_EXPORT
#endif

DL_EXPORT int TestDynamicLoaderData;

DL_EXPORT void TestDynamicLoaderFunction()
{
}

#ifdef _WIN32
#define DL_EXPORT __declspec( dllexport )
#else
#define DL_EXPORT
#endif

DL_EXPORT int TestDynamicLoaderData = 0;

DL_EXPORT void TestDynamicLoaderFunction()
{
}

COMP: Fix compilation on MacOSX (common symbols not allowed with MH_DYLIB output format)


/*
 * Copyright (c) 2004 Suleiman Souhlal <refugee@segfaulted.com>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the author nor the names of any co-contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY DAVID O'BRIEN AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD$
 */

#ifndef _FLOATINGPOINT_H_
#define _FLOATINGPOINT_H_

#include <machine/ieeefp.h>

#endif /* !_FLOATINGPOINT_H_ */

Add sys file required for IEEE fp functions.

Submitted by:  Suleiman Souhlal <refugee@segfaulted.com>


// RUN: %clang_cc1 -fdouble-square-bracket-attributes -std=c11 -E %s -o - | FileCheck %s

// CHECK: has_fallthrough
#if __has_c_attribute(fallthrough)
  int has_fallthrough();
#endif

// CHECK: does_not_have_selectany
#if !__has_c_attribute(selectany)
  int does_not_have_selectany();
#endif

Correct line endings that got mixed up in r320088; NFC.

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


#include <stdio.h>
#include <stdlib.h>
#include "rxvm.h"
#include "test_common.h"
#include "test_modules.h"

#define NUM_MODS          7

const testmod_t mods[NUM_MODS] = {
    test_rxvm_err, test_rxvm_match, test_rxvm_search,
    test_rxvm_search_nomatch, test_rxvm_compile, test_fuzz_rxvm_match,
    test_fuzz_full_rxvm_match
};

int main (void)
{
    testmod_t module;
    int i;
    int ret;
    int count;

    count = 1;
    ret = 0;

    printf("1..%d\n", NUM_TESTS);
    /* Run all test modules */
    for (i = 0; i < NUM_MODS; ++i) {
        module = mods[i];
        ret += (*module)(&count);
    }

	return ret;
}

#include <stdio.h>
#include <stdlib.h>
#include "rxvm.h"
#include "test_common.h"
#include "test_modules.h"

//#define NUM_MODS          7
#define NUM_MODS          6

const testmod_t mods[NUM_MODS] = {
    test_rxvm_err, test_rxvm_match, test_rxvm_search,
    test_rxvm_search_nomatch, test_rxvm_compile, test_fuzz_rxvm_match,
    //test_fuzz_full_rxvm_match
};

int main (void)
{
    testmod_t module;
    int i;
    int ret;
    int count;

    count = 1;
    ret = 0;

    printf("1..%d\n", NUM_TESTS);
    /* Run all test modules */
    for (i = 0; i < NUM_MODS; ++i) {
        module = mods[i];
        ret += (*module)(&count);
    }

	return ret;
}

Disable fuzz_full test until fixed

Disable fuzz_full test until fixed


#include <termios.h>
#include <unistd.h>

void enableRawMode() {
  struct termios raw;

  tcgetattr(STDIN_FILENO, &raw);

  raw.c_lflag &= ~(ECHO);

  tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}

int main() {
  enableRawMode();

  char c;
  while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q');
  return 0;
}

#include <stdlib.h>
#include <termios.h>
#include <unistd.h>

struct termios orig_termios;

void disableRawMode() {
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}

void enableRawMode() {
  tcgetattr(STDIN_FILENO, &orig_termios);
  atexit(disableRawMode);

  struct termios raw = orig_termios;
  raw.c_lflag &= ~(ECHO);

  tcsetattr(STDIN_FILENO, TCSAFLUSH, &raw);
}

int main() {
  enableRawMode();

  char c;
  while (read(STDIN_FILENO, &c, 1) == 1 && c!= 'q');
  return 0;
}

Disable raw mode when exiting

Disable raw mode when exiting


//
//  BBlock.h
//  BBlock
//
//  Created by David Keegan on 4/10/12.
//  Copyright (c) 2012 David Keegan. All rights reserved.
//

#import <Foundation/Foundation.h>

/// For when you need a weak reference of an object, example: `BBlockWeakObject(obj) wobj = obj;`
#define BBlockWeakObject(o) __weak typeof(o)

/// For when you need a weak reference to self, example: `BBlockWeakSelf wself = self;`
#define BBlockWeakSelf BBlockWeakObject(self)

@interface BBlock : NSObject

/// Execute the block on the main thread
+ (void)dispatchOnMainThread:(void (^)())block;

/// Exectute the block on a background thread but in a synchronous queue
+ (void)dispatchOnSynchronousQueue:(void (^)())block;

/// Exectute the block on a background thread but in a synchronous queue,
/// This queue should only be used for writing files to disk.
+ (void)dispatchOnSynchronousFileQueue:(void (^)())block;

+ (void)dispatchOnDefaultPriorityConcurrentQueue:(void (^)())block;
+ (void)dispatchOnLowPriorityConcurrentQueue:(void (^)())block;
+ (void)dispatchOnHighPriorityConcurrentQueue:(void (^)())block;

@end

//
//  BBlock.h
//  BBlock
//
//  Created by David Keegan on 4/10/12.
//  Copyright (c) 2012 David Keegan. All rights reserved.
//

#import <Foundation/Foundation.h>

/// For when you need a weak reference of an object, example: `BBlockWeakObject(obj) wobj = obj;`
#define BBlockWeakObject(o) __weak __typeof__((__typeof__(o))o)

/// For when you need a weak reference to self, example: `BBlockWeakSelf wself = self;`
#define BBlockWeakSelf BBlockWeakObject(self)

@interface BBlock : NSObject

/// Execute the block on the main thread
+ (void)dispatchOnMainThread:(void (^)())block;

/// Exectute the block on a background thread but in a synchronous queue
+ (void)dispatchOnSynchronousQueue:(void (^)())block;

/// Exectute the block on a background thread but in a synchronous queue,
/// This queue should only be used for writing files to disk.
+ (void)dispatchOnSynchronousFileQueue:(void (^)())block;

+ (void)dispatchOnDefaultPriorityConcurrentQueue:(void (^)())block;
+ (void)dispatchOnLowPriorityConcurrentQueue:(void (^)())block;
+ (void)dispatchOnHighPriorityConcurrentQueue:(void (^)())block;

@end

Revert "with Xcode4.4 __weak typeof(o) is all that's needed for weak references"

This reverts commit 7689903fd592848310bf12743dcec7805cd37098.


#include <stdint.h>

void __wasm_call_ctors(void);

int __argc(void);
void __argv(uintptr_t[static 1]);
void __args(char[static 1]);

int main(int, char**);

void _start(void)
{
    int argc = __argc();
    char* argv[argc + 1];
    __argv((uintptr_t*)argv);

    char args[(uintptr_t)argv[argc]];
    __args(args);

    for (int i = 0; i < argc; ++i)
        argv[i] = args + (uintptr_t)argv[i];

    argv[argc] = (void*)0;

    __wasm_call_ctors();
    main(argc, argv);
}

#include <stdint.h>

void __wasm_call_ctors(void);

/*!
 * `argc` getter
 *
 * This function returns 0 if passing arguments to main() is unsupported.
 */
int __argc(void);

/*!
 * `argv` builder
 *
 * This function stores `argv` as offset from `argv[0]`,
 * and appends `sizeof(args)`.
 *
 * For example, if the command line is `foo -c alfa`,
 * { 0, 4, 7, 12 } will be written because
 *
 *     argv[0] = args + 0
 *     argv[1] = args + 4
 *     argv[2] = args + 7
 *     sizeof(args) = 12
 *
 * See __args() for format of `args`.
 */
void __argv(uintptr_t* argv);

/*!
 * This function stores null-separated command line.
 *
 * For example, if the command line is `foo -c alfa`,
 * it is stored as `"foo\0-c\0alfa"`.
 * Note that there is an implied '\0' at the end of a string.
 */
void __args(char* args);

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

void _start(void)
{
    int argc = __argc();
    char* argv[argc + 1];
    __argv((uintptr_t*)argv);

    char args[argc ? (uintptr_t)argv[argc] : 0];
    __args(args);

    for (int i = 0; i < argc; ++i)
        argv[i] = args + (uintptr_t)argv[i];

    argv[argc] = (void*)0;

    __wasm_call_ctors();
    main(argc, argv);
}

Document on getters of argc and argv

Document on getters of argc and argv


// Copyright (c) 2016 Ed Schouten <ed@nuxi.nl>
//
// This file is distributed under a 2-clause BSD license.
// See the LICENSE file for details.

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

#include "infiniteloop.h"

static bool print_solution(const struct il_solution *s, void *thunk) {
  char buf[1024];
  if (!il_solution_print(s, buf, sizeof(buf))) {
    fprintf(stderr, "Failed to print solution\n");
    exit(1);
  }
  printf("-- SOLUTION --\n%s\n", buf);
  return true;
}

int main(void) {
  char buf[1024];
  size_t len = fread(buf, 1, sizeof(buf) - 1, stdin);
  buf[len] = '\0';

  struct il_problem p;
  if (!il_problem_parse(buf, &p)) {
    fprintf(stderr, "Failed to parse input\n");
    return 1;
  }

  il_solve(&p, print_solution, NULL);
  return 0;
}

// Copyright (c) 2016 Ed Schouten <ed@nuxi.nl>
//
// This file is distributed under a 2-clause BSD license.
// See the LICENSE file for details.

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

#include "infiniteloop.h"

static unsigned int solutions_found = 0;

static bool print_solution(const struct il_solution *s, void *thunk) {
  char buf[1024];
  if (!il_solution_print(s, buf, sizeof(buf))) {
    fprintf(stderr, "Failed to print solution\n");
    exit(1);
  }
  printf("-- SOLUTION --\n%s\n", buf);
  ++solutions_found;
  return true;
}

int main(void) {
  char buf[1024];
  size_t len = fread(buf, 1, sizeof(buf) - 1, stdin);
  buf[len] = '\0';

  struct il_problem p;
  if (!il_problem_parse(buf, &p)) {
    fprintf(stderr, "Failed to parse input\n");
    return 1;
  }

  il_solve(&p, print_solution, NULL);

  printf("-- FOUND %u SOLUTIONS --\n", solutions_found);
  return 0;
}

Print the number of solutions.

Print the number of solutions.


//
//  MHClientSecret.h
//  MyHub
//
//  Created by Arcterus on 1/14/14.
//  Copyright (c) 2014 kRaken Research. All rights reserved.
//

#ifndef MyHub_MHClientSecret_h
#define MyHub_MHClientSecret_h

#define CLIENT_ID     "1234567890"
#define CLIENT_SECRET "1234567890abcdef"

#endif

Add file with dummy client info

Add file with dummy client info


#include <MacHeaders>
#include <string.h>

/* Interface used by tokenizer.c */

guesstabsize(path)
	char *path;
{
	char s[256];
	int refnum;
	Handle h;
	int tabsize = 0;
	s[0] = strlen(path);
	strncpy(s+1, path, s[0]);
	refnum = OpenResFile(s);
/* printf("%s --> refnum=%d\n", path, refnum); */
	if (refnum == -1)
		return 0;
	UseResFile(refnum);
	h = GetIndResource('ETAB', 1);
	if (h != 0) {
		tabsize = (*(short**)h)[1];
/* printf("tabsize=%d\n", tabsize); */
	}
	CloseResFile(refnum);
	return tabsize;
}

#include <Types.h>
#include <Files.h>
#include <OSUtils.h>
#include <Resources.h>

#include <string.h>

/* Interface used by tokenizer.c */

guesstabsize(path)
	char *path;
{
	char s[256];
	int refnum;
	Handle h;
	int tabsize = 0;
	s[0] = strlen(path);
	strncpy(s+1, path, s[0]);
	refnum = OpenResFile(s);
/* printf("%s --> refnum=%d\n", path, refnum); */
	if (refnum == -1)
		return 0;
	UseResFile(refnum);
	h = GetIndResource('ETAB', 1);
	if (h != 0) {
		tabsize = (*(short**)h)[1];
/* printf("tabsize=%d\n", tabsize); */
	}
	CloseResFile(refnum);
	return tabsize;
}

Replace <MacHeaders> by specific required header files


/* There is no include guard here - by purpose. This file can be included
 * after system includes that redefine the assert() macro.
 * The actual problem for which this file got separated from utilities.h
 * happens in the sat-solver code, when local include files include
 * Solver.h which in turn includes the system's assert.h. */

#include "error.h" /* for prt_error() */

#ifndef STRINGIFY
#define STR(x) #x
#define STRINGIFY(x) STR(x)
#endif /* STRINGIFY */

#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)

#ifdef _WIN32
#define DEBUG_TRAP (*((volatile int*) 0x0) = 42)
#else
#define DEBUG_TRAP __builtin_trap()
#endif

#define assert(ex, ...) {                                                   \
	if (!(ex)) {                                                             \
		prt_error("Fatal error: \nAssertion (" #ex ") failed at " FILELINE ": " __VA_ARGS__);  \
		prt_error("\n");                                                \
		DEBUG_TRAP;  /* leave stack trace in debugger */                      \
	}                                                                        \
}

/* There is no include guard here - by purpose. This file can be included
 * after system includes that redefine the assert() macro.
 * The actual problem for which this file got separated from utilities.h
 * happens in the sat-solver code, when local include files include
 * Solver.h which in turn includes the system's assert.h. */

#include "error.h" /* for prt_error() */

#ifndef STRINGIFY
#define STR(x) #x
#define STRINGIFY(x) STR(x)
#endif /* STRINGIFY */

#define FILELINE __FILE__ ":" STRINGIFY(__LINE__)

#ifdef _WIN32
#define DEBUG_TRAP (*((volatile int*) 0x0) = 42)
#else
#define DEBUG_TRAP __builtin_trap()
#endif

#define assert(ex, ...) {                                                   \
	if (!(ex)) {                                                             \
		fprintf(stderr, "Fatal error: \nAssertion (" #ex ") failed at " FILELINE ": " __VA_ARGS__);  \
		fprintf(stderr, "\n");                                                \
		DEBUG_TRAP;  /* leave stack trace in debugger */                      \
	}                                                                        \
}

assert(): Use fprintf() to ensure message printing

If prt_error() is used and the error facility uses a non-default error
handler, the message will get lost.


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

  Program: Visomics

  Copyright (c) Kitware, 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.

=========================================================================*/
#ifndef __voMongoSaveDialog_h
#define __voMongoSaveDialog_h

// Qt includes
#include <QDialog>

class voRemoteAnalysisConnectionDialogPrivate;

class voRemoteAnalysisConnectionDialog : public QDialog
{
  Q_OBJECT
public:
  typedef QDialog Superclass;

  voRemoteAnalysisConnectionDialog(QWidget* newParent = 0);
  virtual ~voRemoteAnalysisConnectionDialog();

  QString Url();
  QString User();
  QString Password();

private:
  QScopedPointer<voRemoteAnalysisConnectionDialogPrivate> d_ptr;
  Q_DECLARE_PRIVATE(voRemoteAnalysisConnectionDialog);
  Q_DISABLE_COPY(voRemoteAnalysisConnectionDialog);

  void loadSettings();

private slots:
  void saveSettings();
};

#endif

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

  Program: Visomics

  Copyright (c) Kitware, 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.

=========================================================================*/
#ifndef __voRemoteAnalysisConnectionDialog_h
#define __voRemoteAnalysisConnectionDialog_h

// Qt includes
#include <QDialog>

class voRemoteAnalysisConnectionDialogPrivate;

class voRemoteAnalysisConnectionDialog : public QDialog
{
  Q_OBJECT
public:
  typedef QDialog Superclass;

  voRemoteAnalysisConnectionDialog(QWidget* newParent = 0);
  virtual ~voRemoteAnalysisConnectionDialog();

  QString Url();
  QString User();
  QString Password();

private:
  QScopedPointer<voRemoteAnalysisConnectionDialogPrivate> d_ptr;
  Q_DECLARE_PRIVATE(voRemoteAnalysisConnectionDialog);
  Q_DISABLE_COPY(voRemoteAnalysisConnectionDialog);

  void loadSettings();

private slots:
  void saveSettings();
};

#endif

Fix copy/paste error in header guard

Fix copy/paste error in header guard


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

#ifndef ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_

#include "brightray/browser/browser_main_parts.h"

namespace atom {

class AtomBrowserBindings;
class Browser;
class NodeBindings;

class AtomBrowserMainParts : public brightray::BrowserMainParts {
 public:
  AtomBrowserMainParts();
  virtual ~AtomBrowserMainParts();

  static AtomBrowserMainParts* Get();

  AtomBrowserBindings* atom_bindings() { return atom_bindings_.get(); }
  Browser* browser() { return browser_.get(); }

 protected:
  // Implementations of brightray::BrowserMainParts.
  virtual brightray::BrowserContext* CreateBrowserContext() OVERRIDE;

  // Implementations of content::BrowserMainParts.
  virtual void PostEarlyInitialization() OVERRIDE;
  virtual void PreMainMessageLoopStart() OVERRIDE;
  virtual void PreMainMessageLoopRun() OVERRIDE;
  virtual void PostDestroyThreads() OVERRIDE;

 private:
  scoped_ptr<AtomBrowserBindings> atom_bindings_;
  scoped_ptr<Browser> browser_;
  scoped_ptr<NodeBindings> node_bindings_;

  static AtomBrowserMainParts* self_;

  DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts);
};

}  // namespace atom

#endif  // ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_

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

#ifndef ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_
#define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_

#include "brightray/browser/browser_main_parts.h"

namespace atom {

class AtomBrowserBindings;
class Browser;
class NodeBindings;

class AtomBrowserMainParts : public brightray::BrowserMainParts {
 public:
  AtomBrowserMainParts();
  virtual ~AtomBrowserMainParts();

  static AtomBrowserMainParts* Get();

  AtomBrowserBindings* atom_bindings() { return atom_bindings_.get(); }
  Browser* browser() { return browser_.get(); }

 protected:
  // Implementations of brightray::BrowserMainParts.
  virtual brightray::BrowserContext* CreateBrowserContext() OVERRIDE;

  // Implementations of content::BrowserMainParts.
  virtual void PostEarlyInitialization() OVERRIDE;
  virtual void PreMainMessageLoopRun() OVERRIDE;
#if defined(OS_MACOSX)
  virtual void PreMainMessageLoopStart() OVERRIDE;
  virtual void PostDestroyThreads() OVERRIDE;
#endif

 private:
  scoped_ptr<AtomBrowserBindings> atom_bindings_;
  scoped_ptr<Browser> browser_;
  scoped_ptr<NodeBindings> node_bindings_;

  static AtomBrowserMainParts* self_;

  DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts);
};

}  // namespace atom

#endif  // ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_

Mark OS X only implementations in BrowserMainParts.


#pragma once

#include <QtGui/QMouseEvent>
#include <QtGui/QPaintEvent>
#include <QtWidgets/QWidget>

#include "binaryninjaapi.h"
#include "dockhandler.h"
#include "uitypes.h"

class ContextMenuManager;
class DisassemblyView;
class Menu;
class ViewFrame;

class BINARYNINJAUIAPI MiniGraph: public QWidget, public DockContextHandler
{
	Q_OBJECT

	DisassemblyView* m_disassemblyView = nullptr;

public:
	MiniGraph(QWidget* parent);
	~MiniGraph();

	virtual void notifyViewChanged(ViewFrame* frame) override;
	virtual bool shouldBeVisible(ViewFrame* frame) override;

protected:
	virtual void contextMenuEvent(QContextMenuEvent* event) override;
	virtual void mouseMoveEvent(QMouseEvent* event) override;
	virtual void mousePressEvent(QMouseEvent* event) override;
	virtual void paintEvent(QPaintEvent* event) override;
	virtual void scrollTo(int x, int y);

public Q_SLOTS:
	void notifyUpdate();
};

#pragma once

#include <QtGui/QMouseEvent>
#include <QtGui/QPaintEvent>
#include <QtWidgets/QWidget>

#include "binaryninjaapi.h"
#include "dockhandler.h"
#include "uitypes.h"

class ContextMenuManager;
class FlowGraphWidget;
class Menu;
class ViewFrame;

class BINARYNINJAUIAPI MiniGraph: public QWidget, public DockContextHandler
{
	Q_OBJECT

	FlowGraphWidget* m_flowGraphWidget = nullptr;

public:
	MiniGraph(QWidget* parent);
	~MiniGraph();

	virtual void notifyViewChanged(ViewFrame* frame) override;
	virtual bool shouldBeVisible(ViewFrame* frame) override;

protected:
	virtual void contextMenuEvent(QContextMenuEvent* event) override;
	virtual void mouseMoveEvent(QMouseEvent* event) override;
	virtual void mousePressEvent(QMouseEvent* event) override;
	virtual void paintEvent(QPaintEvent* event) override;
	virtual void scrollTo(int x, int y);

public Q_SLOTS:
	void notifyUpdate();
};

Update MiniGraph to work with FlowGraphWidet.


/*
* Word Rotation Operations
* (C) 1999-2008 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#ifndef BOTAN_WORD_ROTATE_H__
#define BOTAN_WORD_ROTATE_H__

#include <botan/types.h>

namespace Botan {

/**
* Bit rotation left
* @param input the input word
* @param rot the number of bits to rotate
* @return input rotated left by rot bits
*/
template<typename T> inline T rotate_left(T input, size_t rot)
   {
   return (rot == 0) ? input : static_cast<T>((input << rot) | (input >> (8*sizeof(T)-rot)));;
   }

/**
* Bit rotation right
* @param input the input word
* @param rot the number of bits to rotate
* @return input rotated right by rot bits
*/
template<typename T> inline T rotate_right(T input, size_t rot)
   {
   return (rot == 0) ? input : static_cast<T>((input >> rot) | (input << (8*sizeof(T)-rot)));
   }

}

#endif

/*
* Word Rotation Operations
* (C) 1999-2008 Jack Lloyd
*
* Botan is released under the Simplified BSD License (see license.txt)
*/

#ifndef BOTAN_WORD_ROTATE_H__
#define BOTAN_WORD_ROTATE_H__

#include <botan/types.h>

namespace Botan {

/**
* Bit rotation left
* @param input the input word
* @param rot the number of bits to rotate
* @return input rotated left by rot bits
*/
template<typename T> inline T rotate_left(T input, size_t rot)
   {
   rot %= 8 * sizeof(T);
   return (rot == 0) ? input : static_cast<T>((input << rot) | (input >> (8*sizeof(T)-rot)));;
   }

/**
* Bit rotation right
* @param input the input word
* @param rot the number of bits to rotate
* @return input rotated right by rot bits
*/
template<typename T> inline T rotate_right(T input, size_t rot)
   {
   rot %= 8 * sizeof(T);
   return (rot == 0) ? input : static_cast<T>((input >> rot) | (input << (8*sizeof(T)-rot)));
   }

}

#endif

Allow bit rotation by more than sizeof(T)*8 bits.

Currently these functions will happily bit shift by >= sizeof(T)*8 bits.
However, this is undefined behavior, and results in unexpected results (0)
on at least one platform I've tested.

With this update, you can expect that rotate_left<uint32_t>(1, 32)==1
and rotate_right<uint32_t>(1, 32)==1.


//===-- sanitizer_platform_interceptors.h -----------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines macro telling whether sanitizer tools can/should intercept
// given library functions on a given platform.
//
//===----------------------------------------------------------------------===//

#include "sanitizer_internal_defs.h"

#if !defined(_WIN32)
# define SI_NOT_WINDOWS 1
#else
# define SI_NOT_WINDOWS 0
#endif

#if defined(__linux__) && !defined(ANDROID)
# define SI_LINUX_NOT_ANDROID 1
#else
# define SI_LINUX_NOT_ANDROID 0
#endif

# define SANITIZER_INTERCEPT_READ   SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PREAD  SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_WRITE  SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PWRITE SI_NOT_WINDOWS

# define SANITIZER_INTERCEPT_PREAD64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_PWRITE64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_PRCTL   SI_LINUX_NOT_ANDROID

# define SANITIZER_INTERCEPT_SCANF 1

//===-- sanitizer_platform_interceptors.h -----------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines macro telling whether sanitizer tools can/should intercept
// given library functions on a given platform.
//
//===----------------------------------------------------------------------===//

#include "sanitizer_internal_defs.h"

#if !defined(_WIN32)
# define SI_NOT_WINDOWS 1
#else
# define SI_NOT_WINDOWS 0
#endif

#if defined(__linux__) && !defined(ANDROID)
# define SI_LINUX_NOT_ANDROID 1
#else
# define SI_LINUX_NOT_ANDROID 0
#endif

# define SANITIZER_INTERCEPT_READ   SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PREAD  SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_WRITE  SI_NOT_WINDOWS
# define SANITIZER_INTERCEPT_PWRITE SI_NOT_WINDOWS

# define SANITIZER_INTERCEPT_PREAD64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_PWRITE64 SI_LINUX_NOT_ANDROID
# define SANITIZER_INTERCEPT_PRCTL   SI_LINUX_NOT_ANDROID

# define SANITIZER_INTERCEPT_SCANF SI_NOT_WINDOWS

Disable scanf interceptor on windows.

[sanitizer] Disable scanf interceptor on windows.

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


//
//  NearbyObjectProtocol.h
//  ARIS
//
//  Created by Brian Deith on 5/15/09.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

enum {
	NearbyObjectNPC			= 1,
	NearbyObjectItem		= 2,
	NearbyObjectNode		= 3
};
typedef UInt32 nearbyObjectKind;

@protocol NearbyObjectProtocol
- (NSString *)name;
- (nearbyObjectKind)kind;
- (BOOL)forcedDisplay;
- (void)display;
@end

Include nearby object protocol file

Include nearby object protocol file


#pragma once

#include <unordered_map>
#include <string>

#include "TinyXml2\tinyxml2.h"

class Skin;

#define SETTINGS_APP L"SettingsUI.exe"

class Settings {
public:
    static Settings *Instance();

    static std::wstring AppDir();
    static std::wstring SettingsApp();

    std::wstring LanguagesDir();
    std::wstring LanguageName();
    Skin *CurrentSkin();
    std::wstring SkinName();
    std::wstring SkinXML();
    std::wstring SkinXML(std::wstring skinName);

    bool HasSetting(std::string elementName);
    bool IsEnabled(std::string elementName);

    std::wstring GetText(std::string elementName);
    int GetInt(std::string elementName);
    bool NotifyIconEnabled();
    bool SoundEffectsEnabled();

    std::unordered_map<int, int> Hotkeys();

    void Reload();

private:
    static Settings *instance;
    static std::wstring _appDir;

    std::wstring _file;
    tinyxml2::XMLDocument _xml;
    tinyxml2::XMLElement *_root;
    Skin *_skin;

    Settings();
};

#pragma once

#include <unordered_map>
#include <string>

#include "TinyXml2\tinyxml2.h"

class Skin;

#define SETTINGS_APP L"SettingsUI.exe"

class Settings {
public:
    static Settings *Instance();
    void Reload();

    static std::wstring AppDir();
    static std::wstring SettingsApp();

    std::wstring LanguagesDir();
    std::wstring LanguageName();
    Skin *CurrentSkin();
    std::wstring SkinName();
    std::wstring SkinXML();
    std::wstring SkinXML(std::wstring skinName);

    bool NotifyIconEnabled();
    bool SoundEffectsEnabled();

    std::unordered_map<int, int> Hotkeys();

private:
    Settings();

    static Settings *instance;
    static std::wstring _appDir;

    std::wstring _file;
    tinyxml2::XMLDocument _xml;
    tinyxml2::XMLElement *_root;
    Skin *_skin;

    bool HasSetting(std::string elementName);
    bool IsEnabled(std::string elementName);

    std::wstring GetText(std::string elementName);
    int GetInt(std::string elementName);
};

Reorganize and reduce visibility for raw XML access methods

These should be performed by public methods that abstract away the XML elements


Add script to test install

Add script to test install


// PARAM: --sets ana.activated[+] octApron
#include <pthread.h>
#include <assert.h>

int g = 1;

void *t_fun(void *arg) {
  g = 2; // write something non-initial so base wouldn't find success
  return NULL;
}

int main(void) {
  int x, y;

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

  x = g;
  y = g;
  // unlock(m_g)-s must forget relation with unprotected
  assert(x == y); // UNKNOWN!
  return 0;
}

Add regression test where unprotected read must forget relation


#ifndef EIGEN_HELPER_H
#define EIGEN_HELPER_H

#include <Eigen/Dense>

template<typename Derived>
inline bool isFucked(const Eigen::MatrixBase<Derived>& x)
{
  return !((x.array() == x.array())).all() && !( (x - x).array() == (x - x).array()).all();
}

#endif

#ifndef EIGEN_HELPER_H
#define EIGEN_HELPER_H

#include "ros/ros.h"
#include <Eigen/Dense>

template<typename Derived>
inline bool isFucked(const Eigen::MatrixBase<Derived>& x)
{
  return !((x.array() == x.array())).all() && !( (x - x).array() == (x - x).array()).all();
}

inline Eigen::MatrixXd getMatrixParam(ros::NodeHandle nh, std::string name)
{
  XmlRpc::XmlRpcValue matrix;
  nh.getParam(name, matrix);

  try
  {
    const int rows = matrix.size();
    const int cols = matrix[0].size();
    Eigen::MatrixXd X(rows,cols);
    for (int i = 0; i < rows; ++i)
      for (int j = 0; j < cols; ++j)
        X(i,j) = matrix[i][j];
    return X;
  }
  catch(...)
  {
    ROS_ERROR("Error in getMatrixParam. Returning 1-by-1 zero matrix.");
    return Eigen::MatrixXd::Zero(1,1);
  }
}

inline void printEigen(std::string name, const Eigen::MatrixXd &x)
{
  std::stringstream ss;
  ss << name << " = " << std::endl << x;
  ROS_INFO_STREAM(ss.str());
}

inline Eigen::MatrixXd pinv(const Eigen::MatrixXd &X)
{
  Eigen::MatrixXd X_pinv = X.transpose() * ( X*X.transpose() ).inverse();

  if (isFucked(X_pinv))
  {
    ROS_WARN("Could not compute pseudoinverse. Returning transpose.");
    return X.transpose();
  }

  return X_pinv;
}

#endif

Move more stuff to eigen helper header

Move more stuff to eigen helper header


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

int scanf(const char *restrict format, ...);
int getchar(void);

#define BUFSIZE 10

int Buffer[BUFSIZE];
void bufferFoo1(void)
{
  int n;
  scanf("%d", &n);
  Buffer[n] = 1; // expected-warning {{Out of bound memory access }}
}

void bufferScanfArithmetic1(int x) {
  int n;
  scanf("%d", &n);
  int m = (n - 3);
  Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}

void bufferScanfArithmetic2(int x) {
  int n;
  scanf("%d", &n);
  int m = (n + 3) * x;
  Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}

void scanfArg() {
  int t;
  scanf("%d", t); // expected-warning {{Pointer argument is expected}}
}

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

int scanf(const char *restrict format, ...);
int getchar(void);

#define BUFSIZE 10

int Buffer[BUFSIZE];
void bufferScanfDirect(void)
{
  int n;
  scanf("%d", &n);
  Buffer[n] = 1; // expected-warning {{Out of bound memory access }}
}

void bufferScanfArithmetic1(int x) {
  int n;
  scanf("%d", &n);
  int m = (n - 3);
  Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}

void bufferScanfArithmetic2(int x) {
  int n;
  scanf("%d", &n);
  int m = 100 / (n + 3) * x;
  Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
}

void bufferScanfAssignment(int x) {
  int n;
  scanf("%d", &n);
  int m;
  if (x > 0) {
    m = n;
    Buffer[m] = 1; // expected-warning {{Out of bound memory access }}
  }
}

void scanfArg() {
  int t;
  scanf("%d", t); // expected-warning {{Pointer argument is expected}}
}

void bufferGetchar(int x) {
  int m = getchar();
  Buffer[m] = 1;  //expected-warning {{Out of bound memory access }}
}

Add more simple taint tests.

[analyzer] Add more simple taint tests.

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


//===- CodeGen/ValueTypes.h - Low-Level Target independ. types --*- C++ -*-===//
//
// This file defines the set of low-level target independent types which various
// values in the code generator are.  This allows the target specific behavior
// of instructions to be described to target independent passes.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CODEGEN_VALUETYPES_H
#define LLVM_CODEGEN_VALUETYPES_H

/// MVT namespace - This namespace defines the ValueType enum, which contains
/// the various low-level value types.
///
namespace MVT {  // MRF = Machine Register Flags
  enum ValueType {
    Other          =   0 << 0,   // This is a non-standard value
    i1             =   1 << 0,   // This is a 1 bit integer value
    i8             =   1 << 1,   // This is an 8 bit integer value
    i16            =   1 << 2,   // This is a 16 bit integer value
    i32            =   1 << 3,   // This is a 32 bit integer value
    i64            =   1 << 4,   // This is a 64 bit integer value
    i128           =   1 << 5,   // This is a 128 bit integer value

    f32             =   1 << 6,   // This is a 32 bit floating point value
    f64             =   1 << 7,   // This is a 64 bit floating point value
    f80             =   1 << 8,   // This is a 80 bit floating point value
    f128            =   1 << 9,   // This is a 128 bit floating point value
  };
};

#endif

Define target value types in a form usable by target-independent code

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


// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_

#define UNLIKELY(x)   __builtin_expect((x), 0)
#define LIKELY(x)     __builtin_expect((x), 1)

#define cache_aligned __attribute__((aligned(64)))

#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))

const size_t kSystemPageSize = 4096;

always_inline size_t PadSize(size_t size, size_t multiple) {
  return (size + multiple - 1) / multiple * multiple;
}

#endif  // SCALLOC_COMMON_H_

// Copyright (c) 2012-2013, the scalloc Project Authors.  All rights reserved.
// Please see the AUTHORS file for details.  Use of this source code is governed
// by a BSD license that can be found in the LICENSE file.

#ifndef SCALLOC_COMMON_H_
#define SCALLOC_COMMON_H_

#define UNLIKELY(x)   __builtin_expect((x), 0)
#define LIKELY(x)     __builtin_expect((x), 1)

#define cache_aligned __attribute__((aligned(64)))

#define always_inline inline __attribute__((always_inline))
#define no_inline __attribute__((noinline))

const size_t kSystemPageSize = 4096;

// Prohibit reordering of instructions by the compiler.
inline void CompilerBarrier() {
  __asm__ __volatile__("" : : : "memory");
}

// Full memory fence on x86-64
inline void MemoryBarrier() {
  __asm__ __volatile__("mfence" : : : "memory");
}

always_inline size_t PadSize(size_t size, size_t multiple) {
  return (size + multiple - 1) / multiple * multiple;
}

#endif  // SCALLOC_COMMON_H_

Add CompilerBarrier() and MemoryBarrier() functions.

Signed-off-by: Michael Lippautz <0d543840881a2c189b4f7636b15eebd6a8f60ace@gmail.com>