webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
user_uma.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2009-2010 Brad Penoff
3  * Copyright (c) 2009-2010 Humaira Kamal
4  * Copyright (c) 2011-2012 Irene Ruengeler
5  * Copyright (c) 2011-2012 Michael Tuexen
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 #ifndef _USER_UMA_H_
32 #define _USER_UMA_H_
33 
34 #define UMA_ZFLAG_FULL 0x40000000 /* Reached uz_maxpages */
35 #define UMA_ALIGN_PTR (sizeof(void *) - 1) /* Alignment fit for ptr */
36 
37 /* __Userspace__ All these definitions will change for
38 userspace Universal Memory Allocator (UMA). These are included
39 for reference purposes and to avoid compile errors for the time being.
40 */
41 typedef int (*uma_ctor)(void *mem, int size, void *arg, int flags);
42 typedef void (*uma_dtor)(void *mem, int size, void *arg);
43 typedef int (*uma_init)(void *mem, int size, int flags);
44 typedef void (*uma_fini)(void *mem, int size);
45 typedef struct uma_zone * uma_zone_t;
46 typedef struct uma_keg * uma_keg_t;
47 
48 struct uma_cache {
49  int stub; /* TODO __Userspace__ */
50 };
51 
52 struct uma_keg {
53  int stub; /* TODO __Userspace__ */
54 };
55 
56 struct uma_zone {
57  char *uz_name; /* Text name of the zone */
58  struct mtx *uz_lock; /* Lock for the zone (keg's lock) */
59  uma_keg_t uz_keg; /* Our underlying Keg */
60 
61  LIST_ENTRY(uma_zone) uz_link; /* List of all zones in keg */
62  LIST_HEAD(,uma_bucket) uz_full_bucket; /* full buckets */
63  LIST_HEAD(,uma_bucket) uz_free_bucket; /* Buckets for frees */
64 
65  uma_ctor uz_ctor; /* Constructor for each allocation */
66  uma_dtor uz_dtor; /* Destructor */
67  uma_init uz_init; /* Initializer for each item */
68  uma_fini uz_fini; /* Discards memory */
69 
70  u_int64_t uz_allocs; /* Total number of allocations */
71  u_int64_t uz_frees; /* Total number of frees */
72  u_int64_t uz_fails; /* Total number of alloc failures */
73  uint16_t uz_fills; /* Outstanding bucket fills */
74  uint16_t uz_count; /* Highest value ub_ptr can have */
75 
76  /*
77  * This HAS to be the last item because we adjust the zone size
78  * based on NCPU and then allocate the space for the zones.
79  */
80  struct uma_cache uz_cpu[1]; /* Per cpu caches */
81 };
82 
83 /* Prototype */
84 uma_zone_t
85 uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
86  uma_init uminit, uma_fini fini, int align, u_int32_t flags);
87 
88 
89 #define uma_zone_set_max(zone, number) /* stub TODO __Userspace__ */
90 
91 uma_zone_t
92 uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor,
93  uma_init uminit, uma_fini fini, int align, u_int32_t flags)
94 {
95  return NULL; /* stub TODO __Userspace__. Also place implementation in a separate .c file */
96 
97 }
98 #endif
#define size
Definition: float-mm.c:27
EGLStreamKHR EGLint EGLint EGLint size
Definition: eglext.h:984
#define LIST_HEAD(name, type)
Definition: user_queue.h:342
uint16_t uz_count
Definition: user_uma.h:74
uma_zone_t uma_zcreate(char *name, size_t size, uma_ctor ctor, uma_dtor dtor, uma_init uminit, uma_fini fini, int align, u_int32_t flags)
Definition: user_uma.h:92
uint16_t uz_fills
Definition: user_uma.h:73
struct uma_zone * uma_zone_t
Definition: user_uma.h:45
uma_ctor uz_ctor
Definition: user_uma.h:65
Definition: user_uma.h:56
EGLSyncKHR EGLint flags
Definition: eglext.h:415
void(* uma_fini)(void *mem, int size)
Definition: user_uma.h:44
void
Definition: AVFoundationCFSoftLinking.h:81
int
Definition: runtests.py:53
struct uma_keg * uma_keg_t
Definition: user_uma.h:46
unsigned short uint16_t
Definition: ptypes.h:97
uma_keg_t uz_keg
Definition: user_uma.h:59
EGLImageKHR EGLint * name
Definition: eglext.h:851
int stub
Definition: user_uma.h:53
u_int64_t uz_allocs
Definition: user_uma.h:70
char * uz_name
Definition: user_uma.h:57
uma_fini uz_fini
Definition: user_uma.h:68
uma_init uz_init
Definition: user_uma.h:67
void(* uma_dtor)(void *mem, int size, void *arg)
Definition: user_uma.h:42
int(* uma_ctor)(void *mem, int size, void *arg, int flags)
Definition: user_uma.h:41
#define NULL
Definition: common_types.h:41
uma_dtor uz_dtor
Definition: user_uma.h:66
Definition: sctp_os_userspace.h:427
int stub
Definition: user_uma.h:49
Definition: user_uma.h:48
u_int64_t uz_frees
Definition: user_uma.h:71
Definition: user_uma.h:52
u_int64_t uz_fails
Definition: user_uma.h:72
Definition: bwe_rtp.cc:26
#define LIST_ENTRY(type)
Definition: user_queue.h:350
int(* uma_init)(void *mem, int size, int flags)
Definition: user_uma.h:43
struct mtx * uz_lock
Definition: user_uma.h:58