chmod a-x
[mesa.git] / src / mesa / shader / slang / slang_utility.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.6
4 *
5 * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 */
24
25 #if !defined SLANG_UTILITY_H
26 #define SLANG_UTILITY_H
27
28 #if defined __cplusplus
29 extern "C" {
30 #endif
31
32 /* Compile-time assertions. If the expression is zero, try to declare an
33 * array of size [-1] to cause compilation error.
34 */
35 #define static_assert(expr) do { int _array[(expr) ? 1 : -1]; (void) _array[0]; } while (0)
36
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)
44
45 char *slang_string_concat (char *, const char *);
46
47 /* slang_string */
48
49 typedef struct
50 {
51 char *data;
52 GLuint length;
53 GLuint capacity;
54 GLboolean fail;
55 } slang_string;
56
57 GLvoid
58 slang_string_init (slang_string *);
59
60 GLvoid
61 slang_string_free (slang_string *);
62
63 GLvoid
64 slang_string_reset (slang_string *);
65
66 GLvoid
67 slang_string_push (slang_string *, const slang_string *);
68
69 GLvoid
70 slang_string_pushc (slang_string *, const char);
71
72 GLvoid
73 slang_string_pushs (slang_string *, const char *, GLuint);
74
75 GLvoid
76 slang_string_pushi (slang_string *, GLint);
77
78 const char *
79 slang_string_cstr (slang_string *);
80
81 /* slang_atom */
82
83 typedef GLvoid *slang_atom;
84
85 #define SLANG_ATOM_NULL ((slang_atom) 0)
86
87 typedef struct slang_atom_entry_
88 {
89 char *id;
90 struct slang_atom_entry_ *next;
91 } slang_atom_entry;
92
93 #define SLANG_ATOM_POOL_SIZE 1023
94
95 typedef struct slang_atom_pool_
96 {
97 slang_atom_entry *entries[SLANG_ATOM_POOL_SIZE];
98 } slang_atom_pool;
99
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);
104
105 slang_atom
106 slang_atom_pool_gen(slang_atom_pool * pool, const char *prefix);
107
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif
114