rtl/linux/ostypes.inc lazarus / 66-Unix ---------------------------------------------------------------------- Чебурашка · 2022-12-30 09:03 I rephrase the question: Since we already have S_IRWXU, S_IRWXG, S_IRWXO which are compositions of the basic bits, would it make sense adding the following constants (also other names, but with these values)? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     S_IRWU =  S_IRUSR or S_IWUSR;    S_IRWG =  S_IRGRP or S_IWGRP;    S_IRWUG_RO =  S_IRWU or S_IRWG or S_IROTH;      S_IRXO =  S_IROTH or S_IXOTH;    S_IRWXUG_RXO =  S_IRWXU or S_IRWXG or S_IRXO;  In most cases non exes are S_IRWUG_RO, and exes S_IRWXUG_RXO. ---------------------------------------------------------------------- Thaddy · 2022-12-30 09:25 No. ---------------------------------------------------------------------- MarkMLl · 2022-12-30 09:39 Quote from: tt on December 30, 2022, 10:03:56 amWould it make sense adding the following constants (also other names, but with these values)? Applicable to what part of the rather large Linux API? Tell us what you're proposing and why and you might get more than a single-word response out of Thaddy :-) MarkMLl ---------------------------------------------------------------------- Thaddy · 2022-12-30 09:43 Such proposal duplicates functionalty already present, so hence NO. ---------------------------------------------------------------------- Чебурашка · 2022-12-30 09:43 Quote from: MarkMLl on December 30, 2022, 10:39:06 amQuote from: tt on December 30, 2022, 10:03:56 amWould it make sense adding the following constants (also other names, but with these values)? Applicable to what part of the rather large Linux API? Tell us what you're proposing and why and you might get more than a single-word response out of Thaddy :-) MarkMLl I was thinking to the situations in which you create a file and you want to impose the permissions, in many cases is either 664 or 775. Since there are already the S_IRWXU, S_IRWXG, S_IRWXO, I was wondering if also this constants can be useful, otherwise one needs always creating a local composition. If so, one could do also for the S_IRWXU, S_IRWXG, S_IRWXO and not have them in the rtl. I rephrased the question becuase I forgot to mention the existence of S_IRWXU, S_IRWXG, S_IRWXO (sorry Thaddy) ---------------------------------------------------------------------- MarkMLl · 2022-12-30 09:51 Right, so it's applicable to filemodes. It's probably not applicable to put them in ostypes.inc, but it might be worth considering adding them to the Unix package (i.e. outside the lowest levels of the RTL) if they really are a POSIX thing. Even there, the simplicity of deriving the composite values and the fact that- strictly speaking- you'd need to account for the "sticky bit" and various setuid/setgid usage makes it of dubious advantage: industry standard usage is to add together the numeric constants as needed at the application level. MarkMLl ---------------------------------------------------------------------- Чебурашка · 2022-12-30 10:19 Quote from: MarkMLl on December 30, 2022, 10:51:21 amRight, so it's applicable to filemodes. It's probably not applicable to put them in ostypes.inc, but it might be worth considering adding them to the Unix package (i.e. outside the lowest levels of the RTL) if they really are a POSIX thing. Even there, the simplicity of deriving the composite values and the fact that- strictly speaking- you'd need to account for the "sticky bit" and various setuid/setgid usage makes it of dubious advantage: industry standard usage is to add together the numeric constants as needed at the application level. MarkMLl Okay. I understand the point. Then why S_IRWXU, S_IRWXG, S_IRWXO are in ostypes.inc? This is a local grepping: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i user_tt@debian:~$ grep -r ostypes.inc /usr/share/fpcsrc/3.2.0//usr/share/fpcsrc/3.2.0/rtl/aix/sysos.inc:{$I ostypes.inc}                        // c-types, unix base types, unix base structures/usr/share/fpcsrc/3.2.0/rtl/aix/unxfunc.inc:{ should probably be defined in ostypes.inc for all OSes }/usr/share/fpcsrc/3.2.0/rtl/aix/Makefile.fpc:  ostypes.inc osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/haiku/baseunix.pp:{$i ostypes.inc}/usr/share/fpcsrc/3.2.0/rtl/haiku/baseunix.pp:// MAP_ANON(YMOUS) is OS dependant but used in the RTL and in ostypes.inc/usr/share/fpcsrc/3.2.0/rtl/haiku/sysos.inc:{$I ostypes.inc}                        // c-types, unix base types, unix base structures/usr/share/fpcsrc/3.2.0/rtl/dragonfly/Makefile.fpc:  $(BSDINC)/ostypes.inc $(BSDINC)/osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/openbsd/ptypes.inc:    // set in ostypes.inc wordsinsigset   = 4;           // words in sigset_t/usr/share/fpcsrc/3.2.0/rtl/openbsd/Makefile.fpc:  $(BSDINC)/ostypes.inc $(BSDINC)/osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/inc/exeinfo.pp:{$i ostypes.inc}/usr/share/fpcsrc/3.2.0/rtl/android/Makefile.fpc:  $(LINUXINC)/ostypes.inc $(LINUXINC)/osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/netbsd/Makefile.fpc:  $(BSDINC)/ostypes.inc $(BSDINC)/osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/solaris/sysos.inc:{$I ostypes.inc}                      // c-types, unix base types, unix base structures/usr/share/fpcsrc/3.2.0/rtl/solaris/unxfunc.inc:{ should probably be defined in ostypes.inc for all OSes }/usr/share/fpcsrc/3.2.0/rtl/solaris/Makefile.fpc:  ostypes.inc osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/unix/baseunix.pp:{$i ostypes.inc}/usr/share/fpcsrc/3.2.0/rtl/unix/baseunix.pp:// MAP_ANON(YMOUS) is OS dependant but used in the RTL and in ostypes.inc/usr/share/fpcsrc/3.2.0/rtl/freebsd/Makefile.fpc:  $(BSDINC)/ostypes.inc $(BSDINC)/osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/linux/sysos.inc:{$I ostypes.inc}                      // c-types, unix base types, unix base structures/usr/share/fpcsrc/3.2.0/rtl/linux/Makefile.fpc:  ostypes.inc osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/beos/baseunix.pp:{$i ostypes.inc}/usr/share/fpcsrc/3.2.0/rtl/beos/baseunix.pp:// MAP_ANON(YMOUS) is OS dependant but used in the RTL and in ostypes.inc/usr/share/fpcsrc/3.2.0/rtl/beos/ossysc.inc:{$i ostypes.inc}/usr/share/fpcsrc/3.2.0/rtl/beos/sysos.inc:{$I ostypes.inc}                        // c-types, unix base types, unix base structures/usr/share/fpcsrc/3.2.0/rtl/darwin/Makefile.fpc:  $(BSDINC)/ostypes.inc $(BSDINC)/osmacro.inc $(UNIXINC)/gensigset.inc \/usr/share/fpcsrc/3.2.0/rtl/fpmake.pp:          AddInclude('ostypes.i nc',AllUnixOSes);/usr/share/fpcsrc/3.2.0/rtl/fpmake.pp:          AddIn clude('ostypes.inc');/usr/share/fpcsrc/3.2.0/rtl/bsd/sysos.inc:{$I ostypes.inc}                        // c-types, unix base types, unix base structuresuser_tt@debian:~$ grep -r S_IRWXU /usr/share/fpcsrc/3.2.0//usr/share/fpcsrc/3.2.0/rtl/linux/ostypes.inc:    S_IRWXU =  S_IRUSR or S_IWUSR or S_IXUSR;/usr/share/fpcsrc/3.2.0/rtl/netwlibc/libc.pp:     S_IRWXU = $01C0;/usr/share/fpcsrc/3.2.0/rtl/netwlibc/sysdir.inc:  Res := FpMkdir (pchar(s),S_IRWXU);/usr/share/fpcsrc/3.2.0/rtl/netware/nwserv.pp:   S_IRWXU = 0000700;/usr/share/fpcsrc/3.2.0/rtl/bsd/ostypes.inc:    S_IRWXU =  S_IRUSR or S_IWUSR or S_IXUSR;/usr/share/fpcsrc/3.2.0/pack ages/libmicrohttpd/examples/demo.pp:      FpMkdir(uc^.language, S_IRWX U);/usr/share/fpcsrc/3.2.0/packages/libmicrohttpd/examples/demo.pp:    FpMkdir(PAnsiChar(fn), S_IRWXU);/usr/share/fpcsrc/3.2.0/packages/lib microhttpd/examples/demo_https.pp:      FpMkdir(uc^.language, S_IRWXU) ;/usr/share/fpcsrc/3.2.0/packages/libmicrohttpd/examples/demo_https.pp :      FpMkdir(PAnsiChar(fn), S_IRWXU);/usr/share/fpcsrc/3.2.0/packages/libc/src/sstath.inc:  S_IRWXU = (__S_IREAD or __S_IWRITE) or __S_IEXEC;/usr/share/fpcsrc/3.2.0/packages/libc/src/sstath.inc:  S_IRWXG = S_IRWXU shr 3;/usr/share/fpcsrc/3.2.0/packages/libc/src/sstath.inc:  ACCESSPERMS = (S_IRWXU or S_IRWXG) or S_IRWXO;/usr/share/fpcsrc/3.2.0/packages/libc/src/sstath.inc:  ALLPERMS = ((((S_ISUID or S_ISGID) or S_ISVTX) or S_IRWXU) or S_IRWXG) or S_IRWXO; ---------------------------------------------------------------------- MarkMLl · 2022-12-30 10:39 Quote from: tt on December 30, 2022, 11:19:54 amThen why S_IRWXU, S_IRWXG, S_IRWXO are in ostypes.inc? This is a local grepping: Presumably because they're needed for the compiler or the system unit. MarkMLl ---------------------------------------------------------------------- Чебурашка · 2022-12-30 10:58 Quote from: MarkMLl on December 30, 2022, 11:39:43 amQuote from: tt on December 30, 2022, 11:19:54 amThen why S_IRWXU, S_IRWXG, S_IRWXO are in ostypes.inc? This is a local grepping: Presumably because they're needed for the compiler or the system unit. MarkMLl Ah ok, I thought compiler did not use rtl units. ---------------------------------------------------------------------- MarkMLl · 2022-12-30 11:20 Quote from: tt on December 30, 2022, 11:58:09 amAh ok, I thought compiler did not use rtl units. "It's complicated" :-) The best thing I can do is give an example from ten years ago where I was trying to reconcile two different attempts to get a MIPS target going: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i # Build a compiler which runs on the host but targets mipsel, note debug options which are needed later: cd /usr/local/src/fpc-trunkexport PP=make "OPT=-O- -g" -C compiler mipselmv compiler/ppcmipsel compiler/ppcXmipsel # Renaming the compiler prevents it from being deleted by make clean etc., consider extending that OPT setting with -dEXTDEBUG. export PP=/usr/local/src/fpc- trunk/fpc/compiler/ppcXmipselmake CPU_TARGET=mipsel OS_TARGET=linux rtlmake CPU_TARGET=mipsel OS_TARGET=linux compiler # Move the newly- generated compiler and the RTL units to the target system, which should now be able to do a full build. There's obviously better- and in particular officially-sanctioned- explanations, but that's what I can easily lay hands on right now and I think it illustrates the important points. There's obviously been "feature creep" over the years, but basically the non-package part of the RTL contains- /should/ /contain/- only the bits that the compiler and internal toolchain need. However in the case of unix (note lower-case name) that contains things like syscall numbers and the structure returned by the stat() syscall, and at that point it's reasonable to have some degree of naming for the file attribute bits but not necessarily all possible combinations. MarkMLl https://wiki.freepascal.org/Native_MIPS_Systems ---------------------------------------------------------------------- PascalDragon · 2022-12-30 15:27 Quote from: tt on December 30, 2022, 11:19:54 amThen why S_IRWXU, S_IRWXG, S_IRWXO are in ostypes.inc? This is a local grepping: The ostypes.inc contains declarations needed to implement the cross platform functionality inside the RTL and is included by various units because the declarations are the same. Quote from: tt on December 30, 2022, 11:58:09 amAh ok, I thought compiler did not use rtl units. Of course the compiler uses the RTL, it's an ordinary Object Pascal program after all.