All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Chépied" <cedric.chepied@drotek.com>
To: xenomai@lists.linux.dev
Subject: Posix timer creation failure
Date: Tue, 16 Apr 2024 11:49:51 +0200	[thread overview]
Message-ID: <661e49af.df0a0220.ffef6.a7bc@mx.google.com> (raw)

Hi all,

I'm trying to execute a simple posix timer example (see code below). When I
compile it "normally", it works fine but when I add xeno-config generated flags
(to add RT tasks later) the create_timer function fails (invalid argument).

Can somebody tell me what I am doing wrong please ?
I'm running it on a 32 bit arm (imx6), could it be the "-D_TIME_BITS=64
-D_FILE_OFFSET_BITS=64" options ?

Thanks,


Here is the code :

static unsigned int pass_value_by_pointer = 42;

void Timer_has_expired(union sigval timer_data)
{
	printf("Timer expiration handler function; %d\n",
	       *(int*) timer_data.sival_ptr);
}

int main(void)
{
	struct sigevent timer_signal_event;
	timer_t timer;

	struct itimerspec timer_period;

	printf("Create timer\n");
	timer_signal_event.sigev_notify = SIGEV_THREAD;
	timer_signal_event.sigev_notify_function = Timer_has_expired;
	timer_signal_event.sigev_value.sival_ptr =
	    (void*) &pass_value_by_pointer; // as will this (both in a structure)
	timer_signal_event.sigev_notify_attributes = NULL;
	int ret = timer_create(CLOCK_MONOTONIC, &timer_signal_event, &timer);

	if (ret)
	{
		perror("timer_create");
		exit(EXIT_FAILURE);
	}

	printf("Start timer\n");
	timer_period.it_value.tv_sec = 1; // 1 second timer
	timer_period.it_value.tv_nsec = 0; // no nano-seconds
	timer_period.it_interval.tv_sec = 0; // non-repeating timer
	timer_period.it_interval.tv_nsec = 0;

	timer_settime(timer, 0, &timer_period, NULL);
	sleep(2);

	printf("----------------------------\n");
	printf("Start timer a second time\n");
	timer_settime(timer, 0, &timer_period, NULL);
	sleep(2);

	printf("----------------------------\n");
	printf("Start timer a third time\n");
	timer_settime(timer, 0, &timer_period, NULL);

	printf("Cancel timer\n");
	timer_delete(timer);
	sleep(2);
	printf(
	    "The timer expiration handler function should not have been called\n");

	return EXIT_SUCCESS;
}


Here are compilation flags :

sdk/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc   -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi   -O2 -pipe -g -feliminate-unused-debug-types  -Isdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/include/xenomai/cobalt -Isdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/include/xenomai -O2 -pipe -g -feliminate-unused-debug-types -fmacro-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi= -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi-native= -D_GNU_SOURCE -D_REENTRANT -fasynchronous-unwind-tables -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -D__COBALT__ -Isdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/include/xenomai/alchemy -MD -MT CMakeFiles/timer.dir/timer.c.o -MF CMakeFiles/timer.dir/timer.c.o.d -o CMakeFiles/timer.dir/timer.c.o -c Tests/posixTimer/timer.c

sdk/sysroots/x86_64-fslcsdk-linux/usr/bin/arm-fslc-linux-gnueabi/arm-fslc-linux-gnueabi-gcc   -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi --sysroot=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi  -O2 -pipe -g -feliminate-unused-debug-types  -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed  -Wl,-z,relro,-z,now -Wl,--no-as-needed -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/modechk.wrappers -lalchemy -lcopperplate sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/xenomai/bootstrap.o -Wl,--wrap=main -Wl,--dynamic-list=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/dynlist.ld -Lsdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib -lcobalt -lmodechk -lpthread -lrt -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fmacro-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=/workdir/build/tmp/work/cortexa7t2hf-neon-fslc-linux-gnueabi/xenomai/3.2.4-r0=/usr/src/debug/xenomai/3.2.4-r0 -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi= -fdebug-prefix-map=sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi-native= -Wl,-z,relro,-z,now -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/cobalt.wrappers -Wl,@sdk/sysroots/cortexa7t2hf-neon-fslc-linux-gnueabi/usr/lib/cobalt-glibc-time64.wrappers CMakeFiles/timer.dir/timer.c.o -o timer 


-- 
Cédric Chépied
<cedric.chepied@drotek.com>

<http://events.drotek.com/>

             reply	other threads:[~2024-04-16  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16  9:49 Cédric Chépied [this message]
2024-04-16 14:06 ` Posix timer creation failure Cédric Chépied

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=661e49af.df0a0220.ffef6.a7bc@mx.google.com \
    --to=cedric.chepied@drotek.com \
    --cc=xenomai@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.