pipe.h 787 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #ifndef PIPE_H__
  10. #define PIPE_H__
  11. #include <rtdef.h>
  12. #include <rtconfig.h>
  13. /**
  14. * Pipe Device
  15. */
  16. struct rt_pipe_device
  17. {
  18. struct rt_device parent;
  19. rt_bool_t is_named;
  20. #ifdef RT_USING_POSIX_DEVIO
  21. int pipeno; /* for unamed pipe */
  22. #endif
  23. /* ring buffer in pipe device */
  24. struct rt_ringbuffer *fifo;
  25. rt_uint16_t bufsz;
  26. rt_wqueue_t reader_queue;
  27. rt_wqueue_t writer_queue;
  28. int writer;
  29. int reader;
  30. struct rt_mutex lock;
  31. };
  32. typedef struct rt_pipe_device rt_pipe_t;
  33. rt_pipe_t *rt_pipe_create(const char *name, int bufsz);
  34. int rt_pipe_delete(const char *name);
  35. #endif /* PIPE_H__ */