* @brief Sets the cancelability state of the calling thread. * * The `pthread_setcancelstate` function allows a thread to enable or disable its ability to be canceled * by another thread. Cancelability determines if and when a thread responds to a cancellation request. * * @param[in] state * The new cancelability state for the calling thread. Possible values: * - `PTHREAD_CANCEL_ENABLE`
| 1309 | * @see pthread_cancel, pthread_setcanceltype |
| 1310 | */ |
| 1311 | int pthread_setcancelstate(int state, int *oldstate) |
| 1312 | { |
| 1313 | _pthread_data_t *ptd; |
| 1314 | |
| 1315 | if (rt_thread_self() == NULL) return EINVAL; |
| 1316 | |
| 1317 | /* get pthread data from pthread_data of thread */ |
| 1318 | ptd = (_pthread_data_t *)rt_thread_self()->pthread_data; |
| 1319 | RT_ASSERT(ptd != RT_NULL); |
| 1320 | |
| 1321 | if ((state == PTHREAD_CANCEL_ENABLE) || (state == PTHREAD_CANCEL_DISABLE)) |
| 1322 | { |
| 1323 | if (oldstate) |
| 1324 | *oldstate = ptd->cancelstate; |
| 1325 | ptd->cancelstate = state; |
| 1326 | |
| 1327 | return 0; |
| 1328 | } |
| 1329 | |
| 1330 | return EINVAL; |
| 1331 | } |
| 1332 | RTM_EXPORT(pthread_setcancelstate); |
| 1333 | |
| 1334 | /** |
no test coverage detected