Bug 273086 - clock_gettime(CLOCK_MONOTONIC_COARSE, *struct timespec) fails with 32bit program on 64bit machine
Summary: clock_gettime(CLOCK_MONOTONIC_COARSE, *struct timespec) fails with 32bit prog...
Status: Closed DUPLICATE of bug 273085
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.2-RELEASE
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-12 15:18 UTC by Minsoo Choo
Modified: 2023-08-12 15:35 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Minsoo Choo 2023-08-12 15:18:13 UTC
$ 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.
Comment 1 Mina Galić freebsd_triage 2023-08-12 15:35:29 UTC

*** This bug has been marked as a duplicate of bug 273085 ***