What does '_IO(...)' mean in C headers in Linux?
They define ioctl numbers, based on ioctl function and input parameters.
The are defined in kernel, in include/asm-generic/ioctl.h
.
You need to include <linux/ioctl.h>
(or linux/asm-generic/ioctl.h
) in your program. Before including/usr/src/linux-headers-3.2.0-35/include/linux/usbdevice_fs.h
You can't "precompile" this values (e.g. USBDEVFS_DISCARDURB
), because they can be different on other platforms. For example, you are developing your code on plain old x86, but then someone will try to use it on x86_64/arm/mips/etc. So you should always include kernel's ioctl.h
to make sure, you are using right values.
/proc filesystem advantages
You should see /proc as a pipe to kernel. You can modify kernel parameters and see what kernel is doing at a moment in time.
Regards
Macro definition to determine big endian or little endian machine?
Code supporting arbitrary byte orders, ready to be put into a file called order32.h
:
#ifndef ORDER32_H
#define ORDER32_H
#include <limits.h>
#include <stdint.h>
#if CHAR_BIT != 8
#error "unsupported char size"
#endif
enum
{
O32_LITTLE_ENDIAN = 0x03020100ul,
O32_BIG_ENDIAN = 0x00010203ul,
O32_PDP_ENDIAN = 0x01000302ul, /* DEC PDP-11 (aka ENDIAN_LITTLE_WORD) */
O32_HONEYWELL_ENDIAN = 0x02030001ul /* Honeywell 316 (aka ENDIAN_BIG_WORD) */
};
static const union { unsigned char bytes[4]; uint32_t value; } o32_host_order =
{ { 0, 1, 2, 3 } };
#define O32_HOST_ORDER (o32_host_order.value)
#endif
You would check for little endian systems via
O32_HOST_ORDER == O32_LITTLE_ENDIAN
What is the meaning of the using guard macro in struct definition
You are right that there is no change in the behavior of the code.
There is no apparent benefit from the code you show.
This is because
#define GS
Defines GS
as nothing, so after the preprocessor finishes, there is no difference from not including it in the declaration of the struct.
struct gs {
What could be the reason would be if there is some other tool that reads the code before the preprocessor and marks some kind of usage.
Note: in the comments, you reference other code. That code may, depending on other flags, set the macro to something, such as BOOST_SYMBOL_EXPORT
. That then may have specific meaning. These kinds of usage are often used for marking classes as export or import depending on what the compiler is doing at the time.
Related Topics
Difference Between Arm-None-Eabi and Arm-Linux-Gnueabi
Os X Permission Denied for /Usr/Local/Lib
Why Does Pages Allocation with Order of 10 or 11 Using _Get_Free_Pages() Usually Fail
Gcloud - How to Automate Installation of Gcloud on a Server
Self Updating Bash Script from Github
Git Clone Fails: Server Certificate Verification Failed
What Is Dma Mapping and Dma Engine in Context of Linux Kernel
Live Socket Monitoring with Netlink Inet_Diag
Checking If a Screen of The Specified Name Exists
Implicit Declaration of Function 'Create_Proc_Entry'
Is There a 'ssh-Add' Linux Alpine One Liner
Finding Threading Bottlenecks and Optimizing for Wall-Time with Perf
Is There a Libc in Kernel Space
Does I2C Driver Need to Be Implemented Just Like Any Other Character Device Driver