public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-04-13 20:42 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-04-13 20:42 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a56d05672dd4a6b08ed25b6ff2876bd4d5b60290
commit a56d05672dd4a6b08ed25b6ff2876bd4d5b60290
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/libdruntime/config/mingw/msvc.c | 34 +++++-----
libphobos/libdruntime/core/stdc/stdio.d | 108 +++++++++++++++++++++++++++---
2 files changed, 117 insertions(+), 25 deletions(-)
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..4ca77e58f5a 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -23,32 +23,32 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+#ifdef __MINGW32__
+#include <_mingw.h>
+#endif
#include <stdio.h>
-/* The symbols for stdin, stdout, and stderr are defined for D in the
- core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+/* The D runtime library defines stdin, stdout, and stderr as extern(C) symbols
+ in the core.stdc.stdio module, and require initializing at start-up. */
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
-/* Set to 1 if run-time is using ucrtbase.dll. */
+/* Set to 1 if runtime is using libucrt.dll. */
unsigned char msvcUsesUCRT;
void init_msvc()
{
-#if __MSVCRT_VERSION__ >= 0x1400
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
+
+#if __MSVCRT_VERSION__ >= 0xE00
msvcUsedUCRT = 1;
#endif
-
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
}
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index 532a0803f55..6cd7851f96c 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -391,7 +391,21 @@ else version (CRuntime_Microsoft)
///
struct _iobuf
{
+ version (MinGW)
+ {
+ char* _ptr;
+ int _cnt;
+ char* _base;
+ int _flag;
+ int _file;
+ int _charbuf;
+ int _bufsiz;
+ char* _tmpfname;
+ }
+ else
+ {
void* undefined;
+ }
}
///
@@ -1347,7 +1361,7 @@ version (CRuntime_DigitalMars)
///
pure int fileno()(FILE* stream) { return stream._file; }
}
- ///
+ ///
pragma(printf)
int _snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...);
///
@@ -1358,6 +1372,25 @@ version (CRuntime_DigitalMars)
int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
///
alias _vsnprintf vsnprintf;
+
+ //
+ // Digital Mars under-the-hood C I/O functions.
+ //
+
+ ///
+ int _fputc_nlock(int c, FILE* fp);
+ ///
+ int _fputwc_nlock(int c, FILE* fp);
+ ///
+ int _fgetc_nlock(FILE* fp);
+ ///
+ int _fgetwc_nlock(FILE* fp);
+ ///
+ int __fp_lock(FILE* fp);
+ ///
+ void __fp_unlock(FILE* fp);
+ ///
+ int setmode(int fd, int mode);
}
else version (CRuntime_Microsoft)
{
@@ -1373,7 +1406,10 @@ else version (CRuntime_Microsoft)
///
pure int ferror(FILE* stream);
///
- pure int fileno(FILE* stream);
+ pure int _fileno(FILE* stream);
+ ///
+ alias fileno = _fileno;
+
}
version (MinGW)
@@ -1410,16 +1446,72 @@ else version (CRuntime_Microsoft)
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
}
+ //
+ // Microsoft under-the-hood C I/O functions
+ // Uses _iobuf* for the unshared version of FILE*,
+ // usable when the FILE is locked.
+ //
+
+ version (MinGW)
+ {
+ private int _filbuf(FILE*);
+ private int _flsbuf(int, FILE*);
+
///
- int _fputc_nolock(int c, FILE *fp);
+ int _fputc_nolock(int c, FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = cast(char)c;
+ *fp._ptr = ch;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _flsbuf(c, fp);
+ }
///
- int _fgetc_nolock(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = *fp._ptr;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _filbuf(fp);
+ }
+ }
+ else
+ {
///
- int _lock_file(FILE *fp);
+ int _fputc_nolock(int c, FILE* fp);
///
- int _unlock_file(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp);
+ }
+ ///
+ int _fputwc_nolock(int c, FILE* fp);
+ ///
+ int _fgetwc_nolock(FILE* fp);
+ ///
+ void _lock_file(FILE* fp);
+ ///
+ void _unlock_file(FILE* fp);
+ ///
+ int _setmode(int fd, int mode);
+ ///
+ FILE* _fdopen(int fd, const (char)* mode);
+ ///
+ FILE* _wfdopen(int fd, const (wchar)* mode);
+ ///
+ int _fseeki64(FILE* stream, long offset, int origin);
+ ///
+ long _ftelli64(FILE* stream);
///
intptr_t _get_osfhandle(int fd);
///
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-04-17 20:43 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-04-17 20:43 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7dbd2ea913e99814116c50673120d2507ba9b3f8
commit 7dbd2ea913e99814116c50673120d2507ba9b3f8
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/libdruntime/config/mingw/msvc.c | 34 +++++-----
libphobos/libdruntime/core/stdc/stdio.d | 108 +++++++++++++++++++++++++++---
2 files changed, 117 insertions(+), 25 deletions(-)
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..4ca77e58f5a 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -23,32 +23,32 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+#ifdef __MINGW32__
+#include <_mingw.h>
+#endif
#include <stdio.h>
-/* The symbols for stdin, stdout, and stderr are defined for D in the
- core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+/* The D runtime library defines stdin, stdout, and stderr as extern(C) symbols
+ in the core.stdc.stdio module, and require initializing at start-up. */
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
-/* Set to 1 if run-time is using ucrtbase.dll. */
+/* Set to 1 if runtime is using libucrt.dll. */
unsigned char msvcUsesUCRT;
void init_msvc()
{
-#if __MSVCRT_VERSION__ >= 0x1400
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
+
+#if __MSVCRT_VERSION__ >= 0xE00
msvcUsedUCRT = 1;
#endif
-
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
}
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index 532a0803f55..6cd7851f96c 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -391,7 +391,21 @@ else version (CRuntime_Microsoft)
///
struct _iobuf
{
+ version (MinGW)
+ {
+ char* _ptr;
+ int _cnt;
+ char* _base;
+ int _flag;
+ int _file;
+ int _charbuf;
+ int _bufsiz;
+ char* _tmpfname;
+ }
+ else
+ {
void* undefined;
+ }
}
///
@@ -1347,7 +1361,7 @@ version (CRuntime_DigitalMars)
///
pure int fileno()(FILE* stream) { return stream._file; }
}
- ///
+ ///
pragma(printf)
int _snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...);
///
@@ -1358,6 +1372,25 @@ version (CRuntime_DigitalMars)
int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
///
alias _vsnprintf vsnprintf;
+
+ //
+ // Digital Mars under-the-hood C I/O functions.
+ //
+
+ ///
+ int _fputc_nlock(int c, FILE* fp);
+ ///
+ int _fputwc_nlock(int c, FILE* fp);
+ ///
+ int _fgetc_nlock(FILE* fp);
+ ///
+ int _fgetwc_nlock(FILE* fp);
+ ///
+ int __fp_lock(FILE* fp);
+ ///
+ void __fp_unlock(FILE* fp);
+ ///
+ int setmode(int fd, int mode);
}
else version (CRuntime_Microsoft)
{
@@ -1373,7 +1406,10 @@ else version (CRuntime_Microsoft)
///
pure int ferror(FILE* stream);
///
- pure int fileno(FILE* stream);
+ pure int _fileno(FILE* stream);
+ ///
+ alias fileno = _fileno;
+
}
version (MinGW)
@@ -1410,16 +1446,72 @@ else version (CRuntime_Microsoft)
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
}
+ //
+ // Microsoft under-the-hood C I/O functions
+ // Uses _iobuf* for the unshared version of FILE*,
+ // usable when the FILE is locked.
+ //
+
+ version (MinGW)
+ {
+ private int _filbuf(FILE*);
+ private int _flsbuf(int, FILE*);
+
///
- int _fputc_nolock(int c, FILE *fp);
+ int _fputc_nolock(int c, FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = cast(char)c;
+ *fp._ptr = ch;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _flsbuf(c, fp);
+ }
///
- int _fgetc_nolock(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = *fp._ptr;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _filbuf(fp);
+ }
+ }
+ else
+ {
///
- int _lock_file(FILE *fp);
+ int _fputc_nolock(int c, FILE* fp);
///
- int _unlock_file(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp);
+ }
+ ///
+ int _fputwc_nolock(int c, FILE* fp);
+ ///
+ int _fgetwc_nolock(FILE* fp);
+ ///
+ void _lock_file(FILE* fp);
+ ///
+ void _unlock_file(FILE* fp);
+ ///
+ int _setmode(int fd, int mode);
+ ///
+ FILE* _fdopen(int fd, const (char)* mode);
+ ///
+ FILE* _wfdopen(int fd, const (wchar)* mode);
+ ///
+ int _fseeki64(FILE* stream, long offset, int origin);
+ ///
+ long _ftelli64(FILE* stream);
///
intptr_t _get_osfhandle(int fd);
///
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-04-16 1:04 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-04-16 1:04 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9944c62109181e208981f41c3c93599a625fe4d5
commit 9944c62109181e208981f41c3c93599a625fe4d5
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/libdruntime/config/mingw/msvc.c | 34 +++++-----
libphobos/libdruntime/core/stdc/stdio.d | 108 +++++++++++++++++++++++++++---
2 files changed, 117 insertions(+), 25 deletions(-)
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..4ca77e58f5a 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -23,32 +23,32 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+#ifdef __MINGW32__
+#include <_mingw.h>
+#endif
#include <stdio.h>
-/* The symbols for stdin, stdout, and stderr are defined for D in the
- core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+/* The D runtime library defines stdin, stdout, and stderr as extern(C) symbols
+ in the core.stdc.stdio module, and require initializing at start-up. */
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
-/* Set to 1 if run-time is using ucrtbase.dll. */
+/* Set to 1 if runtime is using libucrt.dll. */
unsigned char msvcUsesUCRT;
void init_msvc()
{
-#if __MSVCRT_VERSION__ >= 0x1400
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
+
+#if __MSVCRT_VERSION__ >= 0xE00
msvcUsedUCRT = 1;
#endif
-
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
}
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index 532a0803f55..6cd7851f96c 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -391,7 +391,21 @@ else version (CRuntime_Microsoft)
///
struct _iobuf
{
+ version (MinGW)
+ {
+ char* _ptr;
+ int _cnt;
+ char* _base;
+ int _flag;
+ int _file;
+ int _charbuf;
+ int _bufsiz;
+ char* _tmpfname;
+ }
+ else
+ {
void* undefined;
+ }
}
///
@@ -1347,7 +1361,7 @@ version (CRuntime_DigitalMars)
///
pure int fileno()(FILE* stream) { return stream._file; }
}
- ///
+ ///
pragma(printf)
int _snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...);
///
@@ -1358,6 +1372,25 @@ version (CRuntime_DigitalMars)
int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
///
alias _vsnprintf vsnprintf;
+
+ //
+ // Digital Mars under-the-hood C I/O functions.
+ //
+
+ ///
+ int _fputc_nlock(int c, FILE* fp);
+ ///
+ int _fputwc_nlock(int c, FILE* fp);
+ ///
+ int _fgetc_nlock(FILE* fp);
+ ///
+ int _fgetwc_nlock(FILE* fp);
+ ///
+ int __fp_lock(FILE* fp);
+ ///
+ void __fp_unlock(FILE* fp);
+ ///
+ int setmode(int fd, int mode);
}
else version (CRuntime_Microsoft)
{
@@ -1373,7 +1406,10 @@ else version (CRuntime_Microsoft)
///
pure int ferror(FILE* stream);
///
- pure int fileno(FILE* stream);
+ pure int _fileno(FILE* stream);
+ ///
+ alias fileno = _fileno;
+
}
version (MinGW)
@@ -1410,16 +1446,72 @@ else version (CRuntime_Microsoft)
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
}
+ //
+ // Microsoft under-the-hood C I/O functions
+ // Uses _iobuf* for the unshared version of FILE*,
+ // usable when the FILE is locked.
+ //
+
+ version (MinGW)
+ {
+ private int _filbuf(FILE*);
+ private int _flsbuf(int, FILE*);
+
///
- int _fputc_nolock(int c, FILE *fp);
+ int _fputc_nolock(int c, FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = cast(char)c;
+ *fp._ptr = ch;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _flsbuf(c, fp);
+ }
///
- int _fgetc_nolock(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = *fp._ptr;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _filbuf(fp);
+ }
+ }
+ else
+ {
///
- int _lock_file(FILE *fp);
+ int _fputc_nolock(int c, FILE* fp);
///
- int _unlock_file(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp);
+ }
+ ///
+ int _fputwc_nolock(int c, FILE* fp);
+ ///
+ int _fgetwc_nolock(FILE* fp);
+ ///
+ void _lock_file(FILE* fp);
+ ///
+ void _unlock_file(FILE* fp);
+ ///
+ int _setmode(int fd, int mode);
+ ///
+ FILE* _fdopen(int fd, const (char)* mode);
+ ///
+ FILE* _wfdopen(int fd, const (wchar)* mode);
+ ///
+ int _fseeki64(FILE* stream, long offset, int origin);
+ ///
+ long _ftelli64(FILE* stream);
///
intptr_t _get_osfhandle(int fd);
///
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-04-11 18:58 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-04-11 18:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8654b336a6d32b6de6fa6bf7cd592d0ab59c044d
commit 8654b336a6d32b6de6fa6bf7cd592d0ab59c044d
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/libdruntime/config/mingw/msvc.c | 34 +++++-----
libphobos/libdruntime/core/stdc/stdio.d | 108 +++++++++++++++++++++++++++---
2 files changed, 117 insertions(+), 25 deletions(-)
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..4ca77e58f5a 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -23,32 +23,32 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+#ifdef __MINGW32__
+#include <_mingw.h>
+#endif
#include <stdio.h>
-/* The symbols for stdin, stdout, and stderr are defined for D in the
- core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+/* The D runtime library defines stdin, stdout, and stderr as extern(C) symbols
+ in the core.stdc.stdio module, and require initializing at start-up. */
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
-/* Set to 1 if run-time is using ucrtbase.dll. */
+/* Set to 1 if runtime is using libucrt.dll. */
unsigned char msvcUsesUCRT;
void init_msvc()
{
-#if __MSVCRT_VERSION__ >= 0x1400
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
+
+#if __MSVCRT_VERSION__ >= 0xE00
msvcUsedUCRT = 1;
#endif
-
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
}
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index 532a0803f55..6cd7851f96c 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -391,7 +391,21 @@ else version (CRuntime_Microsoft)
///
struct _iobuf
{
+ version (MinGW)
+ {
+ char* _ptr;
+ int _cnt;
+ char* _base;
+ int _flag;
+ int _file;
+ int _charbuf;
+ int _bufsiz;
+ char* _tmpfname;
+ }
+ else
+ {
void* undefined;
+ }
}
///
@@ -1347,7 +1361,7 @@ version (CRuntime_DigitalMars)
///
pure int fileno()(FILE* stream) { return stream._file; }
}
- ///
+ ///
pragma(printf)
int _snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...);
///
@@ -1358,6 +1372,25 @@ version (CRuntime_DigitalMars)
int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
///
alias _vsnprintf vsnprintf;
+
+ //
+ // Digital Mars under-the-hood C I/O functions.
+ //
+
+ ///
+ int _fputc_nlock(int c, FILE* fp);
+ ///
+ int _fputwc_nlock(int c, FILE* fp);
+ ///
+ int _fgetc_nlock(FILE* fp);
+ ///
+ int _fgetwc_nlock(FILE* fp);
+ ///
+ int __fp_lock(FILE* fp);
+ ///
+ void __fp_unlock(FILE* fp);
+ ///
+ int setmode(int fd, int mode);
}
else version (CRuntime_Microsoft)
{
@@ -1373,7 +1406,10 @@ else version (CRuntime_Microsoft)
///
pure int ferror(FILE* stream);
///
- pure int fileno(FILE* stream);
+ pure int _fileno(FILE* stream);
+ ///
+ alias fileno = _fileno;
+
}
version (MinGW)
@@ -1410,16 +1446,72 @@ else version (CRuntime_Microsoft)
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
}
+ //
+ // Microsoft under-the-hood C I/O functions
+ // Uses _iobuf* for the unshared version of FILE*,
+ // usable when the FILE is locked.
+ //
+
+ version (MinGW)
+ {
+ private int _filbuf(FILE*);
+ private int _flsbuf(int, FILE*);
+
///
- int _fputc_nolock(int c, FILE *fp);
+ int _fputc_nolock(int c, FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = cast(char)c;
+ *fp._ptr = ch;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _flsbuf(c, fp);
+ }
///
- int _fgetc_nolock(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = *fp._ptr;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _filbuf(fp);
+ }
+ }
+ else
+ {
///
- int _lock_file(FILE *fp);
+ int _fputc_nolock(int c, FILE* fp);
///
- int _unlock_file(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp);
+ }
+ ///
+ int _fputwc_nolock(int c, FILE* fp);
+ ///
+ int _fgetwc_nolock(FILE* fp);
+ ///
+ void _lock_file(FILE* fp);
+ ///
+ void _unlock_file(FILE* fp);
+ ///
+ int _setmode(int fd, int mode);
+ ///
+ FILE* _fdopen(int fd, const (char)* mode);
+ ///
+ FILE* _wfdopen(int fd, const (wchar)* mode);
+ ///
+ int _fseeki64(FILE* stream, long offset, int origin);
+ ///
+ long _ftelli64(FILE* stream);
///
intptr_t _get_osfhandle(int fd);
///
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-04-10 17:21 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-04-10 17:21 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0562c0558834e41f1f690d15b3710981681f3cbc
commit 0562c0558834e41f1f690d15b3710981681f3cbc
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/libdruntime/config/mingw/msvc.c | 34 +++++-----
libphobos/libdruntime/core/stdc/stdio.d | 108 +++++++++++++++++++++++++++---
2 files changed, 117 insertions(+), 25 deletions(-)
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..4ca77e58f5a 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -23,32 +23,32 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+#ifdef __MINGW32__
+#include <_mingw.h>
+#endif
#include <stdio.h>
-/* The symbols for stdin, stdout, and stderr are defined for D in the
- core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+/* The D runtime library defines stdin, stdout, and stderr as extern(C) symbols
+ in the core.stdc.stdio module, and require initializing at start-up. */
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
-/* Set to 1 if run-time is using ucrtbase.dll. */
+/* Set to 1 if runtime is using libucrt.dll. */
unsigned char msvcUsesUCRT;
void init_msvc()
{
-#if __MSVCRT_VERSION__ >= 0x1400
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
+
+#if __MSVCRT_VERSION__ >= 0xE00
msvcUsedUCRT = 1;
#endif
-
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
}
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index 532a0803f55..6cd7851f96c 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -391,7 +391,21 @@ else version (CRuntime_Microsoft)
///
struct _iobuf
{
+ version (MinGW)
+ {
+ char* _ptr;
+ int _cnt;
+ char* _base;
+ int _flag;
+ int _file;
+ int _charbuf;
+ int _bufsiz;
+ char* _tmpfname;
+ }
+ else
+ {
void* undefined;
+ }
}
///
@@ -1347,7 +1361,7 @@ version (CRuntime_DigitalMars)
///
pure int fileno()(FILE* stream) { return stream._file; }
}
- ///
+ ///
pragma(printf)
int _snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...);
///
@@ -1358,6 +1372,25 @@ version (CRuntime_DigitalMars)
int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
///
alias _vsnprintf vsnprintf;
+
+ //
+ // Digital Mars under-the-hood C I/O functions.
+ //
+
+ ///
+ int _fputc_nlock(int c, FILE* fp);
+ ///
+ int _fputwc_nlock(int c, FILE* fp);
+ ///
+ int _fgetc_nlock(FILE* fp);
+ ///
+ int _fgetwc_nlock(FILE* fp);
+ ///
+ int __fp_lock(FILE* fp);
+ ///
+ void __fp_unlock(FILE* fp);
+ ///
+ int setmode(int fd, int mode);
}
else version (CRuntime_Microsoft)
{
@@ -1373,7 +1406,10 @@ else version (CRuntime_Microsoft)
///
pure int ferror(FILE* stream);
///
- pure int fileno(FILE* stream);
+ pure int _fileno(FILE* stream);
+ ///
+ alias fileno = _fileno;
+
}
version (MinGW)
@@ -1410,16 +1446,72 @@ else version (CRuntime_Microsoft)
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
}
+ //
+ // Microsoft under-the-hood C I/O functions
+ // Uses _iobuf* for the unshared version of FILE*,
+ // usable when the FILE is locked.
+ //
+
+ version (MinGW)
+ {
+ private int _filbuf(FILE*);
+ private int _flsbuf(int, FILE*);
+
///
- int _fputc_nolock(int c, FILE *fp);
+ int _fputc_nolock(int c, FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = cast(char)c;
+ *fp._ptr = ch;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _flsbuf(c, fp);
+ }
///
- int _fgetc_nolock(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = *fp._ptr;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _filbuf(fp);
+ }
+ }
+ else
+ {
///
- int _lock_file(FILE *fp);
+ int _fputc_nolock(int c, FILE* fp);
///
- int _unlock_file(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp);
+ }
+ ///
+ int _fputwc_nolock(int c, FILE* fp);
+ ///
+ int _fgetwc_nolock(FILE* fp);
+ ///
+ void _lock_file(FILE* fp);
+ ///
+ void _unlock_file(FILE* fp);
+ ///
+ int _setmode(int fd, int mode);
+ ///
+ FILE* _fdopen(int fd, const (char)* mode);
+ ///
+ FILE* _wfdopen(int fd, const (wchar)* mode);
+ ///
+ int _fseeki64(FILE* stream, long offset, int origin);
+ ///
+ long _ftelli64(FILE* stream);
///
intptr_t _get_osfhandle(int fd);
///
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-04-10 17:19 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-04-10 17:19 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:98806df7833841ec0b748d3a3e98f98fbdd97a39
commit 98806df7833841ec0b748d3a3e98f98fbdd97a39
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/libdruntime/config/mingw/msvc.c | 34 +++++-----
libphobos/libdruntime/core/stdc/stdio.d | 108 +++++++++++++++++++++++++++---
2 files changed, 117 insertions(+), 25 deletions(-)
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..4ca77e58f5a 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -23,32 +23,32 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+#ifdef __MINGW32__
+#include <_mingw.h>
+#endif
#include <stdio.h>
-/* The symbols for stdin, stdout, and stderr are defined for D in the
- core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+/* The D runtime library defines stdin, stdout, and stderr as extern(C) symbols
+ in the core.stdc.stdio module, and require initializing at start-up. */
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
-/* Set to 1 if run-time is using ucrtbase.dll. */
+/* Set to 1 if runtime is using libucrt.dll. */
unsigned char msvcUsesUCRT;
void init_msvc()
{
-#if __MSVCRT_VERSION__ >= 0x1400
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
+
+#if __MSVCRT_VERSION__ >= 0xE00
msvcUsedUCRT = 1;
#endif
-
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
}
diff --git a/libphobos/libdruntime/core/stdc/stdio.d b/libphobos/libdruntime/core/stdc/stdio.d
index 532a0803f55..c4dce71f1e0 100644
--- a/libphobos/libdruntime/core/stdc/stdio.d
+++ b/libphobos/libdruntime/core/stdc/stdio.d
@@ -391,7 +391,21 @@ else version (CRuntime_Microsoft)
///
struct _iobuf
{
+ version (MinGW)
+ {
+ char* _ptr;
+ int _cnt;
+ char* _base;
+ int _flag;
+ int _file;
+ int _charbuf;
+ int _bufsiz;
+ char* _tmpfname;
+ }
+ else
+ {
void* undefined;
+ }
}
///
@@ -1347,7 +1361,7 @@ version (CRuntime_DigitalMars)
///
pure int fileno()(FILE* stream) { return stream._file; }
}
- ///
+ ///
pragma(printf)
int _snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...);
///
@@ -1358,6 +1372,25 @@ version (CRuntime_DigitalMars)
int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
///
alias _vsnprintf vsnprintf;
+
+ //
+ // Digital Mars under-the-hood C I/O functions.
+ //
+
+ ///
+ int _fputc_nlock(int c, FILE* fp);
+ ///
+ int _fputwc_nlock(int c, FILE* fp);
+ ///
+ int _fgetc_nlock(FILE* fp);
+ ///
+ int _fgetwc_nlock(FILE* fp);
+ ///
+ int __fp_lock(FILE* fp);
+ ///
+ void __fp_unlock(FILE* fp);
+ ///
+ int setmode(int fd, int mode);
}
else version (CRuntime_Microsoft)
{
@@ -1373,7 +1406,10 @@ else version (CRuntime_Microsoft)
///
pure int ferror(FILE* stream);
///
- pure int fileno(FILE* stream);
+ pure int _fileno(FILE* stream);
+ ///
+ alias fileno = _fileno;
+
}
version (MinGW)
@@ -1410,16 +1446,72 @@ else version (CRuntime_Microsoft)
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg);
}
+ //
+ // Microsoft under-the-hood C I/O functions
+ // Uses _iobuf* for the unshared version of FILE*,
+ // usable when the FILE is locked.
+ //
+
+ version (MinGW)
+ {
+ private int _filbuf(FILE*);
+ private int _flsbuf(int, FILE*);
+
///
- int _fputc_nolock(int c, FILE *fp);
+ int _fputc_nolock()(int c, FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = cast(char)c;
+ *fp._ptr = ch;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _flsbuf(c, fp);
+ }
///
- int _fgetc_nolock(FILE *fp);
-
+ int _fgetc_nolock()(FILE* fp)
+ {
+ pragma(inline, true);
+ fp._cnt = fp._cnt - 1;
+ if (fp._cnt >= 0)
+ {
+ immutable ch = *fp._ptr;
+ fp._ptr = fp._ptr + 1;
+ return ch & 0xFF;
+ }
+ else
+ return _filbuf(fp);
+ }
+ }
+ else
+ {
///
- int _lock_file(FILE *fp);
+ int _fputc_nolock(int c, FILE* fp);
///
- int _unlock_file(FILE *fp);
-
+ int _fgetc_nolock(FILE* fp);
+ }
+ ///
+ int _fputwc_nolock(int c, FILE* fp);
+ ///
+ int _fgetwc_nolock(FILE* fp);
+ ///
+ void _lock_file(FILE* fp);
+ ///
+ void _unlock_file(FILE* fp);
+ ///
+ int _setmode(int fd, int mode);
+ ///
+ FILE* _fdopen(int fd, const (char)* mode);
+ ///
+ FILE* _wfdopen(int fd, const (wchar)* mode);
+ ///
+ int _fseeki64(FILE* stream, long offset, int origin);
+ ///
+ long _ftelli64(FILE* stream);
///
intptr_t _get_osfhandle(int fd);
///
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-04-10 15:22 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-04-10 15:22 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b063aded0533fb19b406f5ca2bec334eb1faded3
commit b063aded0533fb19b406f5ca2bec334eb1faded3
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/configure | 74 +++++++++++++++++++++++++++++++
libphobos/configure.ac | 1 +
libphobos/libdruntime/config/mingw/msvc.c | 21 ++++-----
libphobos/m4/druntime/libraries.m4 | 14 ++++++
4 files changed, 98 insertions(+), 12 deletions(-)
diff --git a/libphobos/configure b/libphobos/configure
index fe7cd9c11ff..e483fcd8360 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -15067,6 +15067,80 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ case "$druntime_cv_target_os" in
+ mingw*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing _fputc_nolock" >&5
+$as_echo_n "checking for library containing _fputc_nolock... " >&6; }
+if ${ac_cv_search__fputc_nolock+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char _fputc_nolock ();
+int
+main ()
+{
+return _fputc_nolock ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' ucrtbase; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search__fputc_nolock=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search__fputc_nolock+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search__fputc_nolock+:} false; then :
+
+else
+ ac_cv_search__fputc_nolock=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__fputc_nolock" >&5
+$as_echo "$ac_cv_search__fputc_nolock" >&6; }
+ac_res=$ac_cv_search__fputc_nolock
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+ ;;
+ esac
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
druntime_check_both=no
ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
if test "x$ac_cv_func_connect" = xyes; then :
diff --git a/libphobos/configure.ac b/libphobos/configure.ac
index 3b5a830cccf..1b1ce5008f0 100644
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -160,6 +160,7 @@ WITH_LOCAL_DRUNTIME([
DRUNTIME_LIBRARIES_ATOMIC
DRUNTIME_LIBRARIES_BACKTRACE
DRUNTIME_LIBRARIES_DLOPEN
+DRUNTIME_LIBRARIES_IO
DRUNTIME_LIBRARIES_NET
DRUNTIME_LIBRARIES_UCONTEXT
DRUNTIME_LIBRARIES_ZLIB
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..85ce3741bca 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -27,17 +27,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* The symbols for stdin, stdout, and stderr are defined for D in the
core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
/* Set to 1 if run-time is using ucrtbase.dll. */
unsigned char msvcUsesUCRT;
@@ -48,7 +45,7 @@ void init_msvc()
msvcUsedUCRT = 1;
#endif
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
}
diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4
index 743d3e3e17c..194602c1bf1 100644
--- a/libphobos/m4/druntime/libraries.m4
+++ b/libphobos/m4/druntime/libraries.m4
@@ -233,3 +233,17 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT],
AC_MSG_ERROR([swapcontext required but not found]))
fi
])
+
+# DRUNTIME_LIBRARIES_IO
+# -----------------------
+# Autodetect and add IO library to LIBS if necessary.
+AC_DEFUN([DRUNTIME_LIBRARIES_IO],
+[
+ AC_LANG_PUSH([C])
+ case "$druntime_cv_target_os" in
+ mingw*)
+ AC_SEARCH_LIBS([_fputc_nolock], [ucrtbase])
+ ;;
+ esac
+ AC_LANG_POP([C])
+])
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-04-08 13:36 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-04-08 13:36 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7113923eb10f6124ea45e8a8687c1518f69e6ea2
commit 7113923eb10f6124ea45e8a8687c1518f69e6ea2
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/configure | 74 +++++++++++++++++++++++++++++++
libphobos/configure.ac | 1 +
libphobos/libdruntime/config/mingw/msvc.c | 21 ++++-----
libphobos/m4/druntime/libraries.m4 | 14 ++++++
4 files changed, 98 insertions(+), 12 deletions(-)
diff --git a/libphobos/configure b/libphobos/configure
index 59ca64aa1e0..037b030a03e 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -15024,6 +15024,80 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ case "$druntime_cv_target_os" in
+ mingw*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing _fputc_nolock" >&5
+$as_echo_n "checking for library containing _fputc_nolock... " >&6; }
+if ${ac_cv_search__fputc_nolock+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char _fputc_nolock ();
+int
+main ()
+{
+return _fputc_nolock ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' ucrtbase; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search__fputc_nolock=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search__fputc_nolock+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search__fputc_nolock+:} false; then :
+
+else
+ ac_cv_search__fputc_nolock=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__fputc_nolock" >&5
+$as_echo "$ac_cv_search__fputc_nolock" >&6; }
+ac_res=$ac_cv_search__fputc_nolock
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+ ;;
+ esac
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
druntime_check_both=no
ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
if test "x$ac_cv_func_connect" = xyes; then :
diff --git a/libphobos/configure.ac b/libphobos/configure.ac
index 248d0ebbc19..4511cf3d79f 100644
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -159,6 +159,7 @@ WITH_LOCAL_DRUNTIME([
DRUNTIME_LIBRARIES_ATOMIC
DRUNTIME_LIBRARIES_BACKTRACE
DRUNTIME_LIBRARIES_DLOPEN
+DRUNTIME_LIBRARIES_IO
DRUNTIME_LIBRARIES_NET
DRUNTIME_LIBRARIES_UCONTEXT
DRUNTIME_LIBRARIES_ZLIB
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..85ce3741bca 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -27,17 +27,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* The symbols for stdin, stdout, and stderr are defined for D in the
core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
/* Set to 1 if run-time is using ucrtbase.dll. */
unsigned char msvcUsesUCRT;
@@ -48,7 +45,7 @@ void init_msvc()
msvcUsedUCRT = 1;
#endif
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
}
diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4
index 743d3e3e17c..194602c1bf1 100644
--- a/libphobos/m4/druntime/libraries.m4
+++ b/libphobos/m4/druntime/libraries.m4
@@ -233,3 +233,17 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT],
AC_MSG_ERROR([swapcontext required but not found]))
fi
])
+
+# DRUNTIME_LIBRARIES_IO
+# -----------------------
+# Autodetect and add IO library to LIBS if necessary.
+AC_DEFUN([DRUNTIME_LIBRARIES_IO],
+[
+ AC_LANG_PUSH([C])
+ case "$druntime_cv_target_os" in
+ mingw*)
+ AC_SEARCH_LIBS([_fputc_nolock], [ucrtbase])
+ ;;
+ esac
+ AC_LANG_POP([C])
+])
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio
@ 2021-03-24 21:11 Iain Buclaw
0 siblings, 0 replies; 9+ messages in thread
From: Iain Buclaw @ 2021-03-24 21:11 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7432cad757def574c0e752de38870ad5df5056ab
commit 7432cad757def574c0e752de38870ad5df5056ab
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Wed Mar 24 22:11:10 2021 +0100
Fix hello world with std.stdio
Diff:
---
libphobos/configure | 74 +++++++++++++++++++++++++++++++
libphobos/configure.ac | 1 +
libphobos/libdruntime/config/mingw/msvc.c | 21 ++++-----
libphobos/m4/druntime/libraries.m4 | 14 ++++++
4 files changed, 98 insertions(+), 12 deletions(-)
diff --git a/libphobos/configure b/libphobos/configure
index 59ca64aa1e0..037b030a03e 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -15024,6 +15024,80 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ case "$druntime_cv_target_os" in
+ mingw*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing _fputc_nolock" >&5
+$as_echo_n "checking for library containing _fputc_nolock... " >&6; }
+if ${ac_cv_search__fputc_nolock+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char _fputc_nolock ();
+int
+main ()
+{
+return _fputc_nolock ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' ucrtbase; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search__fputc_nolock=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search__fputc_nolock+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search__fputc_nolock+:} false; then :
+
+else
+ ac_cv_search__fputc_nolock=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search__fputc_nolock" >&5
+$as_echo "$ac_cv_search__fputc_nolock" >&6; }
+ac_res=$ac_cv_search__fputc_nolock
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+ ;;
+ esac
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
druntime_check_both=no
ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
if test "x$ac_cv_func_connect" = xyes; then :
diff --git a/libphobos/configure.ac b/libphobos/configure.ac
index 248d0ebbc19..4511cf3d79f 100644
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -159,6 +159,7 @@ WITH_LOCAL_DRUNTIME([
DRUNTIME_LIBRARIES_ATOMIC
DRUNTIME_LIBRARIES_BACKTRACE
DRUNTIME_LIBRARIES_DLOPEN
+DRUNTIME_LIBRARIES_IO
DRUNTIME_LIBRARIES_NET
DRUNTIME_LIBRARIES_UCONTEXT
DRUNTIME_LIBRARIES_ZLIB
diff --git a/libphobos/libdruntime/config/mingw/msvc.c b/libphobos/libdruntime/config/mingw/msvc.c
index 25b15a06950..85ce3741bca 100644
--- a/libphobos/libdruntime/config/mingw/msvc.c
+++ b/libphobos/libdruntime/config/mingw/msvc.c
@@ -27,17 +27,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* The symbols for stdin, stdout, and stderr are defined for D in the
core.stdc.stdio module. Save the macros and redeclare them here. */
-#define c_stdin stdin
-#undef stdin
-extern FILE *stdin;
+__attribute__((weakref ("stdin")))
+static FILE *core_stdc_stdin;
-#define c_stdout stdout
-#undef stdout
-extern FILE *stdout;
+__attribute__((weakref ("stdout")))
+static FILE *core_stdc_stdout;
-#define c_stderr stderr
-#undef stderr
-extern FILE *stderr;
+__attribute__((weakref ("stderr")))
+static FILE *core_stdc_stderr;
/* Set to 1 if run-time is using ucrtbase.dll. */
unsigned char msvcUsesUCRT;
@@ -48,7 +45,7 @@ void init_msvc()
msvcUsedUCRT = 1;
#endif
- stdin = c_stdin;
- stdout = c_stdout;
- stderr = c_stderr;
+ core_stdc_stdin = stdin;
+ core_stdc_stdout = stdout;
+ core_stdc_stderr = stderr;
}
diff --git a/libphobos/m4/druntime/libraries.m4 b/libphobos/m4/druntime/libraries.m4
index 743d3e3e17c..194602c1bf1 100644
--- a/libphobos/m4/druntime/libraries.m4
+++ b/libphobos/m4/druntime/libraries.m4
@@ -233,3 +233,17 @@ AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT],
AC_MSG_ERROR([swapcontext required but not found]))
fi
])
+
+# DRUNTIME_LIBRARIES_IO
+# -----------------------
+# Autodetect and add IO library to LIBS if necessary.
+AC_DEFUN([DRUNTIME_LIBRARIES_IO],
+[
+ AC_LANG_PUSH([C])
+ case "$druntime_cv_target_os" in
+ mingw*)
+ AC_SEARCH_LIBS([_fputc_nolock], [ucrtbase])
+ ;;
+ esac
+ AC_LANG_POP([C])
+])
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-04-17 20:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 20:42 [gcc(refs/users/ibuclaw/heads/mingw)] Fix hello world with std.stdio Iain Buclaw
-- strict thread matches above, loose matches on Subject: below --
2021-04-17 20:43 Iain Buclaw
2021-04-16 1:04 Iain Buclaw
2021-04-11 18:58 Iain Buclaw
2021-04-10 17:21 Iain Buclaw
2021-04-10 17:19 Iain Buclaw
2021-04-10 15:22 Iain Buclaw
2021-04-08 13:36 Iain Buclaw
2021-03-24 21:11 Iain Buclaw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).