<gildor>
rwmjones: just a typo... anyway if this feature is to be correct I will probably forward it to upstream GForge
<gildor>
corrected
<rwmjones>
agreed
<mrvn>
I think that has no effect though. The application passes an __off64_t in a register and libc just passes that register along as is. Doesn't cut of the upper 32bit.
<gildor>
rwmjones: feel free to submit the bug report against OCaml Forge Site admin project, or directly to fusionforge.org
<rwmjones>
mrvn, you're kidding? people are rushing around Red Hat right now trying to find every app that might ever have been compiled using those 3 calls
<rwmjones>
it's serious ... half of the 32 bits are garbage
<rwmjones>
half of the 64 bits I mean
<mrvn>
rwmjones: doesn't the user visible part use off_t?
<Dodek>
hey, ((+) 2) returns a function, but ((*) 2) doesn't - the compiler thinks it's a comment
<mrvn>
rwmjones: is that a read-hat only bug?
<mrvn>
-e
<Dodek>
what should i do?
<mrvn>
aeh, -a I mean
<mrvn>
Dodek: (* starts a commen, ( * )
<rwmjones>
mrvn, no, it's more subtle. If your 32 bit program called fallocate (fd, , , n) AND it was compiled with -D_FILE_OFFSET_BITS=64 (which everything is), then what is allocated is (rand () << 32) | n
<rwmjones>
we found this because of an obscure data-corrupter in qemu, which no one could understand until we disassembled the code
<Dodek>
oh. that's a bit nasty.
<Dodek>
it reminds me of c++ and its foo<bar<baz>> vs foo<bar<baz> > problem
<mrvn>
rwmjones: my unistd.h says to use 64bit. So unless the libc cuts of the upper 32bit later (which is easy to fix if it does) then the right things is done.
<flux>
dodek, for that reason it is considered a uniform syntax to write ( + ) etc
<flux>
mrvn, did you try the test case?
<Dodek>
flux: well, that justifies it a bit.
<rwmjones>
mrvn, no it affects all glibc users
<rwmjones>
all who use pread/pwrite/fallocate anyway, which is why this is probably less of an issue than it might have been
<mrvn>
p.c:25: warning: implicit declaration of function 'preadv'
<flux>
my libc/linux doesn't have preadv, so I can't try :)
rwmjones is now known as rwmjones-afk
<mrvn>
rwmjones-afk: If I change the test code to use pread() then I get:
<mrvn>
pread64(3, "", 1, 281474976706303) = 0
<rwmjones-afk>
preadv I think
<mrvn>
Must be a RedHat exetension to glibc. No such thing here and pread() is just fine.
c0m has quit [SendQ exceeded]
<mrvn>
Or recently added to glibc.
<mattiase>
preadv/pwritev are fairly new in glibc, but have existed in BSD for quite some time (about 10 years it seems)
<mrvn>
Addd in glibc 2.10 it seems.
<mattiase>
But then *BSD never had the off_t size problems of Linux, because they used 64 bits from the beginning
<mrvn>
Ok, updating libc6 to 2.10.1, fixing the testcase and then compiling with preadv shows the bug.
<mrvn>
Needs #define _USE_BSD
<mrvn>
Maybe we should create a libc7 and throw out all the legacy 32bit crap. LFS should really be default.
<mrvn>
Throw out Unix and only have Unix.Largefile too.
ski_ has quit ["Lost terminal"]
ski_ has joined #ocaml
rwmjones_lptp has joined #ocaml
ccasin has quit [Read error: 110 (Connection timed out)]
seanmcl has joined #ocaml
<mattiase>
mrvn: Yes, there is really no excuse at all to propagate mistakes in one syscall interface to another.
dmentre has quit ["Leaving."]
_andre has quit ["*puff*"]
julm has quit ["Lost terminal"]
julm has joined #ocaml
reid97 has joined #ocaml
ttamttam has quit ["Leaving."]
c0m has joined #ocaml
ulfdoz has joined #ocaml
sramsay has joined #ocaml
sramsay has left #ocaml []
_zack has quit ["Leaving."]
Yoric[DT] has joined #ocaml
albacker has joined #ocaml
Mr_Awesome_ has quit [Read error: 110 (Connection timed out)]
ulfdoz has quit [Read error: 110 (Connection timed out)]
ikaros has quit ["Leave the magic to Houdini"]
Submarine has joined #ocaml
ttamttam has joined #ocaml
ccasin has joined #ocaml
ygrek has joined #ocaml
tmaeda is now known as tmaedaZ
tmaedaZ is now known as tmaeda
tmaeda has quit [Remote closed the connection]
tmaeda has joined #ocaml
tmaeda is now known as tmaedaZ
slash_ has joined #ocaml
thieusoai has joined #ocaml
<thieusoai>
why does this one gives these errors ?
<thieusoai>
warnings rather
<thieusoai>
# let c=ref 1 in let uONE = 1 in match !c with |uONE -> Printf.printf "ONE" | _ -> ();;
<thieusoai>
Warning Y: unused variable uONE.
<thieusoai>
Warning U: this match case is unused.
<brendan>
you can't use variables in patterns like that. in that case, you're shadowing your outer uONE with whatever !c happens to be
<brendan>
you can do something like: with |x where x = uONE
<brendan>
or just |1
<thieusoai>
ic
<thieusoai>
I need to use the var uONE so |1 is not an option for me
<gildor>
thieusoai: you need to go back to if !c = uONE then Printf.printf "ONE"
<thieusoai>
yeh using if then else etc works fine
<gildor>
so everything is fine ;-)
<mrvn>
switch(x) { case uOne: ... case uTwo: ... } can be done with "where". Otherwise if it is just one case use if.
nb_ has joined #ocaml
<thieusoai>
mrvn: I don't see the switch/where/case being used much in Ocaml -- do you have a reference where I can learn how to use them ?
<flux>
thieusoai, the code in could be written in ocaml like: match xxx with | x where x = uOne -> .. | x where x = uTwo -> ..
<flux>
I suppose that's what mrvn wrote also
<mrvn>
flux: except it is "when" and not "where"
<flux>
argh :)
<thieusoai>
ah
<mrvn>
always get that wrong too.
<flux>
brendan confused me, succesfully ;-)
<thieusoai>
no wonder it keeps saying syntax error where
<mrvn>
yeah, xemacs also doesn't highlight "where" as keyword.
<brendan>
oops :)
nb_ is now known as nb
<mrvn>
I've used it a few times, but usualy with Foo (x,y) when x < z
nb has left #ocaml []
<thieusoai>
thanks ! looks much cleaner than if then else for 20+ cases
ygrek has quit [Remote closed the connection]
Submarine has quit ["Leaving"]
<mrvn>
Before I noticed "when" I really missed switch()
<thieusoai>
the match works fine with me so far until today when I cannot pattern match with variables like uONE above
Modius has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
Associat0r has joined #ocaml
<thieusoai>
how do I iter the list to find something then "break" when I find it ? for instance this code I wrote works fine but it iterates the entire list
<thieusoai>
let f l = let v=ref 0 in List.iter(function (a,b)->(if b = 100 then v:=a))l; !v in f [(7,1);(2,100);(3,4)];;
<mrvn>
thieusoai: option 1: raise an exception, option 2: write your own recursive function
<flux>
v := fst (List.find (function (a, b) when b = 100 -> true | _ -> false))
<flux>
plus the list argument
<mrvn>
flux: still iterates the whole list
<flux>
but I must notice that you seem to use a lot of mutable variables :)
<flux>
mrvn, I would very much expect find to stop iterating on first find!
<mrvn>
thieusoai: If you want to iter and pass along a result then fold instead.
<flux>
fold doesn't really stop the iteration though
<mrvn>
flux: doesn't it return a list of things it found? Or why the fst?
<flux>
mrvn, no, it returns the first
<flux>
mrvn, fst returns the first value of the pairs it's searching
<flux>
fst isn't List.head..
<mrvn>
ahh.
<mrvn>
let find_first f not_found list = let rec loop = function [] -> not_found | x::xs when f x -> x | _::xs -> loop xs in loop list