fcntlcom.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* fcntlcom.h - basic control types header */
  2. /* Copyright 1984-1999 Wind River Systems, Inc. */
  3. /*
  4.  * Copyright (c) 1983 Regents of the University of California.
  5.  * All rights reserved.  The Berkeley software License Agreement
  6.  * specifies the terms and conditions for redistribution.
  7.  */
  8. /*
  9. modification history
  10. --------------------
  11. 01d,13dec99,jkf  added _ASMLANGUAGE
  12. 01c,25jan93,smb  added documentation for POSIX
  13. 01b,22sep92,rrr  added support for c++
  14. 01a,29jul92,smb  taken from UCB stdio.
  15. */
  16. #ifndef __INCfcntlcomh
  17. #define __INCfcntlcomh
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include "types/vxANSI.h"
  22. /*
  23.  * Rewack the FXXXXX values as _FXXXX so that _POSIX_SOURCE works.
  24.  */
  25. #define _FOPEN (-1) /* from sys/file.h, kernel use only */
  26. #define _FREAD 0x0001 /* read enabled */
  27. #define _FWRITE 0x0002 /* write enabled */
  28. #define _FNDELAY 0x0004 /* non blocking I/O (4.2 style) */
  29. #define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */
  30. #define _FMARK 0x0010 /* internal; mark during gc() */
  31. #define _FDEFER 0x0020 /* internal; defer for next gc pass */
  32. #define _FASYNC 0x0040 /* signal pgrp when data ready */
  33. #define _FSHLOCK 0x0080 /* BSD flock() shared lock present */
  34. #define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */
  35. #define _FCREAT 0x0200 /* open with file create */
  36. #define _FTRUNC 0x0400 /* open with truncation */
  37. #define _FEXCL 0x0800 /* error on open if file exists */
  38. #define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */
  39. #define _FSYNC 0x2000 /* do all writes synchronously */
  40. #define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */
  41. #define _FNOCTTY 0x8000 /* don't assign a ctty on this open */
  42. #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
  43. #define DEFFILEMODE  0666
  44. /*
  45.  * Flag values for open(2) and fcntl(2)
  46.  * The kernel adds 1 to the open modes to turn it into some
  47.  * combination of FREAD and FWRITE.
  48.  */
  49. #define O_RDONLY 0 /* +1 == FREAD */
  50. #define O_WRONLY 1 /* +1 == FWRITE */
  51. #define O_RDWR 2 /* +1 == FREAD|FWRITE */
  52. #define O_CREAT _FCREAT
  53. /*
  54.  * added for future POSIX extensions 
  55.  */
  56. #define O_APPEND _FAPPEND
  57. #define O_TRUNC _FTRUNC
  58. #define O_EXCL _FEXCL
  59. #define O_NONBLOCK _FNONBLOCK
  60. #define O_NOCTTY _FNOCTTY
  61. #ifndef _POSIX_SOURCE
  62. #define O_SYNC _FSYNC
  63. /*
  64.  * Flags that work for fcntl(fd, F_SETFL, FXXXX)
  65.  */
  66. #define FAPPEND _FAPPEND
  67. #define FSYNC _FSYNC
  68. #define FASYNC _FASYNC
  69. #define FNBIO _FNBIO
  70. #define FNONBIO _FNONBLOCK
  71. #define FNDELAY _FNDELAY
  72. /*
  73.  * Flags that are disallowed for fcntl's (FCNTLCANT);
  74.  * used for opens, internal state, or locking.
  75.  */
  76. #define FREAD _FREAD
  77. #define FWRITE _FWRITE
  78. #define FMARK _FMARK
  79. #define FDEFER _FDEFER
  80. #define FSHLOCK _FSHLOCK
  81. #define FEXLOCK _FEXLOCK
  82. /*
  83.  * The rest of the flags, used only for opens
  84.  */
  85. #define FOPEN _FOPEN
  86. #define FCREAT _FCREAT
  87. #define FTRUNC _FTRUNC
  88. #define FEXCL _FEXCL
  89. #define FNOCTTY _FNOCTTY
  90. #endif /*!_POSIX_SOURCE*/
  91. /* XXX close on exec request; must match UF_EXCLOSE in user.h */
  92. #define FD_CLOEXEC 1 /* posix */
  93. /* fcntl(2) requests */
  94. #define F_DUPFD 0 /* Duplicate fildes */
  95. #define F_GETFD 1 /* Get fildes flags (close on exec) */
  96. #define F_SETFD 2 /* Set fildes flags (close on exec) */
  97. #define F_GETFL 3 /* Get file flags */
  98. #define F_SETFL 4 /* Set file flags */
  99. #ifndef _POSIX_SOURCE
  100. #define F_GETOWN  5 /* Get owner - for ASYNC */
  101. #define F_SETOWN  6 /* Set owner - for ASYNC */
  102. #endif /* !_POSIX_SOURCE */
  103. #define F_GETLK   7 /* Get record-locking information */
  104. #define F_SETLK   8 /* Set or Clear a record-lock (Non-Blocking) */
  105. #define F_SETLKW  9 /* Set or Clear a record-lock (Blocking) */
  106. #ifndef _POSIX_SOURCE
  107. #define F_RGETLK  10 /* Test a remote lock to see if it is blocked */
  108. #define F_RSETLK  11 /* Set or unlock a remote lock */
  109. #define F_CNVT  12 /* Convert a fhandle to an open fd */
  110. #define F_RSETLKW  13 /* Set or Clear remote record-lock(Blocking) */
  111. #endif /* !_POSIX_SOURCE */
  112. /* fcntl(2) flags (l_type field of flock structure) */
  113. #define F_RDLCK 1 /* read lock */
  114. #define F_WRLCK 2 /* write lock */
  115. #define F_UNLCK 3 /* remove lock(s) */
  116. #ifndef _POSIX_SOURCE
  117. #define F_UNLKSYS 4 /* remove remote locks for a given system */
  118. #endif /* !_POSIX_SOURCE */
  119. #ifndef _ASMLANGUAGE
  120. /* file segment locking set data type - information passed to system by user */
  121. struct flock {
  122. short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
  123. short l_whence; /* flag to choose starting offset */
  124. long l_start; /* relative offset, in bytes */
  125. long l_len; /* length, in bytes; 0 means lock to EOF */
  126. short l_pid; /* returned with F_GETLK */
  127. short l_xxx; /* reserved for future use */
  128. };
  129. #ifndef _POSIX_SOURCE
  130. /* extended file segment locking set data type */
  131. struct eflock {
  132. short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */
  133. short l_whence; /* flag to choose starting offset */
  134. long l_start; /* relative offset, in bytes */
  135. long l_len; /* length, in bytes; 0 means lock to EOF */
  136. short l_pid; /* returned with F_GETLK */
  137. short l_xxx; /* reserved for future use */
  138. long l_rpid; /* Remote process id wanting this lock */
  139. long l_rsys; /* Remote system id wanting this lock */
  140. };
  141. #endif /* !_POSIX_SOURCE */
  142. #endif /* #ifndef _ASMLANGUAGE */
  143.  
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147. #endif /* __INCfcntlcomh */