Commit Graph

74 Commits

Author SHA1 Message Date
Aaron Plattner 4308f5d3d1 os: Don't crash in AttendClient if the client is gone
If a client is in the process of being closed down, then its client->osPrivate
pointer will be set to NULL by CloseDownConnection. This can cause a crash if
freeing the client's resources results in a call to AttendClient. For example,
if the client has a pending sync fence:

 Thread 1 "X" received signal SIGSEGV, Segmentation fault.
 AttendClient (client=0x5571c4aed9a0) at ../os/connection.c:942
 (gdb) bt
 #0  AttendClient (client=0x5571c4aed9a0) at ../os/connection.c:942
 #1  0x00005571c3dbb865 in SyncAwaitTriggerFired (pTrigger=<optimized out>) at ../Xext/sync.c:694
 #2  0x00005571c3dd5749 in miSyncDestroyFence (pFence=0x5571c5063980) at ../miext/sync/misync.c:120
 #3  0x00005571c3dbbc69 in FreeFence (obj=<optimized out>, id=<optimized out>) at ../Xext/sync.c:1909
 #4  0x00005571c3d7a01d in doFreeResource (res=0x5571c506e3d0, skip=skip@entry=0) at ../dix/resource.c:880
 #5  0x00005571c3d7b1dc in FreeClientResources (client=0x5571c4aed9a0) at ../dix/resource.c:1146
 #6  FreeClientResources (client=0x5571c4aed9a0) at ../dix/resource.c:1109
 #7  0x00005571c3d5525f in CloseDownClient (client=0x5571c4aed9a0) at ../dix/dispatch.c:3473
 #8  0x00005571c3d55eeb in Dispatch () at ../dix/dispatch.c:492
 #9  0x00005571c3d59e96 in dix_main (argc=3, argv=0x7ffe7854bc28, envp=<optimized out>) at ../dix/main.c:276
 #10 0x00007fea4837cb6b in __libc_start_main (main=0x5571c3d1d060 <main>, argc=3, argv=0x7ffe7854bc28, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffe7854bc18) at ../csu/libc-start.c:308
 #11 0x00005571c3d1d09a in _start () at ../Xext/sync.c:2378
 (gdb) print client->osPrivate
 $1 = (void *) 0x0

Since the client is about to be freed, its ignore count doesn't matter and
AttendClient can simply be a no-op. Check for client->clientGone in AttendClient
and remove similar checks from two callers that had them.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
2019-11-19 10:15:05 -08:00
Ray Strode 8738ce85df dix: ensure work queues are cleared on reset
If the server resets, most client workqueues are cleaned up as the
clients are killed.

The one exception is the server's client, which is exempt from
the killing spree.

If that client has a queued work procedure active, it won't get
cleared on reset.

This commit ensures it gets cleared too.
2018-11-19 19:37:10 +00:00
Keith Packard 9d15912aa4 Remove fd_set from Block/Wakeup handler API
This removes the last uses of fd_set from the server interfaces
outside of the OS layer itself.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:27:51 -04:00
Keith Packard fb0802113b Remove readmask from screen block/wakeup handler
With no users of the interface needing the readmask anymore, we can
remove it from the argument passed to these functions.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-07-18 15:27:51 -04:00
Keith Packard fb1edccf3c dix: Call screen block/wakeup handlers closest to blocking [v3]
The screen block and wakeup handlers are the only ones which provide a
well known ordering between the wrapping layers; placing these as
close as possible to the server blocking provides a way for the driver
to control the flow of execution correctly.

Switch the shadow code to run in the screen block handler so that it
now occurrs just before the server goes to sleep.

Switch glamor to call down to the driver after it has executed its own
block handler piece, in case the driver needs to perform additional
flushing work after glamor has called glFlush.

These changes ensure that the following modules update the screen in
the correct order:

animated cursors        (uses RegisterBlockAndWakeupHandlers dynamically)
composite               (dynamic wrapping)
misprite                (dynamic wrapping)
shadow                  (static wrapping)
glamor                  (static wrapping)
driver                  (static wrapping)

It looks like there's still a bit of confusion between composite and
misprite; if composite updates after misprite, then it's possible
you'd exit the block handler chain with the cursor left hidden. To fix
that, misprite should be wrapping during ScreenInit time and not
unwrapping. And composite might as well join in that fun, just to make
things consistent.

[v2] Unwrap BlockHandler in shadowCloseScreen (ajax)
[v3] ephyr: Use screen block handler for flushing changes

ephyr needs to make sure it calls glXSwapBuffers after glamor finishes
its rendering. As the screen block handler is now called last, we have
to use that instead of a registered block/wakeup handler to make sure
the GL rendering is done before we copy it to the front buffer.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2016-06-20 11:54:57 -07:00
Chris Wilson bc3634010c dix: Add ClientSignalAll()
This is a variant of ClientSignal() that signals all clients with an
optional matching sleeping client, function and closure.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-29 14:33:11 -05:00
Peter Hutterer 732fd7e571 Drop trailing whitespaces
sed -i "s/[ ]\+$//g" **/*.(c|h)

happy reviewing...
git diff -w is an empty diff.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-12 10:25:00 +10:00
Eric Anholt abf1202706 glx: Move the GLX variable caching what GL context is current to dix.
GLX is trying to track whether the context it wants is current, to
avoid the glFlush() (and the rest of the overhead) that occurs on all
MakeCurrent calls.  However, its cache can be incorrect now that
glamor exists.  This is a step toward getting glamor to coordinate
with GLX.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-04-23 10:32:02 -07:00
Keith Packard 2d2d49dab5 Clean up a few function prototypes to not place formals in /**/
This just removes the comment markers from around the formals in
several function prototypes near where pointer -> void * changes were
made. There are plenty more of these to fix.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-01-12 10:24:12 -08:00
Keith Packard 60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
Peter Hutterer ddc11397a5 dix: delete all callbacks before reset
DeleteCallbackManager() introduced for better symmetry in the caller, they
do the same thing.

==20085== 24 bytes in 1 blocks are still reachable in loss record 11 of 103
==20085==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==20085==    by 0x43A097: CreateCallbackList (dixutils.c:837)
==20085==    by 0x43A1D3: AddCallback (dixutils.c:869)
==20085==    by 0x4B1736: GEExtensionInit (geext.c:209)
==20085==    by 0x41C8A8: InitExtensions (miinitext.c:389)
==20085==    by 0x5AC918: main (main.c:208)

==2042== 8 bytes in 1 blocks are still reachable in loss record 2 of 97
==2042==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==2042==    by 0x4C2A657: realloc (vg_replace_malloc.c:525)
==2042==    by 0x4802F5: XNFrealloc (utils.c:1095)
==2042==    by 0x43A17A: CreateCallbackList (dixutils.c:855)
==2042==    by 0x43A1EF: AddCallback (dixutils.c:870)
==2042==    by 0x4B1752: GEExtensionInit (geext.c:209)
==2042==    by 0x41C8A8: InitExtensions (miinitext.c:389)
==2042==    by 0x5AC9E4: main (main.c:208)
==2042==

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
2013-05-08 09:27:30 +10:00
Dave Airlie 9d17981829 dix: introduce gpu screens. (v5)
This patch introduces gpu screens into screenInfo. It adds interfaces
for adding and removing gpu screens, along with adding private fixup,
block handler support, and scratch pixmap init.

GPU screens have a myNum that is offset by GPU_SCREEN_OFFSET (256),
this is used for logging etc.

RemoveGPUScreen isn't used until "xfree86: add platform bus hotplug support".

v2: no glyph pictures for GPU screens for now.
v3: introduce MAXGPUSCREENS, fix return value check
v4: fixup myNum when renumbering screens (ajax)
v5: drop cursor privates for now.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-06 10:35:13 +01:00
Dave Airlie 1f0e8bd5eb api: rework the X server driver API to avoid global arrays.
This is a squash merge containing all the API changes, as
well as the video ABI bump.

Its been squashed to make bisection easier.

Full patch log below:

commit b202738bbf0c5a1c1172767119c2c71f1e7f8070
Author: Aaron Plattner <aplattner@nvidia.com>
Date:   Mon May 14 15:16:11 2012 -0700

    xfree86: Bump video ABI to 13.0

    The ABI was broken by changes to convert from screen index numbers to ScreenPtr
    / ScrnInfoPtr in various structures and function signatures.

    Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Dave Airlie <airlied@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 3d5f7d9f8d408bcad3f83277d255f25d3b0edbf3
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu May 24 10:56:57 2012 +0100

    xf86: xf86ClearEntityListForScreen should take a pScrn

    When adding GPU screens this make life easier.

    (also fix comment, as pointed out by Alan)

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit afee8b5ab4501597ecc1ade34124d7ca227ab055
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu May 24 07:07:32 2012 +0100

    xf86i2c: add pscrn for drivers to use

    This just adds a pScrn pointer into the struct for the drivers to use
    instead of scrnIndex. Mostly scrnIndex is used for logging, but some
    drivers use it to lookup xf86Screens, so let them stash a pScrn instead.

    Removing the scrnIndex is a bit more involved and I'm not sure its worth
    the effort. Doing i2c in the X server is legacy code as far as I'm concerned.

    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit ea5092f1f679691d187f1eee9427e6057beec56e
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 19:25:20 2012 +0100

    dix/gc: consolidate GC object creation in one place

    The standard GC create and scratch GC create were 90% the same really,
    and I have a need in the future for creating GC objects without the
    other bits, so wanted to avoid a third copy.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 3d91482ea9b4883e64e496f2768168e0ffa21ba1
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 10:24:06 2012 +0100

    xf86: add a define to denote the new non-index interfaces are being used

    This can be used by drivers to provide compatible APIs.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 37c3ae3e6cd4f3dedc72f371096d6743f8f99df3
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 15:09:12 2012 +0100

    dix: make Create/Free scratch pixmaps take a ScreenPtr

    While technically an API/ABI change I doubt anyone uses it,
    but it helps in splitting screens up.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 75f2062a3fe94f04764ecc7d2ff2fbbeccb9da60
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 14:57:55 2012 +0100

    xf86/xv: remove scrnIndexfrom xf86FindXvOptions.

    Move this interface to taking an ScrnInfoPtr.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit f80c2374f40ea7b2ee0556e2e76cc07406f3d843
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 14:53:59 2012 +0100

    xf86: make xf86DeleteScreen take a ScrnInfoPtr (v2)

    stop passing indices into this function.

    v2: drop flags argument.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 58824e414f35682435f15bfe6c4b656bd90b9235
Author: Dave Airlie <airlied@redhat.com>
Date:   Wed May 23 14:48:09 2012 +0100

    xf86: fix xf86IsScreenPrimary interface to take a pScrn (API/ABI)

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 6b4fc1f9d391bcdf7ca288766e49bce60f4635cd
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:18:59 2012 +0100

    xserver: convert block/wakeup handlers to passing ScreenPtr (ABI/API) (v2)

    Instead of passing an index, pass the actual ScreenPtr. This allows
    more moving towards not abusing xf86Screens + screenInfo.

    v2: drop the blockData/wakeupData args as per ajax's suggestion.,
    fix docs.

    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 790d003de20fb47674420a24dadd92412d78620d
Author: Dave Airlie <airlied@gmail.com>
Date:   Wed Apr 11 09:53:14 2012 +0100

    xf86/common: remove some more pScrn->pScreen uses

    remove some more conversions that appeared after api cleanups.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit aac85e18d1dd093f2cad6bd29375e40bd7af0b8f
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 16:34:53 2012 +0100

    ddc: change API to take ScrnInfoPtr (v2)

    This removes all xf86Screens usage from ddc code,
    it modifies the API for some functions to avoid taking indices.

    v2: address Alan's comments about dropping DDC2Init parameter.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit fe3f57b6eaf6860a33876a54f9439f69578f03a5
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 16:31:26 2012 +0100

    vbe: don't use index for VBEInterpretPanelID (API)

    Remove use of xf86screens from vbe module.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit abf1965f4ed91529036d3fdb470d6a3ce6f29675
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 16:25:11 2012 +0100

    int10/vbe: don't use xf86Screens. (ABI) (v3)

    Pass the ScrnInfoPtr instead of the index in the int10 struct.

    This saves us using it to dereference xf86Screens.

    v2: address Alan's comment to fix struct alignment.

    v3: squash in all the int10 fixes, test the vm86 code builds,
    after comments by Keith.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 23cca612b4fb5efc33683c7624b803b457387e3d
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:30:18 2012 +0100

    xserver: drop index argument to ScreenInit (ABI/API) (v2)

    This drops the index argument, its the same as pScreen->myNum,
    and its the last major index abuse I can find.

    v2: address Alan's review - update docs, fix xwin/xnest/darwin

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 40d360e2d7e832407f3ed64e3a02c27ecc89a960
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:23:01 2012 +0100

    xf86: migrate PointerMoved from index to ScrnInfoPtr (ABI/API)

    This migrates PointerMoved from an index to ScrnInfoPtr.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit aa60a2f38679d0eeb979a9c2648c9bc771409bf9
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:20:46 2012 +0100

    xf86: migrate PMEvent to a ScrnInfoPtr (ABI/API)

    This migrates the PMEvent from index to ScrnInfoPtr.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit d3f28ef44371ed4a039ffc5dd7eb6408d1269ba2
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:18:30 2012 +0100

    xf86: migrate SetDGAMode from index to ScrnInfoPtr (ABI/API)

    This migrates the SetDGAMode callback from an index to ScrnInfoPtr.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit baf5e4818a74f2b68c3dfdcc56f54322351039a0
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:14:11 2012 +0100

    xf86: migrate ChangeGamma from index to ScrnInfoPtr (ABI/API) (v2)

    This migrates the ChangeGamma interface to avoid passing a index.

    v2: fix xf86RandR12.c + xf86cmap.c call

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 51e5f90ada929d6b23176090badbb42fdb3fa550
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:11:09 2012 +0100

    xf86/exa: migrate index to screen types for EnableDisableFBAccess (ABI/API)

    The EXA interface migrates to ScreenPtr,
    and the xf86 interface migrated to ScrnInfoPtr.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 94f1f21d17e86f96d4a54292a399160950087675
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 15:02:11 2012 +0100

    xf86: migrate ValidMode callback to ScrnInfoPtr (ABI/API)

    This migrates the ValidMode to passing a ScrnInfoPtr instead
    of an index.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 3f8f18198fed4f39ec805b508a3482e91eea26b2
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:59:46 2012 +0100

    xf86: migrate SwitchMode to taking ScrnInfoPtr (ABI/API) (v2)

    This migrate the SwitchMode interface to take a ScrnInfoPtr
    instead of an index.

    v2: drop flags.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit d06a038a5c49328ab3a8d969d24f9fcd22c63202
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:50:37 2012 +0100

    xf86: move AdjustFrame to passing ScrnInfoPtr (ABI/API) (v2)

    This converts AdjustFrame code paths to passing a ScrnInfoPtr
    instead of an integer index.

    v2: drop flags args.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 53d2f8608ffd4090d08e7d5cf2e92fb954959b90
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:41:27 2012 +0100

    xf86: modify FreeScreen callback to take pScrn instead of index. (ABI/API) (v2)

    Another index->pScrn conversion.

    v2: drop flags arg.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 60db37c0b247052e0f5c54b1921fe58a3609c2e3
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:35:41 2012 +0100

    xf86: change EnterVT/LeaveVT to take a ScrnInfoPtr (ABI/API break) (v2)

    This modifies the EnterVT/LeaveVT interfaces to take a ScrnInfoPtr
    instead of an index into xf86Screens. This allows dropping more
    public dereferences of the xf86Screens and screenInfo.

    v2: drop flags args as suggested by Keith, fix docs.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>

commit 06729dbbc804a20242e6499f446acb5d94023c3c
Author: Dave Airlie <airlied@gmail.com>
Date:   Tue Apr 10 14:04:59 2012 +0100

    xserver: remove index from CloseScreen (API/ABI breakage)

    This drops the index from the CloseScreen callback,
    its always been useless really, since the pScreen contains it.

    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
    Acked-by: Aaron Plattner <aplattner@nvidia.com>
    Reviewed-by: Adam Jackson <ajax@redhat.com>
    Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-06-05 13:22:18 +01:00
Keith Packard 9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Chris Halse Rogers ef492e9797 dix: Return BadWindow rather than BadMatch from dixLookupWindow
dixLookupWindow uses dixLookupDrawable internally, which returns
BadMatch when the XID matches a non-Window drawable.  Users
of dixLookupWindow don't care about this, just that it's not
a valid Window.

This is a generalised version of the fix for X.Org Bug 23562,
where GetProperty was incorrectly returning BadMatch. Auditing other
window requests, all that I checked would incorrectly return BadMatch
in these circumstances.  An incomplete list of calls that could
incorrectly return BadMatch is: ListProperties, SetSelectionOwner,
{Destroy,Map,Unmap}{,Sub}Window.

None of the callers of dixLookupWindow, except for GetProperty, check
for BadMatch

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-01-09 13:09:48 -08:00
Adam Jackson 8f9bdfd293 dix: Tune dixLookupDrawable for success
The vast vast vast majority of resource lookups are successful.  Move some
work to the error paths so we don't punish success.

Before:
40000000 trep @   0.0009 msec (1109091.3/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (2072652.2/sec): ShmPutImage 10x10 square

After:
40000000 trep @   0.0009 msec (1148346.9/sec): PutImage 10x10 square
60000000 trep @   0.0005 msec (2091666.1/sec): ShmPutImage 10x10 square

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2012-01-06 13:29:54 -05:00
Alan Coopersmith d5a5eece67 CompareISOLatin1Lowered: constify arguments
Allows callers to avoid deconstifying arguments when calling, fixing
gcc warning:

filter.c: In function 'PictureGetFilterId':
filter.c:59:2: warning: cast discards qualifiers from pointer target type

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:10 -08:00
Scott James Remnant 2ee85d954c dix: avoid calling deleted block and wakeup handlers
BlockHandler and WakeupHandlers may be removed within a different
BlockHandler or WakeupHandler, especially since config/udev uses
these and removes devices.

Calling the deleted handlers and passing potentially freed data
can result in the X server segfaulting after device removal, or
events that result in device removal such as undocking or suspend/
resume.

Signed-off-by: Scott James Remnant <scott@netsplit.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-06-30 16:38:29 +10:00
Adam Jackson 6274dca9d9 dix: optimize CallCallbacks
Move the basic sanity checking to an inline wrapper, which avoids the
function call overhead if the callback list is empty.  On an XACEful
server on a 2.4GHz Core 2 Duo:

    1              2           Operation
--------   -----------------   -----------------
20000000.0   25100000.0 (  1.25)   X protocol NoOperation

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-10-13 09:24:06 -07:00
Mikhail Gusarov 7287ef9e6c Remove unnecessary parentheses around return values in functions
This patch was generated by the following Perl code:

perl -i -pe 's/([^_])return\s*\(\s*([^(]+?)\s*\)s*;(\s+(\n))?/$1return $2;$4/g;'

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-10 06:42:42 -07:00
Mikhail Gusarov 0a4d8cbdcd Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@

-if(E) { free(E); }
+free(E);

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 20:27:18 +07:00
Jamey Sharp e291c56182 Return an appropriately-typed error from dixLookupResourceByType.
Rather than always returning BadValue, associate an error status like
BadWindow with a resource type like RT_WINDOW, and return the
appropriate one for the requested type.

This patch only touches the core protocol resource types. Others still
return BadValue and need to be mapped appropriately.

dixLookupResourceByType can now return BadImplementation, if the caller
asked for a resource type that has not been allocated in the server.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-19 12:32:48 -07:00
Mikhail Gusarov 3f3ff971ec Replace X-allocation functions with their C89 counterparts
The only remaining X-functions used in server are XNF*, the rest is converted to
plain alloc/calloc/realloc/free/strdup.

X* functions are still exported from server and x* macros are still defined in
header file, so both ABI and API are not affected by this change.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2010-05-13 00:22:37 +07:00
Jamey Sharp 35761d5f81 Introduce dixLookupFontable for "FONT or GC" parameters.
Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-05-07 21:56:36 -07:00
Yaakov Selkowitz 7c31dd5db8 Remove CopyISOLatin1Lowered
This function was moved verbatim into libXfont-1.4, and it is not used
by the server or any drivers.  Exporting it in both places leads to
multiple definition linking errors on Cygwin, where we need to use a
static libXfont due to poor weak-symbol handling.

Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-10-15 08:08:23 -07:00
Eamon Walsh 57aff88c7d Fix most remaining deprecated resource lookups.
Callsites updated to use dixLookupResourceBy{Type,Class}.
TODO: Audit access modes to make sure they reflect the usage.
2009-04-29 01:04:37 -04:00
Keith Packard f8dd80d13b Replace dixLookupResource by dixLookupResourceBy{Type,Class}
dixLookupResource attempted to automatically detect whether the caller
wanted a lookup by-type or by-class, unfortunately, it guessed wrong for
RT_NONE. Instead of trying to make the guess better, this patch just reverts
the unification and creates separate functions for each operation.
2009-03-09 13:08:09 -07:00
Adam Jackson 132b464d73 Remove a bunch of useless casts.
We've had void * for twenty years now people let's try to act like we
know how it works.
2009-01-22 02:11:16 -05:00
Paulo Cesar Pereira de Andrade 49f77fff14 Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.

  This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)

  LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.

  xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 05:43:34 -02:00
Paulo Cesar Pereira de Andrade d6cbd4511e Export symbols defined in the sdk.
This is the biggest "visibility" patch. Instead of doing a "export"
symbol on demand, export everything in the sdk, so that if some module
fails due to an unresolved symbol, it is because it is using a symbol
not in the sdk.

  Most exported symbols shouldn't really be made visible, neither
advertised in the sdk, as they are only used by a single shared object.

  Symbols in the sdk (or referenced in sdk macros), but not defined
anywhere include:
XkbBuildCoreState()
XkbInitialMap
XkbXIUnsupported
XkbCheckActionVMods()
XkbSendCompatNotify()
XkbDDXFakePointerButton()
XkbDDXApplyConfig()
_XkbStrCaseCmp()
_XkbErrMessages[]
_XkbErrCode
_XkbErrLocation
_XkbErrData
XkbAccessXDetailText()
XkbNKNDetailMaskText()
XkbLookupGroupAndLevel()
XkbInitAtoms()
XkbGetOrderedDrawables()
XkbFreeOrderedDrawables()
XkbConvertXkbComponents()
XkbWriteXKBSemantics()
XkbWriteXKBLayout()
XkbWriteXKBKeymap()
XkbWriteXKBFile()
XkbWriteCFile()
XkbWriteXKMFile()
XkbWriteToServer()
XkbMergeFile()
XkmFindTOCEntry()
XkmReadFileSection()
XkmReadFileSectionName()
InitExtInput()
xf86CheckButton()
xf86SwitchCoreDevice()
RamDacSetGamma()
RamDacRestoreDACValues()
xf86Bpp
xf86ConfigPix24
xf86MouseCflags[]
xf86SupportedMouseTypes[]
xf86NumMouseTypes
xf86ChangeBusIndex()
xf86EntityEnter()
xf86EntityLeave()
xf86WrapperInit()
xf86RingBell()
xf86findOptionBoolean()
xf86debugListOptions()
LoadSubModuleLocal()
LoaderSymbolLocal()
getInt10Rec()
xf86CurrentScreen
xf86ReallocatePciResources()
xf86NewSerialNumber()
xf86RandRSetInitialMode()
fbCompositeSolidMask_nx1xn
fbCompositeSolidMask_nx8888x0565C
fbCompositeSolidMask_nx8888x8888C
fbCompositeSolidMask_nx8x0565
fbCompositeSolidMask_nx8x0888
fbCompositeSolidMask_nx8x8888
fbCompositeSrc_0565x0565
fbCompositeSrc_8888x0565
fbCompositeSrc_8888x0888
fbCompositeSrc_8888x8888
fbCompositeSrcAdd_1000x1000
fbCompositeSrcAdd_8000x8000
fbCompositeSrcAdd_8888x8888
fbGeneration
fbIn
fbOver
fbOver24
fbOverlayGeneration
fbRasterizeEdges
fbRestoreAreas
fbSaveAreas
composeFunctions
VBEBuildVbeModeList()
VBECalcVbeModeIndex()
TIramdac3030CalculateMNPForClock()
shadowBufPtr
shadowFindBuf()
miRRGetScreenInfo()
RRSetScreenConfig()
RRModePruneUnused()
PixmanImageFromPicture()
extern int miPointerGetMotionEvents()
miClipPicture()
miRasterizeTriangle()
fbPush1toN()
fbInitializeBackingStore()
ddxBeforeReset()
SetupSprite()
InitSprite()
DGADeliverEvent()

  SPECIAL CASES
o defined as _X_INTERNAL
	xf86NewInputDevice()
o defined as static
	fbGCPrivateKey
	fbOverlayScreenPrivateKey
	fbScreenPrivateKey
	fbWinPrivateKey
o defined in libXfont.so, but declared in xorg/dixfont.h
	GetGlyphs()
	QueryGlyphExtents()
	QueryTextExtents()
	ParseGlyphCachingMode()
	InitGlyphCaching()
	SetGlyphCachingMode()
2008-11-29 23:56:06 -02:00
Paulo Cesar Pereira de Andrade 74e2669103 Export symbols also defined in libXfont.
libXfont has stubs for these symbols, so, when compiling with hidden
symbols by default, these symbols must be visible in the X Server, or
the stubs in libXfont will be used.
2008-11-27 04:33:44 -02:00
Owen Taylor ca9fae0079 Change 'remap' to 'map' in saveset functions/macros
Now that the code has been fixed so that Unmap means unmap and not "don't
remap", 'remap' was confusing to have in the function names/parameters, so
change it to simple 'map'.

Signed-off-by: Keith Packard <keithp@keithp.com>
2008-09-22 12:43:30 -07:00
Jeremy Huddleston 8822110d7d Fixed dixLookupClient to work with client=NullClient as it did in the 1.3 branch
(cherry picked from commit e41ccc6470)
(cherry picked from commit ce5a5f9399)
2008-04-21 20:09:20 -07:00
Adam Jackson aa5216e897 Rip out useless indirection in the callback list management. 2008-02-14 07:02:13 +11:00
Eamon Walsh de18703d2a dix: Fix bug+leak in callback manager DeleteCallbackList function. 2008-01-03 23:17:06 -05:00
Eamon Walsh e89301c879 xace: add hooks + new access codes: core protocol client requests 2007-08-16 10:57:49 -04:00
Eamon Walsh 9a183d7ba5 dix: remove caching of drawables and graphics contexts. The security checks
simply bypass the cached values so they are unused.
2007-08-14 11:39:26 -04:00
Eamon Walsh e2a720c9a1 Merge branch 'master' into XACE-SELINUX
Conflicts:

	dix/dixutils.c
2007-06-11 15:29:11 -04:00
Michel Dänzer 644f7ddc0c dixLookupClient: Use access parameter. 2007-06-11 09:23:18 +02:00
Eamon Walsh 9cee4ec5e6 xace: change the semantics of the return value of XACE hooks to allow
arbitrary X status codes instead of just TRUE/FALSE.

The dix layer in most cases still does not propagate the return value of
XACE hooks back to the client, however.  There is more error propagation
work to do.
2007-04-17 16:01:56 -04:00
Eamon Walsh 1f06d32ef5 Merge branch 'master' into XACE-SELINUX
Conflicts:

	dix/privates.c
2007-04-17 12:10:22 -04:00
Stefan Huehner 1f6741db19 Bug #10560: Code-Cleanup: function declarations () -> (void)
X.Org Bugzilla #10560: <https://bugs.freedesktop.org/show_bug.cgi?id=10560>
Patch #9511 <https://bugs.freedesktop.org/attachment.cgi?id=9511>
2007-04-09 14:33:15 -07:00
Eamon Walsh ed75b05651 dix: add new, combined resource lookup function. Move all dix lookup API
deprecated so far to a new file dix/deprecated.c.  Remove the deprecation
warnings for the time being.
2007-04-04 16:00:15 -04:00
Adam Jackson 4b5802ddbd General DIX static and dead code cleanup. 2007-03-25 17:57:54 -04:00
Peter Hutterer 63169ce52d dix: remove 'register' keyword for all variables. 2007-03-08 17:50:25 +10:30
Michel Dänzer 282a4dcaab Attempt to fix drawable type checks in dixLookupDrawable().
Not sure this is 100% correct either, but it fixes at least one reproducible
crasher where it returned a pixmap to dixLookupWindow().
2007-01-08 19:22:41 +01:00
Eamon Walsh 0128073568 Add loud warnings to deprecated lookup functions.
Hopefully this will alert external driver maintainers.
2006-12-15 18:27:16 -05:00
Eamon Walsh ab1d5b0c31 Convert callers of LookupClient() to dixLookupClient(). 2006-12-15 17:26:58 -05:00
Eamon Walsh ab1886df73 Add new, combined dix lookup functions (tweak). 2006-12-14 15:42:19 -05:00
Eamon Walsh 60cdc592fe Add new, combined dix lookup functions. 2006-12-14 14:46:03 -05:00