title: Where is the logic of comparing '__libc_multiple_threads'?
body: <p>In analyzing <strong>iofclose.c</strong> file, I found some strange part of that.</p>
  <pre class="lang-c prettyprint-override"><code>// glibc-2.23.90/libio/iofclose.c:53
  
   if (fp-&gt;_IO_file_flags &amp; _IO_IS_FILEBUF)
      _IO_un_link ((struct _IO_FILE_plus *) fp);
  
    _IO_acquire_lock (fp); // !!!!! This part !!!!!
   ...
  </code></pre>
  <p>As You see this source, <strong>fclose()</strong> calls <code>_IO_acquire_lock</code> internally.</p>
  <p>And <code>_IO_acquire_lock</code> calls <code>_IO_lock_lock</code> below this.</p>
  <pre class="lang-c prettyprint-override"><code>//glibc-2.23.90/sysdeps/nptl/stdio-lock.h:39
  
  #define _IO_lock_lock(_name) \
    do {                                        \
      void *__self = THREAD_SELF;                           \
      if ((_name).owner != __self)                          \
        {                                       \
      lll_lock ((_name).lock, LLL_PRIVATE);                     \
  ...
  </code></pre>
  <p>In <code>_IO_lock_lock</code>, <code>void *__self = THREAD_SELF;</code> and <code>if ((_name).owner != __self)</code> logic is appeared like this.</p>
  <pre><code>0x7f9a21eca393 &lt;_IO_new_fclose+291&gt;: mov    r8,QWORD PTR fs:0x10
     0x7f9a21eca39c &lt;_IO_new_fclose+300&gt;: cmp    r8,QWORD PTR [rdx+0x8]
     0x7f9a21eca3a0 &lt;_IO_new_fclose+304&gt;: je     0x7f9a21eca3e2 &lt;_IO_new_fclose+370&gt;
     0x7f9a21eca3a2 &lt;_IO_new_fclose+306&gt;: mov    esi,0x1
  ...
  </code></pre>
  <p>Then, if <code>lll_lock((_name).lock, LLL_PRIVATE);</code> is called after branch command, <code>lll_lock()</code> is proceeded like this.</p>
  <pre><code>0x7f9a21eca3a2 &lt;_IO_new_fclose+306&gt;: mov    esi,0x1
     0x7f9a21eca3a7 &lt;_IO_new_fclose+311&gt;: xor    eax,eax
     0x7f9a21eca3a9 &lt;_IO_new_fclose+313&gt;:
      cmp    DWORD PTR [rip+0x35c390],0x0        # 0x7f9a22226740 &lt;__libc_multiple_threads&gt;
     0x7f9a21eca3b0 &lt;_IO_new_fclose+320&gt;: je     0x7f9a21eca3ba &lt;_IO_new_fclose+330&gt;
  ...
  </code></pre>
  <p>In this assembly, logic of comparing <code>__libc_multiple_threads</code> is being.</p>
  <p>But, when I saw <code>lll_lock()</code> code, I can't find that logic...</p>
  <pre class="lang-c prettyprint-override"><code>//glibc-2.23.90/sysdeps/unix/sysv/linux/sparc/lowlevellock.h:51
  
  static inline void
  __attribute__ ((always_inline))
  __lll_lock (int *futex, int private)
  {
    int val = atomic_compare_and_exchange_val_24_acq (futex, 1, 0);
  
    if (__glibc_unlikely (val != 0))
      {
        if (__builtin_constant_p (private) &amp;&amp; private == LLL_PRIVATE)
      __lll_lock_wait_private (futex);
        else
      __lll_lock_wait (futex, private);
      }
  }
  #define lll_lock(futex, private) __lll_lock (&amp;(futex), private)
  </code></pre>
  <p>How happened this situation?</p>
  <p>Where can i find these assembly logic in this c source code?</p>