From 0b8e20c89e994e29abe3013cddf442787ed11c9a Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Fri, 6 Nov 2009 08:46:22 +0000 Subject: [PATCH] Changes to the include files in order to make cross-compilation possible. - The primary reason is that mkfs and installboot need to run natively during the cross compilation (host and target versions are compiled). There is a collision of include files though. E.g. a.out.h is very minix-specific. Therefore some files we moved and replaced by stubs that include the original file if compiling on or for Minix : include/a.out.h -> include/minix/a.out.h include/sys/dir.h -> include/minix/dir.h include/dirent.h -> include/minix/dirent.h include/sys/types.h -> include/minix/types.h - This does not break any native compilation on Minix. Other headers that were including the original files are changed according to include directly the new, minix specific location not to pick up the host system includes while cross-compiling. - role of this patch is to make rebasing of the build branch simpler until the new build system is merged --- include/a.out.h | 125 ++------------------------- include/alloca.h | 2 +- include/dirent.h | 103 ++--------------------- include/fcntl.h | 2 +- include/grp.h | 2 +- include/lib.h | 2 +- include/limits.h | 2 +- include/minix/a.out.h | 118 ++++++++++++++++++++++++++ include/minix/devio.h | 2 +- include/minix/dir.h | 19 +++++ include/minix/dirent.h | 98 ++++++++++++++++++++++ include/minix/ds.h | 2 +- include/minix/ioctl.h | 2 +- include/minix/partition.h | 2 +- include/minix/portio.h | 2 +- include/minix/profile.h | 2 +- include/minix/safecopies.h | 2 +- include/minix/syslib.h | 2 +- include/minix/tty.h | 2 +- include/minix/type.h | 2 +- include/minix/types.h | 168 +++++++++++++++++++++++++++++++++++++ include/minix/u64.h | 2 +- include/minix/vm.h | 2 +- include/pwd.h | 2 +- include/regex.h | 2 +- include/signal.h | 2 +- include/stdint.h | 2 +- include/stdio.h | 2 +- include/sys/dir.h | 26 ++---- include/sys/mman.h | 2 +- include/sys/select.h | 2 +- include/sys/stat.h | 2 +- include/sys/statfs.h | 2 +- include/sys/svrctl.h | 2 +- include/sys/types.h | 159 ++--------------------------------- include/sys/wait.h | 2 +- include/timers.h | 2 +- include/tools.h | 2 + include/unistd.h | 2 +- include/utime.h | 2 +- 40 files changed, 470 insertions(+), 410 deletions(-) create mode 100644 include/minix/a.out.h create mode 100644 include/minix/dir.h create mode 100644 include/minix/dirent.h create mode 100644 include/minix/types.h diff --git a/include/a.out.h b/include/a.out.h index 0499a1f10..b9b8c82ab 100755 --- a/include/a.out.h +++ b/include/a.out.h @@ -1,118 +1,11 @@ -/* The header file describes the format of executable files. */ +/* + * this files resolves conflicts between the file of the host system and + * the minix specific one. This file is included directly only on Minix + * and it is an error to do so on any other system + */ -#ifndef _AOUT_H -#define _AOUT_H - -struct exec { /* a.out header */ - unsigned char a_magic[2]; /* magic number */ - unsigned char a_flags; /* flags, see below */ - unsigned char a_cpu; /* cpu id */ - unsigned char a_hdrlen; /* length of header */ - unsigned char a_unused; /* reserved for future use */ - unsigned short a_version; /* version stamp (not used at present) */ - long a_text; /* size of text segement in bytes */ - long a_data; /* size of data segment in bytes */ - long a_bss; /* size of bss segment in bytes */ - long a_entry; /* entry point */ - long a_total; /* total memory allocated */ - long a_syms; /* size of symbol table */ - - /* SHORT FORM ENDS HERE */ - long a_trsize; /* text relocation size */ - long a_drsize; /* data relocation size */ - long a_tbase; /* text relocation base */ - long a_dbase; /* data relocation base */ -}; - -#define A_MAGIC0 (unsigned char) 0x01 -#define A_MAGIC1 (unsigned char) 0x03 -#define BADMAG(X) ((X).a_magic[0] != A_MAGIC0 ||(X).a_magic[1] != A_MAGIC1) - -/* CPU Id of TARGET machine (byte order coded in low order two bits) */ -#define A_NONE 0x00 /* unknown */ -#define A_I8086 0x04 /* intel i8086/8088 */ -#define A_M68K 0x0B /* motorola m68000 */ -#define A_NS16K 0x0C /* national semiconductor 16032 */ -#define A_I80386 0x10 /* intel i80386 */ -#define A_SPARC 0x17 /* Sun SPARC */ - -#define A_BLR(cputype) ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */ -#define A_WLR(cputype) ((cputype&0x02)!=0) /* TRUE if words left-to-right */ - -/* Flags. */ -#define A_UZP 0x01 /* unmapped zero page (pages) */ -#define A_PAL 0x02 /* page aligned executable */ -#define A_NSYM 0x04 /* new style symbol table */ -#define A_IMG 0x08 /* image instead of executable (e.g. root FS) */ -#define A_EXEC 0x10 /* executable */ -#define A_SEP 0x20 /* separate I/D */ -#define A_PURE 0x40 /* pure text */ /* not used */ -#define A_TOVLY 0x80 /* text overlay */ /* not used */ - -/* Offsets of various things. */ -#define A_MINHDR 32 -#define A_TEXTPOS(X) ((long)(X).a_hdrlen) -#define A_DATAPOS(X) (A_TEXTPOS(X) + (X).a_text) -#define A_HASRELS(X) ((X).a_hdrlen > (unsigned char) A_MINHDR) -#define A_HASEXT(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 8)) -#define A_HASLNS(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16)) -#define A_HASTOFF(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24)) -#define A_TRELPOS(X) (A_DATAPOS(X) + (X).a_data) -#define A_DRELPOS(X) (A_TRELPOS(X) + (X).a_trsize) -#define A_SYMPOS(X) (A_TRELPOS(X) + (A_HASRELS(X) ? \ - ((X).a_trsize + (X).a_drsize) : 0)) - -struct reloc { - long r_vaddr; /* virtual address of reference */ - unsigned short r_symndx; /* internal segnum or extern symbol num */ - unsigned short r_type; /* relocation type */ -}; - -/* r_tyep values: */ -#define R_ABBS 0 -#define R_RELLBYTE 2 -#define R_PCRBYTE 3 -#define R_RELWORD 4 -#define R_PCRWORD 5 -#define R_RELLONG 6 -#define R_PCRLONG 7 -#define R_REL3BYTE 8 -#define R_KBRANCHE 9 - -/* r_symndx for internal segments */ -#define S_ABS ((unsigned short)-1) -#define S_TEXT ((unsigned short)-2) -#define S_DATA ((unsigned short)-3) -#define S_BSS ((unsigned short)-4) - -struct nlist { /* symbol table entry */ - char n_name[8]; /* symbol name */ - long n_value; /* value */ - unsigned char n_sclass; /* storage class */ - unsigned char n_numaux; /* number of auxiliary entries (not used) */ - unsigned short n_type; /* language base and derived type (not used) */ -}; - -/* Low bits of storage class (section). */ -#define N_SECT 07 /* section mask */ -#define N_UNDF 00 /* undefined */ -#define N_ABS 01 /* absolute */ -#define N_TEXT 02 /* text */ -#define N_DATA 03 /* data */ -#define N_BSS 04 /* bss */ -#define N_COMM 05 /* (common) */ - -/* High bits of storage class. */ -#define N_CLASS 0370 /* storage class mask */ -#define C_NULL -#define C_EXT 0020 /* external symbol */ -#define C_STAT 0030 /* static */ - -/* Function prototypes. */ -#ifndef _ANSI_H -#include +#if !defined(_MINIX) && !defined(__minix) && !defined(__ACK__) +#error "Including Minix specific file in program targeted for other system" +#else +#include #endif - -_PROTOTYPE( int nlist, (char *_file, struct nlist *_nl) ); - -#endif /* _AOUT_H */ diff --git a/include/alloca.h b/include/alloca.h index f90b6e6c8..9583b85a9 100755 --- a/include/alloca.h +++ b/include/alloca.h @@ -5,7 +5,7 @@ #define _ALLOCA_H #ifndef _TYPES_H -#include +#include #endif #if __GNUC__ diff --git a/include/dirent.h b/include/dirent.h index 81c031812..6bec9d7fa 100755 --- a/include/dirent.h +++ b/include/dirent.h @@ -1,98 +1,11 @@ -/* dirent.h - Declarations for directory reading routines. - * Author: Kees J. Bot - * 24 Apr 1989 - * - * Note: The V7 format directory entries used under Minix must be transformed - * into a struct dirent with a d_name of at least 15 characters. Given that - * we have to transform V7 entries anyhow it is little trouble to let the - * routines understand the so-called "flex" directory format too. +/* + * this files resolves conflicts between the file of the host system and + * the minix specific one. This file is included directly only on Minix + * and it is an error to do so on any other system */ -#ifndef _DIRENT_H -#define _DIRENT_H - -#ifndef _TYPES_H -#include +#if !defined(_MINIX) && !defined(__minix) && !defined(__ACK__) +#error "Including Minix specific file in program targeted for other system" +#else +#include #endif - -#include - -/* _fl_direct is a flexible directory entry. Actually it's a union of 8 - * characters and the 3 fields defined below. - */ - -/* Flexible directory entry: */ -struct _fl_direct { /* First slot in an entry */ - ino_t d_ino; - unsigned char d_extent; - char d_name[3]; /* two characters for the shortest name */ -}; - - /* Name of length len needs _EXTENT(len) extra slots. */ -#define _EXTENT(len) (((len) + 5) >> 3) - -/* Version 7 directory entry: */ -struct _v7_direct { - ino_t d_ino; - char d_name[DIRSIZ]; -}; - -/* The block size must be at least 1024 bytes, because otherwise - * the superblock (at 1024 bytes) overlaps with other filesystem data. - */ -#define _MIN_BLOCK_SIZE 1024 - -/* The below is allocated in some parts of the system as the largest - * a filesystem block can be. For instance, the boot monitor allocates - * 3 of these blocks and has to fit within 64kB, so this can't be - * increased without taking that into account. - */ -#define _MAX_BLOCK_SIZE 4096 - -/* This is the block size for the fixed versions of the filesystem (V1/V2) */ -#define _STATIC_BLOCK_SIZE 1024 - -#define _STATIC_FLEX_PER_BLOCK (_STATIC_BLOCK_SIZE/sizeof(struct _fl_direct)) -#define _FLEX_PER_V7 (_EXTENT(DIRSIZ) + 1) -#define _FLEX_PER_BLOCK (_STATIC_BLOCK_SIZE/sizeof(struct _fl_direct)) - -/* Definitions for the directory(3) routines: */ -typedef struct { - char _fd; /* Filedescriptor of open directory */ - unsigned _count; /* This many bytes in _buf */ - unsigned _pos; /* Position in _buf */ - char _buf[_MAX_BLOCK_SIZE]; /* The size does not really - * matter as long as the - * buffer is big enough - * to contain at least one - * entry. - */ -} DIR; - -#define _DIRENT_NAME_LEN 61 - -struct dirent { /* Largest entry (8 slots) */ - ino_t d_ino; /* I-node number */ - off_t d_off; /* Offset in directory */ - unsigned short d_reclen; /* Length of this record */ - char d_name[1]; /* Null terminated name */ -}; - -/* Function Prototypes. */ -_PROTOTYPE( int closedir, (DIR *_dirp) ); -_PROTOTYPE( DIR *opendir, (const char *_dirname) ); -_PROTOTYPE( struct dirent *readdir, (DIR *_dirp) ); -_PROTOTYPE( void rewinddir, (DIR *_dirp) ); - -#ifdef _MINIX -_PROTOTYPE( int seekdir, (DIR *_dirp, off_t _loc) ); -_PROTOTYPE( off_t telldir, (DIR *_dirp) ); - -#define dirfd(dirp) ((dirp)->_fd) - -_PROTOTYPE( int getdents, (int _fildes, struct dirent *_buf, - size_t _nbyte) ); - -#endif - -#endif /* _DIRENT_H */ diff --git a/include/fcntl.h b/include/fcntl.h index e0353692c..d252a9ede 100755 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -11,7 +11,7 @@ #define _FCNTL_H #ifndef _TYPES_H -#include +#include #endif /* These values are used for cmd in fcntl(). POSIX Table 6-1. */ diff --git a/include/grp.h b/include/grp.h index 88a93d7c4..e0f85ae82 100755 --- a/include/grp.h +++ b/include/grp.h @@ -4,7 +4,7 @@ #define _GRP_H #ifndef _TYPES_H -#include +#include #endif struct group { diff --git a/include/lib.h b/include/lib.h index 97197b3a2..b20aadf41 100755 --- a/include/lib.h +++ b/include/lib.h @@ -11,7 +11,7 @@ /* The following are so basic, all the lib files get them automatically. */ #include /* must be first */ -#include +#include #include #include #include diff --git a/include/limits.h b/include/limits.h index 428111e48..5569a14d0 100755 --- a/include/limits.h +++ b/include/limits.h @@ -38,7 +38,7 @@ #define LONG_MAX 2147483647L /* maximum value of a long */ #define ULONG_MAX 0xFFFFFFFFL /* maximum value of an unsigned long */ -#include +#include /* Minimum sizes required by the POSIX P1003.1 standard (Table 2-3). */ #ifdef _POSIX_SOURCE /* these are only visible for POSIX */ diff --git a/include/minix/a.out.h b/include/minix/a.out.h new file mode 100644 index 000000000..0499a1f10 --- /dev/null +++ b/include/minix/a.out.h @@ -0,0 +1,118 @@ +/* The header file describes the format of executable files. */ + +#ifndef _AOUT_H +#define _AOUT_H + +struct exec { /* a.out header */ + unsigned char a_magic[2]; /* magic number */ + unsigned char a_flags; /* flags, see below */ + unsigned char a_cpu; /* cpu id */ + unsigned char a_hdrlen; /* length of header */ + unsigned char a_unused; /* reserved for future use */ + unsigned short a_version; /* version stamp (not used at present) */ + long a_text; /* size of text segement in bytes */ + long a_data; /* size of data segment in bytes */ + long a_bss; /* size of bss segment in bytes */ + long a_entry; /* entry point */ + long a_total; /* total memory allocated */ + long a_syms; /* size of symbol table */ + + /* SHORT FORM ENDS HERE */ + long a_trsize; /* text relocation size */ + long a_drsize; /* data relocation size */ + long a_tbase; /* text relocation base */ + long a_dbase; /* data relocation base */ +}; + +#define A_MAGIC0 (unsigned char) 0x01 +#define A_MAGIC1 (unsigned char) 0x03 +#define BADMAG(X) ((X).a_magic[0] != A_MAGIC0 ||(X).a_magic[1] != A_MAGIC1) + +/* CPU Id of TARGET machine (byte order coded in low order two bits) */ +#define A_NONE 0x00 /* unknown */ +#define A_I8086 0x04 /* intel i8086/8088 */ +#define A_M68K 0x0B /* motorola m68000 */ +#define A_NS16K 0x0C /* national semiconductor 16032 */ +#define A_I80386 0x10 /* intel i80386 */ +#define A_SPARC 0x17 /* Sun SPARC */ + +#define A_BLR(cputype) ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */ +#define A_WLR(cputype) ((cputype&0x02)!=0) /* TRUE if words left-to-right */ + +/* Flags. */ +#define A_UZP 0x01 /* unmapped zero page (pages) */ +#define A_PAL 0x02 /* page aligned executable */ +#define A_NSYM 0x04 /* new style symbol table */ +#define A_IMG 0x08 /* image instead of executable (e.g. root FS) */ +#define A_EXEC 0x10 /* executable */ +#define A_SEP 0x20 /* separate I/D */ +#define A_PURE 0x40 /* pure text */ /* not used */ +#define A_TOVLY 0x80 /* text overlay */ /* not used */ + +/* Offsets of various things. */ +#define A_MINHDR 32 +#define A_TEXTPOS(X) ((long)(X).a_hdrlen) +#define A_DATAPOS(X) (A_TEXTPOS(X) + (X).a_text) +#define A_HASRELS(X) ((X).a_hdrlen > (unsigned char) A_MINHDR) +#define A_HASEXT(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 8)) +#define A_HASLNS(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16)) +#define A_HASTOFF(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24)) +#define A_TRELPOS(X) (A_DATAPOS(X) + (X).a_data) +#define A_DRELPOS(X) (A_TRELPOS(X) + (X).a_trsize) +#define A_SYMPOS(X) (A_TRELPOS(X) + (A_HASRELS(X) ? \ + ((X).a_trsize + (X).a_drsize) : 0)) + +struct reloc { + long r_vaddr; /* virtual address of reference */ + unsigned short r_symndx; /* internal segnum or extern symbol num */ + unsigned short r_type; /* relocation type */ +}; + +/* r_tyep values: */ +#define R_ABBS 0 +#define R_RELLBYTE 2 +#define R_PCRBYTE 3 +#define R_RELWORD 4 +#define R_PCRWORD 5 +#define R_RELLONG 6 +#define R_PCRLONG 7 +#define R_REL3BYTE 8 +#define R_KBRANCHE 9 + +/* r_symndx for internal segments */ +#define S_ABS ((unsigned short)-1) +#define S_TEXT ((unsigned short)-2) +#define S_DATA ((unsigned short)-3) +#define S_BSS ((unsigned short)-4) + +struct nlist { /* symbol table entry */ + char n_name[8]; /* symbol name */ + long n_value; /* value */ + unsigned char n_sclass; /* storage class */ + unsigned char n_numaux; /* number of auxiliary entries (not used) */ + unsigned short n_type; /* language base and derived type (not used) */ +}; + +/* Low bits of storage class (section). */ +#define N_SECT 07 /* section mask */ +#define N_UNDF 00 /* undefined */ +#define N_ABS 01 /* absolute */ +#define N_TEXT 02 /* text */ +#define N_DATA 03 /* data */ +#define N_BSS 04 /* bss */ +#define N_COMM 05 /* (common) */ + +/* High bits of storage class. */ +#define N_CLASS 0370 /* storage class mask */ +#define C_NULL +#define C_EXT 0020 /* external symbol */ +#define C_STAT 0030 /* static */ + +/* Function prototypes. */ +#ifndef _ANSI_H +#include +#endif + +_PROTOTYPE( int nlist, (char *_file, struct nlist *_nl) ); + +#endif /* _AOUT_H */ diff --git a/include/minix/devio.h b/include/minix/devio.h index 8ce9b8aa9..fbcd6f962 100644 --- a/include/minix/devio.h +++ b/include/minix/devio.h @@ -10,7 +10,7 @@ #define _DEVIO_H #include /* needed to include */ -#include /* u8_t, u16_t, u32_t needed */ +#include /* u8_t, u16_t, u32_t needed */ typedef u16_t port_t; typedef U16_t Port_t; diff --git a/include/minix/dir.h b/include/minix/dir.h new file mode 100644 index 000000000..9c0a7dd5a --- /dev/null +++ b/include/minix/dir.h @@ -0,0 +1,19 @@ +/* The header gives the layout of a directory. */ + +#ifndef _DIR_H +#define _DIR_H + +#include + +#define DIRBLKSIZ 512 /* size of directory block */ + +#ifndef DIRSIZ +#define DIRSIZ 60 +#endif + +struct direct { + ino_t d_ino; + char d_name[DIRSIZ]; +}; + +#endif /* _DIR_H */ diff --git a/include/minix/dirent.h b/include/minix/dirent.h new file mode 100644 index 000000000..eb248418c --- /dev/null +++ b/include/minix/dirent.h @@ -0,0 +1,98 @@ +/* dirent.h - Declarations for directory reading routines. + * Author: Kees J. Bot + * 24 Apr 1989 + * + * Note: The V7 format directory entries used under Minix must be transformed + * into a struct dirent with a d_name of at least 15 characters. Given that + * we have to transform V7 entries anyhow it is little trouble to let the + * routines understand the so-called "flex" directory format too. + */ + +#ifndef _DIRENT_H +#define _DIRENT_H + +#ifndef _TYPES_H +#include +#endif + +#include + +/* _fl_direct is a flexible directory entry. Actually it's a union of 8 + * characters and the 3 fields defined below. + */ + +/* Flexible directory entry: */ +struct _fl_direct { /* First slot in an entry */ + ino_t d_ino; + unsigned char d_extent; + char d_name[3]; /* two characters for the shortest name */ +}; + + /* Name of length len needs _EXTENT(len) extra slots. */ +#define _EXTENT(len) (((len) + 5) >> 3) + +/* Version 7 directory entry: */ +struct _v7_direct { + ino_t d_ino; + char d_name[DIRSIZ]; +}; + +/* The block size must be at least 1024 bytes, because otherwise + * the superblock (at 1024 bytes) overlaps with other filesystem data. + */ +#define _MIN_BLOCK_SIZE 1024 + +/* The below is allocated in some parts of the system as the largest + * a filesystem block can be. For instance, the boot monitor allocates + * 3 of these blocks and has to fit within 64kB, so this can't be + * increased without taking that into account. + */ +#define _MAX_BLOCK_SIZE 4096 + +/* This is the block size for the fixed versions of the filesystem (V1/V2) */ +#define _STATIC_BLOCK_SIZE 1024 + +#define _STATIC_FLEX_PER_BLOCK (_STATIC_BLOCK_SIZE/sizeof(struct _fl_direct)) +#define _FLEX_PER_V7 (_EXTENT(DIRSIZ) + 1) +#define _FLEX_PER_BLOCK (_STATIC_BLOCK_SIZE/sizeof(struct _fl_direct)) + +/* Definitions for the directory(3) routines: */ +typedef struct { + char _fd; /* Filedescriptor of open directory */ + unsigned _count; /* This many bytes in _buf */ + unsigned _pos; /* Position in _buf */ + char _buf[_MAX_BLOCK_SIZE]; /* The size does not really + * matter as long as the + * buffer is big enough + * to contain at least one + * entry. + */ +} DIR; + +#define _DIRENT_NAME_LEN 61 + +struct dirent { /* Largest entry (8 slots) */ + ino_t d_ino; /* I-node number */ + off_t d_off; /* Offset in directory */ + unsigned short d_reclen; /* Length of this record */ + char d_name[1]; /* Null terminated name */ +}; + +/* Function Prototypes. */ +_PROTOTYPE( int closedir, (DIR *_dirp) ); +_PROTOTYPE( DIR *opendir, (const char *_dirname) ); +_PROTOTYPE( struct dirent *readdir, (DIR *_dirp) ); +_PROTOTYPE( void rewinddir, (DIR *_dirp) ); + +#ifdef _MINIX +_PROTOTYPE( int seekdir, (DIR *_dirp, off_t _loc) ); +_PROTOTYPE( off_t telldir, (DIR *_dirp) ); + +#define dirfd(dirp) ((dirp)->_fd) + +_PROTOTYPE( int getdents, (int _fildes, struct dirent *_buf, + size_t _nbyte) ); + +#endif + +#endif /* _DIRENT_H */ diff --git a/include/minix/ds.h b/include/minix/ds.h index f77c5aaa1..ac368a4d7 100755 --- a/include/minix/ds.h +++ b/include/minix/ds.h @@ -3,7 +3,7 @@ #ifndef _MINIX_DS_H #define _MINIX_DS_H -#include +#include /* DS Flag values. */ #define DS_IN_USE 0x0001 /* Internal use only. */ diff --git a/include/minix/ioctl.h b/include/minix/ioctl.h index 6f1bf0193..f6f79fe9b 100755 --- a/include/minix/ioctl.h +++ b/include/minix/ioctl.h @@ -8,7 +8,7 @@ #define _M_IOCTL_H #ifndef _TYPES_H -#include +#include #endif #if _EM_WSIZE >= 4 diff --git a/include/minix/partition.h b/include/minix/partition.h index 7932c97e5..0cbd9930c 100755 --- a/include/minix/partition.h +++ b/include/minix/partition.h @@ -7,7 +7,7 @@ #define _MINIX__PARTITION_H #ifndef _TYPES_H -#include +#include #endif struct partition { diff --git a/include/minix/portio.h b/include/minix/portio.h index 9e7b412cb..dc0625bab 100755 --- a/include/minix/portio.h +++ b/include/minix/portio.h @@ -8,7 +8,7 @@ Created: Jan 15, 1992 by Philip Homburg #define _PORTIO_H_ #ifndef _TYPES_H -#include +#include #endif unsigned inb(U16_t _port); diff --git a/include/minix/profile.h b/include/minix/profile.h index b242dae0c..afeeec298 100644 --- a/include/minix/profile.h +++ b/include/minix/profile.h @@ -31,7 +31,7 @@ struct { #endif /* SPROFILE */ -#include +#include # define PROF_GET 2 /* get call profiling tables */ # define PROF_RESET 3 /* reset call profiling tables */ diff --git a/include/minix/safecopies.h b/include/minix/safecopies.h index 594addfcf..697d77889 100644 --- a/include/minix/safecopies.h +++ b/include/minix/safecopies.h @@ -3,7 +3,7 @@ #define _MINIX_SAFECOPIES_H 1 #include -#include +#include #include typedef int32_t cp_grant_id_t; diff --git a/include/minix/syslib.h b/include/minix/syslib.h index cf03926fa..5615c6372 100755 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -4,7 +4,7 @@ #define _SYSLIB_H #ifndef _TYPES_H -#include +#include #endif #ifndef _IPC_H diff --git a/include/minix/tty.h b/include/minix/tty.h index fcf8d2f97..65712d540 100644 --- a/include/minix/tty.h +++ b/include/minix/tty.h @@ -2,7 +2,7 @@ #ifndef _MINIX_TTY_H #define _MINIX_TTY_H -#include +#include #define TTYMAGIC 0xb105 diff --git a/include/minix/type.h b/include/minix/type.h index a794a2243..4dd0edfe9 100755 --- a/include/minix/type.h +++ b/include/minix/type.h @@ -6,7 +6,7 @@ #endif #ifndef _TYPES_H -#include +#include #endif /* Type definitions. */ diff --git a/include/minix/types.h b/include/minix/types.h new file mode 100644 index 000000000..d9663c9d1 --- /dev/null +++ b/include/minix/types.h @@ -0,0 +1,168 @@ +/* The header contains important data type definitions. + * It is considered good programming practice to use these definitions, + * instead of the underlying base type. By convention, all type names end + * with _t. + */ + +#ifndef _TYPES_H +#define _TYPES_H + +#ifndef _ANSI_H +#include +#endif + +typedef unsigned char u8_t; /* 8 bit type */ +typedef unsigned short u16_t; /* 16 bit type */ +typedef char i8_t; /* 8 bit signed type */ +typedef short i16_t; /* 16 bit signed type */ + +#if __SIZEOF_LONG__ > 4 +/* compiling with gcc on some (e.g. x86-64) platforms */ +typedef unsigned int u32_t; /* 32 bit type */ +typedef int i32_t; /* 32 bit signed type */ +#else +/* default for ACK or gcc on 32 bit platforms */ +typedef unsigned long u32_t; /* 32 bit type */ +typedef long i32_t; /* 32 bit signed type */ +#endif + +typedef struct { + u32_t lo; + u32_t hi; +} u64_t; + +/* some Minix specific types that do not conflict with posix */ +typedef u32_t zone_t; /* zone number */ +typedef u32_t block_t; /* block number */ +typedef u32_t bit_t; /* bit number in a bit map */ +typedef u16_t zone1_t; /* zone number for V1 file systems */ +typedef u16_t bitchunk_t; /* collection of bits in a bitmap */ + +/* ANSI C makes writing down the promotion of unsigned types very messy. When + * sizeof(short) == sizeof(int), there is no promotion, so the type stays + * unsigned. When the compiler is not ANSI, there is usually no loss of + * unsignedness, and there are usually no prototypes so the promoted type + * doesn't matter. The use of types like Ino_t is an attempt to use ints + * (which are not promoted) while providing information to the reader. + */ + +typedef unsigned long Ino_t; + +#if defined(_MINIX) || defined(__minix) + +/* The type size_t holds all results of the sizeof operator. At first glance, + * it seems obvious that it should be an unsigned int, but this is not always + * the case. For example, MINIX-ST (68000) has 32-bit pointers and 16-bit + * integers. When one asks for the size of a 70K struct or array, the result + * requires 17 bits to express, so size_t must be a long type. The type + * ssize_t is the signed version of size_t. + */ +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#ifndef _SSIZE_T +#define _SSIZE_T +typedef int ssize_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; /* time in sec since 1 Jan 1970 0000 GMT */ +#endif + +#ifndef _CLOCK_T +#define _CLOCK_T +typedef long clock_t; /* unit for system accounting */ +#endif + +#ifndef _SIGSET_T +#define _SIGSET_T +typedef unsigned long sigset_t; +#endif + +#ifndef _KEY_T +#define _KEY_T +typedef long key_t; +#endif + +/* Open Group Base Specifications Issue 6 (not complete) */ +typedef long useconds_t; /* Time in microseconds */ + +typedef short dev_t; /* holds (major|minor) device pair */ + +/* Types used in disk, inode, etc. data structures. */ +typedef char gid_t; /* group id */ +typedef unsigned long ino_t; /* i-node number (V3 filesystem) */ +typedef unsigned short mode_t; /* file type and permissions bits */ +typedef short nlink_t; /* number of links to a file */ +typedef long off_t; /* offset within a file */ +typedef int pid_t; /* process id (must be signed) */ +typedef short uid_t; /* user id */ + +/* The following types are needed because MINIX uses K&R style function + * definitions (for maximum portability). When a short, such as dev_t, is + * passed to a function with a K&R definition, the compiler automatically + * promotes it to an int. The prototype must contain an int as the parameter, + * not a short, because an int is what an old-style function definition + * expects. Thus using dev_t in a prototype would be incorrect. It would be + * sufficient to just use int instead of dev_t in the prototypes, but Dev_t + * is clearer. + */ +typedef int Dev_t; +typedef int _mnx_Gid_t; +typedef int Nlink_t; +typedef int _mnx_Uid_t; +typedef int U8_t; +typedef unsigned long U32_t; +typedef int I8_t; +typedef int I16_t; +typedef long I32_t; + +#if _EM_WSIZE == 2 +/*typedef unsigned int Ino_t; Ino_t is now 32 bits */ +typedef unsigned int Zone1_t; +typedef unsigned int Bitchunk_t; +typedef unsigned int U16_t; +typedef unsigned int _mnx_Mode_t; + +#else /* _EM_WSIZE == 4, or _EM_WSIZE undefined */ +/*typedef int Ino_t; Ino_t is now 32 bits */ +typedef int Zone1_t; +typedef int Bitchunk_t; +typedef int U16_t; +typedef int _mnx_Mode_t; + +#endif /* _EM_WSIZE == 2, etc */ + +/* Signal handler type, e.g. SIG_IGN */ +typedef void _PROTOTYPE( (*sighandler_t), (int) ); + +/* Compatibility with other systems */ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +typedef char *caddr_t; + +/* Devices. */ +#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */ +#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */ + +#ifndef minor +#define minor(dev) (((dev) >> MINOR) & 0xff) +#endif + +#ifndef major +#define major(dev) (((dev) >> MAJOR) & 0xff) +#endif + +#ifndef makedev +#define makedev(major, minor) \ + ((dev_t) (((major) << MAJOR) | ((minor) << MINOR))) +#endif + +#endif /* _MINIX || __minix */ + +#endif /* _TYPES_H */ diff --git a/include/minix/u64.h b/include/minix/u64.h index 82a515a9c..d1e6dcce8 100755 --- a/include/minix/u64.h +++ b/include/minix/u64.h @@ -6,7 +6,7 @@ #define _MINIX__U64_H #ifndef _TYPES_H -#include +#include #endif u64_t add64(u64_t i, u64_t j); diff --git a/include/minix/vm.h b/include/minix/vm.h index ef7692fa3..ef67eeaaa 100755 --- a/include/minix/vm.h +++ b/include/minix/vm.h @@ -3,7 +3,7 @@ #ifndef _MINIX_VM_H #define _MINIX_VM_H -#include +#include #include _PROTOTYPE( int vm_exit, (endpoint_t ep)); diff --git a/include/pwd.h b/include/pwd.h index 244c694b7..c3c7959bf 100755 --- a/include/pwd.h +++ b/include/pwd.h @@ -4,7 +4,7 @@ #define _PWD_H #ifndef _TYPES_H -#include +#include #endif struct passwd { diff --git a/include/regex.h b/include/regex.h index 698e92d5d..4b1c4b579 100755 --- a/include/regex.h +++ b/include/regex.h @@ -41,7 +41,7 @@ #define _REGEX_H_ #ifndef _TYPES_H -#include +#include #endif /* types */ diff --git a/include/signal.h b/include/signal.h index 72ae00494..0be58f01c 100755 --- a/include/signal.h +++ b/include/signal.h @@ -11,7 +11,7 @@ #endif #ifdef _POSIX_SOURCE #ifndef _TYPES_H -#include +#include #endif #endif diff --git a/include/stdint.h b/include/stdint.h index 990bc90d9..77ae1a076 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -11,7 +11,7 @@ #define _STDINT_H #ifndef _MINIX__TYPES_H -#include +#include #endif #include diff --git a/include/stdio.h b/include/stdio.h index 59082fc53..e3f6f8c87 100755 --- a/include/stdio.h +++ b/include/stdio.h @@ -55,7 +55,7 @@ typedef struct __iobuf { #define FOPEN_MAX 20 -#include +#include #define FILENAME_MAX DIRSIZ #define TMP_MAX 999 diff --git a/include/sys/dir.h b/include/sys/dir.h index bb2373de1..578aed097 100755 --- a/include/sys/dir.h +++ b/include/sys/dir.h @@ -1,19 +1,11 @@ -/* The header gives the layout of a directory. */ +/* + * this files resolves conflicts between the file of the host system and + * the minix specific one. This file is included directly only on Minix + * and it is an error to do so on any other system + */ -#ifndef _DIR_H -#define _DIR_H - -#include - -#define DIRBLKSIZ 512 /* size of directory block */ - -#ifndef DIRSIZ -#define DIRSIZ 60 +#if !defined(_MINIX) && !defined(__minix) && !defined(__ACK__) +#error "Including Minix specific file in program targeted for other system" +#else +#include #endif - -struct direct { - ino_t d_ino; - char d_name[DIRSIZ]; -}; - -#endif /* _DIR_H */ diff --git a/include/sys/mman.h b/include/sys/mman.h index 68d06cb3e..6ed8868c8 100755 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -3,7 +3,7 @@ #define _MMAN_H #ifndef _TYPES_H -#include +#include #endif /* prot argument for mmap() */ diff --git a/include/sys/select.h b/include/sys/select.h index f93d39dd0..3132d718f 100755 --- a/include/sys/select.h +++ b/include/sys/select.h @@ -6,7 +6,7 @@ #endif #include -#include +#include #include #include diff --git a/include/sys/stat.h b/include/sys/stat.h index 4dec6c1ca..dddb6968e 100755 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -7,7 +7,7 @@ #define _STAT_H #ifndef _TYPES_H -#include +#include #endif struct stat { diff --git a/include/sys/statfs.h b/include/sys/statfs.h index b1f2371c6..30bf97936 100644 --- a/include/sys/statfs.h +++ b/include/sys/statfs.h @@ -4,7 +4,7 @@ #define _STATFS_H #ifndef _TYPES_H -#include +#include #endif struct statfs { diff --git a/include/sys/svrctl.h b/include/sys/svrctl.h index e4868f078..a85b10371 100755 --- a/include/sys/svrctl.h +++ b/include/sys/svrctl.h @@ -8,7 +8,7 @@ Created: Feb 15, 1994 by Philip Homburg #define _SYS__SVRCTL_H #ifndef _TYPES_H -#include +#include #endif /* Server control commands have the same encoding as the commands for ioctls. */ diff --git a/include/sys/types.h b/include/sys/types.h index 8c3bcb3a2..388f4371a 100755 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -1,154 +1,11 @@ -/* The header contains important data type definitions. - * It is considered good programming practice to use these definitions, - * instead of the underlying base type. By convention, all type names end - * with _t. +/* + * this files resolves conflicts between the file of the host system and + * the minix specific one. This file is included directly only on Minix + * and it is an error to do so on any other system */ -#ifndef _TYPES_H -#define _TYPES_H - -#ifndef _ANSI_H -#include +#if !defined(_MINIX) && !defined(__minix) && !defined(__ACK__) +#error "Including Minix specific file in program targeted for other system" +#else +#include #endif - -/* The type size_t holds all results of the sizeof operator. At first glance, - * it seems obvious that it should be an unsigned int, but this is not always - * the case. For example, MINIX-ST (68000) has 32-bit pointers and 16-bit - * integers. When one asks for the size of a 70K struct or array, the result - * requires 17 bits to express, so size_t must be a long type. The type - * ssize_t is the signed version of size_t. - */ -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif - -#ifndef _SSIZE_T -#define _SSIZE_T -typedef int ssize_t; -#endif - -#ifndef _TIME_T -#define _TIME_T -typedef long time_t; /* time in sec since 1 Jan 1970 0000 GMT */ -#endif - -#ifndef _CLOCK_T -#define _CLOCK_T -typedef long clock_t; /* unit for system accounting */ -#endif - -#ifndef _SIGSET_T -#define _SIGSET_T -typedef unsigned long sigset_t; -#endif - -#ifndef _KEY_T -#define _KEY_T -typedef long key_t; -#endif - -/* Open Group Base Specifications Issue 6 (not complete) */ -typedef long useconds_t; /* Time in microseconds */ - -/* Types used in disk, inode, etc. data structures. */ -typedef short dev_t; /* holds (major|minor) device pair */ -typedef char gid_t; /* group id */ -typedef unsigned long ino_t; /* i-node number (V3 filesystem) */ -typedef unsigned short mode_t; /* file type and permissions bits */ -typedef short nlink_t; /* number of links to a file */ -typedef long off_t; /* offset within a file */ -typedef int pid_t; /* process id (must be signed) */ -typedef short uid_t; /* user id */ -typedef unsigned long zone_t; /* zone number */ -typedef unsigned long block_t; /* block number */ -typedef unsigned long bit_t; /* bit number in a bit map */ -typedef unsigned short zone1_t; /* zone number for V1 file systems */ -typedef unsigned short bitchunk_t; /* collection of bits in a bitmap */ - -typedef unsigned char u8_t; /* 8 bit type */ -typedef unsigned short u16_t; /* 16 bit type */ -typedef unsigned long u32_t; /* 32 bit type */ - -typedef char i8_t; /* 8 bit signed type */ -typedef short i16_t; /* 16 bit signed type */ -typedef long i32_t; /* 32 bit signed type */ - -typedef struct { - u32_t lo; - u32_t hi; -} u64_t; - -/* The following types are needed because MINIX uses K&R style function - * definitions (for maximum portability). When a short, such as dev_t, is - * passed to a function with a K&R definition, the compiler automatically - * promotes it to an int. The prototype must contain an int as the parameter, - * not a short, because an int is what an old-style function definition - * expects. Thus using dev_t in a prototype would be incorrect. It would be - * sufficient to just use int instead of dev_t in the prototypes, but Dev_t - * is clearer. - */ -typedef int Dev_t; -typedef int _mnx_Gid_t; -typedef int Nlink_t; -typedef int _mnx_Uid_t; -typedef int U8_t; -typedef unsigned long U32_t; -typedef int I8_t; -typedef int I16_t; -typedef long I32_t; - -/* ANSI C makes writing down the promotion of unsigned types very messy. When - * sizeof(short) == sizeof(int), there is no promotion, so the type stays - * unsigned. When the compiler is not ANSI, there is usually no loss of - * unsignedness, and there are usually no prototypes so the promoted type - * doesn't matter. The use of types like Ino_t is an attempt to use ints - * (which are not promoted) while providing information to the reader. - */ - -typedef unsigned long Ino_t; - -#if _EM_WSIZE == 2 -/*typedef unsigned int Ino_t; Ino_t is now 32 bits */ -typedef unsigned int Zone1_t; -typedef unsigned int Bitchunk_t; -typedef unsigned int U16_t; -typedef unsigned int _mnx_Mode_t; - -#else /* _EM_WSIZE == 4, or _EM_WSIZE undefined */ -/*typedef int Ino_t; Ino_t is now 32 bits */ -typedef int Zone1_t; -typedef int Bitchunk_t; -typedef int U16_t; -typedef int _mnx_Mode_t; - -#endif /* _EM_WSIZE == 2, etc */ - -/* Signal handler type, e.g. SIG_IGN */ -typedef void _PROTOTYPE( (*sighandler_t), (int) ); - -/* Compatibility with other systems */ -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef char *caddr_t; - -/* Devices. */ -#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */ -#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */ - -#ifndef minor -#define minor(dev) (((dev) >> MINOR) & 0xff) -#endif - -#ifndef major -#define major(dev) (((dev) >> MAJOR) & 0xff) -#endif - -#ifndef makedev -#define makedev(major, minor) \ - ((dev_t) (((major) << MAJOR) | ((minor) << MINOR))) -#endif - -#endif /* _TYPES_H */ diff --git a/include/sys/wait.h b/include/sys/wait.h index 73d6f5595..9b177874b 100755 --- a/include/sys/wait.h +++ b/include/sys/wait.h @@ -17,7 +17,7 @@ #define _WAIT_H #ifndef _TYPES_H -#include +#include #endif #define _LOW(v) ( (v) & 0377) diff --git a/include/timers.h b/include/timers.h index 8dbd135d0..e88d5674a 100644 --- a/include/timers.h +++ b/include/timers.h @@ -16,7 +16,7 @@ #define _TIMERS_H #include -#include +#include struct timer; typedef void (*tmr_func_t)(struct timer *tp); diff --git a/include/tools.h b/include/tools.h index b59e00ecb..a69db0e5f 100755 --- a/include/tools.h +++ b/include/tools.h @@ -76,12 +76,14 @@ EXTERN environment *env; /* Lists the environment */ EXTERN int fsok; /* True if the boot device contains an FS */ EXTERN u32_t lowsec; /* Offset to the file system on the boot dev */ +#if defined(_MINIX) || defined(__minix) || defined(__ACK__) /* Prototypes */ _PROTOTYPE( off_t r_super, (void)); _PROTOTYPE( void r_stat, (Ino_t _inum, struct stat *_stp )); _PROTOTYPE( ino_t r_readdir, (char *_name )); _PROTOTYPE( off_t r_vir2abs, (off_t _virblk )); _PROTOTYPE( ino_t r_lookup, (Ino_t _cwd, char *_path )); +#endif #ifdef _MONHEAD _PROTOTYPE( void readerr, (off_t _sec, int _err )); diff --git a/include/unistd.h b/include/unistd.h index 3c9e15eaf..156742430 100755 --- a/include/unistd.h +++ b/include/unistd.h @@ -4,7 +4,7 @@ #define _UNISTD_H #ifndef _TYPES_H -#include +#include #endif /* Values used by access(). POSIX Table 2-8. */ diff --git a/include/utime.h b/include/utime.h index b512aa482..e02078703 100755 --- a/include/utime.h +++ b/include/utime.h @@ -4,7 +4,7 @@ #define _UTIME_H #ifndef _TYPES_H -#include +#include #endif struct utimbuf {