Skip to content
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

Wrong values generated of constants defined by #define for a linux header file. #2926

Closed
AnirbanHalder654322 opened this issue Sep 6, 2024 · 1 comment

Comments

@AnirbanHalder654322
Copy link

AnirbanHalder654322 commented Sep 6, 2024

Taken from this https://github.com/torvalds/linux/blob/master/include/uapi/linux/posix_acl.h .

Input C/C++ Header

#define ACL_UNDEFINED_ID	(-1)

/* a_type field in acl_user_posix_entry_t */
#define ACL_TYPE_ACCESS		(0x8000)
#define ACL_TYPE_DEFAULT	(0x4000)

/* e_tag entry in struct posix_acl_entry */
#define ACL_USER_OBJ		(0x01)
#define ACL_USER		(0x02)
#define ACL_GROUP_OBJ		(0x04)
#define ACL_GROUP		(0x08)
#define ACL_MASK		(0x10)
#define ACL_OTHER		(0x20)

/* permissions in the e_perm field */
#define ACL_READ		(0x04)
#define ACL_WRITE		(0x02)
#define ACL_EXECUTE	(0x01)

Bindgen Invocation

$ bindgen input.h -o output.rs

Actual Results

pub const ACL_UNDEFINED_ID: i32 = -1;
pub const ACL_TYPE_ACCESS: u32 = 32768;
pub const ACL_TYPE_DEFAULT: u32 = 16384;
pub const ACL_USER_OBJ: u32 = 1;
pub const ACL_USER: u32 = 2;
pub const ACL_GROUP_OBJ: u32 = 4;
pub const ACL_GROUP: u32 = 8;
pub const ACL_MASK: u32 = 16;
pub const ACL_OTHER: u32 = 32;
pub const ACL_READ: u32 = 4;
pub const ACL_WRITE: u32 = 2;
pub const ACL_EXECUTE: u32 = 1;

Expected Results

The correct parsing and generation of the u32 value, this is plaguing few rust libc functions.

@AnirbanHalder654322 AnirbanHalder654322 changed the title Wrong generation of constants defined by #DEFINE for a linux header file. Wrong generation of constants defined by #define for a linux header file. Sep 6, 2024
@AnirbanHalder654322 AnirbanHalder654322 changed the title Wrong generation of constants defined by #define for a linux header file. Wrong values generated of constants defined by #define for a linux header file. Sep 6, 2024
@pvdrz
Copy link
Contributor

pvdrz commented Sep 7, 2024

duplicate of #1594

@pvdrz pvdrz closed this as completed Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants