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