Re: POSIX timer syscalls

Eric Piel
2003-03-07T09:58:42Z

[-- Attachment #1: Type: text/plain, Size: 1737 bytes --]

george anzinger wrote:
>
> The patch to fix idr is attached. Cleans up the int/long confusion
> and also rearranges a couple of structures to honor the sizes involved.
>
I definitly agree with you George. However, in order to avoid hardcoding
the size of an int to 32 I used a constant called BITS_PER_INT (that's
really just for cleanness):

#endif

#define IDR_MASK ((1 << IDR_BITS)-1)

-/* Leave the possibility of an incomplete final layer */
-#define MAX_LEVEL (BITS_PER_LONG - RESERVED_ID_BITS + IDR_BITS - 1) /
IDR_BITS
-#define MAX_ID_SHIFT (BITS_PER_LONG - RESERVED_ID_BITS)
+/* Define the size of the id's */
+#define BITS_PER_INT (sizeof(int)*8)
+
+#define MAX_ID_SHIFT (BITS_PER_INT - RESERVED_ID_BITS)
#define MAX_ID_BIT (1 << MAX_ID_SHIFT)
#define MAX_ID_MASK (MAX_ID_BIT - 1)

+/* Leave the possibility of an incomplete final layer */
+#define MAX_LEVEL (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS
+
/* Number of id_layer structs to leave in free list */
#define IDR_FREE_MAX MAX_LEVEL + MAX_LEVEL

> > Sure, except I don't have a test-program. ;-)
> >
> That is why you should visit the High-res-timers web site (see URL
> below) and get the "support" patch. It installs in you kernel tree at
> .../Documentation/high-res-timers/ and has test programs as well as
> man pages, readme files etc.
>
I used the test programs and they are really good to test the interface.
To have them working on IA64 I had to slightly modify the file
syscall_timer.c in the lib. This is due to the fact only a function
syscall() is used under ia64 instead of _syscall{1,2,3,4}(). I've
attached a patch that does the trick, it's a bit "raw" but it works and
that's only until glibc is upgraded to support those syscalls :-)

Eric

[-- Attachment #2: hrtimers-support-ia64.patch --]
[-- Type: text/plain, Size: 2175 bytes --]

--- high-res-timers.diff/lib/syscall_timer.c 2003-02-25 11:00:30.000000000 +0100
+++ high-res-timers/lib/syscall_timer.c 2003-03-07 10:48:34.000000000 +0100
@@ -11,69 +11,6 @@
#ifndef __set_errno
#define __set_errno(val) (errno = (val))
#endif
-#if defined(__ia64__)
-
-//#include <unistd.h>
-
-
-int timer_create(clockid_t which_clock,
- struct sigevent *timer_event_spec,
- timer_t *created_timer_id)
-{
- return syscall(__NR_timer_create, which_clock, timer_event_spec, created_timer_id);
-}
-
-int timer_gettime(timer_t timer_id, struct itimerspec *setting)
-{
- return syscall(__NR_timer_gettime, timer_id, setting);
-}
-
-int timer_settime(timer_t timer_id,
- int flags,
- const struct itimerspec *new_setting,
- struct itimerspec *old_setting)
-{
- return syscall(__NR_timer_settime, timer_id, flags, new_setting, old_setting);
-}
-
-int timer_getoverrun(timer_t timer_id)
-{
- return syscall(__NR_timer_getoverrun, timer_id);
-}
-
-int timer_delete(timer_t timer_id)
-{
- return syscall(__NR_timer_delete, timer_id);
-}
-
-int clock_gettime(clockid_t which_clock, struct timespec *ts)
-{
- return syscall(__NR_clock_gettime, which_clock, ts);
-}
-
-int clock_settime(clockid_t which_clock,
- const struct timespec *setting)
-{
- return syscall(__NR_clock_settime, which_clock, setting);
-}
-
-int clock_getres(clockid_t which_clock,
- struct timespec *resolution)
-{
- return syscall(__NR_clock_getres, which_clock, resolution);
-}
-
-int clock_nanosleep(clockid_t which_clock,
- int flags,
- const struct timespec *new_setting,
- struct timespec *old_setting)
-{
- return syscall(__NR_clock_nanosleep, which_clock, flags, new_setting, old_setting);
-}
-
-
-
-#else /*! __ia64__ */

#define __NR___timer_create __NR_timer_create
#define __NR___timer_gettime __NR_timer_gettime
@@ -161,4 +98,4 @@
int, flags,
const struct timespec *,rqtp,
struct timespec *,rmtp)
-#endif /*ia64*/
+