Difference between revisions of "Accessing macOS System Information"

From Free Pascal wiki
Jump to navigationJump to search
(The longest journey begins with the first step - this is the first step :-)
 
m (Categorised page)
Line 12: Line 12:
 
    
 
    
 
... more content to come ...
 
... more content to come ...
 +
 +
[[Category:Mac OS X]]

Revision as of 15:04, 22 June 2019

... under construction ...

Sysctl provides an interface that allows you to retrieve many kernel parameters in macOS (and Linux and the BSDs). This provides a wealth of information detailing system hardware which can be useful when debugging user issues or simply optimising your application (eg to take advantage of threads on multi-core CPU systems).

The '/usr/local/share/fpcsrc/rtl/darwin/sysctlh.inc' source file is a partial transalation of the macOS '/usr/include/sys/sysctl.h' file. For details of the sysctls available, start a Terminal and type 'man sysctl'.

The fpSysCtl() function allows you to retrieve system information. The data returned from the function comprises integers (integer and int64), strings (AnsiStrings) and C structures (records). The function is defined in 'sysctl.pp' as:

function FPsysctl (Name: pchar; namelen:cuint; oldp:pointer;oldlenp:psize_t; newp:pointer;newlen:size_t):cint; cdecl; external name 'sysctl';

... more content to come ...