tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r549224 - in /tomcat/connectors/trunk/jk: native/common/jk_global.h native/common/jk_shm.c native/common/jk_types.h.in native/common/jk_util.c native/configure.in native/scripts/build/jk_common.m4 xdocs/miscellaneous/changelog.xml
Date Wed, 20 Jun 2007 20:39:06 GMT
Author: rjung
Date: Wed Jun 20 13:39:05 2007
New Revision: 549224

URL: http://svn.apache.org/viewvc?view=rev&rev=549224
Log:
Auto-detect correct print format for pid_t.
This fixes at least compiler warnings on Solaris.

Added:
    tomcat/connectors/trunk/jk/native/scripts/build/jk_common.m4   (with props)
Modified:
    tomcat/connectors/trunk/jk/native/common/jk_global.h
    tomcat/connectors/trunk/jk/native/common/jk_shm.c
    tomcat/connectors/trunk/jk/native/common/jk_types.h.in
    tomcat/connectors/trunk/jk/native/common/jk_util.c
    tomcat/connectors/trunk/jk/native/configure.in
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml

Modified: tomcat/connectors/trunk/jk/native/common/jk_global.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_global.h?view=diff&rev=549224&r1=549223&r2=549224
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_global.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_global.h Wed Jun 20 13:39:05 2007
@@ -293,6 +293,7 @@
     typedef unsigned __int64 jk_uint64_t;
 #define JK_UINT64_T_FMT "I64u"
 #define JK_UINT64_T_HEX_FMT "I64x"
+#define JK_PID_T_FMT "d"
 #elif defined(AS400) || defined(NETWARE)
     typedef unsigned int jk_uint32_t;
 #define JK_UINT32_T_FMT "u"
@@ -300,6 +301,7 @@
     typedef unsigned long long jk_uint64_t;
 #define JK_UINT64_T_FMT "llu"
 #define JK_UINT64_T_HEX_FMT "llx"
+#define JK_PID_T_FMT "d"
 #else
 #include "jk_types.h"
 #endif

Modified: tomcat/connectors/trunk/jk/native/common/jk_shm.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_shm.c?view=diff&rev=549224&r1=549223&r2=549224
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_shm.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_shm.c Wed Jun 20 13:39:05 2007
@@ -348,7 +348,7 @@
 
     if (!jk_shmem.filename) {
         jk_shmem.filename = (char *)malloc(strlen(fname) + 32);
-        sprintf(jk_shmem.filename, "%s.%d", fname, (int)getpid());
+        sprintf(jk_shmem.filename, "%s.%" JK_PID_T_FMT, fname, getpid());
     }
     if (!attached) {
         size_t size;

Modified: tomcat/connectors/trunk/jk/native/common/jk_types.h.in
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_types.h.in?view=diff&rev=549224&r1=549223&r2=549224
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_types.h.in (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_types.h.in Wed Jun 20 13:39:05 2007
@@ -53,6 +53,9 @@
 /* And JK_UINT64_T_HEX_FMT */
 @uint64_t_hex_fmt@
 
+/* And JK_PID_T_FMT */
+@pid_t_fmt@
+
 #ifdef __cplusplus
 }
 #endif                          /* __cplusplus */

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?view=diff&rev=549224&r1=549223&r2=549224
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Wed Jun 20 13:39:05 2007
@@ -491,7 +491,7 @@
             /* Performance is no issue, because with production log levels */
             /* we only call it often, if we have a lot of errors */
             rc = snprintf(&buf[used], usable_size - used,
-                             "[%04d:%04d] ", getpid(), jk_gettid());
+                             "[%" JK_PID_T_FMT ":%04d] ", getpid(), jk_gettid());
             used += rc;
             if (rc < 0 || usable_size - used < 8) {
                 return 0;

Modified: tomcat/connectors/trunk/jk/native/configure.in
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/configure.in?view=diff&rev=549224&r1=549223&r2=549224
==============================================================================
--- tomcat/connectors/trunk/jk/native/configure.in (original)
+++ tomcat/connectors/trunk/jk/native/configure.in Wed Jun 20 13:39:05 2007
@@ -15,6 +15,11 @@
 
 AM_INIT_AUTOMAKE(${PACKAGE}, ${VERSION})
 
+dnl
+dnl Include our own M4 macros
+dnl
+sinclude(scripts/build/jk_common.m4)
+
 AC_PATH_PROG(TEST,test,$PATH)dnl
 AC_SUBST(TEST)
 
@@ -207,6 +212,30 @@
     AC_ERROR([could not detect a 64-bit integer type])
 fi
 
+JK_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], pid_t, 8)
+
+if test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_short"; then
+    pid_t_fmt='#define JK_PID_T_FMT "hd"'
+elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_int"; then
+    pid_t_fmt='#define JK_PID_T_FMT "d"'
+elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long"; then
+    pid_t_fmt='#define JK_PID_T_FMT "ld"'
+elif test "$ac_cv_sizeof_pid_t" = "$ac_cv_sizeof_long_long"; then
+    pid_t_fmt='#define JK_PID_T_FMT JK_INT64_T_FMT'
+else
+    pid_t_fmt='#error Can not determine the proper size for pid_t'
+fi
+
+# Basically, we have tried to figure out the correct format strings
+# for pid_t which varies between platforms, but we don't always get
+# it right.  If you find that we don't get it right for your platform,
+# you can override our decision below.
+case $host in
+   *-solaris*)
+       pid_t_fmt='#define JK_PID_T_FMT "ld"'
+       ;;
+esac
+
 AC_SUBST(int32_value)
 AC_SUBST(int32_t_fmt) 
 AC_SUBST(uint32_t_fmt) 
@@ -215,6 +244,7 @@
 AC_SUBST(int64_t_fmt) 
 AC_SUBST(uint64_t_fmt) 
 AC_SUBST(uint64_t_hex_fmt) 
+AC_SUBST(pid_t_fmt) 
 
 dnl check for snprintf and vsnprintf.
 AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF,1,[Have snprintf()]))

Added: tomcat/connectors/trunk/jk/native/scripts/build/jk_common.m4
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/scripts/build/jk_common.m4?view=auto&rev=549224
==============================================================================
--- tomcat/connectors/trunk/jk/native/scripts/build/jk_common.m4 (added)
+++ tomcat/connectors/trunk/jk/native/scripts/build/jk_common.m4 Wed Jun 20 13:39:05 2007
@@ -0,0 +1,54 @@
+dnl -------------------------------------------------------- -*- autoconf -*-
+dnl Licensed to the Apache Software Foundation (ASF) under one or more
+dnl contributor license agreements.  See the NOTICE file distributed with
+dnl this work for additional information regarding copyright ownership.
+dnl The ASF licenses this file to You under the Apache License, Version 2.0
+dnl (the "License"); you may not use this file except in compliance with
+dnl the License.  You may obtain a copy of the License at
+dnl
+dnl     http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+
+dnl
+dnl jk_common.m4: JK's general-purpose autoconf macros
+dnl Mostly taken from APR.
+dnl
+
+dnl
+dnl JK_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE])
+dnl
+dnl A variant of AC_CHECK_SIZEOF which allows the checking of
+dnl sizes of non-builtin types
+dnl
+AC_DEFUN([JK_CHECK_SIZEOF_EXTENDED],
+[changequote(<<,>>)dnl
+dnl The name to #define
+define(<<AC_TYPE_NAME>>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnl
+dnl The cache variable
+define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$2, [ *],[<p>]))dnl
+changequote([, ])dnl
+AC_MSG_CHECKING(size of $2)
+AC_CACHE_VAL(AC_CV_NAME,
+[AC_TRY_RUN([#include <stdio.h>
+$1
+main()
+{
+  FILE *f=fopen("conftestval","w");
+  if (!f) exit(1);
+  fprintf(f, "%d\n", sizeof($2));
+  exit(0);
+}], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,,
+AC_CV_NAME=$3))])dnl
+AC_MSG_RESULT($AC_CV_NAME)
+AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The size of ]$2)
+undefine([AC_TYPE_NAME])dnl
+undefine([AC_CV_NAME])dnl
+])
+
+
+

Propchange: tomcat/connectors/trunk/jk/native/scripts/build/jk_common.m4
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/connectors/trunk/jk/native/scripts/build/jk_common.m4
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?view=diff&rev=549224&r1=549223&r2=549224
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Wed Jun 20 13:39:05 2007
@@ -27,6 +27,10 @@
   <br />
   <subsection name="Native">
     <changelog>
+      <update>
+      Common: auto-detect correct print format for pid_t.
+      This fixes at least compiler warnings on Solaris. (rjung)
+      </update>
       <fix>
         <bug>42608</bug>: Handle Content-length as unsigned 64Bit
         to allow for huge up- and downloads. (rjung)



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message