From 8a07562c87168a385b715b170cb17a4e2ef4176c Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 28 Sep 2011 19:09:38 +0000 Subject: [PATCH] Change X11 event loop initialization git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3991 42af7a65-404d-4744-a932-0658087f49c3 --- arch/sim/src/Makefile | 17 ++++++++++++----- arch/sim/src/up_internal.h | 14 +------------- arch/sim/src/up_touchscreen.c | 9 ++------- arch/sim/src/up_x11eventloop.c | 25 +++++++++++++++++++------ 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index 0213a69dc2..b3ed39a2c7 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -88,18 +88,25 @@ SRCS = $(ASRCS) $(CSRCS) $(HOSTSRCS) OBJS = $(AOBJS) $(COBJS) $(HOSTOBJS) LDFLAGS = $(ARCHSCRIPT) + +# Determine which standard libraries will need to be linked in + ifeq ($(CONFIG_SIM_X11FB),y) - STDLIBS = -lX11 -lXext -lc -else - STDLIBS = -lc + STDLIBS += -lX11 -lXext +ifeq ($(CONFIG_SIM_TOUCHSCREEN),y) + STDLIBS += -lpthread endif +endif + ifeq ($(CONFIG_FS_FAT),y) -STDLIBS += -lz +STDLIBS += -lz endif +STDLIBS += -lc + LINKOBJS = up_head$(OBJEXT) LINKLIBS = -LDPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS))) +LDPATHS = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS))) LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS)))) all: up_head$(OBJEXT) libarch$(LIBEXT) diff --git a/arch/sim/src/up_internal.h b/arch/sim/src/up_internal.h index 71a2380e21..2a1d9372a1 100644 --- a/arch/sim/src/up_internal.h +++ b/arch/sim/src/up_internal.h @@ -63,18 +63,6 @@ # endif #endif -#ifdef CONFIG_SIM_TOUCHSCREEN -# ifndef CONFIG_SIM_EVLOOPPRIORITY -# define CONFIG_SIM_EVLOOPPRIORITY 50 -# endif -# ifndef CONFIG_SIM_EVLOOPSTACKSIZE -# define CONFIG_SIM_EVLOOPSTACKSIZE 4096 -# endif -#else -# undef CONFIG_SIM_EVLOOPPRIORITY -# undef CONFIG_SIM_EVLOOPSTACKSIZE -#endif - /* Context Switching Definitions ******************************************/ /* Storage order: %ebx, $esi, %edi, %ebp, sp, and return PC */ @@ -174,7 +162,7 @@ extern int up_x11cmap(unsigned short first, unsigned short len, #ifdef CONFIG_SIM_X11FB #ifdef CONFIG_SIM_TOUCHSCREEN -extern int up_x11eventloop(int argc, char *argv[]); +extern int up_x11eventloop(void); #endif #endif diff --git a/arch/sim/src/up_touchscreen.c b/arch/sim/src/up_touchscreen.c index 38e8931285..a4c6be1cb5 100644 --- a/arch/sim/src/up_touchscreen.c +++ b/arch/sim/src/up_touchscreen.c @@ -58,7 +58,6 @@ #include -#include "os_internal.h" #include "up_internal.h" /**************************************************************************** @@ -107,7 +106,6 @@ struct up_dev_s bool penchange; /* An unreported event is buffered */ sem_t devsem; /* Manages exclusive access to this structure */ sem_t waitsem; /* Used to wait for the availability of data */ - pid_t eventloop; /* PID of the eventloop */ struct up_sample_s sample; /* Last sampled touch point data */ @@ -631,7 +629,7 @@ int up_simtouchscreen(int minor) /* Debug-only sanity checks */ - DEBUGASSERT(minor >= 0 && minor < 100 && priv->eventloop == 0); + DEBUGASSERT(minor >= 0 && minor < 100); /* Initialize the touchscreen device driver instance */ @@ -641,15 +639,12 @@ int up_simtouchscreen(int minor) /* Start the X11 event loop */ - ret = KERNEL_THREAD("evloop", CONFIG_SIM_EVLOOPPRIORITY, - CONFIG_SIM_EVLOOPSTACKSIZE, - (main_t)up_x11eventloop, (const char **)NULL); + ret = up_x11eventloop(); if (ret < 0) { idbg("Failed to start event loop: %d\n", ret); goto errout_with_priv; } - priv->eventloop = ret; /* Register the device as an input device */ diff --git a/arch/sim/src/up_x11eventloop.c b/arch/sim/src/up_x11eventloop.c index d28a03ab90..a21f895c96 100644 --- a/arch/sim/src/up_x11eventloop.c +++ b/arch/sim/src/up_x11eventloop.c @@ -38,6 +38,8 @@ ****************************************************************************/ #include +#include + #include /**************************************************************************** @@ -68,6 +70,8 @@ extern int up_tcleave(int x, int y, int buttons); extern Display *g_display; extern Window g_window; +pthread_t g_eventloop; + /**************************************************************************** * Private Variables ****************************************************************************/ @@ -108,15 +112,11 @@ static int up_buttonmap(int state) return ret; } -/**************************************************************************** - * Public Functions - ***************************************************************************/ - /**************************************************************************** * Name: up_x11eventloop ***************************************************************************/ -int up_x11eventloop(int argc, char *argv[]) +static void *up_x11eventthread(void *arg) { XEvent event; int ret; @@ -164,5 +164,18 @@ int up_x11eventloop(int argc, char *argv[]) break; } } - return 0; + return NULL; } + +/**************************************************************************** + * Name: up_x11eventloop + ***************************************************************************/ + +int up_x11eventloop(void) +{ + /* Start the X11 event loop */ + + return pthread_create(&g_eventloop, 0, up_x11eventthread, 0); +} + +