rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / x11 / libXext / patches / 01.shm.patch
blobce3ed625609c13e4712d23e79ed152d12f818256
1 # Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the "Software"),
5 # to deal in the Software without restriction, including without limitation
6 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 # and/or sell copies of the Software, and to permit persons to whom the
8 # Software is furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice (including the next
11 # paragraph) shall be included in all copies or substantial portions of the
12 # Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 # DEALINGS IN THE SOFTWARE.
23 --- libXext-1.3.5/src/XShm.c.orig
24 +++ libXext-1.3.5/src/XShm.c
25 @@ -38,6 +38,13 @@
26 #include <X11/extensions/Xext.h>
27 #include <X11/extensions/extutil.h>
29 +#ifdef SUNSOFT
30 +#include <fcntl.h>
31 +#include <sys/types.h>
32 +#include <sys/stat.h>
33 +#include <ucred.h>
34 +#endif
36 static XExtensionInfo _shm_info_data;
37 static XExtensionInfo *shm_info = &_shm_info_data;
38 static const char *shm_extension_name = SHMNAME;
39 @@ -135,6 +142,46 @@
40 return False;
43 +#ifdef SUNSOFT
44 +/*
45 + * Function to determine if a connection is local or not.
46 + * Returns: 0 for remote, 1 for local
47 + */
49 +static int
50 +LocalConnection(Display *dpy)
52 + int c = ConnectionNumber(dpy);
53 + int rv = 0;
54 + struct stat statbuf;
55 + ucred_t *ucred = NULL;
57 + if (c >= 0) {
58 + /*
59 + * First stat the connection fd. If we succeed and the type of file
60 + * is a FIFO, then we must be local.
61 + */
62 + if ((fstat(c, &statbuf) >= 0) && S_ISFIFO(statbuf.st_mode)) {
63 + return 1;
64 + }
66 + /*
67 + * Then call getpeerucred - if it succeeds, the other end of the
68 + * connection must be on the same machine (though possibly in a
69 + * different zone).
70 + */
71 + if (getpeerucred(c, &ucred) == 0) {
72 + if (ucred_getzoneid(ucred) != -1) {
73 + rv = 1;
74 + }
75 + ucred_free(ucred);
76 + }
77 + }
79 + return rv;
81 +#endif /* SUNSOFT */
83 /*****************************************************************************
84 * *
85 * public Shared Memory Extension routines *
86 @@ -144,6 +191,15 @@
87 Bool XShmQueryExtension (Display *dpy /* int *event_basep, *error_basep */)
89 XExtDisplayInfo *info = find_display (dpy);
90 +#ifdef SUNSOFT
91 + /*
92 + * Sun Mod -- if we're dealing with a remote connection, then the
93 + * shared memory extension is not valid. Sigh -- this should really
94 + * be in the server somewhere... Required for pipe transport PIPECONN
95 + */
96 + if(!LocalConnection(dpy))
97 + return False;
98 +#endif /* SUNSOFT */
100 if (XextHasExtension(info)) {
101 /* *event_basep = info->codes->first_event;
102 @@ -176,6 +232,15 @@
103 XExtDisplayInfo *info = find_display (dpy);
104 xShmQueryVersionReply rep;
105 register xShmQueryVersionReq *req;
106 +#ifdef SUNSOFT
107 + /*
108 + * Sun Mod -- if we're dealing with a remote connection, then the
109 + * shared memory extension is not valid. Sigh -- this should really
110 + * be in the server somewhere...
111 + */
112 + if(!LocalConnection(dpy))
113 + return False;
114 +#endif /* SUNSOFT */
116 ShmCheckExtension (dpy, info, False);