Changeset 7f9df7b9 in mainline for uspace/lib/posix/src/signal.c


Ignore:
Timestamp:
2018-01-22T22:42:57Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7a08c70
Parents:
e0f47f5
Message:

Remove unnecessary symbol renaming from libposix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/src/signal.c

    re0f47f5 r7f9df7b9  
    3333 */
    3434
    35 #define LIBPOSIX_INTERNAL
    36 #define __POSIX_DEF__(x) posix_##x
    37 
    3835#include "posix/signal.h"
    3936#include "internal/common.h"
     
    6158static LIST_INITIALIZE(_signal_queue);
    6259
    63 static posix_sigset_t _signal_mask = 0;
     60static sigset_t _signal_mask = 0;
    6461
    6562#define DEFAULT_HANDLER { .sa_handler = SIG_DFL, \
     
    6764
    6865/* Actions associated with each signal number. */
    69 static struct posix_sigaction _signal_actions[_TOP_SIGNAL + 1] = {
     66static struct sigaction _signal_actions[_TOP_SIGNAL + 1] = {
    7067        DEFAULT_HANDLER, DEFAULT_HANDLER, DEFAULT_HANDLER, DEFAULT_HANDLER,
    7168        DEFAULT_HANDLER, DEFAULT_HANDLER, DEFAULT_HANDLER, DEFAULT_HANDLER,
     
    111108        case SIGILL:
    112109        case SIGSEGV:
    113                 posix_psignal(signo, "Hardware exception raised by user code");
     110                psignal(signo, "Hardware exception raised by user code");
    114111                abort();
    115112        case SIGSYS:
     
    124121        case SIGTTIN:
    125122        case SIGTTOU:
    126                 posix_psignal(signo, "Unsupported signal caught");
     123                psignal(signo, "Unsupported signal caught");
    127124                abort();
    128125        case SIGCHLD:
     
    164161 * @return Always returns zero.
    165162 */
    166 int posix_sigemptyset(posix_sigset_t *set)
     163int sigemptyset(sigset_t *set)
    167164{
    168165        assert(set != NULL);
     
    178175 * @return Always returns zero.
    179176 */
    180 int posix_sigfillset(posix_sigset_t *set)
     177int sigfillset(sigset_t *set)
    181178{
    182179        assert(set != NULL);
     
    193190 * @return Always returns zero.
    194191 */
    195 int posix_sigaddset(posix_sigset_t *set, int signo)
     192int sigaddset(sigset_t *set, int signo)
    196193{
    197194        assert(set != NULL);
     
    208205 * @return Always returns zero.
    209206 */
    210 int posix_sigdelset(posix_sigset_t *set, int signo)
     207int sigdelset(sigset_t *set, int signo)
    211208{
    212209        assert(set != NULL);
     
    223220 * @return 1 if the signal is in the set, 0 otherwise.
    224221 */
    225 int posix_sigismember(const posix_sigset_t *set, int signo)
     222int sigismember(const sigset_t *set, int signo)
    226223{
    227224        assert(set != NULL);
     
    239236 * @param oact
    240237 */
    241 static void _sigaction_unsafe(int sig, const struct posix_sigaction *restrict act,
    242     struct posix_sigaction *restrict oact)
     238static void _sigaction_unsafe(int sig, const struct sigaction *restrict act,
     239    struct sigaction *restrict oact)
    243240{
    244241        if (oact != NULL) {
    245242                memcpy(oact, &_signal_actions[sig],
    246                     sizeof(struct posix_sigaction));
     243                    sizeof(struct sigaction));
    247244        }
    248245
    249246        if (act != NULL) {
    250247                memcpy(&_signal_actions[sig], act,
    251                     sizeof(struct posix_sigaction));
     248                    sizeof(struct sigaction));
    252249        }
    253250}
     
    263260 * @return -1 with errno set on failure, 0 on success.
    264261 */
    265 int posix_sigaction(int sig, const struct posix_sigaction *restrict act,
    266     struct posix_sigaction *restrict oact)
     262int sigaction(int sig, const struct sigaction *restrict act,
     263    struct sigaction *restrict oact)
    267264{
    268265        if (sig > _TOP_SIGNAL || (act != NULL &&
     
    273270
    274271        if (sig > _TOP_CATCHABLE_SIGNAL) {
    275                 posix_psignal(sig,
     272                psignal(sig,
    276273                    "WARNING: registering handler for a partially"
    277274                    " or fully unsupported signal. This handler may only be"
     
    294291 * @return SIG_ERR on failure, original handler on success.
    295292 */
    296 void (*posix_signal(int sig, void (*func)(int)))(int)
    297 {
    298         struct posix_sigaction new = {
     293void (*signal(int sig, void (*func)(int)))(int)
     294{
     295        struct sigaction new = {
    299296                .sa_handler = func,
    300297                .sa_mask = 0,
     
    302299                .sa_sigaction = NULL
    303300        };
    304         struct posix_sigaction old;
    305         if (posix_sigaction(sig, func == NULL ? NULL : &new, &old) == 0) {
     301        struct sigaction old;
     302        if (sigaction(sig, func == NULL ? NULL : &new, &old) == 0) {
    306303                return old.sa_handler;
    307304        } else {
     
    313310        link_t link;
    314311        int signo;
    315         posix_siginfo_t siginfo;
     312        siginfo_t siginfo;
    316313} signal_queue_item;
    317314
     
    322319 * @param siginfo Additional information about the signal.
    323320 */
    324 static void _queue_signal(int signo, posix_siginfo_t *siginfo)
     321static void _queue_signal(int signo, siginfo_t *siginfo)
    325322{
    326323        assert(signo >= 0 && signo <= _TOP_SIGNAL);
     
    330327        link_initialize(&(item->link));
    331328        item->signo = signo;
    332         memcpy(&item->siginfo, siginfo, sizeof(posix_siginfo_t));
     329        memcpy(&item->siginfo, siginfo, sizeof(siginfo_t));
    333330        list_append(&(item->link), &_signal_queue);
    334331}
     
    343340 *     blocked.
    344341 */
    345 static int _raise_sigaction(int signo, posix_siginfo_t *siginfo)
     342static int _raise_sigaction(int signo, siginfo_t *siginfo)
    346343{
    347344        assert(signo >= 0 && signo <= _TOP_SIGNAL);
     
    350347        fibril_mutex_lock(&_signal_mutex);
    351348
    352         struct posix_sigaction action = _signal_actions[signo];
    353 
    354         if (posix_sigismember(&_signal_mask, signo) ||
     349        struct sigaction action = _signal_actions[signo];
     350
     351        if (sigismember(&_signal_mask, signo) ||
    355352            action.sa_handler == SIG_HOLD) {
    356353                _queue_signal(signo, siginfo);
     
    364361
    365362        if ((action.sa_flags & SA_RESETHAND) && signo != SIGILL && signo != SIGTRAP) {
    366                 _signal_actions[signo] = (struct posix_sigaction) DEFAULT_HANDLER;
     363                _signal_actions[signo] = (struct sigaction) DEFAULT_HANDLER;
    367364        }
    368365
     
    394391                    list_get_instance(iterator, signal_queue_item, link);
    395392               
    396                 if (!posix_sigismember(&_signal_mask, item->signo) &&
     393                if (!sigismember(&_signal_mask, item->signo) &&
    397394                    _signal_actions[item->signo].sa_handler != SIG_HOLD) {
    398395                        list_remove(&(item->link));
     
    411408 * @return -1 with errno set on failure, 0 on success.
    412409 */
    413 int posix_raise(int sig)
     410int raise(int sig)
    414411{
    415412        if (sig >= 0 && sig <= _TOP_SIGNAL) {
    416                 posix_siginfo_t siginfo = {
     413                siginfo_t siginfo = {
    417414                        .si_signo = sig,
    418415                        .si_code = SI_USER
     
    433430 *     action, invalid signal number, lack of permissions, etc.), 0 on success.
    434431 */
    435 int posix_kill(posix_pid_t pid, int signo)
     432int kill(pid_t pid, int signo)
    436433{
    437434        if (pid < 1) {
     
    446443        }
    447444
    448         if (pid == (posix_pid_t) task_get_id()) {
    449                 return posix_raise(signo);
     445        if (pid == (pid_t) task_get_id()) {
     446                return raise(signo);
    450447        }
    451448
     
    471468 * @return -1 on failure, 0 on success (see kill()).
    472469 */
    473 int posix_killpg(posix_pid_t pid, int sig)
     470int killpg(pid_t pid, int sig)
    474471{
    475472        assert(pid > 1);
    476         return posix_kill(-pid, sig);
     473        return kill(-pid, sig);
    477474}
    478475
     
    483480 * @param message String to output alongside human-readable signal description.
    484481 */
    485 void posix_psiginfo(const posix_siginfo_t *pinfo, const char *message)
     482void psiginfo(const siginfo_t *pinfo, const char *message)
    486483{
    487484        assert(pinfo != NULL);
    488         posix_psignal(pinfo->si_signo, message);
     485        psignal(pinfo->si_signo, message);
    489486        // TODO: print si_code
    490487}
     
    496493 * @param message String to output alongside human-readable signal description.
    497494 */
    498 void posix_psignal(int signum, const char *message)
    499 {
    500         char *sigmsg = posix_strsignal(signum);
     495void psignal(int signum, const char *message)
     496{
     497        char *sigmsg = strsignal(signum);
    501498        if (message == NULL || *message == '\0') {
    502499                fprintf(stderr, "%s\n", sigmsg);
     
    514511 * @return 0 success, errorcode on failure.
    515512 */
    516 int posix_thread_sigmask(int how, const posix_sigset_t *restrict set,
    517     posix_sigset_t *restrict oset)
     513int thread_sigmask(int how, const sigset_t *restrict set,
     514    sigset_t *restrict oset)
    518515{
    519516        fibril_mutex_lock(&_signal_mutex);
     
    554551 * @return 0 on success, -1 with errno set on failure.
    555552 */
    556 int posix_sigprocmask(int how, const posix_sigset_t *restrict set,
    557     posix_sigset_t *restrict oset)
    558 {
    559         int result = posix_thread_sigmask(how, set, oset);
     553int sigprocmask(int how, const sigset_t *restrict set,
     554    sigset_t *restrict oset)
     555{
     556        int result = thread_sigmask(how, set, oset);
    560557        if (result != 0) {
    561558                errno = result;
Note: See TracChangeset for help on using the changeset viewer.