public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] ecos and gettimeofday()
@ 2005-09-30  5:35 Alexander Neundorf
       [not found] ` <87achvdsn2.fsf@p4.48ers.dk>
  0 siblings, 1 reply; 26+ messages in thread
From: Alexander Neundorf @ 2005-09-30  5:35 UTC (permalink / raw)
  To: ecos-discuss

Hi,

gettimeofday() is currently implemented in some of the network packages. This 
situation is not really ideal, because in many circumstances gettimeofday() 
is required but there is no network needed.

Some time ago Peter Koorsgard posted two patches which address this issue:
http://sources.redhat.com/ml/ecos-patches/2005-01/msg00008.html
http://sources.redhat.com/ml/ecos-patches/2005-01/msg00009.html

If this is not the right approach, what do you suggest instead ? 

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
       [not found] ` <87achvdsn2.fsf@p4.48ers.dk>
@ 2005-10-04 17:26   ` Alexander Neundorf
  2005-10-12 18:47     ` Alexander Neundorf
  0 siblings, 1 reply; 26+ messages in thread
From: Alexander Neundorf @ 2005-10-04 17:26 UTC (permalink / raw)
  To: ecos-discuss

Hi,

On Friday 30 September 2005 07:36, Peter Korsgaard wrote:
> >>>>> "Alexander" == Alexander Neundorf <neundorf@kde.org> writes:
>
> Hi,
>
>  Alexander> If this is not the right approach, what do you suggest
>  Alexander> instead ?
>
> Johanthan's reply to my patch was pretty clear about that. Basically
> you need to add a include line to the isoinfra package which can be
> set in CDL, and add the include file to the posix package.
>
> I unfortunately haven't had time to do this - if anyone wants to step
> up to the task, please do!
>
> Another item related to this is using HAL_CLOCK_READ in gettimeofday
> so we can get sub-timer tick accuracy.

So it seems gettimeofday() might actually belong into the POSIX compat. 
package. This gives the problem that just to get gettimeofday() the whole 
POSIX compat package has to included, including pthreads, main() and a bunch 
of other things. This seems like a lot of overhead just for gettimeofday().

Do you have a better idea ?

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-04 17:26   ` Alexander Neundorf
@ 2005-10-12 18:47     ` Alexander Neundorf
  2005-10-13 17:13       ` Andrew Lunn
  0 siblings, 1 reply; 26+ messages in thread
From: Alexander Neundorf @ 2005-10-12 18:47 UTC (permalink / raw)
  To: ecos-discuss

[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]

Hi,

attached you can find two patches which add gettimeofday(). This patch is not 
intended to be commited as is, it's just a first attempt, in order to get 
some comments how to do it right.

It does the following:
it adds a very simple sys/time.h to the isoinfra/ package, with the contents 
more or less according to 
http://www.opengroup.org/onlinepubs/000095399/toc.htm.
A simple version of gettimeofday() is included in the header as inline 
function.

Additionally it adds the sys/time.h which currently lives in the tcp/ip 
package to the compat/posix/ package, which overrides the contents of 
isoinfra/include/sys/time.h.

What do you think about this approach ?

If it is ok, I'll prepare a complete patch.
If you think a gettimeofday() implementation doesn't belong in a header in 
isoinfra/ (I guess that will be the case), please suggest a better approach.

If gettimeofday() would be implemented only in the posix package, then e.g. 
the freebsd tcp/ip stack would require the posix compat. package. I don't 
think this would be a good idea, adding the dependency to posix just for a 
single tiny function.
Where would be a better place for gettimeofday(), maybe 
language/c/libc/time/ ? Please let me know.

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net

[-- Attachment #2: isoinfra.patch --]
[-- Type: text/x-diff, Size: 4865 bytes --]

diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/sys/time.h isoinfra/current/include/sys/time.h
--- /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/sys/time.h	1970-01-01 01:00:00.000000000 +0100
+++ isoinfra/current/include/sys/time.h	2005-10-12 18:58:14.000000000 +0200
@@ -0,0 +1,103 @@
+#ifndef CYGONCE_ISO_SYS_TIME_H
+#define CYGONCE_ISO_SYS_TIME_H
+/*========================================================================
+//
+//      sys/time.h
+//
+//      ISO time functions
+//
+//========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2005  Alexander Neundorf
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):     Alexander Neundorf <neundorf@kde.org>
+// Contributors:  
+// Date:          2005-10-04
+// Purpose:       This file provides the time macros, types and functions
+//                required by ISO C and POSIX 1003.1.
+// Description:   The real contents of this file get set from the
+//                configuration (set by the implementation)
+// Usage:         #include <time.h>
+//
+//####DESCRIPTIONEND####
+//
+//======================================================================
+*/
+
+/* CONFIGURATION */
+
+#include <pkgconf/isoinfra.h>          /* Configuration header */
+
+/* INCLUDES */
+
+/* This is the "standard" way to get NULL and size_t from stddef.h,
+ * which is the canonical location of the definitions.
+ */
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
+#include <time.h>
+#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER
+# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER
+#else
+
+/* a very minimalistic sys/time.h */
+
+#include <cyg/kernel/kapi.h>
+
+/*
+ * Structure returned by gettimeofday(2),
+ * and used in other calls such as select(2).
+ */
+struct timeval {
+	time_t	tv_sec;		/* seconds */
+	time_t	tv_usec;	/* and microseconds */
+};
+
+static __inline int gettimeofday(struct timeval *tv, void *restrict)
+{
+   cyg_tick_count_t time_us = cyg_current_time() * (CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR/1000);
+   tv->tv_sec =  time_us / 1000000;
+   tv->tv_usec = time_us % 1000000;
+   return 0;
+}
+
+#endif
+
+
+#endif /* CYGONCE_ISO_SYS_TIME_H multiple inclusion protection */
+
+/* EOF sys/time.h */
diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/time.h isoinfra/current/include/time.h
--- /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/time.h	2002-05-24 01:06:43.000000000 +0200
+++ isoinfra/current/include/time.h	2005-10-12 18:21:15.000000000 +0200
@@ -99,23 +99,7 @@ typedef long clock_t;
 #  define __clock_t_defined
 #endif
 
-#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER
-# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER
-#else
-# ifndef _POSIX_SOURCE
-
-/*
- * Structure returned by gettimeofday(2),
- * and used in other calls such as select(2).
- */
-struct timeval {
-	long	tv_sec;		/* seconds */
-	long	tv_usec;	/* and microseconds */
-};
-
-# endif /* _POSIX_SOURCE */
-#endif
-
+#include <sys/time.h>
 
 #ifdef CYGINT_ISO_POSIX_CLOCK_TYPES
 # include CYGBLD_ISO_POSIX_CLOCK_TYPES_HEADER

[-- Attachment #3: posix.patch --]
[-- Type: text/x-diff, Size: 9899 bytes --]

diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/cdl/posix.cdl compat/posix/current/cdl/posix.cdl
--- /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/cdl/posix.cdl	2003-02-24 15:08:21.000000000 +0100
+++ compat/posix/current/cdl/posix.cdl	2005-10-12 18:49:53.000000000 +0200
@@ -145,6 +145,8 @@ cdl_package CYGPKG_POSIX {
                              "<cyg/posix/time.h>" }
         requires         { CYGBLD_ISO_POSIX_CLOCKS_HEADER == \
                              "<cyg/posix/time.h>" }
+        requires         { CYGBLD_ISO_STRUCTTIMEVAL_HEADER == \
+                             "<cyg/posix/sys/time.h>" }
         requires         CYGPKG_KERNEL
         requires         CYGVAR_KERNEL_COUNTERS_CLOCK
         compile          time.cxx
diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/include/sys/time.h compat/posix/current/include/sys/time.h
--- /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/include/sys/time.h	1970-01-01 01:00:00.000000000 +0100
+++ compat/posix/current/include/sys/time.h	2005-10-12 19:04:41.000000000 +0200
@@ -0,0 +1,219 @@
+//==========================================================================
+//
+//      include/sys/time.h
+//
+//      
+//
+//==========================================================================
+//####BSDCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from OpenBSD or other sources,
+// and are covered by the appropriate copyright disclaimers included herein.
+//
+// -------------------------------------------
+//
+//####BSDCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    gthomas
+// Contributors: gthomas
+// Date:         2000-01-10
+// Purpose:      
+// Description:  
+//              
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+
+/*	$OpenBSD: time.h,v 1.9 1999/12/06 19:36:42 aaron Exp $	*/
+/*	$NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $	*/
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)time.h	8.2 (Berkeley) 7/10/94
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <time.h>
+
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+	long	tv_sec;		/* seconds */
+	long	tv_usec;	/* and microseconds */
+};
+
+
+#define	TIMEVAL_TO_TIMESPEC(tv, ts) {					\
+	(ts)->tv_sec = (tv)->tv_sec;					\
+	(ts)->tv_nsec = (tv)->tv_usec * 1000;				\
+}
+#define	TIMESPEC_TO_TIMEVAL(tv, ts) {					\
+	(tv)->tv_sec = (ts)->tv_sec;					\
+	(tv)->tv_usec = (ts)->tv_nsec / 1000;				\
+}
+
+struct timezone {
+	int	tz_minuteswest;	/* minutes west of Greenwich */
+	int	tz_dsttime;	/* type of dst correction */
+};
+
+#define	DST_NONE	0	/* not on dst */
+#define	DST_USA		1	/* USA style dst */
+#define	DST_AUST	2	/* Australian style dst */
+#define	DST_WET		3	/* Western European dst */
+#define	DST_MET		4	/* Middle European dst */
+#define	DST_EET		5	/* Eastern European dst */
+#define	DST_CAN		6	/* Canada */
+
+/* Operations on timevals. */
+#define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0
+#define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
+#define	timercmp(tvp, uvp, cmp)						\
+	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
+	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
+	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#define	timeradd(tvp, uvp, vvp)						\
+	do {								\
+		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
+		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
+		if ((vvp)->tv_usec >= 1000000) {			\
+			(vvp)->tv_sec++;				\
+			(vvp)->tv_usec -= 1000000;			\
+		}							\
+	} while (0)
+#define	timersub(tvp, uvp, vvp)						\
+	do {								\
+		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
+		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
+		if ((vvp)->tv_usec < 0) {				\
+			(vvp)->tv_sec--;				\
+			(vvp)->tv_usec += 1000000;			\
+		}							\
+	} while (0)
+
+/* Operations on timespecs. */
+#define	timespecclear(tsp)		(tsp)->tv_sec = (tsp)->tv_nsec = 0
+#define	timespecisset(tsp)		((tsp)->tv_sec || (tsp)->tv_nsec)
+#define	timespeccmp(tsp, usp, cmp)					\
+	(((tsp)->tv_sec == (usp)->tv_sec) ?				\
+	    ((tsp)->tv_nsec cmp (usp)->tv_nsec) :			\
+	    ((tsp)->tv_sec cmp (usp)->tv_sec))
+#define	timespecadd(tsp, usp, vsp)					\
+	do {								\
+		(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;		\
+		(vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;	\
+		if ((vsp)->tv_nsec >= 1000000000L) {			\
+			(vsp)->tv_sec++;				\
+			(vsp)->tv_nsec -= 1000000000L;			\
+		}							\
+	} while (0)
+#define	timespecsub(tsp, usp, vsp)					\
+	do {								\
+		(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;		\
+		(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;	\
+		if ((vsp)->tv_nsec < 0) {				\
+			(vsp)->tv_sec--;				\
+			(vsp)->tv_nsec += 1000000000L;			\
+		}							\
+	} while (0)
+
+
+//#if defined(_KERNEL) || defined(_STANDALONE)
+void	microtime __P((struct timeval *tv));
+int	gettimeofday __P((struct timeval *, struct timezone *));
+
+//#endif /* !_KERNEL */
+
+//#endif /* !_SYS_TIME_H_ */
+
+/* the following functions are not supported by eCos */
+#if 0
+
+int	adjtime __P((const struct timeval *, struct timeval *));
+int	clock_getres __P((clockid_t, struct timespec *));
+int	clock_gettime __P((clockid_t, struct timespec *));
+int	clock_settime __P((clockid_t, const struct timespec *));
+int	futimes __P((int, const struct timeval *));
+int	getitimer __P((int, struct itimerval *));
+int	nanosleep __P((const struct timespec *, struct timespec *));
+int	setitimer __P((int, const struct itimerval *, struct itimerval *));
+int	settimeofday __P((const struct timeval *, const struct timezone *));
+int	utimes __P((const char *, const struct timeval *));
+
+
+int	itimerdecr __P((struct itimerval *itp, int usec));
+int	itimerfix __P((struct timeval *tv));
+void	settime __P((struct timeval *tv));
+
+int	adjtime __P((const struct timeval *, struct timeval *));
+int	clock_getres __P((clockid_t, struct timespec *));
+int	clock_gettime __P((clockid_t, struct timespec *));
+int	clock_settime __P((clockid_t, const struct timespec *));
+int	futimes __P((int, const struct timeval *));
+int	getitimer __P((int, struct itimerval *));
+int	nanosleep __P((const struct timespec *, struct timespec *));
+int	setitimer __P((int, const struct itimerval *, struct itimerval *));
+int	settimeofday __P((const struct timeval *, const struct timezone *));
+int	utimes __P((const char *, const struct timeval *));
+
+/*
+ * Structure defined by POSIX.1b to be like a timeval.
+ */
+struct timespec {
+	time_t	tv_sec;		/* seconds */
+	long	tv_nsec;	/* and nanoseconds */
+};
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/src/time.cxx compat/posix/current/src/time.cxx
--- /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/src/time.cxx	2003-01-31 12:53:14.000000000 +0100
+++ compat/posix/current/src/time.cxx	2005-10-12 18:55:46.000000000 +0200
@@ -67,6 +67,7 @@
 #include "pprivate.h"                   // POSIX private header
 
 #include <time.h>                       // our header
+#include <sys/time.h>                   // our header
 
 #include <cyg/kernel/thread.hxx>
 #include <cyg/kernel/clock.hxx>
@@ -311,6 +312,17 @@ externC void cyg_posix_timer_asr( pthrea
 
 #endif // ifdef CYGPKG_POSIX_TIMERS
 
+// Get the current time in a struct timeval
+externC int gettimeofday(struct timeval* tv, struct timezone* tz)
+{
+   struct timespec ts;
+   TIME_ENTRY();
+   cyg_ticks_to_timespec( Cyg_Clock::real_time_clock->current_value(), &ts);
+   tv->tv_sec=ts.tv_sec;
+   tv->tv_usec=ts.tv_nsec/1000;
+   TIME_RETURN(0);
+}
+
 //==========================================================================
 // Clock functions
 


[-- Attachment #4: Type: text/plain, Size: 148 bytes --]

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-12 18:47     ` Alexander Neundorf
@ 2005-10-13 17:13       ` Andrew Lunn
  2005-10-14 19:31         ` Alexander Neundorf
  0 siblings, 1 reply; 26+ messages in thread
From: Andrew Lunn @ 2005-10-13 17:13 UTC (permalink / raw)
  To: Alexander Neundorf; +Cc: ecos-discuss

On Wed, Oct 12, 2005 at 08:12:01PM +0200, Alexander Neundorf wrote:
> Hi,
> 
> attached you can find two patches which add gettimeofday(). This patch is not 
> intended to be commited as is, it's just a first attempt, in order to get 
> some comments how to do it right.
> 
> It does the following:
> it adds a very simple sys/time.h to the isoinfra/ package, with the contents 
> more or less according to 
> http://www.opengroup.org/onlinepubs/000095399/toc.htm.
> A simple version of gettimeofday() is included in the header as inline 
> function.
> 
> Additionally it adds the sys/time.h which currently lives in the tcp/ip 
> package to the compat/posix/ package, which overrides the contents of 
> isoinfra/include/sys/time.h.
> 
> What do you think about this approach ?
> 
> If it is ok, I'll prepare a complete patch.
> If you think a gettimeofday() implementation doesn't belong in a header in 
> isoinfra/ (I guess that will be the case), please suggest a better approach.
> 
> If gettimeofday() would be implemented only in the posix package, then e.g. 
> the freebsd tcp/ip stack would require the posix compat. package. I don't 
> think this would be a good idea, adding the dependency to posix just for a 
> single tiny function.
> Where would be a better place for gettimeofday(), maybe 
> language/c/libc/time/ ? Please let me know.

Jifl message made is clear that the implementation does not belong in
the header file. libc is the wrong as well. The correct place would be
posix since this is a posix function. It might be possible to persuade
me it could go in a package of its own, but i'm not sure about that.

Also your implementation is not so great. Look at Nick's in the ppp
code. Nick's is less arithmetic and less likely to cause an overflow.

Also think about the case when the kernel is not included. Files in
isoinfra should not blindly include kernel header files.

        Andrew


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-13 17:13       ` Andrew Lunn
@ 2005-10-14 19:31         ` Alexander Neundorf
  2005-10-16  9:55           ` Andrew Lunn
                             ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Alexander Neundorf @ 2005-10-14 19:31 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: ecos-discuss

[-- Attachment #1: Type: text/plain, Size: 2868 bytes --]

Hi,

On Thursday 13 October 2005 19:12, Andrew Lunn wrote:
> Jifl message made is clear that the implementation does not belong in
> the header file. libc is the wrong as well. The correct place would be
> posix since this is a posix function. It might be possible to persuade
> me it could go in a package of its own, but i'm not sure about that.

Ok, attached is a new version of the patch (still not meant for inclusion). 
Now gettimeofday() is implemented in posix/src/gettimeofday.cxx. Additionally 
I modified posix.cdl so that gettimeofday.cxx can be compiled separately 
without the rest of the posix package. The rest of the posix package is now 
combined in a CYGPKG_POSIX_BASIC, which is enabled by default, but can be 
disabled now too. Probably the name is not the best.
What do you think ?

> Also your implementation is not so great. Look at Nick's in the ppp
> code. Nick's is less arithmetic and less likely to cause an overflow.

From net/ppp/current/src/sys-ecos.c:

int gettimeofday(struct timeval *tv, struct timezone *tz)
{
    cyg_tick_count_t time = cyg_current_time();
    tv->tv_sec = time/CYGNUM_HAL_RTC_DENOMINATOR;
    tv->tv_usec = (time%CYGNUM_HAL_RTC_DENOMINATOR)*10000;
    return 0;
}

IMHO according to 
http://sources.redhat.com/ecos/docs-latest/ref/hal-clocks-and-timers.html 
also this version is not completely correct:

"CYGNUM_HAL_RTC_NUMERATOR and CYGNUM_HAL_RTC_DENOMINATOR specify the 
resolution of the clock interrupt. [...] The result of dividing the numerator 
by the denominator should correspond to the number of nanoseconds between 
clock interrupts. For example a numerator of 1000000000 and a denominator of 
100 means that there are 10000000 nanoseconds (or 10 milliseconds) between 
clock interrupts."

While the calculation in ppp/ returns the correct result for the numbers as 
given in the documentation, if I understand the documentation correctly, the 
same 10 ms tick could also be specified e.g. with 
CYGNUM_HAL_RTC_NUMERATOR=10000000 and CYGNUM_HAL_RTC_DENOMINATOR=1. The 
documentation doesn't mention that CYGNUM_HAL_RTC_NUMERATOR has always to be 
1,000,000,000.

The version I implemented takes both, NUMERATOR and DENOMINATOR into account. 
The 64 bit of cyg_tick_count_t shouldn't overflow too fast.

int gettimeofday(struct timeval* tv, struct timezone* tz)
{
   cyg_tick_count_t time_us = cyg_current_time() * 
(CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR/1000);
   tv->tv_sec =  time_us / 1000000;
   tv->tv_usec = time_us % 1000000;
   return 0;
}

So, let me know what you think and I'll prepare a complete patch.

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net

[-- Attachment #2: isoinfra.patch --]
[-- Type: text/x-diff, Size: 4529 bytes --]

diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/sys/time.h isoinfra/current/include/sys/time.h
--- /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/sys/time.h	1970-01-01 01:00:00.000000000 +0100
+++ isoinfra/current/include/sys/time.h	2005-10-14 20:53:10.000000000 +0200
@@ -0,0 +1,91 @@
+#ifndef CYGONCE_ISO_SYS_TIME_H
+#define CYGONCE_ISO_SYS_TIME_H
+/*========================================================================
+//
+//      sys/time.h
+//
+//      struct timeval and gettimeofday()
+//
+//========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2005  Alexander Neundorf
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):     Alexander Neundorf <neundorf@kde.org>
+// Contributors:  
+// Date:          2005-10-04
+// Purpose:       This file provides the time macros, types and functions
+//                required by ISO C and POSIX 1003.1.
+// Description:   The real contents of this file get set from the
+//                configuration (set by the implementation)
+// Usage:         #include <time.h>
+//
+//####DESCRIPTIONEND####
+//
+//======================================================================
+*/
+
+/* CONFIGURATION */
+
+#include <pkgconf/isoinfra.h>          /* Configuration header */
+
+/* INCLUDES */
+
+/* This is the "standard" way to get NULL and size_t from stddef.h,
+ * which is the canonical location of the definitions.
+ */
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
+#include <time.h>
+#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER
+# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER
+#else
+
+/*
+ * Structure returned by gettimeofday(2),
+ * and used in other calls such as select(2).
+ */
+struct timeval {
+	time_t	tv_sec;		/* seconds */
+	time_t	tv_usec;	/* and microseconds */
+};
+
+#endif
+
+
+#endif /* CYGONCE_ISO_SYS_TIME_H multiple inclusion protection */
+
+/* EOF sys/time.h */
diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/time.h isoinfra/current/include/time.h
--- /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/time.h	2002-05-24 01:06:43.000000000 +0200
+++ isoinfra/current/include/time.h	2005-10-12 18:21:15.000000000 +0200
@@ -99,23 +99,7 @@ typedef long clock_t;
 #  define __clock_t_defined
 #endif
 
-#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER
-# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER
-#else
-# ifndef _POSIX_SOURCE
-
-/*
- * Structure returned by gettimeofday(2),
- * and used in other calls such as select(2).
- */
-struct timeval {
-	long	tv_sec;		/* seconds */
-	long	tv_usec;	/* and microseconds */
-};
-
-# endif /* _POSIX_SOURCE */
-#endif
-
+#include <sys/time.h>
 
 #ifdef CYGINT_ISO_POSIX_CLOCK_TYPES
 # include CYGBLD_ISO_POSIX_CLOCK_TYPES_HEADER

[-- Attachment #3: posix.patch --]
[-- Type: text/x-diff, Size: 16425 bytes --]

diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/cdl/posix.cdl compat/posix/current/cdl/posix.cdl
--- /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/cdl/posix.cdl	2003-02-24 15:08:21.000000000 +0100
+++ compat/posix/current/cdl/posix.cdl	2005-10-14 20:53:49.000000000 +0200
@@ -49,12 +49,32 @@
 # ====================================================================
 
 cdl_package CYGPKG_POSIX {
+
     display        "POSIX compatibility layer"
     description    "This package enables the POSIX compatibility
                     layer that implements IEEE 1003.1."
     doc            ref/posix-compatibility.html
     include_dir    cyg/posix
     
+    # ----------------------------------------------------------------
+    # gettimeofday()
+    
+    cdl_component CYGPKG_POSIX_GETTIMEOFDAY {
+	display          "POSIX gettimeofday()"
+	flavor           bool
+	default_value    1
+	description      "This component provides the gettimeofday() function"
+        requires         CYGPKG_KERNEL
+        requires         { CYGBLD_ISO_STRUCTTIMEVAL_HEADER == \
+                             "<cyg/posix/sys/time.h>" }
+        
+        compile          gettimeofday.cxx
+    }
+
+    cdl_component CYGPKG_POSIX_BASIC {
+	display          "basic POSIX functions"
+	default_value    1
+
     requires       CYGPKG_KERNEL
     requires       CYGPKG_ISOINFRA
     requires       CYGPKG_ERROR
@@ -94,6 +114,7 @@ cdl_package CYGPKG_POSIX {
         description	"This option defines the POSIX feature test macro
                          for supporting priority ceiling protocol in mutexes."
     }
+    }
     
     # ----------------------------------------------------------------
     # Scheduling component
@@ -105,6 +126,8 @@ cdl_package CYGPKG_POSIX {
 	description      "This component provides controls over scheduling
 	                  in POSIX."
         requires         CYGPKG_POSIX_CLOCKS
+        requires         CYGPKG_POSIX_BASIC
+        active_if        CYGPKG_POSIX_BASIC
         compile          sched.cxx
 
 	cdl_option _POSIX_PRIORITY_SCHEDULING {
@@ -122,6 +145,8 @@ cdl_package CYGPKG_POSIX {
     # Pthreads component
 
     cdl_component CYGPKG_POSIX_PTHREAD {
+        requires         CYGPKG_POSIX_BASIC
+        active_if        CYGPKG_POSIX_BASIC
 	display          "POSIX pthread configuration"
 	flavor           bool
 	default_value    1
@@ -147,6 +172,8 @@ cdl_package CYGPKG_POSIX {
                              "<cyg/posix/time.h>" }
         requires         CYGPKG_KERNEL
         requires         CYGVAR_KERNEL_COUNTERS_CLOCK
+        requires         CYGPKG_POSIX_BASIC
+        active_if        CYGPKG_POSIX_BASIC
         compile          time.cxx
 	description      "This component provides configuration controls for
 	                  the POSIX clocks."
@@ -171,6 +198,8 @@ cdl_package CYGPKG_POSIX {
         requires         CYGPKG_POSIX_PTHREAD
         requires         CYGPKG_POSIX_CLOCKS
         requires         CYGPKG_POSIX_SIGNALS
+        requires         CYGPKG_POSIX_BASIC
+        active_if        CYGPKG_POSIX_BASIC
 	description      "This component provides configuration controls for
 	                  the POSIX timers."
     }
@@ -183,6 +212,8 @@ cdl_package CYGPKG_POSIX {
 	flavor           bool
 	default_value    1
         implements       CYGINT_ISO_SEMAPHORES
+        requires         CYGPKG_POSIX_BASIC
+        active_if        CYGPKG_POSIX_BASIC
         requires         { CYGBLD_ISO_SEMAPHORES_HEADER == \
                              "<cyg/posix/semaphore.h>" }
 	description      "This component provides configuration controls for
@@ -199,6 +230,8 @@ cdl_package CYGPKG_POSIX {
 	flavor           bool
 	default_value    1
         implements       CYGINT_ISO_MQUEUE
+        requires         CYGPKG_POSIX_BASIC
+        active_if        CYGPKG_POSIX_BASIC
         requires         CYGPKG_KERNEL
         requires         CYGINT_ISO_MALLOC
         requires         CYGINT_ISO_ERRNO
@@ -251,6 +284,8 @@ cdl_package CYGPKG_POSIX {
 	requires	 CYGPKG_KERNEL_EXCEPTIONS
         requires         CYGPKG_POSIX_PTHREAD
         requires         CYGPKG_POSIX_TIMERS
+        requires         CYGPKG_POSIX_BASIC
+        active_if        CYGPKG_POSIX_BASIC
         implements       CYGINT_POSIX_REALTIME_SIGNALS
         implements       CYGINT_ISO_SIGSETJMP
         requires         { CYGBLD_ISO_SIGSETJMP_HEADER == \
@@ -273,6 +308,8 @@ cdl_package CYGPKG_POSIX {
 	display           "POSIX utsname configuration"
 	flavor            bool
 	default_value     1
+        requires         CYGPKG_POSIX_BASIC
+        active_if        CYGPKG_POSIX_BASIC
 	requires          { CYGBLD_ISO_UTSNAME_HEADER == \
                             "<cyg/posix/utsname.h>" }
 	description       "This component provides configuration controls for
diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/include/sys/time.h compat/posix/current/include/sys/time.h
--- /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/include/sys/time.h	1970-01-01 01:00:00.000000000 +0100
+++ compat/posix/current/include/sys/time.h	2005-10-12 19:04:41.000000000 +0200
@@ -0,0 +1,219 @@
+//==========================================================================
+//
+//      include/sys/time.h
+//
+//      
+//
+//==========================================================================
+//####BSDCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from OpenBSD or other sources,
+// and are covered by the appropriate copyright disclaimers included herein.
+//
+// -------------------------------------------
+//
+//####BSDCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    gthomas
+// Contributors: gthomas
+// Date:         2000-01-10
+// Purpose:      
+// Description:  
+//              
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+
+/*	$OpenBSD: time.h,v 1.9 1999/12/06 19:36:42 aaron Exp $	*/
+/*	$NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $	*/
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)time.h	8.2 (Berkeley) 7/10/94
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <time.h>
+
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+	long	tv_sec;		/* seconds */
+	long	tv_usec;	/* and microseconds */
+};
+
+
+#define	TIMEVAL_TO_TIMESPEC(tv, ts) {					\
+	(ts)->tv_sec = (tv)->tv_sec;					\
+	(ts)->tv_nsec = (tv)->tv_usec * 1000;				\
+}
+#define	TIMESPEC_TO_TIMEVAL(tv, ts) {					\
+	(tv)->tv_sec = (ts)->tv_sec;					\
+	(tv)->tv_usec = (ts)->tv_nsec / 1000;				\
+}
+
+struct timezone {
+	int	tz_minuteswest;	/* minutes west of Greenwich */
+	int	tz_dsttime;	/* type of dst correction */
+};
+
+#define	DST_NONE	0	/* not on dst */
+#define	DST_USA		1	/* USA style dst */
+#define	DST_AUST	2	/* Australian style dst */
+#define	DST_WET		3	/* Western European dst */
+#define	DST_MET		4	/* Middle European dst */
+#define	DST_EET		5	/* Eastern European dst */
+#define	DST_CAN		6	/* Canada */
+
+/* Operations on timevals. */
+#define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0
+#define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
+#define	timercmp(tvp, uvp, cmp)						\
+	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
+	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
+	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#define	timeradd(tvp, uvp, vvp)						\
+	do {								\
+		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
+		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
+		if ((vvp)->tv_usec >= 1000000) {			\
+			(vvp)->tv_sec++;				\
+			(vvp)->tv_usec -= 1000000;			\
+		}							\
+	} while (0)
+#define	timersub(tvp, uvp, vvp)						\
+	do {								\
+		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
+		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
+		if ((vvp)->tv_usec < 0) {				\
+			(vvp)->tv_sec--;				\
+			(vvp)->tv_usec += 1000000;			\
+		}							\
+	} while (0)
+
+/* Operations on timespecs. */
+#define	timespecclear(tsp)		(tsp)->tv_sec = (tsp)->tv_nsec = 0
+#define	timespecisset(tsp)		((tsp)->tv_sec || (tsp)->tv_nsec)
+#define	timespeccmp(tsp, usp, cmp)					\
+	(((tsp)->tv_sec == (usp)->tv_sec) ?				\
+	    ((tsp)->tv_nsec cmp (usp)->tv_nsec) :			\
+	    ((tsp)->tv_sec cmp (usp)->tv_sec))
+#define	timespecadd(tsp, usp, vsp)					\
+	do {								\
+		(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;		\
+		(vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;	\
+		if ((vsp)->tv_nsec >= 1000000000L) {			\
+			(vsp)->tv_sec++;				\
+			(vsp)->tv_nsec -= 1000000000L;			\
+		}							\
+	} while (0)
+#define	timespecsub(tsp, usp, vsp)					\
+	do {								\
+		(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;		\
+		(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;	\
+		if ((vsp)->tv_nsec < 0) {				\
+			(vsp)->tv_sec--;				\
+			(vsp)->tv_nsec += 1000000000L;			\
+		}							\
+	} while (0)
+
+
+//#if defined(_KERNEL) || defined(_STANDALONE)
+void	microtime __P((struct timeval *tv));
+int	gettimeofday __P((struct timeval *, struct timezone *));
+
+//#endif /* !_KERNEL */
+
+//#endif /* !_SYS_TIME_H_ */
+
+/* the following functions are not supported by eCos */
+#if 0
+
+int	adjtime __P((const struct timeval *, struct timeval *));
+int	clock_getres __P((clockid_t, struct timespec *));
+int	clock_gettime __P((clockid_t, struct timespec *));
+int	clock_settime __P((clockid_t, const struct timespec *));
+int	futimes __P((int, const struct timeval *));
+int	getitimer __P((int, struct itimerval *));
+int	nanosleep __P((const struct timespec *, struct timespec *));
+int	setitimer __P((int, const struct itimerval *, struct itimerval *));
+int	settimeofday __P((const struct timeval *, const struct timezone *));
+int	utimes __P((const char *, const struct timeval *));
+
+
+int	itimerdecr __P((struct itimerval *itp, int usec));
+int	itimerfix __P((struct timeval *tv));
+void	settime __P((struct timeval *tv));
+
+int	adjtime __P((const struct timeval *, struct timeval *));
+int	clock_getres __P((clockid_t, struct timespec *));
+int	clock_gettime __P((clockid_t, struct timespec *));
+int	clock_settime __P((clockid_t, const struct timespec *));
+int	futimes __P((int, const struct timeval *));
+int	getitimer __P((int, struct itimerval *));
+int	nanosleep __P((const struct timespec *, struct timespec *));
+int	setitimer __P((int, const struct itimerval *, struct itimerval *));
+int	settimeofday __P((const struct timeval *, const struct timezone *));
+int	utimes __P((const char *, const struct timeval *));
+
+/*
+ * Structure defined by POSIX.1b to be like a timeval.
+ */
+struct timespec {
+	time_t	tv_sec;		/* seconds */
+	long	tv_nsec;	/* and nanoseconds */
+};
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/src/gettimeofday.cxx compat/posix/current/src/gettimeofday.cxx
--- /usr/src/ecos-stuff/ecos-unchanged/packages/compat/posix/current/src/gettimeofday.cxx	1970-01-01 01:00:00.000000000 +0100
+++ compat/posix/current/src/gettimeofday.cxx	2005-10-13 22:37:23.000000000 +0200
@@ -0,0 +1,76 @@
+//==========================================================================
+//
+//      gettimeofday.cxx
+//
+//      POSIX gettimeofday() function implementation
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):           nickg
+// Contributors:        nickg
+// Date:                2000-03-27
+// Purpose:             POSIX time functions implementation
+// Description:         This file contains the implementation of the POSIX time
+//                      functions.
+//              
+//              
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include <cyg/kernel/kapi.h>          // base kernel types
+
+#include <time.h>                       // our header
+#include <sys/time.h>                   // our header
+
+// Get the current time in a struct timeval
+externC int gettimeofday(struct timeval* tv, struct timezone* tz)
+{
+   cyg_tick_count_t time_us = cyg_current_time() * (CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR/1000);
+   tv->tv_sec =  time_us / 1000000;
+   tv->tv_usec = time_us % 1000000;
+   return 0;
+}
+
+externC void microtime(struct timeval* tv)
+{
+   gettimeofday(tv, 0);
+}
+
+// -------------------------------------------------------------------------
+// EOF gettimeofday.cxx


[-- Attachment #4: Type: text/plain, Size: 148 bytes --]

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-14 19:31         ` Alexander Neundorf
@ 2005-10-16  9:55           ` Andrew Lunn
  2005-10-16 12:36             ` Richard Pennington
  2005-10-19 21:49             ` Alexander Neundorf
  2005-10-16 10:44           ` Peter Korsgaard
  2005-10-17  9:11           ` Nick Garnett
  2 siblings, 2 replies; 26+ messages in thread
From: Andrew Lunn @ 2005-10-16  9:55 UTC (permalink / raw)
  To: Alexander Neundorf; +Cc: Andrew Lunn, ecos-discuss

On Fri, Oct 14, 2005 at 09:30:56PM +0200, Alexander Neundorf wrote:
> Hi,
> 
> On Thursday 13 October 2005 19:12, Andrew Lunn wrote:
> > Jifl message made is clear that the implementation does not belong in
> > the header file. libc is the wrong as well. The correct place would be
> > posix since this is a posix function. It might be possible to persuade
> > me it could go in a package of its own, but i'm not sure about that.
> 
> Ok, attached is a new version of the patch (still not meant for inclusion). 
> Now gettimeofday() is implemented in posix/src/gettimeofday.cxx. Additionally 
> I modified posix.cdl so that gettimeofday.cxx can be compiled separately 
> without the rest of the posix package. The rest of the posix package is now 
> combined in a CYGPKG_POSIX_BASIC, which is enabled by default, but can be 
> disabled now too. Probably the name is not the best.
> What do you think ?

I think this is very ugly....
 
Did you even read posix.cdl?

The POSIX package is already split onto:
1) A generic part for mqueues, mutex and misc function like guid().
2) Scheduling Functions
3) Threads
4) Clocks
5) Timers
6) Semaphores
7) Signals

1) is not optional. Only a very small part goes into libextra.a which
the linker cannot throw away. The rest will only get pulled in when
needed.  It also looks like it would be easy to move mqueues out of
the generic part and into a package of its own. I also think mutex
could be moved, but it is not as obvious from looking at the
code. There might be some dependancies hiding in there i could not see
with just 30s of browsing the code.

All the other parts can be disabled using CDL options.  So your hack
is pretty much redundant.

I suggest you add gettimeofday() to the end of time.cxx.

> 
> > Also your implementation is not so great. Look at Nick's in the ppp
> > code. Nick's is less arithmetic and less likely to cause an overflow.
> 
> From net/ppp/current/src/sys-ecos.c:
> 
> int gettimeofday(struct timeval *tv, struct timezone *tz)
> {
>     cyg_tick_count_t time = cyg_current_time();
>     tv->tv_sec = time/CYGNUM_HAL_RTC_DENOMINATOR;
>     tv->tv_usec = (time%CYGNUM_HAL_RTC_DENOMINATOR)*10000;
>     return 0;
> }
> 
> IMHO according to 
> http://sources.redhat.com/ecos/docs-latest/ref/hal-clocks-and-timers.html 
> also this version is not completely correct:

I will let Nick comment on this. 

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-14 19:31         ` Alexander Neundorf
  2005-10-16  9:55           ` Andrew Lunn
@ 2005-10-16 10:44           ` Peter Korsgaard
  2005-10-16 12:29             ` Andrew Lunn
  2005-10-16 12:39             ` Richard Pennington
  2005-10-17  9:11           ` Nick Garnett
  2 siblings, 2 replies; 26+ messages in thread
From: Peter Korsgaard @ 2005-10-16 10:44 UTC (permalink / raw)
  To: neundorf; +Cc: Andrew Lunn, ecos-discuss

>>>>> "Alexander" == Alexander Neundorf <neundorf@kde.org> writes:

Hi,

 Alexander> From net/ppp/current/src/sys-ecos.c:

 Alexander> int gettimeofday(struct timeval *tv, struct timezone *tz)
 Alexander> {
 Alexander>     cyg_tick_count_t time = cyg_current_time();
 Alexander>     tv->tv_sec = time/CYGNUM_HAL_RTC_DENOMINATOR;
 Alexander>     tv->tv_usec = (time%CYGNUM_HAL_RTC_DENOMINATOR)*10000;
 Alexander>     return 0;
 Alexander> }

Independently of where to put the implementation, it would also be
very interesting to provide sub-tick resolution with HAL_CLOCK_READ -
E.G something like (completely untested):

int gettimeofday(struct timeval *tv, struct timezone *tz)
{
    cyg_uint32 before, after;
    cyg_tick_count_t time;

    /* repeat until we can do a HAL_CLOCK_READ and cyg_current_time
    without getting a timer tick */
    do {
       before = HAL_CLOCK_READ();
       time   = cyg_current_time();
       after  = HAL_CLOCK_READ();
    } while (after < before);

    tv->tv_sec = time/CYGNUM_HAL_RTC_DENOMINATOR;
    tv->tv_usec = (time%CYGNUM_HAL_RTC_DENOMINATOR)*10000;

    tv->tv_usec += (10000/CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION *
       (long long)before) / CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;

    if (tv->tv_usec >= 1000000)
    {
        tv->tv_sec++;
        tv->tv_usec -= 1000000;
    }

    return 0;
}

The do .. while loop may need some HAL_REORDER_BARRIER() calls in
between to make sure gcc doesn't get too clever.

-- 
Bye, Peter Korsgaard

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16 10:44           ` Peter Korsgaard
@ 2005-10-16 12:29             ` Andrew Lunn
  2005-10-16 12:38               ` Gary Thomas
  2005-10-16 15:54               ` Peter Korsgaard
  2005-10-16 12:39             ` Richard Pennington
  1 sibling, 2 replies; 26+ messages in thread
From: Andrew Lunn @ 2005-10-16 12:29 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: ecos-discuss

On Sun, Oct 16, 2005 at 12:45:41PM +0200, Peter Korsgaard wrote:
> >>>>> "Alexander" == Alexander Neundorf <neundorf@kde.org> writes:
> 
> Hi,
> 
>  Alexander> From net/ppp/current/src/sys-ecos.c:
> 
>  Alexander> int gettimeofday(struct timeval *tv, struct timezone *tz)
>  Alexander> {
>  Alexander>     cyg_tick_count_t time = cyg_current_time();
>  Alexander>     tv->tv_sec = time/CYGNUM_HAL_RTC_DENOMINATOR;
>  Alexander>     tv->tv_usec = (time%CYGNUM_HAL_RTC_DENOMINATOR)*10000;
>  Alexander>     return 0;
>  Alexander> }
> 
> Independently of where to put the implementation, it would also be
> very interesting to provide sub-tick resolution with HAL_CLOCK_READ -

Sure, but one problem at a time please....


> E.G something like (completely untested):
> 
> int gettimeofday(struct timeval *tv, struct timezone *tz)
> {
>     cyg_uint32 before, after;
>     cyg_tick_count_t time;
> 
>     /* repeat until we can do a HAL_CLOCK_READ and cyg_current_time
>     without getting a timer tick */
>     do {
>        before = HAL_CLOCK_READ();
>        time   = cyg_current_time();
>        after  = HAL_CLOCK_READ();
>     } while (after < before);
> 

I don't like this. Worse case scenario is that we spin for a complete
eCos tick, typically 10ms. This would happen when the HW timer counter
can only do 10ms ticks. This is probably very rare, but not nice. In
practice the code spins for one HW timer tick.

Thinking allowed here...

We are trying the prevent a mismatch between HAL_CLOCK_READ and
cyg_current_time() becasue the timer interrupt has gone off, but the
DSR has not yet run so that cyg_current_time is one or more ticks
behind. If we don't handle this case the time returned will jump
backwards by up to one eCos tick.

Your code does not work. You are looking for the wrap around
condition. If the hardware timer has wrapped around you assume the
eCos time has been incremented and things are wrong. Actually, it is
the opposite assumption you make. You assume that if the timer has not
wrapped around the eCos counter is correct. This assumption is
false. It could be that the scheduler is locked and the HW timer has
gone off. But since the DSR cannot run the eCos clock is behind by a
tick, or more if the scheduler locked for a long time. Calling
gettimeofday() with the scheduler still locked will allow the HW tick
to increment so fulfilling your test, but the eCos time is still
wrong.

What you need to know is has the hardware timer wrapped around and the
eCos clock not yet ticked. I don't see any easy way to detect this. I
also don't really see what you are going to do even if you could
detect this condition. Spinning is not going to help, since something
is blocking the DSR. 

I think the best you can do is simply combine HAL_CLOCK_READ and
cyg_current_time and store the time you returned. The next time
gettimeofday() is called you compare the current result with the last
and if time has gone backwards you return the old stored value.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16  9:55           ` Andrew Lunn
@ 2005-10-16 12:36             ` Richard Pennington
  2005-10-16 12:44               ` Andrew Lunn
  2005-10-19 21:49             ` Alexander Neundorf
  1 sibling, 1 reply; 26+ messages in thread
From: Richard Pennington @ 2005-10-16 12:36 UTC (permalink / raw)
  To: Alexander Neundorf, Andrew Lunn, ecos-discuss

On Sunday 16 October 2005 04:55 am, Andrew Lunn wrote:
[snip]
> I suggest you add gettimeofday() to the end of time.cxx.

I agree with Andrew that gettimeofday belongs at the end of time.cxx. It is 
amost identical to clock_gettime() (with ns converted to usec).

Is there something about the definition of CLOCK_REALTIME that I don't 
understand that makes clock_gettime() incompatable with gettimeofday()?

-Rich
-- 
Richard Pennington
Email: rich@pennware.com
http://www.pennware.com ftp://ftp.pennware.com

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16 12:29             ` Andrew Lunn
@ 2005-10-16 12:38               ` Gary Thomas
  2005-10-16 12:58                 ` Andrew Lunn
  2005-10-16 15:54               ` Peter Korsgaard
  1 sibling, 1 reply; 26+ messages in thread
From: Gary Thomas @ 2005-10-16 12:38 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Peter Korsgaard, eCos Discussion

On Sun, 2005-10-16 at 14:29 +0200, Andrew Lunn wrote:
> On Sun, Oct 16, 2005 at 12:45:41PM +0200, Peter Korsgaard wrote:
> > >>>>> "Alexander" == Alexander Neundorf <neundorf@kde.org> writes:
> > 
> > Hi,
> > 
> >  Alexander> From net/ppp/current/src/sys-ecos.c:
> > 
> >  Alexander> int gettimeofday(struct timeval *tv, struct timezone *tz)
> >  Alexander> {
> >  Alexander>     cyg_tick_count_t time = cyg_current_time();
> >  Alexander>     tv->tv_sec = time/CYGNUM_HAL_RTC_DENOMINATOR;
> >  Alexander>     tv->tv_usec = (time%CYGNUM_HAL_RTC_DENOMINATOR)*10000;
> >  Alexander>     return 0;
> >  Alexander> }
> > 
> > Independently of where to put the implementation, it would also be
> > very interesting to provide sub-tick resolution with HAL_CLOCK_READ -
> 
> Sure, but one problem at a time please....
> 
> 
> > E.G something like (completely untested):
> > 
> > int gettimeofday(struct timeval *tv, struct timezone *tz)
> > {
> >     cyg_uint32 before, after;
> >     cyg_tick_count_t time;
> > 
> >     /* repeat until we can do a HAL_CLOCK_READ and cyg_current_time
> >     without getting a timer tick */
> >     do {
> >        before = HAL_CLOCK_READ();
> >        time   = cyg_current_time();
> >        after  = HAL_CLOCK_READ();
> >     } while (after < before);
> > 
> 
> I don't like this. Worse case scenario is that we spin for a complete
> eCos tick, typically 10ms. This would happen when the HW timer counter
> can only do 10ms ticks. This is probably very rare, but not nice. In
> practice the code spins for one HW timer tick.
> 
> Thinking allowed here...
> 
> We are trying the prevent a mismatch between HAL_CLOCK_READ and
> cyg_current_time() becasue the timer interrupt has gone off, but the
> DSR has not yet run so that cyg_current_time is one or more ticks
> behind. If we don't handle this case the time returned will jump
> backwards by up to one eCos tick.
> 
> Your code does not work. You are looking for the wrap around
> condition. If the hardware timer has wrapped around you assume the
> eCos time has been incremented and things are wrong. Actually, it is
> the opposite assumption you make. You assume that if the timer has not
> wrapped around the eCos counter is correct. This assumption is
> false. It could be that the scheduler is locked and the HW timer has
> gone off. But since the DSR cannot run the eCos clock is behind by a
> tick, or more if the scheduler locked for a long time. Calling
> gettimeofday() with the scheduler still locked will allow the HW tick
> to increment so fulfilling your test, but the eCos time is still
> wrong.
> 
> What you need to know is has the hardware timer wrapped around and the
> eCos clock not yet ticked. I don't see any easy way to detect this. I
> also don't really see what you are going to do even if you could
> detect this condition. Spinning is not going to help, since something
> is blocking the DSR. 
> 
> I think the best you can do is simply combine HAL_CLOCK_READ and
> cyg_current_time and store the time you returned. The next time
> gettimeofday() is called you compare the current result with the last
> and if time has gone backwards you return the old stored value.

Much better would be to just use HAL_CLOCK_READ() for what it's
designed - it is supposed to return an indication of how much time
has elapsed since the last clock tick.  You can use this to compute
the sub-tick (sub-second) portions of the time-of-day.

For an example of how to use it this way, look at tm_basic


-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16 10:44           ` Peter Korsgaard
  2005-10-16 12:29             ` Andrew Lunn
@ 2005-10-16 12:39             ` Richard Pennington
  1 sibling, 0 replies; 26+ messages in thread
From: Richard Pennington @ 2005-10-16 12:39 UTC (permalink / raw)
  To: ecos-discuss

On Sunday 16 October 2005 05:45 am, Peter Korsgaard wrote:
[snip]
> Independently of where to put the implementation, it would also be
> very interesting to provide sub-tick resolution with HAL_CLOCK_READ -
> E.G something like (completely untested):
>
> int gettimeofday(struct timeval *tv, struct timezone *tz)
> {
>     cyg_uint32 before, after;
>     cyg_tick_count_t time;
>
>     /* repeat until we can do a HAL_CLOCK_READ and cyg_current_time
>     without getting a timer tick */
>     do {
>        before = HAL_CLOCK_READ();
>        time   = cyg_current_time();
>        after  = HAL_CLOCK_READ();
>     } while (after < before);
>
>     tv->tv_sec = time/CYGNUM_HAL_RTC_DENOMINATOR;
>     tv->tv_usec = (time%CYGNUM_HAL_RTC_DENOMINATOR)*10000;
>
>     tv->tv_usec += (10000/CYGNUM_KERNEL_COUNTERS_RTC_RESOLUTION *
>        (long long)before) / CYGNUM_KERNEL_COUNTERS_RTC_PERIOD;
>
>     if (tv->tv_usec >= 1000000)
>     {
>         tv->tv_sec++;
>         tv->tv_usec -= 1000000;
>     }
>
>     return 0;
> }
>
> The do .. while loop may need some HAL_REORDER_BARRIER() calls in
> between to make sure gcc doesn't get too clever.
>
> --
> Bye, Peter Korsgaard

This is cool. This should also be added to the clock_gettime functionality 
(probably in the same underlying code).

-Rich
-- 
Richard Pennington
Email: rich@pennware.com
http://www.pennware.com ftp://ftp.pennware.com

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16 12:36             ` Richard Pennington
@ 2005-10-16 12:44               ` Andrew Lunn
  2005-10-16 12:48                 ` Richard Pennington
  0 siblings, 1 reply; 26+ messages in thread
From: Andrew Lunn @ 2005-10-16 12:44 UTC (permalink / raw)
  To: Richard Pennington; +Cc: ecos-discuss

On Sun, Oct 16, 2005 at 07:36:03AM -0500, Richard Pennington wrote:
> On Sunday 16 October 2005 04:55 am, Andrew Lunn wrote:
> [snip]
> > I suggest you add gettimeofday() to the end of time.cxx.
> 
> I agree with Andrew that gettimeofday belongs at the end of time.cxx. It is 
> amost identical to clock_gettime() (with ns converted to usec).
> 
> Is there something about the definition of CLOCK_REALTIME that I don't 
> understand that makes clock_gettime() incompatable with gettimeofday()?

What do you mean by incompatable? I don't understand the question.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16 12:44               ` Andrew Lunn
@ 2005-10-16 12:48                 ` Richard Pennington
  0 siblings, 0 replies; 26+ messages in thread
From: Richard Pennington @ 2005-10-16 12:48 UTC (permalink / raw)
  To: ecos-discuss

On Sunday 16 October 2005 07:44 am, Andrew Lunn wrote:
> On Sun, Oct 16, 2005 at 07:36:03AM -0500, Richard Pennington wrote:
> > On Sunday 16 October 2005 04:55 am, Andrew Lunn wrote:
> > [snip]
> >
> > > I suggest you add gettimeofday() to the end of time.cxx.
> >
> > I agree with Andrew that gettimeofday belongs at the end of time.cxx. It
> > is amost identical to clock_gettime() (with ns converted to usec).
> >
> > Is there something about the definition of CLOCK_REALTIME that I don't
> > understand that makes clock_gettime() incompatable with gettimeofday()?
>
> What do you mean by incompatable? I don't understand the question.
>
>         Andrew

All I meant was that CLOCK_REALTIME increments just like the (implicit) 
gettimeofday() clock. I'm learning the posix interfaces and wasn't sure if I 
missed some magical meaning.

My main point was that gettimeofday() is virtually identical to 
clock_gettime() except for the units.

-Rich

-- 
Richard Pennington
Email: rich@pennware.com
http://www.pennware.com ftp://ftp.pennware.com

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16 12:38               ` Gary Thomas
@ 2005-10-16 12:58                 ` Andrew Lunn
  0 siblings, 0 replies; 26+ messages in thread
From: Andrew Lunn @ 2005-10-16 12:58 UTC (permalink / raw)
  To: Gary Thomas; +Cc: eCos Discussion

> Much better would be to just use HAL_CLOCK_READ() for what it's
> designed - it is supposed to return an indication of how much time
> has elapsed since the last clock tick.  You can use this to compute
> the sub-tick (sub-second) portions of the time-of-day.
> 
> For an example of how to use it this way, look at tm_basic

Hi Gary

I don't see anything relevent in tm_basic. Maybe i'm missing it? You
use HAL_CLOCK_READ to measure time differences and you always seem to
do it independantly of cyg_current_time(). 

For gettimeofday() we want absolute times, not differences, and we need
to know how HAL_CLOCK_READ relates to cyg_current_time().

Could you explain what you mean in a bit more detail please.

        Thanks
                Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16 12:29             ` Andrew Lunn
  2005-10-16 12:38               ` Gary Thomas
@ 2005-10-16 15:54               ` Peter Korsgaard
  2005-10-17 19:43                 ` Peter Korsgaard
  1 sibling, 1 reply; 26+ messages in thread
From: Peter Korsgaard @ 2005-10-16 15:54 UTC (permalink / raw)
  To: ecos-discuss

>>>>> "Andrew" == Andrew Lunn <andrew@lunn.ch> writes:

 >> Independently of where to put the implementation, it would also be
 >> very interesting to provide sub-tick resolution with HAL_CLOCK_READ -

 Andrew> Sure, but one problem at a time please....

Yes, sorry about that - I just got reminded of the issue with I saw
the gettimeofday implementation..

 >> E.G something like (completely untested):
 >> 
 >> int gettimeofday(struct timeval *tv, struct timezone *tz)
 >> {
 >> cyg_uint32 before, after;
 >> cyg_tick_count_t time;
 >> 
 >> /* repeat until we can do a HAL_CLOCK_READ and cyg_current_time
 >> without getting a timer tick */
 >> do {
 >> before = HAL_CLOCK_READ();
 >> time   = cyg_current_time();
 >> after  = HAL_CLOCK_READ();
 >> } while (after < before);
 >> 

 Andrew> I don't like this. Worse case scenario is that we spin for a complete
 Andrew> eCos tick, typically 10ms. This would happen when the HW timer counter
 Andrew> can only do 10ms ticks. This is probably very rare, but not nice. In
 Andrew> practice the code spins for one HW timer tick.

Sorry, that I don't get. in what situation will the loop be executed
more than twice?

 Andrew> Your code does not work. You are looking for the wrap around
 Andrew> condition. If the hardware timer has wrapped around you assume the
 Andrew> eCos time has been incremented and things are wrong. Actually, it is
 Andrew> the opposite assumption you make. You assume that if the timer has not
 Andrew> wrapped around the eCos counter is correct. This assumption is
 Andrew> false. It could be that the scheduler is locked and the HW timer has
 Andrew> gone off. But since the DSR cannot run the eCos clock is behind by a
 Andrew> tick, or more if the scheduler locked for a long time. Calling
 Andrew> gettimeofday() with the scheduler still locked will allow the HW tick
 Andrew> to increment so fulfilling your test, but the eCos time is still
 Andrew> wrong.

Ah yes, I forgot that the timer isn't updated in the ISR - back to the
drawing board...

 Andrew> I think the best you can do is simply combine HAL_CLOCK_READ and
 Andrew> cyg_current_time and store the time you returned. The next time
 Andrew> gettimeofday() is called you compare the current result with the last
 Andrew> and if time has gone backwards you return the old stored value.

Yes, but that would effectively freeze the clock for a complete tick.

If the problem is that you don't know if the clock DSR has run or not,
perhaps you could do something hackish like this to make sure it hasn't:

cyg_scheduler_lock();

before = HAL_CLOCK_READ();
time   = cyg_current_time();
after  = HAL_CLOCK_READ();

if (after < before)
{
   /* timer overflowed, but DSR hasn't updated cyg_current_time() yet */
   time++;
}

cyg_scheduler_unlock();

.. instead of the do .. while loop. Wouldn't that work?

-- 
Bye, Peter Korsgaard

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-14 19:31         ` Alexander Neundorf
  2005-10-16  9:55           ` Andrew Lunn
  2005-10-16 10:44           ` Peter Korsgaard
@ 2005-10-17  9:11           ` Nick Garnett
  2 siblings, 0 replies; 26+ messages in thread
From: Nick Garnett @ 2005-10-17  9:11 UTC (permalink / raw)
  To: neundorf; +Cc: Andrew Lunn, ecos-discuss

Alexander Neundorf <neundorf@kde.org> writes:

> IMHO according to 
> http://sources.redhat.com/ecos/docs-latest/ref/hal-clocks-and-timers.html 
> also this version is not completely correct:
> 
> "CYGNUM_HAL_RTC_NUMERATOR and CYGNUM_HAL_RTC_DENOMINATOR specify the 
> resolution of the clock interrupt. [...] The result of dividing the numerator 
> by the denominator should correspond to the number of nanoseconds between 
> clock interrupts. For example a numerator of 1000000000 and a denominator of 
> 100 means that there are 10000000 nanoseconds (or 10 milliseconds) between 
> clock interrupts."
> 
> While the calculation in ppp/ returns the correct result for the numbers as 
> given in the documentation, if I understand the documentation correctly, the 
> same 10 ms tick could also be specified e.g. with 
> CYGNUM_HAL_RTC_NUMERATOR=10000000 and CYGNUM_HAL_RTC_DENOMINATOR=1. The 
> documentation doesn't mention that CYGNUM_HAL_RTC_NUMERATOR has always to be 
> 1,000,000,000.
>

Yes. The PPP stack, like the rest of the BSD stack, tends to assume
that clock ticks run at 100Hz. So a calculation of this sort is
generally acceptable.


> The version I implemented takes both, NUMERATOR and DENOMINATOR into account. 
> The 64 bit of cyg_tick_count_t shouldn't overflow too fast.
> 
> int gettimeofday(struct timeval* tv, struct timezone* tz)
> {
>    cyg_tick_count_t time_us = cyg_current_time() * 
> (CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR/1000);
>    tv->tv_sec =  time_us / 1000000;
>    tv->tv_usec = time_us % 1000000;
>    return 0;
> }
> 
> So, let me know what you think and I'll prepare a complete patch.


An alternative implementation that I have used is:

int gettimeofday(struct timeval *tv, struct timezone *tz)
{
    int ticks_per_second = 1000000000/(CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR);    
    cyg_tick_count_t cur_time = cyg_current_time();
    int tix;
    tv->tv_sec = cur_time / ticks_per_second;
    tix = cur_time % ticks_per_second;
    tv->tv_usec = (tix * 1000000)/ticks_per_second;
    return 0;
}

-- 
Nick Garnett                                eCos Kernel Architect
http://www.ecoscentric.com           The eCos and RedBoot experts
>>>> Visit us at stand 230 at The Embedded Systems Show 2005 <<<<
>>>> Oct 19-20 NEC, Birmingham, UK http://www.embedded.co.uk <<<<


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16 15:54               ` Peter Korsgaard
@ 2005-10-17 19:43                 ` Peter Korsgaard
  0 siblings, 0 replies; 26+ messages in thread
From: Peter Korsgaard @ 2005-10-17 19:43 UTC (permalink / raw)
  To: ecos-discuss

>>>>> "Peter" == Peter Korsgaard <jacmet@sunsite.dk> writes:

 Peter> If the problem is that you don't know if the clock DSR has run or not,
 Peter> perhaps you could do something hackish like this to make sure
 Peter> it hasn't:

No, this also doesn't work.

We want to be able to do a HAL_CLOCK_READ() and cyg_current_time() and
want the two values to be in sync. When HAL_CLOCK_READ() reaches
CYGNUM_HAL_RTC_PERIOD an interrupt is generated and the clock is reset
to 0. The DSR will then at some later time be executed and
cyg_current_time() incremented.

If cyg_current_time() was updated in the ISR my routine would work.
What we need to detect is the case of a HAL_CLOCK_READ overflow
(interrupt) having occurred, but the DSR not executed yet. This can be
done by:

1) Updating the counter in the ISR and use that for cyg_current_time()
   (it still needs to be done in the DSR for alarms as well).

2) Set a flag in the ISR that the DSR is pending, clear it in the
   DSR. Increment cyg_current_time if it's set. Alternatively use the
   dsr_count from Cyg_interrupt.

Which of these would be preferred? Or is there a cleaner solution?

-- 
Bye, Peter Korsgaard

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-16  9:55           ` Andrew Lunn
  2005-10-16 12:36             ` Richard Pennington
@ 2005-10-19 21:49             ` Alexander Neundorf
  2005-10-20  7:46               ` Andrew Lunn
  1 sibling, 1 reply; 26+ messages in thread
From: Alexander Neundorf @ 2005-10-19 21:49 UTC (permalink / raw)
  To: ecos-discuss; +Cc: Andrew Lunn

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

On Sunday 16 October 2005 11:55, Andrew Lunn wrote:
...
> I suggest you add gettimeofday() to the end of time.cxx.

Ok, how about the attached version ? 

Additionally I'd like to move the rest of misc.c into its own 
CYGPKG_POSIX_MISC component, but I haven't figured out yet what 
cyg_posix_function_start() and cyg_posix_function_finish() exactly do.
What are they required for ?

I'm not sure that I didn't miss any dependencies, I don't know the _complete_ 
ecos source tree, I guess the maintainers can do this better.

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net

[-- Attachment #2: isoinfra.patch --]
[-- Type: text/x-diff, Size: 4529 bytes --]

diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/sys/time.h isoinfra/current/include/sys/time.h
--- /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/sys/time.h	1970-01-01 01:00:00.000000000 +0100
+++ isoinfra/current/include/sys/time.h	2005-10-14 20:53:10.000000000 +0200
@@ -0,0 +1,91 @@
+#ifndef CYGONCE_ISO_SYS_TIME_H
+#define CYGONCE_ISO_SYS_TIME_H
+/*========================================================================
+//
+//      sys/time.h
+//
+//      struct timeval and gettimeofday()
+//
+//========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2005  Alexander Neundorf
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):     Alexander Neundorf <neundorf@kde.org>
+// Contributors:  
+// Date:          2005-10-04
+// Purpose:       This file provides the time macros, types and functions
+//                required by ISO C and POSIX 1003.1.
+// Description:   The real contents of this file get set from the
+//                configuration (set by the implementation)
+// Usage:         #include <time.h>
+//
+//####DESCRIPTIONEND####
+//
+//======================================================================
+*/
+
+/* CONFIGURATION */
+
+#include <pkgconf/isoinfra.h>          /* Configuration header */
+
+/* INCLUDES */
+
+/* This is the "standard" way to get NULL and size_t from stddef.h,
+ * which is the canonical location of the definitions.
+ */
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
+#include <time.h>
+#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER
+# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER
+#else
+
+/*
+ * Structure returned by gettimeofday(2),
+ * and used in other calls such as select(2).
+ */
+struct timeval {
+	time_t	tv_sec;		/* seconds */
+	time_t	tv_usec;	/* and microseconds */
+};
+
+#endif
+
+
+#endif /* CYGONCE_ISO_SYS_TIME_H multiple inclusion protection */
+
+/* EOF sys/time.h */
diff -rbupN /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/time.h isoinfra/current/include/time.h
--- /usr/src/ecos-stuff/ecos-unchanged/packages/isoinfra/current/include/time.h	2002-05-24 01:06:43.000000000 +0200
+++ isoinfra/current/include/time.h	2005-10-12 18:21:15.000000000 +0200
@@ -99,23 +99,7 @@ typedef long clock_t;
 #  define __clock_t_defined
 #endif
 
-#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER
-# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER
-#else
-# ifndef _POSIX_SOURCE
-
-/*
- * Structure returned by gettimeofday(2),
- * and used in other calls such as select(2).
- */
-struct timeval {
-	long	tv_sec;		/* seconds */
-	long	tv_usec;	/* and microseconds */
-};
-
-# endif /* _POSIX_SOURCE */
-#endif
-
+#include <sys/time.h>
 
 #ifdef CYGINT_ISO_POSIX_CLOCK_TYPES
 # include CYGBLD_ISO_POSIX_CLOCK_TYPES_HEADER

[-- Attachment #3: posix.patch --]
[-- Type: text/x-diff, Size: 15618 bytes --]

diff -rbupN posix.orig/current/ChangeLog posix/current/ChangeLog
--- posix.orig/current/ChangeLog	2004-10-04 13:49:19.000000000 +0200
+++ posix/current/ChangeLog	2005-10-19 23:16:26.000000000 +0200
@@ -1,3 +1,10 @@
+2005-10-18  Alexander Neundorf <neundorf@kde.org>
+
+	src/time.cxx: add gettimeofday() implementation
+        cdl/posix.cdl: make some decriptions a bit more verbose.
+        move mutex.cxx into its own component (CYGPKG_POSIX_PTHREAD_MUTEX).
+        move compilation of mqueue.cxx into the CYGPKG_POSIX_MQUEUES component
+
 2004-10-01  Oyvind Harboe  <oyvind.harboe@zylin.com>
 
 	* src/signal.cxx:  place the CYGBLD_ATTRIB_INIT_PRI such that it
diff -rbupN posix.orig/current/cdl/posix.cdl posix/current/cdl/posix.cdl
--- posix.orig/current/cdl/posix.cdl	2003-02-24 15:08:21.000000000 +0100
+++ posix/current/cdl/posix.cdl	2005-10-19 23:44:28.000000000 +0200
@@ -51,7 +51,10 @@
 cdl_package CYGPKG_POSIX {
     display        "POSIX compatibility layer"
     description    "This package enables the POSIX compatibility
-                    layer that implements IEEE 1003.1."
+                    layer that implements IEEE 1003.1.
+                    Without enabling more components of this package 
+                    it provides the sysconf(),
+                    getXXXid() and setXXXid() functions."
     doc            ref/posix-compatibility.html
     include_dir    cyg/posix
     
@@ -73,9 +76,17 @@ cdl_package CYGPKG_POSIX {
     requires       { CYGBLD_ISO_PTHREAD_MUTEX_HEADER == \
                          "<cyg/posix/mutex.h>" }
     
-    compile        mqueue.cxx mutex.cxx misc.cxx
+    compile        misc.cxx
     compile       -library=libextras.a startup.cxx
 
+    cdl_component CYGPKG_POSIX_PTHREAD_MUTEX {
+
+	display          "POSIX pthread mutexes"
+	flavor           bool
+        compile          mutex.cxx
+	default_value    1
+	description      "This component provides support for POSIX pthreads mutexes."
+
     cdl_option _POSIX_THREAD_PRIO_INHERIT {
         display		"POSIX mutex priority inheritance feature test macro"
         flavor        	bool
@@ -95,6 +106,8 @@ cdl_package CYGPKG_POSIX {
                          for supporting priority ceiling protocol in mutexes."
     }
     
+    }
+    
     # ----------------------------------------------------------------
     # Scheduling component
     
@@ -145,11 +158,14 @@ cdl_package CYGPKG_POSIX {
                              "<cyg/posix/time.h>" }
         requires         { CYGBLD_ISO_POSIX_CLOCKS_HEADER == \
                              "<cyg/posix/time.h>" }
+        requires         { CYGBLD_ISO_STRUCTTIMEVAL_HEADER == \
+                             "<cyg/posix/sys/time.h>" }
         requires         CYGPKG_KERNEL
         requires         CYGVAR_KERNEL_COUNTERS_CLOCK
         compile          time.cxx
 	description      "This component provides configuration controls for
-	                  the POSIX clocks."
+	                  the POSIX clocks and the sleep(), nanosleep()
+                          and gettimeofday() functions."
     }
 
     # ----------------------------------------------------------------
@@ -198,11 +214,13 @@ cdl_package CYGPKG_POSIX {
 	display          "POSIX message queues"
 	flavor           bool
 	default_value    1
+        compile          mqueue.cxx
         implements       CYGINT_ISO_MQUEUE
         requires         CYGPKG_KERNEL
         requires         CYGINT_ISO_MALLOC
         requires         CYGINT_ISO_ERRNO
         requires         CYGINT_ISO_STRING_STRFUNCS
+        requires         CYGPKG_POSIX_PTHREAD_MUTEX
 	description      "This component provides configuration controls for
 	                  POSIX message queues."
 
diff -rbupN posix.orig/current/cdl/pthread.cdl posix/current/cdl/pthread.cdl
--- posix.orig/current/cdl/pthread.cdl	2002-05-24 00:59:56.000000000 +0200
+++ posix/current/cdl/pthread.cdl	2005-10-19 21:42:33.000000000 +0200
@@ -55,6 +55,7 @@ cdl_option CYGPKG_POSIX_PTHREAD_REQUIREM
         implements      CYGINT_ISO_PTHREADTYPES
         implements      CYGINT_ISO_PTHREAD_IMPL
 	requires        CYGPKG_POSIX_SCHED
+        requires        CYGPKG_POSIX_PTHREAD_MUTEX
 	requires	CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE
 	requires	CYGSEM_KERNEL_SCHED_ASR_SUPPORT
 	requires	CYGSEM_KERNEL_SCHED_ASR_GLOBAL
diff -rbupN posix.orig/current/doc/posix.sgml posix/current/doc/posix.sgml
--- posix.orig/current/doc/posix.sgml	2003-02-24 15:08:21.000000000 +0100
+++ posix/current/doc/posix.sgml	2005-10-19 23:20:36.000000000 +0200
@@ -1046,6 +1046,7 @@ int timer&lowbar;settime( timer&lowbar;t
 int timer&lowbar;gettime( timer&lowbar;t timerid, struct itimerspec &ast;value ); 
 int timer&lowbar;getoverrun( timer&lowbar;t timerid ); 
 int nanosleep( const struct timespec &ast;rqtp, struct timespec &ast;rmtp);
+int gettimeofday(struct timeval *tv, struct timezone* tz);
 </screen>
 
 </sect2>
diff -rbupN posix.orig/current/include/sys/time.h posix/current/include/sys/time.h
--- posix.orig/current/include/sys/time.h	1970-01-01 01:00:00.000000000 +0100
+++ posix/current/include/sys/time.h	2005-10-19 22:54:15.000000000 +0200
@@ -0,0 +1,214 @@
+//==========================================================================
+//
+//      include/sys/time.h
+//
+//      
+//
+//==========================================================================
+//####BSDCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from OpenBSD or other sources,
+// and are covered by the appropriate copyright disclaimers included herein.
+//
+// -------------------------------------------
+//
+//####BSDCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    gthomas
+// Contributors: gthomas
+// Date:         2000-01-10
+// Purpose:      
+// Description:  
+//              
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+
+/*	$OpenBSD: time.h,v 1.9 1999/12/06 19:36:42 aaron Exp $	*/
+/*	$NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $	*/
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)time.h	8.2 (Berkeley) 7/10/94
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <time.h>
+
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+	long	tv_sec;		/* seconds */
+	long	tv_usec;	/* and microseconds */
+};
+
+
+#define	TIMEVAL_TO_TIMESPEC(tv, ts) {					\
+	(ts)->tv_sec = (tv)->tv_sec;					\
+	(ts)->tv_nsec = (tv)->tv_usec * 1000;				\
+}
+#define	TIMESPEC_TO_TIMEVAL(tv, ts) {					\
+	(tv)->tv_sec = (ts)->tv_sec;					\
+	(tv)->tv_usec = (ts)->tv_nsec / 1000;				\
+}
+
+struct timezone {
+	int	tz_minuteswest;	/* minutes west of Greenwich */
+	int	tz_dsttime;	/* type of dst correction */
+};
+
+#define	DST_NONE	0	/* not on dst */
+#define	DST_USA		1	/* USA style dst */
+#define	DST_AUST	2	/* Australian style dst */
+#define	DST_WET		3	/* Western European dst */
+#define	DST_MET		4	/* Middle European dst */
+#define	DST_EET		5	/* Eastern European dst */
+#define	DST_CAN		6	/* Canada */
+
+/* Operations on timevals. */
+#define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0
+#define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
+#define	timercmp(tvp, uvp, cmp)						\
+	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
+	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
+	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#define	timeradd(tvp, uvp, vvp)						\
+	do {								\
+		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
+		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
+		if ((vvp)->tv_usec >= 1000000) {			\
+			(vvp)->tv_sec++;				\
+			(vvp)->tv_usec -= 1000000;			\
+		}							\
+	} while (0)
+#define	timersub(tvp, uvp, vvp)						\
+	do {								\
+		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
+		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
+		if ((vvp)->tv_usec < 0) {				\
+			(vvp)->tv_sec--;				\
+			(vvp)->tv_usec += 1000000;			\
+		}							\
+	} while (0)
+
+/* Operations on timespecs. */
+#define	timespecclear(tsp)		(tsp)->tv_sec = (tsp)->tv_nsec = 0
+#define	timespecisset(tsp)		((tsp)->tv_sec || (tsp)->tv_nsec)
+#define	timespeccmp(tsp, usp, cmp)					\
+	(((tsp)->tv_sec == (usp)->tv_sec) ?				\
+	    ((tsp)->tv_nsec cmp (usp)->tv_nsec) :			\
+	    ((tsp)->tv_sec cmp (usp)->tv_sec))
+#define	timespecadd(tsp, usp, vsp)					\
+	do {								\
+		(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;		\
+		(vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;	\
+		if ((vsp)->tv_nsec >= 1000000000L) {			\
+			(vsp)->tv_sec++;				\
+			(vsp)->tv_nsec -= 1000000000L;			\
+		}							\
+	} while (0)
+#define	timespecsub(tsp, usp, vsp)					\
+	do {								\
+		(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;		\
+		(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;	\
+		if ((vsp)->tv_nsec < 0) {				\
+			(vsp)->tv_sec--;				\
+			(vsp)->tv_nsec += 1000000000L;			\
+		}							\
+	} while (0)
+
+
+int	gettimeofday __P((struct timeval *, struct timezone *));
+
+/* the following functions are not supported by eCos */
+#if 0
+
+void	microtime __P((struct timeval *tv));
+int	adjtime __P((const struct timeval *, struct timeval *));
+int	clock_getres __P((clockid_t, struct timespec *));
+int	clock_gettime __P((clockid_t, struct timespec *));
+int	clock_settime __P((clockid_t, const struct timespec *));
+int	futimes __P((int, const struct timeval *));
+int	getitimer __P((int, struct itimerval *));
+int	nanosleep __P((const struct timespec *, struct timespec *));
+int	setitimer __P((int, const struct itimerval *, struct itimerval *));
+int	settimeofday __P((const struct timeval *, const struct timezone *));
+int	utimes __P((const char *, const struct timeval *));
+
+
+int	itimerdecr __P((struct itimerval *itp, int usec));
+int	itimerfix __P((struct timeval *tv));
+void	settime __P((struct timeval *tv));
+
+int	adjtime __P((const struct timeval *, struct timeval *));
+int	clock_getres __P((clockid_t, struct timespec *));
+int	clock_gettime __P((clockid_t, struct timespec *));
+int	clock_settime __P((clockid_t, const struct timespec *));
+int	futimes __P((int, const struct timeval *));
+int	getitimer __P((int, struct itimerval *));
+int	nanosleep __P((const struct timespec *, struct timespec *));
+int	setitimer __P((int, const struct itimerval *, struct itimerval *));
+int	settimeofday __P((const struct timeval *, const struct timezone *));
+int	utimes __P((const char *, const struct timeval *));
+
+/*
+ * Structure defined by POSIX.1b to be like a timeval.
+ */
+struct timespec {
+	time_t	tv_sec;		/* seconds */
+	long	tv_nsec;	/* and nanoseconds */
+};
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff -rbupN posix.orig/current/src/misc.cxx posix/current/src/misc.cxx
--- posix.orig/current/src/misc.cxx	2002-05-24 00:59:59.000000000 +0200
+++ posix/current/src/misc.cxx	2005-10-19 23:43:45.000000000 +0200
@@ -65,7 +65,9 @@
 #include "pprivate.h"                   // POSIX private header
 
 #include <unistd.h>
+#ifdef CYGPKG_POSIX_UTSNAME
 #include <sys/utsname.h>                // My header
+#endif
 #include <string.h>                     // strcpy
 #include <limits.h>
 #include <time.h>
@@ -93,6 +95,7 @@
 // -------------------------------------------------------------------------
 // uname()
 
+#ifdef CYGPKG_POSIX_UTSNAME
 __externC int uname( struct utsname *name )
 {
     CYG_REPORT_FUNCTYPE( "returning %d" );
@@ -106,6 +109,7 @@ __externC int uname( struct utsname *nam
     CYG_REPORT_RETVAL(0);
     return 0;
 }
+#endif
 
 // -------------------------------------------------------------------------
 // sysconf()
diff -rbupN posix.orig/current/src/mqueue.cxx posix/current/src/mqueue.cxx
--- posix.orig/current/src/mqueue.cxx	2003-12-02 06:48:46.000000000 +0100
+++ posix/current/src/mqueue.cxx	2005-10-19 21:32:37.000000000 +0200
@@ -58,8 +58,6 @@
 
 #include <pkgconf/posix.h>
 
-#ifdef CYGPKG_POSIX_MQUEUES
-
 #include <pkgconf/kernel.h>
 
 /* INCLUDES */
@@ -1000,6 +998,4 @@ mq_getattr( mqd_t mqdes, struct mq_attr 
 
 //------------------------------------------------------------------------
 
-#endif // ifdef CYGPKG_POSIX_MQUEUES
-
 /* EOF mqueue.cxx */
diff -rbupN posix.orig/current/src/time.cxx posix/current/src/time.cxx
--- posix.orig/current/src/time.cxx	2003-01-31 12:53:14.000000000 +0100
+++ posix/current/src/time.cxx	2005-10-19 23:40:50.000000000 +0200
@@ -55,8 +55,6 @@
 
 #include <pkgconf/posix.h>
 
-#ifdef CYGPKG_POSIX_CLOCKS
-
 #include <pkgconf/hal.h>
 #include <pkgconf/kernel.h>
 
@@ -67,9 +65,11 @@
 #include "pprivate.h"                   // POSIX private header
 
 #include <time.h>                       // our header
+#include <sys/time.h>
 
 #include <cyg/kernel/thread.hxx>
 #include <cyg/kernel/clock.hxx>
+#include <cyg/kernel/kapi.h>
 
 #include <cyg/kernel/thread.inl>
 #include <cyg/kernel/clock.inl>
@@ -694,7 +694,19 @@ externC unsigned int sleep( unsigned int
     TIME_RETURN(0);
 } 
 
-#endif // ifdef CYGPKG_POSIX_CLOCKS
+// -------------------------------------------------------------------------
+// gettimeofday()
+// Get the current time in a struct timeval
+externC int gettimeofday(struct timeval* tv, struct timezone* tz)
+{
+    int ticks_per_second = 1000000000/(CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR);    
+    cyg_tick_count_t cur_time = cyg_current_time();
+    int tix = cur_time % ticks_per_second;
+    tv->tv_sec = cur_time / ticks_per_second;
+    tv->tv_usec = (tix * 1000000)/ticks_per_second;
+    return 0;
+}
+
 
 // -------------------------------------------------------------------------
 // EOF time.cxx


[-- Attachment #4: Type: text/plain, Size: 148 bytes --]

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-19 21:49             ` Alexander Neundorf
@ 2005-10-20  7:46               ` Andrew Lunn
  2005-10-20  9:06                 ` Nick Garnett
  0 siblings, 1 reply; 26+ messages in thread
From: Andrew Lunn @ 2005-10-20  7:46 UTC (permalink / raw)
  To: Alexander Neundorf; +Cc: ecos-discuss

> Additionally I'd like to move the rest of misc.c into its own 
> CYGPKG_POSIX_MISC component, but I haven't figured out yet what 
> cyg_posix_function_start() and cyg_posix_function_finish() exactly do.
> What are they required for ?

Good question. They are only used in the io/fileio. They are called
when entering or existing all fileio functions. 

They disable and enable ASR. Why i don't know. That is a question for
Nick...

Anyway, it looks like you need these functions when IO/FILEIO is
enabled as well as POSIX. I could not find any other dependancies.

I will take a look at the code later.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-20  7:46               ` Andrew Lunn
@ 2005-10-20  9:06                 ` Nick Garnett
  2005-10-20 17:26                   ` Andrew Lunn
  0 siblings, 1 reply; 26+ messages in thread
From: Nick Garnett @ 2005-10-20  9:06 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Alexander Neundorf, ecos-discuss

Andrew Lunn <andrew@lunn.ch> writes:

> > Additionally I'd like to move the rest of misc.c into its own 
> > CYGPKG_POSIX_MISC component, but I haven't figured out yet what 
> > cyg_posix_function_start() and cyg_posix_function_finish() exactly do.
> > What are they required for ?
> 
> Good question. They are only used in the io/fileio. They are called
> when entering or existing all fileio functions. 
> 
> They disable and enable ASR. Why i don't know. That is a question for
> Nick...

They are used mainly to control the delivery of signals.

As far as the POSIX standard is concerned, most IO calls are atomic,
reflecting their implementation in Unix as system call traps. In eCos
these calls are often composed of a sequence of calls on other
subsystems. If a signal handler is delivered at an arbitrary point, it
may longjump out, or make other calls which will leave some
unsuspecting eCos subsystem with inconsistent data structures. To
avoid this the sensitive functions use cyg_posix_function_start() and
_finish() to block ASR and signal delivery.

Any signals that get queued for a thread will only be delivered during
the _finish() call, although the thread may still be knocked out of
any wait it is in regardless of the subsystem it is currently
executing.


-- 
Nick Garnett                                eCos Kernel Architect
http://www.ecoscentric.com           The eCos and RedBoot experts
>>>> Visit us at stand 230 at The Embedded Systems Show 2005 <<<<
>>>> Oct 19-20 NEC, Birmingham, UK http://www.embedded.co.uk <<<<


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-20  9:06                 ` Nick Garnett
@ 2005-10-20 17:26                   ` Andrew Lunn
  2005-10-20 17:48                     ` Nick Garnett
  0 siblings, 1 reply; 26+ messages in thread
From: Andrew Lunn @ 2005-10-20 17:26 UTC (permalink / raw)
  To: Nick Garnett; +Cc: Alexander Neundorf, ecos-discuss

On Thu, Oct 20, 2005 at 10:06:17AM +0100, Nick Garnett wrote:
> Andrew Lunn <andrew@lunn.ch> writes:
> 
> > > Additionally I'd like to move the rest of misc.c into its own 
> > > CYGPKG_POSIX_MISC component, but I haven't figured out yet what 
> > > cyg_posix_function_start() and cyg_posix_function_finish() exactly do.
> > > What are they required for ?
> > 
> > Good question. They are only used in the io/fileio. They are called
> > when entering or existing all fileio functions. 
> > 
> > They disable and enable ASR. Why i don't know. That is a question for
> > Nick...
> 
> They are used mainly to control the delivery of signals.
> 
> As far as the POSIX standard is concerned, most IO calls are atomic,
> reflecting their implementation in Unix as system call traps. In eCos
> these calls are often composed of a sequence of calls on other
> subsystems. If a signal handler is delivered at an arbitrary point, it
> may longjump out, or make other calls which will leave some
> unsuspecting eCos subsystem with inconsistent data structures. To
> avoid this the sensitive functions use cyg_posix_function_start() and
> _finish() to block ASR and signal delivery.
> 
> Any signals that get queued for a thread will only be delivered during
> the _finish() call, although the thread may still be knocked out of
> any wait it is in regardless of the subsystem it is currently
> executing.

Hi Nick

Thanks for the explanation.

What i don't understand now is why only the fileio package uses these
functions. I would of expected at least the functions in the POSIX
package to also use these.

What am i missing?

        Thanks
                Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-20 17:26                   ` Andrew Lunn
@ 2005-10-20 17:48                     ` Nick Garnett
  2005-10-21 16:19                       ` Alexander Neundorf
  0 siblings, 1 reply; 26+ messages in thread
From: Nick Garnett @ 2005-10-20 17:48 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Alexander Neundorf, ecos-discuss

Andrew Lunn <andrew@lunn.ch> writes:

> 
> Hi Nick
> 
> Thanks for the explanation.
> 
> What i don't understand now is why only the fileio package uses these
> functions. I would of expected at least the functions in the POSIX
> package to also use these.
> 
> What am i missing?

Many of the POSIX package calls are wrappers for straight kernel
calls, or are otherwise immune to the effects of having a signal
handler run. 

-- 
Nick Garnett                                eCos Kernel Architect
http://www.ecoscentric.com           The eCos and RedBoot experts
>>>> Visit us at stand 230 at The Embedded Systems Show 2005 <<<<
>>>> Oct 19-20 NEC, Birmingham, UK http://www.embedded.co.uk <<<<


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-20 17:48                     ` Nick Garnett
@ 2005-10-21 16:19                       ` Alexander Neundorf
  2005-10-21 16:50                         ` Andrew Lunn
  0 siblings, 1 reply; 26+ messages in thread
From: Alexander Neundorf @ 2005-10-21 16:19 UTC (permalink / raw)
  To: Nick Garnett; +Cc: Andrew Lunn, ecos-discuss

[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]

Hi,

On Thursday 20 October 2005 19:48, Nick Garnett wrote:
> Andrew Lunn <andrew@lunn.ch> writes:
> > Hi Nick
> >
> > Thanks for the explanation.
> >
> > What i don't understand now is why only the fileio package uses these
> > functions. I would of expected at least the functions in the POSIX
> > package to also use these.
> >
> > What am i missing?
>
> Many of the POSIX package calls are wrappers for straight kernel
> calls, or are otherwise immune to the effects of having a signal
> handler run.

attached is a new version of the patch, now including even more stuff:

-gettimeofday() in time.cxx (CYGPKG_POSIX_CLOCKS)
-moved cyg_posix_function_start() and _finish() from misc.cxx to pthread.cxx, 
since it seems pthreads and posix signals are the only two users of ASR
-move pthread mutexes into its own component
-make mqueue and pthreads require the mutex component
-move mqueue.cxx into its own component
-use CYG_POSIX_FUNCTION_START only #ifdef CYGPKG_POSIX_PTHREADS instead of 
CYGPKG_POSIX

I hope I got things right.
I didn't change the snmp and FreeBSD stacks so that they use the new 
gettimeofday() function. I would prefer if somebody who actually compiles 
projects which use these packages would do this.

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net

[-- Attachment #2: gettimeofday_and_posix.patch --]
[-- Type: text/x-diff, Size: 26661 bytes --]

diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/ChangeLog packages/compat/posix/current/ChangeLog
--- packages.unmodified/compat/posix/current/ChangeLog	2004-10-04 13:49:19.000000000 +0200
+++ packages/compat/posix/current/ChangeLog	2005-10-19 23:16:26.000000000 +0200
@@ -1,3 +1,10 @@
+2005-10-18  Alexander Neundorf <neundorf@kde.org>
+
+	src/time.cxx: add gettimeofday() implementation
+        cdl/posix.cdl: make some decriptions a bit more verbose.
+        move mutex.cxx into its own component (CYGPKG_POSIX_PTHREAD_MUTEX).
+        move compilation of mqueue.cxx into the CYGPKG_POSIX_MQUEUES component
+
 2004-10-01  Oyvind Harboe  <oyvind.harboe@zylin.com>
 
 	* src/signal.cxx:  place the CYGBLD_ATTRIB_INIT_PRI such that it
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/cdl/posix.cdl packages/compat/posix/current/cdl/posix.cdl
--- packages.unmodified/compat/posix/current/cdl/posix.cdl	2003-02-24 15:08:21.000000000 +0100
+++ packages/compat/posix/current/cdl/posix.cdl	2005-10-19 23:44:28.000000000 +0200
@@ -51,7 +51,10 @@
 cdl_package CYGPKG_POSIX {
     display        "POSIX compatibility layer"
     description    "This package enables the POSIX compatibility
-                    layer that implements IEEE 1003.1."
+                    layer that implements IEEE 1003.1.
+                    Without enabling more components of this package 
+                    it provides the sysconf(),
+                    getXXXid() and setXXXid() functions."
     doc            ref/posix-compatibility.html
     include_dir    cyg/posix
     
@@ -73,9 +76,17 @@ cdl_package CYGPKG_POSIX {
     requires       { CYGBLD_ISO_PTHREAD_MUTEX_HEADER == \
                          "<cyg/posix/mutex.h>" }
     
-    compile        mqueue.cxx mutex.cxx misc.cxx
+    compile        misc.cxx
     compile       -library=libextras.a startup.cxx
 
+    cdl_component CYGPKG_POSIX_PTHREAD_MUTEX {
+
+	display          "POSIX pthread mutexes"
+	flavor           bool
+        compile          mutex.cxx
+	default_value    1
+	description      "This component provides support for POSIX pthreads mutexes."
+
     cdl_option _POSIX_THREAD_PRIO_INHERIT {
         display		"POSIX mutex priority inheritance feature test macro"
         flavor        	bool
@@ -95,6 +106,8 @@ cdl_package CYGPKG_POSIX {
                          for supporting priority ceiling protocol in mutexes."
     }
     
+    }
+    
     # ----------------------------------------------------------------
     # Scheduling component
     
@@ -145,11 +158,14 @@ cdl_package CYGPKG_POSIX {
                              "<cyg/posix/time.h>" }
         requires         { CYGBLD_ISO_POSIX_CLOCKS_HEADER == \
                              "<cyg/posix/time.h>" }
+        requires         { CYGBLD_ISO_STRUCTTIMEVAL_HEADER == \
+                             "<cyg/posix/sys/time.h>" }
         requires         CYGPKG_KERNEL
         requires         CYGVAR_KERNEL_COUNTERS_CLOCK
         compile          time.cxx
 	description      "This component provides configuration controls for
-	                  the POSIX clocks."
+	                  the POSIX clocks and the sleep(), nanosleep()
+                          and gettimeofday() functions."
     }
 
     # ----------------------------------------------------------------
@@ -198,11 +214,13 @@ cdl_package CYGPKG_POSIX {
 	display          "POSIX message queues"
 	flavor           bool
 	default_value    1
+        compile          mqueue.cxx
         implements       CYGINT_ISO_MQUEUE
         requires         CYGPKG_KERNEL
         requires         CYGINT_ISO_MALLOC
         requires         CYGINT_ISO_ERRNO
         requires         CYGINT_ISO_STRING_STRFUNCS
+        requires         CYGPKG_POSIX_PTHREAD_MUTEX
 	description      "This component provides configuration controls for
 	                  POSIX message queues."
 
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/cdl/pthread.cdl packages/compat/posix/current/cdl/pthread.cdl
--- packages.unmodified/compat/posix/current/cdl/pthread.cdl	2002-05-24 00:59:56.000000000 +0200
+++ packages/compat/posix/current/cdl/pthread.cdl	2005-10-19 21:42:33.000000000 +0200
@@ -55,6 +55,7 @@ cdl_option CYGPKG_POSIX_PTHREAD_REQUIREM
         implements      CYGINT_ISO_PTHREADTYPES
         implements      CYGINT_ISO_PTHREAD_IMPL
 	requires        CYGPKG_POSIX_SCHED
+        requires        CYGPKG_POSIX_PTHREAD_MUTEX
 	requires	CYGSEM_KERNEL_SCHED_TIMESLICE_ENABLE
 	requires	CYGSEM_KERNEL_SCHED_ASR_SUPPORT
 	requires	CYGSEM_KERNEL_SCHED_ASR_GLOBAL
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/doc/posix.sgml packages/compat/posix/current/doc/posix.sgml
--- packages.unmodified/compat/posix/current/doc/posix.sgml	2003-02-24 15:08:21.000000000 +0100
+++ packages/compat/posix/current/doc/posix.sgml	2005-10-19 23:20:36.000000000 +0200
@@ -1046,6 +1046,7 @@ int timer&lowbar;settime( timer&lowbar;t
 int timer&lowbar;gettime( timer&lowbar;t timerid, struct itimerspec &ast;value ); 
 int timer&lowbar;getoverrun( timer&lowbar;t timerid ); 
 int nanosleep( const struct timespec &ast;rqtp, struct timespec &ast;rmtp);
+int gettimeofday(struct timeval *tv, struct timezone* tz);
 </screen>
 
 </sect2>
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/include/export.h packages/compat/posix/current/include/export.h
--- packages.unmodified/compat/posix/current/include/export.h	2003-03-19 15:17:23.000000000 +0100
+++ packages/compat/posix/current/include/export.h	2005-10-20 18:49:51.000000000 +0200
@@ -78,6 +78,8 @@
 
 #include <sched.h>              // SCHED_*
 
+#ifdef CYGPKG_POSIX_PTHREAD
+
 //=============================================================================
 // POSIX API function management.
 // These macros should be inserted near the start and all returns of
@@ -109,6 +111,8 @@ __externC void cyg_posix_deliver_signals
 #define CYG_POSIX_DELIVER_SIGNALS cyg_posix_deliver_signals
 #endif
 
+#endif //ifdef CYGPKG_POSIX_PTHREAD
+
 //-----------------------------------------------------------------------------
 #endif // ifndef CYGONCE_POSIX_EXPORT_H
 // End of export.h
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/include/sys/time.h packages/compat/posix/current/include/sys/time.h
--- packages.unmodified/compat/posix/current/include/sys/time.h	1970-01-01 01:00:00.000000000 +0100
+++ packages/compat/posix/current/include/sys/time.h	2005-10-19 22:54:15.000000000 +0200
@@ -0,0 +1,214 @@
+//==========================================================================
+//
+//      include/sys/time.h
+//
+//      
+//
+//==========================================================================
+//####BSDCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from OpenBSD or other sources,
+// and are covered by the appropriate copyright disclaimers included herein.
+//
+// -------------------------------------------
+//
+//####BSDCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    gthomas
+// Contributors: gthomas
+// Date:         2000-01-10
+// Purpose:      
+// Description:  
+//              
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+
+/*	$OpenBSD: time.h,v 1.9 1999/12/06 19:36:42 aaron Exp $	*/
+/*	$NetBSD: time.h,v 1.18 1996/04/23 10:29:33 mycroft Exp $	*/
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *	@(#)time.h	8.2 (Berkeley) 7/10/94
+ */
+
+#ifndef _SYS_TIME_H_
+#define _SYS_TIME_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <sys/types.h>
+#include <sys/cdefs.h>
+#include <time.h>
+
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+	long	tv_sec;		/* seconds */
+	long	tv_usec;	/* and microseconds */
+};
+
+
+#define	TIMEVAL_TO_TIMESPEC(tv, ts) {					\
+	(ts)->tv_sec = (tv)->tv_sec;					\
+	(ts)->tv_nsec = (tv)->tv_usec * 1000;				\
+}
+#define	TIMESPEC_TO_TIMEVAL(tv, ts) {					\
+	(tv)->tv_sec = (ts)->tv_sec;					\
+	(tv)->tv_usec = (ts)->tv_nsec / 1000;				\
+}
+
+struct timezone {
+	int	tz_minuteswest;	/* minutes west of Greenwich */
+	int	tz_dsttime;	/* type of dst correction */
+};
+
+#define	DST_NONE	0	/* not on dst */
+#define	DST_USA		1	/* USA style dst */
+#define	DST_AUST	2	/* Australian style dst */
+#define	DST_WET		3	/* Western European dst */
+#define	DST_MET		4	/* Middle European dst */
+#define	DST_EET		5	/* Eastern European dst */
+#define	DST_CAN		6	/* Canada */
+
+/* Operations on timevals. */
+#define	timerclear(tvp)		(tvp)->tv_sec = (tvp)->tv_usec = 0
+#define	timerisset(tvp)		((tvp)->tv_sec || (tvp)->tv_usec)
+#define	timercmp(tvp, uvp, cmp)						\
+	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
+	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
+	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
+#define	timeradd(tvp, uvp, vvp)						\
+	do {								\
+		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
+		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
+		if ((vvp)->tv_usec >= 1000000) {			\
+			(vvp)->tv_sec++;				\
+			(vvp)->tv_usec -= 1000000;			\
+		}							\
+	} while (0)
+#define	timersub(tvp, uvp, vvp)						\
+	do {								\
+		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
+		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
+		if ((vvp)->tv_usec < 0) {				\
+			(vvp)->tv_sec--;				\
+			(vvp)->tv_usec += 1000000;			\
+		}							\
+	} while (0)
+
+/* Operations on timespecs. */
+#define	timespecclear(tsp)		(tsp)->tv_sec = (tsp)->tv_nsec = 0
+#define	timespecisset(tsp)		((tsp)->tv_sec || (tsp)->tv_nsec)
+#define	timespeccmp(tsp, usp, cmp)					\
+	(((tsp)->tv_sec == (usp)->tv_sec) ?				\
+	    ((tsp)->tv_nsec cmp (usp)->tv_nsec) :			\
+	    ((tsp)->tv_sec cmp (usp)->tv_sec))
+#define	timespecadd(tsp, usp, vsp)					\
+	do {								\
+		(vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;		\
+		(vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;	\
+		if ((vsp)->tv_nsec >= 1000000000L) {			\
+			(vsp)->tv_sec++;				\
+			(vsp)->tv_nsec -= 1000000000L;			\
+		}							\
+	} while (0)
+#define	timespecsub(tsp, usp, vsp)					\
+	do {								\
+		(vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;		\
+		(vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;	\
+		if ((vsp)->tv_nsec < 0) {				\
+			(vsp)->tv_sec--;				\
+			(vsp)->tv_nsec += 1000000000L;			\
+		}							\
+	} while (0)
+
+
+int	gettimeofday __P((struct timeval *, struct timezone *));
+
+/* the following functions are not supported by eCos */
+#if 0
+
+void	microtime __P((struct timeval *tv));
+int	adjtime __P((const struct timeval *, struct timeval *));
+int	clock_getres __P((clockid_t, struct timespec *));
+int	clock_gettime __P((clockid_t, struct timespec *));
+int	clock_settime __P((clockid_t, const struct timespec *));
+int	futimes __P((int, const struct timeval *));
+int	getitimer __P((int, struct itimerval *));
+int	nanosleep __P((const struct timespec *, struct timespec *));
+int	setitimer __P((int, const struct itimerval *, struct itimerval *));
+int	settimeofday __P((const struct timeval *, const struct timezone *));
+int	utimes __P((const char *, const struct timeval *));
+
+
+int	itimerdecr __P((struct itimerval *itp, int usec));
+int	itimerfix __P((struct timeval *tv));
+void	settime __P((struct timeval *tv));
+
+int	adjtime __P((const struct timeval *, struct timeval *));
+int	clock_getres __P((clockid_t, struct timespec *));
+int	clock_gettime __P((clockid_t, struct timespec *));
+int	clock_settime __P((clockid_t, const struct timespec *));
+int	futimes __P((int, const struct timeval *));
+int	getitimer __P((int, struct itimerval *));
+int	nanosleep __P((const struct timespec *, struct timespec *));
+int	setitimer __P((int, const struct itimerval *, struct itimerval *));
+int	settimeofday __P((const struct timeval *, const struct timezone *));
+int	utimes __P((const char *, const struct timeval *));
+
+/*
+ * Structure defined by POSIX.1b to be like a timeval.
+ */
+struct timespec {
+	time_t	tv_sec;		/* seconds */
+	long	tv_nsec;	/* and nanoseconds */
+};
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/src/misc.cxx packages/compat/posix/current/src/misc.cxx
--- packages.unmodified/compat/posix/current/src/misc.cxx	2002-05-24 00:59:59.000000000 +0200
+++ packages/compat/posix/current/src/misc.cxx	2005-10-20 18:55:24.000000000 +0200
@@ -65,7 +65,9 @@
 #include "pprivate.h"                   // POSIX private header
 
 #include <unistd.h>
+#ifdef CYGPKG_POSIX_UTSNAME
 #include <sys/utsname.h>                // My header
+#endif
 #include <string.h>                     // strcpy
 #include <limits.h>
 #include <time.h>
@@ -93,6 +95,7 @@
 // -------------------------------------------------------------------------
 // uname()
 
+#ifdef CYGPKG_POSIX_UTSNAME
 __externC int uname( struct utsname *name )
 {
     CYG_REPORT_FUNCTYPE( "returning %d" );
@@ -106,6 +109,7 @@ __externC int uname( struct utsname *nam
     CYG_REPORT_RETVAL(0);
     return 0;
 }
+#endif
 
 // -------------------------------------------------------------------------
 // sysconf()
@@ -351,36 +355,6 @@ __externC pid_t getpgrp   ( void ) { ret
 __externC pid_t setsid    ( void ) { errno = EPERM; return -1; }
 __externC int   setpgid   ( pid_t pid, pid_t pgid ) { errno = ENOSYS; return -1; }
 
-//==========================================================================
-// Exports to other packages
-
-// -------------------------------------------------------------------------
-// POSIX API function entry
-
-__externC void cyg_posix_function_start()
-{
-    Cyg_Thread *self = Cyg_Scheduler::get_current_thread();
-
-    // Inhibit ASR delivery in this function until it returns.
-    
-    self->set_asr_inhibit();
-}
-
-// -------------------------------------------------------------------------
-
-__externC void cyg_posix_function_finish()
-{
-    Cyg_Thread *self = Cyg_Scheduler::get_current_thread();
-
-    // Re-allow ASR delivery.
-    
-    self->clear_asr_inhibit();
-
-    // After clearing the inhibit flag, blip the scheduler lock
-    // to get any pending ASRs delivered.
-    Cyg_Scheduler::lock();
-    Cyg_Scheduler::unlock();
-}
 
 // -------------------------------------------------------------------------
 // EOF misc.cxx
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/src/mqueue.cxx packages/compat/posix/current/src/mqueue.cxx
--- packages.unmodified/compat/posix/current/src/mqueue.cxx	2003-12-02 06:48:46.000000000 +0100
+++ packages/compat/posix/current/src/mqueue.cxx	2005-10-19 21:32:37.000000000 +0200
@@ -58,8 +58,6 @@
 
 #include <pkgconf/posix.h>
 
-#ifdef CYGPKG_POSIX_MQUEUES
-
 #include <pkgconf/kernel.h>
 
 /* INCLUDES */
@@ -1000,6 +998,4 @@ mq_getattr( mqd_t mqdes, struct mq_attr 
 
 //------------------------------------------------------------------------
 
-#endif // ifdef CYGPKG_POSIX_MQUEUES
-
 /* EOF mqueue.cxx */
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/src/pthread.cxx packages/compat/posix/current/src/pthread.cxx
--- packages.unmodified/compat/posix/current/src/pthread.cxx	2003-11-21 11:53:11.000000000 +0100
+++ packages/compat/posix/current/src/pthread.cxx	2005-10-20 18:55:08.000000000 +0200
@@ -147,6 +147,33 @@ int pthread_canceled_dummy_var;         
 
 //=============================================================================
 // Internal functions
+// -------------------------------------------------------------------------
+// POSIX API function entry
+
+__externC void cyg_posix_function_start()
+{
+    Cyg_Thread *self = Cyg_Scheduler::get_current_thread();
+
+    // Inhibit ASR delivery in this function until it returns.
+    
+    self->set_asr_inhibit();
+}
+
+// -------------------------------------------------------------------------
+
+__externC void cyg_posix_function_finish()
+{
+    Cyg_Thread *self = Cyg_Scheduler::get_current_thread();
+
+    // Re-allow ASR delivery.
+    
+    self->clear_asr_inhibit();
+
+    // After clearing the inhibit flag, blip the scheduler lock
+    // to get any pending ASRs delivered.
+    Cyg_Scheduler::lock();
+    Cyg_Scheduler::unlock();
+}
 
 //-----------------------------------------------------------------------------
 // Private version of pthread_self() that returns a pointer to our internal
diff --exclude=CVS -rbupN packages.unmodified/compat/posix/current/src/time.cxx packages/compat/posix/current/src/time.cxx
--- packages.unmodified/compat/posix/current/src/time.cxx	2003-01-31 12:53:14.000000000 +0100
+++ packages/compat/posix/current/src/time.cxx	2005-10-19 23:40:50.000000000 +0200
@@ -55,8 +55,6 @@
 
 #include <pkgconf/posix.h>
 
-#ifdef CYGPKG_POSIX_CLOCKS
-
 #include <pkgconf/hal.h>
 #include <pkgconf/kernel.h>
 
@@ -67,9 +65,11 @@
 #include "pprivate.h"                   // POSIX private header
 
 #include <time.h>                       // our header
+#include <sys/time.h>
 
 #include <cyg/kernel/thread.hxx>
 #include <cyg/kernel/clock.hxx>
+#include <cyg/kernel/kapi.h>
 
 #include <cyg/kernel/thread.inl>
 #include <cyg/kernel/clock.inl>
@@ -694,7 +694,19 @@ externC unsigned int sleep( unsigned int
     TIME_RETURN(0);
 } 
 
-#endif // ifdef CYGPKG_POSIX_CLOCKS
+// -------------------------------------------------------------------------
+// gettimeofday()
+// Get the current time in a struct timeval
+externC int gettimeofday(struct timeval* tv, struct timezone* tz)
+{
+    int ticks_per_second = 1000000000/(CYGNUM_HAL_RTC_NUMERATOR/CYGNUM_HAL_RTC_DENOMINATOR);    
+    cyg_tick_count_t cur_time = cyg_current_time();
+    int tix = cur_time % ticks_per_second;
+    tv->tv_sec = cur_time / ticks_per_second;
+    tv->tv_usec = (tix * 1000000)/ticks_per_second;
+    return 0;
+}
+
 
 // -------------------------------------------------------------------------
 // EOF time.cxx
diff --exclude=CVS -rbupN packages.unmodified/io/fileio/current/ChangeLog packages/io/fileio/current/ChangeLog
--- packages.unmodified/io/fileio/current/ChangeLog	2005-08-03 23:05:16.000000000 +0200
+++ packages/io/fileio/current/ChangeLog	2005-10-20 20:18:44.000000000 +0200
@@ -1,3 +1,7 @@
+2005-10-18 Alexander Neundorf <neundorf@kde.org>
+        * src/fio.h: use CYG_POSIX_FUNCTION_START/FINISH
+        only #ifdef CYGPKG_POSIX_PTHREAD instead of #ifdef CYGPKG_POSIX
+
 2005-08-02  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* tests/socket.c (SHOW_RESULT): Add a cast to avoid compiler
diff --exclude=CVS -rbupN packages.unmodified/io/fileio/current/src/fio.h packages/io/fileio/current/src/fio.h
--- packages.unmodified/io/fileio/current/src/fio.h	2005-01-22 15:03:37.000000000 +0100
+++ packages/io/fileio/current/src/fio.h	2005-10-20 18:49:05.000000000 +0200
@@ -91,7 +91,7 @@
 //=============================================================================
 // POSIX API support
 
-#ifdef CYGPKG_POSIX
+#ifdef CYGPKG_POSIX_PTHREAD
 #include <pkgconf/posix.h>
 #include <cyg/posix/export.h>
 
diff --exclude=CVS -rbupN packages.unmodified/isoinfra/current/include/sys/time.h packages/isoinfra/current/include/sys/time.h
--- packages.unmodified/isoinfra/current/include/sys/time.h	1970-01-01 01:00:00.000000000 +0100
+++ packages/isoinfra/current/include/sys/time.h	2005-10-14 20:53:10.000000000 +0200
@@ -0,0 +1,91 @@
+#ifndef CYGONCE_ISO_SYS_TIME_H
+#define CYGONCE_ISO_SYS_TIME_H
+/*========================================================================
+//
+//      sys/time.h
+//
+//      struct timeval and gettimeofday()
+//
+//========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2005  Alexander Neundorf
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):     Alexander Neundorf <neundorf@kde.org>
+// Contributors:  
+// Date:          2005-10-04
+// Purpose:       This file provides the time macros, types and functions
+//                required by ISO C and POSIX 1003.1.
+// Description:   The real contents of this file get set from the
+//                configuration (set by the implementation)
+// Usage:         #include <time.h>
+//
+//####DESCRIPTIONEND####
+//
+//======================================================================
+*/
+
+/* CONFIGURATION */
+
+#include <pkgconf/isoinfra.h>          /* Configuration header */
+
+/* INCLUDES */
+
+/* This is the "standard" way to get NULL and size_t from stddef.h,
+ * which is the canonical location of the definitions.
+ */
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+
+#include <time.h>
+#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER
+# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER
+#else
+
+/*
+ * Structure returned by gettimeofday(2),
+ * and used in other calls such as select(2).
+ */
+struct timeval {
+	time_t	tv_sec;		/* seconds */
+	time_t	tv_usec;	/* and microseconds */
+};
+
+#endif
+
+
+#endif /* CYGONCE_ISO_SYS_TIME_H multiple inclusion protection */
+
+/* EOF sys/time.h */
diff --exclude=CVS -rbupN packages.unmodified/isoinfra/current/include/time.h packages/isoinfra/current/include/time.h
--- packages.unmodified/isoinfra/current/include/time.h	2002-05-24 01:06:43.000000000 +0200
+++ packages/isoinfra/current/include/time.h	2005-10-12 18:21:15.000000000 +0200
@@ -99,23 +99,7 @@ typedef long clock_t;
 #  define __clock_t_defined
 #endif
 
-#ifdef CYGBLD_ISO_STRUCTTIMEVAL_HEADER
-# include CYGBLD_ISO_STRUCTTIMEVAL_HEADER
-#else
-# ifndef _POSIX_SOURCE
-
-/*
- * Structure returned by gettimeofday(2),
- * and used in other calls such as select(2).
- */
-struct timeval {
-	long	tv_sec;		/* seconds */
-	long	tv_usec;	/* and microseconds */
-};
-
-# endif /* _POSIX_SOURCE */
-#endif
-
+#include <sys/time.h>
 
 #ifdef CYGINT_ISO_POSIX_CLOCK_TYPES
 # include CYGBLD_ISO_POSIX_CLOCK_TYPES_HEADER
diff --exclude=CVS -rbupN packages.unmodified/language/c/libc/stdio/current/ChangeLog packages/language/c/libc/stdio/current/ChangeLog
--- packages.unmodified/language/c/libc/stdio/current/ChangeLog	2005-07-30 13:44:01.000000000 +0200
+++ packages/language/c/libc/stdio/current/ChangeLog	2005-10-20 20:17:53.000000000 +0200
@@ -1,3 +1,7 @@
+2005-10-18 Alexander Neundorf <neundorf@kde.org>
+        * src/common/fileops.cxx: use CYG_POSIX_FUNCTION_START/FINISH
+        only #ifdef CYGPKG_POSIX_PTHREAD instead of #ifdef CYGPKG_POSIX
+
 2005-07-22  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/common/fopen.cxx (fopen): Default the open mode to Read
diff --exclude=CVS -rbupN packages.unmodified/language/c/libc/stdio/current/src/common/fileops.cxx packages/language/c/libc/stdio/current/src/common/fileops.cxx
--- packages.unmodified/language/c/libc/stdio/current/src/common/fileops.cxx	2004-03-15 17:31:58.000000000 +0100
+++ packages/language/c/libc/stdio/current/src/common/fileops.cxx	2005-10-20 18:48:46.000000000 +0200
@@ -77,7 +77,7 @@
 
 // DEFINES
 
-#ifdef CYGPKG_POSIX
+#ifdef CYGPKG_POSIX_PTHREAD
 # define CYG_STDIO_FUNCTION_START() CYG_POSIX_FUNCTION_START()
 # define CYG_STDIO_FUNCTION_FINISH() CYG_POSIX_FUNCTION_FINISH()
 #else


[-- Attachment #3: Type: text/plain, Size: 148 bytes --]

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-21 16:19                       ` Alexander Neundorf
@ 2005-10-21 16:50                         ` Andrew Lunn
  2005-10-21 17:03                           ` Alexander Neundorf
  0 siblings, 1 reply; 26+ messages in thread
From: Andrew Lunn @ 2005-10-21 16:50 UTC (permalink / raw)
  To: Alexander Neundorf; +Cc: ecos-discuss

On Fri, Oct 21, 2005 at 06:18:40PM +0200, Alexander Neundorf wrote:
> Hi,
> 
> On Thursday 20 October 2005 19:48, Nick Garnett wrote:
> > Andrew Lunn <andrew@lunn.ch> writes:
> > > Hi Nick
> > >
> > > Thanks for the explanation.
> > >
> > > What i don't understand now is why only the fileio package uses these
> > > functions. I would of expected at least the functions in the POSIX
> > > package to also use these.
> > >
> > > What am i missing?
> >
> > Many of the POSIX package calls are wrappers for straight kernel
> > calls, or are otherwise immune to the effects of having a signal
> > handler run.
> 
> attached is a new version of the patch, now including even more stuff:

Upps, sorry. I already started working on your earlier patch. It
breaks lots of things so it is taking a while. 

I suggest you stop working on this until i commit what i've done. You
can then add your new work on top of that.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-21 16:50                         ` Andrew Lunn
@ 2005-10-21 17:03                           ` Alexander Neundorf
  2005-10-21 17:18                             ` Andrew Lunn
  0 siblings, 1 reply; 26+ messages in thread
From: Alexander Neundorf @ 2005-10-21 17:03 UTC (permalink / raw)
  To: ecos-discuss

On Friday 21 October 2005 18:49, Andrew Lunn wrote:
...
> Upps, sorry. I already started working on your earlier patch. 

Nice to hear :-)

> It breaks lots of things so it is taking a while.

What does it break ?

> I suggest you stop working on this until i commit what i've done. You
> can then add your new work on top of that.

Ok

Bye
Alex
-- 
Work: alexander.neundorf@jenoptik.com - http://www.jenoptik-los.de
Home: neundorf@kde.org                - http://www.kde.org
      alex@neundorf.net               - http://www.neundorf.net

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [ECOS] ecos and gettimeofday()
  2005-10-21 17:03                           ` Alexander Neundorf
@ 2005-10-21 17:18                             ` Andrew Lunn
  0 siblings, 0 replies; 26+ messages in thread
From: Andrew Lunn @ 2005-10-21 17:18 UTC (permalink / raw)
  To: Alexander Neundorf; +Cc: ecos-discuss

On Fri, Oct 21, 2005 at 07:03:13PM +0200, Alexander Neundorf wrote:
> On Friday 21 October 2005 18:49, Andrew Lunn wrote:
> ...
> > Upps, sorry. I already started working on your earlier patch. 
> 
> Nice to hear :-)
> 
> > It breaks lots of things so it is taking a while.
> 
> What does it break ?

Select and the test cases.

        Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2005-10-21 17:18 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-30  5:35 [ECOS] ecos and gettimeofday() Alexander Neundorf
     [not found] ` <87achvdsn2.fsf@p4.48ers.dk>
2005-10-04 17:26   ` Alexander Neundorf
2005-10-12 18:47     ` Alexander Neundorf
2005-10-13 17:13       ` Andrew Lunn
2005-10-14 19:31         ` Alexander Neundorf
2005-10-16  9:55           ` Andrew Lunn
2005-10-16 12:36             ` Richard Pennington
2005-10-16 12:44               ` Andrew Lunn
2005-10-16 12:48                 ` Richard Pennington
2005-10-19 21:49             ` Alexander Neundorf
2005-10-20  7:46               ` Andrew Lunn
2005-10-20  9:06                 ` Nick Garnett
2005-10-20 17:26                   ` Andrew Lunn
2005-10-20 17:48                     ` Nick Garnett
2005-10-21 16:19                       ` Alexander Neundorf
2005-10-21 16:50                         ` Andrew Lunn
2005-10-21 17:03                           ` Alexander Neundorf
2005-10-21 17:18                             ` Andrew Lunn
2005-10-16 10:44           ` Peter Korsgaard
2005-10-16 12:29             ` Andrew Lunn
2005-10-16 12:38               ` Gary Thomas
2005-10-16 12:58                 ` Andrew Lunn
2005-10-16 15:54               ` Peter Korsgaard
2005-10-17 19:43                 ` Peter Korsgaard
2005-10-16 12:39             ` Richard Pennington
2005-10-17  9:11           ` Nick Garnett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).