Throughout, use user32 UNICODE functions rather than ANSI functions.

* autoload.cc: Convert all definitions for ANSI user32 functions to
	definitions for the corresponding UNICODE function.
	(SendMessageA): Remove.
	(SendNotifyMessageW): Define.
	* fhandler_windows.cc (fhandler_windows::write): Use SendNotifyMessageW
	call rather than SendMessage to make function always return immediately.
	(fhandler_windows::read): Make function interruptible and a cancellation
	point.  Handle O_NONBLOCK.
	* select.cc (peek_serial): Don't wait for signal_arrived here.
	* window.cc (wininfo::winthread): Call CreateWindowExW directly rather
	than CreateWindow wrapper.
This commit is contained in:
Corinna Vinschen
2011-05-01 14:35:12 +00:00
parent c60d0bbe68
commit 79e741ef6f
7 changed files with 93 additions and 63 deletions

View File

@ -1,7 +1,7 @@
/* fhandler_windows.cc: code to access windows message queues.
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009
Red Hat, Inc.
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009,
2011 Red Hat, Inc.
Written by Sergey S. Okhapkin (sos@prospect.com.ru).
Feedback and testing by Andy Piper (andyp@parallax.co.uk).
@ -18,13 +18,15 @@ details. */
#include "cygerrno.h"
#include "path.h"
#include "fhandler.h"
#include "sigproc.h"
#include "thread.h"
/*
The following unix-style calls are supported:
open ("/dev/windows", flags, mode=0)
- create a unix fd for message queue.
O_NONBLOCK flag controls the read() call behavior.
read (fd, buf, len)
- return next message from queue. buf must point to MSG
@ -67,16 +69,19 @@ fhandler_windows::write (const void *buf, size_t)
if (method_ == WINDOWS_POST)
{
if (!PostMessage (ptr->hwnd, ptr->message, ptr->wParam, ptr->lParam))
if (!PostMessageW (ptr->hwnd, ptr->message, ptr->wParam, ptr->lParam))
{
__seterrno ();
return -1;
}
else
return sizeof (MSG);
}
else
return SendMessage (ptr->hwnd, ptr->message, ptr->wParam, ptr->lParam);
else if (!SendNotifyMessageW (ptr->hwnd, ptr->message, ptr->wParam,
ptr->lParam))
{
__seterrno ();
return -1;
}
return sizeof (MSG);
}
void __stdcall
@ -91,10 +96,47 @@ fhandler_windows::read (void *buf, size_t& len)
return;
}
len = (size_t) GetMessage (ptr, hWnd_, 0, 0);
if ((ssize_t) len == -1)
__seterrno ();
HANDLE w4[3] = { get_handle (), signal_arrived, NULL };
DWORD cnt = 2;
pthread_t thread = pthread::self ();
if (thread && thread->cancel_event
&& thread->cancelstate != PTHREAD_CANCEL_DISABLE)
w4[cnt++] = thread->cancel_event;
restart:
switch (MsgWaitForMultipleObjectsEx (cnt, w4,
is_nonblocking () ? 0 : INFINITE,
QS_ALLINPUT | QS_ALLPOSTMESSAGE,
MWMO_INPUTAVAILABLE))
{
case WAIT_OBJECT_0:
if (!PeekMessageW (ptr, hWnd_, 0, 0, PM_REMOVE))
{
len = (size_t) -1;
__seterrno ();
}
else if (ptr->message == WM_QUIT)
len = 0;
else
len = sizeof (MSG);
break;
case WAIT_OBJECT_0 + 1:
if (_my_tls.call_signal_handler ())
goto restart;
len = (size_t) -1;
set_errno (EINTR);
break;
case WAIT_OBJECT_0 + 2:
pthread::static_cancel_self ();
break;
case WAIT_TIMEOUT:
len = (size_t) -1;
set_errno (EAGAIN);
break;
default:
len = (size_t) -1;
__seterrno ();
break;
}
}
int