Resent-Date: Fri, 8 Jan 1999 10:19:04 +0100 (MET)
To: linux-m68k@lists.linux-m68k.org
Subject: 2.2.0-pre4
X-Yow: MERYL STREEP is my obstetrician!
From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Date: 08 Jan 1999 10:18:58 +0100
Resent-From: linux-m68k@phil.uni-sb.de

Hi!

A few things for 2.2.0-pre4:

- arch/m68k/kernel/process.c, arch/m68k/kernel/sys_m68k.c,
  arch/m68k/kernel/time.c: Modernized.
- drivers/char/console.c, drivers/video/fbcon.c: Fix console w/ 512 char
  font.
- fs/Config.in: Fix missing endmenu.
- include/asm-m68k/init.h: Make __cacheline_aligned really cacheline
  aligned.
- include/linux/sunrpc/xdr.h, net/sunrpc/sunrpc_syms.c, net/sunrpc/xdr.c:
  Replace useless variables by compile-time constants.

Andreas.


--- linux/arch/m68k/kernel/process.c.~1~	Wed Aug 26 18:35:36 1998
+++ linux/arch/m68k/kernel/process.c	Wed Dec 23 18:02:36 1998
@@ -56,16 +56,13 @@
  */
 asmlinkage int sys_idle(void)
 {
-	int ret = -EPERM;
-
-	lock_kernel();
 	if (current->pid != 0)
-		goto out;
+		return -EPERM;
 
 	/* endless idle loop with no priority at all */
-	current->priority = -100;
+	current->priority = 0;
 	current->counter = -100;
-	for (;;){
+	for (;;) {
 		if (!current->need_resched)
 #if defined(CONFIG_ATARI) && !defined(CONFIG_AMIGA) && !defined(CONFIG_MAC)
 			/* block out HSYNC on the atari (falcon) */
@@ -73,14 +70,9 @@
 #else /* portable version */
 			__asm__("stop #0x2000" : : : "cc");
 #endif /* machine compilation types */ 
-		check_pgt_cache();
-		run_task_queue(&tq_scheduler);
 		schedule();
+		check_pgt_cache();
 	}
-	ret = 0;
-out:
-	unlock_kernel();
-	return ret;
 }
 
 void machine_restart(char * __unused)
--- linux/arch/m68k/kernel/sys_m68k.c.~1~	Mon Jul 13 19:05:39 1998
+++ linux/arch/m68k/kernel/sys_m68k.c	Thu Dec 24 01:58:18 1998
@@ -112,7 +112,8 @@
  *
  * This is really horribly ugly.
  */
-asmlinkage int sys_ipc (uint call, int first, int second, int third, void *ptr, long fifth)
+asmlinkage int sys_ipc (uint call, int first, int second,
+			int third, void *ptr, long fifth)
 {
 	int version, ret;
 
@@ -122,88 +123,76 @@
 	if (call <= SEMCTL)
 		switch (call) {
 		case SEMOP:
-			ret = sys_semop (first, (struct sembuf *)ptr, second);
-			goto out;
+			return sys_semop (first, (struct sembuf *)ptr, second);
 		case SEMGET:
-			ret = sys_semget (first, second, third);
-			goto out;
+			return sys_semget (first, second, third);
 		case SEMCTL: {
 			union semun fourth;
-			ret = -EINVAL;
 			if (!ptr)
-				goto out;
-			if ((ret = get_user(fourth.__pad, (void **) ptr)))
-				goto out;
-			ret = sys_semctl (first, second, third, fourth);
-			goto out;
+				return -EINVAL;
+			if (get_user(fourth.__pad, (void **) ptr))
+				return -EFAULT;
+			return sys_semctl (first, second, third, fourth);
 			}
 		default:
-			ret = -EINVAL;
-			goto out;
+			return -EINVAL;
 		}
 	if (call <= MSGCTL) 
 		switch (call) {
 		case MSGSND:
-			ret = sys_msgsnd (first, (struct msgbuf *) ptr, 
+			return sys_msgsnd (first, (struct msgbuf *) ptr, 
 					  second, third);
-			goto out;
 		case MSGRCV:
 			switch (version) {
 			case 0: {
 				struct ipc_kludge tmp;
-				ret = -EINVAL;
 				if (!ptr)
-					goto out;
-				ret = -EFAULT;
-				if (copy_from_user (&tmp, ptr, sizeof (tmp)))
-					goto out;
-				ret = sys_msgrcv (first, tmp.msgp, second, tmp.msgtyp, third);
-				goto out;
+					return -EINVAL;
+				if (copy_from_user (&tmp,
+						    (struct ipc_kludge *)ptr,
+						    sizeof (tmp)))
+					return -EFAULT;
+				return sys_msgrcv (first, tmp.msgp, second,
+						   tmp.msgtyp, third);
 				}
-			case 1: default:
-				ret = sys_msgrcv (first, (struct msgbuf *) ptr, second, fifth, third);
-				goto out;
+			default:
+				return sys_msgrcv (first,
+						   (struct msgbuf *) ptr,
+						   second, fifth, third);
 			}
 		case MSGGET:
-			ret = sys_msgget ((key_t) first, second);
-			goto out;
+			return sys_msgget ((key_t) first, second);
 		case MSGCTL:
-			ret = sys_msgctl (first, second, (struct msqid_ds *) ptr);
-			goto out;
+			return sys_msgctl (first, second,
+					   (struct msqid_ds *) ptr);
 		default:
-			ret = -EINVAL;
-			goto out;
+			return -EINVAL;
 		}
 	if (call <= SHMCTL) 
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			case 0: default: {
+			default: {
 				ulong raddr;
-				ret = sys_shmat (first, (char *) ptr, second, &raddr);
+				ret = sys_shmat (first, (char *) ptr,
+						 second, &raddr);
 				if (ret)
-					goto out;
-				ret = put_user (raddr, (ulong *) third);
-				goto out;
+					return ret;
+				return put_user (raddr, (ulong *) third);
 			}
 			}
 		case SHMDT: 
-			ret = sys_shmdt ((char *)ptr);
-			goto out;
+			return sys_shmdt ((char *)ptr);
 		case SHMGET:
-			ret = sys_shmget (first, second, third);
-			goto out;
+			return sys_shmget (first, second, third);
 		case SHMCTL:
-			ret = sys_shmctl (first, second, (struct shmid_ds *) ptr);
-			goto out;
+			return sys_shmctl (first, second,
+					   (struct shmid_ds *) ptr);
 		default:
-			ret = -EINVAL;
-			goto out;
+			return -EINVAL;
 		}
-	ret = -EINVAL;
-out:
-	unlock_kernel();
-	return ret;
+
+	return -EINVAL;
 }
 
 asmlinkage int sys_ioperm(unsigned long from, unsigned long num, int on)
--- linux/arch/m68k/kernel/time.c.~1~	Mon Jun  8 16:44:07 1998
+++ linux/arch/m68k/kernel/time.c	Mon Jan  4 19:13:45 1999
@@ -146,27 +146,38 @@
 	mach_sched_init(timer_interrupt);
 }
 
+extern rwlock_t xtime_lock;
+
 /*
  * This version of gettimeofday has near microsecond resolution.
  */
 void do_gettimeofday(struct timeval *tv)
 {
+	extern volatile unsigned long lost_ticks;
 	unsigned long flags;
+	unsigned long usec, sec, lost;
+
+	read_lock_irqsave(&xtime_lock, flags);
+	usec = mach_gettimeoffset();
+	lost = lost_ticks;
+	if (lost)
+		usec += lost * (1000000/HZ);
+	sec = xtime.tv_sec;
+	usec += xtime.tv_usec;
+	read_unlock_irqrestore(&xtime_lock, flags);
 
-	save_flags(flags);
-	cli();
-	*tv = xtime;
-	tv->tv_usec += mach_gettimeoffset();
-	if (tv->tv_usec >= 1000000) {
-		tv->tv_usec -= 1000000;
-		tv->tv_sec++;
+	while (usec >= 1000000) {
+		usec -= 1000000;
+		sec++;
 	}
-	restore_flags(flags);
+
+	tv->tv_sec = sec;
+	tv->tv_usec = usec;
 }
 
 void do_settimeofday(struct timeval *tv)
 {
-	cli();
+	write_lock_irq(&xtime_lock);
 	/* This is revolting. We need to set the xtime.tv_usec
 	 * correctly. However, the value in this location is
 	 * is value at the last tick.
@@ -175,7 +186,7 @@
 	 */
 	tv->tv_usec -= mach_gettimeoffset();
 
-	if (tv->tv_usec < 0) {
+	while (tv->tv_usec < 0) {
 		tv->tv_usec += 1000000;
 		tv->tv_sec--;
 	}
@@ -184,5 +195,5 @@
 	time_state = TIME_BAD;
 	time_maxerror = MAXPHASE;
 	time_esterror = MAXPHASE;
-	sti();
+	write_unlock_irq(&xtime_lock);
 }
--- linux/drivers/char/console.c.~1~	Wed Jan  6 19:25:20 1999
+++ linux/drivers/char/console.c	Mon Jan  4 19:34:37 1999
@@ -1221,6 +1221,8 @@
 			break;
 		case 8:	/* store colors as defaults */
 			def_color = attr;
+			if (hi_font_mask == 0x100)
+				def_color >>= 1;
 			default_attr(currcons);
 			update_attr(currcons);
 			break;
@@ -1894,7 +1896,7 @@
 			if (decim)
 				insert_char(currcons, 1);
 			scr_writew(himask ?
-				     ((attr & ~himask) << 8) + ((tc & 0x100) ? himask : 0) + (tc & 0xff) :
+				     ((attr << 8) & ~himask) + ((tc & 0x100) ? himask : 0) + (tc & 0xff) :
 				     (attr << 8) + tc,
 				   (u16 *) pos);
 			if (DO_UPDATE && draw_x < 0) {
--- linux/drivers/video/fbcon.c.~1~	Wed Jan  6 19:28:56 1999
+++ linux/drivers/video/fbcon.c	Sun Jan  3 10:32:54 1999
@@ -536,13 +536,14 @@
     conp->vc_can_do_color = p->var.bits_per_pixel != 1;
     conp->vc_complement_mask = conp->vc_can_do_color ? 0x7700 : 0x0800;
     if (charcnt == 256) {
-    	p->conp->vc_hi_font_mask = 0;
+    	conp->vc_hi_font_mask = 0;
     	p->fgshift = 8;
     	p->bgshift = 12;
     	p->charmask = 0xff;
     } else {
-    	p->conp->vc_hi_font_mask = 0x100;
-    	p->conp->vc_complement_mask <<= 1;
+    	conp->vc_hi_font_mask = 0x100;
+    	if (conp->vc_can_do_color)
+	    conp->vc_complement_mask <<= 1;
     	p->fgshift = 9;
     	p->bgshift = 13;
     	p->charmask = 0x1ff;
@@ -1333,13 +1334,14 @@
     p->_fontheight = h;
     if (p->conp->vc_hi_font_mask && cnt == 256) {
     	p->conp->vc_hi_font_mask = 0;
-    	p->conp->vc_complement_mask >>= 1;
+    	if (p->conp->vc_can_do_color)
+	    p->conp->vc_complement_mask >>= 1;
     	p->fgshift--;
     	p->bgshift--;
     	p->charmask = 0xff;
 
 	/* ++Edmund: reorder the attribute bits */
-	{
+	if (p->conp->vc_can_do_color) {
 	    struct vc_data *conp = p->conp;
 	    unsigned short *cp = (unsigned short *) conp->vc_origin;
 	    int count = conp->vc_screenbuf_size/2;
@@ -1355,7 +1357,8 @@
 
     } else if (!p->conp->vc_hi_font_mask && cnt == 512) {
     	p->conp->vc_hi_font_mask = 0x100;
-    	p->conp->vc_complement_mask <<= 1;
+    	if (p->conp->vc_can_do_color)
+	    p->conp->vc_complement_mask <<= 1;
     	p->fgshift++;
     	p->bgshift++;
     	p->charmask = 0x1ff;
@@ -1367,12 +1370,20 @@
 	    int count = conp->vc_screenbuf_size/2;
 	    unsigned short c;
 	    for (; count > 0; count--, cp++) {
+	        unsigned short newc;
 	        c = scr_readw(cp);
-		scr_writew(((c & 0xff00) << 1) | (c & 0xff), cp);
+		if (conp->vc_can_do_color)
+		    newc = ((c & 0xff00) << 1) | (c & 0xff);
+		else
+		    newc = c & ~0x100;
+		scr_writew(newc, cp);
 	    }
 	    c = conp->vc_video_erase_char;
-	    conp->vc_video_erase_char = ((c & 0xff00) << 1) | (c & 0xff);
-	    conp->vc_attr <<= 1;
+	    if (conp->vc_can_do_color) {
+		conp->vc_video_erase_char = ((c & 0xff00) << 1) | (c & 0xff);
+		conp->vc_attr <<= 1;
+	    } else
+	        conp->vc_video_erase_char = c & ~0x100;
 	}
 
     }
--- linux/fs/Config.in.~1~	Wed Jan  6 19:29:18 1999
+++ linux/fs/Config.in	Wed Jan  6 19:58:41 1999
@@ -164,3 +164,5 @@
   bool 'Unixware slices support (EXPERIMENTAL)' CONFIG_UNIXWARE_DISKLABEL
 fi
 endmenu
+
+endmenu
--- linux/include/asm-m68k/init.h.~1~	Wed Jan  6 19:30:36 1999
+++ linux/include/asm-m68k/init.h	Wed Jan  6 20:28:07 1999
@@ -16,7 +16,7 @@
 #define __INITDATA	.section	".data.init",#alloc,#write
 
 #define __cacheline_aligned __attribute__ \
-			 ((__section__ (".data.cacheline_aligned")))
+		((__aligned__(16), __section__ (".data.cacheline_aligned")))
 
 #else
 
@@ -30,8 +30,8 @@
 #define __INIT
 #define __FINIT
 #define __INITDATA
-#define __cacheline_aligned
+#define __cacheline_aligned __attribute__ ((__aligned__(16)))
 
 #endif /* CONFIG_KGDB */
-	
+
 #endif
--- linux/include/linux/sunrpc/xdr.h.~1~	Wed Apr  9 21:28:59 1997
+++ linux/include/linux/sunrpc/xdr.h	Sun Dec  6 14:29:09 1998
@@ -10,6 +10,7 @@
 #ifdef __KERNEL__
 
 #include <linux/uio.h>
+#include <linux/in.h>
 
 /*
  * Buffer adjustment
@@ -34,25 +35,25 @@
 typedef int	(*kxdrproc_t)(void *rqstp, u32 *data, void *obj);
 
 /*
- * These variables contain pre-xdr'ed values for faster operation.
- * FIXME: should be replaced by macros for big-endian machines.
+ * A few useless macros.
  */
-extern u32	xdr_zero, xdr_one, xdr_two;
-
-extern u32	rpc_success,
-		rpc_prog_unavail,
-		rpc_prog_mismatch,
-		rpc_proc_unavail,
-		rpc_garbage_args,
-		rpc_system_err;
-
-extern u32	rpc_auth_ok,
-		rpc_autherr_badcred,
-		rpc_autherr_rejectedcred,
-		rpc_autherr_badverf,
-		rpc_autherr_rejectedverf,
-		rpc_autherr_tooweak,
-		rpc_autherr_dropit;
+#define xdr_zero			htonl(0)
+#define xdr_one				htonl(1)
+#define xdr_two				htonl(2)
+
+#define rpc_success			htonl(RPC_SUCCESS)
+#define rpc_prog_unavail		htonl(RPC_PROG_UNAVAIL)
+#define rpc_prog_mismatch		htonl(RPC_PROG_MISMATCH)
+#define rpc_proc_unavail		htonl(RPC_PROC_UNAVAIL)
+#define rpc_garbage_args		htonl(RPC_GARBAGE_ARGS)
+#define rpc_system_err			htonl(RPC_SYSTEM_ERR)
+
+#define rpc_auth_ok			htonl(RPC_AUTH_OK)
+#define rpc_autherr_badcred		htonl(RPC_AUTH_BADCRED)
+#define rpc_autherr_rejectedcred	htonl(RPC_AUTH_REJECTEDCRED)
+#define rpc_autherr_badverf		htonl(RPC_AUTH_BADVERF)
+#define rpc_autherr_rejectedverf	htonl(RPC_AUTH_REJECTEDVERF)
+#define rpc_autherr_tooweak		htonl(RPC_AUTH_TOOWEAK)
 
 void		xdr_init(void);
 
--- linux/net/sunrpc/sunrpc_syms.c.~1~	Fri Aug 21 18:43:33 1998
+++ linux/net/sunrpc/sunrpc_syms.c	Sun Dec  6 14:34:23 1998
@@ -91,13 +91,6 @@
 EXPORT_SYMBOL(xdr_decode_string);
 EXPORT_SYMBOL(xdr_decode_netobj);
 EXPORT_SYMBOL(xdr_encode_netobj);
-EXPORT_SYMBOL(xdr_zero);
-EXPORT_SYMBOL(xdr_one);
-
-/* RPC errors */
-EXPORT_SYMBOL(rpc_success);
-EXPORT_SYMBOL(rpc_garbage_args);
-EXPORT_SYMBOL(rpc_system_err);
 
 /* Debugging symbols */
 EXPORT_SYMBOL(rpc_debug);
--- linux/net/sunrpc/xdr.c.~1~	Wed Apr  9 21:29:26 1997
+++ linux/net/sunrpc/xdr.c	Sun Dec  6 14:28:57 1998
@@ -13,39 +13,9 @@
 #include <linux/sunrpc/xdr.h>
 #include <linux/sunrpc/msg_prot.h>
 
-u32	rpc_success, rpc_prog_unavail, rpc_prog_mismatch, rpc_proc_unavail,
-	rpc_garbage_args, rpc_system_err;
-u32	rpc_auth_ok, rpc_autherr_badcred, rpc_autherr_rejectedcred,
-	rpc_autherr_badverf, rpc_autherr_rejectedverf, rpc_autherr_tooweak;
-u32	xdr_zero, xdr_one, xdr_two;
-
 void
 xdr_init(void)
 {
-	static int	inited = 0;
-
-	if (inited)
-		return;
-
-	xdr_zero = htonl(0);
-	xdr_one = htonl(1);
-	xdr_two = htonl(2);
-
-	rpc_success = htonl(RPC_SUCCESS);
-	rpc_prog_unavail = htonl(RPC_PROG_UNAVAIL);
-	rpc_prog_mismatch = htonl(RPC_PROG_MISMATCH);
-	rpc_proc_unavail = htonl(RPC_PROC_UNAVAIL);
-	rpc_garbage_args = htonl(RPC_GARBAGE_ARGS);
-	rpc_system_err = htonl(RPC_SYSTEM_ERR);
-
-	rpc_auth_ok = htonl(RPC_AUTH_OK);
-	rpc_autherr_badcred = htonl(RPC_AUTH_BADCRED);
-	rpc_autherr_rejectedcred = htonl(RPC_AUTH_REJECTEDCRED);
-	rpc_autherr_badverf = htonl(RPC_AUTH_BADVERF);
-	rpc_autherr_rejectedverf = htonl(RPC_AUTH_REJECTEDVERF);
-	rpc_autherr_tooweak = htonl(RPC_AUTH_TOOWEAK);
-
-	inited = 1;
 }
 
 /*

-- 
Andreas Schwab                                      "And now for something
schwab@issan.cs.uni-dortmund.de                      completely different"
schwab@gnu.org

