mysql_thread.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330
  1. /* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software Foundation,
  17. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
  18. #ifndef MYSQL_THREAD_H
  19. #define MYSQL_THREAD_H
  20. /**
  21. @file mysql/psi/mysql_thread.h
  22. Instrumentation helpers for mysys threads, mutexes,
  23. read write locks and conditions.
  24. This header file provides the necessary declarations
  25. to use the mysys thread API with the performance schema instrumentation.
  26. In some compilers (SunStudio), 'static inline' functions, when declared
  27. but not used, are not optimized away (because they are unused) by default,
  28. so that including a static inline function from a header file does
  29. create unwanted dependencies, causing unresolved symbols at link time.
  30. Other compilers, like gcc, optimize these dependencies by default.
  31. Since the instrumented APIs declared here are wrapper on top
  32. of my_thread / safemutex / etc APIs,
  33. including mysql/psi/mysql_thread.h assumes that
  34. the dependency on my_thread and safemutex already exists.
  35. */
  36. /*
  37. Note: there are several orthogonal dimensions here.
  38. Dimension 1: Instrumentation
  39. HAVE_PSI_INTERFACE is defined when the instrumentation is compiled in.
  40. This may happen both in debug or production builds.
  41. Dimension 2: Debug
  42. SAFE_MUTEX is defined when debug is compiled in.
  43. This may happen both with and without instrumentation.
  44. Dimension 3: Platform
  45. Mutexes are implemented with one of:
  46. - the pthread library
  47. - fast mutexes
  48. - window apis
  49. This is implemented by various macro definitions in my_thread.h
  50. This causes complexity with '#ifdef'-ery that can't be avoided.
  51. */
  52. #include "my_thread.h"
  53. #include "my_thread_local.h"
  54. #include "thr_mutex.h"
  55. #include "thr_rwlock.h"
  56. #include "mysql/psi/psi.h"
  57. #ifdef MYSQL_SERVER
  58. #ifndef MYSQL_DYNAMIC_PLUGIN
  59. #include "pfs_thread_provider.h"
  60. #endif
  61. #endif
  62. #ifndef PSI_MUTEX_CALL
  63. #define PSI_MUTEX_CALL(M) PSI_DYNAMIC_CALL(M)
  64. #endif
  65. #ifndef PSI_RWLOCK_CALL
  66. #define PSI_RWLOCK_CALL(M) PSI_DYNAMIC_CALL(M)
  67. #endif
  68. #ifndef PSI_COND_CALL
  69. #define PSI_COND_CALL(M) PSI_DYNAMIC_CALL(M)
  70. #endif
  71. #ifndef PSI_THREAD_CALL
  72. #define PSI_THREAD_CALL(M) PSI_DYNAMIC_CALL(M)
  73. #endif
  74. /**
  75. @defgroup Thread_instrumentation Thread Instrumentation
  76. @ingroup Instrumentation_interface
  77. @{
  78. */
  79. /**
  80. An instrumented mutex structure.
  81. @sa mysql_mutex_t
  82. */
  83. struct st_mysql_mutex
  84. {
  85. /** The real mutex. */
  86. my_mutex_t m_mutex;
  87. /**
  88. The instrumentation hook.
  89. Note that this hook is not conditionally defined,
  90. for binary compatibility of the @c mysql_mutex_t interface.
  91. */
  92. struct PSI_mutex *m_psi;
  93. };
  94. /**
  95. Type of an instrumented mutex.
  96. @c mysql_mutex_t is a drop-in replacement for @c my_mutex_t.
  97. @sa mysql_mutex_assert_owner
  98. @sa mysql_mutex_assert_not_owner
  99. @sa mysql_mutex_init
  100. @sa mysql_mutex_lock
  101. @sa mysql_mutex_unlock
  102. @sa mysql_mutex_destroy
  103. */
  104. typedef struct st_mysql_mutex mysql_mutex_t;
  105. /**
  106. An instrumented rwlock structure.
  107. @sa mysql_rwlock_t
  108. */
  109. struct st_mysql_rwlock
  110. {
  111. /** The real rwlock */
  112. native_rw_lock_t m_rwlock;
  113. /**
  114. The instrumentation hook.
  115. Note that this hook is not conditionally defined,
  116. for binary compatibility of the @c mysql_rwlock_t interface.
  117. */
  118. struct PSI_rwlock *m_psi;
  119. };
  120. /**
  121. An instrumented prlock structure.
  122. @sa mysql_prlock_t
  123. */
  124. struct st_mysql_prlock
  125. {
  126. /** The real prlock */
  127. rw_pr_lock_t m_prlock;
  128. /**
  129. The instrumentation hook.
  130. Note that this hook is not conditionally defined,
  131. for binary compatibility of the @c mysql_rwlock_t interface.
  132. */
  133. struct PSI_rwlock *m_psi;
  134. };
  135. /**
  136. Type of an instrumented rwlock.
  137. @c mysql_rwlock_t is a drop-in replacement for @c pthread_rwlock_t.
  138. @sa mysql_rwlock_init
  139. @sa mysql_rwlock_rdlock
  140. @sa mysql_rwlock_tryrdlock
  141. @sa mysql_rwlock_wrlock
  142. @sa mysql_rwlock_trywrlock
  143. @sa mysql_rwlock_unlock
  144. @sa mysql_rwlock_destroy
  145. */
  146. typedef struct st_mysql_rwlock mysql_rwlock_t;
  147. /**
  148. Type of an instrumented prlock.
  149. A prlock is a read write lock that 'prefers readers' (pr).
  150. @c mysql_prlock_t is a drop-in replacement for @c rw_pr_lock_t.
  151. @sa mysql_prlock_init
  152. @sa mysql_prlock_rdlock
  153. @sa mysql_prlock_wrlock
  154. @sa mysql_prlock_unlock
  155. @sa mysql_prlock_destroy
  156. */
  157. typedef struct st_mysql_prlock mysql_prlock_t;
  158. /**
  159. An instrumented cond structure.
  160. @sa mysql_cond_t
  161. */
  162. struct st_mysql_cond
  163. {
  164. /** The real condition */
  165. native_cond_t m_cond;
  166. /**
  167. The instrumentation hook.
  168. Note that this hook is not conditionally defined,
  169. for binary compatibility of the @c mysql_cond_t interface.
  170. */
  171. struct PSI_cond *m_psi;
  172. };
  173. /**
  174. Type of an instrumented condition.
  175. @c mysql_cond_t is a drop-in replacement for @c native_cond_t.
  176. @sa mysql_cond_init
  177. @sa mysql_cond_wait
  178. @sa mysql_cond_timedwait
  179. @sa mysql_cond_signal
  180. @sa mysql_cond_broadcast
  181. @sa mysql_cond_destroy
  182. */
  183. typedef struct st_mysql_cond mysql_cond_t;
  184. /*
  185. Consider the following code:
  186. static inline void foo() { bar(); }
  187. when foo() is never called.
  188. With gcc, foo() is a local static function, so the dependencies
  189. are optimized away at compile time, and there is no dependency on bar().
  190. With other compilers (HP, Sun Studio), the function foo() implementation
  191. is compiled, and bar() needs to be present to link.
  192. Due to the existing header dependencies in MySQL code, this header file
  193. is sometime used when it is not needed, which in turn cause link failures
  194. on some platforms.
  195. The proper fix would be to cut these extra dependencies in the calling code.
  196. DISABLE_MYSQL_THREAD_H is a work around to limit dependencies.
  197. DISABLE_MYSQL_PRLOCK_H is similar, and is used to disable specifically
  198. the prlock wrappers.
  199. */
  200. #ifndef DISABLE_MYSQL_THREAD_H
  201. /**
  202. @def mysql_mutex_assert_owner(M)
  203. Wrapper, to use safe_mutex_assert_owner with instrumented mutexes.
  204. @c mysql_mutex_assert_owner is a drop-in replacement
  205. for @c safe_mutex_assert_owner.
  206. */
  207. #ifdef SAFE_MUTEX
  208. #define mysql_mutex_assert_owner(M) \
  209. safe_mutex_assert_owner(&(M)->m_mutex);
  210. #else
  211. #define mysql_mutex_assert_owner(M) { }
  212. #endif
  213. /**
  214. @def mysql_mutex_assert_not_owner(M)
  215. Wrapper, to use safe_mutex_assert_not_owner with instrumented mutexes.
  216. @c mysql_mutex_assert_not_owner is a drop-in replacement
  217. for @c safe_mutex_assert_not_owner.
  218. */
  219. #ifdef SAFE_MUTEX
  220. #define mysql_mutex_assert_not_owner(M) \
  221. safe_mutex_assert_not_owner(&(M)->m_mutex);
  222. #else
  223. #define mysql_mutex_assert_not_owner(M) { }
  224. #endif
  225. /**
  226. @def mysql_prlock_assert_write_owner(M)
  227. Drop-in replacement
  228. for @c rw_pr_lock_assert_write_owner.
  229. */
  230. #define mysql_prlock_assert_write_owner(M) \
  231. rw_pr_lock_assert_write_owner(&(M)->m_prlock)
  232. /**
  233. @def mysql_prlock_assert_not_write_owner(M)
  234. Drop-in replacement
  235. for @c rw_pr_lock_assert_not_write_owner.
  236. */
  237. #define mysql_prlock_assert_not_write_owner(M) \
  238. rw_pr_lock_assert_not_write_owner(&(M)->m_prlock)
  239. /**
  240. @def mysql_mutex_register(P1, P2, P3)
  241. Mutex registration.
  242. */
  243. #define mysql_mutex_register(P1, P2, P3) \
  244. inline_mysql_mutex_register(P1, P2, P3)
  245. /**
  246. @def mysql_mutex_init(K, M, A)
  247. Instrumented mutex_init.
  248. @c mysql_mutex_init is a replacement for @c pthread_mutex_init.
  249. @param K The PSI_mutex_key for this instrumented mutex
  250. @param M The mutex to initialize
  251. @param A Mutex attributes
  252. */
  253. #ifdef HAVE_PSI_MUTEX_INTERFACE
  254. #ifdef SAFE_MUTEX
  255. #define mysql_mutex_init(K, M, A) \
  256. inline_mysql_mutex_init(K, M, A, __FILE__, __LINE__)
  257. #else
  258. #define mysql_mutex_init(K, M, A) \
  259. inline_mysql_mutex_init(K, M, A)
  260. #endif
  261. #else
  262. #ifdef SAFE_MUTEX
  263. #define mysql_mutex_init(K, M, A) \
  264. inline_mysql_mutex_init(M, A, __FILE__, __LINE__)
  265. #else
  266. #define mysql_mutex_init(K, M, A) \
  267. inline_mysql_mutex_init(M, A)
  268. #endif
  269. #endif
  270. /**
  271. @def mysql_mutex_destroy(M)
  272. Instrumented mutex_destroy.
  273. @c mysql_mutex_destroy is a drop-in replacement
  274. for @c pthread_mutex_destroy.
  275. */
  276. #ifdef SAFE_MUTEX
  277. #define mysql_mutex_destroy(M) \
  278. inline_mysql_mutex_destroy(M, __FILE__, __LINE__)
  279. #else
  280. #define mysql_mutex_destroy(M) \
  281. inline_mysql_mutex_destroy(M)
  282. #endif
  283. /**
  284. @def mysql_mutex_lock(M)
  285. Instrumented mutex_lock.
  286. @c mysql_mutex_lock is a drop-in replacement for @c pthread_mutex_lock.
  287. @param M The mutex to lock
  288. */
  289. #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
  290. #define mysql_mutex_lock(M) \
  291. inline_mysql_mutex_lock(M, __FILE__, __LINE__)
  292. #else
  293. #define mysql_mutex_lock(M) \
  294. inline_mysql_mutex_lock(M)
  295. #endif
  296. /**
  297. @def mysql_mutex_trylock(M)
  298. Instrumented mutex_lock.
  299. @c mysql_mutex_trylock is a drop-in replacement
  300. for @c my_mutex_trylock.
  301. */
  302. #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
  303. #define mysql_mutex_trylock(M) \
  304. inline_mysql_mutex_trylock(M, __FILE__, __LINE__)
  305. #else
  306. #define mysql_mutex_trylock(M) \
  307. inline_mysql_mutex_trylock(M)
  308. #endif
  309. /**
  310. @def mysql_mutex_unlock(M)
  311. Instrumented mutex_unlock.
  312. @c mysql_mutex_unlock is a drop-in replacement for @c pthread_mutex_unlock.
  313. */
  314. #ifdef SAFE_MUTEX
  315. #define mysql_mutex_unlock(M) \
  316. inline_mysql_mutex_unlock(M, __FILE__, __LINE__)
  317. #else
  318. #define mysql_mutex_unlock(M) \
  319. inline_mysql_mutex_unlock(M)
  320. #endif
  321. /**
  322. @def mysql_rwlock_register(P1, P2, P3)
  323. Rwlock registration.
  324. */
  325. #define mysql_rwlock_register(P1, P2, P3) \
  326. inline_mysql_rwlock_register(P1, P2, P3)
  327. /**
  328. @def mysql_rwlock_init(K, RW)
  329. Instrumented rwlock_init.
  330. @c mysql_rwlock_init is a replacement for @c pthread_rwlock_init.
  331. Note that pthread_rwlockattr_t is not supported in MySQL.
  332. @param K The PSI_rwlock_key for this instrumented rwlock
  333. @param RW The rwlock to initialize
  334. */
  335. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  336. #define mysql_rwlock_init(K, RW) inline_mysql_rwlock_init(K, RW)
  337. #else
  338. #define mysql_rwlock_init(K, RW) inline_mysql_rwlock_init(RW)
  339. #endif
  340. /**
  341. @def mysql_prlock_init(K, RW)
  342. Instrumented rw_pr_init.
  343. @c mysql_prlock_init is a replacement for @c rw_pr_init.
  344. @param K The PSI_rwlock_key for this instrumented prlock
  345. @param RW The prlock to initialize
  346. */
  347. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  348. #define mysql_prlock_init(K, RW) inline_mysql_prlock_init(K, RW)
  349. #else
  350. #define mysql_prlock_init(K, RW) inline_mysql_prlock_init(RW)
  351. #endif
  352. /**
  353. @def mysql_rwlock_destroy(RW)
  354. Instrumented rwlock_destroy.
  355. @c mysql_rwlock_destroy is a drop-in replacement
  356. for @c pthread_rwlock_destroy.
  357. */
  358. #define mysql_rwlock_destroy(RW) inline_mysql_rwlock_destroy(RW)
  359. /**
  360. @def mysql_prlock_destroy(RW)
  361. Instrumented rw_pr_destroy.
  362. @c mysql_prlock_destroy is a drop-in replacement
  363. for @c rw_pr_destroy.
  364. */
  365. #define mysql_prlock_destroy(RW) inline_mysql_prlock_destroy(RW)
  366. /**
  367. @def mysql_rwlock_rdlock(RW)
  368. Instrumented rwlock_rdlock.
  369. @c mysql_rwlock_rdlock is a drop-in replacement
  370. for @c pthread_rwlock_rdlock.
  371. */
  372. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  373. #define mysql_rwlock_rdlock(RW) \
  374. inline_mysql_rwlock_rdlock(RW, __FILE__, __LINE__)
  375. #else
  376. #define mysql_rwlock_rdlock(RW) \
  377. inline_mysql_rwlock_rdlock(RW)
  378. #endif
  379. /**
  380. @def mysql_prlock_rdlock(RW)
  381. Instrumented rw_pr_rdlock.
  382. @c mysql_prlock_rdlock is a drop-in replacement
  383. for @c rw_pr_rdlock.
  384. */
  385. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  386. #define mysql_prlock_rdlock(RW) \
  387. inline_mysql_prlock_rdlock(RW, __FILE__, __LINE__)
  388. #else
  389. #define mysql_prlock_rdlock(RW) \
  390. inline_mysql_prlock_rdlock(RW)
  391. #endif
  392. /**
  393. @def mysql_rwlock_wrlock(RW)
  394. Instrumented rwlock_wrlock.
  395. @c mysql_rwlock_wrlock is a drop-in replacement
  396. for @c pthread_rwlock_wrlock.
  397. */
  398. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  399. #define mysql_rwlock_wrlock(RW) \
  400. inline_mysql_rwlock_wrlock(RW, __FILE__, __LINE__)
  401. #else
  402. #define mysql_rwlock_wrlock(RW) \
  403. inline_mysql_rwlock_wrlock(RW)
  404. #endif
  405. /**
  406. @def mysql_prlock_wrlock(RW)
  407. Instrumented rw_pr_wrlock.
  408. @c mysql_prlock_wrlock is a drop-in replacement
  409. for @c rw_pr_wrlock.
  410. */
  411. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  412. #define mysql_prlock_wrlock(RW) \
  413. inline_mysql_prlock_wrlock(RW, __FILE__, __LINE__)
  414. #else
  415. #define mysql_prlock_wrlock(RW) \
  416. inline_mysql_prlock_wrlock(RW)
  417. #endif
  418. /**
  419. @def mysql_rwlock_tryrdlock(RW)
  420. Instrumented rwlock_tryrdlock.
  421. @c mysql_rwlock_tryrdlock is a drop-in replacement
  422. for @c pthread_rwlock_tryrdlock.
  423. */
  424. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  425. #define mysql_rwlock_tryrdlock(RW) \
  426. inline_mysql_rwlock_tryrdlock(RW, __FILE__, __LINE__)
  427. #else
  428. #define mysql_rwlock_tryrdlock(RW) \
  429. inline_mysql_rwlock_tryrdlock(RW)
  430. #endif
  431. /**
  432. @def mysql_rwlock_trywrlock(RW)
  433. Instrumented rwlock_trywrlock.
  434. @c mysql_rwlock_trywrlock is a drop-in replacement
  435. for @c pthread_rwlock_trywrlock.
  436. */
  437. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  438. #define mysql_rwlock_trywrlock(RW) \
  439. inline_mysql_rwlock_trywrlock(RW, __FILE__, __LINE__)
  440. #else
  441. #define mysql_rwlock_trywrlock(RW) \
  442. inline_mysql_rwlock_trywrlock(RW)
  443. #endif
  444. /**
  445. @def mysql_rwlock_unlock(RW)
  446. Instrumented rwlock_unlock.
  447. @c mysql_rwlock_unlock is a drop-in replacement
  448. for @c pthread_rwlock_unlock.
  449. */
  450. #define mysql_rwlock_unlock(RW) inline_mysql_rwlock_unlock(RW)
  451. /**
  452. @def mysql_prlock_unlock(RW)
  453. Instrumented rw_pr_unlock.
  454. @c mysql_prlock_unlock is a drop-in replacement
  455. for @c rw_pr_unlock.
  456. */
  457. #define mysql_prlock_unlock(RW) inline_mysql_prlock_unlock(RW)
  458. /**
  459. @def mysql_cond_register(P1, P2, P3)
  460. Cond registration.
  461. */
  462. #define mysql_cond_register(P1, P2, P3) \
  463. inline_mysql_cond_register(P1, P2, P3)
  464. /**
  465. @def mysql_cond_init(K, C)
  466. Instrumented cond_init.
  467. @c mysql_cond_init is a replacement for @c pthread_cond_init.
  468. Note that pthread_condattr_t is not supported in MySQL.
  469. @param C The cond to initialize
  470. @param K The PSI_cond_key for this instrumented cond
  471. */
  472. #ifdef HAVE_PSI_COND_INTERFACE
  473. #define mysql_cond_init(K, C) inline_mysql_cond_init(K, C)
  474. #else
  475. #define mysql_cond_init(K, C) inline_mysql_cond_init(C)
  476. #endif
  477. /**
  478. @def mysql_cond_destroy(C)
  479. Instrumented cond_destroy.
  480. @c mysql_cond_destroy is a drop-in replacement for @c pthread_cond_destroy.
  481. */
  482. #define mysql_cond_destroy(C) inline_mysql_cond_destroy(C)
  483. /**
  484. @def mysql_cond_wait(C)
  485. Instrumented cond_wait.
  486. @c mysql_cond_wait is a drop-in replacement for @c native_cond_wait.
  487. */
  488. #if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
  489. #define mysql_cond_wait(C, M) \
  490. inline_mysql_cond_wait(C, M, __FILE__, __LINE__)
  491. #else
  492. #define mysql_cond_wait(C, M) \
  493. inline_mysql_cond_wait(C, M)
  494. #endif
  495. /**
  496. @def mysql_cond_timedwait(C, M, W)
  497. Instrumented cond_timedwait.
  498. @c mysql_cond_timedwait is a drop-in replacement
  499. for @c native_cond_timedwait.
  500. */
  501. #if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
  502. #define mysql_cond_timedwait(C, M, W) \
  503. inline_mysql_cond_timedwait(C, M, W, __FILE__, __LINE__)
  504. #else
  505. #define mysql_cond_timedwait(C, M, W) \
  506. inline_mysql_cond_timedwait(C, M, W)
  507. #endif
  508. /**
  509. @def mysql_cond_signal(C)
  510. Instrumented cond_signal.
  511. @c mysql_cond_signal is a drop-in replacement for @c pthread_cond_signal.
  512. */
  513. #define mysql_cond_signal(C) inline_mysql_cond_signal(C)
  514. /**
  515. @def mysql_cond_broadcast(C)
  516. Instrumented cond_broadcast.
  517. @c mysql_cond_broadcast is a drop-in replacement
  518. for @c pthread_cond_broadcast.
  519. */
  520. #define mysql_cond_broadcast(C) inline_mysql_cond_broadcast(C)
  521. /**
  522. @def mysql_thread_register(P1, P2, P3)
  523. Thread registration.
  524. */
  525. #define mysql_thread_register(P1, P2, P3) \
  526. inline_mysql_thread_register(P1, P2, P3)
  527. /**
  528. @def mysql_thread_create(K, P1, P2, P3, P4)
  529. Instrumented my_thread_create.
  530. This function creates both the thread instrumentation and a thread.
  531. @c mysql_thread_create is a replacement for @c my_thread_create.
  532. The parameter P4 (or, if it is NULL, P1) will be used as the
  533. instrumented thread "indentity".
  534. Providing a P1 / P4 parameter with a different value for each call
  535. will on average improve performances, since this thread identity value
  536. is used internally to randomize access to data and prevent contention.
  537. This is optional, and the improvement is not guaranteed, only statistical.
  538. @param K The PSI_thread_key for this instrumented thread
  539. @param P1 my_thread_create parameter 1
  540. @param P2 my_thread_create parameter 2
  541. @param P3 my_thread_create parameter 3
  542. @param P4 my_thread_create parameter 4
  543. */
  544. #ifdef HAVE_PSI_THREAD_INTERFACE
  545. #define mysql_thread_create(K, P1, P2, P3, P4) \
  546. inline_mysql_thread_create(K, P1, P2, P3, P4)
  547. #else
  548. #define mysql_thread_create(K, P1, P2, P3, P4) \
  549. my_thread_create(P1, P2, P3, P4)
  550. #endif
  551. /**
  552. @def mysql_thread_set_psi_id(I)
  553. Set the thread identifier for the instrumentation.
  554. @param I The thread identifier
  555. */
  556. #ifdef HAVE_PSI_THREAD_INTERFACE
  557. #define mysql_thread_set_psi_id(I) inline_mysql_thread_set_psi_id(I)
  558. #else
  559. #define mysql_thread_set_psi_id(I) do {} while (0)
  560. #endif
  561. /**
  562. @def mysql_thread_set_psi_THD(T)
  563. Set the thread sql session for the instrumentation.
  564. @param I The thread identifier
  565. */
  566. #ifdef HAVE_PSI_THREAD_INTERFACE
  567. #define mysql_thread_set_psi_THD(T) inline_mysql_thread_set_psi_THD(T)
  568. #else
  569. #define mysql_thread_set_psi_THD(T) do {} while (0)
  570. #endif
  571. static inline void inline_mysql_mutex_register(
  572. #ifdef HAVE_PSI_MUTEX_INTERFACE
  573. const char *category,
  574. PSI_mutex_info *info,
  575. int count
  576. #else
  577. const char *category MY_ATTRIBUTE ((unused)),
  578. void *info MY_ATTRIBUTE ((unused)),
  579. int count MY_ATTRIBUTE ((unused))
  580. #endif
  581. )
  582. {
  583. #ifdef HAVE_PSI_MUTEX_INTERFACE
  584. PSI_MUTEX_CALL(register_mutex)(category, info, count);
  585. #endif
  586. }
  587. static inline int inline_mysql_mutex_init(
  588. #ifdef HAVE_PSI_MUTEX_INTERFACE
  589. PSI_mutex_key key,
  590. #endif
  591. mysql_mutex_t *that,
  592. const native_mutexattr_t *attr
  593. #ifdef SAFE_MUTEX
  594. , const char *src_file, uint src_line
  595. #endif
  596. )
  597. {
  598. #ifdef HAVE_PSI_MUTEX_INTERFACE
  599. that->m_psi= PSI_MUTEX_CALL(init_mutex)(key, &that->m_mutex);
  600. #else
  601. that->m_psi= NULL;
  602. #endif
  603. return my_mutex_init(&that->m_mutex, attr
  604. #ifdef SAFE_MUTEX
  605. , src_file, src_line
  606. #endif
  607. );
  608. }
  609. static inline int inline_mysql_mutex_destroy(
  610. mysql_mutex_t *that
  611. #ifdef SAFE_MUTEX
  612. , const char *src_file, uint src_line
  613. #endif
  614. )
  615. {
  616. #ifdef HAVE_PSI_MUTEX_INTERFACE
  617. if (that->m_psi != NULL)
  618. {
  619. PSI_MUTEX_CALL(destroy_mutex)(that->m_psi);
  620. that->m_psi= NULL;
  621. }
  622. #endif
  623. return my_mutex_destroy(&that->m_mutex
  624. #ifdef SAFE_MUTEX
  625. , src_file, src_line
  626. #endif
  627. );
  628. }
  629. static inline int inline_mysql_mutex_lock(
  630. mysql_mutex_t *that
  631. #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
  632. , const char *src_file, uint src_line
  633. #endif
  634. )
  635. {
  636. int result;
  637. #ifdef HAVE_PSI_MUTEX_INTERFACE
  638. if (that->m_psi != NULL)
  639. {
  640. /* Instrumentation start */
  641. PSI_mutex_locker *locker;
  642. PSI_mutex_locker_state state;
  643. locker= PSI_MUTEX_CALL(start_mutex_wait)(&state, that->m_psi,
  644. PSI_MUTEX_LOCK, src_file, src_line);
  645. /* Instrumented code */
  646. result= my_mutex_lock(&that->m_mutex
  647. #ifdef SAFE_MUTEX
  648. , src_file, src_line
  649. #endif
  650. );
  651. /* Instrumentation end */
  652. if (locker != NULL)
  653. PSI_MUTEX_CALL(end_mutex_wait)(locker, result);
  654. return result;
  655. }
  656. #endif
  657. /* Non instrumented code */
  658. result= my_mutex_lock(&that->m_mutex
  659. #ifdef SAFE_MUTEX
  660. , src_file, src_line
  661. #endif
  662. );
  663. return result;
  664. }
  665. static inline int inline_mysql_mutex_trylock(
  666. mysql_mutex_t *that
  667. #if defined(SAFE_MUTEX) || defined (HAVE_PSI_MUTEX_INTERFACE)
  668. , const char *src_file, uint src_line
  669. #endif
  670. )
  671. {
  672. int result;
  673. #ifdef HAVE_PSI_MUTEX_INTERFACE
  674. if (that->m_psi != NULL)
  675. {
  676. /* Instrumentation start */
  677. PSI_mutex_locker *locker;
  678. PSI_mutex_locker_state state;
  679. locker= PSI_MUTEX_CALL(start_mutex_wait)(&state, that->m_psi,
  680. PSI_MUTEX_TRYLOCK, src_file, src_line);
  681. /* Instrumented code */
  682. result= my_mutex_trylock(&that->m_mutex
  683. #ifdef SAFE_MUTEX
  684. , src_file, src_line
  685. #endif
  686. );
  687. /* Instrumentation end */
  688. if (locker != NULL)
  689. PSI_MUTEX_CALL(end_mutex_wait)(locker, result);
  690. return result;
  691. }
  692. #endif
  693. /* Non instrumented code */
  694. result= my_mutex_trylock(&that->m_mutex
  695. #ifdef SAFE_MUTEX
  696. , src_file, src_line
  697. #endif
  698. );
  699. return result;
  700. }
  701. static inline int inline_mysql_mutex_unlock(
  702. mysql_mutex_t *that
  703. #ifdef SAFE_MUTEX
  704. , const char *src_file, uint src_line
  705. #endif
  706. )
  707. {
  708. int result;
  709. #ifdef HAVE_PSI_MUTEX_INTERFACE
  710. if (that->m_psi != NULL)
  711. PSI_MUTEX_CALL(unlock_mutex)(that->m_psi);
  712. #endif
  713. result= my_mutex_unlock(&that->m_mutex
  714. #ifdef SAFE_MUTEX
  715. , src_file, src_line
  716. #endif
  717. );
  718. return result;
  719. }
  720. static inline void inline_mysql_rwlock_register(
  721. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  722. const char *category,
  723. PSI_rwlock_info *info,
  724. int count
  725. #else
  726. const char *category MY_ATTRIBUTE ((unused)),
  727. void *info MY_ATTRIBUTE ((unused)),
  728. int count MY_ATTRIBUTE ((unused))
  729. #endif
  730. )
  731. {
  732. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  733. PSI_RWLOCK_CALL(register_rwlock)(category, info, count);
  734. #endif
  735. }
  736. static inline int inline_mysql_rwlock_init(
  737. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  738. PSI_rwlock_key key,
  739. #endif
  740. mysql_rwlock_t *that)
  741. {
  742. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  743. that->m_psi= PSI_RWLOCK_CALL(init_rwlock)(key, &that->m_rwlock);
  744. #else
  745. that->m_psi= NULL;
  746. #endif
  747. return native_rw_init(&that->m_rwlock);
  748. }
  749. #ifndef DISABLE_MYSQL_PRLOCK_H
  750. static inline int inline_mysql_prlock_init(
  751. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  752. PSI_rwlock_key key,
  753. #endif
  754. mysql_prlock_t *that)
  755. {
  756. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  757. that->m_psi= PSI_RWLOCK_CALL(init_rwlock)(key, &that->m_prlock);
  758. #else
  759. that->m_psi= NULL;
  760. #endif
  761. return rw_pr_init(&that->m_prlock);
  762. }
  763. #endif
  764. static inline int inline_mysql_rwlock_destroy(
  765. mysql_rwlock_t *that)
  766. {
  767. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  768. if (that->m_psi != NULL)
  769. {
  770. PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi);
  771. that->m_psi= NULL;
  772. }
  773. #endif
  774. return native_rw_destroy(&that->m_rwlock);
  775. }
  776. #ifndef DISABLE_MYSQL_PRLOCK_H
  777. static inline int inline_mysql_prlock_destroy(
  778. mysql_prlock_t *that)
  779. {
  780. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  781. if (that->m_psi != NULL)
  782. {
  783. PSI_RWLOCK_CALL(destroy_rwlock)(that->m_psi);
  784. that->m_psi= NULL;
  785. }
  786. #endif
  787. return rw_pr_destroy(&that->m_prlock);
  788. }
  789. #endif
  790. static inline int inline_mysql_rwlock_rdlock(
  791. mysql_rwlock_t *that
  792. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  793. , const char *src_file, uint src_line
  794. #endif
  795. )
  796. {
  797. int result;
  798. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  799. if (that->m_psi != NULL)
  800. {
  801. /* Instrumentation start */
  802. PSI_rwlock_locker *locker;
  803. PSI_rwlock_locker_state state;
  804. locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi,
  805. PSI_RWLOCK_READLOCK, src_file, src_line);
  806. /* Instrumented code */
  807. result= native_rw_rdlock(&that->m_rwlock);
  808. /* Instrumentation end */
  809. if (locker != NULL)
  810. PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result);
  811. return result;
  812. }
  813. #endif
  814. /* Non instrumented code */
  815. result= native_rw_rdlock(&that->m_rwlock);
  816. return result;
  817. }
  818. #ifndef DISABLE_MYSQL_PRLOCK_H
  819. static inline int inline_mysql_prlock_rdlock(
  820. mysql_prlock_t *that
  821. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  822. , const char *src_file, uint src_line
  823. #endif
  824. )
  825. {
  826. int result;
  827. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  828. if (that->m_psi != NULL)
  829. {
  830. /* Instrumentation start */
  831. PSI_rwlock_locker *locker;
  832. PSI_rwlock_locker_state state;
  833. locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi,
  834. PSI_RWLOCK_READLOCK, src_file, src_line);
  835. /* Instrumented code */
  836. result= rw_pr_rdlock(&that->m_prlock);
  837. /* Instrumentation end */
  838. if (locker != NULL)
  839. PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result);
  840. return result;
  841. }
  842. #endif
  843. /* Non instrumented code */
  844. result= rw_pr_rdlock(&that->m_prlock);
  845. return result;
  846. }
  847. #endif
  848. static inline int inline_mysql_rwlock_wrlock(
  849. mysql_rwlock_t *that
  850. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  851. , const char *src_file, uint src_line
  852. #endif
  853. )
  854. {
  855. int result;
  856. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  857. if (that->m_psi != NULL)
  858. {
  859. /* Instrumentation start */
  860. PSI_rwlock_locker *locker;
  861. PSI_rwlock_locker_state state;
  862. locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi,
  863. PSI_RWLOCK_WRITELOCK, src_file, src_line);
  864. /* Instrumented code */
  865. result= native_rw_wrlock(&that->m_rwlock);
  866. /* Instrumentation end */
  867. if (locker != NULL)
  868. PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result);
  869. return result;
  870. }
  871. #endif
  872. /* Non instrumented code */
  873. result= native_rw_wrlock(&that->m_rwlock);
  874. return result;
  875. }
  876. #ifndef DISABLE_MYSQL_PRLOCK_H
  877. static inline int inline_mysql_prlock_wrlock(
  878. mysql_prlock_t *that
  879. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  880. , const char *src_file, uint src_line
  881. #endif
  882. )
  883. {
  884. int result;
  885. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  886. if (that->m_psi != NULL)
  887. {
  888. /* Instrumentation start */
  889. PSI_rwlock_locker *locker;
  890. PSI_rwlock_locker_state state;
  891. locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi,
  892. PSI_RWLOCK_WRITELOCK, src_file, src_line);
  893. /* Instrumented code */
  894. result= rw_pr_wrlock(&that->m_prlock);
  895. /* Instrumentation end */
  896. if (locker != NULL)
  897. PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result);
  898. return result;
  899. }
  900. #endif
  901. /* Non instrumented code */
  902. result= rw_pr_wrlock(&that->m_prlock);
  903. return result;
  904. }
  905. #endif
  906. static inline int inline_mysql_rwlock_tryrdlock(
  907. mysql_rwlock_t *that
  908. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  909. , const char *src_file, uint src_line
  910. #endif
  911. )
  912. {
  913. int result;
  914. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  915. if (that->m_psi != NULL)
  916. {
  917. /* Instrumentation start */
  918. PSI_rwlock_locker *locker;
  919. PSI_rwlock_locker_state state;
  920. locker= PSI_RWLOCK_CALL(start_rwlock_rdwait)(&state, that->m_psi,
  921. PSI_RWLOCK_TRYREADLOCK, src_file, src_line);
  922. /* Instrumented code */
  923. result= native_rw_tryrdlock(&that->m_rwlock);
  924. /* Instrumentation end */
  925. if (locker != NULL)
  926. PSI_RWLOCK_CALL(end_rwlock_rdwait)(locker, result);
  927. return result;
  928. }
  929. #endif
  930. /* Non instrumented code */
  931. result= native_rw_tryrdlock(&that->m_rwlock);
  932. return result;
  933. }
  934. static inline int inline_mysql_rwlock_trywrlock(
  935. mysql_rwlock_t *that
  936. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  937. , const char *src_file, uint src_line
  938. #endif
  939. )
  940. {
  941. int result;
  942. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  943. if (that->m_psi != NULL)
  944. {
  945. /* Instrumentation start */
  946. PSI_rwlock_locker *locker;
  947. PSI_rwlock_locker_state state;
  948. locker= PSI_RWLOCK_CALL(start_rwlock_wrwait)(&state, that->m_psi,
  949. PSI_RWLOCK_TRYWRITELOCK, src_file, src_line);
  950. /* Instrumented code */
  951. result= native_rw_trywrlock(&that->m_rwlock);
  952. /* Instrumentation end */
  953. if (locker != NULL)
  954. PSI_RWLOCK_CALL(end_rwlock_wrwait)(locker, result);
  955. return result;
  956. }
  957. #endif
  958. /* Non instrumented code */
  959. result= native_rw_trywrlock(&that->m_rwlock);
  960. return result;
  961. }
  962. static inline int inline_mysql_rwlock_unlock(
  963. mysql_rwlock_t *that)
  964. {
  965. int result;
  966. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  967. if (that->m_psi != NULL)
  968. PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
  969. #endif
  970. result= native_rw_unlock(&that->m_rwlock);
  971. return result;
  972. }
  973. #ifndef DISABLE_MYSQL_PRLOCK_H
  974. static inline int inline_mysql_prlock_unlock(
  975. mysql_prlock_t *that)
  976. {
  977. int result;
  978. #ifdef HAVE_PSI_RWLOCK_INTERFACE
  979. if (that->m_psi != NULL)
  980. PSI_RWLOCK_CALL(unlock_rwlock)(that->m_psi);
  981. #endif
  982. result= rw_pr_unlock(&that->m_prlock);
  983. return result;
  984. }
  985. #endif
  986. static inline void inline_mysql_cond_register(
  987. #ifdef HAVE_PSI_COND_INTERFACE
  988. const char *category,
  989. PSI_cond_info *info,
  990. int count
  991. #else
  992. const char *category MY_ATTRIBUTE ((unused)),
  993. void *info MY_ATTRIBUTE ((unused)),
  994. int count MY_ATTRIBUTE ((unused))
  995. #endif
  996. )
  997. {
  998. #ifdef HAVE_PSI_COND_INTERFACE
  999. PSI_COND_CALL(register_cond)(category, info, count);
  1000. #endif
  1001. }
  1002. static inline int inline_mysql_cond_init(
  1003. #ifdef HAVE_PSI_COND_INTERFACE
  1004. PSI_cond_key key,
  1005. #endif
  1006. mysql_cond_t *that)
  1007. {
  1008. #ifdef HAVE_PSI_COND_INTERFACE
  1009. that->m_psi= PSI_COND_CALL(init_cond)(key, &that->m_cond);
  1010. #else
  1011. that->m_psi= NULL;
  1012. #endif
  1013. return native_cond_init(&that->m_cond);
  1014. }
  1015. static inline int inline_mysql_cond_destroy(
  1016. mysql_cond_t *that)
  1017. {
  1018. #ifdef HAVE_PSI_COND_INTERFACE
  1019. if (that->m_psi != NULL)
  1020. {
  1021. PSI_COND_CALL(destroy_cond)(that->m_psi);
  1022. that->m_psi= NULL;
  1023. }
  1024. #endif
  1025. return native_cond_destroy(&that->m_cond);
  1026. }
  1027. static inline int inline_mysql_cond_wait(
  1028. mysql_cond_t *that,
  1029. mysql_mutex_t *mutex
  1030. #if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
  1031. , const char *src_file, uint src_line
  1032. #endif
  1033. )
  1034. {
  1035. int result;
  1036. #ifdef HAVE_PSI_COND_INTERFACE
  1037. if (that->m_psi != NULL)
  1038. {
  1039. /* Instrumentation start */
  1040. PSI_cond_locker *locker;
  1041. PSI_cond_locker_state state;
  1042. locker= PSI_COND_CALL(start_cond_wait)(&state, that->m_psi, mutex->m_psi,
  1043. PSI_COND_WAIT, src_file, src_line);
  1044. /* Instrumented code */
  1045. result= my_cond_wait(&that->m_cond, &mutex->m_mutex
  1046. #ifdef SAFE_MUTEX
  1047. , src_file, src_line
  1048. #endif
  1049. );
  1050. /* Instrumentation end */
  1051. if (locker != NULL)
  1052. PSI_COND_CALL(end_cond_wait)(locker, result);
  1053. return result;
  1054. }
  1055. #endif
  1056. /* Non instrumented code */
  1057. result= my_cond_wait(&that->m_cond, &mutex->m_mutex
  1058. #ifdef SAFE_MUTEX
  1059. , src_file, src_line
  1060. #endif
  1061. );
  1062. return result;
  1063. }
  1064. static inline int inline_mysql_cond_timedwait(
  1065. mysql_cond_t *that,
  1066. mysql_mutex_t *mutex,
  1067. const struct timespec *abstime
  1068. #if defined(SAFE_MUTEX) || defined(HAVE_PSI_COND_INTERFACE)
  1069. , const char *src_file, uint src_line
  1070. #endif
  1071. )
  1072. {
  1073. int result;
  1074. #ifdef HAVE_PSI_COND_INTERFACE
  1075. if (that->m_psi != NULL)
  1076. {
  1077. /* Instrumentation start */
  1078. PSI_cond_locker *locker;
  1079. PSI_cond_locker_state state;
  1080. locker= PSI_COND_CALL(start_cond_wait)(&state, that->m_psi, mutex->m_psi,
  1081. PSI_COND_TIMEDWAIT, src_file, src_line);
  1082. /* Instrumented code */
  1083. result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime
  1084. #ifdef SAFE_MUTEX
  1085. , src_file, src_line
  1086. #endif
  1087. );
  1088. /* Instrumentation end */
  1089. if (locker != NULL)
  1090. PSI_COND_CALL(end_cond_wait)(locker, result);
  1091. return result;
  1092. }
  1093. #endif
  1094. /* Non instrumented code */
  1095. result= my_cond_timedwait(&that->m_cond, &mutex->m_mutex, abstime
  1096. #ifdef SAFE_MUTEX
  1097. , src_file, src_line
  1098. #endif
  1099. );
  1100. return result;
  1101. }
  1102. static inline int inline_mysql_cond_signal(
  1103. mysql_cond_t *that)
  1104. {
  1105. int result;
  1106. #ifdef HAVE_PSI_COND_INTERFACE
  1107. if (that->m_psi != NULL)
  1108. PSI_COND_CALL(signal_cond)(that->m_psi);
  1109. #endif
  1110. result= native_cond_signal(&that->m_cond);
  1111. return result;
  1112. }
  1113. static inline int inline_mysql_cond_broadcast(
  1114. mysql_cond_t *that)
  1115. {
  1116. int result;
  1117. #ifdef HAVE_PSI_COND_INTERFACE
  1118. if (that->m_psi != NULL)
  1119. PSI_COND_CALL(broadcast_cond)(that->m_psi);
  1120. #endif
  1121. result= native_cond_broadcast(&that->m_cond);
  1122. return result;
  1123. }
  1124. static inline void inline_mysql_thread_register(
  1125. #ifdef HAVE_PSI_THREAD_INTERFACE
  1126. const char *category,
  1127. PSI_thread_info *info,
  1128. int count
  1129. #else
  1130. const char *category MY_ATTRIBUTE ((unused)),
  1131. void *info MY_ATTRIBUTE ((unused)),
  1132. int count MY_ATTRIBUTE ((unused))
  1133. #endif
  1134. )
  1135. {
  1136. #ifdef HAVE_PSI_THREAD_INTERFACE
  1137. PSI_THREAD_CALL(register_thread)(category, info, count);
  1138. #endif
  1139. }
  1140. #ifdef HAVE_PSI_THREAD_INTERFACE
  1141. static inline int inline_mysql_thread_create(
  1142. PSI_thread_key key,
  1143. my_thread_handle *thread, const my_thread_attr_t *attr,
  1144. my_start_routine start_routine, void *arg)
  1145. {
  1146. int result;
  1147. result= PSI_THREAD_CALL(spawn_thread)(key, thread, attr, start_routine, arg);
  1148. return result;
  1149. }
  1150. static inline void inline_mysql_thread_set_psi_id(my_thread_id id)
  1151. {
  1152. struct PSI_thread *psi= PSI_THREAD_CALL(get_thread)();
  1153. PSI_THREAD_CALL(set_thread_id)(psi, id);
  1154. }
  1155. #ifdef __cplusplus
  1156. class THD;
  1157. static inline void inline_mysql_thread_set_psi_THD(THD *thd)
  1158. {
  1159. struct PSI_thread *psi= PSI_THREAD_CALL(get_thread)();
  1160. PSI_THREAD_CALL(set_thread_THD)(psi, thd);
  1161. }
  1162. #endif /* __cplusplus */
  1163. #endif
  1164. #endif /* DISABLE_MYSQL_THREAD_H */
  1165. /** @} (end of group Thread_instrumentation) */
  1166. #endif