Remove ENABLE_SSSE3_ON_ATOM.
[glibc.git] / nptl / pthread_getcpuclockid.c
blob8506f94eb42e24bb3efc45af4161ff2f6bd77509
1 /* Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #include <errno.h>
20 #include <pthreadP.h>
21 #include <sys/time.h>
22 #include <tls.h>
25 int
26 pthread_getcpuclockid (threadid, clockid)
27 pthread_t threadid;
28 clockid_t *clockid;
30 struct pthread *pd = (struct pthread *) threadid;
32 /* Make sure the descriptor is valid. */
33 if (INVALID_TD_P (pd))
34 /* Not a valid thread handle. */
35 return ESRCH;
37 #ifdef CLOCK_THREAD_CPUTIME_ID
38 /* We need to store the thread ID in the CLOCKID variable together
39 with a number identifying the clock. We reserve the low 3 bits
40 for the clock ID and the rest for the thread ID. This is
41 problematic if the thread ID is too large. But 29 bits should be
42 fine.
44 If some day more clock IDs are needed the ID part can be
45 enlarged. The IDs are entirely internal. */
46 if (pd->tid >= 1 << (8 * sizeof (*clockid) - CLOCK_IDFIELD_SIZE))
47 return ERANGE;
49 /* Store the number. */
50 *clockid = CLOCK_THREAD_CPUTIME_ID | (pd->tid << CLOCK_IDFIELD_SIZE);
52 return 0;
53 #else
54 /* We don't have a timer for that. */
55 return ENOENT;
56 #endif