xref: /aosp_15_r20/external/mesa3d/src/glx/glx_error.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1*61046927SAndroid Build Coastguard Worker /*
2*61046927SAndroid Build Coastguard Worker  Copyright (c) 2009 Apple Inc.
3*61046927SAndroid Build Coastguard Worker 
4*61046927SAndroid Build Coastguard Worker  Permission is hereby granted, free of charge, to any person
5*61046927SAndroid Build Coastguard Worker  obtaining a copy of this software and associated documentation files
6*61046927SAndroid Build Coastguard Worker  (the "Software"), to deal in the Software without restriction,
7*61046927SAndroid Build Coastguard Worker  including without limitation the rights to use, copy, modify, merge,
8*61046927SAndroid Build Coastguard Worker  publish, distribute, sublicense, and/or sell copies of the Software,
9*61046927SAndroid Build Coastguard Worker  and to permit persons to whom the Software is furnished to do so,
10*61046927SAndroid Build Coastguard Worker  subject to the following conditions:
11*61046927SAndroid Build Coastguard Worker 
12*61046927SAndroid Build Coastguard Worker  The above copyright notice and this permission notice shall be
13*61046927SAndroid Build Coastguard Worker  included in all copies or substantial portions of the Software.
14*61046927SAndroid Build Coastguard Worker 
15*61046927SAndroid Build Coastguard Worker  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16*61046927SAndroid Build Coastguard Worker  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17*61046927SAndroid Build Coastguard Worker  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18*61046927SAndroid Build Coastguard Worker  NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
19*61046927SAndroid Build Coastguard Worker  HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20*61046927SAndroid Build Coastguard Worker  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21*61046927SAndroid Build Coastguard Worker  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22*61046927SAndroid Build Coastguard Worker  DEALINGS IN THE SOFTWARE.
23*61046927SAndroid Build Coastguard Worker 
24*61046927SAndroid Build Coastguard Worker  Except as contained in this notice, the name(s) of the above
25*61046927SAndroid Build Coastguard Worker  copyright holders shall not be used in advertising or otherwise to
26*61046927SAndroid Build Coastguard Worker  promote the sale, use or other dealings in this Software without
27*61046927SAndroid Build Coastguard Worker  prior written authorization.
28*61046927SAndroid Build Coastguard Worker */
29*61046927SAndroid Build Coastguard Worker #include <stdbool.h>
30*61046927SAndroid Build Coastguard Worker #include <assert.h>
31*61046927SAndroid Build Coastguard Worker #include <X11/Xlibint.h>
32*61046927SAndroid Build Coastguard Worker #include <X11/extensions/extutil.h>
33*61046927SAndroid Build Coastguard Worker #include <X11/extensions/Xext.h>
34*61046927SAndroid Build Coastguard Worker #include "glxclient.h"
35*61046927SAndroid Build Coastguard Worker #include "glx_error.h"
36*61046927SAndroid Build Coastguard Worker 
37*61046927SAndroid Build Coastguard Worker void
__glXSendError(Display * dpy,int_fast8_t errorCode,uint_fast32_t resourceID,uint_fast16_t minorCode,bool coreX11error)38*61046927SAndroid Build Coastguard Worker __glXSendError(Display * dpy, int_fast8_t errorCode, uint_fast32_t resourceID,
39*61046927SAndroid Build Coastguard Worker                uint_fast16_t minorCode, bool coreX11error)
40*61046927SAndroid Build Coastguard Worker {
41*61046927SAndroid Build Coastguard Worker    struct glx_display *glx_dpy = __glXInitialize(dpy);
42*61046927SAndroid Build Coastguard Worker    xError error;
43*61046927SAndroid Build Coastguard Worker 
44*61046927SAndroid Build Coastguard Worker    assert(glx_dpy);
45*61046927SAndroid Build Coastguard Worker 
46*61046927SAndroid Build Coastguard Worker    LockDisplay(dpy);
47*61046927SAndroid Build Coastguard Worker 
48*61046927SAndroid Build Coastguard Worker    error.type = X_Error;
49*61046927SAndroid Build Coastguard Worker 
50*61046927SAndroid Build Coastguard Worker    if (coreX11error) {
51*61046927SAndroid Build Coastguard Worker       error.errorCode = errorCode;
52*61046927SAndroid Build Coastguard Worker    }
53*61046927SAndroid Build Coastguard Worker    else {
54*61046927SAndroid Build Coastguard Worker       error.errorCode = glx_dpy->codes.first_error + errorCode;
55*61046927SAndroid Build Coastguard Worker    }
56*61046927SAndroid Build Coastguard Worker 
57*61046927SAndroid Build Coastguard Worker    error.sequenceNumber = dpy->request;
58*61046927SAndroid Build Coastguard Worker    error.resourceID = resourceID;
59*61046927SAndroid Build Coastguard Worker    error.minorCode = minorCode;
60*61046927SAndroid Build Coastguard Worker    error.majorCode = glx_dpy->codes.major_opcode;
61*61046927SAndroid Build Coastguard Worker 
62*61046927SAndroid Build Coastguard Worker    _XError(dpy, &error);
63*61046927SAndroid Build Coastguard Worker 
64*61046927SAndroid Build Coastguard Worker    UnlockDisplay(dpy);
65*61046927SAndroid Build Coastguard Worker }
66*61046927SAndroid Build Coastguard Worker 
67*61046927SAndroid Build Coastguard Worker void
__glXSendErrorForXcb(Display * dpy,const xcb_generic_error_t * err)68*61046927SAndroid Build Coastguard Worker __glXSendErrorForXcb(Display * dpy, const xcb_generic_error_t *err)
69*61046927SAndroid Build Coastguard Worker {
70*61046927SAndroid Build Coastguard Worker    xError error;
71*61046927SAndroid Build Coastguard Worker 
72*61046927SAndroid Build Coastguard Worker    LockDisplay(dpy);
73*61046927SAndroid Build Coastguard Worker 
74*61046927SAndroid Build Coastguard Worker    error.type = X_Error;
75*61046927SAndroid Build Coastguard Worker    error.errorCode = err->error_code;
76*61046927SAndroid Build Coastguard Worker    error.sequenceNumber = err->sequence;
77*61046927SAndroid Build Coastguard Worker    error.resourceID = err->resource_id;
78*61046927SAndroid Build Coastguard Worker    error.minorCode = err->minor_code;
79*61046927SAndroid Build Coastguard Worker    error.majorCode = err->major_code;
80*61046927SAndroid Build Coastguard Worker 
81*61046927SAndroid Build Coastguard Worker    _XError(dpy, &error);
82*61046927SAndroid Build Coastguard Worker 
83*61046927SAndroid Build Coastguard Worker    UnlockDisplay(dpy);
84*61046927SAndroid Build Coastguard Worker }
85