diff options
-rw-r--r-- | src/gallium/Automake.inc | 1 | ||||
-rw-r--r-- | src/gallium/drivers/r300/Makefile.am | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/Makefile.sources | 1 | ||||
-rw-r--r-- | src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c | 2 | ||||
l--------- | src/gallium/drivers/r300/ralloc.c | 1 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri/SConscript | 1 | ||||
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/SConscript | 1 | ||||
-rw-r--r-- | src/gallium/targets/libgl-xlib/SConscript | 1 | ||||
-rw-r--r-- | src/gallium/targets/pipe-loader/Makefile.am | 1 | ||||
-rw-r--r-- | src/glsl/builtin_types.cpp | 7 | ||||
-rw-r--r-- | src/loader/Makefile.am | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/common/SConscript | 1 | ||||
-rw-r--r-- | src/mesa/drivers/osmesa/Makefile.am | 1 | ||||
-rw-r--r-- | src/mesa/drivers/osmesa/SConscript | 1 | ||||
-rw-r--r-- | src/mesa/drivers/x11/SConscript | 1 | ||||
-rw-r--r-- | src/mesa/main/compiler.h | 92 | ||||
-rw-r--r-- | src/mesa/main/macros.h | 4 | ||||
-rw-r--r-- | src/util/Makefile.am | 2 | ||||
-rw-r--r-- | src/util/SConscript | 2 | ||||
-rw-r--r-- | src/util/hash_table.c | 2 | ||||
-rw-r--r-- | src/util/hash_table.h | 4 | ||||
-rw-r--r-- | src/util/macros.h | 128 | ||||
-rw-r--r-- | src/util/ralloc.h | 3 |
23 files changed, 154 insertions, 106 deletions
diff --git a/src/gallium/Automake.inc b/src/gallium/Automake.inc index 73d65a4d10f..22ee166e3ba 100644 --- a/src/gallium/Automake.inc +++ b/src/gallium/Automake.inc @@ -1,5 +1,6 @@ GALLIUM_CFLAGS = \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/gallium/include \ -I$(top_srcdir)/src/gallium/auxiliary \ $(DEFINES) diff --git a/src/gallium/drivers/r300/Makefile.am b/src/gallium/drivers/r300/Makefile.am index 2c5951b8f6d..ae6e8d2e466 100644 --- a/src/gallium/drivers/r300/Makefile.am +++ b/src/gallium/drivers/r300/Makefile.am @@ -4,7 +4,7 @@ include Makefile.sources include $(top_srcdir)/src/gallium/Automake.inc AM_CFLAGS = \ - -I$(top_srcdir)/src/util \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/mesa/program \ -I$(top_srcdir)/src/mesa \ -I$(top_srcdir)/src/glsl \ diff --git a/src/gallium/drivers/r300/Makefile.sources b/src/gallium/drivers/r300/Makefile.sources index 0e9ab52c2b1..f987cf8540f 100644 --- a/src/gallium/drivers/r300/Makefile.sources +++ b/src/gallium/drivers/r300/Makefile.sources @@ -67,5 +67,4 @@ COMPILER_TESTS_SOURCES := \ compiler/tests/unit_test.c HELPER_SOURCES := \ - ralloc.c \ register_allocate.c diff --git a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c index 1970a346d1d..7b02e53a482 100644 --- a/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c +++ b/src/gallium/drivers/r300/compiler/radeon_pair_regalloc.c @@ -33,7 +33,7 @@ #include "main/glheader.h" #include "program/register_allocate.h" #include "util/u_memory.h" -#include "ralloc.h" +#include "util/ralloc.h" #include "r300_fragprog_swizzle.h" #include "radeon_compiler.h" diff --git a/src/gallium/drivers/r300/ralloc.c b/src/gallium/drivers/r300/ralloc.c deleted file mode 120000 index 7ad6def37c5..00000000000 --- a/src/gallium/drivers/r300/ralloc.c +++ /dev/null @@ -1 +0,0 @@ -../../../util/ralloc.c
\ No newline at end of file diff --git a/src/gallium/state_trackers/dri/SConscript b/src/gallium/state_trackers/dri/SConscript index 89b035229bc..159ca80328f 100644 --- a/src/gallium/state_trackers/dri/SConscript +++ b/src/gallium/state_trackers/dri/SConscript @@ -11,6 +11,7 @@ env.PkgUseModules(['DRM']) #env.Append(CPPDEFINES = [('__NOT_HAVE_DRM_H', '1')]) env.Append(CPPPATH = [ + '#/src', '#/src/mapi', '#/src/mesa', '#/src/gallium/state_trackers/dri/common', diff --git a/src/gallium/state_trackers/glx/xlib/SConscript b/src/gallium/state_trackers/glx/xlib/SConscript index 88e81b85582..08329895e87 100644 --- a/src/gallium/state_trackers/glx/xlib/SConscript +++ b/src/gallium/state_trackers/glx/xlib/SConscript @@ -6,6 +6,7 @@ Import('*') env = env.Clone() env.Append(CPPPATH = [ + '#/src', '#/src/mapi', '#/src/mesa', '#/src/mesa/main', diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 22cf1077b19..cc39b17eaf5 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -29,6 +29,7 @@ env.Prepend(LIBS = [ ws_xlib, mesautil, glapi, + mesautil, mesa, glsl, gallium, diff --git a/src/gallium/targets/pipe-loader/Makefile.am b/src/gallium/targets/pipe-loader/Makefile.am index 500dfce1932..a4e0407f5aa 100644 --- a/src/gallium/targets/pipe-loader/Makefile.am +++ b/src/gallium/targets/pipe-loader/Makefile.am @@ -96,6 +96,7 @@ nodist_EXTRA_pipe_r300_la_SOURCES = dummy.cpp pipe_r300_la_LIBADD = \ $(PIPE_LIBS) \ $(top_builddir)/src/gallium/winsys/radeon/drm/libradeonwinsys.la \ + $(top_builddir)/src/util/libmesautil.la \ $(top_builddir)/src/gallium/drivers/r300/libr300-helper.la \ $(top_builddir)/src/gallium/drivers/r300/libr300.la \ $(LIBDRM_LIBS) \ diff --git a/src/glsl/builtin_types.cpp b/src/glsl/builtin_types.cpp index 0a0fa8cd35e..404a8038a43 100644 --- a/src/glsl/builtin_types.cpp +++ b/src/glsl/builtin_types.cpp @@ -36,6 +36,7 @@ #include "glsl_types.h" #include "glsl_parser_extras.h" +#include "util/macros.h" /** * Declarations of type flyweights (glsl_type::_foo_type) and @@ -48,7 +49,7 @@ #define STRUCT_TYPE(NAME) \ const glsl_type glsl_type::_struct_##NAME##_type = \ - glsl_type(NAME##_fields, Elements(NAME##_fields), #NAME); \ + glsl_type(NAME##_fields, ARRAY_SIZE(NAME##_fields), #NAME); \ const glsl_type *const glsl_type::struct_##NAME##_type = \ &glsl_type::_struct_##NAME##_type; @@ -265,7 +266,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) { struct glsl_symbol_table *symbols = state->symbols; - for (unsigned i = 0; i < Elements(builtin_type_versions); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(builtin_type_versions); i++) { const struct builtin_type_versions *const t = &builtin_type_versions[i]; if (state->is_version(t->min_gl, t->min_es)) { add_type(symbols, t->type); @@ -276,7 +277,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state) * they're still present. We've removed them in 1.40+ (OpenGL 3.1+). */ if (!state->es_shader && state->language_version < 140) { - for (unsigned i = 0; i < Elements(deprecated_types); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(deprecated_types); i++) { add_type(symbols, deprecated_types[i]); } } diff --git a/src/loader/Makefile.am b/src/loader/Makefile.am index c02de6f59a4..16b9f8f70c2 100644 --- a/src/loader/Makefile.am +++ b/src/loader/Makefile.am @@ -26,6 +26,7 @@ noinst_LTLIBRARIES = libloader.la libloader_la_CPPFLAGS = \ $(DEFINES) \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ $(VISIBILITY_CFLAGS) \ $(LIBUDEV_CFLAGS) diff --git a/src/mesa/drivers/dri/common/SConscript b/src/mesa/drivers/dri/common/SConscript index d003139bfdb..0bee1b41fc6 100644 --- a/src/mesa/drivers/dri/common/SConscript +++ b/src/mesa/drivers/dri/common/SConscript @@ -10,6 +10,7 @@ drienv.Replace(CPPPATH = [ xmlpool_options.dir.dir, # Dir to generated xmlpool/options.h '#include', '#include/GL/internal', + '#src', '#src/mapi', '#src/gallium/include', '#src/gallium/auxiliary', diff --git a/src/mesa/drivers/osmesa/Makefile.am b/src/mesa/drivers/osmesa/Makefile.am index 41577929434..ff9afb21312 100644 --- a/src/mesa/drivers/osmesa/Makefile.am +++ b/src/mesa/drivers/osmesa/Makefile.am @@ -23,6 +23,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/include \ + -I$(top_srcdir)/src \ -I$(top_srcdir)/src/mapi \ -I$(top_builddir)/src/mapi \ -I$(top_srcdir)/src/mesa/ \ diff --git a/src/mesa/drivers/osmesa/SConscript b/src/mesa/drivers/osmesa/SConscript index fb2d98cadc5..cbff5943fbb 100644 --- a/src/mesa/drivers/osmesa/SConscript +++ b/src/mesa/drivers/osmesa/SConscript @@ -3,6 +3,7 @@ Import('*') env = env.Clone() env.Prepend(CPPPATH = [ + '#src', '#src/mapi', '#src/mesa', Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers diff --git a/src/mesa/drivers/x11/SConscript b/src/mesa/drivers/x11/SConscript index 320cece886c..d29f9874f44 100644 --- a/src/mesa/drivers/x11/SConscript +++ b/src/mesa/drivers/x11/SConscript @@ -3,6 +3,7 @@ Import('*') env = env.Clone() env.Append(CPPPATH = [ + '#/src', '#/src/mapi', '#/src/mesa', '#/src/mesa/main', diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 79d8740e590..ae7d343dd36 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -44,6 +44,8 @@ #include <float.h> #include <stdarg.h> +#include "util/macros.h" + #include "c99_compat.h" /* inline, __func__, etc. */ @@ -130,23 +132,6 @@ extern "C" { #endif -/** - * __builtin_expect macros - */ -#if !defined(__GNUC__) -# define __builtin_expect(x, y) (x) -#endif - -#ifndef likely -# ifdef __GNUC__ -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#endif - /* XXX: Use standard `__func__` instead */ #ifndef __FUNCTION__ # define __FUNCTION__ __func__ @@ -238,65 +223,16 @@ static INLINE GLuint CPU_TO_LE32(GLuint x) #endif -/** - * Static (compile-time) assertion. - * Basically, use COND to dimension an array. If COND is false/zero the - * array size will be -1 and we'll get a compilation error. - */ -#define STATIC_ASSERT(COND) \ - do { \ - (void) sizeof(char [1 - 2*!(COND)]); \ - } while (0) - -/** - * Unreachable macro. Useful for suppressing "control reaches end of non-void - * function" warnings. - */ -#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5 -#define unreachable(str) \ -do { \ - assert(!str); \ - __builtin_unreachable(); \ -} while (0) -#elif (defined(__clang__) && defined(__has_builtin)) -# if __has_builtin(__builtin_unreachable) -# define unreachable(str) \ -do { \ - assert(!str); \ - __builtin_unreachable(); \ -} while (0) -# endif -#endif - -#ifndef unreachable -#define unreachable(str) -#endif - /* * A trick to suppress uninitialized variable warning without generating any * code */ #define uninitialized_var(x) x = x -#if (__GNUC__ >= 3) -#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) -#else -#define PRINTFLIKE(f, a) -#endif - #ifndef NULL #define NULL 0 #endif -/* Used to optionally mark structures with misaligned elements or size as - * packed, to trade off performance for space. - */ -#if (__GNUC__ >= 3) -#define PACKED __attribute__((__packed__)) -#else -#define PACKED -#endif - /** * LONGSTRING macro @@ -433,30 +369,6 @@ do { \ #endif #ifdef __cplusplus -/** - * Macro function that evaluates to true if T is a trivially - * destructible type -- that is, if its (non-virtual) destructor - * performs no action and all member variables and base classes are - * trivially destructible themselves. - */ -# if defined(__GNUC__) -# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))) -# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) -# endif -# elif (defined(__clang__) && defined(__has_feature)) -# if __has_feature(has_trivial_destructor) -# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) -# endif -# endif -# ifndef HAS_TRIVIAL_DESTRUCTOR - /* It's always safe (if inefficient) to assume that a - * destructor is non-trivial. - */ -# define HAS_TRIVIAL_DESTRUCTOR(T) (false) -# endif -#endif - -#ifdef __cplusplus } #endif diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 5228c3a8f28..954df3cc8d8 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -818,7 +818,9 @@ DIFFERENT_SIGNS(GLfloat x, GLfloat y) #define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE) /* Compute the size of an array */ -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#ifndef ARRAY_SIZE +# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif /* Stringify */ #define STRINGIFY(x) #x diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 0f9dcab6a59..a2aeafc703b 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -28,8 +28,6 @@ noinst_LTLIBRARIES = libmesautil.la libmesautil_la_CPPFLAGS = \ $(DEFINES) \ -I$(top_srcdir)/include \ - -I$(top_srcdir)/src/mapi \ - -I$(top_srcdir)/src/mesa \ $(VISIBILITY_CFLAGS) libmesautil_la_SOURCES = $(MESA_UTIL_FILES) diff --git a/src/util/SConscript b/src/util/SConscript index a36340deebf..8afeedaf5e9 100644 --- a/src/util/SConscript +++ b/src/util/SConscript @@ -8,8 +8,6 @@ env = env.Clone() env.Prepend(CPPPATH = [ '#include', - '#src/mapi', - '#src/mesa', '#src/util', ]) diff --git a/src/util/hash_table.c b/src/util/hash_table.c index f98a1a647ea..1b6726c79a9 100644 --- a/src/util/hash_table.c +++ b/src/util/hash_table.c @@ -44,8 +44,8 @@ #include <string.h> #include "hash_table.h" -#include "main/macros.h" #include "ralloc.h" +#include "macros.h" static const uint32_t deleted_key_value; diff --git a/src/util/hash_table.h b/src/util/hash_table.h index 5fa58991e30..9b67f05bec6 100644 --- a/src/util/hash_table.h +++ b/src/util/hash_table.h @@ -28,10 +28,10 @@ #ifndef _HASH_TABLE_H #define _HASH_TABLE_H +#include <stdlib.h> #include <inttypes.h> #include <stdbool.h> - -#include "main/compiler.h" +#include "macros.h" #ifdef __cplusplus extern "C" { diff --git a/src/util/macros.h b/src/util/macros.h new file mode 100644 index 00000000000..ee05e05a4a8 --- /dev/null +++ b/src/util/macros.h @@ -0,0 +1,128 @@ +/* + * Copyright © 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef UTIL_MACROS_H +#define UTIL_MACROS_H + +/* Compute the size of an array */ +#ifndef ARRAY_SIZE +# define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) +#endif + + +/** + * __builtin_expect macros + */ +#if !defined(__GNUC__) +# define __builtin_expect(x, y) (x) +#endif + +#ifndef likely +# ifdef __GNUC__ +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +# else +# define likely(x) (x) +# define unlikely(x) (x) +# endif +#endif + + +/** + * Static (compile-time) assertion. + * Basically, use COND to dimension an array. If COND is false/zero the + * array size will be -1 and we'll get a compilation error. + */ +#define STATIC_ASSERT(COND) \ + do { \ + (void) sizeof(char [1 - 2*!(COND)]); \ + } while (0) + + +/** + * Unreachable macro. Useful for suppressing "control reaches end of non-void + * function" warnings. + */ +#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5 +#define unreachable(str) \ +do { \ + assert(!str); \ + __builtin_unreachable(); \ +} while (0) +#elif (defined(__clang__) && defined(__has_builtin)) +# if __has_builtin(__builtin_unreachable) +# define unreachable(str) \ +do { \ + assert(!str); \ + __builtin_unreachable(); \ +} while (0) +# endif +#endif + +#ifndef unreachable +#define unreachable(str) +#endif + + +#if (__GNUC__ >= 3) +#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a))) +#else +#define PRINTFLIKE(f, a) +#endif + + +/* Used to optionally mark structures with misaligned elements or size as + * packed, to trade off performance for space. + */ +#if (__GNUC__ >= 3) +#define PACKED __attribute__((__packed__)) +#else +#define PACKED +#endif + + +#ifdef __cplusplus +/** + * Macro function that evaluates to true if T is a trivially + * destructible type -- that is, if its (non-virtual) destructor + * performs no action and all member variables and base classes are + * trivially destructible themselves. + */ +# if defined(__GNUC__) +# if ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))) +# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) +# endif +# elif (defined(__clang__) && defined(__has_feature)) +# if __has_feature(has_trivial_destructor) +# define HAS_TRIVIAL_DESTRUCTOR(T) __has_trivial_destructor(T) +# endif +# endif +# ifndef HAS_TRIVIAL_DESTRUCTOR + /* It's always safe (if inefficient) to assume that a + * destructor is non-trivial. + */ +# define HAS_TRIVIAL_DESTRUCTOR(T) (false) +# endif +#endif + +#endif /* UTIL_MACROS_H */ diff --git a/src/util/ralloc.h b/src/util/ralloc.h index 1fe53573f0d..4b88f328665 100644 --- a/src/util/ralloc.h +++ b/src/util/ralloc.h @@ -53,7 +53,8 @@ extern "C" { #include <stddef.h> #include <stdarg.h> #include <stdbool.h> -#include "main/compiler.h" + +#include "macros.h" /** * \def ralloc(ctx, type) |