Browse Source

x64 warnings fixes

Nicolas Cannasse 8 years ago
parent
commit
2e45f6ec17
5 changed files with 12 additions and 11 deletions
  1. 2 1
      hl.vcxproj
  2. 2 2
      libs/ssl/ssl.c
  3. 1 1
      src/alloc.c
  4. 1 1
      src/jit.c
  5. 6 6
      src/std/thread.c

+ 2 - 1
hl.vcxproj

@@ -30,6 +30,7 @@
     <ProjectGuid>{BBF750D2-6DD2-4A41-AC3A-07C070B94FA1}</ProjectGuid>
     <Keyword>Win32Proj</Keyword>
     <RootNamespace>hl</RootNamespace>
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
   </PropertyGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -63,7 +64,7 @@
     <UseDebugLibraries>false</UseDebugLibraries>
     <WholeProgramOptimization>true</WholeProgramOptimization>
     <CharacterSet>Unicode</CharacterSet>
-    <PlatformToolset>Windows7.1SDK</PlatformToolset>
+    <PlatformToolset>v140</PlatformToolset>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'" Label="Configuration">
     <ConfigurationType>Application</ConfigurationType>

+ 2 - 2
libs/ssl/ssl.c

@@ -469,7 +469,7 @@ HL_PRIM hl_ssl_cert *HL_NAME(cert_add_pem)(hl_ssl_cert *cert, vbyte *data) {
 		crt = (mbedtls_x509_crt*)malloc(sizeof(mbedtls_x509_crt));
 		mbedtls_x509_crt_init(crt);
 	}
-	len = strlen(data) + 1;
+	len = (int)strlen(data) + 1;
 	buf = (unsigned char *)malloc(len);
 	memcpy(buf, (char*)data, len - 1);
 	buf[len - 1] = '\0';
@@ -557,7 +557,7 @@ HL_PRIM hl_ssl_pkey *HL_NAME(key_from_pem)(vbyte *data, bool pub, vbyte *pass) {
 	unsigned char *buf;
 	mbedtls_pk_context *pk = (mbedtls_pk_context *)malloc(sizeof(mbedtls_pk_context));
 	mbedtls_pk_init(pk);
-	len = strlen((char*)data) + 1;
+	len = (int)strlen((char*)data) + 1;
 	buf = (unsigned char *)malloc(len);
 	memcpy(buf, (char*)data, len - 1);
 	buf[len - 1] = '\0';

+ 1 - 1
src/alloc.c

@@ -577,7 +577,7 @@ HL_PRIM void **hl_gc_mark_grow( void **stack ) {
 	int nsize = mark_stack_size ? (((mark_stack_size * 3) >> 1) & ~1) : 256;
 	void **nstack = (void**)malloc(sizeof(void**) * nsize);
 	void **base_stack = mark_stack_end - mark_stack_size;
-	int avail = stack - base_stack;
+	int avail = (int)(stack - base_stack);
 	memcpy(nstack, base_stack, avail * sizeof(void*));
 	free(base_stack);
 	mark_stack_size = nsize;

+ 1 - 1
src/jit.c

@@ -3260,7 +3260,7 @@ int hl_jit_function( jit_ctx *ctx, hl_module *m, hl_function *f ) {
 	}
 	// save debug infos
 	{
-		int fid = f - m->code->functions;
+		int fid = (int)(f - m->code->functions);
 		ctx->debug[fid].start = codePos;
 		ctx->debug[fid].offsets = debug32 ? (void*)debug32 : (void*)debug16;
 		ctx->debug[fid].large = debug32 != NULL;

+ 6 - 6
src/std/thread.c

@@ -27,7 +27,7 @@
 
 HL_PRIM hl_thread *hl_thread_current() {
 #	ifdef HL_WIN
-	return (hl_thread*)GetCurrentThreadId();
+	return (hl_thread*)(int_val)GetCurrentThreadId();
 #	else
 	return (hl_thread*)pthread_self();
 #	endif
@@ -41,7 +41,7 @@ HL_PRIM hl_thread *hl_thread_start( void *callback, void *param, bool withGC ) {
 	if( h == NULL )
 		return NULL;
 	CloseHandle(h);
-	return (hl_thread*)tid;
+	return (hl_thread*)(int_val)tid;
 #	else
 	pthread_t t;
 	pthread_attr_t attr;
@@ -59,7 +59,7 @@ HL_PRIM hl_thread *hl_thread_start( void *callback, void *param, bool withGC ) {
 HL_PRIM bool hl_thread_pause( hl_thread *t, bool pause ) {
 #	ifdef HL_WIN
 	bool ret;
-	HANDLE h = OpenThread(THREAD_ALL_ACCESS,FALSE,(DWORD)t);
+	HANDLE h = OpenThread(THREAD_ALL_ACCESS,FALSE,(DWORD)(int_val)t);
 	if( pause ) 
 		ret = ((int)SuspendThread(h)) >= 0;
 	else {
@@ -87,7 +87,7 @@ HL_PRIM int hl_thread_context_size() {
 HL_API int hl_thread_context_index( const char *name ) {
 #	ifdef HL_WIN
 	CONTEXT *c = NULL;
-#	define _ADDR(__r) (((int_val)&c->__r) / sizeof(int_val))
+#	define _ADDR(__r) (int)(((int_val)&c->__r) / sizeof(int_val))
 #	ifdef HL_64
 #		define ADDR(_,r) _ADDR(r)
 #	else
@@ -107,7 +107,7 @@ HL_API int hl_thread_context_index( const char *name ) {
 
 HL_API bool hl_thread_get_context( hl_thread *t, hl_thread_registers *regs ) {
 #	ifdef HL_WIN
-	HANDLE h = OpenThread(THREAD_ALL_ACCESS,FALSE,(DWORD)t);
+	HANDLE h = OpenThread(THREAD_ALL_ACCESS,FALSE,(DWORD)(int_val)t);
 	bool ret;
 	CONTEXT *c = (CONTEXT*)regs;
 	c->ContextFlags = CONTEXT_FULL;
@@ -121,7 +121,7 @@ HL_API bool hl_thread_get_context( hl_thread *t, hl_thread_registers *regs ) {
 
 HL_API bool hl_thread_set_context( hl_thread *t, hl_thread_registers *regs ) {
 #	ifdef HL_WIN
-	HANDLE h = OpenThread(THREAD_ALL_ACCESS,FALSE,(DWORD)t);
+	HANDLE h = OpenThread(THREAD_ALL_ACCESS,FALSE,(DWORD)(int_val)t);
 	bool ret;
 	CONTEXT *c = (CONTEXT*)regs;
 	c->ContextFlags = CONTEXT_FULL;