From f16d041476103b7ef3cd5e799558e28cb9d22910 Mon Sep 17 00:00:00 2001 From: oliverschmidt Date: Sat, 14 Apr 2007 23:23:15 +0000 Subject: [PATCH] Provided a meaningful clock_time() implementation - which btw. makes the Cygwin variant finally work :-) --- platform/win32/Makefile.win32 | 5 ++- platform/win32/clock.c | 50 ++++++++++++++++++++++++ platform/win32/contiki-conf.h | 3 +- platform/win32/contiki-main.c | 8 +--- platform/win32/vcproj/contiki.exe.vcproj | 4 ++ 5 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 platform/win32/clock.c diff --git a/platform/win32/Makefile.win32 b/platform/win32/Makefile.win32 index 200ffe6f3..c0c80e931 100644 --- a/platform/win32/Makefile.win32 +++ b/platform/win32/Makefile.win32 @@ -29,7 +29,7 @@ # # Author: Oliver Schmidt # -# $Id: Makefile.win32,v 1.3 2007/04/11 01:07:47 oliverschmidt Exp $ +# $Id: Makefile.win32,v 1.4 2007/04/14 23:23:15 oliverschmidt Exp $ # ifndef CONTIKI @@ -41,7 +41,8 @@ TARGET_LIBFILES = /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a CONTIKI_TARGET_DIRS = . cfs ctk loader CONTIKI_TARGET_MAIN = ${addprefix $(OBJECTDIR)/,contiki-main.o} -CONTIKI_TARGET_SOURCEFILES = contiki-main.c cfs-win32.c ctk-console.c dll-loader.c +CONTIKI_TARGET_SOURCEFILES = contiki-main.c clock.c cfs-win32.c ctk-console.c \ + dll-loader.c CONTIKI_SOURCEFILES += $(CTK) ctk-conio-service.c ctk-draw.c wpcap.c wpcap-service.c \ $(CONTIKI_TARGET_SOURCEFILES) diff --git a/platform/win32/clock.c b/platform/win32/clock.c new file mode 100644 index 000000000..e041734a6 --- /dev/null +++ b/platform/win32/clock.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2007, Swedish Institute of Computer Science. + * 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. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. + * + * This file is part of the Contiki operating system. + * + * Author: Oliver Schmidt + * + * $Id: clock.c,v 1.1 2007/04/14 23:23:15 oliverschmidt Exp $ + */ + +#define WIN32_LEAN_AND_MEAN +#include + +#include "contiki.h" + +/*-----------------------------------------------------------------------------------*/ +clock_time_t +clock_time(void) +{ + unsigned long long time; + + GetSystemTimeAsFileTime((PFILETIME)&time); + return (clock_time_t)(time / 10000); +} +/*-----------------------------------------------------------------------------------*/ diff --git a/platform/win32/contiki-conf.h b/platform/win32/contiki-conf.h index 7a2bce981..d7dd3a3b4 100644 --- a/platform/win32/contiki-conf.h +++ b/platform/win32/contiki-conf.h @@ -27,8 +27,7 @@ CCIF void debug_printf(char *format, ...); -#include -#define CLOCK_CONF_SECOND CLK_TCK +#define CLOCK_CONF_SECOND 1000 typedef unsigned long clock_time_t; diff --git a/platform/win32/contiki-main.c b/platform/win32/contiki-main.c index 7d363a5b8..78fe2f2d3 100644 --- a/platform/win32/contiki-main.c +++ b/platform/win32/contiki-main.c @@ -30,7 +30,7 @@ * * Author: Oliver Schmidt * - * $Id: contiki-main.c,v 1.7 2007/04/14 14:57:19 oliverschmidt Exp $ + * $Id: contiki-main.c,v 1.8 2007/04/14 23:23:15 oliverschmidt Exp $ */ #define WIN32_LEAN_AND_MEAN @@ -89,12 +89,6 @@ log_message(const char *part1, const char *part2) debug_printf("%s%s\n", part1, part2); } /*-----------------------------------------------------------------------------------*/ -clock_time_t -clock_time(void) -{ - return clock(); -} -/*-----------------------------------------------------------------------------------*/ int main(void) { diff --git a/platform/win32/vcproj/contiki.exe.vcproj b/platform/win32/vcproj/contiki.exe.vcproj index eb3cca0ec..70219a8a3 100644 --- a/platform/win32/vcproj/contiki.exe.vcproj +++ b/platform/win32/vcproj/contiki.exe.vcproj @@ -485,6 +485,10 @@ + +