← Back to team overview

kernel-packages team mailing list archive

[Bug 1428260] [NEW] __USE_GNU not being set by -std=gnu11 ( struct f_owner_ex not declared )

 

Public bug reported:

Not sure if this is a bug in libc6-dev (owner of /usr/include/fcntl.h)
or in linux-libc-dev (owner of /usr/include/linux/header that declares struct f_owner_ex) but
it definitely appears to be a bug.
I am trying to compile code that uses the new fcntl interfaces :
   F_SETOWN_EX (struct f_owner_ex *) (since Linux 2.6.32)
   F_GETOWN_EX (struct f_owner_ex *) (since Linux 2.6.32)
but I cannot get the 'struct f_owner_ex' structure to be declared
using the standard system headers - I must declare it manually in my code.
This is on a Ubuntu 14.04.2 LTS x86_64 system, fully up-to-date as
of 2015-03-04 , with:
  gcc :                4:4.8.2-1ubuntu6
  libc6-dev:        2.19-0ubuntu6.6 
  linux-libc-dev:  3.13.0-46.76

Attempts to compile for instance this program always fail :
$ cat /tmp/t_fcntl.c 
#include <unistd.h>
#include <fcntl.h>
void f(void) { struct f_owner_ex foe={0}; }
$ gcc -c /tmp/t_fcntl.c 
/tmp/t_fcntl.c: In function ‘f’:
/tmp/t_fcntl.c:3:23: error: variable ‘foe’ has initializer but incomplete type
 void f(void) { struct f_owner_ex foe={0}; }
                       ^
/tmp/t_fcntl.c:3:23: warning: excess elements in struct initializer [enabled by default]
/tmp/t_fcntl.c:3:23: warning: (near initialization for ‘foe’) [enabled by default]
/tmp/t_fcntl.c:3:34: error: storage size of ‘foe’ isn’t known
 void f(void) { struct f_owner_ex foe={0}; }

I can see this structure is declared in two places:
1: /usr/include/bits/fcntl.h @ line 239:
#ifdef __USE_GNU
/* Owner types.  */
enum __pid_type
  {
    F_OWNER_TID = 0,		/* Kernel thread.  */
    F_OWNER_PID,		/* Process.  */
    F_OWNER_PGRP,		/* Process group.  */
    F_OWNER_GID = F_OWNER_PGRP	/* Alternative, obsolete name.  */
  };

/* Structure to use with F_GETOWN_EX and F_SETOWN_EX.  */
struct f_owner_ex
  {
    enum __pid_type type;	/* Owner type of ID.  */
    __pid_t pid;		/* ID of owner.  */
  };
#endif

2: /usr/include/asm-generic/fcntl.h
struct f_owner_ex {
	int	type;
	__kernel_pid_t	pid;
};
( I am assuming I should not be using the kernel's pid type ).

My understanding of __USE_GNU is that it is defined when 
-std=gnu* is specified on the compile command line, or when
_GNU_SOURCE=1 is set.  

Only when _GNU_SOURCE=1 is explicitly set is __USE_GNU being defined 
and the example compiles OK :
$ gcc -std=gnu11 -D_GNU_SOURCE=1 -c /tmp/t_fcntl.c 
OK, that worked!

$ gcc -std=gnu11  -c /tmp/t_fcntl.c 
/tmp/t_fcntl.c: In function ‘f’:
/tmp/t_fcntl.c:3:23: error: variable ‘foe’ has initializer but incomplete type
 void f(void) { struct f_owner_ex foe={0}; }
                       ^
/tmp/t_fcntl.c:3:23: warning: excess elements in struct initializer [enabled by default]
/tmp/t_fcntl.c:3:23: warning: (near initialization for ‘foe’) [enabled by default]
/tmp/t_fcntl.c:3:34: error: storage size of ‘foe’ isn’t known
 void f(void) { struct f_owner_ex foe={0}; }
                                  ^
Why isn't _GNU_SOURCE being set when I've asked gcc to enable GNU extensions with --std=gnu11 ? 

>From the "Standards" gcc info node :
     You may also select an extended version of the C language explicitly with ... '-std=gnu11' (for C11 with GNU extensions)

It would appear that libc6-dev / linux-libc-dev has broken GCC's
'-std=gnuXX' support.

Also the fcntl.2 manual page makes no mention of _GNU_SOURCE needing to be defined 
in order to use F_SETOWN_EX .

** Affects: linux (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Kernel
Packages, which is subscribed to linux in Ubuntu.
https://bugs.launchpad.net/bugs/1428260

Title:
  __USE_GNU not being set by -std=gnu11 ( struct f_owner_ex not declared
  )

Status in linux package in Ubuntu:
  New

Bug description:
  Not sure if this is a bug in libc6-dev (owner of /usr/include/fcntl.h)
  or in linux-libc-dev (owner of /usr/include/linux/header that declares struct f_owner_ex) but
  it definitely appears to be a bug.
  I am trying to compile code that uses the new fcntl interfaces :
     F_SETOWN_EX (struct f_owner_ex *) (since Linux 2.6.32)
     F_GETOWN_EX (struct f_owner_ex *) (since Linux 2.6.32)
  but I cannot get the 'struct f_owner_ex' structure to be declared
  using the standard system headers - I must declare it manually in my code.
  This is on a Ubuntu 14.04.2 LTS x86_64 system, fully up-to-date as
  of 2015-03-04 , with:
    gcc :                4:4.8.2-1ubuntu6
    libc6-dev:        2.19-0ubuntu6.6 
    linux-libc-dev:  3.13.0-46.76

  Attempts to compile for instance this program always fail :
  $ cat /tmp/t_fcntl.c 
  #include <unistd.h>
  #include <fcntl.h>
  void f(void) { struct f_owner_ex foe={0}; }
  $ gcc -c /tmp/t_fcntl.c 
  /tmp/t_fcntl.c: In function ‘f’:
  /tmp/t_fcntl.c:3:23: error: variable ‘foe’ has initializer but incomplete type
   void f(void) { struct f_owner_ex foe={0}; }
                         ^
  /tmp/t_fcntl.c:3:23: warning: excess elements in struct initializer [enabled by default]
  /tmp/t_fcntl.c:3:23: warning: (near initialization for ‘foe’) [enabled by default]
  /tmp/t_fcntl.c:3:34: error: storage size of ‘foe’ isn’t known
   void f(void) { struct f_owner_ex foe={0}; }

  I can see this structure is declared in two places:
  1: /usr/include/bits/fcntl.h @ line 239:
  #ifdef __USE_GNU
  /* Owner types.  */
  enum __pid_type
    {
      F_OWNER_TID = 0,		/* Kernel thread.  */
      F_OWNER_PID,		/* Process.  */
      F_OWNER_PGRP,		/* Process group.  */
      F_OWNER_GID = F_OWNER_PGRP	/* Alternative, obsolete name.  */
    };

  /* Structure to use with F_GETOWN_EX and F_SETOWN_EX.  */
  struct f_owner_ex
    {
      enum __pid_type type;	/* Owner type of ID.  */
      __pid_t pid;		/* ID of owner.  */
    };
  #endif

  2: /usr/include/asm-generic/fcntl.h
  struct f_owner_ex {
  	int	type;
  	__kernel_pid_t	pid;
  };
  ( I am assuming I should not be using the kernel's pid type ).

  My understanding of __USE_GNU is that it is defined when 
  -std=gnu* is specified on the compile command line, or when
  _GNU_SOURCE=1 is set.  

  Only when _GNU_SOURCE=1 is explicitly set is __USE_GNU being defined 
  and the example compiles OK :
  $ gcc -std=gnu11 -D_GNU_SOURCE=1 -c /tmp/t_fcntl.c 
  OK, that worked!

  $ gcc -std=gnu11  -c /tmp/t_fcntl.c 
  /tmp/t_fcntl.c: In function ‘f’:
  /tmp/t_fcntl.c:3:23: error: variable ‘foe’ has initializer but incomplete type
   void f(void) { struct f_owner_ex foe={0}; }
                         ^
  /tmp/t_fcntl.c:3:23: warning: excess elements in struct initializer [enabled by default]
  /tmp/t_fcntl.c:3:23: warning: (near initialization for ‘foe’) [enabled by default]
  /tmp/t_fcntl.c:3:34: error: storage size of ‘foe’ isn’t known
   void f(void) { struct f_owner_ex foe={0}; }
                                    ^
  Why isn't _GNU_SOURCE being set when I've asked gcc to enable GNU extensions with --std=gnu11 ? 

  From the "Standards" gcc info node :
       You may also select an extended version of the C language explicitly with ... '-std=gnu11' (for C11 with GNU extensions)

  It would appear that libc6-dev / linux-libc-dev has broken GCC's
  '-std=gnuXX' support.

  Also the fcntl.2 manual page makes no mention of _GNU_SOURCE needing to be defined 
  in order to use F_SETOWN_EX .

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1428260/+subscriptions


Follow ups

References