Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: add flush_cstdio function #3949

Merged
merged 1 commit into from
Aug 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ export
fd,
fdio,
flush,
flush_cstdio,
getaddrinfo,
gethostname,
getipaddr,
Expand Down
4 changes: 4 additions & 0 deletions base/util.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# flush C stdio output from external libraries:

flush_cstdio() = ccall(:jl_flush_cstdio, Void, ())

# timing

# system date in seconds
Expand Down
7 changes: 7 additions & 0 deletions doc/helpdb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,13 @@

"),

("I/O","Base","flush_cstdio","flush_cstdio()

Flushes the C stdout and stderr streams (which may have been
written to by external C code).

"),

("I/O","Base","close","close(stream)

Close an I/O stream. Performs a \"flush\" first.
Expand Down
5 changes: 5 additions & 0 deletions doc/stdlib/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,11 @@ I/O

Commit all currently buffered writes to the given stream.

.. function:: flush_cstdio()

Flushes the C ``stdout`` and ``stderr`` streams (which may have been
written to by external C code).

.. function:: close(stream)

Close an I/O stream. Performs a ``flush`` first.
Expand Down
6 changes: 6 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,12 @@ DLLEXPORT int jl_strtof(char *str, float *out)

// showing --------------------------------------------------------------------

void jl_flush_cstdio()
{
fflush(stdout);
fflush(stderr);
}

jl_value_t *jl_stdout_obj()
{
jl_value_t *stdout_obj = jl_get_global(jl_base_module, jl_symbol("STDOUT"));
Expand Down
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ jl_lambda_info_t *jl_wrap_expr(jl_value_t *expr);
// some useful functions
DLLEXPORT void jl_show(jl_value_t *stream, jl_value_t *v);
void jl_show_tuple(jl_value_t *st, jl_tuple_t *t, char opn, char cls, int comma_one);
DLLEXPORT void jl_flush_cstdio();
DLLEXPORT jl_value_t *jl_stdout_obj();
DLLEXPORT jl_value_t *jl_stderr_obj();
DLLEXPORT int jl_egal(jl_value_t *a, jl_value_t *b);
Expand Down