Public bug reported:

INTRODUCTION
--------------------------

The C++ library has internal macros called _GLIBCXX_USE_NANOSLEEP and
_GLIBCXX_USE_SCHED_YIELD.

Normally the macros are defined in x86_64-linux-gnu/32/bits/c++config.h
and x86_64-linux-gnu/bits/c++config.h.

When _GLIBCXX_USE_NANOSLEEP is defined, the standard library has support
for crucial components related to time.

Specifically, in "thread" there is a section which begins with "#ifdef
_GLIBCXX_USE_NANOSLEEP" and declares "sleep_until", "sleep_for",
"nanosleep", "chrono::seconds",  "chrono::nanoseconds", etc. There
functions / types are an important part of C++ standard.

The _GLIBCXX_USE_SCHED_YIELD macro enables "yield()" method.

PROBLEM
--------------------------

C++ code which depends on the relevant parts of the C++ standard simply cannot 
be compiled.
There is no known and reliable workaround for this problem.

WHY IT HAPPENED
--------------------------
I am not 100% sure, but there seem to be a bug in a test program which check 
for the presence of nanosleep. It is a part of "configure", which is in turn 
generated from acinclude.m4.

In order to test for nanosleep the following program is used:

#include <unistd.h>
   #include <time.h>

int
main ()
{
#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
    timespec tp;
   #endif
    clock_gettime(CLOCK_MONOTONIC, &tp);

  ;
  return 0;
}

The program is missing "struct" before "timespec tp;". In fact, there
are three places in the file where the "struct" is missing.

As for "yield", I am not sure yet why it is missing but the reason is
probably similar.

SCOPE
--------------------------
Both macros are NOT enabled in Ubuntu releases after 12.04 LTS, including the 
to-be-released Ubuntu 14.04 LTS.

For example, on Ubuntu 13.10:

 rtvd@localhost $ pwd
 
 /usr/include/c++
 
 rtvd@localhost $ grep -r _GLIBCXX_USE_NANOSLEEP *
 
 4.6/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.6/x86_64-linux-gnu/32/bits/c++config.h:/* #undef _GLIBCXX_USE_NANOSLEEP */
 4.6/x86_64-linux-gnu/bits/c++config.h:/* #undef _GLIBCXX_USE_NANOSLEEP */
 4.6.4/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.6.4/x86_64-linux-gnu/32/bits/c++config.h:/* #undef _GLIBCXX_USE_NANOSLEEP */
 4.6.4/x86_64-linux-gnu/bits/c++config.h:/* #undef _GLIBCXX_USE_NANOSLEEP */
 4.7/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.7.3/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.8/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.8.1/thread:#ifdef _GLIBCXX_USE_NANOSLEEP

On Ubuntu 12.04 LTS (notice #define ...) everything is good:

 rtvd@localhost $ pwd

 /usr/include/c++

 rtvd@localhost $ grep -r _GLIBCXX_USE_NANOSLEEP *

 4.6/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.6/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.6/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.6.3/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.6.3/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.6.3/thread:#ifdef _GLIBCXX_USE_NANOSLEEP

On Debian 7.3 the macros are defined (notice #define ... in each version
of the library), so C++ library is good there too:

 rtvd@debiantest:/usr/include/c++$ pwd
 
 /usr/include/c++
 
 rtvd@debiantest:/usr/include/c++$ grep -r _GLIBCXX_USE_NANOSLEEP *
 
 4.6/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.6/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.6/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.6.3/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.6.3/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.6.3/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.7/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.7/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.7/thread:#ifdef _GLIBCXX_USE_NANOSLEEP
 4.7.2/x86_64-linux-gnu/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.7.2/x86_64-linux-gnu/32/bits/c++config.h:#define _GLIBCXX_USE_NANOSLEEP 1
 4.7.2/thread:#ifdef _GLIBCXX_USE_NANOSLEEP

** Affects: gcc-4.6 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: c++ libstdc++ macro nanosleep yield

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1269803

Title:
  C++ standard library is compiled with nanosleep and yield switched OFF

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.6/+bug/1269803/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to