xserver: Branch 'master' - 3 commits

Daniel Stone daniels at kemper.freedesktop.org
Sun Dec 24 06:28:57 EET 2006


 hw/xfree86/common/xf86fbman.c |   60 +++++++++++++++++++++---------------------
 os/utils.c                    |    2 -
 xkb/xkbUtils.c                |   23 +++++++++-------
 3 files changed, 45 insertions(+), 40 deletions(-)

New commits:
diff-tree c1674660a7115ebf993dcde78f4e45f756e4c951 (from 83080809f9a1c1d24b0318e54632f25f5940da25)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Dec 24 06:28:44 2006 +0200

    os: test for userland, not kernel
    
    It doesn't matter which kernel we're running on, the relevant part when
    dealing with includes is what our userland is.

diff --git a/os/utils.c b/os/utils.c
index 82ec704..b98c9c1 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -53,7 +53,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
 #include <dix-config.h>
 #endif
 
-#ifndef __linux__
+#ifndef __GLIBC__
 #include <time.h>
 #else
 /* The world's most shocking hack, to ensure we get clock_gettime() and
diff-tree 83080809f9a1c1d24b0318e54632f25f5940da25 (from 329f6417275bb1201ba66c29b202028eeab3a355)
Author: Marc Aurele La France <tsi at ualberta.ca>
Date:   Sun Dec 24 06:28:21 2006 +0200

    xfree86: deal with pitch that isn't a multiple of the granularity
    
    When the pitch isn't a multiple of the granularity, allocate more space to
    compensate.

diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c
index 8141a83..d64cfae 100644
--- a/hw/xfree86/common/xf86fbman.c
+++ b/hw/xfree86/common/xf86fbman.c
@@ -368,10 +368,8 @@ AllocateArea(
    /* look through the free boxes */
    for(i = 0; i < num; i++, boxp++) {
 	x = boxp->x1;
-	if(granularity) {
-	    int tmp = x % granularity;
-	    if(tmp) x += (granularity - tmp);
-	}
+	if (granularity > 1)
+	    x = ((x + granularity - 1) / granularity) * granularity;
 
 	if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w))
 	   continue;
@@ -398,10 +396,8 @@ AllocateArea(
 
 	   boxp = &(link->area.box);
 	   x = boxp->x1;
- 	   if(granularity) {
-		int tmp = x % granularity;
-		if(tmp) x += (granularity - tmp);
-	   }
+ 	   if (granularity > 1)
+		x = ((x + granularity - 1) / granularity) * granularity;
 
 	   if(((boxp->y2 - boxp->y1) < h) || ((boxp->x2 - x) < w)) {
 		link = link->next;
@@ -685,10 +681,8 @@ localQueryLargestOffscreenArea(
 
     while(nbox--) {
 	x = pbox->x1;
-	if(granularity) {
-	   int tmp = x % granularity;
-	   if(tmp) x += (granularity - tmp);
-        }
+	if (granularity > 1)
+	   x = ((x + granularity - 1) / granularity) * granularity;
 
 	w = pbox->x2 - x;
 	h = pbox->y2 - pbox->y1;
@@ -845,7 +839,9 @@ AllocateLinear(
    while (linear) {
  	/* Make sure we get a free area that's not an XY fallback case */
       if (!linear->area && linear->free) {
-	 offset = (linear->linear.offset + granularity) & ~granularity;
+	 offset = linear->linear.offset;
+	 if (granularity > 1)
+	    offset = ((offset + granularity - 1) / granularity) * granularity;
 	 end = offset+size;
 	 if (end <= (linear->linear.offset + linear->linear.size))
 	    break;
@@ -935,17 +931,20 @@ localAllocateOffscreenLinear(
    extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
    pitch = extents->x2 - extents->x1;
 
-   if (gran && gran > pitch) {
-	/* we can't match the specified alignment with XY allocations */
-	xfree(link);
-	return NULL;
-   }
-   if (gran && (pitch % gran)) {
-       /* pitch and granularity aren't a perfect match, let's allocate
-	* a bit more so we can align later on
-	*/
-       length += gran - 1;
-   }
+   if (gran > 1) {
+        if (gran > pitch) {
+            /* we can't match the specified alignment with XY allocations */
+            xfree(link);
+            return NULL;
+        }
+
+        if (pitch % gran) {
+            /* pitch and granularity aren't a perfect match, let's allocate
+             * a bit more so we can align later on
+             */
+            length += gran - 1;
+        }
+    }
 
    if(length < pitch) { /* special case */
 	w = length;
@@ -968,8 +967,8 @@ localAllocateOffscreenLinear(
 	linear->pScreen = pScreen;
 	linear->size = h * w;
 	linear->offset = (pitch * area->box.y1) + area->box.x1;
-	if (gran && linear->offset % gran)
-		linear->offset += gran - (linear->offset % gran);
+	if (gran > 1)
+            linear->offset += ((linear->offset + gran - 1) / gran) * gran;
 	linear->granularity = gran;
 	linear->MoveLinearCallback = moveCB;
 	linear->RemoveLinearCallback = removeCB;
@@ -1435,9 +1434,12 @@ xf86AllocateLinearOffscreenArea (
    extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
    w = extents->x2 - extents->x1;
 
-   if(gran && ((gran > w) || (w % gran))) {
-	/* we can't match the specified alignment with XY allocations */
-	return NULL;
+   if (gran > 1) {
+	if (gran > w)
+	    return NULL;
+
+	if (w % gran)
+	    length += gran - 1;
    }
 
    if(length <= w) { /* special case */
diff-tree 329f6417275bb1201ba66c29b202028eeab3a355 (from d9e079d2a385203fdd18d958cfc19d759cab4ba8)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Dec 9 22:51:59 2006 +0200

    XkbCopyKeymap: make sure sym_interpret is always valid
    
    Make sure we're not copying sym_interpret across from an empty source.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index c9c5ed0..400306a 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1497,30 +1497,33 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                 return FALSE;
         }
 
-        if (src->compat->sym_interpret) {
-            if (src->compat->size_si != dst->compat->size_si) {
+        if (src->compat->sym_interpret && src->compat->num_si) {
+            if (src->compat->num_si != dst->compat->size_si) {
                 if (dst->compat->sym_interpret)
                     tmp = xrealloc(dst->compat->sym_interpret,
-                                   src->compat->size_si *
+                                   src->compat->num_si *
                                      sizeof(XkbSymInterpretRec));
                 else
-                    tmp = xalloc(src->compat->size_si *
+                    tmp = xalloc(src->compat->num_si *
                                  sizeof(XkbSymInterpretRec));
                 if (!tmp)
                     return FALSE;
                 dst->compat->sym_interpret = tmp;
             }
             memcpy(dst->compat->sym_interpret, src->compat->sym_interpret,
-                   src->compat->size_si * sizeof(XkbSymInterpretRec));
+                   src->compat->num_si * sizeof(XkbSymInterpretRec));
+
+            dst->compat->num_si = src->compat->num_si;
+            dst->compat->size_si = src->compat->num_si;
         }
         else {
-            if (dst->compat->sym_interpret) {
+            if (dst->compat->sym_interpret && dst->compat->size_si)
                 xfree(dst->compat->sym_interpret);
-                dst->compat->sym_interpret = NULL;
-            }
+
+            dst->compat->sym_interpret = NULL;
+            dst->compat->num_si = 0;
+            dst->compat->size_si = 0;
         }
-        dst->compat->num_si = src->compat->num_si;
-        dst->compat->size_si = src->compat->size_si;
 
         memcpy(dst->compat->groups, src->compat->groups,
                XkbNumKbdGroups * sizeof(XkbModsRec));



More information about the xorg-commit mailing list