* some unix changes mainly on freeBSD and fix to MAXPATHLEN constant

+ added kld* syscalls for freeBSD (tested)
  + changed "directives" macro for freeBSD unit to "extdecl" for Lazarus
  + changed MAXPATHLEN from 255 (wrong on all unices known to fpc since 1993) to 1024 for non-linux and 4096 for linux as per source code (2.4+ for linux, 1993 BSD for BSDs, Solaris 10)

git-svn-id: trunk@4779 -
This commit is contained in:
Almindor 2006-10-03 20:35:07 +00:00
parent 5d469b6847
commit 57d5ce9713
3 changed files with 117 additions and 30 deletions

View File

@ -21,9 +21,9 @@ Unit FreeBSD;
{$inline on}
{$Macro On}
{$ifdef FPC_USE_LIBC}
{$define directives:=cdecl; external 'c';}
{$define extdecl:=cdecl; external 'c'}
{$else}
{$define directives:=inline;}
{$define extdecl:=inline}
{$endif}
{$ENDIF}
@ -37,16 +37,54 @@ const
Type
SF_HDTR = record
headers: PIOVec; //* pointer to an array of header struct iovec's */
hdr_cnt: cint; //* number of header iovec's */
trailers: PIOVec; //* pointer to an array of trailer struct iovec's */
trl_cnt: cint; //* number of trailer iovec's */
headers: PIOVec; {* pointer to an array of header struct iovec's *}
hdr_cnt: cint; {* number of header iovec's *}
trailers: PIOVec; {* pointer to an array of trailer struct iovec's *}
trl_cnt: cint; {* number of trailer iovec's *}
end;
TSF_HDTR = SF_HDTR;
TSF_HDTR = SF_HDTR;
PSF_HDTR = ^TSF_HDTR;
kld_file_stat = record
Version: cInt; {* set to sizeof(linker_file_stat) *}
Name: array[0..MAXPATHLEN-1] of Char;
Refs: cInt;
ID: cInt;
Address: pChar; {* load address *}
Size: size_t; {* size in bytes *}
end;
tkld_file_stat = kld_file_stat;
pkld_file_stat = ^kld_file_stat;
TKldFileStat = kld_file_stat;
PKldFileStat = ^kld_file_stat;
kld_sym_lookup = record
Version: cInt; {* sizeof(struct kld_sym_lookup) *}
SymName: pChar; {* Symbol name we are looking up *}
SymValue: culong;
SymSize: size_t;
end;
tkld_sym_lookup = kld_sym_lookup;
pkld_sym_lookup = ^kld_sym_lookup;
TKldSymLookup = kld_sym_lookup;
PKldSymLookup = ^kld_sym_lookup;
function sendfile(fd: cint; s: cint; Offset: TOff; nBytes: TSize;
HDTR: PSF_HDTR; sBytes: POff; Flags: cint): cint; directives
function sendfile(fd: cint; s: cint; Offset: TOff; nBytes: TSize;
HDTR: PSF_HDTR; sBytes: POff; Flags: cint): cint; extdecl;
function kldload(FileName: pChar): cInt; extdecl;
function kldunload(fileid: cInt): cInt; extdecl;
function kldfind(FileName: pChar): cInt; extdecl;
function kldnext(fileid: cInt): cInt; extdecl;
function kldstat(fileid: cInt; kld_file_stat: pKldFileStat): cInt; extdecl;
function kldfirstmod(fileid: cInt): cInt; extdecl;
function kldsym(fileid: cInt; command: cInt; data: PKldSymLookup): cInt; extdecl;
implementation
@ -54,11 +92,11 @@ Uses
{$ifndef FPC_USE_LIBC} SysCall; {$else} InitC; {$endif}
{$IFNDEF FPC_USE_LIBC}
function SendFile(fd: cint; s: cint; Offset: TOff; nBytes: TSize;
HDTR: PSF_HDTR; sBytes: POff; Flags: cint): cint;
begin
SendFile:=Do_Syscall(syscall_nr_sendfile, fd, s,
SendFile:=Do_Syscall(syscall_nr_sendfile, fd, s,
{$IFNDEF CPU64}
{$IFDEF LITTLE_ENDIAN} // little endian is lo - hi
Lo(Offset), Hi(Offset),
@ -70,6 +108,44 @@ begin
{$ENDIF}
nBytes, TSysParam(HDTR), TSysParam(sBytes), Flags);
end;
function kldload(FileName: pChar): cInt;
begin
kldload:=do_sysCall(syscall_nr_kldload, TSysParam(FileName));
end;
function kldunload(fileid: cInt): cInt;
begin
kldunload:=do_sysCall(syscall_nr_kldunload, TSysParam(fileid));
end;
function kldfind(FileName: pChar): cInt;
begin
kldfind:=do_sysCall(syscall_nr_kldfind, TSysParam(FileName));
end;
function kldnext(fileid: cInt): cInt;
begin
kldnext:=do_sysCall(syscall_nr_kldnext, TSysParam(fileid));
end;
function kldstat(fileid: cInt; kld_file_stat: pKldFileStat): cInt;
begin
kldstat:=do_sysCall(syscall_nr_kldstat, TSysParam(fileid),
TSysParam(kld_file_stat));
end;
function kldfirstmod(fileid: cInt): cInt;
begin
kldfirstmod:=do_sysCall(syscall_nr_kldfirstmod, TSysParam(fileid));
end;
function kldsym(fileid: cInt; command: cInt; data: PKldSymLookup): cInt;
begin
kldsym:=do_sysCall(syscall_nr_kldsym, TSysParam(fileid), TSysParam(command),
TSysParam(data));
end;
{$ENDIF}
end.

View File

@ -226,24 +226,24 @@ syscall_nr_getdirentries =196;
}
{More or less checked/in use FreeBSD syscalls}
syscall_nr_readv =120;
syscall_nr_writev =121;
syscall_nr_pread =173;
syscall_nr_pwrite =174;
syscall_nr_semsys =169;
syscall_nr_msgsys =170;
syscall_nr_shmsys =171;
syscall_nr_mkfifo =132;
syscall_nr___getcwd =326;
syscall_nr_settimeofday =122;
syscall_nr_getitimer = 86;
syscall_nr_setitimer = 83;
syscall_nr___syscall =198;
syscall_nr_setsid =147;
syscall_nr_getpgrp = 81;
syscall_nr_setuid = 23;
syscall_nr_setgid =181;
syscall_nr_getgroups = 79;
syscall_nr_readv = 120;
syscall_nr_writev = 121;
syscall_nr_pread = 173;
syscall_nr_pwrite = 174;
syscall_nr_semsys = 169;
syscall_nr_msgsys = 170;
syscall_nr_shmsys = 171;
syscall_nr_mkfifo = 132;
syscall_nr___getcwd = 326;
syscall_nr_settimeofday = 122;
syscall_nr_getitimer = 86;
syscall_nr_setitimer = 83;
syscall_nr___syscall = 198;
syscall_nr_setsid = 147;
syscall_nr_getpgrp = 81;
syscall_nr_setuid = 23;
syscall_nr_setgid = 181;
syscall_nr_getgroups = 79;
syscall_nr_sysarch = 165;
syscall_nr_accept = 30;
syscall_nr_access = 33;
@ -318,5 +318,12 @@ syscall_nr_getdirentries =196;
syscall_nr_uuidgen = 392; { 5.x+}
syscall_nr_kqueue = 362;
syscall_nr_kevent = 363;
syscall_nr_kldload = 304;
syscall_nr_kldunload = 305;
syscall_nr_kldfind = 306;
syscall_nr_kldnext = 307;
syscall_nr_kldstat = 308;
syscall_nr_kldfirstmod = 309;
syscall_nr_kldsym = 337;
syscall_nr_sendfile = 393;

View File

@ -32,7 +32,11 @@ const
PathSeparator = ':';
{ FileNameCaseSensitive is defined below! }
maxExitCode = 255;
MaxPathLen = 256;
{$ifdef LINUX}
MaxPathLen = 4096; // linux has always got to be BIGGER
{$else}
MaxPathLen = 1024; // BSDs since 1993, Solaris 10, Darwin
{$endif}
const
UnusedHandle = -1;