2 * Mesa 3-D graphics library
5 * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #if !defined SLANG_UTILITY_H
26 #define SLANG_UTILITY_H
28 #if defined __cplusplus
32 /* Compile-time assertions. If the expression is zero, try to declare an
33 * array of size [-1] to cause compilation error.
35 #define static_assert(expr) do { int _array[(expr) ? 1 : -1]; (void) _array[0]; } while (0)
37 #define slang_alloc_free(ptr) _mesa_free (ptr)
38 #define slang_alloc_malloc(size) _mesa_malloc (size)
39 #define slang_alloc_realloc(ptr, old_size, size) _mesa_realloc (ptr, old_size, size)
40 #define slang_string_compare(str1, str2) _mesa_strcmp (str1, str2)
41 #define slang_string_copy(dst, src) _mesa_strcpy (dst, src)
42 #define slang_string_duplicate(src) _mesa_strdup (src)
43 #define slang_string_length(str) _mesa_strlen (str)
45 char *slang_string_concat (char *, const char *);
58 slang_string_init (slang_string
*);
61 slang_string_free (slang_string
*);
64 slang_string_reset (slang_string
*);
67 slang_string_push (slang_string
*, const slang_string
*);
70 slang_string_pushc (slang_string
*, const char);
73 slang_string_pushs (slang_string
*, const char *, GLuint
);
76 slang_string_pushi (slang_string
*, GLint
);
79 slang_string_cstr (slang_string
*);
83 typedef GLvoid
*slang_atom
;
85 #define SLANG_ATOM_NULL ((slang_atom) 0)
87 typedef struct slang_atom_entry_
90 struct slang_atom_entry_
*next
;
93 #define SLANG_ATOM_POOL_SIZE 1023
95 typedef struct slang_atom_pool_
97 slang_atom_entry
*entries
[SLANG_ATOM_POOL_SIZE
];
100 GLvoid
slang_atom_pool_construct (slang_atom_pool
*);
101 GLvoid
slang_atom_pool_destruct (slang_atom_pool
*);
102 slang_atom
slang_atom_pool_atom (slang_atom_pool
*, const char *);
103 const char *slang_atom_pool_id (slang_atom_pool
*, slang_atom
);