Container codes can be found in /usr/include/c++/4.8.5/bits
. What about source codes of other stl libs, such as mutex, future, etc?
Asked
Active
Viewed 243 times
0

SuperBald
- 109
- 1
- 12
-
1https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h – Nov 04 '18 at 19:20
-
Thread related stuff under unix is based on libpthread. – freakish Nov 04 '18 at 19:20
-
2... in `bits` too. Hardcore way to find out a few: `$ grep -ri "class future :" /usr/include/c++` gives `/usr/include/c++/8.2.1/future: class future : public __basic_future<_Res>` for me. – asu Nov 04 '18 at 19:27
-
1You can down load the entire source code for the compiler and the libraries from the GCC website. https://www.gnu.org/software/gcc/ – Galik Nov 04 '18 at 19:30
-
You may be able to check it out as a package in whatever package manager is used by whatever Linux distribution you are using, but the GCC source code does not normally come pre-installed. – user4581301 Nov 04 '18 at 19:36
1 Answers
0
glibc uses NPTL on Linux, and the mutex implementation is split across various directories:
nptl
: High-level POSIX threads mutexes in thepthread_mutex_*.c
source files.sysdeps/nptl
: Documentation and stubs for the futex wrappers inlowlevellock*.h
.sysdeps/unix/sysv/linux
:futex
system call wrappers inlowlevellock-futex.h
.- Architecture-specific subdirectories such as
sysdeps/unix/sysv/linux/x86_64
: Inline assembler functions for low-level lock operations inlowlevellock.h
andlowlevellock.S
.
Most synchronization types in libstdc++
(the C++ standard library implementation in GCC) are themselves wrappers around the libpthread
library component of glibc (only on GNU/Linux, of course).

Florian Weimer
- 32,022
- 3
- 48
- 92