Skip to content

Commit

Permalink
fix(runtime): add ability to ignore setmode failure
Browse files Browse the repository at this point in the history
  • Loading branch information
JaDogg committed Mar 29, 2024
1 parent c5dd614 commit 62f321f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions compiler/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Bunch of `C` code that standard library depend on.
| `cr.h` | Danny Angelo Carminati Grein | hot reloading capabilities | [cr.h](https://github.com/fungos/cr) | MIT |
| `endianness.h` | rofl0r | endian conversion | [endianness.h](https://github.com/rofl0r/endianness.h) | MIT/PublicDomain |


* Warn! net libraries need to be wrapped. They are not used yet.

### Patches

* argparse - `const char short_name;` was changed to `char short_name;`
Expand Down
6 changes: 6 additions & 0 deletions compiler/runtime/_include_mman_win.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Below code is originally from mman-win32
//
/*
* sys/mman.h
* mman-win32
*/
#include <errno.h>
#include <io.h>
#ifndef FILE_MAP_EXECUTE
Expand Down
6 changes: 6 additions & 0 deletions compiler/runtime/_include_mman_win.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Below code is originally from mman-win32
//
/*
* sys/mman.h
* mman-win32
*/
#include <time.h>
#include <sys/types.h>
#include <stdint.h>
Expand Down
5 changes: 5 additions & 0 deletions compiler/runtime/yk__main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ int main(int argc, char *argv[]) {
#if defined(_WIN32) || defined(_WIN64)
int result_mode;
result_mode = _setmode(_fileno(stdout), _O_U16TEXT);
#if !defined(YK_IGNORE_WINDOWS_CONSOLE_SET_MODE_ERROR)
// If we can't set the mode, return -1
// only a concern for a console application
// otherwise, we can ignore this error and let things continue as is
if (result_mode == -1) { return -1; }
#endif
#if defined(YK__WINDOWS_HIDE_CONSOLE)
ShowWindow(GetConsoleWindow(), SW_HIDE);
FreeConsole();
Expand Down
6 changes: 0 additions & 6 deletions compiler/runtime/yk__system.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
#ifndef ssize_t
#define ssize_t intmax_t
#endif
// Below code is originally from mman-win32
//
/*
* sys/mman.h
* mman-win32
*/
#ifndef _WIN32_WINNT// Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT \
0x0501// Change this to the appropriate value to target other versions of Windows.
Expand Down

0 comments on commit 62f321f

Please sign in to comment.