diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-06-28 11:18:01 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-06-28 11:18:01 -0700 |
commit | ef12fb6c3a1f94b620fc71362d42d7e207fe10d6 (patch) | |
tree | 1e2eef2cdd2cb547472ad5b97dab2b09a4456bc2 | |
parent | 4f6ffd478f167cc41f52c2932f4c82e3badea36f (diff) | |
parent | 906e64878935b1bda0dc92852af78bdc271918f5 (diff) |
Merge pull request #1328 from amatus/push-upstream
Fixes for GNUnet compile.
-rw-r--r-- | src/library.js | 17 | ||||
-rw-r--r-- | system/include/libc/grp.h | 2 | ||||
-rw-r--r-- | system/include/libc/sys/signal.h | 1 | ||||
-rw-r--r-- | system/include/libc/sys/stat.h | 42 | ||||
-rw-r--r-- | system/include/libc/time.h | 3 | ||||
-rw-r--r-- | system/include/net/netinet/in.h | 90 | ||||
-rw-r--r-- | system/include/sys/socket.h | 2 |
7 files changed, 151 insertions, 6 deletions
diff --git a/src/library.js b/src/library.js index 01a67804..822f4319 100644 --- a/src/library.js +++ b/src/library.js @@ -7224,6 +7224,23 @@ LibraryManager.library = { return 1; }, + // netinet/in.h + + _in6addr_any: + 'allocate([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], "i8", ALLOC_STATIC)', + _in6addr_loopback: + 'allocate([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1], "i8", ALLOC_STATIC)', + _in6addr_linklocal_allnodes: + 'allocate([255,2,0,0,0,0,0,0,0,0,0,0,0,0,0,1], "i8", ALLOC_STATIC)', + _in6addr_linklocal_allrouters: + 'allocate([255,2,0,0,0,0,0,0,0,0,0,0,0,0,0,2], "i8", ALLOC_STATIC)', + _in6addr_interfacelocal_allnodes: + 'allocate([255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1], "i8", ALLOC_STATIC)', + _in6addr_interfacelocal_allrouters: + 'allocate([255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,2], "i8", ALLOC_STATIC)', + _in6addr_sitelocal_allrouters: + 'allocate([255,5,0,0,0,0,0,0,0,0,0,0,0,0,0,2], "i8", ALLOC_STATIC)', + // ========================================================================== // netdb.h // ========================================================================== diff --git a/system/include/libc/grp.h b/system/include/libc/grp.h index 1273e395..61a1b2c7 100644 --- a/system/include/libc/grp.h +++ b/system/include/libc/grp.h @@ -82,9 +82,9 @@ void setgrfile (const char *); char *group_from_gid (gid_t, int); int setgroupent (int); #endif /* !__CYGWIN__ */ -int initgroups (const char *, gid_t); #endif /* !_XOPEN_SOURCE */ #endif /* !_POSIX_SOURCE */ +int initgroups (const char *, gid_t); #endif /* !__INSIDE_CYGWIN__ */ #ifdef __cplusplus diff --git a/system/include/libc/sys/signal.h b/system/include/libc/sys/signal.h index 910ccf78..49a94d80 100644 --- a/system/include/libc/sys/signal.h +++ b/system/include/libc/sys/signal.h @@ -73,6 +73,7 @@ typedef struct { /* three arguments instead of one. */ #define SA_NODEFER 4 /* XXX Emscripten */ #define SA_RESETHAND 8 /* XXX Emscripten */ +#define SA_RESTART 16 /* XXX Emscripten */ /* struct sigaction notes from POSIX: * diff --git a/system/include/libc/sys/stat.h b/system/include/libc/sys/stat.h index b31dc079..e2b20187 100644 --- a/system/include/libc/sys/stat.h +++ b/system/include/libc/sys/stat.h @@ -58,6 +58,42 @@ struct stat #endif }; +struct stat64 +{ + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; +#if defined(__rtems__) + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + blksize_t st_blksize; + blkcnt_t st_blocks; +#else + /* SysV/sco doesn't have the rest... But Solaris, eabi does. */ +#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__) + time_t st_atime; + time_t st_mtime; + time_t st_ctime; +#else + time_t st_atime; + long st_spare1; + time_t st_mtime; + long st_spare2; + time_t st_ctime; + long st_spare3; + long st_blksize; + long st_blocks; + long st_spare4[2]; +#endif +#endif +}; + #if defined(__rtems__) #define st_atime st_atim.tv_sec #define st_ctime st_ctim.tv_sec @@ -145,16 +181,16 @@ struct stat int _EXFUN(chmod,( const char *__path, mode_t __mode )); int _EXFUN(fchmod,(int __fd, mode_t __mode)); int _EXFUN(fstat,( int __fd, struct stat *__sbuf )); -int _EXFUN(fstat64,( int __fd, struct stat *__sbuf )); /* XXX Emscripten */ +int _EXFUN(fstat64,( int __fd, struct stat64 *__sbuf )); /* XXX Emscripten */ int _EXFUN(mkdir,( const char *_path, mode_t __mode )); int _EXFUN(mkfifo,( const char *__path, mode_t __mode )); int _EXFUN(stat,( const char *__path, struct stat *__sbuf )); -int _EXFUN(stat64,( const char *__path, struct stat *__sbuf )); /* XXX Emscripten */ +int _EXFUN(stat64,( const char *__path, struct stat64 *__sbuf )); /* XXX Emscripten */ mode_t _EXFUN(umask,( mode_t __mask )); #if defined(EMSCRIPTEN) || defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__) int _EXFUN(lstat,( const char *__path, struct stat *__buf )); -int _EXFUN(lstat64,( const char *__path, struct stat *__buf )); /* XXX Emscripten */ +int _EXFUN(lstat64,( const char *__path, struct stat64 *__buf )); /* XXX Emscripten */ int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev )); #endif diff --git a/system/include/libc/time.h b/system/include/libc/time.h index 83993942..2548d6be 100644 --- a/system/include/libc/time.h +++ b/system/include/libc/time.h @@ -126,6 +126,9 @@ extern __IMPORT char *_tzname[2]; #ifndef tzname #define tzname _tzname #endif +#ifndef timezone +#define timezone _timezone +#endif #endif /* !__STRICT_ANSI__ */ #ifdef __cplusplus diff --git a/system/include/net/netinet/in.h b/system/include/net/netinet/in.h index 569a56b0..f4832d52 100644 --- a/system/include/net/netinet/in.h +++ b/system/include/net/netinet/in.h @@ -7,6 +7,7 @@ extern "C" { #endif #include <arpa/inet.h> +#include <stdint.h> enum { IPPROTO_IP = 0, @@ -19,8 +20,10 @@ enum { }; #define INET_ADDRSTRLEN 16 +#define INET6_ADDRSTRLEN 46 #define INADDR_ANY 0 +#define INADDR_LOOPBACK 0x7f000001 /* 127.0.0.1 */ struct in_addr { unsigned long s_addr; @@ -34,9 +37,24 @@ struct sockaddr_in { }; struct in6_addr { - unsigned char s6_addr[16]; + union { + uint8_t _s6_addr8[16]; + uint16_t _s6_addr16[8]; + uint32_t _s6_addr32[4]; + } _u; +#define s6_addr _u._s6_addr8 +#define s6_addr16 _u._s6_addr16 +#define s6_addr32 _u._s6_addr32 }; +extern const struct in6_addr in6addr_any; +extern const struct in6_addr in6addr_loopback; +extern const struct in6_addr in6addr_linklocal_allnodes; +extern const struct in6_addr in6addr_linklocal_allrouters; +extern const struct in6_addr in6addr_interfacelocal_allnodes; +extern const struct in6_addr in6addr_interfacelocal_allrouters; +extern const struct in6_addr in6addr_sitelocal_allrouters; + struct sockaddr_in6 { short sin6_family; short sin6_port; @@ -70,6 +88,76 @@ struct ip_mreq { #define IP_MULTICAST_ALL 49 #define IP_UNICAST_IF 50 +/* + * Tests for IPv6 address types + */ + +#define IN6_IS_ADDR_LINKLOCAL(addr) \ + (((addr)->s6_addr32[0] & htonl(0xffc00000)) == htonl(0xfe800000)) + +#define IN6_IS_ADDR_LOOPBACK(addr) \ + (((addr)->s6_addr32[0] == 0) && ((addr)->s6_addr32[1] == 0) && \ + ((addr)->s6_addr32[2] == 0) && ((addr)->s6_addr32[3] == htonl(1))) + +#define IN6_IS_ADDR_MULTICAST(addr) \ + ((addr)->s6_addr8[0] == 0xff) + +#define IN6_IS_ADDR_SITELOCAL(addr) \ + (((addr)->s6_addr32[0] & htonl(0xffc00000)) == htonl(0xfec00000)) + +#define IN6_IS_ADDR_UNSPECIFIED(addr) \ + (((addr)->s6_addr32[0] == 0) && ((addr)->s6_addr32[1] == 0) && \ + ((addr)->s6_addr32[2] == 0) && ((addr)->s6_addr32[3] == 0)) + +#define IN6_IS_ADDR_V4COMPAT(addr) \ + (((addr)->s6_addr32[0] == 0) && ((addr)->s6_addr32[1] == 0) && \ + ((addr)->s6_addr32[2] == 0) && ((addr)->s6_addr32[3] & ~htonl(1))) + +#define IN6_IS_ADDR_V4MAPPED(addr) \ + (((addr)->s6_addr32[0] == 0) && ((addr)->s6_addr32[1] == 0) && \ + ((addr)->s6_addr32[2] == htonl(0xffff))) + +#define IN6_ARE_ADDR_EQUAL(addr1, addr2) \ + (((addr1)->s6_addr32[0] == (addr2)->s6_addr32[0]) && \ + ((addr1)->s6_addr32[1] == (addr2)->s6_addr32[1]) && \ + ((addr1)->s6_addr32[2] == (addr2)->s6_addr32[2]) && \ + ((addr1)->s6_addr32[3] == (addr2)->s6_addr32[3])) + +/* + * IPv6 Multicast scoping. The scope is stored + * in the bottom 4 bits of the second byte of the + * multicast address. + */ + /* 0x0 */ /* reserved */ +#define IN6_NODE_LOCAL 0x1 /* node-local scope */ +#define IN6_LINK_LOCAL 0x2 /* link-local scope */ + /* 0x3 */ /* (unassigned) */ + /* 0x4 */ /* (unassigned) */ +#define IN6_SITE_LOCAL 0x5 /* site-local scope */ + /* 0x6 */ /* (unassigned) */ + /* 0x7 */ /* (unassigned) */ +#define IN6_ORG_LOCAL 0x8 /* organization-local scope */ + /* 0x9 */ /* (unassigned) */ + /* 0xA */ /* (unassigned) */ + /* 0xB */ /* (unassigned) */ + /* 0xC */ /* (unassigned) */ + /* 0xD */ /* (unassigned) */ +#define IN6_GLOBAL 0xE /* global scope */ + /* 0xF */ /* reserved */ + +#define IN6_MSCOPE(addr) ((addr)->s6_addr8[1] & 0x0f) + +#define IN6_IS_ADDR_MC_NODELOCAL(addr) \ + (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_NODE_LOCAL)) +#define IN6_IS_ADDR_MC_LINKLOCAL(addr) \ + (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_LINK_LOCAL)) +#define IN6_IS_ADDR_MC_SITELOCAL(addr) \ + (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_SITE_LOCAL)) +#define IN6_IS_ADDR_MC_ORGLOCAL(addr) \ + (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_ORG_LOCAL)) +#define IN6_IS_ADDR_MC_GLOBAL(addr) \ + (IN6_IS_ADDR_MULTICAST(addr) && (IN6_MSCOPE(addr) == IN6_GLOBAL)) + #ifdef __cplusplus } #endif diff --git a/system/include/sys/socket.h b/system/include/sys/socket.h index b83ce89a..3168f85b 100644 --- a/system/include/sys/socket.h +++ b/system/include/sys/socket.h @@ -38,7 +38,7 @@ extern "C" { #define SHUT_RDWR 2 typedef unsigned int sa_family_t; -#define AF_INET 1 +#define AF_INET PF_INET #define AF_INET6 6 #define PF_INET6 AF_INET6 |