Signal waiting threads, problem noticed by Christian Kellner.
[glib.git] / glib / gslice.h
blob93b545a7c55f49e32348c330e6a50cbf2f76ffa2
1 /* GLIB sliced memory - fast threaded memory chunk allocator
2 * Copyright (C) 2005 Tim Janik
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
19 #ifndef __G_SLICE_H__
20 #define __G_SLICE_H__
22 #ifndef __G_MEM_H__
23 #error Include <glib.h> instead of <gslice.h>
24 #endif
26 #include <glib/gtypes.h>
28 G_BEGIN_DECLS
30 /* slices - fast allocation/release of small memory blocks
32 gpointer g_slice_alloc (gsize block_size) G_GNUC_MALLOC;
33 gpointer g_slice_alloc0 (gsize block_size) G_GNUC_MALLOC;
34 void g_slice_free1 (gsize block_size,
35 gpointer mem_block);
36 void g_slice_free_chain_with_offset (gsize block_size,
37 gpointer mem_chain,
38 gsize next_offset);
39 #define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type)))
40 #define g_slice_new0(type) ((type*) g_slice_alloc0 (sizeof (type)))
41 /* g_slice_free (MemoryBlockType,
42 * MemoryBlockType *mem_block);
43 * g_slice_free_chain (MemoryBlockType,
44 * MemoryBlockType *first_chain_block,
45 * memory_block_next_field);
46 * pseudo prototypes for the macro
47 * definitions following below.
50 /* we go through extra hoops to ensure type safety */
51 #define g_slice_free(type, mem) do { \
52 if (1) g_slice_free1 (sizeof (type), (mem)); \
53 else (void) ((type*) 0 == (mem)); \
54 } while (0)
55 #define g_slice_free_chain(type, mem_chain, next) do { \
56 if (1) g_slice_free_chain_with_offset (sizeof (type), \
57 (mem_chain), G_STRUCT_OFFSET (type, next)); \
58 else (void) ((type*) 0 == (mem_chain)); \
59 } while (0)
62 /* --- internal debugging API --- */
63 typedef enum {
64 G_SLICE_CONFIG_ALWAYS_MALLOC = 1,
65 G_SLICE_CONFIG_BYPASS_MAGAZINES,
66 G_SLICE_CONFIG_WORKING_SET_MSECS,
67 G_SLICE_CONFIG_COLOR_INCREMENT,
68 G_SLICE_CONFIG_CHUNK_SIZES,
69 G_SLICE_CONFIG_CONTENTION_COUNTER
70 } GSliceConfig;
71 void g_slice_set_config (GSliceConfig ckey, gint64 value);
72 gint64 g_slice_get_config (GSliceConfig ckey);
73 gint64* g_slice_get_config_state (GSliceConfig ckey, gint64 address, guint *n_values);
75 G_END_DECLS
77 #endif /* __G_SLICE_H__ */