vm: hard tabs, indent width 8
							parent
							
								
									5a3ece19b3
								
							
						
					
					
						commit
						c3ae7f3a11
					
				| 
						 | 
				
			
			@ -44,36 +44,36 @@ extern "C" boolean_t exc_server (mach_msg_header_t *request_msg, mach_msg_header
 | 
			
		|||
extern "C"
 | 
			
		||||
kern_return_t
 | 
			
		||||
catch_exception_raise (mach_port_t exception_port,
 | 
			
		||||
                       mach_port_t thread,
 | 
			
		||||
                       mach_port_t task,
 | 
			
		||||
                       exception_type_t exception,
 | 
			
		||||
                       exception_data_t code,
 | 
			
		||||
                       mach_msg_type_number_t code_count);
 | 
			
		||||
		       mach_port_t thread,
 | 
			
		||||
		       mach_port_t task,
 | 
			
		||||
		       exception_type_t exception,
 | 
			
		||||
		       exception_data_t code,
 | 
			
		||||
		       mach_msg_type_number_t code_count);
 | 
			
		||||
extern "C"
 | 
			
		||||
kern_return_t
 | 
			
		||||
catch_exception_raise_state (mach_port_t exception_port,
 | 
			
		||||
                             exception_type_t exception,
 | 
			
		||||
                             exception_data_t code,
 | 
			
		||||
                             mach_msg_type_number_t code_count,
 | 
			
		||||
                             thread_state_flavor_t *flavor,
 | 
			
		||||
                             thread_state_t in_state,
 | 
			
		||||
                             mach_msg_type_number_t in_state_count,
 | 
			
		||||
                             thread_state_t out_state,
 | 
			
		||||
                             mach_msg_type_number_t *out_state_count);
 | 
			
		||||
			     exception_type_t exception,
 | 
			
		||||
			     exception_data_t code,
 | 
			
		||||
			     mach_msg_type_number_t code_count,
 | 
			
		||||
			     thread_state_flavor_t *flavor,
 | 
			
		||||
			     thread_state_t in_state,
 | 
			
		||||
			     mach_msg_type_number_t in_state_count,
 | 
			
		||||
			     thread_state_t out_state,
 | 
			
		||||
			     mach_msg_type_number_t *out_state_count);
 | 
			
		||||
 | 
			
		||||
extern "C"
 | 
			
		||||
kern_return_t
 | 
			
		||||
catch_exception_raise_state_identity (mach_port_t exception_port,
 | 
			
		||||
                                      mach_port_t thread,
 | 
			
		||||
                                      mach_port_t task,
 | 
			
		||||
                                      exception_type_t exception,
 | 
			
		||||
                                      exception_data_t code,
 | 
			
		||||
                                      mach_msg_type_number_t codeCnt,
 | 
			
		||||
                                      thread_state_flavor_t *flavor,
 | 
			
		||||
                                      thread_state_t in_state,
 | 
			
		||||
                                      mach_msg_type_number_t in_state_count,
 | 
			
		||||
                                      thread_state_t out_state,
 | 
			
		||||
                                      mach_msg_type_number_t *out_state_count);
 | 
			
		||||
				      mach_port_t thread,
 | 
			
		||||
				      mach_port_t task,
 | 
			
		||||
				      exception_type_t exception,
 | 
			
		||||
				      exception_data_t code,
 | 
			
		||||
				      mach_msg_type_number_t codeCnt,
 | 
			
		||||
				      thread_state_flavor_t *flavor,
 | 
			
		||||
				      thread_state_t in_state,
 | 
			
		||||
				      mach_msg_type_number_t in_state_count,
 | 
			
		||||
				      thread_state_t out_state,
 | 
			
		||||
				      mach_msg_type_number_t *out_state_count);
 | 
			
		||||
 | 
			
		||||
namespace factor
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,23 +34,23 @@ Modified for Factor by Slava Pestov */
 | 
			
		|||
	#define MACH_STACK_POINTER(thr_state) (thr_state)->__r1
 | 
			
		||||
	#define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->__srr0
 | 
			
		||||
 | 
			
		||||
        #define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__ss)
 | 
			
		||||
        #define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__fs)
 | 
			
		||||
	#define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__ss)
 | 
			
		||||
	#define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__fs)
 | 
			
		||||
 | 
			
		||||
        #define FPSCR(float_state) (float_state)->__fpscr
 | 
			
		||||
	#define FPSCR(float_state) (float_state)->__fpscr
 | 
			
		||||
#else
 | 
			
		||||
	#define MACH_EXC_STATE_FAULT(exc_state) (exc_state)->dar
 | 
			
		||||
	#define MACH_STACK_POINTER(thr_state) (thr_state)->r1
 | 
			
		||||
	#define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->srr0
 | 
			
		||||
 | 
			
		||||
        #define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->ss)
 | 
			
		||||
        #define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->fs)
 | 
			
		||||
	#define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->ss)
 | 
			
		||||
	#define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->fs)
 | 
			
		||||
 | 
			
		||||
        #define FPSCR(float_state) (float_state)->fpscr
 | 
			
		||||
	#define FPSCR(float_state) (float_state)->fpscr
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define UAP_PROGRAM_COUNTER(ucontext) \
 | 
			
		||||
        MACH_PROGRAM_COUNTER(UAP_SS(ucontext))
 | 
			
		||||
	MACH_PROGRAM_COUNTER(UAP_SS(ucontext))
 | 
			
		||||
 | 
			
		||||
inline static unsigned int mach_fpu_status(ppc_float_state_t *float_state)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,25 +32,25 @@ Modified for Factor by Slava Pestov */
 | 
			
		|||
	#define MACH_STACK_POINTER(thr_state) (thr_state)->__esp
 | 
			
		||||
	#define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->__eip
 | 
			
		||||
 | 
			
		||||
        #define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__ss)
 | 
			
		||||
        #define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__fs)
 | 
			
		||||
	#define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__ss)
 | 
			
		||||
	#define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__fs)
 | 
			
		||||
 | 
			
		||||
        #define MXCSR(float_state) (float_state)->__fpu_mxcsr
 | 
			
		||||
        #define X87SW(float_state) (float_state)->__fpu_fsw
 | 
			
		||||
	#define MXCSR(float_state) (float_state)->__fpu_mxcsr
 | 
			
		||||
	#define X87SW(float_state) (float_state)->__fpu_fsw
 | 
			
		||||
#else
 | 
			
		||||
	#define MACH_EXC_STATE_FAULT(exc_state) (exc_state)->faultvaddr
 | 
			
		||||
	#define MACH_STACK_POINTER(thr_state) (thr_state)->esp
 | 
			
		||||
	#define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->eip
 | 
			
		||||
 | 
			
		||||
        #define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->ss)
 | 
			
		||||
        #define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->fs)
 | 
			
		||||
	#define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->ss)
 | 
			
		||||
	#define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->fs)
 | 
			
		||||
 | 
			
		||||
        #define MXCSR(float_state) (float_state)->fpu_mxcsr
 | 
			
		||||
        #define X87SW(float_state) (float_state)->fpu_fsw
 | 
			
		||||
	#define MXCSR(float_state) (float_state)->fpu_mxcsr
 | 
			
		||||
	#define X87SW(float_state) (float_state)->fpu_fsw
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define UAP_PROGRAM_COUNTER(ucontext) \
 | 
			
		||||
        MACH_PROGRAM_COUNTER(UAP_SS(ucontext))
 | 
			
		||||
	MACH_PROGRAM_COUNTER(UAP_SS(ucontext))
 | 
			
		||||
 | 
			
		||||
inline static unsigned int mach_fpu_status(i386_float_state_t *float_state)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -66,8 +66,8 @@ inline static unsigned int uap_fpu_status(void *uap)
 | 
			
		|||
 | 
			
		||||
inline static void mach_clear_fpu_status(i386_float_state_t *float_state)
 | 
			
		||||
{
 | 
			
		||||
        MXCSR(float_state) &= 0xffffffc0;
 | 
			
		||||
        memset(&X87SW(float_state), 0, sizeof(X87SW(float_state)));
 | 
			
		||||
	MXCSR(float_state) &= 0xffffffc0;
 | 
			
		||||
	memset(&X87SW(float_state), 0, sizeof(X87SW(float_state)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline static void uap_clear_fpu_status(void *uap)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,24 +31,24 @@ Modified for Factor by Slava Pestov and Daniel Ehrenberg */
 | 
			
		|||
	#define MACH_EXC_STATE_FAULT(exc_state) (exc_state)->__faultvaddr
 | 
			
		||||
	#define MACH_STACK_POINTER(thr_state) (thr_state)->__rsp
 | 
			
		||||
	#define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->__rip
 | 
			
		||||
        #define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__ss)
 | 
			
		||||
        #define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__fs)
 | 
			
		||||
	#define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__ss)
 | 
			
		||||
	#define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->__fs)
 | 
			
		||||
 | 
			
		||||
        #define MXCSR(float_state) (float_state)->__fpu_mxcsr
 | 
			
		||||
        #define X87SW(float_state) (float_state)->__fpu_fsw
 | 
			
		||||
	#define MXCSR(float_state) (float_state)->__fpu_mxcsr
 | 
			
		||||
	#define X87SW(float_state) (float_state)->__fpu_fsw
 | 
			
		||||
#else
 | 
			
		||||
	#define MACH_EXC_STATE_FAULT(exc_state) (exc_state)->faultvaddr
 | 
			
		||||
	#define MACH_STACK_POINTER(thr_state) (thr_state)->rsp
 | 
			
		||||
	#define MACH_PROGRAM_COUNTER(thr_state) (thr_state)->rip
 | 
			
		||||
        #define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->ss)
 | 
			
		||||
        #define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->fs)
 | 
			
		||||
	#define UAP_SS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->ss)
 | 
			
		||||
	#define UAP_FS(ucontext) &(((ucontext_t *)(ucontext))->uc_mcontext->fs)
 | 
			
		||||
 | 
			
		||||
        #define MXCSR(float_state) (float_state)->fpu_mxcsr
 | 
			
		||||
        #define X87SW(float_state) (float_state)->fpu_fsw
 | 
			
		||||
	#define MXCSR(float_state) (float_state)->fpu_mxcsr
 | 
			
		||||
	#define X87SW(float_state) (float_state)->fpu_fsw
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define UAP_PROGRAM_COUNTER(ucontext) \
 | 
			
		||||
        MACH_PROGRAM_COUNTER(UAP_SS(ucontext))
 | 
			
		||||
	MACH_PROGRAM_COUNTER(UAP_SS(ucontext))
 | 
			
		||||
 | 
			
		||||
inline static unsigned int mach_fpu_status(x86_float_state64_t *float_state)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,7 +58,7 @@ BOOL factor_vm::windows_stat(vm_char *path)
 | 
			
		|||
void factor_vm::windows_image_path(vm_char *full_path, vm_char *temp_path, unsigned int length)
 | 
			
		||||
{
 | 
			
		||||
	wcsncpy(temp_path, full_path, length - 1);
 | 
			
		||||
        size_t full_path_len = wcslen(full_path);
 | 
			
		||||
	size_t full_path_len = wcslen(full_path);
 | 
			
		||||
	if (full_path_len < length - 1)
 | 
			
		||||
		wcsncat(temp_path, L".image", length - full_path_len - 1);
 | 
			
		||||
	temp_path[length - 1] = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +78,7 @@ const vm_char *factor_vm::default_image_path()
 | 
			
		|||
		*ptr = 0;
 | 
			
		||||
 | 
			
		||||
	wcsncpy(temp_path, full_path, MAX_UNICODE_PATH - 1);
 | 
			
		||||
        size_t full_path_len = wcslen(full_path);
 | 
			
		||||
	size_t full_path_len = wcslen(full_path);
 | 
			
		||||
	if (full_path_len < MAX_UNICODE_PATH - 1)
 | 
			
		||||
		wcsncat(temp_path, L".image", MAX_UNICODE_PATH - full_path_len - 1);
 | 
			
		||||
	temp_path[MAX_UNICODE_PATH - 1] = 0;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								vm/run.cpp
								
								
								
								
							
							
						
						
									
										13
									
								
								vm/run.cpp
								
								
								
								
							| 
						 | 
				
			
			@ -11,12 +11,13 @@ void factor_vm::primitive_exit()
 | 
			
		|||
void factor_vm::primitive_nano_count()
 | 
			
		||||
{
 | 
			
		||||
	u64 nanos = nano_count();
 | 
			
		||||
	if(nanos < last_nano_count) {
 | 
			
		||||
            std::cout << "Monotonic counter decreased from 0x";
 | 
			
		||||
            std::cout << std::hex << last_nano_count;
 | 
			
		||||
            std::cout << " to 0x" << nanos << "." << std::dec << "\n";
 | 
			
		||||
            std::cout << "Please report this error.\n";
 | 
			
		||||
            current_vm()->factorbug();
 | 
			
		||||
	if(nanos < last_nano_count)
 | 
			
		||||
	{
 | 
			
		||||
		std::cout << "Monotonic counter decreased from 0x";
 | 
			
		||||
		std::cout << std::hex << last_nano_count;
 | 
			
		||||
		std::cout << " to 0x" << nanos << "." << std::dec << "\n";
 | 
			
		||||
		std::cout << "Please report this error.\n";
 | 
			
		||||
		current_vm()->factorbug();
 | 
			
		||||
	}
 | 
			
		||||
	last_nano_count = nanos;
 | 
			
		||||
	ctx->push(from_unsigned_8(nanos));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue