It seems that cyclictest and switchtest compile fine.
I had no error when I installed Xenomai.

Here is an example of code that fails :

/*Fichier essai_mutex.c*/
#include <pthread.h>
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <time.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <limits.h>

pthread_t task1, task2;
pthread_mutex_t mutex;
void routine1 (void * cookie);
void routine2 (void * cookie);

int tab[200];
int DESTRUCT=0;

void affich(int toto){
static int cpt = 0;
pthread_mutex_lock(&mutex);
tab[cpt] = toto;
cpt ++;
if(cpt == 150)
{
 cpt = 0;
}
pthread_mutex_unlock(&mutex);
}

void routine1 (void * cookie){
struct sched_param param = {.sched_priority = 10 };
pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
for(;;){
 affich(1);
 sleep(1);
 if(DESTRUCT==1){
  pthread_exit(NULL);
 };
}
}

void routine2 (void * cookie){
struct sched_param param = {.sched_priority = 10 };
pthread_setschedparam(pthread_self(), SCHED_FIFO, &param);
for(;;){
 affich(2);
 sleep(2);
 if(DESTRUCT==1){
  pthread_exit(NULL);
 };
}
}

void cleanup_upon_sig(int sig __attribute__((unused)))
{
DESTRUCT=1;
}

int main(int argc, char **argv)
{
int i = 0;
int err;
sigset_t mask, oldmask;
pthread_attr_t attr1, attr2;
struct sched_param param1 = {.sched_priority = 10 };
struct sched_param param2 = {.sched_priority = 10 };

mlockall(MCL_CURRENT | MCL_FUTURE);

/*creation du mutex*/
pthread_mutex_init(&mutex,NULL);

sigemptyset(&mask);
sigaddset(&mask, SIGINT);
signal(SIGINT, cleanup_upon_sig);
sigaddset(&mask, SIGTERM);
signal(SIGTERM, cleanup_upon_sig);
sigaddset(&mask, SIGHUP);
signal(SIGHUP, cleanup_upon_sig);

pthread_sigmask(SIG_BLOCK, &mask, &oldmask);

printf("Ctrl C pour stopper l'application et afficher le resultat\n");

/*Initialisation des attributs des taches*/
pthread_attr_init(&attr1);
pthread_attr_setdetachstate(&attr1, PTHREAD_CREATE_JOINABLE);
pthread_attr_setinheritsched(&attr1, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr1, SCHED_FIFO);
pthread_attr_setschedparam(&attr1, &param1);
pthread_attr_setstacksize(&attr1, PTHREAD_STACK_MIN);

pthread_attr_init(&attr2);
pthread_attr_setdetachstate(&attr2, PTHREAD_CREATE_JOINABLE);
pthread_attr_setinheritsched(&attr2, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&attr2, SCHED_FIFO);
pthread_attr_setschedparam(&attr2, &param2);
pthread_attr_setstacksize(&attr2, PTHREAD_STACK_MIN);

if (err = pthread_create (&task1,&attr1,(void *)routine1,NULL))
 fprintf(stderr, "failed to create threads: %s\n", strerror(err));

if (err = pthread_create (&task2,&attr2,(void *)routine2,NULL))
 fprintf(stderr, "failed to create threads: %s\n", strerror(err));

pthread_sigmask(SIG_UNBLOCK, &mask, &oldmask);

pthread_join(task1, NULL);
pthread_join(task2, NULL);

if (err = pthread_mutex_destroy(&mutex))
 fprintf(stderr, "failed to cancel mutex");

for(i = 0; i < 20 ; i++)
 {
  printf("Task %d\n",tab[i]);
 }
return 0;
}

And the makefile :

arm-linux-gcc -I/usr/xenomai_arm-2.3.1uClibc/include -I/usr/xenomai_arm-
2.3.1uClibc/include/posix -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -g
essai_mutex.c -c -o essai_mutex_rt.o

arm-linux-gcc -Wl,--wrap,pthread_create -Wl,--wrap,pthread_setschedparam
-Wl,--wrap,pthread_getschedparam -Wl,--wrap,pthread_yield
-Wl,--wrap,sched_yield -Wl,--wrap,sem_init -Wl,--wrap,sem_destroy
-Wl,--wrap,sem_post -Wl,--wrap,sem_timedwait -Wl,--wrap,sem_wait
-Wl,--wrap,sem_trywait -Wl,--wrap,sem_getvalue -Wl,--wrap,sem_open
-Wl,--wrap,sem_close -Wl,--wrap,sem_unlink -Wl,--wrap,clock_getres
-Wl,--wrap,clock_gettime -Wl,--wrap,clock_settime -Wl,--wrap,clock_nanosleep
-Wl,--wrap,nanosleep -Wl,--wrap,pthread_mutexattr_init
-Wl,--wrap,pthread_mutexattr_destroy -Wl,--wrap,pthread_mutexattr_gettype
-Wl,--wrap,pthread_mutexattr_settype
-Wl,--wrap,pthread_mutexattr_getprotocol
-Wl,--wrap,pthread_mutexattr_setprotocol
-Wl,--wrap,pthread_mutexattr_getpshared
-Wl,--wrap,pthread_mutexattr_setpshared -Wl,--wrap,pthread_mutex_init
-Wl,--wrap,pthread_mutex_destroy -Wl,--wrap,pthread_mutex_lock
-Wl,--wrap,pthread_mutex_trylock -Wl,--wrap,pthread_mutex_timedlock
-Wl,--wrap,pthread_mutex_unlock -Wl,--wrap,pthread_condattr_init
-Wl,--wrap,pthread_condattr_destroy -Wl,--wrap,pthread_condattr_getclock
-Wl,--wrap,pthread_condattr_setclock -Wl,--wrap,pthread_condattr_getpshared
-Wl,--wrap,pthread_condattr_setpshared -Wl,--wrap,pthread_cond_init
-Wl,--wrap,pthread_cond_destroy -Wl,--wrap,pthread_cond_wait
-Wl,--wrap,pthread_cond_timedwait -Wl,--wrap,pthread_cond_signal
-Wl,--wrap,pthread_cond_broadcast -Wl,--wrap,mq_open -Wl,--wrap,mq_close
-Wl,--wrap,mq_unlink -Wl,--wrap,mq_getattr -Wl,--wrap,mq_setattr
-Wl,--wrap,mq_send -Wl,--wrap,mq_timedsend -Wl,--wrap,mq_receive
-Wl,--wrap,mq_timedreceive -Wl,--wrap,mq_notify -Wl,--wrap,open
-Wl,--wrap,socket -Wl,--wrap,close -Wl,--wrap,ioctl \,--wrap,sendto
-Wl,--wrap,recv -Wl,--wrap,send -Wl,--wrap,getsockopt -Wl,--wrap,setsockopt
-Wl,--wrap,bind -Wl,--wrap,connect -Wl,--wrap,listen -Wl,--wrap,accept
-Wl,--wrap,getsockname -Wl,--wrap,getpeername -Wl,--wrap,shutdown
-Wl,--wrap,timer_create -Wl,--wrap,timer_delete -Wl,--wrap,timer_settime
-Wl,--wrap,timer_getoverrun -Wl,--wrap,timer_gettime -Wl,--wrap,ftruncate
-Wl,--wrap,close -Wl,--wrap,shm_open -Wl,--wrap,shm_unlink -Wl,--wrap,mmap
-Wl,--wrap,munmap -L/usr/xenomai_arm-2.3.1uClibc/lib essai_mutex_rt.o
-lpthread_rt -lpthread -lrt -o essai_mutex_rt

Thanks


On 5/29/07, Gilles Chanteperdrix <[EMAIL PROTECTED]> wrote:

Perrine Martignoni wrote:
> I applied the patch xeno-2.3-posix-shm.diff and the installation of
> Xenomai works fine.
> Thanks
>
> But after when I want to compile an application (who works with glibc),
> I have this error :
>
>
> /usr/src/ELDK_arm/usr/../arm/lib/libpthread.so: undefined reference to
> `__wrap_mmap'
>
> /usr/src/ELDK_arm/usr/../arm/lib/librt.so: undefined reference
> to`__wrap_close'
>
> /usr/src/ELDK_arm/usr/../arm/lib/libpthread.so: undefined reference to
> `__wrap_munmap'
>
> collect2: ld returned 1 exit status
>
> This error appears with any example of code.

Does this happen when compiling Xenomai posix programs, such as
cyclictest or switchtest ?
As usual, please show us an example of code that fails (including the
Makefile).

--
                                                Gilles Chanteperdrix

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to