Changeset 36635433 in rtems


Ignore:
Timestamp:
02/24/17 13:44:04 (7 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
902ffed
Parents:
a165a96
git-author:
Sebastian Huber <sebastian.huber@…> (02/24/17 13:44:04)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/28/17 08:09:23)
Message:

termios: Implement non-blocking write

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/termios.c

    ra165a96 r36635433  
    12151215
    12161216static uint32_t
    1217 rtems_termios_write_tty (rtems_termios_tty *tty, const char *buf, uint32_t len)
    1218 {
    1219   bool wait = true;
     1217rtems_termios_write_tty (rtems_libio_t *iop, rtems_termios_tty *tty,
     1218                         const char *buf, uint32_t len)
     1219{
     1220  bool wait = ((iop->flags & LIBIO_FLAGS_NO_DELAY) == 0);
    12201221
    12211222  if (tty->termios.c_oflag & OPOST) {
     
    12531254    return sc;
    12541255  }
    1255   args->bytes_moved = rtems_termios_write_tty (tty, args->buffer, args->count);
     1256  args->bytes_moved = rtems_termios_write_tty (args->iop, tty,
     1257                                               args->buffer, args->count);
    12561258  rtems_semaphore_release (tty->osem);
    12571259  return sc;
     
    21632165  }
    21642166
    2165   bytes_moved = rtems_termios_write_tty (tty, buffer, count);
     2167  bytes_moved = rtems_termios_write_tty (iop, tty, buffer, count);
    21662168  rtems_semaphore_release (tty->osem);
    21672169  return (ssize_t) bytes_moved;
  • testsuites/libtests/termios09/init.c

    ra165a96 r36635433  
    200200}
    201201
     202static void enable_non_blocking(test_context *ctx, size_t i, bool enable)
     203{
     204  int flags;
     205  int rv;
     206
     207  flags = fcntl(ctx->fds[i], F_GETFL, 0);
     208  rtems_test_assert(flags >= 0);
     209
     210  if (enable) {
     211    flags |= O_NONBLOCK;
     212  } else {
     213    flags &= ~O_NONBLOCK;
     214  }
     215
     216  rv = fcntl(ctx->fds[i], F_SETFL, flags);
     217  rtems_test_assert(rv == 0);
     218}
     219
    202220static void clear_set_iflag(
    203221  test_context *ctx,
     
    969987  rtems_test_assert(ctx->context_switch_counter == 0);
    970988
     989  enable_non_blocking(ctx, i, true);
     990  n = write(ctx->fds[i], &buf[OUTPUT_BUFFER_SIZE - 1], 1);
     991  rtems_test_assert(n == 0);
     992
     993  enable_non_blocking(ctx, i, false);
    971994  n = write(ctx->fds[i], &buf[OUTPUT_BUFFER_SIZE - 1], 1);
    972995  rtems_test_assert(n == 1);
     
    9951018  rtems_test_assert(ctx->context_switch_counter == 2);
    9961019
     1020  enable_non_blocking(ctx, i, true);
     1021  n = write(ctx->fds[i], &buf[OUTPUT_BUFFER_SIZE - 2], 1);
     1022  rtems_test_assert(n == 0);
     1023
     1024  enable_non_blocking(ctx, i, false);
    9971025  n = write(ctx->fds[i], &buf[OUTPUT_BUFFER_SIZE - 2], 1);
    9981026  rtems_test_assert(n == 1);
     
    10211049  rtems_test_assert(ctx->context_switch_counter == 4);
    10221050
     1051  enable_non_blocking(ctx, i, true);
     1052  n = write(ctx->fds[i], &buf[OUTPUT_BUFFER_SIZE - 8], 1);
     1053  rtems_test_assert(n == 0);
     1054
     1055  enable_non_blocking(ctx, i, false);
    10231056  n = write(ctx->fds[i], &buf[OUTPUT_BUFFER_SIZE - 8], 1);
    10241057  rtems_test_assert(n == 1);
Note: See TracChangeset for help on using the changeset viewer.