Allow VC++ to be used as alternative to GCC for building in the WIN32 target.
TODOs: - Update README - Add dependency handling - Add rtimersupport
This commit is contained in:
parent
f83fb3704b
commit
5da4faf71e
3 changed files with 55 additions and 23 deletions
|
@ -33,14 +33,14 @@
|
|||
* $Id: mtarch.c,v 1.2 2007/04/03 18:37:15 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
static void *main_fiber;
|
||||
|
||||
#else /* __CYGWIN__ */
|
||||
#else /* _WIN32 || __CYGWIN__ */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
|
@ -54,7 +54,7 @@ struct mtarch_t {
|
|||
static ucontext_t main_context;
|
||||
static ucontext_t *running_context;
|
||||
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* _WIN32 || __CYGWIN__ */
|
||||
|
||||
#include "mtarch.h"
|
||||
|
||||
|
@ -62,21 +62,21 @@ static ucontext_t *running_context;
|
|||
void
|
||||
mtarch_init(void)
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
main_fiber = ConvertThreadToFiber(NULL);
|
||||
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* _WIN32 || __CYGWIN__ */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_remove(void)
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
ConvertFiberToThread();
|
||||
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* _WIN32 || __CYGWIN__ */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -84,11 +84,11 @@ mtarch_start(struct mtarch_thread *thread,
|
|||
void (* function)(void *data),
|
||||
void *data)
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
thread->mt_thread = CreateFiber(0, (LPFIBER_START_ROUTINE)function, data);
|
||||
|
||||
#else /* __CYGWIN__ */
|
||||
#else /* _WIN32 || __CYGWIN__ */
|
||||
|
||||
thread->mt_thread = malloc(sizeof(struct mtarch_t));
|
||||
|
||||
|
@ -118,51 +118,51 @@ mtarch_start(struct mtarch_thread *thread,
|
|||
makecontext(&((struct mtarch_t *)thread->mt_thread)->context,
|
||||
(void (*)(void))function, 1, data);
|
||||
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* _WIN32 || __CYGWIN__ */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_yield(void)
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
SwitchToFiber(main_fiber);
|
||||
|
||||
#else /* __CYGWIN__ */
|
||||
#else /* _WIN32 || __CYGWIN__ */
|
||||
|
||||
swapcontext(running_context, &main_context);
|
||||
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* _WIN32 || __CYGWIN__ */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_exec(struct mtarch_thread *thread)
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
SwitchToFiber(thread->mt_thread);
|
||||
|
||||
#else /* __CYGWIN__ */
|
||||
#else /* _WIN32 || __CYGWIN__ */
|
||||
|
||||
running_context = &((struct mtarch_t *)thread->mt_thread)->context;
|
||||
swapcontext(&main_context, running_context);
|
||||
running_context = NULL;
|
||||
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* _WIN32 || __CYGWIN__ */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
mtarch_stop(struct mtarch_thread *thread)
|
||||
{
|
||||
#ifdef __CYGWIN__
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
||||
DeleteFiber(thread->mt_thread);
|
||||
|
||||
#else /* __CYGWIN__ */
|
||||
#else /* _WIN32 || __CYGWIN__ */
|
||||
|
||||
free(thread->mt_thread);
|
||||
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* _WIN32 || __CYGWIN__ */
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
void
|
||||
|
|
|
@ -39,7 +39,9 @@
|
|||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#ifndef _WIN32
|
||||
#include <sys/time.h>
|
||||
#endif /* !_WIN32 */
|
||||
#include <stddef.h>
|
||||
|
||||
#include "sys/rtimer.h"
|
||||
|
@ -64,12 +66,15 @@ interrupt(int sig)
|
|||
void
|
||||
rtimer_arch_init(void)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
signal(SIGALRM, interrupt);
|
||||
#endif /* !_WIN32 */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
rtimer_arch_schedule(rtimer_clock_t t)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct itimerval val;
|
||||
rtimer_clock_t c;
|
||||
|
||||
|
@ -83,5 +88,6 @@ rtimer_arch_schedule(rtimer_clock_t t)
|
|||
|
||||
val.it_interval.tv_sec = val.it_interval.tv_usec = 0;
|
||||
setitimer(ITIMER_REAL, &val, NULL);
|
||||
#endif /* !_WIN32 */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -50,9 +50,11 @@ include $(CONTIKI)/cpu/native/Makefile.native
|
|||
|
||||
ifdef PLATFORM_BUILD
|
||||
CONTIKI_TARGET_SOURCEFILES += dll-loader.c
|
||||
CFLAGS += -DPLATFORM_BUILD -DWITH_LOADER_ARCH -DAUTOSTART_ENABLE
|
||||
CFLAGS += -DPLATFORM_BUILD -DWITH_GUI -DWITH_LOADER_ARCH -DAUTOSTART_ENABLE
|
||||
LDFLAGS += -Wl,--out-implib=contiki-main.$(TARGET).a \
|
||||
-u _cfs_open -u _cfs_opendir -u _uiplib_ipaddrconv
|
||||
LINKFLAGS = -implib:contiki-main.$(TARGET).a $(OBJECTDIR)/program-handler.o \
|
||||
-include:_cfs_open -include:_cfs_opendir -include:_uiplib_ipaddrconv
|
||||
else
|
||||
CONTIKI_TARGET_SOURCEFILES += unload.c
|
||||
endif
|
||||
|
@ -72,7 +74,31 @@ ${foreach PRG,$(PRGS),${eval ${call prg_template,$(PRG),${call appname,$(PRG)}}}
|
|||
${foreach DSC,$(DSCS),${eval ${call dsc_template,$(DSC),${call appname,$(DSC)}}}}
|
||||
|
||||
### Generic module-link rules, no prerequisites here
|
||||
$(PRGS:=.prg):
|
||||
$(LD) -shared $^ contiki-main.$(TARGET).a -o $@
|
||||
$(DSCS:=.dsc):
|
||||
$(PRGS:=.prg) $(DSCS:=.dsc):
|
||||
ifdef VCINSTALLDIR
|
||||
link -nologo -debug -dll $^ contiki-main.$(TARGET).a -out:$@
|
||||
else
|
||||
$(LD) -shared $^ contiki-main.$(TARGET).a -o $@
|
||||
endif
|
||||
|
||||
ifdef VCINSTALLDIR
|
||||
|
||||
VCFLAGS = -Od -Z7 $(filter-out -Wall -g -O,$(CFLAGS))
|
||||
|
||||
CUSTOM_RULE_C_TO_OBJECTDIR_O = 1
|
||||
$(OBJECTDIR)/%.o: %.c
|
||||
cl -nologo $(VCFLAGS) -c $< -Fo$@
|
||||
|
||||
CUSTOM_RULE_C_TO_CO = 1
|
||||
%.co: %.c
|
||||
cl -nologo $(VCFLAGS) -DAUTOSTART_ENABLE -c $< -Fo$@
|
||||
|
||||
CUSTOM_RULE_ALLOBJS_TO_TARGETLIB = 1
|
||||
contiki-$(TARGET).a: $(CONTIKI_OBJECTFILES)
|
||||
lib -nologo $^ -out:$@
|
||||
|
||||
CUSTOM_RULE_LINK = 1
|
||||
%.$(TARGET): %.co $(PROJECT_OBJECTFILES) $(PROJECT_LIBRARIES) contiki-$(TARGET).a
|
||||
link -nologo $(LINKFLAGS) -debug -map:contiki-$(TARGET).map $^ user32.lib ws2_32.lib iphlpapi.lib -out:$@
|
||||
|
||||
endif # VCINSTALLDIR
|
Loading…
Reference in a new issue