* first dragonfly patch (existing most). Mantis #27091

git-svn-id: trunk@29213 -
This commit is contained in:
marco 2014-12-07 20:27:02 +00:00
parent 0d717c7e0e
commit 2578514853
24 changed files with 179 additions and 38 deletions

View File

@ -300,7 +300,7 @@ OPTWPOCOLLECT=-OWdevirtcalls,optvmts -FW$(BASEDIR)/pp1.wpo
OPTWPOPERFORM=-Owdevirtcalls,optvmts -Fw$(BASEDIR)/pp1.wpo
# symbol liveness WPO requires nm, smart linking and no stripping (the latter
# is forced by the Makefile when necessary)
ifneq ($(findstring $(OS_TARGET),darwin linux freebsd solaris),)
ifneq ($(findstring $(OS_TARGET),darwin linux dragonfly freebsd solaris),)
ifdef LINKSMART
ifdef CREATESMART
OPTWPOCOLLECT+=-OWsymbolliveness -Xs-

View File

@ -1718,7 +1718,7 @@ implementation
{ "no executable stack" marker }
{ TODO: used by OpenBSD/NetBSD as well? }
if (target_info.system in (systems_linux + systems_android + systems_freebsd)) and
if (target_info.system in (systems_linux + systems_android + systems_freebsd + systems_dragonfly)) and
not(cs_executable_stack in current_settings.moduleswitches) then
begin
AsmWriteLn('.section .note.GNU-stack,"",%progbits');

View File

@ -23,7 +23,9 @@ unit cfileutl;
{$i fpcdefs.inc}
{$ifndef DragonFly}
{$define usedircache}
{$endif DragonFly}
interface

View File

@ -154,7 +154,7 @@ begin
current_asmdata.asmlists[al_procedures].concat(Tai_symbol.Createname_global(hp2.name^,AT_FUNCTION,0));
if (cs_create_pic in current_settings.moduleswitches) and
{ other targets need to be checked how it works }
(target_info.system in [system_i386_freebsd,system_x86_64_freebsd,system_x86_64_linux,system_i386_linux,system_x86_64_solaris,system_i386_solaris,system_i386_android]) then
(target_info.system in [system_i386_freebsd,system_x86_64_freebsd,system_x86_64_linux,system_i386_linux,system_x86_64_solaris,system_i386_solaris,system_i386_android,system_x86_64_dragonfly]) then
begin
{$ifdef x86}
sym:=current_asmdata.RefAsmSymbol(pd.mangledname);

View File

@ -1216,7 +1216,7 @@ implementation
shstrtabsect:=TElfObjSection.create_ext(data,'.shstrtab',SHT_STRTAB,0,1,0);
{ "no executable stack" marker }
{ TODO: used by OpenBSD/NetBSD as well? }
if (target_info.system in (systems_linux + systems_android + systems_freebsd)) and
if (target_info.system in (systems_linux + systems_android + systems_freebsd + systems_dragonfly)) and
not(cs_executable_stack in current_settings.moduleswitches) then
TElfObjSection.create_ext(data,'.note.GNU-stack',SHT_PROGBITS,0,1,0);
{ symbol for filename }
@ -1260,7 +1260,9 @@ implementation
if target_info.system in systems_openbsd then
header.e_ident[EI_OSABI]:=ELFOSABI_OPENBSD
else if target_info.system in systems_freebsd then
header.e_ident[EI_OSABI]:=ELFOSABI_FREEBSD;
header.e_ident[EI_OSABI]:=ELFOSABI_FREEBSD
else if target_info.system in systems_dragonfly then
header.e_ident[EI_OSABI]:=ELFOSABI_NONE;
header.e_type:=ET_REL;
header.e_machine:=ElfTarget.machine_code;
header.e_version:=1;
@ -2025,7 +2027,9 @@ implementation
if target_info.system in systems_openbsd then
header.e_ident[EI_OSABI]:=ELFOSABI_OPENBSD
else if target_info.system in systems_freebsd then
header.e_ident[EI_OSABI]:=ELFOSABI_FREEBSD;
header.e_ident[EI_OSABI]:=ELFOSABI_FREEBSD
else if target_info.system in systems_dragonfly then
header.e_ident[EI_OSABI]:=ELFOSABI_NONE;
if IsSharedLibrary then
header.e_type:=ET_DYN
else

View File

@ -2795,10 +2795,12 @@ implementation
s32real : savesize:=4;
s80real : savesize:=10;
sc80real:
if target_info.system in [system_i386_darwin,system_i386_iphonesim,system_x86_64_darwin,
if target_info.system in [system_i386_darwin,
system_i386_iphonesim,system_x86_64_darwin,
system_x86_64_linux,system_x86_64_freebsd,
system_x86_64_openbsd,system_x86_64_netbsd,
system_x86_64_solaris,system_x86_64_embedded] then
system_x86_64_solaris,system_x86_64_embedded,
system_x86_64_dragonfly] then
savesize:=16
else
savesize:=12;

View File

@ -164,7 +164,8 @@
system_mipseb_embedded, { 81 }
system_mipsel_embedded, { 82 }
system_i386_aros, { 83 }
system_x86_64_aros { 84 }
system_x86_64_aros, { 84 }
system_x86_64_dragonfly { 85 }
);
type

View File

@ -217,6 +217,7 @@ interface
systems_linux = [system_i386_linux,system_x86_64_linux,system_powerpc_linux,system_powerpc64_linux,
system_arm_linux,system_sparc_linux,system_alpha_linux,system_m68k_linux,
system_x86_6432_linux,system_mipseb_linux,system_mipsel_linux];
systems_dragonfly = [system_x86_64_dragonfly];
systems_freebsd = [system_i386_freebsd,
system_x86_64_freebsd];
systems_netbsd = [system_i386_netbsd,
@ -227,7 +228,7 @@ interface
system_m68k_openbsd,
system_x86_64_openbsd];
systems_bsd = systems_freebsd + systems_netbsd + systems_openbsd;
systems_bsd = systems_freebsd + systems_netbsd + systems_openbsd + systems_dragonfly;
systems_aix = [system_powerpc_aix,system_powerpc64_aix];
@ -770,6 +771,10 @@ begin
default_target(system_x86_64_linux);
{$define default_target_set}
{$endif}
{$ifdef dragonfly}
default_target(system_x86_64_dragonfly);
{$define default_target_set}
{$endif}
{$ifdef freebsd}
default_target(system_x86_64_freebsd);
{$define default_target_set}

View File

@ -188,6 +188,72 @@ unit i_bsd;
);
system_x86_64_dragonfly_info : tsysteminfo =
(
system : system_x86_64_dragonfly;
name : 'DragonFly for x86-64';
shortname : 'DragonFly';
flags : [tf_needs_symbol_size,tf_needs_dwarf_cfi,tf_library_needs_pic,tf_needs_symbol_type,
tf_files_case_sensitive,tf_smartlink_library,
tf_dwarf_only_local_labels,
{tf_pic_uses_got,}tf_smartlink_sections,tf_has_winlike_resources];
cpu : cpu_x86_64;
unit_env : 'BSDUNITS';
extradefines : 'UNIX;HASUNIX;BSD';
exeext : '';
defext : '.def';
scriptext : '.sh';
smartext : '.sl';
unitext : '.ppu';
unitlibext : '.ppl';
asmext : '.s';
objext : '.o';
resext : '.res';
resobjext : '.or';
sharedlibext : '.so';
staticlibext : '.a';
staticlibprefix : 'libp';
sharedlibprefix : 'lib';
sharedClibext : '.so';
staticClibext : '.a';
staticClibprefix : 'lib';
sharedClibprefix : 'lib';
importlibprefix : 'libimp';
importlibext : '.a';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_x86_64_elf64;
assemextern : as_gas;
link : ld_none;
linkextern : ld_bsd;
ar : ar_gnu_ar;
res : res_elf;
dbg : dbg_dwarf2; //dbg_stabs;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 8;
loopalign : 4;
jumpalign : 0;
constalignmin : 0;
constalignmax : 8;
varalignmin : 0;
varalignmax : 16;
localalignmin : 4;
localalignmax : 16;
recordalignmin : 0;
recordalignmax : 16;
maxCrecordalign : 16
);
first_parm_offset : 16;
stacksize : 256*1024;
stackalign : 16;
abi : abi_default;
);
system_i386_netbsd_info : tsysteminfo =
(
system : system_i386_NetBSD;
@ -969,6 +1035,9 @@ initialization
{$ifdef FreeBSD}
set_source_info(system_x86_64_FreeBSD_info);
{$endif}
{$ifdef DragonFly}
set_source_info(system_x86_64_DragonFly_info);
{$endif}
{$ifdef OpenBSD}
set_source_info(system_x86_64_OpenBSD_info);
{$endif}

View File

@ -918,6 +918,9 @@ end;
initialization
RegisterLinker(ld_bsd,TLinkerBSD);
{$ifdef x86_64}
RegisterImport(system_x86_64_dragonfly,timportlibbsd);
RegisterExport(system_x86_64_dragonfly,texportlibbsd);
RegisterTarget(system_x86_64_dragonfly_info);
RegisterImport(system_x86_64_freebsd,timportlibbsd);
RegisterExport(system_x86_64_freebsd,texportlibbsd);
RegisterTarget(system_x86_64_freebsd_info);

View File

@ -166,7 +166,8 @@ const
{ 81 } 'Embedded-mipseb',
{ 82 } 'Embedded-mipsel',
{ 83 } 'AROS-i386',
{ 84 } 'AROS-x86-64'
{ 84 } 'AROS-x86-64',
{ 85 } 'DragonFly-x86-64'
);
const

View File

@ -469,7 +469,8 @@ interface
asmcmd : '--64 -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_x86_64_linux,system_x86_64_freebsd,
system_x86_64_win64,system_x86_64_embedded,
system_x86_64_openbsd,system_x86_64_netbsd];
system_x86_64_openbsd,system_x86_64_netbsd,
system_x86_64_dragonfly];
flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
labelprefix : '.L';
comment : '# ';

View File

@ -674,7 +674,8 @@ implementation
asmbin : '';
asmcmd : '';
supported_targets : [system_x86_64_linux,system_x86_64_freebsd,
system_x86_64_openbsd,system_x86_64_netbsd];
system_x86_64_openbsd,system_x86_64_netbsd,
system_x86_64_dragonfly];
flags : [af_outputbinary,af_smartlink_sections,af_supports_dwarf];
labelprefix : '.L';
comment : '';

View File

@ -16,6 +16,7 @@ dirs_go32v1=go32v1
dirs_os2=os2
dirs_emx=emx
dirs_freebsd=freebsd
dirs_dragonfly=dragonfly
dirs_darwin=darwin
dirs_iphonesim=darwin
dirs_beos=beos

View File

@ -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 }

View File

@ -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}

View File

@ -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.

View File

@ -2,7 +2,7 @@
Const
GraphDir = 'inc/graph/';
SysUtilsDir = 'objpas/sysutils/';
Unixes = [darwin,freebsd,linux,netbsd,openbsd];
Unixes = [darwin,dragonfly,freebsd,linux,netbsd,openbsd];
Function CurrentOS : String;

View File

@ -109,7 +109,7 @@ uses
Executable Loaders
****************************************************************************}
{$if defined(freebsd) or defined(netbsd) or defined (openbsd) or defined(linux) or defined(sunos) or defined(android)}
{$if defined(freebsd) or defined(netbsd) or defined (openbsd) or defined(linux) or defined(sunos) or defined(android) or defined(dragonfly)}
{$ifdef cpu64}
{$define ELF64}
{$else}

View File

@ -141,6 +141,12 @@ const
{$elseif defined(aix)}
CODESET = 49;
LC_ALL = -1;
{$elseif defined(dragonfly)}
CODESET = 0;
LC_ALL = 0;
__LC_CTYPE = 0;
_NL_CTYPE_CLASS = (__LC_CTYPE shl 16);
_NL_CTYPE_CODESET_NAME = (_NL_CTYPE_CLASS)+14;
{$else not aix}
{$error lookup the value of CODESET in /usr/include/langinfo.h, and the value of LC_ALL in /usr/include/locale.h for your OS }
// and while doing it, check if iconv is in libc, and if the symbols are prefixed with iconv_ or libiconv_

View File

@ -27,7 +27,7 @@ const
{$endif}
{$endif}
{$if defined(linux) or defined(freebsd) or defined(openbsd)}
{$if defined(linux) or defined(freebsd) or defined(openbsd) or defined(dragonfly)}
{$define ELF} // ELF symbol versioning.
{$endif}

View File

@ -59,7 +59,7 @@ function geterrnolocation: pcint; cdecl;external clib name '__errno_location';
function geterrnolocation: pcint; cdecl;external clib name '__errno';
{$endif}
{$ifdef FreeBSD} // tested on x86
{$if defined(FreeBSD) or defined(DragonFly)} // tested on x86
function geterrnolocation: pcint; cdecl;external clib name '__error';
{$endif}

View File

@ -8,7 +8,7 @@
#####################################################################
# OS categories
BSDs = freebsd netbsd openbsd darwin
BSDs = freebsd netbsd openbsd darwin dragonfly
UNIXs = linux $(BSDs) solaris qnx haiku aix
LIMIT83fs = go32v2 os2 emx watcom msdos
OSNeedsComspecToRunBatch = go32v2 watcom
@ -917,6 +917,14 @@ HASSHAREDLIB=1
SHORTSUFFIX=lnx
endif
# DragonFly BSD
ifeq ($(OS_TARGET),dragonfly)
BATCHEXT=.sh
EXEEXT=
HASSHAREDLIB=1
SHORTSUFFIX=df
endif
# FreeBSD
ifeq ($(OS_TARGET),freebsd)
BATCHEXT=.sh
@ -1396,7 +1404,7 @@ override FPCOPT+=-Cg
endif
# create always pic'ed code on x86_64
ifneq ($(findstring $(OS_TARGET),freebsd openbsd netbsd linux solaris),)
ifneq ($(findstring $(OS_TARGET),dragonfly freebsd openbsd netbsd linux solaris),)
ifeq ($(CPU_TARGET),x86_64)
override FPCOPT+=-Cg
endif

View File

@ -75,7 +75,7 @@ interface
o_amiga,o_atari, o_solaris, o_qnx, o_netware, o_openbsd,o_wdosx,
o_palmos,o_macos,o_darwin,o_emx,o_watcom,o_morphos,o_netwlibc,
o_win64,o_wince,o_gba,o_nds,o_embedded,o_symbian,o_nativent,o_iphonesim,
o_wii,o_aix,o_java,o_android,o_msdos,o_aros
o_wii,o_aix,o_java,o_android,o_msdos,o_aros,o_dragonfly
);
TTargetSet=array[tcpu,tos] of boolean;
@ -98,7 +98,8 @@ interface
'amiga','atari','solaris', 'qnx', 'netware','openbsd','wdosx',
'palmos','macos','darwin','emx','watcom','morphos','netwlibc',
'win64','wince','gba','nds','embedded','symbian','nativent',
'iphonesim', 'wii', 'aix', 'java', 'android', 'msdos', 'aros'
'iphonesim', 'wii', 'aix', 'java', 'android', 'msdos', 'aros',
'dragonfly'
);
OSSuffix : array[TOS] of string=(
@ -106,7 +107,8 @@ interface
'_amiga','_atari','_solaris', '_qnx', '_netware','_openbsd','_wdosx',
'_palmos','_macos','_darwin','_emx','_watcom','_morphos','_netwlibc',
'_win64','_wince','_gba','_nds','_embedded','_symbian','_nativent',
'_iphonesim','_wii','_aix','_java','_android','_msdos','_aros'
'_iphonesim','_wii','_aix','_java','_android','_msdos','_aros',
'_dragonfly'
);
{ This table is kept OS,Cpu because it is easier to maintain (PFV) }
@ -147,7 +149,8 @@ interface
{ java } ( false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false),
{ android } ( true, false, false, false, false, true, false, false, false, false, false, true, false, false, true, false),
{ msdos } ( false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true),
{ aros } ( true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false)
{ aros } ( true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false),
{dragonfly} ( false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false)
);
type