Single-board computer software development discussions
 help / color / mirror / Atom feed
* [devel-sbc] mktime на RPi
@ 2021-03-08  9:20 Vladislav Zavjalov
  2021-03-08  9:42 ` [devel-sbc] mktime на RPiк Vladislav Zavjalov
  0 siblings, 1 reply; 2+ messages in thread
From: Vladislav Zavjalov @ 2021-03-08  9:20 UTC (permalink / raw)
  To: devel-sbc

Привет!

Пытался собрать под RPi одну свою программу, обнаружил, что не проходит
один из тестов. В результате разбирательства столкнулся с какой-то совсем
уж странной вещью. Наверняка что-то простое и глупое, чего я не замечаю.

RPi4, Сизиф (обновился сегодня), aarch64, ядро 5.10.10-un-def-alt1

Минимальная программа:
-----
#include <time.h>
#include <stdint.h>
#include <stdio.h>

int
main() {
  struct tm ts;
  ts.tm_year = 120;
  ts.tm_mon  = 1;
  ts.tm_mday = 2;
  ts.tm_hour  = 1;
  ts.tm_min   = 0;
  ts.tm_sec   = 0;
  ts.tm_isdst   = 1;

  int64_t t0 = mktime(&ts);
  printf("%ld\n", t0);
  return 0;
}
-----

Результат выполнениия на x86_64:
$ make test_mktime
cc     test_mktime.c   -o test_mktime
$ ./test_mktime
1580601600

На RPi:
$ make test_mktime
cc     test_mktime.c   -o test_mktime
$ ./test_mktime
-1

Системное время везде установлено правильно.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [devel-sbc] mktime на RPiк
  2021-03-08  9:20 [devel-sbc] mktime на RPi Vladislav Zavjalov
@ 2021-03-08  9:42 ` Vladislav Zavjalov
  0 siblings, 0 replies; 2+ messages in thread
From: Vladislav Zavjalov @ 2021-03-08  9:42 UTC (permalink / raw)
  To: devel-sbc

Пока выяснил, что поведение отличается только при положительном ts.tm_isdst.
(Наверное, в реальной жизни это обычно и не нужно, и у меня ts.tm_isdst=1 надо
менять на -1. Но интересно, что такое отличие наблюдается.)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-08  9:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08  9:20 [devel-sbc] mktime на RPi Vladislav Zavjalov
2021-03-08  9:42 ` [devel-sbc] mktime на RPiк Vladislav Zavjalov

Single-board computer software development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel-sbc/0 devel-sbc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel-sbc devel-sbc/ http://lore.altlinux.org/devel-sbc \
		devel-sbc@lists.altlinux.org devel-sbc@lists.altlinux.ru devel-sbc@lists.altlinux.com
	public-inbox-index devel-sbc

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel-sbc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git