diff options
author | pquerna <pquerna@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-08 21:08:22 +0000 |
---|---|---|
committer | pquerna <pquerna@13f79535-47bb-0310-9956-ffa450edef68> | 2009-03-08 21:08:22 +0000 |
commit | 6b03473134beac1769b52eeac9aadcb02ef3afcd (patch) | |
tree | 5333de4d99f6b618184db74309921ccef8833c97 | |
parent | c3eb6421426de455c2755450bcb8a3fa70c3d884 (diff) | |
download | libapr-6b03473134beac1769b52eeac9aadcb02ef3afcd.tar.gz |
Scons Updates.
* Add detection of IPv6
* Fix return code checking of TryRun's... Scons expects 1 as success (meh)
* Add ebcdic, nonblock inherited check, tcp_nodelay, union semun,
TCP_CORK/TCP_NOPUSH, getrlimit/setrlimit, in_addr, sockaddr_storage,
rlimit struct, ... and more
* Add sctp check
* Add accept filter check
Submitted by: Ryan Phillips
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@751531 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | SConstruct | 1 | ||||
-rw-r--r-- | build/aprconf.py | 225 | ||||
-rw-r--r-- | build/aprenv.py | 149 |
3 files changed, 362 insertions, 13 deletions
diff --git a/SConstruct b/SConstruct index 0f914ef5f..774d10188 100644 --- a/SConstruct +++ b/SConstruct @@ -10,6 +10,7 @@ vars = Variables('build.py') vars.Add('maintainer_mode', 'Turn on debugging and compile time warnings', 0) vars.Add('profile', 'Turn on profiling for the build (GCC)', 0) vars.Add('lfs', 'Large file support on 32-bit platforms', 1) +vars.Add('ipv6', 'IPv6 support', 1) vars.Add(EnumVariable('pool_debug', 'Turn on pools debugging', 'no', allowed_values=('yes', 'no', 'verbose', 'verbose-alloc', 'lifetime', 'owner', 'all'))) diff --git a/build/aprconf.py b/build/aprconf.py index 1c55f8eb6..a66a6696d 100644 --- a/build/aprconf.py +++ b/build/aprconf.py @@ -70,8 +70,118 @@ int main() } """ result = context.TryRun(source, '.c') + context.Result(result[0] == 0) + return result[0] == 0 + + def Check_apr_ebcdic(self, context): + context.Message('Checking whether system uses EBCDIC.. ') + source = """ +int main(void) { + return (unsigned char)'A' != (unsigned char)0xC1; +}""" + result = context.TryRun(source, '.c') context.Result(result[0]) return result[0] + + def Check_apr_nonblock_inherited(self, context): + context.Message('Checking whether O_NONBLOCK setting is inherited from listening sockets... ') + source = """ +#include <stdio.h> +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif +#ifdef HAVE_NETINET_IN_H +#include <netinet/in.h> +#endif +#ifdef HAVE_NETINET_TCP_H +#include <netinet/tcp.h> +#endif +#ifndef HAVE_SOCKLEN_T +typedef int socklen_t; +#endif +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif +int main(void) { + int listen_s, connected_s, client_s; + int listen_port, rc; + struct sockaddr_in sa; + socklen_t sa_len; + + listen_s = socket(AF_INET, SOCK_STREAM, 0); + if (listen_s < 0) { + perror("socket"); + exit(1); + } + memset(&sa, 0, sizeof sa); + sa.sin_family = AF_INET; +#ifdef BEOS + sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); +#endif + /* leave port 0 to get ephemeral */ + rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa); + if (rc < 0) { + perror("bind for ephemeral port"); + exit(1); + } + /* find ephemeral port */ + sa_len = sizeof(sa); + rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len); + if (rc < 0) { + perror("getsockname"); + exit(1); + } + listen_port = sa.sin_port; + rc = listen(listen_s, 5); + if (rc < 0) { + perror("listen"); + exit(1); + } + rc = fcntl(listen_s, F_SETFL, O_NONBLOCK); + if (rc < 0) { + perror("fcntl(F_SETFL)"); + exit(1); + } + client_s = socket(AF_INET, SOCK_STREAM, 0); + if (client_s < 0) { + perror("socket"); + exit(1); + } + memset(&sa, 0, sizeof sa); + sa.sin_family = AF_INET; + sa.sin_port = listen_port; +#ifdef BEOS + sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); +#endif + /* leave sin_addr all zeros to use loopback */ + rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa); + if (rc < 0) { + perror("connect"); + exit(1); + } + sa_len = sizeof sa; + connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len); + if (connected_s < 0) { + perror("accept"); + exit(1); + } + rc = fcntl(connected_s, F_GETFL, 0); + if (rc < 0) { + perror("fcntl(F_GETFL)"); + exit(1); + } + if (!(rc & O_NONBLOCK)) { + fprintf(stderr, "O_NONBLOCK is not set in the child.\n"); + exit(1); + } + return 0; +}""" + result = context.TryRun(source, '.c') + context.Result(result[0] == 0) + return result[0] == 0 def Check_apr_largefile64(self, context): context.Message('Checking whether to enable -D_LARGEFILE64_SOURCE... ') @@ -112,8 +222,8 @@ void main(void) }""" result = context.TryRun(source, '.c') self.env.Filter(CPPFLAGS = ['-D_LARGEFILE64_SOURCE']) - context.Result(result[0]) - return result[0] + context.Result(result[0] == 0) + return result[0] == 0 def Check_apr_mmap_mapping_dev_zero(self, context): @@ -142,8 +252,8 @@ void main(void) } """ result = context.TryRun(source, '.c') - context.Result(result[0]) - return result[0] + context.Result(result[0] == 0) + return result[0] == 0 def Check_apr_semaphores(self, context): context.Message('Checking for sem_open, sem_close, sem_unlink... ') @@ -178,6 +288,113 @@ main() context.Result(result) return result + def Check_apr_check_tcp_nodelay_inherited(self, context): + context.Message('Checking for tcp nodelay inherited... ') + source = """ +#include <stdio.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <netinet/tcp.h> +int main(void) { + int listen_s, connected_s, client_s; + int listen_port, rc; + struct sockaddr_in sa; + socklen_t sa_len; + socklen_t option_len; + int option; + + listen_s = socket(AF_INET, SOCK_STREAM, 0); + if (listen_s < 0) { + perror("socket"); + exit(1); + } + option = 1; + rc = setsockopt(listen_s, IPPROTO_TCP, TCP_NODELAY, &option, sizeof option); + if (rc < 0) { + perror("setsockopt TCP_NODELAY"); + exit(1); + } + memset(&sa, 0, sizeof sa); + sa.sin_family = AF_INET; +#ifdef BEOS + sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); +#endif + /* leave port 0 to get ephemeral */ + rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa); + if (rc < 0) { + perror("bind for ephemeral port"); + exit(1); + } + /* find ephemeral port */ + sa_len = sizeof(sa); + rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len); + if (rc < 0) { + perror("getsockname"); + exit(1); + } + listen_port = sa.sin_port; + rc = listen(listen_s, 5); + if (rc < 0) { + perror("listen"); + exit(1); + } + client_s = socket(AF_INET, SOCK_STREAM, 0); + if (client_s < 0) { + perror("socket"); + exit(1); + } + memset(&sa, 0, sizeof sa); + sa.sin_family = AF_INET; + sa.sin_port = listen_port; +#ifdef BEOS + sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); +#endif + /* leave sin_addr all zeros to use loopback */ + rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa); + if (rc < 0) { + perror("connect"); + exit(1); + } + sa_len = sizeof sa; + connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len); + if (connected_s < 0) { + perror("accept"); + exit(1); + } + option_len = sizeof option; + rc = getsockopt(connected_s, IPPROTO_TCP, TCP_NODELAY, &option, &option_len); + if (rc < 0) { + perror("getsockopt"); + exit(1); + } + if (!option) { + fprintf(stderr, "TCP_NODELAY is not set in the child.\n"); + exit(1); + } + return 0; +} """ + result = context.TryRun(source, '.c') + context.Result(result[0] == 0) + return result[0] == 0 + + def Check_apr_semun(self, context): + context.Message('Checking for semun... ') + source = """ +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/sem.h> +main() +{ + union semun arg; + semctl(0, 0, 0, arg); + exit(0); +} + """ + result = context.TryCompile(source, '.c') + context.Result(result) + return result + def CheckFile(self, filename): return os.path.exists(filename) diff --git a/build/aprenv.py b/build/aprenv.py index 65011611e..b57043ad5 100644 --- a/build/aprenv.py +++ b/build/aprenv.py @@ -146,6 +146,14 @@ class APREnv(Environment): self.autoconf.Check_apr_mmap_mapping_dev_zero, 'Check_apr_semaphores': self.autoconf.Check_apr_semaphores, + 'Check_apr_semun': + self.autoconf.Check_apr_semun, + 'Check_apr_check_tcp_nodelay_inherited': + self.autoconf.Check_apr_check_tcp_nodelay_inherited, + 'Check_apr_nonblock_inherited': + self.autoconf.Check_apr_nonblock_inherited, + 'Check_apr_ebcdic': + self.autoconf.Check_apr_ebcdic, }, config_h = 'include/arch/%s/apr_private.h' % (self['APR_PLATFORM'])) @@ -227,7 +235,6 @@ class APREnv(Environment): else: subst['@%s@' % (s)] = 0 - sizeof_char = conf.CheckTypeSize('char') sizeof_int = self.critical_value(conf.CheckTypeSize, 4, 'int') subst['@int_value@'] = 'int' @@ -416,25 +423,149 @@ class APREnv(Environment): if mmap_results['mmap'] and \ self.autoconf.CheckFile("/dev/zero") and \ conf.Check_apr_mmap_mapping_dev_zero(): - subst['@havemmapzero@'] = '1' + subst['@havemmapzero@'] = 1 else: - subst['@havemmapzero@'] = '0' + subst['@havemmapzero@'] = 0 # check for locking mechanisms if conf.Check_apr_semaphores(): - subst['@hassysvser@'] = "1" + subst['@hassysvser@'] = 1 else: - subst['@hassysvser@'] = "0" + subst['@hassysvser@'] = 0 if conf.CheckDeclaration('F_SETLK', '#include <fcntl.h>'): - subst['@hasfcntlser@'] = '1' + subst['@hasfcntlser@'] = 1 + else: + subst['@hasfcntlser@'] = 0 + + if conf.CheckFunc('flock'): + subst['@hasflockser@'] = 1 else: - subst['@hasfcntlser@'] = '0' + subst['@hasflockser@'] = 0 + + apr_tcp_nopush_flag="0" + if conf.CheckDeclaration('TCP_CORK', '#include <netinet/tcp.h>'): + subst['@have_corkable_tcp@'] = 1 + apr_tcp_nopush_flag="TCP_CORK" + else: + subst['@have_corkable_tcp@'] = 0 + + if conf.CheckDeclaration('TCP_NOPUSH', '#include <netinet/tcp.h>'): + subst['@apr_tcp_nopush_flag@'] = 3 + subst['@have_corkable_tcp@'] = 1 + + subst['@apr_tcp_nopush_flag@'] = apr_tcp_nopush_flag if conf.CheckFunc('flock'): - subst['@hasflockser@'] = "1" + subst['@hasflockser@'] = 1 + else: + subst['@hasflockser@'] = 0 + + if conf.CheckFunc('getrlimit'): + subst['@have_getrlimit@'] = 1 + else: + subst['@have_getrlimit@'] = 0 + + if conf.CheckFunc('setrlimit'): + subst['@have_setrlimit@'] = 1 + else: + subst['@have_setrlimit@'] = 0 + + if conf.CheckType('struct in_addr', includes='#include <netinet/in.h>'): + subst['@have_in_addr@'] = 1 + else: + subst['@have_in_addr@'] = 0 + + if conf.CheckType('struct sockaddr_storage', includes='#include <netinet/in.h>'): + subst['@have_sa_storage@'] = 1 + else: + subst['@have_sa_storage@'] = 0 + + if conf.CheckType('struct rlimit', includes='#include <sys/resource.h>'): + subst['@struct_rlimit@'] = 1 + else: + subst['@struct_rlimit@'] = 0 + + if conf.Check_apr_semun(): + subst['@have_union_semun@'] = 1 + else: + subst['@have_union_semun@'] = 0 + + check_functions = [ + 'inet_addr', + 'inet_network', + 'memmove', + 'sigaction', + 'sigsuspend', + 'sigwait', + 'strdup', + 'stricmp', + 'strcasecmp', + 'strncasecmp', + 'strnicmp', + 'strstr', + 'memchr', + 'iovec' + ] + + for func in check_functions: + if conf.CheckFunc(func): + subst['@have_%s@' % func] = 1 + else: + subst['@have_%s@' % func] = 0 + + # Set Features + # TODO: Not done yet + subst['@sharedmem@'] = 0 + subst['@threads@'] = 0 + subst['@sendfile@'] = 0 + subst['@mmap@'] = 0 + subst['@fork@'] = 0 + subst['@rand@'] = 0 + subst['@oc@'] = 0 + subst['@aprdso@'] = 0 + subst['@acceptfilter@'] = 0 + subst['@have_unicode_fs@'] = 0 + subst['@have_proc_invoked@'] = 0 + subst['@aprlfs@'] = 0 + subst['@osuuid@'] = 0 + subst['@file_as_socket@'] = 1 + + # check for IPv6 (the user is allowed to disable this via commandline + # options + if self['ipv6']: + if conf.CheckType('struct sockaddr_in6', + includes='#include <netinet/in.h>') and \ + conf.CheckFunc('getaddrinfo') and \ + conf.CheckFunc('getnameinfo'): + subst['@have_ipv6@'] = 1 + else: + subst['@have_ipv6@'] = 0 + + if conf.CheckDeclaration('IPPROTO_SCTP', '#include <netinet/in.h>'): + subst['@have_sctp@'] = 1 + else: + subst['@have_sctp@'] = 0 + + if conf.CheckDeclaration('SO_ACCEPTFILTER', '#include <sys/socket.h>'): + subst['@acceptfilter@'] = 1 + else: + subst['@acceptfilter@'] = 0 + + if conf.Check_apr_check_tcp_nodelay_inherited(): + subst['@tcp_nodelay_inherited@'] = 1 + else: + subst['@tcp_nodelay_inherited@'] = 0 + + if conf.Check_apr_nonblock_inherited(): + subst['@o_nonblock_inherited@'] = 1 + else: + subst['@o_nonblock_inherited@'] = 0 + + if conf.Check_apr_ebcdic(): + subst['@apr_charset_ebcdic@'] = 1 else: - subst['@hasflockser@'] = "0" + subst['@apr_charset_ebcdic@'] = 0 self.SubstFile('include/apr.h', 'include/apr.h.in', SUBST_DICT = subst) |