This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Wallclock C-api functions
- From: Sergei Gavrikov <w3sg at SoftHome dot net>
- To: eCos patches list <ecos-patches at ecos dot sourceware dot org>
- Date: Sat, 1 Sep 2007 23:38:44 +0300
- Subject: Wallclock C-api functions
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.
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