* cygtls.h (_local_storage::setmode_file): New element.

(_local_storage::setmode_mode): New element.
* tlsoffsets.h: Regenerate.
* cygwin.din (setmode): Define as cygwin_getmode.
* syscalls.cc (setmode_helper): Use setmode_* variables from tls rather than
using unthreadsafe static.
(setmode): Break out fwalk stuff.
(cygwin_setmode): New function.  Put fwalk stdio stuff here.
This commit is contained in:
Christopher Faylor 2005-06-09 22:33:57 +00:00
parent fa0dcd0d65
commit 9a91777205
6 changed files with 95 additions and 75 deletions

View File

@ -1,3 +1,14 @@
2005-06-09 Christopher Faylor <cgf@timesys.com>
* cygtls.h (_local_storage::setmode_file): New element.
(_local_storage::setmode_mode): New element.
* tlsoffsets.h: Regenerate.
* cygwin.din (setmode): Define as cygwin_getmode.
* syscalls.cc (setmode_helper): Use setmode_* variables from tls rather
than using unthreadsafe static.
(setmode): Break out fwalk stuff.
(cygwin_setmode): New function. Put fwalk stdio stuff here.
2005-06-09 Christopher Faylor <cgf@timesys.com> 2005-06-09 Christopher Faylor <cgf@timesys.com>
* thread.cc (pthread_mutex::_lock): Use cancelable_wait rather than * thread.cc (pthread_mutex::_lock): Use cancelable_wait rather than

View File

@ -95,6 +95,10 @@ struct _local_storage
/* cygthread.cc */ /* cygthread.cc */
char unknown_thread_name[30]; char unknown_thread_name[30];
/* syscalls.cc */
int setmode_file;
int setmode_mode;
}; };
typedef struct struct_waitq typedef struct struct_waitq

View File

@ -1202,8 +1202,8 @@ _setlocale = setlocale NOSIGFE
setlogmask NOSIGFE setlogmask NOSIGFE
setmntent SIGFE setmntent SIGFE
_setmntent = setmntent SIGFE _setmntent = setmntent SIGFE
setmode SIGFE setmode = cygwin_setmode SIGFE
_setmode = setmode SIGFE _setmode = cygwin_setmode SIGFE
setpassent NOSIGFE setpassent NOSIGFE
_setpassent = setpassent NOSIGFE _setpassent = setpassent NOSIGFE
setpgid SIGFE setpgid SIGFE

View File

@ -1565,20 +1565,17 @@ _cygwin_istext_for_stdio (int fd)
/* internal newlib function */ /* internal newlib function */
extern "C" int _fwalk (struct _reent *ptr, int (*function) (FILE *)); extern "C" int _fwalk (struct _reent *ptr, int (*function) (FILE *));
static int setmode_mode;
static int setmode_file;
static int static int
setmode_helper (FILE *f) setmode_helper (FILE *f)
{ {
if (fileno (f) != setmode_file) if (fileno (f) != _my_tls.locals.setmode_file)
{ {
syscall_printf ("improbable, but %d != %d", fileno (f), setmode_file); syscall_printf ("improbable, but %d != %d", fileno (f), _my_tls.locals.setmode_file);
return 0; return 0;
} }
syscall_printf ("file was %s now %s", f->_flags & __SCLE ? "text" : "binary", syscall_printf ("file was %s now %s", f->_flags & __SCLE ? "text" : "binary",
setmode_mode & O_TEXT ? "text" : "binary"); _my_tls.locals.setmode_mode & O_TEXT ? "text" : "binary");
if (setmode_mode & O_TEXT) if (_my_tls.locals.setmode_mode & O_TEXT)
f->_flags |= __SCLE; f->_flags |= __SCLE;
else else
f->_flags &= ~__SCLE; f->_flags &= ~__SCLE;
@ -1628,18 +1625,27 @@ setmode (int fd, int mode)
else else
cfd->set_flags ((cfd->get_flags () & ~(O_TEXT | O_BINARY)) | mode); cfd->set_flags ((cfd->get_flags () & ~(O_TEXT | O_BINARY)) | mode);
if (_cygwin_istext_for_stdio (fd))
setmode_mode = O_TEXT;
else
setmode_mode = O_BINARY;
setmode_file = fd;
_fwalk (_GLOBAL_REENT, setmode_helper);
syscall_printf ("(%d<%s>, %p) returning %s", fd, cfd->get_name (), syscall_printf ("(%d<%s>, %p) returning %s", fd, cfd->get_name (),
mode, res & O_TEXT ? "text" : "binary"); mode, res & O_TEXT ? "text" : "binary");
return res; return res;
} }
extern "C" int
cygwin_setmode (int fd, int mode)
{
int res = setmode (fd, mode);
if (res != -1)
{
_my_tls.locals.setmode_file = fd;
if (_cygwin_istext_for_stdio (fd))
_my_tls.locals.setmode_mode = O_TEXT;
else
_my_tls.locals.setmode_mode = O_BINARY;
_fwalk (_GLOBAL_REENT, setmode_helper);
}
return res;
}
extern "C" int extern "C" int
ftruncate64 (int fd, _off64_t length) ftruncate64 (int fd, _off64_t length)
{ {

View File

@ -1756,8 +1756,7 @@ int
semaphore::_trywait () semaphore::_trywait ()
{ {
/* FIXME: signals should be able to interrupt semaphores... /* FIXME: signals should be able to interrupt semaphores...
*We probably need WaitForMultipleObjects here. We probably need WaitForMultipleObjects here. */
*/
if (WaitForSingleObject (win32_obj_id, 0) == WAIT_TIMEOUT) if (WaitForSingleObject (win32_obj_id, 0) == WAIT_TIMEOUT)
{ {
set_errno (EAGAIN); set_errno (EAGAIN);

View File

@ -1,117 +1,117 @@
//;# autogenerated: Do not edit. //;# autogenerated: Do not edit.
//; $tls::sizeof__cygtls = 3964; //; $tls::sizeof__cygtls = 3972;
//; $tls::func = -3964; //; $tls::func = -3972;
//; $tls::pfunc = 0; //; $tls::pfunc = 0;
//; $tls::saved_errno = -3960; //; $tls::saved_errno = -3968;
//; $tls::psaved_errno = 4; //; $tls::psaved_errno = 4;
//; $tls::sa_flags = -3956; //; $tls::sa_flags = -3964;
//; $tls::psa_flags = 8; //; $tls::psa_flags = 8;
//; $tls::oldmask = -3952; //; $tls::oldmask = -3960;
//; $tls::poldmask = 12; //; $tls::poldmask = 12;
//; $tls::deltamask = -3948; //; $tls::deltamask = -3956;
//; $tls::pdeltamask = 16; //; $tls::pdeltamask = 16;
//; $tls::event = -3944; //; $tls::event = -3952;
//; $tls::pevent = 20; //; $tls::pevent = 20;
//; $tls::errno_addr = -3940; //; $tls::errno_addr = -3948;
//; $tls::perrno_addr = 24; //; $tls::perrno_addr = 24;
//; $tls::initialized = -3936; //; $tls::initialized = -3944;
//; $tls::pinitialized = 28; //; $tls::pinitialized = 28;
//; $tls::sigmask = -3932; //; $tls::sigmask = -3940;
//; $tls::psigmask = 32; //; $tls::psigmask = 32;
//; $tls::sigwait_mask = -3928; //; $tls::sigwait_mask = -3936;
//; $tls::psigwait_mask = 36; //; $tls::psigwait_mask = 36;
//; $tls::sigwait_info = -3924; //; $tls::sigwait_info = -3932;
//; $tls::psigwait_info = 40; //; $tls::psigwait_info = 40;
//; $tls::threadkill = -3920; //; $tls::threadkill = -3928;
//; $tls::pthreadkill = 44; //; $tls::pthreadkill = 44;
//; $tls::infodata = -3916; //; $tls::infodata = -3924;
//; $tls::pinfodata = 48; //; $tls::pinfodata = 48;
//; $tls::tid = -3768; //; $tls::tid = -3776;
//; $tls::ptid = 196; //; $tls::ptid = 196;
//; $tls::local_clib = -3764; //; $tls::local_clib = -3772;
//; $tls::plocal_clib = 200; //; $tls::plocal_clib = 200;
//; $tls::__dontuse = -3764; //; $tls::__dontuse = -3772;
//; $tls::p__dontuse = 200; //; $tls::p__dontuse = 200;
//; $tls::locals = -2700; //; $tls::locals = -2708;
//; $tls::plocals = 1264; //; $tls::plocals = 1264;
//; $tls::_ctinfo = -1084; //; $tls::_ctinfo = -1084;
//; $tls::p_ctinfo = 2880; //; $tls::p_ctinfo = 2888;
//; $tls::wq = -1080; //; $tls::wq = -1080;
//; $tls::pwq = 2884; //; $tls::pwq = 2892;
//; $tls::prev = -1052; //; $tls::prev = -1052;
//; $tls::pprev = 2912; //; $tls::pprev = 2920;
//; $tls::next = -1048; //; $tls::next = -1048;
//; $tls::pnext = 2916; //; $tls::pnext = 2924;
//; $tls::stackptr = -1044; //; $tls::stackptr = -1044;
//; $tls::pstackptr = 2920; //; $tls::pstackptr = 2928;
//; $tls::sig = -1040; //; $tls::sig = -1040;
//; $tls::psig = 2924; //; $tls::psig = 2932;
//; $tls::incyg = -1036; //; $tls::incyg = -1036;
//; $tls::pincyg = 2928; //; $tls::pincyg = 2936;
//; $tls::spinning = -1032; //; $tls::spinning = -1032;
//; $tls::pspinning = 2932; //; $tls::pspinning = 2940;
//; $tls::stacklock = -1028; //; $tls::stacklock = -1028;
//; $tls::pstacklock = 2936; //; $tls::pstacklock = 2944;
//; $tls::stack = -1024; //; $tls::stack = -1024;
//; $tls::pstack = 2940; //; $tls::pstack = 2948;
//; $tls::padding = 0; //; $tls::padding = 0;
//; $tls::ppadding = 3964; //; $tls::ppadding = 3972;
//; __DATA__ //; __DATA__
#define tls_func (-3964) #define tls_func (-3972)
#define tls_pfunc (0) #define tls_pfunc (0)
#define tls_saved_errno (-3960) #define tls_saved_errno (-3968)
#define tls_psaved_errno (4) #define tls_psaved_errno (4)
#define tls_sa_flags (-3956) #define tls_sa_flags (-3964)
#define tls_psa_flags (8) #define tls_psa_flags (8)
#define tls_oldmask (-3952) #define tls_oldmask (-3960)
#define tls_poldmask (12) #define tls_poldmask (12)
#define tls_deltamask (-3948) #define tls_deltamask (-3956)
#define tls_pdeltamask (16) #define tls_pdeltamask (16)
#define tls_event (-3944) #define tls_event (-3952)
#define tls_pevent (20) #define tls_pevent (20)
#define tls_errno_addr (-3940) #define tls_errno_addr (-3948)
#define tls_perrno_addr (24) #define tls_perrno_addr (24)
#define tls_initialized (-3936) #define tls_initialized (-3944)
#define tls_pinitialized (28) #define tls_pinitialized (28)
#define tls_sigmask (-3932) #define tls_sigmask (-3940)
#define tls_psigmask (32) #define tls_psigmask (32)
#define tls_sigwait_mask (-3928) #define tls_sigwait_mask (-3936)
#define tls_psigwait_mask (36) #define tls_psigwait_mask (36)
#define tls_sigwait_info (-3924) #define tls_sigwait_info (-3932)
#define tls_psigwait_info (40) #define tls_psigwait_info (40)
#define tls_threadkill (-3920) #define tls_threadkill (-3928)
#define tls_pthreadkill (44) #define tls_pthreadkill (44)
#define tls_infodata (-3916) #define tls_infodata (-3924)
#define tls_pinfodata (48) #define tls_pinfodata (48)
#define tls_tid (-3768) #define tls_tid (-3776)
#define tls_ptid (196) #define tls_ptid (196)
#define tls_local_clib (-3764) #define tls_local_clib (-3772)
#define tls_plocal_clib (200) #define tls_plocal_clib (200)
#define tls___dontuse (-3764) #define tls___dontuse (-3772)
#define tls_p__dontuse (200) #define tls_p__dontuse (200)
#define tls_locals (-2700) #define tls_locals (-2708)
#define tls_plocals (1264) #define tls_plocals (1264)
#define tls__ctinfo (-1084) #define tls__ctinfo (-1084)
#define tls_p_ctinfo (2880) #define tls_p_ctinfo (2888)
#define tls_wq (-1080) #define tls_wq (-1080)
#define tls_pwq (2884) #define tls_pwq (2892)
#define tls_prev (-1052) #define tls_prev (-1052)
#define tls_pprev (2912) #define tls_pprev (2920)
#define tls_next (-1048) #define tls_next (-1048)
#define tls_pnext (2916) #define tls_pnext (2924)
#define tls_stackptr (-1044) #define tls_stackptr (-1044)
#define tls_pstackptr (2920) #define tls_pstackptr (2928)
#define tls_sig (-1040) #define tls_sig (-1040)
#define tls_psig (2924) #define tls_psig (2932)
#define tls_incyg (-1036) #define tls_incyg (-1036)
#define tls_pincyg (2928) #define tls_pincyg (2936)
#define tls_spinning (-1032) #define tls_spinning (-1032)
#define tls_pspinning (2932) #define tls_pspinning (2940)
#define tls_stacklock (-1028) #define tls_stacklock (-1028)
#define tls_pstacklock (2936) #define tls_pstacklock (2944)
#define tls_stack (-1024) #define tls_stack (-1024)
#define tls_pstack (2940) #define tls_pstack (2948)
#define tls_padding (0) #define tls_padding (0)
#define tls_ppadding (3964) #define tls_ppadding (3972)