Subversion Repositories Kolibri OS

Rev

Rev 886 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. typedef struct {
  3.         link_t link;
  4.   count_t busy;        /**< Count of full slots in magazine */
  5.   count_t size;        /**< Number of slots in magazine */
  6.   void *objs[];        /**< Slots in magazine */
  7. } slab_magazine_t;
  8.  
  9. typedef struct {
  10.         slab_magazine_t *current;
  11.         slab_magazine_t *last;
  12.         SPINLOCK_DECLARE(lock);
  13. } slab_mag_cache_t;
  14.  
  15. typedef struct {
  16.  
  17.         link_t link;
  18.  
  19.         /* Configuration */
  20.         /** Size of slab position - align_up(sizeof(obj)) */
  21.         size_t size;
  22.  
  23. //  int (*constructor)(void *obj, int kmflag);
  24. //  int (*destructor)(void *obj);
  25.  
  26.         /** Flags changing behaviour of cache */
  27.         int flags;
  28.  
  29.         /* Computed values */
  30.   u32_t order;                /**< Order of frames to be allocated */
  31.   unsigned int objects;        /**< Number of objects that fit in */
  32.  
  33.         /* Statistics */
  34.         atomic_t allocated_slabs;
  35.         atomic_t allocated_objs;
  36.         atomic_t cached_objs;
  37.         /** How many magazines in magazines list */
  38.         atomic_t magazine_counter;
  39.  
  40.         /* Slabs */
  41.   link_t full_slabs;           /**< List of full slabs */
  42.   link_t partial_slabs;        /**< List of partial slabs */
  43.         SPINLOCK_DECLARE(slablock);
  44.         /* Magazines  */
  45.   link_t magazines;            /**< List o full magazines */
  46.         SPINLOCK_DECLARE(maglock);
  47.  
  48.         /** CPU cache */
  49.         slab_mag_cache_t *mag_cache;
  50. } slab_cache_t;
  51.  
  52. typedef struct {
  53.   link_t link;                 /**< List of full/partial slabs. */
  54.   slab_cache_t *cache;         /**< Pointer to parent cache. */
  55.   count_t available;           /**< Count of available items in this slab. */
  56.   void *start;                 /**< Start address of first item. */
  57.   void *nextavail;             /**< The index of next available item. */
  58. } slab_t;
  59.  
  60. #define SLAB_INSIDE_SIZE   (4096 >> 3)
  61.  
  62. /** Maximum wasted space we allow for cache */
  63. #define SLAB_MAX_BADNESS(cache)   (((size_t) PAGE_SIZE << (cache)->order) >> 2)
  64.  
  65.  /** Do not use per-cpu cache */
  66. #define SLAB_CACHE_NOMAGAZINE 0x1
  67. /** Have control structure inside SLAB */
  68. #define SLAB_CACHE_SLINSIDE   0x2
  69. /** We add magazine cache later, if we have this flag */
  70. #define SLAB_CACHE_MAGDEFERRED (0x4 | SLAB_CACHE_NOMAGAZINE)
  71.  
  72.  
  73. slab_cache_t * slab_cache_create(
  74.                                  size_t size,
  75.                                  size_t align,
  76.                                  int (*constructor)(void *obj, int kmflag),
  77.                                  int (*destructor)(void *obj),
  78.          int flags);
  79.  
  80. void* __fastcall slab_alloc(slab_cache_t *cache, int flags);
  81. void  __fastcall slab_free(slab_cache_t *cache, void *obj);
  82.  
  83.  
  84. typedef struct
  85. {
  86.     int left;
  87.     int top;
  88.     int right;
  89.     int bottom;
  90. }rect_t;
  91.  
  92. typedef struct
  93. {
  94.     link_t    link;
  95.     rect_t    wrect;
  96.     rect_t    crect;
  97.     rect_t    hrect;
  98.  
  99.     color_t   clr_workarea;
  100.     color_t   clr_titlebar;
  101.     color_t   clr_frames;
  102.  
  103.     u32_t     style;
  104.     u32_t     state;
  105.  
  106.     int       slot;
  107.  
  108.     link_t    queue;
  109.     u32_t     qflags;
  110.  
  111.     char     *caption;
  112. }window_t;
  113.