/* Virtual: read_nonblocking Returns: the number of bytes read, or -1 on error (including G_IO_ERROR_WOULD_BLOCK).  */
gssize g_pollable_input_stream_read_nonblocking(GPollableInputStream *stream, void *buffer, gsize count, GCancellable *cancellable, GError **error)
/* Virtual: read_nonblocking Returns: the number of bytes read, or -1 on error (including G_IO_ERROR_WOULD_BLOCK).  */
gssize g_pollable_input_stream_read_nonblocking(GPollableInputStream *stream, void *buffer, gsize count, GCancellable *cancellable, GError **error)
{
  gssize res;
  g_return_val_if_fail (G_IS_POLLABLE_INPUT_STREAM (stream), -1);
  g_return_val_if_fail (buffer != NULL, 0);
  if (g_cancellable_set_error_if_cancelled (cancellable, error))
    return -1;
  if (count == 0)
    return 0;
  if (((gssize) count) < 0)
    {
      g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
		   _("Too large count value passed to %s"), G_STRFUNC);
      return -1;
    }
  if (cancellable)
    g_cancellable_push_current (cancellable);
  res = G_POLLABLE_INPUT_STREAM_GET_INTERFACE (stream)->
    read_nonblocking (stream, buffer, count, error);
  if (cancellable)
    g_cancellable_pop_current (cancellable);
  return res;
}