Forráskód Böngészése

+ Fixed errno_location problem

michael 22 éve
szülő
commit
5ac94f8092

+ 10 - 0
packages/base/libc/README

@@ -22,4 +22,14 @@ The translation was done on a SuSE 8.1 machine:
 Kernel version: 2.4.18
 glibc version: 2.3
 
+Note on the Libc errno variable. On recent systems the errno symbol is no
+longer published in libc. It has been replaced by a __errno_location
+pointer, with a macro in the C header files to mask this. The pascal 
+Libc files assume this by default. This also means you cannot set the 
+errno value directly, you must use the 'seterrno' procedure for that.
+(see errno.inc)
+
+The old mechanism of a published errno libc variable is still available 
+by setting the LIBC_OLDERRNO define when compiling the libc units.
+
 Michael.

+ 14 - 0
packages/base/libc/errno.inc

@@ -0,0 +1,14 @@
+
+{ Translation of macro }
+
+function errno : error_t; 
+
+begin
+  Result:=__errno_location()^;
+end;
+
+procedure seterrno (value : error_t); 
+
+begin
+  __errno_location()^:=Value;  
+end;

+ 7 - 1
packages/base/libc/errnoh.inc

@@ -3,9 +3,15 @@ Type
   error_t = Integer;
   
 var
+{$ifdef LIBC_OLDERRNO}
   errno : error_t; cvar; external;
+{$endif}
   program_invocation_name : Pchar;cvar;external;
-  
+
+{$ifndef LIBC_OLDERRNO}
+  function errno : error_t; 
+  procedure seterrno (value : error_t); 
+{$endif}
 { ---------------------------------------------------------------------
     asm/errno.inc
   ---------------------------------------------------------------------}

+ 1 - 0
packages/base/libc/libc.pp

@@ -224,6 +224,7 @@ Implementation
 
 uses kernelioctl;
 
+{$i errno.inc}        // errno.h asm/errno.h bits/errno.h macros.
 {$i time.inc}         // bits/time.h macros.
 {$i stime.inc}        // sys/time.h macros.
 {$i dirent.inc}       // dirent.h macros.