[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MirageOS-devel] unsigned integers


  • To: Hannes Mehnert <hannes@xxxxxxxxxxx>
  • From: Anil Madhavapeddy <anil@xxxxxxxxxx>
  • Date: Wed, 7 Sep 2016 14:50:39 +0100
  • Cc: "mirageos-devel@xxxxxxxxxxxxxxxxxxxx" <mirageos-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 07 Sep 2016 13:50:46 +0000
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=recoil.org; h=content-type :mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; q=dns; s= selector1; b=D9+O9wzD8SG/WOWVXLXv4EnUqOEjDNIaB4hQCYIwNRcyeFs/GIO M5hfyW2GUOn8GWVnsH+rIO0vDthBHxPd2+5/kgrlKVUD0kZM+zCjfYmYcouuXP53 7jfh1ttp0j+jVA4wZ17hc0KvIQKgkh2boc6FsQobnTIFUytmVk0BAH28=
  • List-id: Developer list for MirageOS <mirageos-devel.lists.xenproject.org>

On 7 Sep 2016, at 14:45, Hannes Mehnert <hannes@xxxxxxxxxxx> wrote:
> 
> hello,
> 
> for several projects (i.e. sequence numbers) I had the need to have
> fixed width unsigned integers.  Finally I managed to implement them (8,
> 16, 32, 64 bit), and would like to hear back from you what you think.
> The crucial bit for me is that arithmetic expression expose the carry
> bit explicitly (by being t -> t -> t * bool).
> 
> I don't have the plan to complete it with all possible arithmetics
> operations (div, pow, ..), since I don't have use cases for these.
> 
> The type t is on purpose a public alias to (int, int, int32, int64),
> thus you can use bit operations from these modules directly (and, xor,
> or).  This also means that you have interoperability with e.g. cstruct.
> 
> The documentation is up at
> https://hannesm.github.io/usane/doc/Usane.html , code at
> https://github.com/hannesm/usane
> 
> The implementation uses __builtin_add/sub/mul_overflow if available
> (since clang 3.4 / gcc 5.1).

The optimisation of the use of builtin functions would probably be drowned out 
by the extra 2 value allocations happening because a tuple is being returned.

Would it be crazy to pass in a bool ref that could be reused to check for 
overflow?

Alternatively, the existing allocation may be -flambda safe and optimisable 
away for common usage patterns, but I'm not sure this is the case without 
actually inspecting the output of some tests...

Anil
_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.