Tidy up multiple declarations and STDC_FOO_MACROS guards in headers.

This commit is contained in:
Graydon Hoare 2012-03-28 14:26:38 -07:00
parent 45c74f04ab
commit 2aaca455b9
9 changed files with 33 additions and 72 deletions

View File

@ -1,19 +1,35 @@
#ifndef GLOBALS_H #ifndef RUST_GLOBALS_H
#define GLOBALS_H #define RUST_GLOBALS_H
#ifndef RUST_INTERNAL_H #ifndef __STDC_LIMIT_MACROS
// these are defined in two files and GCC complains
#define __STDC_LIMIT_MACROS 1 #define __STDC_LIMIT_MACROS 1
#endif
#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS 1 #define __STDC_CONSTANT_MACROS 1
#endif
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1 #define __STDC_FORMAT_MACROS 1
#endif #endif
#define ERROR 0
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <fcntl.h>
#include <math.h>
#include "rust.h"
#include "rand.h"
#include "uthash.h"
#include "rust_env.h"
#if defined(__WIN32__) #if defined(__WIN32__)
extern "C" { extern "C" {
@ -23,14 +39,15 @@ extern "C" {
} }
#elif defined(__GNUC__) #elif defined(__GNUC__)
#include <unistd.h> #include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <pthread.h> #include <pthread.h>
#include <errno.h> #include <errno.h>
#include <time.h> #include <dirent.h>
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#else #else
#error "Platform not supported." #error "Platform not supported."
#endif #endif
@ -47,4 +64,4 @@ extern "C" {
} \ } \
} }
#endif /* GLOBALS_H */ #endif /* RUST_GLOBALS_H */

View File

@ -1,52 +1,7 @@
#ifndef RUST_INTERNAL_H #ifndef RUST_INTERNAL_H
#define RUST_INTERNAL_H #define RUST_INTERNAL_H
#ifndef GLOBALS_H #include "rust_globals.h"
// these are defined in two files, and GCC complains.
#define __STDC_LIMIT_MACROS 1
#define __STDC_CONSTANT_MACROS 1
#define __STDC_FORMAT_MACROS 1
#endif
#define ERROR 0
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <math.h>
#include "rust.h"
#include "rand.h"
#include "uthash.h"
#include "rust_env.h"
#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>
#include <dirent.h>
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#else
#error "Platform not supported."
#endif
#include "util/array_list.h" #include "util/array_list.h"
#include "util/indexed_list.h" #include "util/indexed_list.h"
#include "util/synchronized_indexed_list.h" #include "util/synchronized_indexed_list.h"
@ -69,10 +24,6 @@ typedef intptr_t rust_sched_id;
typedef intptr_t rust_task_id; typedef intptr_t rust_task_id;
typedef intptr_t rust_port_id; typedef intptr_t rust_port_id;
//NDM #ifndef __i386__
//NDM #error "Target CPU not supported."
//NDM #endif
#define I(dom, e) ((e) ? (void)0 : \ #define I(dom, e) ((e) ? (void)0 : \
(dom)->srv->fatal(#e, __FILE__, __LINE__, "")) (dom)->srv->fatal(#e, __FILE__, __LINE__, ""))

View File

@ -1,8 +1,3 @@
// A workaround that makes INTPTR_MAX be visible
#ifdef __FreeBSD__
#define __STDC_LIMIT_MACROS 1
#endif
#include "rust_internal.h" #include "rust_internal.h"
#include "rust_util.h" #include "rust_util.h"
#include "rust_scheduler.h" #include "rust_scheduler.h"

View File

@ -10,7 +10,6 @@
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>
#include "globals.h"
#include "rust_upcall.h" #include "rust_upcall.h"
// Tasks // Tasks

View File

@ -5,7 +5,6 @@
#include <vector> #include <vector>
#include "rust_internal.h" #include "rust_internal.h"
#include "rust_util.h" #include "rust_util.h"
#include "globals.h"
#include "rust_scheduler.h" #include "rust_scheduler.h"
#ifndef _WIN32 #ifndef _WIN32

View File

@ -1,5 +1,5 @@
#include <assert.h> #include <assert.h>
#include "../globals.h" #include "../rust_globals.h"
/* /*
* A "lock-and-signal" pair. These are necessarily coupled on pthreads * A "lock-and-signal" pair. These are necessarily coupled on pthreads

View File

@ -5,7 +5,7 @@
* dequeue() is not allowed to interrupt itself. * dequeue() is not allowed to interrupt itself.
*/ */
#include "../globals.h" #include "../rust_globals.h"
#include "lock_free_queue.h" #include "lock_free_queue.h"
lock_free_queue_node::lock_free_queue_node() : next(NULL) { lock_free_queue_node::lock_free_queue_node() : next(NULL) {

View File

@ -1,4 +1,4 @@
#include "globals.h" #include "rust_globals.h"
#include "rust_thread.h" #include "rust_thread.h"
const size_t default_stack_sz = 1024*1024; const size_t default_stack_sz = 1024*1024;

View File

@ -1,4 +1,4 @@
#include "../globals.h" #include "../rust_globals.h"
#include "timer.h" #include "timer.h"
#if defined(__APPLE__) #if defined(__APPLE__)