14

I was just looking at the way to get unique thread ID's in Linux. The way I found was to do as syscall with either of the two parameters as arguments: __NR_gettid OR SYS_gettid.

Can anybody explain how they both differ with respect to each other?

Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
user3328377
  • 151
  • 1
  • 4
  • Note, for _usages_ of these system calls, see [here](https://stackoverflow.com/a/63827823/4561887): `#define gettid() ((pid_t)syscall(SYS_gettid))`, [here](https://stackoverflow.com/a/32211287/4561887):`pid_t x = syscall(__NR_gettid);`, and [here](https://stackoverflow.com/a/43311517/4561887): `pid_t tid = syscall(SYS_gettid);`. – Gabriel Staples Sep 24 '21 at 00:11

1 Answers1

17

Nothing

in <bits/syscall.h> there is this:

#define SYS_gettid __NR_gettid
Salgar
  • 7,687
  • 1
  • 25
  • 39
  • 1
    Correct for this one. However, `SYS_xzy` are the preferred symbol to access a syscall. – alk Mar 12 '14 at 13:10
  • On modern systems, `` seems to simply include either `` or `` (depending on whether your system is 32 or 64 bits), which then has that `#define SYS_gettid __NR_gettid` line. – Gabriel Staples Sep 22 '21 at 21:30