From owner-svn-src-head@FreeBSD.ORG Wed Aug 7 00:00:50 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0145F5A2; Wed, 7 Aug 2013 00:00:50 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D3A2A2BA7; Wed, 7 Aug 2013 00:00:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7700nhx021150; Wed, 7 Aug 2013 00:00:49 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7700mdj021132; Wed, 7 Aug 2013 00:00:48 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201308070000.r7700mdj021132@svn.freebsd.org> From: Marcel Moolenaar Date: Wed, 7 Aug 2013 00:00:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254015 - in head: sbin/fdisk_pc98 sys/boot/pc98/boot2 sys/boot/pc98/libpc98 sys/geom sys/geom/part sys/sys usr.sbin/boot98cfg X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Aug 2013 00:00:50 -0000 Author: marcel Date: Wed Aug 7 00:00:48 2013 New Revision: 254015 URL: http://svnweb.freebsd.org/changeset/base/254015 Log: Change to not redefine the same symbols that are being defined in . Instead give the symbols here a "PC98_" prefix. This way, both and can be included in the same C source file. The renaming is trivial. The only gotcha is that DOSBBSECTOR is also redefined from 0 to 1. This because DOSBBSECTOR was always used in conjunction with an addition of 1. The PC98_BBSECTOR symbol is defined as 1 and the expression is simplified. Note: it is not believed that ports are seriously impacted; or at all for that matter. Approved by: nyan@ Modified: head/sbin/fdisk_pc98/fdisk.c head/sys/boot/pc98/boot2/boot2.c head/sys/boot/pc98/libpc98/biosdisk.c head/sys/geom/geom_pc98.c head/sys/geom/part/g_part_pc98.c head/sys/sys/diskpc98.h head/usr.sbin/boot98cfg/boot98cfg.c Modified: head/sbin/fdisk_pc98/fdisk.c ============================================================================== --- head/sbin/fdisk_pc98/fdisk.c Tue Aug 6 21:44:54 2013 (r254014) +++ head/sbin/fdisk_pc98/fdisk.c Wed Aug 7 00:00:48 2013 (r254015) @@ -254,7 +254,7 @@ main(int argc, char *argv[]) dos_sectors); printf("Part %11s %11s %4s %4s %-16s\n", "Start", "Size", "MID", "SID", "Name"); - for (i = 0; i < NDOSPART; i++) { + for (i = 0; i < PC98_NPARTS; i++) { partp = ((struct pc98_partition *) &mboot.parts) + i; if (partp->dp_sid == 0) continue; @@ -310,7 +310,7 @@ main(int argc, char *argv[]) printf("Warning: BIOS sector numbering starts with sector 1\n"); printf("Information from DOS bootblock is:\n"); if (partition == -1) - for (i = 1; i <= NDOSPART; i++) + for (i = 1; i <= PC98_NPARTS; i++) change_part(i, v_flag); else change_part(partition, 1); @@ -367,7 +367,7 @@ print_s0(int which) print_params(); printf("Information from DOS bootblock is:\n"); if (which == -1) { - for (i = 1; i <= NDOSPART; i++) + for (i = 1; i <= PC98_NPARTS; i++) if (v_flag || !part_unused(i)) { printf("%d: ", i); print_part(i); @@ -414,7 +414,7 @@ static void init_boot(void) { - mboot.signature = DOSMAGIC; + mboot.signature = PC98_MAGIC; } @@ -517,7 +517,7 @@ change_active(int which) int active, i, new, tmp; active = -1; - for (i = 0; i < NDOSPART; i++) { + for (i = 0; i < PC98_NPARTS; i++) { if ((partp[i].dp_sid & PC98_SID_ACTIVE) == 0) continue; printf("Partition %d is marked active\n", i + 1); @@ -672,7 +672,7 @@ write_disk(off_t sector, void *buf) if (error == sz) return (0); - for (i = 0; i < NDOSPART; i++) { + for (i = 0; i < PC98_NPARTS; i++) { sprintf(fbuf, "%ss%d", disk, i + 1); fdw = open(fbuf, O_RDWR, 0); if (fdw < 0) @@ -731,7 +731,7 @@ read_s0() warnx("can't read fdisk partition table"); return -1; } - if (mboot.signature != DOSMAGIC) { + if (mboot.signature != PC98_MAGIC) { warnx("invalid fdisk partition table found"); /* So should we initialize things */ return -1; @@ -911,7 +911,7 @@ reset_boot(void) struct pc98_partition *partp; init_boot(); - for (i = 1; i <= NDOSPART; i++) { + for (i = 1; i <= PC98_NPARTS; i++) { partp = ((struct pc98_partition *) &mboot.parts) + i - 1; bzero((char *)partp, sizeof (struct pc98_partition)); } Modified: head/sys/boot/pc98/boot2/boot2.c ============================================================================== --- head/sys/boot/pc98/boot2/boot2.c Tue Aug 6 21:44:54 2013 (r254014) +++ head/sys/boot/pc98/boot2/boot2.c Wed Aug 7 00:00:48 2013 (r254015) @@ -330,10 +330,10 @@ check_slice(void) if (dsk.type == TYPE_FD) return (WHOLE_DISK_SLICE); - if (drvread(sec, DOSBBSECTOR + 1)) + if (drvread(sec, PC98_BBSECTOR)) return (WHOLE_DISK_SLICE); /* Read error */ - dp = (void *)(sec + DOSPARTOFF); - for (i = 0; i < NDOSPART; i++) { + dp = (void *)(sec + PC98_PARTOFF); + for (i = 0; i < PC98_NPARTS; i++) { if (dp[i].dp_mid == DOSMID_386BSD) { if (dp[i].dp_scyl <= cyl && cyl <= dp[i].dp_ecyl) return (BASE_SLICE + i); @@ -583,7 +583,7 @@ parse() dsk.slice = WHOLE_DISK_SLICE; if (arg[1] == ',') { dsk.slice = *arg - '0' + 1; - if (dsk.slice > NDOSPART + 1) + if (dsk.slice > PC98_NPARTS + 1) return -1; arg += 2; } @@ -626,12 +626,12 @@ dskread(void *buf, unsigned lba, unsigne set_dsk(); if (dsk.type == TYPE_FD) goto unsliced; - if (drvread(sec, DOSBBSECTOR + 1)) + if (drvread(sec, PC98_BBSECTOR)) return -1; - dp = (void *)(sec + DOSPARTOFF); + dp = (void *)(sec + PC98_PARTOFF); sl = dsk.slice; if (sl < BASE_SLICE) { - for (i = 0; i < NDOSPART; i++) + for (i = 0; i < PC98_NPARTS; i++) if (dp[i].dp_mid == DOSMID_386BSD) { sl = BASE_SLICE + i; break; Modified: head/sys/boot/pc98/libpc98/biosdisk.c ============================================================================== --- head/sys/boot/pc98/libpc98/biosdisk.c Tue Aug 6 21:44:54 2013 (r254014) +++ head/sys/boot/pc98/libpc98/biosdisk.c Wed Aug 7 00:00:48 2013 (r254015) @@ -83,7 +83,7 @@ struct open_disk { #define BD_OPTICAL 0x0020 struct disklabel od_disklabel; int od_nslices; /* slice count */ - struct pc98_partition od_slicetab[NDOSPART]; + struct pc98_partition od_slicetab[PC98_NPARTS]; }; /* @@ -528,9 +528,9 @@ bd_open_pc98(struct open_disk *od, struc /* * copy the partition table, then pick up any extended partitions. */ - bcopy(buf + DOSPARTOFF, &od->od_slicetab, - sizeof(struct pc98_partition) * NDOSPART); - od->od_nslices = NDOSPART; /* extended slices start here */ + bcopy(buf + PC98_PARTOFF, &od->od_slicetab, + sizeof(struct pc98_partition) * PC98_NPARTS); + od->od_nslices = PC98_NPARTS; /* extended slices start here */ od->od_flags |= BD_PARTTABOK; dptr = &od->od_slicetab[0]; @@ -647,7 +647,7 @@ bd_open_pc98(struct open_disk *od, struc #define PREF_NONE 7 /* - * slicelimit is in the range 0 .. NDOSPART + * slicelimit is in the range 0 .. PC98_NPARTS */ static int bd_bestslice(struct open_disk *od) Modified: head/sys/geom/geom_pc98.c ============================================================================== --- head/sys/geom/geom_pc98.c Tue Aug 6 21:44:54 2013 (r254014) +++ head/sys/geom/geom_pc98.c Wed Aug 7 00:00:48 2013 (r254015) @@ -56,7 +56,7 @@ FEATURE(geom_pc98, "GEOM NEC PC9800 part struct g_pc98_softc { u_int fwsectors, fwheads, sectorsize; - int type[NDOSPART]; + int type[PC98_NPARTS]; u_char sec[8192]; }; @@ -84,8 +84,8 @@ static int g_pc98_modify(struct g_geom *gp, struct g_pc98_softc *ms, u_char *sec, int len __unused) { int i, error; - off_t s[NDOSPART], l[NDOSPART]; - struct pc98_partition dp[NDOSPART]; + off_t s[PC98_NPARTS], l[PC98_NPARTS]; + struct pc98_partition dp[PC98_NPARTS]; g_topology_assert(); @@ -114,11 +114,11 @@ g_pc98_modify(struct g_geom *gp, struct return (EBUSY); #endif - for (i = 0; i < NDOSPART; i++) + for (i = 0; i < PC98_NPARTS; i++) pc98_partition_dec( sec + 512 + i * sizeof(struct pc98_partition), &dp[i]); - for (i = 0; i < NDOSPART; i++) { + for (i = 0; i < PC98_NPARTS; i++) { /* If start and end are identical it's bogus */ if (dp[i].dp_ssect == dp[i].dp_esect && dp[i].dp_shd == dp[i].dp_ehd && @@ -146,7 +146,7 @@ g_pc98_modify(struct g_geom *gp, struct return (error); } - for (i = 0; i < NDOSPART; i++) { + for (i = 0; i < PC98_NPARTS; i++) { ms->type[i] = (dp[i].dp_sid << 8) | dp[i].dp_mid; g_slice_config(gp, i, G_SLICE_CONFIG_SET, s[i], l[i], ms->sectorsize, "%ss%d", gp->name, i + 1); @@ -269,7 +269,8 @@ g_pc98_taste(struct g_class *mp, struct if (flags == G_TF_NORMAL && !strcmp(pp->geom->class->name, PC98_CLASS_NAME)) return (NULL); - gp = g_slice_new(mp, NDOSPART, pp, &cp, &ms, sizeof *ms, g_pc98_start); + gp = g_slice_new(mp, PC98_NPARTS, pp, &cp, &ms, sizeof *ms, + g_pc98_start); if (gp == NULL) return (NULL); g_topology_unlock(); Modified: head/sys/geom/part/g_part_pc98.c ============================================================================== --- head/sys/geom/part/g_part_pc98.c Tue Aug 6 21:44:54 2013 (r254014) +++ head/sys/geom/part/g_part_pc98.c Wed Aug 7 00:00:48 2013 (r254015) @@ -109,8 +109,8 @@ static struct g_part_scheme g_part_pc98_ g_part_pc98_methods, sizeof(struct g_part_pc98_table), .gps_entrysz = sizeof(struct g_part_pc98_entry), - .gps_minent = NDOSPART, - .gps_maxent = NDOSPART, + .gps_minent = PC98_NPARTS, + .gps_maxent = PC98_NPARTS, .gps_bootcodesz = BOOTSIZE, }; G_PART_SCHEME_DECLARE(g_part_pc98); @@ -259,7 +259,7 @@ g_part_pc98_create(struct g_part_table * basetable->gpt_last = MIN(pp->mediasize / SECSIZE, UINT32_MAX) - 1; table = (struct g_part_pc98_table *)basetable; - le16enc(table->boot + DOSMAGICOFFSET, DOSMAGIC); + le16enc(table->boot + PC98_MAGICOFS, PC98_MAGIC); return (0); } @@ -396,8 +396,8 @@ g_part_pc98_probe(struct g_part_table *t /* We goto out on mismatch. */ res = ENXIO; - magic = le16dec(buf + DOSMAGICOFFSET); - if (magic != DOSMAGIC) + magic = le16dec(buf + PC98_MAGICOFS); + if (magic != PC98_MAGIC) goto out; sum = 0; @@ -408,8 +408,8 @@ g_part_pc98_probe(struct g_part_table *t goto out; } - for (index = 0; index < NDOSPART; index++) { - p = buf + SECSIZE + index * DOSPARTSIZE; + for (index = 0; index < PC98_NPARTS; index++) { + p = buf + SECSIZE + index * PC98_PARTSIZE; if (p[0] == 0 || p[1] == 0) /* !dp_mid || !dp_sid */ continue; scyl = le16dec(p + 10); @@ -456,8 +456,8 @@ g_part_pc98_read(struct g_part_table *ba bcopy(buf + SECSIZE, table->table, sizeof(table->table)); bcopy(buf + SECSIZE*2, table->menu, sizeof(table->menu)); - for (index = NDOSPART - 1; index >= 0; index--) { - p = buf + SECSIZE + index * DOSPARTSIZE; + for (index = PC98_NPARTS - 1; index >= 0; index--) { + p = buf + SECSIZE + index * PC98_PARTSIZE; ent.dp_mid = p[0]; ent.dp_sid = p[1]; ent.dp_dum1 = p[2]; @@ -482,7 +482,7 @@ g_part_pc98_read(struct g_part_table *ba entry->ent = ent; } - basetable->gpt_entries = NDOSPART; + basetable->gpt_entries = PC98_NPARTS; basetable->gpt_first = cyl; basetable->gpt_last = msize - 1; @@ -569,7 +569,7 @@ g_part_pc98_write(struct g_part_table *b table = (struct g_part_pc98_table *)basetable; baseentry = LIST_FIRST(&basetable->gpt_entry); for (index = 1; index <= basetable->gpt_entries; index++) { - p = table->table + (index - 1) * DOSPARTSIZE; + p = table->table + (index - 1) * PC98_PARTSIZE; entry = (baseentry != NULL && index == baseentry->gpe_index) ? (struct g_part_pc98_entry *)baseentry : NULL; if (entry != NULL && !baseentry->gpe_deleted) { @@ -589,7 +589,7 @@ g_part_pc98_write(struct g_part_table *b bcopy(entry->ent.dp_name, p + 16, sizeof(entry->ent.dp_name)); } else - bzero(p, DOSPARTSIZE); + bzero(p, PC98_PARTSIZE); if (entry != NULL) baseentry = LIST_NEXT(baseentry, gpe_entry); Modified: head/sys/sys/diskpc98.h ============================================================================== --- head/sys/sys/diskpc98.h Tue Aug 6 21:44:54 2013 (r254014) +++ head/sys/sys/diskpc98.h Wed Aug 7 00:00:48 2013 (r254015) @@ -35,15 +35,12 @@ #include -#define DOSBBSECTOR 0 /* DOS boot block relative sector number */ -#undef DOSPARTOFF -#define DOSPARTOFF 0 -#undef DOSPARTSIZE -#define DOSPARTSIZE 32 -#undef NDOSPART -#define NDOSPART 16 -#define DOSMAGICOFFSET 510 -#define DOSMAGIC 0xAA55 +#define PC98_BBSECTOR 1 /* DOS boot block relative sector number */ +#define PC98_PARTOFF 0 +#define PC98_PARTSIZE 32 +#define PC98_NPARTS 16 +#define PC98_MAGICOFS 510 +#define PC98_MAGIC 0xAA55 #define PC98_MID_BOOTABLE 0x80 #define PC98_MID_MASK 0x7f @@ -55,8 +52,7 @@ #define DOSMID_386BSD (PC98_MID_386BSD | PC98_MID_BOOTABLE) #define DOSSID_386BSD (PC98_SID_386BSD | PC98_SID_ACTIVE) -#undef DOSPTYP_386BSD -#define DOSPTYP_386BSD (DOSSID_386BSD << 8 | DOSMID_386BSD) +#define PC98_PTYP_386BSD (DOSSID_386BSD << 8 | DOSMID_386BSD) struct pc98_partition { unsigned char dp_mid; @@ -75,7 +71,7 @@ struct pc98_partition { unsigned char dp_name[16]; }; #ifdef CTASSERT -CTASSERT(sizeof (struct pc98_partition) == DOSPARTSIZE); +CTASSERT(sizeof (struct pc98_partition) == PC98_PARTSIZE); #endif void pc98_partition_dec(void const *pp, struct pc98_partition *d); Modified: head/usr.sbin/boot98cfg/boot98cfg.c ============================================================================== --- head/usr.sbin/boot98cfg/boot98cfg.c Tue Aug 6 21:44:54 2013 (r254014) +++ head/usr.sbin/boot98cfg/boot98cfg.c Wed Aug 7 00:00:48 2013 (r254015) @@ -271,7 +271,7 @@ write_boot(const char *disk, u_char *boo warnx("%s: %s", disk, q); gctl_free(grq); - for (i = 0; i < NDOSPART; i++) { + for (i = 0; i < PC98_NPARTS; i++) { snprintf(buf, sizeof(buf), "%ss%d", disk, i + 1); fd = open(buf, O_RDONLY); if (fd < 0)