From: Greg Stein Date: Sat, 24 Feb 2001 11:23:31 +0000 (+0000) Subject: *) fix inline handling. we had: apr_inline, APR_INLINE, USE_GNU_INLINE, and X-Git-Tag: 2.0.12~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee3fe477e346992c61b09da34f2b16dfd3d7e1c0;p=apache *) fix inline handling. we had: apr_inline, APR_INLINE, USE_GNU_INLINE, and INLINE. Now, we just have APR_INLINE and APR_HAS_INLINE. - convert all usage - note that apr_general messed up the defn (compared to apr.h) - simplify the inline decision logic in os/*/os.h - simplify the code in os/*/os-inline.c *) toss ap_checkconv() [no longer used] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88298 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 8491a37626..712b019ee5 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -184,7 +184,7 @@ static char c_by_encoding, c_by_type, c_by_path; * matches ".." or "../"). Hopefully this one call is significantly less * expensive than multiple strcmp() calls. */ -static apr_inline int is_parent(const char *name) +static APR_INLINE int is_parent(const char *name) { /* * Now, IFF the first two bytes are dots, and the third byte is either diff --git a/modules/http/http_core.c b/modules/http/http_core.c index f9d306ff28..50c7e5e2e2 100644 --- a/modules/http/http_core.c +++ b/modules/http/http_core.c @@ -577,7 +577,7 @@ char *ap_response_code_string(request_rec *r, int error_index) /* Code from Harald Hanche-Olsen */ -static apr_inline void do_double_reverse (conn_rec *conn) +static APR_INLINE void do_double_reverse (conn_rec *conn) { apr_sockaddr_t *sa; apr_status_t rv; diff --git a/modules/mappers/mod_vhost_alias.c b/modules/mappers/mod_vhost_alias.c index cf93fb31b4..09994fb7a4 100644 --- a/modules/mappers/mod_vhost_alias.c +++ b/modules/mappers/mod_vhost_alias.c @@ -276,7 +276,7 @@ static const command_rec mva_commands[] = * This really wants to be a nested function * but C is too feeble to support them. */ -static apr_inline void vhost_alias_checkspace(request_rec *r, char *buf, +static APR_INLINE void vhost_alias_checkspace(request_rec *r, char *buf, char **pdest, int size) { /* XXX: what if size > HUGE_STRING_LEN? */ diff --git a/os/bs2000/os-inline.c b/os/bs2000/os-inline.c index 0fdf3b332d..c8299b58ac 100644 --- a/os/bs2000/os-inline.c +++ b/os/bs2000/os-inline.c @@ -62,28 +62,26 @@ * header file and a compilable module. * * Only inlineable functions should be defined in here. They must all - * include the INLINE modifier. + * include the APR_INLINE modifier. * * If the compiler supports inline, this file will be #included as a * header file from os.h to create all the inline function - * definitions. INLINE will be defined to whatever is required on + * definitions. APR_INLINE will be defined to whatever is required on * function definitions to make them inline declarations. * * If the compiler does not support inline, this file will be compiled * as a normal C file into libos.a (along with os.c). In this case - * INLINE will _not_ be set so we can use this to test if we are - * compiling this source file. + * APR_HAS_INLINE will be zero so we can use this to test if we are + * compiling this source file. */ -#ifndef INLINE -#define INLINE - -/* Anything required only when compiling */ -#include "ap_config.h" +#include "apr.h" +#if APR_HAS_INLINE +/* keep inlined functions private to the including file */ +static #endif - -INLINE int ap_os_is_path_absolute(const char *file) +APR_INLINE int ap_os_is_path_absolute(const char *file) { - return (file && file[0] == '/' ? 1 : 0); + return file[0] == '/'; } diff --git a/os/bs2000/os.c b/os/bs2000/os.c index 27d6c22ca9..63907a4393 100644 --- a/os/bs2000/os.c +++ b/os/bs2000/os.c @@ -62,46 +62,7 @@ */ #include "httpd.h" -#include "http_core.h" #include "os.h" -#include "httpd.h" - -/* Check the Content-Type to decide if conversion is needed */ -int ap_checkconv(struct request_rec *r) -{ - int convert_to_ascii; - const char *type; - - /* To make serving of "raw ASCII text" files easy (they serve faster - * since they don't have to be converted from EBCDIC), a new - * "magic" type prefix was invented: text/x-ascii-{plain,html,...} - * If we detect one of these content types here, we simply correct - * the type to the real text/{plain,html,...} type. Otherwise, we - * set a flag that translation is required later on. - */ - - type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type; - - /* If no content type is set then treat it as (ebcdic) text/plain */ - convert_to_ascii = (type == NULL); - - /* Conversion is applied to text/ files only, if ever. */ - if (type && (strncasecmp(type, "text/", 5) == 0 || - strncasecmp(type, "message/", 8) == 0)) { - if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX, - sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0) - r->content_type = apr_pstrcat(r->pool, "text/", - type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1, - NULL); - else - /* translate EBCDIC to ASCII */ - convert_to_ascii = 1; - } - /* Enable conversion if it's a text document */ - ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii); - - return convert_to_ascii; -} AP_DECLARE(apr_status_t) ap_os_create_privileged_process( const request_rec *r, diff --git a/os/bs2000/os.h b/os/bs2000/os.h index ce0f519052..d5be0ad7eb 100644 --- a/os/bs2000/os.h +++ b/os/bs2000/os.h @@ -61,24 +61,22 @@ #define PLATFORM "BS2000" +#include "apr.h" + /* * This file in included in all Apache source code. It contains definitions * of facilities available on _this_ operating system (HAVE_* macros), * and prototypes of OS specific functions defined in os.c or os-inline.c */ -#if !defined(INLINE) && defined(USE_GNU_INLINE) +#if APR_HAS_INLINE /* Compiler supports inline, so include the inlineable functions as * part of the header */ -#define INLINE extern apr_inline - -INLINE int ap_os_is_path_absolute(const char *file); #include "os-inline.c" -#endif -#ifndef INLINE +#else /* Compiler does not support inline, so prototype the inlineable functions * as normal */ @@ -98,10 +96,6 @@ typedef struct { extern int _rini(_rini_struct *); #endif /* !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) */ -/* Sorry if this is ugly, but the include order doesn't allow me - * to use request_rec here... */ -struct request_rec; -extern int ap_checkconv(struct request_rec *r); extern pid_t os_fork(const char *user); #endif /*! APACHE_OS_H*/ diff --git a/os/os2/os-inline.c b/os/os2/os-inline.c index 68d9a4035d..dfcf05cc00 100644 --- a/os/os2/os-inline.c +++ b/os/os2/os-inline.c @@ -62,33 +62,32 @@ * header file and a compilable module. * * Only inlineable functions should be defined in here. They must all - * include the INLINE modifier. + * include the APR_INLINE modifier. * * If the compiler supports inline, this file will be #included as a * header file from os.h to create all the inline function - * definitions. INLINE will be defined to whatever is required on + * definitions. APR_INLINE will be defined to whatever is required on * function definitions to make them inline declarations. * * If the compiler does not support inline, this file will be compiled * as a normal C file into libos.a (along with os.c). In this case - * INLINE will _not_ be set so we can use this to test if we are - * compiling this source file. + * APR_HAS_INLINE will be zero so we can use this to test if we are + * compiling this source file. */ -#ifndef INLINE -#define INLINE - -/* Anything required only when compiling */ -#include "ap_config.h" +#include "apr.h" +#if APR_HAS_INLINE +/* keep inlined functions private to the including file */ +static #endif - -INLINE int ap_os_is_path_absolute(const char *file) +APR_INLINE int ap_os_is_path_absolute(const char *file) { - /* For now, just do the same check that http_request.c and mod_alias.c do. - * XXX: Accept /bleh still? Or do we concur that d:/bleh is a minimum - * requirement? If so, canonical name needs to convert to drive/path - * syntax, and the test becomes (file[0] == '/' && file[1] == '/') ||... - */ - return file && (file[0] == '/' || (file[1] == ':' && file[2] == '/')); + /* For now, just do the same check that http_request.c and mod_alias.c do. + * XXX: Accept /bleh still? Or do we concur that d:/bleh is a minimum + * requirement? If so, canonical name needs to convert to drive/path + * syntax, and the test is (file[0] == '/' && file[1] == '/') ||... + */ + return (file[0] == '/' + || (file[0] != '\0' && file[1] == ':' && file[2] == '/')); } diff --git a/os/os2/os.h b/os/os2/os.h index 6199be0c30..90909271ff 100644 --- a/os/os2/os.h +++ b/os/os2/os.h @@ -64,7 +64,8 @@ #define HAVE_DRIVE_LETTERS #define HAVE_UNC_PATHS -#include +#include +#include /* * This file in included in all Apache source code. It contains definitions @@ -72,18 +73,14 @@ * and prototypes of OS specific functions defined in os.c or os-inline.c */ -#if defined(__GNUC__) && !defined(INLINE) +#if APR_HAS_INLINE /* Compiler supports inline, so include the inlineable functions as * part of the header */ -#define INLINE extern __inline__ - -INLINE int ap_os_is_path_absolute(const char *file); #include "os-inline.c" -#endif -#ifndef INLINE +#else /* Compiler does not support inline, so prototype the inlineable functions * as normal */ diff --git a/os/tpf/os-inline.c b/os/tpf/os-inline.c index 0fdf3b332d..c8299b58ac 100644 --- a/os/tpf/os-inline.c +++ b/os/tpf/os-inline.c @@ -62,28 +62,26 @@ * header file and a compilable module. * * Only inlineable functions should be defined in here. They must all - * include the INLINE modifier. + * include the APR_INLINE modifier. * * If the compiler supports inline, this file will be #included as a * header file from os.h to create all the inline function - * definitions. INLINE will be defined to whatever is required on + * definitions. APR_INLINE will be defined to whatever is required on * function definitions to make them inline declarations. * * If the compiler does not support inline, this file will be compiled * as a normal C file into libos.a (along with os.c). In this case - * INLINE will _not_ be set so we can use this to test if we are - * compiling this source file. + * APR_HAS_INLINE will be zero so we can use this to test if we are + * compiling this source file. */ -#ifndef INLINE -#define INLINE - -/* Anything required only when compiling */ -#include "ap_config.h" +#include "apr.h" +#if APR_HAS_INLINE +/* keep inlined functions private to the including file */ +static #endif - -INLINE int ap_os_is_path_absolute(const char *file) +APR_INLINE int ap_os_is_path_absolute(const char *file) { - return (file && file[0] == '/' ? 1 : 0); + return file[0] == '/'; } diff --git a/os/tpf/os.c b/os/tpf/os.c index 28259deb9c..2181a190b0 100644 --- a/os/tpf/os.c +++ b/os/tpf/os.c @@ -69,51 +69,6 @@ static FILE *sock_fp; -/* Check the Content-Type to decide if conversion is needed */ -int ap_checkconv(struct request_rec *r) -{ - int convert_to_ascii; - const char *type; - - /* To make serving of "raw ASCII text" files easy (they serve faster - * since they don't have to be converted from EBCDIC), a new - * "magic" type prefix was invented: text/x-ascii-{plain,html,...} - * If we detect one of these content types here, we simply correct - * the type to the real text/{plain,html,...} type. Otherwise, we - * set a flag that translation is required later on. - */ - - type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type; - - /* If no content type is set then treat it as (ebcdic) text/plain */ - convert_to_ascii = (type == NULL); - - /* Conversion is applied to text/ files only, if ever. */ - if (type && (strncasecmp(type, "text/", 5) == 0 || - strncasecmp(type, "message/", 8) == 0)) { - if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX, - sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0){ - r->content_type = apr_pstrcat(r->pool, "text/", - type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1, NULL); - if (r->method_number == M_PUT) - ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, 0); - } - - else - /* translate EBCDIC to ASCII */ - convert_to_ascii = 1; - } - else{ - if (r->method_number == M_PUT) - ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, 0); - /* don't translate non-text files to EBCDIC */ - } - /* Enable conversion if it's a text document */ - ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii); - - return convert_to_ascii; -} - int tpf_select(int maxfds, fd_set *reads, fd_set *writes, fd_set *excepts, struct timeval *tv) { /* We're going to force our way through select. We're only interested reads and TPF allows diff --git a/os/tpf/os.h b/os/tpf/os.h index d64a975e6a..65965c0959 100644 --- a/os/tpf/os.h +++ b/os/tpf/os.h @@ -71,28 +71,23 @@ * and prototypes of OS specific functions defined in os.c or os-inline.c */ +#include "apr.h" #include "ap_config.h" -#if !defined(INLINE) && defined(USE_GNU_INLINE) +#if APR_HAS_INLINE /* Compiler supports inline, so include the inlineable functions as * part of the header */ -#define INLINE extern apr_inline + #include "os-inline.c" -#endif -#ifndef INLINE +#else /* Compiler does not support inline, so prototype the inlineable functions * as normal */ extern int ap_os_is_path_absolute(const char *f); #endif - -/* Sorry if this is ugly, but the include order doesn't allow me - * to use request_rec here... */ -struct request_rec; -extern int ap_checkconv(struct request_rec *r); #include #ifndef __strings_h diff --git a/os/unix/os-inline.c b/os/unix/os-inline.c index 72a2f8d9ef..c8299b58ac 100644 --- a/os/unix/os-inline.c +++ b/os/unix/os-inline.c @@ -62,31 +62,26 @@ * header file and a compilable module. * * Only inlineable functions should be defined in here. They must all - * include the INLINE modifier. + * include the APR_INLINE modifier. * * If the compiler supports inline, this file will be #included as a * header file from os.h to create all the inline function - * definitions. INLINE will be defined to whatever is required on + * definitions. APR_INLINE will be defined to whatever is required on * function definitions to make them inline declarations. * * If the compiler does not support inline, this file will be compiled * as a normal C file into libos.a (along with os.c). In this case - * INLINE will _not_ be set so we can use this to test if we are - * compiling this source file. + * APR_HAS_INLINE will be zero so we can use this to test if we are + * compiling this source file. */ -#ifdef HAVE_UNISTD_H -#include -#endif - -#ifndef INLINE -#define INLINE -/* Anything required only when compiling */ -#include "ap_config.h" +#include "apr.h" +#if APR_HAS_INLINE +/* keep inlined functions private to the including file */ +static #endif - -INLINE int ap_os_is_path_absolute(const char *file) +APR_INLINE int ap_os_is_path_absolute(const char *file) { - return file[0] == '/'; + return file[0] == '/'; } diff --git a/os/unix/os.h b/os/unix/os.h index f32f92a8ee..267210d064 100644 --- a/os/unix/os.h +++ b/os/unix/os.h @@ -59,6 +59,7 @@ #ifndef APACHE_OS_H #define APACHE_OS_H +#include "apr.h" #include "ap_config.h" #ifndef PLATFORM @@ -75,19 +76,11 @@ * and prototypes of OS specific functions defined in os.c or os-inline.c */ -#if !defined(INLINE) && defined(USE_GNU_INLINE) + +#if APR_HAS_INLINE /* Compiler supports inline, so include the inlineable functions as * part of the header */ -#define INLINE extern apr_inline - -/** - * Is the path an absolute or relative path - * @param file The path to the file - * @return 1 if absolute, 0 otherwise - * @deffunc int ap_os_is_path_absolute(const char *file) - */ -INLINE int ap_os_is_path_absolute(const char *file); #include "os-inline.c" @@ -96,7 +89,15 @@ INLINE int ap_os_is_path_absolute(const char *file); /* Compiler does not support inline, so prototype the inlineable functions * as normal */ + +/** + * Is the path an absolute or relative path + * @param file The path to the file + * @return 1 if absolute, 0 otherwise + * @deffunc int ap_os_is_path_absolute(const char *file) + */ extern int ap_os_is_path_absolute(const char *file); + #endif /* Other ap_os_ routines not used by this platform */ diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index c5d829d2c7..61797356d3 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -400,7 +400,7 @@ static void sock_disable_nagle(int s) */ static ap_listen_rec *head_listener; -static apr_inline ap_listen_rec *find_ready_listener(fd_set * main_fds) +static APR_INLINE ap_listen_rec *find_ready_listener(fd_set * main_fds) { ap_listen_rec *lr; SOCKET nsd; @@ -885,7 +885,7 @@ static int create_acceptex_context(apr_pool_t *_pconf, ap_listen_rec *lr) return 0; } -static apr_inline apr_status_t reset_acceptex_context(PCOMP_CONTEXT context) +static APR_INLINE apr_status_t reset_acceptex_context(PCOMP_CONTEXT context) { DWORD BytesRead; SOCKET nsd; diff --git a/server/scoreboard.c b/server/scoreboard.c index a0cd9baaf9..88ebe0fb9e 100644 --- a/server/scoreboard.c +++ b/server/scoreboard.c @@ -211,7 +211,7 @@ AP_DECLARE(int) ap_exists_scoreboard_image(void) return (ap_scoreboard_image ? 1 : 0); } -static apr_inline void put_scoreboard_info(int child_num, int thread_num, +static APR_INLINE void put_scoreboard_info(int child_num, int thread_num, short_score *new_score_rec) { /* XXX - needs to be fixed to account for threads */ diff --git a/server/util.c b/server/util.c index b44144e1bd..a3a0be2703 100644 --- a/server/util.c +++ b/server/util.c @@ -1552,7 +1552,7 @@ AP_DECLARE(char *) ap_construct_server(apr_pool_t *p, const char *hostname, */ static const char c2x_table[] = "0123456789abcdef"; -static apr_inline unsigned char *c2x(unsigned what, unsigned char *where) +static APR_INLINE unsigned char *c2x(unsigned what, unsigned char *where) { #if APR_CHARSET_EBCDIC what = apr_xlate_conv_byte(ap_hdrs_to_ascii, (unsigned char)what); diff --git a/server/vhost.c b/server/vhost.c index daaff467d6..ca373e5916 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -342,13 +342,13 @@ static void dump_iphash_statistics(server_rec *main_s) * * Hash function provided by David Hankins. */ -static apr_inline unsigned hash_inaddr(unsigned key) +static APR_INLINE unsigned hash_inaddr(unsigned key) { key ^= (key >> 16); return ((key >> 8) ^ key) % IPHASH_TABLE_SIZE; } -static apr_inline unsigned hash_addr(struct apr_sockaddr_t *sa) +static APR_INLINE unsigned hash_addr(struct apr_sockaddr_t *sa) { unsigned key; @@ -386,7 +386,7 @@ static name_chain *new_name_chain(apr_pool_t *p, server_rec *s, server_addr_rec } -static apr_inline ipaddr_chain *find_ipaddr(apr_sockaddr_t *sa) +static APR_INLINE ipaddr_chain *find_ipaddr(apr_sockaddr_t *sa) { unsigned bucket; ipaddr_chain *trav;