[PATCH] Cygwin: Provide more COM devices

Achim Gratz Stromeko@nexgo.de
Sat Dec 14 18:38:00 GMT 2019


Achim Gratz writes:
> Corinna Vinschen writes:
> […]
>> ttyS%(0-255) takes another 23K btw.  Even that should be ok, if
>> the need arises.  Alternatively we could shortcut shilka as for
>> /dev/sd*, but that involved much bigger numbers.
>
> I've searched for some documentation (anywhere the glob syntax %(1-128)
> would turn up, btw?) and I think Cygwin is misusing shilka a bit here.
> It's a keyword scanner, so the arithmetically coded parts of the device
> shouldn't be targeted at all.  Instead, only the device path prefix
> should be searched via the shilka lexer and the rest of the conversion
> done in code.

I've stared at the code for quite some time now and I think I've come up
with something that could work.  I'm chopping the device numbers and
disk names off the end of the device name before feeding into the shilka
lexer.  That creates a lexer with only 29 keywords and much less entries
in the dev_storage array, so it should be much faster to search also,
although I think a hash to access the array via the major device number
would now be feasible.  I think I'll have to extend the _device
structure with one or two more function pointers to deal with putting
the minor numbers back in before handing the result to the caller.  In
principle that could deal with any number of devices that fit into the
device number scheme, but we can still declare certain ranges illegal.

--8<---------------cut here---------------start------------->8---
void
device::parse (const char *s)
{
  size_t len = strlen (s);
  const char *t = s + len; /* points past s */

  /* chop off any trailing digits and leave t pointing to the beginning of that number */
  for (; isdigit (t-1); len--, t--) ;

  if (len > 7 && len < 12 && s[7] == 'd'
      /* Generic check for /dev/sd[a-z] prefix */
      && strncmp (s, DISK_PREFIX, DP_LEN) == 0
      && s[DP_LEN] >= 'a' && s[DP_LEN] <= 'z')
    {
      /* /dev/sd* devices have 8192 entries, given that we support 128 disks
	 with up to 64 partitions.  Handling them with shilka raises the size
	 of devices.o from ~250K to ~2 Megs.  So we handle them here manually
	 to save this space. */
         …
    }
  else
    {
      const _device *dev = KR_find_keyword (s, len);
      if (!dev)
	*this = *fs_dev;
      else
	{
	  *this = *dev;
	  /* check and process device numbers */
          …
	}
    }
}
--8<---------------cut here---------------end--------------->8---


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Q+, Q and microQ:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds



More information about the Cygwin-patches mailing list