diff options
Diffstat (limited to 'gl/glthread/lock.c')
| -rw-r--r-- | gl/glthread/lock.c | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/gl/glthread/lock.c b/gl/glthread/lock.c index 6661ad6a..dace4fda 100644 --- a/gl/glthread/lock.c +++ b/gl/glthread/lock.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* Locking in multithreaded situations. | 1 | /* Locking in multithreaded situations. |
| 2 | Copyright (C) 2005-2024 Free Software Foundation, Inc. | 2 | Copyright (C) 2005-2025 Free Software Foundation, Inc. |
| 3 | 3 | ||
| 4 | This file is free software: you can redistribute it and/or modify | 4 | This file is free software: you can redistribute it and/or modify |
| 5 | it under the terms of the GNU Lesser General Public License as | 5 | it under the terms of the GNU Lesser General Public License as |
| @@ -240,8 +240,6 @@ glthread_recursive_lock_destroy (gl_recursive_lock_t *lock) | |||
| 240 | return 0; | 240 | return 0; |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | /* -------------------------- gl_once_t datatype -------------------------- */ | ||
| 244 | |||
| 245 | #endif | 243 | #endif |
| 246 | 244 | ||
| 247 | /* ========================================================================= */ | 245 | /* ========================================================================= */ |
| @@ -271,7 +269,7 @@ glthread_rwlock_init_for_glibc (pthread_rwlock_t *lock) | |||
| 271 | /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that | 269 | /* Note: PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP is the only value that |
| 272 | causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not | 270 | causes the writer to be preferred. PTHREAD_RWLOCK_PREFER_WRITER_NP does not |
| 273 | do this; see | 271 | do this; see |
| 274 | http://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */ | 272 | https://man7.org/linux/man-pages/man3/pthread_rwlockattr_setkind_np.3.html */ |
| 275 | err = pthread_rwlockattr_setkind_np (&attributes, | 273 | err = pthread_rwlockattr_setkind_np (&attributes, |
| 276 | PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); | 274 | PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); |
| 277 | if (err == 0) | 275 | if (err == 0) |
| @@ -698,46 +696,6 @@ glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock) | |||
| 698 | 696 | ||
| 699 | # endif | 697 | # endif |
| 700 | 698 | ||
| 701 | /* -------------------------- gl_once_t datatype -------------------------- */ | ||
| 702 | |||
| 703 | static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT; | ||
| 704 | |||
| 705 | int | ||
| 706 | glthread_once_singlethreaded (pthread_once_t *once_control) | ||
| 707 | { | ||
| 708 | /* We don't know whether pthread_once_t is an integer type, a floating-point | ||
| 709 | type, a pointer type, or a structure type. */ | ||
| 710 | char *firstbyte = (char *)once_control; | ||
| 711 | if (*firstbyte == *(const char *)&fresh_once) | ||
| 712 | { | ||
| 713 | /* First time use of once_control. Invert the first byte. */ | ||
| 714 | *firstbyte = ~ *(const char *)&fresh_once; | ||
| 715 | return 1; | ||
| 716 | } | ||
| 717 | else | ||
| 718 | return 0; | ||
| 719 | } | ||
| 720 | |||
| 721 | # if !(PTHREAD_IN_USE_DETECTION_HARD || USE_POSIX_THREADS_WEAK) | ||
| 722 | |||
| 723 | int | ||
| 724 | glthread_once_multithreaded (pthread_once_t *once_control, | ||
| 725 | void (*init_function) (void)) | ||
| 726 | { | ||
| 727 | int err = pthread_once (once_control, init_function); | ||
| 728 | if (err == ENOSYS) | ||
| 729 | { | ||
| 730 | /* This happens on FreeBSD 11: The pthread_once function in libc returns | ||
| 731 | ENOSYS. */ | ||
| 732 | if (glthread_once_singlethreaded (once_control)) | ||
| 733 | init_function (); | ||
| 734 | return 0; | ||
| 735 | } | ||
| 736 | return err; | ||
| 737 | } | ||
| 738 | |||
| 739 | # endif | ||
| 740 | |||
| 741 | #endif | 699 | #endif |
| 742 | 700 | ||
| 743 | /* ========================================================================= */ | 701 | /* ========================================================================= */ |
