Re: non-linux support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Mike Frysinger, le Sat 11 Aug 2007 22:48:43 -0400, a écrit :
> On Friday 10 August 2007, Samuel Thibault wrote:
> > - #include <linux/types.h> is turned into #include <stdint.h>, much more
> >   portable, and __uxy were turned into uintxy_t.
> 
> sounds good regardless ... uintxy_t types are a standard, __uxy are a hack ;)

Ok, here is a patch:

Use u?int{8,16,32,64} instead of Linux-specific __[us]{8,16,32,64}

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>

diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
index 05c8cd6..35a0c5e 100644
--- a/fdisk/cfdisk.c
+++ b/fdisk/cfdisk.c
@@ -78,7 +78,6 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
-#include <linux/types.h>
 
 #include "nls.h"
 #include "xstrncpy.h"
diff --git a/fdisk/fdiskaixlabel.h b/fdisk/fdiskaixlabel.h
index 106b5ac..324b9ae 100644
--- a/fdisk/fdiskaixlabel.h
+++ b/fdisk/fdiskaixlabel.h
@@ -1,7 +1,7 @@
 #ifndef FDISK_AIX_LABEL_H
 #define FDISK_AIX_LABEL_H
 
-#include <linux/types.h>   /* for __u32 etc */
+#include <stdint.h>
 /*
  * Copyright (C) Andreas Neuper, Sep 1998.
  *	This file may be redistributed under
diff --git a/fdisk/fdiskbsdlabel.h b/fdisk/fdiskbsdlabel.h
index 1fabaae..1838dca 100644
--- a/fdisk/fdiskbsdlabel.h
+++ b/fdisk/fdiskbsdlabel.h
@@ -34,10 +34,10 @@
  * SUCH DAMAGE.
  */
 
-#include <linux/types.h>	/* for __u32, __u16, __u8, __s16 */
+#include <stdint.h>
 
 #ifndef BSD_DISKMAGIC
-#define BSD_DISKMAGIC     ((__u32) 0x82564557)
+#define BSD_DISKMAGIC     ((uint32_t) 0x82564557)
 #endif
 
 #ifndef BSD_MAXPARTITIONS
@@ -63,31 +63,31 @@
 #define	BSD_SBSIZE        8192		/* max size of fs superblock */
 
 struct xbsd_disklabel {
-	__u32	d_magic;		/* the magic number */
-	__s16	d_type;			/* drive type */
-	__s16	d_subtype;		/* controller/d_type specific */
+	uint32_t	d_magic;		/* the magic number */
+	int16_t	d_type;			/* drive type */
+	int16_t	d_subtype;		/* controller/d_type specific */
 	char	d_typename[16];		/* type name, e.g. "eagle" */
 	char	d_packname[16];			/* pack identifier */ 
 			/* disk geometry: */
-	__u32	d_secsize;		/* # of bytes per sector */
-	__u32	d_nsectors;		/* # of data sectors per track */
-	__u32	d_ntracks;		/* # of tracks per cylinder */
-	__u32	d_ncylinders;		/* # of data cylinders per unit */
-	__u32	d_secpercyl;		/* # of data sectors per cylinder */
-	__u32	d_secperunit;		/* # of data sectors per unit */
+	uint32_t	d_secsize;		/* # of bytes per sector */
+	uint32_t	d_nsectors;		/* # of data sectors per track */
+	uint32_t	d_ntracks;		/* # of tracks per cylinder */
+	uint32_t	d_ncylinders;		/* # of data cylinders per unit */
+	uint32_t	d_secpercyl;		/* # of data sectors per cylinder */
+	uint32_t	d_secperunit;		/* # of data sectors per unit */
 	/*
 	 * Spares (bad sector replacements) below
 	 * are not counted in d_nsectors or d_secpercyl.
 	 * Spare sectors are assumed to be physical sectors
 	 * which occupy space at the end of each track and/or cylinder.
 	 */
-	__u16	d_sparespertrack;	/* # of spare sectors per track */
-	__u16	d_sparespercyl;		/* # of spare sectors per cylinder */
+	uint16_t	d_sparespertrack;	/* # of spare sectors per track */
+	uint16_t	d_sparespercyl;		/* # of spare sectors per cylinder */
 	/*
 	 * Alternate cylinders include maintenance, replacement,
 	 * configuration description areas, etc.
 	 */
-	__u32	d_acylinders;		/* # of alt. cylinders per unit */
+	uint32_t	d_acylinders;		/* # of alt. cylinders per unit */
 
 			/* hardware characteristics: */
 	/*
@@ -106,30 +106,30 @@ struct xbsd_disklabel {
 	 * Finally, d_cylskew is the offset of sector 0 on cylinder N
 	 * relative to sector 0 on cylinder N-1.
 	 */
-	__u16	d_rpm;			/* rotational speed */
-	__u16	d_interleave;		/* hardware sector interleave */
-	__u16	d_trackskew;		/* sector 0 skew, per track */
-	__u16	d_cylskew;		/* sector 0 skew, per cylinder */
-	__u32	d_headswitch;		/* head switch time, usec */
-	__u32	d_trkseek;		/* track-to-track seek, usec */
-	__u32	d_flags;		/* generic flags */
+	uint16_t	d_rpm;			/* rotational speed */
+	uint16_t	d_interleave;		/* hardware sector interleave */
+	uint16_t	d_trackskew;		/* sector 0 skew, per track */
+	uint16_t	d_cylskew;		/* sector 0 skew, per cylinder */
+	uint32_t	d_headswitch;		/* head switch time, usec */
+	uint32_t	d_trkseek;		/* track-to-track seek, usec */
+	uint32_t	d_flags;		/* generic flags */
 #define NDDATA 5
-	__u32	d_drivedata[NDDATA];	/* drive-type specific information */
+	uint32_t	d_drivedata[NDDATA];	/* drive-type specific information */
 #define NSPARE 5
-	__u32	d_spare[NSPARE];	/* reserved for future use */
-	__u32	d_magic2;		/* the magic number (again) */
-	__u16	d_checksum;		/* xor of data incl. partitions */
+	uint32_t	d_spare[NSPARE];	/* reserved for future use */
+	uint32_t	d_magic2;		/* the magic number (again) */
+	uint16_t	d_checksum;		/* xor of data incl. partitions */
 			/* filesystem and partition information: */
-	__u16	d_npartitions;	        /* number of partitions in following */
-	__u32	d_bbsize;	        /* size of boot area at sn0, bytes */
-	__u32	d_sbsize;	        /* max size of fs superblock, bytes */
+	uint16_t	d_npartitions;	        /* number of partitions in following */
+	uint32_t	d_bbsize;	        /* size of boot area at sn0, bytes */
+	uint32_t	d_sbsize;	        /* max size of fs superblock, bytes */
 	struct xbsd_partition	 {	/* the partition table */
-		__u32	p_size;	        /* number of sectors in partition */
-		__u32	p_offset;       /* starting sector */
-		__u32	p_fsize;        /* filesystem basic fragment size */
-		__u8	p_fstype;       /* filesystem type, see below */
-		__u8	p_frag;	        /* filesystem fragments per block */
-		__u16	p_cpg;	        /* filesystem cylinders per group */
+		uint32_t	p_size;	        /* number of sectors in partition */
+		uint32_t	p_offset;       /* starting sector */
+		uint32_t	p_fsize;        /* filesystem basic fragment size */
+		uint8_t	p_fstype;       /* filesystem type, see below */
+		uint8_t	p_frag;	        /* filesystem fragments per block */
+		uint16_t	p_cpg;	        /* filesystem cylinders per group */
 	} d_partitions[BSD_MAXPARTITIONS]; /* actually may be more */
 };
 
diff --git a/fdisk/fdiskmaclabel.h b/fdisk/fdiskmaclabel.h
index a13900d..e664a15 100644
--- a/fdisk/fdiskmaclabel.h
+++ b/fdisk/fdiskmaclabel.h
@@ -1,7 +1,7 @@
 #ifndef FDISK_MAC_LABEL_H
 #define FDISK_MAC_LABEL_H
 
-#include <linux/types.h>   /* for __u32 etc */
+#include <sys/types.h>
 /*
  * Copyright (C) Andreas Neuper, Sep 1998.
  *	This file may be redistributed under
diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c
index 7e189fb..e7ade26 100644
--- a/fdisk/fdisksgilabel.c
+++ b/fdisk/fdisksgilabel.c
@@ -100,11 +100,11 @@ struct systypes sgi_sys_types[] = {
 
 static inline unsigned short
 __swap16(unsigned short x) {
-        return (((__u16)(x) & 0xFF) << 8) | (((__u16)(x) & 0xFF00) >> 8);
+        return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8);
 }
 
-static inline __u32
-__swap32(__u32 x) {
+static inline uint32_t
+__swap32(uint32_t x) {
         return (((x & 0xFF) << 24) |
 		((x & 0xFF00) << 8) |
 		((x & 0xFF0000) >> 8) |
@@ -222,8 +222,8 @@ sgi_list_table(int xtra) {
 	       w + 1, _("Device"));
 	for (i = 0 ; i < partitions; i++) {
 		if (sgi_get_num_sectors(i) || debug) {
-			__u32 start = sgi_get_start_sector(i);
-			__u32 len = sgi_get_num_sectors(i);
+			uint32_t start = sgi_get_start_sector(i);
+			uint32_t len = sgi_get_num_sectors(i);
 			kpi++;		/* only count nonempty partitions */
 			printf(
 				"%2d: %s %4s %9ld %9ld %9ld  %2x  %s\n",
@@ -244,8 +244,8 @@ sgi_list_table(int xtra) {
 	       sgilabel->boot_file);
 	for (i = 0 ; i < volumes; i++) {
 		if (sgilabel->directory[i].vol_file_size) {
-			__u32 start = SSWAP32(sgilabel->directory[i].vol_file_start);
-			__u32 len = SSWAP32(sgilabel->directory[i].vol_file_size);
+			uint32_t start = SSWAP32(sgilabel->directory[i].vol_file_start);
+			uint32_t len = SSWAP32(sgilabel->directory[i].vol_file_size);
 			unsigned char *name = sgilabel->directory[i].vol_file_name;
 			printf(_("%2d: %-10s sector%5u size%8u\n"),
 			       i, name, (unsigned int) start,
diff --git a/fdisk/fdisksgilabel.h b/fdisk/fdisksgilabel.h
index 02b3e9d..d69616a 100644
--- a/fdisk/fdisksgilabel.h
+++ b/fdisk/fdisksgilabel.h
@@ -1,7 +1,7 @@
 #ifndef FDISK_SGI_LABEL_H
 #define FDISK_SGI_LABEL_H
 
-#include <linux/types.h>   /* for __u32 etc */
+#include <stdint.h>
 /*
  * Copyright (C) Andreas Neuper, Sep 1998.
  *	This file may be modified and redistributed under
@@ -99,9 +99,9 @@ typedef struct {
 #define	SGI_INFO_MAGIC		0x00072959
 #define	SGI_INFO_MAGIC_SWAPPED	0x59290700
 #define SSWAP16(x) (other_endian ? __swap16(x) \
-                                 : (__u16)(x))
+                                 : (uint16_t)(x))
 #define SSWAP32(x) (other_endian ? __swap32(x) \
-                                 : (__u32)(x))
+                                 : (uint32_t)(x))
 
 /* fdisk.c */
 #define sgilabel ((sgi_partition *)MBRbuffer)
diff --git a/fdisk/fdisksunlabel.c b/fdisk/fdisksunlabel.c
index 60ade06..060bbb5 100644
--- a/fdisk/fdisksunlabel.c
+++ b/fdisk/fdisksunlabel.c
@@ -57,16 +57,16 @@ struct systypes sun_sys_types[] = {
 };
 
 static inline unsigned short __swap16(unsigned short x) {
-        return (((__u16)(x) & 0xFF) << 8) | (((__u16)(x) & 0xFF00) >> 8);
+        return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8);
 }
-static inline __u32 __swap32(__u32 x) {
-        return (((__u32)(x) & 0xFF) << 24) | (((__u32)(x) & 0xFF00) << 8) | (((__u32)(x) & 0xFF0000) >> 8) | (((__u32)(x) & 0xFF000000) >> 24);
+static inline uint32_t __swap32(uint32_t x) {
+        return (((uint32_t)(x) & 0xFF) << 24) | (((uint32_t)(x) & 0xFF00) << 8) | (((uint32_t)(x) & 0xFF0000) >> 8) | (((uint32_t)(x) & 0xFF000000) >> 24);
 }
 
 #define SSWAP16(x) (other_endian ? __swap16(x) \
-				 : (__u16)(x))
+				 : (uint16_t)(x))
 #define SSWAP32(x) (other_endian ? __swap32(x) \
-				 : (__u32)(x))
+				 : (uint32_t)(x))
 
 #ifndef IDE0_MAJOR
 #define IDE0_MAJOR 3
@@ -96,7 +96,7 @@ void guess_device_type(int fd)
 	}
 }
 
-static void set_sun_partition(int i, __u32 start, __u32 stop, __u16 sysid)
+static void set_sun_partition(int i, uint32_t start, uint32_t stop, uint16_t sysid)
 {
 	sunlabel->part_tags[i].tag = SSWAP16(sysid);
 	sunlabel->part_tags[i].flag = SSWAP16(0);
@@ -270,7 +270,7 @@ void create_sunlabel(void)
 	set_changed(0);
 }
 
-void toggle_sunflags(int i, __u16 mask)
+void toggle_sunflags(int i, uint16_t mask)
 {
 	struct sun_tag_flag *p = &sunlabel->part_tags[i];
 
@@ -279,7 +279,7 @@ void toggle_sunflags(int i, __u16 mask)
 	set_changed(i);
 }
 
-static void fetch_sun(__u32 *starts, __u32 *lens, __u32 *start, __u32 *stop)
+static void fetch_sun(uint32_t *starts, uint32_t *lens, uint32_t *start, uint32_t *stop)
 {
 	int i, continuous = 1;
 
@@ -328,7 +328,7 @@ static int verify_sun_cmp(int *a, int *b)
 
 void verify_sun(void)
 {
-    __u32 starts[SUN_NUM_PARTITIONS], lens[SUN_NUM_PARTITIONS], start, stop;
+    uint32_t starts[SUN_NUM_PARTITIONS], lens[SUN_NUM_PARTITIONS], start, stop;
     int i,j,k,starto,endo;
     int array[SUN_NUM_PARTITIONS];
 
@@ -394,10 +394,10 @@ void verify_sun(void)
 
 void add_sun_partition(int n, int sys)
 {
-	__u32 starts[SUN_NUM_PARTITIONS], lens[SUN_NUM_PARTITIONS];
+	uint32_t starts[SUN_NUM_PARTITIONS], lens[SUN_NUM_PARTITIONS];
 	struct sun_partition *part = &sunlabel->partitions[n];
 	struct sun_tag_flag *tag = &sunlabel->part_tags[n];
-	__u32 start, stop, stop2;
+	uint32_t start, stop, stop2;
 	int whole_disk = 0;
 		
 	char mesg[256];
@@ -530,7 +530,7 @@ void sun_delete_partition(int i)
 	part->num_sectors = 0;
 }
 
-int sun_change_sysid(int i, __u16 sys)
+int sun_change_sysid(int i, uint16_t sys)
 {
 	struct sun_partition *part = &sunlabel->partitions[i];
 	struct sun_tag_flag *tag = &sunlabel->part_tags[i];
@@ -597,8 +597,8 @@ void sun_list_table(int xtra)
 		struct sun_tag_flag *tag = &sunlabel->part_tags[i];
 
 		if (part->num_sectors) {
-			__u32 start = SSWAP32(part->start_cylinder) * heads * sectors;
-			__u32 len = SSWAP32(part->num_sectors);
+			uint32_t start = SSWAP32(part->start_cylinder) * heads * sectors;
+			uint32_t len = SSWAP32(part->num_sectors);
 			printf(
 			    "%s %c%c %9ld %9ld %9ld%c  %2x  %s\n",
 /* device */		  partname(disk_device, i+1, w),
diff --git a/fdisk/fdisksunlabel.h b/fdisk/fdisksunlabel.h
index fba67f7..b7419cb 100644
--- a/fdisk/fdisksunlabel.h
+++ b/fdisk/fdisksunlabel.h
@@ -1,15 +1,15 @@
 #ifndef FDISK_SUN_LABEL_H
 #define FDISK_SUN_LABEL_H
 
-#include <linux/types.h>   /* for __u16, __u32 */
+#include <stdint.h>
 
 struct sun_partition {
-	__u32	start_cylinder;
-	__u32	num_sectors;
+	uint32_t	start_cylinder;
+	uint32_t	num_sectors;
 };
 
 struct sun_tag_flag {
-	__u16	tag;
+	uint16_t	tag;
 #define SUN_TAG_UNASSIGNED	0x00	/* Unassigned partition */
 #define SUN_TAG_BOOT		0x01	/* Boot partition	*/
 #define SUN_TAG_ROOT		0x02	/* Root filesystem	*/
@@ -27,7 +27,7 @@ struct sun_tag_flag {
 #define SUN_TAG_LINUX_LVM	0x8e	/* Linux LVM		*/
 #define SUN_TAG_LINUX_RAID	0xfd	/* LInux RAID		*/
 
-	__u16	flag;
+	uint16_t	flag;
 #define SUN_FLAG_UNMNT		0x01	/* Unmountable partition*/
 #define SUN_FLAG_RONLY		0x10	/* Read only		*/
 };
@@ -43,32 +43,32 @@ struct sun_tag_flag {
 
 struct sun_disk_label {
 	char			label_id[SUN_LABEL_ID_SIZE];
-	__u32			version;
+	uint32_t			version;
 	char			volume_id[SUN_VOLUME_ID_SIZE];
-	__u16			num_partitions;
+	uint16_t			num_partitions;
 	struct sun_tag_flag	part_tags[SUN_NUM_PARTITIONS];
-	__u32			bootinfo[3];
-	__u32			sanity;
-	__u32			resv[10];
-	__u32			part_timestamps[SUN_NUM_PARTITIONS];
-	__u32			write_reinstruct;
-	__u32			read_reinstruct;
-	__u8			pad[148];
-	__u16			rpm;
-	__u16			pcyl;
-	__u16			apc;
-	__u16			resv1;
-	__u16			resv2;
-	__u16			intrlv;
-	__u16			ncyl;
-	__u16			acyl;
-	__u16			nhead;
-	__u16			nsect;
-	__u16			resv3;
-	__u16			resv4;
+	uint32_t			bootinfo[3];
+	uint32_t			sanity;
+	uint32_t			resv[10];
+	uint32_t			part_timestamps[SUN_NUM_PARTITIONS];
+	uint32_t			write_reinstruct;
+	uint32_t			read_reinstruct;
+	uint8_t			pad[148];
+	uint16_t			rpm;
+	uint16_t			pcyl;
+	uint16_t			apc;
+	uint16_t			resv1;
+	uint16_t			resv2;
+	uint16_t			intrlv;
+	uint16_t			ncyl;
+	uint16_t			acyl;
+	uint16_t			nhead;
+	uint16_t			nsect;
+	uint16_t			resv3;
+	uint16_t			resv4;
 	struct sun_partition	partitions[SUN_NUM_PARTITIONS];
-	__u16			magic;
-	__u16			cksum;
+	uint16_t			magic;
+	uint16_t			cksum;
 };
 
 #define SUN_LABEL_MAGIC		0xDABE
@@ -82,7 +82,7 @@ extern int check_sun_label(void);
 extern void sun_nolabel(void);
 extern void create_sunlabel(void);
 extern void sun_delete_partition(int i);
-extern int sun_change_sysid(int i, __u16 sys);
+extern int sun_change_sysid(int i, uint16_t sys);
 extern void sun_list_table(int xtra);
 extern void verify_sun(void);
 extern void add_sun_partition(int n, int sys);
@@ -93,7 +93,7 @@ extern void sun_set_xcyl(void);
 extern void sun_set_ilfact(void);
 extern void sun_set_rspeed(void);
 extern void sun_set_pcylcount(void);
-extern void toggle_sunflags(int i, __u16 mask);
+extern void toggle_sunflags(int i, uint16_t mask);
 extern int sun_get_sysid(int i);
 
 #endif /* FDISK_SUN_LABEL_H */
diff --git a/mount/loop.h b/mount/loop.h
index 951a5d1..c4586bf 100644
--- a/mount/loop.h
+++ b/mount/loop.h
@@ -14,6 +14,7 @@
 #define LO_KEY_SIZE	32
 
 #include "my_dev_t.h"
+#include <stdint.h>
 
 struct loop_info {
 	int		lo_number;
@@ -30,22 +31,18 @@ struct loop_info {
 	char		reserved[4];
 };
 
-/*
- * Where to get __u8, __u32, __u64? Let us use unsigned char/int/long long
- * and get punished when someone comes with 128-bit long longs.
- */
 struct loop_info64 {
-	unsigned long long	lo_device;
-	unsigned long long	lo_inode;
-	unsigned long long	lo_rdevice;
-	unsigned long long	lo_offset;
-	unsigned long long	lo_sizelimit; /* bytes, 0 == max available */
-	unsigned int		lo_number;
-	unsigned int		lo_encrypt_type;
-	unsigned int		lo_encrypt_key_size;
-	unsigned int		lo_flags;
-	unsigned char		lo_file_name[LO_NAME_SIZE];
-	unsigned char		lo_crypt_name[LO_NAME_SIZE];
-	unsigned char		lo_encrypt_key[LO_KEY_SIZE];
-	unsigned long long	lo_init[2];
+	uint64_t	lo_device;
+	uint64_t	lo_inode;
+	uint64_t	lo_rdevice;
+	uint64_t	lo_offset;
+	uint64_t	lo_sizelimit; /* bytes, 0 == max available */
+	uint32_t	lo_number;
+	uint32_t	lo_encrypt_type;
+	uint32_t	lo_encrypt_key_size;
+	uint32_t	lo_flags;
+	uint8_t		lo_file_name[LO_NAME_SIZE];
+	uint8_t		lo_crypt_name[LO_NAME_SIZE];
+	uint8_t		lo_encrypt_key[LO_KEY_SIZE];
+	uint64_t	lo_init[2];
 };
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux