process.mh

来自「开放源码的编译器open watcom 1.6.0版的源代码」· MH 代码 · 共 245 行

MH
245
字号
/*
 *  process.h   Process spawning and related routines
 *
:include crwatqnx.sp
 */
#ifndef _PROCESS_H_INCLUDED
#define _PROCESS_H_INCLUDED
:include readonly.sp
:include cpluspro.sp

#ifndef _COMDEF_H_INCLUDED
 #include <_comdef.h>
#endif

:segment QNX | LINUX
#ifndef __TYPES_H_INCLUDED
 #include <sys/types.h>
#endif
:endsegment
:include wchar_t.sp

/*
 *  POSIX 1003.1 Prototypes
 */
_WCRTLINK extern int execl( const char *__path, const char *__arg0, ... );
_WCRTLINK extern int execle( const char *__path, const char *__arg0, ... );
_WCRTLINK extern int execlp( const char *__file, const char *__arg0, ... );
_WCRTLINK extern int execv( const char *__path, const char *const __argv[] );
_WCRTLINK extern int execve( const char *__path, const char *const __argv[],
                            const char *const __envp[] );
_WCRTLINK extern int execvp( const char *__file, const char *const __argv[] );

:segment QNX | LINUX
:include ext.sp
:endsegment
:segment QNX

/*
 *  Spawn flags passed to qnx_spawn()
 *  These are unique to QNX
 */

#define _SPAWN_DEBUG        0x0001
#define _SPAWN_HOLD         0x0002
#define _SPAWN_BGROUND      0x0004
#define _SPAWN_NEWPGRP      0x0008
#define _SPAWN_TCSETPGRP    0x0010
#define _SPAWN_NOZOMBIE     0x0020
#define _SPAWN_XCACHE       0x0040
#define _SPAWN_SIGCLR       0x0080
#define _SPAWN_SETSID       0x0100
#define _SPAWN_NOHUP        0x0200

struct _proc_spawn;     /* for C++ */

extern pid_t qnx_spawn( int __mode, struct _proc_spawn *__msgbuf, nid_t __node,
                 int __prio, int __sched_algo, int __flags,
                 const char *__path, char **__argv, char **__envp,
                 char *__iov, int __ctfd );

#if defined(__386__)
extern pid_t tfork( char *__stk_addr, unsigned __stk_size, int (*__func)(void*),
                        void *__arg, int __flags );
#endif
:endsegment

/* mode flags for spawnxxx routines */
_WCRTDATA extern int __p_overlay;

#define P_WAIT      0
#define P_NOWAIT    1
#define P_OVERLAY   __p_overlay
#define P_NOWAITO   3

/*
 *  Prototypes for non-POSIX functions
 */

_WCRTLINK extern int execlpe( const char *__file, const char *__arg0, ... );
_WCRTLINK extern int execvpe( const char *__file, const char *const __argv[],
                              const char *const __envp[] );

:segment QNX | LINUX
#if defined(__386__)
:: extra 'register' is used to prevent C++ compiler from entering a parser
:: disambiguation stage (i.e., it has a use, so don't delete it) AFS
_WCRTLINK extern int  _beginthread( register void (*__start_address)(void *),
   void *__stack_bottom, unsigned __stack_size, void *__arglist );
#pragma intrinsic(_beginthread);
_WCRTLINK extern void _endthread( void );
:elsesegment
#if defined(__386__) || defined(__AXP__) || defined(__PPC__)
#if defined(__NT__)
_WCRTLINK extern unsigned long _beginthread(
                register void (*__start_address)(void *),
                unsigned __stack_size, void *__arglist );
_WCRTLINK extern unsigned long _beginthreadex( void *__security,
                unsigned __stack_size,
                register unsigned (__stdcall *__start_address)(void *),
                void *__arglist, unsigned __initflag, unsigned *__thrdaddr );
#pragma intrinsic(_beginthread,_beginthreadex);
_WCRTLINK extern void _endthreadex( unsigned __retval );
_WCRTLINK extern unsigned long __threadhandle( void );
#else
_WCRTLINK extern int _beginthread( register void (*__start_address)(void *),
   void *__stack_bottom, unsigned __stack_size, void *__arglist );
#pragma intrinsic(_beginthread);
#endif
_WCRTLINK extern void _endthread( void );
#else
_WCRTLINK extern int _WCFAR  _beginthread(
    register void (_WCFAR *__start_address)(void _WCFAR *),
    void _WCFAR *__stack_bottom, unsigned __stack_size, void _WCFAR *__arglist );
#pragma intrinsic(_beginthread);
_WCRTLINK extern void _WCFAR _endthread( void );
#ifndef __SW_ZU
  _WCRTLINK void _WCFAR *__chkstack( void _WCFAR * );
  #define _beginthread( __sa, __sb, __ss, __al ) \
          _beginthread( __sa, __chkstack(__sb), __ss, __al )
#endif
:endsegment
#endif
:segment !QNX

/* values for __action_code used with cwait() */

#define WAIT_CHILD 0
#define WAIT_GRANDCHILD 1

_WCRTLINK extern int   cwait( int *__status, int __process_id,
                             int __action_code );
_WCRTLINK extern int   _cwait( int *__status, int __process_id,
                             int __action_code );
:endsegment

:: These functions from the standard library need to be in namspace std
:: in C++ to avoid conflicts on using declarations if standard headers
:: are also included.
#ifdef __cplusplus
namespace std {
#endif
_WCRTLINK extern void  abort( void );
_WCRTLINK extern void  exit( int __status );
_WCRTLINK extern char  *getenv( const char *__name );
_WCRTLINK extern int   system( const char *__cmd );
#ifdef __cplusplus
}
using std::abort;
using std::exit;
using std::getenv;
using std::system;
#endif

_WCRTLINK extern void  _exit( int __status );

:segment QNX | LINUX
#if !(defined(SYSV) || defined(BSD) || defined(XENIX) || defined(_UNIX_H_INCLUDED))
:endsegment
_WCRTLINK extern char  *getcmd( char *__buffer );
_WCRTLINK extern int   _bgetcmd( char *__buffer, int __len );
_WCRTLINK extern char  *_cmdname( char *__name );
:segment QNX | LINUX
#endif
:endsegment
_WCRTLINK extern int   putenv( const char *__string );
_WCRTLINK extern int   spawnl( int __mode, const char *__path,
                              const char *__arg0, ... );
_WCRTLINK extern int   spawnle( int __mode, const char *__path,
                               const char *__arg0, ... );
_WCRTLINK extern int   spawnlp( int __mode, const char *__path,
                               const char *__arg0, ... );
_WCRTLINK extern int   spawnlpe( int __mode, const char *__path,
                                const char *__arg0, ... );
_WCRTLINK extern int   spawnv( int __mode, const char *__path,
                              const char * const *__argv );
_WCRTLINK extern int   spawnve( int __mode, const char *__path,
                               const char * const *__argv,
                               const char * const *__envp );
_WCRTLINK extern int   spawnvp( int __mode, const char *__path,
                               const char * const *__argv );
_WCRTLINK extern int   spawnvpe( int __mode, const char *__path,
                                const char * const *__argv,
                                const char * const *__envp );

_WCRTLINK extern wchar_t *_wgetenv( const wchar_t *__name );
_WCRTLINK extern int    _wsetenv( const wchar_t *__name,
                                      const wchar_t *__newvalue,
                                      int __overwrite );
_WCRTLINK extern int    _wputenv( const wchar_t *__env_string );

_WCRTLINK extern int    _wexecl( const wchar_t *__path, const wchar_t *__arg0, ... );
_WCRTLINK extern int    _wexecle( const wchar_t *__path, const wchar_t *__arg0, ... );
_WCRTLINK extern int    _wexeclp( const wchar_t *__file, const wchar_t *__arg0, ... );
_WCRTLINK extern int    _wexecv( const wchar_t *__path, const wchar_t *const __argv[] );
_WCRTLINK extern int    _wexecve( const wchar_t *__path, const wchar_t *const __argv[],
                                  const wchar_t *const __envp[] );
_WCRTLINK extern int    _wexecvp( const wchar_t *__file, const wchar_t *const __argv[] );
_WCRTLINK extern int    _wexeclpe( const wchar_t *__file, const wchar_t *__arg0, ... );
_WCRTLINK extern int    _wexecvpe( const wchar_t *__file, const wchar_t *const __argv[],
                                   const wchar_t *const __envp[] );
_WCRTLINK extern int    _wspawnl( int __mode, const wchar_t *__path,
                                  const wchar_t *__arg0, ... );
_WCRTLINK extern int    _wspawnle( int __mode, const wchar_t *__path,
                                   const wchar_t *__arg0, ... );
_WCRTLINK extern int    _wspawnlp( int __mode, const wchar_t *__path,
                                   const wchar_t *__arg0, ... );
_WCRTLINK extern int    _wspawnlpe( int __mode, const wchar_t *__path,
                                    const wchar_t *__arg0, ... );
_WCRTLINK extern int    _wspawnv( int __mode, const wchar_t *__path,
                                  const wchar_t * const *__argv );
_WCRTLINK extern int    _wspawnve( int __mode, const wchar_t *__path,
                                   const wchar_t * const *__argv,
                                   const wchar_t * const *__envp );
_WCRTLINK extern int    _wspawnvp( int __mode, const wchar_t *__path,
                                   const wchar_t * const *__argv );
_WCRTLINK extern int    _wspawnvpe( int __mode, const wchar_t *__path,
                                    const wchar_t * const *__argv,
                                    const wchar_t * const *__envp );
_WCRTLINK extern int    _wsystem( const wchar_t *__cmd );

:segment DOS
#if defined(__NT__)
 // For use when access to the DLL startup is required.
 // this function pointer will be called after the C library startup
 // and before the C++ library startup.
 #if defined(_WINDOWS_)
  extern BOOL (WINAPI   *_pRawDllMain)( HANDLE, DWORD, LPVOID );
 #else
  extern int (__stdcall *_pRawDllMain)( void *, unsigned, void * );
 #endif
#endif
_WCRTLINK extern int    getpid( void );
_WCRTLINK extern int    wait( int *__status );
:elsesegment QNX | LINUX
_WCRTLINK extern pid_t  getpid( void );
_WCRTLINK extern pid_t  wait( int *__status );
:endsegment

:segment QNX | LINUX
#endif
:endsegment

:include cplusepi.sp
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?