Skip to content

Commit 2aaca45

Browse files
committed
Tidy up multiple declarations and STDC_FOO_MACROS guards in headers.
1 parent 45c74f0 commit 2aaca45

9 files changed

+33
-72
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1-
#ifndef GLOBALS_H
2-
#define GLOBALS_H
1+
#ifndef RUST_GLOBALS_H
2+
#define RUST_GLOBALS_H
33

4-
#ifndef RUST_INTERNAL_H
5-
// these are defined in two files and GCC complains
4+
#ifndef __STDC_LIMIT_MACROS
65
#define __STDC_LIMIT_MACROS 1
6+
#endif
7+
8+
#ifndef __STDC_CONSTANT_MACROS
79
#define __STDC_CONSTANT_MACROS 1
10+
#endif
11+
12+
#ifndef __STDC_FORMAT_MACROS
813
#define __STDC_FORMAT_MACROS 1
914
#endif
1015

16+
#define ERROR 0
17+
1118
#include <stdlib.h>
1219
#include <stdint.h>
1320
#include <inttypes.h>
14-
21+
#include <stdarg.h>
22+
#include <sys/types.h>
23+
#include <sys/stat.h>
1524
#include <stdio.h>
1625
#include <string.h>
26+
#include <fcntl.h>
27+
#include <math.h>
28+
29+
#include "rust.h"
30+
#include "rand.h"
31+
#include "uthash.h"
32+
#include "rust_env.h"
1733

1834
#if defined(__WIN32__)
1935
extern "C" {
@@ -23,14 +39,15 @@ extern "C" {
2339
}
2440
#elif defined(__GNUC__)
2541
#include <unistd.h>
26-
#include <sys/time.h>
27-
#include <sys/types.h>
28-
#include <sys/stat.h>
29-
#include <fcntl.h>
3042
#include <dlfcn.h>
3143
#include <pthread.h>
3244
#include <errno.h>
33-
#include <time.h>
45+
#include <dirent.h>
46+
47+
#define GCC_VERSION (__GNUC__ * 10000 \
48+
+ __GNUC_MINOR__ * 100 \
49+
+ __GNUC_PATCHLEVEL__)
50+
3451
#else
3552
#error "Platform not supported."
3653
#endif
@@ -47,4 +64,4 @@ extern "C" {
4764
} \
4865
}
4966

50-
#endif /* GLOBALS_H */
67+
#endif /* RUST_GLOBALS_H */

src/rt/rust_internal.h

+1-50
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,7 @@
11
#ifndef RUST_INTERNAL_H
22
#define RUST_INTERNAL_H
33

4-
#ifndef GLOBALS_H
5-
// these are defined in two files, and GCC complains.
6-
#define __STDC_LIMIT_MACROS 1
7-
#define __STDC_CONSTANT_MACROS 1
8-
#define __STDC_FORMAT_MACROS 1
9-
#endif
10-
11-
#define ERROR 0
12-
13-
#include <stdlib.h>
14-
#include <stdint.h>
15-
#include <inttypes.h>
16-
#include <stdarg.h>
17-
#include <sys/types.h>
18-
#include <sys/stat.h>
19-
#include <stdio.h>
20-
#include <string.h>
21-
#include <fcntl.h>
22-
#include <math.h>
23-
24-
#include "rust.h"
25-
#include "rand.h"
26-
#include "uthash.h"
27-
#include "rust_env.h"
28-
29-
#if defined(__WIN32__)
30-
extern "C" {
31-
#include <windows.h>
32-
#include <tchar.h>
33-
#include <wincrypt.h>
34-
}
35-
#elif defined(__GNUC__)
36-
#include <unistd.h>
37-
#include <dlfcn.h>
38-
#include <pthread.h>
39-
#include <errno.h>
40-
#include <dirent.h>
41-
42-
#define GCC_VERSION (__GNUC__ * 10000 \
43-
+ __GNUC_MINOR__ * 100 \
44-
+ __GNUC_PATCHLEVEL__)
45-
46-
#else
47-
#error "Platform not supported."
48-
#endif
49-
4+
#include "rust_globals.h"
505
#include "util/array_list.h"
516
#include "util/indexed_list.h"
527
#include "util/synchronized_indexed_list.h"
@@ -69,10 +24,6 @@ typedef intptr_t rust_sched_id;
6924
typedef intptr_t rust_task_id;
7025
typedef intptr_t rust_port_id;
7126

72-
//NDM #ifndef __i386__
73-
//NDM #error "Target CPU not supported."
74-
//NDM #endif
75-
7627
#define I(dom, e) ((e) ? (void)0 : \
7728
(dom)->srv->fatal(#e, __FILE__, __LINE__, ""))
7829

src/rt/rust_kernel.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
// A workaround that makes INTPTR_MAX be visible
2-
#ifdef __FreeBSD__
3-
#define __STDC_LIMIT_MACROS 1
4-
#endif
5-
61
#include "rust_internal.h"
72
#include "rust_util.h"
83
#include "rust_scheduler.h"

src/rt/rust_task.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <cstring>
1111
#include <algorithm>
1212

13-
#include "globals.h"
1413
#include "rust_upcall.h"
1514

1615
// Tasks

src/rt/rust_task_thread.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <vector>
66
#include "rust_internal.h"
77
#include "rust_util.h"
8-
#include "globals.h"
98
#include "rust_scheduler.h"
109

1110
#ifndef _WIN32

src/rt/sync/lock_and_signal.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <assert.h>
2-
#include "../globals.h"
2+
#include "../rust_globals.h"
33

44
/*
55
* A "lock-and-signal" pair. These are necessarily coupled on pthreads

src/rt/sync/lock_free_queue.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* dequeue() is not allowed to interrupt itself.
66
*/
77

8-
#include "../globals.h"
8+
#include "../rust_globals.h"
99
#include "lock_free_queue.h"
1010

1111
lock_free_queue_node::lock_free_queue_node() : next(NULL) {

src/rt/sync/rust_thread.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "globals.h"
1+
#include "rust_globals.h"
22
#include "rust_thread.h"
33

44
const size_t default_stack_sz = 1024*1024;

src/rt/sync/timer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "../globals.h"
1+
#include "../rust_globals.h"
22
#include "timer.h"
33

44
#if defined(__APPLE__)

0 commit comments

Comments
 (0)