////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Xilinx, Inc.  All rights reserved.
//
// Xilinx, Inc.
// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A 
// COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
// ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR 
// STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
// IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE 
// FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.  
// XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO 
// THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO 
// ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE 
// FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE.
// 
// Date   : 2002, November.
// Author : Raj Nagarajan (rajn@xilinx.com)
// Company: Xilinx
// Group  : Emerging Software Technologies
//
// $Id :$
//
//////////////////////////////////////////////////////////////////////////////

/***************************************************************************/
/**
 * @file sema.h 
 *
 * This contains the function decleration for Semephore routines.
 ***************************************************************************/
#ifndef _SEMA_H
#define _SEMA_H

#include <os_config.h>
#include <config_param.h>
#include <sys/queue.h>
#include <sys/ipc.h>

#define IPC_PRIVATE (MAX_SEMA+1)

typedef struct semid_ds semaphore ;

/**
 * Each semaphore is associated with this structure.
 */
struct semid_ds {
	char	 	sempid ;		/**< Semaphore ID */
	char  		count ;			/**< Resource count */
	struct _queue 	wait_q ;		/**< Queue of waiting processes */
} ;
		
union semun {
	int val ;	/**< for SETVAL */
} ;

struct sembuf {
	unsigned short 	sem_num ;	/**< member # in the set. Always 0 */
	short 		sem_op ;	/**< semaphore operation */
	short 		sem_flg ;	/**< IPC_NOWAIT */
} ;



/*
 * Function prototypes defined in sys/sema.c
 */
void sema_heap_init() ;
int sys_semget( int key, int nsems, int flag ) ;
int sys_semctl( int semid, int semnum, int cmd, union semun arg ) ;
int sys_semop( int semid, struct sembuf *semoparray, int nops ) ;

#endif
