Skip to content

Commit

Permalink
Use macro for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb committed Sep 1, 2021
1 parent 86d604c commit ff2fd93
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions runtime/caml/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ CAMLextern struct channel * caml_all_opened_channels;
if (caml_channel_mutex_unlock != NULL) (*caml_channel_mutex_unlock)(channel)
#define Unlock_exn() \
if (caml_channel_mutex_unlock_exn != NULL) (*caml_channel_mutex_unlock_exn)()
#define Flush_if_unbuffered(channel) \
if (channel->flags & CHANNEL_FLAG_UNBUFFERED) caml_flush(channel)

/* Conversion between file_offset and int64_t */

Expand Down
2 changes: 1 addition & 1 deletion runtime/extern.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ void caml_output_val(struct channel *chan, value v, value flags)
caml_stat_free(blk);
blk = nextblk;
}
if (chan->flags & CHANNEL_FLAG_UNBUFFERED) caml_flush(chan);
Flush_if_unbuffered(chan);
}

CAMLprim value caml_output_value(value vchan, value v, value flags)
Expand Down
6 changes: 3 additions & 3 deletions runtime/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ CAMLprim value caml_ml_output_char(value vchannel, value ch)

Lock(channel);
Putch(channel, Long_val(ch));
if (channel->flags & CHANNEL_FLAG_UNBUFFERED) caml_flush(channel);
Flush_if_unbuffered(channel);
Unlock(channel);
CAMLreturn (Val_unit);
}
Expand All @@ -700,7 +700,7 @@ CAMLprim value caml_ml_output_int(value vchannel, value w)

Lock(channel);
caml_putword(channel, (uint32_t) Long_val(w));
if (channel->flags & CHANNEL_FLAG_UNBUFFERED) caml_flush(channel);
Flush_if_unbuffered(channel);
Unlock(channel);
CAMLreturn (Val_unit);
}
Expand All @@ -721,7 +721,7 @@ CAMLprim value caml_ml_output_bytes(value vchannel, value buff, value start,
pos += written;
len -= written;
}
if (channel->flags & CHANNEL_FLAG_UNBUFFERED) caml_flush(channel);
Flush_if_unbuffered(channel);
Unlock(channel);
CAMLreturn (Val_unit);
}
Expand Down

0 comments on commit ff2fd93

Please sign in to comment.