Remove _mesa_strcpy in favor of plain strcpy.
[mesa.git] / src / mesa / shader / slang / slang_utility.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.3
4 *
5 * Copyright (C) 2005-2007 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 #ifndef SLANG_UTILITY_H
26 #define SLANG_UTILITY_H
27
28
29 /* Compile-time assertions. If the expression is zero, try to declare an
30 * array of size [-1] to cause compilation error.
31 */
32 #define static_assert(expr) do { int _array[(expr) ? 1 : -1]; (void) _array[0]; } while (0)
33
34
35 #define slang_string_compare(str1, str2) _mesa_strcmp (str1, str2)
36 #define slang_string_copy(dst, src) strcpy (dst, src)
37 #define slang_string_length(str) _mesa_strlen (str)
38
39 char *slang_string_concat (char *, const char *);
40
41 /* slang_string */
42
43 typedef struct
44 {
45 char *data;
46 GLuint length;
47 GLuint capacity;
48 GLboolean fail;
49 } slang_string;
50
51 GLvoid
52 slang_string_init (slang_string *);
53
54 GLvoid
55 slang_string_free (slang_string *);
56
57 GLvoid
58 slang_string_reset (slang_string *);
59
60 GLvoid
61 slang_string_push (slang_string *, const slang_string *);
62
63 GLvoid
64 slang_string_pushc (slang_string *, const char);
65
66 GLvoid
67 slang_string_pushs (slang_string *, const char *, GLuint);
68
69 GLvoid
70 slang_string_pushi (slang_string *, GLint);
71
72 const char *
73 slang_string_cstr (slang_string *);
74
75 /* slang_atom */
76
77 typedef GLvoid *slang_atom;
78
79 #define SLANG_ATOM_NULL ((slang_atom) 0)
80
81 typedef struct slang_atom_entry_
82 {
83 char *id;
84 struct slang_atom_entry_ *next;
85 } slang_atom_entry;
86
87 #define SLANG_ATOM_POOL_SIZE 1023
88
89 typedef struct slang_atom_pool_
90 {
91 slang_atom_entry *entries[SLANG_ATOM_POOL_SIZE];
92 } slang_atom_pool;
93
94 GLvoid slang_atom_pool_construct (slang_atom_pool *);
95 GLvoid slang_atom_pool_destruct (slang_atom_pool *);
96 slang_atom slang_atom_pool_atom (slang_atom_pool *, const char *);
97 const char *slang_atom_pool_id (slang_atom_pool *, slang_atom);
98
99
100 #endif