I use no library and i open no socket. The OS is Linux AMD64, the target is the same. The FPC is of version 3.2.2 The C and Pascal code are here:
http://oscomp.hu/depot/msgtest.c (http://oscomp.hu/depot/msgtest.c)
http://oscomp.hu/depot/msgtest.pas (http://oscomp.hu/depot/msgtest.pas)
And i've read the manual; the C code works as intended. But in the Pascal code, only a longint of zero can be transmitted, all else will yield a result of -1 and ESysENOMSG in errno (fpgeterrno).
These functions are calling the libc functions, aren't they?
I was to follow FP guidelines, but i was deceived by Wikipedia (https://en.wikipedia.org/wiki/C_data_types#Main_types) 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 (http://www.tutorialspoint.com/cprogramming/c_data_types.htm).
The FreePascal manual says however, that clong is always 64-bit. (https://www.freepascal.org/docs-html/current/rtl/unixtype/clong.html) 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?
Well, that's your fault for relying on Wikipedia and on other random URLs. But using a random URL also give me this: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 (https://www.freepascal.org/docs-html/current/rtl/unixtype/clong.html).
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.You can tell me that a few more times, but it will not change what happened in the past.
rtl/dragonfly/sysnr.inc: syscall_nr_msgrcv = 227;
rtl/beos/ostypes.inc: ru_msgrcv : clong; { messages received }
rtl/linux/arm/sysnr.inc: syscall_nr_msgrcv = syscall_nr_base+302;
rtl/linux/sysnr-gen.inc: syscall_nr_msgrcv = 188;
rtl/linux/x86_64/sysnr.inc: syscall_nr_msgrcv = 70;
rtl/openbsd/sysnr.inc:(* 227 *) syscall_nr_msgrcv = 227;
rtl/netbsd/sysnr.inc: { syscall: "msgrcv" ret: "ssize_t" args: "int" "void " "size_t" "long" "int" }
rtl/netbsd/sysnr.inc: syscall_nr_msgrcv = syscall_nr_base + 227;
rtl/netbsd/sysnr.inc: { 227 is excluded msgrcv }
rtl/bsd/ostypes.inc: ru_msgrcv : clong; { messages received }
packages/pthreads/src/pthraix.inc: ru_msgrcv,
packages/rtl-extra/src/linux/ipccall.inc:function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:clong; msgflg:cint):cint;
packages/rtl-extra/src/linux/ipccall.inc: msgrcv:=ipccall(CALL_MSGRCV,msqid,msgsz,msgflg,@tmp,0);
packages/rtl-extra/src/linux/ipcsys.inc:function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:clong; msgflg:cint):cint;
packages/rtl-extra/src/linux/ipcsys.inc:msgrcv:=do_syscall(syscall_nr_MSGRCV,TSysParam(msqid),TSysParam(msgp),TSysParam(msgsz),TSysParam(msgtyp),TSysParam(msgflg));
packages/rtl-extra/src/unix/ipc.pp:Function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:clong; msgflg:cint): {$if defined(Darwin) or defined(aix) or defined(Solaris)}ssize_t;{$else}cint;{$endif} {$ifdef FPC_USE_LIBC} cdecl; external clib name 'msgrcv'; {$endif}
packages/rtl-extra/src/unix/ipccdecl.inc:Function cmsgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:cint; msgflg:cint):cint; cdecl; external;
packages/rtl-extra/src/unix/ipccdecl.inc:Function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:cint; msgflg:cint):cint;
packages/rtl-extra/src/unix/ipccdecl.inc: msgrcv:=cmsgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
packages/rtl-extra/src/bsd/ipcbsd.inc:Function msgrcv(msqid:cint; msgp: PMSGBuf; msgsz: size_t; msgtyp:clong; msgflg:cint):cint;
packages/rtl-extra/src/bsd/ipcbsd.inc: msgrcv:=(do_syscall(syscall_nr_msgrcv, msqid, TSysParam(msgp), msgsz, msgtyp, msgflg));
packages/rtl-extra/src/bsd/ipcbsd.inc: msgrcv:=(do_syscall(syscall_nr_msgsys,3, msqid, TSysParam(msgp), msgsz, msgtyp, msgflg));
packages/libc/src/bresourceh.inc: ru_msgrcv : longint;
packages/libc/src/smsgh.inc:function msgrcv(__msqid:longint; __msgp:pointer; __msgsz:size_t; __msgtyp:longint; __msgflg:longint):longint;cdecl;external clib name 'msgrcv';
packages/libc/src/smsgh.inc:function msgrcv(__msqid:longint; var __msgp; __msgsz:size_t; __msgtyp:longint; __msgflg:longint):longint;cdecl;external clib name 'msgrcv';
Where are the example programs? I've installed FPC and FPC source from the Debian packages they provided.
$ cd /usr/local/src_fpc/fpcbuild-3.2.2
$ find -iname '*msgtool*'
./fpcdocs/ipcex/msgtool.pp
Click on "Procedures and functions" at the top. Go to "msgrcv" which among other things says "For an example, see msgctl." which has an example.Did you check this certain example of msgctl (https://www.freepascal.org/docs-html/current/rtl/ipc/msgctl.html)? It says:
Look, I'm not going to apologise for the difficulty finding some of this stuff: I've been making myself unpopular with the core team for years by complaining about it.Chill out dude, i blame you for nothing.
But the fact is that the information /is/ in there, and a simple "is there a reliable example for..." or "I can't find..." would have saved you- and everybody else- a lot of grief.The fact is that the information what is there is actually as erroneous as some random sources can be and thus, not reliable. The random source you had chastised me for using contained one flaw, while in the official documentation i have already found two with the very same characteristics (erroneous bitwidth) as in the random source.