* [Xenomai-help] how to build a Xenomai posix library ? @ 2008-10-14 13:21 roderik.wildenburg 2008-10-14 13:35 ` Gilles Chanteperdrix 0 siblings, 1 reply; 9+ messages in thread From: roderik.wildenburg @ 2008-10-14 13:21 UTC (permalink / raw) To: xenomai I´ve built a library which includes Xenomai posix functions. If a "customer" wants to use this library (links the library to his project) he unfortunately has to define all the wrappers for the posix functions I used within the library. Is this a general limitation when using posix in a library or do I simply not know how to build a proper Xenomai-library. Is there a posibility to avoid the wrapers so the user simply has to link the library and needn´t to define anyhing else (just -lxenolib) ? Thank you in advance for your help Roderik Achtung: Neue E-Mail-Adresse! Attention: New e-mail-address! roderik.wildenburg@domain.hid -------------------------------------------------------- manroland AG Vorsitzender des Aufsichtsrates: Hanno C. Fiedler Vorstand: Gerd Finkbeiner (Vorsitzender), Dr. Ingo Koch, Dr. Markus Rall, Paul Steidle Sitz der Gesellschaft: Offenbach am Main, Registergericht: Amtsgericht Offenbach HRB-Nr. 42592 USt-Ident-Nr. DE 250200933 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] how to build a Xenomai posix library ? 2008-10-14 13:21 [Xenomai-help] how to build a Xenomai posix library ? roderik.wildenburg @ 2008-10-14 13:35 ` Gilles Chanteperdrix 2008-10-16 9:36 ` roderik.wildenburg 0 siblings, 1 reply; 9+ messages in thread From: Gilles Chanteperdrix @ 2008-10-14 13:35 UTC (permalink / raw) To: roderik.wildenburg; +Cc: xenomai roderik.wildenburg@domain.hid wrote: > I´ve built a library which includes Xenomai posix functions. > If a "customer" wants to use this library (links the library to his > project) he unfortunately has to define all the wrappers for the > posix functions I used within the library. Is this a general > limitation when using posix in a library or do I simply not know how > to build a proper Xenomai-library. Is there a posibility to avoid the > wrapers so the user simply has to link the library and needn´t to > define anyhing else (just -lxenolib) ? > > Thank you in advance for your help Roderik It is a limitation that comes from using ld --wrap option. Unfortunately, we really have no other mean to achieve compliance with the posix interface, especially since Xenomai posix library needs symbols from the libc libpthread library. In a near future, it will be possible to directly call xenomai posix library services without using the --wrap trick. Only, you will have to prefix them or postfix them. Actually, you can already do that by calling directly __wrap_service instead of service. Another way to solve your issue is to ship your library with a shell script much like xeno-config which generates the correct flags. You can probably do what we have not done for xenomai: use the pkg-config package. This approach is used for many libraries nowadays. -- Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] how to build a Xenomai posix library ? 2008-10-14 13:35 ` Gilles Chanteperdrix @ 2008-10-16 9:36 ` roderik.wildenburg 2008-10-16 9:48 ` Gilles Chanteperdrix 0 siblings, 1 reply; 9+ messages in thread From: roderik.wildenburg @ 2008-10-16 9:36 UTC (permalink / raw) To: xenomai > > I´ve built a library which includes Xenomai posix functions. > > If a "customer" wants to use this library (links the library to his > > project) he unfortunately has to define all the wrappers for the > > posix functions I used within the library. Is this a general > > limitation when using posix in a library or do I simply not know how > > to build a proper Xenomai-library. Is there a posibility to > avoid the > > wrapers so the user simply has to link the library and needn´t to > > define anyhing else (just -lxenolib) ? > > > > Thank you in advance for your help Roderik > > It is a limitation that comes from using ld --wrap option. > Unfortunately, we really have no other mean to achieve compliance with > the posix interface, especially since Xenomai posix library needs > symbols from the libc libpthread library. > > In a near future, it will be possible to directly call xenomai posix > library services without using the --wrap trick. Only, you > will have to > prefix them or postfix them. Actually, you can already do that by > calling directly __wrap_service instead of service. I did so and called, within the library, every posix_rt-function with the prefix __wrap_ : e.g. __wrap_shm_open then I compiled my application, which does not use any Xenomai-function, and linked it with pthread_rt an rt (-lpthread_rt -lrt) and my new Xenomai-library (linking without any wrapping defined). Linking and compiling did not produce any error. But, when I call a function in my library, which in turn calls __wrap_shm_open, then shm_open fails. When I link my application with wrapping (as provided by the XENO_CONFIG-script) then everything is fine. Do you have an explanation for this behavior or even better a solution ? > > Another way to solve your issue is to ship your library with a shell > script much like xeno-config which generates the correct > flags. You can > probably do what we have not done for xenomai: use the pkg-config > package. This approach is used for many libraries nowadays. > Achtung: Neue E-Mail-Adresse! Attention: New e-mail-address! roderik.wildenburg@domain.hid -------------------------------------------------------- manroland AG Vorsitzender des Aufsichtsrates: Hanno C. Fiedler Vorstand: Gerd Finkbeiner (Vorsitzender), Dr. Ingo Koch, Dr. Markus Rall, Paul Steidle Sitz der Gesellschaft: Offenbach am Main, Registergericht: Amtsgericht Offenbach HRB-Nr. 42592 USt-Ident-Nr. DE 250200933 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] how to build a Xenomai posix library ? 2008-10-16 9:36 ` roderik.wildenburg @ 2008-10-16 9:48 ` Gilles Chanteperdrix 2008-10-16 10:14 ` roderik.wildenburg 0 siblings, 1 reply; 9+ messages in thread From: Gilles Chanteperdrix @ 2008-10-16 9:48 UTC (permalink / raw) To: roderik.wildenburg; +Cc: xenomai roderik.wildenburg@domain.hid wrote: > I did so and called, within the library, every posix_rt-function with > the prefix __wrap_ : e.g. __wrap_shm_open then I compiled my > application, which does not use any Xenomai-function, and linked it > with pthread_rt an rt (-lpthread_rt -lrt) and my new Xenomai-library > (linking without any wrapping defined). Linking and compiling did not > produce any error. But, when I call a function in my library, which > in turn calls __wrap_shm_open, then shm_open fails. When I link my > application with wrapping (as provided by the XENO_CONFIG-script) > then everything is fine. Do you have an explanation for this behavior > or even better a solution ? __wrap_shm_open only works if you have the CONFIG_XENO_OPT_POSIX_SHM option enabled. Is it enabled? Note that xenomai posix skin shm support is mainly useful for sharing memory between kernel and user-space. If it is enabled, then please tell us what is the value of errno when __wrap_shm_open fails. -- Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] how to build a Xenomai posix library ? 2008-10-16 9:48 ` Gilles Chanteperdrix @ 2008-10-16 10:14 ` roderik.wildenburg 2008-10-16 12:14 ` Gilles Chanteperdrix 0 siblings, 1 reply; 9+ messages in thread From: roderik.wildenburg @ 2008-10-16 10:14 UTC (permalink / raw) To: xenomai > -----Ursprüngliche Nachricht----- > Von: Gilles Chanteperdrix [mailto:gilles.chanteperdrix@xenomai.org > Gesendet: Donnerstag, 16. Oktober 2008 11:48 > An: Wildenburg, Roderik RAEK3 MRA > Cc: xenomai@xenomai.org > Betreff: Re: [Xenomai-help] how to build a Xenomai posix library ? > > roderik.wildenburg@domain.hid wrote: > > I did so and called, within the library, every > posix_rt-function with > > the prefix __wrap_ : e.g. __wrap_shm_open then I compiled my > > application, which does not use any Xenomai-function, and linked it > > with pthread_rt an rt (-lpthread_rt -lrt) and my new Xenomai-library > > (linking without any wrapping defined). Linking and > compiling did not > > produce any error. But, when I call a function in my library, which > > in turn calls __wrap_shm_open, then shm_open fails. When I link my > > application with wrapping (as provided by the XENO_CONFIG-script) > > then everything is fine. Do you have an explanation for > this behavior > > or even better a solution ? > > __wrap_shm_open only works if you have the CONFIG_XENO_OPT_POSIX_SHM > option enabled. Is it enabled? yes it is : CONFIG_XENO_OPT_POSIX_SHM=y otherwise, I think, my application linked with wrappings defined wouldn´t work ? But it does. > Note that xenomai posix skin shm support > is mainly useful for sharing memory between kernel and > user-space. O.k., I just want to share SHM between applications. What SHM construct should I use instead ? > If it is enabled, then please tell us what is the value of errno when > __wrap_shm_open fails. > shm_open fails. errno=2 shm_open fails : : No such file or directory I don´t know what this should mean ?? I call shm_open in the following way : #define LOGSHMNAME "/var/logshm" oflags=O_RDWR; *shmfd = shm_open(LOGSHMNAME, oflags, 0); Again, linking my application with all the wrappers defined builds a well working application. So, for me, the SHM-constructs are o.K., but linking builds different applications, depending on the wrappers. Here is the console output of linking without wrappers: ppc-linux-gcc -I/opt/eldk/xenomai/include -I/opt/eldk/xenomai/include/posix -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -g -Wall pecomlog.c -c -o pecomlog.o ppc-linux-gcc -L/opt/eldk/xenomai/lib -lpthread_rt -lrt -Wall -o pecomlog pecomlog.o loglib.a where loglib.a is my new Xenomay library and pecomlog is my application. many thanks for your help ! Achtung: Neue E-Mail-Adresse! Attention: New e-mail-address! roderik.wildenburg@domain.hid -------------------------------------------------------- manroland AG Vorsitzender des Aufsichtsrates: Hanno C. Fiedler Vorstand: Gerd Finkbeiner (Vorsitzender), Dr. Ingo Koch, Dr. Markus Rall, Paul Steidle Sitz der Gesellschaft: Offenbach am Main, Registergericht: Amtsgericht Offenbach HRB-Nr. 42592 USt-Ident-Nr. DE 250200933 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] how to build a Xenomai posix library ? 2008-10-16 10:14 ` roderik.wildenburg @ 2008-10-16 12:14 ` Gilles Chanteperdrix 2008-10-16 12:34 ` roderik.wildenburg 0 siblings, 1 reply; 9+ messages in thread From: Gilles Chanteperdrix @ 2008-10-16 12:14 UTC (permalink / raw) To: roderik.wildenburg; +Cc: xenomai roderik.wildenburg@domain.hid wrote: >> -----Ursprüngliche Nachricht----- >> Von: Gilles Chanteperdrix [mailto:gilles.chanteperdrix@xenomai.org] >> Gesendet: Donnerstag, 16. Oktober 2008 11:48 >> An: Wildenburg, Roderik RAEK3 MRA >> Cc: xenomai@xenomai.org >> Betreff: Re: [Xenomai-help] how to build a Xenomai posix library ? >> >> roderik.wildenburg@domain.hid wrote: >>> I did so and called, within the library, every >> posix_rt-function with >>> the prefix __wrap_ : e.g. __wrap_shm_open then I compiled my >>> application, which does not use any Xenomai-function, and linked it >>> with pthread_rt an rt (-lpthread_rt -lrt) and my new Xenomai-library >>> (linking without any wrapping defined). Linking and >> compiling did not >>> produce any error. But, when I call a function in my library, which >>> in turn calls __wrap_shm_open, then shm_open fails. When I link my >>> application with wrapping (as provided by the XENO_CONFIG-script) >>> then everything is fine. Do you have an explanation for >> this behavior >>> or even better a solution ? >> __wrap_shm_open only works if you have the CONFIG_XENO_OPT_POSIX_SHM >> option enabled. Is it enabled? > > yes it is : > CONFIG_XENO_OPT_POSIX_SHM=y > otherwise, I think, my application linked with wrappings defined wouldn´t work ? But it does. > >> Note that xenomai posix skin shm support >> is mainly useful for sharing memory between kernel and >> user-space. > O.k., I just want to share SHM between applications. What SHM construct should I use instead ? > >> If it is enabled, then please tell us what is the value of errno when >> __wrap_shm_open fails. >> > > shm_open fails. errno=2 > shm_open fails : : No such file or directory > > I don´t know what this should mean ?? Well, it means that the shared memory does not exist. > I call shm_open in the following way : > #define LOGSHMNAME "/var/logshm" > oflags=O_RDWR; > *shmfd = shm_open(LOGSHMNAME, oflags, 0); a shm name should contain one slash at the beginning and no other slash, for best portability. If you want to create a shared memory, you should pass the O_CREAT flag. This is all documented here: http://www.xenomai.org/documentation/trunk/html/api/group__posix__shm.html#gf765a0fa9152fbf874436c966f3af7ba -- Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] how to build a Xenomai posix library ? 2008-10-16 12:14 ` Gilles Chanteperdrix @ 2008-10-16 12:34 ` roderik.wildenburg 2008-10-16 12:41 ` Gilles Chanteperdrix 0 siblings, 1 reply; 9+ messages in thread From: roderik.wildenburg @ 2008-10-16 12:34 UTC (permalink / raw) To: xenomai > >> roderik.wildenburg@domain.hid wrote: > >>> I did so and called, within the library, every > >> posix_rt-function with > >>> the prefix __wrap_ : e.g. __wrap_shm_open then I compiled my > >>> application, which does not use any Xenomai-function, and > linked it > >>> with pthread_rt an rt (-lpthread_rt -lrt) and my new > Xenomai-library > >>> (linking without any wrapping defined). Linking and > >> compiling did not > >>> produce any error. But, when I call a function in my > library, which > >>> in turn calls __wrap_shm_open, then shm_open fails. When I link my > >>> application with wrapping (as provided by the XENO_CONFIG-script) > >>> then everything is fine. Do you have an explanation for > >> this behavior > >>> or even better a solution ? > >> __wrap_shm_open only works if you have the > CONFIG_XENO_OPT_POSIX_SHM > >> option enabled. Is it enabled? > > > > yes it is : > > CONFIG_XENO_OPT_POSIX_SHM=y > > otherwise, I think, my application linked with wrappings > defined wouldn´t work ? But it does. > > > >> Note that xenomai posix skin shm support > >> is mainly useful for sharing memory between kernel and > >> user-space. > > O.k., I just want to share SHM between applications. What > SHM construct should I use instead ? > > > >> If it is enabled, then please tell us what is the value of > errno when > >> __wrap_shm_open fails. > >> > > > > shm_open fails. errno=2 > > shm_open fails : : No such file or directory > > > > I don´t know what this should mean ?? > > Well, it means that the shared memory does not exist. I am quite shure that it exist. It is created by an other process. Is there a /proc-entry or something else which lists existing shared memories ? > > > I call shm_open in the following way : > > #define LOGSHMNAME "/var/logshm" > > oflags=O_RDWR; > > *shmfd = shm_open(LOGSHMNAME, oflags, 0); > > a shm name should contain one slash at the beginning and no > other slash, > for best portability. As I expected, reducing the number of slashes to one does not change the behavior. > If you want to create a shared memory, you should pass the > O_CREAT flag. As mentioned above, an other process creates the shared memory. What I still don´t understand is, what influence the wrapper defines have on linking. With wrappers : aplication works fine. Without wrappers : application does not work !? Roderik Achtung: Neue E-Mail-Adresse! Attention: New e-mail-address! roderik.wildenburg@domain.hid -------------------------------------------------------- manroland AG Vorsitzender des Aufsichtsrates: Hanno C. Fiedler Vorstand: Gerd Finkbeiner (Vorsitzender), Dr. Ingo Koch, Dr. Markus Rall, Paul Steidle Sitz der Gesellschaft: Offenbach am Main, Registergericht: Amtsgericht Offenbach HRB-Nr. 42592 USt-Ident-Nr. DE 250200933 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] how to build a Xenomai posix library ? 2008-10-16 12:34 ` roderik.wildenburg @ 2008-10-16 12:41 ` Gilles Chanteperdrix 2008-10-17 9:58 ` [Xenomai-help] how to build a Xenomai posix library ? solved roderik.wildenburg 0 siblings, 1 reply; 9+ messages in thread From: Gilles Chanteperdrix @ 2008-10-16 12:41 UTC (permalink / raw) To: roderik.wildenburg; +Cc: xenomai roderik.wildenburg@domain.hid wrote: >>>> roderik.wildenburg@domain.hid wrote: >>> *shmfd = shm_open(LOGSHMNAME, oflags, 0); >> a shm name should contain one slash at the beginning and no >> other slash, >> for best portability. > > As I expected, reducing the number of slashes to one does not change the behavior. I never said it would. > >> If you want to create a shared memory, you should pass the >> O_CREAT flag. > > As mentioned above, an other process creates the shared memory. Is it also linked with xenomai posix skin? > What I still don´t understand is, what influence the wrapper defines have on linking. > With wrappers : aplication works fine. Without wrappers : application does not work !? I would say that with wrappers, you are in fact using the vanilla linux shared memory, by passing __wrap_shm_open, you really use xenomai posix skin services. If that is the case, when using the wrapped version, you should see the shared memory appear under /dev/shm. -- Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] how to build a Xenomai posix library ? solved 2008-10-16 12:41 ` Gilles Chanteperdrix @ 2008-10-17 9:58 ` roderik.wildenburg 0 siblings, 0 replies; 9+ messages in thread From: roderik.wildenburg @ 2008-10-17 9:58 UTC (permalink / raw) To: xenomai Just for information : in my new xenomai library I wraped shm_open (->__wrap_shm_open) shm_inlink (->__wrap_unlink) and so on (all symbols I´ve got a "unresolved" for). Unfortunatelly I did not get a "unresolved" for ftruncate and mmap, so I didn´t wraped them. Wrapping these symbols solved my problem (library is linkable without wrapers defined and the application linked with my new library works fine). Thank you Gilles for your support ! Roderik > -----Ursprüngliche Nachricht----- > Von: Gilles Chanteperdrix [mailto:gilles.chanteperdrix@xenomai.org > Gesendet: Donnerstag, 16. Oktober 2008 14:42 > An: Wildenburg, Roderik RAEK3 MRA > Cc: xenomai@xenomai.org > Betreff: Re: [Xenomai-help] how to build a Xenomai posix library ? > > roderik.wildenburg@domain.hid wrote: > >>>> roderik.wildenburg@domain.hid wrote: > >>> *shmfd = shm_open(LOGSHMNAME, oflags, 0); > >> a shm name should contain one slash at the beginning and no > >> other slash, > >> for best portability. > > > > As I expected, reducing the number of slashes to one does > not change the behavior. > > I never said it would. > > > > >> If you want to create a shared memory, you should pass the > >> O_CREAT flag. > > > > As mentioned above, an other process creates the shared memory. > > Is it also linked with xenomai posix skin? > > > What I still don´t understand is, what influence the > wrapper defines have on linking. > > With wrappers : aplication works fine. Without wrappers : > application does not work !? > > I would say that with wrappers, you are in fact using the > vanilla linux > shared memory, by passing __wrap_shm_open, you really use > xenomai posix > skin services. > > If that is the case, when using the wrapped version, you > should see the > shared memory appear under /dev/shm. > > -- > Gilles. > Achtung: Neue E-Mail-Adresse! Attention: New e-mail-address! roderik.wildenburg@domain.hid -------------------------------------------------------- manroland AG Vorsitzender des Aufsichtsrates: Hanno C. Fiedler Vorstand: Gerd Finkbeiner (Vorsitzender), Dr. Ingo Koch, Dr. Markus Rall, Paul Steidle Sitz der Gesellschaft: Offenbach am Main, Registergericht: Amtsgericht Offenbach HRB-Nr. 42592 USt-Ident-Nr. DE 250200933 ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-10-17 9:58 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-10-14 13:21 [Xenomai-help] how to build a Xenomai posix library ? roderik.wildenburg 2008-10-14 13:35 ` Gilles Chanteperdrix 2008-10-16 9:36 ` roderik.wildenburg 2008-10-16 9:48 ` Gilles Chanteperdrix 2008-10-16 10:14 ` roderik.wildenburg 2008-10-16 12:14 ` Gilles Chanteperdrix 2008-10-16 12:34 ` roderik.wildenburg 2008-10-16 12:41 ` Gilles Chanteperdrix 2008-10-17 9:58 ` [Xenomai-help] how to build a Xenomai posix library ? solved roderik.wildenburg
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.