Git Product home page Git Product logo

Comments (2)

 avatar commented on August 29, 2024 1

It's because CARD32 itself is defined as unsigned long. The API has been around since long before the C standard had uint32_t, and int was only 16 bit in many implementations at the time. This crate has to do things exactly as the C libraries do for binary compatibility.

from x11-rs.

mickvangelderen avatar mickvangelderen commented on August 29, 2024

Ah I see.

I'm trying to figure out how those basic X types are defined now but it isn't simple. The type definitions depend mostly on LONG64 and _XSERVER64 being defined or not. Also they're spread over multiple files like X.h, Xmd.h, Xproto.h, Xdefs.h and maybe more.

In Xproto.h the defintions are said to be overwritten and restored:

/* For the purpose of the structure definitions in this file,
we must redefine the following types in terms of Xmd.h's types, which may
include bit fields.  All of these are #undef'd at the end of this file,
restoring the definitions in X.h.  */

Then there's exceptions like this in XI.h

/*
 * Make XEventClass be a CARD32 for 64 bit servers.  Don't affect client
 * definition of XEventClass since that would be a library interface change.
 * See the top of X.h for more _XSERVER64 magic.
 *
 * But, don't actually use the CARD32 type.  We can't get it defined here
 * without polluting the namespace.
 */
#ifdef _XSERVER64
typedef	unsigned int	XEventClass;
#else
typedef	unsigned long	XEventClass;
#endif

Found this comment https://gitlab.freedesktop.org/xorg/xserver/issues/553#note_94062

For the second, it appears you've missed the _XSERVER64 definition that's required when building X server code on 64-bit systems - this is normally
defined in xorg-config.h, xorg-server.h, or dix-config.h depending on which
portion of the X server source code you're working in. The difference in types between clients & servers in 64-bit builds is a very sad mistake from the distant past we're stuck with to avoid breaking compatibility.

To me it looks like X clients use 64 bit integers for some types, but the data structures communicating with the X server (Xproto.h) use the right (as per the X protocol specification) integer widths. Approximately, probably.

from x11-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.