if (is_internal_unit (dtp))
{
readlen = *length;
- if (sread (dtp->u.p.current_unit->s, p, &readlen) != 0 || readlen < (size_t) *length)
+ if (unlikely (sread (dtp->u.p.current_unit->s, p, &readlen) != 0
+ || readlen < (size_t) *length))
{
generate_error (&dtp->common, LIBERROR_END, NULL);
return NULL;
do
{
- if (sread (dtp->u.p.current_unit->s, &q, &readlen) != 0)
+ if (unlikely (sread (dtp->u.p.current_unit->s, &q, &readlen) != 0))
{
generate_error (&dtp->common, LIBERROR_END, NULL);
return NULL;
EOR below. */
if (readlen < 1 && n == 0)
{
- if (no_error)
+ if (likely (no_error))
break;
generate_error (&dtp->common, LIBERROR_END, NULL);
return NULL;
{
readlen = 1;
pos = stream_offset (dtp->u.p.current_unit->s);
- if (sread (dtp->u.p.current_unit->s, &q, &readlen) != 0)
+ if (unlikely (sread (dtp->u.p.current_unit->s, &q, &readlen)
+ != 0))
{
generate_error (&dtp->common, LIBERROR_END, NULL);
return NULL;
so we can just continue with a short read. */
if (dtp->u.p.current_unit->pad_status == PAD_NO)
{
- if (no_error)
+ if (likely (no_error))
break;
generate_error (&dtp->common, LIBERROR_EOR, NULL);
return NULL;
dtp->u.p.current_unit->bytes_left = dtp->u.p.current_unit->recl;
else
{
- if (dtp->u.p.current_unit->pad_status == PAD_NO)
+ if (unlikely (dtp->u.p.current_unit->pad_status == PAD_NO))
{
/* Not enough data left. */
generate_error (&dtp->common, LIBERROR_EOR, NULL);
}
}
- if (dtp->u.p.current_unit->bytes_left == 0)
+ if (unlikely (dtp->u.p.current_unit->bytes_left == 0))
{
dtp->u.p.current_unit->endfile = AT_ENDFILE;
generate_error (&dtp->common, LIBERROR_END, NULL);
dtp->u.p.current_unit->bytes_left -= (gfc_offset) *nbytes;
nread = *nbytes;
- if (sread (dtp->u.p.current_unit->s, buf, &nread) != 0)
+ if (unlikely (sread (dtp->u.p.current_unit->s, buf, &nread) != 0))
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return FAILURE;
if (nread != *nbytes)
{ /* Short read, this shouldn't happen. */
- if (dtp->u.p.current_unit->pad_status == PAD_YES)
+ if (likely (dtp->u.p.current_unit->pad_status == PAD_YES))
*nbytes = nread;
else
{
{
to_read_record = *nbytes;
have_read_record = to_read_record;
- if (sread (dtp->u.p.current_unit->s, buf, &have_read_record) != 0)
+ if (unlikely (sread (dtp->u.p.current_unit->s, buf, &have_read_record)
+ != 0))
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return;
dtp->u.p.current_unit->strm_pos += (gfc_offset) have_read_record;
- if (to_read_record != have_read_record)
+ if (unlikely (to_read_record != have_read_record))
{
/* Short read, e.g. if we hit EOF. For stream files,
we have to set the end-of-file condition. */
dtp->u.p.current_unit->bytes_left -= to_read_record;
- if (sread (dtp->u.p.current_unit->s, buf, &to_read_record) != 0)
+ if (unlikely (sread (dtp->u.p.current_unit->s, buf, &to_read_record)
+ != 0))
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return;
return;
}
- if (short_record)
+ if (unlikely (short_record))
{
generate_error (&dtp->common, LIBERROR_SHORT_RECORD, NULL);
return;
until the request has been fulfilled or the record has run out
of continuation subrecords. */
- if (dtp->u.p.current_unit->endfile == AT_ENDFILE)
+ if (unlikely (dtp->u.p.current_unit->endfile == AT_ENDFILE))
{
generate_error (&dtp->common, LIBERROR_END, NULL);
return;
dtp->u.p.current_unit->bytes_left_subrecord -= to_read_subrecord;
have_read_subrecord = to_read_subrecord;
- if (sread (dtp->u.p.current_unit->s, buf + have_read_record,
- &have_read_subrecord) != 0)
+ if (unlikely (sread (dtp->u.p.current_unit->s, buf + have_read_record,
+ &have_read_subrecord) != 0))
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return;
have_read_record += have_read_subrecord;
- if (to_read_subrecord != have_read_subrecord)
+ if (unlikely (to_read_subrecord != have_read_subrecord))
{
/* Short read, e.g. if we hit EOF. This means the record
if (to_read_record > 0)
{
- if (dtp->u.p.current_unit->continued)
+ if (likely (dtp->u.p.current_unit->continued))
{
next_record_r_unf (dtp, 0);
us_read (dtp, 1);
}
dtp->u.p.current_unit->bytes_left -= have_read_record;
- if (short_record)
+ if (unlikely (short_record))
{
generate_error (&dtp->common, LIBERROR_SHORT_RECORD, NULL);
return;
{
/* For preconnected units with default record length, set bytes left
to unit record length and proceed, otherwise error. */
- if ((dtp->u.p.current_unit->unit_number == options.stdout_unit
- || dtp->u.p.current_unit->unit_number == options.stderr_unit)
- && dtp->u.p.current_unit->recl == DEFAULT_RECL)
+ if (likely ((dtp->u.p.current_unit->unit_number
+ == options.stdout_unit
+ || dtp->u.p.current_unit->unit_number
+ == options.stderr_unit)
+ && dtp->u.p.current_unit->recl == DEFAULT_RECL))
dtp->u.p.current_unit->bytes_left = dtp->u.p.current_unit->recl;
else
{
return NULL;
}
- if (dtp->u.p.current_unit->endfile == AT_ENDFILE)
+ if (unlikely (dtp->u.p.current_unit->endfile == AT_ENDFILE))
generate_error (&dtp->common, LIBERROR_END, NULL);
}
else
if (is_stream_io (dtp))
{
- if (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0)
+ if (unlikely (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0))
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return FAILURE;
if (dtp->u.p.current_unit->flags.access == ACCESS_DIRECT)
{
- if (dtp->u.p.current_unit->bytes_left < (gfc_offset) nbytes)
+ if (unlikely (dtp->u.p.current_unit->bytes_left < (gfc_offset) nbytes))
{
generate_error (&dtp->common, LIBERROR_DIRECT_EOR, NULL);
return FAILURE;
if (buf == NULL && nbytes == 0)
return SUCCESS;
- if (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0)
+ if (unlikely (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0))
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return FAILURE;
dtp->u.p.current_unit->bytes_left_subrecord -=
(gfc_offset) to_write_subrecord;
- if (swrite (dtp->u.p.current_unit->s, buf + have_written,
- &to_write_subrecord) != 0)
+ if (unlikely (swrite (dtp->u.p.current_unit->s, buf + have_written,
+ &to_write_subrecord) != 0))
{
generate_error (&dtp->common, LIBERROR_OS, NULL);
return FAILURE;
us_write (dtp, 1);
}
dtp->u.p.current_unit->bytes_left -= have_written;
- if (short_record)
+ if (unlikely (short_record))
{
generate_error (&dtp->common, LIBERROR_SHORT_RECORD, NULL);
return FAILURE;
if (f == NULL)
{
/* No data descriptors left. */
- if (n > 0)
+ if (unlikely (n > 0))
generate_error (&dtp->common, LIBERROR_FORMAT,
"Insufficient data descriptors in format after reversion");
return;
nr = n;
- if (sread (dtp->u.p.current_unit->s, &i, &n) != 0)
+ if (unlikely (sread (dtp->u.p.current_unit->s, &i, &n) != 0))
{
generate_error (&dtp->common, LIBERROR_BAD_US, NULL);
return;
return; /* end of file */
}
- if (n != nr)
+ if (unlikely (n != nr))
{
generate_error (&dtp->common, LIBERROR_BAD_US, NULL);
return;
}
/* Only GFC_CONVERT_NATIVE and GFC_CONVERT_SWAP are valid here. */
- if (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE)
+ if (likely (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE))
{
switch (nr)
{
len = compile_options.record_marker;
/* Only GFC_CONVERT_NATIVE and GFC_CONVERT_SWAP are valid here. */
- if (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE)
+ if (likely (dtp->u.p.current_unit->flags.convert == GFC_CONVERT_NATIVE))
{
switch (len)
{
else
m_write = m;
- if (write_us_marker (dtp, m_write) != 0)
+ if (unlikely (write_us_marker (dtp, m_write) != 0))
goto io_error;
if (compile_options.record_marker == 0)
/* Seek to the head and overwrite the bogus length with the real
length. */
- if (sseek (dtp->u.p.current_unit->s, c - m - record_marker)
- == FAILURE)
+ if (unlikely (sseek (dtp->u.p.current_unit->s, c - m - record_marker)
+ == FAILURE))
goto io_error;
if (next_subrecord)
else
m_write = m;
- if (write_us_marker (dtp, m_write) != 0)
+ if (unlikely (write_us_marker (dtp, m_write) != 0))
goto io_error;
/* Seek past the end of the current record. */
- if (sseek (dtp->u.p.current_unit->s, c + record_marker) == FAILURE)
+ if (unlikely (sseek (dtp->u.p.current_unit->s, c + record_marker)
+ == FAILURE))
goto io_error;
return;