3 //=============================================================================
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 //=============================================================================
13 #ifndef ACE_OS_NS_UNISTD_H
14 # define ACE_OS_NS_UNISTD_H
16 # include /**/ "ace/pre.h"
18 # include "ace/config-all.h"
20 # if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include /**/ "ace/ACE_export.h"
25 #include "ace/Time_Value.h"
26 #include "ace/Basic_Types.h"
27 #include "ace/os_include/os_unistd.h"
28 #include "ace/os_include/os_stdio.h"
30 #if defined (ACE_EXPORT_MACRO)
31 # undef ACE_EXPORT_MACRO
33 #define ACE_EXPORT_MACRO ACE_Export
35 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
39 ACE_NAMESPACE_INLINE_FUNCTION
40 int access (const char *path
, int amode
);
42 #if defined (ACE_HAS_WCHAR)
43 ACE_NAMESPACE_INLINE_FUNCTION
44 int access (const wchar_t *path
, int amode
);
45 #endif /* ACE_HAS_WCHAR */
47 ACE_NAMESPACE_INLINE_FUNCTION
48 unsigned int alarm (u_int secs
);
50 ACE_NAMESPACE_INLINE_FUNCTION
51 long allocation_granularity ();
53 /// used by ARGV::argv_to_string() and ACE_OS::fork_exec()
55 int argv_to_string (int argc
,
58 bool substitute_env_args
= true,
59 bool quote_args
= false);
62 int argv_to_string (ACE_TCHAR
**argv
,
64 bool substitute_env_args
= true,
65 bool quote_args
= false);
67 ACE_NAMESPACE_INLINE_FUNCTION
68 int chdir (const char *path
);
70 #if defined (ACE_HAS_WCHAR)
71 ACE_NAMESPACE_INLINE_FUNCTION
72 int chdir (const wchar_t *path
);
73 #endif /* ACE_HAS_WCHAR */
75 ACE_NAMESPACE_INLINE_FUNCTION
76 int rmdir (const char *path
);
78 #if defined (ACE_HAS_WCHAR)
79 ACE_NAMESPACE_INLINE_FUNCTION
80 int rmdir (const wchar_t *path
);
81 #endif /* ACE_HAS_WCHAR */
83 ACE_NAMESPACE_INLINE_FUNCTION
84 int close (ACE_HANDLE handle
);
86 ACE_NAMESPACE_INLINE_FUNCTION
87 ACE_HANDLE
dup (ACE_HANDLE handle
);
89 ACE_NAMESPACE_INLINE_FUNCTION
90 ACE_HANDLE
dup (ACE_HANDLE handle
, pid_t pid
);
92 ACE_NAMESPACE_INLINE_FUNCTION
93 int dup2 (ACE_HANDLE oldfd
,
97 int execl (const char *path
,
98 const char *arg0
, ...);
101 int execle (const char *path
,
102 const char *arg0
, ...);
105 int execlp (const char *file
,
106 const char *arg0
, ...);
108 ACE_NAMESPACE_INLINE_FUNCTION
109 int execv (const char *path
,
112 ACE_NAMESPACE_INLINE_FUNCTION
113 int execve (const char *path
,
117 ACE_NAMESPACE_INLINE_FUNCTION
118 int execvp (const char *file
,
122 /// Forks and exec's a process in a manner that works Windows.
123 /// argv[0] must be the full path name to the executable.
124 ACE_NAMESPACE_INLINE_FUNCTION
129 pid_t
fork (const ACE_TCHAR
*program_name
);
132 pid_t
fork_exec (ACE_TCHAR
*argv
[]);
135 ACE_NAMESPACE_INLINE_FUNCTION
136 int fsync (ACE_HANDLE handle
);
138 ACE_NAMESPACE_INLINE_FUNCTION
139 int ftruncate (ACE_HANDLE handle
, ACE_OFF_T offset
);
141 ACE_NAMESPACE_INLINE_FUNCTION
142 char *getcwd (char *, size_t);
144 #if defined (ACE_HAS_WCHAR)
145 ACE_NAMESPACE_INLINE_FUNCTION
146 wchar_t *getcwd (wchar_t *, size_t);
147 #endif /* ACE_HAS_WCHAR */
149 ACE_NAMESPACE_INLINE_FUNCTION
152 ACE_NAMESPACE_INLINE_FUNCTION
155 ACE_NAMESPACE_INLINE_FUNCTION
156 int getopt (int argc
,
158 const char *optstring
);
160 ACE_NAMESPACE_INLINE_FUNCTION
163 ACE_NAMESPACE_INLINE_FUNCTION
164 pid_t
getpgid (pid_t pid
);
166 ACE_NAMESPACE_INLINE_FUNCTION
169 ACE_NAMESPACE_INLINE_FUNCTION
172 ACE_NAMESPACE_INLINE_FUNCTION
175 ACE_NAMESPACE_INLINE_FUNCTION
178 // should call gethostname()
179 ACE_NAMESPACE_INLINE_FUNCTION
180 int hostname (char name
[],
183 #if defined (ACE_HAS_WCHAR)
184 ACE_NAMESPACE_INLINE_FUNCTION
185 int hostname (wchar_t name
[],
187 #endif /* ACE_HAS_WCHAR */
189 ACE_NAMESPACE_INLINE_FUNCTION
190 int isatty (int handle
);
192 #if defined (ACE_WIN32)
193 ACE_NAMESPACE_INLINE_FUNCTION
194 int isatty (ACE_HANDLE handle
);
195 #endif /* ACE_WIN32 */
197 ACE_NAMESPACE_INLINE_FUNCTION
198 ACE_OFF_T
lseek (ACE_HANDLE handle
,
202 #if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
203 ACE_NAMESPACE_INLINE_FUNCTION
204 ACE_LOFF_T
llseek (ACE_HANDLE handle
,
207 #endif /* ACE_HAS_LLSEEK */
209 /// Get the number of CPUs configured in the machine.
211 long num_processors ();
213 /// Get the number of CPUs currently online.
215 long num_processors_online ();
217 ACE_NAMESPACE_INLINE_FUNCTION
218 int pipe (ACE_HANDLE handles
[]);
221 ssize_t
pread (ACE_HANDLE handle
,
227 ssize_t
pwrite (ACE_HANDLE handle
,
232 ACE_NAMESPACE_INLINE_FUNCTION
233 ssize_t
read (ACE_HANDLE handle
,
237 ACE_NAMESPACE_INLINE_FUNCTION
238 ssize_t
read (ACE_HANDLE handle
,
244 * Receive @a len bytes into @a buf from @a handle (uses the
245 * <ACE_OS::read> call, which uses the <read> system call on UNIX
246 * and the <ReadFile> call on Win32). If errors occur, -1 is
247 * returned. If EOF occurs, 0 is returned. Whatever data has been
248 * read will be returned to the caller through @a bytes_transferred.
252 ssize_t
read_n (ACE_HANDLE handle
,
255 size_t *bytes_transferred
= 0);
257 ACE_NAMESPACE_INLINE_FUNCTION
258 ssize_t
readlink (const char *path
,
262 ACE_NAMESPACE_INLINE_FUNCTION
263 void *sbrk (intptr_t brk
);
265 ACE_NAMESPACE_INLINE_FUNCTION
268 ACE_NAMESPACE_INLINE_FUNCTION
271 ACE_NAMESPACE_INLINE_FUNCTION
272 int setpgid (pid_t pid
, pid_t pgid
);
274 ACE_NAMESPACE_INLINE_FUNCTION
275 int setregid (gid_t rgid
, gid_t egid
);
277 ACE_NAMESPACE_INLINE_FUNCTION
278 int setreuid (uid_t ruid
, uid_t euid
);
280 ACE_NAMESPACE_INLINE_FUNCTION
283 ACE_NAMESPACE_INLINE_FUNCTION
286 ACE_NAMESPACE_INLINE_FUNCTION
289 ACE_NAMESPACE_INLINE_FUNCTION
290 int sleep (u_int seconds
);
292 ACE_NAMESPACE_INLINE_FUNCTION
293 int sleep (const ACE_Time_Value
&tv
);
295 // used by ARGV::string_to_argv
297 int string_to_argv (ACE_TCHAR
*buf
,
300 bool substitute_env_args
= true);
302 ACE_NAMESPACE_INLINE_FUNCTION
303 void swab (const void *src
, void *dest
, ssize_t n
);
305 ACE_NAMESPACE_INLINE_FUNCTION
309 ACE_NAMESPACE_INLINE_FUNCTION
310 long sysinfo (int cmd
,
314 ACE_NAMESPACE_INLINE_FUNCTION
315 int truncate (const ACE_TCHAR
*filename
, ACE_OFF_T length
);
317 ACE_NAMESPACE_INLINE_FUNCTION
318 useconds_t
ualarm (useconds_t usecs
,
319 useconds_t interval
= 0);
321 ACE_NAMESPACE_INLINE_FUNCTION
322 useconds_t
ualarm (const ACE_Time_Value
&tv
,
323 const ACE_Time_Value
&tv_interval
= ACE_Time_Value::zero
);
325 ACE_NAMESPACE_INLINE_FUNCTION
326 int unlink (const char *path
);
328 #if defined (ACE_HAS_WCHAR)
329 ACE_NAMESPACE_INLINE_FUNCTION
330 int unlink (const wchar_t *path
);
331 #endif /* ACE_HAS_WCHAR */
333 ACE_NAMESPACE_INLINE_FUNCTION
334 ssize_t
write (ACE_HANDLE handle
,
338 ACE_NAMESPACE_INLINE_FUNCTION
339 ssize_t
write (ACE_HANDLE handle
,
345 * Send @a len bytes from @a buf to @a handle (uses the <ACE_OS::write>
346 * calls, which is uses the <write> system call on UNIX and the
347 * <WriteFile> call on Win32). If errors occur, -1 is returned. If
348 * EOF occurs, 0 is returned. Whatever data has been transmitted
349 * will be returned to the caller through @a bytes_transferred.
352 ssize_t
write_n (ACE_HANDLE handle
,
355 size_t *bytes_transferred
= 0);
356 } /* namespace ACE_OS */
358 ACE_END_VERSIONED_NAMESPACE_DECL
360 # if defined (ACE_HAS_INLINED_OSCALLS)
361 # if defined (ACE_INLINE)
363 # endif /* ACE_INLINE */
364 # define ACE_INLINE inline
365 # include "ace/OS_NS_unistd.inl"
366 # endif /* ACE_HAS_INLINED_OSCALLS */
368 # include /**/ "ace/post.h"
369 #endif /* ACE_OS_NS_UNISTD_H */