public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
* Wallclock C-api functions
@ 2007-09-01 20:42 Sergei Gavrikov
  2007-09-02 10:30 ` Bart Veer
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Gavrikov @ 2007-09-01 20:42 UTC (permalink / raw)
  To: eCos patches list

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

Hello list,

RFC

I would want to manage the eCos wallclock (to set/get it's time) using a
C API, but, it seems that isn't possible (correct me, please, if I did
miss something). Can we fix that issue using same intervention in the
C++ world?

Thanks.

	Sergei

P.S.

If this isn't ugly, a patch is provided.

[-- Attachment #2: wallclock.h.patch --]
[-- Type: text/x-diff, Size: 3779 bytes --]

diff -urN io/wallclock/current/ChangeLog io/wallclock/current/ChangeLog.new
--- io/wallclock/current/ChangeLog
+++ io/wallclock/current/ChangeLog.new
@@ -1,3 +1,8 @@
+2007-09-01  Sergei Gavrikov  <sg@sgs.gomel.by>
+
+	* include/wallclock.h: New file - add "C" API for wallclock
+	functions.
+
 2007-01-14  Gary Thomas  <gary@mlbassoc.com>
 
 	* src/wallclock.cxx: Use a mutex for exclusion during get/set
diff -urN /dev/null io/wallclock/current/include/wallclock.h
--- /dev/null
+++ io/wallclock/current/include/wallclock.h
@@ -0,0 +1,60 @@
+#ifndef _IO_WALLCLOCK_H_
+#define _IO_WALLCLOCK_H_
+
+//==========================================================================
+//
+//      wallclock.h
+//
+//      C-api to the wallclock
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+// Copyright (C) 2007 eCosCentric Limited
+//
+// 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.
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s):    sergei gavrikov
+// Contributors:
+// Date:         2007-09-01
+// Purpose:      Provide a C-api to the wallclock
+// Description:
+// Usage:        #include <cyg/io/wallclock.h>
+//
+//####DESCRIPTIONEND####
+//
+//===========================================================================*/
+
+#include <cyg/infra/cyg_type.h>
+
+externC cyg_uint32 wallclock_get_current_time(void);
+externC void wallclock_set_current_time(cyg_uint32);
+
+#endif // _IO_WALLCLOCK_H_
diff -urN io/wallclock/current/src/wallclock.cxx io/wallclock/current/src/wallclock.cxx.new
--- io/wallclock/current/src/wallclock.cxx
+++ io/wallclock/current/src/wallclock.cxx.new
@@ -147,5 +147,20 @@
     cyg_drv_mutex_unlock(&wallclock_lock);
 }
 
+// -------------------------------------------------------------------------
+// Implementation of the C-api
+
+externC cyg_uint32
+wallclock_get_current_time(void)
+{
+  return wallclock_instance.get_current_time();
+}
+
+externC void
+wallclock_set_current_time(cyg_uint32 time_stamp)
+{
+  wallclock_instance.set_current_time( time_stamp );
+}
+
 //-----------------------------------------------------------------------------
 // End of devs/wallclock/wallclock.cxx

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

* Re: Wallclock C-api functions
  2007-09-01 20:42 Wallclock C-api functions Sergei Gavrikov
@ 2007-09-02 10:30 ` Bart Veer
  2007-09-02 14:56   ` Sergei Gavrikov
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Veer @ 2007-09-02 10:30 UTC (permalink / raw)
  To: Sergei Gavrikov; +Cc: ecos-patches

>>>>> "Sergei" == Sergei Gavrikov <w3sg@SoftHome.net> writes:

    Sergei> RFC

    Sergei> I would want to manage the eCos wallclock (to set/get it's
    Sergei> time) using a C API, but, it seems that isn't possible
    Sergei> (correct me, please, if I did miss something). Can we fix
    Sergei> that issue using same intervention in the C++ world?

Reading the wallclock is already supported by the standard C library
routines, time() etc., in CYGPKG_LIBC_TIME. Setting the wallclock is
possible via the eCos extension cyg_libc_time_settime() in the same
package. Hence accessing the wallclock via a C API is already
straightforward, and adding equivalent functions to the generic
wallclock package does not gain us anything.

There is an argument for moving the two core functions, time() and
cyg_libc_time_settime() into CYGPKG_IO_WALLCLOCK so that they are
readily available to configurations which do not involve the C
library, but I do not think the gains (if any) are worth the
disruption.

Bart

-- 
Bart Veer                                   eCos Configuration Architect
eCosCentric Limited    The eCos experts      http://www.ecoscentric.com/
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.

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

* Re: Wallclock C-api functions
  2007-09-02 10:30 ` Bart Veer
@ 2007-09-02 14:56   ` Sergei Gavrikov
  0 siblings, 0 replies; 3+ messages in thread
From: Sergei Gavrikov @ 2007-09-02 14:56 UTC (permalink / raw)
  To: Bart Veer; +Cc: ecos-patches

Bart, thank you for your explanation. It's pity what "eCos WallClock" is
an absent section in eCos Reference). And the cyg_libc_time_settime() is
just that what I wanted. The wallclock2.cxx test contains only two calls
from the cyg_libc_time_* set. Thanking you, "nm" did talk me about other
ones.

Thanks!

	Sergei


On Sun, Sep 02, 2007 at 11:30:08AM +0100, Bart Veer wrote:
> >>>>> "Sergei" == Sergei Gavrikov <w3sg@SoftHome.net> writes:
> 
>     Sergei> RFC
> 
>     Sergei> I would want to manage the eCos wallclock (to set/get it's
>     Sergei> time) using a C API, but, it seems that isn't possible
>     Sergei> (correct me, please, if I did miss something). Can we fix
>     Sergei> that issue using same intervention in the C++ world?
> 
> Reading the wallclock is already supported by the standard C library
> routines, time() etc., in CYGPKG_LIBC_TIME. Setting the wallclock is
> possible via the eCos extension cyg_libc_time_settime() in the same
> package. Hence accessing the wallclock via a C API is already
> straightforward, and adding equivalent functions to the generic
> wallclock package does not gain us anything.
> 
> There is an argument for moving the two core functions, time() and
> cyg_libc_time_settime() into CYGPKG_IO_WALLCLOCK so that they are
> readily available to configurations which do not involve the C
> library, but I do not think the gains (if any) are worth the
> disruption.
> 
> Bart
> 
> -- 
> Bart Veer                                   eCos Configuration Architect
> eCosCentric Limited    The eCos experts      http://www.ecoscentric.com/
> Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
> Registered in England and Wales: Reg No 4422071.

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

end of thread, other threads:[~2007-09-02 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-01 20:42 Wallclock C-api functions Sergei Gavrikov
2007-09-02 10:30 ` Bart Veer
2007-09-02 14:56   ` Sergei Gavrikov

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).