Re: close-on-exec

2015-02-26 Thread Emil Velikov
On 25/02/15 22:27, Alan Coopersmith wrote:
 On 02/25/15 01:24 PM, Thomas Klausner wrote:
 I don't know what the proper way to do this portably, but this is
 the diff we currently have in NetBSD's xsrc for xsm to close file
 descriptors on exec.

 I see that glibc added fopen's e flag for 2.7 (in 2007). No idea
 about other operating systems, the flag was new to me too :)
 
 Solaris has the ancient support for setting the FD_CLOEXEC flag via
 fcntl() in all versions, and the more recent support for the O_CLOEXEC
 flag to open() in Solaris 11 and later, but does not yet support the
 e flag to fopen().  (I've filed an enhancement request to add it to
 our libc in the future, but that doesn't help today.)
 
 I believe the most portable way to do this is:
 
 if (!(addfp = fopen (addAuthFile, w)))
  goto bad;
 else
 fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC);
 
 That would be subject to race conditions in multi-threaded processes, as
 described in https://udrepper.livejournal.com/20407.html, so not safe in
 libraries or programs which deliberately start multiple threads, but since
 xsm is not one of those, it should be mostly safe. (Not completely, because
 we can't be sure nothing we called in a library didn't start a thread
 behind
 the scenes to handle one of our requests, but without an e flag
 everywhere,
 I'm not sure what more we can do.  I have no idea how to write a configure
 check to test for fopen(..., e) support either.)
 
Something like the following should be ok, but I haven't tested it.

AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#define _POSIX_SOURCE
#include stdio.h

int main () {
FILE *fp;
fp = fopen(/tmp/foo, e);
return 0;
}]])], AC_DEFINE([HAVE_FOPEN_E], [1],
 [Define if fopen(... , e) exists.])
)

-Emil
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] damage: Only track extents where possible

2015-02-26 Thread Adam Jackson
On Wed, 2015-02-25 at 18:01 +, Chris Wilson wrote:
 For external Damage, we need only track sufficient information to
 satisfy the DamageReportLevel. That is if the Client only wishes to hear
 that the Damage is now non-empty or if the extents change, we only need
 to track the extents of the Damage and can discard the actual
 rectangles. This speeds up the union operation, speeding up damage
 processing for Client as well - with a noticeable increase in
 performance of gnome-shell (which uses DamageReportBoundingBox) for
 example.

I like the idea, not quite sold on the realization.

 Internal users of Damage have access to the DamageRegion irrespective of
 the DamageReportLevel and so we need to keep the full region intact for
 them.

That's not quite what isInternal means, it's currently used to hide
software sprite rendering from the protocol event stream.  xwl and
composite also create their damages with isInternal FALSE.  For xwl that
could just be fixed since it's not initializing midc, but composite
really does want that suppression to work.

So I guess the question is whether automatic windows should take the
bounding box snap too, and I guess whichever method makes x11perf look
better when 'xcompmgr -a' is good enough for me.

 +static void DamageCombineExtents(DamagePtr pDamage, RegionPtr pDamageRegion)
 +{
 +if (!pDamage-isInternal) {
 +RegionUninit(pDamageRegion);
 +RegionUnion(pDamage-damage, pDamage-damage, pDamageRegion);
 +RegionUninit(pDamage-damage);
 +} else
 +RegionUnion(pDamage-damage, pDamage-damage, pDamageRegion);
 +}

First time I've seen this idiom of relying on RegionUninit to empty the
rect list but leave the bounding box.  I don't necessarily have an issue
with it but a comment would be nice.

 @@ -1929,7 +1939,7 @@ DamageReportDamage(DamagePtr pDamage, RegionPtr 
 pDamageRegion)
  break;
  case DamageReportBoundingBox:
  tmpBox = *RegionExtents(pDamage-damage);
 -RegionUnion(pDamage-damage, pDamage-damage, pDamageRegion);
 +DamageCombineExtents(pDamage, pDamageRegion);
  if (!BOX_SAME(tmpBox, RegionExtents(pDamage-damage))) {
  (*pDamage-damageReport) (pDamage, pDamage-damage,
pDamage-closure);

Presumably this half doesn't even need to inspect isInternal, since the
bounding box is all that's requested in any case.  There are no in-tree
BoundingBox consumers so nothing can be relying on getting anything more
detailed in the report hook, and the protocol event snaps to the box
anyway.

- ajax

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver] config: Support multiple 'Files' sections

2015-02-26 Thread Michał Górny
Support reading multiple 'Files' sections in configuration,
concatenating the resulting paths. This makes it possible to add
ModulePaths and FontPaths within xorg.conf.d/ files without interfering
with user-provided xorg.conf. Gentoo needs this to support using
replacement xorg modules provided by proprietary video drivers.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=88003
Signed-off-by: Michał Górny mgo...@gentoo.org
---
[not subscribed, please CC me on replies]

 hw/xfree86/parser/Files.c   | 8 ++--
 hw/xfree86/parser/configProcs.h | 2 +-
 hw/xfree86/parser/read.c| 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/xfree86/parser/Files.c b/hw/xfree86/parser/Files.c
index 849bf92..5cc3ec7 100644
--- a/hw/xfree86/parser/Files.c
+++ b/hw/xfree86/parser/Files.c
@@ -76,14 +76,18 @@ static xf86ConfigSymTabRec FilesTab[] = {
 #define CLEANUP xf86freeFiles
 
 XF86ConfFilesPtr
-xf86parseFilesSection(void)
+xf86parseFilesSection(XF86ConfFilesPtr ptr)
 {
 int i, j;
 int k, l;
 char *str;
 int token;
 
-parsePrologue(XF86ConfFilesPtr, XF86ConfFilesRec)
+if (!ptr) {
+if( (ptr=calloc(1,sizeof(XF86ConfFilesRec))) == NULL ) {
+return NULL;
+}
+}
 
 while ((token = xf86getToken(FilesTab)) != ENDSECTION) {
 switch (token) {
diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h
index 774e2a2..b9fdebb 100644
--- a/hw/xfree86/parser/configProcs.h
+++ b/hw/xfree86/parser/configProcs.h
@@ -37,7 +37,7 @@ void xf86freeDeviceList(XF86ConfDevicePtr ptr);
 int xf86validateDevice(XF86ConfigPtr p);
 
 /* Files.c */
-XF86ConfFilesPtr xf86parseFilesSection(void);
+XF86ConfFilesPtr xf86parseFilesSection(XF86ConfFilesPtr ptr);
 void xf86printFileSection(FILE * cf, XF86ConfFilesPtr ptr);
 void xf86freeFiles(XF86ConfFilesPtr p);
 
diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c
index 327c02a..e0d6139 100644
--- a/hw/xfree86/parser/read.c
+++ b/hw/xfree86/parser/read.c
@@ -110,7 +110,7 @@ xf86readConfigFile(void)
 if (xf86nameCompare(xf86_lex_val.str, files) == 0) {
 free(xf86_lex_val.str);
 xf86_lex_val.str = NULL;
-HANDLE_RETURN(conf_files, xf86parseFilesSection());
+HANDLE_RETURN(conf_files, 
xf86parseFilesSection(ptr-conf_files));
 }
 else if (xf86nameCompare(xf86_lex_val.str, serverflags) == 0) {
 free(xf86_lex_val.str);
-- 
2.3.0

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xf86-input-libinput 1/2] Split out property init into helper functions

2015-02-26 Thread Hans de Goede

Hi,

On 26-02-15 08:07, Peter Hutterer wrote:

Makes the code less messy. Only functional change is that if one property
fails to initialize we'll now continue with the others. Previously the first
failed property would prevent any other property init.

Signed-off-by: Peter Hutterer peter.hutte...@who-t.net


Both patches look good and are:

Reviewed-by: Hans de Goede hdego...@redhat.com

Regards,

Hans


---
  src/libinput.c | 403 +
  1 file changed, 234 insertions(+), 169 deletions(-)

diff --git a/src/libinput.c b/src/libinput.c
index be0b24d..9be17b4 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1632,196 +1632,240 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, 
XIPropertyValuePtr val,
  }

  static void
-LibinputInitProperty(DeviceIntPtr dev)
+LibinputInitTapProperty(DeviceIntPtr dev,
+   struct xf86libinput *driver_data,
+   struct libinput_device *device)
  {
-   InputInfoPtr pInfo  = dev-public.devicePrivate;
-   struct xf86libinput *driver_data = pInfo-private;
-   struct libinput_device *device = driver_data-device;
-   const char *device_node;
-   CARD32 product[2];
-   uint32_t scroll_methods;
-   uint32_t sendevent_modes;
+   BOOL tap = driver_data-options.tapping;
int rc;

-   prop_float = XIGetKnownProperty(FLOAT);
+   if (libinput_device_config_tap_get_finger_count(device) == 0)
+   return;

-   if (libinput_device_config_tap_get_finger_count(device)  0) {
-   BOOL tap = driver_data-options.tapping;
+   prop_tap = MakeAtom(LIBINPUT_PROP_TAP, strlen(LIBINPUT_PROP_TAP), TRUE);
+   rc = XIChangeDeviceProperty(dev, prop_tap, XA_INTEGER, 8,
+   PropModeReplace, 1, tap, FALSE);
+   if (rc != Success)
+   return;
+   XISetDevicePropertyDeletable(dev, prop_tap, FALSE);
+}

-   prop_tap = MakeAtom(LIBINPUT_PROP_TAP, 
strlen(LIBINPUT_PROP_TAP), TRUE);
-   rc = XIChangeDeviceProperty(dev, prop_tap, XA_INTEGER, 8,
-   PropModeReplace, 1, tap, FALSE);
-   if (rc != Success)
-   return;
-   XISetDevicePropertyDeletable(dev, prop_tap, FALSE);
-   }
+static void
+LibinputInitCalibrationProperty(DeviceIntPtr dev,
+   struct xf86libinput *driver_data,
+   struct libinput_device *device)
+{
+   float calibration[9];
+   int rc;
+
+   if (!libinput_device_config_calibration_has_matrix(device))
+   return;

/* We use a 9-element matrix just to be closer to the X server's
   transformation matrix which also has the full matrix */
-   if (libinput_device_config_calibration_has_matrix(device)) {
-   float calibration[9];
-
-   libinput_device_config_calibration_get_matrix(device, 
calibration);
-   calibration[6] = 0;
-   calibration[7] = 0;
-   calibration[8] = 1;
-
-   prop_calibration = MakeAtom(LIBINPUT_PROP_CALIBRATION,
-   strlen(LIBINPUT_PROP_CALIBRATION),
-   TRUE);
-
-   rc = XIChangeDeviceProperty(dev, prop_calibration, prop_float, 
32,
-   PropModeReplace, 9, calibration, 
FALSE);
-   if (rc != Success)
-   return;
-   XISetDevicePropertyDeletable(dev, prop_calibration, FALSE);
-   }
-
-   if (libinput_device_config_accel_is_available(device)) {
-   float speed = driver_data-options.speed;
-
-   prop_accel = MakeAtom(LIBINPUT_PROP_ACCEL, 
strlen(LIBINPUT_PROP_ACCEL), TRUE);
-   rc = XIChangeDeviceProperty(dev, prop_accel, prop_float, 32,
-   PropModeReplace, 1, speed, FALSE);
-   if (rc != Success)
-   return;
-   XISetDevicePropertyDeletable(dev, prop_accel, FALSE);
-   }
-
-   if (libinput_device_config_scroll_has_natural_scroll(device)) {
-   BOOL natural_scroll = driver_data-options.natural_scrolling;
-
-   prop_natural_scroll = MakeAtom(LIBINPUT_PROP_NATURAL_SCROLL,
-  
strlen(LIBINPUT_PROP_NATURAL_SCROLL),
-  TRUE);
-   rc = XIChangeDeviceProperty(dev, prop_natural_scroll, 
XA_INTEGER, 8,
-   PropModeReplace, 1, 
natural_scroll, FALSE);
-   if (rc != Success)
-   return;
-   XISetDevicePropertyDeletable(dev, prop_natural_scroll, FALSE);
-   }
+
+   libinput_device_config_calibration_get_matrix(device, calibration);
+   calibration[6] = 0;
+   

Re: close-on-exec

2015-02-26 Thread Thomas Klausner
On Wed, Feb 25, 2015 at 02:27:30PM -0800, Alan Coopersmith wrote:
 Solaris has the ancient support for setting the FD_CLOEXEC flag via
 fcntl() in all versions, and the more recent support for the O_CLOEXEC
 flag to open() in Solaris 11 and later, but does not yet support the
 e flag to fopen().  (I've filed an enhancement request to add it to
 our libc in the future, but that doesn't help today.)
 
 I believe the most portable way to do this is:
 
 if (!(addfp = fopen (addAuthFile, w)))
   goto bad;
 else
   fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC);
 
 That would be subject to race conditions in multi-threaded processes, as
 described in https://udrepper.livejournal.com/20407.html, so not safe in
 libraries or programs which deliberately start multiple threads, but since
 xsm is not one of those, it should be mostly safe. (Not completely, because
 we can't be sure nothing we called in a library didn't start a thread behind
 the scenes to handle one of our requests, but without an e flag everywhere,
 I'm not sure what more we can do.  I have no idea how to write a configure
 check to test for fopen(..., e) support either.)

Ok, so let's use fcntl for now, new patch attached.
 Thomas
From e8ea2f72fdb8c6ab38fd8a7b76865695065283cf Mon Sep 17 00:00:00 2001
From: Thomas Klausner w...@netbsd.org
Date: Wed, 25 Feb 2015 22:22:50 +0100
Subject: [PATCH:xsm] Close file descriptors on exec.

Signed-off-by: Thomas Klausner w...@netbsd.org
---
 auth.c | 4 
 choose.c   | 2 ++
 lock.c | 1 +
 remote.c   | 3 ++-
 restart.c  | 1 +
 saveutil.c | 3 +++
 6 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/auth.c b/auth.c
index 5b3bcac..6f355c2 100644
--- a/auth.c
+++ b/auth.c
@@ -156,24 +156,28 @@ SetAuthentication(int count, IceListenObj *listenObjs,
 
 if (!(addfp = fopen (addAuthFile, w)))
goto bad;
+(void)fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC);
 
 if ((remAuthFile = unique_filename (path, .xsm)) == NULL)
goto bad;
 
 if (!(removefp = fopen (remAuthFile, w)))
goto bad;
+(void)fcntl(fileno(removefp), F_SETFD, FD_CLOEXEC);
 #else
 if ((addAuthFile = unique_filename (path, .xsm, fd)) == NULL)
goto bad;
 
 if (!(addfp = fdopen(fd, wb))) 
goto bad;
+(void)fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC);
 
 if ((remAuthFile = unique_filename (path, .xsm, fd)) == NULL)
goto bad;
 
 if (!(removefp = fdopen(fd, wb))) 
goto bad;
+(void)fcntl(fileno(removefp), F_SETFD, FD_CLOEXEC);
 #endif
 
 if ((*authDataEntries = (IceAuthDataEntry *) XtMalloc (
diff --git a/choose.c b/choose.c
index 6459b61..4ec80c3 100644
--- a/choose.c
+++ b/choose.c
@@ -98,6 +98,8 @@ GetSessionNames(int *count_ret, String **short_names_ret,
 if ((dir = opendir (path)) == NULL)
return 0;
 
+(void)fcntl(dirfd(dir), F_SETFD, FD_CLOEXEC);
+
 count = 0;
 
 while ((entry = readdir (dir)) != NULL)
diff --git a/lock.c b/lock.c
index 84c0ee3..7fba1d3 100644
--- a/lock.c
+++ b/lock.c
@@ -121,6 +121,7 @@ GetLockId(const char *session_name)
 {
return (NULL);
 }
+(void)fcntl(fileno(fp), F_SETFD, FD_CLOEXEC);
 
 buf[0] = '\0';
 fscanf (fp, %255s\n, buf);
diff --git a/remote.c b/remote.c
index 54d95ac..1fe1b45 100644
--- a/remote.c
+++ b/remote.c
@@ -111,7 +111,8 @@ remote_start(const char *restart_protocol, const char 
*restart_machine,
default:/* parent */
 
close (pipefd[0]);
-   fp = (FILE *) fdopen (pipefd[1], w);
+   (void)fcntl(pipefd[1], F_SETFD, FD_CLOEXEC);
+   fp = fdopen (pipefd[1], w);
 
fprintf (fp, CONTEXT X\n);
fprintf (fp, DIR %s\n, cwd);
diff --git a/restart.c b/restart.c
index 57663a5..6aae637 100644
--- a/restart.c
+++ b/restart.c
@@ -543,6 +543,7 @@ StartDefaultApps (void)
exit (1);
}
 }
+(void)fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
 
 buf = NULL;
 buflen = 0;
diff --git a/saveutil.c b/saveutil.c
index 091763a..f8a7171 100644
--- a/saveutil.c
+++ b/saveutil.c
@@ -72,6 +72,7 @@ ReadSave(const char *session_name, char **sm_id)
*sm_id = NULL;
return 0;
 }
+(void)fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
 if (verbose)
printf(Reading session save file...\n);
 
@@ -319,6 +320,7 @@ WriteSave(const char *sm_id)
 }
 else
 {
+   (void)fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
fprintf (f, %d\n, SAVEFILE_VERSION);
fprintf (f, %s\n, sm_id);
 
@@ -431,6 +433,7 @@ DeleteSession(const char *session_name)
 if(!f) {
return (0);
 }
+(void)fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
 
 buf = NULL;
 buflen = 0;
-- 
2.3.0

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Generated Code : swapcheck_shape.h

2015-02-26 Thread chris
/*
 * This file generated automatically from shape.xml by gen_swap_check.py.
 * Edit at your peril.
 */

/**
 * @defgroup XCB_Shape_API XCB Shape API
 * @brief Shape XCB Protocol Implementation.
 * @{
 **/

#ifndef __SHAPE_H
#define __SHAPE_H

#include swapcheck_xproto.h

#ifdef __cplusplus
extern C {
#endif

#define XCB_SHAPE_MAJOR_VERSION 1
#define XCB_SHAPE_MINOR_VERSION 1


int
xcb_Shape_QueryVersion_SwapToClient(void *data);

int
xcb_Shape_QueryVersion_SwapFromClient(void *data);

int
xcb_Shape_QueryVersion_Check(void *data);

int
xcb_Shape_Rectangles_SwapToClient(void *data);

int
xcb_Shape_Rectangles_SwapFromClient(void *data);

int
xcb_Shape_Rectangles_Check(void *data);

int
xcb_Shape_Mask_SwapToClient(void *data);

int
xcb_Shape_Mask_SwapFromClient(void *data);

int
xcb_Shape_Mask_Check(void *data);

int
xcb_Shape_Combine_SwapToClient(void *data);

int
xcb_Shape_Combine_SwapFromClient(void *data);

int
xcb_Shape_Combine_Check(void *data);

int
xcb_Shape_Offset_SwapToClient(void *data);

int
xcb_Shape_Offset_SwapFromClient(void *data);

int
xcb_Shape_Offset_Check(void *data);

int
xcb_Shape_QueryExtents_SwapToClient(void *data);

int
xcb_Shape_QueryExtents_SwapFromClient(void *data);

int
xcb_Shape_QueryExtents_Check(void *data);

int
xcb_Shape_SelectInput_SwapToClient(void *data);

int
xcb_Shape_SelectInput_SwapFromClient(void *data);

int
xcb_Shape_SelectInput_Check(void *data);

int
xcb_Shape_InputSelected_SwapToClient(void *data);

int
xcb_Shape_InputSelected_SwapFromClient(void *data);

int
xcb_Shape_InputSelected_Check(void *data);

int
xcb_Shape_GetRectangles_SwapToClient(void *data);

int
xcb_Shape_GetRectangles_SwapFromClient(void *data);

int
xcb_Shape_GetRectangles_Check(void *data);


int
xcb_shape_SwapToClient_dispatch(void *req);
int
xcb_shape_SwapFromClient_dispatch(void *req);
int
xcb_shape_Check_dispatch(void *req);

#ifdef __cplusplus
}
#endif

#endif

/**
 * @}
 */
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Generated Code: swapcheck_xproto.h

2015-02-26 Thread chris
/*
 * This file generated automatically from xproto.xml by gen_swap_check.py.
 * Edit at your peril.
 */

/**
 * @defgroup XCB__API XCB  API
 * @brief  XCB Protocol Implementation.
 * @{
 **/

#ifndef __XPROTO_H
#define __XPROTO_H

#include xorg/misc.h
#include X11/X.h
#include X11/Xproto.h

#ifdef __cplusplus
extern C {
#endif
int
xcb_CHAR2B_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_CHAR2B_SwapFromClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_CHAR2B_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_POINT_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_POINT_SwapFromClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_POINT_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_RECTANGLE_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_RECTANGLE_SwapFromClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_RECTANGLE_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_ARC_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_ARC_SwapFromClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_ARC_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_FORMAT_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_FORMAT_SwapFromClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_FORMAT_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_VISUALTYPE_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_VISUALTYPE_SwapFromClient(void *data, void *afterEnd, uint8_t 
**afterStruct);

int
xcb_VISUALTYPE_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_DEPTH_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_DEPTH_SwapFromClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_DEPTH_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_SCREEN_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_SCREEN_SwapFromClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_SCREEN_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_SetupRequest_SwapToClient(void *data, void *afterEnd, uint8_t 
**afterStruct);

int
xcb_SetupRequest_SwapFromClient(void *data, void *afterEnd, uint8_t 
**afterStruct);

int
xcb_SetupRequest_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_SetupFailed_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_SetupFailed_SwapFromClient(void *data, void *afterEnd, uint8_t 
**afterStruct);

int
xcb_SetupFailed_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_SetupAuthenticate_SwapToClient(void *data, void *afterEnd, uint8_t 
**afterStruct);

int
xcb_SetupAuthenticate_SwapFromClient(void *data, void *afterEnd, uint8_t 
**afterStruct);

int
xcb_SetupAuthenticate_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_Setup_SwapToClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_Setup_SwapFromClient(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_Setup_Check(void *data, void *afterEnd, uint8_t **afterStruct);

int
xcb_CreateWindow_SwapToClient(void *data);

int
xcb_CreateWindow_SwapFromClient(void *data);

int
xcb_CreateWindow_Check(void *data);

int
xcb_ChangeWindowAttributes_SwapToClient(void *data);

int
xcb_ChangeWindowAttributes_SwapFromClient(void *data);

int
xcb_ChangeWindowAttributes_Check(void *data);

int
xcb_GetWindowAttributes_SwapToClient(void *data);

int
xcb_GetWindowAttributes_SwapFromClient(void *data);

int
xcb_GetWindowAttributes_Check(void *data);

int
xcb_DestroyWindow_SwapToClient(void *data);

int
xcb_DestroyWindow_SwapFromClient(void *data);

int
xcb_DestroyWindow_Check(void *data);

int
xcb_DestroySubwindows_SwapToClient(void *data);

int
xcb_DestroySubwindows_SwapFromClient(void *data);

int
xcb_DestroySubwindows_Check(void *data);

int
xcb_ChangeSaveSet_SwapToClient(void *data);

int
xcb_ChangeSaveSet_SwapFromClient(void *data);

int
xcb_ChangeSaveSet_Check(void *data);

int
xcb_ReparentWindow_SwapToClient(void *data);

int
xcb_ReparentWindow_SwapFromClient(void *data);

int
xcb_ReparentWindow_Check(void *data);

int
xcb_MapWindow_SwapToClient(void *data);

int
xcb_MapWindow_SwapFromClient(void *data);

int
xcb_MapWindow_Check(void *data);

int
xcb_MapSubwindows_SwapToClient(void *data);

int
xcb_MapSubwindows_SwapFromClient(void *data);

int
xcb_MapSubwindows_Check(void *data);

int
xcb_UnmapWindow_SwapToClient(void *data);

int
xcb_UnmapWindow_SwapFromClient(void *data);

int
xcb_UnmapWindow_Check(void *data);

int
xcb_UnmapSubwindows_SwapToClient(void *data);

int
xcb_UnmapSubwindows_SwapFromClient(void *data);

int
xcb_UnmapSubwindows_Check(void *data);

int
xcb_ConfigureWindow_SwapToClient(void *data);

int
xcb_ConfigureWindow_SwapFromClient(void *data);

int

Generated Code (Re: [OPW] Generated swapping and size-checking code integration)

2015-02-26 Thread Christian Linhart
Hi all,

Since Asalle is sick since a while,
I post here the generated code from one of the last revisions
of Asalle's repository,
so that we can discuss the generated code here,
( The latest revision of her repo has a make-issue,
so I took the generated code from a workspace that
I have built on Feb 16th)

The general approach of this generator is to treat
fixed-size parts and variable-sized parts of the
protocol the same way. This has the advantage of
making the generator much simpler,
and therefore more reliable and easier to understand
and to maintain.

I'll post the generated code in-message as replies to this
message. This will make commenting the code easier.
(Since I use a web-mailer, some line-breaks may be introduced.
I hope that this will not make much difference.
After all, this is just C-code and not a patch.)

Regards,

Chris 



On 02/16/15 20:46, Asal Mirzaieva wrote:
 Hi all,

 I am the Outreachy (called before OP, OPW) participant for Xorg 
 (www.x.org/wiki/XorgOPW/ http://www.x.org/wiki/XorgOPW/) for project 
 Server-side XCB, my task is to write generator for swapping and 
 size-checking functions and integrate the generated code into Xsever.

 Here is the link tobitbucket bitbucket.org/AsalleKim/gen_swap_check. I 
 didn't create patch, because in my opinion it's pretty inconvenient to send 
 patches with code written from scratch, though it's a powerful tool for 
 maintaining already existing code. The repo contains forked xserver from main 
 xserver repo http://cgit.freedesktop.org/xorg/xserver/. It uses some 
 changes in xcb made by Christian Linhart and Jaya Tiwari, the changes are in 
 pending patches and will be soon applied (if they are not already). This 
 mainly touches the valueparam to switch replacement in xproto.xml.
 As valueparam is deprecated, the generator, I am working on, does not support 
 it.

 Generator's code can process almost all extensions, but I am now mainly 
 working on Shape and Xproto.
 For now it creates source file and header file in the directory proto/gen and 
 then they are built with automake (proto/Makefile.am).

 There are several things I was not sure about.
 1. The working name of the swapping and size-checking functions generator is 
 gen_swap_check, which is rather awkward. But I couldn't invent anything 
 better.

 2. To test the code I need to integrate it to the xserver. I already made 
 some changes into Xext/shape.c so it uses the generated code now. The 
 Xext/shape.h must include the swapcheck_shape.h (generated one). Would it be 
 okay if I copy all generated headers to {installdir}/include/xcb, mixing the 
 genswap-generated code and the regular code, generated by c_client.py? And 
 copy the compiled swapcheck_* files to {installdir}/lib.

 3. proto/Makefile.am is written in such way that no make targets are 
 declared. How can I add cp commad to it?

 4. When building several warnings in included file os.h appeared. How can I 
 get rid of them? Or should I ignore them?
 /home/asalle/xorg/Debug2/test-install/include/xorg/os.h:541:1: warning: 
 redundant redeclaration of 'strndup' [-Wredundant-decls]
 1055  strndup(const char *str, size_t n);
 This is the short overview of swapping and size-checking functions generator,
 I would be glad to hear your comments and messages about found bugs,
 Asalle



 ___
 xorg-devel@lists.x.org: X.Org development
 Archives: http://lists.x.org/archives/xorg-devel
 Info: http://lists.x.org/mailman/listinfo/xorg-devel

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Generated Code: swapcheck_shape.c

2015-02-26 Thread chris
/*
 * This file generated automatically from shape.xml by gen_swap_check.py.
 * Edit at your peril.
 */

#include swapcheck_xproto.h
#include swapcheck_shape.h
#include stdlib.h
#include assert.h
#include stddef.h  /* for offsetof() */
#include errno.h

#define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)


typedef enum xcb_shape_so {
XCB_SHAPE_SO_UNION = 1,
XCB_SHAPE_SO_SET = 0,
XCB_SHAPE_SO_SUBTRACT = 3,
XCB_SHAPE_SO_INTERSECT = 2,
XCB_SHAPE_SO_INVERT = 4,
} xcb_shape_so_t;

typedef enum xcb_shape_sk {
XCB_SHAPE_SK_CLIP = 1,
XCB_SHAPE_SK_BOUNDING = 0,
XCB_SHAPE_SK_INPUT = 2,
} xcb_shape_sk_t;

#define GEN_XCB_SHAPE_RECTANGLES 1
#define GEN_XCB_SHAPE_QUERY_VERSION 0
#define GEN_XCB_SHAPE_COMBINE 3
#define GEN_XCB_SHAPE_MASK 2
#define GEN_XCB_SHAPE_QUERY_EXTENTS 5
#define GEN_XCB_SHAPE_OFFSET 4
#define GEN_XCB_SHAPE_INPUT_SELECTED 7
#define GEN_XCB_SHAPE_SELECT_INPUT 6
#define GEN_XCB_SHAPE_GET_RECTANGLES 8

int
xcb_Shape_QueryVersion_SwapToClient(void *data)
{
//type, field_type, field_name, visible, wire, auto, enum, isfd

uint8_t* p = (uint8_t*)data;
uint8_t* afterEnd = NULL;

//('uint8_t',), major_opcode, False, True, True, None, False
p += 1;

//('uint8_t',), minor_opcode, False, True, True, None, False
p += 1;

//('uint16_t',), length, False, True, True, None, False
afterEnd = ((uint8_t*)data) + 4 *  ( *(uint16_t*)p );
if( p + 2  (uint8_t*)afterEnd)
{
return BadLength;
}
swaps((uint16_t*)p);
p += 2;

if (p == afterEnd)
return Success;
else
return BadLength;
}

int
xcb_Shape_QueryVersion_SwapFromClient(void *data)
{
//type, field_type, field_name, visible, wire, auto, enum, isfd

uint8_t* p = (uint8_t*)data;
uint8_t* afterEnd = NULL;

//('uint8_t',), major_opcode, False, True, True, None, False
p += 1;

//('uint8_t',), minor_opcode, False, True, True, None, False
p += 1;

//('uint16_t',), length, False, True, True, None, False
swaps((uint16_t*)p);
afterEnd = ((uint8_t*)data) + 4 *  ( *(uint16_t*)p );
p += 2;

if (p == afterEnd)
return Success;
else
return BadLength;
}

int
xcb_Shape_QueryVersion_Check(void *data)
{
//type, field_type, field_name, visible, wire, auto, enum, isfd

uint8_t* p = (uint8_t*)data;
uint8_t* afterEnd = NULL;

//('uint8_t',), major_opcode, False, True, True, None, False
p += 1;

//('uint8_t',), minor_opcode, False, True, True, None, False
p += 1;

//('uint16_t',), length, False, True, True, None, False
afterEnd = ((uint8_t*)data) + 4 *  ( *(uint16_t*)p );
p += 2;

if (p == afterEnd)
return Success;
else
return BadLength;
}

int
xcb_Shape_Rectangles_SwapToClient(void *data)
{
//type, field_type, field_name, visible, wire, auto, enum, isfd

uint8_t* p = (uint8_t*)data;
uint8_t* afterStruct = NULL;
uint8_t* afterEnd = NULL;

//('uint8_t',), major_opcode, False, True, True, None, False
p += 1;

//('uint8_t',), minor_opcode, False, True, True, None, False
p += 1;

//('uint16_t',), length, False, True, True, None, False
afterEnd = ((uint8_t*)data) + 4 *  ( *(uint16_t*)p );
if( p + 2  (uint8_t*)afterEnd)
{
return BadLength;
}
swaps((uint16_t*)p);
p += 2;

//('xcb', 'Shape', 'OP'), operation, True, True, False, SO, False
p += 1;

//('xcb', 'Shape', 'KIND'), destination_kind, True, True, False, SK, False
p += 1;

//('uint8_t',), ordering, True, True, False, ClipOrdering, False
p += 1;

//('uint8_t',), pad0, False, True, False, ClipOrdering, False
p += 1;

//('xcb', 'WINDOW'), destination_window, True, True, False, None, False
if( p + 4  (uint8_t*)afterEnd)
{
return BadLength;
}
swapl((uint32_t*)p);
p += 4;

//('int16_t',), x_offset, True, True, False, None, False
if( p + 2  (uint8_t*)afterEnd)
{
return BadLength;
}
swaps((uint16_t*)p);
p += 2;

//('int16_t',), y_offset, True, True, False, None, False
if( p + 2  (uint8_t*)afterEnd)
{
return BadLength;
}
swaps((uint16_t*)p);
p += 2;

//('uint32_t',), rectangles_len, True, False, False, None, False
uint32_t fieldvalue_rectangles_len;
fieldvalue_rectangles_len = *(uint32_t*)p;
if( p + 4  (uint8_t*)afterEnd)
{
return BadLength;
}
swapl((uint32_t*)p);
p += 4;

//('xcb', 'RECTANGLE'), rectangles, True, True, False, None, False
{
unsigned int i_rectangles_len;
for(i_rectangles_len = 0; i_rectangles_len  fieldvalue_rectangles_len; 
i_rectangles_len++)
{
if(xcb_RECTANGLE_SwapToClient(p, afterEnd, afterStruct) != Success)
return BadLength;
p = afterStruct;
 

Re: [PATCH] damage: Only track extents where possible

2015-02-26 Thread Chris Wilson
On Thu, Feb 26, 2015 at 02:58:45PM -0500, Adam Jackson wrote:
 On Wed, 2015-02-25 at 18:01 +, Chris Wilson wrote:
  For external Damage, we need only track sufficient information to
  satisfy the DamageReportLevel. That is if the Client only wishes to hear
  that the Damage is now non-empty or if the extents change, we only need
  to track the extents of the Damage and can discard the actual
  rectangles. This speeds up the union operation, speeding up damage
  processing for Client as well - with a noticeable increase in
  performance of gnome-shell (which uses DamageReportBoundingBox) for
  example.
 
 I like the idea, not quite sold on the realization.
 
  Internal users of Damage have access to the DamageRegion irrespective of
  the DamageReportLevel and so we need to keep the full region intact for
  them.
 
 That's not quite what isInternal means, it's currently used to hide
 software sprite rendering from the protocol event stream.  xwl and
 composite also create their damages with isInternal FALSE.  For xwl that
 could just be fixed since it's not initializing midc, but composite
 really does want that suppression to work.
 
 So I guess the question is whether automatic windows should take the
 bounding box snap too, and I guess whichever method makes x11perf look
 better when 'xcompmgr -a' is good enough for me.

x11perf -aa10text certainly prefers extents-only tracking here. I don't
imagine any other test would regress, but I can check for completeness.

  +static void DamageCombineExtents(DamagePtr pDamage, RegionPtr 
  pDamageRegion)
  +{
  +if (!pDamage-isInternal) {
  +RegionUninit(pDamageRegion);
  +RegionUnion(pDamage-damage, pDamage-damage, pDamageRegion);
  +RegionUninit(pDamage-damage);
  +} else
  +RegionUnion(pDamage-damage, pDamage-damage, pDamageRegion);
  +}
 
 First time I've seen this idiom of relying on RegionUninit to empty the
 rect list but leave the bounding box.  I don't necessarily have an issue
 with it but a comment would be nice.

It was a bit cheeky, and it definitely relies on the current code in 
regionstr.h.
Looking at it again, we can't discard the rectangles from pDamageRegion
as we may be called before the op and so required to keep pPendingDamage
intact.
 
  @@ -1929,7 +1939,7 @@ DamageReportDamage(DamagePtr pDamage, RegionPtr 
  pDamageRegion)
   break;
   case DamageReportBoundingBox:
   tmpBox = *RegionExtents(pDamage-damage);
  -RegionUnion(pDamage-damage, pDamage-damage, pDamageRegion);
  +DamageCombineExtents(pDamage, pDamageRegion);
   if (!BOX_SAME(tmpBox, RegionExtents(pDamage-damage))) {
   (*pDamage-damageReport) (pDamage, pDamage-damage,
 pDamage-closure);
 
 Presumably this half doesn't even need to inspect isInternal, since the
 bounding box is all that's requested in any case.  There are no in-tree
 BoundingBox consumers so nothing can be relying on getting anything more
 detailed in the report hook, and the protocol event snaps to the box
 anyway.

In tree users:

DamageReportNone:
  ephyr - region is used for host migration
  exa - region is used for video memory migrations
  modesetting - region is used to limit shadow updates
  randr - region is used during composite
  shadow(mi) - region is exposed to clients

DamageReportNonEmpty:
  composite - region is used
  exa - region is used
  glamor -  region ignored
  xwayland - only extents used

DamageReportRawRegion:
  shadow(xf86) - rectangles are exposed to clients

The DamageReportNone and DamageReportRawRegion the rectangles are part
of the respective API (though we could just report the extents
rectangle), but for e.g. drm/udl (modesetting, shadow) at least we do
want the raw rectangles and the migration would be very expensive. randr
doesn't know if it will be quick or slow, so must err on the side of
tracking the rectangles. ephyr should be able to determine if it has
quick updates via DRI2/SHM or pushing pixels over the wire.

As for DamageReportNonEmpty, exa has to pessimise that pixel data is slow
to readback and so should track rectangles. xwayland/glamor already
ignore the rectangles. composite however doesn't know whether it will be
faster to ignore rectangles (because the copy is hwaccel) or to track
rectangles... Which is where we can make a decision based on xvfb +
xcompgr -a (and also check with the major ddx).

So because of exa, I think we want a DamageSetTrackExtentsOnly()
function call so that consumers can opt out of the full region tracking.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: close-on-exec

2015-02-26 Thread Alan Coopersmith

On 02/26/15 08:04 AM, Emil Velikov wrote:

On 25/02/15 22:27, Alan Coopersmith wrote:

I'm not sure what more we can do.  I have no idea how to write a configure
check to test for fopen(..., e) support either.)


Something like the following should be ok, but I haven't tested it.

AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#define _POSIX_SOURCE
#include stdio.h

int main () {
 FILE *fp;
 fp = fopen(/tmp/foo, e);
 return 0;
}]])], AC_DEFINE([HAVE_FOPEN_E], [1],
  [Define if fopen(... , e) exists.])
)


Since the argument is just a string, it will compile fine, since I don't
know of any compiler that tries to parse  check fopen() option strings - it
would have to be a runtime test, and I don't know if all implementations
that don't support the e modifier (I think you still need the r or w
base) will report an error from it, or if some just ignore it.

--
-Alan Coopersmith-  alan.coopersm...@oracle.com
 Oracle Solaris Engineering - http://blogs.oracle.com/alanc
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: close-on-exec

2015-02-26 Thread Emil Velikov
On 27 February 2015 at 01:02, Alan Coopersmith
alan.coopersm...@oracle.com wrote:
 On 02/26/15 08:04 AM, Emil Velikov wrote:

 On 25/02/15 22:27, Alan Coopersmith wrote:

 I'm not sure what more we can do.  I have no idea how to write a
 configure
 check to test for fopen(..., e) support either.)

 Something like the following should be ok, but I haven't tested it.

 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
 #define _POSIX_SOURCE
 #include stdio.h

 int main () {
  FILE *fp;
  fp = fopen(/tmp/foo, e);
  return 0;
 }]])], AC_DEFINE([HAVE_FOPEN_E], [1],
   [Define if fopen(... , e) exists.])
 )


 Since the argument is just a string, it will compile fine, since I don't
 know of any compiler that tries to parse  check fopen() option strings - it
 would have to be a runtime test, and I don't know if all implementations
 that don't support the e modifier (I think you still need the r or w
 base) will report an error from it, or if some just ignore it.

Hmm you are correct here. I was naively assuming that the compiler
will parse this and error out.
Ignore I said anything :-)

-Emil
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel