मैं glibc में काम कर रहा हूं और मुझे वर्तमान धागे की आईडी प्राप्त करने की आवश्यकता है। इसके लिए मैं syscall(SYS_gettid);
समस्या का उपयोग करता हूं, मुझे आदर्श मामले i.e sys/syscall.h
के बजाय bits/syscall.h
शामिल करने के लिए मजबूर होना पड़ता है।कॉल गेटिड बुद्धिमान glibc
sys/syscall.h
आंतरिक रूप से bits/syscall.h
पर कॉल करता है लेकिन यह #ifndef _LIBC
मैक्रो के साथ लपेटा गया है। यानी
#ifndef _LIBC
/* The Linux kernel header file defines macros `__NR_<name>', but some
programs expect the traditional form `SYS_<name>'. So in building libc
we scan the kernel's list and produce <bits/syscall.h> with macros for
all the `SYS_' names. */
# include <bits/syscall.h>
#endif
भी bits/syscall.h
कहा गया है कि "कभी सीधे बिट्स/syscall.h का उपयोग करें;। sys/syscall.h बजाय शामिल हैं"
_LIBC
के बाद से मेरे मामले में परिभाषित किया जाएगा क्योंकि मैं सीधे malloc.c
, में कोड लिख रहा हूं, कृपया सुझाव दें कि मैं इसे कैसे दूर कर सकता हूं।
धन्यवाद, कपिल
आप '__NR_gettid' का उपयोग क्यों नहीं करते? –