about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-03-28 14:26:38 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-03-28 14:26:51 -0700
commit2aaca455b93351847c0c267a24a3f8c3eb6920a7 (patch)
tree8ffb748385e1c340a9f50cc8e5f10528cab311ba
parent45c74f04ab8ffdc7497159fbc9927b0025e485de (diff)
downloadrust-2aaca455b93351847c0c267a24a3f8c3eb6920a7.tar.gz
rust-2aaca455b93351847c0c267a24a3f8c3eb6920a7.zip
Tidy up multiple declarations and STDC_FOO_MACROS guards in headers.
-rw-r--r--src/rt/rust_globals.h (renamed from src/rt/globals.h)39
-rw-r--r--src/rt/rust_internal.h51
-rw-r--r--src/rt/rust_kernel.cpp5
-rw-r--r--src/rt/rust_task.cpp1
-rw-r--r--src/rt/rust_task_thread.cpp1
-rw-r--r--src/rt/sync/lock_and_signal.cpp2
-rw-r--r--src/rt/sync/lock_free_queue.cpp2
-rw-r--r--src/rt/sync/rust_thread.cpp2
-rw-r--r--src/rt/sync/timer.cpp2
9 files changed, 33 insertions, 72 deletions
diff --git a/src/rt/globals.h b/src/rt/rust_globals.h
index 011d4d93218..dcd1ec85575 100644
--- a/src/rt/globals.h
+++ b/src/rt/rust_globals.h
@@ -1,19 +1,35 @@
-#ifndef GLOBALS_H
-#define GLOBALS_H
+#ifndef RUST_GLOBALS_H
+#define RUST_GLOBALS_H
 
-#ifndef RUST_INTERNAL_H
-// these are defined in two files and GCC complains
+#ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS 1
+#endif
+
+#ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS 1
+#endif
+
+#ifndef __STDC_FORMAT_MACROS
 #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" {
@@ -23,14 +39,15 @@ extern "C" {
 }
 #elif defined(__GNUC__)
 #include <unistd.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
 #include <dlfcn.h>
 #include <pthread.h>
 #include <errno.h>
-#include <time.h>
+#include <dirent.h>
+
+#define GCC_VERSION (__GNUC__ * 10000 \
+                     + __GNUC_MINOR__ * 100 \
+                     + __GNUC_PATCHLEVEL__)
+
 #else
 #error "Platform not supported."
 #endif
@@ -47,4 +64,4 @@ extern "C" {
         }                                                           \
     }
 
-#endif /* GLOBALS_H */
+#endif /* RUST_GLOBALS_H */
diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h
index c5afdd44ae0..aaad5de6451 100644
--- a/src/rt/rust_internal.h
+++ b/src/rt/rust_internal.h
@@ -1,52 +1,7 @@
 #ifndef RUST_INTERNAL_H
 #define RUST_INTERNAL_H
 
-#ifndef 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 "rust_globals.h"
 #include "util/array_list.h"
 #include "util/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_port_id;
 
-//NDM #ifndef __i386__
-//NDM #error "Target CPU not supported."
-//NDM #endif
-
 #define I(dom, e) ((e) ? (void)0 : \
          (dom)->srv->fatal(#e, __FILE__, __LINE__, ""))
 
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 3b6ddbe4db2..e74819ab318 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -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_util.h"
 #include "rust_scheduler.h"
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 317638b93c9..b06a2b2d8b7 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -10,7 +10,6 @@
 #include <cstring>
 #include <algorithm>
 
-#include "globals.h"
 #include "rust_upcall.h"
 
 // Tasks
diff --git a/src/rt/rust_task_thread.cpp b/src/rt/rust_task_thread.cpp
index 658dff23d27..6a5b8bc2ab0 100644
--- a/src/rt/rust_task_thread.cpp
+++ b/src/rt/rust_task_thread.cpp
@@ -5,7 +5,6 @@
 #include <vector>
 #include "rust_internal.h"
 #include "rust_util.h"
-#include "globals.h"
 #include "rust_scheduler.h"
 
 #ifndef _WIN32
diff --git a/src/rt/sync/lock_and_signal.cpp b/src/rt/sync/lock_and_signal.cpp
index 11f7be4670a..35576f7fd97 100644
--- a/src/rt/sync/lock_and_signal.cpp
+++ b/src/rt/sync/lock_and_signal.cpp
@@ -1,5 +1,5 @@
 #include <assert.h>
-#include "../globals.h"
+#include "../rust_globals.h"
 
 /*
  * A "lock-and-signal" pair. These are necessarily coupled on pthreads
diff --git a/src/rt/sync/lock_free_queue.cpp b/src/rt/sync/lock_free_queue.cpp
index 3f8598629b4..90595a6ed11 100644
--- a/src/rt/sync/lock_free_queue.cpp
+++ b/src/rt/sync/lock_free_queue.cpp
@@ -5,7 +5,7 @@
  * dequeue() is not allowed to interrupt itself.
  */
 
-#include "../globals.h"
+#include "../rust_globals.h"
 #include "lock_free_queue.h"
 
 lock_free_queue_node::lock_free_queue_node() : next(NULL) {
diff --git a/src/rt/sync/rust_thread.cpp b/src/rt/sync/rust_thread.cpp
index df0d57767df..6937f4f7811 100644
--- a/src/rt/sync/rust_thread.cpp
+++ b/src/rt/sync/rust_thread.cpp
@@ -1,4 +1,4 @@
-#include "globals.h"
+#include "rust_globals.h"
 #include "rust_thread.h"
 
 const size_t default_stack_sz = 1024*1024;
diff --git a/src/rt/sync/timer.cpp b/src/rt/sync/timer.cpp
index 8ef5634f2cd..28ee6da2b62 100644
--- a/src/rt/sync/timer.cpp
+++ b/src/rt/sync/timer.cpp
@@ -1,4 +1,4 @@
-#include "../globals.h"
+#include "../rust_globals.h"
 #include "timer.h"
 
 #if defined(__APPLE__)