Skip to content

Commit

Permalink
Auto merge of #2534 - devnexen:haiku_dl_phdr, r=JohnTitor
Browse files Browse the repository at this point in the history
haiku dl_phdr_iterate addition (supports since beta3).
  • Loading branch information
bors committed Nov 15, 2021
2 parents f789339 + 5bd59f7 commit 3e36a07
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/unix/haiku/b32.rs
@@ -1,3 +1,20 @@
pub type c_long = i32;
pub type c_ulong = u32;
pub type time_t = i32;

pub type Elf_Addr = ::Elf32_Addr;
pub type Elf_Half = ::Elf32_Half;
pub type Elf_Phdr = ::Elf32_Phdr;

s! {
pub struct Elf32_Phdr {
pub p_type: ::Elf32_Word,
pub p_offset: ::Elf32_Off,
pub p_vaddr: ::Elf32_Addr,
pub p_paddr: ::Elf32_Addr,
pub p_filesz: ::Elf32_Word,
pub p_memsz: ::Elf32_Word,
pub p_flags: ::Elf32_Word,
pub p_align: ::Elf32_Word,
}
}
17 changes: 17 additions & 0 deletions src/unix/haiku/b64.rs
@@ -1,3 +1,20 @@
pub type c_ulong = u64;
pub type c_long = i64;
pub type time_t = i64;

pub type Elf_Addr = ::Elf64_Addr;
pub type Elf_Half = ::Elf64_Half;
pub type Elf_Phdr = ::Elf64_Phdr;

s! {
pub struct Elf64_Phdr {
pub p_type: ::Elf64_Word,
pub p_flags: ::Elf64_Word,
pub p_offset: ::Elf64_Off,
pub p_vaddr: ::Elf64_Addr,
pub p_paddr: ::Elf64_Addr,
pub p_filesz: ::Elf64_Xword,
pub p_memsz: ::Elf64_Xword,
pub p_align: ::Elf64_Xword,
}
}
38 changes: 38 additions & 0 deletions src/unix/haiku/mod.rs
Expand Up @@ -31,6 +31,22 @@ pub type id_t = i32;
pub type idtype_t = ::c_uint;
pub type fd_mask = u32;

pub type Elf32_Addr = u32;
pub type Elf32_Half = u16;
pub type Elf32_Lword = u64;
pub type Elf32_Off = u32;
pub type Elf32_Sword = i32;
pub type Elf32_Word = u32;

pub type Elf64_Addr = u64;
pub type Elf64_Half = u16;
pub type Elf64_Lword = u64;
pub type Elf64_Off = u64;
pub type Elf64_Sword = i32;
pub type Elf64_Sxword = i64;
pub type Elf64_Word = u32;
pub type Elf64_Xword = u64;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl ::Copy for timezone {}
Expand Down Expand Up @@ -343,6 +359,17 @@ s! {
pub sdl_slen: u8,
pub sdl_data: [u8; 46],
}

pub struct dl_phdr_info {
pub dlpi_addr: Elf_Addr,
pub dlpi_name: *const ::c_char,
pub dlpi_phdr: *const Elf_Phdr,
pub dlpi_phnum: Elf_Half,
pub dlpi_adds: ::c_ulonglong,
pub dlpi_subs: ::c_ulonglong,
pub dlpi_tls_modid: usize,
pub dlpi_tls_data: *mut ::c_void,
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1650,6 +1677,17 @@ extern "C" {
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
pub fn setutxent();
pub fn endutxent();

pub fn dl_iterate_phdr(
callback: ::Option<
unsafe extern "C" fn(
info: *mut dl_phdr_info,
size: usize,
data: *mut ::c_void,
) -> ::c_int,
>,
data: *mut ::c_void,
) -> ::c_int;
}

cfg_if! {
Expand Down

0 comments on commit 3e36a07

Please sign in to comment.