| 1 | /* Test of <pthread.h> substitute.
|
|---|
| 2 | Copyright (C) 2019-2022 Free Software Foundation, Inc.
|
|---|
| 3 |
|
|---|
| 4 | This program is free software: you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|---|
| 16 |
|
|---|
| 17 | /* Written by Bruno Haible <bruno@clisp.org>, 2019. */
|
|---|
| 18 |
|
|---|
| 19 | #include <config.h>
|
|---|
| 20 |
|
|---|
| 21 | #include <pthread.h>
|
|---|
| 22 |
|
|---|
| 23 | /* Check that the types are all defined. */
|
|---|
| 24 |
|
|---|
| 25 | pthread_t t1;
|
|---|
| 26 | pthread_attr_t t2;
|
|---|
| 27 |
|
|---|
| 28 | pthread_once_t t3 = PTHREAD_ONCE_INIT;
|
|---|
| 29 |
|
|---|
| 30 | pthread_mutex_t t4 = PTHREAD_MUTEX_INITIALIZER;
|
|---|
| 31 | pthread_mutexattr_t t5;
|
|---|
| 32 |
|
|---|
| 33 | pthread_rwlock_t t6 = PTHREAD_RWLOCK_INITIALIZER;
|
|---|
| 34 | pthread_rwlockattr_t t7;
|
|---|
| 35 |
|
|---|
| 36 | pthread_cond_t t8 = PTHREAD_COND_INITIALIZER;
|
|---|
| 37 | pthread_condattr_t t9;
|
|---|
| 38 |
|
|---|
| 39 | pthread_key_t t10;
|
|---|
| 40 |
|
|---|
| 41 | pthread_spinlock_t t11;
|
|---|
| 42 |
|
|---|
| 43 | #ifdef TODO /* Not implemented in gnulib yet */
|
|---|
| 44 | pthread_barrier_t t12;
|
|---|
| 45 | pthread_barrierattr_t t13;
|
|---|
| 46 | #endif
|
|---|
| 47 |
|
|---|
| 48 | /* Check that the various macros are defined. */
|
|---|
| 49 |
|
|---|
| 50 | /* Constants for pthread_attr_setdetachstate(). */
|
|---|
| 51 | int ds[] = { PTHREAD_CREATE_JOINABLE, PTHREAD_CREATE_DETACHED };
|
|---|
| 52 |
|
|---|
| 53 | /* Constants for pthread_exit(). */
|
|---|
| 54 | void *canceled = PTHREAD_CANCELED;
|
|---|
| 55 |
|
|---|
| 56 | /* Constants for pthread_mutexattr_settype(). */
|
|---|
| 57 | int mt[] = {
|
|---|
| 58 | PTHREAD_MUTEX_DEFAULT,
|
|---|
| 59 | PTHREAD_MUTEX_NORMAL,
|
|---|
| 60 | PTHREAD_MUTEX_RECURSIVE,
|
|---|
| 61 | PTHREAD_MUTEX_ERRORCHECK
|
|---|
| 62 | };
|
|---|
| 63 |
|
|---|
| 64 | #ifdef TODO /* Not implemented in gnulib yet */
|
|---|
| 65 |
|
|---|
| 66 | /* Constants for pthread_mutexattr_setrobust(). */
|
|---|
| 67 | int mr[] = { PTHREAD_MUTEX_ROBUST, PTHREAD_MUTEX_STALLED };
|
|---|
| 68 |
|
|---|
| 69 | /* Constants for pthread_barrierattr_setpshared(). */
|
|---|
| 70 | int bp[] = { PTHREAD_PROCESS_SHARED, PTHREAD_PROCESS_PRIVATE };
|
|---|
| 71 |
|
|---|
| 72 | /* Constants for pthread_barrier_wait(). */
|
|---|
| 73 | int bw[] = { PTHREAD_BARRIER_SERIAL_THREAD };
|
|---|
| 74 |
|
|---|
| 75 | /* Constants for pthread_setcancelstate(). */
|
|---|
| 76 | int cs[] = { PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE };
|
|---|
| 77 |
|
|---|
| 78 | /* Constants for pthread_setcanceltype(). */
|
|---|
| 79 | int ct[] = { PTHREAD_CANCEL_DEFERRED, PTHREAD_CANCEL_ASYNCHRONOUS };
|
|---|
| 80 |
|
|---|
| 81 | #endif
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | int
|
|---|
| 85 | main (void)
|
|---|
| 86 | {
|
|---|
| 87 | return 0;
|
|---|
| 88 | }
|
|---|