summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <cgf@redhat.com>2003-05-10 17:20:51 +0000
committerChristopher Faylor <cgf@redhat.com>2003-05-10 17:20:51 +0000
commit5a14e9e4ab467f38cd17e9d742343d38d974e173 (patch)
tree18d8dbd26f790fe1257d49863094b1d002bc3dbf
parentda9b2172d3404083be67d8a7862d1cc0b1a3befd (diff)
downloadgdb-5a14e9e4ab467f38cd17e9d742343d38d974e173.tar.gz
merge from trunk
-rw-r--r--winsup/cygwin/ChangeLog217
-rw-r--r--winsup/cygwin/Makefile.in96
-rw-r--r--winsup/cygwin/autoload.cc17
-rw-r--r--winsup/cygwin/cpuid.h35
-rw-r--r--winsup/cygwin/cygthread.cc110
-rw-r--r--winsup/cygwin/cygthread.h2
-rw-r--r--winsup/cygwin/cygwin.din94
-rw-r--r--winsup/cygwin/errno.cc6
-rw-r--r--winsup/cygwin/exceptions.cc4
-rw-r--r--winsup/cygwin/fhandler_console.cc18
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc19
-rw-r--r--winsup/cygwin/fhandler_proc.cc36
-rw-r--r--winsup/cygwin/fhandler_tty.cc18
-rw-r--r--winsup/cygwin/fork.cc6
-rw-r--r--winsup/cygwin/grp.cc16
-rw-r--r--winsup/cygwin/include/cygwin/config.h39
-rw-r--r--winsup/cygwin/include/cygwin/in.h2
-rw-r--r--winsup/cygwin/include/cygwin/types.h49
-rw-r--r--winsup/cygwin/include/cygwin/version.h13
-rw-r--r--winsup/cygwin/include/inttypes.h246
-rw-r--r--winsup/cygwin/include/limits.h169
-rw-r--r--winsup/cygwin/include/netinet/ip.h202
-rw-r--r--winsup/cygwin/include/stdint.h182
-rw-r--r--winsup/cygwin/mkvers.sh177
-rw-r--r--winsup/cygwin/path.cc62
-rw-r--r--winsup/cygwin/path.h35
-rw-r--r--winsup/cygwin/profil.c175
-rw-r--r--winsup/cygwin/profil.h44
-rw-r--r--winsup/cygwin/pwdgrp.h20
-rw-r--r--winsup/cygwin/regex/regex.h83
-rw-r--r--winsup/cygwin/regex/regex2.h134
-rw-r--r--winsup/cygwin/security.cc226
-rw-r--r--winsup/cygwin/select.cc12
-rw-r--r--winsup/cygwin/signal.cc2
-rw-r--r--winsup/cygwin/syscalls.cc115
-rw-r--r--winsup/cygwin/termios.cc46
-rw-r--r--winsup/cygwin/thread.cc26
-rw-r--r--winsup/cygwin/thread.h17
-rw-r--r--winsup/cygwin/wincap.cc537
-rw-r--r--winsup/cygwin/wincap.h113
-rw-r--r--winsup/cygwin/winsup.h2
41 files changed, 2915 insertions, 507 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index b839897bb9e..d7584b82221 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,220 @@
+2003-05-10 Corinna Vinschen <corinna@vinschen.de>
+
+ * Makefile.in (NEW_FUNCTIONS): All 32/64 from 0.79 API get
+ leading underscore.
+ * cygwin.din: Ditto.
+ * include/cygwin/version.h: Bump API minor number.
+
+2003-05-09 Corinna Vinschen <corinna@vinschen.de>
+
+ * include/cygwin/config.h: New file.
+
+2003-05-09 Christopher Faylor <cgf@redhat.com>
+
+ * cygthread.cc (cygthread::detach): Prioritize waiting for I/O
+ completion over waiting for signal delivery.
+
+2003-05-06 Thomas Pfaff <tpfaff@gmx.net>
+
+ * signal.cc (nanosleep): Do not wait twice for signal arrival.
+
+2003-05-03 Corinna Vinschen <corinna@vinschen.de>
+
+ * include/cygwin/types.h: Fix erroneous definition of ino_t from
+ 2003-04-28.
+
+2003-05-03 Corinna Vinschen <corinna@vinschen.de>
+
+ * syscalls.cc (chown_worker): Allow chown'ing of socket files.
+
+2003-04-30 Thomas Pfaff <tpfaff@gmx.net>
+
+ * Makefile.in: Revert patch from 2003-04-17.
+
+2003-04-28 Brian Ford <ford@vss.fsi.com>
+
+ * profil.h (PROFADDR): Prevent overflow when text segments are larger
+ than 256k.
+ * profil.c (profthr_func): Raise thread priority for more accurate
+ sampling.
+
+2003-04-26 Christopher Faylor <cgf@redhat.com>
+
+ * path.cc (hash_path_name): Use ino_t as type.
+
+2003-04-26 Christopher Faylor <cgf@redhat.com>
+
+ * errno.cc (_sys_nerr): Fix compile error erroneously checked in on
+ 2003-04-23.
+
+2003-04-25 Corinna Vinschen <corinna@vinschen.de>
+
+ * include/netinet/ip.h: Include netinet/in_systm.h and netinet/in.h
+ to allow standalone usage (autoconf).
+
+2003-04-23 Christopher Faylor <cgf@redhat.com>
+
+ * fork.cc: Change SLOW_PID_REUSE to NO_SLOW_PID_REUSE and invert ifdef
+ sense throughout.
+
+2003-04-22 Christopher Faylor <cgf@redhat.com>
+
+ * select.cc (fhandler_pipe::ready_for_read): Assure that get_guard is
+ called for successful non-blocking pipe reads.
+
+2003-04-22 Corinna Vinschen <corinna@vinschen.de>
+
+ * include/inttypes.h: New file.
+ * include/stdint.h: New file.
+ * include/cygwin/in.h: Include stdint.h instead of sys/types.h.
+ * include/cygwin/types.h: Include stdint.h. Remove typedefs for
+ intN_t and uintN_t since these are defined in stdint.h now.
+
+2003-04-21 Christopher Faylor <cgf@redhat.com>
+
+ * include/cygwin/version.h: Bump DLL major number to 1005. Change DLL
+ minor number to 0. Bump API minor number.
+
+2003-04-20 Corinna Vinschen <corinna@vinschen.de>
+
+ * autoload.cc (CreateWindowStationA): Add.
+ (SetProcessWindowStation): Add.
+
+2003-04-19 Christopher Faylor <cgf@redhat.com>
+
+ * wincap.h (wincaps:pty_needs_alloc_console): New element.
+ (wincapc:pty_needs_alloc_console): New function.
+ * wincap.cc: Add pty_needs_alloc_console throughout.
+ * fhandler_tty.cc (fhandler_tty_slave::open): Open an "invisible"
+ console on first pty allocation.
+
+2003-04-18 Christopher Faylor <cgf@redhat.com>
+
+ * fhandler_tty.cc (fhandler_tty_slave::open): Allocate a console
+ whenever a pty is allocated.
+
+2003-04-18 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in: Use ${nostdlib} variable.
+
+2003-04-18 Diego Biurrun <diego@biurrun.de>
+
+ * fhandler_proc.cc (format_proc_cpuinfo): Change /proc/cpuinfo "vendor
+ id" string to "vendor_id" to conform with Linux systems.
+
+2003-04-17 Christopher Faylor <cgf@redhat.com>
+
+ * syscalls.cc (setsid): Don't call FreeConsole if ctty is already < 0.
+
+2003-04-17 Thomas Pfaff <tpfaff@gmx.net>
+
+ * Makefile.in: Add finline-functions optimization to CXXFLAGS.
+ * autoload.cc (LoadDLLprime): Rename std_dll_init to
+ _std_dll_init.
+ (std_dll_init): Remove name mangling prototype. Add attributes
+ used and noinline.
+ (wsock_init): Ditto.
+ Change wsock_init to _wsock_init in wsock32 and ws2_32
+ LoadDLLprime.
+ * exceptions.cc (unused_sig_wrapper): Remove prototype. Add
+ attributes used and noinline.
+ * pwdgrp.h ((pwdgrp (passwd *&)): Remove inline code.
+ (pwdgrp (__group32 *&)): Ditto.
+ * grp.cc (pwdgrp (passwd *&)): Outline constructor.
+ (pwdgrp (__group32 *&)): Ditto.
+
+2003-04-17 Thomas Pfaff <tpfaff@gmx.net>
+
+ * thread.h (pthread::equal): New static method.
+ * thread.cc: Rename pthread_equal to pthread::equal throughout.
+ (pthread_equal): Use pthread::equal to compare threads ids.
+
+2003-04-15 Christopher Faylor <cgf@redhat.com>
+
+ * termios.cc (setspeed): New function.
+ (cfsetospeed): Use setspeed to set speed.
+ (cfsetispeed): Use setspeed to set speed.
+
+2003-04-15 Chris January <chris@atomice.net>
+
+ * autoload.cc: Add load statement for UuidCreate, and
+ UuidCreateSequential.
+ * cpuid.h: New file.
+ * cygwin.din: Export gethostid.
+ * fhandler_proc.cc (cpuid): Move to cpuid.h.
+ (can_set_flag): Move to cpuid.h.
+ * syscalls.cc (gethostid): New function.
+ * version.h: Bump api minor version number to 83.
+
+2003-04-15 Thomas Pfaff <tpfaff@gmx.net>
+
+ * thread.h (pthread_rwlock::release): New method.
+ * thread.cc (pthread_rwlock::unlock): Use release to signal waiting
+ threads.
+ (pthread_rwlock::rdlock_cleanup): Signal waiting threads after a
+ cancelation.
+ (pthread_rwlock::wrlock_cleanup): Ditto.
+
+2003-04-13 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * mkvers.sh: Prefix day with 0 in date only when day < 10.
+
+2003-04-11 Pierre Humblet <pierre.humblet@ieee.org>
+
+ * security.cc (get_info_from_sd): New function.
+ (get_nt_attribute): Only call read_sd and get_info_from_sd.
+ Return void.
+ (get_file_attribute): Move sd error handling to get_info_from_sd.
+ and symlink handling to fhandler_disk_file::fstat_helper.
+ (get_nt_object_attribute): Only call read_sd and get_info_from_sd.
+ Return void.
+ (get_object_attribute): Remove symlink handling and simply return -1
+ when ntsec is off.
+ * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): For
+ symlinks set the attribute, call get_file_attribute to get the ids
+ and return. In the normal case call get_file_attribute with the
+ addresses of the buffer ids and do not recheck if the file is a socket.
+
+2003-04-10 Christopher Faylor <cgf@redhat.com>
+
+ * cygthread.cc (cygthread::stub): Initialize stack pointer earlier.
+ (cygthread::simplestub): Initialize stack pointer.
+ (cygthread::terminate_thread): Account for possibility that stack
+ pointer has not been set. Issue warnings for unusual conditions.
+
+2003-04-10 Corinna Vinschen <corinna@vinschen.de>
+
+ * regex/regex.h: Define regoff_t as _off_t.
+ * regex/regex2.h: Ditto.
+
+2003-04-10 Corinna Vinschen <corinna@vinschen.de>
+
+ * cygwin.din: Export wcscoll, wcswidth and wcwidth.
+ * include/cygwin/version.h: Bump API minor number.
+
+2003-04-10 Christopher Faylor <cgf@redhat.com>
+
+ * cygthread.h: Change 'avail' cygthread element to 'inuse' throughout.
+ * cygthread.cc: Ditto.
+ (cygthread::stub): Don't initialize already initialized events.
+ (cygthread::freerange): Don't create thread here.
+ (cygthread::cygthread): Create thread here. Die if thread not created.
+ (cygthread::operator new): Simplify. Just grab a thread structure from
+ the pool. Don't try to start the thread.
+ (cygthread::terminate_thread): Don't close event handles. Just reuse
+ them. Call MEM_RELEASE rather than MEM_DECOMMIT (from Joe Buehler).
+
+2003-04-08 Bob Cassels <bcassels@abinitio.com>
+
+ * fhandler_console.cc (fhandler_console::read) Handle certain key up
+ events, to allow pasting accented characters and typing them using the
+ "alt + numerics" sequences.
+
+2003-04-07 Christopher Faylor <cgf@redhat.com>
+
+ * include/limits.h (IOV_MAX): Set to a number which is small enough to
+ use in an array.
+
2003-04-04 Christopher Faylor <cgf@redhat.com>
* cygthread.h (cygthread::avail): Make LONG for easier use with
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 5556ac36023..6378db4eee8 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -185,53 +185,53 @@ NEW_FUNCTIONS:=regcomp posix_regcomp \
regexec posix_regexec \
regfree posix_regfree \
open _open64 \
- acl acl32 \
- aclcheck aclcheck32 \
- aclfrommode aclfrommode32 \
- aclfrompbits aclfrompbits32 \
- aclfromtext aclfromtext32 \
- aclsort aclsort32 \
- acltomode acltomode32 \
- acltopbits acltopbits32 \
- acltotext acltotext32 \
- chown chown32 \
- facl facl32 \
- fchown fchown32 \
- fgetpos fgetpos64 \
- fopen fopen64 \
- freopen freopen64 \
- fseeko fseeko64 \
- fsetpos fsetpos64 \
- fstat fstat64 \
- ftello ftello64 \
- ftruncate ftruncate64 \
- getegid getegid32 \
- geteuid geteuid32 \
- getgid getgid32 \
- getgrent getgrent32 \
- getgrgid getgrgid32 \
- getgrnam getgrnam32 \
- getgroups getgroups32 \
- getpwuid getpwuid32 \
- getpwuid_r getpwuid_r32 \
- getuid getuid32 \
- initgroups initgroups32 \
- lchown lchown32 \
- lseek lseek64 \
- lstat lstat64 \
- mknod mknod32 \
- mmap mmap64 \
- seekdir seekdir64 \
- setegid setegid32 \
- seteuid seteuid32 \
- setgid setgid32 \
- setgroups setgroups32 \
- setregid setregid32 \
- setreuid setreuid32 \
- setuid setuid32 \
- stat stat64 \
- telldir telldir64 \
- truncate truncate64
+ acl _acl32 \
+ aclcheck _aclcheck32 \
+ aclfrommode _aclfrommode32 \
+ aclfrompbits _aclfrompbits32 \
+ aclfromtext _aclfromtext32 \
+ aclsort _aclsort32 \
+ acltomode _acltomode32 \
+ acltopbits _acltopbits32 \
+ acltotext _acltotext32 \
+ chown _chown32 \
+ facl _facl32 \
+ fchown _fchown32 \
+ fgetpos _fgetpos64 \
+ fopen _fopen64 \
+ freopen _freopen64 \
+ fseeko _fseeko64 \
+ fsetpos _fsetpos64 \
+ fstat _fstat64 \
+ ftello _ftello64 \
+ ftruncate _ftruncate64 \
+ getegid _getegid32 \
+ geteuid _geteuid32 \
+ getgid _getgid32 \
+ getgrent _getgrent32 \
+ getgrgid _getgrgid32 \
+ getgrnam _getgrnam32 \
+ getgroups _getgroups32 \
+ getpwuid _getpwuid32 \
+ getpwuid_r _getpwuid_r32 \
+ getuid _getuid32 \
+ initgroups _initgroups32 \
+ lchown _lchown32 \
+ lseek _lseek64 \
+ lstat _lstat64 \
+ mknod _mknod32 \
+ mmap _mmap64 \
+ seekdir _seekdir64 \
+ setegid _setegid32 \
+ seteuid _seteuid32 \
+ setgid _setgid32 \
+ setgroups _setgroups32 \
+ setregid _setregid32 \
+ setreuid _setreuid32 \
+ setuid _setuid32 \
+ stat _stat64 \
+ telldir _telldir64 \
+ truncate _truncate64
API_VER:=$(srcdir)/include/cygwin/version.h
@@ -339,7 +339,7 @@ maintainer-clean realclean: clean
# Rule to build cygwin.dll
$(TEST_DLL_NAME): $(LDSCRIPT) $(DLL_OFILES) $(DEF_FILE) $(DLL_IMPORTS) $(LIBC) $(LIBM) $(API_VER) Makefile winver_stamp
- $(CXX) $(CXXFLAGS) -nostdlib -Wl,-T$(firstword $^) -Wl,--out-implib,cygdll.a -shared -o $@ \
+ $(CXX) $(CXXFLAGS) $(nostdlib) -Wl,-T$(firstword $^) -Wl,--out-implib,cygdll.a -shared -o $@ \
-e $(DLL_ENTRY) $(DEF_FILE) $(DLL_OFILES) version.o winver.o \
$(MALLOC_OBJ) $(LIBM) $(LIBC) \
-lgcc $(DLL_IMPORTS)
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 59d84699259..24527f5902e 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -58,7 +58,7 @@ details. */
#define LoadDLLprime(dllname, init_also) __asm__ (" \n\
.section ." #dllname "_info,\"w\" \n\
.linkonce \n\
- .long std_dll_init \n\
+ .long _std_dll_init \n\
.long 0 \n\
.long -1 \n\
.long " #init_also " \n\
@@ -201,8 +201,7 @@ union retchain
};
/* The standard DLL initialization routine. */
-static long long std_dll_init () __asm__ ("std_dll_init") __attribute__ ((unused));
-static long long
+__attribute__ ((used, noinline)) static long long
std_dll_init ()
{
HANDLE h;
@@ -241,9 +240,8 @@ std_dll_init ()
}
/* Initialization function for winsock stuff. */
-static long long wsock_init () __asm__ ("wsock_init") __attribute__ ((unused, regparm(1)));
bool NO_COPY wsock_started = 0;
-static long long
+__attribute__ ((used, noinline, regparm(1))) static long long
wsock_init ()
{
static LONG NO_COPY here = -1L;
@@ -304,8 +302,8 @@ wsock_init ()
return ret.ll;
}
-LoadDLLprime (wsock32, wsock_init)
-LoadDLLprime (ws2_32, wsock_init)
+LoadDLLprime (wsock32, _wsock_init)
+LoadDLLprime (ws2_32, _wsock_init)
LoadDLLfunc (AccessCheck, 32, advapi32)
LoadDLLfunc (AddAccessAllowedAce, 16, advapi32)
@@ -410,6 +408,7 @@ LoadDLLfunc (CharToOemA, 8, user32)
LoadDLLfunc (CharToOemBuffA, 12, user32)
LoadDLLfunc (CloseClipboard, 0, user32)
LoadDLLfunc (CreateWindowExA, 48, user32)
+LoadDLLfunc (CreateWindowStationA, 16, user32)
LoadDLLfunc (DefWindowProcA, 16, user32)
LoadDLLfunc (DispatchMessageA, 4, user32)
LoadDLLfunc (EmptyClipboard, 0, user32)
@@ -434,6 +433,7 @@ LoadDLLfunc (RegisterClassA, 4, user32)
LoadDLLfunc (RegisterClipboardFormatA, 4, user32)
LoadDLLfunc (SendMessageA, 16, user32)
LoadDLLfunc (SetClipboardData, 8, user32)
+LoadDLLfunc (SetProcessWindowStation, 4, user32)
LoadDLLfunc (SetTimer, 16, user32)
LoadDLLfunc (SetUserObjectSecurity, 12, user32)
@@ -523,4 +523,7 @@ LoadDLLfuncEx (timeGetDevCaps, 8, winmm, 1)
LoadDLLfuncEx (timeGetTime, 0, winmm, 1)
LoadDLLfuncEx (timeBeginPeriod, 4, winmm, 1)
LoadDLLfuncEx (timeEndPeriod, 4, winmm, 1)
+
+LoadDLLfuncEx (UuidCreate, 4, rpcrt4, 1)
+LoadDLLfuncEx (UuidCreateSequential, 4, rpcrt4, 1)
}
diff --git a/winsup/cygwin/cpuid.h b/winsup/cygwin/cpuid.h
new file mode 100644
index 00000000000..1f0cc5006f4
--- /dev/null
+++ b/winsup/cygwin/cpuid.h
@@ -0,0 +1,35 @@
+#ifndef CPUID_H
+#define CPUID_H
+
+extern inline void
+cpuid (unsigned *a, unsigned *b, unsigned *c, unsigned *d, unsigned in)
+{
+ asm ("cpuid"
+ : "=a" (*a),
+ "=b" (*b),
+ "=c" (*c),
+ "=d" (*d)
+ : "a" (in));
+}
+
+extern inline bool
+can_set_flag (unsigned flag)
+{
+ unsigned r1, r2;
+ asm("pushfl\n"
+ "popl %0\n"
+ "movl %0, %1\n"
+ "xorl %2, %0\n"
+ "pushl %0\n"
+ "popfl\n"
+ "pushfl\n"
+ "popl %0\n"
+ "pushl %1\n"
+ "popfl\n"
+ : "=&r" (r1), "=&r" (r2)
+ : "ir" (flag)
+ );
+ return ((r1 ^ r2) & flag) != 0;
+}
+
+#endif // !CPUID_H
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index bc6c8bc9eaf..e3c177e6b3f 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -40,12 +40,22 @@ cygthread::stub (VOID *arg)
cygthread *info = (cygthread *) arg;
if (info->arg == cygself)
+ {
+ if (info->ev)
+ {
+ CloseHandle (info->ev);
+ CloseHandle (info->thread_sync);
+ }
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;
+ if (!info->ev)
+ {
+ info->ev = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
+ info->thread_sync = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
+ }
}
while (1)
{
@@ -90,6 +100,7 @@ cygthread::simplestub (VOID *arg)
init_exceptions (&except_entry);
cygthread *info = (cygthread *) arg;
+ info->stack_ptr = &arg;
info->func (info->arg == cygself ? info : info->arg);
ExitThread (0);
}
@@ -118,8 +129,6 @@ 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;
}
@@ -127,31 +136,19 @@ cygthread::freerange ()
void * cygthread::operator
new (size_t)
{
- LONG is_avail;
cygthread *info;
/* Search the threads array for an empty slot to use */
for (info = threads; info < threads + NTHREADS; info++)
- if ((is_avail = InterlockedExchange (&info->avail, -1)) < 0)
- /* in use */;
- else if (is_avail > 0)
+ if (!InterlockedExchange (&info->inuse, 1))
{
/* available */
#ifdef DEBUGGING
if (info->__name)
api_fatal ("name not NULL? id %p, i %d", info->id, info - threads);
- if (!info->h)
- api_fatal ("h not set? id %p, i %d", info->id, info - threads);
#endif
goto out;
}
- else
- {
- /* Uninitialized. Available as soon as thread is created */
- info->h = CreateThread (&sec_none_nih, 0, cygthread::stub, info,
- CREATE_SUSPENDED, &info->id);
- goto out;
- }
#ifdef DEBUGGING
char buf[1024];
@@ -166,27 +163,26 @@ out:
}
cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param,
- const char *name): func (start), arg (param)
+ const char *name): __name (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
+ if (h)
{
- system_printf ("waiting for %s<%p> to become active", __name, h);
- low_priority_sleep (0);
+ while (!thread_sync)
+ low_priority_sleep (0);
+ SetEvent (thread_sync);
+ thread_printf ("activated thread_sync %p", thread_sync);
}
-#endif
- __name = name;
- if (!thread_sync)
- ResumeThread (h);
else
- SetEvent (thread_sync);
+ {
+ stack_ptr = NULL;
+ h = CreateThread (&sec_none_nih, 0, is_freerange ? simplestub : stub,
+ this, 0, &id);
+ if (!h)
+ api_fatal ("thread handle not set - %p<%p>, %E", h, id);
+ thread_printf ("created thread %p", h);
+ }
}
/* Return the symbolic name of the current thread for debugging.
@@ -241,29 +237,31 @@ void
cygthread::terminate_thread ()
{
if (!is_freerange)
- SetEvent (*this);
+ {
+ ResetEvent (*this);
+ ResetEvent (thread_sync);
+ }
(void) TerminateThread (h, 0);
(void) WaitForSingleObject (h, INFINITE);
+ CloseHandle (h);
+
+ while (!stack_ptr)
+ low_priority_sleep (0);
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 (!m.RegionSize)
+ system_printf ("m.RegionSize 0? stack_ptr %p", stack_ptr);
+ else if (!VirtualFree (m.AllocationBase, 0, MEM_RELEASE))
+ system_printf ("VirtualFree of allocation base %p<%p> failed, %E",
+ stack_ptr, m.AllocationBase);
- if (is_freerange)
- is_freerange = false;
- else
- {
- CloseHandle (ev);
- CloseHandle (thread_sync);
- }
- CloseHandle (h);
- thread_sync = ev = h = NULL;
+ h = NULL;
__name = NULL;
- id = 0;
- (void) InterlockedExchange (&avail, 0); /* No longer initialized */
+ stack_ptr = NULL;
+ (void) InterlockedExchange (&inuse, 0); /* No longer in use */
}
/* Detach the cygthread from the current thread. Note that the
@@ -274,8 +272,8 @@ bool
cygthread::detach (HANDLE sigwait)
{
bool signalled = false;
- if (avail >= 0)
- system_printf ("called detach but avail %d, thread %d?", avail, id);
+ if (!inuse)
+ system_printf ("called detach but inuse %d, thread %p?", inuse, id);
else
{
DWORD res;
@@ -285,17 +283,17 @@ cygthread::detach (HANDLE sigwait)
else
{
HANDLE w4[2];
- w4[0] = signal_arrived;
- w4[1] = *this;
+ w4[0] = *this;
+ w4[1] = signal_arrived;
res = WaitForSingleObject (sigwait, INFINITE);
if (res != WAIT_OBJECT_0)
system_printf ("WFSO sigwait %p failed, res %u, %E", sigwait, res);
res = WaitForMultipleObjects (2, w4, FALSE, INFINITE);
- if (res != WAIT_OBJECT_0)
+ if (res == WAIT_OBJECT_0)
/* nothing */;
- else if (WaitForSingleObject (sigwait, 5) == WAIT_OBJECT_0)
+ else if (WaitForSingleObject (sigwait, 0) == WAIT_OBJECT_0)
res = WaitForSingleObject (*this, INFINITE);
- else
+ else if ((res = WaitForSingleObject (*this, 0)) != WAIT_OBJECT_0)
{
signalled = true;
terminate_thread ();
@@ -317,8 +315,8 @@ cygthread::detach (HANDLE sigwait)
else
{
ResetEvent (*this);
- /* Mark the thread as available by setting avail to positive value */
- (void) InterlockedExchange (&avail, 1);
+ /* Mark the thread as available by setting inuse to zero */
+ (void) InterlockedExchange (&inuse, 0);
}
}
return signalled;
diff --git a/winsup/cygwin/cygthread.h b/winsup/cygwin/cygthread.h
index 3226f2a02e7..7af3f318382 100644
--- a/winsup/cygwin/cygthread.h
+++ b/winsup/cygwin/cygthread.h
@@ -8,7 +8,7 @@ details. */
class cygthread
{
- LONG avail; /* 1: available, 0: ininitialized, -1: not available */
+ LONG inuse;
DWORD id;
HANDLE h;
HANDLE ev;
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index fbb86a28849..cf0dfd62354 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -103,31 +103,31 @@ access
_access = access
acl
_acl = acl
-acl32
+_acl32 = acl32
aclcheck
_aclcheck = aclcheck
-aclcheck32
+_aclcheck32 = aclcheck32
aclfrommode
_aclfrommode = aclfrommode
-aclfrommode32
+_aclfrommode32 = aclfrommode32
aclfrompbits
_aclfrompbits = aclfrompbits
-aclfrompbits32
+_aclfrompbits32 = aclfrompbits32
aclfromtext
_aclfromtext = aclfromtext
-aclfromtext32
+_aclfromtext32 = aclfromtext32
aclsort
_aclsort = aclsort
-aclsort32
+_aclsort32 = aclsort32
acltomode
_acltomode = acltomode
-acltomode32
+_acltomode32 = acltomode32
acltopbits
_acltopbits = acltopbits
-acltopbits32
+_acltopbits32 = acltopbits32
acltotext
_acltotext = acltotext
-acltotext32
+_acltotext32 = acltotext32
acos
_acos = acos
acosf
@@ -209,7 +209,7 @@ chmod
_chmod = chmod
chown
_chown = chown
-chown32
+_chown32 = chown32
chroot
_chroot = chroot
cleanup_glue
@@ -400,14 +400,14 @@ fabsf
_fabsf = fabsf
facl
_facl = facl
-facl32
+_facl32 = facl32
fchdir
_fchdir = fchdir
fchmod
_fchmod = fchmod
fchown
_fchown = fchown
-fchown32
+_fchown32 = fchown32
fclose
_fclose = fclose
fcloseall
@@ -436,7 +436,7 @@ fgetc
_fgetc = fgetc
fgetpos
_fgetpos = fgetpos
-fgetpos64
+_fgetpos64 = fgetpos64
fgets
_fgets = fgets
fileno
@@ -465,7 +465,7 @@ fnmatch
_fnmatch = fnmatch
fopen
_fopen = fopen
-fopen64
+_fopen64 = fopen64
fork
_fork = fork
fpathconf
@@ -481,7 +481,7 @@ free
_free = free
freopen
_freopen = freopen
-freopen64
+_freopen64 = freopen64
frexp
_frexp = frexp
frexpf
@@ -492,11 +492,10 @@ fseek
_fseek = fseek
fseeko
_fseeko = fseeko
-fseeko64
+_fseeko64 = fseeko64
fsetpos
_fsetpos = fsetpos
-fsetpos64
-fstat64
+_fsetpos64 = fsetpos64
_fstat64 = fstat64
fstatfs
_fstatfs = fstatfs
@@ -506,12 +505,12 @@ ftell
_ftell = ftell
ftello
_ftello = ftello
-ftello64
+_ftello64 = ftello64
ftime
_ftime = ftime
ftruncate
_ftruncate = ftruncate
-ftruncate64
+_ftruncate64 = ftruncate64
fwrite
_fwrite = fwrite
gamma
@@ -544,27 +543,28 @@ getdtablesize
_getdtablesize = getdtablesize
getegid
_getegid = getegid
-getegid32
+_getegid32 = getegid32
getenv
_getenv = getenv
geteuid
_geteuid = geteuid
-geteuid32
+_geteuid32 = geteuid32
getgid
_getgid = getgid
-getgid32
+_getgid32 = getgid32
getgrent
_getgrent = getgrent
-getgrent32
+_getgrent32 = getgrent32
getgrgid
_getgrgid = getgrgid
-getgrgid32
+_getgrgid32 = getgrgid32
getgrnam
_getgrnam = getgrnam
-getgrnam32
+_getgrnam32 = getgrnam32
getgroups
_getgroups = getgroups
-getgroups32
+_getgroups32 = getgroups32
+gethostid
getitimer
getlogin
_getlogin = getlogin
@@ -592,9 +592,9 @@ _getpwnam = getpwnam
getpwnam_r
getpwuid
_getpwuid = getpwuid
-getpwuid32
+_getpwuid32 = getpwuid32
getpwuid_r
-getpwuid_r32
+_getpwuid_r32 = getpwuid_r32
getrlimit
_getrlimit = getrlimit
getrusage
@@ -606,7 +606,7 @@ gettimeofday
_gettimeofday = gettimeofday
getuid
_getuid = getuid
-getuid32
+_getuid32 = getuid32
getutent
_getutent = getutent
getutid
@@ -653,7 +653,7 @@ _infinity = infinity
infinityf
_infinityf = infinityf
initgroups
-initgroups32
+_initgroups32 = initgroups32
initstate
ioctl
_ioctl = ioctl
@@ -731,7 +731,7 @@ lacl
_lacl = lacl
lchown
_lchown = lchown
-lchown32
+_lchown32 = lchown32
lcong48
_lcong48 = lcong48
ldexp
@@ -784,9 +784,8 @@ lround
lroundf
lseek
_lseek = lseek
-lseek64
_lseek64 = lseek64
-lstat64
+_lstat64 = lstat64
mallinfo
malloc
_malloc = malloc
@@ -825,7 +824,7 @@ _mkdir = mkdir
mkfifo
mknod
_mknod = mknod
-mknod32
+_mknod32 = mknod32
mkstemp
_mkstemp = mkstemp
mktemp
@@ -833,7 +832,7 @@ _mktemp = mktemp
mktime
_mktime = mktime
mmap
-mmap64
+_mmap64 = mmap64
modf
_modf = modf
modff
@@ -1060,7 +1059,7 @@ seed48
_seed48 = seed48
seekdir
_seekdir = seekdir
-seekdir64
+_seekdir64 = seekdir64
sem_destroy
sem_init
sem_post
@@ -1073,20 +1072,20 @@ setdtablesize
_setdtablesize = setdtablesize
setegid
_setegid = setegid
-setegid32
+_setegid32 = setegid32
setenv
_setenv = setenv
seteuid
_seteuid = seteuid
-seteuid32
+_seteuid32 = seteuid32
setgid
_setgid = setgid
-setgid32
+_setgid32 = setgid32
setgrent
_setgrent = setgrent
setgroups
_setgroups = setgroups
-setgroups32
+_setgroups32 = setgroups32
sethostent
setitimer
setjmp
@@ -1110,9 +1109,11 @@ _setpwent = setpwent
setregid
_setregid = setregid
setregid32
+_setregid32 = setregid32
setreuid
_setreuid = setreuid
setreuid32
+_setreuid32 = setreuid32
setrlimit
_setrlimit = setrlimit
setsid
@@ -1122,7 +1123,7 @@ settimeofday
_settimeofday = settimeofday
setuid
_setuid = setuid
-setuid32
+_setuid32 = setuid32
setutent
_setutent = setutent
setvbuf
@@ -1208,7 +1209,7 @@ _srand48 = srand48
srandom
sscanf
_sscanf = sscanf
-stat64
+_stat64 = stat64
statfs
_statfs = statfs
strcasecmp
@@ -1326,7 +1327,7 @@ tdelete
tdestroy
telldir
_telldir = telldir
-telldir64
+_telldir64 = telldir64
tempnam
_tempnam = tempnam
tfind
@@ -1352,7 +1353,7 @@ towlower
towupper
truncate
_truncate = truncate
-truncate64
+_truncate64 = truncate64
truncf
tsearch
ttyname
@@ -1418,6 +1419,7 @@ wcscat
wcschr
wcscmp
_wcscmp = wcscmp
+wcscoll
wcscpy
wcscspn
wcslcat
@@ -1434,11 +1436,13 @@ wcsspn
wcsstr
wcstombs
_wcstombs = wcstombs
+wcswidth
wctob
wctomb
_wctomb = wctomb
wctrans
wctype
+wcwidth
wmemchr
wmemcmp
wmemcpy
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
index 9b26afcd1b1..a922d5280dd 100644
--- a/winsup/cygwin/errno.cc
+++ b/winsup/cygwin/errno.cc
@@ -290,12 +290,12 @@ const NO_COPY char __declspec(dllexport) * const _sys_errlist[]=
/* 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"
+/* 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]);
+extern const int NO_COPY __declspec(dllexport) _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
};
/* FIXME: Why is strerror() a long switch and not just:
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 742aa68b0ec..ec4b7f4c9ac 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1203,12 +1203,10 @@ reset_signal_arrived ()
sigproc_printf ("reset signal_arrived");
}
-static void unused_sig_wrapper () __attribute__((const, unused));
-
#undef errno
#define errno ((DWORD volatile) _impure_ptr) + (((char *) &_impure_ptr->_errno) - ((char *) _impure_ptr))
-static void
+__attribute__((const, used, noinline)) static void
unused_sig_wrapper ()
{
/* Signal cleanup stuff. Cleans up stack (too bad that we didn't
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index fbafc405377..a76cfb0cdc5 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -321,14 +321,26 @@ fhandler_console::read (void *pv, size_t& buflen)
break;
}
- if (!input_rec.Event.KeyEvent.bKeyDown)
- continue;
-
#define ich (input_rec.Event.KeyEvent.uChar.AsciiChar)
#define wch (input_rec.Event.KeyEvent.uChar.UnicodeChar)
#define ALT_PRESSED (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED)
#define CTRL_PRESSED (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)
+ /* Ignore key up events, except for left alt events with non-zero character
+ */
+ if (!input_rec.Event.KeyEvent.bKeyDown &&
+ /*
+ Event for left alt, with a non-zero character, comes from
+ "alt + numerics" key sequence.
+ e.g. <left-alt> 0233 => &eacute;
+ */
+ !(wch != 0
+ // ?? experimentally determined on an XP system
+ && virtual_key_code == VK_MENU
+ // left alt -- see http://www.microsoft.com/hwdev/tech/input/Scancode.asp
+ && input_rec.Event.KeyEvent.wVirtualScanCode == 0x38))
+ continue;
+
if (wch == 0 ||
/* arrow/function keys */
(input_rec.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY))
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 26f58c44a26..09804405053 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -287,14 +287,18 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
if (pc.isdir ())
buf->st_mode = S_IFDIR;
else if (pc.issymlink ())
- buf->st_mode = S_IFLNK;
+ {
+ /* symlinks are everything for everyone! */
+ buf->st_mode = S_IFLNK | S_IRWXU | S_IRWXG | S_IRWXO;
+ get_file_attribute (pc->has_acls (), get_win32_name (), NULL,
+ &buf->st_uid, &buf->st_gid);
+ goto done;
+ }
else if (pc.issocket ())
buf->st_mode = S_IFSOCK;
- __uid32_t uid;
- __gid32_t gid;
if (get_file_attribute (pc.has_acls (), get_win32_name (), &buf->st_mode,
- &uid, &gid) == 0)
+ &buf->st_uid, &buf->st_gid) == 0)
{
/* If read-only attribute is set, modify ntsec return value */
if (pc.has_attribute (FILE_ATTRIBUTE_READONLY) && !get_symlink_p ())
@@ -315,8 +319,6 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
buf->st_mode |= S_IFDIR | STD_XBITS;
else if (buf->st_mode & S_IFMT)
/* nothing */;
- else if (pc.issocket ())
- buf->st_mode |= S_IFSOCK;
else if (is_fs_special ())
{
buf->st_dev = dev ();
@@ -355,15 +357,12 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
buf->st_mode |= STD_XBITS;
}
- buf->st_uid = uid;
- buf->st_gid = gid;
-
/* The number of links to a directory includes the
number of subdirectories in the directory, since all
those subdirectories point to it.
This is too slow on remote drives, so we do without it and
set the number of links to 2. */
-
+ done:
syscall_printf ("0 = fstat (, %p) st_atime=%x st_size=%D, st_mode=%p, st_ino=%d, sizeof=%d",
buf, buf->st_atime, buf->st_size, buf->st_mode,
(int) buf->st_ino, sizeof (*buf));
diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc
index ed0ef5e1ee9..e6a065f2a80 100644
--- a/winsup/cygwin/fhandler_proc.cc
+++ b/winsup/cygwin/fhandler_proc.cc
@@ -28,6 +28,7 @@ details. */
#include <sys/param.h>
#include "ntdll.h"
#include <winioctl.h>
+#include "cpuid.h"
#define _COMPILING_NEWLIB
#include <dirent.h>
@@ -545,37 +546,6 @@ format_proc_stat (char *destbuf, size_t maxsize)
bufptr += sizeof (x) - 1; \
} while (0)
-static inline void
-cpuid (unsigned *a, unsigned *b, unsigned *c, unsigned *d, unsigned in)
-{
- asm ("cpuid"
- : "=a" (*a),
- "=b" (*b),
- "=c" (*c),
- "=d" (*d)
- : "a" (in));
-}
-
-static inline bool
-can_set_flag (unsigned flag)
-{
- unsigned r1, r2;
- asm("pushfl\n"
- "popl %0\n"
- "movl %0, %1\n"
- "xorl %2, %0\n"
- "pushl %0\n"
- "popfl\n"
- "pushfl\n"
- "popl %0\n"
- "pushl %1\n"
- "popfl\n"
- : "=&r" (r1), "=&r" (r2)
- : "ir" (flag)
- );
- return ((r1 ^ r2) & flag) != 0;
-}
-
static _off64_t
format_proc_cpuinfo (char *destbuf, size_t maxsize)
{
@@ -631,7 +601,7 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
{
bufptr += __small_sprintf (bufptr, "processor : %d\n", cpu_number);
read_value ("VendorIdentifier", REG_SZ);
- bufptr += __small_sprintf (bufptr, "vendor id : %s\n", szBuffer);
+ bufptr += __small_sprintf (bufptr, "vendor_id : %s\n", szBuffer);
read_value ("Identifier", REG_SZ);
bufptr += __small_sprintf (bufptr, "identifier : %s\n", szBuffer);
if (wincap.is_winnt ())
@@ -665,7 +635,7 @@ format_proc_cpuinfo (char *destbuf, size_t maxsize)
cpuid (&maxf, &vendor_id[0], &vendor_id[2], &vendor_id[1], 0);
maxf &= 0xffff;
vendor_id[3] = 0;
- bufptr += __small_sprintf (bufptr, "vendor id : %s\n", (char *)vendor_id);
+ bufptr += __small_sprintf (bufptr, "vendor_id : %s\n", (char *)vendor_id);
unsigned cpu_mhz = 0;
if (wincap.is_winnt ())
{
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 33e97641247..322b80a256b 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -9,6 +9,8 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
+#include <wingdi.h>
+#include <winuser.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -554,7 +556,21 @@ fhandler_tty_slave::open (int flags, mode_t)
set_open_status ();
if (!output_done_event)
{
- fhandler_console::open_fhs++;
+ if (fhandler_console::open_fhs++ == 0
+ && wincap.pty_needs_alloc_console ())
+ {
+ BOOL b;
+ HWINSTA h = CreateWindowStation (NULL, 0, GENERIC_READ | GENERIC_WRITE, &sec_none_nih);
+ termios_printf ("CreateWindowStation %p, %E", h);
+ if (h)
+ {
+ b = SetProcessWindowStation (h);
+ termios_printf ("SetProcessWindowStation %d, %E", b);
+ }
+ b = AllocConsole (); // will cause flashing if workstation
+ // stuff fails
+ termios_printf ("%d = AllocConsole ()", b);
+ }
termios_printf ("incremented open_fhs %d", fhandler_console::open_fhs);
}
termios_printf ("tty%d opened", get_unit ());
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index d3fd4e2a831..ac1708a6ea6 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -325,11 +325,11 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
return 0;
}
-#ifdef SLOW_PID_REUSE
+#ifndef NO_SLOW_PID_REUSE
static void
slow_pid_reuse (HANDLE h)
{
- static NO_COPY HANDLE last_fork_procs[8] = {0};
+ static NO_COPY HANDLE last_fork_procs[4] = {0};
static NO_COPY unsigned nfork_procs = 0;
if (nfork_procs >= (sizeof (last_fork_procs) / sizeof (last_fork_procs [0])))
@@ -538,7 +538,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
goto cleanup;
}
-#ifdef SLOW_PID_REUSE
+#ifndef NO_SLOW_PID_REUSE
slow_pid_reuse (pi.hProcess);
#endif
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 39881e3dda5..f4df7580d73 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -108,6 +108,22 @@ pwdgrp::read_group ()
return;
}
+pwdgrp::pwdgrp (passwd *&pbuf) :
+ pwdgrp_buf_elem_size (sizeof (*pbuf)), passwd_buf (&pbuf)
+{
+ read = &pwdgrp::read_passwd;
+ parse = &pwdgrp::parse_passwd;
+ new_muto (pglock);
+}
+
+pwdgrp::pwdgrp (__group32 *&gbuf) :
+ pwdgrp_buf_elem_size (sizeof (*gbuf)), group_buf (&gbuf)
+{
+ read = &pwdgrp::read_group;
+ parse = &pwdgrp::parse_group;
+ new_muto (pglock);
+}
+
struct __group32 *
internal_getgrsid (cygpsid &sid)
{
diff --git a/winsup/cygwin/include/cygwin/config.h b/winsup/cygwin/include/cygwin/config.h
new file mode 100644
index 00000000000..4bafa3c18a8
--- /dev/null
+++ b/winsup/cygwin/include/cygwin/config.h
@@ -0,0 +1,39 @@
+/* cygwin/config.h header file for Cygwin.
+
+ This wraps Cygwin configuration setting which were in newlib's
+ sys/config.h before. THis way we can manaage our configuration
+ setting without bothering newlib.
+
+ Copyright 2003 Red Hat, Inc.
+ Written by C. Vinschen.
+
+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 _CYGWIN_CONFIG_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define _CYGWIN_CONFIG_H
+
+#define __FILENAME_MAX__ (260 - 1 /* NUL */)
+#define _READ_WRITE_RETURN_TYPE _ssize_t
+#define __LARGE64_FILES 1
+#define __CYGWIN_USE_BIG_TYPES__ 1
+#if defined(__INSIDE_CYGWIN__) || defined(_COMPILING_NEWLIB)
+#define __IMPORT
+#else
+#define __IMPORT __declspec(dllimport)
+#endif
+
+#ifndef __WCHAR_MAX__
+#define __WCHAR_MAX__ 0xffffu
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _CYGWIN_CONFIG_H */
diff --git a/winsup/cygwin/include/cygwin/in.h b/winsup/cygwin/include/cygwin/in.h
index af880f195a2..a2124552ffd 100644
--- a/winsup/cygwin/include/cygwin/in.h
+++ b/winsup/cygwin/include/cygwin/in.h
@@ -18,7 +18,7 @@
#ifndef _CYGWIN_IN_H
#define _CYGWIN_IN_H
-#include <sys/types.h>
+#include <stdint.h>
/* Standard well-defined IP protocols. */
enum
diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h
index d5173b94b8d..8a26ef0a4fb 100644
--- a/winsup/cygwin/include/cygwin/types.h
+++ b/winsup/cygwin/include/cygwin/types.h
@@ -18,6 +18,7 @@ extern "C"
#define _CYGWIN_TYPES_H
#include <sys/sysmacros.h>
+#include <stdint.h>
#ifndef __timespec_t_defined
#define __timespec_t_defined
@@ -89,11 +90,7 @@ typedef __gid16_t gid_t;
#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
@@ -109,40 +106,6 @@ typedef unsigned long vm_offset_t;
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 __u_int8_t_defined
#define __u_int8_t_defined
typedef unsigned char u_int8_t;
@@ -160,16 +123,6 @@ typedef __uint32_t u_int32_t;
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;
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index dd5af1eab4b..cd49fa58952 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -41,8 +41,8 @@ details. */
the Cygwin library". This version is used to track important
changes to the DLL and is mainly informative in nature. */
-#define CYGWIN_VERSION_DLL_MAJOR 1003
-#define CYGWIN_VERSION_DLL_MINOR 23
+#define CYGWIN_VERSION_DLL_MAJOR 1005
+#define CYGWIN_VERSION_DLL_MINOR 0
/* Major numbers before CYGWIN_VERSION_DLL_EPOCH are
incompatible. */
@@ -198,12 +198,19 @@ details. */
_open64 _lseek64 _fstat64 _stat64 mknod32
80: Export pthread_rwlock stuff
81: CW_CHECK_NTSEC addition to external.cc
+ 82: Export wcscoll wcswidth wcwidth
+ 83: Export gethostid
+ 84: Pty open allocates invisible console. 64 bit interface
+ 85: Export new 32/64 functions from API 0.79 only with leading
+ underscore. No problems with backward compatibility since no
+ official release has been made so far. This change removes
+ exported symbols like fopen64, which might confuse configure.
*/
/* Note that we forgot to bump the api for ualarm, strtoll, strtoull */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 81
+#define CYGWIN_VERSION_API_MINOR 85
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
diff --git a/winsup/cygwin/include/inttypes.h b/winsup/cygwin/include/inttypes.h
new file mode 100644
index 00000000000..1d0410ad8c9
--- /dev/null
+++ b/winsup/cygwin/include/inttypes.h
@@ -0,0 +1,246 @@
+/* inttypes.h - fixed size integer types
+
+ Copyright 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 _INTTYPES_H
+#define _INTTYPES_H
+
+#include <stdint.h>
+
+/* fprintf() macros for signed integers */
+
+#define PRId8 "d"
+#define PRId16 "d"
+#define PRId32 "ld"
+#define PRId64 "lld"
+
+#define PRIdLEAST8 "d"
+#define PRIdLEAST16 "d"
+#define PRIdLEAST32 "ld"
+#define PRIdLEAST64 "lld"
+
+#define PRIdFAST8 "d"
+#define PRIdFAST16 "ld"
+#define PRIdFAST32 "ld"
+#define PRIdFAST64 "lld"
+
+#define PRIdMAX "lld"
+#define PRIdPTR "ld"
+
+#define PRIi8 "i"
+#define PRIi16 "i"
+#define PRIi32 "li"
+#define PRIi64 "lli"
+
+#define PRIiLEAST8 "i"
+#define PRIiLEAST16 "i"
+#define PRIiLEAST32 "li"
+#define PRIiLEAST64 "lli"
+
+#define PRIiFAST8 "i"
+#define PRIiFAST16 "li"
+#define PRIiFAST32 "li"
+#define PRIiFAST64 "lli"
+
+#define PRIiMAX "lli"
+#define PRIiPTR "li"
+
+/* fprintf() macros for unsigned integers */
+
+#define PRIo8 "o"
+#define PRIo16 "o"
+#define PRIo32 "lo"
+#define PRIo64 "llo"
+
+#define PRIoLEAST8 "o"
+#define PRIoLEAST16 "o"
+#define PRIoLEAST32 "lo"
+#define PRIoLEAST64 "llo"
+
+#define PRIoFAST8 "o"
+#define PRIoFAST16 "lo"
+#define PRIoFAST32 "lo"
+#define PRIoFAST64 "llo"
+
+#define PRIoMAX "llo"
+#define PRIoPTR "lo"
+
+#define PRIu8 "u"
+#define PRIu16 "u"
+#define PRIu32 "lu"
+#define PRIu64 "llu"
+
+#define PRIuLEAST8 "u"
+#define PRIuLEAST16 "u"
+#define PRIuLEAST32 "lu"
+#define PRIuLEAST64 "llu"
+
+#define PRIuFAST8 "u"
+#define PRIuFAST16 "lu"
+#define PRIuFAST32 "lu"
+#define PRIuFAST64 "llu"
+
+#define PRIuMAX "llu"
+#define PRIuPTR "lu"
+
+#define PRIx8 "x"
+#define PRIx16 "x"
+#define PRIx32 "lx"
+#define PRIx64 "llx"
+
+#define PRIxLEAST8 "x"
+#define PRIxLEAST16 "x"
+#define PRIxLEAST32 "lx"
+#define PRIxLEAST64 "llx"
+
+#define PRIxFAST8 "x"
+#define PRIxFAST16 "lx"
+#define PRIxFAST32 "lx"
+#define PRIxFAST64 "llx"
+
+#define PRIxMAX "llx"
+#define PRIxPTR "lx"
+
+#define PRIX8 "X"
+#define PRIX16 "X"
+#define PRIX32 "lX"
+#define PRIX64 "llX"
+
+#define PRIXLEAST8 "X"
+#define PRIXLEAST16 "X"
+#define PRIXLEAST32 "lX"
+#define PRIXLEAST64 "llX"
+
+#define PRIXFAST8 "X"
+#define PRIXFAST16 "lX"
+#define PRIXFAST32 "lX"
+#define PRIXFAST64 "llX"
+
+#define PRIXMAX "llX"
+#define PRIXPTR "lX"
+
+/* fscanf() macros for signed integers */
+
+#define SCNd8 "hhd"
+#define SCNd16 "hd"
+#define SCNd32 "ld"
+#define SCNd64 "lld"
+
+#define SCNdLEAST8 "hhd"
+#define SCNdLEAST16 "hd"
+#define SCNdLEAST32 "ld"
+#define SCNdLEAST64 "lld"
+
+#define SCNdFAST8 "hhd"
+#define SCNdFAST16 "ld"
+#define SCNdFAST32 "ld"
+#define SCNdFAST64 "lld"
+
+#define SCNdMAX "lld"
+#define SCNdPTR "ld"
+
+#define SCNi8 "hhi"
+#define SCNi16 "hi"
+#define SCNi32 "li"
+#define SCNi64 "lli"
+
+#define SCNiLEAST8 "hhi"
+#define SCNiLEAST16 "hi"
+#define SCNiLEAST32 "li"
+#define SCNiLEAST64 "lli"
+
+#define SCNiFAST8 "hhi"
+#define SCNiFAST16 "li"
+#define SCNiFAST32 "li"
+#define SCNiFAST64 "lli"
+
+#define SCNiMAX "lli"
+#define SCNiPTR "li"
+
+/* fscanf() macros for unsigned integers */
+
+#define SCNo8 "hho"
+#define SCNo16 "ho"
+#define SCNo32 "lo"
+#define SCNo64 "llo"
+
+#define SCNoLEAST8 "hho"
+#define SCNoLEAST16 "ho"
+#define SCNoLEAST32 "lo"
+#define SCNoLEAST64 "llo"
+
+#define SCNoFAST8 "hho"
+#define SCNoFAST16 "lo"
+#define SCNoFAST32 "lo"
+#define SCNoFAST64 "llo"
+
+#define SCNoMAX "llo"
+#define SCNoPTR "lo"
+
+#define SCNu8 "hhu"
+#define SCNu16 "hu"
+#define SCNu32 "lu"
+#define SCNu64 "llu"
+
+#define SCNuLEAST8 "hhu"
+#define SCNuLEAST16 "hu"
+#define SCNuLEAST32 "lu"
+#define SCNuLEAST64 "llu"
+
+#define SCNuFAST8 "hhu"
+#define SCNuFAST16 "lu"
+#define SCNuFAST32 "lu"
+#define SCNuFAST64 "llu"
+
+#define SCNuMAX "llu"
+#define SCNuPTR "lu"
+
+#define SCNx8 "hhx"
+#define SCNx16 "hx"
+#define SCNx32 "lx"
+#define SCNx64 "llx"
+
+#define SCNxLEAST8 "hhx"
+#define SCNxLEAST16 "hx"
+#define SCNxLEAST32 "lx"
+#define SCNxLEAST64 "llx"
+
+#define SCNxFAST8 "hhx"
+#define SCNxFAST16 "lx"
+#define SCNxFAST32 "lx"
+#define SCNxFAST64 "llx"
+
+#define SCNxMAX "llx"
+#define SCNxPTR "lx"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <_ansi.h>
+
+typedef struct {
+ intmax_t quot;
+ intmax_t rem;
+} imaxdiv_t;
+
+#if 0 /* Not yet defined */
+intmax_t _EXFUN(imaxabs, (intmax_t));
+imaxdiv_t _EXFUN(imaxdiv, (intmax_t, intmax_t));
+intmax_t _EXFUN(strtoimax, (const char *, char **, int));
+uintmax_t _EXFUN(strtoumax, (const char *, char **, int));
+intmax_t _EXFUN(wcstoimax, (const wchar_t *, wchar_t **, int));
+uintmax_t _EXFUN(wcstoumax, (const wchar_t *, wchar_t **, int));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _INTTYPES_H */
diff --git a/winsup/cygwin/include/limits.h b/winsup/cygwin/include/limits.h
new file mode 100644
index 00000000000..9fa3cf4fe27
--- /dev/null
+++ b/winsup/cygwin/include/limits.h
@@ -0,0 +1,169 @@
+/* limits.h
+
+ Copyright 1999, 2000, 2001 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 _LIMITS_H___
+#ifndef _MACH_MACHLIMITS_H_
+
+/* _MACH_MACHLIMITS_H_ is used on OSF/1. */
+#define _LIMITS_H___
+#define _MACH_MACHLIMITS_H_
+
+/* Number of bits in a `char'. */
+#undef CHAR_BIT
+#define CHAR_BIT 8
+
+/* Maximum length of a multibyte character. */
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 1
+#endif
+
+/* Minimum and maximum values a `signed char' can hold. */
+#undef SCHAR_MIN
+#define SCHAR_MIN (-128)
+#undef SCHAR_MAX
+#define SCHAR_MAX 127
+
+/* Maximum value an `unsigned char' can hold. (Minimum is 0). */
+#undef UCHAR_MAX
+#define UCHAR_MAX 255
+
+/* Minimum and maximum values a `char' can hold. */
+#ifdef __CHAR_UNSIGNED__
+#undef CHAR_MIN
+#define CHAR_MIN 0
+#undef CHAR_MAX
+#define CHAR_MAX 255
+#else
+#undef CHAR_MIN
+#define CHAR_MIN (-128)
+#undef CHAR_MAX
+#define CHAR_MAX 127
+#endif
+
+/* Minimum and maximum values a `signed short int' can hold. */
+#undef SHRT_MIN
+#define SHRT_MIN (-32768)
+#undef SHRT_MAX
+#define SHRT_MAX 32767
+
+/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */
+#undef USHRT_MAX
+#define USHRT_MAX 65535
+
+/* Minimum and maximum values a `signed int' can hold. */
+#ifndef __INT_MAX__
+#define __INT_MAX__ 2147483647
+#endif
+#undef INT_MIN
+#define INT_MIN (-INT_MAX-1)
+#undef INT_MAX
+#define INT_MAX __INT_MAX__
+
+/* Maximum value an `unsigned int' can hold. (Minimum is 0). */
+#undef UINT_MAX
+#define UINT_MAX (INT_MAX * 2U + 1)
+
+/* Minimum and maximum values a `signed long int' can hold.
+ (Same as `int'). */
+#ifndef __LONG_MAX__
+#ifndef __alpha__
+#define __LONG_MAX__ 2147483647L
+#else
+#define __LONG_MAX__ 9223372036854775807L
+# endif /* __alpha__ */
+#endif
+#undef LONG_MIN
+#define LONG_MIN (-LONG_MAX-1)
+#undef LONG_MAX
+#define LONG_MAX __LONG_MAX__
+
+/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */
+#undef ULONG_MAX
+#define ULONG_MAX (LONG_MAX * 2UL + 1)
+
+/* Minimum and maximum values a `signed long long int' can hold. */
+#ifndef __LONG_LONG_MAX__
+#define __LONG_LONG_MAX__ 9223372036854775807LL
+#endif
+
+#if defined (__GNU_LIBRARY__) ? defined (__USE_GNU) : !defined (__STRICT_ANSI__)
+#undef LONG_LONG_MIN
+#define LONG_LONG_MIN (-LONG_LONG_MAX-1)
+#undef LONG_LONG_MAX
+#define LONG_LONG_MAX __LONG_LONG_MAX__
+
+/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
+#undef ULONG_LONG_MAX
+#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1)
+#endif
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+/* Minimum and maximum values a `signed long long int' can hold. */
+#undef LLONG_MIN
+#define LLONG_MIN (-LLONG_MAX-1)
+#undef LLONG_MAX
+#define LLONG_MAX __LONG_LONG_MAX__
+
+/* Maximum value an `unsigned long long int' can hold. (Minimum is 0). */
+#undef ULLONG_MAX
+#define ULLONG_MAX (LLONG_MAX * 2ULL + 1)
+#endif
+
+/* Maximum number of iovcnt in a writev (an arbitrary number) */
+#undef IOV_MAX
+#define IOV_MAX 1024
+
+/* Maximum size of ssize_t */
+#undef SSIZE_MAX
+#define SSIZE_MAX (__LONG_MAX__)
+
+/* Maximum length of a path */
+#define PATH_MAX (260 - 1 /*NUL*/)
+
+/* Max num groups for a user, value taken from NT documentation */
+/* Must match <sys/param.h> NGROUPS */
+#define NGROUPS_MAX 16
+
+/* WaitForMultipleObjects can't handle waiting for more than 64 objects.
+ This limits how many children we can fork/spawn off. */
+#define CHILD_MAX 63
+
+/* # of open files per process. Actually it can be more since Cygwin
+ grows the dtable as necessary. We define a reasonable limit here
+ which is returned by getdtablesize(), sysconf(_SC_OPEN_MAX) and
+ getrlimit(RLIMIT_NOFILE). */
+#undef OPEN_MAX
+#define OPEN_MAX 256
+
+/* # of bytes in a pipe buf. This is the max # of bytes which can be
+ written to a pipe in one atomic operation. */
+#undef PIPE_BUF
+#define PIPE_BUF 4096
+
+/* POSIX values */
+/* These should never vary from one system type to another */
+/* They represent the minimum values that POSIX systems must support.
+ POSIX-conforming apps must not require larger values. */
+#define _POSIX_ARG_MAX 4096
+#define _POSIX_CHILD_MAX 6
+#define _POSIX_LINK_MAX 8
+#define _POSIX_MAX_CANON 255
+#define _POSIX_MAX_INPUT 255
+#define _POSIX_NAME_MAX 14
+#define _POSIX_NGROUPS_MAX 0
+#define _POSIX_OPEN_MAX 16
+#define _POSIX_PATH_MAX 255
+#define _POSIX_PIPE_BUF 512
+#define _POSIX_SSIZE_MAX 32767
+#define _POSIX_STREAM_MAX 8
+#define _POSIX_TZNAME_MAX 3
+
+#endif /* _MACH_MACHLIMITS_H_ */
+#endif /* _LIMITS_H___ */
diff --git a/winsup/cygwin/include/netinet/ip.h b/winsup/cygwin/include/netinet/ip.h
new file mode 100644
index 00000000000..87b5068d057
--- /dev/null
+++ b/winsup/cygwin/include/netinet/ip.h
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip.h 8.2 (Berkeley) 6/1/94
+ * $FreeBSD: src/sys/netinet/ip.h,v 1.17 1999/12/22 19:13:20 shin Exp $
+ */
+
+#ifndef _NETINET_IP_H
+#define _NETINET_IP_H
+
+#include <netinet/in_systm.h>
+#include <netinet/in.h>
+
+/* Added by Wu Yongwei */
+#ifndef LITTLE_ENDIAN
+#define LITTLE_ENDIAN 1234
+#define BIG_ENDIAN 4321
+#endif
+#ifndef BYTE_ORDER
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+/*
+ * Definitions for internet protocol version 4.
+ * Per RFC 791, September 1981.
+ */
+#define IPVERSION 4
+
+/*
+ * Structure of an internet header, naked of options.
+ */
+struct ip {
+#ifdef _IP_VHL
+ u_char ip_vhl; /* version << 4 | header length >> 2 */
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+ u_int ip_hl:4, /* header length */
+ ip_v:4; /* version */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ u_int ip_v:4, /* version */
+ ip_hl:4; /* header length */
+#endif
+#endif /* not _IP_VHL */
+ u_char ip_tos; /* type of service */
+ u_short ip_len; /* total length */
+ u_short ip_id; /* identification */
+ u_short ip_off; /* fragment offset field */
+#define IP_RF 0x8000 /* reserved fragment flag */
+#define IP_DF 0x4000 /* dont fragment flag */
+#define IP_MF 0x2000 /* more fragments flag */
+#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
+ u_char ip_ttl; /* time to live */
+ u_char ip_p; /* protocol */
+ u_short ip_sum; /* checksum */
+ struct in_addr ip_src,ip_dst; /* source and dest address */
+};
+
+#ifdef _IP_VHL
+#define IP_MAKE_VHL(v, hl) ((v) << 4 | (hl))
+#define IP_VHL_HL(vhl) ((vhl) & 0x0f)
+#define IP_VHL_V(vhl) ((vhl) >> 4)
+#define IP_VHL_BORING 0x45
+#endif
+
+#define IP_MAXPACKET 65535 /* maximum packet size */
+
+/*
+ * Definitions for IP type of service (ip_tos)
+ */
+#ifndef IPTOS_LOWDELAY
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#endif
+#define IPTOS_MINCOST 0x02
+/* ECN bits proposed by Sally Floyd */
+#define IPTOS_CE 0x01 /* congestion experienced */
+#define IPTOS_ECT 0x02 /* ECN-capable transport */
+
+
+/*
+ * Definitions for IP precedence (also in ip_tos) (hopefully unused)
+ */
+#define IPTOS_PREC_NETCONTROL 0xe0
+#define IPTOS_PREC_INTERNETCONTROL 0xc0
+#define IPTOS_PREC_CRITIC_ECP 0xa0
+#define IPTOS_PREC_FLASHOVERRIDE 0x80
+#define IPTOS_PREC_FLASH 0x60
+#define IPTOS_PREC_IMMEDIATE 0x40
+#define IPTOS_PREC_PRIORITY 0x20
+#define IPTOS_PREC_ROUTINE 0x00
+
+/*
+ * Definitions for options.
+ */
+#define IPOPT_COPIED(o) ((o)&0x80)
+#define IPOPT_CLASS(o) ((o)&0x60)
+#define IPOPT_NUMBER(o) ((o)&0x1f)
+
+#define IPOPT_CONTROL 0x00
+#define IPOPT_RESERVED1 0x20
+#define IPOPT_DEBMEAS 0x40
+#define IPOPT_RESERVED2 0x60
+
+#define IPOPT_EOL 0 /* end of option list */
+#define IPOPT_NOP 1 /* no operation */
+
+#define IPOPT_RR 7 /* record packet route */
+#define IPOPT_TS 68 /* timestamp */
+#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
+#define IPOPT_LSRR 131 /* loose source route */
+#define IPOPT_SATID 136 /* satnet id */
+#define IPOPT_SSRR 137 /* strict source route */
+#define IPOPT_RA 148 /* router alert */
+
+/*
+ * Offsets to fields in options other than EOL and NOP.
+ */
+#define IPOPT_OPTVAL 0 /* option ID */
+#define IPOPT_OLEN 1 /* option length */
+#define IPOPT_OFFSET 2 /* offset within option */
+#define IPOPT_MINOFF 4 /* min value of above */
+
+/*
+ * Time stamp option structure.
+ */
+struct ip_timestamp {
+ u_char ipt_code; /* IPOPT_TS */
+ u_char ipt_len; /* size of structure (variable) */
+ u_char ipt_ptr; /* index of current entry */
+#if BYTE_ORDER == LITTLE_ENDIAN
+ u_int ipt_flg:4, /* flags, see below */
+ ipt_oflw:4; /* overflow counter */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ u_int ipt_oflw:4, /* overflow counter */
+ ipt_flg:4; /* flags, see below */
+#endif
+ union ipt_timestamp {
+ n_long ipt_time[1];
+ struct ipt_ta {
+ struct in_addr ipt_addr;
+ n_long ipt_time;
+ } ipt_ta[1];
+ } ipt_timestamp;
+};
+
+/* flag bits for ipt_flg */
+#define IPOPT_TS_TSONLY 0 /* timestamps only */
+#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC 3 /* specified modules only */
+
+/* bits for security (not byte swapped) */
+#define IPOPT_SECUR_UNCLASS 0x0000
+#define IPOPT_SECUR_CONFID 0xf135
+#define IPOPT_SECUR_EFTO 0x789a
+#define IPOPT_SECUR_MMMM 0xbc4d
+#define IPOPT_SECUR_RESTR 0xaf13
+#define IPOPT_SECUR_SECRET 0xd788
+#define IPOPT_SECUR_TOPSECRET 0x6bc5
+
+/*
+ * Internet implementation parameters.
+ */
+#define MAXTTL 255 /* maximum time to live (seconds) */
+#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
+#define IPFRAGTTL 60 /* time to live for frags, slowhz */
+#define IPTTLDEC 1 /* subtracted when forwarding */
+
+#define IP_MSS 576 /* default maximum segment size */
+
+#endif
diff --git a/winsup/cygwin/include/stdint.h b/winsup/cygwin/include/stdint.h
new file mode 100644
index 00000000000..66fd49d3f44
--- /dev/null
+++ b/winsup/cygwin/include/stdint.h
@@ -0,0 +1,182 @@
+/* stdint.h - integer types
+
+ Copyright 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 _STDINT_H
+#define _STDINT_H
+
+/* Exact-width integer types */
+
+#ifndef __int8_t_defined
+#define __int8_t_defined
+typedef signed char int8_t;
+typedef short int16_t;
+typedef long int32_t;
+typedef long long int64_t;
+#endif
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+#ifndef __uint32_t_defined
+#define __uint32_t_defined
+typedef unsigned long uint32_t;
+#endif
+typedef unsigned long long uint64_t;
+
+/* Minimum-width integer types */
+
+typedef signed char int_least8_t;
+typedef short int_least16_t;
+typedef long int_least32_t;
+typedef long long int_least64_t;
+
+typedef unsigned char uint_least8_t;
+typedef unsigned short uint_least16_t;
+typedef unsigned long uint_least32_t;
+typedef unsigned long long uint_least64_t;
+
+/* Fastest minimum-width integer types */
+
+typedef signed char int_fast8_t;
+typedef long int_fast16_t;
+typedef long int_fast32_t;
+typedef long long int_fast64_t;
+
+typedef unsigned char uint_fast8_t;
+typedef unsigned long uint_fast16_t;
+typedef unsigned long uint_fast32_t;
+typedef unsigned long long uint_fast64_t;
+
+/* Integer types capable of holding object pointers */
+
+#ifndef __intptr_t_defined
+#define __intptr_t_defined
+typedef long intptr_t;
+#endif
+typedef unsigned long uintptr_t;
+
+/* Greatest-width integer types */
+
+typedef long long intmax_t;
+typedef unsigned long long uintmax_t;
+
+/* Limits of exact-width integer types */
+
+#define INT8_MIN (-128)
+#define INT16_MIN (-32768)
+#define INT32_MIN (-2147483648)
+#define INT64_MIN (-9223372036854775808)
+
+#define INT8_MAX (127)
+#define INT16_MAX (32767)
+#define INT32_MAX (2147483647)
+#define INT64_MAX (9223372036854775807)
+
+#define UINT8_MAX (255)
+#define UINT16_MAX (65535)
+#define UINT32_MAX (4294967295UL)
+#define UINT64_MAX (18446744073709551615ULL)
+
+/* Limits of minimum-width integer types */
+
+#define INT_LEAST8_MIN (-128)
+#define INT_LEAST16_MIN (-32768)
+#define INT_LEAST32_MIN (-2147483648)
+#define INT_LEAST64_MIN (-9223372036854775808)
+
+#define INT_LEAST8_MAX (127)
+#define INT_LEAST16_MAX (32767)
+#define INT_LEAST32_MAX (2147483647)
+#define INT_LEAST64_MAX (9223372036854775807)
+
+#define UINT_LEAST8_MAX (255)
+#define UINT_LEAST16_MAX (65535)
+#define UINT_LEAST32_MAX (4294967295UL)
+#define UINT_LEAST64_MAX (18446744073709551615ULL)
+
+/* Limits of fastest minimum-width integer types */
+
+#define INT_FAST8_MIN (-128)
+#define INT_FAST16_MIN (-2147483648)
+#define INT_FAST32_MIN (-2147483648)
+#define INT_FAST64_MIN (-9223372036854775808)
+
+#define INT_FAST8_MAX (127)
+#define INT_FAST16_MAX (2147483647)
+#define INT_FAST32_MAX (2147483647)
+#define INT_FAST64_MAX (9223372036854775807)
+
+#define UINT_FAST8_MAX (255)
+#define UINT_FAST16_MAX (4294967295UL)
+#define UINT_FAST32_MAX (4294967295UL)
+#define UINT_FAST64_MAX (18446744073709551615ULL)
+
+/* Limits of integer types capable of holding object pointers */
+
+#define INTPTR_MIN (-2147483648)
+#define INTPTR_MAX (2147483647)
+#define UINTPTR_MAX (4294967295UL)
+
+/* Limits of greatest-width integer types */
+
+#define INTMAX_MIN (-9223372036854775808)
+#define INTMAX_MAX (9223372036854775807)
+#define UINTMAX_MAX (18446744073709551615ULL)
+
+/* Limits of other integer types */
+
+#ifndef PTRDIFF_MIN
+#define PTRDIFF_MIN (-2147483648)
+#define PTRDIFF_MAX (2147483647)
+#endif
+
+#ifndef SIG_ATOMIC_MIN
+#define SIG_ATOMIC_MIN (-2147483648)
+#endif
+#ifndef SIG_ATOMIC_MAX
+#define SIG_ATOMIC_MAX (2147483647)
+#endif
+
+#ifndef SIZE_MAX
+#define SIZE_MAX (4294967295UL)
+#endif
+
+#ifndef WCHAR_MIN
+#ifdef __WCHAR_MIN__
+#define WCHAR_MIN __WCHAR_MIN__
+#define WCHAR_MAX __WCHAR_MAX__
+#else
+#define WCHAR_MIN (0)
+#define WCHAR_MAX (65535)
+#endif
+#endif
+
+#ifndef WINT_MIN
+#define WINT_MIN (-2147483648)
+#define WINT_MAX (2147483647)
+#endif
+
+/* Macros for minimum-width integer constant expressions */
+
+#define INT8_C(x) x
+#define INT16_C(x) x
+#define INT32_C(x) x ## L
+#define INT64_C(x) x ## LL
+
+#define UINT8_C(x) x ## U
+#define UINT16_C(x) x ## U
+#define UINT32_C(x) x ## UL
+#define UINT64_C(x) x ## ULL
+
+/* Macros for greatest-width integer constant expressions */
+
+#define INTMAX_C(x) x ## L
+#define UINTMAX_C(x) x ## UL
+
+#endif /* _STDINT_H */
diff --git a/winsup/cygwin/mkvers.sh b/winsup/cygwin/mkvers.sh
new file mode 100644
index 00000000000..d14deb166b2
--- /dev/null
+++ b/winsup/cygwin/mkvers.sh
@@ -0,0 +1,177 @@
+#!/bin/sh
+# mkvers.sh - Make version information for cygwin DLL
+#
+# Copyright 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.
+
+exec 9> version.cc
+
+#
+# Arg 1 is the name of the version include file
+#
+incfile="$1"
+rcfile="$2"
+windres="$3"
+
+[ -r $incfile ] || {
+ echo "**** Couldn't open file '$incfile'. Aborting."
+}
+
+#
+# Load the current date so we can work on individual fields
+#
+build_date=`date`
+set -$- $build_date
+#
+# Translate the month into a number
+#
+case "$2" in
+ Jan) m=01 ;;
+ Feb) m=02 ;;
+ Mar) m=03 ;;
+ Apr) m=04 ;;
+ May) m=05 ;;
+ Jun) m=06 ;;
+ Jul) m=07 ;;
+ Aug) m=08 ;;
+ Sep) m=09 ;;
+ Oct) m=10 ;;
+ Nov) m=11 ;;
+ Dec) m=12 ;;
+esac
+
+if [ "$3" -lt 10 ]; then
+ d=0$3
+else
+ d=$3
+fi
+hhmm="`echo $4 | sed 's/:..$//'`"
+#
+# Set date into YYYY-MM-DD HH:MM:SS format
+#
+builddate="${6-$5}-$m-$d $hhmm"
+
+set -$- ''
+
+#
+# Output the initial part of version.cc
+#
+cat <<EOF 1>&9
+#include "config.h"
+#include "cygwin_version.h"
+
+#define strval(x) #x
+#define str(x) strval(x)
+#define shared_data_version str(CYGWIN_VERSION_SHARED_DATA)
+
+const char *cygwin_version_strings =
+ "BEGIN_CYGWIN_VERSION_INFO\n"
+EOF
+
+#
+# Split version file into dir and filename components
+#
+dir=`dirname $incfile`
+fn=`basename $incfile`
+
+#
+# Look in the include file CVS directory for a CVS Tag file. This file,
+# if it exists, will contain the name of the sticky tag associated with
+# the current build. Save that for output later.
+#
+cvs_tag="`sed 's%^.\(.*\)%\1%' $dir/CVS/Tag 2>/dev/null`"
+
+wv_cvs_tag="$cvs_tag"
+[ -n "$cvs_tag" ] && cvs_tag=" CVS tag"'
+'"$cvs_tag"
+
+#
+# Look in the source directory containing the include/cygwin/version.h
+# and set dir accordingly.
+dir=`echo $dir | sed -e 's%/include/cygwin.*$%%' -e 's%include/cygwin.*$%.%'`
+
+# Look in $dir for a a ".snapshot-date" file. If one is found then this
+# information will be saved for output to the DLL.
+#
+if [ -r "$dir/.snapshot-date" ]; then
+ read snapshotdate < "$dir/.snapshot-date"
+ snapshot="snapshot date
+$snapshotdate"
+fi
+
+#
+# Scan the version.h file for strings that begin with CYGWIN_INFO or
+# CYGWIN_VERSION. Perform crude parsing on the lines to get the values
+# associated with these values and then pipe it into a while loop which
+# outputs these values in C palatable format for inclusion in the DLL
+# with a '%% ' identifier that will introduce "interesting" strings.
+# These strings are strictly for use by a user to scan the DLL for
+# interesting information.
+#
+(sed -n -e 's%#define CYGWIN_INFO_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\
+\2%p' -e 's%#define CYGWIN_VERSION_\([A-Z_]*\)[ ][ ]*\([a-zA-Z0-9"][^/]*\).*%_\1\
+\2%p' $incfile | sed -e 's/["\\]//g' -e '/^_/y/ABCDEFGHIJKLMNOPQRSTUVWXYZ_/abcdefghijklmnopqrstuvwxyz /';
+echo ' build date'; echo $build_date; [ -n "$cvs_tag" ] && echo "$cvs_tag";\
+[ -n "$snapshot" ] && echo "$snapshot"
+) | while read var; do
+ read val
+cat <<EOF
+ "%%% Cygwin $var: $val\n"
+EOF
+done | tee /tmp/mkvers.$$ 1>&9
+
+trap "rm -f /tmp/mkvers.$$" 0 1 2 15
+
+if [ -n "$snapshotdate" ]; then
+ usedate="`echo $snapshotdate | sed 's/-\\(..:..[^-]*\\).*$/ \1SNP/'`"
+else
+ usedate="$builddate"
+fi
+
+#
+# Finally, output the shared ID and set up the cygwin_version structure
+# for use by Cygwin itself.
+#
+cat <<EOF 1>&9
+#ifdef DEBUGGING
+ "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate\n"
+#else
+ "%%% Cygwin shared id: " CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "\n"
+#endif
+ "END_CYGWIN_VERSION_INFO\n\0";
+cygwin_version_info cygwin_version =
+{
+ CYGWIN_VERSION_API_MAJOR, CYGWIN_VERSION_API_MINOR,
+ CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR,
+ CYGWIN_VERSION_SHARED_DATA,
+ CYGWIN_VERSION_MOUNT_REGISTRY,
+ "$usedate",
+#ifdef DEBUGGING
+ CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version "-$builddate"
+#else
+ CYGWIN_VERSION_DLL_IDENTIFIER "S" shared_data_version
+#endif
+};
+EOF
+
+#
+# Generate winver.o using cygwin/version.h information.
+# Turn the cygwin major number from some large number to something like 1.1.0.
+#
+eval `sed -n 's/^.*dll \(m[ai][jn]or\): \([0-9]*\)[^0-9]*$/\1=\2/p' /tmp/mkvers.$$`
+cygverhigh=`expr $major / 1000`
+cygverlow=`expr $major % 1000`
+cygwin_ver="$cygverhigh.$cygverlow.$minor"
+if [ -n "$cvs_tag" ]; then
+ cvs_tag="`echo $wv_cvs_tag | sed -e 's/-branch.*//'`"
+ cygwin_ver="$cygwin_ver-$cvs_tag"
+fi
+
+echo "Version $cygwin_ver"
+set -$- $builddate
+$windres --include-dir $dir/../w32api/include --include-dir $dir/include --define CYGWIN_BUILD_DATE="$1" --define CYGWIN_BUILD_TIME="$2" --define CYGWIN_VERSION='"'"$cygwin_ver"'"' $rcfile winver.o
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 786cc7a345f..3d4131f5e67 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -359,27 +359,27 @@ fs_info::update (const char *win32_path)
if (!rootdir (tmp_buf))
{
debug_printf ("Cannot get root component of path %s", win32_path);
- name [0] = '\0';
- sym_opt = flags = serial = 0;
+ name_storage [0] = '\0';
+ sym_opt_storage = flags_storage = serial_storage = 0;
return false;
}
- if (strcmp (tmp_buf, root_dir) == 0)
+ if (strcmp (tmp_buf, root_dir_storage) == 0)
return 1;
- strncpy (root_dir, tmp_buf, MAX_PATH);
- drive_type = GetDriveType (root_dir);
- if (drive_type == DRIVE_REMOTE || (drive_type == DRIVE_UNKNOWN && (root_dir[0] == '\\' && root_dir[1] == '\\')))
- is_remote_drive = 1;
+ strncpy (root_dir_storage, tmp_buf, MAX_PATH);
+ drive_type_storage = GetDriveType (root_dir_storage);
+ if (drive_type_storage == DRIVE_REMOTE || (drive_type_storage == DRIVE_UNKNOWN && (root_dir_storage[0] == '\\' && root_dir_storage[1] == '\\')))
+ is_remote_drive_storage = 1;
else
- is_remote_drive = 0;
+ is_remote_drive_storage = 0;
- if (!GetVolumeInformation (root_dir, NULL, 0, &serial, NULL, &flags,
- name, sizeof (name)))
+ if (!GetVolumeInformation (root_dir_storage, NULL, 0, &serial_storage, NULL, &flags_storage,
+ name_storage, sizeof (name_storage)))
{
- debug_printf ("Cannot get volume information (%s), %E", root_dir);
- name [0] = '\0';
- sym_opt = flags = serial = 0;
+ debug_printf ("Cannot get volume information (%s), %E", root_dir_storage);
+ name_storage[0] = '\0';
+ sym_opt_storage = flags_storage = serial_storage = 0;
return false;
}
/* FIXME: Samba by default returns "NTFS" in file system name, but
@@ -387,7 +387,7 @@ fs_info::update (const char *win32_path)
* distinguish between samba and real ntfs, it should be implemented
* here.
*/
- sym_opt = (!is_remote_drive && strcmp (name, "NTFS") == 0) ? PC_CHECK_EA : 0;
+ sym_opt_storage = (!is_remote_drive_storage && strcmp (name_storage, "NTFS") == 0) ? PC_CHECK_EA : 0;
return true;
}
@@ -399,14 +399,14 @@ path_conv::fillin (HANDLE h)
if (!GetFileInformationByHandle (h, &local))
{
fileattr = INVALID_FILE_ATTRIBUTES;
- fs.serial = 0;
+ fs.serial () = 0;
}
else
{
fileattr = local.dwFileAttributes;
- fs.serial = local.dwVolumeSerialNumber;
+ fs.serial () = local.dwVolumeSerialNumber;
}
- fs.drive_type = DRIVE_UNKNOWN;
+ fs.drive_type () = DRIVE_UNKNOWN;
}
void
@@ -472,12 +472,12 @@ path_conv::check (const char *src, unsigned opt,
fileattr = INVALID_FILE_ATTRIBUTES;
case_clash = false;
memset (&dev, 0, sizeof (dev));
- fs.root_dir[0] = '\0';
- fs.name[0] = '\0';
- fs.flags = fs.serial = 0;
- fs.sym_opt = 0;
- fs.drive_type = 0;
- fs.is_remote_drive = 0;
+ fs.root_dir ()[0] = '\0';
+ fs.name ()[0] = '\0';
+ fs.flags () = fs.serial () = 0;
+ fs.sym_opt () = 0;
+ fs.drive_type () = 0;
+ fs.is_remote_drive () = 0;
normalized_path = NULL;
if (!(opt & PC_NULLEMPTY))
@@ -594,7 +594,7 @@ path_conv::check (const char *src, unsigned opt,
}
if (!fs.update (full_path))
- fs.root_dir[0] = '\0';
+ fs.root_dir ()[0] = '\0';
/* Eat trailing slashes */
char *dostail = strchr (full_path, '\0');
@@ -618,7 +618,7 @@ path_conv::check (const char *src, unsigned opt,
goto out;
}
- int len = sym.check (full_path, suff, opt | fs.sym_opt);
+ int len = sym.check (full_path, suff, opt | fs.sym_opt ());
if (sym.minor || sym.major)
{
@@ -799,7 +799,7 @@ out:
{
if (!fs.update (path))
{
- fs.root_dir[0] = '\0';
+ fs.root_dir ()[0] = '\0';
set_has_acls (false);
set_has_buggy_open (false);
}
@@ -807,14 +807,14 @@ out:
{
set_isdisk ();
debug_printf ("root_dir(%s), this->path(%s), set_has_acls(%d)",
- fs.root_dir, this->path, fs.flags & FS_PERSISTENT_ACLS);
- if (!allow_smbntsec && fs.is_remote_drive)
+ fs.root_dir (), this->path, fs.flags () & FS_PERSISTENT_ACLS);
+ if (!allow_smbntsec && fs.is_remote_drive ())
set_has_acls (false);
else
- set_has_acls (fs.flags & FS_PERSISTENT_ACLS);
+ set_has_acls (fs.flags () & FS_PERSISTENT_ACLS);
/* Known file systems with buggy open calls. Further explanation
in fhandler.cc (fhandler_disk_file::open). */
- set_has_buggy_open (strcmp (fs.name, "SUNWNFS") == 0);
+ set_has_buggy_open (strcmp (fs.name (), "SUNWNFS") == 0);
}
}
@@ -3012,7 +3012,7 @@ readlink (const char *path, char *buf, int buflen)
/* Cygwin internal */
unsigned long __stdcall
-hash_path_name (unsigned long hash, const char *name)
+hash_path_name (ino_t hash, const char *name)
{
if (!*name)
return hash;
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index 9cc3fcf49b0..9275bef066f 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -72,13 +72,20 @@ enum path_types
class symlink_info;
struct fs_info
{
- char name[MAX_PATH];
- char root_dir[MAX_PATH];
- DWORD flags;
- DWORD serial;
- DWORD sym_opt; /* additional options to pass to symlink_info resolver */
- DWORD is_remote_drive;
- DWORD drive_type;
+ char name_storage[MAX_PATH];
+ char root_dir_storage[MAX_PATH];
+ DWORD flags_storage;
+ DWORD serial_storage;
+ DWORD sym_opt_storage; /* additional options to pass to symlink_info resolver */
+ bool is_remote_drive_storage;
+ DWORD drive_type_storage;
+ inline char* name () const {return (char *) name_storage;}
+ inline char* root_dir () const {return (char *) root_dir_storage;}
+ inline DWORD& flags () {return flags_storage;};
+ inline DWORD& serial () {return serial_storage;};
+ inline DWORD& sym_opt () {return sym_opt_storage;};
+ inline bool& is_remote_drive () {return is_remote_drive_storage;};
+ inline DWORD& drive_type () {return drive_type_storage;};
bool update (const char *);
};
@@ -96,7 +103,7 @@ class path_conv
BOOL case_clash;
int isdisk () const { return path_flags & PATH_ISDISK;}
- int isremote () const {return fs.is_remote_drive;}
+ bool& isremote () {return fs.is_remote_drive ();}
int has_acls () const {return path_flags & PATH_HASACLS;}
int has_symlinks () const {return path_flags & PATH_HAS_SYMLINKS;}
int hasgood_inode () const {return path_flags & PATH_HASACLS;} // Not strictly correct
@@ -172,13 +179,13 @@ class path_conv
DWORD get_devn () {return dev.devn;}
short get_unitn () {return dev.minor;}
DWORD file_attributes () {return fileattr;}
- DWORD drive_type () {return fs.drive_type;}
- DWORD fs_flags () {return fs.flags;}
- BOOL fs_fast_ea () {return fs.sym_opt & PC_CHECK_EA;}
+ DWORD drive_type () {return fs.drive_type ();}
+ DWORD fs_flags () {return fs.flags ();}
+ BOOL fs_fast_ea () {return fs.sym_opt () & PC_CHECK_EA;}
void set_path (const char *p) {strcpy (path, p);}
- const char * root_dir () const { return fs.root_dir; }
- DWORD volser () { return fs.serial; }
- const char *volname () {return fs.name; }
+ const char * root_dir () const { return fs.root_dir (); }
+ DWORD volser () { return fs.serial (); }
+ const char *volname () {return fs.name (); }
void fillin (HANDLE h);
inline size_t size ()
{
diff --git a/winsup/cygwin/profil.c b/winsup/cygwin/profil.c
new file mode 100644
index 00000000000..cbfffc1b20c
--- /dev/null
+++ b/winsup/cygwin/profil.c
@@ -0,0 +1,175 @@
+/* profil.c -- win32 profil.c equivalent
+
+ Copyright 1998, 1999, 2000, 2001 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. */
+
+#include <windows.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <math.h>
+
+#include <profil.h>
+
+#define SLEEPTIME (1000 / PROF_HZ)
+
+/* global profinfo for profil() call */
+static struct profinfo prof;
+
+/* Get the pc for thread THR */
+
+static u_long
+get_thrpc (HANDLE thr)
+{
+ CONTEXT ctx;
+ u_long pc;
+ int res;
+
+ res = SuspendThread (thr);
+ if (res == -1)
+ return (u_long) - 1;
+ ctx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
+ pc = (u_long) - 1;
+ if (GetThreadContext (thr, &ctx))
+ pc = ctx.Eip;
+ ResumeThread (thr);
+ return pc;
+}
+
+/* Display cell of profile buffer */
+#if 0
+static void
+print_prof (struct profinfo *p)
+{
+ printf ("profthr %x\ttarget thr %x\n", p->profthr, p->targthr);
+ printf ("pc: %x - %x\n", p->lowpc, p->highpc);
+ printf ("scale: %x\n", p->scale);
+ return;
+}
+#endif
+
+/* Everytime we wake up use the main thread pc to hash into the cell in the
+ profile buffer ARG. */
+
+static DWORD CALLBACK
+profthr_func (LPVOID arg)
+{
+ struct profinfo *p = (struct profinfo *) arg;
+ u_long pc, idx;
+
+ SetThreadPriority(p->profthr, THREAD_PRIORITY_TIME_CRITICAL);
+
+ for (;;)
+ {
+ pc = (u_long) get_thrpc (p->targthr);
+ if (pc >= p->lowpc && pc < p->highpc)
+ {
+ idx = PROFIDX (pc, p->lowpc, p->scale);
+ p->counter[idx]++;
+ }
+#if 0
+ print_prof (p);
+#endif
+ Sleep (SLEEPTIME);
+ }
+ return 0;
+}
+
+/* Stop profiling to the profiling buffer pointed to by P. */
+
+static int
+profile_off (struct profinfo *p)
+{
+ if (p->profthr)
+ {
+ TerminateThread (p->profthr, 0);
+ CloseHandle (p->profthr);
+ }
+ if (p->targthr)
+ CloseHandle (p->targthr);
+ return 0;
+}
+
+/* Create a timer thread and pass it a pointer P to the profiling buffer. */
+
+static int
+profile_on (struct profinfo *p)
+{
+ DWORD thrid;
+
+ /* get handle for this thread */
+ if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
+ GetCurrentProcess (), &p->targthr, 0, FALSE,
+ DUPLICATE_SAME_ACCESS))
+ {
+ errno = ESRCH;
+ return -1;
+ }
+
+ p->profthr = CreateThread (0, 0, profthr_func, (void *) p, 0, &thrid);
+ if (!p->profthr)
+ {
+ CloseHandle (p->targthr);
+ p->targthr = 0;
+ errno = EAGAIN;
+ return -1;
+ }
+ return 0;
+}
+
+/*
+ * start or stop profiling
+ *
+ * profiling goes into the SAMPLES buffer of size SIZE (which is treated
+ * as an array of u_shorts of size size/2)
+ *
+ * each bin represents a range of pc addresses from OFFSET. The number
+ * of pc addresses in a bin depends on SCALE. (A scale of 65536 maps
+ * each bin to two addresses, A scale of 32768 maps each bin to 4 addresses,
+ * a scale of 1 maps each bin to 128k addreses). Scale may be 1 - 65536,
+ * or zero to turn off profiling
+ */
+int
+profile_ctl (struct profinfo * p, char *samples, size_t size,
+ u_long offset, u_int scale)
+{
+ u_long maxbin;
+
+ if (scale > 65536)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ profile_off (p);
+ if (scale)
+ {
+ memset (samples, 0, size);
+ memset (p, 0, sizeof *p);
+ maxbin = size >> 1;
+ prof.counter = (u_short *) samples;
+ prof.lowpc = offset;
+ prof.highpc = PROFADDR (maxbin, offset, scale);
+ prof.scale = scale;
+
+ return profile_on (p);
+ }
+ return 0;
+}
+
+/* Equivalent to unix profil()
+ Every SLEEPTIME interval, the user's program counter (PC) is examined:
+ offset is subtracted and the result is multiplied by scale.
+ The word pointed to by this address is incremented. Buf is unused. */
+
+int
+profil (char *samples, size_t size, u_long offset, u_int scale)
+{
+ return profile_ctl (&prof, samples, size, offset, scale);
+}
+
diff --git a/winsup/cygwin/profil.h b/winsup/cygwin/profil.h
new file mode 100644
index 00000000000..7ec4dfa0949
--- /dev/null
+++ b/winsup/cygwin/profil.h
@@ -0,0 +1,44 @@
+/* profil.h: gprof profiling header file
+
+ Copyright 1998, 1999, 2000, 2001 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. */
+
+/* profiling frequency. (No larger than 1000) */
+#define PROF_HZ 100
+
+/* convert an addr to an index */
+#define PROFIDX(pc, base, scale) \
+ ({ \
+ size_t i = (pc - base) / 2; \
+ if (sizeof (unsigned long long int) > sizeof (size_t)) \
+ i = (unsigned long long int) i * scale / 65536; \
+ else \
+ i = i / 65536 * scale + i % 65536 * scale / 65536; \
+ i; \
+ })
+
+/* convert an index into an address */
+#define PROFADDR(idx, base, scale) \
+ ((base) + ((((unsigned long long)(idx) << 16) / (scale)) << 1))
+
+/* convert a bin size into a scale */
+#define PROFSCALE(range, bins) (((bins) << 16) / ((range) >> 1))
+
+typedef void *_WINHANDLE;
+
+struct profinfo {
+ _WINHANDLE targthr; /* thread to profile */
+ _WINHANDLE profthr; /* profiling thread */
+ u_short *counter; /* profiling counters */
+ u_long lowpc, highpc; /* range to be profiled */
+ u_int scale; /* scale value of bins */
+};
+
+int profile_ctl(struct profinfo *, char *, size_t, u_long, u_int);
+int profil(char *, size_t, u_long, u_int);
+
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h
index aea340d507e..b9093d8fcbb 100644
--- a/winsup/cygwin/pwdgrp.h
+++ b/winsup/cygwin/pwdgrp.h
@@ -55,7 +55,7 @@ class pwdgrp
i = (unsigned int) x;
return res;
}
- bool next_num (int& i)
+ inline bool next_num (int& i)
{
unsigned long x;
bool res = next_num (x);
@@ -67,7 +67,7 @@ public:
int curr_lines;
void load (const char *);
- void refresh (bool check)
+ inline void refresh (bool check)
{
if (!check && initialized)
return;
@@ -77,18 +77,6 @@ public:
pglock->release ();
}
- pwdgrp (passwd *&pbuf) :
- pwdgrp_buf_elem_size (sizeof (*pbuf)), passwd_buf (&pbuf)
- {
- read = &pwdgrp::read_passwd;
- parse = &pwdgrp::parse_passwd;
- new_muto (pglock);
- }
- pwdgrp (__group32 *&gbuf) :
- pwdgrp_buf_elem_size (sizeof (*gbuf)), group_buf (&gbuf)
- {
- read = &pwdgrp::read_group;
- parse = &pwdgrp::parse_group;
- new_muto (pglock);
- }
+ pwdgrp (passwd *&pbuf);
+ pwdgrp (__group32 *&gbuf);
};
diff --git a/winsup/cygwin/regex/regex.h b/winsup/cygwin/regex/regex.h
new file mode 100644
index 00000000000..ecba140b023
--- /dev/null
+++ b/winsup/cygwin/regex/regex.h
@@ -0,0 +1,83 @@
+#ifndef _REGEX_H_
+#define _REGEX_H_ /* never again */
+#include <sys/types.h>
+/* ========= begin header generated by ./mkh ========= */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __INSIDE_CYGWIN__
+#define regcomp posix_regcomp
+#define regerror posix_regerror
+#define regexec posix_regexec
+#define regfree posix_regfree
+#endif
+
+/* === regex2.h === */
+typedef _off_t regoff_t;
+typedef struct {
+ int re_magic;
+ size_t re_nsub; /* number of parenthesized subexpressions */
+ const char *re_endp; /* end pointer for REG_PEND */
+ struct re_guts *re_g; /* none of your business :-) */
+} regex_t;
+typedef struct {
+ regoff_t rm_so; /* start of match */
+ regoff_t rm_eo; /* end of match */
+} regmatch_t;
+
+
+/* === regcomp.c === */
+extern int regcomp(regex_t *, const char *, int);
+#define REG_BASIC 0000
+#define REG_EXTENDED 0001
+#define REG_ICASE 0002
+#define REG_NOSUB 0004
+#define REG_NEWLINE 0010
+#define REG_NOSPEC 0020
+#define REG_PEND 0040
+#define REG_DUMP 0200
+
+
+/* === regerror.c === */
+#define REG_OKAY 0
+#define REG_NOMATCH 1
+#define REG_BADPAT 2
+#define REG_ECOLLATE 3
+#define REG_ECTYPE 4
+#define REG_EESCAPE 5
+#define REG_ESUBREG 6
+#define REG_EBRACK 7
+#define REG_EPAREN 8
+#define REG_EBRACE 9
+#define REG_BADBR 10
+#define REG_ERANGE 11
+#define REG_ESPACE 12
+#define REG_BADRPT 13
+#define REG_EMPTY 14
+#define REG_ASSERT 15
+#define REG_INVARG 16
+#define REG_ATOI 255 /* convert name to number (!) */
+#define REG_ITOA 0400 /* convert number to name (!) */
+extern size_t regerror(int, const regex_t *, char *, size_t);
+
+
+/* === regexec.c === */
+extern int regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
+#define REG_NOTBOL 00001
+#define REG_NOTEOL 00002
+#define REG_STARTEND 00004
+#define REG_TRACE 00400 /* tracing of execution */
+#define REG_LARGE 01000 /* force large representation */
+#define REG_BACKR 02000 /* force use of backref code */
+
+
+/* === regfree.c === */
+extern void regfree(regex_t *);
+
+
+#ifdef __cplusplus
+}
+#endif
+/* ========= end header generated by ./mkh ========= */
+#endif
diff --git a/winsup/cygwin/regex/regex2.h b/winsup/cygwin/regex/regex2.h
new file mode 100644
index 00000000000..8c103fa546d
--- /dev/null
+++ b/winsup/cygwin/regex/regex2.h
@@ -0,0 +1,134 @@
+/*
+ * First, the stuff that ends up in the outside-world include file
+ = typedef _off_t regoff_t;
+ = typedef struct {
+ = int re_magic;
+ = size_t re_nsub; // number of parenthesized subexpressions
+ = const char *re_endp; // end pointer for REG_PEND
+ = struct re_guts *re_g; // none of your business :-)
+ = } regex_t;
+ = typedef struct {
+ = regoff_t rm_so; // start of match
+ = regoff_t rm_eo; // end of match
+ = } regmatch_t;
+ */
+/*
+ * internals of regex_t
+ */
+#define MAGIC1 ((('r'^0200)<<8) | 'e')
+
+/*
+ * The internal representation is a *strip*, a sequence of
+ * operators ending with an endmarker. (Some terminology etc. is a
+ * historical relic of earlier versions which used multiple strips.)
+ * Certain oddities in the representation are there to permit running
+ * the machinery backwards; in particular, any deviation from sequential
+ * flow must be marked at both its source and its destination. Some
+ * fine points:
+ *
+ * - OPLUS_ and O_PLUS are *inside* the loop they create.
+ * - OQUEST_ and O_QUEST are *outside* the bypass they create.
+ * - OCH_ and O_CH are *outside* the multi-way branch they create, while
+ * OOR1 and OOR2 are respectively the end and the beginning of one of
+ * the branches. Note that there is an implicit OOR2 following OCH_
+ * and an implicit OOR1 preceding O_CH.
+ *
+ * In state representations, an operator's bit is on to signify a state
+ * immediately *preceding* "execution" of that operator.
+ */
+typedef long sop; /* strip operator */
+typedef long sopno;
+#define OPRMASK 0x7c000000
+#define OPDMASK 0x03ffffff
+#define OPSHIFT (26)
+#define OP(n) ((n)&OPRMASK)
+#define OPND(n) ((n)&OPDMASK)
+#define SOP(op, opnd) ((op)|(opnd))
+/* operators meaning operand */
+/* (back, fwd are offsets) */
+#define OEND (1<<OPSHIFT) /* endmarker - */
+#define OCHAR (2<<OPSHIFT) /* character unsigned char */
+#define OBOL (3<<OPSHIFT) /* left anchor - */
+#define OEOL (4<<OPSHIFT) /* right anchor - */
+#define OANY (5<<OPSHIFT) /* . - */
+#define OANYOF (6<<OPSHIFT) /* [...] set number */
+#define OBACK_ (7<<OPSHIFT) /* begin \d paren number */
+#define O_BACK (8<<OPSHIFT) /* end \d paren number */
+#define OPLUS_ (9<<OPSHIFT) /* + prefix fwd to suffix */
+#define O_PLUS (10<<OPSHIFT) /* + suffix back to prefix */
+#define OQUEST_ (11<<OPSHIFT) /* ? prefix fwd to suffix */
+#define O_QUEST (12<<OPSHIFT) /* ? suffix back to prefix */
+#define OLPAREN (13<<OPSHIFT) /* ( fwd to ) */
+#define ORPAREN (14<<OPSHIFT) /* ) back to ( */
+#define OCH_ (15<<OPSHIFT) /* begin choice fwd to OOR2 */
+#define OOR1 (16<<OPSHIFT) /* | pt. 1 back to OOR1 or OCH_ */
+#define OOR2 (17<<OPSHIFT) /* | pt. 2 fwd to OOR2 or O_CH */
+#define O_CH (18<<OPSHIFT) /* end choice back to OOR1 */
+#define OBOW (19<<OPSHIFT) /* begin word - */
+#define OEOW (20<<OPSHIFT) /* end word - */
+
+/*
+ * Structure for [] character-set representation. Character sets are
+ * done as bit vectors, grouped 8 to a byte vector for compactness.
+ * The individual set therefore has both a pointer to the byte vector
+ * and a mask to pick out the relevant bit of each byte. A hash code
+ * simplifies testing whether two sets could be identical.
+ *
+ * This will get trickier for multicharacter collating elements. As
+ * preliminary hooks for dealing with such things, we also carry along
+ * a string of multi-character elements, and decide the size of the
+ * vectors at run time.
+ */
+typedef struct {
+ uch *ptr; /* -> uch [csetsize] */
+ uch mask; /* bit within array */
+ uch hash; /* hash code */
+ size_t smultis;
+ char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */
+} cset;
+/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */
+#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c))
+#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c))
+#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask)
+#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */
+#define MCsub(p, cs, cp) mcsub(p, cs, cp)
+#define MCin(p, cs, cp) mcin(p, cs, cp)
+
+/* stuff for character categories */
+typedef unsigned char cat_t;
+
+/*
+ * main compiled-expression structure
+ */
+struct re_guts {
+ int magic;
+# define MAGIC2 ((('R'^0200)<<8)|'E')
+ sop *strip; /* malloced area for strip */
+ int csetsize; /* number of bits in a cset vector */
+ int ncsets; /* number of csets in use */
+ cset *sets; /* -> cset [ncsets] */
+ uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */
+ int cflags; /* copy of regcomp() cflags argument */
+ sopno nstates; /* = number of sops */
+ sopno firststate; /* the initial OEND (normally 0) */
+ sopno laststate; /* the final OEND */
+ int iflags; /* internal flags */
+# define USEBOL 01 /* used ^ */
+# define USEEOL 02 /* used $ */
+# define BAD 04 /* something wrong */
+ int nbol; /* number of ^ used */
+ int neol; /* number of $ used */
+ int ncategories; /* how many character categories */
+ cat_t *categories; /* ->catspace[-CHAR_MIN] */
+ char *must; /* match must contain this string */
+ int mlen; /* length of must */
+ size_t nsub; /* copy of re_nsub */
+ int backrefs; /* does it use back references? */
+ sopno nplus; /* how deep does it nest +s? */
+ /* catspace must be last */
+ cat_t catspace[1]; /* actually [NC] */
+};
+
+/* misc utilities */
+#define OUT (CHAR_MAX+1) /* a non-character value */
+#define ISWORD(c) (isalnum(c) || (c) == '_')
diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc
index b89458b7a89..98cb37666b1 100644
--- a/winsup/cygwin/security.cc
+++ b/winsup/cygwin/security.cc
@@ -1318,22 +1318,21 @@ get_attribute_from_acl (mode_t *attribute, PACL acl, PSID owner_sid,
return;
}
-static int
-get_nt_attribute (const char *file, mode_t *attribute,
+static void
+get_info_from_sd (PSECURITY_DESCRIPTOR psd, mode_t *attribute,
__uid32_t *uidret, __gid32_t *gidret)
{
- syscall_printf ("file: %s", file);
-
- /* Yeah, sounds too much, but I've seen SDs of 2100 bytes! */
- DWORD sd_size = 4096;
- char sd_buf[4096];
- PSECURITY_DESCRIPTOR psd = (PSECURITY_DESCRIPTOR) sd_buf;
-
- int ret;
- if ((ret = read_sd (file, psd, &sd_size)) <= 0)
+ if (!psd)
{
- debug_printf ("read_sd %E");
- return -1;
+ /* If reading the security descriptor failed, treat the object
+ as unreadable. */
+ if (attribute)
+ *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
+ if (uidret)
+ *uidret = ILLEGAL_UID;
+ if (gidret)
+ *gidret = ILLEGAL_GID;
+ return;
}
cygpsid owner_sid;
@@ -1345,16 +1344,6 @@ get_nt_attribute (const char *file, mode_t *attribute,
if (!GetSecurityDescriptorGroup (psd, (PSID *) &group_sid, &dummy))
debug_printf ("GetSecurityDescriptorGroup %E");
- PACL acl;
- BOOL acl_exists;
-
- if (!GetSecurityDescriptorDacl (psd, &acl_exists, &acl, &dummy))
- {
- __seterrno ();
- debug_printf ("GetSecurityDescriptorDacl %E");
- return -1;
- }
-
__uid32_t uid;
__gid32_t gid;
BOOL grp_member = get_sids_info (owner_sid, group_sid, &uid, &gid);
@@ -1365,21 +1354,46 @@ get_nt_attribute (const char *file, mode_t *attribute,
if (!attribute)
{
- syscall_printf ("file: %s uid %d, gid %d", file, uid, gid);
- return 0;
+ syscall_printf ("uid %d, gid %d", uid, gid);
+ return;
}
- if (!acl_exists || !acl)
+ PACL acl;
+ BOOL acl_exists;
+
+ if (!GetSecurityDescriptorDacl (psd, &acl_exists, &acl, &dummy))
{
- *attribute |= S_IRWXU | S_IRWXG | S_IRWXO;
- syscall_printf ("file: %s No ACL = %x, uid %d, gid %d",
- file, *attribute, uid, gid);
- return 0;
+ __seterrno ();
+ debug_printf ("GetSecurityDescriptorDacl %E");
+ *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
}
- get_attribute_from_acl (attribute, acl, owner_sid, group_sid, grp_member);
+ else if (!acl_exists || !acl)
+ *attribute |= S_IRWXU | S_IRWXG | S_IRWXO;
+ else
+ get_attribute_from_acl (attribute, acl, owner_sid, group_sid, grp_member);
- syscall_printf ("file: %s %x, uid %d, gid %d", file, *attribute, uid, gid);
- return 0;
+ syscall_printf ("%sACL = %x, uid %d, gid %d",
+ (!acl_exists || !acl)?"NO ":"", *attribute, uid, gid);
+ return;
+}
+
+static void
+get_nt_attribute (const char *file, mode_t *attribute,
+ __uid32_t *uidret, __gid32_t *gidret)
+{
+ /* Yeah, sounds too much, but I've seen SDs of 2100 bytes! */
+ DWORD sd_size = 4096;
+ char sd_buf[4096];
+ PSECURITY_DESCRIPTOR psd = (PSECURITY_DESCRIPTOR) sd_buf;
+
+ if (read_sd (file, psd, &sd_size) <= 0)
+ {
+ debug_printf ("read_sd %E");
+ psd = NULL;
+ }
+
+ get_info_from_sd (psd, attribute, uidret, gidret);
+ return;
}
int
@@ -1387,22 +1401,11 @@ get_file_attribute (int use_ntsec, const char *file,
mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
{
int res;
+ syscall_printf ("file: %s", file);
if (use_ntsec && allow_ntsec && wincap.has_security ())
{
- res = get_nt_attribute (file, attribute, uidret, gidret);
- if (res)
- {
- /* If reading the security descriptor failed, treat the file
- as unreadable. */
- *attribute &= ~(S_IRWXU | S_IRWXG | S_IRWXO);
- if (uidret)
- *uidret = ILLEGAL_UID;
- if (gidret)
- *gidret = ILLEGAL_GID;
- }
- else if (attribute && S_ISLNK (*attribute))
- *attribute |= S_IRWXU | S_IRWXG | S_IRWXO;
+ get_nt_attribute (file, attribute, uidret, gidret);
return 0;
}
@@ -1423,119 +1426,51 @@ get_file_attribute (int use_ntsec, const char *file,
else
res = 0;
- /* symlinks are everything for everyone! */
- if (S_ISLNK (*attribute))
- *attribute |= S_IRWXU | S_IRWXG | S_IRWXO;
-
return res > 0 ? 0 : -1;
}
-static int
+static void
get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
{
- PSECURITY_DESCRIPTOR psd = NULL;
- cygpsid owner_sid;
- cygpsid group_sid;
- PACL acl = NULL;
+ PSECURITY_DESCRIPTOR psd;
+ char sd_buf[4096];
if (object_type == SE_REGISTRY_KEY)
{
- // use different code for registry handles, for performance reasons
- char sd_buf[4096];
- PSECURITY_DESCRIPTOR psd2 = (PSECURITY_DESCRIPTOR) & sd_buf[0];
+ /* use different code for registry handles, for performance reasons */
+ psd = (PSECURITY_DESCRIPTOR) & sd_buf[0];
DWORD len = sizeof (sd_buf);
if (ERROR_SUCCESS != RegGetKeySecurity ((HKEY) handle,
DACL_SECURITY_INFORMATION |
GROUP_SECURITY_INFORMATION |
OWNER_SECURITY_INFORMATION,
- psd2, &len))
+ psd, &len))
{
__seterrno ();
debug_printf ("RegGetKeySecurity %E");
- return -1;
- }
-
- BOOL bDaclPresent;
- BOOL bDaclDefaulted;
- if (!GetSecurityDescriptorDacl (psd2,
- &bDaclPresent, &acl, &bDaclDefaulted))
- {
- __seterrno ();
- debug_printf ("GetSecurityDescriptorDacl %E");
- return -1;
- }
- if (!bDaclPresent)
- {
- acl = NULL;
- }
-
- BOOL bGroupDefaulted;
- if (!GetSecurityDescriptorGroup (psd2,
- (PSID *) & group_sid,
- &bGroupDefaulted))
- {
- __seterrno ();
- debug_printf ("GetSecurityDescriptorGroup %E");
- return -1;
- }
-
- BOOL bOwnerDefaulted;
- if (!GetSecurityDescriptorOwner (psd2,
- (PSID *) & owner_sid,
- &bOwnerDefaulted))
- {
- __seterrno ();
- debug_printf ("GetSecurityDescriptorOwner %E");
- return -1;
+ psd = NULL;
}
- }
+ }
else
{
if (ERROR_SUCCESS != GetSecurityInfo (handle, object_type,
- DACL_SECURITY_INFORMATION |
- GROUP_SECURITY_INFORMATION |
- OWNER_SECURITY_INFORMATION,
- (PSID *) & owner_sid,
- (PSID *) & group_sid,
- &acl, NULL, &psd))
+ DACL_SECURITY_INFORMATION |
+ GROUP_SECURITY_INFORMATION |
+ OWNER_SECURITY_INFORMATION,
+ NULL, NULL, NULL, NULL, &psd))
{
- __seterrno ();
- debug_printf ("GetSecurityInfo %E");
- return -1;
- }
- }
-
- __uid32_t uid;
- __gid32_t gid;
- BOOL grp_member = get_sids_info (owner_sid, group_sid, &uid, &gid);
-
- if (uidret)
- *uidret = uid;
- if (gidret)
- *gidret = gid;
-
- if (!attribute)
- {
- syscall_printf ("uid %d, gid %d", uid, gid);
- LocalFree (psd);
- return 0;
- }
-
- if (!acl)
- {
- *attribute |= S_IRWXU | S_IRWXG | S_IRWXO;
- syscall_printf ("No ACL = %x, uid %d, gid %d", *attribute, uid, gid);
- LocalFree (psd);
- return 0;
+ __seterrno ();
+ debug_printf ("GetSecurityInfo %E");
+ psd = NULL;
+ }
}
- get_attribute_from_acl (attribute, acl, owner_sid, group_sid, grp_member);
-
- LocalFree (psd);
+ get_info_from_sd (psd, attribute, uidret, gidret);
+ if (psd != (PSECURITY_DESCRIPTOR) & sd_buf[0])
+ LocalFree (psd);
- syscall_printf ("%x, uid %d, gid %d", *attribute, uid, gid);
- return 0;
+ return;
}
int
@@ -1544,26 +1479,11 @@ get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
{
if (allow_ntsec && wincap.has_security ())
{
- int res = get_nt_object_attribute (handle, object_type, attribute,
- uidret, gidret);
- if (attribute && S_ISLNK (*attribute))
- *attribute |= S_IRWXU | S_IRWXG | S_IRWXO;
- return res;
+ get_nt_object_attribute (handle, object_type, attribute, uidret, gidret);
+ return 0;
}
-
- if (uidret)
- *uidret = getuid32 ();
- if (gidret)
- *gidret = getgid32 ();
-
- if (!attribute)
- return 0;
-
- /* symlinks are everything for everyone! */
- if (S_ISLNK (*attribute))
- *attribute |= S_IRWXU | S_IRWXG | S_IRWXO;
-
- return 0;
+ /* The entries are already set to default values */
+ return -1;
}
BOOL
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 02c843218e5..6c8a5b4a75a 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -586,11 +586,15 @@ pipe_cleanup (select_record *, select_stuff *stuff)
int
fhandler_pipe::ready_for_read (int fd, DWORD howlong)
{
- if (!howlong)
- return fhandler_base::ready_for_read (fd, howlong);
+ int res;
+ if (howlong)
+ res = true;
+ else
+ res = fhandler_base::ready_for_read (fd, howlong);
- get_guard ();
- return true;
+ if (res)
+ get_guard ();
+ return res;
}
select_record *
diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc
index 5cadc22bc73..547a1285d0c 100644
--- a/winsup/cygwin/signal.cc
+++ b/winsup/cygwin/signal.cc
@@ -88,7 +88,7 @@ nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
int rc = pthread::cancelable_wait (signal_arrived, req);
DWORD now = GetTickCount ();
DWORD rem = (rc == WAIT_TIMEOUT || now >= end_time) ? 0 : end_time - now;
- if (WaitForSingleObject (signal_arrived, 0) == WAIT_OBJECT_0)
+ if (rc == WAIT_OBJECT_0)
{
(void) thisframe.call_signal_handler ();
set_errno (EINTR);
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 7e4660af0ed..96b0c2ad2a0 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -36,6 +36,7 @@ details. */
#include <winnls.h>
#include <wininet.h>
#include <lmcons.h> /* for UNLEN */
+#include <rpc.h>
#undef fstat
#undef stat
@@ -55,6 +56,8 @@ details. */
#define NEED_VFORK
#include "perthread.h"
#include "pwdgrp.h"
+#include "cpuid.h"
+#include "registry.h"
#undef _close
#undef _lseek
@@ -286,13 +289,13 @@ setsid (void)
if (myself->pgid != myself->pid)
{
- myself->ctty = -1;
- if (fhandler_console::open_fhs <= 0)
+ if (myself->ctty >= 0 && fhandler_console::open_fhs <= 0)
{
syscall_printf ("open_fhs %d, freeing console",
fhandler_console::open_fhs);
FreeConsole ();
}
+ myself->ctty = -1;
myself->sid = getpid ();
myself->pgid = getpid ();
syscall_printf ("sid %d, pgid %d, ctty %d", myself->sid, myself->pgid, myself->ctty);
@@ -809,7 +812,7 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
/* FIXME: This makes chown on a device succeed always. Someday we'll want
to actually allow chown to work properly on devices. */
- if (win32_path.is_auto_device ())
+ if (win32_path.is_auto_device () && !win32_path.issocket ())
{
res = 0;
goto done;
@@ -2791,3 +2794,109 @@ pututline (struct utmp *ut)
CloseHandle (mutex);
}
}
+
+extern "C"
+long gethostid(void)
+{
+ unsigned data[13] = {0x92895012,
+ 0x10293412,
+ 0x29602018,
+ 0x81928167,
+ 0x34601329,
+ 0x75630198,
+ 0x89860395,
+ 0x62897564,
+ 0x00194362,
+ 0x20548593,
+ 0x96839102,
+ 0x12219854,
+ 0x00290012};
+
+ bool has_cpuid = false;
+
+ if (!can_set_flag (0x00040000))
+ debug_printf ("386 processor - no cpuid");
+ else
+ {
+ debug_printf ("486 processor");
+ if (can_set_flag (0x00200000))
+ {
+ debug_printf ("processor supports CPUID instruction");
+ has_cpuid = true;
+ }
+ else
+ debug_printf ("processor does not support CPUID instruction");
+ }
+ if (has_cpuid)
+ {
+ unsigned maxf, unused[3];
+ cpuid (&maxf, &unused[0], &unused[1], &unused[2], 0);
+ maxf &= 0xffff;
+ if (maxf >= 1)
+ {
+ unsigned features;
+ cpuid (&data[0], &unused[0], &unused[1], &features, 1);
+ if (features & (1 << 18))
+ {
+ debug_printf ("processor has psn");
+ if (maxf >= 3)
+ {
+ cpuid (&unused[0], &unused[1], &data[1], &data[2], 3);
+ debug_printf ("Processor PSN: %04x-%04x-%04x-%04x-%04x-%04x",
+ data[0] >> 16, data[0] & 0xffff, data[2] >> 16, data[2] & 0xffff, data[1] >> 16, data[1] & 0xffff);
+ }
+ }
+ else
+ debug_printf ("processor does not have psn");
+ }
+ }
+
+ UUID Uuid;
+ RPC_STATUS status = UuidCreateSequential (&Uuid);
+ if (GetLastError () == ERROR_PROC_NOT_FOUND)
+ status = UuidCreate (&Uuid);
+ if (status == RPC_S_OK)
+ {
+ data[4] = *(unsigned *)&Uuid.Data4[2];
+ data[5] = *(unsigned short *)&Uuid.Data4[6];
+ // Unfortunately Windows will sometimes pick a virtual Ethernet card
+ // e.g. VMWare Virtual Ethernet Adaptor
+ debug_printf ("MAC address of first Ethernet card: %02x:%02x:%02x:%02x:%02x:%02x",
+ Uuid.Data4[2], Uuid.Data4[3], Uuid.Data4[4],
+ Uuid.Data4[5], Uuid.Data4[6], Uuid.Data4[7]);
+ }
+ else
+ {
+ debug_printf ("no Ethernet card installed");
+ }
+
+ reg_key key (HKEY_LOCAL_MACHINE, KEY_READ, "SOFTWARE", "Microsoft", "Windows", "CurrentVersion", NULL);
+ key.get_string ("ProductId", (char *)&data[6], 24, "00000-000-0000000-00000");
+ debug_printf ("Windows Product ID: %s", (char *)&data[6]);
+
+ GetDiskFreeSpaceEx ("C:\\", NULL, (PULARGE_INTEGER) &data[11], NULL);
+ if (GetLastError () == ERROR_PROC_NOT_FOUND)
+ GetDiskFreeSpace ("C:\\", NULL, NULL, NULL, (DWORD *)&data[11]);
+
+ debug_printf ("hostid entropy: %08x %08x %08x %08x "
+ "%08x %08x %08x %08x "
+ "%08x %08x %08x %08x "
+ "%08x",
+ data[0], data[1],
+ data[2], data[3],
+ data[4], data[5],
+ data[6], data[7],
+ data[8], data[9],
+ data[10], data[11],
+ data[12]);
+
+ long hostid = 0x40291372;
+ // a random hashing algorithm
+ // dependancy on md5 is probably too costly
+ for (int i=0;i<13;i++)
+ hostid ^= ((data[i] << (i << 2)) | (data[i] >> (32 - (i << 2))));
+
+ debug_printf ("hostid: %08x", hostid);
+
+ return hostid;
+}
diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc
index dc9933b0f05..99019b84b75 100644
--- a/winsup/cygwin/termios.cc
+++ b/winsup/cygwin/termios.cc
@@ -247,14 +247,52 @@ cfgetispeed (struct termios *tp)
return __tonew_termios (tp)->c_ispeed;
}
+static inline int
+setspeed (speed_t &set_speed, speed_t from_speed)
+{
+ int res;
+ switch (from_speed)
+ {
+ case B0:
+ case B50:
+ case B75:
+ case B110:
+ case B134:
+ case B150:
+ case B200:
+ case B300:
+ case B600:
+ case B1200:
+ case B1800:
+ case B2400:
+ case B4800:
+ case B9600:
+ case B19200:
+ case B38400:
+ case B57600:
+ case B115200:
+ case B128000:
+ case B230400:
+ case B256000:
+ set_speed = from_speed;
+ res = 0;
+ break;
+ default:
+ set_errno (EINVAL);
+ res = -1;
+ break;
+ }
+ return res;
+}
+
/* cfsetospeed: POSIX96 7.1.3.1 */
extern "C" int
cfsetospeed (struct termios *in_tp, speed_t speed)
{
struct termios *tp = __tonew_termios (in_tp);
- tp->c_ospeed = speed;
+ int res = setspeed (tp->c_ospeed, speed);
(void) __toapp_termios (in_tp, tp);
- return 0;
+ return res;
}
/* cfsetispeed: POSIX96 7.1.3.1 */
@@ -262,7 +300,7 @@ extern "C" int
cfsetispeed (struct termios *in_tp, speed_t speed)
{
struct termios *tp = __tonew_termios (in_tp);
- tp->c_ispeed = speed;
+ int res = setspeed (tp->c_ispeed, speed);
(void) __toapp_termios (in_tp, tp);
- return 0;
+ return res;
}
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 0eadd03c5a6..de5392f844e 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -373,7 +373,7 @@ pthread::exit (void *value_ptr)
mutex.lock ();
// cleanup if thread is in detached state and not joined
- if (pthread_equal (joiner, thread))
+ if (equal (joiner, thread))
delete this;
else
{
@@ -404,7 +404,7 @@ pthread::cancel (void)
return 0;
}
- else if (pthread_equal (thread, self))
+ else if (equal (thread, self))
{
mutex.unlock ();
cancel_self ();
@@ -1210,13 +1210,7 @@ pthread_rwlock::unlock ()
delete reader;
}
- if (waiting_writers)
- {
- if (!readers)
- cond_writers.unblock (false);
- }
- else if (waiting_readers)
- cond_readers.unblock (true);
+ release ();
DONE:
mtx.unlock ();
@@ -1263,6 +1257,7 @@ pthread_rwlock::rdlock_cleanup (void *arg)
pthread_rwlock *rwlock = (pthread_rwlock *) arg;
--(rwlock->waiting_readers);
+ rwlock->release ();
rwlock->mtx.unlock ();
}
@@ -1272,6 +1267,7 @@ pthread_rwlock::wrlock_cleanup (void *arg)
pthread_rwlock *rwlock = (pthread_rwlock *) arg;
--(rwlock->waiting_writers);
+ rwlock->release ();
rwlock->mtx.unlock ();
}
@@ -1450,7 +1446,7 @@ pthread_mutex::can_be_unlocked (pthread_mutex_t const *mutex)
/*
* Check if the mutex is owned by the current thread and can be unlocked
*/
- return ((*mutex)->recursion_counter == 1 && pthread_equal ((*mutex)->owner, self));
+ return ((*mutex)->recursion_counter == 1 && pthread::equal ((*mutex)->owner, self));
}
List<pthread_mutex> pthread_mutex::mutexes;
@@ -1512,7 +1508,7 @@ pthread_mutex::_lock (pthread_t self)
if (InterlockedIncrement ((long *)&lock_counter) == 1)
set_owner (self);
- else if (type != PTHREAD_MUTEX_NORMAL && pthread_equal (owner, self))
+ else if (type != PTHREAD_MUTEX_NORMAL && pthread::equal (owner, self))
{
InterlockedDecrement ((long *) &lock_counter);
if (type == PTHREAD_MUTEX_RECURSIVE)
@@ -1536,7 +1532,7 @@ pthread_mutex::_trylock (pthread_t self)
if (InterlockedCompareExchange ((long *)&lock_counter, 1, 0 ) == 0)
set_owner (self);
- else if (type == PTHREAD_MUTEX_RECURSIVE && pthread_equal (owner, self))
+ else if (type == PTHREAD_MUTEX_RECURSIVE && pthread::equal (owner, self))
result = lock_recursive ();
else
result = EBUSY;
@@ -1547,7 +1543,7 @@ pthread_mutex::_trylock (pthread_t self)
int
pthread_mutex::_unlock (pthread_t self)
{
- if (!pthread_equal (owner, self))
+ if (!pthread::equal (owner, self))
return EPERM;
if (--recursion_counter == 0)
@@ -2143,7 +2139,7 @@ pthread::join (pthread_t *thread, void **return_val)
if (!is_good_object (thread))
return ESRCH;
- if (pthread_equal (*thread,joiner))
+ if (equal (*thread,joiner))
return EDEADLK;
(*thread)->mutex.lock ();
@@ -2769,7 +2765,7 @@ pthread_sigmask (int operation, const sigset_t *set, sigset_t *old_set)
extern "C" int
pthread_equal (pthread_t t1, pthread_t t2)
{
- return t1 == t2;
+ return pthread::equal (t1, t2);
}
/* Mutexes */
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index 05638d9c62b..e162b32a047 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -438,6 +438,11 @@ public:
virtual unsigned long getsequence_np();
+ static int equal (pthread_t t1, pthread_t t2)
+ {
+ return t1 == t2;
+ }
+
private:
DWORD thread_id;
__pthread_cleanup_handler *cleanup_stack;
@@ -587,6 +592,18 @@ private:
void remove_reader (struct RWLOCK_READER *rd);
struct RWLOCK_READER *lookup_reader (pthread_t thread);
+ void release ()
+ {
+ if (waiting_writers)
+ {
+ if (!readers)
+ cond_writers.unblock (false);
+ }
+ else if (waiting_readers)
+ cond_readers.unblock (true);
+ }
+
+
static void rdlock_cleanup (void *arg);
static void wrlock_cleanup (void *arg);
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
new file mode 100644
index 00000000000..b5385f29c40
--- /dev/null
+++ b/winsup/cygwin/wincap.cc
@@ -0,0 +1,537 @@
+/* wincap.cc -- figure out on which OS we're running. Set the
+ capability class to the appropriate values.
+
+ Copyright 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. */
+
+#include "winsup.h"
+
+static NO_COPY wincaps wincap_unknown = {
+ lock_file_highword:0x0,
+ chunksize:0x0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ access_denied_on_delete:false,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:false,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:false,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false
+};
+
+static NO_COPY wincaps wincap_95 = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:false,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false
+};
+
+static NO_COPY wincaps wincap_95osr2 = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:false,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:false,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false
+};
+
+static NO_COPY wincaps wincap_98 = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:true,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false
+};
+
+static NO_COPY wincaps wincap_98se = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:true,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false
+};
+
+static NO_COPY wincaps wincap_me = {
+ lock_file_highword:0x0,
+ chunksize:32 * 1024 * 1024,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE,
+ is_winnt:false,
+ access_denied_on_delete:true,
+ has_delete_on_close:false,
+ has_page_guard:false,
+ has_security:false,
+ has_security_descriptor_control:false,
+ has_get_process_times:false,
+ has_lseek_bug:true,
+ has_lock_file_ex:false,
+ has_signal_object_and_wait:false,
+ has_eventlog:false,
+ has_ip_helper_lib:true,
+ has_set_handle_information:false,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:true,
+ altgr_is_ctrl_alt:false,
+ has_physical_mem_access:false,
+ has_working_copy_on_write:false,
+ share_mmaps_only_by_name:true,
+ virtual_protect_works_on_shared_pages:false,
+ has_hard_links:false,
+ can_open_directories:false,
+ has_move_file_ex:false,
+ has_negative_pids:true,
+ has_unreliable_pipes:true,
+ has_try_enter_critical_section:false,
+ has_raw_devices:false,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:false,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:false,
+ needs_memory_protection:false,
+ pty_needs_alloc_console:false
+};
+
+static NO_COPY wincaps wincap_nt3 = {
+ lock_file_highword:0xffffffff,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ access_denied_on_delete:false,
+ has_delete_on_close:true,
+ has_page_guard:true,
+ has_security:true,
+ has_security_descriptor_control:false,
+ has_get_process_times:true,
+ has_lseek_bug:false,
+ has_lock_file_ex:true,
+ has_signal_object_and_wait:false,
+ has_eventlog:true,
+ has_ip_helper_lib:false,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:false,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_try_enter_critical_section:false,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true
+};
+
+static NO_COPY wincaps wincap_nt4 = {
+ lock_file_highword:0xffffffff,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ access_denied_on_delete:false,
+ has_delete_on_close:true,
+ has_page_guard:true,
+ has_security:true,
+ has_security_descriptor_control:false,
+ has_get_process_times:true,
+ has_lseek_bug:false,
+ has_lock_file_ex:true,
+ has_signal_object_and_wait:true,
+ has_eventlog:true,
+ has_ip_helper_lib:false,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true
+};
+
+static NO_COPY wincaps wincap_nt4sp4 = {
+ lock_file_highword:0xffffffff,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ access_denied_on_delete:false,
+ has_delete_on_close:true,
+ has_page_guard:true,
+ has_security:true,
+ has_security_descriptor_control:false,
+ has_get_process_times:true,
+ has_lseek_bug:false,
+ has_lock_file_ex:true,
+ has_signal_object_and_wait:true,
+ has_eventlog:true,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:false,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:false,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true
+};
+
+static NO_COPY wincaps wincap_2000 = {
+ lock_file_highword:0xffffffff,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ access_denied_on_delete:false,
+ has_delete_on_close:true,
+ has_page_guard:true,
+ has_security:true,
+ has_security_descriptor_control:true,
+ has_get_process_times:true,
+ has_lseek_bug:false,
+ has_lock_file_ex:true,
+ has_signal_object_and_wait:true,
+ has_eventlog:true,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:true,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:true,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true
+};
+
+static NO_COPY wincaps wincap_xp = {
+ lock_file_highword:0xffffffff,
+ chunksize:0,
+ shared:FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ is_winnt:true,
+ access_denied_on_delete:false,
+ has_delete_on_close:true,
+ has_page_guard:true,
+ has_security:true,
+ has_security_descriptor_control:true,
+ has_get_process_times:true,
+ has_lseek_bug:false,
+ has_lock_file_ex:true,
+ has_signal_object_and_wait:true,
+ has_eventlog:true,
+ has_ip_helper_lib:true,
+ has_set_handle_information:true,
+ has_set_handle_information_on_console_handles:true,
+ supports_smp:true,
+ map_view_of_file_ex_sucks:false,
+ altgr_is_ctrl_alt:true,
+ has_physical_mem_access:true,
+ has_working_copy_on_write:true,
+ share_mmaps_only_by_name:false,
+ virtual_protect_works_on_shared_pages:true,
+ has_hard_links:true,
+ can_open_directories:true,
+ has_move_file_ex:true,
+ has_negative_pids:false,
+ has_unreliable_pipes:false,
+ has_try_enter_critical_section:true,
+ has_raw_devices:true,
+ has_valid_processorlevel:true,
+ has_64bit_file_access:true,
+ has_process_io_counters:true,
+ supports_reading_modem_output_lines:true,
+ needs_memory_protection:true,
+ pty_needs_alloc_console:true
+};
+
+wincapc wincap;
+
+void
+wincapc::init ()
+{
+ const char *os;
+
+ if (caps)
+ return; // already initialized
+
+ memset (&version, 0, sizeof version);
+ version.dwOSVersionInfoSize = sizeof version;
+ GetVersionEx (&version);
+
+ switch (version.dwPlatformId)
+ {
+ case VER_PLATFORM_WIN32_NT:
+ switch (version.dwMajorVersion)
+ {
+ case 3:
+ os = "NT";
+ caps = &wincap_nt3;
+ break;
+ case 4:
+ os = "NT";
+ if (strcmp (version.szCSDVersion, "Service Pack 4") < 0)
+ caps = &wincap_nt4;
+ else
+ caps = &wincap_nt4sp4;
+ break;
+ case 5:
+ os = "NT";
+ if (version.dwMinorVersion == 0)
+ caps = &wincap_2000;
+ else
+ caps = &wincap_xp;
+ break;
+ default:
+ os = "??";
+ caps = &wincap_unknown;
+ break;
+ }
+ break;
+ case VER_PLATFORM_WIN32_WINDOWS:
+ switch (version.dwMinorVersion)
+ {
+ case 0:
+ os = "95";
+ if (strchr (version.szCSDVersion, 'C'))
+ caps = &wincap_95osr2;
+ else
+ caps = &wincap_95;
+ break;
+ case 10:
+ os = "98";
+ if (strchr (version.szCSDVersion, 'A'))
+ caps = &wincap_98se;
+ else
+ caps = &wincap_98;
+ break;
+ case 90:
+ os = "ME";
+ caps = &wincap_me;
+ break;
+ default:
+ os = "??";
+ caps = &wincap_unknown;
+ break;
+ }
+ break;
+ default:
+ os = "??";
+ caps = &wincap_unknown;
+ break;
+ }
+ __small_sprintf (osnam, "%s-%d.%d", os, version.dwMajorVersion,
+ version.dwMinorVersion);
+}
+
+void
+wincapc::set_chunksize (DWORD nchunksize)
+{
+ ((wincaps *)this->caps)->chunksize = nchunksize;
+}
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
new file mode 100644
index 00000000000..066374fd860
--- /dev/null
+++ b/winsup/cygwin/wincap.h
@@ -0,0 +1,113 @@
+/* wincap.h: Header for OS capability class.
+
+ Copyright 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. */
+
+#ifndef _WINCAP_H
+#define _WINCAP_H
+
+struct wincaps
+{
+ DWORD lock_file_highword;
+ DWORD chunksize;
+ int shared;
+ unsigned is_winnt : 1;
+ unsigned access_denied_on_delete : 1;
+ unsigned has_delete_on_close : 1;
+ unsigned has_page_guard : 1;
+ unsigned has_security : 1;
+ unsigned has_security_descriptor_control : 1;
+ unsigned has_get_process_times : 1;
+ unsigned has_lseek_bug : 1;
+ unsigned has_lock_file_ex : 1;
+ unsigned has_signal_object_and_wait : 1;
+ unsigned has_eventlog : 1;
+ unsigned has_ip_helper_lib : 1;
+ unsigned has_set_handle_information : 1;
+ unsigned has_set_handle_information_on_console_handles: 1;
+ unsigned supports_smp : 1;
+ unsigned map_view_of_file_ex_sucks : 1;
+ unsigned altgr_is_ctrl_alt : 1;
+ unsigned has_physical_mem_access : 1;
+ unsigned has_working_copy_on_write : 1;
+ unsigned share_mmaps_only_by_name : 1;
+ unsigned virtual_protect_works_on_shared_pages : 1;
+ unsigned has_hard_links : 1;
+ unsigned can_open_directories : 1;
+ unsigned has_move_file_ex : 1;
+ unsigned has_negative_pids : 1;
+ unsigned has_unreliable_pipes : 1;
+ unsigned has_try_enter_critical_section : 1;
+ unsigned has_raw_devices : 1;
+ unsigned has_valid_processorlevel : 1;
+ unsigned has_64bit_file_access : 1;
+ unsigned has_process_io_counters : 1;
+ unsigned supports_reading_modem_output_lines : 1;
+ unsigned needs_memory_protection : 1;
+ unsigned pty_needs_alloc_console : 1;
+};
+
+class wincapc
+{
+ OSVERSIONINFO version;
+ char osnam[40];
+ void *caps;
+
+public:
+ void init ();
+
+ void set_chunksize (DWORD nchunksize);
+
+ const char *osname () const { return osnam; }
+
+#define IMPLEMENT(cap) cap() const { return ((wincaps *)this->caps)->cap; }
+
+ DWORD IMPLEMENT (lock_file_highword)
+ DWORD IMPLEMENT (chunksize)
+ int IMPLEMENT (shared)
+ bool IMPLEMENT (is_winnt)
+ bool IMPLEMENT (access_denied_on_delete)
+ bool IMPLEMENT (has_delete_on_close)
+ bool IMPLEMENT (has_page_guard)
+ bool IMPLEMENT (has_security)
+ bool IMPLEMENT (has_security_descriptor_control)
+ bool IMPLEMENT (has_get_process_times)
+ bool IMPLEMENT (has_lseek_bug)
+ bool IMPLEMENT (has_lock_file_ex)
+ bool IMPLEMENT (has_signal_object_and_wait)
+ bool IMPLEMENT (has_eventlog)
+ bool IMPLEMENT (has_ip_helper_lib)
+ bool IMPLEMENT (has_set_handle_information)
+ bool IMPLEMENT (has_set_handle_information_on_console_handles)
+ bool IMPLEMENT (supports_smp)
+ bool IMPLEMENT (map_view_of_file_ex_sucks)
+ bool IMPLEMENT (altgr_is_ctrl_alt)
+ bool IMPLEMENT (has_physical_mem_access)
+ bool IMPLEMENT (has_working_copy_on_write)
+ bool IMPLEMENT (share_mmaps_only_by_name)
+ bool IMPLEMENT (virtual_protect_works_on_shared_pages)
+ bool IMPLEMENT (has_hard_links)
+ bool IMPLEMENT (can_open_directories)
+ bool IMPLEMENT (has_move_file_ex)
+ bool IMPLEMENT (has_negative_pids)
+ bool IMPLEMENT (has_unreliable_pipes)
+ bool IMPLEMENT (has_try_enter_critical_section)
+ bool IMPLEMENT (has_raw_devices)
+ bool IMPLEMENT (has_valid_processorlevel)
+ bool IMPLEMENT (has_64bit_file_access)
+ bool IMPLEMENT (has_process_io_counters)
+ bool IMPLEMENT (supports_reading_modem_output_lines)
+ bool IMPLEMENT (needs_memory_protection)
+ bool IMPLEMENT (pty_needs_alloc_console)
+
+#undef IMPLEMENT
+};
+
+extern wincapc wincap;
+
+#endif /* _WINCAP_H */
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index ac639533e6e..17ac8952fce 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -198,7 +198,7 @@ int __stdcall writable_directory (const char *file);
int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
extern BOOL allow_ntsec;
-unsigned long __stdcall hash_path_name (unsigned long hash, const char *name) __attribute__ ((regparm(2)));
+unsigned long __stdcall hash_path_name (ino_t hash, const char *name) __attribute__ ((regparm(2)));
void __stdcall nofinalslash (const char *src, char *dst) __attribute__ ((regparm(2)));
extern "C" char *__stdcall rootdir (char *full_path) __attribute__ ((regparm(1)));