unistd.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (C) 2004-2005 by egnite Software GmbH. All rights reserved.
  3. *
  4. * Copyright (c) 1991 The Regents of the University of California.
  5. * All rights reserved.
  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. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the University nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  23. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  25. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  26. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  27. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  28. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * For additional information see http://www.ethernut.de/
  32. *
  33. */
  34. /*!
  35. * \file unistd.h
  36. * \brief Miscellaneous function declarations.
  37. *
  38. * \verbatim
  39. *
  40. * $Log$
  41. * Revision 1.9 2009/03/05 22:16:57 freckle
  42. * use __NUT_EMULATION instead of __APPLE__, __linux__, or __CYGWIN__
  43. *
  44. * Revision 1.8 2008/04/01 13:34:20 haraldkipp
  45. * Fixed Unix emulation build.
  46. *
  47. * Revision 1.6 2008/01/31 09:15:21 haraldkipp
  48. * Added sleep() prototype.
  49. *
  50. * Revision 1.5 2005/04/19 15:46:45 freckle
  51. * added #include <compiler.h> as the implicit ordering is not sufficient
  52. * on our red hat machines and the cruisecontrol build fails
  53. *
  54. * Revision 1.4 2005/03/24 14:32:02 freckle
  55. * added creation of include/unistd_orig.h to configure
  56. * Added NUT_ wrapper for nut's unistd.h functions. Use <unistd_orig.h>
  57. * instead of "/usr/include/unistd.h". Relevant for unix emulation only.
  58. *
  59. * Revision 1.3 2005/02/23 13:42:28 freckle
  60. * Correctly include /usr/include/unistd.h for unix emulation
  61. *
  62. * Revision 1.2 2005/02/21 11:08:45 olereinhardt
  63. * For unix plattforms I added #include "/usr/include/unistd.h" since some
  64. * functions needed for unix_nutinit.c are missing in this file...
  65. *
  66. * Revision 1.1 2005/02/05 20:37:17 haraldkipp
  67. * Peanut added
  68. *
  69. *
  70. * \endverbatim
  71. */
  72. #ifndef _UNISTD_NUT_H_
  73. #include <compiler.h> // required e.g. for const
  74. #ifndef _UNISTD_VIRTUAL_H_
  75. #define _UNISTD_VIRTUAL_H_
  76. /* use native version on unix emulation */
  77. #ifdef __NUT_EMULATION__
  78. #include "unistd_orig.h"
  79. // prefix all unistd calls with NUT_
  80. #define access(...) NUT_access(__VA_ARGS__)
  81. #define lseek(...) NUT_lseek(__VA_ARGS__)
  82. #define rmdir(...) NUT_rmdir(__VA_ARGS__)
  83. #define unlink(...) NUT_unlink(__VA_ARGS__)
  84. #define sleep(...) NUT_sleep(__VA_ARGS__)
  85. /* assure _UNISTD_H_ is set */
  86. #undef _UNISTD_H_
  87. #define _UNISTD_H_
  88. #define _UNISTD_H_
  89. #else /* unix emulation */
  90. /*!
  91. * \name Access functions
  92. */
  93. /*@{*/
  94. #define F_OK 0 /*!< \brief Test for existence of file. */
  95. #define X_OK 0x01 /*!< \brief Test for execute or search permission. */
  96. #define W_OK 0x02 /*!< \brief Test for write permission. */
  97. #define R_OK 0x04 /*!< \brief Test for read permission. */
  98. /*@}*/
  99. #endif /* unix emulation */
  100. extern int access(const char *path, int what);
  101. extern long lseek(int fh, long pos, int whence);
  102. extern int rmdir(const char *path);
  103. extern int unlink(const char *path);
  104. extern unsigned int sleep(unsigned int);
  105. #endif /* _UNISTD_VIRTUAL_H_ */
  106. #endif /* _UNISTD_H */