summaryrefslogtreecommitdiff
path: root/rtl/bsd
diff options
context:
space:
mode:
Diffstat (limited to 'rtl/bsd')
-rw-r--r--rtl/bsd/ossysc.inc33
-rw-r--r--rtl/bsd/ostypes.inc60
-rw-r--r--rtl/bsd/sysctl.pp2
-rw-r--r--rtl/bsd/sysos.inc2
-rw-r--r--rtl/bsd/system.pp12
5 files changed, 83 insertions, 26 deletions
diff --git a/rtl/bsd/ossysc.inc b/rtl/bsd/ossysc.inc
index 267bff29e1..d1be689bbb 100644
--- a/rtl/bsd/ossysc.inc
+++ b/rtl/bsd/ossysc.inc
@@ -212,6 +212,10 @@ begin
dispose(dirp);
end;
+var
+ use_openbsd_getdirentries_49 : boolean = false;
+ use_getdirentries_syscall : boolean = true;
+
function Fpreaddir(dirp : pdir) : pdirent; [public, alias : 'FPC_SYSC_READDIR'];
{Different from Linux, Readdir on BSD is based on Getdents, due to the
@@ -223,18 +227,29 @@ with blockmode have this higher?}
function readbuffer:longint;
var retval :longint;
-{$ifdef USE_GETDIRENTRIES_I49_SYSCALL}
+{$ifdef FPC_USE_GETDIRENTRIES_SYSCALL}
+ basepp : pointer;
+{$ifdef FPC_USE_GETDIRENTRIES_I49_SYSCALL}
{ OpenBSD i49 getDirEntries system call uses off_t type for last parameter }
- basep : off_t;
-{$else not USE_GETDIRENTRIES_I49_SYSCALL}
+ basep_off_t : off_t;
+{$endif not FPC_USE_GETDIRENTRIES_I49_SYSCALL}
basep : clong;
-{$endif not USE_GETDIRENTRIES_I49_SYSCALL}
-begin
-{$ifdef USE_GETDIRENTRIES_SYSCALL}
- Retval:=do_syscall(syscall_nr_getdirentries,TSysParam(dirp^.dd_fd),TSysParam(@dirp^.dd_buf^),DIRBLKSIZ {sizeof(getdentsbuffer)},TSysParam(@basep));
-{$else not USE_GETDIRENTRIES_SYSCALL}
+{$endif FPC_USE_GETDIRENTRIES_SYSCALL}
+begin
+{$ifdef FPC_USE_GETDIRENTRIES_SYSCALL}
+{$ifdef FPC_USE_GETDIRENTRIES_I49_SYSCALL}
+ if use_openbsd_getdirentries_49 then
+ basepp:=@basep_off_t
+ else
+{$endif FPC_USE_GETDIRENTRIES_I49_SYSCALL}
+ basepp:=@basep;
+ if use_getdirentries_syscall then
+ Retval:=do_syscall(syscall_nr_getdirentries,TSysParam(dirp^.dd_fd),TSysParam(@dirp^.dd_buf^),DIRBLKSIZ {sizeof(getdentsbuffer)},TSysParam(basepp))
+ else
+ Retval:=do_syscall(syscall_nr_getdents,TSysParam(dirp^.dd_fd),TSysParam(@dirp^.dd_buf^),DIRBLKSIZ {sizeof(getdentsbuffer)});
+{$else not FPC_USE_GETDIRENTRIES_SYSCALL}
Retval:=do_syscall(syscall_nr_getdents,TSysParam(dirp^.dd_fd),TSysParam(@dirp^.dd_buf^),DIRBLKSIZ {sizeof(getdentsbuffer)});
-{$endif not USE_GETDIRENTRIES_SYSCALL}
+{$endif not FPC_USE_GETDIRENTRIES_SYSCALL}
dirp^.dd_rewind:=TSysParam(dirp^.dd_buf);
if retval=0 then
begin
diff --git a/rtl/bsd/ostypes.inc b/rtl/bsd/ostypes.inc
index 97d8923cb1..ab7395e77a 100644
--- a/rtl/bsd/ostypes.inc
+++ b/rtl/bsd/ostypes.inc
@@ -63,6 +63,30 @@ TYPE
{ file characteristics services }
stat = record { the types are real}
+{$ifdef dragonfly}
+ st_ino : ino_t; // inode's number
+ st_nlink : nlink_t; // number of hard links
+ st_dev : dev_t; // inode's device
+ st_mode : mode_t; // inode protection mode
+ st_padd1 : cuint16;
+ st_uid : uid_t; // user ID of the file's owner
+ st_gid : gid_t; // group ID of the file's group
+ st_rdev : dev_t; // device type
+ st_atime : time_t; // time of last access (half timespec)
+ st_atimensec : clong; // nsec of last access (half timespec)
+ st_mtime : time_t; // time of last data modification
+ st_mtimensec : clong; // nsec of last data modification
+ st_ctime : time_t; // time of last file status change
+ st_ctimensec : clong; // nsec of last file status change
+ st_size : off_t; // file size, in bytes
+ st_blocks : cint64; // blocks allocated for file
+ st_blksize : cuint32; // optimal blocksize for I/O
+ st_flags : cuint32; // user defined flags for file
+ st_gen : cuint32; // file generation number
+ st_lspare : cint32;
+ st_qspare1 : cint64; // was recursive change detect
+ st_qspare2 : cint64;
+{$else dragonfly}
st_dev : dev_t; // inode's device
{$ifdef darwinarm}
st_mode : mode_t; // inode protection mode
@@ -114,6 +138,7 @@ TYPE
st_birthtimensec : clong; // nsec of file creation time
{$endif}
st_qspare : array[0..1] Of cint64;
+{$endif dragonfly}
end;
TStat = stat;
pStat = ^stat;
@@ -221,7 +246,7 @@ CONST
O_APPEND = 8; { Writes append to the file. }
O_NONBLOCK = 4; { Non-blocking I/O. }
-{$ifdef freebsd}
+{$if defined(freebsd) or defined(dragonfly)}
{ Other }
O_SHLOCK = $10; { Open with shared file lock }
O_EXLOCK = $20; { Open with exclusive file lock }
@@ -269,6 +294,13 @@ CONST
F_SetLkW = 13; { F_SETLK; wait if blocked }
F_SetLkRemote = 14; { debugging support for remote locks }
{$endif}
+{$ifdef dragonfly}
+ F_GetLk = 7; { get record locking information}
+ F_SetLk = 8; { set record locking information }
+ F_SetLkW = 9; { F_SETLK; wait if blocked }
+ F_Dup2Fd = 10; { duplicate file descriptor to arg }
+ F_DupFd_CloExec = 17; { close on exec duplicated fd }
+{$endif}
{$ifdef netbsd}
F_GetLk = 7; { get record locking information}
F_SetLk = 8; { set record locking information }
@@ -358,19 +390,18 @@ type
// #define ru_last ru_nivcsw
// #define ru_first ru_ixrss
-{ auto generated by a c prog, statmacr.c}
Const
- S_IFMT = 61440;
- S_IFIFO = 4096;
- S_IFCHR = 8192;
- S_IFDIR = 16384;
- S_IFBLK = 24576;
- S_IFREG = 32768;
- S_IFLNK = 40960;
- S_IFSOCK= 49152;
- S_IFWHT = 57344;
- S_ISVTX = 512;
+ S_IFMT = &170000;
+ S_IFIFO = &10000;
+ S_IFCHR = &20000;
+ S_IFDIR = &40000;
+ S_IFBLK = &60000;
+ S_IFREG = &100000;
+ S_IFLNK = &120000;
+ S_IFSOCK= &140000;
+ S_IFWHT = &160000;
+ S_ISVTX = &1000;
{
* Resource limits from FreeBSD5. To be checked for the others.
@@ -384,7 +415,7 @@ Const
RLIMIT_MEMLOCK = 6; { locked-in-memory address space }
RLIMIT_NPROC = 7; { number of processes }
RLIMIT_NOFILE = 8; { number of open files }
-{$IFDEF FreeBSD}
+{$if defined(freebsd) or defined(dragonfly)}
RLIMIT_SBSIZE = 9; { maximum size of all socket buffers }
RLIMIT_VMEM =10; { virtual process size (inclusive of mmap) }
RLIMIT_AS = RLIMIT_VMEM;
@@ -395,6 +426,9 @@ Const
{$ifdef FreeBSD}
RLIM_NLIMITS =11; { number of resource limits }
{$endif}
+ {$ifdef dragonfly}
+ RLIM_NLIMITS =12; { number of resource limits }
+ {$endif}
{$ifdef Darwin} // OS X 10.3
RLIM_NLIMITS =9; { number of resource limits }
diff --git a/rtl/bsd/sysctl.pp b/rtl/bsd/sysctl.pp
index 8a63b4234f..6eeddd327b 100644
--- a/rtl/bsd/sysctl.pp
+++ b/rtl/bsd/sysctl.pp
@@ -97,7 +97,7 @@ Uses Syscall;
{$ENDIF}
{$ifndef FPC_USE_LIBC}
-{$ifdef FreeBSD}
+{$if defined(FreeBSD) or defined(DragonFly)}
CONST syscall_nr___sysctl = 202;
{$endif}
diff --git a/rtl/bsd/sysos.inc b/rtl/bsd/sysos.inc
index c06f36e98f..cd0be3b717 100644
--- a/rtl/bsd/sysos.inc
+++ b/rtl/bsd/sysos.inc
@@ -22,7 +22,7 @@ const clib = 'c';
type libcint=longint;
plibcint=^libcint;
-{$ifdef FreeBSD} // tested on x86
+{$if defined(FreeBSD) or defined(DragonFly)} // tested on x86
function geterrnolocation: Plibcint; cdecl;external clib name '__error';
{$else}
{$ifdef NetBSD} // from a sparc dump.
diff --git a/rtl/bsd/system.pp b/rtl/bsd/system.pp
index 634b2fbfe4..316840f57a 100644
--- a/rtl/bsd/system.pp
+++ b/rtl/bsd/system.pp
@@ -79,6 +79,10 @@ Implementation
{$I system.inc}
+{$ifdef FPC_HAS_SETSYSNR_INC}
+{$I setsysnr.inc}
+{$endif FPC_HAS_SETSYSNR_INC}
+
{*****************************************************************************
Misc. System Dependent Functions
*****************************************************************************}
@@ -301,7 +305,7 @@ begin
argv:= argvparam;
envp:= envpparam;
{$ifdef cpui386}
- Set8087CW(Default8087CW);
+ Set8087CW(Default8087CW);
{$endif cpui386}
pascalmain; {run the pascal main program}
end;
@@ -327,6 +331,11 @@ Begin
IsConsole := TRUE;
StackLength := CheckInitialStkLen(InitialStkLen);
StackBottom := Sptr - StackLength;
+{$ifdef FPC_HAS_SETSYSNR_INC}
+ { This procedure is needed for openbsd system which re-uses
+ the same syscall numbers depending on OS version }
+ SetSyscallNumbers;
+{$endif FPC_HAS_SETSYSNR_INC}
{ Set up signals handlers (may be needed by init code to test cpu features) }
InstallSignals;
@@ -345,7 +354,6 @@ Begin
SetupCmdLine;
{ threading }
InitSystemThreads;
- initvariantmanager;
{ restore original signal handlers in case this is a library }
if IsLibrary then
RestoreOldSignalHandlers;