summaryrefslogtreecommitdiff
path: root/ULibc.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2008-06-16 22:33:31 +0200
committerTomas Bzatek <tbzatek@redhat.com>2008-06-16 22:33:31 +0200
commit1c828670f3a5cffc32bf527ecac846161711ee45 (patch)
treeb0c890ad0c0ad8bce3052ae9e6bf674697e6af8e /ULibc.pas
parent5fa771023dc8757f0b23861ef4dac2b4dd9efaf8 (diff)
downloadtuxcmd-1c828670f3a5cffc32bf527ecac846161711ee45.tar.xz
PPC (32bit) fixes
Diffstat (limited to 'ULibc.pas')
-rw-r--r--ULibc.pas75
1 files changed, 75 insertions, 0 deletions
diff --git a/ULibc.pas b/ULibc.pas
index f2fda81..585b7c8 100644
--- a/ULibc.pas
+++ b/ULibc.pas
@@ -99,6 +99,7 @@ type
Pstat64 = ^Tstat64;
Tstat64 = packed record
{$IFNDEF CPU64} // 32-bit platform
+{$IFNDEF CPUPOWERPC}
st_dev : __dev_t;
__pad1 : dword;
__st_ino : __ino_t;
@@ -115,6 +116,24 @@ type
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;
+{$ENDIF}
{$ELSE} // 64-bit platform
st_dev : QWORD;
st_ino : Int64;
@@ -621,11 +640,20 @@ function dlclose(handle: Pointer): Longint; cdecl; external DL_LIB name 'dlclose
function dlsym(handle: Pointer; const symbol: PChar): Pointer; cdecl; external DL_LIB name 'dlsym';
function dlerror: PChar; cdecl; external GLIBC_LIB name 'dlerror';
+{$IFNDEF CPUPOWERPC}
function malloc(size: size_t): Pointer; cdecl; external GLIBC_LIB name 'malloc';
+{$ELSE}
+function malloc(size: size_t): Pointer;
+{$ENDIF}
function calloc(nmemb: size_t; size: size_t): Pointer; cdecl; external GLIBC_LIB name 'calloc';
function realloc(ptr: Pointer; size: size_t): Pointer; cdecl; external GLIBC_LIB name 'realloc';
+{$IFNDEF CPUPOWERPC}
procedure free(ptr: Pointer); cdecl; external GLIBC_LIB name 'free';
procedure libc_free(ptr: Pointer); cdecl; external GLIBC_LIB name 'free';
+{$ELSE}
+procedure free(ptr: Pointer);
+procedure libc_free(ptr: Pointer);
+{$ENDIF}
procedure cfree(ptr: Pointer); cdecl; external GLIBC_LIB name 'cfree';
function memalign(boundary: size_t; size: size_t): Pointer; cdecl; external GLIBC_LIB name 'memalign';
function valloc(size: size_t): Pointer; cdecl; external GLIBC_LIB name 'valloc';
@@ -644,8 +672,13 @@ function strcmp(const s1: PChar; const s2: PChar): Longint; cdecl; external GLIB
function strncmp(const s1: PChar; const s2: PChar; n: size_t): Longint; cdecl; external GLIBC_LIB name 'strncmp';
function strcasecmp(const s1: PChar; const s2: PChar): Longint; cdecl; external GLIBC_LIB name 'strcasecmp';
function strncasecmp(const s1: PChar; const s2: PChar; n: size_t): Longint; cdecl; external GLIBC_LIB name 'strncasecmp';
+{$IFNDEF CPUPOWERPC}
function strdup(const s: PChar): PChar; cdecl; external GLIBC_LIB name 'strdup';
function strndup(const s: PChar; n: size_t): PChar; cdecl; external GLIBC_LIB name 'strndup';
+{$ELSE}
+function strdup(const s: PChar): PChar;
+function strndup(const s: PChar; n: size_t): PChar;
+{$ENDIF}
function strchr(const s: PChar; c: Longint): PChar; cdecl; external GLIBC_LIB name 'strchr';
function strrchr(const s: PChar; c: Longint): PChar; cdecl; external GLIBC_LIB name 'strrchr';
function strstr(const haystack: PChar; const needle: PChar): PChar; cdecl; external GLIBC_LIB name 'strstr';
@@ -819,6 +852,11 @@ function euidaccess(pathname: PChar; mode: Longint): Longint; cdecl; external GL
implementation
+{$IFDEF CPUPOWERPC}
+uses SysUtils;
+{$ENDIF}
+
+
{$IFDEF KYLIX}
function glibc__xstat64(ver: integer; const afile: PChar; buf: Pstat64): longint; cdecl; external GLIBC_LIB name '__xstat64';
function glibc__lxstat64(ver: integer; const path: PChar; buf: Pstat64): longint; cdecl; external GLIBC_LIB name '__lxstat64';
@@ -932,5 +970,42 @@ begin
Result:=(Signal shl 8) or $7F;
end;
+
+{$IFDEF CPUPOWERPC}
+function xmalloc(size: size_t): Pointer; cdecl; external GLIBC_LIB name 'malloc';
+procedure xfree(ptr: Pointer); cdecl; external GLIBC_LIB name 'free';
+
+function malloc(size: size_t): Pointer;
+begin
+ Result := GetMem(size);
+// Result := xmalloc(size);
+ WriteLn('malloc(', size, '): 0x', IntToHex(DWORD(Result), 4));
+end;
+
+procedure libc_free(ptr: Pointer);
+begin
+ WriteLn('free(0x', IntToHex(DWORD(ptr), 4), ')');
+ FreeMem(ptr);
+// xfree(ptr);
+end;
+
+procedure free(ptr: Pointer);
+begin
+ libc_free(ptr);
+end;
+
+function strdup(const s: PChar): PChar;
+begin
+ Result := GetMem(strlen(s) + 1);
+ SysUtils.StrLCopy(Result, s, strlen(s) + 1);
+end;
+
+function strndup(const s: PChar; n: size_t): PChar;
+begin
+ Result := GetMem(n + 1);
+ SysUtils.StrLCopy(Result, s, n);
+end;
+{$ENDIF}
+
end.