3 Replies Latest reply: Sep 29, 2008 2:38 PM by h2o_hyperic RSS

    Linux / glibc 2.8: ARG_MAX undeclard?

    h2o_hyperic Hot Shot
      Sigar is very cool and everything runs out of the box, so I wanted to rebuild from scratch and maybe provide a Gentoo package. But not so fast cowboy:

             [cc] /tmp/hyperic-sigar-1.6.0-src/src/os/linux/linux_sigar.c: In function 'sigar_proc_env_get':
             [cc] /tmp/hyperic-sigar-1.6.0-src/src/os/linux/linux_sigar.c:889: error: 'ARG_MAX' undeclared (first use in this function)

      This looks interesting, because limits.h pulls in sys/params.h which includes linux/limits.h and then successfully UNdefines ARG_MAX again because it thinks it knows better:

      --snip--

      #ifndef ARG_MAX
      # define __undef_ARG_MAX
      #endif

      #include limits.h
      #include linux/limits.h
      #include linux/param.h

      /* The kernel headers defines ARG_MAX.  The value is wrong, though.  */
      #ifndef __undef_ARG_MAX
      # undef ARG_MAX
      # undef __undef_ARG_MAX
      #endif

      --snip--

      ..and so I end up with no ARG_MAX. I know that directly defining values from linux/* is bad, but in this case it looks like a valid workaround. Sure enough, adding the following after all includes:

      #ifndef ARG_MAX
      #define ARG_MAX 131072
      #endif

      ..fixes things to build & run fine, as expected.

      This is with glibc 2.8_p20080602 - arguably a "testing" version, but since this is Gentoo practically everything is built from source, and this is the very first time I ran into this particular error.

      Any other suggestions? Should I file this into JIRA?

      thanks for an awesome package,
      Holger

      fixed include brackets

         
      Message was edited by: h2o