Re: provide __xpg_strerror_r

2011-02-10 Thread Corinna Vinschen
On Feb  9 21:15, Christopher Faylor wrote:
 On Wed, Feb 09, 2011 at 05:20:59PM -0700, Eric Blake wrote:
 +/* Newlib's string.h provides declarations for two strerror_r
 +   variants, according to preprocessor feature macros.  It does the
 +   right thing for GNU strerror_r, but its __xpg_strerror_r mishandles
 +   a case of EINVAL when coupled with our strerror() override.*/
  #if 0
 
 Can't we get rid of this now?

I agree.  We should simply implement strerror_r by ourselves, even if
it's identical to newlib's strerror_r.  In the long run it's less
puzzeling to have all the strerror variants in one place.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat


Re: [PATCH] pthread_yield

2011-02-10 Thread Corinna Vinschen
On Feb 10 01:04, Christopher Faylor wrote:
 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.

Two notes:

- We should use the API version bump to 236 for both new functions,
  __xpg_strerror_r as well as pthread_yield.

- Please add the new entry point to doc/new-features.sgml.


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat


Re: provide __xpg_strerror_r

2011-02-10 Thread Corinna Vinschen
On Feb 10 10:50, Corinna Vinschen wrote:
 On Feb  9 21:15, Christopher Faylor wrote:
  On Wed, Feb 09, 2011 at 05:20:59PM -0700, Eric Blake wrote:
  +/* Newlib's string.h provides declarations for two strerror_r
  +   variants, according to preprocessor feature macros.  It does the
  +   right thing for GNU strerror_r, but its __xpg_strerror_r mishandles
  +   a case of EINVAL when coupled with our strerror() override.*/
   #if 0
  
  Can't we get rid of this now?
 
 I agree.  We should simply implement strerror_r by ourselves, even if
 it's identical to newlib's strerror_r.  In the long run it's less
 puzzeling to have all the strerror variants in one place.

Oh, and: http://cygwin.com/ml/cygwin-patches/2011-q1/msg00031.html


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat


Re: [PATCH] for SIGSEGV, compilation error in gcc 4.6

2011-02-10 Thread Corinna Vinschen
On Feb 10 15:15, Corinna Vinschen wrote:
 On Feb 10 21:47, jojelino wrote:
  On 2011-02-10 19:02, Corinna Vinschen wrote:
  
  Also, it would be nice if you would add more words to explain what your
  patch is doing.  Just a patch with no explanation is not very inviting
  to take a look at it at all.
  
  this patch deals with only two problem. and this is first one.
  
  static char * (*findenv_func)(const char *, int *) = (char *
  (*)(const char *, int *)) getearly;
  findenv_func is declared without __stdcall convention, and it is
  casting getearly having __stdcall convention with function type
  without __stdcall convention. to fix this problem, add __stdcall to
  findenv_func.
  
  and this is another one.
  
  this one deals with compilation error that gcc 4.6 complained. so i
  just copy  paste __attribute__((regparm (x))) from function
  declaration to function definition, so i must admit that this one
  was derived from original cygwin source code. that is, you can fix
  it without this patch.
 
 Ok, I have just a problem.  Your patch doesn't apply because your
 mail client appears to insert line breaks if the lines get too long.
 Please send the patch again without the line breaks.  Maybe you could
 just attach it to your mail rather than inlining it.

Oh, and, would you mind to create a new patch which is against current
CVS?  It looks like some of your changes collide with changes already
checked in.


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat


Re: [PATCH] for SIGSEGV, compilation error in gcc 4.6

2011-02-10 Thread jojelino

i am sorry for extra line feed. corrected.
requesting review.
Index: winsup/cygwin/dcrt0.cc
===
RCS file: /cvs/src/src/winsup/cygwin/dcrt0.cc,v
retrieving revision 1.390
diff -u -r1.390 dcrt0.cc
--- winsup/cygwin/dcrt0.cc  26 Dec 2010 21:11:37 -  1.390
+++ winsup/cygwin/dcrt0.cc  10 Feb 2011 14:46:04 -
@@ -1034,7 +1034,7 @@
   sig_dispatch_pending (true);
 }
 
-void __stdcall
+void __stdcall __attribute__ ((regparm (1), noreturn))
 do_exit (int status)
 {
   syscall_printf (do_exit (%d), exit_state %d, status, exit_state);
@@ -1198,7 +1198,7 @@
 }
 
 #ifdef DEBUGGING
-void __stdcall
+void __stdcall __attribute__((regparm (1)))
 cygbench (const char *s)
 {
   if (GetEnvironmentVariableA (CYGWIN_BENCH, NULL, 0))
Index: winsup/cygwin/debug.cc
===
RCS file: /cvs/src/src/winsup/cygwin/debug.cc,v
retrieving revision 1.63
diff -u -r1.63 debug.cc
--- winsup/cygwin/debug.cc  5 Aug 2009 04:44:27 -   1.63
+++ winsup/cygwin/debug.cc  10 Feb 2011 14:46:04 -
@@ -103,7 +103,7 @@
   return NULL;
 }
 
-void __stdcall
+void __stdcall __attribute__ ((regparm (3)))
 modify_handle (const char *func, int ln, HANDLE h, const char *name, bool inh)
 {
   lock_debug here;
@@ -119,7 +119,7 @@
 }
 
 /* Add a handle to the linked list of known handles. */
-void __stdcall
+void __stdcall __attribute__ ((regparm (3)))
 add_handle (const char *func, int ln, HANDLE h, const char *name, bool inh)
 {
   handle_list *hl;
@@ -213,7 +213,7 @@
 
 /* Close a known handle.  Complain if !force and closing a known handle or
if the name of the handle being closed does not match the registered name. 
*/
-bool __stdcall
+bool __stdcall __attribute__ ((regparm (3)))
 close_handle (const char *func, int ln, HANDLE h, const char *name, bool force)
 {
   bool ret;
Index: winsup/cygwin/environ.cc
===
RCS file: /cvs/src/src/winsup/cygwin/environ.cc,v
retrieving revision 1.183
diff -u -r1.183 environ.cc
--- winsup/cygwin/environ.cc18 May 2010 14:30:50 -  1.183
+++ winsup/cygwin/environ.cc10 Feb 2011 14:46:04 -
@@ -156,7 +156,7 @@
   to the beginning of the environment variable name.  *in_posix is any
   known posix value for the environment variable. Returns a pointer to
   the appropriate conversion structure.  */
-win_env * __stdcall
+win_env * __stdcall __attribute__ ((regparm (3)))
 getwinenv (const char *env, const char *in_posix, win_env *temp)
 {
   if (!conv_start_chars[(unsigned char)*env])
@@ -219,7 +219,7 @@
   free (src);
   MALLOC_CHECK;
 }
-
+typedef char* (__stdcall *pfnenv)(const char*,int*);
 /* Returns pointer to value associated with name, if any, else NULL.
   Sets offset to be the offset of the name/value combination in the
   environment array, for use by setenv(3) and unsetenv(3).
@@ -275,7 +275,7 @@
   return NULL;
 }
 
-static char * (*findenv_func)(const char *, int *) = (char * (*)(const char *, 
int *)) getearly;
+static pfnenv findenv_func = getearly;
 
 /* Returns ptr to value associated with name, if any, else NULL.  */
 
@@ -830,7 +830,7 @@
   FreeEnvironmentStringsW (rawenv);
 
 out:
-  findenv_func = (char * (*)(const char*, int*)) my_findenv;
+  findenv_func = my_findenv;
   __cygwin_environ = envp;
   update_envptrs ();
   if (envp_passed_in)
@@ -856,7 +856,7 @@
   return strcmp (*p, *q);
 }
 
-char * __stdcall
+char * __stdcall __attribute__ ((regparm (3)))
 getwinenveq (const char *name, size_t namelen, int x)
 {
   WCHAR name0[namelen - 1];
@@ -956,7 +956,7 @@
filled with null terminated strings, terminated by double null characters.
Converts environment variables noted in conv_envvars into win32 form
prior to placing them in the string.  */
-char ** __stdcall
+char ** __stdcall __attribute__ ((regparm (3)))
 build_env (const char * const *envp, PWCHAR envblock, int envc,
   bool no_envblock)
 {
Index: winsup/cygwin/errno.cc
===
RCS file: /cvs/src/src/winsup/cygwin/errno.cc,v
retrieving revision 1.75
diff -u -r1.75 errno.cc
--- winsup/cygwin/errno.cc  19 Jan 2011 09:15:17 -  1.75
+++ winsup/cygwin/errno.cc  10 Feb 2011 14:46:04 -
@@ -301,7 +301,7 @@
 int NO_COPY_INIT _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
 };
 
-int __stdcall
+int __stdcall __attribute__ ((regparm(2)))
 geterrno_from_win_error (DWORD code, int deferrno)
 {
   for (int i = 0; errmap[i].w != 0; ++i)
@@ -318,7 +318,7 @@
 
 /* seterrno_from_win_error: Given a Windows error code, set errno
as appropriate. */
-void __stdcall
+void __stdcall __attribute__ ((regparm(3)))
 seterrno_from_win_error (const char *file, int line, DWORD code)
 {
   syscall_printf (%s:%d windows error %d, file, line, code);
@@ -327,7 +327,7 @@
 
 /* seterrno_from_nt_status: Given a NT status code, set 

Re: [PATCH] for SIGSEGV, compilation error in gcc 4.6

2011-02-10 Thread Corinna Vinschen
On Feb 10 23:56, jojelino wrote:
 i am sorry for extra line feed. corrected.
 requesting review.

Thanks, will do.  Would you mind to give us your real name for the
ChangeLog entry?


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat


Re: [PATCH] for SIGSEGV, compilation error in gcc 4.6

2011-02-10 Thread jojelino

On 2011-02-11 AM 12:02, Corinna Vinschen wrote:

On Feb 10 23:56, jojelino wrote:

i am sorry for extra line feed. corrected.
requesting review.


Thanks, will do.  Would you mind to give us your real name for the
ChangeLog entry?


Corinna



Jin-woo Ye.thank you


Re: [PATCH] for SIGSEGV, compilation error in gcc 4.6

2011-02-10 Thread Corinna Vinschen
On Feb 10 10:29, Christopher Faylor wrote:
 On Thu, Feb 10, 2011 at 03:15:15PM +0100, Corinna Vinschen wrote:
 Ok, I have just a problem.  Your patch doesn't apply because your
 mail client appears to insert line breaks if the lines get too long.
 Please send the patch again without the line breaks.  Maybe you could
 just attach it to your mail rather than inlining it.
 
 Please don't just apply it.  Some of the changes suffered from a cut/paste
 mentality, where the right solution was not always to just add a __stdcall.
 
 The patch needs to actually be studied and probably applied piecemeal.

Ok, no worries.  If you're looking into that anyway I just drop off from
this thread.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat


Re: [PATCH] for SIGSEGV, compilation error in gcc 4.6

2011-02-10 Thread jojelino

On 2011-02-11 AM 12:32, Christopher Faylor wrote:


-void __stdcall
+void __stdcall __attribute__ ((regparm (1), noreturn))
do_exit (int status)
{


no. it doesn't fix sigsegv, but for compilation error in 4.6.
to summerize, all changes of function definition fixes compilation error 
in gcc 4.6(trunk) and it doesn't fix sigsegv.
fixing sigsegv is done by adding __stdcall to *findenv_func type. and it 
doesn't fix compilation error in 4.6.

it was missing in changelog. so it was added
2011-02-10?@?

* environ.cc (getwinenv,getwinenveq,build_env):Add __attribute__ 
((regparm (x))) in function definition.
(pfnenv):Define. make sure __stdcall is added.
(findenv_func): replace function pointer declaration to above.
use it for casting getearly. fixes segmentation fault in gcc 4.6
(environ_init):do the same as above for my_findenv.

* 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.



Re: provide __xpg_strerror_r

2011-02-10 Thread Christopher Faylor
On Thu, Feb 10, 2011 at 10:37:45AM -0700, Eric Blake wrote:
Pushed, and squashed into minor version 236.  I've also updated
new-features.sgml.

Thanks Eric.

cgf