summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <cgf@redhat.com>2003-02-11 03:13:08 +0000
committerChristopher Faylor <cgf@redhat.com>2003-02-11 03:13:08 +0000
commitfcd81fa62f460d3268aa6a2a8e336f983c46f79e (patch)
treee41a41eba41d65bfedb2187dfe43d9befc9321f0
parent474fd417d16b4336e6327c3663c0cf73cebcb8c7 (diff)
downloadgdb-fcd81fa62f460d3268aa6a2a8e336f983c46f79e.tar.gz
merge from trunk
-rw-r--r--winsup/cygwin/ChangeLog21
-rw-r--r--winsup/cygwin/cygthread.cc331
-rw-r--r--winsup/cygwin/errno.cc693
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc2
-rw-r--r--winsup/cygwin/include/arpa/inet.h35
-rw-r--r--winsup/cygwin/include/cygwin/in.h187
-rw-r--r--winsup/cygwin/include/cygwin/types.h234
-rw-r--r--winsup/cygwin/pipe.cc3
-rw-r--r--winsup/cygwin/security.cc10
-rw-r--r--winsup/cygwin/security.h4
-rw-r--r--winsup/cygwin/syscalls.cc4
11 files changed, 1513 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 5e8356ce7cb..70b40c6d3a7 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,24 @@
+2003-02-10 Ralf Habacker <ralf.habacker@freenet.de>
+
+ * include/cygwin/in.h (in_attr_t): Define new type.
+ * include/arpa/inet.h (inet_addr): Change return type to in_addr_t.
+ (inet_lnaof): Ditto.
+ (inet_netof): Ditto.
+ (inet_network): Ditto.
+
+2003-02-10 Christopher Faylor <cgf@redhat.com>
+
+ * include/cygwin/types.h: Move many *_t typedefs here. Protect them
+ with ifdefs.
+ * fhandler_disk_file.cc (fhandler_disk_file::fstat): Change ntsec_atts to mode_t.
+ * security.cc (get_attribute_from_acl): Accept mode_t attribute.
+ (get_nt_attribute): Ditto.
+ (get_file_attribute): Ditto.
+ (get_nt_object_attribute): Ditto.
+ (get_object_attribute): Ditto.
+ * security.h: Reflect above changes.
+ * syscalls.cc (chown_worker): Change attrib to mode_t.
+
2003-02-08 Christopher Faylor <cgf@redhat.com>
* include/cygwin/version.h: Bump DLL minor number to 21.
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
new file mode 100644
index 00000000000..2099f19bea5
--- /dev/null
+++ b/winsup/cygwin/cygthread.cc
@@ -0,0 +1,331 @@
+/* cygthread.cc
+
+ Copyright 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#include "winsup.h"
+#include <windows.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "exceptions.h"
+#include "security.h"
+#include "cygthread.h"
+#include "sync.h"
+#include "cygerrno.h"
+#include "sigproc.h"
+
+#undef CloseHandle
+
+static cygthread NO_COPY threads[18];
+#define NTHREADS (sizeof (threads) / sizeof (threads[0]))
+
+DWORD NO_COPY cygthread::main_thread_id;
+bool NO_COPY cygthread::exiting;
+
+/* Initial stub called by cygthread constructor. Performs initial
+ per-thread initialization and loops waiting for new thread functions
+ to execute. */
+DWORD WINAPI
+cygthread::stub (VOID *arg)
+{
+ DECLARE_TLS_STORAGE;
+ exception_list except_entry;
+
+ /* Initialize this thread's ability to respond to things like
+ SIGSEGV or SIGFPE. */
+ init_exceptions (&except_entry);
+
+ cygthread *info = (cygthread *) arg;
+ if (info->arg == cygself)
+ info->ev = info->thread_sync = info->stack_ptr = NULL;
+ else
+ {
+ info->ev = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
+ info->thread_sync = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
+ info->stack_ptr = &arg;
+ }
+ while (1)
+ {
+ if (!info->__name)
+ system_printf ("erroneous thread activation");
+ else
+ {
+ if (!info->func || exiting)
+ ExitThread (0);
+
+ /* Cygwin threads should not call ExitThread directly */
+ info->func (info->arg == cygself ? info : info->arg);
+ /* ...so the above should always return */
+
+#ifdef DEBUGGING
+ info->func = NULL; // catch erroneous activation
+#endif
+ info->__name = NULL;
+ SetEvent (info->ev);
+ }
+ switch (WaitForSingleObject (info->thread_sync, INFINITE))
+ {
+ case WAIT_OBJECT_0:
+ continue;
+ default:
+ api_fatal ("WFSO failed, %E");
+ break;
+ }
+ }
+}
+
+/* Overflow stub called by cygthread constructor. Calls specified function
+ and then exits the thread. */
+DWORD WINAPI
+cygthread::simplestub (VOID *arg)
+{
+ DECLARE_TLS_STORAGE;
+ exception_list except_entry;
+
+ /* Initialize this thread's ability to respond to things like
+ SIGSEGV or SIGFPE. */
+ init_exceptions (&except_entry);
+
+ cygthread *info = (cygthread *) arg;
+ info->func (info->arg == cygself ? info : info->arg);
+ ExitThread (0);
+}
+
+static NO_COPY muto *cygthread_protect;
+/* Start things going. Called from dll_crt0_1. */
+void
+cygthread::init ()
+{
+ new_muto (cygthread_protect);
+ main_thread_id = GetCurrentThreadId ();
+}
+
+bool
+cygthread::is ()
+{
+ DWORD tid = GetCurrentThreadId ();
+
+ for (DWORD i = 0; i < NTHREADS; i++)
+ if (threads[i].id == tid)
+ return 1;
+
+ return 0;
+}
+
+cygthread *
+cygthread::freerange ()
+{
+ cygthread *self = (cygthread *) calloc (1, sizeof (*self));
+ self->is_freerange = true;
+ self->h = CreateThread (&sec_none_nih, 0, cygthread::simplestub, self,
+ CREATE_SUSPENDED, &self->id);
+ self->ev = self->h;
+ return self;
+}
+
+void * cygthread::operator
+new (size_t)
+{
+ DWORD id;
+ cygthread *info;
+
+ cygthread_protect->acquire ();
+
+ /* Search the threads array for an empty slot to use */
+ for (info = threads; info < threads + NTHREADS; info++)
+ if ((id = (DWORD) InterlockedExchange ((LPLONG) &info->avail, 0)))
+ {
+#ifdef DEBUGGING
+ if (info->__name)
+ api_fatal ("name not NULL? id %p, i %d", id, info - threads);
+#endif
+ goto out;
+ }
+ else if (!info->id)
+ {
+ info->h = CreateThread (&sec_none_nih, 0, cygthread::stub, info,
+ CREATE_SUSPENDED, &info->id);
+ goto out;
+ }
+
+#ifdef DEBUGGING
+ char buf[1024];
+ if (!GetEnvironmentVariable ("CYGWIN_NOFREERANGE_NOCHECK", buf, sizeof (buf)))
+ api_fatal ("Overflowed cygwin thread pool");
+#endif
+
+ info = freerange (); /* exhausted thread pool */
+
+out:
+ cygthread_protect->release ();
+ return info;
+}
+
+cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param,
+ const char *name): func (start), arg (param)
+{
+#ifdef DEBUGGGING
+ if (!__name)
+ api_fatal ("name should never be NULL");
+#endif
+ thread_printf ("name %s, id %p", name, id);
+ while (!h)
+#ifndef DEBUGGING
+ low_priority_sleep (0);
+#else
+ {
+ system_printf ("waiting for %s<%p> to become active", __name, h);
+ low_priority_sleep (0);
+ }
+#endif
+ __name = name;
+ if (!thread_sync)
+ ResumeThread (h);
+ else
+ SetEvent (thread_sync);
+}
+
+/* Return the symbolic name of the current thread for debugging.
+ */
+const char *
+cygthread::name (DWORD tid)
+{
+ const char *res = NULL;
+ if (!tid)
+ tid = GetCurrentThreadId ();
+
+ if (tid == main_thread_id)
+ return "main";
+
+ for (DWORD i = 0; i < NTHREADS; i++)
+ if (threads[i].id == tid)
+ {
+ res = threads[i].__name ?: "exiting thread";
+ break;
+ }
+
+ if (!res)
+ {
+ static char buf[30] NO_COPY = {0};
+ __small_sprintf (buf, "unknown (%p)", tid);
+ res = buf;
+ }
+
+ return res;
+}
+
+cygthread::operator
+HANDLE ()
+{
+ while (!ev)
+ low_priority_sleep (0);
+ return ev;
+}
+
+/* Should only be called when the process is exiting since it
+ leaves an open thread slot. */
+void
+cygthread::exit_thread ()
+{
+ if (!is_freerange)
+ SetEvent (*this);
+ ExitThread (0);
+}
+
+/* Forcibly terminate a thread. */
+void
+cygthread::terminate_thread ()
+{
+ if (!is_freerange)
+ SetEvent (*this);
+ (void) TerminateThread (h, 0);
+ (void) WaitForSingleObject (h, INFINITE);
+
+ MEMORY_BASIC_INFORMATION m;
+ memset (&m, 0, sizeof (m));
+ (void) VirtualQuery (stack_ptr, &m, sizeof m);
+
+ if (m.RegionSize)
+ (void) VirtualFree (m.AllocationBase, m.RegionSize, MEM_DECOMMIT);
+
+ if (is_freerange)
+ is_freerange = false;
+ else
+ {
+ CloseHandle (ev);
+ CloseHandle (thread_sync);
+ }
+ CloseHandle (h);
+ thread_sync = ev = h = NULL;
+ __name = NULL;
+ id = 0;
+}
+
+/* Detach the cygthread from the current thread. Note that the
+ theory is that cygthreads are only associated with one thread.
+ So, there should be no problems with multiple threads doing waits
+ on the one cygthread. */
+bool
+cygthread::detach (HANDLE sigwait)
+{
+ bool signalled = false;
+ if (avail)
+ system_printf ("called detach on available thread %d?", avail);
+ else
+ {
+ DWORD newavail = id;
+ DWORD res;
+
+ if (!sigwait)
+ res = WaitForSingleObject (*this, INFINITE);
+ else
+ {
+ HANDLE w4[2];
+ w4[0] = signal_arrived;
+ w4[1] = *this;
+ res = WaitForSingleObject (sigwait, INFINITE);
+ if (res != WAIT_OBJECT_0)
+ system_printf ("WFSO sigwait failed, res %u", res);
+ res = WaitForMultipleObjects (2, w4, FALSE, INFINITE);
+ if (res != WAIT_OBJECT_0)
+ /* nothing */;
+ else if (WaitForSingleObject (sigwait, 5) == WAIT_OBJECT_0)
+ res = WaitForSingleObject (*this, INFINITE);
+ else
+ {
+ terminate_thread ();
+ set_sig_errno (EINTR); /* caller should be dealing with return
+ values. */
+ newavail = 0;
+ signalled = true;
+ }
+ }
+
+ thread_printf ("%s returns %d, id %p", sigwait ? "WFMO" : "WFSO",
+ res, id);
+
+ if (!newavail)
+ /* already handled */;
+ else if (is_freerange)
+ {
+ CloseHandle (h);
+ free (this);
+ }
+ else
+ {
+ ResetEvent (*this);
+ /* Mark the thread as available by setting avail to non-zero */
+ (void) InterlockedExchange ((LPLONG) &avail, newavail);
+ }
+ }
+ return signalled;
+}
+
+void
+cygthread::terminate ()
+{
+ exiting = 1;
+}
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
new file mode 100644
index 00000000000..9b26afcd1b1
--- /dev/null
+++ b/winsup/cygwin/errno.cc
@@ -0,0 +1,693 @@
+/* errno.cc: errno-related functions
+
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#define _sys_nerr FOO_sys_nerr
+#define sys_nerr FOOsys_nerr
+#include "winsup.h"
+#define _REENT_ONLY
+#include <stdio.h>
+#include <errno.h>
+#include "cygerrno.h"
+#include "thread.h"
+#undef _sys_nerr
+#undef sys_nerr
+
+/* Table to map Windows error codes to Errno values. */
+/* FIXME: Doing things this way is a little slow. It's trivial to change
+ this into a big case statement if necessary. Left as is for now. */
+
+#define X(w, e) {ERROR_##w, #w, e}
+
+static const NO_COPY struct
+ {
+ DWORD w; /* windows version of error */
+ const char *s; /* text of windows version */
+ int e; /* errno version of error */
+ }
+errmap[] =
+{
+ /* FIXME: Some of these choices are arbitrary! */
+ X (INVALID_FUNCTION, EBADRQC),
+ X (FILE_NOT_FOUND, ENOENT),
+ X (PATH_NOT_FOUND, ENOENT),
+ X (TOO_MANY_OPEN_FILES, EMFILE),
+ X (ACCESS_DENIED, EACCES),
+ X (INVALID_HANDLE, EBADF),
+ X (NOT_ENOUGH_MEMORY, ENOMEM),
+ X (INVALID_DATA, EINVAL),
+ X (OUTOFMEMORY, ENOMEM),
+ X (INVALID_DRIVE, ENODEV),
+ X (NOT_SAME_DEVICE, EXDEV),
+ X (NO_MORE_FILES, ENMFILE),
+ X (WRITE_PROTECT, EROFS),
+ X (BAD_UNIT, ENODEV),
+ X (SHARING_VIOLATION, EACCES),
+ X (LOCK_VIOLATION, EACCES),
+ X (SHARING_BUFFER_EXCEEDED, ENOLCK),
+ X (HANDLE_EOF, ENODATA),
+ X (HANDLE_DISK_FULL, ENOSPC),
+ X (NOT_SUPPORTED, ENOSYS),
+ X (REM_NOT_LIST, ENONET),
+ X (DUP_NAME, ENOTUNIQ),
+ X (BAD_NETPATH, ENOSHARE),
+ X (BAD_NET_NAME, ENOSHARE),
+ X (FILE_EXISTS, EEXIST),
+ X (CANNOT_MAKE, EPERM),
+ X (INVALID_PARAMETER, EINVAL),
+ X (NO_PROC_SLOTS, EAGAIN),
+ X (BROKEN_PIPE, EPIPE),
+ X (OPEN_FAILED, EIO),
+ X (NO_MORE_SEARCH_HANDLES, ENFILE),
+ X (CALL_NOT_IMPLEMENTED, ENOSYS),
+ X (INVALID_NAME, ENOENT),
+ X (WAIT_NO_CHILDREN, ECHILD),
+ X (CHILD_NOT_COMPLETE, EBUSY),
+ X (DIR_NOT_EMPTY, ENOTEMPTY),
+ X (SIGNAL_REFUSED, EIO),
+ X (BAD_PATHNAME, ENOENT),
+ X (SIGNAL_PENDING, EBUSY),
+ X (MAX_THRDS_REACHED, EAGAIN),
+ X (BUSY, EBUSY),
+ X (ALREADY_EXISTS, EEXIST),
+ X (NO_SIGNAL_SENT, EIO),
+ X (FILENAME_EXCED_RANGE, EINVAL),
+ X (META_EXPANSION_TOO_LONG, EINVAL),
+ X (INVALID_SIGNAL_NUMBER, EINVAL),
+ X (THREAD_1_INACTIVE, EINVAL),
+ X (BAD_PIPE, EINVAL),
+ X (PIPE_BUSY, EBUSY),
+ X (NO_DATA, EPIPE),
+ X (PIPE_NOT_CONNECTED, ECOMM),
+ X (MORE_DATA, EAGAIN),
+ X (DIRECTORY, ENOTDIR),
+ X (PIPE_CONNECTED, EBUSY),
+ X (PIPE_LISTENING, ECOMM),
+ X (NO_TOKEN, EINVAL),
+ X (PROCESS_ABORTED, EFAULT),
+ X (BAD_DEVICE, ENODEV),
+ X (BAD_USERNAME, EINVAL),
+ X (NOT_CONNECTED, ENOLINK),
+ X (OPEN_FILES, EAGAIN),
+ X (ACTIVE_CONNECTIONS, EAGAIN),
+ X (DEVICE_IN_USE, EAGAIN),
+ X (INVALID_AT_INTERRUPT_TIME, EINTR),
+ X (IO_DEVICE, EIO),
+ X (NOT_OWNER, EPERM),
+ X (END_OF_MEDIA, ENOSPC),
+ X (EOM_OVERFLOW, ENOSPC),
+ X (BEGINNING_OF_MEDIA, ESPIPE),
+ X (SETMARK_DETECTED, ESPIPE),
+ X (NO_DATA_DETECTED, ENOSPC),
+ X (POSSIBLE_DEADLOCK, EDEADLOCK),
+ X (CRC, EIO),
+ X (NEGATIVE_SEEK, EINVAL),
+ X (NOT_READY, ENOMEDIUM),
+ X (DISK_FULL, ENOSPC),
+ X (NOACCESS, EFAULT),
+ X (FILE_INVALID, ENXIO),
+ X (INVALID_ADDRESS, EOVERFLOW),
+ { 0, NULL, 0}
+};
+
+int __stdcall
+geterrno_from_win_error (DWORD code, int deferrno)
+{
+ for (int i = 0; errmap[i].w != 0; ++i)
+ if (code == errmap[i].w)
+ {
+ syscall_printf ("windows error %u == errno %d", code, errmap[i].e);
+ return errmap[i].e;
+ }
+
+ syscall_printf ("unknown windows error %u, setting errno to %d", code,
+ deferrno);
+ return deferrno; /* FIXME: what's so special about EACCESS? */
+}
+
+/* seterrno_from_win_error: Given a Windows error code, set errno
+ as appropriate. */
+void __stdcall
+seterrno_from_win_error (const char *file, int line, DWORD code)
+{
+ syscall_printf ("%s:%d windows error %d", file, line, code);
+ set_errno (geterrno_from_win_error (code, EACCES));
+ return;
+}
+
+/* seterrno: Set `errno' based on GetLastError (). */
+void __stdcall
+seterrno (const char *file, int line)
+{
+ seterrno_from_win_error (file, line, GetLastError ());
+}
+
+extern char *_user_strerror _PARAMS ((int));
+
+extern "C" {
+const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
+{
+/* NOERROR 0 */ "No error",
+/* EPERM 1 */ "Operation not permitted",
+/* ENOENT 2 */ "No such file or directory",
+/* ESRCH 3 */ "No such process",
+/* EINTR 4 */ "Interrupted system call",
+/* EIO 5 */ "I/O error",
+/* ENXIO 6 */ "No such device or address",
+/* E2BIG 7 */ "Arg list too long",
+/* ENOEXEC 8 */ "Exec format error",
+/* EBADF 9 */ "Bad file descriptor",
+/* ECHILD 10 */ "No children",
+/* EAGAIN 11 */ "Resource temporarily unavailable",
+/* ENOMEM 12 */ "Not enough core",
+/* EACCES 13 */ "Permission denied",
+/* EFAULT 14 */ "Bad address",
+/* ENOTBLK 15 */ "Block device required",
+/* EBUSY 16 */ "Mount device busy",
+/* EEXIST 17 */ "File exists",
+/* EXDEV 18 */ "Cross-device link",
+/* ENODEV 19 */ "No such device",
+/* ENOTDIR 20 */ "Not a directory",
+/* EISDIR 21 */ "Is a directory",
+/* EINVAL 22 */ "Invalid argument",
+/* ENFILE 23 */ "Too many open files in system",
+/* EMFILE 24 */ "Too many open files",
+/* ENOTTY 25 */ "Not a typewriter",
+/* ETXTBSY 26 */ "Text file busy",
+/* EFBIG 27 */ "File too large",
+/* ENOSPC 28 */ "No space left on device",
+/* ESPIPE 29 */ "Illegal seek",
+/* EROFS 30 */ "Read only file system",
+/* EMLINK 31 */ "Too many links",
+/* EPIPE 32 */ "Broken pipe",
+/* EDOM 33 */ "Math arg out of domain of func",
+/* ERANGE 34 */ "Math result not representable",
+/* ENOMSG 35 */ "No message of desired type",
+/* EIDRM 36 */ "Identifier removed",
+/* ECHRNG 37 */ "Channel number out of range",
+/* EL2NSYNC 38 */ "Level 2 not synchronized",
+/* EL3HLT 39 */ "Level 3 halted",
+/* EL3RST 40 */ "Level 3 reset",
+/* ELNRNG 41 */ "Link number out of range",
+/* EUNATCH 42 */ "Protocol driver not attached",
+/* ENOCSI 43 */ "No CSI structure available",
+/* EL2HLT 44 */ "Level 2 halted",
+/* EDEADLK 45 */ "Deadlock condition",
+/* ENOLCK 46 */ "No record locks available",
+ "47",
+ "48",
+ "49",
+/* EBADE 50 */ "Invalid exchange",
+/* EBADR 51 */ "Invalid request descriptor",
+/* EXFULL 52 */ "Exchange full",
+/* ENOANO 53 */ "No anode",
+/* EBADRQC 54 */ "Invalid request code",
+/* EBADSLT 55 */ "Invalid slot",
+/* EDEADLOCK 56 */ "File locking deadlock error",
+/* EBFONT 57 */ "Bad font file fmt",
+ "58",
+ "59",
+/* ENOSTR 60 */ "Device not a stream",
+/* ENODATA 61 */ "No data (for no delay io)",
+/* ETIME 62 */ "Timer expired",
+/* ENOSR 63 */ "Out of streams resources",
+/* ENONET 64 */ "Machine is not on the network",
+/* ENOPKG 65 */ "Package not installed",
+/* EREMOTE 66 */ "The object is remote",
+/* ENOLINK 67 */ "The link has been severed",
+/* EADV 68 */ "Advertise error",
+/* ESRMNT 69 */ "Srmount error",
+/* ECOMM 70 */ "Communication error on send",
+/* EPROTO 71 */ "Protocol error",
+ "72",
+ "73",
+/* EMULTIHOP 74 */ "Multihop attempted",
+/* ELBIN 75 */ "Inode is remote (not really error)",
+/* EDOTDOT 76 */ "Cross mount point (not really error)",
+/* EBADMSG 77 */ "Trying to read unreadable message",
+ "78",
+ "79",
+/* ENOTUNIQ 80 */ "Given log. name not unique",
+/* EBADFD 81 */ "f.d. invalid for this operation",
+/* EREMCHG 82 */ "Remote address changed",
+/* ELIBACC 83 */ "Can't access a needed shared lib",
+/* ELIBBAD 84 */ "Accessing a corrupted shared lib",
+/* ELIBSCN 85 */ ".lib section in a.out corrupted",
+/* ELIBMAX 86 */ "Attempting to link in too many libs",
+/* ELIBEXEC 87 */ "Attempting to exec a shared library",
+/* ENOSYS 88 */ "Function not implemented",
+/* ENMFILE 89 */ "No more files",
+/* ENOTEMPTY 90 */ "Directory not empty",
+/* ENAMETOOLONG 91 */ "File or path name too long",
+/* ELOOP 92 */ "Too many symbolic links",
+ "93",
+ "94",
+/* EOPNOTSUPP 95 */ "Operation not supported on transport endpoint",
+/* EPFNOSUPPORT 96 */ "Protocol family not supported",
+ "97",
+ "98",
+ "99",
+ "100",
+ "101",
+ "102",
+ "103",
+/* ECONNRESET 104 */ "Connection reset by peer",
+/* ENOBUFS 105 */ "No buffer space available",
+/* EAFNOSUPPORT 106 */ "Address family not supported by protocol",
+/* EPROTOTYPE 107 */ "Protocol wrong type for transport endpoint",
+/* ENOTSOCK 108 */ "Socket operation on non-socket",
+/* ENOPROTOOPT 109 */ "Protocol not available",
+/* ESHUTDOWN 110 */ "Cannot send after transport endpoint shutdown",
+/* ECONNREFUSED 111 */ "Connection refused",
+/* EADDRINUSE 112 */ "Address already in use",
+/* ECONNABORTED 113 */ "Connection aborted",
+/* ENETUNREACH 114 */ "Network is unreachable",
+/* ENETDOWN 115 */ "Network is down",
+/* ETIMEDOUT 116 */ "Connection timed out",
+/* EHOSTDOWN 117 */ "Host is down",
+/* EHOSTUNREACH 118 */ "No route to host",
+/* EINPROGRESS 119 */ "Operation now in progress",
+/* EALREADY 120 */ "Operation already in progress",
+/* EDESTADDRREQ 121 */ "Destination address required",
+/* EMSGSIZE 122 */ "Message too long",
+/* EPROTONOSUPPORT 123 */ "Protocol not supported",
+/* ESOCKTNOSUPPORT 124 */ "Socket type not supported",
+/* EADDRNOTAVAIL 125 */ "Cannot assign requested address",
+/* ENETRESET 126 */ "Network dropped connection because of reset",
+/* EISCONN 127 */ "Transport endpoint is already connected",
+/* ENOTCONN 128 */ "Transport endpoint is not connected",
+/* ETOOMANYREFS 129 */ "Too many references: cannot splice",
+/* EPROCLIM 130 */ "Process limit exceeded",
+/* EUSERS 131 */ "Too many users",
+/* EDQUOT 132 */ "Quota exceeded",
+/* ESTALE 133 */ "Stale NFS file handle",
+/* ENOTSUP 134 */ "134",
+/* ENOMEDIUM 135 */ "no medium",
+/* ENOSHARE 136 */ "No such host or network path",
+/* ECASECLASH 137 */ "Filename exists with different case"
+/* EILSEQ 138 */ "Illegal byte sequence"
+/* EOVERFLOW 139 */ "Value too large for defined data type"
+};
+
+extern int const NO_COPY __declspec(dllexport) _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
+};
+
+/* FIXME: Why is strerror() a long switch and not just:
+ return sys_errlist[errnum];
+ (or moral equivalent).
+ Some entries in sys_errlist[] don't match the corresponding
+ entries in strerror(). This seems odd.
+*/
+
+/* CYGWIN internal */
+/* strerror: convert from errno values to error strings */
+extern "C" char *
+strerror (int errnum)
+{
+ const char *error;
+ if (errnum < _sys_nerr)
+ error = _sys_errlist [errnum];
+ else
+ switch (errnum)
+ {
+ case EPERM:
+ error = "Operation not permitted";
+ break;
+ case ENOENT:
+ error = "No such file or directory";
+ break;
+ case ESRCH:
+ error = "No such process";
+ break;
+ case EINTR:
+ error = "Interrupted system call";
+ break;
+ case EIO:
+ error = "I/O error";
+ break;
+ case ENXIO:
+ error = "No such device or address";
+ break;
+ case E2BIG:
+ error = "Arg list too long";
+ break;
+ case ENOEXEC:
+ error = "Exec format error";
+ break;
+ case EBADF:
+ error = "Bad file descriptor";
+ break;
+ case ECHILD:
+ error = "No children";
+ break;
+ case EAGAIN:
+ error = "Resource temporarily unavailable";
+ break;
+ case ENOMEM:
+ error = "Not enough memory";
+ break;
+ case EACCES:
+ error = "Permission denied";
+ break;
+ case EFAULT:
+ error = "Bad address";
+ break;
+ case ENOTBLK:
+ error = "Block device required";
+ break;
+ case EBUSY:
+ error = "Device or resource busy";
+ break;
+ case EEXIST:
+ error = "File exists";
+ break;
+ case EXDEV:
+ error = "Cross-device link";
+ break;
+ case ENODEV:
+ error = "No such device";
+ break;
+ case ENOTDIR:
+ error = "Not a directory";
+ break;
+ case EISDIR:
+ error = "Is a directory";
+ break;
+ case EINVAL:
+ error = "Invalid argument";
+ break;
+ case ENFILE:
+ error = "Too many open files in system";
+ break;
+ case EMFILE:
+ error = "Too many open files";
+ break;
+ case ENOTTY:
+ error = "Not a character device";
+ break;
+ case ETXTBSY:
+ error = "Text file busy";
+ break;
+ case EFBIG:
+ error = "File too large";
+ break;
+ case ENOSPC:
+ error = "No space left on device";
+ break;
+ case ESPIPE:
+ error = "Illegal seek";
+ break;
+ case EROFS:
+ error = "Read-only file system";
+ break;
+ case EMLINK:
+ error = "Too many links";
+ break;
+ case EPIPE:
+ error = "Broken pipe";
+ break;
+ case EDOM:
+ error = "Math arg out of domain of func";
+ break;
+ case ERANGE:
+ error = "Math result out of range";
+ break;
+ case ENOMSG:
+ error = "No message of desired type";
+ break;
+ case EIDRM:
+ error = "Identifier removed";
+ break;
+ case ECHRNG:
+ error = "Channel number out of range";
+ break;
+ case EL2NSYNC:
+ error = "Level 2 not synchronized";
+ break;
+ case EL3HLT:
+ error = "Level 3 halted";
+ break;
+ case EL3RST:
+ error = "Level 3 reset";
+ break;
+ case ELNRNG:
+ error = "Link number out of range";
+ break;
+ case EUNATCH:
+ error = "Protocol driver not attached";
+ break;
+ case ENOCSI:
+ error = "No CSI structure available";
+ break;
+ case EL2HLT:
+ error = "Level 2 halted";
+ break;
+ case EDEADLK:
+ error = "Deadlock condition";
+ break;
+ case ENOLCK:
+ error = "No lock";
+ break;
+ case EBADE:
+ error = "Invalid exchange";
+ break;
+ case EBADR:
+ error = "Invalid request descriptor";
+ break;
+ case EXFULL:
+ error = "Exchange full";
+ break;
+ case ENOANO:
+ error = "No anode";
+ break;
+ case EBADRQC:
+ error = "Invalid request code";
+ break;
+ case EBADSLT:
+ error = "Invalid slot";
+ break;
+ case EDEADLOCK:
+ error = "File locking deadlock error";
+ break;
+ case EBFONT:
+ error = "Bad font file fmt";
+ break;
+ case ENOSTR:
+ error = "Not a stream";
+ break;
+ case ENODATA:
+ error = "No data (for no delay io)";
+ break;
+ case ETIME:
+ error = "Stream ioctl timeout";
+ break;
+ case ENOSR:
+ error = "No stream resources";
+ break;
+ case ENONET:
+ error = "Machine is not on the network";
+ break;
+ case ENOPKG:
+ error = "No package";
+ break;
+ case EREMOTE:
+ error = "Resource is remote";
+ break;
+ case ENOLINK:
+ error = "Virtual circuit is gone";
+ break;
+ case EADV:
+ error = "Advertise error";
+ break;
+ case ESRMNT:
+ error = "Srmount error";
+ break;
+ case ECOMM:
+ error = "Communication error";
+ break;
+ case EPROTO:
+ error = "Protocol error";
+ break;
+ case EMULTIHOP:
+ error = "Multihop attempted";
+ break;
+ case ELBIN:
+ error = "Inode is remote (not really error)";
+ break;
+ case EDOTDOT:
+ error = "Cross mount point (not really error)";
+ break;
+ case EBADMSG:
+ error = "Bad message";
+ break;
+ case ENOTUNIQ:
+ error = "Given log. name not unique";
+ break;
+ case EBADFD:
+ error = "f.d. invalid for this operation";
+ break;
+ case EREMCHG:
+ error = "Remote address changed";
+ break;
+ case ELIBACC:
+ error = "Cannot access a needed shared library";
+ break;
+ case ELIBBAD:
+ error = "Accessing a corrupted shared library";
+ break;
+ case ELIBSCN:
+ error = ".lib section in a.out corrupted";
+ break;
+ case ELIBMAX:
+ error = "Attempting to link in more shared libraries than system limit";
+ break;
+ case ELIBEXEC:
+ error = "Cannot exec a shared library directly";
+ break;
+ case ENOSYS:
+ error = "Function not implemented";
+ break;
+ case ENMFILE:
+ error = "No more files";
+ break;
+ case ENOTEMPTY:
+ error = "Directory not empty";
+ break;
+ case ENAMETOOLONG:
+ error = "File or path name too long";
+ break;
+ case ELOOP:
+ error = "Too many symbolic links";
+ break;
+ case EOPNOTSUPP:
+ error = "Operation not supported on transport endpoint";
+ break;
+ case EPFNOSUPPORT:
+ error = "Protocol family not supported";
+ break;
+ case ECONNRESET:
+ error = "Connection reset by peer";
+ break;
+ case ENOBUFS:
+ error = "No buffer space available; the socket cannot be connected";
+ break;
+ case EAFNOSUPPORT:
+ error = "Addresses in the specified family cannot be used with this socket";
+ break;
+ case EPROTOTYPE:
+ error = "errno EPROTOTYPE triggered";
+ break;
+ case ENOTSOCK:
+ error = "The descriptor is a file, not a socket";
+ break;
+ case ENOPROTOOPT:
+ error = "This option is unsupported";
+ break;
+ case ESHUTDOWN:
+ error = "errno ESHUTDOWN triggered";
+ break;
+ case ECONNREFUSED:
+ error = "Connection refused";
+ break;
+ case EADDRINUSE:
+ error = "Address already in use";
+ break;
+ case ECONNABORTED:
+ error = "The connection was aborted";
+ break;
+ case ENETUNREACH:
+ error ="The network can't be reached from this host at this time";
+ break;
+ case ENETDOWN:
+ error = "Network failed.";
+ break;
+ case ETIMEDOUT:
+ error = "Attempt to connect timed out without establishing a connection";
+ break;
+ case EHOSTDOWN:
+ error = "errno EHOSTDOWN triggered";
+ break;
+ case EHOSTUNREACH:
+ error = "errno EHOSTUNREACH triggered";
+ break;
+ case EINPROGRESS:
+ error = "errno EINPROGRESS triggered";
+ break;
+ case EALREADY:
+ error = "errno EALREADY triggered";
+ break;
+ case EDESTADDRREQ:
+ error = "errno EDESTADDRREQ triggered";
+ break;
+ case EMSGSIZE:
+ error = "errno EMSGSIZE triggered";
+ break;
+
+ case EPROTONOSUPPORT:
+ error = "errno EPROTONOSUPPORT triggered";
+ break;
+ case ESOCKTNOSUPPORT:
+ error = "errno ESOCKTNOSUPPORT triggered";
+ break;
+ case EADDRNOTAVAIL:
+ error = "errno EADDRNOTAVAIL triggered";
+ break;
+ case ENETRESET:
+ error = "errno ENETRESET triggered";
+ break;
+ case EISCONN:
+ error = "The socket is already connected";
+ break;
+ case ENOTCONN:
+ error = "The socket is not connected";
+ break;
+ case ETOOMANYREFS:
+ error = "errno ETOOMANYREFS triggered";
+ break;
+ case EPROCLIM:
+ error = "errno EPROCLIM triggered";
+ break;
+ case EUSERS:
+ error = "errno EUSERS triggered";
+ break;
+ case EDQUOT:
+ error = "errno EDQUOT triggered";
+ break;
+ case ESTALE:
+ error = "errno ESTALE triggered";
+ break;
+ case ENOTSUP:
+ error = "errno ENOTSUP triggered";
+ break;
+ case ENOMEDIUM:
+ error = "no medium";
+ break;
+ case ENOSHARE:
+ error = "No such host or network path";
+ break;
+ case ECASECLASH:
+ error = "Filename exists with different case";
+ break;
+ case EILSEQ:
+ error = "Illegal byte sequence";
+ break;
+ case EOVERFLOW:
+ error = "Value too large for defined data type";
+ break;
+ default:
+ char *buf= _reent_winsup ()->_strerror_buf;
+ __small_sprintf (buf, "error %d", errnum);
+ error = buf;
+ break;
+ }
+
+ /* FIXME: strerror should really be const in the appropriate newlib
+ include files. */
+ return (char *) error;
+}
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 6f383278dbf..01df5f2ccb4 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -180,7 +180,7 @@ fhandler_base::fstat_fs (struct __stat64 *buf, path_conv *pc)
oret = 0;
else if (!(oret = open_fs (pc, open_flags, 0)))
{
- int ntsec_atts = 0;
+ mode_t ntsec_atts = 0;
/* If we couldn't open the file, try a "query open" with no permissions.
This will allow us to determine *some* things about the file, at least. */
set_query_open (true);
diff --git a/winsup/cygwin/include/arpa/inet.h b/winsup/cygwin/include/arpa/inet.h
new file mode 100644
index 00000000000..284e98e401e
--- /dev/null
+++ b/winsup/cygwin/include/arpa/inet.h
@@ -0,0 +1,35 @@
+/* arpa/inet.h
+
+ Copyright 1997, 1998, 2001, 2002, 2003 Red Hat, Inc.
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _ARPA_INET_H
+#define _ARPA_INET_H
+
+#include <netinet/in.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifndef __INSIDE_CYGWIN_NET__
+in_addr_t inet_addr (const char *);
+int inet_aton (const char *, struct in_addr *);
+in_addr_t inet_lnaof (struct in_addr);
+struct in_addr inet_makeaddr (unsigned long , unsigned long);
+in_addr_t inet_netof (struct in_addr);
+in_addr_t inet_network (const char *);
+char *inet_ntoa (struct in_addr);
+#endif
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* _ARPA_INET_H */
diff --git a/winsup/cygwin/include/cygwin/in.h b/winsup/cygwin/include/cygwin/in.h
new file mode 100644
index 00000000000..ed73b26db70
--- /dev/null
+++ b/winsup/cygwin/include/cygwin/in.h
@@ -0,0 +1,187 @@
+/*
+ * INET An implementation of the TCP/IP protocol suite for the LINUX
+ * operating system. INET is implemented using the BSD Socket
+ * interface as the means of communication with the user level.
+ *
+ * Definitions of the Internet Protocol.
+ *
+ * Version: @(#)in.h 1.0.1 04/21/93
+ *
+ * Authors: Original taken from the GNU Project <netinet/in.h> file.
+ * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#ifndef _CYGWIN_IN_H
+#define _CYGWIN_IN_H
+
+#include <cygwin/types.h>
+
+/* Standard well-defined IP protocols. */
+enum
+{
+ IPPROTO_IP = 0, /* Dummy protocol for TCP */
+ IPPROTO_ICMP = 1, /* Internet Control Message Protocol */
+ IPPROTO_IGMP = 2, /* Internet Gateway Management Protocol */
+ IPPROTO_IPIP = 4, /* IPIP tunnels (older KA9Q tunnels use 94) */
+ IPPROTO_TCP = 6, /* Transmission Control Protocol */
+ IPPROTO_EGP = 8, /* Exterior Gateway Protocol */
+ IPPROTO_PUP = 12, /* PUP protocol */
+ IPPROTO_UDP = 17, /* User Datagram Protocol */
+ IPPROTO_IDP = 22, /* XNS IDP protocol */
+
+ IPPROTO_RAW = 255, /* Raw IP packets */
+ IPPROTO_MAX
+};
+
+typedef uint16_t in_port_t;
+/* Standard well-known ports. *//* from winsup/include/netinet/in.h */
+enum
+{
+ IPPORT_ECHO = 7, /* Echo service. */
+ IPPORT_DISCARD = 9, /* Discard transmissions service. */
+ IPPORT_SYSTAT = 11, /* System status service. */
+ IPPORT_DAYTIME = 13, /* Time of day service. */
+ IPPORT_NETSTAT = 15, /* Network status service. */
+ IPPORT_FTP = 21, /* File Transfer Protocol. */
+ IPPORT_TELNET = 23, /* Telnet protocol. */
+ IPPORT_SMTP = 25, /* Simple Mail Transfer Protocol. */
+ IPPORT_TIMESERVER = 37, /* Timeserver service. */
+ IPPORT_NAMESERVER = 42, /* Domain Name Service. */
+ IPPORT_WHOIS = 43, /* Internet Whois service. */
+ IPPORT_MTP = 57,
+
+ IPPORT_TFTP = 69, /* Trivial File Transfer Protocol. */
+ IPPORT_RJE = 77,
+ IPPORT_FINGER = 79, /* Finger service. */
+ IPPORT_TTYLINK = 87,
+ IPPORT_SUPDUP = 95, /* SUPDUP protocol. */
+
+
+ IPPORT_EXECSERVER = 512, /* execd service. */
+ IPPORT_LOGINSERVER = 513, /* rlogind service. */
+ IPPORT_CMDSERVER = 514,
+ IPPORT_EFSSERVER = 520,
+
+ /* UDP ports. */
+ IPPORT_BIFFUDP = 512,
+ IPPORT_WHOSERVER = 513,
+ IPPORT_ROUTESERVER = 520,
+
+ /* Ports less than this value are reserved for privileged processes. */
+ IPPORT_RESERVED = 1024,
+
+ /* Ports greater this value are reserved for (non-privileged) servers. */
+ IPPORT_USERRESERVED = 5000
+};
+
+typedef uint32_t in_addr_t;
+/* Internet address. */
+struct in_addr
+{
+ unsigned int s_addr;
+};
+
+/* Request struct for multicast socket ops */
+
+struct ip_mreq
+{
+ struct in_addr imr_multiaddr; /* IP multicast address of group */
+ struct in_addr imr_interface; /* local IP address of interface */
+};
+
+
+/* Structure describing an Internet (IP) socket address. */
+#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
+struct sockaddr_in
+{
+ short int sin_family; /* Address family */
+ unsigned short int sin_port; /* Port number */
+ struct in_addr sin_addr; /* Internet address */
+
+ /* Pad to size of `struct sockaddr'. */
+ unsigned chari __pad[__SOCK_SIZE__ - sizeof(short int)
+ - sizeof(unsigned short int) - sizeof(struct in_addr)];
+};
+#define sin_zero __pad /* for BSD UNIX comp. -FvK */
+
+/*
+ * Definitions of the bits in an Internet address integer.
+ * On subnets, host and network parts are found according
+ * to the subnet mask, not these masks.
+ */
+#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0)
+#define IN_CLASSA_NET 0xff000000
+#define IN_CLASSA_NSHIFT 24
+#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
+#define IN_CLASSA_MAX 128
+
+#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000)
+#define IN_CLASSB_NET 0xffff0000
+#define IN_CLASSB_NSHIFT 16
+#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
+#define IN_CLASSB_MAX 65536
+
+#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000)
+#define IN_CLASSC_NET 0xffffff00
+#define IN_CLASSC_NSHIFT 8
+#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
+
+#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
+#define IN_MULTICAST(a) IN_CLASSD(a)
+#define IN_MULTICAST_NET 0xF0000000
+
+#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) == 0xe0000000)
+#define IN_BADCLASS(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
+
+/* Address to accept any incoming messages. */
+#define INADDR_ANY ((unsigned long int) 0x00000000)
+
+/* Address to send to all hosts. */
+#define INADDR_BROADCAST ((unsigned long int) 0xffffffff)
+
+/* Address indicating an error return. */
+#define INADDR_NONE 0xffffffff
+
+/* Network number for local host loopback. */
+#define IN_LOOPBACKNET 127
+
+/* Address to loopback in software to local host. */
+#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */
+#define IN_LOOPBACK(a) ((((long int) (a)) & 0xff000000) == 0x7f000000)
+
+/* Defines for Multicast INADDR */
+#define INADDR_UNSPEC_GROUP 0xe0000000 /* 224.0.0.0 */
+#define INADDR_ALLHOSTS_GROUP 0xe0000001 /* 224.0.0.1 */
+#define INADDR_MAX_LOCAL_GROUP 0xe00000ff /* 224.0.0.255 */
+
+/* <asm/byteorder.h> contains the htonl type stuff.. */
+
+#include <asm/byteorder.h>
+
+/* Some random defines to make it easier in the kernel.. */
+#ifdef __KERNEL__
+
+#define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000))
+#define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
+
+#endif
+
+/* IPv6 definitions as we start to include them. This is just
+ a beginning dont get excited 8) */
+struct in6_addr
+{
+ unsigned char s6_addr[16];
+};
+
+struct sockaddr_in6
+{
+ unsigned short sin6_family;
+ unsigned short sin6_port;
+ unsigned long sin6_flowinfo;
+ struct in6_addr sin6_addr;
+};
+#endif /* _CYGWIN_IN_H */
diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h
new file mode 100644
index 00000000000..c4ba3a656b8
--- /dev/null
+++ b/winsup/cygwin/include/cygwin/types.h
@@ -0,0 +1,234 @@
+/* types.h
+
+ Copyright 2001, 2002, 2003 Red Hat Inc.
+ Written by Robert Collins <rbtcollins@hotmail.com>
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license. Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#ifndef _CYGWIN_TYPES_H
+#define _CYGWIN_TYPES_H
+
+#include <sys/sysmacros.h>
+
+#ifndef __timespec_t_defined
+#define __timespec_t_defined
+typedef struct timespec timespec_t;
+#endif /*__timespec_t_defined*/
+
+#ifndef __timestruc_t_defined
+#define __timestruc_t_defined
+typedef struct timespec timestruc_t;
+#endif /*__timestruc_t_defined*/
+
+#ifndef __off_t_defined
+#define __off_t_defined
+typedef long __off32_t;
+typedef long long __off64_t;
+#ifdef __CYGWIN_USE_BIG_TYPES__
+typedef __off64_t off_t;
+#else
+typedef __off32_t off_t;
+#endif
+#endif /*__off_t_defined*/
+
+#ifndef __dev_t_defined
+#define __dev_t_defined
+typedef short __dev16_t;
+typedef unsigned long __dev32_t;
+#ifdef __CYGWIN_USE_BIG_TYPES__
+typedef __dev32_t dev_t;
+#else
+typedef __dev16_t dev_t;
+#endif
+#endif /*__dev_t_defined*/
+
+#ifndef __blksize_t_defined
+#define __blksize_t_defined
+typedef long blksize_t;
+#endif /*__blksize_t_defined*/
+
+#ifndef __blkcnt_t_defined
+#define __blkcnt_t_defined
+typedef long __blkcnt32_t;
+typedef long long __blkcnt64_t;
+#ifdef __CYGWIN_USE_BIG_TYPES__
+typedef __blkcnt64_t blkcnt_t;
+#else
+typedef __blkcnt32_t blkcnt_t;
+#endif
+#endif /*__blkcnt_t_defined*/
+
+#ifndef __uid_t_defined
+#define __uid_t_defined
+typedef unsigned short __uid16_t;
+typedef unsigned long __uid32_t;
+#ifdef __CYGWIN_USE_BIG_TYPES__
+typedef __uid32_t uid_t;
+#else
+typedef __uid16_t uid_t;
+#endif
+#endif /*__uid_t_defined*/
+
+#ifndef __gid_t_defined
+#define __gid_t_defined
+typedef unsigned short __gid16_t;
+typedef unsigned long __gid32_t;
+#ifdef __CYGWIN_USE_BIG_TYPES__
+typedef __gid32_t gid_t;
+#else
+typedef __gid16_t gid_t;
+#endif
+#endif /*__gid_t_defined*/
+
+#ifndef __ino_t_defined
+#define __ino_t_defined
+#ifdef __CYGWIN_USE_BIG_TYPES1__
+typedef unsigned long long ino_t;
+#else
+typedef unsigned long ino_t;
+#endif
+#endif /*__ino_t_defined*/
+
+#ifndef __BIT_TYPES_DEFINED
+#define __BIT_TYPES_DEFINED__ 1
+
+#ifndef __vm_offset_t
+#define __vm_offset_t_defined
+typedef unsigned long vm_offset_t;
+#endif /*__vm_offset_t_defined*/
+
+#ifndef __vm_size_t
+#define __vm_size_t_defined
+typedef unsigned long vm_size_t;
+#endif /*__vm_size_t_defined*/
+
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef char int8_t;
+#endif
+#ifndef __int16_t_defined
+#define __int16_t_defined
+typedef __int16_t int16_t;
+#endif
+#ifndef __int32_t_defined
+#define __int32_t_defined
+typedef __int32_t int32_t;
+#endif
+#ifndef __int64_t_defined
+#define __int64_t_defined
+typedef __int64_t int64_t;
+#endif
+
+#ifndef __uint8_t_defined
+#define __uint8_t_defined
+typedef unsigned char uint8_t;
+#endif
+#ifndef __uint16_t_defined
+#define __uint16_t_defined
+typedef __uint16_t uint16_t;
+#endif
+#ifndef __uint32_t_defined
+#define __uint32_t_defined
+typedef __uint32_t uint32_t;
+#endif
+#ifndef __uint64_t_defined
+#define __uint64_t_defined
+typedef __uint64_t uint64_t;
+#endif
+
+#ifndef __uint8_t_defined
+#define __uint8_t_defined
+typedef unsigned char u_int8_t;
+#endif
+#ifndef __uint16_t_defined
+#define __uint16_t_defined
+typedef __uint16_t u_int16_t;
+#endif
+#ifndef __uint32_t_defined
+#define __uint32_t_defined
+typedef __uint32_t u_int32_t;
+#endif
+#ifndef __uint64_t_defined
+#define __uint64_t_defined
+typedef __uint64_t u_int64_t;
+#endif
+
+#ifndef __uintptr_t_defined
+#define __uintptr_t_defined
+typedef unsigned long uintptr_t;
+#endif
+
+#ifndef __intptr_t_defined
+#define __intptr_t_defined
+typedef long intptr_t;
+#endif
+
+#ifndef __register_t_defined
+#define __register_t_defined
+typedef __int32_t register_t;
+#endif
+
+#ifndef __addr_t_defined
+#define __addr_t_defined
+typedef char *addr_t;
+#endif
+
+#ifndef __mode_t_defined
+#define __mode_t_defined
+typedef unsigned mode_t;
+#endif
+#endif /*__BIT_TYPES_DEFINED*/
+
+#if !defined(__INSIDE_CYGWIN__) || !defined(__cplusplus)
+
+typedef struct __pthread_t {char __dummy;} *pthread_t;
+typedef struct __pthread_mutex_t {char __dummy;} *pthread_mutex_t;
+
+typedef struct __pthread_key_t {char __dummy;} *pthread_key_t;
+typedef struct __pthread_attr_t {char __dummy;} *pthread_attr_t;
+typedef struct __pthread_mutexattr_t {char __dummy;} *pthread_mutexattr_t;
+typedef struct __pthread_condattr_t {char __dummy;} *pthread_condattr_t;
+typedef struct __pthread_cond_t {char __dummy;} *pthread_cond_t;
+
+ /* These variables are not user alterable. This means you!. */
+typedef struct
+{
+ pthread_mutex_t mutex;
+ int state;
+}
+pthread_once_t;
+typedef struct __pthread_rwlock_t {char __dummy;} *pthread_rwlock_t;
+typedef struct __pthread_rwlockattr_t {char __dummy;} *pthread_rwlockattr_t;
+
+#else
+
+/* pthreads types */
+
+typedef class pthread *pthread_t;
+typedef class pthread_mutex *pthread_mutex_t;
+typedef class pthread_key *pthread_key_t;
+typedef class pthread_attr *pthread_attr_t;
+typedef class pthread_mutexattr *pthread_mutexattr_t;
+typedef class pthread_condattr *pthread_condattr_t;
+typedef class pthread_cond *pthread_cond_t;
+typedef class pthread_once pthread_once_t;
+typedef class pthread_rwlock *pthread_rwlock_t;
+typedef class pthread_rwlockattr *pthread_rwlockattr_t;
+
+/* semaphores types */
+typedef class semaphore *sem_t;
+#endif /* __INSIDE_CYGWIN__ */
+#endif /* _CYGWIN_TYPES_H */
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 51c74cf2c73..6123de87139 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -62,7 +62,8 @@ static DWORD WINAPI
read_pipe (void *arg)
{
pipeargs *pi = (pipeargs *) arg;
- pi->fh->fhandler_base::read (pi->ptr, *pi->len);
+ fhandler_base *fh = dynamic_cast<fhandler_base *> (pi->fh);
+ fh->fhandler_base::read (pi->ptr, *pi->len);
return 0;
}
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index 33b529d610e..35ac5cfac63 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -1224,7 +1224,7 @@ write_sd (const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size)
}
static void
-get_attribute_from_acl (int * attribute, PACL acl, PSID owner_sid,
+get_attribute_from_acl (mode_t *attribute, PACL acl, PSID owner_sid,
PSID group_sid, BOOL grp_member)
{
ACCESS_ALLOWED_ACE *ace;
@@ -1319,7 +1319,7 @@ get_attribute_from_acl (int * attribute, PACL acl, PSID owner_sid,
}
static int
-get_nt_attribute (const char *file, int *attribute,
+get_nt_attribute (const char *file, mode_t *attribute,
__uid32_t *uidret, __gid32_t *gidret)
{
if (!wincap.has_security ())
@@ -1387,7 +1387,7 @@ get_nt_attribute (const char *file, int *attribute,
int
get_file_attribute (int use_ntsec, const char *file,
- int *attribute, __uid32_t *uidret, __gid32_t *gidret)
+ mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
{
int res;
@@ -1435,7 +1435,7 @@ get_file_attribute (int use_ntsec, const char *file,
static int
get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
- int *attribute, __uid32_t *uidret, __gid32_t *gidret)
+ mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
{
if (!wincap.has_security ())
return 0;
@@ -1492,7 +1492,7 @@ get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
int
get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
- int *attribute, __uid32_t *uidret, __gid32_t *gidret)
+ mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
{
if (allow_ntsec)
{
diff --git a/winsup/cygwin/security.h b/winsup/cygwin/security.h
index a99ac0a8e11..9cbea2ff0b9 100644
--- a/winsup/cygwin/security.h
+++ b/winsup/cygwin/security.h
@@ -215,11 +215,11 @@ extern BOOL allow_smbntsec;
/* File manipulation */
int __stdcall set_process_privileges ();
-int __stdcall get_file_attribute (int, const char *, int *,
+int __stdcall get_file_attribute (int, const char *, mode_t *,
__uid32_t * = NULL, __gid32_t * = NULL);
int __stdcall set_file_attribute (int, const char *, int);
int __stdcall set_file_attribute (int, const char *, __uid32_t, __gid32_t, int);
-int __stdcall get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, int *,
+int __stdcall get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, mode_t *,
__uid32_t * = NULL, __gid32_t * = NULL);
LONG __stdcall read_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, LPDWORD sd_size);
LONG __stdcall write_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size);
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index a6ab79dc8e8..889d3cc698c 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -811,12 +811,12 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
goto done;
}
- DWORD attrib = 0;
+ mode_t attrib = 0;
if (win32_path.isdir ())
attrib |= S_IFDIR;
res = get_file_attribute (win32_path.has_acls (),
win32_path.get_win32 (),
- (int *) &attrib);
+ &attrib);
if (!res)
res = set_file_attribute (win32_path.has_acls (), win32_path, uid,
gid, attrib);