Browse Source

Fix some API and HL_XBO compatibility

Yuxiao Mao 1 year ago
parent
commit
ff210397af
5 changed files with 15 additions and 15 deletions
  1. 1 1
      src/gc.c
  2. 1 1
      src/std/file.c
  3. 1 1
      src/std/sys.c
  4. 10 10
      src/std/thread.c
  5. 2 2
      src/std/types.c

+ 1 - 1
src/gc.c

@@ -1470,7 +1470,7 @@ static void gc_count_live_page( gc_pheader *p, int private_data ) {
 		gc_iter_live_blocks(p, gc_count_live_block);
 }
 
-static int hl_gc_get_live_objects( hl_type *t, varray *arr ) {
+HL_API int hl_gc_get_live_objects( hl_type *t, varray *arr ) {
 	if( !hl_is_dynamic(t) ) return -1;
 	gc_global_lock(true);
 	gc_stop_world(true);

+ 1 - 1
src/std/file.c

@@ -33,7 +33,7 @@
 #	include <windows.h>
 #	include <io.h>
 #	include <fcntl.h>
-#elif HL_XBO
+#elif defined(HL_XBO)
 #	include<xdk.h>
 #endif
 #	define fopen(name,mode) _wfopen(name,mode)

+ 1 - 1
src/std/sys.c

@@ -724,6 +724,7 @@ DEFINE_PRIM(_F64, sys_thread_cpu_time, _NO_ARG);
 DEFINE_PRIM(_ARR, sys_read_dir, _BYTES);
 DEFINE_PRIM(_BYTES, sys_full_path, _BYTES);
 DEFINE_PRIM(_BYTES, sys_exe_path, _NO_ARG);
+DEFINE_PRIM(_F64, sys_process_memory, _NO_ARG);
 DEFINE_PRIM(_I32, sys_get_char, _BOOL);
 DEFINE_PRIM(_ARR, sys_args, _NO_ARG);
 DEFINE_PRIM(_I32, sys_getpid, _NO_ARG);
@@ -731,4 +732,3 @@ DEFINE_PRIM(_BOOL, sys_check_reload, _BYTES);
 DEFINE_PRIM(_VOID, sys_profile_event, _I32 _BYTES _I32);
 DEFINE_PRIM(_I32, sys_set_flags, _I32);
 DEFINE_PRIM(_BOOL, sys_has_debugger, _NO_ARG);
-DEFINE_PRIM(_F64, sys_process_memory, _NO_ARG);

+ 10 - 10
src/std/thread.c

@@ -1032,7 +1032,7 @@ HL_PRIM int hl_atomic_add32(int *a, int b) {
 #if defined(HL_GCC_ATOMICS)
   return __atomic_fetch_add(a, b, __ATOMIC_SEQ_CST);
 #elif defined(HL_VCC_ATOMICS)
-  return _InterlockedExchangeAdd((LONG volatile *)a, b);
+  return _InterlockedExchangeAdd((long volatile *)a, b);
 #endif
 }
 
@@ -1040,7 +1040,7 @@ HL_PRIM int hl_atomic_sub32(int *a, int b) {
 #if defined(HL_GCC_ATOMICS)
   return __atomic_fetch_sub(a, b, __ATOMIC_SEQ_CST);
 #elif defined(HL_VCC_ATOMICS)
-  return _InterlockedExchangeAdd((LONG volatile *)a, -b);
+  return _InterlockedExchangeAdd((long volatile *)a, -b);
 #endif
 }
 
@@ -1048,7 +1048,7 @@ HL_PRIM int hl_atomic_and32(int *a, int b) {
 #if defined(HL_GCC_ATOMICS)
   return __atomic_fetch_and(a, b, __ATOMIC_SEQ_CST);
 #elif defined(HL_VCC_ATOMICS)
-  return _InterlockedAnd((LONG volatile *)a, b);
+  return _InterlockedAnd((long volatile *)a, b);
 #endif
 }
 
@@ -1056,7 +1056,7 @@ HL_PRIM int hl_atomic_or32(int *a, int b) {
 #if defined(HL_GCC_ATOMICS)
   return __atomic_fetch_or(a, b, __ATOMIC_SEQ_CST);
 #elif defined(HL_VCC_ATOMICS)
-  return _InterlockedOr((LONG volatile *)a, b);
+  return _InterlockedOr((long volatile *)a, b);
 #endif
 }
 
@@ -1064,7 +1064,7 @@ HL_PRIM int hl_atomic_xor32(int *a, int b) {
 #if defined(HL_GCC_ATOMICS)
   return __atomic_fetch_xor(a, b, __ATOMIC_SEQ_CST);
 #elif defined(HL_VCC_ATOMICS)
-  return _InterlockedXor((LONG volatile *)a, b);
+  return _InterlockedXor((long volatile *)a, b);
 #endif
 }
 
@@ -1076,7 +1076,7 @@ HL_PRIM int hl_atomic_compare_exchange32(int *a, int expected,
                             __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
   return _expected;
 #elif defined(HL_VCC_ATOMICS)
-  return _InterlockedCompareExchange((LONG volatile *)a, replacement, expected);
+  return _InterlockedCompareExchange((long volatile *)a, replacement, expected);
 #endif
 }
 
@@ -1099,7 +1099,7 @@ HL_PRIM int hl_atomic_exchange32(int *a, int replacement) {
   __atomic_exchange(a, &replacement, &ret, __ATOMIC_SEQ_CST);
   return ret;
 #elif defined(HL_VCC_ATOMICS)
-  return _InterlockedExchange((LONG volatile *)a, replacement);
+  return _InterlockedExchange((long volatile *)a, replacement);
 #endif
 }
 
@@ -1119,7 +1119,7 @@ HL_PRIM int hl_atomic_load32(int *a) {
   __atomic_load(a, &ret, __ATOMIC_SEQ_CST);
   return ret;
 #elif defined(HL_VCC_ATOMICS)
-  return _InterlockedXor((LONG volatile *)a, 0);
+  return _InterlockedXor((long volatile *)a, 0);
 #endif
 }
 
@@ -1132,7 +1132,7 @@ HL_PRIM void *hl_atomic_load_ptr(void **a) {
 #ifdef HL_64
   return (void *)_InterlockedXor64((__int64 volatile *)a, 0);
 #else
-  return (void *)_InterlockedXor((LONG volatile *)a, 0);
+  return (void *)_InterlockedXor((long volatile *)a, 0);
 #endif
 #endif
 }
@@ -1142,7 +1142,7 @@ HL_PRIM int hl_atomic_store32(int *a, int value) {
   __atomic_store(a, &value, __ATOMIC_SEQ_CST);
   return value;
 #elif defined(HL_VCC_ATOMICS)
-  _InterlockedExchange((LONG volatile *)a, value);
+  _InterlockedExchange((long volatile *)a, value);
   return value;
 #endif
 }

+ 2 - 2
src/std/types.c

@@ -903,7 +903,7 @@ HL_PRIM vdynamic *hl_mem_compact( vdynamic *d, varray *exclude, int flags, int *
 		object_count++;
 	}
 	vbyte *data = NULL;
-#	ifdef HL_WIN
+#	if defined(HL_WIN) && !defined(HL_XBO)
 	if( flags & 1 )
 		data = (vbyte*)VirtualAlloc(NULL,ctx->buf_pos,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE);
 #	endif
@@ -928,7 +928,7 @@ HL_PRIM vdynamic *hl_mem_compact( vdynamic *d, varray *exclude, int flags, int *
 	free(ctx->offsets);
 	free(ctx->remap_target);
 	free(ctx->todos);
-#	ifdef HL_WIN
+#	if defined(HL_WIN) && !defined(HL_XBO)
 	if( flags & 1 ) {
 		DWORD old = 0;
 		VirtualProtect(data,ctx->buf_pos,PAGE_READONLY,&old);