#

include(`emuniv.h')

/*
 *      SCCS File Type - Emulator Source File
 *
 *      What identification string
 */
static char *_S_K18     "@(#)EM_K18.c	3.2";

	/****************************************************************
	 *
	 *      K_receive
	 *
	 */

/*
 *      K_receive (
 *          1  timeOut, : cardinal         : int   (*timeout in clock ticks*)
 *          2  n_pil,   : pseudo_int_levels:struct (* new level            *)
 *          3  &msg     : ipc_block        :struct (* returned message     *)
 *                )
 */

# ifdef EMULATOR
extern t_FProcTab_index ownPindex;
extern Fstruct          F;
# endif

K_receive (PtimeOut, Pn_pil, PmsgP)
	cardinal                PtimeOut;
	pseudo_int_levels       Pn_pil;
	ipc_block               *PmsgP;
{
	K_err_num       ex;

	struct          /* Kreceive_param */
	{       cardinal                t_out;          /* const */
		pseudo_int_levels       n_pil;          /* const */
		ipc_block               vmsg;           /* var   */
	} pb;

	pb.t_out = PtimeOut;
	pb.n_pil = Pn_pil;

	ex = EMT18 (&pb);

	st_copy (&pb.vmsg, PmsgP, sizeof (ipc_block));

#       ifdef EMULATOR
	/* Update the recorded pseudo-interrupt level: */
	if (ex == XOK)
		F.P[ownPindex].P_cur_pil = pb.n_pil;
#       endif

	return (ex);
}
