Skip to content

Commit

Permalink
msvc fixes
Browse files Browse the repository at this point in the history
declare vasprintf before using

use JL_GC_PUSH1 instead of JL_GC_PUSH, latter requires C99 vararg macros

use __alignof instead of __alignof__ for msvc

remove define for _isnan, no longer seems to be necessary

disable ASM_COPY_STACKS for MSVC

Don't include valgrind.h for MSVC

use _write instead of write
  • Loading branch information
tkelman committed Mar 16, 2015
1 parent 6d68792 commit 9fc07bc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ DLLEXPORT void NORETURN jl_error(const char *str)
jl_throw(jl_new_struct(jl_errorexception_type, msg));
}

extern int vasprintf(char **str, const char *fmt, va_list ap);

static void NORETURN jl_vexceptionf(jl_datatype_t *exception_type, const char *fmt, va_list args)
{
if (exception_type == NULL) {
Expand Down
6 changes: 5 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ extern void _chkstk(void);
#endif
}

#if defined(_COMPILER_MICROSOFT_) && !defined(__alignof__)
#define __alignof__ __alignof
#endif

#define DISABLE_FLOAT16

// llvm state
Expand Down Expand Up @@ -791,7 +795,7 @@ static Function *jl_cfunction_object(jl_function_t *f, jl_value_t *rt, jl_value_

uint64_t isref = 0; // bit vector of which argument types are a subtype of Type{Ref{T}}
jl_value_t *sigt; // type signature with Ref{} annotations removed
JL_GC_PUSH(&sigt);
JL_GC_PUSH1(&sigt);
sigt = (jl_value_t*)jl_alloc_tuple(nargs);
for (i = 0; i < nargs; i++) {
jl_value_t *ati = jl_tupleref(argt, i);
Expand Down
8 changes: 6 additions & 2 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <string.h>
#include <assert.h>

#include "valgrind.h"

#include "julia.h"
#include "julia_internal.h"
#include "builtin_proto.h"
Expand All @@ -15,6 +13,12 @@
#include <dlfcn.h>
#endif

#ifndef _COMPILER_MICROSOFT_
#include "valgrind.h"
#else
#define RUNNING_ON_VALGRIND 0
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down
5 changes: 5 additions & 0 deletions src/jl_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#include "support/ios.h"
#include "uv.h"

#if defined(_COMPILER_MICROSOFT_) && !defined(write)
#include <io.h>
#define write _write
#endif

#ifdef __cplusplus
#include <cstring>
extern "C" {
Expand Down
4 changes: 0 additions & 4 deletions src/support/dtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@

#endif /* !_COMPILER_MINGW_ */

#if defined(_COMPILER_MICROSOFT_)
#define isnan _isnan
#endif /* _COMPILER_MICROSOFT_ */

#endif /* _OS_WINDOWS_ */


Expand Down
2 changes: 1 addition & 1 deletion src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jl_gcframe_t *jl_pgcstack = NULL;
#ifdef COPY_STACKS
static jl_jmp_buf * volatile jl_jmp_target;

#if defined(_CPU_X86_64_) || defined(_CPU_X86_)
#if (defined(_CPU_X86_64_) || defined(_CPU_X86_)) && !defined(_COMPILER_MICROSOFT_)

This comment has been minimized.

Copy link
@tkelman

tkelman Mar 16, 2015

Author Contributor

@vtjnash I think the longjmp workaround you were describing in #7761 (comment) is the same as the fallback you already implemented when ASM_COPY_STACKS is not defined?

This comment has been minimized.

Copy link
@vtjnash

vtjnash Mar 16, 2015

Member

close enough for now

#define ASM_COPY_STACKS
#endif
void *jl_stackbase;
Expand Down

0 comments on commit 9fc07bc

Please sign in to comment.