mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-27 19:53:38 +02:00

Revision(s) 39739, 39749, 39860, 39862, 39865, 39869, 39871, 39903, 39905, 39917, 39956, 39959-39960, 39969, 39971, 39980, 39987, 40198-40201, 40472, 40532, 40535-40536 from trunk: * Android: The list of supported syscalls has been auto-generated directly from android sources for each CPU. * Minor adjustments to make all compilable with the proper list of Android syscalls. ........ * Re-generated lists of android syscalls by a new script. The lists are more correct now. The script's location: https://svn.freepascal.org/svn/fpcbuild/scripts/android ........ * Fixed UnhookSignal when RTL_SIGDEFAULT is passed. The bug have caused crash on aarch64-android due to out of bounds read of the rtlsig2ossig[] array. ........ + Added support for the aarch64-android target. ........ * Set ICU data dir if it is not set by the system. It fixes issues on newer Android versions. * Added more predefined ICU versions. ........ * android: Use the current dir as temp. ........ * Corrected TUContext record for aarch64-linux and aarch64-android. It fixes obtaining of an address of the instruction where a signal has thrown. ........ * Enabled safecall support for aarch64 to be on par with other cpus. ........ * Android: Reworked the startup code to use no assembly instructions. Generic assembler startup files contains only section data and are compiled for each CPU. * Android: argc and argv are correct for shared libraries. ........ * Use syscall_nr_renameat for android. ........ + added support for x86_64-android target. ........ + Added the auto-generated list syscalls for mips64-android. It will be needed when mips64 is supported. ........ * x86_64-android requires sigreturn for proper signal handling. ........ * Register external gas assembler for aarch64-android and x86_64-android. ........ * Enabled compilation of the cpu unit for arm-android and x86_64-android. ........ * ucnv_open() must be called with some SSE exception masked on x86_64-android. * Call u_init() during initialization. ........ * Create the ".note.gnu.build-id" section for android. It fixes debugging of shared libs in Android Studio. ........ * android: Removed cwstring from the uses clause of the unix unit. Use cwstring indirectly. It allows to avoid using cwstring if needed. ........ * ICU v3.8 on Android 1.5-2.1 is buggy and can't be unloaded properly. ........ * Fixed locale detection on new Android versions. ........ * Fixed obtaining a time zone information for 64-bit android. ........ * Since Android 8 the net.dnsX properties can't be read. Use Google Public DNS servers. ........ * android: Use libc for sockets since the "accept" syscall is blocked by SECCOMP, but the "accept4" alternative is not available on old Android versions (2.3 and older). ........ * android: Regenerated syscalls. ........ * android: Disabled usage of the "pselect6" and "ppoll" syscalls for arm-android. These syscalls are not available on old Android versions (2.3 or older). ........ git-svn-id: branches/fixes_3_2@40540 -
139 lines
3.8 KiB
PHP
139 lines
3.8 KiB
PHP
{$IF defined(WINDOWS)}
|
|
type
|
|
isoLPWStr = PWideChar;
|
|
isoWinBool = LongBool;
|
|
TSysCharSet = set of AnsiChar;
|
|
|
|
function GetEnvironmentStringsW: isoLPWStr; stdcall; external 'kernel32' name 'GetEnvironmentStringsW';
|
|
function FreeEnvironmentStringsW(_para1 : isoLPWStr): isoWinBool; stdcall; external 'kernel32' name 'FreeEnvironmentStringsW';
|
|
|
|
function StrLen(p : PWideChar): sizeint; external name 'FPC_PWIDECHAR_LENGTH'; overload;
|
|
|
|
{$push}
|
|
{$checkpointer off}
|
|
|
|
function CharInSet(Ch : WideChar; const CSet : TSysCharSet): Boolean;
|
|
begin
|
|
CharInSet := (Ch <= #$FF) and (AnsiChar(byte(Ch)) in CSet);
|
|
end;
|
|
|
|
function InternalChangeCase(const S : UnicodeString; const Chars: TSysCharSet; const Adjustment: Longint): UnicodeString;
|
|
var
|
|
i : Integer;
|
|
p : PWideChar;
|
|
unique : Boolean;
|
|
begin
|
|
InternalChangeCase := S;
|
|
if InternalChangeCase = '' then
|
|
exit;
|
|
unique := false;
|
|
p := PWideChar(InternalChangeCase);
|
|
for i := 1 to Length(InternalChangeCase) do
|
|
begin
|
|
if CharInSet(p^, Chars) then
|
|
begin
|
|
if not unique then
|
|
begin
|
|
UniqueString(InternalChangeCase);
|
|
p := @InternalChangeCase[i];
|
|
unique := true;
|
|
end;
|
|
p^ := WideChar(Ord(p^) + Adjustment);
|
|
end;
|
|
inc(p);
|
|
end;
|
|
end;
|
|
|
|
function UpperCase(const s : UnicodeString) : UnicodeString;
|
|
begin
|
|
UpperCase := InternalChangeCase(s, ['a'..'z'], -32);
|
|
end;
|
|
|
|
function GetEnvironmentVariable(const EnvVar : UnicodeString) : UnicodeString;
|
|
var
|
|
s, upperenv : UnicodeString;
|
|
i : Longint;
|
|
hp, p : PWideChar;
|
|
begin
|
|
GetEnvironmentVariable := '';
|
|
p := GetEnvironmentStringsW;
|
|
hp := p;
|
|
upperenv := uppercase(envvar);
|
|
while hp^ <> #0 do
|
|
begin
|
|
s := hp;
|
|
i := pos('=', s);
|
|
if uppercase(copy(s,1,i-1)) = upperenv then
|
|
begin
|
|
GetEnvironmentVariable := copy(s, i+1, length(s)-i);
|
|
break;
|
|
end;
|
|
{ next string entry }
|
|
hp := hp + strlen(hp) + 1;
|
|
end;
|
|
FreeEnvironmentStringsW(p);
|
|
end;
|
|
|
|
function getTempDir: String;
|
|
var
|
|
astringLength : Integer;
|
|
begin
|
|
getTempDir := GetEnvironmentVariable('TMP');
|
|
if getTempDir = '' then
|
|
getTempDir := GetEnvironmentVariable('TEMP');
|
|
astringlength := Length(getTempDir);
|
|
if (astringlength > 0) and (getTempDir[astringlength] <> DirectorySeparator) then
|
|
getTempDir := getTempDir + DirectorySeparator;
|
|
end;
|
|
|
|
{$pop}
|
|
|
|
{$ELSEIF defined(UNIX) and not defined(android)}
|
|
|
|
function getTempDir: string;
|
|
var
|
|
key: string;
|
|
value: string;
|
|
i_env, i_key, i_value: integer;
|
|
begin
|
|
value := '/tmp/'; (** default for UNIX **)
|
|
while (envp <> NIL) and assigned(envp^) do
|
|
begin
|
|
i_env := 0;
|
|
i_key := 1;
|
|
while not (envp^[i_env] in ['=', #0]) do
|
|
begin
|
|
key[i_key] := envp^[i_env];
|
|
inc(i_env);
|
|
inc(i_key);
|
|
end;
|
|
setlength(key, i_key - 1);
|
|
if (key = 'TEMP') or (key = 'TMP') or (key = 'TMPDIR') then
|
|
begin
|
|
inc(i_env); (** skip '=' **)
|
|
i_value := 1;
|
|
while (envp^[i_env] <> #0) do
|
|
begin
|
|
value[i_value] := envp^[i_env];
|
|
inc(i_env);
|
|
inc(i_value);
|
|
end;
|
|
setlength(value, i_value - 1);
|
|
end;
|
|
inc(envp);
|
|
end;
|
|
i_value:=length(value);
|
|
if (i_value > 0) and (value[i_value] <> DirectorySeparator) then
|
|
value := value + DirectorySeparator;
|
|
getTempDir := value;
|
|
end;
|
|
|
|
{$ELSE} // neither unix nor windows
|
|
|
|
function getTempDir: string;
|
|
begin
|
|
getTempDir:='';
|
|
end;
|
|
|
|
{$ENDIF}
|