Skip to content

Refactor includes structure, getting rid of rust_internal.h #2118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/rt/arch/i386/context.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "context.h"

#include "../../rust.h"

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "context.h"
#include "../../rust_globals.h"

extern "C" uint32_t CDECL swap_registers(registers_t *oregs,
registers_t *regs)
Expand Down
8 changes: 2 additions & 6 deletions src/rt/arch/x86_64/context.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "context.h"

#include "../../rust.h"

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "context.h"
#include "../../rust_globals.h"

extern "C" void CDECL swap_registers(registers_t *oregs,
registers_t *regs)
Expand Down
6 changes: 4 additions & 2 deletions src/rt/boxed_region.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <assert.h>


#include "boxed_region.h"
#include "rust_internal.h"
#include "rust_globals.h"
#include "rust_task.h"

// #define DUMP_BOXED_REGION

Expand Down
4 changes: 3 additions & 1 deletion src/rt/circular_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* A simple resizable circular buffer.
*/

#include "rust_internal.h"
#include "circular_buffer.h"
#include "rust_globals.h"
#include "rust_kernel.h"

circular_buffer::circular_buffer(rust_kernel *kernel, size_t unit_sz) :
kernel(kernel),
Expand Down
3 changes: 3 additions & 0 deletions src/rt/circular_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#ifndef CIRCULAR_BUFFER_H
#define CIRCULAR_BUFFER_H

#include "rust_globals.h"
#include "rust_kernel.h"

class
circular_buffer : public kernel_owned<circular_buffer> {
static const size_t INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS = 8;
Expand Down
41 changes: 0 additions & 41 deletions src/rt/memory.h

This file was deleted.

4 changes: 3 additions & 1 deletion src/rt/memory_region.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "rust_internal.h"

#include "sync/sync.h"
#include "memory_region.h"
#include "rust_env.h"

#if RUSTRT_TRACK_ALLOCATIONS >= 3
#include <execinfo.h>
Expand Down
2 changes: 2 additions & 0 deletions src/rt/memory_region.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#ifndef MEMORY_REGION_H
#define MEMORY_REGION_H

#include "rust_globals.h"
#include "sync/lock_and_signal.h"
#include "util/array_list.h"

// There are three levels of debugging:
//
Expand Down
5 changes: 3 additions & 2 deletions src/rt/rust.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "rust_internal.h"

#include "rust_globals.h"
#include "rust_kernel.h"
#include "rust_util.h"
#include "rust_scheduler.h"
#include <cstdio>

struct
command_line_args : public kernel_owned<command_line_args>
Expand Down
41 changes: 0 additions & 41 deletions src/rt/rust.h

This file was deleted.

4 changes: 3 additions & 1 deletion src/rt/rust_box_annihilator.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "rust_internal.h"

#include "rust_globals.h"
#include "rust_task.h"
#include "rust_shape.h"

class annihilator : public shape::data<annihilator,shape::ptr> {
Expand Down
2 changes: 1 addition & 1 deletion src/rt/rust_builtin.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* Native builtins. */

#include "rust_internal.h"
#include "rust_sched_loop.h"
#include "rust_task.h"
#include "rust_util.h"
#include "rust_scheduler.h"
#include "sync/timer.h"
#include "rust_abi.h"
#include "rust_port.h"

#ifdef __APPLE__
#include <crt_externs.h>
Expand Down
14 changes: 6 additions & 8 deletions src/rt/rust_cc.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// Rust cycle collector. Temporary, but will probably stick around for some
// time until LLVM's GC infrastructure is more mature.

#include "rust_debug.h"
#include "rust_internal.h"
#include "rust_shape.h"
#include "rust_task.h"
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <stdint.h>
#include <ios>

#include "rust_globals.h"
#include "rust_cc.h"
#include "rust_debug.h"
#include "rust_shape.h"
#include "rust_task.h"

// The number of allocations Rust code performs before performing cycle
// collection.
#define RUST_CC_FREQUENCY 5000
Expand Down
4 changes: 2 additions & 2 deletions src/rt/rust_debug.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Routines useful when debugging the Rust runtime.

#include "rust_globals.h"
#include "rust_abi.h"
#include "rust_debug.h"
#include "rust_internal.h"
#include "rust_task.h"

#include <iostream>
#include <string>
#include <sstream>
#include <stdint.h>

namespace {

Expand Down
2 changes: 1 addition & 1 deletion src/rt/rust_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// that might come from the environment is loaded here, once, during
// init.

#include "rust_internal.h"
#include "rust_env.h"

// The environment variables that the runtime knows about
#define RUST_THREADS "RUST_THREADS"
Expand Down
8 changes: 8 additions & 0 deletions src/rt/rust_env.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

#ifndef RUST_ENV_H
#define RUST_ENV_H

#include "rust_globals.h"

struct rust_env {
size_t num_sched_threads;
size_t min_stack_size;
Expand All @@ -11,3 +17,5 @@ struct rust_env {

rust_env* load_env();
void free_env(rust_env *rust_env);

#endif
38 changes: 35 additions & 3 deletions src/rt/rust_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define ERROR 0

#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdarg.h>
#include <sys/types.h>
Expand All @@ -25,11 +24,10 @@
#include <string.h>
#include <fcntl.h>
#include <math.h>
#include <assert.h>

#include "rust.h"
#include "rand.h"
#include "uthash.h"
#include "rust_env.h"

#if defined(__WIN32__)
extern "C" {
Expand All @@ -52,6 +50,28 @@ extern "C" {
#error "Platform not supported."
#endif

#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;

#define CHECKED(call) \
{ \
int res = (call); \
Expand All @@ -64,4 +84,16 @@ extern "C" {
} \
}

#define PTR "0x%" PRIxPTR

// This accounts for logging buffers.
static size_t const BUF_BYTES = 2048;

// 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 { };

#endif /* RUST_GLOBALS_H */
Loading