GALLIUM_CFLAGS = \
-I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
-I$(top_srcdir)/src/gallium/include \
-I$(top_srcdir)/src/gallium/auxiliary \
$(DEFINES)
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 \
compiler/tests/unit_test.c
HELPER_SOURCES := \
- ralloc.c \
register_allocate.c
#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"
+++ /dev/null
-../../../util/ralloc.c
\ No newline at end of file
#env.Append(CPPDEFINES = [('__NOT_HAVE_DRM_H', '1')])
env.Append(CPPPATH = [
+ '#/src',
'#/src/mapi',
'#/src/mesa',
'#/src/gallium/state_trackers/dri/common',
env = env.Clone()
env.Append(CPPPATH = [
+ '#/src',
'#/src/mapi',
'#/src/mesa',
'#/src/mesa/main',
ws_xlib,
mesautil,
glapi,
+ mesautil,
mesa,
glsl,
gallium,
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) \
#include "glsl_types.h"
#include "glsl_parser_extras.h"
+#include "util/macros.h"
/**
* Declarations of type flyweights (glsl_type::_foo_type) and
#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;
{
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);
* 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]);
}
}
libloader_la_CPPFLAGS = \
$(DEFINES) \
-I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
$(VISIBILITY_CFLAGS) \
$(LIBUDEV_CFLAGS)
xmlpool_options.dir.dir, # Dir to generated xmlpool/options.h
'#include',
'#include/GL/internal',
+ '#src',
'#src/mapi',
'#src/gallium/include',
'#src/gallium/auxiliary',
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/ \
env = env.Clone()
env.Prepend(CPPPATH = [
+ '#src',
'#src/mapi',
'#src/mesa',
Dir('../../../mapi'), # src/mapi build path for python-generated GL API files/headers
env = env.Clone()
env.Append(CPPPATH = [
+ '#/src',
'#/src/mapi',
'#/src/mesa',
'#/src/mesa/main',
#include <float.h>
#include <stdarg.h>
+#include "util/macros.h"
+
#include "c99_compat.h" /* inline, __func__, etc. */
#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__
#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
#define Elements(x) (sizeof(x)/sizeof(*(x)))
#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
#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
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)
env.Prepend(CPPPATH = [
'#include',
- '#src/mapi',
- '#src/mesa',
'#src/util',
])
#include <string.h>
#include "hash_table.h"
-#include "main/macros.h"
#include "ralloc.h"
+#include "macros.h"
static const uint32_t deleted_key_value;
#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" {
--- /dev/null
+/*
+ * 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 */
#include <stddef.h>
#include <stdarg.h>
#include <stdbool.h>
-#include "main/compiler.h"
+
+#include "macros.h"
/**
* \def ralloc(ctx, type)