Simple coroutine library / objects in plain C Snapshot
stacks.h
Go to the documentation of this file.
00001 #ifndef __STACK_CACHE_H_
00002 #define __STACK_CACHE_H_
00003 
00004 #include <stdint.h>
00005 #include <cutils/dlist.h>
00006 
00007 typedef enum {
00008    STACK_DIR_GROWING_DOWN,
00009    STACK_DIR_GROWING_UP,
00010 }  STACK_DIR;
00011 
00012 /** 
00013  * @defgroup STACKS
00014  * @brief a pool of stacks for a threading package. 
00015  * 
00016  * @{
00017  */
00018 typedef struct tagSTACKS {
00019   uint8_t *mapping;
00020   size_t mapping_length;
00021   int num_stacks;
00022   size_t one_stack_size;
00023   DLIST root;
00024 } STACKS;
00025 
00026 typedef struct tagSTACK_ENTRY {
00027   DLIST_entry entry;
00028   void *stack_start;
00029   STACKS *stacks;
00030 } STACK_ENTRY;
00031 
00032 int   STACKS_init( STACKS *stack, int num_stacks, int pages_per_stack );
00033 int   STACKS_destroy( STACKS *stack );
00034 void *STACKS_get(STACKS *stack, STACK_ENTRY **rentry );
00035 int   STACKS_release(STACK_ENTRY *entry);
00036 
00037 
00038 M_INLINE size_t STACKS_get_stack_size(STACKS *stack) {
00039   return stack->one_stack_size;
00040 }
00041 
00042 /*
00043  * @}
00044  */
00045 
00046 #endif
00047 
00048