Skip to content

Commit

Permalink
Revert "upgrade to libuv1.9.0-fork"
Browse files Browse the repository at this point in the history
This reverts commit d9cdda6.
The new libuv branch is causing JuliaLang#16556
  • Loading branch information
tkelman committed May 29, 2016
1 parent b88be59 commit 67d8881
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 48 deletions.
11 changes: 6 additions & 5 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -894,14 +894,15 @@ ifeq ($(OS), WINNT)
ifneq ($(USEMSVC), 1)
HAVE_SSP := 1
OSLIBS += -Wl,--export-all-symbols -Wl,--version-script=$(JULIAHOME)/src/julia.expmap \
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp -luserenv
JLDFLAGS := -Wl,--stack,8388608
$(NO_WHOLE_ARCHIVE) -lpsapi -lkernel32 -lws2_32 -liphlpapi -lwinmm -ldbghelp
ifeq ($(ARCH),i686)
JLDFLAGS += -Wl,--large-address-aware
JLDFLAGS := -Wl,--stack,8388608 -Wl,--large-address-aware
else #x64
JLDFLAGS := -Wl,--stack,16777216
endif
else #USEMSVC
OSLIBS += kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib shell32.lib winmm.lib userenv.lib
JLDFLAGS := -stack:8388608
OSLIBS += kernel32.lib ws2_32.lib psapi.lib advapi32.lib iphlpapi.lib shell32.lib winmm.lib
JLDFLAGS := -stack:16777216
endif
JCPPFLAGS += -D_WIN32_WINNT=0x0502
UNTRUSTED_SYSTEM_LIBM := 1
Expand Down
29 changes: 15 additions & 14 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export

function pwd()
b = Array{UInt8}(1024)
len = Ref{Csize_t}(length(b))
len = Csize_t[length(b),]
uv_error(:getcwd, ccall(:uv_cwd, Cint, (Ptr{UInt8}, Ptr{Csize_t}), b, len))
String(b[1:len[]])
String(b[1:len[1]-1])
end

function cd(dir::AbstractString)
Expand Down Expand Up @@ -289,25 +289,26 @@ function mktempdir(fn::Function, parent=tempdir())
end
end

immutable uv_dirent_t
name::Ptr{UInt8}
typ::Cint
end
function readdir(path::AbstractString)
# Allocate space for uv_fs_t struct
uv_readdir_req = zeros(UInt8, ccall(:jl_sizeof_uv_fs_t, Int32, ()))

# defined in sys.c, to call uv_fs_readdir, which sets errno on error.
err = ccall(:uv_fs_scandir, Int32, (Ptr{Void}, Ptr{UInt8}, Cstring, Cint, Ptr{Void}),
eventloop(), uv_readdir_req, path, 0, C_NULL)
err < 0 && throw(SystemError("unable to read directory $path", -err))
#uv_error("unable to read directory $path", err)
file_count = ccall(:jl_readdir, Int32, (Cstring, Ptr{UInt8}),
path, uv_readdir_req)
systemerror("unable to read directory $path", file_count < 0)

# iterate the listing into entries
# The list of dir entries is returned as a contiguous sequence of null-terminated
# strings, the first of which is pointed to by ptr in uv_readdir_req.
# The following lines extracts those strings into dirent
entries = String[]
ent = Ref{uv_dirent_t}()
while Base.UV_EOF != ccall(:uv_fs_scandir_next, Cint, (Ptr{Void}, Ptr{uv_dirent_t}), uv_readdir_req, ent)
push!(entries, String(ent[].name))
offset = 0

for i = 1:file_count
entry = String(ccall(:jl_uv_fs_t_ptr_offset, Cstring,
(Ptr{UInt8}, Int32), uv_readdir_req, offset))
push!(entries, entry)
offset += sizeof(entry) + 1 # offset to the next entry
end

# Clean up the request string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b05f089b4ac277deaac0d8372b7d4ea6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5bf5a4a026c57a26c8a4cbce2d69b4b12a0d325bd46a83c48ca8a24af1fc8548967f2060258e6cd751c8b86b653c42d41c42512fc6ce2114a06738332fdd243b

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions deps/libuv.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LIBUV_BRANCH=julia-uv1.9.0
LIBUV_SHA1=a1d9166a440e4a0664c0e6de6ebe25350de56a42
LIBUV_BRANCH=julia-uv0.11.26
LIBUV_SHA1=07730c4bd595b4d45a498a8ee0bcd53878ff7c10
2 changes: 1 addition & 1 deletion src/flisp/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static value_t fl_path_cwd(fl_context_t *fl_ctx, value_t *args, uint32_t nargs)
err = uv_cwd(buf, &len);
if (err != 0)
lerrorf(fl_ctx, fl_ctx->IOError, "path.cwd: could not get cwd: %s", uv_strerror(err));
return string_from_cstrn(fl_ctx, buf, len);
return string_from_cstr(fl_ctx, buf);
}
char *ptr = tostring(fl_ctx, args[0], "path.cwd");
err = uv_chdir(ptr);
Expand Down
4 changes: 2 additions & 2 deletions src/flisp/flisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void fl_raise(fl_context_t *fl_ctx, value_t e)
static value_t make_error_msg(fl_context_t *fl_ctx, char *format, va_list args)
{
char msgbuf[512];
size_t len = vsnprintf(msgbuf, sizeof(msgbuf), format, args);
return string_from_cstrn(fl_ctx, msgbuf, len);
vsnprintf(msgbuf, sizeof(msgbuf), format, args);
return string_from_cstr(fl_ctx, msgbuf);
}

void lerrorf(fl_context_t *fl_ctx, value_t e, char *format, ...)
Expand Down
12 changes: 5 additions & 7 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ static void *init_stdio_handle(uv_file fd,int readable)
jl_errorf("error initializing stdio in uv_tty_init (%d, %d)", fd, type);
}
((uv_tty_t*)handle)->data=0;
uv_tty_set_mode((uv_tty_t*)handle, UV_TTY_MODE_NORMAL); //cooked stdio
uv_tty_set_mode((uv_tty_t*)handle,0); //cooked stdio
break;
case UV_UNKNOWN_HANDLE:
// dup the descriptor with a new one pointing at the bit bucket ...
Expand Down Expand Up @@ -446,11 +446,11 @@ static char *abspath(const char *in)
if (uv_cwd(path, &path_size)) {
jl_error("fatal error: unexpected error while retrieving current working directory");
}
if (path_size + len + 2 >= PATH_MAX) {
if (path_size + len + 1 >= PATH_MAX) {
jl_error("fatal error: current working directory path too long");
}
path[path_size] = PATHSEPSTRING[0];
memcpy(path + path_size + 1, in, len+1);
path[path_size-1] = PATHSEPSTRING[0];
memcpy(path+path_size, in, len+1);
out = strdup(path);
free(path);
}
Expand Down Expand Up @@ -485,9 +485,7 @@ static void jl_resolve_sysimg_location(JL_IMAGE_SEARCH rel)
if (path_size >= PATH_MAX) {
jl_error("fatal error: jl_options.julia_bin path too long");
}
jl_options.julia_bin = (char*)malloc(path_size+1);
memcpy((char*)jl_options.julia_bin, free_path, path_size);
((char*)jl_options.julia_bin)[path_size] = '\0';
jl_options.julia_bin = strdup(free_path);
if (!jl_options.julia_home) {
jl_options.julia_home = getenv("JULIA_HOME");
if (!jl_options.julia_home) {
Expand Down
20 changes: 6 additions & 14 deletions src/jl_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ JL_DLLEXPORT void jl_close_uv(uv_handle_t *handle)
}

if (handle->type == UV_NAMED_PIPE || handle->type == UV_TCP) {
#ifdef _OS_WINDOWS_
if (((uv_stream_t*)handle)->stream.conn.shutdown_req) {
#else
if (((uv_stream_t*)handle)->shutdown_req) {
#endif
// don't close the stream while attempting a graceful shutdown
return;
}
Expand All @@ -229,8 +225,8 @@ JL_DLLEXPORT void jl_close_uv(uv_handle_t *handle)
if (!uv_is_closing((uv_handle_t*)handle)) {
// avoid double-closing the stream
if (handle->type == UV_TTY)
uv_tty_set_mode((uv_tty_t*)handle, UV_TTY_MODE_NORMAL);
uv_close(handle, &jl_uv_closeHandle);
uv_tty_set_mode((uv_tty_t*)handle,0);
uv_close(handle,&jl_uv_closeHandle);
}
}

Expand Down Expand Up @@ -848,10 +844,9 @@ JL_DLLEXPORT int jl_ispty(uv_pipe_t *pipe)
{
if (pipe->type != UV_NAMED_PIPE) return 0;
size_t len = 0;
if (uv_pipe_getpeername(pipe, NULL, &len) != UV_ENOBUFS) return 0;
char *name = (char*)alloca(len + 1);
if (uv_pipe_getpeername(pipe, name, &len)) return 0;
name[len] = '\0';
if (uv_pipe_getsockname(pipe, NULL, &len) != UV_ENOBUFS) return 0;
char *name = (char *) alloca(len);
if (uv_pipe_getsockname(pipe, name, &len)) return 0;
// return true if name matches regex:
// ^\\\\?\\pipe\\(msys|cygwin)-[0-9a-z]{16}-[pt]ty[1-9][0-9]*-
//jl_printf(JL_STDERR,"pipe_name: %s\n", name);
Expand Down Expand Up @@ -888,10 +883,7 @@ JL_DLLEXPORT uv_handle_type jl_uv_handle_type(uv_handle_t *handle)
JL_DLLEXPORT int jl_tty_set_mode(uv_tty_t *handle, int mode)
{
if (handle->type != UV_TTY) return 0;
uv_tty_mode_t mode_enum = UV_TTY_MODE_NORMAL;
if (mode)
mode_enum = UV_TTY_MODE_RAW;
return uv_tty_set_mode(handle, mode_enum);
return uv_tty_set_mode(handle, mode);
}

typedef int (*work_cb_t)(void *, void *);
Expand Down
13 changes: 12 additions & 1 deletion src/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,19 @@ JL_DLLEXPORT int32_t jl_nb_available(ios_t *s)
// --- dir/file stuff ---

JL_DLLEXPORT int jl_sizeof_uv_fs_t(void) { return sizeof(uv_fs_t); }
JL_DLLEXPORT void jl_uv_fs_req_cleanup(uv_fs_t *req) { uv_fs_req_cleanup(req); }
JL_DLLEXPORT void jl_uv_fs_req_cleanup(uv_fs_t *req)
{
uv_fs_req_cleanup(req);
}

JL_DLLEXPORT int jl_readdir(const char *path, uv_fs_t *readdir_req)
{
// Note that the flags field is mostly ignored by libuv
return uv_fs_readdir(uv_default_loop(), readdir_req, path, 0 /*flags*/, NULL);
}

JL_DLLEXPORT char *jl_uv_fs_t_ptr(uv_fs_t *req) { return (char*)req->ptr; }
JL_DLLEXPORT char *jl_uv_fs_t_ptr_offset(uv_fs_t *req, int offset) { return (char*)req->ptr + offset; }
JL_DLLEXPORT int jl_uv_fs_result(uv_fs_t *f) { return f->result; }

// --- stat ---
Expand Down

0 comments on commit 67d8881

Please sign in to comment.