Thursday, December 23, 2010

The __user macro

While studying some USB related kernel code I came across the __user macro defined in include/linux/compiler.h. 
#define __user __attribute__ ((noderef, address_space(1)))
Simple explanations I found after a bit of googling described this macro as being a bit of self-documenting code. This allows you to designate a pointer as belonging to the user address-space, and to let the compiler know that it shouldn't be dereferenced. While I understand the basics of what this means, I decided to ask Stack Overflow if anyone wanted to explain the details and implications of what this means to a systems programmer.

http://stackoverflow.com/questions/4521551/what-are-the-implications-of-the-linux-user-macro

Also, another blogger shed more light on the topic:

http://weichong78.blogspot.com/2006/09/merge-entries-from-another-blog.html