#define __ONCE_ALIGNMENT的作用是什么?

在pthread源码中x86_64-linux-gnu/bits/pthreadtypes.h

typedef int __ONCE_ALIGNMENT pthread_once_t;

__ONCE_ALIGNMENTx86_64-linux-gnu/bits/pthreadtypes-arch.h中定义:

#define __ONCE_ALIGNMENT

我很疑惑这里的__ONCE_ALIGNMENT的作用? 还望各位大神解答!先提前表示感谢!!!

 ((      /|_/|
  \\.._.'  , ,\
  /\ | '.__ v / 
 (_ .   /   "    系统: 4.9.0-kali4-amd64 Debian x86_64 GNU/Linux
  ) _)._  _ /
 '.\ \|( / ( 
   '' ''\\ \\
阅读 3.2k
1 个回答

glibc/sysdeps/nptl/bits/thread-shared-types.h :

       The additional macro defines any constraint for the lock alignment
       inside the thread structures:
    
       __LOCK_ALIGNMENT - for internal lock/futex usage.
    
       Same idea but for the once locking primitive:
    
       __ONCE_ALIGNMENT - for pthread_once_t/once_flag definition.

glibc/sysdeps/nptl/bits/pthreadtypes.h

       /* Once-only execution */
       typedef int __ONCE_ALIGNMENT pthread_once_t;

Maybe just an once_flag in threads call_once functions. (*~・ω・)~

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进