Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-06-10 02:33:57 +0400
committerChristopher Faylor <me@cgf.cx>2005-06-10 02:33:57 +0400
commit9a9177720555953b8761b8f22ef7f5566db0955f (patch)
treefcbbb366a27fce1bba7d724b265bb3df91970f21 /winsup/cygwin/syscalls.cc
parentfa0dcd0d650d47e33d3301f107580bbf3e7afa69 (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc34
1 files changed, 20 insertions, 14 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index e655d3684..fa92b1b46 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1565,20 +1565,17 @@ _cygwin_istext_for_stdio (int fd)
/* internal newlib function */
extern "C" int _fwalk (struct _reent *ptr, int (*function) (FILE *));
-static int setmode_mode;
-static int setmode_file;
-
static int
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;
}
syscall_printf ("file was %s now %s", f->_flags & __SCLE ? "text" : "binary",
- setmode_mode & O_TEXT ? "text" : "binary");
- if (setmode_mode & O_TEXT)
+ _my_tls.locals.setmode_mode & O_TEXT ? "text" : "binary");
+ if (_my_tls.locals.setmode_mode & O_TEXT)
f->_flags |= __SCLE;
else
f->_flags &= ~__SCLE;
@@ -1628,19 +1625,28 @@ setmode (int fd, int mode)
else
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 (),
mode, res & O_TEXT ? "text" : "binary");
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
ftruncate64 (int fd, _off64_t length)
{
int res = -1;