Re: Add PAGE_SIZE, PAGE_SHIFT, PAGE_MASK to sys/param.h

2003-10-31 Thread Corinna Vinschen
On Thu, Oct 30, 2003 at 04:15:39PM -0500, Nicholas Wourms wrote:
 I just want to make sure that I do the right thing.  The numbering seems 
 arbitrary, however I could be wrong.  I just wonder why none of our 
 ioctls are _IOWR, when they are defined that way for bsd/linux?  Perhaps 
 this is a limitation of the winsock?  It could be that I'm just making a 
 big deal over nothing, but I wanted to check first.

It's just not defined in asm/socket.h.  I've always interpreted the _IOW as
a read/write, not just as write.  Now, looking into it again, I see that
using _IOW for the SIOCGIF* control codes was just wrong from the beginning.
They should have been _IOR.  Too bad.  But we can't change that now, since
that would break existing applications.

I'm wondering if we should redefine them, though, and mark the old
values as deprecated, using them in Cygwin only for backward compatibility. 
The new values could easily start from 4.  I'll guess we'll never get
the problem to be out of values...

 Don't bother.  Is it a value which could be changed in Cygwin or Winsock?
 
 I don't know, I guess I'll just make it 108 and see what happens.  The 
 group code seems to be arbitrary as well, so I'll just stick with the 
 flow and use `i'.

i?  What i?

 What are you trying to implement?  I'm really curious.
 
 [SIOCGIFDSTADDR]

Cool.

 (Gee, a 
 copy of unix network programming 2nd edition would come in handy right 
 about now)

I can recommend it.  It's really good, IMHO just missing info about
using the resolver routines.

   Not to rant, but 
 our network sockets seems lacking in a few areas, so I hope to 
 contribute there.

Sure they do.  You're welcome to contribute in that area.

Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Developermailto:[EMAIL PROTECTED]
Red Hat, Inc.


[PATCH] Fix debugger attach for threads

2003-10-31 Thread Thomas Pfaff
This patch allows a debugger to attach when an exception occurs in a 
thread other than the mainthread.

I am not happy about the wait in handle_exceptions, but it works on my 
machine. I think that a waitloop until the debugger is attached is 
cleaner, but there must be a reason why the debbugging loop is 
implemented this way.

Thomas

003-10-31  Thomas Pfaff  [EMAIL PROTECTED]

* exceptions.cc (try_to_debug): Suspend/resume all threads when
a debugger is attaching.
(handle_exceptions): Give debugger CPU time to attach.
? suspend_all_on_stop.patch
? thread_try_to_debug.patch
Index: exceptions.cc
===
RCS file: /cvs/src/src/winsup/cygwin/exceptions.cc,v
retrieving revision 1.172
diff -u -p -r1.172 exceptions.cc
--- exceptions.cc   14 Oct 2003 09:21:55 -  1.172
+++ exceptions.cc   31 Oct 2003 20:50:31 -
@@ -360,9 +360,7 @@ try_to_debug (bool waitloop)
   si.dwFlags = 0;
   si.cb = sizeof (si);
 
-  /* FIXME: need to know handles of all running threads to
- suspend_all_threads_except (current_thread_id);
-  */
+  pthread::suspend_all_except_self ();
 
   /* if any of these mutexes is owned, we will fail to start any cygwin app
  until trapped app exits */
@@ -400,7 +398,10 @@ try_to_debug (bool waitloop)
   else
 {
   if (!waitloop)
-   return 1;
+{
+  pthread::resume_all ();
+  return 1;
+}
   SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
   while (!being_debugged ())
Sleep (0);
@@ -409,9 +410,8 @@ try_to_debug (bool waitloop)
   SetThreadPriority (GetCurrentThread (), prio);
 }
 
-  /* FIXME: need to know handles of all running threads to
-resume_all_threads_except (current_thread_id);
-  */
+  pthread::resume_all ();
+
   return 0;
 }
 
@@ -426,7 +426,15 @@ handle_exceptions (EXCEPTION_RECORD *e, 
 
   if (debugging  ++debugging  50)
 {
-  SetThreadPriority (hMainThread, THREAD_PRIORITY_NORMAL);
+  /*
+   * Give debugger a chance to attach
+   */
+  LONG prio = GetThreadPriority (GetCurrentThread ());
+  pthread::suspend_all_except_self ();
+  SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_IDLE);
+  Sleep (0);
+  SetThreadPriority (GetCurrentThread (), prio);
+  pthread::resume_all ();
   return 0;
 }