winsys/sw/xlib: Prevent shared memory segment leakage.
winsys/sw/xlib: Prevent shared memory segment leakage.

Running piglit with this was causing all sort of weird stuff happening
to my desktop (Chromium webpages become blank, Qt Creator flickered,
etc).  I tracked this down to shared memory segment leakage when GL is
not shutdown properly. The segments can be seen running `ipcs` and
looking for nattch==0.

This changes fixes this by calling shmctl(IPC_RMID) soon after creation
(which does not remove the segment immediately, but simply marks it for
removal when no more processes are attached).

This matches src/mesa/drivers/x11/xm_buffer.c behaviour.

v2:
- move shmctl(IPC_RMID) after XShmAttach() for *BSD, per Chris Wilson
- remove stray debug printfs, spotted by Ian Romanick

NOTE: This is a candidate for stable branches.

Reviewed-by: Brian Paul <3cb4e1df5ec4da2c7c4af7c52cec8cf340a55a10@vmware.com>

zeux/glsl-optimizer,bkaradzic/glsl-optimizer,zz85/glsl-optimizer,benaadams/glsl-optimizer,benaadams/glsl-optimizer,jbarczak/glsl-optimizer,zeux/glsl-optimizer,metora/MesaGLSLCompiler,mapbox/glsl-optimizer,wolf96/glsl-optimizer,bkaradzic/glsl-optimizer,bkaradzic/glsl-optimizer,djreep81/glsl-optimizer,dellis1972/glsl-optimizer,benaadams/glsl-optimizer,benaadams/glsl-optimizer,dellis1972/glsl-optimizer,tokyovigilante/glsl-optimizer,jbarczak/glsl-optimizer,mcanthony/glsl-optimizer,mcanthony/glsl-optimizer,zz85/glsl-optimizer,tokyovigilante/glsl-optimizer,zz85/glsl-optimizer,djreep81/glsl-optimizer,benaadams/glsl-optimizer,jbarczak/glsl-optimizer,zz85/glsl-optimizer,mcanthony/glsl-optimizer,benaadams/glsl-optimizer,djreep81/glsl-optimizer,wolf96/glsl-optimizer,dellis1972/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,mcanthony/glsl-optimizer,tokyovigilante/glsl-optimizer,mapbox/glsl-optimizer,dellis1972/glsl-optimizer,metora/MesaGLSLCompiler,djreep81/glsl-optimizer,zeux/glsl-optimizer,dellis1972/glsl-optimizer,bkaradzic/glsl-optimizer,jbarczak/glsl-optimizer,djreep81/glsl-optimizer,wolf96/glsl-optimizer,tokyovigilante/glsl-optimizer,mapbox/glsl-optimizer,zeux/glsl-optimizer,jbarczak/glsl-optimizer,zz85/glsl-optimizer,mcanthony/glsl-optimizer,metora/MesaGLSLCompiler,mapbox/glsl-optimizer,zeux/glsl-optimizer,mapbox/glsl-optimizer,zz85/glsl-optimizer,bkaradzic/glsl-optimizer,wolf96/glsl-optimizer