summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2009-10-03 13:22:27 +0200
committerTomas Bzatek <tbzatek@redhat.com>2009-10-03 13:22:27 +0200
commit15efde21a039f2dfa11c715c9c40b6d12813baf3 (patch)
tree48ec9dcf18ecded5cfb478e22a6f8b0b695e93c7
parentdffc52bad545084a53b20f892ebf51d1d7c7fa78 (diff)
downloadtuxcmd-15efde21a039f2dfa11c715c9c40b6d12813baf3.tar.xz
Consolidate basic glibc structs
Fixes crashes on PPC32
-rw-r--r--UConfig.pas2
-rw-r--r--UEngines.pas14
-rw-r--r--ULibc.pas171
-rw-r--r--vfs/uVFSprototypes.pas10
4 files changed, 120 insertions, 77 deletions
diff --git a/UConfig.pas b/UConfig.pas
index edaac1b..d0e536f 100644
--- a/UConfig.pas
+++ b/UConfig.pas
@@ -1102,7 +1102,7 @@ begin
Result := -1;
StatBuf := malloc(sizeof(Tstat64));
memset(StatBuf, 0, sizeof(Tstat64));
- if lstat64(PChar(FileName), StatBuf) = 0 then Result := StatBuf^.st_mtim.tv_sec;
+ if lstat64(PChar(FileName), StatBuf) = 0 then Result := StatBuf^.st_mtime;
libc_free(StatBuf);
end;
diff --git a/UEngines.pas b/UEngines.pas
index b77d7e3..c08b077 100644
--- a/UEngines.pas
+++ b/UEngines.pas
@@ -303,7 +303,7 @@ begin
IsChr := __S_ISTYPE(StatBuf^.st_mode, __S_IFCHR);
IsFIFO := __S_ISTYPE(StatBuf^.st_mode, __S_IFIFO);
IsSock := __S_ISTYPE(StatBuf^.st_mode, __S_IFSOCK);
- ModifyTime := StatBuf^.st_mtim.tv_sec;
+ ModifyTime := StatBuf^.st_mtime;
if StatBuf^.st_uid = 4294967295 then UID := getuid
else UID := StatBuf^.st_uid;
if StatBuf^.st_gid = 4294967295 then GID := getgid
@@ -567,8 +567,8 @@ var Handle : PDIR;
else UID := StatBuf_local^.st_uid;
if StatBuf_local^.st_gid = 4294967295 then GID := getgid
else GID := StatBuf_local^.st_gid;
- atime := StatBuf_local^.st_atim.tv_sec;
- mtime := StatBuf_local^.st_mtim.tv_sec;
+ atime := StatBuf_local^.st_atime;
+ mtime := StatBuf_local^.st_mtime;
if IsLnk and AddCurrDirStage then DebugMsg(['*** Assertion failed AddEntry: Item^.IsLnk = True']);
if IsLnk and (not AddCurrDirStage) then begin
i := readlink(PChar(APath + String(PChar(@DirEnt^.d_name[0]))), LnkBuf, SizeOf(LnkBuf));
@@ -580,7 +580,7 @@ var Handle : PDIR;
// StrLCopy(LnkPointTo, @LnkBuf[0], i);
end;
end;
- ModifyTime := StatBuf_local^.st_mtim.tv_sec;
+ ModifyTime := StatBuf_local^.st_mtime;
// DebugMsg([FormatDateTime('c', ModifyTime)]);
Level := ALevel + Ord(not AddCurrDirStage);
libc_free(StatBuf_local);
@@ -667,14 +667,14 @@ begin
// DebugMsg(['x2']);
ForceMove := False;
// DebugMsg(['x2']);
- ModifyTime := StatBuf^.st_mtim.tv_sec;
+ ModifyTime := StatBuf^.st_mtime;
// DebugMsg(['x2']);
if StatBuf^.st_uid = 4294967295 then UID := getuid
else UID := StatBuf^.st_uid;
if StatBuf^.st_gid = 4294967295 then GID := getgid
else GID := StatBuf^.st_gid;
- atime := StatBuf^.st_atim.tv_sec;
- mtime := StatBuf^.st_mtim.tv_sec;
+ atime := StatBuf^.st_atime;
+ mtime := StatBuf^.st_mtime;
// DebugMsg(['x1']);
libc_free(StatBuf);
// DebugMsg(['x1']);
diff --git a/ULibc.pas b/ULibc.pas
index a01b573..63902f5 100644
--- a/ULibc.pas
+++ b/ULibc.pas
@@ -21,6 +21,9 @@ unit ULibc;
interface
+{$IFDEF FPC}
+ {$PACKRECORDS C}
+{$ENDIF}
const GLIBC_LIB = 'libc.so.6';
DL_LIB = 'libdl.so.2';
@@ -30,8 +33,24 @@ type
{$IFDEF KYLIX}
DWORD = Cardinal;
QWORD = Int64;
+ LongWord = LongInt;
+{$ENDIF}
+
+ cUShort = Word;
+ cInt = LongInt;
+ cuInt = LongWord;
+ cLongLong = Int64;
+ cuLongLong = QWord;
+ cuChar = Byte;
+{$IFDEF CPU64}
+ cLong = Int64;
+ cuLong = QWord;
+{$ELSE}
+ cLong = Longint;
+ cuLong = Cardinal;
{$ENDIF}
+
sig_atomic_t = Longint;
size_t = Cardinal;
ssize_t = Longint;
@@ -50,8 +69,8 @@ type
__blksize_t = Longint;
__blkcnt_t = Longint;
__blkcnt64_t = Int64;
-
-
+
+
Pidtype_t = ^idtype_t;
idtype_t = (P_ALL,P_PID,P_PGID);
@@ -89,7 +108,7 @@ type
end;
Pdirent64 = ^Tdirent64;
- Tdirent64 = record
+ Tdirent64 = packed record
d_ino : QWORD;
d_off : Int64;
d_reclen : word;
@@ -98,59 +117,88 @@ type
end;
Pstat64 = ^Tstat64;
- Tstat64 = packed record
-{$IFNDEF CPU64} // 32-bit platform
-{$IFNDEF CPUPOWERPC}
- st_dev : __dev_t;
- __pad1 : dword;
- __st_ino : __ino_t;
- st_mode : __mode_t;
- st_nlink : __nlink_t;
- st_uid : __uid_t;
- st_gid : __gid_t;
- st_rdev : __dev_t;
- __pad2 : dword;
- st_size : __off64_t;
- st_blksize : __blksize_t;
- st_blocks : __blkcnt64_t;
- st_atim : Ttimespec;
- st_mtim : Ttimespec;
- st_ctim : Ttimespec;
- st_ino : __ino64_t;
-{$ELSE} // 32-bit PPC
- st_dev : __dev_t;
- st_ino : __ino64_t;
- st_mode : __mode_t;
- st_nlink : __nlink_t;
- st_uid : __uid_t;
- st_gid : __gid_t;
- st_rdev : __dev_t;
- __pad2 : ShortInt;
- st_size : __off64_t;
- st_blksize : __blksize_t;
- st_blocks : __blkcnt64_t;
- st_atim : Ttimespec;
- st_mtim : Ttimespec;
- st_ctim : Ttimespec;
- __unused4 : DWORD;
- __unused5 : DWORD;
+ Tstat64 = record
+{$IFNDEF CPU64}
+{$IFNDEF CPUPOWERPC} // i386
+ st_dev: cuLongLong;
+ __pad0_: array[0..3] of cuChar;
+ __st_ino: cuLong;
+ st_mode: cuInt;
+ st_nlink: cuInt;
+ st_uid: cuLong;
+ st_gid: cuLong;
+ st_rdev: cuLongLong;
+ __pad3_: array[0..3] of cuChar;
+ st_size: cLongLong;
+ st_blksize: cuLong;
+ st_blocks: cuLongLong; //* Number 512-byte blocks allocated. */
+ st_atime: cuLong;
+ st_atime_nsec: cuLong;
+ st_mtime: cuLong;
+ st_mtime_nsec: cuInt;
+ st_ctime: cuLong;
+ st_ctime_nsec: cuLong;
+ st_ino: cuLongLong
+{$ELSE} // PPC32
+ st_dev : cULongLong;
+ st_ino : cULongLong;
+ st_mode : cUInt;
+ st_nlink : cUInt;
+ st_uid : cUInt;
+ st_gid : cUInt;
+ st_rdev : cULongLong;
+ __pad2 : cUShort;
+ st_size : cLongLong;
+ st_blksize : cInt;
+ st_blocks : cULongLong;
+ st_atime,
+ st_atime_nsec,
+ st_mtime,
+ st_mtime_nsec,
+ st_ctime,
+ st_ctime_nsec,
+ __unused4,
+ __unused5 : cULong;
+{$ENDIF}
+{$ELSE}
+{$IFNDEF CPUPOWERPC} // x86_64
+ st_dev: cuLong;
+ st_ino: cuLong;
+ st_nlink: cuLong;
+ st_mode: cuInt;
+ st_uid: cuInt;
+ st_gid: cuInt;
+ __pad1: cuInt;
+ st_rdev: cuLong;
+ st_size: cLong;
+ st_blksize: cLong;
+ st_blocks: cLong; //* Number 512-byte blocks allocated. */
+ st_atime: cuLong;
+ st_atime_nsec: cuLong;
+ st_mtime: cuLong;
+ st_mtime_nsec: cuLong;
+ st_ctime: cuLong;
+ st_ctime_nsec: cuLong;
+ __unused2: array[0..2] of cLong;
+{$ELSE} // PPC64
+ st_dev : cULong;
+ st_ino : cULong; { wrongly defined in RTL? }
+ st_nlink : cULong; { wrongly defined in RTL? }
+ st_mode : mode_t;
+ st_uid : uid_t;
+ st_gid : gid_t;
+ st_rdev : cULong;
+ st_size : off_t;
+ st_blksize : cULong;
+ st_blocks : cULong; { Number 512-byte blocks allocated. }
+ st_atime : cULong;
+ st_atime_nsec : cULong;
+ st_mtime : cULong;
+ st_mtime_nsec : cULong;
+ st_ctime : cULong;
+ st_ctime_nsec : cULong;
+ __unused : array[0..2] of cULong;
{$ENDIF}
-{$ELSE} // 64-bit platform
- st_dev : QWORD;
- st_ino : Int64;
- st_nlink : QWORD;
- st_mode : DWORD;
- st_uid : DWORD;
- st_gid : DWORD;
- pad0 : DWORD;
- st_rdev : QWORD;
- st_size : Int64;
- st_blksize : Int64;
- st_blocks : Int64;
- st_atim : Ttimespec;
- st_mtim : Ttimespec;
- st_ctim : Ttimespec;
- __unused : array[1..3] of QWORD;
{$ENDIF}
end;
@@ -194,28 +242,19 @@ type
Ptime_t = ^time_t;
Putimbuf = ^Tutimbuf;
- Tutimbuf = packed record
+ Tutimbuf = record
actime : time_t;
modtime : time_t;
end;
Pmntent = ^Tmntent;
- Tmntent = packed record
-{$IFNDEF CPU64} // 32-bit platform
+ Tmntent = record
mnt_fsname : PChar;
mnt_dir : PChar;
mnt_type : PChar;
mnt_opts : PChar;
mnt_freq : Longint;
mnt_passno : Longint;
-{$ELSE} // 64-bit platform
- mnt_fsname : PChar;
- mnt_dir : PChar;
- mnt_type : PChar;
- mnt_opts : PChar;
- mnt_freq : Longint;
- mnt_passno : Longint;
-{$ENDIF}
end;
PPasswd = ^TPasswd;
diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas
index a67b303..5f0106c 100644
--- a/vfs/uVFSprototypes.pas
+++ b/vfs/uVFSprototypes.pas
@@ -27,6 +27,10 @@ unit uVFSprototypes;
interface
+{$IFDEF FPC}
+ {$PACKRECORDS C}
+{$ENDIF}
+
const
cVFSVersion = 4; // current version of the VFS API
@@ -106,7 +110,7 @@ type
PVFSItem = ^TVFSItem;
- TVFSItem = packed record
+ TVFSItem = record
{$IFNDEF CPU64} // 32-bit platform
FName: PChar;
// FDisplayName - plugins must ensure correct UTF-8 string
@@ -121,7 +125,7 @@ type
sLinkTo: PChar;
iUID: Integer;
iGID: Integer;
- ItemType: TVFSItemType;
+ ItemType: Integer;
{$ELSE} // 64-bit platform
FName: PChar;
FDisplayName: PChar;
@@ -141,7 +145,7 @@ type
end;
// This structure contains basic informations about the plugin (Name is used to identify the module in the application)
- TVFSInfo = packed record
+ TVFSInfo = record
Name: PChar;
Description: PChar;
About: PChar;