You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2020/07/07 13:40:16 UTC

svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Author: jorton
Date: Tue Jul  7 13:40:15 2020
New Revision: 1879591

URL: http://svn.apache.org/viewvc?rev=1879591&view=rev
Log:
Check for and use gettid() directly if available; glibc 2.30 and later
provides a wrapper for the system call:

* configure.in: Check for gettid() and define HAVE_SYS_GETTID if
  gettid() is only usable via syscall().

* server/log.c (log_tid): Use gettid() directly if available.

Modified:
    httpd/httpd/trunk/configure.in
    httpd/httpd/trunk/server/log.c

Modified: httpd/httpd/trunk/configure.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/configure.in?rev=1879591&r1=1879590&r2=1879591&view=diff
==============================================================================
--- httpd/httpd/trunk/configure.in (original)
+++ httpd/httpd/trunk/configure.in Tue Jul  7 13:40:15 2020
@@ -535,22 +535,26 @@ prctl \
 timegm \
 getpgid \
 fopen64 \
-getloadavg
+getloadavg \
+gettid
 )
 
 dnl confirm that a void pointer is large enough to store a long integer
 APACHE_CHECK_VOID_PTR_LEN
 
-AC_CACHE_CHECK([for gettid()], ac_cv_gettid,
+if test $ac_cv_func_gettid = no; then
+  # On Linux before glibc 2.30, gettid() is only usable via syscall()
+  AC_CACHE_CHECK([for gettid() via syscall], ap_cv_gettid,
 [AC_TRY_RUN(#define _GNU_SOURCE
 #include <unistd.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
 int main(int argc, char **argv) {
 pid_t t = syscall(SYS_gettid); return t == -1 ? 1 : 0; },
-[ac_cv_gettid=yes], [ac_cv_gettid=no], [ac_cv_gettid=no])])
-if test "$ac_cv_gettid" = "yes"; then
-    AC_DEFINE(HAVE_GETTID, 1, [Define if you have gettid()])
+  [ap_cv_gettid=yes], [ap_cv_gettid=no], [ap_cv_gettid=no])])
+  if test "$ap_cv_gettid" = "yes"; then
+      AC_DEFINE(HAVE_SYS_GETTID, 1, [Define if you have gettid() via syscall()])
+  fi
 fi
 
 dnl ## Check for the tm_gmtoff field in struct tm to get the timezone diffs

Modified: httpd/httpd/trunk/server/log.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/log.c?rev=1879591&r1=1879590&r2=1879591&view=diff
==============================================================================
--- httpd/httpd/trunk/server/log.c (original)
+++ httpd/httpd/trunk/server/log.c Tue Jul  7 13:40:15 2020
@@ -56,7 +56,7 @@
 #include "ap_provider.h"
 #include "ap_listen.h"
 
-#if HAVE_GETTID
+#ifdef HAVE_SYS_GETTID
 #include <sys/syscall.h>
 #include <sys/types.h>
 #endif
@@ -538,14 +538,18 @@ static int log_tid(const ap_errorlog_inf
 #if APR_HAS_THREADS
     int result;
 #endif
-#if HAVE_GETTID
+#if defined(HAVE_GETTID) || defined(HAVE_SYS_GETTID)
     if (arg && *arg == 'g') {
+#ifdef HAVE_GETTID
+        pid_t tid = gettid();
+#else
         pid_t tid = syscall(SYS_gettid);
+#endif
         if (tid == -1)
             return 0;
         return apr_snprintf(buf, buflen, "%"APR_PID_T_FMT, tid);
     }
-#endif
+#endif /* HAVE_GETTID || HAVE_SYS_GETTID */
 #if APR_HAS_THREADS
     if (ap_mpm_query(AP_MPMQ_IS_THREADED, &result) == APR_SUCCESS
         && result != AP_MPMQ_NOT_SUPPORTED)



Re: svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 7/15/20 3:52 PM, Ruediger Pluem wrote:
> 
> 
> On 7/15/20 2:58 PM, Graham Leggett wrote:
>> On 07 Jul 2020, at 15:40, jorton@apache.org <ma...@apache.org> wrote:
>>
>>> Author: jorton
>>> Date: Tue Jul  7 13:40:15 2020
>>> New Revision: 1879591
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1879591&view=rev
>>> Log:
>>> Check for and use gettid() directly if available; glibc 2.30 and later
>>> provides a wrapper for the system call:
>>>
>>> * configure.in: Check for gettid() and define HAVE_SYS_GETTID if
>>>  gettid() is only usable via syscall().
>>>
>>> * server/log.c (log_tid): Use gettid() directly if available.
>>
>> This is not working for me on CentOS8.
>>
>> ./configure says this:
>>
>> checking for gettid()... yes
>>
>> but the build fails like this:
>>
>> log.c: In function 'log_tid':
>> log.c:544:21: warning: implicit declaration of function 'gettid'; did you mean getgid'? [-Wimplicit-function-declaration]
>>          pid_t tid = gettid();
>>                      ^~~~~~
>>                      getgid
>>
>> Is there maybe a missing header file needed somewhere?
> 
> I guess we need to include either
> 
> linux/unistd.h
> 
> or keep including
> 
> sys/syscall.h

Scratch that. Both cause the syscall stuff to be included not a glibc function.

Regards

Rüdiger



Re: svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 7/15/20 2:58 PM, Graham Leggett wrote:
> On 07 Jul 2020, at 15:40, jorton@apache.org <ma...@apache.org> wrote:
> 
>> Author: jorton
>> Date: Tue Jul  7 13:40:15 2020
>> New Revision: 1879591
>>
>> URL: http://svn.apache.org/viewvc?rev=1879591&view=rev
>> Log:
>> Check for and use gettid() directly if available; glibc 2.30 and later
>> provides a wrapper for the system call:
>>
>> * configure.in: Check for gettid() and define HAVE_SYS_GETTID if
>>  gettid() is only usable via syscall().
>>
>> * server/log.c (log_tid): Use gettid() directly if available.
> 
> This is not working for me on CentOS8.
> 
> ./configure says this:
> 
> checking for gettid()... yes
> 
> but the build fails like this:
> 
> log.c: In function 'log_tid':
> log.c:544:21: warning: implicit declaration of function 'gettid'; did you mean getgid'? [-Wimplicit-function-declaration]
>          pid_t tid = gettid();
>                      ^~~~~~
>                      getgid
> 
> Is there maybe a missing header file needed somewhere?

I guess we need to include either

linux/unistd.h

or keep including

sys/syscall.h


Regards

Rüdiger

Re: svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Posted by Graham Leggett <mi...@sharp.fm>.
On 15 Jul 2020, at 16:27, Joe Orton <jo...@redhat.com> wrote:

>> Looks like ac_cv_func_gettid is no but ap_cv_gettid is yes.
> 
> This is not consistent with what you posted before.  Looking again, the 
> old configure output you posted has:
> 
> checking for gettid()... yes
> 
> note the (), which is only possible if you haven't re-run buildconf.  
> Re-run buildconf and configure, and if the build still fails please 
> provide the full config.log somewhere so I can try to understand what's 
> going on.

Double checked the terminal history, and I had indeed run buildconf - this wasn't enough though.

As rpluem suggested "make extraclean” was the secret, this is needed over and above the buildconf. The build is now clean.

Regards,
Graham
—


Re: svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Posted by Joe Orton <jo...@redhat.com>.
On Wed, Jul 15, 2020 at 04:03:41PM +0200, Graham Leggett wrote:
> On 15 Jul 2020, at 15:35, Joe Orton <jo...@redhat.com> wrote:
> 
> >> checking for gettid()... yes
> > 
> > Interesting, can you provide the config.log and "rpm -q glibc"?  With a 
> > RHEL8 vm here it does not detect gettid (as I'd expect for glibc 2.28) 
> > and builds fine.
> 
> A quick and dirty search across config.log shows this:
> 
> [minfrin@bob httpd-trunk]$ cat config.log | grep gettid
> configure:8059: checking for gettid
> conftest.c:(.text+0xa): undefined reference to `gettid'
> | /* Define gettid to an innocuous variant, in case <limits.h> declares gettid.
> | #define gettid innocuous_gettid
> |     which can conflict with char gettid (); below.
> | #undef gettid
> | char gettid ();
> | #if defined __stub_gettid || defined __stub___gettid
> | return gettid ();
> configure:8107: checking for gettid() via syscall
> ac_cv_func_gettid=no
> ap_cv_gettid=yes
> 
> Looks like ac_cv_func_gettid is no but ap_cv_gettid is yes.

This is not consistent with what you posted before.  Looking again, the 
old configure output you posted has:

checking for gettid()... yes

note the (), which is only possible if you haven't re-run buildconf.  
Re-run buildconf and configure, and if the build still fails please 
provide the full config.log somewhere so I can try to understand what's 
going on.


Re: svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Posted by Ruediger Pluem <rp...@apache.org>.

On 7/15/20 4:03 PM, Graham Leggett wrote:
> On 15 Jul 2020, at 15:35, Joe Orton <jorton@redhat.com <ma...@redhat.com>> wrote:
> 
>>> checking for gettid()... yes
>>
>> Interesting, can you provide the config.log and "rpm -q glibc"?  With a 
>> RHEL8 vm here it does not detect gettid (as I'd expect for glibc 2.28) 
>> and builds fine.
> 
> A quick and dirty search across config.log shows this:
> 
> [minfrin@bob httpd-trunk]$ cat config.log | grep gettid
> configure:8059: checking for gettid
> conftest.c:(.text+0xa): undefined reference to `gettid'
> | /* Define gettidto an innocuous variant, in case <limits.h> declares gettid.
> | #define gettidinnocuous_gettid
> |     which can conflict with char gettid(); below.
> | #undef gettid
> | char gettid();
> | #if defined __stub_gettid|| defined __stub___gettid
> | return gettid();
> configure:8107: checking for gettid() via syscall
> ac_cv_func_gettid=no
> ap_cv_gettid=yes
> 
> Looks like ac_cv_func_gettid is no but ap_cv_gettid is yes.
> 
> [minfrin@bob httpd-trunk]$ rpm -q glibc
> glibc-2.28-72.el8_1.1.x86_64
> 
> A search for what ends up in the ap_config_auto.h shows this:
> 
> [minfrin@bob httpd-trunk]$ grep -r GETTID include/
> include/ap_config_auto.h:#define HAVE_GETTID1
> include/ap_config_auto.h.in:#undef HAVE_GETTID
> include/ap_config_auto.h.in:#undef HAVE_SYS_GETTID
> 

Stupid question: Did you try a make extraclean; ./buildconf before doing your build that fails?

Regards

Rüdiger


Re: svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Posted by Graham Leggett <mi...@sharp.fm>.
On 15 Jul 2020, at 15:35, Joe Orton <jo...@redhat.com> wrote:

>> checking for gettid()... yes
> 
> Interesting, can you provide the config.log and "rpm -q glibc"?  With a 
> RHEL8 vm here it does not detect gettid (as I'd expect for glibc 2.28) 
> and builds fine.

A quick and dirty search across config.log shows this:

[minfrin@bob httpd-trunk]$ cat config.log | grep gettid
configure:8059: checking for gettid
conftest.c:(.text+0xa): undefined reference to `gettid'
| /* Define gettid to an innocuous variant, in case <limits.h> declares gettid.
| #define gettid innocuous_gettid
|     which can conflict with char gettid (); below.
| #undef gettid
| char gettid ();
| #if defined __stub_gettid || defined __stub___gettid
| return gettid ();
configure:8107: checking for gettid() via syscall
ac_cv_func_gettid=no
ap_cv_gettid=yes

Looks like ac_cv_func_gettid is no but ap_cv_gettid is yes.

[minfrin@bob httpd-trunk]$ rpm -q glibc
glibc-2.28-72.el8_1.1.x86_64

A search for what ends up in the ap_config_auto.h shows this:

[minfrin@bob httpd-trunk]$ grep -r GETTID include/
include/ap_config_auto.h:#define HAVE_GETTID 1
include/ap_config_auto.h.in:#undef HAVE_GETTID
include/ap_config_auto.h.in:#undef HAVE_SYS_GETTID

Regards,
Graham
—


Re: svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Posted by Joe Orton <jo...@redhat.com>.
On Wed, Jul 15, 2020 at 02:58:43PM +0200, Graham Leggett wrote:
> On 07 Jul 2020, at 15:40, jorton@apache.org wrote:
> > Author: jorton
> > Date: Tue Jul  7 13:40:15 2020
> > New Revision: 1879591
> > 
> > URL: http://svn.apache.org/viewvc?rev=1879591&view=rev
> > Log:
> > Check for and use gettid() directly if available; glibc 2.30 and later
> > provides a wrapper for the system call:
> > 
> > * configure.in: Check for gettid() and define HAVE_SYS_GETTID if
> >  gettid() is only usable via syscall().
> > 
> > * server/log.c (log_tid): Use gettid() directly if available.
> 
> This is not working for me on CentOS8.
> 
> ./configure says this:
> 
> checking for gettid()... yes

Interesting, can you provide the config.log and "rpm -q glibc"?  With a 
RHEL8 vm here it does not detect gettid (as I'd expect for glibc 2.28) 
and builds fine.

Regards, Joe


Re: svn commit: r1879591 - in /httpd/httpd/trunk: configure.in server/log.c

Posted by Graham Leggett <mi...@sharp.fm>.
On 07 Jul 2020, at 15:40, jorton@apache.org wrote:

> Author: jorton
> Date: Tue Jul  7 13:40:15 2020
> New Revision: 1879591
> 
> URL: http://svn.apache.org/viewvc?rev=1879591&view=rev
> Log:
> Check for and use gettid() directly if available; glibc 2.30 and later
> provides a wrapper for the system call:
> 
> * configure.in: Check for gettid() and define HAVE_SYS_GETTID if
>  gettid() is only usable via syscall().
> 
> * server/log.c (log_tid): Use gettid() directly if available.

This is not working for me on CentOS8.

./configure says this:

checking for gettid()... yes

but the build fails like this:

log.c: In function 'log_tid':
log.c:544:21: warning: implicit declaration of function 'gettid'; did you mean getgid'? [-Wimplicit-function-declaration]
         pid_t tid = gettid();
                     ^~~~~~
                     getgid

Is there maybe a missing header file needed somewhere?

MacOS says this and works:

checking for gettid()... no

Regards,
Graham
—