2012-03-28 14:26:38 -07:00
|
|
|
#ifndef RUST_GLOBALS_H
|
|
|
|
#define RUST_GLOBALS_H
|
2010-07-19 14:05:18 -07:00
|
|
|
|
2012-03-28 14:26:38 -07:00
|
|
|
#ifndef __STDC_LIMIT_MACROS
|
2010-07-19 14:05:18 -07:00
|
|
|
#define __STDC_LIMIT_MACROS 1
|
2012-03-28 14:26:38 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __STDC_CONSTANT_MACROS
|
2010-07-19 14:05:18 -07:00
|
|
|
#define __STDC_CONSTANT_MACROS 1
|
2012-03-28 14:26:38 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
2010-07-19 14:05:18 -07:00
|
|
|
#define __STDC_FORMAT_MACROS 1
|
2011-05-31 17:44:54 -07:00
|
|
|
#endif
|
2010-07-19 14:05:18 -07:00
|
|
|
|
2012-03-28 14:26:38 -07:00
|
|
|
#define ERROR 0
|
|
|
|
|
2010-07-19 14:05:18 -07:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <inttypes.h>
|
2012-03-28 14:26:38 -07:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2010-07-19 14:05:18 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2012-03-28 14:26:38 -07:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <math.h>
|
2012-04-02 22:18:01 -05:00
|
|
|
#include <assert.h>
|
2012-03-28 14:26:38 -07:00
|
|
|
|
|
|
|
#include "rand.h"
|
|
|
|
#include "uthash.h"
|
2010-07-19 14:05:18 -07:00
|
|
|
|
|
|
|
#if defined(__WIN32__)
|
|
|
|
extern "C" {
|
|
|
|
#include <windows.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <wincrypt.h>
|
|
|
|
}
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <dlfcn.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <errno.h>
|
2012-03-28 14:26:38 -07:00
|
|
|
#include <dirent.h>
|
|
|
|
|
|
|
|
#define GCC_VERSION (__GNUC__ * 10000 \
|
|
|
|
+ __GNUC_MINOR__ * 100 \
|
|
|
|
+ __GNUC_PATCHLEVEL__)
|
|
|
|
|
2010-07-19 14:05:18 -07:00
|
|
|
#else
|
|
|
|
#error "Platform not supported."
|
|
|
|
#endif
|
|
|
|
|
2012-04-02 22:18:01 -05:00
|
|
|
#ifdef __i386__
|
|
|
|
// 'cdecl' ABI only means anything on i386
|
|
|
|
#ifdef __WIN32__
|
|
|
|
#ifndef CDECL
|
|
|
|
#define CDECL __cdecl
|
|
|
|
#endif
|
|
|
|
#ifndef FASTCALL
|
|
|
|
#define FASTCALL __fastcall
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define CDECL __attribute__((cdecl))
|
|
|
|
#define FASTCALL __attribute__((fastcall))
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define CDECL
|
|
|
|
#define FASTCALL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Controls whether claims are turned into checks */
|
|
|
|
/* Variable name must be kept consistent with trans.rs */
|
|
|
|
extern "C" int check_claims;
|
|
|
|
|
2011-05-31 17:44:54 -07:00
|
|
|
#define CHECKED(call) \
|
|
|
|
{ \
|
|
|
|
int res = (call); \
|
|
|
|
if(0 != res) { \
|
|
|
|
fprintf(stderr, \
|
|
|
|
#call " failed in %s at line %d, result = %d " \
|
|
|
|
"(%s) \n", \
|
|
|
|
__FILE__, __LINE__, res, strerror(res)); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
2011-07-13 15:44:09 -07:00
|
|
|
}
|
2011-05-31 17:44:54 -07:00
|
|
|
|
2012-07-24 18:22:44 -04:00
|
|
|
#define MUST_CHECK __attribute__((warn_unused_result))
|
|
|
|
|
2012-04-02 22:18:01 -05:00
|
|
|
#define PTR "0x%" PRIxPTR
|
|
|
|
|
|
|
|
// This accounts for logging buffers.
|
|
|
|
static size_t const BUF_BYTES = 2048;
|
|
|
|
|
2012-07-13 19:13:11 -04:00
|
|
|
#define INIT_TASK_ID 1
|
|
|
|
|
2012-04-02 22:18:01 -05:00
|
|
|
// The error status to use when the process fails
|
|
|
|
#define PROC_FAIL_CODE 101
|
|
|
|
|
|
|
|
// A cond(ition) is something we can block on. This can be a channel
|
|
|
|
// (writing), a port (reading) or a task (waiting).
|
|
|
|
struct rust_cond { };
|
|
|
|
|
2012-03-28 14:26:38 -07:00
|
|
|
#endif /* RUST_GLOBALS_H */
|