pthread_barrierattr_getpshared wird nicht gefunden

Siegmar Gross <[email protected]>
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
Hallo,

ein kleines Programm soll die Default-Thread-Attribute auf verschiedenen
Betriebssystemen ausgeben. Leider findet gcc die Funktion
"pthread_barrierattr_getpshared" nicht, obwohl sie in der Bibliothek
vorhanden ist.


linpc1 Solutions 120 uname -a
Linux linpc1 2.6.8-24.18-smp #1 SMP Fri Aug 19 11:56:28 UTC 2005 i686 i686 i386 GNU/Linux
linpc1 Solutions 121 



linpc1 Solutions 118 gcc -DBARRIER x.c -lpthread 
/tmp/ccUvGCcs.o(.text+0x776): In function `print_def_attr':
: undefined reference to `pthread_barrierattr_getpshared'
collect2: ld returned 1 exit status


linpc1 Solutions 119 nm /lib/tls/libpthread.so.0 | grep pthread_barrierattr_getpshared
000080e0 T pthread_barrierattr_getpshared



linpc1 Solutions 121 gcc x.c -lpthread
linpc1 Solutions 122 ldd a.out
        linux-gate.so.1 =>  (0xffffe000)
        libpthread.so.0 => /lib/tls/libpthread.so.0 (0x40019000)
        libc.so.6 => /lib/tls/libc.so.6 (0x4002b000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
linpc1 Solutions 123 


Hat irgendjemand eine Loesung? Vielen Dank im voraus fuer alle Antworten.

Siegmar

-- 
Um die Liste abzubestellen, schicken Sie eine Mail an:
    [email protected]
Um eine Liste aller verfügbaren Kommandos zu bekommen, schicken
Sie eine Mail an: [email protected]
x.c (text/x-sun-c-file, 1.3 KB)
#define _REENTRANT			/* must precede any "#include"!	*/
#ifdef Linux
  #define _POSIX_C_SOURCE 200112L	/* features.h			*/
  #define _XOPEN_SOURCE   600
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>

pthread_barrierattr_t	battr;		/* barrier attributes object	*/

void print_def_attr (void);

int main (void)
{
  pthread_t thr_id;			/* ID of created thread		*/

  pthread_barrierattr_init (&battr);

  pthread_create (&thr_id, NULL,
		  (void *(*) (void *)) print_def_attr, NULL);
  pthread_join (thr_id, NULL);
  return 0;
}


void print_def_attr (void)
{
  #ifdef BARRIER
    int			val,	       	/* attribute value		*/
			ret;	       	/* return value of a function	*/

    printf ("  Barrier variable attributes:\n");
    ret = pthread_barrierattr_getpshared (&battr, &val);
    if (ret == 0)
    {
      printf ("    Scope:\t\t");
      switch (val)
      {
        case PTHREAD_PROCESS_PRIVATE:
	  printf ("PTHREAD_PROCESS_PRIVATE\n");
	  break;
        case PTHREAD_PROCESS_SHARED:
	  printf ("PTHREAD_PROCESS_SHARED\n");
	  break;
        default:
	  printf ("unknown\n");
      };
    }
    else
    {
      printf ("    pthread_barrierattr_getpshared:\t%s\n",
	      strerror (ret));
    };
  #endif
  printf ("\n");
  pthread_exit ((void *) 0);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.