2020-06-15 07:18:57 -07:00
|
|
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
|
|
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
|
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
2022-03-25 07:11:44 -07:00
|
|
|
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
2020-06-15 07:18:57 -07:00
|
|
|
│ │
|
2020-12-27 17:18:44 -08:00
|
|
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
|
|
│ any purpose with or without fee is hereby granted, provided that the │
|
|
|
|
│ above copyright notice and this permission notice appear in all copies. │
|
2020-06-15 07:18:57 -07:00
|
|
|
│ │
|
2020-12-27 17:18:44 -08:00
|
|
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
|
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
|
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
|
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
|
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
|
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
|
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
|
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
2020-06-15 07:18:57 -07:00
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
2022-11-04 01:04:43 -07:00
|
|
|
#include "libc/calls/internal.h"
|
2022-03-25 07:11:44 -07:00
|
|
|
#include "libc/calls/sig.internal.h"
|
2022-05-23 15:06:11 -07:00
|
|
|
#include "libc/calls/syscall_support-nt.internal.h"
|
2022-11-04 01:04:43 -07:00
|
|
|
#include "libc/errno.h"
|
2022-08-13 13:11:56 -07:00
|
|
|
#include "libc/intrin/weaken.h"
|
2023-09-10 11:52:03 -07:00
|
|
|
#include "libc/nt/struct/windowplacement.h"
|
2022-11-04 01:04:43 -07:00
|
|
|
#include "libc/sysv/errfuns.h"
|
|
|
|
#include "libc/thread/thread.h"
|
2022-09-10 02:56:25 -07:00
|
|
|
#include "libc/thread/tls.h"
|
2022-05-20 18:51:41 -07:00
|
|
|
|
2023-08-19 06:41:06 -07:00
|
|
|
textwindows int _check_interrupts(int sigops) {
|
|
|
|
int e, rc, flags = 0;
|
2023-07-30 04:26:34 -07:00
|
|
|
e = errno;
|
2022-11-04 01:04:43 -07:00
|
|
|
if (_weaken(pthread_testcancel_np) &&
|
|
|
|
(rc = _weaken(pthread_testcancel_np)())) {
|
|
|
|
errno = rc;
|
|
|
|
return -1;
|
|
|
|
}
|
2023-08-08 04:00:29 -07:00
|
|
|
if (__tls_enabled) {
|
2023-08-19 06:41:06 -07:00
|
|
|
flags = __get_tls()->tib_flags;
|
2023-08-08 04:00:29 -07:00
|
|
|
__get_tls()->tib_flags |= TIB_FLAG_TIME_CRITICAL;
|
|
|
|
}
|
2023-07-30 04:26:34 -07:00
|
|
|
if (_weaken(_check_sigalrm)) {
|
|
|
|
_weaken(_check_sigalrm)();
|
|
|
|
}
|
2023-08-08 04:00:29 -07:00
|
|
|
if (__tls_enabled) {
|
2023-08-19 06:41:06 -07:00
|
|
|
__get_tls()->tib_flags = flags;
|
|
|
|
}
|
2023-07-30 08:55:01 -07:00
|
|
|
if (_weaken(__sig_check) && _weaken(__sig_check)(sigops)) {
|
2023-07-30 04:26:34 -07:00
|
|
|
return eintr();
|
2022-10-08 02:40:44 -07:00
|
|
|
}
|
2023-07-30 04:26:34 -07:00
|
|
|
errno = e;
|
2022-11-04 01:04:43 -07:00
|
|
|
return 0;
|
2020-06-15 07:18:57 -07:00
|
|
|
}
|