avsm changed the topic of #mirage to: mirage 2 released! party on!
caw has quit [Ping timeout: 260 seconds]
caw has joined #mirage
rgrinberg has quit [Quit: WeeChat 1.5]
rgrinberg has joined #mirage
syntiux has quit [Ping timeout: 250 seconds]
syntiux has joined #mirage
syntiux has quit [Ping timeout: 250 seconds]
syntiux has joined #mirage
syntiux has quit [Ping timeout: 240 seconds]
syntiux has joined #mirage
syntiux has quit [Ping timeout: 264 seconds]
syntiux has joined #mirage
syntiux has quit [Ping timeout: 260 seconds]
syntiux has joined #mirage
rgrinberg has quit [Ping timeout: 258 seconds]
rgrinberg has joined #mirage
agarwal1975 has quit [Ping timeout: 276 seconds]
rgrinberg has quit [Ping timeout: 250 seconds]
agarwal1975 has joined #mirage
copy` has quit [Quit: Connection closed for inactivity]
syntiux has quit [Ping timeout: 260 seconds]
syntiux has joined #mirage
jermar has joined #mirage
jermar has quit [Ping timeout: 244 seconds]
srenatus[m] has quit [Remote host closed the connection]
jermar has joined #mirage
srenatus[m] has joined #mirage
haesbaert has joined #mirage
jermar has quit [Ping timeout: 265 seconds]
yomimono has joined #mirage
yomimono has quit [Ping timeout: 250 seconds]
<haesbaert> what's the recommended safe/nice way to compare int32 as unsigned ?
<haesbaert> I'm working with Cstruct uint32 which uses an int32, very often I need to compare things as unsigned.
<haesbaert> It's quite painfull to keep checking for underflow all the time
<haesbaert> I'm sure someone came across this
<hannes> haesbaert: is checking for equality sufficient?
<haesbaert> no
<haesbaert> I know equality is totally safe
<haesbaert> I need to do additions/subtractions and sometimes check if it's lower/higher than something
<hannes> I managed to avoid these comparisons so far... but several times I thought that a uint32 library should be written.. since OCaml doesn't seem to get it builtin soon
<haesbaert> I'm trying to avoid them and I think so far it's being ok, there is one case so far I can't avoid, but I'm sure I'll make a mistake somewhere
<haesbaert> +1 for a uint32 library
<hannes> there's https://github.com/andrenth/ocaml-stdint around, but it is slightly heavy afaics
<haesbaert> I saw that, problem is I can't directly interface that with cstruct
<haesbaert> which becomes a chore
hel-io has joined #mirage
<haesbaert> it might pay off at some point and I switch
copy` has joined #mirage
<hannes> yes.. well... i suspect a uint32/uint64 library which cstruct depends on would be great to have
<hannes> haesbaert: operations you'd need are add/sub/compare (and maybe succ/pred for convenience)!?
<haesbaert> yep
<haesbaert> I'd love a add_fail_if_overflow
<haesbaert> or something like that
<hannes> ah, you'll want to have an exception on overflow, rather than this silent wrap around OCaml does atm?
<haesbaert> the silen wrap around would be enough, but if we could have both, better
<hannes> I just discussed that piece yesterday, this silent wraparound is really really bad imho
<haesbaert> I'm ok with checking everytime, but I'm sure I'll make a mistake someday
<hannes> 'coz every caller has to check if they care
<haesbaert> yeah, I'd prefer to blow up, maybe make the default blow up and another add_dont_care
<hannes> ack (and (+) being the one throwing)
<haesbaert> that could be a mirage pioneer project imho
<hannes> that could be a hannes sunday afternoon project imho
<haesbaert> even better
<haesbaert> I can send you bier
<hannes> better than procrastinating on this opam signing
<haesbaert> if you do that I promise I'll use.
<hannes> I only fail at the first step, finding a name..
<haesbaert> usane
<haesbaert> uinsane
<haesbaert> as in, uint sane
<haesbaert> hannes-uint32 later to be renamed
<haesbaert> I bet 99% of the bugs now go unnoticed since people code on amd64
<haesbaert> where an int is enough to hold an int32
<hannes> https://gist.github.com/hannesm/ec2d47a8edca79094a53d7b6bfefa011 would be good? or do you want convenience such as add_i : t -> int -> t ?
<haesbaert> nah convenience can come later, if needed
<haesbaert> that's fine
<haesbaert> but you'll write the cstruct part too /
<haesbaert> ?
<hannes> I also usually only need to increment by one..
<hannes> oh, I'd first do the lib, then tests, then modify cstruct to use that (so the dependency is cstruct depends on uint)
hel-io has quit [Remote host closed the connection]
<haesbaert> ack
<haesbaert> bbl
rgrinberg has joined #mirage
jermar has joined #mirage
jermar has quit [Ping timeout: 244 seconds]
maker has quit [Ping timeout: 250 seconds]
maker has joined #mirage
<hannes> had to write some C stubs (tested on clang so far) to get the overflow information...
<hannes> since I expose (and use) type t = int32, there's no change needed for cstruct... you can just use those usane operations on something retrieved from Cstruct.BE.get_uint32!
dezzy_ is now known as dezzy
srenatus[m] has quit [Remote host closed the connection]
srenatus[m] has joined #mirage
<hannes> (now also with gcc<=5.01 support)
yomimono has joined #mirage