xserver-multidpi/Xext/xace.h
Eamon Walsh d7c5e8bfc1 Modified performance patches from Arjan van de Ven <arjan@infradead.org>
Subject: [PATCH] fix some performance gaps in Xace

The XaceHook function is used in several hotpaths.
The problem with it (performance wise) is twofold:
 * The XaceHook function has a big switch() statement for the hook number in it
 * The XaceHook function uses varargs to reassemble the final dispatch arguments again

Both are expensive operations... for something that is known at compile time

This patch turns the hotpath XaceHook call into a direct call to avoid
the switch and varargs; this gives me over 10% performance gain
on the x11perf benchmark.
2007-11-06 16:26:09 -05:00

119 lines
3.3 KiB
C

/************************************************************
Author: Eamon Walsh <ewalsh@epoch.ncsc.mil>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
this permission notice appear in supporting documentation. This permission
notice shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
********************************************************/
#ifndef _XACE_H
#define _XACE_H
/* Hook return codes */
#define XaceErrorOperation 0
#define XaceAllowOperation 1
#define XaceIgnoreOperation 2
#ifdef XACE
#define XACE_EXTENSION_NAME "XAccessControlExtension"
#define XACE_MAJOR_VERSION 1
#define XACE_MINOR_VERSION 0
#include "pixmap.h" /* for DrawablePtr */
#include "regionstr.h" /* for RegionPtr */
#define XaceNumberEvents 0
#define XaceNumberErrors 0
/* security hooks */
/* Constants used to identify the available security hooks
*/
#define XACE_CORE_DISPATCH 0
#define XACE_EXT_DISPATCH 1
#define XACE_RESOURCE_ACCESS 2
#define XACE_DEVICE_ACCESS 3
#define XACE_PROPERTY_ACCESS 4
#define XACE_DRAWABLE_ACCESS 5
#define XACE_MAP_ACCESS 6
#define XACE_BACKGRND_ACCESS 7
#define XACE_EXT_ACCESS 8
#define XACE_HOSTLIST_ACCESS 9
#define XACE_SITE_POLICY 10
#define XACE_DECLARE_EXT_SECURE 11
#define XACE_AUTH_AVAIL 12
#define XACE_KEY_AVAIL 13
#define XACE_WINDOW_INIT 14
#define XACE_AUDIT_BEGIN 15
#define XACE_AUDIT_END 16
#define XACE_NUM_HOOKS 17
extern CallbackListPtr XaceHooks[XACE_NUM_HOOKS];
/* Entry point for hook functions. Called by Xserver.
*/
extern int XaceHook(
int /*hook*/,
... /*appropriate args for hook*/
);
/* Special-cased hook functions
*/
extern void XaceHookAuditEnd(ClientPtr ptr, int result);
extern void XaceHookAuditBegin(ClientPtr ptr);
/* Register a callback for a given hook.
*/
#define XaceRegisterCallback(hook,callback,data) \
AddCallback(XaceHooks+(hook), callback, data)
/* Unregister an existing callback for a given hook.
*/
#define XaceDeleteCallback(hook,callback,data) \
DeleteCallback(XaceHooks+(hook), callback, data)
/* From the original Security extension...
*/
extern void XaceCensorImage(
ClientPtr client,
RegionPtr pVisibleRegion,
long widthBytesLine,
DrawablePtr pDraw,
int x, int y, int w, int h,
unsigned int format,
char * pBuf
);
#else /* XACE */
/* Define calls away when XACE is not being built. */
#ifdef __GNUC__
#define XaceHook(args...) XaceAllowOperation
#define XaceHookAuditEnd(args...) { ; }
#define XaceHookAuditBegin(args...) { ; }
#define XaceCensorImage(args...) { ; }
#else
#define XaceHook(...) XaceAllowOperation
#define XaceHookAuditEnd(...) { ; }
#define XaceHookAuditBegin(...) { ; }
#define XaceCensorImage(...) { ; }
#endif
#endif /* XACE */
#endif /* _XACE_H */