summaryrefslogtreecommitdiffstats
path: root/src/util/macros.h
Commit message (Collapse)AuthorAgeFilesLines
* mesa: removed redundant #elseGeorge Kyriazis2016-11-211-1/+0
| | | | Reviewed-by: Emil Velikov <[email protected]>
* util: Fix Clang trivial destructor check.Vinson Lee2016-11-151-4/+4
| | | | | | | | | | | | | | | Check for Clang before GCC. Clang defines __GNUC__ == 4 and __GNUC_MINOR__ == 2 and matches the GCC check but not the GCC version for trivial destructor. Fixes: 98ab905af0e0 ("mesa: Define introspection macro to determine whether a type is trivially destructible.") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98526 Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Edward O'Callaghan <[email protected]> Reviewed-by: Francisco Jerez <[email protected]>
* util: add MSVC HAS_TRIVIAL_DESTRUCTOR implementationBrian Paul2016-11-091-0/+5
| | | | | | | | | | | | Based on a patch by George Kyriazis but changed to test for _MSC_VER >= 1800 (Visual Studio 2015). This fixes the failed CANARY assertion in src/util/ralloc.c:get_header() on Windows. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98595 Tested-by: Brian Paul <[email protected]> Signed-off-by: Brian Paul <[email protected]>
* util: move min/max/clamp macros to util macros.hDave Airlie2016-10-191-0/+13
| | | | | | | | | Although the vulkan drivers include mesa macros.h, for radv I'd like to move away from that. Reviewed-by: Nicolai Hähnle <[email protected]> Acked-by: Jason Ekstrand <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
* util: remove Sun C Compiler supportTimothy Arceri2016-09-231-1/+1
| | | | | | Support for this compiler was dropped in 51564f04b77e6 Acked-by: Edward O'Callaghan <[email protected]>
* util: Add ATTRIBUTE_RETURNS_NONNULL.Matt Turner2016-05-161-0/+6
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* st/glsl_to_tgsi: reduce stack explosion in recursive expression visitorNicolai Hähnle2016-04-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | In optimized builds, visit(ir_expression *) experiences inlining with gcc that leads the function to have a roughly 32KB stack frame. This is a problem given that the function is called recursively. In non-optimized builds, the stack frame is much smaller, hence one gets crashes that happen only in optimized builds. Arguably there is a compiler bug or at least severe misfeature here. In any case, the easy thing to do for now seems to be moving the bulk of the non-recursive code into a separate function. This is sufficient to convince my version of gcc not to blow up the stack frame of the recursive part. Just to be sure, add the gcc-specific noinline attribute to prevent this bug from reoccuring if inliner heuristics change. v2: put ATTRIBUTE_NOINLINE into macros.h Cc: "11.1 11.2" <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95133 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95026 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92850 Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* scons: Move fallback HAVE_* definitions to headers.Jose Fonseca2016-04-261-0/+2
| | | | | | | | | | | | | | | | | | These were being defined in SCons, but it's not practical: - we actually need to include Gallium headers from external source trees, with completely disjoint build infrastructure, and it's unsustainable to replicate the HAVE_xxx checks or even hard-coded defines across everywhere. - checking compiler version via command line doesn't really work due to Clang essentially being like a cameleon which can fake either GCC or MSVC There's no change for autoconf. Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* util: add MAYBE_UNUSED for config dependent variablesGrazvydas Ignotas2016-04-251-0/+2
| | | | | | | | | | | | | | | | | This is mostly for variables that are only used in asserts and cause unused-but-set-variable warnings in release builds. Could just use UNUSED directly, but MAYBE_UNUSED should be less confusing and is similar to what the Linux kernel has. And yes __attribute__((unused)) can be used on variables on both GCC 4.2 (oldest supported by mesa) and clang 3.0 (just some random old version, not sure what's the minimum for mesa). Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Francisco Jerez <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* Remove Sun CC specific code.Jose Fonseca2015-12-021-1/+1
| | | | | Reviewed-by: Matt Turner <[email protected]> Acked-by: Alan Coopersmith <[email protected]>
* util: Include assert.h in macros.h.Matt Turner2015-11-241-0/+2
|
* util: Rename PURE to ATTRIBUTE_PURE.Jose Fonseca2015-08-091-2/+2
| | | | | | | | | To avoid collission with windows.h's PURE macro. We could consider eventually renaming to __pure, but that would require further care, so it's left to the future. Reviewed-by: Brian Paul <[email protected]>
* mesa: Detect and provide macros for function attributes pure and const.Eric Anholt2015-07-171-0/+20
| | | | | | | | | | | | | These are really useful hints to the compiler in the absence of link-time optimization, and I'm going to use them in VC4. I've made the const attribute be ATTRIBUTE_CONST unlike other function attributes, because we have other things in the tree #defining CONST for their own unrelated purposes. v2: Alphabetize. Reviewed-by: Kenneth Graunke <[email protected]> (v1)
* mesa: Add a MUST_CHECK macro for __attribute__((warn_unused_result)).Kenneth Graunke2015-07-061-0/+6
| | | | | | | | | In the kernel, this is called __must_check; all our attribute macros in Mesa appear to be uppercase, so I went with that. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* util/macros: Move DIV_ROUND_UP to util/macros.hAxel Davy2015-04-291-0/+2
| | | | | | | Move DIV_ROUND_UP to a shared location accessible everywhere Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Axel Davy <[email protected]>
* Add macro for unused function attribute.Vinson Lee2015-03-091-0/+6
| | | | | | Suggested-by: Emil Velikov <[email protected]> Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: rework _MSC_VER >= 1200 checksEmil Velikov2015-03-061-5/+3
| | | | | | | | | Replace the _MSC_VER >= 1200 with defined (_MSC_VER) and compact if/else statements. We require MSVC 2008 or later with commit 46110c5d564. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* mesa: consolidate PUBLIC macro definitionBrian Paul2015-03-041-0/+23
| | | | | | | Define the macro in src/util/macros.h rather than in two different places. Note that USED isn't actually used anywhere at this time. Reviewed-by: Jose Fonseca <[email protected]>
* Revert "util: Move the alternate fpclassify implementation to util"Jason Ekstrand2015-01-281-62/+0
| | | | | | | | | | | | | This reverts commits d6eb572905e39c36168b8f5da240af961f9dde0a and 58e8468d113c7d3d4a59ea4a8d70fd45b78e85e6. This is no longer necessary as we aren't using it in NIR anymore. Also, it broke the build on some strange systems so let's put it back in querymatrix where it came from. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88852 Acked-by: Matt Turner <[email protected]>
* util: Predicate the fpclassify fallback on !defined(__cplusplus)Jason Ekstrand2015-01-281-2/+12
| | | | | | | | | | | The problem is that the fallbacks we have at the moment don't work in C++. While we could theoretically fix the fallbacks it would also raise the issue of correctly detecting the fpclassify function. So, for now, we'll just disable it until we actually have a C++ user. Reported-by: Tom Stellard <[email protected]> Tested-by: Tom Stellard <[email protected]> Tested-by: EdB <[email protected]>
* util: Move the alternate fpclassify implementation to utilJason Ekstrand2015-01-281-0/+52
| | | | Reviewed-by: Ian Romanick <[email protected]>
* util: Make unreachable at least be an assertCarl Worth2015-01-161-1/+1
| | | | | | | | Previously, if __builtin_unreachable() was unavailable, the unreachable macro was defined to do nothing. We do better here, by at least still making it an assert. Reviewed-by: Ian Romanick <[email protected]>
* util: Implement assume() for clang.Matt Turner2014-11-241-1/+11
| | | | Reviewed-by: Jordan Justen <[email protected]>
* util: Implement unreachable for MSVC using __assumeIan Romanick2014-11-051-0/+6
| | | | | | | | | Based on the description of __assume at: http://msdn.microsoft.com/en-us/library/1b3fsfxw.aspx Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* util: Add assume() macro.Matt Turner2014-10-231-0/+14
| | | | Reviewed-by: Ian Romanick <[email protected]>
* ralloc: Mark ralloc functions with gcc's malloc attribute.Matt Turner2014-09-251-0/+6
| | | | | | | Cuts a few hundred bytes from the DRI drivers, so it must give gcc some extra information. Reviewed-by: Ian Romanick <[email protected]>
* mesa: Replace a priori knowledge of gcc attributes with configure tests.Matt Turner2014-09-251-4/+7
| | | | | | | | Note that I had to add support for testing the packed attribute to m4/ax_gcc_func_attribute.m4. Reviewed-by: Jason Ekstrand <[email protected]> [C bits] Reviewed-by: Ian Romanick <[email protected]>
* mesa: Replace a priori knowledge of gcc builtins with configure tests.Matt Turner2014-09-251-11/+3
| | | | | | | | | | | | | | Presumbly this will let clang and other compilers use the built-ins as well. Notice two changes specifically: - in _mesa_next_pow_two_64(), always use __builtin_clzll and add a static assertion that this is safe. - in macros.h, remove the clang-specific definition since it should be able to detect __builtin_unreachable in configure. Reviewed-by: Jason Ekstrand <[email protected]> [C bits] Reviewed-by: Ian Romanick <[email protected]>
* util: Gather some common macrosJason Ekstrand2014-08-041-0/+128
This gathers macros that have been included across components into util so that the include chain can be more vertical. In particular, this makes util stand on its own without any dependence whatsoever on the rest of mesa. Signed-off-by: "Jason Ekstrand" <[email protected]> Reviewed-by: Marek Olšák <[email protected]>