From: Philip Homburg Date: Fri, 10 Jun 2005 15:12:03 +0000 (+0000) Subject: Improved compatibility with other Unix systems. X-Git-Tag: v3.1.0~761 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=dc23e18cef1e704f49b8e576cc83313a6ebf2538;p=minix.git Improved compatibility with other Unix systems. --- diff --git a/include/ansi.h b/include/ansi.h index 1e4eac3e1..8c1d50faa 100755 --- a/include/ansi.h +++ b/include/ansi.h @@ -55,6 +55,9 @@ #endif /* _ANSI */ +/* This should be defined as restrict when a C99 compiler is used. */ +#define _RESTRICT + /* Setting any of _MINIX, _POSIX_C_SOURCE or _POSIX2_SOURCE implies * _POSIX_SOURCE. (Seems wrong to put this here in ANSI space.) */ diff --git a/include/arpa/inet.h b/include/arpa/inet.h new file mode 100644 index 000000000..99516d72a --- /dev/null +++ b/include/arpa/inet.h @@ -0,0 +1,11 @@ +/* +arpa/inet.h +*/ + +#ifndef _ARPA__INET_H +#define _ARPA__INET_H + +/* Open Group Base Specifications Issue 6 (not complete): */ +char *inet_ntoa(struct in_addr in); + +#endif /* _ARPA__INET_H */ diff --git a/include/inttypes.h b/include/inttypes.h new file mode 100644 index 000000000..0a3c0c7e8 --- /dev/null +++ b/include/inttypes.h @@ -0,0 +1,236 @@ +/* inttypes.h - Format conversions of integer types. + * Author: Kees J. Bot + * 4 Oct 2003 + * Assumptions and bugs the same as for + * Bug: Wide character integer conversion functions missing. + */ + +#ifndef _INTTYPES_H +#define _INTTYPES_H + +#ifndef _STDINT_H +#include +#endif + +#if !__cplusplus || defined(__STDC_FORMAT_MACROS) + +/* Macros to print integers defined in . The first group should + * not be used in code, they're merely here to build the second group. + * (The standard really went overboard here, only the first group is needed.) + */ +#define PRI8 "" +#define PRILEAST8 "" +#define PRIFAST8 "" +#define PRI16 "" +#define PRILEAST16 "" +#define PRIFAST16 "" +#if _WORD_SIZE == 2 +#define PRI32 "l" +#define PRILEAST32 "l" +#define PRIFAST32 "l" +#else +#define PRI32 "" +#define PRILEAST32 "" +#define PRIFAST32 "" +#endif +#if _WORD_SIZE > 2 && __L64 +#define PRI64 "l" +#define PRILEAST64 "l" +#define PRIFAST64 "l" +#endif + +/* Macros for fprintf, the ones defined by the standard. */ +#define PRId8 PRI8"d" +#define PRIdLEAST8 PRILEAST8"d" +#define PRIdFAST8 PRIFAST8"d" +#define PRId16 PRI16"d" +#define PRIdLEAST16 PRILEAST16"d" +#define PRIdFAST16 PRIFAST16"d" +#define PRId32 PRI32"d" +#define PRIdLEAST32 PRILEAST32"d" +#define PRIdFAST32 PRIFAST32"d" +#if _WORD_SIZE > 2 && __L64 +#define PRId64 PRI64"d" +#define PRIdLEAST64 PRILEAST64"d" +#define PRIdFAST64 PRIFAST64"d" +#endif + +#define PRIi8 PRI8"i" +#define PRIiLEAST8 PRILEAST8"i" +#define PRIiFAST8 PRIFAST8"i" +#define PRIi16 PRI16"i" +#define PRIiLEAST16 PRILEAST16"i" +#define PRIiFAST16 PRIFAST16"i" +#define PRIi32 PRI32"i" +#define PRIiLEAST32 PRILEAST32"i" +#define PRIiFAST32 PRIFAST32"i" +#if _WORD_SIZE > 2 && __L64 +#define PRIi64 PRI64"i" +#define PRIiLEAST64 PRILEAST64"i" +#define PRIiFAST64 PRIFAST64"i" +#endif + +#define PRIo8 PRI8"o" +#define PRIoLEAST8 PRILEAST8"o" +#define PRIoFAST8 PRIFAST8"o" +#define PRIo16 PRI16"o" +#define PRIoLEAST16 PRILEAST16"o" +#define PRIoFAST16 PRIFAST16"o" +#define PRIo32 PRI32"o" +#define PRIoLEAST32 PRILEAST32"o" +#define PRIoFAST32 PRIFAST32"o" +#if _WORD_SIZE > 2 && __L64 +#define PRIo64 PRI64"o" +#define PRIoLEAST64 PRILEAST64"o" +#define PRIoFAST64 PRIFAST64"o" +#endif + +#define PRIu8 PRI8"u" +#define PRIuLEAST8 PRILEAST8"u" +#define PRIuFAST8 PRIFAST8"u" +#define PRIu16 PRI16"u" +#define PRIuLEAST16 PRILEAST16"u" +#define PRIuFAST16 PRIFAST16"u" +#define PRIu32 PRI32"u" +#define PRIuLEAST32 PRILEAST32"u" +#define PRIuFAST32 PRIFAST32"u" +#if _WORD_SIZE > 2 && __L64 +#define PRIu64 PRI64"u" +#define PRIuLEAST64 PRILEAST64"u" +#define PRIuFAST64 PRIFAST64"u" +#endif + +#define PRIx8 PRI8"x" +#define PRIxLEAST8 PRILEAST8"x" +#define PRIxFAST8 PRIFAST8"x" +#define PRIx16 PRI16"x" +#define PRIxLEAST16 PRILEAST16"x" +#define PRIxFAST16 PRIFAST16"x" +#define PRIx32 PRI32"x" +#define PRIxLEAST32 PRILEAST32"x" +#define PRIxFAST32 PRIFAST32"x" +#if _WORD_SIZE > 2 && __L64 +#define PRIx64 PRI64"x" +#define PRIxLEAST64 PRILEAST64"x" +#define PRIxFAST64 PRIFAST64"x" +#endif + +#define PRIX8 PRI8"X" +#define PRIXLEAST8 PRILEAST8"X" +#define PRIXFAST8 PRIFAST8"X" +#define PRIX16 PRI16"X" +#define PRIXLEAST16 PRILEAST16"X" +#define PRIXFAST16 PRIFAST16"X" +#define PRIX32 PRI32"X" +#define PRIXLEAST32 PRILEAST32"X" +#define PRIXFAST32 PRIFAST32"X" +#if _WORD_SIZE > 2 && __L64 +#define PRIX64 PRI64"X" +#define PRIXLEAST64 PRILEAST64"X" +#define PRIXFAST64 PRIFAST64"X" +#endif + +/* Macros to scan integers with fscanf(), nonstandard first group. */ +#define SCN8 "hh" +#define SCNLEAST8 "hh" +#define SCNFAST8 "" +#define SCN16 "h" +#define SCNLEAST16 "h" +#define SCNFAST16 "" +#if _WORD_SIZE == 2 +#define SCN32 "l" +#define SCNLEAST32 "l" +#define SCNFAST32 "l" +#else +#define SCN32 "" +#define SCNLEAST32 "" +#define SCNFAST32 "" +#endif +#if _WORD_SIZE > 2 && __L64 +#define SCN64 "l" +#define SCNLEAST64 "l" +#define SCNFAST64 "l" +#endif + +/* Macros for fscanf, the ones defined by the standard. */ +#define SCNd8 SCN8"d" +#define SCNdLEAST8 SCNLEAST8"d" +#define SCNdFAST8 SCNFAST8"d" +#define SCNd16 SCN16"d" +#define SCNdLEAST16 SCNLEAST16"d" +#define SCNdFAST16 SCNFAST16"d" +#define SCNd32 SCN32"d" +#define SCNdLEAST32 SCNLEAST32"d" +#define SCNdFAST32 SCNFAST32"d" +#if _WORD_SIZE > 2 && __L64 +#define SCNd64 SCN64"d" +#define SCNdLEAST64 SCNLEAST64"d" +#define SCNdFAST64 SCNFAST64"d" +#endif + +#define SCNi8 SCN8"i" +#define SCNiLEAST8 SCNLEAST8"i" +#define SCNiFAST8 SCNFAST8"i" +#define SCNi16 SCN16"i" +#define SCNiLEAST16 SCNLEAST16"i" +#define SCNiFAST16 SCNFAST16"i" +#define SCNi32 SCN32"i" +#define SCNiLEAST32 SCNLEAST32"i" +#define SCNiFAST32 SCNFAST32"i" +#if _WORD_SIZE > 2 && __L64 +#define SCNi64 SCN64"i" +#define SCNiLEAST64 SCNLEAST64"i" +#define SCNiFAST64 SCNFAST64"i" +#endif + +#define SCNo8 SCN8"o" +#define SCNoLEAST8 SCNLEAST8"o" +#define SCNoFAST8 SCNFAST8"o" +#define SCNo16 SCN16"o" +#define SCNoLEAST16 SCNLEAST16"o" +#define SCNoFAST16 SCNFAST16"o" +#define SCNo32 SCN32"o" +#define SCNoLEAST32 SCNLEAST32"o" +#define SCNoFAST32 SCNFAST32"o" +#if _WORD_SIZE > 2 && __L64 +#define SCNo64 SCN64"o" +#define SCNoLEAST64 SCNLEAST64"o" +#define SCNoFAST64 SCNFAST64"o" +#endif + +#define SCNu8 SCN8"u" +#define SCNuLEAST8 SCNLEAST8"u" +#define SCNuFAST8 SCNFAST8"u" +#define SCNu16 SCN16"u" +#define SCNuLEAST16 SCNLEAST16"u" +#define SCNuFAST16 SCNFAST16"u" +#define SCNu32 SCN32"u" +#define SCNuLEAST32 SCNLEAST32"u" +#define SCNuFAST32 SCNFAST32"u" +#if _WORD_SIZE > 2 && __L64 +#define SCNu64 SCN64"u" +#define SCNuLEAST64 SCNLEAST64"u" +#define SCNuFAST64 SCNFAST64"u" +#endif + +#define SCNx8 SCN8"x" +#define SCNxLEAST8 SCNLEAST8"x" +#define SCNxFAST8 SCNFAST8"x" +#define SCNx16 SCN16"x" +#define SCNxLEAST16 SCNLEAST16"x" +#define SCNxFAST16 SCNFAST16"x" +#define SCNx32 SCN32"x" +#define SCNxLEAST32 SCNLEAST32"x" +#define SCNxFAST32 SCNFAST32"x" +#if _WORD_SIZE > 2 && __L64 +#define SCNx64 SCN64"x" +#define SCNxLEAST64 SCNLEAST64"x" +#define SCNxFAST64 SCNFAST64"x" +#endif +#endif /* !__cplusplus || __STDC_FORMAT_MACROS */ + +/* Integer conversion functions for [u]intmax_t. */ +#define stroimax(nptr, endptr, base) strtol(nptr, endptr, base) +#define stroumax(nptr, endptr, base) strtoul(nptr, endptr, base) + +#endif /* _INTTYPES_H */ diff --git a/include/minix/config.h b/include/minix/config.h index df20c96a7..0c86c14c4 100755 --- a/include/minix/config.h +++ b/include/minix/config.h @@ -26,6 +26,7 @@ /* Word size in bytes (a constant equal to sizeof(int)). */ #if __ACK__ #define _WORD_SIZE _EM_WSIZE +#define _PTR_SIZE _EM_WSIZE #endif /* Number of slots in the process table for non-kernel processes. */ diff --git a/include/netdb.h b/include/netdb.h new file mode 100644 index 000000000..1b7423935 --- /dev/null +++ b/include/netdb.h @@ -0,0 +1,6 @@ +/* +netdb.h +*/ + +/* Open Group Base Specifications Issue 6 (not complete) */ +#include diff --git a/include/netinet/in.h b/include/netinet/in.h new file mode 100644 index 000000000..11e33bde9 --- /dev/null +++ b/include/netinet/in.h @@ -0,0 +1,21 @@ +/* +netinet/in.h +*/ + +#ifndef _NETINET__IN_H +#define _NETINET__IN_H + +/* Can we include here or do we need an additional header that is + * safe to include? + */ +#include + +/* Open Group Base Specifications Issue 6 (not complete) */ +typedef uint32_t in_addr_t; + +struct in_addr +{ + in_addr_t s_addr; +}; + +#endif /* _NETINET__IN_H */ diff --git a/include/stdint.h b/include/stdint.h new file mode 100644 index 000000000..0e7a402b0 --- /dev/null +++ b/include/stdint.h @@ -0,0 +1,221 @@ +/* stdint.h - Standard sized integer types. Author: Kees J. Bot + * 4 Oct 2003 + * + * Assumption: Long is the biggest type. + * Bug: C99 requires a 64 bit type, and long isn't 64 bits yet, and + * will never be 64 bits under 16-bits Minix. + * Omission: Limits like PTR_DIFF_MAX not here yet, maybe ? + */ + +#ifndef _STDINT_H +#define _STDINT_H + +#ifndef _MINIX__TYPES_H +#include +#endif + +#if (_WORD_SIZE != 2 && _WORD_SIZE != 4) || \ + (_PTR_SIZE != _WORD_SIZE && _PTR_SIZE != 2*_WORD_SIZE) +#error Odd word or pointer sizes +#endif + +/* Integer types of precisely the given bitsize. */ +typedef i8_t int8_t; +typedef i16_t int16_t; +typedef i32_t int32_t; +#if _WORD_SIZE > 2 && __L64 +typedef i64_t int64_t; +#endif + +typedef u8_t uint8_t; +typedef u16_t uint16_t; +typedef u32_t uint32_t; +#if _WORD_SIZE > 2 && __L64 +typedef u64_t uint64_t; +#endif + +/* Integer types of at least the given bitsize. */ +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +#if _WORD_SIZE > 2 && __L64 +typedef int64_t int_least64_t; +#endif + +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +#if _WORD_SIZE > 2 && __L64 +typedef uint64_t uint_least64_t; +#endif + +/* Fast integer types of at least the given bitsize. */ +#if _WORD_SIZE == 2 +typedef int16_t int_fast8_t; +typedef int16_t int_fast16_t; +#else +typedef int32_t int_fast8_t; +typedef int32_t int_fast16_t; +#endif +typedef int32_t int_fast32_t; +#if _WORD_SIZE > 2 && __L64 +typedef int64_t int_fast64_t; +#endif + +#if _WORD_SIZE == 2 +typedef uint16_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +#else +typedef uint32_t uint_fast8_t; +typedef uint32_t uint_fast16_t; +#endif +typedef uint32_t uint_fast32_t; +#if _WORD_SIZE > 2 && __L64 +typedef uint64_t uint_fast64_t; +#endif + +/* Integer type capable of holding a pointer and the largest integer type. */ +#if _PTR_SIZE == _WORD_SIZE +typedef int intptr_t; +typedef unsigned uintptr_t; +#elif _PTR_SIZE == 2*_WORD_SIZE +typedef long intptr_t; +typedef unsigned long uintptr_t; +#endif +typedef long intmax_t; +typedef unsigned long uintmax_t; + +#if !__cplusplus || defined(__STDC_LIMIT_MACROS) +#ifndef _LIMITS_H +#include +#endif + +/* Range definitions for each of the above types conform . */ +#define INT8_MIN (-INT8_MAX-1) +#define INT16_MIN (-INT16_MAX-1) +#define INT32_MIN (-INT32_MAX-1) +#if _WORD_SIZE > 2 && __L64 +#define INT64_MIN (-INT64_MAX-1) +#endif + +#define INT8_MAX 127 +#define INT16_MAX 32767 +#define INT32_MAX 2147483647 +#if _WORD_SIZE > 2 && __L64 +#define INT64_MAX 9223372036854775807 +#endif + +#define UINT8_MAX 255 +#define UINT16_MAX 65535 +#define UINT32_MAX 4294967295 +#if _WORD_SIZE > 2 && __L64 +#define UINT64_MAX 18446744073709551615 +#endif + +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST32_MIN INT32_MIN +#if _WORD_SIZE > 2 && __L64 +#define INT_LEAST64_MIN INT64_MIN +#endif + +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MAX INT32_MAX +#if _WORD_SIZE > 2 && __L64 +#define INT_LEAST64_MAX INT64_MAX +#endif + +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#if _WORD_SIZE > 2 && __L64 +#define UINT_LEAST64_MAX UINT64_MAX +#endif + +#define INT_FAST8_MIN (-INT_FAST8_MAX-1) +#define INT_FAST16_MIN (-INT_FAST16_MAX-1) +#define INT_FAST32_MIN INT32_MIN +#if _WORD_SIZE > 2 && __L64 +#define INT_FAST64_MIN INT64_MIN +#endif + +#if _WORD_SIZE == 2 +#define INT_FAST8_MAX INT16_MAX +#define INT_FAST16_MAX INT16_MAX +#else +#define INT_FAST8_MAX INT32_MAX +#define INT_FAST16_MAX INT32_MAX +#endif +#define INT_FAST32_MAX INT32_MAX +#if _WORD_SIZE > 2 && __L64 +#define INT_FAST64_MAX INT64_MAX +#endif + +#if _WORD_SIZE == 2 +#define UINT_FAST8_MAX UINT16_MAX +#define UINT_FAST16_MAX UINT16_MAX +#else +#define UINT_FAST8_MAX UINT32_MAX +#define UINT_FAST16_MAX UINT32_MAX +#endif +#define UINT_FAST32_MAX UINT32_MAX +#if _WORD_SIZE > 2 && __L64 +#define UINT_FAST64_MAX UINT64_MAX +#endif + +#if _PTR_SIZE == _WORD_SIZE +#define INTPTR_MIN INT_MIN +#define INTPTR_MAX INT_MAX +#define UINTPTR_MAX UINT_MAX +#elif _PTR_SIZE > _WORD_SIZE +#define INTPTR_MIN LONG_MIN +#define INTPTR_MAX LONG_MAX +#define UINTPTR_MAX ULONG_MAX +#endif +#define INTMAX_MIN LONG_MIN +#define INTMAX_MAX LONG_MAX +#define UINTMAX_MAX ULONG_MAX + +#endif /* !__cplusplus || __STDC_LIMIT_MACROS */ + +#ifndef __CONCAT +#define __CONCAT(x,y) x ## y +#endif + +/* Constants of the proper type. */ +#define INT8_C(c) c +#define INT16_C(c) c +#if _WORD_SIZE == 2 +#define INT32_C(c) __CONCAT(c,l) +#else +#define INT32_C(c) c +#endif +#if _WORD_SIZE > 2 && __L64 +#define INT64_C(c) __CONCAT(c,l) +#endif + +#define UINT8_C(c) __CONCAT(c,u) +#define UINT16_C(c) __CONCAT(c,u) +#if _WORD_SIZE == 2 +#define UINT32_C(c) __CONCAT(c,lu) +#else +#define UINT32_C(c) __CONCAT(c,u) +#endif +#if _WORD_SIZE > 2 && __L64 +#define UINT64_C(c) __CONCAT(c,lu) +#endif + +#if _WORD_SIZE == 2 || !__L64 +#define INTMAX_C(c) INT32_C(c) +#define UINTMAX_C(c) UINT32_C(c) +#else +#define INTMAX_C(c) INT64_C(c) +#define UINTMAX_C(c) UINT64_C(c) +#endif + +#endif /* _STDINT_H */ + +/* + * $PchId: stdint.h,v 1.2 2005/01/27 17:32:00 philip Exp $ + */ diff --git a/include/sys/asynchio.h b/include/sys/asynchio.h index b80ac7d84..06bac33d8 100755 --- a/include/sys/asynchio.h +++ b/include/sys/asynchio.h @@ -12,6 +12,8 @@ #include #endif +#include + typedef struct { char state; char op; diff --git a/include/sys/socket.h b/include/sys/socket.h new file mode 100644 index 000000000..e2c642e9c --- /dev/null +++ b/include/sys/socket.h @@ -0,0 +1,6 @@ +/* +sys/socket.h +*/ + +/* Open Group Base Specifications Issue 6 (not complete) */ +#include diff --git a/include/sys/stat.h b/include/sys/stat.h index f1be28525..28dbb5a5c 100755 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -29,6 +29,7 @@ struct stat { * extensions such as S_IFREG != (mode_t) S_IFREG when ints are 32 bits. */ #define S_IFMT ((mode_t) 0170000) /* type of file */ +#define S_IFLNK ((mode_t) 0120000) /* symbolic link, not implemented */ #define S_IFREG ((mode_t) 0100000) /* regular */ #define S_IFBLK 0060000 /* block special */ #define S_IFDIR 0040000 /* directory */ @@ -61,7 +62,7 @@ struct stat { #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* is a char spec */ #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) /* is a block spec */ #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */ - +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* is a sym link */ /* Function Prototypes. */ _PROTOTYPE( int chmod, (const char *_path, Mode_t _mode) ); @@ -71,4 +72,7 @@ _PROTOTYPE( int mkfifo, (const char *_path, Mode_t _mode) ); _PROTOTYPE( int stat, (const char *_path, struct stat *_buf) ); _PROTOTYPE( mode_t umask, (Mode_t _cmask) ); +/* Open Group Base Specifications Issue 6 (not complete) */ +_PROTOTYPE( int lstat, (const char *_path, struct stat *_buf) ); + #endif /* _STAT_H */ diff --git a/include/sys/time.h b/include/sys/time.h new file mode 100644 index 000000000..e8ce1b09a --- /dev/null +++ b/include/sys/time.h @@ -0,0 +1,22 @@ +/* +sys/time.h +*/ + +#ifndef _SYS__TIME_H +#define _SYS__TIME_H + +#include + +/* Open Group Base Specifications Issue 6 (not complete) */ +struct timeval +{ + long /*time_t*/ tv_sec; + long /*useconds_t*/ tv_usec; +}; + +int gettimeofday(struct timeval *_RESTRICT tp, void *_RESTRICT tzp); + +/* Compatibility with other Unix systems */ +int settimeofday(const struct timeval *tp, const void *tzp); + +#endif /* _SYS__TIME_H */ diff --git a/include/sys/types.h b/include/sys/types.h index c4a847ce6..6bbf5b4cb 100755 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -43,6 +43,9 @@ typedef long clock_t; /* unit for system accounting */ typedef unsigned long sigset_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 */ @@ -116,4 +119,10 @@ typedef int Mode_t; /* 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; + #endif /* _TYPES_H */ diff --git a/include/time.h b/include/time.h index bc6022121..8cb0f3a8c 100755 --- a/include/time.h +++ b/include/time.h @@ -70,7 +70,6 @@ _PROTOTYPE( void tzset, (void) ); _PROTOTYPE( int stime, (time_t *_top) ); #endif -struct timeval { long tv_sec, tv_usec; }; extern long timezone; #endif /* _TIME_H */ diff --git a/include/unistd.h b/include/unistd.h index 0a7c06b9e..870ee51e2 100755 --- a/include/unistd.h +++ b/include/unistd.h @@ -130,6 +130,9 @@ _PROTOTYPE( char *ttyname, (int _fd) ); _PROTOTYPE( int unlink, (const char *_path) ); _PROTOTYPE( ssize_t write, (int _fd, const void *_buf, size_t _n) ); +/* Open Group Base Specifications Issue 6 (not complete) */ +_PROTOTYPE( int symlink, (const char *path1, const char *path2) ); + #ifdef _MINIX #ifndef _TYPE_H #include @@ -156,6 +159,11 @@ _PROTOTYPE( int getprocnr, (int *proc_nr) ); _PROTOTYPE( int findproc, (char *proc_name, int *proc_nr) ); _PROTOTYPE( int allocmem, (phys_bytes size, phys_bytes *base) ); _PROTOTYPE( int freemem, (phys_bytes size, phys_bytes base) ); + +/* For compatibility with other Unix systems */ +_PROTOTYPE( int getpagesize, (void) ); +_PROTOTYPE( int setgroups, (int ngroups, const gid_t *gidset) ); + #endif _PROTOTYPE( int setcache, (int kb)); diff --git a/lib/ip/gethnmadr.c b/lib/ip/gethnmadr.c index 3f79d1b0c..5f14875ac 100755 --- a/lib/ip/gethnmadr.c +++ b/lib/ip/gethnmadr.c @@ -58,9 +58,6 @@ struct in_addr { ipaddr_t s_addr; }; -typedef u32_t u_long; -typedef u16_t u_short; -typedef u8_t u_char; union querybuf; extern int dn_skipname _ARGS(( const u_char *comp_dn, const u_char *eom )); diff --git a/lib/ip/res_comp.c b/lib/ip/res_comp.c index 36a6b79e9..0b4574027 100755 --- a/lib/ip/res_comp.c +++ b/lib/ip/res_comp.c @@ -29,10 +29,6 @@ static char sccsid[] = "@(#)res_comp.c 6.18 (Berkeley) 6/27/90"; #include #include -typedef u8_t u_char; -typedef u16_t u_short; -typedef u32_t u_long; - static int dn_find _ARGS(( const u_char *exp_dn, const u_char *msg, u_char **dnptrs, u_char **lastdnptr )); int dn_skipname _ARGS(( const u_char *comp_dn, const u_char *eom )); diff --git a/lib/ip/res_mkquery.c b/lib/ip/res_mkquery.c index bf1800091..ef6a0ab0f 100755 --- a/lib/ip/res_mkquery.c +++ b/lib/ip/res_mkquery.c @@ -32,10 +32,6 @@ static char sccsid[] = "@(#)res_mkquery.c 6.12 (Berkeley) 6/1/90"; #include #include -typedef u16_t u_short; -typedef unsigned u_int; -typedef u32_t u_long; - #define bzero(b,l) memset(b,0,l) #define bcopy(s,d,l) memcpy(d,s,l) diff --git a/lib/ip/res_query.c b/lib/ip/res_query.c index 6f6330d9a..2fa6ce2ac 100755 --- a/lib/ip/res_query.c +++ b/lib/ip/res_query.c @@ -35,8 +35,6 @@ static char sccsid[] = "@(#)res_query.c 5.7 (Berkeley) 6/1/90"; #include #include -typedef u8_t u_char; - #define bcopy(s,d,l) memcpy(d,s,l) #define hostalias __hostalias diff --git a/lib/ip/res_send.c b/lib/ip/res_send.c index dd6ac99fc..1c6dbe4c1 100755 --- a/lib/ip/res_send.c +++ b/lib/ip/res_send.c @@ -80,8 +80,6 @@ static char sccsid[] = "@(#)res_send.c 6.27 (Berkeley) 2/24/91"; #include #include -typedef u16_t u_short; - static int tcp_connect _ARGS(( ipaddr_t host, Tcpport_t port, int *terrno )); static int tcpip_writeall _ARGS(( int fd, const char *buf, size_t siz )); static int udp_connect _ARGS(( void )); diff --git a/lib/other/Makefile b/lib/other/Makefile index 990b6d8ea..724448ef5 100755 --- a/lib/other/Makefile +++ b/lib/other/Makefile @@ -33,6 +33,7 @@ OBJECTS = \ $(LIBRARY)(getgrent.o) \ $(LIBRARY)(getlogin.o) \ $(LIBRARY)(getopt.o) \ + $(LIBRARY)(getpagesize.o) \ $(LIBRARY)(getpass.o) \ $(LIBRARY)(getpwent.o) \ $(LIBRARY)(getttyent.o) \ @@ -51,6 +52,8 @@ OBJECTS = \ $(LIBRARY)(popen.o) \ $(LIBRARY)(putenv.o) \ $(LIBRARY)(putw.o) \ + $(LIBRARY)(setgroups.o) \ + $(LIBRARY)(settimeofday.o) \ $(LIBRARY)(stderr.o) \ $(LIBRARY)(swab.o) \ $(LIBRARY)(syscall.o) \ @@ -144,6 +147,9 @@ $(LIBRARY)(getlogin.o): getlogin.c $(LIBRARY)(getopt.o): getopt.c $(CC1) getopt.c +$(LIBRARY)(getpagesize.o): getpagesize.c + $(CC1) getpagesize.c + $(LIBRARY)(getpass.o): getpass.c $(CC1) getpass.c @@ -204,6 +210,12 @@ $(LIBRARY)(putw.o): putw.c $(LIBRARY)(rindex.o): rindex.c $(CC1) rindex.c +$(LIBRARY)(setgroups.o): setgroups.c + $(CC1) setgroups.c + +$(LIBRARY)(settimeofday.o): settimeofday.c + $(CC1) settimeofday.c + $(LIBRARY)(stderr.o): stderr.c $(CC1) stderr.c diff --git a/lib/other/getpagesize.c b/lib/other/getpagesize.c new file mode 100644 index 000000000..fd0f6258b --- /dev/null +++ b/lib/other/getpagesize.c @@ -0,0 +1,11 @@ +/* +getpagesize.c +*/ + +#include + +int getpagesize(void) +{ + /* We don't have paging. Pretend that we do. */ + return 4096; +} diff --git a/lib/other/setgroups.c b/lib/other/setgroups.c new file mode 100644 index 000000000..23a364417 --- /dev/null +++ b/lib/other/setgroups.c @@ -0,0 +1,15 @@ +/* +setgroups.c +*/ + +#include +#include + +int setgroups(int ngroups, const gid_t *gidset) +{ + /* Not implemented */ + + errno= ENOSYS; + return -1; +} + diff --git a/lib/other/settimeofday.c b/lib/other/settimeofday.c new file mode 100644 index 000000000..956135a38 --- /dev/null +++ b/lib/other/settimeofday.c @@ -0,0 +1,14 @@ +/* +settimeofday.c +*/ + +#define stime _stime + +#include +#include + +int settimeofday(const struct timeval *tp, const void *tzp) +{ + /* Ignore time zones */ + return stime(&tp->tv_sec); +} diff --git a/lib/posix/Makefile b/lib/posix/Makefile index 638ac71ac..cd8f68f8b 100755 --- a/lib/posix/Makefile +++ b/lib/posix/Makefile @@ -95,6 +95,9 @@ OBJECTS = \ $(LIBRARY)(_wait.o) \ $(LIBRARY)(_waitpid.o) \ $(LIBRARY)(_write.o) \ + $(LIBRARY)(gettimeofday.o) \ + $(LIBRARY)(lstat.o) \ + $(LIBRARY)(symlink.o) \ $(LIBRARY): $(OBJECTS) aal cr $@ *.o @@ -363,3 +366,13 @@ $(LIBRARY)(_waitpid.o): _waitpid.c $(LIBRARY)(_write.o): _write.c $(CC1) _write.c + +$(LIBRARY)(gettimeofday.o): gettimeofday.c + $(CC1) gettimeofday.c + +$(LIBRARY)(lstat.o): lstat.c + $(CC1) lstat.c + +$(LIBRARY)(symlink.o): symlink.c + $(CC1) symlink.c + diff --git a/lib/posix/gettimeofday.c b/lib/posix/gettimeofday.c new file mode 100644 index 000000000..6ec563604 --- /dev/null +++ b/lib/posix/gettimeofday.c @@ -0,0 +1,18 @@ +/* +gettimeofday.c +*/ + +#include +#include + +int gettimeofday(struct timeval *_RESTRICT tp, void *_RESTRICT tzp) +{ + if (time(&tp->tv_sec) == (time_t)-1) + return -1; + tp->tv_usec= 0; + + /* tzp has to be a nul pointer according to the standard. Otherwise + * behavior is undefined. We can just ignore tzp. + */ + return 0; +} diff --git a/lib/posix/lstat.c b/lib/posix/lstat.c new file mode 100644 index 000000000..b96fa6fff --- /dev/null +++ b/lib/posix/lstat.c @@ -0,0 +1,13 @@ +/* +lstat.c +*/ + +#define stat _stat + +#include + +int lstat(const char *path, struct stat *sb) +{ + /* Without symlinks, lstat is equal to stat */ + return stat(path, sb); +} diff --git a/lib/posix/symlink.c b/lib/posix/symlink.c new file mode 100644 index 000000000..3e918fe08 --- /dev/null +++ b/lib/posix/symlink.c @@ -0,0 +1,12 @@ +/* +symlink.c +*/ + +#include +#include + +int symlink(const char *path1, const char *path2) +{ + errno= ENOSYS; + return -1; +}