diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/Makefile.inc | 2 | ||||
-rw-r--r-- | lib/libc/gen/Symbol.map | 1 | ||||
-rw-r--r-- | lib/libc/gen/clock_getcpuclockid.c | 39 | ||||
-rw-r--r-- | lib/libc/gen/sysconf.c | 4 | ||||
-rw-r--r-- | lib/libc/sys/Symbol.map | 3 | ||||
-rw-r--r-- | lib/libthr/thread/thr_getcpuclockid.c | 4 |
6 files changed, 47 insertions, 6 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 2e7a31c..332165f 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -8,7 +8,7 @@ SRCS+= __getosreldate.c __xuname.c \ _once_stub.c _pthread_stubs.c _rand48.c _spinlock_stub.c \ _thread_init.c \ alarm.c arc4random.c assert.c auxv.c basename.c check_utility_compat.c \ - clock.c closedir.c confstr.c \ + clock.c clock_getcpuclockid.c closedir.c confstr.c \ crypt.c ctermid.c daemon.c devname.c dirfd.c dirname.c disklabel.c \ dlfcn.c drand48.c elf_utils.c erand48.c err.c errlst.c errno.c \ exec.c fdevname.c feature_present.c fmtcheck.c fmtmsg.c fnmatch.c \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 356bee5..50a1d88 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -382,6 +382,7 @@ FBSD_1.2 { }; FBSD_1.3 { + clock_getcpuclockid; dirfd; fdlopen; __FreeBSD_libc_enter_restricted_mode; diff --git a/lib/libc/gen/clock_getcpuclockid.c b/lib/libc/gen/clock_getcpuclockid.c new file mode 100644 index 0000000..fc12bd6 --- /dev/null +++ b/lib/libc/gen/clock_getcpuclockid.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2012 David Xu <davidxu@FreeBSD.org>. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY DANIEL EISCHEN AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <errno.h> +#include <time.h> +#include <unistd.h> +#include <sys/time.h> + +clockid_t +clock_getcpuclockid(pid_t pid, clockid_t *clock_id) +{ + return clock_getcpuclockid2(pid, CPUCLOCK_WHICH_PID, clock_id); +} diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c index 2d117b7..b7952b1 100644 --- a/lib/libc/gen/sysconf.c +++ b/lib/libc/gen/sysconf.c @@ -359,11 +359,7 @@ yesno: return (_POSIX_CLOCK_SELECTION); #endif case _SC_CPUTIME: -#if _POSIX_CPUTIME == 0 -#error "_POSIX_CPUTIME" -#else return (_POSIX_CPUTIME); -#endif #ifdef notdef case _SC_FILE_LOCKING: /* diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map index 6888ea0..008b8da 100644 --- a/lib/libc/sys/Symbol.map +++ b/lib/libc/sys/Symbol.map @@ -379,6 +379,7 @@ FBSD_1.2 { }; FBSD_1.3 { + clock_getcpuclockid2; ffclock_getcounter; ffclock_getestimate; ffclock_setestimate; @@ -490,6 +491,8 @@ FBSDprivate_1.0 { __sys_chown; _chroot; __sys_chroot; + _clock_getcpuclockid2; + __sys_clock_getcpuclockid2; _clock_getres; __sys_clock_getres; _clock_gettime; diff --git a/lib/libthr/thread/thr_getcpuclockid.c b/lib/libthr/thread/thr_getcpuclockid.c index 68f88d5..b4ec666 100644 --- a/lib/libthr/thread/thr_getcpuclockid.c +++ b/lib/libthr/thread/thr_getcpuclockid.c @@ -39,9 +39,11 @@ __weak_reference(_pthread_getcpuclockid, pthread_getcpuclockid); int _pthread_getcpuclockid(pthread_t pthread, clockid_t *clock_id) { + if (pthread == NULL) return (EINVAL); - *clock_id = CLOCK_THREAD_CPUTIME_ID; + if (clock_getcpuclockid2(TID(pthread), CPUCLOCK_WHICH_TID, clock_id)) + return (errno); return (0); } |