Initial Spring 2016 commit.
This commit is contained in:
13
userland/sbin/mksfs/Makefile
Normal file
13
userland/sbin/mksfs/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
# Makefile for mksfs
|
||||
|
||||
TOP=../../..
|
||||
.include "$(TOP)/mk/os161.config.mk"
|
||||
|
||||
PROG=mksfs
|
||||
SRCS=mksfs.c disk.c support.c
|
||||
BINDIR=/sbin
|
||||
HOSTBINDIR=/hostbin
|
||||
|
||||
|
||||
.include "$(TOP)/mk/os161.prog.mk"
|
||||
.include "$(TOP)/mk/os161.hostprog.mk"
|
200
userland/sbin/mksfs/disk.c
Normal file
200
userland/sbin/mksfs/disk.c
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "support.h"
|
||||
#include "disk.h"
|
||||
|
||||
#define HOSTSTRING "System/161 Disk Image"
|
||||
#define BLOCKSIZE 512
|
||||
|
||||
#ifndef EINTR
|
||||
#define EINTR 0
|
||||
#endif
|
||||
|
||||
static int fd=-1;
|
||||
static uint32_t nblocks;
|
||||
|
||||
/*
|
||||
* Open a disk. If we're built for the host OS, check that it's a
|
||||
* System/161 disk image, and then ignore the header block.
|
||||
*/
|
||||
void
|
||||
opendisk(const char *path)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
assert(fd<0);
|
||||
fd = open(path, O_RDWR);
|
||||
if (fd<0) {
|
||||
err(1, "%s", path);
|
||||
}
|
||||
if (fstat(fd, &statbuf)) {
|
||||
err(1, "%s: fstat", path);
|
||||
}
|
||||
|
||||
nblocks = statbuf.st_size / BLOCKSIZE;
|
||||
|
||||
#ifdef HOST
|
||||
nblocks--;
|
||||
|
||||
{
|
||||
char buf[64];
|
||||
int len;
|
||||
|
||||
do {
|
||||
len = read(fd, buf, sizeof(buf)-1);
|
||||
if (len < 0 && (errno==EINTR || errno==EAGAIN)) {
|
||||
continue;
|
||||
}
|
||||
} while (0);
|
||||
|
||||
buf[len] = 0;
|
||||
buf[strlen(HOSTSTRING)] = 0;
|
||||
|
||||
if (strcmp(buf, HOSTSTRING)) {
|
||||
errx(1, "%s: Not a System/161 disk image", path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the block size. (This is fixed, but still...)
|
||||
*/
|
||||
uint32_t
|
||||
diskblocksize(void)
|
||||
{
|
||||
assert(fd>=0);
|
||||
return BLOCKSIZE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the device/image size in blocks.
|
||||
*/
|
||||
uint32_t
|
||||
diskblocks(void)
|
||||
{
|
||||
assert(fd>=0);
|
||||
return nblocks;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a block.
|
||||
*/
|
||||
void
|
||||
diskwrite(const void *data, uint32_t block)
|
||||
{
|
||||
const char *cdata = data;
|
||||
uint32_t tot=0;
|
||||
int len;
|
||||
|
||||
assert(fd>=0);
|
||||
|
||||
#ifdef HOST
|
||||
// skip over disk file header
|
||||
block++;
|
||||
#endif
|
||||
|
||||
if (lseek(fd, block*BLOCKSIZE, SEEK_SET)<0) {
|
||||
err(1, "lseek");
|
||||
}
|
||||
|
||||
while (tot < BLOCKSIZE) {
|
||||
len = write(fd, cdata + tot, BLOCKSIZE - tot);
|
||||
if (len < 0) {
|
||||
if (errno==EINTR || errno==EAGAIN) {
|
||||
continue;
|
||||
}
|
||||
err(1, "write");
|
||||
}
|
||||
if (len==0) {
|
||||
err(1, "write returned 0?");
|
||||
}
|
||||
tot += len;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a block.
|
||||
*/
|
||||
void
|
||||
diskread(void *data, uint32_t block)
|
||||
{
|
||||
char *cdata = data;
|
||||
uint32_t tot=0;
|
||||
int len;
|
||||
|
||||
assert(fd>=0);
|
||||
|
||||
#ifdef HOST
|
||||
// skip over disk file header
|
||||
block++;
|
||||
#endif
|
||||
|
||||
if (lseek(fd, block*BLOCKSIZE, SEEK_SET)<0) {
|
||||
err(1, "lseek");
|
||||
}
|
||||
|
||||
while (tot < BLOCKSIZE) {
|
||||
len = read(fd, cdata + tot, BLOCKSIZE - tot);
|
||||
if (len < 0) {
|
||||
if (errno==EINTR || errno==EAGAIN) {
|
||||
continue;
|
||||
}
|
||||
err(1, "read");
|
||||
}
|
||||
if (len==0) {
|
||||
err(1, "unexpected EOF in mid-sector");
|
||||
}
|
||||
tot += len;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Close the disk.
|
||||
*/
|
||||
void
|
||||
closedisk(void)
|
||||
{
|
||||
assert(fd>=0);
|
||||
if (close(fd)) {
|
||||
err(1, "close");
|
||||
}
|
||||
fd = -1;
|
||||
}
|
38
userland/sbin/mksfs/disk.h
Normal file
38
userland/sbin/mksfs/disk.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
void opendisk(const char *path);
|
||||
|
||||
uint32_t diskblocksize(void);
|
||||
uint32_t diskblocks(void);
|
||||
|
||||
void diskwrite(const void *data, uint32_t block);
|
||||
void diskread(void *data, uint32_t block);
|
||||
|
||||
void closedisk(void);
|
240
userland/sbin/mksfs/mksfs.c
Normal file
240
userland/sbin/mksfs/mksfs.c
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009, 2014
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "support.h"
|
||||
#include "kern/sfs.h"
|
||||
|
||||
|
||||
#ifdef HOST
|
||||
|
||||
#include <netinet/in.h> // for arpa/inet.h
|
||||
#include <arpa/inet.h> // for ntohl
|
||||
#include "hostcompat.h"
|
||||
#define SWAP64(x) ntohll(x)
|
||||
#define SWAP32(x) ntohl(x)
|
||||
#define SWAP16(x) ntohs(x)
|
||||
|
||||
#else
|
||||
|
||||
#define SWAP64(x) (x)
|
||||
#define SWAP32(x) (x)
|
||||
#define SWAP16(x) (x)
|
||||
|
||||
#endif
|
||||
|
||||
#include "disk.h"
|
||||
|
||||
/* Maximum size of freemap we support */
|
||||
#define MAXFREEMAPBLOCKS 32
|
||||
|
||||
/* Free block bitmap */
|
||||
static char freemapbuf[MAXFREEMAPBLOCKS * SFS_BLOCKSIZE];
|
||||
|
||||
/*
|
||||
* Assert that the on-disk data structures are correctly sized.
|
||||
*/
|
||||
static
|
||||
void
|
||||
check(void)
|
||||
{
|
||||
assert(sizeof(struct sfs_superblock)==SFS_BLOCKSIZE);
|
||||
assert(sizeof(struct sfs_dinode)==SFS_BLOCKSIZE);
|
||||
assert(SFS_BLOCKSIZE % sizeof(struct sfs_direntry) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Mark a block allocated.
|
||||
*/
|
||||
static
|
||||
void
|
||||
allocblock(uint32_t block)
|
||||
{
|
||||
uint32_t mapbyte = block/CHAR_BIT;
|
||||
unsigned char mask = (1<<(block % CHAR_BIT));
|
||||
|
||||
assert((freemapbuf[mapbyte] & mask) == 0);
|
||||
freemapbuf[mapbyte] |= mask;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the free block bitmap.
|
||||
*/
|
||||
static
|
||||
void
|
||||
initfreemap(uint32_t fsblocks)
|
||||
{
|
||||
uint32_t freemapbits = SFS_FREEMAPBITS(fsblocks);
|
||||
uint32_t freemapblocks = SFS_FREEMAPBLOCKS(fsblocks);
|
||||
uint32_t i;
|
||||
|
||||
if (freemapblocks > MAXFREEMAPBLOCKS) {
|
||||
errx(1, "Filesystem too large -- "
|
||||
"increase MAXFREEMAPBLOCKS and recompile");
|
||||
}
|
||||
|
||||
/* mark the superblock and root inode in use */
|
||||
allocblock(SFS_SUPER_BLOCK);
|
||||
allocblock(SFS_ROOTDIR_INO);
|
||||
|
||||
/* the freemap blocks must be in use */
|
||||
for (i=0; i<freemapblocks; i++) {
|
||||
allocblock(SFS_FREEMAP_START + i);
|
||||
}
|
||||
|
||||
/* all blocks in the freemap but past the volume end are "in use" */
|
||||
for (i=fsblocks; i<freemapbits; i++) {
|
||||
allocblock(i);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize and write out the superblock.
|
||||
*/
|
||||
static
|
||||
void
|
||||
writesuper(const char *volname, uint32_t nblocks)
|
||||
{
|
||||
struct sfs_superblock sb;
|
||||
|
||||
/* The cast is required on some outdated host systems. */
|
||||
bzero((void *)&sb, sizeof(sb));
|
||||
|
||||
if (strlen(volname) >= SFS_VOLNAME_SIZE) {
|
||||
errx(1, "Volume name %s too long", volname);
|
||||
}
|
||||
|
||||
/* Initialize the superblock structure */
|
||||
sb.sb_magic = SWAP32(SFS_MAGIC);
|
||||
sb.sb_nblocks = SWAP32(nblocks);
|
||||
strcpy(sb.sb_volname, volname);
|
||||
|
||||
/* and write it out. */
|
||||
diskwrite(&sb, SFS_SUPER_BLOCK);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out the free block bitmap.
|
||||
*/
|
||||
static
|
||||
void
|
||||
writefreemap(uint32_t fsblocks)
|
||||
{
|
||||
uint32_t freemapblocks;
|
||||
char *ptr;
|
||||
uint32_t i;
|
||||
|
||||
/* Write out each of the blocks in the free block bitmap. */
|
||||
freemapblocks = SFS_FREEMAPBLOCKS(fsblocks);
|
||||
for (i=0; i<freemapblocks; i++) {
|
||||
ptr = freemapbuf + i*SFS_BLOCKSIZE;
|
||||
diskwrite(ptr, SFS_FREEMAP_START+i);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out the root directory inode.
|
||||
*/
|
||||
static
|
||||
void
|
||||
writerootdir(void)
|
||||
{
|
||||
struct sfs_dinode sfi;
|
||||
|
||||
/* Initialize the dinode */
|
||||
bzero((void *)&sfi, sizeof(sfi));
|
||||
sfi.sfi_size = SWAP32(0);
|
||||
sfi.sfi_type = SWAP16(SFS_TYPE_DIR);
|
||||
sfi.sfi_linkcount = SWAP16(1);
|
||||
|
||||
/* Write it out */
|
||||
diskwrite(&sfi, SFS_ROOTDIR_INO);
|
||||
}
|
||||
|
||||
/*
|
||||
* Main.
|
||||
*/
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
uint32_t size, blocksize;
|
||||
char *volname, *s;
|
||||
|
||||
#ifdef HOST
|
||||
hostcompat_init(argc, argv);
|
||||
#endif
|
||||
|
||||
if (argc!=3) {
|
||||
errx(1, "Usage: mksfs device/diskfile volume-name");
|
||||
}
|
||||
|
||||
check();
|
||||
|
||||
volname = argv[2];
|
||||
|
||||
/* Remove one trailing colon from volname, if present */
|
||||
s = strchr(volname, ':');
|
||||
if (s != NULL) {
|
||||
if (strlen(s)!=1) {
|
||||
errx(1, "Illegal volume name %s", volname);
|
||||
}
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
/* Don't allow slashes */
|
||||
s = strchr(volname, '/');
|
||||
if (s != NULL) {
|
||||
errx(1, "Illegal volume name %s", volname);
|
||||
}
|
||||
|
||||
opendisk(argv[1]);
|
||||
blocksize = diskblocksize();
|
||||
|
||||
if (blocksize!=SFS_BLOCKSIZE) {
|
||||
errx(1, "Device has wrong blocksize %u (should be %u)\n",
|
||||
blocksize, SFS_BLOCKSIZE);
|
||||
}
|
||||
size = diskblocks();
|
||||
|
||||
/* Write out the on-disk structures */
|
||||
initfreemap(size);
|
||||
writesuper(volname, size);
|
||||
writefreemap(size);
|
||||
writerootdir();
|
||||
|
||||
closedisk();
|
||||
|
||||
return 0;
|
||||
}
|
34
userland/sbin/mksfs/support.c
Normal file
34
userland/sbin/mksfs/support.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file doesn't actually do anything any more, but I'm going to
|
||||
* leave it here for now (and leave the mechanisms in place for building
|
||||
* it) in case it's wanted again later on.
|
||||
*/
|
64
userland/sbin/mksfs/support.h
Normal file
64
userland/sbin/mksfs/support.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
|
||||
* The President and Fellows of Harvard College.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __osf__
|
||||
/* Digital Unix (aka Compaq Tru64) */
|
||||
#define HAS_NO_SIZED_TYPES
|
||||
#endif
|
||||
|
||||
#if defined(__sun__) && defined(__svr4__)
|
||||
/* Solaris */
|
||||
#define HAS_NO_SIZED_TYPES
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some systems don't have uint32_t, uint16_t, or uint8_t.
|
||||
* (Sometime this should be changed so it gets probed by the configure script.)
|
||||
*/
|
||||
|
||||
#ifdef HAS_NO_SIZED_TYPES
|
||||
|
||||
#if defined(__alpha__) || defined(__alpha)
|
||||
/* Alpha processor: lp64 */
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
#elif defined(__sparc__)
|
||||
/* Sparc processor: 32-bit or lp64 */
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
#else
|
||||
#error "HAS_NO_SIZED_TYPES defined and I don't know what the sizes should be"
|
||||
#endif
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user