Skip to content

Commit

Permalink
Merge pull request #68 from Shock-1/iox2-54
Browse files Browse the repository at this point in the history
[#54] Rename char in types.rs to c_char.
  • Loading branch information
elfenpiff authored Jan 6, 2024
2 parents 8afd996 + 0fb8390 commit 33ab53b
Show file tree
Hide file tree
Showing 69 changed files with 235 additions and 217 deletions.
2 changes: 1 addition & 1 deletion doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

### Refactoring

* Example [#1](https://github.com/eclipse-iceoryx/iceoryx2/issues/1)
* Rename char in platform to c_char [#54](https://github.com/eclipse-iceoryx/iceoryx2/issues/54)

### Workflow

Expand Down
4 changes: 2 additions & 2 deletions iceoryx2-bb/posix/src/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,11 @@ impl Directory {
let mut contents: Vec<DirectoryEntry> = vec![];
for i in 0..number_of_directory_entries {
let raw_name = unsafe {
(*(*namelist.offset(i as isize))).d_name.as_ptr() as *mut posix::char
(*(*namelist.offset(i as isize))).d_name.as_ptr() as *mut posix::c_char
};
let raw_name_length = unsafe { strlen(raw_name) };

const DOT: posix::char = b'.' as _;
const DOT: posix::c_char = b'.' as _;
// dot is skipped
if raw_name_length == 1 && unsafe { *raw_name == DOT } {
continue;
Expand Down
4 changes: 2 additions & 2 deletions iceoryx2-bb/posix/src/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Group {
self.members.clone()
}

fn extract_entry(&self, field: *mut posix::char, name: &str) -> Result<String, GroupError> {
fn extract_entry(&self, field: *mut posix::c_char, name: &str) -> Result<String, GroupError> {
Ok(
fail!(from self, when unsafe { CStr::from_ptr(field) }.to_str(),
with GroupError::InvalidGroupName,
Expand All @@ -196,7 +196,7 @@ impl Group {
fn populate_entries(&mut self, source: Source) -> Result<(), GroupError> {
let mut group = posix::group::new();
let mut group_ptr: *mut posix::group = &mut group;
let mut buffer: [posix::char; GROUP_BUFFER_SIZE] = [0; GROUP_BUFFER_SIZE];
let mut buffer: [posix::c_char; GROUP_BUFFER_SIZE] = [0; GROUP_BUFFER_SIZE];

let msg;
let errno_value = match source {
Expand Down
8 changes: 4 additions & 4 deletions iceoryx2-bb/posix/src/message_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ pub trait MessageQueueSenderInterface<T>: internal::MessageQueueInterface + Debu
if unsafe {
posix::mq_send(
self.get().mqdes,
(value as *const T) as *const posix::char,
(value as *const T) as *const posix::c_char,
std::mem::size_of::<T>(),
prio,
)
Expand Down Expand Up @@ -615,7 +615,7 @@ pub trait MessageQueueSenderInterface<T>: internal::MessageQueueInterface + Debu
if unsafe {
posix::mq_timedsend(
self.get().mqdes,
(value as *const T) as *const posix::char,
(value as *const T) as *const posix::c_char,
std::mem::size_of::<T>(),
prio,
&timeout.as_timespec(),
Expand Down Expand Up @@ -696,7 +696,7 @@ pub trait MessageQueueReceiverInterface<T>: internal::MessageQueueInterface + De
let received_bytes = unsafe {
posix::mq_receive(
self.get().mqdes,
data.as_mut_ptr() as *mut posix::char,
data.as_mut_ptr() as *mut posix::c_char,
std::mem::size_of::<T>(),
&mut priority,
)
Expand Down Expand Up @@ -749,7 +749,7 @@ pub trait MessageQueueReceiverInterface<T>: internal::MessageQueueInterface + De
let received_bytes = unsafe {
posix::mq_timedreceive(
self.get().mqdes,
data.as_mut_ptr() as *mut posix::char,
data.as_mut_ptr() as *mut posix::c_char,
std::mem::size_of::<T>(),
&mut priority,
&timeout.as_timespec(),
Expand Down
5 changes: 3 additions & 2 deletions iceoryx2-bb/posix/src/system_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ impl Limit {
pub fn value(&self) -> u64 {
match self {
Limit::MaxPathLength | Limit::MaxFileNameLength => {
let result =
unsafe { posix::pathconf("/".as_ptr() as *const posix::char, -(*self as i32)) };
let result = unsafe {
posix::pathconf("/".as_ptr() as *const posix::c_char, -(*self as i32))
};
result.clamp(0, posix::long::MAX) as u64
}
Limit::MaxUnixDomainSocketNameLength => {
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-bb/posix/src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ impl ThreadProperties for ThreadHandle {
return Ok(unsafe { self.name.get().as_ref().unwrap() });
}

let mut name: [posix::char; MAX_THREAD_NAME_LENGTH] = [0; MAX_THREAD_NAME_LENGTH];
let mut name: [posix::c_char; MAX_THREAD_NAME_LENGTH] = [0; MAX_THREAD_NAME_LENGTH];

let msg = "Unable to acquire thread name";
match unsafe {
Expand Down
4 changes: 2 additions & 2 deletions iceoryx2-bb/posix/src/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl User {
self.password.as_str()
}

fn extract_entry(&self, field: *mut posix::char, name: &str) -> Result<String, UserError> {
fn extract_entry(&self, field: *mut posix::c_char, name: &str) -> Result<String, UserError> {
Ok(
fail!(from self, when unsafe { CStr::from_ptr(field) }.to_str(),
with UserError::InvalidUTF8SymbolsInEntry,
Expand All @@ -200,7 +200,7 @@ impl User {
fn populate_entries_from(&mut self, source: Source) -> Result<(), UserError> {
let mut passwd = posix::passwd::new();
let mut passwd_ptr: *mut posix::passwd = &mut passwd;
let mut buffer: [posix::char; PASSWD_BUFFER_SIZE] = [0; PASSWD_BUFFER_SIZE];
let mut buffer: [posix::c_char; PASSWD_BUFFER_SIZE] = [0; PASSWD_BUFFER_SIZE];

let msg;
let errno_value = match source {
Expand Down
4 changes: 2 additions & 2 deletions iceoryx2-pal/posix/src/freebsd/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ pub unsafe fn acl_set_fd(fd: int, acl: acl_t) -> int {
crate::internal::acl_set_fd(fd, acl)
}

pub unsafe fn acl_to_text(acl: acl_t, len_p: *mut ssize_t) -> *const char {
pub unsafe fn acl_to_text(acl: acl_t, len_p: *mut ssize_t) -> *const c_char {
crate::internal::acl_to_text(acl, len_p)
}

pub unsafe fn acl_from_text(buf_p: *const char) -> acl_t {
pub unsafe fn acl_from_text(buf_p: *const c_char) -> acl_t {
crate::internal::acl_from_text(buf_p)
}
2 changes: 1 addition & 1 deletion iceoryx2-pal/posix/src/freebsd/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::posix::types::*;

pub const CPU_SETSIZE: usize = crate::internal::CPU_SETSIZE as _;
pub const FD_SETSIZE: usize = crate::internal::FD_SETSIZE as _;
pub const NULL_TERMINATOR: char = 0;
pub const NULL_TERMINATOR: c_char = 0;

pub const O_RDONLY: int = crate::internal::O_RDONLY as _;
pub const O_WRONLY: int = crate::internal::O_WRONLY as _;
Expand Down
8 changes: 4 additions & 4 deletions iceoryx2-pal/posix/src/freebsd/dirent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@

use crate::posix::types::*;

pub unsafe fn scandir(path: *const char, namelist: *mut *mut *mut dirent) -> int {
pub unsafe fn scandir(path: *const c_char, namelist: *mut *mut *mut dirent) -> int {
internal::scandir_ext(path, namelist)
}

pub unsafe fn mkdir(pathname: *const char, mode: mode_t) -> int {
pub unsafe fn mkdir(pathname: *const c_char, mode: mode_t) -> int {
crate::internal::mkdir(pathname, mode)
}

pub unsafe fn opendir(dirname: *const char) -> *mut DIR {
pub unsafe fn opendir(dirname: *const c_char) -> *mut DIR {
crate::internal::opendir(dirname)
}

Expand All @@ -40,6 +40,6 @@ mod internal {

#[cfg_attr(target_os = "freebsd", link(name = "c"))]
extern "C" {
pub(super) fn scandir_ext(path: *const char, namelist: *mut *mut *mut dirent) -> int;
pub(super) fn scandir_ext(path: *const c_char, namelist: *mut *mut *mut dirent) -> int;
}
}
8 changes: 4 additions & 4 deletions iceoryx2-pal/posix/src/freebsd/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ macro_rules! ErrnoEnumGenerator {
impl Display for Errno {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
const BUFFER_SIZE: usize = 1024;
let mut buffer: [char; BUFFER_SIZE] = [0; BUFFER_SIZE];
let mut buffer: [c_char; BUFFER_SIZE] = [0; BUFFER_SIZE];
unsafe { strerror_r(*self as i32, buffer.as_mut_ptr(), BUFFER_SIZE) };
let s = match unsafe { CStr::from_ptr(buffer.as_ptr()) }.to_str() {
Ok(v) => v.to_string(),
Expand Down Expand Up @@ -216,11 +216,11 @@ impl Errno {
}
}

pub unsafe fn strerror_r(errnum: int, buf: *mut char, buflen: size_t) -> int {
pub unsafe fn strerror_r(errnum: int, buf: *mut c_char, buflen: size_t) -> int {
internal::strerror_r(errnum, buf, buflen)
}

pub unsafe fn strerror(errnum: int) -> *const char {
pub unsafe fn strerror(errnum: int) -> *const c_char {
crate::internal::strerror(errnum)
}

Expand All @@ -230,6 +230,6 @@ mod internal {
#[cfg_attr(target_os = "freebsd", link(name = "c"))]
extern "C" {
pub(super) fn __error() -> *mut int;
pub(super) fn strerror_r(errnum: int, buf: *mut char, buflen: size_t) -> int;
pub(super) fn strerror_r(errnum: int, buf: *mut c_char, buflen: size_t) -> int;
}
}
4 changes: 2 additions & 2 deletions iceoryx2-pal/posix/src/freebsd/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use crate::posix::types::*;
use crate::posix::Struct;

pub unsafe fn open_with_mode(pathname: *const char, flags: int, mode: mode_t) -> int {
pub unsafe fn open_with_mode(pathname: *const c_char, flags: int, mode: mode_t) -> int {
crate::internal::open(pathname, flags, mode as core::ffi::c_uint)
}

Expand Down Expand Up @@ -47,6 +47,6 @@ pub unsafe fn fchmod(fd: int, mode: mode_t) -> int {
crate::internal::fchmod(fd, mode)
}

pub unsafe fn open(pathname: *const char, flags: int) -> int {
pub unsafe fn open(pathname: *const c_char, flags: int) -> int {
crate::internal::open(pathname, flags)
}
6 changes: 3 additions & 3 deletions iceoryx2-pal/posix/src/freebsd/mman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ pub unsafe fn munlockall() -> int {
crate::internal::munlockall()
}

pub unsafe fn shm_open(name: *const char, oflag: int, mode: mode_t) -> int {
pub unsafe fn shm_open(name: *const c_char, oflag: int, mode: mode_t) -> int {
crate::internal::shm_open(name, oflag, mode)
}

pub unsafe fn shm_unlink(name: *const char) -> int {
pub unsafe fn shm_unlink(name: *const c_char) -> int {
crate::internal::shm_unlink(name)
}

Expand Down Expand Up @@ -138,6 +138,6 @@ pub unsafe fn sysctl(
crate::internal::sysctl(name, namelen, oldp, oldlenp, newp, newlen)
}

pub unsafe fn sysctlnametomib(name: *mut char, mibp: *mut int, sizep: *mut size_t) -> int {
pub unsafe fn sysctlnametomib(name: *mut c_char, mibp: *mut int, sizep: *mut size_t) -> int {
crate::internal::sysctlnametomib(name, mibp, sizep)
}
19 changes: 12 additions & 7 deletions iceoryx2-pal/posix/src/freebsd/mqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@

use crate::posix::types::*;

pub unsafe fn mq_open4(name: *const char, flags: int, mode: mode_t, attr: *mut mq_attr) -> mqd_t {
pub unsafe fn mq_open4(name: *const c_char, flags: int, mode: mode_t, attr: *mut mq_attr) -> mqd_t {
crate::internal::mq_open(name, flags, mode as uint, attr)
}

pub unsafe fn mq_open2(name: *const char, flags: int) -> mqd_t {
pub unsafe fn mq_open2(name: *const c_char, flags: int) -> mqd_t {
crate::internal::mq_open(name, flags)
}

pub unsafe fn mq_close(mqdes: mqd_t) -> int {
crate::internal::mq_close(mqdes)
}

pub unsafe fn mq_unlink(name: *const char) -> int {
pub unsafe fn mq_unlink(name: *const c_char) -> int {
crate::internal::mq_unlink(name)
}

Expand All @@ -41,7 +41,7 @@ pub unsafe fn mq_setattr(mqdes: mqd_t, newattr: *const mq_attr, oldattr: *mut mq

pub unsafe fn mq_receive(
mqdes: mqd_t,
msg_ptr: *mut char,
msg_ptr: *mut c_char,
msg_len: size_t,
msg_prio: *mut uint,
) -> ssize_t {
Expand All @@ -50,21 +50,26 @@ pub unsafe fn mq_receive(

pub unsafe fn mq_timedreceive(
mqdes: mqd_t,
msg_ptr: *mut char,
msg_ptr: *mut c_char,
msg_len: size_t,
msg_prio: *mut uint,
abs_timeout: *const timespec,
) -> ssize_t {
crate::internal::mq_timedreceive(mqdes, msg_ptr, msg_len, msg_prio, abs_timeout)
}

pub unsafe fn mq_send(mqdes: mqd_t, msg_ptr: *const char, msg_len: size_t, msg_prio: uint) -> int {
pub unsafe fn mq_send(
mqdes: mqd_t,
msg_ptr: *const c_char,
msg_len: size_t,
msg_prio: uint,
) -> int {
crate::internal::mq_send(mqdes, msg_ptr, msg_len, msg_prio)
}

pub unsafe fn mq_timedsend(
mqdes: mqd_t,
msg_ptr: *const char,
msg_ptr: *const c_char,
msg_len: size_t,
msg_prio: uint,
abs_timeout: *const timespec,
Expand Down
8 changes: 4 additions & 4 deletions iceoryx2-pal/posix/src/freebsd/pthread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ pub unsafe fn pthread_self() -> pthread_t {
crate::internal::pthread_self()
}

pub unsafe fn pthread_setname_np(thread: pthread_t, name: *const char) -> int {
pub unsafe fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> int {
internal::pthread_setname_np(thread, name)
}

pub unsafe fn pthread_getname_np(thread: pthread_t, name: *mut char, len: size_t) -> int {
pub unsafe fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size_t) -> int {
internal::pthread_getname_np(thread, name, len)
}

Expand Down Expand Up @@ -346,8 +346,8 @@ mod internal {
cpuset: *const cpu_set_t,
) -> int;

pub(super) fn pthread_setname_np(thread: pthread_t, name: *const char) -> int;
pub(super) fn pthread_getname_np(thread: pthread_t, name: *mut char, len: size_t) -> int;
pub(super) fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> int;
pub(super) fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size_t) -> int;
pub(super) fn pthread_kill(thread: pthread_t, sig: int) -> int;
pub(super) fn pthread_setaffinity_np(
thread: pthread_t,
Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-pal/posix/src/freebsd/pwd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
use crate::posix::types::*;

pub unsafe fn getpwnam_r(
name: *const char,
name: *const c_char,
pwd: *mut passwd,
buf: *mut char,
buf: *mut c_char,
buflen: size_t,
result: *mut *mut passwd,
) -> int {
Expand All @@ -27,17 +27,17 @@ pub unsafe fn getpwnam_r(
pub unsafe fn getpwuid_r(
uid: uid_t,
pwd: *mut passwd,
buf: *mut char,
buf: *mut c_char,
buflen: size_t,
result: *mut *mut passwd,
) -> int {
crate::internal::getpwuid_r(uid, pwd, buf, buflen, result)
}

pub unsafe fn getgrnam_r(
name: *const char,
name: *const c_char,
grp: *mut group,
buf: *mut char,
buf: *mut c_char,
buflen: size_t,
result: *mut *mut group,
) -> int {
Expand All @@ -47,7 +47,7 @@ pub unsafe fn getgrnam_r(
pub unsafe fn getgrgid_r(
gid: gid_t,
grp: *mut group,
buf: *mut char,
buf: *mut c_char,
buflen: size_t,
result: *mut *mut group,
) -> int {
Expand Down
6 changes: 3 additions & 3 deletions iceoryx2-pal/posix/src/freebsd/semaphore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use crate::posix::types::*;

pub unsafe fn sem_create(name: *const char, oflag: int, mode: mode_t, value: uint) -> *mut sem_t {
pub unsafe fn sem_create(name: *const c_char, oflag: int, mode: mode_t, value: uint) -> *mut sem_t {
crate::internal::sem_open(name, oflag, mode as core::ffi::c_uint, value)
}

Expand All @@ -35,11 +35,11 @@ pub unsafe fn sem_timedwait(sem: *mut sem_t, abs_timeout: *const timespec) -> in
crate::internal::sem_timedwait(sem, abs_timeout)
}

pub unsafe fn sem_unlink(name: *const char) -> int {
pub unsafe fn sem_unlink(name: *const c_char) -> int {
crate::internal::sem_unlink(name)
}

pub unsafe fn sem_open(name: *const char, oflag: int) -> *mut sem_t {
pub unsafe fn sem_open(name: *const c_char, oflag: int) -> *mut sem_t {
crate::internal::sem_open(name, oflag)
}

Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-pal/posix/src/freebsd/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use crate::posix::types::*;
use crate::posix::Struct;

pub unsafe fn stat(path: *const char, buf: *mut stat_t) -> int {
pub unsafe fn stat(path: *const c_char, buf: *mut stat_t) -> int {
let mut os_specific_buffer = crate::internal::stat::new();
match crate::internal::stat(path, &mut os_specific_buffer) {
0 => {
Expand Down
Loading

0 comments on commit 33ab53b

Please sign in to comment.