aboutsummaryrefslogtreecommitdiff
path: root/src/jit
diff options
context:
space:
mode:
authorMike Pall <mike>2021-12-17 14:30:44 +0100
committerMike Pall <mike>2021-12-17 14:30:44 +0100
commit1d20f33d2905db55fb7191076bbac10f570f9175 (patch)
treed2154e218fcb6c623f68c20ad3838a85a254fa20 /src/jit
parent8b7ea5c1af6502c4ed051bb9b5ff795b8cceffc0 (diff)
downloadluajit-1d20f33d2905db55fb7191076bbac10f570f9175.tar.gz
luajit-1d20f33d2905db55fb7191076bbac10f570f9175.tar.bz2
luajit-1d20f33d2905db55fb7191076bbac10f570f9175.zip
Windows: Fix binary output of jit.bcsave to stdout.
Thanks to erw7.
Diffstat (limited to 'src/jit')
-rw-r--r--src/jit/bcsave.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/jit/bcsave.lua b/src/jit/bcsave.lua
index ab13667a..bc959327 100644
--- a/src/jit/bcsave.lua
+++ b/src/jit/bcsave.lua
@@ -60,6 +60,11 @@ local function savefile(name, mode)
60 return check(io.open(name, mode)) 60 return check(io.open(name, mode))
61end 61end
62 62
63local function set_stdout_binary(ffi)
64 ffi.cdef[[int _setmode(int fd, int mode);]]
65 ffi.C._setmode(1, 0x8000)
66end
67
63------------------------------------------------------------------------------ 68------------------------------------------------------------------------------
64 69
65local map_type = { 70local map_type = {
@@ -125,6 +130,11 @@ local function bcsave_tail(fp, output, s)
125end 130end
126 131
127local function bcsave_raw(output, s) 132local function bcsave_raw(output, s)
133 if output == "-" and jit.os == "Windows" then
134 local ok, ffi = pcall(require, "ffi")
135 check(ok, "FFI library required to write binary file to stdout")
136 set_stdout_binary(ffi)
137 end
128 local fp = savefile(output, "wb") 138 local fp = savefile(output, "wb")
129 bcsave_tail(fp, output, s) 139 bcsave_tail(fp, output, s)
130end 140end
@@ -568,6 +578,9 @@ end
568local function bcsave_obj(ctx, output, s) 578local function bcsave_obj(ctx, output, s)
569 local ok, ffi = pcall(require, "ffi") 579 local ok, ffi = pcall(require, "ffi")
570 check(ok, "FFI library required to write this file type") 580 check(ok, "FFI library required to write this file type")
581 if output == "-" and jit.os == "Windows" then
582 set_stdout_binary(ffi)
583 end
571 if ctx.os == "windows" then 584 if ctx.os == "windows" then
572 return bcsave_peobj(ctx, output, s, ffi) 585 return bcsave_peobj(ctx, output, s, ffi)
573 elseif ctx.os == "osx" then 586 elseif ctx.os == "osx" then