gdbio.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Xtensa Debug-FileSystem definitions
  2. *
  3. * Copyright (c) 2006-2009 by Tensilica Inc. ALL RIGHTS RESERVED.
  4. * These coded instructions, statements, and computer programs are the
  5. * copyrighted works and confidential proprietary information of Tensilica Inc.
  6. * They may not be modified, copied, reproduced, distributed, or disclosed to
  7. * third parties in any manner, medium, or form, in whole or in part, without
  8. * the prior written consent of Tensilica Inc.
  9. */
  10. #ifndef __DEBUGFS_H__
  11. #define __DEBUGFS_H__
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <unistd.h>
  16. #include <fcntl.h>
  17. #include <stdlib.h>
  18. #include <errno.h>
  19. int _gdbio_open_r(void * ptr, const char *pathname, int flags, mode_t mode);
  20. int _gdbio_creat_r(void * ptr, const char *pathname, mode_t mode);
  21. int _gdbio_lseek_r(void * ptr, int fd, off_t offset, int whence);
  22. ssize_t _gdbio_write_r(void * ptr, int fd, const void * buf, size_t bytes);
  23. ssize_t _gdbio_read_r(void * ptr, int fd, void * buf, size_t bytes);
  24. int _gdbio_close_r(void * ptr, int fd);
  25. int _gdbio_unlink_r(void * ptr, const char * pathname);
  26. static inline
  27. int gdbio_open(const char *pathname, int flags, mode_t mode) {
  28. return _gdbio_open_r(&errno, pathname, flags, mode);
  29. }
  30. static inline int
  31. gdbio_creat(const char *pathname, mode_t mode) {
  32. return _gdbio_open_r(&errno, pathname, O_CREAT|O_WRONLY|O_TRUNC, mode);
  33. }
  34. static inline int
  35. gdbio_errno(void) {
  36. return errno;
  37. }
  38. static inline int
  39. gdbio_lseek(int fd, off_t offset, int whence) {
  40. return _gdbio_lseek_r(&errno, fd, offset, whence);
  41. }
  42. static inline
  43. ssize_t gdbio_write(int fd, const void * buf, size_t bytes) {
  44. return _gdbio_write_r(&errno, fd, buf, bytes);
  45. }
  46. static inline
  47. ssize_t gdbio_read(int fd, void * buf, size_t bytes) {
  48. return _gdbio_read_r(&errno, fd, buf, bytes);
  49. }
  50. static inline int
  51. gdbio_close(int fd) {
  52. return _gdbio_close_r(&errno, fd);
  53. }
  54. static inline int
  55. gdbio_unlink(const char * pathname) {
  56. return _gdbio_unlink_r(&errno, pathname);
  57. }
  58. #ifdef REPLACE_FS_WITH_GDBIO
  59. #define open gdbio_open
  60. #define close gdbio_close
  61. #define creat gdbio_creat
  62. #define lseek gdbio_lseek
  63. #define write gdbio_write
  64. #define read gdbio_read
  65. #define close gdbio_close
  66. #define unlink gdbio_unlink
  67. #endif
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif