[PATCH 1/2] Remove two unused defines in C files

2009-03-20 Thread Tomas Carnecky
These two defines were defined in C files but not used anywhere:

  dix/window.c  #define DeviceEventMasks (KeyPressMask | [...]
  os/connection.c   #define MAXFD 500

Signed-off-by: Tomas Carnecky t...@dbservice.com
---
 dix/window.c|3 ---
 os/connection.c |1 -
 2 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/dix/window.c b/dix/window.c
index e2669f0..f112f81 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -984,9 +984,6 @@ DestroySubwindows(WindowPtr pWin, ClientPtr client)
 return Success;
 }
 
-#define DeviceEventMasks (KeyPressMask | KeyReleaseMask | ButtonPressMask | \
-ButtonReleaseMask | PointerMotionMask)
-
 /*
  *  ChangeWindowAttributes
  *   
diff --git a/os/connection.c b/os/connection.c
index 14c91b5..a6270b3 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -172,7 +172,6 @@ int *ConnectionTranslation = NULL;
 #define MAXSOCKS 500
 #undef MAXSELECT
 #define MAXSELECT 500
-#define MAXFD 500
 
 struct _ct_node {
 struct _ct_node *next;
-- 
1.6.2


___
xorg-devel mailing list
xorg-devel@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 2/2] FID, whatever that was, isn't anymore

2009-03-20 Thread Tomas Carnecky
No traces of FID in the xserver nor in the modules listed in
util/modular/xorg.modules

Signed-off-by: Tomas Carnecky t...@dbservice.com
---
 include/os.h |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/include/os.h b/include/os.h
index df5c73a..7da31a5 100644
--- a/include/os.h
+++ b/include/os.h
@@ -52,8 +52,6 @@ SOFTWARE.
 #include misc.h
 #include stdarg.h
 
-#define NullFID ((FID) 0)
-
 #define SCREEN_SAVER_ON   0
 #define SCREEN_SAVER_OFF  1
 #define SCREEN_SAVER_FORCER 2
@@ -66,7 +64,6 @@ SOFTWARE.
 #define MAX_BIG_REQUEST_SIZE 4194303
 #endif
 
-typedef pointerFID;
 typedef struct _FontPathRec *FontPathPtr;
 typedef struct _NewClientRec *NewClientPtr;
 
-- 
1.6.2


___
xorg-devel mailing list
xorg-devel@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-devel


[PATCH 3/3] Convert remaining code to use C99 inline

2009-03-20 Thread Tomas Carnecky
But keep compatibility defines for __inline and __inline__ in case
some drivers still use those (hw/xfree86/common/compiler.h).

Signed-off-by: Tomas Carnecky t...@dbservice.com
---

I think this will break drivers if you try to compile them with a compiler
that doesn't support C99 inline. Each driver probably also needs AC_C_INLINE
in its configure.ac. Is there some kind of common AC macro that is executed
by all xorg modules where this check could be added? Or does each module have
to be update individually?

 hw/xfree86/common/compiler.h   |  238 +++-
 hw/xfree86/os-support/bus/linuxPci.c   |2 +-
 hw/xfree86/os-support/misc/BUSmemcpy.c |4 +-
 hw/xfree86/x86emu/sys.c|   12 +-
 hw/xquartz/xpr/x-hash.h|8 +-
 5 files changed, 124 insertions(+), 140 deletions(-)

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 2601693..6810a4c 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -59,25 +59,9 @@
 # include X11/Xfuncproto.h
 #endif
 
-/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
-# ifndef __inline__
-#  if defined(__GNUC__)
-/* gcc has __inline__ */
-#  elif defined(__HIGHC__)
-#   define __inline__ _Inline
-#  else
-#   define __inline__ /**/
-#  endif
-# endif /* __inline__ */
-# ifndef __inline
-#  if defined(__GNUC__)
-/* gcc has __inline */
-#  elif defined(__HIGHC__)
-#   define __inline _Inline
-#  else
-#   define __inline /**/
-#  endif
-# endif /* __inline */
+/* FIXME: Remove once all drivers and other external modules are ported */
+#define __inline inline
+#define __inline__ inline
 
 /* Support gcc's __FUNCTION__ for people using other compilers */
 #if !defined(__GNUC__)  !defined(__FUNCTION__)
@@ -137,42 +121,42 @@ extern unsigned short ldw_brx(volatile unsigned char *, 
int);
 /*  *before* any inx/outx is done. */
 
 extern _X_EXPORT void (*_alpha_outb)(char val, unsigned long port);
-static __inline__ void
+static inline void
 outb(unsigned long port, unsigned char val)
 {
 _alpha_outb(val, port);
 }
 
 extern _X_EXPORT void (*_alpha_outw)(short val, unsigned long port);
-static __inline__ void
+static inline void
 outw(unsigned long port, unsigned short val)
 {
 _alpha_outw(val, port);
 }
 
 extern _X_EXPORT void (*_alpha_outl)(int val, unsigned long port);
-static __inline__ void
+static inline void
 outl(unsigned long port, unsigned int val)
 {
 _alpha_outl(val, port);
 }
 
 extern _X_EXPORT unsigned int (*_alpha_inb)(unsigned long port);
-static __inline__ unsigned int
+static inline unsigned int
 inb(unsigned long port)
 {
   return _alpha_inb(port);
 }
 
 extern _X_EXPORT unsigned int (*_alpha_inw)(unsigned long port);
-static __inline__ unsigned int
+static inline unsigned int
 inw(unsigned long port)
 {
   return _alpha_inw(port);
 }
 
 extern _X_EXPORT unsigned int (*_alpha_inl)(unsigned long port);
-static __inline__ unsigned int
+static inline unsigned int
 inl(unsigned long port)
 {
   return _alpha_inl(port);
@@ -221,7 +205,7 @@ struct __una_u16 { unsigned short x 
__attribute__((packed)); };
  */
 /* let's try making these things static */
 
-static __inline__ unsigned long ldq_u(unsigned long * r11)
+static inline unsigned long ldq_u(unsigned long * r11)
 {
 #if defined(__GNUC__)
const struct __una_u64 *ptr = (const struct __una_u64 *) r11;
@@ -240,7 +224,7 @@ static __inline__ unsigned long ldq_u(unsigned long * r11)
 #endif
 }
 
-static __inline__ unsigned long ldl_u(unsigned int * r11)
+static inline unsigned long ldl_u(unsigned int * r11)
 {
 #if defined(__GNUC__)
const struct __una_u32 *ptr = (const struct __una_u32 *) r11;
@@ -259,7 +243,7 @@ static __inline__ unsigned long ldl_u(unsigned int * r11)
 #endif
 }
 
-static __inline__ unsigned long ldw_u(unsigned short * r11)
+static inline unsigned long ldw_u(unsigned short * r11)
 {
 #if defined(__GNUC__)
const struct __una_u16 *ptr = (const struct __una_u16 *) r11;
@@ -282,7 +266,7 @@ static __inline__ unsigned long ldw_u(unsigned short * r11)
  * Elemental unaligned stores 
  */
 
-static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
+static inline void stq_u(unsigned long r5, unsigned long * r11)
 {
 #if defined(__GNUC__)
struct __una_u64 *ptr = (struct __una_u64 *) r11;
@@ -307,7 +291,7 @@ static __inline__ void stq_u(unsigned long r5, unsigned 
long * r11)
 #endif
 }
 
-static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
+static inline void stl_u(unsigned long r5, unsigned int * r11)
 {
 #if defined(__GNUC__)
struct __una_u32 *ptr = (struct __una_u32 *) r11;
@@ -332,7 +316,7 @@ static __inline__ void stl_u(unsigned long r5, unsigned int 
* r11)
 #endif
 }
 
-static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
+static inline void stw_u(unsigned long r5, unsigned short * r11)
 {
 #if defined(__GNUC__)

[PATCH] DDC: Add EDID caching

2009-03-20 Thread Adam Jackson
Attempt to detect when we're DDC'ing the same monitor on the same output
as we did last time.  The first 16 bytes of EDID is almost certainly
sufficient to identify a monitor uniquely, as it contains the vendor ID,
model ID, and serial number fields.

This takes 'xrandr -q' on my machine down from ~170ms to ~50ms.  That's
still three frames, but at least it's not ten.  However, the win isn't
perfectly reliable, occasionally it still takes a fair amount of time.
This might be as much to do with DDC timing bugs and retries as anything
else.

Patch is against 1.6.0, but applies with only minor massaging to master.

---
 hw/xfree86/ddc/xf86DDC.c|  176 ---
 hw/xfree86/ddc/xf86DDC.h|1 +
 hw/xfree86/modes/xf86Crtc.c |   10 ++-
 3 files changed, 140 insertions(+), 47 deletions(-)

diff --git a/hw/xfree86/ddc/xf86DDC.c b/hw/xfree86/ddc/xf86DDC.c
index 0d86776..ac80241 100644
--- a/hw/xfree86/ddc/xf86DDC.c
+++ b/hw/xfree86/ddc/xf86DDC.c
@@ -150,64 +150,115 @@ EEDIDStop(I2CDevPtr d)
 {
 }
 
-/* block is the EDID block number.  a segment is two blocks. */
+enum {
+DDC2_FAILURE,
+DDC2_SUCCESS,
+DDC2_CACHED,
+};
+
 static Bool
-DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer)
+DDC2SetSegment(I2CDevPtr dev, int block)
 {
-unsigned char W_Buffer[1];
-int i, segment;
+unsigned char W_Buffer;
 I2CDevPtr seg;
 void (*stop)(I2CDevPtr);
+int segment = block  1;
 
-for (i = 0; i  RETRIES; i++) {
-   /* Stop bits reset the segment pointer to 0, so be careful here. */
-   segment = block  1;
-   if (segment) {
-   Bool b;
-   
-   if (!(seg = xf86I2CFindDev(dev-pI2CBus, 0x0060)))
-   return FALSE;
+/* Stop bits reset the segment pointer to 0, so be careful here. */
+if (segment) {
+   Bool b;
 
-   W_Buffer[0] = segment;
+   if (!(seg = xf86I2CFindDev(dev-pI2CBus, 0x0060)))
+   return FALSE;
 
-   stop = dev-pI2CBus-I2CStop;
-   dev-pI2CBus-I2CStop = EEDIDStop;
+   W_Buffer = segment;
 
-   b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
+   stop = dev-pI2CBus-I2CStop;
+   dev-pI2CBus-I2CStop = EEDIDStop;
 
-   dev-pI2CBus-I2CStop = stop;
-   if (!b) {
-   dev-pI2CBus-I2CStop(dev);
-   continue;
+   b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
+
+   dev-pI2CBus-I2CStop = stop;
+   if (!b) {
+   dev-pI2CBus-I2CStop(dev);
+   return FALSE;
+   }
+}
+
+return TRUE;
+}
+
+/* Hacked version of I2CWriteRead for early bailout */
+int
+DDC2WriteRead(I2CDevPtr d, I2CByte *WriteBuffer, int nWrite,
+ I2CByte *ReadBuffer, int nRead, xf86MonPtr old)
+{
+I2CByte *rb = ReadBuffer;
+int r = TRUE;
+I2CBusPtr b = d-pI2CBus;
+int s = 0;
+
+if (r  nWrite  0) {
+   r = b-I2CAddress(d, d-SlaveAddr  ~1);
+   if (r) {
+   for (; nWrite  0; WriteBuffer++, nWrite--)
+   if (!(r = b-I2CPutByte(d, *WriteBuffer))) 
+   break;
+   s++;
+   }
+}
+
+if (r  nRead  0) {
+   r = b-I2CAddress(d, d-SlaveAddr | 1);
+   if (r) {
+   for (; nRead  0; ReadBuffer++, nRead--) {
+   if (!(r = b-I2CGetByte(d, ReadBuffer, nRead == 1))) 
+   break;
+   if ((nRead == EDID1_LEN - 16)  old  old-rawData 
+   !memcmp(old-rawData, rb, 16)) {
+   r = DDC2_CACHED;
+   break;
+   }
}
+   s++;
}
+}
+
+if (s) b-I2CStop(d);
+
+return r;
+}
+
+/* block is the EDID block number.  a segment is two blocks. */
+static int
+DDC2GetBlock(I2CDevPtr dev, int block, unsigned char *R_Buffer, xf86MonPtr old)
+{
+unsigned char W_Buffer[1];
+int i, ret;
+
+if (block != 0)
+   old = NULL;
+
+for (i = 0; i  RETRIES; i++) {
+   if (!DDC2SetSegment(dev, block))
+   return FALSE;
 
W_Buffer[0] = (block  0x01) * EDID1_LEN;
 
-   if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) {
-   if (!DDC_checksum(R_Buffer, EDID1_LEN))
-   return TRUE;
-   }
+   ret = DDC2WriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN, old);
+
+   if (ret == DDC2_CACHED)
+   return DDC2_CACHED;
+   if (ret == DDC2_SUCCESS  !DDC_checksum(R_Buffer, EDID1_LEN))
+   return DDC2_SUCCESS;
+   /* else continue */
 }
  
 return FALSE;
 }
 
-/**
- * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are
- * unset.  EDID information blocks are interpreted and the results returned in
- * an xf86MonPtr.  Unlike xf86DoEDID_DDC[12](), this function will return
- * the complete EDID data, including all extension blocks, if the 'complete'
- * parameter is TRUE;
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to 

Re: Default local auth policy

2009-03-20 Thread Eric Anholt
On Tue, 2009-03-17 at 14:06 -0400, Adam Jackson wrote:
 On Mon, 2009-03-16 at 12:52 -0700, Eric Anholt wrote:
  On Fri, 2009-03-13 at 13:46 -0400, Adam Jackson wrote:
   Currently, if you start X without -ac and without -auth, the default
   connection policy is to allow connections from localhost.  In
   particular, this means on every IPv[46] address, and any local
   transports including unix sockets.
   
   I'd like to see a mode where the default policy is effectively
   +si:localuser:`id -un`, which would allow connections only from the uid
   that started the server.  This is effectively the policy everyone's
   trying to implement with xauth cookies, but cookies have to get stored
   on disk somewhere which sucks for NFS and r/o images, etc.  For the gdm
   case, the display manager would add the real user to the access list
   once they've been authed, and then remove itself and start the session
   as the user.
   
   Normally I'd just change the default here, but I think this might be a
   significant enough difference in behaviour that you should have to ask
   for it.  So.  New -localuser option?  Change the default?  Bad idea,
   give up, take up farming?
  
  It sounds sensible, the only thing I'm concerned about is whether with
  this new default I could sudo X app and still get success.
 
 It's not particularly well specified, at least for
 getsockopt(SO_PEERCRED).  The Linux implementation appears to give you
 the effective UID, not real, so suid apps would fail.  I'm not sure what
 the other OS's implement offhand.

And sudo would fail as well?  That's extremely uncool.  Unless the plan
is to add +si:localuser:0 as well.

-- 
Eric Anholt
e...@anholt.net eric.anh...@intel.com




signature.asc
Description: This is a digitally signed message part
___
xorg-devel mailing list
xorg-devel@lists.x.org
http://lists.x.org/mailman/listinfo/xorg-devel