From 3b5b7ef5c2ab1d196806f6359e0972fd78d204dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B6glund?= Date: Wed, 3 Jan 2007 21:05:35 +0100 Subject: [PATCH 1/5] Move the code for resetting the DPMS mode in response to input events, from WaitForSomething to mieqProcessInputEvents. mieqProcessInputEvents already handles resetting the screen saver. --- mi/mieq.c | 13 +++++++++++++ os/WaitFor.c | 5 +---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/mi/mieq.c b/mi/mieq.c index 80915fd73..507cdd337 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -52,6 +52,12 @@ in this Software without prior written authorization from The Open Group. # include "extinit.h" # include "exglobals.h" +#ifdef DPMSExtension +# include "dpmsproc.h" +# define DPMS_SERVER +# include +#endif + #define QUEUE_SIZE 256 typedef struct _Event { @@ -183,6 +189,13 @@ mieqProcessInputEvents() while (miEventQueue.head != miEventQueue.tail) { if (screenIsSaved == SCREEN_SAVER_ON) SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset); +#ifdef DPMSExtension + else if (DPMSPowerLevel != DPMSModeOn) + SetScreenSaverTimer(); + + if (DPMSPowerLevel != DPMSModeOn) + DPMSSet(DPMSModeOn); +#endif e = &miEventQueue.events[miEventQueue.head]; /* Assumption - screen switching can only occur on motion events. */ diff --git a/os/WaitFor.c b/os/WaitFor.c index ba227a3b6..d39964f30 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -337,10 +337,7 @@ WaitForSomething(int *pClientsReady) if (XFD_ANYSET(&tmp_set)) QueueWorkProc(EstablishNewConnections, NULL, (pointer)&LastSelectMask); -#ifdef DPMSExtension - if (XFD_ANYSET (&devicesReadable) && (DPMSPowerLevel != DPMSModeOn)) - DPMSSet(DPMSModeOn); -#endif + if (XFD_ANYSET (&devicesReadable) || XFD_ANYSET (&clientsReadable)) break; #ifdef WIN32 From 66fa87292ef26bd0f464481287f3af992cd5741c Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Wed, 3 Jan 2007 10:27:07 -0800 Subject: [PATCH 2/5] Fix BSF and BSR instructions in the x86 emulator. Patch courtesy of Michael Yaroslavtsev. --- hw/xfree86/x86emu/ops2.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/hw/xfree86/x86emu/ops2.c b/hw/xfree86/x86emu/ops2.c index 4bf95c182..7b0156aaa 100644 --- a/hw/xfree86/x86emu/ops2.c +++ b/hw/xfree86/x86emu/ops2.c @@ -2129,7 +2129,7 @@ static void x86emuOp2_bsf(u8 X86EMU_UNUSED(op2)) uint srcoffset; START_OF_INSTR(); - DECODE_PRINTF("BSF\n"); + DECODE_PRINTF("BSF\t"); FETCH_DECODE_MODRM(mod, rh, rl); switch(mod) { case 0: @@ -2209,25 +2209,25 @@ static void x86emuOp2_bsf(u8 X86EMU_UNUSED(op2)) break; case 3: /* register to register */ if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg, *dstreg; + u32 srcval, *dstreg; - srcreg = DECODE_RM_LONG_REGISTER(rl); + srcval = *DECODE_RM_LONG_REGISTER(rl); DECODE_PRINTF(","); dstreg = DECODE_RM_LONG_REGISTER(rh); TRACE_AND_STEP(); - CONDITIONAL_SET_FLAG(*srcreg == 0, F_ZF); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); for(*dstreg = 0; *dstreg < 32; (*dstreg)++) - if ((*srcreg >> *dstreg) & 1) break; + if ((srcval >> *dstreg) & 1) break; } else { - u16 *srcreg, *dstreg; + u16 srcval, *dstreg; - srcreg = DECODE_RM_WORD_REGISTER(rl); + srcval = *DECODE_RM_WORD_REGISTER(rl); DECODE_PRINTF(","); dstreg = DECODE_RM_WORD_REGISTER(rh); TRACE_AND_STEP(); - CONDITIONAL_SET_FLAG(*srcreg == 0, F_ZF); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); for(*dstreg = 0; *dstreg < 16; (*dstreg)++) - if ((*srcreg >> *dstreg) & 1) break; + if ((srcval >> *dstreg) & 1) break; } break; } @@ -2245,7 +2245,7 @@ static void x86emuOp2_bsr(u8 X86EMU_UNUSED(op2)) uint srcoffset; START_OF_INSTR(); - DECODE_PRINTF("BSF\n"); + DECODE_PRINTF("BSR\t"); FETCH_DECODE_MODRM(mod, rh, rl); switch(mod) { case 0: @@ -2325,25 +2325,25 @@ static void x86emuOp2_bsr(u8 X86EMU_UNUSED(op2)) break; case 3: /* register to register */ if (M.x86.mode & SYSMODE_PREFIX_DATA) { - u32 *srcreg, *dstreg; + u32 srcval, *dstreg; - srcreg = DECODE_RM_LONG_REGISTER(rl); + srcval = *DECODE_RM_LONG_REGISTER(rl); DECODE_PRINTF(","); dstreg = DECODE_RM_LONG_REGISTER(rh); TRACE_AND_STEP(); - CONDITIONAL_SET_FLAG(*srcreg == 0, F_ZF); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); for(*dstreg = 31; *dstreg > 0; (*dstreg)--) - if ((*srcreg >> *dstreg) & 1) break; + if ((srcval >> *dstreg) & 1) break; } else { - u16 *srcreg, *dstreg; + u16 srcval, *dstreg; - srcreg = DECODE_RM_WORD_REGISTER(rl); + srcval = *DECODE_RM_WORD_REGISTER(rl); DECODE_PRINTF(","); dstreg = DECODE_RM_WORD_REGISTER(rh); TRACE_AND_STEP(); - CONDITIONAL_SET_FLAG(*srcreg == 0, F_ZF); + CONDITIONAL_SET_FLAG(srcval == 0, F_ZF); for(*dstreg = 15; *dstreg > 0; (*dstreg)--) - if ((*srcreg >> *dstreg) & 1) break; + if ((srcval >> *dstreg) & 1) break; } break; } From 2fd4626fa6969b84d8e2f9db16d6e2d44c4bc499 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Wed, 3 Jan 2007 15:44:55 -0800 Subject: [PATCH 3/5] Make GLX byteswap macros more portable - Use autoconf tests instead of platform-specific #ifdef's to decide which macros to use. - Provide fallbacks for platforms like Solaris that don't provide any of the existing known forms. --- GL/glx/indirect_dispatch_swap.c | 26 +++++++----- GL/glx/indirect_program.c | 22 +++++----- GL/glx/indirect_texture_compression.c | 22 +++++----- GL/glx/indirect_util.c | 26 +++++++----- GL/glx/swap_interval.c | 22 +++++----- configure.ac | 58 +++++++++++++++++++++++++++ include/dix-config.h.in | 15 +++++++ 7 files changed, 146 insertions(+), 45 deletions(-) diff --git a/GL/glx/indirect_dispatch_swap.c b/GL/glx/indirect_dispatch_swap.c index 136f0d010..4fee8eed6 100644 --- a/GL/glx/indirect_dispatch_swap.c +++ b/GL/glx/indirect_dispatch_swap.c @@ -25,21 +25,29 @@ * SOFTWARE. */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + #include #include #include -#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) +#if defined(HAVE_BYTESWAP_H) #include -#elif defined(__OpenBSD__) +#elif defined(USE_SYS_ENDIAN_H) #include -#define bswap_16 __swap16 -#define bswap_32 __swap32 -#define bswap_64 __swap64 #else -#include -#define bswap_16 bswap16 -#define bswap_32 bswap32 -#define bswap_64 bswap64 +#define bswap_16(value) \ + ((((value) & 0xff) << 8) | ((value) >> 8)) + +#define bswap_32(value) \ + (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ + (uint32_t)bswap_16((uint16_t)((value) >> 16))) + +#define bswap_64(value) \ + (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ + << 32) | \ + (uint64_t)bswap_32((uint32_t)((value) >> 32))) #endif #include #include "indirect_size.h" diff --git a/GL/glx/indirect_program.c b/GL/glx/indirect_program.c index 8d5f0e60f..8372191f7 100644 --- a/GL/glx/indirect_program.c +++ b/GL/glx/indirect_program.c @@ -46,18 +46,22 @@ #include "dispatch.h" #include "glapioffsets.h" -#if defined(__linux__) || defined (__GLIBC__) || defined (__GNU__) +#if defined(HAVE_BYTESWAP_H) #include -#elif defined(__OpenBSD__) +#elif defined(USE_SYS_ENDIAN_H) #include -#define bswap_16 __swap16 -#define bswap_32 __swap32 -#define bswap_64 __swap64 #else -#include -#define bswap_16 bswap16 -#define bswap_32 bswap32 -#define bswap_64 bswap64 +#define bswap_16(value) \ + ((((value) & 0xff) << 8) | ((value) >> 8)) + +#define bswap_32(value) \ + (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ + (uint32_t)bswap_16((uint16_t)((value) >> 16))) + +#define bswap_64(value) \ + (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ + << 32) | \ + (uint64_t)bswap_32((uint32_t)((value) >> 32))) #endif static int DoGetProgramString(struct __GLXclientStateRec *cl, GLbyte *pc, diff --git a/GL/glx/indirect_texture_compression.c b/GL/glx/indirect_texture_compression.c index 35af1d235..801579d18 100644 --- a/GL/glx/indirect_texture_compression.c +++ b/GL/glx/indirect_texture_compression.c @@ -39,18 +39,22 @@ #include "glthread.h" #include "dispatch.h" -#if defined(__linux__) || defined (__GLIBC__) || defined (__GNU__) +#if defined(HAVE_BYTESWAP_H) #include -#elif defined(__OpenBSD__) +#elif defined(USE_SYS_ENDIAN_H) #include -#define bswap_16 __swap16 -#define bswap_32 __swap32 -#define bswap_64 __swap64 #else -#include -#define bswap_16 bswap16 -#define bswap_32 bswap32 -#define bswap_64 bswap64 +#define bswap_16(value) \ + ((((value) & 0xff) << 8) | ((value) >> 8)) + +#define bswap_32(value) \ + (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ + (uint32_t)bswap_16((uint16_t)((value) >> 16))) + +#define bswap_64(value) \ + (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ + << 32) | \ + (uint64_t)bswap_32((uint32_t)((value) >> 32))) #endif int __glXDisp_GetCompressedTexImageARB(struct __GLXclientStateRec *cl, GLbyte *pc) diff --git a/GL/glx/indirect_util.c b/GL/glx/indirect_util.c index 09b7ab87c..d72e40744 100644 --- a/GL/glx/indirect_util.c +++ b/GL/glx/indirect_util.c @@ -23,23 +23,31 @@ * SOFTWARE. */ +#ifdef HAVE_DIX_CONFIG_H +#include +#endif + #include #include #include #include -#if defined(__linux__) || defined (__GLIBC__) || defined(__GNU__) +#if defined(HAVE_BYTESWAP_H) #include -#elif defined(__OpenBSD__) +#elif defined(USE_SYS_ENDIAN_H) #include -#define bswap_16 __swap16 -#define bswap_32 __swap32 -#define bswap_64 __swap64 #else -#include -#define bswap_16 bswap16 -#define bswap_32 bswap32 -#define bswap_64 bswap64 +#define bswap_16(value) \ + ((((value) & 0xff) << 8) | ((value) >> 8)) + +#define bswap_32(value) \ + (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ + (uint32_t)bswap_16((uint16_t)((value) >> 16))) + +#define bswap_64(value) \ + (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ + << 32) | \ + (uint64_t)bswap_32((uint32_t)((value) >> 32))) #endif #include #include "indirect_size.h" diff --git a/GL/glx/swap_interval.c b/GL/glx/swap_interval.c index c4137c1aa..e5b48a6ef 100644 --- a/GL/glx/swap_interval.c +++ b/GL/glx/swap_interval.c @@ -40,18 +40,22 @@ #include "dispatch.h" #include "glapioffsets.h" -#if defined(__linux__) || defined (__GLIBC__) || defined (__GNU__) +#if defined(HAVE_BYTESWAP_H) #include -#elif defined(__OpenBSD__) +#elif defined(USE_SYS_ENDIAN_H) #include -#define bswap_16 __swap16 -#define bswap_32 __swap32 -#define bswap_64 __swap64 #else -#include -#define bswap_16 bswap16 -#define bswap_32 bswap32 -#define bswap_64 bswap64 +#define bswap_16(value) \ + ((((value) & 0xff) << 8) | ((value) >> 8)) + +#define bswap_32(value) \ + (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ + (uint32_t)bswap_16((uint16_t)((value) >> 16))) + +#define bswap_64(value) \ + (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ + << 32) | \ + (uint64_t)bswap_32((uint32_t)((value) >> 32))) #endif static int DoSwapInterval(__GLXclientState *cl, GLbyte *pc, int do_swap); diff --git a/configure.ac b/configure.ac index 491bdd511..278502be9 100644 --- a/configure.ac +++ b/configure.ac @@ -99,6 +99,64 @@ fi AC_TYPE_PID_T +# Checks for headers/macros for byte swapping +# Known variants: +# bswap_16, bswap_32, bswap_64 (glibc) +# __swap16, __swap32, __swap64 (OpenBSD) +# bswap16, bswap32, bswap64 (other BSD's) +# and a fallback to local macros if none of the above are found + +# if is found, assume it's the correct version +AC_CHECK_HEADERS([byteswap.h]) + +# if is found, have to check which version +AC_CHECK_HEADER([sys/endian.h], [HAVE_SYS_ENDIAN_H="yes"], [HAVE_SYS_ENDIAN_H="no"]) + +if test "x$HAVE_SYS_ENDIAN_H" = "xyes" ; then + AC_MSG_CHECKING([for __swap16 variant of byteswapping macros]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include + ], [ +int a = 1, b; +b = __swap16(a); + ]) +], [SYS_ENDIAN__SWAP='yes'], [SYS_ENDIAN__SWAP='no']) + AC_MSG_RESULT([$SYS_ENDIAN__SWAP]) + + AC_MSG_CHECKING([for bswap_16 variant of byteswapping macros]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include + ], [ +int a = 1, b; +b = bswap_16(a); + ]) +], [SYS_ENDIAN_BSWAP='yes'], [SYS_ENDIAN_BSWAP='no']) + AC_MSG_RESULT([$SYS_ENDIAN_BSWAP]) + + if test "$SYS_ENDIAN_BSWAP" = "yes" ; then + USE_SYS_ENDIAN_H=yes + BSWAP=bswap_ + else + if test "$SYS_ENDIAN__SWAP" = "yes" ; then + USE_SYS_ENDIAN_H=yes + BSWAP=__swap + else + USE_SYS_ENDIAN_H=no + fi + fi + + if test "$USE_SYS_ENDIAN_H" = "yes" ; then + AC_DEFINE([USE_SYS_ENDIAN_H], 1, + [Define to use byteswap macros from ]) + AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, + [Define to 16-bit byteswap macro]) + AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, + [Define to 32-bit byteswap macro]) + AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, + [Define to 64-bit byteswap macro]) + fi +fi + dnl Checks for library functions. AC_FUNC_VPRINTF AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \ diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 7aabae2ec..6bf27865c 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -93,6 +93,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ASM_MTRR_H +/* Define to 1 if you have the header file. */ +#undef HAVE_BYTESWAP_H + /* Define to 1 if you have the header file. */ #undef HAVE_DBM_H @@ -311,6 +314,9 @@ /* Use rgb.txt directly */ #undef USE_RGB_TXT +/* Define to use byteswap macros from */ +#undef USE_SYS_ENDIAN_H + /* unaligned word accesses behave as expected */ #undef WORKING_UNALIGNED_INT @@ -469,4 +475,13 @@ /* Path to XErrorDB file */ #undef XERRORDB_PATH +/* Define to 16-bit byteswap macro */ +#undef bswap_16 + +/* Define to 32-bit byteswap macro */ +#undef bswap_32 + +/* Define to 64-bit byteswap macro */ +#undef bswap_64 + #endif /* _DIX_CONFIG_H_ */ From aab2ca204279b638c7e5bb6b8427c58be9704c57 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 21 Dec 2006 09:16:19 -0800 Subject: [PATCH 4/5] Try dlsym(RTLD_DEFAULT) first when finding symbols. The previous mechanism failed when finding drm symbols now that libdrm has moved to being linked by libdri instead of being linked into the server. --- hw/xfree86/loader/dlloader.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/xfree86/loader/dlloader.c b/hw/xfree86/loader/dlloader.c index a0e867056..2afdef789 100644 --- a/hw/xfree86/loader/dlloader.c +++ b/hw/xfree86/loader/dlloader.c @@ -113,6 +113,10 @@ DLFindSymbol(const char *name) DLModuleList *l; void *p; + p = dlsym(RTLD_DEFAULT, name); + if (p != NULL) + return p; + for (l = dlModuleList; l != NULL; l = l->next) { p = DLFindSymbolLocal(l->module, name); if (p) From 7d2ec92170ebbdfa10a05734cb7cfaac97d19d65 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 4 Jan 2007 12:24:48 -0800 Subject: [PATCH 5/5] Keep track of how many visuals we set up for GLcore, to avoid an invalid free. The proper fix would involve actually setting up the ARGB visual for GLcore, but I just want the server to not crash at exit. --- GL/mesa/X/xf86glx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GL/mesa/X/xf86glx.c b/GL/mesa/X/xf86glx.c index 94959d628..47c87f6d9 100644 --- a/GL/mesa/X/xf86glx.c +++ b/GL/mesa/X/xf86glx.c @@ -78,6 +78,7 @@ typedef struct __GLXMESAdrawable __GLXMESAdrawable; struct __GLXMESAscreen { __GLXscreen base; int index; + int num_vis; XMesaVisual *xm_vis; }; @@ -280,7 +281,7 @@ __glXMesaScreenDestroy(__GLXscreen *screen) __GLXMESAscreen *mesaScreen = (__GLXMESAscreen *) screen; int i; - for (i = 0; i < screen->numVisuals; i++) { + for (i = 0; i < mesaScreen->num_vis; i++) { if (mesaScreen->xm_vis[i]) XMesaDestroyVisual(mesaScreen->xm_vis[i]); } @@ -389,6 +390,7 @@ static void init_screen_visuals(__GLXMESAscreen *screen) xfree(used); + screen->num_vis = pScreen->numVisuals; screen->xm_vis = pXMesaVisual; }