file.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*****************************************************************************/
  2. /* FILE.H v8.2.2 */
  3. /* */
  4. /* Copyright (c) 1995-2017 Texas Instruments Incorporated */
  5. /* http://www.ti.com/ */
  6. /* */
  7. /* Redistribution and use in source and binary forms, with or without */
  8. /* modification, are permitted provided that the following conditions */
  9. /* are met: */
  10. /* */
  11. /* Redistributions of source code must retain the above copyright */
  12. /* notice, this list of conditions and the following disclaimer. */
  13. /* */
  14. /* Redistributions in binary form must reproduce the above copyright */
  15. /* notice, this list of conditions and the following disclaimer in */
  16. /* the documentation and/or other materials provided with the */
  17. /* distribution. */
  18. /* */
  19. /* Neither the name of Texas Instruments Incorporated nor the names */
  20. /* of its contributors may be used to endorse or promote products */
  21. /* derived from this software without specific prior written */
  22. /* permission. */
  23. /* */
  24. /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
  25. /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
  26. /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
  27. /* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
  28. /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
  29. /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
  30. /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
  31. /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */
  32. /* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
  33. /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
  34. /* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
  35. /* */
  36. /*****************************************************************************/
  37. /*****************************************************************************/
  38. /* Macros and declarations used in lowlevel I/O functions. */
  39. /*****************************************************************************/
  40. #ifndef _FILE
  41. #define _FILE
  42. #include <linkage.h>
  43. /*---------------------------------------------------------------------------*/
  44. /* constants for file manipulations */
  45. /*---------------------------------------------------------------------------*/
  46. #define O_RDONLY (0x0000) /* open for reading */
  47. #define O_WRONLY (0x0001) /* open for writing */
  48. #define O_RDWR (0x0002) /* open for read & write */
  49. #define O_APPEND (0x0008) /* append on each write */
  50. #define O_CREAT (0x0200) /* open with file create */
  51. #define O_TRUNC (0x0400) /* open with truncation */
  52. #define O_BINARY (0x8000) /* open in binary mode */
  53. /*---------------------------------------------------------------------------*/
  54. /* lowlevel I/O declarations */
  55. /*---------------------------------------------------------------------------*/
  56. #ifdef __cplusplus
  57. #define _DECL extern "C"
  58. #else /* ! __cplusplus */
  59. #define _DECL extern
  60. #endif
  61. #ifndef _OFF_T
  62. #define _OFF_T
  63. typedef int off_t;
  64. #endif /* _OFF_T */
  65. #ifndef SEEK_SET
  66. #define SEEK_SET (0x0000)
  67. #endif /* SEEK_SET */
  68. #ifndef SEEK_CUR
  69. #define SEEK_CUR (0x0001)
  70. #endif /*SEEK_CUR */
  71. #ifndef SEEK_END
  72. #define SEEK_END (0x0002)
  73. #endif /* SEEK_END */
  74. _DECL _CODE_ACCESS int open(const char *path, unsigned flags, int mode);
  75. _DECL _CODE_ACCESS int read(int fildes, char *bufptr, unsigned cnt);
  76. _DECL _CODE_ACCESS int write(int fildes, const char *bufptr, unsigned cnt);
  77. _DECL _CODE_ACCESS off_t lseek(int fildes, off_t offset, int origin);
  78. _DECL _CODE_ACCESS int close(int fildes);
  79. _DECL _CODE_ACCESS int unlink(const char *path);
  80. _DECL _CODE_ACCESS int rename(const char *old_name, const char *new_name);
  81. _DECL _CODE_ACCESS int add_device(
  82. char *name,
  83. unsigned flags,
  84. int (*dopen)(const char *path, unsigned flags, int llv_fd),
  85. int (*dclose)(int dev_fd),
  86. int (*dread)(int dev_fd, char *buf, unsigned count),
  87. int (*dwrite)(int dev_fd, const char *buf, unsigned count),
  88. off_t (*dlseek)(int dev_fd, off_t offset, int origin),
  89. int (*dunlink)(const char *path),
  90. int (*drename)(const char *old_name, const char *new_name));
  91. /*---------------------------------------------------------------------------*/
  92. /* _NSTREAM defines the max number of files you can have open with fopen(). */
  93. /* Since the standard streams(stdin/stdout/stderr) use 3 of them by default, */
  94. /* (_NSTREAM - 3) will be available to users. */
  95. /*---------------------------------------------------------------------------*/
  96. #define _NSTREAM 20
  97. #define _NDEVICE 3 /* Size of device table */
  98. #define _SSA (0x0000) /* Single Stream allowed */
  99. #define _BUSY (0x0001) /* Device busy */
  100. #define _MSA (0x0002) /* Multiple Streams Allowed */
  101. #undef _DECL
  102. #endif /* _FILE */