From 8a3268cddb42e7af5f645f8f87d7eb1a373b1e29 Mon Sep 17 00:00:00 2001 From: michael Date: Thu, 11 Aug 2005 17:28:04 +0000 Subject: [PATCH] + Last Borland Compatibility fixes git-svn-id: trunk@847 - --- packages/base/libc/bsocketh.inc | 5 ++ packages/base/libc/direnth.inc | 6 ++ packages/base/libc/pthreadh.inc | 17 +++++ packages/base/libc/pthreadtypesh.inc | 3 +- packages/base/libc/semaphoreh.inc | 5 +- packages/base/libc/sigactionh.inc | 3 +- packages/base/libc/siginfoh.inc | 107 ++++++++++++--------------- packages/base/libc/sigseth.inc | 2 +- packages/base/libc/systypeshh.inc | 2 + packages/base/libc/timexh.inc | 24 +++--- packages/base/libc/typesh.inc | 6 ++ 11 files changed, 104 insertions(+), 76 deletions(-) diff --git a/packages/base/libc/bsocketh.inc b/packages/base/libc/bsocketh.inc index 89c0186cb2..70fd3e071d 100644 --- a/packages/base/libc/bsocketh.inc +++ b/packages/base/libc/bsocketh.inc @@ -249,3 +249,8 @@ type function SA_LEN(const buf): Cardinal; // Untyped buffer; this is *unsafe*. function __libc_sa_len(__af: sa_family_t): Integer; cdecl;external clib name '__libc_sa_len'; +{ Borland compatibility } + +Type + PSocketLength = ^socklen_t; + \ No newline at end of file diff --git a/packages/base/libc/direnth.inc b/packages/base/libc/direnth.inc index 41e5471286..2578401080 100644 --- a/packages/base/libc/direnth.inc +++ b/packages/base/libc/direnth.inc @@ -48,6 +48,12 @@ function scandir64(__dir:Pchar; __namelist:PPPdirent64; __selector:TSelectorFunc function getdirentries(__fd:longint; __buf:Pchar; __nbytes:size_t; __basep:P__off_t):__ssize_t;cdecl;external clib name 'getdirentries'; function getdirentries64(__fd:longint; __buf:Pchar; __nbytes:size_t; __basep:P__off64_t):__ssize_t;cdecl;external clib name 'getdirentries64'; +function alphasort(const e1: Pointer; const e2: Pointer): Integer; cdecl; external clib name 'alphasort'; +function alphasort64(const e1: Pointer; const e2: Pointer): Integer; cdecl; external clib name 'alphasort64'; +function versionsort(const e1: Pointer; const e2: Pointer): Integer; cdecl; external clib name 'versionsort'; +function versionsort64(const e1: Pointer; const e2: Pointer): Integer; cdecl; external clib name 'versionsort64'; + + { --------------------------------------------------------------------- Borland compatibility types ---------------------------------------------------------------------} diff --git a/packages/base/libc/pthreadh.inc b/packages/base/libc/pthreadh.inc index 7ba48f58b0..0c567f978d 100644 --- a/packages/base/libc/pthreadh.inc +++ b/packages/base/libc/pthreadh.inc @@ -27,6 +27,8 @@ Const PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP = 2; PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP; + PTHREAD_ONCE_INIT = 0; + type TPThreadCleanupRoutine = procedure(Arg: Pointer); cdecl; @@ -49,12 +51,20 @@ Const PTHREAD_CANCELED = Pointer(-1); PTHREAD_BARRIER_SERIAL_THREAD = -1; + NONRECURSIVE = 0; + RECURSIVE = 1; + + + + // procedural types used in parameters to pthread functions Type TStartRoutine = function (_para1:pointer): integer; cdecl;// pthread_create TKeyValueDestructor = procedure(ValueInKey: Pointer); cdecl; TInitOnceProc = Procedure;cdecl; TForkHandler = procedure; cdecl; + + procedure __pthread_initialize;cdecl;external threadslib name '__pthread_initialize'; function pthread_create(__thread:Ppthread_t; __attr:Ppthread_attr_t; __start_routine:TStartRoutine; __arg:pointer):longint;cdecl;external threadslib name 'pthread_create'; @@ -242,3 +252,10 @@ procedure _pthread_cleanup_push(var __buffer: _pthread_cleanup_buffer; __routine procedure _pthread_cleanup_pop(var __buffer:_pthread_cleanup_buffer; __execute:longint);cdecl; external threadslib; function pthread_sigmask(__how:longint; var __newmask:__sigset_t; var __oldmask:__sigset_t):longint;cdecl; external threadslib; +{ Borland compatibility } + +function GetCurrentThreadID: TTHreadID ; cdecl; external threadslib name 'pthread_self'; + +Type + TPThreadFunc = function(Parameter: Pointer): Integer; cdecl; + PPthreadCleanupBuffer = ^_pthread_cleanup_buffer; \ No newline at end of file diff --git a/packages/base/libc/pthreadtypesh.inc b/packages/base/libc/pthreadtypesh.inc index a147782b71..89a505b2f7 100644 --- a/packages/base/libc/pthreadtypesh.inc +++ b/packages/base/libc/pthreadtypesh.inc @@ -134,5 +134,6 @@ Type PPthreadBarrierAttribute = ^TPthreadBarrierAttribute; TThreadID = pthread_t; - + TPThreadKey = pthread_key_t; + diff --git a/packages/base/libc/semaphoreh.inc b/packages/base/libc/semaphoreh.inc index 4361a38f89..a835bef064 100644 --- a/packages/base/libc/semaphoreh.inc +++ b/packages/base/libc/semaphoreh.inc @@ -37,6 +37,9 @@ Type spinlock: Integer; end; + TPCharArray = System.TPCharArray; + PPCharArray = System.PPCharArray; + function sem_init(var __sem: sem_t; __pshared:longint; __value:dword):longint;cdecl;external threadslib name 'sem_init'; function sem_destroy(var __sem: sem_t):longint;cdecl;external threadslib name 'sem_destroy'; function sem_close(var __sem: sem_t):longint;cdecl;external threadslib name 'sem_close'; @@ -46,4 +49,4 @@ function sem_trywait(var __sem: sem_t):longint;cdecl;external threadslib name 's function sem_post(var __sem: sem_t):longint;cdecl;external threadslib name 'sem_post'; function sem_getvalue(var __sem: sem_t; __sval:Plongint):longint;cdecl;external threadslib name 'sem_getvalue'; - + diff --git a/packages/base/libc/sigactionh.inc b/packages/base/libc/sigactionh.inc index d084e57263..23593a7089 100644 --- a/packages/base/libc/sigactionh.inc +++ b/packages/base/libc/sigactionh.inc @@ -38,5 +38,6 @@ Type PSigAction = ^TSigAction; TRestoreHandler = procedure; cdecl; __sigaction = _sigaction; - + TSigActionHandler = procedure(Signal: Integer); cdecl; + diff --git a/packages/base/libc/siginfoh.inc b/packages/base/libc/siginfoh.inc index aa7559fdb7..e184a3e2e3 100644 --- a/packages/base/libc/siginfoh.inc +++ b/packages/base/libc/siginfoh.inc @@ -1,3 +1,6 @@ +const + __SI_MAX_SIZE = 128; + __SI_PAD_SIZE = (__SI_MAX_SIZE div sizeof (Integer)) - 3; type @@ -10,9 +13,40 @@ type sigval_t = sigval; Psigval_t = ^sigval_t; -const - __SI_MAX_SIZE = 128; - __SI_PAD_SIZE = (__SI_MAX_SIZE div sizeof (Integer)) - 3; + + // Borland compatibility types moved here, needed for siginfo + _si_sigchld = record + si_pid: __pid_t; + si_uid: __uid_t; + si_status: Integer; + si_utime: __clock_t; + si_stime: __clock_t; + end; + + _si_kill = record + si_pid: __pid_t; + si_uid: __uid_t; + end; + _si_pad = packed array[0..__SI_PAD_SIZE-1] of Integer; + _si_sigfault = record + si_addr: Pointer; + end; + _si_sigpoll = record + si_band: Longint; + si_fd: Integer; + end; + _si_timer = record + _timer1: Cardinal; + _timer2: Cardinal; + end; + _si_rt = record + si_pid: __pid_t; + si_uid: __uid_t; + si_sigval: sigval_t; + end; + + + type @@ -21,37 +55,14 @@ type si_signo : longint; si_errno : longint; si_code : longint; - _sifields : record - case longint of - 0 : ( _pad : array[0..(__SI_PAD_SIZE)-1] of longint ); - 1 : ( _kill : record - si_pid : __pid_t; - si_uid : __uid_t; - end ); - 2 : ( _timer : record - _timer1 : dword; - _timer2 : dword; - end ); - 3 : ( _rt : record - si_pid : __pid_t; - si_uid : __uid_t; - si_sigval : sigval_t; - end ); - 4 : ( _sigchld : record - si_pid : __pid_t; - si_uid : __uid_t; - si_status : longint; - si_utime : __clock_t; - si_stime : __clock_t; - end ); - 5 : ( _sigfault : record - si_addr : pointer; - end ); - 6 : ( _sigpoll : record - si_band : longint; - si_fd : longint; - end ); - end; + Case integer of + 0: (_pad: _si_pad); + 1: (_kill: _si_kill); + 2: (_timer: _si_timer); + 3: (_rt: _si_rt); + 4: (_sigchld: _si_sigchld); + 5: (_sigfault: _si_sigfault); + 6: (_sigpoll: _si_sigpoll); end; siginfo_t = siginfo; Psiginfo_t = ^siginfo_t; @@ -123,8 +134,6 @@ type _attribute: Pointer; { Really pthread_attr_t. } end; - - Psigevent = ^sigevent; sigevent = record sigev_value : sigval_t; @@ -144,7 +153,6 @@ Const SIGEV_NONE = 1; SIGEV_THREAD = 2; - { --------------------------------------------------------------------- Borland compatibility types ---------------------------------------------------------------------} @@ -155,26 +163,5 @@ Type TSigInfo = siginfo; TSigEvent = sigevent; - _si_kill = record - si_pid: __pid_t; - si_uid: __uid_t; - end; - _si_pad = packed array[0..__SI_PAD_SIZE-1] of Integer; - _si_sigfault = record - si_addr: Pointer; - end; - _si_sigpoll = record - si_band: Longint; - si_fd: Integer; - end; - _si_timer = record - _timer1: Cardinal; - _timer2: Cardinal; - end; - _si_rt = record - si_pid: __pid_t; - si_uid: __uid_t; - si_sigval: sigval_t; - end; - - + + \ No newline at end of file diff --git a/packages/base/libc/sigseth.inc b/packages/base/libc/sigseth.inc index 74f5b2a1e3..ef445999f2 100644 --- a/packages/base/libc/sigseth.inc +++ b/packages/base/libc/sigseth.inc @@ -3,7 +3,6 @@ type P__sig_atomic_t = ^__sig_atomic_t; __sig_atomic_t = longint; - Const _SIGSET_NWORDS = 1024 div (8 * (sizeof(dword))); @@ -27,5 +26,6 @@ function __sigdelset(_para1:P__sigset_t; _para2:longint):longint;cdecl;external Type TSigset = __sigset_t; PSigset = ^TSigset; + sig_atomic_t = __sig_atomic_t; diff --git a/packages/base/libc/systypeshh.inc b/packages/base/libc/systypeshh.inc index 41910a4d6a..5543322f1d 100644 --- a/packages/base/libc/systypeshh.inc +++ b/packages/base/libc/systypeshh.inc @@ -50,3 +50,5 @@ Type blkcnt64_t = __blkcnt64_t; fsblkcnt64_t = __fsblkcnt64_t; fsfilcnt64_t = __fsfilcnt64_t; + u_int64_t = QWord; + \ No newline at end of file diff --git a/packages/base/libc/timexh.inc b/packages/base/libc/timexh.inc index a8adc7c8e3..55c6f39442 100644 --- a/packages/base/libc/timexh.inc +++ b/packages/base/libc/timexh.inc @@ -28,18 +28,18 @@ type calcnt : longint; errcnt : longint; stbcnt : longint; - a32 : longint; - b32 : longint; - c32 : longint; - d32 : longint; - e32 : longint; - f32 : longint; - g32 : longint; - h32 : longint; - i32 : longint; - j32 : longint; - k32 : longint; - l32 : longint; + bitfield11 : longint; + bitfield12 : longint; + bitfield13 : longint; + bitfield14 : longint; + bitfield21 : longint; + bitfield22 : longint; + bitfield23 : longint; + bitfield24 : longint; + bitfield31 : longint; + bitfield32 : longint; + bitfield33 : longint; + bitfield34 : longint; end; diff --git a/packages/base/libc/typesh.inc b/packages/base/libc/typesh.inc index 66417fa3a9..23703218ed 100644 --- a/packages/base/libc/typesh.inc +++ b/packages/base/libc/typesh.inc @@ -76,6 +76,12 @@ type __intptr_t = longint; __socklen_t = dword; TFileDescriptor = integer; + +Const + stdin = 0; + stdout = 1; + stderr = 2; + { --------------------------------------------------------------------- 'h2pas -S -c -D -l libc -i' from sys/types.h