Skip to content

Commit

Permalink
Refactor includes structure, getting rid of rust_internal.h
Browse files Browse the repository at this point in the history
Many changes to code structure are included:
- removed TIME_SLICE_IN_MS
- removed sychronized_indexed_list
- removed region_owned
- kernel_owned move to kernel.h, task_owned moved to task.h
- global configs moved to rust_globals.h
- changed #pragma once to standard guard in rust_upcall.h
- got rid of memory.h
  • Loading branch information
jamorton authored and brson committed Apr 3, 2012
1 parent 704ca04 commit 632a4c9
Show file tree
Hide file tree
Showing 54 changed files with 311 additions and 412 deletions.
8 changes: 2 additions & 6 deletions src/rt/arch/i386/context.cpp
@@ -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
@@ -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
@@ -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
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
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
34 changes: 1 addition & 33 deletions src/rt/memory.h
Expand Up @@ -2,40 +2,8 @@
#ifndef MEMORY_H
#define MEMORY_H

// FIXME: It would be really nice to be able to get rid of this.
inline void *operator new[](size_t size, rust_task *task, const char *tag) {
return task->malloc(size, tag);
}
#include "rust_task.h"

template <typename T>
inline void *task_owned<T>::operator new(size_t size, rust_task *task,
const char *tag) {
return task->malloc(size, tag);
}

template <typename T>
inline void *task_owned<T>::operator new[](size_t size, rust_task *task,
const char *tag) {
return task->malloc(size, tag);
}

template <typename T>
inline void *task_owned<T>::operator new(size_t size, rust_task &task,
const char *tag) {
return task.malloc(size, tag);
}

template <typename T>
inline void *task_owned<T>::operator new[](size_t size, rust_task &task,
const char *tag) {
return task.malloc(size, tag);
}

template <typename T>
inline void *kernel_owned<T>::operator new(size_t size, rust_kernel *kernel,
const char *tag) {
return kernel->malloc(size, tag);
}


#endif /* MEMORY_H */
4 changes: 3 additions & 1 deletion src/rt/memory_region.cpp
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
@@ -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
37 changes: 35 additions & 2 deletions src/rt/rust_globals.h
Expand Up @@ -25,11 +25,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 +51,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 +85,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 */

0 comments on commit 632a4c9

Please sign in to comment.