/******************************************************************************
 *			  FREXX PROGRAMMING LANGUAGE			      *
 ******************************************************************************
 
 liballoc.h
 
 Stack allocation routine prototypes.
 
 *****************************************************************************/

/************************************************************************
 *                                                                      *
 * fpl.library - A run time library interpreting script langauge.       *
 * Copyright (C) 1992, 1993 FrexxWare                                   *
 * Author: Daniel Stenberg                                              *
 *                                                                      *
 * This program is free software; you can redistribute it and/or modify *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation; either version 2, or (at your option)  *
 * any later version.                                                   *
 *                                                                      *
 * This program is distributed in the hope that it will be useful,      *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with this program; if not, write to the Free Software          *
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.            *
 *                                                                      *
 * Daniel Stenberg                                                      *
 * Birger Jarlsgatan 93b 3tr                                            *
 * 113 56 Stockholm                                                     *
 * Sweden                                                               *
 *                                                                      *
 * FidoNet 2:201/328                                                    *
 *                                                                      *
 ************************************************************************/

/*****************************************************
 *
 * InitStack(...);
 *
 * Initialize a new stack and call Script().
 * Input : a (struct Data *) should be the first input.
 * Returns: nothing, but there's a new stack pointer!
 ******/
long InitStack(...);

/*****************************************************
 *
 * EndStack(char **stackbase, int stacksize);
 *
 * Swaps back to original stack.
 * Input : Pointer to the stack base and max stack size.
 * Returns: nothing, but we're back with the original stack pointer.
 ******/
void __asm EndStack(register __a0 struct Data*, register __d0 long);

/*****************************************************
 *
 * CheckStack(char **stackbase);
 *
 * Check whether to expand stack.
 * Input : struct Data *, stack limit, stack margin (minimum stack free)
 * Returns: NULL if ok, 1=out of mem, 2=Stack full.
 ******/
long __asm CheckStack(register __a3 struct Data *,
		      register __d2 long,
		      register __d3 long);

/******************************************************
 *
 * GetStackSize(struct Data *);
 *
 * Returns the current stack size in D0.
 *
 *******/

long __asm GetStackSize(register __a0 struct Data *);

/******************************************************
 *
 * GetStackUsed(struct Data *);
 *
 * Returns the current stack size used in D0.
 *
 *******/

long __asm GetStackUsed(register __a0 struct Data *);

/******************************************************
 *
 * InterfaceCall();
 *
 * Calls a user function - with the original registers set!
 *
 ******/

long __asm InterfaceCall(register __a1 struct Data *,
		         register __a0 void *, /* function argument */
			 register __a2 long (*)(register __a0 void *));

/******************************************************
 *
 * StoreRegisters();
 *
 * Store all registers as they look now to be read and
 * set each time the interface function is called!
 *
 *******/

void __asm StoreRegisters(register __a0 struct Data *);

/******************************************************
 *
 * The lock and unlock routines.
 *
 * Specify memory address and bit number of the
 * semaphore to use!
 *
 *******/

void __asm Locker(register __a0 long *, register __d0 char);

void __asm Unlocker(register __a0 long *, register __d0 char);
