/*
 * type definitions needed by fork() and exec().
 */

#ifndef _FORK_H
#define _FORK_H

#ifndef _SETJMP_H
#include <setjmp.h>
#endif
#ifndef _BASEPAGE_H
#include <basepage.h>
#endif

#ifndef _COMPILER_H
#include <compiler.h>
#endif

struct _fork_block
{
    struct _fork_block *next;
    jmp_buf	ctxt;			/* saved context of the fork */
    long	*start_addr;		/* address for saved data */
    long	data_size;		/* size of saved data (in words) */
    BASEPAGE *ppid;			/* parent's basepage */
    BASEPAGE *pid;			/* child's basepage */
    short	return_code;		/* exit value from Pexec */
    long	tmp_stack[64];		/* temporary stack for Pexec */
    long	data[0];		/* saved data goes here */
};

extern struct _fork_block *_forks;

/*
 *  macro to convert a basepage to a pid; should match what's done in
 *  getpid.c
 */

#define BP_TO_PID(x) ((int)(0x7fff & (((unsigned long)(x)) >> 8)))

__EXTERN int _fork __PROTO((char *save_to));
__EXTERN int _wait __PROTO((int  *exit_code));

#endif /* _FORK_H */
