Use C++ namespaces

db4
Slava Pestov 2009-05-04 01:46:13 -05:00
parent 8e17e0a01e
commit edecac508e
118 changed files with 594 additions and 52 deletions

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* gets the address of an object representing a C pointer, with the
intention of storing the pointer across code which may potentially GC. */
char *pinned_alien_offset(CELL object)
@ -222,3 +225,5 @@ VM_C_API void box_medium_struct(CELL x1, CELL x2, CELL x3, CELL x4, CELL size)
data[3] = x4;
box_value_struct(data,size);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
CELL allot_alien(CELL delegate, CELL displacement);
PRIMITIVE(displaced_alien);
@ -42,3 +45,5 @@ VM_C_API void to_value_struct(CELL src, void *dest, CELL size);
VM_C_API void box_value_struct(void *src, CELL size);
VM_C_API void box_small_struct(CELL x, CELL y, CELL size);
VM_C_API void box_medium_struct(CELL x1, CELL x2, CELL x3, CELL x4, CELL size);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* make a new array with an initial element */
F_ARRAY *allot_array(CELL capacity, CELL fill_)
{
@ -80,3 +83,5 @@ void growable_array::trim()
{
array = reallot_array(array.untagged(),count);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
inline static CELL array_nth(F_ARRAY *array, CELL slot)
{
#ifdef FACTOR_DEBUG
@ -36,3 +39,5 @@ struct growable_array {
void add(CELL elt);
void trim();
};
}

View File

@ -56,6 +56,9 @@ MIT in each case. */
#include <stdio.h>
#include <math.h>
namespace factor
{
/* Exports */
int
@ -1841,3 +1844,5 @@ digit_stream_to_bignum(unsigned int n_digits,
}
}
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
/* :tabSize=2:indentSize=2:noTabs=true:
Copyright (C) 1989-1992 Massachusetts Institute of Technology
@ -124,3 +127,5 @@ F_BIGNUM * digit_stream_to_bignum(unsigned int n_digits,
unsigned int (*producer)(unsigned int),
unsigned int radix,
int negative_p);
}

View File

@ -33,6 +33,9 @@ Technology nor of any adaptation thereof in any advertising,
promotional, or sales literature without prior written consent from
MIT in each case. */
namespace factor
{
/* Internal Interface to Bignum Code */
#undef BIGNUM_ZERO_P
#undef BIGNUM_NEGATIVE_P
@ -98,3 +101,5 @@ typedef F_FIXNUM bignum_length_type;
}
#endif /* not BIGNUM_DISABLE_ASSERTION_CHECKS */
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
VM_C_API void box_boolean(bool value)
{
dpush(value ? T : F);
@ -9,3 +12,5 @@ VM_C_API bool to_boolean(CELL value)
{
return value != F;
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
inline static CELL tag_boolean(CELL untagged)
{
return (untagged ? T : F);
@ -5,3 +8,5 @@ inline static CELL tag_boolean(CELL untagged)
VM_C_API void box_boolean(bool value);
VM_C_API bool to_boolean(CELL value);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
F_BYTE_ARRAY *allot_byte_array(CELL size)
{
F_BYTE_ARRAY *array = allot_array_internal<F_BYTE_ARRAY>(size);
@ -57,3 +60,5 @@ void growable_byte_array::trim()
{
array = reallot_array(array.untagged(),count);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
F_BYTE_ARRAY *allot_byte_array(CELL size);
PRIMITIVE(byte_array);
@ -16,3 +19,5 @@ struct growable_byte_array {
void trim();
};
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
static void check_frame(F_STACK_FRAME *frame)
{
#ifdef FACTOR_DEBUG
@ -223,3 +226,5 @@ VM_ASM_API void save_callstack_bottom(F_STACK_FRAME *callstack_bottom)
{
stack_chain->callstack_bottom = callstack_bottom;
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
inline static CELL callstack_size(CELL size)
{
return sizeof(F_CALLSTACK) + size;
@ -24,3 +27,5 @@ PRIMITIVE(innermost_stack_frame_scan);
PRIMITIVE(set_innermost_stack_frame_quot);
VM_ASM_API void save_callstack_bottom(F_STACK_FRAME *callstack_bottom);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
void flush_icache_for(F_CODE_BLOCK *block)
{
flush_icache((CELL)block,block->block.size);
@ -321,7 +324,10 @@ void *get_rel_symbol(F_ARRAY *literals, CELL index)
if(sym)
return sym;
else
{
printf("%s\n",name);
return (void *)undefined_symbol;
}
case ARRAY_TYPE:
CELL i;
F_ARRAY *names = untag<F_ARRAY>(symbol);
@ -485,3 +491,5 @@ F_CODE_BLOCK *add_code_block(
return compiled;
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
typedef enum {
/* arg is a primitive number */
RT_PRIMITIVE,
@ -85,3 +88,5 @@ inline static bool stack_traces_p(void)
}
F_CODE_BLOCK *add_code_block(CELL type, CELL code, CELL labels, CELL relocation, CELL literals);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
static void clear_free_list(F_HEAP *heap)
{
memset(&heap->free,0,sizeof(F_HEAP_FREE_LIST));
@ -334,3 +337,5 @@ void compact_heap(F_HEAP *heap)
scan = next;
}
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
#define FREE_LIST_COUNT 16
#define BLOCK_SIZE_INCREMENT 32
@ -43,3 +46,5 @@ inline static F_BLOCK *last_block(F_HEAP *heap)
{
return (F_BLOCK *)heap->segment->end;
}
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
F_HEAP code_heap;
/* Allocate a code heap during startup */
@ -220,3 +223,5 @@ void compact_code_heap(void)
the end */
build_free_list(&code_heap,size);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
/* compiled code */
extern F_HEAP code_heap;
@ -25,3 +28,5 @@ inline static void check_code_pointer(CELL pointer)
assert(pointer >= code_heap.segment->start && pointer < code_heap.segment->end);
#endif
}
}

View File

@ -1,6 +1,10 @@
#include "master.hpp"
F_CONTEXT *stack_chain;
factor::F_CONTEXT *stack_chain;
namespace factor
{
CELL ds_size, rs_size;
F_CONTEXT *unused_contexts;
@ -184,3 +188,5 @@ PRIMITIVE(check_datastack)
dpush(T);
}
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
/* Assembly code makes assumptions about the layout of this struct:
- callstack_top field is 0
- callstack_bottom field is 1
@ -33,8 +36,6 @@ struct F_CONTEXT {
F_CONTEXT *next;
};
extern F_CONTEXT *stack_chain;
extern CELL ds_size, rs_size;
#define ds_bot (stack_chain->datastack_region->start)
@ -59,3 +60,7 @@ PRIMITIVE(check_datastack);
VM_C_API void save_stacks(void);
VM_C_API void nest_stacks(void);
VM_C_API void unnest_stacks(void);
}
VM_C_API factor::F_CONTEXT *stack_chain;

View File

@ -1,3 +1,6 @@
namespace factor
{
#define FACTOR_CPU_STRING "arm"
register CELL ds asm("r5");
@ -11,3 +14,5 @@ void c_to_factor(CELL quot);
void set_callstack(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *memcpy);
void throw_impl(CELL quot, F_STACK_FRAME *rewind);
void lazy_jit_compile(CELL quot);
}

View File

@ -1,3 +1,6 @@
namespace factor
{
#define FACTOR_CPU_STRING "ppc"
#define VM_ASM_API
@ -10,3 +13,5 @@ void set_callstack(F_STACK_FRAME *to, F_STACK_FRAME *from, CELL length, void *me
void throw_impl(CELL quot, F_STACK_FRAME *rewind);
void lazy_jit_compile(CELL quot);
void flush_icache(CELL start, CELL len);
}

View File

@ -1,6 +1,11 @@
namespace factor
{
#define FACTOR_CPU_STRING "x86.32"
register CELL ds asm("esi");
register CELL rs asm("edi");
#define VM_ASM_API extern "C" __attribute__ ((regparm (2)))
}

View File

@ -1,6 +1,11 @@
namespace factor
{
#define FACTOR_CPU_STRING "x86.64"
register CELL ds asm("r14");
register CELL rs asm("r15");
#define VM_ASM_API extern "C"
}

View File

@ -1,5 +1,8 @@
#include <assert.h>
namespace factor
{
#define FRAME_RETURN_ADDRESS(frame) *(XT *)(frame_successor(frame) + 1)
inline static void flush_icache(CELL start, CELL len) {}
@ -37,3 +40,5 @@ VM_C_API void set_callstack(F_STACK_FRAME *to,
F_STACK_FRAME *from,
CELL length,
void *(*memcpy)(void*,const void*, size_t));
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* used during garbage collection only */
F_ZONE *newspace;
bool performing_gc;
@ -682,3 +685,5 @@ VM_C_API void minor_gc(void)
{
garbage_collection(NURSERY,false,0);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
/* statistics */
struct F_GC_STATS {
CELL collections;
@ -133,3 +136,5 @@ inline static void check_tagged_pointer(CELL tagged)
VM_C_API void minor_gc(void);
}

View File

@ -1,5 +1,10 @@
#include "master.hpp"
factor::F_ZONE nursery;
namespace factor
{
/* Set by the -securegc command line argument */
bool secure_gc;
@ -11,8 +16,6 @@ bool gc_off;
F_DATA_HEAP *data_heap;
F_ZONE nursery;
CELL init_zone(F_ZONE *z, CELL size, CELL start)
{
z->size = size;
@ -375,3 +378,5 @@ CELL find_all_words(void)
words.trim();
return words.array.value();
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
/* Set by the -securegc command line argument */
extern bool secure_gc;
@ -46,9 +49,6 @@ extern F_DATA_HEAP *data_heap;
#define MIN_GEN_COUNT 1
#define MAX_GEN_COUNT 3
/* new objects are allocated here */
extern F_ZONE nursery;
inline static bool in_zone(F_ZONE *z, F_OBJECT *pointer)
{
return (CELL)pointer >= z->start && (CELL)pointer < z->end;
@ -128,3 +128,7 @@ inline static void do_slots(CELL obj, void (* iter)(CELL *))
}
}
}
/* new objects are allocated here */
VM_C_API factor::F_ZONE nursery;

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
static bool fep_disabled;
static bool full_output;
@ -472,3 +475,5 @@ PRIMITIVE(die)
print_string("you have triggered a bug in Factor. Please report.\n");
factorbug();
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
void print_obj(CELL obj);
void print_nested_obj(CELL obj, F_FIXNUM nesting);
void dump_generations(void);
@ -5,3 +8,5 @@ void factorbug(void);
void dump_zone(F_ZONE *z);
PRIMITIVE(die);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
CELL megamorphic_cache_hits;
CELL megamorphic_cache_misses;
@ -205,3 +208,5 @@ void quotation_jit::emit_mega_cache_lookup(CELL methods_, F_FIXNUM index, CELL c
emit(userenv[JIT_EPILOG]);
emit(userenv[JIT_EXECUTE_JUMP]);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
CELL lookup_method(CELL object, CELL methods);
PRIMITIVE(lookup_method);
@ -11,3 +14,5 @@ PRIMITIVE(dispatch_stats);
void jit_emit_class_lookup(jit *jit, F_FIXNUM index, CELL type);
void jit_emit_mega_cache_lookup(jit *jit, CELL methods, F_FIXNUM index, CELL cache);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* Global variables used to pass fault handler state from signal handler to
user-space */
CELL signal_number;
@ -147,3 +150,5 @@ void misc_signal_handler_impl(void)
{
signal_error(signal_number,signal_callstack_top);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
/* Runtime errors */
typedef enum
{
@ -44,3 +47,5 @@ extern F_STACK_FRAME *signal_callstack_top;
void memory_signal_handler_impl(void);
void misc_signal_handler_impl(void);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
VM_C_API void default_parameters(F_PARAMETERS *p)
{
p->image_path = NULL;
@ -209,3 +212,5 @@ VM_C_API void factor_sleep(long us)
void (*callback)(long) = (void (*)(long))alien_offset(userenv[SLEEP_CALLBACK_ENV]);
callback(us);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
VM_C_API void default_parameters(F_PARAMETERS *p);
VM_C_API void init_parameters_from_args(F_PARAMETERS *p, int argc, F_CHAR **argv);
VM_C_API void init_factor(F_PARAMETERS *p);
@ -9,3 +12,5 @@ VM_C_API char *factor_eval_string(char *string);
VM_C_API void factor_eval_free(char *result);
VM_C_API void factor_yield(void);
VM_C_API void factor_sleep(long ms);
}

View File

@ -1,3 +1,6 @@
namespace factor
{
/* Some functions for converting floating point numbers to binary
representations and vice versa */
@ -38,3 +41,5 @@ inline static float bits_float(u32 y)
b.y = y;
return b.x;
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
template<typename T> CELL array_capacity(T *array)
{
#ifdef FACTOR_DEBUG
@ -52,3 +55,5 @@ template <typename T> T *reallot_array(T *array_, CELL capacity)
return new_array;
}
}
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* Certain special objects in the image are known to the runtime */
static void init_objects(F_IMAGE_HEADER *h)
{
@ -337,3 +340,5 @@ void load_image(F_PARAMETERS *p)
/* Store image path name */
userenv[IMAGE_ENV] = allot_alien(F,(CELL)p->image_path);
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
#define IMAGE_MAGIC 0x0f0e0d0c
#define IMAGE_VERSION 4
@ -43,3 +46,5 @@ bool save_image(const F_CHAR *file);
PRIMITIVE(save_image);
PRIMITIVE(save_image_and_exit);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
CELL max_pic_size;
CELL cold_call_to_ic_transitions;
@ -252,3 +255,5 @@ PRIMITIVE(inline_cache_stats)
stats.trim();
dpush(stats.array.value());
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
extern CELL max_pic_size;
void init_inline_caching(int max_size);
@ -7,3 +10,5 @@ PRIMITIVE(inline_cache_stats);
PRIMITIVE(inline_cache_miss);
extern "C" XT inline_cache_miss(CELL return_address);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* Simple wrappers for ANSI C I/O functions, used for bootstrapping.
Note the ugly loop logic in almost every function; we have to handle EINTR
@ -222,3 +225,5 @@ VM_C_API void clear_err_no(void)
{
errno = 0;
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
void init_c_io(void);
void io_error(void);
@ -17,3 +20,5 @@ PRIMITIVE(read_dir);
VM_C_API int err_no(void);
VM_C_API void clear_err_no(void);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* Simple code generator used by:
- profiler (profiler.cpp),
- quotation compiler (quotations.cpp),
@ -112,3 +115,5 @@ F_CODE_BLOCK *jit::code_block()
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
struct jit {
CELL type;
gc_root<F_OBJECT> owner;
@ -57,3 +60,5 @@ struct jit {
F_CODE_BLOCK *code_block();
};
}

View File

@ -1,3 +1,6 @@
namespace factor
{
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
@ -324,3 +327,5 @@ struct F_TUPLE : public F_OBJECT {
CELL *data() { return (CELL *)(this + 1); }
};
}

View File

@ -1,7 +1,12 @@
#include "master.hpp"
namespace factor
{
F_SEGMENT *gc_locals_region;
CELL gc_locals;
F_SEGMENT *gc_bignums_region;
CELL gc_bignums;
}

View File

@ -1,3 +1,6 @@
namespace factor
{
/* If a runtime function needs to call another function which potentially
allocates memory, it must wrap any local variable references to Factor
objects in gc_root instances */
@ -40,3 +43,5 @@ struct gc_bignum
};
#define GC_BIGNUM(x) gc_bignum x##__gc_root(&x)
}

View File

@ -1,5 +1,6 @@
/* Fault handler information. MacOSX version.
Copyright (C) 1993-1999, 2002-2003 Bruno Haible <clisp.org at bruno>
Copyright (C) 2003 Paolo Bonzini <gnu.org at bonzini>
Used under BSD license with permission from Paolo Bonzini and Bruno Haible,
@ -11,6 +12,9 @@ Modified for Factor by Slava Pestov */
#include "master.hpp"
namespace factor
{
/* The exception port on which our thread listens. */
mach_port_t our_exception_port;
@ -164,7 +168,6 @@ mach_exception_thread (void *arg)
}
}
/* Initialize the Mach exception handler thread. */
void mach_initialize (void)
{
@ -201,3 +204,5 @@ void mach_initialize (void)
!= KERN_SUCCESS)
fatal_error("task_set_exception_ports() failed",0);
}
}

View File

@ -76,4 +76,9 @@ catch_exception_raise_state_identity (mach_port_t exception_port,
thread_state_t out_state,
mach_msg_type_number_t *out_state_count);
namespace factor
{
void mach_initialize (void);
}

View File

@ -2,6 +2,6 @@
int main(int argc, char **argv)
{
start_standalone_factor(argc,argv);
factor::start_standalone_factor(argc,argv);
return 0;
}

View File

@ -128,7 +128,7 @@ WinMain(
int nCmdShow)
{
parse_args(&__argc, &__argv, lpCmdLine);
start_standalone_factor(__argc,(LPWSTR*)__argv);
factor::start_standalone_factor(__argc,(LPWSTR*)__argv);
// memory leak from malloc, wcsdup
return 0;
}

View File

@ -1,6 +1,3 @@
#include <windows.h>
#include <stdio.h>
#include <shellapi.h>
#include "master.hpp"
int WINAPI WinMain(
@ -19,7 +16,7 @@ int WINAPI WinMain(
return 1;
}
start_standalone_factor(nArgs,szArglist);
factor::start_standalone_factor(nArgs,szArglist);
LocalFree(szArglist);

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
CELL bignum_zero;
CELL bignum_pos_one;
CELL bignum_neg_one;
@ -509,3 +512,5 @@ VM_ASM_API void overflow_fixnum_multiply(F_FIXNUM x, F_FIXNUM y)
GC_BIGNUM(by);
drepl(tag<F_BIGNUM>(bignum_multiply(bx,by)));
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
extern CELL bignum_zero;
extern CELL bignum_pos_one;
extern CELL bignum_neg_one;
@ -142,3 +145,5 @@ VM_C_API CELL to_cell(CELL tagged);
VM_ASM_API void overflow_fixnum_add(F_FIXNUM x, F_FIXNUM y);
VM_ASM_API void overflow_fixnum_subtract(F_FIXNUM x, F_FIXNUM y);
VM_ASM_API void overflow_fixnum_multiply(F_FIXNUM x, F_FIXNUM y);
}

View File

@ -1,5 +1,8 @@
#include <ucontext.h>
namespace factor
{
inline static void *ucontext_stack_pointer(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
@ -7,3 +10,5 @@ inline static void *ucontext_stack_pointer(void *uap)
}
#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)(ucontext))->uc_mcontext.mc_eip)
}

View File

@ -1,5 +1,8 @@
#include <ucontext.h>
namespace factor
{
inline static void *ucontext_stack_pointer(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
@ -7,3 +10,5 @@ inline static void *ucontext_stack_pointer(void *uap)
}
#define UAP_PROGRAM_COUNTER(ucontext) (((ucontext_t *)(ucontext))->uc_mcontext.mc_rip)
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* From SBCL */
const char *vm_executable_path(void)
{
@ -32,3 +35,5 @@ const char *vm_executable_path(void)
return safe_strdup(path);
}
}

View File

@ -1,9 +1,8 @@
#include <osreldate.h>
extern int getosreldate(void);
#include <sys/sysctl.h>
extern "C" int getosreldate(void);
#ifndef KERN_PROC_PATHNAME
#define KERN_PROC_PATHNAME 12
#endif

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
void c_to_factor_toplevel(CELL quot)
{
c_to_factor(quot);
@ -33,3 +36,5 @@ const char *default_image_path(void)
memcpy(new_path + len,SUFFIX,SUFFIX_LEN + 1);
return new_path;
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
#define VM_C_API extern "C"
#define NULL_DLL NULL
@ -6,3 +9,5 @@ void init_signals(void);
void early_init(void);
const char *vm_executable_path(void);
const char *default_image_path(void);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
void flush_icache(CELL start, CELL len)
{
int result;
@ -24,3 +27,5 @@ void flush_icache(CELL start, CELL len)
if(result < 0)
critical_error("flush_icache() failed",result);
}
}

View File

@ -2,6 +2,9 @@
#include <asm/unistd.h>
#include <sys/syscall.h>
namespace factor
{
inline static void *ucontext_stack_pointer(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
@ -12,3 +15,5 @@ inline static void *ucontext_stack_pointer(void *uap)
(((ucontext_t *)(ucontext))->uc_mcontext.arm_pc)
void flush_icache(CELL start, CELL len);
}

View File

@ -1,5 +1,8 @@
#include <ucontext.h>
namespace factor
{
#define FRAME_RETURN_ADDRESS(frame) *((XT *)(frame_successor(frame) + 1) + 1)
inline static void *ucontext_stack_pointer(void *uap)
@ -10,3 +13,5 @@ inline static void *ucontext_stack_pointer(void *uap)
#define UAP_PROGRAM_COUNTER(ucontext) \
(((ucontext_t *)(ucontext))->uc_mcontext.uc_regs->gregs[PT_NIP])
}

View File

@ -1,5 +1,8 @@
#include <ucontext.h>
namespace factor
{
inline static void *ucontext_stack_pointer(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
@ -8,3 +11,5 @@ inline static void *ucontext_stack_pointer(void *uap)
#define UAP_PROGRAM_COUNTER(ucontext) \
(((ucontext_t *)(ucontext))->uc_mcontext.gregs[14])
}

View File

@ -1,5 +1,8 @@
#include <ucontext.h>
namespace factor
{
inline static void *ucontext_stack_pointer(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
@ -8,3 +11,5 @@ inline static void *ucontext_stack_pointer(void *uap)
#define UAP_PROGRAM_COUNTER(ucontext) \
(((ucontext_t *)(ucontext))->uc_mcontext.gregs[16])
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
/* Snarfed from SBCL linux-so.c. You must free() this yourself. */
const char *vm_executable_path(void)
{
@ -56,3 +59,5 @@ int inotify_rm_watch(int fd, u32 wd)
}
#endif
}

View File

@ -1,5 +1,10 @@
#include <sys/syscall.h>
namespace factor
{
int inotify_init(void);
int inotify_add_watch(int fd, const char *name, u32 mask);
int inotify_rm_watch(int fd, u32 wd);
}

View File

@ -1,3 +1,8 @@
#include <ucontext.h>
namespace factor
{
/* Fault handler information. MacOSX version.
Copyright (C) 1993-1999, 2002-2003 Bruno Haible <clisp.org at bruno>
Copyright (C) 2003 Paolo Bonzini <gnu.org at bonzini>
@ -8,8 +13,6 @@ Used under BSD license with permission from Paolo Bonzini and Bruno Haible,
http://sourceforge.net/mailarchive/message.php?msg_name=200503102200.32002.bruno%40clisp.org
Modified for Factor by Slava Pestov */
#include <ucontext.h>
#define FRAME_RETURN_ADDRESS(frame) *((XT *)(frame_successor(frame) + 1) + 2)
#define MACH_EXC_STATE_TYPE ppc_exception_state_t
@ -37,3 +40,5 @@ inline static CELL fix_stack_pointer(CELL sp)
{
return sp;
}
}

View File

@ -1,3 +1,8 @@
#include <ucontext.h>
namespace factor
{
/* Fault handler information. MacOSX version.
Copyright (C) 1993-1999, 2002-2003 Bruno Haible <clisp.org at bruno>
Copyright (C) 2003 Paolo Bonzini <gnu.org at bonzini>
@ -8,8 +13,6 @@ Used under BSD license with permission from Paolo Bonzini and Bruno Haible,
http://sourceforge.net/mailarchive/message.php?msg_name=200503102200.32002.bruno%40clisp.org
Modified for Factor by Slava Pestov */
#include <ucontext.h>
#define MACH_EXC_STATE_TYPE i386_exception_state_t
#define MACH_EXC_STATE_FLAVOR i386_EXCEPTION_STATE
#define MACH_EXC_STATE_COUNT i386_EXCEPTION_STATE_COUNT
@ -35,3 +38,5 @@ inline static CELL fix_stack_pointer(CELL sp)
{
return ((sp + 4) & ~15) - 4;
}
}

View File

@ -1,3 +1,8 @@
#include <ucontext.h>
namespace factor
{
/* Fault handler information. MacOSX version.
Copyright (C) 1993-1999, 2002-2003 Bruno Haible <clisp.org at bruno>
Copyright (C) 2003 Paolo Bonzini <gnu.org at bonzini>
@ -8,8 +13,6 @@ Used under BSD license with permission from Paolo Bonzini and Bruno Haible,
http://sourceforge.net/mailarchive/message.php?msg_name=200503102200.32002.bruno%40clisp.org
Modified for Factor by Slava Pestov and Daniel Ehrenberg */
#include <ucontext.h>
#define MACH_EXC_STATE_TYPE x86_exception_state64_t
#define MACH_EXC_STATE_FLAVOR x86_EXCEPTION_STATE64
#define MACH_EXC_STATE_COUNT x86_EXCEPTION_STATE64_COUNT
@ -35,3 +38,5 @@ inline static CELL fix_stack_pointer(CELL sp)
{
return ((sp + 8) & ~15) - 8;
}
}

View File

@ -1,3 +1,6 @@
namespace factor
{
#define VM_C_API extern "C" __attribute__((visibility("default")))
#define FACTOR_OS_STRING "macosx"
#define NULL_DLL "libfactor.dylib"
@ -15,3 +18,5 @@ inline static void *ucontext_stack_pointer(void *uap)
}
void c_to_factor_toplevel(CELL quot);
}

View File

@ -2,6 +2,9 @@
#include "master.hpp"
namespace factor
{
void c_to_factor_toplevel(CELL quot)
{
for(;;)
@ -80,3 +83,5 @@ Protocol *objc_getProtocol(char *name)
else
return nil;
}
}

View File

@ -1,3 +1,8 @@
#include <ucontext.h>
namespace factor
{
#define ucontext_stack_pointer(uap) ((void *)_UC_MACHINE_SP((ucontext_t *)uap))
}

View File

@ -1,4 +1,9 @@
#include <ucontext.h>
namespace factor
{
#define ucontext_stack_pointer(uap) \
((void *)(((ucontext_t *)(uap))->uc_mcontext.__gregs[_REG_URSP]))
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
extern int main();
const char *vm_executable_path(void)
@ -9,3 +12,5 @@ const char *vm_executable_path(void)
dladdr(main, &info);
return info.dli_fname;
}
}

View File

@ -1,5 +1,10 @@
#include <ucontext.h>
namespace factor
{
#define UAP_PROGRAM_COUNTER(uap) _UC_MACHINE_PC((ucontext_t *)uap)
#define DIRECTORY_P(file) ((file)->d_type == DT_DIR)
}

View File

@ -1,5 +1,8 @@
#include <i386/signal.h>
namespace factor
{
inline static void *openbsd_stack_pointer(void *uap)
{
struct sigcontext *sc = (struct sigcontext*) uap;
@ -8,3 +11,5 @@ inline static void *openbsd_stack_pointer(void *uap)
#define ucontext_stack_pointer openbsd_stack_pointer
#define UAP_PROGRAM_COUNTER(uap) (((struct sigcontext*)(uap))->sc_eip)
}

View File

@ -1,5 +1,8 @@
#include <amd64/signal.h>
namespace factor
{
inline static void *openbsd_stack_pointer(void *uap)
{
struct sigcontext *sc = (struct sigcontext*) uap;
@ -8,3 +11,5 @@ inline static void *openbsd_stack_pointer(void *uap)
#define ucontext_stack_pointer openbsd_stack_pointer
#define UAP_PROGRAM_COUNTER(uap) (((struct sigcontext*)(uap))->sc_rip)
}

View File

@ -1,6 +1,11 @@
#include "master.hpp"
namespace factor
{
const char *vm_executable_path(void)
{
return NULL;
}
}

View File

@ -1,5 +1,8 @@
#include <ucontext.h>
namespace factor
{
inline static void *ucontext_stack_pointer(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
@ -8,3 +11,5 @@ inline static void *ucontext_stack_pointer(void *uap)
#define UAP_PROGRAM_COUNTER(ucontext) \
(((ucontext_t *)(ucontext))->uc_mcontext.gregs[EIP])
}

View File

@ -1,5 +1,8 @@
#include <ucontext.h>
namespace factor
{
inline static void *ucontext_stack_pointer(void *uap)
{
ucontext_t *ucontext = (ucontext_t *)uap;
@ -8,3 +11,5 @@ inline static void *ucontext_stack_pointer(void *uap)
#define UAP_PROGRAM_COUNTER(ucontext) \
(((ucontext_t *)(ucontext))->uc_mcontext.gregs[RIP])
}

View File

@ -1,6 +1,11 @@
#include "master.hpp"
namespace factor
{
const char *vm_executable_path(void)
{
return NULL;
}
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
void start_thread(void *(*start_routine)(void *))
{
pthread_attr_t attr;
@ -311,3 +314,5 @@ VM_C_API void wait_for_stdin(void)
fatal_error("Error writing control fd",errno);
}
}
}

View File

@ -8,11 +8,12 @@
#include <signal.h>
#include <pthread.h>
namespace factor
{
typedef char F_CHAR;
typedef char F_SYMBOL;
#define string_to_native_alien(string) string_to_char_alien(string,true)
#define STRING_LITERAL(string) string
#define SSCANF sscanf
@ -54,3 +55,5 @@ s64 current_micros(void);
void sleep_micros(CELL usec);
void open_console(void);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
s64 current_micros(void)
{
SYSTEMTIME st;
@ -38,3 +41,5 @@ void c_to_factor_toplevel(CELL quot)
}
void open_console(void) { }
}

View File

@ -5,6 +5,9 @@
#include <windows.h>
#include <ctype.h>
namespace factor
{
typedef wchar_t F_SYMBOL;
#define FACTOR_OS_STRING "wince"
@ -22,3 +25,5 @@ char *getenv(char *name);
s64 current_micros(void);
void c_to_factor_toplevel(CELL quot);
void open_console(void);
}

View File

@ -1,2 +1,7 @@
namespace factor
{
#define ESP Esp
#define EIP Eip
}

View File

@ -1,2 +1,7 @@
namespace factor
{
#define ESP Rsp
#define EIP Rip
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
s64 current_micros(void)
{
FILETIME t;
@ -49,3 +52,5 @@ void c_to_factor_toplevel(CELL quot)
void open_console(void)
{
}
}

View File

@ -5,8 +5,12 @@
#define UNICODE
#endif
#include <shellapi.h>
#include <windows.h>
namespace factor
{
typedef char F_SYMBOL;
#define FACTOR_OS_STRING "winnt"
@ -16,3 +20,5 @@ typedef char F_SYMBOL;
void c_to_factor_toplevel(CELL quot);
long exception_handler(PEXCEPTION_POINTERS pe);
void open_console(void);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
HMODULE hFactorDll;
void init_ffi(void)
@ -144,3 +147,5 @@ void sleep_micros(u64 usec)
{
Sleep((DWORD)(usec / 1000));
}
}

View File

@ -5,9 +5,10 @@
#include <wchar.h>
#endif
typedef wchar_t F_CHAR;
namespace factor
{
#define string_to_native_alien(string) string_to_u16_alien(string,true)
typedef wchar_t F_CHAR;
#define STRING_LITERAL(string) L##string
@ -55,3 +56,4 @@ long getpagesize (void);
s64 current_micros(void);
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
void *primitives[] = {
(void *)primitive_bignum_to_fixnum,
(void *)primitive_float_to_fixnum,
@ -152,3 +155,5 @@ void *primitives[] = {
(void *)primitive_inline_cache_stats,
(void *)primitive_optimized_p,
};
}

View File

@ -1,5 +1,10 @@
namespace factor
{
//typedef extern "C" void (*F_PRIMITIVE)(void);
extern void *primitives[];
#define PRIMITIVE(name) extern "C" void primitive_##name()
}

View File

@ -1,5 +1,8 @@
#include "master.hpp"
namespace factor
{
bool profiling_p;
void init_profiler(void)
@ -50,3 +53,5 @@ PRIMITIVE(profiling)
{
set_profiling(to_boolean(dpop()));
}
}

View File

@ -1,4 +1,9 @@
namespace factor
{
extern bool profiling_p;
void init_profiler(void);
F_CODE_BLOCK *compile_profiling_stub(CELL word);
PRIMITIVE(profiling);
}

Some files were not shown because too many files have changed in this diff Show More