Throughout, remove "include <errno.h>" from files which already include

cygerrno.h.
* include/cygwin/config.h (__DYNAMIC_REENT__): Define.
* include/cygwin/version.h: Bump API minor version.
* cygwin.din: Export __getreent
* cygerrno.h: Include errno.h.  Fix places where _impure_ptr is used directly
to store the errno value.
* debug.cc (__set_errno): Ditto.
* errno.cc: Remove _RRENT_ONLY define to get errno.cc compiled.
* signal.cc: Rename _reent_clib to _REENT throughout.
* thread.h (reent_clib): Remove prototype.
* thread.cc (reent_clib): Rename reent_clib to __getreent.  Return _impure_ptr
until MTinterface is initialized.
(reent_winsup): Fix a possible SEGV when _r == NULL.  Return NULL instead.
* MTinterface::fixup_after_fork: Switch reent back to _impure_ptr to keep
signal handling running when fork is called from a thread other than the
mainthread.
This commit is contained in:
Christopher Faylor 2003-06-16 03:24:13 +00:00
parent 753d031f1f
commit c433f4617f
83 changed files with 65 additions and 91 deletions

View File

@ -18,7 +18,6 @@ details. */
#endif
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>

View File

@ -16,7 +16,6 @@ details. */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
#include <signal.h>
#include <stdio.h>

View File

@ -15,7 +15,6 @@ details. */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include "cygerrno.h"

View File

@ -20,7 +20,6 @@ details. */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>

View File

@ -1,3 +1,27 @@
2003-06-15 Christopher Faylor <cgf@redhat.com>
Throughout, remove "include <errno.h>" from files which already include
cygerrno.h.
2003-06-15 Thomas Pfaff <tpfaff@gmx.net>
* include/cygwin/config.h (__DYNAMIC_REENT__): Define.
* include/cygwin/version.h: Bump API minor version.
* cygwin.din: Export __getreent
* cygerrno.h: Include errno.h. Fix places where _impure_ptr is used
directly to store the errno value.
* debug.cc (__set_errno): Ditto.
* errno.cc: Remove _RRENT_ONLY define to get errno.cc compiled.
* signal.cc: Rename _reent_clib to _REENT throughout.
* thread.h (reent_clib): Remove prototype.
* thread.cc (reent_clib): Rename reent_clib to __getreent. Return
_impure_ptr until MTinterface is initialized.
(reent_winsup): Fix a possible SEGV when _r == NULL. Return NULL
instead.
* MTinterface::fixup_after_fork: Switch reent back to _impure_ptr to
keep signal handling running when fork is called from a thread other
than the mainthread.
2003-06-12 Thomas Pfaff <tpfaff@gmx.net>
* thread.cc (pthread_attr_init): Revert change from 2003-06-11

View File

@ -1,6 +1,6 @@
/* cygerrno.h: main Cygwin header file.
Copyright 2000 Red Hat, Inc.
Copyright 2000, 2001, 2002, 2003 Red Hat, Inc.
This file is part of Cygwin.
@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include <errno.h>
void __stdcall seterrno_from_win_error (const char *file, int line, DWORD code) __attribute__ ((regparm(3)));
void __stdcall seterrno (const char *, int line) __attribute__ ((regparm(2)));
int __stdcall geterrno_from_win_error (DWORD code, int deferrno) __attribute__ ((regparm(2)));
@ -16,12 +18,12 @@ int __stdcall geterrno_from_win_error (DWORD code, int deferrno) __attribute__ (
#define __seterrno_from_win_error(val) seterrno_from_win_error (__FILE__, __LINE__, val)
#ifndef DEBUGGING
#define set_errno(val) (_impure_ptr->_errno = (val))
#define set_errno(val) (errno = (val))
#else
int __stdcall __set_errno (const char *ln, int ln, int val) __attribute ((regparm(3)));
#define set_errno(val) __set_errno (__PRETTY_FUNCTION__, __LINE__, (val))
#endif
#define get_errno() (_impure_ptr->_errno)
#define get_errno() (errno)
extern "C" void __stdcall set_sig_errno (int e);
class save_errno

View File

@ -10,7 +10,6 @@
#include "winsup.h"
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <stdlib.h>
#include "security.h"

View File

@ -16,7 +16,6 @@ details. */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
#include <signal.h>
#include <stdio.h>

View File

@ -18,7 +18,6 @@ details. */
#endif
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>

View File

@ -15,7 +15,6 @@ details. */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include "cygerrno.h"

View File

@ -20,7 +20,6 @@ details. */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include <netdb.h>
#include <pthread.h>
#include <unistd.h>

View File

@ -9,7 +9,6 @@ details. */
#include "winsup.h"
#include <windows.h>
#include <stdlib.h>
#include <errno.h>
#include "exceptions.h"
#include "security.h"
#include "cygthread.h"

View File

@ -26,6 +26,7 @@ __eprintf
__errno
__fpclassifyd
__fpclassifyf
__getreent
__infinity
__main
__signbitd

View File

@ -17,7 +17,6 @@ details. */
#include <limits.h>
#include <wingdi.h>
#include <winuser.h>
#include <errno.h>
#include "sigproc.h"
#include "pinfo.h"
#include "cygerrno.h"

View File

@ -15,7 +15,6 @@ details. */
#include "security.h"
#include "cygerrno.h"
#ifdef DEBUGGING
#include <errno.h>
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
@ -222,6 +221,6 @@ int __stdcall
__set_errno (const char *func, int ln, int val)
{
debug_printf ("%s:%d val %d", func, ln, val);
return _impure_ptr->_errno = val;
return errno = val;
}
#endif /*DEBUGGING*/

View File

@ -12,7 +12,6 @@ details. */
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
#define _COMPILING_NEWLIB
#include <dirent.h>

View File

@ -8,7 +8,6 @@ details. */
#include "winsup.h"
#include <stdlib.h>
#include <errno.h>
#include "cygerrno.h"
#include "perprocess.h"
#include "dll_init.h"

View File

@ -11,7 +11,6 @@ details. */
#define __INSIDE_CYGWIN_NET__
#include "winsup.h"
#include <errno.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <stdio.h>

View File

@ -8,7 +8,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>

View File

@ -12,9 +12,7 @@ details. */
#define sys_nerr FOOsys_nerr
#define _sys_errlist FOO_sys_errlist
#include "winsup.h"
#define _REENT_ONLY
#include <stdio.h>
#include <errno.h>
#include "cygerrno.h"
#include "thread.h"
#undef _sys_nerr

View File

@ -10,7 +10,6 @@ details. */
#include "winsup.h"
#include <imagehlp.h>
#include <errno.h>
#include <stdlib.h>
#include "exceptions.h"

View File

@ -12,7 +12,6 @@ details. */
#include "winsup.h"
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <process.h>
#include "perprocess.h"
#include "security.h"

View File

@ -11,7 +11,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include "security.h"
#include "fhandler.h"
#include "sigproc.h"

View File

@ -10,7 +10,6 @@ details. */
#include "winsup.h"
#include <stdarg.h>
#include <errno.h>
#include <unistd.h>
#include "security.h"
#include "fhandler.h"

View File

@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/cygwin.h>

View File

@ -13,7 +13,6 @@ details. */
#include "winsup.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <windows.h>
#include <wingdi.h>

View File

@ -12,7 +12,6 @@ details. */
#include <sys/termios.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <wingdi.h>
#include <winuser.h>

View File

@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/cygwin.h>

View File

@ -12,7 +12,6 @@ details. */
#include "winsup.h"
#include <stdio.h>
#include <errno.h>
#include <windows.h>
#include <sys/soundcard.h>
#include <mmsystem.h>

View File

@ -11,7 +11,6 @@ details. */
#include "winsup.h"
#include <sys/termios.h>
#include <errno.h>
#include <unistd.h>
#include <winioctl.h>
#include <asm/socket.h>

View File

@ -9,7 +9,6 @@
details. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <sys/mman.h>
#include <ntdef.h>

View File

@ -11,7 +11,6 @@ details. */
#define _WIN32_WINNT 0x0501
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/cygwin.h>

View File

@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/cygwin.h>

View File

@ -11,7 +11,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <limits.h>
#include "cygerrno.h"
#include "security.h"

View File

@ -10,7 +10,6 @@
#include "winsup.h"
#include <sys/termios.h>
#include <errno.h>
#include <unistd.h>
#include <cygwin/rdevio.h>

View File

@ -11,7 +11,6 @@ details. */
/* FIXME: Access permissions are ignored at the moment. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/cygwin.h>

View File

@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "cygerrno.h"

View File

@ -13,7 +13,6 @@
#define __INSIDE_CYGWIN_NET__
#include "winsup.h"
#include <errno.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/uio.h>

View File

@ -11,7 +11,6 @@ details. */
#include "winsup.h"
#include <sys/termios.h>
#include <errno.h>
#include <unistd.h>
#include <sys/mtio.h>
#include "cygerrno.h"

View File

@ -12,7 +12,6 @@ details. */
#include <sys/termios.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include "cygerrno.h"
#include "security.h"

View File

@ -14,7 +14,6 @@ details. */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <ctype.h>
#include <limits.h>
#include "cygerrno.h"

View File

@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/cygwin.h>

View File

@ -12,7 +12,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <wingdi.h>
#include <winuser.h>
#include "cygerrno.h"

View File

@ -13,7 +13,6 @@ details. */
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include "security.h"
#include "fhandler.h"
#include "path.h"

View File

@ -16,7 +16,6 @@ details. */
#include <wininet.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "pinfo.h"
#include "security.h"
#include "fhandler.h"

View File

@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include "cygerrno.h"
#include "sigproc.h"
#include "pinfo.h"

View File

@ -19,6 +19,7 @@ extern "C" {
#endif
#define _CYGWIN_CONFIG_H
#define __DYNAMIC_REENT__
#define __FILENAME_MAX__ (260 - 1 /* NUL */)
#define _READ_WRITE_RETURN_TYPE _ssize_t
#define __LARGE64_FILES 1

View File

@ -207,12 +207,13 @@ details. */
exported symbols like fopen64, which might confuse configure.
86: Export ftok
87: Export vsyslog
88: Export _getreent
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
#define CYGWIN_VERSION_API_MINOR 87
#define CYGWIN_VERSION_API_MINOR 88
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible

View File

@ -13,7 +13,6 @@ details. */
#include "winsup.h"
#include <sys/ioctl.h>
#include <errno.h>
#include "cygerrno.h"
#include "security.h"
#include "fhandler.h"

View File

@ -18,7 +18,6 @@ details. */
#include "fhandler.h"
#include "path.h"
#include "dtable.h"
#include <errno.h>
#include "cygerrno.h"
#include "cygheap.h"
#include "heap.h"

View File

@ -13,7 +13,6 @@ details. */
#include <stdlib.h>
#include <stddef.h>
#include <sys/mman.h>
#include <errno.h>
#include "security.h"
#include "fhandler.h"
#include "path.h"

View File

@ -15,7 +15,6 @@ details. */
#include <sys/types.h>
#include <cygwin/msg.h>
#include <errno.h>
#include "cygerrno.h"

View File

@ -13,7 +13,6 @@ details. */
#define __INSIDE_CYGWIN_NET__
#include "winsup.h"
#include <errno.h>
#include <ctype.h>
#include <sys/socket.h>
#include <sys/un.h>

View File

@ -12,7 +12,6 @@ details. */
#include <stdlib.h>
#include <pwd.h>
#include <stdio.h>
#include <errno.h>
#include "cygerrno.h"
#include "security.h"
#include "fhandler.h"

View File

@ -53,7 +53,6 @@ details. */
#include <sys/mount.h>
#include <mntent.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <winioctl.h>
#include <wingdi.h>

View File

@ -11,7 +11,6 @@ details. */
#include "winsup.h"
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#include <limits.h>
#include "security.h"
#include "fhandler.h"

View File

@ -12,7 +12,6 @@ details. */
#include "winsup.h"
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include "cygerrno.h"
#include "security.h"

View File

@ -15,7 +15,6 @@
#include <sys/time.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <errno.h>
#include <stdlib.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock2.h>

View File

@ -13,7 +13,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <limits.h>
#include "cygerrno.h"

View File

@ -13,7 +13,6 @@
#include "winsup.h"
#include <dirent.h>
#include <stdlib.h>
#include <errno.h>
#include "cygerrno.h"
extern "C" int

View File

@ -16,7 +16,6 @@
#include "winsup.h"
#include <limits.h>
#include <errno.h>
#include "cygerrno.h"
#include <assert.h>
#include <stdlib.h>

View File

@ -15,7 +15,6 @@ details. */
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>

View File

@ -15,7 +15,6 @@ details. */
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>

View File

@ -16,7 +16,6 @@ details. */
#include <pwd.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>

View File

@ -20,7 +20,6 @@ details. */
#define __INSIDE_CYGWIN_NET__
#include "winsup.h"
#include <errno.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <sys/time.h>

View File

@ -15,7 +15,6 @@ details. */
#include <sys/types.h>
#include <cygwin/sem.h>
#include <errno.h>
#include "cygerrno.h"

View File

@ -14,7 +14,6 @@ details. */
#include <stdlib.h>
#include <grp.h>
#include <pwd.h>
#include <errno.h>
#include "pinfo.h"
#include "security.h"
#include "fhandler.h"

View File

@ -16,7 +16,6 @@ details. */
#include <sys/types.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>

View File

@ -12,7 +12,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <stdlib.h>
#include "cygerrno.h"
#include <sys/cygwin.h>
@ -297,8 +296,8 @@ abort (void)
be flushed.
However this is the way FreeBSD does it, and it is much easier to
do things this way, so... */
if (_reent_clib ()->__cleanup)
_reent_clib ()->__cleanup (_reent_clib ());
if (_REENT->__cleanup)
_REENT->__cleanup (_REENT);
/* Ensure that SIGABRT can be caught regardless of blockage. */
sigset_t sig_mask;

View File

@ -14,7 +14,6 @@ details. */
#include <stdlib.h>
#include <time.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/cygwin.h>
#include <assert.h>

View File

@ -14,7 +14,6 @@ details. */
#include <unistd.h>
#include <process.h>
#include <sys/wait.h>
#include <errno.h>
#include <limits.h>
#include <wingdi.h>
#include <winuser.h>

View File

@ -14,7 +14,6 @@ details. */
#include <wingdi.h>
#include <winuser.h>
#include <ctype.h>
#include <errno.h>
#include "pinfo.h"
#include "perprocess.h"
#include "cygwin_version.h"

View File

@ -29,7 +29,6 @@ details. */
#include <process.h>
#include <utmp.h>
#include <sys/uio.h>
#include <errno.h>
#include <limits.h>
#include <unistd.h>
#include <setjmp.h>

View File

@ -10,7 +10,6 @@ details. */
#include "winsup.h"
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <limits.h>
#include <ntdef.h>

View File

@ -14,7 +14,6 @@ details. */
#include <syslog.h>
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
#include "security.h"
#include "fhandler.h"
#include "path.h"

View File

@ -12,7 +12,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <signal.h>
#include <stdlib.h>
#include "cygerrno.h"

View File

@ -45,16 +45,21 @@ details. */
extern int threadsafe;
struct _reent *
_reent_clib ()
extern "C" struct _reent *
__getreent ()
{
struct __reent_t *_r =
(struct __reent_t *) MT_INTERFACE->reent_key.get ();
#ifdef _CYG_THREAD_FAILSAFE
if (_r == 0)
system_printf ("local thread storage not inited");
{
#ifdef _CYG_THREAD_FAILSAFE
system_printf ("local thread storage not inited");
#endif
/* Return _impure_ptr as long as MTinterface is not initialized */
return _impure_ptr;
}
return _r->_clib;
}
@ -64,10 +69,14 @@ _reent_winsup ()
struct __reent_t *_r =
(struct __reent_t *) MT_INTERFACE->reent_key.get ();
#ifdef _CYG_THREAD_FAILSAFE
if (_r == 0)
system_printf ("local thread storage not inited");
{
#ifdef _CYG_THREAD_FAILSAFE
system_printf ("local thread storage not inited");
#endif
return NULL;
}
return _r->_winsup;
}
@ -212,6 +221,20 @@ MTinterface::fixup_after_fork (void)
{
pthread_key::fixup_after_fork ();
#ifndef __SIGNALS_ARE_MULTITHREADED__
/* As long as the signal handling not multithreaded
switch reents storage back to _impure_ptr for the mainthread
to support fork from threads other than the mainthread */
struct _reent *reent_old = __getreent ();
if (reent_old && _impure_ptr != reent_old)
*_impure_ptr = *reent_old;
reents._clib = _impure_ptr;
reents._winsup = &winsup_reent;
winsup_reent._process_logmask = LOG_UPTO (LOG_DEBUG);
reent_key.set (&reents);
#endif
threadcount = 1;
pthread::init_mainthread ();

View File

@ -110,7 +110,6 @@ struct __reent_t
struct _winsup_t *_winsup;
};
_reent *_reent_clib ();
_winsup_t *_reent_winsup ();
void SetResourceLock (int, int, const char *) __attribute__ ((regparm (3)));
void ReleaseResourceLock (int, int, const char *)

View File

@ -15,7 +15,6 @@ details. */
#include <utime.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "cygerrno.h"
#include "security.h"
#include "fhandler.h"

View File

@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <errno.h>
#include <unistd.h>
#include <utmp.h>
#include <wingdi.h>

View File

@ -17,7 +17,6 @@ details. */
#include <limits.h>
#include <stdlib.h>
#include <lm.h>
#include <errno.h>
#include <sys/cygwin.h>
#include "pinfo.h"
#include "security.h"

View File

@ -11,7 +11,6 @@ details. */
#include "winsup.h"
#include <sys/wait.h>
#include <stdlib.h>
#include <errno.h>
#include "cygerrno.h"
#include "sigproc.h"
#include "perthread.h"

View File

@ -13,7 +13,6 @@ details. */
#include "winsup.h"
#include <sys/time.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <limits.h>
#include <wingdi.h>