Skip to content

libc::ucontext_t does not match aarch64-linux-android NDK. #5159

Description

@StackOverflowExcept1on

https://android.googlesource.com/platform/bionic/+/refs/tags/ndk-r29/libc/include/sys/ucontext.h
~/Android/Sdk/ndk/29.0.14206865/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/aarch64-linux-android/asm/ucontext.h:

/*
 * This file is auto-generated. Modifications will be lost.
 *
 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
 * for more information.
 */
#ifndef _UAPI__ASM_UCONTEXT_H
#define _UAPI__ASM_UCONTEXT_H
#include <linux/types.h>
struct ucontext {
  unsigned long uc_flags;
  struct ucontext * uc_link;
  stack_t uc_stack;
  sigset_t uc_sigmask;
  __u8 __linux_unused[1024 / 8 - sizeof(sigset_t)];
  struct sigcontext uc_mcontext;
};
#endif
#include <ucontext.h>

static_assert(offsetof(ucontext_t, uc_flags) == 0);
static_assert(offsetof(ucontext_t, uc_link) == 8);
static_assert(offsetof(ucontext_t, uc_stack) == 16);
static_assert(offsetof(ucontext_t, uc_sigmask) == 40);
static_assert(offsetof(ucontext_t, uc_mcontext) == 176);

static_assert(sizeof(ucontext_t) == 4560);
fn main() {
    const _: () = {
        assert!(std::mem::offset_of!(libc::ucontext_t, uc_flags) == 0);
        assert!(std::mem::offset_of!(libc::ucontext_t, uc_link) == 8);
        assert!(std::mem::offset_of!(libc::ucontext_t, uc_stack) == 16);
        assert!(std::mem::offset_of!(libc::ucontext_t, uc_sigmask) == 40);
        assert!(std::mem::offset_of!(libc::ucontext_t, uc_mcontext) == 48);

        assert!(std::mem::size_of::<libc::ucontext_t>() == 4432);
    };
}

I compiled first one using one of latest Android NDK versions (though not in Android Studio), and I built second one in Termux using latest version of libc.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions