12.1 Type, Variable and Constant declarations

Types

PGlob and TGlob are 2 types used in the Glob (401) function:
 PGlob = ^TGlob;
 TGlob = record
   Name : PChar;
   Next : PGlob;
   end;
The following types are used in the signal-processing procedures.
 tfpreg = record
   significand: array[0..3] of word;
   exponent: word;
 end;
 
 pfpstate = ^tfpstate;
 tfpstate = record
   cw, sw, tag, ipoff, cssel, dataoff, datasel: cardinal;
   st: array[0..7] of tfpreg;
   status: cardinal;
 end;
 
 PSigContextRec = ^SigContextRec;
 SigContextRec = record
   gs, __gsh: word;
   fs, __fsh: word;
   es, __esh: word;
   ds, __dsh: word;
   edi: cardinal;
   esi: cardinal;
   ebp: cardinal;
   esp: cardinal;
   ebx: cardinal;
   edx: cardinal;
   ecx: cardinal;
   eax: cardinal;
   trapno: cardinal;
   err: cardinal;
   eip: cardinal;
   cs, __csh: word;
   eflags: cardinal;
   esp_at_signal: cardinal;
   ss, __ssh: word;
   fpstate: pfpstate;
   oldmask: cardinal;
   cr2: cardinal;
   end;
The above records contain information about the processor state and process state at the moment a signal is sent to your program.

The records below are used in catching signals.

 TSigAction = procedure(Sig: Longint; SigContext: SigContextRec);cdecl;
 SignalHandler   = Procedure ( Sig : Integer);cdecl;
 
 PSignalHandler  = SignalHandler;
 SignalRestorer  = Procedure;cdecl;
 PSignalrestorer = SignalRestorer;
 SigActionRec = packed record
   Handler  : record
     case byte of
       0: (Sh: SignalHandler);
       1: (Sa: TSigAction);
     end;
   Sa_Mask     : SigSet;
   Sa_Flags    : Longint;
   Sa_restorer : SignalRestorer; { Obsolete - Don't use }
 end;
   PSigActionRec = ^SigActionRec;
Stat is used to store information about a file. It is defined in the syscalls unit.
   stat = record
      dev    : word;
      pad1   : word;
      ino    : longint;
      mode   : word;
      nlink  : word;
      uid    : word;
      gid    : word;
      rdev   : word;
      pad2   : word;
      size   : longint;
      blksze : Longint;
      blocks : Longint;
      atime  : Longint;
      unused1 : longint;
      mtime   : Longint;
      unused2 : longint;
      ctime   : Longint;
      unused3 : longint;
      unused4 : longint;
      unused5 : longint;
      end;
  
Statfs is used to store information about a filesystem. It is defined in the syscalls unit.
    statfs = record
      fstype   : longint;
      bsize    : longint;
      blocks   : longint;
      bfree    : longint;
      bavail   : longint;
      files    : longint;
      ffree    : longint;
      fsid     : longint;
      namelen  : longint;
      spare    : array [0..6] of longint;
      end
Dir and PDir are used in the OpenDir (416) and ReadDir (419) functions.
   TDir =record
     fd     : integer;
     loc    : longint;
     size   : integer;
     buf    : pdirent;
     nextoff: longint;
     dd_max : integer;
     lock   : pointer;
   end;
   PDir =^TDir;
Dirent, PDirent are used in the ReadDir (419) function to return files in a directory.
  PDirent = ^Dirent;
  Dirent = Record
    ino,
    off    : longint;
    reclen : word;
    name   : string[255]
  end;
Termio and Termios are used with iotcl() calls for terminal handling.
 Const  NCCS = 19;
        NCC = 8;
 
 Type termio = record
 c_iflag,{ input mode flags }
 c_oflag,{ output mode flags }
 c_cflag,{ control mode flags }
 c_lflag : Word; { local mode flags }
 c_line : Word; { line discipline - careful, only High byte in use}
 c_cc : array [0..NCC-1] of char; { control characters }
 end;
 termios = record
   c_iflag,              { input mode flags }
   c_oflag,              { output mode flags }
   c_cflag,              { control mode flags }
   c_lflag : Cardinal; { local mode flags }
   c_line : char;          { line discipline }
   c_cc : array [0..NCCS-1] of char;      { control characters }
 end;
Utimbuf is used in the Utime (440) call to set access and modificaton time of a file.
 utimbuf = record
   actime,modtime : Longint;
   end;
For the Select (423) call, the following 4 types are needed:
 FDSet = Array [0..31] of longint;
 PFDSet = ^FDSet;
 TimeVal = Record
    sec,usec : Longint;
 end;
 PTimeVal = ^TimeVal;
The timespec record is needed in the NanoSleep (413) function:
 timespec = packed record
   tv_sec,tv_nsec:longint;
 end;

The Uname (439) function uses the utsname to return information about the current kernel :

 utsname =record
   sysname,nodename,release,
   version,machine,domainname : Array[0..64] of char;
 end;
Its elements are null-terminated C style strings, you cannot access them directly !

Variables

Linuxerror is the variable in which the procedures in the linux unit report errors.
 LinuxError : Longint;
StdErr Is a Text variable, corresponding to Standard Error or diagnostic output. It is connected to file descriptor 2. It can be freely used, and will be closed on exit.
 StdErr : Text;

Constants

Constants for setting/getting process priorities :
       Prio_Process = 0;
       Prio_PGrp    = 1;
       Prio_User    = 2;
For testing access rights:
       R_OK = 4;
       W_OK = 2;
       X_OK = 1;
       F_OK = 0;
For signal handling functions :
       SA_NOCLDSTOP = 1;
       SA_SHIRQ    = $04000000;
       SA_STACK    = $08000000;
       SA_RESTART   = $10000000;
       SA_INTERRUPT = $20000000;
       SA_NOMASK    = $40000000;
       SA_ONESHOT   = $80000000;
 
       SIG_BLOCK   = 0;
       SIG_UNBLOCK = 1;
       SIG_SETMASK = 2;
       SIG_DFL = 0 ;
       SIG_IGN = 1 ;
       SIG_ERR = -1;
 
       SIGHUP = 1;
       SIGINT = 2;
       SIGQUIT = 3;
       SIGILL = 4;
       SIGTRAP = 5;
       SIGABRT = 6;
       SIGIOT = 6;
       SIGBUS = 7;
       SIGFPE = 8;
       SIGKILL = 9;
       SIGUSR1 = 10;
       SIGSEGV = 11;
       SIGUSR2 = 12;
       SIGPIPE = 13;
       SIGALRM = 14;
       SIGTERM = 15;
       SIGSTKFLT = 16;
       SIGCHLD = 17;
       SIGCONT = 18;
       SIGSTOP = 19;
       SIGTSTP = 20;
       SIGTTIN = 21;
       SIGTTOU = 22;
       SIGURG = 23;
       SIGXCPU = 24;
       SIGXFSZ = 25;
       SIGVTALRM = 26;
       SIGPROF = 27;
       SIGWINCH = 28;
       SIGIO = 29;
       SIGPOLL = SIGIO;
       SIGPWR = 30;
       SIGUNUSED = 31;
For file control mechanism :
       F_GetFd  = 1;
       F_SetFd  = 2;
       F_GetFl  = 3;
       F_SetFl  = 4;
       F_GetLk  = 5;
       F_SetLk  = 6;
       F_SetLkW = 7;
       F_GetOwn = 8;
       F_SetOwn = 9;
For Terminal handling :
    TCGETS = $5401 ;
    TCSETS = $5402 ;
    TCSETSW = $5403 ;
    TCSETSF = $5404 ;
    TCGETA = $5405 ;
    TCSETA = $5406 ;
    TCSETAW = $5407 ;
    TCSETAF = $5408 ;
    TCSBRK = $5409 ;
    TCXONC = $540A ;
    TCFLSH = $540B ;
    TIOCEXCL = $540C ;
    TIOCNXCL = $540D ;
    TIOCSCTTY = $540E ;
    TIOCGPGRP = $540F ;
    TIOCSPGRP = $5410 ;
    TIOCOUTQ = $5411 ;
    TIOCSTI = $5412 ;
    TIOCGWINSZ = $5413 ;
    TIOCSWINSZ = $5414 ;
    TIOCMGET = $5415 ;
    TIOCMBIS = $5416 ;
    TIOCMBIC = $5417 ;
    TIOCMSET = $5418 ;
    TIOCGSOFTCAR = $5419 ;
    TIOCSSOFTCAR = $541A ;
    FIONREAD = $541B ;
    TIOCINQ = FIONREAD;
    TIOCLINUX = $541C ;
    TIOCCONS = $541D ;
    TIOCGSERIAL = $541E ;
    TIOCSSERIAL = $541F ;
    TIOCPKT = $5420 ;
    FIONBIO = $5421 ;
    TIOCNOTTY = $5422 ;
    TIOCSETD = $5423 ;
    TIOCGETD = $5424 ;
    TCSBRKP = $5425  ;
    TIOCTTYGSTRUCT = $5426  ;
    FIONCLEX = $5450  ;
    FIOCLEX = $5451 ;
    FIOASYNC = $5452 ;
    TIOCSERCONFIG = $5453 ;
    TIOCSERGWILD = $5454 ;
    TIOCSERSWILD = $5455 ;
    TIOCGLCKTRMIOS = $5456 ;
    TIOCSLCKTRMIOS = $5457 ;
    TIOCSERGSTRUCT = $5458  ;
    TIOCSERGETLSR   = $5459  ;
    TIOCSERGETMULTI = $545A  ;
                                                                            

                                                                            
    TIOCSERSETMULTI = $545B  ;
    TIOCMIWAIT = $545C ;
    TIOCGICOUNT = $545D ;
    TIOCPKT_DATA = 0;
    TIOCPKT_FLUSHREAD = 1;
    TIOCPKT_FLUSHWRITE = 2;
    TIOCPKT_STOP = 4;
    TIOCPKT_START = 8;
    TIOCPKT_NOSTOP = 16;
    TIOCPKT_DOSTOP = 32;
Other than that, all constants for setting the speed and control flags of a terminal line, as described in the termios (2) man page, are defined in the linux unit. It would take too much place to list them here. To check the mode field of a stat record, you ca use the following constants :
   { Constants to check stat.mode }
   STAT_IFMT   = $f000; {00170000}
   STAT_IFSOCK = $c000; {0140000}
   STAT_IFLNK  = $a000; {0120000}
   STAT_IFREG  = $8000; {0100000}
   STAT_IFBLK  = $6000; {0060000}
   STAT_IFDIR  = $4000; {0040000}
   STAT_IFCHR  = $2000; {0020000}
   STAT_IFIFO  = $1000; {0010000}
   STAT_ISUID  = $0800; {0004000}
   STAT_ISGID  = $0400; {0002000}
   STAT_ISVTX  = $0200; {0001000}
   { Constants to check permissions }
   STAT_IRWXO = $7;
   STAT_IROTH = $4;
   STAT_IWOTH = $2;
   STAT_IXOTH = $1;
   STAT_IRWXG = STAT_IRWXO shl 3;
   STAT_IRGRP = STAT_IROTH shl 3;
   STAT_IWGRP = STAT_IWOTH shl 3;
   STAT_IXGRP = STAT_IXOTH shl 3;
   STAT_IRWXU = STAT_IRWXO shl 6;
   STAT_IRUSR = STAT_IROTH shl 6;
   STAT_IWUSR = STAT_IWOTH shl 6;
   STAT_IXUSR = STAT_IXOTH shl 6;
You can test the type of a filesystem returned by a FSStat (386) call with the following constants:
   fs_old_ext2 = $ef51;
   fs_ext2     = $ef53;
   fs_ext      = $137d;
   fs_iso      = $9660;
   fs_minix    = $137f;
   fs_minix_30 = $138f;
   fs_minux_V2 = $2468;
   fs_msdos    = $4d44;
   fs_nfs      = $6969;
   fs_proc     = $9fa0;
   fs_xia      = $012FD16D;
the FLock (383) call uses the following mode constants :
   LOCK_SH = 1;
   LOCK_EX = 2;
   LOCK_UN = 8;
   LOCK_NB = 4;
The MMap (411) function uses the following constants to specify access to mapped memory:
   PROT_READ  = $1;   { page can be read }
   PROT_WRITE = $2;   { page can be written }
   PROT_EXEC  = $4;   { page can be executed }
   PROT_NONE  = $0;   { page can not be accessed }
and the following constants to specify the type of mapping.
   MAP_SHARED    = $1;  { Share changes }
   MAP_PRIVATE   = $2;  { Changes are private }
   MAP_TYPE      = $f;  { Mask for type of mapping }
   MAP_FIXED     = $10; { Interpret addr exactly }
   MAP_ANONYMOUS = $20; { don't use a file }