Changeset 1614 for trunk/src


Ignore:
Timestamp:
Nov 5, 2004, 3:16:17 AM (21 years ago)
Author:
bird
Message:

Non-working signal code. (better having it in CVS than locally now)

Location:
trunk/src/emx
Files:
40 added
12 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/CompileOne.sh

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1613 r1614  
    99#set -x
    1010   gcc -c -O3 -o $TMP/compileO3.o -fmessage-length=0 -std=gnu99 -Wundef -Wall -Wmissing-prototypes -pedantic -Wno-long-long \
    11     -DIN_INNOTEK_LIBC -D_NFILES=20 \
    12     -I$SRCDIR -I$ROOTDIR/include -I$ROOTDIR/src/include -I$OUTDIR/emx -I$ROOTDIR/src/lib/lgpl/include -DHAVE_CONFIG_H $1 \
     11    -DIN_INNOTEK_LIBC -D_NFILES=20 -DHAVE_CONFIG_H \
     12    -I$SRCDIR -I$ROOTDIR/include -I$ROOTDIR/src/include -I$OUTDIR/emx -I$ROOTDIR/src/lib/lgpl/include $1 \
    1313&& gcc -c -O3 -o $TMP/compileLg.o -fmessage-length=0 -std=gnu99 -Wundef -Wall -Wmissing-prototypes -pedantic -Wno-long-long \
    1414    -DIN_INNOTEK_LIBC -D_NFILES=20 -DHAVE_CONFIG_H -DDEBUG_LOGGING -D__LIBC_STRICT \
  • trunk/src/emx/Makefile

    • Property cvs2svn:cvs-rev changed from 1.54 to 1.55
  • trunk/src/emx/include/InnoTekLIBC/sharedpm.h

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r1613 r1614  
    598598 *
    599599 * @returns 0 on success.
    600  * @returns -1 and errno on failure.
     600 * @returns Negative error code (errno.h) on failure.
    601601 * @param   iSocket     The new socket.
    602602 */
     
    607607 *
    608608 * @returns The new reference count.
    609  * @returns -1 and errno on failure.
     609 * @returns Negative error code (errno.h) on failure.
    610610 * @param   iSocket     socket to reference.
    611611 */
     
    617617 * @returns The new reference count.
    618618 *          The caller must close the socket if 0 is returned.
    619  * @returns -1 and errno on failure.
     619 * @returns Negative error code (errno.h) on failure.
    620620 * @param   iSocket     Socket to dereference.
    621621 */
  • trunk/src/emx/include/InnoTekLIBC/signals.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1613 r1614  
    9797int         __libc_back_signalVerifyPGrp(pid_t pgid);
    9898int         __libc_back_signalSendPid(pid_t pid, int iSignalNo);
     99int         __libc_back_signalSendPidOther(pid_t pid, int iSignalNo);
    99100int         __libc_back_signalSendPGrp(pid_t pgrp, int iSignalNo);
    100101int         __libc_back_signalAction(int iSignalNo, const struct sigaction *pSigAct, struct sigaction *pSigActOld);
    101102unsigned    __libc_back_signalRaise(int iSignalNo, siginfo_t *pSigInfo, void *pvXcptOrQueued, unsigned fFlags);
    102103int         __libc_back_signalRaisePoked(void *pvXcptParams, int tidPoker);
     104void        __libc_back_signalOS2V1Handler16bit(unsigned short uSignal, unsigned short uArg);
     105void        __libc_back_signalOS2V1Handler32bit(unsigned uSignal, unsigned uArg);
    103106
    104107__END_DECLS
  • trunk/src/emx/include/InnoTekLIBC/thread.h

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r1613 r1614  
    6868    struct _uheap * pRegularHeap;
    6969    /** Reference count. */
    70     unsigned        cRefs;
     70    volatile unsigned cRefs;
    7171    /** Thread Id. */
    7272    unsigned        tid;
     
    145145     * read without owning the semaphore.
    146146     */
    147     unsigned        fSigBeingPoked;
     147    volatile unsigned   fSigBeingPoked;
    148148
    149149
     
    189189        struct __libc_sys
    190190        {
    191 #ifndef __NEW_SIGNALS__
    192             /** Blocked signal mask. */
    193             sigset_t            sig_blocked;
    194             /** Pending signal mask. */
    195             sigset_t            sig_pending;
    196             /** Signal actions. */
    197             struct sigaction    signals[NSIG];
    198 #endif /* !__NEW_SIGNALS__ */
    199191            /** Directory find data entry.
    200192             * Used by __findfirst() and __findnext(). */
  • trunk/src/emx/include/emx/syscalls.h

    • Property cvs2svn:cvs-rev changed from 1.14 to 1.15
    r1613 r1614  
    55
    66#include <sys/types.h>
    7 #ifdef __NEW_SIGNALS__
    87#include <sys/_sigset.h>
    9 #endif
    108
    119#if defined (__cplusplus)
     
    3129#define _SO_SYNC        0x00100000
    3230#define _SO_SIZE        0x00200000
    33 
    34 #ifndef __NEW_SIGNALS__
    35 #include <sys/types.h>
    36 /* For debugging of signal handlers. */
    37 #define _SIG_MAGIC1     0xfeed6666
    38 #define _SIG_MAGIC2     0x47dead11
    39 #define _SIG_MAGIC3     0x9999beef
    40 #define _SIG_MAGIC4     0xaffe0815
    41 
    42 #if !defined (_SIGSET_T)
    43 #define _SIGSET_T
    44 typedef unsigned long sigset_t;
    45 #endif
    46 #endif /* !__NEW_SIGNALS__ */
    47 
    4831
    4932struct hostent;
  • trunk/src/emx/include/signal.h

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1613 r1614  
    1 #ifdef __NEW_SIGNALS__
    21/** @file
    32 * FreeBSD 5.1
     
    136135#endif /* !_SIGNAL_H_ */
    137136
    138 #else  /* !__NEW_SIGNALS__ */
    139 
    140 /* signal.h (emx+gcc) */
    141 
    142 #ifndef _SIGNAL_H
    143 #define _SIGNAL_H
    144 #include <sys/cdefs.h>
    145 #include <sys/signal.h>
    146 
    147 #if __BSD_VISIBLE
    148 /*
    149  * XXX should enlarge these, if only to give empty names instead of bounds
    150  * errors for large signal numbers.
    151  */
    152 extern __const char *__const sys_signame[NSIG];
    153 extern __const char *__const sys_siglist[NSIG];
    154 extern __const int sys_nsig;
    155 #endif
    156 
    157 
    158 #endif /* not _SIGNAL_H */
    159 
    160 #endif /* !__NEW_SIGNALS__ */
  • trunk/src/emx/include/sys/select.h

    • Property cvs2svn:cvs-rev changed from 1.8 to 1.9
    r1613 r1614  
    1010
    1111#include <sys/cdefs.h>
    12 #ifdef __NEW_SIGNALS__
    1312#include <sys/_sigset.h>
    1413
     
    1817typedef __sigset_t sigset_t;
    1918#endif
    20 
    21 #else /* !__NEW_SIGNALS__ */
    22 
    23 /** Define sigset_t here for pselect(). */
    24 #if !defined (_SIGSET_T)
    25 #define _SIGSET_T
    26 typedef unsigned long sigset_t;
    27 #endif
    28 
    29 #endif /* !__NEW_SIGNALS__ */
    30 
    3119
    3220/** Define the number of file handles in the select buffer.
  • trunk/src/emx/include/sys/signal.h

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r1613 r1614  
    1 #ifdef __NEW_SIGNALS__
    21/* $Id: $ */
    32/** @file
     
    530529#endif /* not _SYS_SIGNAL_H */
    531530
    532 
    533 #else /* !__NEW_SIGNALS__ */
    534 
    535 
    536 /* sys/signal.h (emx+gcc) */
    537 
    538 #ifndef _SYS_SIGNAL_H
    539 #define _SYS_SIGNAL_H
    540 
    541 #if defined (__cplusplus)
    542 extern "C" {
    543 #endif
    544 
    545 typedef int sig_atomic_t;
    546 
    547 #define SIGHUP    1 /* Hangup */
    548 #define SIGINT    2 /* Interrupt (Ctrl-C) */
    549 #define SIGQUIT   3 /* Quit */
    550 #define SIGILL    4 /* Illegal instruction */
    551 #define SIGTRAP   5 /* Single step (debugging) */
    552 #define SIGABRT   6 /* abort () */
    553 #define SIGEMT    7 /* EMT instruction */
    554 #define SIGFPE    8 /* Floating point */
    555 #define SIGKILL   9 /* Kill process */
    556 #define SIGBUS   10 /* Bus error */
    557 #define SIGSEGV  11 /* Segmentation fault */
    558 #define SIGSYS   12 /* Invalid argument to system call */
    559 #define SIGPIPE  13 /* Broken pipe */
    560 #define SIGALRM  14 /* Alarm */
    561 #define SIGTERM  15 /* Termination, process killed */
    562 #define SIGUSR1  16 /* User-defined signal #1 */
    563 #define SIGUSR2  17 /* User-defined signal #2 */
    564 #define SIGCHLD  18 /* Death of a child process */
    565 #define SIGBREAK 21 /* Break (Ctrl-Break) */
    566 #define SIGWINCH 28 /* Window size change (not implemented) */
    567 
    568 #define SIGPTRACENOTIFY 128     /* Notification from ptrace() */
    569 
    570 #define SIGCLD   SIGCHLD
    571 
    572 #define SIG_DFL ((void (*)(int))0)
    573 #define SIG_IGN ((void (*)(int))1)
    574 #define SIG_ERR ((void (*)(int))-1)
    575 
    576 void (*signal (int, void (*)(int)))(int);
    577 int raise (int);
    578 
    579 
    580 #if !defined (__STRICT_ANSI__)
    581 
    582 #define NSIG 29
    583 
    584 #define SA_NOCLDSTOP    0x0001
    585 
    586 #define SIG_BLOCK       1
    587 #define SIG_UNBLOCK     2
    588 #define SIG_SETMASK     3
    589 
    590 #if !defined (_SIGSET_T)
    591 #define _SIGSET_T
    592 typedef unsigned long sigset_t;
    593 #endif
    594 
    595 struct sigaction
    596 {
    597   void (*sa_handler)(int);
    598   sigset_t sa_mask;
    599   int sa_flags;
    600 };
    601 
    602 
    603 int kill (int, int);
    604 int pause (void);
    605 
    606 int sigaction (int, __const__ struct sigaction *, struct sigaction *);
    607 int sigpending (sigset_t *);
    608 int sigprocmask (int, __const__ sigset_t *, sigset_t *);
    609 int sigsuspend (__const__ sigset_t *);
    610 
    611 int sigaddset (sigset_t *, int);
    612 int sigdelset (sigset_t *, int);
    613 int sigemptyset (sigset_t *);
    614 int sigfillset (sigset_t *);
    615 int sigismember (__const__ sigset_t *, int);
    616 
    617 #define _SIGMASK(sig) ((sigset_t)1 << ((sig) - 1))
    618 #define __sigaddset(set,sig)   (*(set) |= _SIGMASK (sig), 0)
    619 #define __sigdelset(set,sig)   (*(set) &= ~_SIGMASK (sig), 0)
    620 #define __sigemptyset(set)     (*(set) = 0, 0)
    621 #define __sigfillset(set)      (*(set) = ~(sigset_t)0, 0)
    622 #define __sigismember(set,sig) ((*(set) & _SIGMASK (sig)) ? 1 : 0)
    623 
    624 int _kill (int, int);
    625 int _pause (void);
    626 
    627 int _sigaction (int, __const__ struct sigaction *, struct sigaction *);
    628 int _sigpending (sigset_t *);
    629 int _sigprocmask (int, __const__ sigset_t *, sigset_t *);
    630 int _sigsuspend (__const__ sigset_t *);
    631 
    632 int _sigaddset (sigset_t *, int);
    633 int _sigdelset (sigset_t *, int);
    634 int _sigemptyset (sigset_t *);
    635 int _sigfillset (sigset_t *);
    636 int _sigismember (__const__ sigset_t *, int);
    637 
    638 #endif
    639 
    640 
    641 #if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) || defined(__USE_EMX)
    642 
    643 #define SIG_ACK ((void (*)(int))4)
    644 
    645 #define SA_SYSV         0x0002  /* Reset to SIG_DFL */
    646 #define SA_ACK          0x0004  /* Don't unblock automatically */
    647 
    648 #define SIGTY void
    649 
    650 #endif
    651 
    652 
    653 #include <sys/_types.h>
    654 
    655 typedef union sigval
    656 {
    657     int     sigval_int;
    658     void   *sigval_ptr;
    659 } sigval_t;
    660 
    661 typedef struct __siginfo
    662 {
    663     /** Signal number. */
    664     int             si_signo;
    665     /** Associated errno. */
    666     int             si_errno;
    667     /** Signal code. (See SI_* and FPE_* macros.) */
    668     int             si_code;
    669     /** Timestamp when the signal was generated - LIBC extension. */
    670     unsigned        si_timestamp;
    671     /** Process sending the signal. */
    672     __pid_t         si_pid;
    673     /** Thread sending the signal - LIBC extension. */
    674     unsigned        si_tid;
    675     /** User sending the signal (ruid). (Usually 0 for OS/2) */
    676     __uid_t         si_uid;
    677     /** Exit value. (SIGCHLD) */
    678     int             si_status;
    679     /** Pointer to the faulting instruction or memory reference. (SIGSEGV, SIGILL, SIGFPE, SIGBUS) */
    680     void           *si_addr;
    681     /** Signal value. */
    682     union sigval    si_value;
    683     /** Band event for SIGPOLL. */
    684     long            si_band;
    685     /** Filehandle for SIGPOLL. */
    686     int             si_fd;
    687     /** Reserve a little bit for future usage. */
    688     unsigned        auReserved[4];
    689 } siginfo_t;
    690 
    691 #if defined (__cplusplus)
    692 }
    693 #endif
    694 
    695 #endif /* not _SYS_SIGNAL_H */
    696 
    697 
    698 #endif /* !__NEW_SIGNALS__ */
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.71 to 1.72
    r1613 r1614  
    10901090    "_setprogname" @1112
    10911091    "_setstate" @1113
    1092     "_sig_info" @1114
     1092;    "_sig_info" @1114
    10931093    "_sradixsort" @1115
    10941094    "_srandom" @1116
     
    11011101    "_strsep" @1123
    11021102    "_strsignal" @1124
    1103     "_sys_exception" @1125
     1103;    "_sys_exception" @1125
    11041104    "_sys_nsig" @1126
    11051105    "_sys_siglist" @1127
     
    12111211    "___libc_Back_mmanProtect" @1233
    12121212    "__std_mprotect" @1234
     1213    "__libc_Back_exceptionHandler" @1235
     1214    "__signal_os2" @1236
     1215    "__signal_sysv" @1237
     1216    "___sigpause_bsd" @1238
     1217    "__std_bsd_signal" @1239
     1218    "__std_killpg" @1240
     1219    "__std_psignal" @1241
     1220    "__std_sigaltstack" @1242
     1221    "__std_sigblock" @1243
     1222    "__std_sighold" @1244
     1223    "__std_sigignore" @1245
     1224    "__std_siginterrupt" @1246
     1225    "__std_sigpause" @1247
     1226    "__std_sigrelse" @1248
     1227    "__std_sigsetmask" @1249
     1228    "__std_sigtimedwait" @1250
     1229    "__std_sigvec" @1251
     1230    "__std_sigwait" @1252
     1231    "__std_sigwaitinfo" @1253
  • trunk/src/emx/src/lib/libc.smak

    • Property cvs2svn:cvs-rev changed from 1.49 to 1.50
    r1613 r1614  
    4343.TARGET := libc_s.a
    4444.TKIND  := aout
     45.TKEEP  := 1
     46include mklib.smak
     47
     48.TARGET := libc_omf386.lib
     49.TKIND  := omf
     50.TSRC   := $(wildcard src/lib/sys/386/*.asm)
     51.TDEP   :=
     52.TCF    :=
    4553.TKEEP  := 1
    4654include mklib.smak
     
    106114        $.omf/src/lib/startup/dll0hi.obj \
    107115        $(LIBC.OBJS.COMMON)
    108 LIBC.LIBS       := $.omf/libc_s.lib $.omf/libc_app.lib
     116LIBC.LIBS       := $.omf/libc_s.lib $.omf/libc_app.lib $.omf/libc_omf386.lib
    109117LIBC.DEPS       := $(LIBC.STUB) $.omf/libc_alias.lib $.omf/liblazyimp.lib $.omf-lazy/libos2_unicode_lazy.lib $.omf/libos2.lib $.omf/libend.lib
    110118LIBC.DLL.OBJS   :=
     
    116124        $.omf/src/lib/startup/dll0hi.obj \
    117125        $(subst /omf/,/omf-prof/,$(LIBC.OBJS.COMMON))
    118 LIBC.PRF.LIBS   := $.omf-prof/libc_p_s.lib $.omf-prof/libc_app_p.lib
     126LIBC.PRF.LIBS   := $.omf-prof/libc_p_s.lib $.omf-prof/libc_app_p.lib $.omf/libc_omf386.lib
    119127LIBC.PRF.DEPS   := $(LIBC.STUB) $.omf/libc_alias.lib $.omf-prof/liblazyimp_p.lib $.omf-lazy/libos2_unicode_lazy.lib $.omf-prof/libos2_p.lib $.omf/libend.lib
    120128LIBC.PRF.DIRS   := $(sort $(dir $(LIBC.PRF.OBJS) $(LIBC.PRF.DEPS)))
     
    134142        $.omf/src/lib/startup/dll0hi.obj \
    135143        $(subst /omf/,/omf-log/,$(LIBC.OBJS.COMMON))
    136 LIBC.LOG.LIBS   := $.omf-log/libc_l_s.lib $.omf-log/libc_app_l.lib
     144LIBC.LOG.LIBS   := $.omf-log/libc_l_s.lib $.omf-log/libc_app_l.lib $.omf/libc_omf386.lib
    137145LIBC.LOG.DEPS   := $(LIBC.DEPS)
    138146LIBC.LOG.DIRS   := $(sort $(dir $(LIBC.LOG.OBJS) $(LIBC.LOG.DEPS))) $.omf-log/
  • trunk/src/emx/src/lib/process/386/gettid.s

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1613 r1614  
    1010
    1111__gettid:
     12        push    %fs
     13        movl    $DosTIB, %eax
     14        movl    %eax, %fs
    1215        fs
    1316        movl    12, %eax                /* ptib2 */
    1417        movl    0(%eax), %eax           /* TID */
     18        pop     %fs
    1519        EPILOGUE(_gettid)
  • trunk/src/emx/src/lib/process/386/threadid.s

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r1613 r1614  
    1010
    1111___threadid:
     12        push    %fs
     13        movl    $DosTIB, %eax
     14        movl    %eax, %fs
    1215        fs
    1316        movl    12, %eax                /* ptib2 */
     17        pop     %fs
    1418        EPILOGUE(__threadid)
  • trunk/src/emx/src/lib/process/sigempty.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1613 r1614  
    1 /* sigempty.c (emx+gcc) -- Copyright (c) 1994-1995 by Eberhard Mattes */
     1/* $Id: $ */
     2/** @file
     3 *
     4 * LIBC - sigemptyset()
     5 *
     6 * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
     7 *
     8 *
     9 * This file is part of InnoTek LIBC.
     10 *
     11 * InnoTek LIBC is free software; you can redistribute it and/or modify
     12 * it under the terms of the GNU Lesser General Public License as published
     13 * by the Free Software Foundation; either version 2 of the License, or
     14 * (at your option) any later version.
     15 *
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
     17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
     22 * along with InnoTek LIBC; if not, write to the Free Software
     23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     24 *
     25 */
    226
     27
     28/*******************************************************************************
     29*   Header Files                                                               *
     30*******************************************************************************/
    331#include "libc-alias.h"
    432#include <signal.h>
     
    634#include <InnoTekLIBC/logstrict.h>
    735
    8 int _STD(sigemptyset)(sigset_t *set)
     36
     37/**
     38 * Empties (i.e. deletes all signals) a signal set.
     39 *
     40 * @returns 0 indicating success.
     41 * @param   pSigSet     Pointer to signal set to empty.
     42 */
     43int _STD(sigemptyset)(sigset_t *pSigSet)
    944{
    10     LIBCLOG_ENTER("set=%p\n", set);
    11     int rc = __sigemptyset(set);
    12     LIBCLOG_RETURN_INT(rc);
     45    LIBCLOG_ENTER("pSigSet=%p\n", (void*)pSigSet);
     46
     47    /*
     48     * Empty signal set.
     49     */
     50    __SIGSET_EMPTY(pSigSet);
     51    LIBCLOG_RETURN_INT(0);
    1352}
  • trunk/src/emx/src/lib/process/sigfills.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1613 r1614  
    1 /* sigfills.c (emx+gcc) -- Copyright (c) 1994-1995 by Eberhard Mattes */
     1/* $Id: $ *//* sigfills.c (emx+gcc) -- Copyright (c) 1994-1995 by Eberhard Mattes */
     2/** @file
     3 *
     4 * LIBC - sigfillset().
     5 *
     6 * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
     7 *
     8 *
     9 * This file is part of InnoTek LIBC.
     10 *
     11 * InnoTek LIBC is free software; you can redistribute it and/or modify
     12 * it under the terms of the GNU Lesser General Public License as published
     13 * by the Free Software Foundation; either version 2 of the License, or
     14 * (at your option) any later version.
     15 *
     16 * InnoTek LIBC is distributed in the hope that it will be useful,
     17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     19 * GNU Lesser General Public License for more details.
     20 *
     21 * You should have received a copy of the GNU Lesser General Public License
     22 * along with InnoTek LIBC; if not, write to the Free Software
     23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     24 *
     25 */
    226
     27
     28/*******************************************************************************
     29*   Header Files                                                               *
     30*******************************************************************************/
    331#include "libc-alias.h"
    432#include <signal.h>
     
    634#include <InnoTekLIBC/logstrict.h>
    735
    8 int _STD(sigfillset)(sigset_t *set)
     36
     37/**
     38 * Fills (i.e. add all possible signals) to a signal set.
     39 *
     40 * @returns 0 indicating success.
     41 * @param   pSigSet     Pointer to signal set.
     42 */
     43int _STD(sigfillset)(sigset_t *pSigSet)
    944{
    10     LIBCLOG_ENTER("set=%p\n", set);
    11     int rc = __sigfillset(set);
    12     LIBCLOG_RETURN_INT(rc);
     45    LIBCLOG_ENTER("pSigSet=%p\n", (void*)pSigSet);
     46
     47    /*
     48     * Fill set.
     49     */
     50    __SIGSET_FILL(pSigSet);
     51    LIBCLOG_RETURN_INT(0);
    1352}
  • trunk/src/emx/src/lib/process/thread_internals.c

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r1613 r1614  
    9494         * Gain exclusive access to the signal stuff.
    9595         */
    96 #ifdef __NEW_SIGNALS__
    9796        int rc = __libc_back_signalSemRequest();
    98 #endif
    9997
    10098        /*
     
    111109         * Release semaphore.
    112110         */
    113 #ifdef __NEW_SIGNALS__
    114111        if (!rc)
    115112            __libc_back_signalSemRelease();
    116 #endif
    117113    }
    118114    else
  • trunk/src/emx/src/lib/sys/__init.c

    • Property cvs2svn:cvs-rev changed from 1.15 to 1.16
    r1613 r1614  
    1616#include "libc-alias.h"
    1717#define INCL_DOS
     18#define INCL_DOSSIGNALS
    1819#define INCL_FSMACROS
    1920#include <os2emx.h>
     
    2728#include <InnoTekLIBC/thread.h>
    2829#include <InnoTekLIBC/sharedpm.h>
     30#include <InnoTekLIBC/backend.h>
     31#include <InnoTekLIBC/signals.h>
    2932#define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_INITTERM
    3033#include <InnoTekLIBC/logstrict.h>
     
    173176        /** somewhere after this comes the string. */
    174177    } * pStackFrame;
    175     ULONG     rc;
     178    int       rc;
    176179    PTIB      ptib;
    177180    PPIB      ppib;
     
    224227     * Install exception handler.
    225228     */
    226     _sys_xreg = &pStackFrame->ExcpRegReg;
    227     _sys_xreg->prev_structure = (void *)0xffffffff;
    228     _sys_xreg->ExceptionHandler = _sys_exception;
    229     rc = DosSetExceptionHandler(_sys_xreg);
     229    pStackFrame->ExcpRegReg.prev_structure   = END_OF_CHAIN;
     230    pStackFrame->ExcpRegReg.ExceptionHandler = __libc_Back_exceptionHandler;
     231    rc = DosSetExceptionHandler(&pStackFrame->ExcpRegReg);
    230232    if (rc != 0)
    231233        goto failure;
     
    234236    DosSetSignalExceptionFocus(SIG_SETFOCUS, &times);
    235237
     238    /*
     239     * Install 16-bit signal handler.
     240     */
     241    rc = DosSetSigHandler((PFNSIGHANDLER)__libc_back_signalOS2V1Handler16bit, NULL, NULL, SIGA_ACCEPT, SIG_PFLG_C);
     242    if (rc)
     243    {
     244        LIBC_ASSERTM_FAILED("DosSetSigHandler failed with rc=%d\n", rc);
     245        goto failure;
     246    }
     247
     248
    236249    /* Return to the program. */
    237250    _sys_init_ret(pStackFrame);
    238251
    239     failure:
     252failure:
    240253    DosExit(EXIT_PROCESS, 255);
    241254}
    242255
    243 
    244 char const _sys_sig_valid[NSIG] =
    245 {
    246     0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1
    247 };
    248 
    249 struct sig_descr const sig_info[NSIG] =
    250 {
    251     {"SIG0",     ST_TERM,   ST_TERM},
    252     {"SIGHUP",   ST_TERM,   ST_IGNORE},
    253     {"SIGINT",   ST_TERM,   ST_IGNORE},
    254     {"SIGQUIT",  ST_TERM,   ST_IGNORE},
    255     {"SIGILL",   ST_NEXT,   ST_NEXT},
    256     {"SIGTRAP",  ST_NEXT,   ST_NEXT},
    257     {"SIGABRT",  ST_TERM,   ST_TERM},
    258     {"SIGEMT",   ST_TERM,   ST_TERM},
    259     {"SIGFPE",   ST_NEXT,   ST_NEXT},
    260     {"SIGKILL",  ST_TERM,   ST_TERM},
    261     {"SIGBUS",   ST_TERM,   ST_TERM},
    262     {"SIGSEGV",  ST_NEXT,   ST_NEXT},
    263     {"SIGSYS",   ST_TERM,   ST_TERM},
    264     {"SIGPIPE",  ST_TERM,   ST_IGNORE},
    265     {"SIGALRM",  ST_TERM,   ST_IGNORE},
    266     {"SIGTERM",  ST_NEXT,   ST_IGNORE},
    267     {"SIGUSR1",  ST_IGNORE, ST_IGNORE},
    268     {"SIGUSR2",  ST_IGNORE, ST_IGNORE},
    269     {"SIGCLD",   ST_IGNORE, ST_IGNORE},
    270     {"SIG19",    ST_TERM,   ST_TERM},
    271     {"SIG20",    ST_TERM,   ST_TERM},
    272     {"SIGBREAK", ST_TERM,   ST_IGNORE}
    273 };
    274 
    275 
    276 static void say(const char *msg)
    277 {
    278     __write(2, msg, strlen (msg));
    279 }
    280 
    281 
    282 static void _sys_terminate(int signo)
    283 {
    284     PPIB    pPib;
    285     PTIB    pTib;
    286     FS_VAR();
    287     DosGetInfoBlocks(&pTib, &pPib);
    288     say("\r\n");
    289     say(pPib->pib_pchcmd);
    290     say(":");
    291 
    292     if (signo == SIGABRT)
    293         say("\r\nAbnormal program termination\r\n");
    294     else
    295     {
    296         say("\r\nProcess terminated by ");
    297         say(sig_info[signo].name);
    298         say("\r\n");
    299     }
    300     FS_SAVE_LOAD();
    301     while (1)
    302         DosExit(EXIT_PROCESS, 3);
    303 }
    304 
    305 
    306 static void _sys_signal_acknowledge(int signo)
    307 {
    308     FS_VAR();
    309     FS_SAVE_LOAD();
    310     switch (signo)
    311     {
    312         case SIGINT:
    313             DosAcknowledgeSignalException(XCPT_SIGNAL_INTR);
    314             break;
    315         case SIGTERM:
    316             DosAcknowledgeSignalException(XCPT_SIGNAL_KILLPROC);
    317             break;
    318         case SIGBREAK:
    319             DosAcknowledgeSignalException(XCPT_SIGNAL_BREAK);
    320             break;
    321     }
    322     FS_RESTORE();
    323 }
    324 
    325 
    326 /* Called from OS/2 exception handler for signal exceptions. */
    327 
    328 static ULONG _sys_signal(int signo)
    329 {
    330     __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto();
    331     if (pThrd == NULL)
    332         return XCPT_CONTINUE_SEARCH;
    333     __sigaddset (&pThrd->b.sys.sig_pending, signo);
    334     _sys_signal_acknowledge(signo);
    335     _sys_deliver_pending_signals(pThrd);
    336     switch (sig_info[signo].fun_action)
    337     {
    338         case ST_TERM:
    339             _sys_terminate(signo);
    340         case ST_NEXT:
    341             return XCPT_CONTINUE_SEARCH;
    342         case ST_IGNORE:
    343             return XCPT_CONTINUE_EXECUTION;
    344     }
    345     return XCPT_CONTINUE_SEARCH;  /* Keep the optimizer happy */
    346 }
    347 
    348 
    349 /* Called from OS/2 exception handler for traps. */
    350 
    351 static ULONG _sys_trap(int signo)
    352 {
    353     __LIBC_PTHREAD  pThrd;
    354     void          (*handler)(int signo);
    355 
    356     pThrd = __libc_threadCurrentNoAuto();
    357     if (pThrd == NULL)
    358         return XCPT_CONTINUE_SEARCH;
    359     handler = pThrd->b.sys.signals[signo].sa_handler;
    360     if (handler != SIG_IGN && handler != SIG_DFL)
    361         handler(signo);
    362     switch (sig_info[signo].fun_action)
    363     {
    364         case ST_TERM:
    365             _sys_terminate(signo);
    366         case ST_NEXT:
    367             return XCPT_CONTINUE_SEARCH;
    368         case ST_IGNORE:
    369             return XCPT_CONTINUE_EXECUTION;
    370     }
    371     return XCPT_CONTINUE_SEARCH;  /* Keep the optimizer happy */
    372 }
    373 
    374 
    375 static void _sys_deliver_signal(__LIBC_PTHREAD pThrd, int signo)
    376 {
    377     struct sigaction *p;
    378     void (*handler)(int signo);
    379     sigset_t mask, old_blocked;
    380 
    381     /* TODO: Critical section */
    382 
    383     mask = _SIGMASK(signo);
    384     p = &pThrd->b.sys.signals[signo];
    385 
    386     pThrd->b.sys.sig_pending &= ~mask;
    387     handler = p->sa_handler;
    388 
    389     if (handler == SIG_IGN)
    390     {
    391         /* Ignore the signal. */
    392     }
    393     else if (handler == SIG_DFL)
    394     {
    395         if (sig_info[signo].dfl_action != ST_IGNORE)
    396             _sys_terminate(signo);
    397     }
    398     else
    399     {
    400         if (p->sa_flags & SA_SYSV)
    401         {
    402             p->sa_handler = SIG_DFL;
    403             handler(signo);
    404         }
    405         else if (p->sa_flags & SA_ACK)
    406         {
    407             pThrd->b.sys.sig_blocked |= mask;
    408             handler(signo);
    409         }
    410         else
    411         {
    412             old_blocked = pThrd->b.sys.sig_blocked;
    413             SET_BLOCKED(&pThrd->b.sys, pThrd->b.sys.sig_blocked | mask | p->sa_mask);
    414             handler(signo);
    415             pThrd->b.sys.sig_blocked = old_blocked;
    416         }
    417     }
    418 }
    419 
    420 
    421 void _sys_deliver_pending_signals(__LIBC_PTHREAD pThrd)
    422 {
    423     int signo;
    424 
    425     /* TODO: Critical section */
    426     while ((pThrd->b.sys.sig_pending & ~pThrd->b.sys.sig_blocked) != 0)
    427     {
    428         for (signo = 1; signo < NSIG; ++signo)
    429             if (pThrd->b.sys.sig_pending & ~pThrd->b.sys.sig_blocked & _SIGMASK(signo))
    430                 _sys_deliver_signal(pThrd, signo);
    431     }
    432 }
    433 
    434 /* from kLib/kHeapDbg.h */
    435 typedef enum
    436 {
    437     enmRead, enmWrite, enmUnknown
    438 } ENMACCESS;
    439 extern BOOL _Optlink kHeapDbgException(void *    pvAccess,
    440                                        ENMACCESS enmAccess,
    441                                        void *    pvIP,
    442                                        void *    pvOS);
    443 /* Weak on _Optlink and _System doesn't work because of underscoring. */
    444 asm (".weak kHeapDbgException");
    445 
    446 ULONG _System _sys_exception(PEXCEPTIONREPORTRECORD report,
    447                              PEXCEPTIONREGISTRATIONRECORD registration,
    448                              PCONTEXTRECORD context,
    449                              PVOID whatever)
    450 {
    451     __asm__ ("cld");              /* Don't trust */
    452     LIBCLOG_MSG2("!!! num %08lx flags %08lx nested %p whatever %p\n",
    453                  report->ExceptionNum, report->fHandlerFlags, (void *)report->NestedExceptionReportRecord, whatever);
    454     if (report->fHandlerFlags & (EH_UNWINDING | EH_EXIT_UNWIND))
    455         return XCPT_CONTINUE_SEARCH;
    456     switch (report->ExceptionNum)
    457     {
    458         case XCPT_SIGNAL:
    459             if (report->cParameters >= 1)
    460             {
    461                 if (report->ExceptionInfo[0] == XCPT_SIGNAL_INTR)
    462                     return _sys_signal(SIGINT);
    463                 else if (report->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC)
    464                     return _sys_signal(SIGTERM);
    465                 else if (report->ExceptionInfo[0] == XCPT_SIGNAL_BREAK)
    466                     return _sys_signal(SIGBREAK);
    467             }
    468             break;
    469         case XCPT_ACCESS_VIOLATION:
    470             /* If we're linking libc01.elh or someone is linking static libc
    471                together with kLib the electric fence heap will get the opportunity
    472                to check if any access violation was caused by someone touching any
    473                of the electric fences. */
    474             if (    kHeapDbgException
    475                 &&  (   report->ExceptionInfo[0] == XCPT_READ_ACCESS
    476                         || report->ExceptionInfo[0] == XCPT_WRITE_ACCESS
    477                         || report->ExceptionInfo[0] == XCPT_EXECUTE_ACCESS
    478                         || report->ExceptionInfo[0] == XCPT_UNKNOWN_ACCESS)
    479                )
    480             {
    481                 ENMACCESS enmAccess = enmRead;
    482                 switch (report->ExceptionInfo[0])
    483                 {
    484                     case XCPT_WRITE_ACCESS:     enmAccess = enmWrite; break;
    485                     case XCPT_UNKNOWN_ACCESS:   enmAccess = enmUnknown; break;
    486                 }
    487                 /* This call returns true if the page was commited in order
    488                    to workaround the immediate problem. If it returns false
    489                    the default action should be taken. */
    490                 if (kHeapDbgException((void*)report->ExceptionInfo[1],
    491                                       enmAccess,
    492                                       report->ExceptionAddress,
    493                                       report))
    494                     return XCPT_CONTINUE_EXECUTION;
    495             }
    496         case XCPT_DATATYPE_MISALIGNMENT:
    497             return _sys_trap(SIGSEGV);
    498 
    499         case XCPT_INTEGER_DIVIDE_BY_ZERO:
    500         case XCPT_INTEGER_OVERFLOW:
    501         case XCPT_ARRAY_BOUNDS_EXCEEDED:
    502         case XCPT_FLOAT_DENORMAL_OPERAND:
    503         case XCPT_FLOAT_DIVIDE_BY_ZERO:
    504         case XCPT_FLOAT_INEXACT_RESULT:
    505         case XCPT_FLOAT_INVALID_OPERATION:
    506         case XCPT_FLOAT_OVERFLOW:
    507         case XCPT_FLOAT_STACK_CHECK:
    508         case XCPT_FLOAT_UNDERFLOW:
    509             return _sys_trap(SIGFPE);
    510 
    511         case XCPT_ILLEGAL_INSTRUCTION:
    512         case XCPT_INVALID_LOCK_SEQUENCE:
    513         case XCPT_PRIVILEGED_INSTRUCTION:
    514             return _sys_trap(SIGILL);
    515     }
    516     return XCPT_CONTINUE_SEARCH;
    517 }
    518 
    519 
  • trunk/src/emx/src/lib/sys/__initdll.c

    • Property cvs2svn:cvs-rev changed from 1.16 to 1.17
    r1613 r1614  
    3737#include <InnoTekLIBC/thread.h>
    3838#include <InnoTekLIBC/libc.h>
     39#include <InnoTekLIBC/signals.h>
    3940#define __LIBC_LOG_GROUP    __LIBC_LOG_GRP_INITTERM
    4041#include <InnoTekLIBC/logstrict.h>
     
    196197    if (rc)
    197198    {
    198         LIBC_ASSERTM_FAILED("__libc_fhInit(%p) failed\n", pSelf->pInherit ? (void *)pSelf->pInherit->pFHBundles : NULL);
     199        LIBC_ASSERTM_FAILED("__libc_fhInit() failed\n");
     200        return -1;
     201    }
     202
     203    /*
     204     * Init signals
     205     */
     206    rc = __libc_back_signalInit();
     207    if (rc)
     208    {
     209        LIBC_ASSERTM_FAILED("__libc_back_signalInit() failed\n");
    199210        return -1;
    200211    }
  • trunk/src/emx/src/lib/sys/b_threadInit.c

    • Property cvs2svn:cvs-rev changed from 1.3 to 1.4
    r1613 r1614  
    3939void __libc_Back_threadInit(__LIBC_PTHREAD pThrd, const __LIBC_PTHREAD pParentThrd)
    4040{
    41     unsigned        i;
    42 
    43     __sigemptyset(&pThrd->b.sys.sig_blocked);
    44     __sigemptyset(&pThrd->b.sys.sig_pending);
    45     for (i = 0; i < NSIG; ++i)
    46     {
    47         pThrd->b.sys.signals[i].sa_handler = SIG_DFL;
    48         pThrd->b.sys.signals[i].sa_flags   = SA_ACK;
    49         __sigemptyset(&pThrd->b.sys.signals[i].sa_mask);
    50     }
    5141    pThrd->b.sys.fd.hdir = HDIR_CREATE;
    5242    pThrd->b.sys.fd.cFiles = 0;
  • trunk/src/emx/src/lib/sys/b_threadStartup.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1613 r1614  
    1 /* $Id$ *//* sys/initthre.c (emx+gcc) -- Copyright (c) 1993-1996 by Eberhard Mattes */
     1/* $Id$ */
    22/** @file
    33 *
     
    3030*******************************************************************************/
    3131#include "libc-alias.h"
    32 #include <errno.h>
    3332#define INCL_DOS
    3433#define INCL_FSMACROS
    3534#include <os2emx.h>
    36 #include "syscalls.h"
    3735#include <InnoTekLIBC/backend.h>
     36
    3837
    3938void __libc_Back_threadStartup(void *pExpRegRec)
    4039{
    4140    FS_VAR();
    42     ((PEXCEPTIONREGISTRATIONRECORD)pExpRegRec)->ExceptionHandler = _sys_exception;
    43     ((PEXCEPTIONREGISTRATIONRECORD)pExpRegRec)->prev_structure   = NULL;
     41    ((PEXCEPTIONREGISTRATIONRECORD)pExpRegRec)->ExceptionHandler = __libc_Back_exceptionHandler;
     42    ((PEXCEPTIONREGISTRATIONRECORD)pExpRegRec)->prev_structure   = END_OF_CHAIN;
    4443    FS_SAVE_LOAD();
    4544    DosSetExceptionHandler(pExpRegRec);
  • trunk/src/emx/src/lib/sys/syscalls.h

    • Property cvs2svn:cvs-rev changed from 1.14 to 1.15
    r1613 r1614  
    66#include "libc-alias.h"
    77#include <sys/signal.h>
     8#include <sys/types.h>
    89#include <InnoTekLIBC/sharedpm.h>
    910
     
    9192#define FDATEZEROP(x) (*(PUSHORT)&(x) == 0)
    9293
    93 #if defined (INCL_DOSEXCEPTIONS)
    94 EXTERN PEXCEPTIONREGISTRATIONRECORD _sys_xreg INIT (NULL);
    95 ULONG _System _sys_exception (PEXCEPTIONREPORTRECORD report,
    96     PEXCEPTIONREGISTRATIONRECORD registration, PCONTEXTRECORD context,
    97     PVOID whatever);
    98 #endif /* defined (INCL_DOSEXCEPTIONS) */
    99 
    100 /* TODO: SIGSTOP */
    101 #define SET_BLOCKED(tp,set) ((tp)->sig_blocked = (set) & ~_SIGMASK (SIGKILL))
    102 
    103 enum sig_type
    104 {
    105   ST_TERM,                      /* Terminate process (SIGINT for instance) */
    106   ST_NEXT,                      /* Pass on to next exception handler */
    107   ST_IGNORE                     /* Ignore exception and continue thread */
    108 };
    109 
    110 struct sig_descr
    111 {
    112   const char *name;             /* Name of the signal */
    113   enum sig_type dfl_action;     /* Default action */
    114   enum sig_type fun_action;     /* Action taken after calling handler */
    115 };
    116 
    117 extern char const _sys_sig_valid[NSIG];
    118 extern struct sig_descr const sig_info[NSIG];
    119 
    12094long _sys_p2t(FTIME t, FDATE d);
    121 void _sys_deliver_pending_signals(__LIBC_PTHREAD pThrd);
    12295
    12396#endif /* _OS2EMX_H */
     
    162135/** @} */
    163136
    164 
    165137/** @group Error code and errno Functions.
    166138 * @{ */
  • trunk/src/emx/version.smak

    • Property cvs2svn:cvs-rev changed from 1.16 to 1.17
    r1613 r1614  
    44VH = 0
    55# Middle part of version number
    6 VM = 6a3
     6VM = 6s3
    77# Low part of version number
    88VL = 0
Note: See TracChangeset for help on using the changeset viewer.