2002-06-05 Jeff Johnston <jjohnstn@redhat.com>

* libc/include/string.h[__linux__]: Add strsignal prototype.
        * libc/include/sys/lock.h: New file with default locking support.
        * libc/include/sys/reent.h: Add signal buffer support for strsignal
        and psignal.
        * libc/posix/Makefile.am: Add support for readdir_r.c.
        * libc/posix/Makefile.in: Regenerated.
        * libc/posix/closedir.c: Add locking support and hash table cleanup.
        * libc/posix/opendir.c: Add lock support.
        * libc/posix/readdir.c: Ditto.
        * libc/posix/rewinddir.c: Ditto.
        * libc/posix/scandir.c: Ditto.
        * libc/posix/seekdir.c: Ditto.
        * libc/posix/telldir.c: Ditto plus add _cleanupdir routine to
        clean up leftover hash table entries.
        * libc/posix/readdir_r.c: New file.
        * libc/sys/linux/Makefile.am: Add psignal.c and strsignal.c support.
        * libc/sys/linux/Makefile.in: Regenerated.
        * libc/sys/linux/sys/dirent.h: Add dd_lock to DIR structure.
        * libc/sys/linux/sys/signal.h: Add psignal prototype.
        * libc/sys/linux/psignal.c: New file.
        * libc/sys/linux/strsignal.c: Ditto.
This commit is contained in:
Jeff Johnston 2002-06-05 20:58:59 +00:00
parent ea4e6ec8f9
commit 39e65e0113
20 changed files with 539 additions and 58 deletions

View File

@ -1,3 +1,27 @@
2002-06-05 Jeff Johnston <jjohnstn@redhat.com>
* libc/include/string.h[__linux__]: Add strsignal prototype.
* libc/include/sys/lock.h: New file with default locking support.
* libc/include/sys/reent.h: Add signal buffer support for strsignal
and psignal.
* libc/posix/Makefile.am: Add support for readdir_r.c.
* libc/posix/Makefile.in: Regenerated.
* libc/posix/closedir.c: Add locking support and hash table cleanup.
* libc/posix/opendir.c: Add lock support.
* libc/posix/readdir.c: Ditto.
* libc/posix/rewinddir.c: Ditto.
* libc/posix/scandir.c: Ditto.
* libc/posix/seekdir.c: Ditto.
* libc/posix/telldir.c: Ditto plus add _cleanupdir routine to
clean up leftover hash table entries.
* libc/posix/readdir_r.c: New file.
* libc/sys/linux/Makefile.am: Add psignal.c and strsignal.c support.
* libc/sys/linux/Makefile.in: Regenerated.
* libc/sys/linux/sys/dirent.h: Add dd_lock to DIR structure.
* libc/sys/linux/sys/signal.h: Add psignal prototype.
* libc/sys/linux/psignal.c: New file.
* libc/sys/linux/strsignal.c: Ditto.
2002-06-03 Corinna Vinschen <corinna@vinschen.de> 2002-06-03 Corinna Vinschen <corinna@vinschen.de>
* libc/include/sys/types.h: Don't define dev_t when compiling for * libc/include/sys/types.h: Don't define dev_t when compiling for

View File

@ -74,6 +74,8 @@ char *_EXFUN(strupr,(char *));
const char *_EXFUN(strsignal, (int __signo)); const char *_EXFUN(strsignal, (int __signo));
#endif #endif
int _EXFUN(strtosigno, (const char *__name)); int _EXFUN(strtosigno, (const char *__name));
#elif defined(__linux__)
char *_EXFUN(strsignal, (int __signo));
#endif #endif
/* These function names are used on Windows and perhaps other systems. */ /* These function names are used on Windows and perhaps other systems. */

View File

@ -0,0 +1,20 @@
#ifndef __SYS_LOCK_H__
#define __SYS_LOCK_H__
/* dummy lock routines for single-threaded aps */
typedef int _LOCK_T;
typedef int _LOCK_RECURSIVE_T;
#define __LOCK_INIT(class,lock) static int lock = 0;
#define __LOCK_INIT_RECURSIVE(class,lock) static int lock = 0;
#define __lock_init(lock) {}
#define __lock_init_recursive(lock) {}
#define __lock_close(lock) {}
#define __lock_close_recursive(lock) {}
#define __lock_acquire(lock) {}
#define __lock_acquire_recursive(lock) {}
#define __lock_release(lock) {}
#define __lock_release_recursive(lock) {}
#endif /* __SYS_LOCK_H__ */

View File

@ -229,6 +229,7 @@ struct _rand48 {
/* How big the some arrays are. */ /* How big the some arrays are. */
#define _REENT_EMERGENCY_SIZE 25 #define _REENT_EMERGENCY_SIZE 25
#define _REENT_ASCTIME_SIZE 26 #define _REENT_ASCTIME_SIZE 26
#define _REENT_SIGNAL_SIZE 24
/* /*
* struct _reent * struct _reent
@ -305,13 +306,14 @@ struct _reent
struct __sFILE *__sf; /* file descriptors */ struct __sFILE *__sf; /* file descriptors */
struct __sFILE_fake __sf_fake; /* fake initial stdin/out/err */ struct __sFILE_fake __sf_fake; /* fake initial stdin/out/err */
struct _misc_reent *_misc; /* strtok, multibyte states */ struct _misc_reent *_misc; /* strtok, multibyte states */
char *_signal_buf; /* strsignal */
}; };
#define _REENT_INIT(var) \ #define _REENT_INIT(var) \
{ (struct __sFILE *)&var.__sf_fake, (struct __sFILE *)&var.__sf_fake, \ { (struct __sFILE *)&var.__sf_fake, (struct __sFILE *)&var.__sf_fake, \
(struct __sFILE *)&var.__sf_fake, 0, 0, _NULL, 0, 0, \ (struct __sFILE *)&var.__sf_fake, 0, 0, _NULL, 0, 0, \
"C", _NULL, _NULL, 0, 0, _NULL, _NULL, _NULL, _NULL, _NULL, \ "C", _NULL, _NULL, 0, 0, _NULL, _NULL, _NULL, _NULL, _NULL, \
{ 0, _NULL, _NULL, 0 }, { _NULL, 0, _NULL }, _NULL, 0, _NULL } { 0, _NULL, _NULL, 0 }, { _NULL, 0, _NULL }, _NULL, 0, _NULL, _NULL }
#define _REENT_INIT_PTR(var) \ #define _REENT_INIT_PTR(var) \
{ var->_stdin = (struct __sFILE *)&var->__sf_fake; \ { var->_stdin = (struct __sFILE *)&var->__sf_fake; \
@ -341,6 +343,7 @@ struct _reent
var->__sglue._iobs = _NULL; \ var->__sglue._iobs = _NULL; \
var->__sf = 0; \ var->__sf = 0; \
var->_misc = _NULL; \ var->_misc = _NULL; \
var->_signal_buf = _NULL; \
var->__sf_fake._p = _NULL; \ var->__sf_fake._p = _NULL; \
var->__sf_fake._r = 0; \ var->__sf_fake._r = 0; \
var->__sf_fake._w = 0; \ var->__sf_fake._w = 0; \
@ -414,6 +417,9 @@ struct _reent
#define _REENT_CHECK_MISC(var) \ #define _REENT_CHECK_MISC(var) \
_REENT_CHECK(var, _misc, struct _misc_reent *, sizeof *((var)->_misc), _REENT_INIT_MISC(var)) _REENT_CHECK(var, _misc, struct _misc_reent *, sizeof *((var)->_misc), _REENT_INIT_MISC(var))
#define _REENT_CHECK_SIGNAL_BUF(var) \
_REENT_CHECK(var, _signal_buf, char *, _REENT_SIGNAL_SIZE, /* nothing */)
#define _REENT_SIGNGAM(ptr) ((ptr)->_gamma_signgam) #define _REENT_SIGNGAM(ptr) ((ptr)->_gamma_signgam)
#define _REENT_RAND_NEXT(ptr) ((ptr)->_r48->_rand_next) #define _REENT_RAND_NEXT(ptr) ((ptr)->_r48->_rand_next)
#define _REENT_RAND48_SEED(ptr) ((ptr)->_r48->_seed) #define _REENT_RAND48_SEED(ptr) ((ptr)->_r48->_seed)
@ -431,6 +437,7 @@ struct _reent
#define _REENT_MBTOWC_STATE(ptr)((ptr)->_misc->_mbtowc_state) #define _REENT_MBTOWC_STATE(ptr)((ptr)->_misc->_mbtowc_state)
#define _REENT_WCTOMB_STATE(ptr)((ptr)->_misc->_wctomb_state) #define _REENT_WCTOMB_STATE(ptr)((ptr)->_misc->_wctomb_state)
#define _REENT_L64A_BUF(ptr) ((ptr)->_misc->_l64a_buf) #define _REENT_L64A_BUF(ptr) ((ptr)->_misc->_l64a_buf)
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_signal_buf)
#else /* !_REENT_SMALL */ #else /* !_REENT_SMALL */
@ -469,7 +476,7 @@ struct _reent
{ {
unsigned int _unused_rand; unsigned int _unused_rand;
char * _strtok_last; char * _strtok_last;
char _asctime_buf[26]; char _asctime_buf[_REENT_ASCTIME_SIZE];
struct __tm _localtime_buf; struct __tm _localtime_buf;
int _gamma_signgam; int _gamma_signgam;
__extension__ unsigned long long _rand_next; __extension__ unsigned long long _rand_next;
@ -478,6 +485,7 @@ struct _reent
int _mbtowc_state; int _mbtowc_state;
int _wctomb_state; int _wctomb_state;
char _l64a_buf[8]; char _l64a_buf[8];
char _signal_buf[_REENT_SIGNAL_SIZE];
} _reent; } _reent;
/* Two next two fields were once used by malloc. They are no longer /* Two next two fields were once used by malloc. They are no longer
used. They are used to preserve the space used before so as to used. They are used to preserve the space used before so as to
@ -551,6 +559,7 @@ struct _reent
var->_new._reent._mbtowc_state = 0; \ var->_new._reent._mbtowc_state = 0; \
var->_new._reent._wctomb_state = 0; \ var->_new._reent._wctomb_state = 0; \
var->_new._reent._l64a_buf[0] = '\0'; \ var->_new._reent._l64a_buf[0] = '\0'; \
var->_new._reent._signal_buf[0] = '\0'; \
var->_atexit = _NULL; \ var->_atexit = _NULL; \
var->_atexit0._ind = 0; \ var->_atexit0._ind = 0; \
var->_atexit0._fns[0] = _NULL; \ var->_atexit0._fns[0] = _NULL; \
@ -568,6 +577,7 @@ struct _reent
#define _REENT_CHECK_ASCTIME_BUF(ptr) /* nothing */ #define _REENT_CHECK_ASCTIME_BUF(ptr) /* nothing */
#define _REENT_CHECK_EMERGENCY(ptr) /* nothing */ #define _REENT_CHECK_EMERGENCY(ptr) /* nothing */
#define _REENT_CHECK_MISC(ptr) /* nothing */ #define _REENT_CHECK_MISC(ptr) /* nothing */
#define _REENT_CHECK_SIGNAL_BUF(ptr) /* nothing */
#define _REENT_SIGNGAM(ptr) ((ptr)->_new._reent._gamma_signgam) #define _REENT_SIGNGAM(ptr) ((ptr)->_new._reent._gamma_signgam)
#define _REENT_RAND_NEXT(ptr) ((ptr)->_new._reent._rand_next) #define _REENT_RAND_NEXT(ptr) ((ptr)->_new._reent._rand_next)
@ -586,6 +596,7 @@ struct _reent
#define _REENT_MBTOWC_STATE(ptr)((ptr)->_new._reent._mbtowc_state) #define _REENT_MBTOWC_STATE(ptr)((ptr)->_new._reent._mbtowc_state)
#define _REENT_WCTOMB_STATE(ptr)((ptr)->_new._reent._wctomb_state) #define _REENT_WCTOMB_STATE(ptr)((ptr)->_new._reent._wctomb_state)
#define _REENT_L64A_BUF(ptr) ((ptr)->_new._reent._l64a_buf) #define _REENT_L64A_BUF(ptr) ((ptr)->_new._reent._l64a_buf)
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_new._reent._signal_buf)
#endif /* !_REENT_SMALL */ #endif /* !_REENT_SMALL */

View File

@ -7,7 +7,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
LIB_SOURCES = \ LIB_SOURCES = \
closedir.c opendir.c readdir.c rewinddir.c scandir.c seekdir.c \ closedir.c opendir.c readdir.c rewinddir.c scandir.c seekdir.c \
telldir.c execl.c execle.c execlp.c execv.c execve.c execvp.c \ telldir.c execl.c execle.c execlp.c execv.c execve.c execvp.c \
popen.c creat.c isatty.c popen.c creat.c isatty.c readdir_r.c
libposix_la_LDFLAGS = -Xcompiler -nostdlib libposix_la_LDFLAGS = -Xcompiler -nostdlib

View File

@ -105,7 +105,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
LIB_SOURCES = \ LIB_SOURCES = \
closedir.c opendir.c readdir.c rewinddir.c scandir.c seekdir.c \ closedir.c opendir.c readdir.c rewinddir.c scandir.c seekdir.c \
telldir.c execl.c execle.c execlp.c execv.c execve.c execvp.c \ telldir.c execl.c execle.c execlp.c execv.c execve.c execvp.c \
popen.c creat.c isatty.c popen.c creat.c isatty.c readdir_r.c
libposix_la_LDFLAGS = -Xcompiler -nostdlib libposix_la_LDFLAGS = -Xcompiler -nostdlib
@ -138,14 +138,15 @@ lib_a_LIBADD =
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = closedir.o opendir.o readdir.o \ @USE_LIBTOOL_FALSE@lib_a_OBJECTS = closedir.o opendir.o readdir.o \
@USE_LIBTOOL_FALSE@rewinddir.o scandir.o seekdir.o telldir.o execl.o \ @USE_LIBTOOL_FALSE@rewinddir.o scandir.o seekdir.o telldir.o execl.o \
@USE_LIBTOOL_FALSE@execle.o execlp.o execv.o execve.o execvp.o popen.o \ @USE_LIBTOOL_FALSE@execle.o execlp.o execv.o execve.o execvp.o popen.o \
@USE_LIBTOOL_FALSE@creat.o isatty.o @USE_LIBTOOL_FALSE@creat.o isatty.o readdir_r.o
LTLIBRARIES = $(noinst_LTLIBRARIES) LTLIBRARIES = $(noinst_LTLIBRARIES)
libposix_la_LIBADD = libposix_la_LIBADD =
@USE_LIBTOOL_TRUE@libposix_la_OBJECTS = closedir.lo opendir.lo \ @USE_LIBTOOL_TRUE@libposix_la_OBJECTS = closedir.lo opendir.lo \
@USE_LIBTOOL_TRUE@readdir.lo rewinddir.lo scandir.lo seekdir.lo \ @USE_LIBTOOL_TRUE@readdir.lo rewinddir.lo scandir.lo seekdir.lo \
@USE_LIBTOOL_TRUE@telldir.lo execl.lo execle.lo execlp.lo execv.lo \ @USE_LIBTOOL_TRUE@telldir.lo execl.lo execle.lo execlp.lo execv.lo \
@USE_LIBTOOL_TRUE@execve.lo execvp.lo popen.lo creat.lo isatty.lo @USE_LIBTOOL_TRUE@execve.lo execvp.lo popen.lo creat.lo isatty.lo \
@USE_LIBTOOL_TRUE@readdir_r.lo
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

View File

@ -41,6 +41,9 @@ static char sccsid[] = "@(#)closedir.c 5.9 (Berkeley) 2/23/91";
#include <dirent.h> #include <dirent.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/lock.h>
extern void _cleanupdir (DIR *dirp);
/* /*
* close a directory. * close a directory.
@ -49,14 +52,26 @@ int
closedir(dirp) closedir(dirp)
register DIR *dirp; register DIR *dirp;
{ {
int fd; int fd, rc;
#ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
#endif
rc = 0;
fd = dirp->dd_fd; fd = dirp->dd_fd;
dirp->dd_fd = -1; if (fd != -1) {
dirp->dd_loc = 0; dirp->dd_fd = -1;
(void)free((void *)dirp->dd_buf); dirp->dd_loc = 0;
(void)free((void *)dirp); (void)free((void *)dirp->dd_buf);
return(close(fd)); (void)free((void *)dirp);
rc = close(fd);
_cleanupdir(dirp);
}
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
__lock_close_recursive(dirp->dd_lock);
#endif
return rc;
} }
#endif /* ! HAVE_OPENDIR */ #endif /* ! HAVE_OPENDIR */

View File

@ -41,6 +41,7 @@ static char sccsid[] = "@(#)opendir.c 5.11 (Berkeley) 2/23/91";
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/lock.h>
/* /*
* open a directory. * open a directory.
@ -78,6 +79,12 @@ opendir(name)
/* /*
* Set up seek point for rewinddir. * Set up seek point for rewinddir.
*/ */
#ifdef HAVE_DD_LOCK
/* if we have a locking mechanism, initialize it */
__lock_init_recursive(dirp->dd_lock);
#endif
return dirp; return dirp;
} }

View File

@ -39,6 +39,8 @@ static char sccsid[] = "@(#)readdir.c 5.7 (Berkeley) 6/1/90";
#include <dirent.h> #include <dirent.h>
extern int getdents (int fd, void *dp, int count);
/* /*
* get next entry in a directory. * get next entry in a directory.
*/ */
@ -47,28 +49,50 @@ readdir(dirp)
register DIR *dirp; { register DIR *dirp; {
register struct dirent *dp; register struct dirent *dp;
#ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
#endif
if (dirp->dd_fd == -1)
return NULL;
for (;;) { for (;;) {
if (dirp->dd_loc == 0) { if (dirp->dd_loc == 0) {
dirp->dd_size = getdents (dirp->dd_fd, dirp->dd_size = getdents (dirp->dd_fd,
dirp->dd_buf, dirp->dd_buf,
dirp->dd_len); dirp->dd_len);
if (dirp->dd_size <= 0) if (dirp->dd_size <= 0) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return NULL; return NULL;
}
} }
if (dirp->dd_loc >= dirp->dd_size) { if (dirp->dd_loc >= dirp->dd_size) {
dirp->dd_loc = 0; dirp->dd_loc = 0;
continue; continue;
} }
dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc); dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
if ((int)dp & 03) /* bogus pointer check */ if ((int)dp & 03) { /* bogus pointer check */
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return NULL; return NULL;
}
if (dp->d_reclen <= 0 || if (dp->d_reclen <= 0 ||
dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return NULL; return NULL;
}
dirp->dd_loc += dp->d_reclen; dirp->dd_loc += dp->d_reclen;
if (dp->d_ino == 0) if (dp->d_ino == 0)
continue; continue;
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return (dp); return (dp);
} }
} }

View File

@ -0,0 +1,108 @@
#ifndef HAVE_OPENDIR
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* this code is modified from readdir.c by Jeff Johnston, June 5, 2002 */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)readdir.c 5.7 (Berkeley) 6/1/90";
#endif /* LIBC_SCCS and not lint */
#include <dirent.h>
#include <errno.h>
#include <string.h>
extern int getdents (int fd, void *dp, int count);
/*
* get next entry in a directory using supplied dirent structure.
*/
int
readdir_r(dirp, dp, dpp)
register DIR *dirp;
struct dirent *dp;
struct dirent **dpp; {
struct dirent *tmpdp;
#ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
#endif
if (dirp->dd_fd == -1) {
*dpp = NULL;
return errno = EBADF;
}
for (;;) {
if (dirp->dd_loc == 0) {
dirp->dd_size = getdents (dirp->dd_fd,
dirp->dd_buf,
dirp->dd_len);
if (dirp->dd_size <= 0) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
*dpp = NULL;
return errno;
}
}
if (dirp->dd_loc >= dirp->dd_size) {
dirp->dd_loc = 0;
continue;
}
tmpdp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
memcpy (dp, tmpdp, sizeof(struct dirent));
if (dp->d_reclen <= 0 ||
dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
*dpp = NULL;
return -1;
}
dirp->dd_loc += dp->d_reclen;
if (dp->d_ino == 0)
continue;
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
*dpp = dp;
return 0;
}
}
#endif /* ! HAVE_OPENDIR */

View File

@ -39,12 +39,19 @@ static char sccsid[] = "@(#)rewinddir.c 5.1 (Berkeley) 5/25/90";
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
#include <sys/lock.h>
void void
rewinddir(dirp) rewinddir(dirp)
DIR *dirp; DIR *dirp;
{ {
#ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
#endif
_seekdir((dirp), (off_t)0); _seekdir((dirp), (off_t)0);
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
} }
#endif /* ! HAVE_OPENDIR */ #endif /* ! HAVE_OPENDIR */

View File

@ -49,6 +49,7 @@ static char sccsid[] = "@(#)scandir.c 5.10 (Berkeley) 2/23/91";
#include <dirent.h> #include <dirent.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/lock.h>
/* /*
* The DIRSIZ macro gives the minimum record length which will hold * The DIRSIZ macro gives the minimum record length which will hold
@ -84,8 +85,15 @@ scandir(dirname, namelist, select, dcomp)
if ((dirp = opendir(dirname)) == NULL) if ((dirp = opendir(dirname)) == NULL)
return(-1); return(-1);
if (fstat(dirp->dd_fd, &stb) < 0) #ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
#endif
if (fstat(dirp->dd_fd, &stb) < 0) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return(-1); return(-1);
}
/* /*
* estimate the array size by taking the size of the directory file * estimate the array size by taking the size of the directory file
@ -93,8 +101,12 @@ scandir(dirname, namelist, select, dcomp)
*/ */
arraysz = (stb.st_size / 24); arraysz = (stb.st_size / 24);
names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *)); names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *));
if (names == NULL) if (names == NULL) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return(-1); return(-1);
}
nitems = 0; nitems = 0;
while ((d = readdir(dirp)) != NULL) { while ((d = readdir(dirp)) != NULL) {
@ -104,8 +116,12 @@ scandir(dirname, namelist, select, dcomp)
* Make a minimum size copy of the data * Make a minimum size copy of the data
*/ */
p = (struct dirent *)malloc(DIRSIZ(d)); p = (struct dirent *)malloc(DIRSIZ(d));
if (p == NULL) if (p == NULL) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return(-1); return(-1);
}
p->d_ino = d->d_ino; p->d_ino = d->d_ino;
p->d_reclen = d->d_reclen; p->d_reclen = d->d_reclen;
#ifdef _DIRENT_HAVE_D_NAMLEN #ifdef _DIRENT_HAVE_D_NAMLEN
@ -119,13 +135,21 @@ scandir(dirname, namelist, select, dcomp)
* realloc the maximum size. * realloc the maximum size.
*/ */
if (++nitems >= arraysz) { if (++nitems >= arraysz) {
if (fstat(dirp->dd_fd, &stb) < 0) if (fstat(dirp->dd_fd, &stb) < 0) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return(-1); /* just might have grown */ return(-1); /* just might have grown */
}
arraysz = stb.st_size / 12; arraysz = stb.st_size / 12;
names = (struct dirent **)realloc((char *)names, names = (struct dirent **)realloc((char *)names,
arraysz * sizeof(struct dirent *)); arraysz * sizeof(struct dirent *));
if (names == NULL) if (names == NULL) {
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return(-1); return(-1);
}
} }
names[nitems-1] = p; names[nitems-1] = p;
} }
@ -133,6 +157,9 @@ scandir(dirname, namelist, select, dcomp)
if (nitems && dcomp != NULL) if (nitems && dcomp != NULL)
qsort(names, nitems, sizeof(struct dirent *), dcomp); qsort(names, nitems, sizeof(struct dirent *), dcomp);
*namelist = names; *namelist = names;
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
return(nitems); return(nitems);
} }

View File

@ -39,6 +39,7 @@ static char sccsid[] = "@(#)seekdir.c 5.7 (Berkeley) 6/1/90";
#include <sys/param.h> #include <sys/param.h>
#include <dirent.h> #include <dirent.h>
#include <sys/lock.h>
/* /*
* Seek to an entry in a directory. * Seek to an entry in a directory.
@ -49,8 +50,13 @@ seekdir(dirp, loc)
DIR *dirp; DIR *dirp;
long loc; long loc;
{ {
#ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
#endif
_seekdir(dirp, loc); _seekdir(dirp, loc);
#ifdef HAVE_DD_LOCK
__lock_release_recursive(dirp->dd_lock);
#endif
} }
#endif /* ! HAVE_OPENDIR */ #endif /* ! HAVE_OPENDIR */

View File

@ -41,6 +41,7 @@ static char sccsid[] = "@(#)telldir.c 5.9 (Berkeley) 2/23/91";
#include <dirent.h> #include <dirent.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <sys/lock.h>
/* /*
* The option SINGLEUSE may be defined to say that a telldir * The option SINGLEUSE may be defined to say that a telldir
@ -60,6 +61,7 @@ struct ddloc {
long loc_index; /* key associated with structure */ long loc_index; /* key associated with structure */
long loc_seek; /* magic cookie returned by getdirentries */ long loc_seek; /* magic cookie returned by getdirentries */
long loc_loc; /* offset of entry in buffer */ long loc_loc; /* offset of entry in buffer */
DIR *loc_dirp; /* DIR pointer */
}; };
#define NDIRHASH 32 /* Num of hash lists, must be a power of 2 */ #define NDIRHASH 32 /* Num of hash lists, must be a power of 2 */
@ -67,6 +69,7 @@ struct ddloc {
static long dd_loccnt; /* Index of entry for sequential readdir's */ static long dd_loccnt; /* Index of entry for sequential readdir's */
static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */ static struct ddloc *dd_hash[NDIRHASH]; /* Hash list heads for ddlocs */
__LOCK_INIT(static, dd_hash_lock);
/* /*
* return a pointer into a directory * return a pointer into a directory
@ -80,12 +83,22 @@ telldir(dirp)
if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL) if ((lp = (struct ddloc *)malloc(sizeof(struct ddloc))) == NULL)
return (-1); return (-1);
#ifdef HAVE_DD_LOCK
__lock_acquire_recursive(dirp->dd_lock);
__lock_acquire(dd_hash_lock);
#endif
index = dd_loccnt++; index = dd_loccnt++;
lp->loc_index = index; lp->loc_index = index;
lp->loc_seek = dirp->dd_seek; lp->loc_seek = dirp->dd_seek;
lp->loc_loc = dirp->dd_loc; lp->loc_loc = dirp->dd_loc;
lp->loc_dirp = dirp;
lp->loc_next = dd_hash[LOCHASH(index)]; lp->loc_next = dd_hash[LOCHASH(index)];
dd_hash[LOCHASH(index)] = lp; dd_hash[LOCHASH(index)] = lp;
#ifdef HAVE_DD_LOCK
__lock_release(dd_hash_lock);
__lock_release_recursive(dirp->dd_lock);
#endif
return (index); return (index);
} }
@ -103,6 +116,9 @@ _seekdir(dirp, loc)
struct dirent *dp; struct dirent *dp;
extern long lseek(); extern long lseek();
#ifdef HAVE_DD_LOCK
__lock_acquire(dd_hash_lock);
#endif
prevlp = &dd_hash[LOCHASH(loc)]; prevlp = &dd_hash[LOCHASH(loc)];
lp = *prevlp; lp = *prevlp;
while (lp != NULL) { while (lp != NULL) {
@ -111,8 +127,12 @@ _seekdir(dirp, loc)
prevlp = &lp->loc_next; prevlp = &lp->loc_next;
lp = lp->loc_next; lp = lp->loc_next;
} }
if (lp == NULL) if (lp == NULL) {
#ifdef HAVE_DD_LOCK
__lock_release(dd_hash_lock);
#endif
return; return;
}
if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek) if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
goto found; goto found;
(void) lseek(dirp->dd_fd, lp->loc_seek, 0); (void) lseek(dirp->dd_fd, lp->loc_seek, 0);
@ -128,6 +148,46 @@ found:
*prevlp = lp->loc_next; *prevlp = lp->loc_next;
free((caddr_t)lp); free((caddr_t)lp);
#endif #endif
#ifdef HAVE_DD_LOCK
__lock_release(dd_hash_lock);
#endif
} }
/* clean out any hash entries from a closed directory */
void
_cleanupdir (dirp)
register DIR *dirp;
{
int i;
#ifdef HAVE_DD_LOCK
__lock_acquire(dd_hash_lock);
#endif
for (i = 0; i < NDIRHASH; ++i) {
register struct ddloc *lp;
register struct ddloc *prevlp;
lp = dd_hash[i];
while (lp != NULL && lp->loc_dirp == dirp) {
dd_hash[i] = lp->loc_next;
prevlp = lp;
free((caddr_t)lp);
lp = prevlp->loc_next;
}
prevlp = lp;
while (lp != NULL) {
lp = lp->loc_next;
if (lp != NULL && lp->loc_dirp == dirp) {
prevlp->loc_next = lp->loc_next;
free((caddr_t)lp);
lp = prevlp;
}
else
prevlp = lp;
}
}
#ifdef HAVE_DD_LOCK
__lock_release(dd_hash_lock);
#endif
}
#endif /* ! HAVE_OPENDIR */ #endif /* ! HAVE_OPENDIR */

View File

@ -10,13 +10,55 @@ SUBLIBS = \
$(LINUX_MACH_LIB) $(LINUX_MACH_LIB)
LIB_SOURCES = \ LIB_SOURCES = \
brk.c cfspeed.c flockfile.c funlockfile.c gethostname.c getoptlong.c \ brk.c \
getreent.c ids.c inode.c io.c io64.c linux.c mmap.c \ cfspeed.c \
pread.c pread64.c process.c pwrite.c pwrite64.c raise.c realpath.c \ flockfile.c \
rename.c resource.c sched.c select.c seteuid.c shm_open.c shm_unlink.c \ funlockfile.c \
sig.c sigaction.c sigqueue.c signal.c siglongjmp.c sigset.c sigwait.c \ gethostname.c \
socket.c sleep.c stack.c sysconf.c sysctl.c systat.c system.c \ getoptlong.c \
tcdrain.c tcsendbrk.c termios.c time.c usleep.c wait.c getreent.c \
ids.c \
inode.c \
io.c \
io64.c \
linux.c \
mmap.c \
pread.c \
pread64.c \
process.c \
psignal.c \
pwrite.c \
pwrite64.c \
raise.c \
realpath.c \
rename.c \
resource.c \
sched.c \
select.c \
seteuid.c \
shm_open.c \
shm_unlink.c \
sig.c \
sigaction.c \
sigqueue.c \
signal.c \
siglongjmp.c \
sigset.c \
sigwait.c \
socket.c \
sleep.c \
stack.c \
strsignal.c \
sysconf.c \
sysctl.c \
systat.c \
system.c \
tcdrain.c \
tcsendbrk.c \
termios.c \
time.c \
usleep.c \
wait.c
# This will handle both /usr/src/linux-2.4/include/asm/signal.h (in Red Hat Linux 7.1) # This will handle both /usr/src/linux-2.4/include/asm/signal.h (in Red Hat Linux 7.1)
# and also /usr/src/linux/include/asm/signal.h in older versions of Red Hat Linux # and also /usr/src/linux/include/asm/signal.h in older versions of Red Hat Linux

View File

@ -101,13 +101,55 @@ SUBLIBS = \
LIB_SOURCES = \ LIB_SOURCES = \
brk.c cfspeed.c flockfile.c funlockfile.c gethostname.c getoptlong.c \ brk.c \
getreent.c ids.c inode.c io.c io64.c linux.c mmap.c \ cfspeed.c \
pread.c pread64.c process.c pwrite.c pwrite64.c raise.c realpath.c \ flockfile.c \
rename.c resource.c sched.c select.c seteuid.c shm_open.c shm_unlink.c \ funlockfile.c \
sig.c sigaction.c sigqueue.c signal.c siglongjmp.c sigset.c sigwait.c \ gethostname.c \
socket.c sleep.c stack.c sysconf.c sysctl.c systat.c system.c \ getoptlong.c \
tcdrain.c tcsendbrk.c termios.c time.c usleep.c wait.c getreent.c \
ids.c \
inode.c \
io.c \
io64.c \
linux.c \
mmap.c \
pread.c \
pread64.c \
process.c \
psignal.c \
pwrite.c \
pwrite64.c \
raise.c \
realpath.c \
rename.c \
resource.c \
sched.c \
select.c \
seteuid.c \
shm_open.c \
shm_unlink.c \
sig.c \
sigaction.c \
sigqueue.c \
signal.c \
siglongjmp.c \
sigset.c \
sigwait.c \
socket.c \
sleep.c \
stack.c \
strsignal.c \
sysconf.c \
sysctl.c \
systat.c \
system.c \
tcdrain.c \
tcsendbrk.c \
termios.c \
time.c \
usleep.c \
wait.c
# This will handle both /usr/src/linux-2.4/include/asm/signal.h (in Red Hat Linux 7.1) # This will handle both /usr/src/linux-2.4/include/asm/signal.h (in Red Hat Linux 7.1)
@ -140,26 +182,27 @@ LIBS = @LIBS@
@USE_LIBTOOL_FALSE@lib_a_OBJECTS = brk.o cfspeed.o flockfile.o \ @USE_LIBTOOL_FALSE@lib_a_OBJECTS = brk.o cfspeed.o flockfile.o \
@USE_LIBTOOL_FALSE@funlockfile.o gethostname.o getoptlong.o getreent.o \ @USE_LIBTOOL_FALSE@funlockfile.o gethostname.o getoptlong.o getreent.o \
@USE_LIBTOOL_FALSE@ids.o inode.o io.o io64.o linux.o mmap.o pread.o \ @USE_LIBTOOL_FALSE@ids.o inode.o io.o io64.o linux.o mmap.o pread.o \
@USE_LIBTOOL_FALSE@pread64.o process.o pwrite.o pwrite64.o raise.o \ @USE_LIBTOOL_FALSE@pread64.o process.o psignal.o pwrite.o pwrite64.o \
@USE_LIBTOOL_FALSE@realpath.o rename.o resource.o sched.o select.o \ @USE_LIBTOOL_FALSE@raise.o realpath.o rename.o resource.o sched.o \
@USE_LIBTOOL_FALSE@seteuid.o shm_open.o shm_unlink.o sig.o sigaction.o \ @USE_LIBTOOL_FALSE@select.o seteuid.o shm_open.o shm_unlink.o sig.o \
@USE_LIBTOOL_FALSE@sigqueue.o signal.o siglongjmp.o sigset.o sigwait.o \ @USE_LIBTOOL_FALSE@sigaction.o sigqueue.o signal.o siglongjmp.o \
@USE_LIBTOOL_FALSE@socket.o sleep.o stack.o sysconf.o sysctl.o systat.o \ @USE_LIBTOOL_FALSE@sigset.o sigwait.o socket.o sleep.o stack.o \
@USE_LIBTOOL_FALSE@system.o tcdrain.o tcsendbrk.o termios.o time.o \ @USE_LIBTOOL_FALSE@strsignal.o sysconf.o sysctl.o systat.o system.o \
@USE_LIBTOOL_FALSE@usleep.o wait.o @USE_LIBTOOL_FALSE@tcdrain.o tcsendbrk.o termios.o time.o usleep.o \
@USE_LIBTOOL_FALSE@wait.o
LTLIBRARIES = $(noinst_LTLIBRARIES) LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@liblinux_la_DEPENDENCIES = @USE_LIBTOOL_TRUE@liblinux_la_DEPENDENCIES =
@USE_LIBTOOL_TRUE@liblinux_la_OBJECTS = brk.lo cfspeed.lo flockfile.lo \ @USE_LIBTOOL_TRUE@liblinux_la_OBJECTS = brk.lo cfspeed.lo flockfile.lo \
@USE_LIBTOOL_TRUE@funlockfile.lo gethostname.lo getoptlong.lo \ @USE_LIBTOOL_TRUE@funlockfile.lo gethostname.lo getoptlong.lo \
@USE_LIBTOOL_TRUE@getreent.lo ids.lo inode.lo io.lo io64.lo linux.lo \ @USE_LIBTOOL_TRUE@getreent.lo ids.lo inode.lo io.lo io64.lo linux.lo \
@USE_LIBTOOL_TRUE@mmap.lo pread.lo pread64.lo process.lo pwrite.lo \ @USE_LIBTOOL_TRUE@mmap.lo pread.lo pread64.lo process.lo psignal.lo \
@USE_LIBTOOL_TRUE@pwrite64.lo raise.lo realpath.lo rename.lo \ @USE_LIBTOOL_TRUE@pwrite.lo pwrite64.lo raise.lo realpath.lo rename.lo \
@USE_LIBTOOL_TRUE@resource.lo sched.lo select.lo seteuid.lo shm_open.lo \ @USE_LIBTOOL_TRUE@resource.lo sched.lo select.lo seteuid.lo shm_open.lo \
@USE_LIBTOOL_TRUE@shm_unlink.lo sig.lo sigaction.lo sigqueue.lo \ @USE_LIBTOOL_TRUE@shm_unlink.lo sig.lo sigaction.lo sigqueue.lo \
@USE_LIBTOOL_TRUE@signal.lo siglongjmp.lo sigset.lo sigwait.lo \ @USE_LIBTOOL_TRUE@signal.lo siglongjmp.lo sigset.lo sigwait.lo \
@USE_LIBTOOL_TRUE@socket.lo sleep.lo stack.lo sysconf.lo sysctl.lo \ @USE_LIBTOOL_TRUE@socket.lo sleep.lo stack.lo strsignal.lo sysconf.lo \
@USE_LIBTOOL_TRUE@systat.lo system.lo tcdrain.lo tcsendbrk.lo \ @USE_LIBTOOL_TRUE@sysctl.lo systat.lo system.lo tcdrain.lo tcsendbrk.lo \
@USE_LIBTOOL_TRUE@termios.lo time.lo usleep.lo wait.lo @USE_LIBTOOL_TRUE@termios.lo time.lo usleep.lo wait.lo
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

View File

@ -0,0 +1,15 @@
/* libc/sys/linux/psignal.c - print signal message to stderr */
/* Copyright 2002, Red Hat Inc. */
#include <stdio.h>
#include <string.h>
void
psignal (int sig, const char *s)
{
if (s != NULL)
fprintf (stderr, "%s: %s\n", s, strsignal (sig));
else
fprintf (stderr, "%s\n", strsignal (sig));
}

View File

@ -0,0 +1,63 @@
#include <string.h>
#include <signal.h>
#include <stdio.h>
#include <reent.h>
static const char *sigstring[] =
{
"Signal 0",
"Hangup",
"Interrupt",
"Quit",
"Illegal instruction",
"Trace/breakpoint trap",
"IOT trap",
"EMT trap",
"Floating point exception",
"Killed",
"Bus error",
"Segmentation fault",
"Bad system call",
"Broken pipe",
"Alarm clock",
"Terminated",
"Urgent I/O condition",
"Stopped (signal)",
"Stopped",
"Continued",
"Child exited",
"Stopped (tty input)",
"Stopped (tty output)",
"I/O possible",
"CPU time limit exceeded",
"File size limit exceeded",
"Virtual timer expired",
"Profiling timer expired",
"Window changed",
"Resource lost",
"User defined signal 1",
"User defined signal 2"
};
char *
strsignal (int sig)
{
if (sig < 0 || sig >= __SIGRTMIN)
{
char *buffer;
struct _reent *ptr;
ptr = _REENT;
_REENT_CHECK_SIGNAL_BUF(ptr);
buffer = _REENT_SIGNAL_BUF(ptr);
if (sig < 0 || sig > __SIGRTMAX)
siprintf (buffer, "Unknown signal %d", sig);
else
siprintf (buffer, "Real-time signal %d", sig - __SIGRTMIN);
return buffer;
}
else
return sigstring[sig];
}

View File

@ -8,8 +8,12 @@
#include <sys/types.h> #include <sys/types.h>
#include <linux/dirent.h> #include <linux/dirent.h>
#define _LIBC
#include <sys/lock.h>
#undef _LIBC
#define HAVE_NO_D_NAMLEN /* no struct dirent->d_namlen */ #define HAVE_NO_D_NAMLEN /* no struct dirent->d_namlen */
#define HAVE_DD_LOCK /* have locking mechanism */
#define MAXNAMLEN 255 /* sizeof(struct dirent.d_name)-1 */ #define MAXNAMLEN 255 /* sizeof(struct dirent.d_name)-1 */
@ -21,6 +25,7 @@ typedef struct {
char *dd_buf; /* buffer */ char *dd_buf; /* buffer */
int dd_len; /* buffer length */ int dd_len; /* buffer length */
int dd_size; /* amount of data in buffer */ int dd_size; /* amount of data in buffer */
_LOCK_RECURSIVE_T dd_lock;
} DIR; } DIR;

View File

@ -30,16 +30,17 @@
#include <_ansi.h> #include <_ansi.h>
int _EXFUN(kill, (int, int)); int _EXFUN(kill, (int, int));
int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); _VOID _EXFUN(psignal, (int, const char *));
int _EXFUN(sigaddset, (sigset_t *, const int)); int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *));
int _EXFUN(sigdelset, (sigset_t *, const int)); int _EXFUN(sigaddset, (sigset_t *, const int));
int _EXFUN(sigismember, (const sigset_t *, int)); int _EXFUN(sigdelset, (sigset_t *, const int));
int _EXFUN(sigfillset, (sigset_t *)); int _EXFUN(sigismember, (const sigset_t *, int));
int _EXFUN(sigemptyset, (sigset_t *)); int _EXFUN(sigfillset, (sigset_t *));
int _EXFUN(sigpending, (sigset_t *)); int _EXFUN(sigemptyset, (sigset_t *));
int _EXFUN(sigsuspend, (const sigset_t *)); int _EXFUN(sigpending, (sigset_t *));
int _EXFUN(sigpause, (int)); int _EXFUN(sigsuspend, (const sigset_t *));
int _EXFUN(sigpause, (int));
#ifndef _POSIX_SOURCE #ifndef _POSIX_SOURCE
extern const char *const sys_siglist[]; extern const char *const sys_siglist[];