-
-
Notifications
You must be signed in to change notification settings - Fork 411
first support for VS2015 #1341
first support for VS2015 #1341
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -259,14 +259,7 @@ else version( CRuntime_Microsoft ) | |
| /// | ||
| struct _iobuf | ||
| { | ||
| char* _ptr; | ||
| int _cnt; | ||
| char* _base; | ||
| int _flag; | ||
| int _file; | ||
| int _charbuf; | ||
| int _bufsiz; | ||
| char* _tmpfname; | ||
| void* undefined; | ||
| } | ||
|
|
||
| /// | ||
|
|
@@ -572,10 +565,6 @@ else version( CRuntime_Microsoft ) | |
|
|
||
| extern shared void function() _fcloseallp; | ||
|
|
||
| private extern shared FILE[_NFILE] _iob; | ||
|
|
||
| shared(FILE)* __iob_func(); | ||
|
|
||
| /// | ||
| shared FILE* stdin; // = &__iob_func()[0]; | ||
| /// | ||
|
|
@@ -939,18 +928,18 @@ else version( CRuntime_DigitalMars ) | |
| else version( CRuntime_Microsoft ) | ||
| { | ||
| // No unsafe pointer manipulation. | ||
| extern (D) @trusted | ||
| @trusted | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depending on the VC version detected by the compiler we should import the correct msvcxx here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My suggestion is a link time resolution, with the rest of druntime/phobos agnostic to the VS version. So no versions and no imports here. |
||
| { | ||
| /// | ||
| void rewind(FILE* stream) { fseek(stream,0L,SEEK_SET); stream._flag = stream._flag & ~_IOERR; } | ||
| void rewind(FILE* stream); | ||
| /// | ||
| pure void clearerr(FILE* stream) { stream._flag = stream._flag & ~(_IOERR|_IOEOF); } | ||
| pure void clearerr(FILE* stream); | ||
| /// | ||
| pure int feof(FILE* stream) { return stream._flag&_IOEOF; } | ||
| pure int feof(FILE* stream); | ||
| /// | ||
| pure int ferror(FILE* stream) { return stream._flag&_IOERR; } | ||
| pure int ferror(FILE* stream); | ||
| /// | ||
| pure int fileno(FILE* stream) { return stream._file; } | ||
| pure int fileno(FILE* stream); | ||
| } | ||
| /// | ||
| int _snprintf(char* s, size_t n, in char* fmt, ...); | ||
|
|
@@ -963,42 +952,10 @@ else version( CRuntime_Microsoft ) | |
| alias _vsnprintf vsnprintf; | ||
|
|
||
| /// | ||
| uint _set_output_format(uint format); | ||
| /// | ||
| enum _TWO_DIGIT_EXPONENT = 1; | ||
| int _fputc_nolock(int c, FILE *fp); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance to get inline definitions for those?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the implementation uses C++ and a lot of internals, so it doesn't seem easily translatable. |
||
|
|
||
| /// | ||
| int _filbuf(FILE *fp); | ||
| /// | ||
| int _flsbuf(int c, FILE *fp); | ||
|
|
||
| /// | ||
| int _fputc_nolock(int c, FILE *fp) | ||
| { | ||
| fp._cnt = fp._cnt - 1; | ||
| if (fp._cnt >= 0) | ||
| { | ||
| *fp._ptr = cast(char)c; | ||
| fp._ptr = fp._ptr + 1; | ||
| return cast(char)c; | ||
| } | ||
| else | ||
| return _flsbuf(c, fp); | ||
| } | ||
|
|
||
| /// | ||
| int _fgetc_nolock(FILE *fp) | ||
| { | ||
| fp._cnt = fp._cnt - 1; | ||
| if (fp._cnt >= 0) | ||
| { | ||
| char c = *fp._ptr; | ||
| fp._ptr = fp._ptr + 1; | ||
| return c; | ||
| } | ||
| else | ||
| return _filbuf(fp); | ||
| } | ||
| int _fgetc_nolock(FILE *fp); | ||
|
|
||
| /// | ||
| int _lock_file(FILE *fp); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /** | ||
| * This module provides MS VC runtime helper function to be used | ||
| * with VS versions before VS 2015 | ||
| * | ||
| * Copyright: Copyright Digital Mars 2015. | ||
| * License: Distributed under the | ||
| * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). | ||
| * (See accompanying file LICENSE) | ||
| * Source: $(DRUNTIMESRC core/sys/windows/_stdio_msvc12.d) | ||
| * Authors: Rainer Schuetze | ||
| */ | ||
|
|
||
| module core.sys.windows.stdio_msvc12; | ||
|
|
||
| version( CRuntime_Microsoft ): | ||
|
|
||
| import core.stdc.stdio; | ||
|
|
||
| extern (C): | ||
| @system: | ||
| nothrow: | ||
| @nogc: | ||
|
|
||
| alias stdio_FILE = core.stdc.stdio.FILE; | ||
|
|
||
| FILE* __iob_func(); | ||
|
|
||
| uint _set_output_format(uint format); | ||
|
|
||
| enum _TWO_DIGIT_EXPONENT = 1; | ||
|
|
||
| void init_msvc() | ||
| { | ||
| // stdin,stdout and stderr internally in a static array __iob[3] | ||
| auto fp = __iob_func(); | ||
| stdin = cast(stdio_FILE*) &fp[0]; | ||
| stdout = cast(stdio_FILE*) &fp[1]; | ||
| stderr = cast(stdio_FILE*) &fp[2]; | ||
|
|
||
| // ensure that sprintf generates only 2 digit exponent when writing floating point values | ||
| _set_output_format(_TWO_DIGIT_EXPONENT); | ||
| } | ||
|
|
||
| struct _iobuf | ||
| { | ||
| char* _ptr; | ||
| int _cnt; // _cnt and _base exchanged for VS2015 | ||
| char* _base; | ||
| int _flag; | ||
| int _file; | ||
| int _charbuf; | ||
| int _bufsiz; | ||
| char* _tmpfname; | ||
| } | ||
|
|
||
| alias shared(_iobuf) FILE; | ||
|
|
||
| int _filbuf(FILE *fp); | ||
| int _flsbuf(int c, FILE *fp); | ||
|
|
||
| int _fputc_nolock(int c, FILE *fp) | ||
| { | ||
| fp._cnt = fp._cnt - 1; | ||
| if (fp._cnt >= 0) | ||
| { | ||
| *fp._ptr = cast(char)c; | ||
| fp._ptr = fp._ptr + 1; | ||
| return cast(char)c; | ||
| } | ||
| else | ||
| return _flsbuf(c, fp); | ||
| } | ||
|
|
||
| int _fgetc_nolock(FILE *fp) | ||
| { | ||
| fp._cnt = fp._cnt - 1; | ||
| if (fp._cnt >= 0) | ||
| { | ||
| char c = *fp._ptr; | ||
| fp._ptr = fp._ptr + 1; | ||
| return c; | ||
| } | ||
| else | ||
| return _filbuf(fp); | ||
| } | ||
|
|
||
| @trusted | ||
| { | ||
| /// | ||
| void rewind(FILE* stream) | ||
| { | ||
| fseek(cast(stdio_FILE*)stream,0L,SEEK_SET); | ||
| stream._flag = stream._flag & ~_IOERR; | ||
| } | ||
| /// | ||
| pure void clearerr(FILE* stream) { stream._flag = stream._flag & ~(_IOERR|_IOEOF); } | ||
| /// | ||
| pure int feof(FILE* stream) { return stream._flag&_IOEOF; } | ||
| /// | ||
| pure int ferror(FILE* stream) { return stream._flag&_IOERR; } | ||
| /// | ||
| pure int fileno(FILE* stream) { return stream._file; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /** | ||
| * This module provides MS VC runtime helper function to be used | ||
| * with VS versions VS 2015 or later | ||
| * | ||
| * Copyright: Copyright Digital Mars 2015. | ||
| * License: Distributed under the | ||
| * $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). | ||
| * (See accompanying file LICENSE) | ||
| * Source: $(DRUNTIMESRC core/sys/windows/_stdio_msvc14.d) | ||
| * Authors: Rainer Schuetze | ||
| */ | ||
|
|
||
| module core.sys.windows.stdio_msvc14; | ||
|
|
||
| version (CRuntime_Microsoft): | ||
|
|
||
| import core.stdc.stdio; | ||
|
|
||
| extern (C): | ||
| @system: | ||
| nothrow: | ||
| @nogc: | ||
|
|
||
| shared(FILE)* __acrt_iob_func(uint); // VS2015+ | ||
|
|
||
| void init_msvc() | ||
| { | ||
| stdin = __acrt_iob_func(0); | ||
| stdout = __acrt_iob_func(1); | ||
| stderr = __acrt_iob_func(2); | ||
| } | ||
|
|
||
| pragma(lib, "legacy_stdio_definitions.lib"); | ||
|
|
||
| shared static this() | ||
| { | ||
| // force linkage of ModuleInfo that includes the pragma(lib) above in its object file | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msvc14 missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATM you cannot link both stdio_msvc12 and stdio_msvc14 (this is the SRCS file). They both have to be added to MANIFEST, though.