Converters.c revision 9e7bcd65
1/* 2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24#include <X11/Intrinsic.h> 25#include <glib.h> 26 27/* Test for Solaris bug 4163152 XtCvtIntToPixmap() gets a SIGBUS in 64-bit 28 Fixed by libXt commit 16d9941f3aa38dde115cbff639e131761c1b36d0 29 */ 30static void test_XtCvtIntToPixmap(void) 31{ 32 Display *display = NULL; /* not actually used */ 33 Boolean status; 34 XrmValue args[2]; 35 Cardinal num_args; 36 XrmValue fromVal; 37 XrmValue toVal; 38 Pixmap res; 39 XtPointer *closure_ret = NULL; 40 int num[2]; 41 42 43 XtToolkitInitialize(); 44 45 num[0] = 7; 46 num[1] = -1; 47 48 num_args = 0; 49 fromVal.addr = (XtPointer) num; 50 fromVal.size = sizeof(int); 51 toVal.addr = (XtPointer) &res; 52 toVal.size = sizeof(Pixmap); 53 54 status = XtCvtIntToPixmap(display, &args[0], &num_args, 55 &fromVal, &toVal, closure_ret); 56 57 g_assert(res == num[0]); 58 59 60 num[0] = -1; 61 num[1] = 7; 62 63 num_args = 0; 64 fromVal.addr = (XtPointer) (&num[1]); 65 fromVal.size = sizeof(int); 66 toVal.addr = (XtPointer) &res; 67 toVal.size = sizeof(Pixmap); 68 69 status = XtCvtIntToPixmap(display, &args[0], &num_args, 70 &fromVal, &toVal, closure_ret); 71 72 g_assert(res == num[1]); 73} 74 75int main(int argc, char** argv) 76{ 77 g_test_init(&argc, &argv, NULL); 78 g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id="); 79 80 g_test_add_func("/Converters/XtCvtIntToPixmap", test_XtCvtIntToPixmap); 81 82 return g_test_run(); 83} 84