Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in NVidia Orin aarm64 with time.now( ) function returning empty struct time.Time, but libc.time( ) returning correct time. #4588

Open
joaocarvalhoopen opened this issue Dec 17, 2024 · 0 comments

Comments

@joaocarvalhoopen
Copy link

Hello,

I beleave I have found an bug, this is for aarm64 on NVidia Orin 64 GB on Linux Ubuntu from the NVidia.

The Nvidia Orim, each core is similar to a CPU core of a Raspberry Pi 5.

The used version of Odin in this NVidia Orin is :

odin version dev-2024-10

I'm trying to give a date the name of a file and for that I'm using the function time.now() to get the date but it returns the empty struct.

current_time_instant : time.Time = time.now( )

str_time_h_m_s, _ := strings.replace_all(
                                        time.to_string_hms( current_time_instant, buf_time[ : ] ),
                                        ":",      // Replace this.
                                        "-"  )    // By this. 

But the time.now( ) returns always the empty struct value. That is zero, that corresponds to the day zero of 1970 UNIX time.

And the when I run the date command in the shell I see the correct date 2024_12, so it's not a problem of the date inside this computer.

I have seen the code inside time.now() but it calls a

core:time/time_linux.odin


_now :: proc "contextless" () -> Time {
   time_spec_now, _ := linux.clock_gettime(.REALTIME)
   ns := time_spec_now.time_sec * 1e9 + time_spec_now.time_nsec
   return Time{_nsec=i64(ns)}
}

I have substituted .REALTIME with other identifiers without success.


core:sys/linux/sys.odin

/*
   Retrieve the time of the specified clock.
   Available since Linux 2.6.
*/
clock_gettime :: proc "contextless" (clock: Clock_Id) -> (ts: Time_Spec, err: Errno) {
   ret := syscall(SYS_clock_gettime, clock, &ts)
   err = Errno(-ret)
   return
}

core:sys/linux/sys_call_amd64.odin

SYS_clock_gettime           :: uintptr(228)


core:sys/linux/sys_call_arm64.odin

SYS_clock_gettime           :: uintptr(113)


/*
        Clock IDs for various system clocks.
*/
Clock_Id :: enum {
        REALTIME           = 0,
        MONOTONIC          = 1,
        PROCESS_CPUTIME_ID = 2,
        THREAD_CPUTIME_ID  = 3,
        MONOTONIC_RAW      = 4,
        REALTIME_COARSE    = 5,
        MONOTONIC_COARSE   = 6,
        BOOTTIME           = 7,
        REALTIME_ALARM     = 8,
        BOOTTIME_ALARM     = 9,
}

NOTE_0 : I tryed to copy to my program the previous function and change the .REALTIME enum label to others to see if I could make them work, and could not make them work either.

NOTE_1 : If I use the libc.time() and then convert seconds to nanoseconds and fill the time.Time structure (with a transmute ) all my rest program works well. So I believe that there isn't any error on my program.

NOTE_2 : zen3ger on the Odin forum said the following that can also be important:

" zen3ger
I found a couple nvidia forum posts regarding CLOCK_REALTIME, so it could be they have a silently patched libc to get it working. "

Best regards and have a nice day,
Joao Carvalho

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant