This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1341 from rainers/vs2015
first support for VS2015
- Loading branch information
Showing
7 changed files
with
172 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters