Subject: wsevent cleanup
To: None <tech-kern@netbsd.org>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 02/06/2006 12:21:58
------=_Part_20520_17363843.1139224918812
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi,

while looking at wscons' code I noticed that it duplicates a "lot" of
code to manipulate wsevent queues.  For example, all queue additions
are done by checking if there is enough space in it, directly accessing
the object and manually advancing the put pointer.  This is ugly and
error prone.

Also, the code in wsmouse.c tries to "simplify" this by defining several
macros, which make it very confusing if you need to see what's really
going on.

I've done the following:

- Add two new functions, wsevent_free and wsevent_inject.  The former
  returns the amount of free space in the queue and the latter adds a
  new event to it.  The latter assumes that the queue has at least one
  free slot.
- Replace the WSEVENT_WAKEUP macro with a regular function.  I see
  no reason for this to be a macro.
- Move the definition of WSEVENT_QSIZE, PWSEVENT and splwsevent
  from the wseventvar.h header file to the wsevent.c file, as no other
  code uses/should use them.
- Make the wsevent_init function take a process to attach to the queue,
  instead of leaving this task to the caller (which always does it, anyway)=