Browse Source

* 14 april version killed, and replaced by newer fixes branch version

marco 25 năm trước cách đây
mục cha
commit
057ac2adec
11 tập tin đã thay đổi với 3376 bổ sung0 xóa
  1. 1202 0
      rtl/bsd/Makefile
  2. 181 0
      rtl/bsd/Makefile.fpc
  3. 224 0
      rtl/bsd/bsdport.txt
  4. 176 0
      rtl/bsd/bsdsock.inc
  5. 141 0
      rtl/bsd/i386/cprt0.as
  6. 124 0
      rtl/bsd/i386/prt0.as
  7. 167 0
      rtl/bsd/signal.inc
  8. 511 0
      rtl/bsd/syscalls.inc
  9. 119 0
      rtl/bsd/sysconst.inc
  10. 345 0
      rtl/bsd/sysnr.inc
  11. 186 0
      rtl/bsd/systypes.inc

+ 1202 - 0
rtl/bsd/Makefile

@@ -0,0 +1,1202 @@
+#
+# Makefile generated by fpcmake v0.99.13 [2000/01/17]
+#
+
+defaultrule: all
+
+#####################################################################
+# Autodetect OS (Linux or Dos or Windows NT)
+# define inlinux when running under linux
+# define inWinNT when running under WinNT
+#####################################################################
+
+# We need only / in the path
+override PATH:=$(subst \,/,$(PATH))
+
+# Search for PWD and determine also if we are under linux
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
+ifeq ($(PWD),)
+nopwd:
+	@echo You need the GNU utils package to use this Makefile!
+	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
+	@exit
+else
+inlinux=1
+endif
+else
+PWD:=$(firstword $(PWD))
+endif
+
+# Detect NT - NT sets OS to Windows_NT
+ifndef inlinux
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+endif
+endif
+
+# Detect OS/2 - OS/2 has OS2_SHELL defined
+ifndef inlinux
+ifndef inWinNT
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+endif
+
+# The extension of executables
+ifdef inlinux
+EXEEXT=
+else
+EXEEXT=.exe
+endif
+
+# The path which is searched separated by spaces
+ifdef inlinux
+SEARCHPATH=$(subst :, ,$(PATH))
+else
+SEARCHPATH=$(subst ;, ,$(PATH))
+endif
+
+# Base dir
+ifdef PWD
+BASEDIR:=$(shell $(PWD))
+else
+BASEDIR=.
+endif
+
+#####################################################################
+# Default target
+#####################################################################
+
+override OS_TARGET:=linux
+override CPU_TARGET:=i386
+
+#####################################################################
+# FPC version/target Detection
+#####################################################################
+
+# What compiler to use ?
+ifndef FPC
+# Compatibility with old makefiles
+ifdef PP
+FPC=$(PP)
+else
+ifdef inOS2
+FPC=ppos2$(EXEEXT)
+else
+FPC=ppc386$(EXEEXT)
+endif
+endif
+endif
+
+# Target OS
+ifndef OS_TARGET
+OS_TARGET:=$(shell $(FPC) -iTO)
+endif
+
+# Source OS
+ifndef OS_SOURCE
+OS_SOURCE:=$(shell $(FPC) -iSO)
+endif
+
+# Target CPU
+ifndef CPU_TARGET
+CPU_TARGET:=$(shell $(FPC) -iTP)
+endif
+
+# Source CPU
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(shell $(FPC) -iSP)
+endif
+
+# FPC version
+ifndef FPC_VERSION
+FPC_VERSION:=$(shell $(FPC) -iV)
+endif
+
+export FPC OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FPC_VERSION
+
+#####################################################################
+# Pre Settings
+#####################################################################
+
+RTL=..
+INC=$(RTL)/inc
+PROCINC=$(RTL)/$(CPU_TARGET)
+
+UNITPREFIX=rtl
+
+# Paths
+OBJPASDIR=$(RTL)/objpas
+GRAPHDIR=$(INC)/graph
+
+# Define Go32v2 Units
+SYSTEMUNIT=syslinux
+
+# Use new graph unit ?
+# NEWGRAPH=YES
+# Use LibGGI ?
+# Use
+#
+ifndef USELIBGGI
+USELIBGGI=NO
+endif
+#####################################################################
+# FPCDIR Setting
+#####################################################################
+
+# Test FPCDIR to look if the RTL dir exists
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(FPCDIR)/rtl),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+
+# Default FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR=.
+ifeq ($(wildcard $(FPCDIR)/rtl),)
+override FPCDIR=wrong
+endif
+endif
+
+# Detect FPCDIR
+ifeq ($(FPCDIR),wrong)
+ifdef inlinux
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+else
+override FPCDIR:=$(subst /$(FPC)$(EXEEXT),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC)$(EXEEXT),$(SEARCHPATH))))))
+endif
+endif
+
+#####################################################################
+# User Settings
+#####################################################################
+
+
+# Targets
+
+override LOADEROBJECTS+=prt0 cprt0
+override UNITOBJECTS+=$(SYSTEMUNIT) objpas strings linux initc dos crt objects printer sysutils typinfo math cpu mmx getopts heaptrc lineinfo errors sockets gpm ipc
+override RSTOBJECTS+=math
+
+# Clean
+
+
+# Install
+
+UNITSUBDIR=rtl
+ZIPTARGET=install
+
+# Defaults
+
+
+# Directories
+
+override NEEDINCDIR=$(INC) $(PROCINC)
+ifndef TARGETDIR
+TARGETDIR=.
+endif
+
+# Packages
+
+
+# Libraries
+
+LIBNAME=libfprtl.so
+SHAREDLIBOBJECTUNITS=$(SYSTEMUNIT) objpas strings linux  dos crt objects printer sysutils typinfo math cpu mmx getopts heaptrc errors sockets ipc
+
+# Info
+
+INFOTARGET=fpc_infocfg fpc_infoobjects fpc_infoinstall 
+
+#####################################################################
+# Post Settings
+#####################################################################
+
+SYSTEMPPU=$(addsuffix $(PPUEXT),$(SYSTEMUNIT))
+
+# Get the system independent include file names.
+# This will set the following variables :
+# SYSINCNAMES
+include $(INC)/makefile.inc
+SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
+
+# Get the processor dependent include file names.
+# This will set the following variables :
+# CPUINCNAMES
+include $(PROCINC)/makefile.cpu
+SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
+
+# Put system unit dependencies together.
+SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
+
+#####################################################################
+# Shell tools
+#####################################################################
+
+# echo
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=echo
+ECHOE:=echo
+else
+ECHO:=$(firstword $(ECHO))
+ECHOE=$(ECHO) -E
+endif
+else
+ECHO:=$(firstword $(ECHO))
+ECHOE=$(ECHO) -E
+endif
+endif
+
+# To copy pograms
+ifndef COPY
+COPY:=cp -fp
+endif
+
+# Copy a whole tree
+ifndef COPYTREE
+COPYTREE:=cp -rfp
+endif
+
+# To move pograms
+ifndef MOVE
+MOVE:=mv -f
+endif
+
+# Check delete program
+ifndef DEL
+DEL:=rm -f
+endif
+
+# Check deltree program
+ifndef DELTREE
+DELTREE:=rm -rf
+endif
+
+# To install files
+ifndef INSTALL
+ifdef inlinux
+INSTALL:=install -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+
+# To install programs
+ifndef INSTALLEXE
+ifdef inlinux
+INSTALLEXE:=install -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+
+# To make a directory.
+ifndef MKDIR
+ifdef inlinux
+MKDIR:=install -m 755 -d
+else
+MKDIR:=ginstall -m 755 -d
+endif
+endif
+
+export ECHO ECHOE COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+
+#####################################################################
+# Default Tools
+#####################################################################
+
+# assembler, redefine it if cross compiling
+ifndef AS
+AS=as
+endif
+
+# linker, but probably not used
+ifndef LD
+LD=ld
+endif
+
+# ppas.bat / ppas.sh
+ifdef inlinux
+PPAS=ppas.sh
+else
+ifdef inOS2
+PPAS=ppas.cmd
+else
+PPAS=ppas.bat
+endif
+endif
+
+# also call ppas if with command option -s
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+EXECPPAS:=@$(PPAS)
+endif
+
+# ldconfig to rebuild .so cache
+ifdef inlinux
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+
+# ppumove
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE=
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+
+# ppufiles
+ifndef PPUFILES
+PPUFILES:=$(strip $(wildcard $(addsuffix /ppufiles$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUFILES),)
+PPUFILES=
+else
+PPUFILES:=$(firstword $(PPUFILES))
+endif
+endif
+export PPUFILES
+
+# Look if UPX is found for go32v2 and win32. We can't use $UPX becuase
+# upx uses that one itself (PFV)
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+
+# ZipProg, you can't use Zip as the var name (PFV)
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG=
+else
+ZIPPROG:=$(firstword $(ZIPPROG)) -D9 -r
+endif
+endif
+export ZIPPROG
+
+ZIPOPT=-9
+ZIPEXT=.zip
+
+# Tar
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(EXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG=
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+
+ifeq ($(USETAR),bz2)
+TAROPT=vI
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+
+#####################################################################
+# Default extensions
+#####################################################################
+
+# Default needed extensions (Go32v2,Linux)
+LOADEREXT=.as
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+RSTEXT=.rst
+FPCMADE=fpcmade
+
+# Go32v1
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+FPCMADE=fpcmade.v1
+endif
+
+# Go32v2
+ifeq ($(OS_TARGET),go32v2)
+FPCMADE=fpcmade.dos
+endif
+
+# Linux
+ifeq ($(OS_TARGET),linux)
+FPCMADE=fpcmade.lnx
+endif
+
+# Win32
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.w32
+endif
+
+# OS/2
+ifeq ($(OS_TARGET),os2)
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+SMARTEXT=.so
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+FPCMADE=fpcmade.os2
+endif
+
+# library prefix
+LIBPREFIX=lib
+ifeq ($(OS_TARGET),go32v2)
+LIBPREFIX=
+endif
+ifeq ($(OS_TARGET),go32v1)
+LIBPREFIX=
+endif
+
+# determine which .pas extension is used
+ifndef PASEXT
+ifdef EXEOBJECTS
+override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(EXEOBJECTS)))))
+else
+override TESTPAS:=$(strip $(wildcard $(addsuffix .pas,$(firstword $(UNITOBJECTS)))))
+endif
+ifeq ($(TESTPAS),)
+PASEXT=.pp
+else
+PASEXT=.pas
+endif
+endif
+
+
+
+#####################################################################
+# Default Directories
+#####################################################################
+
+# set the prefix directory where to install everything
+ifndef PREFIXINSTALLDIR
+ifdef inlinux
+PREFIXINSTALLDIR=/usr
+else
+PREFIXINSTALLDIR=/pp
+endif
+endif
+export PREFIXINSTALLDIR
+
+# Where to place the resulting zip files
+ifndef DESTZIPDIR
+DESTZIPDIR:=$(BASEDIR)
+endif
+export DESTZIPDIR
+
+#####################################################################
+# Install Directories
+#####################################################################
+
+# set the base directory where to install everything
+ifndef BASEINSTALLDIR
+ifdef inlinux
+BASEINSTALLDIR=$(PREFIXINSTALLDIR)/lib/fpc/$(FPC_VERSION)
+else
+BASEINSTALLDIR=$(PREFIXINSTALLDIR)
+endif
+endif
+
+# set the directory where to install the binaries
+ifndef BININSTALLDIR
+ifdef inlinux
+BININSTALLDIR=$(PREFIXINSTALLDIR)/bin
+else
+BININSTALLDIR=$(BASEINSTALLDIR)/bin/$(OS_TARGET)
+endif
+endif
+
+# set the directory where to install the units.
+ifndef UNITINSTALLDIR
+UNITINSTALLDIR=$(BASEINSTALLDIR)/units/$(OS_TARGET)
+ifdef UNITSUBDIR
+UNITINSTALLDIR:=$(UNITINSTALLDIR)/$(UNITSUBDIR)
+endif
+endif
+
+# Where to install shared libraries
+ifndef LIBINSTALLDIR
+ifdef inlinux
+LIBINSTALLDIR=$(PREFIXINSTALLDIR)/lib
+else
+LIBINSTALLDIR=$(UNITINSTALLDIR)
+endif
+endif
+
+# Where the source files will be stored
+ifndef SOURCEINSTALLDIR
+ifdef inlinux
+SOURCEINSTALLDIR=$(PREFIXINSTALLDIR)/src/fpc-$(FPC_VERSION)
+else
+SOURCEINSTALLDIR=$(BASEINSTALLDIR)/source
+endif
+ifdef SOURCESUBDIR
+SOURCEINSTALLDIR:=$(SOURCEINSTALLDIR)/$(SOURCESUBDIR)
+endif
+endif
+
+# Where the doc files will be stored
+ifndef DOCINSTALLDIR
+ifdef inlinux
+DOCINSTALLDIR=$(PREFIXINSTALLDIR)/doc/fpc-$(FPC_VERSION)
+else
+DOCINSTALLDIR=$(BASEINSTALLDIR)/doc
+endif
+endif
+
+# Where the some extra (data)files will be stored
+ifndef DATAINSTALLDIR
+DATAINSTALLDIR=$(BASEINSTALLDIR)
+endif
+
+#####################################################################
+# Redirection
+#####################################################################
+
+# Release ? Then force OPT and don't use extra opts via commandline
+ifndef REDIRFILE
+REDIRFILE=log
+endif
+
+ifdef REDIR
+ifndef inlinux
+override FPC=redir -eo $(FPC)
+endif
+# set the verbosity to max
+override FPCOPT+=-va
+override REDIR:= >> $(REDIRFILE)
+endif
+
+
+#####################################################################
+# Compiler Command Line
+#####################################################################
+
+# Load commandline OPTDEF and add FPC_CPU define
+override FPCOPTDEF:=-d$(CPU_TARGET)
+
+# Load commandline OPT and add target and unit dir to be sure
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+
+ifdef UNITSDIR
+override FPCOPT+=-Fu$(UNITSDIR)
+endif
+
+ifdef NEEDINCDIR
+override FPCOPT+=$(addprefix -Fi,$(NEEDINCDIR))
+endif
+
+
+# Target dirs
+ifdef TARGETDIR
+override FPCOPT+=-FE$(TARGETDIR)
+endif
+
+# Smartlinking
+ifdef SMARTLINK
+override FPCOPT+=-CX
+endif
+
+# Debug
+ifdef DEBUG
+override FPCOPT+=-g -dDEBUG
+endif
+
+# Release mode (strip, optimize and don't load ppc386.cfg)
+ifdef RELEASE
+override FPCOPT+=-Xs -OG2p3 -n
+endif
+
+# Verbose settings (warning,note,info)
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+
+# Add commandline options
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+
+# Add defines from FPCOPTDEF to FPCOPT
+ifdef FPCOPTDEF
+override FPCOPT+=$(FPCOPTDEF)
+endif
+
+# Error file ?
+ifdef ERRORFILE
+override FPCOPT+=-Fr$(ERRORFILE)
+endif
+
+# Was a config file specified ?
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+
+# For win32 the options are passed using the environment FPCEXTCMD
+ifeq ($(OS_SOURCE),win32)
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+endif
+
+# Compiler commandline
+override COMPILER:=$(FPC) $(FPCOPT)
+
+#####################################################################
+# Standard rules
+#####################################################################
+
+all: fpc_all
+
+debug: fpc_debug
+
+smart: fpc_smart
+
+shared: fpc_shared
+
+showinstall: fpc_showinstall
+
+install: fpc_install
+
+sourceinstall: fpc_sourceinstall
+
+zipinstall: fpc_zipinstall
+
+zipsourceinstall: fpc_zipsourceinstall
+
+clean: fpc_clean
+
+cleanall: fpc_cleanall
+
+info: fpc_info
+
+.PHONY:  all debug smart shared showinstall install sourceinstall zipinstall zipsourceinstall clean cleanall info
+
+#####################################################################
+# Loaders
+#####################################################################
+
+.PHONY: fpc_loaders
+
+%$(OEXT): %$(LOADEREXT)
+	$(AS) -o $*$(OEXT) $<
+
+override ALLTARGET+=fpc_loaders
+override CLEANTARGET+=fpc_loaders_clean
+override SHOWINSTALLTARGET+=fpc_loaders_showinstall
+override INSTALLTARGET+=fpc_loaders_install
+
+override LOADEROFILES:=$(addsuffix $(OEXT),$(LOADEROBJECTS))
+
+fpc_loaders: $(LOADEROFILES)
+
+fpc_loaders_clean:
+	-$(DEL) $(LOADEROFILES)
+
+fpc_loaders_showinstall:
+	@$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(LOADEROFILES))
+
+fpc_loaders_install:
+	$(MKDIR) $(UNITINSTALLDIR)
+	$(INSTALL) $(LOADEROFILES) $(UNITINSTALLDIR)
+
+#####################################################################
+# Units
+#####################################################################
+
+.PHONY: fpc_units
+
+override ALLTARGET+=fpc_units
+
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(UNITOBJECTS))
+override INSTALLPPUFILES+=$(UNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES)
+
+fpc_units: $(UNITPPUFILES)
+
+#####################################################################
+# Resource strings
+#####################################################################
+
+override RSTFILES=$(addsuffix $(RSTEXT),$(RSTOBJECTS))
+
+override CLEANRSTFILES+=$(RSTFILES)
+
+#####################################################################
+# General compile rules
+#####################################################################
+
+.PHONY: fpc_packages fpc_all fpc_debug
+
+$(FPCMADE): $(ALLTARGET)
+	@$(ECHO) Compiled > $(FPCMADE)
+
+fpc_packages: $(COMPILEPACKAGES)
+
+fpc_all: fpc_packages $(FPCMADE)
+
+fpc_debug:
+	$(MAKE) all DEBUG=1
+
+# General compile rules, available for both possible PASEXT
+
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .pp
+
+%$(PPUEXT): %.pp
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
+
+%$(PPUEXT): %.pas
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
+
+%$(EXEEXT): %.pp
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
+
+%$(EXEEXT): %.pas
+	$(COMPILER) $< $(REDIR)
+	$(EXECPASS)
+
+#####################################################################
+# Library
+#####################################################################
+
+.PHONY: fpc_smart fpc_shared
+
+# Default sharedlib units are all unit objects
+ifndef SHAREDLIBUNITOBJECTS
+SHAREDLIBUNITOBJECTS:=$(UNITOBJECTS)
+endif
+
+fpc_smart:
+	$(MAKE) all SMARTLINK=1
+
+fpc_shared: all
+ifdef inlinux
+ifndef LIBNAME
+	@$(ECHO) "LIBNAME not set"
+else
+	$(PPUMOVE) $(SHAREDLIBUNITOBJECTS) -o$(LIBNAME)
+endif
+else
+	@$(ECHO) "Shared Libraries not supported"
+endif
+
+#####################################################################
+# Install rules
+#####################################################################
+
+.PHONY: fpc_showinstall fpc_install
+
+ifdef EXTRAINSTALLUNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRAINSTALLUNITS))
+endif
+
+ifdef INSTALLPPUFILES
+ifdef PPUFILES
+ifdef inlinux
+INSTALLPPULINKFILES:=$(shell $(PPUFILES) -S -O $(INSTALLPPUFILES))
+INSTALLPPULIBFILES:=$(shell $(PPUFILES) -L $(INSTALLPPUFILES))
+else
+INSTALLPPULINKFILES:=$(shell $(PPUFILES) $(INSTALLPPUFILES))
+endif
+else
+INSTALLPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)))
+endif
+endif
+
+fpc_showinstall: $(SHOWINSTALLTARGET)
+ifdef INSTALLEXEFILES
+	@$(ECHO) -e $(addprefix "\n"$(BININSTALLDIR)/,$(INSTALLEXEFILES))
+endif
+ifdef INSTALLPPUFILES
+	@$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPUFILES))
+ifneq ($(INSTALLPPULINKFILES),)
+	@$(ECHO) -e $(addprefix "\n"$(UNITINSTALLDIR)/,$(INSTALLPPULINKFILES))
+endif
+ifneq ($(INSTALLPPULIBFILES),)
+	@$(ECHO) -e $(addprefix "\n"$(LIBINSTALLDIR)/,$(INSTALLPPULIBFILES))
+endif
+endif
+ifdef EXTRAINSTALLFILES
+	@$(ECHO) -e $(addprefix "\n"$(DATAINSTALLDIR)/,$(EXTRAINSTALLFILES))
+endif
+
+fpc_install: $(INSTALLTARGET)
+# Create UnitInstallFiles
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(BININSTALLDIR)
+# Compress the exes if upx is defined
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(BININSTALLDIR)
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(UNITINSTALLDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(UNITINSTALLDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(UNITINSTALLDIR)
+endif
+ifneq ($(INSTALLPPULIBFILES),)
+	$(MKDIR) $(LIBINSTALLDIR)
+	$(INSTALL) $(INSTALLPPULIBFILES) $(LIBINSTALLDIR)
+endif
+endif
+ifdef EXTRAINSTALLFILES
+	$(MKDIR) $(DATAINSTALLDIR)
+	$(INSTALL) $(EXTRAINSTALLFILES) $(DATAINSTALLDIR)
+endif
+
+#####################################################################
+# SourceInstall rules
+#####################################################################
+
+.PHONY: fpc_sourceinstall
+
+ifndef SOURCETOPDIR
+SOURCETOPDIR=$(BASEDIR)
+endif
+
+fpc_sourceinstall: clean
+	$(MKDIR) $(SOURCEINSTALLDIR)
+	$(COPYTREE) $(SOURCETOPDIR) $(SOURCEINSTALLDIR)
+
+#####################################################################
+# Zip
+#####################################################################
+
+.PHONY: fpc_zipinstall
+
+# Create suffix to add
+ifndef PACKAGESUFFIX
+PACKAGESUFFIX=$(OS_TARGET)
+ifeq ($(OS_TARGET),go32v2)
+PACKAGESUFFIX=go32
+endif
+ifeq ($(OS_TARGET),win32)
+PACKAGESUFFIX=w32
+endif
+endif
+
+# Temporary path to pack a file
+ifndef PACKDIR
+ifndef inlinux
+PACKDIR=$(BASEDIR)/pack_tmp
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+
+# Maybe create default zipname from packagename
+ifndef ZIPNAME
+ifdef PACKAGENAME
+ZIPNAME=$(PACKAGEPREFIX)$(PACKAGENAME)$(PACKAGESUFFIX)
+endif
+endif
+
+# Use tar by default under linux
+ifndef USEZIP
+ifdef inlinux
+USETAR=1
+endif
+endif
+
+fpc_zipinstall:
+ifndef ZIPNAME
+	@$(ECHO) "Please specify ZIPNAME!"
+	@exit 1
+else
+	$(MAKE) $(ZIPTARGET) PREFIXINSTALLDIR=$(PACKDIR)
+ifdef USETAR
+	$(DEL) $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT)
+	cd $(PACKDIR) ; $(TARPROG) c$(TAROPT) --file $(DESTZIPDIR)/$(ZIPNAME)$(TAREXT) * ; cd $(BASEDIR)
+else
+	$(DEL) $(DESTZIPDIR)/$(ZIPNAME)/$(ZIPEXT)
+	cd $(PACKDIR) ; $(ZIPPROG) -Dr $(ZIPOPT) $(DESTZIPDIR)/$(ZIPNAME)$(ZIPEXT) * ; cd $(BASEDIR)
+endif
+	$(DELTREE) $(PACKDIR)
+endif
+
+.PHONY:  fpc_zipsourceinstall
+
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall PACKAGESUFFIX=src
+
+#####################################################################
+# Clean rules
+#####################################################################
+
+.PHONY: fpc_clean fpc_cleanall
+
+ifdef EXTRACLEANUNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(EXTRACLEANUNITS))
+endif
+
+ifdef CLEANPPUFILES
+ifdef PPUFILES
+CLEANPPULINKFILES:=$(shell $(PPUFILES) $(CLEANPPUFILES))
+else
+CLEANPPULINKFILES:=$(wildcard $(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)))
+endif
+endif
+
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(CLEANRSTFILES)
+endif
+ifdef EXTRACLEANFILES
+	-$(DEL) $(EXTRACLEANFILES)
+endif
+	-$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTCMD) $(REDIRFILE)
+
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTCMD) $(REDIRFILE)
+
+#####################################################################
+# Info rules
+#####################################################################
+
+.PHONY: fpc_info fpc_cfginfo fpc_objectinfo fpc_toolsinfo fpc_installinfo \
+	fpc_dirinfo
+
+fpc_info: $(INFOTARGET)
+
+fpc_infocfg:
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC....... $(FPC)
+	@$(ECHO)  Version... $(FPC_VERSION)
+	@$(ECHO)  CPU....... $(CPU_TARGET)
+	@$(ECHO)  Source.... $(OS_SOURCE)
+	@$(ECHO)  Target.... $(OS_TARGET)
+	@$(ECHO)
+
+fpc_infoobjects:
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  LoaderObjects..... $(LOADEROBJECTS)
+	@$(ECHO)  UnitObjects....... $(UNITOBJECTS)
+	@$(ECHO)  ExeObjects........ $(EXEOBJECTS)
+	@$(ECHO)
+	@$(ECHO)  ExtraCleanUnits... $(EXTRACLEANUNITS)
+	@$(ECHO)  ExtraCleanFiles... $(EXTRACLEANFILES)
+	@$(ECHO)
+	@$(ECHO)  ExtraInstallUnits. $(EXTRAINSTALLUNITS)
+	@$(ECHO)  ExtraInstallFiles. $(EXTRAINSTALLFILES)
+	@$(ECHO)
+
+fpc_infoinstall:
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+ifdef DATE
+	@$(ECHO)  DateStr.............. $(DATESTR)
+endif
+ifdef PACKAGEPREFIX
+	@$(ECHO)  PackagePrefix........ $(PACKAGEPREFIX)
+endif
+ifdef PACKAGENAME
+	@$(ECHO)  PackageName.......... $(PACKAGENAME)
+endif
+	@$(ECHO)  PackageSuffix........ $(PACKAGESUFFIX)
+	@$(ECHO)
+	@$(ECHO)  BaseInstallDir....... $(BASEINSTALLDIR)
+	@$(ECHO)  BinInstallDir........ $(BININSTALLDIR)
+	@$(ECHO)  LibInstallDir........ $(LIBINSTALLDIR)
+	@$(ECHO)  UnitInstallDir....... $(UNITINSTALLDIR)
+	@$(ECHO)  SourceInstallDir..... $(SOURCEINSTALLDIR)
+	@$(ECHO)  DocInstallDir........ $(DOCINSTALLDIR)
+	@$(ECHO)  DataInstallDir....... $(DATAINSTALLDIR)
+	@$(ECHO)
+	@$(ECHO)  DestZipDir........... $(DESTZIPDIR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)
+
+#####################################################################
+# Local Makefile
+#####################################################################
+
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif
+
+#####################################################################
+# Users rules
+#####################################################################
+
+vpath %$(PASEXT) $(INC) $(PROCINC)
+
+#
+# Loaders
+#
+
+prt0$(OEXT) : $(CPU_TARGET)/prt0.as
+	$(AS) -o prt0$(OEXT) $(CPU_TARGET)/prt0.as
+
+cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
+	$(AS) -o cprt0$(OEXT) $(CPU_TARGET)/cprt0.as
+
+
+
+
+#
+# System Units (System, Objpas, Strings)
+#
+
+$(SYSTEMPPU) : syslinux.pp sysconst.inc systypes.inc syscalls.inc $(SYSDEPS)
+	$(COMPILER) -Us -Sg syslinux.pp $(REDIR)
+
+objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMPPU)
+	$(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp $(REDIR)
+
+strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
+		   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
+		   $(SYSTEMPPU)
+
+#
+# System Dependent Units
+#
+
+linux$(PPUEXT) : linux.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
+		 syscalls.inc systypes.inc sysconst.inc timezone.inc $(SYSTEMPPU) \
+		 linsysca.inc
+
+
+#
+# TP7 Compatible RTL Units
+#
+
+dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
+	       linux$(PPUEXT) $(SYSTEMPPU)
+
+crt$(PPUEXT) : crt.pp $(INC)/textrec.inc linux$(PPUEXT) $(SYSTEMPPU)
+
+objects$(PPUEXT) : $(INC)/objects.pp objinc.inc $(SYSTEMPPU)
+
+printer$(PPUEXT) : printer.pp $(INC)/textrec.inc linux$(PPUEXT) $(SYSTEMPPU)
+
+#
+# Graph
+#
+
+#
+# Delphi Compatible Units
+#
+
+sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
+		    objpas$(PPUEXT) linux$(PPUEXT) errors$(PPUEXT)
+	$(COMPILER) -I$(OBJPASDIR) sysutils.pp $(REDIR)
+
+typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
+	$(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp $(REDIR)
+
+math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
+	$(COMPILER) $(OBJPASDIR)/math.pp $(REDIR)
+
+gettext$(PPUEXT): $(OBJPASDIR)/gettext.pp objpas$(PPUEXT) sysutils$(PPUEXT)
+	$(COMPILER) $(OBJPASDIR)/gettext.pp $(REDIR)
+
+#
+# Other system-independent RTL Units
+#
+
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMPPU)
+
+mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMPPU)
+
+getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMPPU)
+
+heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMPPU)
+	$(COMPILER) -Sg $(INC)/heaptrc.pp $(REDIR)
+
+lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMPPU)
+
+#
+# Other system-dependent RTL Units
+#
+
+sockets$(PPUEXT) : sockets.pp $(INC)/textrec.inc $(INC)/filerec.inc \
+		   linux$(PPUEXT) $(SYSTEMPPU)
+
+errors$(PPUEXT) : errors.pp strings$(PPUEXT) $(SYSTEMPPU)
+
+ipc$(PPUEXT) : ipc.pp linux$(PPUEXT) $(SYSTEMPPU)

+ 181 - 0
rtl/bsd/Makefile.fpc

@@ -0,0 +1,181 @@
+#
+#   Makefile.fpc for Free Pascal FreeBSD RTL
+#
+
+[targets]
+loaders=prt0 cprt0 
+units=$(SYSTEMUNIT) objpas strings \
+      linux initc \
+      dos crt objects printer \
+      sysutils typinfo math \
+      cpu mmx getopts heaptrc lineinfo \
+      errors sockets gpm ipc 
+rst=math
+
+[require]
+rtl=0
+
+[defaults]
+defaulttarget=linux
+defaultcpu=i386
+
+[install]
+unitsubdir=rtl
+
+[dirs]
+fpcdir=.
+incdir=$(INC) $(PROCINC)
+targetdir=.
+
+[libs]
+libname=libfprtl.so
+libversion=1.0
+libunits=$(SYSTEMUNIT) objpas strings \
+      linux  \
+      dos crt objects printer \
+      sysutils typinfo math \
+      cpu mmx getopts heaptrc \
+      errors sockets ipc
+
+
+[presettings]
+RTL=..
+INC=$(RTL)/inc
+PROCINC=$(RTL)/$(CPU_TARGET)
+
+UNITPREFIX=rtl
+
+# Paths
+OBJPASDIR=$(RTL)/objpas
+GRAPHDIR=$(INC)/graph
+
+# Define Go32v2 Units
+SYSTEMUNIT=syslinux
+
+# Use new graph unit ?
+# NEWGRAPH=YES
+# Use LibGGI ?
+# Use
+#
+ifndef USELIBGGI
+USELIBGGI=NO
+endif
+
+
+[postsettings]
+SYSTEMPPU=$(addsuffix $(PPUEXT),$(SYSTEMUNIT))
+
+# Get the system independent include file names.
+# This will set the following variables :
+# SYSINCNAMES
+include $(INC)/makefile.inc
+SYSINCDEPS=$(addprefix $(INC)/,$(SYSINCNAMES))
+
+# Get the processor dependent include file names.
+# This will set the following variables :
+# CPUINCNAMES
+include $(PROCINC)/makefile.cpu
+SYSCPUDEPS=$(addprefix $(PROCINC)/,$(CPUINCNAMES))
+
+# Put system unit dependencies together.
+SYSDEPS=$(SYSINCDEPS) $(SYSCPUDEPS)
+
+
+[rules]
+vpath %$(PASEXT) $(INC) $(PROCINC)
+
+#
+# Loaders
+#
+
+prt0$(OEXT) : $(CPU_TARGET)/prt0.as
+        $(AS) -o prt0$(OEXT) $(CPU_TARGET)/prt0.as
+
+cprt0$(OEXT) : $(CPU_TARGET)/cprt0.as
+        $(AS) -o cprt0$(OEXT) $(CPU_TARGET)/cprt0.as
+
+
+
+
+#
+# System Units (System, Objpas, Strings)
+#
+
+$(SYSTEMPPU) : syslinux.pp sysconst.inc systypes.inc syscalls.inc $(SYSDEPS)
+        $(COMPILER) -Us -Sg syslinux.pp $(REDIR)
+
+objpas$(PPUEXT): $(OBJPASDIR)/objpas.pp $(INC)/except.inc $(SYSTEMPPU)
+        $(COMPILER) -I$(OBJPASDIR) $(OBJPASDIR)/objpas.pp $(REDIR)
+
+strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
+                   $(PROCINC)/strings.inc $(PROCINC)/stringss.inc\
+                   $(SYSTEMPPU)
+
+#
+# System Dependent Units
+#
+
+linux$(PPUEXT) : linux.pp strings$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
+                 syscalls.inc systypes.inc sysconst.inc timezone.inc $(SYSTEMPPU) \
+                 linsysca.inc
+
+
+#
+# TP7 Compatible RTL Units
+#
+
+dos$(PPUEXT) : dos.pp $(INC)/filerec.inc $(INC)/textrec.inc strings$(PPUEXT) \
+               linux$(PPUEXT) $(SYSTEMPPU)
+
+crt$(PPUEXT) : crt.pp $(INC)/textrec.inc linux$(PPUEXT) $(SYSTEMPPU)
+
+objects$(PPUEXT) : $(INC)/objects.pp objinc.inc $(SYSTEMPPU)
+
+printer$(PPUEXT) : printer.pp $(INC)/textrec.inc linux$(PPUEXT) $(SYSTEMPPU)
+
+#
+# Graph
+#
+
+#
+# Delphi Compatible Units
+#
+
+sysutils$(PPUEXT) : sysutils.pp $(wildcard $(OBJPASDIR)/*.inc) \
+                    objpas$(PPUEXT) linux$(PPUEXT) errors$(PPUEXT)
+        $(COMPILER) -I$(OBJPASDIR) sysutils.pp $(REDIR)
+
+typinfo$(PPUEXT): $(OBJPASDIR)/typinfo.pp objpas$(PPUEXT)
+        $(COMPILER) -Sg $(OBJPASDIR)/typinfo.pp $(REDIR)
+
+math$(PPUEXT): $(OBJPASDIR)/math.pp objpas$(PPUEXT) sysutils$(PPUEXT)
+        $(COMPILER) $(OBJPASDIR)/math.pp $(REDIR)
+
+gettext$(PPUEXT): $(OBJPASDIR)/gettext.pp objpas$(PPUEXT) sysutils$(PPUEXT)
+        $(COMPILER) $(OBJPASDIR)/gettext.pp $(REDIR)
+
+#
+# Other system-independent RTL Units
+#
+
+cpu$(PPUEXT) : $(PROCINC)/cpu.pp $(SYSTEMPPU)
+
+mmx$(PPUEXT) : $(PROCINC)/mmx.pp cpu$(PPUEXT) $(SYSTEMPPU)
+
+getopts$(PPUEXT) : $(INC)/getopts.pp $(SYSTEMPPU)
+
+heaptrc$(PPUEXT) : $(INC)/heaptrc.pp $(SYSTEMPPU)
+        $(COMPILER) -Sg $(INC)/heaptrc.pp $(REDIR)
+
+lineinfo$(PPUEXT) : $(INC)/lineinfo.pp $(SYSTEMPPU)
+
+#
+# Other system-dependent RTL Units
+#
+
+sockets$(PPUEXT) : sockets.pp $(INC)/textrec.inc $(INC)/filerec.inc \
+                   linux$(PPUEXT) $(SYSTEMPPU)
+
+errors$(PPUEXT) : errors.pp strings$(PPUEXT) $(SYSTEMPPU)
+
+ipc$(PPUEXT) : ipc.pp linux$(PPUEXT) $(SYSTEMPPU)

+ 224 - 0
rtl/bsd/bsdport.txt

@@ -0,0 +1,224 @@
+$Id$
+
+Comments, mistakes and suggestions to [email protected]
+
+1 FreeBSD status and notes. (kept on CVS because I work on several places)
+-----------------------------------------------------------------------------
+
+Please read these before running a FreeBSD snapshot.
+
+- Supported are FreeBSD 3.x (3.2, 3.4 and 4.0-release (quickly) tested. I never
+   tested on 3.0).  NON-ELF (2.x) versions are not supported.
+
+- This is alpha software. I didn't have data-loss using it, but you
+	use this on your own responsability. Use a scratch, or well backup'ed
+	system.
+
+- The FreeBSD/FPC port is now in its second stage. Some more stuff then what
+    is required to recompile is now implemented (Clone, Sockets, Signals).
+    Plans to create an (Alpha) release distribution are being made.
+    (linking to external libs worked in the 16 april version already, even
+    though the bsdport.txt of that date said it didn't)
+    
+-  IMPORTANT:
+     !!! An explicite warning: Not all procedures and structures in Linux are
+   checked, so even if they are not commented out, they can be not implemented!!!
+   This specially applies to linux specific stuff. In case of doubt, use a
+   scratch system, view the source, or mail the maintainer.
+
+- The pre alpha version's READDIR problem is fixed with a "hack", which
+    means that searchpath (-Fx) and FindFirst/FindNext are more or less 
+    working.
+  I don't know how  good that hack is,I hope to replace it later this week 
+     by a port of freebsd's libc opendir/readdir/closedir/telldir/seekdir code,
+     just to make sure.( Libc does some complex scanning and sorting for
+     duplicate names, but I don't know if that is something archaic or not.
+     Probably related to hardlinks, so don't use findfirst in /dev for now)
+
+These packages have more or less been tested with ncurses:
+- RTL, (NOT the Crt unit. Use ncrt for now!)
+- compiler can rebuild (see below)
+- packages/inet,
+- packages/zlib
+- packages/x11
+- fcl/
+- ncurses/panel.
+- (reported by somebody else) XForms.
+- fpgui's "hello world" demo (the other ones needed a FPC 1.1 compiler, I
+        only tested 1.0.1 with FreeBSD)
+
+2 Syscalls.
+-----------
+
+The bulk of the linux syscalls are implemented.
+
+Some that aren't implemented:
+
+NI           = not implemented yet
+req          = required for compiler
+noreq?       = not required, but not checked.
+Ever? (y/n)
+
+syscall   status  Ever?  comment
+------------------------------------------------------------------------
+Readdir   I req         implemented from scratch, working. (this
+                        call doesn't exist on FreeBSD and FindFirst is
+                        based on it)
+
+ioperm   NI noreq  n    IO via port access impossible under FreeBSD
+                           (so: no ports unit, port[] support)
+                        (got some reports that port access is possible under
+                        FreeBSD. Probably the same way it slipped into Linux;
+                        dos emulation)
+
+ipc      NI       ?     The IPC is System V thingy, and only supported
+                          under FreeBSD with certain kernel parameters.
+
+Clone()  I  noreq       Not implemented as syscall, based on linuxthread
+                         assembler routine. Untested. Somebody has a good
+                         test program? Or that tests the FCL threading
+                         routines based on it?
+
+sysinfo  NI noreq       Not supported under BSD, not even by emulator
+uname    NI noreq       "        "       "    "   "   "    "   "
+                        (procedures based on this call are also commented
+                         (get* procs))
+
+signal   I   noreq      A *lot* of emulation code.
+alarm    NI  noreq?     Could be possible to port. (crt.delay?)
+pause    NI  noreq?     Also possible I think. Uses process information
+                        in linux-emu, that is why I didn't port directly.
+
+3 How to build a FreeBSD compiler/RTL ?
+-----------------------------------------------------------------------------
+
+(You'll probably need CVS sources dated after April 16th for basic support, or
+after the major updates on 10 september for signals and sockets.)
+
+To rebuild the compiler, you need a starting compiler.
+- Start compiler on other OS? (tested is Linux) -> check 3a
+- Already a 1.0.x startcompiler on FreeBSD (e.g. from a snapshot) -> 3b is much
+    easier.
+
+3a How to build a FreeBSD system starting on Linux or using the Linux emu of
+   FreeBSD? (Bootstrapping)
+
+The FreeBSD port is experimental atm, though valid native binaries can be
+obtained.
+
+The procedure here is verbose, and for the most akward case.
+If you have linux support on on your FreeBSD machine, or operate on NFS or Samba
+share (so that copying and using the sources in two systems is easier)
+some steps can be omitted or simplified. Just play with it.
+
+STEP A: create the RTL assembler files.
+
+1. Copy all linux files to a new directory. (here called BSDBUILD), and
+2. Copy all bsd files over them.
+2b. Run fpcmake if you can. This will eliminate problems with Makefile being
+    out of sync or containing dos lfns.
+3. Execute  make OPT='-Tlinux -dBSD -a -s -OG3p3' (with any i386 FPC
+    compiler) in directory BSDBUILD. This failed with some go32v2 versions
+    (which wanted to assemble anyway), but worked with several win32 and
+    linux' snapshots. On go32v2 you can try to add -Aas.
+
+You now have .ppu's and .s  's for the RTL hopefully. Don't forget
+    i386/prt0.as (which is in fact a .s file)!
+
+STEP B: Create the compiler assembler (.s) sources;
+
+4. Compile with
+   ./bsdcompile -Fu/full_path_to_BSDBUILD -a -s
+
+(steps 5 and 6 are only needed for the very first FreeBSD snapshot, which
+is no longer available)
+
+STEP C: Building the binary
+
+7. Copy all necessary files
+    (- all *.s *.ppu files, both from compiler and BSDBUILD dir,
+     - compiler/link.res and
+     - compiler/ppas.sh
+     - Cut and paste of the DO_S script at the end of this document to file
+     - rtl/bsd/i386/*.as files.
+     )
+     to a directory on the BSD machine.
+8a. Change to the directory on the BSD machine, and run the script DO_S to
+    assemble all .s files to .o files.
+8b. Assemble the stub with as prt0.as -o prt0.o
+9. Adapt link.res so that all paths are right.
+    (remove all paths in front of all .o files, remove the -l lines and their
+      parentheses)
+10a. Edit ppas.sh, and keep only #!/bin/sh and the line starting with ld.
+  b  Remove any -l=ld-linux.so.1 (or similar) option from the ld line.
+  c  run ppas.sh to build the compiler
+
+11. Have fun :-) The compiler is called "pp"
+
+12. If you have a heavy machine (pentium 100 and 32MB+) execute 3b to make
+    sure everything is up to date.
+
+------------
+
+3b How to update FPC compiler on FreeBSD from fresh CVS sources with a snapshot
+installed.
+
+(To create a compiler for the 1.0 branch, you need a 1.0.x compiler, and to
+create a 1.1 (development branch) compiler you need a 1.1.x snapshot.
+You can check the version of your snapshot with ppc386 -i)
+
+(assuming ppc386 in the PATH, and a rtl/ and compiler/ directory obtained
+ from snapshot zips, with non mangled makefiles)
+
+1a  Rename the rtl/linux to something else. (here: rtl/linuxorg)
+1b  create a new rtl/linux dir
+1c  copy rtl/linuxorg/* to rtl/linux
+1d  copy rtl/bsd/* to rtl/linux  RECURSIVELY
+1e  (optionally) Run fpcmake if you have it installed. This is a good
+    habit!
+2   switch to compiler/
+3   gmake cycle OPT='-OG3p3 -dBSD' will generate a new compiler.
+
+Be patient! FreeBSD has slower disk-io than Linux :-)
+
+Rest is like Linux, except that I strongly advise to create the fpc
+directory always in /usr/local/lib/ instead of /usr/lib.
+This habit is still fashionable on FreeBSD.
+
+The same with other packages. Like Linux :-)
+
+4 Linking to external libraries
+-----------------------------------------------------------------------------
+
+Same as on Linux, except use the
+
+
+------------------
+The DO_S script. (C) El Znorro
+------------------
+#!/bin/sh
+
+for i in *.s; do
+ flup=`basename $i .s`
+ as $i -o $flup.o
+ echo $i
+ echo $flup
+ done
+
+{
+$Log$
+Revision 1.3  2000-09-11 14:38:09  marco
+ * 14 april version killed, and replaced by newer fixes branch version
+
+Revision 1.1.2.1  2000/09/10 16:12:14  marco
+Initial signals, sockets and clone
+
+Revision 1.1  2000/07/13 06:30:32  michael
++ Initial import
+
+Revision 1.3  2000/04/16 16:11:33  marco
+ * Severe updates for now *working* status
+
+Revision 1.2  2000/04/10 15:46:51  marco
+ * worked all day. probably a lot changed
+}

+ 176 - 0
rtl/bsd/bsdsock.inc

@@ -0,0 +1,176 @@
+{******************************************************************************
+                          Basic Socket Functions
+******************************************************************************}
+
+Function socket(Domain,SocketType,Protocol:Longint):Longint;
+begin
+  Socket:=Do_Syscall(syscall_nr_socket,Domain,SocketType,Protocol);
+end;
+
+Function Send(Sock:Longint;Var Addr;AddrLen,Flags:Longint):Longint;
+begin
+  Send:=do_syscall(syscall_nr_sendto,Sock,Longint(@Addr),AddrLen,Flags,0,0);
+end;
+
+Function Recv(Sock:Longint;Var Addr;AddrLen,Flags:Longint):Longint;
+begin
+  Recv:=do_syscall(syscall_nr_Recvfrom,Sock,Longint(@Addr),AddrLen,Flags,0,0);
+end;
+
+Function Bind(Sock:Longint;Var Addr;AddrLen:Longint):Boolean;
+begin
+  Bind:=(do_syscall(syscall_nr_Bind,Sock,Longint(@Addr),AddrLen)=0);
+end;
+
+Function Listen(Sock,MaxConnect:Longint):Boolean;
+begin
+  Listen:=(do_syscall(syscall_nr_Listen,Sock,MaxConnect,0)=0);
+end;
+
+Function Accept(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
+begin
+  Accept:=do_syscall(syscall_nr_accept,Sock,longint(@Addr),longint(@AddrLen));
+  If Accept<0 Then
+    Accept:=-1;
+end;
+
+Function Connect(Sock:Longint;Var Addr;Addrlen:Longint): boolean;
+
+begin
+  Connect:=do_syscall(syscall_nr_connect,Sock,longint(@Addr),AddrLen)=0;
+end;
+
+
+Function Shutdown(Sock:Longint;How:Longint):Longint;
+begin
+  ShutDown:=do_syscall(syscall_nr_shutdown,Sock,How);
+end;
+
+
+Function GetSocketName(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
+begin
+  GetSocketName:=do_syscall(syscall_nr_GetSockName,Sock,longint(@Addr),longint(@AddrLen));
+end;
+
+
+
+Function GetPeerName(Sock:Longint;Var Addr;Var Addrlen:Longint):Longint;
+begin
+  GetPeerName:=do_syscall(syscall_nr_GetPeerName,Sock,longint(@Addr),longint(@AddrLen));
+end;
+
+
+
+Function SetSocketOptions(Sock,Level,OptName:Longint;Var OptVal;optlen:longint):Longint;
+begin
+  SetSocketOptions:=do_syscall(syscall_nr_SetSockOpt,Sock,Level,OptName,Longint(@OptVal),OptLen,0);
+end;
+
+
+
+Function GetSocketOptions(Sock,Level,OptName:Longint;Var OptVal;Var optlen:longint):Longint;
+begin
+  GetSocketOptions:=do_syscall(syscall_nr_GetSockOpt,Sock,Level,OptName,Longint(@OptVal),OptLen,0);
+end;
+
+
+
+Function SocketPair(Domain,SocketType,Protocol:Longint;var Pair:TSockArray):Longint;
+begin
+  SocketPair:=do_syscall(syscall_nr_SocketPair,Domain,SocketType,Protocol,longint(@Pair),0,0);
+end;
+
+{******************************************************************************
+                               UnixSock
+******************************************************************************}
+
+Procedure Str2UnixSockAddr(const addr:string;var t:TUnixSockAddr;var len:longint);
+begin
+  Move(Addr[1],t.Path,length(Addr));
+  t.Family:=AF_UNIX;
+  t.Path[length(Addr)]:=#0;
+  Len:=Length(Addr)+3;
+end;
+
+
+Function Bind(Sock:longint;const addr:string):boolean;
+var
+  UnixAddr : TUnixSockAddr;
+  AddrLen  : longint;
+begin
+  Str2UnixSockAddr(addr,UnixAddr,AddrLen);
+  Bind(Sock,UnixAddr,AddrLen);
+  Bind:=(SocketError=0);
+end;
+
+
+
+Function DoAccept(Sock:longint;var addr:string):longint;
+var
+  UnixAddr : TUnixSockAddr;
+  AddrLen  : longint;
+begin
+  AddrLen:=length(addr)+3;
+  DoAccept:=Accept(Sock,UnixAddr,AddrLen);
+  Move(UnixAddr.Path,Addr[1],AddrLen);
+  SetLength(Addr,AddrLen);
+end;
+
+
+
+Function DoConnect(Sock:longint;const addr:string):Boolean;
+var
+  UnixAddr : TUnixSockAddr;
+  AddrLen  : longint;
+begin
+  Str2UnixSockAddr(addr,UnixAddr,AddrLen);
+  DoConnect:=Connect(Sock,UnixAddr,AddrLen);
+end;
+
+Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:text):Boolean;
+var
+  s : longint;
+begin
+  S:=DoAccept(Sock,addr);
+  if S>0 then
+   begin
+     Sock2Text(S,SockIn,SockOut);
+     Accept:=true;
+   end
+  else
+   Accept:=false;
+end;
+
+
+
+Function Accept(Sock:longint;var addr:string;var SockIn,SockOut:File):Boolean;
+var
+  s : longint;
+begin
+  S:=DoAccept(Sock,addr);
+  if S>0 then
+   begin
+     Sock2File(S,SockIn,SockOut);
+     Accept:=true;
+   end
+  else
+   Accept:=false;
+end;
+
+
+
+Function Connect(Sock:longint;const addr:string;var SockIn,SockOut:text):Boolean;
+begin
+  Connect:=DoConnect(Sock,addr);
+  If Connect then
+     Sock2Text(Sock,SockIn,SockOut);
+end;
+
+
+
+Function Connect(Sock:longint;const addr:string;var SockIn,SockOut:file):Boolean;
+begin
+  Connect:=DoConnect(Sock,addr);
+  if Connect then
+     Sock2File(Sock,SockIn,SockOut);
+end;

+ 141 - 0
rtl/bsd/i386/cprt0.as

@@ -0,0 +1,141 @@
+#
+#   $Id$
+#   This file is part of the Free Pascal run time library.
+#   Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
+#                                                  and Peter Vreman
+#   members of the Free Pascal development team.
+#
+#   See the file COPYING.FPC, included in this distribution,
+#   for details about the copyright.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY;without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+#**********************************************************************}
+#
+# FreeBSD  ELF startup code for Free Pascal for dynamical linking to libc.
+#
+
+        .file   "cprt0.as"
+        .version        "01.01"
+gcc2_compiled.:
+.globl __progname
+.section        .rodata
+.LC0:
+        .ascii "\0"
+.data
+        .p2align 2
+        .type    __progname,@object
+        .size    __progname,4
+__progname:
+        .long .LC0
+        .align  4
+___fpucw:
+        .long   0x1332
+
+        .globl  ___fpc_brk_addr         /* heap management */
+        .type   ___fpc_brk_addr,@object
+        .size   ___fpc_brk_addr,4
+___fpc_brk_addr:
+        .long   0
+
+
+.text
+        .p2align 2
+.globl _start
+        .type    _start,@function
+_start:
+        pushl %ebp
+        movl %esp,%ebp
+        pushl %edi
+        pushl %esi
+        pushl %ebx
+#APP
+        movl %edx,%edx
+#NO_APP
+        leal 8(%ebp),%edi
+        movl %edi,U_SYSLINUX_ARGV
+        mov -4(%edi),%eax
+        movl %eax,U_SYSLINUX_ARGC
+        movl 4(%ebp),%ebx
+        leal 12(%ebp,%ebx,4),%esi
+        movl %esi,U_SYSLINUX_ENVP
+        movl %esi,environ
+        testl %ebx,%ebx
+        jle .L2
+        movl 8(%ebp),%eax
+        testl %eax,%eax
+        je .L2
+        movl %eax,__progname
+        cmpb $0,(%eax)
+        je .L2
+        .p2align 2,0x90
+.L6:
+        cmpb $47,(%eax)
+        jne .L5
+        leal 1(%eax),%ecx
+        movl %ecx,__progname
+.L5:
+        incl %eax
+        cmpb $0,(%eax)
+        jne .L6
+.L2:
+        movl $_DYNAMIC,%eax
+        testl %eax,%eax
+        je .L9
+        pushl %edx
+        call atexit
+        addl $4,%esp
+.L9:
+        pushl $_fini
+        call atexit
+        call _init
+#       pushl %esi
+#       pushl %edi
+#       pushl %ebx
+#       call main
+#       pushl %eax
+#       call exit
+
+
+        finit                           /* initialize fpu */
+        fwait
+        fldcw   ___fpucw
+
+        xorl    %ebp,%ebp
+
+        call main
+        pushl %eax
+        jmp   _haltproc
+
+        .p2align 2,0x90
+        
+.globl _haltproc
+.type _haltproc,@function
+
+_haltproc:
+           mov $1,%eax  
+           movzwl U_SYSLINUX_EXITCODE,%ebx
+           pushl %ebx
+           call .Lactualsyscall
+           addl  $4,%esp
+           jmp   _haltproc
+
+.Lactualsyscall:
+         int $0x80
+         jb .LErrorcode
+         xor %ebx,%ebx
+         ret
+.LErrorcode:
+         mov %eax,%ebx
+         mov $-1,%eax
+         ret
+        .p2align 2,0x90
+.Lfe1:
+
+
+        .size    _start,.Lfe1-_start
+        .comm   environ,4,4
+        .weak   _DYNAMIC
+        .ident  "GCC: (GNU) 2.7.2.1"

+ 124 - 0
rtl/bsd/i386/prt0.as

@@ -0,0 +1,124 @@
+#
+#   $Id$
+#   This file is part of the Free Pascal run time library.
+#   Copyright (c) 1999-2000 by Marco van de Voort, Michael Van Canneyt
+#                                                  and Peter Vreman
+#   members of the Free Pascal development team.
+#
+#   See the file COPYING.FPC, included in this distribution,
+#   for details about the copyright.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY;without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+#**********************************************************************}
+#
+# FreeBSD standard (static) ELF startup code for Free Pascal
+#
+
+        .file   "prt1.as"
+        .version        "01.01"
+gcc2_compiled.:
+.globl __progname
+.section        .rodata
+.LC0:
+        .ascii "\0"
+.data
+        .p2align 2
+        .type    __progname,@object
+        .size    __progname,4
+__progname:
+        .long .LC0
+        .align  4
+___fpucw:
+        .long   0x1332
+
+        .globl  ___fpc_brk_addr         /* heap management */
+        .type   ___fpc_brk_addr,@object
+        .size   ___fpc_brk_addr,4
+___fpc_brk_addr:
+        .long   0
+
+
+.text
+        .p2align 2
+.globl _start
+        .type    _start,@function
+_start:
+        pushl %ebp
+        movl %esp,%ebp
+        pushl %edi
+        pushl %esi
+        pushl %ebx
+#APP
+        movl %edx,%edx
+#NO_APP
+        leal 8(%ebp),%edi
+        movl %edi,U_SYSLINUX_ARGV
+        mov -4(%edi),%eax
+        movl %eax,U_SYSLINUX_ARGC
+        movl 4(%ebp),%ebx
+        leal 12(%ebp,%ebx,4),%esi
+        movl %esi,U_SYSLINUX_ENVP
+        movl %esi,environ
+        testl %ebx,%ebx
+        jle .L2
+        movl 8(%ebp),%eax
+        testl %eax,%eax
+        je .L2
+        movl %eax,__progname
+        cmpb $0,(%eax)
+        je .L2
+        .p2align 2,0x90
+.L6:
+        cmpb $47,(%eax)
+        jne .L5
+        leal 1(%eax),%ecx
+        movl %ecx,__progname
+.L5:
+        incl %eax
+        cmpb $0,(%eax)
+        jne .L6
+.L2:
+.L9:
+
+# copied from linux
+
+        finit                           /* initialize fpu */
+        fwait
+        fldcw   ___fpucw
+
+        xorl    %ebp,%ebp
+
+        call main
+        pushl %eax
+        jmp   _haltproc
+        
+.p2align 2,0x90
+.globl _haltproc
+.type _haltproc,@function
+
+_haltproc:
+           mov $1,%eax  
+           movzwl U_SYSLINUX_EXITCODE,%ebx
+           pushl %ebx
+           call _actualsyscall
+           addl  $4,%esp
+           jmp   _haltproc
+
+_actualsyscall:
+         int $0x80
+         jb .LErrorcode
+         xor %ebx,%ebx
+         ret
+.LErrorcode:
+         mov %eax,%ebx
+         mov $-1,%eax
+         ret
+        .p2align 2,0x90
+.Lfe1:
+        .size    _start,.Lfe1-_start
+        .comm   environ,4,4
+        .weak   _DYNAMIC
+        .ident  "GCC: (GNU) 2.7.2.1"

+ 167 - 0
rtl/bsd/signal.inc

@@ -0,0 +1,167 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Jonas Maebe,
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+Const   { For sending a signal }
+
+  SA_NOCLDSTOP = 8;
+  SA_ONSTACK   = $001; { take signal on signal stack }
+  SA_RESTART   = $002; { restart system call on signal return }
+  SA_RESETHAND = $004; { reset to SIG_DFL when taking signal }
+  SA_NODEFER   = $010; { don't mask the signal we're delivering }
+  SA_NOCLDWAIT = $020; { don't keep zombies around }
+  SA_SIGINFO   = $040; { signal handler with SA_SIGINFO args }
+  SA_USERTRAMP = $100; { SUNOS compat: Do not bounce off kernel's sigtramp }
+
+  SIG_BLOCK   = 1;
+  SIG_UNBLOCK = 2;
+  SIG_SETMASK = 3;
+
+{BSD Checked}
+  SIG_DFL = 0 ;
+  SIG_IGN = 1 ;
+  SIG_ERR = -1 ;
+
+  SIGHUP     = 1;
+  SIGINT     = 2;
+  SIGQUIT    = 3;
+  SIGILL     = 4;
+  SIGTRAP    = 5;
+  SIGABRT    = 6;
+  SIGIOT     = 6;
+  SIGEMT     = 7;
+  SIGFPE     = 8;
+  SIGKILL    = 9;
+  SIGBUS     = 10;
+  SIGSEGV    = 11;
+  SIGSYS     = 12;
+  SIGPIPE    = 13;
+  SIGALRM    = 14;
+  SIGTERM    = 15;
+  SIGURG     = 16;
+  SIGSTOP    = 17;
+  SIGTSTP    = 18;
+  SIGCONT    = 19;
+  SIGCHLD   = 20;
+  SIGTTIN    = 21;
+  SIGTTOU    = 22;
+  SIGIO      = 23;
+  SIGXCPU    = 24;
+  SIGXFSZ    = 25;
+  SIGVTALRM  = 26;
+  SIGPROF    = 27;
+  SIGWINCH   = 28;
+  SIGINFO    = 29;
+  SIGUSR1    = 30;
+  SIGUSR2    = 31;
+
+
+{$packrecords C}
+const
+  SI_PAD_SIZE   = ((128/sizeof(longint)) - 3);
+
+{
+ * The sequence of the fields/registers in struct sigcontext should match
+ * those in mcontext_t.
+ }
+
+type sigset_t = cardinal;
+
+    PSigContextRec = ^SigContextRec;
+    SigContextRec = record
+       sc_mask      : sigset_t;          { signal mask to restore }
+       sc_onstack   : longint;              { sigstack state to restore }
+
+       sc_gs        : longint;              { machine state (struct trapframe): }
+       sc_fs        : longint;
+       sc_es        : longint;
+       sc_ds        : longint;
+       sc_edi       : longint;
+       sc_esi       : longint;
+       sc_ebp       : longint;
+       sc_isp       : longint;
+       sc_ebx       : longint;
+       sc_edx       : longint;
+       sc_ecx       : longint;
+       sc_eax       : longint;
+       sc_trapno    : longint;
+       sc_err       : longint;
+       sc_eip       : longint;
+       sc_cs        : longint;
+       sc_efl       : longint;
+       sc_esp       : longint;
+       sc_ss        : longint;
+        {
+         * XXX FPU state is 27 * 4 bytes h/w, 1 * 4 bytes s/w (probably not
+         * needed here), or that + 16 * 4 bytes for emulators (probably all
+         * needed here).  The "spare" bytes are mostly not spare.
+         }
+       en_cw        : cardinal;     { control word (16bits used) }
+       en_sw        : cardinal;     { status word (16bits) }
+       en_tw        : cardinal;     { tag word (16bits) }
+       en_fip       : cardinal;     { floating point instruction pointer }
+       en_fcs       : word;         { floating code segment selector }
+       en_opcode    : word;         { opcode last executed (11 bits ) }
+       en_foo       : cardinal;     { floating operand offset }
+       en_fos       : cardinal;     { floating operand segment selector }
+       fpr_acc      : array[0..79] of char;
+       fpr_ex_sw    : cardinal;
+       fpr_pad      : array[0..63] of char;
+       end;
+
+  SignalHandler   = Procedure(Sig : Longint);cdecl;
+  PSignalHandler  = ^SignalHandler;
+  SignalRestorer  = Procedure;cdecl;
+  PSignalRestorer = ^SignalRestorer;
+  TSigAction = procedure(Sig: Longint; SigContext: SigContextRec;someptr:pointer);cdecl;
+
+  Sigset=sigset_t;
+  PSigSet = ^SigSet;
+
+  SigActionRec = packed record
+    Handler  : record
+      case byte of
+        0: (Sh: SignalHandler);
+        1: (Sa: TSigAction);
+      end;
+    Sa_Flags    : Longint;
+    Sa_Mask     : SigSet;
+  end;
+  PSigActionRec = ^SigActionRec;
+
+{
+  Change action of process upon receipt of a signal.
+  Signum specifies the signal (all except SigKill and SigStop).
+  If Act is non-nil, it is used to specify the new action.
+  If OldAct is non-nil the previous action is saved there.
+}
+
+
+{
+  $Log$
+  Revision 1.2  2000-09-11 14:38:10  marco
+   * 14 april version killed, and replaced by newer fixes branch version
+
+  Revision 1.1.2.1  2000/09/10 16:18:41  marco
+  initial version
+
+  Revision 1.2  2000/03/31 23:11:23  pierre
+   * TSigAction Context param is the full record not a pointer
+
+  Revision 1.1  2000/03/31 13:24:28  jonas
+    * signal handling using sigaction when compiled with -dnewsignal
+      (allows multiple signals to be received in one run)
+
+}

+ 511 - 0
rtl/bsd/syscalls.inc

@@ -0,0 +1,511 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{BSD version of the syscalls required to implement SysLinux.}
+
+{No debugging for syslinux include !}
+{$IFDEF SYS_LINUX}
+  {$UNDEF SYSCALL_DEBUG}
+{$ENDIF SYS_LINUX}
+
+{*****************************************************************************
+                     --- Main:The System Call Self ---
+*****************************************************************************}
+
+{ The system designed for Linux can't be used for FreeBSD so easily, since
+  FreeBSD pushes arguments, instead of loading them to registers.
+
+For now I do them in assembler, which makes it easier to test them (copy and
+paste to and AS source). Ultimately I hope to design something like this}
+
+{actualsyscall:
+  _actualsyscall : int $0x80
+                   jb someerror
+                   ret
+      someerror:   storeerrorsomewhere
+                   ret
+}
+
+{
+procedure actualsyscall; cdecl; EXTERNAL NAME '_actualsyscall';
+}
+
+procedure actualsyscall; assembler;
+    asm
+         int $0x80
+         jb .LErrorcode
+         xor %ebx,%ebx
+         ret
+.LErrorcode:
+	 mov %eax,%ebx
+         mov $-1,%eax
+   end;
+
+
+function Do_SysCall(sysnr:LONGINT):longint; assembler;
+
+asm
+  movl  sysnr,%eax
+  call  actualsyscall
+  movw  %bx,Errno
+end;
+
+function Do_SysCall(sysnr,param1:longint):longint; assembler;
+
+ asm
+  movl  sysnr,%eax
+  pushl Param1
+  call  actualsyscall
+  addl  $4,%esp
+  movw  %bx,Errno
+ end;
+
+function Do_SysCall(sysnr,param1:integer):longint; assembler;
+
+ asm
+  movl  sysnr,%eax
+  pushw Param1
+  call  actualsyscall
+  addw  $2,%esp
+  movw  %bx,Errno
+ end;
+
+
+function Do_SysCall(sysnr,param1,param2:LONGINT):longint; assembler;
+
+ asm
+   movl  sysnr,%eax
+   pushl param2
+   pushl Param1
+   call  actualsyscall
+   addl  $8,%esp
+   movw  %bx,Errno
+ end;
+
+function Do_SysCall(sysnr,param1,param2,param3:LONGINT):longint; assembler;
+
+ asm
+   movl  sysnr,%eax
+   pushl param3
+   pushl param2
+   pushl Param1
+   call  actualsyscall
+   addl  $12,%esp
+   movw  %bx,Errno
+ end;
+
+function Do_SysCall(sysnr,param1,param2,param3,param4:LONGINT):longint; assembler;
+
+asm
+   movl  sysnr,%eax
+   pushl param4
+   pushl param3
+   pushl param2
+   pushl Param1
+   call  actualsyscall
+   addl  $16,%esp
+   movw  %bx,Errno
+end;
+
+
+function Do_SysCall(sysnr,param1,param2,param3,param4,param5:LONGINT):longint;  assembler;
+
+ asm
+   movl  sysnr,%eax
+   pushl param5
+   pushl param4
+   pushl param3
+   pushl param2
+   pushl Param1
+   call  actualsyscall
+   addl  $20,%esp
+   movw  %bx,Errno
+ end;
+
+function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6:LONGINT):longint;  assembler;
+
+asm
+   movl  sysnr,%eax
+   pushl param6
+   pushl param5
+   pushl param4
+   pushl param3
+   pushl param2
+   pushl Param1
+   call  actualsyscall
+   addl  $24,%esp
+   movw  %bx,Errno
+end;
+
+
+function Do_SysCall(sysnr,param1,param2,param3,param4,param5,param6,param7:LONGINT):longint;  assembler;
+
+asm
+   movl  sysnr,%eax
+   pushl param7
+   pushl param6
+   pushl param5
+   pushl param4
+   pushl param3
+   pushl param2
+   pushl Param1
+   call  actualsyscall
+   addl  $28,%esp
+   movw  %bx,Errno
+end;
+
+Function Sys_Time:longint;
+
+VAR tv     : timeval;
+    tz     : timezone;
+    retval : longint;
+
+begin
+  Retval:=do_syscall(116,longint(@tv),longint(@tz));
+  If retval=-1 then
+   sys_time:=-1
+  else
+   sys_time:=tv.sec;
+end;
+
+{*****************************************************************************
+               --- File:File handling related calls ---
+*****************************************************************************}
+
+
+Function Sys_Open(f:pchar;flags:longint;mode:integer):longint;
+
+Begin
+ sys_open:=do_syscall(syscall_nr_open,longint(f),flags,mode);
+End;
+
+Function Sys_Close(f:longint):longint;
+
+begin
+ sys_close:=do_syscall(syscall_nr_close,f);
+end;
+
+{
+Function Sys_Lseek(F:longint;Off:longint;Whence:longint):longint;
+
+var returnvalue64 : array[0..1] of longint;
+
+begin
+ {Lseek's offset is 64-bit, the highword  is the 0}
+ do_syscall(syscall_nr_lseek,longint(@returnvalue64),F,Off,0,Whence);
+ sys_lseek:=returnvalue64[0];
+end;
+
+}
+
+Function Sys_Lseek(F:longint;Off:longint;Whence:longint):longint; assembler;
+
+{this one is special for the return value being 64-bit..}
+
+ asm
+  pushl Whence
+  pushl $0      // high dword
+  pushl Off
+  pushl $0
+  pushl F
+  pushl $0      // Your guess is as good as mine.
+  pushl $0xc7   // Actual lseek syscall number.
+  movl  $0xc6,%eax
+  call  actualsyscall
+  addl  $28,%esp
+  mov   %ebx,Errno
+ end;
+
+Function Sys_Read(f:longint;buffer:pchar;count:longint):longint;
+
+begin
+  sys_read:=do_syscall(syscall_nr_read,F,longint(buffer),count);
+end;
+
+Function Sys_Write(f:longint;buffer:pchar;count:longint):longint;
+
+begin
+ sys_write:=do_syscall(syscall_nr_write,F,longint(buffer),count);
+end;
+
+Function Sys_Unlink(Filename:pchar):longint;
+
+begin
+  sys_unlink:=do_syscall(syscall_nr_unlink,longint(Filename));
+end;
+
+Function Sys_Rename(Oldname,Newname:pchar):longint;
+
+begin
+  sys_rename:=do_syscall(syscall_nr_rename,longint(oldname),longint(newname));
+end;
+
+Function Sys_Stat(Filename:pchar;var Buffer: stat):longint;
+{
+   We need this for getcwd
+}
+
+begin
+ sys_stat:=do_syscall(syscall_nr_stat,longint(filename),longint(@buffer));
+end;
+
+Function Sys_Symlink(oldname,newname:pchar):longint;
+{
+  We need this for erase
+}
+
+begin
+ sys_symlink:=do_syscall(syscall_nr_symlink,longint(oldname),longint(newname));
+end;
+
+
+Function Sys_ReadLink(name,linkname:pchar;maxlen:longint):longint;
+
+begin
+  sys_readlink:=do_syscall(syscall_nr_readlink, longint(name),longint(linkname),maxlen);
+end;
+
+
+
+{*****************************************************************************
+               --- Directory:Directory related calls ---
+*****************************************************************************}
+
+Function Sys_Chdir(Filename:pchar):longint;
+
+begin
+ sys_chdir:=do_syscall(syscall_nr_chdir,longint(filename));
+end;
+
+Function Sys_Mkdir(Filename:pchar;mode:longint):longint;
+
+begin {Mode is 16-bit on F-BSD}
+  sys_mkdir:=do_syscall(syscall_nr_mkdir,longint(filename),mode shl 8);
+end;
+
+Function Sys_Rmdir(Filename:pchar):longint;
+
+begin
+ sys_rmdir:=do_syscall(syscall_nr_rmdir,longint(filename));
+end;
+
+
+const DIRBLKSIZ=1024;
+
+
+{ we need this for getcwd, NOT touched for BSD version }
+Function OpenDir(f:pchar):pdir;
+
+var
+  fd:longint;
+  st:stat;
+  ptr:pdir;
+begin
+  opendir:=nil;
+  if sys_stat(f,st)<0 then
+   exit;
+{ Is it a dir ? }
+  if not((st.mode and $f000)=$4000)then
+   begin
+     errno:=sys_enotdir;
+     exit
+   end;
+{ Open it}
+  fd:=sys_open(f,OPEN_RDONLY,438);
+  if fd<0 then
+   exit;
+  new(ptr);
+  if ptr=nil then
+   exit;
+  Getmem(ptr^.buf,2*DIRBLKSIZ);
+  if ptr^.buf=nil then
+   exit;
+  ptr^.fd:=fd;
+  ptr^.loc:=-1;
+  ptr^.rewind:=longint(ptr^.buf);
+  ptr^.size:=0;
+//  ptr^.dd_max:=sizeof(ptr^.buf^);
+  opendir:=ptr;
+end;
+
+function CloseDir(p:pdir):integer;
+begin
+  closedir:=sys_close(p^.fd);
+  Freemem(p^.buf);
+  dispose(p);
+end;
+
+
+Function Sys_ReadDir(p:pdir):pdirent;
+{Different from Linux, Readdir on BSD is based on Getdents, due to the
+missing of the readdir syscall.
+Getdents requires the buffer to be larger than the blocksize.
+This usually the sectorsize =512 bytes, but maybe tapedrives and harddisks
+with blockmode have this higher?}
+
+function readbuffer:longint;
+
+var retval :longint;
+
+begin
+   retval:=do_syscall(syscall_nr_getdents,longint(p^.fd),longint(@p^.buf^),DIRBLKSIZ {sizeof(getdentsbuffer)});
+   p^.rewind:=longint(p^.buf);
+   if retval=0 then
+    begin
+     p^.rewind:=0;
+     p^.loc:=0;
+    end
+   else
+    P^.loc:=retval;
+ readbuffer:=retval;
+end;
+
+var
+    l              : pdirent;
+    novalid        : boolean;
+
+begin
+ if (p^.buf=nil) or (p^.loc=0) THEN
+  exit(nil);
+ if p^.loc=-1 then         {First readdir on this pdir. Initial fill of buffer}
+  begin
+   if readbuffer()=0 Then    {nothing to be read}
+    exit(nil)
+  end;
+ l:=nil;
+ repeat
+  novalid:=false;
+  if (pdirent(p^.rewind)^.reclen<>0) then
+   begin {valid direntry?}
+    if pdirent(P^.rewind)^.ino<>0 then
+     l:=pdirent(p^.rewind);       
+    inc(p^.rewind,pdirent(p^.rewind)^.reclen);
+    if p^.rewind>=(longint(p^.buf)+dirblksiz) then
+     novalid:=true;
+   end
+  else
+   novalid:=true;
+  if novalid then
+   begin {block entirely searched or reclen=0}
+    if p^.loc<>0 THEN             {blocks left?}
+     if readbuffer()<>0 then        {succesful read?}
+      novalid:=false;
+   end;
+ until (l<>nil) or novalid;
+ Sys_ReadDir:=l;
+end;
+
+
+{*****************************************************************************
+        --- Process:Process & program handling - related calls ---
+*****************************************************************************}
+
+
+Function sys_GetPid:LongInt;
+{
+  Get Process ID.
+}
+
+begin
+ sys_GetPID:=do_syscall(syscall_nr_getpid);
+end;
+
+Procedure Sys_Exit(ExitCode:longint);
+
+begin
+  do_syscall(syscall_nr_exit,exitcode);
+end;
+
+{
+  Change action of process upon receipt of a signal.
+  Signum specifies the signal (all except SigKill and SigStop).
+  If Act is non-nil, it is used to specify the new action.
+  If OldAct is non-nil the previous action is saved there.
+}
+
+
+
+Procedure SigAction(Signum:longint;Act,OldAct:PSigActionRec );
+{
+  Change action of process upon receipt of a signal.
+  Signum specifies the signal (all except SigKill and SigStop).
+  If Act is non-nil, it is used to specify the new action.
+  If OldAct is non-nil the previous action is saved there.
+}
+
+begin
+  do_syscall(syscall_nr_sigaction,longint(signum),longint(act),longint(oldact));
+ {$ifdef linuxunit}
+  LinuxError:=Errno;
+ {$endif}
+end;
+
+
+{
+  $Log$
+  Revision 1.4  2000-09-11 14:38:10  marco
+   * 14 april version killed, and replaced by newer fixes branch version
+
+  Revision 1.1.2.1  2000/09/10 16:12:14  marco
+  Initial signals, sockets and clone
+
+  Revision 1.1  2000/07/13 06:30:32  michael
+  + Initial import
+
+  Revision 1.15  2000/04/16 16:08:53  marco
+   * Fixes (mainly opendir/Readdir/closedir)
+
+  Revision 1.14  2000/04/14 17:04:13  marco
+   * Working!
+
+  Revision 1.13  2000/04/10 15:46:52  marco
+   * worked all day. probably a lot changed
+
+  Revision 1.11  2000/04/05 13:58:40  marco
+   * syscall variablenames reintroduced.
+
+  Revision 1.10  2000/03/16 16:18:12  marco
+   * Last changes before next test. ppc386 -h works with these srcs.
+
+  Revision 1.9  2000/03/02 15:34:07  marco
+   * added a syscall for 5 longints
+
+  Revision 1.8  2000/03/01 20:03:57  marco
+   * small fixes for syslinux
+
+  Revision 1.7  2000/03/01 17:28:40  marco
+   * some changes due to updating linux.pp to new syscall
+
+  Revision 1.6  2000/02/27 23:45:39  marco
+   * Redone the syscalls
+
+  Revision 1.5  2000/02/04 16:53:26  marco
+   * Finished Linux (and rest syscalls) roughly. Some things still need to be
+    tested, and checked (off_t calls specially)
+
+  Revision 1.4  2000/02/03 17:04:47  marco
+   * additions fixes due to port linux
+
+  Revision 1.3  2000/02/02 18:07:27  marco
+   * Ported except for readdir which is 200 lines C code in FBSD linux
+        emulator
+
+  Revision 1.2  2000/02/02 16:35:10  marco
+   * Ported more functions. Half done now.
+
+  Revision 1.1  2000/02/02 15:41:56  marco
+   * Initial BSD version. Still needs a lot of work.
+
+}

+ 119 - 0
rtl/bsd/sysconst.inc

@@ -0,0 +1,119 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+{BSD version, only the blocks with BSD in the comment are updated}
+
+Const
+  { Things for LSEEK call, same in linux and BSD }
+  Seek_set = 0;
+  Seek_Cur = 1;
+  Seek_End = 2;
+  { Things for OPEN call - after include/sys/fcntl.h, BSD updated.
+   BSD specifies these constants in hex }
+  Open_Accmode  = 3;
+  Open_RdOnly   = 0;
+  Open_WrOnly   = 1;
+  Open_RdWr     = 2;
+  Open_NonBlock = 4;
+  Open_Append   = 8;
+  Open_ShLock   = $10;
+  Open_ExLock   = $20;
+  Open_ASync    = $40;
+  Open_FSync    = $80;
+  Open_NoFollow = $100;
+  Open_Create   = $200;       {BSD convention}
+  Open_Creat    = $200;       {Linux convention}
+  Open_Trunc    = $400;
+  Open_Excl     = $800;
+
+
+  { The waitpid uses the following options:}
+  Wait_NoHang   = 1;
+  Wait_UnTraced = 2;
+  Wait_Any      = -1; 
+  Wait_MyPGRP   = 0;  
+  { Constants to check stat.mode -  checked all STAT constants with BSD}
+  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 all }
+  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;
+
+  { Constants to test the type of filesystem }
+  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;
+
+{
+  $Log$
+  Revision 1.4  2000-09-11 14:38:10  marco
+   * 14 april version killed, and replaced by newer fixes branch version
+
+  Revision 1.1  2000/07/13 06:30:33  michael
+  + Initial import
+
+  Revision 1.5  2000/04/10 15:46:52  marco
+   * worked all day. probably a lot changed
+
+  Revision 1.3  2000/02/03 17:05:13  marco
+   * fixes and updates due to linux unit porting
+
+  Revision 1.2  2000/02/02 16:35:29  marco
+   * Checked stat constants
+
+  Revision 1.1  2000/02/02 15:41:28  marco
+   * initial BSD version.
+
+  Revision 1.4  2000/01/07 16:41:41  daniel
+    * copyright 2000
+
+  Revision 1.3  2000/01/07 16:32:28  daniel
+    * copyright 2000 added
+
+  Revision 1.2  1998/05/06 12:38:22  michael
+  + Removed log from before restored version.
+
+  Revision 1.1.1.1  1998/03/25 11:18:43  root
+  * Restored version
+}

+ 345 - 0
rtl/bsd/sysnr.inc

@@ -0,0 +1,345 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+const
+{ Crude converted FreeBSD  4.0-release syscall.h. Copy and paste if you
+ checked the function.
+ syscall_nr_syscall                     =  0;
+ syscall_nr_exit                        =  1;
+ syscall_nr_fork                        =  2;
+ syscall_nr_read                        =  3;
+ syscall_nr_write                       =  4;
+ syscall_nr_open                        =  5;
+ syscall_nr_close                       =  6;
+ syscall_nr_wait4                       =  7;
+ syscall_nr_link                        =  9;
+ syscall_nr_unlink                      = 10;
+ syscall_nr_chdir                       = 12;
+ syscall_nr_fchdir                      = 13;
+ syscall_nr_mknod                       = 14;
+ syscall_nr_chmod                       = 15;
+ syscall_nr_chown                       = 16;
+ syscall_nr_break                       = 17;
+ syscall_nr_getfsstat                   = 18;
+ syscall_nr_getpid                      = 20;
+ syscall_nr_mount                       = 21;
+ syscall_nr_unmount                     = 22;
+ syscall_nr_setuid                      = 23;
+ syscall_nr_getuid                      = 24;
+ syscall_nr_geteuid                     = 25;
+ syscall_nr_ptrace                      = 26;
+ syscall_nr_recvmsg                     = 27;
+ syscall_nr_sendmsg                     = 28;
+ syscall_nr_getpeername                 = 31;
+ syscall_nr_getsockname                 = 32;
+ syscall_nr_access                      = 33;
+ syscall_nr_chflags                     = 34;
+ syscall_nr_fchflags                    = 35;
+ syscall_nr_sync                        = 36;
+ syscall_nr_kill                        = 37;
+ syscall_nr_getppid                     = 39;
+ syscall_nr_dup                         = 41;
+ syscall_nr_pipe                        = 42;
+ syscall_nr_getegid                     = 43;
+ syscall_nr_profil                      = 44;
+ syscall_nr_ktrace                      = 45;
+ syscall_nr_getgid                      = 47;
+ syscall_nr_getlogin                    = 49;
+ syscall_nr_setlogin                    = 50;
+ syscall_nr_acct                        = 51;
+ syscall_nr_sigaltstack                 = 53;
+ syscall_nr_ioctl                       = 54;
+ syscall_nr_reboot                      = 55;
+ syscall_nr_revoke                      = 56;
+ syscall_nr_symlink                     = 57;
+ syscall_nr_readlink                    = 58;
+ syscall_nr_execve                      = 59;
+ syscall_nr_umask                       = 60;
+ syscall_nr_chroot                      = 61;
+ syscall_nr_msync                       = 65;
+ syscall_nr_vfork                       = 66;
+ syscall_nr_sbrk                        = 69;
+ syscall_nr_sstk                        = 70;
+ syscall_nr_vadvise                     = 72;
+ syscall_nr_mprotect                    = 74;
+ syscall_nr_madvise                     = 75;
+ syscall_nr_mincore                     = 78;
+ syscall_nr_getgroups                   = 79;
+ syscall_nr_setgroups                   = 80;
+ syscall_nr_getpgrp                     = 81;
+ syscall_nr_setpgid                     = 82;
+ syscall_nr_setitimer                   = 83;
+ syscall_nr_swapon                      = 85;
+ syscall_nr_getitimer                   = 86;
+ syscall_nr_getdtablesize               = 89;
+ syscall_nr_dup2                        = 90;
+ syscall_nr_fcntl                       = 92;
+ syscall_nr_select                      = 93;
+ syscall_nr_fsync                       = 95;
+ syscall_nr_setpriority                 = 96;
+ syscall_nr_connect                     = 98;
+ syscall_nr_getpriority                 =100;
+ syscall_nr_setsockopt                  =105;
+ syscall_nr_gettimeofday                =116;
+ syscall_nr_getrusage                   =117;
+ syscall_nr_readv                       =120;
+ syscall_nr_writev                      =121;
+ syscall_nr_settimeofday                =122;
+ syscall_nr_fchown                      =123;
+ syscall_nr_fchmod                      =124;
+ syscall_nr_setreuid                    =126;
+ syscall_nr_setregid                    =127;
+ syscall_nr_rename                      =128;
+ syscall_nr_flock                       =131;
+ syscall_nr_mkfifo                      =132;
+ syscall_nr_mkdir                       =136;
+ syscall_nr_rmdir                       =137;
+ syscall_nr_utimes                      =138;
+ syscall_nr_adjtime                     =140;
+ syscall_nr_setsid                      =147;
+ syscall_nr_quotactl                    =148;
+ syscall_nr_nfssvc                      =155;
+ syscall_nr_statfs                      =157;
+ syscall_nr_fstatfs                     =158;
+ syscall_nr_getfh                       =161;
+ syscall_nr_getdomainname               =162;
+ syscall_nr_setdomainname               =163;
+ syscall_nr_uname                       =164;
+ syscall_nr_sysarch                     =165;
+ syscall_nr_rtprio                      =166;
+ syscall_nr_semsys                      =169;
+ syscall_nr_msgsys                      =170;
+ syscall_nr_shmsys                      =171;
+ syscall_nr_pread                       =173;
+ syscall_nr_pwrite                      =174;
+ syscall_nr_ntp_adjtime                 =176;
+ syscall_nr_setgid                      =181;
+ syscall_nr_setegid                     =182;
+ syscall_nr_seteuid                     =183;
+ syscall_nr_stat                        =188;
+ syscall_nr_fstat                       =189;
+ syscall_nr_lstat                       =190;
+ syscall_nr_pathconf                    =191;
+ syscall_nr_fpathconf                   =192;
+ syscall_nr_getrlimit                   =194;
+ syscall_nr_setrlimit                   =195;
+syscall_nr_getdirentries                =196;
+ syscall_nr_mmap                        =197;
+ syscall_nr___syscall                   =198;
+ syscall_nr_lseek                       =199;
+ syscall_nr_truncate                    =200;
+ syscall_nr_ftruncate                   =201;
+ syscall_nr___sysctl                    =202;
+ syscall_nr_mlock                       =203;
+ syscall_nr_munlock                     =204;
+ syscall_nr_undelete                    =205;
+ syscall_nr_futimes                     =206;
+ syscall_nr_getpgid                     =207;
+ syscall_nr_poll                        =209;
+ syscall_nr___semctl                    =220;
+ syscall_nr_semget                      =221;
+ syscall_nr_semop                       =222;
+ syscall_nr_semconfig                   =223;
+ syscall_nr_msgctl                      =224;
+ syscall_nr_msgget                      =225;
+ syscall_nr_msgsnd                      =226;
+ syscall_nr_msgrcv                      =227;
+ syscall_nr_shmat                       =228;
+ syscall_nr_shmctl                      =229;
+ syscall_nr_shmdt                       =230;
+ syscall_nr_shmget                      =231;
+ syscall_nr_clock_gettime               =232;
+ syscall_nr_clock_settime               =233;
+ syscall_nr_clock_getres                =234;
+ syscall_nr_nanosleep                   =240;
+ syscall_nr_minherit                    =250;
+ syscall_nr_openbsd_poll                =252;
+ syscall_nr_issetugid                   =253;
+ syscall_nr_lchown                      =254;
+ syscall_nr_getdents                    =272;
+ syscall_nr_lchmod                      =274;
+ syscall_nr_netbsd_lchown               =275;
+ syscall_nr_lutimes                     =276;
+ syscall_nr_netbsd_msync                =277;
+ syscall_nr_nstat                       =278;
+ syscall_nr_nfstat                      =279;
+ syscall_nr_nlstat                      =280;
+ syscall_nr_fhstatfs                    =297;
+ syscall_nr_fhopen                      =298;
+ syscall_nr_fhstat                      =299;
+ syscall_nr_modnext                     =300;
+ syscall_nr_modstat                     =301;
+ syscall_nr_modfnext                    =302;
+ syscall_nr_modfind                     =303;
+ 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_getsid                      =310;
+ syscall_nr_setresuid                   =311;
+ syscall_nr_setresgid                   =312;
+ syscall_nr_aio_return                  =314;
+ syscall_nr_aio_suspend                 =315;
+ syscall_nr_aio_cancel                  =316;
+ syscall_nr_aio_error                   =317;
+ syscall_nr_aio_read                    =318;
+ syscall_nr_aio_write                   =319;
+ syscall_nr_lio_listio                  =320;
+ syscall_nr_yield                       =321;
+ syscall_nr_thr_sleep                   =322;
+ syscall_nr_thr_wakeup                  =323;
+ syscall_nr_mlockall                    =324;
+ syscall_nr_munlockall                  =325;
+ syscall_nr___getcwd                    =326;
+ syscall_nr_sched_setparam              =327;
+ syscall_nr_sched_getparam              =328;
+ syscall_nr_sched_setscheduler          =329;
+ syscall_nr_sched_getscheduler          =330;
+ syscall_nr_sched_yield                 =331;
+ syscall_nr_sched_get_priority_max      =332;
+ syscall_nr_sched_get_priority_min      =333;
+ syscall_nr_sched_rr_get_interval       =334;
+ syscall_nr_utrace                      =335;
+ syscall_nr_sendfile                    =336;
+ syscall_nr_kldsym                      =337;
+ syscall_nr_jail                        =338;
+ syscall_nr_sigprocmask                 =340;
+ syscall_nr_sigsuspend                  =341;
+ syscall_nr_sigaction                   =342;
+ syscall_nr_sigpending                  =343;
+ syscall_nr_sigreturn                   =344;
+ syscall_nr___acl_get_file              =347;
+ syscall_nr___acl_set_file              =348;
+ syscall_nr___acl_get_fd                =349;
+ syscall_nr___acl_set_fd                =350;
+ syscall_nr___acl_delete_file           =351;
+ syscall_nr___acl_delete_fd             =352;
+ syscall_nr___acl_aclcheck_file         =353;
+ syscall_nr___acl_aclcheck_fd           =354;
+ syscall_nr_extattrctl                  =355;
+ syscall_nr_extattr_set_file            =356;
+ syscall_nr_extattr_get_file            =357;
+ syscall_nr_extattr_delete_file         =358;
+ syscall_nr_aio_waitcomplete            =359;
+ syscall_nr_getresuid                   =360;
+ syscall_nr_getresgid                   =361;
+ syscall_nr_MAXSYSCALL                  =362;
+
+}
+
+{More or less checked BSD syscalls}
+
+ syscall_nr_accept                      =  30;
+ syscall_nr_access                      =  33;
+ syscall_nr_bind                        = 104;
+ syscall_nr_chdir                       =  12;
+ syscall_nr_chmod                       =  15;
+ syscall_nr_chown                       =  16;
+ syscall_nr_close                       =   6;
+ syscall_nr_connect                     =  98;
+ syscall_nr_dup                         =  41;
+ syscall_nr_dup2                        =  90;
+ syscall_nr_execve                      =  59;
+ syscall_nr_exit                        =   1;
+ syscall_nr_fcntl                       =  92;
+ syscall_nr_flock                       = 131;
+ syscall_nr_fork                        =   2;
+ syscall_nr_fstat                       = 189;
+ syscall_nr_fstatfs                     = 158;
+ syscall_nr_fsync                       =  95;
+ syscall_nr_ftruncate                   = 201;
+ syscall_nr_getdents                    = 272;
+ syscall_nr_getegid                     =  43;
+ syscall_nr_geteuid                     =  25;
+ syscall_nr_getgid                      =  47;
+ syscall_nr_getpeername                 =  31;
+ syscall_nr_getpid                      =  20;
+ syscall_nr_getppid                     =  39;
+ syscall_nr_getpriority                 = 100;
+ syscall_nr_getsockname                 =  32;
+ syscall_nr_gettimeofday                = 116;
+ syscall_nr_getuid                      =  24;
+ syscall_nr_ioctl                       =  54;
+ syscall_nr_kill                        =  37;
+ syscall_nr_link                        =   9;
+ syscall_nr_listen                      = 106;
+ syscall_nr_lseek                       = 199;
+ syscall_nr_lstat                       = 190;
+ syscall_nr_mkdir                       = 136;
+ syscall_nr_mknod                       =  14;
+ syscall_nr_mmap                        = 197;
+ syscall_nr_open                        =   5;
+ syscall_nr_pipe                        =  42;
+ syscall_nr_read                        =   3;
+ syscall_nr_readlink                    =  58;
+ syscall_nr_recvfrom                    =  29;
+ syscall_nr_rename                      = 128;
+ syscall_nr_rmdir                       = 137;
+ syscall_nr_select                      =  93;
+ syscall_nr_sendto                      = 133;
+ syscall_nr_setpriority                 =  96;
+ syscall_nr_setsockopt                  = 105;
+ syscall_nr_shutdown                    = 134;
+ syscall_nr_sigaction                   = 342;
+ syscall_nr_sigpending                  = 343;
+ syscall_nr_sigprocmask                 = 340;
+ syscall_nr_sigsuspend                  = 341;
+ syscall_nr_socket                      =  97;
+ syscall_nr_socketpair                  = 135;
+ syscall_nr_stat                        = 188;
+ syscall_nr_statfs                      = 157;
+ syscall_nr_symlink                     =  57;
+ syscall_nr_umask                       =  60;
+ syscall_nr_unlink                      =  10;
+ syscall_nr_utimes                      = 138;
+ syscall_nr_waitpid                     =   7;
+ syscall_nr_write                       =   4;
+ syscall_nr_munmap                      = 73;
+ syscall_nr_getsockopt                  =118;
+ syscall_nr_rfork                       =251;
+
+
+{
+  $Log$
+  Revision 1.4  2000-09-11 14:38:10  marco
+   * 14 april version killed, and replaced by newer fixes branch version
+
+  Revision 1.1.2.1  2000/09/10 16:12:14  marco
+  Initial signals, sockets and clone
+
+  Revision 1.1  2000/07/13 06:30:33  michael
+  + Initial import
+
+  Revision 1.4  2000/04/10 15:46:52  marco
+   * worked all day. probably a lot changed
+
+  Revision 1.2  2000/04/05 13:59:10  marco
+   * added constants for syscall.inc
+
+  Revision 1.1  2000/04/05 13:06:24  marco
+   * Initial version. (copied from linux.) Patch for BSD not ready yeT
+
+  Revision 1.5  2000/02/09 16:59:32  peter
+    * truncated log
+
+  Revision 1.4  2000/01/07 16:41:41  daniel
+    * copyright 2000
+
+  Revision 1.3  2000/01/07 16:32:28  daniel
+    * copyright 2000 added
+
+}

+ 186 - 0
rtl/bsd/systypes.inc

@@ -0,0 +1,186 @@
+{
+    $Id$
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Michael Van Canneyt,
+    member of the Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+type
+
+{
+ Linux system calls take arguments as follows :
+
+   i386/m68k:
+
+   %eax/%d0 : System call number
+   %ebx/%d1 : first argument
+   %ecx/%d2 : second argument
+   %edx/%d3 : third argumens
+   %esi/%d3 : fourth argument
+   %edi/%d4 : fifth argument
+
+  That is why we define a special type, with only these arguments
+  To make it processor independent, we don't give any system dependent
+  names, but the rather abstract reg1,reg2 etc;
+
+  SysCallRegs=record
+    reg1,reg2,reg3,reg4,reg5,reg6 : longint;
+  end;
+  PSysCallRegs=^SysCallRegs;
+  TSysCallRegs=SysCallRegs;
+}
+{ The following are records for system calls BSD updated }
+  dirent = packed record
+    ino    : cardinal;		{ This is not inode number, but "a number
+				  unique for each file on a filesystem"}
+    reclen : word;
+    d_type,
+    namlen : byte;
+    name   : array [0..255] of char;
+  end;
+
+  pdirent =^dirent;
+  TDirEnt = dirent;
+
+    TDir= packed record {BSD libc record.}
+            fd    : longint;    { file descriptor associated with directory }
+            loc,                { offset in current buffer }
+            size  : cardinal;   { amount of data returned by getdirentries}
+            buf   : pdirent;    { data buffer, actually a pchar}
+            len   : longint;    { size of data buffer 	}
+            seek,               { magic cookie returned by getdirentries}
+            rewind: cardinal;   { magic cookie for rewinding}
+            flags : longint;    { flags for readdir }
+            end;
+
+{ Linux kernel record
+    TDir = packed record
+            fd     : longint;
+            loc    : longint;
+            size   : integer;
+            buf    : pdirent;
+   {The following are used in libc, but NOT in the linux kernel sources ??}
+            nextoff: longint;
+            dd_max : integer; {size of buf. Irrelevant, as buf is of type dirent}
+            lock   : pointer;
+            dummy  : array[0..1023] of char;
+            end;}
+
+  PDir =^TDir;
+
+{$packrecords C}
+ Stat =record {BSD version}
+        dev,                            { inode's device }
+        ino        :  cardinal;         { inode's number }
+        mode, 				{ inode protection mode }
+        nlink	   :  word;             { number of hard links }
+        uid,				{ user ID of the file's owner }
+        gid,				{ group ID of the file's group }
+        dev_t	   :  cardinal;		{ device type }
+	atime,                          { time of last access }
+	atime_nsec,         		{ nsec of last access }
+	mtime,	           		{ time of last data modification }
+	mtime_nsec,         		{ nsec of last data modification }
+	ctime,            		{ time of last file status change }
+	ctime_nsec : longint;      	{ nsec of last file status change }
+	size,           		{ file size, in bytes }
+	blocks     : Int64;		{ blocks allocated for file }
+	blksze,         		{ optimal blocksize for I/O }
+	flags,          		{ user defined flags for file }
+	filegen    : cardinal;		{ file generation number }
+	lspare	   : longint;
+	qspare     : array[0..1] of int64;
+       end;
+
+  PStat=^Stat;
+  TStat=Stat;
+
+  Statfs = packed record
+    spare2,	       { place holder}
+    bsize,	       { fundamental block size}
+    iosize,            { optimal block size }
+    blocks,            {  total blocks}
+    bfree,             { blocks free}
+    bavail,            { block available for mortal users}
+    files,	       { Total file nodes}
+    ffree	   : longint;    { file nodes free}
+    fsid	   : array[0..1] of longint;
+    fowner	   : longint; {mounter uid}
+    ftype	   : longint;
+    fflags         : longint; {copy of mount flags}
+    spare          : array [0..1] of longint; { For later use }
+    fstypename     : array[0..15] of char;
+    mountpoint     : array[0..89] of char;
+    mnfromname     : array[0..89] of char;
+  end;
+  PStatFS=^StatFS;
+  TStatFS=StatFS;
+
+  fdSet=array[0..7] of longint;{=256 bits}
+  pfdset=^fdset;
+  TFDSet=fdset;
+
+  timeval = packed record
+    sec,usec:int64;
+  end;
+  ptimeval=^timeval;
+  TTimeVal=timeval;
+
+  timezone = packed record
+    minuteswest,dsttime:longint;
+  end;
+  ptimezone =^timezone;
+  TTimeZone = timezone;
+
+  utsname = packed record
+    sysname,
+    nodename,
+    release,
+    version,
+    machine,
+    domainname : Array[0..64] of char;
+  end;
+  PUTSName=^UTSName;
+  TUTSName=UTSName;
+
+{
+  $Log$
+  Revision 1.4  2000-09-11 14:38:10  marco
+   * 14 april version killed, and replaced by newer fixes branch version
+
+  Revision 1.1.2.1  2000/09/10 16:12:14  marco
+  Initial signals, sockets and clone
+
+  Revision 1.1  2000/07/13 06:30:33  michael
+  + Initial import
+
+  Revision 1.8  2000/04/16 16:08:30  marco
+   * Updated PDir to BSD libc layout. (which is totally different from Linux)
+
+  Revision 1.7  2000/04/10 15:46:52  marco
+   * worked all day. probably a lot changed
+
+  Revision 1.5  2000/03/17 12:58:57  marco
+   * some changes to ftruncate based procs. Added a "0" as extra parameter
+
+  Revision 1.4  2000/02/04 16:55:47  marco
+   * Fixed tdir, some params need to be 32-bit
+
+  Revision 1.3  2000/02/03 17:05:55  marco
+
+   * Some types fixed/ported.
+
+  Revision 1.2  2000/02/02 16:45:38  marco
+   * Typo in STAT record
+
+  Revision 1.1  2000/02/02 16:36:09  marco
+   * Initial version. Copy of linux version, with BSD stat.
+
+}