Change Linux-centric clone() to POSIX threads for portability (Daryl Fonseca-Holt)

This commit is contained in:
marschap
2007-11-10 19:41:46 +00:00
parent cdd1c13711
commit a21f727566
3 changed files with 40 additions and 15 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ noinst_LIBRARIES = libLCD.a libbignum.a
IOWarrior_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
hd44780_CFLAGS = @LIBUSB_CFLAGS@ @LIBFTDI_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)
shuttleVFD_CFLAGS = @LIBUSB_CFLAGS@ $(AM_CFLAGS)
ula200_CFLAGS = @LIBFTDI_CFLAGS@ $(AM_CFLAGS)
@@ -45,7 +45,7 @@ IOWarrior_LDADD = @LIBUSB_LIBS@ libLCD.a libbignum.a
irman_LDADD = @LIBIRMAN@
lcterm_LDADD = libLCD.a
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
mtc_s16209x_LDADD = libLCD.a
MtxOrb_LDADD = libLCD.a libbignum.a
+13 -11
View File
@@ -45,6 +45,8 @@
* 2007/05/30 Remove set_custom_chars(). Implement
* lis_set_chars(), lis_vbar(), lis_hbar()
* and lis_num() using helper functions.
* 2007/11/01 Change Linux-centric clone() to POSIX
* threads for portability.
*/
#include <stdlib.h>
#include <stdio.h>
@@ -54,6 +56,7 @@
#include <string.h>
#include <errno.h>
#include <syslog.h>
#include <pthread.h>
#include <usb.h>
#include <ftdi.h>
@@ -367,8 +370,9 @@ lis_init(Driver *drvthis)
PrivateData *p;
int err;
const char *s;
unsigned char buffer[64], *thread_stack;
unsigned char buffer[64];
int count;
pthread_t read_thread;
report(RPT_DEBUG, "%s: Initializing driver",
drvthis->name);
@@ -502,16 +506,14 @@ lis_init(Driver *drvthis)
goto err_ftdi;
}
// clone a thread to keep a read up on the device
thread_stack = calloc(4096, 1);
if(! thread_stack) {
report(RPT_ERR, "%s: cannot create thread stack", drvthis->name);
goto err_framebuf;
}
err = clone(lis_read_thread, thread_stack+4092, CLONE_VM | CLONE_THREAD| CLONE_SIGHAND, drvthis);
if (err == -1) {
report(RPT_ERR, "%s: clone() - %s", drvthis->name, strerror(errno));
// create a thread to keep a read up on the device
err = pthread_create( &read_thread,
NULL,
(void *) lis_read_thread,
drvthis
);
if (err) {
report(RPT_ERR, "%s: pthread_create() - %s", drvthis->name, err);
goto err_framebuf;
}
p->parent_flag = 1; // show we're now a happy parent, birth successful.