Browse Source

* refactored definition of pthread_mutex_t into single location
(pmutext.inc) like for *BSD; fixes the definition of
TRTLCriticalSection for MIPS (and AArch64, as found by
Edmund Grimley Evans)

git-svn-id: trunk@30875 -

Jonas Maebe 10 years ago
parent
commit
23254e7ce2
4 changed files with 67 additions and 31 deletions
  1. 1 0
      .gitattributes
  2. 56 0
      rtl/linux/pmutext.inc
  3. 5 20
      rtl/linux/ptypes.inc
  4. 5 11
      rtl/linux/sysosh.inc

+ 1 - 0
.gitattributes

@@ -8715,6 +8715,7 @@ rtl/linux/osdefs.inc svneol=native#text/plain
 rtl/linux/osmacro.inc svneol=native#text/plain
 rtl/linux/osmacro.inc svneol=native#text/plain
 rtl/linux/ossysc.inc svneol=native#text/plain
 rtl/linux/ossysc.inc svneol=native#text/plain
 rtl/linux/ostypes.inc svneol=native#text/plain
 rtl/linux/ostypes.inc svneol=native#text/plain
+rtl/linux/pmutext.inc svneol=native#text/plain
 rtl/linux/powerpc/bsyscall.inc svneol=native#text/plain
 rtl/linux/powerpc/bsyscall.inc svneol=native#text/plain
 rtl/linux/powerpc/cprt0.as svneol=native#text/plain
 rtl/linux/powerpc/cprt0.as svneol=native#text/plain
 rtl/linux/powerpc/dllprt0.as svneol=native#text/plain
 rtl/linux/powerpc/dllprt0.as svneol=native#text/plain

+ 56 - 0
rtl/linux/pmutext.inc

@@ -0,0 +1,56 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 1999-2000 by Peter Vreman
+    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.
+
+ **********************************************************************}
+
+{ definition of pthread_mutex_t, because needed in both ptypes.inc and }
+{ in sysosh.inc                                                        }
+
+{ use a macro rather than a constant, so this name doesn't get exported
+  from the system unit interface; macro's have to be on at this point
+  because they're use to propagate the MUTEXTYPENAME here }
+
+{$ifdef CPUMIPS}
+{$define USE_PTHREAD_SIZEOF}
+
+{$ifdef CPU64}
+  {$define __SIZEOF_PTHREAD_MUTEX_T := 40}
+{$else CPU64}
+  {$define __SIZEOF_PTHREAD_MUTEX_T := 24}
+{$endif CPU64}
+
+{$endif MIPS}
+
+  MUTEXTYPENAME = record
+    case byte of
+{$ifdef USE_PTHREAD_SIZEOF}
+      0 : (
+        __size : array[0..__SIZEOF_PTHREAD_MUTEX_T-1] of char;
+        __align : sizeint;
+      );
+{$endif}
+      1 : (
+        __m_reserved: longint;
+        __m_count: longint;
+        __m_owner: pointer;
+        __m_kind:  longint;
+        __m_lock:  record
+           __status: sizeint;
+          __spinlock: longint;
+        end;
+       );
+  end;
+
+{$ifdef __SIZEOF_PTHREAD_MUTEX_T}
+{$undef __SIZEOF_PTHREAD_MUTEX_T}
+{$endif __SIZEOF_PTHREAD_MUTEX_T}
+{$macro off}

+ 5 - 20
rtl/linux/ptypes.inc

@@ -35,7 +35,6 @@ introduction)
 {$ifdef CPU64}
 {$ifdef CPU64}
 const
 const
   __SIZEOF_PTHREAD_ATTR_T = 56;
   __SIZEOF_PTHREAD_ATTR_T = 56;
-  __SIZEOF_PTHREAD_MUTEX_T = 40;
   __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
   __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
   __SIZEOF_PTHREAD_COND_T = 48;
   __SIZEOF_PTHREAD_COND_T = 48;
   __SIZEOF_PTHREAD_CONDATTR_T = 4;
   __SIZEOF_PTHREAD_CONDATTR_T = 4;
@@ -46,7 +45,6 @@ const
 {$else : not CPU64, i.e. CPU32}
 {$else : not CPU64, i.e. CPU32}
 const
 const
   __SIZEOF_PTHREAD_ATTR_T = 36;
   __SIZEOF_PTHREAD_ATTR_T = 36;
-  __SIZEOF_PTHREAD_MUTEX_T = 24;
   __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
   __SIZEOF_PTHREAD_MUTEXATTR_T = 4;
   __SIZEOF_PTHREAD_COND_T = 48;
   __SIZEOF_PTHREAD_COND_T = 48;
   __SIZEOF_PTHREAD_CONDATTR_T = 4;
   __SIZEOF_PTHREAD_CONDATTR_T = 4;
@@ -245,24 +243,11 @@ Type
     __spinlock: cint;
     __spinlock: cint;
   end;
   end;
 
 
-  pthread_mutex_t = record
-  {$ifdef USE_PTHREAD_SIZEOF}
-  case byte of
-   0 : (
-    	 __size : array[0..__SIZEOF_PTHREAD_MUTEX_T-1] of char;
-    	 __align : clong;
-       );
-  1 : (
-  {$endif}    	
-    __m_reserved: cint;
-    __m_count: cint;
-    __m_owner: pointer;
-    __m_kind:  cint;
-    __m_lock: _pthread_fastlock;
-  {$ifdef USE_PTHREAD_SIZEOF}
-       );
-  {$endif}    	
-  end;
+{$macro on}
+{$define MUTEXTYPENAME := pthread_mutex_t}
+{$i pmutext.inc}
+{$undef MUTEXTYPENAME}
+{$macro off}
 
 
   pthread_mutexattr_t = record
   pthread_mutexattr_t = record
   {$ifdef USE_PTHREAD_SIZEOF}
   {$ifdef USE_PTHREAD_SIZEOF}

+ 5 - 11
rtl/linux/sysosh.inc

@@ -23,18 +23,12 @@ type
   { pthread_t is defined as an "unsigned long" }
   { pthread_t is defined as an "unsigned long" }
   TThreadID = PtrUInt;
   TThreadID = PtrUInt;
 
 
-  { pthread_mutex_t }
   PRTLCriticalSection = ^TRTLCriticalSection;
   PRTLCriticalSection = ^TRTLCriticalSection;
-  TRTLCriticalSection = record
-    __m_reserved: longint;
-    __m_count: longint;
-    __m_owner: pointer;
-    __m_kind:  longint;
-    __m_lock:  record
-       __status: sizeint;
-      __spinlock: longint;
-    end;
-  end;
+{$macro on}
+{$define MUTEXTYPENAME := TRTLCriticalSection}
+{$i pmutext.inc}
+{$undef MUTEXTYPENAME}
+{$macro off}