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...
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)
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
35 #define ACE_EXPORT_MACRO ACE_Export
37 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
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()
58 int argv_to_string (int argc
,
61 bool substitute_env_args
= true,
62 bool quote_args
= false);
65 int argv_to_string (ACE_TCHAR
**argv
,
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
,
100 int execl (const char *path
,
101 const char *arg0
, ...);
104 int execle (const char *path
,
105 const char *arg0
, ...);
108 int execlp (const char *file
,
109 const char *arg0
, ...);
111 ACE_NAMESPACE_INLINE_FUNCTION
112 int execv (const char *path
,
115 ACE_NAMESPACE_INLINE_FUNCTION
116 int execve (const char *path
,
120 ACE_NAMESPACE_INLINE_FUNCTION
121 int execvp (const char *file
,
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
132 pid_t
fork (const ACE_TCHAR
*program_name
);
135 pid_t
fork_exec (ACE_TCHAR
*argv
[]);
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
155 ACE_NAMESPACE_INLINE_FUNCTION
158 ACE_NAMESPACE_INLINE_FUNCTION
159 int getopt (int argc
,
161 const char *optstring
);
163 ACE_NAMESPACE_INLINE_FUNCTION
166 ACE_NAMESPACE_INLINE_FUNCTION
167 pid_t
getpgid (pid_t pid
);
169 ACE_NAMESPACE_INLINE_FUNCTION
172 ACE_NAMESPACE_INLINE_FUNCTION
175 ACE_NAMESPACE_INLINE_FUNCTION
178 ACE_NAMESPACE_INLINE_FUNCTION
181 // should call gethostname()
182 ACE_NAMESPACE_INLINE_FUNCTION
183 int hostname (char name
[],
186 #if defined (ACE_HAS_WCHAR)
187 ACE_NAMESPACE_INLINE_FUNCTION
188 int hostname (wchar_t name
[],
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
,
205 #if defined (ACE_HAS_LLSEEK) || defined (ACE_HAS_LSEEK64)
206 ACE_NAMESPACE_INLINE_FUNCTION
207 ACE_LOFF_T
llseek (ACE_HANDLE handle
,
210 #endif /* ACE_HAS_LLSEEK */
212 /// Get the number of CPUs configured in the machine.
214 long num_processors ();
216 /// Get the number of CPUs currently online.
218 long num_processors_online ();
220 ACE_NAMESPACE_INLINE_FUNCTION
221 int pipe (ACE_HANDLE handles
[]);
224 ssize_t
pread (ACE_HANDLE handle
,
230 ssize_t
pwrite (ACE_HANDLE handle
,
235 ACE_NAMESPACE_INLINE_FUNCTION
236 ssize_t
read (ACE_HANDLE handle
,
240 ACE_NAMESPACE_INLINE_FUNCTION
241 ssize_t
read (ACE_HANDLE handle
,
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.
255 ssize_t
read_n (ACE_HANDLE handle
,
258 size_t *bytes_transferred
= 0);
260 ACE_NAMESPACE_INLINE_FUNCTION
261 ssize_t
readlink (const char *path
,
265 ACE_NAMESPACE_INLINE_FUNCTION
266 void *sbrk (intptr_t brk
);
268 ACE_NAMESPACE_INLINE_FUNCTION
271 ACE_NAMESPACE_INLINE_FUNCTION
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
286 ACE_NAMESPACE_INLINE_FUNCTION
289 ACE_NAMESPACE_INLINE_FUNCTION
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
300 int string_to_argv (ACE_TCHAR
*buf
,
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
312 ACE_NAMESPACE_INLINE_FUNCTION
313 long sysinfo (int cmd
,
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
,
341 ACE_NAMESPACE_INLINE_FUNCTION
342 ssize_t
write (ACE_HANDLE handle
,
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.
355 ssize_t
write_n (ACE_HANDLE handle
,
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)
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 */