Skip to content

Commit 56dfe2f

Browse files
committed
Auto merge of #2351 - devnexen:fbsd_auxv_info, r=JohnTitor
freebsd auxiliary vectors type addition
2 parents 4fbc1b4 + 94b478d commit 56dfe2f

File tree

5 files changed

+160
-1
lines changed

5 files changed

+160
-1
lines changed

libc-test/build.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,7 @@ fn test_freebsd(target: &str) {
17471747
"limits.h",
17481748
"link.h",
17491749
"locale.h",
1750+
"machine/elf.h",
17501751
"machine/reg.h",
17511752
"malloc_np.h",
17521753
"mqueue.h",
@@ -1823,7 +1824,8 @@ fn test_freebsd(target: &str) {
18231824
cfg.type_name(move |ty, is_struct, is_union| {
18241825
match ty {
18251826
// Just pass all these through, no need for a "struct" prefix
1826-
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" => ty.to_string(),
1827+
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr"
1828+
| "Elf32_Auxinfo" | "Elf64_Auxinfo" => ty.to_string(),
18271829

18281830
// FIXME: https://github.com/rust-lang/libc/issues/1273
18291831
"sighandler_t" => "sig_t".to_string(),
@@ -2044,6 +2046,9 @@ fn test_freebsd(target: &str) {
20442046
// is PATH_MAX long but tests can't accept multi array as equivalent.
20452047
("kinfo_vmentry", "kve_path") => true,
20462048

2049+
// a_un field is a union
2050+
("Elf32_Auxinfo", "a_un") => true,
2051+
("Elf64_Auxinfo", "a_un") => true,
20472052
_ => false,
20482053
}
20492054
});

libc-test/semver/freebsd-x86_64.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
Elf64_Auxinfo
12
MAP_32BIT
23
_MC_FLAG_MASK
34
_MC_FPFMT_NODEV

libc-test/semver/freebsd.txt

+15
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,25 @@ ATF_COM
7676
ATF_PERM
7777
ATF_PUBL
7878
ATF_USETRAILERS
79+
AT_BASE
7980
AT_EACCESS
81+
AT_EGID
82+
AT_ENTRY
83+
AT_EUID
84+
AT_EXECPATH
8085
AT_FDCWD
86+
AT_FLAGS
87+
AT_GID
88+
AT_NOTELF
89+
AT_NULL
90+
AT_PAGESZ
91+
AT_PHDR
92+
AT_PHENT
93+
AT_PHNUM
8194
AT_REMOVEDIR
8295
AT_SYMLINK_FOLLOW
8396
AT_SYMLINK_NOFOLLOW
97+
AT_UID
8498
B14400
8599
B28800
86100
B460800
@@ -274,6 +288,7 @@ EXTATTR_NAMESPACE_USER
274288
EXTB
275289
EXTPROC
276290
Elf32_Addr
291+
Elf32_Auxinfo
277292
Elf32_Half
278293
Elf32_Lword
279294
Elf32_Off

src/unix/bsd/freebsdlike/freebsd/mod.rs

+75
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,17 @@ s_no_extra_traits! {
299299
__unused1: ::c_int,
300300
__unused2: [::c_long; 7]
301301
}
302+
303+
#[cfg(libc_union)]
304+
pub union __c_anonymous_elf32_auxv_union {
305+
pub a_val: ::c_int,
306+
}
307+
308+
pub struct Elf32_Auxinfo {
309+
pub a_type: ::c_int,
310+
#[cfg(libc_union)]
311+
pub a_un: __c_anonymous_elf32_auxv_union,
312+
}
302313
}
303314

304315
cfg_if! {
@@ -519,6 +530,53 @@ cfg_if! {
519530
self.sigev_notify_thread_id.hash(state);
520531
}
521532
}
533+
#[cfg(libc_union)]
534+
impl PartialEq for __c_anonymous_elf32_auxv_union {
535+
fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool {
536+
unsafe { self.a_val == other.a_val}
537+
}
538+
}
539+
#[cfg(libc_union)]
540+
impl Eq for __c_anonymous_elf32_auxv_union {}
541+
#[cfg(libc_union)]
542+
impl ::fmt::Debug for __c_anonymous_elf32_auxv_union {
543+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
544+
f.debug_struct("a_val")
545+
.field("a_val", unsafe { &self.a_val })
546+
.finish()
547+
}
548+
}
549+
#[cfg(not(libc_union))]
550+
impl PartialEq for Elf32_Auxinfo {
551+
fn eq(&self, other: &Elf32_Auxinfo) -> bool {
552+
self.a_type == other.a_type
553+
}
554+
}
555+
#[cfg(libc_union)]
556+
impl PartialEq for Elf32_Auxinfo {
557+
fn eq(&self, other: &Elf32_Auxinfo) -> bool {
558+
self.a_type == other.a_type
559+
&& self.a_un == other.a_un
560+
}
561+
}
562+
impl Eq for Elf32_Auxinfo {}
563+
#[cfg(not(libc_union))]
564+
impl ::fmt::Debug for Elf32_Auxinfo {
565+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
566+
f.debug_struct("Elf32_Auxinfo")
567+
.field("a_type", &self.a_type)
568+
.finish()
569+
}
570+
}
571+
#[cfg(libc_union)]
572+
impl ::fmt::Debug for Elf32_Auxinfo {
573+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
574+
f.debug_struct("Elf32_Auxinfo")
575+
.field("a_type", &self.a_type)
576+
.field("a_un", &self.a_un)
577+
.finish()
578+
}
579+
}
522580
}
523581
}
524582

@@ -1299,6 +1357,23 @@ pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200;
12991357
pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
13001358
pub const AT_REMOVEDIR: ::c_int = 0x800;
13011359

1360+
pub const AT_NULL: ::c_int = 0;
1361+
pub const AT_IGNORE: ::c_int = 1;
1362+
pub const AT_EXECFD: ::c_int = 2;
1363+
pub const AT_PHDR: ::c_int = 3;
1364+
pub const AT_PHENT: ::c_int = 4;
1365+
pub const AT_PHNUM: ::c_int = 5;
1366+
pub const AT_PAGESZ: ::c_int = 6;
1367+
pub const AT_BASE: ::c_int = 7;
1368+
pub const AT_FLAGS: ::c_int = 8;
1369+
pub const AT_ENTRY: ::c_int = 9;
1370+
pub const AT_NOTELF: ::c_int = 10;
1371+
pub const AT_UID: ::c_int = 11;
1372+
pub const AT_EUID: ::c_int = 12;
1373+
pub const AT_GID: ::c_int = 13;
1374+
pub const AT_EGID: ::c_int = 14;
1375+
pub const AT_EXECPATH: ::c_int = 15;
1376+
13021377
pub const TABDLY: ::tcflag_t = 0x00000004;
13031378
pub const TAB0: ::tcflag_t = 0x00000000;
13041379
pub const TAB3: ::tcflag_t = 0x00000004;

src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs

+63
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,19 @@ s_no_extra_traits! {
8080
pub xmm_reg: [[u8; 16]; 8],
8181
pub xmm_pad: [u8; 224],
8282
}
83+
84+
#[cfg(libc_union)]
85+
pub union __c_anonymous_elf64_auxv_union {
86+
pub a_val: ::c_long,
87+
pub a_ptr: *mut ::c_void,
88+
pub a_fcn: extern "C" fn(),
89+
}
90+
91+
pub struct Elf64_Auxinfo {
92+
pub a_type: ::c_long,
93+
#[cfg(libc_union)]
94+
pub a_un: __c_anonymous_elf64_auxv_union,
95+
}
8396
}
8497

8598
cfg_if! {
@@ -173,6 +186,56 @@ cfg_if! {
173186
self.xmm_pad.hash(state);
174187
}
175188
}
189+
190+
#[cfg(libc_union)]
191+
impl PartialEq for __c_anonymous_elf64_auxv_union {
192+
fn eq(&self, other: &__c_anonymous_elf64_auxv_union) -> bool {
193+
unsafe { self.a_val == other.a_val
194+
|| self.a_ptr == other.a_ptr
195+
|| self.a_fcn == other.a_fcn }
196+
}
197+
}
198+
#[cfg(libc_union)]
199+
impl Eq for __c_anonymous_elf64_auxv_union {}
200+
#[cfg(libc_union)]
201+
impl ::fmt::Debug for __c_anonymous_elf64_auxv_union {
202+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
203+
f.debug_struct("a_val")
204+
.field("a_val", unsafe { &self.a_val })
205+
.finish()
206+
}
207+
}
208+
#[cfg(not(libc_union))]
209+
impl PartialEq for Elf64_Auxinfo {
210+
fn eq(&self, other: &Elf64_Auxinfo) -> bool {
211+
self.a_type == other.a_type
212+
}
213+
}
214+
#[cfg(libc_union)]
215+
impl PartialEq for Elf64_Auxinfo {
216+
fn eq(&self, other: &Elf64_Auxinfo) -> bool {
217+
self.a_type == other.a_type
218+
&& self.a_un == other.a_un
219+
}
220+
}
221+
impl Eq for Elf64_Auxinfo {}
222+
#[cfg(not(libc_union))]
223+
impl ::fmt::Debug for Elf64_Auxinfo {
224+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
225+
f.debug_struct("Elf64_Auxinfo")
226+
.field("a_type", &self.a_type)
227+
.finish()
228+
}
229+
}
230+
#[cfg(libc_union)]
231+
impl ::fmt::Debug for Elf64_Auxinfo {
232+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
233+
f.debug_struct("Elf64_Auxinfo")
234+
.field("a_type", &self.a_type)
235+
.field("a_un", &self.a_un)
236+
.finish()
237+
}
238+
}
176239
}
177240
}
178241

0 commit comments

Comments
 (0)