#ifndef  CLIB_EXEC_PROTOS_H
#define  CLIB_EXEC_PROTOS_H

/*******************************************************************
 pOS / Amiga adapt
*******************************************************************/

#ifndef  EXEC_TYPES_H
#include <exec/types.h>
#endif
#ifndef  EXEC_TASKS_H
#include <exec/tasks.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

struct Library *MakeLibrary( APTR funcInit, APTR structInit,
        unsigned long (*libInit)(), unsigned long dataSize,
        unsigned long segList );
void MakeFunctions( APTR target, APTR functionArray,
        unsigned long funcDispBase );
struct Resident *FindResident( UBYTE *name );
APTR InitResident( struct Resident *resident, unsigned long segList );

void Alert( unsigned long alertNum );

void Disable( void );
void Enable( void );
void Forbid( void );
void Permit( void );

APTR Allocate( struct MemHeader *freeList, unsigned long byteSize );
void Deallocate( struct MemHeader *freeList, APTR memoryBlock,
        unsigned long byteSize );
APTR AllocMem( unsigned long byteSize, unsigned long requirements );
APTR AllocAbs( unsigned long byteSize, APTR location );
void FreeMem( APTR memoryBlock, unsigned long byteSize );
ULONG AvailMem( unsigned long requirements );
struct MemList *AllocEntry( struct MemList *entry );
void FreeEntry( struct MemList *entry );

void Insert( struct List *list, struct Node *node, struct Node *pred );
void AddHead( struct List *list, struct Node *node );
void AddTail( struct List *list, struct Node *node );
void Remove( struct Node *node );
struct Node *RemHead( struct List *list );
struct Node *RemTail( struct List *list );
void Enqueue( struct List *list, struct Node *node );
struct Node *FindName( struct List *list, UBYTE *name );

APTR AddTask( struct Task *task, APTR initPC, APTR finalPC );
void RemTask( struct Task *task );
struct Task *FindTask( UBYTE *name );
BYTE SetTaskPri( struct Task *task, long priority );
ULONG SetSignal( unsigned long newSignals, unsigned long signalSet );
ULONG SetExcept( unsigned long newSignals, unsigned long signalSet );
ULONG Wait( unsigned long signalSet );
void Signal( struct Task *task, unsigned long signalSet );
BYTE AllocSignal( long signalNum );
void FreeSignal( long signalNum );

void AddPort( struct MsgPort *port );
void RemPort( struct MsgPort *port );
void PutMsg( struct MsgPort *port, struct Message *message );
struct Message *GetMsg( struct MsgPort *port );
void ReplyMsg( struct Message *message );
struct Message *WaitPort( struct MsgPort *port );
struct MsgPort *FindPort( UBYTE *name );

void AddLibrary( struct Library *library );
void RemLibrary( struct Library *library );
struct Library *OldOpenLibrary( UBYTE *libName );
void CloseLibrary( struct Library *library );
APTR SetFunction( struct Library *library, long funcOffset,
        unsigned long (*newFunction)() );
void SumLibrary( struct Library *library );

void AddDevice( struct Device *device );
void RemDevice( struct Device *device );
BYTE OpenDevice( UBYTE *devName, unsigned long unit,
        struct IORequest *ioRequest, unsigned long flags );
void CloseDevice( struct IORequest *ioRequest );
BYTE DoIO( struct IORequest *ioRequest );
void SendIO( struct IORequest *ioRequest );
struct IORequest *CheckIO( struct IORequest *ioRequest );
BYTE WaitIO( struct IORequest *ioRequest );
void AbortIO( struct IORequest *ioRequest );

void AddResource( APTR resource );
void RemResource( APTR resource );
APTR OpenResource( UBYTE *resName );

ULONG TypeOfMem( APTR address );
VOID Procure( struct SignalSemaphore *sigSem,struct SemaphoreMessage *bidMsg );
void Vacate( struct SignalSemaphore *sigSem,struct SemaphoreMessage *bidMsg );
struct Library *OpenLibrary( UBYTE *libName, unsigned long version );

void InitSemaphore( struct SignalSemaphore *sigSem );
void ObtainSemaphore( struct SignalSemaphore *sigSem );
void ReleaseSemaphore( struct SignalSemaphore *sigSem );
ULONG AttemptSemaphore( struct SignalSemaphore *sigSem );
void ObtainSemaphoreList( struct List *sigSem );
void ReleaseSemaphoreList( struct List *sigSem );
struct SignalSemaphore *FindSemaphore( UBYTE *sigSem );
void AddSemaphore( struct SignalSemaphore *sigSem );
void RemSemaphore( struct SignalSemaphore *sigSem );

void CopyMem( APTR source, APTR dest, unsigned long size );
void CopyMemQuick( APTR source, APTR dest, unsigned long size );

void CacheClearU( void );
void CacheClearE( APTR address, unsigned long length, unsigned long caches );
ULONG CacheControl( unsigned long cacheBits, unsigned long cacheMask );

APTR CreateIORequest( struct MsgPort *port, unsigned long size );
void DeleteIORequest( APTR iorequest );
struct MsgPort *CreateMsgPort( void );
void DeleteMsgPort( struct MsgPort *port );
void ObtainSemaphoreShared( struct SignalSemaphore *sigSem );

APTR AllocVec( unsigned long byteSize, unsigned long requirements );
void FreeVec( APTR memoryBlock );

void ColdReboot( void );
void StackSwap( struct StackSwapStruct *newStack );

void AddMemHandler( struct Interrupt *memhand );
void RemMemHandler( struct Interrupt *memhand );

APTR CreatePool(ULONG requirements,ULONG puddleSize,ULONG threshSize );
void DeletePool( APTR poolHeader );
APTR AllocPooled( APTR poolHeader, unsigned long memSize );
void FreePooled( APTR poolHeader, APTR memory, unsigned long memSize );






#ifdef __IGNORE_NOT_SUPPORTED__

  ULONG AttemptSemaphoreShared( struct SignalSemaphore *sigSem );

  void Debug( unsigned long flags );
  struct Interrupt *SetIntVector( long intNumber, struct Interrupt *interrupt );
  void AddIntServer( long intNumber, struct Interrupt *interrupt );
  void RemIntServer( long intNumber, struct Interrupt *interrupt );
  void Cause( struct Interrupt *interrupt );
  LONG AllocTrap( long trapNum );
  void FreeTrap( long trapNum );
  APTR RawDoFmt(UBYTE *formatString, APTR dataStream, void(*putChProc)(),APTR putChData);
  ULONG GetCC( void );
  ULONG SumKickData( void );
  void AddMemList(ULONG size,ULONG attributes, long pri,APTR base, UBYTE *name );
  void ChildFree( APTR tid );
  void ChildOrphan( APTR tid );
  void ChildStatus( APTR tid );
  void ChildWait( APTR tid );
  APTR CachePreDMA( APTR address, ULONG *length, unsigned long flags );
  void CachePostDMA( APTR address, ULONG *length, unsigned long flags );
  ULONG ObtainQuickVector( APTR interruptCode );

#else  /** __IGNORE_NOT_SUPPORTED__ **/

#define AttemptSemaphoreShared AttemptSemaphoreShared_NOT_SUPPORTED
  ULONG AttemptSemaphoreShared(struct NOT_SUPPORTED*, struct SignalSemaphore *sigSem );

#define Debug Debug_NOT_COMPATIBLE
  void Debug(struct NOT_SUPPORTED*, unsigned long flags );
#define SetIntVector SetIntVector_NOT_SUPPORTED
  struct Interrupt *SetIntVector(struct NOT_SUPPORTED*, long intNumber, struct Interrupt *interrupt );
#define AddIntServer AddIntServer_NOT_SUPPORTED
  void AddIntServer(struct NOT_SUPPORTED*, long intNumber, struct Interrupt *interrupt );
#define RemIntServer RemIntServer_NOT_SUPPORTED
  void RemIntServer(struct NOT_SUPPORTED*, long intNumber, struct Interrupt *interrupt );
#define Cause Cause_NOT_SUPPORTED
  void Cause(struct NOT_SUPPORTED*, struct Interrupt *interrupt );
#define AllocTrap AllocTrap_NOT_COMPATIBLE
  LONG AllocTrap(struct NOT_SUPPORTED*, long trapNum );
#define FreeTrap FreeTrap_NOT_COMPATIBLE
  void FreeTrap(struct NOT_SUPPORTED*, long trapNum );
#define RawDoFmt RawDoFmt_NOT_COMPATIBLE
  APTR RawDoFmt(struct NOT_SUPPORTED*,UBYTE *formatString, APTR dataStream, void(*putChProc)(),APTR putChData);
#define GetCC GetCC_NOT_COMPATIBLE
  ULONG GetCC(struct NOT_SUPPORTED*);
#define SumKickData SumKickData_NOT_COMPATIBLE
  ULONG SumKickData(struct NOT_SUPPORTED*);
#define AddMemList AddMemList_NOT_SUPPORTED
  void AddMemList(struct NOT_SUPPORTED*,ULONG size,ULONG attributes, long pri,APTR base, UBYTE *name );
#define ChildFree ChildFree_NOT_SUPPORTED
  void ChildFree(struct NOT_SUPPORTED*, APTR tid );
#define ChildOrphan ChildOrphan_NOT_SUPPORTED
  void ChildOrphan(struct NOT_SUPPORTED*, APTR tid );
#define ChildStatus ChildStatus_NOT_SUPPORTED
  void ChildStatus(struct NOT_SUPPORTED*, APTR tid );
#define ChildWait ChildWait_NOT_SUPPORTED
  void ChildWait(struct NOT_SUPPORTED*, APTR tid );
#define CachePreDMA CachePreDMA_NOT_SUPPORTED
  APTR CachePreDMA(struct NOT_SUPPORTED*, APTR address, ULONG *length, unsigned long flags );
#define CachePostDMA CachePostDMA_NOT_SUPPORTED
  void CachePostDMA(struct NOT_SUPPORTED*, APTR address, ULONG *length, unsigned long flags );
#define ObtainQuickVector ObtainQuickVector_NOT_COMPATIBLE
  ULONG ObtainQuickVector(struct NOT_SUPPORTED*, APTR interruptCode );

#endif /** __IGNORE_NOT_SUPPORTED__ **/







#ifdef __cplusplus
}
#endif

#endif   /* CLIB_EXEC_PROTOS_H */
