Skip to content

Commit 94b478d

Browse files
committed
freebsd auxiliary vectors type addition
1 parent e4d2225 commit 94b478d

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
@@ -1744,6 +1744,7 @@ fn test_freebsd(target: &str) {
17441744
"limits.h",
17451745
"link.h",
17461746
"locale.h",
1747+
"machine/elf.h",
17471748
"machine/reg.h",
17481749
"malloc_np.h",
17491750
"mqueue.h",
@@ -1818,7 +1819,8 @@ fn test_freebsd(target: &str) {
18181819
cfg.type_name(move |ty, is_struct, is_union| {
18191820
match ty {
18201821
// Just pass all these through, no need for a "struct" prefix
1821-
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" => ty.to_string(),
1822+
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr"
1823+
| "Elf32_Auxinfo" | "Elf64_Auxinfo" => ty.to_string(),
18221824

18231825
// FIXME: https://github.com/rust-lang/libc/issues/1273
18241826
"sighandler_t" => "sig_t".to_string(),
@@ -2036,6 +2038,9 @@ fn test_freebsd(target: &str) {
20362038
// is PATH_MAX long but tests can't accept multi array as equivalent.
20372039
("kinfo_vmentry", "kve_path") => true,
20382040

2041+
// a_un field is a union
2042+
("Elf32_Auxinfo", "a_un") => true,
2043+
("Elf64_Auxinfo", "a_un") => true,
20392044
_ => false,
20402045
}
20412046
});

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
@@ -269,6 +283,7 @@ EXTATTR_NAMESPACE_USER
269283
EXTB
270284
EXTPROC
271285
Elf32_Addr
286+
Elf32_Auxinfo
272287
Elf32_Half
273288
Elf32_Lword
274289
Elf32_Off

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

+75
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,17 @@ s_no_extra_traits! {
266266
__unused1: ::c_int,
267267
__unused2: [::c_long; 7]
268268
}
269+
270+
#[cfg(libc_union)]
271+
pub union __c_anonymous_elf32_auxv_union {
272+
pub a_val: ::c_int,
273+
}
274+
275+
pub struct Elf32_Auxinfo {
276+
pub a_type: ::c_int,
277+
#[cfg(libc_union)]
278+
pub a_un: __c_anonymous_elf32_auxv_union,
279+
}
269280
}
270281

271282
cfg_if! {
@@ -486,6 +497,53 @@ cfg_if! {
486497
self.sigev_notify_thread_id.hash(state);
487498
}
488499
}
500+
#[cfg(libc_union)]
501+
impl PartialEq for __c_anonymous_elf32_auxv_union {
502+
fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool {
503+
unsafe { self.a_val == other.a_val}
504+
}
505+
}
506+
#[cfg(libc_union)]
507+
impl Eq for __c_anonymous_elf32_auxv_union {}
508+
#[cfg(libc_union)]
509+
impl ::fmt::Debug for __c_anonymous_elf32_auxv_union {
510+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
511+
f.debug_struct("a_val")
512+
.field("a_val", unsafe { &self.a_val })
513+
.finish()
514+
}
515+
}
516+
#[cfg(not(libc_union))]
517+
impl PartialEq for Elf32_Auxinfo {
518+
fn eq(&self, other: &Elf32_Auxinfo) -> bool {
519+
self.a_type == other.a_type
520+
}
521+
}
522+
#[cfg(libc_union)]
523+
impl PartialEq for Elf32_Auxinfo {
524+
fn eq(&self, other: &Elf32_Auxinfo) -> bool {
525+
self.a_type == other.a_type
526+
&& self.a_un == other.a_un
527+
}
528+
}
529+
impl Eq for Elf32_Auxinfo {}
530+
#[cfg(not(libc_union))]
531+
impl ::fmt::Debug for Elf32_Auxinfo {
532+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
533+
f.debug_struct("Elf32_Auxinfo")
534+
.field("a_type", &self.a_type)
535+
.finish()
536+
}
537+
}
538+
#[cfg(libc_union)]
539+
impl ::fmt::Debug for Elf32_Auxinfo {
540+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
541+
f.debug_struct("Elf32_Auxinfo")
542+
.field("a_type", &self.a_type)
543+
.field("a_un", &self.a_un)
544+
.finish()
545+
}
546+
}
489547
}
490548
}
491549

@@ -1266,6 +1324,23 @@ pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x200;
12661324
pub const AT_SYMLINK_FOLLOW: ::c_int = 0x400;
12671325
pub const AT_REMOVEDIR: ::c_int = 0x800;
12681326

1327+
pub const AT_NULL: ::c_int = 0;
1328+
pub const AT_IGNORE: ::c_int = 1;
1329+
pub const AT_EXECFD: ::c_int = 2;
1330+
pub const AT_PHDR: ::c_int = 3;
1331+
pub const AT_PHENT: ::c_int = 4;
1332+
pub const AT_PHNUM: ::c_int = 5;
1333+
pub const AT_PAGESZ: ::c_int = 6;
1334+
pub const AT_BASE: ::c_int = 7;
1335+
pub const AT_FLAGS: ::c_int = 8;
1336+
pub const AT_ENTRY: ::c_int = 9;
1337+
pub const AT_NOTELF: ::c_int = 10;
1338+
pub const AT_UID: ::c_int = 11;
1339+
pub const AT_EUID: ::c_int = 12;
1340+
pub const AT_GID: ::c_int = 13;
1341+
pub const AT_EGID: ::c_int = 14;
1342+
pub const AT_EXECPATH: ::c_int = 15;
1343+
12691344
pub const TABDLY: ::tcflag_t = 0x00000004;
12701345
pub const TAB0: ::tcflag_t = 0x00000000;
12711346
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)