Opened 15 years ago

Closed 11 years ago

#414 closed defect (fixed)

IZ2217: daemos/common/procfs.c failed to compile

Reported by: nova Owned by: Dave Love <…>
Priority: normal Milestone:
Component: sge Version: 6.0u10
Severity: Keywords: PC Linux build


[Imported from gridengine issuezilla]

        Issue #:      2217             Platform:     PC       Reporter: nova (nova)
       Component:     gridengine          OS:        Linux
     Subcomponent:    build            Version:      6.0u10      CC:    None defined
        Status:       NEW              Priority:     P3
      Resolution:                     Issue type:    DEFECT
                                   Target milestone: ---
      Assigned to:    andreas (andreas)
      QA Contact:     andreas
       * Summary:     daemos/common/procfs.c failed to compile
   Status whiteboard:
                      Date/filename:                                   Description:                    Submitted by:
                      Tue Sep 25 07:59:00 -0700 2007: procfs-diffs.txt patch with sysconf (text/plain) olesen

     Issue 2217 blocks:
   Votes for issue 2217:

   Opened: Tue Mar 20 10:28:00 -0700 2007 

Compilation of procfs.c fails with the error about an undefined symbol "HZ".
It's on the openSUSE 10.2 x86_64 Linux with kernel.

As I could found out, the problem is in the included <sys/param.h> header, which
in turn includes asm/params.h from kernel source. Apparently, the "HZ"
definition there has been changed in the kernel version <=2.6.18. One need to
#define __KERNEL__ now to obtain it, which can bring some side effects I think.
And it seems that to convert jiffies to seconds in procfs.c one should use
"USER_HZ", not "HZ".

I think the workaround is to use HZ=sysconf(_SC_CLK_TCK) (from <unistd.h>), or
function like jiffies_to_*() from <linux/jiffies.h>. Don't know though if this
is portable.

   ------- Additional comments from olesen Tue Sep 25 07:59:40 -0700 2007 -------
Created an attachment (id=121)
patch with sysconf

   ------- Additional comments from olesen Tue Sep 25 08:10:30 -0700 2007 -------
I just ran into this compile issue as well and needed to find the cause (qucikly).
From man page, it would look like the sysconf(3) is really the right thing to do
(ie, POSIX).

The following mini program yields '100' on SuSE 9.2 (2.6.8-24) and on SuSE 10.2.
This is identical to the HZ define.

If this same functionality is available in the older 2.4 kernels, sysconf()
could be used throughout.

#include <stdio.h>
#include <unistd.h>
int main()
    printf("sysconf(_SC_CLK_TCK) = %ld\n", sysconf(_SC_CLK_TCK));
    return 0;

Attachments (1)

121 (1.4 KB) - added by dlove 11 years ago.

Download all attachments as: .zip

Change History (2)

Changed 11 years ago by dlove

comment:1 Changed 11 years ago by Dave Love <…>

  • Owner set to Dave Love <…>
  • Resolution set to fixed
  • Status changed from new to closed

In [3600/sge]:

Fix #414 (IZ2217): Use sysconf, not HZ.
I'm puzzled by the error reported in the ticket, as HZ is defined
OK in the earlier and later systems I have. It's wrong to use it
anyhow, so syscof is used unconditionally. There are some other uses
(outside qtcsh), but they're in code for platforms that are probably
irrelevant now.

Note: See TracTickets for help on using tickets.