Skip to content

Commit

Permalink
Merge pull request #345 from rudis/master
Browse files Browse the repository at this point in the history
syncpipe: implement .native_descriptor introspection
  • Loading branch information
jnthn committed Mar 11, 2016
2 parents 8ee9b92 + c20b5a3 commit ef19050
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/io/syncpipe.c
Expand Up @@ -67,6 +67,15 @@ static void gc_free(MVMThreadContext *tc, MVMObject *h, void *d) {
do_close(tc, data);
}

/* Get native file descriptor. */
static MVMint64 mvm_fileno(MVMThreadContext *tc, MVMOSHandle *h) {
MVMIOSyncPipeData *data = (MVMIOSyncPipeData *)h->body.data;
uv_os_fd_t fd;
if (uv_fileno((uv_handle_t *)data->ss.handle, &fd) >= 0)
return (MVMint64)fd;
return -1;
}

/* IO ops table, populated with functions. */
static const MVMIOClosable closable = { closefh };
static const MVMIOEncodable encodable = { MVM_io_syncstream_set_encoding };
Expand All @@ -83,6 +92,7 @@ static const MVMIOSyncWritable sync_writable = { MVM_io_syncstream_write_str,
static const MVMIOSeekable seekable = { MVM_io_syncstream_seek,
MVM_io_syncstream_tell };
static const MVMIOPipeable pipeable = { bind_stdio_handle };
static const MVMIOIntrospection introspection = { NULL, mvm_fileno };
static const MVMIOOps op_table = {
&closable,
&encodable,
Expand All @@ -95,7 +105,7 @@ static const MVMIOOps op_table = {
NULL,
&pipeable,
NULL,
NULL,
&introspection,
NULL,
gc_free
};
Expand Down
1 change: 1 addition & 0 deletions src/io/syncstream.c
Expand Up @@ -262,6 +262,7 @@ static MVMint64 is_tty(MVMThreadContext *tc, MVMOSHandle *h) {
return data->is_tty;
}

/* Get native file descriptor. */
static MVMint64 mvm_fileno(MVMThreadContext *tc, MVMOSHandle *h) {
MVMIOSyncStreamData *data = (MVMIOSyncStreamData *)h->body.data;
uv_os_fd_t fd;
Expand Down

0 comments on commit ef19050

Please sign in to comment.