/dep/acelite/ace/OS_NS_unistd.h

https://gitlab.com/mohsencs/SunWellCore · C Header · 373 lines · 248 code · 87 blank · 38 comment · 4 complexity · 5062b1f0f698290866d9bfd062725947 MD5 · raw file

  1. // -*- C++ -*-
  2. //=============================================================================
  3. /**
  4. * @file OS_NS_unistd.h
  5. *
  6. * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
  7. * @author Jesper S. M|ller<stophph@diku.dk>
  8. * @author and a cast of thousands...
  9. *
  10. * Originally in OS.h.
  11. */
  12. //=============================================================================
  13. #ifndef ACE_OS_NS_UNISTD_H
  14. # define ACE_OS_NS_UNISTD_H
  15. # include /**/ "ace/pre.h"
  16. # include "ace/config-all.h"
  17. # if !defined (ACE_LACKS_PRAGMA_ONCE)
  18. # pragma once
  19. # endif /* ACE_LACKS_PRAGMA_ONCE */
  20. #include /**/ "ace/ACE_export.h"
  21. #include "ace/Time_Value.h"
  22. #include "ace/Basic_Types.h"
  23. #include "ace/os_include/os_unistd.h"
  24. #include "ace/os_include/os_stdio.h"
  25. #if defined (ACE_EXPORT_MACRO)
  26. # undef ACE_EXPORT_MACRO
  27. #endif
  28. #define ACE_EXPORT_MACRO ACE_Export
  29. ACE_BEGIN_VERSIONED_NAMESPACE_DECL
  30. namespace ACE_OS
  31. {
  32. ACE_NAMESPACE_INLINE_FUNCTION
  33. int access (const char *path, int amode);
  34. #if defined (ACE_HAS_WCHAR)
  35. ACE_NAMESPACE_INLINE_FUNCTION
  36. int access (const wchar_t *path, int amode);
  37. #endif /* ACE_HAS_WCHAR */
  38. ACE_NAMESPACE_INLINE_FUNCTION
  39. unsigned int alarm (u_int secs);
  40. ACE_NAMESPACE_INLINE_FUNCTION
  41. long allocation_granularity (void);
  42. /// used by ARGV::argv_to_string() and ACE_OS::fork_exec()
  43. extern ACE_Export
  44. int argv_to_string (int argc,
  45. ACE_TCHAR **argv,
  46. ACE_TCHAR *&buf,
  47. bool substitute_env_args = true,
  48. bool quote_args = false);
  49. extern ACE_Export
  50. int argv_to_string (ACE_TCHAR **argv,
  51. ACE_TCHAR *&buf,
  52. bool substitute_env_args = true,
  53. bool quote_args = false);
  54. ACE_NAMESPACE_INLINE_FUNCTION
  55. int chdir (const char *path);
  56. #if defined (ACE_HAS_WCHAR)
  57. ACE_NAMESPACE_INLINE_FUNCTION
  58. int chdir (const wchar_t *path);
  59. #endif /* ACE_HAS_WCHAR */
  60. ACE_NAMESPACE_INLINE_FUNCTION
  61. int rmdir (const char *path);
  62. #if defined (ACE_HAS_WCHAR)
  63. ACE_NAMESPACE_INLINE_FUNCTION
  64. int rmdir (const wchar_t *path);
  65. #endif /* ACE_HAS_WCHAR */
  66. ACE_NAMESPACE_INLINE_FUNCTION
  67. int close (ACE_HANDLE handle);
  68. ACE_NAMESPACE_INLINE_FUNCTION
  69. ACE_HANDLE dup (ACE_HANDLE handle);
  70. ACE_NAMESPACE_INLINE_FUNCTION
  71. ACE_HANDLE dup (ACE_HANDLE handle, pid_t pid);
  72. ACE_NAMESPACE_INLINE_FUNCTION
  73. int dup2 (ACE_HANDLE oldfd,
  74. ACE_HANDLE newfd);
  75. extern ACE_Export
  76. int execl (const char *path,
  77. const char *arg0, ...);
  78. extern ACE_Export
  79. int execle (const char *path,
  80. const char *arg0, ...);
  81. extern ACE_Export
  82. int execlp (const char *file,
  83. const char *arg0, ...);
  84. ACE_NAMESPACE_INLINE_FUNCTION
  85. int execv (const char *path,
  86. char *const argv[]);
  87. ACE_NAMESPACE_INLINE_FUNCTION
  88. int execve (const char *path,
  89. char *const argv[],
  90. char *const envp[]);
  91. ACE_NAMESPACE_INLINE_FUNCTION
  92. int execvp (const char *file,
  93. char *const argv[]);
  94. //@{
  95. /// Forks and exec's a process in a manner that works on Solaris and
  96. /// NT. argv[0] must be the full path name to the executable.
  97. ACE_NAMESPACE_INLINE_FUNCTION
  98. pid_t fork (void);
  99. // not in susv3
  100. extern ACE_Export
  101. pid_t fork (const ACE_TCHAR *program_name);
  102. extern ACE_Export
  103. pid_t fork_exec (ACE_TCHAR *argv[]);
  104. //@}
  105. ACE_NAMESPACE_INLINE_FUNCTION
  106. int fsync (ACE_HANDLE handle);
  107. ACE_NAMESPACE_INLINE_FUNCTION
  108. int ftruncate (ACE_HANDLE handle, ACE_OFF_T offset);
  109. ACE_NAMESPACE_INLINE_FUNCTION
  110. char *getcwd (char *, size_t);
  111. #if defined (ACE_HAS_WCHAR)
  112. ACE_NAMESPACE_INLINE_FUNCTION
  113. wchar_t *getcwd (wchar_t *, size_t);
  114. #endif /* ACE_HAS_WCHAR */
  115. ACE_NAMESPACE_INLINE_FUNCTION
  116. gid_t getgid (void);
  117. ACE_NAMESPACE_INLINE_FUNCTION
  118. gid_t getegid (void);
  119. ACE_NAMESPACE_INLINE_FUNCTION
  120. int getopt (int argc,
  121. char *const *argv,
  122. const char *optstring);
  123. ACE_NAMESPACE_INLINE_FUNCTION
  124. long getpagesize (void);
  125. ACE_NAMESPACE_INLINE_FUNCTION
  126. pid_t getpgid (pid_t pid);
  127. ACE_NAMESPACE_INLINE_FUNCTION
  128. pid_t getpid (void);
  129. ACE_NAMESPACE_INLINE_FUNCTION
  130. pid_t getppid (void);
  131. ACE_NAMESPACE_INLINE_FUNCTION
  132. uid_t getuid (void);
  133. ACE_NAMESPACE_INLINE_FUNCTION
  134. uid_t geteuid (void);
  135. // should call gethostname()
  136. ACE_NAMESPACE_INLINE_FUNCTION
  137. int hostname (char name[],
  138. size_t maxnamelen);
  139. #if defined (ACE_HAS_WCHAR)
  140. ACE_NAMESPACE_INLINE_FUNCTION
  141. int hostname (wchar_t name[],
  142. size_t maxnamelen);
  143. #endif /* ACE_HAS_WCHAR */
  144. ACE_NAMESPACE_INLINE_FUNCTION
  145. int isatty (int handle);
  146. #if defined (ACE_WIN32)
  147. ACE_NAMESPACE_INLINE_FUNCTION
  148. int isatty (ACE_HANDLE handle);
  149. #endif /* ACE_WIN32 */
  150. ACE_NAMESPACE_INLINE_FUNCTION
  151. ACE_OFF_T lseek (ACE_HANDLE handle,
  152. ACE_OFF_T offset,
  153. int whence);
  154. #if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
  155. ACE_NAMESPACE_INLINE_FUNCTION
  156. ACE_LOFF_T llseek (ACE_HANDLE handle,
  157. ACE_LOFF_T offset,
  158. int whence);
  159. #endif /* ACE_HAS_LLSEEK */
  160. /// Get the number of CPUs configured in the machine.
  161. extern ACE_Export
  162. long num_processors (void);
  163. /// Get the number of CPUs currently online.
  164. extern ACE_Export
  165. long num_processors_online (void);
  166. ACE_NAMESPACE_INLINE_FUNCTION
  167. int pipe (ACE_HANDLE handles[]);
  168. extern ACE_Export
  169. ssize_t pread (ACE_HANDLE handle,
  170. void *buf,
  171. size_t nbyte,
  172. ACE_OFF_T offset);
  173. extern ACE_Export
  174. ssize_t pwrite (ACE_HANDLE handle,
  175. const void *buf,
  176. size_t nbyte,
  177. ACE_OFF_T offset);
  178. ACE_NAMESPACE_INLINE_FUNCTION
  179. ssize_t read (ACE_HANDLE handle,
  180. void *buf,
  181. size_t len);
  182. ACE_NAMESPACE_INLINE_FUNCTION
  183. ssize_t read (ACE_HANDLE handle,
  184. void *buf,
  185. size_t len,
  186. ACE_OVERLAPPED *);
  187. /**
  188. * Receive @a len bytes into @a buf from @a handle (uses the
  189. * <ACE_OS::read> call, which uses the <read> system call on UNIX
  190. * and the <ReadFile> call on Win32). If errors occur, -1 is
  191. * returned. If EOF occurs, 0 is returned. Whatever data has been
  192. * read will be returned to the caller through @a bytes_transferred.
  193. *
  194. */
  195. extern ACE_Export
  196. ssize_t read_n (ACE_HANDLE handle,
  197. void *buf,
  198. size_t len,
  199. size_t *bytes_transferred = 0);
  200. ACE_NAMESPACE_INLINE_FUNCTION
  201. ssize_t readlink (const char *path,
  202. char *buf,
  203. size_t bufsiz);
  204. ACE_NAMESPACE_INLINE_FUNCTION
  205. void *sbrk (intptr_t brk);
  206. ACE_NAMESPACE_INLINE_FUNCTION
  207. int setgid (gid_t);
  208. ACE_NAMESPACE_INLINE_FUNCTION
  209. int setegid (gid_t);
  210. ACE_NAMESPACE_INLINE_FUNCTION
  211. int setpgid (pid_t pid, pid_t pgid);
  212. ACE_NAMESPACE_INLINE_FUNCTION
  213. int setregid (gid_t rgid, gid_t egid);
  214. ACE_NAMESPACE_INLINE_FUNCTION
  215. int setreuid (uid_t ruid, uid_t euid);
  216. ACE_NAMESPACE_INLINE_FUNCTION
  217. pid_t setsid (void);
  218. ACE_NAMESPACE_INLINE_FUNCTION
  219. int setuid (uid_t);
  220. ACE_NAMESPACE_INLINE_FUNCTION
  221. int seteuid (uid_t);
  222. ACE_NAMESPACE_INLINE_FUNCTION
  223. int sleep (u_int seconds);
  224. ACE_NAMESPACE_INLINE_FUNCTION
  225. int sleep (const ACE_Time_Value &tv);
  226. // used by ARGV::string_to_argv
  227. extern ACE_Export
  228. int string_to_argv (ACE_TCHAR *buf,
  229. int &argc,
  230. ACE_TCHAR **&argv,
  231. bool substitute_env_args = true);
  232. ACE_NAMESPACE_INLINE_FUNCTION
  233. void swab (const void *src, void *dest, ssize_t n);
  234. ACE_NAMESPACE_INLINE_FUNCTION
  235. long sysconf (int);
  236. // not in susv3
  237. ACE_NAMESPACE_INLINE_FUNCTION
  238. long sysinfo (int cmd,
  239. char *buf,
  240. long count);
  241. ACE_NAMESPACE_INLINE_FUNCTION
  242. int truncate (const ACE_TCHAR *filename, ACE_OFF_T length);
  243. ACE_NAMESPACE_INLINE_FUNCTION
  244. useconds_t ualarm (useconds_t usecs,
  245. useconds_t interval = 0);
  246. ACE_NAMESPACE_INLINE_FUNCTION
  247. useconds_t ualarm (const ACE_Time_Value &tv,
  248. const ACE_Time_Value &tv_interval = ACE_Time_Value::zero);
  249. ACE_NAMESPACE_INLINE_FUNCTION
  250. int unlink (const char *path);
  251. #if defined (ACE_HAS_WCHAR)
  252. ACE_NAMESPACE_INLINE_FUNCTION
  253. int unlink (const wchar_t *path);
  254. #endif /* ACE_HAS_WCHAR */
  255. ACE_NAMESPACE_INLINE_FUNCTION
  256. ssize_t write (ACE_HANDLE handle,
  257. const void *buf,
  258. size_t nbyte);
  259. ACE_NAMESPACE_INLINE_FUNCTION
  260. ssize_t write (ACE_HANDLE handle,
  261. const void *buf,
  262. size_t nbyte,
  263. ACE_OVERLAPPED *);
  264. /**
  265. * Send @a len bytes from @a buf to @a handle (uses the <ACE_OS::write>
  266. * calls, which is uses the <write> system call on UNIX and the
  267. * <WriteFile> call on Win32). If errors occur, -1 is returned. If
  268. * EOF occurs, 0 is returned. Whatever data has been transmitted
  269. * will be returned to the caller through @a bytes_transferred.
  270. */
  271. extern ACE_Export
  272. ssize_t write_n (ACE_HANDLE handle,
  273. const void *buf,
  274. size_t len,
  275. size_t *bytes_transferred = 0);
  276. } /* namespace ACE_OS */
  277. ACE_END_VERSIONED_NAMESPACE_DECL
  278. # if defined (ACE_HAS_INLINED_OSCALLS)
  279. # if defined (ACE_INLINE)
  280. # undef ACE_INLINE
  281. # endif /* ACE_INLINE */
  282. # define ACE_INLINE inline
  283. # include "ace/OS_NS_unistd.inl"
  284. # endif /* ACE_HAS_INLINED_OSCALLS */
  285. # include /**/ "ace/post.h"
  286. #endif /* ACE_OS_NS_UNISTD_H */