From: Philip Homburg Date: Mon, 11 Jul 2005 13:00:43 +0000 (+0000) Subject: Many changes to simplify porting applications. X-Git-Tag: v3.1.0~632 X-Git-Url: http://zhaoyanbai.com/repos/doc/tz-art.htm?a=commitdiff_plain;h=11cbb6faae3821c680728b16435d860e9c45858f;p=minix.git Many changes to simplify porting applications. --- diff --git a/include/arpa/inet.h b/include/arpa/inet.h index 99516d72a..f42508f45 100644 --- a/include/arpa/inet.h +++ b/include/arpa/inet.h @@ -6,6 +6,17 @@ arpa/inet.h #define _ARPA__INET_H /* Open Group Base Specifications Issue 6 (not complete): */ + +#ifndef _STRUCT_IN_ADDR +#define _STRUCT_IN_ADDR +/* Has to match corresponding declaration in */ +struct in_addr +{ + in_addr_t s_addr; +}; +#endif + + char *inet_ntoa(struct in_addr in); #endif /* _ARPA__INET_H */ diff --git a/include/errno.h b/include/errno.h index 332bde28b..95b30969c 100755 --- a/include/errno.h +++ b/include/errno.h @@ -94,6 +94,9 @@ extern int errno; /* place where the error numbers go */ #define ENOCONN (_SIGN 66) /* no such connection */ #define EAFNOSUPPORT (_SIGN 67) /* address family not supported */ #define EPROTONOSUPPORT (_SIGN 68) /* protocol not supported by AF */ +#define EPROTOTYPE (_SIGN 69) /* Protocol wrong type for socket */ +#define EINPROGRESS (_SIGN 70) /* Operation now in progress */ +#define EADDRNOTAVAIL (_SIGN 71) /* Can't assign requested address */ /* The following are not POSIX errors, but they can still happen. * All of these are generated by the kernel and relate to message passing. diff --git a/include/math.h b/include/math.h index 48d16aa1f..1ea4b47aa 100755 --- a/include/math.h +++ b/include/math.h @@ -36,4 +36,8 @@ _PROTOTYPE( double sqrt, (double _x) ); _PROTOTYPE( double tan, (double _x) ); _PROTOTYPE( double tanh, (double _x) ); +#ifdef _POSIX_SOURCE /* STD-C? */ +#include +#endif + #endif /* _MATH_H */ diff --git a/include/minix/config.h b/include/minix/config.h index a43189a2b..94b244111 100755 --- a/include/minix/config.h +++ b/include/minix/config.h @@ -22,7 +22,6 @@ #define SUN_4 40 /* any Sun SPARC-based system */ #define SUN_4_60 40 /* Sun-4/60 (aka SparcStation 1 or Campus) */ #define ATARI 60 /* ATARI ST/STe/TT (68000/68030) */ -#define AMIGA 61 /* Commodore Amiga (68000) */ #define MACINTOSH 62 /* Apple Macintosh (68000) */ /* Word size in bytes (a constant equal to sizeof(int)). */ @@ -160,7 +159,7 @@ #define CHIP INTEL #endif -#if (MACHINE == ATARI) || (MACHINE == AMIGA) || (MACHINE == MACINTOSH) +#if (MACHINE == ATARI) || (MACHINE == MACINTOSH) #define CHIP M68000 #endif diff --git a/include/net/if.h b/include/net/if.h new file mode 100644 index 000000000..e49449acf --- /dev/null +++ b/include/net/if.h @@ -0,0 +1,3 @@ +/* +net/if.h +*/ diff --git a/include/netinet/in.h b/include/netinet/in.h index 11e33bde9..a1586e165 100644 --- a/include/netinet/in.h +++ b/include/netinet/in.h @@ -11,11 +11,47 @@ netinet/in.h #include /* Open Group Base Specifications Issue 6 (not complete) */ -typedef uint32_t in_addr_t; +#define INADDR_ANY (uint32_t)0x00000000 +typedef uint16_t in_port_t; + +#ifndef _IN_ADDR_T +#define _IN_ADDR_T +typedef uint32_t in_addr_t; +#endif /* _IN_ADDR_T */ + +#ifndef _SA_FAMILY_T +#define _SA_FAMILY_T +/* Should match corresponding typedef in */ +typedef uint8_t sa_family_t; +#endif /* _SA_FAMILY_T */ + +/* Protocols */ +#define IPPROTO_IP 0 /* Dummy protocol */ + +/* setsockopt options at IP level */ +#define IP_ADD_MEMBERSHIP 12 +#define IP_DROP_MEMBERSHIP 13 + +#ifndef _STRUCT_IN_ADDR +#define _STRUCT_IN_ADDR struct in_addr { in_addr_t s_addr; }; +#endif + +struct sockaddr_in +{ + sa_family_t sin_family; + in_port_t sin_port; + struct in_addr sin_addr; +}; + +struct ip_mreq +{ + struct in_addr imr_multiaddr; + struct in_addr imr_interface; +}; #endif /* _NETINET__IN_H */ diff --git a/include/netinet/tcp.h b/include/netinet/tcp.h new file mode 100644 index 000000000..e69de29bb diff --git a/include/stdlib.h b/include/stdlib.h index 2e42cc1a5..827a69164 100755 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -64,11 +64,21 @@ _PROTOTYPE( unsigned long int strtoul, (const char *_nptr, char **_endptr, int _base) ); #ifdef _POSIX_SOURCE +/* Open Group Base Specifications Issue 6 */ _PROTOTYPE( int mkstemp, (char *_fmt) ); +_PROTOTYPE( char *initstate, (unsigned _seed, char *_state, + size_t _size) ); +_PROTOTYPE( long random, (void) ); +_PROTOTYPE( char *setstate, (const char *state) ); +_PROTOTYPE( void srandom, (unsigned seed) ); #endif #ifdef _MINIX _PROTOTYPE( int putenv, (const char *_name) ); + +/* According to POSIX, getopt should be in unistd.h. What do we do with + * this? + */ _PROTOTYPE(int getopt, (int _argc, char **_argv, char *_opts)); extern char *optarg; extern int optind, opterr, optopt; diff --git a/include/string.h b/include/string.h index bd93957d2..5594922b2 100755 --- a/include/string.h +++ b/include/string.h @@ -40,6 +40,11 @@ _PROTOTYPE( char *strstr, (const char *_s1, const char *_s2) ); _PROTOTYPE( char *strtok, (char *_s1, const char *_s2) ); _PROTOTYPE( size_t strxfrm, (char *_s1, const char *_s2, size_t _n) ); +#ifdef _POSIX_SOURCE +/* Open Group Base Specifications Issue 6 (not complete) */ + char *strdup(const char *_s1); +#endif + #ifdef _MINIX /* For backward compatibility. */ _PROTOTYPE( char *index, (const char *_s, int _charwanted) ); @@ -49,6 +54,7 @@ _PROTOTYPE( int bcmp, (const void *_s1, const void *_s2, size_t _length)); _PROTOTYPE( void bzero, (void *_dst, size_t _length) ); _PROTOTYPE( void *memccpy, (char *_dst, const char *_src, int _ucharstop, size_t _size) ); + /* Misc. extra functions */ _PROTOTYPE( int strcasecmp, (const char *_s1, const char *_s2) ); _PROTOTYPE( int strncasecmp, (const char *_s1, const char *_s2, diff --git a/include/sys/ioc_file.h b/include/sys/ioc_file.h new file mode 100755 index 000000000..735bfe726 --- /dev/null +++ b/include/sys/ioc_file.h @@ -0,0 +1,11 @@ +/* sys/ioc_file.h - File ioctl() command codes. + */ + +#ifndef _SYS_IOC_FILE_H +#define _SYS_IOC_FILE_H + +#include + +#define FIONREAD _IOR('f', 1, int) + +#endif /* _SYS_IOC_FILE_H */ diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h index f49b88236..2cfb735d8 100755 --- a/include/sys/ioctl.h +++ b/include/sys/ioctl.h @@ -16,6 +16,7 @@ #include /* 'T' 't' 'k' */ #include /* 'n' */ #include /* 'd' */ +#include /* 'f' */ #include /* 'm' */ #include /* 'M' */ #include /* 'S' */ diff --git a/include/sys/param.h b/include/sys/param.h new file mode 100644 index 000000000..0ef24f643 --- /dev/null +++ b/include/sys/param.h @@ -0,0 +1,7 @@ +/* +sys/param.h +*/ + +/* Do we need this header file? Maybe an empty one is sufficient to avoid + * compilations errors. + */ diff --git a/include/sys/select.h b/include/sys/select.h index a27ac59f5..67c1eb99e 100755 --- a/include/sys/select.h +++ b/include/sys/select.h @@ -8,10 +8,10 @@ #include /* Use this datatype as basic storage unit in fd_set */ -typedef u32_t _fdsetword; +typedef u32_t fd_mask; /* This many bits fit in an fd_set word. */ -#define _FDSETBITSPERWORD (sizeof(_fdsetword)*8) +#define _FDSETBITSPERWORD (sizeof(fd_mask)*8) /* Bit manipulation macros */ #define _FD_BITMASK(b) (1L << ((b) % _FDSETBITSPERWORD)) @@ -26,7 +26,7 @@ typedef u32_t _fdsetword; #define _FDSETWORDS ((FD_SETSIZE+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD) typedef struct { - _fdsetword _fdsetval[_FDSETWORDS]; + fd_mask fds_bits[_FDSETWORDS]; } fd_set; _PROTOTYPE( int select, (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) ); diff --git a/include/sys/socket.h b/include/sys/socket.h index e2c642e9c..6aaada3ac 100644 --- a/include/sys/socket.h +++ b/include/sys/socket.h @@ -2,5 +2,66 @@ sys/socket.h */ +#ifndef SYS_SOCKET_H +#define SYS_SOCKET_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) */ #include + +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 + +#define SOL_SOCKET 0xFFFF + +#define SO_REUSEADDR 0x0004 +#define SO_KEEPALIVE 0x0008 + +/* The how argument to shutdown */ +#define SHUT_RD 0 /* No further reads */ +#define SHUT_WR 1 /* No further writes */ +#define SHUT_RDWR 2 /* No further reads and writes */ + +#ifndef _SA_FAMILY_T +#define _SA_FAMILY_T +typedef uint8_t sa_family_t; +#endif /* _SA_FAMILY_T */ + +typedef int32_t socklen_t; + +struct sockaddr +{ + sa_family_t sa_family; + char sa_data[1]; +}; + +_PROTOTYPE( int accept, (int _socket, + struct sockaddr *_RESTRICT _address, + socklen_t *_RESTRICT _address_len) ); +_PROTOTYPE( int bind, (int _socket, const struct sockaddr *_address, + socklen_t _address_len) ); +_PROTOTYPE( int connect, (int _socket, const struct sockaddr *_address, + socklen_t _address_len) ); +_PROTOTYPE( int getpeername, (int _socket, + struct sockaddr *_RESTRICT _address, + socklen_t *_RESTRICT _address_len) ); +_PROTOTYPE( int getsockname, (int _socket, + struct sockaddr *_RESTRICT _address, + socklen_t *_RESTRICT _address_len) ); +_PROTOTYPE( int setsockopt,(int _socket, int _level, int _option_name, + const void *_option_value, socklen_t _option_len) ); +_PROTOTYPE( int listen, (int _socket, int _backlog) ); +_PROTOTYPE( ssize_t recvfrom, (int _socket, void *_RESTRICT _buffer, + size_t _length, int _flags, struct sockaddr *_RESTRICT _address, + socklen_t *_RESTRICT _address_len) ); +_PROTOTYPE( ssize_t sendto, (int _socket, const void *_message, + size_t _length, int _flags, const struct sockaddr *_dest_addr, + socklen_t _dest_len) ); +_PROTOTYPE( int shutdown, (int _socket, int _how) ); +_PROTOTYPE( int socket, (int _domain, int _type, int _protocol) ); + +#endif /* SYS_SOCKET_H */ diff --git a/include/sys/uio.h b/include/sys/uio.h new file mode 100644 index 000000000..d4dba19a3 --- /dev/null +++ b/include/sys/uio.h @@ -0,0 +1,23 @@ +/* +sys/uio.h + +definitions for vector I/O operations +*/ + +#ifndef _SYS_UIO_H +#define _SYS_UIO_H + +/* Open Group Base Specifications Issue 6 (not complete) */ + +struct iovec +{ + void *iov_base; + size_t iov_len; +}; + +_PROTOTYPE(ssize_t readv, (int _fildes, const struct iovec *_iov, + int _iovcnt) ); +_PROTOTYPE(ssize_t writev, (int _fildes, const struct iovec *_iov, + int iovcnt) ); + +#endif /* _SYS_UIO_H */ diff --git a/include/sys/un.h b/include/sys/un.h new file mode 100644 index 000000000..5a38e3ce8 --- /dev/null +++ b/include/sys/un.h @@ -0,0 +1,19 @@ +/* +sys/un.h +*/ + +/* Open Group Base Specifications Issue 6 */ + +#ifndef SA_FAMILY_T +#define SA_FAMILY_T +/* Should match corresponding typedef in */ +typedef uint8_t sa_family_t; +#endif /* SA_FAMILY_T */ + +struct sockaddr_un +{ + sa_family_t sun_family; + char sun_path[127]; +}; + +/* Note: UNIX domain sockets are not implemented! */ diff --git a/include/unistd.h b/include/unistd.h index d23249c0b..aca86a3ad 100755 --- a/include/unistd.h +++ b/include/unistd.h @@ -133,6 +133,10 @@ _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) ); +_PROTOTYPE( int getopt, (int _argc, char **_argv, char *_opts) ); +extern char *optarg; +extern int optind, opterr, optopt; +_PROTOTYPE( int usleep, (useconds_t _useconds) ); #ifdef _MINIX #ifndef _TYPE_H