View Issue Details

IDProjectCategoryView StatusLast Update
0015483FPCRTLpublic2010-01-13 16:47
ReporterAnton Kavalenka Assigned ToMarco van de Voort  
PrioritynormalSeverityblockReproducibilityalways
Status closedResolutionfixed 
Platformx86_64OSDebian GNU/Linxu 
Product Version2.5.1 
Target Version2.5.1Fixed in Version2.6.0 
Summary0015483: RTL: TTime is Object Pascal type but not Unix-system type
DescriptionCurrent SVN head cannot be built under x86_64-linux

TTime cannot be used as Pascal alias of UNIX timestamp types
Steps To Reproducemake all fails
TagsNo tags attached.
Fixed in Revisionseveral up to 14601
FPCOldBugId
FPCTarget
Attached Files

Relationships

child of 0015474 closedVincent Snijders Lazarus TDate and TTime are not defined in unit System 

Activities

2010-01-08 19:24

 

time_impact.patch (2,220 bytes)   
Index: linux/ossysc.inc
===================================================================
--- linux/ossysc.inc	(revision 14578)
+++ linux/ossysc.inc	(working copy)
@@ -19,7 +19,7 @@
                      --- Main:The System Call Self ---
 *****************************************************************************}
 
-function Fptime(tloc:pTime): TTime; [public, alias : 'FPC_SYSC_TIME'];
+function Fptime(tloc:pTime): time_t; [public, alias : 'FPC_SYSC_TIME'];
 {$ifdef FPC_USEGETTIMEOFDAY}
 VAR tv     : timeval;
     tz     : timezone;
Index: linux/ptypes.inc
===================================================================
--- linux/ptypes.inc	(revision 14578)
+++ linux/ptypes.inc	(working copy)
@@ -98,7 +98,7 @@
     pSSize    = ^ssize_t;
     TClock    = clock_t;
     pClock    = ^clock_t;
-    TTime     = time_t;
+    //TTime     = time_t;
     pTime     = ^time_t;
     ptime_t   = ^time_t;
 
Index: unix/aliasptp.inc
===================================================================
--- unix/aliasptp.inc	(revision 14578)
+++ unix/aliasptp.inc	(working copy)
@@ -54,7 +54,7 @@
     TClock   = UnixType.TClock;
     pClock   = UnixType.pClock;
     time_t   = UnixType.time_t;
-    TTime    = UnixType.TTime;
+    //TTime    = UnixType.TTime;
     pTime    = UnixType.pTime;
     ptime_t  = UnixType.ptime_t;
 
Index: unix/bunxh.inc
===================================================================
--- unix/bunxh.inc	(revision 14578)
+++ unix/bunxh.inc	(working copy)
@@ -86,7 +86,7 @@
     function  FpWriteV	   (fd: cint; const iov : piovec; iovcnt : cint):TSSize; 
 
     Function  FpLseek      (fd : cInt; offset : TOff; whence : cInt): TOff; external name 'FPC_SYSC_LSEEK';
-    Function  FpTime       (var tloc : TTime): TTime; external name 'FPC_SYSC_TIME';
+    Function  FpTime       (var tloc : time_t): time_t; external name 'FPC_SYSC_TIME';
     Function  FpFtruncate  (fd : cInt; flength : TOff): cInt;  external name 'FPC_SYSC_FTRUNCATE';
     Function  FPSigaction  (sig: cInt; act : pSigActionRec; oact : pSigActionRec): cint;  external name 'FPC_SYSC_SIGACTION';
     Function  FPSelect     (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
time_impact.patch (2,220 bytes)   

Sven Barth

2010-01-08 20:51

manager   ~0033519

A quick grep in RTL directory shows that there are some more locations where TTime is used, while a time_t was meant. I'll try to write a patch similiar to the attached one containing all TTime occurences... (it's my fault after all :P )

Sven Barth

2010-01-08 21:29

manager   ~0033520

Ok... I'll attach three patches:
* time_rtl.patch replaces all (Unix) TTime types in all RTLs with time_t (includes changes from time_impact.patch)
* time_users.patch replaces two TTime occurences in packages/users
* time_x11.patch: TTime is redefined in x.pp as culong (and used in all x11 units that use TTime). I only moved the PTime type defined there below the TTime declaration to be sure that the correct type is used. If you're sure that not the new System.TTime is used, you might ignore this patch

2010-01-08 21:30

 

time_rtl.patch (10,660 bytes)   
Index: rtl/unix/oscdeclh.inc
===================================================================
--- rtl/unix/oscdeclh.inc	(Revision 14580)
+++ rtl/unix/oscdeclh.inc	(Arbeitskopie)
@@ -66,7 +66,7 @@
     function  FPSigProcMask(how:cint;nset : psigset;oset : psigset):cint;cdecl; external clib name 'sigprocmask';
     function  FPSigProcMask(how:cint;const nset : sigset;var oset : sigset):cint;cdecl; external clib name 'sigprocmask';
     function  FpTime       (tloc:ptime_t): time_t; cdecl; external clib name 'time';
-    Function  FpTime       (var tloc : TTime): TTime; cdecl; external clib name 'time';
+    Function  FpTime       (var tloc : time_t): time_t; cdecl; external clib name 'time';
     function  FpTimes	(var buffer : tms): TClock; cdecl; external clib name 'times';
     function  FpUname   (var name: utsname): cint; cdecl; external clib name 'uname';
     function  FpUnlink  (path: pchar): cint; cdecl; external clib name 'unlink';
Index: rtl/unix/aliasptp.inc
===================================================================
--- rtl/unix/aliasptp.inc	(Revision 14580)
+++ rtl/unix/aliasptp.inc	(Arbeitskopie)
@@ -54,7 +54,6 @@
     TClock   = UnixType.TClock;
     pClock   = UnixType.pClock;
     time_t   = UnixType.time_t;
-    TTime    = UnixType.TTime;
     pTime    = UnixType.pTime;
     ptime_t  = UnixType.ptime_t;
 
Index: rtl/unix/bunxh.inc
===================================================================
--- rtl/unix/bunxh.inc	(Revision 14580)
+++ rtl/unix/bunxh.inc	(Arbeitskopie)
@@ -86,7 +86,7 @@
     function  FpWriteV	   (fd: cint; const iov : piovec; iovcnt : cint):TSSize; 
 
     Function  FpLseek      (fd : cInt; offset : TOff; whence : cInt): TOff; external name 'FPC_SYSC_LSEEK';
-    Function  FpTime       (var tloc : TTime): TTime; external name 'FPC_SYSC_TIME';
+    Function  FpTime       (var tloc : time_t): time_t; external name 'FPC_SYSC_TIME';
     Function  FpFtruncate  (fd : cInt; flength : TOff): cInt;  external name 'FPC_SYSC_FTRUNCATE';
     Function  FPSigaction  (sig: cInt; act : pSigActionRec; oact : pSigActionRec): cint;  external name 'FPC_SYSC_SIGACTION';
     Function  FPSelect     (N:cint;readfds,writefds,exceptfds:pfdSet;TimeOut:PTimeVal):cint;
Index: rtl/beos/ptypes.inc
===================================================================
--- rtl/beos/ptypes.inc	(Revision 14580)
+++ rtl/beos/ptypes.inc	(Arbeitskopie)
@@ -86,7 +86,6 @@
     pClock   = ^clock_t;
 
     time_t   = clong;           { used for returning the time  }
-    TTime    = time_t; 
     pTime    = ^time_t;
     ptime_t =  ^time_t;
     
Index: rtl/openbsd/ptypes.inc
===================================================================
--- rtl/openbsd/ptypes.inc	(Revision 14580)
+++ rtl/openbsd/ptypes.inc	(Arbeitskopie)
@@ -70,7 +70,6 @@
     pClock   = ^clock_t;
 
     time_t   = clong;           { used for returning the time  }
-    TTime    = time_t;
     pTime    = ^time_t;
     ptime_t  = ^time_t;
 
Index: rtl/haiku/ptypes.inc
===================================================================
--- rtl/haiku/ptypes.inc	(Revision 14580)
+++ rtl/haiku/ptypes.inc	(Arbeitskopie)
@@ -86,7 +86,6 @@
     pClock   = ^clock_t;
 
     time_t   = clong;           { used for returning the time  }
-    TTime    = time_t; 
     pTime    = ^time_t;
     ptime_t =  ^time_t;
     
Index: rtl/netwlibc/sysutils.pp
===================================================================
--- rtl/netwlibc/sysutils.pp	(Revision 14580)
+++ rtl/netwlibc/sysutils.pp	(Arbeitskopie)
@@ -518,7 +518,7 @@
 ****************************************************************************}
 
 Procedure GetLocalTime(var SystemTime: TSystemTime);
-var t : TTime;
+var t : time_t;
     tm: Ttm;
 begin
   libc.time(t);
Index: rtl/netwlibc/libc.pp
===================================================================
--- rtl/netwlibc/libc.pp	(Revision 14580)
+++ rtl/netwlibc/libc.pp	(Arbeitskopie)
@@ -1101,7 +1101,6 @@
 
    Ptime_t = ^time_t;
    time_t = longint;
-   Ttime  = time_t;
 
 { turn on 1-byte packing...  }
 
@@ -1205,12 +1204,12 @@
 function asctime(var localtime:Ttm):Pchar;cdecl;external libc_nlm name 'asctime';
 function clock:clock_t;cdecl;external libc_nlm name 'clock';
 function ctime(calendar:Ptime_t):Pchar;cdecl;external libc_nlm name 'ctime';
-function ctime(var calendar:Ttime):Pchar;cdecl;external libc_nlm name 'ctime';
-function difftime(t1, t2:Ttime):double;cdecl;external libc_nlm name 'difftime';
+function ctime(var calendar:time_t):Pchar;cdecl;external libc_nlm name 'ctime';
+function difftime(t1, t2:time_t):double;cdecl;external libc_nlm name 'difftime';
 function gmtime(calendar:Ptime_t):Ptm;cdecl;external libc_nlm name 'gmtime';
-function gmtime(var calendar:Ttime):Ptm;cdecl;external libc_nlm name 'gmtime';
+function gmtime(var calendar:time_t):Ptm;cdecl;external libc_nlm name 'gmtime';
 function localtime(calendar:Ptime_t):Ptm;cdecl;external libc_nlm name 'localtime';
-function localtime(var calendar:Ttime):Ptm;cdecl;external libc_nlm name 'localtime';
+function localtime(var calendar:time_t):Ptm;cdecl;external libc_nlm name 'localtime';
 function mktime(localtime:Ptm):time_t;cdecl;external libc_nlm name 'mktime';
 function mktime(var localtime:Ttm):time_t;cdecl;external libc_nlm name 'mktime';
 
@@ -1219,7 +1218,7 @@
 //                      const tm * __restrict localtime );
 
 function time(calendar:Ptime_t):time_t;cdecl;external libc_nlm name 'time';
-function time(var calendar:Ttime):time_t;cdecl;external libc_nlm name 'time';
+function time(var calendar:time_t):time_t;cdecl;external libc_nlm name 'time';
 function ___clocks_per_sec:longint;cdecl;external libc_nlm name '___clocks_per_sec';
 { POSIX data and helper functions...  }
 function ___daylight:Plongint;cdecl;external libc_nlm name '___daylight';
@@ -1234,17 +1233,17 @@
 function asctime_r(localtime:Ptm; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'asctime_r';
 function asctime_r(var localtime:Ttm; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'asctime_r';
 function ctime_r(calendar:Ptime_t; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'ctime_r';
-function ctime_r(var calendar:Ttime; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'ctime_r';
+function ctime_r(var calendar:time_t; timestr:Pchar):Pchar;cdecl;external libc_nlm name 'ctime_r';
 function gmtime_r(calendar:Ptime_t; localtime:Ptm):Ptm;cdecl;external libc_nlm name 'gmtime_r';
-function gmtime_r(var calendar:Ttime; localtime:Ptm):Ptm;cdecl;external libc_nlm name 'gmtime_r';
+function gmtime_r(var calendar:time_t; localtime:Ptm):Ptm;cdecl;external libc_nlm name 'gmtime_r';
 function localtime_r(calendar:Ptime_t; localtime:Ptm):Ptm;cdecl;external libc_nlm name 'localtime_r';
-function localtime_r(var calendar:Ttime; var localtime:Ttm):Ptm;cdecl;external libc_nlm name 'localtime_r';
+function localtime_r(var calendar:time_t; var localtime:Ttm):Ptm;cdecl;external libc_nlm name 'localtime_r';
 { Single UNIX Specification additions...  }
 function nanosleep(rqtp, rmtp:Ptimespec):longint;cdecl;external libc_nlm name 'nanosleep';
 function nanosleep(var rqtp, rmtp:Ttimespec):longint;cdecl;external libc_nlm name 'nanosleep';
 { Novell-defined additions...  }
 function ltime(calendar:Ptime_t):time_t;cdecl;external libc_nlm name 'ltime';
-function ltime(var calendar:Ttime):time_t;cdecl;external libc_nlm name 'ltime';
+function ltime(var calendar:time_t):time_t;cdecl;external libc_nlm name 'ltime';
 function mkgmtime(gmtime:Ptm):time_t;cdecl;external libc_nlm name 'mkgmtime';
 function mkgmtime(var gmtime:Ttm):time_t;cdecl;external libc_nlm name 'mkgmtime';
 function dos2calendar(dostime:Tdos_d):time_t;cdecl;external libc_nlm name 'dos2calendar';
Index: rtl/netwlibc/dos.pp
===================================================================
--- rtl/netwlibc/dos.pp	(Revision 14580)
+++ rtl/netwlibc/dos.pp	(Arbeitskopie)
@@ -97,7 +97,7 @@
 
 procedure getdate(var year,month,mday,wday : word);
 var
-  t  : TTime;
+  t  : time_t;
   tm : Ttm;
 begin
   time(t); localtime_r(t,tm);
@@ -118,7 +118,7 @@
 
 procedure gettime(var hour,minute,second,sec100 : word);
 var
-  t  : TTime;
+  t  : time_t;
   tm : Ttm;
 begin
   time(t); localtime_r(t,tm);
Index: rtl/freebsd/ptypes.inc
===================================================================
--- rtl/freebsd/ptypes.inc	(Revision 14580)
+++ rtl/freebsd/ptypes.inc	(Arbeitskopie)
@@ -94,7 +94,6 @@
 
     time_t   = clong;           { used for returning the time, clong
                                         is 64-bit on AMD64}
-    TTime    = time_t;
     pTime    = ^time_t;
     ptime_t =  ^time_t;
 
Index: rtl/solaris/ptypes.inc
===================================================================
--- rtl/solaris/ptypes.inc	(Revision 14580)
+++ rtl/solaris/ptypes.inc	(Arbeitskopie)
@@ -93,7 +93,6 @@
     pSSize    = ^ssize_t;
     TClock    = clock_t;
     pClock    = ^clock_t;
-    TTime     = time_t;
     pTime     = ^time_t;
     ptime_t   = ^time_t;
     clockid_t = cint;
Index: rtl/netbsd/ptypes.inc
===================================================================
--- rtl/netbsd/ptypes.inc	(Revision 14580)
+++ rtl/netbsd/ptypes.inc	(Arbeitskopie)
@@ -80,7 +80,6 @@
     pClock   = ^clock_t;
 
     time_t   = clong;           { used for returning the time  }
-    TTime    = time_t;
     pTime    = ^time_t;
     ptime_t  = ^time_t;
 
Index: rtl/darwin/ptypes.inc
===================================================================
--- rtl/darwin/ptypes.inc	(Revision 14580)
+++ rtl/darwin/ptypes.inc	(Arbeitskopie)
@@ -77,7 +77,6 @@
     pClock   = ^clock_t;
 
     time_t   = clong;           { used for returning the time  }
-    TTime    = time_t;
     pTime    = ^time_t;
     ptime_t  = ^time_t;
 
Index: rtl/linux/ptypes.inc
===================================================================
--- rtl/linux/ptypes.inc	(Revision 14580)
+++ rtl/linux/ptypes.inc	(Arbeitskopie)
@@ -98,7 +98,6 @@
     pSSize    = ^ssize_t;
     TClock    = clock_t;
     pClock    = ^clock_t;
-    TTime     = time_t;
     pTime     = ^time_t;
     ptime_t   = ^time_t;
 
Index: rtl/linux/ossysc.inc
===================================================================
--- rtl/linux/ossysc.inc	(Revision 14580)
+++ rtl/linux/ossysc.inc	(Arbeitskopie)
@@ -19,7 +19,7 @@
                      --- Main:The System Call Self ---
 *****************************************************************************}
 
-function Fptime(tloc:pTime): TTime; [public, alias : 'FPC_SYSC_TIME'];
+function Fptime(tloc:pTime): time_t; [public, alias : 'FPC_SYSC_TIME'];
 {$ifdef FPC_USEGETTIMEOFDAY}
 VAR tv     : timeval;
     tz     : timezone;
time_rtl.patch (10,660 bytes)   

2010-01-08 21:30

 

time_users.patch (1,074 bytes)   
Index: packages/users/src/pwd.pp
===================================================================
--- packages/users/src/pwd.pp	(Revision 14580)
+++ packages/users/src/pwd.pp	(Arbeitskopie)
@@ -77,14 +77,14 @@
             pw_uid     : Tuid;		{ user uid  }
             pw_gid     : Tgid;		{ user gid  }
             {$ifdef bsd}
-            pw_change  : Ttime platform;         { password change time  }
+            pw_change  : time_t platform;         { password change time  }
             pw_class   : pchar platform;        { user access class  }
             {$endif}
             pw_gecos   : pchar;        { Honeywell login info  }
             pw_dir     : pchar;        { home directory  }
             pw_shell   : pchar;        { default shell  }
             {$ifdef bsd}
-            pw_expire  : Ttime platform;         { account expiration  }
+            pw_expire  : time_t platform;         { account expiration  }
             {$ifdef FreeBSD}
             pw_fields  : cint platform;          { internal: fields filled in  }
             {$endif}
time_users.patch (1,074 bytes)   

2010-01-08 21:30

 

time_x11.patch (364 bytes)   
Index: packages/x11/src/x.pp
===================================================================
--- packages/x11/src/x.pp	(Revision 14580)
+++ packages/x11/src/x.pp	(Arbeitskopie)
@@ -39,8 +39,8 @@
    PVisualID = ^TVisualID;
    TVisualID = culong;
 
+   TTime = culong;
    PTime = ^TTime;
-   TTime = culong;
 
    PPWindow = ^PWindow;
    PWindow = ^TWindow;
time_x11.patch (364 bytes)   

Marco van de Voort

2010-01-09 16:39

manager   ~0033524

Last edited: 2010-01-09 16:43

This is no solution, since it possibly breaks heaps of headers.

When baseunix was conceived, there was a lot of pressure on me to define friendly pascal/Delphi styleguide T<x> identifiers for everything instead of c-like "time_t" likes.

I didn't know then that Delphi defined a similar type in system.

However if we are going to remove the baseunix stuff, I propose to come clean, and remove all T<X> friendly types, including TOFF etc.

Marco van de Voort

2010-01-09 17:12

manager   ~0033525

I misunderstood apparantly, from Florian I understood it only goes for the "system unit" implementation scope.

Solved that by postponing aliasing ttime to time_t till unixtype, r14584

FreeBSD now cycles.

Sven Barth

2010-01-09 17:36

manager   ~0033526

Also a way to solves this... :)

A little question regarding the PTime pointer in packages/X11/x.pp: Does it refer to the TTime defined directly below it or the TTime defined in system.pp?

Marco van de Voort

2010-01-09 18:49

manager   ~0033527

Last edited: 2010-01-09 18:52

(Edited) I don't know what it does in such circumstances, since ttime is also defined within the same block. Something for the compiler guys.

But probably the whole principle is wrong. It should use the versions from baseunix as much as possible and not import its own.

Since this could break on (32-bit) systems where time_t is already 64-bit, UNLESS the x11 time_t type is independant from the system one.

Sven Barth

2010-01-09 20:17

manager   ~0033528

Last edited: 2010-01-09 20:22

I don't think it should. The declaration of Time in X.h looks like this:

typedef CARD32 Time

So it's not the same as time_t. The use of the same type names is only in our sources.

Btw: Linux didn't cycle. There was a use of TTime inside system.pp (ossysc.inc)). I'll upload the patch once the cycle is complete.

Edit: patch uploaded. I also replaced the usage of PTime with the "more sane" ptime_t. Linux now cycles again.

2010-01-09 20:21

 

time-linux-rtl.patch (558 bytes)   
Index: rtl/linux/ossysc.inc
===================================================================
--- rtl/linux/ossysc.inc	(Revision 14584)
+++ rtl/linux/ossysc.inc	(Arbeitskopie)
@@ -19,7 +19,7 @@
                      --- Main:The System Call Self ---
 *****************************************************************************}
 
-function Fptime(tloc:pTime): TTime; [public, alias : 'FPC_SYSC_TIME'];
+function Fptime(tloc:ptime_t): time_t; [public, alias : 'FPC_SYSC_TIME'];
 {$ifdef FPC_USEGETTIMEOFDAY}
 VAR tv     : timeval;
     tz     : timezone;
time-linux-rtl.patch (558 bytes)   

Marco van de Voort

2010-01-09 23:03

manager   ~0033529

Fixed that, and another one when compiling with -dFPC_USE_LIBC

Marco van de Voort

2010-01-10 16:24

manager   ~0033542

- Reversed x11 ttime/ptime.
- "users" is no problem since importing unix units with ttime in it overrides the system definition

Issue History

Date Modified Username Field Change
2010-01-08 19:24 Anton Kavalenka New Issue
2010-01-08 19:24 Anton Kavalenka File Added: time_impact.patch
2010-01-08 19:42 Jonas Maebe Relationship added child of 0015474
2010-01-08 20:51 Sven Barth Note Added: 0033519
2010-01-08 21:29 Sven Barth Note Added: 0033520
2010-01-08 21:30 Sven Barth File Added: time_rtl.patch
2010-01-08 21:30 Sven Barth File Added: time_users.patch
2010-01-08 21:30 Sven Barth File Added: time_x11.patch
2010-01-09 16:39 Marco van de Voort Note Added: 0033524
2010-01-09 16:43 Marco van de Voort Note Edited: 0033524
2010-01-09 17:12 Marco van de Voort Note Added: 0033525
2010-01-09 17:36 Sven Barth Note Added: 0033526
2010-01-09 18:49 Marco van de Voort Note Added: 0033527
2010-01-09 18:51 Marco van de Voort Note Edited: 0033527
2010-01-09 18:52 Marco van de Voort Note Edited: 0033527
2010-01-09 18:52 Marco van de Voort Note Edited: 0033527
2010-01-09 20:17 Sven Barth Note Added: 0033528
2010-01-09 20:21 Sven Barth File Added: time-linux-rtl.patch
2010-01-09 20:22 Sven Barth Note Edited: 0033528
2010-01-09 23:03 Marco van de Voort Note Added: 0033529
2010-01-10 16:24 Marco van de Voort Fixed in Revision => several up to 14601
2010-01-10 16:24 Marco van de Voort Status new => resolved
2010-01-10 16:24 Marco van de Voort Fixed in Version => 2.5.1
2010-01-10 16:24 Marco van de Voort Resolution open => fixed
2010-01-10 16:24 Marco van de Voort Assigned To => Marco van de Voort
2010-01-10 16:24 Marco van de Voort Note Added: 0033542
2010-01-10 16:24 Marco van de Voort Target Version => 2.5.1
2010-01-13 16:47 Anton Kavalenka Status resolved => closed