Forum > Unix

msgrcv only succeeds if msgsnd sends a buffer with only zeros.

<< < (3/5) > >>

MarkMLl:

--- Quote from: TCH on May 20, 2022, 09:18:36 am ---These functions are calling the libc functions, aren't they?

--- End quote ---

Not a safe assumption in the general case. Libc is called by some stuff but my understanding is that FPC tries to avoid it as much as possible; even when it does call it you can find that there are unexpected changes e.g. what libc would expect to be a zero-terminated string is now a Pascal-type string.

You /can/ go direct to the syscalls or low-level kernel libraries, but it's very easy to fall foul of e.g. alignment issues.

So the first thing to do is *always* test the example provided in a package first, then to read the documentation, then to look at the wiki, and finally to start writing your own code.

But I'm as bad as anybody at trying to bypass some of those steps :-)

MarkMLl

TCH:
I was to follow FP guidelines, but i was deceived by Wikipedia where it was told, that long is 32-bit. But that turned out to be erroneous, it is 64-bit on 64-bit OS-es.
The FreePascal manual says however, that clong is always 64-bit. Does that mean, that if FPC_USE_LIBC is set, then these functions will fail if the TMSGbuf derivate is defined with clong as mtype?

MarkMLl:

--- Quote from: TCH on May 20, 2022, 09:45:00 am ---I was to follow FP guidelines, but i was deceived by Wikipedia where it was told, that long is 32-bit. But that turned out to be erroneous, it is 64-bit on 64-bit OS-es.
The FreePascal manual says however, that clong is always 64-bit. Does that mean, that if FPC_USE_LIBC is set, then these functions will fail if the TMSGbuf derivate is defined with clong as mtype?

--- End quote ---

Well, that's your fault for relying on Wikipedia and on other random URLs. But using a random URL also give me this:

https://fpc-pascal.freepascal.narkive.com/3JsSIyvf/usage-of-fpc-use-libc

So the bottom line is that if you rebuilt FPC you might be able to use it... and the core developers would probably be interested in your experience.

But I say again:

* Test programs. If one of these doesn't work as expected raise a bug.

* Documentation. If this is incomplete discuss it here or on the MLs.

* FPC/Lazarus wiki (and I /don't/ mean Wikipedia here). If this is wrong fix it.

MarkMLl

TCH:

--- Quote from: MarkMLl on May 20, 2022, 09:52:45 am ---Well, that's your fault for relying on Wikipedia and on other random URLs. But using a random URL also give me this:
--- End quote ---
And if i would relying on the FPC documentation, then would it be my fault too, if i would have ended up the same position, but from a different angle?
The FPC manual is actually erroneously states, that clong is int64. I've just compiled the test program on a 32-bit Linux, with the mtype as int64. It produced the same error as before. If i change it back to longword, then it works perfectly. So, it needs to be 32-bit on 32-bit OS and 64-bit on 64-bit OS. With clong, it works on both. Therefore the bitwidth of clong also depends on the bitwidth of the underlying arch and thus the FPC manual is erroneous.

MarkMLl:

--- Quote from: TCH on May 20, 2022, 10:27:18 am ---The FPC manual is actually erroneously states, that clong is int64.

--- End quote ---

I agree, raise it as a bug.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---     52 {$ifdef cpu64}     53   clong                  = int64;              pclong                 = ^clong;     54   cslong                 = int64;              pcslong                = ^cslong;     55   culong                 = qword;              pculong                = ^culong;     56 {$else}     57   clong                  = longint;            pclong                 = ^clong;     58   cslong                 = longint;            pcslong                = ^cslong;     59   culong                 = cardinal;           pculong                = ^culong;     60 {$endif} 
Not to mince words, this isn't the first time I've seen this sort of thing.

But if you'd started off with the example program- and this is the third- sorry, FOURTH- time I've told you this- you wouldn't have been caught by that one or at least would have had a much better idea of where to look.

MarkMLl

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version