19e7bcd65Smrg/* 2fdf6a26fSmrg * Copyright (c) 2011, 2022, Oracle and/or its affiliates. 39e7bcd65Smrg * 49e7bcd65Smrg * Permission is hereby granted, free of charge, to any person obtaining a 59e7bcd65Smrg * copy of this software and associated documentation files (the "Software"), 69e7bcd65Smrg * to deal in the Software without restriction, including without limitation 79e7bcd65Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 89e7bcd65Smrg * and/or sell copies of the Software, and to permit persons to whom the 99e7bcd65Smrg * Software is furnished to do so, subject to the following conditions: 109e7bcd65Smrg * 119e7bcd65Smrg * The above copyright notice and this permission notice (including the next 129e7bcd65Smrg * paragraph) shall be included in all copies or substantial portions of the 139e7bcd65Smrg * Software. 149e7bcd65Smrg * 159e7bcd65Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 169e7bcd65Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 179e7bcd65Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 189e7bcd65Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 199e7bcd65Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 209e7bcd65Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 219e7bcd65Smrg * DEALINGS IN THE SOFTWARE. 229e7bcd65Smrg */ 239e7bcd65Smrg 249e7bcd65Smrg#include <X11/Intrinsic.h> 259e7bcd65Smrg#include <glib.h> 269e7bcd65Smrg 279e7bcd65Smrg/* Test for Solaris bug 4163152 XtCvtIntToPixmap() gets a SIGBUS in 64-bit 289e7bcd65Smrg Fixed by libXt commit 16d9941f3aa38dde115cbff639e131761c1b36d0 299e7bcd65Smrg */ 309e7bcd65Smrgstatic void test_XtCvtIntToPixmap(void) 319e7bcd65Smrg{ 329e7bcd65Smrg Display *display = NULL; /* not actually used */ 339e7bcd65Smrg Boolean status; 349e7bcd65Smrg XrmValue args[2]; 359e7bcd65Smrg Cardinal num_args; 369e7bcd65Smrg XrmValue fromVal; 379e7bcd65Smrg XrmValue toVal; 389e7bcd65Smrg Pixmap res; 399e7bcd65Smrg XtPointer *closure_ret = NULL; 409e7bcd65Smrg int num[2]; 419e7bcd65Smrg 429e7bcd65Smrg 439e7bcd65Smrg XtToolkitInitialize(); 449e7bcd65Smrg 459e7bcd65Smrg num[0] = 7; 469e7bcd65Smrg num[1] = -1; 479e7bcd65Smrg 489e7bcd65Smrg num_args = 0; 499e7bcd65Smrg fromVal.addr = (XtPointer) num; 509e7bcd65Smrg fromVal.size = sizeof(int); 519e7bcd65Smrg toVal.addr = (XtPointer) &res; 529e7bcd65Smrg toVal.size = sizeof(Pixmap); 539e7bcd65Smrg 549e7bcd65Smrg status = XtCvtIntToPixmap(display, &args[0], &num_args, 559e7bcd65Smrg &fromVal, &toVal, closure_ret); 569e7bcd65Smrg 57fdf6a26fSmrg g_assert_cmpint(status, ==, True); 58fdf6a26fSmrg g_assert_cmpint(res, ==, num[0]); 599e7bcd65Smrg 609e7bcd65Smrg 619e7bcd65Smrg num[0] = -1; 629e7bcd65Smrg num[1] = 7; 639e7bcd65Smrg 649e7bcd65Smrg num_args = 0; 659e7bcd65Smrg fromVal.addr = (XtPointer) (&num[1]); 669e7bcd65Smrg fromVal.size = sizeof(int); 679e7bcd65Smrg toVal.addr = (XtPointer) &res; 689e7bcd65Smrg toVal.size = sizeof(Pixmap); 699e7bcd65Smrg 709e7bcd65Smrg status = XtCvtIntToPixmap(display, &args[0], &num_args, 719e7bcd65Smrg &fromVal, &toVal, closure_ret); 729e7bcd65Smrg 73fdf6a26fSmrg g_assert_cmpint(status, ==, True); 74fdf6a26fSmrg g_assert_cmpint(res, ==, num[1]); 759e7bcd65Smrg} 769e7bcd65Smrg 779e7bcd65Smrgint main(int argc, char** argv) 789e7bcd65Smrg{ 799e7bcd65Smrg g_test_init(&argc, &argv, NULL); 80fdf6a26fSmrg g_test_bug_base("https://gitlab.freedesktop.org/xorg/lib/libxt/-/issues/"); 819e7bcd65Smrg 829e7bcd65Smrg g_test_add_func("/Converters/XtCvtIntToPixmap", test_XtCvtIntToPixmap); 839e7bcd65Smrg 849e7bcd65Smrg return g_test_run(); 859e7bcd65Smrg} 86