[PATCH 06/15] glamor: Remove copy of sna's compiler.h

Eric Anholt eric at anholt.net
Thu Jan 9 17:26:20 PST 2014


From: Adam Jackson <ajax at redhat.com>

Xfuncproto.h has equivalents for these already.

v2: Adjust a couple more likelies after the rebase (anholt)

Signed-off-by: Adam Jackson <ajax at redhat.com>
Signed-off-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Eric Anholt <eric at anholt.net>
---
 glamor/Makefile.am             |  1 -
 glamor/compiler.h              | 59 ------------------------------------------
 glamor/glamor_compositerects.c |  2 +-
 glamor/glamor_fill.c           |  4 +--
 glamor/glamor_glyphs.c         |  8 +++---
 glamor/glamor_priv.h           |  2 --
 glamor/glamor_utils.h          | 34 ++++++++++++------------
 glamor/glapi.h                 |  6 ++---
 8 files changed, 27 insertions(+), 89 deletions(-)
 delete mode 100644 glamor/compiler.h

diff --git a/glamor/Makefile.am b/glamor/Makefile.am
index 2fd521f..5eefd8e 100644
--- a/glamor/Makefile.am
+++ b/glamor/Makefile.am
@@ -12,7 +12,6 @@ libglamor_la_LDFLAGS = -version-info 0:0:0
 
 libglamor_la_SOURCES = \
 	compat-api.h \
-	compiler.h \
 	glamor.c \
 	glamor_copyarea.c \
 	glamor_copywindow.c \
diff --git a/glamor/compiler.h b/glamor/compiler.h
deleted file mode 100644
index 5f2d4ea..0000000
--- a/glamor/compiler.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2011 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.
- *
- * Authors:
- *    Chris Wilson <chris at chris-wilson.co.uk>
- *
- *    Copied from sna 
- *
- */
-
-#ifndef _GLAMOR_COMPILER_H_
-#define _GLAMOR_COMPILER_H_
-
-#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
-#define likely(expr) (__builtin_expect (!!(expr), 1))
-#define unlikely(expr) (__builtin_expect (!!(expr), 0))
-#define noinline __attribute__((noinline))
-#define fastcall __attribute__((regparm(3)))
-#define must_check __attribute__((warn_unused_result))
-#define constant __attribute__((const))
-#else
-#define likely(expr) (expr)
-#define unlikely(expr) (expr)
-#define noinline
-#define fastcall
-#define must_check
-#define constant
-#endif
-
-#ifdef HAVE_VALGRIND
-#define VG(x) x
-#else
-#define VG(x)
-#endif
-
-#define VG_CLEAR(s) VG(memset(&s, 0, sizeof(s)))
-
-#define COMPILE_TIME_ASSERT(E) ((void)sizeof(char[1 - 2*!(E)]))
-
-#endif                          /* _SNA_COMPILER_H_ */
diff --git a/glamor/glamor_compositerects.c b/glamor/glamor_compositerects.c
index a0d5980..967e228 100644
--- a/glamor/glamor_compositerects.c
+++ b/glamor/glamor_compositerects.c
@@ -246,7 +246,7 @@ glamor_composite_rectangles(CARD8 op,
         goto done;
     }
     else {
-        if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) {
+        if (_X_LIKELY(priv->type != GLAMOR_TEXTURE_LARGE)) {
             int error;
 
             source = CreateSolidPicture(0, color, &error);
diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c
index 3aef7fc..d59e620 100644
--- a/glamor/glamor_fill.c
+++ b/glamor/glamor_fill.c
@@ -203,7 +203,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
 
     pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
 
-    if (unlikely(nbox * 4 * 2 > ARRAY_SIZE(vertices))) {
+    if (_X_UNLIKELY(nbox * 4 * 2 > ARRAY_SIZE(vertices))) {
         int allocated_box;
 
         if (nbox * 6 > GLAMOR_COMPOSITE_VBO_VERT_CNT) {
@@ -220,7 +220,7 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
         }
     }
 
-    if (unlikely(nbox > 1))
+    if (_X_UNLIKELY(nbox > 1))
         dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
 
     dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
diff --git a/glamor/glamor_glyphs.c b/glamor/glamor_glyphs.c
index 1c0f9f5..3586b33 100644
--- a/glamor/glamor_glyphs.c
+++ b/glamor/glamor_glyphs.c
@@ -191,7 +191,7 @@ find_continuous_bits(unsigned int bits, int bits_cnt, unsigned int *pbits_mask)
 
     bits_mask = ((1LL << bits_cnt) - 1);
 
-    if (unlikely(bits_cnt > 56)) {
+    if (_X_UNLIKELY(bits_cnt > 56)) {
         while (bits) {
             if ((bits & bits_mask) == bits_mask) {
                 *pbits_mask = bits_mask << idx;
@@ -751,7 +751,7 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr *glyphs,
         left_to_right = TRUE;
         cur_list = list++;
 
-        if (unlikely(!first_list)) {
+        if (_X_UNLIKELY(!first_list)) {
             pixman_region_init_with_extents(&current_region, extents);
             pixman_region_union(&list_region, &list_region, &current_region);
             first = TRUE;
@@ -821,7 +821,7 @@ glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr *glyphs,
                 }
             }
             else {
-                if (unlikely(!first_list)) {
+                if (_X_UNLIKELY(!first_list)) {
                     current_box.x1 = x1;
                     current_box.y1 = y1;
                     current_box.x2 = x2;
@@ -1709,7 +1709,7 @@ _glamor_glyphs(CARD8 op,
     format = mask_format->depth << 24 | mask_format->format;
 
     fixed_list = calloc(fixed_size, sizeof(*fixed_list));
-    if (unlikely(fixed_list == NULL))
+    if (_X_UNLIKELY(fixed_list == NULL))
         fixed_size = 0;
     fixed_cnt = glamor_glyphs_intersect(nlist, list, glyphs,
                                         format, dst->pDrawable->pScreen,
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index d4f5371..08b6bb0 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -31,8 +31,6 @@
 #include "config.h"
 #endif
 
-#include "compiler.h"
-
 #include <xorg-server.h>
 #ifndef DEBUG
 #define NDEBUG
diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
index b27c56c..49d2ff7 100644
--- a/glamor/glamor_utils.h
+++ b/glamor/glamor_utils.h
@@ -59,7 +59,7 @@
 
 #define PIXMAP_PRIV_GET_ACTUAL_SIZE(priv, w, h)			\
   do {								\
-	if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) {		\
+	if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) {	\
 		w = priv->large.box.x2 - priv->large.box.x1;	\
 		h = priv->large.box.y2 - priv->large.box.y1;	\
 	} else {						\
@@ -80,7 +80,7 @@
 
 #define pixmap_priv_get_fbo_off(_priv_, _xoff_, _yoff_)		\
    do {								\
-	if (unlikely(_priv_ && (_priv_)->type == GLAMOR_TEXTURE_LARGE)) {  \
+	if (_X_UNLIKELY(_priv_ && (_priv_)->type == GLAMOR_TEXTURE_LARGE)) {  \
 		*(_xoff_) = - (_priv_)->large.box.x1;	\
 		*(_yoff_) = - (_priv_)->large.box.y1;	\
 	} else {						\
@@ -314,7 +314,7 @@
 				     texcoord, yInverted)		\
   do {									\
 	(texcoord)[0] = t_from_x_coord_x(xscale, _tx_);			\
-	if (likely(yInverted))						\
+	if (_X_LIKELY(yInverted))					\
 		(texcoord)[1] = t_from_x_coord_y_inverted(yscale, _ty_);\
 	else								\
 		(texcoord)[1] = t_from_x_coord_y(yscale, _ty_);		\
@@ -337,7 +337,7 @@
     tx += fbo_x_off;							\
     ty += fbo_y_off;							\
     (texcoord)[0] = t_from_x_coord_x(xscale, tx);			\
-    if (likely(yInverted))							\
+    if (_X_LIKELY(yInverted))						\
       (texcoord)[1] = t_from_x_coord_y_inverted(yscale, ty);		\
     else								\
       (texcoord)[1] = t_from_x_coord_y(yscale, ty);			\
@@ -432,7 +432,7 @@
 							 texcoords,	\
 							 stride)	\
   do {									\
-    if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) {			\
+    if (_X_LIKELY(priv->type != GLAMOR_TEXTURE_LARGE)) {		\
 	glamor_set_transformed_normalize_tcoords_ext(priv, matrix, xscale,	\
 						 yscale, _x1_, _y1_,	\
 						 _x2_, _y2_, yInverted,	\
@@ -505,7 +505,7 @@
     (vertices)[1 * stride] = _t2_ = t_from_x_coord_x(xscale, tx2);	\
     (vertices)[2 * stride] = _t2_;					\
     (vertices)[3 * stride] = _t0_;					\
-    if (likely(yInverted)) {							\
+    if (_X_LIKELY(yInverted)) {						\
       (vertices)[1] = _t1_ = t_from_x_coord_y_inverted(yscale, ty1);	\
       (vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y_inverted(yscale, ty2);\
     }									\
@@ -521,7 +521,7 @@
 				     x1, y1, x2, y2,			\
                                      yInverted, vertices, stride)	\
   do {									\
-     if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) {				\
+     if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) {		\
 	float tx1, tx2, ty1, ty2;					\
 	int fbo_x_off, fbo_y_off;					\
 	pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off);		\
@@ -551,7 +551,7 @@
 					    _x1_, _y1_, _x2_, _y2_,	\
 	                                    yInverted, vertices, stride)\
   do {									\
-     if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) {				\
+     if (_X_UNLIKELY(priv->type == GLAMOR_TEXTURE_LARGE)) {		\
 	float tx1, tx2, ty1, ty2;					\
 	if (repeat_type == RepeatPad) {					\
 		tx1 = _x1_ - priv->large.box.x1;			\
@@ -591,7 +591,7 @@
 	(vertices)[2] = t_from_x_coord_x(xscale, x2);			\
 	(vertices)[6] = (vertices)[2];					\
 	(vertices)[4] = (vertices)[0];					\
-	if (likely(yInverted)) {						\
+	if (_X_LIKELY(yInverted)) {					\
 	    (vertices)[1] = t_from_x_coord_y_inverted(yscale, y1);	\
 	    (vertices)[7] = t_from_x_coord_y_inverted(yscale, y2);	\
 	}								\
@@ -610,7 +610,7 @@
 	(vertices)[2] = (x2);					\
 	(vertices)[4] = (vertices)[2];				\
 	(vertices)[6] = (vertices)[0];				\
-	if (likely(yInverted)) {					\
+	if (_X_LIKELY(yInverted)) {				\
 	    (vertices)[1] = (y1);				\
 	    (vertices)[5] = (y2);				\
 	}							\
@@ -629,7 +629,7 @@
 	(vertices)[1*stride] = (x2);				\
 	(vertices)[2*stride] = (vertices)[1*stride];		\
 	(vertices)[3*stride] = (vertices)[0];			\
-	if (likely(yInverted)) {				\
+	if (_X_LIKELY(yInverted)) {				\
 	    (vertices)[1] = (y1);				\
 	    (vertices)[2*stride + 1] = (y2);			\
 	}							\
@@ -645,7 +645,7 @@
 					yInverted, vertices)		\
     do {								\
 	(vertices)[0] = v_from_x_coord_x(xscale, x);			\
-	if (likely(yInverted)) {						\
+	if (_X_LIKELY(yInverted)) {					\
 	    (vertices)[1] = v_from_x_coord_y_inverted(yscale, y);	\
 	} else {							\
 	    (vertices)[1] = v_from_x_coord_y(yscale, y);		\
@@ -673,7 +673,7 @@
 	(vertices)[2] = (x2);						\
 	(vertices)[6] = (vertices)[2];					\
 	(vertices)[4] = (vertices)[0];					\
-	if (likely(yInverted)) {						\
+	if (_X_LIKELY(yInverted)) {	    				\
 	    (vertices)[1] = (y1);					\
 	    (vertices)[7] = (y2);					\
 	}								\
@@ -699,7 +699,7 @@
 					x2 + fbo_x_off);		\
     (vertices)[2 * stride] = _t2_;					\
     (vertices)[3 * stride] = _t0_;					\
-    if (likely(yInverted)) {							\
+    if (_X_LIKELY(yInverted)) {						\
       (vertices)[1] = _t1_ = v_from_x_coord_y_inverted(yscale,		\
 				y1 + fbo_y_off);			\
       (vertices)[2 * stride + 1] = _t5_ =				\
@@ -742,7 +742,7 @@
 	(vertices)[2] = v_from_x_coord_x(xscale, x2);			\
 	(vertices)[6] = (vertices)[2];					\
 	(vertices)[4] = (vertices)[0];					\
-	if (likely(yInverted)) {						\
+	if (_X_LIKELY(yInverted)) {	    				\
 	    (vertices)[1] = v_from_x_coord_y_inverted(yscale, y1);	\
 	    (vertices)[7] = v_from_x_coord_y_inverted(yscale, y2);	\
 	}								\
@@ -758,7 +758,7 @@
                                 yInverted, pt)			\
     do {							\
         (pt)[0] = t_from_x_coord_x(xscale, x);			\
-        if (likely(yInverted)) {					\
+        if (_X_LIKELY(yInverted)) {				\
             (pt)[1] = t_from_x_coord_y_inverted(yscale, y);	\
         } else {						\
             (pt)[1] = t_from_x_coord_y(yscale, y);		\
@@ -769,7 +769,7 @@
 				 yInverted, c)		\
     do {						\
         (c)[0] = (float)x;				\
-        if (likely(yInverted)) {				\
+        if (_X_LIKELY(yInverted)) {	    		\
             (c)[1] = (float)y;				\
         } else {					\
             (c)[1] = (float)height - (float)y;		\
diff --git a/glamor/glapi.h b/glamor/glapi.h
index 481e4ba..f61fc84 100644
--- a/glamor/glapi.h
+++ b/glamor/glapi.h
@@ -88,12 +88,12 @@ extern void *_glapi_Context;
 #ifdef THREADS
 
 #define GET_DISPATCH() \
-     (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
+     (_X_LIKELY(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
 
 #define GET_CURRENT_CONTEXT(C)  C = (typeof(C)) \
-     (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
+     (_X_LIKELY(_glapi_Context) ? _glapi_Context : _glapi_get_context())
 
-#define SET_CURRENT_CONTEXT(C) do { if (likely(_glapi_Context))   \
+#define SET_CURRENT_CONTEXT(C) do { if (_X_LIKELY(_glapi_Context))      \
 					_glapi_Context = (void*)C; \
 				     else \
 					_glapi_set_context(C); } while(0)
-- 
1.8.5.1



More information about the xorg-devel mailing list