thread-utils: macros to unconditionally compile pthreads API

When built with NO_PTHREADS, the macros are used make the code build
even though pthreads header and library may be missing. The code can
still have different code paths for no threads support with
HAVE_THREADS variable.

There are of course impacts on no-pthreads builds:

- data structure may get slightly bigger because all the mutexes and
  pthread_t are present (as an int)

- code execution is not impacted much. Locking (in hot path) is
  no-op. Other wrapper function calls really should not matter much.

- the binary size grows bigger because of threaded code. But at least
  on Linux this does not matter, if some code is not executed, it's
  not mapped in memory.

This is a preparation step to remove "#ifdef NO_PTHREADS" in the code
mostly because of maintainability. As Jeff put it

> it's probably OK to stop thinking of it as "non-threaded platforms
> are the default and must pay zero cost" and more as "threaded
> platforms are the default, and non-threaded ones are OK to pay a
> small cost as long as they still work".

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 files changed
tree: 7f6764d952bacb6b262511bfe395ecfb79d7665f
  1. .github/
  2. block-sha1/
  3. builtin/
  4. ci/
  5. compat/
  6. contrib/
  7. Documentation/
  8. ewah/
  9. git-gui/
  10. gitk-git/
  11. gitweb/
  12. mergetools/
  13. negotiator/
  14. perl/
  15. po/
  16. ppc/
  17. refs/
  18. sha1dc/
  19. t/
  20. templates/
  21. vcs-svn/
  22. xdiff/
  23. .clang-format
  24. .editorconfig
  25. .gitattributes
  26. .gitignore
  27. .gitmodules
  28. .mailmap
  29. .travis.yml
  30. .tsan-suppressions
  31. abspath.c
  32. aclocal.m4
  33. advice.c
  34. advice.h
  35. alias.c
  36. alias.h
  37. alloc.c
  38. alloc.h
  39. apply.c
  40. apply.h
  41. archive-tar.c
  42. archive-zip.c
  43. archive.c
  44. archive.h
  45. argv-array.c
  46. argv-array.h
  47. attr.c
  48. attr.h
  49. banned.h
  50. base85.c
  51. bisect.c
  52. bisect.h
  53. blame.c
  54. blame.h
  55. blob.c
  56. blob.h
  57. branch.c
  58. branch.h
  59. builtin.h
  60. bulk-checkin.c
  61. bulk-checkin.h
  62. bundle.c
  63. bundle.h
  64. cache-tree.c
  65. cache-tree.h
  66. cache.h
  67. chdir-notify.c
  68. chdir-notify.h
  69. check-builtins.sh
  70. check-racy.c
  71. check_bindir
  72. checkout.c
  73. checkout.h
  74. color.c
  75. color.h
  76. column.c
  77. column.h
  78. combine-diff.c
  79. command-list.txt
  80. commit-graph.c
  81. commit-graph.h
  82. commit-reach.c
  83. commit-reach.h
  84. commit-slab-decl.h
  85. commit-slab-impl.h
  86. commit-slab.h
  87. commit.c
  88. commit.h
  89. common-main.c
  90. config.c
  91. config.h
  92. config.mak.dev
  93. config.mak.in
  94. config.mak.uname
  95. configure.ac
  96. connect.c
  97. connect.h
  98. connected.c
  99. connected.h
  100. convert.c
  101. convert.h
  102. copy.c
  103. COPYING
  104. credential-cache--daemon.c
  105. credential-cache.c
  106. credential-store.c
  107. credential.c
  108. credential.h
  109. csum-file.c
  110. csum-file.h
  111. ctype.c
  112. daemon.c
  113. date.c
  114. decorate.c
  115. decorate.h
  116. delta-islands.c
  117. delta-islands.h
  118. delta.h
  119. detect-compiler
  120. diff-delta.c
  121. diff-lib.c
  122. diff-no-index.c
  123. diff.c
  124. diff.h
  125. diffcore-break.c
  126. diffcore-delta.c
  127. diffcore-order.c
  128. diffcore-pickaxe.c
  129. diffcore-rename.c
  130. diffcore.h
  131. dir-iterator.c
  132. dir-iterator.h
  133. dir.c
  134. dir.h
  135. editor.c
  136. entry.c
  137. environment.c
  138. exec-cmd.c
  139. exec-cmd.h
  140. fast-import.c
  141. fetch-negotiator.c
  142. fetch-negotiator.h
  143. fetch-object.c
  144. fetch-object.h
  145. fetch-pack.c
  146. fetch-pack.h
  147. fmt-merge-msg.h
  148. fsck.c
  149. fsck.h
  150. fsmonitor.c
  151. fsmonitor.h
  152. fuzz-pack-headers.c
  153. fuzz-pack-idx.c
  154. generate-cmdlist.sh
  155. gettext.c
  156. gettext.h
  157. git-add--interactive.perl
  158. git-archimport.perl
  159. git-bisect.sh
  160. git-compat-util.h
  161. git-cvsexportcommit.perl
  162. git-cvsimport.perl
  163. git-cvsserver.perl
  164. git-difftool--helper.sh
  165. git-filter-branch.sh
  166. git-instaweb.sh
  167. git-merge-octopus.sh
  168. git-merge-one-file.sh
  169. git-merge-resolve.sh
  170. git-mergetool--lib.sh
  171. git-mergetool.sh
  172. git-p4.py
  173. git-parse-remote.sh
  174. git-quiltimport.sh
  175. git-rebase--am.sh
  176. git-rebase--interactive.sh
  177. git-rebase--merge.sh
  178. git-rebase--preserve-merges.sh
  179. git-rebase.sh
  180. git-remote-testgit.sh
  181. git-request-pull.sh
  182. git-send-email.perl
  183. git-sh-i18n.sh
  184. git-sh-setup.sh
  185. git-stash.sh
  186. git-submodule.sh
  187. git-svn.perl
  188. GIT-VERSION-GEN
  189. git-web--browse.sh
  190. git.c
  191. git.rc
  192. gpg-interface.c
  193. gpg-interface.h
  194. graph.c
  195. graph.h
  196. grep.c
  197. grep.h
  198. hash.h
  199. hashmap.c
  200. hashmap.h
  201. help.c
  202. help.h
  203. hex.c
  204. http-backend.c
  205. http-fetch.c
  206. http-push.c
  207. http-walker.c
  208. http.c
  209. http.h
  210. ident.c
  211. imap-send.c
  212. INSTALL
  213. interdiff.c
  214. interdiff.h
  215. iterator.h
  216. json-writer.c
  217. json-writer.h
  218. khash.h
  219. kwset.c
  220. kwset.h
  221. levenshtein.c
  222. levenshtein.h
  223. LGPL-2.1
  224. line-log.c
  225. line-log.h
  226. line-range.c
  227. line-range.h
  228. linear-assignment.c
  229. linear-assignment.h
  230. list-objects-filter-options.c
  231. list-objects-filter-options.h
  232. list-objects-filter.c
  233. list-objects-filter.h
  234. list-objects.c
  235. list-objects.h
  236. list.h
  237. ll-merge.c
  238. ll-merge.h
  239. lockfile.c
  240. lockfile.h
  241. log-tree.c
  242. log-tree.h
  243. ls-refs.c
  244. ls-refs.h
  245. mailinfo.c
  246. mailinfo.h
  247. mailmap.c
  248. mailmap.h
  249. Makefile
  250. match-trees.c
  251. mem-pool.c
  252. mem-pool.h
  253. merge-blobs.c
  254. merge-blobs.h
  255. merge-recursive.c
  256. merge-recursive.h
  257. merge.c
  258. mergesort.c
  259. mergesort.h
  260. midx.c
  261. midx.h
  262. name-hash.c
  263. notes-cache.c
  264. notes-cache.h
  265. notes-merge.c
  266. notes-merge.h
  267. notes-utils.c
  268. notes-utils.h
  269. notes.c
  270. notes.h
  271. object-store.h
  272. object.c
  273. object.h
  274. oidmap.c
  275. oidmap.h
  276. oidset.c
  277. oidset.h
  278. pack-bitmap-write.c
  279. pack-bitmap.c
  280. pack-bitmap.h
  281. pack-check.c
  282. pack-objects.c
  283. pack-objects.h
  284. pack-revindex.c
  285. pack-revindex.h
  286. pack-write.c
  287. pack.h
  288. packfile.c
  289. packfile.h
  290. pager.c
  291. parse-options-cb.c
  292. parse-options.c
  293. parse-options.h
  294. patch-delta.c
  295. patch-ids.c
  296. patch-ids.h
  297. path.c
  298. path.h
  299. pathspec.c
  300. pathspec.h
  301. pkt-line.c
  302. pkt-line.h
  303. preload-index.c
  304. pretty.c
  305. pretty.h
  306. prio-queue.c
  307. prio-queue.h
  308. progress.c
  309. progress.h
  310. prompt.c
  311. prompt.h
  312. protocol.c
  313. protocol.h
  314. quote.c
  315. quote.h
  316. range-diff.c
  317. range-diff.h
  318. reachable.c
  319. reachable.h
  320. read-cache.c
  321. README.md
  322. ref-filter.c
  323. ref-filter.h
  324. reflog-walk.c
  325. reflog-walk.h
  326. refs.c
  327. refs.h
  328. refspec.c
  329. refspec.h
  330. remote-curl.c
  331. remote-testsvn.c
  332. remote.c
  333. remote.h
  334. replace-object.c
  335. replace-object.h
  336. repository.c
  337. repository.h
  338. rerere.c
  339. rerere.h
  340. resolve-undo.c
  341. resolve-undo.h
  342. revision.c
  343. revision.h
  344. run-command.c
  345. run-command.h
  346. send-pack.c
  347. send-pack.h
  348. sequencer.c
  349. sequencer.h
  350. serve.c
  351. serve.h
  352. server-info.c
  353. setup.c
  354. sh-i18n--envsubst.c
  355. sha1-array.c
  356. sha1-array.h
  357. sha1-file.c
  358. sha1-lookup.c
  359. sha1-lookup.h
  360. sha1-name.c
  361. sha1dc_git.c
  362. sha1dc_git.h
  363. shallow.c
  364. shell.c
  365. shortlog.h
  366. sideband.c
  367. sideband.h
  368. sigchain.c
  369. sigchain.h
  370. split-index.c
  371. split-index.h
  372. strbuf.c
  373. strbuf.h
  374. streaming.c
  375. streaming.h
  376. string-list.c
  377. string-list.h
  378. sub-process.c
  379. sub-process.h
  380. submodule-config.c
  381. submodule-config.h
  382. submodule.c
  383. submodule.h
  384. symlinks.c
  385. tag.c
  386. tag.h
  387. tar.h
  388. tempfile.c
  389. tempfile.h
  390. thread-utils.c
  391. thread-utils.h
  392. tmp-objdir.c
  393. tmp-objdir.h
  394. trace.c
  395. trace.h
  396. trailer.c
  397. trailer.h
  398. transport-helper.c
  399. transport-internal.h
  400. transport.c
  401. transport.h
  402. tree-diff.c
  403. tree-walk.c
  404. tree-walk.h
  405. tree.c
  406. tree.h
  407. unicode-width.h
  408. unimplemented.sh
  409. unix-socket.c
  410. unix-socket.h
  411. unpack-trees.c
  412. unpack-trees.h
  413. upload-pack.c
  414. upload-pack.h
  415. url.c
  416. url.h
  417. urlmatch.c
  418. urlmatch.h
  419. usage.c
  420. userdiff.c
  421. userdiff.h
  422. utf8.c
  423. utf8.h
  424. varint.c
  425. varint.h
  426. version.c
  427. version.h
  428. versioncmp.c
  429. walker.c
  430. walker.h
  431. wildmatch.c
  432. wildmatch.h
  433. worktree.c
  434. worktree.h
  435. wrap-for-bin.sh
  436. wrapper.c
  437. write-or-die.c
  438. ws.c
  439. wt-status.c
  440. wt-status.h
  441. xdiff-interface.c
  442. xdiff-interface.h
  443. zlib.c
README.md

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://public-inbox.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks