Skip to content

Commit

Permalink
Merge pull request #3949 from stevengj/flush_cstdio
Browse files Browse the repository at this point in the history
RFC: add flush_cstdio function
  • Loading branch information
stevengj committed Aug 7, 2013

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 27b2c38 + 3198f4b commit 528dd2c
Showing 6 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/exports.jl
Original file line number Diff line number Diff line change
@@ -1032,6 +1032,7 @@ export
fd,
fdio,
flush,
flush_cstdio,
getaddrinfo,
gethostname,
getipaddr,
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
7 changes: 7 additions & 0 deletions doc/helpdb.jl
Original file line number Diff line number Diff line change
@@ -1519,6 +1519,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.
5 changes: 5 additions & 0 deletions doc/stdlib/base.rst
Original file line number Diff line number Diff line change
@@ -987,6 +987,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.
6 changes: 6 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
@@ -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"));
1 change: 1 addition & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 528dd2c

Please sign in to comment.