[Bug 273085] clock_gettime(CLOCK_MONOTONIC_COARSE, *struct timespec) fails with 32bit program on 64bit machine

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 12 Aug 2023 15:17:59 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273085

            Bug ID: 273085
           Summary: clock_gettime(CLOCK_MONOTONIC_COARSE, *struct
                    timespec) fails with 32bit program on 64bit machine
           Product: Base System
           Version: 13.2-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: minsoochoo0122@proton.me

$ cat main.c
#include <stdio.h>
#include <time.h>

int main() {
  struct timespec ts;

  for (int i = 0; i < 100; ++i) {
    clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
    printf("%d %ld\n", ts.tv_sec, ts.tv_nsec);
  }
  return 0;
}

$ cc -m32 main.c
$ ./a.out
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
-1 318747501
....


This happens when building the program as 32bit executable on 64bit FreeBSD and
run the executable on 64bit FreeBSD.

-- 
You are receiving this mail because:
You are the assignee for the bug.