Skip to content

Proposal to improve sysconf() #87

@xdelatour

Description

@xdelatour

I propose a modification to the sysconf() function in the mintlib library (the kernel is not modified).

The problem with system information is that it is returned:

  • either by the sysconf system call (kernel)
  • or by the sysconf function (mintlib), which can return it itself or obtain it from the system call
  • or by sysctl (kernel)

The goal is to limit ourselves to a systcl backend (since we don't have a complete /proc/sys) in the kernel and to the sysconf function only in the library (sysconf in the kernel is redundant).

Thus,

  • the confname.h file (included by unistd.h) contains all possible values ​​for sysconf. It is no longer necessary to duplicate them in the kernel (dos.c)

  • The sysconf function returns the information, or retrieves it from sysctl

    • With the exception of _SC_AVPHYS_PAGES, which requires the sysconf system call because sysctl does not provide this value, sysconf can be completely bypassed and deprecated (but should be kept for existing binaries that call it)
    • sysctl can be extended to return the total RAM using totalphysmem(), which will allow obtaining the total number of pages and completely eliminating the need for the sysconf system call
  • Maintaining sysconf() only in the mintlib becomes simpler, for when new features are added

  • Whether under TOS or MiNT, sysconf can return relevant values ​​(_SC_V8_ILP32_OFF32, which indicates that the system is 32-bit, for example)

  • Modern free software can benefit from the availability of information relating to existing features or not on the system (for example, _SC_IPV6)

  • Conversely, care must be taken regarding the consequences of automatically enabling or disabling directives via headers in the C library based on the returned results (for example, I made _SC_FSYNC return 0 because the function doesn't do what it's expected to do; we could instead make it return 1 because it exists even if it synchronizes the entire filesystem containing the file in question, perhaps some softwares relies on this information).

  • sysconf.c.patch.txt

  • confname.h.patch.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions