[Linux-ia64] POSIX timers interface for IA64

From: Eric Piel <Eric.Piel_at_Bull.Net>
Date: 2003-03-08 00:40:04
Hello,

Here is a patch to have the POSIX timer interface completly integrated
in ia64 (2.5.64). The programs in userland can now access the siginfo
structure. With that patch the test programs of the high resolution
timers pass without error but one which seems to also be triggered on
ix86: nanosleeps too short.

I did the same modifications to the ia32 support but I wasn't able to
test them.

A (modified) patch of George Anzinger cleaning up long/int confusion in
idr.c is also included.

Hoping you will find this useful.
Eric
diff -urP linux-2.5.64-ia64.orig/Makefile linux-2.5.64-ia64-timer-030307.diff/Makefile
--- linux-2.5.64-ia64.orig/Makefile	2003-03-07 13:27:04.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/Makefile	2003-03-07 13:40:40.000000000 +0100
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 64
-EXTRAVERSION =
+EXTRAVERSION = eric-posix-timers-2
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
diff -urP linux-2.5.64-ia64.orig/arch/ia64/ia32/ia32_signal.c linux-2.5.64-ia64-timer-030307.diff/arch/ia64/ia32/ia32_signal.c
--- linux-2.5.64-ia64.orig/arch/ia64/ia32/ia32_signal.c	2003-03-05 04:28:55.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/arch/ia64/ia32/ia32_signal.c	2003-03-07 13:39:27.000000000 +0100
@@ -148,6 +148,11 @@
 			err |= __put_user(from->si_band, &to->si_band);
 			err |= __put_user(from->si_fd, &to->si_fd);
 			break;
+		case __SI_TIMER >> 16:
+			err |= __put_user(from->si_tid, &to->si_tid);
+			err |= __put_user(from->si_overrun, &to->si_overrun);
+			err |= __put_user(from->si_ptr, &to->si_ptr); /*XXX eric: not sure the size is correct because it contains pointer*/
+			break;
 		/* case __SI_RT: This is not generated by the kernel as of now.  */
 		}
 	}
diff -urP linux-2.5.64-ia64.orig/arch/ia64/kernel/fsys.S linux-2.5.64-ia64-timer-030307.diff/arch/ia64/kernel/fsys.S
--- linux-2.5.64-ia64.orig/arch/ia64/kernel/fsys.S	2003-03-07 13:27:04.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/arch/ia64/kernel/fsys.S	2003-03-07 13:39:25.000000000 +0100
@@ -533,15 +533,15 @@
 	data8 fsys_fallback_syscall	// epoll_wait		// 1245
 	data8 fsys_fallback_syscall	// restart_syscall
 	data8 fsys_fallback_syscall	// semtimedop
-	data8 fsys_fallback_syscall
-	data8 fsys_fallback_syscall
-	data8 fsys_fallback_syscall				// 1250
-	data8 fsys_fallback_syscall
-	data8 fsys_fallback_syscall
-	data8 fsys_fallback_syscall
-	data8 fsys_fallback_syscall
-	data8 fsys_fallback_syscall				// 1255
-	data8 fsys_fallback_syscall
+	data8 fsys_fallback_syscall	// timer_create
+	data8 fsys_fallback_syscall	// timer_settime
+	data8 fsys_fallback_syscall	// timer_gettime 	// 1250
+	data8 fsys_fallback_syscall	// timer_getoverrun
+	data8 fsys_fallback_syscall	// timer_delete
+	data8 fsys_fallback_syscall	// clock_settime
+	data8 fsys_fallback_syscall	// clock_gettime
+	data8 fsys_fallback_syscall	// clock_getres		// 1255
+	data8 fsys_fallback_syscall	// clock_nanosleep
 	data8 fsys_fallback_syscall
 	data8 fsys_fallback_syscall
 	data8 fsys_fallback_syscall
diff -urP linux-2.5.64-ia64.orig/arch/ia64/kernel/signal.c linux-2.5.64-ia64-timer-030307.diff/arch/ia64/kernel/signal.c
--- linux-2.5.64-ia64.orig/arch/ia64/kernel/signal.c	2003-03-07 13:27:04.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/arch/ia64/kernel/signal.c	2003-03-07 13:39:25.000000000 +0100
@@ -191,6 +191,10 @@
 				err |= __put_user(from->si_pfm_ovfl[2], &to->si_pfm_ovfl[2]);
 				err |= __put_user(from->si_pfm_ovfl[3], &to->si_pfm_ovfl[3]);
 			}
+		      case __SI_TIMER >> 16:
+			err |= __put_user(from->si_tid, &to->si_tid);
+			err |= __put_user(from->si_overrun, &to->si_overrun);
+			err |= __put_user(from->si_value, &to->si_value);
 			break;
 		      default:
 			err |= __put_user(from->si_uid, &to->si_uid);
diff -urP linux-2.5.64-ia64.orig/arch/ia64/kernel/time.c linux-2.5.64-ia64-timer-030307.diff/arch/ia64/kernel/time.c
--- linux-2.5.64-ia64.orig/arch/ia64/kernel/time.c	2003-03-07 13:27:04.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/arch/ia64/kernel/time.c	2003-03-07 13:39:25.000000000 +0100
@@ -110,6 +110,7 @@
 		time_esterror = NTP_PHASE_LIMIT;
 	}
 	write_sequnlock_irq(&xtime_lock);
+	clock_was_set();
 }
 
 void
diff -urP linux-2.5.64-ia64.orig/include/asm-ia64/ia32.h linux-2.5.64-ia64-timer-030307.diff/include/asm-ia64/ia32.h
--- linux-2.5.64-ia64.orig/include/asm-ia64/ia32.h	2003-03-05 04:29:54.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/include/asm-ia64/ia32.h	2003-03-07 13:39:41.000000000 +0100
@@ -214,8 +214,11 @@
 
 		/* POSIX.1b timers */
 		struct {
-			unsigned int _timer1;
-			unsigned int _timer2;
+			timer_t _tid;		/* timer id */
+			int _overrun;		/* overrun count */
+			char _pad[sizeof(unsigned int) - sizeof(int)];
+			sigval_t32 _sigval;	/* same as below */
+			int _sys_private;       /* not to be passed to user */
 		} _timer;
 
 		/* POSIX.1b signals */
Binary files linux-2.5.64-ia64.orig/include/linux/.idr.h.swp and linux-2.5.64-ia64-timer-030307.diff/include/linux/.idr.h.swp differ
diff -urP linux-2.5.64-ia64.orig/include/linux/idr.h linux-2.5.64-ia64-timer-030307.diff/include/linux/idr.h
--- linux-2.5.64-ia64.orig/include/linux/idr.h	2003-03-05 04:28:58.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/include/linux/idr.h	2003-03-07 13:39:42.000000000 +0100
@@ -25,26 +25,30 @@
 
 #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 MAX_ID_BIT (1L << MAX_ID_SHIFT)
+/* 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
 
 struct idr_layer {
 	unsigned long	        bitmap;     // A zero bit means "space here"
-	int                     count;      // When zero, we can release it
 	struct idr_layer       *ary[1<<IDR_BITS];
+	int                     count;      // When zero, we can release it
 };
 
 struct idr {
 	struct idr_layer *top;
-	int		  layers;
-	long		  count;
 	struct idr_layer *id_free;
+	long		  count;
+	int		  layers;
 	int               id_free_cnt;
 	spinlock_t        lock;
 };
Binary files linux-2.5.64-ia64.orig/kernel/.posix-timers.c.swp and linux-2.5.64-ia64-timer-030307.diff/kernel/.posix-timers.c.swp differ
Binary files linux-2.5.64-ia64.orig/lib/.idr.c.swp and linux-2.5.64-ia64-timer-030307.diff/lib/.idr.c.swp differ
diff -urP linux-2.5.64-ia64.orig/lib/idr.c linux-2.5.64-ia64-timer-030307.diff/lib/idr.c
--- linux-2.5.64-ia64.orig/lib/idr.c	2003-03-05 04:29:17.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/lib/idr.c	2003-03-07 13:40:37.000000000 +0100
@@ -150,7 +150,7 @@
 
 static inline int sub_alloc(struct idr *idp, int shift, void *ptr)
 {
-	long n, v = 0;
+	int n, v = 0;
 	struct idr_layer *p;
 	struct idr_layer **pa[MAX_LEVEL];
 	struct idr_layer ***paa = &pa[0];
@@ -211,7 +211,7 @@
 
 int idr_get_new(struct idr *idp, void *ptr)
 {
-	long v;
+	int v;
 	
 	if (idp->id_free_cnt < idp->layers + 1) 
 		return (-1);
diff -urP linux-2.5.64-ia64.orig/usr/initramfs_data.S linux-2.5.64-ia64-timer-030307.diff/usr/initramfs_data.S
--- linux-2.5.64-ia64.orig/usr/initramfs_data.S	1970-01-01 01:00:00.000000000 +0100
+++ linux-2.5.64-ia64-timer-030307.diff/usr/initramfs_data.S	2003-03-07 13:40:41.000000000 +0100
@@ -0,0 +1,17 @@
+.section ".init.ramfs", "a"
+.byte 0x1f,0x8b,0x08,0x00,0xf6,0x71,0x68,0x3e
+.byte 0x02,0x03,0x33,0x30,0x37,0x30,0x37,0x30
+.byte 0x34,0x00,0x01,0x23,0x17,0x30,0x6d,0x62
+.byte 0xe8,0x6c,0x80,0x03,0x18,0x19,0xbb,0x9a
+.byte 0x59,0x98,0x1b,0xba,0x99,0xa1,0x89,0x1b
+.byte 0x43,0x69,0x43,0x1c,0xfa,0x4c,0x61,0x0c
+.byte 0xfd,0x94,0xd4,0x32,0x06,0x06,0x03,0x64
+.byte 0x3b,0x8d,0xc0,0x94,0xa1,0x05,0x2e,0x3b
+.byte 0x0d,0x89,0xb4,0xd3,0x14,0x8d,0xef,0x82
+.byte 0x6c,0xa7,0x7e,0x72,0x7e,0x5e,0x71,0x7e
+.byte 0x4e,0x2a,0x9a,0xdd,0xc6,0x34,0xf2,0x2f
+.byte 0x5c,0xbd,0x7e,0x51,0x7e,0x7e,0x09,0xb2
+.byte 0x9d,0x84,0x01,0xb1,0xea,0xd0,0x81,0x13
+.byte 0x8c,0x11,0x12,0xe4,0xe8,0xe9,0xe3,0x1a
+.byte 0xa4,0xa8,0xa8,0xc8,0x40,0x04,0x00,0x00
+.byte 0x0e,0x7c,0x69,0xf7,0x00,0x02,0x00,0x00
Received on Fri Mar 07 05:41:39 2003

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:12 EST