* Fixes to get the generic *BSD RTL compiling again + fixes for thread

support. Still problems left in fexpand. (inoutres?) Therefore fixed
   sysposix not yet commited
This commit is contained in:
marco 2002-10-18 12:19:58 +00:00
parent 0f0eedba0a
commit 38a63b01f0
8 changed files with 105 additions and 197 deletions

View File

@ -467,6 +467,11 @@ begin
Sys_mmap:=do_syscall(syscall_nr_mmap,Adr,Len,Prot,Flags,fdes,off,0); Sys_mmap:=do_syscall(syscall_nr_mmap,Adr,Len,Prot,Flags,fdes,off,0);
end; end;
Function Sys_munmap(adr:longint;len:size_t):longint; [public, alias :'FPC_SYSC_MUNMAP'];
begin
Sys_munmap:=do_syscall(syscall_nr_munmap,longint(Adr),Len);
end;
Function sbrk(size : longint) : Longint; Function sbrk(size : longint) : Longint;
begin begin
sbrk:=Sys_mmap(0,Size,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0); sbrk:=Sys_mmap(0,Size,3,MAP_PRIVATE+MAP_ANONYMOUS,-1,0);
@ -526,7 +531,12 @@ end;
{ {
$Log$ $Log$
Revision 1.4 2002-10-16 18:44:18 marco Revision 1.5 2002-10-18 12:19:58 marco
* Fixes to get the generic *BSD RTL compiling again + fixes for thread
support. Still problems left in fexpand. (inoutres?) Therefore fixed
sysposix not yet commited
Revision 1.4 2002/10/16 18:44:18 marco
* Lseek and ftruncate 64-bit fix * Lseek and ftruncate 64-bit fix
Revision 1.3 2002/09/07 16:01:17 peter Revision 1.3 2002/09/07 16:01:17 peter

View File

@ -1,5 +1,6 @@
Function Sys_mmap(adr,len,prot,flags,fdes,off:longint):longint; external name 'FPC_SYSC_MMAP'; Function Sys_mmap(adr,len,prot,flags,fdes,off:longint):longint; external name 'FPC_SYSC_MMAP';
Function Sys_munmap(adr:longint;len:size_t):longint; external name 'FPC_SYSC_MUNMAP';
Function Sys_IOCtl(Handle,Ndx: Longint;Data: Pointer):LongInt; external name 'FPC_SYSC_IOCTL'; Function Sys_IOCtl(Handle,Ndx: Longint;Data: Pointer):LongInt; external name 'FPC_SYSC_IOCTL';
Function sys_GetPid:LongInt; external name 'FPC_SYSC_GETPID'; Function sys_GetPid:LongInt; external name 'FPC_SYSC_GETPID';
Function Sys_ReadLink(name,linkname:pchar;maxlen:longint):longint; external name 'FPC_SYSC_READLINK'; Function Sys_ReadLink(name,linkname:pchar;maxlen:longint):longint; external name 'FPC_SYSC_READLINK';

View File

@ -61,7 +61,13 @@ end;
{$i typefile.inc} {$i typefile.inc}
procedure SysInitStdIO;
begin
OpenStdIO(Input,fmInput,StdInputHandle);
OpenStdIO(Output,fmOutput,StdOutputHandle);
OpenStdIO(StdOut,fmOutput,StdOutputHandle);
OpenStdIO(StdErr,fmOutput,StdErrorHandle);
end;
Begin Begin
IsConsole := TRUE; IsConsole := TRUE;
@ -71,14 +77,11 @@ Begin
InstallSignals; InstallSignals;
{ Setup heap } { Setup heap }
InitHeap; InitHeap;
InitExceptions; SysInitExceptions;
{ Arguments } { Arguments }
SetupCmdLine; SetupCmdLine;
{ Setup stdin, stdout and stderr } { Setup stdin, stdout and stderr }
OpenStdIO(Input,fmInput,StdInputHandle); SysInitStdIO;
OpenStdIO(Output,fmOutput,StdOutputHandle);
OpenStdIO(StdOut,fmOutput,StdOutputHandle);
OpenStdIO(StdErr,fmOutput,StdErrorHandle);
{ Reset IO Error } { Reset IO Error }
InOutRes:=0; InOutRes:=0;
{$ifdef HASVARIANT} {$ifdef HASVARIANT}
@ -88,7 +91,12 @@ End.
{ {
$Log$ $Log$
Revision 1.3 2002-10-13 09:25:39 florian Revision 1.4 2002-10-18 12:19:58 marco
* Fixes to get the generic *BSD RTL compiling again + fixes for thread
support. Still problems left in fexpand. (inoutres?) Therefore fixed
sysposix not yet commited
Revision 1.3 2002/10/13 09:25:39 florian
+ call to initvariantmanager inserted + call to initvariantmanager inserted
Revision 1.2 2002/09/07 16:01:17 peter Revision 1.2 2002/09/07 16:01:17 peter

View File

@ -1,8 +1,8 @@
# #
# Don't edit, this file is generated by FPCMake Version 1.1 [2002/08/24] # Don't edit, this file is generated by FPCMake Version 1.1 [2002/08/01]
# #
default: all default: all
MAKEFILETARGETS=linux go32v2 win32 os2 freebsd beos netbsd amiga atari sunos qnx netware openbsd wdosx MAKEFILETARGETS=freebsd
override PATH:=$(subst \,/,$(PATH)) override PATH:=$(subst \,/,$(PATH))
ifeq ($(findstring ;,$(PATH)),) ifeq ($(findstring ;,$(PATH)),)
inUnix=1 inUnix=1
@ -227,7 +227,7 @@ GRAPHDIR=$(INC)/graph
ifndef USELIBGGI ifndef USELIBGGI
USELIBGGI=NO USELIBGGI=NO
endif endif
override TARGET_UNITS+=$(SYSTEMUNIT) objpas strings $(LINUXUNIT) unix initc dos crt objects printer sysutils typinfo math varutils cpu mmx charset ucomplex getopts heaptrc lineinfo errors sockets gpm ipc terminfo video mouse keyboard console serial variants types override TARGET_UNITS+=$(SYSTEMUNIT) objpas strings $(LINUXUNIT) unix initc dos crt objects printer sysutils typinfo math varutils cpu mmx charset ucomplex getopts heaptrc lineinfo errors sockets gpm ipc terminfo video mouse keyboard console serial variants types systhrds
override TARGET_LOADERS+=prt0 cprt0 override TARGET_LOADERS+=prt0 cprt0
override TARGET_RSTS+=math varutils typinfo override TARGET_RSTS+=math varutils typinfo
override INSTALL_FPCPACKAGE=y y override INSTALL_FPCPACKAGE=y y

View File

@ -16,7 +16,7 @@ units=$(SYSTEMUNIT) objpas strings \
sysutils typinfo math varutils \ sysutils typinfo math varutils \
cpu mmx charset ucomplex getopts heaptrc lineinfo \ cpu mmx charset ucomplex getopts heaptrc lineinfo \
errors sockets gpm ipc terminfo \ errors sockets gpm ipc terminfo \
video mouse keyboard console serial variants types video mouse keyboard console serial variants types systhrds
rsts=math varutils typinfo rsts=math varutils typinfo
[require] [require]

View File

@ -77,7 +77,7 @@ const
* those in mcontext_t. * those in mcontext_t.
} }
type sigset_t = array[0..15] of char; type sigset_t = array[0..15] of byte;
PSigContextRec = ^SigContextRec; PSigContextRec = ^SigContextRec;
SigContextRec = record SigContextRec = record
@ -152,7 +152,12 @@ type sigset_t = array[0..15] of char;
{ {
$Log$ $Log$
Revision 1.4 2002-10-16 18:50:22 marco Revision 1.5 2002-10-18 12:19:59 marco
* Fixes to get the generic *BSD RTL compiling again + fixes for thread
support. Still problems left in fexpand. (inoutres?) Therefore fixed
sysposix not yet commited
Revision 1.4 2002/10/16 18:50:22 marco
* sigset back at 16 bytes * sigset back at 16 bytes
Revision 1.3 2002/09/07 16:01:17 peter Revision 1.3 2002/09/07 16:01:17 peter

View File

@ -635,7 +635,7 @@ function signal(signum:longint;Handler:signalhandler):signalhandler;
var sa,osa : sigactionrec; var sa,osa : sigactionrec;
begin begin
sa.handler.sh:=handler; sa.sa_handler:=handler;
FillChar(sa.sa_mask,sizeof(sigset),#0); FillChar(sa.sa_mask,sizeof(sigset),#0);
sa.sa_flags := 0; sa.sa_flags := 0;
{ if (sigintr and signum) =0 then { if (sigintr and signum) =0 then
@ -646,7 +646,7 @@ begin
if ErrNo<>0 then if ErrNo<>0 then
signal:=NIL signal:=NIL
else else
signal:=osa.handler.sh; signal:=osa.sa_handler;
LinuxError:=Errno; LinuxError:=Errno;
end; end;
@ -785,7 +785,12 @@ End;
{ {
$Log$ $Log$
Revision 1.5 2002-09-07 16:01:18 peter Revision 1.6 2002-10-18 12:19:59 marco
* Fixes to get the generic *BSD RTL compiling again + fixes for thread
support. Still problems left in fexpand. (inoutres?) Therefore fixed
sysposix not yet commited
Revision 1.5 2002/09/07 16:01:18 peter
* old logs removed and tabs fixed * old logs removed and tabs fixed
Revision 1.4 2002/05/06 09:35:09 marco Revision 1.4 2002/05/06 09:35:09 marco

View File

@ -19,8 +19,13 @@ interface
{$S-} {$S-}
{$linklib c} {$ifndef BSD}
{$linklib pthread} {$linklib c}
{$linklib pthread}
{$else}
// Link reentrant libc with pthreads
{$linklib c_r}
{$endif}
type type
PRTLCriticalSection = ^TRTLCriticalSection; PRTLCriticalSection = ^TRTLCriticalSection;
@ -48,192 +53,51 @@ implementation
{$i thread.inc} {$i thread.inc}
{***************************************************************************** {$ifndef BSD}
Local POSIX Threads (pthread) imports {$i pthreads.inc}
*****************************************************************************} {$else}
{$i ptypes.inc}
{ Attributes } CONST PTHREAD_EXPLICIT_SCHED = 0;
const PTHREAD_CREATE_DETACHED = 1;
THREAD_PRIORITY_IDLE = 1; PTHREAD_SCOPE_PROCESS = 0;
THREAD_PRIORITY_LOWEST = 15;
THREAD_PRIORITY_BELOW_NORMAL = 30;
THREAD_PRIORITY_NORMAL = 50;
THREAD_PRIORITY_ABOVE_NORMAL = 70;
THREAD_PRIORITY_HIGHEST = 80;
THREAD_PRIORITY_TIME_CRITICAL = 99;
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP : array [0..5]of Integer = (0, 0, 0, 1, 0, 0);
type TYPE
TThreadPriority = (tpIdle, tpLowest, tpLower, tpNormal, tpHigher, tpHighest, tpTimeCritical);
const
Priorities: array [TThreadPriority] of Integer = (
THREAD_PRIORITY_IDLE, THREAD_PRIORITY_LOWEST, THREAD_PRIORITY_BELOW_NORMAL,
THREAD_PRIORITY_NORMAL, THREAD_PRIORITY_ABOVE_NORMAL,
THREAD_PRIORITY_HIGHEST, THREAD_PRIORITY_TIME_CRITICAL
);
type
psched_param = ^sched_param;
sched_param = record
sched_priority : LongInt;
end;
ptimespec = ^timespec;
timespec = record
tv_sec : LongInt;
tv_nsec : LongInt;
end;
psigset_t = ^sigset_t;
sigset_t = DWORD; // unsigned long 32 bits
const
_POSIX_THREAD_THREADS_MAX = 64;
PTHREAD_THREADS_MAX = 512;
_POSIX_THREAD_KEYS_MAX = 128;
PTHREAD_KEYS_MAX = 128;
type
pthread_t = pointer; pthread_t = pointer;
ppthread_t = ^pthread_t; ppthread_t = ^pthread_t;
pthread_key_t = cint;
p_pthread_queue = ^_pthread_queue;
_pthread_queue = record
head : pthread_t;
tail : pthread_t;
end;
ppthread_mutex_t = PRtlCriticalSection;
pthread_mutex_t = TRtlCriticalSection;
ppthread_cond_t = ^pthread_cond_t;
pthread_cond_t = record
c_spinlock : longint;
c_waiting : _pthread_queue;
end;
{ Attributes }
const
PTHREAD_CREATE_JOINABLE = 0;
PTHREAD_CREATE_DETACHED = 1;
PTHREAD_INHERIT_SCHED = 0;
PTHREAD_EXPLICIT_SCHED = 1;
PTHREAD_SCOPE_SYSTEM = 0;
PTHREAD_SCOPE_PROCESS = 1;
type
size_t = longint;
ppthread_attr_t = ^pthread_attr_t;
pthread_attr_t = record
detachstate : longint;
schedpolicy : longint;
schedparam : sched_param;
inheritsched : longint;
scope : longint;
__guardsize : size_t;
__stackaddr_set : longint;
__stackaddr : pointer;
__stacksize : size_t;
end;
ppthread_mutexattr_t = ^pthread_mutexattr_t;
pthread_mutexattr_t = record
mutexkind : longint;
end;
ppthread_condattr_t = ^pthread_condattr_t;
pthread_condattr_t = record
dummy : longint;
end;
ppthread_key_t = ^pthread_key_t; ppthread_key_t = ^pthread_key_t;
pthread_key_t = cardinal; pthread_mutex_t = pointer;
ppthread_mutex_t= ^pthread_mutex_t;
pthread_attr_t = pointer; // opague
ppthread_attr_t = ^pthread_attr_t; // opague
__destr_func_t = procedure (p :pointer);cdecl;
__startroutine_t= function (p :pointer):pointer;cdecl;
pthread_mutex_attr_t = pointer;
ppthread_mutex_attr_t = ^pthread_mutex_t;
ppthread_once_t = ^pthread_once_t; function pthread_getspecific (t : pthread_key_t):pointer; cdecl; external;
pthread_once_t = longint; function pthread_setspecific (t : pthread_key_t;p:pointer):cint; cdecl; external;
function pthread_key_create (p : ppthread_key_t;f: __destr_func_t):cint; cdecl;external;
const function pthread_attr_init (p : ppthread_key_t):cint; cdecl; external;
PTHREAD_ONCE_INIT = 0; function pthread_attr_setinheritsched(p : ppthread_attr_t;i:cint):cint; cdecl; external;
function pthread_attr_setscope (p : ppthread_attr_t;i:cint):cint;cdecl;external;
type function pthread_attr_setdetachstate (p : ppthread_attr_t;i:cint):cint;cdecl;external;
tpcb_routine = Procedure(P:Pointer); cdecl; function pthread_create ( p: ppthread_t;attr : ppthread_attr_t;f:__startroutine_t;arg:pointer):cint;cdecl;external;
procedure pthread_exit ( p: pointer); cdecl;external;
p_pthread_cleanup_buffer = ^_pthread_cleanup_buffer; function pthread_mutex_init (p:ppthread_mutex_t;o:ppthread_mutex_attr_t):cint; cdecl;external;
_pthread_cleanup_buffer = record function pthread_mutex_destroy (p:ppthread_mutex_attr_t):cint; cdecl;external;
routine : tpcb_routine; { Function to call. } function pthread_mutex_lock (p:ppthread_mutex_attr_t):cint; cdecl;external;
arg : Pointer; { Its argument. } function pthread_mutex_unlock (p:ppthread_mutex_attr_t):cint; cdecl;external;
canceltype:LongInt; { Saved cancellation type. }
prev : p_pthread_cleanup_buffer; { Chaining of cleanup functions. }
end;
__start_routine_t = function (_para1:pointer):pointer;cdecl;
__destr_function_t = procedure (_para1:pointer);
t_pthread_cleanup_push_routine = procedure (_para1:pointer);
t_pthread_cleanup_push_defer_routine = procedure (_para1:pointer);
function pthread_create(__thread:ppthread_t; __attr:ppthread_attr_t;__start_routine: __start_routine_t;__arg:pointer):longint;cdecl;external;
function pthread_self:pthread_t;cdecl;external;
function pthread_equal(__thread1:pthread_t; __thread2:pthread_t):longint;cdecl;external;
procedure pthread_exit(__retval:pointer);cdecl;external;
function pthread_join(__th:pthread_t; __thread_return:ppointer):longint;cdecl;external;
function pthread_detach(__th:pthread_t):longint;cdecl;external;
function pthread_attr_init(__attr:ppthread_attr_t):longint;cdecl;external;
function pthread_attr_destroy(__attr:ppthread_attr_t):longint;cdecl;external;
function pthread_attr_setdetachstate(__attr:ppthread_attr_t; __detachstate:longint):longint;cdecl;external;
function pthread_attr_getdetachstate(__attr:ppthread_attr_t; __detachstate:plongint):longint;cdecl;external;
function pthread_attr_setschedparam(__attr:ppthread_attr_t; __param:psched_param):longint;cdecl;external;
function pthread_attr_getschedparam(__attr:ppthread_attr_t; __param:psched_param):longint;cdecl;external;
function pthread_attr_setschedpolicy(__attr:ppthread_attr_t; __policy:longint):longint;cdecl;external;
function pthread_attr_getschedpolicy(__attr:ppthread_attr_t; __policy:plongint):longint;cdecl;external;
function pthread_attr_setinheritsched(__attr:ppthread_attr_t; __inherit:longint):longint;cdecl;external;
function pthread_attr_getinheritsched(__attr:ppthread_attr_t; __inherit:plongint):longint;cdecl;external;
function pthread_attr_setscope(__attr:ppthread_attr_t; __scope:longint):longint;cdecl;external;
function pthread_attr_getscope(__attr:ppthread_attr_t; __scope:plongint):longint;cdecl;external;
function pthread_setschedparam(__target_thread:pthread_t; __policy:longint; __param:psched_param):longint;cdecl;external;
function pthread_getschedparam(__target_thread:pthread_t; __policy:plongint; __param:psched_param):longint;cdecl;external;
function pthread_mutex_init(__mutex:ppthread_mutex_t; __mutex_attr:ppthread_mutexattr_t):longint;cdecl;external;
function pthread_mutex_destroy(__mutex:ppthread_mutex_t):longint;cdecl;external;
function pthread_mutex_trylock(__mutex:ppthread_mutex_t):longint;cdecl;external;
function pthread_mutex_lock(__mutex:ppthread_mutex_t):longint;cdecl;external;
function pthread_mutex_unlock(__mutex:ppthread_mutex_t):longint;cdecl;external;
function pthread_mutexattr_init(__attr:ppthread_mutexattr_t):longint;cdecl;external;
function pthread_mutexattr_destroy(__attr:ppthread_mutexattr_t):longint;cdecl;external;
function pthread_mutexattr_setkind_np(__attr:ppthread_mutexattr_t; __kind:longint):longint;cdecl;external;
function pthread_mutexattr_getkind_np(__attr:ppthread_mutexattr_t; __kind:plongint):longint;cdecl;external;
function pthread_cond_init(__cond:ppthread_cond_t; __cond_attr:ppthread_condattr_t):longint;cdecl;external;
function pthread_cond_destroy(__cond:ppthread_cond_t):longint;cdecl;external;
function pthread_cond_signal(__cond:ppthread_cond_t):longint;cdecl;external;
function pthread_cond_broadcast(__cond:ppthread_cond_t):longint;cdecl;external;
function pthread_cond_wait(__cond:ppthread_cond_t; __mutex:ppthread_mutex_t):longint;cdecl;external;
function pthread_cond_timedwait(__cond:ppthread_cond_t; __mutex:ppthread_mutex_t; __abstime:ptimespec):longint;cdecl;external;
function pthread_condattr_init(__attr:ppthread_condattr_t):longint;cdecl;external;
function pthread_condattr_destroy(__attr:ppthread_condattr_t):longint;cdecl;external;
function pthread_key_create(__key:ppthread_key_t; __destr_function:__destr_function_t):longint;cdecl;external;
function pthread_key_delete(__key:pthread_key_t):longint;cdecl;external;
function pthread_setspecific(__key:pthread_key_t; __pointer:pointer):longint;cdecl;external;
function pthread_getspecific(__key:pthread_key_t):pointer;cdecl;external;
function pthread_once(__once_control:ppthread_once_t; __init_routine:tprocedure ):longint;cdecl;external;
function pthread_setcancelstate(__state:longint; __oldstate:plongint):longint;cdecl;external;
function pthread_setcanceltype(__type:longint; __oldtype:plongint):longint;cdecl;external;
function pthread_cancel(__thread:pthread_t):longint;cdecl;external;
procedure pthread_testcancel;cdecl;external;
procedure _pthread_cleanup_push(__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_routine; __arg:pointer);cdecl;external;
procedure _pthread_cleanup_push_defer(__buffer:p_pthread_cleanup_buffer;__routine:t_pthread_cleanup_push_defer_routine; __arg:pointer);cdecl;external;
function pthread_sigmask(__how:longint; __newmask:psigset_t; __oldmask:psigset_t):longint;cdecl;external;
function pthread_kill(__thread:pthread_t; __signo:longint):longint;cdecl;external;
function sigwait(__set:psigset_t; __sig:plongint):longint;cdecl;external;
function pthread_atfork(__prepare:tprocedure ; __parent:tprocedure ; __child:tprocedure ):longint;cdecl;external;
procedure pthread_kill_other_threads_np;cdecl;external;
{$endif}
{***************************************************************************** {*****************************************************************************
System dependent memory allocation System dependent memory allocation
*****************************************************************************} *****************************************************************************}
{$ifndef BSD}
const const
syscall_nr_mmap = 90; syscall_nr_mmap = 90;
syscall_nr_munmap = 91; syscall_nr_munmap = 91;
@ -286,6 +150,16 @@ begin
Sys_munmap:=syscall(syscall_nr_munmap,t); Sys_munmap:=syscall(syscall_nr_munmap,t);
end; end;
{$else}
CONST
{ Constansts for MMAP. These are still private for *BSD }
MAP_PRIVATE =2;
MAP_ANONYMOUS =$1000;
// *BSD POSIX. Include headers to syscalls.
{$I bsdsysch.inc}
{$endif}
{***************************************************************************** {*****************************************************************************
Threadvar support Threadvar support
@ -506,7 +380,12 @@ initialization
end. end.
{ {
$Log$ $Log$
Revision 1.1 2002-10-16 06:22:56 michael Revision 1.2 2002-10-18 12:19:59 marco
* Fixes to get the generic *BSD RTL compiling again + fixes for thread
support. Still problems left in fexpand. (inoutres?) Therefore fixed
sysposix not yet commited
Revision 1.1 2002/10/16 06:22:56 michael
Threads renamed from threads to systhrds Threads renamed from threads to systhrds
Revision 1.1 2002/10/14 19:39:17 peter Revision 1.1 2002/10/14 19:39:17 peter