I am working around a problem called Y2038 bug.
http://groups.google.co.in/group/comp.unix.programmer/browse_thread/t...
I am developing an application which need to be built both on windows
and linux and used time_t, ctime, mktime, localtime and gmtime
functions from <time.h>.
The application already exists and I have to replace these 32bit time
structures with their 64bit equivalents. I have made all the changes
and built the application on windows but can't do so on linux because
Linux does not seem to have a 64 bit equivalent for time_t , or
mktime..
http://msdn2.microsoft.com/en-us/library/bf12f0hc.aspx
Is there a patch or some workaround it? need suggestions
Thank
|
|
0
|
|
|
|
Reply
|
drool.galz (37)
|
2/11/2008 11:30:42 AM |
|
On Feb 11, 3:30 am, Aditi <drool.g...@gmail.com> wrote:
> The application already exists and I have to replace these 32bit time
> structures with their 64bit equivalents. I have made all the changes
> and built the application on windows but can't do so on linux because
> Linux does not seem to have a 64 bit equivalent for time_t , or
> mktime..
Are you using 32-bit Linux or 64-bit Linux? If your goal is to have
actual compiled code that will run in 2038, you will have to build it
for 64-bit Linux. It is not currently possible to make a 32-bit Linux
kernel or 32-bit Linux applications that will work unmodified after
2038.
$ cat test.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
printf("Sizeof(time_t)==%d\n", sizeof(time_t));
}
$ uname -ri
2.6.23.14-115.fc8 x86_64
$ gcc test.c -o test
$ ./test
Sizeof(time_t)==8
Looks fine to me.
DS
|
|
0
|
|
|
|
Reply
|
David
|
2/11/2008 12:02:45 PM
|
|
David Schwartz wrote:
> Are you using 32-bit Linux or 64-bit Linux? If your goal is to have
> actual compiled code that will run in 2038, you will have to build it
> for 64-bit Linux.
Sorry, thats wrong. sizeof (time_t) is 8 on 32 and 64 bit Linux.
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
>
> int main(void) {
> printf("Sizeof(time_t)==%d\n", sizeof(time_t));
> }
> $ uname -ri
> 2.6.23.14-115.fc8 x86_64
> $ gcc test.c -o test
> $ ./test
> Sizeof(time_t)==8
You get exactly the same result on 32 bit linux.
Erik
--
-----------------------------------------------------------------
Erik de Castro Lopo
-----------------------------------------------------------------
"Only wimps use tape backup: *real* men just upload their
important stuff on FTP, and let the rest of the world
mirror it ;)" -- Linus Torvalds
|
|
0
|
|
|
|
Reply
|
erikd (176)
|
2/11/2008 9:37:03 PM
|
|
David Schwartz <davids@webmaster.com> writes:
> On Feb 11, 3:30 am, Aditi <drool.g...@gmail.com> wrote:
>> The application already exists and I have to replace these 32bit time
>> structures with their 64bit equivalents. I have made all the changes
>> and built the application on windows but can't do so on linux because
>> Linux does not seem to have a 64 bit equivalent for time_t , or
>> mktime..
>
> Are you using 32-bit Linux or 64-bit Linux? If your goal is to have
> actual compiled code that will run in 2038, you will have to build it
> for 64-bit Linux. It is not currently possible to make a 32-bit Linux
> kernel or 32-bit Linux applications that will work unmodified after
> 2038.
[...]
It's not *currently* possible, but as far as I know there's no
fundamental reason why 32-bit Linux couldn't be changed to use a
64-bit time_t (it would be a typedef for unsigned long long). Of
course that doesn't do the original poster any good.
On the other hand, it's certainly possible to implement your own
64-bit time type and a mktime-like function that uses it, but it won't
play well with the underlying system.
--
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
|
|
0
|
|
|
|
Reply
|
kst-u (21480)
|
2/11/2008 9:54:15 PM
|
|
Erik de Castro Lopo wrote:
> David Schwartz wrote:
>
>> Are you using 32-bit Linux or 64-bit Linux? If your goal is to have
>> actual compiled code that will run in 2038, you will have to build it
>> for 64-bit Linux.
>
> Sorry, thats wrong. sizeof (time_t) is 8 on 32 and 64 bit Linux.
>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <time.h>
>>
>> int main(void) {
>> printf("Sizeof(time_t)==%d\n", sizeof(time_t));
>> }
>> $ uname -ri
>> 2.6.23.14-115.fc8 x86_64
>> $ gcc test.c -o test
>> $ ./test
>> Sizeof(time_t)==8
>
> You get exactly the same result on 32 bit linux.
Well, I'm running a 32bit Linux, and I get different results
~/code $ uname -ri
2.4.33.3 i386
~/code $ cat t1.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
printf("sizeof(time_t) = %d\n",(int)sizeof(time_t));
return EXIT_SUCCESS;
}
~/code $ gcc -o t1 t1.c
~/code $ ./t1
sizeof(time_t) = 4
~/code $
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
|
|
0
|
|
|
|
Reply
|
lpitcher2 (869)
|
2/12/2008 12:33:27 AM
|
|
On Feb 11, 1:54 pm, Keith Thompson <ks...@mib.org> wrote:
> It's not *currently* possible, but as far as I know there's no
> fundamental reason why 32-bit Linux couldn't be changed to use a
> 64-bit time_t (it would be a typedef for unsigned long long). Of
> course that doesn't do the original poster any good.
> On the other hand, it's certainly possible to implement your own
> 64-bit time type and a mktime-like function that uses it, but it won't
> play well with the underlying system.
You can fix your source code, but you cannot compile it today and have
it work in 2039.
FWIW, the industry consensus is that it is too early to work on the
year 2038 problem. I disagree and have publically argued for a 64-bit
time interface on 32-bit operating systems since at least 2003.
Quoting myself from that time:
"I've proposed both a time64_t solution (with corresponding time64/
mktime64 functions), including a method to cause these types/functions
to replace the defaults. I've also proposed an alternate
assumptionless interface (one where all the time types are opaque
except
structures).
But the world seems to be at an impasse. The opposition to my
suggestions is that any code that is broken by a switch to a 64-bit
time_t is broken already, and that therefore the 'right' solution is
to switch to a 64-bit time_t. The opposition to that suggestion is
that it will cause needless pain and hurt performance. So we're at a
stalemate, waiting for
2038 to get here, while code that needs to manipulate future times has
to be made clumsy and we're writing and compiling code today that we
know we'll have to at least recompile. *sigh*"
DS
|
|
0
|
|
|
|
Reply
|
David
|
2/12/2008 3:15:07 AM
|
|
David Schwartz <davids@webmaster.com> writes:
>FWIW, the industry consensus is that it is too early to work on the
>year 2038 problem. I disagree and have publically argued for a 64-bit
>time interface on 32-bit operating systems since at least 2003.
I think I agree.
>Quoting myself from that time:
>"I've proposed both a time64_t solution (with corresponding time64/
>mktime64 functions), including a method to cause these types/functions
>to replace the defaults. I've also proposed an alternate
>assumptionless interface (one where all the time types are opaque
>except structures).
>But the world seems to be at an impasse. The opposition to my
>suggestions is that any code that is broken by a switch to a 64-bit
>time_t is broken already, and that therefore the 'right' solution is
>to switch to a 64-bit time_t. The opposition to that suggestion is
>that it will cause needless pain and hurt performance. So we're at a
>stalemate, waiting for
>2038 to get here, while code that needs to manipulate future times has
>to be made clumsy and we're writing and compiling code today that we
>know we'll have to at least recompile. *sigh*"
I don't think it's quite as easy as doing the "64 bit file offsets"
as so many structures in UNIX embed a time_t or some time value someplace.
But if people need to recompile, which they will, why not just recompile
for 64 bits and be done with it?
There's not a lot of impetus to fix 32 bit computing when mainstream
computing is already predominantly 64 bit.
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
|
|
0
|
|
|
|
Reply
|
Casper.Dik (623)
|
2/12/2008 9:29:02 AM
|
|
David Schwartz <davids@webmaster.com> writes:
>On Feb 11, 1:54 pm, Keith Thompson <ks...@mib.org> wrote:
>
>> It's not *currently* possible, but as far as I know there's no
>> fundamental reason why 32-bit Linux couldn't be changed to use a
>> 64-bit time_t (it would be a typedef for unsigned long long). Of
>> course that doesn't do the original poster any good.
>
>> On the other hand, it's certainly possible to implement your own
>> 64-bit time type and a mktime-like function that uses it, but it won't
>> play well with the underlying system.
>
>You can fix your source code, but you cannot compile it today and have
>it work in 2039.
>
>FWIW, the industry consensus is that it is too early to work on the
>year 2038 problem. I disagree and have publically argued for a 64-bit
>time interface on 32-bit operating systems since at least 2003.
By 2038 there will be _no_ 32-bit operating systems left outside of
museums.
scott
|
|
0
|
|
|
|
Reply
|
scott
|
2/12/2008 9:06:35 PM
|
|
On Feb 12, 1:06 pm, sc...@slp53.sl.home (Scott Lurndal) wrote:
> By 2038 there will be _no_ 32-bit operating systems left outside of
> museums.
8-bit CPUs were replaced by 16-bit CPUs in 1980 the same way 64-bit
CPUs are now replacing 32-bit CPUs. 28 years later, more than 20
manufacturers still make 8-bit CPUs in significant quantities. If 8-
bit CPUs are still going strong after 28 years, what makes you think
32-bit CPUs will become museum pieces in 30?
It comes down to whether 32-bit CPUs are going to stick around, like 8-
bit CPUs did, or die a fast and horrible death, like 16-bit CPUs did.
I think they will die rather quickly because the circumstances that
keep 8-bit CPUs around are, IMO, fairly unique (lots of applications
that don't need high performance, so no reason to upgrade). But it's
dangerous to gamble.
DS
|
|
0
|
|
|
|
Reply
|
David
|
2/13/2008 12:41:18 AM
|
|
|
8 Replies
65 Views
(page loaded in 0.164 seconds)
Similiar Articles: convert inline gcc asm to Visual c++ - comp.lang.asm.x86 ...... whatsoever, can someone please tell me what the equivalent ... find a fixed point arithmetic > package for real-time Linux. ... Group GNU C compiler i ... Trouble converting VC ... help: gcc asm-> vc++ asm - comp.lang.asm.x86... anaylitics (for both Linux and Windows on 32 and 64 bit). ... manner between 32 and 64 bit compilers but i haven't found if GCC has an equivalent ... Trouble converting VC ... Unable to compile CUDA mex in Matlab R2010a 64bit CUDA - comp.soft ...I'm using: MATLAB R2010b 64-bit MSVC 8.0 (2005 ... Program Files (x86)\Microsoft Visual Studio 8\VC\INCLUDE\math.h ... Privacy Policy | All Times Are GMT(UTC) | powered by MEX in Matlab 7.10, 64 bit, Windows 7 - comp.soft-sys.matlab ...... Program Files (x86)\Microsoft Visual Studio 9.0\VC ... MEX file cannot find entry point in 64-bit linux - comp.soft ... Privacy Policy | All Times Are GMT(UTC) | powered by Re: Using SSE 128 bit movs From One Memory Location To Another ...// gcc -std=3Dc99 -o cmagic cmagic.c // --- #include <time.h ... dFITS -f elf32 -o magic.o magic.asm ; ld -I/lib/ld-linux ... Using C and Assembly code: 64Bit Calling convention ... 64 bit integer - comp.lang.c++.moderated> I think VC will do this also with some ... should both compile under 32bit and 64bit linux on ... C99 requires support for at least 64-bit integers, | so making time_t 64 ... Compiler warnings assoc. with 'fileno' being deprecated on Windows ...c:\program files\microsoft visual studio 8\vc\include\stdio.h ... x86, >PPC) and OS's (XP, RHEL 5, Wind River Linux ... changing the definition of the ACE_FILENO_EQUIVALENT ... Compilation error with C++ mex file - comp.soft-sys.matlab ...MEX file cannot find entry point in 64-bit linux - comp ... Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\comdef.h ... Privacy Policy | All Times Are GMT(UTC) | powered ... C++ compiler for mex - comp.soft-sys.matlab... Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h(576 ... MATLAB R2010b 64-bit MSVC 8.0 (2005) with 64-bit ... 64bit linux, mex, Fortran, and -largeArrayDims - comp ... SuperKISS for 32- and 64-bit RNGs in both C and Fortran. - comp ...... have dedicated their efforts and computer time to ... get the expected output from gcc 4.4.1 on 64-bit Intel Linux. ... with your compilers, or if you can > provide equivalent ... 64bit equivalent of VC++ time.h on linux?64bit equivalent of VC++ time.h on linux? - Unix . This is a discussion on 64bit equivalent of VC++ time.h on linux? - Unix; I am working around a problem called ... 64bit equivalent of VC++ time.h on linux? - C / C++64bit equivalent of VC++ time.h on linux?. C / C++ Forums on Bytes. 7/26/2012 11:59:01 PM
|