This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Sat, Jul 12, 2008 at 1:27 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote: > Hi, > >> I just wanted some feedback based on new information I've >> gathered regarding the clocks and POSIX systems. > > Always remember, however, that we cannot assume POSIX, we can only in general assume C89, anything beyond it requires configure tests. > > From what I gather, >> gettimeofday() *must* be available to all posix systems but >> only provides mircosecond resolution whereas clock_gettime (a >> POSIX.1b real-time extension) gives nanosecond resolution but is only >> available if CLOCK_REALTIME is defined, and the monotonic version is >> available only if CLOCK_MONOTONIC is defined. > > I think you need 2 tests (TRY_COMPILE is enough): the first one for the availability of clock_gettime in <time.h>; then another for unistd.h defining _POSIX_MONOTONIC_CLOCK (you have lots of examples in acinclude.m4 about checking for the availability of a function, checking for the preliminary availability of unistd.h, etc). The constants you mentioned above are just possible values of the first argument of clock_gettime, not something to be used at configure time. Please take time to experiment a bit, there are always various, stricter and less strict, ways to perform such tests. I suggest using as a reference the various entries (in a particular, unistd.h, and clock_gettime) of http://www.unix.org/single_unix_specification/ > > Paolo. > > Ok, I attached a patch (for review purposes) of what I currently have. Is the first check at least ok? The second check I don't like. The POSIX std says _POSIX_MONOTONIC_CLOCK "shall be defined to be -1, 0, or 200112L" (if available) and also "the value of this symbol reported by sysconf() shall either be -1 or 200112L". On my system, _POSIX_MONOTONIC_CLOCK is 0 and sysconf returns 176. Since its greater than 0 (whatever that means) it leads me to believe that I'm not interpreting the std correctly. Maybe I should just test for _POSIX_MONOTONIC_CLOCK > 0 for success so if there's ambiguity because its defined to be 0, its considered not supported. help!? :) Chris
Attachment:
acinclude_rtclock_patch.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |