semaphor.h
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:5k
- /*
- * semaphor.h
- *
- * Copyright (C) SGS-THOMSON Microelectronics Ltd. 1997
- *
- * Semaphore handling.
- */
- #ifndef __os20_semaphor_h
- #define __os20_semaphor_h
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct semaphore_class_s;
- #ifndef __descriptor_t
- #define __descriptor_t
- typedef int* descriptor_t;
- #endif
- #ifndef __clock_t
- #define __clock_t
- typedef unsigned int clock_t;
- #endif
- #include "task.h"
- typedef struct semaphore_s
- {
- const struct semaphore_class_s *semaphore_class; /* class of sempahore */
- struct semaphore_s* semaphore_next; /* next semaphore_t */
- int semaphore_count; /* value of semaphore */
- descriptor_t semaphore_front; /* front of queue of */
- descriptor_t semaphore_back; /* back of queue */
- tdesc_t* semaphore_owner; /* semaphore owner */
- } semaphore_t;
- #ifdef __CORE__
- #pragma ST_translate (semaphore_init_fifo, "semaphore_init_fifo%os")
- #pragma ST_translate (semaphore_create_fifo, "semaphore_create_fifo%os")
- #pragma ST_translate (semaphore_init_priority, "semaphore_init_priority%os")
- #pragma ST_translate (semaphore_create_priority, "semaphore_create_priority%os")
- #pragma ST_translate (semaphore_init_fifo_timeout, "semaphore_init_fifo_timeout%os")
- #pragma ST_translate (semaphore_create_fifo_timeout, "semaphore_create_fifo_timeout%os")
- #pragma ST_translate (semaphore_init_priority_timeout, "semaphore_init_priority_timeout%os")
- #pragma ST_translate (semaphore_create_priority_timeout, "semaphore_create_priority_timeout%os")
- #pragma ST_translate (semaphore_init_binary, "semaphore_init_binary%os")
- #pragma ST_translate (semaphore_create_binary, "semaphore_create_binary%os")
- #pragma ST_translate (semaphore_init_fifo_immortal, "semaphore_init_fifo_immortal%os")
- #pragma ST_translate (semaphore_wait, "semaphore_wait%os")
- #pragma ST_translate (semaphore_signal, "semaphore_signal%os")
- #pragma ST_translate (semaphore_delete, "semaphore_delete%os")
- #pragma ST_translate (semaphore_value, "semaphore_value%os")
- #pragma ST_translate (semaphore_wait_timeout, "semaphore_wait_timeout%os")
- #pragma ST_translate (semaphore_list_head, "semaphore_list_head%os")
- #pragma ST_translate (semaphore_list_next, "semaphore_list_next%os")
- #else
- #pragma IMS_translate (semaphore_init_fifo, "semaphore_init_fifo%os")
- #pragma IMS_translate (semaphore_create_fifo, "semaphore_create_fifo%os")
- #pragma IMS_translate (semaphore_init_priority, "semaphore_init_priority%os")
- #pragma IMS_translate (semaphore_create_priority, "semaphore_create_priority%os")
- #pragma IMS_translate (semaphore_init_fifo_timeout, "semaphore_init_fifo_timeout%os")
- #pragma IMS_translate (semaphore_create_fifo_timeout, "semaphore_create_fifo_timeout%os")
- #pragma IMS_translate (semaphore_init_priority_timeout, "semaphore_init_priority_timeout%os")
- #pragma IMS_translate (semaphore_create_priority_timeout, "semaphore_create_priority_timeout%os")
- #pragma IMS_translate (semaphore_init_binary, "semaphore_init_binary%os")
- #pragma IMS_translate (semaphore_create_binary, "semaphore_create_binary%os")
- #pragma IMS_translate (semaphore_init_fifo_immortal, "semaphore_init_fifo_immortal%os")
- #pragma IMS_translate (semaphore_wait, "semaphore_wait%os")
- #pragma IMS_translate (semaphore_signal, "semaphore_signal%os")
- #pragma IMS_translate (semaphore_delete, "semaphore_delete%os")
- #pragma IMS_translate (semaphore_value, "semaphore_value%os")
- #pragma IMS_translate (semaphore_wait_timeout, "semaphore_wait_timeout%os")
- #pragma IMS_translate (semaphore_list_head, "semaphore_list_head%os")
- #pragma IMS_translate (semaphore_list_next, "semaphore_list_next%os")
- #endif
- void semaphore_init_fifo (semaphore_t* Semaphore, int Count);
- semaphore_t* semaphore_create_fifo (int Count);
- void semaphore_init_priority (semaphore_t* Semaphore, int Count);
- semaphore_t* semaphore_create_priority (int Count);
- void semaphore_init_fifo_timeout (semaphore_t* Semaphore, int Count);
- semaphore_t* semaphore_create_fifo_timeout (int Count);
- void semaphore_init_priority_timeout (semaphore_t* Semaphore, int Count);
- semaphore_t* semaphore_create_priority_timeout (int Count);
- void semaphore_init_binary (semaphore_t* Semaphore);
- semaphore_t* semaphore_create_binary (void);
- void semaphore_init_fifo_immortal(semaphore_t* Semaphore, int Count);
- int semaphore_wait (semaphore_t* Semaphore);
- void semaphore_signal (semaphore_t* Semaphore);
- void semaphore_delete (semaphore_t* Semaphore);
- int semaphore_value (semaphore_t* Semaphore);
- int semaphore_wait_timeout (semaphore_t* Semaphore, const clock_t* timeout);
- semaphore_t* semaphore_list_head(void);
- semaphore_t* semaphore_list_next(semaphore_t*);
- #ifdef __cplusplus
- }
- #endif
- #endif /* __os20_semaphor_h */