📄 self2.c
字号:
/* * self2.c * * Test for pthread_self(). * * Depends on API functions: * pthread_create() * pthread_self() * * Implicitly depends on: * pthread_getspecific() * pthread_setspecific() */#include "test.h"#include <string.h>static pthread_t me;void *entry(void * arg){ me = pthread_self(); return arg;}intmain(){ pthread_t t; assert(pthread_create(&t, NULL, entry, NULL) == 0); Sleep(2000); /* * Not much more we can do here but bytewise compare t with * what pthread_self returned. */ assert(t == me); assert(memcmp((const void *) t, (const void *) me, sizeof t) == 0); /* Success. */ return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -