From: Takashi Iwai Subject: Re: [alsa-cvslog] alsa-lib: Add struct timeval and timespec definition when _POSIX_C_SOURCE is not defined Date: Mon, 25 Jun 2007 15:15:39 +0200 Message-ID: References: <20070624133525.GA24739@procyon.home> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (cantor.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 9A26C10380B for ; Mon, 25 Jun 2007 15:15:44 +0200 (CEST) In-Reply-To: <20070624133525.GA24739@procyon.home> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Sergey Vlasov Cc: alsa-devel@alsa-project.org, Jaroslav Kysela List-Id: alsa-devel@alsa-project.org At Sun, 24 Jun 2007 17:35:25 +0400, Sergey Vlasov wrote: > > On Fri, Oct 06, 2006 at 11:01:44AM +0200, Jaroslav Kysela wrote: > > changeset: 2218:603411fd0c77712cab43cdd5afcf0ff4ebe51a7f > > tag: tip > > user: perex > > date: Fri Oct 06 11:01:40 2006 +0200 > > files: include/global.h > > description: > > Add struct timeval and timespec definition when _POSIX_C_SOURCE is not defined > > > > FIXME: It might cause problems on some platforms when tv_usec is not long type. > > And now it also breaks compilation of the following code (at least > with glibc 2.5): > > #include > #include > > $ gcc -c --std=c99 x.c > In file included from x.c:2: > /usr/include/alsa/global.h:134: error: redefinition of 'struct timeval' > /usr/include/alsa/global.h:139: error: redefinition of 'struct timespec' > > (Without #include only 'struct timespec' is redefined.) > > IMHO attempts to define structures which should be defined by system > headers are too dangerous - if someone is using preprocessor flags > which hide required parts of system headers, it is their problem, and > the risk of mismatch is too high. I agree. Jaroslav, which system has no definition of these types? Maybe it'd be better to check it in configure script, rather than the simple ifdef. > BTW, does not provide 'struct timeval' at all, even with > _GNU_SOURCE - it defines only 'struct timespec'; however, this does > not cause problems, because ALSA headers currently use only pointers > to snd_timestamp_t, which works even without a complete definition of > 'struct timeval'. We can try to include to get 'struct > timeval', or even (which currently seems to provide > both 'struct timeval' and 'struct timespec' even with -ansi, and > http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/select.h.html > tells that it should always provide their definitions). A patch is welcome :) thanks, Takashi