mysql_thread.h 32 KB

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