8

In /usr/include/asm/swab.h I found following code:

static __inline__  __u32 __arch_swab32(__u32 val)
{
    __asm__("bswapl %0" : "=r" (val) : "0" (val));
    return val;
}
#define __arch_swab32 __arch_swab32

What is the meaning of the last line, defining a name as itself?

1 Answers1

8

This is called self-referentitial macro:

One common, useful use of self-reference is to create a macro which expands to itself. If you write

 #define EPERM EPERM

then the macro EPERM expands to EPERM. Effectively, it is left alone by the preprocessor whenever it's used in running text. You can tell that it's a macro with #ifdef. You might do this if you want to define numeric constants with an enum, but have #ifdef be true for each constant.

haccks
  • 104,019
  • 25
  • 176
  • 264