aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/ChangeLog26
-rw-r--r--winsup/cygwin/cygthread.cc22
-rw-r--r--winsup/cygwin/cygwin.din40
-rw-r--r--winsup/cygwin/dcrt0.cc8
-rw-r--r--winsup/cygwin/debug.cc3
-rw-r--r--winsup/cygwin/dtable.cc2
-rw-r--r--winsup/cygwin/exec.cc11
-rw-r--r--winsup/cygwin/fhandler_socket.cc20
-rw-r--r--winsup/cygwin/fork.cc9
-rw-r--r--winsup/cygwin/heap.cc2
-rw-r--r--winsup/cygwin/include/cygwin/version.h2
-rw-r--r--winsup/cygwin/mmap.cc13
-rw-r--r--winsup/cygwin/shared.cc8
-rw-r--r--winsup/cygwin/sigproc.cc37
-rw-r--r--winsup/cygwin/syscalls.cc56
-rw-r--r--winsup/cygwin/times.cc29
-rw-r--r--winsup/cygwin/wait.cc2
17 files changed, 164 insertions, 126 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 942db01..f84535e 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,29 @@
2002-10-20 Christopher Faylor <cgf@redhat.com>
+ Change _function() to function() throughout.
+ * cygwin.din: Remove last vestiges (?) of newlib wrappers.
+
+2002-10-20 Christopher Faylor <cgf@redhat.com>
+
+ * cygthread.cc (cygthread::detach): Always wait for event or suffer an
+ apparently inavoidable race.
+ * dcrt0.cc (dll_crt0_1): Allocate threads after stack has been
+ relocated.
+ * debub.cc (lock_debug): Don't acquire lock on exit.
+ * fork.cc (fork_child): Recreate mmaps before doing anything else since
+ Windows has a habit of using blocks of memory in the child that could
+ previously have been occupied by shared memory in the parent.
+ * mmap.cc (fhandler_disk_file::fixup_mmap_after_fork): Issue error here
+ and provide some details about what went wrong.
+ (fixup_mmaps_after_fork): Remove error message.
+ * shared.cc (open_shared): Move warning message so that more detail is
+ possible.
+ * sigproc.cc (sigproc_init): Initialize sync_proc_subproc to avoid a
+ race.
+ (sigproc_terminate): Specifically wait for process thread to terminate.
+
+2002-10-20 Christopher Faylor <cgf@redhat.com>
+
* cygthread.cc (cygthread::stub): Fix typo.
(cygthread::terminate): Don't zero thread handle prior to using it.
@@ -73,7 +97,7 @@
unneeded SEGV's during debugging.
2002-10-17 Thomas Pfaff <tpfaff@gmx.net>
-
+
* thread.cc (verifyable_object_isvalid): Test for static object first.
2002-10-16 Christopher Faylor <cgf@redhat.com>
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index e564ad3..7143d70 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -64,7 +64,6 @@ cygthread::stub (VOID *arg)
switch (WaitForSingleObject (info->thread_sync, INFINITE))
{
case WAIT_OBJECT_0:
- // ResetEvent (info->thread_sync);
continue;
default:
api_fatal ("WFSO failed, %E");
@@ -204,10 +203,10 @@ cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param,
__name = name; /* Need to set after thread has woken up to
ensure that it won't be cleared by exiting
thread. */
- if (thread_sync)
- SetEvent (thread_sync);
- else
+ if (!thread_sync)
ResumeThread (h);
+ else
+ SetEvent (thread_sync);
}
/* Return the symbolic name of the current thread for debugging.
@@ -269,15 +268,9 @@ cygthread::detach ()
else
{
DWORD avail = id;
- /* Checking for __name here is just a minor optimization to avoid
- an OS call. */
- if (!__name)
- thread_printf ("thread id %p returned. No need to wait.", id);
- else
- {
- DWORD res = WaitForSingleObject (*this, INFINITE);
- thread_printf ("WFSO returns %d, id %p", res, id);
- }
+ DWORD res = WaitForSingleObject (*this, INFINITE);
+ thread_printf ("WFSO returns %d, id %p", res, id);
+
if (is_freerange)
{
CloseHandle (h);
@@ -285,9 +278,8 @@ cygthread::detach ()
}
else
{
- ResetEvent (*this);
id = 0;
- __name = NULL;
+ ResetEvent (*this);
/* Mark the thread as available by setting avail to non-zero */
(void) InterlockedExchange ((LPLONG) &this->avail, avail);
}
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index b9b687f..a9c009a 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -110,8 +110,8 @@ clearerr
_clearerr = clearerr
clock
_clock = clock
-_close
-close = _close
+close
+_close = close
closedir
_closedir = closedir
copysign
@@ -217,8 +217,8 @@ fcloseall
_fcloseall = fcloseall
_fcloseall_r
fcloseall_r = _fcloseall_r
-_fcntl
-fcntl = _fcntl
+fcntl
+_fcntl = fcntl
fcvt
_fcvt = fcvt
fcvtbuf
@@ -534,8 +534,8 @@ login
logout
longjmp
_longjmp = longjmp
-_lseek
-lseek = _lseek
+lseek
+_lseek = lseek
lseek64
lstat = cygwin_lstat
_lstat = cygwin_lstat
@@ -593,8 +593,8 @@ nextafter
_nextafter = nextafter
nextafterf
_nextafterf = nextafterf
-_open
-open = _open
+open
+_open = open
opendir
_opendir = opendir
pathconf
@@ -632,8 +632,8 @@ _rand = rand
random
initstate
setstate
-_read
-read = _read
+read
+_read = read
readdir
_readdir = readdir
readlink
@@ -652,8 +652,8 @@ remainderf
_remainderf = remainderf
remove
_remove = remove
-_rename
-rename = _rename
+rename
+_rename = rename
rewind
_rewind = rewind
rewinddir
@@ -893,8 +893,8 @@ tempnam
_tempnam = tempnam
time
_time = time
-_times
-times = _times
+times
+_times = times
timezone
tmpfile
_tmpfile = tmpfile
@@ -921,8 +921,8 @@ uname
_uname = uname
ungetc
_ungetc = ungetc
-_unlink
-unlink = _unlink
+unlink
+_unlink = unlink
usleep
_usleep = usleep
utime
@@ -956,8 +956,8 @@ vsscanf
_vsscanf = vsscanf
_vsscanf_r
vsscanf_r = _vsscanf_r
-_wait
-wait = _wait
+wait
+_wait = wait
waitpid
_waitpid = waitpid
wait3
@@ -966,8 +966,8 @@ wcstombs
_wcstombs = wcstombs
wctomb
_wctomb = wctomb
-_write
-write = _write
+write
+_write = write
writev
_writev = writev
y0
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 64d5e22..febb200 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -574,8 +574,8 @@ dll_crt0_1 ()
if (!child_proc_info)
{
- memory_init ();
cygthread::init ();
+ memory_init ();
}
else
{
@@ -584,8 +584,9 @@ dll_crt0_1 ()
switch (child_proc_info->type)
{
case _PROC_FORK:
- cygheap_fixup_in_child (0);
alloc_stack (fork_info);
+ cygthread::init ();
+ cygheap_fixup_in_child (0);
close_ppid_handle = !!child_proc_info->pppid_handle;
memory_init ();
set_myself (mypid);
@@ -599,6 +600,7 @@ dll_crt0_1 ()
hexec_proc = spawn_info->hexec_proc;
around:
HANDLE h;
+ cygthread::init ();
cygheap_fixup_in_child (1);
memory_init ();
if (!spawn_info->moreinfo->myself_pinfo ||
@@ -619,7 +621,7 @@ dll_crt0_1 ()
old_title = strcpy (title_buf, spawn_info->moreinfo->old_title);
cfree (spawn_info->moreinfo->old_title);
}
- cygthread::init ();
+ // cygthread::init ();
break;
}
if (close_hexec_proc)
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index 418f355..3513a67 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -37,7 +37,8 @@ class lock_debug
public:
lock_debug () : acquired (0)
{
- if (locker)
+ extern int exit_state;
+ if (locker && !exit_state)
acquired = !!locker->acquire (INFINITE);
}
void unlock ()
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 9c363aa..be3e0da 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -476,7 +476,7 @@ dtable::dup2 (int oldfd, int newfd)
newfh->get_io_handle (), fds[oldfd]->get_io_handle ());
if (!not_open (newfd))
- _close (newfd);
+ close (newfd);
else if ((size_t) newfd < size)
/* nothing to do */;
else if (find_unused_handle (newfd) < 0)
diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc
index 942b79d..f0288dc 100644
--- a/winsup/cygwin/exec.cc
+++ b/winsup/cygwin/exec.cc
@@ -8,6 +8,7 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#define _execve __FOO_execve_
#include "winsup.h"
#include <unistd.h>
#include <stdlib.h>
@@ -20,12 +21,13 @@ details. */
#include "pinfo.h"
#include "environ.h"
#include "cygerrno.h"
+#undef _execve
/* This is called _execve and not execve because the real execve is defined
in libc/posix/execve.c. It calls us. */
extern "C" int
-_execve (const char *path, char *const argv[], char *const envp[])
+execve (const char *path, char *const argv[], char *const envp[])
{
static char *const empty_env[] = { 0 };
MALLOC_CHECK;
@@ -34,6 +36,9 @@ _execve (const char *path, char *const argv[], char *const envp[])
return spawnve (_P_OVERLAY, path, argv, envp);
}
+extern "C" int _execve (const char *, char *const [], char *const [])
+ __attribute__ ((alias ("execve")));
+
extern "C" int
execl (const char *path, const char *arg0, ...)
{
@@ -49,14 +54,14 @@ execl (const char *path, const char *arg0, ...)
while (argv[i++] != NULL);
va_end (args);
MALLOC_CHECK;
- return _execve (path, (char * const *) argv, cur_environ ());
+ return execve (path, (char * const *) argv, cur_environ ());
}
extern "C" int
execv (const char *path, char * const *argv)
{
MALLOC_CHECK;
- return _execve (path, (char * const *) argv, cur_environ ());
+ return execve (path, (char * const *) argv, cur_environ ());
}
extern "C" pid_t
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index c60ba29..eadc9b3 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -20,7 +20,6 @@
#include <asm/byteorder.h>
#include <stdlib.h>
-#include <unistd.h>
#define USE_SYS_TYPES_FD_SET
#include <winsock2.h>
#include "cygerrno.h"
@@ -33,6 +32,7 @@
#include "cygheap.h"
#include "sigproc.h"
#include "wsock_event.h"
+#include <unistd.h>
#define SECRET_EVENT_NAME "cygwin.local_socket.secret.%d.%08x-%08x-%08x-%08x"
#define ENTROPY_SOURCE_NAME "/dev/urandom"
@@ -61,7 +61,7 @@ get_inet_addr (const struct sockaddr *in, int inlen,
}
else if (in->sa_family == AF_LOCAL)
{
- int fd = _open (in->sa_data, O_RDONLY);
+ int fd = open (in->sa_data, O_RDONLY);
if (fd == -1)
return 0;
@@ -81,7 +81,7 @@ get_inet_addr (const struct sockaddr *in, int inlen,
*outlen = sizeof sin;
ret = 1;
}
- _close (fd);
+ close (fd);
return ret;
}
else
@@ -354,9 +354,7 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen)
/* bind must fail if file system socket object already exists
so _open () is called with O_EXCL flag. */
- fd = _open (un_addr->sun_path,
- O_WRONLY | O_CREAT | O_EXCL | O_BINARY,
- 0);
+ fd = ::open (un_addr->sun_path, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0);
if (fd < 0)
{
if (get_errno () == EEXIST)
@@ -372,17 +370,17 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen)
len = strlen (buf) + 1;
/* Note that the terminating nul is written. */
- if (_write (fd, buf, len) != len)
+ if (::write (fd, buf, len) != len)
{
save_errno here;
- _close (fd);
- _unlink (un_addr->sun_path);
+ ::close (fd);
+ unlink (un_addr->sun_path);
}
else
{
- _close (fd);
+ ::close (fd);
chmod (un_addr->sun_path,
- (S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO) & ~cygheap->umask);
+ (S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO) & ~cygheap->umask);
set_sun_path (un_addr->sun_path);
res = 0;
}
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 4cac097..485bd17 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -278,12 +278,12 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
MALLOC_CHECK;
- cygheap->fdtab.fixup_after_fork (hParent);
- ProtectHandleINH (hParent);
-
if (fixup_mmaps_after_fork (hParent))
api_fatal ("recreate_mmaps_after_fork_failed");
+ cygheap->fdtab.fixup_after_fork (hParent);
+ ProtectHandleINH (hParent);
+
MALLOC_CHECK;
/* If we haven't dynamically loaded any dlls, just signal
@@ -305,7 +305,6 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
if (fixup_shms_after_fork ())
api_fatal ("recreate_shm areas after fork failed");
- cygthread::init ();
pinfo_fixup_after_fork ();
signal_fixup_after_fork ();
@@ -316,8 +315,8 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
if ((*t)->clear_on_fork ())
(*t)->set ();
- wait_for_sigthread ();
pthread::atforkchild ();
+ wait_for_sigthread ();
cygbench ("fork-child");
return 0;
}
diff --git a/winsup/cygwin/heap.cc b/winsup/cygwin/heap.cc
index 1292048..c850a79 100644
--- a/winsup/cygwin/heap.cc
+++ b/winsup/cygwin/heap.cc
@@ -86,7 +86,7 @@ heap_init ()
/* FIXME: This function no longer handles "split heaps". */
extern "C" void *
-_sbrk (int n)
+sbrk (int n)
{
sigframe thisframe (mainthread);
char *newtop, *newbrk;
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 984798f..3737944 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -1,6 +1,6 @@
/* version.h -- Cygwin version numbers and accompanying documentation.
- Copyright 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
This file is part of Cygwin.
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index cb0d476..19c8e08 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -868,6 +868,13 @@ fhandler_disk_file::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
{
/* Re-create the MapViewOfFileEx call */
void *base = MapViewOfFileEx (h, access, 0, offset, size, address);
+ if (base != address)
+ {
+ MEMORY_BASIC_INFORMATION m;
+ (void) VirtualQuery (address, &m, sizeof (m));
+ system_printf ("requested %p != %p mem alloc base %p, state %p, size %d, %E",
+ address, base, m.AllocationBase, m.State, m.RegionSize);
+ }
return base == address;
}
@@ -961,11 +968,7 @@ fixup_mmaps_after_fork (HANDLE parent)
rec->free_fh (fh);
if (!ret)
- {
- system_printf ("base address fails to match requested address %p",
- rec->get_address ());
- return -1;
- }
+ return -1;
if (rec->get_access () == FILE_MAP_COPY)
{
for (char *address = rec->get_address ();
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 3ea8465..ba370f8 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -104,14 +104,14 @@ open_shared (const char *name, int n, HANDLE &shared_h, DWORD size, shared_locat
if (!shared)
{
-#ifdef DEBUGGING
- if (wincap.is_winnt ())
- system_printf ("relocating shared object %s(%d) on Windows NT", name, n);
-#endif
/* Probably win95, so try without specifying the address. */
shared = (shared_info *) MapViewOfFileEx (shared_h,
FILE_MAP_READ|FILE_MAP_WRITE,
0, 0, 0, 0);
+#ifdef DEBUGGING
+ if (wincap.is_winnt ())
+ system_printf ("relocating shared object %s(%d) from %p to %p on Windows NT", name, n, addr, shared);
+#endif
}
if (!shared)
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 4424705..9fb1fd4 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -472,6 +472,7 @@ proc_terminate (void)
ForceCloseHandle1 (zombies[i]->hProcess, childhProc);
ForceCloseHandle1 (zombies[i]->pid_handle, pid_handle);
}
+ zombies[i]->ppid = 1;
zombies[i]->process_state = PID_EXITED; /* CGF FIXME - still needed? */
zombies[i].release (); // FIXME: this breaks older gccs for some reason
}
@@ -561,6 +562,11 @@ sigproc_init ()
wait_sig_inited = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
ProtectHandle (wait_sig_inited);
+ /* sync_proc_subproc is used by proc_subproc. It serialises
+ * access to the children and zombie arrays.
+ */
+ new_muto (sync_proc_subproc);
+
/* local event signaled when main thread has been dispatched
to a signal handler function. */
signal_arrived = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
@@ -569,11 +575,6 @@ sigproc_init ()
hwait_sig = new cygthread (wait_sig, cygself, "sig");
hwait_sig->zap_h ();
- /* sync_proc_subproc is used by proc_subproc. It serialises
- * access to the children and zombie arrays.
- */
- new_muto (sync_proc_subproc);
-
/* Initialize waitq structure for main thread. A waitq structure is
* allocated for each thread that executes a wait to allow multiple threads
* to perform waits. Pre-allocate a waitq structure for the main thread.
@@ -598,6 +599,16 @@ sigproc_terminate (void)
{
hwait_sig = NULL;
+ if (!sig_loop_wait)
+ sigproc_printf ("sigproc_terminate: sigproc handling not active");
+ else
+ {
+ sigproc_printf ("entering");
+ sig_loop_wait = 0; // Tell wait_sig to exit when it is
+ // finished with anything it is doing
+ sig_dispatch_pending (1);
+ }
+
if (GetCurrentThreadId () == sigtid)
{
ForceCloseHandle (sigcomplete_main);
@@ -610,22 +621,6 @@ sigproc_terminate (void)
}
proc_terminate (); // Terminate process handling thread
- if (!sig_loop_wait)
- sigproc_printf ("sigproc_terminate: sigproc handling not active");
- else
- {
- sigproc_printf ("entering");
- sig_loop_wait = 0; // Tell wait_sig to exit when it is
- // finished with anything it is doing
- sigproc_printf ("done");
- }
-
-#if 0
- /* Set this so that subsequent tests will succeed. */
- if (!myself->dwProcessId)
- myself->dwProcessId = GetCurrentProcessId ();
-#endif
-
return;
}
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 305443f..fd571eb 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -8,6 +8,12 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
+#define _close __FOO_close__
+#define _lseek __FOO_lseek__
+#define _open __FOO_open__
+#define _read __FOO_read__
+#define _write __FOO_write__
+
#include "winsup.h"
#include <sys/stat.h>
#include <sys/vfs.h> /* needed for statfs */
@@ -40,6 +46,12 @@ details. */
#include <setjmp.h>
#include "perthread.h"
+#undef _close
+#undef _lseek
+#undef _open
+#undef _read
+#undef _write
+
SYSTEM_INFO system_info;
/* Close all files and process any queued deletions.
@@ -94,7 +106,7 @@ dup2 (int oldfd, int newfd)
}
extern "C" int
-_unlink (const char *ourname)
+unlink (const char *ourname)
{
int res = -1;
DWORD devn;
@@ -248,7 +260,7 @@ remove (const char *ourname)
return -1;
}
- return win32_name.isdir () ? rmdir (ourname) : _unlink (ourname);
+ return win32_name.isdir () ? rmdir (ourname) : unlink (ourname);
}
extern "C" pid_t
@@ -325,7 +337,7 @@ getsid (pid_t pid)
}
extern "C" ssize_t
-_read (int fd, void *ptr, size_t len)
+read (int fd, void *ptr, size_t len)
{
const struct iovec iov =
{
@@ -336,8 +348,11 @@ _read (int fd, void *ptr, size_t len)
return readv (fd, &iov, 1);
}
+extern "C" ssize_t _read (int, void *, size_t)
+ __attribute__ ((alias ("read")));
+
extern "C" ssize_t
-_write (int fd, const void *ptr, size_t len)
+write (int fd, const void *ptr, size_t len)
{
const struct iovec iov =
{
@@ -348,6 +363,9 @@ _write (int fd, const void *ptr, size_t len)
return writev (fd, &iov, 1);
}
+extern "C" ssize_t _write (int fd, const void *ptr, size_t len)
+ __attribute__ ((alias ("write")));
+
extern "C" ssize_t
readv (int fd, const struct iovec *const iov, const int iovcnt)
{
@@ -487,7 +505,7 @@ done:
/* newlib's fcntl.h defines _open as taking variable args so we must
correspond. The third arg if it exists is: mode_t mode. */
extern "C" int
-_open (const char *unix_path, int flags, ...)
+open (const char *unix_path, int flags, ...)
{
int res = -1;
va_list ap;
@@ -525,6 +543,9 @@ _open (const char *unix_path, int flags, ...)
return res;
}
+extern "C" int _open (const char *, int flags, ...)
+ __attribute__ ((alias ("open")));
+
extern "C" __off64_t
lseek64 (int fd, __off64_t pos, int dir)
{
@@ -550,13 +571,16 @@ lseek64 (int fd, __off64_t pos, int dir)
}
extern "C" __off32_t
-_lseek (int fd, __off32_t pos, int dir)
+lseek (int fd, __off32_t pos, int dir)
{
return lseek64 (fd, (__off64_t) pos, dir);
}
+extern "C" __off32_t _lseek (int, __off32_t, int)
+ __attribute__ ((alias ("lseek")));
+
extern "C" int
-_close (int fd)
+close (int fd)
{
int res;
sigframe thisframe (mainthread);
@@ -578,6 +602,8 @@ _close (int fd)
return res;
}
+extern "C" int _close (int) __attribute__ ((alias ("close")));
+
extern "C" int
isatty (int fd)
{
@@ -601,7 +627,7 @@ isatty (int fd)
*/
extern "C" int
-_link (const char *a, const char *b)
+link (const char *a, const char *b)
{
int res = -1;
sigframe thisframe (mainthread);
@@ -1231,7 +1257,7 @@ done:
}
extern "C" int
-_rename (const char *oldpath, const char *newpath)
+rename (const char *oldpath, const char *newpath)
{
sigframe thisframe (mainthread);
int res = 0;
@@ -2490,16 +2516,16 @@ setutent ()
sigframe thisframe (mainthread);
if (utmp_fd == -2)
{
- utmp_fd = _open (utmp_file, O_RDONLY);
+ utmp_fd = open (utmp_file, O_RDONLY);
}
- _lseek (utmp_fd, 0, SEEK_SET);
+ lseek (utmp_fd, 0, SEEK_SET);
}
extern "C" void
endutent ()
{
sigframe thisframe (mainthread);
- _close (utmp_fd);
+ close (utmp_fd);
utmp_fd = -2;
}
@@ -2522,7 +2548,7 @@ getutent ()
sigframe thisframe (mainthread);
if (utmp_fd == -2)
setutent ();
- if (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) != sizeof (utmp_data))
+ if (read (utmp_fd, &utmp_data, sizeof (utmp_data)) != sizeof (utmp_data))
return NULL;
return &utmp_data;
}
@@ -2533,7 +2559,7 @@ getutid (struct utmp *id)
sigframe thisframe (mainthread);
if (check_null_invalid_struct_errno (id))
return NULL;
- while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
+ while (read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
{
switch (id->ut_type)
{
@@ -2566,7 +2592,7 @@ getutline (struct utmp *line)
sigframe thisframe (mainthread);
if (check_null_invalid_struct_errno (line))
return NULL;
- while (_read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
+ while (read (utmp_fd, &utmp_data, sizeof (utmp_data)) == sizeof (utmp_data))
{
if ((utmp_data.ut_type == LOGIN_PROCESS ||
utmp_data.ut_type == USER_PROCESS) &&
diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc
index 06a98dd..d56dbab 100644
--- a/winsup/cygwin/times.cc
+++ b/winsup/cygwin/times.cc
@@ -46,7 +46,7 @@ __to_clock_t (FILETIME * src, int flag)
/* times: POSIX 4.5.2.1 */
extern "C" clock_t
-_times (struct tms * buf)
+times (struct tms *buf)
{
FILETIME creation_time, exit_time, kernel_time, user_time;
@@ -86,6 +86,8 @@ _times (struct tms * buf)
return tc;
}
+extern "C" clock_t _times (struct tms *) __attribute__((alias ("times")));
+
/* settimeofday: BSD */
extern "C" int
settimeofday (const struct timeval *tv, const struct timezone *tz)
@@ -168,11 +170,8 @@ gettimeofday (struct timeval *tv, struct timezone *tz)
return 0;
}
-extern "C" int
-_gettimeofday (struct timeval *p, struct timezone *z)
-{
- return gettimeofday (p, z);
-}
+extern "C" int _gettimeofday (struct timeval *, struct timezone *)
+ __attribute__((alias ("gettimeofday")));
/* Cygwin internal */
void
@@ -266,8 +265,7 @@ time_as_timestruc_t (timestruc_t * out)
/* time: POSIX 4.5.1.1, C 4.12.2.4 */
/* Return number of seconds since 00:00 UTC on jan 1, 1970 */
-extern "C"
-time_t
+extern "C" time_t
time (time_t * ptr)
{
time_t res;
@@ -409,8 +407,7 @@ corelocaltime (const time_t * tim_p)
* localtime takes a time_t (which is in UTC)
* and formats it into a struct tm as a local time.
*/
-extern "C"
-struct tm *
+extern "C" struct tm *
localtime (const time_t *tim_p)
{
time_t tim = *tim_p;
@@ -434,8 +431,7 @@ localtime (const time_t *tim_p)
* gmtime takes a time_t (which is already in UTC)
* and just puts it into a struct tm.
*/
-extern "C"
-struct tm *
+extern "C" struct tm *
gmtime (const time_t *tim_p)
{
time_t tim = *tim_p;
@@ -452,8 +448,7 @@ gmtime (const time_t *tim_p)
#endif /* POSIX_LOCALTIME */
/* utimes: standards? */
-extern "C"
-int
+extern "C" int
utimes (const char *path, struct timeval *tvp)
{
int res = 0;
@@ -532,8 +527,7 @@ utimes (const char *path, struct timeval *tvp)
}
/* utime: POSIX 5.6.6.1 */
-extern "C"
-int
+extern "C" int
utime (const char *path, struct utimbuf *buf)
{
struct timeval tmp[2];
@@ -549,8 +543,7 @@ utime (const char *path, struct utimbuf *buf)
}
/* ftime: standards? */
-extern "C"
-int
+extern "C" int
ftime (struct timeb *tp)
{
struct timeval tv;
diff --git a/winsup/cygwin/wait.cc b/winsup/cygwin/wait.cc
index d9588e8..9040dc5 100644
--- a/winsup/cygwin/wait.cc
+++ b/winsup/cygwin/wait.cc
@@ -21,7 +21,7 @@ details. */
extern "C"
pid_t
-_wait (int *status)
+wait (int *status)
{
return wait4 (-1, status, 0, NULL);
}