Bug 45513 - Wrong pid_t_fmt detection for Solaris
Summary: Wrong pid_t_fmt detection for Solaris
Status: RESOLVED FIXED
Alias: None
Product: APR
Classification: Unclassified
Component: APR (show other bugs)
Version: HEAD
Hardware: Sun Solaris
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2008-07-31 04:27 UTC by Rainer Jung
Modified: 2008-08-08 14:32 UTC (History)
2 users (show)



Attachments
Fix APR_PID_T_FMT on Solaris (1.89 KB, patch)
2008-07-31 04:27 UTC, Rainer Jung
Details | Diff
This patch moves platform specific stuff to very end, like we had it in 1.2.x (2.46 KB, patch)
2008-08-07 14:51 UTC, Bojan Smojver
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Jung 2008-07-31 04:27:08 UTC
Created attachment 22336 [details]
Fix APR_PID_T_FMT on Solaris

Revision 553652 of configure.in introduced changes in printf format detection for size_t and ssize_t to branch 1.3 and trunk. There were two unwanted side effects, that break detection of format for pid_t on Solaris (and lead to lots of Compilation warnings for httpd 2.2.9).

Problem 1: In the block setting pid_t_fmt for Solaris it got changed from 

   pid_t_fmt='#define APR_PID_T_FMT "ld"'

to

   pid_t_fmt="ld"

That type of change was wanted for size_t and ssize_t, but is unwanted for pid_t, since later on in configure.in, the define style is still used, and the way pid_t_fmt is included in apr.h.in was not adjusted.

Problem 2: the whole block of special system handling concerning format characters was moved around. Before it was located under the lines were the defaults for pid_t_fmt had been set, now it is located above, so any special setting gets overwritten by the defaults.

The attached patch fixed it. Same file for 1.3 and trunk.
Comment 1 Bojan Smojver 2008-08-04 00:19:30 UTC
So, when you apply just this hunk:
----------------------------
@@ -1360,9 +1374,9 @@
        ;;
    *-solaris*)
        if test "$ac_cv_sizeof_long" = "8"; then
-         pid_t_fmt="d"
+         pid_t_fmt='#define APR_PID_T_FMT "d"'
        else
-         pid_t_fmt="ld"
+         pid_t_fmt='#define APR_PID_T_FMT "ld"'
        fi
        ;;
    *aix4*|*aix5*)
----------------------------

It doesn't work, right?
Comment 2 Rainer Jung 2008-08-04 04:11:54 UTC
Right, that hunk alone doesn't help, because later down in configure the variable pid_t_fmt gets overwritten.
Comment 3 Bojan Smojver 2008-08-07 14:51:10 UTC
Created attachment 22407 [details]
This patch moves platform specific stuff to very end, like we had it in 1.2.x
Comment 4 Bojan Smojver 2008-08-07 14:51:47 UTC
Does the patch I just attached still do it for you? I moved that platform specific stuff to the very end.
Comment 5 Rainer Jung 2008-08-07 15:19:33 UTC
This will work for the pid_t_fmt case, but not for the biggest part in that block.

For size_t_fmt and ssize_t_fmt there is logic below the block but before the place you want to move it, that already uses the values.

I think you can savely move the block down below the immediately following lines

APR_CHECK_TYPES_COMPATIBLE(ssize_t, int, [ssize_t_fmt="d"])
APR_CHECK_TYPES_COMPATIBLE(ssize_t, long, [ssize_t_fmt="ld"])
APR_CHECK_TYPES_COMPATIBLE(size_t, unsigned int, [size_t_fmt="u"])
APR_CHECK_TYPES_COMPATIBLE(size_t, unsigned long, [size_t_fmt="lu"])

(and that might be more correct), but not further down. This is not far enough for the pid_t_fmt case :(
Comment 6 Rainer Jung 2008-08-07 15:31:26 UTC
Some examples why you shouldn't move the whole block down:

1) 

size_t_fmt="#define APR_SIZE_T_FMT \"$size_t_fmt\""
ssize_t_fmt="#define APR_SSIZE_T_FMT \"$ssize_t_fmt\""

Need to stay as the latest size_t_fmt/ssize_t_fmt manipulating statements.

2)

AC_MSG_CHECKING([which format to use for apr_ssize_t])
if test -n "$ssize_t_fmt"; then

# So we take this branch if we already determined ssize_t_fmt

    AC_MSG_RESULT(%$ssize_t_fmt)
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_int"; then
    ssize_t_fmt="d"
    AC_MSG_RESULT(%d)
elif test "$ac_cv_sizeof_ssize_t" = "$ac_cv_sizeof_long"; then
    ssize_t_fmt="ld"
    AC_MSG_RESULT(%ld)
else
# And now we complain, because we couldn't determine the format
    AC_ERROR([could not determine the proper format for apr_ssize_t])
fi

Obviously this block (and the same for the size_t_fmt block) needs to stay below the special case settings too.
Comment 7 Bojan Smojver 2008-08-07 15:59:10 UTC
Comment on attachment 22407 [details]
This patch moves platform specific stuff to very end, like we had it in 1.2.x

This patch is incorrect.
Comment 8 Bojan Smojver 2008-08-07 15:59:53 UTC
Thanks for the quick reply. I'll resend your original fix to the development list, so that people can have a look.
Comment 9 Bojan Smojver 2008-08-07 17:15:12 UTC
You patch has gone into trunk - thank you! I'll be waiting for other developers to chime in before backporting to 1.3.x. Hopefully, it'll make it into 1.3.3.
Comment 10 Rainer Jung 2008-08-08 01:09:21 UTC
Thanks for taking care. If it doesn't make it into 1.3.3 it's definitely not a showstopper and can wait for 1.3.4.
Comment 11 Bojan Smojver 2008-08-08 14:03:05 UTC
Fixed in trunk and 1.3.x. Thanks for your patch!
Comment 12 Eric Covener 2008-08-08 14:32:18 UTC
Looks good on solaris/amd64:
include/apr.h:#define APR_PID_T_FMT "d"