Menu

config problem? HAVE_PTHREAD_RWLOCK

Help
2000-06-21
2000-07-05
  • John Zedlewski

    John Zedlewski - 2000-06-21

      When I installed Common C++ on a Red Hat Linux box (standard ./configure && make && make install with no special options), I found that the installed cc++/config.h contained the line "#define HAVE_PTHREAD_RWLOCK 1", and that I got a parse error on cc++/threads.h on the lines:
    "
    #ifdef HAV_PHTREAD_RWLOCK
    pthread_rwlock_t _lock;
    #endif
    "
      As far as I know, Linux doesn't have rwlocks.  Is this an autoconf error?  I'm using Common C++ 1.0.3, by the way.
      Thanks!
    --JRZ

     
    • David Sugar

      David Sugar - 2000-06-25

      The current glibc and pthread libraries do support Posix rwlock under GNU/Linux. Both the test and the resulting code compile correctly on a Mandrake 7.0 GNU/Linux distribution which includes glibc 2.1.2.   You usually have to #define "__USE_UNIX98" to get it to do so though.

       
      • Henner Zeller

        Henner Zeller - 2000-06-30

        yes, but there are some problems; for some reason it fails if other header files are included before <cc++/thread.h> on RH 6.2 for example. This seems to be a bug in the system header files .. I'll check this and try to find a solution which prevents this.

        Workaround: include <cc++/thread.h> as the very first include file, then it should work.

         
        • David Sugar

          David Sugar - 2000-06-30

          There actually is kind of a bug, in that some features and system calls are not even prototyped in glibc headers unless one defines certain key macros.  For example, pread and pwrite are unusable in glibc unless one defines _XOPEN_SOURCES properly, though this kills building other targets.  Similarly, Posix RWLOCK support is tied to defining __USE_UNIX98 in glibc.

          It's possible other headers if given a chance define by default special macro sets that are incompaible with __USE_UNIX98 unless this is seen first.  Including cc++/thread.h gaurentees this happens, as it's defined in cc++/config.h which is automatically included.

           
          • Henner Zeller

            Henner Zeller - 2000-07-05

            Yes I checked this out. The interesting file is /usr/include/features.h. If this happens to be included by another header first, without _XOPEN_SOURCE=500 set, __USE_UNIX98 is disabled. It even does not work to set this in cc++/config.h, because pthread.h might have been included already and protectes against reincluding.

            So, the ONLY way to make this work reliably is to set -D_XOPEN_SOURCE=500 on the commandline or #define _XOPEN_SOURCE 500 as the first line in every sourcefile .. First solution is better and as it supposed to be.

            ciao,
            -hen

             

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.