Browse Source

clang support

Nicolas Cannasse 8 years ago
parent
commit
61e9a845a2
7 changed files with 133 additions and 27 deletions
  1. 18 14
      src/alloc.c
  2. 14 2
      src/hl.h
  3. 5 1
      src/hlc.h
  4. 9 0
      src/std/date.c
  5. 1 0
      src/std/debug.c
  6. 4 0
      src/std/random.c
  7. 82 10
      src/std/sys.c

+ 18 - 14
src/alloc.c

@@ -84,6 +84,8 @@ static inline unsigned int TRAILING_ZEROES( unsigned int x ) {
 #	define GC_DEBUG
 #	define GC_DEBUG
 #endif
 #endif
 
 
+#define out_of_memory()		hl_fatal("Out of Memory")
+
 typedef struct _gc_pheader gc_pheader;
 typedef struct _gc_pheader gc_pheader;
 
 
 struct _gc_pheader {
 struct _gc_pheader {
@@ -280,7 +282,7 @@ retry:
 		hl_gc_major();
 		hl_gc_major();
 		if( pages != gc_stats.pages_allocated ) goto retry;
 		if( pages != gc_stats.pages_allocated ) goto retry;
 		if( gc_flags & GC_DUMP_MEM ) hl_gc_dump_memory("hlmemory.dump");
 		if( gc_flags & GC_DUMP_MEM ) hl_gc_dump_memory("hlmemory.dump");
-		hl_fatal("Out of memory");
+		out_of_memory();
 	}
 	}
 
 
 #	ifdef HL_64
 #	ifdef HL_64
@@ -567,7 +569,7 @@ void *hl_gc_alloc_gen( int size, int flags ) {
 	}
 	}
 	ptr = alloc_all;
 	ptr = alloc_all;
 	alloc_all += size;
 	alloc_all += size;
-	if( alloc_all > alloc_end ) hl_fatal("Out of memory");
+	if( alloc_all > alloc_end ) out_of_memory();
 #else
 #else
 	gc_check_mark();
 	gc_check_mark();
 	if( gc_flags & GC_PROFILE ) time = TIMESTAMP();
 	if( gc_flags & GC_PROFILE ) time = TIMESTAMP();
@@ -609,7 +611,7 @@ HL_PRIM void **hl_gc_mark_grow( void **stack ) {
 	int avail = (int)(stack - base_stack);
 	int avail = (int)(stack - base_stack);
 	if( nstack == NULL ) {
 	if( nstack == NULL ) {
 		// try to recover / eliminate fully scanned elements
 		// try to recover / eliminate fully scanned elements
-		void **st = base_stack + 2;
+/*		void **st = base_stack + 2;
 		void **out = st;
 		void **out = st;
 		while( st < stack ) {
 		while( st < stack ) {
 			void **block = (void**)*st++;
 			void **block = (void**)*st++;
@@ -635,9 +637,9 @@ HL_PRIM void **hl_gc_mark_grow( void **stack ) {
 				}
 				}
 			}
 			}
 		}
 		}
-		if( out == mark_stack_end )
-			hl_fatal("Out of memory");
-		return out;
+		if( out == mark_stack_end )*/
+			out_of_memory();
+		return NULL;
 	}
 	}
 	memcpy(nstack, base_stack, avail * sizeof(void*));
 	memcpy(nstack, base_stack, avail * sizeof(void*));
 	free(base_stack);
 	free(base_stack);
@@ -782,6 +784,7 @@ static void gc_mark() {
 		while( mark_size < mark_bytes )
 		while( mark_size < mark_bytes )
 			mark_size <<= 1;
 			mark_size <<= 1;
 		mark_data = gc_alloc_page_memory(mark_size);
 		mark_data = gc_alloc_page_memory(mark_size);
+		if( mark_data == NULL ) out_of_memory();
 	}
 	}
 	mark_cur = mark_data;
 	mark_cur = mark_data;
 	MZERO(mark_data,mark_bytes);
 	MZERO(mark_data,mark_bytes);
@@ -897,10 +900,12 @@ static void hl_gc_init( void *stack_top ) {
 		hl_fatal("Invalid builtin tl1");
 		hl_fatal("Invalid builtin tl1");
 	if( TRAILING_ZEROES((unsigned)~0x080003FF) != 10 || TRAILING_ZEROES(0) != 32 || TRAILING_ZEROES(0xFFFFFFFF) != 0 )
 	if( TRAILING_ZEROES((unsigned)~0x080003FF) != 10 || TRAILING_ZEROES(0) != 32 || TRAILING_ZEROES(0xFFFFFFFF) != 0 )
 		hl_fatal("Invalid builtin tl0");
 		hl_fatal("Invalid builtin tl0");
+#	ifndef HL_PS
 	if( getenv("HL_GC_PROFILE") )
 	if( getenv("HL_GC_PROFILE") )
 		gc_flags |= GC_PROFILE;
 		gc_flags |= GC_PROFILE;
 	if( getenv("HL_DUMP_MEMORY") )
 	if( getenv("HL_DUMP_MEMORY") )
 		gc_flags |= GC_DUMP_MEM;
 		gc_flags |= GC_DUMP_MEM;
+#	endif
 }
 }
 
 
 // ---- UTILITIES ----------------------
 // ---- UTILITIES ----------------------
@@ -932,10 +937,7 @@ void *hl_malloc( hl_alloc *a, int size ) {
 	if( b == NULL || b->size <= size ) {
 	if( b == NULL || b->size <= size ) {
 		int alloc = size < 4096-sizeof(hl_alloc_block) ? 4096-sizeof(hl_alloc_block) : size;
 		int alloc = size < 4096-sizeof(hl_alloc_block) ? 4096-sizeof(hl_alloc_block) : size;
 		b = (hl_alloc_block *)malloc(sizeof(hl_alloc_block) + alloc);
 		b = (hl_alloc_block *)malloc(sizeof(hl_alloc_block) + alloc);
-		if( b == NULL ) {
-			printf("Out of memory");
-			exit(99);
-		}
+		if( b == NULL ) out_of_memory();
 		b->p = ((unsigned char*)b) + sizeof(hl_alloc_block);
 		b->p = ((unsigned char*)b) + sizeof(hl_alloc_block);
 		b->size = alloc;
 		b->size = alloc;
 		b->next = a->cur;
 		b->next = a->cur;
@@ -975,8 +977,10 @@ HL_PRIM void *hl_alloc_executable_memory( int size ) {
 #     		define MAP_ANONYMOUS MAP_ANON
 #     		define MAP_ANONYMOUS MAP_ANON
 #       endif
 #       endif
 #endif
 #endif
-#ifdef HL_WIN
+#if defined(HL_WIN)
 	return VirtualAlloc(NULL,size,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
 	return VirtualAlloc(NULL,size,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
+#elif defined(HL_PS)
+	return NULL;
 #else
 #else
 	void *p;
 	void *p;
 	p = mmap(NULL,size,PROT_READ|PROT_WRITE|PROT_EXEC,(MAP_PRIVATE|MAP_ANONYMOUS),-1,0);
 	p = mmap(NULL,size,PROT_READ|PROT_WRITE|PROT_EXEC,(MAP_PRIVATE|MAP_ANONYMOUS),-1,0);
@@ -985,15 +989,15 @@ HL_PRIM void *hl_alloc_executable_memory( int size ) {
 }
 }
 
 
 HL_PRIM void hl_free_executable_memory( void *c, int size ) {
 HL_PRIM void hl_free_executable_memory( void *c, int size ) {
-#ifdef HL_WIN
+#if defined(HL_WIN)
 	VirtualFree(c,0,MEM_RELEASE);
 	VirtualFree(c,0,MEM_RELEASE);
-#else
+#elif !defined(HL_PS)
 	munmap(c, size);
 	munmap(c, size);
 #endif
 #endif
 }
 }
 
 
 static void *gc_alloc_page_memory( int size ) {
 static void *gc_alloc_page_memory( int size ) {
-#ifdef HL_WIN
+#if defined(HL_WIN)
 	return VirtualAlloc(NULL,size,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
 	return VirtualAlloc(NULL,size,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE);
 #else
 #else
 	void *ptr;
 	void *ptr;

+ 14 - 2
src/hl.h

@@ -37,7 +37,12 @@
 #	define _GNU_SOURCE
 #	define _GNU_SOURCE
 #endif
 #endif
 
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#ifdef __ORBIS__
+#	define HL_PS
+#	define HL_PS_API(name,fun)	sce##name##fun
+#endif
+
+#if (defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && !defined(HL_PS)
 #	define HL_BSD
 #	define HL_BSD
 #endif
 #endif
 
 
@@ -61,6 +66,10 @@
 #	define HL_LLVM
 #	define HL_LLVM
 #endif
 #endif
 
 
+#if defined(__clang__)
+#	define HL_CLANG
+#endif
+
 #if defined(_MSC_VER) && !defined(HL_LLVM)
 #if defined(_MSC_VER) && !defined(HL_LLVM)
 #	define HL_VCC
 #	define HL_VCC
 #	pragma warning(disable:4996) // remove deprecated C API usage warnings
 #	pragma warning(disable:4996) // remove deprecated C API usage warnings
@@ -182,8 +191,10 @@ HL_API void uprintf( const uchar *fmt, const uchar *str );
 C_FUNCTION_END
 C_FUNCTION_END
 #endif
 #endif
 
 
-#ifdef HL_VCC
+#if defined(HL_VCC)
 #	define hl_debug_break()	if( IsDebuggerPresent() ) __debugbreak()
 #	define hl_debug_break()	if( IsDebuggerPresent() ) __debugbreak()
+#elif defined(HL_PS)
+#	define hl_debug_break()	__debugbreak()
 #else
 #else
 #	define hl_debug_break()
 #	define hl_debug_break()
 #endif
 #endif
@@ -590,6 +601,7 @@ HL_API const uchar *hl_type_str( hl_type *t );
 #undef _NULL
 #undef _NULL
 #define _NULL(t)					"N" t
 #define _NULL(t)					"N" t
 
 
+#undef _STRING
 #define _STRING						_OBJ(_BYTES _I32)
 #define _STRING						_OBJ(_BYTES _I32)
 
 
 typedef struct {
 typedef struct {

+ 5 - 1
src/hlc.h

@@ -54,9 +54,13 @@
 #else
 #else
 #	pragma GCC diagnostic ignored "-Wunused-variable"
 #	pragma GCC diagnostic ignored "-Wunused-variable"
 #	pragma GCC diagnostic ignored "-Wunused-function"
 #	pragma GCC diagnostic ignored "-Wunused-function"
+#	pragma GCC diagnostic ignored "-Wcomment" // comment in comment
+#	ifdef HL_CLANG
+#	pragma GCC diagnostic ignored "-Wreturn-type"
+#else
 #	pragma GCC diagnostic ignored "-Wunused-but-set-variable"
 #	pragma GCC diagnostic ignored "-Wunused-but-set-variable"
 #	pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
 #	pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
-#	pragma GCC diagnostic ignored "-Wcomment" // comment in comment
+#	endif
 #endif
 #endif
 
 
 static void hl_null_access() {
 static void hl_null_access() {

+ 9 - 0
src/std/date.c

@@ -22,6 +22,15 @@
 #include <hl.h>
 #include <hl.h>
 #include <time.h>
 #include <time.h>
 
 
+#ifdef HL_PS
+static struct tm *localtime_r( const time_t *clock, struct tm *result ) {
+	struct tm *tt = localtime(clock);
+	if( !tt ) return NULL;
+	*result = *tt;
+	return result;
+}
+#endif
+
 #ifdef HL_WIN
 #ifdef HL_WIN
 
 
 static struct tm *localtime_r( time_t *t, struct tm *r ) {
 static struct tm *localtime_r( time_t *t, struct tm *r ) {

+ 1 - 0
src/std/debug.c

@@ -98,6 +98,7 @@ HL_API bool hl_debug_flush( int pid, vbyte *addr, int size ) {
 #	ifdef HL_WIN
 #	ifdef HL_WIN
 	return (bool)FlushInstructionCache(OpenPID(pid),addr,size);
 	return (bool)FlushInstructionCache(OpenPID(pid),addr,size);
 #	else
 #	else
+	return false;
 #	endif
 #	endif
 }
 }
 
 

+ 4 - 0
src/std/random.c

@@ -31,6 +31,10 @@
 #	include <unistd.h>
 #	include <unistd.h>
 #endif
 #endif
 
 
+#ifdef HL_PS
+#define getpid() 0
+#endif
+
 #define NSEEDS	25
 #define NSEEDS	25
 #define MAX		7
 #define MAX		7
 
 

+ 82 - 10
src/std/sys.c

@@ -46,12 +46,14 @@ typedef struct _stat32 pstat;
 #else
 #else
 #	include <errno.h>
 #	include <errno.h>
 #	include <unistd.h>
 #	include <unistd.h>
-#	include <dirent.h>
 #	include <limits.h>
 #	include <limits.h>
-#	include <termios.h>
 #	include <sys/time.h>
 #	include <sys/time.h>
+#ifndef HL_PS
+#	include <dirent.h>
+#	include <termios.h>
 #	include <sys/times.h>
 #	include <sys/times.h>
 #	include <sys/wait.h>
 #	include <sys/wait.h>
+#endif
 #	include <locale.h>
 #	include <locale.h>
 #	define HL_UTF8PATH
 #	define HL_UTF8PATH
 typedef struct stat pstat;
 typedef struct stat pstat;
@@ -77,6 +79,14 @@ typedef uchar pchar;
 #	define CLK_TCK	100
 #	define CLK_TCK	100
 #endif
 #endif
 
 
+#ifdef HL_PS
+#include <kernel.h>
+int	gettimeofday(struct timeval *t, struct timezone *tz) {
+	HL_PS_API(Kernel,Gettimeofday)(t);
+	return 0;
+}
+#endif
+
 static pchar *pstrdup( const pchar *s, int len ) {
 static pchar *pstrdup( const pchar *s, int len ) {
 	pchar *ret;
 	pchar *ret;
 	if( len < 0 ) len = (int)pstrlen(s);
 	if( len < 0 ) len = (int)pstrlen(s);
@@ -104,6 +114,8 @@ HL_PRIM vbyte *hl_sys_string() {
 	return (vbyte*)USTR("BSD");
 	return (vbyte*)USTR("BSD");
 #elif defined(HL_MAC)
 #elif defined(HL_MAC)
 	return (vbyte*)USTR("Mac");
 	return (vbyte*)USTR("Mac");
+#elif defined(HL_PS)
+	return (vbyte*)USTR("PS");
 #else
 #else
 #error Unknow system string
 #error Unknow system string
 #endif
 #endif
@@ -148,16 +160,22 @@ HL_PRIM double hl_sys_time() {
 }
 }
 
 
 HL_PRIM vbyte *hl_sys_get_env( vbyte *v ) {
 HL_PRIM vbyte *hl_sys_get_env( vbyte *v ) {
+#	ifdef HL_PS
+	return NULL;
+#	else
 	return (vbyte*)getenv((pchar*)v);
 	return (vbyte*)getenv((pchar*)v);
+#	endif
 }
 }
 
 
 HL_PRIM bool hl_sys_put_env( vbyte *e, vbyte *v ) {
 HL_PRIM bool hl_sys_put_env( vbyte *e, vbyte *v ) {
-#ifdef HL_WIN
+#if defined(HL_WIN)
 	hl_buffer *b = hl_alloc_buffer();
 	hl_buffer *b = hl_alloc_buffer();
 	hl_buffer_str(b,(uchar*)e);
 	hl_buffer_str(b,(uchar*)e);
 	hl_buffer_char(b,'=');
 	hl_buffer_char(b,'=');
 	if( v ) hl_buffer_str(b,(uchar*)v);
 	if( v ) hl_buffer_str(b,(uchar*)v);
 	return putenv(hl_buffer_content(b,NULL)) == 0;
 	return putenv(hl_buffer_content(b,NULL)) == 0;
+#elif defined(HL_PS)
+	return false;
 #else
 #else
 	if( v == NULL ) return unsetenv((char*)e) == 0;
 	if( v == NULL ) return unsetenv((char*)e) == 0;
 	return setenv((char*)e,(char*)v,1) == 0;
 	return setenv((char*)e,(char*)v,1) == 0;
@@ -176,6 +194,9 @@ extern char **environ;
 #endif
 #endif
 
 
 HL_PRIM varray *hl_sys_env() {
 HL_PRIM varray *hl_sys_env() {
+#ifdef HL_PS
+	return hl_alloc_array(&hlt_bytes,0);
+#else
 	varray *a;
 	varray *a;
 	pchar **e = environ;
 	pchar **e = environ;
 	pchar **arr;
 	pchar **arr;
@@ -203,12 +224,15 @@ HL_PRIM varray *hl_sys_env() {
 		e++;
 		e++;
 	}
 	}
 	return a;
 	return a;
+#endif
 }
 }
 
 
 
 
 HL_PRIM void hl_sys_sleep( double f ) {
 HL_PRIM void hl_sys_sleep( double f ) {
-#ifdef HL_WIN
+#if defined(HL_WIN)
 	Sleep((DWORD)(f * 1000));
 	Sleep((DWORD)(f * 1000));
+#elif defined(HL_PS)
+	// nothing
 #else
 #else
 	struct timespec t;
 	struct timespec t;
 	t.tv_sec = (int)f;
 	t.tv_sec = (int)f;
@@ -237,6 +261,9 @@ HL_PRIM bool hl_sys_set_time_locale( vbyte *l ) {
 
 
 
 
 HL_PRIM vbyte *hl_sys_get_cwd() {
 HL_PRIM vbyte *hl_sys_get_cwd() {
+#	ifdef HL_PS
+	return (vbyte*)"";
+#	else
 	pchar buf[256];
 	pchar buf[256];
 	int l;
 	int l;
 	if( getcwd(buf,256) == NULL )
 	if( getcwd(buf,256) == NULL )
@@ -247,10 +274,15 @@ HL_PRIM vbyte *hl_sys_get_cwd() {
 		buf[l+1] = 0;
 		buf[l+1] = 0;
 	}
 	}
 	return (vbyte*)pstrdup(buf,-1);
 	return (vbyte*)pstrdup(buf,-1);
+#	endif
 }
 }
 
 
 HL_PRIM bool hl_sys_set_cwd( vbyte *dir ) {
 HL_PRIM bool hl_sys_set_cwd( vbyte *dir ) {
+#ifdef HL_PS
+	return false;
+#else
 	return chdir((pchar*)dir) == 0;
 	return chdir((pchar*)dir) == 0;
+#endif
 }
 }
 
 
 HL_PRIM bool hl_sys_is64() {
 HL_PRIM bool hl_sys_is64() {
@@ -262,8 +294,10 @@ HL_PRIM bool hl_sys_is64() {
 }
 }
 
 
 HL_PRIM int hl_sys_command( vbyte *cmd ) {
 HL_PRIM int hl_sys_command( vbyte *cmd ) {
-#ifdef HL_WIN
+#if defined(HL_WIN)
 	return system((pchar*)cmd);
 	return system((pchar*)cmd);
+#elif defined(HL_PS)
+	return -1;
 #else
 #else
 	int status = system((pchar*)cmd);
 	int status = system((pchar*)cmd);
 	return WEXITSTATUS(status) | (WTERMSIG(status) << 8);
 	return WEXITSTATUS(status) | (WTERMSIG(status) << 8);
@@ -271,19 +305,34 @@ HL_PRIM int hl_sys_command( vbyte *cmd ) {
 }
 }
 
 
 HL_PRIM bool hl_sys_exists( vbyte *path ) {
 HL_PRIM bool hl_sys_exists( vbyte *path ) {
+#if defined(HL_PS)
+	return false;
+#else
 	pstat st;
 	pstat st;
 	return stat((pchar*)path,&st) == 0;
 	return stat((pchar*)path,&st) == 0;
+#endif
 }
 }
 
 
 HL_PRIM bool hl_sys_delete( vbyte *path ) {
 HL_PRIM bool hl_sys_delete( vbyte *path ) {
+#if defined(HL_PS)
+	return false;
+#else
 	return unlink((pchar*)path) == 0;
 	return unlink((pchar*)path) == 0;
+#endif
 }
 }
 
 
 HL_PRIM bool hl_sys_rename( vbyte *path, vbyte *newname ) {
 HL_PRIM bool hl_sys_rename( vbyte *path, vbyte *newname ) {
+#if defined(HL_PS)
+	return false;
+#else
 	return rename((pchar*)path,(pchar*)newname) == 0;
 	return rename((pchar*)path,(pchar*)newname) == 0;
+#endif
 }
 }
 
 
 HL_PRIM varray *hl_sys_stat( vbyte *path ) {
 HL_PRIM varray *hl_sys_stat( vbyte *path ) {
+#if defined(HL_PS)
+	return NULL;
+#else
 	pstat s;
 	pstat s;
 	varray *a;
 	varray *a;
 	int *i;
 	int *i;
@@ -303,31 +352,46 @@ HL_PRIM varray *hl_sys_stat( vbyte *path ) {
 	*i++ = s.st_rdev;
 	*i++ = s.st_rdev;
 	*i++ = s.st_mode;
 	*i++ = s.st_mode;
 	return a;
 	return a;
+#endif
 }
 }
 
 
 HL_PRIM bool hl_sys_is_dir( vbyte *path ) {
 HL_PRIM bool hl_sys_is_dir( vbyte *path ) {
+#if defined(HL_PS)
+	return false;
+#else
 	pstat s;
 	pstat s;
 	if( stat((pchar*)path,&s) != 0 )
 	if( stat((pchar*)path,&s) != 0 )
 		return false;
 		return false;
 	return (s.st_mode & S_IFDIR) != 0;
 	return (s.st_mode & S_IFDIR) != 0;
+#endif
 }
 }
 
 
 HL_PRIM bool hl_sys_create_dir( vbyte *path, int mode ) {
 HL_PRIM bool hl_sys_create_dir( vbyte *path, int mode ) {
+#if defined(HL_PS)
+	return false;
+#else
 	return mkdir((pchar*)path,mode) == 0;
 	return mkdir((pchar*)path,mode) == 0;
+#endif
 }
 }
 
 
 HL_PRIM bool hl_sys_remove_dir( vbyte *path ) {
 HL_PRIM bool hl_sys_remove_dir( vbyte *path ) {
+#if defined(HL_PS)
+	return false;
+#else
 	return rmdir((pchar*)path) == 0;
 	return rmdir((pchar*)path) == 0;
+#endif
 }
 }
 
 
 HL_PRIM double hl_sys_cpu_time() {
 HL_PRIM double hl_sys_cpu_time() {
-#ifdef HL_WIN
+#if defined(HL_WIN)
 	FILETIME unused;
 	FILETIME unused;
 	FILETIME stime;
 	FILETIME stime;
 	FILETIME utime;
 	FILETIME utime;
 	if( !GetProcessTimes(GetCurrentProcess(),&unused,&unused,&stime,&utime) )
 	if( !GetProcessTimes(GetCurrentProcess(),&unused,&unused,&stime,&utime) )
 		return 0.;
 		return 0.;
 	return ((double)(utime.dwHighDateTime+stime.dwHighDateTime)) * 65.536 * 6.5536 + (((double)utime.dwLowDateTime + (double)stime.dwLowDateTime) / 10000000);
 	return ((double)(utime.dwHighDateTime+stime.dwHighDateTime)) * 65.536 * 6.5536 + (((double)utime.dwLowDateTime + (double)stime.dwLowDateTime) / 10000000);
+#elif defined(HL_PS)
+	return 0.;
 #else
 #else
 	struct tms t;
 	struct tms t;
 	times(&t);
 	times(&t);
@@ -342,8 +406,8 @@ HL_PRIM double hl_sys_thread_cpu_time() {
 	if( !GetThreadTimes(GetCurrentThread(),&unused,&unused,&unused,&utime) )
 	if( !GetThreadTimes(GetCurrentThread(),&unused,&unused,&unused,&utime) )
 		return 0.;
 		return 0.;
 	return ((double)utime.dwHighDateTime) * 65.536 * 6.5536 + (((double)utime.dwLowDateTime) / 10000000);
 	return ((double)utime.dwHighDateTime) * 65.536 * 6.5536 + (((double)utime.dwLowDateTime) / 10000000);
-#elif defined(HL_MAC)
-	hl_error("sys_thread_cpu_time not implemented on OSX");
+#elif defined(HL_MAC) || defined(HL_PS)
+	hl_error("sys_thread_cpu_time not implemented on this platform");
 	return 0.;
 	return 0.;
 #else
 #else
 	struct timespec t;
 	struct timespec t;
@@ -392,6 +456,8 @@ HL_PRIM varray *hl_sys_read_dir( vbyte *_path ) {
 			break;
 			break;
 	}
 	}
 	FindClose(handle);
 	FindClose(handle);
+#elif defined(HL_PS)
+	return NULL;
 #else
 #else
 	DIR *d;
 	DIR *d;
 	struct dirent *e;
 	struct dirent *e;
@@ -424,7 +490,7 @@ HL_PRIM varray *hl_sys_read_dir( vbyte *_path ) {
 }
 }
 
 
 HL_PRIM vbyte *hl_sys_full_path( vbyte *path ) {
 HL_PRIM vbyte *hl_sys_full_path( vbyte *path ) {
-#ifdef HL_WIN
+#if defined(HL_WIN)
 	pchar out[MAX_PATH+1];
 	pchar out[MAX_PATH+1];
 	int len, i, last;
 	int len, i, last;
 	HANDLE handle;
 	HANDLE handle;
@@ -471,6 +537,8 @@ HL_PRIM vbyte *hl_sys_full_path( vbyte *path ) {
 		last = i;
 		last = i;
 	}
 	}
 	return (vbyte*)pstrdup(out,len);
 	return (vbyte*)pstrdup(out,len);
+#elif defined(HL_PS)
+	return NULL;
 #else
 #else
 	pchar buf[PATH_MAX];
 	pchar buf[PATH_MAX];
 	if( realpath((pchar*)path,buf) == NULL )
 	if( realpath((pchar*)path,buf) == NULL )
@@ -491,6 +559,8 @@ HL_PRIM vbyte *hl_sys_exe_path() {
 	if( _NSGetExecutablePath(path, &path_len) )
 	if( _NSGetExecutablePath(path, &path_len) )
 		return NULL;
 		return NULL;
 	return (vbyte*)pstrdup(path,-1);
 	return (vbyte*)pstrdup(path,-1);
+#elif defined(HL_PS)
+	return NULL;
 #else
 #else
 	const pchar *p = getenv("_");
 	const pchar *p = getenv("_");
 	if( p != NULL )
 	if( p != NULL )
@@ -507,8 +577,10 @@ HL_PRIM vbyte *hl_sys_exe_path() {
 }
 }
 
 
 HL_PRIM int hl_sys_get_char( bool b ) {
 HL_PRIM int hl_sys_get_char( bool b ) {
-#	ifdef HL_WIN
+#	if defined(HL_WIN)
 	return b?getche():getch();
 	return b?getche():getch();
+#	elif defined(HL_PS)
+	return -1;
 #	else
 #	else
 	// took some time to figure out how to do that
 	// took some time to figure out how to do that
 	// without relying on ncurses, which clear the
 	// without relying on ncurses, which clear the