]> sourceware.org Git - newlib-cygwin.git/commitdiff
* Merge in cygwin-64bit-branch.
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 23 Apr 2013 09:44:36 +0000 (09:44 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 23 Apr 2013 09:44:36 +0000 (09:44 +0000)
253 files changed:
winsup/cygserver/ChangeLog
winsup/cygserver/ChangeLog.64bit [new file with mode: 0644]
winsup/cygserver/Makefile.in
winsup/cygserver/bsd_helper.cc
winsup/cygserver/bsd_helper.h
winsup/cygserver/bsd_log.cc
winsup/cygserver/bsd_log.h
winsup/cygserver/bsd_mutex.cc
winsup/cygserver/client.cc
winsup/cygserver/cygserver.cc
winsup/cygserver/msg.cc
winsup/cygserver/process.h
winsup/cygserver/sem.cc
winsup/cygserver/shm.cc
winsup/cygserver/sysv_shm.cc
winsup/cygserver/threaded_queue.h
winsup/cygwin/ChangeLog
winsup/cygwin/ChangeLog.64bit [new file with mode: 0644]
winsup/cygwin/Makefile.in
winsup/cygwin/aclocal.m4
winsup/cygwin/advapi32.cc
winsup/cygwin/autoload.cc
winsup/cygwin/automode.c
winsup/cygwin/binmode.c
winsup/cygwin/child_info.h
winsup/cygwin/configure
winsup/cygwin/configure.ac
winsup/cygwin/cpuid.h
winsup/cygwin/cygerrno.h
winsup/cygwin/cygheap.cc
winsup/cygwin/cygheap.h
winsup/cygwin/cygmagic
winsup/cygwin/cygmalloc.h
winsup/cygwin/cygserver.h
winsup/cygwin/cygserver_ipc.h
winsup/cygwin/cygthread.cc
winsup/cygwin/cygtls.cc
winsup/cygwin/cygtls.h
winsup/cygwin/cygwin.din
winsup/cygwin/cygwin.sc.in [moved from winsup/cygwin/cygwin.sc with 66% similarity]
winsup/cygwin/cygwin64.din [new file with mode: 0644]
winsup/cygwin/dcrt0.cc
winsup/cygwin/debug.h
winsup/cygwin/devices.cc
winsup/cygwin/devices.h
winsup/cygwin/devices.in
winsup/cygwin/dir.cc
winsup/cygwin/dlfcn.cc
winsup/cygwin/dll_init.cc
winsup/cygwin/dll_init.h
winsup/cygwin/dtable.cc
winsup/cygwin/environ.cc
winsup/cygwin/environ.h
winsup/cygwin/errno.cc
winsup/cygwin/exception.h
winsup/cygwin/exceptions.cc
winsup/cygwin/external.cc
winsup/cygwin/fcntl.cc
winsup/cygwin/fenv.cc
winsup/cygwin/fhandler.cc
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_clipboard.cc
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_dev.cc
winsup/cygwin/fhandler_disk_file.cc
winsup/cygwin/fhandler_dsp.cc
winsup/cygwin/fhandler_fifo.cc
winsup/cygwin/fhandler_floppy.cc
winsup/cygwin/fhandler_mailslot.cc
winsup/cygwin/fhandler_mem.cc
winsup/cygwin/fhandler_netdrive.cc
winsup/cygwin/fhandler_proc.cc
winsup/cygwin/fhandler_process.cc
winsup/cygwin/fhandler_procnet.cc
winsup/cygwin/fhandler_procsys.cc
winsup/cygwin/fhandler_procsysvipc.cc
winsup/cygwin/fhandler_random.cc
winsup/cygwin/fhandler_raw.cc
winsup/cygwin/fhandler_registry.cc
winsup/cygwin/fhandler_serial.cc
winsup/cygwin/fhandler_socket.cc
winsup/cygwin/fhandler_tape.cc
winsup/cygwin/fhandler_termios.cc
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/fhandler_virtual.cc
winsup/cygwin/fhandler_virtual.h
winsup/cygwin/fhandler_zero.cc
winsup/cygwin/flock.cc
winsup/cygwin/fork.cc
winsup/cygwin/gendef
winsup/cygwin/gentls_offsets
winsup/cygwin/glob.cc
winsup/cygwin/globals.cc
winsup/cygwin/grp.cc
winsup/cygwin/heap.cc
winsup/cygwin/hookapi.cc
winsup/cygwin/include/a.out.h
winsup/cygwin/include/asm/byteorder.h
winsup/cygwin/include/bits/wordsize.h
winsup/cygwin/include/cygwin/acl.h
winsup/cygwin/include/cygwin/config.h
winsup/cygwin/include/cygwin/cygwin_dll.h
winsup/cygwin/include/cygwin/grp.h
winsup/cygwin/include/cygwin/ipc.h
winsup/cygwin/include/cygwin/msg.h
winsup/cygwin/include/cygwin/sem.h
winsup/cygwin/include/cygwin/shm.h
winsup/cygwin/include/cygwin/signal.h
winsup/cygwin/include/cygwin/socket.h
winsup/cygwin/include/cygwin/stat.h
winsup/cygwin/include/cygwin/sysproto.h
winsup/cygwin/include/cygwin/time.h
winsup/cygwin/include/cygwin/types.h
winsup/cygwin/include/cygwin/version.h
winsup/cygwin/include/fts.h
winsup/cygwin/include/ftw.h
winsup/cygwin/include/glob.h
winsup/cygwin/include/inttypes.h
winsup/cygwin/include/io.h
winsup/cygwin/include/limits.h
winsup/cygwin/include/mntent.h
winsup/cygwin/include/stdint.h
winsup/cygwin/include/sys/cygwin.h
winsup/cygwin/include/sys/dirent.h
winsup/cygwin/include/sys/resource.h
winsup/cygwin/include/sys/strace.h
winsup/cygwin/init.cc
winsup/cygwin/ioctl.cc
winsup/cygwin/ipc.cc
winsup/cygwin/kernel32.cc
winsup/cygwin/lc_msg.h
winsup/cygwin/lib/_cygwin_crt0_common.cc
winsup/cygwin/lib/crt0.h
winsup/cygwin/lib/cygwin_attach_dll.c
winsup/cygwin/lib/premain0.c
winsup/cygwin/lib/premain1.c
winsup/cygwin/lib/premain2.c
winsup/cygwin/lib/premain3.c
winsup/cygwin/libc/bsdlib.cc
winsup/cygwin/libc/fts.c
winsup/cygwin/libc/ftw.c
winsup/cygwin/libc/inet_network.c
winsup/cygwin/libc/minires-os-if.c
winsup/cygwin/libc/minires.c
winsup/cygwin/libc/nftw.c
winsup/cygwin/libc/rcmd.cc
winsup/cygwin/libc/rexec.cc
winsup/cygwin/libstdcxx_wrapper.cc
winsup/cygwin/localtime.cc
winsup/cygwin/malloc_wrapper.cc
winsup/cygwin/miscfuncs.cc
winsup/cygwin/mkimport
winsup/cygwin/mktemp.cc
winsup/cygwin/mmap.cc
winsup/cygwin/mount.cc
winsup/cygwin/msg.cc
winsup/cygwin/mtinfo.h
winsup/cygwin/net.cc
winsup/cygwin/netdb.cc
winsup/cygwin/nfs.h
winsup/cygwin/nlsfuncs.cc
winsup/cygwin/ntdll.h
winsup/cygwin/passwd.cc
winsup/cygwin/path.cc
winsup/cygwin/path.h
winsup/cygwin/perprocess.h
winsup/cygwin/pinfo.cc
winsup/cygwin/pinfo.h
winsup/cygwin/pipe.cc
winsup/cygwin/poll.cc
winsup/cygwin/posix_ipc.cc
winsup/cygwin/profil.c
winsup/cygwin/profil.h
winsup/cygwin/pseudo-reloc.cc
winsup/cygwin/pwdgrp.h
winsup/cygwin/regex/engine.c
winsup/cygwin/regex/regcomp.c
winsup/cygwin/registry.cc
winsup/cygwin/regparm.h [new file with mode: 0644]
winsup/cygwin/resource.cc
winsup/cygwin/sched.cc
winsup/cygwin/sec_acl.cc
winsup/cygwin/sec_auth.cc
winsup/cygwin/sec_helper.cc
winsup/cygwin/security.cc
winsup/cygwin/security.h
winsup/cygwin/select.cc
winsup/cygwin/select.h
winsup/cygwin/sem.cc
winsup/cygwin/shared.cc
winsup/cygwin/shm.cc
winsup/cygwin/signal.cc
winsup/cygwin/sigproc.cc
winsup/cygwin/sigproc.h
winsup/cygwin/smallprint.cc
winsup/cygwin/spawn.cc
winsup/cygwin/speclib
winsup/cygwin/strace.cc
winsup/cygwin/strsig.cc
winsup/cygwin/sync.cc
winsup/cygwin/sync.h
winsup/cygwin/syscalls.cc
winsup/cygwin/sysconf.cc
winsup/cygwin/syslog.cc
winsup/cygwin/termios.cc
winsup/cygwin/textmode.c
winsup/cygwin/textreadmode.c
winsup/cygwin/thread.cc
winsup/cygwin/thread.h
winsup/cygwin/timer.cc
winsup/cygwin/times.cc
winsup/cygwin/tlsoffsets.h
winsup/cygwin/tlsoffsets64.h [new file with mode: 0644]
winsup/cygwin/tty.cc
winsup/cygwin/tty.h
winsup/cygwin/uinfo.cc
winsup/cygwin/wait.cc
winsup/cygwin/winbase.h
winsup/cygwin/wincap.cc
winsup/cygwin/wincap.h
winsup/cygwin/winlean.h
winsup/cygwin/winsup.h
winsup/cygwin/wow64.cc
winsup/cygwin/wow64.h
winsup/doc/ChangeLog
winsup/doc/faq-what.xml
winsup/lsaauth/ChangeLog
winsup/lsaauth/ChangeLog.64bit [new file with mode: 0644]
winsup/lsaauth/Makefile.in
winsup/lsaauth/configure
winsup/lsaauth/configure.ac
winsup/utils/ChangeLog
winsup/utils/ChangeLog.64bit [new file with mode: 0644]
winsup/utils/aclocal.m4
winsup/utils/configure
winsup/utils/cygcheck.cc
winsup/utils/dumper.cc
winsup/utils/dumper.h
winsup/utils/kill.cc
winsup/utils/ldd.cc
winsup/utils/locale.cc
winsup/utils/mkgroup.c
winsup/utils/mkpasswd.c
winsup/utils/module_info.cc
winsup/utils/mount.cc
winsup/utils/parse_pe.cc
winsup/utils/passwd.c
winsup/utils/path.cc
winsup/utils/ps.cc
winsup/utils/regtool.cc
winsup/utils/ssp.c
winsup/utils/strace.cc
winsup/utils/tzset.c

index 76b6c27db9cca18c810be0e155d6894a14f4958a..a29903af40b01c7bd71fab3f7ed9f4b82a91946a 100644 (file)
@@ -1,3 +1,7 @@
+2013-04-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Merge in cygwin-64bit-branch.  See ChangeLog.64bit for details.
+
 2012-11-27  Christopher Faylor  <me.cygwin2012@cgf.cx>
 
        * Makefile.in: Remove old from CFLAGS and move C*FLAGS so that they can
diff --git a/winsup/cygserver/ChangeLog.64bit b/winsup/cygserver/ChangeLog.64bit
new file mode 100644 (file)
index 0000000..7ab21bf
--- /dev/null
@@ -0,0 +1,87 @@
+2013-03-07  Corinna Vinschen  <corinna@vinschen.de>
+
+       * msg.cc (client_request_msg::serve): Revert change to refuse 64 bit
+       processes on 32 bit systems.
+       * sem.cc (client_request_sem::serve): Ditto.
+       * shm.cc (client_request_shm::serve): Ditto.
+
+2013-03-01  Corinna Vinschen  <corinna@vinschen.de>
+
+       * client.cc: Revert changes to handle 32 bit processes on 64 bit
+       systems.
+       * sysv_msg.cc: Ditto.
+       * sysv_sem.cc: Ditto.
+       * sysv_shm.cc: Ditto.
+
+2013-02-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (cygserver.exe): Make cygwin_build a tooldir (-B instead
+       of -L) to support bootstrapping.
+
+2013-02-09  Corinna Vinschen  <corinna@vinschen.de>
+
+       * configure: Regenerate to fix wrong ac_unique_file dependency.
+
+2012-12-06  Corinna Vinschen  <corinna@vinschen.de>
+
+       * sysv_msg.cc (conv_timespec32_to_timespec): Move implementation to
+       cygserver_ipc.h.
+       (conv_timespec_to_timespec32): Ditto.
+       (conv_msqid_ds32_to_msqid_ds): Drop and move code into copyin_msqid_ds.
+       (conv_msqid_ds_to_msqid_ds32): Drop and move code into copyout_msqid_ds.
+       * sysv_sem.cc (copyin_semid_ds): New inline function on Cygwin.
+       (copyout_semid_ds): Ditto.
+       (__semctl): Use a conditional arg_size value rather than a fixed
+       sizeof(real_arg) throughout, to accommodate 64/32 bit conversion.
+       Use copyout_semid_ds and copyin_semid_ds to copy semid_ds
+       structures from cygserver to client and vice versa on Cygwin.
+       * sysv_shm.cc (copyin_shmid_ds): New inline function on Cygwin.
+       (copyout_shmid_ds): Ditto.
+       (shmctl): Use copyout_shmid_ds and copyin_shmid_ds to copy shmid_ds
+       structures from cygserver to client and vice versa on Cygwin.
+
+2012-12-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * client.cc (client_request::header_t::header_t): Accommodate changes
+       to msglen member.
+       (client_request::handle_request): Ditto.
+       (client_request::client_request): Zero out entire parameter block.
+       Explain why.
+       * sysv_msg.cc (conv_timespec32_to_timespec): New inline function on
+       64 bit Cygwin.
+       (conv_timespec_to_timespec32): Ditto.
+       (conv_msqid_ds32_to_msqid_ds): Ditto.
+       (conv_msqid_ds_to_msqid_ds32): Ditto.
+       (copyin_msqid_ds): New inline function on Cygwin.
+       (copyout_msqid_ds): Ditto.
+       (msgctl): Use copyout_msqid_ds and copyin_msqid_ds to copy msqid_ds
+       structures from cygserver to client and vice versa on Cygwin.
+       (msgsnd): Special case copyin of msg_type on 64 bit Cygwin.
+       (msgrcv): Special case copyout of msg_type on 64 bit Cygwin.
+
+2012-12-04  Corinna Vinschen  <corinna@vinschen.de>
+
+       * bsd_helper.cc (tunable_int_fetch): Convert 2nd parameter to
+       int32_t.
+       * bsd_helper.h (tunable_int_fetch): Fix declaration accordingly.
+       * bsd_log.cc (log_level): Change type to int32_t.
+       * bsd_log.h (log_level): Fix declaration accordingly.
+       * bsd_mutex.cc (msgmni): Change type to int32_t.
+       (semmni): Ditto.
+       * cygserver.cc: Fix debug output to be target agnostic.  Use same
+       style throughout.
+       * msg.cc (client_request_msg::serve): Refuse to serve 64 bit processes
+       from 32 bit cygserver.
+       * sem.cc (client_request_sem::serve): Ditto.
+       * shm.cc (client_request_shm::serve): Ditto.
+       * sysv_shm.cc (shm_delete_mapping): Mark size as unused to make gcc
+       happy.
+       (kern_shmat): Ditto with flags.
+       * process.h (class process): Change type of _cleaning_up member to LONG.
+       * threaded_queue.h (class threaded_queue): Ditto for _workers_count.
+
+2012-08-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * configure.in: Add AC_NO_EXECUTABLES to allow bootstrap.
+       * configure: Regenerate.
+
index e98dea2e6551013f062c3a9b28b1657f63a463f6..e2fe3099272383bb58987fe95c87bf0a05c516b5 100644 (file)
@@ -71,7 +71,7 @@ libclean:
 fullclean: clean libclean
 
 cygserver.exe: $(CYGWIN_LIB) $(OBJS) $(CYGWIN_OBJS)
-       $(CXX) -o $@ ${wordlist 2,999,$^} -static -static-libgcc -L$(cygwin_build) -lntdll
+       $(CXX) -o $@ ${wordlist 2,999,$^} -static -static-libgcc -B$(cygwin_build) -lntdll
 
 $(cygwin_build)/%.o: $(cygwin_source)/%.cc
        @$(MAKE) -C $(@D) $(@F)
index 7c6d23a607d10e8027dae2bd1d63c51a511effee..718c587c337294d80bfd97632fe1c67e60d0e81a 100644 (file)
@@ -655,7 +655,7 @@ tunable_param_init (const char *config_file, bool force)
 }
 
 void
-tunable_int_fetch (const char *name, long *tunable_target)
+tunable_int_fetch (const char *name, int32_t *tunable_target)
 {
   tun_struct *s;
   for (s = &tunable_params[0]; s->name; ++s)
index 04589857304e505b81a8ed26b8032c565da85aa6..bc8d228106e69975bdad2f29713a6fc524617ff2 100644 (file)
@@ -1,6 +1,6 @@
 /* bsd_helper.h: Helps integrating BSD kernel code
 
-   Copyright 2003 Red Hat, Inc.
+   Copyright 2003, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -60,7 +60,7 @@ vm_object_t vm_object_duplicate (struct thread *td, vm_object_t object);
 void vm_object_deallocate (vm_object_t object);
 
 void tunable_param_init (const char *, bool);
-void tunable_int_fetch (const char *, long *);
+void tunable_int_fetch (const char *, int32_t *);
 void tunable_bool_fetch (const char *, tun_bool_t *);
 
 #endif /* _BSD_HELPER_H */
index 78dcdb00c1ecc5a867d12473d7b7bbfc6cd75f56..18dc1a53b3c1974449adf81fecef99cc5b5dd8a9 100644 (file)
@@ -1,6 +1,6 @@
 /* bsd_log.cc
 
-   Copyright 2003, 2004 Red Hat Inc.
+   Copyright 2003, 2004, 2012 Red Hat Inc.
 
 This file is part of Cygwin.
 
@@ -14,7 +14,7 @@ details. */
 #include <stdio.h>
 #include <stdlib.h>
 
-long log_level = 8; /* Illegal value.  Don't change! */
+int32_t log_level = 8; /* Illegal value.  Don't change! */
 tun_bool_t log_debug = TUN_UNDEF;
 tun_bool_t log_syslog = TUN_UNDEF;
 tun_bool_t log_stderr = TUN_UNDEF;
index 48573182aa9948fe49115ffd06ce0495d63caf6e..0027d4ff5311deee359e3c6746f93955db59b5bb 100644 (file)
@@ -1,6 +1,6 @@
 /* bsd_log.h: Helps integrating BSD kernel code
 
-   Copyright 2003 Red Hat, Inc.
+   Copyright 2003, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -13,7 +13,7 @@ details. */
 #include <sys/types.h>
 #include <sys/syslog.h>
 
-extern long log_level;
+extern int32_t log_level;
 extern tun_bool_t log_debug;
 extern tun_bool_t log_syslog;
 extern tun_bool_t log_stderr;
index d4cad5678878e1f101da69162d9bcd9defdf14ad..a13cfe07dc678a45494c1248fff40ec5dbf9b534 100644 (file)
@@ -1,6 +1,6 @@
 /* bsd_mutex.cc
 
-   Copyright 2003, 2004, 2005, 2007 Red Hat Inc.
+   Copyright 2003, 2004, 2005, 2007, 2012 Red Hat Inc.
 
 This file is part of Cygwin.
 
@@ -285,8 +285,8 @@ msleep_init (void)
   msleep_glob_evt = CreateEvent (NULL, TRUE, FALSE, NULL);
   if (!msleep_glob_evt)
     panic ("CreateEvent in msleep_init failed: %lu", GetLastError ());
-  long msgmni = support_msgqueues ? msginfo.msgmni : 0;
-  long semmni = support_semaphores ? seminfo.semmni : 0;
+  int32_t msgmni = support_msgqueues ? msginfo.msgmni : 0;
+  int32_t semmni = support_semaphores ? seminfo.semmni : 0;
   TUNABLE_INT_FETCH ("kern.ipc.msgmni", &msgmni);
   TUNABLE_INT_FETCH ("kern.ipc.semmni", &semmni);
   debug ("Try allocating msgmni (%d) + semmni (%d) msleep records",
index dfa88d09beda3351b902486825f6b678859b7848..63ce421c96fa9906e4086da534cceb443fd7deaf 100644 (file)
@@ -1,6 +1,6 @@
 /* client.cc
 
-   Copyright 2001, 2002, 2003, 2004, 2008, 2009 Red Hat Inc.
+   Copyright 2001, 2002, 2003, 2004, 2008, 2009, 2012, 2013 Red Hat Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -115,11 +115,11 @@ client_request_attach_tty::send (transport_layer_base * const conn)
 }
 
 client_request::header_t::header_t (const request_code_t request_code,
-                                   const size_t msglen)
-  : msglen (msglen),
-    request_code (request_code)
+                                   const size_t len)
+  : request_code (request_code)
 {
   assert (request_code >= 0 && request_code < CYGSERVER_REQUEST_LAST);
+  msglen = len;
 }
 
 // FIXME: also check write and read result for -1.
index 8b3fd4c45e01a5db281af7b20b5e7096e665a6c4..bf78e9daf5032cbad2cef758ec3c1cdce2b6a0a9 100644 (file)
@@ -1,6 +1,6 @@
 /* cygserver.cc
 
-   Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2011 Red Hat Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2011, 2012 Red Hat Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -51,13 +51,13 @@ setup_privileges ()
   rc = OpenProcessToken (GetCurrentProcess () , TOKEN_ALL_ACCESS , &hToken) ;
   if (!rc)
     {
-      debug ("error opening process token (%lu)", GetLastError ());
+      debug ("error opening process token (err %u)", GetLastError ());
       return false;
     }
   rc = LookupPrivilegeValue (NULL, SE_DEBUG_NAME, &sPrivileges.Privileges[0].Luid);
   if (!rc)
     {
-      debug ("error getting privilege luid (%lu)", GetLastError ());
+      debug ("error getting privilege luid (err %u)", GetLastError ());
       ret_val = false;
       goto out;
     }
@@ -66,7 +66,7 @@ setup_privileges ()
   rc = AdjustTokenPrivileges (hToken, FALSE, &sPrivileges, 0, NULL, NULL) ;
   if (!rc)
     {
-      debug ("error adjusting privilege level. (%lu)", GetLastError ());
+      debug ("error adjusting privilege level. (err %u)", GetLastError ());
       ret_val = false;
       goto out;
     }
@@ -106,8 +106,8 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process,
                            0, bInheritHandle,
                            DUPLICATE_SAME_ACCESS))
        {
-         log (LOG_ERR, "error getting handle(%u) to server (%lu)",
-                        (unsigned int)from_handle, GetLastError ());
+         log (LOG_ERR, "error getting handle(%p) to server (err %u)",
+                        from_handle, GetLastError ());
          goto out;
        }
     } else
@@ -119,7 +119,7 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process,
                                 | DACL_SECURITY_INFORMATION),
                                sd, sizeof (sd_buf), &bytes_needed))
     {
-      log (LOG_ERR, "error getting handle SD (%lu)", GetLastError ());
+      log (LOG_ERR, "error getting handle SD (err %u)", GetLastError ());
       goto out;
     }
 
@@ -128,8 +128,7 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process,
   if (!AccessCheck (sd, from_process_token, access, &access_mapping,
                    &ps, &ps_len, &access, &status))
     {
-      log (LOG_ERR, "error checking access rights (%lu)",
-                    GetLastError ());
+      log (LOG_ERR, "error checking access rights (err %u)", GetLastError ());
       goto out;
     }
 
@@ -143,7 +142,7 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process,
                        to_process, to_handle_ptr,
                        access, bInheritHandle, 0))
     {
-      log (LOG_ERR, "error getting handle to client (%lu)", GetLastError ());
+      log (LOG_ERR, "error getting handle to client (err %u)", GetLastError ());
       goto out;
     }
 
@@ -191,8 +190,7 @@ client_request_attach_tty::serve (transport_layer_base *const conn,
 
   if (!from_process_handle)
     {
-      log (LOG_ERR, "error opening `from' process, error = %lu",
-                    GetLastError ());
+      log (LOG_ERR, "error opening `from' process (err %u)", GetLastError ());
       error_code (EACCES);
       return;
     }
@@ -204,8 +202,7 @@ client_request_attach_tty::serve (transport_layer_base *const conn,
 
   if (!to_process_handle)
     {
-      log (LOG_ERR, "error opening `to' process, error = %lu",
-                    GetLastError ());
+      log (LOG_ERR, "error opening `to' process (err %u)", GetLastError ());
       CloseHandle (from_process_handle);
       error_code (EACCES);
       return;
@@ -228,7 +225,7 @@ client_request_attach_tty::serve (transport_layer_base *const conn,
                                    TRUE,
                                    &token_handle);
 
-  debug ("opened thread token, rc=%lu", rc);
+  debug ("opened thread token, rc=%u", rc);
   if (!conn->revert_to_self ())
     {
       CloseHandle (from_process_handle);
@@ -239,8 +236,7 @@ client_request_attach_tty::serve (transport_layer_base *const conn,
 
   if (!rc)
     {
-      log (LOG_ERR, "error opening thread token, error = %lu",
-                    GetLastError ());
+      log (LOG_ERR, "error opening thread token (err %u)", GetLastError ());
       CloseHandle (from_process_handle);
       CloseHandle (to_process_handle);
       error_code (EACCES);
@@ -264,7 +260,7 @@ client_request_attach_tty::serve (transport_layer_base *const conn,
                              from_master,
                              &req.from_master, TRUE) != 0)
       {
-       log (LOG_ERR, "error duplicating from_master handle, error = %lu",
+       log (LOG_ERR, "error duplicating from_master handle (err %u)",
                       GetLastError ());
        error_code (EACCES);
       }
@@ -276,7 +272,7 @@ client_request_attach_tty::serve (transport_layer_base *const conn,
                              to_master,
                              &req.to_master, TRUE) != 0)
       {
-       log (LOG_ERR, "error duplicating to_master handle, error = %lu",
+       log (LOG_ERR, "error duplicating to_master handle (err %u)",
                       GetLastError ());
        error_code (EACCES);
       }
@@ -285,9 +281,8 @@ client_request_attach_tty::serve (transport_layer_base *const conn,
   CloseHandle (to_process_handle);
   CloseHandle (token_handle);
 
-  debug ("%lu(%lu, %lu) -> %lu(%lu,%lu)",
-               req.master_pid, from_master, to_master,
-               req.pid, req.from_master, req.to_master);
+  debug ("%u(%p, %p) -> %u(%p,%p)", req.master_pid, from_master, to_master,
+                                   req.pid, req.from_master, req.to_master);
 
   return;
 }
@@ -374,7 +369,7 @@ server_submission_loop::request_loop ()
    */
   if (!SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST + 1))
     if (!SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST))
-      debug ("failed to raise accept thread priority, error = %lu",
+      debug ("failed to raise accept thread priority (err %u)",
             GetLastError ());
 
   while (_running)
@@ -393,7 +388,7 @@ server_submission_loop::request_loop ()
       if (!conn && errno == EINTR)
        {
          if (!SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_NORMAL))
-           debug ("failed to reset thread priority, error = %lu",
+           debug ("failed to reset thread priority (err %u)",
                   GetLastError ());
 
          Sleep (0);
@@ -401,7 +396,7 @@ server_submission_loop::request_loop ()
                                  THREAD_PRIORITY_HIGHEST + 1))
            if (!SetThreadPriority (GetCurrentThread (),
                                    THREAD_PRIORITY_HIGHEST))
-             debug ("failed to raise thread priority, error = %lu",
+             debug ("failed to raise thread priority (err %u)",
                     GetLastError ());
        }
       if (conn)
@@ -534,9 +529,9 @@ main (const int argc, char *argv[])
 
   const char opts[] = "c:deEf:hl:mp:qr:sSVyY";
 
-  long cleanup_threads = 0;
-  long request_threads = 0;
-  long process_cache_size = 0;
+  int32_t cleanup_threads = 0;
+  int32_t request_threads = 0;
+  int32_t process_cache_size = 0;
   bool shutdown = false;
   const char *config_file = DEF_CONFIG_FILE;
   bool force_config_file = false;
index 87df873100d2d416f1706d9b882a8748effea12b..c92e698b006af41c793965ae9d19b0bbd32c7745 100644 (file)
@@ -1,6 +1,6 @@
 /* msg.cc: Single unix specification IPC interface for Cygwin.
 
-   Copyright 2003, 2004 Red Hat, Inc.
+   Copyright 2003, 2004, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
index 4702d2818e56292cbd9915a5cad1c4b5cc084e30..3de11b6f8d85f501063e403c484b83c1b265427a 100644 (file)
@@ -1,6 +1,6 @@
 /* process.h
 
-   Copyright 2001, 2002, 2003, 2004, 2005 Red Hat Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2012 Red Hat Inc.
 
    Written by Robert Collins <rbtcollins@hotmail.com>
 
@@ -103,7 +103,7 @@ private:
   const DWORD _winpid;
   HANDLE _hProcess;
   HANDLE _signal_arrived;
-  long _cleaning_up;
+  LONG _cleaning_up;
   DWORD _exit_status;          // Set in the constructor and in exit_code ().
   cleanup_routine *_routines_head;
   /* used to prevent races-on-delete */
index 37d894ef9d2a89796ab218eecafdd67a60e5ab68..55cd6e51e9bf914c50e227573a5790dc8cab99b0 100644 (file)
@@ -1,6 +1,6 @@
 /* sem.cc: Single unix specification IPC interface for Cygwin.
 
-   Copyright 2003, 2004 Red Hat, Inc.
+   Copyright 2003, 2004, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
index 38f2d2ee56e60435c702f70c41c40cbf1d5dd6a3..3be0d15f4dbe9f58ed16ce9bee5c892da490d3d8 100644 (file)
@@ -1,6 +1,6 @@
 /* shm.cc: Single unix specification IPC interface for Cygwin.
 
-   Copyright 2003, 2004 Red Hat, Inc.
+   Copyright 2003, 2004, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
index 1a7271f873f7f31d0d6505500c319ee63a13f04f..4578c53a2cea120c629438685ae2f63ea5720cfe 100644 (file)
@@ -258,7 +258,7 @@ shm_delete_mapping(struct vmspace *vm, struct shmmap_state *shmmap_s)
 {
        struct shmid_ds *shmseg;
        int segnum, result;
-       size_t size;
+       size_t size __attribute__ ((unused));
 
        GIANT_REQUIRED;
 
@@ -335,7 +335,7 @@ int
 kern_shmat(struct thread *td, int shmid, const void *shmaddr, int shmflg)
 {
        struct proc *p = td->td_proc;
-       int i, flags;
+       int i, flags __attribute__ ((unused));
        struct shmid_ds *shmseg;
        struct shmmap_state *shmmap_s = NULL;
 #ifndef __CYGWIN__
@@ -512,7 +512,7 @@ done2:
        return (EINVAL);
 #endif
 }
-#endif /* __CYGWIN__ */
+#endif /* !__CYGWIN__ */
 
 #ifndef _SYS_SYSPROTO_H_
 struct shmctl_args {
index 0c3f9913a811a4b2f5eaae49b7d6c3e1d0912869..e17f904348e819ca07f52f38ac8892ae68c23bc7 100644 (file)
@@ -1,6 +1,6 @@
 /* threaded_queue.h
 
-   Copyright 2001, 2002, 2003 Red Hat Inc.
+   Copyright 2001, 2002, 2003, 2012 Red Hat Inc.
 
    Written by Robert Collins <rbtcollins@hotmail.com>
 
@@ -50,7 +50,7 @@ public:
   void add (queue_request *);
 
 private:
-  long _workers_count;
+  LONG _workers_count;
   bool _running;
 
   queue_submission_loop *_submitters_head;
index ed76cc61eb90fa0937edf4889ef6eb929f829791..a65fc43ee3e8ce8797ba3dcca77104174bdf2e6a 100644 (file)
@@ -1,3 +1,7 @@
+2013-04-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Merge in cygwin-64bit-branch.  See ChangeLog.64bit for details.
+
 2013-04-22  Corinna Vinschen  <corinna@vinschen.de>
 
        * include/sys/queue.h: Delete in favor of more complete newlib file.
diff --git a/winsup/cygwin/ChangeLog.64bit b/winsup/cygwin/ChangeLog.64bit
new file mode 100644 (file)
index 0000000..3d91c9a
--- /dev/null
@@ -0,0 +1,1877 @@
+2013-04-21  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
+
+       * include/stdint.h (INTPTR_MAX): Fix missing parenthesis.
+
+2013-04-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_tty.cc (fhandler_pty_slave::write): Change type of towrite to
+       ssize_t.
+       (fhandler_pty_slave::read): Ditto for totalread.
+
+2013-04-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * net.cc (fdsock): Raise send/recv buffer sizes for x86_64.  Extend
+       comment.
+       (cygwin_setsockopt): Fix condition and syscall_printf.
+
+2013-04-12  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler.cc (fhandler_base_overlapped::wait_overlapped): Fix typo in
+       debug_printf.
+       (fhandler_base_overlapped::raw_read): Handle size difference between
+       DWORD and {s}size_t platform-independently.
+       (fhandler_base_overlapped::raw_write): Ditto.  Fix typo in comment.
+
+2013-04-10  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Reinstantiate ptmalloc3.
+       * configure.ac (MALLOC_OFILES): Drop here.
+       * configure: Regenerate.
+       * Makefile.in (MALLOC_OFILES): Set to fixed value here.
+       * cygmalloc.h (HAVE_MORECORE): Define.
+       * malloc.cc (init_user_mstate): Don't disable MORECORE if building
+       with ONLY_MSPACES.
+
+2013-04-09  Corinna Vinschen  <corinna@vinschen.de>
+
+       * mount.cc (MINIMAL_WIN_NTFS_FLAGS): Fix comment.
+
+2013-04-08  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Throughout fix -Wextra warnings.  Ignore regex files and gmon.c.
+
+2013-04-08  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_socket.cc (fhandler_socket::send_internal): Change type of
+       local variable res to ssize_t.
+       * net.cc (cygwin_sendto): Fix local variable res, containing return
+       value, to be ssize_t as well.
+       (cygwin_recvfrom): Ditto.
+       (cygwin_recv): Ditto.
+       (cygwin_send): Ditto.
+       (cygwin_recvmsg): Ditto.
+       (cygwin_sendmsg): Ditto.
+       * syscalls.cc (write): Ditto.
+       (writev): Ditto.
+       * pipe.cc (fhandler_pipe::open): Fix type when reading handle value to
+       accommodate 32 bit compiler.
+
+2013-04-08  Corinna Vinschen  <corinna@vinschen.de>
+       
+       * fhandler_socket.cc (fhandler_socket::get_proc_fd_name): Use %lu as
+       format specifier to match HANDLE size.
+       * net.cc (cygwin_sendto): Fix return type to be ssize_t.  Change
+       syscall_printf return type format specifier to %lR.
+       (cygwin_recvfrom): Ditto.
+       (cygwin_recv): Ditto.
+       (cygwin_send): Ditto.
+       (cygwin_recvmsg): Ditto.
+       (cygwin_sendmsg): Ditto.
+       * smallprint.cc (__small_vsprintf): Handle `l' for %R, too.
+       (__small_vswprintf): Ditto.
+       * syscalls.cc (read): Change syscall_printf return type format specifier
+       to %lR.
+       (readv): Ditto.
+       (pread): Ditto.
+       (write): Ditto.
+       (writev): Ditto.
+       (pwrite): Ditto.
+       (lseek64): Enhance comment.
+
+2013-04-08  Corinna Vinschen  <corinna@vinschen.de>
+
+       * pipe.cc (fhandler_pipe::open): Fix format specifier and type when
+       reading handle value.
+       (fhandler_pipe::get_proc_fd_name): Use same format specifier as in
+       fhandler_pipe::open.
+
+2013-04-06  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.cc (_csbrk): Move down in file, right in front of _cmalloc.
+
+2013-04-04  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.h (struct _cmalloc_entry): Define b as unsigned rather than
+       DWORD.
+       (NBUCKETS): Define here as constant value.
+       (struct init_cygheap): Add bucket_val member.  Define size of bucket_val
+       and buckets using NBUCKETS.
+       * cygheap.cc (NBUCKETS): Drop definition here.
+       (cygheap_init): Initialize cygheap->bucket_val.  Add comment to explain
+       what we do and why.
+       (_cmalloc): Simplify bit bucket search using cygheap->bucket_val.  Drop
+       local variable sz.  Fetch size of block from cygheap->bucket_val.
+       (_cfree): Define b as unsigned.
+       (_crealloc): Fetch size of block from cygheap->bucket_val.
+
+2013-04-02  Алексей Павлов <alexpux@gmail.com>
+
+       * fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Add missed
+       ampersand.
+
+2013-03-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * lc_msg.h: Regenerate from F18 glibc 2.16-28.  In the first place this
+       fixes fi_FI and adds ta_LK (new in Windows 8).
+       * nlsfuncs.cc (LocaleNameToLCID): Drop unneeded declaration.
+
+2013-03-29  Corinna Vinschen  <corinna@vinschen.de>
+
+       * autoload.cc: Drop old comment.
+       * hookapi.cc (PEHeaderFromHModule): Return PIMAGE_NT_HEADERS.
+       (rvadelta): Convert to function and merge in rvadelta_get.
+       (remap): New function to have code for remapping big executables
+       only once.
+       (find_first_notloaded_dll): Simplify.  Don't handle different
+       architecture at all.  Call remap.
+       (hook_or_detect_cygwin): Ditto.
+
+2013-03-28  Kai Tietz  <ktietz@redhat.com>
+
+       * include/cygwin/config.h (___getreent): Harden against aggressive
+       compiler optimization.
+
+2013-03-28  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin64.din: Reinstantiate definition of __srget and __srget_r.
+
+2013-03-28  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in ($(LIB_NAME)): Make sure to rebuild when cygwin.def file
+       has been changed.
+       * cygwin64.din: Remove more underscored symbols.
+       (getdelim): Add missing define in favor of unneeded __getline.
+       (getline): Ditto.
+
+2013-03-27  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_console.cc
+       (fhandler_console::create_invisible_console_workaround): Fix comment.
+       * wincap.cc: Throughout, remove unused has_console_handle_problem
+       wincapc members.
+       * wincap.h (struct wincaps): Remove has_console_handle_problem.
+
+2013-03-27  Corinna Vinschen  <corinna@vinschen.de>
+
+       * net.cc (cygwin_gethostbyname): Revert accidental checkin of change
+       added for debugging.
+
+2013-03-27  Corinna Vinschen  <corinna@vinschen.de>
+
+       * net.cc (struct win64_servent): Define for x86_64.  Explain why.
+       (WIN_SERVENT): Define for all targets.
+       (dup_ent): Use WIN_SERVENT to access critical servent members
+       throughout.
+
+2013-03-27  Corinna Vinschen  <corinna@vinschen.de>
+
+       * sysconf.cc (sca): Change build environment values according to
+       architecture.
+       (csa): Ditto.
+
+2013-03-27  Corinna Vinschen  <corinna@vinschen.de>
+
+       * ntdll.h (STATUS_NETWORK_OPEN_RESTRICTION): Define.
+       (STATUS_SYMLINK_CLASS_DISABLED): Define.
+       * path.cc (symlink_info::check): Handle STATUS_NETWORK_OPEN_RESTRICTION
+       and STATUS_SYMLINK_CLASS_DISABLED status codes.  Explain why.
+
+2013-03-22  Kai Tietz  <ktietz@redhat.com>
+
+       * gendef: Use pause instead of calling yield throughout in x86_64 code.
+
+2013-03-20  Ken Brown  <kbrown@cornell.edu>
+
+       * include/sys/resource.h (RLIM_INFINITY): Define wordsize agnostic.
+
+2013-03-20  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
+
+       * lib/_cygwin_crt0_common.cc: Fix mangled operator new names for x86_64.
+
+2013-03-19  Corinna Vinschen  <corinna@vinschen.de>
+
+       * exceptions.cc (stack_info::init): Don't attempt to dereference NULL
+       framep.
+       (exception::handle): On x86_64, if Rbp is NULL, use Rsp as frame
+       pointer.
+
+2013-03-19  Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef (sigdelayed): Make sure to align the stack since sigdelayed
+       can be called with or without aligned stack.  Save and restore all
+       CPU registers.
+
+2013-03-18  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin.sc.in: Fix comment.
+       * dcrt0.cc (child_info_fork::handle_fork): Revert patch from 2013-03-15.
+
+2013-03-17  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin64.din (strlwr): Export.
+
+2013-03-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Revert previous patch.  For some reason perl doesn't like it.
+
+2013-03-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygtls.h (CYGTLS_PADSIZE): Reduce to 8000 on x86_64.
+       * tlsoffsets64.h: Regenerate.
+
+2013-03-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dcrt0.cc (child_info_fork::handle_fork): Call
+       _pei386_runtime_relocator first thing, before copying parent data and
+       bss segment.  Tweak comment to explain why.
+
+2013-03-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef (_sigfe): 16-byte align xmm0 storage and use movdqa.
+       (_sigbe): Fix alignment before calling yield.  Use movdqa to save and
+       restore xmm0.
+       (sigdelayed): Use movdqa to save and restore xmm0.
+       (_ZN7_cygtls4lockEv): Change absolute values to hex.
+       (stabilize_sig_stack): Ditto.
+       (setjmp): Add comment to explain usage of movdqu.
+       (__sjfault): Ditto.
+       (__ljfault): Ditto.
+       (longjmp): Ditto. Access return value using 32 bit opcodes only.
+       * miscfuncs.cc (thread_wrapper): Don't attempt to copy exception
+       handler list on x86_64.
+
+2013-03-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * autoload.cc (.#dllname_info): Call _std_dll_init on x86_64 bit, too.
+       (INIT_WRAPPER): Change to accommodate the change of the init functions
+       from sysv_abit to ms_abi.  Fix preceeding comment accordingly.  Add
+       SEH information and comments.
+       (std_dll_init): Drop leading underscore on x86_64.  Drop sysv_abi
+       comment.
+       (wsock_init): Ditto.
+       (LoadDLLprime): Drop surrounding ifdef to accommodate above underscore
+       juggling.
+
+2013-03-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef (_sigfe): Save float arguments as well before calling yield.
+       (_sigbe): Move saving %rax from prologue to just before the yield call.
+       Save %xmm0 register, too.
+       (sigdelayed): Add comment.  Save %xmm0 register, too, before calling
+       yield.
+
+2013-03-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_tty.cc (fhandler_pty_master::setup): Add
+       PIPE_REJECT_REMOTE_CLIENTS to pipe mode on systems supporting it.  Add
+       FILE_FLAG_FIRST_PIPE_INSTANCE to pipe open mode.
+       * pipe.cc (fhandler_pipe::create): Ditto.  Fix subsequent comment
+       accordingly.
+       * wincap.h (wincaps::has_pipe_reject_remote_clients): New element.
+       * wincap.cc: Implement above element throughout.
+       * winlean.h (PIPE_REJECT_REMOTE_CLIENTS): Temporarily define until
+       Mingw64 headers define it.
+
+2013-03-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       Remove more old cruft.  Remove Windows NT4 and 2000 from comments
+       throughout, unless it still makes sense.
+       * dlfcn.cc (dlopen): Drop W2K-only code to make loaded DLL persistent.
+       * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Drop code
+       trying to use information from NtQueryVolumeInformationFile.
+       * fhandler_socket.cc (fhandler_socket::close): Drop code snippet
+       disabled since 2008.
+       * mount.cc (MINIMAL_WIN_NTFS_FLAGS): Add flag values set on all
+       NTFS since Windows XP.
+       (get_volume_path_names_for_volume_name): Remove.
+       (dos_drive_mappings::dos_drive_mappings): Call Win32 function
+       GetVolumePathNamesForVolumeNameW directly.
+       * path.cc (file_get_fnoi): Drop test for NT4-only return code.
+       * sched.cc: Add FIXME to global comment.  Reformat comments throughout.
+       * spawn.cc (child_info_spawn::worker): Just call official IsProcessInJob
+       function rather than to test undocumented TEB member.
+       * winlean.h: Drop Mingw32-related defines.
+       * include/limits.h (PTHREAD_KEYS_MAX): Raise value to reflect minimum
+       value available on XP and later.
+
+2013-03-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Revert to old malloc.
+       * mmap.cc (MMAP_STORAGE_LOW): Set higher.  Add comment.
+       (MMAP_STORAGE_HIGH): Add comment.
+       (class mmap_allocator): Change comment.  Add mmap_current_low member.
+       (mmap_allocator::mmap_allocator): Define default constructor.
+       (mmap_allocator::alloc): Change to a round-robin mechanism.  Add or
+       change comments accordingly.
+
+2013-03-13  Kai Tietz  <ktietz@redhat.com>
+           Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef (_sigfe): Save arguments before calling yield so they don't
+       get clobbered.  Explain why.
+
+2013-03-12  Ken Brown  <kbrown@cornell.edu>
+
+       * include/a.out.h: Fix up for x86_64.
+
+2013-03-12  Corinna Vinschen  <corinna@vinschen.de>
+
+       * smallprint.cc (rnarg): Fix cast to print negative values correctly.
+
+2013-03-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler.cc (fhandler_base::raw_read): Replace accidentally left in
+       Win32 error codes with equivalent status codes.
+
+2013-03-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygmalloc.h: Include regparm.h rather than defining __reg{1,2,3} here.
+       * ptmalloc3.cc (__malloc_initialized): Define as type LONG on Cygwin
+       and include windows.h.
+       (ptmalloc_init): Set __malloc_initialized on Cygwin using
+       InterlockedCompareExchange and carefully check for concurrency
+       situation.
+
+2013-03-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef: Add SEH information to sigfe entry points, as well as to
+       _sigfe and _sigbe.
+
+2013-03-07  Corinna Vinschen  <corinna@vinschen.de>
+
+       * heap.cc (heap_init): Fix setting reserved_size value when using
+       ptmalloc3 to avoid too much pagefile pressure at fork time.
+
+2013-03-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       For x86_64 target:
+       * dll_init.cc (dll::init): Don't set p.envptr.
+       (update_envptrs): Disable entirely.
+       * dll_init.h (struct per_module): Disable envptr.
+       * environ.h (update_envptrs): Change to empty macro.
+
+2013-03-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       For x86_64 target:
+       * Makefile.in (COMMON_CFLAGS): Add -mcmodel=small to create smaller
+       footprint.
+       * cygwin64.din (__cygwin_environ): Drop export.  Only export environ
+       as alias to __cygwin_environ.
+       * dcrt0.cc (dll_crt0_1): Call main with __cygwin_environ as parameter.
+       (_dll_crt0): Don't set main_environ.
+       (cygwin_dll_init): Don't create local variable envp and don't set
+       user_data->envptr.
+       * dll_init.cc (dll_list::alloc): Don't assert.
+       * dll_init.h (per_module::operator =): Don't set envptr.
+       * environ.cc (cur_environ): Disable.
+       * environ.h (main_environ): Don't define.
+       (cur_environ): Change to macro.
+       * globals.cc (main_environ): Don't initialize.
+       (struct per_process): Drop envptr.
+       * perprocess.h (SIZEOF_PER_PROCESS): Set to 41*8 to accommodate size
+       change of struct per_process.
+       * include/sys/cygwin.h (struct per_process): Drop envptr.
+       * lib/_cygwin_crt0_common.cc (environ): Drop declaration.
+       (_cygwin_crt0_common): Don't set u->envptr.
+
+2013-03-04  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
+
+       * cygwin64.din: Fix mangled operator new names for size_t==long.
+       * libstdcxx_wrapper.cc: Ditto for x86_64.
+
+2013-03-01  Corinna Vinschen  <corinna@vinschen.de>
+
+       * autoload.cc (AttachConsole): Remove.
+       (GetModuleHandleExW): Remove.
+       (GetSystemWow64DirectoryW): Remove.
+       (GetVolumePathNamesForVolumeNameW): Remove.
+       * exceptions.cc (cygwin_stackdump): Always call RtlCaptureContext.
+       (exception::handle): Drop accidentally left in debugging statement.
+       Always call RtlCaptureContext.
+       (sigpacket::process): Always call RtlCaptureContext for current thread.
+       * fhandler_disk_file.cc (fstatvfs): Drop code using
+       FileFsSizeInformation.
+       (struct __DIR_cache): Remove comment.
+       (fhandler_disk_file::rewinddir): Drop W2K-only code.
+       * fhandler_floppy.cc (fhandler_dev_floppy::get_drive_info): Don't
+       check for old OS.  Extend a comment.
+       * fhandler_mem.cc (fhandler_dev_mem::open): Drop NT4 and W2K from
+       debug output.
+       * fhandler_proc.cc (format_proc_partitions): Drop Pre-XP considerations.
+       * fhandler_procnet.cc (fhandler_procnet::exists): Ditto.
+       (fhandler_procnet::readdir): Ditto.
+       (format_procnet_ifinet6): Ditto.
+       * fhandler_socket.cc (fhandler_socket::recvmsg): Ditto.
+       * fhandler_tape.cc (mtinfo_drive::get_status): Ditto.
+       * init.cc (dll_entry): Drop W2K-only code.
+       * net.cc (get_ifs): Rename from get_xp_ifs.
+       (get_2k_ifs): Remove.
+       (getifaddrs): Always call get_ifs.
+       (get_ifconf): Ditto.
+       (if_nametoindex): Drop Pre-XP considerations.
+       (load_ipv6_funcs): Ditto.  Fix preceeding comment.
+       * sec_auth.cc (lsaauth): Drop code handling fake_login_sid.
+       * sec_helper.cc (fake_logon_sid): Remove.
+       (set_cygwin_privileges): Fix uncommented statement to drop pre-XP
+       considerations.
+       * security.h (fake_logon_sid): Drop declaration.
+       * shared.cc (shared_info::init_obcaseinsensitive): Drop W2K-only code.
+       * wincap.cc: Throughout, remove setting all deprecated wincapc members.
+       (wincap_minimal): Set to wincap_xpsp2.
+       (wincap_2000): Remove.
+       (wincap_2000sp4): Remove.
+       (wincap_xp): Remove.
+       (wincap_xpsp1): Remove.
+       (wincapc::init): Drop OS 5.0 and pre-SP2 XP.
+       * wincap.h (struct wincaps): Remove the following members:
+       has_create_global_privilege, has_ioctl_storage_get_media_types_ex,
+       has_disk_ex_ioctls, has_buggy_restart_scan, needs_logon_sid_in_sid_list,
+       has_gaa_prefixes, has_recvmsg, has_stack_size_param_is_a_reservation,
+       kernel_is_always_casesensitive, has_rtl_capture_context.
+
+2013-03-01  Corinna Vinschen  <corinna@vinschen.de>
+
+       * exceptions.cc (rtl_unwind): Convert to macro doing nothing on x86_64.
+       (exception::handle): Drop creating frame variable on x86_64.
+       * wincap.cc (wincap_2000sp4): Set has_rtl_capture_context to false.
+
+2013-03-01  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygserver.h (struct header_t): Revert msglen to simple member.
+       Drop accessor methods.
+       * cygserver_ipc.h (struct proc): Drop enforced 4 byte struct packing.
+       Remove members for 64<->32 bit IPC.  Revert to original member order.
+       (ipc_set_proc_info): Remove 64<->32 handling.
+       (conv_timespec32_to_timespec): Delete.
+       (conv_timespec_to_timespec32): Delete.
+       * pinfo.h (struct win_heap_info): Remove.
+       * shm.cc (fixup_shms_after_fork): Revert parent initialization.
+       * winlean.h: Remove _TYPE64_CLR and _TYPE64_SET macros.  Remove
+       usage throughout code.
+       * include/cygwin/ipc.h: Drop 64<->32 bit helper structures.
+       * include/cygwin/msg.h: Ditto.  Drop enforced 4 byte struct packing.
+       * include/cygwin/sem.h: Ditto.
+       * include/cygwin/shm.h: Ditto.
+       * include/cygwin/sysproto.h: Drop enforced 4 byte struct packing.
+
+2013-02-28  Corinna Vinschen  <corinna@vinschen.de>
+
+       * pseudo-reloc.cc (do_pseudo_reloc): Add test to check for invalid 32
+       bit relocation in 64 bit code.  Only test when building without
+       optimization.
+
+2013-02-28  Corinna Vinschen  <corinna@vinschen.de>
+
+       * exceptions.cc (_cygtls::signal_debugger): Raise size of sigmsg buffer
+       on x86_64.
+       * tlsoffsets64.h: Regenerate.
+
+2013-02-27  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/cygwin/signal.h (struct ucontext): Add missing fields from
+       Windows CONTEXT definition.  Define oldmask as 64 bit type.
+
+-- post-ptmalloc3 tag
+
+2013-02-27  Corinna Vinschen  <corinna@vinschen.de>
+
+       * configure.ac (MALLOC_OFILES): Add ptmalloc3.o.
+       * configure: Regenerate.
+       * cygmalloc.h: Declare pt* functions rather than dl* functions.
+       (mmap64): Declare.
+       (mmap): Define as mmap64.
+       (__malloc_lock): Drop macro.
+       (__malloc_unlock): Ditto.
+       (MSPACES): Define.
+       (ONLY_MSPACES): Define.
+       * debug.h: Include malloc.h rather than otherwise unused dlmalloc.h.
+       * fork.cc (frok::parent): Drop malloc locking since that's performed
+       by malloc_atfork now.
+       * heap.cc (heap_init): Accommodate the fact that there's a chance
+       that no heap space has been allocated at fork time.
+       * malloc-private.h: New file from ptmalloc3, having malloc-machine.h
+       and malloc-2.8.3.h folded in.
+       * malloc.cc: Replaced by new file from ptmalloc3.
+       * malloc_wrapper.cc: Throughout, remove malloc locks and call pt*
+       functions rather than dl* functions.
+       * pinfo.cc (winpids::set): Drop malloc locking.
+       * ptmalloc3.cc: New file from ptmalloc3.
+
+-- pre-ptmalloc3 tag
+
+2013-02-26  Corinna Vinschen  <corinna@vinschen.de>
+
+       * exception.h (_except_list): Don't define on x86_64.
+       (class exception): Don't define members el and save on x86_64.
+       (exception::~exception): Don't define on x86_64.
+       * exceptions.cc (signal_exit): Fix typo in condition.
+
+2013-02-25  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin64.din: Remove all deprecated cygwin32_foo and cygwin_foo
+       path conversion functions.
+       * path.cc: Disable aforementioned functions on x86_64.
+       * include/sys/cygwin.h: Don't declare aforementioned functions on
+       x86_64.
+
+2013-02-25  Corinna Vinschen  <corinna@vinschen.de>
+
+       * exception.h (class exception): Add handler_installed member.
+       Change parameters to handle method to match high-level exception
+       handler calls.
+       (exception::exception): On x86_64, install exception handler only
+       once.  Explain what we do.
+       * exceptions.cc (_AFMT): Change to only 11 digits on x86_64.
+       (cygwin_exception::dump_exception): Print Rip with only 11 digits.
+       Print 64 bit registers with 0-padding.
+       (class stack_info): Add members c and hist on x86_64.
+       (stack_info::init): Take PCONTEXT rather than bool as third parameter.
+       Tweak code accordingly.  Initialize c and hist on x86_64.
+       (stack_info::walk): Add implementation for x86_64.  Drop unneeded
+       #ifndef in 32 bit code.
+       (cygwin_exception::dumpstack): Call thestack.init with context as
+       parameter.  Change header output for x86_64.
+       (cygwin_stackdump): Prefer RtlCaptureContext over GetThreadContext.
+       (CYG_EXC_CONTINUE_EXECUTION): Define generic definition matching all
+       platforms.
+       (CYG_EXC_CONTINUE_SEARCH): Ditto.
+       (exception::handler_installed): Define here.
+       (exception::handle): Define according to declaration in exception.h.
+       Create 32 bit parameters as local variable on 64 bit.  Change all
+       return statements to use generic definitions.  Simplify setting framep
+       on x86_64.  Disable setting frame-based exception handler on x86_64.
+       Fix formatting of klog output for x86_64.
+       (signal_exit): Create context for cygwin_exception creation.
+       (sigpacket::process): Prefer RtlCaptureContext over GetThreadContext.
+       * wincap.h (wincaps::has_rtl_capture_context): New element.
+       * wincap.cc: Implement above element throughout.
+
+2013-02-22  Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+           Corinna Vinschen <corinna@vinschen.de>
+
+       * cygwin.din (_get_osfhandle): Make main export.  Define get_osfhandle
+       from here.
+       * cygwin64.din (_get_osfhandle): Rename from get_osfhandle.
+       (_setmode): Rename from setmode.
+       * include/io.h: Ditto. Define unprefixed names with preprocessor
+       macros for backwards source compatibility.
+       (access): Remove.
+       * syscalls.cc (_setmode): Rename from setmode.
+       (cygwin_setmode): Call _setmode.
+       (_get_osfhandle): Rename from get_osfhandle.
+
+2013-02-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (target_cpu): Define.  Check for target_cpu rather than
+       target_alias for conditional compilation issues.
+       (toolopts): Change --target into --cpu option and use $target_cpu as
+       argument.
+       ($(DEF_FILE)): Call gendef with $(target_cpu) as argument, rather than
+       with $(target_alias).
+       * gendef: Accommodate change from --target to --cpu option.
+       * mkimport: Ditto.
+       * speclib: Ditto.
+
+2013-02-20  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
+
+       * cygserver_ipc (class ipc_retval): Add ssize_t member to anonymous
+       union.
+       (ipc_retval::operator =): Add ssize_t variant for x86_64.
+       * fhandler_floppy.cc (fhandler_dev_floppy::raw_write): Change return
+       type to ssize_t to match fhandler.h.
+       * fhandler_socket.cc (fhandler_socket::readv): Ditto.
+       (fhandler_socket::write): Ditto.
+       (fhandler_socket::writev): Ditto.
+       (fhandler_socket::sendmsg): Ditto.
+
+2013-02-18  Corinna Vinschen  <corinna@vinschen.de>
+
+       * localtime.cc: Add comment.
+
+2013-02-18  Corinna Vinschen  <corinna@vinschen.de>
+
+       * localtime.cc: Throughout, pull up to latest code from NetBSD.
+
+2013-02-18  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler.cc (fhandler_base::raw_read): Rearrange code to use
+       NtReadFile and to fix problem using pointer to wrongly sized variable
+       on x86_64.
+       (fhandler_base::read): Drop redundant code.
+       * fhandler_disk_file.cc (fhandler_disk_file::pread): Fix function
+       to not read the information twice.  Handle STATUS_END_OF_FILE.
+
+2013-02-17  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
+
+       * Makefile.in (libcygwin.a): Move --target flag from here...
+       (toolopts): to here, to be used by both mkimport and speclib.
+       * speclib: Omit leading underscore in symbol names on x86_64.
+
+2013-02-17  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin.sc.in (.gnu_debuglink_overlay): Drop "64" in dbg file name.
+
+2013-02-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * nfs.h: Make sure packing of NFS fattr3 struct is 4 byte.
+       (struct nfs_timestruc_t): Define.
+       (struct fattr3): Define timestamps as type struct nfs_timestruc_t.
+       * fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Copy
+       each timestruc_t component separately to accommodate different size.
+
+2013-02-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (toollibdir): Remove.  Revert to using tooldir instead.
+       * configure.ac (DLL_NAME): Set to cygwin1.dll in x86_64 case, too.
+       * configure: Regenerate.
+       * cygwin.sc.in (SEARCH_DIR): Align to 32 bit search dir, use lib, rather
+       than lib64.
+       * cygwin64.din (LIBRARY): Set name to cygwin1.dll.
+       * fhandler_process.cc (struct heap_info): Drop win_heap_info class
+       and revert code to former heap_info implementation.
+       (format_process_maps): Define heaps back to heap_info
+       * hookapi.cc (hook_or_detect_cygwin): Add shortcut so the code does
+       not search executable for being a Cygwin executable, if the architecture
+       is not matching the current Cygwin.  Always use for "cygwin1.dll".
+       * pinfo.cc (commune_process): Drop PICOM_HEAP_INFO code.
+       (_pinfo::commune_request): Ditto.
+       (_pinfo::win_heap_info): Remove.
+       * pinfo.h (enum picom): Remove PICOM_HEAP_INFO.
+
+2013-02-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * autoload.cc (two_addr_t): Use __uint64_t as type for the i686
+       version, analogue to __uint128_t for x86_64.
+       (INIT_WRAPPER): New x86_64 macro to install a sysv_abi function wrapper
+       for the DLL init functions.  Add long comment to explain why this is
+       necessary.  Create wrapper for std_dll_init and wsock_init.
+       (std_dll_init): Rename with leading underscore on x86_64 and take
+       calling function as argument.  Disable overwriting return address on
+       stack for x86_64.
+       (wsock_init): Ditto.
+
+2013-02-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (toollibdir): Define build and target dependent.
+       (install-libs): Use $(toollibdir) rather than $(tooldir)/lib.
+       (uninstall-libs): Ditto.
+       (uninstall-man): Use $(DESTDIR)$(mandir) as in install-man, rather
+       than $(tooldir)/man.
+
+2013-02-12  Corinna Vinschen  <corinna@vinschen.de>
+
+       * heap.cc (eval_start_address): Move heap to 0x6:00000000.  Change
+       comment to explain why.
+       * mmap.cc (MMAP_STORAGE_LOW): Accommodate above change.
+
+2013-02-12  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_floppy.cc (fhandler_dev_floppy::open): Cast second parameter
+       in roundup2 to same size as first parameter to make sure mask size is
+       correct.
+       * fhandler_process.cc (format_process_maps): Ditto.
+       * fhandler_raw.cc (fhandler_dev_raw::dup): Ditto.
+       * hookapi.cc (find_first_notloaded_dll): Add cast.
+       * spawn.cc (av::fixup): Ditto.
+       * wincap.h: Add comment to explain the following change.
+       (wincapc::page_size): Return size_t.
+       (wincapc::allocation_granularity): Ditto.
+
+       * mmap.cc: Throughout, accommodate the fact that AT_ROUND_TO_PAGE isn't
+       support on 64 bit at all.
+       (class mmap_allocator): New class to allocate mmap slots on x86_64.
+       (mmap_alloc): Define global instant of mmap_allocator.
+       (mmap64): Call mmap_alloc.alloc on x86_64.
+
+2013-02-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef (longjmp): Fix indirect addressing in x86_64 setjmp.
+
+2013-02-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin64.din: Add missing symbols.
+       * mkimport: Make sure to use and test against platform dependent
+       "imp" prefix.
+
+2013-02-09  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin.sc.in (.rdata): Add .rdata_cygwin_nocopy subsection.
+       (.cygheap): Raise size to 3 Megs on x86_64.
+       * dcrt0.cc (dll_crt0_0): Drop call to init_global_security.
+       * dtable.cc (std_consts): Drop NO_COPY.
+       * errno.cc (errmap): Drop NO_COPY, constify instead.
+       (_sys_errlist): Drop NO_COPY.
+       * fhandler_clipboard.cc (CYGWIN_NATIVE): Ditto.
+       * fhandler_console.cc (keytable): Drop NO_COPY, constify instead.
+       * grp.cc (null_ptr): Make NO_COPY_RO.
+       * heap.cc (eval_start_address): Fix comment.
+       * localtime.cc (wildabbr): Make NO_COPY_RO.
+       (gmt): Ditto.
+       * miscfuncs.cc (case_folded_lower): Drop NO_COPY.
+       (case_folded_upper): Ditto.
+       (isalpha_array): Ditto.
+       (nice_to_winprio): Ditto for priority.
+       (class thread_allocator): New class to allocate thread stack on x86_64.
+       (thr_alloc): Define global NO_COPY instant of thread_allocator.
+       (CygwinCreateThread): Call thr_alloc.alloc on x86_64 to reserve stack.
+       * net.cc (errmap): Drop NO_COPY, constify instead.
+       (host_errmap): Ditto.
+       * netdb.cc (SPACE): Drop NO_COPY.
+       * sec_helper.cc (null_sdp): Static NO_COPY_RO definition of null SD.
+       (sec_none): Define NO_COPY_RO, define content statically.
+       (sec_none_nih): Ditto.
+       (sec_all): Ditto.
+       (sec_all_nih): Ditto.
+       (get_null_sd): Remove.
+       (init_global_security): Remove.
+       * security.cc (file_mapping): Define NO_COPY_RO.
+       (check_registry_access): Ditto for reg_mapping.
+       * spawn.cc (exe_suffixes): Drop NO_COPY, constify instead.
+       (dll_suffixes): Drop unused, disabled definition and comment.
+       * strsig.cc (sys_sigabbrev): Drop NO_COPY_INIT.
+       (sys_siglist): Ditto.
+       * syscalls.cc (def_shells): Drop NO_COPY.
+       * winsup.h (NO_COPY_RO): Define to place variable in
+       .rdata_cygwin_nocopy section.
+       (init_global_security): Drop declaration.
+
+2013-02-09  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_process.cc (win_heap_info::~win_heap_info): Only try to free
+       heap_vm_chunks if it's not NULL.
+       * pinfo.h (struct commune_result): Change type of n to DWORD.
+       * pinfo.cc (_pinfo::commune_request): Change type of n to DWORD to
+       fix subsequent sizeof test after reading from commune pipe on x86_64.
+       Raise read timeout to match write timeout.
+
+2013-02-09  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygserver_ipc.h (ipc_retval::operator =): Disable size_t variant
+       on x86_64 since type is identical to vm_offset_t.
+
+2013-02-08  Corinna Vinschen  <corinna@vinschen.de>
+
+       * regparm.h: New file to define platform dependent regparm attributes.
+       Define all of them empty if __CYGMAGIC__ is defined.
+       * cygerrno.h: Include regparm.h instead of defining _reg[123] here.
+       * winsup.h: Ditto.
+       * cygmagic: Define __CYGMAGIC__ to help generate same result on all
+       platforms.
+
+2013-02-08  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin64.din (BASE): Set to 0x180040000.
+       (_fe_dfl_env): Remove useless symbol.
+       (_fe_nomask_env): Remove useless symbol.
+       (exit): Add missing symbol.
+       (setmode): Ditto.
+       * gendef (longjmp): Convert all displacements to hex for readability.
+       Change all movaps instructions to movdqu to accommodate unaligned
+       access to 128 bit values.
+
+2013-02-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * pseudo-reloc.cc (do_pseudo_reloc): Enable 64 bit code for x86_64
+       Cygwin.
+
+2013-02-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * miscfuncs.cc (RtlFillMemory): Declare.
+       (RtlCopyMemory): Declare.
+       (memset): Just call RtlFillMemory.
+       (memcpy): Just call RtlCopyMemory.
+       * mmap.cc (class mmap_record): Drop enforced packing.  Reorder members
+       to allow tight packing on 32 as well as on 64 bit.
+       * include/sys/dirent.h: Don't enforced structure packing on x86_64.
+       (__DIRENT_COOKIE): Use different value on 64 bit.
+
+2013-02-04  Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef (fefunc): Fix incorrect pc-relative jmp instruction.
+       (_sigfe): Fix offset to return address on stack.  Add and fix comments.
+       (_sigbe): Fix stack alignment when creating spill area for call to
+       yield.  Add and fix comments.
+       (sigdelayed): Add fake push to make sure stack is aligned correctly.
+       Use fake stack alignment on exit to store return address and call ret,
+       rather than jmp.  Fix comments.
+       (_cygtls::lock): Only create and destroy spill area when really calling
+       yield.
+
+2013-02-04  Corinna Vinschen  <corinna@vinschen.de>
+
+       * autoload.cc (LoadDLLfuncEx3): Adjust address computation required
+       by latest change to the 64 bit code.
+       * cygmalloc.h (MALLOC_ALIGNMENT): Set to 16 on x86_64.
+       * cygtls.h: Set struct alignment to 8 on x86_64.  Move inclusion of
+       other header files outside of alignment-enforced code area.  Drop
+       inclusion of security.h entirely.
+       (_cygtls::get_signal_arrived): Use NULL SECURITY_ATTRIBUTES rather than
+       &sec_none_nih.
+       * gendef (_cygtls::lock): Fix stack alignment.
+       * heap.cc (page_const): Change type to ptrdiff_t, otherwise negation
+       operator in pround creates broken bitmask.
+       * shared.cc (page_const): Add cast to ptrdiff_t.
+       * tlsoffsets64.h: Regenerate.
+
+2013-01-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in ($(LIB_NAME)): Add --target option to mkimport call.
+       * gendef: Drop -w option.  Make callto sigfe function pc-relative
+       on x86_64.
+       * miscfuncs.cc (__import_address): Drop comment and misguide attempt
+       to handle absolute addressing in x86_64 mode.
+       * mkimport: Add --target option.  Handle x86_64 target, especially
+       create pc-relative jmp calls.
+
+2013-01-29  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygtls.h: Cleanup x86_64 related comment.
+       (_tlsbase): Change return type to PVOID.
+       (_tlstop): Ditto.
+       (_my_tls): Accommodate above change.
+       * dcrt0.cc (child_info_fork::alloc_stack): Revert previous patch, but
+       keep cast to PVOID.
+       (dll_crt0_1): Ditto.
+       * exception.h: Define _exception_list as _EXCEPTION_REGISTRATION_RECORD
+       on x86_64.
+       (_except_list): Define in terms of NtCurrentTeb() on x86_64.
+       * miscfuncs.cc (__import_address): Handle 32 bit absolute addressing
+       in IAT on x86_64.
+       * include/cygwin/config.h (___getreent): New inline function on
+       x86_64.  Define __getreent in terms of ___getreent on x86_64.  Fix
+       comment accordingly.
+
+2013-01-29  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygtls.h (_tlsbase): Temporary workaround for GCC bug.
+       (_tlsbase): Ditto.
+       * cygwin64.din: Set BASE temporariliy to address < 32 bit to workaround
+       GDB bug.
+       * dcrt0.cc (child_info_fork::alloc_stack): Temporary workaround for GCC
+       bug.
+       (dll_crt0_1): Ditto.
+       * miscfuncs.cc (memset): Temporary workaround missing MSABI function in
+       newlib.
+       (memcpy): Ditto.
+       * include/cygwin/config.h (__getreent): Drop definition for x86_64 to
+       workaround GCC bug.
+
+2013-01-29  Corinna Vinschen  <corinna@vinschen.de>
+
+       * winbase.h (ilockcmpexch): Define always.
+       (InterlockedCompareExchange): Ditto.
+       (ilockcmpexch64): Define for x86_64.
+       (InterlockedCompareExchange64): Ditto.
+       (InterlockedCompareExchangePointer): Define in terms of
+       InterlockedCompareExchange64 on x86_64.
+
+2013-01-29  Kai Tietz  <ktietz@redhat.com>
+
+       * cygwin.sc.in: Fix ctors and dtors filler and zero-terminator for
+       64 bit.
+
+2013-01-29  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (TEST_DLL_NAME): Fix to use correct name per target.
+       * gendef (fefunc): Resurrect accidentally dropped 32 bit code.
+
+2013-01-29  Corinna Vinschen  <corinna@vinschen.de>
+
+       * heap.cc (eval_start_address): Change address and comment for 64 bit.
+       (eval_initial_heap_size): Change return type to SIZE_T.  Use different
+       values for 64 bit.
+
+2013-01-28  Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef: Add missing setjmp/longjmp functionality, still untested.
+
+2013-01-25  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin.sc.in: Accommodate extra .text, .pdata, and .xdata section on
+       64 bit.
+       * cygwin64.din: Set BASE to 0x200040000 to start shared sections at
+       0x200000000.
+       * gendef: Second cut 64 bit assembler functionality, still untested.
+
+2013-01-25  Kai Tietz  <ktietz@redhat.com>
+
+       * autoload.cc (LoadDLLfuncEx3): Adjust assembler for x64 to avoid
+       relocations.
+       (noload): Likewise.
+
+2013-01-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * gendef: First cut 64 bit assembler functionality, untested.
+
+2013-01-22  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (speclib): Exclude main symbol.
+       (NEW_FUNCTIONS): Set to empty for x86_64.
+       ($(DEF_FILE)): Call gendef with target_alias as additional parameter.
+       * configure.ac (DLL_ENTRY): Drop leading underscore for x86_64.
+       * configure: Regenerate.
+       * cygwin.sc.in: Drop _SYM usage for __data_start__, __data_end__,
+       __bss_start__, and __bss_end__.
+       * cygwin64.din: Remove all fast-call math function entry points.
+       (_alloca): Define as __alloca.
+       (_dll_crt0): Drop 32 bit stdcall specifier.
+       (dll_entry): Ditto.
+       (dll_noncygwin_dllcrt0): Remove.
+       (getpwduid): Remove.
+       (lacl): Remove.
+       * dcrt0.cc (dll_data_start): Define for x86_64.
+       (dll_data_end): Ditto.
+       (dll_bss_start): Ditto.
+       (dll_bss_end): Ditto.
+       * gendef: Handle new target argument.  Handle 64 bit target.
+       Add preliminiary empty function definitions for 64 bit to allow linking.
+       * winsup.h: Define linker data and bss section symbols with
+       additional underscore for x86_64.
+       * lib/_cygwin_crt0_common.cc (__image_base__): Define for 64 bit and
+       map to _image_base__ via macro.
+       (_cygwin_crt0_common): Fix setting data and bss section borders on
+       x86_64.
+
+2013-01-21  Corinna Vinschen  <corinna@vinschen.de>
+
+       * miscfuncs.cc (__import_address): Fix address computation for 64 bit.
+
+2013-01-19  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dcrt0.cc (_cygwin_exit_return): Define to allow usage of same C
+       symbol name independent of target.
+       * perprocess.h (SIZEOF_PER_PROCESS): Define for x86_64.
+       * include/sys/cygwin.h (struct per_process): Tweak definition for
+       x86_64.
+
+2013-01-18  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/cygwin/config.h (__SYMBOL_PREFIX): Define.
+       (_SYMSTR): Define.
+       * child_info.h (spawn_info): Use _SYMSTR macro to define assembler
+       symbol.
+       (fork_info): Ditto.
+       * libstdcxx_wrapper.cc: Ditto, throughout.
+       * winsup.h (dll_crt0): Ditto.
+       * include/cygwin/time.h (daylight): Ditto.
+       (timezone): Ditto.
+       * lib/_cygwin_crt0_common.cc: Ditto, throughout.
+
+2013-01-17  Corinna Vinschen  <corinna@vinschen.de>
+
+       * child_info.h (spawn_info): Define asm symbol without leading
+       underscore for x86_64.
+       (fork_info): Ditto.
+       * cygwin.sc.in (__CONCAT1): Define.
+       (__CONCAT): Define.
+       (_SYM): Define.
+       (_data_start__): Define using _SYM macro to accommodate multiple
+       platforms.
+       (_data_end__): Ditto.
+       (_bss_start__): Ditto.
+       (_bss_end__): Ditto.
+       (_cygheap_start): Ditto.
+       (_cygheap_end): Ditto.
+
+2013-01-09  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/cygwin/config.h (_tlsbase): Define for x86_64.
+
+2012-12-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin.sc.in (.gnu_debuglink_overlay): Accommodate longer dbg file
+       name on 64 bit.
+
+2012-12-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * pinfo.h (enum picom): Add PICOM_HEAP_INFO.
+       (_pinfo::win_heap_info): Declare.
+       (struct win_heap_info): Rename from heap_info and define here.  Change
+       to accommodate 64 bit.
+       * fhandler_process.cc (struct win_heap_info): Just implement here.
+       (win_heap_info::gen_heap_info): New method.
+       (format_process_maps): Accommodate above changes.  Add FIXME comment
+       to explain 32->64 bit problem with VirtualQueryEx.
+       * pinfo.cc (commune_process): Handle PICOM_HEAP_INFO.
+       (_pinfo::commune_request): Ditto.
+       (_pinfo::win_heap_info): New method.
+
+2012-12-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin.sc.in (OUTPUT_FORMAT): Fix typo in 64 bit code.
+       * spawn.cc (av::fixup): Drop '!!' to keep argument to set_cygexec a
+       void *.
+
+2012-12-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (TLSOFFSETS_H): Let configure fill in.  Change all
+       occurence of tlsoffsets.h to $(TLSOFFSETS_H).
+       $(srcdir)/$(TLSOFFSETS_H): Add @CONFIG_DIR@ as parameter to
+       gentls_offsets so the script knows the target CPU.
+       * configure.ac (TLSOFFSETS_H): Set according to target.
+       * configure: Regenerate.
+       * gentls_offsets: Handle x86_64 as target.  Add FIXME comment.  Unlink
+       all temporary files.
+       * tlsoffsets64.h: New file.
+
+2012-12-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (DLL_NAME): Let configure fill in.
+       (DIN_FILE): Ditto.  Change all occurence of cygwin.din to $(DIN_FILE).
+       * configure.ac (DLL_NAME): Set according to target.
+       (DIN_FILE): Ditto.
+       * configure: Regenerate.
+       * cygwin64.din: New file.
+
+2012-12-10  Corinna Vinschen  <corinna@vinschen.de>
+
+       * posix_ipc.cc: Enforce 4 byte alignment on all structs used in the
+       message queue file.
+       (struct mq_fattr): Fixed size mq_attr structure as stored in file.
+       (struct mq_hdr): Change to have same size on 32 and 64 bit.  Add
+       mqh_magic to allow check for old message queue file.
+       (struct msg_hdr): Change to have same size on 32 and 64 bit.  Change
+       type of mqh_attr to struct mq_fattr.
+       (struct mq_info): Change to have same size on 32 and 64 bit.
+       (mq_open): Add check for maximum mq_maxmsg and mq_msgsize values which
+       still fit into 32 bit values.  Set mqh_magic in file to MQI_MAGIC.
+       Check mqh_magic value on existing file to detect old message queue file.
+       (mq_getattr): Change type of local attr variable to struct mq_fattr.
+       (mq_setattr): Ditto.
+       (_mq_send): Ditto.
+       (_mq_receive): Ditto.
+       (mq_close): Ditto.
+
+2012-12-10  Corinna Vinschen  <corinna@vinschen.de>
+
+       * hookapi.cc (hook_or_detect_cygwin): Only check for one cygwin DLL
+       file name depending on executable target type.  Return value indicating
+       executable target type.  Change comment accordingly.
+       * path.h (enum path_types): Add FIXME comment to definition of
+       PATH_OPEN.  Add PATH_64BITEXEC.
+       (iscygexec32): New method.
+       (iscygexec64): New method.
+       (set_cygexec): Implement additionally with void * parameter to be able
+       to set PATH_64BITEXEC if required.
+
+2012-12-10  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Throughout, fix format string of debug printf and api_fatal calls
+       to work in 32 and 64 bit environment, as well as to honor signedness.
+       Use %y instead of 0x%x.
+       * fhandler.h (class fhandler_dev_mem): Change type of mem_size from
+       DWORD to SIZE_T.
+       * fhandler_mem.cc: Throughout, cast mem_size in comparisons to make
+       GCC happy.
+       * fhandler_process.cc (format_process_maps): Change type of ret_len
+       to SIZE_T.
+       (get_mem_values): Ditto for n and length.
+       * mmap.cc (MapView): Ditto for commitsize and viewsize.
+       (class mmap_record): Ditto for len.  Use SIZE_T througout for memory
+       size in method args and return types.
+       * ntdll.h (NtLockVirtualMemory): Fix type of memory size parameters
+       to SIZE_T.
+       (NtMapViewOfSection): Ditto.
+       (NtQueryVirtualMemory): Ditto.
+       (NtUnlockVirtualMemory): Ditto.
+       (RtlFreeHeap): Change type of first parameter to HANDLE.
+       * shm.cc (shmat): Change type of viewsize to SIZE_T.
+       * timer.cc (timer_thread): Change type of sleep_ms to LONG.
+       (ualarm): Drop casts to unsigned int in timer value computation.
+
+2012-12-06  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygserver_ipc.h (conv_timespec32_to_timespec): Implement here.
+       (conv_timespec_to_timespec32): Ditto.
+       * include/cygwin/ipc.h (struct _ts32): Define here.
+       * include/cygwin/msg.h: Enforce 4 byte alignment on all structs.
+       (struct _ts32): Move definition to include/cygwin/ipc.h.
+       (struct _msqid_ds32): Drop member comments.
+       * include/cygwin/sem.h: Enforce 4 byte alignment on all structs.
+       (struct _semid_ds32): Define on 64 bit in _KERNEL mode.
+       * include/cygwin/shm.h: Enforce 4 byte alignment on all structs.
+       (struct _shmid_ds32): Define on 64 bit in _KERNEL mode.
+       (struct shminfo): Enhance coment on shmall member.
+       (struct shm_info): Convert type of all members to int32_t.
+       * include/cygwin/sysproto.h (struct semctl_args): Change definition to
+       use the same structure on 32 and 64 bit.
+       (struct semop_args): Ditto.
+       (struct shmat_args): Ditto.
+       (struct shmctl_args): Ditto.
+       (struct shmdt_args): Ditto.
+       (struct shmget_args): Ditto.
+
+2012-12-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygserver.h (struct client_request::header_t): Change definition of
+       msglen to use the same structure on 32 and 64 bit.  Add read and write
+       accessors.  Change type of error_code to int.
+       (class client_request): Align accessor methods to above change.
+       * cygserver_ipc.h (ipc_set_proc_info): Use _TYPE64_CLR macros.
+       * winlean.h (_TYPE64_CLR): New macro.
+       (_TYPE64_SET): Ditto.
+       * include/cygwin/msg.h (struct _ts32): Define on 64 bit in _KERNEL mode.
+       (struct _msqid_ds32): Ditto.  Add comment to explain why.
+       * include/cygwin/sysproto.h: Enforce 4 byte alignment on all structs.
+       (struct msgctl_args): Change definition to use the same structure on
+       32 and 64 bit.
+       (struct msgrcv_args): Ditto.
+       (struct msgsnd_args): Ditto.
+
+2012-12-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * shm.cc (fixup_shms_after_fork): Fix initialization of local variable
+       parent.
+
+2012-12-04  Corinna Vinschen  <corinna@vinschen.de>
+
+       * winlean.h (_TYPE64): Define.
+       * cygserver_ipc.h (struct proc): Rearrange to use same structure on
+       32 and 64 bit.  Add member is_64bit.
+       (ipc_set_proc_info): Change accordingly.
+
+2012-12-04  Kai Tietz  <ktietz@redhat.com>
+
+       * child_info.h (child_info): Re-type magic to DWORD.
+
+2012-12-03  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygtls.h (CYGTLS_PADSIZE): Change comment noting alignment has to
+       be 16 bytes on x86_64.
+
+2012-12-03  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in: Add rule to build cygwin.sc dynamically using the
+       target compiler.
+       * cygwin.sc.in: Rename from cygwin.sc.  Make OUTPUT_FORMAT and
+       SEARCH_DIR dependent on target CPU.  Add extra alignment and .xdata
+       section on x86_64.  Keep up with latest dwarf debug section changes.
+
+2012-11-29  Corinna Vinschen  <corinna@vinschen.de>
+
+       * miscfuncs.cc (thread_wrapper): Use PVOID instead of VOID *.
+       Fix stack alignment before calling VirtualFree.  Fix comments.
+
+2012-11-28  Corinna Vinschen  <corinna@vinschen.de>
+
+       * autoload.cc (wsock_init): Drop vendor info debug printout.  It's
+       undefined since Wsock version 2.
+
+2012-11-28  Corinna Vinschen  <corinna@vinschen.de>
+
+       * autoload.cc: Extend leading comment to describe the 64 bit
+       implementation as well.
+       (LoadDLLprime): Define for x86_64.
+       (LoadDLLfuncEx3): Ditto.
+       (dll_func_load): Ditto.
+       (struct dll_info): Use target-agnostic type for load_state.
+       (struct func_info): Add func_addr member on x86_64.
+       (two_addr_t): New type to be twice the size of an address on either
+       target.
+       (union retchain): Use target-agnostic type for low and high,
+       use two_addr_t as type for ll member.
+       (std_dll_init): Define as SYSV ABI function on x86_64.  Explain why.
+       Change return type to two_addr_t.  Add casts as necessary.  Convert
+       assembler code to tweak return address into C code.
+       (wsock_init): Ditto.  Drop leading underscore in LoadDLLprime
+       macro call on x86_64.
+       (GetAdaptersAddresses): Define using LoadDLLfunc since it's not called
+       on pre-XP anyway.
+       (AttachConsole): Don't define on x86_64.
+       (GetModuleHandleExW): Ditto.
+       (GetSystemWow64DirectoryW): Ditto.
+       (GetVolumePathNamesForVolumeNameW): Ditto.
+
+2012-11-22  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/sys/strace.h: Include sys/types.h for pid_t.
+
+2012-11-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygtls.h (CYGTLS_PADSIZE): Define for 64 bit.  Add FIXME comment.
+       * profil.c: Replace usage of network types with types as documented
+       in Linux, throughout.
+       (get_thrpc): Fix access to instruction pointer for x86_64.
+       * profil.h: Include stdin.t.h.  Replace usage of network types with
+       types as documented in Linux, throughout.
+       * config/x86_64/profile.h (mcount): Use unsigned long rather than
+       __uintptr_t.
+
+2012-11-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygmalloc.h (dlmalloc): Change unsigned in declaration to size_t.
+       (dlrealloc): Ditto.
+       * wait.cc (wait4): Cast second parameter in proc_subproc call to
+       uintptr_t.
+
+2012-11-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * thread.cc (verifyable_object_isvalid): Temporarily define as
+       non-inline on x86_64 to workaround compiler bug.
+
+2012-11-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_netdrive.cc: Use UINT32_MAX rather than UINT_MAX to make
+       absolutely clear that we mean the 32 bit maximum.
+       * fhandler_socket.cc: Ditto.
+       * pinfo.cc: Ditto with INT32_MAX.
+       * select.cc (fd_mask): Drop gratuitious definition.
+       (sizeof_fd_set): Cast to size_t.
+       * shared.cc (pround): Cast to ptrdiff_t.
+       * strace.cc (strace::activate): Fix format string.
+       (strace::write_childpid): Take pid_t as parameter.
+       * include/sys/strace.h (strace::write_childpid): Change declaration
+       accordingly.
+       * sync.cc (muto::init): Cast in call to InterlockedExchangePointer to
+       make compiler happy.
+       * sync.h (class muto): De-const name.
+       * syslog.cc (try_connect_syslogd): Take size_t as third argument.
+       (vsyslog): Convert len to size_t.
+       * thread.cc: Use {U}INT32_MAX rather than {U}LONG_MAX.  Througout change
+       types used in Windows calls to matching Windows types.
+       (pthread::cancel): Fix access to instruction pointer for x86_64.
+       (pthread_attr_getstack): Cast to ptrdiff_t for pointer arithmetic.
+       * thread.h: Throughout convert 'long' types to uint32_t or LONG.
+
+2012-11-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/cygwin/acl.h (struct __acl32): Drop.  Use struct acl or
+       aclent_t throughout instead.
+       * sec_acl.cc (aclcheck32): Mark currently unused variables as unused.
+       (lacl32): Disable on x86_64.
+       (acl): Alias to acl32 on x86_64.
+       (facl): Alias to facl32 on x86_64.
+       (aclcheck): Alias to aclcheck32 on x86_64.
+       (aclsort): Alias to aclsort32 on x86_64.
+       (acltomode): Alias to acltomode32 on x86_64.
+       (aclfrommode): Alias to aclfrommode32 on x86_64.
+       (acltopbits): Alias to acltopbits32 on x86_64.
+       (aclfrompbits): Alias to aclfrompbits32 on x86_64.
+       (acltotext): Alias to acltotext32 on x86_64.
+       (aclfromtext): Alias to aclfromtext32 on x86_64.
+       * resource.cc (getrlimit): Use correct cast to rlim_t rather than DWORD.
+       * sched.cc (sched_setparam): Drop ThreadPriority and all code setting
+       it.
+
+2012-11-15  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_process.cc (format_process_stat): Add comment to explain
+       the WOW64 problems concerning the BasePriority value.  Fix format
+       string in __small_sprintf call.
+       * ntdll.h: Mark more native structures as tested on 64 bit.
+       (enum _EVENT_TYPE): Drop definition.
+       (enum _TIMER_TYPE): Ditto.
+       (enum _SECTION_INHERIT): Drop __MINGW64_VERSION_MAJOR guard.
+
+2012-11-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * ntdll.h: Mark more native structures as tested on 64 bit.
+       (struct _FILE_BOTH_DIR_INFORMATION): Rename from
+       _FILE_BOTH_DIRECTORY_INFORMATION as per WDK documentation.
+       * fhandler_disk_file.cc: Accommodate aforementioned structure name
+       change.
+       * path.cc: Ditto.
+
+2012-11-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.h (class fcwd_access_t): Remove wrong alignment attribute from
+       Buffer member of FAST_CWD_OLD structure.  Add comment that everything
+       has been tested.
+       * ntdll.h: Mark more native structures as tested on 64 bit.
+
+2012-11-12  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.h (class fcwd_access_t): Add alignment attribute to Buffer
+       member of FAST_CWD_* structures to work on 64 bit.
+       * path.cc (symlink_info::check_shortcut): Add cast to avoid compiler
+       warning.
+       (cygwin_conv_path_list): Drop ununsed variable.
+       (peek32): Define with int32_t cast on 64 bit to allow easier fetching
+       of instruction pointer relative addresses.
+       (find_fast_cwd_pointer): Add new implementation for x86_64.
+       Tweak a comment in 32 bit version.
+
+2012-11-12  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dlfcn.cc (dlopen): Change cast to accommodate type change in ntdll.h
+       * fhandler_process.cc (thread_info::thread_info): Change type of local
+       variable size to ULONG to match NtQuerySystemInformation call.
+       Add cast to avoid compiler warnings.
+       (get_process_state): Add cast to avoid compiler warnings.  Accommodate
+       name change of NextEntryOffset member of PSYSTEM_PROCESS_INFORMATION
+       structure.
+       * mmap.cc: Add casts to avoid compiler warnings.
+       (mlock): Change type of local variables min and max to match
+       GetProcessWorkingSetSize call.
+       * nlsfuncs.cc (__collate_range_cmp): Add casts to avoid compiler
+       warnings.
+       * ntdll.h: Drop accommodations for Mingw32.  Fix a couple of formatting
+       glitches.  Add a comment to all structures explicitely tested on 64 bit.
+       (SYSTEM_INFORMATION_CLASS): Change SystemProcessesAndThreadsInformation
+       to SystemProcessInformation and SystemProcessorTimes to
+       SystemProcessorPerformanceInformation to match MSDN.
+       (SYSTEM_BASIC_INFORMATION): Fix member types to match 64 bit.
+       (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION): Rename from
+       SYSTEM_PROCESSOR_TIMES to use official name from MSDN.  Accommodate
+       throughout.  Drop unneeded align attribute.
+       (VM_COUNTERS): Fix member types to match 64 bit.
+       (SYSTEM_PROCESS_INFORMATION): Rename from SYSTEM_PROCESSES to use
+       official name from MSDN.  Fix member types to match 64 bit.  Change
+       member names to match MSDN and Mingw64.  Accommodate throughout.
+       (IO_STATUS_BLOCK): Change to use MSDN definition.
+       (SYSTEM_TIMEOFDAY_INFORMATION): Rename from
+       SYSTEM_TIME_OF_DAY_INFORMATION to use official name from MSDN.
+       Accommodate throughout.  Add Reserved1 area per MSDN.
+       (LDR_DATA_TABLE_ENTRY): Add comment for future reference.  Change
+       type of LoadCount to USHORT.
+       (PEB_LDR_DATA): Change type of Initialized to BOOLEAN.  Add comment for
+       future reference.
+       (PEB): Fix member types to match 64 bit.
+       (GDI_TEB_BATCH): New type.
+       (TEB): Fix member types to match 64 bit.
+       (PROCESS_BASIC_INFORMATION): Ditto.
+       (MEMORY_WORKING_SET_LIST): Ditto.
+       (SharedUserData): Change comment to note the fact that the address
+       is valid on 32 and 64 bit.
+       * pinfo.cc (winpids::enum_processes): Add cast to avoid compiler
+       warnings.
+       * select.cc (pipe_data_available): Add braces in initalization of an
+       IO_STATUS_BLOCK to match new definition.
+       * wincap.h (class wincapc): Change type of wow64 to ULONG_PTR to match
+       MSDN description.
+       (wincapc::is_wow64): Convert return value explicitely to bool.
+       * wow64.cc (wow64_test_for_64bit_parent): Change type of wow64 to
+       ULONG_PTR to match MSDN description.  Add a cast to avoid compiler
+       warning.
+       * regex/engine.c: Avoid compiler warnings about unused and potentially
+       uninitialized variables.
+       * regex/regcomp.c: Ditto.  Drop unnecessary definition of LCID.
+
+2012-11-11  Corinna Vinschen  <corinna@vinschen.de>
+
+       * pinfo.cc (_pinfo::commune_request): Accommodate the fact that LONG_MAX
+       does not match sizeof LONG.
+
+2012-11-09  Corinna Vinschen  <corinna@vinschen.de>
+
+       * miscfuncs.cc (case_folded_lower): Change to unsigned char to avoid
+       compiler warnings.
+       (case_folded_upper): Ditto.
+       (thread_wrapper): Add assembler code for x86_64.
+       * winsup.h (case_folded_lower): Change to unsigned char.
+       (case_folded_upper): Ditto.
+       (cyg_tolower): Add cast to avoid compiler warnings.
+       (cyg_toupper): Add cast to avoid compiler warnings.
+
+2012-11-08  Corinna Vinschen  <corinna@vinschen.de>
+
+       * tty.h (class tty): Store from_master and to_master HANDLEs in
+       unions to make sure the storage is 64 bit compatible.  Add comment to
+       explain why.
+       (from_master): Convert to read accessor method.
+       (to_master): Ditto.
+       (set_from_master): New method to store HANDLE value 64 bit clean.
+       (set_to_master): Ditto.
+       * fhandler_tty.cc: Fix debug printfs to work in 64 bit mode as well.
+       Change usage of from_master and to_master throughout to accommodate
+       aforementioned change.
+       * fhandler_termios.cc (fhandler_termios::ioctl): Add cast to avoid
+       compiler warning.
+
+2012-11-08  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.h (struct user_heap_info): Change type of chunk to SIZE_T.
+       Remove unused slop member.
+       * fork.cc (fork): Rename esp to stackp.  Add 64 bit asm expression to
+       fetch stack pointer.
+       (child_copy): Use platform independent types.
+       * heap.cc (eval_start_address): Add comment. Disable 3GB code on 64 bit.
+       (eval_initial_heap_size): Use platform independent types.  Fix debug
+       printf format strings.
+       (sbrk): Add comment.  Change argument type according to newlib
+       definition.  Use platform independent types.  Drop unneeded else and
+       move comment to the right spot.
+       * hookapi.cc (PEHeaderFromHModule): Return PVOID.  Add comment to
+       explain why.  Add bool parameter to return if target executable is
+       64 bit or not.
+       (rvadelta_get): New inline function to fetch section address platform
+       independent.
+       (rvadelta32, rvadelta64): Platform dependent wrappers.
+       (rvadelta): Change to macro calling the platform dependent rvadelta
+       wrappers.
+       (putmem): Define platform dependent THUNK_FUNC_TYPE and use throughout.
+       (RedirectIAT): Add comment.
+       (get_export): Add comment.
+       (find_first_notloaded_dll): Allow to fetch information in a platform
+       and target independent way.
+       (hook_or_detect_cygwin): Ditto.  Recognize the cyg64win1.dll file name
+       as well.
+       * kernel32.cc (CreateFileMappingW): Cast to avoid compiler warning.
+
+       * fhandler.h (class fhandler_dev_tape): Replace mt_evt with an
+       OVERLAPPED structure ov.
+       * mtinfo.h (class mtinfo_part): Define members as int32_t rather than
+       long.  Change member function declarations accordingly.
+       (class mtinfo_drive): Ditto.  Store OVERLAPPED pointer rather than
+       holding the full structure.  Add comment to explain why.
+       * fhandler_tape.cc: Accommodate above changes throughout.
+
+2012-11-08  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_socket.cc (fhandler_socket::ioctl): Don't use __ms_u_long
+       directly.  Rather only use it on 64 bit.  Add comment to explain the
+       problem.
+
+2012-11-07  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_socket.cc: Throughout, fix casts to work on 64 bit.  Move
+       calls to pthread_testcancel to upper syscall level for consistency.
+       Move read, readv, write, and writev methods to keep together with
+       equivalent recv and send methods.
+       (fhandler_socket::read): Compute WSAMSG buffer on 64 bit to overcome
+       type restriction of WSABUF len member.
+       (fhandler_socket::recvfrom): Ditto.
+       (fhandler_socket::write): Ditto.
+       (fhandler_socket::sendto): Ditto.
+       (fhandler_socket::sendmsg): Restructure for readability.
+       * net.cc (cygwin_sendto): Call pthread_testcancel here.
+       (cygwin_recvfrom): Ditto.
+       (cygwin_connect): Ditto.
+       (cygwin_accept): Ditto.
+       (cygwin_recv): Ditto.
+       (cygwin_send): Ditto.
+       (cygwin_recvmsg): Ditto.
+       (cygwin_sendmsg): Ditto.
+
+2012-11-07  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_process.cc (heap_info::heap_info): Add comment to explain a
+       TODO item.
+
+2012-11-07  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_procsysvipc.cc (format_procsysvipc_msg): Fix printf format
+       string for 32 bit as well.
+
+2012-11-07  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_procsysvipc.cc (format_procsysvipc_msg): Fix printf format
+       string for 64 bit.
+       * fhandler_registry.cc (fhandler_registry::readdir): Fix cast.
+       * fhandler_serial.cc (ibuf): Avoid compiler warning.
+       * include/cygwin/ipc.h: Include stdint.h.
+       * include/cygwin/msg.h (msgqnum_t): Define as uint32_t.
+       (msglen_t): Ditto.
+       (struct msginfo): Convert all long members to int32_t.
+       (struct msg_info): Ditto.
+       * include/cygwin/sem.h (struct seminfo): Ditto.
+       * include/cygwin/shm.h (shmatt_t): Define as uint32_t.
+       (struct shmid_ds): Define shm_segsz as uint32_t.
+       (struct shminfo): Convert all long members to int32_t.
+
+2012-11-06  Corinna Vinschen  <corinna@vinschen.de>
+
+       * ntdll.h (PDI_WOW64_MODULES): Define.
+       (struct _DEBUG_BUFFER): Fix definition to work on 32 and 64 bit.
+       (struct _DEBUG_HEAP_INFORMATION): Ditto.
+       (struct _DEBUG_HEAP_BLOCK): Ditto.
+
+2012-11-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fhandler_process.cc: Fix debug printf calls to be type safe.
+       Add casts to avoid compiler warnings.
+       (get_mem_values): Avoid using ULONG_MAX since it's NOT matching
+       ULONG on 64 bit.
+       * fhandler_procnet.cc (fhandler_procnet::open): Fix syscall_printf call
+       to be type safe.
+       (format_procnet_ifinet6): Add cast to avoid compiler warnings.
+       * ntdll.h (struct _DEBUG_HEAP_BLOCK): Change Address to ULONG_PTR.
+
+       * include/bits/wordsize.h: Fix __WORDSIZE definition for x86_64.
+       Add __WORDSIZE_COMPAT32 as on Linux.
+       * include/inttypes.h: Include bits/wordsize.h.  Use __WORDSIZE check
+       where appropriate.
+       * include/limits.h: Include bits/wordsize.h.
+       (CHAR_BIT): Change definition to rely on default
+       compiler definition.
+       (LONG_BIT): Ditto.
+       (WORD_BIT): Ditto.
+       (__LONG_MAX__): Use __WORDSIZE check.
+       (RTSIG_MAX): Ditto.
+       * include/stdint.h: Include bits/wordsize.h.  Use __WORDSIZE check
+       where appropriate.
+       * include/cygwin/signal.h: Ditto.
+       * include/cygwin/types.h: Ditto.
+
+       * include/asm/byteorder.h (__ntohl): Use bswap instruction, available
+       since i486.
+       (__ntohs): Fix constraint to work on 64 bit CPU as well.
+
+2012-11-05  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cpuid.h (can_set_flag): Implement for x86_64.
+       * fhandler.h (class fhandler_dev_raw): Define devbuf members taking
+       numerical values as DWORD, rather than size_t.
+       * fhandler_dsp.cc: Fix debug printf calls to be type safe.
+       (waveOut_callback): Align parameter types to latest MSDN description.
+       (waveIn_callback): Ditto.
+       (fhandler_dev_dsp::Audio_out::start): Change casts in call to
+       waveOutOpen according to MSDN.
+       (fhandler_dev_dsp::Audio_out::parsewav): Fix a cast.
+       (fhandler_dev_dsp::Audio_in::start): Change casts in call to
+       waveInOpen according to MSDN.
+       * fhandler_floppy.cc: Fix debug printf calls to be type safe.
+       (fhandler_dev_floppy::ioctl): Add casts to be on the safe side.
+       * fhandler_proc.cc: Fix debug printf calls to be type safe.
+
+2012-10-31  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygthread.cc: Fix usage of %p in debug printfs, throughout.
+       * dcrt0.cc: Ditto.
+       * dtable.cc: Ditto.
+       * errno.cc: Ditto.
+       * exceptions.cc: Ditto.
+       * fhandler.cc: Ditto.
+       * fhandler_console.cc: Ditto.
+       * fhandler_disk_file.cc: Ditto.
+
+       * fhandler_clipboard.cc (cygnativeformat): Define as UINT.
+       (fhandler_dev_clipboard::read): Ditto for local format variable.
+       Use casts to compare off_t with size_t value.
+       * fhandler_console.cc (fhandler_console::ioctl): Avoid compiler
+       warnings.
+       * fhandler_disk_file.cc (fhandler_disk_file::opendir): Fix cast.
+       * include/sys/dirent.h (struct __DIR): Define __d_internal as uintptr_t,
+       rather than unsigned int.
+
+2012-10-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * fcntl.cc (fcntl64): Make arg an intptr_t.  Add comment to explain a
+       potential type problem.  Fix syscall_printf.
+       (_fcntl): Make arg an intptr_t.
+       * fhandler.cc (fhandler_base::fcntl): Ditto.
+       * fhandler_socket.cc (fhandler_socket::fcntl): Ditto.
+       * fhandler.h: Align declarations.
+
+2012-10-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dtable.cc: Use %y rather than 0x%x.
+       * exceptions.cc: Ditto.
+
+2012-10-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * smallprint.cc (__small_vsprintf): Add 'y' and 'Y' conversion.
+       Add description to comment.
+       (__small_vswprintf): Align behaviour to __small_vsprintf.
+
+2012-10-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * external.cc (get_cygdrive_info): Return uintptr_t rather than DWORD.
+       (check_ntsec): Return bool.
+       (cygwin_internal): Return uintptr_t.  Accommodate throughout.
+       * include/sys/cygwin.h (cygwin_internal): Align declaration.
+
+2012-10-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/cygwin/signal.h (NSIG): Define differently for x86_64 and
+       i686.  Change FIXME comment accordingly.
+       (SIGRTMAX): Define in terms of NSIG.
+       * include/limits.h (RTSIG_MAX): Define for x86_64.
+       * strsig.cc (__signals_common): Hold all signals available on both
+       platforms.
+       (__signals): Define differently for x86_64 and i686.
+
+2012-10-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dll_init.cc: Fix debug printf to be type-safe.
+       * dtable.cc: Ditto.
+
+2012-10-26  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygtls.cc (_cygtls::remove): Fix debug printf to be type-safe.
+       * dcrt0.cc: Ditto, throughout.
+       * include/sys/cygwin.h (struct per_process): Define magic_biscuit,
+       dll_major and dll_minor as uint32_t.
+
+2012-10-26  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.h (struct init_cygheap): Define sthreads as uint32_t.
+
+2012-10-26  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.cc: Fix debug printfs to work in 64 bit mode as well,
+       throughout.
+       (nthreads): Define as uint32_t to make always 4 byte.  Accommodate
+       throughout.
+       (threadlist_ix): Ditto.
+
+2012-10-26  Corinna Vinschen  <corinna@vinschen.de>
+
+       * exception.h (stackdump): Change first parameter to PUINT_PTR.
+       * exceptions.cc: Define cpu specific macros _GR, _AFMT and _ADDR.
+       Use throughout to avoid ifdef's.  Fix debug printfs to work in
+       64 bit mode as well, throughout.
+       (status_info): Define member code as NTSTATUS.  Add casts where
+       necessary throughout.
+       (dump_exception): Dump all x86_64 registers if building for it.
+       (class stack_info): Define dummy_frame as PUINT_PTR.
+       (stack_info::init): Change first parameter to PUINT_PTR.  Rename
+       ebp to framep for CPU independent naming.  Drop debp macro.
+       (stack_info::walk): Rename ebp to framep for CPU independent naming.
+       Disable WOW64 hack in 64 bit mode.
+       (stackdump): Change first parameter to PUINT_PTR.  Rename ebp to framep
+       for CPU independent naming.
+       (_cygtls::inside_kernel): Ignore system_wow64_directory on 64 bit.
+       (rtl_unwind): Redefine for x86_64 cpu.
+       (_except_list): Drop redundant definition.
+       (_cygtls::copy_context): Just use __COPY_CONTEXT_SIZE.
+       * sigproc.cc (_cygtls::signal_exit): Conditionalize stackdump call per
+       cpu.
+       * smallprint.cc (__small_vsprintf): Fix up for 64 bit.  Handle 'l' size
+       modifier in 'd', 'o', 'u', 'x' conversion to print "long" values on a
+       per cpu base.  Add 'O' conversion.  Change comment accrdingly.
+       * include/cygwin/signal.h (struct _uc_fpxreg): Define for 64 bit.
+       (struct _uc_xmmreg): Ditto.
+       (struct _fpstate): Ditto.
+       (struct ucontext): Ditto.
+       (struct _uc_fpreg): Define for 32 bit.
+       (struct _fpstate): Use struct _uc_fpreg for _st.  Use explicit sized
+       types.
+       (struct ucontext): Use explicit sized types.
+       (__COPY_CONTEXT_SIZE): Cast safely.
+       (sigset_t): Define as __uint64_t on 64 bit.  Add FIXME comment in 32
+       bit case.
+
+2012-10-24  Corinna Vinschen  <corinna@vinschen.de>
+
+       * smallprint.cc (rnarg): Make type-safe.
+       (rnargLL): Ditto.
+       (__small_vsprintf): Add comment to document meaning of each possible
+       conversion.  Fix 'p' conversion for 64 bit.
+
+2012-10-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * globals.cc: Redefine _RDATA as "const", if not already defined.
+       Apply extern "C" linkage to the R/O UNICODE_STRINGs and cygwin_props.
+       Change comments to explain new method.
+       * winsup.h (_RDATA): Define as empty string and only if including
+       globals.h.
+       (cygwin_finished_initializing): Drop redundant declaration.
+
+2012-10-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dtable.cc (dtable::get_debugger_info): Raise size of buf to allow
+       64 bit values.  Call sprintf in a type-safe manner.
+
+2012-10-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dll_init.cc (reserve_at): Use PVOID rather than DWORD as type for
+       pointer parameters and return type.
+       (release_at): Ditto.
+       (dll_list::load_after_fork_impl): Fix format strings.  Call reserve_at
+       without casts to DWORD.
+       (struct dllcrt0_info): Change type of res to PVOID.
+       (dll_dllcrt0): Return PVOID rather than int.
+       (dll_dllcrt0_1): Accommodate type change of dllcrt0_info::res.
+       (dll_noncygwin_dllcrt0): Disable on 64 bit.  Add a cast for 32 bit.
+       * dll_init.h (struct pefile): Drop 32 bit decoration from Windows
+       types.
+       * ntdll.h (struct _DEBUG_HEAP_INFORMATION): Define Base as UINT_PTR.
+       (struct _DEBUG_MODULE_INFORMATION): Define Reserved and Base as
+       UINT_PTR.
+       * winsup.h (dll_dllcrt0): Declare as PVOID.
+       (dll_noncygwin_dllcrt0): Don't declare on 64 bit.
+       * include/cygwin/cygwin_dll.h (cygwin_attach_dll): Declare as PVOID.
+       (cygwin_detach_dll): Declare with PVOID parameter.
+       (dll_index): Declare as PVOID.
+       (_cygwin_dll_entry): Accommodate type change of dll_index.
+       * lib/crt0.h (dll_dllcrt0): Declare as PVOID.
+       * lib/cygwin_attach_dll.c (cygwin_attach_dll): Define PVOID.
+
+2012-10-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dcrt0.cc (init_windows_system_directory): Disable setting
+       system_wow64_directory{_length} on 64 bit.
+       (dll_crt0_0): Disable WOW64-specific code on 64 bit.
+       (_dll_crt0): Ditto.
+       * globals.cc (system_wow64_directory): Don't define on 64 bit.
+       (system_wow64_directory_length): Ditto.
+       * wincap.cc (wincapc::init): On 64 bit, always set wow64 to 0 and
+       related bool values to false.
+       * wow64.cc: Disable entire code on 64 bit.
+       * wow64.h: Ditto.
+
+2012-10-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygtls.h (__stack_t): Define as uintptr_t.
+       * dcrt0.cc (child_info_fork::alloc_stack): Conditionalize assembler
+       code on a per-CPU base.  Rename esp to stackp.
+       (get_cygwin_startup_info): Cast pointers to uintptr_t in
+       multiple_cygwin_problem call.  Minor formatting change.
+       (_dll_crt0): Conditionalize assembler code on a per-CPU base.
+       (multiple_cygwin_problem): Change parameters from unsigned to uintptr_t.
+       * winsup.h (multiple_cygwin_problem): Change declaration accordingly.
+       * pinfo.h (pinfo::reattach): Cast 2nd argument in proc_subproc call
+       to uintptr_t.
+       (pinfo::remember): Ditto.
+       * sigproc.cc (proc_subproc): Change 2nd parameter to uintptr_t to allow
+       pointer values.
+       * sigproc.h (proc_subproc): Change declaration accordingly.
+       * include/sys/cygwin.h (per_process_overwrite): Use offsetof to compute
+       value.
+
+2012-10-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.cc (N0): Remove.
+       (N): Ditto.
+       (to_cmalloc): Use offsetof to compute value.
+       (tocygheap): Use offsetof to compute value.
+
+2012-10-22  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygtls.h (_tlsbase): Define for __x86_64__.
+       (_tlstop): Ditto.
+       * exception.h (exception_list): Ditto.
+
+2012-10-22  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygheap.cc (to_cmalloc): Fix pointer cast.
+       (nextpage): Ditto.  Base definition on roundup2.
+       (allocsize): Cast to SIZE_T.
+       (_csbrk): Drop granmask.  Define adjsbs SIZE_T as 2nd parameter to
+       VirtualAlloc.
+       (tocygheap): Fix pointer cast.
+
+2012-10-18  Corinna Vinschen  <corinna@vinschen.de>
+
+       Avoid various type ambiguity problems showing up in the 64 bit case:
+       * cygheap.h (cygheap_user::set_sid): Convert to void.
+       (cygheap_user::set_saved_sid): Ditto.
+       * devices.h (struct device): Drop operator int& and DWORD& entirely.
+       Throughout, use dev_t or fh_devices instead.
+       * devices.cc: Regenerate.
+       * fhandler.h (class fhandler_base): Convert _refcnt member to LONG.
+       (fhandler_base::inc_refcnt): Return LONG.
+       (fhandler_base::dec_refcnt): Ditto.
+       (fhandler_base::get_major): Return _major_t.
+       (fhandler_base::get_minor): Return _minor_t.
+       (fhandler_base::get_unit): Delete.  Throughout, use get_minor instead
+       of get_unit.
+       (fhandler_socket::get_socket): Use SOCKET rather than int.  Only define
+       if __INSIDE_CYGWIN_NET__ is defined.
+       (fhandler_pty_slave::get_unit): Drop declaration.
+       * fhandler_procnet.cc: Include Windows headers early.
+       * fhandler_socket.cc: Ditto.
+       * fhandler_tty.cc (fhandler_pty_slave::get_unit): Remove.
+       * path.h (path_conv::get_device): Rename from get_devn and change return
+       type to dev_t.  Accommodate throughout.
+       (path_conv::get_unitn): Remove unused method.
+       * pinfo.h (class pinfo): Drop operator== for int case.
+       (pinfo::operator!): Define.
+       * poll.cc: Don't define __INSIDE_CYGWIN_NET__.
+       * syscalls.cc (getpgid): Replace use of pinfo::operator== with
+       pinfo::operator!.
+       * tty.h (tty_min::setntty): Convert 2nd parameter to _minor_t.
+       * tty.h (tty_min::getntty): Change return type to dev_t.
+       (tty_min::get_minor): Rename from get_unit.  Change return type to
+       _minor_t.
+
+2012-08-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/mntent.h: Don't include paths.h and don't define macros if
+       _NOMNTENT_MACROS is set.
+
+2012-08-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * advapi32.cc (DuplicateTokenEx): Make ?: expression type-safe.
+       * ntdll.h (KAFFINITY): Don't define if building with Mingw64 headers.
+       * thread.cc: Throughout drop casts in calls to Interlocked functions.
+       * thread.h (class fast_mutex): Ditto.  Define lock_counter as LONG.
+       (class pthread_mutex): Define lock_counter as LONG.
+       (struct MTinterface): Define threadcount as LONG.
+
+2012-08-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * configure.in: Add AC_NO_EXECUTABLES to allow bootstrap.
+       Add x86_64 to allowed cpu types.
+       * configure: Regenerate.
+       * config/x86_64/profile.h: New file.
+
+2012-08-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * thread.cc (semaphore::_fixup_after_fork): Fix Win32 error output in
+       api_fatal call.
+
+2012-08-14  Corinna Vinschen  <corinna@vinschen.de>
+
+       * mkvers.sh: Drop reference to w32api includes.
+
+2012-08-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * include/cygwin/stat.h (struct __stat64): Drop entirely in favor of
+       struct stat.  Accommodate throughout Cygwin.
+       * include/cygwin/types.h: Throughout, drop current, internal types
+       used since Cygwin 1.5 with the base type they have been used for.
+       Throughout, define types based on bitsize-specific types where
+       appropriate.  Accommodate throughout Cygwin.
+       * include/sys/cygwin.h: Drop __uid32_t and __gid32_t in favor of
+       uid_t and gid_t.  Define uid/gid types based on bitsize-specific types.
+       (struct external_pinfo): Accommodate above change.
+       * cygtls.h (struct _local_storage): Drop unused members grp and
+       namearray,
+       * tlsoffsets.h: Regenerate.
+       * devices.h (_dev_t): Drop definition.  Use dev_t throughout instead.
+       * devices.cc: Regenerate.
+
+       Probably temporary patch to drop unneeded functionality on x86_64:
+       * fcntl.cc (_fcntl): Alias to fcntl64 on x86_64.
+       * glob.cc (CYGWIN_gl_stat): Simplify on x86_64.
+       * grp.cc (grp32togrp16): Don't define on x86_64.
+       (getgrgid): Alias to getgrgid32 on x86_64.
+       (getgrnam): Alias to getgrnam32 on x86_64.
+       (getgrent): Alias to getgrent32 on x86_64.
+       (getgroups): Alias to getgroups32 on x86_64.
+       (initgroups): Alias to initgroups32 on x86_64.
+       (setgroups): Alias to setgroups32 on x86_64.
+       * mmap.cc (mmap): Alias to mmap64 on x86_64.
+       * passwd.cc (getpwuid): Alias to getpwuid32 on x86_64.
+       (getpwuid_r): Alias to getpwuid_r32 on x86_64.
+       (getpwduid): Don't define on x86_64.
+       * syscalls.cc (lseek): Alias to lseek64 on x86_64.
+       (_lseek): Alias to lseek64 on x86_64.
+       (chown): Alias to chown32 on x86_64.
+       (lchown): Alias to lchown32 on x86_64.
+       (fchown): Alias to fchown32 on x86_64.
+       (stat64_to_stat32): Don't define on x86_64.
+       (fstat): Alias to fstat64 on x86_64.
+       (_fstat_r): Alias to _fstat64_r on x86_64.
+       (stat): Alias to stat64 on x86_64.
+       (_stat_r): Alias to _stat64_r on x86_64.
+       (lstat): Alias to lstat64 on x86_64.
+       (ftruncate): Alias to ftruncate64 on x86_64.
+       (truncate): Alias to truncate64 on x86_64.
+       (seteuid): Alias to seteuid32 on x86_64.
+       (setuid): Alias to setuid32 on x86_64.
+       (setreuid): Alias to setreuid32 on x86_64.
+       (setegid): Alias to setegid32 on x86_64.
+       (setgid): Alias to setgid32 on x86_64.
+       (setregid): Alias to setregid32 on x86_64.
+       * uinfo.cc (getuid): Alias to getuid32 on x86_64.
+       (getgid): Alias to getgid32 on x86_64.
+       (geteuid): Alias to geteuid32 on x86_64.
+       (getegid): Alias to getegid32 on x86_64.
+       * winsup.h (ILLEGAL_UID16): Don't define on x86_64.
+       (ILLEGAL_GID16): Ditto.
+       (uid16touid32): Don't declare on x86_64.
+       (gid16togid32): Don't declare on x86_64.
+
+2012-08-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (TEST_DLL_NAME): Use -nostdlib flag unconditionally.
+
+2012-08-10  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygwin.sc: Add default w32api search dirs.
+       * Makefile.in (DLL_IMPORTS); Just use -l syntax.
+       (TEST_DLL_NAME): Drop DLL_IMPORTS dependency.
+
index 56c910a699c872982e5972b28765bcda5a3efa89..0c387e7176a952496f7360cef4650e36757c6b27 100644 (file)
@@ -31,6 +31,7 @@ export CCWRAP_DIRAFTER_HEADERS:=@windows_headers@
 
 VPATH+=$(CONFIG_DIR) $(srcdir)/regex $(srcdir)/lib $(srcdir)/libc
 
+target_cpu:=@target_cpu@
 target_alias:=@target_alias@
 build_alias:=@build_alias@
 host_alias:=@host_alias@
@@ -76,6 +77,9 @@ MT_SAFE:=@MT_SAFE@
 DEFS:=@DEFS@
 CCEXTRA=
 COMMON_CFLAGS=-MMD ${$(*F)_CFLAGS} -Werror -fmerge-constants -ftracer $(CCEXTRA)
+ifeq ($(target_cpu),x86_64)
+COMMON_CFLAGS+=-mcmodel=small
+endif
 COMPILE.cc+=${COMMON_CFLAGS} -mno-use-libstdc-wrappers
 COMPILE.c+=${COMMON_CFLAGS}
 
@@ -110,23 +114,26 @@ RUNTESTFLAGS =
 # native rebuilding issues (we don't want the build tools to see a partially
 # built cygwin.dll and attempt to use it instead of the old one).
 
-DLL_NAME:=cygwin1.dll
-TEST_DLL_NAME:=cygwin0.dll
+DLL_NAME:=@DLL_NAME@
+TEST_DLL_NAME:=${patsubst %1.dll,%0.dll,@DLL_NAME@}
 TEST_LIB_NAME:=libcygwin0.a
 STATIC_LIB_NAME:=libcygwin_s.a
+DIN_FILE=@DIN_FILE@
 DEF_FILE:=cygwin.def
+TLSOFFSETS_H:=@TLSOFFSETS_H@
 DLL_ENTRY:=@DLL_ENTRY@
 
 LIBGMON_A:=libgmon.a
 CYGWIN_START:=crt0.o
 GMON_START:=gcrt0.o
 
-toolopts:=--ar=${AR} --as=${AS} --nm=${NM} --objcopy=${OBJCOPY} 
+toolopts:=--cpu=${target_cpu} --ar=${AR} --as=${AS} --nm=${NM} --objcopy=${OBJCOPY}
 speclib=\
     ${srcdir}/speclib ${toolopts} \
        --exclude='cygwin' \
        --exclude='(?i:dll)' \
        --exclude='reloc' \
+       --exclude='^main$$' \
        --exclude='^_main$$' \
        $^
 
@@ -143,7 +150,7 @@ EXTRA_DLL_OFILES:=${addsuffix .o,${basename ${notdir ${wildcard $(CONFIG_DIR)/*.
 
 EXTRA_OFILES:=
 
-MALLOC_OFILES:=@MALLOC_OFILES@
+MALLOC_OFILES:=malloc.o
 
 DLL_IMPORTS:=${shell $(CC) -print-file-name=w32api/libkernel32.a} ${shell $(CC) -print-file-name=w32api/libntdll.a}
 
@@ -193,6 +200,9 @@ endif #PREPROCESS
 
 GMON_OFILES:=gmon.o mcount.o profil.o
 
+ifeq ($(target_cpu),x86_64)
+NEW_FUNCTIONS:=
+else
 NEW_FUNCTIONS:=$(addprefix --replace=,\
        acl=_acl32 \
        aclcheck=_aclcheck32 \
@@ -245,6 +255,7 @@ NEW_FUNCTIONS:=$(addprefix --replace=,\
        tmpfile=_tmpfile64 \
        truncate=_truncate64 \
 )
+endif
 
 API_VER:=$(srcdir)/include/cygwin/version.h
 
@@ -390,20 +401,20 @@ uninstall-headers:
 uninstall-man:
        cd $(srcdir); \
        for i in `find . -type f -name '*.2'`; do \
-           rm -f $(tooldir)/man/man2/`basename $$i` ; \
+           rm -f $(DESTDIR)$(mandir)/man2/`basename $$i` ; \
        done; \
        for i in `find . -type f -name '*.3'`; do \
-           rm -f $(tooldir)/man/man3/`basename $$i` ; \
+           rm -f $(DESTDIR)$(mandir)/man3/`basename $$i` ; \
        done; \
        for i in `find . -type f -name '*.5'`; do \
-           rm -f $(tooldir)/man/man5/`basename $$i` ; \
+           rm -f $(DESTDIR)$(mandir)/man5/`basename $$i` ; \
        done; \
        for i in `find . -type f -name '*.7'`; do \
-           rm -f $(tooldir)/man/man7/`basename $$i` ; \
+           rm -f $(DESTDIR)$(mandir)/man7/`basename $$i` ; \
        done
 
 clean:
-       -rm -f *.o *.dll *.dbg *.a *.exp junk *.base version.cc winver_stamp *.exe *.d *stamp* *_magic.h sigfe.s cygwin.def globals.h $(srcdir)/tlsoffsets.h $(srcdir)/devices.cc
+       -rm -f *.o *.dll *.dbg *.a *.exp junk *.base version.cc winver_stamp *.exe *.d *stamp* *_magic.h sigfe.s cygwin.def globals.h $(srcdir)/$(TLSOFFSETS_H) $(srcdir)/devices.cc
        -@$(MAKE) -C ${cygserver_blddir} libclean
 
 maintainer-clean realclean: clean
@@ -411,6 +422,9 @@ maintainer-clean realclean: clean
        @echo "it deletes files that may require special tools to rebuild."
        -rm -fr configure
 
+# Rule to build LDSCRIPT
+$(LDSCRIPT): $(LDSCRIPT).in
+       $(CC) -E - -P < $^ -o $@
 
 # Rule to build cygwin.dll
 $(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg $(DLL_OFILES) $(LIBSERVER) $(LIBC) $(LIBM) $(API_VER) Makefile winver_stamp
@@ -423,8 +437,8 @@ $(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg $(DLL_OFILES) $(LIBSERVER) $(LIBC) $(LIB
        @ln -f $@ new-$(DLL_NAME)
 
 # Rule to build libcygwin.a
-$(LIB_NAME): $(LIBCOS) | $(TEST_DLL_NAME) 
-       ${srcdir}/mkimport ${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a $^
+$(LIB_NAME): $(DEF_FILE) $(LIBCOS) | $(TEST_DLL_NAME)
+       ${srcdir}/mkimport ${toolopts} ${NEW_FUNCTIONS} $@ cygdll.a $(wordlist 2,99,$^)
 
 ${STATIC_LIB_NAME}: mkstatic ${TEST_DLL_NAME}
        perl -d $< -x ${EXCLUDE_STATIC_OFILES} --library=${LIBC} --library=${LIBM} --ar=${AR} $@ cygwin.map
@@ -446,7 +460,7 @@ dll_ofiles: $(DLL_OFILES)
 $(LIBGMON_A): $(GMON_OFILES) $(GMON_START)
        $(AR) rcv $(LIBGMON_A) $(GMON_OFILES)
 
-$(API_VER): $(srcdir)/cygwin.din
+$(API_VER): $(srcdir)/$(DIN_FILE)
        @echo Error: Version info is older than DLL API!
 
 version.cc winver.o: winver_stamp
@@ -500,14 +514,14 @@ winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES)
        $(COMPILE.cc) -c -o version.o version.cc && \
        touch $@
 
-Makefile: cygwin.din ${srcdir}/Makefile.in
+Makefile: $(DIN_FILE) ${srcdir}/Makefile.in
        /bin/sh ./config.status
 
-$(DEF_FILE): gendef cygwin.din $(srcdir)/tlsoffsets.h
-       $^ $@ sigfe.s
+$(DEF_FILE): gendef $(DIN_FILE) $(srcdir)/$(TLSOFFSETS_H)
+       $^ $(target_cpu) $@ sigfe.s
 
-$(srcdir)/tlsoffsets.h: gentls_offsets cygtls.h
-       $^ $@ $(COMPILE.cc) -c
+$(srcdir)/$(TLSOFFSETS_H): gentls_offsets cygtls.h
+       $^ $@ @CONFIG_DIR@ $(COMPILE.cc) -c
 
 sigfe.s: $(DEF_FILE)
        @[ -s $@ ] || \
index 5985aa9a19b9076cc61480cdcf82856e9fe1c7f0..b08bdfec570a2eb092120359ee7560802d49e1d9 100644 (file)
@@ -1,7 +1,7 @@
-# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.12.1 -*- Autoconf -*-
+
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
index 3cf8aea11d4830d6f1d5588726a48dc09ec96fea..07d26e710bb14ccd041a23f49b5d22cc2bcff025 100644 (file)
@@ -43,7 +43,7 @@ DuplicateTokenEx (HANDLE tok, DWORD access, LPSECURITY_ATTRIBUTES sec_attr,
   OBJECT_ATTRIBUTES attr =
     { sizeof attr, NULL, NULL,
       (sec_attr && sec_attr->bInheritHandle) ? OBJ_INHERIT : 0U,
-      (sec_attr ? sec_attr->lpSecurityDescriptor : NULL), &sqos };
+      sec_attr ? sec_attr->lpSecurityDescriptor : NULL, &sqos };
   NTSTATUS status = NtDuplicateToken (tok, access, &attr, FALSE, type, new_tok);
   DEFAULT_NTSTATUS_TO_BOOL_RETURN
 }
index 3e61f837f08e2c17ef5bed6753d51bbf222daf70..0c3794269c7cb5eaa51c797c640df1ed8800ac90 100644 (file)
@@ -32,34 +32,60 @@ bool NO_COPY wsock_started;
  *
  * So, immediately following the the call to one of the above routines
  * we have:
- *  DLL info (4 bytes)  Pointer to a block of information concerning
+ *  DLL info (4/8 bytes) Pointer to a block of information concerning
  *                      the DLL (see below).
  *  DLL args (4 bytes)  The number of arguments pushed on the stack by
  *                      the call.  If this is an odd value then this
  *                      is a flag that non-existence of this function
  *                      is not a fatal error
+ *  func addr (8 bytes)  (64 bit ONLY!)
+ *                      Address of the actual Win32 function.  For the
+ *                      reason why this is necessary, see the below
+ *                      description of the load_state.
  *  func name (n bytes)         asciz string containing the name of the function
  *                      to be loaded.
  *
  * The DLL info block consists of the following
- *  load_state (4 bytes) Pointer to a word containing the routine used
+ *  load_state (4/8 bytes) Pointer to a word containing the routine used
  *                      to eventually invoke the function.  Initially
- *                      points to an init function which loads the
- *                      DLL, gets the process's load address,
- *                      changes the contents here to point to the
- *                      function address, and changes the call *(%eax)
- *                      to a jmp func.  If the initialization has been
- *                      done, only the load part is done.
- *  DLL handle (4 bytes) The handle to use when loading the DLL.
+ *                      points to an init function which loads the DLL,
+ *                      gets the process's load address, changes the contents
+ *                      here to point to the function address, and changes
+ *                      the address argument of the initial jmp call.
+ *                      On 64 bit, the jmp is not tweaked directly.  Rather,
+ *                      the address of the Win32 function is stored in the
+ *                      aforementioned Win32 function address slot and fetched
+ *                      there for a jmp *%rax call.  This indirection is
+ *                      necessary to workaround the lack of a jmp opcode with
+ *                      offset values > 32 bit.  If the initialization has
+ *                      been done, only the load part is done.
+ *  DLL handle (4/8 bytes) The handle to use when loading the DLL.
  *  DLL locker (4 bytes) Word to use to avoid multi-thread access during
  *                      initialization.
- *  extra init (4 bytes) Extra initialization function.
+ *  extra init (4/8 bytes) Extra initialization function.
  *  DLL name (n bytes)  asciz string containing the name of the DLL.
  */
 
 /* LoadDLLprime is used to prime the DLL info information, providing an
    additional initialization routine to call prior to calling the first
    function.  */
+#ifdef __x86_64__
+#define LoadDLLprime(dllname, init_also, no_resolve_on_fork) __asm__ ("        \n\
+.ifndef " #dllname "_primed                            \n\
+  .section     .data_cygwin_nocopy,\"w\"               \n\
+  .align       8                                       \n\
+."#dllname "_info:                                     \n\
+  .quad                _std_dll_init                           \n\
+  .quad                " #no_resolve_on_fork "                 \n\
+  .long                -1                                      \n\
+  .align       8                                       \n\
+  .quad                " #init_also "                          \n\
+  .string16    \"" #dllname ".dll\"                    \n\
+  .text                                                        \n\
+  .set         " #dllname "_primed, 1                  \n\
+.endif                                                 \n\
+");
+#else
 #define LoadDLLprime(dllname, init_also, no_resolve_on_fork) __asm__ ("        \n\
 .ifndef " #dllname "_primed                            \n\
   .section     .data_cygwin_nocopy,\"w\"               \n\
@@ -74,6 +100,7 @@ bool NO_COPY wsock_started;
   .set         " #dllname "_primed, 1                  \n\
 .endif                                                 \n\
 ");
+#endif
 
 /* Create a "decorated" name */
 #define mangle(name, n) #name "@" #n
@@ -88,6 +115,32 @@ bool NO_COPY wsock_started;
   LoadDLLfuncEx3(name, n, dllname, notimp, err, 0)
 
 /* Main DLL setup stuff. */
+#ifdef __x86_64__
+#define LoadDLLfuncEx3(name, n, dllname, notimp, err, no_resolve_on_fork) \
+  LoadDLLprime (dllname, dll_func_load, no_resolve_on_fork) \
+  __asm__ ("                                           \n\
+  .section     ." #dllname "_autoload_text,\"wx\"      \n\
+  .global      " #name "                               \n\
+  .global      _win32_" #name "                        \n\
+  .align       16                                      \n\
+" #name ":                                             \n\
+_win32_" #name ":                                      \n\
+  movq         3f(%rip),%rax                           \n\
+  jmp          *%rax                                   \n\
+1:movq         2f(%rip),%rax                           \n\
+  push         %rbp            # Keep 16 byte aligned  \n\
+  push         %r9                                     \n\
+  push         %r8                                     \n\
+  push         %rdx                                    \n\
+  push         %rcx                                    \n\
+  call         *(%rax)                                 \n\
+2:.quad                ." #dllname "_info                      \n\
+  .long                (" #n "+" #notimp ") | (((" #err ") & 0xff) <<16) \n\
+3:.quad                1b                                      \n\
+  .asciz       \"" #name "\"                           \n\
+  .text                                                        \n\
+");
+#else
 #define LoadDLLfuncEx3(name, n, dllname, notimp, err, no_resolve_on_fork) \
   LoadDLLprime (dllname, dll_func_load, no_resolve_on_fork) \
   __asm__ ("                                           \n\
@@ -106,6 +159,7 @@ _win32_" mangle (name, n) ":                                \n\
   .asciz       \"" #name "\"                           \n\
   .text                                                        \n\
 ");
+#endif
 
 /* DLL loader helper functions used during initialization. */
 
@@ -121,6 +175,69 @@ extern "C" void dll_chain () __asm__ ("dll_chain");
 
 extern "C" {
 
+#ifdef __x86_64__
+__asm__ ("                                                             \n\
+        .section .rdata,\"r\"                                                  \n\
+msg1:                                                                  \n\
+       .ascii  \"couldn't dynamically determine load address for '%s' (handle %p), %E\\0\"\n\
+                                                                       \n\
+        .text                                                          \n\
+       .p2align 4,,15                                                  \n\
+noload:                                                                        \n\
+       movq    40(%rsp),%rdx   # Get the address of the information block\n\
+       movl    8(%rdx),%eax    # Should we 'ignore' the lack           \n\
+       test    $1,%eax         #  of this function?                    \n\
+       jz      1f              # Nope.                                 \n\
+       andl    $0xffff0000,%eax# upper word (== desired return value)  \n\
+       movl    %eax,32(%rsp)   # Save for later (in shadow space)      \n\
+       movl    $127,%ecx       # ERROR_PROC_NOT_FOUND                  \n\
+       call    SetLastError    # Set it                                \n\
+       movl    32(%rsp),%eax   # Get back return value                 \n\
+       sarl    $16,%eax        # swap to low order word                \n\
+       addq    $40,%rsp        # Revert stack                          \n\
+       pop     %r10            # Drop pointer to 'return address'      \n\
+       pop     %rcx            # Restore arg registers                 \n\
+       pop     %rdx                                                    \n\
+       pop     %r8                                                     \n\
+       pop     %r9                                                     \n\
+       pop     %rbp            # ...and restore frame pointer          \n\
+       ret                     # Return                                \n\
+1:                                                                     \n\
+       movq    (%rdx),%rax     # Handle value                          \n\
+       movq    8(%rax),%r8                                             \n\
+       lea     20(%rdx),%rdx   # Location of name of function          \n\
+       lea     msg1(%rip),%rcx # The message                           \n\
+       call    api_fatal       # Print message. Never returns          \n\
+                                                                       \n\
+       .globl  dll_func_load                                           \n\
+dll_func_load:                                                         \n\
+       movq    (%rsp),%rdx     # 'Return address' contains load info   \n\
+       movq    (%rdx),%rcx     # Where handle lives                    \n\
+       movq    8(%rcx),%rcx    # Address of Handle to DLL              \n\
+       addq    $20,%rdx        # Address of name of function to load   \n\
+       subq    $40,%rsp        # Shadow space + 8 byte for alignment   \n\
+       call    GetProcAddress  # Load it                               \n\
+       test    %rax,%rax       # Success?                              \n\
+       jne     gotit           # Yes                                   \n\
+       jmp     noload          # Issue an error or return              \n\
+gotit:                                                                 \n\
+       addq    $40,%rsp        # Revert stack                          \n\
+       pop     %r10            # Pointer to 'return address'           \n\
+       movq    %rax,12(%r10)   # Move absolute address to address slot \n\
+       subq    $25,%r10        # Point to jmp                          \n\
+       pop     %rcx            # Restore arg registers                 \n\
+       pop     %rdx                                                    \n\
+       pop     %r8                                                     \n\
+       pop     %r9                                                     \n\
+       pop     %rbp            # ...and restore frame pointer          \n\
+       jmp     *%r10           # Jump to actual function               \n\
+                                                                       \n\
+       .global dll_chain                                               \n\
+dll_chain:                                                             \n\
+       push    %rax            # Restore 'return address'              \n\
+       jmp     *%rdx           # Jump to next init function            \n\
+");
+#else
 __asm__ ("                                                             \n\
         .text                                                          \n\
 msg1:                                                                  \n\
@@ -177,13 +294,14 @@ dll_chain:                                                                \n\
        pushl   %eax            # Restore 'return address'              \n\
        jmp     *%edx           # Jump to next init function            \n\
 ");
+#endif
 
 /* C representations of the two info blocks described above.
    FIXME: These structures confuse gdb for some reason.  GDB can print
    the whole structure but has problems with the name field? */
 struct dll_info
 {
-  DWORD load_state;
+  UINT_PTR load_state;
   HANDLE handle;
   LONG here;
   void (*init) ();
@@ -194,14 +312,22 @@ struct func_info
 {
   struct dll_info *dll;
   LONG decoration;
+#ifdef __x86_64__
+  UINT_PTR func_addr;
+#endif
   char name[];
 };
 
 /* Mechanism for setting up info for passing to dll_chain routines. */
+#ifdef __x86_64__
+typedef __uint128_t two_addr_t;
+#else
+typedef __uint64_t two_addr_t;
+#endif
 union retchain
 {
-  struct {long high; long low;};
-  long long ll;
+  struct {uintptr_t high; uintptr_t low;};
+  two_addr_t ll;
 };
 
 
@@ -228,10 +354,56 @@ dll_load (HANDLE& handle, WCHAR *name)
 #define RETRY_COUNT 10
 
 /* The standard DLL initialization routine. */
-__attribute__ ((used, noinline)) static long long
+#ifdef __x86_64__
+
+/* On x86_64, we need assembler wrappers for std_dll_init and wsock_init.
+   In the x86_64 ABI it's no safe bet that frame[1] (aka 8(%rbp)) contains
+   the return address.  Consequentially, if we try to overwrite frame[1]
+   with the address of dll_chain, we end up with a scrambled stack, the
+   result depending on the optimization settings and the current frame of
+   mind of the compiler.  So for x86_64, we disable overwriting the return
+   address in the real std_dll_init/wsock_init function, but rather do this
+   in the wrapper, after return from the function, when we exactly know
+   where the original return address is stored on the stack. */
+
+#define INIT_WRAPPER(func) \
+__asm__ ("                                                             \n\
+       .text                                                           \n\
+       .p2align 4,,15                                                  \n\
+       .seh_proc _" #func "                                            \n\
+_" #func ":                                                            \n\
+       pushq   %rbp                                                    \n\
+       .seh_pushreg %rbp                                               \n\
+       movq    %rsp,%rbp                                               \n\
+       .seh_setframe %rbp,0                                            \n\
+       subq    $0x20,%rsp                                              \n\
+       .seh_stackalloc 32                                              \n\
+       .seh_endprologue                                                \n\
+       movq    0x28(%rsp),%rcx         # return address as parameter   \n\
+       call    " #func "                                               \n\
+       movdqa  %xmm0,0x10(%rsp)        # 128 bit return value in xmm0  \n\
+       movq    0x10(%rsp),%rax         # copy over to %rax and %rdx    \n\
+       movq    0x18(%rsp),%rdx                                         \n\
+       leaq    dll_chain(%rip),%rcx    # load address of dll_chain     \n\
+       movq    %rcx,0x28(%rsp)         # and overwrite return address  \n\
+       addq    $0x20,%rsp                                              \n\
+       popq    %rbp                                                    \n\
+       ret                                                             \n\
+       .seh_endproc                                                    \n\
+");
+
+INIT_WRAPPER (std_dll_init)
+
+__attribute__ ((used, noinline)) static two_addr_t
+std_dll_init (struct func_info *func)
+#else
+__attribute__ ((used, noinline)) static two_addr_t
 std_dll_init ()
+#endif
 {
+#ifndef __x86_64__
   struct func_info *func = (struct func_info *) __builtin_return_address (0);
+#endif
   struct dll_info *dll = func->dll;
   retchain ret;
 
@@ -284,26 +456,38 @@ std_dll_init ()
     }
 
   /* Set "arguments" for dll_chain. */
-  ret.low = (long) dll->init;
-  ret.high = (long) func;
+  ret.low = (uintptr_t) dll->init;
+  ret.high = (uintptr_t) func;
 
   InterlockedDecrement (&dll->here);
 
+#ifndef __x86_64__
   /* Kludge alert.  Redirects the return address to dll_chain. */
-  __asm__ __volatile__ ("              \n\
-       movl    $dll_chain,4(%ebp)      \n\
-  ");
+  uintptr_t *volatile frame = (uintptr_t *) __builtin_frame_address (0);
+  frame[1] = (uintptr_t) dll_chain;
+#endif
 
   return ret.ll;
 }
 
 /* Initialization function for winsock stuff. */
 WSADATA NO_COPY wsadata;
-static long long __attribute__ ((used, noinline))
+
+#ifdef __x86_64__
+/* See above comment preceeding std_dll_init. */
+INIT_WRAPPER (wsock_init)
+
+__attribute__ ((used, noinline)) static two_addr_t
+wsock_init (struct func_info *func)
+#else
+__attribute__ ((used, noinline)) static two_addr_t
 wsock_init ()
+#endif
 {
   static LONG NO_COPY here = -1L;
+#ifndef __x86_64__
   struct func_info *func = (struct func_info *) __builtin_return_address (0);
+#endif
   struct dll_info *dll = func->dll;
 
   while (InterlockedIncrement (&here))
@@ -330,23 +514,23 @@ wsock_init ()
          debug_printf ("szSystemStatus %s", wsadata.szSystemStatus);
          debug_printf ("iMaxSockets %d", wsadata.iMaxSockets);
          debug_printf ("iMaxUdpDg %d", wsadata.iMaxUdpDg);
-         debug_printf ("lpVendorInfo %d", wsadata.lpVendorInfo);
 
          wsock_started = 1;
        }
     }
 
+#ifndef __x86_64__
   /* Kludge alert.  Redirects the return address to dll_chain. */
-  __asm__ __volatile__ ("              \n\
-       movl    $dll_chain,4(%ebp)      \n\
-  ");
+  uintptr_t *volatile frame = (uintptr_t *) __builtin_frame_address (0);
+  frame[1] = (uintptr_t) dll_chain;
+#endif
 
   InterlockedDecrement (&here);
 
   volatile retchain ret;
   /* Set "arguments for dll_chain. */
-  ret.low = (long) dll_func_load;
-  ret.high = (long) func;
+  ret.low = (uintptr_t) dll_func_load;
+  ret.high = (uintptr_t) func;
   return ret.ll;
 }
 
@@ -383,19 +567,14 @@ LoadDLLfunc (ReportEventW, 36, advapi32)
 LoadDLLfunc (DnsQuery_A, 24, dnsapi)
 LoadDLLfunc (DnsRecordListFree, 8, dnsapi)
 
-// 50 = ERROR_NOT_SUPPORTED.  Returned if OS doesn't support iphlpapi funcs
-LoadDLLfuncEx2 (GetAdaptersAddresses, 20, iphlpapi, 1, 50)
+LoadDLLfunc (GetAdaptersAddresses, 20, iphlpapi)
 LoadDLLfunc (GetIfEntry, 4, iphlpapi)
 LoadDLLfunc (GetIpAddrTable, 12, iphlpapi)
 LoadDLLfunc (GetIpForwardTable, 12, iphlpapi)
 LoadDLLfunc (GetNetworkParams, 8, iphlpapi)
 LoadDLLfunc (GetUdpTable, 12, iphlpapi)
 
-LoadDLLfuncEx (AttachConsole, 4, kernel32, 1)
-LoadDLLfuncEx (GetModuleHandleExW, 12, kernel32, 1)
 LoadDLLfuncEx (GetNamedPipeClientProcessId, 8, kernel32, 1)
-LoadDLLfuncEx (GetSystemWow64DirectoryW, 8, kernel32, 1)
-LoadDLLfuncEx (GetVolumePathNamesForVolumeNameW, 16, kernel32, 1)
 LoadDLLfunc (LocaleNameToLCID, 8, kernel32)
 
 LoadDLLfunc (WNetCloseEnum, 4, mpr)
index f047d4724608d8ff35320ca72daa30c47c4b6479..6951bfd6b82db890af265076ac5ffef60f5afc91 100644 (file)
@@ -1,6 +1,6 @@
 /* automode.c
 
-   Copyright 2000, 2001, 2010 Red Hat, Inc.
+   Copyright 2000, 2001, 2010, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -14,7 +14,9 @@ details. */
 
 extern int _fmode;
 void
-cygwin_premain0 (int argc, char **argv, struct per_process *myself)
+cygwin_premain0 (int argc __attribute__ ((unused)),
+                char **argv __attribute__ ((unused)),
+                struct per_process *myself __attribute__ ((unused)))
 {
   static struct __cygwin_perfile pf[] =
   {
index f97ad0080e1f78f29e0c12a1e4e2ed478821848e..d4673d17dfcc5aab461d279dd31b7d1b17c3f485 100644 (file)
@@ -1,6 +1,6 @@
 /* binmode.c
 
-   Copyright 2000, 2001, 2010 Red Hat, Inc.
+   Copyright 2000, 2001, 2010, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -14,7 +14,9 @@ details. */
 
 extern int _fmode;
 void
-cygwin_premain0 (int argc, char **argv, struct per_process *myself)
+cygwin_premain0 (int argc __attribute__ ((unused)),
+                char **argv __attribute__ ((unused)),
+                struct per_process *myself __attribute__ ((unused)))
 {
   _fmode &= ~_O_TEXT;
   _fmode |= _O_BINARY;
index 17da88ec6f22ea4c77bb17eab0d2c4a13756e650..70cfd5433dea23f1b057312e3db618797cceb755 100644 (file)
@@ -35,7 +35,7 @@ enum child_status
 #define EXEC_MAGIC_SIZE sizeof(child_info)
 
 /* Change this value if you get a message indicating that it is out-of-sync. */
-#define CURR_CHILD_INFO_MAGIC 0xe399543U
+#define CURR_CHILD_INFO_MAGIC 0x93737edaU
 
 #define NPROCS 256
 
@@ -55,7 +55,7 @@ public:
   DWORD msv_count;     // zeroed on < W2K3, set to pseudo-count on Vista
   DWORD cb;            // size of this record
   DWORD intro;         // improbable string
-  unsigned long magic; // magic number unique to child_info
+  DWORD magic;         // magic number unique to child_info
   unsigned short type; // type of record, exec, spawn, fork
   init_cygheap *cygheap;
   void *cygheap_max;
@@ -190,6 +190,6 @@ void __stdcall init_child_info (DWORD, child_info *, HANDLE);
 
 extern "C" {
 extern child_info *child_proc_info;
-extern child_info_spawn *spawn_info asm ("_child_proc_info");
-extern child_info_fork *fork_info asm ("_child_proc_info");
+extern child_info_spawn *spawn_info asm (_SYMSTR (child_proc_info));
+extern child_info_fork *fork_info asm (_SYMSTR (child_proc_info));
 }
index 87d97b55a759014b23831799d5bec9b17f0eefde..55a5c58e408670c6907a7ad97902005e5a175718 100755 (executable)
@@ -566,10 +566,12 @@ ac_no_link=no
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
 CONFIG_DIR
+TLSOFFSETS_H
+DIN_FILE
 DEF_DLL_ENTRY
 DLL_ENTRY
+DLL_NAME
 LIBSERVER
-MALLOC_OFILES
 configure_args
 SET_MAKE
 WINDRES
@@ -4410,14 +4412,23 @@ esac
 fi
 
 
-MALLOC_OFILES=malloc.o
-
 
 
 case "$target_cpu" in
-   i?86) DLL_ENTRY="_dll_entry@12"
+   i?86)
+               DLL_NAME="cygwin1.dll"
+               DLL_ENTRY="_dll_entry@12"
                DEF_DLL_ENTRY="dll_entry@12"
+               DIN_FILE="cygwin.din"
+               TLSOFFSETS_H="tlsoffsets.h"
                CONFIG_DIR="i386"  ;;
+   x86_64)
+               DLL_NAME="cygwin1.dll"
+               DLL_ENTRY="dll_entry"
+               DEF_DLL_ENTRY="dll_entry"
+               DIN_FILE="cygwin64.din"
+               TLSOFFSETS_H="tlsoffsets64.h"
+               CONFIG_DIR="x86_64"  ;;
    *)          as_fn_error $? "Invalid target processor \"$target_cpu\"" "$LINENO" 5 ;;
 esac
 
@@ -4437,6 +4448,8 @@ configure_args=$(/usr/bin/expr "$configure_args" : 'X \(.*\)')
 
 
 
+
+
 ac_config_files="$ac_config_files Makefile"
 
 cat >confcache <<\_ACEOF
index 0796e63912b8844f2bf2f533b377a1d2751dcebd..97b3795503dfefec9b7e82965bc81591e22e7c3c 100644 (file)
@@ -55,8 +55,6 @@ no)    ;;
 esac
 ])
 
-MALLOC_OFILES=malloc.o
-
 dnl The only time we might want to transform the install names
 dnl is for unix x cygwin.  Otherwise we don't.  For now we don't
 dnl transform names.
@@ -73,16 +71,29 @@ dnl   fi
 dnl fi
 
 case "$target_cpu" in
-   i?86) DLL_ENTRY="_dll_entry@12"
+   i?86)
+               DLL_NAME="cygwin1.dll"
+               DLL_ENTRY="_dll_entry@12"
                DEF_DLL_ENTRY="dll_entry@12"
+               DIN_FILE="cygwin.din"
+               TLSOFFSETS_H="tlsoffsets.h"
                CONFIG_DIR="i386"  ;;
+   x86_64)
+               DLL_NAME="cygwin1.dll"
+               DLL_ENTRY="dll_entry"
+               DEF_DLL_ENTRY="dll_entry"
+               DIN_FILE="cygwin64.din"
+               TLSOFFSETS_H="tlsoffsets64.h"
+               CONFIG_DIR="x86_64"  ;;
    *)          AC_MSG_ERROR(Invalid target processor \"$target_cpu\") ;;
 esac
 
 AC_CONFIGURE_ARGS
-AC_SUBST(MALLOC_OFILES)
 AC_SUBST(LIBSERVER)
+AC_SUBST(DLL_NAME)
 AC_SUBST(DLL_ENTRY)
 AC_SUBST(DEF_DLL_ENTRY)
+AC_SUBST(DIN_FILE)
+AC_SUBST(TLSOFFSETS_H)
 AC_SUBST(CONFIG_DIR)
 AC_OUTPUT(Makefile)
index 998bbbf91b32c34341f93c7e8ac1fe234803ad4a..ff353227ecc580667157d922e9711f9e35a985e6 100644 (file)
@@ -12,10 +12,31 @@ cpuid (unsigned *a, unsigned *b, unsigned *c, unsigned *d, unsigned in)
        : "a" (in));
 }
 
+#ifdef __x86_64__
 extern inline bool
-can_set_flag (unsigned flag)
+can_set_flag (register unsigned long flag)
 {
-  unsigned r1, r2;
+  register unsigned long r1, r2;
+  asm("pushfq\n"
+      "popq %0\n"
+      "movq %0, %1\n"
+      "xorq %2, %0\n"
+      "pushq %0\n"
+      "popfq\n"
+      "pushfq\n"
+      "popq %0\n"
+      "pushq %1\n"
+      "popfq\n"
+      : "=&r" (r1), "=&r" (r2)
+      : "ir" (flag)
+  );
+  return ((r1 ^ r2) & flag) != 0;
+}
+#else
+extern inline bool
+can_set_flag (register unsigned flag)
+{
+  register unsigned r1, r2;
   asm("pushfl\n"
       "popl %0\n"
       "movl %0, %1\n"
@@ -31,5 +52,6 @@ can_set_flag (unsigned flag)
   );
   return ((r1 ^ r2) & flag) != 0;
 }
+#endif
 
 #endif // !CPUID_H
index 64a32ddbdbc18c71ce1d63111e1a63ba29439337..337dd75fcbb88ea65fb2c83cc04ea4fb313d92d9 100644 (file)
@@ -12,16 +12,7 @@ details. */
 #ifndef _CYGERRNO_H
 #define _CYGERRNO_H
 #include <errno.h>
-
-#ifndef __reg1
-# define __reg1 __stdcall __attribute__ ((regparm (1)))
-#endif
-#ifndef __reg2
-# define __reg2 __stdcall __attribute__ ((regparm (2)))
-#endif
-#ifndef __reg3
-# define __reg3 __stdcall __attribute__ ((regparm (3)))
-#endif
+#include "regparm.h"
 
 void __reg3 seterrno_from_win_error (const char *file, int line, DWORD code);
 void __reg3 seterrno_from_nt_status (const char *file, int line, NTSTATUS status);
index 90873215b5fc698e259439d901a71c22e635f5c4..bb926118f5047d15e0dc67967e0106067d75d920 100644 (file)
@@ -27,6 +27,7 @@
 #include "ntdll.h"
 #include <unistd.h>
 #include <wchar.h>
+#include <sys/param.h>
 
 static mini_cygheap NO_COPY cygheap_dummy =
 {
@@ -60,13 +61,11 @@ public:
 };
 
 muto NO_COPY tls_sentry::lock;
-static NO_COPY size_t nthreads;
+static NO_COPY uint32_t nthreads;
 
 #define THREADLIST_CHUNK 256
 
-#define NBUCKETS (sizeof (cygheap->buckets) / sizeof (cygheap->buckets[0]))
-#define N0 ((_cmalloc_entry *) NULL)
-#define to_cmalloc(s) ((_cmalloc_entry *) (((char *) (s)) - (unsigned) (N0->data)))
+#define to_cmalloc(s) ((_cmalloc_entry *) (((char *) (s)) - offsetof (_cmalloc_entry, data)))
 
 #define CFMAP_OPTIONS (SEC_RESERVE | PAGE_READWRITE)
 #define MVMAP_OPTIONS (FILE_MAP_WRITE)
@@ -116,47 +115,6 @@ init_cygheap::close_ctty ()
   cygheap->ctty = NULL;
 }
 
-#define nextpage(x) ((char *) (((DWORD) ((char *) x + granmask)) & ~granmask))
-#define allocsize(x) ((DWORD) nextpage (x))
-#ifdef DEBUGGING
-#define somekinda_printf debug_printf
-#else
-#define somekinda_printf malloc_printf
-#endif
-
-static void *__stdcall
-_csbrk (int sbs)
-{
-  void *prebrk = cygheap_max;
-  size_t granmask = wincap.allocation_granularity () - 1;
-  char *newbase = nextpage (prebrk);
-  cygheap_max = (char *) cygheap_max + sbs;
-  if (!sbs || (newbase >= cygheap_max) || (cygheap_max <= _cygheap_end))
-    /* nothing to do */;
-  else
-    {
-      if (prebrk <= _cygheap_end)
-       newbase = _cygheap_end;
-
-      DWORD adjsbs = allocsize ((char *) cygheap_max - newbase);
-      if (adjsbs && !VirtualAlloc (newbase, adjsbs, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE))
-       {
-         MEMORY_BASIC_INFORMATION m;
-         if (!VirtualQuery (newbase, &m, sizeof m))
-           system_printf ("couldn't get memory info, %E");
-         somekinda_printf ("Couldn't reserve/commit %d bytes of space for cygwin's heap, %E",
-                           adjsbs);
-         somekinda_printf ("AllocationBase %p, BaseAddress %p, RegionSize %p, State %p\n",
-                           m.AllocationBase, m.BaseAddress, m.RegionSize, m.State);
-         __seterrno ();
-         cygheap_max = (char *) cygheap_max - sbs;
-         return NULL;
-       }
-    }
-
-  return prebrk;
-}
-
 /* Use absolute path of cygwin1.dll to derive the Win32 dir which
    is our installation_root.  Note that we can't handle Cygwin installation
    root dirs of more than 4K path length.  I assume that's ok...
@@ -261,6 +219,21 @@ cygheap_init ()
                                         sizeof (*cygheap));
       cygheap_max = cygheap;
       _csbrk (sizeof (*cygheap));
+      /* Initialize bucket_val.  The value is the max size of a block
+         fitting into the bucket.  The values are powers of two and their
+        medians: 12, 16, 24, 32, 48, 64, ...  On 64 bit, start with 24 to
+        accommodate bigger size of struct cygheap_entry.
+        With NBUCKETS == 40, the maximum block size is 6291456/12582912.
+        The idea is to have better matching bucket sizes (not wasting
+        space) without trading in performance compared to the old powers
+        of 2 method. */
+#ifdef __x86_64__
+      unsigned sz[2] = { 16, 24 };     /* sizeof cygheap_entry == 16 */
+#else
+      unsigned sz[2] = { 8, 12 };      /* sizeof cygheap_entry == 8 */
+#endif
+      for (unsigned b = 1; b < NBUCKETS; b++, sz[b & 1] <<= 1)
+       cygheap->bucket_val[b] = sz[b & 1];
       /* Default locale settings. */
       cygheap->locale.mbtowc = __utf8_mbtowc;
       cygheap->locale.wctomb = __utf8_wctomb;
@@ -276,6 +249,47 @@ cygheap_init ()
   cygheap->init_tls_list ();
 }
 
+#define nextpage(x) ((char *) roundup2 ((uintptr_t) (x), \
+                                       wincap.allocation_granularity ()))
+#define allocsize(x) ((SIZE_T) nextpage (x))
+#ifdef DEBUGGING
+#define somekinda_printf debug_printf
+#else
+#define somekinda_printf malloc_printf
+#endif
+
+static void *__stdcall
+_csbrk (int sbs)
+{
+  void *prebrk = cygheap_max;
+  char *newbase = nextpage (prebrk);
+  cygheap_max = (char *) cygheap_max + sbs;
+  if (!sbs || (newbase >= cygheap_max) || (cygheap_max <= _cygheap_end))
+    /* nothing to do */;
+  else
+    {
+      if (prebrk <= _cygheap_end)
+       newbase = _cygheap_end;
+
+      SIZE_T adjsbs = allocsize ((char *) cygheap_max - newbase);
+      if (adjsbs && !VirtualAlloc (newbase, adjsbs, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE))
+       {
+         MEMORY_BASIC_INFORMATION m;
+         if (!VirtualQuery (newbase, &m, sizeof m))
+           system_printf ("couldn't get memory info, %E");
+         somekinda_printf ("Couldn't reserve/commit %ld bytes of space for cygwin's heap, %E",
+                           adjsbs);
+         somekinda_printf ("AllocationBase %p, BaseAddress %p, RegionSize %lx, State %x\n",
+                           m.AllocationBase, m.BaseAddress, m.RegionSize, m.State);
+         __seterrno ();
+         cygheap_max = (char *) cygheap_max - sbs;
+         return NULL;
+       }
+    }
+
+  return prebrk;
+}
+
 /* Copyright (C) 1997, 2000 DJ Delorie */
 
 static void *__reg1 _cmalloc (unsigned size);
@@ -285,11 +299,13 @@ static void *__reg1
 _cmalloc (unsigned size)
 {
   _cmalloc_entry *rvc;
-  unsigned b, sz;
+  unsigned b;
 
-  /* Calculate "bit bucket" and size as a power of two. */
-  for (b = 3, sz = 8; sz && sz < size; b++, sz <<= 1)
+  /* Calculate "bit bucket". */
+  for (b = 1; b < NBUCKETS && cygheap->bucket_val[b] < size; b++)
     continue;
+  if (b >= NBUCKETS)
+    return NULL;
 
   cygheap_protect.acquire ();
   if (cygheap->buckets[b])
@@ -300,7 +316,8 @@ _cmalloc (unsigned size)
     }
   else
     {
-      rvc = (_cmalloc_entry *) _csbrk (sz + sizeof (_cmalloc_entry));
+      rvc = (_cmalloc_entry *) _csbrk (cygheap->bucket_val[b]
+                                      + sizeof (_cmalloc_entry));
       if (!rvc)
        {
          cygheap_protect.release ();
@@ -320,7 +337,7 @@ _cfree (void *ptr)
 {
   cygheap_protect.acquire ();
   _cmalloc_entry *rvc = to_cmalloc (ptr);
-  DWORD b = rvc->b;
+  unsigned b = rvc->b;
   rvc->ptr = cygheap->buckets[b];
   cygheap->buckets[b] = (char *) rvc;
   cygheap_protect.release ();
@@ -334,7 +351,7 @@ _crealloc (void *ptr, unsigned size)
     newptr = _cmalloc (size);
   else
     {
-      unsigned oldsize = 1 << to_cmalloc (ptr)->b;
+      unsigned oldsize = cygheap->bucket_val[to_cmalloc (ptr)->b];
       if (size <= oldsize)
        return ptr;
       newptr = _cmalloc (size);
@@ -351,8 +368,7 @@ _crealloc (void *ptr, unsigned size)
 
 #define sizeof_cygheap(n) ((n) + sizeof (cygheap_entry))
 
-#define N ((cygheap_entry *) NULL)
-#define tocygheap(s) ((cygheap_entry *) (((char *) (s)) - (int) (N->data)))
+#define tocygheap(s) ((cygheap_entry *) (((char *) (s)) - offsetof (cygheap_entry, data)))
 
 inline static void *
 creturn (cygheap_types x, cygheap_entry * c, unsigned len, const char *fn = NULL)
@@ -600,12 +616,12 @@ init_cygheap::remove_tls (_cygtls *t, DWORD wait)
   tls_sentry here (wait);
   if (here.acquired ())
     {
-      for (size_t i = 0; i < nthreads; i++)
+      for (uint32_t i = 0; i < nthreads; i++)
        if (t == threadlist[i])
          {
            if (i < --nthreads)
              threadlist[i] = threadlist[nthreads];
-           debug_only_printf ("removed %p element %d", this, i);
+           debug_only_printf ("removed %p element %u", this, i);
            break;
          }
     }
index b510764727a27cc4e2d843b1972331557d31218f..ed645b7d684a7c2c58001b9f203d2e4689b4743d 100644 (file)
@@ -18,7 +18,7 @@ struct _cmalloc_entry
 {
   union
   {
-    DWORD b;
+    unsigned b;
     char *ptr;
   };
   struct _cmalloc_entry *prev;
@@ -97,11 +97,11 @@ class cygheap_user
   cygsid effec_cygsid;  /* buffer for user's SID */
   cygsid saved_cygsid;  /* Remains intact even after impersonation */
 public:
-  __uid32_t saved_uid;     /* Remains intact even after impersonation */
-  __gid32_t saved_gid;     /* Ditto */
-  __uid32_t real_uid;      /* Remains intact on seteuid, replaced by setuid */
-  __gid32_t real_gid;      /* Ditto */
-  user_groups groups;      /* Primary and supp SIDs */
+  uid_t saved_uid;      /* Remains intact even after impersonation */
+  gid_t saved_gid;      /* Ditto */
+  uid_t real_uid;       /* Remains intact on seteuid, replaced by setuid */
+  gid_t real_gid;       /* Ditto */
+  user_groups groups;   /* Primary and supp SIDs */
 
   /* token is needed if set(e)uid should be called. It can be set by a call
      to `set_impersonation_token()'. */
@@ -153,8 +153,8 @@ public:
     const char *p = env_domain ("USERDOMAIN=", sizeof ("USERDOMAIN=") - 1);
     return (p == almost_null) ? NULL : p;
   }
-  BOOL set_sid (PSID new_sid) {return (BOOL) (effec_cygsid = new_sid);}
-  BOOL set_saved_sid () { return (BOOL) (saved_cygsid = effec_cygsid); }
+  void set_sid (PSID new_sid) { effec_cygsid = new_sid;}
+  void set_saved_sid () { saved_cygsid = effec_cygsid; }
   PSID sid () { return effec_cygsid; }
   PSID saved_sid () { return saved_cygsid; }
   const char *ontherange (homebodies what, struct passwd * = NULL);
@@ -216,9 +216,10 @@ enum fcwd_version_t {
    minimal locking and it's much more multi-thread friendly.  Presumably
    it minimizes contention when accessing the CWD.
    The class fcwd_access_t is supposed to encapsulate the gory implementation
-   details depending on OS version from the calling functions. */
+   details depending on OS version from the calling functions.
+   The layout of all structures has been tested on 32 and 64 bit. */
 class fcwd_access_t {
-  /* This is the layout used in Windows 8 developer preview. */
+  /* This is the layout used in Windows 8. */
   struct FAST_CWD_8 {
     LONG           ReferenceCount;     /* Only release when this is 0. */
     HANDLE         DirectoryHandle;
@@ -227,7 +228,7 @@ class fcwd_access_t {
     UNICODE_STRING Path;               /* Path's Buffer member always refers
                                           to the following Buffer array. */
     LONG           FSCharacteristics;  /* Taken from FileFsDeviceInformation */
-    WCHAR          Buffer[MAX_PATH];
+    WCHAR          Buffer[MAX_PATH] __attribute ((aligned (8)));
   };
   /* This is the layout used in Windows 7 and Vista. */
   struct FAST_CWD_7 {
@@ -238,7 +239,7 @@ class fcwd_access_t {
     LONG           ReferenceCount;     /* Only release when this is 0. */
     ULONG          OldDismountCount;   /* Reflects the system DismountCount
                                           at the time the CWD has been set. */
-    WCHAR          Buffer[MAX_PATH];
+    WCHAR          Buffer[MAX_PATH] __attribute ((aligned (8)));
   };
   /* This is the old FAST_CWD structure up to the patch from KB 2393802,
      release in February 2011. */
@@ -349,8 +350,7 @@ struct user_heap_info
   void *ptr;
   void *top;
   void *max;
-  unsigned chunk;
-  unsigned slop;
+  SIZE_T chunk;
 };
 
 struct hook_chain
@@ -365,10 +365,13 @@ struct mini_cygheap
   cygheap_locale locale;
 };
 
+#define NBUCKETS 40
+
 struct init_cygheap: public mini_cygheap
 {
   _cmalloc_entry *chain;
-  char *buckets[32];
+  unsigned bucket_val[NBUCKETS];
+  char *buckets[NBUCKETS];
   WCHAR installation_root[PATH_MAX];
   UNICODE_STRING installation_key;
   WCHAR installation_key_buf[18];
@@ -387,7 +390,7 @@ struct init_cygheap: public mini_cygheap
 
   fhandler_termios *ctty;      /* Current tty */
   struct _cygtls **threadlist;
-  size_t sthreads;
+  uint32_t sthreads;
   pid_t pid;                   /* my pid */
   struct {                     /* Equivalent to using LIST_HEAD. */
     struct inode_t *lh_first;
index 90d1e573378182c63416dc602e922a8ae44b9d34..b9452910930f70ea292bdbb2de3f2fd53015d330 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # cygmagic - Generate "magic numbers" from a structure.
 #
-#   Copyright 2001, 2002, 2005 Red Hat, Inc.
+#   Copyright 2001, 2002, 2005, 2013 Red Hat, Inc.
 #
 # This file is part of Cygwin.
 #
@@ -24,7 +24,7 @@ sumit() {
 while [ -n "$1" ]; do
     define=$1; shift
     struct=$1; shift
-    sum=`$gcc -E $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[      ]//g' -e '/^$/d' | sumit | awk '{printf "0x%xU", $1}'`
+    sum=`$gcc -D__CYGMAGIC__ -E $file | sed -n "/^$struct/,/^};/p" | sed -e 's/[       ]//g' -e '/^$/d' | sumit | awk '{printf "0x%xU", $1}'`
     echo "#define $define $sum"
     curr=`sed -n "s/^#[        ]*define CURR_$define[  ][      ]*\([^  ][^     ]*\)/\1/p" $file`
     [ "$curr" != "$sum" ] && echo "*** WARNING WARNING WARNING WARNING WARNING ***
index bf3a6237b1801ccdec0957dc8f050f25d8476753..092e2f6959b8e379d02573e53f0c2abb276fa1a9 100644 (file)
@@ -11,18 +11,11 @@ details. */
 #ifdef __cplusplus
 extern "C" {
 #endif
-#ifndef __reg1
-# define __reg1 __stdcall __attribute__ ((regparm (1)))
-#endif
-#ifndef __reg2
-# define __reg2 __stdcall __attribute__ ((regparm (2)))
-#endif
-#ifndef __reg3
-# define __reg3 __stdcall __attribute__ ((regparm (3)))
-#endif
+#include "regparm.h"
+
 void __reg1 dlfree (void *p);
-void __reg1 *dlmalloc (unsigned size);
-void __reg2 *dlrealloc (void *p, unsigned size);
+void __reg1 *dlmalloc (size_t size);
+void __reg2 *dlrealloc (void *p, size_t size);
 void __reg2 *dlcalloc (size_t nmemb, size_t size);
 void __reg2 *dlmemalign (size_t alignment, size_t bytes);
 void __reg1 *dlvalloc (size_t bytes);
@@ -31,8 +24,14 @@ int __reg1 dlmalloc_trim (size_t);
 int __reg2 dlmallopt (int p, int v);
 void dlmalloc_stats ();
 
+#ifdef __x86_64__
+#define MALLOC_ALIGNMENT ((size_t)16U)
+#endif
+
 #ifndef __INSIDE_CYGWIN__
 extern "C" void __set_ENOMEM ();
+void *mmap64 (void *, size_t, int, int, int, off_t);
+#define mmap mmap64
 # define MALLOC_FAILURE_ACTION __set_ENOMEM ()
 # define USE_DL_PREFIX 1
 #else
index b549ed006608d80c7823a052afb6cb25b10d6d8d..8bcc271f39db908f56ff048998059ffcab172dcf 100644 (file)
@@ -1,6 +1,6 @@
 /* cygserver.h
 
-   Copyright 2001, 2002, 2003, 2004, 2008 Red Hat Inc.
+   Copyright 2001, 2002, 2003, 2004, 2008, 2012, 2013 Red Hat Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -61,7 +61,7 @@ protected:
     union
     {
       request_code_t request_code;
-      ssize_t error_code;
+      int error_code;
     };
 
     header_t () {};
@@ -80,8 +80,8 @@ public:
 
   request_code_t request_code () const { return _header.request_code; }
 
-  ssize_t error_code () const { return _header.error_code; };
-  void error_code (ssize_t error_code) { _header.error_code = error_code; };
+  int error_code () const { return _header.error_code; };
+  void error_code (int error_code) { _header.error_code = error_code; };
 
   size_t msglen () const { return _header.msglen; };
   void msglen (size_t len) { _header.msglen = len; };
index d99f47647ff45f5d641a015eb4bafc55d8498944..2604150449d76fe5968b23432d4b06651b091afa 100644 (file)
@@ -1,6 +1,6 @@
 /* cygserver_ipc.h
 
-   Copyright 2002, 2003, 2004, 2012 Red Hat, Inc.
+   Copyright 2002, 2003, 2004, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -22,10 +22,10 @@ struct vmspace {
 struct proc {
   pid_t cygpid;
   DWORD winpid;
-  __uid32_t uid;
-  __gid32_t gid;
+  uid_t uid;
+  gid_t gid;
   int gidcnt;
-  __gid32_t *gidlist;
+  gid_t *gidlist;
   bool is_admin;
   struct vmspace *p_vmspace;
   HANDLE signal_arrived;
@@ -52,7 +52,8 @@ class ipc_retval {
 private:
   union {
     int i;
-    unsigned int u;
+    ssize_t ssz;
+    size_t sz;
     vm_offset_t off;
     vm_object_t obj;
   };
@@ -63,8 +64,15 @@ public:
   operator int () const { return i; }
   int operator = (int ni) { return i = ni; }
 
-  operator unsigned int () const { return u; }
-  unsigned int operator = (unsigned int nu) { return u = nu; }
+#ifndef __x86_64__
+  /* On x86_64: size_t == vm_offset_t == unsigned long */
+  operator size_t () const { return sz; }
+  size_t operator = (size_t nsz) { return sz = nsz; }
+#else
+  /* On i686: ssize_t == long == int */
+  operator ssize_t () const { return ssz; }
+  ssize_t operator = (ssize_t nssz) { return ssz = nssz; }
+#endif
 
   operator vm_offset_t () const { return off; }
   vm_offset_t operator = (vm_offset_t noff) { return off = noff; }
index 325b7e87961b0201aab1c84feeefc475e0d20ec3..e48a73e545e7ca90884fc891f1b188e0ab3bf863 100644 (file)
@@ -72,7 +72,7 @@ cygthread::stub (VOID *arg)
   else
     {
       info->stack_ptr = &arg;
-      debug_printf ("thread '%s', id %p, stack_ptr %p", info->name (), info->id, info->stack_ptr);
+      debug_printf ("thread '%s', id %y, stack_ptr %p", info->name (), info->id, info->stack_ptr);
       if (!info->ev)
        {
          info->ev = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
@@ -165,7 +165,7 @@ new (size_t)
        /* available */
 #ifdef DEBUGGING
        if (info->__name)
-         api_fatal ("name not NULL? %s, id %p, i %d", info->__name, info->id, info - threads);
+         api_fatal ("name not NULL? %s, id %y, i %ld", info->__name, info->id, info - threads);
 #endif
        goto out;
       }
@@ -197,7 +197,7 @@ cygthread::async_create (ULONG_PTR arg)
 void
 cygthread::create ()
 {
-  thread_printf ("name %s, id %p, this %p", __name, id, this);
+  thread_printf ("name %s, id %y, this %p", __name, id, this);
   HANDLE htobe;
   if (h)
     {
@@ -206,7 +206,7 @@ cygthread::create ()
       while (!thread_sync)
        yield ();
       SetEvent (thread_sync);
-      thread_printf ("activated name '%s', thread_sync %p for id %p", __name, thread_sync, id);
+      thread_printf ("activated name '%s', thread_sync %p for id %y", __name, thread_sync, id);
       htobe = h;
     }
   else
@@ -215,8 +215,8 @@ cygthread::create ()
       htobe = CreateThread (&sec_none_nih, 0, is_freerange ? simplestub : stub,
                            this, 0, &id);
       if (!htobe)
-       api_fatal ("CreateThread failed for %s - %p<%p>, %E", __name, h, id);
-      thread_printf ("created name '%s', thread %p, id %p", __name, h, id);
+       api_fatal ("CreateThread failed for %s - %p<%y>, %E", __name, h, id);
+      thread_printf ("created name '%s', thread %p, id %y", __name, h, id);
 #ifdef DEBUGGING
       terminated = false;
 #endif
@@ -257,7 +257,7 @@ cygthread::name (DWORD tid)
     res = "main";
   else
     {
-      __small_sprintf (_my_tls.locals.unknown_thread_name, "unknown (%p)", tid);
+      __small_sprintf (_my_tls.locals.unknown_thread_name, "unknown (%y)", tid);
       res = _my_tls.locals.unknown_thread_name;
     }
   return res;
@@ -296,7 +296,7 @@ bool
 cygthread::terminate_thread ()
 {
   bool terminated = true;
-  debug_printf ("thread '%s', id %p, inuse %d, stack_ptr %p", __name, id, inuse, stack_ptr);
+  debug_printf ("thread '%s', id %y, inuse %d, stack_ptr %p", __name, id, inuse, stack_ptr);
   while (inuse && !stack_ptr)
     yield ();
 
@@ -354,7 +354,7 @@ cygthread::detach (HANDLE sigwait)
   bool signalled = false;
   bool thread_was_reset = false;
   if (!inuse)
-    system_printf ("called detach but inuse %d, thread %p?", inuse, id);
+    system_printf ("called detach but inuse %d, thread %y?", inuse, id);
   else
     {
       DWORD res;
@@ -429,7 +429,7 @@ cygthread::detach (HANDLE sigwait)
          ::SetThreadPriority (hth, prio);
        }
 
-      thread_printf ("%s returns %d, id %p", sigwait ? "WFMO" : "WFSO",
+      thread_printf ("%s returns %d, id %y", sigwait ? "WFMO" : "WFSO",
                     res, id);
 
       if (thread_was_reset)
index 80cab35166d95d1959a28fe0d1f5992d361a6fe2..6aebdc97543dd773f2437fa928951a0e6588ff8e 100644 (file)
@@ -166,7 +166,7 @@ _cygtls::remove (DWORD wait)
   if (exit_state >= ES_FINAL)
     return;
 
-  debug_printf ("wait %p", wait);
+  debug_printf ("wait %u", wait);
 
   /* FIXME: Need some sort of atthreadexit function to allow things like
      select to control this themselves. */
index 5463ed85ca6b6f74dc55177a593455f9356fc464..d475508e2e581caba721fe5ad4e90827c7876c0a 100644 (file)
@@ -39,7 +39,11 @@ details. */
 #include "thread.h"
 #endif
 
+#ifdef __x86_64__
+#pragma pack(push,8)
+#else
 #pragma pack(push,4)
+#endif
 /* Defined here to support auto rebuild of tlsoffsets.h. */
 class tls_pathbuf
 {
@@ -78,8 +82,6 @@ struct _local_storage
   /*
      Needed for the group functions
    */
-  struct __group16 grp;
-  char *namearray[2];
   int grp_pos;
 
   /* dlfcn.cc */
@@ -157,15 +159,13 @@ typedef struct struct_waitq
 */
 
 /*gentls_offsets*/
-#include "cygerrno.h"
-#include "security.h"
 
 extern "C" int __sjfault (jmp_buf);
 extern "C" int __ljfault (jmp_buf, int);
 
 /*gentls_offsets*/
 
-typedef __uint32_t __stack_t;
+typedef uintptr_t __stack_t;
 
 class _cygtls
 {
@@ -237,7 +237,7 @@ public:
        if (wait_for_lock)
          lock ();
        if (!signal_arrived)
-         signal_arrived = CreateEvent (&sec_none_nih, false, false, NULL);
+         signal_arrived = CreateEvent (NULL, false, false, NULL);
        if (wait_for_lock)
          unlock ();
       }
@@ -266,13 +266,29 @@ private:
 };
 #pragma pack(pop)
 
-const int CYGTLS_PADSIZE = 12700;      /* FIXME: Find some way to autogenerate
-                                          this value */
+/* FIXME: Find some way to autogenerate this value */
+#ifdef __x86_64__
+const int CYGTLS_PADSIZE = 12800;      /* Must be 16-byte aligned */
+#else
+const int CYGTLS_PADSIZE = 12700;
+#endif
+
 /*gentls_offsets*/
 
-extern char *_tlsbase __asm__ ("%fs:4");
-extern char *_tlstop __asm__ ("%fs:8");
-#define _my_tls (*((_cygtls *) (_tlsbase - CYGTLS_PADSIZE)))
+#include "cygerrno.h"
+#include "ntdll.h"
+
+#ifdef __x86_64__
+/* When just using a "gs:X" asm for the x86_64 code, gcc wrongly creates
+   pc-relative instructions.  However, NtCurrentTeb() is inline assembler
+   anyway, so using it here should be fast enough on x86_64. */
+#define _tlsbase (NtCurrentTeb()->Tib.StackBase)
+#define _tlstop (NtCurrentTeb()->Tib.StackLimit)
+#else
+extern PVOID _tlsbase __asm__ ("%fs:4");
+extern PVOID _tlstop __asm__ ("%fs:8");
+#endif
+#define _my_tls (*((_cygtls *) ((char *)_tlsbase - CYGTLS_PADSIZE)))
 extern _cygtls *_main_tls;
 extern _cygtls *_sig_tls;
 
index c1e2e9ac04b4dd64792b3046c4c938a40a26ed17..8d02c161aff8be55212fd3e88ed526335da75dcd 100644 (file)
@@ -678,8 +678,8 @@ get_avphys_pages SIGFE
 get_current_dir_name SIGFE
 get_nprocs SIGFE
 get_nprocs_conf SIGFE
-get_osfhandle SIGFE
-_get_osfhandle = get_osfhandle SIGFE
+_get_osfhandle SIGFE
+get_osfhandle = _get_osfhandle SIGFE
 get_phys_pages SIGFE
 getaddrinfo = cygwin_getaddrinfo SIGFE
 getc SIGFE
similarity index 66%
rename from winsup/cygwin/cygwin.sc
rename to winsup/cygwin/cygwin.sc.in
index d5f79ab6caf82a208cdc275ed596418529b90043..694e91697451a7d11e92c2ecbdd5f7a7664de0db 100644 (file)
@@ -1,17 +1,38 @@
+#ifdef __x86_64__
+OUTPUT_FORMAT(pei-x86-64)
+SEARCH_DIR("/usr/x86_64-pc-cygwin/lib/w32api"); SEARCH_DIR("=/usr/lib/w32api");
+#else
+#undef i386
 OUTPUT_FORMAT(pei-i386)
+SEARCH_DIR("/usr/i686-pc-cygwin/lib/w32api"); SEARCH_DIR("=/usr/lib/w32api");
+#endif
+#define __CONCAT1(a,b) a##b
+#define __CONCAT(a,b) __CONCAT1(a,b)
+#define _SYM(x)        __CONCAT(__USER_LABEL_PREFIX__, x)
 SECTIONS
 {
   .text  __image_base__ + __section_alignment__  :
   {
      *(.init)
     *(.text)
+#ifdef __x86_64__
+    *(.text.*)
+#endif
     *(SORT(.text$*))
     *(.glue_7t)
     *(.glue_7)
+#ifdef __x86_64__
+    . = ALIGN(8);
+     ___CTOR_LIST__ = .; __CTOR_LIST__ = .;
+                       LONG (-1); LONG (-1); *(SORT(.ctors.*)); *(.ctors); *(.ctor); LONG (0); LONG (0);
+     ___DTOR_LIST__ = .; __DTOR_LIST__ = .;
+                       LONG (-1); LONG (-1); *(SORT(.dtors.*)); *(.dtors); *(.dtor);  LONG (0); LONG (0);
+#else
      ___CTOR_LIST__ = .; __CTOR_LIST__ = .;
                        LONG (-1); *(SORT(.ctors.*)); *(.ctors); *(.ctor); LONG (0);
      ___DTOR_LIST__ = .; __DTOR_LIST__ = .;
                        LONG (-1); *(SORT(.dtors.*)); *(.dtors); *(.dtor);  LONG (0);
+#endif
      *(.fini)
     /* ??? Why is .gcc_exc here?  */
      *(.gcc_exc)
@@ -23,10 +44,10 @@ SECTIONS
     *(.*_autoload_text);
   }
   /* The Cygwin DLL uses a section to avoid copying certain data
-     on fork.  This used to be named ".data".  The linker used
+     on fork.  This used to be named ".data$nocopy".  The linker used
      to include this between __data_start__ and __data_end__, but that
-     breaks building the cygwin32 dll.  Instead, we name the section
-     ".data_cygwin_nocopy" and explictly include it after __data_end__. */
+     breaks building the cygwin dll.  Instead, we name the section
+     ".data_cygwin_nocopy" and explicitly include it after __data_end__. */
   .data ALIGN(__section_alignment__) :
   {
     __data_start__ = .;
@@ -41,11 +62,18 @@ SECTIONS
     *(.rdata)
     *(SORT(.rdata$*))
     *(.eh_frame)
+    *(.rdata_cygwin_nocopy)
   }
   .pdata ALIGN(__section_alignment__) :
   {
-    *(.pdata)
+    *(.pdata*)
+  }
+#ifdef __x86_64__
+  .xdata ALIGN(__section_alignment__) :
+  {
+    *(.xdata*)
   }
+#endif
   .bss ALIGN(__section_alignment__) :
   {
     __bss_start__ = .;
@@ -99,13 +127,17 @@ SECTIONS
     SORT(*)(.idata$6)
     SORT(*)(.idata$7)
     . = ALIGN(16);
-    __cygheap_start = ABSOLUTE(.);
+    _SYM (_cygheap_start) = ABSOLUTE(.);
   }
   .cygheap ALIGN(__section_alignment__) :
   {
+#ifdef __x86_64__
+    . = . + (3072 * 1024);
+#else
     . = . + (2048 * 1024);
+#endif
     . = ALIGN(0x10000);
-    __cygheap_end = ABSOLUTE(.);
+    _SYM (_cygheap_end) = ABSOLUTE(.);
   }
   /DISCARD/ :
   {
@@ -125,6 +157,7 @@ SECTIONS
   /* DWARF 1.1 and DWARF 2 */
   .debug_aranges  ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_aranges) }
   .debug_pubnames ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_pubnames) }
+  .debug_pubtypes ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_pubtypes) }
   /* DWARF 2 */
   .debug_info     ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_info) }
   .debug_abbrev   ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_abbrev) }
@@ -133,6 +166,14 @@ SECTIONS
   .debug_str      ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_str) }
   .debug_loc      ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_loc) }
   .debug_macinfo  ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_macinfo) }
+  /* SGI/MIPS DWARF 2 extensions. */
+  .debug_weaknames ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_weaknames) }
+  .debug_funcnames ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_funcnames) }
+  .debug_typenames ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_typenames) }
+  .debug_varnames  ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_varnames) }
+  .debug_macro    ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_macro) }
+  /* DWARF 3. */
   .debug_ranges   ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_ranges) }
-  .debug_pubtypes ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_pubtypes) }
+  /* DWARF 4. */
+  .debug_types   ALIGN(__section_alignment__) (NOLOAD) : { *(.debug_types .gnu.linkonce.wt.*) }
 }
diff --git a/winsup/cygwin/cygwin64.din b/winsup/cygwin/cygwin64.din
new file mode 100644 (file)
index 0000000..5a3f22a
--- /dev/null
@@ -0,0 +1,1346 @@
+LIBRARY "cygwin1.dll" BASE=0x180040000
+
+EXPORTS
+__argc DATA
+__argv DATA
+_check_for_executable DATA
+__check_rhosts_file DATA
+_ctype_ DATA
+__ctype_ptr__ DATA
+environ = __cygwin_environ DATA
+__cygwin_user_data DATA
+_daylight DATA
+error_message_count DATA
+error_one_per_line DATA
+error_print_progname DATA
+h_errno DATA
+_impure_ptr DATA
+in6addr_any DATA
+in6addr_loopback DATA
+__mb_cur_max DATA
+optarg DATA
+opterr DATA
+optind DATA
+optopt DATA
+optreset DATA
+__progname DATA
+program_invocation_name DATA
+program_invocation_short_name DATA
+__rcmd_errstr DATA
+reent_data DATA
+sys_errlist = _sys_errlist DATA
+_sys_errlist DATA
+sys_nerr = _sys_nerr DATA
+_sys_nerr DATA
+sys_sigabbrev DATA
+sys_siglist DATA
+_timezone DATA
+_tzname DATA
+_Exit SIGFE
+a64l NOSIGFE
+abort NOSIGFE
+abs NOSIGFE
+accept = cygwin_accept SIGFE
+accept4 SIGFE
+access SIGFE
+acl SIGFE
+aclcheck NOSIGFE
+aclfrommode SIGFE
+aclfrompbits SIGFE
+aclfromtext SIGFE
+aclsort SIGFE
+acltomode SIGFE
+acltopbits SIGFE
+acltotext SIGFE
+acos NOSIGFE
+acosf NOSIGFE
+acosh NOSIGFE
+acoshf NOSIGFE
+alarm SIGFE
+_alloca = __alloca NOSIGFE
+alphasort NOSIGFE
+argz_add SIGFE
+argz_add_sep SIGFE
+argz_append SIGFE
+argz_count NOSIGFE
+argz_create SIGFE
+argz_create_sep SIGFE
+argz_delete SIGFE
+argz_extract NOSIGFE
+argz_insert SIGFE
+argz_next NOSIGFE
+argz_replace SIGFE
+argz_stringify NOSIGFE
+asctime SIGFE
+asctime_r SIGFE
+asin NOSIGFE
+asinf NOSIGFE
+asinh NOSIGFE
+asinhf NOSIGFE
+asnprintf SIGFE
+asprintf SIGFE
+__assert NOSIGFE
+__assert_func NOSIGFE
+__assertfail NOSIGFE
+atan NOSIGFE
+atan2 NOSIGFE
+atan2f NOSIGFE
+atanf NOSIGFE
+atanh NOSIGFE
+atanhf NOSIGFE
+atexit = cygwin_atexit SIGFE
+atof SIGFE
+atoff SIGFE
+atoi NOSIGFE
+atol NOSIGFE
+atoll NOSIGFE
+basename NOSIGFE
+bcmp NOSIGFE
+bcopy NOSIGFE
+bind = cygwin_bind SIGFE
+bindresvport = cygwin_bindresvport SIGFE
+bindresvport_sa = cygwin_bindresvport_sa SIGFE
+bsearch NOSIGFE
+btowc NOSIGFE
+bzero NOSIGFE
+cabs NOSIGFE
+cabsf NOSIGFE
+cacos NOSIGFE
+cacosf NOSIGFE
+cacosh NOSIGFE
+cacoshf NOSIGFE
+calloc SIGFE
+canonicalize_file_name SIGFE
+carg NOSIGFE
+cargf NOSIGFE
+casin NOSIGFE
+casinf NOSIGFE
+casinh NOSIGFE
+casinhf NOSIGFE
+catan NOSIGFE
+catanf NOSIGFE
+catanh NOSIGFE
+catanhf NOSIGFE
+cbrt NOSIGFE
+cbrtf NOSIGFE
+ccos NOSIGFE
+ccosf NOSIGFE
+ccosh NOSIGFE
+ccoshf NOSIGFE
+ceil NOSIGFE
+ceilf NOSIGFE
+cexp NOSIGFE
+cexpf NOSIGFE
+cfgetispeed NOSIGFE
+cfgetospeed NOSIGFE
+cfmakeraw NOSIGFE
+cfsetispeed SIGFE
+cfsetospeed SIGFE
+cfsetspeed SIGFE
+chdir SIGFE
+chmod SIGFE
+chown SIGFE
+chroot SIGFE
+cimag NOSIGFE
+cimagf NOSIGFE
+cleanup_glue NOSIGFE
+clearerr SIGFE
+clock SIGFE
+clock_getcpuclockid SIGFE
+clock_getres SIGFE
+clock_gettime SIGFE
+clock_nanosleep SIGFE
+clock_setres SIGFE
+clock_settime SIGFE
+clog NOSIGFE
+clogf NOSIGFE
+close SIGFE
+closedir SIGFE
+closelog SIGFE
+confstr NOSIGFE
+conj NOSIGFE
+conjf NOSIGFE
+connect = cygwin_connect SIGFE
+copysign NOSIGFE
+copysignf NOSIGFE
+cos NOSIGFE
+cosf NOSIGFE
+cosh NOSIGFE
+coshf NOSIGFE
+cpow NOSIGFE
+cpowf NOSIGFE
+cproj NOSIGFE
+cprojf NOSIGFE
+creal NOSIGFE
+crealf NOSIGFE
+creat SIGFE
+csin NOSIGFE
+csinf NOSIGFE
+csinh NOSIGFE
+csinhf NOSIGFE
+csqrt NOSIGFE
+csqrtf NOSIGFE
+ctan NOSIGFE
+ctanf NOSIGFE
+ctanh NOSIGFE
+ctanhf NOSIGFE
+ctermid SIGFE
+ctime SIGFE
+ctime_r SIGFE
+cuserid NOSIGFE
+cwait SIGFE
+cygwin_attach_handle_to_fd SIGFE
+cygwin_conv_path SIGFE
+cygwin_conv_path_list SIGFE
+cygwin_create_path SIGFE
+cygwin_detach_dll SIGFE_MAYBE
+cygwin_dll_init NOSIGFE
+cygwin_internal NOSIGFE
+cygwin_logon_user SIGFE
+cygwin_posix_path_list_p NOSIGFE
+cygwin_set_impersonation_token SIGFE
+cygwin_split_path NOSIGFE
+cygwin_stackdump SIGFE
+cygwin_umount SIGFE
+cygwin_winpid_to_pid SIGFE
+daemon SIGFE
+difftime NOSIGFE
+dirfd SIGFE
+dirname NOSIGFE
+div NOSIGFE
+dlclose SIGFE
+dlerror NOSIGFE
+dlfork NOSIGFE
+_dll_crt0 NOSIGFE
+dll_crt0__FP11per_process NOSIGFE # dll_crt0(per_process *)
+dll_dllcrt0 NOSIGFE
+dll_entry NOSIGFE
+dlopen SIGFE
+dlsym SIGFE
+dn_comp = __dn_comp SIGFE
+__dn_comp SIGFE
+dn_expand = __dn_expand SIGFE
+__dn_expand SIGFE
+dn_skipname = __dn_skipname SIGFE
+__dn_skipname SIGFE
+dprintf SIGFE
+drand48 NOSIGFE
+drem NOSIGFE
+dremf NOSIGFE
+dup SIGFE
+dup2 SIGFE
+dup3 SIGFE
+eaccess = euidaccess SIGFE
+ecvt SIGFE
+ecvtbuf SIGFE
+ecvtf SIGFE
+endgrent NOSIGFE
+endhostent NOSIGFE
+endmntent NOSIGFE
+endprotoent = cygwin_endprotoent SIGFE
+endpwent NOSIGFE
+endservent = cygwin_endservent SIGFE
+endusershell SIGFE
+endutent SIGFE
+endutxent SIGFE
+envz_add SIGFE
+envz_entry NOSIGFE
+envz_get NOSIGFE
+envz_merge SIGFE
+envz_remove SIGFE
+envz_strip SIGFE
+__eprintf SIGFE
+erand48 NOSIGFE
+erf NOSIGFE
+erfc NOSIGFE
+erfcf NOSIGFE
+erff NOSIGFE
+err SIGFE
+__errno NOSIGFE
+error SIGFE
+error_at_line SIGFE
+errx SIGFE
+euidaccess SIGFE
+execl SIGFE
+execle SIGFE
+execlp SIGFE
+execv SIGFE
+execve SIGFE
+execvp SIGFE
+execvpe SIGFE
+exit = cygwin_exit SIGFE
+_exit SIGFE
+exp NOSIGFE
+exp10 NOSIGFE
+exp10f NOSIGFE
+exp2 NOSIGFE
+exp2f NOSIGFE
+expf NOSIGFE
+expm1 NOSIGFE
+expm1f NOSIGFE
+fabs NOSIGFE
+fabsf NOSIGFE
+faccessat SIGFE
+facl SIGFE
+fchdir SIGFE
+fchmod SIGFE
+fchmodat SIGFE
+fchown SIGFE
+fchownat SIGFE
+fclose SIGFE
+fcloseall SIGFE
+fcntl SIGFE
+fcvt SIGFE
+fcvtbuf SIGFE
+fcvtf SIGFE
+fdatasync SIGFE
+fdim NOSIGFE
+fdimf NOSIGFE
+fdopen SIGFE
+fdopendir SIGFE
+feclearexcept NOSIGFE
+fedisableexcept NOSIGFE
+feenableexcept SIGFE
+fegetenv NOSIGFE
+fegetexcept NOSIGFE
+fegetexceptflag NOSIGFE
+fegetprec NOSIGFE
+fegetround NOSIGFE
+feholdexcept SIGFE
+_feinitialise NOSIGFE
+feof SIGFE
+feraiseexcept SIGFE
+ferror SIGFE
+fesetenv SIGFE
+fesetexceptflag SIGFE
+fesetprec NOSIGFE
+fesetround NOSIGFE
+fetestexcept NOSIGFE
+feupdateenv SIGFE
+fexecve SIGFE
+fflush SIGFE
+ffs NOSIGFE
+fgetc SIGFE
+fgetpos SIGFE
+fgets SIGFE
+fgetwc SIGFE
+fgetws SIGFE
+fgetxattr SIGFE
+fileno SIGFE
+finite NOSIGFE
+finitef NOSIGFE
+fiprintf SIGFE
+flistxattr SIGFE
+flock SIGFE
+flockfile SIGFE
+floor NOSIGFE
+floorf NOSIGFE
+fma NOSIGFE
+fmaf NOSIGFE
+fmax NOSIGFE
+fmaxf NOSIGFE
+fmemopen SIGFE
+fmin NOSIGFE
+fminf NOSIGFE
+fmod NOSIGFE
+fmodf NOSIGFE
+fnmatch NOSIGFE
+fopen SIGFE
+fopencookie SIGFE
+fork SIGFE
+forkpty SIGFE
+fpathconf SIGFE
+__fpclassifyd NOSIGFE
+__fpclassifyf NOSIGFE
+fprintf SIGFE
+fpurge SIGFE
+__fpurge SIGFE
+fputc SIGFE
+fputs SIGFE
+fputwc SIGFE
+fputws SIGFE
+fread SIGFE
+free SIGFE
+freeaddrinfo = cygwin_freeaddrinfo SIGFE
+freeifaddrs SIGFE
+fremovexattr SIGFE
+freopen SIGFE
+frexp NOSIGFE
+frexpf NOSIGFE
+fscanf SIGFE
+_fscanf_r SIGFE
+fseek SIGFE
+fseeko SIGFE
+fsetpos SIGFE
+fsetxattr SIGFE
+fstat SIGFE
+fstatat SIGFE
+fstatfs SIGFE
+fstatvfs SIGFE
+fsync SIGFE
+ftell SIGFE
+ftello SIGFE
+ftime SIGFE
+ftok SIGFE
+ftruncate SIGFE
+ftrylockfile SIGFE
+fts_children SIGFE
+fts_close SIGFE
+fts_get_clientptr NOSIGFE
+fts_get_stream NOSIGFE
+fts_open SIGFE
+fts_read SIGFE
+fts_set NOSIGFE
+fts_set_clientptr NOSIGFE
+ftw SIGFE
+funlockfile SIGFE
+funopen SIGFE
+futimens SIGFE
+futimes SIGFE
+futimesat SIGFE
+fwide SIGFE
+fwprintf SIGFE
+fwrite SIGFE
+fwscanf SIGFE
+gai_strerror = cygwin_gai_strerror NOSIGFE
+gamma NOSIGFE
+gamma_r NOSIGFE
+gammaf NOSIGFE
+gammaf_r NOSIGFE
+gcvt SIGFE
+gcvtf SIGFE
+get_avphys_pages SIGFE
+get_current_dir_name SIGFE
+get_nprocs SIGFE
+get_nprocs_conf SIGFE
+_get_osfhandle SIGFE
+get_phys_pages SIGFE
+getaddrinfo = cygwin_getaddrinfo SIGFE
+getc SIGFE
+getc_unlocked SIGFE
+getchar SIGFE
+getchar_unlocked SIGFE
+getcwd SIGFE
+getdelim = __getdelim SIGFE
+getdomainname SIGFE
+getdtablesize NOSIGFE
+getegid NOSIGFE
+getenv NOSIGFE
+geteuid NOSIGFE
+getgid NOSIGFE
+getgrent SIGFE
+getgrgid SIGFE
+getgrgid_r SIGFE
+getgrnam SIGFE
+getgrnam_r SIGFE
+getgrouplist SIGFE
+getgroups SIGFE
+gethostbyaddr = cygwin_gethostbyaddr SIGFE
+gethostbyname = cygwin_gethostbyname SIGFE
+gethostbyname2 SIGFE
+gethostid SIGFE
+gethostname = cygwin_gethostname SIGFE
+getifaddrs SIGFE
+getitimer SIGFE
+getline = __getline SIGFE
+getlogin NOSIGFE
+getlogin_r NOSIGFE
+getmntent SIGFE
+getmntent_r SIGFE
+getmode SIGFE
+getnameinfo = cygwin_getnameinfo SIGFE
+getopt SIGFE
+getopt_long SIGFE
+getopt_long_only SIGFE
+getpagesize SIGFE
+getpass SIGFE
+getpeereid SIGFE
+getpeername = cygwin_getpeername SIGFE
+getpgid SIGFE
+getpgrp SIGFE
+getpid NOSIGFE
+getppid NOSIGFE
+getpriority SIGFE
+getprogname NOSIGFE
+getprotobyname = cygwin_getprotobyname SIGFE
+getprotobynumber = cygwin_getprotobynumber SIGFE
+getprotoent = cygwin_getprotoent SIGFE
+getpt SIGFE
+getpwent SIGFE
+getpwnam SIGFE
+getpwnam_r SIGFE
+getpwuid SIGFE
+getpwuid_r SIGFE
+__getreent NOSIGFE
+getrlimit SIGFE
+getrusage SIGFE
+gets SIGFE
+getservbyname = cygwin_getservbyname SIGFE
+getservbyport = cygwin_getservbyport SIGFE
+getservent = cygwin_getservent SIGFE
+getsid SIGFE
+getsockname = cygwin_getsockname SIGFE
+getsockopt = cygwin_getsockopt SIGFE
+getsubopt NOSIGFE
+gettimeofday SIGFE
+getuid NOSIGFE
+getusershell SIGFE
+getutent SIGFE
+getutid SIGFE
+getutline SIGFE
+getutxent SIGFE
+getutxid SIGFE
+getutxline SIGFE
+getw SIGFE
+getwc SIGFE
+getwchar SIGFE
+getwd SIGFE
+getxattr SIGFE
+glob SIGFE
+glob_pattern_p
+globfree SIGFE
+gmtime SIGFE
+gmtime_r SIGFE
+grantpt NOSIGFE
+hcreate SIGFE
+hcreate_r SIGFE
+hdestroy SIGFE
+hdestroy_r SIGFE
+herror = cygwin_herror SIGFE
+hsearch SIGFE
+hsearch_r SIGFE
+hstrerror = cygwin_hstrerror NOSIGFE
+htonl NOSIGFE
+htons NOSIGFE
+hypot NOSIGFE
+hypotf NOSIGFE
+if_freenameindex SIGFE
+if_indextoname SIGFE
+if_nameindex SIGFE
+if_nametoindex SIGFE
+ilogb NOSIGFE
+ilogbf NOSIGFE
+imaxabs = llabs NOSIGFE
+imaxdiv = lldiv NOSIGFE
+index NOSIGFE
+inet_addr = cygwin_inet_addr SIGFE
+inet_aton = cygwin_inet_aton SIGFE
+inet_makeaddr NOSIGFE
+inet_netof NOSIGFE
+inet_network = cygwin_inet_network SIGFE
+inet_ntoa = cygwin_inet_ntoa SIGFE
+inet_ntop = cygwin_inet_ntop SIGFE
+inet_pton = cygwin_inet_pton SIGFE
+infinity NOSIGFE
+__infinity NOSIGFE
+infinityf NOSIGFE
+initgroups SIGFE
+initstate NOSIGFE
+insque NOSIGFE
+ioctl SIGFE
+iprintf SIGFE
+iruserok SIGFE
+iruserok_sa SIGFE
+isalnum NOSIGFE
+isalpha NOSIGFE
+isascii NOSIGFE
+isatty SIGFE
+isblank NOSIGFE
+iscntrl NOSIGFE
+isdigit NOSIGFE
+isgraph NOSIGFE
+isinf NOSIGFE
+__isinfd NOSIGFE
+isinff NOSIGFE
+__isinff NOSIGFE
+islower NOSIGFE
+isnan NOSIGFE
+__isnand NOSIGFE
+isnanf NOSIGFE
+__isnanf NOSIGFE
+isprint NOSIGFE
+ispunct NOSIGFE
+isspace NOSIGFE
+isupper NOSIGFE
+iswalnum NOSIGFE
+iswalpha NOSIGFE
+iswblank NOSIGFE
+iswcntrl NOSIGFE
+iswctype NOSIGFE
+iswdigit NOSIGFE
+iswgraph NOSIGFE
+iswlower NOSIGFE
+iswprint NOSIGFE
+iswpunct NOSIGFE
+iswspace NOSIGFE
+iswupper NOSIGFE
+iswxdigit NOSIGFE
+isxdigit NOSIGFE
+j0 NOSIGFE
+j0f NOSIGFE
+j1 NOSIGFE
+j1f NOSIGFE
+jn NOSIGFE
+jnf NOSIGFE
+jrand48 NOSIGFE
+kill SIGFE
+killpg SIGFE
+l64a NOSIGFE
+labs NOSIGFE
+lchown SIGFE
+lcong48 NOSIGFE
+ldexp NOSIGFE
+ldexpf NOSIGFE
+ldiv NOSIGFE
+lfind NOSIGFE
+lgamma NOSIGFE
+lgamma_r NOSIGFE
+lgammaf NOSIGFE
+lgammaf_r NOSIGFE
+lgetxattr SIGFE
+link SIGFE
+linkat SIGFE
+listen = cygwin_listen SIGFE
+listxattr SIGFE
+llabs NOSIGFE
+lldiv NOSIGFE
+llistxattr SIGFE
+llrint NOSIGFE
+llrintf NOSIGFE
+llround NOSIGFE
+llroundf NOSIGFE
+__locale_mb_cur_max NOSIGFE
+localeconv NOSIGFE
+localtime SIGFE
+localtime_r SIGFE
+lockf SIGFE
+log NOSIGFE
+log10 NOSIGFE
+log10f NOSIGFE
+log1p NOSIGFE
+log1pf NOSIGFE
+log2 NOSIGFE
+log2f NOSIGFE
+logb NOSIGFE
+logbf NOSIGFE
+logf NOSIGFE
+login SIGFE
+login_tty SIGFE
+logout SIGFE
+logwtmp SIGFE
+longjmp NOSIGFE
+lrand48 NOSIGFE
+lremovexattr SIGFE
+lrint NOSIGFE
+lrintf NOSIGFE
+lround NOSIGFE
+lroundf NOSIGFE
+lsearch NOSIGFE
+lseek SIGFE
+lsetxattr SIGFE
+lstat SIGFE
+lutimes SIGFE
+__main NOSIGFE
+madvise = posix_madvise SIGFE
+mallinfo SIGFE
+malloc SIGFE
+malloc_stats SIGFE
+malloc_trim SIGFE
+malloc_usable_size SIGFE
+mallopt SIGFE
+matherr NOSIGFE
+mblen NOSIGFE
+mbrlen NOSIGFE
+mbrtowc NOSIGFE
+mbsinit NOSIGFE
+mbsnrtowcs NOSIGFE
+mbsrtowcs NOSIGFE
+mbstowcs NOSIGFE
+mbtowc NOSIGFE
+memalign SIGFE
+memccpy NOSIGFE
+memchr NOSIGFE
+memcmp NOSIGFE
+memcpy NOSIGFE
+memmem NOSIGFE
+memmove NOSIGFE
+mempcpy NOSIGFE
+memrchr NOSIGFE
+memset NOSIGFE
+mkdir SIGFE
+mkdirat SIGFE
+mkdtemp SIGFE
+mkfifo SIGFE
+mkfifoat SIGFE
+mknod SIGFE
+mknodat SIGFE
+mkostemp SIGFE
+mkostemps SIGFE
+mkstemp SIGFE
+mkstemps SIGFE
+mktemp SIGFE
+mktime SIGFE
+mlock SIGFE
+mmap SIGFE
+modf NOSIGFE
+modff NOSIGFE
+mount SIGFE
+mprotect SIGFE
+mq_close SIGFE
+mq_getattr SIGFE
+mq_notify SIGFE
+mq_open SIGFE
+mq_receive SIGFE
+mq_send SIGFE
+mq_setattr SIGFE
+mq_timedreceive SIGFE
+mq_timedsend SIGFE
+mq_unlink SIGFE
+mrand48 NOSIGFE
+msgctl SIGFE
+msgget SIGFE
+msgrcv SIGFE
+msgsnd SIGFE
+msync SIGFE
+munlock SIGFE
+munmap SIGFE
+nan NOSIGFE
+nanf NOSIGFE
+nanosleep SIGFE
+nearbyint NOSIGFE
+nearbyintf NOSIGFE
+nextafter NOSIGFE
+nextafterf NOSIGFE
+nftw SIGFE
+nice SIGFE
+nl_langinfo SIGFE
+nrand48 NOSIGFE
+ntohl NOSIGFE
+ntohs NOSIGFE
+on_exit SIGFE
+open SIGFE
+open_memstream SIGFE
+open_wmemstream SIGFE
+openat SIGFE
+opendir SIGFE
+__opendir_with_d_ino SIGFE
+openlog SIGFE
+openpty SIGFE
+pathconf SIGFE
+pause SIGFE
+pclose SIGFE
+perror SIGFE
+pipe SIGFE
+_pipe SIGFE
+pipe2 SIGFE
+poll SIGFE
+popen SIGFE
+posix_fadvise SIGFE
+posix_fallocate SIGFE
+posix_madvise SIGFE
+posix_memalign SIGFE
+posix_openpt SIGFE
+pow NOSIGFE
+pow10 NOSIGFE
+pow10f NOSIGFE
+powf NOSIGFE
+ppoll SIGFE
+pread SIGFE
+printf SIGFE
+pselect SIGFE
+psiginfo SIGFE
+psignal SIGFE
+pthread_atfork SIGFE
+pthread_attr_destroy SIGFE
+pthread_attr_getdetachstate SIGFE
+pthread_attr_getguardsize SIGFE
+pthread_attr_getinheritsched SIGFE
+pthread_attr_getschedparam SIGFE
+pthread_attr_getschedpolicy SIGFE
+pthread_attr_getscope SIGFE
+pthread_attr_getstack SIGFE
+pthread_attr_getstackaddr SIGFE
+pthread_attr_getstacksize SIGFE
+pthread_attr_init SIGFE
+pthread_attr_setdetachstate SIGFE
+pthread_attr_setguardsize SIGFE
+pthread_attr_setinheritsched SIGFE
+pthread_attr_setschedparam SIGFE
+pthread_attr_setschedpolicy SIGFE
+pthread_attr_setscope SIGFE
+pthread_attr_setstack SIGFE
+pthread_attr_setstackaddr SIGFE
+pthread_attr_setstacksize SIGFE
+pthread_cancel SIGFE
+_pthread_cleanup_pop SIGFE
+_pthread_cleanup_push SIGFE
+pthread_cond_broadcast SIGFE
+pthread_cond_destroy SIGFE
+pthread_cond_init SIGFE
+pthread_cond_signal SIGFE
+pthread_cond_timedwait SIGFE
+pthread_cond_wait SIGFE
+pthread_condattr_destroy SIGFE
+pthread_condattr_getclock SIGFE
+pthread_condattr_getpshared SIGFE
+pthread_condattr_init SIGFE
+pthread_condattr_setclock SIGFE
+pthread_condattr_setpshared SIGFE
+pthread_continue SIGFE
+pthread_create SIGFE
+pthread_detach SIGFE
+pthread_equal SIGFE
+pthread_exit SIGFE
+pthread_getattr_np SIGFE
+pthread_getconcurrency SIGFE
+pthread_getcpuclockid SIGFE
+pthread_getschedparam SIGFE
+pthread_getsequence_np SIGFE
+pthread_getspecific SIGFE
+pthread_join SIGFE
+pthread_key_create SIGFE
+pthread_key_delete SIGFE
+pthread_kill SIGFE
+pthread_mutex_destroy SIGFE
+pthread_mutex_getprioceiling SIGFE
+pthread_mutex_init SIGFE
+pthread_mutex_lock SIGFE
+pthread_mutex_setprioceiling SIGFE
+pthread_mutex_trylock SIGFE
+pthread_mutex_unlock SIGFE
+pthread_mutexattr_destroy SIGFE
+pthread_mutexattr_getprioceiling SIGFE
+pthread_mutexattr_getprotocol SIGFE
+pthread_mutexattr_getpshared SIGFE
+pthread_mutexattr_gettype SIGFE
+pthread_mutexattr_init SIGFE
+pthread_mutexattr_setprioceiling SIGFE
+pthread_mutexattr_setprotocol SIGFE
+pthread_mutexattr_setpshared SIGFE
+pthread_mutexattr_settype SIGFE
+pthread_once SIGFE
+pthread_rwlock_destroy SIGFE
+pthread_rwlock_init SIGFE
+pthread_rwlock_rdlock SIGFE
+pthread_rwlock_tryrdlock SIGFE
+pthread_rwlock_trywrlock SIGFE
+pthread_rwlock_unlock SIGFE
+pthread_rwlock_wrlock SIGFE
+pthread_rwlockattr_destroy SIGFE
+pthread_rwlockattr_getpshared SIGFE
+pthread_rwlockattr_init SIGFE
+pthread_rwlockattr_setpshared SIGFE
+pthread_self SIGFE
+pthread_setcancelstate SIGFE
+pthread_setcanceltype SIGFE
+pthread_setconcurrency SIGFE
+pthread_setschedparam SIGFE
+pthread_setschedprio SIGFE
+pthread_setspecific SIGFE
+pthread_sigmask SIGFE
+pthread_sigqueue SIGFE
+pthread_suspend SIGFE
+pthread_spin_destroy SIGFE
+pthread_spin_init SIGFE
+pthread_spin_lock SIGFE
+pthread_spin_trylock SIGFE
+pthread_spin_unlock SIGFE
+pthread_testcancel SIGFE
+pthread_yield = sched_yield SIGFE
+ptsname SIGFE
+ptsname_r SIGFE
+putc SIGFE
+putc_unlocked SIGFE
+putchar SIGFE
+putchar_unlocked SIGFE
+putenv SIGFE
+puts SIGFE
+pututline SIGFE
+pututxline SIGFE
+putw SIGFE
+putwc SIGFE
+putwchar SIGFE
+pwrite SIGFE
+qsort NOSIGFE
+raise SIGFE
+rand NOSIGFE
+rand_r NOSIGFE
+random NOSIGFE
+rcmd = cygwin_rcmd SIGFE
+rcmd_af = cygwin_rcmd_af SIGFE
+read SIGFE
+readdir SIGFE
+readdir_r SIGFE
+readlink SIGFE
+readlinkat SIGFE
+readv SIGFE
+realloc SIGFE
+reallocf SIGFE
+realpath SIGFE
+recv = cygwin_recv SIGFE
+recvfrom = cygwin_recvfrom SIGFE
+recvmsg = cygwin_recvmsg SIGFE
+regcomp SIGFE
+regerror SIGFE
+regexec SIGFE
+regfree SIGFE
+remainder NOSIGFE
+remainderf NOSIGFE
+remove SIGFE
+removexattr SIGFE
+remque NOSIGFE
+remquo NOSIGFE
+remquof NOSIGFE
+rename SIGFE
+renameat SIGFE
+res_close = __res_close SIGFE
+__res_close SIGFE
+res_init = __res_init SIGFE
+__res_init SIGFE
+res_mkquery = __res_mkquery SIGFE
+__res_mkquery SIGFE
+res_nclose = __res_nclose SIGFE
+__res_nclose SIGFE
+res_ninit = __res_ninit SIGFE
+__res_ninit SIGFE
+res_nmkquery = __res_nmkquery SIGFE
+__res_nmkquery SIGFE
+res_nquery = __res_nquery SIGFE
+__res_nquery SIGFE
+res_nquerydomain = __res_nquerydomain SIGFE
+__res_nquerydomain SIGFE
+res_nsearch = __res_nsearch SIGFE
+__res_nsearch SIGFE
+res_nsend = __res_nsend SIGFE
+__res_nsend SIGFE
+res_query = __res_query SIGFE
+__res_query SIGFE
+res_querydomain = __res_querydomain SIGFE
+__res_querydomain SIGFE
+res_search = __res_search SIGFE
+__res_search SIGFE
+res_send = __res_send SIGFE
+__res_send SIGFE
+__res_state SIGFE
+revoke SIGFE
+rewind SIGFE
+rewinddir SIGFE
+rexec = cygwin_rexec SIGFE
+rindex NOSIGFE
+rint NOSIGFE
+rintf NOSIGFE
+rmdir SIGFE
+round NOSIGFE
+roundf NOSIGFE
+rresvport = cygwin_rresvport SIGFE
+rresvport_af = cygwin_rresvport_af SIGFE
+ruserok SIGFE
+sbrk SIGFE
+scalb NOSIGFE
+scalbf NOSIGFE
+scalbln NOSIGFE
+scalblnf NOSIGFE
+scalbn NOSIGFE
+scalbnf NOSIGFE
+scandir SIGFE
+scandirat SIGFE
+scanf SIGFE
+sched_get_priority_max SIGFE
+sched_get_priority_min SIGFE
+sched_getparam SIGFE
+sched_getscheduler NOSIGFE
+sched_rr_get_interval SIGFE
+sched_setparam SIGFE
+sched_setscheduler SIGFE
+sched_yield SIGFE
+seed48 NOSIGFE
+seekdir SIGFE
+select = cygwin_select SIGFE
+sem_close SIGFE
+sem_destroy SIGFE
+sem_getvalue SIGFE
+sem_init SIGFE
+sem_open SIGFE
+sem_post SIGFE
+sem_timedwait SIGFE
+sem_trywait SIGFE
+sem_unlink SIGFE
+sem_wait SIGFE
+semctl SIGFE
+semget SIGFE
+semop SIGFE
+send = cygwin_send SIGFE
+sendmsg = cygwin_sendmsg SIGFE
+sendto = cygwin_sendto SIGFE
+setbuf SIGFE
+setbuffer SIGFE
+setdtablesize SIGFE
+setegid SIGFE
+setenv SIGFE
+seteuid SIGFE
+setgid SIGFE
+setgrent NOSIGFE
+setgroups SIGFE
+sethostent NOSIGFE
+setitimer SIGFE
+setjmp NOSIGFE
+setlinebuf SIGFE
+setlocale NOSIGFE
+setlogmask NOSIGFE
+setmntent SIGFE
+_setmode = cygwin_setmode SIGFE
+setpassent NOSIGFE
+setpgid SIGFE
+setpgrp SIGFE
+setpriority SIGFE
+setprogname NOSIGFE
+setprotoent = cygwin_setprotoent SIGFE
+setpwent NOSIGFE
+setregid SIGFE
+setreuid SIGFE
+setrlimit SIGFE
+setservent = cygwin_setservent SIGFE
+setsid SIGFE
+setsockopt = cygwin_setsockopt SIGFE
+setstate NOSIGFE
+settimeofday SIGFE
+setuid SIGFE
+setusershell SIGFE
+setutent SIGFE
+setutxent SIGFE
+setvbuf SIGFE
+setxattr SIGFE
+shm_open SIGFE
+shm_unlink SIGFE
+shmat SIGFE
+shmctl SIGFE
+shmdt SIGFE
+shmget SIGFE
+shutdown = cygwin_shutdown SIGFE
+sigaction SIGFE
+sigaddset SIGFE
+sigdelset SIGFE
+sigemptyset NOSIGFE
+sigfillset NOSIGFE
+sighold SIGFE
+sigignore SIGFE
+siginterrupt SIGFE
+sigismember SIGFE
+signal SIGFE
+__signbitd NOSIGFE
+__signbitf NOSIGFE
+__signgam NOSIGFE
+significand NOSIGFE
+significandf NOSIGFE
+sigpause SIGFE
+sigpending SIGFE
+sigprocmask SIGFE
+sigqueue SIGFE
+sigrelse SIGFE
+sigset SIGFE
+sigsuspend SIGFE
+sigwait SIGFE
+sigwaitinfo SIGFE
+sin NOSIGFE
+sincos NOSIGFE
+sincosf NOSIGFE
+sinf NOSIGFE
+sinh NOSIGFE
+sinhf NOSIGFE
+siprintf SIGFE
+sleep SIGFE
+snprintf SIGFE
+socket = cygwin_socket SIGFE
+socketpair SIGFE
+spawnl SIGFE
+spawnle SIGFE
+spawnlp SIGFE
+spawnlpe SIGFE
+spawnv SIGFE
+spawnve SIGFE
+spawnvp SIGFE
+spawnvpe SIGFE
+sprintf SIGFE
+sqrt NOSIGFE
+sqrtf NOSIGFE
+srand NOSIGFE
+srand48 NOSIGFE
+srandom NOSIGFE
+__srget SIGFE
+__srget_r SIGFE
+sscanf SIGFE
+stat SIGFE
+statfs SIGFE
+statvfs SIGFE
+stpcpy NOSIGFE
+stpncpy NOSIGFE
+strcasecmp NOSIGFE
+strcasestr NOSIGFE
+strcat NOSIGFE
+strchr NOSIGFE
+strchrnul NOSIGFE
+strcmp NOSIGFE
+strcoll NOSIGFE
+strcpy NOSIGFE
+strcspn NOSIGFE
+strdup SIGFE
+strerror SIGFE
+strerror_r SIGFE
+strfmon SIGFE
+strftime SIGFE
+strlcat NOSIGFE
+strlcpy NOSIGFE
+strlen NOSIGFE
+strlwr NOSIGFE
+strncasecmp NOSIGFE
+strncat NOSIGFE
+strncmp NOSIGFE
+strncpy NOSIGFE
+strndup SIGFE
+strnlen NOSIGFE
+strpbrk NOSIGFE
+strptime SIGFE
+strrchr NOSIGFE
+strsep NOSIGFE
+strsignal SIGFE
+strspn NOSIGFE
+strstr NOSIGFE
+strtod SIGFE
+strtof SIGFE
+strtoimax = strtoll NOSIGFE
+strtok NOSIGFE
+strtok_r NOSIGFE
+strtol NOSIGFE
+strtold = _strtold SIGFE
+strtoll NOSIGFE
+strtosigno NOSIGFE
+strtoul NOSIGFE
+strtoull NOSIGFE
+strtoumax = strtoull NOSIGFE
+strupr NOSIGFE
+strxfrm NOSIGFE
+swab NOSIGFE
+__swbuf SIGFE
+__swbuf_r SIGFE
+swprintf SIGFE
+swscanf SIGFE
+symlink SIGFE
+symlinkat SIGFE
+sync SIGFE
+sysconf SIGFE
+sysinfo SIGFE
+syslog SIGFE
+system SIGFE
+tan NOSIGFE
+tanf NOSIGFE
+tanh NOSIGFE
+tanhf NOSIGFE
+tcdrain SIGFE
+tcflow SIGFE
+tcflush SIGFE
+tcgetattr SIGFE
+tcgetpgrp SIGFE
+tcgetsid SIGFE
+tcsendbreak SIGFE
+tcsetattr SIGFE
+tcsetpgrp SIGFE
+tdelete SIGFE
+tdestroy NOSIGFE
+telldir SIGFE
+tempnam SIGFE
+tfind NOSIGFE
+tgamma NOSIGFE
+tgammaf NOSIGFE
+time SIGFE
+timegm NOSIGFE
+timelocal SIGFE
+timer_create SIGFE
+timer_delete SIGFE
+timer_gettime SIGFE
+timer_settime SIGFE
+times SIGFE
+timezone SIGFE
+tmpfile SIGFE
+tmpnam SIGFE
+toascii NOSIGFE
+tolower NOSIGFE
+toupper NOSIGFE
+towctrans NOSIGFE
+towlower NOSIGFE
+towupper NOSIGFE
+trunc NOSIGFE
+truncate SIGFE
+truncf NOSIGFE
+tsearch SIGFE
+ttyname SIGFE
+ttyname_r SIGFE
+ttyslot NOSIGFE
+twalk NOSIGFE
+tzset SIGFE
+ualarm SIGFE
+umask NOSIGFE
+umount SIGFE
+uname SIGFE
+ungetc SIGFE
+ungetwc SIGFE
+unlink SIGFE
+unlinkat SIGFE
+unlockpt NOSIGFE
+unsetenv SIGFE
+updwtmp SIGFE
+updwtmpx SIGFE
+usleep SIGFE
+utime SIGFE
+utimensat SIGFE
+utimes SIGFE
+utmpname SIGFE
+utmpxname SIGFE
+valloc SIGFE
+vasnprintf SIGFE
+vasprintf SIGFE
+vdprintf SIGFE
+verr SIGFE
+verrx SIGFE
+vfiprintf SIGFE
+vfork SIGFE
+vfprintf SIGFE
+vfscanf SIGFE
+vfwprintf SIGFE
+vfwscanf SIGFE
+vhangup SIGFE
+vprintf SIGFE
+vscanf SIGFE
+vsnprintf SIGFE
+vsprintf SIGFE
+vsscanf SIGFE
+vswprintf SIGFE
+vswscanf SIGFE
+vsyslog SIGFE
+vwarn SIGFE
+vwarnx SIGFE
+vwprintf SIGFE
+vwscanf SIGFE
+wait SIGFE
+wait3 SIGFE
+wait4 SIGFE
+waitpid SIGFE
+warn SIGFE
+warnx SIGFE
+wcpcpy NOSIGFE
+wcpncpy NOSIGFE
+wcrtomb NOSIGFE
+wcscasecmp NOSIGFE
+wcscat NOSIGFE
+wcschr NOSIGFE
+wcscmp NOSIGFE
+wcscoll NOSIGFE
+wcscpy NOSIGFE
+wcscspn NOSIGFE
+wcsdup NOSIGFE
+wcsftime SIGFE
+wcslcat NOSIGFE
+wcslcpy NOSIGFE
+wcslen NOSIGFE
+wcsncasecmp NOSIGFE
+wcsncat NOSIGFE
+wcsncmp NOSIGFE
+wcsncpy NOSIGFE
+wcsnlen NOSIGFE
+wcsnrtombs NOSIGFE
+wcspbrk NOSIGFE
+wcsrchr NOSIGFE
+wcsrtombs NOSIGFE
+wcsspn NOSIGFE
+wcsstr NOSIGFE
+wcstod NOSIGFE
+wcstof NOSIGFE
+wcstoimax = wcstoll NOSIGFE
+wcstok NOSIGFE
+wcstol NOSIGFE
+wcstoll NOSIGFE
+wcstombs NOSIGFE
+wcstoul NOSIGFE
+wcstoull NOSIGFE
+wcstoumax = wcstoull NOSIGFE
+wcswidth NOSIGFE
+wcsxfrm NOSIGFE
+wctob NOSIGFE
+wctomb NOSIGFE
+wctrans NOSIGFE
+wctype NOSIGFE
+wcwidth NOSIGFE
+wmemchr NOSIGFE
+wmemcmp NOSIGFE
+wmemcpy NOSIGFE
+wmemmove NOSIGFE
+wmemset NOSIGFE
+wordexp NOSIGFE
+wordfree NOSIGFE
+wprintf SIGFE
+write SIGFE
+writev SIGFE
+wscanf SIGFE
+xdr_array SIGFE
+xdr_bool SIGFE
+xdr_bytes SIGFE
+xdr_char SIGFE
+xdr_double SIGFE
+xdr_enum SIGFE
+xdr_float SIGFE
+xdr_free SIGFE
+xdr_hyper SIGFE
+xdr_int SIGFE
+xdr_int16_t SIGFE
+xdr_int32_t SIGFE
+xdr_int64_t SIGFE
+xdr_int8_t SIGFE
+xdr_long SIGFE
+xdr_longlong_t SIGFE
+xdr_netobj SIGFE
+xdr_opaque SIGFE
+xdr_pointer SIGFE
+xdr_reference SIGFE
+xdr_short SIGFE
+xdr_sizeof SIGFE
+xdr_string SIGFE
+xdr_u_char SIGFE
+xdr_u_hyper SIGFE
+xdr_u_int SIGFE
+xdr_u_int16_t SIGFE
+xdr_u_int32_t SIGFE
+xdr_u_int64_t SIGFE
+xdr_u_int8_t SIGFE
+xdr_u_long SIGFE
+xdr_u_longlong_t SIGFE
+xdr_u_short SIGFE
+xdr_uint16_t SIGFE
+xdr_uint32_t SIGFE
+xdr_uint64_t SIGFE
+xdr_uint8_t SIGFE
+xdr_union SIGFE
+xdr_vector SIGFE
+xdr_void SIGFE
+xdr_wrapstring SIGFE
+xdrmem_create SIGFE
+xdrrec_create SIGFE
+xdrrec_endofrecord SIGFE
+xdrrec_eof SIGFE
+xdrrec_skiprecord SIGFE
+__xdrrec_getrec SIGFE
+__xdrrec_setnonblock SIGFE
+xdrstdio_create SIGFE
+__xpg_strerror_r SIGFE
+y0 NOSIGFE
+y0f NOSIGFE
+y1 NOSIGFE
+y1f NOSIGFE
+yn NOSIGFE
+ynf NOSIGFE
+__wrap__ZdaPv NOSIGFE               # void operator delete[](void *p) throw()
+__wrap__ZdaPvRKSt9nothrow_t NOSIGFE # void operator delete[](void *p, const std::nothrow_t &nt) throw()
+__wrap__ZdlPv NOSIGFE               # void operator delete(void *p) throw()
+__wrap__ZdlPvRKSt9nothrow_t NOSIGFE # void operator delete(void *p, const std::nothrow_t &nt) throw()
+__wrap__Znam NOSIGFE                # void *operator new[](std::size_t sz) throw (std::bad_alloc)
+__wrap__ZnamRKSt9nothrow_t NOSIGFE  # void *operator new[](std::size_t sz, const std::nothrow_t &nt) throw()
+__wrap__Znwm NOSIGFE                # void *operator new(std::size_t sz) throw (std::bad_alloc)
+__wrap__ZnwmRKSt9nothrow_t NOSIGFE  # void *operator new(std::size_t sz, const std::nothrow_t &nt) throw()
index c2684dee7f7eecce0319a87f465b542f16dff3fb..0208a941282115d84165f27e9a99d369d99dc019 100644 (file)
@@ -377,17 +377,17 @@ check_sanity_and_sync (per_process *p)
 
   /* Complain if older than last incompatible change */
   if (p->dll_major < CYGWIN_VERSION_DLL_EPOCH)
-    api_fatal ("cygwin DLL and APP are out of sync -- DLL version mismatch %d < %d",
+    api_fatal ("cygwin DLL and APP are out of sync -- DLL version mismatch %u < %u",
               p->dll_major, CYGWIN_VERSION_DLL_EPOCH);
 
   /* magic_biscuit != 0 if using the old style version numbering scheme.  */
   if (p->magic_biscuit != SIZEOF_PER_PROCESS)
-    api_fatal ("Incompatible cygwin .dll -- incompatible per_process info %d != %d",
+    api_fatal ("Incompatible cygwin .dll -- incompatible per_process info %u != %u",
               p->magic_biscuit, SIZEOF_PER_PROCESS);
 
   /* Complain if incompatible API changes made */
   if (p->api_major > cygwin_version.api_major)
-    api_fatal ("cygwin DLL and APP are out of sync -- API version mismatch %d > %d",
+    api_fatal ("cygwin DLL and APP are out of sync -- API version mismatch %u > %u",
               p->api_major, cygwin_version.api_major);
 
   /* This is a kludge to work around a version of _cygwin_common_crt0
@@ -458,8 +458,12 @@ getstack (volatile char * volatile p)
 void
 child_info_fork::alloc_stack ()
 {
-  volatile char * volatile esp;
-  __asm__ volatile ("movl %%esp,%0": "=r" (esp));
+  volatile char * volatile stackp;
+#ifdef __x86_64__
+  __asm__ volatile ("movq %%rsp,%0": "=r" (stackp));
+#else
+  __asm__ volatile ("movl %%esp,%0": "=r" (stackp));
+#endif
   /* Make sure not to try a hard allocation if we have been forked off from
      the main thread of a Cygwin process which has been started from a 64 bit
      parent.  In that case the _tlsbase of the forked child is not the same
@@ -471,18 +475,18 @@ child_info_fork::alloc_stack ()
       && (!wincap.is_wow64 ()
          || stacktop < (char *) NtCurrentTeb ()->DeallocationStack
          || stackbottom > _tlsbase))
-    alloc_stack_hard_way (esp);
+    alloc_stack_hard_way (stackp);
   else
     {
       char *st = (char *) stacktop - 4096;
       while (_tlstop >= st)
-       esp = getstack (esp);
+       stackp = getstack (stackp);
       stackaddr = 0;
       /* This only affects forked children of a process started from a native
         64 bit process, but it doesn't hurt to do it unconditionally.  Fix
         StackBase in the child to be the same as in the parent, so that the
         computation of _my_tls is correct. */
-      _tlsbase = (char *) stackbottom;
+      _tlsbase = (PVOID) stackbottom;
     }
 }
 
@@ -546,8 +550,8 @@ get_cygwin_startup_info ()
       if ((res->intro & OPROC_MAGIC_MASK) == OPROC_MAGIC_GENERIC)
        multiple_cygwin_problem ("proc intro", res->intro, 0);
       else if (res->cygheap != (void *) &_cygheap_start)
-       multiple_cygwin_problem ("cygheap base", (DWORD) res->cygheap,
-                                (DWORD) &_cygheap_start);
+       multiple_cygwin_problem ("cygheap base", (uintptr_t) res->cygheap,
+                                (uintptr_t) &_cygheap_start);
 
       unsigned should_be_cb = 0;
       switch (res->type)
@@ -563,7 +567,8 @@ get_cygwin_startup_info ()
            if (should_be_cb != res->cb)
              multiple_cygwin_problem ("proc size", res->cb, should_be_cb);
            else if (sizeof (fhandler_union) != res->fhandler_union_cb)
-             multiple_cygwin_problem ("fhandler size", res->fhandler_union_cb, sizeof (fhandler_union));
+             multiple_cygwin_problem ("fhandler size", res->fhandler_union_cb,
+                                      sizeof (fhandler_union));
            if (res->isstraced ())
              {
                while (!being_debugged ())
@@ -572,7 +577,7 @@ get_cygwin_startup_info ()
              }
            break;
          default:
-           system_printf ("unknown exec type %d", res->type);
+           system_printf ("unknown exec type %u", res->type);
            /* intentionally fall through */
          case _CH_WHOOPS:
            res = NULL;
@@ -583,10 +588,17 @@ get_cygwin_startup_info ()
   return res;
 }
 
+#ifdef __x86_64__
+#define dll_data_start &__data_start__
+#define dll_data_end &__data_end__
+#define dll_bss_start &__bss_start__
+#define dll_bss_end &__bss_end__
+#else
 #define dll_data_start &_data_start__
 #define dll_data_end &_data_end__
 #define dll_bss_start &_bss_start__
 #define dll_bss_end &_bss_end__
+#endif
 
 void
 child_info_fork::handle_fork ()
@@ -708,7 +720,7 @@ init_windows_system_directory ()
        api_fatal ("can't find windows system directory");
       windows_system_directory[windows_system_directory_length++] = L'\\';
       windows_system_directory[windows_system_directory_length] = L'\0';
-
+#ifndef __x86_64__
       system_wow64_directory_length =
        GetSystemWow64DirectoryW (system_wow64_directory, MAX_PATH);
       if (system_wow64_directory_length)
@@ -716,6 +728,7 @@ init_windows_system_directory ()
          system_wow64_directory[system_wow64_directory_length++] = L'\\';
          system_wow64_directory[system_wow64_directory_length] = L'\0';
        }
+#endif /* !__x86_64__ */
     }
 }
 
@@ -725,7 +738,6 @@ dll_crt0_0 ()
   wincap.init ();
   child_proc_info = get_cygwin_startup_info ();
   init_windows_system_directory ();
-  init_global_security ();
   initial_env ();
 
   SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
@@ -753,12 +765,14 @@ dll_crt0_0 ()
   if (!child_proc_info)
     {
       memory_init (true);
+#ifndef __x86_64__
       /* WOW64 process on XP/64 or Server 2003/64?  Check if we have been
         started from 64 bit process and if our stack is at an unusual
         address.  Set wow64_needs_stack_adjustment if so.  Problem
         description in wow64_test_for_64bit_parent. */
       if (wincap.wow64_has_secondary_stack ())
        wow64_needs_stack_adjustment = wow64_test_for_64bit_parent ();
+#endif /* !__x86_64__ */
     }
   else
     {
@@ -847,7 +861,7 @@ dll_crt0_1 (void *)
        small_printf ("cmalloc returns %p\n", cmalloc (HEAP_STR, n));
       else
        {
-         small_printf ("total allocated %p\n", (i - 1) * n);
+         small_printf ("total allocated %y\n", (i - 1) * n);
          break;
        }
     }
@@ -890,8 +904,8 @@ dll_crt0_1 (void *)
         this step. */
       if (fork_info->stackaddr)
        {
-         _tlsbase = (char *) fork_info->stackbottom;
-         _tlstop = (char *) fork_info->stacktop;
+         _tlsbase = (PVOID) fork_info->stackbottom;
+         _tlstop = (PVOID) fork_info->stacktop;
        }
 
       /* Not resetting _my_tls.incyg here because presumably fork will overwrite
@@ -1015,17 +1029,25 @@ dll_crt0_1 (void *)
       sig_dispatch_pending (false);
       _my_tls.call_signal_handler ();
       _my_tls.incyg--; /* Not in Cygwin anymore */
+#ifdef __x86_64__
+      cygwin_exit (user_data->main (__argc, newargv, __cygwin_environ));
+#else
       cygwin_exit (user_data->main (__argc, newargv, *user_data->envptr));
+#endif
     }
   __asm__ ("                           \n\
+       .global _cygwin_exit_return     \n\
        .global __cygwin_exit_return    \n\
+_cygwin_exit_return:                   \n\
 __cygwin_exit_return:                  \n\
+               nop                     \n\
 ");
 }
 
 extern "C" void __stdcall
 _dll_crt0 ()
 {
+#ifndef __x86_64__
   /* Handle WOW64 process on XP/2K3 which has been started from native 64 bit
      process.  See comment in wow64_test_for_64bit_parent for a full problem
      description. */
@@ -1056,10 +1078,11 @@ _dll_crt0 ()
        /* Fall back to respawn if wow64_revert_to_original_stack fails. */
        wow64_respawn_process ();
     }
-#ifdef __i386__
+#endif /* !__x86_64__ */
   _feinitialise ();
-#endif
+#ifndef __x86_64__
   main_environ = user_data->envptr;
+#endif
   if (in_forkee)
     {
       fork_info->alloc_stack ();
@@ -1092,12 +1115,16 @@ dll_crt0 (per_process *uptr)
 extern "C" void
 cygwin_dll_init ()
 {
+#ifndef __x86_64__
   static char **envp;
+#endif
   static int _fmode;
 
   user_data->magic_biscuit = sizeof (per_process);
 
+#ifndef __x86_64__
   user_data->envptr = &envp;
+#endif
   user_data->fmode_ptr = &_fmode;
 
   _dll_crt0 ();
@@ -1121,7 +1148,7 @@ __main (void)
   sig_dispatch_pending (true);
 }
 
-void __stdcall
+void __reg1
 do_exit (int status)
 {
   syscall_printf ("do_exit (%d), exit_state %d", status, exit_state);
@@ -1173,7 +1200,7 @@ do_exit (int status)
          siginfo_t si = {0};
          si.si_signo = -SIGHUP;
          si.si_code = SI_KERNEL;
-         sigproc_printf ("%d == pgrp %d, send SIG{HUP,CONT} to stopped children",
+         sigproc_printf ("%u == pgrp %u, send SIG{HUP,CONT} to stopped children",
                          myself->pid, myself->pgid);
          kill_pgrp (myself->pgid, si);
        }
@@ -1186,7 +1213,7 @@ do_exit (int status)
       if (getpgrp () > 0 && myself->pid == myself->sid && real_tty_attached (myself))
        {
          tty *tp = cygwin_shared->tty[myself->ctty];
-         sigproc_printf ("%d == sid %d, send SIGHUP to children",
+         sigproc_printf ("%u == sid %u, send SIGHUP to children",
                          myself->pid, myself->sid);
 
        /* CGF FIXME: This can't be right. */
@@ -1249,7 +1276,7 @@ api_fatal (const char *fmt, ...)
 }
 
 void
-multiple_cygwin_problem (const char *what, unsigned magic_version, unsigned version)
+multiple_cygwin_problem (const char *what, uintptr_t magic_version, uintptr_t version)
 {
   if (_cygwin_testing && (strstr (what, "proc") || strstr (what, "cygheap")))
     {
@@ -1261,9 +1288,9 @@ multiple_cygwin_problem (const char *what, unsigned magic_version, unsigned vers
     return;
 
   if (CYGWIN_VERSION_MAGIC_VERSION (magic_version) == version)
-    system_printf ("%s magic number mismatch detected - %p/%p", what, magic_version, version);
+    system_printf ("%s magic number mismatch detected - %p/%ly", what, magic_version, version);
   else
-    api_fatal ("%s mismatch detected - %p/%p.\n\
+    api_fatal ("%s mismatch detected - %ly/%ly.\n\
 This problem is probably due to using incompatible versions of the cygwin DLL.\n\
 Search for cygwin1.dll using the Windows Start->Find/Search facility\n\
 and delete all but the most recent version.  The most recent version *should*\n\
@@ -1278,6 +1305,6 @@ void __stdcall
 cygbench (const char *s)
 {
   if (GetEnvironmentVariableA ("CYGWIN_BENCH", NULL, 0))
-    small_printf ("%05d ***** %s : %10d\n", GetCurrentProcessId (), s, strace.microseconds ());
+    small_printf ("%05u ***** %s : %10d\n", GetCurrentProcessId (), s, strace.microseconds ());
 }
 #endif
index 4550b5cfc4ec03af7bab5ac915cdf01216079635..627c77ed625ef8283f319cc8c065522d60e34a65 100644 (file)
@@ -1,7 +1,7 @@
 /* debug.h
 
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010
-   Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010,
+   2013 Red Hat, Inc.
 
 This software is a copyrighted work licensed under the terms of the
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
@@ -11,7 +11,7 @@ details. */
 #define MALLOC_CHECK do {} while (0)
 #else
 #include <stdlib.h>
-#include "dlmalloc.h"
+#include <malloc.h>
 #define MALLOC_CHECK ({\
   debug_printf ("checking malloc pool");\
   mallinfo ();\
index e2a776a5b2e45baaaad60be35d8b6996303cba77..f2694c283674a4bd9c6106b109494cdd311e9d29 100644 (file)
@@ -70,7 +70,7 @@ exists_ntdev_silent (const device& dev)
 static int
 exists_console (const device& dev)
 {
-  int devn = *const_cast<device *> (&dev);
+  fh_devices devn = *const_cast<device *> (&dev);
   switch (devn)
     {
     case FH_CONSOLE:
@@ -45845,7 +45845,7 @@ device::init ()
 void
 device::parse (_major_t major, _minor_t minor)
 {
-  _dev_t devn = FHDEV (major, minor);
+  dev_t devn = FHDEV (major, minor);
 
   d.devn = 0;
 
@@ -45861,7 +45861,7 @@ device::parse (_major_t major, _minor_t minor)
 }
 
 void
-device::parse (_dev_t dev)
+device::parse (dev_t dev)
 {
   parse (_major (dev), _minor (dev));
 }
index b4886d8989b947f4195ef4e6d01da72e2de713b9..bdddb8ce448dddd8539cce32e7273ebfe1037d7d 100644 (file)
@@ -14,7 +14,6 @@ details. */
 typedef unsigned short _major_t;
 typedef unsigned short _minor_t;
 typedef mode_t _mode_t;
-typedef __dev32_t _dev_t;
 
 #define FHDEV(maj, min) ((((unsigned) (maj)) << (sizeof (_major_t) * 8)) | (unsigned) (min))
 #define _minor(dev) ((dev) & ((1 << (sizeof (_minor_t) * 8)) - 1))
@@ -263,7 +262,7 @@ struct device
   const char *name;
   union __cygwin_dev
   {
-    _dev_t devn;
+    dev_t devn;
     DWORD devn_dword;
     int devn_int;
     fh_devices devn_fh_devices;
@@ -281,7 +280,7 @@ struct device
   static const device *lookup (const char *, unsigned int = UINT32_MAX);
   void parse (const char *);
   void parse (_major_t major, _minor_t minor);
-  void parse (_dev_t dev);
+  void parse (dev_t dev);
   void parsedisk (int, int);
   inline bool setunit (unsigned n)
   {
@@ -290,32 +289,31 @@ struct device
   }
   static void init ();
 
-  static _major_t major (_dev_t n)
+  static _major_t major (dev_t n)
   {
     __cygwin_dev d;
     d.devn = n;
     return d.major;
   }
-  static _minor_t minor (_dev_t n)
+  static _minor_t minor (dev_t n)
   {
     __cygwin_dev d;
     d.devn = n;
     return d.minor;
   }
-  static _major_t major (int n) {return major ((_dev_t) n);}
-  static _minor_t minor (int n) {return minor ((_dev_t) n);}
+  static _major_t major (int n) {return major ((dev_t) n);}
+  static _minor_t minor (int n) {return minor ((dev_t) n);}
 
-  bool is_device (_dev_t n) const {return n == d.devn; }
-  bool not_device (_dev_t n) const {return d.devn && n != d.devn; }
+  bool is_device (dev_t n) const {return n == d.devn; }
+  bool not_device (dev_t n) const {return d.devn && n != d.devn; }
 
   _minor_t get_minor () const {return d.minor;}
   _major_t get_major () const {return d.major;}
-  _dev_t   get_device () const {return d.devn;}
+  dev_t   get_device () const {return d.devn;}
 
-  inline operator int& () {return d.devn_int;}
   inline operator fh_devices () {return d.devn_fh_devices;}
   inline operator bool () {return !!d.devn_int;}
-  inline operator DWORD& () {return d.devn_dword;}
+  inline operator dev_t& () {return d.devn;}
   fh_devices operator = (fh_devices n) {return d.devn_fh_devices = n;}
   inline void setfs (bool x) {dev_on_fs = x;}
   inline bool isfs () const {return dev_on_fs || d.devn == FH_FS;}
@@ -377,9 +375,9 @@ extern const device dev_fs_storage;
   (isproc_dev (devn) || devn == FH_CYGDRIVE || devn == FH_NETDRIVE)
 
 #define iscons_dev(n) \
-  ((device::major ((int) (n)) == DEV_CONS_MAJOR) \
-   || (((int) n) == FH_CONSOLE) \
-   || (((int) n) == FH_CONIN) \
-   || (((int) n) == FH_CONOUT))
+  ((device::major ((dev_t) (n)) == DEV_CONS_MAJOR) \
+   || (((dev_t) n) == FH_CONSOLE) \
+   || (((dev_t) n) == FH_CONIN) \
+   || (((dev_t) n) == FH_CONOUT))
 
 #define istty_slave_dev(n) (device::major (n) == DEV_PTYS_MAJOR)
index 213226ae682eb5bec75196182ebc3d5b4b4a3a47..dd1689fc3452d6e488bbe6c593e1e4048768e41e 100644 (file)
@@ -66,7 +66,7 @@ exists_ntdev_silent (const device& dev)
 static int
 exists_console (const device& dev)
 {
-  int devn = *const_cast<device *> (&dev);
+  fh_devices devn = *const_cast<device *> (&dev);
   switch (devn)
     {
     case FH_CONSOLE:
@@ -207,7 +207,7 @@ device::init ()
 void
 device::parse (_major_t major, _minor_t minor)
 {
-  _dev_t devn = FHDEV (major, minor);
+  dev_t devn = FHDEV (major, minor);
 
   d.devn = 0;
 
@@ -223,7 +223,7 @@ device::parse (_major_t major, _minor_t minor)
 }
 
 void
-device::parse (_dev_t dev)
+device::parse (dev_t dev)
 {
   parse (_major (dev), _minor (dev));
 }
index 25e55db27868229fa34ca009600bc64e6529fb62..478a41862c5fdee01831a3a64d26f5a1205a1999 100644 (file)
@@ -204,10 +204,10 @@ telldir (DIR *dir)
 /* telldir was never defined using off_t in POSIX, only in early versions
    of glibc.  We have to keep the function in as entry point for backward
    compatibility. */
-extern "C" _off64_t
+extern "C" off_t
 telldir64 (DIR *dir)
 {
-  return (_off64_t) telldir (dir);
+  return (off_t) telldir (dir);
 }
 
 /* seekdir */
@@ -228,7 +228,7 @@ seekdir (DIR *dir, long loc)
    of glibc.  We have to keep the function in as entry point for backward
    compatibility. */
 extern "C" void
-seekdir64 (DIR *dir, _off64_t loc)
+seekdir64 (DIR *dir, off_t loc)
 {
   seekdir (dir, (long) loc);
 }
index 0e664afca980f27f2cd3561c7c4cf26b7c600560..c27adf6750722a9e4db5d1edb701247ffa028ede 100644 (file)
@@ -1,7 +1,7 @@
 /* dlfcn.cc
 
    Copyright 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011 Red Hat, Inc.
+   2010, 2011, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -155,33 +155,9 @@ dlopen (const char *name, int flags)
              || (ret = GetModuleHandleW (path)) != NULL)
            {
              ret = (void *) LoadLibraryW (path);
-             if (ret && (flags & RTLD_NODELETE)
-                 && !GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_PIN, path,
-                                         (HMODULE *) &ret))
-               {
-                 /* Windows 2000 is missing the GetModuleHandleEx call, so we
-                    use a non-documented way to set the DLL to "don't free".
-                    This is how it works:  Fetch the Windows Loader data from
-                    the PEB.  Iterate backwards through the list of loaded
-                    DLLs and compare the DllBase address with the address
-                    returned by LoadLibrary.  If they are equal we found the
-                    right entry.  Now set the LoadCount to -1, which is the
-                    marker for a DLL which should never be free'd. */
-                 PPEB_LDR_DATA ldr = NtCurrentTeb ()->Peb->Ldr;
-
-                 for (PLDR_DATA_TABLE_ENTRY entry = (PLDR_DATA_TABLE_ENTRY)
-                                            ldr->InLoadOrderModuleList.Blink;
-                      entry && entry->DllBase;
-                      entry = (PLDR_DATA_TABLE_ENTRY)
-                              entry->InLoadOrderLinks.Blink)
-                   {
-                     if (entry->DllBase == ret)
-                       {
-                         entry->LoadCount = (WORD) -1;
-                         break;
-                       }
-                   }
-               }
+             if (ret && (flags & RTLD_NODELETE))
+               GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_PIN, path,
+                                   (HMODULE *) &ret);
            }
 
          /* Restore original cxx_malloc pointer. */
index 0d5b31545ea6f875908dae291fd33bc99212cb34..1c68196fb6b2ea2bb72b13c0d9f830b9c3a2a58a 100644 (file)
@@ -1,7 +1,7 @@
 /* dll_init.cc
 
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011, 2012 Red Hat, Inc.
+   2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This software is a copyrighted work licensed under the terms of the
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
@@ -86,11 +86,13 @@ dll::init ()
 {
   int ret = 1;
 
+#ifndef __x86_64__
   /* This should be a no-op.  Why didn't we just import this variable? */
   if (!p.envptr)
     p.envptr = &__cygwin_environ;
   else if (*(p.envptr) != __cygwin_environ)
     *(p.envptr) = __cygwin_environ;
+#endif
 
   /* Don't run constructors or the "main" if we've forked. */
   if (!in_forkee)
@@ -243,7 +245,9 @@ dll_list::alloc (HINSTANCE h, per_process *p, dll_type type)
        loaded_dlls++;
     }
   guard (false);
+#ifndef __x86_64__
   assert (p->envptr != NULL);
+#endif
   return d;
 }
 
@@ -430,30 +434,29 @@ dll_list::init ()
    covering at least _dll_size_ bytes. However, we must take care not
    to clobber the dll's target address range because it often overlaps.
  */
-static DWORD
-reserve_at (const PWCHAR name, DWORD here, DWORD dll_base, DWORD dll_size)
+static PVOID
+reserve_at (const PWCHAR name, PVOID here, PVOID dll_base, DWORD dll_size)
 {
   DWORD size;
   MEMORY_BASIC_INFORMATION mb;
 
-  if (!VirtualQuery ((void *) here, &mb, sizeof (mb)))
-    fabort ("couldn't examine memory at %08lx while mapping %W, %E",
-           here, name);
+  if (!VirtualQuery (here, &mb, sizeof (mb)))
+    fabort ("couldn't examine memory at %p while mapping %W, %E", here, name);
   if (mb.State != MEM_FREE)
     return 0;
 
   size = mb.RegionSize;
 
   // don't clobber the space where we want the dll to land
-  DWORD end = here + size;
-  DWORD dll_end = dll_base + dll_size;
-  if (dll_base < here && dll_end > here)
-      here = dll_end; // the dll straddles our left edge
-  else if (dll_base >= here && dll_base < end)
-      end = dll_base; // the dll overlaps partly or fully to our right
-
-  size = end - here;
-  if (!VirtualAlloc ((void *) here, size, MEM_RESERVE, PAGE_NOACCESS))
+  caddr_t end = (caddr_t) here + size;
+  caddr_t dll_end = (caddr_t) dll_base + dll_size;
+  if (dll_base < here && dll_end > (caddr_t) here)
+      here = (PVOID) dll_end; // the dll straddles our left edge
+  else if (dll_base >= here && (caddr_t) dll_base < end)
+      end = (caddr_t) dll_base; // the dll overlaps partly or fully to our right
+
+  size = end - (caddr_t) here;
+  if (!VirtualAlloc (here, size, MEM_RESERVE, PAGE_NOACCESS))
     fabort ("couldn't allocate memory %p(%d) for '%W' alignment, %E\n",
            here, size, name);
   return here;
@@ -461,9 +464,9 @@ reserve_at (const PWCHAR name, DWORD here, DWORD dll_base, DWORD dll_size)
 
 /* Release the memory previously allocated by "reserve_at" above. */
 static void
-release_at (const PWCHAR name, DWORD here)
+release_at (const PWCHAR name, PVOID here)
 {
-  if (!VirtualFree ((void *) here, 0, MEM_RELEASE))
+  if (!VirtualFree (here, 0, MEM_RELEASE))
     fabort ("couldn't release memory %p for '%W' alignment, %E\n",
            here, name);
 }
@@ -536,7 +539,7 @@ void dll_list::load_after_fork_impl (HANDLE parent, dll* d, int retries)
           dll's protective reservation from step 1
         */
        if (!retries && !VirtualFree (d->handle, 0, MEM_RELEASE))
-         fabort ("unable to release protective reservation for %W (%08lx), %E",
+         fabort ("unable to release protective reservation for %W (%p), %E",
                  d->modname, d->handle);
 
        HMODULE h = LoadLibraryExW (d->name, NULL, DONT_RESOLVE_DLL_REFERENCES);
@@ -544,11 +547,11 @@ void dll_list::load_after_fork_impl (HANDLE parent, dll* d, int retries)
          fabort ("unable to create interim mapping for %W, %E", d->name);
        if (h != d->handle)
          {
-           sigproc_printf ("%W loaded in wrong place: %08lx != %08lx",
+           sigproc_printf ("%W loaded in wrong place: %p != %p",
                            d->modname, h, d->handle);
            FreeLibrary (h);
-           DWORD reservation = reserve_at (d->modname, (DWORD) h,
-                                           (DWORD) d->handle, d->image_size);
+           PVOID reservation = reserve_at (d->modname, h,
+                                           d->handle, d->image_size);
            if (!reservation)
              fabort ("unable to block off %p to prevent %W from loading there",
                      h, d->modname);
@@ -556,12 +559,12 @@ void dll_list::load_after_fork_impl (HANDLE parent, dll* d, int retries)
            if (retries < DLL_RETRY_MAX)
              load_after_fork_impl (parent, d, retries+1);
            else
-              fabort ("unable to remap %W to same address as parent (%08lx) - try running rebaseall",
+              fabort ("unable to remap %W to same address as parent (%p) - try running rebaseall",
                       d->modname, d->handle);
 
            /* once the above returns all the dlls are mapped; release
               the reservation and continue unwinding */
-           sigproc_printf ("releasing blocked space at %08lx", reservation);
+           sigproc_printf ("releasing blocked space at %p", reservation);
            release_at (d->modname, reservation);
            return;
          }
@@ -577,7 +580,7 @@ void dll_list::load_after_fork_impl (HANDLE parent, dll* d, int retries)
       if (d->handle == d->preferred_base)
        {
          if (!VirtualFree (d->handle, 0, MEM_RELEASE))
-           fabort ("unable to release protective reservation for %W (%08lx), %E",
+           fabort ("unable to release protective reservation for %W (%p), %E",
                    d->modname, d->handle);
        }
       else
@@ -601,15 +604,15 @@ struct dllcrt0_info
 {
   HMODULE h;
   per_process *p;
-  int res;
+  PVOID res;
   dllcrt0_info (HMODULE h0, per_process *p0): h (h0), p (p0) {}
 };
 
-extern "C" int
+extern "C" PVOID
 dll_dllcrt0 (HMODULE h, per_process *p)
 {
   if (dynamically_loaded)
-    return 1;
+    return (PVOID) 1;
   dllcrt0_info x (h, p);
   dll_dllcrt0_1 (&x);
   return x.res;
@@ -620,7 +623,7 @@ dll_dllcrt0_1 (VOID *x)
 {
   HMODULE& h = ((dllcrt0_info *) x)->h;
   per_process*& p = ((dllcrt0_info *) x)->p;
-  int& res = ((dllcrt0_info *) x)->res;
+  PVOID& res = ((dllcrt0_info *) x)->res;
 
   if (p == NULL)
     p = &__cygwin_user_data;
@@ -677,20 +680,21 @@ dll_dllcrt0_1 (VOID *x)
      it may not be safe to call the dll's "main" since not
      all of cygwin's internal structures may have been set up. */
   if (!d || (!linked && !d->init ()))
-    res = -1;
+    res = (PVOID) -1;
   else
-    res = (DWORD) d;
+    res = (PVOID) d;
 }
 
+#ifndef __x86_64__
 /* OBSOLETE: This function is obsolete and will go away in the
    future.  Cygwin can now handle being loaded from a noncygwin app
    using the same entry point. */
-
 extern "C" int
 dll_noncygwin_dllcrt0 (HMODULE h, per_process *p)
 {
-  return dll_dllcrt0 (h, p);
+  return (int) dll_dllcrt0 (h, p);
 }
+#endif /* !__x86_64__ */
 
 extern "C" void
 cygwin_detach_dll (dll *)
@@ -709,6 +713,7 @@ dlfork (int val)
   dlls.reload_on_fork = val;
 }
 
+#ifndef __x86_64__
 /* Called from various places to update all of the individual
    ideas of the environ block.  Explain to me again why we didn't
    just import __cygwin_environ? */
@@ -720,3 +725,4 @@ update_envptrs ()
       *(d->p.envptr) = __cygwin_environ;
   *main_environ = __cygwin_environ;
 }
+#endif
index 6c102c536ce57b7bd8edda84deaac5f95f70f220..8127d0bb4292c1803abafe0bac22d32ba17e1b51 100644 (file)
@@ -1,7 +1,7 @@
 /* dll_init.h
 
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2010,
-   2011, 2012 Red Hat, Inc.
+   2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -11,7 +11,9 @@ details. */
 
 struct per_module
 {
+#ifndef __x86_64__
   char ***envptr;
+#endif
   void (**ctors)(void);
   void (**dtors)(void);
   void *data_start;
@@ -21,7 +23,9 @@ struct per_module
   int (*main)(int, char **, char **);
   per_module &operator = (per_process *p)
   {
+#ifndef __x86_64__
     envptr = p->envptr;
+#endif
     ctors = p->ctors;
     dtors = p->dtors;
     data_start = p->data_start;
@@ -129,12 +133,12 @@ struct pefile
 {
   IMAGE_DOS_HEADER dos_hdr;
 
-  char* rva (long offset) { return (char*) this + offset; }
-  PIMAGE_NT_HEADERS32 pe_hdr () { return (PIMAGE_NT_HEADERS32) rva (dos_hdr.e_lfanew); }
-  PIMAGE_OPTIONAL_HEADER32 optional_hdr () { return &pe_hdr ()->OptionalHeader; }
+  char* rva (ptrdiff_t offset) { return (char*) this + offset; }
+  PIMAGE_NT_HEADERS pe_hdr () { return (PIMAGE_NT_HEADERS) rva (dos_hdr.e_lfanew); }
+  PIMAGE_OPTIONAL_HEADER optional_hdr () { return &pe_hdr ()->OptionalHeader; }
   PIMAGE_DATA_DIRECTORY idata_dir (DWORD which)
   {
-    PIMAGE_OPTIONAL_HEADER32 oh = optional_hdr ();
+    PIMAGE_OPTIONAL_HEADER oh = optional_hdr ();
     return (which < oh->NumberOfRvaAndSizes)? oh->DataDirectory + which : 0;
   }
 };
index e46c6c58d41fbb3f317f186956183d5e8079dc4c..b5781e8ae47f1798f79e150564d57aaeec06a0f9 100644 (file)
@@ -1,7 +1,7 @@
 /* dtable.cc: file descriptor support.
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -31,8 +31,8 @@ details. */
 #include "ntdll.h"
 #include "shared_info.h"
 
-static const NO_COPY DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
-                                          STD_ERROR_HANDLE};
+static const DWORD std_consts[] = {STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
+                                  STD_ERROR_HANDLE};
 
 static bool handle_to_fn (HANDLE, char *);
 
@@ -103,7 +103,7 @@ dtable::extend (int howmuch)
 
   size = new_size;
   fds = newfds;
-  debug_printf ("size %d, fds %p", size, fds);
+  debug_printf ("size %ld, fds %p", size, fds);
   return 1;
 }
 
@@ -115,8 +115,8 @@ dtable::get_debugger_info ()
     {
       char std[3][sizeof ("/dev/ptyNNNN")];
       std[0][0] = std[1][0] = std [2][0] = '\0';
-      char buf[sizeof ("cYgstd %x") + 32];
-      sprintf (buf, "cYgstd %x %x %x", (unsigned) &std, sizeof (std[0]), 3);
+      char buf[sizeof ("cYgstd %x") + 64];
+      sprintf (buf, "cYgstd %p %zx %x", &std, sizeof (std[0]), 3);
       OutputDebugString (buf);
       for (int i = 0; i < 3; i++)
        if (std[i][0])
@@ -194,7 +194,7 @@ fhandler_base *
 dtable::find_archetype (device& dev)
 {
   for (unsigned i = 0; i < farchetype; i++)
-    if (archetypes[i]->get_device () == (DWORD) dev)
+    if (archetypes[i]->get_device () == (dev_t) dev)
       return archetypes[i];
   return NULL;
 }
@@ -482,7 +482,7 @@ fh_alloc (path_conv& pc)
       fh = cnew (fhandler_console, pc.dev);
       break;
     default:
-      switch ((DWORD) pc.dev)
+      switch ((dev_t) pc.dev)
        {
        case FH_CONSOLE:
        case FH_CONIN:
@@ -661,7 +661,7 @@ build_fh_pc (path_conv& pc)
     last_tty_dev = fh->dev ();
 
 out:
-  debug_printf ("fh %p, dev %p", fh, fh ? (DWORD) fh->dev () : 0);
+  debug_printf ("fh %p, dev %08x", fh, fh ? (dev_t) fh->dev () : 0);
   return fh;
 }
 
@@ -710,7 +710,7 @@ dtable::dup3 (int oldfd, int newfd, int flags)
   fhandler_base *newfh = NULL; // = NULL to avoid an incorrect warning
 
   MALLOC_CHECK;
-  debug_printf ("dup3 (%d, %d, %p)", oldfd, newfd, flags);
+  debug_printf ("dup3 (%d, %d, %y)", oldfd, newfd, flags);
   lock ();
   bool do_unlock = true;
   bool unlock_on_return;
@@ -736,7 +736,7 @@ dtable::dup3 (int oldfd, int newfd, int flags)
     }
   if ((flags & ~O_CLOEXEC) != 0)
     {
-      syscall_printf ("invalid flags value %x", flags);
+      syscall_printf ("invalid flags value %y", flags);
       set_errno (EINVAL);
       return -1;
     }
@@ -778,7 +778,7 @@ done:
   MALLOC_CHECK;
   if (do_unlock)
     unlock ();
-  syscall_printf ("%R = dup3(%d, %d, %p)", res, oldfd, newfd, flags);
+  syscall_printf ("%R = dup3(%d, %d, %y)", res, oldfd, newfd, flags);
 
   return res;
 }
@@ -939,7 +939,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
 
   NTSTATUS status = NtQueryObject (h, ObjectNameInformation, ntfn, 65536, &len);
   if (!NT_SUCCESS (status))
-    debug_printf ("NtQueryObject failed, %p", status);
+    debug_printf ("NtQueryObject failed, %y", status);
   // NT seems to do this on an unopened file
   else if (!ntfn->Name.Buffer)
     debug_printf ("nt->Name.Buffer == NULL");
index 0d9e42e0fc153782f980124e27362c2268572d75..a510e50d59ce9100a36397585a5c4b782cb119e5 100644 (file)
@@ -187,7 +187,7 @@ parse_options (const char *inbuf)
                  *k->setting.x = k->values[istrue].i;
                else
                  *k->setting.x = strtol (eq, NULL, 0);
-               debug_printf ("%s %d", k->name, *k->setting.x);
+               debug_printf ("%s %u", k->name, *k->setting.x);
                break;
              case setbool:
                if (!istrue || !eq)
@@ -1048,7 +1048,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
   else
     {
       *pass_dstp = NULL;
-      debug_printf ("env count %d, bytes %d", pass_envc, tl);
+      debug_printf ("env count %ld, bytes %d", pass_envc, tl);
       win_env temp;
       temp.reset ();
 
@@ -1118,6 +1118,7 @@ build_env (const char * const *envp, PWCHAR &envblock, int &envc,
   return newenv;
 }
 
+#ifndef __x86_64__
 /* This idiocy is necessary because the early implementers of cygwin
    did not seem to know about importing data variables from the DLL.
    So, we have to synchronize cygwin's idea of the environment with the
@@ -1133,3 +1134,4 @@ cur_environ ()
 
   return __cygwin_environ;
 }
+#endif
index 888c36625d96943ff3868a91c91c4c39f74c5b66..d6a7d8a3888c17a36de106f82e4dfcf6d5664017 100644 (file)
@@ -35,9 +35,15 @@ struct win_env
 win_env * __reg3 getwinenv (const char *name, const char *posix = NULL, win_env * = NULL);
 char * __reg3 getwinenveq (const char *name, size_t len, int);
 
+#ifdef __x86_64__
+#define update_envptrs()
+extern "C" char **__cygwin_environ;
+#define cur_environ()  __cygwin_environ
+#else
 void __stdcall update_envptrs ();
 extern "C" char **__cygwin_environ, ***main_environ;
 extern "C" char __stdcall **cur_environ ();
+#endif
 char ** __reg3 build_env (const char * const *envp, PWCHAR &envblock,
                             int &envc, bool need_envblock);
 
index b2cbd983ba8df8aaec16cf1e80b5d2b4daae06eb..2a5f711bde5c2b99ff6a57a9debe111e4974495a 100644 (file)
@@ -34,7 +34,7 @@ details. */
 
 #define X(w, e) {ERROR_##w, #w, e}
 
-static NO_COPY struct
+static const struct
 {
   DWORD w;              /* windows version of error */
   const char *s;        /* text of windows version */
@@ -162,7 +162,7 @@ static NO_COPY struct
 };
 
 extern "C" {
-const char *_sys_errlist[] NO_COPY_INIT =
+const char *_sys_errlist[] =
 {
 /* NOERROR 0 */                  "No error",
 /* EPERM 1 */            "Operation not permitted",
@@ -333,7 +333,7 @@ geterrno_from_win_error (DWORD code, int deferrno)
 void __reg3
 seterrno_from_win_error (const char *file, int line, DWORD code)
 {
-  syscall_printf ("%s:%d windows error %d", file, line, code);
+  syscall_printf ("%s:%d windows error %u", file, line, code);
   errno = _impure_ptr->_errno =  geterrno_from_win_error (code, EACCES);
 }
 
@@ -350,7 +350,7 @@ seterrno_from_nt_status (const char *file, int line, NTSTATUS status)
 {
   DWORD code = RtlNtStatusToDosError (status);
   SetLastError (code);
-  syscall_printf ("%s:%d status %p -> windows error %d",
+  syscall_printf ("%s:%d status %y -> windows error %u",
                  file, line, status, code);
   errno = _impure_ptr->_errno =  geterrno_from_win_error (code, EACCES);
 }
index c14aa16140952362258ff2c6ae717e11a5cd918a..5b11b0c003b19f831580fbe5442becda0eedf782 100644 (file)
@@ -8,35 +8,61 @@ details. */
 
 #pragma once
 
+#ifdef __x86_64__
+#define _exception_list _EXCEPTION_REGISTRATION_RECORD
+#endif
+
 #include <exceptions.h>
 
+#ifndef __x86_64__
 extern exception_list *_except_list asm ("%fs:0");
+#endif
 
 class exception
 {
+#ifdef __x86_64__
+  static bool handler_installed; 
+  static int handle (LPEXCEPTION_POINTERS);
+#else
   exception_list el;
   exception_list *save;
   static int handle (EXCEPTION_RECORD *, exception_list *, CONTEXT *, void *);
+#endif
 public:
   exception () __attribute__ ((always_inline))
   {
+#ifdef __x86_64__
+    if (!handler_installed)
+      {
+       handler_installed = true;
+       /* The unhandled exception filter goes first.  It won't work if the
+          executable is debugged, but then the vectored continue handler
+          kicks in.  For some reason the vectored continue handler doesn't
+          get called if no unhandled exception filter is installed. */
+       SetUnhandledExceptionFilter (handle);
+       AddVectoredContinueHandler (1, handle);
+      }
+#else
     save = _except_list;
     el.handler = handle;
     el.prev = _except_list;
     _except_list = &el;
+#endif
   };
+#ifndef __x86_64__
   ~exception () __attribute__ ((always_inline)) { _except_list = save; }
+#endif
 };
 
 class cygwin_exception
 {
-  DWORD ebp;
+  PUINT_PTR framep;
   PCONTEXT ctx;
   EXCEPTION_RECORD *e;
   void dump_exception ();
 public:
-  cygwin_exception (DWORD in_ebp, PCONTEXT in_ctx = NULL, EXCEPTION_RECORD *in_e = NULL):
-    ebp (in_ebp), ctx (in_ctx), e (in_e) {}
+  cygwin_exception (PUINT_PTR in_framep, PCONTEXT in_ctx = NULL, EXCEPTION_RECORD *in_e = NULL):
+    framep (in_framep), ctx (in_ctx), e (in_e) {}
   void dumpstack ();
   PCONTEXT context () const {return ctx;}
 };
index d86635baebfac80c18a68e729367efccd528567a..083d87ff49e93449a41c6b9b8856e443ff681ebd 100644 (file)
@@ -1,7 +1,7 @@
 /* exceptions.cc
 
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+   2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -32,6 +32,17 @@ details. */
 #include "ntdll.h"
 #include "exception.h"
 
+/* Definitions for code simplification */
+#ifdef __x86_64__
+# define _GR(reg)      R ## reg
+# define _AFMT         "%011X"
+# define _ADDR         DWORD64
+#else
+# define _GR(reg)      E ## reg
+# define _AFMT         "%08x"
+# define _ADDR         DWORD
+#endif
+
 #define CALL_HANDLER_RETRY_OUTER 10
 #define CALL_HANDLER_RETRY_INNER 10
 
@@ -39,7 +50,7 @@ char debugger_command[2 * NT_MAX_PATH + 20];
 
 static BOOL WINAPI ctrl_c_handler (DWORD);
 
-NO_COPY static struct
+static const struct
 {
   NTSTATUS code;
   const char *name;
@@ -178,6 +189,20 @@ cygwin_exception::dump_exception ()
        }
     }
 
+#ifdef __x86_64__
+  if (exception_name)
+    small_printf ("Exception: %s at rip=%011X\r\n", exception_name, ctx->Rip);
+  else
+    small_printf ("Signal %d at rip=%011X\r\n", e->ExceptionCode, ctx->Rip);
+  small_printf ("rax=%016X rbx=%016X rcx=%016X\r\n", ctx->Rax, ctx->Rbx, ctx->Rcx);
+  small_printf ("rdx=%016X rsi=%016X rdi=%016X\r\n", ctx->Rdx, ctx->Rsi, ctx->Rdi);
+  small_printf ("r8 =%016X r9 =%016X r10=%016X\r\n", ctx->R8, ctx->R9, ctx->R10);
+  small_printf ("r11=%016X r12=%016X r13=%016X\r\n", ctx->R11, ctx->R12, ctx->R13);
+  small_printf ("r14=%016X r15=%016X\r\n", ctx->R14, ctx->R15);
+  small_printf ("rbp=%016X rsp=%016X\r\n", ctx->Rbp, ctx->Rsp);
+  small_printf ("program=%W, pid %u, thread %s\r\n",
+               myself->progname, myself->pid, cygthread::name ());
+#else
   if (exception_name)
     small_printf ("Exception: %s at eip=%08x\r\n", exception_name, ctx->Eip);
   else
@@ -185,7 +210,9 @@ cygwin_exception::dump_exception ()
   small_printf ("eax=%08x ebx=%08x ecx=%08x edx=%08x esi=%08x edi=%08x\r\n",
                ctx->Eax, ctx->Ebx, ctx->Ecx, ctx->Edx, ctx->Esi, ctx->Edi);
   small_printf ("ebp=%08x esp=%08x program=%W, pid %u, thread %s\r\n",
-               ctx->Ebp, ctx->Esp, myself->progname, myself->pid, cygthread::name ());
+               ctx->Ebp, ctx->Esp, myself->progname, myself->pid,
+               cygthread::name ());
+#endif
   small_printf ("cs=%04x ds=%04x es=%04x fs=%04x gs=%04x ss=%04x\r\n",
                ctx->SegCs, ctx->SegDs, ctx->SegEs, ctx->SegFs, ctx->SegGs, ctx->SegSs);
 }
@@ -196,10 +223,14 @@ class stack_info
   int walk ();                 /* Uses the "old" method */
   char *next_offset () {return *((char **) sf.AddrFrame.Offset);}
   bool needargs;
-  DWORD dummy_frame;
+  PUINT_PTR dummy_frame;
+#ifdef __x86_64__
+  CONTEXT c;
+  UNWIND_HISTORY_TABLE hist;
+#endif
 public:
   STACKFRAME sf;                /* For storing the stack information */
-  void init (DWORD, bool, bool); /* Called the first time that stack info is needed */
+  void init (PUINT_PTR, bool, PCONTEXT); /* Called the first time that stack info is needed */
 
   /* Postfix ++ iterates over the stack, returning zero when nothing is left. */
   int operator ++(int) { return walk (); }
@@ -213,21 +244,30 @@ static NO_COPY stack_info thestack;
 
 /* Initialize everything needed to start iterating. */
 void
-stack_info::init (DWORD ebp, bool wantargs, bool goodframe)
+stack_info::init (PUINT_PTR framep, bool wantargs, PCONTEXT ctx)
 {
-# define debp ((DWORD *) ebp)
+#ifdef __x86_64__
+  memset (&hist, 0, sizeof hist);
+  if (ctx)
+    memcpy (&c, ctx, sizeof c);
+  else
+    {
+      memset (&c, 0, sizeof c);
+      c.ContextFlags = CONTEXT_ALL;
+    }
+#endif
   memset (&sf, 0, sizeof (sf));
-  if (!goodframe)
-    sf.AddrFrame.Offset = ebp;
+  if (ctx)
+    sf.AddrFrame.Offset = (UINT_PTR) framep;
   else
     {
-      dummy_frame = ebp;
-      sf.AddrFrame.Offset = (DWORD) &dummy_frame;
+      dummy_frame = framep;
+      sf.AddrFrame.Offset = (UINT_PTR) &dummy_frame;
     }
-  sf.AddrReturn.Offset = debp[1];
+  if (framep)
+    sf.AddrReturn.Offset = framep[1];
   sf.AddrFrame.Mode = AddrModeFlat;
   needargs = wantargs;
-# undef debp
 }
 
 extern "C" void _cygwin_exit_return ();
@@ -237,26 +277,56 @@ extern "C" void _cygwin_exit_return ();
 int
 stack_info::walk ()
 {
-  char **ebp;
+#ifdef __x86_64__
+  PRUNTIME_FUNCTION f;
+  ULONG64 imagebase;
+  DWORD64 establisher;
+  PVOID hdl;
+
+  if (!c.Rip)
+    return 0;
+
+  sf.AddrPC.Offset = c.Rip;
+  sf.AddrStack.Offset = c.Rsp;
+  sf.AddrFrame.Offset = c.Rbp;
+
+  f = RtlLookupFunctionEntry (c.Rip, &imagebase, &hist);
+  if (f)
+    RtlVirtualUnwind (0, imagebase, c.Rip, f, &c, &hdl, &establisher, NULL);
+  else
+    {
+      c.Rip = *(ULONG_PTR *) c.Rsp;
+      c.Rsp += 8;
+    }
+  if (needargs && c.Rip)
+    {
+      PULONG_PTR p = (PULONG_PTR) c.Rsp;
+      for (unsigned i = 0; i < NPARAMS; ++i)
+       sf.Params[i] = p[i + 1];
+    }
+  return 1;
+#else
+  char **framep;
 
   if ((void (*) ()) sf.AddrPC.Offset == _cygwin_exit_return)
     return 0;          /* stack frames are exhausted */
 
-  if (((ebp = (char **) next_offset ()) == NULL) || (ebp >= (char **) cygwin_hmodule))
+  if (((framep = (char **) next_offset ()) == NULL)
+      || (framep >= (char **) cygwin_hmodule))
     return 0;
 
-  sf.AddrFrame.Offset = (DWORD) ebp;
+  sf.AddrFrame.Offset = (_ADDR) framep;
   sf.AddrPC.Offset = sf.AddrReturn.Offset;
 
   /* The return address always follows the stack pointer */
-  sf.AddrReturn.Offset = (DWORD) *++ebp;
+  sf.AddrReturn.Offset = (_ADDR) *++framep;
 
   if (needargs)
     {
       unsigned nparams = NPARAMS;
 
       /* The arguments follow the return address */
-      sf.Params[0] = (DWORD) *++ebp;
+      sf.Params[0] = (_ADDR) *++framep;
       /* Hack for XP/2K3 WOW64.  If the first stack param points to the
         application entry point, we can only fetch one additional
         parameter.  Accessing anything beyond this address results in
@@ -264,10 +334,10 @@ stack_info::walk ()
       if (wincap.has_restricted_stack_args () && sf.Params[0] == 0x401000)
        nparams = 2;
       for (unsigned i = 1; i < nparams; i++)
-       sf.Params[i] = (DWORD) *++ebp;
+       sf.Params[i] = (_ADDR) *++framep;
     }
-
   return 1;
+#endif
 }
 
 void
@@ -285,14 +355,18 @@ cygwin_exception::dumpstack ()
 
   int i;
 
-  thestack.init (ebp, 1, !ctx);        /* Initialize from the input CONTEXT */
+  thestack.init (framep, 1, ctx);      /* Initialize from the input CONTEXT */
+#ifdef __x86_64__
+  small_printf ("Stack trace:\r\nFrame        Function    Args\r\n");
+#else
   small_printf ("Stack trace:\r\nFrame     Function  Args\r\n");
+#endif
   for (i = 0; i < 16 && thestack++; i++)
     {
-      small_printf ("%08x  %08x ", thestack.sf.AddrFrame.Offset,
+      small_printf (_AFMT "  " _AFMT, thestack.sf.AddrFrame.Offset,
                    thestack.sf.AddrPC.Offset);
       for (unsigned j = 0; j < NPARAMS; j++)
-       small_printf ("%s%08x", j == 0 ? " (" : ", ", thestack.sf.Params[j]);
+       small_printf ("%s" _AFMT, j == 0 ? " (" : ", ", thestack.sf.Params[j]);
       small_printf (")\r\n");
     }
   small_printf ("End of stack trace%s\n",
@@ -309,8 +383,8 @@ _cygtls::inside_kernel (CONTEXT *cx)
     return true;
 
   memset (&m, 0, sizeof m);
-  if (!VirtualQuery ((LPCVOID) cx->Eip, &m, sizeof m))
-    sigproc_printf ("couldn't get memory info, pc %p, %E", cx->Eip);
+  if (!VirtualQuery ((LPCVOID) cx->_GR(ip), &m, sizeof m))
+    sigproc_printf ("couldn't get memory info, pc %p, %E", cx->_GR(ip));
 
   size_t size = (windows_system_directory_length + 6) * sizeof (WCHAR);
   PWCHAR checkdir = (PWCHAR) alloca (size);
@@ -330,12 +404,14 @@ _cygtls::inside_kernel (CONTEXT *cx)
        checkdir += 4;
       res = wcsncasecmp (windows_system_directory, checkdir,
                         windows_system_directory_length) == 0;
+#ifndef __x86_64__
       if (!res && system_wow64_directory_length)
        res = wcsncasecmp (system_wow64_directory, checkdir,
                           system_wow64_directory_length) == 0;
 
+#endif
     }
-  sigproc_printf ("pc %p, h %p, inside_kernel %d", cx->Eip, h, res);
+  sigproc_printf ("pc %p, h %p, inside_kernel %d", cx->_GR(ip), h, res);
 # undef h
   return res;
 }
@@ -346,8 +422,8 @@ cygwin_stackdump ()
 {
   CONTEXT c;
   c.ContextFlags = CONTEXT_FULL;
-  GetThreadContext (GetCurrentThread (), &c);
-  cygwin_exception exc (c.Ebp);
+  RtlCaptureContext (&c);
+  cygwin_exception exc ((PUINT_PTR) c._GR(bp), &c);
   exc.dumpstack ();
 }
 
@@ -440,9 +516,13 @@ try_to_debug (bool waitloop)
   return dbg;
 }
 
-extern "C" void WINAPI RtlUnwind (void *, void *, PEXCEPTION_RECORD, void *);
-static void __reg3 rtl_unwind (exception_list *, PEXCEPTION_RECORD) __attribute__ ((noinline, ));
-void __stdcall
+#ifdef __x86_64__
+/* Don't unwind the stack on x86_64.  It's not necessary to do that from the
+   exception handler. */
+#define rtl_unwind(el,er)
+#else
+static void __reg3 rtl_unwind (exception_list *, PEXCEPTION_RECORD) __attribute__ ((noinline, regparm (3)));
+void __reg3
 rtl_unwind (exception_list *frame, PEXCEPTION_RECORD e)
 {
   __asm__ ("\n\
@@ -460,27 +540,44 @@ rtl_unwind (exception_list *frame, PEXCEPTION_RECORD e)
   popl         %%ebx                                   \n\
 ": : "r" (frame), "r" (e));
 }
+#endif
 
 /* Main exception handler. */
 
-extern exception_list *_except_list asm ("%fs:0");
+#ifdef __x86_64__
+#define CYG_EXC_CONTINUE_EXECUTION     EXCEPTION_CONTINUE_EXECUTION
+#define CYG_EXC_CONTINUE_SEARCH                EXCEPTION_CONTINUE_SEARCH
+
+bool exception::handler_installed NO_COPY; 
+
+int
+exception::handle (LPEXCEPTION_POINTERS ep)
+#else
+#define CYG_EXC_CONTINUE_EXECUTION     0
+#define CYG_EXC_CONTINUE_SEARCH                1
 
 int
 exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void *)
+#endif
 {
   static bool NO_COPY debugging;
   _cygtls& me = _my_tls;
 
+#ifdef __x86_64__
+  EXCEPTION_RECORD *e = ep->ExceptionRecord;
+  CONTEXT *in = ep->ContextRecord;
+#endif
+
   if (debugging && ++debugging < 500000)
     {
       SetThreadPriority (hMainThread, THREAD_PRIORITY_NORMAL);
-      return 0;
+      return CYG_EXC_CONTINUE_EXECUTION;
     }
 
   /* If we're exiting, don't do anything here.  Returning 1
      tells Windows to keep looking for an exception handler.  */
   if (exit_state || e->ExceptionFlags)
-    return 1;
+    return CYG_EXC_CONTINUE_SEARCH;
 
   siginfo_t si = {};
   si.si_code = SI_KERNEL;
@@ -549,7 +646,7 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void
                                             1))
        {
        case MMAP_NORESERVE_COMMITED:
-         return 0;
+         return CYG_EXC_CONTINUE_EXECUTION;
        case MMAP_RAISE_SIGBUS: /* MAP_NORESERVE page, commit failed, or
                                   access to mmap page beyond EOF. */
          si.si_signo = SIGBUS;
@@ -583,26 +680,34 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void
         want CloseHandle to return an error.  This can be revisited
         if gcc ever supports Windows style structured exception
         handling.  */
-      return 0;
+      return CYG_EXC_CONTINUE_EXECUTION;
 
     default:
       /* If we don't recognize the exception, we have to assume that
         we are doing structured exception handling, and we let
         something else handle it.  */
-      return 1;
+      return CYG_EXC_CONTINUE_SEARCH;
     }
 
   if (me.andreas)
     me.andreas->leave ();      /* Return from a "san" caught fault */
 
-  debug_printf ("In cygwin_except_handler exception %p at %p sp %p", e->ExceptionCode, in->Eip, in->Esp);
-  debug_printf ("In cygwin_except_handler signal %d at %p", si.si_signo, in->Eip);
-
-  DWORD *ebp = (DWORD *) in->Esp;
-  for (DWORD *bpend = (DWORD *) __builtin_frame_address (0); ebp > bpend; ebp--)
-    if (*ebp == in->SegCs && ebp[-1] == in->Eip)
+  debug_printf ("In cygwin_except_handler exception %y at %p sp %p", e->ExceptionCode, in->_GR(ip), in->_GR(sp));
+  debug_printf ("In cygwin_except_handler signal %d at %p", si.si_signo, in->_GR(ip));
+
+#ifdef __x86_64__
+  PUINT_PTR framep = (PUINT_PTR) in->Rbp;
+  /* Sometimes, when a stack is screwed up, Rbp tends to be NULL.  In that
+     case, base the stacktrace on Rsp.  In most cases, it allows to generate
+     useful stack trace. */
+  if (!framep)
+    framep = (PUINT_PTR) in->Rsp;
+#else
+  PUINT_PTR framep = (PUINT_PTR) in->_GR(sp);
+  for (PUINT_PTR bpend = (PUINT_PTR) __builtin_frame_address (0); framep > bpend; framep--)
+    if (*framep == in->SegCs && framep[-1] == in->_GR(ip))
       {
-       ebp -= 2;
+       framep -= 2;
        break;
       }
 
@@ -610,6 +715,7 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void
      We don't want any Windows magic kicking in.  This top level frame
      will be removed automatically after our exception handler returns. */
   _except_list->handler = handle;
+#endif
 
   if (exit_state >= ES_SIGNAL_EXIT
       && (NTSTATUS) e->ExceptionCode != STATUS_CONTROL_C_EXIT)
@@ -619,7 +725,7 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void
   else
     {
       debugging = true;
-      return 0;
+      return CYG_EXC_CONTINUE_EXECUTION;
     }
 
   /* FIXME: Probably should be handled in signal processing code */
@@ -632,19 +738,24 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, void
        error_code |= 2;
       if (!me.inside_kernel (in))      /* User space */
        error_code |= 4;
-      klog (LOG_INFO, "%s[%d]: segfault at %08x rip %08x rsp %08x error %d",
-                     __progname, myself->pid, e->ExceptionInformation[1],
-                     in->Eip, in->Esp, error_code);
+      klog (LOG_INFO,
+#ifdef __x86_64__
+           "%s[%d]: segfault at %011X rip %011X rsp %011X error %d",
+#else
+           "%s[%d]: segfault at %08x rip %08x rsp %08x error %d",
+#endif
+                     __progname, myself->pid,
+                     e->ExceptionInformation[1], in->_GR(ip), in->_GR(sp),
+                     error_code);
     }
-
-  cygwin_exception exc ((DWORD) ebp, in, e);
+  cygwin_exception exc (framep, in, e);
   si.si_cyg = (void *) &exc;
-  si.si_addr = (void *) in->Eip;
+  si.si_addr = (void *) in->_GR(ip);
   me.incyg++;
   sig_send (NULL, si, &me);    /* Signal myself */
   me.incyg--;
   e->ExceptionFlags = 0;
-  return 0;
+  return CYG_EXC_CONTINUE_EXECUTION;
 }
 
 /* Utilities to call a user supplied exception handler.  */
@@ -664,7 +775,7 @@ handle_sigsuspend (sigset_t tempmask)
   sigset_t oldmask = _my_tls.sigmask;  // Remember for restoration
 
   set_signal_mask (_my_tls.sigmask, tempmask);
-  sigproc_printf ("oldmask %p, newmask %p", oldmask, tempmask);
+  sigproc_printf ("oldmask %ly, newmask %ly", oldmask, tempmask);
 
   pthread_testcancel ();
   cygwait (NULL, cw_infinite, cw_cancel | cw_cancel_self | cw_sig_eintr);
@@ -730,16 +841,17 @@ _cygtls::interrupt_now (CONTEXT *cx, siginfo_t& si, void *handler,
     interrupted = false;
   else
     {
-      push ((__stack_t) cx->Eip);
+      _ADDR &ip = cx->_GR(ip);
+      push (ip);
       interrupt_setup (si, handler, siga);
-      cx->Eip = pop ();
+      ip = pop ();
       SetThreadContext (*this, cx); /* Restart the thread in a new location */
       interrupted = true;
     }
   return interrupted;
 }
 
-void __stdcall
+void __reg3
 _cygtls::interrupt_setup (siginfo_t& si, void *handler, struct sigaction& siga)
 {
   push ((__stack_t) sigdelayed);
@@ -1050,7 +1162,7 @@ set_process_mask_delta ()
   else
     oldmask = _my_tls.sigmask;
   newmask = (oldmask | _my_tls.deltamask) & ~SIG_NONMASKABLE;
-  sigproc_printf ("oldmask %p, newmask %p, deltamask %p", oldmask, newmask,
+  sigproc_printf ("oldmask %lx, newmask %lx, deltamask %lx", oldmask, newmask,
                  _my_tls.deltamask);
   _my_tls.sigmask = newmask;
   return oldmask;
@@ -1064,7 +1176,7 @@ set_signal_mask (sigset_t& setmask, sigset_t newmask)
 {
   newmask &= ~SIG_NONMASKABLE;
   sigset_t mask_bits = setmask & ~newmask;
-  sigproc_printf ("setmask %p, newmask %p, mask_bits %p", setmask, newmask,
+  sigproc_printf ("setmask %lx, newmask %lx, mask_bits %lx", setmask, newmask,
                  mask_bits);
   setmask = newmask;
   if (mask_bits)
@@ -1092,16 +1204,23 @@ signal_exit (int sig, siginfo_t *si)
       case SIGTRAP:
       case SIGXCPU:
       case SIGXFSZ:
-       if (try_to_debug ())
-         break;
-       if (si->si_code != SI_USER && si->si_cyg)
-         ((cygwin_exception *) si->si_cyg)->dumpstack ();
-       else
-         {
-           cygwin_exception exc (_my_tls.thread_context.ebp);
-           exc.dumpstack ();
-         }
-       break;
+       if (try_to_debug ())
+        break;
+       if (si->si_code != SI_USER && si->si_cyg)
+        ((cygwin_exception *) si->si_cyg)->dumpstack ();
+       else
+        {
+          CONTEXT c;
+          c.ContextFlags = CONTEXT_FULL;
+          RtlCaptureContext (&c);
+#ifdef __x86_64__
+          cygwin_exception exc ((PUINT_PTR) _my_tls.thread_context.rbp, &c);
+#else
+          cygwin_exception exc ((PUINT_PTR) _my_tls.thread_context.ebp, &c);
+#endif
+          exc.dumpstack ();
+        }
+       break;
       }
 
   lock_process until_exit (true);
@@ -1129,22 +1248,22 @@ _cygtls::handle_SIGCONT ()
       int state = 0;
       /* Carefully tell sig_handle_tty_stop to wake up.  */
       while (state < 2)
-       {
-         lock ();
-         if (sig)
-           yield ();           /* state <= 1 */
-         else if (state)
-           state++;            /* state == 2 */
-         else
-           {
-             sig = SIGCONT;
-             SetEvent (signal_arrived);
-             state++;          /* state == 1 */
-           }
-         unlock ();
-       }
+       {
+        lock ();
+        if (sig)
+          yield ();           /* state <= 1 */
+        else if (state)
+          state++;            /* state == 2 */
+        else
+          {
+            sig = SIGCONT;
+            SetEvent (signal_arrived);
+            state++;          /* state == 1 */
+          }
+        unlock ();
+       }
       /* Tell wait_sig to handle any queued signals now that we're alive
-        again. */
+       again. */
       sig_dispatch_pending (false);
     }
   /* Clear pending stop signals */
@@ -1154,7 +1273,7 @@ _cygtls::handle_SIGCONT ()
   sig_clear (SIGTTOU);
 }
 
-int __stdcall
+int __reg1
 sigpacket::process ()
 {
   int rc = 1;
@@ -1200,7 +1319,7 @@ sigpacket::process ()
       else
        tls = NULL;
     }
-
+      
   /* !tls means no threads available to catch a signal. */
   if (!tls)
     {
@@ -1350,16 +1469,24 @@ _cygtls::signal_debugger (siginfo_t& si)
          else
            goto out;
          if (incyg)
+#ifdef __x86_64__
+           c.Rip = retaddr ();
+#else
            c.Eip = retaddr ();
+#endif
+         memcpy (&thread_context, pc, (&thread_context._internal -
+                                       (unsigned char *) &thread_context));
        }
-      memcpy (&thread_context, pc, (&thread_context._internal -
-                                  (unsigned char *) &thread_context));
+#ifdef __x86_64__
+      char sigmsg[2 * sizeof (_CYGWIN_SIGNAL_STRING " ffffffff ffffffffffffffff")];
+#else
       char sigmsg[2 * sizeof (_CYGWIN_SIGNAL_STRING " ffffffff ffffffff")];
-      __small_sprintf (sigmsg, _CYGWIN_SIGNAL_STRING " %d %p %p", si.si_signo,
+#endif
+      __small_sprintf (sigmsg, _CYGWIN_SIGNAL_STRING " %d %y %p", si.si_signo,
                       thread_id, &thread_context);
       OutputDebugString (sigmsg);
     }
 out:
-    if (th)
-      ResumeThread (th);
+  if (th)
+    ResumeThread (th);
 }
index 8734deed366ab4513e26875f497358083368d8d1..4dc87bf80cd017e05c14b032d81772c4ba844d18 100644 (file)
@@ -113,7 +113,7 @@ fillout_pinfo (pid_t pid, int winpid)
   return &ep;
 }
 
-static inline DWORD
+static inline uintptr_t
 get_cygdrive_info (char *user, char *system, char *user_flags,
                   char *system_flags)
 {
@@ -122,7 +122,7 @@ get_cygdrive_info (char *user, char *system, char *user_flags,
   return (res == ERROR_SUCCESS) ? 1 : 0;
 }
 
-static DWORD
+static bool
 check_ntsec (const char *filename)
 {
   if (!filename)
@@ -200,7 +200,7 @@ exit_process (UINT status, bool useTerminateProcess)
 }
 
 
-extern "C" unsigned long
+extern "C" uintptr_t
 cygwin_internal (cygwin_getinfo_types t, ...)
 {
   va_list arg;
@@ -218,7 +218,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
        break;
 
       case CW_GETTHREADNAME:
-       res = (DWORD) cygthread::name (va_arg (arg, DWORD));
+       res = (uintptr_t) cygthread::name (va_arg (arg, DWORD));
        break;
 
       case CW_SETTHREADNAME:
@@ -229,11 +229,11 @@ cygwin_internal (cygwin_getinfo_types t, ...)
        break;
 
       case CW_GETPINFO:
-       res = (DWORD) fillout_pinfo (va_arg (arg, DWORD), 0);
+       res = (uintptr_t) fillout_pinfo (va_arg (arg, DWORD), 0);
        break;
 
       case CW_GETVERSIONINFO:
-       res = (DWORD) cygwin_version_strings;
+       res = (uintptr_t) cygwin_version_strings;
        break;
 
       case CW_READ_V1_MOUNT_TABLES:
@@ -247,7 +247,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
           Hilarity ensues if the DLL is not loaded like while the process
           is forking. */
        __cygwin_user_data.cxx_malloc = &default_cygwin_cxx_malloc;
-       res = (DWORD) &__cygwin_user_data;
+       res = (uintptr_t) &__cygwin_user_data;
        break;
 
       case CW_PERFILE:
@@ -264,7 +264,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
        break;
 
       case CW_GETPINFO_FULL:
-       res = (DWORD) fillout_pinfo (va_arg (arg, pid_t), 1);
+       res = (uintptr_t) fillout_pinfo (va_arg (arg, pid_t), 1);
        break;
 
       case CW_INIT_EXCEPTIONS:
@@ -299,7 +299,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
          else
            {
              set_errno (ESRCH);
-             res = (DWORD) -1;
+             res = (uintptr_t) -1;
            }
        }
        break;
@@ -337,7 +337,7 @@ cygwin_internal (cygwin_getinfo_types t, ...)
          size_t n;
          pid_t pid = va_arg (arg, pid_t);
          pinfo p (pid);
-         res = (DWORD) p->cmdline (n);
+         res = (uintptr_t) p->cmdline (n);
        }
        break;
       case CW_CHECK_NTSEC:
@@ -406,24 +406,24 @@ cygwin_internal (cygwin_getinfo_types t, ...)
          const char *name = va_arg (arg, const char *);
          const void *hookfn = va_arg (arg, const void *);
          WORD subsys;
-         res = (unsigned long) hook_or_detect_cygwin (name, hookfn, subsys);
+         res = (uintptr_t) hook_or_detect_cygwin (name, hookfn, subsys);
        }
        break;
       case CW_ARGV:
        {
          child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info ();
-         res = (unsigned long) (ci ? ci->moreinfo->argv : NULL);
+         res = (uintptr_t) (ci ? ci->moreinfo->argv : NULL);
        }
        break;
       case CW_ENVP:
        {
          child_info_spawn *ci = (child_info_spawn *) get_cygwin_startup_info ();
-         res = (unsigned long) (ci ? ci->moreinfo->envp : NULL);
+         res = (uintptr_t) (ci ? ci->moreinfo->envp : NULL);
        }
        break;
       case CW_DEBUG_SELF:
        error_start_init (va_arg (arg, const char *));
-       try_to_debug ();
+       res = try_to_debug ();
        break;
       case CW_SYNC_WINENV:
        create_winenv (NULL);
index d9d27f391e9de098d02efde8ebdc3f8daa8c68e4..7fc6e83e22cbac63057c19dbad469fbfe2845d47 100644 (file)
@@ -23,7 +23,7 @@ extern "C" int
 fcntl64 (int fd, int cmd, ...)
 {
   int res = -1;
-  void *arg = NULL;
+  intptr_t arg = 0;
   va_list args;
 
   pthread_testcancel ();
@@ -37,18 +37,32 @@ fcntl64 (int fd, int cmd, ...)
   if (cfd < 0)
     goto done;
 
+  /* FIXME?  All numerical args to fcntl are defined as long on Linux.
+     This relies on a really dirty trick on x86_64:  A 32 bit mov to
+     a register (e.g. mov $1, %edx) always sets the high 32 bit to 0.
+     We're following the Linux lead here since the third arg to any
+     function is in a register anyway (%r8 in MS ABI).  That's the easy
+     case which is covered here by always reading the arg with
+     sizeof (intptr_t) == sizeof (long) == sizeof (void*) which matches
+     all targets.
+     
+     However, the POSIX standard defines all numerical args as type int.
+     If we take that literally, we had a (small) problem on 64 bit, since
+     sizeof (void*) != sizeof (int).  If we would like to follow POSIX
+     more closely than Linux, we'd have to call va_arg on a per cmd basis. */
+
   va_start (args, cmd);
-  arg = va_arg (args, void *);
+  arg = va_arg (args, intptr_t);
   va_end (args);
 
   switch (cmd)
     {
     case F_DUPFD:
     case F_DUPFD_CLOEXEC:
-      if ((int) arg >= 0 && (int) arg < OPEN_MAX_MAX)
+      if (arg >= 0 && arg < OPEN_MAX_MAX)
        {
          int flags = cmd == F_DUPFD_CLOEXEC ? O_CLOEXEC : 0;
-         res = cygheap->fdtab.dup3 (fd, cygheap_fdnew (((int) arg) - 1), flags);
+         res = cygheap->fdtab.dup3 (fd, cygheap_fdnew ((arg) - 1), flags);
        }
       else
        {
@@ -60,7 +74,7 @@ fcntl64 (int fd, int cmd, ...)
     case F_SETLK:
     case F_SETLKW:
       {
-       struct __flock64 *fl = (struct __flock64 *) arg;
+       struct flock *fl = (struct flock *) arg;
        fl->l_type &= F_RDLCK | F_WRLCK | F_UNLCK;
        res = cfd->lock (cmd, fl);
       }
@@ -70,24 +84,27 @@ fcntl64 (int fd, int cmd, ...)
       break;
     }
 done:
-  syscall_printf ("%R = fcntl(%d, %d, %p)", res, fd, cmd, arg);
+  syscall_printf ("%R = fcntl(%d, %d, %ly)", res, fd, cmd, arg);
   return res;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (fcntl64, _fcntl)
+#else
 extern "C" int
 _fcntl (int fd, int cmd, ...)
 {
-  void *arg = NULL;
+  intptr_t arg = 0;
   va_list args;
   struct __flock32 *src = NULL;
-  struct __flock64 dst;
+  struct flock dst;
 
   myfault efault;
   if (efault.faulted (EFAULT))
     return -1;
 
   va_start (args, cmd);
-  arg = va_arg (args, void *);
+  arg = va_arg (args, intptr_t);
   va_end (args);
   if (cmd == F_GETLK || cmd == F_SETLK || cmd == F_SETLKW)
     {
@@ -97,7 +114,7 @@ _fcntl (int fd, int cmd, ...)
       dst.l_start = src->l_start;
       dst.l_len = src->l_len;
       dst.l_pid = src->l_pid;
-      arg = &dst;
+      arg = (intptr_t) &dst;
     }
   int res = fcntl64 (fd, cmd, arg);
   if (cmd == F_GETLK)
@@ -110,4 +127,4 @@ _fcntl (int fd, int cmd, ...)
     }
   return res;
 }
-
+#endif
index 66513e9d23b9dd133de7e69c9d07a09965506630..5443681f983e32ac664e133f15285342b5a426e0 100755 (executable)
@@ -421,8 +421,7 @@ _feinitialise (void)
   /* Check for presence of SSE: invoke CPUID #1, check EDX bit 25.  */
   eax = 1;
   __asm__ volatile ("cpuid" : "=d" (edx), "+a" (eax) :: "%ecx", "%ebx");
-  /* If this flag isn't set, or if the OS doesn't support SSE (NT4, at least
-     up to SP4) we'll avoid trying to execute any SSE.  */
+  /* If this flag isn't set we'll avoid trying to execute any SSE.  */
   if ((edx & (1 << 25)) != 0)
     use_sse = true;
 
index ab4048b1376d81ccdcf99ec3e66cd5a2a415f61e..4506670992f5157c267cd774b04f26f39d1a62da 100644 (file)
@@ -190,9 +190,9 @@ fhandler_base::set_flags (int flags, int supplied_bin)
 {
   int bin;
   int fmode;
-  debug_printf ("flags %p, supplied_bin %p", flags, supplied_bin);
+  debug_printf ("flags %y, supplied_bin %y", flags, supplied_bin);
   if ((bin = flags & (O_BINARY | O_TEXT)))
-    debug_printf ("O_TEXT/O_BINARY set in flags %p", bin);
+    debug_printf ("O_TEXT/O_BINARY set in flags %y", bin);
   else if (rbinset () && wbinset ())
     bin = rbinary () ? O_BINARY : O_TEXT;      // FIXME: Not quite right
   else if ((fmode = get_default_fmode (flags)) & O_BINARY)
@@ -217,34 +217,36 @@ fhandler_base::set_flags (int flags, int supplied_bin)
 /* Cover function to ReadFile to achieve (as much as possible) Posix style
    semantics and use of errno.  */
 void __stdcall
-fhandler_base::raw_read (void *ptr, size_t& ulen)
+fhandler_base::raw_read (void *ptr, size_t& len)
 {
-#define bytes_read ulen
-
+  NTSTATUS status;
+  IO_STATUS_BLOCK io;
   int try_noreserve = 1;
-  DWORD len = ulen;
 
 retry:
-  ulen = (size_t) -1;
-  BOOL res = ReadFile (get_handle (), ptr, len, (DWORD *) &ulen, NULL);
-  if (!res)
+  status = NtReadFile (get_handle (), NULL, NULL, NULL, &io, ptr, len,
+                      NULL, NULL);
+  if (NT_SUCCESS (status))
+    len = io.Information;
+  else
     {
       /* Some errors are not really errors.  Detect such cases here.  */
-
-      DWORD  errcode = GetLastError ();
-      switch (errcode)
+      switch (status)
        {
-       case ERROR_BROKEN_PIPE:
+       case STATUS_END_OF_FILE:
+       case STATUS_PIPE_BROKEN:
          /* This is really EOF.  */
-         bytes_read = 0;
+         len = 0;
          break;
-       case ERROR_MORE_DATA:
-         /* `bytes_read' is supposedly valid.  */
+       case STATUS_MORE_ENTRIES:
+       case STATUS_BUFFER_OVERFLOW:
+         /* `io.Information' is supposedly valid.  */
+         len = io.Information;
          break;
-       case ERROR_NOACCESS:
+       case STATUS_ACCESS_VIOLATION:
          if (is_at_eof (get_handle ()))
            {
-             bytes_read = 0;
+             len = 0;
              break;
            }
          if (try_noreserve)
@@ -261,23 +263,21 @@ retry:
                }
            }
          /*FALLTHRU*/
-       case ERROR_INVALID_FUNCTION:
-       case ERROR_INVALID_PARAMETER:
-       case ERROR_INVALID_HANDLE:
+       case STATUS_INVALID_DEVICE_REQUEST:
+       case STATUS_INVALID_PARAMETER:
+       case STATUS_INVALID_HANDLE:
          if (pc.isdir ())
            {
              set_errno (EISDIR);
-             bytes_read = (size_t) -1;
+             len = (size_t) -1;
              break;
            }
        default:
-         syscall_printf ("ReadFile %s(%p) failed, %E", get_name (), get_handle ());
-         __seterrno_from_win_error (errcode);
-         bytes_read = (size_t) -1;
+         __seterrno_from_nt_status (status);
+         len = (size_t) -1;
          break;
        }
     }
-#undef bytes_read
 }
 
 /* Cover function to WriteFile to provide Posix interface and semantics
@@ -388,7 +388,7 @@ fhandler_base::fhaccess (int flags, bool effective)
       return res;
     }
 
-  struct __stat64 st;
+  struct stat st;
   if (fstat (&st))
     goto done;
 
@@ -516,7 +516,7 @@ fhandler_base::open (int flags, mode_t mode)
   PFILE_FULL_EA_INFORMATION p = NULL;
   ULONG plen = 0;
 
-  syscall_printf ("(%S, %p)", pc.get_nt_native_path (), flags);
+  syscall_printf ("(%S, %y)", pc.get_nt_native_path (), flags);
 
   pc.get_object_attr (attr, *sec_none_cloexec (flags));
 
@@ -586,11 +586,10 @@ fhandler_base::open (int flags, mode_t mode)
            }
        }
 
-      /* Starting with Windows 2000, when trying to overwrite an already
-        existing file with FILE_ATTRIBUTE_HIDDEN and/or FILE_ATTRIBUTE_SYSTEM
-        attribute set, CreateFile fails with ERROR_ACCESS_DENIED.
-        Per MSDN you have to create the file with the same attributes as
-        already specified for the file. */
+      /* Trying to overwrite an already existing file with FILE_ATTRIBUTE_HIDDEN
+        and/or FILE_ATTRIBUTE_SYSTEM attribute set, NtCreateFile fails with
+        STATUS_ACCESS_DENIED.  Per MSDN you have to create the file with the
+        same attributes as already specified for the file. */
       if (((flags & O_CREAT) || create_disposition == FILE_OVERWRITE)
          && has_attribute (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM))
        file_attributes |= pc.file_attributes ();
@@ -705,12 +704,12 @@ fhandler_base::open (int flags, mode_t mode)
   res = 1;
   set_open_status ();
 done:
-  debug_printf ("%x = NtCreateFile "
-               "(%p, %x, %S, io, NULL, %x, %x, %x, %x, NULL, 0)",
+  debug_printf ("%y = NtCreateFile "
+               "(%p, %y, %S, io, NULL, %y, %y, %y, %y, NULL, 0)",
                status, fh, access, pc.get_nt_native_path (), file_attributes,
                shared, create_disposition, options);
 
-  syscall_printf ("%d = fhandler_base::open(%S, %p)",
+  syscall_printf ("%d = fhandler_base::open(%S, %y)",
                  res, pc.get_nt_native_path (), flags);
   return res;
 }
@@ -729,26 +728,13 @@ fhandler_base::read (void *in_ptr, size_t& len)
   char *ptr = (char *) in_ptr;
   ssize_t copied_chars = get_readahead_into_buffer (ptr, len);
 
-  if (copied_chars)
+  if (copied_chars || !len)
     {
       len = (size_t) copied_chars;
       goto out;
     }
 
-  len -= copied_chars;
-  if (!len)
-    {
-      len = (size_t) copied_chars;
-      goto out;
-    }
-
-  raw_read (ptr + copied_chars, len);
-  if (!copied_chars)
-    /* nothing */;
-  else if ((ssize_t) len > 0)
-    len += copied_chars;
-  else
-    len = copied_chars;
+  raw_read (ptr, len);
 
   if (rbinary () || (ssize_t) len <= 0)
     goto out;
@@ -791,24 +777,6 @@ fhandler_base::read (void *in_ptr, size_t& len)
 
   len = dst - (char *) ptr;
 
-#ifndef NOSTRACE
-  if (strace.active ())
-    {
-      char buf[16 * 6 + 1];
-      char *p = buf;
-
-      for (int i = 0; i < copied_chars && i < 16; ++i)
-       {
-         unsigned char c = ((unsigned char *) ptr)[i];
-         __small_sprintf (p, " %c", c);
-         p += strlen (p);
-       }
-      *p = '\0';
-      debug_printf ("read %d bytes (%s%s)", copied_chars, buf,
-                   copied_chars > 16 ? " ..." : "");
-    }
-#endif
-
 out:
   debug_printf ("returning %d, %s mode", len, rbinary () ? "binary" : "text");
 }
@@ -846,7 +814,7 @@ fhandler_base::write (const void *ptr, size_t len)
          if (NT_SUCCESS (status))
            pc.file_attributes (pc.file_attributes ()
                                | FILE_ATTRIBUTE_SPARSE_FILE);
-         debug_printf ("%p = NtFsControlFile(%S, FSCTL_SET_SPARSE)",
+         debug_printf ("%y = NtFsControlFile(%S, FSCTL_SET_SPARSE)",
                        status, pc.get_nt_native_path ());
        }
     }
@@ -1018,8 +986,8 @@ fhandler_base::writev (const struct iovec *const iov, const int iovcnt,
   return ret;
 }
 
-_off64_t
-fhandler_base::lseek (_off64_t offset, int whence)
+off_t
+fhandler_base::lseek (off_t offset, int whence)
 {
   NTSTATUS status;
   IO_STATUS_BLOCK io;
@@ -1071,7 +1039,7 @@ fhandler_base::lseek (_off64_t offset, int whence)
       __seterrno_from_nt_status (status);
       return -1;
     }
-  _off64_t res = fpi.CurrentByteOffset.QuadPart;
+  off_t res = fpi.CurrentByteOffset.QuadPart;
 
   /* When next we write(), we will check to see if *this* seek went beyond
      the end of the file and if so, potentially sparsify the file. */
@@ -1088,14 +1056,14 @@ fhandler_base::lseek (_off64_t offset, int whence)
 }
 
 ssize_t __stdcall
-fhandler_base::pread (void *, size_t, _off64_t)
+fhandler_base::pread (void *, size_t, off_t)
 {
   set_errno (ESPIPE);
   return -1;
 }
 
 ssize_t __stdcall
-fhandler_base::pwrite (void *, size_t, _off64_t)
+fhandler_base::pwrite (void *, size_t, off_t)
 {
   set_errno (ESPIPE);
   return -1;
@@ -1263,14 +1231,14 @@ fhandler_base::ioctl (unsigned int cmd, void *buf)
 }
 
 int
-fhandler_base::lock (int, struct __flock64 *)
+fhandler_base::lock (int, struct flock *)
 {
   set_errno (EINVAL);
   return -1;
 }
 
 int __reg2
-fhandler_base::fstat (struct __stat64 *buf)
+fhandler_base::fstat (struct stat *buf)
 {
   if (is_fs_special ())
     return fstat_fs (buf);
@@ -1351,7 +1319,7 @@ fhandler_base::dup (fhandler_base *child, int)
                            GetCurrentProcess (), &nh,
                            0, TRUE, DUPLICATE_SAME_ACCESS))
        {
-         debug_printf ("dup(%s) failed, handle %x, %E",
+         debug_printf ("dup(%s) failed, handle %p, %E",
                        get_name (), get_handle ());
          __seterrno ();
          return -1;
@@ -1371,7 +1339,7 @@ fhandler_base_overlapped::dup (fhandler_base *child, int flags)
   return res;
 }
 
-int fhandler_base::fcntl (int cmd, void *arg)
+int fhandler_base::fcntl (int cmd, intptr_t arg)
 {
   int res;
 
@@ -1381,12 +1349,12 @@ int fhandler_base::fcntl (int cmd, void *arg)
       res = close_on_exec () ? FD_CLOEXEC : 0;
       break;
     case F_SETFD:
-      set_close_on_exec (((int) arg & FD_CLOEXEC) ? 1 : 0);
+      set_close_on_exec ((arg & FD_CLOEXEC) ? 1 : 0);
       res = 0;
       break;
     case F_GETFL:
       res = get_flags ();
-      debug_printf ("GETFL: %p", res);
+      debug_printf ("GETFL: %y", res);
       break;
     case F_SETFL:
       {
@@ -1395,7 +1363,7 @@ int fhandler_base::fcntl (int cmd, void *arg)
           Since O_ASYNC isn't defined in fcntl.h it's currently
           ignored as well.  */
        const int allowed_flags = O_APPEND | O_NONBLOCK_MASK;
-       int new_flags = (int) arg & allowed_flags;
+       int new_flags = arg & allowed_flags;
        /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
           Set only the flag that has been passed in.  If both are set, just
           record O_NONBLOCK.   */
@@ -1679,7 +1647,7 @@ fhandler_base::fchmod (mode_t mode)
 }
 
 int
-fhandler_base::fchown (__uid32_t uid, __gid32_t gid)
+fhandler_base::fchown (uid_t uid, gid_t gid)
 {
   if (pc.is_fs_special ())
     return ((fhandler_disk_file *) this)->fhandler_disk_file::fchown (uid, gid);
@@ -1688,7 +1656,7 @@ fhandler_base::fchown (__uid32_t uid, __gid32_t gid)
 }
 
 int
-fhandler_base::facl (int cmd, int nentries, __aclent32_t *aclbufp)
+fhandler_base::facl (int cmd, int nentries, aclent_t *aclbufp)
 {
   int res = -1;
   switch (cmd)
@@ -1745,14 +1713,14 @@ fhandler_base::fsetxattr (const char *name, const void *value, size_t size,
 }
 
 int
-fhandler_base::fadvise (_off64_t offset, _off64_t length, int advice)
+fhandler_base::fadvise (off_t offset, off_t length, int advice)
 {
   set_errno (EINVAL);
   return -1;
 }
 
 int
-fhandler_base::ftruncate (_off64_t length, bool allow_truncate)
+fhandler_base::ftruncate (off_t length, bool allow_truncate)
 {
   set_errno (EINVAL);
   return -1;
@@ -1966,7 +1934,7 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
          wores = GetOverlappedResult (h, get_overlapped (), bytes, false);
          err = GetLastError ();
          ResetEvent (get_overlapped ()->hEvent);       /* Probably not needed but CYA */
-         debug_printf ("wfres %d, wores %d, bytes %u", wfres, wores, *bytes);
+         debug_printf ("wfres %u, wores %d, bytes %u", wfres, wores, *bytes);
          if (wores)
            res = overlapped_success;   /* operation succeeded */
          else if (wfres == WAIT_OBJECT_0 + 1)
@@ -1981,7 +1949,7 @@ fhandler_base_overlapped::wait_overlapped (bool inres, bool writing, DWORD *byte
            res = overlapped_nonblocking_no_data;       /* more handling below */
          else
            {
-             debug_printf ("GetOverLappedResult failed, h %p, bytes %u, %E", h, *bytes);
+             debug_printf ("GetOverlappedResult failed, h %p, bytes %u, %E", h, *bytes);
              res = overlapped_error;
            }
        }
@@ -2041,7 +2009,7 @@ fhandler_base_overlapped::raw_read (void *ptr, size_t& len)
        }
     }
   while (keep_looping);
-  len = (size_t) nbytes;
+  len = (nbytes == (DWORD) -1) ? (size_t) -1 : (size_t) nbytes;
 }
 
 ssize_t __reg3
@@ -2051,13 +2019,13 @@ fhandler_base_overlapped::raw_write (const void *ptr, size_t len)
   if (has_ongoing_io ())
     {
       set_errno (EAGAIN);
-      nbytes = (DWORD) -1;
+      nbytes = (size_t) -1;
     }
   else
     {
       size_t chunk;
       if (!max_atomic_write || len < max_atomic_write)
-       chunk = len;
+       chunk = MIN (len, INT_MAX);
       else if (is_nonblocking ())
        chunk = len = max_atomic_write;
       else
@@ -2065,7 +2033,7 @@ fhandler_base_overlapped::raw_write (const void *ptr, size_t len)
 
       nbytes = 0;
       DWORD nbytes_now = 0;
-      /* Write to fd in smaller chunks, accumlating a total.
+      /* Write to fd in smaller chunks, accumulating a total.
         If there's an error, just return the accumulated total
         unless the first write fails, in which case return value
         from wait_overlapped(). */
@@ -2095,7 +2063,7 @@ fhandler_base_overlapped::raw_write (const void *ptr, size_t len)
            }
        }
       if (!nbytes)
-       nbytes = nbytes_now;
+       nbytes = (nbytes_now == (DWORD) -1) ? (size_t) -1 : nbytes_now;
     }
   return nbytes;
 }
index d6c1cf656c951eaa33a3b3201628b3fb4944caea..86c0fa8e81052665e31856ee1e9aabec2c59d60c 100644 (file)
@@ -55,7 +55,7 @@ class inode_t;
 typedef struct __DIR DIR;
 struct dirent;
 struct iovec;
-struct __acl32;
+struct acl;
 
 enum dirent_states
 {
@@ -162,8 +162,8 @@ class fhandler_base
 
   HANDLE io_handle;
 
-  __ino64_t ino;       /* file ID or hashed filename, depends on FS. */
-  long _refcnt;
+  ino_t ino;   /* file ID or hashed filename, depends on FS. */
+  LONG _refcnt;
 
  protected:
   /* File open flags from open () and fcntl () calls */
@@ -182,8 +182,8 @@ class fhandler_base
   HANDLE read_state;
 
  public:
-  long inc_refcnt () {return InterlockedIncrement (&_refcnt);}
-  long dec_refcnt () {return InterlockedDecrement (&_refcnt);}
+  LONG inc_refcnt () {return InterlockedIncrement (&_refcnt);}
+  LONG dec_refcnt () {return InterlockedDecrement (&_refcnt);}
   class fhandler_base *archetype;
   int usecount;
 
@@ -209,10 +209,9 @@ class fhandler_base
   /* Non-virtual simple accessor functions. */
   void set_io_handle (HANDLE x) { io_handle = x; }
 
-  DWORD& get_device () { return dev (); }
-  DWORD get_major () { return dev ().get_major (); }
-  DWORD get_minor () { return dev ().get_minor (); }
-  virtual int get_unit () { return dev ().get_minor (); }
+  dev_t& get_device () { return dev (); }
+  _major_t get_major () { return dev ().get_major (); }
+  _minor_t get_minor () { return dev ().get_minor (); }
 
   ACCESS_MASK get_access () const { return access; }
   void set_access (ACCESS_MASK x) { access = x; }
@@ -295,8 +294,8 @@ class fhandler_base
   bool has_attribute (DWORD x) const {return pc.has_attribute (x);}
   const char *get_name () const { return pc.normalized_path; }
   const char *get_win32_name () { return pc.get_win32 (); }
-  __dev32_t get_dev () { return pc.fs_serial_number (); }
-  __ino64_t get_ino () { return ino ?: ino = hash_path_name (0, pc.get_nt_native_path ()); }
+  dev_t get_dev () { return pc.fs_serial_number (); }
+  ino_t get_ino () { return ino ?: ino = hash_path_name (0, pc.get_nt_native_path ()); }
   long long get_unique_id () const { return unique_id; }
   /* Returns name used for /proc/<pid>/fd in buf. */
   virtual char *get_proc_fd_name (char *buf);
@@ -328,48 +327,48 @@ class fhandler_base
   int open_fs (int, mode_t = 0);
 # define archetype_usecount(n) _archetype_usecount (__PRETTY_FUNCTION__, __LINE__, (n))
   int close_fs () { return fhandler_base::close (); }
-  virtual int __reg2 fstat (struct __stat64 *buf);
-  void __reg2 stat_fixup (struct __stat64 *buf);
-  int __reg2 fstat_fs (struct __stat64 *buf);
+  virtual int __reg2 fstat (struct stat *buf);
+  void __reg2 stat_fixup (struct stat *buf);
+  int __reg2 fstat_fs (struct stat *buf);
 private:
-  int __reg3 fstat_helper (struct __stat64 *buf,
+  int __reg3 fstat_helper (struct stat *buf,
                              DWORD nNumberOfLinks);
-  int __reg2 fstat_by_nfs_ea (struct __stat64 *buf);
-  int __reg2 fstat_by_handle (struct __stat64 *buf);
-  int __reg2 fstat_by_name (struct __stat64 *buf);
+  int __reg2 fstat_by_nfs_ea (struct stat *buf);
+  int __reg2 fstat_by_handle (struct stat *buf);
+  int __reg2 fstat_by_name (struct stat *buf);
 public:
   virtual int __reg2 fstatvfs (struct statvfs *buf);
   int __reg2 utimens_fs (const struct timespec *);
   virtual int __reg1 fchmod (mode_t mode);
-  virtual int __reg2 fchown (__uid32_t uid, __gid32_t gid);
-  virtual int __reg3 facl (int, int, __acl32 *);
+  virtual int __reg2 fchown (uid_t uid, gid_t gid);
+  virtual int __reg3 facl (int, int, struct acl *);
   virtual ssize_t __reg3 fgetxattr (const char *, void *, size_t);
   virtual int __reg3 fsetxattr (const char *, const void *, size_t, int);
-  virtual int __reg3 fadvise (_off64_t, _off64_t, int);
-  virtual int __reg3 ftruncate (_off64_t, bool);
+  virtual int __reg3 fadvise (off_t, off_t, int);
+  virtual int __reg3 ftruncate (off_t, bool);
   virtual int __reg2 link (const char *);
   virtual int __reg2 utimens (const struct timespec *);
   virtual int __reg1 fsync ();
   virtual int ioctl (unsigned int cmd, void *);
-  virtual int fcntl (int cmd, void *);
+  virtual int fcntl (int cmd, intptr_t);
   virtual char const *ttyname () { return get_name (); }
   virtual void __reg3 read (void *ptr, size_t& len);
   virtual ssize_t __stdcall write (const void *ptr, size_t len);
   virtual ssize_t __stdcall readv (const struct iovec *, int iovcnt, ssize_t tot = -1);
   virtual ssize_t __stdcall writev (const struct iovec *, int iovcnt, ssize_t tot = -1);
-  virtual ssize_t __reg3 pread (void *, size_t, _off64_t);
-  virtual ssize_t __reg3 pwrite (void *, size_t, _off64_t);
-  virtual _off64_t lseek (_off64_t offset, int whence);
-  virtual int lock (int, struct __flock64 *);
+  virtual ssize_t __reg3 pread (void *, size_t, off_t);
+  virtual ssize_t __reg3 pwrite (void *, size_t, off_t);
+  virtual off_t lseek (off_t offset, int whence);
+  virtual int lock (int, struct flock *);
   virtual int dup (fhandler_base *child, int flags);
   virtual int fpathconf (int);
 
   virtual HANDLE mmap (caddr_t *addr, size_t len, int prot,
-                      int flags, _off64_t off);
+                      int flags, off_t off);
   virtual int munmap (HANDLE h, caddr_t addr, size_t len);
   virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
   virtual bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
-                                     _off64_t offset, DWORD size,
+                                     off_t offset, DWORD size,
                                      void *address);
 
   void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;}
@@ -480,12 +479,12 @@ class fhandler_socket: public fhandler_base
   int wait_for_events (const long event_mask, const DWORD flags);
   void release_events ();
 
-  pid_t     sec_pid;
-  __uid32_t sec_uid;
-  __gid32_t sec_gid;
-  pid_t     sec_peer_pid;
-  __uid32_t sec_peer_uid;
-  __gid32_t sec_peer_gid;
+  pid_t sec_pid;
+  uid_t sec_uid;
+  gid_t sec_gid;
+  pid_t sec_peer_pid;
+  uid_t sec_peer_uid;
+  gid_t sec_peer_gid;
   void af_local_set_secret (char *);
   void af_local_setblocking (bool &, bool &);
   void af_local_unsetblocking (bool, bool);
@@ -536,7 +535,14 @@ class fhandler_socket: public fhandler_base
  public:
   fhandler_socket ();
   ~fhandler_socket ();
-  int get_socket () { return (int) get_handle(); }
+/* Originally get_socket returned an int, which is not a good idea
+   to cast a handle to on 64 bit.  The right type here is very certainly
+   SOCKET instead.  On the other hand, we don't want to have to include
+   winsock.h just to build fhandler.h.  Therefore we define get_socket
+   now only when building network related code. */
+#ifdef __INSIDE_CYGWIN_NET__
+  SOCKET get_socket () { return (SOCKET) get_handle(); }
+#endif
   fhandler_socket *is_socket () { return this; }
 
   IMPLEMENT_STATUS_FLAG (bool, async_io)
@@ -552,7 +558,7 @@ class fhandler_socket: public fhandler_base
   int accept4 (struct sockaddr *peer, int *len, int flags);
   int getsockname (struct sockaddr *name, int *namelen);
   int getpeername (struct sockaddr *name, int *namelen);
-  int getpeereid (pid_t *pid, __uid32_t *euid, __gid32_t *egid);
+  int getpeereid (pid_t *pid, uid_t *euid, gid_t *egid);
 
   int open (int flags, mode_t mode = 0);
   void __reg3 read (void *ptr, size_t& len);
@@ -570,8 +576,8 @@ class fhandler_socket: public fhandler_base
   ssize_t sendmsg (const struct msghdr *msg, int flags);
 
   int ioctl (unsigned int cmd, void *);
-  int fcntl (int cmd, void *);
-  _off64_t lseek (_off64_t, int) { return 0; }
+  int fcntl (int cmd, intptr_t);
+  off_t lseek (off_t, int) { return 0; }
   int shutdown (int how);
   int close ();
   void hclose (HANDLE) {close ();}
@@ -595,11 +601,11 @@ class fhandler_socket: public fhandler_base
   void set_peer_sun_path (const char *path);
   char *get_peer_sun_path () {return peer_sun_path;}
 
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   int __reg2 fstatvfs (struct statvfs *buf);
   int __reg1 fchmod (mode_t mode);
-  int __reg2 fchown (__uid32_t uid, __gid32_t gid);
-  int __reg3 facl (int, int, __acl32 *);
+  int __reg2 fchown (uid_t uid, gid_t gid);
+  int __reg3 facl (int, int, struct acl *);
   int __reg2 link (const char *);
 
   fhandler_socket (void *) {}
@@ -693,7 +699,7 @@ public:
 
   void set_popen_pid (pid_t pid) {popen_pid = pid;}
   pid_t get_popen_pid () const {return popen_pid;}
-  _off64_t lseek (_off64_t offset, int whence);
+  off_t lseek (off_t offset, int whence);
   select_record *select_read (select_stuff *);
   select_record *select_write (select_stuff *);
   select_record *select_except (select_stuff *);
@@ -702,8 +708,8 @@ public:
   int dup (fhandler_base *child, int);
   int ioctl (unsigned int cmd, void *);
   int __reg2 fstatvfs (struct statvfs *buf);
-  int __reg3 fadvise (_off64_t, _off64_t, int);
-  int __reg3 ftruncate (_off64_t, bool);
+  int __reg3 fadvise (off_t, off_t, int);
+  int __reg3 ftruncate (off_t, bool);
   int init (HANDLE, DWORD, mode_t);
   static int create (fhandler_pipe *[2], unsigned, int);
   static DWORD create (LPSECURITY_ATTRIBUTES, HANDLE *, HANDLE *, DWORD,
@@ -770,7 +776,7 @@ class fhandler_mailslot : public fhandler_base_overlapped
   POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &, PUNICODE_STRING, int);
  public:
   fhandler_mailslot ();
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   int open (int flags, mode_t mode = 0);
   ssize_t __reg3 raw_write (const void *, size_t);
   int ioctl (unsigned int cmd, void *);
@@ -799,10 +805,10 @@ class fhandler_dev_raw: public fhandler_base
  protected:
   char *devbufalloc;
   char *devbuf;
-  size_t devbufalign;
-  size_t devbufsiz;
-  size_t devbufstart;
-  size_t devbufend;
+  DWORD devbufalign;
+  DWORD devbufsiz;
+  DWORD devbufstart;
+  DWORD devbufend;
   struct status_flags
   {
     unsigned lastblk_to_read : 1;
@@ -819,7 +825,7 @@ class fhandler_dev_raw: public fhandler_base
 
   int open (int flags, mode_t mode = 0);
 
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
 
   int dup (fhandler_base *child, int);
   int ioctl (unsigned int cmd, void *buf);
@@ -856,7 +862,7 @@ struct part_t
 class fhandler_dev_floppy: public fhandler_dev_raw
 {
  private:
-  _off64_t drive_size;
+  off_t drive_size;
   part_t *partitions;
   struct status_flags
   {
@@ -867,7 +873,7 @@ class fhandler_dev_floppy: public fhandler_dev_raw
 
   IMPLEMENT_STATUS_FLAG (bool, eom_detected)
 
-  inline _off64_t get_current_position ();
+  inline off_t get_current_position ();
   int get_drive_info (struct hd_geometry *geo);
 
   int lock_partition (DWORD to_write);
@@ -883,7 +889,7 @@ class fhandler_dev_floppy: public fhandler_dev_raw
   int dup (fhandler_base *child, int);
   void __reg3 raw_read (void *ptr, size_t& ulen);
   ssize_t __reg3 raw_write (const void *ptr, size_t ulen);
-  _off64_t lseek (_off64_t offset, int whence);
+  off_t lseek (off_t offset, int whence);
   int ioctl (unsigned int cmd, void *buf);
 
   fhandler_dev_floppy (void *) {}
@@ -907,7 +913,7 @@ class fhandler_dev_floppy: public fhandler_dev_raw
 class fhandler_dev_tape: public fhandler_dev_raw
 {
   HANDLE mt_mtx;
-  HANDLE mt_evt;
+  OVERLAPPED ov;
 
   bool is_rewind_device () { return get_minor () < 128; }
   unsigned int driveno () { return (unsigned int) get_minor () & 0x7f; }
@@ -925,9 +931,9 @@ class fhandler_dev_tape: public fhandler_dev_raw
   void __reg3 raw_read (void *ptr, size_t& ulen);
   ssize_t __reg3 raw_write (const void *ptr, size_t ulen);
 
-  virtual _off64_t lseek (_off64_t offset, int whence);
+  virtual off_t lseek (off_t offset, int whence);
 
-  virtual int __reg2 fstat (struct __stat64 *buf);
+  virtual int __reg2 fstat (struct stat *buf);
 
   virtual int dup (fhandler_base *child, int);
   virtual void fixup_after_fork (HANDLE parent);
@@ -969,25 +975,25 @@ class fhandler_disk_file: public fhandler_base
   int close ();
   int dup (fhandler_base *child, int);
   void fixup_after_fork (HANDLE parent);
-  int lock (int, struct __flock64 *);
+  int lock (int, struct flock *);
   bool isdevice () const { return false; }
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   int __reg1 fchmod (mode_t mode);
-  int __reg2 fchown (__uid32_t uid, __gid32_t gid);
-  int __reg3 facl (int, int, __acl32 *);
+  int __reg2 fchown (uid_t uid, gid_t gid);
+  int __reg3 facl (int, int, struct acl *);
   ssize_t __reg3 fgetxattr (const char *, void *, size_t);
   int __reg3 fsetxattr (const char *, const void *, size_t, int);
-  int __reg3 fadvise (_off64_t, _off64_t, int);
-  int __reg3 ftruncate (_off64_t, bool);
+  int __reg3 fadvise (off_t, off_t, int);
+  int __reg3 ftruncate (off_t, bool);
   int __reg2 link (const char *);
   int __reg2 utimens (const struct timespec *);
   int __reg2 fstatvfs (struct statvfs *buf);
 
-  HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, _off64_t off);
+  HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, off_t off);
   int munmap (HANDLE h, caddr_t addr, size_t len);
   int msync (HANDLE h, caddr_t addr, size_t len, int flags);
   bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
-                             _off64_t offset, DWORD size, void *address);
+                             off_t offset, DWORD size, void *address);
   int mkdir (mode_t mode);
   int rmdir ();
   DIR __reg2 *opendir (int fd);
@@ -997,8 +1003,8 @@ class fhandler_disk_file: public fhandler_base
   void rewinddir (DIR *);
   int closedir (DIR *);
 
-  ssize_t __reg3 pread (void *, size_t, _off64_t);
-  ssize_t __reg3 pwrite (void *, size_t, _off64_t);
+  ssize_t __reg3 pread (void *, size_t, off_t);
+  ssize_t __reg3 pwrite (void *, size_t, off_t);
 
   fhandler_disk_file (void *) {}
 
@@ -1026,7 +1032,7 @@ public:
   fhandler_dev ();
   int open (int flags, mode_t mode);
   int close ();
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   int __reg2 fstatvfs (struct statvfs *buf);
   DIR __reg2 *opendir (int fd);
   int __reg3 readdir (DIR *, dirent *);
@@ -1068,7 +1074,7 @@ class fhandler_cygdrive: public fhandler_disk_file
   int __reg3 readdir (DIR *, dirent *);
   void rewinddir (DIR *);
   int closedir (DIR *);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   int __reg2 fstatvfs (struct statvfs *buf);
 
   fhandler_cygdrive (void *) {}
@@ -1120,7 +1126,7 @@ class fhandler_serial: public fhandler_base
   int switch_modem_lines (int set, int clr);
   int tcsetattr (int a, const struct termios *t);
   int tcgetattr (struct termios *t);
-  _off64_t lseek (_off64_t, int) { return 0; }
+  off_t lseek (off_t, int) { return 0; }
   int tcflush (int);
   bool is_tty () const { return true; }
   void fixup_after_fork (HANDLE parent);
@@ -1190,7 +1196,7 @@ class fhandler_termios: public fhandler_base
   virtual DWORD __acquire_output_mutex (const char *fn, int ln, DWORD ms) {return 1;}
   virtual void __release_output_mutex (const char *fn, int ln) {}
   void echo_erase (int force = 0);
-  virtual _off64_t lseek (_off64_t, int);
+  virtual off_t lseek (off_t, int);
   pid_t tcgetsid ();
 
   fhandler_termios (void *) {}
@@ -1438,7 +1444,7 @@ class fhandler_pty_common: public fhandler_termios
   void __release_output_mutex (const char *fn, int ln);
 
   int close ();
-  _off64_t lseek (_off64_t, int);
+  off_t lseek (off_t, int);
   bool bytes_available (DWORD& n);
   void set_close_on_exec (bool val);
   select_record *select_read (select_stuff *);
@@ -1493,11 +1499,10 @@ class fhandler_pty_slave: public fhandler_pty_common
   void fixup_after_exec ();
 
   select_record *select_read (select_stuff *);
-  int get_unit ();
   virtual char const *ttyname () { return pc.dev.name; }
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   int __reg1 fchmod (mode_t mode);
-  int __reg2 fchown (__uid32_t uid, __gid32_t gid);
+  int __reg2 fchown (uid_t uid, gid_t gid);
 
   fhandler_pty_slave (void *) {}
 
@@ -1611,14 +1616,14 @@ class fhandler_dev_zero: public fhandler_base
   int open (int flags, mode_t mode = 0);
   ssize_t __stdcall write (const void *ptr, size_t len);
   void __reg3 read (void *ptr, size_t& len);
-  _off64_t lseek (_off64_t offset, int whence);
+  off_t lseek (off_t offset, int whence);
 
   virtual HANDLE mmap (caddr_t *addr, size_t len, int prot,
-                      int flags, _off64_t off);
+                      int flags, off_t off);
   virtual int munmap (HANDLE h, caddr_t addr, size_t len);
   virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
   virtual bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
-                                     _off64_t offset, DWORD size,
+                                     off_t offset, DWORD size,
                                      void *address);
 
   fhandler_dev_zero (void *) {}
@@ -1644,7 +1649,7 @@ class fhandler_dev_random: public fhandler_base
  protected:
   HCRYPTPROV crypt_prov;
   long pseudo;
-  _off64_t dummy_offset;
+  off_t dummy_offset;
 
   bool crypt_gen_random (void *ptr, size_t len);
   int pseudo_write (const void *ptr, size_t len);
@@ -1655,7 +1660,7 @@ class fhandler_dev_random: public fhandler_base
   int open (int flags, mode_t mode = 0);
   ssize_t __stdcall write (const void *ptr, size_t len);
   void __reg3 read (void *ptr, size_t& len);
-  _off64_t lseek (_off64_t offset, int whence);
+  off_t lseek (off_t offset, int whence);
   int close ();
   int dup (fhandler_base *child, int);
 
@@ -1680,8 +1685,8 @@ class fhandler_dev_random: public fhandler_base
 class fhandler_dev_mem: public fhandler_base
 {
  protected:
-  DWORD mem_size;
-  _off64_t pos;
+  SIZE_T mem_size;
+  off_t pos;
 
  public:
   fhandler_dev_mem ();
@@ -1690,14 +1695,14 @@ class fhandler_dev_mem: public fhandler_base
   int open (int flags, mode_t mode = 0);
   ssize_t __stdcall write (const void *ptr, size_t ulen);
   void __reg3 read (void *ptr, size_t& len);
-  _off64_t lseek (_off64_t offset, int whence);
-  int __reg2 fstat (struct __stat64 *buf);
+  off_t lseek (off_t offset, int whence);
+  int __reg2 fstat (struct stat *buf);
 
-  HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, _off64_t off);
+  HANDLE mmap (caddr_t *addr, size_t len, int prot, int flags, off_t off);
   int munmap (HANDLE h, caddr_t addr, size_t len);
   int msync (HANDLE h, caddr_t addr, size_t len, int flags);
   bool fixup_mmap_after_fork (HANDLE h, int prot, int flags,
-                             _off64_t offset, DWORD size, void *address);
+                             off_t offset, DWORD size, void *address);
 
   fhandler_dev_mem (void *) {}
 
@@ -1719,17 +1724,17 @@ class fhandler_dev_mem: public fhandler_base
 
 class fhandler_dev_clipboard: public fhandler_base
 {
-  _off64_t pos;
+  off_t pos;
   void *membuffer;
   size_t msize;
  public:
   fhandler_dev_clipboard ();
   int is_windows () { return 1; }
   int open (int flags, mode_t mode = 0);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   ssize_t __stdcall write (const void *ptr, size_t len);
   void __reg3 read (void *ptr, size_t& len);
-  _off64_t lseek (_off64_t offset, int whence);
+  off_t lseek (off_t offset, int whence);
   int close ();
 
   int dup (fhandler_base *child, int);
@@ -1765,7 +1770,7 @@ class fhandler_windows: public fhandler_base
   ssize_t __stdcall write (const void *ptr, size_t len);
   void __reg3 read (void *ptr, size_t& len);
   int ioctl (unsigned int cmd, void *);
-  _off64_t lseek (_off64_t, int) { return 0; }
+  off_t lseek (off_t, int) { return 0; }
   int close () { return 0; }
 
   void set_close_on_exec (bool val);
@@ -1812,7 +1817,7 @@ class fhandler_dev_dsp: public fhandler_base
   ssize_t __stdcall write (const void *ptr, size_t len);
   void __reg3 read (void *ptr, size_t& len);
   int ioctl (unsigned int cmd, void *);
-  _off64_t lseek (_off64_t, int);
+  off_t lseek (off_t, int);
   int close ();
   void fixup_after_fork (HANDLE parent);
   void fixup_after_exec ();
@@ -1843,8 +1848,8 @@ class fhandler_virtual : public fhandler_base
 {
  protected:
   char *filebuf;
-  _off64_t filesize;
-  _off64_t position;
+  off_t filesize;
+  off_t position;
   int fileid; // unique within each class
  public:
 
@@ -1859,15 +1864,14 @@ class fhandler_virtual : public fhandler_base
   int closedir (DIR *);
   ssize_t __stdcall write (const void *ptr, size_t len);
   void __reg3 read (void *ptr, size_t& len);
-  _off64_t lseek (_off64_t, int);
+  off_t lseek (off_t, int);
   int dup (fhandler_base *child, int);
   int open (int flags, mode_t mode = 0);
   int close ();
-  int __reg2 fstat (struct stat *buf);
   int __reg2 fstatvfs (struct statvfs *buf);
   int __reg1 fchmod (mode_t mode);
-  int __reg2 fchown (__uid32_t uid, __gid32_t gid);
-  int __reg3 facl (int, int, __acl32 *);
+  int __reg2 fchown (uid_t uid, gid_t gid);
+  int __reg3 facl (int, int, struct acl *);
   virtual bool fill_filebuf ();
   char *get_filebuf () { return filebuf; }
   void fixup_after_exec ();
@@ -1901,7 +1905,7 @@ class fhandler_proc: public fhandler_virtual
   static fh_devices get_proc_fhandler (const char *path);
 
   int open (int flags, mode_t mode = 0);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   bool fill_filebuf ();
 
   fhandler_proc (void *) {}
@@ -1926,7 +1930,7 @@ class fhandler_procsys: public fhandler_virtual
 {
  public:
   fhandler_procsys ();
-  virtual_ftype_t __reg2 exists(struct __stat64 *buf);
+  virtual_ftype_t __reg2 exists(struct stat *buf);
   virtual_ftype_t exists();
   DIR __reg2 *opendir (int fd);
   int __reg3 readdir (DIR *, dirent *);
@@ -1937,7 +1941,7 @@ class fhandler_procsys: public fhandler_virtual
   int close ();
   void __reg3 read (void *ptr, size_t& len);
   ssize_t __stdcall write (const void *ptr, size_t len);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   bool fill_filebuf ();
 
   fhandler_procsys (void *) {}
@@ -1966,7 +1970,7 @@ class fhandler_procsysvipc: public fhandler_proc
   virtual_ftype_t exists();
   int __reg3 readdir (DIR *, dirent *);
   int open (int flags, mode_t mode = 0);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   bool fill_filebuf ();
 
   fhandler_procsysvipc (void *) {}
@@ -1997,7 +2001,7 @@ class fhandler_netdrive: public fhandler_virtual
   void rewinddir (DIR *);
   int closedir (DIR *);
   int open (int flags, mode_t mode = 0);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
 
   fhandler_netdrive (void *) {}
 
@@ -2035,7 +2039,7 @@ class fhandler_registry: public fhandler_proc
   int closedir (DIR *);
 
   int open (int flags, mode_t mode = 0);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   bool fill_filebuf ();
   int close ();
   int dup (fhandler_base *child, int);
@@ -2069,7 +2073,7 @@ class fhandler_process: public fhandler_proc
   int closedir (DIR *);
   int __reg3 readdir (DIR *, dirent *);
   int open (int flags, mode_t mode = 0);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   bool fill_filebuf ();
 
   fhandler_process (void *) {}
@@ -2098,7 +2102,7 @@ class fhandler_procnet: public fhandler_proc
   virtual_ftype_t exists();
   int __reg3 readdir (DIR *, dirent *);
   int open (int flags, mode_t mode = 0);
-  int __reg2 fstat (struct __stat64 *buf);
+  int __reg2 fstat (struct stat *buf);
   bool fill_filebuf ();
 
   fhandler_procnet (void *) {}
index 85fa1a4183226557dcf3828f23f6e0257ee5c422..1118137c140d49c2f1596e30d557c2c81942f2fe 100644 (file)
@@ -29,7 +29,7 @@ details. */
  * changed? How does /dev/clipboard operate under (say) linux?
  */
 
-static const NO_COPY WCHAR *CYGWIN_NATIVE = L"CYGWIN_NATIVE_CLIPBOARD";
+static const WCHAR *CYGWIN_NATIVE = L"CYGWIN_NATIVE_CLIPBOARD";
 /* this is MT safe because windows format id's are atomic */
 static UINT cygnativeformat;
 
@@ -181,7 +181,7 @@ fhandler_dev_clipboard::write (const void *buf, size_t len)
 }
 
 int __reg2
-fhandler_dev_clipboard::fstat (struct __stat64 *buf)
+fhandler_dev_clipboard::fstat (struct stat *buf)
 {
   buf->st_mode = S_IFCHR | STD_RBITS | STD_WBITS | S_IWGRP | S_IWOTH;
   buf->st_uid = geteuid32 ();
@@ -243,7 +243,7 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
     {
       cygcb_t *clipbuf = (cygcb_t *) cb_data;
 
-      if (pos < clipbuf->len)
+      if (pos < (off_t) clipbuf->len)
        {
          ret = ((len > (clipbuf->len - pos)) ? (clipbuf->len - pos) : len);
          memcpy (ptr, clipbuf->data + pos , ret);
@@ -267,7 +267,7 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
       wchar_t *buf = (wchar_t *) cb_data;
 
       size_t glen = GlobalSize (hglb) / sizeof (WCHAR) - 1;
-      if (pos < glen)
+      if (pos < (off_t) glen)
        {
          /* If caller's buffer is too small to hold at least one
             max-size character, redirect algorithm to local
@@ -325,8 +325,8 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
   len = ret;
 }
 
-_off64_t
-fhandler_dev_clipboard::lseek (_off64_t offset, int whence)
+off_t
+fhandler_dev_clipboard::lseek (off_t offset, int whence)
 {
   /* On reads we check this at read time, not seek time.
    * On writes we use this to decide how to write - empty and write, or open, copy, empty
index d66f3a8d7bd96a3a381cff81a8367fb6f451025c..7e7b6cf5837b550347453c4efb29f19984f39fc9 100644 (file)
@@ -216,7 +216,7 @@ fhandler_console::setup ()
 tty_min *
 tty_list::get_cttyp ()
 {
-  _dev_t n = myself->ctty;
+  dev_t n = myself->ctty;
   if (iscons_dev (n))
     return fhandler_console::shared_console_info ?
       &fhandler_console::shared_console_info->tty_min_state : NULL;
@@ -944,9 +944,9 @@ fhandler_console::ioctl (unsigned int cmd, void *arg)
        *(int *) arg = (dev_state.metabit) ? K_METABIT : K_ESCPREFIX;
        return 0;
       case KDSKBMETA:
-       if ((int) arg == K_METABIT)
+       if ((intptr_t) arg == K_METABIT)
          dev_state.metabit = TRUE;
-       else if ((int) arg == K_ESCPREFIX)
+       else if ((intptr_t) arg == K_ESCPREFIX)
          dev_state.metabit = FALSE;
        else
          {
@@ -1013,7 +1013,7 @@ fhandler_console::output_tcsetattr (int, struct termios const *t)
   int res = SetConsoleMode (get_output_handle (), flags) ? 0 : -1;
   if (res)
     __seterrno_from_win_error (GetLastError ());
-  syscall_printf ("%d = tcsetattr(,%x) (ENABLE FLAGS %x) (lflag %x oflag %x)",
+  syscall_printf ("%d = tcsetattr(,%p) (ENABLE FLAGS %y) (lflag %y oflag %y)",
                  res, t, flags, t->c_lflag, t->c_oflag);
   return res;
 }
@@ -1075,7 +1075,7 @@ fhandler_console::input_tcsetattr (int, struct termios const *t)
       res = SetConsoleMode (get_io_handle (), flags) ? 0 : -1;
       if (res < 0)
        __seterrno ();
-      syscall_printf ("%d = tcsetattr(,%x) enable flags %p, c_lflag %p iflag %p",
+      syscall_printf ("%d = tcsetattr(,%p) enable flags %y, c_lflag %y iflag %y",
                      res, t, flags, t->c_lflag, t->c_iflag);
     }
 
@@ -1126,7 +1126,7 @@ fhandler_console::tcgetattr (struct termios *t)
       /* All the output bits we can ignore */
       res = 0;
     }
-  syscall_printf ("%d = tcgetattr(%p) enable flags %p, t->lflag %p, t->iflag %p",
+  syscall_printf ("%d = tcgetattr(%p) enable flags %y, t->lflag %y, t->iflag %y",
                 res, t, flags, t->c_lflag, t->c_iflag);
   return res;
 }
@@ -2044,7 +2044,7 @@ fhandler_console::write (const void *vsrc, size_t len)
   tmp_pathbuf tp;
   write_buf = tp.w_get ();
 
-  debug_printf ("%x, %d", vsrc, len);
+  debug_printf ("%p, %ld", vsrc, len);
 
   while (src < end)
     {
@@ -2211,15 +2211,15 @@ fhandler_console::write (const void *vsrc, size_t len)
        }
     }
 
-  syscall_printf ("%d = fhandler_console::write(...)", len);
+  syscall_printf ("%ld = fhandler_console::write(...)", len);
 
   return len;
 }
 
-static struct {
+static const struct {
   int vk;
   const char *val[4];
-} keytable[] NO_COPY = {
+} keytable[] = {
               /* NORMAL */    /* SHIFT */     /* CTRL */     /* CTRL-SHIFT */
   /* Unmodified and Alt-modified keypad keys comply with linux console
      SHIFT, CTRL, CTRL-SHIFT modifiers comply with xterm modifier usage */
@@ -2366,7 +2366,7 @@ fhandler_console::create_invisible_console (HWINSTA horig)
   return b;
 }
 
-/* Ugly workaround for Windows 7.
+/* Ugly workaround for Windows 7 and later.
 
    First try to just attach to any console which may have started this
    app.  If that works use this as our "invisible console".
index 6e95453832f5e56c9d0600e5890fe3cde631edf8..8a9808f8e97e721627db50d872aebb9b11239404 100644 (file)
@@ -68,7 +68,7 @@ fhandler_dev::close ()
 }
 
 int __reg2
-fhandler_dev::fstat (struct __stat64 *st)
+fhandler_dev::fstat (struct stat *st)
 {
   /* If /dev really exists on disk, return correct disk information. */
   if (pc.fs_got_fs ())
index 6836f366f7dc5ddfdffbe5e321928aa1932362e4..93b02fe11101181ffc68cc405f2d1fc08501f654 100644 (file)
@@ -44,11 +44,11 @@ class __DIR_mounts
 #define __DIR_CYGDRIVE (MAX_MOUNTS+1)
 #define __DIR_DEV      (MAX_MOUNTS+2)
 
-  __ino64_t eval_ino (int idx)
+  ino_t eval_ino (int idx)
     {
-      __ino64_t ino = 0;
+      ino_t ino = 0;
       char fname[parent_dir_len + mounts[idx].Length + 2];
-      struct __stat64 st;
+      struct stat st;
 
       char *c = stpcpy (fname, parent_dir);
       if (c[- 1] != '/')
@@ -76,7 +76,7 @@ public:
        RtlFreeUnicodeString (&mounts[i]);
       RtlFreeUnicodeString (&cygdrive);
     }
-  __ino64_t check_mount (PUNICODE_STRING fname, __ino64_t ino,
+  ino_t check_mount (PUNICODE_STRING fname, ino_t ino,
                         bool eval = true)
     {
       if (parent_dir_len == 1) /* root dir */
@@ -106,7 +106,7 @@ public:
          }
       return ino;
     }
-  __ino64_t check_missing_mount (PUNICODE_STRING retname = NULL)
+  ino_t check_missing_mount (PUNICODE_STRING retname = NULL)
     {
       for (int i = 0; i < count; ++i)
        if (!found[i])
@@ -152,7 +152,7 @@ public:
 };
 
 inline bool
-path_conv::isgood_inode (__ino64_t ino) const
+path_conv::isgood_inode (ino_t ino) const
 {
   /* If the FS doesn't support nonambiguous inode numbers anyway, bail out
      immediately. */
@@ -220,7 +220,7 @@ readdir_check_reparse_point (POBJECT_ATTRIBUTES attr)
   return ret;
 }
 
-inline __ino64_t
+inline ino_t
 path_conv::get_ino_by_handle (HANDLE hdl)
 {
   IO_STATUS_BLOCK io;
@@ -256,7 +256,7 @@ path_conv::ndisk_links (DWORD nNumberOfLinks)
 
   unsigned count = 0;
   bool first = true;
-  PFILE_BOTH_DIRECTORY_INFORMATION fdibuf = (PFILE_BOTH_DIRECTORY_INFORMATION)
+  PFILE_BOTH_DIR_INFORMATION fdibuf = (PFILE_BOTH_DIR_INFORMATION)
                                       alloca (65536);
   __DIR_mounts *dir = new __DIR_mounts (normalized_path);
   while (NT_SUCCESS (NtQueryDirectoryFile (fh, NULL, NULL, NULL, &io, fdibuf,
@@ -272,9 +272,9 @@ path_conv::ndisk_links (DWORD nNumberOfLinks)
          if (fdibuf->FileNameLength != 2 || fdibuf->FileName[0] != L'.')
            count = 2;
        }
-      for (PFILE_BOTH_DIRECTORY_INFORMATION pfdi = fdibuf;
+      for (PFILE_BOTH_DIR_INFORMATION pfdi = fdibuf;
           pfdi;
-          pfdi = (PFILE_BOTH_DIRECTORY_INFORMATION)
+          pfdi = (PFILE_BOTH_DIR_INFORMATION)
                  (pfdi->NextEntryOffset ? (PBYTE) pfdi + pfdi->NextEntryOffset
                                         : NULL))
        {
@@ -320,7 +320,7 @@ path_conv::ndisk_links (DWORD nNumberOfLinks)
    The content is the NFS equivalent of struct stat. so there's not much
    to do here except for copying. */
 int __stdcall
-fhandler_base::fstat_by_nfs_ea (struct __stat64 *buf)
+fhandler_base::fstat_by_nfs_ea (struct stat *buf)
 {
   fattr3 *nfs_attr = pc.nfsattr ();
 
@@ -353,14 +353,17 @@ fhandler_base::fstat_by_nfs_ea (struct __stat64 *buf)
   buf->st_size = nfs_attr->size;
   buf->st_blksize = PREFERRED_IO_BLKSIZE;
   buf->st_blocks = (nfs_attr->used + S_BLKSIZE - 1) / S_BLKSIZE;
-  buf->st_atim = nfs_attr->atime;
-  buf->st_mtim = nfs_attr->mtime;
-  buf->st_ctim = nfs_attr->ctime;
+  buf->st_atim.tv_sec = nfs_attr->atime.tv_sec;
+  buf->st_atim.tv_nsec = nfs_attr->atime.tv_nsec;
+  buf->st_mtim.tv_sec = nfs_attr->mtime.tv_sec;
+  buf->st_mtim.tv_nsec = nfs_attr->mtime.tv_nsec;
+  buf->st_ctim.tv_sec = nfs_attr->ctime.tv_sec;
+  buf->st_ctim.tv_nsec = nfs_attr->ctime.tv_nsec;
   return 0;
 }
 
 int __stdcall
-fhandler_base::fstat_by_handle (struct __stat64 *buf)
+fhandler_base::fstat_by_handle (struct stat *buf)
 {
   /* Don't use FileAllInformation info class.  It returns a pathname rather
      than a filename, so it needs a really big buffer for no good reason
@@ -380,7 +383,7 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf)
       status = file_get_fnoi (h, pc.fs_is_netapp (), pc.fnoi ());
       if (!NT_SUCCESS (status))
        {
-        debug_printf ("%p = NtQueryInformationFile(%S, "
+        debug_printf ("%y = NtQueryInformationFile(%S, "
                       "FileNetworkOpenInformation)",
                       status, pc.get_nt_native_path ());
         return -1;
@@ -394,7 +397,7 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf)
                                       FileStandardInformation);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("%p = NtQueryInformationFile(%S, "
+         debug_printf ("%y = NtQueryInformationFile(%S, "
                        "FileStandardInformation)",
                        status, pc.get_nt_native_path ());
          return -1;
@@ -405,7 +408,7 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf)
                                           FileInternalInformation);
          if (!NT_SUCCESS (status))
            {
-             debug_printf ("%p = NtQueryInformationFile(%S, "
+             debug_printf ("%y = NtQueryInformationFile(%S, "
                            "FileInternalInformation)",
                            status, pc.get_nt_native_path ());
              return -1;
@@ -418,7 +421,7 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf)
 }
 
 int __stdcall
-fhandler_base::fstat_by_name (struct __stat64 *buf)
+fhandler_base::fstat_by_name (struct stat *buf)
 {
   NTSTATUS status;
   OBJECT_ATTRIBUTES attr;
@@ -442,7 +445,7 @@ fhandler_base::fstat_by_name (struct __stat64 *buf)
                           | FILE_OPEN_FOR_BACKUP_INTENT
                           | FILE_DIRECTORY_FILE);
       if (!NT_SUCCESS (status))
-       debug_printf ("%p = NtOpenFile(%S)", status,
+       debug_printf ("%y = NtOpenFile(%S)", status,
                      pc.get_nt_native_path ());
       else
        {
@@ -452,7 +455,7 @@ fhandler_base::fstat_by_name (struct __stat64 *buf)
                                         TRUE, &basename, TRUE);
          NtClose (dir);
          if (!NT_SUCCESS (status))
-           debug_printf ("%p = NtQueryDirectoryFile(%S)", status,
+           debug_printf ("%y = NtQueryDirectoryFile(%S)", status,
                          pc.get_nt_native_path ());
          else
            ino = fdi_buf.fdi.FileId.QuadPart;
@@ -462,7 +465,7 @@ fhandler_base::fstat_by_name (struct __stat64 *buf)
 }
 
 int __stdcall
-fhandler_base::fstat_fs (struct __stat64 *buf)
+fhandler_base::fstat_fs (struct stat *buf)
 {
   int res = -1;
   int oret;
@@ -506,7 +509,7 @@ fhandler_base::fstat_fs (struct __stat64 *buf)
 }
 
 int __stdcall
-fhandler_base::fstat_helper (struct __stat64 *buf,
+fhandler_base::fstat_helper (struct stat *buf,
                             DWORD nNumberOfLinks)
 {
   IO_STATUS_BLOCK st;
@@ -531,7 +534,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
      0 in the first call and size > 0 in the second call.  This in turn can
      affect applications like newer tar.
      FIXME: Is the allocation size affected as well? */
-  buf->st_size = pc.isdir () ? 0 : (_off64_t) pfnoi->EndOfFile.QuadPart;
+  buf->st_size = pc.isdir () ? 0 : (off_t) pfnoi->EndOfFile.QuadPart;
   /* The number of links to a directory includes the number of subdirectories
      in the directory, since all those subdirectories point to it.  However,
      this is painfully slow, so we do without it. */
@@ -543,7 +546,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
 
   /* Enforce namehash as inode number on untrusted file systems. */
   if (ino && pc.isgood_inode (ino))
-    buf->st_ino = (__ino64_t) ino;
+    buf->st_ino = (ino_t) ino;
   else
     buf->st_ino = get_ino ();
 
@@ -651,7 +654,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
                                   FILE_OPEN_FOR_BACKUP_INTENT
                                   | FILE_SYNCHRONOUS_IO_NONALERT);
              if (!NT_SUCCESS (status))
-               debug_printf ("%p = NtOpenFile(%S)", status,
+               debug_printf ("%y = NtOpenFile(%S)", status,
                              pc.get_nt_native_path ());
              else
                {
@@ -661,7 +664,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
                  status = NtReadFile (h, NULL, NULL, NULL,
                                       &io, magic, 3, &off, NULL);
                  if (!NT_SUCCESS (status))
-                   debug_printf ("%p = NtReadFile(%S)", status,
+                   debug_printf ("%y = NtReadFile(%S)", status,
                                  pc.get_nt_native_path ());
                  else if (has_exec_chars (magic, io.Information))
                    {
@@ -687,9 +690,9 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
     }
 
  done:
-  syscall_printf ("0 = fstat (%S, %p) st_size=%D, st_mode=%p, st_ino=%D"
-                 "st_atim=%x.%x st_ctim=%x.%x "
-                 "st_mtim=%x.%x st_birthtim=%x.%x",
+  syscall_printf ("0 = fstat (%S, %p) st_size=%D, st_mode=%y, st_ino=%D"
+                 "st_atim=%lx.%lx st_ctim=%lx.%lx "
+                 "st_mtim=%lx.%lx st_birthtim=%lx.%lx",
                  pc.get_nt_native_path (), buf,
                  buf->st_size, buf->st_mode, buf->st_ino,
                  buf->st_atim.tv_sec, buf->st_atim.tv_nsec,
@@ -700,7 +703,7 @@ fhandler_base::fstat_helper (struct __stat64 *buf,
 }
 
 int __reg2
-fhandler_disk_file::fstat (struct __stat64 *buf)
+fhandler_disk_file::fstat (struct stat *buf)
 {
   return fstat_fs (buf);
 }
@@ -712,7 +715,6 @@ fhandler_disk_file::fstatvfs (struct statvfs *sfs)
   NTSTATUS status;
   IO_STATUS_BLOCK io;
   FILE_FS_FULL_SIZE_INFORMATION full_fsi;
-  FILE_FS_SIZE_INFORMATION fsi;
   /* We must not use the stat handle here, even if it exists.  The handle
      has been opened with FILE_OPEN_REPARSE_POINT, thus, in case of a volume
      mount point, it points to the FS of the mount point, rather than to the
@@ -746,18 +748,18 @@ fhandler_disk_file::fstatvfs (struct statvfs *sfs)
   sfs->f_fsid = pc.fs_serial_number ();
   sfs->f_flag = pc.fs_flags ();
   sfs->f_namemax = pc.fs_name_len ();
-  /* Get allocation related information.  Try to get "full" information
-     first, which is only available since W2K.  If that fails, try to
-     retrieve normal allocation information. */
+  /* Get allocation related information. */
   status = NtQueryVolumeInformationFile (fh, &io, &full_fsi, sizeof full_fsi,
                                         FileFsFullSizeInformation);
   if (NT_SUCCESS (status))
     {
       sfs->f_bsize = full_fsi.BytesPerSector * full_fsi.SectorsPerAllocationUnit;
       sfs->f_frsize = sfs->f_bsize;
-      sfs->f_blocks = full_fsi.TotalAllocationUnits.LowPart;
-      sfs->f_bfree = full_fsi.ActualAvailableAllocationUnits.LowPart;
-      sfs->f_bavail = full_fsi.CallerAvailableAllocationUnits.LowPart;
+      sfs->f_blocks = (fsblkcnt_t) full_fsi.TotalAllocationUnits.QuadPart;
+      sfs->f_bfree = (fsblkcnt_t)
+                    full_fsi.ActualAvailableAllocationUnits.QuadPart;
+      sfs->f_bavail = (fsblkcnt_t)
+                     full_fsi.CallerAvailableAllocationUnits.QuadPart;
       if (sfs->f_bfree > sfs->f_bavail)
        {
          /* Quotas active.  We can't trust TotalAllocationUnits. */
@@ -767,29 +769,13 @@ fhandler_disk_file::fstatvfs (struct statvfs *sfs)
                                    FSCTL_GET_NTFS_VOLUME_DATA,
                                    NULL, 0, &nvdb, sizeof nvdb);
          if (!NT_SUCCESS (status))
-           debug_printf ("%p = NtFsControlFile(%S, FSCTL_GET_NTFS_VOLUME_DATA)",
+           debug_printf ("%y = NtFsControlFile(%S, FSCTL_GET_NTFS_VOLUME_DATA)",
                          status, pc.get_nt_native_path ());
          else
-           sfs->f_blocks = nvdb.TotalClusters.QuadPart;
+           sfs->f_blocks = (fsblkcnt_t) nvdb.TotalClusters.QuadPart;
        }
       ret = 0;
     }
-  else
-    {
-      status = NtQueryVolumeInformationFile (fh, &io, &fsi, sizeof fsi,
-                                            FileFsSizeInformation);
-      if (!NT_SUCCESS (status))
-       {
-         __seterrno_from_nt_status (status);
-         goto out;
-       }
-      sfs->f_bsize = fsi.BytesPerSector * fsi.SectorsPerAllocationUnit;
-      sfs->f_frsize = sfs->f_bsize;
-      sfs->f_blocks = fsi.TotalAllocationUnits.LowPart;
-      sfs->f_bfree = fsi.AvailableAllocationUnits.LowPart;
-      sfs->f_bavail = sfs->f_bfree;
-      ret = 0;
-    }
 out:
   if (opened)
     NtClose (fh);
@@ -906,7 +892,7 @@ out:
 }
 
 int __stdcall
-fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
+fhandler_disk_file::fchown (uid_t uid, gid_t gid)
 {
   int oret = 0;
 
@@ -928,7 +914,7 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
   mode_t attrib = 0;
   if (pc.isdir ())
     attrib |= S_IFDIR;
-  __uid32_t old_uid;
+  uid_t old_uid;
   int res = get_file_attribute (get_handle (), pc, &attrib, &old_uid, NULL);
   if (!res)
     {
@@ -974,7 +960,7 @@ fhandler_disk_file::fchown (__uid32_t uid, __gid32_t gid)
 }
 
 int _stdcall
-fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp)
+fhandler_disk_file::facl (int cmd, int nentries, aclent_t *aclbufp)
 {
   int res = -1;
   int oret = 0;
@@ -999,7 +985,7 @@ cant_access_acl:
              set_errno (ENOSPC);
            else
              {
-               struct __stat64 st;
+               struct stat st;
                if (!fstat (&st))
                  {
                    aclbufp[0].a_type = USER_OBJ;
@@ -1113,7 +1099,7 @@ fhandler_disk_file::fsetxattr (const char *name, const void *value, size_t size,
 }
 
 int
-fhandler_disk_file::fadvise (_off64_t offset, _off64_t length, int advice)
+fhandler_disk_file::fadvise (off_t offset, off_t length, int advice)
 {
   if (advice < POSIX_FADV_NORMAL || advice > POSIX_FADV_NOREUSE)
     {
@@ -1156,7 +1142,7 @@ fhandler_disk_file::fadvise (_off64_t offset, _off64_t length, int advice)
 }
 
 int
-fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
+fhandler_disk_file::ftruncate (off_t length, bool allow_truncate)
 {
   int res = -1;
 
@@ -1197,8 +1183,8 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
                                    FSCTL_SET_SPARSE, NULL, 0, NULL, 0);
          if (NT_SUCCESS (status))
            pc.file_attributes (pc.file_attributes ()
-                               | FILE_ATTRIBUTE_SPARSE_FILE);
-         syscall_printf ("%p = NtFsControlFile(%S, FSCTL_SET_SPARSE)",
+                               | FILE_ATTRIBUTE_SPARSE_FILE);
+         syscall_printf ("%y = NtFsControlFile(%S, FSCTL_SET_SPARSE)",
                          status, pc.get_nt_native_path ());
        }
       status = NtSetInformationFile (get_handle (), &io,
@@ -1350,7 +1336,7 @@ fhandler_base::utimens_fs (const struct timespec *tvp)
       tmp[0] = (tvp[0].tv_nsec == UTIME_NOW) ? timeofday : tvp[0];
       tmp[1] = (tvp[1].tv_nsec == UTIME_NOW) ? timeofday : tvp[1];
     }
-  debug_printf ("incoming lastaccess %08x %08x", tmp[0].tv_sec, tmp[0].tv_nsec);
+  debug_printf ("incoming lastaccess %ly %ly", tmp[0].tv_sec, tmp[0].tv_nsec);
 
   IO_STATUS_BLOCK io;
   FILE_BASIC_INFORMATION fbi;
@@ -1477,7 +1463,7 @@ fhandler_base::open_fs (int flags, mode_t mode)
     NtAllocateLocallyUniqueId ((PLUID) &unique_id);
 
 out:
-  syscall_printf ("%d = fhandler_disk_file::open(%S, %p)", res,
+  syscall_printf ("%d = fhandler_disk_file::open(%S, %y)", res,
                  pc.get_nt_native_path (), flags);
   return res;
 }
@@ -1538,7 +1524,7 @@ fhandler_disk_file::prw_open (bool write)
       status = NtOpenFile (&prw_handle, access, &attr, &io,
                           FILE_SHARE_VALID_FLAGS, get_options ());
     }
-  debug_printf ("%x = NtOpenFile (%p, %x, %S, io, %x, %x)",
+  debug_printf ("%y = NtOpenFile (%p, %y, %S, io, %y, %y)",
                status, prw_handle, access, pc.get_nt_native_path (),
                FILE_SHARE_VALID_FLAGS, get_options ());
   if (!NT_SUCCESS (status))
@@ -1550,8 +1536,10 @@ fhandler_disk_file::prw_open (bool write)
 }
 
 ssize_t __stdcall
-fhandler_disk_file::pread (void *buf, size_t count, _off64_t offset)
+fhandler_disk_file::pread (void *buf, size_t count, off_t offset)
 {
+  ssize_t res;
+
   if ((get_flags () & O_ACCMODE) == O_WRONLY)
     {
       set_errno (EBADF);
@@ -1570,7 +1558,7 @@ fhandler_disk_file::pread (void *buf, size_t count, _off64_t offset)
        goto non_atomic;
       status = NtReadFile (prw_handle, NULL, NULL, NULL, &io, buf, count,
                           &off, NULL);
-      if (!NT_SUCCESS (status))
+      if (!NT_SUCCESS (status) && status != STATUS_END_OF_FILE)
        {
          if (pc.isdir ())
            {
@@ -1598,29 +1586,31 @@ fhandler_disk_file::pread (void *buf, size_t count, _off64_t offset)
          __seterrno_from_nt_status (status);
          return -1;
        }
+      res = io.Information;    /* Valid on EOF. */
     }
-
-non_atomic:
-  /* Text mode stays slow and non-atomic. */
-  ssize_t res;
-  _off64_t curpos = lseek (0, SEEK_CUR);
-  if (curpos < 0 || lseek (offset, SEEK_SET) < 0)
-    res = -1;
   else
     {
-      size_t tmp_count = count;
-      read (buf, tmp_count);
-      if (lseek (curpos, SEEK_SET) >= 0)
-       res = (ssize_t) tmp_count;
-      else
+non_atomic:
+      /* Text mode stays slow and non-atomic. */
+      off_t curpos = lseek (0, SEEK_CUR);
+      if (curpos < 0 || lseek (offset, SEEK_SET) < 0)
        res = -1;
+      else
+       {
+         size_t tmp_count = count;
+         read (buf, tmp_count);
+         if (lseek (curpos, SEEK_SET) >= 0)
+           res = (ssize_t) tmp_count;
+         else
+           res = -1;
+       }
     }
-  debug_printf ("%d = pread(%p, %d, %d)\n", res, buf, count, offset);
+  debug_printf ("%d = pread(%p, %ld, %D)\n", res, buf, count, offset);
   return res;
 }
 
 ssize_t __stdcall
-fhandler_disk_file::pwrite (void *buf, size_t count, _off64_t offset)
+fhandler_disk_file::pwrite (void *buf, size_t count, off_t offset)
 {
   if ((get_flags () & O_ACCMODE) == O_RDONLY)
     {
@@ -1650,7 +1640,7 @@ fhandler_disk_file::pwrite (void *buf, size_t count, _off64_t offset)
 non_atomic:
   /* Text mode stays slow and non-atomic. */
   int res;
-  _off64_t curpos = lseek (0, SEEK_CUR);
+  off_t curpos = lseek (0, SEEK_CUR);
   if (curpos < 0 || lseek (offset, SEEK_SET) < 0)
     res = curpos;
   else
@@ -1659,7 +1649,7 @@ non_atomic:
       if (lseek (curpos, SEEK_SET) < 0)
        res = -1;
     }
-  debug_printf ("%d = pwrite(%p, %d, %d)\n", res, buf, count, offset);
+  debug_printf ("%d = pwrite(%p, %ld, %D)\n", res, buf, count, offset);
   return res;
 }
 
@@ -1784,7 +1774,7 @@ fhandler_disk_file::rmdir ()
 
 struct __DIR_cache
 {
-  char  __cache[DIR_BUF_SIZE]; /* W2K needs this buffer 8 byte aligned. */
+  char  __cache[DIR_BUF_SIZE];
   ULONG __pos;
 };
 
@@ -1827,7 +1817,7 @@ fhandler_disk_file::opendir (int fd)
       dir->__d_position = 0;
       dir->__flags = (get_name ()[0] == '/' && get_name ()[1] == '\0')
                     ? dirent_isroot : 0;
-      dir->__d_internal = (unsigned) new __DIR_mounts (get_name ());
+      dir->__d_internal = (uintptr_t) new __DIR_mounts (get_name ());
       d_cachepos (dir) = 0;
 
       if (!pc.iscygdrive ())
@@ -1880,10 +1870,9 @@ fhandler_disk_file::opendir (int fd)
             XP when accessing directories on UDF.  When trying to use it
             so, NtQueryDirectoryFile returns with STATUS_ACCESS_VIOLATION.
             It's not clear if the call isn't also unsupported on other
-            OS/FS combinations (say, Win2K/CDFS or so).  Instead of
-            testing in readdir for yet another error code, let's use
-            FileIdBothDirectoryInformation only on filesystems supporting
-            persistent ACLs, FileBothDirectoryInformation otherwise.
+            OS/FS combinations.  Instead of testing for yet another error
+            code, let's use FileIdBothDirectoryInformation only on FSes
+            supporting persistent ACLs, FileBothDirectoryInformation otherwise.
 
             NFS clients hide dangling symlinks from directory queries,
             unless you use the FileNamesInformation info class.
@@ -1935,15 +1924,15 @@ free_dir:
   return res;
 }
 
-__ino64_t __stdcall
+ino_t __stdcall
 readdir_get_ino (const char *path, bool dot_dot)
 {
   char *fname;
-  struct __stat64 st;
+  struct stat st;
   HANDLE hdl;
   OBJECT_ATTRIBUTES attr;
   IO_STATUS_BLOCK io;
-  __ino64_t ino = 0;
+  ino_t ino = 0;
 
   if (dot_dot)
     {
@@ -2118,11 +2107,10 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
                                         FileIdBothDirectoryInformation,
                                         FALSE, NULL, dir->__d_position == 0);
          /* FileIdBothDirectoryInformation isn't supported for remote drives
-            on NT4 and 2K systems, and it's also not supported on 2K at all,
-            when accessing network drives on any remote OS.  There are also
-            hacked versions of Samba 3.0.x out there (Debian-based it seems),
-            which return STATUS_NOT_SUPPORTED rather than handling this info
-            class.  We just fall back to using a standard directory query in
+            on NT4 and 2K systems.  There are also hacked versions of
+            Samba 3.0.x out there (Debian-based it seems), which return
+            STATUS_NOT_SUPPORTED rather than handling this info class.
+            We just fall back to using a standard directory query in
             this case and note this case using the dirent_get_d_ino flag. */
          if (!NT_SUCCESS (status) && status != STATUS_NO_MORE_FILES
              && (status == STATUS_INVALID_LEVEL
@@ -2193,7 +2181,7 @@ go_ahead:
   if (status == STATUS_NO_MORE_FILES)
     /*nothing*/;
   else if (!NT_SUCCESS (status))
-    debug_printf ("NtQueryDirectoryFile failed, status %p, win32 error %lu",
+    debug_printf ("NtQueryDirectoryFile failed, status %y, win32 error %u",
                  status, RtlNtStatusToDosError (status));
   else
     {
@@ -2217,11 +2205,11 @@ go_ahead:
        }
       else
        {
-         FileName = ((PFILE_BOTH_DIRECTORY_INFORMATION) buf)->FileName;
+         FileName = ((PFILE_BOTH_DIR_INFORMATION) buf)->FileName;
          FileNameLength =
-               ((PFILE_BOTH_DIRECTORY_INFORMATION) buf)->FileNameLength;
+               ((PFILE_BOTH_DIR_INFORMATION) buf)->FileNameLength;
          FileAttributes =
-               ((PFILE_BOTH_DIRECTORY_INFORMATION) buf)->FileAttributes;
+               ((PFILE_BOTH_DIR_INFORMATION) buf)->FileAttributes;
        }
       RtlInitCountedUnicodeString (&fname, FileName, FileNameLength);
       de->d_ino = d_mounts (dir)->check_mount (&fname, de->d_ino);
@@ -2319,7 +2307,7 @@ go_ahead:
       res = 0;
     }
 
-  syscall_printf ("%d = readdir(%p, %p) (L\"%lS\" > \"%ls\") (attr %p > type %d)",
+  syscall_printf ("%d = readdir(%p, %p) (L\"%lS\" > \"%ls\") (attr %y > type %d)",
                  res, dir, &de, res ? NULL : &fname, res ? "***" : de->d_name,
                  FileAttributes, de->d_type);
   return res;
@@ -2344,32 +2332,6 @@ void
 fhandler_disk_file::rewinddir (DIR *dir)
 {
   d_cachepos (dir) = 0;
-  if (wincap.has_buggy_restart_scan () && isremote ())
-    {
-      /* This works around a W2K bug.  The RestartScan parameter in calls
-        to NtQueryDirectoryFile on remote shares is ignored, thus
-        resulting in not being able to rewind on remote shares.  By
-        reopening the directory, we get a fresh new directory pointer. */
-      OBJECT_ATTRIBUTES attr;
-      NTSTATUS status;
-      IO_STATUS_BLOCK io;
-      HANDLE new_dir;
-
-      pc.init_reopen_attr (&attr, get_handle ());
-      status = NtOpenFile (&new_dir, SYNCHRONIZE | FILE_LIST_DIRECTORY,
-                          &attr, &io, FILE_SHARE_VALID_FLAGS,
-                          FILE_SYNCHRONOUS_IO_NONALERT
-                          | FILE_OPEN_FOR_BACKUP_INTENT
-                          | FILE_DIRECTORY_FILE);
-      if (!NT_SUCCESS (status))
-       debug_printf ("Unable to reopen dir %s, NT error: %p",
-                     get_name (), status);
-      else
-       {
-         NtClose (get_handle ());
-         set_io_handle (new_dir);
-       }
-    }
   dir->__d_position = 0;
   d_mounts (dir)->rewind ();
 }
@@ -2422,7 +2384,7 @@ fhandler_cygdrive::set_drives ()
 }
 
 int
-fhandler_cygdrive::fstat (struct __stat64 *buf)
+fhandler_cygdrive::fstat (struct stat *buf)
 {
   fhandler_base::fstat (buf);
   buf->st_ino = 2;
index b16606615d007a186bdd10a55ac781edf6d1a9b3..c807058368dd7b8474cbb906bd400298a0bd86a9 100644 (file)
@@ -102,8 +102,9 @@ class fhandler_dev_dsp::Audio::queue
   WAVEHDR **storage_;
 };
 
-static void CALLBACK waveOut_callback (HWAVEOUT hWave, UINT msg, DWORD instance,
-                                      DWORD param1, DWORD param2);
+static void CALLBACK waveOut_callback (HWAVEOUT hWave, UINT msg,
+                                      DWORD_PTR instance, DWORD_PTR param1,
+                                      DWORD_PTR param2);
 
 class fhandler_dev_dsp::Audio_out: public Audio
 {
@@ -135,8 +136,9 @@ class fhandler_dev_dsp::Audio_out: public Audio
   int channels_;
 };
 
-static void CALLBACK waveIn_callback (HWAVEIN hWave, UINT msg, DWORD instance,
-                                     DWORD param1, DWORD param2);
+static void CALLBACK waveIn_callback (HWAVEIN hWave, UINT msg,
+                                     DWORD_PTR instance, DWORD_PTR param1,
+                                     DWORD_PTR param2);
 
 class fhandler_dev_dsp::Audio_in: public Audio
 {
@@ -365,7 +367,7 @@ fhandler_dev_dsp::Audio_out::fork_fixup (HANDLE parent)
   /* Null dev_.
      It will be necessary to reset the queue, open the device
      and create a lock when writing */
-  debug_printf ("parent=0x%08x", parent);
+  debug_printf ("parent=%p", parent);
   dev_ = NULL;
 }
 
@@ -378,7 +380,7 @@ fhandler_dev_dsp::Audio_out::query (int rate, int bits, int channels)
 
   fillFormat (&format, rate, bits, channels);
   rc = waveOutOpen (NULL, WAVE_MAPPER, &format, 0L, 0L, WAVE_FORMAT_QUERY);
-  debug_printf ("%d = waveOutOpen(freq=%d bits=%d channels=%d)", rc, rate, bits, channels);
+  debug_printf ("%u = waveOutOpen(freq=%d bits=%d channels=%d)", rc, rate, bits, channels);
   return (rc == MMSYSERR_NOERROR);
 }
 
@@ -400,12 +402,12 @@ fhandler_dev_dsp::Audio_out::start ()
     return false;
 
   fillFormat (&format, freq_, bits_, channels_);
-  rc = waveOutOpen (&dev_, WAVE_MAPPER, &format, (DWORD) waveOut_callback,
-                    (DWORD) this, CALLBACK_FUNCTION);
+  rc = waveOutOpen (&dev_, WAVE_MAPPER, &format, (DWORD_PTR) waveOut_callback,
+                    (DWORD_PTR) this, CALLBACK_FUNCTION);
   if (rc == MMSYSERR_NOERROR)
     init (bSize);
 
-  debug_printf ("%d = waveOutOpen(freq=%d bits=%d channels=%d)", rc, freq_, bits_, channels_);
+  debug_printf ("%u = waveOutOpen(freq=%d bits=%d channels=%d)", rc, freq_, bits_, channels_);
 
   return (rc == MMSYSERR_NOERROR);
 }
@@ -416,7 +418,7 @@ fhandler_dev_dsp::Audio_out::stop (bool immediately)
   MMRESULT rc;
   WAVEHDR *pHdr;
 
-  debug_printf ("dev_=%08x", (int)dev_);
+  debug_printf ("dev_=%p", dev_);
   if (dev_)
     {
       if (!immediately)
@@ -426,15 +428,15 @@ fhandler_dev_dsp::Audio_out::stop (bool immediately)
        }
 
       rc = waveOutReset (dev_);
-      debug_printf ("%d = waveOutReset()", rc);
+      debug_printf ("%u = waveOutReset()", rc);
       while (Qisr2app_->recv (&pHdr))
        {
          rc = waveOutUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR));
-         debug_printf ("%d = waveOutUnprepareHeader(0x%08x)", rc, pHdr);
+         debug_printf ("%u = waveOutUnprepareHeader(%p)", rc, pHdr);
        }
 
       rc = waveOutClose (dev_);
-      debug_printf ("%d = waveOutClose()", rc);
+      debug_printf ("%u = waveOutClose()", rc);
 
       Qisr2app_->dellock ();
     }
@@ -564,7 +566,7 @@ fhandler_dev_dsp::Audio_out::waitforspace ()
       /* Errors are ignored here. They will probbaly cause a failure
         in the subsequent PrepareHeader */
       rc = waveOutUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR));
-      debug_printf ("%d = waveOutUnprepareHeader(0x%08x)", rc, pHdr);
+      debug_printf ("%u = waveOutUnprepareHeader(%p)", rc, pHdr);
     }
   pHdr_ = pHdr;
   bufferIndex_ = 0;
@@ -587,7 +589,7 @@ fhandler_dev_dsp::Audio_out::sendcurrent ()
 {
   WAVEHDR *pHdr = pHdr_;
   MMRESULT rc;
-  debug_printf ("pHdr=0x%08x bytes=%d", pHdr, bufferIndex_);
+  debug_printf ("pHdr=%p bytes=%d", pHdr, bufferIndex_);
 
   if (pHdr_ == NULL)
     return false;
@@ -599,11 +601,11 @@ fhandler_dev_dsp::Audio_out::sendcurrent ()
   // Send internal buffer out to the soundcard
   pHdr->dwBufferLength = bufferIndex_;
   rc = waveOutPrepareHeader (dev_, pHdr, sizeof (WAVEHDR));
-  debug_printf ("%d = waveOutPrepareHeader(0x%08x)", rc, pHdr);
+  debug_printf ("%u = waveOutPrepareHeader(%p)", rc, pHdr);
   if (rc == MMSYSERR_NOERROR)
     {
       rc = waveOutWrite (dev_, pHdr, sizeof (WAVEHDR));
-      debug_printf ("%d = waveOutWrite(0x%08x)", rc, pHdr);
+      debug_printf ("%u = waveOutWrite(%p)", rc, pHdr);
     }
   if (rc == MMSYSERR_NOERROR)
     return true;
@@ -617,8 +619,8 @@ fhandler_dev_dsp::Audio_out::sendcurrent ()
 //------------------------------------------------------------------------
 // Call back routine
 static void CALLBACK
-waveOut_callback (HWAVEOUT hWave, UINT msg, DWORD instance, DWORD param1,
-                 DWORD param2)
+waveOut_callback (HWAVEOUT hWave, UINT msg, DWORD_PTR instance,
+                 DWORD_PTR param1, DWORD_PTR param2)
 {
   if (msg == WOM_DONE)
     {
@@ -663,7 +665,7 @@ fhandler_dev_dsp::Audio_out::parsewav (const char * &pData, int &nBytes,
   setconvert (bits_ == 8 ? AFMT_U8 : AFMT_S16_LE);
 
   // Check alignment first: A lot of the code below depends on it
-  if (((int)pData & 0x3) != 0)
+  if (((uintptr_t)pData & 0x3) != 0)
     return false;
   if (!(pData[0] == 'R' && pData[1] == 'I'
        && pData[2] == 'F' && pData[3] == 'F'))
@@ -740,7 +742,7 @@ fhandler_dev_dsp::Audio_in::fork_fixup (HANDLE parent)
   /* Null dev_.
      It will be necessary to reset the queue, open the device
      and create a lock when reading */
-  debug_printf ("parent=0x%08x", parent);
+  debug_printf ("parent=%p", parent);
   dev_ = NULL;
 }
 
@@ -752,7 +754,7 @@ fhandler_dev_dsp::Audio_in::query (int rate, int bits, int channels)
 
   fillFormat (&format, rate, bits, channels);
   rc = waveInOpen (NULL, WAVE_MAPPER, &format, 0L, 0L, WAVE_FORMAT_QUERY);
-  debug_printf ("%d = waveInOpen(freq=%d bits=%d channels=%d)", rc, rate, bits, channels);
+  debug_printf ("%u = waveInOpen(freq=%d bits=%d channels=%d)", rc, rate, bits, channels);
   return (rc == MMSYSERR_NOERROR);
 }
 
@@ -774,9 +776,9 @@ fhandler_dev_dsp::Audio_in::start (int rate, int bits, int channels)
     return false;
 
   fillFormat (&format, rate, bits, channels);
-  rc = waveInOpen (&dev_, WAVE_MAPPER, &format, (DWORD) waveIn_callback,
-                  (DWORD) this, CALLBACK_FUNCTION);
-  debug_printf ("%d = waveInOpen(rate=%d bits=%d channels=%d)", rc, rate, bits, channels);
+  rc = waveInOpen (&dev_, WAVE_MAPPER, &format, (DWORD_PTR) waveIn_callback,
+                  (DWORD_PTR) this, CALLBACK_FUNCTION);
+  debug_printf ("%u = waveInOpen(rate=%d bits=%d channels=%d)", rc, rate, bits, channels);
 
   if (rc == MMSYSERR_NOERROR)
     {
@@ -792,7 +794,7 @@ fhandler_dev_dsp::Audio_in::stop ()
   MMRESULT rc;
   WAVEHDR *pHdr;
 
-  debug_printf ("dev_=%08x", (int)dev_);
+  debug_printf ("dev_=%p", dev_);
   if (dev_)
     {
       /* Note that waveInReset calls our callback for all incomplete buffers.
@@ -800,16 +802,16 @@ fhandler_dev_dsp::Audio_in::stop ()
         we must not call into the wave API from the callback.
         Otherwise we end up in a deadlock. */
       rc = waveInReset (dev_);
-      debug_printf ("%d = waveInReset()", rc);
+      debug_printf ("%u = waveInReset()", rc);
 
       while (Qisr2app_->recv (&pHdr))
        {
          rc = waveInUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR));
-         debug_printf ("%d = waveInUnprepareHeader(0x%08x)", rc, pHdr);
+         debug_printf ("%u = waveInUnprepareHeader(%p)", rc, pHdr);
        }
 
       rc = waveInClose (dev_);
-      debug_printf ("%d = waveInClose()", rc);
+      debug_printf ("%u = waveInClose()", rc);
 
       Qisr2app_->dellock ();
     }
@@ -820,11 +822,11 @@ fhandler_dev_dsp::Audio_in::queueblock (WAVEHDR *pHdr)
 {
   MMRESULT rc;
   rc = waveInPrepareHeader (dev_, pHdr, sizeof (WAVEHDR));
-  debug_printf ("%d = waveInPrepareHeader(0x%08x)", rc, pHdr);
+  debug_printf ("%u = waveInPrepareHeader(%p)", rc, pHdr);
   if (rc == MMSYSERR_NOERROR)
     {
       rc = waveInAddBuffer (dev_, pHdr, sizeof (WAVEHDR));
-      debug_printf ("%d = waveInAddBuffer(0x%08x)", rc, pHdr);
+      debug_printf ("%u = waveInAddBuffer(%p)", rc, pHdr);
     }
   if (rc == MMSYSERR_NOERROR)
     return true;
@@ -854,7 +856,7 @@ fhandler_dev_dsp::Audio_in::init (unsigned blockSize)
     }
   pHdr_ = NULL;
   rc = waveInStart (dev_);
-  debug_printf ("%d = waveInStart(), queued=%d", rc, i);
+  debug_printf ("%u = waveInStart(), queued=%d", rc, i);
   return (rc == MMSYSERR_NOERROR);
 }
 
@@ -863,7 +865,7 @@ fhandler_dev_dsp::Audio_in::read (char *pSampleData, int &nBytes)
 {
   int bytes_to_read = nBytes;
   nBytes = 0;
-  debug_printf ("pSampleData=%08x nBytes=%d", pSampleData, bytes_to_read);
+  debug_printf ("pSampleData=%p nBytes=%d", pSampleData, bytes_to_read);
   while (bytes_to_read != 0)
     { // Block till next sound has been read
       if (!waitfordata ())
@@ -942,7 +944,7 @@ fhandler_dev_dsp::Audio_in::waitfordata ()
       /* Errors are ignored here. They will probbaly cause a failure
         in the subsequent PrepareHeader */
       rc = waveInUnprepareHeader (dev_, pHdr, sizeof (WAVEHDR));
-      debug_printf ("%d = waveInUnprepareHeader(0x%08x)", rc, pHdr);
+      debug_printf ("%u = waveInUnprepareHeader(%p)", rc, pHdr);
     }
   pHdr_ = pHdr;
   bufferIndex_ = 0;
@@ -978,8 +980,8 @@ fhandler_dev_dsp::Audio_in::callback_blockfull (WAVEHDR *pHdr)
 }
 
 static void CALLBACK
-waveIn_callback (HWAVEIN hWave, UINT msg, DWORD instance, DWORD param1,
-                DWORD param2)
+waveIn_callback (HWAVEIN hWave, UINT msg, DWORD_PTR instance, DWORD_PTR param1,
+                DWORD_PTR param2)
 {
   if (msg == WIM_DATA)
     {
@@ -1039,7 +1041,7 @@ fhandler_dev_dsp::open (int flags, mode_t mode)
   else
     set_errno (err);
 
-  debug_printf ("ACCMODE=0x%08x audio_in=%d audio_out=%d, err=%d",
+  debug_printf ("ACCMODE=%y audio_in=%d audio_out=%d, err=%d",
                flags & O_ACCMODE, num_in, num_out, err);
   return !err;
 }
@@ -1050,7 +1052,7 @@ fhandler_dev_dsp::open (int flags, mode_t mode)
 ssize_t __stdcall
 fhandler_dev_dsp::write (const void *ptr, size_t len)
 {
-  debug_printf ("ptr=%08x len=%d", ptr, len);
+  debug_printf ("ptr=%p len=%ld", ptr, len);
   int len_s = len;
   const char *ptr_s = static_cast <const char *> (ptr);
 
@@ -1066,7 +1068,7 @@ fhandler_dev_dsp::write (const void *ptr, size_t len)
 
       if (audio_out_->parsewav (ptr_s, len_s,
                                audiofreq_, audiobits_, audiochannels_))
-       debug_printf ("=> ptr_s=%08x len_s=%d", ptr_s, len_s);
+       debug_printf ("=> ptr_s=%p len_s=%d", ptr_s, len_s);
     }
   else
     {
@@ -1096,7 +1098,7 @@ fhandler_dev_dsp::write (const void *ptr, size_t len)
 void __stdcall
 fhandler_dev_dsp::read (void *ptr, size_t& len)
 {
-  debug_printf ("ptr=%08x len=%d", ptr, len);
+  debug_printf ("ptr=%p len=%ld", ptr, len);
 
   if (audio_in_)
     /* nothing to do */;
@@ -1129,8 +1131,8 @@ fhandler_dev_dsp::read (void *ptr, size_t& len)
   audio_in_->read ((char *)ptr, (int&)len);
 }
 
-_off64_t
-fhandler_dev_dsp::lseek (_off64_t offset, int whence)
+off_t
+fhandler_dev_dsp::lseek (off_t offset, int whence)
 {
   return 0;
 }
@@ -1160,8 +1162,7 @@ fhandler_dev_dsp::close_audio_out (bool immediately)
 int
 fhandler_dev_dsp::close ()
 {
-  debug_printf ("audio_in=%08x audio_out=%08x",
-               (int)audio_in_, (int)audio_out_);
+  debug_printf ("audio_in=%p audio_out=%p", audio_in_, audio_out_);
   close_audio_in ();
   close_audio_out (exit_state != ES_NOT_EXITING);
   return 0;
@@ -1170,8 +1171,7 @@ fhandler_dev_dsp::close ()
 int
 fhandler_dev_dsp::ioctl (unsigned int cmd, void *buf)
 {
-  debug_printf ("audio_in=%08x audio_out=%08x",
-               (int)audio_in_, (int)audio_out_);
+  debug_printf ("audio_in=%p audio_out=%p", audio_in_, audio_out_);
   int *intbuf = (int *) buf;
   switch (cmd)
     {
@@ -1374,8 +1374,8 @@ fhandler_dev_dsp::ioctl (unsigned int cmd, void *buf)
 void
 fhandler_dev_dsp::fixup_after_fork (HANDLE parent)
 { // called from new child process
-  debug_printf ("audio_in=%08x audio_out=%08x",
-               (int)audio_in_, (int)audio_out_);
+  debug_printf ("audio_in=%p audio_out=%p",
+               audio_in_, audio_out_);
 
   if (audio_in_)
     audio_in_->fork_fixup (parent);
@@ -1386,8 +1386,8 @@ fhandler_dev_dsp::fixup_after_fork (HANDLE parent)
 void
 fhandler_dev_dsp::fixup_after_exec ()
 {
-  debug_printf ("audio_in=%08x audio_out=%08x, close_on_exec %d",
-               (int) audio_in_, (int) audio_out_, close_on_exec ());
+  debug_printf ("audio_in=%p audio_out=%p, close_on_exec %d",
+               audio_in_, audio_out_, close_on_exec ());
   if (!close_on_exec ())
     {
       audio_in_ = NULL;
index 310cf828fd19b3ad385b8dc2ec5f5bf55e50406a..6b288e5f0f5708d7171e2023182a14c708c87953 100644 (file)
@@ -290,7 +290,7 @@ fhandler_fifo::raw_read (void *in_ptr, size_t& len)
         could hang indefinitely.  Maybe implement a timeout?  */
       if (!DisconnectNamedPipe (get_io_handle ()))
        {
-         debug_printf ("DisconnecttNamedPipe failed, %E");
+         debug_printf ("DisconnectNamedPipe failed, %E");
          goto errno_out;
        }
       else if (!ConnectNamedPipe (get_io_handle (), get_overlapped ())
index bbbaf9ca527244b0922d2cefa9a0963238452264..de4c13ee8d2626e2d664da5f6a4084aae011ea65 100644 (file)
@@ -53,7 +53,7 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
   /* Always try using the new EX ioctls first (>= XP).  If not available,
      fall back to trying the old non-EX ioctls.
      Unfortunately the EX ioctls are not implemented in the floppy driver. */
-  if (wincap.has_disk_ex_ioctls () && get_major () != DEV_FLOPPY_MAJOR)
+  if (get_major () != DEV_FLOPPY_MAJOR)
     {
       if (!DeviceIoControl (get_handle (),
                            IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, NULL, 0,
@@ -76,95 +76,49 @@ fhandler_dev_floppy::get_drive_info (struct hd_geometry *geo)
       if (!DeviceIoControl (get_handle (),
                            IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0,
                            dbuf, 256, &bytes_read, NULL))
-       __seterrno ();
-      else
        {
-         di = (DISK_GEOMETRY *) dbuf;
-         if (!DeviceIoControl (get_handle (),
-                               IOCTL_DISK_GET_PARTITION_INFO, NULL, 0,
-                               pbuf, 256, &bytes_read, NULL))
-           __seterrno ();
-         else
-           pi = (PARTITION_INFORMATION *) pbuf;
+         __seterrno ();
+         return -1;
        }
+      di = (DISK_GEOMETRY *) dbuf;
+      if (!DeviceIoControl (get_handle (),
+                           IOCTL_DISK_GET_PARTITION_INFO, NULL, 0,
+                           pbuf, 256, &bytes_read, NULL))
+       __seterrno ();
+      else
+       pi = (PARTITION_INFORMATION *) pbuf;
     }
-  if (!di)
+  debug_printf ("disk geometry: (%D cyl)*(%u trk)*(%u sec)*(%u bps)",
+                di->Cylinders.QuadPart,
+                di->TracksPerCylinder,
+                di->SectorsPerTrack,
+                di->BytesPerSector);
+  bytes_per_sector = di->BytesPerSector;
+  if (pix)
     {
-      /* Up to Win2K, even IOCTL_DISK_GET_DRIVE_GEOMETRY fails when trying
-        it on CD or DVD drives.  In that case fall back to requesting
-        simple file system information. */
-      NTSTATUS status;
-      IO_STATUS_BLOCK io;
-      FILE_FS_SIZE_INFORMATION ffsi;
-
-      status = NtQueryVolumeInformationFile (get_handle (), &io, &ffsi,
-                                            sizeof ffsi,
-                                            FileFsSizeInformation);
-      if (!NT_SUCCESS (status))
-       {
-         __seterrno_from_nt_status (status);
-         return -1;
-       }
-      debug_printf ("fsys geometry: (%D units)*(%u sec)*(%u bps)",
-                   ffsi.TotalAllocationUnits.QuadPart,
-                   ffsi.SectorsPerAllocationUnit,
-                   ffsi.BytesPerSector);
-      bytes_per_sector = ffsi.BytesPerSector;
-      drive_size = ffsi.TotalAllocationUnits.QuadPart
-                  * ffsi.SectorsPerAllocationUnit
-                  * ffsi.BytesPerSector;
-      if (geo)
-       {
-         geo->heads = 1;
-         geo->sectors = ffsi.SectorsPerAllocationUnit;
-         geo->cylinders = ffsi.TotalAllocationUnits.LowPart;
-         geo->start = 0;
-       }
+      debug_printf ("partition info: offset %D  length %D",
+                   pix->StartingOffset.QuadPart,
+                   pix->PartitionLength.QuadPart);
+      drive_size = pix->PartitionLength.QuadPart;
     }
   else
     {
-      debug_printf ("disk geometry: (%D cyl)*(%u trk)*(%u sec)*(%u bps)",
-                    di->Cylinders.QuadPart,
-                    di->TracksPerCylinder,
-                    di->SectorsPerTrack,
-                    di->BytesPerSector);
-      bytes_per_sector = di->BytesPerSector;
+      debug_printf ("partition info: offset %D  length %D",
+                   pi->StartingOffset.QuadPart,
+                   pi->PartitionLength.QuadPart);
+      drive_size = pi->PartitionLength.QuadPart;
+    }
+  if (geo)
+    {
+      geo->heads = di->TracksPerCylinder;
+      geo->sectors = di->SectorsPerTrack;
+      geo->cylinders = di->Cylinders.LowPart;
       if (pix)
-       {
-         debug_printf ("partition info: offset %D  length %D",
-                       pix->StartingOffset.QuadPart,
-                       pix->PartitionLength.QuadPart);
-         drive_size = pix->PartitionLength.QuadPart;
-       }
+       geo->start = pix->StartingOffset.QuadPart >> 9ULL;
       else if (pi)
-       {
-         debug_printf ("partition info: offset %D  length %D",
-                       pi->StartingOffset.QuadPart,
-                       pi->PartitionLength.QuadPart);
-         drive_size = pi->PartitionLength.QuadPart;
-       }
+       geo->start = pi->StartingOffset.QuadPart >> 9ULL;
       else
-       {
-         /* Getting the partition size by using the drive geometry information
-            looks wrong, but this is a historical necessity.  NT4 didn't
-            maintain partition information for the whole drive (aka
-            "partition 0"), but returned ERROR_INVALID_HANDLE instead.  That
-            got fixed in W2K. */
-         drive_size = di->Cylinders.QuadPart * di->TracksPerCylinder
-                      * di->SectorsPerTrack * di->BytesPerSector;
-       }
-      if (geo)
-       {
-         geo->heads = di->TracksPerCylinder;
-         geo->sectors = di->SectorsPerTrack;
-         geo->cylinders = di->Cylinders.LowPart;
-         if (pix)
-           geo->start = pix->StartingOffset.QuadPart >> 9ULL;
-         else if (pi)
-           geo->start = pi->StartingOffset.QuadPart >> 9ULL;
-         else
-           geo->start = 0;
-       }
+       geo->start = 0;
     }
   debug_printf ("drive size: %D", drive_size);
 
@@ -180,7 +134,7 @@ fhandler_dev_floppy::read_file (void *buf, DWORD to_read, DWORD *read, int *err)
   *err = 0;
   if (!(ret = ReadFile (get_handle (), buf, to_read, read, 0)))
     *err = GetLastError ();
-  syscall_printf ("%d (err %d) = ReadFile (%d, %d, to_read %d, read %d, 0)",
+  syscall_printf ("%d (err %d) = ReadFile (%p, %p, to_read %u, read %u, 0)",
                  ret, *err, get_handle (), buf, to_read, *read);
   return ret;
 }
@@ -234,7 +188,7 @@ fhandler_dev_floppy::lock_partition (DWORD to_write)
                                   FilePositionInformation);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtQueryInformationFile(FilePositionInformation): %p",
+      debug_printf ("NtQueryInformationFile(FilePositionInformation): %y",
                    status);
       return FALSE;
     }
@@ -268,7 +222,7 @@ fhandler_dev_floppy::lock_partition (DWORD to_write)
          if (part_no >= MAX_PARTITIONS)
            return FALSE;
          found = TRUE;
-         debug_printf ("%d %D->%D : %D->%D", part_no,
+         debug_printf ("%u %D->%D : %D->%D", part_no,
                        ppie->StartingOffset.QuadPart,
                        ppie->StartingOffset.QuadPart
                        + ppie->PartitionLength.QuadPart,
@@ -305,7 +259,7 @@ fhandler_dev_floppy::lock_partition (DWORD to_write)
                               &io, FILE_SHARE_READ | FILE_SHARE_WRITE, 0);
          if (!NT_SUCCESS (status))
            {
-             debug_printf ("NtCreateFile(%W): %p", part, status);
+             debug_printf ("NtCreateFile(%W): %y", part, status);
              return FALSE;
            }
          if (!DeviceIoControl (partitions->hdl[part_no - 1], FSCTL_LOCK_VOLUME,
@@ -349,7 +303,7 @@ fhandler_dev_floppy::write_file (const void *buf, DWORD to_write,
       if (!(ret = WriteFile (get_handle (), buf, to_write, written, 0)))
        *err = GetLastError ();
     }
-  syscall_printf ("%d (err %d) = WriteFile (%d, %d, write %d, written %d, 0)",
+  syscall_printf ("%d (err %d) = WriteFile (%p, %p, write %u, written %u, 0)",
                  ret, *err, get_handle (), buf, to_write, *written);
   return ret;
 }
@@ -377,7 +331,8 @@ fhandler_dev_floppy::open (int flags, mode_t)
             Whoever uses O_DIRECT has my condolences. */
          devbufsiz = MAX (16 * bytes_per_sector, 65536);
          devbufalloc = new char [devbufsiz + devbufalign];
-         devbuf = (char *) roundup2 ((uintptr_t) devbufalloc, devbufalign);
+         devbuf = (char *) roundup2 ((uintptr_t) devbufalloc,
+                                     (uintptr_t) devbufalign);
        }
 
       /* If we're not trying to access a floppy disk, make sure we're actually
@@ -418,7 +373,7 @@ fhandler_dev_floppy::dup (fhandler_base *child, int flags)
   return ret;
 }
 
-inline _off64_t
+inline off_t
 fhandler_dev_floppy::get_current_position ()
 {
   LARGE_INTEGER off = { QuadPart: 0LL };
@@ -451,7 +406,7 @@ fhandler_dev_floppy::raw_read (void *ptr, size_t& ulen)
          if (devbufstart < devbufend)
            {
              bytes_to_read = MIN (len, devbufend - devbufstart);
-             debug_printf ("read %d bytes from buffer (rest %d)",
+             debug_printf ("read %u bytes from buffer (rest %u)",
                            bytes_to_read,
                            devbufend - devbufstart - bytes_to_read);
              memcpy (p, devbuf + devbufstart, bytes_to_read);
@@ -478,13 +433,13 @@ fhandler_dev_floppy::raw_read (void *ptr, size_t& ulen)
                  tgt = devbuf;
                  bytes_to_read = devbufsiz;
                }
-             _off64_t current_position = get_current_position ();
+             off_t current_position = get_current_position ();
              if (current_position + bytes_to_read >= drive_size)
                bytes_to_read = drive_size - current_position;
              if (!bytes_to_read)
                break;
 
-             debug_printf ("read %d bytes from pos %U %s", bytes_to_read,
+             debug_printf ("read %u bytes from pos %U %s", bytes_to_read,
                            current_position,
                            len < devbufsiz ? "into buffer" : "directly");
              if (!read_file (tgt, bytes_to_read, &read2, &ret))
@@ -527,11 +482,11 @@ fhandler_dev_floppy::raw_read (void *ptr, size_t& ulen)
     }
   else
     {
-      _off64_t current_position = get_current_position ();
+      off_t current_position = get_current_position ();
       bytes_to_read = len;
       if (current_position + bytes_to_read >= drive_size)
        bytes_to_read = drive_size - current_position;
-      debug_printf ("read %d bytes from pos %U directly", bytes_to_read,
+      debug_printf ("read %u bytes from pos %U directly", bytes_to_read,
                    current_position);
       if (bytes_to_read && !read_file (p, bytes_to_read, &bytes_read, &ret))
        {
@@ -558,7 +513,7 @@ err:
   ulen = (size_t) -1;
 }
 
-int __stdcall
+ssize_t __stdcall
 fhandler_dev_floppy::raw_write (const void *ptr, size_t len)
 {
   DWORD bytes_written = 0;
@@ -585,7 +540,7 @@ fhandler_dev_floppy::raw_write (const void *ptr, size_t len)
         buffer in case we seek to an address which is not sector aligned. */
       if (devbufend && devbufstart < devbufend)
        {
-         _off64_t current_pos = get_current_position ();
+         off_t current_pos = get_current_position ();
          cplen = MIN (len, devbufend - devbufstart);
          memcpy (devbuf + devbufstart, p, cplen);
          LARGE_INTEGER off = { QuadPart:current_pos - devbufend };
@@ -647,7 +602,7 @@ fhandler_dev_floppy::raw_write (const void *ptr, size_t len)
        }
       return bytes_written;
     }
-
+  
   /* In O_DIRECT case, just write. */
   if (write_file (p, len, &bytes_written, &ret))
     return bytes_written;
@@ -664,11 +619,11 @@ err:
   return bytes_written ?: -1;
 }
 
-_off64_t
-fhandler_dev_floppy::lseek (_off64_t offset, int whence)
+off_t
+fhandler_dev_floppy::lseek (off_t offset, int whence)
 {
   char buf[bytes_per_sector];
-  _off64_t current_pos = (_off64_t) -1;
+  off_t current_pos = (off_t) -1;
   LARGE_INTEGER sector_aligned_offset;
   size_t bytes_left;
 
@@ -680,7 +635,7 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence)
   else if (whence == SEEK_CUR)
     {
       current_pos = get_current_position ();
-      _off64_t exact_pos = current_pos - (devbufend - devbufstart);
+      off_t exact_pos = current_pos - (devbufend - devbufstart);
       /* Shortcut when used to get current position. */
       if (offset == 0)
        return exact_pos;
@@ -697,7 +652,7 @@ fhandler_dev_floppy::lseek (_off64_t offset, int whence)
   /* If new position is in buffered range, adjust buffer and return */
   if (devbufstart < devbufend)
     {
-      if (current_pos == (_off64_t) -1)
+      if (current_pos == (off_t) -1)
        current_pos = get_current_position ();
       if (current_pos - devbufend <= offset && offset <= current_pos)
        {
@@ -749,7 +704,7 @@ fhandler_dev_floppy::ioctl (unsigned int cmd, void *buf)
       if (cmd == BLKGETSIZE)
        *(long *)buf = drive_size >> 9UL;
       else
-       *(_off64_t *)buf = drive_size;
+       *(off_t *)buf = drive_size;
       break;
     case BLKRRPART:
       debug_printf ("BLKRRPART");
@@ -764,19 +719,19 @@ fhandler_dev_floppy::ioctl (unsigned int cmd, void *buf)
       break;
     case BLKSSZGET:
       debug_printf ("BLKSSZGET");
-      *(int *)buf = bytes_per_sector;
+      *(int *)buf = (int) bytes_per_sector;
       break;
     case BLKIOMIN:
       debug_printf ("BLKIOMIN");
-      *(int *)buf = bytes_per_sector;
+      *(int *)buf = (int) bytes_per_sector;
       break;
     case BLKIOOPT:
       debug_printf ("BLKIOOPT");
-      *(int *)buf = bytes_per_sector;
+      *(int *)buf = (int) bytes_per_sector;
       break;
     case BLKPBSZGET:
       debug_printf ("BLKPBSZGET");
-      *(int *)buf = bytes_per_sector;
+      *(int *)buf = (int) bytes_per_sector;
       break;
     case BLKALIGNOFF:
       debug_printf ("BLKALIGNOFF");
index a6cec5fd2b3251300506867106a2442bc4b9867e..37c41a2dd5583e9d9f03889fdd9ac9fb149975da 100644 (file)
@@ -29,7 +29,7 @@ fhandler_mailslot::fhandler_mailslot ()
 }
 
 int __reg2
-fhandler_mailslot::fstat (struct __stat64 *buf)
+fhandler_mailslot::fstat (struct stat *buf)
 {
   debug_printf ("here");
 
@@ -177,7 +177,7 @@ fhandler_mailslot::ioctl (unsigned int cmd, void *buf)
                                       FileMailslotSetInformation);
        if (!NT_SUCCESS (status))
          {
-           debug_printf ("NtSetInformationFile (%X): %08x",
+           debug_printf ("NtSetInformationFile (%X): %p",
                          fmsi.ReadTimeout.QuadPart, status);
            __seterrno_from_nt_status (status);
            break;
index e7e0d41b82911e5303901089a8f6ba8cc08f6386..89c43e143f561bd42699c82df579faf00edb0dfd 100644 (file)
@@ -37,7 +37,7 @@ fhandler_dev_mem::open (int flags, mode_t)
   if (!wincap.has_physical_mem_access ())
     {
       set_errno (EACCES);
-      debug_printf ("%s is accessible under NT4/W2K/XP only", dev ().name);
+      debug_printf ("%s is accessible under XP only", dev ().name);
       return 0;
     }
 
@@ -49,17 +49,18 @@ fhandler_dev_mem::open (int flags, mode_t)
       if (NT_SUCCESS (status))
        {
          __seterrno_from_nt_status (status);
-         debug_printf("NtQuerySystemInformation: status %p, %E", status);
+         debug_printf("NtQuerySystemInformation: status %p", status);
          mem_size = 0;
        }
       else
-       mem_size = sbi.PhysicalPageSize * sbi.NumberOfPhysicalPages;
-      debug_printf ("MemSize: %d MB", mem_size >> 20);
+       mem_size = (SIZE_T) sbi.PhysicalPageSize
+                  * (SIZE_T) sbi.NumberOfPhysicalPages;
+      debug_printf ("MemSize: %ld MB", mem_size >> 20);
     }
   else if (dev () == FH_KMEM) /* /dev/kmem - Not yet supported */
     {
       mem_size = 0;
-      debug_printf ("KMemSize: %d MB", mem_size >> 20);
+      debug_printf ("KMemSize: %ld MB", mem_size >> 20);
     }
   else if (dev () == FH_PORT) /* /dev/port == First 64K of /dev/mem */
     {
@@ -119,7 +120,7 @@ fhandler_dev_mem::open (int flags, mode_t)
 ssize_t __stdcall
 fhandler_dev_mem::write (const void *ptr, size_t ulen)
 {
-  if (!ulen || pos >= mem_size)
+  if (!ulen || pos >= (off_t) mem_size)
     return 0;
 
   if (!(get_access () & GENERIC_WRITE))
@@ -129,12 +130,12 @@ fhandler_dev_mem::write (const void *ptr, size_t ulen)
     }
 
   if (pos + ulen > mem_size)
-    ulen = mem_size - pos;
+    ulen = (off_t) mem_size - pos;
 
   PHYSICAL_ADDRESS phys;
   NTSTATUS status;
   void *viewmem = NULL;
-  DWORD len = ulen + wincap.page_size () - 1;
+  SIZE_T len = ulen + wincap.page_size () - 1;
 
   phys.QuadPart = (ULONGLONG) pos;
   status = NtMapViewOfSection (get_handle (), INVALID_HANDLE_VALUE, &viewmem,
@@ -162,7 +163,7 @@ fhandler_dev_mem::write (const void *ptr, size_t ulen)
 void __stdcall
 fhandler_dev_mem::read (void *ptr, size_t& ulen)
 {
-  if (!ulen || pos >= mem_size)
+  if (!ulen || pos >= (off_t) mem_size)
     {
       ulen = 0;
       return;
@@ -176,12 +177,12 @@ fhandler_dev_mem::read (void *ptr, size_t& ulen)
     }
 
   if (pos + ulen > mem_size)
-    ulen = mem_size - pos;
+    ulen = (off_t) mem_size - pos;
 
   PHYSICAL_ADDRESS phys;
   NTSTATUS status;
   void *viewmem = NULL;
-  DWORD len = ulen + wincap.page_size () - 1;
+  SIZE_T len = ulen + wincap.page_size () - 1;
 
   phys.QuadPart = (ULONGLONG) pos;
   status = NtMapViewOfSection (get_handle (), INVALID_HANDLE_VALUE, &viewmem,
@@ -207,8 +208,8 @@ fhandler_dev_mem::read (void *ptr, size_t& ulen)
   pos += ulen;
 }
 
-_off64_t
-fhandler_dev_mem::lseek (_off64_t offset, int whence)
+off_t
+fhandler_dev_mem::lseek (off_t offset, int whence)
 {
   switch (whence)
     {
@@ -221,7 +222,7 @@ fhandler_dev_mem::lseek (_off64_t offset, int whence)
       break;
 
     case SEEK_END:
-      pos = mem_size;
+      pos = (off_t) mem_size;
       pos += offset;
       break;
 
@@ -230,7 +231,7 @@ fhandler_dev_mem::lseek (_off64_t offset, int whence)
       return ILLEGAL_SEEK;
     }
 
-  if (pos > mem_size)
+  if (pos > (off_t) mem_size)
     {
       set_errno (EINVAL);
       return ILLEGAL_SEEK;
@@ -240,7 +241,7 @@ fhandler_dev_mem::lseek (_off64_t offset, int whence)
 }
 
 int __reg2
-fhandler_dev_mem::fstat (struct __stat64 *buf)
+fhandler_dev_mem::fstat (struct stat *buf)
 {
   fhandler_base::fstat (buf);
   buf->st_blksize = wincap.page_size ();
index 84e840cff3ba3fc745cc0ef333f8b90ee184da30..af9abcadafe81cbd51e1b003ae0ce0a39da7d003 100644 (file)
@@ -1,6 +1,6 @@
 /* fhandler_netdrive.cc: fhandler for // and //MACHINE handling
 
-   Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Red Hat, Inc.
+   Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -175,7 +175,7 @@ fhandler_netdrive::fhandler_netdrive ():
 }
 
 int __reg2
-fhandler_netdrive::fstat (struct __stat64 *buf)
+fhandler_netdrive::fstat (struct stat *buf)
 {
   const char *path = get_name ();
   debug_printf ("fstat (%s)", path);
@@ -246,7 +246,7 @@ fhandler_netdrive::readdir (DIR *dir, dirent *de)
          de->d_ino = readdir_get_ino (nro->lpRemoteName, false);
          /* We can't trust remote inode numbers of only 32 bit.  That means,
             remote NT4 NTFS, as well as shares of Samba version < 3.0. */
-         if (de->d_ino <= UINT_MAX)
+         if (de->d_ino <= UINT32_MAX)
            de->d_ino = hash_path_name (0, nro->lpRemoteName);
        }
       de->d_type = DT_DIR;
@@ -318,7 +318,7 @@ fhandler_netdrive::open (int flags, mode_t mode)
   set_flags ((flags & ~O_TEXT) | O_BINARY | O_DIROPEN);
   set_open_status ();
 out:
-  syscall_printf ("%d = fhandler_netdrive::open(%p, %d)", res, flags, mode);
+  syscall_printf ("%d = fhandler_netdrive::open(%y, 0%o)", res, flags, mode);
   return res;
 }
 
index 57a1532a2f0215e1de7e98fe4c7ca1be3ce28169..58e628aa9f0ca1f276150952f751b253fbb4684a 100644 (file)
@@ -1,7 +1,7 @@
 /* fhandler_proc.cc: fhandler for /proc virtual filesystem
 
-   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013
-   Red Hat, Inc.
+   Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
+   2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -36,19 +36,19 @@ details. */
 #define _COMPILING_NEWLIB
 #include <dirent.h>
 
-static _off64_t format_proc_loadavg (void *, char *&);
-static _off64_t format_proc_meminfo (void *, char *&);
-static _off64_t format_proc_stat (void *, char *&);
-static _off64_t format_proc_version (void *, char *&);
-static _off64_t format_proc_uptime (void *, char *&);
-static _off64_t format_proc_cpuinfo (void *, char *&);
-static _off64_t format_proc_partitions (void *, char *&);
-static _off64_t format_proc_self (void *, char *&);
-static _off64_t format_proc_mounts (void *, char *&);
-static _off64_t format_proc_filesystems (void *, char *&);
-static _off64_t format_proc_swaps (void *, char *&);
-static _off64_t format_proc_devices (void *, char *&);
-static _off64_t format_proc_misc (void *, char *&);
+static off_t format_proc_loadavg (void *, char *&);
+static off_t format_proc_meminfo (void *, char *&);
+static off_t format_proc_stat (void *, char *&);
+static off_t format_proc_version (void *, char *&);
+static off_t format_proc_uptime (void *, char *&);
+static off_t format_proc_cpuinfo (void *, char *&);
+static off_t format_proc_partitions (void *, char *&);
+static off_t format_proc_self (void *, char *&);
+static off_t format_proc_mounts (void *, char *&);
+static off_t format_proc_filesystems (void *, char *&);
+static off_t format_proc_swaps (void *, char *&);
+static off_t format_proc_devices (void *, char *&);
+static off_t format_proc_misc (void *, char *&);
 
 /* names of objects in /proc */
 static const virt_tab_t proc_tab[] = {
@@ -185,7 +185,7 @@ fhandler_proc::fhandler_proc ():
 }
 
 int __reg2
-fhandler_proc::fstat (struct __stat64 *buf)
+fhandler_proc::fstat (struct stat *buf)
 {
   const char *path = get_name ();
   debug_printf ("fstat (%s)", path);
@@ -377,7 +377,7 @@ success:
   set_flags ((flags & ~O_TEXT) | O_BINARY);
   set_open_status ();
 out:
-  syscall_printf ("%d = fhandler_proc::open(%p, %d)", res, flags, mode);
+  syscall_printf ("%d = fhandler_proc::open(%y, 0%o)", res, flags, mode);
   return res;
 }
 
@@ -393,7 +393,7 @@ fhandler_proc::fill_filebuf ()
   return false;
 }
 
-static _off64_t
+static off_t
 format_proc_version (void *, char *&destbuf)
 {
   tmp_pathbuf tp;
@@ -411,7 +411,7 @@ format_proc_version (void *, char *&destbuf)
   return bufptr - buf;
 }
 
-static _off64_t
+static off_t
 format_proc_loadavg (void *, char *&destbuf)
 {
   extern int get_process_state (DWORD dwProcessId);
@@ -431,7 +431,7 @@ format_proc_loadavg (void *, char *&destbuf)
                                    0, 0, 0, 0, 0, 0, running, pids.npids);
 }
 
-static _off64_t
+static off_t
 format_proc_meminfo (void *, char *&destbuf)
 {
   unsigned long long mem_total, mem_free, swap_total, swap_free;
@@ -457,12 +457,12 @@ format_proc_meminfo (void *, char *&destbuf)
                           swap_total >> 10, swap_free >> 10);
 }
 
-static _off64_t
+static off_t
 format_proc_uptime (void *, char *&destbuf)
 {
   unsigned long long uptime = 0ULL, idle_time = 0ULL;
   NTSTATUS status;
-  SYSTEM_TIME_OF_DAY_INFORMATION stodi;
+  SYSTEM_TIMEOFDAY_INFORMATION stodi;
   /* Sizeof SYSTEM_PERFORMANCE_INFORMATION on 64 bit systems.  It
      appears to contain some trailing additional information from
      what I can tell after examining the content.
@@ -477,7 +477,7 @@ format_proc_uptime (void *, char *&destbuf)
     uptime = (stodi.CurrentTime.QuadPart - stodi.BootTime.QuadPart) / 100000ULL;
   else
     debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), "
-                 "status %p", status);
+                 "status %y", status);
 
   if (NT_SUCCESS (NtQuerySystemInformation (SystemPerformanceInformation,
                                                 spi, sizeof_spi, NULL)))
@@ -490,7 +490,7 @@ format_proc_uptime (void *, char *&destbuf)
                          idle_time / 100, long (idle_time % 100));
 }
 
-static _off64_t
+static off_t
 format_proc_stat (void *, char *&destbuf)
 {
   unsigned long pages_in = 0UL, pages_out = 0UL, interrupt_count = 0UL,
@@ -504,18 +504,19 @@ format_proc_stat (void *, char *&destbuf)
   const size_t sizeof_spi = sizeof (SYSTEM_PERFORMANCE_INFORMATION) + 16;
   PSYSTEM_PERFORMANCE_INFORMATION spi = (PSYSTEM_PERFORMANCE_INFORMATION)
                                        alloca (sizeof_spi);
-  SYSTEM_TIME_OF_DAY_INFORMATION stodi;
+  SYSTEM_TIMEOFDAY_INFORMATION stodi;
   tmp_pathbuf tp;
 
   char *buf = tp.c_get ();
   char *eobuf = buf;
 
-  SYSTEM_PROCESSOR_TIMES spt[wincap.cpu_count ()];
-  status = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) spt,
+  SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION spt[wincap.cpu_count ()];
+  status = NtQuerySystemInformation (SystemProcessorPerformanceInformation,
+                                    (PVOID) spt,
                                     sizeof spt[0] * wincap.cpu_count (), NULL);
   if (!NT_SUCCESS (status))
-    debug_printf ("NtQuerySystemInformation(SystemProcessorTimes), "
-                 "status %p", status);
+    debug_printf ("NtQuerySystemInformation(SystemProcessorPerformanceInformation), "
+                 "status %y", status);
   else
     {
       unsigned long long user_time = 0ULL, kernel_time = 0ULL, idle_time = 0ULL;
@@ -545,14 +546,14 @@ format_proc_stat (void *, char *&destbuf)
       if (!NT_SUCCESS (status))
        {
          debug_printf ("NtQuerySystemInformation(SystemPerformanceInformation)"
-                       ", status %p", status);
+                       ", status %y", status);
          memset (spi, 0, sizeof_spi);
        }
       status = NtQuerySystemInformation (SystemTimeOfDayInformation,
                                         (PVOID) &stodi, sizeof stodi, NULL);
       if (!NT_SUCCESS (status))
        debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), "
-                     "status %p", status);
+                     "status %y", status);
     }
   if (!NT_SUCCESS (status))
     {
@@ -588,7 +589,7 @@ format_proc_stat (void *, char *&destbuf)
 
 #define print(x) { bufptr = stpcpy (bufptr, (x)); }
 
-static _off64_t
+static off_t
 format_proc_cpuinfo (void *, char *&destbuf)
 {
   DWORD orig_affinity_mask;
@@ -1078,7 +1079,7 @@ format_proc_cpuinfo (void *, char *&destbuf)
   return bufptr - buf;
 }
 
-static _off64_t
+static off_t
 format_proc_partitions (void *, char *&destbuf)
 {
   OBJECT_ATTRIBUTES attr;
@@ -1098,7 +1099,7 @@ format_proc_partitions (void *, char *&destbuf)
   status = NtOpenDirectoryObject (&dirhdl, DIRECTORY_QUERY, &attr);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtOpenDirectoryObject, status %p", status);
+      debug_printf ("NtOpenDirectoryObject, status %y", status);
       __seterrno_from_nt_status (status);
       return 0;
     }
@@ -1138,14 +1139,11 @@ format_proc_partitions (void *, char *&destbuf)
       upath.MaximumLength = upath.Length + sizeof (WCHAR);
       InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE,
                                  dirhdl, NULL);
-      /* Up to W2K the handle needs read access to fetch the partition info. */
-      status = NtOpenFile (&devhdl, wincap.has_disk_ex_ioctls ()
-                                   ? READ_CONTROL
-                                   : READ_CONTROL | FILE_READ_DATA,
-                          &attr, &io, FILE_SHARE_VALID_FLAGS, 0);
+      status = NtOpenFile (&devhdl, READ_CONTROL, &attr, &io,
+                          FILE_SHARE_VALID_FLAGS, 0);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("NtOpenFile(%S), status %p", &upath, status);
+         debug_printf ("NtOpenFile(%S), status %y", &upath, status);
          __seterrno_from_nt_status (status);
          continue;
        }
@@ -1155,9 +1153,8 @@ format_proc_partitions (void *, char *&destbuf)
          got_one = true;
        }
       /* Fetch partition info for the entire disk to get its size. */
-      if (wincap.has_disk_ex_ioctls ()
-         && DeviceIoControl (devhdl, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0,
-                             ioctl_buf, NT_MAX_PATH, &bytes_read, NULL))
+      if (DeviceIoControl (devhdl, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0,
+                          ioctl_buf, NT_MAX_PATH, &bytes_read, NULL))
        {
          pix = (PARTITION_INFORMATION_EX *) ioctl_buf;
          size = pix->PartitionLength.QuadPart;
@@ -1179,9 +1176,8 @@ format_proc_partitions (void *, char *&destbuf)
                                 dev.get_major (), dev.get_minor (),
                                 size >> 10, dev.name + 5);
       /* Fetch drive layout info to get size of all partitions on the disk. */
-      if (wincap.has_disk_ex_ioctls ()
-         && DeviceIoControl (devhdl, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
-                             NULL, 0, ioctl_buf, NT_MAX_PATH, &bytes_read, NULL))
+      if (DeviceIoControl (devhdl, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
+                          NULL, 0, ioctl_buf, NT_MAX_PATH, &bytes_read, NULL))
        {
          PDRIVE_LAYOUT_INFORMATION_EX pdlix = (PDRIVE_LAYOUT_INFORMATION_EX)
                                               ioctl_buf;
@@ -1213,13 +1209,7 @@ format_proc_partitions (void *, char *&destbuf)
            else
              {
                size = pi->PartitionLength.QuadPart;
-               /* Pre-W2K you can't rely on the partition number info for
-                  unused partitions. */
-               if (pi->PartitionType == PARTITION_ENTRY_UNUSED
-                   || pi->PartitionType == PARTITION_EXTENDED)
-                 part_num = 0;
-               else
-                 part_num = pi->PartitionNumber;
+               part_num = pi->PartitionNumber;
                ++pi;
              }
            /* A partition number of 0 denotes an extended partition or a
@@ -1244,21 +1234,21 @@ format_proc_partitions (void *, char *&destbuf)
   return bufptr - buf;
 }
 
-static _off64_t
+static off_t
 format_proc_self (void *, char *&destbuf)
 {
   destbuf = (char *) crealloc_abort (destbuf, 16);
   return __small_sprintf (destbuf, "%d", getpid ());
 }
 
-static _off64_t
+static off_t
 format_proc_mounts (void *, char *&destbuf)
 {
   destbuf = (char *) crealloc_abort (destbuf, sizeof ("self/mounts"));
   return __small_sprintf (destbuf, "self/mounts");
 }
 
-static _off64_t
+static off_t
 format_proc_filesystems (void *, char *&destbuf)
 {
   tmp_pathbuf tp;
@@ -1276,7 +1266,7 @@ format_proc_filesystems (void *, char *&destbuf)
   return bufptr - buf;
 }
 
-static _off64_t
+static off_t
 format_proc_swaps (void *, char *&destbuf)
 {
   unsigned long long total = 0ULL, used = 0ULL;
@@ -1338,7 +1328,7 @@ format_proc_swaps (void *, char *&destbuf)
   return bufptr - buf;
 }
 
-static _off64_t
+static off_t
 format_proc_devices (void *, char *&destbuf)
 {
   tmp_pathbuf tp;
@@ -1382,7 +1372,7 @@ format_proc_devices (void *, char *&destbuf)
   return bufptr - buf;
 }
 
-static _off64_t
+static off_t
 format_proc_misc (void *, char *&destbuf)
 {
   tmp_pathbuf tp;
index 9faeb7d98aee63686a3c29b382c24c5f4acbbc9e..044757d743debdc0b6a6682f755a12c16ff76aab 100644 (file)
@@ -34,25 +34,25 @@ details. */
 #define _COMPILING_NEWLIB
 #include <dirent.h>
 
-static _off64_t format_process_maps (void *, char *&);
-static _off64_t format_process_stat (void *, char *&);
-static _off64_t format_process_status (void *, char *&);
-static _off64_t format_process_statm (void *, char *&);
-static _off64_t format_process_winexename (void *, char *&);
-static _off64_t format_process_winpid (void *, char *&);
-static _off64_t format_process_exename (void *, char *&);
-static _off64_t format_process_root (void *, char *&);
-static _off64_t format_process_cwd (void *, char *&);
-static _off64_t format_process_cmdline (void *, char *&);
-static _off64_t format_process_ppid (void *, char *&);
-static _off64_t format_process_uid (void *, char *&);
-static _off64_t format_process_pgid (void *, char *&);
-static _off64_t format_process_sid (void *, char *&);
-static _off64_t format_process_gid (void *, char *&);
-static _off64_t format_process_ctty (void *, char *&);
-static _off64_t format_process_fd (void *, char *&);
-static _off64_t format_process_mounts (void *, char *&);
-static _off64_t format_process_mountinfo (void *, char *&);
+static off_t format_process_maps (void *, char *&);
+static off_t format_process_stat (void *, char *&);
+static off_t format_process_status (void *, char *&);
+static off_t format_process_statm (void *, char *&);
+static off_t format_process_winexename (void *, char *&);
+static off_t format_process_winpid (void *, char *&);
+static off_t format_process_exename (void *, char *&);
+static off_t format_process_root (void *, char *&);
+static off_t format_process_cwd (void *, char *&);
+static off_t format_process_cmdline (void *, char *&);
+static off_t format_process_ppid (void *, char *&);
+static off_t format_process_uid (void *, char *&);
+static off_t format_process_pgid (void *, char *&);
+static off_t format_process_sid (void *, char *&);
+static off_t format_process_gid (void *, char *&);
+static off_t format_process_ctty (void *, char *&);
+static off_t format_process_fd (void *, char *&);
+static off_t format_process_mounts (void *, char *&);
+static off_t format_process_mountinfo (void *, char *&);
 
 static const virt_tab_t process_tab[] =
 {
@@ -137,7 +137,7 @@ fhandler_process::fhandler_process ():
 }
 
 int __reg2
-fhandler_process::fstat (struct __stat64 *buf)
+fhandler_process::fstat (struct stat *buf)
 {
   const char *path = get_name ();
   int file_type = exists ();
@@ -222,7 +222,7 @@ fhandler_process::readdir (DIR *dir, dirent *de)
   int res = ENMFILE;
   if (process_tab[fileid].fhandler == FH_PROCESSFD)
     {
-      if (dir->__d_position >= 2 + filesize / sizeof (int))
+      if ((size_t) dir->__d_position >= 2 + filesize / sizeof (int))
        goto out;
     }
   else if (dir->__d_position >= PROCESS_LINK_COUNT)
@@ -314,7 +314,7 @@ success:
   set_flags ((flags & ~O_TEXT) | O_BINARY);
   set_open_status ();
 out:
-  syscall_printf ("%d = fhandler_proc::open(%p, %d)", res, flags, mode);
+  syscall_printf ("%d = fhandler_proc::open(%y, 0%o)", res, flags, mode);
   return res;
 }
 
@@ -356,7 +356,7 @@ fhandler_process::fill_filebuf ()
   return false;
 }
 
-static _off64_t
+static off_t
 format_process_fd (void *data, char *&destbuf)
 {
   _pinfo *p = ((process_fd_t *) data)->p;
@@ -390,7 +390,7 @@ format_process_fd (void *data, char *&destbuf)
   return fs;
 }
 
-static _off64_t
+static off_t
 format_process_ppid (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -398,7 +398,7 @@ format_process_ppid (void *data, char *&destbuf)
   return __small_sprintf (destbuf, "%d\n", p->ppid);
 }
 
-static _off64_t
+static off_t
 format_process_uid (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -406,7 +406,7 @@ format_process_uid (void *data, char *&destbuf)
   return __small_sprintf (destbuf, "%d\n", p->uid);
 }
 
-static _off64_t
+static off_t
 format_process_pgid (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -414,7 +414,7 @@ format_process_pgid (void *data, char *&destbuf)
   return __small_sprintf (destbuf, "%d\n", p->pgid);
 }
 
-static _off64_t
+static off_t
 format_process_sid (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -422,7 +422,7 @@ format_process_sid (void *data, char *&destbuf)
   return __small_sprintf (destbuf, "%d\n", p->sid);
 }
 
-static _off64_t
+static off_t
 format_process_gid (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -430,7 +430,7 @@ format_process_gid (void *data, char *&destbuf)
   return __small_sprintf (destbuf, "%d\n", p->gid);
 }
 
-static _off64_t
+static off_t
 format_process_ctty (void *data, char *&destbuf)
 {
   device d;
@@ -440,7 +440,7 @@ format_process_ctty (void *data, char *&destbuf)
   return __small_sprintf (destbuf, "%s\n", d.name);
 }
 
-static _off64_t
+static off_t
 format_process_root (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -460,7 +460,7 @@ format_process_root (void *data, char *&destbuf)
   return fs;
 }
 
-static _off64_t
+static off_t
 format_process_cwd (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -480,7 +480,7 @@ format_process_cwd (void *data, char *&destbuf)
   return fs;
 }
 
-static _off64_t
+static off_t
 format_process_cmdline (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -500,7 +500,7 @@ format_process_cmdline (void *data, char *&destbuf)
   return fs;
 }
 
-static _off64_t
+static off_t
 format_process_exename (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -526,7 +526,7 @@ format_process_exename (void *data, char *&destbuf)
   return len;
 }
 
-static _off64_t
+static off_t
 format_process_winpid (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -534,7 +534,7 @@ format_process_winpid (void *data, char *&destbuf)
   return __small_sprintf (destbuf, "%d\n", p->dwProcessId);
 }
 
-static _off64_t
+static off_t
 format_process_winexename (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -647,15 +647,15 @@ struct thread_info
   {
     NTSTATUS status;
     PVOID buf = NULL;
-    size_t size = 50 * (sizeof (SYSTEM_PROCESSES)
-                       + 16 * sizeof (SYSTEM_THREADS));
-    PSYSTEM_PROCESSES proc;
+    ULONG size = 50 * (sizeof (SYSTEM_PROCESS_INFORMATION)
+                      + 16 * sizeof (SYSTEM_THREADS));
+    PSYSTEM_PROCESS_INFORMATION proc;
     PSYSTEM_THREADS thread;
 
     do
       {
        buf = realloc (buf, size);
-       status = NtQuerySystemInformation (SystemProcessesAndThreadsInformation,
+       status = NtQuerySystemInformation (SystemProcessInformation,
                                           buf, size, NULL);
        size <<= 1;
       }
@@ -664,30 +664,30 @@ struct thread_info
       {
        if (buf)
          free (buf);
-       debug_printf ("NtQuerySystemInformation, %p", status);
+       debug_printf ("NtQuerySystemInformation, %y", status);
        return;
       }
-    proc = (PSYSTEM_PROCESSES) buf;
+    proc = (PSYSTEM_PROCESS_INFORMATION) buf;
     while (true)
       {
-       if (proc->ProcessId == pid)
+       if ((DWORD) (uintptr_t) proc->UniqueProcessId == pid)
          break;
-       if (!proc->NextEntryDelta)
+       if (!proc->NextEntryOffset)
          {
            free (buf);
            return;
          }
-       proc = (PSYSTEM_PROCESSES) ((PBYTE) proc + proc->NextEntryDelta);
+       proc = (PSYSTEM_PROCESS_INFORMATION) ((PBYTE) proc + proc->NextEntryOffset);
       }
     thread = proc->Threads;
-    for (ULONG i = 0; i < proc->ThreadCount; ++i)
+    for (ULONG i = 0; i < proc->NumberOfThreads; ++i)
       {
        THREAD_BASIC_INFORMATION tbi;
        TEB teb;
        HANDLE thread_h;
 
        if (!(thread_h = OpenThread (THREAD_QUERY_INFORMATION, FALSE,
-                                    (ULONG) thread[i].ClientId.UniqueThread)))
+                                    (ULONG) (ULONG_PTR) thread[i].ClientId.UniqueThread)))
          continue;
        status = NtQueryInformationThread (thread_h, ThreadBasicInformation,
                                           &tbi, sizeof tbi, NULL);
@@ -697,7 +697,7 @@ struct thread_info
        region *r = (region *) malloc (sizeof (region));
        if (r)
          {
-           *r = (region) { regions, (ULONG) thread[i].ClientId.UniqueThread,
+           *r = (region) { regions, (ULONG) (ULONG_PTR) thread[i].ClientId.UniqueThread,
                            (char *) tbi.TebBaseAddress,
                            (char *) tbi.TebBaseAddress + wincap.page_size (),
                            true };
@@ -709,7 +709,7 @@ struct thread_info
        r = (region *) malloc (sizeof (region));
        if (r)
          {
-           *r = (region) { regions, (ULONG) thread[i].ClientId.UniqueThread,
+           *r = (region) { regions, (ULONG) (ULONG_PTR) thread[i].ClientId.UniqueThread,
                            (char *) (teb.DeallocationStack
                                      ?: teb.Tib.StackLimit),
                            (char *) teb.Tib.StackBase,
@@ -751,7 +751,7 @@ struct thread_info
   }
 };
 
-static _off64_t
+static off_t
 format_process_maps (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -780,12 +780,12 @@ format_process_maps (void *data, char *&destbuf)
   ReadProcessMemory (proc, &cygheap->user_heap, &user_heap,
                     sizeof user_heap, NULL);
 
-  _off64_t len = 0;
+  off_t len = 0;
 
   union access
   {
     char flags[8];
-    _off64_t word;
+    off_t word;
   } a;
 
   struct region {
@@ -799,7 +799,7 @@ format_process_maps (void *data, char *&destbuf)
   dos_drive_mappings drive_maps;
   heap_info heaps (p->dwProcessId);
   thread_info threads (p->dwProcessId, proc);
-  struct __stat64 st;
+  struct stat st;
   long last_pass = 0;
 
   tmp_pathbuf tp;
@@ -815,7 +815,12 @@ format_process_maps (void *data, char *&destbuf)
 
   /* Iterate over each VM region in the address space, coalescing
      memory regions with the same permissions. Once we run out, do one
-     last_pass to trigger output of the last accumulated region. */
+     last_pass to trigger output of the last accumulated region.
+     
+     FIXME:  32 bit processes can't get address information beyond the
+            32 bit address space from 64 bit processes.  We have to run
+            this functionality in the target process, if the target
+            process is 64 bit and our own process is 32 bit. */
   for (char *i = 0;
        VirtualQueryEx (proc, i, &mb, sizeof(mb)) || (1 == ++last_pass);
        i = cur.rend)
@@ -867,9 +872,9 @@ format_process_maps (void *data, char *&destbuf)
            {
              size_t newlen = strlen (posix_modname) + 62;
              if (len + newlen >= maxsize)
-               destbuf = (char *) crealloc_abort (destbuf,
-                                                  maxsize += roundup2 (newlen,
-                                                                       2048));
+               destbuf = (char *)
+                 crealloc_abort (destbuf,
+                                 maxsize += roundup2 (newlen, 2048UL));
              int written = __small_sprintf (destbuf + len,
                                             "%08lx-%08lx %s %08lx %04x:%04x %U   ",
                                             cur.rbase, cur.rend, cur.a.flags,
@@ -889,7 +894,7 @@ format_process_maps (void *data, char *&destbuf)
            {
              /* If the return length pointer is missing, NtQueryVirtualMemory
                 returns with STATUS_ACCESS_VIOLATION on Windows 2000. */
-             ULONG ret_len = 0;
+             SIZE_T ret_len = 0;
 
              st.st_dev = 0;
              st.st_ino = 0;
@@ -932,7 +937,7 @@ format_process_maps (void *data, char *&destbuf)
   return len;
 }
 
-static _off64_t
+static off_t
 format_process_stat (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -975,8 +980,8 @@ format_process_stat (void *data, char *&destbuf)
   KERNEL_USER_TIMES put;
   PROCESS_BASIC_INFORMATION pbi;
   QUOTA_LIMITS ql;
-  SYSTEM_TIME_OF_DAY_INFORMATION stodi;
-  SYSTEM_PROCESSOR_TIMES spt;
+  SYSTEM_TIMEOFDAY_INFORMATION stodi;
+  SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION spt;
   hProcess = OpenProcess (PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
                          FALSE, p->dwProcessId);
   if (hProcess != NULL)
@@ -998,19 +1003,19 @@ format_process_stat (void *data, char *&destbuf)
     {
       DWORD error = GetLastError ();
       __seterrno_from_win_error (error);
-      debug_printf ("OpenProcess: ret %d", error);
+      debug_printf ("OpenProcess: ret %u", error);
       return 0;
     }
   if (NT_SUCCESS (status))
     status = NtQuerySystemInformation (SystemTimeOfDayInformation,
                                       (PVOID) &stodi, sizeof stodi, NULL);
   if (NT_SUCCESS (status))
-    status = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) &spt,
-                                      sizeof spt, NULL);
+    status = NtQuerySystemInformation (SystemProcessorPerformanceInformation,
+                                      (PVOID) &spt, sizeof spt, NULL);
   if (!NT_SUCCESS (status))
     {
       __seterrno_from_nt_status (status);
-      debug_printf ("NtQueryInformationProcess: status %p, %E", status);
+      debug_printf ("NtQueryInformationProcess: status %y, %E", status);
       return 0;
     }
   fault_count = vmc.PageFaultCount;
@@ -1028,7 +1033,13 @@ format_process_stat (void *data, char *&destbuf)
       */
      start_time = (spt.KernelTme.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
 #endif
-  priority = pbi.BasePriority;
+  /* The BasePriority returned to a 32 bit process under WOW64 is
+     apparently broken, for 32 and 64 bit target processes.  64 bit
+     processes get the correct base priority, even for 32 bit processes. */
+  if (wincap.is_wow64 ())
+    priority = 8; /* Default value. */
+  else
+    priority = pbi.BasePriority;
   unsigned page_size = wincap.page_size ();
   vmsize = vmc.PagefileUsage;
   vmrss = vmc.WorkingSetSize / page_size;
@@ -1037,22 +1048,20 @@ format_process_stat (void *data, char *&destbuf)
   destbuf = (char *) crealloc_abort (destbuf, strlen (cmd) + 320);
   return __small_sprintf (destbuf, "%d (%s) %c "
                                   "%d %d %d %d %d "
-                                  "%lu %lu %lu %lu %lu %lu %lu "
-                                  "%ld %ld %ld %ld %ld %ld "
+                                  "%u %lu %lu %u %u %lu %lu "
+                                  "%ld %ld %d %d %d %d "
                                   "%lu %lu "
-                                  "%ld "
-                                  "%lu",
-                         p->pid, cmd,
-                         state,
-                         p->ppid, p->pgid, p->sid, p->ctty,
-                         -1, 0, fault_count, fault_count, 0, 0, utime, stime,
+                                  "%ld %lu",
+                         p->pid, cmd, state,
+                         p->ppid, p->pgid, p->sid, p->ctty, -1,
+                         0, fault_count, fault_count, 0, 0, utime, stime,
                          utime, stime, priority, 0, 0, 0,
                          start_time, vmsize,
                          vmrss, vmmaxrss
                          );
 }
 
-static _off64_t
+static off_t
 format_process_status (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -1139,7 +1148,7 @@ format_process_status (void *data, char *&destbuf)
                          );
 }
 
-static _off64_t
+static off_t
 format_process_statm (void *data, char *&destbuf)
 {
   _pinfo *p = (_pinfo *) data;
@@ -1158,13 +1167,13 @@ extern "C" {
   struct mntent *getmntent (FILE *);
 };
 
-static _off64_t
+static off_t
 format_process_mountstuff (void *data, char *&destbuf, bool mountinfo)
 {
   _pinfo *p = (_pinfo *) data;
   user_info *u_shared = NULL;
   HANDLE u_hdl = NULL;
-  _off64_t len = 0;
+  off_t len = 0;
   struct mntent *mnt;
 
   if (p->uid != myself->uid)
@@ -1203,7 +1212,7 @@ format_process_mountstuff (void *data, char *&destbuf, bool mountinfo)
         each cygdrive entry if it's a remote drive.  If so, ignore it. */
       if (iteration >= mtab->nmounts && u_hdl)
        {
-         WCHAR drive[3] = { mnt->mnt_fsname[0], L':', L'\0' };
+         WCHAR drive[3] = { (WCHAR) mnt->mnt_fsname[0], L':', L'\0' };
          disk_type dt = get_disk_type (drive);
 
          if (dt == DT_SHARE_SMB || dt == DT_SHARE_NFS)
@@ -1246,13 +1255,13 @@ format_process_mountstuff (void *data, char *&destbuf, bool mountinfo)
   return len;
 }
 
-static _off64_t
+static off_t
 format_process_mounts (void *data, char *&destbuf)
 {
   return format_process_mountstuff (data, destbuf, false);
 }
 
-static _off64_t
+static off_t
 format_process_mountinfo (void *data, char *&destbuf)
 {
   return format_process_mountstuff (data, destbuf, true);
@@ -1264,28 +1273,28 @@ get_process_state (DWORD dwProcessId)
   /* This isn't really heavy magic - just go through the processes' threads
      one by one and return a value accordingly.  Errors are silently ignored. */
   NTSTATUS status;
-  PSYSTEM_PROCESSES p, sp;
+  PSYSTEM_PROCESS_INFORMATION p, sp;
   ULONG n = 0x4000;
   int state =' ';
 
-  p = (PSYSTEM_PROCESSES) malloc (n);
+  p = (PSYSTEM_PROCESS_INFORMATION) malloc (n);
   if (!p)
     return state;
   while (true)
     {
-      status = NtQuerySystemInformation (SystemProcessesAndThreadsInformation,
+      status = NtQuerySystemInformation (SystemProcessInformation,
                                         (PVOID) p, n, NULL);
       if (status != STATUS_INFO_LENGTH_MISMATCH)
        break;
       n <<= 1;
-      PSYSTEM_PROCESSES new_p = (PSYSTEM_PROCESSES) realloc (p, n);
+      PSYSTEM_PROCESS_INFORMATION new_p = (PSYSTEM_PROCESS_INFORMATION) realloc (p, n);
       if (!new_p)
        goto out;
       p = new_p;
     }
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtQuerySystemInformation: status %p, %lu",
+      debug_printf ("NtQuerySystemInformation: status %y, %u",
                    status, RtlNtStatusToDosError (status));
       goto out;
     }
@@ -1293,12 +1302,12 @@ get_process_state (DWORD dwProcessId)
   sp = p;
   for (;;)
     {
-      if (sp->ProcessId == dwProcessId)
+      if ((DWORD) (uintptr_t) sp->UniqueProcessId == dwProcessId)
        {
          SYSTEM_THREADS *st;
          st = &sp->Threads[0];
          state = 'S';
-         for (unsigned i = 0; i < sp->ThreadCount; i++)
+         for (unsigned i = 0; i < sp->NumberOfThreads; i++)
            {
              /* FIXME: at some point we should consider generating 'O' */
              if (st->State == StateRunning ||
@@ -1311,9 +1320,9 @@ get_process_state (DWORD dwProcessId)
            }
          break;
        }
-      if (!sp->NextEntryDelta)
+      if (!sp->NextEntryOffset)
         break;
-      sp = (PSYSTEM_PROCESSES) ((char *) sp + sp->NextEntryDelta);
+      sp = (PSYSTEM_PROCESS_INFORMATION) ((char *) sp + sp->NextEntryOffset);
     }
 out:
   free (p);
@@ -1330,7 +1339,7 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
   HANDLE hProcess;
   VM_COUNTERS vmc;
   PMEMORY_WORKING_SET_LIST p;
-  ULONG n = 0x4000, length;
+  SIZE_T n = 0x4000, length;
 
   p = (PMEMORY_WORKING_SET_LIST) malloc (n);
   if (!p)
@@ -1346,7 +1355,7 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
     {
       status = NtQueryVirtualMemory (hProcess, 0, MemoryWorkingSetList,
                                     (PVOID) p, n,
-                                    (length = ULONG_MAX, &length));
+                                    (length = (SIZE_T) -1, &length));
       if (status != STATUS_INFO_LENGTH_MISMATCH)
        break;
       n <<= 1;
@@ -1358,7 +1367,7 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
     }
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtQueryVirtualMemory: status %p", status);
+      debug_printf ("NtQueryVirtualMemory: status %y", status);
       if (status == STATUS_PROCESS_IS_TERMINATING)
        {
          *vmsize = *vmrss = *vmtext = *vmdata = *vmlib = *vmshare = 0;
@@ -1386,7 +1395,7 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
                                      sizeof vmc, NULL);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtQueryInformationProcess: status %p", status);
+      debug_printf ("NtQueryInformationProcess: status %y", status);
       __seterrno_from_nt_status (status);
       goto out;
     }
index d6dc209001ed340d150eb6590f4175943a24e3b9..73f06f637e3a0f8ba0418c59bc87e299e5895658 100644 (file)
@@ -11,6 +11,8 @@ details. */
 #define  __INSIDE_CYGWIN_NET__
 #define USE_SYS_TYPES_FD_SET
 #include "winsup.h"
+#include <ws2tcpip.h>
+#include <iphlpapi.h>
 #include "cygerrno.h"
 #include "security.h"
 #include "path.h"
@@ -18,8 +20,6 @@ details. */
 #include "fhandler_virtual.h"
 #include "dtable.h"
 #include "cygheap.h"
-#include <ws2tcpip.h>
-#include <iphlpapi.h>
 #include <asm/byteorder.h>
 
 #define _COMPILING_NEWLIB
@@ -31,7 +31,7 @@ extern "C" int ip_addr_prefix (PIP_ADAPTER_UNICAST_ADDRESS pua,
                               PIP_ADAPTER_PREFIX pap);
 bool get_adapters_addresses (PIP_ADAPTER_ADDRESSES *pa0, ULONG family);
 
-static _off64_t format_procnet_ifinet6 (void *, char *&);
+static off_t format_procnet_ifinet6 (void *, char *&);
 
 static const virt_tab_t procnet_tab[] =
 {
@@ -63,12 +63,8 @@ fhandler_procnet::exists ()
                                       PROCNET_LINK_COUNT);
   if (entry)
     {
-      if (entry->type == virt_file)
-       {
-         if (!wincap.has_gaa_prefixes ()
-             || !get_adapters_addresses (NULL, AF_INET6))
-           return virt_none;
-       }
+      if (entry->type == virt_file && !get_adapters_addresses (NULL, AF_INET6))
+       return virt_none;
       fileid = entry - procnet_tab;
       return entry->type;
     }
@@ -81,7 +77,7 @@ fhandler_procnet::fhandler_procnet ():
 }
 
 int __reg2
-fhandler_procnet::fstat (struct __stat64 *buf)
+fhandler_procnet::fstat (struct stat *buf)
 {
   fhandler_base::fstat (buf);
   buf->st_mode &= ~_IFMT & NO_W;
@@ -109,12 +105,9 @@ fhandler_procnet::readdir (DIR *dir, dirent *de)
   int res = ENMFILE;
   if (dir->__d_position >= PROCNET_LINK_COUNT)
     goto out;
-  if (procnet_tab[dir->__d_position].type == virt_file)
-    {
-      if (!wincap.has_gaa_prefixes ()
-         || !get_adapters_addresses (NULL, AF_INET6))
-       goto out;
-    }
+  if (procnet_tab[dir->__d_position].type == virt_file
+      && !get_adapters_addresses (NULL, AF_INET6))
+    goto out;
   strcpy (de->d_name, procnet_tab[dir->__d_position++].name);
   dir->__flags |= dirent_saw_dot | dirent_saw_dot_dot;
   res = 0;
@@ -190,7 +183,7 @@ success:
   set_flags ((flags & ~O_TEXT) | O_BINARY);
   set_open_status ();
 out:
-  syscall_printf ("%d = fhandler_proc::open(%p, %d)", res, flags, mode);
+  syscall_printf ("%d = fhandler_proc::open(%y, 0%o)", res, flags, mode);
   return res;
 }
 
@@ -230,16 +223,14 @@ static unsigned int dad_to_flags[] =
   0x80         /* Preferred -> PERMANENT */
 };
 
-static _off64_t
+static off_t
 format_procnet_ifinet6 (void *, char *&filebuf)
 {
   PIP_ADAPTER_ADDRESSES pa0 = NULL, pap;
   PIP_ADAPTER_UNICAST_ADDRESS pua;
   ULONG alloclen;
+  off_t filesize = 0;
 
-  if (!wincap.has_gaa_prefixes ())
-    return 0;
-  _off64_t filesize = 0;
   if (!get_adapters_addresses (&pa0, AF_INET6))
     goto out;
   alloclen = 0;
@@ -263,7 +254,7 @@ format_procnet_ifinet6 (void *, char *&filebuf)
        filebuf[filesize++] = ' ';
        filesize += sprintf (filebuf + filesize,
                             "%02lx %02x %02x %02x %s\n",
-                            pap->Ipv6IfIndex,
+                            (long) pap->Ipv6IfIndex,
                             ip_addr_prefix (pua, pap->FirstPrefix),
                             get_scope (&((struct sockaddr_in6 *)
                                        pua->Address.lpSockaddr)->sin6_addr),
index 14ce0ec2845156a004490c5b46fc6c13e6e760b0..6db2cd89720848e8c6dee2cb263c710532f57f4b 100644 (file)
@@ -1,6 +1,6 @@
 /* fhandler_procsys.cc: fhandler for native NT namespace.
 
-   Copyright 2010, 2011, 2013 Red Hat, Inc.
+   Copyright 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -44,7 +44,7 @@ const size_t procsys_len = sizeof (procsys) - 1;
 /* Returns 0 if path doesn't exist, >0 if path is a directory,
    -1 if path is a file, -2 if it's a symlink.  */
 virtual_ftype_t
-fhandler_procsys::exists (struct __stat64 *buf)
+fhandler_procsys::exists (struct stat *buf)
 {
   UNICODE_STRING path;
   UNICODE_STRING dir;
@@ -74,7 +74,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
     dir.Length -= sizeof (WCHAR);
   InitializeObjectAttributes (&attr, &dir, OBJ_CASE_INSENSITIVE, NULL, NULL);
   status = NtOpenDirectoryObject (&h, DIRECTORY_QUERY, &attr);
-  debug_printf ("NtOpenDirectoryObject: %p", status);
+  debug_printf ("NtOpenDirectoryObject: %y", status);
   if (NT_SUCCESS (status))
     {
       internal = true;
@@ -85,7 +85,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
   InitializeObjectAttributes (&attr, &path, OBJ_CASE_INSENSITIVE, NULL, NULL);
   status = NtOpenSymbolicLinkObject (&h, READ_CONTROL | SYMBOLIC_LINK_QUERY,
                                     &attr);
-  debug_printf ("NtOpenSymbolicLinkObject: %p", status);
+  debug_printf ("NtOpenSymbolicLinkObject: %y", status);
   if (NT_SUCCESS (status))
     {
       /* If requested, check permissions. */
@@ -98,7 +98,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
     return virt_symlink;
   /* Then check if it's an object directory. */
   status = NtOpenDirectoryObject (&h, READ_CONTROL | DIRECTORY_QUERY, &attr);
-  debug_printf ("NtOpenDirectoryObject: %p", status);
+  debug_printf ("NtOpenDirectoryObject: %y", status);
   if (NT_SUCCESS (status))
     {
       /* If requested, check permissions. */
@@ -112,7 +112,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
   /* Next try to open as file/device. */
   status = NtOpenFile (&h, READ_CONTROL | FILE_READ_ATTRIBUTES, &attr, &io,
                       FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
-  debug_printf ("NtOpenFile: %p", status);
+  debug_printf ("NtOpenFile: %y", status);
   /* Name is invalid, that's nothing. */
   if (status == STATUS_OBJECT_NAME_INVALID)
     return virt_none;
@@ -135,7 +135,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
         since NtQueryAttributesFile might crash the machine if the underlying
         driver is badly written. */
       status = NtQueryAttributesFile (&attr, &fbi);
-      debug_printf ("NtQueryAttributesFile: %p", status);
+      debug_printf ("NtQueryAttributesFile: %y", status);
       if (NT_SUCCESS (status))
        return (fbi.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
               ? virt_fsdir : virt_fsfile;
@@ -154,7 +154,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
          status = NtOpenFile (&h, READ_CONTROL | FILE_READ_ATTRIBUTES,
                               &attr, &io, FILE_SHARE_VALID_FLAGS,
                               FILE_OPEN_FOR_BACKUP_INTENT);
-         debug_printf ("NtOpenDirectoryObject: %p", status);
+         debug_printf ("NtOpenDirectoryObject: %y", status);
          if (dir.Length > sizeof (WCHAR))
            dir.Length -= sizeof (WCHAR);
        }
@@ -173,7 +173,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
       /* Check for the device type. */
       status = NtQueryVolumeInformationFile (h, &io, &ffdi, sizeof ffdi,
                                             FileFsDeviceInformation);
-      debug_printf ("NtQueryVolumeInformationFile: %p", status);
+      debug_printf ("NtQueryVolumeInformationFile: %y", status);
       /* Don't call NtQueryInformationFile unless we know it's a safe type.
         The call is known to crash machines, if the underlying driver is
         badly written. */
@@ -195,7 +195,7 @@ fhandler_procsys::exists (struct __stat64 *buf)
             into a real FS through /proc/sys. */
          status = NtQueryInformationFile (h, &io, &fbi, sizeof fbi,
                                           FileBasicInformation);
-         debug_printf ("NtQueryInformationFile: %p", status);
+         debug_printf ("NtQueryInformationFile: %y", status);
          if (!NT_SUCCESS (status))
            file_type = virt_blk;
          else
@@ -261,7 +261,7 @@ unreadable:
 }
 
 int __reg2
-fhandler_procsys::fstat (struct __stat64 *buf)
+fhandler_procsys::fstat (struct stat *buf)
 {
   const char *path = get_name ();
   debug_printf ("fstat (%s)", path);
@@ -271,7 +271,7 @@ fhandler_procsys::fstat (struct __stat64 *buf)
   buf->st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
   buf->st_uid = 544;
   buf->st_gid = 18;
-  buf->st_dev = buf->st_rdev = (int) dev ();
+  buf->st_dev = buf->st_rdev = dev ();
   buf->st_ino = get_ino ();
   switch (exists (buf))
     {
@@ -446,7 +446,7 @@ fhandler_procsys::open (int flags, mode_t mode)
          break;
        }
     }
-  syscall_printf ("%d = fhandler_procsys::open(%p, %d)", res, flags, mode);
+  syscall_printf ("%d = fhandler_procsys::open(%p, 0%o)", res, flags, mode);
   return res;
 }
 
index f2b7169be118a02fee52ffb5b53cf09da7861e4a..6c2aa40069a2062ab11d9acf81f0d755b9fa9ce9 100644 (file)
@@ -1,6 +1,6 @@
 /* fhandler_procsysvipc.cc: fhandler for /proc/sysvipc virtual filesystem
 
-   Copyright 2011, 2013 Red Hat, Inc.
+   Copyright 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -38,9 +38,9 @@ details. */
 #include <sys/sem.h>
 #include <sys/shm.h>
 
-static _off64_t format_procsysvipc_msg (void *, char *&);
-static _off64_t format_procsysvipc_sem (void *, char *&);
-static _off64_t format_procsysvipc_shm (void *, char *&);
+static off_t format_procsysvipc_msg (void *, char *&);
+static off_t format_procsysvipc_sem (void *, char *&);
+static off_t format_procsysvipc_shm (void *, char *&);
 
 static const virt_tab_t procsysvipc_tab[] =
 {
@@ -93,7 +93,7 @@ fhandler_procsysvipc::fhandler_procsysvipc ():
 }
 
 int __reg2
-fhandler_procsysvipc::fstat (struct __stat64 *buf)
+fhandler_procsysvipc::fstat (struct stat *buf)
 {
   fhandler_base::fstat (buf);
   buf->st_mode &= ~_IFMT & NO_W;
@@ -202,7 +202,7 @@ success:
   set_flags ((flags & ~O_TEXT) | O_BINARY);
   set_open_status ();
 out:
-  syscall_printf ("%d = fhandler_proc::open(%p, %d)", res, flags, mode);
+  syscall_printf ("%d = fhandler_proc::open(%p, 0%o)", res, flags, mode);
   return res;
 }
 
@@ -217,7 +217,7 @@ fhandler_procsysvipc::fill_filebuf ()
   return false;
 }
 
-static _off64_t
+static off_t
 format_procsysvipc_msg (void *, char *&destbuf)
 {
   tmp_pathbuf tp;
@@ -238,7 +238,7 @@ format_procsysvipc_msg (void *, char *&destbuf)
   for (int i = 0; i < msginfo.msgmni; i++) {
     if (xmsqids[i].msg_qbytes != 0) {
        bufptr += sprintf (bufptr,
-                "%10llu %10u %5o %11lu %10lu %5d %5d %5lu %5lu %5lu %5lu %10ld %10ld %10ld\n",
+                "%10llu %10u %5o %11u %10u %5d %5d %5u %5u %5u %5u %10ld %10ld %10ld\n",
                 xmsqids[i].msg_perm.key,
                 IXSEQ_TO_IPCID(i, xmsqids[i].msg_perm),
                 xmsqids[i].msg_perm.mode,
@@ -246,10 +246,10 @@ format_procsysvipc_msg (void *, char *&destbuf)
                 xmsqids[i].msg_qnum,
                 xmsqids[i].msg_lspid,
                 xmsqids[i].msg_lrpid,
-                xmsqids[i].msg_perm.uid,
-                xmsqids[i].msg_perm.gid,
-                xmsqids[i].msg_perm.cuid,
-                xmsqids[i].msg_perm.cgid,
+                (unsigned) xmsqids[i].msg_perm.uid,
+                (unsigned) xmsqids[i].msg_perm.gid,
+                (unsigned) xmsqids[i].msg_perm.cuid,
+                (unsigned) xmsqids[i].msg_perm.cgid,
                 xmsqids[i].msg_stime,
                 xmsqids[i].msg_rtime,
                 xmsqids[i].msg_ctime);
@@ -261,7 +261,7 @@ format_procsysvipc_msg (void *, char *&destbuf)
   return bufptr - buf;
 }
 
-static _off64_t
+static off_t
 format_procsysvipc_sem (void *, char *&destbuf)
 {
   tmp_pathbuf tp;
@@ -284,15 +284,15 @@ format_procsysvipc_sem (void *, char *&destbuf)
   for (int i = 0; i < seminfo.semmni; i++) {
     if ((xsemids[i].sem_perm.mode & SEM_ALLOC) != 0) {
       bufptr += sprintf (bufptr,
-               "%10llu %10u %5o %10d %5lu %5lu %5lu %5lu %10ld %10ld\n",
+               "%10llu %10u %5o %10d %5u %5u %5u %5u %10ld %10ld\n",
                xsemids[i].sem_perm.key,
                IXSEQ_TO_IPCID(i, xsemids[i].sem_perm),
                xsemids[i].sem_perm.mode,
                xsemids[i].sem_nsems,
-               xsemids[i].sem_perm.uid,
-               xsemids[i].sem_perm.gid,
-               xsemids[i].sem_perm.cuid,
-               xsemids[i].sem_perm.cgid,
+               (unsigned) xsemids[i].sem_perm.uid,
+               (unsigned) xsemids[i].sem_perm.gid,
+               (unsigned) xsemids[i].sem_perm.cuid,
+               (unsigned) xsemids[i].sem_perm.cgid,
                xsemids[i].sem_otime,
                xsemids[i].sem_ctime);
     }
@@ -303,7 +303,7 @@ format_procsysvipc_sem (void *, char *&destbuf)
   return bufptr - buf;
 }
 
-static _off64_t
+static off_t
 format_procsysvipc_shm (void *, char *&destbuf)
 {
   tmp_pathbuf tp;
@@ -323,7 +323,7 @@ format_procsysvipc_shm (void *, char *&destbuf)
   for (int i = 0; i < shminfo.shmmni; i++) {
     if (xshmids[i].shm_perm.mode & 0x0800) {
       bufptr += sprintf (bufptr,
-               "%10llu %10u %5o %10u %5d %5d %6u %5lu %5lu %5lu %5lu %10ld %10ld %10ld\n",
+               "%10llu %10u %5o %10u %5d %5d %6u %5u %5u %5u %5u %10ld %10ld %10ld\n",
                xshmids[i].shm_perm.key,
                IXSEQ_TO_IPCID(i, xshmids[i].shm_perm),
                xshmids[i].shm_perm.mode,
@@ -331,10 +331,10 @@ format_procsysvipc_shm (void *, char *&destbuf)
                xshmids[i].shm_cpid,
                xshmids[i].shm_lpid,
                xshmids[i].shm_nattch,
-               xshmids[i].shm_perm.uid,
-               xshmids[i].shm_perm.gid,
-               xshmids[i].shm_perm.cuid,
-               xshmids[i].shm_perm.cgid,
+               (unsigned) xshmids[i].shm_perm.uid,
+               (unsigned) xshmids[i].shm_perm.gid,
+               (unsigned) xshmids[i].shm_perm.cuid,
+               (unsigned) xshmids[i].shm_perm.cgid,
                xshmids[i].shm_atime,
                xshmids[i].shm_dtime,
                xshmids[i].shm_ctime);
index cc94801d3e19ba819e06889d77c43bc6a418469a..d8ea2a3c85b472d797ca8fd58588d802f023416e 100644 (file)
@@ -143,13 +143,13 @@ fhandler_dev_random::read (void *ptr, size_t& len)
   len = (size_t) -1;
 }
 
-_off64_t
-fhandler_dev_random::lseek (_off64_t off, int whence)
+off_t
+fhandler_dev_random::lseek (off_t off, int whence)
 {
   /* As on Linux, fake being able to set an offset.  The fact that neither
      reading nor writing changes the dummy offset is also the same as on
      Linux (tested with kernel 2.6.23). */
-  _off64_t new_off;
+  off_t new_off;
 
   switch (whence)
     {
@@ -161,12 +161,12 @@ fhandler_dev_random::lseek (_off64_t off, int whence)
       break;
     default:
       set_errno (EINVAL);
-      return (_off64_t) -1;
+      return (off_t) -1;
     }
   if (new_off < 0)
     {
       set_errno (EINVAL);
-      return (_off64_t) -1;
+      return (off_t) -1;
     }
   return dummy_offset = new_off;
 }
index cf6861f1fbecc2904c704e1d0d9e16b08a3e7f57..04f40f3873e2112bba4843608cc576f34fcc5449 100644 (file)
@@ -36,7 +36,7 @@ fhandler_dev_raw::~fhandler_dev_raw ()
 }
 
 int __reg2
-fhandler_dev_raw::fstat (struct __stat64 *buf)
+fhandler_dev_raw::fstat (struct stat *buf)
 {
   debug_printf ("here");
 
@@ -95,7 +95,7 @@ fhandler_dev_raw::dup (fhandler_base *child, int flags)
          /* Create sector-aligned buffer */
          fhc->devbufalloc = new char [devbufsiz + devbufalign];
          fhc->devbuf = (char *) roundup2 ((uintptr_t) fhc->devbufalloc,
-                                          devbufalign);
+                                          (uintptr_t) devbufalign);
        }
       fhc->devbufstart = 0;
       fhc->devbufend = 0;
@@ -121,7 +121,8 @@ fhandler_dev_raw::fixup_after_exec ()
        {
          /* Create sector-aligned buffer */
          devbufalloc = new char [devbufsiz + devbufalign];
-         devbuf = (char *) roundup2 ((uintptr_t) devbufalloc, devbufalign);
+         devbuf = (char *) roundup2 ((uintptr_t) devbufalloc,
+                                     (uintptr_t) devbufalign);
        }
       devbufstart = 0;
       devbufend = 0;
@@ -165,7 +166,7 @@ fhandler_dev_raw::ioctl (unsigned int cmd, void *buf)
            else if (!devbuf || op->rd_parm != devbufsiz)
              {
                char *buf = NULL;
-               _off64_t curpos = lseek (0, SEEK_CUR);
+               off_t curpos = lseek (0, SEEK_CUR);
 
                if (op->rd_parm > 1L)
                  buf = new char [op->rd_parm + devbufalign];
@@ -174,7 +175,8 @@ fhandler_dev_raw::ioctl (unsigned int cmd, void *buf)
                  delete [] devbufalloc;
 
                devbufalloc = buf;
-               devbuf = (char *) roundup2 ((uintptr_t) buf, devbufalign);
+               devbuf = (char *) roundup2 ((uintptr_t) buf,
+                                           (uintptr_t) devbufalign);
                devbufsiz = op->rd_parm ?: 1L;
                devbufstart = devbufend = 0;
                lseek (curpos, SEEK_SET);
index 97870f0137cfe549ccb835706b6461afdd6d98cb..ef1213360c0bebf1c7f66f9e915048d00151980e 100644 (file)
@@ -29,8 +29,8 @@ details. */
  * the bottom 16 bits are the absolute position and the top 15 bits
  * make up the value index if we are enuerating values.
  */
-static const _off_t REG_ENUM_VALUES_MASK = 0x8000000;
-static const _off_t REG_POSITION_MASK = 0xffff;
+static const __int32_t REG_ENUM_VALUES_MASK = 0x8000000;
+static const __int32_t REG_POSITION_MASK = 0xffff;
 
 /* These key paths are used below whenever we return key information.
    The problem is UAC virtualization when running an admin account with
@@ -59,7 +59,7 @@ static const char *registry_listing[] =
   "HKEY_CURRENT_USER",
   "HKEY_LOCAL_MACHINE",
   "HKEY_USERS",
-  "HKEY_PERFORMANCE_DATA",     // NT/2000/XP
+  "HKEY_PERFORMANCE_DATA",
   NULL
 };
 
@@ -462,7 +462,7 @@ fhandler_proc ()
 }
 
 int __reg2
-fhandler_registry::fstat (struct __stat64 *buf)
+fhandler_registry::fstat (struct stat *buf)
 {
   fhandler_base::fstat (buf);
   buf->st_mode &= ~_IFMT & NO_W;
@@ -551,8 +551,8 @@ fhandler_registry::fstat (struct __stat64 *buf)
                  else
                    buf->st_size = dwSize;
                }
-             __uid32_t uid;
-             __gid32_t gid;
+             uid_t uid;
+             gid_t gid;
              if (get_reg_attribute (hKey, &buf->st_mode, &uid, &gid) == 0)
                {
                  buf->st_uid = uid;
@@ -616,7 +616,7 @@ fhandler_registry::readdir (DIR *dir, dirent *de)
       dir->__handle = open_key (path + 1, KEY_READ, wow64, false);
       if (dir->__handle == INVALID_HANDLE_VALUE)
        goto out;
-      dir->__d_internal = (unsigned) new __DIR_hash ();
+      dir->__d_internal = (uintptr_t) new __DIR_hash ();
     }
   if (dir->__d_position < SPECIAL_DOT_FILE_COUNT)
     {
@@ -893,7 +893,7 @@ success:
   set_flags ((flags & ~O_TEXT) | O_BINARY);
   set_open_status ();
 out:
-  syscall_printf ("%d = fhandler_registry::open(%p, %d)", res, flags, mode);
+  syscall_printf ("%d = fhandler_registry::open(%p, 0%o)", res, flags, mode);
   return res;
 }
 
index b6b06f76d9871bd86af5b42cad79fdbf3dc9058a..1c0f4d4f4524218cb6181adf1c12801c71d18353 100644 (file)
@@ -49,8 +49,8 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
 
   size_t minchars = vmin_ ? MIN (vmin_, ulen) : ulen;
 
-  debug_printf ("ulen %d, vmin_ %d, vtime_ %d, hEvent %p", ulen, vmin_, vtime_,
-               io_status.hEvent);
+  debug_printf ("ulen %ld, vmin_ %ld, vtime_ %u, hEvent %p",
+               ulen, vmin_, vtime_, io_status.hEvent);
   if (!overlapped_armed)
     {
       SetCommMask (get_handle (), EV_RXCHAR);
@@ -94,7 +94,7 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
                  if (!GetOverlappedResult (get_handle (), &io_status, &n,
                                            FALSE))
                    goto err;
-                 debug_printf ("n %d, ev %x", n, ev);
+                 debug_printf ("n %u, ev %x", n, ev);
                  break;
                case WAIT_SIGNALED:
                  tot = -1;
@@ -117,7 +117,7 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
       ResetEvent (io_status.hEvent);
       if (inq > ulen)
        inq = ulen;
-      debug_printf ("inq %d", inq);
+      debug_printf ("inq %u", inq);
       if (ReadFile (get_handle (), ptr, inq, &n, &io_status))
        /* Got something */;
       else if (GetLastError () != ERROR_IO_PENDING)
@@ -143,7 +143,7 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
        goto err;
 
       tot += n;
-      debug_printf ("vtime_ %d, vmin_ %d, n %d, tot %d", vtime_, vmin_, n, tot);
+      debug_printf ("vtime_ %u, vmin_ %lu, n %u, tot %d", vtime_, vmin_, n, tot);
       if (vtime_ || !vmin_ || !n)
        break;
       continue;
@@ -244,8 +244,8 @@ fhandler_serial::open (int flags, mode_t mode)
   int res;
   COMMTIMEOUTS to;
 
-  syscall_printf ("fhandler_serial::open (%s, %p, %p)",
-                       get_name (), flags, mode);
+  syscall_printf ("fhandler_serial::open (%s, %y, 0%o)",
+                 get_name (), flags, mode);
 
   if (!fhandler_base::open (flags, mode))
     return 0;
@@ -301,8 +301,8 @@ fhandler_serial::open (int flags, mode_t mode)
 
   SetCommMask (get_handle (), EV_RXCHAR);
   set_open_status ();
-  syscall_printf ("%p = fhandler_serial::open (%s, %p, %p)",
-                       res, get_name (), flags, mode);
+  syscall_printf ("%p = fhandler_serial::open (%s, %y, 0%o)",
+                 res, get_name (), flags, mode);
   return res;
 }
 
@@ -446,7 +446,7 @@ fhandler_serial::ioctl (unsigned int cmd, void *buf)
 {
   int res = 0;
 
-# define ibuf ((int) buf)
+# define ibuf ((int) (intptr_t) buf)
 # define ipbuf (*(int *) buf)
 
   DWORD ev;
@@ -544,7 +544,7 @@ fhandler_serial::ioctl (unsigned int cmd, void *buf)
        break;
      }
 
-  termios_printf ("%d = ioctl(%p, %p)", res, cmd, buf);
+  termios_printf ("%d = ioctl(%x, %p)", res, cmd, buf);
 # undef ibuf
 # undef ipbuf
   return res;
@@ -699,7 +699,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
       break;
     default:
       /* Unsupported baud rate! */
-      termios_printf ("Invalid t->c_ospeed %d", t->c_ospeed);
+      termios_printf ("Invalid t->c_ospeed %u", t->c_ospeed);
       set_errno (EINVAL);
       return -1;
     }
@@ -722,7 +722,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
       break;
     default:
       /* Unsupported byte size! */
-      termios_printf ("Invalid t->c_cflag byte size %d",
+      termios_printf ("Invalid t->c_cflag byte size %u",
                      t->c_cflag & CSIZE);
       set_errno (EINVAL);
       return -1;
@@ -902,7 +902,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
       vmin_ = t->c_cc[VMIN];
     }
 
-  debug_printf ("vtime %d, vmin %d", vtime_, vmin_);
+  debug_printf ("vtime %d, vmin %ld", vtime_, vmin_);
 
   if (ovmin != vmin_ || ovtime != vtime_)
   {
@@ -935,7 +935,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
        to.ReadIntervalTimeout = MAXDWORD;
       }
 
-    debug_printf ("ReadTotalTimeoutConstant %d, ReadIntervalTimeout %d, ReadTotalTimeoutMultiplier %d",
+    debug_printf ("ReadTotalTimeoutConstant %u, ReadIntervalTimeout %u, ReadTotalTimeoutMultiplier %u",
                  to.ReadTotalTimeoutConstant, to.ReadIntervalTimeout, to.ReadTotalTimeoutMultiplier);
 
     if (!SetCommTimeouts(get_handle (), &to))
@@ -1042,7 +1042,7 @@ fhandler_serial::tcgetattr (struct termios *t)
        break;
     default:
        /* Unsupported baud rate! */
-       termios_printf ("Invalid baud rate %d", state.BaudRate);
+       termios_printf ("Invalid baud rate %u", state.BaudRate);
        set_errno (EINVAL);
        return -1;
     }
@@ -1065,7 +1065,7 @@ fhandler_serial::tcgetattr (struct termios *t)
       break;
     default:
       /* Unsupported byte size! */
-      termios_printf ("Invalid byte size %d", state.ByteSize);
+      termios_printf ("Invalid byte size %u", state.ByteSize);
       set_errno (EINVAL);
       return -1;
     }
@@ -1136,7 +1136,7 @@ fhandler_serial::tcgetattr (struct termios *t)
   t->c_cc[VTIME] = vtime_ / 100;
   t->c_cc[VMIN] = vmin_;
 
-  debug_printf ("vmin_ %d, vtime_ %d", vmin_, vtime_);
+  debug_printf ("vmin_ %lu, vtime_ %u", vmin_, vtime_);
 
   return 0;
 }
index c76fa47c31f21efc9ee305e0d06319adcc445b02..46cb09c03fea03649d0051bc64d75f99be53b096 100644 (file)
 #define  __INSIDE_CYGWIN_NET__
 #define USE_SYS_TYPES_FD_SET
 
+#define _BSDTYPES_DEFINED
 #include "winsup.h"
+#undef _BSDTYPES_DEFINED
+#include <ws2tcpip.h>
+#include <mswsock.h>
+#include <iphlpapi.h>
 #include "cygerrno.h"
 #include "security.h"
 #include "path.h"
 #include "fhandler.h"
 #include "dtable.h"
 #include "cygheap.h"
-#include <ws2tcpip.h>
-#include <mswsock.h>
-#include <iphlpapi.h>
 #include <asm/byteorder.h>
 #include "cygwin/version.h"
 #include "perprocess.h"
@@ -232,7 +234,7 @@ fhandler_socket::~fhandler_socket ()
 char *
 fhandler_socket::get_proc_fd_name (char *buf)
 {
-  __small_sprintf (buf, "socket:[%d]", get_socket ());
+  __small_sprintf (buf, "socket:[%lu]", get_socket ());
   return buf;
 }
 
@@ -328,7 +330,7 @@ fhandler_socket::af_local_send_secret ()
 bool
 fhandler_socket::af_local_recv_cred ()
 {
-  struct ucred out = { (pid_t) 0, (__uid32_t) -1, (__gid32_t) -1 };
+  struct ucred out = { (pid_t) 0, (uid_t) -1, (gid_t) -1 };
   int rest = sizeof out;
   char *ptr = (char *) &out;
   while (rest > 0)
@@ -421,8 +423,8 @@ fhandler_socket::af_local_set_cred ()
   sec_uid = geteuid32 ();
   sec_gid = getegid32 ();
   sec_peer_pid = (pid_t) 0;
-  sec_peer_uid = (__uid32_t) -1;
-  sec_peer_gid = (__gid32_t) -1;
+  sec_peer_uid = (uid_t) -1;
+  sec_peer_gid = (gid_t) -1;
 }
 
 void
@@ -504,7 +506,7 @@ search_wsa_event_slot (LONG new_serial_number)
                                  everyone_sd (CYG_MUTANT_ACCESS));
       status = NtCreateMutant (&wsa_slot_mtx, CYG_MUTANT_ACCESS, &attr, FALSE);
       if (!NT_SUCCESS (status))
-       api_fatal ("Couldn't create/open shared socket mutex %S, %p",
+       api_fatal ("Couldn't create/open shared socket mutex %S, %y",
                   &uname, status);
     }
   switch (WaitForSingleObject (wsa_slot_mtx, INFINITE))
@@ -566,7 +568,7 @@ fhandler_socket::init_events ()
       status = NtCreateMutant (&wsock_mtx, CYG_MUTANT_ACCESS, &attr, FALSE);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("NtCreateMutant(%S), %p", &uname, status);
+         debug_printf ("NtCreateMutant(%S), %y", &uname, status);
          set_errno (ENOBUFS);
          return false;
        }
@@ -722,7 +724,7 @@ fhandler_socket::fixup_before_fork_exec (DWORD win_pid)
   if (ret)
     set_winsock_errno ();
   else
-    debug_printf ("WSADuplicateSocket succeeded (%lx)", prot_info_ptr->dwProviderReserved);
+    debug_printf ("WSADuplicateSocket succeeded (%x)", prot_info_ptr->dwProviderReserved);
   return (int) ret;
 }
 
@@ -752,7 +754,7 @@ fhandler_socket::fixup_after_fork (HANDLE parent)
         socket is potentially inheritable again. */
       SetHandleInformation ((HANDLE) new_sock, HANDLE_FLAG_INHERIT, 0);
       set_io_handle ((HANDLE) new_sock);
-      debug_printf ("WSASocket succeeded (%lx)", new_sock);
+      debug_printf ("WSASocket succeeded (%p)", new_sock);
     }
 }
 
@@ -818,7 +820,7 @@ fhandler_socket::dup (fhandler_base *child, int flags)
 }
 
 int __reg2
-fhandler_socket::fstat (struct __stat64 *buf)
+fhandler_socket::fstat (struct stat *buf)
 {
   int res;
   if (get_device () == FH_UNIX)
@@ -836,7 +838,7 @@ fhandler_socket::fstat (struct __stat64 *buf)
       if (!res)
        {
          buf->st_dev = 0;
-         buf->st_ino = (__ino64_t) ((DWORD) get_handle ());
+         buf->st_ino = (ino_t) ((uintptr_t) get_handle ());
          buf->st_mode = S_IFSOCK | S_IRWXU | S_IRWXG | S_IRWXO;
          buf->st_size = 0;
        }
@@ -872,7 +874,7 @@ fhandler_socket::fchmod (mode_t mode)
 }
 
 int
-fhandler_socket::fchown (__uid32_t uid, __gid32_t gid)
+fhandler_socket::fchown (uid_t uid, gid_t gid)
 {
   if (get_device () == FH_UNIX)
     {
@@ -884,7 +886,7 @@ fhandler_socket::fchown (__uid32_t uid, __gid32_t gid)
 }
 
 int
-fhandler_socket::facl (int cmd, int nentries, __aclent32_t *aclbufp)
+fhandler_socket::facl (int cmd, int nentries, aclent_t *aclbufp)
 {
   if (get_device () == FH_UNIX)
     {
@@ -1022,7 +1024,7 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen)
              status = NtSetInformationFile (fh, &io, &fdi, sizeof fdi,
                                             FileDispositionInformation);
              if (!NT_SUCCESS (status))
-               debug_printf ("Setting delete dispostion failed, status = %p",
+               debug_printf ("Setting delete dispostion failed, status = %y",
                              status);
            }
          else
@@ -1041,10 +1043,7 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen)
          /* If the application didn't explicitely request SO_REUSEADDR,
             enforce POSIX standard socket binding behaviour by setting the
             SO_EXCLUSIVEADDRUSE socket option.  See cygwin_setsockopt()
-            for a more detailed description.
-
-            KB 870562: Note that a bug in Win2K SP1-3 and XP up to SP1 only
-            enables this option for users in the local administrators group. */
+            for a more detailed description. */
          int on = 1;
          int ret = ::setsockopt (get_socket (), SOL_SOCKET,
                                  ~(SO_REUSEADDR),
@@ -1069,8 +1068,6 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
   DWORD err;
   int type;
 
-  pthread_testcancel ();
-
   if (get_inet_addr (name, namelen, &sst, &namelen, &type, connect_secret)
       == SOCKET_ERROR)
     return SOCKET_ERROR;
@@ -1181,8 +1178,6 @@ fhandler_socket::accept4 (struct sockaddr *peer, int *len, int flags)
   struct sockaddr_storage lpeer;
   int llen = sizeof (struct sockaddr_storage);
 
-  pthread_testcancel ();
-
   int res = 0;
   while (!(res = wait_for_events (FD_ACCEPT | FD_CLOSE, 0))
         && (res = ::accept (get_socket (), (struct sockaddr *) &lpeer, &llen))
@@ -1355,30 +1350,6 @@ fhandler_socket::getpeername (struct sockaddr *name, int *namelen)
   return res;
 }
 
-void __stdcall
-fhandler_socket::read (void *in_ptr, size_t& len)
-{
-  WSABUF wsabuf = { len, (char *) in_ptr };
-  WSAMSG wsamsg = { NULL, 0, &wsabuf, 1, { 0,  NULL }, 0 };
-  len = recv_internal (&wsamsg, false);
-}
-
-int
-fhandler_socket::readv (const struct iovec *const iov, const int iovcnt,
-                       ssize_t tot)
-{
-  WSABUF wsabuf[iovcnt];
-  WSABUF *wsaptr = wsabuf + iovcnt;
-  const struct iovec *iovptr = iov + iovcnt;
-  while (--wsaptr >= wsabuf)
-    {
-      wsaptr->len = (--iovptr)->iov_len;
-      wsaptr->buf = (char *) iovptr->iov_base;
-    }
-  WSAMSG wsamsg = { NULL, 0, wsabuf, iovcnt, { 0,  NULL}, 0 };
-  return recv_internal (&wsamsg, false);
-}
-
 /* There's no DLL which exports the symbol WSARecvMsg.  One has to call
    WSAIoctl as below to fetch the function pointer.  Why on earth did the
    MS developers decide not to export a normal symbol for these extension
@@ -1556,17 +1527,79 @@ fhandler_socket::recv_internal (LPWSAMSG wsamsg, bool use_recvmsg)
   return ret;
 }
 
+void __stdcall
+fhandler_socket::read (void *in_ptr, size_t& len)
+{
+  char *ptr = (char *) in_ptr;
+
+#ifdef __x86_64__
+  /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
+     Split buffer if necessary. */
+  DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
+  WSABUF wsabuf[bufcnt];
+  WSAMSG wsamsg = { NULL, 0, wsabuf, bufcnt, { 0,  NULL }, 0 };
+  /* Don't use len as loop condition, it could be 0. */
+  for (WSABUF *wsaptr = wsabuf; bufcnt--; ++wsaptr)
+    {
+      wsaptr->len = MIN (len, UINT32_MAX);
+      wsaptr->buf = ptr;
+      len -= wsaptr->len;
+      ptr += wsaptr->len;
+    }
+#else
+  WSABUF wsabuf = { len, ptr };
+  WSAMSG wsamsg = { NULL, 0, &wsabuf, 1, { 0,  NULL }, 0 };
+#endif
+  
+  len = recv_internal (&wsamsg, false);
+}
+
 ssize_t
-fhandler_socket::recvfrom (void *ptr, size_t len, int flags,
+fhandler_socket::readv (const struct iovec *const iov, const int iovcnt,
+                       ssize_t tot)
+{
+  WSABUF wsabuf[iovcnt];
+  WSABUF *wsaptr = wsabuf + iovcnt;
+  const struct iovec *iovptr = iov + iovcnt;
+  while (--wsaptr >= wsabuf)
+    {
+      wsaptr->len = (--iovptr)->iov_len;
+      wsaptr->buf = (char *) iovptr->iov_base;
+    }
+  WSAMSG wsamsg = { NULL, 0, wsabuf, (DWORD) iovcnt, { 0,  NULL}, 0 };
+  return recv_internal (&wsamsg, false);
+}
+
+ssize_t
+fhandler_socket::recvfrom (void *in_ptr, size_t len, int flags,
                           struct sockaddr *from, int *fromlen)
 {
-  pthread_testcancel ();
+  char *ptr = (char *) in_ptr;
 
-  WSABUF wsabuf = { len, (char *) ptr };
+#ifdef __x86_64__
+  /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
+     Split buffer if necessary. */
+  DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
+  WSABUF wsabuf[bufcnt];
+  WSAMSG wsamsg = { from, from && fromlen ? *fromlen : 0,
+                   wsabuf, bufcnt,
+                   { 0,  NULL },
+                   (DWORD) flags };
+  /* Don't use len as loop condition, it could be 0. */
+  for (WSABUF *wsaptr = wsabuf; bufcnt--; ++wsaptr)
+    {
+      wsaptr->len = MIN (len, UINT32_MAX);
+      wsaptr->buf = ptr;
+      len -= wsaptr->len;
+      ptr += wsaptr->len;
+    }
+#else
+  WSABUF wsabuf = { len, ptr };
   WSAMSG wsamsg = { from, from && fromlen ? *fromlen : 0,
                    &wsabuf, 1,
                    { 0, NULL},
-                   flags };
+                   (DWORD) flags };
+#endif
   ssize_t ret = recv_internal (&wsamsg, false);
   if (fromlen)
     *fromlen = wsamsg.namelen;
@@ -1576,15 +1609,12 @@ fhandler_socket::recvfrom (void *ptr, size_t len, int flags,
 ssize_t
 fhandler_socket::recvmsg (struct msghdr *msg, int flags)
 {
-  pthread_testcancel ();
-
   /* TODO: Descriptor passing on AF_LOCAL sockets. */
 
   /* Disappointing but true:  Even if WSARecvMsg is supported, it's only
      supported for datagram and raw sockets. */
   bool use_recvmsg = true;
-  if (get_socket_type () == SOCK_STREAM || get_addr_family () == AF_LOCAL
-      || !wincap.has_recvmsg ())
+  if (get_socket_type () == SOCK_STREAM || get_addr_family () == AF_LOCAL)
     {
       use_recvmsg = false;
       msg->msg_controllen = 0;
@@ -1599,9 +1629,9 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags)
       wsaptr->buf = (char *) iovptr->iov_base;
     }
   WSAMSG wsamsg = { (struct sockaddr *) msg->msg_name, msg->msg_namelen,
-                   wsabuf, msg->msg_iovlen,
-                   { msg->msg_controllen, (char *) msg->msg_control },
-                   flags };
+                   wsabuf, (DWORD) msg->msg_iovlen,
+                   { (DWORD) msg->msg_controllen, (char *) msg->msg_control },
+                   (DWORD) flags };
   ssize_t ret = recv_internal (&wsamsg, use_recvmsg);
   if (ret >= 0)
     {
@@ -1613,34 +1643,10 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags)
   return ret;
 }
 
-int
-fhandler_socket::write (const void *ptr, size_t len)
-{
-  WSABUF wsabuf = { len, (char *) ptr };
-  WSAMSG wsamsg = { NULL, 0, &wsabuf, 1, { 0, NULL }, 0 };
-  return send_internal (&wsamsg, 0);
-}
-
-int
-fhandler_socket::writev (const struct iovec *const iov, const int iovcnt,
-                        ssize_t tot)
-{
-  WSABUF wsabuf[iovcnt];
-  WSABUF *wsaptr = wsabuf;
-  const struct iovec *iovptr = iov;
-  for (int i = 0; i < iovcnt; ++i)
-    {
-      wsaptr->len = iovptr->iov_len;
-      (wsaptr++)->buf = (char *) (iovptr++)->iov_base;
-    }
-  WSAMSG wsamsg = { NULL, 0, wsabuf, iovcnt, { 0, NULL}, 0 };
-  return send_internal (&wsamsg, 0);
-}
-
 inline ssize_t
 fhandler_socket::send_internal (struct _WSAMSG *wsamsg, int flags)
 {
-  int res = 0;
+  ssize_t res = 0;
   DWORD ret = 0, err = 0, sum = 0, off = 0;
   WSABUF buf;
   bool use_sendmsg = false;
@@ -1721,25 +1727,85 @@ fhandler_socket::send_internal (struct _WSAMSG *wsamsg, int flags)
 }
 
 ssize_t
-fhandler_socket::sendto (const void *ptr, size_t len, int flags,
+fhandler_socket::write (const void *in_ptr, size_t len)
+{
+  char *ptr = (char *) in_ptr;
+
+#ifdef __x86_64__
+  /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
+     Split buffer if necessary. */
+  DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
+  WSABUF wsabuf[bufcnt];
+  WSAMSG wsamsg = { NULL, 0, wsabuf, bufcnt, { 0,  NULL }, 0 };
+  /* Don't use len as loop condition, it could be 0. */
+  for (WSABUF *wsaptr = wsabuf; bufcnt--; ++wsaptr)
+    {
+      wsaptr->len = MIN (len, UINT32_MAX);
+      wsaptr->buf = ptr;
+      len -= wsaptr->len;
+      ptr += wsaptr->len;
+    }
+#else
+  WSABUF wsabuf = { len, ptr };
+  WSAMSG wsamsg = { NULL, 0, &wsabuf, 1, { 0, NULL }, 0 };
+#endif
+  return send_internal (&wsamsg, 0);
+}
+
+ssize_t
+fhandler_socket::writev (const struct iovec *const iov, const int iovcnt,
+                        ssize_t tot)
+{
+  WSABUF wsabuf[iovcnt];
+  WSABUF *wsaptr = wsabuf;
+  const struct iovec *iovptr = iov;
+  for (int i = 0; i < iovcnt; ++i)
+    {
+      wsaptr->len = iovptr->iov_len;
+      (wsaptr++)->buf = (char *) (iovptr++)->iov_base;
+    }
+  WSAMSG wsamsg = { NULL, 0, wsabuf, (DWORD) iovcnt, { 0, NULL}, 0 };
+  return send_internal (&wsamsg, 0);
+}
+
+ssize_t
+fhandler_socket::sendto (const void *in_ptr, size_t len, int flags,
                         const struct sockaddr *to, int tolen)
 {
+  char *ptr = (char *) in_ptr;
   struct sockaddr_storage sst;
 
-  pthread_testcancel ();
-
   if (to && get_inet_addr (to, tolen, &sst, &tolen) == SOCKET_ERROR)
     return SOCKET_ERROR;
 
-  WSABUF wsabuf = { len, (char *) ptr };
+#ifdef __x86_64__
+  /* size_t is 64 bit, but the len member in WSABUF is 32 bit.
+     Split buffer if necessary. */
+  DWORD bufcnt = len / UINT32_MAX + ((!len || (len % UINT32_MAX)) ? 1 : 0);
+  WSABUF wsabuf[bufcnt];
+  WSAMSG wsamsg = { to ? (struct sockaddr *) &sst : NULL, tolen,
+                   wsabuf, bufcnt,
+                   { 0,  NULL },
+                   0 };
+  /* Don't use len as loop condition, it could be 0. */
+  for (WSABUF *wsaptr = wsabuf; bufcnt--; ++wsaptr)
+    {
+      wsaptr->len = MIN (len, UINT32_MAX);
+      wsaptr->buf = ptr;
+      len -= wsaptr->len;
+      ptr += wsaptr->len;
+    }
+#else
+  WSABUF wsabuf = { len, ptr };
   WSAMSG wsamsg = { to ? (struct sockaddr *) &sst : NULL, tolen,
                    &wsabuf, 1,
                    { 0, NULL},
                    0 };
+#endif
   return send_internal (&wsamsg, flags);
 }
 
-int
+ssize_t
 fhandler_socket::sendmsg (const struct msghdr *msg, int flags)
 {
   /* TODO: Descriptor passing on AF_LOCAL sockets. */
@@ -1747,8 +1813,6 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags)
   struct sockaddr_storage sst;
   int len = 0;
 
-  pthread_testcancel ();
-
   if (msg->msg_name
       && get_inet_addr ((struct sockaddr *) msg->msg_name, msg->msg_namelen,
                        &sst, &len) == SOCKET_ERROR)
@@ -1762,15 +1826,15 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags)
       wsaptr->len = iovptr->iov_len;
       (wsaptr++)->buf = (char *) (iovptr++)->iov_base;
     }
+  /* Disappointing but true:  Even if WSASendMsg is supported, it's only
+     supported for datagram and raw sockets. */
+  DWORD controllen = (DWORD) (!wincap.has_sendmsg ()
+                             || get_socket_type () == SOCK_STREAM
+                             || get_addr_family () == AF_LOCAL
+                             ? 0 : msg->msg_controllen);
   WSAMSG wsamsg = { msg->msg_name ? (struct sockaddr *) &sst : NULL, len,
-                   wsabuf, msg->msg_iovlen,
-                   /* Disappointing but true:  Even if WSASendMsg is
-                      supported, it's only supported for datagram and
-                      raw sockets. */
-                   { !wincap.has_sendmsg ()
-                     || get_socket_type () == SOCK_STREAM
-                     || get_addr_family () == AF_LOCAL
-                     ? 0 : msg->msg_controllen, (char *) msg->msg_control },
+                   wsabuf, (DWORD) msg->msg_iovlen,
+                   { controllen, (char *) msg->msg_control },
                    0 };
   return send_internal (&wsamsg, flags);
 }
@@ -1818,20 +1882,7 @@ int
 fhandler_socket::close ()
 {
   int res = 0;
-  /* TODO: CV - 2008-04-16.  Lingering disabled.  The original problem
-     could be no longer reproduced on NT4, XP, 2K8.  Any return of a
-     spurious "Connection reset by peer" *could* be caused by disabling
-     the linger code here... */
-#if 0
-  /* HACK to allow a graceful shutdown even if shutdown() hasn't been
-     called by the application. Note that this isn't the ultimate
-     solution but it helps in many cases. */
-  struct linger linger;
-  linger.l_onoff = 1;
-  linger.l_linger = 240; /* secs. default 2MSL value according to MSDN. */
-  setsockopt (get_socket (), SOL_SOCKET, SO_LINGER,
-             (const char *)&linger, sizeof linger);
-#endif
+
   release_events ();
   while ((res = closesocket (get_socket ())) != 0)
     {
@@ -2040,7 +2091,17 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
        WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK);
       break;
     case FIONREAD:
-      res = ioctlsocket (get_socket (), FIONREAD, (unsigned long *) p);
+#ifdef __x86_64__
+/* FIXME: This looks broken in the Mingw64 headers.  If I make sure
+to use the Windows u_long definition, I'd expect that it's defined
+as a 4 byte type on LP64 as well.  But that's not the case right now.
+The *additional* type __ms_u_long is available on LP64, and that's
+used in subsequent function declarations, but that's not available
+on 32 bit or LLP64.  The LP64-ness shouldn't require to use another
+type name in the application code. */
+#define u_long __ms_u_long
+#endif
+      res = ioctlsocket (get_socket (), FIONREAD, (u_long *) p);
       if (res == SOCKET_ERROR)
        set_winsock_errno ();
       break;
@@ -2055,15 +2116,15 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
          res = 0;
        }
       else
-       res = ioctlsocket (get_socket (), cmd, (unsigned long *) p);
+       res = ioctlsocket (get_socket (), cmd, (u_long *) p);
       break;
     }
-  syscall_printf ("%d = ioctl_socket(%x, %x)", res, cmd, p);
+  syscall_printf ("%d = ioctl_socket(%x, %p)", res, cmd, p);
   return res;
 }
 
 int
-fhandler_socket::fcntl (int cmd, void *arg)
+fhandler_socket::fcntl (int cmd, intptr_t arg)
 {
   int res = 0;
   int request, current;
@@ -2087,7 +2148,7 @@ fhandler_socket::fcntl (int cmd, void *arg)
        /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
           Set only the flag that has been passed in.  If both are set, just
           record O_NONBLOCK.   */
-       int new_flags = (int) arg & O_NONBLOCK_MASK;
+       int new_flags = arg & O_NONBLOCK_MASK;
        if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
          new_flags = O_NONBLOCK;
        current = get_flags () & O_NONBLOCK_MASK;
@@ -2131,7 +2192,7 @@ fhandler_socket::set_peer_sun_path (const char *path)
 }
 
 int
-fhandler_socket::getpeereid (pid_t *pid, __uid32_t *euid, __gid32_t *egid)
+fhandler_socket::getpeereid (pid_t *pid, uid_t *euid, gid_t *egid)
 {
   if (get_addr_family () != AF_LOCAL || get_socket_type () != SOCK_STREAM)
     {
index 41bb118e972ba272d5ad4e7ae897fc4764c5d930..14891a2e8cfcfc954ef2602a89bbc42c6f038cff 100644 (file)
@@ -53,7 +53,7 @@ details. */
 /* mtinfo_part */
 
 void
-mtinfo_part::initialize (long nblock)
+mtinfo_part::initialize (int32_t nblock)
 {
   block = nblock;
   if (block == 0)
@@ -182,7 +182,7 @@ mtinfo_drive::close (HANDLE mt, bool rewind)
 }
 
 int
-mtinfo_drive::read (HANDLE mt, HANDLE mt_evt, void *ptr, size_t &ulen)
+mtinfo_drive::read (HANDLE mt, LPOVERLAPPED pov, void *ptr, size_t &ulen)
 {
   BOOL ret;
   DWORD bytes_read = 0;
@@ -231,17 +231,17 @@ mtinfo_drive::read (HANDLE mt, HANDLE mt_evt, void *ptr, size_t &ulen)
   part (partition)->smark = false;
   if (auto_lock () && lock < auto_locked)
     prepare (mt, TAPE_LOCK, true);
-  ov.Offset = ov.OffsetHigh = 0;
-  ov.hEvent = mt_evt;
-  ret = ReadFile (mt, ptr, ulen, &bytes_read, &ov);
+  ov = pov;
+  ov->Offset = ov->OffsetHigh = 0;
+  ret = ReadFile (mt, ptr, ulen, &bytes_read, ov);
   lasterr = ret ? 0 : GetLastError ();
   if (lasterr == ERROR_IO_PENDING)
     lasterr = async_wait (mt, &bytes_read);
   ulen = (size_t) bytes_read;
   if (bytes_read > 0)
     {
-      long blocks_read = mp ()->BlockSize == 0
-                        ? 1 : howmany (bytes_read, mp ()->BlockSize);
+      int32_t blocks_read = mp ()->BlockSize == 0
+                           ? 1 : howmany (bytes_read, mp ()->BlockSize);
       block += blocks_read;
       part (partition)->block += blocks_read;
       if (part (partition)->fblock >= 0)
@@ -287,14 +287,14 @@ mtinfo_drive::async_wait (HANDLE mt, DWORD *bytes_written)
 {
   DWORD written;
 
-  bool ret = GetOverlappedResult (mt, &ov, &written, TRUE);
+  bool ret = GetOverlappedResult (mt, ov, &written, TRUE);
   if (bytes_written)
     *bytes_written = written;
   return ret ? 0 : GetLastError ();
 }
 
 int
-mtinfo_drive::write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len)
+mtinfo_drive::write (HANDLE mt, LPOVERLAPPED pov, const void *ptr, size_t &len)
 {
   BOOL ret;
   DWORD bytes_written = 0;
@@ -313,9 +313,9 @@ mtinfo_drive::write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len)
   part (partition)->smark = false;
   if (auto_lock () && lock < auto_locked)
     prepare (mt, TAPE_LOCK, true);
-  ov.Offset = ov.OffsetHigh = 0;
-  ov.hEvent = mt_evt;
-  ret = WriteFile (mt, ptr, len, &bytes_written, &ov);
+  ov = pov;
+  ov->Offset = ov->OffsetHigh = 0;
+  ret = WriteFile (mt, ptr, len, &bytes_written, ov);
   lasterr = ret ? 0: GetLastError ();
   if (lasterr == ERROR_IO_PENDING)
     {
@@ -328,8 +328,8 @@ mtinfo_drive::write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len)
   len = (size_t) bytes_written;
   if (bytes_written > 0)
     {
-      long blocks_written = mp ()->BlockSize == 0
-                        ? 1 : howmany (bytes_written, mp ()->BlockSize);
+      int32_t blocks_written = mp ()->BlockSize == 0
+                              ? 1 : howmany (bytes_written, mp ()->BlockSize);
       block += blocks_written;
       part (partition)->block += blocks_written;
       if (part (partition)->fblock >= 0)
@@ -353,7 +353,7 @@ mtinfo_drive::write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len)
 }
 
 int
-mtinfo_drive::get_pos (HANDLE mt, long *ppartition, long *pblock)
+mtinfo_drive::get_pos (HANDLE mt, int32_t *ppartition, int32_t *pblock)
 {
   DWORD p, low, high;
 
@@ -363,8 +363,8 @@ mtinfo_drive::get_pos (HANDLE mt, long *ppartition, long *pblock)
   if (!lasterr)
     {
       if (p > 0)
-       partition = (long) p - 1;
-      block = (long) low;
+       partition = (int32_t) p - 1;
+      block = (int32_t) low;
       if (ppartition)
        *ppartition= partition;
       if (pblock)
@@ -379,7 +379,7 @@ mtinfo_drive::get_pos (HANDLE mt, long *ppartition, long *pblock)
 }
 
 int
-mtinfo_drive::_set_pos (HANDLE mt, int mode, long count, int partition,
+mtinfo_drive::_set_pos (HANDLE mt, int mode, int32_t count, int partition,
                        BOOL dont_wait)
 {
   /* If an async write is still pending, wait for completion. */
@@ -392,11 +392,11 @@ mtinfo_drive::_set_pos (HANDLE mt, int mode, long count, int partition,
 }
 
 int
-mtinfo_drive::set_pos (HANDLE mt, int mode, long count,
+mtinfo_drive::set_pos (HANDLE mt, int mode, int32_t count,
                       bool sfm_func)
 {
   int err = 0;
-  long undone = count;
+  int32_t undone = count;
   BOOL dont_wait = FALSE;
 
   switch (mode)
@@ -547,7 +547,7 @@ out:
 }
 
 int
-mtinfo_drive::create_partitions (HANDLE mt, long count)
+mtinfo_drive::create_partitions (HANDLE mt, int32_t count)
 {
   if (dp ()->MaximumPartitionCount <= 1)
     return ERROR_INVALID_PARAMETER;
@@ -578,9 +578,9 @@ out:
 }
 
 int
-mtinfo_drive::set_partition (HANDLE mt, long count)
+mtinfo_drive::set_partition (HANDLE mt, int32_t count)
 {
-  if (count < 0 || (unsigned long) count >= MAX_PARTITION_NUM)
+  if (count < 0 || (uint32_t) count >= MAX_PARTITION_NUM)
     lasterr = ERROR_INVALID_PARAMETER;
   else if ((DWORD) count >= dp ()->MaximumPartitionCount)
     lasterr = ERROR_IO_DEVICE;
@@ -715,14 +715,14 @@ mtinfo_drive::prepare (HANDLE mt, int action, bool is_auto)
 }
 
 int
-mtinfo_drive::set_compression (HANDLE mt, long count)
+mtinfo_drive::set_compression (HANDLE mt, int32_t count)
 {
   if (!get_feature (TAPE_DRIVE_SET_COMPRESSION))
     return ERROR_INVALID_PARAMETER;
   TAPE_SET_DRIVE_PARAMETERS sdp =
     {
       dp ()->ECC,
-      count ? TRUE : FALSE,
+      (BOOLEAN) (count ? TRUE : FALSE),
       dp ()->DataPadding,
       dp ()->ReportSetmarks,
       dp ()->EOTWarningZoneSize
@@ -738,7 +738,7 @@ mtinfo_drive::set_compression (HANDLE mt, long count)
 }
 
 int
-mtinfo_drive::set_blocksize (HANDLE mt, long count)
+mtinfo_drive::set_blocksize (HANDLE mt, DWORD count)
 {
   TAPE_SET_MEDIA_PARAMETERS smp = {count};
   TAPE_FUNC (SetTapeParameters (mt, SET_TAPE_MEDIA_INFORMATION, &smp));
@@ -768,32 +768,29 @@ mtinfo_drive::get_status (HANDLE mt, struct mtget *get)
     get->mt_dsreg = (dp ()->DefaultBlockSize << MT_ST_BLKSIZE_SHIFT)
                    & MT_ST_BLKSIZE_MASK;
 
-  if (wincap.has_ioctl_storage_get_media_types_ex ())
+  DWORD size = sizeof (GET_MEDIA_TYPES) + 10 * sizeof (DEVICE_MEDIA_INFO);
+  void *buf = alloca (size);
+  if (DeviceIoControl (mt, IOCTL_STORAGE_GET_MEDIA_TYPES_EX,
+                      NULL, 0, buf, size, &size, NULL)
+      || GetLastError () == ERROR_MORE_DATA)
     {
-      DWORD size = sizeof (GET_MEDIA_TYPES) + 10 * sizeof (DEVICE_MEDIA_INFO);
-      void *buf = alloca (size);
-      if (DeviceIoControl (mt, IOCTL_STORAGE_GET_MEDIA_TYPES_EX,
-                          NULL, 0, buf, size, &size, NULL)
-         || GetLastError () == ERROR_MORE_DATA)
+      PGET_MEDIA_TYPES gmt = (PGET_MEDIA_TYPES) buf;
+      for (DWORD i = 0; i < gmt->MediaInfoCount; ++i)
        {
-         PGET_MEDIA_TYPES gmt = (PGET_MEDIA_TYPES) buf;
-         for (DWORD i = 0; i < gmt->MediaInfoCount; ++i)
+         PDEVICE_MEDIA_INFO dmi = &gmt->MediaInfo[i];
+         get->mt_type = dmi->DeviceSpecific.TapeInfo.MediaType;
+#define TINFO DeviceSpecific.TapeInfo
+         if (dmi->TINFO.MediaCharacteristics & MEDIA_CURRENTLY_MOUNTED)
            {
-             PDEVICE_MEDIA_INFO dmi = &gmt->MediaInfo[i];
              get->mt_type = dmi->DeviceSpecific.TapeInfo.MediaType;
-#define TINFO DeviceSpecific.TapeInfo
-             if (dmi->TINFO.MediaCharacteristics & MEDIA_CURRENTLY_MOUNTED)
-               {
-                 get->mt_type = dmi->DeviceSpecific.TapeInfo.MediaType;
-                 if (dmi->TINFO.BusType == BusTypeScsi)
-                   get->mt_dsreg |=
-                     (dmi->TINFO.BusSpecificData.ScsiInformation.DensityCode
-                      << MT_ST_DENSITY_SHIFT)
-                     & MT_ST_DENSITY_MASK;
-                 break;
-               }
-#undef TINFO
+             if (dmi->TINFO.BusType == BusTypeScsi)
+               get->mt_dsreg |=
+                 (dmi->TINFO.BusSpecificData.ScsiInformation.DensityCode
+                  << MT_ST_DENSITY_SHIFT)
+                 & MT_ST_DENSITY_MASK;
+             break;
            }
+#undef TINFO
        }
     }
 
@@ -870,9 +867,9 @@ mtinfo_drive::get_status (HANDLE mt, struct mtget *get)
 }
 
 int
-mtinfo_drive::set_options (HANDLE mt, long options)
+mtinfo_drive::set_options (HANDLE mt, int32_t options)
 {
-  long what = (options & MT_ST_OPTIONS);
+  int32_t what = (options & MT_ST_OPTIONS);
   bool call_setparams = false;
   bool set;
   TAPE_SET_DRIVE_PARAMETERS sdp =
@@ -1234,8 +1231,8 @@ fhandler_dev_tape::close ()
       cret = fhandler_dev_raw::close ();
       unlock (0);
     }
-  if (mt_evt)
-    CloseHandle (mt_evt);
+  if (ov.hEvent)
+    CloseHandle (ov.hEvent);
   CloseHandle (mt_mtx);
   return ret ? -1 : cret;
 }
@@ -1267,7 +1264,7 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
       if (devbufend > devbufstart)
        {
          bytes_to_read = MIN (len, devbufend - devbufstart);
-         debug_printf ("read %d bytes from buffer (rest %d)",
+         debug_printf ("read %lu bytes from buffer (rest %lu)",
                        bytes_to_read, devbufend - devbufstart - bytes_to_read);
          memcpy (buf, devbuf + devbufstart, bytes_to_read);
          len -= bytes_to_read;
@@ -1284,15 +1281,16 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
        }
       if (len > 0)
        {
-         if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
+         if (!ov.hEvent
+             && !(ov.hEvent = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
            debug_printf ("Creating event failed, %E");
          size_t block_fit = !block_size ? len : rounddown(len,  block_size);
          if (block_fit)
            {
-             debug_printf ("read %d bytes from tape (rest %d)",
+             debug_printf ("read %lu bytes from tape (rest %lu)",
                            block_fit, len - block_fit);
-             ret = mt.drive (driveno ())->read (get_handle (), mt_evt, buf,
-                                                 block_fit);
+             ret = mt.drive (driveno ())->read (get_handle (), &ov, buf,
+                                                block_fit);
              if (ret)
                __seterrno_from_win_error (ret);
              else if (block_fit)
@@ -1312,9 +1310,9 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
            }
          if (!ret && len > 0)
            {
-             debug_printf ("read %d bytes from tape (one block)", block_size);
-             ret = mt.drive (driveno ())->read (get_handle (), mt_evt, devbuf,
-                                                 block_size);
+             debug_printf ("read %lu bytes from tape (one block)", block_size);
+             ret = mt.drive (driveno ())->read (get_handle (), &ov, devbuf,
+                                                block_size);
              if (ret)
                __seterrno_from_win_error (ret);
              else if (block_size)
@@ -1331,11 +1329,11 @@ fhandler_dev_tape::raw_read (void *ptr, size_t &ulen)
     }
   else
     {
-      if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
+      if (!ov.hEvent
+         && !(ov.hEvent = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
        debug_printf ("Creating event failed, %E");
       bytes_read = ulen;
-      ret = mt.drive (driveno ())->read (get_handle (), mt_evt, ptr,
-                                         bytes_read);
+      ret = mt.drive (driveno ())->read (get_handle (), &ov, ptr, bytes_read);
     }
   ulen = (ret ? (size_t) -1 : bytes_read);
   unlock ();
@@ -1346,25 +1344,25 @@ fhandler_dev_tape::raw_write (const void *ptr, size_t len)
 {
   if (!_lock (true))
     return -1;
-  if (!mt_evt && !(mt_evt = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
+  if (!ov.hEvent && !(ov.hEvent = CreateEvent (&sec_none, TRUE, FALSE, NULL)))
     debug_printf ("Creating event failed, %E");
-  int ret = mt.drive (driveno ())->write (get_handle (), mt_evt, ptr, len);
+  int ret = mt.drive (driveno ())->write (get_handle (), &ov, ptr, len);
   if (ret)
     __seterrno_from_win_error (ret);
   return unlock (ret ? -1 : (int) len);
 }
 
-_off64_t
-fhandler_dev_tape::lseek (_off64_t offset, int whence)
+off_t
+fhandler_dev_tape::lseek (off_t offset, int whence)
 {
   struct mtop op;
   struct mtpos pos;
   DWORD block_size;
-  _off64_t ret = ILLEGAL_SEEK;
+  off_t ret = ILLEGAL_SEEK;
 
   lock (ILLEGAL_SEEK);
 
-  debug_printf ("lseek (%s, %d, %d)", get_name (), offset, whence);
+  debug_printf ("lseek (%s, %D, %d)", get_name (), offset, whence);
 
   block_size = mt.drive (driveno ())->mp ()->BlockSize;
   if (block_size == 0)
@@ -1418,7 +1416,7 @@ out:
 }
 
 int __reg2
-fhandler_dev_tape::fstat (struct __stat64 *buf)
+fhandler_dev_tape::fstat (struct stat *buf)
 {
   int ret;
 
@@ -1441,19 +1439,19 @@ fhandler_dev_tape::dup (fhandler_base *child, int flags)
                        GetCurrentProcess (), &fh->mt_mtx,
                        0, TRUE, DUPLICATE_SAME_ACCESS))
     {
-      debug_printf ("dup(%s) failed, mutex handle %x, %E",
+      debug_printf ("dup(%s) failed, mutex handle %p, %E",
                    get_name (), mt_mtx);
       __seterrno ();
       return unlock (-1);
     }
-  fh->mt_evt = NULL;
-  if (mt_evt &&
-      !DuplicateHandle (GetCurrentProcess (), mt_evt,
-                       GetCurrentProcess (), &fh->mt_evt,
+  fh->ov.hEvent = NULL;
+  if (ov.hEvent &&
+      !DuplicateHandle (GetCurrentProcess (), ov.hEvent,
+                       GetCurrentProcess (), &fh->ov.hEvent,
                        0, TRUE, DUPLICATE_SAME_ACCESS))
     {
-      debug_printf ("dup(%s) failed, event handle %x, %E",
-                   get_name (), mt_evt);
+      debug_printf ("dup(%s) failed, event handle %p, %E",
+                   get_name (), ov.hEvent);
       __seterrno ();
       return unlock (-1);
     }
@@ -1465,8 +1463,8 @@ fhandler_dev_tape::fixup_after_fork (HANDLE parent)
 {
   fhandler_dev_raw::fixup_after_fork (parent);
   fork_fixup (parent, mt_mtx, "mt_mtx");
-  if (mt_evt)
-    fork_fixup (parent, mt_evt, "mt_evt");
+  if (ov.hEvent)
+    fork_fixup (parent, ov.hEvent, "ov.hEvent");
 }
 
 void
@@ -1474,8 +1472,8 @@ fhandler_dev_tape::set_close_on_exec (bool val)
 {
   fhandler_dev_raw::set_close_on_exec (val);
   set_no_inheritance (mt_mtx, val);
-  if (mt_evt)
-    set_no_inheritance (mt_evt, val);
+  if (ov.hEvent)
+    set_no_inheritance (ov.hEvent, val);
 }
 
 int
index 1383d5e37c5f9e0df658b527f3ce069bc2218051..fdf75891804fae96eb0b403320f3311e93cc71fd 100644 (file)
@@ -306,6 +306,7 @@ fhandler_termios::line_edit (const char *rptr, int nread, termios& ti)
          else
            set_input_done (iscanon);
        }
+
       if (iscanon && ti.c_lflag & IEXTEN && CCEQ (ti.c_cc[VDISCARD], c))
        {
          ti.c_lflag ^= FLUSHO;
@@ -392,8 +393,8 @@ fhandler_termios::line_edit (const char *rptr, int nread, termios& ti)
   return ret;
 }
 
-_off64_t
-fhandler_termios::lseek (_off64_t, int)
+off_t
+fhandler_termios::lseek (off_t, int)
 {
   set_errno (ESPIPE);
   return -1;
@@ -426,7 +427,7 @@ fhandler_termios::ioctl (int cmd, void *varg)
   if (cmd != TIOCSCTTY)
     return 1;          /* Not handled by this function */
 
-  int arg = (int) varg;
+  int arg = (int) (intptr_t) varg;
 
   if (arg != 0 && arg != 1)
     {
index e3470794438fab8a48a413ebaf8b77a6057a323c..f213fe6ae2ae5c35fe70315403b825c0cee3f04b 100644 (file)
@@ -45,12 +45,6 @@ struct pipe_reply {
   DWORD error;
 };
 
-int
-fhandler_pty_slave::get_unit ()
-{
-  return dev ().get_minor ();
-}
-
 bool
 bytes_available (DWORD& n, HANDLE h)
 {
@@ -176,7 +170,7 @@ fhandler_pty_master::accept_input ()
       DWORD rc;
       DWORD written = 0;
 
-      paranoid_printf ("about to write %d chars to slave", bytes_left);
+      paranoid_printf ("about to write %u chars to slave", bytes_left);
       rc = WriteFile (get_output_handle (), p, bytes_left, &written, NULL);
       if (!rc)
        {
@@ -352,7 +346,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
              if (optr - buf >= (int) len)
                {
                  if (*iptr != '\n' || n != 0)
-                   system_printf ("internal error: %d unexpected characters", n);
+                   system_printf ("internal error: %u unexpected characters", n);
                  need_nl = 1;
                  break;
                }
@@ -402,11 +396,11 @@ fhandler_pty_slave::open (int flags, mode_t)
   for (HANDLE **h = handles; *h; h++)
     **h = NULL;
 
-  _tc = cygwin_shared->tty[get_unit ()];
+  _tc = cygwin_shared->tty[get_minor ()];
 
   tcinit (false);
 
-  cygwin_shared->tty.attach (get_unit ());
+  cygwin_shared->tty.attach (get_minor ());
 
   /* Create synchronisation events */
   char buf[MAX_PATH];
@@ -423,7 +417,7 @@ fhandler_pty_slave::open (int flags, mode_t)
       errmsg = "open input mutex failed, %E";
       goto err;
     }
-  shared_name (buf, INPUT_AVAILABLE_EVENT, get_unit ());
+  shared_name (buf, INPUT_AVAILABLE_EVENT, get_minor ());
   if (!(input_available_event = OpenEvent (MAXIMUM_ALLOWED, TRUE, buf)))
     {
       errmsg = "open input event failed, %E";
@@ -447,7 +441,7 @@ fhandler_pty_slave::open (int flags, mode_t)
     release_output_mutex ();
   }
 
-  if (!get_ttyp ()->from_master || !get_ttyp ()->to_master)
+  if (!get_ttyp ()->from_master () || !get_ttyp ()->to_master ())
     {
       errmsg = "pty handles have been closed";
       set_errno (EACCES);
@@ -488,16 +482,16 @@ fhandler_pty_slave::open (int flags, mode_t)
     }
   if (pty_owner)
     {
-      if (!DuplicateHandle (pty_owner, get_ttyp ()->from_master,
+      if (!DuplicateHandle (pty_owner, get_ttyp ()->from_master (),
                            GetCurrentProcess (), &from_master_local, 0, TRUE,
                            DUPLICATE_SAME_ACCESS))
        {
          termios_printf ("can't duplicate input from %u/%p, %E",
-                         get_ttyp ()->master_pid, get_ttyp ()->from_master);
+                         get_ttyp ()->master_pid, get_ttyp ()->from_master ());
          __seterrno ();
          goto err_no_msg;
        }
-      if (!DuplicateHandle (pty_owner, get_ttyp ()->to_master,
+      if (!DuplicateHandle (pty_owner, get_ttyp ()->to_master (),
                          GetCurrentProcess (), &to_master_local, 0, TRUE,
                          DUPLICATE_SAME_ACCESS))
        {
@@ -514,7 +508,7 @@ fhandler_pty_slave::open (int flags, mode_t)
       DWORD len;
 
       __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
-                      &cygheap->installation_key, get_unit ());
+                      &cygheap->installation_key, get_minor ());
       termios_printf ("dup handles via master control pipe %s", buf);
       if (!CallNamedPipe (buf, &req, sizeof req, &repl, sizeof repl,
                          &len, 500))
@@ -535,9 +529,9 @@ fhandler_pty_slave::open (int flags, mode_t)
   VerifyHandle (to_master_local);
 
   termios_printf ("duplicated from_master %p->%p from pty_owner",
-                 get_ttyp ()->from_master, from_master_local);
+                 get_ttyp ()->from_master (), from_master_local);
   termios_printf ("duplicated to_master %p->%p from pty_owner",
-                 get_ttyp ()->to_master, to_master_local);
+                 get_ttyp ()->to_master (), to_master_local);
 
   set_io_handle (from_master_local);
   set_output_handle (to_master_local);
@@ -587,7 +581,7 @@ fhandler_pty_slave::close ()
     termios_printf ("CloseHandle (inuse), %E");
   if (!ForceCloseHandle (input_available_event))
     termios_printf ("CloseHandle (input_available_event<%p>), %E", input_available_event);
-  if ((unsigned) myself->ctty == FHDEV (DEV_PTYS_MAJOR, get_unit ()))
+  if ((unsigned) myself->ctty == FHDEV (DEV_PTYS_MAJOR, get_minor ()))
     fhandler_console::free_console (); /* assumes that we are the last pty closer */
   return fhandler_pty_common::close ();
 }
@@ -635,13 +629,14 @@ fhandler_pty_slave::init (HANDLE h, DWORD a, mode_t)
 ssize_t __stdcall
 fhandler_pty_slave::write (const void *ptr, size_t len)
 {
-  DWORD n, towrite = len;
+  DWORD n;
+  ssize_t towrite = len;
 
   bg_check_types bg = bg_check (SIGTTOU);
   if (bg <= bg_eof)
     return (ssize_t) bg;
 
-  termios_printf ("pty%d, write(%x, %d)", get_unit (), ptr, len);
+  termios_printf ("pty%d, write(%p, %lu)", get_minor (), ptr, len);
 
   push_process_state process_state (PID_TTYOU);
 
@@ -662,7 +657,7 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
       if (get_ttyp ()->write_error)
        {
          set_errno (get_ttyp ()->write_error);
-         towrite = (DWORD) -1;
+         towrite = -1;
          get_ttyp ()->write_error = 0;
          release_output_mutex ();
          break;
@@ -682,7 +677,7 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
              __seterrno_from_win_error (err);
            }
          raise (SIGHUP);               /* FIXME: Should this be SIGTTOU? */
-         towrite = (DWORD) -1;
+         towrite = -1;
          break;
        }
     }
@@ -692,7 +687,7 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
 void __stdcall
 fhandler_pty_slave::read (void *ptr, size_t& len)
 {
-  int totalread = 0;
+  ssize_t totalread = 0;
   int vmin = 0;
   int vtime = 0;       /* Initialized to prevent -Wuninitialized warning */
   size_t readlen;
@@ -707,7 +702,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
       return;
     }
 
-  termios_printf ("read(%x, %d) handle %p", ptr, len, get_handle ());
+  termios_printf ("read(%p, %lu) handle %p", ptr, len, get_handle ());
 
   push_process_state process_state (PID_TTYIN);
 
@@ -836,7 +831,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
       DWORD n = 0;
       if (readlen)
        {
-         termios_printf ("reading %d bytes (vtime %d)", readlen, vtime);
+         termios_printf ("reading %lu bytes (vtime %d)", readlen, vtime);
          if (!ReadFile (get_handle (), buf, readlen, &n, NULL))
            {
              termios_printf ("read failed, %E");
@@ -912,7 +907,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
        break;
     }
 out:
-  termios_printf ("%d=read(%x, %d)", totalread, ptr, len);
+  termios_printf ("%d=read(%p, %lu)", totalread, ptr, len);
   len = (size_t) totalread;
 }
 
@@ -987,7 +982,7 @@ fhandler_pty_slave::ioctl (unsigned int cmd, void *arg)
     return res;
 
   if (myself->pgid && get_ttyp ()->getpgid () != myself->pgid
-      && (unsigned) myself->ctty == FHDEV (DEV_PTYS_MAJOR, get_unit ())
+      && (unsigned) myself->ctty == FHDEV (DEV_PTYS_MAJOR, get_minor ())
       && (get_ttyp ()->ti.c_lflag & TOSTOP))
     {
       /* background process */
@@ -1015,7 +1010,7 @@ fhandler_pty_slave::ioctl (unsigned int cmd, void *arg)
       }
       goto out;
     case TIOCSPGRP:
-      retval = this->tcsetpgrp ((pid_t) arg);
+      retval = this->tcsetpgrp ((pid_t) (intptr_t) arg);
       goto out;
     case FIONREAD:
       {
@@ -1072,7 +1067,7 @@ out:
 }
 
 int __reg2
-fhandler_pty_slave::fstat (struct __stat64 *st)
+fhandler_pty_slave::fstat (struct stat *st)
 {
   fhandler_base::fstat (st);
 
@@ -1080,7 +1075,7 @@ fhandler_pty_slave::fstat (struct __stat64 *st)
   if (!input_available_event)
     {
       char buf[MAX_PATH];
-      shared_name (buf, INPUT_AVAILABLE_EVENT, get_unit ());
+      shared_name (buf, INPUT_AVAILABLE_EVENT, get_minor ());
       input_available_event = OpenEvent (READ_CONTROL, TRUE, buf);
       if (input_available_event)
        to_close = true;
@@ -1107,8 +1102,8 @@ fhandler_pty_slave::fch_open_handles ()
 {
   char buf[MAX_PATH];
 
-  _tc = cygwin_shared->tty[get_unit ()];
-  shared_name (buf, INPUT_AVAILABLE_EVENT, get_unit ());
+  _tc = cygwin_shared->tty[get_minor ()];
+  shared_name (buf, INPUT_AVAILABLE_EVENT, get_minor ());
   input_available_event = OpenEvent (READ_CONTROL | WRITE_DAC | WRITE_OWNER,
                                     TRUE, buf);
   output_mutex = get_ttyp ()->open_output_mutex (WRITE_DAC | WRITE_OWNER);
@@ -1161,8 +1156,8 @@ fhandler_pty_slave::fchmod (mode_t mode)
   int ret = -1;
   bool to_close = false;
   security_descriptor sd;
-  __uid32_t uid;
-  __gid32_t gid;
+  uid_t uid;
+  gid_t gid;
 
   if (!input_available_event)
     {
@@ -1182,13 +1177,13 @@ errout:
 }
 
 int __stdcall
-fhandler_pty_slave::fchown (__uid32_t uid, __gid32_t gid)
+fhandler_pty_slave::fchown (uid_t uid, gid_t gid)
 {
   int ret = -1;
   bool to_close = false;
   mode_t mode = 0;
-  __uid32_t o_uid;
-  __gid32_t o_gid;
+  uid_t o_uid;
+  gid_t o_gid;
   security_descriptor sd;
 
   if (uid == ILLEGAL_UID && gid == ILLEGAL_GID)
@@ -1247,12 +1242,12 @@ fhandler_pty_master::open_setup (int flags)
 {
   set_flags ((flags & ~O_TEXT) | O_BINARY);
   char buf[sizeof ("opened pty master for ptyNNNNNNNNNNN")];
-  __small_sprintf (buf, "opened pty master for pty%d", get_unit ());
+  __small_sprintf (buf, "opened pty master for pty%d", get_minor ());
   report_tty_counts (this, buf, "");
 }
 
-_off64_t
-fhandler_pty_common::lseek (_off64_t, int)
+off_t
+fhandler_pty_common::lseek (off_t, int)
 {
   set_errno (ESPIPE);
   return -1;
@@ -1261,7 +1256,7 @@ fhandler_pty_common::lseek (_off64_t, int)
 int
 fhandler_pty_common::close ()
 {
-  termios_printf ("pty%d <%p,%p> closing", get_unit (), get_handle (), get_output_handle ());
+  termios_printf ("pty%d <%p,%p> closing", get_minor (), get_handle (), get_output_handle ());
   if (!ForceCloseHandle (input_mutex))
     termios_printf ("CloseHandle (input_mutex<%p>), %E", input_mutex);
   if (!ForceCloseHandle (output_mutex))
@@ -1285,7 +1280,7 @@ fhandler_pty_master::cleanup ()
 int
 fhandler_pty_master::close ()
 {
-  termios_printf ("closing from_master(%p)/to_master(%p) since we own them(%d)",
+  termios_printf ("closing from_master(%p)/to_master(%p) since we own them(%u)",
                  from_master, to_master, dwProcessId);
   if (cygwin_finished_initializing)
     {
@@ -1297,7 +1292,7 @@ fhandler_pty_master::close ()
          DWORD len;
 
          __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
-                          &cygheap->installation_key, get_unit ());
+                          &cygheap->installation_key, get_minor ());
          CallNamedPipe (buf, &req, sizeof req, &repl, sizeof repl, &len, 500);
          CloseHandle (master_ctl);
          master_thread->detach ();
@@ -1376,14 +1371,14 @@ fhandler_pty_master::read (void *ptr, size_t& len)
 int
 fhandler_pty_master::tcgetattr (struct termios *t)
 {
-  *t = cygwin_shared->tty[get_unit ()]->ti;
+  *t = cygwin_shared->tty[get_minor ()]->ti;
   return 0;
 }
 
 int
 fhandler_pty_master::tcsetattr (int, const struct termios *t)
 {
-  cygwin_shared->tty[get_unit ()]->ti = *t;
+  cygwin_shared->tty[get_minor ()]->ti = *t;
   return 0;
 }
 
@@ -1432,7 +1427,7 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
       *((pid_t *) arg) = this->tcgetpgrp ();
       break;
     case TIOCSPGRP:
-      return this->tcsetpgrp ((pid_t) arg);
+      return this->tcsetpgrp ((pid_t) (intptr_t) arg);
     case FIONREAD:
       {
        DWORD n;
@@ -1455,7 +1450,7 @@ fhandler_pty_master::ptsname_r (char *buf, size_t buflen)
 {
   char tmpbuf[TTY_NAME_MAX];
 
-  __ptsname (tmpbuf, get_unit ());
+  __ptsname (tmpbuf, get_minor ());
   if (buflen <= strlen (tmpbuf))
     {
       set_errno (ERANGE);
@@ -1556,7 +1551,7 @@ fhandler_pty_master::pty_master_thread ()
                                  &token);
       if (!NT_SUCCESS (status))
        {
-         termios_printf ("NtOpenThreadToken, %p", status);
+         termios_printf ("NtOpenThreadToken, %y", status);
          SetLastError (RtlNtStatusToDosError (status));
          goto reply;
        }
@@ -1566,7 +1561,7 @@ fhandler_pty_master::pty_master_thread ()
       NtClose (token);
       if (!NT_SUCCESS (status))
        {
-         termios_printf ("NtAccessCheck, %p", status);
+         termios_printf ("NtAccessCheck, %y", status);
          SetLastError (RtlNtStatusToDosError (status));
          goto reply;
        }
@@ -1614,7 +1609,7 @@ reply:
       if (deimp)
        cygheap->user.reimpersonate ();
       sd.free ();
-      termios_printf ("Reply: from %p, to %p, error %lu",
+      termios_printf ("Reply: from %p, to %p, error %u",
                      repl.from_master, repl.to_master, repl.error );
       if (!WriteFile (master_ctl, &repl, sizeof repl, &len, NULL))
        termios_printf ("WriteFile, %E");
@@ -1699,10 +1694,13 @@ fhandler_pty_master::setup ()
      the pty pipe handles to processes which deserve it. */
   __small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
                   &cygheap->installation_key, unit);
-  master_ctl = CreateNamedPipe (buf, PIPE_ACCESS_DUPLEX,
+  master_ctl = CreateNamedPipe (buf, PIPE_ACCESS_DUPLEX
+                                    | FILE_FLAG_FIRST_PIPE_INSTANCE,
                                PIPE_WAIT | PIPE_TYPE_MESSAGE
-                               | PIPE_READMODE_MESSAGE, 1, 4096, 4096,
-                               0, &sec_all_nih);
+                               | PIPE_READMODE_MESSAGE
+                               | (wincap.has_pipe_reject_remote_clients ()
+                                  ? PIPE_REJECT_REMOTE_CLIENTS : 0),
+                               1, 4096, 4096, 0, &sec_all_nih);
   if (master_ctl == INVALID_HANDLE_VALUE)
     {
       errstr = "pty master control pipe";
@@ -1715,8 +1713,8 @@ fhandler_pty_master::setup ()
       goto err;
     }
 
-  t.from_master = from_master;
-  t.to_master = to_master;
+  t.set_from_master (from_master);
+  t.set_to_master (to_master);
   t.winsize.ws_col = 80;
   t.winsize.ws_row = 25;
   t.master_pid = myself->pid;
@@ -1751,8 +1749,8 @@ fhandler_pty_master::fixup_after_fork (HANDLE parent)
       tty& t = *get_ttyp ();
       if (myself->pid == t.master_pid)
        {
-         t.from_master = arch->from_master;
-         t.to_master = arch->to_master;
+         t.set_from_master (arch->from_master);
+         t.set_to_master (arch->to_master);
        }
       arch->dwProcessId = wpid;
     }
index 24c517702fef9e093c7f1a1396fc4207317108d2..dce98d4182a7957882eeb00317f759a1637f9e0c 100644 (file)
@@ -126,15 +126,15 @@ fhandler_virtual::closedir (DIR * dir)
   return 0;
 }
 
-_off64_t
-fhandler_virtual::lseek (_off64_t offset, int whence)
+off_t
+fhandler_virtual::lseek (off_t offset, int whence)
 {
   /*
    * On Linux, when you lseek within a /proc file,
    * the contents of the file are updated.
    */
   if (!fill_filebuf ())
-    return (_off64_t) -1;
+    return (off_t) -1;
   switch (whence)
     {
     case SEEK_SET:
@@ -148,7 +148,7 @@ fhandler_virtual::lseek (_off64_t offset, int whence)
       break;
     default:
       set_errno (EINVAL);
-      return (_off64_t) -1;
+      return (off_t) -1;
     }
   return position;
 }
@@ -246,7 +246,7 @@ fhandler_virtual::fchmod (mode_t mode)
 }
 
 int
-fhandler_virtual::fchown (__uid32_t uid, __gid32_t gid)
+fhandler_virtual::fchown (uid_t uid, gid_t gid)
 {
   /* Same as on Linux. */
   set_errno (EPERM);
@@ -254,7 +254,7 @@ fhandler_virtual::fchown (__uid32_t uid, __gid32_t gid)
 }
 
 int
-fhandler_virtual::facl (int cmd, int nentries, __aclent32_t *aclbufp)
+fhandler_virtual::facl (int cmd, int nentries, aclent_t *aclbufp)
 {
   int res = fhandler_base::facl (cmd, nentries, aclbufp);
   if (res >= 0 && cmd == GETACL)
index dff8195eacb4934b295d6c659812fa00e634610e..9747dd2cbbfba07e455040371639ddc4d6331cba 100644 (file)
@@ -13,7 +13,7 @@ struct virt_tab_t {
   size_t name_len;
   fh_devices fhandler;
   virtual_ftype_t type;
-  _off64_t (*format_func)(void *data, char *&);
+  off_t (*format_func)(void *data, char *&);
 };
 
 #define _VN(s) s, sizeof (s) - 1
index 943d8738e4baad4f96faa0980a433f808f91ba6c..e7794f3a160bde7b5386d0f38e353b0b851cbb7e 100644 (file)
@@ -47,8 +47,8 @@ fhandler_dev_zero::read (void *ptr, size_t& len)
   memset (ptr, 0, len);
 }
 
-_off64_t
-fhandler_dev_zero::lseek (_off64_t, int)
+off_t
+fhandler_dev_zero::lseek (off_t, int)
 {
   return 0;
 }
index 0a2ff9ea2fc85665ea09a4a46c363019d1eaeae0..1e875113de049d873b7c94a811c7c78ebc04197d 100644 (file)
@@ -170,7 +170,7 @@ allow_others_to_sync ()
                                  MAX_PROCESS_SD_SIZE, &len);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtQuerySecurityObject: %p", status);
+      debug_printf ("NtQuerySecurityObject: %y", status);
       return;
     }
   /* Create a valid dacl pointer and set its size to be as big as
@@ -197,14 +197,14 @@ allow_others_to_sync ()
                                   well_known_world_sid);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("RtlAddAccessAllowedAce: %p", status);
+      debug_printf ("RtlAddAccessAllowedAce: %y", status);
       return;
     }
   /* Set the size of the DACL correctly. */
   status = RtlFirstFreeAce (dacl, &ace);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("RtlFirstFreeAce: %p", status);
+      debug_printf ("RtlFirstFreeAce: %y", status);
       return;
     }
   dacl->AclSize = (char *) ace - (char *) dacl;
@@ -212,7 +212,7 @@ allow_others_to_sync ()
   status = NtSetSecurityObject (NtCurrentProcess (), DACL_SECURITY_INFORMATION, sd);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtSetSecurityObject: %p", status);
+      debug_printf ("NtSetSecurityObject: %y", status);
       return;
     }
   done = true;
@@ -228,7 +228,7 @@ get_obj_handle_count (HANDLE h)
 
   status = NtQueryObject (h, ObjectBasicInformation, &obi, sizeof obi, NULL);
   if (!NT_SUCCESS (status))
-    debug_printf ("NtQueryObject: %p\n", status);
+    debug_printf ("NtQueryObject: %y", status);
   else
     hdl_cnt = obi.HandleCount;
   return hdl_cnt;
@@ -248,9 +248,9 @@ class lockf_t
   public:
     uint16_t       lf_flags; /* Semantics: F_POSIX, F_FLOCK, F_WAIT */
     uint16_t       lf_type;  /* Lock type: F_RDLCK, F_WRLCK */
-    _off64_t       lf_start; /* Byte # of the start of the lock */
-    _off64_t       lf_end;   /* Byte # of the end of the lock (-1=EOF) */
-    int64_t        lf_id;    /* Cygwin PID for POSIX locks, a unique id per
+    off_t          lf_start; /* Byte # of the start of the lock */
+    off_t          lf_end;   /* Byte # of the end of the lock (-1=EOF) */
+    int64_t         lf_id;    /* Cygwin PID for POSIX locks, a unique id per
                                 file table entry for BSD flock locks. */
     DWORD          lf_wid;   /* Win PID of the resource holding the lock */
     uint16_t       lf_ver;   /* Version number of the lock.  If a released
@@ -268,7 +268,7 @@ class lockf_t
       lf_next (NULL), lf_obj (NULL)
     {}
     lockf_t (class inode_t *node, class lockf_t **head,
-            short flags, short type, _off64_t start, _off64_t end,
+            short flags, short type, off_t start, off_t end,
             long long id, DWORD wid, uint16_t ver)
     : lf_flags (flags), lf_type (type), lf_start (start), lf_end (end),
       lf_id (id), lf_wid (wid), lf_ver (ver), lf_head (head), lf_inode (node),
@@ -308,8 +308,8 @@ class inode_t
     lockf_t            *i_lockf;  /* List of locks of this process. */
     lockf_t            *i_all_lf; /* Temp list of all locks for this file. */
 
-    __dev32_t           i_dev;    /* Device ID */
-    __ino64_t           i_ino;    /* inode number */
+    dev_t               i_dev;    /* Device ID */
+    ino_t               i_ino;    /* inode number */
 
   private:
     HANDLE              i_dir;
@@ -317,7 +317,7 @@ class inode_t
     uint32_t            i_cnt;    /* # of threads referencing this instance. */
 
   public:
-    inode_t (__dev32_t dev, __ino64_t ino);
+    inode_t (dev_t dev, ino_t ino);
     ~inode_t ();
 
     void *operator new (size_t size)
@@ -325,7 +325,7 @@ class inode_t
     void operator delete (void *p)
     { cfree (p); }
 
-    static inode_t *get (__dev32_t dev, __ino64_t ino,
+    static inode_t *get (dev_t dev, ino_t ino,
                         bool create_if_missing, bool lock);
 
     void LOCK () { WaitForSingleObject (i_mtx, INFINITE); }
@@ -482,7 +482,7 @@ fixup_lockf_after_exec ()
    file.  The file is specified by the device and inode_t number.  If inode_t
    doesn't exist, create it. */
 inode_t *
-inode_t::get (__dev32_t dev, __ino64_t ino, bool create_if_missing, bool lock)
+inode_t::get (dev_t dev, ino_t ino, bool create_if_missing, bool lock)
 {
   inode_t *node;
 
@@ -504,7 +504,7 @@ inode_t::get (__dev32_t dev, __ino64_t ino, bool create_if_missing, bool lock)
   return node;
 }
 
-inode_t::inode_t (__dev32_t dev, __ino64_t ino)
+inode_t::inode_t (dev_t dev, ino_t ino)
 : i_lockf (NULL), i_all_lf (NULL), i_dev (dev), i_ino (ino), i_cnt (0L)
 {
   HANDLE parent_dir;
@@ -522,14 +522,14 @@ inode_t::inode_t (__dev32_t dev, __ino64_t ino)
                              parent_dir, everyone_sd (FLOCK_INODE_DIR_ACCESS));
   status = NtCreateDirectoryObject (&i_dir, FLOCK_INODE_DIR_ACCESS, &attr);
   if (!NT_SUCCESS (status))
-    api_fatal ("NtCreateDirectoryObject(inode): %p", status);
+    api_fatal ("NtCreateDirectoryObject(inode): %y", status);
   /* Create a mutex object in the file specific dir, which is used for
      access synchronization on the dir and its objects. */
   InitializeObjectAttributes (&attr, &ro_u_mtx, OBJ_INHERIT | OBJ_OPENIF, i_dir,
                              everyone_sd (CYG_MUTANT_ACCESS));
   status = NtCreateMutant (&i_mtx, CYG_MUTANT_ACCESS, &attr, FALSE);
   if (!NT_SUCCESS (status))
-    api_fatal ("NtCreateMutant(inode): %p", status);
+    api_fatal ("NtCreateMutant(inode): %y", status);
 }
 
 /* Enumerate all lock event objects for this file and create a lockf_t
@@ -554,10 +554,10 @@ lockf_t::from_obj_name (inode_t *node, lockf_t **head, const wchar_t *name)
   lf_type = wcstol (endptr + 1, &endptr, 16);
   if ((lf_type != F_RDLCK && lf_type != F_WRLCK) || !endptr || *endptr != L'-')
     return false;
-  lf_start = (_off64_t) wcstoull (endptr + 1, &endptr, 16);
+  lf_start = (off_t) wcstoull (endptr + 1, &endptr, 16);
   if (lf_start < 0 || !endptr || *endptr != L'-')
     return false;
-  lf_end = (_off64_t) wcstoull (endptr + 1, &endptr, 16);
+  lf_end = (off_t) wcstoull (endptr + 1, &endptr, 16);
   if (lf_end < -1LL
       || (lf_end > 0 && lf_end < lf_start)
       || !endptr || *endptr != L'-')
@@ -640,8 +640,8 @@ create_lock_in_parent (PVOID param)
   OBJECT_NAME_INFORMATION *ntfn;
   NTSTATUS status;
   wchar_t *lockname, *inodename, *endptr;
-  __dev32_t dev;
-  __ino64_t ino;
+  dev_t dev;
+  ino_t ino;
   inode_t *node;
   lockf_t newlock, *lock;
   int cnt;
@@ -753,7 +753,7 @@ lockf_t::create_lock_obj ()
       if (!NT_SUCCESS (status))
        {
          if (status != STATUS_OBJECT_NAME_COLLISION)
-           api_fatal ("NtCreateEvent(lock): %p", status);
+           api_fatal ("NtCreateEvent(lock): %y", status);
          /* If we get a STATUS_OBJECT_NAME_COLLISION, the event still exists
             because some other process is waiting for it in lf_setlock.
             If so, check the event's signal state.  If we can't open it, it
@@ -764,7 +764,7 @@ lockf_t::create_lock_obj ()
          if (open_lock_obj ())
            {
              if (!IsEventSignalled (lf_obj))
-               api_fatal ("NtCreateEvent(lock): %p", status);
+               api_fatal ("NtCreateEvent(lock): %y", status);
              close_lock_obj ();
              /* Increment the lf_ver field until we have no collision. */
              ++lf_ver;
@@ -910,15 +910,15 @@ static int maxlockdepth = MAXDEPTH;
 static int      lf_clearlock (lockf_t *, lockf_t **, HANDLE);
 static int      lf_findoverlap (lockf_t *, lockf_t *, int, lockf_t ***, lockf_t **);
 static lockf_t *lf_getblock (lockf_t *, inode_t *node);
-static int      lf_getlock (lockf_t *, inode_t *, struct __flock64 *);
+static int      lf_getlock (lockf_t *, inode_t *, struct flock *);
 static int      lf_setlock (lockf_t *, inode_t *, lockf_t **, HANDLE);
 static void     lf_split (lockf_t *, lockf_t *, lockf_t **);
 static void     lf_wakelock (lockf_t *, HANDLE);
 
 int
-fhandler_disk_file::lock (int a_op, struct __flock64 *fl)
+fhandler_disk_file::lock (int a_op, struct flock *fl)
 {
-  _off64_t start, end, oadd;
+  off_t start, end, oadd;
   int error = 0;
 
   short a_flags = fl->l_type & (F_POSIX | F_FLOCK);
@@ -1499,7 +1499,7 @@ lf_clearlock (lockf_t *unlock, lockf_t **clean, HANDLE fhdl)
  * and if so return its process identifier.
  */
 static int
-lf_getlock (lockf_t *lock, inode_t *node, struct __flock64 *fl)
+lf_getlock (lockf_t *lock, inode_t *node, struct flock *fl)
 {
   lockf_t *block;
   tmp_pathbuf tp;
@@ -1577,7 +1577,7 @@ static int
 lf_findoverlap (lockf_t *lf, lockf_t *lock, int type, lockf_t ***prev,
                lockf_t **overlap)
 {
-  _off64_t start, end;
+  off_t start, end;
 
   *overlap = lf;
   if (lf == NOLOCKF)
@@ -1716,7 +1716,7 @@ flock (int fd, int operation)
 {
   int res = -1;
   int cmd;
-  struct __flock64 fl = { 0, SEEK_SET, 0, 0, 0 };
+  struct flock fl = { 0, SEEK_SET, 0, 0, 0 };
 
   myfault efault;
   if (efault.faulted (EFAULT))
@@ -1751,11 +1751,11 @@ done:
 }
 
 extern "C" int
-lockf (int filedes, int function, _off64_t size)
+lockf (int filedes, int function, off_t size)
 {
   int res = -1;
   int cmd;
-  struct __flock64 fl;
+  struct flock fl;
 
   pthread_testcancel ();
 
index 720d62a4c9f168c3a9ff69279085ecccd61c1157..634621351d0ef250099948aae06115c1be67ea7c 100644 (file)
@@ -328,7 +328,7 @@ frok::parent (volatile char * volatile stack_here)
            ch.guardsize = _my_tls.tid->attr.guardsize;
        }
     }
-  debug_printf ("stack - bottom %p, top %p, addr %p, guardsize %p",
+  debug_printf ("stack - bottom %p, top %p, addr %p, guardsize %lu",
                ch.stackbottom, ch.stacktop, ch.stackaddr, ch.guardsize);
 
   PROCESS_INFORMATION pi;
@@ -340,7 +340,7 @@ frok::parent (volatile char * volatile stack_here)
   si.lpReserved2 = (LPBYTE) &ch;
   si.cbReserved2 = sizeof (ch);
 
-  syscall_printf ("CreateProcessW (%W, %W, 0, 0, 1, %p, 0, 0, %p, %p)",
+  syscall_printf ("CreateProcessW (%W, %W, 0, 0, 1, %y, 0, 0, %p, %p)",
                  myself->progname, myself->progname, c_flags, &si, &pi);
   bool locked = __malloc_lock ();
   time_t start_time = time (NULL);
@@ -598,14 +598,18 @@ fork ()
 
     ischild = !!setjmp (grouped.ch.jmp);
 
-    volatile char * volatile esp;
-    __asm__ volatile ("movl %%esp,%0": "=r" (esp));
+    volatile char * volatile stackp;
+#ifdef __x86_64__
+    __asm__ volatile ("movq %%rsp,%0": "=r" (stackp));
+#else
+    __asm__ volatile ("movl %%esp,%0": "=r" (stackp));
+#endif
 
     if (!ischild)
-      res = grouped.parent (esp);
+      res = grouped.parent (stackp);
     else
       {
-       res = grouped.child (esp);
+       res = grouped.child (stackp);
        in_forkee = false;
        ischild = true; /* might have been reset by fork mem copy */
       }
@@ -664,12 +668,12 @@ child_copy (HANDLE hp, bool write, ...)
     {
       char *low = va_arg (args, char *);
       char *high = va_arg (args, char *);
-      DWORD todo = high - low;
+      SIZE_T todo = high - low;
       char *here;
 
       for (here = low; here < high; here += todo)
        {
-         DWORD done = 0;
+         SIZE_T done = 0;
          if (here + todo > high)
            todo = high - here;
          int res;
@@ -684,7 +688,7 @@ child_copy (HANDLE hp, bool write, ...)
                __seterrno ();
              /* If this happens then there is a bug in our fork
                 implementation somewhere. */
-             system_printf ("%s %s copy failed, %p..%p, done %d, windows pid %u, %E",
+             system_printf ("%s %s copy failed, %p..%p, done %lu, windows pid %u, %E",
                            what, huh[write], low, high, done, myself->dwProcessId);
              goto err;
            }
index c393f2372b4fd760d17201b6fd8347443591c908..e7449a21f8775b4e30a82a154f17e61014ce78f1 100755 (executable)
@@ -13,16 +13,20 @@ sub cleanup(@);
 
 my $in = shift;
 my $tls_offsets = shift;
+my $cpu = shift;
 my $out = shift;
 my $sigfe = shift;
 
 $main::first = 0;
-if (!defined($in) || !defined($out) || !defined($sigfe)) {
-    die "usage: $0 deffile.in cygtls.h deffile.def sigfe.s\n";
+if (!defined($in) || !defined($cpu) || !defined($out) || !defined($sigfe)) {
+    die "usage: $0 deffile.in cygtls.h target-cpu deffile.def sigfe.s\n";
 }
 
 require $tls_offsets;
 
+my $is64bit = ($cpu eq 'x86_64' ? 1 : 0);
+my $sym_prefix = ($is64bit ? '' : '_');
+
 open(IN, $in) or die "$0: couldn't open \"$in\" - $!\n";
 my @top = ();
 while (<IN>) {
@@ -47,7 +51,7 @@ for (@in) {
            # nothing
        } elsif (s/\s+SIGFE(_MAYBE)?$//) {
            my $func = (split(' '))[2];
-           my $maybe = lc $1 . '_';
+           my $maybe = (defined($1) ? lc $1 : '') . '_';
            $sigfe{$func} = '_sigfe' . $maybe . $func;
        }
     } else {
@@ -86,20 +90,312 @@ for my $k (sort keys %sigfe) {
 close SIGFE;
 
 sub fefunc {
-    my $func = '_' . shift;
-    my $fe = '_' . shift;
-    my $sigfe_func = ($fe =~ /^(.*)$func/)[0];
+    my $func = $sym_prefix . shift;
+    my $fe = $sym_prefix . shift;
+    my $sigfe_func;
+    if ($is64bit) {
+       $sigfe_func = ($fe =~ /^(.*)_${func}$/)[0];
+    } else {
+       $sigfe_func = ($fe =~ /^(.*)${func}$/)[0];
+    }
     my $extra;
-    my $res = <<EOF;
+    my $res;
+    if ($is64bit) {
+       $res = <<EOF;
        .extern $func
        .global $fe
+       .seh_proc $fe
 $fe:
-       pushl   \$$func
+       leaq    $func(%rip),%r10
+       pushq   %r10
+       .seh_pushreg %r10
+       .seh_endprologue
        jmp     $sigfe_func
+       .seh_endproc
+
+EOF
+    } else {
+       $res = <<EOF;
+        .extern $func
+        .global $fe
+$fe:
+        pushl   \$$func
+        jmp     $sigfe_func
 
 EOF
+    }
     if (!$main::first++) {
-       $res = <<EOF . longjmp () . $res;
+       if ($is64bit) {
+         $res = <<EOF . longjmp () . $res;
+       .text
+
+       .seh_proc _sigfe_maybe
+_sigfe_maybe:
+       pushq   %r12
+       .seh_pushreg %r12
+       .seh_endprologue
+       movq    %gs:8,%r12                      # location of bottom of stack
+       addq    \$$tls::initialized,%r12        # where we will be looking
+       cmpq    %r12,%rsp                       # stack loc > than tls
+       jge     0f                              #  yep.  we don't have a tls.
+       subq    \$$tls::initialized,%r12        # where we will be looking
+       movl    $tls::initialized(%r12),%r11d
+       cmpl    \$0xc763173f,%r11d              # initialized?
+       je      1f
+0:
+       popq    %r12
+       ret
+       .seh_endproc
+
+       .seh_proc _sigfe
+_sigfe:                                                # stack is aligned on entry!
+       pushq   %r12
+       .seh_pushreg %r12
+       .seh_endprologue
+       movq    %gs:8,%r12                      # location of bottom of stack
+1:     movl    \$1,%r11d                       # potential lock value
+       xchgl   %r11d,$tls::stacklock(%r12)     # see if we can grab it
+       movl    %r11d,$tls::spinning(%r12)      # flag if we are waiting for lock
+       testl   %r11d,%r11d                     # it will be zero
+       jz      2f                              #  if so
+       pause
+       jmp     1b                              # loop
+2:     movq    \$8,%rax                        # have the lock, now increment the
+       xaddq   %rax,$tls::stackptr(%r12)       #  stack pointer and get pointer
+       leaq    _sigbe(%rip),%r11               # new place to return to
+       xchgq   %r11,16(%rsp)                   # exchange with real return value
+       movq    %r11,(%rax)                     # store real return value on alt stack
+       incl    $tls::incyg(%r12)
+       decl    $tls::stacklock(%r12)           # remove lock
+       popq    %r12                            # restore saved value
+       popq    %rax                            # pop real function address from stack
+       jmp     *%rax                           # and jmp to it
+       .seh_endproc
+
+       .seh_proc _sigfe
+_sigbe:                                                # return here after cygwin syscall
+                                               # stack is aligned on entry!
+       pushq   %r12
+       .seh_pushreg %r12
+       .seh_endprologue
+       movq    %gs:8,%r12                      # address of bottom of tls
+1:     movl    \$1,%r11d                       # potential lock value
+       xchgl   %r11d,$tls::stacklock(%r12)     # see if we can grab it
+       movl    %r11d,$tls::spinning(%r12)      # flag if we are waiting for lock
+       testl   %r11d,%r11d                     # it will be zero
+       jz      2f                              #  if so
+       pause
+       jmp     1b                              #  and loop
+2:     movq    \$-8,%r11                       # now decrement aux stack
+       xaddq   %r11,$tls::stackptr(%r12)       #  and get pointer
+       movq    -8(%r11),%r11                   # get return address from signal stack
+       decl    $tls::incyg(%r12)
+       decl    $tls::stacklock(%r12)           # release lock
+       popq    %r12
+       jmp     *%r11                           # "return" to caller
+       .seh_endproc
+
+       .global sigdelayed
+       .seh_proc sigdelayed
+sigdelayed:
+       pushq   %r10                            # used for return address injection
+       .seh_pushreg %rbp
+       pushq   %rbp
+       .seh_pushreg %rbp
+       movq    %rsp,%rbp
+       # stack is aligned or unaligned on entry!
+       # make sure it is aligned from here on
+       # We could be called from an interrupted thread which doesn't know
+       # about his fate, so save and restore everything and the kitchen sink.
+       andq    \$0xfffffffffffffff0,%rsp
+       .seh_setframe %rbp,0
+       pushq   %r15
+       .seh_pushreg %r15
+       pushq   %r14
+       .seh_pushreg %r14
+       pushq   %r13
+       .seh_pushreg %r13
+       pushq   %r12
+       .seh_pushreg %r12
+       pushq   %r11
+       .seh_pushreg %r11
+       pushq   %r9
+       .seh_pushreg %r9
+       pushq   %r8
+       .seh_pushreg %r8
+       pushq   %rsi
+       .seh_pushreg %rsi
+       pushq   %rdi
+       .seh_pushreg %rdi
+       pushq   %rdx
+       .seh_pushreg %rdx
+       pushq   %rcx
+       .seh_pushreg %rcx
+       pushq   %rbx
+       .seh_pushreg %rbx
+       pushq   %rax
+       .seh_pushreg %rax
+       pushf
+       subq    \$0x120,%rsp
+       .seh_stackalloc 0x120
+       movdqa  %xmm15,0x110(%rsp)
+       movdqa  %xmm14,0x100(%rsp)
+       movdqa  %xmm13,0xf0(%rsp)
+       movdqa  %xmm12,0xe0(%rsp)
+       movdqa  %xmm11,0xd0(%rsp)
+       movdqa  %xmm10,0xc0(%rsp)
+       movdqa  %xmm9,0xb0(%rsp)
+       movdqa  %xmm8,0xa0(%rsp)
+       movdqa  %xmm7,0x90(%rsp)
+       movdqa  %xmm6,0x80(%rsp)
+       movdqa  %xmm5,0x70(%rsp)
+       movdqa  %xmm4,0x60(%rsp)
+       movdqa  %xmm3,0x50(%rsp)
+       movdqa  %xmm2,0x40(%rsp)
+       movdqa  %xmm1,0x30(%rsp)
+       movdqa  %xmm0,0x20(%rsp)
+       .seh_endprologue
+
+       movq    %gs:8,%r12                      # get tls
+       movl    $tls::saved_errno(%r12),%r15d   # temporarily save saved_errno
+       movq    \$$tls::start_offset,%rcx       # point to beginning of tls block
+       addq    %r12,%rcx                       #  and store as first arg to method
+       call    _ZN7_cygtls19call_signal_handlerEv      # call handler
+
+1:     movl    \$1,%r11d                       # potential lock value
+       xchgl   %r11d,$tls::stacklock(%r12)     # see if we can grab it
+       movl    %r11d,$tls::spinning(%r12)      # flag if we are waiting for lock
+       testl   %r11d,%r11d                     # it will be zero
+       jz      2f                              #  if so
+       pause
+       jmp     1b                              #  and loop
+2:     testl   %r15d,%r15d                     # was saved_errno < 0
+       jl      3f                              # yup.  ignore it
+       movq    $tls::errno_addr(%r12),%r11
+       movl    %r15d,(%r11)
+3:     movq    \$-8,%r11                       # now decrement aux stack
+       xaddq   %r11,$tls::stackptr(%r12)       #  and get pointer
+       xorq    %r10,%r10
+       xchgq   %r10,-8(%r11)                   # get return address from signal stack
+       xorl    %r11d,%r11d
+       movl    %r11d,$tls::incyg(%r12)
+       movl    %r11d,$tls::stacklock(%r12)     # unlock
+       movdqa  0x20(%rsp),%xmm0
+       movdqa  0x30(%rsp),%xmm1
+       movdqa  0x40(%rsp),%xmm2
+       movdqa  0x50(%rsp),%xmm3
+       movdqa  0x60(%rsp),%xmm4
+       movdqa  0x70(%rsp),%xmm5
+       movdqa  0x80(%rsp),%xmm6
+       movdqa  0x90(%rsp),%xmm7
+       movdqa  0xa0(%rsp),%xmm8
+       movdqa  0xb0(%rsp),%xmm9
+       movdqa  0xc0(%rsp),%xmm10
+       movdqa  0xd0(%rsp),%xmm11
+       movdqa  0xe0(%rsp),%xmm12
+       movdqa  0xf0(%rsp),%xmm13
+       movdqa  0x100(%rsp),%xmm14
+       movdqa  0x110(%rsp),%xmm15
+       addq    \$0x120,%rsp
+       popf
+       popq    %rax
+       popq    %rbx
+       popq    %rcx
+       popq    %rdx
+       popq    %rdi
+       popq    %rsi
+       popq    %r8
+       popq    %r9
+       popq    %r11
+       popq    %r12
+       popq    %r13
+       popq    %r14
+       popq    %r15
+       movq    %rbp,%rsp
+       popq    %rbp
+       xchgq   %r10,(%rsp)
+       ret
+       .seh_endproc
+
+# _cygtls::pop
+       .global _ZN7_cygtls3popEv
+       .seh_proc _ZN7_cygtls3popEv
+_ZN7_cygtls3popEv:
+       .seh_endprologue
+       movq    \$-8,%r11
+       xaddq   %r11,$tls::pstackptr(%rcx)
+       movq    -8(%r11),%rax
+       ret
+       .seh_endproc
+
+# _cygtls::lock
+       .global _ZN7_cygtls4lockEv
+       .seh_proc _ZN7_cygtls4lockEv
+_ZN7_cygtls4lockEv:
+       pushq   %r12
+       .seh_pushreg %r12
+       .seh_endprologue
+       movq    %rcx,%r12
+1:     movl    \$1,%r11d
+       xchgl   %r11d,$tls::pstacklock(%r12)
+       testl   %r11d,%r11d
+       jz      2f
+       pause
+       jmp     1b
+2:     popq    %r12
+       ret
+       .seh_endproc
+
+# _cygtls::unlock
+       .global _ZN7_cygtls6unlockEv
+       .seh_proc _ZN7_cygtls6unlockEv
+_ZN7_cygtls6unlockEv:
+       .seh_endprologue
+       decl    $tls::pstacklock(%rcx)
+       ret
+       .seh_endproc
+
+# _cygtls::locked
+       .global _ZN7_cygtls6lockedEv
+       .seh_proc _ZN7_cygtls6lockedEv
+_ZN7_cygtls6lockedEv:
+       .seh_endprologue
+       movl    $tls::pstacklock(%rcx),%eax
+       ret
+       .seh_endproc
+
+       .seh_proc stabilize_sig_stack
+stabilize_sig_stack:
+       pushq   %r12
+       .seh_pushreg %r12
+       subq    \$0x20,%rsp
+       .seh_stackalloc 32
+       .seh_endprologue
+       movq    %gs:8,%r12
+1:     movl    \$1,%r10d
+       xchgl   %r10d,$tls::stacklock(%r12)
+       movl    %r10d,$tls::spinning(%r12)              # flag if we are waiting for lock
+       testl   %r10d,%r10d
+       jz      2f
+       pause
+       jmp     1b
+2:     incl    $tls::incyg(%r12)
+       cmpl    \$0,$tls::sig(%r12)
+       jz      3f
+       decl    $tls::stacklock(%r12)                   # unlock
+       movq    \$$tls::start_offset,%rcx               # point to beginning
+       addq    %r12,%rcx                               #  of tls block
+       call    _ZN7_cygtls19call_signal_handlerEv
+       jmp     1b
+3:     decl    $tls::incyg(%r12)
+       addq    \$0x20,%rsp
+       movq    %r12,%r11                               # return tls addr in r11
+       popq    %r12
+       ret
+       .seh_endproc
+EOF
+       } else {
+         $res = <<EOF . longjmp () . $res;
        .text
 
 __sigfe_maybe:
@@ -265,12 +561,170 @@ stabilize_sig_stack:
 3:     decl    $tls::incyg(%ebx)
        ret
 EOF
+       }
     }
     return $res;
 }
 
 sub longjmp {
-    return <<EOF;
+    if ($is64bit) {
+       return <<EOF;
+
+       .globl  setjmp
+       .seh_proc setjmp
+setjmp:
+       .seh_endprologue
+       # We use the Windows jmp_buf layout.  Store ExceptionList in Frame.
+       # Store alternative stackptr in Spare.
+       movq    %gs:0,%r10
+       movq    %r10,(%rcx)
+       movq    %rbx,0x8(%rcx)
+       movq    %rsp,0x10(%rcx)
+       movq    %rbp,0x18(%rcx)
+       movq    %rsi,0x20(%rcx)
+       movq    %rdi,0x28(%rcx)
+       movq    %r12,0x30(%rcx)
+       movq    %r13,0x38(%rcx)
+       movq    %r14,0x40(%rcx)
+       movq    %r15,0x48(%rcx)
+       movq    (%rsp),%r10
+       movq    %r10,0x50(%rcx)
+       # jmp_buf is potentially unaligned!
+       movdqu  %xmm6,0x60(%rcx)
+       movdqu  %xmm7,0x70(%rcx)
+       movdqu  %xmm8,0x80(%rcx)
+       movdqu  %xmm9,0x90(%rcx)
+       movdqu  %xmm10,0xa0(%rcx)
+       movdqu  %xmm11,0xb0(%rcx)
+       movdqu  %xmm12,0xc0(%rcx)
+       movdqu  %xmm13,0xd0(%rcx)
+       movdqu  %xmm14,0xe0(%rcx)
+       movdqu  %xmm15,0xf0(%rcx)
+       pushq   %rcx
+       .seh_pushreg %rcx
+       call    stabilize_sig_stack             # returns tls in r11
+       popq    %rcx
+       movq    $tls::stackptr(%r11),%r10
+       movq    %r10,0x58(%rcx)
+       decl    $tls::stacklock(%r11)
+       movl    \$0,%eax
+       ret
+       .seh_endproc
+
+       .globl  __sjfault
+       .seh_proc __sjfault
+__sjfault:
+       .seh_endprologue
+       # Like setjmp, just w/o storing the alternate stackptr.
+       movq    %gs:0,%r10
+       movq    %r10,(%rcx)
+       movq    %rbx,0x8(%rcx)
+       movq    %rsp,0x10(%rcx)
+       movq    %rbp,0x18(%rcx)
+       movq    %rsi,0x20(%rcx)
+       movq    %rdi,0x28(%rcx)
+       movq    %r12,0x30(%rcx)
+       movq    %r13,0x38(%rcx)
+       movq    %r14,0x40(%rcx)
+       movq    %r15,0x48(%rcx)
+       movq    (%rsp),%r10
+       movq    %r10,0x50(%rcx)
+       # jmp_buf is potentially unaligned!
+       movdqu  %xmm6,0x60(%rcx)
+       movdqu  %xmm7,0x70(%rcx)
+       movdqu  %xmm8,0x80(%rcx)
+       movdqu  %xmm9,0x90(%rcx)
+       movdqu  %xmm10,0xa0(%rcx)
+       movdqu  %xmm11,0xb0(%rcx)
+       movdqu  %xmm12,0xc0(%rcx)
+       movdqu  %xmm13,0xd0(%rcx)
+       movdqu  %xmm14,0xe0(%rcx)
+       movdqu  %xmm15,0xf0(%rcx)
+       movl    \$0,%eax
+       ret
+       .seh_endproc
+
+       .globl  __ljfault
+       .seh_proc __ljfault
+__ljfault:
+       movq    (%rcx),%r10
+       movq    %r10,%gs:0
+       movq    0x8(%rcx),%rbx
+       movq    0x10(%rcx),%rsp
+       movq    0x18(%rcx),%rbp
+       movq    0x20(%rcx),%rsi
+       movq    0x28(%rcx),%rdi
+       movq    0x30(%rcx),%r12
+       movq    0x38(%rcx),%r13
+       movq    0x40(%rcx),%r14
+       movq    0x48(%rcx),%r15
+       movq    0x50(%rcx),%r10
+       movq    %r10,(%rsp)
+       # jmp_buf is potentially unaligned!
+       movdqu  0x60(%rcx),%xmm6
+       movdqu  0x70(%rcx),%xmm7
+       movdqu  0x80(%rcx),%xmm8
+       movdqu  0x90(%rcx),%xmm9
+       movdqu  0xa0(%rcx),%xmm10
+       movdqu  0xb0(%rcx),%xmm11
+       movdqu  0xc0(%rcx),%xmm12
+       movdqu  0xd0(%rcx),%xmm13
+       movdqu  0xe0(%rcx),%xmm14
+       movdqu  0xf0(%rcx),%xmm15
+       movl    %edx,%eax
+       testl   %eax,%eax
+       jne     0f
+       incl    %eax
+0:     ret
+       .seh_endproc
+
+       .globl  longjmp
+       .seh_proc longjmp
+longjmp:
+       pushq   %rcx
+       .seh_pushreg %rcx
+       .seh_endprologue
+       movl    %edx,%r12d                      # save return value (r12 is overwritten anyway)
+       call    stabilize_sig_stack             # returns tls in r11
+       popq    %rcx
+       movl    %r12d,%eax                      # restore return value
+       movq    0x58(%rcx),%r10                 # get old signal stack
+       movq    %r10,$tls::stackptr(%r11)       # restore
+       decl    $tls::stacklock(%r11)           # relinquish lock
+       xorl    %r10d,%r10d
+       movl    %r10d,$tls::incyg(%r11)         # we're definitely not in cygwin anymore
+       movq    (%rcx),%r10
+       movq    %r10,%gs:0
+       movq    0x8(%rcx),%rbx
+       movq    0x10(%rcx),%rsp
+       movq    0x18(%rcx),%rbp
+       movq    0x20(%rcx),%rsi
+       movq    0x28(%rcx),%rdi
+       movq    0x30(%rcx),%r12
+       movq    0x38(%rcx),%r13
+       movq    0x40(%rcx),%r14
+       movq    0x48(%rcx),%r15
+       movq    0x50(%rcx),%r10
+       movq    %r10,(%rsp)
+       # jmp_buf is potentially unaligned!
+       movdqu  0x60(%rcx),%xmm6
+       movdqu  0x70(%rcx),%xmm7
+       movdqu  0x80(%rcx),%xmm8
+       movdqu  0x90(%rcx),%xmm9
+       movdqu  0xa0(%rcx),%xmm10
+       movdqu  0xb0(%rcx),%xmm11
+       movdqu  0xc0(%rcx),%xmm12
+       movdqu  0xd0(%rcx),%xmm13
+       movdqu  0xe0(%rcx),%xmm14
+       movdqu  0xf0(%rcx),%xmm15
+       testl   %eax,%eax
+       jne     0f
+       incl    %eax
+0:     ret
+       .seh_endproc
+EOF
+    } else {
+       return <<EOF;
 
        .globl  _setjmp
 _setjmp:
@@ -424,6 +878,7 @@ _longjmp:
        popfl
        ret
 EOF
+    }
 }
 
 sub cleanup(@) {
index 0272868d208581f515a5b3bd3f6a01cf46b3853e..d2400bb295d4d62350ee0f1d037e80613d53acde 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -s
-# Copyright 2003, 2004, 2005, 2006, 2008, 2012, 2013 Red Hat, Inc.
+# Copyright 2003, 2004, 2005, 2012, 2013 Red Hat, Inc.
 #
 # This file is part of Cygwin.
 #
@@ -9,6 +9,13 @@
 #
 my $tls = shift;
 my $tls_out = shift;
+my $tgt = shift;
+# FIXME?  This method obviously requires a 64 bit OS to build tlsoffsets64.h
+# Another method which doesn't requires to run an executable would be to
+# generate assembler code accessing the various struct members and analyzing
+# it, but that's arguably a lot more effort.
+my $tgt_opt='-m64';
+$tgt_opt='-m32' unless ($tgt eq 'x86_64');
 open(TLS, $tls) or die "$0: couldn't open tls file \"$tls\" - $!\n";
 my $struct = '';
 my @fields = ();
@@ -44,7 +51,9 @@ close TLS;
 open(TMP, '>', "/tmp/$$.cc") or die "$0: couldn't open temporary index file \"/tmp/$$.c\" - $!\n";
 print TMP <<EOF;
 #define __INSIDE_CYGWIN__
+#ifndef __x86_64__
 #define __attribute__(X)
+#endif
 #define __reg1
 #define __reg2
 #define __reg3
@@ -81,13 +90,13 @@ EOF
 EOF
 close TMP;
 system @ARGV, '-o', "/tmp/$$-1.cc", '-E', "/tmp/$$.cc";
-system 'g++', '-m32', '-o', "/tmp/$$.a.out", "/tmp/$$-1.cc" and
-($? == 127 && system 'c++', '-m32', '-o', "/tmp/$$.a.out", "/tmp/$$-1.cc") and
+system 'g++', "$tgt_opt", '-o', "/tmp/$$.a.out", "/tmp/$$-1.cc" and
+($? == 127 && system 'c++', "$tgt_opt", '-o', "/tmp/$$.a.out", "/tmp/$$-1.cc") and
 die "$0: couldn't generate executable for offset calculation \"/tmp/$$.a.out\" - $!\n";
 open(TLS_OUT, '>', $tls_out) or die "$0: couldn't open tls index file \"$tls_out\" - $!\n";
 open(OFFS, "/tmp/$$.a.out|") or die "$0: couldn't run \"/tmp/$$.a.out\" - $!\n";
 print TLS_OUT <OFFS>;
 close OFFS;
 close TLS_OUT;
-unlink "/tmp/$$.cc", "/tmp/$$.a.out";
+unlink "/tmp/$$.cc", "/tmp/$$-1.cc", "/tmp/$$-1.d", "/tmp/$$.a.out";
 exit(0);
index c02901fc6c5c1a67dd0d1de4059ca70e03efd550..296cd7fbc2c532605385d7572b6fd5c58d6464fe 100644 (file)
@@ -105,8 +105,6 @@ __FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.28 2010/05/12 17:44:00 gordon Ex
 #define getuid()       getuid32 ()
 #define issetugid()    (cygheap->user.issetuid ())
 
-#define stat __stat64
-
 #define CCHAR(c)       (ignore_case_with_glob ? towlower (CHAR (c)) : CHAR (c))
 #define Cchar(c)       (ignore_case_with_glob ? towlower (c) : (c))
 #endif
@@ -858,8 +856,11 @@ g_opendir(Char *str, glob_t *pglob)
        return(opendir(buf));
 }
 
+#ifdef __x86_64__
+#define CYGWIN_gl_stat(sfptr) ((*pglob->sfptr) (buf, sb))
+#else
 static void
-stat32_to_stat64 (struct __stat32 *src, struct __stat64 *dst)
+stat32_to_stat64 (struct __stat32 *src, struct stat *dst)
 {
   dst->st_dev = src->st_dev;
   dst->st_ino = src->st_ino;
@@ -882,10 +883,11 @@ stat32_to_stat64 (struct __stat32 *src, struct __stat64 *dst)
      struct __stat32 lsb;                                               \
      if (CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES)                      \
        ret = (*pglob->sfptr) (buf, sb);                                         \
-     else  if (!(ret = (*pglob->sfptr) (buf, (struct __stat64 *) &lsb))) \
+     else  if (!(ret = (*pglob->sfptr) (buf, (struct stat *) &lsb))) \
        stat32_to_stat64 (&lsb, sb);                                     \
      ret;                                                               \
   })
+#endif
 
 static int
 g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
index d08cae75c150409d81694ddb7f782af11a960357..d7d278fcafd28efb6a397ff5504b6010b986762a 100644 (file)
@@ -26,8 +26,10 @@ HMODULE NO_COPY cygwin_hmodule;
 int NO_COPY sigExeced;
 WCHAR windows_system_directory[MAX_PATH];
 UINT windows_system_directory_length;
+#ifndef __x86_64__
 WCHAR system_wow64_directory[MAX_PATH];
 UINT system_wow64_directory_length;
+#endif /* !__x86_64__ */
 
 /* program exit the program */
 
@@ -78,64 +80,74 @@ bool NO_COPY _cygwin_testing;
 
 char NO_COPY almost_null[1];
 
-/* Heavily-used const UNICODE_STRINGs are defined here once.  The idea is a
-   speed improvement by not having to initialize a UNICODE_STRING every time
-   we make a string comparison.  The strings are not defined as const,
-   because the respective NT functions are not taking const arguments
-   and doing so here results in lots of extra casts for no good reason.
-   Rather, the strings are placed in the R/O section .rdata, so we get
-   a SEGV if some code erroneously tries to overwrite these strings. */
+extern "C" {
+
+  /* Heavily-used const UNICODE_STRINGs are defined here once.  The idea is a
+     speed improvement by not having to initialize a UNICODE_STRING every time
+     we make a string comparison.  The _RDATA trick allows defining the strings
+     as const (so we get a SEGV if some code erroneously tries to overwrite
+     them), while declaring them as non-const in the auto-generated globals.h.
+     The strings are usually used in NT functions which don't take const
+     arguments.  We avoid a lot of extra casts here...
+     Note:  The "extern" is required, otherwise either the variables are dropped
+            entirely, or C++ name mangling is applied despite the extern "C"
+           bracket, depending on the compiler version */
+#ifndef _RDATA
+#  define _RDATA const
+#endif
+
 #define _ROU(_s) \
-       { Length: sizeof (_s) - sizeof (WCHAR), \
-         MaximumLength: sizeof (_s), \
-         Buffer: (PWSTR) (_s) }
-UNICODE_STRING _RDATA ro_u_empty = _ROU (L"");
-UNICODE_STRING _RDATA ro_u_lnk = _ROU (L".lnk");
-UNICODE_STRING _RDATA ro_u_exe = _ROU (L".exe");
-UNICODE_STRING _RDATA ro_u_dll = _ROU (L".dll");
-UNICODE_STRING _RDATA ro_u_com = _ROU (L".com");
-UNICODE_STRING _RDATA ro_u_scr = _ROU (L".scr");
-UNICODE_STRING _RDATA ro_u_sys = _ROU (L".sys");
-UNICODE_STRING _RDATA ro_u_proc = _ROU (L"proc");
-UNICODE_STRING _RDATA ro_u_dev = _ROU (L"dev");
-UNICODE_STRING _RDATA ro_u_pmem = _ROU (L"\\Device\\PhysicalMemory");
-UNICODE_STRING _RDATA ro_u_natp = _ROU (L"\\??\\");
-UNICODE_STRING _RDATA ro_u_uncp = _ROU (L"\\??\\UNC\\");
-UNICODE_STRING _RDATA ro_u_mtx = _ROU (L"mtx");
-UNICODE_STRING _RDATA ro_u_csc = _ROU (L"CSC-CACHE");
-UNICODE_STRING _RDATA ro_u_fat = _ROU (L"FAT");
-UNICODE_STRING _RDATA ro_u_mvfs = _ROU (L"MVFS");
-UNICODE_STRING _RDATA ro_u_nfs = _ROU (L"NFS");
-UNICODE_STRING _RDATA ro_u_ntfs = _ROU (L"NTFS");
-UNICODE_STRING _RDATA ro_u_refs = _ROU (L"ReFS");
-UNICODE_STRING _RDATA ro_u_sunwnfs = _ROU (L"SUNWNFS");
-UNICODE_STRING _RDATA ro_u_udf = _ROU (L"UDF");
-UNICODE_STRING _RDATA ro_u_unixfs = _ROU (L"UNIXFS");
-UNICODE_STRING _RDATA ro_u_nwfs = _ROU (L"NWFS");
-UNICODE_STRING _RDATA ro_u_ncfsd = _ROU (L"NcFsd");
-UNICODE_STRING _RDATA ro_u_volume = _ROU (L"\\??\\Volume{");
-UNICODE_STRING _RDATA ro_u_pipedir = _ROU (L"\\\\?\\PIPE\\");
-UNICODE_STRING _RDATA ro_u_globalroot = _ROU (L"\\\\.\\GLOBALROOT");
-#undef _ROU
-
-/* Cygwin properties are meant to be readonly data placed in the DLL, but
-   which can be changed by external tools to make adjustments to the
-   behaviour of a DLL based on the binary of the DLL itself.  This is
-   different from $CYGWIN since it only affects that very DLL, not all
-   DLLs which have access to the $CYGWIN environment variable. */
-cygwin_props_t _RDATA cygwin_props =
-{
-  CYGWIN_PROPS_MAGIC,
-  sizeof (cygwin_props_t),
-  0
-};
+         { Length: sizeof (_s) - sizeof (WCHAR), \
+           MaximumLength: sizeof (_s), \
+           Buffer: (PWSTR) (_s) }
+  extern UNICODE_STRING _RDATA ro_u_empty = _ROU (L"");
+  extern UNICODE_STRING _RDATA ro_u_lnk = _ROU (L".lnk");
+  extern UNICODE_STRING _RDATA ro_u_exe = _ROU (L".exe");
+  extern UNICODE_STRING _RDATA ro_u_dll = _ROU (L".dll");
+  extern UNICODE_STRING _RDATA ro_u_com = _ROU (L".com");
+  extern UNICODE_STRING _RDATA ro_u_scr = _ROU (L".scr");
+  extern UNICODE_STRING _RDATA ro_u_sys = _ROU (L".sys");
+  extern UNICODE_STRING _RDATA ro_u_proc = _ROU (L"proc");
+  extern UNICODE_STRING _RDATA ro_u_dev = _ROU (L"dev");
+  extern UNICODE_STRING _RDATA ro_u_pmem = _ROU (L"\\Device\\PhysicalMemory");
+  extern UNICODE_STRING _RDATA ro_u_natp = _ROU (L"\\??\\");
+  extern UNICODE_STRING _RDATA ro_u_uncp = _ROU (L"\\??\\UNC\\");
+  extern UNICODE_STRING _RDATA ro_u_mtx = _ROU (L"mtx");
+  extern UNICODE_STRING _RDATA ro_u_csc = _ROU (L"CSC-CACHE");
+  extern UNICODE_STRING _RDATA ro_u_fat = _ROU (L"FAT");
+  extern UNICODE_STRING _RDATA ro_u_mvfs = _ROU (L"MVFS");
+  extern UNICODE_STRING _RDATA ro_u_nfs = _ROU (L"NFS");
+  extern UNICODE_STRING _RDATA ro_u_ntfs = _ROU (L"NTFS");
+  extern UNICODE_STRING _RDATA ro_u_refs = _ROU (L"ReFS");
+  extern UNICODE_STRING _RDATA ro_u_sunwnfs = _ROU (L"SUNWNFS");
+  extern UNICODE_STRING _RDATA ro_u_udf = _ROU (L"UDF");
+  extern UNICODE_STRING _RDATA ro_u_unixfs = _ROU (L"UNIXFS");
+  extern UNICODE_STRING _RDATA ro_u_nwfs = _ROU (L"NWFS");
+  extern UNICODE_STRING _RDATA ro_u_ncfsd = _ROU (L"NcFsd");
+  extern UNICODE_STRING _RDATA ro_u_volume = _ROU (L"\\??\\Volume{");
+  extern UNICODE_STRING _RDATA ro_u_pipedir = _ROU (L"\\\\?\\PIPE\\");
+  extern UNICODE_STRING _RDATA ro_u_globalroot = _ROU (L"\\\\.\\GLOBALROOT");
+  #undef _ROU
+
+  /* Cygwin properties are meant to be readonly data placed in the DLL, but
+     which can be changed by external tools to make adjustments to the
+     behaviour of a DLL based on the binary of the DLL itself.  This is
+     different from $CYGWIN since it only affects that very DLL, not all
+     DLLs which have access to the $CYGWIN environment variable.  We use the
+     same _RDATA trick as for the above UNICODE_STRINGs. */
+  extern cygwin_props_t _RDATA cygwin_props =
+  {
+    CYGWIN_PROPS_MAGIC,
+    sizeof (cygwin_props_t),
+    0
+  };
 
-extern "C"
-{
   /* This is an exported copy of environ which can be used by DLLs
      which use cygwin.dll.  */
   char **__cygwin_environ;
+#ifndef __x86_64__
   char ***main_environ = &__cygwin_environ;
+#endif
   /* __progname used in getopt error message */
   char *__progname;
   char *program_invocation_name;
@@ -145,7 +157,10 @@ extern "C"
   {/* initial_sp */ 0, /* magic_biscuit */ 0,
    /* dll_major */ CYGWIN_VERSION_DLL_MAJOR,
    /* dll_major */ CYGWIN_VERSION_DLL_MINOR,
-   /* impure_ptr_ptr */ NULL, /* envptr */ NULL,
+   /* impure_ptr_ptr */ NULL,
+#ifndef __x86_64__
+   /* envptr */ NULL,
+#endif
    /* malloc */ malloc, /* free */ free,
    /* realloc */ realloc,
    /* fmode_ptr */ NULL, /* main */ NULL, /* ctors */ NULL,
index 17f0954f0f0a8e5ca231bac423cb6e8f4f5fe426..a2ab5b635d0024f44dc86881cbc6c05bd799ace5 100644 (file)
@@ -1,7 +1,7 @@
 /* grp.cc
 
    Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2011, 2012 Red Hat, Inc.
+   2008, 2009, 2011, 2012, 2013 Red Hat, Inc.
 
    Original stubs by Jason Molenda of Cygnus Support, crash@cygnus.com
    First implementation by Gunther Ebert, gunther.ebert@ixos-leipzig.de
@@ -25,14 +25,14 @@ details. */
 #include "ntdll.h"
 #include "pwdgrp.h"
 
-static __group32 *group_buf;
+static group *group_buf;
 static pwdgrp gr (group_buf);
-static char * NO_COPY null_ptr;
+static char * NO_COPY_RO null_ptr;
 
 bool
 pwdgrp::parse_group ()
 {
-  __group32 &grp = (*group_buf)[curr_lines];
+  group &grp = (*group_buf)[curr_lines];
   grp.gr_name = next_str (':');
   if (!*grp.gr_name)
     return false;
@@ -81,15 +81,15 @@ pwdgrp::read_group ()
       static char linebuf [200];
       char group_name [UNLEN + 1] = "mkgroup";
       char strbuf[128] = "";
-      struct __group32 *gr;
+      struct group *gr;
 
       cygheap->user.groups.pgsid.string (strbuf);
       if ((gr = internal_getgrsid (cygheap->user.groups.pgsid)))
        snprintf (group_name, sizeof (group_name),
-                 "passwd/group_GID_clash(%lu/%lu)", myself->gid, gr->gr_gid);
+                 "passwd/group_GID_clash(%u/%u)", myself->gid, gr->gr_gid);
       if (myself->uid == UNKNOWN_UID)
        strcpy (group_name, "mkpasswd"); /* Feedback... */
-      snprintf (linebuf, sizeof (linebuf), "%s:%s:%lu:%s",
+      snprintf (linebuf, sizeof (linebuf), "%s:%s:%u:%s",
                group_name, strbuf, myself->gid, cygheap->user.name ());
       debug_printf ("Completing /etc/group: %s", linebuf);
       add_line (linebuf);
@@ -108,7 +108,7 @@ pwdgrp::pwdgrp (passwd *&pbuf) :
   pglock.init ("pglock");
 }
 
-pwdgrp::pwdgrp (__group32 *&gbuf) :
+pwdgrp::pwdgrp (group *&gbuf) :
   pwdgrp_buf_elem_size (sizeof (*gbuf)), group_buf (&gbuf)
 {
   read = &pwdgrp::read_group;
@@ -116,7 +116,7 @@ pwdgrp::pwdgrp (__group32 *&gbuf) :
   pglock.init ("pglock");
 }
 
-struct __group32 *
+struct group *
 internal_getgrsid (cygpsid &sid)
 {
   char sid_string[128];
@@ -130,8 +130,8 @@ internal_getgrsid (cygpsid &sid)
   return NULL;
 }
 
-struct __group32 *
-internal_getgrgid (__gid32_t gid, bool check)
+struct group *
+internal_getgrgid (gid_t gid, bool check)
 {
   gr.refresh (check);
 
@@ -141,7 +141,7 @@ internal_getgrgid (__gid32_t gid, bool check)
   return NULL;
 }
 
-struct __group32 *
+struct group *
 internal_getgrnam (const char *name, bool check)
 {
   gr.refresh (check);
@@ -154,8 +154,9 @@ internal_getgrnam (const char *name, bool check)
   return NULL;
 }
 
+#ifndef __x86_64__
 static struct __group16 *
-grp32togrp16 (struct __group16 *gp16, struct __group32 *gp32)
+grp32togrp16 (struct __group16 *gp16, struct group *gp32)
 {
   if (!gp16 || !gp32)
     return NULL;
@@ -169,17 +170,18 @@ grp32togrp16 (struct __group16 *gp16, struct __group32 *gp32)
 
   return gp16;
 }
+#endif
 
 extern "C" int
-getgrgid_r (__gid32_t gid, struct __group32 *grp, char *buffer, size_t bufsize,
-           struct __group32 **result)
+getgrgid_r (gid_t gid, struct group *grp, char *buffer, size_t bufsize,
+           struct group **result)
 {
   *result = NULL;
 
   if (!grp || !buffer)
     return ERANGE;
 
-  struct __group32 *tempgr = internal_getgrgid (gid, true);
+  struct group *tempgr = internal_getgrgid (gid, true);
   pthread_testcancel ();
   if (!tempgr)
     return 0;
@@ -206,12 +208,15 @@ getgrgid_r (__gid32_t gid, struct __group32 *grp, char *buffer, size_t bufsize,
   return 0;
 }
 
-extern "C" struct __group32 *
-getgrgid32 (__gid32_t gid)
+extern "C" struct group *
+getgrgid32 (gid_t gid)
 {
   return internal_getgrgid (gid, true);
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getgrgid32, getgrgid)
+#else
 extern "C" struct __group16 *
 getgrgid (__gid16_t gid)
 {
@@ -219,17 +224,18 @@ getgrgid (__gid16_t gid)
 
   return grp32togrp16 (&g16, getgrgid32 (gid16togid32 (gid)));
 }
+#endif
 
 extern "C" int
-getgrnam_r (const char *nam, struct __group32 *grp, char *buffer,
-           size_t bufsize, struct __group32 **result)
+getgrnam_r (const char *nam, struct group *grp, char *buffer,
+           size_t bufsize, struct group **result)
 {
   *result = NULL;
 
   if (!grp || !buffer)
     return ERANGE;
 
-  struct __group32 *tempgr = internal_getgrnam (nam, true);
+  struct group *tempgr = internal_getgrnam (nam, true);
   pthread_testcancel ();
   if (!tempgr)
     return 0;
@@ -256,12 +262,15 @@ getgrnam_r (const char *nam, struct __group32 *grp, char *buffer,
   return 0;
 }
 
-extern "C" struct __group32 *
+extern "C" struct group *
 getgrnam32 (const char *name)
 {
   return internal_getgrnam (name, true);
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getgrnam32, getgrnam)
+#else
 extern "C" struct __group16 *
 getgrnam (const char *name)
 {
@@ -269,6 +278,7 @@ getgrnam (const char *name)
 
   return grp32togrp16 (&g16, getgrnam32 (name));
 }
+#endif
 
 extern "C" void
 endgrent ()
@@ -276,7 +286,7 @@ endgrent ()
   _my_tls.locals.grp_pos = 0;
 }
 
-extern "C" struct __group32 *
+extern "C" struct group *
 getgrent32 ()
 {
   if (_my_tls.locals.grp_pos == 0)
@@ -287,6 +297,9 @@ getgrent32 ()
   return NULL;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getgrent32, getgrent)
+#else
 extern "C" struct __group16 *
 getgrent ()
 {
@@ -294,6 +307,7 @@ getgrent ()
 
   return grp32togrp16 (&g16, getgrent32 ());
 }
+#endif
 
 extern "C" void
 setgrent ()
@@ -302,7 +316,7 @@ setgrent ()
 }
 
 /* Internal function. ONLY USE THIS INTERNALLY, NEVER `getgrent'!!! */
-struct __group32 *
+struct group *
 internal_getgrent (int pos)
 {
   gr.refresh (false);
@@ -313,13 +327,13 @@ internal_getgrent (int pos)
 }
 
 int
-internal_getgroups (int gidsetsize, __gid32_t *grouplist, cygpsid * srchsid)
+internal_getgroups (int gidsetsize, gid_t *grouplist, cygpsid * srchsid)
 {
   NTSTATUS status;
   HANDLE hToken = NULL;
   ULONG size;
   int cnt = 0;
-  struct __group32 *gr;
+  struct group *gr;
 
   if (!srchsid && cygheap->user.groups.issetgroups ())
     {
@@ -383,7 +397,7 @@ internal_getgroups (int gidsetsize, __gid32_t *grouplist, cygpsid * srchsid)
        }
     }
   else
-    debug_printf ("%lu = NtQueryInformationToken(NULL) %p", size, status);
+    debug_printf ("%u = NtQueryInformationToken(NULL) %y", size, status);
   return cnt;
 
 error:
@@ -392,15 +406,18 @@ error:
 }
 
 extern "C" int
-getgroups32 (int gidsetsize, __gid32_t *grouplist)
+getgroups32 (int gidsetsize, gid_t *grouplist)
 {
   return internal_getgroups (gidsetsize, grouplist);
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getgroups32, getgroups)
+#else
 extern "C" int
 getgroups (int gidsetsize, __gid16_t *grouplist)
 {
-  __gid32_t *grouplist32 = NULL;
+  gid_t *grouplist32 = NULL;
 
   if (gidsetsize < 0)
     {
@@ -408,7 +425,7 @@ getgroups (int gidsetsize, __gid16_t *grouplist)
       return -1;
     }
   if (gidsetsize > 0 && grouplist)
-    grouplist32 = (__gid32_t *) alloca (gidsetsize * sizeof (__gid32_t));
+    grouplist32 = (gid_t *) alloca (gidsetsize * sizeof (gid_t));
 
   int ret = internal_getgroups (gidsetsize, grouplist32);
 
@@ -418,6 +435,7 @@ getgroups (int gidsetsize, __gid16_t *grouplist)
 
   return ret;
 }
+#endif
 
 /* Core functionality of initgroups and getgrouplist. */
 static int
@@ -427,7 +445,7 @@ get_groups (const char *user, gid_t gid, cygsidlist &gsids)
 
   cygheap->user.deimpersonate ();
   struct passwd *pw = internal_getpwnam (user);
-  struct __group32 *gr = internal_getgrgid (gid);
+  struct group *gr = internal_getgrgid (gid);
   cygsid usersid, grpsid;
   if (!usersid.getfrompw (pw) || !grpsid.getfromgr (gr))
     set_errno (EINVAL);
@@ -441,7 +459,7 @@ get_groups (const char *user, gid_t gid, cygsidlist &gsids)
 }
 
 extern "C" int
-initgroups32 (const char *user, __gid32_t gid)
+initgroups32 (const char *user, gid_t gid)
 {
   int ret;
 
@@ -459,11 +477,15 @@ initgroups32 (const char *user, __gid32_t gid)
   return ret;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (initgroups32, initgroups)
+#else
 extern "C" int
 initgroups (const char *user, __gid16_t gid)
 {
   return initgroups32 (user, gid16togid32(gid));
 }
+#endif
 
 extern "C" int
 getgrouplist (const char *user, gid_t gid, gid_t *groups, int *ngroups)
@@ -484,7 +506,7 @@ getgrouplist (const char *user, gid_t gid, gid_t *groups, int *ngroups)
       int cnt = 0;
       for (int i = 0; i < tmp_gsids.count (); i++)
        {
-         struct __group32 *gr = internal_getgrsid (tmp_gsids.sids[i]);
+         struct group *gr = internal_getgrsid (tmp_gsids.sids[i]);
          if (gr)
            {
              if (groups && cnt < *ngroups)
@@ -503,7 +525,7 @@ getgrouplist (const char *user, gid_t gid, gid_t *groups, int *ngroups)
 
 /* setgroups32: standards? */
 extern "C" int
-setgroups32 (int ngroups, const __gid32_t *grouplist)
+setgroups32 (int ngroups, const gid_t *grouplist)
 {
   syscall_printf ("setgroups32 (%d)", ngroups);
   if (ngroups < 0 || (ngroups > 0 && !grouplist))
@@ -513,7 +535,7 @@ setgroups32 (int ngroups, const __gid32_t *grouplist)
     }
 
   cygsidlist gsids (cygsidlist_alloc, ngroups);
-  struct __group32 *gr;
+  struct group *gr;
 
   if (ngroups && !gsids.sids)
     return -1;
@@ -523,7 +545,7 @@ setgroups32 (int ngroups, const __gid32_t *grouplist)
       if ((gr = internal_getgrgid (grouplist[gidx]))
          && gsids.addfromgr (gr))
        continue;
-      debug_printf ("No sid found for gid %d", grouplist[gidx]);
+      debug_printf ("No sid found for gid %u", grouplist[gidx]);
       gsids.free_sids ();
       set_errno (EINVAL);
       return -1;
@@ -532,14 +554,17 @@ setgroups32 (int ngroups, const __gid32_t *grouplist)
   return 0;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (setgroups32, setgroups)
+#else
 extern "C" int
 setgroups (int ngroups, const __gid16_t *grouplist)
 {
-  __gid32_t *grouplist32 = NULL;
+  gid_t *grouplist32 = NULL;
 
   if (ngroups > 0 && grouplist)
     {
-      grouplist32 = (__gid32_t *) alloca (ngroups * sizeof (__gid32_t));
+      grouplist32 = (gid_t *) alloca (ngroups * sizeof (gid_t));
       if (grouplist32 == NULL)
        return -1;
       for (int i = 0; i < ngroups; i++)
@@ -547,3 +572,4 @@ setgroups (int ngroups, const __gid16_t *grouplist)
     }
   return setgroups32 (ngroups, grouplist32);
 }
+#endif
index 23093dda79b106a26732790d08c6419008ee88c4..b10261cb65846c584d0f21a7cda3dd2bf6edb52a 100644 (file)
@@ -1,7 +1,7 @@
 /* heap.cc: Cygwin heap manager.
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -22,13 +22,22 @@ details. */
 
 #define assert(x)
 
-static unsigned page_const;
+static ptrdiff_t page_const;
 
 #define MINHEAP_SIZE (4 * 1024 * 1024)
 
 static uintptr_t
 eval_start_address ()
 {
+#ifdef __x86_64__
+  /* On 64 bit, we choose a fixed address outside the 32 bit area.  The
+     executable starts at 0x1:00400000L, the Cygwin DLL starts at
+     0x1:80040000L, other rebased DLLs are located in the region from
+     0x2:00000000L up to 0x4:00000000L, -auto-image-based DLLs are located
+     in the region from 0x4:00000000L up to 0x6:00000000L.
+     So we let the heap start at 0x6:00000000L. */
+  uintptr_t start_address = 0x600000000L;
+#else
   /* Starting with Vista, Windows performs heap ASLR.  This spoils the entire
      region below 0x20000000 for us, because that region is used by Windows
      to randomize heap and stack addresses.  Therefore we put our heap into a
@@ -53,30 +62,41 @@ eval_start_address ()
         memory for heap, thread stacks, and shared memory regions. */
       start_address = 0x80000000L;
     }
+#endif
   return start_address;
 }
 
-static unsigned
+static SIZE_T
 eval_initial_heap_size ()
 {
   PIMAGE_DOS_HEADER dosheader;
-  PIMAGE_NT_HEADERS32 ntheader;
-  unsigned size;
+  PIMAGE_NT_HEADERS ntheader;
+  SIZE_T size;
 
   dosheader = (PIMAGE_DOS_HEADER) GetModuleHandle (NULL);
-  ntheader = (PIMAGE_NT_HEADERS32) ((PBYTE) dosheader + dosheader->e_lfanew);
+  ntheader = (PIMAGE_NT_HEADERS) ((PBYTE) dosheader + dosheader->e_lfanew);
   /* LoaderFlags is an obsolete DWORD member of the PE/COFF file header.
      It's value is ignored by the loader, so we're free to use it for
-     Cygwin.  If it's 0, we default to the usual 384 Megs.  Otherwise,
-     we use it as the default initial heap size in megabyte.  Valid values
-     are between 4 and 2048 Megs. */
+     Cygwin.  If it's 0, we default to the usual 384 Megs on 32 bit and
+     512 on 64 bit.  Otherwise, we use it as the default initial heap size
+     in megabyte.  Valid values are between 4 and 2048/8388608 Megs. */
+
   size = ntheader->OptionalHeader.LoaderFlags;
+#ifdef __x86_64__
+  if (size == 0)
+    size = 512;
+  else if (size < 4)
+    size = 4;
+  else if (size > 8388608)
+    size = 8388608;
+#else
   if (size == 0)
     size = 384;
   else if (size < 4)
     size = 4;
   else if (size > 2048)
     size = 2048;
+#endif
   return size << 20;
 }
 
@@ -93,7 +113,7 @@ heap_init ()
     {
       uintptr_t start_address = eval_start_address ();
       PVOID largest_found = NULL;
-      size_t largest_found_size = 0;
+      SIZE_T largest_found_size = 0;
       SIZE_T ret;
       MEMORY_BASIC_INFORMATION mbi;
 
@@ -156,7 +176,7 @@ heap_init ()
        }
       while (!cygheap->user_heap.base && ret);
       if (cygheap->user_heap.base == NULL)
-       api_fatal ("unable to allocate heap, heap_chunk_size %p, %E",
+       api_fatal ("unable to allocate heap, heap_chunk_size %ly, %E",
                   cygheap->user_heap.chunk);
       cygheap->user_heap.ptr = cygheap->user_heap.top = cygheap->user_heap.base;
       cygheap->user_heap.max = (char *) cygheap->user_heap.base
@@ -164,14 +184,21 @@ heap_init ()
     }
   else
     {
-      DWORD chunk = cygheap->user_heap.chunk;  /* allocation chunk */
+      SIZE_T chunk = cygheap->user_heap.chunk; /* allocation chunk */
       /* total size commited in parent */
-      DWORD allocsize = (char *) cygheap->user_heap.top -
-                       (char *) cygheap->user_heap.base;
+      SIZE_T allocsize = (char *) cygheap->user_heap.top -
+                        (char *) cygheap->user_heap.base;
 
       /* Loop until we've managed to reserve an adequate amount of memory. */
       char *p;
-      DWORD reserve_size = chunk * ((allocsize + (chunk - 1)) / chunk);
+      SIZE_T reserve_size = chunk * ((allocsize + (chunk - 1)) / chunk);
+      /* With ptmalloc3 there's a good chance that there has been no memory
+        allocated on the heap.  If we don't check that, reserve_size will
+        be 0 and from there, the below loop will end up overallocating due
+        to integer overflow. */
+      if (!reserve_size)
+       reserve_size = chunk;
+
       while (1)
        {
          p = (char *) VirtualAlloc (cygheap->user_heap.base, reserve_size,
@@ -183,12 +210,14 @@ heap_init ()
        }
       if (!p && in_forkee && !fork_info->abort (NULL))
        api_fatal ("couldn't allocate heap, %E, base %p, top %p, "
-                  "reserve_size %d, allocsize %d, page_const %d",
+                  "reserve_size %ld, allocsize %ld, page_const %d",
                   cygheap->user_heap.base, cygheap->user_heap.top,
                   reserve_size, allocsize, page_const);
       if (p != cygheap->user_heap.base)
-       api_fatal ("heap allocated at wrong address %p (mapped) != %p (expected)", p, cygheap->user_heap.base);
-      if (allocsize && !VirtualAlloc (cygheap->user_heap.base, allocsize, MEM_COMMIT, PAGE_READWRITE))
+       api_fatal ("heap allocated at wrong address %p (mapped) "
+                  "!= %p (expected)", p, cygheap->user_heap.base);
+      if (allocsize && !VirtualAlloc (cygheap->user_heap.base, allocsize,
+                                     MEM_COMMIT, PAGE_READWRITE))
        api_fatal ("MEM_COMMIT failed, %E");
     }
 
@@ -198,7 +227,7 @@ heap_init ()
      size has not been evaluated yet, except in a forked child.  Since
      heap_init is called early, the heap size is printed pretty much at the
      start of the strace output, so there isn't anything lost. */
-  debug_printf ("heap base %p, heap top %p, heap size %p (%u)",
+  debug_printf ("heap base %p, heap top %p, heap size %ly (%lu)",
                cygheap->user_heap.base, cygheap->user_heap.top,
                cygheap->user_heap.chunk, cygheap->user_heap.chunk);
   page_const--;
@@ -209,11 +238,14 @@ heap_init ()
 
 /* FIXME: This function no longer handles "split heaps". */
 
+/* Linux defines n to be intptr_t, newlib defines it to be ptrdiff_t.
+   It shouldn't matter much, though, since the function is not standarized
+   and sizeof(ptrdiff_t) == sizeof(intptr_t) anyway. */
 extern "C" void *
-sbrk (int n)
+sbrk (ptrdiff_t n)
 {
   char *newtop, *newbrk;
-  unsigned commitbytes, newbrksize;
+  SIZE_T commitbytes, newbrksize;
 
   if (n == 0)
     return cygheap->user_heap.ptr;             /* Just wanted to find current cygheap->user_heap.ptr address */
@@ -230,9 +262,8 @@ sbrk (int n)
       assert (newtop < cygheap->user_heap.top);
       n = (char *) cygheap->user_heap.top - newtop;
       if (VirtualFree (newtop, n, MEM_DECOMMIT)) /* Give it back to OS */
-       goto good;                              /*  Didn't take */
-      else
-       goto err;
+       goto good;
+      goto err;                                        /*  Didn't take */
     }
 
   assert (newtop > cygheap->user_heap.top);
@@ -256,11 +287,15 @@ sbrk (int n)
   if ((newbrksize = cygheap->user_heap.chunk) < commitbytes)
     newbrksize = commitbytes;
 
-   if ((VirtualAlloc (cygheap->user_heap.top, newbrksize, MEM_RESERVE, PAGE_NOACCESS)
-       || VirtualAlloc (cygheap->user_heap.top, newbrksize = commitbytes, MEM_RESERVE, PAGE_NOACCESS))
-       && VirtualAlloc (cygheap->user_heap.top, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL)
+   if ((VirtualAlloc (cygheap->user_heap.top, newbrksize,
+                     MEM_RESERVE, PAGE_NOACCESS)
+       || VirtualAlloc (cygheap->user_heap.top, newbrksize = commitbytes,
+                        MEM_RESERVE, PAGE_NOACCESS))
+       && VirtualAlloc (cygheap->user_heap.top, commitbytes,
+                       MEM_COMMIT, PAGE_READWRITE) != NULL)
      {
-       cygheap->user_heap.max = (char *) cygheap->user_heap.max + pround (newbrksize);
+       cygheap->user_heap.max = (char *) cygheap->user_heap.max
+                                + pround (newbrksize);
        goto good;
      }
 
index 0c3494d3f06b20e8d68e5175b56db4371235d282..133d8cbf5d6edd0f0f853d9a026a8fc1e2a6b3fa 100644 (file)
@@ -1,6 +1,6 @@
 /* hookapi.cc
 
-   Copyright 2005, 2006, 2007, 2008, 2011, 2012 Red Hat, Inc.
+   Copyright 2005, 2006, 2007, 2008, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -29,13 +29,13 @@ struct function_hook
   void *origfn;                // Stored by HookAPICalls, the address of the original function.
 };
 
-/* Given an HMODULE, returns a pointer to the PE header */
+/* Given an HMODULE, returns a pointer to the PE header. */
 static PIMAGE_NT_HEADERS
-PEHeaderFromHModule (HMODULE hModule)
+PEHeaderFromHModule (HMODULE hModule, bool &is_64bit)
 {
   PIMAGE_NT_HEADERS pNTHeader;
 
-  if (PIMAGE_DOS_HEADER(hModule) ->e_magic != IMAGE_DOS_SIGNATURE)
+  if (PIMAGE_DOS_HEADER (hModule) ->e_magic != IMAGE_DOS_SIGNATURE)
     pNTHeader = NULL;
   else
     {
@@ -43,6 +43,12 @@ PEHeaderFromHModule (HMODULE hModule)
                                     + PIMAGE_DOS_HEADER (hModule) ->e_lfanew);
       if (pNTHeader->Signature != IMAGE_NT_SIGNATURE)
        pNTHeader = NULL;
+      else if (pNTHeader->FileHeader.Machine == IMAGE_FILE_MACHINE_AMD64)
+       is_64bit = true;
+      else if (pNTHeader->FileHeader.Machine == IMAGE_FILE_MACHINE_I386)
+       is_64bit = false;
+      else
+       pNTHeader = NULL;
     }
 
   return pNTHeader;
@@ -55,7 +61,6 @@ rvadelta (PIMAGE_NT_HEADERS pnt, DWORD import_rva, DWORD &max_size)
   for (int i = 0; i < pnt->FileHeader.NumberOfSections; i++)
     if (section[i].VirtualAddress <= import_rva
        && (section[i].VirtualAddress + section[i].Misc.VirtualSize) > import_rva)
-    // if (ascii_strncasematch ((char *) section[i].Name, ".idata", IMAGE_SIZEOF_SHORT_NAME))
       {
        max_size = section[i].SizeOfRawData
                   - (import_rva - section[i].VirtualAddress);
@@ -64,21 +69,30 @@ rvadelta (PIMAGE_NT_HEADERS pnt, DWORD import_rva, DWORD &max_size)
   return -1;
 }
 
+/* This function is only used for the current architecture.
+   Just the size of the IMAGE_THUNK_DATA Function member differs. */
 static void *
 putmem (PIMAGE_THUNK_DATA pi, const void *hookfn)
 {
+#ifdef __x86_64__
+#define THUNK_FUNC_TYPE ULONGLONG
+#else
+#define THUNK_FUNC_TYPE DWORD
+#endif
+
   DWORD ofl;
-  if (!VirtualProtect (pi, sizeof (PVOID), PAGE_READWRITE, &ofl) )
+  if (!VirtualProtect (pi, sizeof (THUNK_FUNC_TYPE), PAGE_READWRITE, &ofl) )
     return NULL;
 
   void *origfn = (void *) pi->u1.Function;
-  pi->u1.Function = (DWORD) hookfn;
+  pi->u1.Function = (THUNK_FUNC_TYPE) hookfn;
 
-  VirtualProtect (pi, sizeof (PVOID), ofl, &ofl);
+  VirtualProtect (pi, sizeof (THUNK_FUNC_TYPE), ofl, &ofl);
   return origfn;
 }
 
-/* Builds stubs for and redirects the IAT for one DLL (pImportDesc) */
+/* Builds stubs for and redirects the IAT for one DLL (pImportDesc)
+   This function is only used for the current architecture. */
 
 static bool
 RedirectIAT (function_hook& fh, PIMAGE_IMPORT_DESCRIPTOR pImportDesc,
@@ -122,6 +136,7 @@ RedirectIAT (function_hook& fh, PIMAGE_IMPORT_DESCRIPTOR pImportDesc,
   return true;
 }
 
+/* This function is only used for the current architecture. */
 static void
 get_export (function_hook& fh)
 {
@@ -162,6 +177,59 @@ makename (const char *name, char *&buf, int& i, int inc)
   return name;
 }
 
+static HMODULE
+remap (PIMAGE_IMPORT_DESCRIPTOR &pdfirst, long &delta, HANDLE hc,
+       DWORD importRVA, DWORD importRVASize, DWORD importRVAMaxSize)
+{
+  /* If h is not NULL, the calling function only mapped at most the first
+     64K of the image.  The IAT is usually at the end of the image, so
+     what we do here is to map the IAT into our address space if it doesn't
+     reside in the first 64K anyway.  The offset must be a multiple of the
+     allocation granularity, though, so we have to map a bit more. */
+  HMODULE map;
+  DWORD offset = rounddown (importRVA, wincap.allocation_granularity ());
+  /* But that's not all, unfortunately.  Apparently there's a difference
+     between the importRVASize of applications built with gcc and those
+     built with Visual Studio.  When built with gcc, importRVASize contains
+     the size of the import RVA table plus the size of the referenced
+     string table with the DLL names.  When built with VS, it only contains
+     the size of the naked import RVA table.  The following code handles
+     the situation.  importRVAMaxSize contains the size of the remainder
+     of the section.  If the difference between importRVAMaxSize and
+     importRVASize is less than 64K, we just use importRVAMaxSize to
+     compute the size of the memory map.  Otherwise the executable may be
+     very big.  In that case we only map the import RVA table and ... */
+  DWORD size = importRVA - offset + ((importRVAMaxSize - importRVASize
+                                     <= wincap.allocation_granularity ())
+                                    ? importRVAMaxSize : importRVASize);
+  map = (HMODULE) MapViewOfFile (hc, FILE_MAP_READ, 0, offset, size);
+  if (!map)
+    return NULL;
+  pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, map, importRVA - offset);
+  /* ... carefully check the required size to fit the string table into
+     the map as well.  Allow NAME_MAX bytes for the DLL name, but don't
+     go beyond the remainder of the section. */
+  if (importRVAMaxSize - importRVASize > wincap.allocation_granularity ())
+    {
+      DWORD newsize = size;
+      for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
+       if (pd->Name - delta - offset + (NAME_MAX + 1) > newsize)
+         newsize = pd->Name - delta - offset + (NAME_MAX + 1);
+      if (newsize > size)
+       {
+         if (newsize > importRVA - offset + importRVAMaxSize)
+           newsize = importRVA - offset + importRVAMaxSize;
+         UnmapViewOfFile (map);
+         map = (HMODULE) MapViewOfFile (hc, FILE_MAP_READ, 0, offset, newsize);
+         if (!map)
+           return NULL;
+         pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, map, importRVA - offset);
+       }
+    }
+  delta += offset;
+  return map;
+}
+
 /* Find first missing dll in a given executable.
    FIXME: This is not foolproof since it doesn't look for dlls in the
    same directory as the given executable, like Windows.  Instead it
@@ -178,6 +246,10 @@ find_first_notloaded_dll (path_conv& pc)
   HANDLE h;
   NTSTATUS status;
   LARGE_INTEGER size;
+  PIMAGE_NT_HEADERS pExeNTHdr;
+  DWORD importRVA, importRVASize, importRVAMaxSize;
+  HMODULE map;
+  long delta;
 
   status = NtOpenFile (&h, SYNCHRONIZE | GENERIC_READ,
                       pc.get_object_attr (attr, sec_none_nih),
@@ -199,7 +271,7 @@ find_first_notloaded_dll (path_conv& pc)
       NtClose (h);
       goto out;
     }
-  if (size.QuadPart > wincap.allocation_granularity ())
+  if (size.QuadPart > (LONGLONG) wincap.allocation_granularity ())
     size.LowPart = wincap.allocation_granularity ();
   hc = CreateFileMapping (h, &sec_none_nih, PAGE_READONLY, 0, 0, NULL);
   NtClose (h);
@@ -209,55 +281,58 @@ find_first_notloaded_dll (path_conv& pc)
   if (!hm)
     goto out;
 
-  PIMAGE_NT_HEADERS pExeNTHdr;
-  pExeNTHdr = PEHeaderFromHModule (hm);
+  bool is_64bit;
+  pExeNTHdr = PEHeaderFromHModule (hm, is_64bit);
+
+  if (!pExeNTHdr)
+    goto out;
+
+#ifdef __x86_64__
+  if (!is_64bit)
+#else
+  if (is_64bit)
+#endif
+    goto out;
+
+  importRVA = pExeNTHdr->OptionalHeader.DataDirectory
+                       [IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
+  importRVASize = pExeNTHdr->OptionalHeader.DataDirectory
+                       [IMAGE_DIRECTORY_ENTRY_IMPORT].Size;
+  if (!importRVA)
+    goto out;
 
-  if (pExeNTHdr)
+  delta = rvadelta (pExeNTHdr, importRVA, importRVAMaxSize);
+  if (delta < 0)
+    goto out;
+  importRVA -= delta;
+  map = NULL;
+
+  PIMAGE_IMPORT_DESCRIPTOR pdfirst;
+
+  if (importRVA + importRVAMaxSize > wincap.allocation_granularity ())
     {
-      DWORD importRVA;
-      DWORD importRVAMaxSize;
-      importRVA = pExeNTHdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
-      if (importRVA)
+      map = remap (pdfirst, delta, hc, importRVA, importRVASize,
+                  importRVAMaxSize);
+      if (!map)
+       goto out;
+    }
+  else
+    pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, hm, importRVA);
+
+  /* Iterate through each import descriptor, and check if DLL can be loaded. */
+  for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
+    {
+      const char *lib = rva (PSTR, map ?: hm, pd->Name - delta);
+      if (!LoadLibraryEx (lib, NULL, DONT_RESOLVE_DLL_REFERENCES
+                                    | LOAD_LIBRARY_AS_DATAFILE))
        {
-         long delta = rvadelta (pExeNTHdr, importRVA, importRVAMaxSize);
-         if (delta < 0)
-           goto out;
-         importRVA -= delta;
-
-         DWORD offset = 0;
-         HMODULE map = NULL;
-         if (importRVA + importRVAMaxSize > wincap.allocation_granularity ())
-           {
-             offset = rounddown (importRVA, wincap.allocation_granularity ());
-             DWORD size = importRVA - offset + importRVAMaxSize;
-             map = (HMODULE) MapViewOfFile (hc, FILE_MAP_READ, 0,
-                                            offset, size);
-             if (!map)
-               goto out;
-           }
-
-         // Convert imports RVA to a usable pointer
-         PIMAGE_IMPORT_DESCRIPTOR pdfirst;
-         pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, map ?: hm,
-                        importRVA - offset);
-
-         // Iterate through each import descriptor, and redirect if appropriate
-         for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
-           {
-             const char *lib = rva (PSTR, map ?: hm,
-                                    pd->Name - delta - offset);
-             if (!LoadLibraryEx (lib, NULL, DONT_RESOLVE_DLL_REFERENCES
-                                            | LOAD_LIBRARY_AS_DATAFILE))
-               {
-                 static char buf[MAX_PATH];
-                 strlcpy (buf, lib, MAX_PATH);
-                 res = buf;
-               }
-           }
-         if (map)
-           UnmapViewOfFile (map);
+         static char buf[MAX_PATH];
+         strlcpy (buf, lib, MAX_PATH);
+         res = buf;
        }
     }
+  if (map)
+    UnmapViewOfFile (map);
 
 out:
   if (hm)
@@ -273,25 +348,32 @@ void *
 hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h)
 {
   HMODULE hm = fn ? GetModuleHandle (NULL) : (HMODULE) name;
-  PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule (hm);
+  bool is_64bit;
+  PIMAGE_NT_HEADERS pExeNTHdr = PEHeaderFromHModule (hm, is_64bit);
 
   if (!pExeNTHdr)
     return NULL;
 
-  /* FIXME: This code has to be made 64 bit capable. */
-  if (pExeNTHdr->FileHeader.Machine != IMAGE_FILE_MACHINE_I386)
+  /* Shortcut.  We don't have to do anything further from here, if the
+     executable's architecture doesn't match, unless we want to support
+     a mix of 32 and 64 bit Cygwin at one point. */
+#ifdef __x86_64__
+  if (!is_64bit)
+#else
+  if (is_64bit)
+#endif
     return NULL;
 
-  subsys =  pExeNTHdr->OptionalHeader.Subsystem;
-
-  DWORD importRVA = pExeNTHdr->OptionalHeader.DataDirectory
-                     [IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
-  DWORD importRVASize = pExeNTHdr->OptionalHeader.DataDirectory
+  DWORD importRVA, importRVASize;
+  subsys = pExeNTHdr->OptionalHeader.Subsystem;
+  importRVA = pExeNTHdr->OptionalHeader.DataDirectory
+                       [IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress;
+  importRVASize = pExeNTHdr->OptionalHeader.DataDirectory
                        [IMAGE_DIRECTORY_ENTRY_IMPORT].Size;
   if (!importRVA)
     return NULL;
 
-  DWORD importRVAMaxSize;
+  DWORD importRVAMaxSize = 0;
   long delta = fn ? 0 : rvadelta (pExeNTHdr, importRVA, importRVAMaxSize);
   if (delta < 0)
     return NULL;
@@ -300,55 +382,12 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h)
   // Convert imports RVA to a usable pointer
   PIMAGE_IMPORT_DESCRIPTOR pdfirst;
   char *map = NULL;
-  DWORD offset = 0;
   if (h && importRVA + importRVAMaxSize > wincap.allocation_granularity ())
     {
-      /* If h is not NULL, the calling function only mapped at most the first
-        64K of the image.  The IAT is usually at the end of the image, so
-        what we do here is to map the IAT into our address space if it doesn't
-        reside in the first 64K anyway.  The offset must be a multiple of the
-        allocation granularity, though, so we have to map a bit more. */
-      offset = rounddown (importRVA, wincap.allocation_granularity ());
-      /* But that's not all, unfortunately.  Apparently there's a difference
-        between the importRVASize of applications built with gcc and those
-        built with Visual Studio.  When built with gcc, importRVASize contains
-        the size of the import RVA table plus the size of the referenced
-        string table with the DLL names.  When built with VS, it only contains
-        the size of the naked import RVA table.  The following code handles
-        the situation.  importRVAMaxSize contains the size of the remainder
-        of the section.  If the difference between importRVAMaxSize and
-        importRVASize is less than 64K, we just use importRVAMaxSize to
-        compute the size of the memory map.  Otherwise the executable may be
-        very big.  In that case we only map the import RVA table and ... */
-      DWORD size = importRVA - offset
-                  + ((importRVAMaxSize - importRVASize
-                      <= wincap.allocation_granularity ())
-                     ? importRVAMaxSize : importRVASize);
-      map = (char *) MapViewOfFile (h, FILE_MAP_READ, 0, offset, size);
+      map = (char *) remap (pdfirst, delta, h, importRVA, importRVASize,
+                           importRVAMaxSize);
       if (!map)
        return NULL;
-      pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, map, importRVA - offset);
-      /* ... carefully check the required size to fit the string table into
-        the map as well.  Allow NAME_MAX bytes for the DLL name, but don't
-        go beyond the remainder of the section. */
-      if (importRVAMaxSize - importRVASize > wincap.allocation_granularity ())
-       {
-         DWORD newsize = size;
-         for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
-           if (pd->Name - delta - offset + (NAME_MAX + 1) > newsize)
-             newsize = pd->Name - delta - offset + (NAME_MAX + 1);
-         if (newsize > size)
-           {
-             if (newsize > importRVA - offset + importRVAMaxSize)
-               newsize = importRVA - offset + importRVAMaxSize;
-             UnmapViewOfFile (map);
-             map = (char *) MapViewOfFile (h, FILE_MAP_READ, 0, offset,
-                                           newsize);
-             if (!map)
-               return NULL;
-             pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, map, importRVA - offset);
-           }
-       }
     }
   else
     pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, hm, importRVA);
@@ -363,14 +402,15 @@ hook_or_detect_cygwin (const char *name, const void *fn, WORD& subsys, HANDLE h)
   // Iterate through each import descriptor, and redirect if appropriate
   for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
     {
-      if (!ascii_strcasematch (rva (PSTR, map ?: (char *) hm,
-                                   pd->Name - delta - offset), "cygwin1.dll"))
-       continue;
+      if (!ascii_strcasematch (rva (PSTR, map ?: (char *) hm, pd->Name - delta),
+                              "cygwin1.dll"))
+       continue;
       if (!fn)
        {
+         /* Just checking if executable used cygwin1.dll. */
          if (map)
            UnmapViewOfFile (map);
-         return (void *) "found it";   // just checking if executable used cygwin1.dll
+         return (void *) "found it";
        }
       i = -1;
       while (!fh.origfn && (fh.name = makename (name, buf, i, 1)))
index 1ccc3f425960618dd0e93503167a75824b84df4f..ad9b5a56fbe68224cfc63447494bd9d48ec020b9 100644 (file)
@@ -1,6 +1,6 @@
 /* a.out.h
 
-   Copyright 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
+   Copyright 1997, 1998, 1999, 2000, 2001, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -14,22 +14,25 @@ details. */
 #ifdef __cplusplus
 extern "C" {
 #endif
+
+#include <stdint.h>
+
 #define COFF_IMAGE_WITH_PE
 #define COFF_LONG_SECTION_NAMES
 
-/*** coff information for Intel 386/486.  */
+/*** coff information for Intel 386/486 and AMD64.  */
 
 
 /********************** FILE HEADER **********************/
 
 struct external_filehdr {
-  short f_magic;       /* magic number                 */
-  short f_nscns;       /* number of sections           */
-  unsigned long f_timdat;      /* time & date stamp            */
-  unsigned long f_symptr;      /* file pointer to symtab       */
-  unsigned long f_nsyms;       /* number of symtab entries     */
-  short f_opthdr;      /* sizeof(optional hdr)         */
-  short f_flags;       /* flags                        */
+  uint16_t f_magic;    /* magic number                 */
+  uint16_t f_nscns;    /* number of sections           */
+  uint32_t f_timdat;   /* time & date stamp            */
+  uint32_t f_symptr;   /* file pointer to symtab       */
+  uint32_t f_nsyms;    /* number of symtab entries     */
+  uint16_t f_opthdr;   /* sizeof(optional hdr)         */
+  uint16_t f_flags;    /* flags                        */
 };
 
 /* Bits for f_flags:
@@ -50,6 +53,7 @@ struct external_filehdr {
 #define        I386MAGIC       0x14c
 #define I386PTXMAGIC   0x154
 #define I386AIXMAGIC   0x175
+#define AMD64MAGIC     0x8664
 
 /* This is Lynx's all-platform magic number for executables. */
 
@@ -70,14 +74,14 @@ struct external_filehdr {
 
 typedef struct
 {
-  unsigned short magic;                /* type of file                         */
-  unsigned short vstamp;       /* version stamp                        */
-  unsigned long        tsize;          /* text size in bytes, padded to FW bdry*/
-  unsigned long        dsize;          /* initialized data "  "                */
-  unsigned long        bsize;          /* uninitialized data "   "             */
-  unsigned long        entry;          /* entry pt.                            */
-  unsigned long text_start;    /* base of text used for this file */
-  unsigned long data_start;    /* base of data used for this file=
+  uint16_t magic;              /* type of file                         */
+  uint16_t vstamp;             /* version stamp                        */
+  uint32_t tsize;              /* text size in bytes, padded to FW bdry*/
+  uint32_t dsize;              /* initialized data "  "                */
+  uint32_t bsize;              /* uninitialized data "   "             */
+  uint32_t entry;              /* entry pt.                            */
+  uint32_t text_start;         /* base of text used for this file */
+  uint32_t data_start;         /* base of data used for this file=
  */
 }
 AOUTHDR;
@@ -103,16 +107,16 @@ AOUTHDR;
 
 struct external_scnhdr {
   char         s_name[8];      /* section name                 */
-  unsigned long        s_paddr;        /* physical address, offset
+  uint32_t     s_paddr;        /* physical address, offset
                                   of last addr in scn */
-  unsigned long        s_vaddr;        /* virtual address              */
-  unsigned long        s_size;         /* section size                 */
-  unsigned long        s_scnptr;       /* file ptr to raw data for section */
-  unsigned long        s_relptr;       /* file ptr to relocation       */
-  unsigned long        s_lnnoptr;      /* file ptr to line numbers     */
-  unsigned short s_nreloc;     /* number of relocation entries */
-  unsigned short s_nlnno;      /* number of line number entries*/
-  unsigned long        s_flags;        /* flags                        */
+  uint32_t     s_vaddr;        /* virtual address              */
+  uint32_t     s_size;         /* section size                 */
+  uint32_t     s_scnptr;       /* file ptr to raw data for section */
+  uint32_t     s_relptr;       /* file ptr to relocation       */
+  uint32_t     s_lnnoptr;      /* file ptr to line numbers     */
+  uint16_t     s_nreloc;       /* number of relocation entries */
+  uint16_t     s_nlnno;        /* number of line number entries*/
+  uint32_t     s_flags;        /* flags                        */
 };
 
 #define        SCNHDR  struct external_scnhdr
@@ -136,10 +140,10 @@ struct external_scnhdr {
  */
 struct external_lineno {
   union {
-    unsigned long l_symndx; /* function name symbol index, iff l_lnno 0 */
-    unsigned long l_paddr;     /* (physical) address of line number    */
+    uint32_t l_symndx;                 /* function name symbol index, iff l_lnno 0 */
+    uint32_t l_paddr;          /* (physical) address of line number    */
   } l_addr;
-  unsigned short l_lnno;       /* line number          */
+  uint16_t l_lnno;     /* line number          */
 };
 
 #define        LINENO  struct external_lineno
@@ -156,13 +160,13 @@ struct external_syment
   union {
     char e_name[E_SYMNMLEN];
     struct {
-      unsigned long e_zeroes;
-      unsigned long e_offset;
+      uint32_t e_zeroes;
+      uint32_t e_offset;
     } e;
   } e;
-  unsigned long e_value;
-  unsigned short e_scnum;
-  unsigned short e_type;
+  uint32_t e_value;
+  uint16_t e_scnum;
+  uint16_t e_type;
   char e_sclass[1];
   char e_numaux[1];
 };
@@ -174,46 +178,46 @@ struct external_syment
 
 union external_auxent {
   struct {
-    unsigned long x_tagndx;    /* str, un, or enum tag indx */
+    uint32_t x_tagndx; /* str, un, or enum tag indx */
     union {
       struct {
-       unsigned short  x_lnno; /* declaration line number */
-       unsigned short  x_size; /* str/union/array size */
+       uint16_t  x_lnno; /* declaration line number */
+       uint16_t  x_size; /* str/union/array size */
       } x_lnsz;
-      unsigned long x_fsize;   /* size of function */
+      uint32_t x_fsize;        /* size of function */
     } x_misc;
     union {
       struct {                 /* if ISFCN, tag, or .bb */
-       unsigned long x_lnnoptr;/* ptr to fcn line # */
-       unsigned long x_endndx; /* entry ndx past block end */
+       uint32_t x_lnnoptr;     /* ptr to fcn line # */
+       uint32_t x_endndx;      /* entry ndx past block end */
       } x_fcn;
       struct {                 /* if ISARY, up to 4 dimen. */
        char x_dimen[E_DIMNUM][2];
       } x_ary;
     } x_fcnary;
-    unsigned short x_tvndx;    /* tv index */
+    uint16_t x_tvndx;  /* tv index */
   } x_sym;
 
   union {
     char x_fname[E_FILNMLEN];
     struct {
-      unsigned long x_zeroes;
-      unsigned long x_offset;
+      uint32_t x_zeroes;
+      uint32_t x_offset;
     } x_n;
   } x_file;
 
   struct {
-    unsigned long x_scnlen;    /* section length */
-    unsigned short x_nreloc;   /* # relocation entries */
-    unsigned short x_nlinno;   /* # line numbers */
-    unsigned long x_checksum;  /* section COMDAT checksum */
-    unsigned short x_associated;/* COMDAT associated section index */
+    uint32_t x_scnlen;         /* section length */
+    uint16_t x_nreloc;         /* # relocation entries */
+    uint16_t x_nlinno;         /* # line numbers */
+    uint32_t x_checksum;       /* section COMDAT checksum */
+    uint16_t x_associated;     /* COMDAT associated section index */
     char x_comdat[1];          /* COMDAT selection number */
   } x_scn;
 
   struct {
-    unsigned long x_tvfill;    /* tv fill value */
-    unsigned short x_tvlen;    /* length of .tv */
+    uint32_t x_tvfill;         /* tv fill value */
+    uint16_t x_tvlen;          /* length of .tv */
     char x_tvran[2][2];                /* tv range */
   } x_tv;      /* info about .tv section (in auxent of symbol .tv)) */
 
@@ -244,6 +248,20 @@ struct external_reloc {
 #ifndef _PE_H
 #define _PE_H
 
+#define IMAGE_FILE_MACHINE_I386 0x014c
+#define IMAGE_FILE_MACHINE_AMD64 0x8664
+
+#define IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
+#define IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
+
+#define IMAGE_SIZEOF_STD_OPTIONAL_HEADER 28
+#define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
+#define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
+
+#define IMAGE_SUBSYSTEM_NATIVE 1
+#define IMAGE_SUBSYSTEM_WINDOWS_GUI 2
+#define IMAGE_SUBSYSTEM_WINDOWS_CUI 3
+
 /* NT specific file attributes */
 #define IMAGE_FILE_RELOCS_STRIPPED           0x0001
 #define IMAGE_FILE_EXECUTABLE_IMAGE          0x0002
@@ -320,43 +338,43 @@ struct external_reloc {
 
 
 #ifdef COFF_IMAGE_WITH_PE
-/* The filehdr is only weired in images */
+/* The filehdr is only weird in images */
 
 #undef FILHDR
 struct external_PE_filehdr
 {
   /* DOS header fields */
-  unsigned short e_magic;      /* Magic number, 0x5a4d */
-  unsigned short e_cblp;       /* Bytes on last page of file, 0x90 */
-  unsigned short e_cp;         /* Pages in file, 0x3 */
-  unsigned short e_crlc;       /* Relocations, 0x0 */
-  unsigned short e_cparhdr;    /* Size of header in paragraphs, 0x4 */
-  unsigned short e_minalloc;   /* Minimum extra paragraphs needed, 0x0 */
-  unsigned short e_maxalloc;   /* Maximum extra paragraphs needed, 0xFFFF */
-  unsigned short e_ss;         /* Initial (relative) SS value, 0x0 */
-  unsigned short e_sp;         /* Initial SP value, 0xb8 */
-  unsigned short e_csum;       /* Checksum, 0x0 */
-  unsigned short e_ip;         /* Initial IP value, 0x0 */
-  unsigned short e_cs;         /* Initial (relative) CS value, 0x0 */
-  unsigned short e_lfarlc;     /* File address of relocation table, 0x40 */
-  unsigned short e_ovno;       /* Overlay number, 0x0 */
-  char e_res[4][2];            /* Reserved words, all 0x0 */
-  unsigned short e_oemid;      /* OEM identifier (for e_oeminfo), 0x0 */
-  unsigned short e_oeminfo;    /* OEM information; e_oemid specific, 0x0 */
-  char e_res2[10][2];          /* Reserved words, all 0x0 */
-  unsigned long e_lfanew;      /* File address of new exe header, 0x80 */
+  uint16_t e_magic;    /* Magic number, 0x5a4d */
+  uint16_t e_cblp;     /* Bytes on last page of file, 0x90 */
+  uint16_t e_cp;       /* Pages in file, 0x3 */
+  uint16_t e_crlc;     /* Relocations, 0x0 */
+  uint16_t e_cparhdr;  /* Size of header in paragraphs, 0x4 */
+  uint16_t e_minalloc; /* Minimum extra paragraphs needed, 0x0 */
+  uint16_t e_maxalloc; /* Maximum extra paragraphs needed, 0xFFFF */
+  uint16_t e_ss;       /* Initial (relative) SS value, 0x0 */
+  uint16_t e_sp;       /* Initial SP value, 0xb8 */
+  uint16_t e_csum;     /* Checksum, 0x0 */
+  uint16_t e_ip;       /* Initial IP value, 0x0 */
+  uint16_t e_cs;       /* Initial (relative) CS value, 0x0 */
+  uint16_t e_lfarlc;   /* File address of relocation table, 0x40 */
+  uint16_t e_ovno;     /* Overlay number, 0x0 */
+  char e_res[4][2];    /* Reserved words, all 0x0 */
+  uint16_t e_oemid;    /* OEM identifier (for e_oeminfo), 0x0 */
+  uint16_t e_oeminfo;  /* OEM information; e_oemid specific, 0x0 */
+  char e_res2[10][2];  /* Reserved words, all 0x0 */
+  uint32_t e_lfanew;   /* File address of new exe header, 0x80 */
   char dos_message[16][4];     /* other stuff, always follow DOS header */
-  unsigned int nt_signature;   /* required NT signature, 0x4550 */
+  uint32_t nt_signature;       /* required NT signature, 0x4550 */
 
   /* From standard header */
 
-  unsigned short f_magic;      /* magic number                 */
-  unsigned short f_nscns;      /* number of sections           */
-  unsigned long f_timdat;      /* time & date stamp            */
-  unsigned long f_symptr;      /* file pointer to symtab       */
-  unsigned long f_nsyms;       /* number of symtab entries     */
-  unsigned short f_opthdr;     /* sizeof(optional hdr)         */
-  unsigned short f_flags;      /* flags                        */
+  uint16_t f_magic;    /* magic number                 */
+  uint16_t f_nscns;    /* number of sections           */
+  uint32_t f_timdat;   /* time & date stamp            */
+  uint32_t f_symptr;   /* file pointer to symtab       */
+  uint32_t f_nsyms;    /* number of symtab entries     */
+  uint16_t f_opthdr;   /* sizeof(optional hdr)         */
+  uint16_t f_flags;    /* flags                        */
 };
 
 
@@ -368,37 +386,39 @@ struct external_PE_filehdr
 
 typedef struct
 {
-  unsigned short magic;                /* type of file                         */
-  unsigned short vstamp;       /* version stamp                        */
-  unsigned long        tsize;          /* text size in bytes, padded to FW bdry*/
-  unsigned long        dsize;          /* initialized data "  "                */
-  unsigned long        bsize;          /* uninitialized data "   "             */
-  unsigned long        entry;          /* entry pt.                            */
-  unsigned long text_start;    /* base of text used for this file */
-  unsigned long data_start;    /* base of all data used for this file */
+  uint16_t magic;              /* type of file                         */
+  uint16_t vstamp;             /* version stamp                        */
+  uint32_t tsize;              /* text size in bytes, padded to FW bdry*/
+  uint32_t dsize;              /* initialized data "  "                */
+  uint32_t bsize;              /* uninitialized data "   "             */
+  uint32_t entry;              /* entry pt.                            */
+  uint32_t text_start; /* base of text used for this file */
+#ifndef __x86_64__
+  uint32_t data_start; /* base of all data used for this file */
+#endif
 
   /* NT extra fields; see internal.h for descriptions */
-  unsigned long  ImageBase;
-  unsigned long  SectionAlignment;
-  unsigned long  FileAlignment;
-  unsigned short  MajorOperatingSystemVersion;
-  unsigned short  MinorOperatingSystemVersion;
-  unsigned short  MajorImageVersion;
-  unsigned short  MinorImageVersion;
-  unsigned short  MajorSubsystemVersion;
-  unsigned short  MinorSubsystemVersion;
+  uintptr_t ImageBase;
+  uint32_t  SectionAlignment;
+  uint32_t  FileAlignment;
+  uint16_t  MajorOperatingSystemVersion;
+  uint16_t  MinorOperatingSystemVersion;
+  uint16_t  MajorImageVersion;
+  uint16_t  MinorImageVersion;
+  uint16_t  MajorSubsystemVersion;
+  uint16_t  MinorSubsystemVersion;
   char  Reserved1[4];
-  unsigned long  SizeOfImage;
-  unsigned long  SizeOfHeaders;
-  unsigned long  CheckSum;
-  unsigned short Subsystem;
-  unsigned short DllCharacteristics;
-  unsigned long  SizeOfStackReserve;
-  unsigned long  SizeOfStackCommit;
-  unsigned long  SizeOfHeapReserve;
-  unsigned long  SizeOfHeapCommit;
-  unsigned long  LoaderFlags;
-  unsigned long  NumberOfRvaAndSizes;
+  uint32_t  SizeOfImage;
+  uint32_t  SizeOfHeaders;
+  uint32_t  CheckSum;
+  uint16_t  Subsystem;
+  uint16_t  DllCharacteristics;
+  uintptr_t SizeOfStackReserve;
+  uintptr_t SizeOfStackCommit;
+  uintptr_t SizeOfHeapReserve;
+  uintptr_t SizeOfHeapCommit;
+  uint32_t  LoaderFlags;
+  uint32_t  NumberOfRvaAndSizes;
   /* IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; */
   char  DataDirectory[16][2][4]; /* 16 entries, 2 elements/entry, 4 chars */
 
@@ -406,7 +426,11 @@ typedef struct
 
 
 #undef AOUTSZ
+#ifdef __x86_64__
+#define AOUTSZ (AOUTHDRSZ + 212)
+#else
 #define AOUTSZ (AOUTHDRSZ + 196)
+#endif
 
 #undef  E_FILNMLEN
 #define E_FILNMLEN     18      /* # characters in a file name          */
index 4887016ac131acd51601e5b9bf804013d269f7ac..4f5d7cb59576d9730f09e6ed12d97b361880bc15 100644 (file)
@@ -1,6 +1,6 @@
 /* asm/byteorder.h
 
-   Copyright 1996, 1998, 2000, 2001, 2006, 2009, 2011 Red Hat, Inc.
+   Copyright 1996, 1998, 2001, 2006, 2009, 2011, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -34,11 +34,7 @@ _ELIDABLE_INLINE uint16_t __ntohs(uint16_t);
 _ELIDABLE_INLINE uint32_t
 __ntohl(uint32_t x)
 {
-       __asm__("xchgb %b0,%h0\n\t"     /* swap lower bytes     */
-               "rorl $16,%0\n\t"       /* swap words           */
-               "xchgb %b0,%h0"         /* swap higher bytes    */
-               :"=q" (x)
-               : "0" (x));
+       __asm__("bswap %0" : "=r" (x) : "0" (x));
        return x;
 }
 
@@ -52,7 +48,7 @@ _ELIDABLE_INLINE uint16_t
 __ntohs(uint16_t x)
 {
        __asm__("xchgb %b0,%h0"         /* swap bytes           */
-               : "=q" (x)
+               : "=Q" (x)
                :  "0" (x));
        return x;
 }
index 38e14f85f470286292c887731ab030e975929b8a..b0ee337f89aaa484502733508523b40da6a9c974 100644 (file)
@@ -2,5 +2,10 @@
 
 #ifndef _WORDSIZE_H
 #define _WORDSIZE_H 1
-#define __WORDSIZE      32
+#ifdef __x86_64__
+# define __WORDSIZE     64
+# define __WORDSIZE_COMPAT32    1
+#else
+# define __WORDSIZE     32
+#endif
 #endif /*_WORDSIZE_H*/
index 6083b5332be8a9bda37e8703eb2ea9791edc9840..9a62e325ea71907b77b309dbf2e4f381b95458d5 100644 (file)
@@ -59,24 +59,20 @@ extern "C" {
 #define OTHER           OTHER_OBJ
 
 #ifdef __INSIDE_CYGWIN__
+#ifndef __x86_64__
 typedef struct __acl16 {
     int          a_type;
     __uid16_t    a_id;
     mode_t       a_perm;
 } __aclent16_t;
+#endif
+#endif
 
-typedef struct __acl32 {
-    int          a_type;
-    __uid32_t    a_id;
-    mode_t       a_perm;
-} __aclent32_t;
-#else
 typedef struct acl {
     int          a_type;    /* entry type */
     uid_t        a_id;      /* UID | GID  */
     mode_t       a_perm;    /* permissions */
 } aclent_t;
-#endif
 
 #ifndef __INSIDE_CYGWIN__
 int _EXFUN(acl,(const char *path, int cmd, int nentries, aclent_t *aclbufp));
index f330ca4ab37f7496c354eff0e1c83875981502ac..cd73388d503676b21e9acd80c27200c2e9578b3c 100644 (file)
@@ -4,7 +4,7 @@
    sys/config.h before.  This way we can manaage our configuration
    setting without bothering newlib.
 
-   Copyright 2003, 2007, 2008, 2009, 2010, 2012 Red Hat, Inc.
+   Copyright 2003, 2007, 2008, 2009, 2010, 2012, 2013 Red Hat, Inc.
    Written by C. Vinschen.
 
 This file is part of Cygwin.
@@ -38,11 +38,31 @@ extern "C" {
    we might as well just use it here.  */
 
 #ifdef _COMPILING_NEWLIB
+#ifdef __x86_64__
+#include "../tlsoffsets64.h"
+/* We would like to use just "%gs:8", but on x86_64 gcc uses pc-relative
+   addressing and translates "gs:8" into the wrong addressing mode. */
+static inline char *___getreent (void)
+{
+  register char *ret;
+  __asm __volatile__ ("movq %%gs:8,%0" : "=r" (ret));
+  return ret + tls_local_clib;
+}
+#define __getreent() ((struct _reent *) ___getreent())
+#else
 #include "../tlsoffsets.h"
 extern char *_tlsbase __asm__ ("%fs:4");
 #define __getreent() (struct _reent *)(_tlsbase + tls_local_clib)
+#endif
 #endif  /* _COMPILING_NEWLIB */
 
+#ifdef __x86_64__
+# define __SYMBOL_PREFIX
+#else
+# define __SYMBOL_PREFIX "_"
+#endif
+#define _SYMSTR(x)     __SYMBOL_PREFIX #x
+
 #define __FILENAME_MAX__ 4096  /* Keep in sync with PATH_MAX in limits.h. */
 
 /* The following block of macros is required to build newlib correctly for
index 7abf5bd9706df011832f8408c5c0c06a1bc8ffc4..d3da87ddd6b0c127650c661a71b3e531dbdca89a 100644 (file)
@@ -1,6 +1,6 @@
 /* cygwin_dll.h
 
-   Copyright 1998, 1999, 2000, 2001, 2009, 2011 Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2009, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -26,8 +26,8 @@ details. */
 CDECL_BEGIN                                                                  \
   int WINAPI Entry (HINSTANCE h, DWORD reason, void *ptr);                   \
   typedef int (*mainfunc) (int, char **, char **);                           \
-  extern int cygwin_attach_dll (HMODULE, mainfunc);                          \
-  extern void cygwin_detach_dll (DWORD);                                     \
+  extern PVOID cygwin_attach_dll (HMODULE, mainfunc);                        \
+  extern void cygwin_detach_dll (PVOID);                                     \
 CDECL_END                                                                    \
                                                                              \
 static HINSTANCE storedHandle;                                               \
@@ -35,12 +35,14 @@ static DWORD storedReason;                                                \
 static void* storedPtr;                                                              \
 int __dynamically_loaded;                                                    \
                                                                              \
-static int __dllMain (int a, char **b, char **c)                             \
+static int __dllMain (int a __attribute__ ((unused)),                        \
+                     char **b __attribute__ ((unused)),                      \
+                     char **c __attribute__ ((unused)))                      \
 {                                                                            \
   return Entry (storedHandle, storedReason, storedPtr);                              \
 }                                                                            \
                                                                              \
-static DWORD dll_index;                                                              \
+static PVOID dll_index;                                                              \
                                                                              \
 int WINAPI _cygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr)          \
 {                                                                            \
@@ -56,7 +58,7 @@ int WINAPI _cygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr)         \
       storedPtr = ptr;                                                       \
       __dynamically_loaded = (ptr == NULL);                                  \
       dll_index = cygwin_attach_dll (h, &__dllMain);                         \
-      if (dll_index == (DWORD) -1)                                           \
+      if (dll_index == (PVOID) -1)                                           \
        ret = 0;                                                              \
     }                                                                        \
     break;                                                                   \
@@ -67,7 +69,7 @@ int WINAPI _cygwin_dll_entry (HINSTANCE h, DWORD reason, void *ptr)         \
       if (ret)                                                               \
       {                                                                              \
        cygwin_detach_dll (dll_index);                                        \
-       dll_index = (DWORD) -1;                                               \
+       dll_index = (PVOID) -1;                                               \
       }                                                                              \
     }                                                                        \
     break;                                                                   \
index b990b25acb8c477a9ac6efb9d3e3c64302385dad..056c5f6185a58416eaa14cd3facbd0a7e8b13558 100644 (file)
@@ -19,6 +19,7 @@ extern "C" {
 #endif
 
 #ifdef __INSIDE_CYGWIN__
+#ifndef __x86_64__
 struct __group16
 {
   char *gr_name;
@@ -26,19 +27,12 @@ struct __group16
   __gid16_t gr_gid;
   char **gr_mem;
 };
+#endif
 
-struct __group32
-{
-  char *gr_name;
-  char *gr_passwd;
-  __gid32_t gr_gid;
-  char **gr_mem;
-};
-
-struct __group32 * getgrgid32 (__gid32_t gid);
-struct __group32 * getgrnam32 (const char *name);
-__gid32_t getgid32 ();
-__gid32_t getegid32 ();
+struct group * getgrgid32 (gid_t gid);
+struct group * getgrnam32 (const char *name);
+gid_t getgid32 ();
+gid_t getegid32 ();
 #endif
 
 extern int getgrouplist (const char *, gid_t, gid_t *, int *);
index 7837788225fc32e04242a79714d0c1415c3b5784..c660d960ab122262db63d2669d98d4b8b06a7f58 100644 (file)
@@ -1,6 +1,6 @@
 /* sys/ipc.h
 
-   Copyright 2001, 2002 Red Hat Inc.
+   Copyright 2001, 2002, 2012, 2013 Red Hat Inc.
    Written by Robert Collins <rbtcollins@hotmail.com>
 
 This file is part of Cygwin.
@@ -13,6 +13,7 @@ details. */
 #define _CYGWIN_IPC_H
 
 #include <sys/types.h>
+#include <stdint.h>
 
 #ifdef __cplusplus
 extern "C"
index 8679786dd11b1d814911903da1c12b7a2bbcf9d2..c737971eae13de8da71b94f8b032b31541add930 100644 (file)
@@ -1,6 +1,6 @@
 /* sys/msg.h
 
-   Copyright 2002 Red Hat Inc.
+   Copyright 2002, 2012, 2013 Red Hat Inc.
    Written by Conrad Scott <conrad.scott@dsl.pipex.com>
 
 This file is part of Cygwin.
@@ -32,11 +32,11 @@ extern "C"
 
 /* Used for the number of messages in the message queue.
  */
-typedef unsigned long msgqnum_t;
+typedef uint32_t msgqnum_t;
 
 /* Used for the number of bytes allowed in a message queue.
  */
-typedef unsigned long msglen_t;
+typedef uint32_t msglen_t;
 
 struct msqid_ds
 {
@@ -66,27 +66,27 @@ struct msqid_ds
  */
 struct msginfo
 {
-  long msgmax;         /* Maximum number of bytes per
+  int32_t msgmax;      /* Maximum number of bytes per
                           message. */
-  long msgmnb;         /* Maximum number of bytes on any one
+  int32_t msgmnb;      /* Maximum number of bytes on any one
                           message queue. */
-  long msgmni;         /* Maximum number of message queues,
+  int32_t msgmni;      /* Maximum number of message queues,
                           system wide. */
-  long msgtql;         /* Maximum number of messages, system
+  int32_t msgtql;      /* Maximum number of messages, system
                           wide. */
-  long msgssz;         /* Size of a message segment, must be
+  int32_t msgssz;      /* Size of a message segment, must be
                           small power of 2 greater than 4. */
-  long msgseg;         /* Number of message segments */
-  long msg_spare[2];
+  int32_t msgseg;      /* Number of message segments */
+  int32_t msg_spare[2];
 };
 
 /* Buffer type for msgctl (MSG_INFO, ...) as used by ipcs(8).
  */
 struct msg_info
 {
-  long msg_ids;                /* Number of allocated queues. */
-  long msg_num;                /* Number of messages, system wide. */
-  long msg_tot;                /* Size in bytes of messages, system wide. */
+  int32_t msg_ids;             /* Number of allocated queues. */
+  int32_t msg_num;             /* Number of messages, system wide. */
+  int32_t msg_tot;             /* Size in bytes of messages, system wide. */
 };
 #endif /* _KERNEL */
 
index af7a42f3638ccda0555b5c4e8f5676b62772ef4a..71592e52fc04055ba54912ee8772862593b7cedd 100644 (file)
@@ -1,6 +1,6 @@
 /* sys/sem.h
 
-   Copyright 2002 Red Hat Inc.
+   Copyright 2002, 2012, 2013 Red Hat Inc.
    Written by Conrad Scott <conrad.scott@dsl.pipex.com>
 
 This file is part of Cygwin.
@@ -67,23 +67,23 @@ struct sembuf
  */
 struct seminfo
 {
-  long semmni;         /* Maximum number of unique semaphore
+  int32_t semmni;      /* Maximum number of unique semaphore
                           sets, system wide. */
-  long semmns;         /* Maximum number of semaphores,
+  int32_t semmns;      /* Maximum number of semaphores,
                           system wide. */
-  long semmsl;         /* Maximum number of semaphores per
+  int32_t semmsl;      /* Maximum number of semaphores per
                           semaphore set. */
-  long semopm;         /* Maximum number of operations per
+  int32_t semopm;      /* Maximum number of operations per
                           semop call. */
-  long semmnu;         /* Maximum number of undo structures,
+  int32_t semmnu;      /* Maximum number of undo structures,
                           system wide. */
-  long semume;         /* Maximum number of undo entries per
+  int32_t semume;      /* Maximum number of undo entries per
                           undo structure. */
-  long semvmx;         /* Maximum semaphore value. */
-  long semaem;         /* Maximum adjust-on-exit value. */
-  long semmap;         /* # of entries in semaphore map */
-  long semusz;         /* size in bytes of undo structure */
-  long sem_spare[2];
+  int32_t semvmx;      /* Maximum semaphore value. */
+  int32_t semaem;      /* Maximum adjust-on-exit value. */
+  int32_t semmap;      /* # of entries in semaphore map */
+  int32_t semusz;      /* size in bytes of undo structure */
+  int32_t sem_spare[2];
 };
 
 /* Buffer type for semctl (SEM_INFO, ...) as used by ipcs(8).
index 2c882012c9037e2e66db19239d47c27a2b9c37a8..c585993796cf1fe7403438a37384353c5fdf6049 100644 (file)
@@ -1,6 +1,6 @@
 /* sys/shm.h
 
-   Copyright 2001, 2002 Red Hat Inc.
+   Copyright 2001, 2002, 2012, 2013 Red Hat Inc.
    Written by Robert Collins <rbtcollins@hotmail.com>
 
 This file is part of Cygwin.
@@ -40,12 +40,12 @@ extern "C"
 
 /* Unsigned integer used for the number of current attaches.
  */
-typedef unsigned int shmatt_t;
+typedef uint32_t shmatt_t;
 
 struct shmid_ds
 {
   struct ipc_perm    shm_perm; /* Operation permission structure. */
-  size_t             shm_segsz;        /* Size of segment in bytes. */
+  uint32_t           shm_segsz;        /* Size of segment in bytes. */
   pid_t              shm_lpid; /* Process ID of last operation. */
   pid_t              shm_cpid; /* Process ID of creator. */
   shmatt_t           shm_nattch;/* Number of current attaches. */
@@ -69,17 +69,20 @@ struct shmid_ds
  */
 struct shminfo
 {
-  long shmmax;         /* Maximum size in bytes of a shared
+  int32_t shmmax;      /* Maximum size in bytes of a shared
                           memory segment. */
-  long shmmin;         /* Minimum size in bytes of a shared
+  int32_t shmmin;      /* Minimum size in bytes of a shared
                           memory segment. */
-  long shmmni;         /* Maximum number of shared memory
+  int32_t shmmni;      /* Maximum number of shared memory
                           segments, system wide. */
-  long shmseg;         /* Maximum number of shared memory
+  int32_t shmseg;      /* Maximum number of shared memory
                           segments attached per process. */
-  long shmall;         /* Maximum number of bytes of shared
-                          memory, system wide. */
-  long shm_spare[4];
+  int32_t shmall;      /* Maximum number of bytes of shared
+                          memory, system wide.
+                          Note that XSI IPC shared memory allocation is
+                          restricted to a bit less than 2 Gigs, even on
+                          64 bit, so using an int32_t here is sufficient. */
+  int32_t shm_spare[4];
 };
 
 /* Buffer type for shmctl (SHM_INFO, ...) as used by ipcs(8).
@@ -87,9 +90,9 @@ struct shminfo
 struct shm_info
 {
 #define shm_ids used_ids
-  long used_ids;       /* Number of allocated segments. */
-  long shm_tot;                /* Size in bytes of allocated segments. */
-  long shm_atts;       /* Number of attached segments, system
+  int32_t used_ids;    /* Number of allocated segments. */
+  int32_t shm_tot;     /* Size in bytes of allocated segments. */
+  int32_t shm_atts;    /* Number of attached segments, system
                           wide. */
 };
 #endif /* _KERNEL */
index 268b5eb7460cf9d468ea4f7732c362d71ea0aae9..3d74c9c8d9a804db66992cc6622aaf2db6c25819 100644 (file)
 #ifndef _CYGWIN_SIGNAL_H
 #define _CYGWIN_SIGNAL_H
 
+#include <bits/wordsize.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
+
+#ifdef __x86_64__
+
+struct _uc_fpxreg {
+  __uint16_t significand[4];
+  __uint16_t exponent;
+  __uint16_t padding[3];
+};
+
+struct _uc_xmmreg {
+  __uint32_t element[4];
+};
+
 struct _fpstate
 {
-  unsigned long cw;
-  unsigned long sw;
-  unsigned long tag;
-  unsigned long ipoff;
-  unsigned long cssel;
-  unsigned long dataoff;
-  unsigned long datasel;
-  unsigned char _st[80];
-  unsigned long nxst;
+  __uint16_t cwd;
+  __uint16_t swd;
+  __uint16_t ftw;
+  __uint16_t fop;
+  __uint64_t rip;
+  __uint64_t rdp;
+  __uint32_t mxcsr;
+  __uint32_t mxcr_mask;
+  struct _uc_fpxreg st[8];
+  struct _uc_xmmreg xmm[16];
+  __uint32_t padding[24];
 };
 
 struct ucontext
 {
-  unsigned long cr2;
-  unsigned long dr0;
-  unsigned long dr1;
-  unsigned long dr2;
-  unsigned long dr3;
-  unsigned long dr6;
-  unsigned long dr7;
+  __uint64_t p1home;
+  __uint64_t p2home;
+  __uint64_t p3home;
+  __uint64_t p4home;
+  __uint64_t p5home;
+  __uint64_t p6home;
+  __uint32_t cr2;
+  __uint32_t mxcsr;
+  __uint16_t cs;
+  __uint16_t ds;
+  __uint16_t es;
+  __uint16_t fs;
+  __uint16_t gs;
+  __uint16_t ss;
+  __uint32_t eflags;
+  __uint64_t dr0;
+  __uint64_t dr1;
+  __uint64_t dr2;
+  __uint64_t dr3;
+  __uint64_t dr6;
+  __uint64_t dr7;
+  __uint64_t rax;
+  __uint64_t rcx;
+  __uint64_t rdx;
+  __uint64_t rbx;
+  __uint64_t rsp;
+  __uint64_t rbp;
+  __uint64_t rsi;
+  __uint64_t rdi;
+  __uint64_t r8;
+  __uint64_t r9;
+  __uint64_t r10;
+  __uint64_t r11;
+  __uint64_t r12;
+  __uint64_t r13;
+  __uint64_t r14;
+  __uint64_t r15;
+  __uint64_t rip;
+  struct _fpstate fpregs;
+  __uint64_t vcx;
+  __uint64_t dbc;
+  __uint64_t btr;
+  __uint64_t bfr;
+  __uint64_t etr;
+  __uint64_t efr;
+  __uint8_t _internal;
+  __uint64_t oldmask;
+};
+
+#else /* !x86_64 */
+
+struct _uc_fpreg
+{
+  __uint16_t significand[4];
+  __uint16_t exponent;
+};
+
+struct _fpstate
+{
+  __uint32_t cw;
+  __uint32_t sw;
+  __uint32_t tag;
+  __uint32_t ipoff;
+  __uint32_t cssel;
+  __uint32_t dataoff;
+  __uint32_t datasel;
+  struct _uc_fpreg _st[8];
+  __uint32_t nxst;
+};
+
+struct ucontext
+{
+  __uint32_t cr2;
+  __uint32_t dr0;
+  __uint32_t dr1;
+  __uint32_t dr2;
+  __uint32_t dr3;
+  __uint32_t dr6;
+  __uint32_t dr7;
   struct _fpstate fpstate;
-  unsigned long gs;
-  unsigned long fs;
-  unsigned long es;
-  unsigned long ds;
-  unsigned long edi;
-  unsigned long esi;
-  unsigned long ebx;
-  unsigned long edx;
-  unsigned long ecx;
-  unsigned long eax;
-  unsigned long ebp;
-  unsigned long eip;
-  unsigned long cs;
-  unsigned long eflags;
-  unsigned long esp;
-  unsigned long ss;
-  unsigned char _internal;
-  unsigned long oldmask;
+  __uint32_t gs;
+  __uint32_t fs;
+  __uint32_t es;
+  __uint32_t ds;
+  __uint32_t edi;
+  __uint32_t esi;
+  __uint32_t ebx;
+  __uint32_t edx;
+  __uint32_t ecx;
+  __uint32_t eax;
+  __uint32_t ebp;
+  __uint32_t eip;
+  __uint32_t cs;
+  __uint32_t eflags;
+  __uint32_t esp;
+  __uint32_t ss;
+  __uint8_t _internal;
+  __uint32_t oldmask;
 };
 
-#define __COPY_CONTEXT_SIZE ((unsigned) &((struct ucontext *) 0)->_internal)
+#endif /* !x86_64 */
+
+#define __COPY_CONTEXT_SIZE ((size_t) (uintptr_t) &((struct ucontext *) 0)->_internal)
 
 typedef union sigval
 {
@@ -208,7 +299,13 @@ enum
                                           perform notification */
 };
 
+#if __WORDSIZE == 64
+typedef __uint64_t sigset_t;
+#else
+/* FIXME: We should probably raise the # of signals for 32 bit as well.
+          Unfortunately this is an ABI change so requires some forethought. */
 typedef __uint32_t sigset_t;
+#endif
 
 typedef void (*_sig_func_ptr)(int);
 
@@ -274,10 +371,15 @@ struct sigaction
 #define        SIGUSR1 30      /* user defined signal 1 */
 #define        SIGUSR2 31      /* user defined signal 2 */
 
+#if __WORDSIZE == 64
+#define NSIG   65      /* signal 0 implied */
+#else
+#define NSIG   33      /* signal 0 implied */
+#endif
+
 /* Real-Time signals per SUSv3.  RT_SIGMAX is defined as 8 in limits.h */
 #define SIGRTMIN 32
-#define SIGRTMAX ((SIGRTMIN) + 0)
-#define NSIG   33      /* signal 0 implied */
+#define SIGRTMAX (NSIG - 1)
 
 #define SIG_HOLD ((_sig_func_ptr)2)    /* Signal in signal mask */
 
index eec7962e8c8564d6b87ebc37dbe7601f9cfe0b89..aed729a730285e3a84d98391e67f17aaef1d0a4e 100644 (file)
@@ -55,8 +55,8 @@ struct sockaddr_storage {
 
 struct ucred {
   pid_t                        pid;
-  __uid32_t            uid;
-  __gid32_t            gid;
+  uid_t                        uid;
+  gid_t                        gid;
 };
 
 struct linger {
index 13c1e3bed32b5a11adee70a472d67e70937fae13..ed96fafd98b5f232088a135f089268eeadaa493a 100644 (file)
@@ -16,7 +16,26 @@ details. */
 extern "C" {
 #endif
 
+struct stat
+{
+  dev_t         st_dev;
+  ino_t         st_ino;
+  mode_t        st_mode;
+  nlink_t       st_nlink;
+  uid_t         st_uid;
+  gid_t         st_gid;
+  dev_t         st_rdev;
+  off_t         st_size;
+  timestruc_t   st_atim;
+  timestruc_t   st_mtim;
+  timestruc_t   st_ctim;
+  blksize_t     st_blksize;
+  blkcnt_t      st_blocks;
+  timestruc_t   st_birthtim;
+};
+
 #if defined (__INSIDE_CYGWIN__) || defined (_COMPILING_NEWLIB)
+#ifndef __x86_64__
 struct __stat32
 {
   __dev16_t    st_dev;
@@ -34,49 +53,14 @@ struct __stat32
   __blkcnt32_t  st_blocks;
   long          st_spare4[2];
 };
+#endif
 
-struct __stat64
-{
-  __dev32_t     st_dev;
-  __ino64_t     st_ino;
-  mode_t        st_mode;
-  nlink_t       st_nlink;
-  __uid32_t     st_uid;
-  __gid32_t     st_gid;
-  __dev32_t     st_rdev;
-  _off64_t      st_size;
-  timestruc_t   st_atim;
-  timestruc_t   st_mtim;
-  timestruc_t   st_ctim;
-  blksize_t     st_blksize;
-  __blkcnt64_t  st_blocks;
-  timestruc_t   st_birthtim;
-};
-
-extern int fstat64 (int fd, struct __stat64 *buf);
-extern int stat64 (const char *file_name, struct __stat64 *buf);
-extern int lstat64 (const char *file_name, struct __stat64 *buf);
+extern int fstat64 (int fd, struct stat *buf);
+extern int stat64 (const char *file_name, struct stat *buf);
+extern int lstat64 (const char *file_name, struct stat *buf);
 
 #endif
 
-struct stat
-{
-  dev_t         st_dev;
-  ino_t         st_ino;
-  mode_t        st_mode;
-  nlink_t       st_nlink;
-  uid_t         st_uid;
-  gid_t         st_gid;
-  dev_t         st_rdev;
-  off_t         st_size;
-  timestruc_t   st_atim;
-  timestruc_t   st_mtim;
-  timestruc_t   st_ctim;
-  blksize_t     st_blksize;
-  blkcnt_t      st_blocks;
-  timestruc_t   st_birthtim;
-};
-
 #define st_atime st_atim.tv_sec
 #define st_mtime st_mtim.tv_sec
 #define st_ctime st_ctim.tv_sec
index 3d183a94b6716cfb9fb91a9ac80d7a1d3e4f51c5..838555002e8df7a050dce3cc573540226333ce52 100644 (file)
@@ -1,6 +1,6 @@
 /* cygwin/sysproto.h
 
-   Copyright 2003, 2005 Red Hat, Inc.
+   Copyright 2003, 2005, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
index d1b7670bc2a6dd5506969a84782d017c7c8610e2..3dbc372a3102c347eb11f55446571312dc3562d1 100644 (file)
@@ -26,10 +26,10 @@ time_t __cdecl timegm (struct tm *);
 
 #ifndef __STRICT_ANSI__
 
-extern int daylight __asm__ ("__daylight");
+extern int daylight __asm__ (_SYMSTR (_daylight));
 
 #ifndef __timezonefunc__
-extern long timezone __asm__ ("__timezone");
+extern long timezone __asm__ (_SYMSTR (_timezone));
 #endif
 
 #endif /*__STRICT_ANSI__*/
index cbb4b4492a75ee72776f124be9b8133a1373c6d1..54c0c5ba5e35f8e80aa08b5591b1f8189a316daa 100644 (file)
@@ -19,6 +19,7 @@ extern "C"
 
 #include <stdint.h>
 #include <endian.h>
+#include <bits/wordsize.h>
 
 #ifndef __timespec_t_defined
 #define __timespec_t_defined
@@ -32,68 +33,72 @@ typedef struct timespec timestruc_t;
 
 #ifndef __off_t_defined
 #define __off_t_defined
+/* Based on the newlib definitions. */
+#if __WORDSIZE == 64
+typedef _off_t off_t;
+#else
 typedef _off64_t off_t;
+#endif
 #endif /*__off_t_defined*/
 
 typedef __loff_t loff_t;
 
 #ifndef __dev_t_defined
 #define __dev_t_defined
-typedef short __dev16_t;
-typedef unsigned long __dev32_t;
-typedef __dev32_t dev_t;
+typedef __int16_t __dev16_t;
+typedef __uint32_t dev_t;
 #endif /*__dev_t_defined*/
 
 #ifndef __blksize_t_defined
 #define __blksize_t_defined
-typedef long blksize_t;
+typedef __int32_t blksize_t;
 #endif /*__blksize_t_defined*/
 
 #ifndef __blkcnt_t_defined
 #define __blkcnt_t_defined
-typedef long __blkcnt32_t;
-typedef long long __blkcnt64_t;
-typedef __blkcnt64_t  blkcnt_t;
+typedef __int32_t __blkcnt32_t;
+typedef __int64_t blkcnt_t;
 #endif /*__blkcnt_t_defined*/
 
 #ifndef __fsblkcnt_t_defined
 #define __fsblkcnt_t_defined
+/* Keep as is.  32 bit on i386, 64 bit on x86_64. */
 typedef unsigned long fsblkcnt_t;
 #endif /* __fsblkcnt_t_defined */
 
 #ifndef __fsfilcnt_t_defined
 #define __fsfilcnt_t_defined
+/* Keep as is.  32 bit on i386, 64 bit on x86_64. */
 typedef unsigned long fsfilcnt_t;
 #endif /* __fsfilcnt_t_defined */
 
 #ifndef __uid_t_defined
 #define __uid_t_defined
 typedef unsigned short __uid16_t;
-typedef unsigned long  __uid32_t;
-typedef __uid32_t uid_t;
+typedef __uint32_t uid_t;
 #endif /*__uid_t_defined*/
 
 #ifndef __gid_t_defined
 #define __gid_t_defined
 typedef unsigned short __gid16_t;
-typedef unsigned long  __gid32_t;
-typedef __gid32_t gid_t;
+typedef __uint32_t gid_t;
 #endif /*__gid_t_defined*/
 
 #ifndef __ino_t_defined
 #define __ino_t_defined
-typedef unsigned long __ino32_t;
-typedef unsigned long long __ino64_t;
-typedef __ino64_t ino_t;
+#ifndef __x86_64__
+typedef __uint32_t __ino32_t;
+#endif
+typedef __uint64_t ino_t;
 #endif /*__ino_t_defined*/
 
 /* Generic ID type, must match at least pid_t, uid_t and gid_t in size. */
 #ifndef __id_t_defined
 #define __id_t_defined
-typedef unsigned long id_t;
+typedef __uint32_t id_t;
 #endif /* __id_t_defined */
 
-#if defined (__INSIDE_CYGWIN__)
+#if defined (__INSIDE_CYGWIN__) && !defined (__x86_64__)
 struct __flock32 {
        short    l_type;        /* F_RDLCK, F_WRLCK, or F_UNLCK */
        short    l_whence;      /* flag to choose starting offset */
@@ -102,14 +107,6 @@ struct __flock32 {
        short    l_pid;         /* returned with F_GETLK */
        short    l_xxx;         /* reserved for future use */
 };
-
-struct __flock64 {
-       short    l_type;        /* F_RDLCK, F_WRLCK, or F_UNLCK */
-       short    l_whence;      /* flag to choose starting offset */
-       _off64_t l_start;       /* relative offset, in bytes */
-       _off64_t l_len;         /* length, in bytes; 0 means lock to EOF */
-       pid_t    l_pid;         /* returned with F_GETLK */
-};
 #endif
 
 struct flock {
index 7284c58ef9b0252c87e8da3ecff890060ad72265..e8c45c7c2d8695d95a75e75a50011ca950ef68e2 100644 (file)
@@ -1,7 +1,7 @@
 /* version.h -- Cygwin version numbers and accompanying documentation.
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
index d4900bb2436bd2d210d98c4d4b525894fdbd664d..57e9096b44ecb2752145eb1311e92be849fb5637 100644 (file)
@@ -41,7 +41,7 @@ typedef struct {
        struct _ftsent *fts_cur;        /* current node */
        struct _ftsent *fts_child;      /* linked list of children */
        struct _ftsent **fts_array;     /* sort array */
-       __dev32_t fts_dev;              /* starting device # */
+       dev_t fts_dev;                  /* starting device # */
        char *fts_path;                 /* path for this descent */
        int fts_rfd;                    /* fd for root */
        int fts_pathlen;                /* sizeof(path) */
@@ -88,8 +88,8 @@ typedef struct _ftsent {
        u_short fts_pathlen;            /* strlen(fts_path) */
        u_short fts_namelen;            /* strlen(fts_name) */
 
-       __ino64_t fts_ino;              /* inode */
-       __dev32_t fts_dev;              /* device */
+       ino_t fts_ino;                  /* inode */
+       dev_t fts_dev;                  /* device */
        nlink_t fts_nlink;              /* link count */
 
 #define        FTS_ROOTPARENTLEVEL     -1
@@ -123,11 +123,7 @@ typedef struct _ftsent {
 #define        FTS_SKIP         4              /* discard node */
        u_short fts_instr;              /* fts_set() instructions */
 
-#ifdef __INSIDE_CYGWIN__
-       struct __stat64 *fts_statp;     /* stat(2) information */
-#else
        struct stat *fts_statp;         /* stat(2) information */
-#endif
        char *fts_name;                 /* file name */
        FTS *fts_fts;                   /* back pointer to main FTS */
 } FTSENT;
index 4f53bf5d61f267e53c9e28fc16adfcc666fb53c0..c0025a7c686812464e92279b1bba384675384e31 100644 (file)
@@ -55,15 +55,9 @@ struct FTW {
 };
 
 __BEGIN_DECLS
-#ifdef __INSIDE_CYGWIN__
-int    ftw(const char *, int (*)(const char *, const struct __stat64 *, int), int);
-int    nftw(const char *, int (*)(const char *, const struct __stat64 *, int,
-           struct FTW *), int, int);
-#else
 int    ftw(const char *, int (*)(const char *, const struct stat *, int), int);
 int    nftw(const char *, int (*)(const char *, const struct stat *, int,
            struct FTW *), int, int);
-#endif
 __END_DECLS
 
 #endif /* !_FTW_H */
index 93f2d7e9420fbfdc0290ff2ec852ce9338c0a50b..35745196b11b5b07ced13cd8501dbb6d4598a4aa 100644 (file)
@@ -61,14 +61,8 @@ typedef struct {
        void (*gl_closedir)(void *);
        struct dirent *(*gl_readdir)(void *);
        void *(*gl_opendir)(const char *);
-#if defined (__INSIDE_CYGWIN__)
-       int (*gl_lstat) __P((const char *, struct __stat64 *));
-       int (*gl_stat) __P((const char *, struct __stat64 *));
-#else
-
        int (*gl_lstat) __P((const char *, struct stat *));
        int (*gl_stat) __P((const char *, struct stat *));
-#endif
 } glob_t;
 
 /* Believed to have been introduced in 1003.2-1992 */
index cc1d8970a553a71983a6f48f18e0787ad2a75233..eb60e79e4f9f52537a22fe5ffe64765c2cace182 100644 (file)
@@ -14,13 +14,14 @@ details. */
 #include <stdint.h>
 #define __need_wchar_t
 #include <stddef.h>
+#include <bits/wordsize.h>
 
 /* C99 requires that in C++ the following macros should be defined only
    if requested. */
 #if !defined (__cplusplus) || defined (__STDC_FORMAT_MACROS) \
     || defined (__INSIDE_CYGWIN__)
 
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define __PRI64 "l"
 #define __PRIFAST "l"
 #define __PRIPTR "l"
@@ -144,7 +145,7 @@ details. */
 
 /* fscanf() macros for signed integers */
 
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define __SCN64 "l"
 #define __SCNFAST "l"
 #define __SCNPTR "l"
index de9f39e0a8a717edbe22b8647d786e0978f2937c..517f871fed9ddda71ba4d14be855971ac98e80a2 100644 (file)
@@ -18,9 +18,10 @@ extern "C" {
 /*
  * Function to return a Win32 HANDLE from a fd.
  */
-extern long get_osfhandle(int);
-extern int setmode (int __fd, int __mode);
-int access(const char *__path, int __amode);
+extern long _get_osfhandle(int);
+#define get_osfhandle(i) _get_osfhandle(i)
+extern int _setmode (int __fd, int __mode);
+#define setmode(f,m) _setmode((f),(m))
 
 #ifdef __cplusplus
 };
index 20723ab1d9677ee793017db89b42324c790e994d..e093d283d73ca7cab4eba28f150d70bc6107e7dc 100644 (file)
@@ -1,7 +1,7 @@
 /* limits.h
 
    Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2011, 2012 Red Hat, Inc.
+   2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -12,6 +12,7 @@ details. */
 #ifndef _LIMITS_H___
 
 #include <features.h>
+#include <bits/wordsize.h>
 
 #ifndef _MACH_MACHLIMITS_H_
 
@@ -24,15 +25,15 @@ details. */
 
 /* Number of bits in a `char'.  */
 #undef CHAR_BIT
-#define CHAR_BIT 8
+#define CHAR_BIT __CHAR_BIT__
 
 /* Number of bits in a `long'.  */
 #undef LONG_BIT
-#define LONG_BIT 32
+#define LONG_BIT (__SIZEOF_LONG__ * __CHAR_BIT__)
 
 /* Number of bits in a `int'.  */
 #undef WORD_BIT
-#define WORD_BIT 32
+#define WORD_BIT (__SIZEOF_INT__ * __CHAR_BIT__)
 
 /* Maximum length of a multibyte character.  */
 #ifndef MB_LEN_MAX
@@ -89,14 +90,14 @@ details. */
 /* Minimum and maximum values a `signed long int' can hold.
    (Same as `int').  */
 #ifndef __LONG_MAX__
-#ifndef __alpha__
-#define __LONG_MAX__ 2147483647L
-#else
+#if __WORDSIZE == 64
 #define __LONG_MAX__ 9223372036854775807L
+#else
+#define __LONG_MAX__ 2147483647L
 # endif /* __alpha__ */
 #endif
 #undef LONG_MIN
-#define LONG_MIN (-LONG_MAX-1)
+#define LONG_MIN (-LONG_MAX-1L)
 #undef LONG_MAX
 #define LONG_MAX __LONG_MAX__
 
@@ -221,9 +222,9 @@ details. */
 #define PTHREAD_DESTRUCTOR_ITERATIONS 1
 
 /* Maximum number of data keys that can be created by a process. */
-/* Tls has 64 items for pre win2000 - and we don't want to use them all :] */
+/* Tls has 1088 items - and we don't want to use them all :] */
 #undef PTHREAD_KEYS_MAX
-#define PTHREAD_KEYS_MAX 32
+#define PTHREAD_KEYS_MAX 1024
 
 /* Minimum size in bytes of thread stack storage. */
 /* Actually the minimum stack size is somewhat of a split personality.
@@ -242,9 +243,14 @@ details. */
 /* #define PTHREAD_THREADS_MAX unspecified */
 
 /* Maximum number of realtime signals reserved for application use. */
-/* FIXME: We only support one realtime signal but _POSIX_RTSIG_MAX is 8. */
+/* FIXME: We only support one realtime signal in 32 bit mode, but
+        _POSIX_RTSIG_MAX is 8. */
 #undef RTSIG_MAX
+#if __WORDSIZE == 64
+#define RTSIG_MAX 33
+#else
 #define RTSIG_MAX 1
+#endif
 
 /* Maximum number of semaphores that a process may have. */
 /* Windows allows any arbitrary number of semaphores per process. */
index db87904ef9a25bd3b59d25a2f3973727e73a591d..5a0c13054118a0ecfc67e908f3defba2219e5b1b 100644 (file)
@@ -33,9 +33,7 @@ struct mntent *getmntent_r (FILE *, struct mntent *, char *, int);
 int endmntent (FILE *__filep);
 #endif
 
-#ifdef __CYGWIN__
-/* Only include paths.h if building for Cygwin.  This avoids including
-   newlib headers when building the native tools in winsup/utils. */
+#ifndef _NOMNTENT_MACROS
 
 #include <paths.h>
 
@@ -52,7 +50,7 @@ int endmntent (FILE *__filep);
 #define MOUNTED _PATH_MOUNTED
 #endif
 
-#endif /* __CYGWIN__ */
+#endif /* !_NOMNTENT_MACROS */
 
 #ifdef __cplusplus
 };
index 3c8a50d8375c557f5b86a383344103df832e86f6..b670884a703d7a3ebb98bdb6515ee9a0a324c214 100644 (file)
@@ -11,6 +11,8 @@ details. */
 #ifndef _STDINT_H
 #define _STDINT_H
 
+#include <bits/wordsize.h>
+
 /* Exact-width integer types */
 
 #ifndef __int8_t_defined
@@ -18,7 +20,7 @@ details. */
 typedef signed char int8_t;
 typedef short int16_t;
 typedef int int32_t;
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef long int64_t;
 #else
 typedef long long int64_t;
@@ -31,7 +33,7 @@ typedef unsigned short uint16_t;
 #define __uint32_t_defined
 typedef unsigned int uint32_t;
 #endif
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef unsigned long uint64_t;
 #else
 typedef unsigned long long uint64_t;
@@ -42,7 +44,7 @@ typedef unsigned long long uint64_t;
 typedef signed char int_least8_t;
 typedef short int_least16_t;
 typedef int int_least32_t;
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef long int_least64_t;
 #else
 typedef long long int_least64_t;
@@ -51,7 +53,7 @@ typedef long long int_least64_t;
 typedef unsigned char uint_least8_t;
 typedef unsigned short uint_least16_t;
 typedef unsigned int uint_least32_t;
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef unsigned long uint_least64_t;
 #else
 typedef unsigned long long uint_least64_t;
@@ -60,7 +62,7 @@ typedef unsigned long long uint_least64_t;
 /* Fastest minimum-width integer types */
 
 typedef signed char int_fast8_t;
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef long int_fast16_t;
 typedef long int_fast32_t;
 typedef long int_fast64_t;
@@ -71,7 +73,7 @@ typedef long long int_fast64_t;
 #endif
 
 typedef unsigned char uint_fast8_t;
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef unsigned long uint_fast16_t;
 typedef unsigned long uint_fast32_t;
 typedef unsigned long uint_fast64_t;
@@ -85,13 +87,13 @@ typedef unsigned long long uint_fast64_t;
 
 #ifndef __intptr_t_defined
 #define __intptr_t_defined
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef long intptr_t;
 #else
 typedef int intptr_t;
 #endif
 #endif
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef unsigned long uintptr_t;
 #else
 typedef unsigned int uintptr_t;
@@ -99,7 +101,7 @@ typedef unsigned int uintptr_t;
 
 /* Greatest-width integer types */
 
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 typedef long intmax_t;
 typedef unsigned long uintmax_t;
 #else
@@ -157,7 +159,7 @@ typedef unsigned long long uintmax_t;
 /* Limits of fastest minimum-width integer types */
 
 #define INT_FAST8_MIN (-128)
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define INT_FAST16_MIN (-__I64(9223372036854775807) - 1)
 #define INT_FAST32_MIN (-__I64(9223372036854775807) - 1)
 #else
@@ -167,7 +169,7 @@ typedef unsigned long long uintmax_t;
 #define INT_FAST64_MIN (-__I64(9223372036854775807) - 1)
 
 #define INT_FAST8_MAX (127)
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define INT_FAST16_MAX (__I64(9223372036854775807))
 #define INT_FAST32_MAX (__I64(9223372036854775807))
 #else
@@ -177,7 +179,7 @@ typedef unsigned long long uintmax_t;
 #define INT_FAST64_MAX (__I64(9223372036854775807))
 
 #define UINT_FAST8_MAX (255)
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define UINT_FAST16_MAX (__U64(18446744073709551615))
 #define UINT_FAST32_MAX (__U64(18446744073709551615))
 #else
@@ -188,9 +190,9 @@ typedef unsigned long long uintmax_t;
 
 /* Limits of integer types capable of holding object pointers */
 
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define INTPTR_MIN (-__I64(9223372036854775807) - 1)
-#define INTPTR_MAX (__I64(9223372036854775807)
+#define INTPTR_MAX (__I64(9223372036854775807))
 #define UINTPTR_MAX (__U64(18446744073709551615))
 #else
 #define INTPTR_MIN (-2147483647 - 1)
@@ -207,7 +209,7 @@ typedef unsigned long long uintmax_t;
 /* Limits of other integer types */
 
 #ifndef PTRDIFF_MIN
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define PTRDIFF_MIN (-9223372036854775807L - 1)
 #define PTRDIFF_MAX (9223372036854775807L)
 #else
@@ -224,7 +226,7 @@ typedef unsigned long long uintmax_t;
 #endif
 
 #ifndef SIZE_MAX
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define SIZE_MAX (18446744073709551615UL)
 #else
 #define SIZE_MAX (4294967295U)
@@ -258,7 +260,7 @@ typedef unsigned long long uintmax_t;
 #define INT8_C(x) x
 #define INT16_C(x) x
 #define INT32_C(x) x
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define INT64_C(x) x ## L
 #else
 #define INT64_C(x) x ## LL
@@ -267,7 +269,7 @@ typedef unsigned long long uintmax_t;
 #define UINT8_C(x) x
 #define UINT16_C(x) x
 #define UINT32_C(x) x ## U
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define UINT64_C(x) x ## UL
 #else
 #define UINT64_C(x) x ## ULL
@@ -275,7 +277,7 @@ typedef unsigned long long uintmax_t;
 
 /* Macros for greatest-width integer constant expressions */
 
-#ifdef __x86_64__
+#if __WORDSIZE == 64
 #define INTMAX_C(x) x ## L
 #define UINTMAX_C(x) x ## UL
 #else
index ac7b2336ab28c46f4566e0f9f5424e8c9534ffcf..354d0eb4cd0a88e773ae9124222c2c1fe21a9150 100644 (file)
@@ -1,7 +1,7 @@
 /* sys/cygwin.h
 
    Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011, 2012 Red Hat, Inc.
+   2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -14,6 +14,7 @@ details. */
 
 #include <sys/types.h>
 #include <limits.h>
+#include <stdint.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -21,8 +22,9 @@ extern "C" {
 
 #define _CYGWIN_SIGNAL_STRING "cYgSiGw00f"
 
+#ifndef __x86_64__
 /* DEPRECATED INTERFACES.  These are restricted to MAX_PATH length.
-   Don't use in modern applications. */
+   Don't use in modern applications.  They don't exist on x86_64. */
 extern int cygwin_win32_to_posix_path_list (const char *, char *)
   __attribute__ ((deprecated));
 extern int cygwin_win32_to_posix_path_list_buf_size (const char *)
@@ -39,6 +41,7 @@ extern int cygwin_conv_to_posix_path (const char *, char *)
   __attribute__ ((deprecated));
 extern int cygwin_conv_to_full_posix_path (const char *, char *)
   __attribute__ ((deprecated));
+#endif /* !__x86_64__ */
 
 /* Use these interfaces in favor of the above. */
 
@@ -200,7 +203,7 @@ CW_TOKEN_RESTRICTED    = 1
 };
 
 #define CW_NEXTPID     0x80000000      /* or with pid to get next one */
-unsigned long cygwin_internal (cygwin_getinfo_types, ...);
+uintptr_t cygwin_internal (cygwin_getinfo_types, ...);
 
 /* Flags associated with process_state */
 enum
@@ -255,12 +258,14 @@ struct per_process
 
   /* The offset of these 3 values can never change. */
   /* magic_biscuit is the size of this class and should never change. */
-  unsigned long magic_biscuit;
-  unsigned long dll_major;
-  unsigned long dll_minor;
+  uint32_t magic_biscuit;
+  uint32_t dll_major;
+  uint32_t dll_minor;
 
   struct _reent **impure_ptr_ptr;
+#ifndef __x86_64__
   char ***envptr;
+#endif
 
   /* Used to point to the memory machine we should use.  Usually these
      point back into the dll, but they can be overridden by the user. */
@@ -284,10 +289,10 @@ struct per_process
   /* For future expansion of values set by the app. */
   void (*premain[4]) (int, char **, struct per_process *);
 
-  /* non-zero of ctors have been run.  Inherited from parent. */
-  int run_ctors_p;
+  /* non-zero if ctors have been run.  Inherited from parent. */
+  int32_t run_ctors_p;
 
-  DWORD unused[7];
+  DWORD_PTR unused[7];
 
   /* Pointers to real operator new/delete functions for forwarding.  */
   struct per_process_cxx_malloc *cxx_malloc;
@@ -298,7 +303,11 @@ struct per_process
   DWORD api_minor;             /*  linked with */
   /* For future expansion, so apps won't have to be relinked if we
      add an item. */
-  DWORD unused2[3];
+#ifdef __x86_64__
+  DWORD_PTR unused2[5];
+#else
+  DWORD_PTR unused2[3];
+#endif
   void *pseudo_reloc_start;
   void *pseudo_reloc_end;
   void *image_base;
@@ -310,7 +319,7 @@ struct per_process
 #endif
   struct _reent *impure_ptr;
 };
-#define per_process_overwrite ((unsigned) &(((struct per_process *) NULL)->threadinterface))
+#define per_process_overwrite offsetof (struct per_process, threadinterface)
 
 #ifdef _PATH_PASSWD
 extern HANDLE cygwin_logon_user (const struct passwd *, const char *);
@@ -335,11 +344,11 @@ extern void cygwin_premain3 (int, char **, struct per_process *);
 #define EXTERNAL_PINFO_VERSION_32_LP  2
 #define EXTERNAL_PINFO_VERSION EXTERNAL_PINFO_VERSION_32_LP
 
-#ifndef _SYS_TYPES_H
-typedef unsigned short __uid16_t;
-typedef unsigned short __gid16_t;
-typedef unsigned long __uid32_t;
-typedef unsigned long __gid32_t;
+#ifndef __uid_t_defined
+typedef __uint16_t __uid16_t;
+typedef __uint16_t __gid16_t;
+typedef __uint32_t uid_t;
+typedef __uint32_t gid_t;
 #endif
 
 struct external_pinfo
@@ -367,8 +376,8 @@ struct external_pinfo
   DWORD process_state;
 
   /* Only available if version >= EXTERNAL_PINFO_VERSION_32_BIT */
-  __uid32_t uid32;
-  __gid32_t gid32;
+  uid_t uid32;
+  gid_t gid32;
 
   /* Only available if version >= EXTERNAL_PINFO_VERSION_32_LP */
   char *progname_long;
index bcb1a2488b6ad25972fdb2866e9b745bcc669d38..027fa8f7363635db2073a6131df4619b2135b25c 100644 (file)
@@ -1,6 +1,7 @@
 /* Posix dirent.h for WIN32.
 
-   Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2010, 2012 Red Hat, Inc.
+   Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2010, 2012,
+   2013 Red Hat, Inc.
 
    This software is a copyrighted work licensed under the terms of the
    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 
 #define __DIRENT_VERSION       2
 
+#ifndef __x86_64__
 #pragma pack(push,4)
+#endif
 #define _DIRENT_HAVE_D_TYPE
 struct dirent
 {
-  long __d_version;                    /* Used internally */
-  __ino64_t d_ino;
+  uint32_t __d_version;                        /* Used internally */
+  ino_t d_ino;
   unsigned char d_type;
   unsigned char __d_unused1[3];
   __uint32_t __d_internal1;
   char d_name[NAME_MAX + 1];
 };
+#ifndef __x86_64__
 #pragma pack(pop)
+#endif
 
 #define d_fileno d_ino                 /* BSD compatible definition */
 
+#ifdef __x86_64__
+#define __DIRENT_COOKIE 0xcdcd8484
+#else
 #define __DIRENT_COOKIE 0xdede4242
+#endif
 
+#ifndef __x86_64__
 #pragma pack(push,4)
+#endif
 typedef struct __DIR
 {
   /* This is first to set alignment in non _COMPILING_NEWLIB case.  */
   unsigned long __d_cookie;
   struct dirent *__d_dirent;
   char *__d_dirname;                   /* directory name with trailing '*' */
-  long __d_position;                   /* used by telldir/seekdir */
+  __int32_t __d_position;                      /* used by telldir/seekdir */
   int __d_fd;
-  unsigned __d_internal;
+  uintptr_t __d_internal;
   void *__handle;
   void *__fh;
   unsigned __flags;
 } DIR;
+#ifndef __x86_64__
 #pragma pack(pop)
+#endif
 
 DIR *opendir (const char *);
 DIR *fdopendir (int);
index d487a272da44a361c2fd8982a9412191b49760d9..d9419d150e272d45cdf00b0ad7daec25a2ad2cba 100644 (file)
@@ -34,7 +34,7 @@ extern "C" {
 #define RLIMIT_NLIMITS  7              /* upper bound of RLIMIT_* defines */
 #define RLIM_NLIMITS    RLIMIT_NLIMITS
 
-#define RLIM_INFINITY  (0xffffffffUL)
+#define RLIM_INFINITY  (~0UL)
 #define RLIM_SAVED_MAX RLIM_INFINITY
 #define RLIM_SAVED_CUR RLIM_INFINITY
 
index c58b45cda25969357a1ca7ad7f6eefb767cb882a..164af1e50f6b617c50084cb600a1d204a778f05e 100644 (file)
@@ -1,7 +1,7 @@
 /* sys/strace.h
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008,
-   2010, 2011 Red Hat, Inc.
+   2010, 2011, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -29,6 +29,7 @@ details. */
 #define _SYS_STRACE_H
 
 #include <stdarg.h>
+#include <sys/types.h>
 
 #ifdef __cplusplus
 
@@ -49,7 +50,7 @@ public:
   void prntf (unsigned, const char *func, const char *, ...) /*__attribute__ ((regparm(3)))*/;
   void vprntf (unsigned, const char *func, const char *, va_list ap) /*__attribute__ ((regparm(3)))*/;
   void wm (int message, int word, int lon) __attribute__ ((regparm(3)));
-  void write_childpid (unsigned long) __attribute__ ((regparm (3)));
+  void write_childpid (pid_t) __attribute__ ((regparm (3)));
   bool attached () const {return _active == 3;}
   bool active () const {return _active & 1;}
   unsigned char& active_val () {return _active;}
index f99cbf9bea7744c8af14892d61c2d400fbec331d..78e88b94bca808851d63813bab3fea542ef4be41 100644 (file)
@@ -1,7 +1,7 @@
 /* init.cc
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -96,13 +96,6 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
          && (PVOID) &_my_tls > (PVOID) &test_stack_marker
          && _my_tls.isinitialized ())
        _my_tls.remove (0);
-      /* Windows 2000 has a bug in NtTerminateThread.  Instead of releasing
-        the stack at teb->DeallocationStack it uses the value of
-        teb->Tib.StackLimit to evaluate the stack address.  So we just claim
-        there is no stack. */
-      if (NtCurrentTeb ()->DeallocationStack == NULL
-         && !wincap.has_stack_size_param_is_a_reservation ())
-       NtCurrentTeb ()->Tib.StackLimit = NULL;
       break;
     }
 
index fa02db4d4babb0a24fc6e4574cb5d1b4b2d8576d..326c6e28b7e1c2eff9756aef92f3f199af1a233a 100644 (file)
@@ -1,7 +1,7 @@
 /* ioctl.cc: ioctl routines.
 
-   Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2008, 2009, 2011
-   Red Hat, Inc.
+   Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2008, 2009, 2011,
+   2012 Red Hat, Inc.
 
    Written by Doug Evans of Cygnus Support
    dje@cygnus.com
@@ -33,7 +33,7 @@ ioctl (int fd, int cmd, ...)
   char *argp = va_arg (ap, char *);
   va_end (ap);
 
-  debug_printf ("ioctl(fd %d, cmd %p)", fd, cmd);
+  debug_printf ("ioctl(fd %d, cmd %y)", fd, cmd);
   int res;
   /* FIXME: This stinks.  There are collisions between cmd types
      depending on whether fd is associated with a pty master or not.
@@ -58,6 +58,6 @@ ioctl (int fd, int cmd, ...)
   res = cfd->ioctl (cmd, argp);
 
 out:
-  syscall_printf ("%R = ioctl(%d, %p, ...)", res, fd, cmd);
+  syscall_printf ("%R = ioctl(%d, %y, ...)", res, fd, cmd);
   return res;
 }
index 5bf8b20fb39cd36dbda3c640edbcd0d8435772d0..3be8666fb8586b21bf19387ef5cfb9384589fbc2 100644 (file)
@@ -18,7 +18,7 @@
 extern "C" key_t
 ftok (const char *path, int id)
 {
-  struct __stat64 statbuf;
+  struct stat statbuf;
   key_t tmp;
   if (stat64 (path, &statbuf))
     {
index 5b6aae77188ad39ceea451f495db408ca7a3c0ee..6eeb2dc4347c1b08677706d51d50ea4c92db6c0f 100644 (file)
@@ -310,7 +310,7 @@ CreateFileMappingW (HANDLE hFile, LPSECURITY_ATTRIBUTES lpAttributes,
   ULONG attribs = flProtect & (SEC_COMMIT | SEC_IMAGE | SEC_NOCACHE
                               | SEC_RESERVE);
   LARGE_INTEGER size = {{ LowPart  : dwMaximumSizeLow,
-                         HighPart : dwMaximumSizeHigh }};
+                         HighPart : (LONG) dwMaximumSizeHigh }};
   PLARGE_INTEGER psize = size.QuadPart ? &size : NULL;
 
   if (prot & (PAGE_READWRITE | PAGE_WRITECOPY
index 98b9e4b866a323b1e594dd89d0675d75425320e3..6b7ccaaff6261e9a73e8046032ef660509593406 100644 (file)
@@ -1,5 +1,5 @@
 /* This struct of LC_MESSAGES data has been generated by fetching locale
-   data from a Linux system using glibc-2.14-5.x86_64 on 2011-09-01. */
+   data from a Linux system using glibc-2.16-28.fc18.x86_64 on 2013-03-30. */
 
 struct lc_msg_t
 {
@@ -46,12 +46,14 @@ static struct lc_msg_t lc_msg[] =
   { "ber_DZ", L"^[Bb].*", L"^[YyNn].*", L"b\x0259li", L"yox" },
   { "ber_MA", L"^[Bb].*", L"^[YyNn].*", L"b\x0259li", L"yox" },
   { "bg_BG", L"^[+1\x0414\x0434\x0044\x0064YyOo].*", L"^[-0\x041d\x043dNnKk].*", L"", L"" },
+  { "bho_IN", L"^[yY].*", L"^[nN].*", L"", L"" },
   { "bn_BD", L"^[\x09b9\x09cd\x09af\x09be\x0981yY]", L"^[\x09a8\x09benN]", L"\x09b9\x09cd\x09af\x09be\x0981", L"\x09a8\x09be" },
   { "bn_IN", L"^[\x09b9\x09cd\x09af\x09be\x0981yY]", L"^[\x09a8\x09benN]", L"\x09b9\x09cd\x09af\x09be\x0981", L"\x09a8\x09be" },
   { "bo_CN", L"^[\x0f68Yy].*", L"^[\x0f58Nn].*", L"\x0f68\x0f72\x0f53", L"\x0f58\x0f7a\x0f53" },
   { "bo_IN", L"^[\x0f68Yy].*", L"^[\x0f58Nn].*", L"\x0f68\x0f72\x0f53", L"\x0f58\x0f7a\x0f53" },
   { "br_FR", L"^[oOyY].*", L"^[nN].*", L"", L"" },
   { "br_FR@euro", L"^[oOyY].*", L"^[nN].*", L"", L"" },
+  { "brx_IN", L"^(\x0928\x0902\x0917\x094c|[yY])", L"^(\x0928\x0919\x093e|[nN])", L"", L"" },
   { "bs_BA", L"^[dDyY]*.", L"^[nN]*.", L"", L"" },
   { "byn_ER", L"^[yY].*", L"^[nN].*", L"", L"" },
   { "ca_AD", L"^[sSyY].*", L"^[nN].*", L"", L"" },
@@ -74,6 +76,7 @@ static struct lc_msg_t lc_msg[] =
   { "de_DE@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" },
   { "de_LU", L"^[jJyY].*", L"^[nN].*", L"", L"" },
   { "de_LU@euro", L"^[jJyY].*", L"^[nN].*", L"", L"" },
+  { "doi_IN", L"^(\x0911\x0939|[yY])", L"^(\x0928\x093e|[nN])", L"", L"" },
   { "dv_MV", L"^[yY].*", L"^[nN].*", L"", L"" },
   { "dz_BT", L"^[\x0f68Yy].*", L"^[\x0f58Nn].*", L"\x0f68\x0f72\x0f53", L"\x0f58\x0f7a\x0f53" },
   { "el_CY", L"^[\x03bd\x039dyY].*", L"^[\x03bf\x039fnN].*", L"", L"" },
@@ -101,6 +104,7 @@ static struct lc_msg_t lc_msg[] =
   { "es_CL", L"^[sSyY].*", L"^[nN].*", L"", L"" },
   { "es_CO", L"^[sSyY].*", L"^[nN].*", L"", L"" },
   { "es_CR", L"^[sSyY].*", L"^[nN].*", L"", L"" },
+  { "es_CU", L"^[sSyY].*", L"^[nN].*", L"", L"" },
   { "es_DO", L"^[sSyY].*", L"^[nN].*", L"", L"" },
   { "es_EC", L"^[sSyY].*", L"^[nN].*", L"", L"" },
   { "es_ES", L"^[sSyY].*", L"^[nN].*", L"", L"" },
@@ -122,8 +126,8 @@ static struct lc_msg_t lc_msg[] =
   { "eu_ES@euro", L"^[bBsSyY].*", L"^[eEnN].*", L"", L"" },
   { "fa_IR", L"^[yY\x0622\x0628Hf].*", L"^[nN\x062e\x0646ok].*", L"", L"" },
   { "ff_SN", L"^[yYeE].*", L"^[nNaA].*", L"", L"" },
-  { "fi_FI", L"^[KkJjYy].*", L"^[NnEe].*", L"", L"" },
-  { "fi_FI@euro", L"^[KkJjYy].*", L"^[NnEe].*", L"", L"" },
+  { "fi_FI", L"^[KkYy].*", L"^[EeNn].*", L"", L"" },
+  { "fi_FI@euro", L"^[KkYy].*", L"^[EeNn].*", L"", L"" },
   { "fil_PH", L"[oOyY].*", L"[hHnN].*", L"oo", L"hindi" },
   { "fo_FO", L"^[JjYy].*", L"^[Nn].*", L"", L"" },
   { "fr_BE", L"^[oOjJyY1].*", L"^[nN0].*", L"", L"" },
@@ -187,6 +191,7 @@ static struct lc_msg_t lc_msg[] =
   { "lo_LA", L"^[yY\x0ea1]", L"^[nN\x0e9a]", L"\x0ec1\x0ea1\x0ec8\x0e99", L"\x0e9a\x0ecd\x0ec8\x0ec1\x0ea1\x0ec8\x0e99" },
   { "lt_LT", L"^[TtYy].*", L"^[Nn].*", L"", L"" },
   { "lv_LV", L"^[JjYy].*", L"^[Nn].*", L"", L"" },
+  { "mag_IN", L"^[yY].*", L"^[nN].*", L"", L"" },
   { "mai_IN", L"^[yY].*", L"^[nN].*", L"", L"" },
   { "mg_MG", L"^[eEyY].*", L"^[tTnN].*", L"", L"" },
   { "mhr_RU", L"^[\x0422\x0442Yy].*", L"^[\x0423\x0443Nn].*", L"", L"" },
@@ -194,6 +199,7 @@ static struct lc_msg_t lc_msg[] =
   { "mk_MK", L"^[\x0414\x0434\x0044\x0064Yy1].*", L"^[\x041d\x043dNn0].*", L"\x0434\x0430", L"\x043d\x0435" },
   { "ml_IN", L"^[\x0d05\x0d24\x0d46yY]", L"^[\x0d05\x0d32\x0d4d\x0d32nN]", L"\x0d05\x0d24\x0d46", L"\x0d05\x0d32\x0d4d\x0d32" },
   { "mn_MN", L"^[\x0442\x0422yY].*", L"^[\x04af\x04aenN].*", L"", L"" },
+  { "mni_IN", L"^[yY]", L"^[nN]", L"Yes", L"No" },
   { "mr_IN", L"^(Yes|[yY])", L"^(No|[nN])", L"", L"" },
   { "ms_MY", L"^[yY]", L"^[tT]", L"Ya", L"Tidak" },
   { "mt_MT", L"^(Yes|[yY])", L"^(No|[nN])", L"", L"" },
@@ -230,6 +236,7 @@ static struct lc_msg_t lc_msg[] =
   { "ru_UA", L"^[\x0414\x0434Yy].*", L"^[\x041d\x043dNn].*", L"", L"" },
   { "rw_RW", L"^[yY]", L"^[nNoO]", L"", L"" },
   { "sa_IN", L"^[aAyY].*", L"^[nN].*", L"", L"" },
+  { "sat_IN", L"^(\x0939\x094b\x092f|[yY])", L"^(\x092c\x093e\x0919|[nN])", L"", L"" },
   { "sc_IT", L"^[sSjJoOyY].*", L"^[nN].*", L"", L"" },
   { "sd_IN", L"^[\x0646yY].*", L"^[\x0644nN].*", L"\x0646\x0639\x0645", L"\x0644\x0627" },
   { "sd_IN@devanagari", L"^[yY].*", L"^[nN].*", L"", L"" },
@@ -261,6 +268,7 @@ static struct lc_msg_t lc_msg[] =
   { "sw_KE", L"^[nNyY].*", L"^[hHlL].*", L"", L"" },
   { "sw_TZ", L"^[nNyY].*", L"^[hHlL].*", L"", L"" },
   { "ta_IN", L"^[\x0b86\x0bae\x0bcdyY]", L"^[\x0b87\x0bb2\x0bcd\x0bb2\x0bc8nN]", L"\x0b86\x0bae\x0bcd", L"\x0b87\x0bb2\x0bcd\x0bb2\x0bc8" },
+  { "ta_LK", L"^[\x0b86\x0bae\x0bcdyY]", L"^[\x0b87\x0bb2\x0bcd\x0bb2\x0bc8nN]", L"\x0b86\x0bae\x0bcd", L"\x0b87\x0bb2\x0bcd\x0bb2\x0bc8" },
   { "te_IN", L"^[yY\x0c05].*", L"^[nN\x0c15].*", L"\x0c05\x0c35\x0c28\x0c41", L"\x0c15\x0c3e\x0c26\x0c41" },
   { "tg_TJ", L"^[\x04b2\x04b3\x0425\x0445\x0414\x0434Yy].*", L"^[\x041d\x043dNn].*", L"\x0434\x0430", L"\x043d\x0435\x0442" },
   { "th_TH", L"^[yY\x0e0a]", L"^[nN\x0e21]", L"\x0e43\x0e0a\x0e48", L"\x0e44\x0e21\x0e48\x0e43\x0e0a\x0e48" },
@@ -277,6 +285,8 @@ static struct lc_msg_t lc_msg[] =
   { "tt_RU@iqtelif", L"^[Ee].*", L"^[YyNn].*", L"ey\x00ed", L"yuq" },
   { "ug_CN", L"^[1JjsSyYoO].*", L"^[0nN].*", L"yes", L"no" },
   { "uk_UA", L"^([Yy+]|[\x0422\x0442][\x0410\x0430][\x041a\x043a]?)$", L"^([Nn-]|[\x041d\x043d][\x0406\x0456])$", L"\x0442\x0430\x043a", L"\x043d\x0456" },
+  { "unm_US", L"^[yY].*", L"^[kKmM].*", L"", L"" },
+  { "ur_IN", L"^[\x06c1yY].*", L"^[\x0646nN].*", L"\x06c1\x0627\x06ba", L"\x0646\x06c1\x06cc\x06ba" },
   { "ur_PK", L"^[yY\x0647\x0628\x0066].*", L"^[nN\x0646o].*", L"\x0628\x0644\x0643\x0644", L"\x0646\x0647\x064a\x06ba" },
   { "uz_UZ", L"^[yY\x0647\x0628\x0066].*", L"^[nN\x0646o].*", L"\x0628\x0644\x0643\x0644", L"\x0646\x0647\x064a\x06ba" },
   { "uz_UZ@cyrillic", L"^[\x04b2\x04b3Yy].*", L"^[\x0419\x0439Nn].*", L"\x04b2\x0430", L"\x0419\x045e\x049b" },
@@ -285,6 +295,7 @@ static struct lc_msg_t lc_msg[] =
   { "wa_BE", L"^[oOyYaAwW].*", L"^[nN].*", L"Oyi", L"Neni" },
   { "wa_BE@euro", L"^[oOyYaAwW].*", L"^[nN].*", L"Oyi", L"Neni" },
   { "wae_CH", L"^[jJyY].*", L"^[nN].*", L"Ja", L"Nei" },
+  { "wal_ET", L"^[yY].*", L"^[nN].*", L"", L"" },
   { "wo_SN", L"^[wWyY].*", L"^[dDnN].*", L"", L"" },
   { "xh_ZA", L"^[yYeE]", L"^[nNhH]", L"", L"" },
   { "yi_US", L"^[Yy\x05d9].*", L"^[Nn\x05e0\x05e7].*", L"\x05d9\x05d0\x05b8", L"\x05e7\x05f2\x05df" },
index 83cbda82815e90e650775d74cb2569bf7eeea81b..b22859ec031285b4720537b78f7f0c47b84f8ea1 100644 (file)
@@ -1,6 +1,7 @@
 /* _cygwin_crt0_common.cc: common crt0 function for cygwin crt0's.
 
-   Copyright 2000, 2001, 2002, 2003, 2004, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   Copyright 2000, 2001, 2002, 2003, 2004, 2009, 2010, 2011, 2012, 2013
+   Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -16,26 +17,42 @@ details. */
    unnecessarily.  */
 #define WEAK __attribute__ ((weak))
 
+#ifdef __x86_64__
+#define REAL_ZNWX              "__real__Znwm"
+#define REAL_ZNAX              "__real__Znam"
+#define REAL_ZNWX_NOTHROW_T    "__real__ZnwmRKSt9nothrow_t"
+#define REAL_ZNAX_NOTHROW_T    "__real__ZnamRKSt9nothrow_t"
+#else
+#define REAL_ZNWX              "___real__Znwj"
+#define REAL_ZNAX              "___real__Znaj"
+#define REAL_ZNWX_NOTHROW_T    "___real__ZnwjRKSt9nothrow_t"
+#define REAL_ZNAX_NOTHROW_T    "___real__ZnajRKSt9nothrow_t"
+#endif
+#define REAL_ZDLPV             _SYMSTR (__real__ZdlPv)
+#define REAL_ZDAPV             _SYMSTR (__real__ZdaPv)
+#define REAL_ZDLPV_NOTHROW_T   _SYMSTR (__real__ZdlPvRKSt9nothrow_t)
+#define REAL_ZDAPV_NOTHROW_T   _SYMSTR (__real__ZdaPvRKSt9nothrow_t)
+
 /* Use asm names to bypass the --wrap that is being applied to redirect all other
    references to these operators toward the redirectors in the Cygwin DLL; this
    way we can record what definitions were visible at final link time but still
    send all calls to the redirectors.  */
 extern WEAK void *operator new(std::size_t sz) throw (std::bad_alloc)
-                       __asm__ ("___real__Znwj");
+                       __asm__ (REAL_ZNWX);
 extern WEAK void *operator new[](std::size_t sz) throw (std::bad_alloc)
-                       __asm__ ("___real__Znaj");
+                       __asm__ (REAL_ZNAX);
 extern WEAK void operator delete(void *p) throw()
-                       __asm__ ("___real__ZdlPv ");
+                       __asm__ (REAL_ZDLPV);
 extern WEAK void operator delete[](void *p) throw()
-                       __asm__ ("___real__ZdaPv");
+                       __asm__ (REAL_ZDAPV);
 extern WEAK void *operator new(std::size_t sz, const std::nothrow_t &nt) throw()
-                       __asm__ ("___real__ZnwjRKSt9nothrow_t");
+                       __asm__ (REAL_ZNWX_NOTHROW_T);
 extern WEAK void *operator new[](std::size_t sz, const std::nothrow_t &nt) throw()
-                       __asm__ ("___real__ZnajRKSt9nothrow_t");
+                       __asm__ (REAL_ZNAX_NOTHROW_T);
 extern WEAK void operator delete(void *p, const std::nothrow_t &nt) throw()
-                       __asm__ ("___real__ZdlPvRKSt9nothrow_t");
+                       __asm__ (REAL_ZDLPV_NOTHROW_T);
 extern WEAK void operator delete[](void *p, const std::nothrow_t &nt) throw()
-                       __asm__ ("___real__ZdaPvRKSt9nothrow_t");
+                       __asm__ (REAL_ZDAPV_NOTHROW_T);
 
 /* Avoid an info message from linker when linking applications.  */
 extern __declspec(dllimport) struct _reent *_impure_ptr;
@@ -47,12 +64,19 @@ extern int __dynamically_loaded;
 
 extern "C"
 {
+#ifndef __x86_64__
 char **environ;
+#endif
 int _fmode;
 
 extern char __RUNTIME_PSEUDO_RELOC_LIST__;
 extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
+#ifdef __x86_64__
+extern char __image_base__;
+#define _image_base__ __image_base__
+#else
 extern char _image_base__;
+#endif
 
 struct per_process_cxx_malloc __cygwin_cxx_malloc =
 {
@@ -93,7 +117,9 @@ _cygwin_crt0_common (MainFunc f, per_process *u)
 
   u->ctors = &__CTOR_LIST__;
   u->dtors = &__DTOR_LIST__;
+#ifndef __x86_64__
   u->envptr = &environ;
+#endif
   if (uwasnull)
     _impure_ptr = u->impure_ptr;       /* Use field initialized in newer DLLs. */
   else
@@ -145,10 +171,17 @@ _cygwin_crt0_common (MainFunc f, per_process *u)
   u->hmodule = GetModuleHandle (0);
 
   /* variables for fork */
+#ifdef __x86_64__
+  u->data_start = &__data_start__;
+  u->data_end = &__data_end__;
+  u->bss_start = &__bss_start__;
+  u->bss_end = &__bss_end__;
+#else
   u->data_start = &_data_start__;
   u->data_end = &_data_end__;
   u->bss_start = &_bss_start__;
   u->bss_end = &_bss_end__;
+#endif
   u->pseudo_reloc_start = &__RUNTIME_PSEUDO_RELOC_LIST__;
   u->pseudo_reloc_end = &__RUNTIME_PSEUDO_RELOC_LIST_END__;
   u->image_base = &_image_base__;
index 1d0b6f0c370c3cd4904114e82f6899bcd7af64db..d289e7824296719275fc87469eb967fa3450632c 100644 (file)
@@ -16,7 +16,7 @@ extern "C" {
 struct per_process;
 typedef int (*MainFunc) (int argc, char *argv[], char **env);
 int __stdcall _cygwin_crt0_common (MainFunc, struct per_process *);
-int dll_dllcrt0 (HMODULE, struct per_process *);
+PVOID dll_dllcrt0 (HMODULE, struct per_process *);
 
 #ifdef __cplusplus
 }
index 54c3caf4cc127db3c701d55cab41399d2f635259..543073c895c8755e8007eaeb409d3f3e70f17267 100644 (file)
@@ -16,7 +16,7 @@ details. */
 #include "crt0.h"
 
 /* for a loaded dll */
-int
+PVOID
 cygwin_attach_dll (HMODULE h, MainFunc f)
 {
   static struct per_process u;
index b77e02e8ee80f75ed1e909e507fc7b3b0be8886b..20e4e7712721959c3ee1c938cbfc8962daa74463 100644 (file)
@@ -1,6 +1,6 @@
 /* premain0.c
 
-   Copyright 2000 Red Hat, Inc.
+   Copyright 2000, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -9,6 +9,7 @@ Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
 void
-cygwin_premain0(int argc, char **argv)
+cygwin_premain0(int argc __attribute__ ((unused)),
+               char **argv __attribute__ ((unused)))
 {
 }
index 99aeac916b9acb71e439df43c94856811a519ce8..e30d112658d6cca6118a2434a31d867ed59ae9fa 100644 (file)
@@ -1,6 +1,6 @@
 /* premain1.c
 
-   Copyright 2000 Red Hat, Inc.
+   Copyright 2000, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -9,6 +9,7 @@ Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
 void
-cygwin_premain1(int argc, char **argv)
+cygwin_premain1(int argc __attribute__ ((unused)),
+               char **argv __attribute__ ((unused)))
 {
 }
index a89e76ec3db7a50e3895d3414dd4c6e355d3178c..437562dc5e62dee51d40c10d707111a1305a9a1a 100644 (file)
@@ -1,6 +1,6 @@
 /* premain2.c
 
-   Copyright 2000 Red Hat, Inc.
+   Copyright 2000, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -9,6 +9,7 @@ Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
 void
-cygwin_premain2(int argc, char **argv)
+cygwin_premain2(int argc __attribute__ ((unused)),
+               char **argv __attribute__ ((unused)))
 {
 }
index c5b99b91845efd3c6189ca9d72ec720e0deb38eb..b377586000f28ea029be56e3146d3662c5d59254 100644 (file)
@@ -1,6 +1,6 @@
 /* premain3.c
 
-   Copyright 2000 Red Hat, Inc.
+   Copyright 2000, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -9,6 +9,7 @@ Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
 void
-cygwin_premain3(int argc, char **argv)
+cygwin_premain3(int argc __attribute__ ((unused)),
+               char **argv __attribute__ ((unused)))
 {
 }
index 599df7107e6d073cfe11cc11d3cb8fa7480e6d83..66cffc7d31319b6687dbf48aad4cb8238be7cad8 100644 (file)
@@ -54,7 +54,7 @@ daemon (int nochdir, int noclose)
        break;
       default:
        /* This sleep avoids a race condition which kills the
-          child process if parent is started by a NT/W2K service.
+          child process if parent is started by a service process.
           FIXME: Is that still true? */
        Sleep (1000L);
        _exit (0);
@@ -112,7 +112,7 @@ openpty (int *amaster, int *aslave, char *name, const struct termios *termp,
     {
       grantpt (master);
       unlockpt (master);
-      __ptsname (pts, cygheap->fdtab[master]->get_unit ());
+      __ptsname (pts, cygheap->fdtab[master]->get_minor ());
       revoke (pts);
       if ((slave = open (pts, O_RDWR | O_NOCTTY)) >= 0)
        {
index 7f292a57b0023fc57c0bd2922a566ffaa92a7e2a..e82ec3fd7944140e0a811c03068d77fcf40e8e69 100644 (file)
@@ -94,7 +94,7 @@ static int     fts_ufslinks(FTS *, const FTSENT *);
 struct _fts_private {
        FTS             ftsp_fts;
        struct statfs   ftsp_statfs;
-       __dev32_t       ftsp_dev;
+       dev_t           ftsp_dev;
        int             ftsp_linksreliable;
 };
 
@@ -507,7 +507,7 @@ name:               t = sp->fts_path + NAPPEND(p->fts_parent);
 /* ARGSUSED */
 int
 fts_set(sp, p, instr)
-       FTS *sp;
+       FTS *sp __attribute__ ((unused));
        FTSENT *p;
        int instr;
 {
@@ -758,7 +758,7 @@ fts_build(sp, type)
 
                if ((p = fts_alloc(sp, dp->d_name, (int)dnamlen)) == NULL)
                        goto mem1;
-               if (dnamlen >= maxlen) {        /* include space for NUL */
+               if ((int) dnamlen >= maxlen) {  /* include space for NUL */
                        oldaddr = sp->fts_path;
                        if (fts_palloc(sp, dnamlen + len + 1)) {
                                /*
@@ -907,9 +907,9 @@ fts_stat(sp, p, follow)
        int follow;
 {
        FTSENT *t;
-       __dev32_t dev;
-       __ino64_t ino;
-       struct __stat64 *sbp, sb;
+       dev_t dev;
+       ino_t ino;
+       struct stat *sbp, sb;
        int saved_errno;
 
        /* If user needs stat info, stat buffer already allocated. */
@@ -943,7 +943,7 @@ fts_stat(sp, p, follow)
                }
        } else if (lstat64(p->fts_accpath, sbp)) {
                p->fts_errno = errno;
-err:           memset(sbp, 0, sizeof(struct __stat64));
+err:           memset(sbp, 0, sizeof(struct stat));
                return (FTS_NS);
        }
 
@@ -1041,7 +1041,7 @@ fts_alloc(sp, name, namelen)
 
        struct ftsent_withstat {
                FTSENT  ent;
-               struct  __stat64 statbuf;
+               struct  stat statbuf;
        };
 
        /*
@@ -1177,7 +1177,7 @@ fts_safe_changedir(sp, p, fd, path)
        const char *path;
 {
        int ret, oerrno, newfd;
-       struct __stat64 sb;
+       struct stat sb;
 
        newfd = fd;
        if (ISSET(FTS_NOCHDIR))
index 9863e1621950d83a180140da974ab724fcd08c28..61d1e7c216f07de8f76e2ad25f0924dfc908b416 100644 (file)
@@ -41,8 +41,8 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/ftw.c,v 1.4 2004/08/24 13:0
 #include <limits.h>
 
 int
-ftw(const char *path, int (*fn)(const char *, const struct __stat64 *, int),
-    int nfds)
+ftw(const char *path, int (*fn)(const char *, const struct stat *, int),
+    int nfds __attribute__ ((unused)))
 {
        char * const paths[2] = { (char *)path, NULL };
        FTSENT *cur;
index 01e1a76822a6f3a7d17f19fed9c3107f861bab24..43a394cf4593f0b2ed42ec06347feb8c2d3c38bd 100644 (file)
@@ -62,7 +62,7 @@ cygwin_inet_network(cp)
        in_addr_t val, base, n;
        char c;
        in_addr_t parts[4], *pp = parts;
-       int i, digit;
+       unsigned int i, digit;
 
 again:
        val = 0; base = 10; digit = 0;
index 46e8297fd9450ec20b5c4964664c90ec0628d9cc..94460ffb2f6aec5fde18b4c55af55c67203f5693 100644 (file)
@@ -37,7 +37,7 @@ details. */
  ***********************************************************************/
 
 #define PUTDOMAIN(d,p)\
- {int res = dn_comp(d, p, EndPtr - p, dnptrs, lastdnptr); p += res < 0 ? strlen(d) : res; }
+ {int res = dn_comp(d, p, EndPtr - p, dnptrs, lastdnptr); p += res < 0 ? (int) strlen(d) : res; }
 
 static u_char * write_record(unsigned char * ptr, PDNS_RECORD rr, unsigned char * EndPtr,
                           unsigned char ** dnptrs, unsigned char ** lastdnptr, int debug)
@@ -187,7 +187,8 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty
 {
   DNS_STATUS res;
   PDNS_RECORD pQueryResultsSet, rr;
-  int section, len, counts[4] = {0, 0, 0, 0}, debug = statp->options & RES_DEBUG;
+  DWORD section;
+  int len, counts[4] = {0, 0, 0, 0}, debug = statp->options & RES_DEBUG;
   unsigned char * dnptrs[256], * ptr;
 
   dnptrs[0] = AnsPtr;
@@ -309,7 +310,7 @@ static void get_registry_dns_items(PUNICODE_STRING in, res_state statp,
     size_t size = wcstombs (list, in->Buffer, in->Length);
     if (what == 0) { /* Get the addresses */
       char *ap, *srch;
-      int numAddresses = 0;
+      size_t numAddresses = 0;
       for (ap = list; ap < list + size && *ap; ap = srch) {
        /* The separation character can be 0, ' ', or ','. */
        for (srch = ap; *srch && (isdigit((unsigned) *srch) || *srch == '.' );
@@ -418,7 +419,7 @@ void get_dns_info(res_state statp)
   DWORD dwRetVal;
   IP_ADDR_STRING * pIPAddr;
   FIXED_INFO * pFixedInfo;
-  int numAddresses = 0;
+  size_t numAddresses = 0;
 
   if (statp->use_os)
   {
index 0b3a7f3ac09431f207be54a76296e2c1bba292b7..c73ad3c582af64660f2340da9adb50f3dcc6fe22 100644 (file)
@@ -177,9 +177,9 @@ static void get_resolv(res_state statp)
       if (!have_address
          && !strncasecmp("nameserver", words[0], sizes[0])) {
        for ( j = 1; j < i ; j++) {
-         unsigned int address;
+         in_addr_t address;
          address = cygwin_inet_addr(words[j]);
-         if (address == -1) {
+         if (address == INADDR_NONE) {
            DPRINTF(debug, "invalid server \"%s\"\n", words[j]);
          }
          else if (ns >= MAXNS) {
@@ -295,7 +295,7 @@ int res_ninit(res_state statp)
      Mix the upper and lower bits as they are not used equally */
   i = getpid();
   statp->id = (ushort) (getppid() ^ (i << 8) ^ (i >> 8));
-  for (i = 0; i < DIM(statp->dnsrch); i++)  statp->dnsrch[i] = 0;
+  for (i = 0; i < (int) DIM(statp->dnsrch); i++)  statp->dnsrch[i] = 0;
 
   /* resolv.conf (dns servers & search list)*/
   get_resolv(statp);
@@ -424,7 +424,7 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
               int MsgLength, unsigned char * AnsPtr, int AnsLength)
 {
   /* Current server, shared by all tasks */
-  volatile static unsigned int SServ = 0XFFFFFFFF;
+  static volatile unsigned int SServ = 0XFFFFFFFF;
   int tcp;
   const int debug = statp->options & RES_DEBUG;
 
@@ -459,7 +459,7 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr,
 
   /* Close the socket if it had been opened before a fork.
      Reuse of pid's cannot hurt */
-  if ((statp->sockfd != -1) && (statp->mypid != getpid())) {
+  if ((statp->sockfd != -1) && ((pid_t) statp->mypid != getpid())) {
     res_nclose(statp);
   }
 
@@ -625,8 +625,10 @@ int res_send( const unsigned char * MsgPtr, int MsgLength,
 *****************************************************************/
 int res_nmkquery (res_state statp,
                  int op, const char * dnameptr, int qclass, int qtype,
-                 const unsigned char * dataptr, int datalen,
-                 const unsigned char * newrr, unsigned char * buf, int buflen)
+                 const unsigned char * dataptr __attribute__ ((unused)),
+                 int datalen __attribute__ ((unused)),
+                 const unsigned char * newrr __attribute__ ((unused)),
+                 unsigned char * buf, int buflen)
 {
   int i, len;
   const char * ptr;
@@ -722,7 +724,7 @@ int res_nquerydomain( res_state statp, const char * Name, const char * DomName,
                      int Class, int Type, unsigned char * AnsPtr, int AnsLength)
 {
   char fqdn[MAXDNAME], *ptr;
-  int nlen;
+  size_t nlen;
 
   if (!DomName)
     ptr = (char *) Name;
index bb1c92381ceda1fcacc19149061e593be8d42f2e..1def24160a5f5c8f52feb5b6abfc4213f195aab2 100644 (file)
@@ -41,8 +41,8 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/nftw.c,v 1.1.2.1 2004/08/29
 #include <limits.h>
 
 int
-nftw(const char *path, int (*fn)(const char *, const struct __stat64 *, int,
-     struct FTW *), int nfds, int ftwflags)
+nftw(const char *path, int (*fn)(const char *, const struct stat *, int,
+     struct FTW *), int nfds __attribute__ ((unused)), int ftwflags)
 {
        char * const paths[2] = { (char *)path, NULL };
        struct FTW ftw;
index 16c05b01ba59c72d2c7cb46894c7c9c90a830c09..4ebdd062a78cae85a54670abb4a2cb55022ae590 100644 (file)
@@ -103,7 +103,7 @@ extern "C" {
   int cygwin_rresvport_af(int *alport, int family);
   int cygwin_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
   int cygwin_socket (int, int, int);
-  int seteuid32 (__uid32_t);
+  int seteuid32 (uid_t);
 }
 #endif
 
@@ -421,7 +421,7 @@ iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser,
            const char *luser)
 {
        const char *cp;
-       struct __stat64 sbuf;
+       struct stat sbuf;
        struct passwd *pwd;
        FILE *hostf;
        uid_t uid;
index a09828675f59f8cfbc866c1a77f5f268b7b77a04..d5548bf1571ac600ec22c3a73d8a3581d622e79f 100644 (file)
@@ -155,7 +155,7 @@ ruserpass(const char *host, char **aname, char **apass, char **aacct)
        char myname[INTERNET_MAX_HOST_NAME_LENGTH + 1];
        const char *mydomain;
        int t, i, c, usedefault = 0;
-       struct __stat64 stb;
+       struct stat stb;
 
        hdir = getenv("HOME");
        if (hdir == NULL)
index a6492f24394ddc614f10d4fd279ee8ea1dbeb801..80861b73822463790c119d273b590236a5c0979b 100755 (executable)
@@ -22,23 +22,34 @@ details.  */
    around the standard C++ memory management operators; these are the wrappers,
    but we want the compiler to know they are the malloc operators and not have
    it think they're just any old function matching 'extern "C" _wrap_*'.  */
+#ifdef __x86_64__
+#define MANGLED_ZNWX                   "__wrap__Znwm"
+#define MANGLED_ZNAX                   "__wrap__Znam"
+#define MANGLED_ZNWX_NOTHROW_T         "__wrap__ZnwmRKSt9nothrow_t"
+#define MANGLED_ZNAX_NOTHROW_T         "__wrap__ZnamRKSt9nothrow_t"
+#else
+#define MANGLED_ZNWX                   "___wrap__Znwj"
+#define MANGLED_ZNAX                   "___wrap__Znaj"
+#define MANGLED_ZNWX_NOTHROW_T         "___wrap__ZnwjRKSt9nothrow_t"
+#define MANGLED_ZNAX_NOTHROW_T         "___wrap__ZnajRKSt9nothrow_t"
+#endif
 
 extern void *operator new(std::size_t sz) throw (std::bad_alloc)
-                       __asm__ ("___wrap__Znwj");
+                       __asm__ (MANGLED_ZNWX);
 extern void *operator new[](std::size_t sz) throw (std::bad_alloc)
-                       __asm__ ("___wrap__Znaj");
+                       __asm__ (MANGLED_ZNAX);
 extern void operator delete(void *p) throw()
-                       __asm__ ("___wrap__ZdlPv");
+                       __asm__ (_SYMSTR (__wrap__ZdlPv));
 extern void operator delete[](void *p) throw()
-                       __asm__ ("___wrap__ZdaPv");
+                       __asm__ (_SYMSTR (__wrap__ZdaPv));
 extern void *operator new(std::size_t sz, const std::nothrow_t &nt) throw()
-                       __asm__ ("___wrap__ZnwjRKSt9nothrow_t");
+                       __asm__ (MANGLED_ZNWX_NOTHROW_T);
 extern void *operator new[](std::size_t sz, const std::nothrow_t &nt) throw()
-                       __asm__ ("___wrap__ZnajRKSt9nothrow_t");
+                       __asm__ (MANGLED_ZNAX_NOTHROW_T);
 extern void operator delete(void *p, const std::nothrow_t &nt) throw()
-                       __asm__ ("___wrap__ZdlPvRKSt9nothrow_t");
+                       __asm__ (_SYMSTR (__wrap__ZdlPvRKSt9nothrow_t));
 extern void operator delete[](void *p, const std::nothrow_t &nt) throw()
-                       __asm__ ("___wrap__ZdaPvRKSt9nothrow_t");
+                       __asm__ (_SYMSTR (__wrap__ZdaPvRKSt9nothrow_t));
 
 extern void *
 operator new(std::size_t sz) throw (std::bad_alloc)
index 239aaffdd9be4ed02ae6ce0c490aaa70e6038285..37a4ca0f4d4766a82206d6ce292aa4a00fa2889d 100644 (file)
@@ -1,3 +1,11 @@
+/*     $NetBSD: localtime.c,v 1.72 2012/10/28 19:02:29 christos Exp $  */
+
+/* Don't reformat the code arbitrarily.
+
+   It uses in wide parts the exact formatting as the upstream NetBSD
+   versions.  The purpose is to simplify subsequent diffs to the NetBSD
+   version, should the need arise again at one point. */
+
 /*
 ** This file is in the public domain, so clarified as of
 ** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
@@ -25,6 +33,8 @@ static char   elsieid[] = "@(#)localtime.c    7.66";
 ** (guy@auspex.com).
 */
 
+#define NO_ERROR_IN_DST_GAP
+
 /*LINTLIBRARY*/
 
 #ifndef PRIVATE_H
@@ -33,7 +43,7 @@ static char   elsieid[] = "@(#)localtime.c    7.66";
 
 /*
 ** This file is in the public domain, so clarified as of
-** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
+** 1996-06-05 by Arthur David Olson
 */
 
 /*
@@ -54,43 +64,6 @@ static char  privatehid[] = "@(#)private.h   7.48";
 #endif /* !defined NOID */
 #endif /* !defined lint */
 
-/*
-** Defaults for preprocessor symbols.
-** You can override these in your C compiler options, e.g. `-DHAVE_ADJTIME=0'.
-*/
-
-#ifndef HAVE_ADJTIME
-#define HAVE_ADJTIME           1
-#endif /* !defined HAVE_ADJTIME */
-
-#ifndef HAVE_GETTEXT
-#define HAVE_GETTEXT           0
-#endif /* !defined HAVE_GETTEXT */
-
-#ifndef HAVE_SETTIMEOFDAY
-#define HAVE_SETTIMEOFDAY      3
-#endif /* !defined HAVE_SETTIMEOFDAY */
-
-#ifndef HAVE_STRERROR
-#define HAVE_STRERROR          0
-#endif /* !defined HAVE_STRERROR */
-
-#ifndef HAVE_SYMLINK
-#define HAVE_SYMLINK           1
-#endif /* !defined HAVE_SYMLINK */
-
-#ifndef HAVE_UNISTD_H
-#define HAVE_UNISTD_H          1
-#endif /* !defined HAVE_UNISTD_H */
-
-#ifndef HAVE_UTMPX_H
-#define HAVE_UTMPX_H           0
-#endif /* !defined HAVE_UTMPX_H */
-
-#ifndef LOCALE_HOME
-#define LOCALE_HOME            "/usr/lib/locale"
-#endif /* !defined LOCALE_HOME */
-
 /*
 ** Nested includes
 */
@@ -98,102 +71,27 @@ static char        privatehid[] = "@(#)private.h   7.48";
 #include "stdio.h"
 #include "limits.h"    /* for CHAR_BIT */
 #include "stdlib.h"
-
-#if HAVE_GETTEXT - 0
-#endif /* HAVE_GETTEXT - 0 */
-
-#if HAVE_UNISTD_H - 0
 #include "unistd.h"    /* for F_OK and R_OK */
-#endif /* HAVE_UNISTD_H - 0 */
-
-#if !(HAVE_UNISTD_H - 0)
-#ifndef F_OK
-#define F_OK   0
-#endif /* !defined F_OK */
-#ifndef R_OK
-#define R_OK   4
-#endif /* !defined R_OK */
-#endif /* !(HAVE_UNISTD_H - 0) */
 
 /* Unlike <ctype.h>'s isdigit, this also works if c < 0 | c > UCHAR_MAX.  */
 #define is_digit(c) ((unsigned)(c) - '0' <= 9)
 
-/*
-** Workarounds for compilers/systems.
-*/
-
-/*
-** SunOS 4.1.1 cc lacks const.
-*/
-
-#ifndef const
-#ifndef __STDC__
-#define const
-#endif /* !defined __STDC__ */
-#endif /* !defined const */
-
-/*
-** SunOS 4.1.1 cc lacks prototypes.
-*/
-
-#ifndef P
-#ifdef __STDC__
-#define P(x)   x
-#endif /* defined __STDC__ */
-#ifndef __STDC__
-#define P(x)   ()
-#endif /* !defined __STDC__ */
-#endif /* !defined P */
-
-/*
-** SunOS 4.1.1 headers lack EXIT_SUCCESS.
-*/
-
-#ifndef EXIT_SUCCESS
-#define EXIT_SUCCESS   0
-#endif /* !defined EXIT_SUCCESS */
-
-/*
-** SunOS 4.1.1 headers lack EXIT_FAILURE.
-*/
-
-#ifndef EXIT_FAILURE
-#define EXIT_FAILURE   1
-#endif /* !defined EXIT_FAILURE */
-
-/*
-** SunOS 4.1.1 headers lack FILENAME_MAX.
-*/
-
-#ifndef FILENAME_MAX
-
-#ifndef MAXPATHLEN
-#ifdef unix
-#endif /* defined unix */
-#endif /* !defined MAXPATHLEN */
-
-#ifdef MAXPATHLEN
-#define FILENAME_MAX   MAXPATHLEN
-#endif /* defined MAXPATHLEN */
-#ifndef MAXPATHLEN
-#define FILENAME_MAX   1024            /* Pure guesswork */
-#endif /* !defined MAXPATHLEN */
-
-#endif /* !defined FILENAME_MAX */
-
-/*
-** SunOS 4.1.1 libraries lack remove.
-*/
-
-#ifndef remove
-extern int     unlink P((const char * filename));
-#define remove unlink
-#endif /* !defined remove */
+#ifndef __pure
+#if 2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)
+# define __pure __attribute__ ((__pure__))
+#else
+# define __pure /* empty */
+#endif
+#endif
 
 /*
 ** Finally, some convenience items.
 */
 
+#ifndef TYPE_INTEGRAL
+#define TYPE_INTEGRAL(type) (/*CONSTCOND*/((type) 0.5) != 0.5)
+#endif /* !defined TYPE_INTEGRAL */
+
 #ifndef TYPE_BIT
 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
 #endif /* !defined TYPE_BIT */
@@ -237,23 +135,29 @@ extern int        unlink P((const char * filename));
 #endif /* !defined GNUC_or_lint */
 #endif /* !defined INITIALIZE */
 
+#ifndef TZ_DOMAIN
+#define TZ_DOMAIN "tz"
+#endif /* !defined TZ_DOMAIN */
+
+#ifndef YEARSPERREPEAT
+#define YEARSPERREPEAT   400     /* years before a Gregorian repeat */
+#endif /* !defined YEARSPERREPEAT */
+
 /*
-** For the benefit of GNU folk...
-** `_(MSGID)' uses the current locale's message library string for MSGID.
-** The default is to use gettext if available, and use MSGID otherwise.
+** The Gregorian year averages 365.2425 days, which is 31556952 seconds.
 */
 
-#ifndef _
-#if HAVE_GETTEXT - 0
-#define _(msgid) gettext(msgid)
-#else /* !(HAVE_GETTEXT - 0) */
-#define _(msgid) msgid
-#endif /* !(HAVE_GETTEXT - 0) */
-#endif /* !defined _ */
+#ifndef AVGSECSPERYEAR
+#define AVGSECSPERYEAR   31556952L
+#endif /* !defined AVGSECSPERYEAR */
 
-#ifndef TZ_DOMAIN
-#define TZ_DOMAIN "tz"
-#endif /* !defined TZ_DOMAIN */
+#ifndef SECSPERREPEAT
+#define SECSPERREPEAT     ((int_fast64_t) YEARSPERREPEAT * (int_fast64_t) AVGSECSPERYEAR)
+#endif /* !defined SECSPERREPEAT */
+
+#ifndef SECSPERREPEAT_BITS
+#define SECSPERREPEAT_BITS      34      /* ceil(log2(SECSPERREPEAT)) */
+#endif /* !defined SECSPERREPEAT_BITS */
 
 /*
 ** UNIX was a registered trademark of UNIX System Laboratories in 1993.
@@ -312,7 +216,8 @@ static char tzfilehid[] = "@(#)tzfile.h     7.14";
 
 struct tzhead {
        char    tzh_magic[4];           /* TZ_MAGIC */
-       char    tzh_reserved[16];       /* reserved for future use */
+       char    tzh_version[1];         /* '\0' or '2' as of 2005 */
+       char    tzh_reserved[15];       /* reserved for future use */
        char    tzh_ttisgmtcnt[4];      /* coded number of trans. time flags */
        char    tzh_ttisstdcnt[4];      /* coded number of trans. time flags */
        char    tzh_leapcnt[4];         /* coded number of leap seconds */
@@ -334,18 +239,28 @@ struct tzhead {
 **     tzh_leapcnt repetitions of
 **             one (char [4])          coded leap second transition times
 **             one (char [4])          total correction after above
-**     tzh_ttisstdcnt (char)s          indexed by type; if true, transition
-**                                     time is standard time, if false,
+**     tzh_ttisstdcnt (char)s          indexed by type; if TRUE, transition
+**                                     time is standard time, if FALSE,
 **                                     transition time is wall clock time
 **                                     if absent, transition times are
 **                                     assumed to be wall clock time
-**     tzh_ttisgmtcnt (char)s          indexed by type; if true, transition
-**                                     time is UTC, if false,
+**     tzh_ttisgmtcnt (char)s          indexed by type; if TRUE, transition
+**                                     time is UTC, if FALSE,
 **                                     transition time is local time
 **                                     if absent, transition times are
 **                                     assumed to be local time
 */
 
+/*
+** If tzh_version is '2' or greater, the above is followed by a second instance
+** of tzhead and a second instance of the data in which each coded transition
+** time uses 8 rather than 4 chars,
+** then a POSIX-TZ-environment-variable-style string for use in handling
+** instants after the last transition time stored in the file
+** (with nothing between the newlines if there is no POSIX representation for
+** such instants).
+*/
+
 /*
 ** In the current implementation, "tzset()" refuses to deal with files that
 ** exceed any of the limits below.
@@ -477,25 +392,36 @@ struct tzhead {
 **     5.      They might reference tm.TM_ZONE after calling offtime.
 ** What's best to do in the above cases is open to debate;
 ** for now, we just set things up so that in any of the five cases
-** WILDABBR is used.  Another possibility:  initialize tzname[0] to the
+** WILDABBR is used. Another possibility: initialize tzname[0] to the
 ** string "tzname[0] used before set", and similarly for the other cases.
-** And another:  initialize tzname[0] to "ERA", with an explanation in the
+** And another: initialize tzname[0] to "ERA", with an explanation in the
 ** manual page of what this "time zone abbreviation" means (doing this so
 ** that tzname[0] has the "normal" length of three characters).
 */
 #define WILDABBR       "   "
 #endif /* !defined WILDABBR */
 
-static char wildabbr[] NO_COPY = WILDABBR;
+static const char      wildabbr[] = WILDABBR;
+
+static const char      gmt[] = "GMT";
 
-static char gmt[] NO_COPY = "GMT";
+/*
+** The DST rules to use if TZ has no rules and we can't load TZDEFRULES.
+** We default to US rules as of 1999-08-17.
+** POSIX 1003.1 section 8.1.1 says that the default DST rules are
+** implementation dependent; for historical reasons, US rules are a
+** common default.
+*/
+#ifndef TZDEFRULESTRING
+#define TZDEFRULESTRING ",M4.1.0,M10.5.0"
+#endif /* !defined TZDEFDST */
 
 struct ttinfo {                                /* time type information */
        long            tt_gmtoff;      /* UTC offset in seconds */
        int             tt_isdst;       /* used to set tm_isdst */
        int             tt_abbrind;     /* abbreviation list index */
-       int             tt_ttisstd;     /* true if transition is std time */
-       int             tt_ttisgmt;     /* true if transition is UTC */
+       int             tt_ttisstd;     /* TRUE if transition is std time */
+       int             tt_ttisgmt;     /* TRUE if transition is UTC */
 };
 
 struct lsinfo {                                /* leap second information */
@@ -512,19 +438,23 @@ struct lsinfo {                           /* leap second information */
 #define MY_TZNAME_MAX  255
 #endif /* !defined TZNAME_MAX */
 
-struct state {
+struct __state {
        int             leapcnt;
        int             timecnt;
        int             typecnt;
        int             charcnt;
+       int             goback;
+       int             goahead;
        time_t          ats[TZ_MAX_TIMES];
        unsigned char   types[TZ_MAX_TIMES];
        struct ttinfo   ttis[TZ_MAX_TYPES];
-       char            chars[BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt),
-                               (2 * (MY_TZNAME_MAX + 1)))];
+       char            chars[/*CONSTCOND*/BIGGEST(BIGGEST(TZ_MAX_CHARS + 1,
+                               sizeof gmt), (2 * (MY_TZNAME_MAX + 1)))];
        struct lsinfo   lsis[TZ_MAX_LEAPS];
 };
 
+typedef struct __state *timezone_t;
+
 struct rule {
        int             r_type;         /* type of rule--see below */
        int             r_day;          /* day number of rule */
@@ -537,59 +467,60 @@ struct rule {
 #define DAY_OF_YEAR            1       /* n - day of year */
 #define MONTH_NTH_DAY_OF_WEEK  2       /* Mm.n.d - month, week, day of week */
 
+typedef struct tm *(*subfun_t)(const timezone_t sp, const time_t *timep,
+                              long offset, struct tm *tmp);
+
 /*
 ** Prototypes for static functions.
 */
 
-static long            detzcode P((const char * codep));
-static const char *    getzname P((const char * strp));
-static const char *    getnum P((const char * strp, int * nump, int min,
-                               int max));
-static const char *    getsecs P((const char * strp, long * secsp));
-static const char *    getoffset P((const char * strp, long * offsetp));
-static const char *    getrule P((const char * strp, struct rule * rulep));
-static void            gmtload P((struct state * sp));
-static void            gmtsub P((const time_t * timep, long offset,
-                               struct tm * tmp));
-static void            localsub P((const time_t * timep, long offset,
-                               struct tm * tmp));
-static int             increment_overflow P((int * number, int delta));
-static int             normalize_overflow P((int * tensptr, int * unitsptr,
-                               int base));
-static void            settzname P((void));
-static time_t          time1 P((struct tm * tmp,
-                               void(*funcp) P((const time_t *,
-                               long, struct tm *)),
-                               long offset));
-static time_t          time2 P((struct tm *tmp,
-                               void(*funcp) P((const time_t *,
-                               long, struct tm*)),
-                               long offset, int * okayp));
-static time_t          time2sub P((struct tm *tmp,
-                               void(*funcp) P((const time_t *,
-                               long, struct tm*)),
-                               long offset, int * okayp, int do_norm_secs));
-static void            timesub P((const time_t * timep, long offset,
-                               const struct state * sp, struct tm * tmp));
-static int             tmcomp P((const struct tm * atmp,
-                               const struct tm * btmp));
-static time_t          transtime P((time_t janfirst, int year,
-                               const struct rule * rulep, long offset));
-static int             tzload P((const char * name, struct state * sp));
-static int             tzparse P((const char * name, struct state * sp,
-                               int lastditch));
-
-#ifdef ALL_STATE
-static struct state *  lclptr;
-static struct state *  gmtptr;
-#endif /* defined ALL_STATE */
-
-#ifndef ALL_STATE
-static struct state    lclmem;
-static struct state    gmtmem;
-#define lclptr         (&lclmem)
-#define gmtptr         (&gmtmem)
-#endif /* State Farm */
+static long            detzcode(const char * codep);
+static time_t          detzcode64(const char * codep);
+static int             differ_by_repeat(time_t t1, time_t t0);
+static const char *    getzname(const char * strp) __pure;
+static const char *    getqzname(const char * strp, const int delim) __pure;
+static const char *    getnum(const char * strp, int * nump, int min,
+                               int max);
+static const char *    getsecs(const char * strp, long * secsp);
+static const char *    getoffset(const char * strp, long * offsetp);
+static const char *    getrule(const char * strp, struct rule * rulep);
+static void            gmtload(timezone_t sp);
+static struct tm *     gmtsub(const timezone_t sp, const time_t *timep,
+                               long offset, struct tm * tmp);
+static struct tm *     localsub(const timezone_t sp, const time_t *timep,
+                               long offset, struct tm *tmp);
+static int             increment_overflow(int * number, int delta);
+static int             leaps_thru_end_of(int y) __pure;
+static int             long_increment_overflow(long * number, int delta);
+static int             long_normalize_overflow(long * tensptr,
+                               int * unitsptr, int base);
+static int             normalize_overflow(int * tensptr, int * unitsptr,
+                               int base);
+static void            settzname(void);
+static time_t          time1(const timezone_t sp, struct tm * const tmp,
+                               subfun_t funcp, const long offset);
+static time_t          time2(const timezone_t sp, struct tm * const tmp,
+                               subfun_t funcp,
+                               const long offset, int *const okayp);
+static time_t          time2sub(const timezone_t sp, struct tm * const tmp,
+                               subfun_t funcp, const long offset,
+                               int *const okayp, const int do_norm_secs);
+static struct tm *     timesub(const timezone_t sp, const time_t * timep,
+                               long offset, struct tm * tmp);
+static int             tmcomp(const struct tm * atmp,
+                               const struct tm * btmp);
+static time_t          transtime(time_t janfirst, int year,
+                               const struct rule * rulep, long offset) __pure;
+static int             typesequiv(const timezone_t sp, int a, int b);
+static int             tzload(timezone_t sp, const char * name,
+                               int doextend);
+static int             tzparse(timezone_t sp, const char * name,
+                               int lastditch);
+static void            tzset_unlocked(void);
+static long            leapcorr(time_t * timep);
+
+static timezone_t lclptr;
+static timezone_t gmtptr;
 
 #ifndef TZ_STRLEN_MAX
 #define TZ_STRLEN_MAX 255
@@ -609,8 +540,8 @@ static int          gmt_is_set;
 #undef _tzname
 
 char * tzname[2] = {
-       wildabbr,
-       wildabbr
+       (char *) wildabbr,
+       (char *) wildabbr
 };
 
 /*
@@ -618,12 +549,11 @@ char *    tzname[2] = {
 **     Except for the strftime function, these functions [asctime,
 **     ctime, gmtime, localtime] return values in one of two static
 **     objects: a broken-down time structure and an array of char.
-** Thanks to Paul Eggert (eggert@twinsun.com) for noting this.
+** Thanks to Paul Eggert for noting this.
 */
 
 static struct tm       tm;
 
-
 /* These variables are initialized by tzset.  The macro versions are
    defined in time.h, and indirect through the __imp_ pointers.  */
 
@@ -633,34 +563,46 @@ static struct tm  tm;
 #undef _daylight
 
 #ifdef USG_COMPAT
-long           timezone;       /* was time_t but POSIX requires long. */
-int            daylight;
+long                   timezone = 0;
+int                    daylight;
 #endif /* defined USG_COMPAT */
 
 #ifdef ALTZONE
-time_t         altzone;
+time_t                 altzone = 0;
 #endif /* defined ALTZONE */
 
 static long
-detzcode(const char *codep)
+detzcode(const char *const codep)
 {
-       register long   result;
-       register int    i;
+       long    result;
+       int     i;
 
-       result = (codep[0] & 0x80) ? ~0L : 0L;
+       result = (codep[0] & 0x80) ? ~0L : 0;
        for (i = 0; i < 4; ++i)
                result = (result << 8) | (codep[i] & 0xff);
        return result;
 }
 
+static time_t
+detzcode64(const char *const codep)
+{
+       time_t  result;
+       int     i;
+
+       result = (time_t)((codep[0] & 0x80) ? (~(int_fast64_t) 0) : 0);
+       for (i = 0; i < 8; ++i)
+               result = result * 256 + (codep[i] & 0xff);
+       return result;
+}
+
 static void
-settzname P((void))
+settzname (void)
 {
-       register struct state * const   sp = lclptr;
-       register int                    i;
+       timezone_t const        sp = lclptr;
+       int                     i;
 
-       tzname[0] = wildabbr;
-       tzname[1] = wildabbr;
+       tzname[0] = (char *) wildabbr;
+       tzname[1] = (char *) wildabbr;
 #ifdef USG_COMPAT
        daylight = 0;
        timezone = 0;
@@ -668,14 +610,12 @@ settzname P((void))
 #ifdef ALTZONE
        altzone = 0;
 #endif /* defined ALTZONE */
-#ifdef ALL_STATE
        if (sp == NULL) {
-               tzname[0] = tzname[1] = gmt;
+               tzname[0] = tzname[1] = (char *) gmt;
                return;
        }
-#endif /* defined ALL_STATE */
        for (i = 0; i < sp->typecnt; ++i) {
-               register const struct ttinfo * const    ttisp = &sp->ttis[i];
+               const struct ttinfo * const     ttisp = &sp->ttis[i];
 
                tzname[ttisp->tt_isdst] =
                        &sp->chars[ttisp->tt_abbrind];
@@ -694,9 +634,7 @@ settzname P((void))
        ** And to get the latest zone names into tzname. . .
        */
        for (i = 0; i < sp->timecnt; ++i) {
-               register const struct ttinfo * const    ttisp =
-                                                       &sp->ttis[
-                                                               sp->types[i]];
+               const struct ttinfo *const ttisp = &sp->ttis[sp->types[i]];
 
                tzname[ttisp->tt_isdst] =
                        &sp->chars[ttisp->tt_abbrind];
@@ -706,17 +644,40 @@ settzname P((void))
 #include "tz_posixrules.h"
 
 static int
-tzload(const char *name, struct state *sp)
+differ_by_repeat(const time_t t1, const time_t t0)
+{
+       if (TYPE_INTEGRAL(time_t) &&
+               TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS)
+                       return 0;
+       return (int_fast64_t)t1 - (int_fast64_t)t0 == SECSPERREPEAT;
+}
+
+static int
+tzload(timezone_t sp, const char *name, const int doextend)
 {
-       register const char *   p;
-       register int            i;
-       register int            fid;
+       const char *            p;
+       int                     i;
+       int                     fid;
+       int                     stored;
+       ssize_t                 nread;
+       typedef union {
+               struct tzhead   tzhead;
+               char            buf[2 * sizeof(struct tzhead) +
+                                       2 * sizeof *sp +
+                                       4 * TZ_MAX_TIMES];
+       } u_t;
+       u_t *                   up;
        save_errno              save;
 
-       if (name == NULL && (name = TZDEFAULT) == NULL)
+       up = (u_t *) calloc(1, sizeof *up);
+       if (up == NULL)
                return -1;
+
+       sp->goback = sp->goahead = FALSE;
+       if (name == NULL && (name = TZDEFAULT) == NULL)
+               goto oops;
        {
-               register int    doaccess;
+               int     doaccess;
                /*
                ** Section 4.9.1 of the C standard says that
                ** "FILENAME_MAX expands to an integral constant expression
@@ -731,24 +692,21 @@ tzload(const char *name, struct state *sp)
                doaccess = name[0] == '/';
                if (!doaccess) {
                        if ((p = TZDIR) == NULL)
-                               return -1;
+                               goto oops;
                        if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
-                               return -1;
-                       strcpy(fullname, p);
-                       strcat(fullname, "/");
-                       strcat(fullname, name);
+                               goto oops;
+                       (void) strcpy(fullname, p);     /* XXX strcpy is safe */
+                       (void) strcat(fullname, "/");   /* XXX strcat is safe */
+                       (void) strcat(fullname, name);  /* XXX strcat is safe */
                        /*
                        ** Set doaccess if '.' (as in "../") shows up in name.
                        */
                        if (strchr(name, '.') != NULL)
-                               doaccess = true;
+                               doaccess = TRUE;
                        name = fullname;
                }
-#if 0
-               if (doaccess && access(name, R_OK) != 0)
-                       return -1;
-#endif
-               if ((fid = open(name, OPEN_MODE)) == -1)
+               if ((doaccess && access(name, R_OK) != 0)
+                   || (fid = open(name, OPEN_MODE)) == -1)
                  {
                    const char *base = strrchr(name, '/');
                    if (base)
@@ -762,110 +720,202 @@ tzload(const char *name, struct state *sp)
                    fid = -2;
                  }
        }
-       {
-               struct tzhead * tzhp;
-               union {
-                 struct tzhead tzhead;
-                 char          buf[sizeof *sp + sizeof *tzhp];
-               } u;
+       if (fid == -2)
+         {
+           memcpy(up->buf, _posixrules_data, sizeof (_posixrules_data));
+           nread = sizeof (_posixrules_data);
+         }
+       else
+         {
+           nread = read(fid, up->buf, sizeof up->buf);
+           if (close(fid) < 0 || nread <= 0)
+             goto oops;
+         }
+       for (stored = 4; stored <= 8; stored *= 2) {
                int             ttisstdcnt;
                int             ttisgmtcnt;
 
-               if (fid == -2)
-                 {
-                   memcpy(u.buf, _posixrules_data, sizeof (_posixrules_data));
-                   i = sizeof (_posixrules_data);
-                 }
-               else
-                 {
-                   i = read(fid, u.buf, sizeof u.buf);
-                   if (close(fid) != 0)
-                       return -1;
-                 }
-               ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt);
-               ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt);
-               sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt);
-               sp->timecnt = (int) detzcode(u.tzhead.tzh_timecnt);
-               sp->typecnt = (int) detzcode(u.tzhead.tzh_typecnt);
-               sp->charcnt = (int) detzcode(u.tzhead.tzh_charcnt);
-               p = u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt;
+               ttisstdcnt = (int) detzcode(up->tzhead.tzh_ttisstdcnt);
+               ttisgmtcnt = (int) detzcode(up->tzhead.tzh_ttisgmtcnt);
+               sp->leapcnt = (int) detzcode(up->tzhead.tzh_leapcnt);
+               sp->timecnt = (int) detzcode(up->tzhead.tzh_timecnt);
+               sp->typecnt = (int) detzcode(up->tzhead.tzh_typecnt);
+               sp->charcnt = (int) detzcode(up->tzhead.tzh_charcnt);
+               p = up->tzhead.tzh_charcnt + sizeof up->tzhead.tzh_charcnt;
                if (sp->leapcnt < 0 || sp->leapcnt > TZ_MAX_LEAPS ||
                        sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES ||
                        sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES ||
                        sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS ||
                        (ttisstdcnt != sp->typecnt && ttisstdcnt != 0) ||
                        (ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0))
-                               return -1;
-               if (i - (p - u.buf) < sp->timecnt * 4 + /* ats */
+                               goto oops;
+               if (nread - (p - up->buf) <
+                       sp->timecnt * stored +          /* ats */
                        sp->timecnt +                   /* types */
-                       sp->typecnt * (4 + 2) +         /* ttinfos */
+                       sp->typecnt * 6 +               /* ttinfos */
                        sp->charcnt +                   /* chars */
-                       sp->leapcnt * (4 + 4) +         /* lsinfos */
+                       sp->leapcnt * (stored + 4) +    /* lsinfos */
                        ttisstdcnt +                    /* ttisstds */
                        ttisgmtcnt)                     /* ttisgmts */
-                               return -1;
+                               goto oops;
                for (i = 0; i < sp->timecnt; ++i) {
-                       sp->ats[i] = detzcode(p);
-                       p += 4;
+                       sp->ats[i] = (time_t)((stored == 4) ?
+                               detzcode(p) : detzcode64(p));
+                       p += stored;
                }
                for (i = 0; i < sp->timecnt; ++i) {
                        sp->types[i] = (unsigned char) *p++;
                        if (sp->types[i] >= sp->typecnt)
-                               return -1;
+                               goto oops;
                }
                for (i = 0; i < sp->typecnt; ++i) {
-                       register struct ttinfo *        ttisp;
+                       struct ttinfo * ttisp;
 
                        ttisp = &sp->ttis[i];
                        ttisp->tt_gmtoff = detzcode(p);
                        p += 4;
                        ttisp->tt_isdst = (unsigned char) *p++;
                        if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1)
-                               return -1;
+                               goto oops;
                        ttisp->tt_abbrind = (unsigned char) *p++;
                        if (ttisp->tt_abbrind < 0 ||
                                ttisp->tt_abbrind > sp->charcnt)
-                                       return -1;
+                                       goto oops;
                }
                for (i = 0; i < sp->charcnt; ++i)
                        sp->chars[i] = *p++;
                sp->chars[i] = '\0';    /* ensure '\0' at end */
                for (i = 0; i < sp->leapcnt; ++i) {
-                       register struct lsinfo *        lsisp;
+                       struct lsinfo * lsisp;
 
                        lsisp = &sp->lsis[i];
-                       lsisp->ls_trans = detzcode(p);
-                       p += 4;
+                       lsisp->ls_trans = (time_t)((stored == 4) ?
+                           detzcode(p) : detzcode64(p));
+                       p += stored;
                        lsisp->ls_corr = detzcode(p);
                        p += 4;
                }
                for (i = 0; i < sp->typecnt; ++i) {
-                       register struct ttinfo *        ttisp;
+                       struct ttinfo * ttisp;
 
                        ttisp = &sp->ttis[i];
                        if (ttisstdcnt == 0)
-                               ttisp->tt_ttisstd = false;
+                               ttisp->tt_ttisstd = FALSE;
                        else {
                                ttisp->tt_ttisstd = *p++;
-                               if (ttisp->tt_ttisstd != true &&
-                                       ttisp->tt_ttisstd != false)
-                                               return -1;
+                               if (ttisp->tt_ttisstd != TRUE &&
+                                       ttisp->tt_ttisstd != FALSE)
+                                               goto oops;
                        }
                }
                for (i = 0; i < sp->typecnt; ++i) {
-                       register struct ttinfo *        ttisp;
+                       struct ttinfo * ttisp;
 
                        ttisp = &sp->ttis[i];
                        if (ttisgmtcnt == 0)
-                               ttisp->tt_ttisgmt = false;
+                               ttisp->tt_ttisgmt = FALSE;
                        else {
                                ttisp->tt_ttisgmt = *p++;
-                               if (ttisp->tt_ttisgmt != true &&
-                                       ttisp->tt_ttisgmt != false)
-                                               return -1;
+                               if (ttisp->tt_ttisgmt != TRUE &&
+                                       ttisp->tt_ttisgmt != FALSE)
+                                               goto oops;
+                       }
+               }
+               /*
+               ** Out-of-sort ats should mean we're running on a
+               ** signed time_t system but using a data file with
+               ** unsigned values (or vice versa).
+               */
+               for (i = 0; i < sp->timecnt - 2; ++i)
+                       if (sp->ats[i] > sp->ats[i + 1]) {
+                               ++i;
+                               if (TYPE_SIGNED(time_t)) {
+                                       /*
+                                       ** Ignore the end (easy).
+                                       */
+                                       sp->timecnt = i;
+                               } else {
+                                       /*
+                                       ** Ignore the beginning (harder).
+                                       */
+                                       int     j;
+
+                                       for (j = 0; j + i < sp->timecnt; ++j) {
+                                               sp->ats[j] = sp->ats[j + i];
+                                               sp->types[j] = sp->types[j + i];
+                                       }
+                                       sp->timecnt = j;
+                               }
+                               break;
+                       }
+               /*
+               ** If this is an old file, we're done.
+               */
+               if (up->tzhead.tzh_version[0] == '\0')
+                       break;
+               nread -= p - up->buf;
+               for (i = 0; i < nread; ++i)
+                       up->buf[i] = p[i];
+               /*
+               ** If this is a narrow integer time_t system, we're done.
+               */
+               if (stored >= (int) sizeof(time_t)
+/* CONSTCOND */
+                               && TYPE_INTEGRAL(time_t))
+                       break;
+       }
+       if (doextend && nread > 2 &&
+               up->buf[0] == '\n' && up->buf[nread - 1] == '\n' &&
+               sp->typecnt + 2 <= TZ_MAX_TYPES) {
+                       struct __state ts;
+                       int     result;
+
+                       up->buf[nread - 1] = '\0';
+                       result = tzparse(&ts, &up->buf[1], FALSE);
+                       if (result == 0 && ts.typecnt == 2 &&
+                               sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) {
+                                       for (i = 0; i < 2; ++i)
+                                               ts.ttis[i].tt_abbrind +=
+                                                       sp->charcnt;
+                                       for (i = 0; i < ts.charcnt; ++i)
+                                               sp->chars[sp->charcnt++] =
+                                                       ts.chars[i];
+                                       i = 0;
+                                       while (i < ts.timecnt &&
+                                               ts.ats[i] <=
+                                               sp->ats[sp->timecnt - 1])
+                                                       ++i;
+                                       while (i < ts.timecnt &&
+                                           sp->timecnt < TZ_MAX_TIMES) {
+                                               sp->ats[sp->timecnt] =
+                                                       ts.ats[i];
+                                               sp->types[sp->timecnt] =
+                                                       sp->typecnt +
+                                                       ts.types[i];
+                                               ++sp->timecnt;
+                                               ++i;
+                                       }
+                                       sp->ttis[sp->typecnt++] = ts.ttis[0];
+                                       sp->ttis[sp->typecnt++] = ts.ttis[1];
                        }
+       }
+       if (sp->timecnt > 1) {
+               for (i = 1; i < sp->timecnt; ++i)
+                       if (typesequiv(sp, sp->types[i], sp->types[0]) &&
+                               differ_by_repeat(sp->ats[i], sp->ats[0])) {
+                                       sp->goback = TRUE;
+                                       break;
+                               }
+               for (i = sp->timecnt - 2; i >= 0; --i)
+                       if (typesequiv(sp, sp->types[sp->timecnt - 1],
+                               sp->types[i]) &&
+                               differ_by_repeat(sp->ats[sp->timecnt - 1],
+                               sp->ats[i])) {
+                                       sp->goahead = TRUE;
+                                       break;
                }
        }
+       free(up);
        if (sp == lclptr)
          {
            __gettzinfo ()->__tzrule[0].offset
@@ -874,6 +924,31 @@ tzload(const char *name, struct state *sp)
                                    = -sp->ttis[0].tt_gmtoff;
          }
        return 0;
+oops:
+       free(up);
+       return -1;
+}
+
+static int
+typesequiv(const timezone_t sp, const int a, const int b)
+{
+       int     result;
+
+       if (sp == NULL ||
+               a < 0 || a >= sp->typecnt ||
+               b < 0 || b >= sp->typecnt)
+                       result = FALSE;
+       else {
+               const struct ttinfo *   ap = &sp->ttis[a];
+               const struct ttinfo *   bp = &sp->ttis[b];
+               result = ap->tt_gmtoff == bp->tt_gmtoff &&
+                       ap->tt_isdst == bp->tt_isdst &&
+                       ap->tt_ttisstd == bp->tt_ttisstd &&
+                       ap->tt_ttisgmt == bp->tt_ttisgmt &&
+                       strcmp(&sp->chars[ap->tt_abbrind],
+                       &sp->chars[bp->tt_abbrind]) == 0;
+       }
+       return result;
 }
 
 static const int       mon_lengths[2][MONSPERYEAR] = {
@@ -887,14 +962,14 @@ static const int  year_lengths[2] = {
 
 /*
 ** Given a pointer into a time zone string, scan until a character that is not
-** a valid character in a zone name is found.  Return a pointer to that
+** a valid character in a zone name is found. Return a pointer to that
 ** character.
 */
 
 static const char *
 getzname(const char *strp)
 {
-       register char   c;
+       char    c;
 
        while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
                c != '+')
@@ -902,6 +977,25 @@ getzname(const char *strp)
        return strp;
 }
 
+/*
+** Given a pointer into an extended time zone string, scan until the ending
+** delimiter of the zone name is located. Return a pointer to the delimiter.
+**
+** As with getzname above, the legal character set is actually quite
+** restricted, with other characters producing undefined results.
+** We don't do any checking here; checking is done later in common-case code.
+*/
+
+static const char *
+getqzname(const char *strp, const int delim)
+{
+       int     c;
+
+       while ((c = *strp) != '\0' && c != delim)
+               ++strp;
+       return strp;
+}
+
 /*
 ** Given a pointer into a time zone string, extract a number from that string.
 ** Check that the number is within a specified range; if it is not, return
@@ -910,22 +1004,28 @@ getzname(const char *strp)
 */
 
 static const char *
-getnum(const char *strp, int *nump, const int min, const int max)
+getnum(const char *strp, int *const nump, const int min, const int max)
 {
-       register char   c;
-       register int    num;
+       char    c;
+       int     num;
 
-       if (strp == NULL || !is_digit(c = *strp))
+       if (strp == NULL || !is_digit(c = *strp)) {
+               errno = EINVAL;
                return NULL;
+       }
        num = 0;
        do {
                num = num * 10 + (c - '0');
-               if (num > max)
+               if (num > max) {
+                       errno = EOVERFLOW;
                        return NULL;    /* illegal value */
+               }
                c = *++strp;
        } while (is_digit(c));
-       if (num < min)
+       if (num < min) {
+               errno = EINVAL;
                return NULL;            /* illegal value */
+       }
        *nump = num;
        return strp;
 }
@@ -939,7 +1039,7 @@ getnum(const char *strp, int *nump, const int min, const int max)
 */
 
 static const char *
-getsecs(const char *strp, long *secsp)
+getsecs(const char *strp, long *const secsp)
 {
        int     num;
 
@@ -961,7 +1061,7 @@ getsecs(const char *strp, long *secsp)
                *secsp += num * SECSPERMIN;
                if (*strp == ':') {
                        ++strp;
-                       /* `SECSPERMIN' allows for leap seconds.  */
+                       /* `SECSPERMIN' allows for leap seconds. */
                        strp = getnum(strp, &num, 0, SECSPERMIN);
                        if (strp == NULL)
                                return NULL;
@@ -979,9 +1079,9 @@ getsecs(const char *strp, long *secsp)
 */
 
 static const char *
-getoffset(const char *strp, long *offsetp)
+getoffset(const char *strp, long *const offsetp)
 {
-       register int    neg = 0;
+       int     neg = 0;
 
        if (*strp == '-') {
                neg = 1;
@@ -998,13 +1098,13 @@ getoffset(const char *strp, long *offsetp)
 
 /*
 ** Given a pointer into a time zone string, extract a rule in the form
-** date[/time].  See POSIX section 8 for the format of "date" and "time".
+** date[/time]. See POSIX section 8 for the format of "date" and "time".
 ** If a valid rule is not found, return NULL.
 ** Otherwise, return a pointer to the first character not part of the rule.
 */
 
 static const char *
-getrule(const char *strp, struct rule *rulep)
+getrule(const char *strp, struct rule *const rulep)
 {
        if (*strp == 'J') {
                /*
@@ -1056,12 +1156,12 @@ getrule(const char *strp, struct rule *rulep)
 */
 
 static time_t
-transtime(const time_t janfirst, const int year, const struct rule *rulep,
-               long offset)
+transtime(const time_t janfirst, const int year, const struct rule *const rulep,
+    const long offset)
 {
-       register int    leapyear;
-       register time_t value;
-       register int    i;
+       int     leapyear;
+       time_t  value;
+       int     i;
        int             d, m1, yy0, yy1, yy2, dow;
 
        INITIALIZE(value);
@@ -1076,7 +1176,7 @@ transtime(const time_t janfirst, const int year, const struct rule *rulep,
                ** add SECSPERDAY times the day number-1 to the time of
                ** January 1, midnight, to get the day.
                */
-               value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
+               value = (time_t)(janfirst + (rulep->r_day - 1) * SECSPERDAY);
                if (leapyear && rulep->r_day >= 60)
                        value += SECSPERDAY;
                break;
@@ -1087,7 +1187,7 @@ transtime(const time_t janfirst, const int year, const struct rule *rulep,
                ** Just add SECSPERDAY times the day number to the time of
                ** January 1, midnight, to get the day.
                */
-               value = janfirst + rulep->r_day * SECSPERDAY;
+               value = (time_t)(janfirst + rulep->r_day * SECSPERDAY);
                break;
 
        case MONTH_NTH_DAY_OF_WEEK:
@@ -1096,7 +1196,7 @@ transtime(const time_t janfirst, const int year, const struct rule *rulep,
                */
                value = janfirst;
                for (i = 0; i < rulep->r_mon - 1; ++i)
-                       value += mon_lengths[leapyear][i] * SECSPERDAY;
+                       value += (time_t)(mon_lengths[leapyear][i] * SECSPERDAY);
 
                /*
                ** Use Zeller's Congruence to get day-of-week of first day of
@@ -1112,7 +1212,7 @@ transtime(const time_t janfirst, const int year, const struct rule *rulep,
                        dow += DAYSPERWEEK;
 
                /*
-               ** "dow" is the day-of-week of the first day of the month.  Get
+               ** "dow" is the day-of-week of the first day of the month. Get
                ** the day-of-month (zero-origin) of the first "dow" day of the
                ** month.
                */
@@ -1129,17 +1229,17 @@ transtime(const time_t janfirst, const int year, const struct rule *rulep,
                /*
                ** "d" is the day-of-month (zero-origin) of the day we want.
                */
-               value += d * SECSPERDAY;
+               value += (time_t)(d * SECSPERDAY);
                break;
        }
 
        /*
        ** "value" is the Epoch-relative time of 00:00:00 UTC on the day in
-       ** question.  To get the Epoch-relative time of the specified local
+       ** question. To get the Epoch-relative time of the specified local
        ** time on that day, add the transition time and the current offset
        ** from UTC.
        */
-       return value + rulep->r_time + offset;
+       return (time_t)(value + rulep->r_time + offset);
 }
 
 /*
@@ -1148,7 +1248,7 @@ transtime(const time_t janfirst, const int year, const struct rule *rulep,
 */
 
 static int
-tzparse(const char *name, struct state *sp, const int lastditch)
+tzparse(timezone_t sp, const char *name, const int lastditch)
 {
        const char *                    stdname;
        const char *                    dstname;
@@ -1156,10 +1256,10 @@ tzparse(const char *name, struct state *sp, const int lastditch)
        size_t                          dstlen;
        long                            stdoffset;
        long                            dstoffset;
-       register time_t *               atp;
-       register unsigned char *        typep;
-       register char *                 cp;
-       register int                    load_result;
+       time_t *                atp;
+       unsigned char * typep;
+       char *                  cp;
+       int                     load_result;
 
        INITIALIZE(dstname);
        stdname = name;
@@ -1170,35 +1270,52 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                        stdlen = (sizeof sp->chars) - 1;
                stdoffset = 0;
        } else {
-               name = getzname(name);
-               stdlen = name - stdname;
-               if (stdlen < 3)
-                       return -1;
+               if (*name == '<') {
+                       name++;
+                       stdname = name;
+                       name = getqzname(name, '>');
+                       if (*name != '>')
+                               return (-1);
+                       stdlen = name - stdname;
+                       name++;
+               } else {
+                       name = getzname(name);
+                       stdlen = name - stdname;
+               }
                if (*name == '\0')
                        return -1;
                name = getoffset(name, &stdoffset);
                if (name == NULL)
                        return -1;
        }
-       load_result = tzload(TZDEFRULES, sp);
+       load_result = tzload(sp, TZDEFRULES, FALSE);
        if (load_result != 0)
                sp->leapcnt = 0;                /* so, we're off a little */
        if (*name != '\0') {
-               dstname = name;
-               name = getzname(name);
-               dstlen = name - dstname;        /* length of DST zone name */
-               if (dstlen < 3)
-                       return -1;
+               if (*name == '<') {
+                       dstname = ++name;
+                       name = getqzname(name, '>');
+                       if (*name != '>')
+                               return -1;
+                       dstlen = name - dstname;
+                       name++;
+               } else {
+                       dstname = name;
+                       name = getzname(name);
+                       dstlen = name - dstname; /* length of DST zone name */
+               }
                if (*name != '\0' && *name != ',' && *name != ';') {
                        name = getoffset(name, &dstoffset);
                        if (name == NULL)
                                return -1;
                } else  dstoffset = stdoffset - SECSPERHOUR;
+               if (*name == '\0' && load_result != 0)
+                       name = TZDEFRULESTRING;
                if (*name == ',' || *name == ';') {
                        struct rule     start;
                        struct rule     end;
-                       register int    year;
-                       register time_t janfirst;
+                       int     year;
+                       time_t  janfirst;
                        time_t          starttime;
                        time_t          endtime;
 
@@ -1213,21 +1330,24 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                                return -1;
                        sp->typecnt = 2;        /* standard time and DST */
                        /*
-                       ** Two transitions per year, from EPOCH_YEAR to 2037.
+                       ** Two transitions per year, from EPOCH_YEAR forward.
                        */
-                       sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
-                       if (sp->timecnt > TZ_MAX_TIMES)
-                               return -1;
+                       memset(sp->ttis, 0, sizeof(sp->ttis));
                        sp->ttis[0].tt_gmtoff = -dstoffset;
                        sp->ttis[0].tt_isdst = 1;
-                       sp->ttis[0].tt_abbrind = stdlen + 1;
+                       sp->ttis[0].tt_abbrind = (int)(stdlen + 1);
                        sp->ttis[1].tt_gmtoff = -stdoffset;
                        sp->ttis[1].tt_isdst = 0;
                        sp->ttis[1].tt_abbrind = 0;
                        atp = sp->ats;
                        typep = sp->types;
                        janfirst = 0;
-                       for (year = EPOCH_YEAR; year <= 2037; ++year) {
+                       sp->timecnt = 0;
+                       for (year = EPOCH_YEAR;
+                           sp->timecnt + 2 <= TZ_MAX_TIMES;
+                           ++year) {
+                               time_t  newfirst;
+
                                starttime = transtime(janfirst, year, &start,
                                        stdoffset);
                                endtime = transtime(janfirst, year, &end,
@@ -1243,8 +1363,13 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                                        *atp++ = endtime;
                                        *typep++ = 1;   /* DST ends */
                                }
-                               janfirst += year_lengths[isleap(year)] *
-                                       SECSPERDAY;
+                               sp->timecnt += 2;
+                               newfirst = janfirst;
+                               newfirst += (time_t)
+                                   (year_lengths[isleap(year)] * SECSPERDAY);
+                               if (newfirst <= janfirst)
+                                       break;
+                               janfirst = newfirst;
                        }
                        if (sp == lclptr)
                          {
@@ -1254,17 +1379,15 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                                                    = -sp->ttis[0].tt_gmtoff;
                          }
                } else {
-                       register long   theirstdoffset;
-                       register long   theirdstoffset;
-                       register long   theiroffset;
-                       register int    isdst;
-                       register int    i;
-                       register int    j;
+                       long    theirstdoffset;
+                       long    theirdstoffset;
+                       long    theiroffset;
+                       int     isdst;
+                       int     i;
+                       int     j;
 
                        if (*name != '\0')
                                return -1;
-                       if (load_result != 0)
-                               return -1;
                        /*
                        ** Initial values of theirstdoffset and theirdstoffset.
                        */
@@ -1289,7 +1412,7 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                        /*
                        ** Initially we're assumed to be in standard time.
                        */
-                       isdst = false;
+                       isdst = FALSE;
                        theiroffset = theirstdoffset;
                        /*
                        ** Now juggle transition times and types
@@ -1316,28 +1439,29 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                                        ** offset.
                                        */
                                        if (isdst && !sp->ttis[j].tt_ttisstd) {
-                                               sp->ats[i] += dstoffset -
-                                                       theirdstoffset;
+                                               sp->ats[i] += (time_t)
+                                                   (dstoffset - theirdstoffset);
                                        } else {
-                                               sp->ats[i] += stdoffset -
-                                                       theirstdoffset;
+                                               sp->ats[i] += (time_t)
+                                                   (stdoffset - theirstdoffset);
                                        }
                                }
                                theiroffset = -sp->ttis[j].tt_gmtoff;
-                               if (sp->ttis[j].tt_isdst)
-                                       theirdstoffset = theiroffset;
-                               else    theirstdoffset = theiroffset;
+                               if (!sp->ttis[j].tt_isdst)
+                                       theirstdoffset = theiroffset;
+                               else    theirdstoffset = theiroffset;
                        }
                        /*
                        ** Finally, fill in ttis.
-                       ** ttisstd and ttisgmt need not be handled.
+                       ** ttisstd and ttisgmt need not be handled
                        */
+                       memset(sp->ttis, 0, sizeof(sp->ttis));
                        sp->ttis[0].tt_gmtoff = -stdoffset;
-                       sp->ttis[0].tt_isdst = false;
+                       sp->ttis[0].tt_isdst = FALSE;
                        sp->ttis[0].tt_abbrind = 0;
                        sp->ttis[1].tt_gmtoff = -dstoffset;
-                       sp->ttis[1].tt_isdst = true;
-                       sp->ttis[1].tt_abbrind = stdlen + 1;
+                       sp->ttis[1].tt_isdst = TRUE;
+                       sp->ttis[1].tt_abbrind = (int)(stdlen + 1);
                        sp->typecnt = 2;
                        if (sp == lclptr)
                          {
@@ -1351,6 +1475,7 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                dstlen = 0;
                sp->typecnt = 1;                /* only standard time */
                sp->timecnt = 0;
+               memset(sp->ttis, 0, sizeof(sp->ttis));
                sp->ttis[0].tt_gmtoff = -stdoffset;
                sp->ttis[0].tt_isdst = 0;
                sp->ttis[0].tt_abbrind = 0;
@@ -1360,27 +1485,27 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                    __gettzinfo ()->__tzrule[1].offset = -sp->ttis[0].tt_gmtoff;
                  }
        }
-       sp->charcnt = stdlen + 1;
+       sp->charcnt = (int)(stdlen + 1);
        if (dstlen != 0)
-               sp->charcnt += dstlen + 1;
+               sp->charcnt += (int)(dstlen + 1);
        if ((size_t) sp->charcnt > sizeof sp->chars)
                return -1;
        cp = sp->chars;
-       strncpy(cp, stdname, stdlen);
+       (void) strncpy(cp, stdname, stdlen);
        cp += stdlen;
        *cp++ = '\0';
        if (dstlen != 0) {
-               strncpy(cp, dstname, dstlen);
+               (void) strncpy(cp, dstname, dstlen);
                *(cp + dstlen) = '\0';
        }
        return 0;
 }
 
 static void
-gmtload(struct state *sp)
+gmtload(timezone_t sp)
 {
-       if (tzload(gmt, sp) != 0)
-               tzparse(gmt, sp, true);
+       if (tzload(sp, gmt, TRUE) != 0)
+               (void) tzparse(sp, gmt, TRUE);
 }
 
 #ifndef STD_INSPIRED
@@ -1391,21 +1516,19 @@ gmtload(struct state *sp)
 static
 #endif /* !defined STD_INSPIRED */
 void
-tzsetwall P((void))
+tzsetwall (void)
 {
        if (lcl_is_set == lcl_setting)
                return;
        lcl_is_set = lcl_setting;
 
-#ifdef ALL_STATE
        if (lclptr == NULL) {
-               lclptr = (struct state *) malloc(sizeof *lclptr);
+               lclptr = (timezone_t) calloc(1, sizeof *lclptr);
                if (lclptr == NULL) {
                        settzname();    /* all we can do */
                        return;
                }
        }
-#endif /* defined ALL_STATE */
 #if defined (__CYGWIN__)
        {
            TIME_ZONE_INFORMATION tz;
@@ -1470,7 +1593,7 @@ tzsetwall P((void))
                    sprintf(cp=strchr(cp, 0), ":%d", tz.StandardDate.wSecond);
            }
            /* printf("TZ deduced as `%s'\n", buf); */
-           if (tzparse(buf, lclptr, false) == 0) {
+           if (tzparse(lclptr, buf, FALSE) == 0) {
                settzname();
                lcl_is_set = lcl_from_default;
                strlcpy(lcl_TZname, buf, sizeof (lcl_TZname));
@@ -1483,85 +1606,130 @@ tzsetwall P((void))
            }
        }
 #endif
-       if (tzload((char *) NULL, lclptr) != 0)
+       if (tzload(lclptr, NULL, TRUE) != 0)
                gmtload(lclptr);
        settzname();
 }
 
 static NO_COPY muto tzset_guard;
 
-extern "C" void
-tzset P((void))
+#ifndef STD_INSPIRED
+/*
+** A non-static declaration of tzsetwall in a system header file
+** may cause a warning about this upcoming static declaration...
+*/
+static
+#endif /* !defined STD_INSPIRED */
+void
+tzset_unlocked(void)
 {
-       tzset_guard.init ("tzset_guard")->acquire ();
-       const char *    name = getenv("TZ");
+       const char *    name;
 
+       name = getenv("TZ");
        if (name == NULL) {
                if (lcl_is_set != lcl_from_default)
                        tzsetwall();
-               goto out;
+               return;
        }
 
        if (lcl_is_set > 0 && strncmp(lcl_TZname, name, sizeof(lcl_TZname) - 1) == 0)
-               goto out;
+               return;
        lcl_is_set = (strlen(name) < sizeof (lcl_TZname)) ? lcl_from_environment : lcl_unset;
        if (lcl_is_set != lcl_unset)
                strlcpy(lcl_TZname, name, sizeof (lcl_TZname));
 
-#ifdef ALL_STATE
        if (lclptr == NULL) {
-               lclptr = (struct state *) malloc(sizeof *lclptr);
+               save_errno save;
+               lclptr = (timezone_t) calloc(1, sizeof *lclptr);
                if (lclptr == NULL) {
                        settzname();    /* all we can do */
-                       goto out;
+                       return;
                }
        }
-#endif /* defined ALL_STATE */
        if (*name == '\0') {
                /*
                ** User wants it fast rather than right.
                */
                lclptr->leapcnt = 0;            /* so, we're off a little */
                lclptr->timecnt = 0;
+               lclptr->typecnt = 0;
+               lclptr->ttis[0].tt_isdst = 0;
                lclptr->ttis[0].tt_gmtoff = 0;
                lclptr->ttis[0].tt_abbrind = 0;
-               strcpy(lclptr->chars, gmt);
-       } else if (tzload(name, lclptr) != 0) {
-               if (name[0] == ':' || tzparse(name, lclptr, false) != 0)
-                       gmtload(lclptr);
-       }
+               (void) strlcpy(lclptr->chars, gmt, sizeof(lclptr->chars));
+       } else if (tzload(lclptr, name, TRUE) != 0)
+               if (name[0] == ':' || tzparse(lclptr, name, FALSE) != 0)
+                       (void) gmtload(lclptr);
        settzname();
-out:
+}
+
+extern "C" void
+tzset(void)
+{
+       tzset_guard.init ("tzset_guard")->acquire ();
+       tzset_unlocked();
        tzset_guard.release ();
 }
 
 /*
 ** The easy way to behave "as if no library function calls" localtime
 ** is to not call it--so we drop its guts into "localsub", which can be
-** freely called.  (And no, the PANS doesn't require the above behavior--
+** freely called. (And no, the PANS doesn't require the above behavior--
 ** but it *is* desirable.)
 **
 ** The unused offset argument is for the benefit of mktime variants.
 */
 
 /*ARGSUSED*/
-static void
-localsub (const time_t * const timep,
-         const long offset,
-         struct tm * const tmp)
+static struct tm *
+localsub(const timezone_t sp, const time_t * const timep, const long offset,
+    struct tm *const tmp)
 {
-       register struct state *         sp;
-       register const struct ttinfo *  ttisp;
-       register int                    i;
+       const struct ttinfo *   ttisp;
+       int                     i;
+       struct tm *             result;
        const time_t                    t = *timep;
 
-       sp = lclptr;
-#ifdef ALL_STATE
-       if (sp == NULL) {
-               gmtsub(timep, offset, tmp);
-               return;
+       if ((sp->goback && t < sp->ats[0]) ||
+               (sp->goahead && t > sp->ats[sp->timecnt - 1])) {
+                       time_t                  newt = t;
+                       time_t          seconds;
+                       time_t          tcycles;
+                       int_fast64_t    icycles;
+
+                       if (t < sp->ats[0])
+                               seconds = sp->ats[0] - t;
+                       else    seconds = t - sp->ats[sp->timecnt - 1];
+                       --seconds;
+                       tcycles = (time_t)
+                           (seconds / YEARSPERREPEAT / AVGSECSPERYEAR);
+                       ++tcycles;
+                       icycles = tcycles;
+                       if (tcycles - icycles >= 1 || icycles - tcycles >= 1)
+                               return NULL;
+                       seconds = (time_t) icycles;
+                       seconds *= YEARSPERREPEAT;
+                       seconds *= AVGSECSPERYEAR;
+                       if (t < sp->ats[0])
+                               newt += seconds;
+                       else    newt -= seconds;
+                       if (newt < sp->ats[0] ||
+                               newt > sp->ats[sp->timecnt - 1])
+                                       return NULL;    /* "cannot happen" */
+                       result = localsub(sp, &newt, offset, tmp);
+                       if (result == tmp) {
+                               time_t  newy;
+
+                               newy = tmp->tm_year;
+                               if (t < sp->ats[0])
+                                       newy -= (time_t)icycles * YEARSPERREPEAT;
+                               else    newy += (time_t)icycles * YEARSPERREPEAT;
+                               tmp->tm_year = (int)newy;
+                               if (tmp->tm_year != newy)
+                                       return NULL;
+                       }
+                       return result;
        }
-#endif /* defined ALL_STATE */
        if (sp->timecnt == 0 || t < sp->ats[0]) {
                i = 0;
                while (sp->ttis[i].tt_isdst)
@@ -1570,10 +1738,17 @@ localsub (const time_t * const  timep,
                                break;
                        }
        } else {
-               for (i = 1; i < sp->timecnt; ++i)
-                       if (t < sp->ats[i])
-                               break;
-               i = sp->types[i - 1];
+               int     lo = 1;
+               int     hi = sp->timecnt;
+
+               while (lo < hi) {
+                       int     mid = (lo + hi) / 2;
+
+                       if (t < sp->ats[mid])
+                               hi = mid;
+                       else    lo = mid + 1;
+               }
+               i = (int) sp->types[lo - 1];
        }
        ttisp = &sp->ttis[i];
        /*
@@ -1582,49 +1757,58 @@ localsub (const time_t * const  timep,
        **      t += ttisp->tt_gmtoff;
        **      timesub(&t, 0L, sp, tmp);
        */
-       timesub(&t, ttisp->tt_gmtoff, sp, tmp);
+       result = timesub(sp, &t, ttisp->tt_gmtoff, tmp);
        tmp->tm_isdst = ttisp->tt_isdst;
-       tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
+       if (sp == lclptr)
+               tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
 #ifdef TM_ZONE
        tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind];
 #endif /* defined TM_ZONE */
+       return result;
 }
 
+/*
+** Re-entrant version of localtime.
+*/
 extern "C" struct tm *
-localtime(const time_t *timep)
+localtime_r(const time_t *timep, struct tm *tmp)
 {
-       tzset();
-       localsub(timep, 0L, &tm);
-       return &tm;
+       tzset_guard.init ("tzset_guard")->acquire ();
+       tzset_unlocked();
+       tmp = localsub(lclptr, timep, 0L, tmp);
+       tzset_guard.release ();
+       if (tmp == NULL)
+               errno = EOVERFLOW;
+       return tmp;
 }
 
-/*
- * Re-entrant version of localtime
- */
 extern "C" struct tm *
-localtime_r(const time_t *timep, struct tm *tm)
+localtime(const time_t *const timep)
 {
-       tzset();
-       localsub(timep, 0L, tm);
-       return tm;
+       return localtime_r(timep, &tm);
 }
 
 /*
 ** gmtsub is to gmtime as localsub is to localtime.
 */
+static NO_COPY muto gmt_guard;
 
-static void
-gmtsub(const time_t *timep, const long offset, struct tm *tmp)
+static struct tm *
+gmtsub(const timezone_t sp, const time_t *const timep, const long offset,
+    struct tm *tmp)
 {
+       struct tm *     result;
+
+       gmt_guard.init ("gmt_guard")->acquire ();
        if (!gmt_is_set) {
-               gmt_is_set = true;
-#ifdef ALL_STATE
-               gmtptr = (struct state *) malloc(sizeof *gmtptr);
+               save_errno save;
+               gmt_is_set = TRUE;
+               gmtptr = (timezone_t) calloc(1, sizeof *gmtptr);
                if (gmtptr != NULL)
-#endif /* defined ALL_STATE */
                        gmtload(gmtptr);
        }
-       timesub(timep, offset, gmtptr, tmp);
+       gmt_guard.release ();
+       result = timesub(gmtptr, timep, offset, tmp);
 #ifdef TM_ZONE
        /*
        ** Could get fancy here and deliver something such as
@@ -1634,68 +1818,84 @@ gmtsub(const time_t *timep, const long offset, struct tm *tmp)
        if (offset != 0)
                tmp->TM_ZONE = wildabbr;
        else {
-#ifdef ALL_STATE
                if (gmtptr == NULL)
                        tmp->TM_ZONE = gmt;
                else    tmp->TM_ZONE = gmtptr->chars;
-#endif /* defined ALL_STATE */
-#ifndef ALL_STATE
-               tmp->TM_ZONE = gmtptr->chars;
-#endif /* State Farm */
        }
 #endif /* defined TM_ZONE */
+       return result;
 }
 
 extern "C" struct tm *
-gmtime(const time_t *timep)
+gmtime(const time_t *const timep)
 {
-       gmtsub(timep, 0L, &tm);
-       return &tm;
+       struct tm *tmp = gmtsub(NULL, timep, 0L, &tm);
+
+       if (tmp == NULL)
+               errno = EOVERFLOW;
+
+       return tmp;
 }
 
 /*
- * Re-entrant version of gmtime
- */
+** Re-entrant version of gmtime.
+*/
+
 extern "C" struct tm *
-gmtime_r(const time_t *timep, struct tm *tm)
+gmtime_r(const time_t * const timep, struct tm *tmp)
 {
-       gmtsub(timep, 0L, tm);
-       return tm;
+       tmp = gmtsub(NULL, timep, 0L, tmp);
+
+       if (tmp == NULL)
+               errno = EOVERFLOW;
+
+       return tmp;
 }
 
 #ifdef STD_INSPIRED
 
 extern "C" struct tm *
-offtime(const time_t *timep, const long offset)
+offtime(const time_t *const timep, long offset)
 {
-       gmtsub(timep, offset, &tm);
-       return &tm;
+       struct tm *tmp = gmtsub(NULL, timep, offset, &tm);
+
+       if (tmp == NULL)
+               errno = EOVERFLOW;
+
+       return tmp;
 }
 
 #endif /* defined STD_INSPIRED */
 
-static void
-timesub(const time_t *timep, const long offset, const struct state *sp,
-       struct tm *tmp)
+/*
+** Return the number of leap years through the end of the given year
+** where, to make the math easy, the answer for year zero is defined as zero.
+*/
+
+static int
+leaps_thru_end_of(const int y)
+{
+       return (y >= 0) ? (y / 4 - y / 100 + y / 400) :
+               -(leaps_thru_end_of(-(y + 1)) + 1);
+}
+
+static struct tm *
+timesub(const timezone_t sp, const time_t *const timep, const long offset,
+    struct tm *const tmp)
 {
-       register const struct lsinfo *  lp;
-       register long                   days;
-       register long                   rem;
-       register int                    y;
-       register int                    yleap;
-       register const int *            ip;
-       register long                   corr;
-       register int                    hit;
-       register int                    i;
+       const struct lsinfo *   lp;
+       time_t                  tdays;
+       int                     idays;  /* unsigned would be so 2003 */
+       long                    rem;
+       int                     y;
+       const int *             ip;
+       long                    corr;
+       int                     hit;
+       int                     i;
 
        corr = 0;
        hit = 0;
-#ifdef ALL_STATE
        i = (sp == NULL) ? 0 : sp->leapcnt;
-#endif /* defined ALL_STATE */
-#ifndef ALL_STATE
-       i = sp->leapcnt;
-#endif /* State Farm */
        while (--i >= 0) {
                lp = &sp->lsis[i];
                if (*timep >= lp->ls_trans) {
@@ -1716,115 +1916,170 @@ timesub(const time_t *timep, const long offset, const struct state *sp,
                        break;
                }
        }
-       days = *timep / SECSPERDAY;
-       rem = *timep % SECSPERDAY;
-#ifdef mc68k
-       if (*timep == 0x80000000) {
-               /*
-               ** A 3B1 muffs the division on the most negative number.
-               */
-               days = -24855;
-               rem = -11648;
+       y = EPOCH_YEAR;
+       tdays = (time_t)(*timep / SECSPERDAY);
+       rem = (long) (*timep - tdays * SECSPERDAY);
+       while (tdays < 0 || tdays >= year_lengths[isleap(y)]) {
+               int             newy;
+               time_t  tdelta;
+               int     idelta;
+               int     leapdays;
+
+               tdelta = tdays / DAYSPERLYEAR;
+               idelta = (int) tdelta;
+               if (tdelta - idelta >= 1 || idelta - tdelta >= 1)
+                       return NULL;
+               if (idelta == 0)
+                       idelta = (tdays < 0) ? -1 : 1;
+               newy = y;
+               if (increment_overflow(&newy, idelta))
+                       return NULL;
+               leapdays = leaps_thru_end_of(newy - 1) -
+                       leaps_thru_end_of(y - 1);
+               tdays -= ((time_t) newy - y) * DAYSPERNYEAR;
+               tdays -= leapdays;
+               y = newy;
+       }
+       {
+               long    seconds;
+
+               seconds = tdays * SECSPERDAY + 0.5;
+               tdays = (time_t)(seconds / SECSPERDAY);
+               rem += (long) (seconds - tdays * SECSPERDAY);
        }
-#endif /* defined mc68k */
-       rem += (offset - corr);
+       /*
+       ** Given the range, we can now fearlessly cast...
+       */
+       idays = (int) tdays;
+       rem += offset - corr;
        while (rem < 0) {
                rem += SECSPERDAY;
-               --days;
+               --idays;
        }
        while (rem >= SECSPERDAY) {
                rem -= SECSPERDAY;
-               ++days;
+               ++idays;
+       }
+       while (idays < 0) {
+               if (increment_overflow(&y, -1))
+                       return NULL;
+               idays += year_lengths[isleap(y)];
+       }
+       while (idays >= year_lengths[isleap(y)]) {
+               idays -= year_lengths[isleap(y)];
+               if (increment_overflow(&y, 1))
+                       return NULL;
        }
+       tmp->tm_year = y;
+       if (increment_overflow(&tmp->tm_year, -TM_YEAR_BASE))
+               return NULL;
+       tmp->tm_yday = idays;
+       /*
+       ** The "extra" mods below avoid overflow problems.
+       */
+       tmp->tm_wday = EPOCH_WDAY +
+               ((y - EPOCH_YEAR) % DAYSPERWEEK) *
+               (DAYSPERNYEAR % DAYSPERWEEK) +
+               leaps_thru_end_of(y - 1) -
+               leaps_thru_end_of(EPOCH_YEAR - 1) +
+               idays;
+       tmp->tm_wday %= DAYSPERWEEK;
+       if (tmp->tm_wday < 0)
+               tmp->tm_wday += DAYSPERWEEK;
        tmp->tm_hour = (int) (rem / SECSPERHOUR);
-       rem = rem % SECSPERHOUR;
+       rem %= SECSPERHOUR;
        tmp->tm_min = (int) (rem / SECSPERMIN);
        /*
        ** A positive leap second requires a special
-       ** representation.  This uses "... ??:59:60" et seq.
+       ** representation. This uses "... ??:59:60" et seq.
        */
        tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
-       tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
-       if (tmp->tm_wday < 0)
-               tmp->tm_wday += DAYSPERWEEK;
-       y = EPOCH_YEAR;
-#define LEAPS_THRU_END_OF(y)   ((y) / 4 - (y) / 100 + (y) / 400)
-       while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) {
-               register int    newy;
-
-               newy = y + days / DAYSPERNYEAR;
-               if (days < 0)
-                       --newy;
-               days -= (newy - y) * DAYSPERNYEAR +
-                       LEAPS_THRU_END_OF(newy - 1) -
-                       LEAPS_THRU_END_OF(y - 1);
-               y = newy;
-       }
-       tmp->tm_year = y - TM_YEAR_BASE;
-       tmp->tm_yday = (int) days;
-       ip = mon_lengths[yleap];
-       for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon))
-               days = days - (long) ip[tmp->tm_mon];
-       tmp->tm_mday = (int) (days + 1);
+       ip = mon_lengths[isleap(y)];
+       for (tmp->tm_mon = 0; idays >= ip[tmp->tm_mon]; ++(tmp->tm_mon))
+               idays -= ip[tmp->tm_mon];
+       tmp->tm_mday = (int) (idays + 1);
        tmp->tm_isdst = 0;
 #ifdef TM_GMTOFF
        tmp->TM_GMTOFF = offset;
 #endif /* defined TM_GMTOFF */
+       return tmp;
 }
 
 extern "C" char *
-ctime(const time_t *timep)
+ctime(const time_t *const timep)
 {
 /*
 ** Section 4.12.3.2 of X3.159-1989 requires that
 **     The ctime function converts the calendar time pointed to by timer
-**     to local time in the form of a string.  It is equivalent to
+**     to local time in the form of a string. It is equivalent to
 **             asctime(localtime(timer))
 */
-       return asctime(localtime(timep));
+       struct tm *rtm = localtime(timep);
+       if (rtm == NULL)
+               return NULL;
+       return asctime(rtm);
 }
 
 extern "C" char *
-ctime_r(const time_t *timep, char *buf)
+ctime_r(const time_t *const timep, char *buf)
 {
-       struct tm       tm;
+       struct tm       mytm, *rtm;
 
-       return asctime_r(localtime_r(timep, &tm), buf);
+       rtm = localtime_r(timep, &mytm);
+       if (rtm == NULL)
+               return NULL;
+       return asctime_r(rtm, buf);
 }
 
 /*
 ** Adapted from code provided by Robert Elz, who writes:
 **     The "best" way to do mktime I think is based on an idea of Bob
 **     Kridle's (so its said...) from a long time ago.
-**     [kridle@xinet.com as of 1996-01-16.]
-**     It does a binary search of the time_t space.  Since time_t's are
+**     It does a binary search of the time_t space. Since time_t's are
 **     just 32 bits, its a max of 32 iterations (even at 64 bits it
 **     would still be very reasonable).
 */
 
 #ifndef WRONG
-#define WRONG  (-1)
+#define WRONG  ((time_t)-1)
 #endif /* !defined WRONG */
 
 /*
-** Simplified normalize logic courtesy Paul Eggert (eggert@twinsun.com).
+** Simplified normalize logic courtesy Paul Eggert.
 */
 
-/* Mark as noinline to prevent a compiler warning. */
-static int __attribute__((noinline))
-increment_overflow(int *number, int delta)
+static int
+increment_overflow(int *const ip, int j)
+{
+       int     i = *ip;
+
+       /*
+       ** If i >= 0 there can only be overflow if i + j > INT_MAX
+       ** or if j > INT_MAX - i; given i >= 0, INT_MAX - i cannot overflow.
+       ** If i < 0 there can only be overflow if i + j < INT_MIN
+       ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
+       */
+       if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i))
+               return TRUE;
+       *ip += j;
+       return FALSE;
+}
+
+static int
+long_increment_overflow(long *const lp, int m)
 {
-       int     number0;
+       long l = *lp;
 
-       number0 = *number;
-       *number += delta;
-       return (*number < number0) != (delta < 0);
+       if ((l >= 0) ? (m > LONG_MAX - l) : (m < LONG_MIN - l))
+               return TRUE;
+       *lp += m;
+       return FALSE;
 }
 
 static int
-normalize_overflow(int *tensptr, int *unitsptr, const int base)
+normalize_overflow(int *const tensptr, int *const unitsptr, const int base)
 {
-       register int    tensdelta;
+       int     tensdelta;
 
        tensdelta = (*unitsptr >= 0) ?
                (*unitsptr / base) :
@@ -1834,9 +2089,22 @@ normalize_overflow(int *tensptr, int *unitsptr, const int base)
 }
 
 static int
-tmcomp(register const struct tm *atmp, register const struct tm *btmp)
+long_normalize_overflow(long *const tensptr, int *const unitsptr,
+    const int base)
+{
+       int     tensdelta;
+
+       tensdelta = (*unitsptr >= 0) ?
+               (*unitsptr / base) :
+               (-1 - (-1 - *unitsptr) / base);
+       *unitsptr -= tensdelta * base;
+       return long_increment_overflow(tensptr, tensdelta);
+}
+
+static int
+tmcomp(const struct tm *const atmp, const struct tm *const btmp)
 {
-       register int    result;
+       int     result;
 
        if ((result = (atmp->tm_year - btmp->tm_year)) == 0 &&
                (result = (atmp->tm_mon - btmp->tm_mon)) == 0 &&
@@ -1848,63 +2116,77 @@ tmcomp(register const struct tm *atmp, register const struct tm *btmp)
 }
 
 static time_t
-time2sub(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
-        const long offset, int *okayp, const int do_norm_secs)
+time2sub(const timezone_t sp, struct tm *const tmp, subfun_t funcp,
+    const long offset, int *const okayp, const int do_norm_secs)
 {
-       register const struct state *   sp;
-       register int                    dir;
-       register int                    bits;
-       register int                    i, j ;
-       register int                    saved_seconds;
+       int                     dir;
+       int                     i, j;
+       int                     saved_seconds;
+       long                    li;
+       time_t                  lo;
+       time_t                  hi;
+#ifdef NO_ERROR_IN_DST_GAP
+       time_t                  ilo;
+#endif
+       long                            y;
        time_t                          newt;
        time_t                          t;
        struct tm                       yourtm, mytm;
 
-       *okayp = false;
+       *okayp = FALSE;
        yourtm = *tmp;
+#ifdef NO_ERROR_IN_DST_GAP
+again:
+#endif
        if (do_norm_secs) {
                if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec,
-                       SECSPERMIN))
-                               return WRONG;
+                   SECSPERMIN))
+                       goto overflow;
        }
        if (normalize_overflow(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR))
-               return WRONG;
+               goto overflow;
        if (normalize_overflow(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY))
-               return WRONG;
-       if (normalize_overflow(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR))
-               return WRONG;
+               goto overflow;
+       y = yourtm.tm_year;
+       if (long_normalize_overflow(&y, &yourtm.tm_mon, MONSPERYEAR))
+               goto overflow;
        /*
-       ** Turn yourtm.tm_year into an actual year number for now.
+       ** Turn y into an actual year number for now.
        ** It is converted back to an offset from TM_YEAR_BASE later.
        */
-       if (increment_overflow(&yourtm.tm_year, TM_YEAR_BASE))
-               return WRONG;
+       if (long_increment_overflow(&y, TM_YEAR_BASE))
+               goto overflow;
        while (yourtm.tm_mday <= 0) {
-               if (increment_overflow(&yourtm.tm_year, -1))
-                       return WRONG;
-               i = yourtm.tm_year + (1 < yourtm.tm_mon);
-               yourtm.tm_mday += year_lengths[isleap(i)];
+               if (long_increment_overflow(&y, -1))
+                       goto overflow;
+               li = y + (1 < yourtm.tm_mon);
+               yourtm.tm_mday += year_lengths[isleap(li)];
        }
        while (yourtm.tm_mday > DAYSPERLYEAR) {
-               i = yourtm.tm_year + (1 < yourtm.tm_mon);
-               yourtm.tm_mday -= year_lengths[isleap(i)];
-               if (increment_overflow(&yourtm.tm_year, 1))
-                       return WRONG;
+               li = y + (1 < yourtm.tm_mon);
+               yourtm.tm_mday -= year_lengths[isleap(li)];
+               if (long_increment_overflow(&y, 1))
+                       goto overflow;
        }
        for ( ; ; ) {
-               i = mon_lengths[isleap(yourtm.tm_year)][yourtm.tm_mon];
+               i = mon_lengths[isleap(y)][yourtm.tm_mon];
                if (yourtm.tm_mday <= i)
                        break;
                yourtm.tm_mday -= i;
                if (++yourtm.tm_mon >= MONSPERYEAR) {
                        yourtm.tm_mon = 0;
-                       if (increment_overflow(&yourtm.tm_year, 1))
-                               return WRONG;
+                       if (long_increment_overflow(&y, 1))
+                               goto overflow;
                }
        }
-       if (increment_overflow(&yourtm.tm_year, -TM_YEAR_BASE))
-               return WRONG;
-       if (yourtm.tm_year + TM_YEAR_BASE < EPOCH_YEAR) {
+       if (long_increment_overflow(&y, -TM_YEAR_BASE))
+               goto overflow;
+       yourtm.tm_year = (int)y;
+       if (yourtm.tm_year != y)
+               goto overflow;
+       if (yourtm.tm_sec >= 0 && yourtm.tm_sec < SECSPERMIN)
+               saved_seconds = 0;
+       else if (y + TM_YEAR_BASE < EPOCH_YEAR) {
                /*
                ** We can't set tm_sec to 0, because that might push the
                ** time below the minimum representable time.
@@ -1914,7 +2196,7 @@ time2sub(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
                ** which is a safer assumption than using 58 would be.
                */
                if (increment_overflow(&yourtm.tm_sec, 1 - SECSPERMIN))
-                       return WRONG;
+                       goto overflow;
                saved_seconds = yourtm.tm_sec;
                yourtm.tm_sec = SECSPERMIN - 1;
        } else {
@@ -1922,27 +2204,71 @@ time2sub(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
                yourtm.tm_sec = 0;
        }
        /*
-       ** Divide the search space in half
-       ** (this works whether time_t is signed or unsigned).
+       ** Do a binary search (this works whatever time_t's type is).
        */
-       bits = TYPE_BIT(time_t) - 1;
-       /*
-       ** If time_t is signed, then 0 is just above the median,
-       ** assuming two's complement arithmetic.
-       ** If time_t is unsigned, then (1 << bits) is just above the median.
-       */
-       t = TYPE_SIGNED(time_t) ? 0 : (((time_t) 1) << bits);
+       /* LINTED const not */
+       if (!TYPE_SIGNED(time_t)) {
+               lo = 0;
+               hi = lo - 1;
+       /* LINTED const not */
+       } else {
+               lo = 1;
+               for (i = 0; i < (int) TYPE_BIT(time_t) - 1; ++i)
+                       lo *= 2;
+               hi = -(lo + 1);
+       }
+#ifdef NO_ERROR_IN_DST_GAP
+       ilo = lo;
+#endif
        for ( ; ; ) {
-               (*funcp)(&t, offset, &mytm);
-               dir = tmcomp(&mytm, &yourtm);
+               t = lo / 2 + hi / 2;
+               if (t < lo)
+                       t = lo;
+               else if (t > hi)
+                       t = hi;
+               if ((*funcp)(sp, &t, offset, &mytm) == NULL) {
+                       /*
+                       ** Assume that t is too extreme to be represented in
+                       ** a struct tm; arrange things so that it is less
+                       ** extreme on the next pass.
+                       */
+                       dir = (t > 0) ? 1 : -1;
+               } else  dir = tmcomp(&mytm, &yourtm);
                if (dir != 0) {
-                       if (bits-- < 0)
-                               return WRONG;
-                       if (bits < 0)
-                               --t; /* may be needed if new t is minimal */
-                       else if (dir > 0)
-                               t -= ((time_t) 1) << bits;
-                       else    t += ((time_t) 1) << bits;
+                       if (t == lo) {
+                               ++t;
+                               if (t <= lo)
+                                       goto overflow;
+                               ++lo;
+                       } else if (t == hi) {
+                               --t;
+                               if (t >= hi)
+                                       goto overflow;
+                               --hi;
+                       }
+#ifdef NO_ERROR_IN_DST_GAP
+                       if (ilo != lo && lo - 1 == hi && yourtm.tm_isdst < 0 &&
+                           do_norm_secs) {
+                               for (i = sp->typecnt - 1; i >= 0; --i) {
+                                       for (j = sp->typecnt - 1; j >= 0; --j) {
+                                               time_t off;
+                                               if (sp->ttis[j].tt_isdst ==
+                                                   sp->ttis[i].tt_isdst)
+                                                       continue;
+                                               off = sp->ttis[j].tt_gmtoff -
+                                                   sp->ttis[i].tt_gmtoff;
+                                               yourtm.tm_sec += off < 0 ?
+                                                   -off : off;
+                                               goto again;
+                                       }
+                               }
+                       }
+#endif
+                       if (lo > hi)
+                               goto invalid;
+                       if (dir > 0)
+                               hi = t;
+                       else    lo = t;
                        continue;
                }
                if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst)
@@ -1953,25 +2279,18 @@ time2sub(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
                ** It's okay to guess wrong since the guess
                ** gets checked.
                */
-               /*
-               ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
-               */
-               sp = (const struct state *)
-                       (((void *) funcp == (void *) localsub) ?
-                       lclptr : gmtptr);
-#ifdef ALL_STATE
                if (sp == NULL)
-                       return WRONG;
-#endif /* defined ALL_STATE */
+                       goto invalid;
                for (i = sp->typecnt - 1; i >= 0; --i) {
                        if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
                                continue;
                        for (j = sp->typecnt - 1; j >= 0; --j) {
                                if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
                                        continue;
-                               newt = t + sp->ttis[j].tt_gmtoff -
-                                       sp->ttis[i].tt_gmtoff;
-                               (*funcp)(&newt, offset, &mytm);
+                               newt = (time_t)(t + sp->ttis[j].tt_gmtoff -
+                                   sp->ttis[i].tt_gmtoff);
+                               if ((*funcp)(sp, &newt, offset, &mytm) == NULL)
+                                       continue;
                                if (tmcomp(&mytm, &yourtm) != 0)
                                        continue;
                                if (mytm.tm_isdst != yourtm.tm_isdst)
@@ -1983,21 +2302,28 @@ time2sub(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
                                goto label;
                        }
                }
-               return WRONG;
+               goto invalid;
        }
 label:
        newt = t + saved_seconds;
        if ((newt < t) != (saved_seconds < 0))
-               return WRONG;
+               goto overflow;
        t = newt;
-       (*funcp)(&t, offset, tmp);
-       *okayp = true;
-       return t;
+       if ((*funcp)(sp, &t, offset, tmp)) {
+               *okayp = TRUE;
+               return t;
+       }
+overflow:
+       errno = EOVERFLOW;
+       return WRONG;
+invalid:
+       errno = EINVAL;
+       return WRONG;
 }
 
 static time_t
-time2(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
-      const long offset, int *okayp)
+time2(const timezone_t sp, struct tm *const tmp, subfun_t funcp,
+    const long offset, int *const okayp)
 {
        time_t  t;
 
@@ -2006,46 +2332,33 @@ time2(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
        ** (in case tm_sec contains a value associated with a leap second).
        ** If that fails, try with normalization of seconds.
        */
-       t = time2sub(tmp, funcp, offset, okayp, false);
-       if (*okayp)
-         return t;
-       t = time2sub(tmp, funcp, offset, okayp, true);
-       if (*okayp)
-         return t;
-       /* Workaround for the spring forward gap problem which results in
-          the autoconf mktime usability test failing.
-          What we do here is this:  The gap has 3600 seconds.  If we
-          subtract 3600 from the tm_sec value and get a valid result,
-          then we can simply add 3600 to the return value and are done.
-          If the result is still not valid, the problem is not the
-          spring forward gap and we can give up. */
-       struct tm tmp2 = *tmp;
-       tmp2.tm_sec -= 3600;
-       t = time2sub(&tmp2, funcp, offset, okayp, true);
-       if (*okayp)
-         {
-           if (t + 3600 < 0)   /* Sanity check */
-             return WRONG;
-           return t + 3600;
-         }
-       return t;
+       t = time2sub(sp, tmp, funcp, offset, okayp, FALSE);
+       return *okayp ? t : time2sub(sp, tmp, funcp, offset, okayp, TRUE);
 }
 
 static time_t
-time1(struct tm *tmp, void (*funcp) P((const time_t *, long, struct tm *)),
-      const long offset)
+time1(const timezone_t sp, struct tm *const tmp, subfun_t funcp,
+    const long offset)
 {
-       register time_t                 t;
-       register const struct state *   sp;
-       register int                    samei, otheri;
+       time_t                  t;
+       int                     samei, otheri;
+       int                     sameind, otherind;
+       int                     i;
+       int                     nseen;
+       int                             seen[TZ_MAX_TYPES];
+       int                             types[TZ_MAX_TYPES];
        int                             okay;
 
+       if (tmp == NULL) {
+               errno = EINVAL;
+               return WRONG;
+       }
        if (tmp->tm_isdst > 1)
                tmp->tm_isdst = 1;
-       t = time2(tmp, funcp, offset, &okay);
+       t = time2(sp, tmp, funcp, offset, &okay);
 #ifdef PCTS
        /*
-       ** PCTS code courtesy Grant Sullivan (grant@osf.org).
+       ** PCTS code courtesy Grant Sullivan.
        */
        if (okay)
                return t;
@@ -2062,63 +2375,83 @@ time1(struct tm *tmp, void (*funcp) P((const time_t *, long, struct tm *)),
        ** We try to divine the type they started from and adjust to the
        ** type they need.
        */
-       /*
-       ** The (void *) casts are the benefit of SunOS 3.3 on Sun 2's.
-       */
-       sp = (const struct state *) (((void *) funcp == (void *) localsub) ?
-               lclptr : gmtptr);
-#ifdef ALL_STATE
-       if (sp == NULL)
+       if (sp == NULL) {
+               errno = EINVAL;
                return WRONG;
-#endif /* defined ALL_STATE */
-       for (samei = sp->typecnt - 1; samei >= 0; --samei) {
+       }
+       for (i = 0; i < sp->typecnt; ++i)
+               seen[i] = FALSE;
+       nseen = 0;
+       for (i = sp->timecnt - 1; i >= 0; --i)
+               if (!seen[sp->types[i]]) {
+                       seen[sp->types[i]] = TRUE;
+                       types[nseen++] = sp->types[i];
+               }
+       for (sameind = 0; sameind < nseen; ++sameind) {
+               samei = types[sameind];
                if (sp->ttis[samei].tt_isdst != tmp->tm_isdst)
                        continue;
-               for (otheri = sp->typecnt - 1; otheri >= 0; --otheri) {
+               for (otherind = 0; otherind < nseen; ++otherind) {
+                       otheri = types[otherind];
                        if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
                                continue;
-                       tmp->tm_sec += sp->ttis[otheri].tt_gmtoff -
-                                       sp->ttis[samei].tt_gmtoff;
+                       tmp->tm_sec += (int)(sp->ttis[otheri].tt_gmtoff -
+                                       sp->ttis[samei].tt_gmtoff);
                        tmp->tm_isdst = !tmp->tm_isdst;
-                       t = time2(tmp, funcp, offset, &okay);
+                       t = time2(sp, tmp, funcp, offset, &okay);
                        if (okay)
                                return t;
-                       tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff -
-                                       sp->ttis[samei].tt_gmtoff;
+                       tmp->tm_sec -= (int)(sp->ttis[otheri].tt_gmtoff -
+                                       sp->ttis[samei].tt_gmtoff);
                        tmp->tm_isdst = !tmp->tm_isdst;
                }
        }
+       errno = EOVERFLOW;
        return WRONG;
 }
 
 extern "C" time_t
-mktime(struct tm *tmp)
+mktime(struct tm *const tmp)
 {
-       tzset();
-       return time1(tmp, localsub, 0L);
+       time_t result;
+
+       tzset_guard.init ("tzset_guard")->acquire ();
+       tzset_unlocked();
+       result = time1(lclptr, tmp, localsub, 0L);
+       tzset_guard.release ();
+       return result;
 }
 
 #ifdef STD_INSPIRED
 
 extern "C" time_t
-timelocal(struct tm *tmp)
+timelocal(struct tm *const tmp)
 {
-       tmp->tm_isdst = -1;     /* in case it wasn't initialized */
+       if (tmp != NULL)
+               tmp->tm_isdst = -1;     /* in case it wasn't initialized */
        return mktime(tmp);
 }
 
 extern "C" time_t
-timegm(struct tm *tmp)
+timegm(struct tm *const tmp)
 {
-       tmp->tm_isdst = 0;
-       return time1(tmp, gmtsub, 0L);
+       time_t t;
+
+       if (tmp != NULL)
+               tmp->tm_isdst = 0;
+       t = time1(gmtptr, tmp, gmtsub, 0L);
+       return t;
 }
 
 extern "C" time_t
-timeoff(struct tm *tmp, const long offset)
+timeoff(struct tm *const tmp, const long offset)
 {
-       tmp->tm_isdst = 0;
-       return time1(tmp, gmtsub, offset);
+       time_t t;
+
+       if (tmp != NULL)
+               tmp->tm_isdst = 0;
+       t = time1(gmtptr, tmp, gmtsub, offset);
+       return t;
 }
 
 #endif /* defined STD_INSPIRED */
@@ -2131,9 +2464,9 @@ timeoff(struct tm *tmp, const long offset)
 */
 
 extern "C" long
-gtime(struct tm *tmp)
+gtime(struct tm *const tmp)
 {
-       const time_t    t = mktime(tmp);
+       const time_t t = mktime(tmp);
 
        if (t == WRONG)
                return -1;
@@ -2159,9 +2492,9 @@ gtime(struct tm *tmp)
 static long
 leapcorr(time_t *timep)
 {
-       register struct state *         sp;
-       register struct lsinfo *        lp;
-       register int                    i;
+       timezone_t      sp;
+       struct lsinfo * lp;
+       int             i;
 
        sp = lclptr;
        i = sp->leapcnt;
@@ -2176,8 +2509,12 @@ leapcorr(time_t *timep)
 extern "C" time_t
 time2posix(time_t t)
 {
-       tzset();
-       return t - leapcorr(&t);
+       time_t result;
+       tzset_guard.init ("tzset_guard")->acquire ();
+       tzset_unlocked();
+       result = t - leapcorr(&t);
+       tzset_guard.release ();
+       return (result);
 }
 
 extern "C" time_t
@@ -2186,30 +2523,34 @@ posix2time(time_t t)
        time_t  x;
        time_t  y;
 
-       tzset();
+       tzset_guard.init ("tzset_guard")->acquire ();
+       tzset_unlocked();
        /*
        ** For a positive leap second hit, the result
-       ** is not unique.  For a negative leap second
+       ** is not unique. For a negative leap second
        ** hit, the corresponding time doesn't exist,
        ** so we return an adjacent second.
        */
-       x = t + leapcorr(&t);
-       y = x - leapcorr(&x);
+       x = (time_t)(t + leapcorr(&t));
+       y = (time_t)(x - leapcorr(&x));
        if (y < t) {
                do {
                        x++;
-                       y = x - leapcorr(&x);
+                       y = (time_t)(x - leapcorr(&x));
                } while (y < t);
-               if (t != y)
+               if (t != y) {
                        return x - 1;
+               }
        } else if (y > t) {
                do {
                        --x;
-                       y = x - leapcorr(&x);
+                       y = (time_t)(x - leapcorr(&x));
                } while (y > t);
-               if (t != y)
+               if (t != y) {
                        return x + 1;
+               }
        }
+       tzset_guard.release ();
        return x;
 }
 
index 2adacba9c782151cc1c9902eea45d5b8782f348a..c5271588fc55b800a7074db1429f2167603d3694 100644 (file)
@@ -61,7 +61,7 @@ malloc (size_t size)
       res = dlmalloc (size);
       __malloc_unlock ();
     }
-  malloc_printf ("(%d) = %x, called by %p", size, res, __builtin_return_address (0));
+  malloc_printf ("(%ld) = %p, called by %p", size, res, __builtin_return_address (0));
   return res;
 }
 
@@ -77,7 +77,7 @@ realloc (void *p, size_t size)
       res = dlrealloc (p, size);
       __malloc_unlock ();
     }
-  malloc_printf ("(%x, %d) = %x, called by %x", p, size, res, __builtin_return_address (0));
+  malloc_printf ("(%p, %ld) = %p, called by %p", p, size, res, __builtin_return_address (0));
   return res;
 }
 
@@ -104,7 +104,7 @@ calloc (size_t nmemb, size_t size)
       res = dlcalloc (nmemb, size);
       __malloc_unlock ();
     }
-  malloc_printf ("(%d, %d) = %x, called by %x", nmemb, size, res, __builtin_return_address (0));
+  malloc_printf ("(%ld, %ld) = %p, called by %p", nmemb, size, res, __builtin_return_address (0));
   return res;
 }
 
index 4f9c9df9d08f8a9f820a665fdae3f1b684704ca0..521486ee70d8fd0938a604f03d104e800959c11b 100644 (file)
@@ -32,7 +32,7 @@ details. */
 
 long tls_ix = -1;
 
-const char case_folded_lower[] NO_COPY = {
+const unsigned char case_folded_lower[] = {
    0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
   16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
   32, '!', '"', '#', '$', '%', '&',  39, '(', ')', '*', '+', ',', '-', '.', '/',
@@ -51,7 +51,7 @@ const char case_folded_lower[] NO_COPY = {
  240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
 };
 
-const char case_folded_upper[] NO_COPY = {
+const unsigned char case_folded_upper[] = {
    0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,  15,
   16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,
   32, '!', '"', '#', '$', '%', '&',  39, '(', ')', '*', '+', ',', '-', '.', '/',
@@ -70,7 +70,7 @@ const char case_folded_upper[] NO_COPY = {
  240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
 };
 
-const char isalpha_array[] NO_COPY = {
+const char isalpha_array[] = {
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
@@ -282,7 +282,7 @@ winprio_to_nice (DWORD prio)
 DWORD
 nice_to_winprio (int &nice)
 {
-  static const DWORD priority[] NO_COPY =
+  static const DWORD priority[] =
     {
       REALTIME_PRIORITY_CLASS,         /*  0 */
       HIGH_PRIORITY_CLASS,             /*  1 */
@@ -443,7 +443,11 @@ __import_address (void *imp)
   if (efault.faulted ())
     return NULL;
   const char *ptr = (const char *) imp;
+#ifdef __x86_64__
+  const uintptr_t *jmpto = (uintptr_t *) (ptr + 6 + *(int32_t *)(ptr + 2));
+#else
   const uintptr_t *jmpto = (uintptr_t *) *((uintptr_t *) (ptr + 2));
+#endif
   return (void *) *jmpto;
 }
 
@@ -463,7 +467,7 @@ struct thread_wrapper_arg
 };
 
 static DWORD WINAPI
-thread_wrapper (VOID *arg)
+thread_wrapper (PVOID arg)
 {
   /* Just plain paranoia. */
   if (!arg)
@@ -496,7 +500,7 @@ thread_wrapper (VOID *arg)
   /* Initialize new _cygtls. */
   _my_tls.init_thread (wrapper_arg.stackbase - CYGTLS_PADSIZE,
                       (DWORD (*)(void*, void*)) wrapper_arg.func);
-
+#ifndef __x86_64__
   /* Copy exception list over to new stack.  I'm not quite sure how the
      exception list is extended by Windows itself.  What's clear is that it
      always grows downwards and that it starts right at the stackbase.
@@ -529,9 +533,34 @@ thread_wrapper (VOID *arg)
          old_start = old_start->prev;
        }
     }
-
+#endif
+#ifdef __x86_64__
   __asm__ ("\n\
-          movl  %[WRAPPER_ARG], %%ebx # Load &wrapper_arg into ebx     \n\
+          movq  %[WRAPPER_ARG], %%rbx  # Load &wrapper_arg into rbx    \n\
+          movq  (%%rbx), %%r12         # Load thread func into r12     \n\
+          movq  8(%%rbx), %%r13        # Load thread arg into r13      \n\
+          movq  16(%%rbx), %%rcx       # Load stackaddr into rcx       \n\
+          movq  24(%%rbx), %%rsp       # Load stackbase into rsp       \n\
+          subq  %[CYGTLS], %%rsp       # Subtract CYGTLS_PADSIZE       \n\
+                                       # (here we are 16 bytes aligned)\n\
+          subq  $32, %%rsp             # Subtract another 32 bytes     \n\
+                                       # (shadow space for arg regs)   \n\
+          xorq  %%rbp, %%rbp           # Set rbp to 0                  \n\
+          # We moved to the new stack.                                 \n\
+          # Now it's safe to release the OS stack.                     \n\
+          movl  $0x8000, %%r8d         # dwFreeType: MEM_RELEASE       \n\
+          xorl  %%edx, %%edx           # dwSize:     0                 \n\
+          # dwAddress is already in the correct arg register rcx       \n\
+          call  VirtualFree                                            \n\
+          # All set.  We can copy the thread arg from the safe         \n\
+          # register r13 and then just call the function.              \n\
+          movq  %%r13, %%rcx           # Move thread arg to 1st arg reg\n\
+          call  *%%r12                 # Call thread func              \n"
+          : : [WRAPPER_ARG] "r" (&wrapper_arg),
+              [CYGTLS] "i" (CYGTLS_PADSIZE));
+#else
+  __asm__ ("\n\
+          movl  %[WRAPPER_ARG], %%ebx  # Load &wrapper_arg into ebx    \n\
           movl  (%%ebx), %%eax         # Load thread func into eax     \n\
           movl  4(%%ebx), %%ecx        # Load thread arg into ecx      \n\
           movl  8(%%ebx), %%edx        # Load stackaddr into edx       \n\
@@ -560,10 +589,74 @@ thread_wrapper (VOID *arg)
           call  *%%eax                 # Call thread func              \n"
           : : [WRAPPER_ARG] "r" (&wrapper_arg),
               [CYGTLS] "i" (CYGTLS_PADSIZE));
+#endif
   /* Never return from here. */
   ExitThread (0);
 }
 
+#ifdef __x86_64__
+/* The memory region used for thread stacks */
+#define THREAD_STORAGE_LOW     0x080000000L
+#define THREAD_STORAGE_HIGH    0x100000000L
+/* We provide the stacks always in 1 Megabyte slots */
+#define THREAD_STACK_SLOT      0x100000L       /* 1 Meg */
+/* Maximum stack size returned from the pool. */
+#define THREAD_STACK_MAX       0x20000000L     /* 512 Megs */
+
+class thread_allocator
+{
+  UINT_PTR current;
+public:
+  thread_allocator () : current (THREAD_STORAGE_HIGH) {}
+  PVOID alloc (SIZE_T size)
+  {
+    SIZE_T real_size = roundup2 (size, THREAD_STACK_SLOT);
+    BOOL overflow = FALSE;
+    PVOID real_stackaddr = NULL;
+
+    /* If an application requests a monster stack, we fulfill this request
+       from outside of our pool, top down. */
+    if (real_size > THREAD_STACK_MAX)
+      return VirtualAlloc (NULL, real_size, MEM_RESERVE | MEM_TOP_DOWN,
+                          PAGE_READWRITE);
+    /* Simple round-robin.  Keep looping until VirtualAlloc succeeded, or
+       until we overflowed and hit the current address. */
+    for (UINT_PTR addr = current - real_size;
+        !real_stackaddr && (!overflow || addr >= current);
+        addr -= THREAD_STACK_SLOT)
+      {
+       if (addr < THREAD_STORAGE_LOW)
+         {
+           addr = THREAD_STORAGE_HIGH - real_size;
+           overflow = TRUE;
+         }
+       real_stackaddr = VirtualAlloc ((PVOID) addr, real_size,
+                                      MEM_RESERVE, PAGE_READWRITE);
+       if (!real_stackaddr)
+         {
+           /* So we couldn't grab this space.  Let's check the state.
+              If this area is free, simply try the next lower 1 Meg slot.
+              Otherwise, shift the next try down to the AllocationBase
+              of the current address, minus the requested slot size.
+              Add THREAD_STACK_SLOT since that's subtracted in the next
+              run of the loop anyway. */
+           MEMORY_BASIC_INFORMATION mbi;
+           VirtualQuery ((PVOID) addr, &mbi, sizeof mbi);
+           if (mbi.State != MEM_FREE)
+             addr = (UINT_PTR) mbi.AllocationBase - real_size
+                                                   + THREAD_STACK_SLOT;
+         }
+      }
+    /* If we got an address, remember it for the next allocation attempt. */
+    if (real_stackaddr)
+      current = (UINT_PTR) real_stackaddr;
+    return real_stackaddr;
+  }
+};
+
+thread_allocator thr_alloc NO_COPY;
+#endif
+
 HANDLE WINAPI
 CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func, PVOID thread_arg,
                    PVOID stackaddr, ULONG stacksize, ULONG guardsize,
@@ -607,14 +700,18 @@ CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func, PVOID thread_arg,
       /* Now roundup the result to the next allocation boundary. */
       real_stacksize = roundup2 (real_stacksize,
                                 wincap.allocation_granularity ());
-      /* Reserve stack.
-        FIXME? If the TOP_DOWN method tends to collide too much with
+      /* Reserve stack. */
+#ifdef __x86_64__
+      real_stackaddr = thr_alloc.alloc (real_stacksize);
+#else
+      /* FIXME? If the TOP_DOWN method tends to collide too much with
         other stuff, we should provide our own mechanism to find a
         suitable place for the stack.  Top down from the start of
         the Cygwin DLL comes to mind. */
       real_stackaddr = VirtualAlloc (NULL, real_stacksize,
                                     MEM_RESERVE | MEM_TOP_DOWN,
                                     PAGE_READWRITE);
+#endif
       if (!real_stackaddr)
        return NULL;
       /* Set up committed region.  Two cases: */
@@ -659,11 +756,9 @@ CygwinCreateThread (LPTHREAD_START_ROUTINE thread_func, PVOID thread_arg,
       wrapper_arg->stacklimit = real_stacklimit;
     }
   /* Use the STACK_SIZE_PARAM_IS_A_RESERVATION parameter so only the
-     minimum size for a thread stack is reserved by the OS.  This doesn't
-     work on Windows 2000, but we deallocate the OS stack in thread_wrapper
-     anyway, so this should be a problem only in a tight memory condition.
-     Note that we reserve a 256K stack, not 64K, otherwise the thread creation
-     might crash the process due to a stack overflow. */
+     minimum size for a thread stack is reserved by the OS.  Note that we
+     reserve a 256K stack, not 64K, otherwise the thread creation might
+     crash the process due to a stack overflow. */
   thread = CreateThread (&sec_none_nih, 4 * PTHREAD_STACK_MIN,
                         thread_wrapper, wrapper_arg,
                         creation_flags | STACK_SIZE_PARAM_IS_A_RESERVATION,
@@ -680,3 +775,25 @@ err:
     }
   return thread;
 }
+
+#ifdef __x86_64__
+// TODO: The equivalent newlib functions only work for SYSV ABI so far.
+#undef RtlFillMemory
+#undef RtlCopyMemory
+extern "C" void NTAPI RtlFillMemory (PVOID, SIZE_T, BYTE);
+extern "C" void NTAPI RtlCopyMemory (PVOID, const VOID *, SIZE_T);
+
+extern "C" void *
+memset (void *s, int c, size_t n)
+{
+  RtlFillMemory (s, n, c);
+  return s;
+}
+
+extern "C" void *
+memcpy(void *dest, const void *src, size_t n)
+{
+  RtlCopyMemory (dest, src, n);
+  return dest;
+}
+#endif
index 1dfcab3f45c5292f7e375de0823c00fca18d65d5..2b08dfe3db6a1d044284989b97987a6e46ea4e04 100755 (executable)
@@ -5,8 +5,8 @@ use File::Spec;
 use Getopt::Long;
 my $dir = tempdir(CLEANUP => 1);
 
-my ($ar, $as, $nm, $objcopy, %replace);
-GetOptions('ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy, 'replace=s'=>\%replace);
+my ($cpu, $ar, $as, $nm, $objcopy, %replace);
+GetOptions('cpu=s'=>\$cpu, 'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy, 'replace=s'=>\%replace);
 
 # Args::
 #   1) import lib to create
@@ -22,6 +22,10 @@ open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', $inpdll;
 my %text = ();
 my %import = ();
 my %symfile = ();
+
+my $is64bit = ($cpu eq 'x86_64' ? 1 : 0);
+my $sym_prefix = ($is64bit ? '' : '_');
+
 while (<$nm_fd>) {
     chomp;
     my ($fn, $type, $sym) = /^$inpdll:(.*?):\S+\s+(\S)\s+(\S+)$/o;
@@ -34,12 +38,12 @@ close $nm_fd or exit 1;
 
 for my $sym (keys %replace) {
     my $fn;
-    my $_sym = '_' . $sym;
+    my $_sym = $sym_prefix . $sym;
     if (!defined($fn = $symfile{$_sym})) {
        $fn = "$sym.o";
        $text{$fn} = $_sym;
     }
-    my $imp_sym = '__imp__' . $replace{$sym};
+    my $imp_sym = '__imp_' . $sym_prefix . $replace{$sym};
     $import{$fn} = $imp_sym;
 }
 
@@ -48,18 +52,28 @@ for my $f (keys %text) {
     my $glob_sym = $text{$f};
     if (!defined $imp_sym) {
        delete $text{$f};
-    } elsif ($imp_sym eq '__imp__') {
+    } elsif ($imp_sym eq '__imp_' . $sym_prefix) {
        $text{$f} = 0;
     } else {
        $text{$f} = 1;
        open my $as_fd, '|-', $as, '-o', "$dir/t-$f", "-";
-       print $as_fd <<EOF;
+       if ($is64bit) {
+           print $as_fd <<EOF;
+       .text
+       .extern $imp_sym
+       .global $glob_sym
+$glob_sym:
+       jmp     *$imp_sym(%rip)
+EOF
+       } else {
+           print $as_fd <<EOF;
        .text
        .extern $imp_sym
        .global $glob_sym
 $glob_sym:
        jmp     *$imp_sym
 EOF
+       }
        close $as_fd or exit 1;
     }
 }
index 7770c3bff57c851bc9bc516c858c68096464742e..831111d8566d9fef2589b6ddd1ccea8a5a6d3964 100644 (file)
@@ -93,7 +93,7 @@ _gettemp(char *path, int *doopen, int domkdir, size_t suffixlen, int flags)
   /*
    * check the target directory.
    */
-  struct __stat64 sbuf;
+  struct stat sbuf;
   if (doopen != NULL || domkdir)
     {
       for (; trv > path; trv--)
index d32f6fa0654d19316bd36e334a7719008833048a..697ec40991899d99e4cce6f8e373e108d60a06f8 100644 (file)
@@ -137,13 +137,13 @@ gen_protect (int prot, int flags)
 }
 
 static HANDLE
-CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
+CreateMapping (HANDLE fhdl, size_t len, off_t off, DWORD openflags,
               int prot, int flags)
 {
   HANDLE h;
   NTSTATUS status;
 
-  LARGE_INTEGER sectionsize = { QuadPart: len };
+  LARGE_INTEGER sectionsize = { QuadPart: (LONGLONG) len };
   ULONG protect = gen_create_protect (openflags, flags);
   ULONG attributes = attached (prot) ? SEC_RESERVE : SEC_COMMIT;
 
@@ -191,16 +191,20 @@ CreateMapping (HANDLE fhdl, size_t len, _off64_t off, DWORD openflags,
 
 static void *
 MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
-        int prot, int flags, _off64_t off)
+        int prot, int flags, off_t off)
 {
   NTSTATUS status;
   LARGE_INTEGER offset = { QuadPart:off };
   DWORD protect = gen_create_protect (openflags, flags);
   void *base = addr;
-  ULONG commitsize = attached (prot) ? 0 : len;
-  ULONG viewsize = len;
+  SIZE_T commitsize = attached (prot) ? 0 : len;
+  SIZE_T viewsize = len;
+#ifdef __x86_64__ /* AT_ROUND_TO_PAGE isn't supported on 64 bit systems. */
+  ULONG alloc_type = MEM_TOP_DOWN;
+#else
   ULONG alloc_type = (base && !wincap.is_wow64 () ? AT_ROUND_TO_PAGE : 0)
                     | MEM_TOP_DOWN;
+#endif
 
   /* Try mapping using the given address first, even if it's NULL.
      If it failed, and addr was not NULL and flags is not MAP_FIXED,
@@ -222,8 +226,8 @@ MapView (HANDLE h, void *addr, size_t len, DWORD openflags,
       base = NULL;
       SetLastError (RtlNtStatusToDosError (status));
     }
-  debug_printf ("%p (status %p) = NtMapViewOfSection (h:%x, addr:%x, len:%u,"
-               " off:%X, protect:%x, type:%x)",
+  debug_printf ("%p (status %p) = NtMapViewOfSection (h:%p, addr:%p, len:%lu,"
+               " off:%Y, protect:%y, type:%y)",
                base, status, h, addr, len, off, protect, 0);
   return base;
 }
@@ -253,28 +257,31 @@ class mmap_record
     LIST_ENTRY (mmap_record) mr_next;
 
   private:
-    int fd;
+    /* 4 byte on 32 bit, 8 byte on 64 bit */
     HANDLE mapping_hdl;
+    SIZE_T len;
+    caddr_t base_address;
+    /* Always 8 bytes */
+    off_t offset;
+    /* Always 4 bytes */
+    int fd;
     DWORD openflags;
     int prot;
     int flags;
-    _off64_t offset;
-    DWORD len;
-    caddr_t base_address;
-    int dev;
+    dev_t dev;
     DWORD page_map[0];
 
   public:
-    mmap_record (int nfd, HANDLE h, DWORD of, int p, int f, _off64_t o, DWORD l,
+    mmap_record (int nfd, HANDLE h, DWORD of, int p, int f, off_t o, DWORD l,
                 caddr_t b) :
-       fd (nfd),
        mapping_hdl (h),
+       len (l),
+       base_address (b),
+       offset (o),
+       fd (nfd),
        openflags (of),
        prot (p),
-       flags (f),
-       offset (o),
-       len (l),
-       base_address (b)
+       flags (f)
       {
        dev = 0;
        if (fd >= 0 && !cygheap->fdtab.not_open (fd))
@@ -296,17 +303,17 @@ class mmap_record
     bool autogrow () const { return ::autogrow (flags); }
     bool attached () const { return ::attached (prot); }
     bool filler () const { return ::filler (prot); }
-    _off64_t get_offset () const { return offset; }
-    DWORD get_len () const { return len; }
+    off_t get_offset () const { return offset; }
+    SIZE_T get_len () const { return len; }
     caddr_t get_address () const { return base_address; }
 
     void init_page_map (mmap_record &r);
 
     DWORD find_unused_pages (DWORD pages) const;
-    bool match (caddr_t addr, DWORD len, caddr_t &m_addr, DWORD &m_len);
-    _off64_t map_pages (_off64_t off, DWORD len);
-    bool map_pages (caddr_t addr, DWORD len);
-    bool unmap_pages (caddr_t addr, DWORD len);
+    bool match (caddr_t addr, SIZE_T len, caddr_t &m_addr, DWORD &m_len);
+    off_t map_pages (off_t off, SIZE_T len);
+    bool map_pages (caddr_t addr, SIZE_T len);
+    bool unmap_pages (caddr_t addr, SIZE_T len);
     int access (caddr_t address);
 
     fhandler_base *alloc_fh ();
@@ -328,17 +335,17 @@ class mmap_list
 
   private:
     int fd;
-    __ino64_t hash;
+    ino_t hash;
 
   public:
     int get_fd () const { return fd; }
-    __ino64_t get_hash () const { return hash; }
+    ino_t get_hash () const { return hash; }
 
     bool anonymous () const { return fd == -1; }
-    void set (int nfd, struct __stat64 *st);
+    void set (int nfd, struct stat *st);
     mmap_record *add_record (mmap_record &r);
     bool del_record (mmap_record *rec);
-    caddr_t try_map (void *addr, size_t len, int flags, _off64_t off);
+    caddr_t try_map (void *addr, size_t len, int flags, off_t off);
 };
 
 class mmap_areas
@@ -346,8 +353,8 @@ class mmap_areas
   public:
     LIST_HEAD (, mmap_list) lists;
 
-    mmap_list *get_list_by_fd (int fd, struct __stat64 *st);
-    mmap_list *add_list (int fd, struct __stat64 *st);
+    mmap_list *get_list_by_fd (int fd, struct stat *st);
+    mmap_list *add_list (int fd, struct stat *st);
     void del_list (mmap_list *ml);
 };
 
@@ -383,7 +390,7 @@ mmap_record::find_unused_pages (DWORD pages) const
 }
 
 bool
-mmap_record::match (caddr_t addr, DWORD len, caddr_t &m_addr, DWORD &m_len)
+mmap_record::match (caddr_t addr, SIZE_T len, caddr_t &m_addr, DWORD &m_len)
 {
   caddr_t low = (addr >= get_address ()) ? addr : get_address ();
   caddr_t high = get_address ();
@@ -410,24 +417,24 @@ mmap_record::init_page_map (mmap_record &r)
   if (real_protect != start_protect && !noreserve ()
       && !VirtualProtect (get_address (), get_len (),
                          real_protect, &start_protect))
-    system_printf ("Warning: VirtualProtect (addr: %p, len: 0x%x, "
-                  "new_prot: 0x%x, old_prot: 0x%x), %E",
+    system_printf ("Warning: VirtualProtect (addr: %p, len: %ly, "
+                  "new_prot: %y, old_prot: %y), %E",
                   get_address (), get_len (),
                   real_protect, start_protect);
-  DWORD len = PAGE_CNT (get_len ());
+  SIZE_T len = PAGE_CNT (get_len ());
   while (len-- > 0)
     MAP_SET (len);
 }
 
-_off64_t
-mmap_record::map_pages (_off64_t off, DWORD len)
+off_t
+mmap_record::map_pages (off_t off, SIZE_T len)
 {
   /* Used ONLY if this mapping matches into the chunk of another already
      performed mapping in a special case of MAP_ANON|MAP_PRIVATE.
 
      Otherwise it's job is now done by init_page_map(). */
   DWORD old_prot;
-  debug_printf ("map_pages (fd=%d, off=%D, len=%u)", get_fd (), off, len);
+  debug_printf ("map_pages (fd=%d, off=%Y, len=%lu)", get_fd (), off, len);
   len = PAGE_CNT (len);
 
   if ((off = find_unused_pages (len)) == (DWORD)-1)
@@ -438,7 +445,7 @@ mmap_record::map_pages (_off64_t off, DWORD len)
                          &old_prot))
     {
       __seterrno ();
-      return (_off64_t)-1;
+      return (off_t)-1;
     }
 
   while (len-- > 0)
@@ -447,9 +454,9 @@ mmap_record::map_pages (_off64_t off, DWORD len)
 }
 
 bool
-mmap_record::map_pages (caddr_t addr, DWORD len)
+mmap_record::map_pages (caddr_t addr, SIZE_T len)
 {
-  debug_printf ("map_pages (addr=%x, len=%u)", addr, len);
+  debug_printf ("map_pages (addr=%p, len=%lu)", addr, len);
   DWORD old_prot;
   DWORD off = addr - get_address ();
   off /= wincap.page_size ();
@@ -475,7 +482,7 @@ mmap_record::map_pages (caddr_t addr, DWORD len)
 }
 
 bool
-mmap_record::unmap_pages (caddr_t addr, DWORD len)
+mmap_record::unmap_pages (caddr_t addr, SIZE_T len)
 {
   DWORD old_prot;
   DWORD off = addr - get_address ();
@@ -553,7 +560,7 @@ mmap_list::add_record (mmap_record &r)
 }
 
 void
-mmap_list::set (int nfd, struct __stat64 *st)
+mmap_list::set (int nfd, struct stat *st)
 {
   fd = nfd;
   if (!anonymous ())
@@ -561,7 +568,7 @@ mmap_list::set (int nfd, struct __stat64 *st)
       /* The fd isn't sufficient since it could already be the fd of another
         file.  So we use the inode number as evaluated by fstat to identify
         the file. */
-      hash = st ? st->st_ino : (__ino64_t) 0;
+      hash = st ? st->st_ino : (ino_t) 0;
     }
   LIST_INIT (&recs);
 }
@@ -577,7 +584,7 @@ mmap_list::del_record (mmap_record *rec)
 }
 
 caddr_t
-mmap_list::try_map (void *addr, size_t len, int flags, _off64_t off)
+mmap_list::try_map (void *addr, size_t len, int flags, off_t off)
 {
   mmap_record *rec;
 
@@ -585,13 +592,13 @@ mmap_list::try_map (void *addr, size_t len, int flags, _off64_t off)
     {
       /* If MAP_FIXED isn't given, check if this mapping matches into the
         chunk of another already performed mapping. */
-      DWORD plen = PAGE_CNT (len);
+      SIZE_T plen = PAGE_CNT (len);
       LIST_FOREACH (rec, &recs, mr_next)
        if (rec->find_unused_pages (plen) != (DWORD) -1)
          break;
       if (rec && rec->compatible_flags (flags))
        {
-         if ((off = rec->map_pages (off, len)) == (_off64_t) -1)
+         if ((off = rec->map_pages (off, len)) == (off_t) -1)
            return (caddr_t) MAP_FAILED;
          return (caddr_t) rec->get_address () + off;
        }
@@ -627,7 +634,7 @@ mmap_list::try_map (void *addr, size_t len, int flags, _off64_t off)
 }
 
 mmap_list *
-mmap_areas::get_list_by_fd (int fd, struct __stat64 *st)
+mmap_areas::get_list_by_fd (int fd, struct stat *st)
 {
   mmap_list *ml;
   LIST_FOREACH (ml, &lists, ml_next)
@@ -644,7 +651,7 @@ mmap_areas::get_list_by_fd (int fd, struct __stat64 *st)
 }
 
 mmap_list *
-mmap_areas::add_list (int fd, struct __stat64 *st)
+mmap_areas::add_list (int fd, struct stat *st)
 {
   mmap_list *ml = (mmap_list *) cmalloc (HEAP_MMAP, sizeof (mmap_list));
   if (!ml)
@@ -771,7 +778,7 @@ out:
 
 static caddr_t
 mmap_worker (mmap_list *map_list, fhandler_base *fh, caddr_t base, size_t len,
-            int prot, int flags, int fd, _off64_t off, struct __stat64 *st)
+            int prot, int flags, int fd, off_t off, struct stat *st)
 {
   HANDLE h = fh->mmap (&base, len, prot, flags, off);
   if (h == INVALID_HANDLE_VALUE)
@@ -793,10 +800,96 @@ mmap_worker (mmap_list *map_list, fhandler_base *fh, caddr_t base, size_t len,
   return base;
 }
 
+#ifdef __x86_64__
+
+/* The memory region used for memory maps */
+#define MMAP_STORAGE_LOW       0x00800000000L  /* Leave 8 Gigs for heap. */
+#define MMAP_STORAGE_HIGH      0x70000000000L  /* Leave enough room for OS. */
+
+/* FIXME?  Unfortunately the OS doesn't support a top down allocation with
+          a ceiling value.  The ZeroBits mechanism only works for
+          NtMapViewOfSection and it only evaluates the high bit of ZeroBits
+          on 64 bit, so it's pretty much useless for our purposes.
+
+          If the below simple mechanism to perform top-down allocations
+          turns out to be too dumb, we need something else.  One idea is to
+          dived the space in (3835) 4 Gig chunks and simply store the
+          available free space per slot.  Then we can go top down from slot
+          to slot and only try slots which are supposed to have enough space.
+          Bookkeeping would be very simple and fast. */
+class mmap_allocator
+{
+  caddr_t mmap_current_low;
+
+public:
+  mmap_allocator () : mmap_current_low ((caddr_t) MMAP_STORAGE_HIGH) {}
+
+  PVOID alloc (PVOID in_addr, SIZE_T in_size, bool fixed)
+  {
+    MEMORY_BASIC_INFORMATION mbi;
+
+    SIZE_T size = roundup2 (in_size, wincap.allocation_granularity ());
+    /* First check for the given address. */
+    if (in_addr)
+      {
+       /* If it points to a free area, big enough to fulfill the request,
+          return the address. */
+       if (VirtualQuery (in_addr, &mbi, sizeof mbi)
+           && mbi.State == MEM_FREE
+           && mbi.RegionSize >= size)
+         return in_addr;
+       /* Otherwise, if MAP_FIXED was given, give up. */
+       if (fixed)
+         return NULL;
+       /* Otherwise, fall through to the usual free space search mechanism. */
+      }
+    /* Start with the last allocation start address - requested size. */
+    caddr_t addr = mmap_current_low - size;
+    bool merry_go_round = false;
+    do
+      {
+       /* Did we hit the lower ceiling?  If so, restart from the upper
+          ceiling, but note that we did it. */
+       if (addr < (caddr_t) MMAP_STORAGE_LOW)
+         {
+           addr = (caddr_t) MMAP_STORAGE_HIGH - size;
+           merry_go_round = true;
+         }
+       /* Shouldn't fail, but better test. */
+       if (!VirtualQuery ((PVOID) addr, &mbi, sizeof mbi))
+         return NULL;
+       /* If the region is free... */
+       if (mbi.State == MEM_FREE)
+         {
+           /* ...and the region is big enough to fulfill the request... */
+           if (mbi.RegionSize >= size)
+             {
+               /* ...note the address as next start address for our simple
+                  merry-go-round and return the address. */
+               mmap_current_low = addr;
+               return (PVOID) addr;
+             }
+           /* Otherwise, subtract what's missing in size and try again. */
+           addr -= size - mbi.RegionSize;
+         }
+       /* If the region isn't free, skip to address below AllocationBase
+          and try again. */
+       else
+         addr = (caddr_t) mbi.AllocationBase - size;
+      }
+    /* Repeat until we had a full ride on the merry_go_round. */
+    while (!merry_go_round || addr >= mmap_current_low);
+    return NULL;
+  }
+};
+
+static mmap_allocator mmap_alloc;      /* Inherited by forked child. */
+#endif
+
 extern "C" void *
-mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
+mmap64 (void *addr, size_t len, int prot, int flags, int fd, off_t off)
 {
-  syscall_printf ("addr %x, len %u, prot %x, flags %x, fd %d, off %D",
+  syscall_printf ("addr %p, len %lu, prot %y, flags %y, fd %d, off %Y",
                  addr, len, prot, flags, fd, off);
 
   caddr_t ret = (caddr_t) MAP_FAILED;
@@ -806,7 +899,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
   mmap_list *map_list = NULL;
   size_t orig_len = 0;
   caddr_t base = NULL;
-  struct __stat64 st;
+  struct stat st;
 
   DWORD pagesize = wincap.allocation_granularity ();
 
@@ -862,7 +955,11 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
         If all these requirements are given, we just return an anonymous map.
         This will help to get over the autoconf test even on 64 bit systems.
         The tests are ordered for speed. */
+#ifdef __x86_64__
+      if (1)
+#else
       if (wincap.is_wow64 ())
+#endif
        {
          UNICODE_STRING fname;
          IO_STATUS_BLOCK io;
@@ -944,7 +1041,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
          __seterrno ();
          goto out;
        }
-      _off64_t fsiz = st.st_size;
+      off_t fsiz = st.st_size;
 
       /* Don't allow file mappings beginning beyond EOF since Windows can't
         handle that POSIX like, unless MAP_AUTOGROW flag is set, which
@@ -966,15 +1063,17 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
        }
       fsiz -= off;
       /* We're creating the pages beyond EOF as reserved, anonymous pages.
-        Note that this isn't done in WOW64 environments since apparently
-        WOW64 does not support the AT_ROUND_TO_PAGE flag which is required
-        to get this right.  Too bad. */
+        Note that this isn't done in 64 bit environments since apparently
+        64 bit systems don't support the AT_ROUND_TO_PAGE flag, which is
+        required to get this right.  Too bad. */
+#ifndef __x86_64__
       if (!wincap.is_wow64 ()
-         && ((len > fsiz && !autogrow (flags))
+         && (((off_t) len > fsiz && !autogrow (flags))
              || roundup2 (len, wincap.page_size ())
                 < roundup2 (len, pagesize)))
        orig_len = len;
-      if (len > fsiz)
+#endif
+      if ((off_t) len > fsiz)
        {
          if (autogrow (flags))
            {
@@ -995,7 +1094,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
 
       /* If the requested offset + len is <= file size, drop MAP_AUTOGROW.
         This simplifes fhandler::mmap's job. */
-      if (autogrow (flags) && (off + len) <= fsiz)
+      if (autogrow (flags) && (off + (off_t) len) <= fsiz)
        flags &= ~MAP_AUTOGROW;
     }
 
@@ -1023,6 +1122,9 @@ go_ahead:
        }
     }
 
+#ifdef __x86_64__
+  addr = mmap_alloc.alloc (addr, orig_len ?: len, fixed (flags));
+#else
   if (orig_len)
     {
       /* If the requested length is bigger than the file size, we try to
@@ -1053,6 +1155,7 @@ go_ahead:
        }
       addr = newaddr;
     }
+#endif
 
   base = mmap_worker (map_list, fh, (caddr_t) addr, len, prot, flags, fd, off,
                      &st);
@@ -1126,18 +1229,22 @@ out:
   return ret;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (mmap64, mmap)
+#else
 extern "C" void *
 mmap (void *addr, size_t len, int prot, int flags, int fd, _off_t off)
 {
-  return mmap64 (addr, len, prot, flags, fd, (_off64_t)off);
+  return mmap64 (addr, len, prot, flags, fd, (off_t)off);
 }
+#endif
 
 /* munmap () removes all mmapped pages between addr and addr+len. */
 
 extern "C" int
 munmap (void *addr, size_t len)
 {
-  syscall_printf ("munmap (addr %x, len %u)", addr, len);
+  syscall_printf ("munmap (addr %p, len %lu)", addr, len);
 
   /* Error conditions according to SUSv3 */
   if (!addr || !len || check_invalid_virtual_addr (addr, len))
@@ -1191,7 +1298,7 @@ munmap (void *addr, size_t len)
     }
 
   LIST_UNLOCK ();
-  syscall_printf ("0 = munmap(): %x", addr);
+  syscall_printf ("0 = munmap(): %p", addr);
   return 0;
 }
 
@@ -1203,7 +1310,7 @@ msync (void *addr, size_t len, int flags)
   int ret = -1;
   mmap_list *map_list;
 
-  syscall_printf ("msync (addr: %p, len %u, flags %x)", addr, len, flags);
+  syscall_printf ("msync (addr: %p, len %lu, flags %y)", addr, len, flags);
 
   pthread_testcancel ();
 
@@ -1265,7 +1372,7 @@ mprotect (void *addr, size_t len, int prot)
   DWORD old_prot;
   DWORD new_prot = 0;
 
-  syscall_printf ("mprotect (addr: %p, len %u, prot %x)", addr, len, prot);
+  syscall_printf ("mprotect (addr: %p, len %lu, prot %y)", addr, len, prot);
 
   /* See comment in mmap64 for a description. */
   size_t pagesize = wincap.allocation_granularity ();
@@ -1356,7 +1463,8 @@ mlock (const void *addr, size_t len)
   /* Align address and length values to page size. */
   size_t pagesize = wincap.allocation_granularity ();
   PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize);
-  ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize);
+  SIZE_T size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len,
+                         pagesize);
   NTSTATUS status = 0;
   do
     {
@@ -1374,7 +1482,7 @@ mlock (const void *addr, size_t len)
             and retry, until either we fail to raise the working set size
             further, or until NtLockVirtualMemory returns successfully (or
             with another error).  */
-         ULONG min, max;
+         SIZE_T min, max;
          if (!GetProcessWorkingSetSize (GetCurrentProcess (), &min, &max))
            {
              set_errno (ENOMEM);
@@ -1401,7 +1509,7 @@ mlock (const void *addr, size_t len)
     }
   while (status == STATUS_WORKING_SET_QUOTA);
 
-  syscall_printf ("%R = mlock(%p, %u)", ret, addr, len);
+  syscall_printf ("%R = mlock(%p, %lu)", ret, addr, len);
   return ret;
 }
 
@@ -1413,7 +1521,8 @@ munlock (const void *addr, size_t len)
   /* Align address and length values to page size. */
   size_t pagesize = wincap.allocation_granularity ();
   PVOID base = (PVOID) rounddown((uintptr_t) addr, pagesize);
-  ULONG size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len, pagesize);
+  SIZE_T size = roundup2 (((uintptr_t) addr - (uintptr_t) base) + len,
+                         pagesize);
   NTSTATUS status = NtUnlockVirtualMemory (NtCurrentProcess (), &base, &size,
                                           MAP_PROCESS);
   if (!NT_SUCCESS (status))
@@ -1421,7 +1530,7 @@ munlock (const void *addr, size_t len)
   else
     ret = 0;
 
-  syscall_printf ("%R = munlock(%p, %u)", ret, addr, len);
+  syscall_printf ("%R = munlock(%p, %lu)", ret, addr, len);
   return ret;
 }
 
@@ -1451,7 +1560,7 @@ posix_madvise (void *addr, size_t len, int advice)
       ret = 0;
     }
 
-  syscall_printf ("%d = posix_madvise(%p, %u, %d)", ret, addr, len, advice);
+  syscall_printf ("%d = posix_madvise(%p, %lu, %d)", ret, addr, len, advice);
   /* Eventually do nothing. */
   return 0;
 }
@@ -1470,7 +1579,7 @@ posix_madvise (void *addr, size_t len, int advice)
 */
 HANDLE
 fhandler_base::mmap (caddr_t *addr, size_t len, int prot,
-                    int flags, _off64_t off)
+                    int flags, off_t off)
 {
   set_errno (ENODEV);
   return INVALID_HANDLE_VALUE;
@@ -1492,7 +1601,7 @@ fhandler_base::msync (HANDLE h, caddr_t addr, size_t len, int flags)
 
 bool
 fhandler_base::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
-                                     _off64_t offset, DWORD size,
+                                     off_t offset, DWORD size,
                                      void *address)
 {
   set_errno (ENODEV);
@@ -1503,7 +1612,7 @@ fhandler_base::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
    quite the natural way. */
 HANDLE
 fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot,
-                        int flags, _off64_t off)
+                        int flags, off_t off)
 {
   HANDLE h;
   void *base;
@@ -1590,7 +1699,7 @@ fhandler_dev_zero::msync (HANDLE h, caddr_t addr, size_t len, int flags)
 
 bool
 fhandler_dev_zero::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
-                                     _off64_t offset, DWORD size,
+                                     off_t offset, DWORD size,
                                      void *address)
 {
   /* Re-create the map */
@@ -1609,8 +1718,8 @@ fhandler_dev_zero::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
     {
       MEMORY_BASIC_INFORMATION m;
       VirtualQuery (address, &m, sizeof (m));
-      system_printf ("requested %p != %p mem alloc base %p, state %p, "
-                    "size %d, %E", address, base, m.AllocationBase, m.State,
+      system_printf ("requested %p != %p mem alloc base %p, state %y, "
+                    "size %lu, %E", address, base, m.AllocationBase, m.State,
                     m.RegionSize);
     }
   return base == address;
@@ -1619,7 +1728,7 @@ fhandler_dev_zero::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
 /* Implementation for disk files and anonymous mappings. */
 HANDLE
 fhandler_disk_file::mmap (caddr_t *addr, size_t len, int prot,
-                         int flags, _off64_t off)
+                         int flags, off_t off)
 {
   HANDLE h = CreateMapping (get_handle (), len, off, get_access (),
                            prot, flags);
@@ -1686,7 +1795,7 @@ fhandler_disk_file::msync (HANDLE h, caddr_t addr, size_t len, int flags)
 
 bool
 fhandler_disk_file::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
-                                          _off64_t offset, DWORD size,
+                                          off_t offset, DWORD size,
                                           void *address)
 {
   /* Re-create the map */
@@ -1695,8 +1804,8 @@ fhandler_disk_file::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
     {
       MEMORY_BASIC_INFORMATION m;
       VirtualQuery (address, &m, sizeof (m));
-      system_printf ("requested %p != %p mem alloc base %p, state %p, "
-                    "size %d, %E", address, base, m.AllocationBase, m.State,
+      system_printf ("requested %p != %p mem alloc base %p, state %y, "
+                    "size %lu, %E", address, base, m.AllocationBase, m.State,
                     m.RegionSize);
     }
   return base == address;
@@ -1704,10 +1813,10 @@ fhandler_disk_file::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
 
 HANDLE
 fhandler_dev_mem::mmap (caddr_t *addr, size_t len, int prot,
-                       int flags, _off64_t off)
+                       int flags, off_t off)
 {
-  if (off >= mem_size
-      || (DWORD) len >= mem_size
+  if (off >= (off_t) mem_size
+      || len >= mem_size
       || off + len >= mem_size)
     {
       set_errno (EINVAL);
@@ -1780,7 +1889,7 @@ fhandler_dev_mem::msync (HANDLE h, caddr_t addr, size_t len, int flags)
 
 bool
 fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
-                                        _off64_t offset, DWORD size,
+                                        off_t offset, DWORD size,
                                         void *address)
 {
   void *base = MapView (h, address, size, get_access (), prot,
@@ -1789,8 +1898,8 @@ fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, int prot, int flags,
     {
       MEMORY_BASIC_INFORMATION m;
       VirtualQuery (address, &m, sizeof (m));
-      system_printf ("requested %p != %p mem alloc base %p, state %p, "
-                    "size %d, %E", address, base, m.AllocationBase, m.State,
+      system_printf ("requested %p != %p mem alloc base %p, state %y, "
+                    "size %lu, %E", address, base, m.AllocationBase, m.State,
                     m.RegionSize);
     }
   return base == address;
@@ -1812,8 +1921,8 @@ fixup_mmaps_after_fork (HANDLE parent)
       mmap_record *rec;
       LIST_FOREACH (rec, &map_list->recs, mr_next)
        {
-         debug_printf ("fd %d, h 0x%x, address %p, len 0x%x, prot: 0x%x, "
-                       "flags: 0x%x, offset %X",
+         debug_printf ("fd %d, h %p, address %p, len %ly, prot: %y, "
+                       "flags: %y, offset %Y",
                        rec->get_fd (), rec->get_handle (), rec->get_address (),
                        rec->get_len (), rec->get_prot (), rec->get_flags (),
                        rec->get_offset ());
@@ -1908,10 +2017,10 @@ fixup_mmaps_after_fork (HANDLE parent)
                  VirtualQuery (address, &m, sizeof m);
                  system_printf ("VirtualProtect failed for "
                                 "address %p, "
-                                "parentstate: 0x%x, "
-                                "state: 0x%x, "
-                                "parentprot: 0x%x, "
-                                "prot: 0x%x, %E",
+                                "parentstate: %y, "
+                                "state: %y, "
+                                "parentprot: %y, "
+                                "prot: %y, %E",
                                 address, mbi.State, m.State,
                                 mbi.Protect, m.Protect);
                  return -1;
index 4ff42693d53e32745b398c02e1925d72a3eaf1e0..a776f2b265cb7e179b6ef5236e9c8d0cc558e3c9 100644 (file)
@@ -224,7 +224,7 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol)
        }
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("Cannot access path %S, status %08lx",
+         debug_printf ("Cannot access path %S, status %y",
                        attr.ObjectName, status);
          return false;
        }
@@ -262,7 +262,7 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol)
                                           FileFsAttributeInformation);
   if (no_media || !NT_SUCCESS (status))
     {
-      debug_printf ("Cannot get volume attributes (%S), %08lx",
+      debug_printf ("Cannot get volume attributes (%S), %y",
                    attr.ObjectName, status);
       if (!in_vol)
        NtClose (vol);
@@ -306,14 +306,20 @@ fs_info::update (PUNICODE_STRING upath, HANDLE in_vol)
                             | FILE_CASE_PRESERVED_NAMES \
                             | FILE_UNICODE_ON_DISK \
                             | FILE_NAMED_STREAMS)
-/* These are the minimal flags supported by NTFS since NT4.  Every filesystem
-   not supporting these flags is not a native NTFS.  We subsume them under
-   the filesystem type "cifs". */
+/* These are the minimal flags supported by NTFS since Windows 2000.  Every
+   filesystem not supporting these flags is not a native NTFS.  We subsume
+   them under the filesystem type "cifs". */
 #define MINIMAL_WIN_NTFS_FLAGS (FILE_CASE_SENSITIVE_SEARCH \
                                | FILE_CASE_PRESERVED_NAMES \
                                | FILE_UNICODE_ON_DISK \
                                | FILE_PERSISTENT_ACLS \
-                               | FILE_FILE_COMPRESSION)
+                               | FILE_FILE_COMPRESSION \
+                               | FILE_VOLUME_QUOTAS \
+                               | FILE_SUPPORTS_SPARSE_FILES \
+                               | FILE_SUPPORTS_REPARSE_POINTS \
+                               | FILE_SUPPORTS_OBJECT_IDS \
+                               | FILE_SUPPORTS_ENCRYPTION \
+                               | FILE_NAMED_STREAMS)
 #define FS_IS_WINDOWS_NTFS TEST_GVI(flags () & MINIMAL_WIN_NTFS_FLAGS, \
                                    MINIMAL_WIN_NTFS_FLAGS)
 /* These are the exact flags of a real Windows FAT/FAT32 filesystem.
@@ -479,7 +485,7 @@ mount_info::init ()
     {
       char native[PATH_MAX];
       if (root_idx < 0)
-       api_fatal ("root_idx %d, user_shared magic %p, nmounts %d", root_idx, user_shared->version, nmounts);
+       api_fatal ("root_idx %d, user_shared magic %y, nmounts %d", root_idx, user_shared->version, nmounts);
       char *p = stpcpy (native, mount[root_idx].native_path);
       if (!got_usr_bin)
       {
@@ -503,12 +509,12 @@ set_flags (unsigned *flags, unsigned val)
   if (!(*flags & PATH_BINARY))
     {
       *flags |= PATH_TEXT;
-      debug_printf ("flags: text (%p)", *flags & (PATH_TEXT | PATH_BINARY));
+      debug_printf ("flags: text (%y)", *flags & (PATH_TEXT | PATH_BINARY));
     }
   else
     {
       *flags |= PATH_BINARY;
-      debug_printf ("flags: binary (%p)", *flags & (PATH_TEXT | PATH_BINARY));
+      debug_printf ("flags: binary (%y)", *flags & (PATH_TEXT | PATH_BINARY));
     }
 }
 
@@ -717,7 +723,7 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, device& dev,
     }
 
  out_no_chroot_check:
-  debug_printf ("src_path %s, dst %s, flags %p, rc %d", src_path, dst, *flags, rc);
+  debug_printf ("src_path %s, dst %s, flags %y, rc %d", src_path, dst, *flags, rc);
   return rc;
 }
 
@@ -1195,7 +1201,7 @@ mount_info::from_fstab (bool user, WCHAR fstab[], PWCHAR fstab_end)
                       | FILE_OPEN_FOR_BACKUP_INTENT);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtOpenFile(%S) failed, %p", &upath, status);
+      debug_printf ("NtOpenFile(%S) failed, %y", &upath, status);
       return false;
     }
 
@@ -1444,7 +1450,7 @@ mount_info::add_item (const char *native, const char *posix,
   else
     posixerr = normalize_posix_path (posix, posixtmp, posixtail);
 
-  debug_printf ("%s[%s], %s[%s], %p",
+  debug_printf ("%s[%s], %s[%s], %y",
                native, nativeerr ? error : nativetmp,
                posix, posixerr ? error : posixtmp, mountflags);
 
@@ -1808,7 +1814,7 @@ mount (const char *win32_path, const char *posix_path, unsigned flags)
       res = mount_table->add_item (w32_path, posix_path, flags);
     }
 
-  syscall_printf ("%R = mount(%s, %s, %p)", res, win32_path, posix_path, flags);
+  syscall_printf ("%R = mount(%s, %s, %y)", res, win32_path, posix_path, flags);
   return res;
 }
 
@@ -1940,41 +1946,6 @@ endmntent (FILE *)
   return 1;
 }
 
-static bool
-get_volume_path_names_for_volume_name (LPCWSTR vol, LPWSTR mounts)
-{
-  DWORD len;
-  if (GetVolumePathNamesForVolumeNameW (vol, mounts, NT_MAX_PATH, &len))
-    return true;
-
-  /* Windows 2000 doesn't have GetVolumePathNamesForVolumeNameW.
-     Just assume that mount points are not longer than MAX_PATH. */
-  WCHAR drives[MAX_PATH], dvol[MAX_PATH], mp[MAX_PATH + 3];
-  if (!GetLogicalDriveStringsW (MAX_PATH, drives))
-    return false;
-  for (PWCHAR drive = drives; *drive; drive = wcschr (drive, '\0') + 1)
-    {
-      if (!GetVolumeNameForVolumeMountPointW (drive, dvol, MAX_PATH))
-       continue;
-      if (!wcscasecmp (vol, dvol))
-       mounts = wcpcpy (mounts, drive) + 1;
-      wcscpy (mp, drive);
-      HANDLE h = FindFirstVolumeMountPointW (dvol, mp + 3, MAX_PATH);
-      if (h == INVALID_HANDLE_VALUE)
-       continue;
-      do
-       {
-         if (GetVolumeNameForVolumeMountPointW (mp, dvol, MAX_PATH))
-           if (!wcscasecmp (vol, dvol))
-             mounts = wcpcpy (mounts, drive) + 1;
-       }
-      while (FindNextVolumeMountPointW (h, mp, MAX_PATH));
-      FindVolumeMountPointClose (h);
-    }
-  *mounts = L'\0';
-  return true;
-}
-
 dos_drive_mappings::dos_drive_mappings ()
 : mappings(0)
 {
@@ -1993,7 +1964,8 @@ dos_drive_mappings::dos_drive_mappings ()
     do
       {
        /* Skip drives which are not mounted. */
-       if (!get_volume_path_names_for_volume_name (vol, mounts)
+       DWORD len;
+       if (!GetVolumePathNamesForVolumeNameW (vol, mounts, NT_MAX_PATH, &len)
            || mounts[0] == L'\0')
          continue;
        *wcsrchr (vol, L'\\') = L'\0';
@@ -2045,7 +2017,7 @@ dos_drive_mappings::dos_drive_mappings ()
          }
        else
          debug_printf ("Unable to determine the native mapping for %ls "
-                       "(error %lu)", vol, GetLastError ());
+                       "(error %u)", vol, GetLastError ());
       }
     while (FindNextVolumeW (sh, vol, 64));
     FindVolumeClose (sh);
index 2ae6ccdadcda1c0af09c5dcd739a5d94b99262aa..f970121c9dec739a71e8955338b05a7ae69ec810 100644 (file)
@@ -91,7 +91,7 @@ client_request_msg::client_request_msg (int msqid,
 extern "C" int
 msgctl (int msqid, int cmd, struct msqid_ds *buf)
 {
-  syscall_printf ("msgctl (msqid = %d, cmd = 0x%x, buf = %p)",
+  syscall_printf ("msgctl (msqid = %d, cmd = %y, buf = %p)",
                  msqid, cmd, buf);
   myfault efault;
   if (efault.faulted (EFAULT))
@@ -128,7 +128,7 @@ msgctl (int msqid, int cmd, struct msqid_ds *buf)
 extern "C" int
 msgget (key_t key, int msgflg)
 {
-  syscall_printf ("msgget (key = %U, msgflg = 0x%x)", key, msgflg);
+  syscall_printf ("msgget (key = %U, msgflg = %y)", key, msgflg);
   client_request_msg request (key, msgflg);
   if (request.make_request () == -1 || request.retval () == -1)
     {
@@ -144,8 +144,8 @@ msgget (key_t key, int msgflg)
 extern "C" ssize_t
 msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
 {
-  syscall_printf ("msgrcv (msqid = %d, msgp = %p, msgsz = %d, "
-                 "msgtyp = %d, msgflg = 0x%x)",
+  syscall_printf ("msgrcv (msqid = %d, msgp = %p, msgsz = %ld, "
+                 "msgtyp = %d, msgflg = %y)",
                  msqid, msgp, msgsz, msgtyp, msgflg);
   myfault efault;
   if (efault.faulted (EFAULT))
@@ -165,7 +165,7 @@ msgrcv (int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg)
 extern "C" int
 msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
 {
-  syscall_printf ("msgsnd (msqid = %d, msgp = %p, msgsz = %d, msgflg = 0x%x)",
+  syscall_printf ("msgsnd (msqid = %d, msgp = %p, msgsz = %ld, msgflg = %y)",
                  msqid, msgp, msgsz, msgflg);
   myfault efault;
   if (efault.faulted (EFAULT))
index cccaed8b7a65e96e0782d1a09ae69acda143cd55..157fe1bf98190b8b4250e6b8885070e8d918d28e 100644 (file)
@@ -1,6 +1,6 @@
 /* mtinfo.h: Defininitions for the Cygwin tape driver class.
 
-   Copyright 2004, 2005, 2006, 2008 Red Hat, Inc.
+   Copyright 2004, 2005, 2006, 2008, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -46,26 +46,30 @@ enum lock_state
 class mtinfo_part
 {
 public:
-  long block;          /* logical block no */
-  long file;           /* current file no */
-  long fblock;         /* relative block no */
+  int32_t block;               /* logical block no */
+  int32_t file;                /* current file no */
+  int32_t fblock;              /* relative block no */
   bool smark;          /* At setmark? */
   eom_val emark;       /* "end-of"-mark */
 
-  void initialize (long nblock = -1);
+  void initialize (int32_t nblock = -1);
 };
 
 class mtinfo_drive
 {
   int drive;
   int lasterr;
-  long partition;
-  long block;
+  int32_t partition;
+  int32_t block;
   dirty_state dirty;
   lock_state lock;
   TAPE_GET_DRIVE_PARAMETERS _dp;
   TAPE_GET_MEDIA_PARAMETERS _mp;
-  OVERLAPPED ov;
+  /* sizeof(OVERLAPPED) == 20 on 32 bit, 32 on 64 bit.  A drive is always
+     opened exclusively by a single process, though, so instead of the
+     OVERLAPPED structure, we just keep track of the pointer to the
+     OVERLAPPED structure in the application's fhandler. */
+  LPOVERLAPPED ov;
   struct status_flags
   {
     unsigned buffer_writes : 1;
@@ -90,17 +94,17 @@ class mtinfo_drive
              ? ((_dp.FeaturesHigh & parm) != 0)
              : ((_dp.FeaturesLow & parm) != 0));
     }
-  int get_pos (HANDLE mt, long *ppartition = NULL, long *pblock = NULL);
-  int _set_pos (HANDLE mt, int mode, long count, int partition, BOOL dont_wait);
-  int create_partitions (HANDLE mt, long count);
-  int set_partition (HANDLE mt, long count);
+  int get_pos (HANDLE mt, int32_t *ppartition = NULL, int32_t *pblock = NULL);
+  int _set_pos (HANDLE mt, int mode, int32_t count, int partition, BOOL dont_wait);
+  int create_partitions (HANDLE mt, int32_t count);
+  int set_partition (HANDLE mt, int32_t count);
   int write_marks (HANDLE mt, int marktype, DWORD count);
   int erase (HANDLE mt, int mode);
   int prepare (HANDLE mt, int action, bool is_auto = false);
-  int set_compression (HANDLE mt, long count);
-  int set_blocksize (HANDLE mt, long count);
+  int set_compression (HANDLE mt, int32_t count);
+  int set_blocksize (HANDLE mt, DWORD count);
   int get_status (HANDLE mt, struct mtget *get);
-  int set_options (HANDLE mt, long options);
+  int set_options (HANDLE mt, int32_t options);
   int async_wait (HANDLE mt, DWORD *bytes_written);
 
 public:
@@ -109,10 +113,10 @@ public:
   int get_mp (HANDLE mt);
   int open (HANDLE mt);
   int close (HANDLE mt, bool rewind);
-  int read (HANDLE mt, HANDLE mt_evt, void *ptr, size_t &ulen);
-  int write (HANDLE mt, HANDLE mt_evt, const void *ptr, size_t &len);
+  int read (HANDLE mt, LPOVERLAPPED pov, void *ptr, size_t &ulen);
+  int write (HANDLE mt, LPOVERLAPPED pov, const void *ptr, size_t &len);
   int ioctl (HANDLE mt, unsigned int cmd, void *buf);
-  int set_pos (HANDLE mt, int mode, long count, bool sfm_func);
+  int set_pos (HANDLE mt, int mode, int32_t count, bool sfm_func);
 
   IMPLEMENT_STATUS_FLAG (bool, buffer_writes)
   IMPLEMENT_STATUS_FLAG (bool, async_writes)
index 8a0c5b5a4bc0add8b6e8331a0f64405ad58a7cfb..0454d9b32dba68db1f5c8a51c0d6128518a48365 100644 (file)
@@ -1,7 +1,7 @@
 /* net.cc: network-related routines.
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -157,7 +157,7 @@ struct tl
   int e;
 };
 
-static NO_COPY struct tl errmap[] = {
+static const struct tl errmap[] = {
   {WSAEINTR, "WSAEINTR", EINTR},
   {WSAEWOULDBLOCK, "WSAEWOULDBLOCK", EWOULDBLOCK},
   {WSAEINPROGRESS, "WSAEINPROGRESS", EINPROGRESS},
@@ -219,14 +219,14 @@ __set_winsock_errno (const char *fn, int ln)
   int err = find_winsock_errno (werr);
 
   set_errno (err);
-  syscall_printf ("%s:%d - winsock error %d -> errno %d", fn, ln, werr, err);
+  syscall_printf ("%s:%d - winsock error %u -> errno %d", fn, ln, werr, err);
 }
 
 /*
  * Since the member `s' isn't used for debug output we can use it
  * for the error text returned by herror and hstrerror.
  */
-static NO_COPY struct tl host_errmap[] = {
+static const struct tl host_errmap[] = {
   {WSAHOST_NOT_FOUND, "Unknown host", HOST_NOT_FOUND},
   {WSATRY_AGAIN, "Host name lookup failure", TRY_AGAIN},
   {WSANO_RECOVERY, "Unknown server error", NO_RECOVERY},
@@ -305,6 +305,22 @@ realloc_ent (int sz, hostent *)
    The 'unionent' struct is a union of all of the currently used
    *ent structure.  */
 
+#ifdef __x86_64__
+/* For some baffling reason, somebody at Microsoft decided that it would be
+   a good idea to exchange the s_port and s_proto members in the servent
+   structure. */
+struct win64_servent
+{
+  char  *s_name;
+  char **s_aliases;
+  char  *s_proto;
+  short  s_port;
+};
+#define WIN_SERVENT(x) ((win64_servent *)(x))
+#else
+#define WIN_SERVENT(x) ((servent *)(x))
+#endif
+
 #ifdef DEBUGGING
 static void *
 #else
@@ -369,8 +385,8 @@ dup_ent (unionent *&dst, unionent *src, unionent::struct_type type)
   int addr_list_len = 0;
   if (type == unionent::t_servent)
     {
-      if (src->s_proto)
-       sz += (protolen = strlen_round (src->s_proto));
+      if (WIN_SERVENT (src)->s_proto)
+       sz += (protolen = strlen_round (WIN_SERVENT (src)->s_proto));
     }
   else if (type == unionent::t_hostent)
     {
@@ -392,8 +408,12 @@ dup_ent (unionent *&dst, unionent *src, unionent::struct_type type)
     {
       memset (dst, 0, sz);
       /* This field is common to all *ent structures but named differently
-        in each, of course.  */
-      dst->port_proto_addrtype = src->port_proto_addrtype;
+        in each, of course.  Also, take 64 bit Windows servent weirdness
+        into account. */
+      if (type == unionent::t_servent)
+       dst->port_proto_addrtype = WIN_SERVENT (src)->s_port;
+      else
+       dst->port_proto_addrtype = src->port_proto_addrtype;
 
       char *dp = ((char *) dst) + struct_sz;
       if (namelen)
@@ -420,12 +440,12 @@ dup_ent (unionent *&dst, unionent *src, unionent::struct_type type)
 
       /* Do servent/protoent/hostent specific processing. */
       if (type == unionent::t_protoent)
-       debug_printf ("protoent %s %x %x", dst->name, dst->list, dst->port_proto_addrtype);
+       debug_printf ("protoent %s %p %y", dst->name, dst->list, dst->port_proto_addrtype);
       else if (type == unionent::t_servent)
        {
-         if (src->s_proto)
+         if (WIN_SERVENT (src)->s_proto)
            {
-             strcpy (dst->s_proto = dp, src->s_proto);
+             strcpy (dst->s_proto = dp, WIN_SERVENT (src)->s_proto);
              dp += protolen;
            }
        }
@@ -534,7 +554,7 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc)
       ret = WSAIoctl (soc, SIO_BASE_HANDLE, NULL, 0, (void *) &base_soc,
                      sizeof (base_soc), &bret, NULL, NULL);
       if (ret)
-       debug_printf ("WSAIoctl: %lu", WSAGetLastError ());
+       debug_printf ("WSAIoctl: %u", WSAGetLastError ());
       else if (base_soc != soc)
        {
          /* LSPs are often BLODAs as well.  So we print an info about
@@ -585,26 +605,35 @@ fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc)
      handle inheritance.  An explanation for this weird behaviour would
      be nice, though.
 
+     NOTE 2.  Testing on x86_64 (XP, Vista, 2008 R2, W8) indicates that
+     this is no problem on 64 bit.  So we set the default buffer size to
+     the default values in current 3.x Linux versions.
+
      (*) Maximum normal TCP window size.  Coincidence?  */
+#ifdef __x86_64__
+  ((fhandler_socket *) fd)->rmem () = 212992;
+  ((fhandler_socket *) fd)->wmem () = 212992;
+#else
   ((fhandler_socket *) fd)->rmem () = 65535;
   ((fhandler_socket *) fd)->wmem () = 65535;
+#endif
   if (::setsockopt (soc, SOL_SOCKET, SO_RCVBUF,
                    (char *) &((fhandler_socket *) fd)->rmem (), sizeof (int)))
     {
-      debug_printf ("setsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ());
+      debug_printf ("setsockopt(SO_RCVBUF) failed, %u", WSAGetLastError ());
       if (::getsockopt (soc, SOL_SOCKET, SO_RCVBUF,
                        (char *) &((fhandler_socket *) fd)->rmem (),
                        (size = sizeof (int), &size)))
-       system_printf ("getsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ());
+       system_printf ("getsockopt(SO_RCVBUF) failed, %u", WSAGetLastError ());
     }
   if (::setsockopt (soc, SOL_SOCKET, SO_SNDBUF,
                    (char *) &((fhandler_socket *) fd)->wmem (), sizeof (int)))
     {
-      debug_printf ("setsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ());
+      debug_printf ("setsockopt(SO_SNDBUF) failed, %u", WSAGetLastError ());
       if (::getsockopt (soc, SOL_SOCKET, SO_SNDBUF,
                        (char *) &((fhandler_socket *) fd)->wmem (),
                        (size = sizeof (int), &size)))
-       system_printf ("getsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ());
+       system_printf ("getsockopt(SO_SNDBUF) failed, %u", WSAGetLastError ());
     }
 
   return true;
@@ -620,7 +649,7 @@ cygwin_socket (int af, int type, int protocol)
   int flags = type & _SOCK_FLAG_MASK;
   type &= ~_SOCK_FLAG_MASK;
 
-  debug_printf ("socket (%d, %d (flags %p), %d)", af, type, flags, protocol);
+  debug_printf ("socket (%d, %d (flags %y), %d)", af, type, flags, protocol);
 
   if ((flags & ~(SOCK_NONBLOCK | SOCK_CLOEXEC)) != 0)
     {
@@ -670,7 +699,7 @@ cygwin_socket (int af, int type, int protocol)
            DWORD blen;
            if (WSAIoctl (soc, SIO_UDP_CONNRESET, &cr, sizeof cr, NULL, 0,
                          &blen, NULL, NULL) == SOCKET_ERROR)
-             debug_printf ("Reset SIO_UDP_CONNRESET: WinSock error %lu",
+             debug_printf ("Reset SIO_UDP_CONNRESET: WinSock error %u",
                            WSAGetLastError ());
          }
        res = fd;
@@ -678,17 +707,19 @@ cygwin_socket (int af, int type, int protocol)
   }
 
 done:
-  syscall_printf ("%R = socket(%d, %d (flags %p), %d)",
+  syscall_printf ("%R = socket(%d, %d (flags %y), %d)",
                  res, af, type, flags, protocol);
   return res;
 }
 
 /* exported as sendto: standards? */
-extern "C" int
+extern "C" ssize_t
 cygwin_sendto (int fd, const void *buf, size_t len, int flags,
               const struct sockaddr *to, socklen_t tolen)
 {
-  int res;
+  ssize_t res;
+
+  pthread_testcancel ();
 
   fhandler_socket *fh = get (fd);
 
@@ -698,17 +729,19 @@ cygwin_sendto (int fd, const void *buf, size_t len, int flags,
   else
     res = fh->sendto (buf, len, flags, to, tolen);
 
-  syscall_printf ("%R = sendto(%d, %p, %d, %x, %p, %d)",
+  syscall_printf ("%lR = sendto(%d, %p, %ld, %y, %p, %d)",
                  res, fd, buf, len, flags, to, tolen);
   return res;
 }
 
 /* exported as recvfrom: standards? */
-extern "C" int
+extern "C" ssize_t
 cygwin_recvfrom (int fd, void *buf, size_t len, int flags,
                 struct sockaddr *from, socklen_t *fromlen)
 {
-  int res;
+  ssize_t res;
+
+  pthread_testcancel ();
 
   fhandler_socket *fh = get (fd);
 
@@ -722,7 +755,7 @@ cygwin_recvfrom (int fd, void *buf, size_t len, int flags,
        to deliver valid error conditions and peer address. */
     res = fh->recvfrom (buf, len, flags, from, fromlen);
 
-  syscall_printf ("%R = recvfrom(%d, %p, %d, %x, %p, %p)",
+  syscall_printf ("%lR = recvfrom(%d, %p, %ld, %y, %p, %p)",
                  res, fd, buf, len, flags, from, fromlen);
   return res;
 }
@@ -786,8 +819,8 @@ cygwin_setsockopt (int fd, int level, int optname, const void *optval,
        res = setsockopt (fh->get_socket (), level, optname,
                          (const char *) optval, optlen);
 
-      if (optlen == 4)
-       syscall_printf ("setsockopt optval=%x", *(long *) optval);
+      if (optlen == sizeof (int))
+       syscall_printf ("setsockopt optval=%x", *(int *) optval);
 
       if (res)
        {
@@ -837,7 +870,7 @@ cygwin_setsockopt (int fd, int level, int optname, const void *optval,
          }
     }
 
-  syscall_printf ("%R = setsockopt(%d, %d, %x, %p, %d)",
+  syscall_printf ("%R = setsockopt(%d, %d, %y, %p, %d)",
                  res, fd, level, optname, optval, optlen);
   return res;
 }
@@ -897,13 +930,13 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval,
        }
     }
 
-  syscall_printf ("%R = getsockopt(%d, %d, 0x%x, %p, %p)",
+  syscall_printf ("%R = getsockopt(%d, %d, %y, %p, %p)",
                  res, fd, level, optname, optval, optlen);
   return res;
 }
 
 extern "C" int
-getpeereid (int fd, __uid32_t *euid, __gid32_t *egid)
+getpeereid (int fd, uid_t *euid, gid_t *egid)
 {
   fhandler_socket *fh = get (fd);
   if (fh)
@@ -917,6 +950,8 @@ cygwin_connect (int fd, const struct sockaddr *name, socklen_t namelen)
 {
   int res;
 
+  pthread_testcancel ();
+
   fhandler_socket *fh = get (fd);
 
   myfault efault;
@@ -1293,6 +1328,8 @@ cygwin_accept (int fd, struct sockaddr *peer, socklen_t *len)
 {
   int res;
 
+  pthread_testcancel ();
+
   fhandler_socket *fh = get (fd);
 
   myfault efault;
@@ -1310,6 +1347,8 @@ accept4 (int fd, struct sockaddr *peer, socklen_t *len, int flags)
 {
   int res;
 
+  pthread_testcancel ();
+
   fhandler_socket *fh = get (fd);
 
   myfault efault;
@@ -1323,7 +1362,7 @@ accept4 (int fd, struct sockaddr *peer, socklen_t *len, int flags)
   else
     res = fh->accept4 (peer, len, flags);
 
-  syscall_printf ("%R = accept4(%d, %p, %p, %p)", res, fd, peer, len, flags);
+  syscall_printf ("%R = accept4(%d, %p, %p, %y)", res, fd, peer, len, flags);
   return res;
 }
 
@@ -1457,15 +1496,18 @@ cygwin_getpeername (int fd, struct sockaddr *name, socklen_t *len)
   else
     res = fh->getpeername (name, len);
 
-  syscall_printf ("%R = getpeername(%d) %d", res, fd, (fh ? fh->get_socket () : -1));
+  syscall_printf ("%R = getpeername(%d) %p", res, fd,
+                 (fh ? fh->get_socket () : (SOCKET) -1));
   return res;
 }
 
 /* exported as recv: standards? */
-extern "C" int
+extern "C" ssize_t
 cygwin_recv (int fd, void *buf, size_t len, int flags)
 {
-  int res;
+  ssize_t res;
+
+  pthread_testcancel ();
 
   fhandler_socket *fh = get (fd);
 
@@ -1479,15 +1521,17 @@ cygwin_recv (int fd, void *buf, size_t len, int flags)
        to deliver valid error conditions. */
     res = fh->recvfrom (buf, len, flags, NULL, NULL);
 
-  syscall_printf ("%R = recv(%d, %p, %d, %x)", res, fd, buf, len, flags);
+  syscall_printf ("%lR = recv(%d, %p, %ld, %y)", res, fd, buf, len, flags);
   return res;
 }
 
 /* exported as send: standards? */
-extern "C" int
+extern "C" ssize_t
 cygwin_send (int fd, const void *buf, size_t len, int flags)
 {
-  int res;
+  ssize_t res;
+
+  pthread_testcancel ();
 
   fhandler_socket *fh = get (fd);
 
@@ -1497,7 +1541,7 @@ cygwin_send (int fd, const void *buf, size_t len, int flags)
   else
     res = fh->sendto (buf, len, flags, NULL, 0);
 
-  syscall_printf ("%R = send(%d, %p, %d, %x)", res, fd, buf, len, flags);
+  syscall_printf ("%lR = send(%d, %p, %ld, %y)", res, fd, buf, len, flags);
   return res;
 }
 
@@ -1855,12 +1899,12 @@ get_hwaddr (struct ifall *ifp, PIP_ADAPTER_ADDRESSES pap)
     else
       ifp->ifa_hwaddr.sa_data[i] = pap->PhysicalAddress[i];
 }
+
 /*
- * Get network interfaces XP SP1 and above.
- * Use IP Helper function GetAdaptersAddresses.
+ * Get network interfaces.  Use IP Helper function GetAdaptersAddresses.
  */
 static struct ifall *
-get_xp_ifs (ULONG family)
+get_ifs (ULONG family)
 {
   PIP_ADAPTER_ADDRESSES pa0 = NULL, pap;
   PIP_ADAPTER_UNICAST_ADDRESS pua;
@@ -2038,201 +2082,6 @@ done:
   return ifret;
 }
 
-/*
- * Get network interfaces up to XP w/o service packs.
- */
-static struct ifall *
-get_2k_ifs ()
-{
-  int ethId = 0, pppId = 0, slpId = 0, tokId = 0;
-
-  DWORD ip_cnt;
-  DWORD siz_ip_table = 0;
-  PMIB_IPADDRTABLE ipt;
-  PMIB_IFROW ifrow;
-  struct ifall *ifret = NULL, *ifp = NULL;
-  struct sockaddr_in *if_sin;
-
-  struct ifcount_t
-  {
-    DWORD ifIndex;
-    size_t count;
-    unsigned int enumerated;   // for eth0:1
-    unsigned int classId;      // for eth0, tok0 ...
-
-  };
-  ifcount_t *iflist, *ifEntry;
-
-  if (GetIpAddrTable (NULL, &siz_ip_table, TRUE) == ERROR_INSUFFICIENT_BUFFER
-      && (ifrow = (PMIB_IFROW) alloca (sizeof (MIB_IFROW)))
-      && (ipt = (PMIB_IPADDRTABLE) alloca (siz_ip_table))
-      && !GetIpAddrTable (ipt, &siz_ip_table, TRUE))
-    {
-      if (!(ifret = (struct ifall *) calloc (ipt->dwNumEntries, sizeof (struct ifall))))
-       goto done;
-      ifp = ifret;
-
-      iflist =
-       (ifcount_t *) alloca (sizeof (ifcount_t) * (ipt->dwNumEntries + 1));
-      memset (iflist, 0, sizeof (ifcount_t) * (ipt->dwNumEntries + 1));
-      for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
-       {
-         ifEntry = iflist;
-         /* search for matching entry (and stop at first free entry) */
-         while (ifEntry->count != 0)
-           {
-             if (ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex)
-               break;
-             ifEntry++;
-           }
-         if (ifEntry->count == 0)
-           {
-             ifEntry->count = 1;
-             ifEntry->ifIndex = ipt->table[ip_cnt].dwIndex;
-           }
-         else
-           {
-             ifEntry->count++;
-           }
-       }
-      /* reset the last element. This is just the stopper for the loop. */
-      iflist[ipt->dwNumEntries].count = 0;
-
-      /* Iterate over all configured IP-addresses */
-      for (ip_cnt = 0; ip_cnt < ipt->dwNumEntries; ++ip_cnt)
-       {
-         memset (ifrow, 0, sizeof (MIB_IFROW));
-         ifrow->dwIndex = ipt->table[ip_cnt].dwIndex;
-         if (GetIfEntry (ifrow) != NO_ERROR)
-           continue;
-
-         ifcount_t *ifEntry = iflist;
-
-         /* search for matching entry (and stop at first free entry) */
-         while (ifEntry->count != 0)
-           {
-             if (ifEntry->ifIndex == ipt->table[ip_cnt].dwIndex)
-               break;
-             ifEntry++;
-           }
-
-         /* Next in chain */
-         ifp->ifa_ifa.ifa_next = (struct ifaddrs *) &ifp[1].ifa_ifa;
-         /* Interface name */
-         if (ifrow->dwType == IF_TYPE_SOFTWARE_LOOPBACK)
-           strcpy (ifp->ifa_name, "lo");
-         else
-           {
-             const char *name = "";
-             switch (ifrow->dwType)
-               {
-                 case IF_TYPE_ISO88025_TOKENRING:
-                   name = "tok";
-                   if (ifEntry->enumerated == 0)
-                     ifEntry->classId = tokId++;
-                   break;
-                 case IF_TYPE_ETHERNET_CSMACD:
-                   name = "eth";
-                   if (ifEntry->enumerated == 0)
-                     ifEntry->classId = ethId++;
-                   break;
-                 case IF_TYPE_PPP:
-                   name = "ppp";
-                   if (ifEntry->enumerated == 0)
-                     ifEntry->classId = pppId++;
-                   break;
-                 case IF_TYPE_SLIP:
-                   name = "slp";
-                   if (ifEntry->enumerated == 0)
-                     ifEntry->classId = slpId++;
-                   break;
-                 default:
-                   continue;
-               }
-             __small_sprintf (ifp->ifa_name,
-                              ifEntry->enumerated ? "%s%u:%u" : "%s%u",
-                              name, ifEntry->classId, ifEntry->enumerated);
-             ifEntry->enumerated++;
-           }
-         ifp->ifa_ifa.ifa_name = ifp->ifa_name;
-         /* Flags */
-         if (ifrow->dwType == IF_TYPE_SOFTWARE_LOOPBACK)
-           ifp->ifa_ifa.ifa_flags |= IFF_LOOPBACK;
-         else if (ifrow->dwType == IF_TYPE_PPP
-                  || ifrow->dwType == IF_TYPE_SLIP)
-           ifp->ifa_ifa.ifa_flags |= IFF_POINTOPOINT | IFF_NOARP;
-         else
-           ifp->ifa_ifa.ifa_flags |= IFF_BROADCAST;
-         if (ifrow->dwAdminStatus == IF_ADMIN_STATUS_UP)
-           {
-             ifp->ifa_ifa.ifa_flags |= IFF_UP | IFF_LOWER_UP;
-             if (ifrow->dwOperStatus >= IF_OPER_STATUS_CONNECTED)
-               ifp->ifa_ifa.ifa_flags |= IFF_RUNNING;
-           }
-         /* Address */
-         if_sin = (struct sockaddr_in *) &ifp->ifa_addr;
-         if_sin->sin_addr.s_addr = ipt->table[ip_cnt].dwAddr;
-         if_sin->sin_family = AF_INET;
-         ifp->ifa_ifa.ifa_addr = (struct sockaddr *) &ifp->ifa_addr;
-         /* Netmask */
-         if_sin = (struct sockaddr_in *) &ifp->ifa_netmask;
-         if_sin->sin_addr.s_addr = ipt->table[ip_cnt].dwMask;
-         if_sin->sin_family = AF_INET;
-         ifp->ifa_ifa.ifa_netmask = (struct sockaddr *) &ifp->ifa_netmask;
-         if_sin = (struct sockaddr_in *) &ifp->ifa_brddstaddr;
-         if (ifrow->dwType == IF_TYPE_PPP
-             || ifrow->dwType == IF_TYPE_SLIP)
-           {
-             /* Destination address */
-             if_sin->sin_addr.s_addr =
-               get_routedst (ipt->table[ip_cnt].dwIndex);
-             ifp->ifa_ifa.ifa_dstaddr = (struct sockaddr *)
-                                        &ifp->ifa_brddstaddr;
-           }
-         else
-           {
-             /* Broadcast address */
-#if 0
-             /* Unfortunately, the field returns only crap. */
-             if_sin->sin_addr.s_addr = ipt->table[ip_cnt].dwBCastAddr;
-#else
-             uint32_t mask = ipt->table[ip_cnt].dwMask;
-             if_sin->sin_addr.s_addr = (ipt->table[ip_cnt].dwAddr & mask) | ~mask;
-#endif
-             ifp->ifa_ifa.ifa_broadaddr = (struct sockaddr *)
-                                          &ifp->ifa_brddstaddr;
-           }
-         if_sin->sin_family = AF_INET;
-         /* Hardware address */
-         for (UINT i = 0; i < IFHWADDRLEN; ++i)
-           if (i >= ifrow->dwPhysAddrLen)
-             ifp->ifa_hwaddr.sa_data[i] = '\0';
-           else
-             ifp->ifa_hwaddr.sa_data[i] = ifrow->bPhysAddr[i];
-         /* Metric */
-         ifp->ifa_metric = 1;
-         /* MTU */
-         ifp->ifa_mtu = ifrow->dwMtu;
-         /* Interface index */
-         ifp->ifa_ifindex = ifrow->dwIndex;
-         /* Friendly name */
-         struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *)
-                                        &ifp->ifa_frndlyname;
-         iff->ifrf_len = sys_wcstombs (iff->ifrf_friendlyname,
-                                       IFRF_FRIENDLYNAMESIZ,
-                                       ifrow->wszName);
-         ++ifp;
-       }
-    }
-  /* Since every entry is set to the next entry, the last entry points to an
-     invalid next entry now.  Fix it retroactively. */
-  if (ifp > ifret)
-    ifp[-1].ifa_ifa.ifa_next = NULL;
-
-done:
-  return ifret;
-}
-
 extern "C" int
 getifaddrs (struct ifaddrs **ifap)
 {
@@ -2242,10 +2091,7 @@ getifaddrs (struct ifaddrs **ifap)
       return -1;
     }
   struct ifall *ifp;
-  if (wincap.has_gaa_prefixes () && !CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
-    ifp = get_xp_ifs (AF_UNSPEC);
-  else
-    ifp = get_2k_ifs ();
+  ifp = get_ifs (AF_UNSPEC);
   *ifap = &ifp->ifa_ifa;
   return ifp ? 0 : -1;
 }
@@ -2272,10 +2118,7 @@ get_ifconf (struct ifconf *ifc, int what)
     }
 
   struct ifall *ifret, *ifp;
-  if (wincap.has_gaa_prefixes () && !CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
-    ifret = get_xp_ifs (AF_INET);
-  else
-    ifret = get_2k_ifs ();
+  ifret = get_ifs (AF_INET);
   if (!ifret)
     return -1;
 
@@ -2354,8 +2197,7 @@ if_nametoindex (const char *name)
   if (efault.faulted (EFAULT))
     return 0;
 
-  if (wincap.has_gaa_prefixes ()
-      && get_adapters_addresses (&pa0, AF_UNSPEC))
+  if (get_adapters_addresses (&pa0, AF_UNSPEC))
     {
       char lname[IF_NAMESIZE], *c;
 
@@ -2384,8 +2226,7 @@ if_indextoname (unsigned ifindex, char *ifname)
   if (efault.faulted (EFAULT))
     return NULL;
 
-  if (wincap.has_gaa_prefixes ()
-      && get_adapters_addresses (&pa0, AF_UNSPEC))
+  if (get_adapters_addresses (&pa0, AF_UNSPEC))
     {
       for (pap = pa0; pap; pap = pap->Next)
        if (ifindex == (pap->Ipv6IfIndex ?: pap->IfIndex))
@@ -2424,8 +2265,7 @@ if_nameindex (void)
   if (efault.faulted (EFAULT))
     return NULL;
 
-  if (wincap.has_gaa_prefixes ()
-      && get_adapters_addresses (&pa0, AF_UNSPEC))
+  if (get_adapters_addresses (&pa0, AF_UNSPEC))
     {
       int cnt = 0;
       for (pap = pa0; pap; pap = pap->Next)
@@ -2780,10 +2620,12 @@ endhostent (void)
 }
 
 /* exported as recvmsg: standards? */
-extern "C" int
+extern "C" ssize_t
 cygwin_recvmsg (int fd, struct msghdr *msg, int flags)
 {
-  int res;
+  ssize_t res;
+
+  pthread_testcancel ();
 
   fhandler_socket *fh = get (fd);
 
@@ -2801,15 +2643,17 @@ cygwin_recvmsg (int fd, struct msghdr *msg, int flags)
        res = fh->recvmsg (msg, flags);
     }
 
-  syscall_printf ("%R = recvmsg(%d, %p, %x)", res, fd, msg, flags);
+  syscall_printf ("%lR = recvmsg(%d, %p, %y)", res, fd, msg, flags);
   return res;
 }
 
 /* exported as sendmsg: standards? */
-extern "C" int
+extern "C" ssize_t
 cygwin_sendmsg (int fd, const struct msghdr *msg, int flags)
 {
-  int res;
+  ssize_t res;
+
+  pthread_testcancel ();
 
   fhandler_socket *fh = get (fd);
 
@@ -2823,7 +2667,7 @@ cygwin_sendmsg (int fd, const struct msghdr *msg, int flags)
        res = fh->sendmsg (msg, flags);
     }
 
-  syscall_printf ("%R = sendmsg(%d, %p, %x)", res, fd, msg, flags);
+  syscall_printf ("%lR = sendmsg(%d, %p, %y)", res, fd, msg, flags);
   return res;
 }
 
@@ -4144,11 +3988,9 @@ w32_to_gai_err (int w32_err)
   return w32_err;
 }
 
-/* We can't use autoload here because we don't know where the functions
-   are loaded from.  On Win2K, the functions are available in the
-   ipv6 technology preview lib called wship6.dll, in XP and above they
-   are implemented in ws2_32.dll.  For older systems we use the ipv4-only
-   version above. */
+/* We can't use autoload here because we don't know if the functions
+   are available (pre-Vista).  For those systems we redirect to the
+   ipv4-only version above. */
 
 static void (WINAPI *ws_freeaddrinfo)(const struct addrinfo *);
 static int (WINAPI *ws_getaddrinfo)(const char *, const char *,
@@ -4189,13 +4031,6 @@ load_ipv6_funcs ()
   WSAGetLastError ();  /* Kludge.  Enforce WSAStartup call. */
   lib_name = wcpcpy (lib_path, windows_system_directory);
   wcpcpy (lib_name, L"ws2_32.dll");
-  if ((lib = LoadLibraryW (lib_path)))
-    {
-      if (get_ipv6_funcs (lib))
-       goto out;
-      FreeLibrary (lib);
-    }
-  wcpcpy (lib_name, L"wship6.dll");
   if ((lib = LoadLibraryW (lib_path)))
     {
       if (get_ipv6_funcs (lib))
index c6d8624b6cffd23a146a394db2668ce344b74952..3e3b3549855bee31d06ae17c2372cffda90e32a9 100644 (file)
@@ -1,6 +1,6 @@
 /* netdb.cc: network database related routines.
 
-   Copyright 2002, 2003, 2007, 2008, 2010, 2011 Red Hat, Inc.
+   Copyright 2002, 2003, 2007, 2008, 2010, 2011, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -115,7 +115,7 @@ get_entire_line (FILE *fd)
 
 /* Characters representing whitespace.  Used by parse_* routines to
 delimit tokens.  */
-static const NO_COPY char *SPACE = " \t\n\r\f";
+static const char *SPACE = " \t\n\r\f";
 
 /* Parse a list aliases from a network database file.  Returns a
 char** structure terminated by a NULL. */
index f185fe0b14592170af401587c16dcca2566f6288..72a0179c7ce315224eddc26f7daca2c6d055ff4f 100644 (file)
@@ -22,6 +22,13 @@ enum ftype3 {
   NF3FIFO   = 7
 };
 
+#pragma pack (push, 4)
+struct nfs_timestruc_t
+{
+  int32_t  tv_sec;
+  uint32_t tv_nsec;
+};
+
 struct fattr3 {
   uint32_t type;
   uint32_t mode;
@@ -38,10 +45,11 @@ struct fattr3 {
     } rdev;
   uint64_t fsid;
   uint64_t fileid;
-  timestruc_t atime;
-  timestruc_t mtime;
-  timestruc_t ctime;
+  struct nfs_timestruc_t atime;
+  struct nfs_timestruc_t mtime;
+  struct nfs_timestruc_t ctime;
 };
+#pragma pack (pop)
 
 struct nfs_aol_ffei_t {
   ULONG NextEntryOffset;
index f2df9123d24ba54d15de8dc713a6612a1c79fd9f..0bbd4759c6d45f629e470fb3f3e8f6b998842ab1 100644 (file)
@@ -1,6 +1,6 @@
 /* nlsfuncs.cc: NLS helper functions
 
-   Copyright 2010, 2011, 2012 Red Hat, Inc.
+   Copyright 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -41,11 +41,6 @@ details. */
 
 #define has_modifier(x)        ((x)[0] && !strcmp (modifier, (x)))
 
-/* Vista and later.  Not defined in w32api yet. */
-extern "C" {
-WINBASEAPI LCID WINAPI LocaleNameToLCID (LPCWSTR, DWORD);
-};
-
 static char last_locale[ENCODING_LEN + 1];
 static LCID last_lcid;
 
@@ -66,7 +61,7 @@ __get_lcid_from_locale (const char *name)
   /* Speed up reusing the same locale as before, for instance in LC_ALL case. */
   if (!strcmp (name, last_locale))
     {
-      debug_printf ("LCID=0x%04x", last_lcid);
+      debug_printf ("LCID=%04y", last_lcid);
       return last_lcid;
     }
   stpcpy (last_locale, name);
@@ -145,7 +140,7 @@ __get_lcid_from_locale (const char *name)
              }
        }
       last_lcid = lcid ?: (LCID) -1;
-      debug_printf ("LCID=0x%04x", last_lcid);
+      debug_printf ("LCID=%04y", last_lcid);
       return last_lcid;
     }
   /* Pre-Vista we have to loop through the LCID values and see if they
@@ -230,7 +225,7 @@ __get_lcid_from_locale (const char *name)
        lcid = MAKELANGID (lcid & 0x3ff, (lcid >> 10) + 1);
     }
   last_lcid = lcid ?: (LCID) -1;
-  debug_printf ("LCID=0x%04x", last_lcid);
+  debug_printf ("LCID=%04y", last_lcid);
   return last_lcid;
 }
 
@@ -1196,8 +1191,8 @@ strcoll (const char *s1, const char *s2)
 extern "C" int
 __collate_range_cmp (int c1, int c2)
 {
-  char s1[2] = { c1, '\0' };
-  char s2[2] = { c2, '\0' };
+  char s1[2] = { (char) c1, '\0' };
+  char s2[2] = { (char) c2, '\0' };
   return strcoll (s1, s2);
 }
 
index e4ac385954e0b463556b0b843573956727f16995..4d302ffe72de1c0a49b106904662ada5d1e1bfd4 100644 (file)
@@ -1,7 +1,7 @@
 /* ntdll.h.  Contains ntdll specific stuff not defined elsewhere.
 
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-   2011, 2012 Red Hat, Inc.
+   2011, 2012, 2013 Red Hat, Inc.
 
    This file is part of Cygwin.
 
 /* custom status code: */
 #define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269)
 
-#define NtCurrentProcess() ((HANDLE) 0xffffffff)
-#define NtCurrentThread()  ((HANDLE) 0xfffffffe)
+/* As of March 2013, Mingw doesn't define these status codes yet. */
+#ifndef STATUS_NETWORK_OPEN_RESTRICTION
+#define STATUS_NETWORK_OPEN_RESTRICTION ((NTSTATUS)0xC0000201)
+#endif
+#ifndef STATUS_SYMLINK_CLASS_DISABLED
+#define STATUS_SYMLINK_CLASS_DISABLED ((NTSTATUS)0xC0000715)
+#endif
+
+#define NtCurrentProcess() ((HANDLE) (LONG_PTR) -1)
+#define NtCurrentThread()  ((HANDLE) (LONG_PTR) -2)
 
 /* Creation information returned in IO_STATUS_BLOCK. */
 #define FILE_SUPERSEDED     0
 #define PDI_MODULES 0x01
 #define PDI_HEAPS 0x04
 #define PDI_HEAP_BLOCKS 0x10
+#define PDI_WOW64_MODULES 0x40
 
 /* VM working set list protection values.  Returned by NtQueryVirtualMemory. */
 #define WSLE_PAGE_READONLY 0x001
@@ -181,6 +190,7 @@ typedef enum _FILE_INFORMATION_CLASS
   FileMaximumInformation
 } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_NAMES_INFORMATION
 {
   ULONG  NextEntryOffset;
@@ -189,7 +199,9 @@ typedef struct _FILE_NAMES_INFORMATION
   WCHAR  FileName[1];
 } FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
 
-typedef struct _FILE_DIRECTORY_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_DIRECTORY_INFORMATION
+{
   ULONG  NextEntryOffset;
   ULONG  FileIndex;
   LARGE_INTEGER  CreationTime;
@@ -203,7 +215,8 @@ typedef struct _FILE_DIRECTORY_INFORMATION {
   WCHAR  FileName[1];
 } FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;
 
-typedef struct _FILE_BOTH_DIRECTORY_INFORMATION
+/* Checked on 64 bit. */
+typedef struct _FILE_BOTH_DIR_INFORMATION
 {
   ULONG  NextEntryOffset;
   ULONG  FileIndex;
@@ -219,8 +232,9 @@ typedef struct _FILE_BOTH_DIRECTORY_INFORMATION
   CCHAR  ShortNameLength;
   WCHAR  ShortName[12];
   WCHAR  FileName[1];
-} FILE_BOTH_DIRECTORY_INFORMATION, *PFILE_BOTH_DIRECTORY_INFORMATION;
+} FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_ID_BOTH_DIR_INFORMATION
 {
   ULONG  NextEntryOffset;
@@ -240,20 +254,19 @@ typedef struct _FILE_ID_BOTH_DIR_INFORMATION
   WCHAR  FileName[1];
 } FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;
 
-typedef ULONG KAFFINITY;
-
 typedef enum _SYSTEM_INFORMATION_CLASS
 {
   SystemBasicInformation = 0,
   SystemPerformanceInformation = 2,
   SystemTimeOfDayInformation = 3,
-  SystemProcessesAndThreadsInformation = 5,
-  SystemProcessorTimes = 8,
+  SystemProcessInformation = 5,
+  SystemProcessorPerformanceInformation = 8,
   SystemHandleInformation = 16,
   SystemPagefileInformation = 18,
   /* There are a lot more of these... */
 } SYSTEM_INFORMATION_CLASS;
 
+/* Checked on 64 bit. */
 typedef struct _SYSTEM_BASIC_INFORMATION
 {
   ULONG Unknown;
@@ -263,12 +276,13 @@ typedef struct _SYSTEM_BASIC_INFORMATION
   ULONG LowestPhysicalPage;
   ULONG HighestPhysicalPage;
   ULONG AllocationGranularity;
-  ULONG LowestUserAddress;
-  ULONG HighestUserAddress;
-  ULONG ActiveProcessors;
+  ULONG_PTR LowestUserAddress;
+  ULONG_PTR HighestUserAddress;
+  ULONG_PTR ActiveProcessors;
   UCHAR NumberProcessors;
 } SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _SYSTEM_PAGEFILE_INFORMATION
 {
   ULONG NextEntryOffset;
@@ -278,7 +292,8 @@ typedef struct _SYSTEM_PAGEFILE_INFORMATION
   UNICODE_STRING FileName;
 } SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION;
 
-typedef struct __attribute__ ((aligned (8))) _SYSTEM_PROCESSOR_TIMES
+/* Checked on 64 bit. */
+typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
 {
   LARGE_INTEGER IdleTime;
   LARGE_INTEGER KernelTime;
@@ -286,24 +301,27 @@ typedef struct __attribute__ ((aligned (8))) _SYSTEM_PROCESSOR_TIMES
   LARGE_INTEGER DpcTime;
   LARGE_INTEGER InterruptTime;
   ULONG InterruptCount;
-} SYSTEM_PROCESSOR_TIMES, *PSYSTEM_PROCESSOR_TIMES;
+} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
 
 typedef LONG KPRIORITY;
+
+/* Checked on 64 bit. */
 typedef struct _VM_COUNTERS
 {
-  ULONG PeakVirtualSize;
-  ULONG VirtualSize;
+  SIZE_T PeakVirtualSize;
+  SIZE_T VirtualSize;
   ULONG PageFaultCount;
-  ULONG PeakWorkingSetSize;
-  ULONG WorkingSetSize;
-  ULONG QuotaPeakPagedPoolUsage;
-  ULONG QuotaPagedPoolUsage;
-  ULONG QuotaPeakNonPagedPoolUsage;
-  ULONG QuotaNonPagedPoolUsage;
-  ULONG PagefileUsage;
-  ULONG PeakPagefileUsage;
+  SIZE_T PeakWorkingSetSize;
+  SIZE_T WorkingSetSize;
+  SIZE_T QuotaPeakPagedPoolUsage;
+  SIZE_T QuotaPagedPoolUsage;
+  SIZE_T QuotaPeakNonPagedPoolUsage;
+  SIZE_T QuotaNonPagedPoolUsage;
+  SIZE_T PagefileUsage;
+  SIZE_T PeakPagefileUsage;
 } VM_COUNTERS, *PVM_COUNTERS;
 
+/* Checked on 64 bit. */
 typedef struct _CLIENT_ID
 {
   HANDLE UniqueProcess;
@@ -354,6 +372,7 @@ typedef enum
   MaximumWaitReason
 } KWAIT_REASON;
 
+/* Checked on 64 bit. */
 typedef struct _SYSTEM_THREADS
 {
   LARGE_INTEGER KernelTime;
@@ -370,31 +389,39 @@ typedef struct _SYSTEM_THREADS
   DWORD Reserved;
 } SYSTEM_THREADS, *PSYSTEM_THREADS;
 
-typedef struct _SYSTEM_PROCESSES
+/* Checked on 64 bit. */
+typedef struct _SYSTEM_PROCESS_INFORMATION
 {
-  ULONG NextEntryDelta;
-  ULONG ThreadCount;
+  ULONG NextEntryOffset;
+  ULONG NumberOfThreads;
   ULONG Reserved1[6];
   LARGE_INTEGER CreateTime;
   LARGE_INTEGER UserTime;
   LARGE_INTEGER KernelTime;
-  UNICODE_STRING ProcessName;
+  UNICODE_STRING ImageName;
   KPRIORITY BasePriority;
-  ULONG ProcessId;
-  ULONG InheritedFromProcessId;
+  HANDLE UniqueProcessId;
+  HANDLE InheritedFromUniqueProcessId;
   ULONG HandleCount;
-  ULONG Reserved2[2];
-  VM_COUNTERS VmCounters;
+  ULONG SessionId;
+  ULONG PageDirectoryBase;
+  VM_COUNTERS VirtualMemoryCounters;
+  SIZE_T PrivatePageCount;
   IO_COUNTERS IoCounters;
   SYSTEM_THREADS Threads[1];
-} SYSTEM_PROCESSES, *PSYSTEM_PROCESSES;
+} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _IO_STATUS_BLOCK
 {
-  NTSTATUS Status;
-  ULONG Information;
+  union {
+    NTSTATUS Status;
+    PVOID Pointer;
+  };
+  ULONG_PTR Information;
 } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
 
+/* Checked on 64 bit. */
 typedef struct _SYSTEM_PERFORMANCE_INFORMATION
 {
   LARGE_INTEGER IdleTime;
@@ -472,13 +499,15 @@ typedef struct _SYSTEM_PERFORMANCE_INFORMATION
   ULONG SystemCalls;
 } SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
 
-typedef struct __attribute__ ((aligned(8))) _SYSTEM_TIME_OF_DAY_INFORMATION
+/* Checked on 64 bit. */
+typedef struct _SYSTEM_TIMEOFDAY_INFORMATION
 {
   LARGE_INTEGER BootTime;
   LARGE_INTEGER CurrentTime;
   LARGE_INTEGER TimeZoneBias;
   ULONG CurrentTimeZoneId;
-} SYSTEM_TIME_OF_DAY_INFORMATION, *PSYSTEM_TIME_OF_DAY_INFORMATION;
+  BYTE Reserved1[20];          /* Per MSDN.  Always 0. */
+} SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION;
 
 typedef enum _PROCESSINFOCLASS
 {
@@ -491,34 +520,36 @@ typedef enum _PROCESSINFOCLASS
   ProcessImageFileName = 27
 } PROCESSINFOCLASS;
 
+/* Checked on 64 bit. */
 typedef struct _DEBUG_BUFFER
 {
   HANDLE SectionHandle;
   PVOID SectionBase;
   PVOID RemoteSectionBase;
-  ULONG SectionBaseDelta;
+  ULONG_PTR SectionBaseDelta;
   HANDLE EventPairHandle;
-  ULONG Unknown[2];
+  ULONG_PTR Unknown[2];
   HANDLE RemoteThreadHandle;
   ULONG InfoClassMask;
-  ULONG SizeOfInfo;
-  ULONG AllocatedSize;
-  ULONG SectionSize;
+  ULONG_PTR SizeOfInfo;
+  ULONG_PTR AllocatedSize;
+  ULONG_PTR SectionSize;
   PVOID ModuleInformation;
   PVOID BackTraceInformation;
   PVOID HeapInformation;
   PVOID LockInformation;
-  PVOID Reserved[9];
+  PVOID Reserved[8];
 } DEBUG_BUFFER, *PDEBUG_BUFFER;
 
+/* Checked on 64 bit. */
 typedef struct _DEBUG_HEAP_INFORMATION
 {
-  ULONG Base;
+  ULONG_PTR Base;
   ULONG Flags;
   USHORT Granularity;
   USHORT Unknown;
-  ULONG Allocated;
-  ULONG Committed;
+  ULONG_PTR Allocated;
+  ULONG_PTR Committed;
   ULONG TagCount;
   ULONG BlockCount;
   ULONG Reserved[7];
@@ -526,24 +557,27 @@ typedef struct _DEBUG_HEAP_INFORMATION
   PVOID Blocks;
 } DEBUG_HEAP_INFORMATION, *PDEBUG_HEAP_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _DEBUG_HEAP_ARRAY
 {
   ULONG Count;
   DEBUG_HEAP_INFORMATION Heaps[1];
 } DEBUG_HEAP_ARRAY, *PDEBUG_HEAP_ARRAY;
 
+/* Checked on 64 bit. */
 typedef struct _DEBUG_HEAP_BLOCK
 {
-  ULONG Size;
+  ULONG_PTR Size;
   ULONG Flags;
-  ULONG Committed;
-  ULONG Address;
+  ULONG_PTR Committed;
+  ULONG_PTR Address;
 } DEBUG_HEAP_BLOCK, *PDEBUG_HEAP_BLOCK;
 
+/* Checked on 64 bit. */
 typedef struct _DEBUG_MODULE_INFORMATION
 {
-  ULONG Reserved[2];
-  ULONG Base;
+  ULONG_PTR Reserved[2];
+  ULONG_PTR Base;
   ULONG Size;
   ULONG Flags;
   USHORT Index;
@@ -553,12 +587,14 @@ typedef struct _DEBUG_MODULE_INFORMATION
   CHAR ImageName[256];
 } DEBUG_MODULE_INFORMATION, *PDEBUG_MODULE_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _DEBUG_MODULE_ARRAY
 {
   ULONG Count;
   DEBUG_MODULE_INFORMATION Modules[1];
 } DEBUG_MODULE_ARRAY, *PDEBUG_MODULE_ARRAY;
 
+/* Checked on 64 bit. */
 typedef struct _KERNEL_USER_TIMES
 {
   LARGE_INTEGER CreateTime;
@@ -567,8 +603,12 @@ typedef struct _KERNEL_USER_TIMES
   LARGE_INTEGER UserTime;
 } KERNEL_USER_TIMES, *PKERNEL_USER_TIMES;
 
+/* Checked on 64 bit. */
 typedef struct _LDR_DATA_TABLE_ENTRY
 {
+  /* Heads up!  The pointers within the LIST_ENTRYs don't point to the
+     start of the next LDR_DATA_TABLE_ENTRY, but rather they point to the
+     start of their respective LIST_ENTRY *within* LDR_DATA_TABLE_ENTRY. */
   LIST_ENTRY InLoadOrderLinks;
   LIST_ENTRY InMemoryOrderLinks;
   LIST_ENTRY InInitializationOrderLinks;
@@ -578,23 +618,28 @@ typedef struct _LDR_DATA_TABLE_ENTRY
   UNICODE_STRING FullDllName;
   UNICODE_STRING BaseDllName;
   ULONG Flags;
-  WORD LoadCount;
+  USHORT LoadCount;
   /* More follows.  Left out since it's just not used.  The aforementioned
-     part of the structure is stable from at least NT4 up to Windows 7,
+     part of the structure is stable from at least NT4 up to Windows 8,
      including WOW64. */
 } LDR_DATA_TABLE_ENTRY, *PLDR_DATA_TABLE_ENTRY;
 
+/* Checked on 64 bit. */
 typedef struct _PEB_LDR_DATA
 {
   ULONG Length;
-  UCHAR Initialized;
+  BOOLEAN Initialized;
   PVOID SsHandle;
+  /* Heads up!  The pointers within the LIST_ENTRYs don't point to the
+     start of the next LDR_DATA_TABLE_ENTRY, but rather they point to the
+     start of their respective LIST_ENTRY *within* LDR_DATA_TABLE_ENTRY. */
   LIST_ENTRY InLoadOrderModuleList;
   LIST_ENTRY InMemoryOrderModuleList;
   LIST_ENTRY InInitializationOrderModuleList;
   PVOID EntryInProgress;
 } PEB_LDR_DATA, *PPEB_LDR_DATA;
 
+/* Checked on 64 bit. */
 typedef struct _RTL_USER_PROCESS_PARAMETERS
 {
   ULONG AllocationSize;
@@ -627,23 +672,35 @@ typedef struct _RTL_USER_PROCESS_PARAMETERS
   UNICODE_STRING RuntimeInfo;
 } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
 
+/* Checked on 64 bit. */
 typedef struct _PEB
 {
   BYTE Reserved1[2];
   BYTE BeingDebugged;
-  BYTE Reserved2[9];
+  BYTE Reserved2[1];
+  PVOID Reserved3[2];
   PPEB_LDR_DATA Ldr;
   PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
-  BYTE Reserved3[4];
+  PVOID Reserved4;
   PVOID ProcessHeap;
   PRTL_CRITICAL_SECTION FastPebLock;
-  BYTE Reserved4[8];
+  PVOID Reserved5[2];
   ULONG EnvironmentUpdateCount;
-  BYTE Reserved5[424];
+  BYTE Reserved6[228];
+  PVOID Reserved7[49];
   ULONG SessionId;
+  /* A lot more follows... */
 } PEB, *PPEB;
 
-/* Simplified definition, just to get stuff we're interested in. */
+/* Checked on 64 bit. */
+typedef struct _GDI_TEB_BATCH
+{
+  ULONG Offset;
+  HANDLE HDC;
+  ULONG Buffer[0x136];
+} GDI_TEB_BATCH, *PGDI_TEB_BATCH;
+
+/* Checked on 64 bit. */
 typedef struct _TEB
 {
   NT_TIB Tib;
@@ -654,33 +711,47 @@ typedef struct _TEB
   PPEB Peb;
   ULONG LastErrorValue;
   ULONG CountOfOwnedCriticalSections;
-  PVOID _reserved1[2];
-  ULONG _reserved2[31];
+  PVOID CsrClientThread;
+  PVOID Win32ThreadInfo;
+  ULONG User32Reserved[26];
+  ULONG UserReserved[5];
   PVOID WOW32Reserved;
-  ULONG CurrentLocale;
+  LCID CurrentLocale;
   ULONG FpSoftwareStatusRegister;
   PVOID SystemReserved1[54];
   LONG ExceptionCode;
   PVOID ActivationContextStackPointer;
-  UCHAR SpareBytes1[36];
+  UCHAR SpareBytes1[0x30 - 3 * sizeof(PVOID)];
   ULONG TxFsContext;
-  ULONG GdiTebBatch[312];
+  GDI_TEB_BATCH GdiTebBatch;
   CLIENT_ID RealClientId;
   PVOID GdiCachedProcessHandle;
   ULONG GdiClientPID;
   ULONG GdiClientTID;
   PVOID GdiThreadLocalInfo;
-  ULONG Win32ClientInfo[62];
+  SIZE_T Win32ClientInfo[62];
   PVOID glDispatchTable[233];
-  ULONG glReserved1[29];
-  PVOID glReserved2[6];
+  SIZE_T glReserved1[29];
+  PVOID glReserved2;
+  PVOID glSectionInfo;
+  PVOID glSection;
+  PVOID glTable;
+  PVOID glCurrentRC;
+  PVOID glContext;
   ULONG LastStatusValue;
   UNICODE_STRING StaticUnicodeString;
   WCHAR StaticUnicodeBuffer[261];
   PVOID DeallocationStack;
+  PVOID TlsSlots[64];
+  BYTE Reserved3[8];
+  PVOID Reserved4[26];
+  PVOID ReservedForOle;
+  PVOID Reserved5[4];
+  PVOID TlsExpansionSlots;
   /* A lot more follows... */
 } TEB, *PTEB;
 
+/* Checked on 64 bit. */
 typedef struct _KSYSTEM_TIME
 {
   ULONG LowPart;
@@ -688,6 +759,7 @@ typedef struct _KSYSTEM_TIME
   LONG High2Time;
 } KSYSTEM_TIME, *PKSYSTEM_TIME;
 
+/* Checked on 64 bit. */
 typedef struct _KUSER_SHARED_DATA
 {
   BYTE Reserved1[0x08];
@@ -697,16 +769,18 @@ typedef struct _KUSER_SHARED_DATA
   /* A lot more follows... */
 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
 
+/* Checked on 64 bit. */
 typedef struct _PROCESS_BASIC_INFORMATION
 {
   NTSTATUS ExitStatus;
   PPEB PebBaseAddress;
   KAFFINITY AffinityMask;
-  KPRIORITY BasePriority;
-  ULONG UniqueProcessId;
-  ULONG InheritedFromUniqueProcessId;
+  KPRIORITY BasePriority;      /* !!!Broken on WOW64!!! */
+  ULONG_PTR UniqueProcessId;
+  ULONG_PTR InheritedFromUniqueProcessId;
 } PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _PROCESS_SESSION_INFORMATION
 {
   ULONG  SessionId;
@@ -720,18 +794,22 @@ typedef enum _MEMORY_INFORMATION_CLASS
   MemoryBasicVlmInformation
 } MEMORY_INFORMATION_CLASS;
 
+/* Checked on 64 bit. */
 typedef struct _MEMORY_WORKING_SET_LIST
 {
   ULONG NumberOfPages;
-  ULONG WorkingSetList[1];
+  ULONG_PTR WorkingSetList[1];
 } MEMORY_WORKING_SET_LIST, *PMEMORY_WORKING_SET_LIST;
 
+/* Checked on 64 bit. */
 typedef struct _MEMORY_SECTION_NAME
 {
   UNICODE_STRING SectionFileName;
 } MEMORY_SECTION_NAME, *PMEMORY_SECTION_NAME;
 
-typedef struct _FILE_BASIC_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_BASIC_INFORMATION
+{
   LARGE_INTEGER CreationTime;
   LARGE_INTEGER LastAccessTime;
   LARGE_INTEGER LastWriteTime;
@@ -739,7 +817,9 @@ typedef struct _FILE_BASIC_INFORMATION {
   ULONG FileAttributes;
 } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
 
-typedef struct _FILE_STANDARD_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_STANDARD_INFORMATION
+{
   LARGE_INTEGER AllocationSize;
   LARGE_INTEGER EndOfFile;
   ULONG NumberOfLinks;
@@ -747,7 +827,9 @@ typedef struct _FILE_STANDARD_INFORMATION {
   BOOLEAN Directory;
 } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
 
-typedef struct _FILE_NETWORK_OPEN_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_NETWORK_OPEN_INFORMATION
+{
   LARGE_INTEGER CreationTime;
   LARGE_INTEGER LastAccessTime;
   LARGE_INTEGER LastWriteTime;
@@ -757,57 +839,80 @@ typedef struct _FILE_NETWORK_OPEN_INFORMATION {
   ULONG FileAttributes;
 } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
 
-typedef struct _FILE_INTERNAL_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_INTERNAL_INFORMATION
+{
   LARGE_INTEGER FileId;
 } FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION;
 
-typedef struct _FILE_EA_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_EA_INFORMATION
+{
   ULONG EaSize;
 } FILE_EA_INFORMATION, *PFILE_EA_INFORMATION;
 
-typedef struct _FILE_ACCESS_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_ACCESS_INFORMATION
+{
   ACCESS_MASK AccessFlags;
 } FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION;
 
-typedef struct _FILE_DISPOSITION_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_DISPOSITION_INFORMATION
+{
   BOOLEAN DeleteFile;
 } FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION;
 
-typedef struct _FILE_POSITION_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_POSITION_INFORMATION
+{
   LARGE_INTEGER CurrentByteOffset;
 } FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION;
 
-typedef struct _FILE_END_OF_FILE_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_END_OF_FILE_INFORMATION
+{
   LARGE_INTEGER EndOfFile;
 } FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION;
 
-typedef struct _FILE_MODE_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_MODE_INFORMATION
+{
   ULONG Mode;
 } FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION;
 
-typedef struct _FILE_ALIGNMENT_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_ALIGNMENT_INFORMATION
+{
   ULONG AlignmentRequirement;
 } FILE_ALIGNMENT_INFORMATION;
 
-typedef struct _FILE_NAME_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_NAME_INFORMATION
+{
   ULONG FileNameLength;
   WCHAR FileName[1];
 } FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
 
-typedef struct _FILE_LINK_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_LINK_INFORMATION
+{
   BOOLEAN ReplaceIfExists;
   HANDLE RootDirectory;
   ULONG FileNameLength;
   WCHAR FileName[1];
 } FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION;
 
-typedef struct _FILE_RENAME_INFORMATION {
+/* Checked on 64 bit. */
+typedef struct _FILE_RENAME_INFORMATION
+{
   BOOLEAN ReplaceIfExists;
   HANDLE RootDirectory;
   ULONG FileNameLength;
   WCHAR FileName[1];
 } FILE_RENAME_INFORMATION, *PFILE_RENAME_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_ALL_INFORMATION {
   FILE_BASIC_INFORMATION     BasicInformation;
   FILE_STANDARD_INFORMATION  StandardInformation;
@@ -828,6 +933,7 @@ enum
   FILE_PIPE_CLOSING_STATE = 4
 };
 
+/* Checked on 64 bit. */
 typedef struct _FILE_PIPE_LOCAL_INFORMATION
 {
   ULONG NamedPipeType;
@@ -842,6 +948,7 @@ typedef struct _FILE_PIPE_LOCAL_INFORMATION
   ULONG NamedPipeEnd;
 } FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_COMPRESSION_INFORMATION
 {
   LARGE_INTEGER CompressedFileSize;
@@ -852,12 +959,14 @@ typedef struct _FILE_COMPRESSION_INFORMATION
   UCHAR Reserved[3];
 } FILE_COMPRESSION_INFORMATION, *PFILE_COMPRESSION_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_FS_DEVICE_INFORMATION
 {
   ULONG DeviceType;
   ULONG Characteristics;
 } FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_FS_ATTRIBUTE_INFORMATION
 {
   ULONG FileSystemAttributes;
@@ -866,6 +975,7 @@ typedef struct _FILE_FS_ATTRIBUTE_INFORMATION
   WCHAR FileSystemName[1];
 } FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION;
 
+/* Checked on 64 bit. */
 #pragma pack(push,4)
 typedef struct _FILE_FS_VOLUME_INFORMATION
 {
@@ -878,6 +988,7 @@ typedef struct _FILE_FS_VOLUME_INFORMATION
 } FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION;
 #pragma pack(pop)
 
+/* Checked on 64 bit. */
 typedef struct _FILE_FS_SIZE_INFORMATION
 {
   LARGE_INTEGER TotalAllocationUnits;
@@ -886,6 +997,7 @@ typedef struct _FILE_FS_SIZE_INFORMATION
   ULONG BytesPerSector;
 } FILE_FS_SIZE_INFORMATION, *PFILE_FS_SIZE_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_FS_FULL_SIZE_INFORMATION
 {
   LARGE_INTEGER TotalAllocationUnits;
@@ -895,9 +1007,11 @@ typedef struct _FILE_FS_FULL_SIZE_INFORMATION
   ULONG BytesPerSector;
 } FILE_FS_FULL_SIZE_INFORMATION, *PFILE_FS_FULL_SIZE_INFORMATION;
 
-typedef struct _FILE_FS_OBJECTID_INFORMATION {
-    UCHAR ObjectId[16];
-    UCHAR ExtendedInfo[48];
+/* Checked on 64 bit. */
+typedef struct _FILE_FS_OBJECTID_INFORMATION
+{
+  UCHAR ObjectId[16];
+  UCHAR ExtendedInfo[48];
 } FILE_FS_OBJECTID_INFORMATION, *PFILE_FS_OBJECTID_INFORMATION;
 
 typedef enum _FSINFOCLASS {
@@ -921,6 +1035,7 @@ typedef enum _OBJECT_INFORMATION_CLASS
    // and many more
 } OBJECT_INFORMATION_CLASS;
 
+/* Checked on 64 bit. */
 typedef struct _OBJECT_BASIC_INFORMATION
 {
   ULONG Attributes;
@@ -936,24 +1051,28 @@ typedef struct _OBJECT_BASIC_INFORMATION
   LARGE_INTEGER CreateTime;
 } OBJECT_BASIC_INFORMATION, *POBJECT_BASIC_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _OBJECT_NAME_INFORMATION
 {
   UNICODE_STRING Name;
 } OBJECT_NAME_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _DIRECTORY_BASIC_INFORMATION
 {
   UNICODE_STRING ObjectName;
   UNICODE_STRING ObjectTypeName;
 } DIRECTORY_BASIC_INFORMATION, *PDIRECTORY_BASIC_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_GET_EA_INFORMATION
 {
-  ULONG   NextEntryOffset;
-  UCHAR   EaNameLength;
-  CHAR    EaName[1];
+  ULONG NextEntryOffset;
+  UCHAR EaNameLength;
+  CHAR EaName[1];
 } FILE_GET_EA_INFORMATION, *PFILE_GET_EA_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_FULL_EA_INFORMATION
 {
   ULONG NextEntryOffset;
@@ -963,6 +1082,7 @@ typedef struct _FILE_FULL_EA_INFORMATION
   CHAR EaName[1];
 } FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION;
 
+/* Checked on 64 bit. */
 typedef struct _FILE_MAILSLOT_SET_INFORMATION
 {
   LARGE_INTEGER ReadTimeout;
@@ -970,6 +1090,7 @@ typedef struct _FILE_MAILSLOT_SET_INFORMATION
 
 typedef VOID NTAPI (*PIO_APC_ROUTINE)(PVOID, PIO_STATUS_BLOCK, ULONG);
 
+/* Checked on 64 bit. */
 typedef struct _EVENT_BASIC_INFORMATION
 {
   EVENT_TYPE EventType;
@@ -988,13 +1109,15 @@ typedef enum _THREAD_INFORMATION_CLASS
   ThreadImpersonationToken = 5
 } THREAD_INFORMATION_CLASS, *PTHREAD_INFORMATION_CLASS;
 
-typedef struct _THREAD_BASIC_INFORMATION {
-    NTSTATUS  ExitStatus;
-    PNT_TIB  TebBaseAddress;
-    CLIENT_ID  ClientId;
-    KAFFINITY  AffinityMask;
-    KPRIORITY  Priority;
-    KPRIORITY  BasePriority;
+/* Checked on 64 bit. */
+typedef struct _THREAD_BASIC_INFORMATION
+{
+  NTSTATUS ExitStatus;
+  PNT_TIB TebBaseAddress;
+  CLIENT_ID ClientId;
+  KAFFINITY AffinityMask;
+  KPRIORITY Priority;
+  KPRIORITY BasePriority;
 } THREAD_BASIC_INFORMATION, *PTHREAD_BASIC_INFORMATION;
 
 typedef enum _TIMER_INFORMATION_CLASS {
@@ -1047,9 +1170,9 @@ typedef VOID (APIENTRY *PTIMER_APC_ROUTINE)(PVOID, ULONG, ULONG);
    standard Win32 header.  */
 
 #ifdef __cplusplus
-/* This is the mapping of the KUSER_SHARED_DATA structure into the 32 bit
-   user address space.  We need it here to access the current DismountCount
-   and InterruptTime.  */
+/* This is the mapping of the KUSER_SHARED_DATA structure into the user
+   address space on BOTH architectures, 32 and 64 bit!
+   We need it here to access the current DismountCount and InterruptTime.  */
 static volatile KUSER_SHARED_DATA &SharedUserData
        = *(volatile KUSER_SHARED_DATA *) 0x7ffe0000;
 
@@ -1101,9 +1224,9 @@ extern "C"
                                  PVOID, ULONG);
   NTSTATUS NTAPI NtFlushBuffersFile (HANDLE, PIO_STATUS_BLOCK);
   NTSTATUS NTAPI NtLoadKey (POBJECT_ATTRIBUTES, POBJECT_ATTRIBUTES);
-  NTSTATUS NTAPI NtLockVirtualMemory (HANDLE, PVOID *, ULONG *, ULONG);
-  NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG, ULONG,
-                                    PLARGE_INTEGER, PULONG, SECTION_INHERIT,
+  NTSTATUS NTAPI NtLockVirtualMemory (HANDLE, PVOID *, PSIZE_T, ULONG);
+  NTSTATUS NTAPI NtMapViewOfSection (HANDLE, HANDLE, PVOID *, ULONG_PTR, SIZE_T,
+                                    PLARGE_INTEGER, PSIZE_T, SECTION_INHERIT,
                                     ULONG, ULONG);
   NTSTATUS NTAPI NtNotifyChangeDirectoryFile (HANDLE, HANDLE, PIO_APC_ROUTINE,
                                              PVOID, PIO_STATUS_BLOCK,
@@ -1162,7 +1285,7 @@ extern "C"
                                  KEY_VALUE_INFORMATION_CLASS, PVOID, ULONG,
                                  PULONG);
   NTSTATUS NTAPI NtQueryVirtualMemory (HANDLE, PVOID, MEMORY_INFORMATION_CLASS,
-                                      PVOID, ULONG, PULONG);
+                                      PVOID, SIZE_T, PSIZE_T);
   NTSTATUS NTAPI NtQueryVolumeInformationFile (HANDLE, IO_STATUS_BLOCK *,
                                               VOID *, ULONG,
                                               FS_INFORMATION_CLASS);
@@ -1185,7 +1308,7 @@ extern "C"
   NTSTATUS NTAPI NtSetTimerResolution (ULONG, BOOLEAN, PULONG);
   NTSTATUS NTAPI NtSetValueKey (HANDLE, PUNICODE_STRING, ULONG, ULONG, PVOID,
                                ULONG);
-  NTSTATUS NTAPI NtUnlockVirtualMemory (HANDLE, PVOID *, ULONG *, ULONG);
+  NTSTATUS NTAPI NtUnlockVirtualMemory (HANDLE, PVOID *, PSIZE_T, ULONG);
   NTSTATUS NTAPI NtUnmapViewOfSection (HANDLE, PVOID);
   NTSTATUS NTAPI NtWriteFile (HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID,
                              PIO_STATUS_BLOCK, PVOID, ULONG, PLARGE_INTEGER,
@@ -1232,7 +1355,7 @@ extern "C"
   BOOLEAN NTAPI RtlEqualUnicodeString (PUNICODE_STRING, PUNICODE_STRING,
                                       BOOLEAN);
   VOID NTAPI RtlFreeAnsiString (PANSI_STRING);
-  BOOLEAN NTAPI RtlFreeHeap (PVOID, ULONG, PVOID);
+  BOOLEAN NTAPI RtlFreeHeap (HANDLE, ULONG, PVOID);
   VOID NTAPI RtlFreeOemString (POEM_STRING);
   VOID NTAPI RtlFreeUnicodeString (PUNICODE_STRING);
   BOOLEAN NTAPI RtlFirstFreeAce (PACL, PVOID *);
index 42ad38c24b75b689f36f55144893000956665ac0..9cb9c2ed2b0e47fe70746eb54a071e280c13ad71 100644 (file)
@@ -69,12 +69,12 @@ pwdgrp::read_passwd ()
       && (!(pw = internal_getpwnam (cygheap->user.name ()))
          || !user_shared->cb
          || (myself->uid != ILLEGAL_UID
-             && myself->uid != (__uid32_t) pw->pw_uid
+             && myself->uid != pw->pw_uid
              && !internal_getpwuid (myself->uid))))
     {
       static char linebuf[1024];       // must be static and
                                        // should not be NO_COPY
-      snprintf (linebuf, sizeof (linebuf), "%s:*:%lu:%lu:,%s:%s:/bin/sh",
+      snprintf (linebuf, sizeof (linebuf), "%s:*:%u:%u:,%s:%s:/bin/sh",
                cygheap->user.name (),
                (!user_shared->cb || myself->uid == ILLEGAL_UID)
                ? UNKNOWN_UID : myself->uid,
@@ -111,12 +111,12 @@ internal_getpwsid (cygpsid &sid)
 }
 
 struct passwd *
-internal_getpwuid (__uid32_t uid, bool check)
+internal_getpwuid (uid_t uid, bool check)
 {
   pr.refresh (check);
 
   for (int i = 0; i < pr.curr_lines; i++)
-    if (uid == (__uid32_t) passwd_buf[i].pw_uid)
+    if (uid == passwd_buf[i].pw_uid)
       return passwd_buf + i;
   return NULL;
 }
@@ -135,21 +135,25 @@ internal_getpwnam (const char *name, bool check)
 
 
 extern "C" struct passwd *
-getpwuid32 (__uid32_t uid)
+getpwuid32 (uid_t uid)
 {
   struct passwd *temppw = internal_getpwuid (uid, true);
   pthread_testcancel ();
   return temppw;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getpwuid32, getpwuid)
+#else
 extern "C" struct passwd *
 getpwuid (__uid16_t uid)
 {
   return getpwuid32 (uid16touid32 (uid));
 }
+#endif
 
 extern "C" int
-getpwuid_r32 (__uid32_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
+getpwuid_r32 (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
 {
   *result = NULL;
 
@@ -181,11 +185,15 @@ getpwuid_r32 (__uid32_t uid, struct passwd *pwd, char *buffer, size_t bufsize, s
   return 0;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getpwuid_r32, getpwuid_r)
+#else
 extern "C" int
 getpwuid_r (__uid16_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
 {
   return getpwuid_r32 (uid16touid32 (uid), pwd, buffer, bufsize, result);
 }
+#endif
 
 extern "C" struct passwd *
 getpwnam (const char *name)
@@ -245,11 +253,13 @@ getpwent (void)
   return NULL;
 }
 
+#ifndef __x86_64__
 extern "C" struct passwd *
 getpwduid (__uid16_t)
 {
   return NULL;
 }
+#endif
 
 extern "C" void
 setpwent (void)
index cfda6bb27df3f6568e46173e12c154de6b304131..80336a252354f44a0b3368f9c6249788f8c0ec99 100644 (file)
@@ -527,7 +527,7 @@ getfileattr (const char *path, bool caseinsensitive) /* path has to be always ab
         directory query. */
       UNICODE_STRING dirname, basename;
       HANDLE dir;
-      FILE_BOTH_DIRECTORY_INFORMATION fdi;
+      FILE_BOTH_DIR_INFORMATION fdi;
 
       RtlSplitUnicodePath (&upath, &dirname, &basename);
       InitializeObjectAttributes (&attr, &dirname,
@@ -1213,11 +1213,10 @@ file_get_fnoi (HANDLE h, bool skip_network_open_inf,
   status = skip_network_open_inf ? STATUS_INVALID_PARAMETER
           : NtQueryInformationFile (h, &io, pfnoi, sizeof *pfnoi,
                                     FileNetworkOpenInformation);
-  if (status == STATUS_INVALID_PARAMETER || status == STATUS_NOT_IMPLEMENTED)
+  if (status == STATUS_INVALID_PARAMETER)
     {
       /* Apart from accessing Netapps, this also occurs when accessing SMB
-        share root dirs hosted on NT4 (STATUS_INVALID_PARAMETER), or when
-        accessing SMB share root dirs from NT4 (STATUS_NOT_IMPLEMENTED). */
+        share root dirs hosted on NT4. */
       FILE_BASIC_INFORMATION fbi;
       FILE_STANDARD_INFORMATION fsi;
 
@@ -1650,12 +1649,11 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
        full_len += sizeof (unsigned short) + pidl_len;
       oldpath_len = strlen (oldpath);
       /* Unfortunately the length of the description is restricted to a
-        length of MAX_PATH up to NT4, and to a length of 2000 bytes
-        since W2K.  We don't want to add considerations for the different
-        lengths and even 2000 bytes is not enough for long path names.
-        So what we do here is to set the description to the POSIX path
-        only if the path is not longer than MAX_PATH characters.  We
-        append the full path name after the regular shortcut data
+        length of 2000 bytes.  We don't want to add considerations for
+        the different lengths and even 2000 bytes is not enough for long
+        path names.  So what we do here is to set the description to the
+        POSIX path only if the path is not longer than MAX_PATH characters.
+        We append the full path name after the regular shortcut data
         (see below), which works fine with Windows Explorer as well
         as older Cygwin versions (as long as the whole file isn't bigger
         than 8K).  The description field is only used for backward
@@ -1783,7 +1781,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
       status = NtSetAttributesFile (fh, mk_winsym ? FILE_ATTRIBUTE_READONLY
                                                  : FILE_ATTRIBUTE_SYSTEM);
       if (!NT_SUCCESS (status))
-       debug_printf ("Setting attributes failed, status = %p", status);
+       debug_printf ("Setting attributes failed, status = %y", status);
       res = 0;
     }
   else
@@ -1793,7 +1791,7 @@ symlink_worker (const char *oldpath, const char *newpath, bool use_winsym,
       status = NtSetInformationFile (fh, &io, &fdi, sizeof fdi,
                                     FileDispositionInformation);
       if (!NT_SUCCESS (status))
-       debug_printf ("Setting delete dispostion failed, status = %p", status);
+       debug_printf ("Setting delete dispostion failed, status = %y", status);
     }
   NtClose (fh);
 
@@ -1838,7 +1836,7 @@ symlink_info::check_shortcut (HANDLE h)
       set_error (EIO);
       return 0;
     }
-  if (fsi.EndOfFile.QuadPart <= sizeof (win_shortcut_hdr)
+  if (fsi.EndOfFile.QuadPart <= (LONGLONG) sizeof (win_shortcut_hdr)
       || fsi.EndOfFile.QuadPart > 4 * 65536)
     return 0;
   if (fsi.EndOfFile.LowPart < NT_MAX_PATH * sizeof (WCHAR))
@@ -1913,7 +1911,7 @@ symlink_info::check_sysfile (HANDLE h)
                       sizeof (cookie_buf), &off, NULL);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("ReadFile1 failed %p", status);
+      debug_printf ("ReadFile1 failed %y", status);
       if (status != STATUS_END_OF_FILE)
        set_error (EIO);
       return 0;
@@ -2000,7 +1998,7 @@ symlink_info::check_reparse_point (HANDLE h, bool remote)
     }
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtFsControlFile(FSCTL_GET_REPARSE_POINT) failed, %p",
+      debug_printf ("NtFsControlFile(FSCTL_GET_REPARSE_POINT) failed, %y",
                    status);
       set_error (EIO);
       return 0;
@@ -2412,7 +2410,7 @@ restart:
                             FILE_OPEN_REPARSE_POINT
                             | FILE_OPEN_FOR_BACKUP_INTENT,
                             eabuf, easize);
-      debug_printf ("%p = NtCreateFile (%S)", status, &upath);
+      debug_printf ("%y = NtCreateFile (%S)", status, &upath);
       /* No right to access EAs or EAs not supported? */
       if (!NT_SUCCESS (status)
          && (status == STATUS_ACCESS_DENIED
@@ -2435,7 +2433,7 @@ restart:
                               &attr, &io, FILE_SHARE_VALID_FLAGS,
                               FILE_OPEN_REPARSE_POINT
                               | FILE_OPEN_FOR_BACKUP_INTENT);
-         debug_printf ("%p = NtOpenFile (no-EAs %S)", status, &upath);
+         debug_printf ("%y = NtOpenFile (no-EAs %S)", status, &upath);
        }
       if (status == STATUS_OBJECT_NAME_NOT_FOUND)
        {
@@ -2451,7 +2449,7 @@ restart:
                                   &attr, &io, FILE_SHARE_VALID_FLAGS,
                                   FILE_OPEN_REPARSE_POINT
                                   | FILE_OPEN_FOR_BACKUP_INTENT);
-             debug_printf ("%p = NtOpenFile (broken-UDF, %S)", status, &upath);
+             debug_printf ("%y = NtOpenFile (broken-UDF, %S)", status, &upath);
              attr.Attributes = 0;
              if (NT_SUCCESS (status))
                {
@@ -2504,6 +2502,22 @@ restart:
                }
            }
        }
+      else if (status == STATUS_NETWORK_OPEN_RESTRICTION
+              || status == STATUS_SYMLINK_CLASS_DISABLED)
+       {
+         /* These status codes are returned if you try to open a native
+            symlink and the usage of this kind of symlink is forbidden
+            (see fsutil).  Since we can't open them at all, not even for
+            stat purposes, we have to return a POSIX error code which is
+            at least a bit helpful.
+
+            Additionally Windows 8 introduces a bug in NFS: If you have
+            a symlink to a directory, with symlinks underneath, resolving
+            the second level of symlinks fails if remote->remote symlinks
+            are disabled in fsutil.  Unfortunately that's the default. */
+         set_error (ELOOP);
+         break;
+       }
 
       if (NT_SUCCESS (status)
          /* Check file system while we're having the file open anyway.
@@ -2526,7 +2540,7 @@ restart:
        }
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("%p = NtQueryInformationFile (%S)", status, &upath);
+         debug_printf ("%y = NtQueryInformationFile (%S)", status, &upath);
          fileattr = INVALID_FILE_ATTRIBUTES;
 
          /* One of the inner path components is invalid, or the path contains
@@ -2559,7 +2573,7 @@ restart:
              OBJECT_ATTRIBUTES dattr;
              HANDLE dir;
              struct {
-               FILE_BOTH_DIRECTORY_INFORMATION fdi;
+               FILE_BOTH_DIR_INFORMATION fdi;
                WCHAR dummy_buf[NAME_MAX + 1];
              } fdi_buf;
 
@@ -2573,7 +2587,7 @@ restart:
                                   | FILE_DIRECTORY_FILE);
              if (!NT_SUCCESS (status))
                {
-                 debug_printf ("%p = NtOpenFile(%S)", status, &dirname);
+                 debug_printf ("%y = NtOpenFile(%S)", status, &dirname);
                  /* There's a special case if the file is itself the root
                     of a drive which is not accessible by the current user.
                     This case is only recognized by the length of the
@@ -2593,7 +2607,7 @@ restart:
                  NtClose (dir);
                  if (!NT_SUCCESS (status))
                    {
-                     debug_printf ("%p = NtQueryDirectoryFile(%S)",
+                     debug_printf ("%y = NtQueryDirectoryFile(%S)",
                                    status, &dirname);
                      if (status == STATUS_NO_SUCH_FILE)
                        {
@@ -2771,7 +2785,7 @@ restart:
        NtClose (h);
     }
 
-  syscall_printf ("%d = symlink.check(%s, %p) (%p)",
+  syscall_printf ("%d = symlink.check(%s, %p) (%y)",
                  res, suffix.path, contents, pflags);
   return res;
 }
@@ -2809,7 +2823,7 @@ readlink (const char *path, char *buf, size_t buflen)
   if (pathbuf.error)
     {
       set_errno (pathbuf.error);
-      syscall_printf ("-1 = readlink (%s, %p, %d)", path, buf, buflen);
+      syscall_printf ("-1 = readlink (%s, %p, %lu)", path, buf, buflen);
       return -1;
     }
 
@@ -2841,8 +2855,8 @@ readlink (const char *path, char *buf, size_t buflen)
    done during the opendir call and the hash or the filename within
    the directory.  FIXME: Not bullet-proof. */
 /* Cygwin internal */
-__ino64_t __stdcall
-hash_path_name (__ino64_t hash, PUNICODE_STRING name)
+ino_t __stdcall
+hash_path_name (ino_t hash, PUNICODE_STRING name)
 {
   if (name->Length == 0)
     return hash;
@@ -2855,20 +2869,20 @@ hash_path_name (__ino64_t hash, PUNICODE_STRING name)
   return hash;
 }
 
-__ino64_t __stdcall
-hash_path_name (__ino64_t hash, PCWSTR name)
+ino_t __stdcall
+hash_path_name (ino_t hash, PCWSTR name)
 {
   UNICODE_STRING uname;
   RtlInitUnicodeString (&uname, name);
   return hash_path_name (hash, &uname);
 }
 
-__ino64_t __stdcall
-hash_path_name (__ino64_t hash, const char *name)
+ino_t __stdcall
+hash_path_name (ino_t hash, const char *name)
 {
   UNICODE_STRING uname;
   RtlCreateUnicodeStringFromAsciiz (&uname, name);
-  __ino64_t ret = hash_path_name (hash, &uname);
+  ino_t ret = hash_path_name (hash, &uname);
   RtlFreeUnicodeString (&uname);
   return ret;
 }
@@ -2899,7 +2913,7 @@ get_current_dir_name (void)
 {
   const char *pwd = getenv ("PWD");
   char *cwd = getcwd (NULL, 0);
-  struct __stat64 pwdbuf, cwdbuf;
+  struct stat pwdbuf, cwdbuf;
 
   if (pwd && strcmp (pwd, cwd) != 0
       && stat64 (pwd, &pwdbuf) == 0
@@ -2941,7 +2955,7 @@ chdir (const char *in_dir)
 
   int res = -1;
   const char *posix_cwd = NULL;
-  int devn = path.get_devn ();
+  dev_t devn = path.get_device ();
   if (!path.exists ())
     set_errno (ENOENT);
   else if (!path.isdir ())
@@ -3177,6 +3191,7 @@ cygwin_create_path (cygwin_conv_path_t what, const void *from)
   return to;
 }
 
+#ifndef __x86_64__     /* Disable deprecated functions on x86_64. */
 
 extern "C" int
 cygwin_conv_to_win32_path (const char *path, char *win32_path)
@@ -3208,6 +3223,8 @@ cygwin_conv_to_full_posix_path (const char *path, char *posix_path)
                           MAX_PATH);
 }
 
+#endif /* !__x86_64__ */
+
 /* The realpath function is required by POSIX:2008.  */
 
 extern "C" char *
@@ -3344,6 +3361,14 @@ conv_path_list_buf_size (const char *path_list, bool to_posix)
   return size;
 }
 
+extern "C" ssize_t
+env_PATH_to_posix (const void *win32, void *posix, size_t size)
+{
+  return_with_errno (conv_path_list ((const char *) win32, (char *) posix,
+                                    size, ENV_CVT));
+}
+
+#ifndef __x86_64__     /* Disable deprecated functions on x86_64. */
 
 extern "C" int
 cygwin_win32_to_posix_path_list_buf_size (const char *path_list)
@@ -3357,13 +3382,6 @@ cygwin_posix_to_win32_path_list_buf_size (const char *path_list)
   return conv_path_list_buf_size (path_list, false);
 }
 
-extern "C" ssize_t
-env_PATH_to_posix (const void *win32, void *posix, size_t size)
-{
-  return_with_errno (conv_path_list ((const char *) win32, (char *) posix,
-                                    size, ENV_CVT));
-}
-
 extern "C" int
 cygwin_win32_to_posix_path_list (const char *win32, char *posix)
 {
@@ -3378,6 +3396,8 @@ cygwin_posix_to_win32_path_list (const char *posix, char *win32)
                     CCP_POSIX_TO_WIN_A | CCP_RELATIVE));
 }
 
+#endif /* !__x86_64__ */
+
 extern "C" ssize_t
 cygwin_conv_path_list (cygwin_conv_path_t what, const void *from, void *to,
                       size_t size)
@@ -3385,7 +3405,6 @@ cygwin_conv_path_list (cygwin_conv_path_t what, const void *from, void *to,
   int ret;
   char *winp = NULL;
   void *orig_to = NULL;
-  size_t orig_size = (size_t) -1;
   tmp_pathbuf tp;
 
   switch (what & CCP_CONVTYPE_MASK)
@@ -3403,7 +3422,6 @@ cygwin_conv_path_list (cygwin_conv_path_t what, const void *from, void *to,
               * sizeof (WCHAR);
       what = (what & ~CCP_CONVTYPE_MASK) | CCP_POSIX_TO_WIN_A;
       orig_to = to;
-      orig_size = size;
       to = (void *) tp.w_get ();
       size = 65536;
       break;
@@ -3685,8 +3703,6 @@ fcwd_access_t::SetVersionFromPointer (PBYTE buf_p, bool is_buffer)
     fast_cwd_version () = FCWD_OLD;
 }
 
-#define peek32(x)      (*(uint32_t *)(x))
-
 /* This function scans the code in ntdll.dll to find the address of the
    global variable used to access the CWD starting with Vista.  While the
    pointer is global, it's not exported from the DLL, unfortunately.
@@ -3696,6 +3712,99 @@ fcwd_access_t::SetVersionFromPointer (PBYTE buf_p, bool is_buffer)
    Windows 7 32/64 bit, Server 2008 R2 (which is only 64 bit anyway),
    and W8CP 32/64 bit.  There's some hope this will still work for
    Windows 8 RTM... */
+
+#ifdef __x86_64__
+
+#define peek32(x)      (*(int32_t *)(x))
+
+static fcwd_access_t **
+find_fast_cwd_pointer ()
+{
+  /* Fetch entry points of relevant functions in ntdll.dll. */
+  HMODULE ntdll = GetModuleHandle ("ntdll.dll");
+  if (!ntdll)
+    return NULL;
+  const uint8_t *get_dir = (const uint8_t *)
+                          GetProcAddress (ntdll, "RtlGetCurrentDirectory_U");
+  const uint8_t *ent_crit = (const uint8_t *)
+                           GetProcAddress (ntdll, "RtlEnterCriticalSection");
+  if (!get_dir || !ent_crit)
+    return NULL;
+  /* Search first relative call instruction in RtlGetCurrentDirectory_U. */
+  const uint8_t *rcall = (const uint8_t *) memchr (get_dir, 0xe8, 40);
+  if (!rcall)
+    return NULL;
+  /* Fetch offset from instruction and compute address of called function.
+     This function actually fetches the current FAST_CWD instance and
+     performs some other actions, not important to us. */
+  const uint8_t *use_cwd = rcall + 5 + peek32 (rcall + 1);
+  /* Next we search for the locking mechanism and perform a sanity check.
+     On Pre-Windows 8 we basically look for the RtlEnterCriticalSection call.
+     Windows 8 does not call RtlEnterCriticalSection.  The code manipulates
+     the FastPebLock manually, probably because RtlEnterCriticalSection has
+     been converted to an inline function.  Either way, we test if the code
+     uses the FastPebLock. */
+  const uint8_t *movrbx;
+  const uint8_t *lock = (const uint8_t *)
+                        memmem ((const char *) use_cwd, 80,
+                                "\xf0\x0f\xba\x35", 4);
+  if (lock)
+    {
+      /* The lock instruction tweaks the LockCount member, which is not at
+        the start of the PRTL_CRITICAL_SECTION structure.  So we have to
+        subtract the offset of LockCount to get the real address. */
+      PRTL_CRITICAL_SECTION lockaddr =
+        (PRTL_CRITICAL_SECTION) (lock + 9 + peek32 (lock + 4)
+                                 - offsetof (RTL_CRITICAL_SECTION, LockCount));
+      /* Test if lock address is FastPebLock. */
+      if (lockaddr != NtCurrentTeb ()->Peb->FastPebLock)
+        return NULL;
+      /* Search `mov rbx, rel(rip)'.  This is the instruction fetching the
+         address of the current fcwd_access_t pointer, and it should be pretty
+        near to the locking stuff. */
+      movrbx = (const uint8_t *) memmem ((const char *) lock, 40,
+                                         "\x48\x8b\x1d", 3);
+    }
+  else
+    {
+      /* Search lea rcx, rel(rip).  This loads the address of the lock into
+         $rcx for the subsequent RtlEnterCriticalSection call. */
+      lock = (const uint8_t *) memmem ((const char *) use_cwd, 80,
+                                       "\x48\x8d\x0d", 3);
+      if (!lock)
+        return NULL;
+      PRTL_CRITICAL_SECTION lockaddr =
+        (PRTL_CRITICAL_SECTION) (lock + 7 + peek32 (lock + 3));
+      /* Test if lock address is FastPebLock. */
+      if (lockaddr != NtCurrentTeb ()->Peb->FastPebLock)
+        return NULL;
+      /* Next is the call RtlEnterCriticalSection. */
+      lock += 7;
+      if (lock[0] != 0xe8)
+        return NULL;
+      const uint8_t *call_addr = (const uint8_t *)
+                                 (lock + 5 + peek32 (lock + 1));
+      if (call_addr != ent_crit)
+        return NULL;
+      /* In contrast to the above Windows 8 code, we don't have to search
+        for the `mov rbx, rel(rip)' instruction.  It follows right after
+        the call to RtlEnterCriticalSection. */
+      movrbx = lock + 5;
+    }
+  if (!movrbx)
+    return NULL;
+  /* Check that the next instruction tests if the fetched value is NULL. */
+  const uint8_t *testrbx = (const uint8_t *)
+                          memmem (movrbx + 7, 3, "\x48\x85\xdb", 3);
+  if (!testrbx)
+    return NULL;
+  /* Compute address of the fcwd_access_t ** pointer. */
+  return (fcwd_access_t **) (testrbx + peek32 (movrbx + 3));
+}
+#else
+
+#define peek32(x)      (*(uint32_t *)(x))
+
 static fcwd_access_t **
 find_fast_cwd_pointer ()
 {
@@ -3726,9 +3835,8 @@ find_fast_cwd_pointer ()
   const uint8_t *mov_pfast_cwd;
   if (movedi[0] == 0x8b && movedi[1] == 0xff)  /* mov edi,edi -> W8 */
     {
-      /* Windows 8 CP 32 bit (after a Windows Update?) does not call
-        RtlEnterCriticalSection.  For some reason the function manipulates
-        the FastPebLock manually, kind of like RtlEnterCriticalSection has
+      /* Windows 8 does not call RtlEnterCriticalSection.  The code manipulates
+        the FastPebLock manually, probably because RtlEnterCriticalSection has
         been converted to an inline function.
 
         Next we search for a `mov eax, some address'.  This address points
@@ -3782,6 +3890,7 @@ find_fast_cwd_pointer ()
     return NULL;
   return (fcwd_access_t **) peek32 (mov_pfast_cwd + 2);
 }
+#endif
 
 static fcwd_access_t **
 find_fast_cwd ()
@@ -3906,7 +4015,7 @@ cwdstuff::override_win32_cwd (bool init, ULONG old_dismount_count)
                RtlSetCurrentDirectory_U (error ? &ro_u_pipedir : &win32);
              if (!NT_SUCCESS (status))
                {
-                 debug_printf ("RtlSetCurrentDirectory_U(%S) failed, %p",
+                 debug_printf ("RtlSetCurrentDirectory_U(%S) failed, %y",
                                error ? &ro_u_pipedir : &win32, status);
                  return;
                }
@@ -4276,7 +4385,7 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen)
   cwd_lock.release ();
 
 out:
-  syscall_printf ("(%s) = cwdstuff::get (%p, %d, %d, %d), errno %d",
+  syscall_printf ("(%s) = cwdstuff::get (%p, %u, %d, %d), errno %d",
                  buf, buf, ulen, need_posix, with_chroot, errno);
   MALLOC_CHECK;
   return buf;
@@ -4317,7 +4426,7 @@ etc::test_file_change (int n)
     {
       res = true;
       memset (last_modified + n, 0, sizeof (last_modified[n]));
-      debug_printf ("NtQueryFullAttributesFile (%S) failed, %p",
+      debug_printf ("NtQueryFullAttributesFile (%S) failed, %y",
                    fn[n].ObjectName, status);
     }
   else
@@ -4355,7 +4464,7 @@ etc::dir_changed (int n)
          if (!NT_SUCCESS (status))
            {
 #ifdef DEBUGGING
-             system_printf ("NtOpenFile (%S) failed, %p",
+             system_printf ("NtOpenFile (%S) failed, %y",
                             dir.get_nt_native_path (), status);
 #endif
              changed_h = INVALID_HANDLE_VALUE;
@@ -4370,7 +4479,7 @@ etc::dir_changed (int n)
              if (!NT_SUCCESS (status))
                {
 #ifdef DEBUGGING
-                 system_printf ("NtNotifyChangeDirectoryFile (1) failed, %p",
+                 system_printf ("NtNotifyChangeDirectoryFile (1) failed, %y",
                                 status);
 #endif
                  NtClose (changed_h);
@@ -4392,7 +4501,7 @@ etc::dir_changed (int n)
          if (!NT_SUCCESS (status))
            {
 #ifdef DEBUGGING
-             system_printf ("NtNotifyChangeDirectoryFile (2) failed, %p",
+             system_printf ("NtNotifyChangeDirectoryFile (2) failed, %y",
                             status);
 #endif
              NtClose (changed_h);
index b9d7defbc306dec740bde6ab1ead0b3f8627897b..290ad83325b9f93d6fee7a08a82df73beb4ce5f3 100644 (file)
@@ -80,11 +80,15 @@ enum path_types
   PATH_NO_ACCESS_CHECK = PC_NO_ACCESS_CHECK,
   PATH_CTTY            = 0x00400000,   /* could later be used as ctty */
   PATH_OPEN            = 0x00800000,   /* use open semantics */
+                                       /* FIXME?  PATH_OPEN collides with
+                                          PATH_NO_ACCESS_CHECK, but it looks
+                                          like they are never used together. */
   PATH_LNK             = 0x01000000,
   PATH_TEXT            = 0x02000000,
   PATH_REP             = 0x04000000,
   PATH_HAS_SYMLINKS    = 0x10000000,
-  PATH_SOCKET          = 0x40000000
+  PATH_SOCKET          = 0x40000000,
+  PATH_64BITEXEC       = 0x80000000
 };
 
 class symlink_info;
@@ -153,7 +157,7 @@ class path_conv
   ULONG objcaseinsensitive () const {return caseinsensitive;}
   bool has_acls () const {return !(path_flags & PATH_NOACL) && fs.has_acls (); }
   bool hasgood_inode () const {return !(path_flags & PATH_IHASH); }
-  bool isgood_inode (__ino64_t ino) const;
+  bool isgood_inode (ino_t ino) const;
   bool support_sparse () const
   {
     return (path_flags & PATH_SPARSE)
@@ -186,6 +190,12 @@ class path_conv
   int is_lnk_special () const {return is_fs_device () || isfifo () || is_lnk_symlink ();}
   int issocket () const {return dev.is_device (FH_UNIX);}
   int iscygexec () const {return path_flags & PATH_CYGWIN_EXEC;}
+  int iscygexec32 () const
+       {return (path_flags & (PATH_CYGWIN_EXEC | PATH_64BITEXEC))
+               == PATH_CYGWIN_EXEC;}
+  int iscygexec64 () const
+       {return (path_flags & (PATH_CYGWIN_EXEC | PATH_64BITEXEC))
+               == (PATH_CYGWIN_EXEC | PATH_64BITEXEC);}
   int isopen () const {return path_flags & PATH_OPEN;}
   int isctty_capable () const {return path_flags & PATH_CTTY;}
   void set_cygexec (bool isset)
@@ -195,6 +205,17 @@ class path_conv
     else
       path_flags &= ~PATH_CYGWIN_EXEC;
   }
+  void set_cygexec (void *target)
+  {
+    if (target)
+      {
+       path_flags |= PATH_CYGWIN_EXEC;
+       if (target == (void *) 64)
+         path_flags |= PATH_64BITEXEC;
+      }
+    else
+      path_flags &= ~PATH_CYGWIN_EXEC;
+  }
   bool isro () const {return !!(path_flags & PATH_RO);}
   bool exists () const {return fileattr != INVALID_FILE_ATTRIBUTES;}
   bool has_attribute (DWORD x) const {return exists () && (fileattr & x);}
@@ -344,8 +365,7 @@ class path_conv
   {
     return eq_worker (pc, pc.path, pc.normalized_path);
   }
-  DWORD get_devn () {return (DWORD) dev;}
-  short get_unitn () const {return dev.get_minor ();}
+  dev_t get_device () {return dev.get_device ();}
   DWORD file_attributes () const {return fileattr;}
   void file_attributes (DWORD new_attr) {fileattr = new_attr;}
   DWORD fs_flags () const {return fs.flags ();}
@@ -380,7 +400,7 @@ class path_conv
   void reset_conv_handle () { conv_handle.set (NULL); }
   void close_conv_handle () { conv_handle.close (); }
 
-  __ino64_t get_ino_by_handle (HANDLE h);
+  ino_t get_ino_by_handle (HANDLE h);
 #if 0 /* obsolete, method still exists in fhandler_disk_file.cc */
   unsigned __stdcall ndisk_links (DWORD);
 #endif
index c0a555983a6f21dd3ff3b4104200cc4d8f2f657b..13cf1771626ba17467f7d38b66647e829bca4c60 100644 (file)
@@ -1,6 +1,6 @@
 /* per_process.h: main Cygwin header file.
 
-   Copyright 2000, 2001 Red Hat, Inc.
+   Copyright 2000, 2001, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -21,7 +21,11 @@ extern struct per_process __cygwin_user_data;
 /* We use the following to test that sizeof hasn't changed.  When adding
    or deleting members, insert fillers or use the reserved entries.
    Do not change this value. */
+#ifdef __x86_64__
+#define SIZEOF_PER_PROCESS (41 * 8)
+#else
 #define SIZEOF_PER_PROCESS (42 * 4)
+#endif
 
 #ifdef __cplusplus
 }
index 79eb25e016eec71a76c1df41c0a0475e7a45971d..47192462dcd8b49c0189b317e2a139441db0452d 100644 (file)
@@ -120,7 +120,7 @@ pinfo::status_exit (DWORD x)
        char posix_prog[NT_MAX_PATH];
        path_conv pc;
        if (!procinfo)
-         pc.check ("/dev/null");
+          pc.check ("/dev/null");
        else
          {
            UNICODE_STRING uc;
@@ -128,7 +128,8 @@ pinfo::status_exit (DWORD x)
            pc.check (&uc, PC_NOWARN);
          }
        mount_table->conv_to_posix_path (pc.get_win32 (), posix_prog, 1);
-       small_printf ("%s: error while loading shared libraries: %s: cannot open shared object file: No such file or directory\n",
+       small_printf ("%s: error while loading shared libraries: %s: cannot "
+                     "open shared object file: No such file or directory\n",
                      posix_prog, find_first_notloaded_dll (pc));
        x = 127 << 8;
       }
@@ -144,7 +145,7 @@ pinfo::status_exit (DWORD x)
       x = SIGILL;
       break;
     default:
-      debug_printf ("*** STATUS_%p\n", x);
+      debug_printf ("*** STATUS_%y\n", x);
       x = 127 << 8;
     }
   return EXITCODE_SET | x;
@@ -174,7 +175,7 @@ pinfo::maybe_set_exit_code_from_windows ()
       GetExitCodeProcess (hProcess, &x);
       set_exit_code (x);
     }
-  sigproc_printf ("pid %d, exit value - old %p, windows %p, cygwin %p",
+  sigproc_printf ("pid %d, exit value - old %y, windows %y, cygwin %y",
                  self->pid, oexitcode, x, self->exitcode);
 }
 
@@ -208,7 +209,7 @@ pinfo::exit (DWORD n)
   int exitcode = self->exitcode & 0xffff;
   if (!self->cygstarted)
     exitcode = ((exitcode & 0xff) << 8) | ((exitcode >> 8) & 0xff);
-  sigproc_printf ("Calling ExitProcess n %p, exitcode %p", n, exitcode);
+  sigproc_printf ("Calling ExitProcess n %y, exitcode %y", n, exitcode);
   if (!TerminateProcess (GetCurrentProcess (), exitcode))
     system_printf ("TerminateProcess failed, %E");
   ExitProcess (exitcode);
@@ -324,7 +325,7 @@ pinfo::init (pid_t n, DWORD flag, HANDLE h0)
       if (procinfo->process_state & PID_EXECED)
        {
          pid_t realpid = procinfo->pid;
-         debug_printf ("execed process windows pid %d, cygwin pid %d", n, realpid);
+         debug_printf ("execed process windows pid %u, cygwin pid %d", n, realpid);
          if (realpid == n)
            api_fatal ("retrieval of execed process info for pid %d failed due to recursion.", n);
 
@@ -389,9 +390,9 @@ pinfo::set_acl()
   RtlCreateSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION);
   status = RtlSetDaclSecurityDescriptor (&sd, TRUE, acl_buf, FALSE);
   if (!NT_SUCCESS (status))
-    debug_printf ("RtlSetDaclSecurityDescriptor %p", status);
+    debug_printf ("RtlSetDaclSecurityDescriptor %y", status);
   else if ((status = NtSetSecurityObject (h, DACL_SECURITY_INFORMATION, &sd)))
-    debug_printf ("NtSetSecurityObject %p", status);
+    debug_printf ("NtSetSecurityObject %y", status);
 }
 
 pinfo::pinfo (HANDLE parent, pinfo_minimal& from, pid_t pid):
@@ -441,7 +442,7 @@ bool
 _pinfo::set_ctty (fhandler_termios *fh, int flags)
 {
   tty_min& tc = *fh->tc ();
-  debug_printf ("old %s, ctty device number %p, tc.ntty device number %p flags & O_NOCTTY %p", __ctty (), ctty, tc.ntty, flags & O_NOCTTY);
+  debug_printf ("old %s, ctty device number %y, tc.ntty device number %y flags & O_NOCTTY %y", __ctty (), ctty, tc.ntty, flags & O_NOCTTY);
   if (fh && &tc && (ctty <= 0 || ctty == tc.ntty) && !(flags & O_NOCTTY))
     {
       ctty = tc.ntty;
@@ -641,7 +642,7 @@ commune_process (void *arg)
     {
       DWORD res = WaitForSingleObject (process_sync, 5000);
       if (res != WAIT_OBJECT_0)
-       sigproc_printf ("WFSO failed - %d, %E", res);
+       sigproc_printf ("WFSO failed - %u, %E", res);
       else
        sigproc_printf ("synchronized with pid %d", si.si_pid);
       ForceCloseHandle (process_sync);
@@ -688,7 +689,7 @@ _pinfo::commune_request (__uint32_t code, ...)
   va_end (args);
 
   char name_buf[MAX_PATH];
-  request_sync = CreateSemaphore (&sec_none_nih, 0, LONG_MAX,
+  request_sync = CreateSemaphore (&sec_none_nih, 0, INT32_MAX,
                                  shared_name (name_buf, "commune", myself->pid));
   if (!request_sync)
     goto err;
@@ -702,7 +703,7 @@ _pinfo::commune_request (__uint32_t code, ...)
       goto err;
     }
 
-  size_t n;
+  DWORD n;
   switch (code)
     {
     case PICOM_CMDLINE:
@@ -711,7 +712,7 @@ _pinfo::commune_request (__uint32_t code, ...)
     case PICOM_FDS:
     case PICOM_FD:
     case PICOM_PIPE_FHANDLER:
-      if (!ReadPipeOverlapped (fromthem, &n, sizeof n, &nr, 500L)
+      if (!ReadPipeOverlapped (fromthem, &n, sizeof n, &nr, 1000L)
          || nr != sizeof n)
        {
          __seterrno ();
@@ -724,7 +725,7 @@ _pinfo::commune_request (__uint32_t code, ...)
          res.s = (char *) cmalloc_abort (HEAP_COMMUNE, n);
          char *p;
          for (p = res.s;
-              n && ReadPipeOverlapped (fromthem, p, n, &nr, 500L);
+              n && ReadPipeOverlapped (fromthem, p, n, &nr, 1000L);
               p += nr, n -= nr)
            continue;
          if (n)
@@ -999,7 +1000,7 @@ pinfo::wait ()
   else
     {
       wait_thread = h;
-      sigproc_printf ("created tracking thread for pid %d, winpid %p, rd_proc_pipe %p",
+      sigproc_printf ("created tracking thread for pid %d, winpid %y, rd_proc_pipe %p",
                      (*this)->pid, (*this)->dwProcessId, rd_proc_pipe);
     }
 
@@ -1254,11 +1255,11 @@ winpids::enum_processes (bool winpid)
   if (winpid)
     {
       static DWORD szprocs;
-      static PSYSTEM_PROCESSES procs;
+      static PSYSTEM_PROCESS_INFORMATION procs;
 
       if (!szprocs)
        {
-         procs = (PSYSTEM_PROCESSES)
+         procs = (PSYSTEM_PROCESS_INFORMATION)
                  malloc (sizeof (*procs) + (szprocs = 200 * sizeof (*procs)));
          if (!procs)
            {
@@ -1271,16 +1272,16 @@ winpids::enum_processes (bool winpid)
       for (;;)
        {
          status =
-               NtQuerySystemInformation (SystemProcessesAndThreadsInformation,
+               NtQuerySystemInformation (SystemProcessInformation,
                                          procs, szprocs, NULL);
          if (NT_SUCCESS (status))
            break;
 
          if (status == STATUS_INFO_LENGTH_MISMATCH)
            {
-             PSYSTEM_PROCESSES new_p;
+             PSYSTEM_PROCESS_INFORMATION new_p;
 
-             new_p = (PSYSTEM_PROCESSES)
+             new_p = (PSYSTEM_PROCESS_INFORMATION)
                      realloc (procs, szprocs += 200 * sizeof (*procs));
              if (!new_p)
                {
@@ -1292,30 +1293,30 @@ winpids::enum_processes (bool winpid)
            }
          else
            {
-             system_printf ("error %p reading system process information",
+             system_printf ("error %y reading system process information",
                             status);
              return 0;
            }
        }
 
-      PSYSTEM_PROCESSES px = procs;
+      PSYSTEM_PROCESS_INFORMATION px = procs;
       for (;;)
        {
-         if (px->ProcessId)
+         if (px->UniqueProcessId)
            {
              bool do_add = true;
              for (unsigned i = 0; i < cygwin_pid_nelem; ++i)
-               if (pidlist[i] == px->ProcessId)
+               if (pidlist[i] == (uintptr_t) px->UniqueProcessId)
                  {
                    do_add = false;
                    break;
                  }
              if (do_add)
-               add (nelem, true, px->ProcessId);
+               add (nelem, true, (DWORD) (uintptr_t) px->UniqueProcessId);
            }
-         if (!px->NextEntryDelta)
+         if (!px->NextEntryOffset)
            break;
-         px = (PSYSTEM_PROCESSES) ((char *) px + px->NextEntryDelta);
+         px = (PSYSTEM_PROCESS_INFORMATION) ((char *) px + px->NextEntryOffset);
        }
     }
 
index 2f97dcb901df3cd1b79163e0b479a2e8b0aec5fc..0a13c4bf8ab8f156fab867fba2bbb533f87f40e6 100644 (file)
@@ -17,7 +17,7 @@ details. */
 struct commune_result
 {
   char *s;
-  int n;
+  DWORD n;
   HANDLE handles[2];
 };
 
@@ -78,11 +78,11 @@ public:
      if not found.  This data resides in the shared data area (allowing
      tasks to store whatever they want here) so it's for informational
      purposes only. */
-  __uid32_t uid;       /* User ID */
-  __gid32_t gid;       /* Group ID */
-  pid_t pgid;          /* Process group ID */
-  pid_t sid;           /* Session ID */
-  int ctty;            /* Control tty */
+  uid_t uid;   /* User ID */
+  gid_t gid;   /* Group ID */
+  pid_t pgid;  /* Process group ID */
+  pid_t sid;   /* Session ID */
+  int ctty;    /* Control tty */
   bool has_pgid_children;/* True if we've forked or spawned children with our GID. */
 
   /* Resources used by process. */
@@ -110,6 +110,7 @@ public:
   char *root (size_t &);
   char *cwd (size_t &);
   char *cmdline (size_t &);
+  char *win_heap_info (size_t &);
   bool set_ctty (class fhandler_termios *, int);
   bool alert_parent (char);
   int __reg2 kill (siginfo_t&);
@@ -178,9 +179,9 @@ public:
   int operator == (pinfo &x) const {return x.procinfo == procinfo;}
   int operator == (_pinfo *x) const {return x == procinfo;}
   int operator == (void *x) const {return procinfo == x;}
-  int operator == (int x) const {return (int) procinfo == (int) x;}
   _pinfo *operator * () const {return procinfo;}
   operator _pinfo * () const {return procinfo;}
+  int operator !() const {return !procinfo;}
   void preserve () { destroy = false; }
   void allow_remove () { destroy = true; }
 #ifndef SIG_BAD_MASK           // kludge to ensure that sigproc.h included
@@ -189,14 +190,14 @@ public:
 #else
   int reattach ()
   {
-    int res = proc_subproc (PROC_REATTACH_CHILD, (DWORD) this);
+    int res = proc_subproc (PROC_REATTACH_CHILD, (uintptr_t) this);
     destroy = res ? false : true;
     return res;
   }
   int remember (bool detach)
   {
     int res = proc_subproc (detach ? PROC_DETACHED_CHILD : PROC_ADDCHILD,
-                           (DWORD) this);
+                           (uintptr_t) this);
     destroy = res ? false : true;
     return res;
   }
index 4a420ea32a10a8118107601f7f3a1934115dd4ba..1e06f902509dcf67def326c18b8c64827871f5e7 100644 (file)
@@ -1,7 +1,7 @@
 /* pipe.cc: pipe for Cygwin.
 
    Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011, 2012 Hat, Inc.
+   2008, 2009, 2010, 2011, 2012, 2013 Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -72,7 +72,8 @@ fhandler_pipe::open (int flags, mode_t mode)
   int pid, rwflags = (flags & O_ACCMODE);
   bool inh;
 
-  sscanf (get_name (), "/proc/%d/fd/pipe:[%d]", &pid, (int *) &pipe_hdl);
+  sscanf (get_name (), "/proc/%d/fd/pipe:[%lu]",
+                      &pid, (unsigned long *) &pipe_hdl);
   if (pid == myself->pid)
     {
       cygheap_fdenum cfd (true);
@@ -142,23 +143,23 @@ out:
   return 0;
 }
 
-_off64_t
-fhandler_pipe::lseek (_off64_t offset, int whence)
+off_t
+fhandler_pipe::lseek (off_t offset, int whence)
 {
-  debug_printf ("(%d, %d)", offset, whence);
+  debug_printf ("(%D, %d)", offset, whence);
   set_errno (ESPIPE);
   return -1;
 }
 
 int
-fhandler_pipe::fadvise (_off64_t offset, _off64_t length, int advice)
+fhandler_pipe::fadvise (off_t offset, off_t length, int advice)
 {
   set_errno (ESPIPE);
   return -1;
 }
 
 int
-fhandler_pipe::ftruncate (_off64_t length, bool allow_truncate)
+fhandler_pipe::ftruncate (off_t length, bool allow_truncate)
 {
   set_errno (allow_truncate ? EINVAL : ESPIPE);
   return -1;
@@ -167,7 +168,7 @@ fhandler_pipe::ftruncate (_off64_t length, bool allow_truncate)
 char *
 fhandler_pipe::get_proc_fd_name (char *buf)
 {
-  __small_sprintf (buf, "pipe:[%d]", get_handle ());
+  __small_sprintf (buf, "pipe:[%lu]", get_handle ());
   return buf;
 }
 
@@ -213,7 +214,9 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
   char pipename[MAX_PATH];
   size_t len = __small_sprintf (pipename, PIPE_INTRO "%S-",
                                      &cygheap->installation_key);
-  DWORD pipe_mode = PIPE_READMODE_BYTE;
+  DWORD pipe_mode = PIPE_READMODE_BYTE
+                   | (wincap.has_pipe_reject_remote_clients ()
+                      ? PIPE_REJECT_REMOTE_CLIENTS : 0);
   if (!name)
     pipe_mode |= pipe_byte ? PIPE_TYPE_BYTE : PIPE_TYPE_MESSAGE;
   else
@@ -228,7 +231,7 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
   if (name)
     len += __small_sprintf (pipename + len, "%s", name);
 
-  open_mode |= PIPE_ACCESS_INBOUND;
+  open_mode |= PIPE_ACCESS_INBOUND | FILE_FLAG_FIRST_PIPE_INSTANCE;
 
   /* Retry CreateNamedPipe as long as the pipe name is in use.
      Retrying will probably never be necessary, but we want
@@ -241,7 +244,7 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
        __small_sprintf (pipename + len, "pipe-%p",
                         InterlockedIncrement ((LONG *) &pipe_unique_id));
 
-      debug_printf ("name %s, size %lu, mode %s", pipename, psize,
+      debug_printf ("name %s, size %u, mode %s", pipename, psize,
                    (pipe_mode & PIPE_TYPE_MESSAGE)
                    ? "PIPE_TYPE_MESSAGE" : "PIPE_TYPE_BYTE");
 
@@ -252,8 +255,7 @@ fhandler_pipe::create (LPSECURITY_ATTRIBUTES sa_ptr, PHANDLE r, PHANDLE w,
         a waste, since only a single direction is actually used.
         It's important to only allow a single instance, to ensure that
         the pipe was not created earlier by some other process, even if
-        the pid has been reused.  We avoid FILE_FLAG_FIRST_PIPE_INSTANCE
-        because that is only available for Win2k SP2 and WinXP.
+        the pid has been reused.
 
         Note that the write side of the pipe is opened as PIPE_TYPE_MESSAGE.
         This *seems* to more closely mimic Linux pipe behavior and is
@@ -361,7 +363,7 @@ fhandler_pipe::create (fhandler_pipe *fhs[2], unsigned psize, int mode)
       res = 0;
     }
 
-  debug_printf ("%R = pipe([%p, %p], %d, %p)", res, fhs[0], fhs[1], psize, mode);
+  debug_printf ("%R = pipe([%p, %p], %d, %y)", res, fhs[0], fhs[1], psize, mode);
   return res;
 }
 
@@ -433,7 +435,7 @@ _pipe (int filedes[2], unsigned int psize, int mode)
       read = filedes[0];
       write = filedes[1];
     }
-  syscall_printf ("%R = _pipe([%d, %d], %u, %p)", res, read, write, psize, mode);
+  syscall_printf ("%R = _pipe([%d, %d], %u, %y)", res, read, write, psize, mode);
   return res;
 }
 
@@ -465,6 +467,6 @@ pipe2 (int filedes[2], int mode)
       read = filedes[0];
       write = filedes[1];
     }
-  syscall_printf ("%R = pipe2([%d, %d], %p)", res, read, write, mode);
+  syscall_printf ("%R = pipe2([%d, %d], %y)", res, read, write, mode);
   return res;
 }
index b936245cdae652576899dee95fa7a5eb4ca1d8df..8ce4a28be2757cc2b029877c1d5e1a17d8614135 100644 (file)
@@ -9,8 +9,6 @@
    Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
    details. */
 
-#define  __INSIDE_CYGWIN_NET__
-
 #define FD_SETSIZE 16384               // lots of fds
 #include "winsup.h"
 #include <sys/poll.h>
index e3c72bf2d75d2f3e42c06cc63931715b844e4503..682066d1b3a0e8c9bf9d68570af1201c1e65094c 100644 (file)
@@ -110,7 +110,7 @@ ipc_mutex_init (HANDLE *pmtx, const char *name)
   status = NtCreateMutant (pmtx, CYG_MUTANT_ACCESS, &attr, FALSE);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtCreateMutant: %p", status);
+      debug_printf ("NtCreateMutant: %y", status);
       return geterrno_from_win_error (RtlNtStatusToDosError (status));
     }
   return 0;
@@ -163,7 +163,7 @@ ipc_cond_init (HANDLE *pevt, const char *name, char sr)
                          NotificationEvent, FALSE);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtCreateEvent: %p", status);
+      debug_printf ("NtCreateEvent: %y", status);
       return geterrno_from_win_error (RtlNtStatusToDosError (status));
     }
   return 0;
@@ -284,7 +284,7 @@ ipc_cond_close (HANDLE evt)
 
 class ipc_flock
 {
-  struct __flock64 fl;
+  struct flock fl;
 
 public:
   ipc_flock () { memset (&fl, 0, sizeof fl); }
@@ -348,29 +348,52 @@ shm_unlink (const char *name)
    files are created under /dev/mqueue.  mq_timedsend and mq_timedreceive
    are implemented additionally. */
 
+/* The mq_attr structure is defined using long datatypes per POSIX.
+   For interoperability reasons between 32 and 64 bit processes, we have
+   to make sure to use a unified structure layout in the message queue file.
+   That's what the mq_fattr is, the in-file representation of the mq_attr
+   struct. */
+#pragma pack (push, 4)
+struct mq_fattr
+{
+  uint32_t mq_flags;
+  uint32_t mq_maxmsg;
+  uint32_t mq_msgsize;
+  uint32_t mq_curmsgs;
+};
+
 struct mq_hdr
 {
-  struct mq_attr  mqh_attr;     /* the queue's attributes */
-  long            mqh_head;     /* index of first message */
-  long            mqh_free;     /* index of first free message */
-  long            mqh_nwait;    /* #threads blocked in mq_receive() */
+  struct mq_fattr mqh_attr;     /* the queue's attributes */
+  int32_t         mqh_head;     /* index of first message */
+  int32_t         mqh_free;     /* index of first free message */
+  int32_t         mqh_nwait;    /* #threads blocked in mq_receive() */
   pid_t           mqh_pid;      /* nonzero PID if mqh_event set */
   char            mqh_uname[36]; /* unique name used to identify synchronization
                                    objects connected to this queue */
-  struct sigevent mqh_event;    /* for mq_notify() */
+  union {
+    struct sigevent mqh_event;  /* for mq_notify() */
+    /* Make sure sigevent takes the same space on 32 and 64 bit systems.
+       Other than that, it doesn't need to be compatible since only
+       one process can be notified at a time. */
+    uint64_t        mqh_placeholder[8];
+  };
+  uint32_t        mqh_magic;   /* Expect MQI_MAGIC here, otherwise it's
+                                  an old-style message queue. */
 };
 
 struct msg_hdr
 {
-  long            msg_next;     /* index of next on linked list */
-  ssize_t         msg_len;      /* actual length */
+  int32_t         msg_next;     /* index of next on linked list */
+  int32_t         msg_len;      /* actual length */
   unsigned int    msg_prio;     /* priority */
 };
+#pragma pack (pop)
 
 struct mq_info
 {
   struct mq_hdr  *mqi_hdr;      /* start of mmap'ed region */
-  unsigned long   mqi_magic;    /* magic number if open */
+  uint32_t        mqi_magic;    /* magic number if open */
   int             mqi_flags;    /* flags for this process */
   HANDLE          mqi_lock;     /* mutex lock */
   HANDLE          mqi_waitsend;         /* and condition variable for full queue */
@@ -385,19 +408,19 @@ struct mq_info
 
 struct mq_attr defattr = { 0, 10, 8192, 0 };   /* Linux defaults. */
 
-extern "C" _off64_t lseek64 (int, _off64_t, int);
-extern "C" void *mmap64 (void *, size_t, int, int, int, _off64_t);
+extern "C" off_t lseek64 (int, off_t, int);
+extern "C" void *mmap64 (void *, size_t, int, int, int, off_t);
 
 extern "C" mqd_t
 mq_open (const char *name, int oflag, ...)
 {
   int i, fd = -1, nonblock, created;
   long msgsize, index;
-  _off64_t filesize = 0;
+  off_t filesize = 0;
   va_list ap;
   mode_t mode;
   int8_t *mptr;
-  struct __stat64 statbuff;
+  struct stat statbuff;
   struct mq_hdr *mqhdr;
   struct msg_hdr *msghdr;
   struct mq_attr *attr;
@@ -441,7 +464,12 @@ again:
       /* First one to create the file initializes it */
       if (attr == NULL)
        attr = &defattr;
-      else if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0)
+      /* Check minimum and maximum values.  The max values are pretty much
+         arbitrary, taken from the linux mq_overview man page.  However,
+        these max values make sure that the internal mq_fattr structure
+        can use 32 bit types. */
+      else if (attr->mq_maxmsg <= 0 || attr->mq_maxmsg > 32768
+              || attr->mq_msgsize <= 0 || attr->mq_msgsize > 1048576)
        {
          set_errno (EINVAL);
          goto err;
@@ -481,6 +509,7 @@ again:
                       hash_path_name (0,mqname),
                       luid.HighPart, luid.LowPart);
       mqhdr->mqh_head = 0;
+      mqhdr->mqh_magic = MQI_MAGIC;
       index = sizeof (struct mq_hdr);
       mqhdr->mqh_free = index;
       for (i = 0; i < attr->mq_maxmsg - 1; i++)
@@ -555,6 +584,15 @@ exists:
   if (!(mqinfo = (struct mq_info *) calloc (1, sizeof (struct mq_info))))
     goto err;
   mqinfo->mqi_hdr = mqhdr = (struct mq_hdr *) mptr;
+  if (mqhdr->mqh_magic != MQI_MAGIC)
+    {
+      system_printf (
+"Old message queue \"%s\" detected!\n"
+"This file is not usable as message queue anymore due to changes in the "
+"internal file layout.  Please remove the file and try again.", mqname);
+      set_errno (EACCES);
+      goto err;
+    }
   mqinfo->mqi_magic = MQI_MAGIC;
   mqinfo->mqi_flags = nonblock;
 
@@ -603,7 +641,7 @@ mq_getattr (mqd_t mqd, struct mq_attr *mqstat)
 {
   int n;
   struct mq_hdr *mqhdr;
-  struct mq_attr *attr;
+  struct mq_fattr *attr;
   struct mq_info *mqinfo;
 
   myfault efault;
@@ -637,7 +675,7 @@ mq_setattr (mqd_t mqd, const struct mq_attr *mqstat, struct mq_attr *omqstat)
 {
   int n;
   struct mq_hdr *mqhdr;
-  struct mq_attr *attr;
+  struct mq_fattr *attr;
   struct mq_info *mqinfo;
 
   myfault efault;
@@ -733,7 +771,7 @@ _mq_send (mqd_t mqd, const char *ptr, size_t len, unsigned int prio,
   int8_t *mptr;
   struct sigevent *sigev;
   struct mq_hdr *mqhdr;
-  struct mq_attr *attr;
+  struct mq_fattr *attr;
   struct msg_hdr *msghdr, *nmsghdr, *pmsghdr;
   struct mq_info *mqinfo;
 
@@ -866,7 +904,7 @@ _mq_receive (mqd_t mqd, char *ptr, size_t maxlen, unsigned int *priop,
   int8_t *mptr;
   ssize_t len;
   struct mq_hdr *mqhdr;
-  struct mq_attr *attr;
+  struct mq_fattr *attr;
   struct msg_hdr *msghdr;
   struct mq_info *mqinfo;
 
@@ -963,7 +1001,7 @@ mq_close (mqd_t mqd)
 {
   long msgsize, filesize;
   struct mq_hdr *mqhdr;
-  struct mq_attr *attr;
+  struct mq_fattr *attr;
   struct mq_info *mqinfo;
 
   myfault efault;
@@ -1028,7 +1066,7 @@ sem_open (const char *name, int oflag, ...)
   va_list ap;
   mode_t mode = 0;
   unsigned int value = 0;
-  struct __stat64 statbuff;
+  struct stat statbuff;
   sem_t *sem = SEM_FAILED;
   sem_finfo sf;
   bool wasopen = false;
@@ -1150,7 +1188,7 @@ _sem_close (sem_t *sem, bool do_close)
   if (semaphore::getinternal (sem, &fd, &sf.hash, &sf.luid, &sf.value) == -1)
     return -1;
   if (!file.lock (fd, sizeof sf)
-      && lseek64 (fd, 0LL, SEEK_SET) != (_off64_t) -1
+      && lseek64 (fd, 0LL, SEEK_SET) != (off_t) -1
       && write (fd, &sf, sizeof sf) == sizeof sf)
     ret = do_close ? semaphore::close (sem) : 0;
 
index 00e7b9682379f792acc92f7b22cf4d9566634963..4af7d3ad275440844f93ad9981c908d2b6efbc39 100644 (file)
@@ -1,6 +1,6 @@
 /* profil.c -- win32 profil.c equivalent
 
-   Copyright 1998, 1999, 2000, 2001, 2003, 2009, 2010 Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2003, 2009, 2010, 2012 Red Hat, Inc.
 
    This file is part of Cygwin.
 
@@ -21,20 +21,24 @@ static struct profinfo prof;
 
 /* Get the pc for thread THR */
 
-static u_long
+static uintptr_t
 get_thrpc (HANDLE thr)
 {
   CONTEXT ctx;
-  u_long pc;
+  uintptr_t pc;
   int res;
 
   res = SuspendThread (thr);
   if (res == -1)
-    return (u_long) - 1;
+    return (uintptr_t) -1;
   ctx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
-  pc = (u_long) - 1;
+  pc = (uintptr_t) -1;
   if (GetThreadContext (thr, &ctx))
+#ifdef __x86_64__
+    pc = ctx.Rip;
+#else
     pc = ctx.Eip;
+#endif
   ResumeThread (thr);
   return pc;
 }
@@ -58,13 +62,14 @@ static DWORD CALLBACK
 profthr_func (LPVOID arg)
 {
   struct profinfo *p = (struct profinfo *) arg;
-  u_long pc, idx;
+  uintptr_t pc;
+  size_t idx;
 
   SetThreadPriority(p->profthr, THREAD_PRIORITY_TIME_CRITICAL);
 
   for (;;)
     {
-      pc = (u_long) get_thrpc (p->targthr);
+      pc = (uintptr_t) get_thrpc (p->targthr);
       if (pc >= p->lowpc && pc < p->highpc)
        {
          idx = PROFIDX (pc, p->lowpc, p->scale);
@@ -134,9 +139,9 @@ profile_on (struct profinfo *p)
  */
 int
 profile_ctl (struct profinfo * p, char *samples, size_t size,
-            u_long offset, u_int scale)
+            size_t offset, unsigned int scale)
 {
-  u_long maxbin;
+  size_t maxbin;
 
   if (scale > 65536)
     {
@@ -150,7 +155,7 @@ profile_ctl (struct profinfo * p, char *samples, size_t size,
       memset (samples, 0, size);
       memset (p, 0, sizeof *p);
       maxbin = size >> 1;
-      prof.counter = (u_short *) samples;
+      prof.counter = (uint16_t *) samples;
       prof.lowpc = offset;
       prof.highpc = PROFADDR (maxbin, offset, scale);
       prof.scale = scale;
@@ -166,8 +171,7 @@ profile_ctl (struct profinfo * p, char *samples, size_t size,
    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)
+profil (char *samples, size_t size, size_t offset, unsigned int scale)
 {
   return profile_ctl (&prof, samples, size, offset, scale);
 }
-
index a681da12382d64eaace2db5c8f9a0552e7d62bab..a25b6edf476d148666d577795916cebda0bc6f5c 100644 (file)
@@ -1,6 +1,6 @@
 /* profil.h: gprof profiling header file
 
-   Copyright 1998, 1999, 2000, 2001, 2003 Red Hat, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2003, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -8,6 +8,8 @@ This software is a copyrighted work licensed under the terms of the
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#include <stdint.h>
+
 /* profiling frequency.  (No larger than 1000) */
 #define PROF_HZ                        100
 
@@ -34,11 +36,11 @@ 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 */
+    uint16_t *counter;                 /* profiling counters */
+    uintptr_t lowpc, highpc;           /* range to be profiled */
+    unsigned 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);
+int profile_ctl (struct profinfo *, char *, size_t, size_t, unsigned int);
+int profil (char *, size_t, size_t, unsigned int);
 
index df91e58892572ce1debb3f019567be04ee346a2e..00c58d7a8a780737ed149603c4094cba1ec1bf14 100644 (file)
@@ -313,12 +313,12 @@ do_pseudo_reloc (void * start, void * end, void * base)
          break;
        case 32:
          reldata = (ptrdiff_t) (*((unsigned int *)reloc_target));
-#ifdef _WIN64
+#if defined (__x86_64__) || defined (_WIN64)
          if ((reldata & 0x80000000) != 0)
            reldata |= ~((ptrdiff_t) 0xffffffff);
 #endif
          break;
-#ifdef _WIN64
+#if defined (__x86_64__) || defined (_WIN64)
        case 64:
          reldata = (ptrdiff_t) (*((unsigned long long *)reloc_target));
          break;
@@ -344,9 +344,15 @@ do_pseudo_reloc (void * start, void * end, void * base)
          __write_memory ((void *) reloc_target, &reldata, 2);
          break;
        case 32:
+#if defined (__CYGWIN__) && defined (__x86_64__) && !defined (__OPTIMIZE__)
+         if (reldata > (ptrdiff_t) __INT32_MAX__
+             || reldata < -((ptrdiff_t) __INT32_MAX__) - 1)
+           __report_error ("Invalid relocation.  Offset %p at address %p "
+                           "doesn't fit into 32 bits", reldata, reloc_target);
+#endif
          __write_memory ((void *) reloc_target, &reldata, 4);
          break;
-#ifdef _WIN64
+#if defined (__x86_64__) || defined (_WIN64)
        case 64:
          __write_memory ((void *) reloc_target, &reldata, 8);
          break;
index 00ef2e87ac65a4c553d71f995ef0a8726af6eca9..fe3c3f2a15477d8ace4036e1a4c3424334a9c28d 100644 (file)
@@ -14,12 +14,12 @@ details. */
    the passwd and group lists */
 extern struct passwd *internal_getpwsid (cygpsid &);
 extern struct passwd *internal_getpwnam (const char *, bool = FALSE);
-extern struct passwd *internal_getpwuid (__uid32_t, bool = FALSE);
-extern struct __group32 *internal_getgrsid (cygpsid &);
-extern struct __group32 *internal_getgrgid (__gid32_t gid, bool = FALSE);
-extern struct __group32 *internal_getgrnam (const char *, bool = FALSE);
-extern struct __group32 *internal_getgrent (int);
-int internal_getgroups (int, __gid32_t *, cygpsid * = NULL);
+extern struct passwd *internal_getpwuid (uid_t, bool = FALSE);
+extern struct group *internal_getgrsid (cygpsid &);
+extern struct group *internal_getgrgid (gid_t gid, bool = FALSE);
+extern struct group *internal_getgrnam (const char *, bool = FALSE);
+extern struct group *internal_getgrent (int);
+int internal_getgroups (int, gid_t *, cygpsid * = NULL);
 
 #include "sync.h"
 #include "cygtls.h"
@@ -29,7 +29,7 @@ class pwdgrp
   union
   {
     passwd **passwd_buf;
-    __group32 **group_buf;
+    group **group_buf;
     void **pwdgrp_buf;
   };
   void (pwdgrp::*read) ();
@@ -80,5 +80,5 @@ public:
   }
 
   pwdgrp (passwd *&pbuf);
-  pwdgrp (__group32 *&gbuf);
+  pwdgrp (group *&gbuf);
 };
index 4afaf8d9a104c9dce11400160b5cd06448ef5912..94e418505f6d8a28fcb57d18976f734f310c7072 100644 (file)
@@ -160,7 +160,7 @@ matcher(struct re_guts *g,
        int i;
        struct match mv;
        struct match *m = &mv;
-       const char *dp;
+       const char *dp = NULL;
        const sopno gf = g->firststate+1;       /* +1 for OEND */
        const sopno gl = g->laststate;
        const char *start;
@@ -391,7 +391,7 @@ dissect(struct match *m,
        const char *ssp;        /* start of string matched by subsubRE */
        const char *sep;        /* end of string matched by subsubRE */
        const char *oldssp;     /* previous ssp */
-       const char *dp;
+       const char *dp __attribute__ ((unused));
 
        AT("diss", start, stop, startst, stopst);
        sp = start;
index b44ba2c62079150474e194e02a77c394d6bda9b3..881c1609947d04f39758192cfcd5e4b72ff8016e 100644 (file)
@@ -63,8 +63,6 @@ __FBSDID("$FreeBSD: src/lib/libc/regex/regcomp.c,v 1.36 2007/06/11 03:05:54 delp
 #include "cname.h"
 
 #ifdef __CYGWIN__
-/* Don't pull in windows headers just for LCID. */
-typedef unsigned long LCID;
 /* These are defined in nlsfuncs.cc. */
 extern LCID collate_lcid;
 extern char collate_charset[];
@@ -1477,8 +1475,8 @@ static void
 findmust(struct parse *p, struct re_guts *g)
 {
        sop *scan;
-       sop *start;
-       sop *newstart;
+       sop *start = NULL;
+       sop *newstart = NULL;
        sopno newlen;
        sop s;
        char *cp;
index 8ea7f75b78772803eb7075b00ec2a8d7aead6194..632260aaea4e6eb1ee83fbd4dc651fe6a8448467 100644 (file)
@@ -238,7 +238,7 @@ get_registry_hive_path (PCWSTR name, PWCHAR path)
                                   NULL, NULL);
   if (!NT_SUCCESS (status) || buf.Length == 0)
     {
-      debug_printf ("ProfileImagePath for %W not found, status %p", name,
+      debug_printf ("ProfileImagePath for %W not found, status %y", name,
                    status);
       return NULL;
     }
@@ -280,11 +280,11 @@ load_registry_hive (PCWSTR name)
   status = NtLoadKey (&key_attr, &path_attr);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("Loading user registry hive %S into %S failed: %p",
+      debug_printf ("Loading user registry hive %S into %S failed: %y",
                    &upath, &ukey, status);
       return;
     }
-  debug_printf ("Loading user registry hive %S into %S SUCCEEDED: %p",
+  debug_printf ("Loading user registry hive %S into %S SUCCEEDED: %y",
                &upath, &ukey, status);
   /* If loading the normal hive worked, try to load the classes hive into
      the sibling *_Classes subkey, which is what the user is supposed to
@@ -300,9 +300,9 @@ load_registry_hive (PCWSTR name)
   /* Load UsrClass.dat file into key. */
   status = NtLoadKey (&key_attr, &path_attr);
   if (!NT_SUCCESS (status))
-    debug_printf ("Loading user classes hive %S into %S failed: %p",
+    debug_printf ("Loading user classes hive %S into %S failed: %y",
                  &upath, &ukey, status);
   else
-    debug_printf ("Loading user classes hive %S into %S SUCCEEDED: %p",
+    debug_printf ("Loading user classes hive %S into %S SUCCEEDED: %y",
                  &upath, &ukey, status);
 }
diff --git a/winsup/cygwin/regparm.h b/winsup/cygwin/regparm.h
new file mode 100644 (file)
index 0000000..5b95426
--- /dev/null
@@ -0,0 +1,21 @@
+/* regparm.h: Define macros for regparm functions and methods.
+
+   Copyright 2013 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. */
+
+#pragma once
+
+#if defined (__x86_64__) || defined (__CYGMAGIC__)
+# define __reg1
+# define __reg2
+# define __reg3
+#else
+# define __reg1 __stdcall __attribute__ ((regparm (1)))
+# define __reg2 __stdcall __attribute__ ((regparm (2)))
+# define __reg3 __stdcall __attribute__ ((regparm (3)))
+#endif
index d40567f4f7092f36bd0268aaf71be8da4a4ff9ed..97a9dff23a7b433b506bab8665155dd18d52dbe2 100644 (file)
@@ -1,7 +1,7 @@
 /* resource.cc: getrusage () and friends.
 
    Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2008, 2009, 2010,
-   2011 Red Hat, Inc.
+   2011, 2012 Red Hat, Inc.
 
    Written by Steve Chamberlain (sac@cygnus.com), Doug Evans (dje@cygnus.com),
    Geoffrey Noer (noer@cygnus.com) of Cygnus Support.
@@ -137,9 +137,9 @@ getrlimit (int resource, struct rlimit *rlp)
        debug_printf ("couldn't get stack info, returning def.values. %E");
       else
        {
-         rlp->rlim_cur = (DWORD) &m - (DWORD) m.AllocationBase;
-         rlp->rlim_max = (DWORD) m.BaseAddress + m.RegionSize
-                         - (DWORD) m.AllocationBase;
+         rlp->rlim_cur = (rlim_t) &m - (rlim_t) m.AllocationBase;
+         rlp->rlim_max = (rlim_t) m.BaseAddress + m.RegionSize
+                         - (rlim_t) m.AllocationBase;
        }
       break;
     case RLIMIT_NOFILE:
index 0b0d0956b228cafe01574e5183227117563ae3eb..b39400d02b538452c56ce8c086f06137048ff6bb 100644 (file)
@@ -1,7 +1,7 @@
 /* sched.cc: scheduler interface for Cygwin
 
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012
-   Red Hat, Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012,
+   2013 Red Hat, Inc.
 
    Written by Robert Collins <rbtcollins@hotmail.com>
 
 #include "registry.h"
 
 /* Win32 priority to UNIX priority Mapping.
+
    For now, I'm just following the spec: any range of priorities is ok.
    There are probably many many issues with this...
 
-   We don't want process's going realtime. Well, they probably could, but the issues
-   with avoiding the priority values 17-22 and 27-30 (not supported before win2k)
-   make that inefficient.
-   However to complicate things most unixes use lower is better priorities.
+   FIXME: We don't support pre-Windows 2000 so we should fix the priority
+          computation.  Here's the description for the current code:
 
-   So we map -14 to 15, and 15 to 1 via (16- ((n+16) >> 1))
-   we then map 1 to 15 to various process class and thread priority combinations
+     We don't want process's going realtime. Well, they probably could, but
+     the issues with avoiding the priority values 17-22 and 27-30 (not
+     supported before win2k) make that inefficient.
 
-   Then we need to look at the threads vi process priority. As win95 98 and NT 4
-   Don't support opening threads cross-process (unless a thread HANDLE is passed around)
-   for now, we'll just use the priority class.
+     However to complicate things most unixes use lower is better priorities.
 
-   The code and logic are present to calculate the priority for thread
-   , if a thread handle can be obtained. Alternatively, if the symbols wouldn't be
-   resolved until they are used
-   we could support this on windows 2000 and ME now, and just fall back to the
-   class only on pre win2000 machines.
+     So we map -14 to 15, and 15 to 1 via (16- ((n+16) >> 1)).  We then map 1
+     to 15 to various process class and thread priority combinations.  Then we
+     need to look at the threads process priority.  As win95, 98 and NT 4
+     don't support opening threads cross-process (unless a thread HANDLE is
+     passed around) for now, we'll just use the priority class.
 
-   Lastly, because we can't assume that the pid we're given are Windows pids, we can't
-   alter non-cygwin started programs.
-*/
+     The code and logic are present to calculate the priority for thread, if a
+     thread handle can be obtained.  Alternatively, if the symbols wouldn't be
+     resolved until they are used we could support this.
+
+   Lastly, because we can't assume that the pid we're given are Windows pids,
+   we can't alter non-cygwin started programs.  */
 
 extern "C"
 {
@@ -130,10 +131,7 @@ sched_getparam (pid_t pid, struct sched_param *param)
     }
   ThreadPriority = THREAD_PRIORITY_NORMAL;
 
-  /* calculate the unix priority.
-
-     FIXME: windows 2000 supports ABOVE_NORMAL and BELOW_NORMAL class's
-     So this logic just defaults those class factors to NORMAL in the calculations */
+  /* calculate the unix priority. */
 
   switch (Class)
     {
@@ -241,11 +239,7 @@ sched_getscheduler (pid_t pid)
     return SCHED_FIFO;
 }
 
-/* get the time quantum for pid
-
-   Implemented only for NT systems, it fails and sets errno to ESRCH
-   for non-NT systems.
-*/
+/* get the time quantum for pid */
 int
 sched_rr_get_interval (pid_t pid, struct timespec *interval)
 {
@@ -315,7 +309,6 @@ sched_setparam (pid_t pid, const struct sched_param *param)
   pid_t localpid;
   int winpri;
   DWORD Class;
-  int ThreadPriority;
   HANDLE process;
 
   if (!param || pid < 0)
@@ -342,70 +335,6 @@ sched_setparam (pid_t pid, const struct sched_param *param)
   else
     Class = NORMAL_PRIORITY_CLASS;
 
-  switch (Class)
-    {
-    case IDLE_PRIORITY_CLASS:
-      switch (winpri)
-       {
-       case 1:
-         ThreadPriority = THREAD_PRIORITY_IDLE;
-         break;
-       case 2:
-         ThreadPriority = THREAD_PRIORITY_LOWEST;
-         break;
-       case 3:
-         ThreadPriority = THREAD_PRIORITY_BELOW_NORMAL;
-         break;
-       case 4:
-         ThreadPriority = THREAD_PRIORITY_NORMAL;
-         break;
-       case 5:
-         ThreadPriority = THREAD_PRIORITY_ABOVE_NORMAL;
-         break;
-       case 6:
-         ThreadPriority = THREAD_PRIORITY_HIGHEST;
-         break;
-       }
-      break;
-    case NORMAL_PRIORITY_CLASS:
-      switch (winpri)
-       {
-       case 7:
-         ThreadPriority = THREAD_PRIORITY_LOWEST;
-         break;
-       case 8:
-         ThreadPriority = THREAD_PRIORITY_BELOW_NORMAL;
-         break;
-       case 9:
-         ThreadPriority = THREAD_PRIORITY_NORMAL;
-         break;
-       case 10:
-         ThreadPriority = THREAD_PRIORITY_ABOVE_NORMAL;
-         break;
-       case 11:
-         ThreadPriority = THREAD_PRIORITY_HIGHEST;
-         break;
-       }
-      break;
-    case HIGH_PRIORITY_CLASS:
-      switch (winpri)
-       {
-       case 12:
-         ThreadPriority = THREAD_PRIORITY_BELOW_NORMAL;
-         break;
-       case 13:
-         ThreadPriority = THREAD_PRIORITY_NORMAL;
-         break;
-       case 14:
-         ThreadPriority = THREAD_PRIORITY_ABOVE_NORMAL;
-         break;
-       case 15:
-         ThreadPriority = THREAD_PRIORITY_HIGHEST;
-         break;
-       }
-      break;
-    }
-
   localpid = pid ? pid : getpid ();
 
   pinfo p (localpid);
@@ -414,7 +343,7 @@ sched_setparam (pid_t pid, const struct sched_param *param)
 
   if (!p)
     {
-      set_errno (1);           //ESRCH);
+      set_errno (ESRCH);
       return -1;
     }
   process =
@@ -435,11 +364,11 @@ sched_setparam (pid_t pid, const struct sched_param *param)
   return 0;
 }
 
-/* we map -14 to 15, and 15 to 1 via (16- ((n+16) >> 1)). This lines up with the allowed
- * valueswe return elsewhere in the sched* functions. We then map in groups of three to
* allowed thread priority's. The reason for dropping accuracy while still returning
- * a wide range of values is to allow more flexible code in the future.
- */
+/* we map -14 to 15, and 15 to 1 via (16- ((n+16) >> 1)). This lines up with
+   the allowed values we return elsewhere in the sched* functions. We then
  map in groups of three to allowed thread priority's. The reason for dropping
+   accuracy while still returning a wide range of values is to allow more
  flexible code in the future. */
 int
 sched_set_thread_priority (HANDLE thread, int priority)
 {
index b9ffa49f65c608d1cf7f344a7965cb33b96714c1..2f7ac278ddb4263c1b4c9624c3291d465402665e 100644 (file)
@@ -26,7 +26,7 @@ details. */
 #include "tls_pbuf.h"
 
 static int
-searchace (__aclent32_t *aclp, int nentries, int type, __uid32_t id = ILLEGAL_UID)
+searchace (aclent_t *aclp, int nentries, int type, uid_t id = ILLEGAL_UID)
 {
   int i;
 
@@ -38,7 +38,7 @@ searchace (__aclent32_t *aclp, int nentries, int type, __uid32_t id = ILLEGAL_UI
 }
 
 int
-setacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp,
+setacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp,
        bool &writable)
 {
   security_descriptor sd_ret;
@@ -93,7 +93,7 @@ setacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp,
 
   cygsid sid;
   struct passwd *pw;
-  struct __group32 *gr;
+  struct group *gr;
   int pos;
 
   RtlCreateAcl (acl, ACL_MAXIMUM_SIZE, ACL_REVISION);
@@ -201,7 +201,7 @@ setacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp,
     }
   /* Set AclSize to computed value. */
   acl->AclSize = acl_len;
-  debug_printf ("ACL-Size: %d", acl_len);
+  debug_printf ("ACL-Size: %u", acl_len);
   /* Create DACL for local security descriptor. */
   status = RtlSetDaclSecurityDescriptor (&sd, TRUE, acl, FALSE);
   if (!NT_SUCCESS (status))
@@ -228,7 +228,7 @@ setacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp,
       __seterrno_from_nt_status (status);
       return -1;
     }
-  debug_printf ("Created SD-Size: %d", sd_ret.size ());
+  debug_printf ("Created SD-Size: %u", sd_ret.size ());
   return set_file_sd (handle, pc, sd_ret, false);
 }
 
@@ -238,7 +238,7 @@ setacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp,
 #define DENY_X 010000
 
 static void
-getace (__aclent32_t &acl, int type, int id, DWORD win_ace_mask,
+getace (aclent_t &acl, int type, int id, DWORD win_ace_mask,
        DWORD win_ace_type)
 {
   acl.a_type = type;
@@ -270,7 +270,7 @@ getace (__aclent32_t &acl, int type, int id, DWORD win_ace_mask,
 }
 
 int
-getacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp)
+getacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp)
 {
   security_descriptor sd;
 
@@ -281,8 +281,8 @@ getacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp)
   cygpsid group_sid;
   NTSTATUS status;
   BOOLEAN dummy;
-  __uid32_t uid;
-  __gid32_t gid;
+  uid_t uid;
+  gid_t gid;
 
   status = RtlGetOwnerSecurityDescriptor (sd, (PSID *) &owner_sid, &dummy);
   if (!NT_SUCCESS (status))
@@ -300,8 +300,8 @@ getacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp)
     }
   gid = group_sid.get_gid ();
 
-  __aclent32_t lacl[MAX_ACL_ENTRIES];
-  memset (&lacl, 0, MAX_ACL_ENTRIES * sizeof (__aclent32_t));
+  aclent_t lacl[MAX_ACL_ENTRIES];
+  memset (&lacl, 0, MAX_ACL_ENTRIES * sizeof (aclent_t));
   lacl[0].a_type = USER_OBJ;
   lacl[0].a_id = uid;
   lacl[1].a_type = GROUP_OBJ;
@@ -435,7 +435,7 @@ getacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp)
        set_errno (ENOSPC);
        return -1;
       }
-    memcpy (aclbufp, lacl, pos * sizeof (__aclent32_t));
+    memcpy (aclbufp, lacl, pos * sizeof (aclent_t));
     for (i = 0; i < pos; ++i)
       aclbufp[i].a_perm &= ~(DENY_R | DENY_W | DENY_X);
     aclsort32 (pos, 0, aclbufp);
@@ -445,7 +445,7 @@ getacl (HANDLE handle, path_conv &pc, int nentries, __aclent32_t *aclbufp)
 }
 
 extern "C" int
-acl32 (const char *path, int cmd, int nentries, __aclent32_t *aclbufp)
+acl32 (const char *path, int cmd, int nentries, aclent_t *aclbufp)
 {
   int res = -1;
 
@@ -466,16 +466,18 @@ acl32 (const char *path, int cmd, int nentries, __aclent32_t *aclbufp)
   return res;
 }
 
+#ifndef __x86_64__
 extern "C" int
-lacl32 (const char *path, int cmd, int nentries, __aclent32_t *aclbufp)
+lacl32 (const char *path, int cmd, int nentries, aclent_t *aclbufp)
 {
   /* This call was an accident.  Make it absolutely clear. */
   set_errno (ENOSYS);
   return -1;
 }
+#endif
 
 extern "C" int
-facl32 (int fd, int cmd, int nentries, __aclent32_t *aclbufp)
+facl32 (int fd, int cmd, int nentries, aclent_t *aclbufp)
 {
   cygheap_fdget cfd (fd);
   if (cfd < 0)
@@ -489,18 +491,18 @@ facl32 (int fd, int cmd, int nentries, __aclent32_t *aclbufp)
 }
 
 extern "C" int
-aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
+aclcheck32 (aclent_t *aclbufp, int nentries, int *which)
 {
   bool has_user_obj = false;
   bool has_group_obj = false;
   bool has_other_obj = false;
   bool has_class_obj = false;
-  bool has_ug_objs = false;
-  bool has_def_user_obj = false;
+  bool has_ug_objs __attribute__ ((unused)) = false;
+  bool has_def_user_obj __attribute__ ((unused)) = false;
   bool has_def_group_obj = false;
   bool has_def_other_obj = false;
   bool has_def_class_obj = false;
-  bool has_def_ug_objs = false;
+  bool has_def_ug_objs __attribute__ ((unused)) = false;
   int pos2;
 
   for (int pos = 0; pos < nentries; ++pos)
@@ -623,7 +625,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
 static int
 acecmp (const void *a1, const void *a2)
 {
-#define ace(i) ((const __aclent32_t *) a##i)
+#define ace(i) ((const aclent_t *) a##i)
   int ret = ace (1)->a_type - ace (2)->a_type;
   if (!ret)
     ret = ace (1)->a_id - ace (2)->a_id;
@@ -632,7 +634,7 @@ acecmp (const void *a1, const void *a2)
 }
 
 extern "C" int
-aclsort32 (int nentries, int, __aclent32_t *aclbufp)
+aclsort32 (int nentries, int, aclent_t *aclbufp)
 {
   if (aclcheck32 (aclbufp, nentries, NULL))
     return -1;
@@ -641,12 +643,12 @@ aclsort32 (int nentries, int, __aclent32_t *aclbufp)
       set_errno (EINVAL);
       return -1;
     }
-  qsort ((void *) aclbufp, nentries, sizeof (__aclent32_t), acecmp);
+  qsort ((void *) aclbufp, nentries, sizeof (aclent_t), acecmp);
   return 0;
 }
 
 extern "C" int
-acltomode32 (__aclent32_t *aclbufp, int nentries, mode_t *modep)
+acltomode32 (aclent_t *aclbufp, int nentries, mode_t *modep)
 {
   int pos;
 
@@ -685,7 +687,7 @@ acltomode32 (__aclent32_t *aclbufp, int nentries, mode_t *modep)
 }
 
 extern "C" int
-aclfrommode32 (__aclent32_t *aclbufp, int nentries, mode_t *modep)
+aclfrommode32 (aclent_t *aclbufp, int nentries, mode_t *modep)
 {
   int pos;
 
@@ -722,13 +724,13 @@ aclfrommode32 (__aclent32_t *aclbufp, int nentries, mode_t *modep)
 }
 
 extern "C" int
-acltopbits32 (__aclent32_t *aclbufp, int nentries, mode_t *pbitsp)
+acltopbits32 (aclent_t *aclbufp, int nentries, mode_t *pbitsp)
 {
   return acltomode32 (aclbufp, nentries, pbitsp);
 }
 
 extern "C" int
-aclfrompbits32 (__aclent32_t *aclbufp, int nentries, mode_t *pbitsp)
+aclfrompbits32 (aclent_t *aclbufp, int nentries, mode_t *pbitsp)
 {
   return aclfrommode32 (aclbufp, nentries, pbitsp);
 }
@@ -746,7 +748,7 @@ permtostr (mode_t perm)
 }
 
 extern "C" char *
-acltotext32 (__aclent32_t *aclbufp, int aclcnt)
+acltotext32 (aclent_t *aclbufp, int aclcnt)
 {
   if (!aclbufp || aclcnt < 1 || aclcnt > MAX_ACL_ENTRIES
       || aclcheck32 (aclbufp, aclcnt, NULL))
@@ -821,7 +823,7 @@ permfromstr (char *perm)
   return mode;
 }
 
-extern "C" __aclent32_t *
+extern "C" aclent_t *
 aclfromtext32 (char *acltextp, int *)
 {
   if (!acltextp)
@@ -830,7 +832,7 @@ aclfromtext32 (char *acltextp, int *)
       return NULL;
     }
   char buf[strlen (acltextp) + 1];
-  __aclent32_t lacl[MAX_ACL_ENTRIES];
+  aclent_t lacl[MAX_ACL_ENTRIES];
   memset (lacl, 0, sizeof lacl);
   int pos = 0;
   strcpy (buf, acltextp);
@@ -882,7 +884,7 @@ aclfromtext32 (char *acltextp, int *)
              c += 5;
              if (isalpha (*c))
                {
-                 struct __group32 *gr = internal_getgrnam (c);
+                 struct group *gr = internal_getgrnam (c);
                  if (!gr)
                    {
                      set_errno (EINVAL);
@@ -927,17 +929,29 @@ aclfromtext32 (char *acltextp, int *)
        }
       ++pos;
     }
-  __aclent32_t *aclp = (__aclent32_t *) malloc (pos * sizeof (__aclent32_t));
+  aclent_t *aclp = (aclent_t *) malloc (pos * sizeof (aclent_t));
   if (aclp)
-    memcpy (aclp, lacl, pos * sizeof (__aclent32_t));
+    memcpy (aclp, lacl, pos * sizeof (aclent_t));
   return aclp;
 }
 
-/* __aclent16_t and __aclent32_t have same size and same member offsets */
-static __aclent32_t *
+#ifdef __x86_64__
+EXPORT_ALIAS (acl32, acl)
+EXPORT_ALIAS (facl32, facl)
+EXPORT_ALIAS (aclcheck32, aclcheck)
+EXPORT_ALIAS (aclsort32, aclsort)
+EXPORT_ALIAS (acltomode32, acltomode)
+EXPORT_ALIAS (aclfrommode32, aclfrommode)
+EXPORT_ALIAS (acltopbits32, acltopbits)
+EXPORT_ALIAS (aclfrompbits32, aclfrompbits)
+EXPORT_ALIAS (acltotext32, acltotext)
+EXPORT_ALIAS (aclfromtext32, aclfromtext)
+#else
+/* __aclent16_t and aclent_t have same size and same member offsets */
+static aclent_t *
 acl16to32 (__aclent16_t *aclbufp, int nentries)
 {
-  __aclent32_t *aclbufp32 = (__aclent32_t *) aclbufp;
+  aclent_t *aclbufp32 = (aclent_t *) aclbufp;
   if (aclbufp32)
     for (int i = 0; i < nentries; i++)
       aclbufp32[i].a_id &= USHRT_MAX;
@@ -986,7 +1000,7 @@ acltomode (__aclent16_t *aclbufp, int nentries, mode_t *modep)
 extern "C" int
 aclfrommode (__aclent16_t *aclbufp, int nentries, mode_t *modep)
 {
-  return aclfrommode32 ((__aclent32_t *)aclbufp, nentries, modep);
+  return aclfrommode32 ((aclent_t *)aclbufp, nentries, modep);
 }
 
 extern "C" int
@@ -998,7 +1012,7 @@ acltopbits (__aclent16_t *aclbufp, int nentries, mode_t *pbitsp)
 extern "C" int
 aclfrompbits (__aclent16_t *aclbufp, int nentries, mode_t *pbitsp)
 {
-  return aclfrompbits32 ((__aclent32_t *)aclbufp, nentries, pbitsp);
+  return aclfrompbits32 ((aclent_t *)aclbufp, nentries, pbitsp);
 }
 
 extern "C" char *
@@ -1012,3 +1026,4 @@ aclfromtext (char *acltextp, int * aclcnt)
 {
   return (__aclent16_t *) aclfromtext32 (acltextp, aclcnt);
 }
+#endif /* !__x86_64__ */
index 95e7d0bf1744bbc2853a2d430b9d28cb8c4ed6c4..dd5ee06271ccf3aa56bc70d3ffefaa285259e46a 100644 (file)
@@ -1,7 +1,7 @@
 /* sec_auth.cc: NT authentication functions
 
    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -87,7 +87,7 @@ get_full_privileged_inheritable_token (HANDLE token)
 void
 set_imp_token (HANDLE token, int type)
 {
-  debug_printf ("set_imp_token (%d, %d)", token, type);
+  debug_printf ("set_imp_token (%p, %d)", token, type);
   cygheap->user.external_token = (token == INVALID_HANDLE_VALUE
                                  ? NO_IMPERSONATION : token);
   cygheap->user.ext_token_is_restricted = (type == CW_TOKEN_RESTRICTED);
@@ -108,7 +108,7 @@ extract_nt_dom_user (const struct passwd *pw, PWCHAR domain, PWCHAR user)
   DWORD dlen = MAX_DOMAIN_NAME_LEN + 1;
   SID_NAME_USE use;
 
-  debug_printf ("pw_gecos %x (%s)", pw->pw_gecos, pw->pw_gecos);
+  debug_printf ("pw_gecos %p (%s)", pw->pw_gecos, pw->pw_gecos);
 
   if (psid.getfrompw (pw)
       && LookupAccountSidW (NULL, psid, user, &ulen, domain, &dlen, &use))
@@ -283,7 +283,7 @@ get_user_groups (WCHAR *logonserver, cygsidlist &grp_list,
       else if (legal_sid_type (use))
        grp_list += gsid;
       else
-       debug_printf ("Global group %W invalid. Use: %d", dgroup, use);
+       debug_printf ("Global group %W invalid. Use: %u", dgroup, use);
     }
 
   NetApiBufferFree (buf);
@@ -332,7 +332,7 @@ get_user_local_groups (PWCHAR logonserver, PWCHAR domain,
          else if (legal_sid_type (use))
            grp_list += gsid;
          else
-           debug_printf ("Rejecting local %W. use: %d", dg_ptr, use);
+           debug_printf ("Rejecting local %W. use: %u", dg_ptr, use);
        }
       else if (GetLastError () == ERROR_NONE_MAPPED)
        {
@@ -360,7 +360,7 @@ get_user_local_groups (PWCHAR logonserver, PWCHAR domain,
                                      dom, &domlen, &use))
                {
                  if (!legal_sid_type (use))
-                   debug_printf ("Rejecting local %W. use: %d", dg_ptr, use);
+                   debug_printf ("Rejecting local %W. use: %u", dg_ptr, use);
                  else
                    grp_list *= gsid;
                }
@@ -389,12 +389,12 @@ sid_in_token_groups (PTOKEN_GROUPS grps, cygpsid sid)
 static void
 get_unix_group_sidlist (struct passwd *pw, cygsidlist &grp_list)
 {
-  struct __group32 *gr;
+  struct group *gr;
   cygsid gsid;
 
   for (int gidx = 0; (gr = internal_getgrent (gidx)); ++gidx)
     {
-      if (gr->gr_gid == (__gid32_t) pw->pw_gid)
+      if (gr->gr_gid == pw->pw_gid)
        goto found;
       else if (gr->gr_mem)
        for (int gi = 0; gr->gr_mem[gi]; ++gi)
@@ -689,7 +689,7 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern)
       status = NtQueryInformationToken (token, TokenSource, &ts, sizeof ts,
                                        &size);
       if (!NT_SUCCESS (status))
-       debug_printf ("NtQueryInformationToken(), %p", status);
+       debug_printf ("NtQueryInformationToken(), %y", status);
       else
        *pintern = intern = !memcmp (ts.SourceName, "Cygwin.1", 8);
     }
@@ -698,7 +698,7 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern)
   status = NtQueryInformationToken (token, TokenUser, &tok_usersid,
                                    sizeof tok_usersid, &size);
   if (!NT_SUCCESS (status))
-    debug_printf ("NtQueryInformationToken(), %p", status);
+    debug_printf ("NtQueryInformationToken(), %y", status);
   if (usersid != tok_usersid)
     return false;
 
@@ -713,14 +713,14 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern)
       status = NtQuerySecurityObject (token, GROUP_SECURITY_INFORMATION,
                                      sd_buf, sd_buf_siz, &size);
       if (!NT_SUCCESS (status))
-       debug_printf ("NtQuerySecurityObject(), %p", status);
+       debug_printf ("NtQuerySecurityObject(), %y", status);
       else
        {
          BOOLEAN dummy;
          status = RtlGetGroupSecurityDescriptor (sd_buf, (PSID *) &gsid,
                                                  &dummy);
          if (!NT_SUCCESS (status))
-           debug_printf ("RtlGetGroupSecurityDescriptor(), %p", status);
+           debug_printf ("RtlGetGroupSecurityDescriptor(), %y", status);
        }
       if (well_known_null_sid != gsid)
        return gsid == groups.pgsid;
@@ -731,14 +731,14 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern)
   status = NtQueryInformationToken (token, TokenGroups, NULL, 0, &size);
   if (!NT_SUCCESS (status) && status != STATUS_BUFFER_TOO_SMALL)
     {
-      debug_printf ("NtQueryInformationToken(token, TokenGroups), %p", status);
+      debug_printf ("NtQueryInformationToken(token, TokenGroups), %y", status);
       return false;
     }
   my_grps = (PTOKEN_GROUPS) alloca (size);
   status = NtQueryInformationToken (token, TokenGroups, my_grps, size, &size);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtQueryInformationToken(my_token, TokenGroups), %p",
+      debug_printf ("NtQueryInformationToken(my_token, TokenGroups), %y",
                    status);
       return false;
     }
@@ -748,7 +748,7 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern)
   if (groups.issetgroups ()) /* setgroups was called */
     {
       cygsid gsid;
-      struct __group32 *gr;
+      struct group *gr;
       bool saw[groups.sgsids.count ()];
       memset (saw, 0, sizeof(saw));
 
@@ -851,7 +851,7 @@ create_token (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
                                            &stats, sizeof stats, &size);
          if (!NT_SUCCESS (status))
            debug_printf ("NtQueryInformationToken(hProcToken, "
-                         "TokenStatistics), %p", status);
+                         "TokenStatistics), %y", status);
          else
            auth_luid = stats.AuthenticationId;
        }
@@ -861,7 +861,7 @@ create_token (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
       status = NtQueryInformationToken (hProcToken, TokenGroups, NULL, 0,
                                        &size);
       if (!NT_SUCCESS (status) && status != STATUS_BUFFER_TOO_SMALL)
-       debug_printf ("NtQueryInformationToken(hProcToken, TokenGroups), %p",
+       debug_printf ("NtQueryInformationToken(hProcToken, TokenGroups), %y",
                      status);
       else if (!(my_tok_gsids = (PTOKEN_GROUPS) malloc (size)))
        debug_printf ("malloc (my_tok_gsids) failed.");
@@ -872,7 +872,7 @@ create_token (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
          if (!NT_SUCCESS (status))
            {
              debug_printf ("NtQueryInformationToken(hProcToken, TokenGroups), "
-                           "%p", status);
+                           "%y", status);
              free (my_tok_gsids);
              my_tok_gsids = NULL;
            }
@@ -995,7 +995,7 @@ lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
   status = LsaRegisterLogonProcess (&name, &lsa_hdl, &sec_mode);
   if (status != STATUS_SUCCESS)
     {
-      debug_printf ("LsaRegisterLogonProcess: %p", status);
+      debug_printf ("LsaRegisterLogonProcess: %y", status);
       __seterrno_from_nt_status (status);
       goto out;
     }
@@ -1009,7 +1009,7 @@ lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
   status = LsaLookupAuthenticationPackage (lsa_hdl, &name, &package_id);
   if (status != STATUS_SUCCESS)
     {
-      debug_printf ("LsaLookupAuthenticationPackage: %p", status);
+      debug_printf ("LsaLookupAuthenticationPackage: %y", status);
       __seterrno_from_nt_status (status);
       goto out;
     }
@@ -1033,11 +1033,6 @@ lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
   else if (!get_initgroups_sidlist (tmp_gsids, usersid, new_groups.pgsid, pw,
                                    NULL, auth_luid, auth_pos))
     goto out;
-  /* The logon SID entry is not generated automatically on Windows 2000
-     and earlier for some reason.  So add fake logon sid here, which is
-     filled with logon id values in the authentication package. */
-  if (wincap.needs_logon_sid_in_sid_list ())
-    tmp_gsids += fake_logon_sid;
 
   tmp_gsids.debug_print ("tmp_gsids");
 
@@ -1131,10 +1126,6 @@ lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
       gsids->Groups[i].Attributes = SE_GROUP_MANDATORY
                                    | SE_GROUP_ENABLED_BY_DEFAULT
                                    | SE_GROUP_ENABLED;
-      /* Mark logon SID as logon SID :) */
-      if (wincap.needs_logon_sid_in_sid_list ()
-         && tmp_gsids.sids[tmpidx] == fake_logon_sid)
-       gsids->Groups[i].Attributes += SE_GROUP_LOGON_ID;
       RtlCopySid (RtlLengthSid (tmp_gsids.sids[tmpidx]),
                  (PSID) ((PBYTE) &authinf->inf + sids_offset),
                  tmp_gsids.sids[tmpidx]);
@@ -1171,7 +1162,7 @@ lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
                         &sub_status);
   if (status != STATUS_SUCCESS)
     {
-      debug_printf ("LsaLogonUser: %p (sub-status %p)", status, sub_status);
+      debug_printf ("LsaLogonUser: %y (sub-status %y)", status, sub_status);
       __seterrno_from_nt_status (status);
       goto out;
     }
index 285550c688f5aa31ba849452a39e4bda30665140..619c0c166d902e9eaff280d213dadc7335e9a48a 100644 (file)
@@ -1,7 +1,7 @@
 /* sec_helper.cc: NT security helper functions
 
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
-   2011, 2012 Red Hat, Inc.
+   2011, 2012, 2013 Red Hat, Inc.
 
    Written by Corinna Vinschen <corinna@vinschen.de>
 
@@ -26,10 +26,17 @@ details. */
 #include "ntdll.h"
 
 /* General purpose security attribute objects for global use. */
-SECURITY_ATTRIBUTES NO_COPY sec_none;
-SECURITY_ATTRIBUTES NO_COPY sec_none_nih;
-SECURITY_ATTRIBUTES NO_COPY sec_all;
-SECURITY_ATTRIBUTES NO_COPY sec_all_nih;
+static NO_COPY_RO SECURITY_DESCRIPTOR null_sdp =
+       { SECURITY_DESCRIPTOR_REVISION, 0, SE_DACL_PRESENT,
+         NULL, NULL, NULL, NULL };
+SECURITY_ATTRIBUTES NO_COPY_RO sec_none =
+       { sizeof (SECURITY_ATTRIBUTES), NULL, TRUE };
+SECURITY_ATTRIBUTES NO_COPY_RO sec_none_nih =
+       { sizeof (SECURITY_ATTRIBUTES), NULL, FALSE };
+SECURITY_ATTRIBUTES NO_COPY_RO sec_all =
+       { sizeof (SECURITY_ATTRIBUTES), &null_sdp, TRUE };
+SECURITY_ATTRIBUTES NO_COPY_RO sec_all_nih =
+       { sizeof (SECURITY_ATTRIBUTES), &null_sdp, FALSE };
 
 MKSID (well_known_null_sid, "S-1-0-0",
        SECURITY_NULL_SID_AUTHORITY, 1, SECURITY_NULL_RID);
@@ -67,8 +74,6 @@ MKSID (well_known_admins_sid, "S-1-5-32-544",
 MKSID (well_known_users_sid, "S-1-5-32-545",
        SECURITY_NT_AUTHORITY, 2, SECURITY_BUILTIN_DOMAIN_RID,
                                 DOMAIN_ALIAS_RID_USERS);
-MKSID (fake_logon_sid, "S-1-5-5-0-0",
-       SECURITY_NT_AUTHORITY, 3, SECURITY_LOGON_IDS_RID, 0, 0);
 MKSID (mandatory_medium_integrity_sid, "S-1-16-8192",
        SECURITY_MANDATORY_LABEL_AUTHORITY, 1, SECURITY_MANDATORY_MEDIUM_RID);
 MKSID (mandatory_high_integrity_sid, "S-1-16-12288",
@@ -87,15 +92,15 @@ cygpsid::operator== (const char *nsidstr) const
   return psid == nsid;
 }
 
-__uid32_t
+uid_t
 cygpsid::get_id (BOOL search_grp, int *type)
 {
     /* First try to get SID from group, then passwd */
-  __uid32_t id = ILLEGAL_UID;
+  uid_t id = ILLEGAL_UID;
 
   if (search_grp)
     {
-      struct __group32 *gr;
+      struct group *gr;
       if (cygheap->user.groups.pgsid == psid)
        id = myself->gid;
       else if ((gr = internal_getgrsid (*this)))
@@ -205,7 +210,7 @@ cygsid::getfrompw (const struct passwd *pw)
 }
 
 BOOL
-cygsid::getfromgr (const struct __group32 *gr)
+cygsid::getfromgr (const struct group *gr)
 {
   char *sp = (gr && gr->gr_passwd) ? gr->gr_passwd : NULL;
   return (*this = sp) != NULL;
@@ -254,10 +259,10 @@ cygsidlist::add (const PSID nsi, bool well_known)
 }
 
 bool
-get_sids_info (cygpsid owner_sid, cygpsid group_sid, __uid32_t * uidret, __gid32_t * gidret)
+get_sids_info (cygpsid owner_sid, cygpsid group_sid, uid_t * uidret, gid_t * gidret)
 {
   struct passwd *pw;
-  struct __group32 *gr = NULL;
+  struct group *gr = NULL;
   bool ret = false;
 
   owner_sid.debug_print ("get_sids_info: owner SID =");
@@ -434,7 +439,7 @@ set_privilege (HANDLE token, DWORD privilege, bool enable)
 
 out:
   if (ret < 0)
-    debug_printf ("%d = set_privilege((token %x) %W, %d)", ret, token,
+    debug_printf ("%d = set_privilege((token %p) %W, %d)", ret, token,
                  privilege_name (new_priv.Privileges[0].Luid), enable);
   return ret;
 }
@@ -456,44 +461,10 @@ set_cygwin_privileges (HANDLE token)
   /* Allow to create global shared memory.  This isn't required anymore since
      Cygwin 1.7.  It uses its own subdirectories in the global NT namespace
      which isn't affected by the SE_CREATE_GLOBAL_PRIVILEGE restriction. */
-  if (wincap.has_create_global_privilege ())
-    set_privilege (token, SE_CREATE_GLOBAL_PRIVILEGE, true);
+  set_privilege (token, SE_CREATE_GLOBAL_PRIVILEGE, true);
 #endif
 }
 
-/* Function to return a common SECURITY_DESCRIPTOR that
-   allows all access.  */
-
-static inline PSECURITY_DESCRIPTOR
-get_null_sd ()
-{
-  static NO_COPY SECURITY_DESCRIPTOR sd;
-  static NO_COPY PSECURITY_DESCRIPTOR null_sdp;
-
-  if (!null_sdp)
-    {
-      RtlCreateSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION);
-      RtlSetDaclSecurityDescriptor (&sd, TRUE, NULL, FALSE);
-      null_sdp = &sd;
-    }
-  return null_sdp;
-}
-
-/* Initialize global security attributes.
-   Called from dcrt0.cc (_dll_crt0).  */
-
-void
-init_global_security ()
-{
-  sec_none.nLength = sec_none_nih.nLength =
-  sec_all.nLength = sec_all_nih.nLength = sizeof (SECURITY_ATTRIBUTES);
-  sec_none.bInheritHandle = sec_all.bInheritHandle = TRUE;
-  sec_none_nih.bInheritHandle = sec_all_nih.bInheritHandle = FALSE;
-  sec_none.lpSecurityDescriptor = sec_none_nih.lpSecurityDescriptor = NULL;
-  sec_all.lpSecurityDescriptor = sec_all_nih.lpSecurityDescriptor =
-    get_null_sd ();
-}
-
 bool
 sec_acl (PACL acl, bool original, bool admins, PSID sid1, PSID sid2, DWORD access2)
 {
@@ -509,44 +480,44 @@ sec_acl (PACL acl, bool original, bool admins, PSID sid1, PSID sid2, DWORD acces
   status = RtlCreateAcl (acl, acl_len, ACL_REVISION);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("RtlCreateAcl: %p", status);
+      debug_printf ("RtlCreateAcl: %y", status);
       return false;
     }
   if (sid1)
     {
       status = RtlAddAccessAllowedAce (acl, ACL_REVISION, GENERIC_ALL, sid1);
       if (!NT_SUCCESS (status))
-       debug_printf ("RtlAddAccessAllowedAce(sid1) %p", status);
+       debug_printf ("RtlAddAccessAllowedAce(sid1) %y", status);
     }
   if (original && (psid = cygheap->user.saved_sid ())
       && psid != sid1 && psid != well_known_system_sid)
     {
       status = RtlAddAccessAllowedAce (acl, ACL_REVISION, GENERIC_ALL, psid);
       if (!NT_SUCCESS (status))
-       debug_printf ("RtlAddAccessAllowedAce(original) %p", status);
+       debug_printf ("RtlAddAccessAllowedAce(original) %y", status);
     }
   if (sid2)
     {
       status = RtlAddAccessAllowedAce (acl, ACL_REVISION, access2, sid2);
       if (!NT_SUCCESS (status))
-       debug_printf ("RtlAddAccessAllowedAce(sid2) %p", status);
+       debug_printf ("RtlAddAccessAllowedAce(sid2) %y", status);
     }
   if (admins)
     {
       status = RtlAddAccessAllowedAce (acl, ACL_REVISION, GENERIC_ALL,
                                       well_known_admins_sid);
       if (!NT_SUCCESS (status))
-       debug_printf ("RtlAddAccessAllowedAce(admin) %p", status);
+       debug_printf ("RtlAddAccessAllowedAce(admin) %y", status);
     }
   status = RtlAddAccessAllowedAce (acl, ACL_REVISION, GENERIC_ALL,
                                   well_known_system_sid);
   if (!NT_SUCCESS (status))
-    debug_printf ("RtlAddAccessAllowedAce(system) %p", status);
+    debug_printf ("RtlAddAccessAllowedAce(system) %y", status);
   status = RtlFirstFreeAce (acl, &pAce);
   if (NT_SUCCESS (status) && pAce)
     acl->AclSize = (char *) pAce - (char *) acl;
   else
-    debug_printf ("RtlFirstFreeAce: %p", status);
+    debug_printf ("RtlFirstFreeAce: %y", status);
 
   return true;
 }
@@ -570,7 +541,7 @@ __sec_user (PVOID sa_buf, PSID sid1, PSID sid2, DWORD access2, BOOL inherit)
   RtlCreateSecurityDescriptor (psd, SECURITY_DESCRIPTOR_REVISION);
   status = RtlSetDaclSecurityDescriptor (psd, TRUE, acl, FALSE);
   if (!NT_SUCCESS (status))
-    debug_printf ("RtlSetDaclSecurityDescriptor %p", status);
+    debug_printf ("RtlSetDaclSecurityDescriptor %y", status);
 
   psa->nLength = sizeof (SECURITY_ATTRIBUTES);
   psa->lpSecurityDescriptor = psd;
@@ -621,7 +592,7 @@ _recycler_sd (void *buf, bool users, bool dir)
   status = RtlFirstFreeAce (dacl, &ace);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("RtlFirstFreeAce: %p", status);
+      debug_printf ("RtlFirstFreeAce: %y", status);
       return NULL;
     }
   dacl->AclSize = (char *) ace - (char *) dacl;
@@ -655,14 +626,14 @@ _everyone_sd (void *buf, ACCESS_MASK access)
                                       well_known_world_sid);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("RtlAddAccessAllowedAce: %p", status);
+         debug_printf ("RtlAddAccessAllowedAce: %y", status);
          return NULL;
        }
       LPVOID ace;
       status = RtlFirstFreeAce (dacl, &ace);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("RtlFirstFreeAce: %p", status);
+         debug_printf ("RtlFirstFreeAce: %y", status);
          return NULL;
        }
       dacl->AclSize = (char *) ace - (char *) dacl;
index fbc1d97a09ff8f5258c6b9ecd0c182d0aeaa77a9..251e9609e6aa283092826052660f697c68b5909f 100644 (file)
@@ -1,7 +1,7 @@
 /* security.cc: NT file access control functions
 
    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
    Originaly written by Gunther Ebert, gunther.ebert@ixos-leipzig.de
    Completely rewritten by Corinna Vinschen <corinna@vinschen.de>
@@ -31,10 +31,10 @@ details. */
                                  | GROUP_SECURITY_INFORMATION \
                                  | OWNER_SECURITY_INFORMATION)
 
-static NO_COPY GENERIC_MAPPING file_mapping = { FILE_GENERIC_READ,
-                                               FILE_GENERIC_WRITE,
-                                               FILE_GENERIC_EXECUTE,
-                                               FILE_ALL_ACCESS };
+static GENERIC_MAPPING NO_COPY_RO file_mapping = { FILE_GENERIC_READ,
+                                                  FILE_GENERIC_WRITE,
+                                                  FILE_GENERIC_EXECUTE,
+                                                  FILE_ALL_ACCESS };
 
 LONG
 get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd,
@@ -58,7 +58,7 @@ get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd,
                                      sd, len, &rlen);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("NtQuerySecurityObject (%S), status %p",
+         debug_printf ("NtQuerySecurityObject (%S), status %y",
                        pc.get_nt_native_path (), status);
          fh = NULL;
        }
@@ -152,7 +152,7 @@ get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd,
                           | FILE_OPEN_REPARSE_POINT);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("NtOpenFile (%S), status %p", &dirname, status);
+         debug_printf ("NtOpenFile (%S), status %y", &dirname, status);
          return 0;
        }
       /* ... fetch the parent's security descriptor ... */
@@ -162,7 +162,7 @@ get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd,
       NtClose (fh);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("NtQuerySecurityObject (%S), status %p",
+         debug_printf ("NtQuerySecurityObject (%S), status %y",
                        &dirname, status);
          return 0;
        }
@@ -177,7 +177,7 @@ get_file_sd (HANDLE fh, path_conv &pc, security_descriptor &sd,
                                                      &file_mapping);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("RtlConvertToAutoInheritSecurityObject (%S), status %p",
+         debug_printf ("RtlConvertToAutoInheritSecurityObject (%S), status %y",
                        &dirname, status);
          return 0;
        }
@@ -330,7 +330,7 @@ get_attribute_from_acl (mode_t *attribute, PACL acl, PSID owner_sid,
 
 static void
 get_info_from_sd (PSECURITY_DESCRIPTOR psd, mode_t *attribute,
-                 __uid32_t *uidret, __gid32_t *gidret)
+                 uid_t *uidret, gid_t *gidret)
 {
   if (!psd)
     {
@@ -352,13 +352,13 @@ get_info_from_sd (PSECURITY_DESCRIPTOR psd, mode_t *attribute,
 
   status = RtlGetOwnerSecurityDescriptor (psd, (PSID *) &owner_sid, &dummy);
   if (!NT_SUCCESS (status))
-    debug_printf ("RtlGetOwnerSecurityDescriptor: %p", status);
+    debug_printf ("RtlGetOwnerSecurityDescriptor: %y", status);
   status = RtlGetGroupSecurityDescriptor (psd, (PSID *) &group_sid, &dummy);
   if (!NT_SUCCESS (status))
-    debug_printf ("RtlGetGroupSecurityDescriptor: %p", status);
+    debug_printf ("RtlGetGroupSecurityDescriptor: %y", status);
 
-  __uid32_t uid;
-  __gid32_t gid;
+  uid_t uid;
+  gid_t gid;
   bool grp_member = get_sids_info (owner_sid, group_sid, &uid, &gid);
   if (uidret)
     *uidret = uid;
@@ -367,7 +367,7 @@ get_info_from_sd (PSECURITY_DESCRIPTOR psd, mode_t *attribute,
 
   if (!attribute)
     {
-      syscall_printf ("uid %d, gid %d", uid, gid);
+      syscall_printf ("uid %u, gid %u", uid, gid);
       return;
     }
 
@@ -385,7 +385,7 @@ get_info_from_sd (PSECURITY_DESCRIPTOR psd, mode_t *attribute,
   else
     get_attribute_from_acl (attribute, acl, owner_sid, group_sid, grp_member);
 
-  syscall_printf ("%sACL %x, uid %d, gid %d",
+  syscall_printf ("%sACL %y, uid %u, gid %u",
                  (!acl_exists || !acl)?"NO ":"", *attribute, uid, gid);
 }
 
@@ -414,8 +414,8 @@ get_reg_sd (HANDLE handle, security_descriptor &sd_ret)
 }
 
 int
-get_reg_attribute (HKEY hkey, mode_t *attribute, __uid32_t *uidret,
-                  __gid32_t *gidret)
+get_reg_attribute (HKEY hkey, mode_t *attribute, uid_t *uidret,
+                  gid_t *gidret)
 {
   security_descriptor sd;
 
@@ -430,7 +430,7 @@ get_reg_attribute (HKEY hkey, mode_t *attribute, __uid32_t *uidret,
 
 int
 get_file_attribute (HANDLE handle, path_conv &pc,
-                   mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
+                   mode_t *attribute, uid_t *uidret, gid_t *gidret)
 {
   if (pc.has_acls ())
     {
@@ -496,7 +496,7 @@ add_access_denied_ace (PACL acl, int offset, DWORD attributes,
 }
 
 static PSECURITY_DESCRIPTOR
-alloc_sd (path_conv &pc, __uid32_t uid, __gid32_t gid, int attribute,
+alloc_sd (path_conv &pc, uid_t uid, gid_t gid, int attribute,
          security_descriptor &sd_ret)
 {
   NTSTATUS status;
@@ -506,17 +506,17 @@ alloc_sd (path_conv &pc, __uid32_t uid, __gid32_t gid, int attribute,
   /* NOTE: If the high bit of attribute is set, we have just created
      a file or directory.  See below for an explanation. */
 
-  debug_printf("uid %d, gid %d, attribute %x", uid, gid, attribute);
+  debug_printf("uid %u, gid %u, attribute %y", uid, gid, attribute);
 
   /* Get owner and group from current security descriptor. */
   PSID cur_owner_sid = NULL;
   PSID cur_group_sid = NULL;
   status = RtlGetOwnerSecurityDescriptor (sd_ret, &cur_owner_sid, &dummy);
   if (!NT_SUCCESS (status))
-    debug_printf ("RtlGetOwnerSecurityDescriptor: %p", status);
+    debug_printf ("RtlGetOwnerSecurityDescriptor: %y", status);
   status = RtlGetGroupSecurityDescriptor (sd_ret, &cur_group_sid, &dummy);
   if (!NT_SUCCESS (status))
-    debug_printf ("RtlGetGroupSecurityDescriptor: %p", status);
+    debug_printf ("RtlGetGroupSecurityDescriptor: %y", status);
 
   /* Get SID of owner. */
   cygsid owner_sid;
@@ -899,7 +899,7 @@ get_object_sd (HANDLE handle, security_descriptor &sd)
 }
 
 int
-get_object_attribute (HANDLE handle, __uid32_t *uidret, __gid32_t *gidret,
+get_object_attribute (HANDLE handle, uid_t *uidret, gid_t *gidret,
                      mode_t *attribute)
 {
   security_descriptor sd;
@@ -911,7 +911,7 @@ get_object_attribute (HANDLE handle, __uid32_t *uidret, __gid32_t *gidret,
 }
 
 int
-create_object_sd_from_attribute (HANDLE handle, __uid32_t uid, __gid32_t gid,
+create_object_sd_from_attribute (HANDLE handle, uid_t uid, gid_t gid,
                                 mode_t attribute, security_descriptor &sd)
 {
   path_conv pc;
@@ -936,7 +936,7 @@ set_object_sd (HANDLE handle, security_descriptor &sd, bool chown)
 }
 
 int
-set_object_attribute (HANDLE handle, __uid32_t uid, __gid32_t gid,
+set_object_attribute (HANDLE handle, uid_t uid, gid_t gid,
                      mode_t attribute)
 {
   security_descriptor sd;
@@ -949,7 +949,7 @@ set_object_attribute (HANDLE handle, __uid32_t uid, __gid32_t gid,
 
 int
 set_file_attribute (HANDLE handle, path_conv &pc,
-                   __uid32_t uid, __gid32_t gid, mode_t attribute)
+                   uid_t uid, gid_t gid, mode_t attribute)
 {
   int ret = -1;
 
@@ -964,7 +964,7 @@ set_file_attribute (HANDLE handle, path_conv &pc,
     }
   else
     ret = 0;
-  syscall_printf ("%d = set_file_attribute(%S, %d, %d, %p)",
+  syscall_printf ("%d = set_file_attribute(%S, %d, %d, %y)",
                  ret, pc.get_nt_native_path (), uid, gid, attribute);
   return ret;
 }
@@ -1061,7 +1061,7 @@ check_file_access (path_conv &pc, int flags, bool effective)
     desired |= FILE_EXECUTE;
   if (!get_file_sd (pc.handle (), pc, sd, false))
     ret = check_access (sd, file_mapping, desired, flags, effective);
-  debug_printf ("flags %x, ret %d", flags, ret);
+  debug_printf ("flags %y, ret %d", flags, ret);
   return ret;
 }
 
@@ -1070,10 +1070,10 @@ check_registry_access (HANDLE hdl, int flags, bool effective)
 {
   security_descriptor sd;
   int ret = -1;
-  static GENERIC_MAPPING NO_COPY reg_mapping = { KEY_READ,
-                                                KEY_WRITE,
-                                                KEY_EXECUTE,
-                                                KEY_ALL_ACCESS };
+  static GENERIC_MAPPING NO_COPY_RO reg_mapping = { KEY_READ,
+                                                   KEY_WRITE,
+                                                   KEY_EXECUTE,
+                                                   KEY_ALL_ACCESS };
   ACCESS_MASK desired = 0;
   if (flags & R_OK)
     desired |= KEY_ENUMERATE_SUB_KEYS;
@@ -1094,6 +1094,6 @@ check_registry_access (HANDLE hdl, int flags, bool effective)
       set_errno (EROFS);
       ret = -1;
     }
-  debug_printf ("flags %x, ret %d", flags, ret);
+  debug_printf ("flags %y, ret %d", flags, ret);
   return ret;
 }
index e478d91aca239122a6c1656685b2e233e7a12c8e..9550e98d7dd0d696ccadea846cb067f254194a0b 100644 (file)
@@ -53,12 +53,10 @@ details. */
 #define SE_SYSTEM_ENVIRONMENT_PRIVILEGE     22UL
 #define SE_CHANGE_NOTIFY_PRIVILEGE          23UL
 #define SE_REMOTE_SHUTDOWN_PRIVILEGE        24UL
-/* Starting with Windows 2000 */
 #define SE_UNDOCK_PRIVILEGE                 25UL
 #define SE_SYNC_AGENT_PRIVILEGE             26UL
 #define SE_ENABLE_DELEGATION_PRIVILEGE      27UL
 #define SE_MANAGE_VOLUME_PRIVILEGE          28UL
-/* Starting with Windows 2000 SP4, XP SP2, 2003 Server */
 #define SE_IMPERSONATE_PRIVILEGE            29UL
 #define SE_CREATE_GLOBAL_PRIVILEGE          30UL
 /* Starting with Vista */
@@ -114,7 +112,7 @@ public:
   cygpsid (PSID nsid) { psid = nsid; }
   operator PSID () const { return psid; }
   const PSID operator= (PSID nsid) { return psid = nsid;}
-  __uid32_t get_id (BOOL search_grp, int *type = NULL);
+  uid_t get_id (BOOL search_grp, int *type = NULL);
   int get_uid () { return get_id (FALSE); }
   int get_gid () { return get_id (TRUE); }
 
@@ -187,7 +185,7 @@ public:
   inline PSID set () { return psid = (PSID) sbuf; }
 
   BOOL getfrompw (const struct passwd *pw);
-  BOOL getfromgr (const struct __group32 *gr);
+  BOOL getfromgr (const struct group *gr);
 
   void debug_print (const char *prefix = NULL) const
     {
@@ -217,7 +215,7 @@ public:
     }
   ~cygsidlist () { if (type == cygsidlist_auto) delete [] sids; }
 
-  BOOL addfromgr (struct __group32 *gr) /* Only with alloc */
+  BOOL addfromgr (struct group *gr) /* Only with alloc */
     { return sids[cnt].getfromgr (gr) && ++cnt; }
 
   /* += adds a "normal" SID, *= adds a well-known SID.  See comment in class
@@ -346,7 +344,6 @@ extern cygpsid well_known_system_sid;
 extern cygpsid well_known_builtin_sid;
 extern cygpsid well_known_admins_sid;
 extern cygpsid well_known_users_sid;
-extern cygpsid fake_logon_sid;
 extern cygpsid mandatory_medium_integrity_sid;
 extern cygpsid mandatory_high_integrity_sid;
 extern cygpsid mandatory_system_integrity_sid;
@@ -370,17 +367,17 @@ legal_sid_type (SID_NAME_USE type)
 class path_conv;
 /* File manipulation */
 int __reg3 get_file_attribute (HANDLE, path_conv &, mode_t *,
-                                 __uid32_t *, __gid32_t *);
+                                 uid_t *, gid_t *);
 int __reg3 set_file_attribute (HANDLE, path_conv &,
-                                 __uid32_t, __gid32_t, mode_t);
+                                 uid_t, gid_t, mode_t);
 int __reg2 get_object_sd (HANDLE, security_descriptor &);
-int __reg3 get_object_attribute (HANDLE, __uid32_t *, __gid32_t *, mode_t *);
-int __reg3 set_object_attribute (HANDLE, __uid32_t, __gid32_t, mode_t);
-int __reg3 create_object_sd_from_attribute (HANDLE, __uid32_t, __gid32_t,
+int __reg3 get_object_attribute (HANDLE, uid_t *, gid_t *, mode_t *);
+int __reg3 set_object_attribute (HANDLE, uid_t, gid_t, mode_t);
+int __reg3 create_object_sd_from_attribute (HANDLE, uid_t, gid_t,
                                               mode_t, security_descriptor &);
 int __reg3 set_object_sd (HANDLE, security_descriptor &, bool);
 
-int __reg3 get_reg_attribute (HKEY hkey, mode_t *, __uid32_t *, __gid32_t *);
+int __reg3 get_reg_attribute (HKEY hkey, mode_t *, uid_t *, gid_t *);
 LONG __reg3 get_file_sd (HANDLE fh, path_conv &, security_descriptor &, bool);
 LONG __reg3 set_file_sd (HANDLE fh, path_conv &, security_descriptor &, bool);
 bool __reg3 add_access_allowed_ace (PACL, int, DWORD, PSID, size_t &, DWORD);
@@ -392,14 +389,14 @@ void set_security_attribute (path_conv &pc, int attribute,
                             PSECURITY_ATTRIBUTES psa,
                             security_descriptor &sd_buf);
 
-bool get_sids_info (cygpsid, cygpsid, __uid32_t * , __gid32_t *);
+bool get_sids_info (cygpsid, cygpsid, uid_t * , gid_t *);
 
 /* sec_acl.cc */
-struct __acl32;
-extern "C" int aclsort32 (int, int, __acl32 *);
-extern "C" int acl32 (const char *, int, int, __acl32 *);
-int getacl (HANDLE, path_conv &, int, __acl32 *);
-int setacl (HANDLE, path_conv &, int, __acl32 *, bool &);
+struct acl;
+extern "C" int aclsort32 (int, int, struct acl *);
+extern "C" int acl32 (const char *, int, int, struct acl *);
+int getacl (HANDLE, path_conv &, int, struct acl *);
+int setacl (HANDLE, path_conv &, int, struct acl *, bool &);
 
 /* Set impersonation or restricted token.  */
 void set_imp_token (HANDLE token, int type);
index 11964c9d648fcd8dfb10a95a0e492714db4229ab..ab6517cbf67a3e3af213c8d32a7f4d2c705cf2ad 100644 (file)
@@ -53,7 +53,6 @@ details. */
  * should be >= NOFILE (param.h).
  */
 
-typedef long fd_mask;
 #define UNIX_NFDBITS (sizeof (fd_mask) * NBBY)       /* bits per mask */
 #ifndef unix_howmany
 #define unix_howmany(x,y) (((x)+((y)-1))/(y))
@@ -63,7 +62,7 @@ typedef long fd_mask;
 
 #define NULL_fd_set ((fd_set *) NULL)
 #define sizeof_fd_set(n) \
-  ((unsigned) (NULL_fd_set->fds_bits + unix_howmany ((n), UNIX_NFDBITS)))
+  ((size_t) (NULL_fd_set->fds_bits + unix_howmany ((n), UNIX_NFDBITS)))
 #define UNIX_FD_SET(n, p) \
   ((p)->fds_bits[(n)/UNIX_NFDBITS] |= (1L << ((n) % UNIX_NFDBITS)))
 #define UNIX_FD_CLR(n, p) \
@@ -114,7 +113,7 @@ cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
        ms = 1;                 /* At least 1 ms granularity */
 
       if (to)
-       select_printf ("to->tv_sec %d, to->tv_usec %d, ms %d", to->tv_sec, to->tv_usec, ms);
+       select_printf ("to->tv_sec %ld, to->tv_usec %ld, ms %d", to->tv_sec, to->tv_usec, ms);
       else
        select_printf ("to NULL, ms %x", ms);
 
@@ -295,7 +294,7 @@ select_record::dump_select_record ()
                 read_ready, write_ready, except_ready);
   select_printf ("read_selected %d, write_selected %d, except_selected %d, except_on_write %d",
                 read_selected, write_selected, except_selected, except_on_write);
-
+                    
   select_printf ("startup %p, peek %p, verify %p cleanup %p, next %p",
                 startup, peek, verify, cleanup, next);
 }
@@ -539,7 +538,7 @@ no_verify (select_record *, fd_set *, fd_set *, fd_set *)
 static int
 pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
 {
-  IO_STATUS_BLOCK iosb = {0};
+  IO_STATUS_BLOCK iosb = {{0}, 0};
   FILE_PIPE_LOCAL_INFORMATION fpli = {0};
 
   bool res;
@@ -568,7 +567,7 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
        that.  This means that a pipe could still block since you could
        be trying to write more to the pipe than is available in the
        buffer but that is the hazard of select().  */
-    paranoid_printf ("fd %d, %s, write: size %lu, avail %lu", fd,
+    paranoid_printf ("fd %d, %s, write: size %u, avail %u", fd,
                     fh->get_name (), fpli.OutboundQuota,
                     fpli.WriteQuotaAvailable);
   else if ((res = (fpli.OutboundQuota < PIPE_BUF &&
@@ -576,7 +575,7 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
     /* If we somehow inherit a tiny pipe (size < PIPE_BUF), then consider
        the pipe writable only if it is completely empty, to minimize the
        probability that a subsequent write will block.  */
-    select_printf ("fd, %s, write tiny pipe: size %lu, avail %lu",
+    select_printf ("fd, %s, write tiny pipe: size %u, avail %u",
                   fd, fh->get_name (), fpli.OutboundQuota,
                   fpli.WriteQuotaAvailable);
   return res ?: -!!(fpli.NamedPipeState & FILE_PIPE_CLOSING_STATE);
index 9231e2fdcd9329c0243639510975c54b530ee113..5ce0924864858177e0022a4ee98f563b8b62eaec 100644 (file)
@@ -1,7 +1,7 @@
 /* select.h
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
index d90ba2adda9c48b5ce1005442b4dc739d73f096c..2c172990ab86da115a29980168c63144980a50a2 100644 (file)
@@ -1,6 +1,6 @@
 /* sem.cc: XSI IPC interface for Cygwin.
 
-   Copyright 2002, 2003, 2004, 2005, 2008, 2009 Red Hat, Inc.
+   Copyright 2002, 2003, 2004, 2005, 2008, 2009, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -83,8 +83,8 @@ semctl (int semid, int semnum, int cmd, ...)
       arg = va_arg (ap, union semun);
       va_end (ap);
     }
-  syscall_printf ("semctl (semid = %d, semnum = %d, cmd = %d, arg.val = 0x%x)",
-                 semid, semnum, cmd, arg.val);
+  syscall_printf ("semctl (semid = %d, semnum = %d, cmd = %d, arg = %p)",
+                 semid, semnum, cmd, arg.buf);
   myfault efault;
   if (efault.faulted (EFAULT))
     return -1;
@@ -103,7 +103,7 @@ semctl (int semid, int semnum, int cmd, ...)
 extern "C" int
 semget (key_t key, int nsems, int semflg)
 {
-  syscall_printf ("semget (key = %U, nsems = %d, semflg = 0x%x)",
+  syscall_printf ("semget (key = %U, nsems = %d, semflg = %y)",
                  key, nsems, semflg);
   client_request_sem request (key, nsems, semflg);
   if (request.make_request () == -1 || request.retval () == -1)
@@ -120,7 +120,7 @@ semget (key_t key, int nsems, int semflg)
 extern "C" int
 semop (int semid, struct sembuf *sops, size_t nsops)
 {
-  syscall_printf ("semop (semid = %d, sops = %p, nsops = %d)",
+  syscall_printf ("semop (semid = %d, sops = %p, nsops = %ld)",
                  semid, sops, nsops);
   myfault efault;
   if (efault.faulted (EFAULT))
index 5ba69dc6508abd2d1b708557be0c731a9b664925..17f84c29d6b42dfbfd834dd5ed7ca939f992be17 100644 (file)
@@ -1,7 +1,7 @@
 /* shared.cc: shared data area support.
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -59,7 +59,7 @@ get_shared_parent_dir ()
       status = NtCreateDirectoryObject (&shared_parent_dir,
                                        CYG_SHARED_DIR_ACCESS, &attr);
       if (!NT_SUCCESS (status))
-       api_fatal ("NtCreateDirectoryObject(%S): %p", &uname, status);
+       api_fatal ("NtCreateDirectoryObject(%S): %y", &uname, status);
     }
   return shared_parent_dir;
 }
@@ -95,7 +95,7 @@ get_session_parent_dir ()
          status = NtCreateDirectoryObject (&session_parent_dir,
                                            CYG_SHARED_DIR_ACCESS, &attr);
          if (!NT_SUCCESS (status))
-           api_fatal ("NtCreateDirectoryObject(%S): %p", &uname, status);
+           api_fatal ("NtCreateDirectoryObject(%S): %y", &uname, status);
        }
     }
   return session_parent_dir;
@@ -115,8 +115,8 @@ shared_name (WCHAR *ret_buf, const WCHAR *str, int num)
   return ret_buf;
 }
 
-#define page_const (65535)
-#define pround(n) (((size_t) (n) + page_const) & ~page_const)
+#define page_const ((ptrdiff_t) 65535)
+#define pround(n) ((ptrdiff_t)(((n) + page_const) & ~page_const))
 
 /* The order in offsets is so that the constant blocks shared_info
    and user_info are right below the cygwin DLL, then the pinfo block
@@ -290,40 +290,20 @@ shared_destroy ()
 void
 shared_info::init_obcaseinsensitive ()
 {
-  if (wincap.kernel_is_always_casesensitive ())
-    {
-      /* Only Windows 2000.  Default to case insensitive unless the user
-        sets the obcaseinsensitive registry value explicitely to 0. */
-      DWORD def_obcaseinsensitive = 1;
-
-      obcaseinsensitive = def_obcaseinsensitive;
-      RTL_QUERY_REGISTRY_TABLE tab[2] = {
-       { NULL, RTL_QUERY_REGISTRY_DIRECT | RTL_QUERY_REGISTRY_NOSTRING,
-         L"obcaseinsensitive", &obcaseinsensitive, REG_DWORD,
-         &def_obcaseinsensitive, sizeof (DWORD) },
-       { NULL, 0, NULL, NULL, 0, NULL, 0 }
-      };
-      RtlQueryRegistryValues (RTL_REGISTRY_CONTROL,
-                             L"Session Manager\\kernel",
-                             tab, NULL, NULL);
-    }
-  else
-    {
-      /* Instead of reading the obcaseinsensitive registry value, test the
-        actual state of case sensitivity handling in the kernel. */
-      UNICODE_STRING sysroot;
-      OBJECT_ATTRIBUTES attr;
-      HANDLE h;
-
-      RtlInitUnicodeString (&sysroot, L"\\SYSTEMROOT");
-      InitializeObjectAttributes (&attr, &sysroot, 0, NULL, NULL);
-      /* NtOpenSymbolicLinkObject returns STATUS_ACCESS_DENIED when called
-        with a 0 access mask.  However, if the kernel is case sensitive,
-        it returns STATUS_OBJECT_NAME_NOT_FOUND because we used the incorrect
-        case for the filename (It's actually "\\SystemRoot"). */
-      obcaseinsensitive = NtOpenSymbolicLinkObject (&h, 0, &attr)
-                         != STATUS_OBJECT_NAME_NOT_FOUND;
-    }
+  /* Instead of reading the obcaseinsensitive registry value, test the
+     actual state of case sensitivity handling in the kernel. */
+  UNICODE_STRING sysroot;
+  OBJECT_ATTRIBUTES attr;
+  HANDLE h;
+
+  RtlInitUnicodeString (&sysroot, L"\\SYSTEMROOT");
+  InitializeObjectAttributes (&attr, &sysroot, 0, NULL, NULL);
+  /* NtOpenSymbolicLinkObject returns STATUS_ACCESS_DENIED when called
+     with a 0 access mask.  However, if the kernel is case sensitive,
+     it returns STATUS_OBJECT_NAME_NOT_FOUND because we used the incorrect
+     case for the filename (It's actually "\\SystemRoot"). */
+  obcaseinsensitive = NtOpenSymbolicLinkObject (&h, 0, &attr)
+                     != STATUS_OBJECT_NAME_NOT_FOUND;
 }
 
 void inline
@@ -359,7 +339,7 @@ shared_info::initialize ()
     sversion.multiple_cygwin_problem ("system shared memory version",
                                      sversion, CURR_SHARED_MAGIC);
   else if (cb != sizeof (*this))
-    system_printf ("size of shared memory region changed from %u to %u",
+    system_printf ("size of shared memory region changed from %lu to %u",
                   sizeof (*this), cb);
   heap_init ();
 }
index f972109491c58d70e0c28cd3d0311250be143c89..226d2ee913850740df5cf9e0b3e47f3e3fff92fe 100644 (file)
@@ -1,6 +1,7 @@
 /* shm.cc: XSI IPC interface for Cygwin.
 
-   Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 Red Hat, Inc.
+   Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2012, 2013
+   Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -135,12 +136,12 @@ fixup_shms_after_fork ()
     {
       NTSTATUS status;
       vm_object_t ptr = sph_entry->ptr;
-      ULONG viewsize = sph_entry->parent->size;
+      SIZE_T viewsize = sph_entry->parent->size;
       status = NtMapViewOfSection (sph_entry->parent->hdl, NtCurrentProcess (),
                                   &ptr, 0, sph_entry->parent->size, NULL,
                                   &viewsize, ViewShare, 0, sph_entry->access);
       if (!NT_SUCCESS (status) || ptr != sph_entry->ptr)
-       api_fatal ("fixup_shms_after_fork: NtMapViewOfSection (%p), status %p.  Terminating.",
+       api_fatal ("fixup_shms_after_fork: NtMapViewOfSection (%p), status %y.  Terminating.",
                   sph_entry->ptr, status);
     }
   return 0;
@@ -153,7 +154,7 @@ fixup_shms_after_fork ()
 extern "C" void *
 shmat (int shmid, const void *shmaddr, int shmflg)
 {
-  syscall_printf ("shmat (shmid = %d, shmaddr = %p, shmflg = 0x%x)",
+  syscall_printf ("shmat (shmid = %d, shmaddr = %p, shmflg = %y)",
                  shmid, shmaddr, shmflg);
 
   SLIST_LOCK ();
@@ -219,7 +220,7 @@ shmat (int shmid, const void *shmaddr, int shmflg)
     }
   NTSTATUS status;
   vm_object_t ptr = NULL;
-  ULONG viewsize = ssh_entry->size;
+  SIZE_T viewsize = ssh_entry->size;
   ULONG access = (shmflg & SHM_RDONLY) ? PAGE_READONLY : PAGE_READWRITE;
   status = NtMapViewOfSection (ssh_entry->hdl, NtCurrentProcess (), &ptr, 0,
                               ssh_entry->size, NULL, &viewsize, ViewShare,
@@ -257,7 +258,7 @@ shmat (int shmid, const void *shmaddr, int shmflg)
 extern "C" int
 shmctl (int shmid, int cmd, struct shmid_ds *buf)
 {
-  syscall_printf ("shmctl (shmid = %d, cmd = %d, buf = 0x%x)",
+  syscall_printf ("shmctl (shmid = %d, cmd = %d, buf = %p)",
                  shmid, cmd, buf);
   myfault efault;
   if (efault.faulted (EFAULT))
@@ -339,7 +340,7 @@ shmdt (const void *shmaddr)
 extern "C" int
 shmget (key_t key, size_t size, int shmflg)
 {
-  syscall_printf ("shmget (key = %U, size = %d, shmflg = 0x%x)",
+  syscall_printf ("shmget (key = %U, size = %d, shmflg = %y)",
                  key, size, shmflg);
   /* Try allocating memory before calling cygserver. */
   shm_shmid_list *ssh_new_entry = new (shm_shmid_list);
index c99220d35921bb07e7fc74b87650a88ad4422a44..a3f595e1a7f6ae6df005f68f2eb7179b3169718e 100644 (file)
@@ -273,7 +273,7 @@ _pinfo::kill (siginfo_t& si)
       res = -1;
     }
 
-  syscall_printf ("%d = _pinfo::kill (%d), pid %d, process_state %p", res,
+  syscall_printf ("%d = _pinfo::kill (%d), pid %d, process_state %y", res,
                  si.si_signo, this_pid, this_process_state);
   return res;
 }
@@ -516,7 +516,7 @@ extern "C" int
 sigpause (int signal_mask)
 {
   int res = handle_sigsuspend ((sigset_t) signal_mask);
-  syscall_printf ("%R = sigpause(%p)", res, signal_mask);
+  syscall_printf ("%R = sigpause(%y)", res, signal_mask);
   return res;
 }
 
@@ -544,7 +544,7 @@ siginterrupt (int sig, int flag)
       act.sa_flags |= SA_RESTART;
     }
   int res = sigaction_worker (sig, &act, NULL, true);
-  syscall_printf ("%R = siginterrupt(%d, %p)", sig, flag);
+  syscall_printf ("%R = siginterrupt(%d, %y)", sig, flag);
   return res;
 }
 
index e585877b93a55539d21a9cc005422f5105970c88..9deb926def0e39e69f183ca45b215b151133ec4e 100644 (file)
@@ -171,7 +171,7 @@ mychild (int pid)
 /* Handle all subprocess requests
  */
 int __reg2
-proc_subproc (DWORD what, DWORD val)
+proc_subproc (DWORD what, uintptr_t val)
 {
   int rc = 1;
   int potential_match;
@@ -991,7 +991,7 @@ child_info::sync (pid_t pid, HANDLE& hProcess, DWORD howlong)
              hProcess = NULL;
            }
        }
-      sigproc_printf ("pid %u, WFMO returned %d, exit_code %p, res %d", pid, x,
+      sigproc_printf ("pid %u, WFMO returned %d, exit_code %y, res %d", pid, x,
                      exit_code, res);
     }
   return res;
@@ -1002,7 +1002,7 @@ child_info::proc_retry (HANDLE h)
 {
   if (!exit_code)
     return EXITCODE_OK;
-  sigproc_printf ("exit_code %p", exit_code);
+  sigproc_printf ("exit_code %y", exit_code);
   switch (exit_code)
     {
     case STILL_ACTIVE: /* shouldn't happen */
index c4313f05659be2aaba11ad1c01b52b42a5e6fd58..23647a4586450e5b4df96401c4d44729b9a43842 100644 (file)
@@ -68,7 +68,7 @@ void __reg1 sig_clear (int);
 void __reg1 sig_set_pending (int);
 int __stdcall handle_sigsuspend (sigset_t);
 
-int __reg2 proc_subproc (DWORD, DWORD);
+int __reg2 proc_subproc (DWORD, uintptr_t);
 
 class _pinfo;
 void __stdcall proc_terminate ();
index f0ce7e74bb5eb38a17fa985fef1faa05d87ce1c0..75291e713a741ee738ac9e03ce2558992f06db59 100644 (file)
@@ -1,7 +1,7 @@
 /* smallprint.cc: small print routines for WIN32
 
    Copyright 1996, 1998, 2000, 2001, 2002, 2003, 2005, 2006,
-            2007, 2008, 2009, 2012
+            2007, 2008, 2009, 2012, 2013
    Red Hat, Inc.
 
 This file is part of Cygwin.
@@ -20,8 +20,8 @@ details. */
 #define LLMASK (0xffffffffffffffffULL)
 #define LMASK  (0xffffffff)
 
-#define rnarg(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, long), len, pad, LMASK)
-#define rnargLL(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, unsigned long long), len, pad, LLMASK)
+#define rnarg(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, int32_t), len, pad, LMASK)
+#define rnargLL(dst, base, dosign, len, pad) __rn ((dst), (base), (dosign), va_arg (ap, uint64_t), len, pad, LLMASK)
 
 static const char hex_str[] = "0123456789ABCDEF";
 
@@ -92,6 +92,40 @@ __rn (char *dst, int base, int dosign, long long val, int len, int pad, unsigned
   return dst;
 }
 
+/*
+  Meaning of format conversion specifiers.  If 'l' isn't explicitely mentioned,
+  it's ignored!
+
+   c       char
+   C       WCHAR/wchar_t
+   d       signed int, 4 byte
+  ld       signed long, 4 byte on 32 bit, 8 byte on 64 bit
+   D       signed long long, 8 byte
+   E       GetLastError
+   o       octal unsigned int, 4 byte
+  lo       octal unsigned long, 4 byte on 32 bit, 8 byte on 64 bit
+   O       octal unsigned long long, 8 byte
+   p       address
+   P       process name
+   R       return value, 4 byte.
+  lR       return value, 4 byte on 32 bit, 8 byte on 64 bit.
+   s       char *
+  ls       char * w/ non-ASCII tweaking
+   S       PUNICODE_STRING
+  lS       PUNICODE_STRING w/ non-ASCII tweaking
+   u       unsigned int, 4 byte
+  lu       unsigned long, 4 byte on 32 bit, 8 byte on 64 bit
+   U       unsigned long long, 8 byte
+   W       PWCHAR/wchar_t *
+  lW       PWCHAR/wchar_t * w/ non-ASCII tweaking
+   x       hex unsigned int, 4 byte
+  lx       hex unsigned long, 4 byte on 32 bit, 8 byte on 64 bit
+   X       hex unsigned long long, 8 byte
+   y       0x hex unsigned int, 4 byte
+  ly       0x hex unsigned long, 4 byte on 32 bit, 8 byte on 64 bit
+   Y       0x hex unsigned long long, 8 byte
+*/
+
 int
 __small_vsprintf (char *dst, const char *fmt, va_list ap)
 {
@@ -100,10 +134,11 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
   const char *s;
   PWCHAR w;
   UNICODE_STRING uw, *us;
+  int base = 0;
 
   DWORD err = GetLastError ();
 
-  long Rval = 0;
+  intptr_t Rval = 0;
   while (*fmt)
     {
       int i, n = 0x7fff;
@@ -171,35 +206,82 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
                  dst = __rn (dst + sizeof ("Win32 error"), 10, 0, err, len, pad, LMASK);
                  break;
                case 'R':
-               case 'd':
                  {
-                   long val = va_arg (ap, long);
-                   dst = __rn (dst, 10, addsign, val, len, pad, LMASK);
-                   if (c == 'R')
-                     Rval = val;
+#ifdef __x86_64__
+                   if (l_opt)
+                     Rval = va_arg (ap, int64_t);
+                   else
+#endif
+                     Rval = va_arg (ap, int32_t);
+                   dst = __rn (dst, 10, addsign, Rval, len, pad, LMASK);
                  }
                  break;
-               case 'D':
-                 dst = rnargLL (dst, 10, addsign, len, pad);
-                 break;
+               case 'd':
+                 base = 10;
+#ifdef __x86_64__
+                 if (l_opt)
+                   goto gen_decimalLL;
+#endif
+                 goto gen_decimal;
                case 'u':
-                 dst = rnarg (dst, 10, 0, len, pad);
-                 break;
-               case 'U':
-                 dst = rnargLL (dst, 10, 0, len, pad);
-                 break;
+                 base = 10;
+                 addsign = 0;
+#ifdef __x86_64__
+                 if (l_opt)
+                   goto gen_decimalLL;
+#endif
+                 goto gen_decimal;
                case 'o':
-                 dst = rnarg (dst, 8, 0, len, pad);
-                 break;
-               case 'p':
+                 base = 8;
+                 addsign = 0;
+#ifdef __x86_64__
+                 if (l_opt)
+                   goto gen_decimalLL;
+#endif
+                 goto gen_decimal;
+               case 'y':
                  *dst++ = '0';
                  *dst++ = 'x';
-                 /* fall through */
+                 /*FALLTHRU*/
                case 'x':
-                 dst = rnarg (dst, 16, 0, len, pad);
+                 base = 16;
+                 addsign = 0;
+#ifdef __x86_64__
+                 if (l_opt)
+                   goto gen_decimalLL;
+#endif
+gen_decimal:
+                 dst = rnarg (dst, base, addsign, len, pad);
                  break;
+               case 'D':
+                 base = 10;
+                 goto gen_decimalLL;
+               case 'U':
+                 base = 10;
+                 addsign = 0;
+                 goto gen_decimalLL;
+               case 'O':
+                 base = 8;
+                 addsign = 0;
+                 goto gen_decimalLL;
+               case 'Y':
+                 *dst++ = '0';
+                 *dst++ = 'x';
+                 /*FALLTHRU*/
                case 'X':
+                 base = 16;
+                 addsign = 0;
+gen_decimalLL:
+                 dst = rnargLL (dst, base, addsign, len, pad);
+                 break;
+               case 'p':
+                 *dst++ = '0';
+                 *dst++ = 'x';
+#ifdef __x86_64__
                  dst = rnargLL (dst, 16, 0, len, pad);
+#else
+                 dst = rnarg (dst, 16, 0, len, pad);
+#endif
                  break;
                case 'P':
                  if (!GetModuleFileName (NULL, tmp, NT_MAX_PATH))
@@ -273,8 +355,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
     }
   if (Rval < 0)
     {
-      strcpy (dst, ", errno ");
-      dst += strlen (", errno ");
+      dst = stpcpy (dst, ", errno ");
       dst = __rn (dst, 10, false, get_errno (), 0, 0, LMASK);
     }
   *dst = 0;
@@ -395,12 +476,15 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
   const char *s;
   PWCHAR w;
   UNICODE_STRING uw, *us;
+  int base = 0;
 
   DWORD err = GetLastError ();
 
+  intptr_t Rval = 0;
   while (*fmt)
     {
       unsigned int n = 0x7fff;
+      bool l_opt = false;
       if (*fmt != L'%')
        *dst++ = *fmt++;
       else
@@ -435,6 +519,7 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
                  len = len * 10 + (c - L'0');
                  continue;
                case L'l':
+                 l_opt = true;
                  continue;
                case L'c':
                case L'C':
@@ -444,30 +529,83 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
                  wcscpy (dst, L"Win32 error ");
                  dst = __wrn (dst + sizeof ("Win32 error"), 10, 0, err, len, pad, LMASK);
                  break;
-               case L'd':
-                 dst = wrnarg (dst, 10, addsign, len, pad);
-                 break;
-               case L'D':
-                 dst = wrnargLL (dst, 10, addsign, len, pad);
-                 break;
-               case L'u':
-                 dst = wrnarg (dst, 10, 0, len, pad);
+               case 'R':
+                 {
+#ifdef __x86_64__
+                   if (l_opt)
+                     Rval = va_arg (ap, int64_t);
+                   else
+#endif
+                     Rval = va_arg (ap, int32_t);
+                   dst = __wrn (dst, 10, addsign, Rval, len, pad, LMASK);
+                 }
                  break;
-               case L'U':
-                 dst = wrnargLL (dst, 10, 0, len, pad);
+               case L'd':
+                 base = 10;
+#ifdef __x86_64__
+                 if (l_opt)
+                   goto gen_decimalLL;
+#endif
+                 goto gen_decimal;
+               case 'u':
+                 base = 10;
+                 addsign = 0;
+#ifdef __x86_64__
+                 if (l_opt)
+                   goto gen_decimalLL;
+#endif
+                 goto gen_decimal;
+               case 'o':
+                 base = 8;
+                 addsign = 0;
+#ifdef __x86_64__
+                 if (l_opt)
+                   goto gen_decimalLL;
+#endif
+                 goto gen_decimal;
+               case 'y':
+                 *dst++ = '0';
+                 *dst++ = 'x';
+                 /*FALLTHRU*/
+               case 'x':
+                 base = 16;
+                 addsign = 0;
+#ifdef __x86_64__
+                 if (l_opt)
+                   goto gen_decimalLL;
+#endif
+gen_decimal:
+                 dst = wrnarg (dst, base, addsign, len, pad);
                  break;
-               case L'o':
-                 dst = wrnarg (dst, 8, 0, len, pad);
+               case 'D':
+                 base = 10;
+                 goto gen_decimalLL;
+               case 'U':
+                 base = 10;
+                 addsign = 0;
+                 goto gen_decimalLL;
+               case 'O':
+                 base = 8;
+                 addsign = 0;
+                 goto gen_decimalLL;
+               case 'Y':
+                 *dst++ = '0';
+                 *dst++ = 'x';
+                 /*FALLTHRU*/
+               case 'X':
+                 base = 16;
+                 addsign = 0;
+gen_decimalLL:
+                 dst = wrnargLL (dst, base, addsign, len, pad);
                  break;
                case L'p':
                  *dst++ = L'0';
                  *dst++ = L'x';
-                 /* fall through */
-               case L'x':
-                 dst = wrnarg (dst, 16, 0, len, pad);
-                 break;
-               case L'X':
+#ifdef __x86_64__
                  dst = wrnargLL (dst, 16, 0, len, pad);
+#else
+                 dst = wrnarg (dst, 16, 0, len, pad);
+#endif
                  break;
                case L'P':
                  if (!GetModuleFileNameW (NULL, tmp, NT_MAX_PATH))
@@ -511,6 +649,11 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
            }
        }
     }
+  if (Rval < 0)     
+    {
+      dst = wcpcpy (dst, L", errno ");
+      dst = __wrn (dst, 10, false, get_errno (), 0, 0, LMASK);
+    }
   *dst = L'\0';
   SetLastError (err);
   return dst - orig;
index 4ed3221dd16882c9d6c03a9ece71bb641e5aa642..1225a37659c1b7307a83fdd6b808114ff13e5e78 100644 (file)
@@ -34,7 +34,7 @@ details. */
 #include "winf.h"
 #include "ntdll.h"
 
-static suffix_info NO_COPY exe_suffixes[] =
+static const suffix_info exe_suffixes[] =
 {
   suffix_info ("", 1),
   suffix_info (".exe", 1),
@@ -42,20 +42,6 @@ static suffix_info NO_COPY exe_suffixes[] =
   suffix_info (NULL)
 };
 
-#if 0
-/* CV, 2009-11-05: Used to be used when searching for DLLs in calls to
-   dlopen().  However, dlopen() on other platforms never adds a suffix by
-   its own.  Therefore we use stat_suffixes now, which only adds a .exe
-   suffix for symmetry. */
-static suffix_info dll_suffixes[] =
-{
-  suffix_info (".dll"),
-  suffix_info ("", 1),
-  suffix_info (".exe", 1),
-  suffix_info (NULL)
-};
-#endif
-
 /* Add .exe to PROG if not already present and see if that exists.
    If not, return PROG (converted from posix to win32 rules if necessary).
    The result is always BUF.
@@ -465,28 +451,18 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv,
         of a compatibility job, which allows child processes to break away
         from the job.  This helps to avoid this issue.
 
+        First we call IsProcessInJob.  It fetches the information whether or
+        not we're part of a job 20 times faster than QueryInformationJobObject.
+
         (*) Note that this is not mintty's fault.  It has just been observed
         with mintty in the first place.  See the archives for more info:
         http://cygwin.com/ml/cygwin-developers/2012-02/msg00018.html */
 
       JOBOBJECT_BASIC_LIMIT_INFORMATION jobinfo;
+      BOOL is_in_job;
 
-      /* Calling QueryInformationJobObject costs time.  Starting with
-        Windows XP there's a function IsProcessInJob, which fetches the
-        information whether or not we're part of a job 20 times faster than
-        the call to QueryInformationJobObject.  But we're still
-        supporting Windows 2000, so we can't just link to that function.
-        On the other hand, loading the function pointer at runtime is a
-        time comsuming operation, too.  So, what we do here is to emulate
-        the IsProcessInJob function when called for the own process and with
-        a NULL job handle.  In this case it just returns the value of the
-        lowest bit from PEB->EnvironmentUpdateCount (observed with WinDbg).
-        The name of this PEB member is the same in all (inofficial)
-        documentations of the PEB.  Apparently it's a bit misleading.
-        As a result, we only call QueryInformationJobObject if we're on
-        Vista or later *and* if the PEB indicates we're running in a job.
-        Tested on Vista/32, Vista/64, W7/32, W7/64, W8/64. */
-      if ((NtCurrentTeb ()->Peb->EnvironmentUpdateCount & 1) != 0
+      if (IsProcessInJob (GetCurrentProcess (), NULL, &is_in_job)
+         && is_in_job
          && QueryInformationJobObject (NULL, JobObjectBasicLimitInformation,
                                     &jobinfo, sizeof jobinfo, NULL)
          && (jobinfo.LimitFlags & (JOB_OBJECT_LIMIT_BREAKAWAY_OK
@@ -935,7 +911,7 @@ spawnve (int mode, const char *path, const char *const *argv,
     vf = NULL;
 #endif
 
-  syscall_printf ("spawnve (%s, %s, %x)", path, argv[0], envp);
+  syscall_printf ("spawnve (%s, %s, %p)", path, argv[0], envp);
 
   if (!envp)
     envp = empty_env;
@@ -1135,7 +1111,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext,
          NtClose (h);
          goto err;
        }
-      if (size.QuadPart > wincap.allocation_granularity ())
+      if (size.QuadPart > (LONGLONG) wincap.allocation_granularity ())
        size.LowPart = wincap.allocation_granularity ();
 
       HANDLE hm = CreateFileMapping (h, &sec_none_nih, PAGE_READONLY,
@@ -1176,8 +1152,8 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext,
            unsigned off = (unsigned char) buf[0x18] | (((unsigned char) buf[0x19]) << 8);
            win16_exe = off < sizeof (IMAGE_DOS_HEADER);
            if (!win16_exe)
-             real_path.set_cygexec (!!hook_or_detect_cygwin (buf, NULL,
-                                                             subsys, hm));
+             real_path.set_cygexec (hook_or_detect_cygwin (buf, NULL,
+                                                           subsys, hm));
            else
              real_path.set_cygexec (false);
            UnmapViewOfFile (buf);
index 7bac7eac4ca26f0c71a7b45350f70d67bfe545c7..b9009604027cde65626c4fbafe9ac7faffe9eb95 100755 (executable)
@@ -11,16 +11,17 @@ my $static;
 my $inverse;
 my @exclude;
 
-my ($ar, $as, $nm, $objcopy);
+my ($cpu, $ar, $as, $nm, $objcopy);
 GetOptions('exclude=s'=>\@exclude, 'static!'=>\$static, 'v!'=>\$inverse,
-          'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy);
+          'cpu=s'=>\$cpu, 'ar=s'=>\$ar, 'as=s'=>\$as,'nm=s'=>\$nm, 'objcopy=s'=>\$objcopy);
 
 $_ = File::Spec->rel2abs($_) for @ARGV;
 
 my $libdll = shift;
 my $lib =  pop;
+my $uscore = ($cpu eq 'x86_64' ? undef : '_');
 (my $iname = basename $lib) =~ s/\.a$//o;
-$iname = '_' . $iname . '_dll_iname';
+$iname = $uscore . $iname . '_dll_iname';
 
 open my $nm_fd, '-|', $nm, '-Apg', '--defined-only', @ARGV, $libdll or
   die "$0: execution of $nm for object files failed - $!\n";
@@ -34,7 +35,7 @@ $exclude_regex = qr/$exclude_regex/;
 my $dllname;
 while (<$nm_fd>) {
     study;
-    if (/ I _(.*)_dll_iname/o) {
+    if (/ I _?(.*)_dll_iname/o) {
        $dllname = $1;
     } else {
        my ($file, $member, $symbol) = m%^([^:]*):([^:]*(?=:))?.* T (.*)%o;
index 98d3c4cb12aef784d64c5fe85f4028e178e9d1de..c77882007bbd9b700ce7038570d2a459bf0f82de 100644 (file)
@@ -37,7 +37,7 @@ strace::activate (bool isfork)
   if (!_active && being_debugged ())
     {
       char buf[30];
-      __small_sprintf (buf, "cYg%8x %x %d", _STRACE_INTERFACE_ACTIVATE_ADDR, &_active, isfork);
+      __small_sprintf (buf, "cYg%8x %lx %d", _STRACE_INTERFACE_ACTIVATE_ADDR, &_active, isfork);
       OutputDebugString (buf);
       if (_active)
        {
@@ -223,7 +223,7 @@ strace::write (unsigned category, const char *buf, int count)
 }
 
 void
-strace::write_childpid (DWORD pid)
+strace::write_childpid (pid_t pid)
 {
   char buf[30];
 
index 8afa8db7a8128811269b3e6095009305abfd597d..987e13549e6e277b1f9a375d7f36d828b05340f2 100644 (file)
@@ -1,6 +1,6 @@
 /* strsig.cc
 
-   Copyright 2004, 2007, 2008, 2010, 2011 Red Hat, Inc.
+   Copyright 2004, 2007, 2008, 2010, 2011, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -20,7 +20,7 @@ struct sigdesc
   const char *str;
 };
 
-#define __signals \
+#define __signals_common \
   _s(SIGHUP, "Hangup"),                                /*  1 */ \
   _s(SIGINT, "Interrupt"),                     /*  2 */ \
   _s(SIGQUIT, "Quit"),                         /*  3 */ \
@@ -54,13 +54,54 @@ struct sigdesc
   _s2(SIGPWR, "Power failure",                 /* 29 */ \
       SIGLOST, "Resource lost"),                        \
   _s(SIGUSR1, "User defined signal 1"),                /* 30 */ \
-  _s(SIGUSR2, "User defined signal 2"),                /* 31 */ \
+  _s(SIGUSR2, "User defined signal 2"),                /* 31 */
+
+#ifdef __x86_64__
+# define __signals \
+  __signals_common \
+  _s(SIGRTMIN, "Real-time signal 0"),          /* 32 */ \
+  _s(SIGRTMIN + 1, "Real-time signal 1"),      /* 33 */ \
+  _s(SIGRTMIN + 2, "Real-time signal 2"),      /* 34 */ \
+  _s(SIGRTMIN + 3, "Real-time signal 3"),      /* 35 */ \
+  _s(SIGRTMIN + 4, "Real-time signal 4"),      /* 36 */ \
+  _s(SIGRTMIN + 5, "Real-time signal 5"),      /* 37 */ \
+  _s(SIGRTMIN + 6, "Real-time signal 6"),      /* 38 */ \
+  _s(SIGRTMIN + 7, "Real-time signal 7"),      /* 39 */ \
+  _s(SIGRTMIN + 8, "Real-time signal 8"),      /* 40 */ \
+  _s(SIGRTMIN + 9, "Real-time signal 9"),      /* 41 */ \
+  _s(SIGRTMIN + 10, "Real-time signal 10"),    /* 42 */ \
+  _s(SIGRTMIN + 11, "Real-time signal 11"),    /* 43 */ \
+  _s(SIGRTMIN + 12, "Real-time signal 12"),    /* 44 */ \
+  _s(SIGRTMIN + 13, "Real-time signal 13"),    /* 45 */ \
+  _s(SIGRTMIN + 14, "Real-time signal 14"),    /* 46 */ \
+  _s(SIGRTMIN + 15, "Real-time signal 15"),    /* 47 */ \
+  _s(SIGRTMIN + 16, "Real-time signal 16"),    /* 48 */ \
+  _s(SIGRTMIN + 17, "Real-time signal 17"),    /* 49 */ \
+  _s(SIGRTMIN + 18, "Real-time signal 18"),    /* 50 */ \
+  _s(SIGRTMIN + 19, "Real-time signal 19"),    /* 51 */ \
+  _s(SIGRTMIN + 20, "Real-time signal 20"),    /* 52 */ \
+  _s(SIGRTMIN + 21, "Real-time signal 21"),    /* 53 */ \
+  _s(SIGRTMIN + 22, "Real-time signal 22"),    /* 54 */ \
+  _s(SIGRTMIN + 23, "Real-time signal 23"),    /* 55 */ \
+  _s(SIGRTMIN + 24, "Real-time signal 24"),    /* 56 */ \
+  _s(SIGRTMIN + 25, "Real-time signal 25"),    /* 57 */ \
+  _s(SIGRTMIN + 26, "Real-time signal 26"),    /* 58 */ \
+  _s(SIGRTMIN + 27, "Real-time signal 27"),    /* 59 */ \
+  _s(SIGRTMIN + 28, "Real-time signal 28"),    /* 60 */ \
+  _s(SIGRTMIN + 29, "Real-time signal 29"),    /* 61 */ \
+  _s(SIGRTMIN + 30, "Real-time signal 30"),    /* 62 */ \
+  _s(SIGRTMIN + 31, "Real-time signal 31"),    /* 63 */ \
+  _s(SIGRTMAX, "Real-time signal 32")          /* 64 */
+#else
+# define __signals \
+  __signals_common \
   _s2(SIGRTMIN, "Real-time signal 0",          /* 32 */ \
       SIGRTMAX, "Real-time signal 0")
+#endif
 
 #define _s(n, s) #n
 #define _s2(n, s, n1, s1) #n
-const char *sys_sigabbrev[] NO_COPY_INIT =
+const char *sys_sigabbrev[] =
 {
   NULL,
   __signals
@@ -70,7 +111,7 @@ const char *sys_sigabbrev[] NO_COPY_INIT =
 #undef _s2
 #define _s(n, s) s
 #define _s2(n, s, n1, s1) s
-const char *sys_siglist[] NO_COPY_INIT =
+const char *sys_siglist[] =
 {
   NULL,
   __signals
@@ -128,7 +169,7 @@ psiginfo (const siginfo_t *info, const char *s)
            fprintf (stderr, " (%d [%p])", info->si_code, info->si_addr);
            break;
          case SIGCHLD:
-           fprintf (stderr, " (%d %d %d %ld)", info->si_code, info->si_pid,
+           fprintf (stderr, " (%d %d %d %u)", info->si_code, info->si_pid,
                     info->si_status, info->si_uid);
            break;
 /* FIXME: implement si_band
@@ -137,7 +178,7 @@ psiginfo (const siginfo_t *info, const char *s)
            break;
 */
          default:
-           fprintf (stderr, " (%d %d %ld)", info->si_code, info->si_pid, info->si_uid);
+           fprintf (stderr, " (%d %d %u)", info->si_code, info->si_pid, info->si_uid);
        }
     }
 
index d8b3d8f54a4b4474246bd5195067a48890070760..821c214f7f09df4eee8eeb9df1fbc0ad09bb64b7 100644 (file)
@@ -33,7 +33,8 @@ muto::grab ()
 muto *
 muto::init (const char *s)
 {
-  char *already_exists = (char *) InterlockedExchangePointer (&name, s);
+  char *already_exists = (char *) InterlockedExchangePointer ((PVOID *) &name,
+                                                             (PVOID) s);
   if (already_exists)
     while (!bruteforce)
       yield ();
index 9d702b6afb7da35db1e61a16ee4371646e38aa28..ebfccab45a2abd2d5f829fd0477e1daf5d8ed512 100644 (file)
@@ -16,7 +16,7 @@ details. */
 class muto
 {
 public:
-  const char *name;
+  char *name;
 private:
   LONG sync;   /* Used to serialize access to this class. */
   LONG waiters;        /* Number of threads waiting for lock. */
index bc3ba0f8918fa14822772e3eec941765a3a59705..48b06ad9ead97f22541649400367ce6a4860cec7 100644 (file)
@@ -11,7 +11,7 @@ details. */
 
 #define fstat __FOOfstat__
 #define lstat __FOOlstat__
-#define stat __FOOstat__
+//#define stat __FOOstat__
 #define _close __FOO_close__
 #define _lseek __FOO_lseek__
 #define _open __FOO_open__
@@ -44,7 +44,7 @@ details. */
 
 #undef fstat
 #undef lstat
-#undef stat
+//#undef stat
 #undef pread
 #undef pwrite
 
@@ -177,7 +177,7 @@ dup3 (int oldfd, int newfd, int flags)
   else
     res = dup_finish (oldfd, newfd, flags);
 
-  syscall_printf ("%R = dup3(%d, %d, %p)", res, oldfd, newfd, flags);
+  syscall_printf ("%R = dup3(%d, %d, %y)", res, oldfd, newfd, flags);
   return res;
 }
 
@@ -194,7 +194,7 @@ start_transaction (HANDLE &old_trans, HANDLE &trans)
     }
   else
     {
-      debug_printf ("NtCreateTransaction failed, %p", status);
+      debug_printf ("NtCreateTransaction failed, %y", status);
       old_trans = trans = NULL;
     }
 }
@@ -258,7 +258,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
   if (!NT_SUCCESS (status))
     {
       debug_printf ("NtQueryInformationFile (%S, FileNameInformation) "
-                   "failed, status = %p", pc.get_nt_native_path (), status);
+                   "failed, status = %y", pc.get_nt_native_path (), status);
       goto out;
     }
   /* The filename could change, the parent dir not.  So we split both paths
@@ -302,7 +302,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                           FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("NtOpenFile (%S) failed, status = %p", &root, status);
+         debug_printf ("NtOpenFile (%S) failed, status = %y", &root, status);
          goto out;
        }
 
@@ -321,8 +321,6 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
          /* Unhide trailing backslash. */
          recycler.Length += sizeof (WCHAR);
          RtlInitEmptyUnicodeString (&sid, sidbuf, sizeof sidbuf);
-         /* In contrast to what MSDN claims, this function is already available
-            since NT4. */
          RtlConvertSidToUnicodeString (&sid, cygheap->user.sid (), FALSE);
          RtlAppendUnicodeStringToString (&recycler, &sid);
          recycler_user_len = recycler.Length;
@@ -349,7 +347,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
   if (!NT_SUCCESS (status))
     {
       debug_printf ("NtQueryInformationFile (%S, FileInternalInformation) "
-                   "failed, status = %p", pc.get_nt_native_path (), status);
+                   "failed, status = %y", pc.get_nt_native_path (), status);
       goto out;
     }
   RtlInt64ToHexUnicodeString (pfii->FileId.QuadPart, &recycler, TRUE);
@@ -374,7 +372,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                           FILE_SHARE_VALID_FLAGS, FILE_OPEN_FOR_BACKUP_INTENT);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("NtOpenFile (%S) failed, status = %p",
+         debug_printf ("NtOpenFile (%S) failed, status = %y",
                        &recycler, status);
          goto out;
        }
@@ -399,7 +397,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                             FILE_DIRECTORY_FILE, NULL, 0);
       if (!NT_SUCCESS (status))
        {
-         debug_printf ("NtCreateFile (%S) failed, status = %p",
+         debug_printf ("NtCreateFile (%S) failed, status = %y",
                        &recycler, status);
          goto out;
        }
@@ -419,7 +417,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                                 FILE_DIRECTORY_FILE, NULL, 0);
          if (!NT_SUCCESS (status))
            {
-             debug_printf ("NtCreateFile (%S) failed, status = %p",
+             debug_printf ("NtCreateFile (%S) failed, status = %y",
                            &recycler, status);
              goto out;
            }
@@ -438,14 +436,14 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                                 FILE_SYNCHRONOUS_IO_NONALERT
                                 | FILE_NON_DIRECTORY_FILE, NULL, 0);
          if (!NT_SUCCESS (status))
-           debug_printf ("NtCreateFile (%S) failed, status = %p",
+           debug_printf ("NtCreateFile (%S) failed, status = %y",
                          &recycler, status);
          else
            {
              status = NtWriteFile (tmp_fh, NULL, NULL, NULL, &io, desktop_ini,
                                    sizeof desktop_ini - 1, NULL, NULL);
              if (!NT_SUCCESS (status))
-               debug_printf ("NtWriteFile (%S) failed, status = %p",
+               debug_printf ("NtWriteFile (%S) failed, status = %y",
                              &fname, status);
              else if (wincap.has_recycle_dot_bin ())
                {
@@ -453,7 +451,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                                        desktop_ini_ext,
                                        sizeof desktop_ini_ext - 1, NULL, NULL);
                  if (!NT_SUCCESS (status))
-                   debug_printf ("NtWriteFile (%S) failed, status = %p",
+                   debug_printf ("NtWriteFile (%S) failed, status = %y",
                                  &fname, status);
                }
              NtClose (tmp_fh);
@@ -468,14 +466,14 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                                     FILE_SYNCHRONOUS_IO_NONALERT
                                     | FILE_NON_DIRECTORY_FILE, NULL, 0);
                if (!NT_SUCCESS (status))
-                 debug_printf ("NtCreateFile (%S) failed, status = %p",
+                 debug_printf ("NtCreateFile (%S) failed, status = %y",
                                &recycler, status);
                else
                {
                  status = NtWriteFile (tmp_fh, NULL, NULL, NULL, &io, info2,
                                        sizeof info2, NULL, NULL);
                  if (!NT_SUCCESS (status))
-                   debug_printf ("NtWriteFile (%S) failed, status = %p",
+                   debug_printf ("NtWriteFile (%S) failed, status = %y",
                                  &fname, status);
                  NtClose (tmp_fh);
                }
@@ -488,7 +486,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
     }
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("Move %S to %S failed, status = %p",
+      debug_printf ("Move %S to %S failed, status = %y",
                    pc.get_nt_native_path (), &recycler, status);
       goto out;
     }
@@ -546,7 +544,7 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                         NULL, 0);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("Creating file for overwriting failed, status = %p",
+      debug_printf ("Creating file for overwriting failed, status = %y",
                    status);
       goto out;
     }
@@ -554,12 +552,12 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access)
                                 FileRenameInformation);
   NtClose (tmp_fh);
   if (!NT_SUCCESS (status))
-    debug_printf ("Overwriting with another file failed, status = %p", status);
+    debug_printf ("Overwriting with another file failed, status = %y", status);
 
 out:
   if (rootdir)
     NtClose (rootdir);
-  debug_printf ("%S, return status %d", pc.get_nt_native_path (), bin_stat);
+  debug_printf ("%S, return bin_status %d", pc.get_nt_native_path (), bin_stat);
   return bin_stat;
 }
 
@@ -576,7 +574,7 @@ check_dir_not_empty (HANDLE dir, path_conv &pc)
                                          FALSE, NULL, TRUE);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("Checking if directory %S is empty failed, status = %p",
+      debug_printf ("Checking if directory %S is empty failed, status = %y",
                    pc.get_nt_native_path (), status);
       return status;
     }
@@ -621,7 +619,7 @@ check_dir_not_empty (HANDLE dir, path_conv &pc)
                  && status != STATUS_OBJECT_PATH_NOT_FOUND)
                {
                  debug_printf ("Directory %S not empty, found file <%S>, "
-                                "query status = %p",
+                                "query status = %y",
                                pc.get_nt_native_path (), &fname, status);
                  return STATUS_DIRECTORY_NOT_EMPTY;
                }
@@ -685,12 +683,12 @@ unlink_nt (path_conv &pc)
                                                  pc.file_attributes ()
                                                  & ~FILE_ATTRIBUTE_READONLY);
          if (!NT_SUCCESS (status2))
-           debug_printf ("Removing R/O on %S failed, status = %p",
+           debug_printf ("Removing R/O on %S failed, status = %y",
                          pc.get_nt_native_path (), status2);
          pc.init_reopen_attr (&attr, fh_ro);
        }
       else
-       debug_printf ("Opening %S for removing R/O failed, status = %p",
+       debug_printf ("Opening %S for removing R/O failed, status = %y",
                      pc.get_nt_native_path (), status);
       if (pc.is_lnk_symlink ())
        {
@@ -782,7 +780,7 @@ unlink_nt (path_conv &pc)
          status = STATUS_SUCCESS;
          goto out;
        }
-      debug_printf ("Opening %S for delete failed, status = %p",
+      debug_printf ("Opening %S for delete failed, status = %y",
                    pc.get_nt_native_path (), status);
       goto out;
     }
@@ -807,7 +805,7 @@ try_again:
                                 FileDispositionInformation);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("Setting delete disposition on %S failed, status = %p",
+      debug_printf ("Setting delete disposition on %S failed, status = %y",
                    pc.get_nt_native_path (), status);
       if (status == STATUS_DIRECTORY_NOT_EMPTY)
        {
@@ -879,7 +877,7 @@ try_again:
            {
              fh = NULL;
              debug_printf ("Opening dir %S for check_dir_not_empty failed, "
-                           "status = %p", pc.get_nt_native_path (), status2);
+                           "status = %y", pc.get_nt_native_path (), status2);
            }
          else /* Directory disappeared between NtClose and NtOpenFile. */
            status = STATUS_SUCCESS;
@@ -912,7 +910,7 @@ try_again:
                               flags | FILE_DELETE_ON_CLOSE);
          if (!NT_SUCCESS (status))
            {
-             debug_printf ("Setting delete-on-close on %S failed, status = %p",
+             debug_printf ("Setting delete-on-close on %S failed, status = %y",
                            pc.get_nt_native_path (), status);
              /* This is really the last chance.  If it hasn't been moved
                 to the bin already, try it now.  If moving to the bin
@@ -961,7 +959,7 @@ out:
       && (pc.fs_flags () & FILE_SUPPORTS_TRANSACTIONS))
     stop_transaction (status, old_trans, trans);
 
-  syscall_printf ("%S, return status = %p", pc.get_nt_native_path (), status);
+  syscall_printf ("%S, return status = %y", pc.get_nt_native_path (), status);
   return status;
 }
 
@@ -969,7 +967,7 @@ extern "C" int
 unlink (const char *ourname)
 {
   int res = -1;
-  DWORD devn;
+  dev_t devn;
   NTSTATUS status;
 
   path_conv win32_name (ourname, PC_SYM_NOFOLLOW, stat_suffixes);
@@ -980,7 +978,7 @@ unlink (const char *ourname)
       goto done;
     }
 
-  devn = win32_name.get_devn ();
+  devn = win32_name.get_device ();
   if (isproc_dev (devn))
     {
       set_errno (EROFS);
@@ -1149,7 +1147,7 @@ read (int fd, void *ptr, size_t len)
   cfd->read (ptr, res = len);
 
 done:
-  syscall_printf ("%R = read(%d, %p, %d)", res, fd, ptr, len);
+  syscall_printf ("%lR = read(%d, %p, %d)", res, fd, ptr, len);
   MALLOC_CHECK;
   return (ssize_t) res;
 }
@@ -1191,13 +1189,13 @@ readv (int fd, const struct iovec *const iov, const int iovcnt)
   res = cfd->readv (iov, iovcnt, tot);
 
 done:
-  syscall_printf ("%R = readv(%d, %p, %d)", res, fd, iov, iovcnt);
+  syscall_printf ("%lR = readv(%d, %p, %d)", res, fd, iov, iovcnt);
   MALLOC_CHECK;
   return res;
 }
 
 extern "C" ssize_t
-pread (int fd, void *ptr, size_t len, _off64_t off)
+pread (int fd, void *ptr, size_t len, off_t off)
 {
   pthread_testcancel ();
 
@@ -1208,7 +1206,7 @@ pread (int fd, void *ptr, size_t len, _off64_t off)
   else
     res = cfd->pread (ptr, len, off);
 
-  syscall_printf ("%R = pread(%d, %p, %d, %d)", res, fd, ptr, len, off);
+  syscall_printf ("%lR = pread(%d, %p, %d, %d)", res, fd, ptr, len, off);
   return res;
 }
 
@@ -1221,7 +1219,7 @@ write (int fd, const void *ptr, size_t len)
   if (efault.faulted (EFAULT))
     return -1;
 
-  int res = -1;
+  ssize_t res = -1;
 
   cygheap_fdget cfd (fd);
   if (cfd < 0)
@@ -1242,7 +1240,7 @@ write (int fd, const void *ptr, size_t len)
   res = cfd->write (ptr, len);
 
 done:
-  syscall_printf ("%R = write(%d, %p, %d)", res, fd, ptr, len);
+  syscall_printf ("%lR = write(%d, %p, %d)", res, fd, ptr, len);
 
   MALLOC_CHECK;
   return res;
@@ -1259,7 +1257,7 @@ writev (const int fd, const struct iovec *const iov, const int iovcnt)
   if (efault.faulted (EFAULT))
     return -1;
 
-  int res = -1;
+  ssize_t res = -1;
   const ssize_t tot = check_iovec_for_write (iov, iovcnt);
 
   cygheap_fdget cfd (fd);
@@ -1288,16 +1286,16 @@ writev (const int fd, const struct iovec *const iov, const int iovcnt)
 
 done:
   if (fd == 1 || fd == 2)
-    paranoid_printf ("%R = writev(%d, %p, %d)", res, fd, iov, iovcnt);
+    paranoid_printf ("%lR = writev(%d, %p, %d)", res, fd, iov, iovcnt);
   else
-    syscall_printf ("%R = writev(%d, %p, %d)", res, fd, iov, iovcnt);
+    syscall_printf ("%lR = writev(%d, %p, %d)", res, fd, iov, iovcnt);
 
   MALLOC_CHECK;
   return res;
 }
 
 extern "C" ssize_t
-pwrite (int fd, void *ptr, size_t len, _off64_t off)
+pwrite (int fd, void *ptr, size_t len, off_t off)
 {
   pthread_testcancel ();
 
@@ -1308,7 +1306,7 @@ pwrite (int fd, void *ptr, size_t len, _off64_t off)
   else
     res = cfd->pwrite (ptr, len, off);
 
-  syscall_printf ("%R = pwrite(%d, %p, %d, %d)", res, fd, ptr, len, off);
+  syscall_printf ("%lR = pwrite(%d, %p, %d, %d)", res, fd, ptr, len, off);
   return res;
 }
 
@@ -1322,7 +1320,7 @@ open (const char *unix_path, int flags, ...)
   va_list ap;
   mode_t mode = 0;
 
-  syscall_printf ("open(%s, %p)", unix_path, flags);
+  syscall_printf ("open(%s, %y)", unix_path, flags);
   pthread_testcancel ();
   myfault efault;
   if (efault.faulted (EFAULT))
@@ -1390,17 +1388,17 @@ open (const char *unix_path, int flags, ...)
        }
     }
 
-  syscall_printf ("%R = open(%s, %p)", res, unix_path, flags);
+  syscall_printf ("%R = open(%s, %y)", res, unix_path, flags);
   return res;
 }
 
 EXPORT_ALIAS (open, _open )
 EXPORT_ALIAS (open, _open64 )
 
-extern "C" _off64_t
-lseek64 (int fd, _off64_t pos, int dir)
+extern "C" off_t
+lseek64 (int fd, off_t pos, int dir)
 {
-  _off64_t res;
+  off_t res;
 
   if (dir != SEEK_SET && dir != SEEK_CUR && dir != SEEK_END)
     {
@@ -1415,7 +1413,7 @@ lseek64 (int fd, _off64_t pos, int dir)
       else
        res = -1;
     }
-  /* Can't use %R here since res is 8 bytes */
+  /* Can't use %R/%lR here since res is always 8 bytes */
   syscall_printf (res == -1 ? "%D = lseek(%d, %D, %d), errno %d"
                            : "%D = lseek(%d, %D, %d)",
                  res, fd, pos, dir, get_errno ());
@@ -1425,13 +1423,18 @@ lseek64 (int fd, _off64_t pos, int dir)
 
 EXPORT_ALIAS (lseek64, _lseek64)
 
+#ifdef __x86_64__
+EXPORT_ALIAS (lseek64, lseek)
+EXPORT_ALIAS (lseek64, _lseek)
+#else
 extern "C" _off_t
 lseek (int fd, _off_t pos, int dir)
 {
-  return lseek64 (fd, (_off64_t) pos, dir);
+  return lseek64 (fd, (off_t) pos, dir);
 }
-
 EXPORT_ALIAS (lseek, _lseek)
+#endif
+
 
 extern "C" int
 close (int fd)
@@ -1509,7 +1512,7 @@ link (const char *oldpath, const char *newpath)
  * systems, it is only a stub that always returns zero.
  */
 static int
-chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
+chown_worker (const char *name, unsigned fmode, uid_t uid, gid_t gid)
 {
   int res = -1;
   fhandler_base *fh;
@@ -1533,33 +1536,41 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
 }
 
 extern "C" int
-chown32 (const char * name, __uid32_t uid, __gid32_t gid)
+chown32 (const char * name, uid_t uid, gid_t gid)
 {
   return chown_worker (name, PC_SYM_FOLLOW, uid, gid);
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (chown32, chown)
+#else
 extern "C" int
 chown (const char * name, __uid16_t uid, __gid16_t gid)
 {
   return chown_worker (name, PC_SYM_FOLLOW,
                       uid16touid32 (uid), gid16togid32 (gid));
 }
+#endif
 
 extern "C" int
-lchown32 (const char * name, __uid32_t uid, __gid32_t gid)
+lchown32 (const char * name, uid_t uid, gid_t gid)
 {
   return chown_worker (name, PC_SYM_NOFOLLOW, uid, gid);
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (lchown32, lchown)
+#else
 extern "C" int
 lchown (const char * name, __uid16_t uid, __gid16_t gid)
 {
   return chown_worker (name, PC_SYM_NOFOLLOW,
                       uid16touid32 (uid), gid16togid32 (gid));
 }
+#endif
 
 extern "C" int
-fchown32 (int fd, __uid32_t uid, __gid32_t gid)
+fchown32 (int fd, uid_t uid, gid_t gid)
 {
   cygheap_fdget cfd (fd);
   if (cfd < 0)
@@ -1574,11 +1585,15 @@ fchown32 (int fd, __uid32_t uid, __gid32_t gid)
   return res;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (fchown32, fchown)
+#else
 extern "C" int
 fchown (int fd, __uid16_t uid, __gid16_t gid)
 {
   return fchown32 (fd, uid16touid32 (uid), gid16togid32 (gid));
 }
+#endif
 
 /* umask: POSIX 5.3.3.1 */
 extern "C" mode_t
@@ -1619,7 +1634,7 @@ chmod (const char *path, mode_t mode)
 
   delete fh;
  error:
-  syscall_printf ("%R = chmod(%s, %p)", res, path, mode);
+  syscall_printf ("%R = chmod(%s, 0%o)", res, path, mode);
   return res;
 }
 
@@ -1638,8 +1653,9 @@ fchmod (int fd, mode_t mode)
   return cfd->fchmod (FILTERED_MODE (mode));
 }
 
+#ifndef __x86_64__
 static void
-stat64_to_stat32 (struct __stat64 *src, struct __stat32 *dst)
+stat64_to_stat32 (struct stat *src, struct __stat32 *dst)
 {
   dst->st_dev = ((src->st_dev >> 8) & 0xff00) | (src->st_dev & 0xff);
   dst->st_ino = ((unsigned) (src->st_ino >> 32)) | (unsigned) src->st_ino;
@@ -1655,12 +1671,13 @@ stat64_to_stat32 (struct __stat64 *src, struct __stat32 *dst)
   dst->st_blksize = src->st_blksize;
   dst->st_blocks = src->st_blocks;
 }
+#endif
 
-static struct __stat64 dev_st;
+static struct stat dev_st;
 static bool dev_st_inited;
 
 void
-fhandler_base::stat_fixup (struct __stat64 *buf)
+fhandler_base::stat_fixup (struct stat *buf)
 {
   /* For devices, set inode number to device number.  This gives us a valid,
      unique inode number without having to call hash_path_name. */
@@ -1700,7 +1717,7 @@ fhandler_base::stat_fixup (struct __stat64 *buf)
 }
 
 extern "C" int
-fstat64 (int fd, struct __stat64 *buf)
+fstat64 (int fd, struct stat *buf)
 {
   int res;
 
@@ -1709,7 +1726,7 @@ fstat64 (int fd, struct __stat64 *buf)
     res = -1;
   else
     {
-      memset (buf, 0, sizeof (struct __stat64));
+      memset (buf, 0, sizeof (struct stat));
       res = cfd->fstat (buf);
       if (!res)
        cfd->stat_fixup (buf);
@@ -1720,7 +1737,7 @@ fstat64 (int fd, struct __stat64 *buf)
 }
 
 extern "C" int
-_fstat64_r (struct _reent *ptr, int fd, struct __stat64 *buf)
+_fstat64_r (struct _reent *ptr, int fd, struct stat *buf)
 {
   int ret;
 
@@ -1729,18 +1746,22 @@ _fstat64_r (struct _reent *ptr, int fd, struct __stat64 *buf)
   return ret;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (fstat64, fstat)
+EXPORT_ALIAS (_fstat64_r, _fstat_r)
+#else
 extern "C" int
-fstat (int fd, struct __stat32 *buf)
+fstat (int fd, struct stat *buf)
 {
-  struct __stat64 buf64;
+  struct stat buf64;
   int ret = fstat64 (fd, &buf64);
   if (!ret)
-    stat64_to_stat32 (&buf64, buf);
+    stat64_to_stat32 (&buf64, (struct __stat32 *) buf);
   return ret;
 }
 
 extern "C" int
-_fstat_r (struct _reent *ptr, int fd, struct __stat32 *buf)
+_fstat_r (struct _reent *ptr, int fd, struct stat *buf)
 {
   int ret;
 
@@ -1748,6 +1769,7 @@ _fstat_r (struct _reent *ptr, int fd, struct __stat32 *buf)
     ptr->_errno = get_errno ();
   return ret;
 }
+#endif
 
 /* fsync: P96 6.6.1.1 */
 extern "C" int
@@ -1778,12 +1800,12 @@ sync_worker (HANDLE dir, USHORT len, LPCWSTR vol)
   status = NtOpenFile (&fh, GENERIC_WRITE, &attr, &io,
                       FILE_SHARE_VALID_FLAGS, 0);
   if (!NT_SUCCESS (status))
-    debug_printf ("NtOpenFile (%S), status %p", &uvol, status);
+    debug_printf ("NtOpenFile (%S), status %y", &uvol, status);
   else
     {
       status = NtFlushBuffersFile (fh, &io);
       if (!NT_SUCCESS (status))
-       debug_printf ("NtFlushBuffersFile (%S), status %p", &uvol, status);
+       debug_printf ("NtFlushBuffersFile (%S), status %y", &uvol, status);
       NtClose (fh);
     }
 }
@@ -1803,7 +1825,7 @@ sync ()
   status = NtOpenDirectoryObject (&devhdl, DIRECTORY_QUERY, &attr);
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("NtOpenDirectoryObject, status %p", status);
+      debug_printf ("NtOpenDirectoryObject, status %y", status);
       return;
     }
   /* Traverse \Device directory ... */
@@ -1826,7 +1848,7 @@ sync ()
 
 /* Cygwin internal */
 int __stdcall
-stat_worker (path_conv &pc, struct __stat64 *buf)
+stat_worker (path_conv &pc, struct stat *buf)
 {
   int res = -1;
 
@@ -1864,7 +1886,7 @@ stat_worker (path_conv &pc, struct __stat64 *buf)
 }
 
 extern "C" int
-stat64 (const char *name, struct __stat64 *buf)
+stat64 (const char *name, struct stat *buf)
 {
   syscall_printf ("entering");
   path_conv pc (name, PC_SYM_FOLLOW | PC_POSIX | PC_KEEP_HANDLE,
@@ -1873,7 +1895,7 @@ stat64 (const char *name, struct __stat64 *buf)
 }
 
 extern "C" int
-_stat64_r (struct _reent *ptr, const char *name, struct __stat64 *buf)
+_stat64_r (struct _reent *ptr, const char *name, struct stat *buf)
 {
   int ret;
 
@@ -1882,18 +1904,22 @@ _stat64_r (struct _reent *ptr, const char *name, struct __stat64 *buf)
   return ret;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (stat64, stat)
+EXPORT_ALIAS (_stat64_r, _stat_r)
+#else
 extern "C" int
-stat (const char *name, struct __stat32 *buf)
+stat (const char *name, struct stat *buf)
 {
-  struct __stat64 buf64;
+  struct stat buf64;
   int ret = stat64 (name, &buf64);
   if (!ret)
-    stat64_to_stat32 (&buf64, buf);
+    stat64_to_stat32 (&buf64, (struct __stat32 *) buf);
   return ret;
 }
 
 extern "C" int
-_stat_r (struct _reent *ptr, const char *name, struct __stat32 *buf)
+_stat_r (struct _reent *ptr, const char *name, struct stat *buf)
 {
   int ret;
 
@@ -1901,10 +1927,11 @@ _stat_r (struct _reent *ptr, const char *name, struct __stat32 *buf)
     ptr->_errno = get_errno ();
   return ret;
 }
+#endif
 
 /* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */
 extern "C" int
-lstat64 (const char *name, struct __stat64 *buf)
+lstat64 (const char *name, struct stat *buf)
 {
   syscall_printf ("entering");
   path_conv pc (name, PC_SYM_NOFOLLOW | PC_POSIX | PC_KEEP_HANDLE,
@@ -1912,16 +1939,20 @@ lstat64 (const char *name, struct __stat64 *buf)
   return stat_worker (pc, buf);
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (lstat64, lstat)
+#else
 /* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */
 extern "C" int
-lstat (const char *name, struct __stat32 *buf)
+lstat (const char *name, struct stat *buf)
 {
-  struct __stat64 buf64;
+  struct stat buf64;
   int ret = lstat64 (name, &buf64);
   if (!ret)
-    stat64_to_stat32 (&buf64, buf);
+    stat64_to_stat32 (&buf64, (struct __stat32 *) buf);
   return ret;
 }
+#endif
 
 extern "C" int
 access (const char *fn, int flags)
@@ -2338,7 +2369,7 @@ retry:
   }
   if (!NT_SUCCESS (status))
     {
-      debug_printf ("status %p", status);
+      debug_printf ("status %y", status);
       if (status == STATUS_SHARING_VIOLATION
          && cygwait (10L) != WAIT_SIGNALED)
        {
@@ -2721,7 +2752,7 @@ getmode (int fd)
    previous mode.  */
 
 extern "C" int
-setmode (int fd, int mode)
+_setmode (int fd, int mode)
 {
   cygheap_fdget cfd (fd);
   if (cfd < 0)
@@ -2759,7 +2790,7 @@ setmode (int fd, int mode)
 extern "C" int
 cygwin_setmode (int fd, int mode)
 {
-  int res = setmode (fd, mode);
+  int res = _setmode (fd, mode);
   if (res != -1)
     {
       _my_tls.locals.setmode_file = fd;
@@ -2773,7 +2804,7 @@ cygwin_setmode (int fd, int mode)
 }
 
 extern "C" int
-posix_fadvise (int fd, _off64_t offset, _off64_t len, int advice)
+posix_fadvise (int fd, off_t offset, off_t len, int advice)
 {
   int res = -1;
   cygheap_fdget cfd (fd);
@@ -2787,7 +2818,7 @@ posix_fadvise (int fd, _off64_t offset, _off64_t len, int advice)
 }
 
 extern "C" int
-posix_fallocate (int fd, _off64_t offset, _off64_t len)
+posix_fallocate (int fd, off_t offset, off_t len)
 {
   int res = -1;
   if (offset < 0 || len == 0)
@@ -2805,7 +2836,7 @@ posix_fallocate (int fd, _off64_t offset, _off64_t len)
 }
 
 extern "C" int
-ftruncate64 (int fd, _off64_t length)
+ftruncate64 (int fd, off_t length)
 {
   int res = -1;
   cygheap_fdget cfd (fd);
@@ -2817,16 +2848,20 @@ ftruncate64 (int fd, _off64_t length)
   return res;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (ftruncate64, ftruncate)
+#else
 /* ftruncate: P96 5.6.7.1 */
 extern "C" int
 ftruncate (int fd, _off_t length)
 {
-  return ftruncate64 (fd, (_off64_t)length);
+  return ftruncate64 (fd, (off_t)length);
 }
+#endif
 
 /* truncate: Provided by SVR4 and 4.3+BSD.  Not part of POSIX.1 or XPG3 */
 extern "C" int
-truncate64 (const char *pathname, _off64_t length)
+truncate64 (const char *pathname, off_t length)
 {
   int fd;
   int res = -1;
@@ -2843,15 +2878,19 @@ truncate64 (const char *pathname, _off64_t length)
   return res;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (truncate64, truncate)
+#else
 /* truncate: Provided by SVR4 and 4.3+BSD.  Not part of POSIX.1 or XPG3 */
 extern "C" int
 truncate (const char *pathname, _off_t length)
 {
-  return truncate64 (pathname, (_off64_t)length);
+  return truncate64 (pathname, (off_t)length);
 }
+#endif
 
 extern "C" long
-get_osfhandle (int fd)
+_get_osfhandle (int fd)
 {
   long res;
 
@@ -2993,7 +3032,7 @@ getpgid (pid_t pid)
     pid = getpid ();
 
   pinfo p (pid);
-  if (p == 0)
+  if (!p)
     {
       set_errno (ESRCH);
       return -1;
@@ -3046,7 +3085,7 @@ mknod_worker (const char *path, mode_t type, mode_t mode, _major_t major,
 }
 
 extern "C" int
-mknod32 (const char *path, mode_t mode, __dev32_t dev)
+mknod32 (const char *path, mode_t mode, dev_t dev)
 {
   myfault efault;
   if (efault.faulted (EFAULT))
@@ -3102,7 +3141,7 @@ mknod32 (const char *path, mode_t mode, __dev32_t dev)
 extern "C" int
 mknod (const char *_path, mode_t mode, __dev16_t dev)
 {
-  return mknod32 (_path, mode, (__dev32_t) dev);
+  return mknod32 (_path, mode, (dev_t) dev);
 }
 
 extern "C" int
@@ -3113,7 +3152,7 @@ mkfifo (const char *path, mode_t mode)
 
 /* seteuid: standards? */
 extern "C" int
-seteuid32 (__uid32_t uid)
+seteuid32 (uid_t uid)
 {
   debug_printf ("uid: %u myself->uid: %u myself->gid: %u",
                uid, myself->uid, myself->gid);
@@ -3213,7 +3252,7 @@ seteuid32 (__uid32_t uid)
                            &token_is_internal))
     new_token = cygheap->user.internal_token;
 
-  debug_printf ("Found token %d", new_token);
+  debug_printf ("Found token %p", new_token);
 
   /* If no impersonation token is available, try to authenticate using
      LSA private data stored password, LSA authentication using our own
@@ -3268,14 +3307,14 @@ seteuid32 (__uid32_t uid)
       status = NtSetInformationToken (new_token, TokenOwner,
                                      &usersid, sizeof usersid);
       if (!NT_SUCCESS (status))
-       debug_printf ("NtSetInformationToken (user.token, TokenOwner), %p",
+       debug_printf ("NtSetInformationToken (user.token, TokenOwner), %y",
                      status);
       /* Try setting primary group in token to current group */
       status = NtSetInformationToken (new_token, TokenPrimaryGroup,
                                      &groups.pgsid, sizeof (cygsid));
       if (!NT_SUCCESS (status))
        debug_printf ("NtSetInformationToken (user.token, TokenPrimaryGroup),"
-                     "%p", status);
+                     "%y", status);
       /* Try setting default DACL */
       PACL dacl_buf = (PACL) alloca (MAX_DACL_LEN (5));
       if (sec_acl (dacl_buf, true, true, usersid))
@@ -3284,7 +3323,7 @@ seteuid32 (__uid32_t uid)
          status = NtSetInformationToken (new_token, TokenDefaultDacl,
                                          &tdacl, sizeof (tdacl));
          if (!NT_SUCCESS (status))
-           debug_printf ("NtSetInformationToken (TokenDefaultDacl), %p",
+           debug_printf ("NtSetInformationToken (TokenDefaultDacl), %y",
                          status);
        }
     }
@@ -3333,15 +3372,19 @@ seteuid32 (__uid32_t uid)
   return 0;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (seteuid32, seteuid)
+#else
 extern "C" int
 seteuid (__uid16_t uid)
 {
   return seteuid32 (uid16touid32 (uid));
 }
+#endif
 
 /* setuid: POSIX 4.2.2.1 */
 extern "C" int
-setuid32 (__uid32_t uid)
+setuid32 (uid_t uid)
 {
   int ret = seteuid32 (uid);
   if (!ret)
@@ -3354,18 +3397,22 @@ setuid32 (__uid32_t uid)
   return ret;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (setuid32, setuid)
+#else
 extern "C" int
 setuid (__uid16_t uid)
 {
   return setuid32 (uid16touid32 (uid));
 }
+#endif
 
 extern "C" int
-setreuid32 (__uid32_t ruid, __uid32_t euid)
+setreuid32 (uid_t ruid, uid_t euid)
 {
   int ret = 0;
   bool tried = false;
-  __uid32_t old_euid = myself->uid;
+  uid_t old_euid = myself->uid;
 
   if (ruid != ILLEGAL_UID && cygheap->user.real_uid != ruid && euid != ruid)
     tried = !(ret = seteuid32 (ruid));
@@ -3379,15 +3426,19 @@ setreuid32 (__uid32_t ruid, __uid32_t euid)
   return ret;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (setreuid32, setreuid)
+#else
 extern "C" int
 setreuid (__uid16_t ruid, __uid16_t euid)
 {
   return setreuid32 (uid16touid32 (ruid), uid16touid32 (euid));
 }
+#endif
 
 /* setegid: from System V.  */
 extern "C" int
-setegid32 (__gid32_t gid)
+setegid32 (gid_t gid)
 {
   debug_printf ("new egid: %u current: %u", gid, myself->gid);
 
@@ -3400,7 +3451,7 @@ setegid32 (__gid32_t gid)
   NTSTATUS status;
   user_groups * groups = &cygheap->user.groups;
   cygsid gsid;
-  struct __group32 * gr = internal_getgrgid (gid);
+  struct group * gr = internal_getgrgid (gid);
 
   if (!gsid.getfromgr (gr))
     {
@@ -3417,33 +3468,37 @@ setegid32 (__gid32_t gid)
                                      TokenPrimaryGroup, &gsid, sizeof gsid);
       if (!NT_SUCCESS (status))
        debug_printf ("NtSetInformationToken (primary_token, "
-                     "TokenPrimaryGroup), %p", status);
+                     "TokenPrimaryGroup), %y", status);
       status = NtSetInformationToken (cygheap->user.imp_token (),
                                      TokenPrimaryGroup, &gsid, sizeof gsid);
       if (!NT_SUCCESS (status))
-       debug_printf ("NtSetInformationToken (token, TokenPrimaryGroup), %p",
+       debug_printf ("NtSetInformationToken (token, TokenPrimaryGroup), %y",
                      status);
     }
   cygheap->user.deimpersonate ();
   status = NtSetInformationToken (hProcToken, TokenPrimaryGroup,
                                  &gsid, sizeof gsid);
   if (!NT_SUCCESS (status))
-    debug_printf ("NtSetInformationToken (hProcToken, TokenPrimaryGroup), %p",
+    debug_printf ("NtSetInformationToken (hProcToken, TokenPrimaryGroup), %y",
                  status);
   clear_procimptoken ();
   cygheap->user.reimpersonate ();
   return 0;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (setegid32, setegid)
+#else
 extern "C" int
 setegid (__gid16_t gid)
 {
   return setegid32 (gid16togid32 (gid));
 }
+#endif
 
 /* setgid: POSIX 4.2.2.1 */
 extern "C" int
-setgid32 (__gid32_t gid)
+setgid32 (gid_t gid)
 {
   int ret = setegid32 (gid);
   if (!ret)
@@ -3451,6 +3506,9 @@ setgid32 (__gid32_t gid)
   return ret;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (setgid32, setgid)
+#else
 extern "C" int
 setgid (__gid16_t gid)
 {
@@ -3459,13 +3517,14 @@ setgid (__gid16_t gid)
     cygheap->user.real_gid = myself->gid;
   return ret;
 }
+#endif
 
 extern "C" int
-setregid32 (__gid32_t rgid, __gid32_t egid)
+setregid32 (gid_t rgid, gid_t egid)
 {
   int ret = 0;
   bool tried = false;
-  __gid32_t old_egid = myself->gid;
+  gid_t old_egid = myself->gid;
 
   if (rgid != ILLEGAL_GID && cygheap->user.real_gid != rgid && egid != rgid)
     tried = !(ret = setegid32 (rgid));
@@ -3479,11 +3538,15 @@ setregid32 (__gid32_t rgid, __gid32_t egid)
   return ret;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (setregid32, setregid)
+#else
 extern "C" int
 setregid (__gid16_t rgid, __gid16_t egid)
 {
   return setregid32 (gid16togid32 (rgid), gid16togid32 (egid));
 }
+#endif
 
 /* chroot: privileged Unix system call.  */
 /* FIXME: Not privileged here. How should this be done? */
@@ -3584,7 +3647,7 @@ setpriority (int which, id_t who, int value)
                continue;
              break;
            case PRIO_USER:
-               if ((__uid32_t) who != p->uid)
+               if ((uid_t) who != p->uid)
                continue;
              break;
            }
@@ -3655,7 +3718,7 @@ getpriority (int which, id_t who)
              nice = p->nice;
            break;
          case PRIO_USER:
-           if ((__uid32_t) who == p->uid && p->nice < nice)
+           if ((uid_t) who == p->uid && p->nice < nice)
              nice = p->nice;
              break;
          }
@@ -3705,14 +3768,14 @@ ffs (int i)
 static void
 locked_append (int fd, const void * buf, size_t size)
 {
-  struct __flock64 lock_buffer = {F_WRLCK, SEEK_SET, 0, 0, 0};
+  struct flock lock_buffer = {F_WRLCK, SEEK_SET, 0, 0, 0};
   int count = 0;
 
   do
-    if ((lock_buffer.l_start = lseek64 (fd, 0, SEEK_END)) != (_off64_t) -1
+    if ((lock_buffer.l_start = lseek64 (fd, 0, SEEK_END)) != (off_t) -1
        && fcntl64 (fd, F_SETLKW, &lock_buffer) != -1)
       {
-       if (lseek64 (fd, 0, SEEK_END) != (_off64_t) -1)
+       if (lseek64 (fd, 0, SEEK_END) != (off_t) -1)
          write (fd, buf, size);
        lock_buffer.l_type = F_UNLCK;
        fcntl64 (fd, F_SETLK, &lock_buffer);
@@ -4010,7 +4073,7 @@ gethostid (void)
   /* SDBM hash */
   for (PWCHAR wp = wguid; *wp; ++wp)
     hostid = *wp + (hostid << 6) + (hostid << 16) - hostid;
-  debug_printf ("hostid 0x%08x from MachineGuid %W", hostid, wguid);
+  debug_printf ("hostid %08y from MachineGuid %W", hostid, wguid);
   return (int32_t) hostid; /* Avoid sign extension. */
 }
 
@@ -4025,7 +4088,7 @@ getusershell ()
      FIXME: SunOS has a far longer list, containing all shells which
      might be shipped with the OS.  Should we do the same for the Cygwin
      distro, adding bash, tcsh, ksh, pdksh and zsh?  */
-  static NO_COPY const char *def_shells[] = {
+  static const char *def_shells[] = {
     "/bin/sh",
     "/bin/csh",
     "/usr/bin/sh",
@@ -4375,8 +4438,7 @@ fchmodat (int dirfd, const char *pathname, mode_t mode, int flags)
 }
 
 extern "C" int
-fchownat (int dirfd, const char *pathname, __uid32_t uid, __gid32_t gid,
-        int flags)
+fchownat (int dirfd, const char *pathname, uid_t uid, gid_t gid, int flags)
 {
   tmp_pathbuf tp;
   myfault efault;
@@ -4395,7 +4457,7 @@ fchownat (int dirfd, const char *pathname, __uid32_t uid, __gid32_t gid,
 }
 
 extern "C" int
-fstatat (int dirfd, const char *pathname, struct __stat64 *st, int flags)
+fstatat (int dirfd, const char *pathname, struct stat *st, int flags)
 {
   tmp_pathbuf tp;
   myfault efault;
@@ -4512,7 +4574,7 @@ mkfifoat (int dirfd, const char *pathname, mode_t mode)
 }
 
 extern "C" int
-mknodat (int dirfd, const char *pathname, mode_t mode, __dev32_t dev)
+mknodat (int dirfd, const char *pathname, mode_t mode, dev_t dev)
 {
   tmp_pathbuf tp;
   myfault efault;
index efff108ed1f69bc1409d5060199a59249d2d4ee3..7d09f53d006609d0dca88ec264ebe109e6f94a9e 100644 (file)
@@ -1,7 +1,7 @@
 /* sysconf.cc
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -47,7 +47,7 @@ get_nproc_values (int in)
   if (!NT_SUCCESS (status))
     {
       __seterrno_from_nt_status (status);
-      debug_printf ("NtQuerySystemInformation: status %p, %E", status);
+      debug_printf ("NtQuerySystemInformation: status %y, %E", status);
       return -1;
     }
   switch (in)
@@ -81,7 +81,7 @@ get_avphys (int in)
   if (!NT_SUCCESS (status))
     {
       __seterrno_from_nt_status (status);
-      debug_printf ("NtQuerySystemInformation: status %d, %E", status);
+      debug_printf ("NtQuerySystemInformation: status %y, %E", status);
       return -1;
     }
   return spi.AvailablePages
@@ -192,10 +192,10 @@ static struct
   {nsup, {c:0}},                       /*  89, _SC_TRACE_SYS_MAX */
   {nsup, {c:0}},                       /*  90, _SC_TRACE_USER_EVENT_MAX */
   {cons, {c:-1L}},                     /*  91, _SC_TYPED_MEMORY_OBJECTS */
-  {cons, {c:-1L}},                     /*  92, _SC_V6_ILP32_OFF32 */
+  {cons, {c:_POSIX_V6_ILP32_OFF32}},   /*  92, _SC_V6_ILP32_OFF32 */
   {cons, {c:_POSIX_V6_ILP32_OFFBIG}},  /*  93, _SC_V6_ILP32_OFFBIG */
-  {cons, {c:-1L}},                     /*  94, _SC_V6_LP64_OFF64 */
-  {cons, {c:-1L}},                     /*  95, _SC_V6_LPBIG_OFFBIG */
+  {cons, {c:_POSIX_V6_LP64_OFF64}},    /*  94, _SC_V6_LP64_OFF64 */
+  {cons, {c:_POSIX_V6_LPBIG_OFFBIG}},  /*  95, _SC_V6_LPBIG_OFFBIG */
   {cons, {c:_XOPEN_CRYPT}},            /*  96, _SC_XOPEN_CRYPT */
   {cons, {c:_XOPEN_ENH_I18N}},         /*  97, _SC_XOPEN_ENH_I18N */
   {cons, {c:-1L}},                     /*  98, _SC_XOPEN_LEGACY */
@@ -266,6 +266,21 @@ static struct
   {0, NULL},                           /* _CS_POSIX_V6_ILP32_OFF32_LDFLAGS */
   {0, NULL},                           /* _CS_POSIX_V6_ILP32_OFF32_LIBS */
   {0, NULL},                           /* _CS_XBS5_ILP32_OFF32_LINTFLAGS */
+#ifdef __x86_64__
+  {0, NULL},                           /* _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
+  {0, NULL},                           /* _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
+  {0, NULL},                           /* _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
+  {0, NULL},                           /* _CS_XBS5_ILP32_OFFBIG_LINTFLAGS */
+  {ls ("")},                           /* _CS_POSIX_V6_LP64_OFF64_CFLAGS */
+  {ls ("")},                           /* _CS_POSIX_V6_LP64_OFF64_LDFLAGS */
+  {ls ("")},                           /* _CS_POSIX_V6_LP64_OFF64_LIBS */
+  {ls ("")},                           /* _CS_XBS5_LP64_OFF64_LINTFLAGS */
+  {ls ("")},                           /* _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS */
+  {ls ("")},                           /* _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS */
+  {ls ("")},                           /* _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
+  {ls ("")},                           /* _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
+  {ls ("POSIX_V6_LP64_OFF64")},                /* _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS */
+#else
   {ls ("")},                           /* _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS */
   {ls ("")},                           /* _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS */
   {ls ("")},                           /* _CS_POSIX_V6_ILP32_OFFBIG_LIBS */
@@ -279,6 +294,7 @@ static struct
   {0, NULL},                           /* _CS_POSIX_V6_LPBIG_OFFBIG_LIBS */
   {0, NULL},                           /* _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS */
   {ls ("POSIX_V6_ILP32_OFFBIG")},      /* _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS */
+#endif
   {ls ("")},                           /* _CS_POSIX_V7_THREADS_CFLAGS */
   {ls ("")},                           /* _CS_POSIX_V7_THREADS_LDFLAGS */
   {ls ("POSIXLY_CORRECT=1")},          /* _CS_V7_ENV */
@@ -336,8 +352,8 @@ sysinfo (struct sysinfo *info)
   MEMORYSTATUSEX memory_status;
   PSYSTEM_PAGEFILE_INFORMATION spi = NULL;
   ULONG sizeof_spi = 512;
-  PSYSTEM_TIME_OF_DAY_INFORMATION stodi = NULL;
-  const ULONG sizeof_stodi = sizeof (SYSTEM_TIME_OF_DAY_INFORMATION);
+  PSYSTEM_TIMEOFDAY_INFORMATION stodi = NULL;
+  const ULONG sizeof_stodi = sizeof (SYSTEM_TIMEOFDAY_INFORMATION);
   NTSTATUS status = STATUS_SUCCESS;
   winpids pids ((DWORD) 0);
 
@@ -347,7 +363,7 @@ sysinfo (struct sysinfo *info)
       return -1;
     }
 
-  stodi = (PSYSTEM_TIME_OF_DAY_INFORMATION) malloc (sizeof_stodi);
+  stodi = (PSYSTEM_TIMEOFDAY_INFORMATION) malloc (sizeof_stodi);
   status = NtQuerySystemInformation (SystemTimeOfDayInformation, (PVOID) stodi,
                                     sizeof_stodi, NULL);
   if (NT_SUCCESS (status))
@@ -355,7 +371,7 @@ sysinfo (struct sysinfo *info)
             / 10000000ULL;
   else
     debug_printf ("NtQuerySystemInformation(SystemTimeOfDayInformation), "
-                 "status %p", status);
+                 "status %y", status);
 
   if (stodi)
     free (stodi);
@@ -383,7 +399,7 @@ sysinfo (struct sysinfo *info)
   if (!spi || !NT_SUCCESS (status))
     {
       debug_printf ("NtQuerySystemInformation(SystemPagefileInformation), "
-                   "status %p", status);
+                   "status %y", status);
       totalswap = (memory_status.ullTotalPageFile - memory_status.ullTotalPhys)
                  / wincap.page_size ();
       freeswap = (memory_status.ullAvailPageFile - memory_status.ullTotalPhys)
index 98b15060d5325fabad70752f7d37dcee6b1d8af7..7949b70010fb5d3ab8e0063e66535e0a2c01de4c 100644 (file)
@@ -45,7 +45,7 @@ openlog (const char *ident, int logopt, int facility)
     wchar_t *new_ident = NULL;
 
     debug_printf ("openlog called with (%s, %d, %d)",
-                      ident ? ident : "<NULL>", logopt, facility);
+                 ident ? ident : "<NULL>", logopt, facility);
 
     if (ident)
       {
@@ -249,7 +249,7 @@ connect_syslogd ()
 }
 
 static int
-try_connect_syslogd (int priority, const char *msg, int len)
+try_connect_syslogd (int priority, const char *msg, size_t len)
 {
   ssize_t ret = -1;
 
@@ -296,11 +296,11 @@ try_connect_syslogd (int priority, const char *msg, int len)
 extern "C" void
 vsyslog (int priority, const char *message, va_list ap)
 {
-  debug_printf ("%x %s", priority, message);
+  debug_printf ("%y %s", priority, message);
   /* If the priority fails the current mask, reject */
   if ((LOG_MASK (LOG_PRI (priority)) & syslog_globals.process_logmask) == 0)
     {
-      debug_printf ("failing message %x due to priority mask %x",
+      debug_printf ("failing message %y due to priority mask %y",
                    priority, syslog_globals.process_logmask);
       return;
     }
@@ -402,7 +402,7 @@ vsyslog (int priority, const char *message, va_list ap)
 
     }
   char *total_msg = pass.get_message ();
-  int len = strlen (total_msg);
+  size_t len = strlen (total_msg);
   if (len != 0 && (total_msg[len - 1] == '\n'))
     total_msg[--len] = '\0';
 
index fef5e506c2e285d49ad738760862d2d2e7d37264..2f66298428a71a7267490492bfa849d7899d3065 100644 (file)
@@ -159,10 +159,10 @@ tcsetattr (int fd, int a, const struct termios *t)
     }
 
   set_errno (e);
-  termios_printf ("iflag %p, oflag %p, cflag %p, lflag %p, VMIN %d, VTIME %d",
+  termios_printf ("iflag %y, oflag %y, cflag %y, lflag %y, VMIN %d, VTIME %d",
        t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN],
        t->c_cc[VTIME]);
-  termios_printf ("%R = tcsetattr(%d, %d, %x)", res, fd, a, t);
+  termios_printf ("%R = tcsetattr(%d, %d, %p)", res, fd, a, t);
   return res;
 }
 
@@ -184,7 +184,7 @@ tcgetattr (int fd, struct termios *in_t)
   if (res)
     termios_printf ("%R = tcgetattr(%d, %p)", res, fd, in_t);
   else
-    termios_printf ("iflag %x, oflag %x, cflag %x, lflag %x, VMIN %d, VTIME %d",
+    termios_printf ("iflag %y, oflag %y, cflag %y, lflag %y, VMIN %d, VTIME %d",
          t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag, t->c_cc[VMIN],
          t->c_cc[VTIME]);
 
index 55c6fb975f37d85c74b25846b84ee00b61a83201..320b7545317f8f96a70ea93579e0814f86635d95 100644 (file)
@@ -1,6 +1,6 @@
 /* binmode.c
 
-   Copyright 2000, 2001, 2010 Red Hat, Inc.
+   Copyright 2000, 2001, 2010, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -14,7 +14,9 @@ details. */
 
 extern int _fmode;
 void
-cygwin_premain0 (int argc, char **argv, struct per_process *myself)
+cygwin_premain0 (int argc __attribute__ ((unused)),
+                char **argv __attribute__ ((unused)),
+                struct per_process *myself __attribute__ ((unused)))
 {
   _fmode &= ~_O_BINARY;
   _fmode |= _O_TEXT;
index ab6d2cbb28ff5a7cf415535c1b409f0c08946371..5425002f2b182bc12f035132d1a1d2fefde6cfc0 100644 (file)
@@ -1,6 +1,6 @@
 /* textreadmode.c
 
-   Copyright 2004, 2010 Red Hat, Inc.
+   Copyright 2004, 2010, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -14,7 +14,9 @@ details. */
 
 extern int _fmode;
 void
-cygwin_premain0 (int argc, char **argv, struct per_process *myself)
+cygwin_premain0 (int argc __attribute__ ((unused)),
+                char **argv __attribute__ ((unused)),
+                struct per_process *myself __attribute__ ((unused)))
 {
   static struct __cygwin_perfile pf[] =
     {
index 183b9b8d5239c0173182d132b17b0f6fcc788377..2e54b7a503e1dd72767f771f1f4848aef9767418 100644 (file)
@@ -38,7 +38,12 @@ extern "C" void __fp_lock_all ();
 extern "C" void __fp_unlock_all ();
 extern "C" int valid_sched_parameters(const struct sched_param *);
 extern "C" int sched_set_thread_priority(HANDLE thread, int priority);
+#ifdef __x86_64__
+/* FIXME: Temporarily workaround gcc 4.8 bug. */
+static verifyable_object_state
+#else
 static inline verifyable_object_state
+#endif
   verifyable_object_isvalid (void const * objectptr, thread_magic_t magic,
                             void *static_ptr1 = NULL,
                             void *static_ptr2 = NULL,
@@ -117,7 +122,12 @@ __cygwin_lock_unlock (_LOCK_T *lock)
   paranoid_printf ("threadcount %d.  unlocked", MT_INTERFACE->threadcount);
 }
 
+#ifdef __x86_64__
+/* FIXME: Temporarily workaround gcc 4.8 bug. */
+static verifyable_object_state
+#else
 static inline verifyable_object_state
+#endif
 verifyable_object_isvalid (void const *objectptr, thread_magic_t magic, void *static_ptr1,
                           void *static_ptr2, void *static_ptr3)
 {
@@ -216,7 +226,7 @@ pthread_mutex::can_be_unlocked ()
    * Also check for the ANONYMOUS owner to cover NORMAL mutexes as well. */
   bool res = type == PTHREAD_MUTEX_NORMAL || no_owner ()
             || (recursion_counter == 1 && pthread::equal (owner, self));
-  pthread_printf ("recursion_counter %d res %d", recursion_counter, res);
+  pthread_printf ("recursion_counter %u res %d", recursion_counter, res);
   return res;
 }
 
@@ -579,7 +589,11 @@ pthread::cancel ()
         executing Windows code.  Rely on deferred cancellation in this case. */
       if (!cygtls->inside_kernel (&context))
        {
+#ifdef __x86_64__
+         context.Rip = (ULONG_PTR) pthread::static_cancel_self;
+#else
          context.Eip = (DWORD) pthread::static_cancel_self;
+#endif
          SetThreadContext (win32_obj_id, &context);
        }
     }
@@ -1143,7 +1157,7 @@ pthread_cond::pthread_cond (pthread_condattr *attr) :
   /* Change the mutex type to NORMAL to speed up mutex operations */
   mtx_out.set_type (PTHREAD_MUTEX_NORMAL);
 
-  sem_wait = ::CreateSemaphore (&sec_none_nih, 0, LONG_MAX, NULL);
+  sem_wait = ::CreateSemaphore (&sec_none_nih, 0, INT32_MAX, NULL);
   if (!sem_wait)
     {
       pthread_printf ("CreateSemaphore failed. %E");
@@ -1165,7 +1179,7 @@ pthread_cond::~pthread_cond ()
 void
 pthread_cond::unblock (const bool all)
 {
-  unsigned long releaseable;
+  LONG releaseable;
 
   /*
    * Block outgoing threads (and avoid simultanous unblocks)
@@ -1175,7 +1189,7 @@ pthread_cond::unblock (const bool all)
   releaseable = waiting - pending;
   if (releaseable)
     {
-      unsigned long released;
+      LONG released;
 
       if (!pending)
        {
@@ -1212,11 +1226,11 @@ pthread_cond::wait (pthread_mutex_t mutex, PLARGE_INTEGER timeout)
   DWORD rv;
 
   mtx_in.lock ();
-  if (InterlockedIncrement ((long *)&waiting) == 1)
+  if (InterlockedIncrement (&waiting) == 1)
     mtx_cond = mutex;
   else if (mtx_cond != mutex)
     {
-      InterlockedDecrement ((long *)&waiting);
+      InterlockedDecrement (&waiting);
       mtx_in.unlock ();
       return EINVAL;
     }
@@ -1247,7 +1261,7 @@ pthread_cond::wait (pthread_mutex_t mutex, PLARGE_INTEGER timeout)
        rv = WAIT_OBJECT_0;
     }
 
-  InterlockedDecrement ((long *)&waiting);
+  InterlockedDecrement (&waiting);
 
   if (rv == WAIT_OBJECT_0 && --pending == 0)
     /*
@@ -1286,7 +1300,7 @@ pthread_cond::_fixup_after_fork ()
   mtx_in.unlock ();
   mtx_out.unlock ();
 
-  sem_wait = ::CreateSemaphore (&sec_none_nih, 0, LONG_MAX, NULL);
+  sem_wait = ::CreateSemaphore (&sec_none_nih, 0, INT32_MAX, NULL);
   if (!sem_wait)
     api_fatal ("pthread_cond::_fixup_after_fork () failed to recreate win32 semaphore");
 }
@@ -1383,7 +1397,7 @@ pthread_rwlock::rdlock ()
   reader = lookup_reader ();
   if (reader)
     {
-      if (reader->n < ULONG_MAX)
+      if (reader->n < UINT32_MAX)
        ++reader->n;
       else
        errno = EAGAIN;
@@ -1429,7 +1443,7 @@ pthread_rwlock::tryrdlock ()
       RWLOCK_READER *reader = lookup_reader ();
       if (!reader)
        reader = add_reader ();
-      if (reader && reader->n < ULONG_MAX)
+      if (reader && reader->n < UINT32_MAX)
        ++reader->n;
       else
        result = EAGAIN;
@@ -1448,7 +1462,7 @@ pthread_rwlock::wrlock ()
 
   mtx.lock ();
 
-  if (writer ==  self || lookup_reader ())
+  if (writer == self || lookup_reader ())
     {
       result = EDEADLK;
       goto DONE;
@@ -1730,7 +1744,7 @@ pthread_mutex::lock ()
   pthread_t self = ::pthread_self ();
   int result = 0;
 
-  if (InterlockedIncrement ((long *) &lock_counter) == 1)
+  if (InterlockedIncrement (&lock_counter) == 1)
     set_owner (self);
   else if (type == PTHREAD_MUTEX_NORMAL /* potentially causes deadlock */
           || !pthread::equal (owner, self))
@@ -1741,14 +1755,14 @@ pthread_mutex::lock ()
     }
   else
     {
-      InterlockedDecrement ((long *) &lock_counter);
+      InterlockedDecrement (&lock_counter);
       if (type == PTHREAD_MUTEX_RECURSIVE)
        result = lock_recursive ();
       else
        result = EDEADLK;
     }
 
-  pthread_printf ("mutex %p, self %p, owner %p, lock_counter %d, recursion_counter %d",
+  pthread_printf ("mutex %p, self %p, owner %p, lock_counter %d, recursion_counter %u",
                  this, self, owner, lock_counter, recursion_counter);
   return result;
 }
@@ -1772,12 +1786,12 @@ pthread_mutex::unlock ()
 #ifdef DEBUGGING
       tid = 0;         // thread-id
 #endif
-      if (InterlockedDecrement ((long *) &lock_counter))
+      if (InterlockedDecrement (&lock_counter))
        ::SetEvent (win32_obj_id); // Another thread is waiting
       res = 0;
     }
 
-  pthread_printf ("mutex %p, owner %p, self %p, lock_counter %d, recursion_counter %d, type %d, res %d",
+  pthread_printf ("mutex %p, owner %p, self %p, lock_counter %d, recursion_counter %u, type %d, res %d",
                  this, owner, self, lock_counter, recursion_counter, type, res);
   return res;
 }
@@ -1788,7 +1802,7 @@ pthread_mutex::trylock ()
   pthread_t self = ::pthread_self ();
   int result = 0;
 
-  if (InterlockedCompareExchange ((long *) &lock_counter, 1, 0) == 0)
+  if (InterlockedCompareExchange (&lock_counter, 1, 0) == 0)
     set_owner (self);
   else if (type == PTHREAD_MUTEX_RECURSIVE && pthread::equal (owner, self))
     result = lock_recursive ();
@@ -1864,7 +1878,7 @@ pthread_spinlock::lock ()
 
   do
     {
-      if (InterlockedExchange ((long *) &lock_counter, 1) == 0)
+      if (InterlockedExchange (&lock_counter, 1) == 0)
        {
          set_owner (self);
          result = 0;
@@ -1899,7 +1913,7 @@ pthread_spinlock::unlock ()
 #ifdef DEBUGGING
       tid = 0;         // thread-id
 #endif
-      InterlockedExchange ((long *) &lock_counter, 0);
+      InterlockedExchange (&lock_counter, 0);
       ::SetEvent (win32_obj_id);
       result = 0;
     }
@@ -2248,7 +2262,7 @@ pthread_attr_getstack (const pthread_attr_t *attr, void **addr, size_t *size)
   if (!pthread_attr::is_good_object (attr))
     return EINVAL;
   /* uses lowest address of stack on all platforms */
-  *addr = (void *)((int)(*attr)->stackaddr - (*attr)->stacksize);
+  *addr = (void *)((ptrdiff_t)(*attr)->stackaddr - (*attr)->stacksize);
   *size = (*attr)->stacksize;
   return 0;
 }
@@ -2481,7 +2495,7 @@ pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
   else
     {
       debug_printf ("NtQueryInformationThread(ThreadBasicInformation), "
-                   "status %p", status);
+                   "status %y", status);
       (*attr)->stackaddr = thread->attr.stackaddr;
       (*attr)->stacksize = thread->attr.stacksize;
     }
@@ -3030,7 +3044,8 @@ extern "C" int
 pthread_sigmask (int operation, const sigset_t *set, sigset_t *old_set)
 {
   int res = handle_sigprocmask (operation, set, old_set, _my_tls.sigmask);
-  syscall_printf ("%d = pthread_sigmask(%d, %p, %p)", operation, set, old_set);
+  syscall_printf ("%d = pthread_sigmask(%d, %p, %p)",
+                 res, operation, set, old_set);
   return res;
 }
 
@@ -3368,7 +3383,7 @@ semaphore::semaphore (int pshared, unsigned int value)
 {
   SECURITY_ATTRIBUTES sa = (pshared != PTHREAD_PROCESS_PRIVATE)
                           ? sec_all : sec_none_nih;
-  this->win32_obj_id = ::CreateSemaphore (&sa, value, LONG_MAX, NULL);
+  this->win32_obj_id = ::CreateSemaphore (&sa, value, INT32_MAX, NULL);
   if (!this->win32_obj_id)
     magic = 0;
 
@@ -3389,7 +3404,7 @@ semaphore::semaphore (unsigned long long shash, LUID sluid, int sfd,
 
   __small_sprintf (name, "semaphore/%016X%08x%08x",
                   hash, luid.HighPart, luid.LowPart);
-  this->win32_obj_id = ::CreateSemaphore (&sec_all, value, LONG_MAX, name);
+  this->win32_obj_id = ::CreateSemaphore (&sec_all, value, INT32_MAX, name);
   if (!this->win32_obj_id)
     magic = 0;
   if (GetLastError () == ERROR_ALREADY_EXISTS && (oflag & O_EXCL))
@@ -3420,7 +3435,7 @@ semaphore::_post ()
 int
 semaphore::_getvalue (int *sval)
 {
-  long val;
+  LONG val;
 
   switch (WaitForSingleObject (win32_obj_id, 0))
     {
@@ -3513,10 +3528,10 @@ semaphore::_fixup_after_fork ()
 {
   if (shared == PTHREAD_PROCESS_PRIVATE)
     {
-      pthread_printf ("sem %x", this);
+      pthread_printf ("sem %p", this);
       /* FIXME: duplicate code here and in the constructor. */
       this->win32_obj_id = ::CreateSemaphore (&sec_none_nih, currentvalue,
-                                             LONG_MAX, NULL);
+                                             INT32_MAX, NULL);
       if (!win32_obj_id)
        api_fatal ("failed to create new win32 semaphore, %E");
     }
index 71f301258537328710e38a2ddde28d95a50db6d3..c87c620ebdac34f3c7e1a3162260396b31fc0b5b 100644 (file)
@@ -92,7 +92,7 @@ class pinfo;
 
 #define MUTEX_OWNER_ANONYMOUS ((pthread_t) -1)
 
-typedef unsigned long thread_magic_t;
+typedef uint32_t thread_magic_t;
 
 /* verifyable_object should not be defined here - it's a general purpose class */
 
@@ -496,8 +496,8 @@ public:
   int shared;
   clockid_t clock_id;
 
-  unsigned long waiting;
-  unsigned long pending;
+  LONG waiting;
+  LONG pending;
   HANDLE sem_wait;
 
   pthread_mutex mtx_in;
@@ -547,14 +547,14 @@ public:
 
   int shared;
 
-  unsigned long waiting_readers;
-  unsigned long waiting_writers;
+  uint32_t waiting_readers;
+  uint32_t waiting_writers;
   pthread_t writer;
   struct RWLOCK_READER
   {
     struct RWLOCK_READER *next;
     pthread_t thread;
-    unsigned long n;
+    uint32_t n;
     RWLOCK_READER (): next (NULL), thread (pthread::self ()), n (0) {}
   } *readers;
   fast_mutex readers_mx;
@@ -637,7 +637,7 @@ public:
 
   HANDLE win32_obj_id;
   int shared;
-  long currentvalue;
+  LONG currentvalue;
   int fd;
   unsigned long long hash;
   LUID luid;
index 281d20cf3399bb874f67a9ccd1c4bd93000044b7..93b9cb59206e2674bdb88b7355ac65c7f27cb559 100644 (file)
@@ -1,7 +1,6 @@
 /* timer.cc
 
-   Copyright 2004, 2005, 2006, 2008, 2010, 2011
-   Red Hat, Inc.
+   Copyright 2004, 2005, 2006, 2008, 2010, 2011, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -125,7 +124,7 @@ timer_thread (VOID *x)
   while (1)
     {
       long long sleep_us;
-      long sleep_ms;
+      LONG sleep_ms;
       /* Account for delays in starting thread
        and sending the signal */
       now = gtod.usecs ();
@@ -449,7 +448,7 @@ alarm (unsigned int seconds)
  newt.it_value.tv_sec = seconds;
  timer_settime ((timer_t) &ttstart, 0, &newt, &oldt);
  int ret = oldt.it_value.tv_sec + (oldt.it_value.tv_nsec > 0);
- syscall_printf ("%d = alarm(%d)", ret, seconds);
+ syscall_printf ("%d = alarm(%u)", ret, seconds);
  return ret;
 }
 
@@ -461,16 +460,16 @@ ualarm (useconds_t value, useconds_t interval)
     Interpret negative arguments as zero */
  if (value > 0)
    {
-     timer.it_value.tv_sec = (unsigned int) value / 1000000;
-     timer.it_value.tv_nsec = ((unsigned int) value % 1000000) * 1000;
+     timer.it_value.tv_sec = value / 1000000;
+     timer.it_value.tv_nsec = (value % 1000000) * 1000;
    }
  if (interval > 0)
    {
-     timer.it_interval.tv_sec = (unsigned int) interval / 1000000;
-     timer.it_interval.tv_nsec = ((unsigned int) interval % 1000000) * 1000;
+     timer.it_interval.tv_sec = interval / 1000000;
+     timer.it_interval.tv_nsec = (interval % 1000000) * 1000;
    }
  timer_settime ((timer_t) &ttstart, 0, &timer, &otimer);
  useconds_t ret = otimer.it_value.tv_sec * 1000000 + (otimer.it_value.tv_nsec + 999) / 1000;
- syscall_printf ("%d = ualarm(%d , %d)", ret, value, interval);
+ syscall_printf ("%d = ualarm(%ld , %ld)", ret, value, interval);
  return ret;
 }
index 407f7c479a0ac0b19a66951b6ab125c2d9948a80..14d65354cd92c07ca1e630d1b0d6aec95a52c7c6 100644 (file)
@@ -74,9 +74,11 @@ times (struct tms *buf)
   GetProcessTimes (GetCurrentProcess (), &creation_time, &exit_time,
                   &kernel_time, &user_time);
 
-  syscall_printf ("ticks %d, CLOCKS_PER_SEC %d", ticks, CLOCKS_PER_SEC);
-  syscall_printf ("user_time %d, kernel_time %d, creation_time %d, exit_time %d",
-                 user_time, kernel_time, creation_time, exit_time);
+  syscall_printf ("ticks %D, CLOCKS_PER_SEC %d", ticks, CLOCKS_PER_SEC);
+  syscall_printf ("user_time %D, kernel_time %D, "
+                 "creation_time %D, exit_time %D",
+                 user_time, kernel_time,
+                 creation_time, exit_time);
   buf->tms_stime = __to_clock_t (&kernel_time, 0);
   buf->tms_utime = __to_clock_t (&user_time, 0);
   timeval_to_filetime (&myself->rusage_children.ru_stime, &kernel_time);
@@ -123,7 +125,7 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
   if (res)
     set_errno (EPERM);
 
-  syscall_printf ("%R = settimeofday(%x, %x)", res, tv, tz);
+  syscall_printf ("%R = settimeofday(%p, %p)", res, tv, tz);
   return res;
 }
 
@@ -321,7 +323,7 @@ time (time_t * ptr)
   if (ptr)
     *ptr = res;
 
-  syscall_printf ("%d = time(%x)", res, ptr);
+  syscall_printf ("%d = time(%p)", res, ptr);
 
   return res;
 }
@@ -425,7 +427,7 @@ utime (const char *path, const struct utimbuf *buf)
   if (buf == 0)
     return utimes (path, 0);
 
-  debug_printf ("incoming utime act %x", buf->actime);
+  debug_printf ("incoming utime act %lx", buf->actime);
   tmp[0] = time_t_to_timeval (buf->actime);
   tmp[1] = time_t_to_timeval (buf->modtime);
 
@@ -496,7 +498,7 @@ hires_ns::nsecs (bool monotonic)
 
   // FIXME: Use round() here?
   now.QuadPart = (LONGLONG) (freq * (double)
-                (now.QuadPart - (monotonic ? 0LL : primed_pc.QuadPart)));
+                (now.QuadPart - (monotonic ? 0LL : primed_pc.QuadPart)));
   return now.QuadPart;
 }
 
index 2347e929177d2545310868aebaec00afed3e2639..37f30c070bf506830f7394c5a1be2e45dc68fbd6 100644 (file)
 //; $tls::start_offset = -12700;
 //; $tls::locals = -12700;
 //; $tls::plocals = 0;
-//; $tls::local_clib = -11236;
-//; $tls::plocal_clib = 1464;
-//; $tls::__dontuse = -11236;
-//; $tls::p__dontuse = 1464;
-//; $tls::func = -10148;
-//; $tls::pfunc = 2552;
-//; $tls::saved_errno = -10144;
-//; $tls::psaved_errno = 2556;
-//; $tls::sa_flags = -10140;
-//; $tls::psa_flags = 2560;
-//; $tls::oldmask = -10136;
-//; $tls::poldmask = 2564;
-//; $tls::deltamask = -10132;
-//; $tls::pdeltamask = 2568;
-//; $tls::errno_addr = -10128;
-//; $tls::perrno_addr = 2572;
-//; $tls::sigmask = -10124;
-//; $tls::psigmask = 2576;
-//; $tls::sigwait_mask = -10120;
-//; $tls::psigwait_mask = 2580;
-//; $tls::sigwait_info = -10116;
-//; $tls::psigwait_info = 2584;
-//; $tls::signal_arrived = -10112;
-//; $tls::psignal_arrived = 2588;
-//; $tls::will_wait_for_signal = -10108;
-//; $tls::pwill_wait_for_signal = 2592;
-//; $tls::thread_context = -10104;
-//; $tls::pthread_context = 2596;
-//; $tls::thread_id = -9892;
-//; $tls::pthread_id = 2808;
-//; $tls::infodata = -9888;
-//; $tls::pinfodata = 2812;
-//; $tls::tid = -9740;
-//; $tls::ptid = 2960;
-//; $tls::_ctinfo = -9736;
-//; $tls::p_ctinfo = 2964;
-//; $tls::andreas = -9732;
-//; $tls::pandreas = 2968;
-//; $tls::wq = -9728;
-//; $tls::pwq = 2972;
-//; $tls::sig = -9700;
-//; $tls::psig = 3000;
-//; $tls::incyg = -9696;
-//; $tls::pincyg = 3004;
-//; $tls::spinning = -9692;
-//; $tls::pspinning = 3008;
-//; $tls::stacklock = -9688;
-//; $tls::pstacklock = 3012;
-//; $tls::stackptr = -9684;
-//; $tls::pstackptr = 3016;
-//; $tls::stack = -9680;
-//; $tls::pstack = 3020;
-//; $tls::initialized = -8656;
-//; $tls::pinitialized = 4044;
+//; $tls::local_clib = -11260;
+//; $tls::plocal_clib = 1440;
+//; $tls::__dontuse = -11260;
+//; $tls::p__dontuse = 1440;
+//; $tls::func = -10172;
+//; $tls::pfunc = 2528;
+//; $tls::saved_errno = -10168;
+//; $tls::psaved_errno = 2532;
+//; $tls::sa_flags = -10164;
+//; $tls::psa_flags = 2536;
+//; $tls::oldmask = -10160;
+//; $tls::poldmask = 2540;
+//; $tls::deltamask = -10156;
+//; $tls::pdeltamask = 2544;
+//; $tls::errno_addr = -10152;
+//; $tls::perrno_addr = 2548;
+//; $tls::sigmask = -10148;
+//; $tls::psigmask = 2552;
+//; $tls::sigwait_mask = -10144;
+//; $tls::psigwait_mask = 2556;
+//; $tls::sigwait_info = -10140;
+//; $tls::psigwait_info = 2560;
+//; $tls::signal_arrived = -10136;
+//; $tls::psignal_arrived = 2564;
+//; $tls::will_wait_for_signal = -10132;
+//; $tls::pwill_wait_for_signal = 2568;
+//; $tls::thread_context = -10128;
+//; $tls::pthread_context = 2572;
+//; $tls::thread_id = -9916;
+//; $tls::pthread_id = 2784;
+//; $tls::infodata = -9912;
+//; $tls::pinfodata = 2788;
+//; $tls::tid = -9764;
+//; $tls::ptid = 2936;
+//; $tls::_ctinfo = -9760;
+//; $tls::p_ctinfo = 2940;
+//; $tls::andreas = -9756;
+//; $tls::pandreas = 2944;
+//; $tls::wq = -9752;
+//; $tls::pwq = 2948;
+//; $tls::sig = -9724;
+//; $tls::psig = 2976;
+//; $tls::incyg = -9720;
+//; $tls::pincyg = 2980;
+//; $tls::spinning = -9716;
+//; $tls::pspinning = 2984;
+//; $tls::stacklock = -9712;
+//; $tls::pstacklock = 2988;
+//; $tls::stackptr = -9708;
+//; $tls::pstackptr = 2992;
+//; $tls::stack = -9704;
+//; $tls::pstack = 2996;
+//; $tls::initialized = -8680;
+//; $tls::pinitialized = 4020;
 //; __DATA__
 
 #define tls_locals (-12700)
 #define tls_plocals (0)
-#define tls_local_clib (-11236)
-#define tls_plocal_clib (1464)
-#define tls___dontuse (-11236)
-#define tls_p__dontuse (1464)
-#define tls_func (-10148)
-#define tls_pfunc (2552)
-#define tls_saved_errno (-10144)
-#define tls_psaved_errno (2556)
-#define tls_sa_flags (-10140)
-#define tls_psa_flags (2560)
-#define tls_oldmask (-10136)
-#define tls_poldmask (2564)
-#define tls_deltamask (-10132)
-#define tls_pdeltamask (2568)
-#define tls_errno_addr (-10128)
-#define tls_perrno_addr (2572)
-#define tls_sigmask (-10124)
-#define tls_psigmask (2576)
-#define tls_sigwait_mask (-10120)
-#define tls_psigwait_mask (2580)
-#define tls_sigwait_info (-10116)
-#define tls_psigwait_info (2584)
-#define tls_signal_arrived (-10112)
-#define tls_psignal_arrived (2588)
-#define tls_will_wait_for_signal (-10108)
-#define tls_pwill_wait_for_signal (2592)
-#define tls_thread_context (-10104)
-#define tls_pthread_context (2596)
-#define tls_thread_id (-9892)
-#define tls_pthread_id (2808)
-#define tls_infodata (-9888)
-#define tls_pinfodata (2812)
-#define tls_tid (-9740)
-#define tls_ptid (2960)
-#define tls__ctinfo (-9736)
-#define tls_p_ctinfo (2964)
-#define tls_andreas (-9732)
-#define tls_pandreas (2968)
-#define tls_wq (-9728)
-#define tls_pwq (2972)
-#define tls_sig (-9700)
-#define tls_psig (3000)
-#define tls_incyg (-9696)
-#define tls_pincyg (3004)
-#define tls_spinning (-9692)
-#define tls_pspinning (3008)
-#define tls_stacklock (-9688)
-#define tls_pstacklock (3012)
-#define tls_stackptr (-9684)
-#define tls_pstackptr (3016)
-#define tls_stack (-9680)
-#define tls_pstack (3020)
-#define tls_initialized (-8656)
-#define tls_pinitialized (4044)
+#define tls_local_clib (-11260)
+#define tls_plocal_clib (1440)
+#define tls___dontuse (-11260)
+#define tls_p__dontuse (1440)
+#define tls_func (-10172)
+#define tls_pfunc (2528)
+#define tls_saved_errno (-10168)
+#define tls_psaved_errno (2532)
+#define tls_sa_flags (-10164)
+#define tls_psa_flags (2536)
+#define tls_oldmask (-10160)
+#define tls_poldmask (2540)
+#define tls_deltamask (-10156)
+#define tls_pdeltamask (2544)
+#define tls_errno_addr (-10152)
+#define tls_perrno_addr (2548)
+#define tls_sigmask (-10148)
+#define tls_psigmask (2552)
+#define tls_sigwait_mask (-10144)
+#define tls_psigwait_mask (2556)
+#define tls_sigwait_info (-10140)
+#define tls_psigwait_info (2560)
+#define tls_signal_arrived (-10136)
+#define tls_psignal_arrived (2564)
+#define tls_will_wait_for_signal (-10132)
+#define tls_pwill_wait_for_signal (2568)
+#define tls_thread_context (-10128)
+#define tls_pthread_context (2572)
+#define tls_thread_id (-9916)
+#define tls_pthread_id (2784)
+#define tls_infodata (-9912)
+#define tls_pinfodata (2788)
+#define tls_tid (-9764)
+#define tls_ptid (2936)
+#define tls__ctinfo (-9760)
+#define tls_p_ctinfo (2940)
+#define tls_andreas (-9756)
+#define tls_pandreas (2944)
+#define tls_wq (-9752)
+#define tls_pwq (2948)
+#define tls_sig (-9724)
+#define tls_psig (2976)
+#define tls_incyg (-9720)
+#define tls_pincyg (2980)
+#define tls_spinning (-9716)
+#define tls_pspinning (2984)
+#define tls_stacklock (-9712)
+#define tls_pstacklock (2988)
+#define tls_stackptr (-9708)
+#define tls_pstackptr (2992)
+#define tls_stack (-9704)
+#define tls_pstack (2996)
+#define tls_initialized (-8680)
+#define tls_pinitialized (4020)
diff --git a/winsup/cygwin/tlsoffsets64.h b/winsup/cygwin/tlsoffsets64.h
new file mode 100644 (file)
index 0000000..f85dae2
--- /dev/null
@@ -0,0 +1,117 @@
+//;# autogenerated:  Do not edit.
+
+//; $tls::start_offset = -12800;
+//; $tls::locals = -12800;
+//; $tls::plocals = 0;
+//; $tls::local_clib = -11200;
+//; $tls::plocal_clib = 1600;
+//; $tls::__dontuse = -11200;
+//; $tls::p__dontuse = 1600;
+//; $tls::func = -9312;
+//; $tls::pfunc = 3488;
+//; $tls::saved_errno = -9304;
+//; $tls::psaved_errno = 3496;
+//; $tls::sa_flags = -9300;
+//; $tls::psa_flags = 3500;
+//; $tls::oldmask = -9296;
+//; $tls::poldmask = 3504;
+//; $tls::deltamask = -9288;
+//; $tls::pdeltamask = 3512;
+//; $tls::errno_addr = -9280;
+//; $tls::perrno_addr = 3520;
+//; $tls::sigmask = -9272;
+//; $tls::psigmask = 3528;
+//; $tls::sigwait_mask = -9264;
+//; $tls::psigwait_mask = 3536;
+//; $tls::sigwait_info = -9256;
+//; $tls::psigwait_info = 3544;
+//; $tls::signal_arrived = -9248;
+//; $tls::psignal_arrived = 3552;
+//; $tls::will_wait_for_signal = -9240;
+//; $tls::pwill_wait_for_signal = 3560;
+//; $tls::thread_context = -9232;
+//; $tls::pthread_context = 3568;
+//; $tls::thread_id = -8400;
+//; $tls::pthread_id = 4400;
+//; $tls::infodata = -8396;
+//; $tls::pinfodata = 4404;
+//; $tls::tid = -8248;
+//; $tls::ptid = 4552;
+//; $tls::_ctinfo = -8240;
+//; $tls::p_ctinfo = 4560;
+//; $tls::andreas = -8232;
+//; $tls::pandreas = 4568;
+//; $tls::wq = -8224;
+//; $tls::pwq = 4576;
+//; $tls::sig = -8176;
+//; $tls::psig = 4624;
+//; $tls::incyg = -8172;
+//; $tls::pincyg = 4628;
+//; $tls::spinning = -8168;
+//; $tls::pspinning = 4632;
+//; $tls::stacklock = -8164;
+//; $tls::pstacklock = 4636;
+//; $tls::stackptr = -8160;
+//; $tls::pstackptr = 4640;
+//; $tls::stack = -8152;
+//; $tls::pstack = 4648;
+//; $tls::initialized = -6104;
+//; $tls::pinitialized = 6696;
+//; __DATA__
+
+#define tls_locals (-12800)
+#define tls_plocals (0)
+#define tls_local_clib (-11200)
+#define tls_plocal_clib (1600)
+#define tls___dontuse (-11200)
+#define tls_p__dontuse (1600)
+#define tls_func (-9312)
+#define tls_pfunc (3488)
+#define tls_saved_errno (-9304)
+#define tls_psaved_errno (3496)
+#define tls_sa_flags (-9300)
+#define tls_psa_flags (3500)
+#define tls_oldmask (-9296)
+#define tls_poldmask (3504)
+#define tls_deltamask (-9288)
+#define tls_pdeltamask (3512)
+#define tls_errno_addr (-9280)
+#define tls_perrno_addr (3520)
+#define tls_sigmask (-9272)
+#define tls_psigmask (3528)
+#define tls_sigwait_mask (-9264)
+#define tls_psigwait_mask (3536)
+#define tls_sigwait_info (-9256)
+#define tls_psigwait_info (3544)
+#define tls_signal_arrived (-9248)
+#define tls_psignal_arrived (3552)
+#define tls_will_wait_for_signal (-9240)
+#define tls_pwill_wait_for_signal (3560)
+#define tls_thread_context (-9232)
+#define tls_pthread_context (3568)
+#define tls_thread_id (-8400)
+#define tls_pthread_id (4400)
+#define tls_infodata (-8396)
+#define tls_pinfodata (4404)
+#define tls_tid (-8248)
+#define tls_ptid (4552)
+#define tls__ctinfo (-8240)
+#define tls_p_ctinfo (4560)
+#define tls_andreas (-8232)
+#define tls_pandreas (4568)
+#define tls_wq (-8224)
+#define tls_pwq (4576)
+#define tls_sig (-8176)
+#define tls_psig (4624)
+#define tls_incyg (-8172)
+#define tls_pincyg (4628)
+#define tls_spinning (-8168)
+#define tls_pspinning (4632)
+#define tls_stacklock (-8164)
+#define tls_pstacklock (4636)
+#define tls_stackptr (-8160)
+#define tls_pstackptr (4640)
+#define tls_stack (-8152)
+#define tls_pstack (4648)
+#define tls_initialized (-6104)
+#define tls_pinitialized (6696)
index 515e706a08b999efa584759f8c033857f439fcc4..d27300bd0f316c8aae045d77cbb1c17430472f4d 100644 (file)
@@ -1,7 +1,7 @@
 /* tty.cc
 
    Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009,
-   2010, 2011 Red Hat, Inc.
+   2010, 2011, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -163,7 +163,7 @@ tty::not_allocated (HANDLE& r, HANDLE& w)
   /* Attempt to open the from-master side of the tty.  If it is accessible
      then it exists although we may not have privileges to actually use it. */
   char pipename[sizeof("ptyNNNN-from-master")];
-  __small_sprintf (pipename, "pty%d-from-master", get_unit ());
+  __small_sprintf (pipename, "pty%d-from-master", get_minor ());
   /* fhandler_pipe::create returns 0 when creation succeeds */
   return fhandler_pipe::create (&sec_none, &r, &w,
                                fhandler_pty_common::pipesize, pipename,
@@ -202,7 +202,7 @@ HANDLE
 tty::open_mutex (const char *mutex, ACCESS_MASK access)
 {
   char buf[MAX_PATH];
-  shared_name (buf, mutex, get_unit ());
+  shared_name (buf, mutex, get_minor ());
   return OpenMutex (access, TRUE, buf);
 }
 
@@ -210,7 +210,7 @@ HANDLE
 tty::open_inuse (ACCESS_MASK access)
 {
   char buf[MAX_PATH];
-  shared_name (buf, TTY_SLAVE_ALIVE, get_unit ());
+  shared_name (buf, TTY_SLAVE_ALIVE, get_minor ());
   return OpenEvent (access, FALSE, buf);
 }
 
@@ -220,11 +220,11 @@ tty::create_inuse (PSECURITY_ATTRIBUTES sa)
   HANDLE h;
   char buf[MAX_PATH];
 
-  shared_name (buf, TTY_SLAVE_ALIVE, get_unit ());
+  shared_name (buf, TTY_SLAVE_ALIVE, get_minor ());
   h = CreateEvent (sa, TRUE, FALSE, buf);
   termios_printf ("%s %p", buf, h);
   if (!h)
-    termios_printf ("couldn't open inuse event, %E", buf);
+    termios_printf ("couldn't open inuse event %s, %E", buf);
   return h;
 }
 
@@ -245,7 +245,7 @@ tty::get_event (const char *fmt, PSECURITY_ATTRIBUTES sa, BOOL manual_reset)
   HANDLE hev;
   char buf[MAX_PATH];
 
-  shared_name (buf, fmt, get_unit ());
+  shared_name (buf, fmt, get_minor ());
   if (!sa)
     sa = &sec_all;
   if (!(hev = CreateEvent (sa, manual_reset, FALSE, buf)))
index b05ed97809c3e135ea7461e009de9b785e6f7085..f7a80e10ff12b3932f9004a6bd1eba3fc81ce41a 100644 (file)
@@ -69,9 +69,9 @@ public:
   int ioctl_retval;
   int write_error;
 
-  void setntty (_major_t t, int n) {ntty = (fh_devices) FHDEV (t, n);}
-  int getntty () const {return ntty;}
-  int get_unit () const {return device::minor (ntty);}
+  void setntty (_major_t t, _minor_t n) {ntty = (fh_devices) FHDEV (t, n);}
+  dev_t getntty () const {return ntty;}
+  _minor_t get_minor () const {return device::minor (ntty);}
   pid_t getpgid () const {return pgid;}
   void setpgid (int pid) {pgid = pid;}
   int getsid () const {return sid;}
@@ -90,7 +90,30 @@ class tty: public tty_min
 public:
   pid_t master_pid;    /* PID of tty master process */
 
-  HANDLE from_master, to_master;
+private:
+  /* Since tty is shared, the HANDLEs must be 32 and 64 bit clean.  The below
+     code makes sure of that by setting the upper 4 byte of the union to 0
+     when writing the handle value from a 32 bit process.  Fortunately the
+     actual values are 32 bit on both platforms, so the HANDLES can be
+     used on both platforms. */
+  union {
+    HANDLE _from_master;
+    LARGE_INTEGER _fm_dummy;
+  };
+  union {    
+    HANDLE _to_master;
+    LARGE_INTEGER _tm_dummy;
+  };
+public:
+  HANDLE from_master() const { return _from_master; }
+  HANDLE to_master() const { return _to_master; }
+#ifdef __x86_64__
+  void set_from_master (HANDLE h) { _from_master = h; }
+  void set_to_master (HANDLE h) { _to_master = h; }
+#else
+  void set_from_master (HANDLE h) { _fm_dummy.HighPart = 0; _from_master = h; }
+  void set_to_master (HANDLE h) { _tm_dummy.HighPart = 0; _to_master = h; }
+#endif
 
   int read_retval;
   bool was_opened;     /* True if opened at least once. */
index 6cd6c6436633dd7ab0a70f59f8d6e6b01fd45536..4ca901f356b955b2b09994abc1a69a37d7670104 100644 (file)
@@ -66,14 +66,14 @@ cygheap_user::init ()
   status = NtQueryInformationToken (hProcToken, TokenPrimaryGroup,
                                    &groups.pgsid, sizeof (cygsid), &size);
   if (!NT_SUCCESS (status))
-    system_printf ("NtQueryInformationToken (TokenPrimaryGroup), %p", status);
+    system_printf ("NtQueryInformationToken (TokenPrimaryGroup), %y", status);
 
   /* Get the SID from current process and store it in effec_cygsid */
   status = NtQueryInformationToken (hProcToken, TokenUser, &effec_cygsid,
                                    sizeof (cygsid), &size);
   if (!NT_SUCCESS (status))
     {
-      system_printf ("NtQueryInformationToken (TokenUser), %p", status);
+      system_printf ("NtQueryInformationToken (TokenUser), %y", status);
       return;
     }
 
@@ -81,7 +81,7 @@ cygheap_user::init ()
   status = NtSetInformationToken (hProcToken, TokenOwner, &effec_cygsid,
                                  sizeof (cygsid));
   if (!NT_SUCCESS (status))
-    debug_printf ("NtSetInformationToken(TokenOwner), %p", status);
+    debug_printf ("NtSetInformationToken(TokenOwner), %y", status);
 
   /* Standard way to build a security descriptor with the usual DACL */
   PSECURITY_ATTRIBUTES sa_buf = (PSECURITY_ATTRIBUTES) alloca (1024);
@@ -100,10 +100,10 @@ cygheap_user::init ()
       status = NtSetInformationToken (hProcToken, TokenDefaultDacl, &dacl,
                                      sizeof (dacl));
       if (!NT_SUCCESS (status))
-       system_printf ("NtSetInformationToken (TokenDefaultDacl), %p", status);
+       system_printf ("NtSetInformationToken (TokenDefaultDacl), %y", status);
       if ((status = NtSetSecurityObject (NtCurrentProcess (),
                                         DACL_SECURITY_INFORMATION, psd)))
-       system_printf ("NtSetSecurityObject, %lx", status);
+       system_printf ("NtSetSecurityObject, %y", status);
     }
   else
     system_printf("Cannot get dacl, %E");
@@ -136,7 +136,7 @@ internal_getlogin (cygheap_user &user)
                                                       TokenPrimaryGroup,
                                                       &gsid, sizeof gsid);
              if (!NT_SUCCESS (status))
-               debug_printf ("NtSetInformationToken (TokenPrimaryGroup), %p",
+               debug_printf ("NtSetInformationToken (TokenPrimaryGroup), %y",
                              status);
              else
                user.groups.pgsid = gsid;
@@ -211,53 +211,69 @@ getlogin (void)
   return username;
 }
 
-extern "C" __uid32_t
+extern "C" uid_t
 getuid32 (void)
 {
   return cygheap->user.real_uid;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getuid32, getuid)
+#else
 extern "C" __uid16_t
 getuid (void)
 {
   return cygheap->user.real_uid;
 }
+#endif
 
-extern "C" __gid32_t
+extern "C" gid_t
 getgid32 (void)
 {
   return cygheap->user.real_gid;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getgid32, getgid)
+#else
 extern "C" __gid16_t
 getgid (void)
 {
   return cygheap->user.real_gid;
 }
+#endif
 
-extern "C" __uid32_t
+extern "C" uid_t
 geteuid32 (void)
 {
   return myself->uid;
 }
 
-extern "C" __uid16_t
+#ifdef __x86_64__
+EXPORT_ALIAS (geteuid32, geteuid)
+#else
+extern "C" uid_t
 geteuid (void)
 {
   return myself->uid;
 }
+#endif
 
-extern "C" __gid32_t
+extern "C" gid_t
 getegid32 (void)
 {
   return myself->gid;
 }
 
+#ifdef __x86_64__
+EXPORT_ALIAS (getegid32, getegid)
+#else
 extern "C" __gid16_t
 getegid (void)
 {
   return myself->gid;
 }
+#endif
 
 /* Not quite right - cuserid can change, getlogin can't */
 extern "C" char *
@@ -569,14 +585,14 @@ pwdgrp::load (const wchar_t *rel_path)
                       | FILE_OPEN_FOR_BACKUP_INTENT);
   if (!NT_SUCCESS (status))
     {
-      paranoid_printf ("NtOpenFile(%S) failed, status %p", &upath, status);
+      paranoid_printf ("NtOpenFile(%S) failed, status %y", &upath, status);
       goto out;
     }
   status = NtQueryInformationFile (fh, &io, &fsi, sizeof fsi,
                                   FileStandardInformation);
   if (!NT_SUCCESS (status))
     {
-      paranoid_printf ("NtQueryInformationFile(%S) failed, status %p",
+      paranoid_printf ("NtQueryInformationFile(%S) failed, status %y",
                       &upath, status);
       goto out;
     }
@@ -587,14 +603,14 @@ pwdgrp::load (const wchar_t *rel_path)
   buf = (char *) malloc (fsi.EndOfFile.LowPart + 1);
   if (!buf)
     {
-      paranoid_printf ("malloc (%d) failed", fsi.EndOfFile.LowPart);
+      paranoid_printf ("malloc (%u) failed", fsi.EndOfFile.LowPart);
       goto out;
     }
   status = NtReadFile (fh, NULL, NULL, NULL, &io, buf, fsi.EndOfFile.LowPart,
                       NULL, NULL);
   if (!NT_SUCCESS (status))
     {
-      paranoid_printf ("NtReadFile(%S) failed, status %p", &upath, status);
+      paranoid_printf ("NtReadFile(%S) failed, status %y", &upath, status);
       free (buf);
       goto out;
     }
index 8dd97277e2a00d1142414037f864291ff94e86c2..fca5a3c015b87192c16ff96f1a25decc4544d13c 100644 (file)
@@ -69,7 +69,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
       w->rusage = r;
       sigproc_printf ("calling proc_subproc, pid %d, options %d",
                      w->pid, w->options);
-      if (!proc_subproc (PROC_WAIT, (DWORD) w))
+      if (!proc_subproc (PROC_WAIT, (uintptr_t) w))
        {
          set_errno (ENOSYS);
          paranoid_printf ("proc_subproc returned 0");
@@ -110,7 +110,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
       break;
     }
 
-  syscall_printf ("%R = wait4(%d, %p, %d, %p)", res, intpid, w->status, options, r);
+  syscall_printf ("%R = wait4(%d, %y, %d, %p)", res, intpid, w->status, options, r);
   w->status = -1;
   return res;
 }
index d9c53cfbaa5c5493391b6a390157d1ff27497f43..666f74a2d2f20e3ef8ac7dcb5abbe60f1a3d1af2 100644 (file)
@@ -11,7 +11,6 @@ details. */
 #ifndef _WINBASE2_H
 #define _WINBASE2_H
 
-#ifndef __x86_64__
 extern __inline__ LONG
 ilockcmpexch (volatile LONG *t, LONG v, LONG c)
 {
@@ -29,7 +28,30 @@ ilockcmpexch (volatile LONG *t, LONG v, LONG c)
 #undef InterlockedCompareExchange
 #define InterlockedCompareExchange ilockcmpexch
 #undef InterlockedCompareExchangePointer
+
+#ifdef __x86_64__
+extern __inline__ LONGLONG
+ilockcmpexch64 (volatile LONGLONG *t, LONGLONG v, LONGLONG c)
+{
+  return
+  ({
+    register LONGLONG ret __asm ("%rax");
+    __asm __volatile ("lock cmpxchgq %2, %1"
+       : "=a" (ret), "=m" (*t)
+       : "r" (v), "m" (*t), "0" (c)
+       : "memory");
+    ret;
+  });
+}
+
+#define InterlockedCompareExchange64 ilockcmpexch64
+#define InterlockedCompareExchangePointer(d,e,c) \
+    (PVOID)InterlockedCompareExchange64((LONGLONG volatile *)(d),(LONGLONG)(e),(LONGLONG)(c))
+
+#else
+
 #define InterlockedCompareExchangePointer(d,e,c) \
     (PVOID)InterlockedCompareExchange((LONG volatile *)(d),(LONG)(e),(LONG)(c))
+
 #endif /* !__x86_64 */
 #endif /*_WINBASE2_H*/
index 30c4eb90833dcdf79d1231345a3497cca149c0d4..9964467e359b64d256e85817b4047792a5dd498d 100644 (file)
@@ -21,185 +21,32 @@ details. */
    puzzled that this has never been noticed before... */
 
 /* Minimal set of capabilities required to run Cygwin. */
-#define wincap_minimal wincap_2000
-
-wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
-  max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
-  is_server:false,
-  has_physical_mem_access:true,
-  has_create_global_privilege:false,
-  has_ioctl_storage_get_media_types_ex:false,
-  has_disk_ex_ioctls:false,
-  has_buggy_restart_scan:true,
-  has_mandatory_integrity_control:false,
-  needs_logon_sid_in_sid_list:true,
-  needs_count_in_si_lpres2:false,
-  has_recycle_dot_bin:false,
-  has_gaa_prefixes:false,
-  has_gaa_on_link_prefix:false,
-  has_gaa_largeaddress_bug:false,
-  supports_all_posix_ai_flags:false,
-  has_restricted_stack_args:false,
-  has_transactions:false,
-  has_recvmsg:false,
-  has_sendmsg:false,
-  has_broken_udf:true,
-  has_console_handle_problem:false,
-  has_broken_alloc_console:false,
-  has_always_all_codepages:false,
-  has_localenames:false,
-  has_fast_cwd:false,
-  has_restricted_raw_disk_access:false,
-  use_dont_resolve_hack:false,
-  has_stack_size_param_is_a_reservation:false,
-  has_console_logon_sid:false,
-  wow64_has_secondary_stack:false,
-  has_program_compatibility_assistant:false,
-  kernel_is_always_casesensitive:true,
-  terminate_thread_frees_stack:false,
-};
-
-wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
-  max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
-  is_server:false,
-  has_physical_mem_access:true,
-  has_create_global_privilege:true,
-  has_ioctl_storage_get_media_types_ex:false,
-  has_disk_ex_ioctls:false,
-  has_buggy_restart_scan:true,
-  has_mandatory_integrity_control:false,
-  needs_logon_sid_in_sid_list:true,
-  needs_count_in_si_lpres2:false,
-  has_recycle_dot_bin:false,
-  has_gaa_prefixes:false,
-  has_gaa_on_link_prefix:false,
-  has_gaa_largeaddress_bug:false,
-  supports_all_posix_ai_flags:false,
-  has_restricted_stack_args:false,
-  has_transactions:false,
-  has_recvmsg:false,
-  has_sendmsg:false,
-  has_broken_udf:true,
-  has_console_handle_problem:false,
-  has_broken_alloc_console:false,
-  has_always_all_codepages:false,
-  has_localenames:false,
-  has_fast_cwd:false,
-  has_restricted_raw_disk_access:false,
-  use_dont_resolve_hack:false,
-  has_stack_size_param_is_a_reservation:false,
-  has_console_logon_sid:false,
-  wow64_has_secondary_stack:false,
-  has_program_compatibility_assistant:false,
-  kernel_is_always_casesensitive:true,
-  terminate_thread_frees_stack:false,
-};
-
-wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
-  max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
-  is_server:false,
-  has_physical_mem_access:true,
-  has_create_global_privilege:false,
-  has_ioctl_storage_get_media_types_ex:true,
-  has_disk_ex_ioctls:true,
-  has_buggy_restart_scan:false,
-  has_mandatory_integrity_control:false,
-  needs_logon_sid_in_sid_list:false,
-  needs_count_in_si_lpres2:false,
-  has_recycle_dot_bin:false,
-  has_gaa_prefixes:false,
-  has_gaa_on_link_prefix:false,
-  has_gaa_largeaddress_bug:false,
-  supports_all_posix_ai_flags:false,
-  has_restricted_stack_args:false,
-  has_transactions:false,
-  has_recvmsg:true,
-  has_sendmsg:false,
-  has_broken_udf:true,
-  has_console_handle_problem:false,
-  has_broken_alloc_console:false,
-  has_always_all_codepages:false,
-  has_localenames:false,
-  has_fast_cwd:false,
-  has_restricted_raw_disk_access:false,
-  use_dont_resolve_hack:true,
-  has_stack_size_param_is_a_reservation:true,
-  has_console_logon_sid:false,
-  wow64_has_secondary_stack:false,
-  has_program_compatibility_assistant:false,
-  kernel_is_always_casesensitive:false,
-  terminate_thread_frees_stack:false,
-};
-
-wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
-  max_sys_priv:SE_MANAGE_VOLUME_PRIVILEGE,
-  is_server:false,
-  has_physical_mem_access:true,
-  has_create_global_privilege:false,
-  has_ioctl_storage_get_media_types_ex:true,
-  has_disk_ex_ioctls:true,
-  has_buggy_restart_scan:false,
-  has_mandatory_integrity_control:false,
-  needs_logon_sid_in_sid_list:false,
-  needs_count_in_si_lpres2:false,
-  has_recycle_dot_bin:false,
-  has_gaa_prefixes:true,
-  has_gaa_on_link_prefix:false,
-  has_gaa_largeaddress_bug:false,
-  supports_all_posix_ai_flags:false,
-  has_restricted_stack_args:false,
-  has_transactions:false,
-  has_recvmsg:true,
-  has_sendmsg:false,
-  has_broken_udf:true,
-  has_console_handle_problem:false,
-  has_broken_alloc_console:false,
-  has_always_all_codepages:false,
-  has_localenames:false,
-  has_fast_cwd:false,
-  has_restricted_raw_disk_access:false,
-  use_dont_resolve_hack:true,
-  has_stack_size_param_is_a_reservation:true,
-  has_console_logon_sid:false,
-  wow64_has_secondary_stack:false,
-  has_program_compatibility_assistant:false,
-  kernel_is_always_casesensitive:false,
-  terminate_thread_frees_stack:false,
-};
+#define wincap_minimal wincap_xpsp2
 
 wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
   max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
   is_server:false,
   has_physical_mem_access:true,
-  has_create_global_privilege:true,
-  has_ioctl_storage_get_media_types_ex:true,
-  has_disk_ex_ioctls:true,
-  has_buggy_restart_scan:false,
   has_mandatory_integrity_control:false,
-  needs_logon_sid_in_sid_list:false,
   needs_count_in_si_lpres2:false,
   has_recycle_dot_bin:false,
-  has_gaa_prefixes:true,
   has_gaa_on_link_prefix:false,
   has_gaa_largeaddress_bug:false,
   supports_all_posix_ai_flags:false,
   has_restricted_stack_args:false,
   has_transactions:false,
-  has_recvmsg:true,
   has_sendmsg:false,
   has_broken_udf:true,
-  has_console_handle_problem:false,
   has_broken_alloc_console:false,
   has_always_all_codepages:false,
   has_localenames:false,
   has_fast_cwd:false,
   has_restricted_raw_disk_access:false,
   use_dont_resolve_hack:true,
-  has_stack_size_param_is_a_reservation:true,
   has_console_logon_sid:false,
   wow64_has_secondary_stack:false,
   has_program_compatibility_assistant:false,
-  kernel_is_always_casesensitive:false,
+  has_pipe_reject_remote_clients:false,
   terminate_thread_frees_stack:false,
 };
 
@@ -207,35 +54,26 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
   max_sys_priv:SE_CREATE_GLOBAL_PRIVILEGE,
   is_server:false,
   has_physical_mem_access:false,
-  has_create_global_privilege:true,
-  has_ioctl_storage_get_media_types_ex:true,
-  has_disk_ex_ioctls:true,
-  has_buggy_restart_scan:false,
   has_mandatory_integrity_control:false,
-  needs_logon_sid_in_sid_list:false,
   needs_count_in_si_lpres2:false,
   has_recycle_dot_bin:false,
-  has_gaa_prefixes:true,
   has_gaa_on_link_prefix:false,
   has_gaa_largeaddress_bug:false,
   supports_all_posix_ai_flags:false,
   has_restricted_stack_args:true,
   has_transactions:false,
-  has_recvmsg:true,
   has_sendmsg:false,
   has_broken_udf:true,
-  has_console_handle_problem:false,
   has_broken_alloc_console:false,
   has_always_all_codepages:false,
   has_localenames:false,
   has_fast_cwd:false,
   has_restricted_raw_disk_access:false,
   use_dont_resolve_hack:true,
-  has_stack_size_param_is_a_reservation:true,
   has_console_logon_sid:false,
   wow64_has_secondary_stack:true,
   has_program_compatibility_assistant:false,
-  kernel_is_always_casesensitive:false,
+  has_pipe_reject_remote_clients:false,
   terminate_thread_frees_stack:false,
 };
 
@@ -243,35 +81,26 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
   max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE,
   is_server:false,
   has_physical_mem_access:false,
-  has_create_global_privilege:true,
-  has_ioctl_storage_get_media_types_ex:true,
-  has_disk_ex_ioctls:true,
-  has_buggy_restart_scan:false,
   has_mandatory_integrity_control:true,
-  needs_logon_sid_in_sid_list:false,
   needs_count_in_si_lpres2:true,
   has_recycle_dot_bin:true,
-  has_gaa_prefixes:true,
   has_gaa_on_link_prefix:true,
   has_gaa_largeaddress_bug:true,
   supports_all_posix_ai_flags:true,
   has_restricted_stack_args:false,
   has_transactions:true,
-  has_recvmsg:true,
   has_sendmsg:true,
   has_broken_udf:false,
-  has_console_handle_problem:false,
   has_broken_alloc_console:false,
   has_always_all_codepages:true,
   has_localenames:true,
   has_fast_cwd:true,
   has_restricted_raw_disk_access:true,
   use_dont_resolve_hack:false,
-  has_stack_size_param_is_a_reservation:true,
   has_console_logon_sid:false,
   wow64_has_secondary_stack:false,
   has_program_compatibility_assistant:true,
-  kernel_is_always_casesensitive:false,
+  has_pipe_reject_remote_clients:true,
   terminate_thread_frees_stack:true,
 };
 
@@ -279,35 +108,26 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
   max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE,
   is_server:false,
   has_physical_mem_access:false,
-  has_create_global_privilege:true,
-  has_ioctl_storage_get_media_types_ex:true,
-  has_disk_ex_ioctls:true,
-  has_buggy_restart_scan:false,
   has_mandatory_integrity_control:true,
-  needs_logon_sid_in_sid_list:false,
   needs_count_in_si_lpres2:false,
   has_recycle_dot_bin:true,
-  has_gaa_prefixes:true,
   has_gaa_on_link_prefix:true,
   has_gaa_largeaddress_bug:true,
   supports_all_posix_ai_flags:true,
   has_restricted_stack_args:false,
   has_transactions:true,
-  has_recvmsg:true,
   has_sendmsg:true,
   has_broken_udf:false,
-  has_console_handle_problem:true,
   has_broken_alloc_console:true,
   has_always_all_codepages:true,
   has_localenames:true,
   has_fast_cwd:true,
   has_restricted_raw_disk_access:true,
   use_dont_resolve_hack:false,
-  has_stack_size_param_is_a_reservation:true,
   has_console_logon_sid:true,
   wow64_has_secondary_stack:false,
   has_program_compatibility_assistant:true,
-  kernel_is_always_casesensitive:false,
+  has_pipe_reject_remote_clients:true,
   terminate_thread_frees_stack:true,
 };
 
@@ -315,35 +135,26 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = {
   max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE,
   is_server:false,
   has_physical_mem_access:false,
-  has_create_global_privilege:true,
-  has_ioctl_storage_get_media_types_ex:true,
-  has_disk_ex_ioctls:true,
-  has_buggy_restart_scan:false,
   has_mandatory_integrity_control:true,
-  needs_logon_sid_in_sid_list:false,
   needs_count_in_si_lpres2:false,
   has_recycle_dot_bin:true,
-  has_gaa_prefixes:true,
   has_gaa_on_link_prefix:true,
   has_gaa_largeaddress_bug:false,
   supports_all_posix_ai_flags:true,
   has_restricted_stack_args:false,
   has_transactions:true,
-  has_recvmsg:true,
   has_sendmsg:true,
   has_broken_udf:false,
-  has_console_handle_problem:true,
   has_broken_alloc_console:true,
   has_always_all_codepages:true,
   has_localenames:true,
   has_fast_cwd:true,
   has_restricted_raw_disk_access:true,
   use_dont_resolve_hack:false,
-  has_stack_size_param_is_a_reservation:true,
   has_console_logon_sid:true,
   wow64_has_secondary_stack:false,
   has_program_compatibility_assistant:true,
-  kernel_is_always_casesensitive:false,
+  has_pipe_reject_remote_clients:true,
   terminate_thread_frees_stack:true,
 };
 
@@ -364,24 +175,8 @@ wincapc::init ()
       case 5:
        switch (version.dwMinorVersion)
          {
-           case 0:
-             if (version.wServicePackMajor < 4)
-               caps = &wincap_2000;
-             else
-               caps = &wincap_2000sp4;
-             break;
-
            case 1:
-             caps = &wincap_xp;
-             switch (version.wServicePackMajor)
-               {
-               case 0:
-                 caps = &wincap_xp;
-               case 1:
-                 caps = &wincap_xpsp1;
-               default:
-                 caps = &wincap_xpsp2;
-               }
+             caps = &wincap_xpsp2;
              break;
 
            default:
@@ -408,10 +203,14 @@ wincapc::init ()
     }
 
   ((wincaps *)caps)->is_server = (version.wProductType != VER_NT_WORKSTATION);
+#ifdef __x86_64__
+  wow64 = 0;
+#else
   if (NT_SUCCESS (NtQueryInformationProcess (NtCurrentProcess (),
                                             ProcessWow64Information,
                                             &wow64, sizeof wow64, NULL))
       && !wow64)
+#endif
     {
       ((wincaps *)caps)->needs_count_in_si_lpres2 = false;
       ((wincaps *)caps)->has_restricted_stack_args = false;
index d3823e0c3e1225f4e1dc2ff3ae834f16e96900a2..1004a5e469cf1ca581959f625da2e2be93ce8678 100644 (file)
@@ -17,35 +17,26 @@ struct wincaps
   DWORD    max_sys_priv;
   unsigned is_server                                    : 1;
   unsigned has_physical_mem_access                      : 1;
-  unsigned has_create_global_privilege                 : 1;
-  unsigned has_ioctl_storage_get_media_types_ex                : 1;
-  unsigned has_disk_ex_ioctls                          : 1;
-  unsigned has_buggy_restart_scan                      : 1;
   unsigned has_mandatory_integrity_control             : 1;
-  unsigned needs_logon_sid_in_sid_list                 : 1;
   unsigned needs_count_in_si_lpres2                    : 1;
   unsigned has_recycle_dot_bin                         : 1;
-  unsigned has_gaa_prefixes                            : 1;
   unsigned has_gaa_on_link_prefix                      : 1;
   unsigned has_gaa_largeaddress_bug                    : 1;
   unsigned supports_all_posix_ai_flags                 : 1;
   unsigned has_restricted_stack_args                   : 1;
   unsigned has_transactions                            : 1;
-  unsigned has_recvmsg                                 : 1;
   unsigned has_sendmsg                                 : 1;
   unsigned has_broken_udf                              : 1;
-  unsigned has_console_handle_problem                  : 1;
   unsigned has_broken_alloc_console                    : 1;
   unsigned has_always_all_codepages                    : 1;
   unsigned has_localenames                             : 1;
   unsigned has_fast_cwd                                        : 1;
   unsigned has_restricted_raw_disk_access              : 1;
   unsigned use_dont_resolve_hack                       : 1;
-  unsigned has_stack_size_param_is_a_reservation       : 1;
   unsigned has_console_logon_sid                       : 1;
   unsigned wow64_has_secondary_stack                   : 1;
   unsigned has_program_compatibility_assistant         : 1;
-  unsigned kernel_is_always_casesensitive              : 1;
+  unsigned has_pipe_reject_remote_clients              : 1;
   unsigned terminate_thread_frees_stack                        : 1;
 };
 
@@ -54,53 +45,47 @@ class wincapc
   SYSTEM_INFO      system_info;
   OSVERSIONINFOEX  version;
   char             osnam[40];
-  ULONG            wow64;
+  ULONG_PTR        wow64;
   void             *caps;
 
 public:
   void init ();
 
   const DWORD cpu_count () const { return system_info.dwNumberOfProcessors; }
-  const DWORD page_size () const { return system_info.dwPageSize; }
-  const DWORD allocation_granularity () const
-                             { return system_info.dwAllocationGranularity; }
+  /* The casts to size_t make sure that the returned value has the size of
+     a pointer on any system.  This is important when using them for bit
+     mask operations, like in roundup2. */
+  const size_t page_size () const { return (size_t) system_info.dwPageSize; }
+  const size_t allocation_granularity () const
+                    { return (size_t) system_info.dwAllocationGranularity; }
   const char *osname () const { return osnam; }
-  const bool is_wow64 () const { return wow64; }
+  const bool is_wow64 () const { return !!wow64; }
 
 #define IMPLEMENT(cap) cap() const { return ((wincaps *) this->caps)->cap; }
 
   DWORD IMPLEMENT (max_sys_priv)
   bool  IMPLEMENT (is_server)
   bool  IMPLEMENT (has_physical_mem_access)
-  bool  IMPLEMENT (has_create_global_privilege)
-  bool IMPLEMENT (has_ioctl_storage_get_media_types_ex)
-  bool IMPLEMENT (has_disk_ex_ioctls)
-  bool IMPLEMENT (has_buggy_restart_scan)
   bool IMPLEMENT (has_mandatory_integrity_control)
-  bool IMPLEMENT (needs_logon_sid_in_sid_list)
   bool IMPLEMENT (needs_count_in_si_lpres2)
   bool IMPLEMENT (has_recycle_dot_bin)
-  bool IMPLEMENT (has_gaa_prefixes)
   bool IMPLEMENT (has_gaa_on_link_prefix)
   bool IMPLEMENT (has_gaa_largeaddress_bug)
   bool IMPLEMENT (supports_all_posix_ai_flags)
   bool IMPLEMENT (has_restricted_stack_args)
   bool IMPLEMENT (has_transactions)
-  bool IMPLEMENT (has_recvmsg)
   bool IMPLEMENT (has_sendmsg)
   bool IMPLEMENT (has_broken_udf)
-  bool IMPLEMENT (has_console_handle_problem)
   bool IMPLEMENT (has_broken_alloc_console)
   bool IMPLEMENT (has_always_all_codepages)
   bool IMPLEMENT (has_localenames)
   bool IMPLEMENT (has_fast_cwd)
   bool IMPLEMENT (has_restricted_raw_disk_access)
   bool IMPLEMENT (use_dont_resolve_hack)
-  bool IMPLEMENT (has_stack_size_param_is_a_reservation)
   bool IMPLEMENT (has_console_logon_sid)
   bool IMPLEMENT (wow64_has_secondary_stack)
   bool IMPLEMENT (has_program_compatibility_assistant)
-  bool IMPLEMENT (kernel_is_always_casesensitive)
+  bool IMPLEMENT (has_pipe_reject_remote_clients)
   bool IMPLEMENT (terminate_thread_frees_stack)
 
 #undef IMPLEMENT
index 15e533037da6707894ca1b5afc0810ba40a8524a..8a4c2aeb24b7a30c2abe621a2f79fcc5c2caedea 100644 (file)
@@ -12,13 +12,6 @@ details. */
 #define _WINLEAN_H 1
 #define WIN32_LEAN_AND_MEAN 1
 
-/* Mingw32 */
-#define _WINGDI_H
-#define _WINUSER_H
-#define _WINNLS_H
-#define _WINVER_H
-#define _WINNETWK_H
-#define _WINSVC_H
 /* Mingw64 */
 #define _WINNLS_
 #define _WINNETWK_
@@ -34,8 +27,6 @@ details. */
 #define _WINMM_
 #define WINIMPM
 #define WINSOCK_API_LINKAGE
-#define NTDDI_VERSION 0x6020000        /* Probably should just be derived from our
-                                  _WIN32_WINNT setting in winsup.h */
 
 /* Windows headers define a couple of annoyingly intrusive macros for the
    sole purpose of inline documentation.  Since they are defined without
@@ -63,6 +54,11 @@ details. */
 #include <lmcons.h>
 #include <ntdef.h>
 
+/* Temporary kludge for missing flag in Mingw64's w32api. */
+#ifndef PIPE_REJECT_REMOTE_CLIENTS
+#define PIPE_REJECT_REMOTE_CLIENTS 8
+#endif
+
 #ifdef __undef_IN
 #undef IN
 #endif
@@ -79,13 +75,6 @@ details. */
 #undef CRITICAL
 #endif
 
-#undef _WINGDI_H
-#undef _WINUSER_H
-#undef _WINNLS_H
-#undef _WINVER_H
-#undef _WINNETWK_H
-#undef _WINSVC_H
-
 #undef _WINNLS_
 #undef _WINNETWK_
 #undef _WINSVC_
index f955dd38eab42b3dae09c581b3fb2ac7cb4b673c..488110926d561a0d00a643936ece49c6006b64a5 100644 (file)
@@ -13,9 +13,9 @@ details. */
 
 #define __INSIDE_CYGWIN__
 
+#define NO_COPY_RO __attribute__((nocommon)) __attribute__((section(".rdata_cygwin_nocopy")))
 #define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
 #define NO_COPY_INIT __attribute__((section(".data_cygwin_nocopy")))
-#define _RDATA __attribute__ ((section(".rdata")))
 
 #define EXPORT_ALIAS(sym,symalias) extern "C" __typeof (sym) symalias __attribute__ ((alias(#sym)));
 
@@ -33,11 +33,11 @@ details. */
 #ifdef __cplusplus
 extern "C" {
 #endif
-__uid32_t getuid32 ();
-__uid32_t geteuid32 ();
-int seteuid32 (__uid32_t);
-__gid32_t getegid32 (void);
-struct passwd *getpwuid32 (__uid32_t);
+uid_t getuid32 ();
+uid_t geteuid32 ();
+int seteuid32 (uid_t);
+gid_t getegid32 (void);
+struct passwd *getpwuid32 (uid_t);
 struct passwd *getpwnam (const char *);
 struct __sFILE64 *fopen64 (const char *, const char *);
 struct hostent *cygwin_gethostbyname (const char *name);
@@ -78,15 +78,12 @@ int fcntl64 (int fd, int cmd, ...);
 #ifdef __cplusplus
 
 #include "wincap.h"
+#include "regparm.h"
 
-#define __reg1 __stdcall __attribute__ ((regparm (1)))
-#define __reg2 __stdcall __attribute__ ((regparm (2)))
-#define __reg3 __stdcall __attribute__ ((regparm (3)))
-
-extern const char case_folded_lower[];
-#define cyg_tolower(c) (case_folded_lower[(unsigned char)(c)])
-extern const char case_folded_upper[];
-#define cyg_toupper(c) (case_folded_upper[(unsigned char)(c)])
+extern const unsigned char case_folded_lower[];
+#define cyg_tolower(c) ((char) case_folded_lower[(unsigned char)(c)])
+extern const unsigned char case_folded_upper[];
+#define cyg_toupper(c) ((char) case_folded_upper[(unsigned char)(c)])
 
 #ifndef MALLOC_DEBUG
 #define cfree newlib_cfree_dont_use
@@ -155,18 +152,21 @@ extern int cygserver_running;
 
 class per_process;
 /* cygwin .dll initialization */
-void dll_crt0 (per_process *) __asm__ ("_dll_crt0__FP11per_process");
+void dll_crt0 (per_process *) __asm__ (_SYMSTR (dll_crt0__FP11per_process));
 extern "C" void __stdcall _dll_crt0 ();
 void dll_crt0_1 (void *);
 void dll_dllcrt0_1 (void *);
 
 /* dynamically loaded dll initialization */
-extern "C" int dll_dllcrt0 (HMODULE, per_process *);
+extern "C" PVOID dll_dllcrt0 (HMODULE, per_process *);
 
 extern "C" void _pei386_runtime_relocator (per_process *);
 
+#ifndef __x86_64__
 /* dynamically loaded dll initialization for non-cygwin apps */
 extern "C" int dll_noncygwin_dllcrt0 (HMODULE, per_process *);
+#endif /* !__x86_64__ */
+
 void __reg1 do_exit (int) __attribute__ ((noreturn));
 
 /* libstdc++ malloc operator wrapper support.  */
@@ -175,14 +175,16 @@ extern struct per_process_cxx_malloc default_cygwin_cxx_malloc;
 /* UID/GID */
 void uinfo_init ();
 
+#define ILLEGAL_UID ((uid_t)-1)
+#define ILLEGAL_GID ((gid_t)-1)
+#define ILLEGAL_SEEK ((off_t)-1)
+
+#ifndef __x86_64__
 #define ILLEGAL_UID16 ((__uid16_t)-1)
-#define ILLEGAL_UID ((__uid32_t)-1)
 #define ILLEGAL_GID16 ((__gid16_t)-1)
-#define ILLEGAL_GID ((__gid32_t)-1)
-#define ILLEGAL_SEEK ((_off64_t)-1)
-
-#define uid16touid32(u16)  ((u16)==ILLEGAL_UID16?ILLEGAL_UID:(__uid32_t)(u16))
-#define gid16togid32(g16)  ((g16)==ILLEGAL_GID16?ILLEGAL_GID:(__gid32_t)(g16))
+#define uid16touid32(u16)  ((u16)==ILLEGAL_UID16?ILLEGAL_UID:(uid_t)(u16))
+#define gid16togid32(g16)  ((g16)==ILLEGAL_GID16?ILLEGAL_GID:(gid_t)(g16))
+#endif
 
 /* Convert LARGE_INTEGER into long long */
 #define get_ll(pl)  (((long long) (pl).HighPart << 32) | (pl).LowPart)
@@ -199,16 +201,14 @@ extern "C" int try_to_debug (bool waitloop = 1);
 void ld_preload ();
 const char *find_first_notloaded_dll (class path_conv &);
 
-extern bool cygwin_finished_initializing;
-
 /**************************** Miscellaneous ******************************/
 
 void __stdcall set_std_handle (int);
-int __stdcall stat_dev (DWORD, int, unsigned long, struct __stat64 *);
+int __stdcall stat_dev (DWORD, int, unsigned long, struct stat *);
 
-__ino64_t __reg2 hash_path_name (__ino64_t hash, PUNICODE_STRING name);
-__ino64_t __reg2 hash_path_name (__ino64_t hash, PCWSTR name);
-__ino64_t __reg2 hash_path_name (__ino64_t hash, const char *name);
+ino_t __reg2 hash_path_name (ino_t hash, PUNICODE_STRING name);
+ino_t __reg2 hash_path_name (ino_t hash, PCWSTR name);
+ino_t __reg2 hash_path_name (ino_t hash, const char *name);
 void __reg2 nofinalslash (const char *src, char *dst);
 
 void __reg3 *hook_or_detect_cygwin (const char *, const void *, WORD&, HANDLE h = NULL);
@@ -225,8 +225,6 @@ void __stdcall timeval_to_filetime (const struct timeval *, FILETIME *);
 void __stdcall set_console_title (char *);
 void init_console_handler (bool);
 
-void init_global_security ();
-
 void __reg2 __set_winsock_errno (const char *fn, int ln);
 #define set_winsock_errno() __set_winsock_errno (__FUNCTION__, __LINE__)
 
@@ -239,7 +237,7 @@ int __small_sprintf (char *dst, const char *fmt, ...);
 int __small_vsprintf (char *dst, const char *fmt, va_list ap);
 int __small_swprintf (PWCHAR dst, const WCHAR *fmt, ...);
 int __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap);
-void multiple_cygwin_problem (const char *, unsigned, unsigned);
+void multiple_cygwin_problem (const char *, uintptr_t, uintptr_t);
 
 extern "C" void vklog (int priority, const char *message, va_list ap);
 extern "C" void klog (int priority, const char *message, ...);
@@ -249,9 +247,9 @@ int __reg3 symlink_worker (const char *, const char *, bool, bool);
 
 class path_conv;
 
-int __reg2 stat_worker (path_conv &pc, struct __stat64 *buf);
+int __reg2 stat_worker (path_conv &pc, struct stat *buf);
 
-__ino64_t __reg2 readdir_get_ino (const char *path, bool dot_dot);
+ino_t __reg2 readdir_get_ino (const char *path, bool dot_dot);
 
 /* mmap functions. */
 enum mmap_region_status
@@ -293,13 +291,16 @@ int cygwin_gethostname (char *__name, size_t __len);
 #define NO_X ~(S_IXUSR | S_IXGRP | S_IXOTH)
 
 
+#ifdef __x86_64__
+extern "C" char __data_start__, __data_end__, __bss_start__, __bss_end__;
+#else
 extern "C" char _data_start__, _data_end__, _bss_start__, _bss_end__;
+#endif
 extern "C" void (*__CTOR_LIST__) (void);
 extern "C" void (*__DTOR_LIST__) (void);
 
-
-
 #ifndef NO_GLOBALS_H
+#define _RDATA /* See globals.h */
 #include "globals.h"
 
 extern inline void clear_procimptoken ()
index 35dd5cda9a0f45450a87f3df4be3800a3cc8d46e..070b9c2c4b3156265f03fdaf447bebfd1e625236 100644 (file)
@@ -1,6 +1,6 @@
 /* wow64.cc
 
-   Copyright 2011 Red Hat, Inc.
+   Copyright 2011, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -8,6 +8,10 @@ This software is a copyrighted work licensed under the terms of the
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef __x86_64__
+/* WOW64 only plays a role in the 32 bit version.  Don't use any of this
+   in the 64 bit version. */
+
 #include "winsup.h"
 #include "cygtls.h"
 #include "ntdll.h"
@@ -77,7 +81,7 @@ wow64_test_for_64bit_parent ()
   HANDLE parent;
   PVOID allocbase, stackbase;
 
-  ULONG wow64 = TRUE;   /* Opt on the safe side. */
+  ULONG_PTR wow64 = TRUE;   /* Opt on the safe side. */
 
   /* First check if the current stack is where it belongs.  If so, we don't
      have to do anything special.  This is the case on Vista and later. */
@@ -94,7 +98,7 @@ wow64_test_for_64bit_parent ()
   if (NT_SUCCESS (ret)
       && (parent = OpenProcess (PROCESS_QUERY_INFORMATION,
                                FALSE,
-                               pbi.InheritedFromUniqueProcessId)))
+                               (DWORD) pbi.InheritedFromUniqueProcessId)))
     {
       NtQueryInformationProcess (parent, ProcessWow64Information,
                                 &wow64, sizeof wow64, NULL);
@@ -203,9 +207,11 @@ wow64_respawn_process ()
               path, GetCommandLineW ());
   CloseHandle (pi.hThread);
   if (WaitForSingleObject (pi.hProcess, INFINITE) == WAIT_FAILED)
-    api_fatal ("Waiting for process %d failed, %E", pi.dwProcessId);
+    api_fatal ("Waiting for process %u failed, %E", pi.dwProcessId);
   GetExitCodeProcess (pi.hProcess, &ret);
   CloseHandle (pi.hProcess);
   TerminateProcess (GetCurrentProcess (), ret);
   ExitProcess (ret);
 }
+
+#endif /* !__x86_64__ */
index d82293e69faa3031d05f4040db9e70d7aa404309..a0b5b318d948bec2d9446ddcc84c3a3df17f8600 100644 (file)
@@ -1,6 +1,6 @@
 /* wow64.h
 
-   Copyright 2011 Red Hat, Inc.
+   Copyright 2011, 2012 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -8,8 +8,14 @@ This software is a copyrighted work licensed under the terms of the
 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
 details. */
 
+#ifndef __x86_64__
+/* WOW64 only plays a role in the 32 bit version.  Don't use any of this
+   in the 64 bit version. */
+
 extern bool NO_COPY wow64_needs_stack_adjustment;
 
 extern bool wow64_test_for_64bit_parent ();
 extern PVOID wow64_revert_to_original_stack (PVOID &allocationbase);
 extern void wow64_respawn_process () __attribute__ ((noreturn));
+
+#endif /* !__x86_64__ */
index 223261304962eaffd1b868818f513af49456509d..42d23953f9e26f89c10456190050d55c76e811e7 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * faq-what.xml (faq.what.supported): Change to accommodate existence
+       of 64 bit version.
+
 2013-03-27  Corinna Vinschen  <corinna@vinschen.de>
 
        * faq-what.xml (faq.what.supported): Mention Windows 8 and Server 2012.
index ff1134042002a636a3bb25aa0cb425e7d16ff35e..166338d991620e0cee26d2b1c141661a19c24c91 100644 (file)
@@ -26,13 +26,12 @@ sad reason.
 <question><para>What versions of Windows are supported?</para></question>
 <answer>
 
-<para>Cygwin can be expected to run on all modern 32 bit versions of
-Windows  This includes, as of the time of writing this, Windows 2000,
-Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008,
-Windows 7, Windows Server 2012, Windows 8, as well as the WOW64 32 bit
+<para>Cygwin can be expected to run on all modern versions of Windows.
+This includes, as of the time of writing this, Windows XP SP3, Windows
+Server 2003, Windows Vista, Windows Server 2008, Windows 7, Windows
+Server 2012, Windows 8.  The 32 bit version also runs in the WOW64 32 bit
 environment on released 64 bit versions of Windows
 (XP/2003/Vista/2008/7/2008 R2/8/2012).
-A native 64 bit Cygwin version is in the works.
 Since Cygwin is a community-supported free software project, patches to
 provide support for other versions would be thoughtfully considered.
 Paid support contracts or enhancements are available through Red Hat.  For 
index 0632a8a17fe5a3a2fec7007539977b4b6e0b8d5b..bd0ecbd1c2aa3ab4810bd9bbbd54935b1954840d 100644 (file)
@@ -1,3 +1,7 @@
+2013-04-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Merge in cygwin-64bit-branch.  See ChangeLog.64bit for details.
+
 2012-11-26  Christopher Faylor  <me.cygwin2012@cgf.cx>
 
        * configure.ac: Rename from configure.in.
diff --git a/winsup/lsaauth/ChangeLog.64bit b/winsup/lsaauth/ChangeLog.64bit
new file mode 100644 (file)
index 0000000..32ef857
--- /dev/null
@@ -0,0 +1,13 @@
+2013-02-22  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
+
+       * configure.ac: Skip check for i686-w64-mingw32-g++ on x86_64.
+       * configure: Regenerate.
+
+2013-02-21  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Makefile.in (target_cpu): Define.  Check for target_cpu rather than
+       target_alias for conditional compilation issues.
+
+2013-02-15  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
+
+       * Makefile.in: Do not build or install 32bit DLL for 64bit target.
index 8fbb2a45ab9cdf37ff5bb60963dd6828158389de..162e5aa0c9b6c6da9a90de50c2f715bb96a4d1dd 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2006, 2008, 2009, 2011, 2012 Red Hat, Inc.
+# Copyright (c) 2006, 2008, 2009, 2011, 2012, 2013 Red Hat, Inc.
 #
 #     This program is free software; you can redistribute it and/or modify
 #     it under the terms of the GNU General Public License as published by
@@ -36,6 +36,8 @@ CFLAGS          := @CFLAGS@
 
 include $(srcdir)/../Makefile.common
 
+target_cpu:=@target_cpu@
+
 WIN32_INCLUDES  := -I. -I$(srcdir)
 WIN32_CFLAGS    := $(CFLAGS) $(WIN32_INCLUDES)
 WIN32_LDFLAGS  := $(CFLAGS) -nostdlib -Wl,-shared
@@ -46,9 +48,11 @@ WIN32_LDFLAGS        := $(CFLAGS) -nostdlib -Wl,-shared
 # not recognized by LSA.
 LIBS           := -ladvapi32 -lkernel32 -lntdll
 
+ifneq ($(target_cpu),x86_64)
 DLL32  :=      cyglsa.dll
 DEF32  :=      cyglsa.def
 OBJ32  :=      cyglsa.o
+endif
 
 DLL64  :=      cyglsa64.dll
 DEF64  :=      cyglsa64.def
@@ -84,6 +88,8 @@ clean:
 
 install: all
        /bin/mkdir -p $(DESTDIR)$(bindir)
+ifneq ($(target_cpu),x86_64)
        $(INSTALL_PROGRAM) $(DLL32) $(DESTDIR)$(bindir)/$(DLL32)
+endif
        $(INSTALL_PROGRAM) $(DLL64) $(DESTDIR)$(bindir)/$(DLL64)
        $(INSTALL_PROGRAM) $(srcdir)/cyglsa-config $(DESTDIR)$(bindir)/cyglsa-config
index 240d14448c180e76434af25e4edbfc4858a52cfd..51e28587bc802fbdf29f63e63833a5ad920aab19 100755 (executable)
@@ -2838,7 +2838,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 test -z "$CC" && as_fn_error $? "no acceptable cc found in \$PATH" "$LINENO" 5
 
 
-for ac_prog in i686-w64-mingw32-gcc
+case "$target_cpu" in
+i?86)
+  for ac_prog in i686-w64-mingw32-gcc
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -2880,6 +2882,10 @@ fi
   test -n "$MINGW32_CC" && break
 done
 
+  test -z "$MINGW32_CC" && as_fn_error $? "no acceptable mingw32 cc found in \$PATH" "$LINENO" 5
+  ;;
+esac
+
 for ac_prog in x86_64-w64-mingw32-gcc
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -2922,8 +2928,6 @@ fi
   test -n "$MINGW64_CC" && break
 done
 
-
-test -z "$MINGW32_CC" && as_fn_error $? "no acceptable mingw32 cc found in \$PATH" "$LINENO" 5
 test -z "$MINGW64_CC" && as_fn_error $? "no acceptable mingw64 cc found in \$PATH" "$LINENO" 5
 
 test "$program_prefix" != NONE &&
index edc81e809ed260ba0302c265b22b05684b628dfe..fe2e30bf09aa3b297d07d6f144dbf3148569deb6 100644 (file)
@@ -25,10 +25,14 @@ AC_CANONICAL_SYSTEM
 
 LIB_AC_PROG_CC
 
-AC_CHECK_PROGS(MINGW32_CC, i686-w64-mingw32-gcc)
-AC_CHECK_PROGS(MINGW64_CC, x86_64-w64-mingw32-gcc)
+case "$target_cpu" in
+i?86)
+  AC_CHECK_PROGS(MINGW32_CC, i686-w64-mingw32-gcc)
+  test -z "$MINGW32_CC" && AC_MSG_ERROR([no acceptable mingw32 cc found in \$PATH])
+  ;;
+esac
 
-test -z "$MINGW32_CC" && AC_MSG_ERROR([no acceptable mingw32 cc found in \$PATH])
+AC_CHECK_PROGS(MINGW64_CC, x86_64-w64-mingw32-gcc)
 test -z "$MINGW64_CC" && AC_MSG_ERROR([no acceptable mingw64 cc found in \$PATH])
 
 AC_ARG_PROGRAM
index 9eaa7dc0b3fb9573e2b2be2a954e184704b846bf..b71cb49c7d2ca2cafa12b9bfc026539ecfb776b2 100644 (file)
@@ -1,3 +1,7 @@
+2013-04-23  Corinna Vinschen  <corinna@vinschen.de>
+
+       * Merge in cygwin-64bit-branch.  See ChangeLog.64bit for details.
+
 2013-02-20  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
 
        * Makefile.in (CYGWIN_LDFLAGS): Replace -static-lib* with -static.
diff --git a/winsup/utils/ChangeLog.64bit b/winsup/utils/ChangeLog.64bit
new file mode 100644 (file)
index 0000000..69c2356
--- /dev/null
@@ -0,0 +1,85 @@
+2013-03-28  Peter Rosin  <peda@lysator.liu.se>
+           Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygcheck.cc (dll_info): Fix crash due to sizeof(time_t) being not
+       equal to sizeof(int).  Output timestamp RFC 3339 compatible.
+
+2013-03-26  Corinna Vinschen  <corinna@vinschen.de>
+
+       * tzset.c (main): Don't try to overwrite space with NUL.  Explain why.
+       Rather, just print the string with computed precision value.
+
+2013-03-22  Corinna Vinschen  <corinna@vinschen.de>
+
+       * kill.cc (main): Chack pid against INT_MIN and (U)INT_MAX since pid_t
+       is 4 byte on all platforms.
+       * mkgroup.c (main): Check domlist[i].id_offset against UINT_MAX since
+       DWORD is 4 byte on all platforms.
+       * mkpasswd.c (main): Ditto.
+
+2013-02-19  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygcheck.cc (dll_info): Handle x86_64 binaries.  Make sure to print
+       only architecture matching cygcheck build, otherwise suffer path
+       evaluation problems.
+
+2013-02-17  Yaakov Selkowitz  <yselkowitz@users.sourceforge.net>
+
+       Fix 64-bit type problems in dumper.exe
+       * dumper.cc: Througout, cast pid to unsigned int, change addresses
+       and sizes from DWORD to SIZE_T, and use %p for pointer addresses.
+       (dumper::add_mem_region): Change size type to SIZE_T.
+       (dumper::split_add_mem_region): Ditto.
+       * dumper.h (struct process_mem_region): Change size type to SIZE_T.
+       (class exclusion): Change last, size, and step types to size_t.
+       (exclusion::exclusion): Change argument type to size_t.
+       (exclusion::add): Change mem_size type to SIZE_T.
+       (dumper::add_mem_region): Change size type to SIZE_T.
+       (dumper::split_add_mem_region): Ditto.
+       (psapi_get_module_name): Change BaseAddress type to LPVOID.
+       * module_info.cc (psapi_get_module_name): Ditto.
+       * parse_pe.cc: Througout, change addresses and sizes from DWORD to
+       SIZE_T, and use %p for pointer addresses.
+       (exclusion::add): Change mem_size type to SIZE_T.
+
+2013-02-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * kill.cc (forcekill): Use unsigned int printf format specifier and
+       cast to avoid compiler warnings where DWORD value is used.
+       * regtool.cc: Ditto, throughout.
+
+2013-02-06  Corinna Vinschen  <corinna@vinschen.de>
+
+       * ldd.cc: Drop including inttypes.h.  Use %u rather than PRIu32.
+       * mount.cc: Fix type problem with %* expression.
+       * cygcheck.cc: Ditto.
+
+2013-02-06  Corinna Vinschen  <corinna@vinschen.de>
+
+       Throughout, fix type problems on 32 and 64 bit.  Except:
+       * ssp.c: Disable entire functionality on x86_64 for now.
+
+2012-11-22  Corinna Vinschen  <corinna@vinschen.de>
+
+       * dump_setup.cc: Drop temporary workaround to handle older Mingw header
+       files on Fedora 17.
+       * strace.cc: Ditto.
+
+2012-08-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * ps.cc (main): Define uid correctly as uid_t.
+
+2012-08-16  Corinna Vinschen  <corinna@vinschen.de>
+
+       * cygcheck.cc: Change include path to not depend on installed
+       cygwin/version.h.
+       (_NOMNTENT_MACROS): Define before including mntent.h.
+       * path.cc (_NOMNTENT_MACROS): Ditto.
+       * dump_setup.cc: Add temporary workaround to handle older Mingw header
+       files on Fedora 17.
+       * strace.cc: Ditto.
+
+2012-08-13  Corinna Vinschen  <corinna@vinschen.de>
+
+       * ps.cc (main): Drop unneeded cast.
+
index 5985aa9a19b9076cc61480cdcf82856e9fe1c7f0..b08bdfec570a2eb092120359ee7560802d49e1d9 100644 (file)
@@ -1,7 +1,7 @@
-# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.12.1 -*- Autoconf -*-
+
+# Copyright (C) 1996-2012 Free Software Foundation, Inc.
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
index 36248c9c0680f875ee1bfff802347c31b1f04605..76432e74326e1114fe8f66e9933e6af0c6807460 100755 (executable)
@@ -1,11 +1,9 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68.
+# Generated by GNU Autoconf 2.69.
 #
 #
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -134,6 +132,31 @@ export LANGUAGE
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
@@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -211,21 +235,25 @@ IFS=$as_save_IFS
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-       # neutralization value for shells without unset; and this also
-       # works around shells that cannot unset nonexistent variables.
-       # Preserve -v and -x to the replacement shell.
-       BASH_ENV=/dev/null
-       ENV=/dev/null
-       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-       export CONFIG_SHELL
-       case $- in # ((((
-         *v*x* | *x*v* ) as_opts=-vx ;;
-         *v* ) as_opts=-v ;;
-         *x* ) as_opts=-x ;;
-         * ) as_opts= ;;
-       esac
-       exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
 fi
 
     if test x$as_have_required = xno; then :
@@ -327,6 +355,14 @@ $as_echo X"$as_dir" |
 
 
 } # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -448,6 +484,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
   chmod +x "$as_me.lineno" ||
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -482,16 +522,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -503,28 +543,8 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-       test -d "$1/.";
-      else
-       case $1 in #(
-       -*)set "./$1";;
-       esac;
-       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-       ???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -1108,8 +1128,6 @@ target=$target_alias
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1353,9 +1371,9 @@ test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
 configure
-generated by GNU Autoconf 2.68
+generated by GNU Autoconf 2.69
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1446,7 +1464,7 @@ This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 
@@ -1989,7 +2007,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2029,7 +2047,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2082,7 +2100,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2123,7 +2141,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
@@ -2181,7 +2199,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2225,7 +2243,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2747,8 +2765,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -2861,7 +2878,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2905,7 +2922,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CXX="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3178,7 +3195,7 @@ case $as_dir/ in #((
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+       if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
          if test $ac_prog = install &&
            grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
            # AIX install.  It has an incompatible calling convention.
@@ -3253,7 +3270,7 @@ do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_MINGW_CXX="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3736,16 +3753,16 @@ if (echo >conf$$.file) 2>/dev/null; then
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -3805,28 +3822,16 @@ else
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-       test -d "$1/.";
-      else
-       case $1 in #(
-       -*)set "./$1";;
-       esac;
-       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-       ???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -3848,7 +3853,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # values after options handling.
 ac_log="
 This file was extended by $as_me, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -3901,10 +3906,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.68,
+configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -3982,7 +3987,7 @@ fi
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'
index 2560b07f16bcf2c7c2acddc1b83538d884dd13fa..8c7af0e1cdf7c262db4dad42ea9bae7f825788c1 100644 (file)
@@ -1,7 +1,7 @@
 /* cygcheck.cc
 
    Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011, 2012 Red Hat, Inc.
+   2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
    This file is part of Cygwin.
 
@@ -24,6 +24,7 @@
 #include <getopt.h>
 #include "../cygwin/include/cygwin/version.h"
 #include "../cygwin/include/sys/cygwin.h"
+#define _NOMNTENT_MACROS
 #include "../cygwin/include/mntent.h"
 #include "../cygwin/cygprops.h"
 #undef cygwin_internal
@@ -597,6 +598,28 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse)
   int pe_header_offset = get_dword (fh, 0x3c);
   if (GetLastError () != NO_ERROR)
     display_error ("get_dword");
+  WORD arch = get_word (fh, pe_header_offset + 4);
+  if (GetLastError () != NO_ERROR)
+    display_error ("get_word");
+#ifdef __x86_64__
+  if (arch != IMAGE_FILE_MACHINE_AMD64)
+    {
+      fputc ('\n', stderr);
+      display_error ("Wrong architecture. Only x86_64 executables supported.",
+                    false, false);
+      return;
+    }
+  int base_off = 108;
+#else
+  if (arch != IMAGE_FILE_MACHINE_I386)
+    {
+      fputc ('\n', stderr);
+      display_error ("Wrong architecture. Only ix86 executables supported.",
+                    false, false);
+      return;
+    }
+  int base_off = 92;
+#endif
   int opthdr_ofs = pe_header_offset + 4 + 20;
   unsigned short v[6];
 
@@ -619,19 +642,19 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse)
   else
     printf ("\n");
 
-  int num_entries = get_dword (fh, opthdr_ofs + 92);
+  int num_entries = get_dword (fh, opthdr_ofs + base_off + 0);
   if (GetLastError () != NO_ERROR)
     display_error ("get_dword");
-  int export_rva = get_dword (fh, opthdr_ofs + 96);
+  int export_rva = get_dword (fh, opthdr_ofs + base_off + 4);
   if (GetLastError () != NO_ERROR)
     display_error ("get_dword");
-  int export_size = get_dword (fh, opthdr_ofs + 100);
+  int export_size = get_dword (fh, opthdr_ofs + base_off + 8);
   if (GetLastError () != NO_ERROR)
     display_error ("get_dword");
-  int import_rva = get_dword (fh, opthdr_ofs + 104);
+  int import_rva = get_dword (fh, opthdr_ofs + base_off + 12);
   if (GetLastError () != NO_ERROR)
     display_error ("get_dword");
-  int import_size = get_dword (fh, opthdr_ofs + 108);
+  int import_size = get_dword (fh, opthdr_ofs + base_off + 16);
   if (GetLastError () != NO_ERROR)
     display_error ("get_dword");
 
@@ -667,17 +690,20 @@ dll_info (const char *path, HANDLE fh, int lvl, int recurse)
 
          ExpDirectory *ed = (ExpDirectory *) exp;
          int ofs = ed->name_rva - export_rva;
-         struct tm *tm = localtime ((const time_t *) &(ed->timestamp));
-         if (tm->tm_year < 60)
+         time_t ts = ed->timestamp;    /* timestamp is only 4 bytes! */
+         struct tm *tm = localtime (&ts);
+         if (tm && tm->tm_year < 60)
            tm->tm_year += 2000;
-         if (tm->tm_year < 200)
+         if (tm && tm->tm_year < 200)
            tm->tm_year += 1900;
          printf ("%*c", lvl + 2, ' ');
-         printf ("\"%s\" v%d.%d ts=", exp + ofs,
+         printf ("\"%s\" v%d.%d", exp + ofs,
                  ed->major_ver, ed->minor_ver);
-         printf ("%d/%d/%d %d:%02d\n",
-                 tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
-                 tm->tm_hour, tm->tm_min);
+         if (tm)
+           printf (" ts=%04d-%02d-%02d %02d:%02d",
+                   tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
+                   tm->tm_hour, tm->tm_min);
+         putchar ('\n');
        }
     }
 
@@ -1115,7 +1141,7 @@ pretty_id ()
   sz = -sz;
   for (char **g = groups; g <= ng; g++)
     if ((g != ng) && (++i < n))
-      printf ("%*s", sz, *g);
+      printf ("%*s", (int) sz, *g);
     else
       {
        puts (*g);
@@ -1691,7 +1717,7 @@ dump_sysinfo ()
        {
          for (e = s; *e && *e != sep; e++);
          if (e-s)
-           printf ("\t%.*s\n", e - s, s);
+           printf ("\t%.*s\n", (int) (e - s), s);
          else
            puts ("\t.");
          count_path_items++;
@@ -2307,7 +2333,7 @@ nuke (char *ev)
 }
 
 extern "C" {
-unsigned long (*cygwin_internal) (int, ...);
+uintptr_t (*cygwin_internal) (int, ...);
 WCHAR cygwin_dll_path[32768];
 };
 
@@ -2319,10 +2345,11 @@ load_cygwin (int& argc, char **&argv)
   if (!(h = LoadLibrary ("cygwin1.dll")))
     return;
   GetModuleFileNameW (h, cygwin_dll_path, 32768);
-  if ((cygwin_internal = (DWORD (*) (int, ...)) GetProcAddress (h, "cygwin_internal")))
+  if ((cygwin_internal = (uintptr_t (*) (int, ...))
+                        GetProcAddress (h, "cygwin_internal")))
     {
       char **av = (char **) cygwin_internal (CW_ARGV);
-      if (av && ((DWORD) av != (DWORD) -1))
+      if (av && ((uintptr_t) av != (uintptr_t) -1))
        {
          /* Copy cygwin's idea of the argument list into this Window application. */
          for (argc = 0; av[argc]; argc++)
@@ -2334,7 +2361,7 @@ load_cygwin (int& argc, char **&argv)
 
 
       char **envp = (char **) cygwin_internal (CW_ENVP);
-      if (envp && ((DWORD) envp != (DWORD) -1))
+      if (envp && ((uintptr_t) envp != (uintptr_t) -1))
        {
          /* Store path and revert to this value, otherwise path gets overwritten
             by the POSIXy Cygwin variation, which breaks cygcheck.
index 8199aa4eb20652690b5429b14c3247061c67c868..50df44569130d67f560e0d7f09c7be747983498d 100644 (file)
@@ -1,6 +1,6 @@
 /* dumper.cc
 
-   Copyright 1999, 2001, 2002, 2004, 2006, 2007, 2011 Red Hat Inc.
+   Copyright 1999, 2001, 2002, 2004, 2006, 2007, 2011, 2013 Red Hat Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -84,7 +84,8 @@ dumper::dumper (DWORD pid, DWORD tid, const char *file_name)
                          pid);
   if (!hProcess)
     {
-      fprintf (stderr, "Failed to open process #%lu, error %ld\n", pid, GetLastError ());
+      fprintf (stderr, "Failed to open process #%u, error %ld\n",
+              (unsigned int) pid, (long) GetLastError ());
       return;
     }
 
@@ -192,7 +193,7 @@ dumper::add_thread (DWORD tid, HANDLE hThread)
 }
 
 int
-dumper::add_mem_region (LPBYTE base, DWORD size)
+dumper::add_mem_region (LPBYTE base, SIZE_T size)
 {
   if (!sane ())
     return 0;
@@ -209,14 +210,14 @@ dumper::add_mem_region (LPBYTE base, DWORD size)
   new_entity->u.memory.base = base;
   new_entity->u.memory.size = size;
 
-  deb_printf ("added memory region %08x-%08x\n", (DWORD) base, (DWORD) base + size);
+  deb_printf ("added memory region %p-%p\n", base, base + size);
   return 1;
 }
 
 /* split_add_mem_region scans list of regions to be excluded from dumping process
    (excl_list) and removes all "excluded" parts from given region. */
 int
-dumper::split_add_mem_region (LPBYTE base, DWORD size)
+dumper::split_add_mem_region (LPBYTE base, SIZE_T size)
 {
   if (!sane ())
     return 0;
@@ -255,7 +256,7 @@ dumper::add_module (LPVOID base_address)
   if (!sane ())
     return 0;
 
-  char *module_name = psapi_get_module_name (hProcess, (DWORD) base_address);
+  char *module_name = psapi_get_module_name (hProcess, base_address);
   if (module_name == NULL)
     return 1;
 
@@ -270,7 +271,7 @@ dumper::add_module (LPVOID base_address)
 
   parse_pe (module_name, excl_list);
 
-  deb_printf ("added module %08x %s\n", base_address, module_name);
+  deb_printf ("added module %p %s\n", base_address, module_name);
   return 1;
 }
 
@@ -284,8 +285,8 @@ dumper::collect_memory_sections ()
 
   LPBYTE current_page_address;
   LPBYTE last_base = (LPBYTE) 0xFFFFFFFF;
-  DWORD last_size = 0;
-  DWORD done;
+  SIZE_T last_size = (SIZE_T) 0;
+  SIZE_T done;
 
   char mem_buf[PAGE_BUFFER_SIZE];
 
@@ -329,9 +330,9 @@ dumper::collect_memory_sections ()
              for (int i = 0; i < 10; i++)
                strcat (buf, pt[i]);
 
-             deb_printf ("warning: failed to read memory at %08x-%08x (protect = %s), error %ld.\n",
-                         (DWORD) current_page_address,
-                         (DWORD) current_page_address + mbi.RegionSize,
+             deb_printf ("warning: failed to read memory at %p-%p (protect = %s), error %ld.\n",
+                         current_page_address,
+                         current_page_address + mbi.RegionSize,
                          buf, err);
              skip_region_p = 1;
            }
@@ -369,9 +370,9 @@ dumper::dump_memory_region (asection * to, process_mem_region * memory)
   if (!sane ())
     return 0;
 
-  DWORD size = memory->size;
-  DWORD todo;
-  DWORD done;
+  SIZE_T size = memory->size;
+  SIZE_T todo;
+  SIZE_T done;
   LPBYTE pos = memory->base;
   DWORD sect_pos = 0;
 
@@ -516,12 +517,13 @@ dumper::collect_process_information ()
 
   if (!DebugActiveProcess (pid))
     {
-      fprintf (stderr, "Cannot attach to process #%lu, error %ld", pid, GetLastError ());
+      fprintf (stderr, "Cannot attach to process #%u, error %ld",
+              (unsigned int) pid, (long) GetLastError ());
       return 0;
     }
 
   char event_name[sizeof ("cygwin_error_start_event") + 20];
-  sprintf (event_name, "cygwin_error_start_event%16lx", pid);
+  sprintf (event_name, "cygwin_error_start_event%16x", (unsigned int) pid);
   HANDLE sync_with_debugee = OpenEvent (EVENT_MODIFY_STATE, FALSE, event_name);
 
   DEBUG_EVENT current_event;
@@ -660,7 +662,7 @@ dumper::prepare_core_dump ()
   char sect_name[50];
 
   flagword sect_flags;
-  DWORD sect_size;
+  SIZE_T sect_size;
   bfd_vma sect_vma;
 
   asection *new_section;
@@ -812,7 +814,7 @@ dumper::write_core_dump ()
       if (p->section == NULL)
        continue;
 
-      deb_printf ("writing section type=%u base=%08x size=%08x flags=%08x\n",
+      deb_printf ("writing section type=%u base=%p size=%p flags=%08x\n",
                  p->type,
                  p->section->vma,
                  bfd_get_section_size (p->section),
@@ -936,7 +938,7 @@ main (int argc, char **argv)
   DWORD tid = 0;
 
   if (verbose)
-    printf ("dumping process #%lu to %s\n", pid, core_file);
+    printf ("dumping process #%u to %s\n", (unsigned int) pid, core_file);
 
   dumper d (pid, tid, core_file);
   if (!d.sane ())
index 4b8d2bdf728161f251601866abe1fba0a040b4f2..b6c70308c8477afa05e4ed0f9cb16dcf120c0348 100644 (file)
@@ -1,6 +1,6 @@
 /* dumper.h
 
-   Copyright 1999,2001 Red Hat Inc.
+   Copyright 1999, 2001, 2013 Red Hat Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -28,7 +28,7 @@
 typedef struct
 {
   LPBYTE base;
-  DWORD size;
+  SIZE_T size;
 } process_mem_region;
 
 typedef struct
@@ -67,16 +67,16 @@ typedef struct _process_entity
 class exclusion
 {
 public:
-  int last;
-  int size;
-  int step;
+  size_t last;
+  size_t size;
+  size_t step;
   process_mem_region* region;
 
-  exclusion ( int step ) { last = size = 0;
-                          this->step = step;
-                          region = NULL; }
+  exclusion ( size_t step ) { last = size = 0;
+                             this->step = step;
+                             region = NULL; }
   ~exclusion () { free ( region ); }
-  int add ( LPBYTE mem_base, DWORD mem_size );
+  int add ( LPBYTE mem_base, SIZE_T mem_size );
   int sort_and_check ();
 };
 
@@ -105,10 +105,10 @@ class dumper
 
   process_entity* add_process_entity_to_list ( process_entity_type type );
   int add_thread ( DWORD tid, HANDLE hThread );
-  int add_mem_region ( LPBYTE base, DWORD size );
+  int add_mem_region ( LPBYTE base, SIZE_T size );
 
   /* break mem_region by excl_list and add add all subregions */
-  int split_add_mem_region ( LPBYTE base, DWORD size );
+  int split_add_mem_region ( LPBYTE base, SIZE_T size );
 
   int add_module ( LPVOID base_address );
 
@@ -133,7 +133,7 @@ public:
 
 extern int deb_printf ( const char* format, ... );
 
-extern char* psapi_get_module_name ( HANDLE hProcess, DWORD BaseAddress );
+extern char* psapi_get_module_name ( HANDLE hProcess, LPVOID BaseAddress );
 
 extern int parse_pe ( const char* file_name, exclusion* excl_list );
 
index 486d273f942f0aee48ab491a804ecb9986d6445e..edabff32149ec9f2b33f89520e6046578001a8d0 100644 (file)
@@ -176,8 +176,8 @@ forcekill (int pid, int sig, int wait)
   if (!wait || WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
     if (sig && !TerminateProcess (h, sig << 8)
        && WaitForSingleObject (h, 200) != WAIT_OBJECT_0)
-      fprintf (stderr, "%s: couldn't kill pid %u, %lu\n",
-              prog_name, (unsigned) dwpid, GetLastError ());
+      fprintf (stderr, "%s: couldn't kill pid %u, %u\n",
+              prog_name, (unsigned) dwpid, (unsigned int) GetLastError ());
   CloseHandle (h);
 }
 
@@ -260,13 +260,13 @@ out:
       if (!pid)
        pid = strtoll (*argv, &p, 10);
       if (*p != '\0'
-         || (!force && (pid < LONG_MIN || pid > LONG_MAX))
-         || (force && (pid <= 0 || pid > ULONG_MAX)))
+         || (!force && (pid < INT_MIN || pid > INT_MAX))
+         || (force && (pid <= 0 || pid > UINT_MAX)))
        {
          fprintf (stderr, "%s: illegal pid: %s\n", prog_name, *argv);
          ret = 1;
        }
-      else if (pid <= LONG_MAX && kill ((pid_t) pid, sig) == 0)
+      else if (pid <= INT_MAX && kill ((pid_t) pid, sig) == 0)
        {
          if (force)
            forcekill ((pid_t) pid, sig, 1);
index fa771b288ae5e378e9bcc3576ccbb97f130b5e73..de98658bcaa9f7f11b22b68cc96ab87f374dd044 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009, 2010, 2011  Chris Faylor
+/* Copyright (c) 2009, 2010, 2011, 2013  Chris Faylor
 
   All rights reserved.
 
@@ -162,7 +162,8 @@ load_dll (const wchar_t *fn)
   wchar_t *buf = get_module_filename (GetCurrentProcess (), NULL);
   if (!buf)
     {
-      printf ("ldd: GetModuleFileName returned an error %lu\n", GetLastError ());
+      printf ("ldd: GetModuleFileName returned an error %u\n",
+             (unsigned int) GetLastError ());
       exit (1);                /* FIXME */
     }
 
@@ -219,8 +220,9 @@ static int
 set_entry_point_break ()
 {
   HMODULE hm;
-  DWORD cb;
-  if (!EnumProcessModules (hProcess, &hm, sizeof (hm), &cb) || !cb)
+  DWORD cbe;
+  SIZE_T cbw;
+  if (!EnumProcessModules (hProcess, &hm, sizeof (hm), &cbe) || !cbe)
     set_errno_and_return (1);
 
   MODULEINFO mi = {};
@@ -228,7 +230,7 @@ set_entry_point_break ()
     set_errno_and_return (1);
 
   static const unsigned char int3 = 0xcc;
-  if (!WriteProcessMemory (hProcess, mi.EntryPoint, &int3, 1, &cb) || cb != 1)
+  if (!WriteProcessMemory (hProcess, mi.EntryPoint, &int3, 1, &cbw) || cbw != 1)
     set_errno_and_return (1);
   return 0;
 }
@@ -485,13 +487,15 @@ map_file (const wchar_t *filename)
     }
   if (!(hMapping = CreateFileMapping (hFile, 0, PAGE_READONLY | SEC_COMMIT, 0, 0, 0)))
     {
-      fprintf (stderr, "CreateFileMapping failed with windows error %lu\n", GetLastError ());
+      fprintf (stderr, "CreateFileMapping failed with windows error %u\n",
+              (unsigned int) GetLastError ());
       CloseHandle (hFile);
       return 0;
     }
   if (!(basepointer = MapViewOfFile (hMapping, FILE_MAP_READ, 0, 0, 0)))
     {
-      fprintf (stderr, "MapViewOfFile failed with windows error %lu\n", GetLastError ());
+      fprintf (stderr, "MapViewOfFile failed with windows error %u\n",
+              (unsigned int) GetLastError ());
       CloseHandle (hMapping);
       CloseHandle (hFile);
       return 0;
index be57cf161e00ff18bcab21b0998adeed2c6b3547..fadf3f3dacedad6474c92aabe826620b2677e494 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011 Corinna Vinschen
+ * Copyright (c) 2010, 2011, 2012, 2013 Corinna Vinschen
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -520,7 +520,7 @@ print_lc_sepstrings (int key, const char *name, const char *value)
        }
       else
        {
-         printf ("%.*s", c - value, value);
+         printf ("%.*s", (int) (c - value), value);
          value = c + 1;
        }
       if (key)
index b15c148442c7fa9c089a5f2aadba5514584f226e..05f5910b0200921077a2a12c4e886f37966ba7df 100644 (file)
@@ -1,7 +1,7 @@
 /* mkgroup.c:
 
    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-   2008, 2009, 2010, 2011, 2012 Red Hat, Inc.
+   2008, 2009, 2010, 2011, 2012, 2013 Red Hat, Inc.
 
    This file is part of Cygwin.
 
@@ -18,6 +18,7 @@
 #include <locale.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <inttypes.h>
 #include <getopt.h>
 #include <io.h>
 #include <sys/fcntl.h>
@@ -62,9 +63,11 @@ _print_win_error (DWORD code, int line)
       code,
       MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
       (LPTSTR) buf, sizeof (buf), NULL))
-    fprintf (stderr, "mkgroup (%d): [%lu] %s", line, code, buf);
+    fprintf (stderr, "mkgroup (%d): [%" PRIu32 "] %s",
+            line, (unsigned int) code, buf);
   else
-    fprintf (stderr, "mkgroup (%d): error %lu", line, code);
+    fprintf (stderr, "mkgroup (%d): error %" PRIu32 ,
+            line, (unsigned int) code);
 }
 
 static PWCHAR
@@ -104,7 +107,7 @@ put_sid (PSID psid)
   strcat (s, t);
   for (i = 0; i < *GetSidSubAuthorityCount (psid); ++i)
     {
-      sprintf(t, "-%lu", *GetSidSubAuthority (psid, i));
+      sprintf(t, "-%" PRIu32 , (unsigned int) *GetSidSubAuthority (psid, i));
       strcat (s, t);
     }
   return s;
@@ -164,12 +167,12 @@ current_group (const char *sep, DWORD id_offset)
     }
   gid = *GetSidSubAuthority (curr_pgrp.psid,
                             *GetSidSubAuthorityCount(curr_pgrp.psid) - 1);
-  printf ("%ls%s%ls:%s:%lu:\n",
+  printf ("%ls%s%ls:%s:%" PRIu32 ":\n",
          sep ? dom : L"",
          sep ?: "",
          grp,
          put_sid (curr_pgrp.psid),
-         id_offset + gid);
+         (unsigned int) (id_offset + gid));
 }
 
 static void
@@ -225,14 +228,14 @@ enum_unix_groups (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
                                       dom,
                                       (dlen = MAX_DOMAIN_NAME_LEN + 1, &dlen),
                                       &acc_type))
-           printf ("%s%s%ls:%s:%lu:\n",
+           printf ("%s%s%ls:%s:%" PRIu32 ":\n",
                    with_dom ? "Unix Group" : "",
                    with_dom ? sep : "",
                    p,
                    put_sid (psid),
-                   id_offset +
+                   (unsigned int) (id_offset +
                    *GetSidSubAuthority (psid,
-                                        *GetSidSubAuthorityCount(psid) - 1));
+                                        *GetSidSubAuthorityCount(psid) - 1)));
        }
       else
        {
@@ -262,12 +265,12 @@ enum_unix_groups (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
                                     (dlen = MAX_DOMAIN_NAME_LEN + 1, &dlen),
                                     &acc_type)
                  && !iswdigit (grp[0]))
-               printf ("%s%s%ls:%s:%lu:\n",
+               printf ("%s%s%ls:%s:%" PRIu32 ":\n",
                        with_dom ? "Unix Group" : "",
                        with_dom ? sep : "",
                        grp,
                        put_sid (psid),
-                       id_offset + start);
+                       (unsigned int) (id_offset + start));
            }
        }
     }
@@ -288,7 +291,7 @@ enum_local_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
   LOCALGROUP_INFO_0 *buffer;
   DWORD entriesread = 0;
   DWORD totalentries = 0;
-  DWORD resume_handle = 0;
+  DWORD_PTR resume_handle = 0;
   WCHAR gname[GNLEN + 1];
   DWORD rc;
 
@@ -411,12 +414,12 @@ enum_local_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
            got_curr_pgrp = TRUE;
 
          gid = *GetSidSubAuthority (psid, *GetSidSubAuthorityCount(psid) - 1);
-         printf ("%ls%s%ls:%s:%ld:\n",
+         printf ("%ls%s%ls:%s:%" PRIu32 ":\n",
                  with_dom && !is_builtin ? domain_name : L"",
                  with_dom && !is_builtin ? sep : "",
                  buffer[i].lgrpi0_name,
                  put_sid (psid),
-                 gid + (is_builtin ? 0 : id_offset));
+                 (unsigned int) (gid + (is_builtin ? 0 : id_offset)));
 skip_group:
          ;
        }
@@ -443,7 +446,7 @@ enum_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
   GROUP_INFO_2 *buffer;
   DWORD entriesread = 0;
   DWORD totalentries = 0;
-  DWORD resume_handle = 0;
+  DWORD_PTR resume_handle = 0;
   WCHAR gname[GNLEN + 1];
   DWORD rc;
 
@@ -543,12 +546,12 @@ enum_groups (BOOL domain, domlist_t *dom_or_machine, const char *sep,
          else if (EqualSid (curr_pgrp.psid, psid))
            got_curr_pgrp = TRUE;
 
-         printf ("%ls%s%ls:%s:%lu:\n",
+         printf ("%ls%s%ls:%s:%" PRIu32 ":\n",
                  with_dom ? domain_name : L"",
                  with_dom ? sep : "",
                  buffer[i].grpi2_name,
                  put_sid (psid),
-                 id_offset + gid);
+                 (unsigned int) (id_offset + gid));
        }
 
       NetApiBufferFree (buffer);
@@ -591,7 +594,8 @@ print_special_by_sid (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
            rid = sub2;
          else
            rid = sub1;
-         printf ("%ls:%s:%lu:\n", grp, put_sid (psid), rid);
+         printf ("%ls:%s:%" PRIu32 ":\n", grp, put_sid (psid),
+                 (unsigned int) rid);
        }
       FreeSid (psid);
     }
@@ -797,7 +801,7 @@ main (int argc, char **argv)
            }
        if (!(domlist[print_domlist].str = opt))
          print_system = 1;
-       domlist[print_domlist].id_offset = ULONG_MAX;
+       domlist[print_domlist].id_offset = UINT32_MAX;
        if (opt && (p = strchr (opt, ',')))
          {
            if (p == opt
@@ -884,7 +888,7 @@ skip:
   for (i = 0; i < print_domlist; ++i)
     {
       DWORD my_off = (domlist[i].domain || domlist[i].str)
-                    ? domlist[i].id_offset != ULONG_MAX
+                    ? domlist[i].id_offset != UINT_MAX
                       ? domlist[i].id_offset : off : 0;
       if (!enum_local_groups (domlist[i].domain, domlist + i, sep_char,
                              my_off, disp_groupname, print_builtin, print_current))
index c16c8689237711a089ebf59507dc46dc9fd01020..d080dbd709e83b4111c67c0799c93cbc484550ec 100644 (file)
@@ -1,7 +1,7 @@
 /* mkpasswd.c:
 
    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2009,
-   2010, 2011, 2012 Red Hat, Inc.
+   2010, 2011, 2012, 2013 Red Hat, Inc.
 
    This file is part of Cygwin.
 
@@ -18,6 +18,7 @@
 #include <locale.h>
 #include <stdio.h>
 #include <unistd.h>
+#include <inttypes.h>
 #include <getopt.h>
 #include <io.h>
 #include <sys/fcntl.h>
@@ -62,9 +63,11 @@ _print_win_error(DWORD code, int line)
       code,
       MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
       (LPTSTR) buf, sizeof (buf), NULL))
-    fprintf (stderr, "mkpasswd (%d): [%lu] %s", line, code, buf);
+    fprintf (stderr, "mkpasswd (%d): [%" PRIu32 "] %s",
+            line, (unsigned int) code, buf);
   else
-    fprintf (stderr, "mkpasswd (%d): error %lu", line, code);
+    fprintf (stderr, "mkpasswd (%d): error %" PRIu32,
+            line, (unsigned int) code);
 }
 
 static PWCHAR
@@ -104,7 +107,7 @@ put_sid (PSID sid)
   strcat (s, t);
   for (i = 0; i < *GetSidSubAuthorityCount (sid); ++i)
     {
-      sprintf(t, "-%lu", *GetSidSubAuthority (sid, i));
+      sprintf(t, "-%" PRIu32, (unsigned int) *GetSidSubAuthority (sid, i));
       strcat (s, t);
     }
   return s;
@@ -192,12 +195,13 @@ current_user (const char *sep, const char *passed_home_path, DWORD id_offset,
       homedir_psx[PATH_MAX - 1] = '\0';
     }
 
-  printf ("%ls%s%ls:unused:%lu:%lu:U-%ls\\%ls,%s:%s:/bin/bash\n",
+  printf ("%ls%s%ls:unused:%" PRIu32 ":%" PRIu32
+         ":U-%ls\\%ls,%s:%s:/bin/bash\n",
          sep ? dom : L"",
          sep ?: "",
          user,
-         id_offset + uid,
-         id_offset + gid,
+         (unsigned int) (id_offset + uid),
+         (unsigned int) (id_offset + gid),
          dom,
          user,
          put_sid (curr_user.psid),
@@ -257,13 +261,13 @@ enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
                                       dom,
                                       (dlen = MAX_DOMAIN_NAME_LEN + 1, &dlen),
                                       &acc_type))
-           printf ("%s%s%ls:unused:%lu:99999:,%s::\n",
+           printf ("%s%s%ls:unused:%" PRIu32 ":99999:,%s::\n",
                    with_dom ? "Unix User" : "",
                    with_dom ? sep : "",
                    user + 10,
-                   id_offset +
+                   (unsigned int) (id_offset +
                    *GetSidSubAuthority (psid,
-                                        *GetSidSubAuthorityCount(psid) - 1),
+                                        *GetSidSubAuthorityCount(psid) - 1)),
                    put_sid (psid));
        }
       else
@@ -294,11 +298,11 @@ enum_unix_users (domlist_t *dom_or_machine, const char *sep, DWORD id_offset,
                                     (dlen = MAX_DOMAIN_NAME_LEN + 1, &dlen),
                                     &acc_type)
                  && !iswdigit (user[0]))
-               printf ("%s%s%ls:unused:%lu:99999:,%s::\n",
+               printf ("%s%s%ls:unused:%" PRIu32 ":99999:,%s::\n",
                        with_dom ? "Unix User" : "",
                        with_dom ? sep : "",
                        user,
-                       id_offset + start,
+                       (unsigned int) (id_offset + start),
                        put_sid (psid));
            }
        }
@@ -435,12 +439,13 @@ enum_users (BOOL domain, domlist_t *dom_or_machine, const char *sep,
          else if (EqualSid (curr_user.psid, psid))
            got_curr_user = TRUE;
 
-         printf ("%ls%s%ls:unused:%lu:%lu:%ls%sU-%ls\\%ls,%s:%s:/bin/bash\n",
+         printf ("%ls%s%ls:unused:%" PRIu32 ":%" PRIu32
+                 ":%ls%sU-%ls\\%ls,%s:%s:/bin/bash\n",
                  with_dom ? domain_name : L"",
                  with_dom ? sep : "",
                  buffer[i].usri3_name,
-                 id_offset + uid,
-                 id_offset + gid,
+                 (unsigned int) (id_offset + uid),
+                 (unsigned int) (id_offset + gid),
                  buffer[i].usri3_full_name ?: L"",
                  buffer[i].usri3_full_name
                  && buffer[i].usri3_full_name[0] ? "," : "",
@@ -473,7 +478,7 @@ print_special_by_sid (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
     {
       if (LookupAccountSidW (NULL, sid,
                             user, (len = UNLEN + 1, &len),
-                            dom, (len2 = MAX_DOMAIN_NAME_LEN + 1, &len),
+                            dom, (len2 = MAX_DOMAIN_NAME_LEN + 1, &len2),
                             &acc_type))
        {
          if (sub8)
@@ -492,8 +497,9 @@ print_special_by_sid (PSID_IDENTIFIER_AUTHORITY auth, BYTE cnt,
            rid = sub2;
          else
            rid = sub1;
-         printf ("%ls:*:%lu:%lu:,%s::\n",
-                 user, rid, rid == 18 ? 544 : rid, /* SYSTEM hack */
+         printf ("%ls:*:%" PRIu32 ":%" PRIu32 ":,%s::\n",
+                 user, (unsigned int) rid,
+                 (unsigned int) (rid == 18 ? 544 : rid), /* SYSTEM hack */
                  put_sid (sid));
        }
       FreeSid (sid);
@@ -718,7 +724,7 @@ main (int argc, char **argv)
              goto skip;
            }
        domlist[print_domlist].str = opt;
-       domlist[print_domlist].id_offset = ULONG_MAX;
+       domlist[print_domlist].id_offset = UINT32_MAX;
        if (opt && (p = strchr (opt, ',')))
          {
            if (p == opt
@@ -812,7 +818,7 @@ skip:
   for (i = 0; i < print_domlist; ++i)
     {
       DWORD my_off = (domlist[i].domain || domlist[i].str)
-                    ? domlist[i].id_offset != ULONG_MAX
+                    ? domlist[i].id_offset != UINT_MAX
                       ? domlist[i].id_offset : off : 0;
       if (!domlist[i].domain && domlist[i].str && print_unix)
        enum_unix_users (domlist + i, sep_char, my_off, print_unix);
index 8137991ca465a6e961ff071b6074cc2bfbd03afe..12e74de39b75cf8a2c28c9ec0e3173376b8d06d7 100644 (file)
@@ -1,6 +1,6 @@
 /* module_info.cc
 
-   Copyright 1999, 2000, 2001, 2010 Red Hat, Inc.
+   Copyright 1999, 2000, 2001, 2010, 2013 Red Hat, Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -33,7 +33,7 @@ static tf_GetModuleFileNameExA *psapi_GetModuleFileNameExA = NULL;
    Uses psapi.dll. */
 
 char *
-psapi_get_module_name (HANDLE hProcess, DWORD BaseAddress)
+psapi_get_module_name (HANDLE hProcess, LPVOID BaseAddress)
 {
   DWORD len;
   MODULEINFO mi;
@@ -103,7 +103,7 @@ psapi_get_module_name (HANDLE hProcess, DWORD BaseAddress)
          goto failed;
        }
 
-      if ((DWORD) (mi.lpBaseOfDll) == BaseAddress)
+      if (mi.lpBaseOfDll == BaseAddress)
        {
          free (DllHandle);
          return strdup (name_buf);
index 1a3add1474fda1dfb23df68361c2f504538c479c..650266d3f52be1f890465b4c6bab244003ded47b 100644 (file)
@@ -1,7 +1,7 @@
 /* mount.cc
 
    Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
+   2007, 2008, 2009, 2010, 2011, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -22,9 +22,6 @@ details. */
 #include <dirent.h>
 #include "path.h"
 
-#ifdef errno
-#undef errno
-#endif
 #include <errno.h>
 
 #define NT_MAX_PATH 32768
@@ -104,7 +101,7 @@ do_mount (const char *dev, const char *where, int flags)
          fprintf (stderr,
       "%s: defaulting to 'notexec' mount option for speed since native path\n"
       "%*creferences a remote share.  Use '-f' option to override.\n",
-                  progname, strlen(progname) + 2, ' ');
+                  progname, (int) strlen(progname) + 2, ' ');
          flags |= MOUNT_NOTEXEC;
        }
     }
index 30043f6a6eca985579d2f19188c06192c91b7363..c3ae7bb1171b016b7189b9536d84e20df95baefe 100644 (file)
@@ -1,6 +1,6 @@
 /* parse_pe.cc
 
-   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2012 Red Hat, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2012, 2013 Red Hat, Inc.
 
    Written by Egor Duda <deo@logos-m.ru>
 
@@ -28,7 +28,7 @@
 #include "dumper.h"
 
 int
-exclusion::add (LPBYTE mem_base, DWORD mem_size)
+exclusion::add (LPBYTE mem_base, SIZE_T mem_size)
 {
   while (last >= size)
     size += step;
@@ -62,7 +62,7 @@ exclusion::sort_and_check ()
        continue;
       if (p->base + size > q->base)
        {
-         fprintf (stderr, "region error @ (%8p + %d) > %8p\n", p->base, size, q->base);
+         fprintf (stderr, "region error @ (%p + %zd) > %p\n", p->base, size, q->base);
          return 0;
        }
     }
@@ -77,7 +77,7 @@ select_data_section (bfd * abfd, asection * sect, PTR obj)
   if ((sect->flags & (SEC_CODE | SEC_DEBUGGING)) &&
       sect->vma && bfd_get_section_size (sect))
     {
-      excl_list->add ((LPBYTE) sect->vma, (DWORD) bfd_get_section_size (sect));
+      excl_list->add ((LPBYTE) sect->vma, (SIZE_T) bfd_get_section_size (sect));
       deb_printf ("excluding section: %20s %08lx\n", sect->name,
                  bfd_get_section_size (sect));
     }
index 59a2d73ff7dbadd33d12d381f00e4e7e6d58d94e..ea3e2d159412e877b8fa1d61807b31de8d5a739c 100644 (file)
@@ -1,7 +1,7 @@
 /* passwd.c: Changing passwords and managing account information
 
-   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2008, 2009, 2011, 2012 Red
-   Hat, Inc.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2008, 2009, 2011, 2012,
+   2013 Red Hat, Inc.
 
    Written by Corinna Vinschen <corinna.vinschen@cityweb.de>
 
@@ -22,6 +22,7 @@ details. */
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <inttypes.h>
 #include <getopt.h>
 #include <pwd.h>
 #include <sys/cygwin.h>
@@ -203,14 +204,14 @@ PrintPW (PUSER_INFO_3 ui, LPCWSTR server)
       if (ui->usri3_priv == USER_PRIV_ADMIN)
        mi->usrmod0_min_passwd_len = 0;
       printf ("\nSystem password settings:\n");
-      printf ("Max. password age %ld days\n",
-             mi->usrmod0_max_passwd_age / ONE_DAY);
-      printf ("Min. password age %ld days\n",
-             mi->usrmod0_min_passwd_age / ONE_DAY);
-      printf ("Force logout after %ld days\n",
-             mi->usrmod0_force_logoff / ONE_DAY);
-      printf ("Min. password length: %ld\n",
-             mi->usrmod0_min_passwd_len);
+      printf ("Max. password age %" PRIu32 " days\n",
+             (unsigned int) (mi->usrmod0_max_passwd_age / ONE_DAY));
+      printf ("Min. password age %" PRIu32 " days\n",
+             (unsigned int) (mi->usrmod0_min_passwd_age / ONE_DAY));
+      printf ("Force logout after %" PRIu32 " days\n",
+             (unsigned int) (mi->usrmod0_force_logoff / ONE_DAY));
+      printf ("Min. password length: %" PRIu32 "\n",
+             (unsigned int) mi->usrmod0_min_passwd_len);
     }
 }
 
index 8c17dce1445cc4591a36d0e616bfe727c727b383..a66dcdc145aa8923fc9b611c29d315d60fca7987 100644 (file)
@@ -1,7 +1,7 @@
 /* path.cc
 
-   Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-   Red Hat, Inc.
+   Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
+   2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -25,6 +25,7 @@ details. */
 #include "path.h"
 #include "../cygwin/include/cygwin/version.h"
 #include "../cygwin/include/sys/mount.h"
+#define _NOMNTENT_MACROS
 #include "../cygwin/include/mntent.h"
 #include "testsuite.h"
 #ifdef FSTAB_ONLY
@@ -841,7 +842,7 @@ vcygpath (const char *cwd, const char *s, va_list v)
       if (n < max_len || !path_prefix_p (m->posix, path, n))
        continue;
       if ((m->flags & MOUNT_CYGDRIVE)
-         && (strlen (path) < n + 2
+         && ((int) strlen (path) < n + 2
              || path[n] != '/'
              || !isalpha (path[n + 1])
              || path[n + 2] != '/'))
@@ -917,7 +918,8 @@ getmntent (FILE *)
   if (!mnt.mnt_opts)
     mnt.mnt_opts = (char *) malloc (64);
 
-  strcpy (mnt.mnt_type, (char *) (m->flags & MOUNT_SYSTEM) ? "system" : "user");
+  strcpy (mnt.mnt_type,
+         (char *) ((m->flags & MOUNT_SYSTEM) ? "system" : "user"));
 
   if (!(m->flags & MOUNT_BINARY))
     strcpy (mnt.mnt_opts, (char *) "text");
index ca874a19145f5bc5149b18bd947d9fa57d47c01a..952b63ee3c2a6ff7716ab741d1a8e0ea746656e2 100644 (file)
@@ -149,7 +149,8 @@ int
 main (int argc, char *argv[])
 {
   external_pinfo *p;
-  int aflag, lflag, fflag, sflag, uid, proc_id;
+  int aflag, lflag, fflag, sflag, proc_id;
+  uid_t uid;
   bool found_proc_id = true;
   DWORD proc_access = PROCESS_QUERY_LIMITED_INFORMATION;
   cygwin_getinfo_types query = CW_GETPINFO;
@@ -294,7 +295,7 @@ main (int argc, char *argv[])
        /* nothing to do */;
       else if (p->version >= EXTERNAL_PINFO_VERSION_32_BIT)
        {
-         if (p->uid32 != (__uid32_t) uid)
+         if (p->uid32 != uid)
            continue;
        }
       else if (p->uid != uid)
index 5a4244e3e18c7f8989c1e972ef5df44740401e78..86f2bb61f1b5d81532455798a1e0fa324e065c19 100644 (file)
@@ -190,7 +190,7 @@ print_version ()
 }
 
 void
-Fail (DWORD rv)
+Fail (unsigned int rv)
 {
   char *buf;
   if (!quiet)
@@ -198,7 +198,7 @@ Fail (DWORD rv)
       FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER
                     | FORMAT_MESSAGE_FROM_SYSTEM,
                     0, rv, 0, (CHAR *) & buf, 0, 0);
-      fprintf (stderr, "Error (%ld): %s\n", rv, buf);
+      fprintf (stderr, "Error (%d): %s\n", rv, buf);
       LocalFree (buf);
     }
   exit (1);
@@ -512,8 +512,8 @@ cmd_list ()
                printf ("\n");
                break;
              case REG_DWORD:
-               printf ("0x%08lx (%lu)\n", *(DWORD *) value_data,
-                       *(DWORD *) value_data);
+               printf ("0x%08x (%u)\n", *(unsigned int *) value_data,
+                       *(unsigned int *) value_data);
                break;
              case REG_DWORD_BIG_ENDIAN:
                v = ((value_data[0] << 24)
@@ -773,14 +773,14 @@ cmd_get ()
        fwrite (data, dsize, 1, stdout);
        break;
       case REG_DWORD:
-       printf (hex ? "0x%08lx\n" : "%lu\n", *(DWORD *) data);
+       printf (hex ? "0x%08x\n" : "%u\n", *(unsigned int *) data);
        break;
       case REG_DWORD_BIG_ENDIAN:
        rv = ((data[0] << 24)
              | (data[1] << 16)
              | (data[2] << 8)
              | (data[3]));
-       printf (hex ? "0x%08lx\n" : "%lu\n", rv);
+       printf (hex ? "0x%08x\n" : "%u\n", (unsigned int) rv);
        break;
       case REG_QWORD:
        printf (hex ? "0x%016llx\n" : "%llu\n", *(unsigned long long *) data);
index 63aa9197eaf3e9f4723c70bfe940cb2688a3af5d..3136a9f66383a2dfffe3b6451b99af8950c7e7ec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2001, 2002, 2009, 2011 Red Hat, Inc.
+ * Copyright (c) 2000, 2001, 2002, 2009, 2011, 2013 Red Hat, Inc.
  *
  *     This program is free software; you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
  *
  */
 
+#ifdef __x86_64__
+
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+  fprintf (stderr, "%s: This application is unsuported on x86_64 so far.\n",
+          argv[0]);
+  return 1;
+}
+
+#else
+
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
@@ -939,3 +953,4 @@ main (int argc, char **argv)
   exit (0);
 }
 
+#endif /* !__x86_64 */
index 62d40860133d614805dd24fe775cbeaf1bc7aa6a..73096ab3b0b35c2182285d01033599bb185ce852 100644 (file)
@@ -1,7 +1,7 @@
 /* strace.cc
 
    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-   2009, 2010, 2011 Red Hat Inc.
+   2009, 2010, 2011, 2012, 2013 Red Hat Inc.
 
    Written by Chris Faylor <cgf@redhat.com>
 
@@ -265,7 +265,7 @@ ctrl_c (DWORD)
 }
 
 extern "C" {
-unsigned long (*cygwin_internal) (int, ...);
+uintptr_t (*cygwin_internal) (int, ...);
 WCHAR cygwin_dll_path[32768];
 };
 
@@ -286,7 +286,7 @@ load_cygwin ()
       return 0;
     }
   GetModuleFileNameW (h, cygwin_dll_path, 32768);
-  if (!(cygwin_internal = (DWORD (*) (int, ...)) GetProcAddress (h, "cygwin_internal")))
+  if (!(cygwin_internal = (uintptr_t (*) (int, ...)) GetProcAddress (h, "cygwin_internal")))
     {
       errno = ENOSYS;
       return 0;
@@ -437,7 +437,7 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
   int len;
   int special;
   char alen[3 + 8 + 1];
-  DWORD nbytes;
+  SIZE_T nbytes;
   child_list *child = get_child (id);
   if (!child)
     error (0, "no process id %d found", id);
@@ -482,7 +482,11 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
   buf[len] = '\0';
   char *s = strtok (buf, " ");
 
+#ifdef __x86_64__
+  unsigned long long n = strtoull (s, NULL, 16);
+#else
   unsigned long n = strtoul (s, NULL, 16);
+#endif
 
   s = strchr (s, '\0') + 1;
 
@@ -619,7 +623,11 @@ handle_output_debug_string (DWORD id, LPVOID p, unsigned mask, FILE *ofile)
   if (include_hex)
     {
       s -= 8;
-      sprintf (s, "%p", (void *) n);
+#ifdef __x86_64__
+      sprintf (s, "%012I64x", n);
+#else
+      sprintf (s, "%08lx", n);
+#endif
       strchr (s, '\0')[0] = ' ';
     }
   child->last_usecs = usecs;
@@ -691,8 +699,9 @@ proc_child (unsigned mask, FILE *ofile, pid_t pid)
            {
              status = DBG_EXCEPTION_NOT_HANDLED;
              if (ev.u.Exception.dwFirstChance)
-               fprintf (ofile, "--- Process %lu, exception %p at %p\n", ev.dwProcessId,
-                        (void *) ev.u.Exception.ExceptionRecord.ExceptionCode,
+               fprintf (ofile, "--- Process %lu, exception %08lx at %p\n",
+                        ev.dwProcessId,
+                        ev.u.Exception.ExceptionRecord.ExceptionCode,
                         ev.u.Exception.ExceptionRecord.ExceptionAddress);
            }
          break;
@@ -966,7 +975,7 @@ main (int argc, char **argv)
   if (load_cygwin ())
     {
       char **av = (char **) cygwin_internal (CW_ARGV);
-      if (av && (DWORD) av != (DWORD) -1)
+      if (av && (uintptr_t) av != (uintptr_t) -1)
        for (argc = 0, argv = av; *av; av++)
          argc++;
     }
index a3abe315e4e1e5422aaeb28373f460b41a1f5e7e..45f3f16554a9d60e232ad9b4230e739a0623e9e5 100644 (file)
@@ -1,6 +1,6 @@
 /* tzset.c: Convert current Windows timezone to POSIX timezone information.
 
-   Copyright 2012 Red Hat, Inc.
+   Copyright 2012, 2013 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -10,6 +10,7 @@ details. */
 
 #include <errno.h>
 #include <stdio.h>
+#include <inttypes.h>
 #include <wchar.h>
 #include <locale.h>
 #include <getopt.h>
@@ -518,8 +519,8 @@ reg_open (HKEY pkey, PCWSTR path, const char *msg)
   if (ret == ERROR_SUCCESS)
     return hkey;
   if (msg)
-    fprintf (stderr, "%s: cannot open registry %s, error code %ld\n",
-            program_invocation_short_name, msg, ret);
+    fprintf (stderr, "%s: cannot open registry %s, error code %" PRIu32 "\n",
+            program_invocation_short_name, msg, (unsigned int) ret);
   return NULL;
 }
 
@@ -536,8 +537,8 @@ reg_query (HKEY hkey, PCWSTR value, PWCHAR buf, DWORD size, const char *msg)
   if (ret == ERROR_SUCCESS)
     return TRUE;
   if (msg)
-    fprintf (stderr, "%s: cannot query registry %s, error code %ld\n",
-            program_invocation_short_name, msg, ret);
+    fprintf (stderr, "%s: cannot query registry %s, error code %" PRIu32 "\n",
+            program_invocation_short_name, msg, (unsigned int) ret);
   return FALSE;
 }
 
@@ -709,10 +710,12 @@ main (int argc, char **argv)
        }
       idx = gotit;
     }
-  /* Got one.  Print it. */
-  spc = wcschr (tzmap[idx].posix_tzid, ' ');
-  if (spc)
-    *spc = L'\0';
-  printf ("%ls\n", tzmap[idx].posix_tzid);
+  /* Got one.  Print it.
+     Note: The tzmap array is in the R/O data section on x86_64.  Don't
+           try to overwrite the space, as the code did originally. */
+  spc = wcschr (tzmap[idx].posix_tzid, L' ');
+  if (!spc)
+    spc = wcschr (tzmap[idx].posix_tzid, L'\0');
+  printf ("%.*ls\n", (int) (spc - tzmap[idx].posix_tzid), tzmap[idx].posix_tzid);
   return 0;
 }
This page took 1.124175 seconds and 5 git commands to generate.