Provided a meaningful clock_time() implementation - which btw. makes the Cygwin variant finally work :-)

This commit is contained in:
oliverschmidt 2007-04-14 23:23:15 +00:00
parent 8b7de528fb
commit f16d041476
5 changed files with 59 additions and 11 deletions

View file

@ -29,7 +29,7 @@
#
# Author: Oliver Schmidt <ol.sc@web.de>
#
# $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)

50
platform/win32/clock.c Normal file
View file

@ -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 <ol.sc@web.de>
*
* $Id: clock.c,v 1.1 2007/04/14 23:23:15 oliverschmidt Exp $
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "contiki.h"
/*-----------------------------------------------------------------------------------*/
clock_time_t
clock_time(void)
{
unsigned long long time;
GetSystemTimeAsFileTime((PFILETIME)&time);
return (clock_time_t)(time / 10000);
}
/*-----------------------------------------------------------------------------------*/

View file

@ -27,8 +27,7 @@ CCIF void debug_printf(char *format, ...);
#include <time.h>
#define CLOCK_CONF_SECOND CLK_TCK
#define CLOCK_CONF_SECOND 1000
typedef unsigned long clock_time_t;

View file

@ -30,7 +30,7 @@
*
* Author: Oliver Schmidt <ol.sc@web.de>
*
* $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)
{

View file

@ -485,6 +485,10 @@
<Filter
Name="win32"
>
<File
RelativePath="..\clock.c"
>
</File>
<File
RelativePath="..\conio.h"
>