Date: Fri, 27 Jun 1997 10:42:12 +0200 (CEST)
From: Geert Uytterhoeven <Geert.Uytterhoeven@cs.kuleuven.ac.be>
To: Martin Mitchell <gevans@mail.usyd.edu.au>
Cc: Linux/m68k <linux-m68k@phil.uni-sb.de>
Subject: Re: L68K: More miscellaneous fixes for 2.1.42
In-Reply-To: <87d8padg3e.fsf@mail.usyd.edu.au>
Sender: owner-linux-m68k@phil.uni-sb.de
Reply-To: linux-m68k@phil.uni-sb.de

On 25 Jun 1997, Martin Mitchell wrote:
> > More miscellaneous fixes for 2.1.42:
> 
> I have another suggestion for a fix: in linux/fb.h types such as u_short
> and u_long are used. However in linux/types.h these are protected inside
> a #ifndef __KERNEL_STRICT_NAMES / #endif pair. The header files for glibc
> seem to define __KERNEL_STRICT_NAMES by default, thus making it
> impossible to compile a program using just #include <linux/fb.h>, because
> u_short and u_long are not available. I have hacked around this now, by
> including <sys/types.h> which defines these types, before <linux/fb.h>,
> but this seems like a broken way to do things. I suggest using some of
> the types declared in <asm/types.h> instead, under the comment where it
> says 'use these to export to user space', such as __u16 for u_short.
> 
> What do you think? Does the above make any sense?

Here are some patches to fix this. Is this OK?

--- linux-2.1.42/drivers/video/amifb.c.orig	Mon Jun 16 21:44:27 1997
+++ linux-2.1.42/drivers/video/amifb.c	Thu Jun 26 22:44:25 1997
@@ -2107,7 +2107,7 @@
 	int i;
 
 	strcpy(fix->id, amiga_fb_name);
-	fix->smem_start = videomemory;
+	fix->smem_start = (caddr_t)videomemory;
 	fix->smem_len = videomemorysize;
 
 	if (amifb_ilbm) {
--- linux-2.1.42/drivers/video/atafb.c.orig	Mon Jun 16 21:44:28 1997
+++ linux-2.1.42/drivers/video/atafb.c	Thu Jun 26 22:46:40 1997
@@ -503,7 +503,7 @@
 	int mode, i;
 
 	strcpy(fix->id,"Atari Builtin");
-	fix->smem_start=real_screen_base;
+	fix->smem_start = (caddr_t)real_screen_base;
 	fix->smem_len = screen_len;
 	fix->type=FB_TYPE_INTERLEAVED_PLANES;
 	fix->type_aux=2;
@@ -829,7 +829,7 @@
 	int i;
 
 	strcpy(fix->id, "Atari Builtin");
-	fix->smem_start = real_screen_base;
+	fix->smem_start = (caddr_t)real_screen_base;
 	fix->smem_len = screen_len;
 	fix->type = FB_TYPE_INTERLEAVED_PLANES;
 	fix->type_aux = 2;
@@ -1777,7 +1777,7 @@
 	int mode, i;
 
 	strcpy(fix->id,"Atari Builtin");
-	fix->smem_start=real_screen_base;
+	fix->smem_start=(caddr_t)real_screen_base;
 	fix->smem_len=screen_len;
 	fix->type=FB_TYPE_INTERLEAVED_PLANES;
 	fix->type_aux=2;
@@ -2104,7 +2104,7 @@
 	int i;
 
 	strcpy(fix->id,"Unknown Extern");
-	fix->smem_start=external_addr;
+	fix->smem_start=(caddr_t)external_addr;
 	fix->smem_len=(external_len + PAGE_SIZE -1) & PAGE_MASK;
 	if (external_depth == 1) {
 		fix->type = FB_TYPE_PACKED_PIXELS;
--- linux-2.1.42/drivers/video/cyberfb.c.orig	Tue Jun 17 22:41:45 1997
+++ linux-2.1.42/drivers/video/cyberfb.c	Thu Jun 26 22:47:21 1997
@@ -401,7 +401,7 @@
    int i;
 
    strcpy(fix->id, Cyber_fb_name);
-   fix->smem_start = CyberMem;
+   fix->smem_start = (caddr_t)CyberMem;
 #if 0
    fix->smem_len = CyberSize;
 #else
--- linux-2.1.42/drivers/video/retz3fb.c.orig	Tue Jun 17 22:42:00 1997
+++ linux-2.1.42/drivers/video/retz3fb.c	Thu Jun 26 22:47:41 1997
@@ -896,7 +896,7 @@
 	int i;
 
 	strcpy(fix->id, retz3_fb_name);
-	fix->smem_start = z3_fbmem;
+	fix->smem_start = (caddr_t)z3_fbmem;
 	fix->smem_len = z3_size;
 
 	fix->type = FB_TYPE_PACKED_PIXELS;
--- linux-2.1.42/drivers/video/vfb.c.orig	Sun Jun 22 22:47:49 1997
+++ linux-2.1.42/drivers/video/vfb.c	Thu Jun 26 22:47:53 1997
@@ -462,7 +462,7 @@
 			   struct fb_var_screeninfo *var)
 {
     strcpy(fix->id, virtual_fb_name);
-    fix->smem_start = videomemory;
+    fix->smem_start = (caddr_t)videomemory;
     fix->smem_len = videomemorysize;
     fix->type = FB_TYPE_PACKED_PIXELS;
     fix->type_aux = 0;
--- linux-2.1.42/include/linux/fb.h.orig	Tue Jun 17 22:58:53 1997
+++ linux-2.1.42/include/linux/fb.h	Thu Jun 26 22:40:22 1997
@@ -11,12 +11,12 @@
 
 /* ioctls
    0x46 is 'F'								*/
-#define FBIOGET_VSCREENINFO 	0x4600
-#define FBIOPUT_VSCREENINFO 	0x4601
-#define FBIOGET_FSCREENINFO 	0x4602
+#define FBIOGET_VSCREENINFO	0x4600
+#define FBIOPUT_VSCREENINFO	0x4601
+#define FBIOGET_FSCREENINFO	0x4602
 #define FBIOGETCMAP		0x4604
 #define FBIOPUTCMAP		0x4605
-#define FBIOPAN_DISPLAY         0x4606
+#define FBIOPAN_DISPLAY		0x4606
 /* 0x4607-0x460B are defined below */
 /* #define FBIOGET_MONITORSPEC	0x460C */
 /* #define FBIOPUT_MONITORSPEC	0x460D */
@@ -38,22 +38,22 @@
 
 struct fb_fix_screeninfo {
 	char id[16];			/* identification string eg "TT Builtin" */
-	unsigned long smem_start;	/* Start of frame buffer mem */
-	unsigned long smem_len;		/* Length of frame buffer mem */	
-	int type;			/* see FB_TYPE_* 		*/
-	int type_aux;			/* Interleave for interleaved Planes */
-	int visual;			/* see FB_VISUAL_*  		*/ 
-	u_short xpanstep;               /* zero if no hardware panning  */
-        u_short ypanstep;               /* zero if no hardware panning  */
-        u_short ywrapstep;              /* zero if no hardware ywrap    */
-        u_long line_length;             /* length of a line in bytes    */
-        short reserved[9];              /* Reserved for future compatibility */
+	caddr_t smem_start;		/* Start of frame buffer mem */
+	size_t long smem_len;		/* Length of frame buffer mem */	
+	__u32 type;			/* see FB_TYPE_*		*/
+	__u32 type_aux;			/* Interleave for interleaved Planes */
+	__u32 visual;			/* see FB_VISUAL_*		*/ 
+	__u16 xpanstep;			/* zero if no hardware panning  */
+	__u16 ypanstep;			/* zero if no hardware panning  */
+	__u16 ywrapstep;		/* zero if no hardware ywrap    */
+	__u32 line_length;		/* length of a line in bytes    */
+	__u16 reserved[9];		/* Reserved for future compatibility */
 };
 
 struct fb_bitfield {
-	int offset;			/* beginning of bitfield	*/
-	int length;			/* length of bitfield		*/
-	int msb_right;			/* != 0 : Most significant bit is */ 
+	__u32 offset;			/* beginning of bitfield	*/
+	__u32 length;			/* length of bitfield		*/
+	__u32 msb_right;		/* != 0 : Most significant bit is */ 
 					/* right */ 
 };
 
@@ -82,7 +82,7 @@
 					/* vtotal = 121d/242n/484i => NTSC */
 
 #define FB_VMODE_NONINTERLACED  0	/* non interlaced */
-#define FB_VMODE_INTERLACED 	1	/* interlaced	*/
+#define FB_VMODE_INTERLACED	1	/* interlaced	*/
 #define FB_VMODE_DOUBLE		2	/* double scan */
 #define FB_VMODE_MASK		255
 
@@ -91,55 +91,55 @@
 #define FB_VMODE_CONUPDATE	512	/* don't update x/yoffset	*/
 
 struct fb_var_screeninfo {
-	int xres;			/* visible resolution		*/
-	int yres;
-	int xres_virtual;		/* virtual resolution		*/
-	int yres_virtual;
-	int xoffset;			/* offset from virtual to visible */
-	int yoffset;			/* resolution			*/
+	__u32 xres;			/* visible resolution		*/
+	__u32 yres;
+	__u32 xres_virtual;		/* virtual resolution		*/
+	__u32 yres_virtual;
+	__u32 xoffset;			/* offset from virtual to visible */
+	__u32 yoffset;			/* resolution			*/
 
-	int bits_per_pixel;		/* guess what 			*/
-	int grayscale;			/* != 0 Graylevels instead of colors */
+	__u32 bits_per_pixel;		/* guess what			*/
+	__u32 grayscale;		/* != 0 Graylevels instead of colors */
 
 	struct fb_bitfield red;		/* bitfield in fb mem if true color, */
 	struct fb_bitfield green;	/* else only length is significant */
 	struct fb_bitfield blue;
 	struct fb_bitfield transp;	/* transparency			*/	
 
-	int nonstd;			/* != 0 Non standard pixel format */
+	__u32 nonstd;			/* != 0 Non standard pixel format */
 
-	int activate;			/* see FB_ACTIVATE_* 		*/
+	__u32 activate;			/* see FB_ACTIVATE_*		*/
 
-	int height;			/* height of picture in mm    */
-	int width;			/* width of picture in mm     */
+	__u32 height;			/* height of picture in mm    */
+	__u32 width;			/* width of picture in mm     */
 
-	int accel;			/* see FB_ACCEL_*		*/
+	__u32 accel;			/* see FB_ACCEL_*		*/
 
 	/* Timing: All values in pixclocks, except pixclock (of course) */
-	unsigned long pixclock;		/* pixel clock in ps (pico seconds) */
-	unsigned long left_margin;	/* time from sync to picture	*/
-	unsigned long right_margin;	/* time from picture to sync	*/
-	unsigned long upper_margin;	/* time from sync to picture	*/
-	unsigned long lower_margin;
-	unsigned long hsync_len;	/* length of horizontal sync	*/
-	unsigned long vsync_len;	/* length of vertical sync	*/
-	int sync;			/* see FB_SYNC_*		*/
-	int vmode;			/* see FB_VMODE_*		*/
-	int reserved[6];		/* Reserved for future compatibility */
+	__u32 pixclock;			/* pixel clock in ps (pico seconds) */
+	__u32 left_margin;		/* time from sync to picture	*/
+	__u32 right_margin;		/* time from picture to sync	*/
+	__u32 upper_margin;		/* time from sync to picture	*/
+	__u32 lower_margin;
+	__u32 hsync_len;		/* length of horizontal sync	*/
+	__u32 vsync_len;		/* length of vertical sync	*/
+	__u32 sync;			/* see FB_SYNC_*		*/
+	__u32 vmode;			/* see FB_VMODE_*		*/
+	__u32 reserved[6];		/* Reserved for future compatibility */
 };
 
 struct fb_cmap {
-	int start;			/* First entry	*/
-	int len;			/* Number of entries */
-	unsigned short *red;		/* Red values	*/
-	unsigned short *green;
-	unsigned short *blue;
-	unsigned short *transp;		/* transparency, can be NULL */
+	__u32 start;			/* First entry	*/
+	__u32 len;			/* Number of entries */
+	__u16 *red;			/* Red values	*/
+	__u16 *green;
+	__u16 *blue;
+	__u16 *transp;			/* transparency, can be NULL */
 };
 
 struct fb_con2fbmap {
-        int console;
-	int framebuffer;
+	__u32 console;
+	__u32 framebuffer;
 };
 
 #ifdef __KERNEL__
@@ -161,8 +161,8 @@
 	/* set colormap			*/
 	int (*fb_set_cmap) (struct fb_cmap *, int, int);
 	/* pan display                   */
-        int (*fb_pan_display) (struct fb_var_screeninfo *, int);
-        /* perform fb specific ioctl	*/
+	int (*fb_pan_display) (struct fb_var_screeninfo *, int);
+	/* perform fb specific ioctl	*/
 	int (*fb_ioctl)(struct inode *, struct file *, unsigned int,
 			unsigned long, int);
 };
@@ -249,10 +249,10 @@
 			 int fsfromto);
 extern int fb_get_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
 		       int kspc, int (*getcolreg)(u_int, u_int *, u_int *,
-		       				  u_int *, u_int *));
+						  u_int *, u_int *));
 extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_var_screeninfo *var,
 		       int kspc, int (*setcolreg)(u_int, u_int, u_int, u_int,
-		       				  u_int));
+						  u_int));
 extern struct fb_cmap *fb_default_cmap(int bpp);
 extern void fb_invert_cmaps(void);
 
@@ -260,8 +260,8 @@
 
 #if 1
 
-#define FBCMD_GET_CURRENTPAR	    0xDEAD0005
-#define FBCMD_SET_CURRENTPAR        0xDEAD8005
+#define FBCMD_GET_CURRENTPAR	0xDEAD0005
+#define FBCMD_SET_CURRENTPAR	0xDEAD8005
 
 #endif
 
@@ -280,26 +280,26 @@
 
 
 struct fb_fix_cursorinfo {
-	u_short crsr_width;		/* width and height of the cursor in */
-	u_short crsr_height;		/* pixels (zero if no cursor)	*/
-	u_short crsr_xsize;		/* cursor size in display pixels */
-	u_short crsr_ysize;
-	u_short crsr_color1;		/* colormap entry for cursor color1 */
-	u_short crsr_color2;		/* colormap entry for cursor color2 */
+	__u16 crsr_width;		/* width and height of the cursor in */
+	__u16 crsr_height;		/* pixels (zero if no cursor)	*/
+	__u16 crsr_xsize;		/* cursor size in display pixels */
+	__u16 crsr_ysize;
+	__u16 crsr_color1;		/* colormap entry for cursor color1 */
+	__u16 crsr_color2;		/* colormap entry for cursor color2 */
 };
 
 struct fb_var_cursorinfo {
-        u_short width;
-        u_short height;
-        u_short xspot;
-        u_short yspot;
-        u_char data[1];                 /* field with [height][width]        */
+	__u16 width;
+	__u16 height;
+	__u16 xspot;
+	__u16 yspot;
+	__u8 data[1];			/* field with [height][width]        */
 };
 
 struct fb_cursorstate {
-	short xoffset;
-	short yoffset;
-	u_short mode;
+	__s16 xoffset;
+	__s16 yoffset;
+	__u16 mode;
 };
 
 #define FB_CURSOR_OFF		0
@@ -314,21 +314,21 @@
 #define FB_LINE_FILLED	4
 
 struct fb_line {
-	int start_x;
-	int start_y;
-	int end_x;
-	int end_y;
-	int color;
-	int option;
+	__s32 start_x;
+	__s32 start_y;
+	__s32 end_x;
+	__s32 end_y;
+	__u32 color;
+	__u32 option;
 };
 
 struct fb_move {
-	int src_x;
-	int src_y;
-	int dest_x;
-	int dest_y;
-	int height;
-	int width;
+	__u32 src_x;
+	__u32 src_y;
+	__u32 dest_x;
+	__u32 dest_y;
+	__u32 height;
+	__u32 width;
 };
 
 #endif /* Preliminary */

Greetings,

						Geert

--
Geert Uytterhoeven                     Geert.Uytterhoeven@cs.kuleuven.ac.be
Wavelets, Linux/m68k on Amiga          http://www.cs.kuleuven.ac.be/~geert/
Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium

