Skip to content

Add resolv #4618

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Add resolv #4618

wants to merge 1 commit into from

Conversation

lorenzleutgeb
Copy link

@lorenzleutgeb lorenzleutgeb commented Aug 5, 2025

Description

See #4611

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@rustbot label +stable-nominated

@rustbot rustbot added O-linux-like O-unix stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Aug 5, 2025
@lorenzleutgeb lorenzleutgeb force-pushed the resolv branch 2 times, most recently from c82667c to a67b6e7 Compare August 5, 2025 14:57
@devnexen
Copy link
Contributor

devnexen commented Aug 7, 2025

several things at quick glance :

  • res_init is already defined for supported platforms (see src/unix/mod.rs)
  • couple of definitions errors, with this change it passes for me
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index 86e5baa8..2260d010 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -4218,7 +4218,6 @@ regmatch_t
 regoff_t
 remap_file_pages
 removexattr
-res_init
 res_mkquery
 res_query
 res_querydomain
diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs
index ef7426df..41e9999b 100644
--- a/src/unix/linux_like/mod.rs
+++ b/src/unix/linux_like/mod.rs
@@ -2069,8 +2069,6 @@ extern "C" {
     pub fn setdomainname(name: *const c_char, len: size_t) -> c_int;
 
     // <resolv.h>
-    #[allow(dead_code)]
-    pub fn res_init() -> c_int;
     pub fn res_query(
         dname: *const c_char,
         class: c_int,
@@ -2098,13 +2096,13 @@ extern "C" {
         dname: *const c_char,
         class: c_int,
         kind: c_int,
-        data: *mut c_char,
-        newrr: *const c_void,
+        data: *const c_uchar,
         datalen: c_int,
-        buf: *mut c_char,
+        newrr: *const c_uchar,
+        buf: *mut c_uchar,
         buflen: c_int,
     ) -> c_int;
-    pub fn res_send(msg: *const c_char, msglen: c_int, answer: *mut c_char, anslen: c_int)
+    pub fn res_send(msg: *const c_uchar, msglen: c_int, answer: *mut c_uchar, anslen: c_int)
         -> c_int;
 }

hope it helps (hopefully it will pass on android :) do not have the sdk and nothing set to check it).

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is the linking story here, by the way? Are the symbols always distributed with the libc binary?

@@ -2062,6 +2067,45 @@ extern "C" {

pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int;
pub fn setdomainname(name: *const c_char, len: size_t) -> c_int;

// <resolv.h>
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be needed

Comment on lines +2096 to +2106
pub fn res_mkquery(
op: c_int,
dname: *const c_char,
class: c_int,
kind: c_int,
data: *mut c_char,
newrr: *const c_void,
datalen: c_int,
buf: *mut c_char,
buflen: c_int,
) -> c_int;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to match the definitions linked at #4611: those have data as const and followed by an integer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also few arguments misplacements see above my comment and on linux it should be linked to libresolv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-linux-like O-unix stable-nominated This PR should be considered for cherry-pick to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants