Browse Source

* android: Properly initialize time zone information.

git-svn-id: trunk@34332 -
yury 9 years ago
parent
commit
2630f3c498
5 changed files with 73 additions and 3 deletions
  1. 1 0
      .gitattributes
  2. 2 2
      rtl/android/Makefile
  3. 1 1
      rtl/android/Makefile.fpc
  4. 57 0
      rtl/android/unixandroid.inc
  5. 12 0
      rtl/unix/unix.pp

+ 1 - 0
.gitattributes

@@ -8352,6 +8352,7 @@ rtl/android/jvm/rtl.cfg svneol=native#text/plain
 rtl/android/mipsel/dllprt0.as svneol=native#text/plain
 rtl/android/mipsel/prt0.as svneol=native#text/plain
 rtl/android/sysandroid.inc svneol=native#text/plain
+rtl/android/unixandroid.inc svneol=native#text/plain
 rtl/arm/arm.inc svneol=native#text/plain
 rtl/arm/armdefines.inc svneol=native#text/plain
 rtl/arm/cpu.pp svneol=native#text/pascal

+ 2 - 2
rtl/android/Makefile

@@ -1,5 +1,5 @@
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2016-06-18 rev 34006]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2016/08/07]
 #
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim i386-android i386-aros m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii powerpc-aix sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-netbsd x86_64-solaris x86_64-openbsd x86_64-darwin x86_64-win64 x86_64-embedded x86_64-iphonesim x86_64-aros x86_64-dragonfly arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian arm-android powerpc64-linux powerpc64-darwin powerpc64-embedded powerpc64-aix avr-embedded armeb-linux armeb-embedded mips-linux mipsel-linux mipsel-embedded mipsel-android jvm-java jvm-android i8086-embedded i8086-msdos i8086-win16 aarch64-linux aarch64-darwin
@@ -3598,7 +3598,7 @@ strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
 	$(COMPILER) $(INC)/strings.pp
 unix$(PPUEXT) : $(UNIXINC)/unix.pp strings$(PPUEXT) baseunix$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
 		 $(LINUXINC)/unxconst.inc $(UNIXINC)/timezone.inc $(SYSTEMUNIT)$(PPUEXT) \
-		 $(LINUXINC)/unxfunc.inc
+		 $(LINUXINC)/unxfunc.inc unixandroid.inc
 	$(COMPILER) $(UNIXINC)/unix.pp
 syscall$(PPUEXT) : $(UNIXINC)/syscall.pp $(LINUXINC)/$(ARCH)/syscallh.inc $(LINUXINC)/$(ARCH)/sysnr.inc $(SYSTEMUNIT)$(PPUEXT)
 	$(COMPILER) $(UNIXINC)/syscall.pp

+ 1 - 1
rtl/android/Makefile.fpc

@@ -139,7 +139,7 @@ strings$(PPUEXT) : $(INC)/strings.pp $(INC)/stringsi.inc\
 
 unix$(PPUEXT) : $(UNIXINC)/unix.pp strings$(PPUEXT) baseunix$(PPUEXT) $(INC)/textrec.inc $(INC)/filerec.inc \
                  $(LINUXINC)/unxconst.inc $(UNIXINC)/timezone.inc $(SYSTEMUNIT)$(PPUEXT) \
-                 $(LINUXINC)/unxfunc.inc
+                 $(LINUXINC)/unxfunc.inc unixandroid.inc
         $(COMPILER) $(UNIXINC)/unix.pp
 
 syscall$(PPUEXT) : $(UNIXINC)/syscall.pp $(LINUXINC)/$(ARCH)/syscallh.inc $(LINUXINC)/$(ARCH)/sysnr.inc $(SYSTEMUNIT)$(PPUEXT)

+ 57 - 0
rtl/android/unixandroid.inc

@@ -0,0 +1,57 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2016 by Yury Sidorov,
+    member of the Free Pascal development team.
+
+    Android-specific part of the System unit.
+
+    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.
+ **********************************************************************}
+
+type
+   Ptm = ^tm;
+   tm = record
+        tm_sec : longint;
+        tm_min : longint;
+        tm_hour : longint;
+        tm_mday : longint;
+        tm_mon : longint;
+        tm_year : longint;
+        tm_wday : longint;
+        tm_yday : longint;
+        tm_isdst : longint;
+        case boolean of
+          false : (tm_gmtoff : longint;tm_zone : Pchar);
+          true  : (__tm_gmtoff : longint;__tm_zone : Pchar);
+	 end;
+
+function localtime(t: PLongInt): Ptm; cdecl; external;
+
+var
+  c_tzname: array[0..1] of PAnsiChar; external name 'tzname';
+  c_timezone: longint; external name 'timezone';
+  c_daylignt: shortint; external name 'daylight';
+
+procedure InitLocalTime;
+var
+  t: longint;
+  tt: Ptm;
+begin
+  t:=fptime;
+  tt:=localtime(@t);
+  tzname[false]:=c_tzname[0];
+  tzname[true]:=c_tzname[1];
+  if tt <> nil then begin
+    tzdaylight:=tt^.tm_isdst <> 0;
+    tzseconds:=tt^.tm_gmtoff;
+  end
+  else begin
+    tzdaylight:=c_daylignt <> 0;
+    tzseconds:=-c_timezone;
+  end;
+end;

+ 12 - 0
rtl/unix/unix.pp

@@ -57,6 +57,10 @@ var
 
 {************     Procedure/Functions     ************}
 
+{$ifdef android}
+  {$define DONT_READ_TIMEZONE}
+{$endif android}
+
 {$IFNDEF DONT_READ_TIMEZONE}  // allows to disable linking in and trying for platforms
                        // it doesn't (yet) work for.
 
@@ -1219,10 +1223,18 @@ begin
   FSearch:=FSearch(ToSingleByteFileSystemEncodedFileName(path),ToSingleByteFileSystemEncodedFileName(dirlist),CurrentDirectoryFirst);
 end;
 
+{$ifdef android}
+  {$I unixandroid.inc}
+{$endif android}
+
 Initialization
 {$IFNDEF DONT_READ_TIMEZONE}
   InitLocalTime;
 {$endif}
+{$ifdef android}
+  InitLocalTime;
+{$endif android}
+
 finalization
 {$IFNDEF DONT_READ_TIMEZONE}
   DoneLocalTime;