浏览代码

more hl_ps support

Nicolas Cannasse 8 年之前
父节点
当前提交
5d863a0d1b
共有 3 个文件被更改,包括 23 次插入18 次删除
  1. 4 0
      libs/sdl/gl.c
  2. 14 3
      src/std/socket.c
  3. 5 15
      src/std/sys.c

+ 4 - 0
libs/sdl/gl.c

@@ -289,11 +289,13 @@ HL_PRIM vdynamic *HL_NAME(gl_create_shader)( int type ) {
 	return alloc_i32(s);
 }
 
+#ifndef HL_PS
 HL_PRIM void HL_NAME(gl_shader_source)( vdynamic *s, vstring *src ) {
 	const GLchar *c = (GLchar*)hl_to_utf8(src->bytes);
 	GLOG("%d,%s",s->v.i,c);
 	glShaderSource(s->v.i, 1, &c, NULL);
 }
+#endif
 
 HL_PRIM void HL_NAME(gl_compile_shader)( vdynamic *s ) {
 	GLOG("%d",s->v.i);
@@ -618,7 +620,9 @@ DEFINE_PRIM(_NULL(_I32),gl_get_uniform_location,_NULL(_I32) _STRING);
 DEFINE_PRIM(_I32,gl_get_attrib_location,_NULL(_I32) _STRING);
 DEFINE_PRIM(_VOID,gl_use_program,_NULL(_I32));
 DEFINE_PRIM(_NULL(_I32),gl_create_shader,_I32);
+#ifndef HL_PS
 DEFINE_PRIM(_VOID,gl_shader_source,_NULL(_I32) _STRING);
+#endif
 DEFINE_PRIM(_VOID,gl_compile_shader,_NULL(_I32));
 DEFINE_PRIM(_BYTES,gl_get_shader_info_bytes,_NULL(_I32));
 DEFINE_PRIM(_DYN,gl_get_shader_parameter,_NULL(_I32) _I32);

+ 14 - 3
src/std/socket.c

@@ -44,11 +44,22 @@
 #	include <netinet/tcp.h>
 #	include <arpa/inet.h>
 #	include <unistd.h>
+#	ifdef __ORBIS__
+#	include <net.h>
+struct hostent { unsigned int *h_addr_list[1]; const char *h_name; };
+extern unsigned int inet_addr( const char *host );
+extern const char *inet_ntoa( struct in_addr addr );
+extern struct hostent *gethostbyname( const char *name );
+extern struct hostent *gethostbyaddr( const void *addr, socklen_t len, int type);
+extern int gethostname( char *name, size_t len );
+#	define errno sce_net_errno
+#	else
 #	include <netdb.h>
+#	include <poll.h>
+#	endif
 #	include <fcntl.h>
 #	include <errno.h>
 #	include <stdio.h>
-#	include <poll.h>
 	typedef int SOCKET;
 #	define closesocket close
 #	define SOCKET_ERROR (-1)
@@ -176,7 +187,7 @@ HL_PRIM int hl_host_resolve( vbyte *host ) {
 	ip = inet_addr((char*)host);
 	if( ip == INADDR_NONE ) {
 		struct hostent *h;
-#	if defined(HL_WIN) || defined(HL_MAC) || defined (HL_CYGWIN)
+#	if defined(HL_WIN) || defined(HL_MAC) || defined (HL_CYGWIN) || defined(HL_PS)
 		h = gethostbyname((char*)host);
 #	else
 		struct hostent hbase;
@@ -199,7 +210,7 @@ HL_PRIM vbyte *hl_host_to_string( int ip ) {
 
 HL_PRIM vbyte *hl_host_reverse( int ip ) {
 	struct hostent *h;
-#	if defined(HL_WIN) || defined(HL_MAC) || defined(HL_CYGWIN)
+#	if defined(HL_WIN) || defined(HL_MAC) || defined(HL_CYGWIN) || defined(HL_PS)
 	h = gethostbyaddr((char *)&ip,4,AF_INET);
 #	else
 	struct hostent htmp;

+ 5 - 15
src/std/sys.c

@@ -48,7 +48,9 @@ typedef struct _stat32 pstat;
 #	include <unistd.h>
 #	include <limits.h>
 #	include <sys/time.h>
-#ifndef HL_PS
+#ifdef HL_PS
+extern const char *ps_exe_path();
+#else
 #	include <dirent.h>
 #	include <termios.h>
 #	include <sys/times.h>
@@ -297,12 +299,8 @@ HL_PRIM int hl_sys_command( vbyte *cmd ) {
 }
 
 HL_PRIM bool hl_sys_exists( vbyte *path ) {
-#if defined(HL_PS)
-	return false;
-#else
 	pstat st;
 	return stat((pchar*)path,&st) == 0;
-#endif
 }
 
 HL_PRIM bool hl_sys_delete( vbyte *path ) {
@@ -322,9 +320,6 @@ HL_PRIM bool hl_sys_rename( vbyte *path, vbyte *newname ) {
 }
 
 HL_PRIM varray *hl_sys_stat( vbyte *path ) {
-#if defined(HL_PS)
-	return NULL;
-#else
 	pstat s;
 	varray *a;
 	int *i;
@@ -344,18 +339,13 @@ HL_PRIM varray *hl_sys_stat( vbyte *path ) {
 	*i++ = s.st_rdev;
 	*i++ = s.st_mode;
 	return a;
-#endif
 }
 
 HL_PRIM bool hl_sys_is_dir( vbyte *path ) {
-#if defined(HL_PS)
-	return false;
-#else
 	pstat s;
 	if( stat((pchar*)path,&s) != 0 )
 		return false;
 	return (s.st_mode & S_IFDIR) != 0;
-#endif
 }
 
 HL_PRIM bool hl_sys_create_dir( vbyte *path, int mode ) {
@@ -530,7 +520,7 @@ HL_PRIM vbyte *hl_sys_full_path( vbyte *path ) {
 	}
 	return (vbyte*)pstrdup(out,len);
 #elif defined(HL_PS)
-	return NULL;
+	return path;
 #else
 	pchar buf[PATH_MAX];
 	if( realpath((pchar*)path,buf) == NULL )
@@ -552,7 +542,7 @@ HL_PRIM vbyte *hl_sys_exe_path() {
 		return NULL;
 	return (vbyte*)pstrdup(path,-1);
 #elif defined(HL_PS)
-	return NULL;
+	return ps_exe_path();
 #else
 	const pchar *p = getenv("_");
 	if( p != NULL )