File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -263,6 +263,28 @@ pub unsafe extern "C" fn sys_getaddrbyname(
263
263
-ENOSYS
264
264
}
265
265
266
+ /// The system call `sys_getaddrbyname` determine the network host entry.
267
+ /// It expects an array of u8 with a size of in_addr or of in6_addr.
268
+ /// The result of the DNS request will be stored in this array.
269
+ ///
270
+ /// # Example
271
+ ///
272
+ /// ```
273
+ /// use hermit_abi::in_addr;
274
+ /// let c_string = std::ffi::CString::new("rust-lang.org").expect("CString::new failed");
275
+ /// let name = c_string.into_raw();
276
+ /// let mut inaddr: in_addr = Default::default();
277
+ /// let _ = unsafe {
278
+ /// hermit_abi::getaddrbyname(
279
+ /// name,
280
+ /// &mut inaddr as *mut _ as *mut u8,
281
+ /// std::mem::size_of::<in_addr>(),
282
+ /// )
283
+ /// };
284
+ ///
285
+ /// // retake pointer to free memory
286
+ /// let _ = CString::from_raw(name);
287
+ /// ```
266
288
#[ cfg( feature = "dns" ) ]
267
289
#[ hermit_macro:: system]
268
290
#[ no_mangle]
You can’t perform that action at this time.
0 commit comments