title: (((long)*(ptr)) << 1) >> 1;
body: <p>One of my friends asked me this question,and I do else not know the meaning of the function.Maybe like the note above them <code>/* sign-extend to 32 bits */</code>.But I want to know the detail how the function realize role "sign-extend to 32 bits".</p>
  
  <p>The function from Linux kernel. thx all.</p>
  
  <p>Like @unwind said, the complete definition of the function is this:</p>
  
  <pre><code>/* Convert a prel31 symbol to an absolute address */
  #define prel31_to_addr(ptr)                         \
  ({                                                  \
      /* sign-extend to 32 bits */                    \
      long offset = (((long)*(ptr)) &lt;&lt; 1) &gt;&gt; 1;       \
      (unsigned long)(ptr) + offset;                  \
  })
  </code></pre>
  
  <p>and it would be used in the function:</p>
  
  <pre><code>int __init unwind_init(void)
  {
      struct unwind_idx *idx;
  
      /* Convert the symbol addresses to absolute values */
      for (idx = __start_unwind_idx; idx &lt; __stop_unwind_idx; idx++)
          idx-&gt;addr = prel31_to_addr(&amp;idx-&gt;addr);
  
      pr_debug("unwind: ARM stack unwinding initialised\n");
  
      return 0;
  }
  </code></pre>