Change Linux-centric clone() to POSIX threads for portability (Daryl Fonseca-Holt)
This commit is contained in:
+25
-2
@@ -263,9 +263,31 @@ dnl else
|
|||||||
])
|
])
|
||||||
;;
|
;;
|
||||||
lis)
|
lis)
|
||||||
|
AC_CHECK_HEADERS([pthread.h],[
|
||||||
|
AC_CHECK_LIB(pthread, pthread_create,[
|
||||||
|
LIBPTHREAD_LIBS="-lpthread"
|
||||||
|
ac_cv_lis_pthread=yes
|
||||||
|
],[
|
||||||
|
dnl else
|
||||||
|
ac_cv_lis_pthread=no
|
||||||
|
AC_MSG_WARN([The lis driver needs the pthread library and pthread_create() from it])
|
||||||
|
])
|
||||||
|
],[
|
||||||
|
dnl else
|
||||||
|
ac_cv_lis_pthread=no
|
||||||
|
AC_MSG_WARN([The lis driver needs pthread.h])
|
||||||
|
])
|
||||||
if test "$enable_libftdi" = yes ; then
|
if test "$enable_libftdi" = yes ; then
|
||||||
DRIVERS="$DRIVERS lis${SO}"
|
if test "$enable_libusb" = yes; then
|
||||||
actdrivers=["$actdrivers lis"]
|
if test "$ac_cv_lis_pthread" = yes; then
|
||||||
|
DRIVERS="$DRIVERS lis${SO}"
|
||||||
|
actdrivers=["$actdrivers lis"]
|
||||||
|
else
|
||||||
|
AC_MSG_WARN([The lis driver needs the pthread library])
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
AC_MSG_WARN([The lis driver needs the usb library])
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
AC_MSG_WARN([The lis driver needs the ftdi library])
|
AC_MSG_WARN([The lis driver needs the ftdi library])
|
||||||
fi
|
fi
|
||||||
@@ -423,6 +445,7 @@ AC_SUBST(LIBG15)
|
|||||||
AC_SUBST(LIBGLCD)
|
AC_SUBST(LIBGLCD)
|
||||||
AC_SUBST(LIBFTDI)
|
AC_SUBST(LIBFTDI)
|
||||||
AC_SUBST(LIBXOSD)
|
AC_SUBST(LIBXOSD)
|
||||||
|
AC_SUBST(LIBPTHREAD_LIBS)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ noinst_LIBRARIES = libLCD.a libbignum.a
|
|||||||
IOWarrior_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
IOWarrior_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
||||||
hd44780_CFLAGS = @LIBUSB_CFLAGS@ @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
hd44780_CFLAGS = @LIBUSB_CFLAGS@ @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
||||||
g15_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
g15_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
||||||
lis_CFLAGS = @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
lis_CFLAGS = @LIBUSB_CFLAGS@ @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
||||||
picolcd_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
picolcd_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
||||||
shuttleVFD_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
shuttleVFD_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
|
||||||
ula200_CFLAGS = @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
ula200_CFLAGS = @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
|
||||||
@@ -45,7 +45,7 @@ IOWarrior_LDADD = @LIBUSB_LIBS@ libLCD.a libbignum.a
|
|||||||
irman_LDADD = @LIBIRMAN@
|
irman_LDADD = @LIBIRMAN@
|
||||||
lcterm_LDADD = libLCD.a
|
lcterm_LDADD = libLCD.a
|
||||||
lirc_LDADD = @LIBLIRC_CLIENT@
|
lirc_LDADD = @LIBLIRC_CLIENT@
|
||||||
lis_LDADD = libLCD.a @LIBFTDI_LIBS@ libbignum.a
|
lis_LDADD = libLCD.a @LIBFTDI_LIBS@ @LIBUSB_LIBS@ @LIBPTHREAD_LIBS@ libbignum.a
|
||||||
MD8800_LDADD = libLCD.a
|
MD8800_LDADD = libLCD.a
|
||||||
mtc_s16209x_LDADD = libLCD.a
|
mtc_s16209x_LDADD = libLCD.a
|
||||||
MtxOrb_LDADD = libLCD.a libbignum.a
|
MtxOrb_LDADD = libLCD.a libbignum.a
|
||||||
|
|||||||
+13
-11
@@ -45,6 +45,8 @@
|
|||||||
* 2007/05/30 Remove set_custom_chars(). Implement
|
* 2007/05/30 Remove set_custom_chars(). Implement
|
||||||
* lis_set_chars(), lis_vbar(), lis_hbar()
|
* lis_set_chars(), lis_vbar(), lis_hbar()
|
||||||
* and lis_num() using helper functions.
|
* and lis_num() using helper functions.
|
||||||
|
* 2007/11/01 Change Linux-centric clone() to POSIX
|
||||||
|
* threads for portability.
|
||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -54,6 +56,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
#include <ftdi.h>
|
#include <ftdi.h>
|
||||||
@@ -367,8 +370,9 @@ lis_init(Driver *drvthis)
|
|||||||
PrivateData *p;
|
PrivateData *p;
|
||||||
int err;
|
int err;
|
||||||
const char *s;
|
const char *s;
|
||||||
unsigned char buffer[64], *thread_stack;
|
unsigned char buffer[64];
|
||||||
int count;
|
int count;
|
||||||
|
pthread_t read_thread;
|
||||||
|
|
||||||
report(RPT_DEBUG, "%s: Initializing driver",
|
report(RPT_DEBUG, "%s: Initializing driver",
|
||||||
drvthis->name);
|
drvthis->name);
|
||||||
@@ -502,16 +506,14 @@ lis_init(Driver *drvthis)
|
|||||||
goto err_ftdi;
|
goto err_ftdi;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone a thread to keep a read up on the device
|
// create a thread to keep a read up on the device
|
||||||
thread_stack = calloc(4096, 1);
|
err = pthread_create( &read_thread,
|
||||||
if(! thread_stack) {
|
NULL,
|
||||||
report(RPT_ERR, "%s: cannot create thread stack", drvthis->name);
|
(void *) lis_read_thread,
|
||||||
goto err_framebuf;
|
drvthis
|
||||||
}
|
);
|
||||||
|
if (err) {
|
||||||
err = clone(lis_read_thread, thread_stack+4092, CLONE_VM | CLONE_THREAD| CLONE_SIGHAND, drvthis);
|
report(RPT_ERR, "%s: pthread_create() - %s", drvthis->name, err);
|
||||||
if (err == -1) {
|
|
||||||
report(RPT_ERR, "%s: clone() - %s", drvthis->name, strerror(errno));
|
|
||||||
goto err_framebuf;
|
goto err_framebuf;
|
||||||
}
|
}
|
||||||
p->parent_flag = 1; // show we're now a happy parent, birth successful.
|
p->parent_flag = 1; // show we're now a happy parent, birth successful.
|
||||||
|
|||||||
Reference in New Issue
Block a user