Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate non-truncated versions for GLib's GHookList #466

Merged
merged 1 commit into from
Sep 18, 2017

Conversation

sdroege
Copy link
Member

@sdroege sdroege commented Sep 18, 2017

I need this for GStreamer, as GstPad contains a GHookList and I need access to its fields after the GHookList. Did an awful (and not entirely correct) workaround for that for now: https://github.com/sdroege/gstreamer-rs/blob/f4958b71d71d7d6a71fddaed71535887e19e44c0/gstreamer/src/pad.rs#L672

This generates

#[repr(C)]
pub struct GHookList {
    pub seq_id: c_ulong,
    #[cfg(any(not(windows), not(target_pointer_width = "64")))]
    pub hook_size_and_setup: gpointer,
    #[cfg(all(windows, target_pointer_width = "64"))]
    pub hook_size_and_setup: c_ulong,
    pub hooks: *mut GHook,
    pub dummy3: gpointer,
    pub finalize_hook: GHookFinalizeFunc,
    pub dummy: [gpointer; 2],
}

I think this is correct on 64 bit Windows but I'm not entirely sure. Can someone (@nirbheek) print sizeof(GHookList) from C on 32 bit and 64 bit Windows so we can be sure? My expectation is 28 bytes (32 bit Windows, and 32 bit everywhere) and 48 bytes (64 bit Windows), and 56 bytes (64 bit everywhere else).

@sdroege
Copy link
Member Author

sdroege commented Sep 18, 2017

Related: #465

@nirbheek
Copy link

nirbheek commented Sep 18, 2017

Can someone (@nirbheek) print sizeof(GHookList) from C on 32 bit and 64 bit Windows so we can be sure? My expectation is 28 bytes (32 bit Windows, and 32 bit everywhere) and 48 bytes (64 bit Windows)

Your expectation is correct. I tested this by building a C program with 64-bit MSVC against 64-bit MinGW glib and 32-bit MSVC against 32-bit MinGW glib. To reiterate:

sizeof GHookList on 64-bit is 48
sizeof GHookList on 32-bit is 28

I can test against a glib built with MSVC, but that will take longer.

Edit: glib built with MSVC (32-bit and 64-bit) gave the same results.

@sdroege
Copy link
Member Author

sdroege commented Sep 18, 2017

Great, thanks!

@EPashkin
Copy link
Member

Thanks, @sdroege

@EPashkin EPashkin merged commit 844ef55 into gtk-rs:master Sep 18, 2017
GuillaumeGomez pushed a commit to gtk-rs/gtk3-rs that referenced this pull request Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants