A question about include/linux/socket.h
Subsystems (2)
Hi,
I am writing CAN bus userspace code and I get a compiler error stating "sa_family_t is not defined" for "include/linux/can.h". sa_family_t is defined in include/linux/socket.h but it is not carried to userspace kernel headers.
When I searched about it I saw that a similar problem ininclude/linux/netlink.h and include/linux/socket.h is fixed by the patch:
I also read about UAPI but I can't use newer kernels.
I searched the kernel git repo but couldn't find a similar patch for can.h. When you search for "sa_family_t" in include/linux directory you can see it is used in more than 10 files and I guess none of those files will compile since they won't be able to find typedef sa_family_t (just like can.h).
So my question is:
- Does anyone remember a patch fixing this issue?
- Should the typedef sa_family_t moved to userspace kernel headers? Or should structs containing sa_family_t type variables moved away from user space?
I have been using the file manually defining sa_family_t but I wanted to ask. I am using kernel version 2.6.37 but I guess can.h file was unchanged until 3.5.
Thanks
Quoted 11 lines · Sinan Akpolat
Hi,
I am writing CAN bus userspace code and I get a compiler error stating "
sa_family_tis not defined" for "include/linux/can.h".sa_family_tis defined ininclude/linux/socket.hbut it is not carried to userspace kernel headers.When I searched about it I saw that a similar problem in
include/linux/netlink.handinclude/linux/socket.his fixed by the patch:
You probably want commit bcb949b8847655516ba499ca75cd8529f167e360, which fixed include/linux/can.h.
Quoted 8 lines
I also read about UAPI but I can't use newer kernels.
I searched the kernel git repo but couldn't find a similar patch for
can.h. When you search for "sa_family_t" ininclude/linuxdirectory you can see it is used in more than 10 files and I guess none of those files will compile since they won't be able to find typedefsa_family_t(just likecan.h).
Quoted 5 lines
So my question is:
- Does anyone remember a patch fixing this issue?
- Should the typedefsa_family_tmoved to userspace kernel headers? Or should structs containingsa_family_ttype variables moved away from user space?
No, sa_family_t is normally defined by the C library headers. But kernel headers generally don't include those (for good reasons). So kernel headers should instead define and use __kernel_sa_family_t, and that's what they do now (mostly).
Ben.
Quoted 3 lines
I have been using the file manually defining
sa_family_tbut I wanted to ask. I am using kernel version 2.6.37 but I guesscan.hfile was unchanged until 3.5.
Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
28.8.2013 17:27 tarihinde, Ben Hutchings yazdı:
Quoted 8 lines · Sinan Akpolat
Quoted 7 lines
Hi,
I am writing CAN bus userspace code and I get a compiler error stating "
sa_family_tis not defined" for "include/linux/can.h".sa_family_tis defined ininclude/linux/socket.hbut it is not carried to userspace kernel headers.
Quoted 6 lines
Quoted 4 lines
When I searched about it I saw that a similar problem in
include/linux/netlink.handinclude/linux/socket.his fixed by the patch:You probably want commit
bcb949b8847655516ba499ca75cd8529f167e360, which fixedinclude/linux/can.h.
Yeah, that's the one. Thank you very much, I couldn't find it using cgit interface in git.kernel.org.
Quoted 14 lines
Quoted 9 lines
I also read about UAPI but I can't use newer kernels.
I searched the kernel git repo but couldn't find a similar patch for
can.h. When you search for "sa_family_t" ininclude/linuxdirectory you can see it is used in more than 10 files and I guess none of those files will compile since they won't be able to find typedefsa_family_t(just likecan.h).Quoted 5 lines
So my question is:
- Does anyone remember a patch fixing this issue?
- Should the typedefsa_family_tmoved to userspace kernel headers? Or should structs containingsa_family_ttype variables moved away from user space?
Quoted 6 lines
No,
sa_family_tis normally defined by the C library headers. But kernel headers generally don't include those (for good reasons). So kernel headers should instead define and use__kernel_sa_family_t, and that's what they do now (mostly).Ben.
Thanks for the info.
Quoted 4 lines
Quoted 4 lines
I have been using the file manually defining
sa_family_tbut I wanted to ask. I am using kernel version 2.6.37 but I guesscan.hfile was unchanged until 3.5.