Revert to Current Include Style
[ACE_TAO.git] / ACE / ace / OS_NS_unistd.h
blob091cc708452ea36db1c610f8e2a4c6af6f4a44c1
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_NS_unistd.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 * Originally in OS.h.
13 //=============================================================================
15 #ifndef ACE_OS_NS_UNISTD_H
16 # define ACE_OS_NS_UNISTD_H
18 # include /**/ "ace/pre.h"
20 # include "ace/config-all.h"
22 # if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 # endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include /**/ "ace/ACE_export.h"
27 #include "ace/Time_Value.h"
28 #include "ace/Basic_Types.h"
29 #include "ace/os_include/os_unistd.h"
30 #include "ace/os_include/os_stdio.h"
32 #if defined (ACE_EXPORT_MACRO)
33 # undef ACE_EXPORT_MACRO
34 #endif
35 #define ACE_EXPORT_MACRO ACE_Export
37 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
39 namespace ACE_OS
42 ACE_NAMESPACE_INLINE_FUNCTION
43 int access (const char *path, int amode);
45 #if defined (ACE_HAS_WCHAR)
46 ACE_NAMESPACE_INLINE_FUNCTION
47 int access (const wchar_t *path, int amode);
48 #endif /* ACE_HAS_WCHAR */
50 ACE_NAMESPACE_INLINE_FUNCTION
51 unsigned int alarm (u_int secs);
53 ACE_NAMESPACE_INLINE_FUNCTION
54 long allocation_granularity ();
56 /// used by ARGV::argv_to_string() and ACE_OS::fork_exec()
57 extern ACE_Export
58 int argv_to_string (int argc,
59 ACE_TCHAR **argv,
60 ACE_TCHAR *&buf,
61 bool substitute_env_args = true,
62 bool quote_args = false);
64 extern ACE_Export
65 int argv_to_string (ACE_TCHAR **argv,
66 ACE_TCHAR *&buf,
67 bool substitute_env_args = true,
68 bool quote_args = false);
70 ACE_NAMESPACE_INLINE_FUNCTION
71 int chdir (const char *path);
73 #if defined (ACE_HAS_WCHAR)
74 ACE_NAMESPACE_INLINE_FUNCTION
75 int chdir (const wchar_t *path);
76 #endif /* ACE_HAS_WCHAR */
78 ACE_NAMESPACE_INLINE_FUNCTION
79 int rmdir (const char *path);
81 #if defined (ACE_HAS_WCHAR)
82 ACE_NAMESPACE_INLINE_FUNCTION
83 int rmdir (const wchar_t *path);
84 #endif /* ACE_HAS_WCHAR */
86 ACE_NAMESPACE_INLINE_FUNCTION
87 int close (ACE_HANDLE handle);
89 ACE_NAMESPACE_INLINE_FUNCTION
90 ACE_HANDLE dup (ACE_HANDLE handle);
92 ACE_NAMESPACE_INLINE_FUNCTION
93 ACE_HANDLE dup (ACE_HANDLE handle, pid_t pid);
95 ACE_NAMESPACE_INLINE_FUNCTION
96 int dup2 (ACE_HANDLE oldfd,
97 ACE_HANDLE newfd);
99 extern ACE_Export
100 int execl (const char *path,
101 const char *arg0, ...);
103 extern ACE_Export
104 int execle (const char *path,
105 const char *arg0, ...);
107 extern ACE_Export
108 int execlp (const char *file,
109 const char *arg0, ...);
111 ACE_NAMESPACE_INLINE_FUNCTION
112 int execv (const char *path,
113 char *const argv[]);
115 ACE_NAMESPACE_INLINE_FUNCTION
116 int execve (const char *path,
117 char *const argv[],
118 char *const envp[]);
120 ACE_NAMESPACE_INLINE_FUNCTION
121 int execvp (const char *file,
122 char *const argv[]);
124 //@{
125 /// Forks and exec's a process in a manner that works on Solaris and
126 /// NT. argv[0] must be the full path name to the executable.
127 ACE_NAMESPACE_INLINE_FUNCTION
128 pid_t fork ();
130 // not in susv3
131 extern ACE_Export
132 pid_t fork (const ACE_TCHAR *program_name);
134 extern ACE_Export
135 pid_t fork_exec (ACE_TCHAR *argv[]);
136 //@}
138 ACE_NAMESPACE_INLINE_FUNCTION
139 int fsync (ACE_HANDLE handle);
141 ACE_NAMESPACE_INLINE_FUNCTION
142 int ftruncate (ACE_HANDLE handle, ACE_OFF_T offset);
144 ACE_NAMESPACE_INLINE_FUNCTION
145 char *getcwd (char *, size_t);
147 #if defined (ACE_HAS_WCHAR)
148 ACE_NAMESPACE_INLINE_FUNCTION
149 wchar_t *getcwd (wchar_t *, size_t);
150 #endif /* ACE_HAS_WCHAR */
152 ACE_NAMESPACE_INLINE_FUNCTION
153 gid_t getgid ();
155 ACE_NAMESPACE_INLINE_FUNCTION
156 gid_t getegid ();
158 ACE_NAMESPACE_INLINE_FUNCTION
159 int getopt (int argc,
160 char *const *argv,
161 const char *optstring);
163 ACE_NAMESPACE_INLINE_FUNCTION
164 long getpagesize ();
166 ACE_NAMESPACE_INLINE_FUNCTION
167 pid_t getpgid (pid_t pid);
169 ACE_NAMESPACE_INLINE_FUNCTION
170 pid_t getpid ();
172 ACE_NAMESPACE_INLINE_FUNCTION
173 pid_t getppid ();
175 ACE_NAMESPACE_INLINE_FUNCTION
176 uid_t getuid ();
178 ACE_NAMESPACE_INLINE_FUNCTION
179 uid_t geteuid ();
181 // should call gethostname()
182 ACE_NAMESPACE_INLINE_FUNCTION
183 int hostname (char name[],
184 size_t maxnamelen);
186 #if defined (ACE_HAS_WCHAR)
187 ACE_NAMESPACE_INLINE_FUNCTION
188 int hostname (wchar_t name[],
189 size_t maxnamelen);
190 #endif /* ACE_HAS_WCHAR */
192 ACE_NAMESPACE_INLINE_FUNCTION
193 int isatty (int handle);
195 #if defined (ACE_WIN32)
196 ACE_NAMESPACE_INLINE_FUNCTION
197 int isatty (ACE_HANDLE handle);
198 #endif /* ACE_WIN32 */
200 ACE_NAMESPACE_INLINE_FUNCTION
201 ACE_OFF_T lseek (ACE_HANDLE handle,
202 ACE_OFF_T offset,
203 int whence);
205 #if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
206 ACE_NAMESPACE_INLINE_FUNCTION
207 ACE_LOFF_T llseek (ACE_HANDLE handle,
208 ACE_LOFF_T offset,
209 int whence);
210 #endif /* ACE_HAS_LLSEEK */
212 /// Get the number of CPUs configured in the machine.
213 extern ACE_Export
214 long num_processors ();
216 /// Get the number of CPUs currently online.
217 extern ACE_Export
218 long num_processors_online ();
220 ACE_NAMESPACE_INLINE_FUNCTION
221 int pipe (ACE_HANDLE handles[]);
223 extern ACE_Export
224 ssize_t pread (ACE_HANDLE handle,
225 void *buf,
226 size_t nbyte,
227 ACE_OFF_T offset);
229 extern ACE_Export
230 ssize_t pwrite (ACE_HANDLE handle,
231 const void *buf,
232 size_t nbyte,
233 ACE_OFF_T offset);
235 ACE_NAMESPACE_INLINE_FUNCTION
236 ssize_t read (ACE_HANDLE handle,
237 void *buf,
238 size_t len);
240 ACE_NAMESPACE_INLINE_FUNCTION
241 ssize_t read (ACE_HANDLE handle,
242 void *buf,
243 size_t len,
244 ACE_OVERLAPPED *);
247 * Receive @a len bytes into @a buf from @a handle (uses the
248 * <ACE_OS::read> call, which uses the <read> system call on UNIX
249 * and the <ReadFile> call on Win32). If errors occur, -1 is
250 * returned. If EOF occurs, 0 is returned. Whatever data has been
251 * read will be returned to the caller through @a bytes_transferred.
254 extern ACE_Export
255 ssize_t read_n (ACE_HANDLE handle,
256 void *buf,
257 size_t len,
258 size_t *bytes_transferred = 0);
260 ACE_NAMESPACE_INLINE_FUNCTION
261 ssize_t readlink (const char *path,
262 char *buf,
263 size_t bufsiz);
265 ACE_NAMESPACE_INLINE_FUNCTION
266 void *sbrk (intptr_t brk);
268 ACE_NAMESPACE_INLINE_FUNCTION
269 int setgid (gid_t);
271 ACE_NAMESPACE_INLINE_FUNCTION
272 int setegid (gid_t);
274 ACE_NAMESPACE_INLINE_FUNCTION
275 int setpgid (pid_t pid, pid_t pgid);
277 ACE_NAMESPACE_INLINE_FUNCTION
278 int setregid (gid_t rgid, gid_t egid);
280 ACE_NAMESPACE_INLINE_FUNCTION
281 int setreuid (uid_t ruid, uid_t euid);
283 ACE_NAMESPACE_INLINE_FUNCTION
284 pid_t setsid ();
286 ACE_NAMESPACE_INLINE_FUNCTION
287 int setuid (uid_t);
289 ACE_NAMESPACE_INLINE_FUNCTION
290 int seteuid (uid_t);
292 ACE_NAMESPACE_INLINE_FUNCTION
293 int sleep (u_int seconds);
295 ACE_NAMESPACE_INLINE_FUNCTION
296 int sleep (const ACE_Time_Value &tv);
298 // used by ARGV::string_to_argv
299 extern ACE_Export
300 int string_to_argv (ACE_TCHAR *buf,
301 int &argc,
302 ACE_TCHAR **&argv,
303 bool substitute_env_args = true);
305 ACE_NAMESPACE_INLINE_FUNCTION
306 void swab (const void *src, void *dest, ssize_t n);
308 ACE_NAMESPACE_INLINE_FUNCTION
309 long sysconf (int);
311 // not in susv3
312 ACE_NAMESPACE_INLINE_FUNCTION
313 long sysinfo (int cmd,
314 char *buf,
315 long count);
317 ACE_NAMESPACE_INLINE_FUNCTION
318 int truncate (const ACE_TCHAR *filename, ACE_OFF_T length);
320 ACE_NAMESPACE_INLINE_FUNCTION
321 useconds_t ualarm (useconds_t usecs,
322 useconds_t interval = 0);
324 ACE_NAMESPACE_INLINE_FUNCTION
325 useconds_t ualarm (const ACE_Time_Value &tv,
326 const ACE_Time_Value &tv_interval = ACE_Time_Value::zero);
328 ACE_NAMESPACE_INLINE_FUNCTION
329 int unlink (const char *path);
331 #if defined (ACE_HAS_WCHAR)
332 ACE_NAMESPACE_INLINE_FUNCTION
333 int unlink (const wchar_t *path);
334 #endif /* ACE_HAS_WCHAR */
336 ACE_NAMESPACE_INLINE_FUNCTION
337 ssize_t write (ACE_HANDLE handle,
338 const void *buf,
339 size_t nbyte);
341 ACE_NAMESPACE_INLINE_FUNCTION
342 ssize_t write (ACE_HANDLE handle,
343 const void *buf,
344 size_t nbyte,
345 ACE_OVERLAPPED *);
348 * Send @a len bytes from @a buf to @a handle (uses the <ACE_OS::write>
349 * calls, which is uses the <write> system call on UNIX and the
350 * <WriteFile> call on Win32). If errors occur, -1 is returned. If
351 * EOF occurs, 0 is returned. Whatever data has been transmitted
352 * will be returned to the caller through @a bytes_transferred.
354 extern ACE_Export
355 ssize_t write_n (ACE_HANDLE handle,
356 const void *buf,
357 size_t len,
358 size_t *bytes_transferred = 0);
360 } /* namespace ACE_OS */
362 ACE_END_VERSIONED_NAMESPACE_DECL
364 # if defined (ACE_HAS_INLINED_OSCALLS)
365 # if defined (ACE_INLINE)
366 # undef ACE_INLINE
367 # endif /* ACE_INLINE */
368 # define ACE_INLINE inline
369 # include "ace/OS_NS_unistd.inl"
370 # endif /* ACE_HAS_INLINED_OSCALLS */
372 # include /**/ "ace/post.h"
373 #endif /* ACE_OS_NS_UNISTD_H */