[PATCH] for SIGSEGV, compilation error in gcc 4.6
2011-02-10 * environ.cc (getwinenv,getwinenveq,build_env):Add __attribute__ ((regparm (x))) in function definition. (pfnenv):Define. (findenv_func):Use it. (environ_init):Ditto. * syscalls.cc (stat_worker):Add __attribute__ ((regparm (x))) in function definition. * window.cc (wininfo::process,process_window_events,wininfo::winthread):Ditto. * strfuncs.cc (sys_cp_wcstombs,sys_wcstombs,sys_wcstombs_alloc,sys_cp_mbstowcs,sys_mbstowcs,sys_mbstowcs_alloc):Ditto. * spawn.cc (find_exec):Ditto. * sigproc.cc (pid_exists,proc_subproc,sig_clear,sig_send,checkstate):Ditto. * signal.cc (handle_sigprocmask,_pinfo::kill):Ditto. * sec_helper.cc (__sec_user):Ditto. * pipe.cc (fhandler_pipe::fstatvfs):Ditto. * pinfo.cc (_pinfo::exists):Ditto. * path.cc (mkrelpath,nofinalslash,hash_path_name):Ditto. * ntea.cc (read_ea,write_ea):Ditto. * miscfuncs.cc (check_invalid_virtual_addr):Ditto. * fhandler_zero.cc (fhandler_dev_zero::read):Ditto. * fhandler_windows.cc (fhandler_windows::read):Ditto. * fhandler_virtual.cc (fhandler_virtual::(read,fstatvfs)):Ditto. * fhandler_tty.cc (fhandler_tty_slave::(read,fstat,fchmod,fchown),fhandler_pty_master::read):Ditto. * fhandler_socket.cc (fhandler_socket::(fstat,fstatvfs)):Ditto. * fhandler_raw.cc (fhandler_dev_raw::fstat):Ditto. * fhandler_random.cc (fhandler_dev_random::read):Ditto. * fhandler_procsys.cc (fhandler_procsys::read):Ditto. * fhandler_mem.cc (fhandler_dev_mem::read):Ditto. * fhandler_mailslot.cc (fhandler_mailslot::fstat):Ditto. * fhandler_fifo.cc (fhandler_fifo::fstatvfs):Ditto. * fhandler_dsp.cc (fhandler_dev_dsp::read):Ditto. * fhandler_disk_file.cc (fhandler_base::(fstat_by_nfs_ea,fstat_by_handle,fstat_by_name,fstat_fs,fstat_helper),fhandler_disk_file::(fstat,fstatvfs,fchmod,fchown,facl,pread,pwrite),readdir_get_ino):Ditto. * fhandler_console.cc (fhandler_console::read):Ditto. * fhandler_clipboard.cc (fhandler_dev_clipboard::read):Ditto. * fhandler.cc (fhandler_base::(read,pread,pwrite,fstat,fstatvfs),fhandler_base_overlapped::read_overlapped):Ditto. * exceptions.cc (rtl_unwind,_cygtls::interrupt_setup,sigpacket::process):Ditto. * errno.cc (geterrno_from_win_error,seterrno_from_win_error,seterrno_from_nt_status,seterrno):Ditto. * debug.cc (modify_handle,add_handle,close_handle):Ditto. * dcrt0.cc (do_exit,cygbench):Ditto. * cygheap.cc (_cmalloc,_crealloc,_cfree,crealloc,crealloc_abort,cfree,cfree_and_set,ccalloc,ccalloc_abort,cwcsdup,cwcsdup1,cstrdup,cstrdup1):Ditto. Index: winsup/cygwin/cygheap.cc === RCS file: /cvs/src/src/winsup/cygwin/cygheap.cc,v retrieving revision 1.155 diff -u -r1.155 cygheap.cc --- winsup/cygwin/cygheap.cc31 May 2010 18:52:02 -1.155 +++ winsup/cygwin/cygheap.cc9 Feb 2011 20:19:16 - @@ -178,10 +178,10 @@ /* Copyright (C) 1997, 2000 DJ Delorie */ -static void *_cmalloc (unsigned size) __attribute ((regparm(1))); -static void *__stdcall _crealloc (void *ptr, unsigned size) __attribute ((regparm(2))); +static void *__stdcall _cmalloc (unsigned size) __attribute__ ((regparm(1))); +static void *__stdcall _crealloc (void *ptr, unsigned size) __attribute__ ((regparm(2))); -static void *__stdcall +static void *__stdcall __attribute__ ((regparm(1))) _cmalloc (unsigned size) { _cmalloc_entry *rvc; @@ -215,7 +215,7 @@ return rvc->data; } -static void __stdcall +static void __stdcall __attribute__((regparm(1))) _cfree (void *ptr) { cygheap_protect.acquire (); @@ -226,7 +226,7 @@ cygheap_protect.release (); } -static void *__stdcall +static void *__stdcall __attribute__ ((regparm(2))) _crealloc (void *ptr, unsigned size) { void *newptr; @@ -295,7 +295,7 @@ return cmalloc (x, n, "cmalloc"); } -inline static void * +inline static void * __stdcall __attribute__ ((regparm(2))) crealloc (void *s, DWORD n, const char *fn) { MALLOC_CHECK; @@ -309,19 +309,19 @@ return creturn (t, c, n, fn); } -extern "C" void *__stdcall +extern "C" void *__stdcall __attribute__ ((regparm(2))) crealloc (void *s, DWORD n) { return crealloc (s, n, NULL); } -extern "C" void *__stdcall +extern "C" void *__stdcall __attribute__ ((regparm(2))) crealloc_abort (void *s, DWORD n) { return crealloc (s, n, "crealloc"); } -extern "C" void __stdcall +extern "C" void __stdcall __attribute__ ((regparm(1))) cfree (void *s) { assert (!inheap (s)); @@ -329,7 +329,7 @@ MALLOC_CHECK; } -extern "C" void __stdcall +extern "C" void __stdcall __attribute__ ((regparm(2))) cfree_and_set (char *&s, char *what) { if (s && s != almost_null) @@ -349,19 +349,19 @@ return creturn (x, c, n, fn); } -extern "C" void *__stdcall +extern "C" void *__stdcall __attribute__ ((regparm(3))) ccalloc (cygheap_types x, DWORD n, DWORD size) { return ccalloc (x, n, size, NULL); }
Re: provide __xpg_strerror_r
On 02/06/2011 02:54 AM, Corinna Vinschen wrote: >> We already provide our own strerror() (it provides a better experience >> for out-of-range values that the newlib interface), but we're currently >> using the newlib strerror_r() (in spite of its truncation flaw). >> >> How should I rework this patch? > > It would be better if we implement strerror_r locally, in two versions, > just as on Linux. I think the best approach is to implement this in > newlib first (I replied to your mail there) and then, given that we use > the newlib string.h, copy the method over to Cygwin to match our current > strerror more closely. Here's the cygwin side of things, to match newlib's changes. Surprisingly, strerror_r turned out to be identical even when based on different root strerror(), so I left that inside #if 0, but it's easy enough to kill the #if 0 if you don't want cygwin to use any of newlib's strerror*. --- winsup/cygwin/ChangeLog|9 +++ winsup/cygwin/cygwin.din |1 + winsup/cygwin/errno.cc | 84 +--- winsup/cygwin/include/cygwin/version.h |3 +- 4 files changed, 68 insertions(+), 29 deletions(-) 2011-02-09 Eric Blake * errno.cc (__xpg_strerror_r): New function. (strerror_r): Update comments to match newlib's fixes. (strerror): Set errno on failure. (_sys_errlist): Cause EINVAL failure for reserved values. * cygwin.din: Export new function. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 2e7e647..780179a 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -1933,6 +1933,7 @@ xdrrec_skiprecord SIGFE __xdrrec_getrec SIGFE __xdrrec_setnonblock SIGFE xdrstdio_create SIGFE +__xpg_strerror_r SIGFE y0 NOSIGFE y0f NOSIGFE y1 NOSIGFE diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc index a9860f4..0e9c863 100644 --- a/winsup/cygwin/errno.cc +++ b/winsup/cygwin/errno.cc @@ -199,9 +199,9 @@ const char *_sys_errlist[] NO_COPY_INIT = /* EL2HLT 44 */ "Level 2 halted", /* EDEADLK 45 */ "Resource deadlock avoided", /* ENOLCK 46 */ "No locks available", - "error 47", - "error 48", - "error 49", + NULL, + NULL, + NULL, /* EBADE 50 */ "Invalid exchange", /* EBADR 51 */ "Invalid request descriptor", /* EXFULL 52 */ "Exchange full", @@ -210,8 +210,8 @@ const char *_sys_errlist[] NO_COPY_INIT = /* EBADSLT 55 */ "Invalid slot", /* EDEADLOCK 56 */ "File locking deadlock error", /* EBFONT 57 */ "Bad font file format", - "error 58", - "error 59", + NULL, + NULL, /* ENOSTR 60 */ "Device not a stream", /* ENODATA 61 */ "No data available", /* ETIME 62 */ "Timer expired", @@ -224,13 +224,13 @@ const char *_sys_errlist[] NO_COPY_INIT = /* ESRMNT 69 */ "Srmount error", /* ECOMM 70 */ "Communication error on send", /* EPROTO 71 */ "Protocol error", - "error 72", - "error 73", + NULL, + NULL, /* EMULTIHOP 74 */ "Multihop attempted", /* ELBIN 75 */ "Inode is remote (not really error)", /* EDOTDOT 76 */ "RFS specific error", /* EBADMSG 77 */ "Bad message", - "error 78", + NULL, /* EFTYPE 79 */ "Inappropriate file type or format", /* ENOTUNIQ 80 */"Name not unique on network", /* EBADFD 81 */ "File descriptor in bad state", @@ -245,17 +245,17 @@ const char *_sys_errlist[] NO_COPY_INIT = /* ENOTEMPTY 90*/"Directory not empty", /* ENAMETOOLONG 91 */"File name too long", /* ELOOP 92 */ "Too many levels of symbolic links", - "error 93", - "error 94", + NULL, + NULL, /* EOPNOTSUPP 95 */ "Operation not supported", /* EPFNOSUPPORT 96 */"Protocol family not supported", - "error 97", - "error 98", - "error 99", - "error 100", - "error 101", - "error 102", - "error 103", + NULL, + NULL, + NULL, + NULL, + NULL, +
Re: provide __xpg_strerror_r
On Wed, Feb 09, 2011 at 05:20:59PM -0700, Eric Blake wrote: >On 02/06/2011 02:54 AM, Corinna Vinschen wrote: >>> We already provide our own strerror() (it provides a better experience >>> for out-of-range values that the newlib interface), but we're currently >>> using the newlib strerror_r() (in spite of its truncation flaw). >>> >>> How should I rework this patch? >> >> It would be better if we implement strerror_r locally, in two versions, >> just as on Linux. I think the best approach is to implement this in >> newlib first (I replied to your mail there) and then, given that we use >> the newlib string.h, copy the method over to Cygwin to match our current >> strerror more closely. > >Here's the cygwin side of things, to match newlib's changes. > Surprisingly, strerror_r turned out to be identical even when based on >different root strerror(), so I left that inside #if 0, but it's easy >enough to kill the #if 0 if you don't want cygwin to use any of newlib's >strerror*. > >--- > winsup/cygwin/ChangeLog|9 +++ > winsup/cygwin/cygwin.din |1 + > winsup/cygwin/errno.cc | 84 >+--- > winsup/cygwin/include/cygwin/version.h |3 +- > 4 files changed, 68 insertions(+), 29 deletions(-) > >2011-02-09 Eric Blake > > * errno.cc (__xpg_strerror_r): New function. > (strerror_r): Update comments to match newlib's fixes. > (strerror): Set errno on failure. > (_sys_errlist): Cause EINVAL failure for reserved values. > * cygwin.din: Export new function. > * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. > >-- >Eric Blake ebl...@redhat.com+1-801-349-2682 >Libvirt virtualization library http://libvirt.org >diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din >index 2e7e647..780179a 100644 >--- a/winsup/cygwin/cygwin.din >+++ b/winsup/cygwin/cygwin.din >@@ -1933,6 +1933,7 @@ xdrrec_skiprecord SIGFE > __xdrrec_getrec SIGFE > __xdrrec_setnonblock SIGFE > xdrstdio_create SIGFE >+__xpg_strerror_r SIGFE > y0 NOSIGFE > y0f NOSIGFE > y1 NOSIGFE >diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc >index a9860f4..0e9c863 100644 >--- a/winsup/cygwin/errno.cc >+++ b/winsup/cygwin/errno.cc >@@ -199,9 +199,9 @@ const char *_sys_errlist[] NO_COPY_INIT = > /* EL2HLT 44 */ "Level 2 halted", > /* EDEADLK 45 */"Resource deadlock avoided", > /* ENOLCK 46 */ "No locks available", >-"error 47", >-"error 48", >-"error 49", >+NULL, >+NULL, >+NULL, > /* EBADE 50 */ "Invalid exchange", > /* EBADR 51 */ "Invalid request descriptor", > /* EXFULL 52 */ "Exchange full", >@@ -210,8 +210,8 @@ const char *_sys_errlist[] NO_COPY_INIT = > /* EBADSLT 55 */"Invalid slot", > /* EDEADLOCK 56 */ "File locking deadlock error", > /* EBFONT 57 */ "Bad font file format", >-"error 58", >-"error 59", >+NULL, >+NULL, > /* ENOSTR 60 */ "Device not a stream", > /* ENODATA 61 */"No data available", > /* ETIME 62 */ "Timer expired", >@@ -224,13 +224,13 @@ const char *_sys_errlist[] NO_COPY_INIT = > /* ESRMNT 69 */ "Srmount error", > /* ECOMM 70 */ "Communication error on send", > /* EPROTO 71 */ "Protocol error", >-"error 72", >-"error 73", >+NULL, >+NULL, > /* EMULTIHOP 74 */ "Multihop attempted", > /* ELBIN 75 */ "Inode is remote (not really error)", > /* EDOTDOT 76 */"RFS specific error", > /* EBADMSG 77 */"Bad message", >-"error 78", >+NULL, > /* EFTYPE 79 */ "Inappropriate file type or format", > /* ENOTUNIQ 80 */ "Name not unique on network", > /* EBADFD 81 */ "File descriptor in bad state", >@@ -245,17 +245,17 @@ const char *_sys_errlist[] NO_COPY_INIT = > /* ENOTEMPTY 90 */"Directory not empty", > /* ENAMETOOLONG 91 */ "File name too long", > /* ELOOP 92 */ "Too many levels of symbolic links", >-"error 93", >-"error 94", >+NULL, >+NULL, > /* EOPNOTSUPP 95 */ "Operation not supported", > /* EPFNOSUPPORT 96 */ "Protocol family not supported", >-"error 97", >-"error 98", >-"error 99", >-"error 100", >-"error 101", >-"error 102", >-"error 103", >+
[PATCH] pthread_yield
pthread_yield(3) was part of the POSIX.1c drafts but never made it into the final standard. Nevertheless, it is provided by Linux[1], FreeBSD[2], OpenBSD[3], AIX[4], and possibly other *NIXes. "On Linux, this function is implemented as a call to sched_yield(2)." Patch attached. Yaakov [1] http://www.kernel.org/doc/man-pages/online/pages/man3/pthread_yield.3.html [2] http://www.freebsd.org/cgi/man.cgi?query=pthread_yield [3] http://www.openbsd.org/cgi-bin/man.cgi?query=pthread_yield [4] http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.basetechref/doc/basetrf1/pthread_yield.htm 2011-02-09 Yaakov Selkowitz * cygwin.din (pthread_yield): Export as alias to sched_yield. * include/pthread.h (pthread_yield): Declare. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. * posix.sgml (std-deprec): Add pthread_yield. Index: cygwin.din === RCS file: /cvs/src/src/winsup/cygwin/cygwin.din,v retrieving revision 1.229 diff -u -r1.229 cygwin.din --- cygwin.din 13 Jan 2011 13:48:12 - 1.229 +++ cygwin.din 10 Feb 2011 03:11:52 - @@ -1245,6 +1245,7 @@ pthread_sigmask SIGFE pthread_suspend SIGFE pthread_testcancel SIGFE +pthread_yield = sched_yield SIGFE ptsname SIGFE putc SIGFE _putc = putc SIGFE Index: include/pthread.h === RCS file: /cvs/src/src/winsup/cygwin/include/pthread.h,v retrieving revision 1.26 diff -u -r1.26 pthread.h --- include/pthread.h 7 Feb 2007 17:22:40 - 1.26 +++ include/pthread.h 10 Feb 2011 03:11:53 - @@ -194,6 +194,7 @@ int pthread_suspend (pthread_t); int pthread_continue (pthread_t); +int pthread_yield (void); #ifdef __cplusplus } Index: include/cygwin/version.h === RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/version.h,v retrieving revision 1.332 diff -u -r1.332 version.h --- include/cygwin/version.h 12 Jan 2011 13:01:43 - 1.332 +++ include/cygwin/version.h 10 Feb 2011 03:11:53 - @@ -399,12 +399,13 @@ 233: Add TIOCGPGRP, TIOCSPGRP. Export llround, llroundf. 234: Export program_invocation_name, program_invocation_short_name. 235: Export madvise. + 236: Export pthread_yield. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 235 +#define CYGWIN_VERSION_API_MINOR 236 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible Index: posix.sgml === RCS file: /cvs/src/src/winsup/cygwin/posix.sgml,v retrieving revision 1.52 diff -u -r1.52 posix.sgml --- posix.sgml 12 Jan 2011 13:09:31 - 1.52 +++ posix.sgml 10 Feb 2011 05:13:45 - @@ -1225,6 +1225,7 @@ pthread_continue (XPG2) pthread_getsequence_np (Tru64) pthread_suspend (XPG2) +pthread_yield (POSIX.1c drafts) pututline (XPG2) putw (SVID) rindex (SUSv3)
Re: [PATCH] pthread_yield
On Wed, Feb 09, 2011 at 11:49:58PM -0600, Yaakov (Cygwin/X) wrote: >pthread_yield(3) was part of the POSIX.1c drafts but never made it into >the final standard. Nevertheless, it is provided by Linux[1], >FreeBSD[2], OpenBSD[3], AIX[4], and possibly other *NIXes. > >"On Linux, this function is implemented as a call to sched_yield(2)." >Patch attached. Please check in. Thanks. cgf