Modified to allow other threads to run in a multithreaded environment.
This commit is contained in:
parent
1738388c59
commit
743db36cd2
@ -30,6 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||||||
#include "import.h"
|
#include "import.h"
|
||||||
#include "modsupport.h"
|
#include "modsupport.h"
|
||||||
#include "structmember.h"
|
#include "structmember.h"
|
||||||
|
#include "ceval.h"
|
||||||
|
|
||||||
|
|
||||||
/* Config objects */
|
/* Config objects */
|
||||||
@ -274,7 +275,9 @@ al_readsamps (self, args)
|
|||||||
v = newsizedstringobject ((char *)NULL, width * count);
|
v = newsizedstringobject ((char *)NULL, width * count);
|
||||||
if (v == NULL) return NULL;
|
if (v == NULL) return NULL;
|
||||||
|
|
||||||
|
BGN_SAVE
|
||||||
ALreadsamps (self-> ob_port, (void *) getstringvalue(v), count);
|
ALreadsamps (self-> ob_port, (void *) getstringvalue(v), count);
|
||||||
|
END_SAVE
|
||||||
|
|
||||||
return (v);
|
return (v);
|
||||||
}
|
}
|
||||||
@ -294,7 +297,9 @@ al_writesamps (self, args)
|
|||||||
c = ALgetconfig(self->ob_port);
|
c = ALgetconfig(self->ob_port);
|
||||||
width = ALgetwidth(c);
|
width = ALgetwidth(c);
|
||||||
ALfreeconfig(c);
|
ALfreeconfig(c);
|
||||||
|
BGN_SAVE
|
||||||
ALwritesamps (self-> ob_port, (void *) buf, (long) size / width);
|
ALwritesamps (self-> ob_port, (void *) buf, (long) size / width);
|
||||||
|
END_SAVE
|
||||||
|
|
||||||
INCREF (None);
|
INCREF (None);
|
||||||
return None;
|
return None;
|
||||||
@ -361,6 +366,7 @@ al_getconfig (self, args)
|
|||||||
static struct methodlist port_methods[] = {
|
static struct methodlist port_methods[] = {
|
||||||
{"closeport", al_closeport},
|
{"closeport", al_closeport},
|
||||||
{"getfd", al_getfd},
|
{"getfd", al_getfd},
|
||||||
|
{"fileno", al_getfd},
|
||||||
{"getfilled", al_getfilled},
|
{"getfilled", al_getfilled},
|
||||||
{"getfillable", al_getfillable},
|
{"getfillable", al_getfillable},
|
||||||
{"readsamps", al_readsamps},
|
{"readsamps", al_readsamps},
|
||||||
|
@ -25,6 +25,11 @@ Each definition must be contained on one line:
|
|||||||
N*retval
|
N*retval
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* An attempt has been made to make this module switch threads on qread
|
||||||
|
* calls. It is far from safe, though.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <gl.h>
|
#include <gl.h>
|
||||||
#include <device.h>
|
#include <device.h>
|
||||||
|
|
||||||
@ -32,6 +37,7 @@ Each definition must be contained on one line:
|
|||||||
#include "import.h"
|
#include "import.h"
|
||||||
#include "modsupport.h"
|
#include "modsupport.h"
|
||||||
#include "cgensupport.h"
|
#include "cgensupport.h"
|
||||||
|
#include "ceval.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Some stubs are too complicated for the stub generator.
|
Some stubs are too complicated for the stub generator.
|
||||||
@ -40,6 +46,27 @@ A line starting with '%' gives the name of the function so the stub
|
|||||||
generator can include it in the table of functions.
|
generator can include it in the table of functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
% qread
|
||||||
|
|
||||||
|
static object *
|
||||||
|
gl_qread(self, args)
|
||||||
|
object *self;
|
||||||
|
object *args;
|
||||||
|
{
|
||||||
|
long retval;
|
||||||
|
short arg1 ;
|
||||||
|
BGN_SAVE
|
||||||
|
retval = qread( & arg1 );
|
||||||
|
END_SAVE
|
||||||
|
{ object *v = newtupleobject( 2 );
|
||||||
|
if (v == NULL) return NULL;
|
||||||
|
settupleitem(v, 0, mknewlongobject(retval));
|
||||||
|
settupleitem(v, 1, mknewshortobject(arg1));
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
varray -- an array of v.. calls.
|
varray -- an array of v.. calls.
|
||||||
The argument is an array (maybe list or tuple) of points.
|
The argument is an array (maybe list or tuple) of points.
|
||||||
|
@ -29,6 +29,16 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||||||
and possibly also with previous versions.
|
and possibly also with previous versions.
|
||||||
(You must also edit FL.py to set _v15 to 1.) */
|
(You must also edit FL.py to set _v15 to 1.) */
|
||||||
|
|
||||||
|
/* A half-hearted attempt has been made to allow programs using this
|
||||||
|
* module to exploit parallelism (through the threads module). No provisions
|
||||||
|
* have been made for multiple threads to use this module at the same time,
|
||||||
|
* though. So, a program with a forms thread and a non-forms thread will work
|
||||||
|
* fine but a program with two threads using forms will probably crash (unless
|
||||||
|
* the program takes precaution to ensure that only one thread can be in
|
||||||
|
* this module at any time). This will have to be fixed some time.
|
||||||
|
* (A fix will probably also have to synchronise with the gl module).
|
||||||
|
*/
|
||||||
|
|
||||||
#include "forms.h"
|
#include "forms.h"
|
||||||
|
|
||||||
#include "allobjects.h"
|
#include "allobjects.h"
|
||||||
@ -1964,7 +1974,9 @@ forms_do_or_check_forms(dummy, args, func)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
BGN_SAVE
|
||||||
generic = (*func)();
|
generic = (*func)();
|
||||||
|
END_SAVE
|
||||||
if (generic == NULL) {
|
if (generic == NULL) {
|
||||||
INCREF(None);
|
INCREF(None);
|
||||||
return None;
|
return None;
|
||||||
@ -2131,7 +2143,9 @@ forms_qread(self, args)
|
|||||||
{
|
{
|
||||||
long retval;
|
long retval;
|
||||||
short arg1 ;
|
short arg1 ;
|
||||||
|
BGN_SAVE
|
||||||
retval = fl_qread(&arg1);
|
retval = fl_qread(&arg1);
|
||||||
|
END_SAVE
|
||||||
{ object *v = newtupleobject(2);
|
{ object *v = newtupleobject(2);
|
||||||
if (v == NULL) return NULL;
|
if (v == NULL) return NULL;
|
||||||
settupleitem(v, 0, newintobject(retval));
|
settupleitem(v, 0, newintobject(retval));
|
||||||
@ -2273,7 +2287,9 @@ forms_show_message(f, args)
|
|||||||
|
|
||||||
if (!getargs(args, "(sss)", &a, &b, &c)) return NULL;
|
if (!getargs(args, "(sss)", &a, &b, &c)) return NULL;
|
||||||
|
|
||||||
|
BGN_SAVE
|
||||||
fl_show_message(a, b, c);
|
fl_show_message(a, b, c);
|
||||||
|
END_SAVE
|
||||||
|
|
||||||
INCREF(None);
|
INCREF(None);
|
||||||
return None;
|
return None;
|
||||||
@ -2287,6 +2303,7 @@ forms_show_choice(f, args)
|
|||||||
char *m1, *m2, *m3, *b1, *b2, *b3;
|
char *m1, *m2, *m3, *b1, *b2, *b3;
|
||||||
int nb;
|
int nb;
|
||||||
char *format;
|
char *format;
|
||||||
|
int rv;
|
||||||
|
|
||||||
if (args == NULL || !is_tupleobject(args)) {
|
if (args == NULL || !is_tupleobject(args)) {
|
||||||
err_badarg();
|
err_badarg();
|
||||||
@ -2314,7 +2331,10 @@ forms_show_choice(f, args)
|
|||||||
if (!getargs(args, format, &m1, &m2, &m3, &b1, &b2, &b3))
|
if (!getargs(args, format, &m1, &m2, &m3, &b1, &b2, &b3))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return newintobject(fl_show_choice(m1, m2, m3, nb, b1, b2, b3));
|
BGN_SAVE
|
||||||
|
rv = fl_show_choice(m1, m2, m3, nb, b1, b2, b3);
|
||||||
|
END_SAVE
|
||||||
|
return newintobject(rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static object *
|
static object *
|
||||||
@ -2327,7 +2347,9 @@ forms_show_question(f, args)
|
|||||||
|
|
||||||
if (!getargs(args, "(sss)", &a, &b, &c)) return NULL;
|
if (!getargs(args, "(sss)", &a, &b, &c)) return NULL;
|
||||||
|
|
||||||
|
BGN_SAVE
|
||||||
ret = fl_show_question(a, b, c);
|
ret = fl_show_question(a, b, c);
|
||||||
|
END_SAVE
|
||||||
|
|
||||||
return newintobject((long) ret);
|
return newintobject((long) ret);
|
||||||
}
|
}
|
||||||
@ -2342,7 +2364,9 @@ forms_show_input(f, args)
|
|||||||
|
|
||||||
if (!getstrstrarg(args, &a, &b)) return NULL;
|
if (!getstrstrarg(args, &a, &b)) return NULL;
|
||||||
|
|
||||||
|
BGN_SAVE
|
||||||
str = fl_show_input(a, b);
|
str = fl_show_input(a, b);
|
||||||
|
END_SAVE
|
||||||
|
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
INCREF(None);
|
INCREF(None);
|
||||||
@ -2361,7 +2385,9 @@ forms_file_selector(f, args)
|
|||||||
|
|
||||||
if (!getargs(args, "(ssss)", &a, &b, &c, &d)) return NULL;
|
if (!getargs(args, "(ssss)", &a, &b, &c, &d)) return NULL;
|
||||||
|
|
||||||
|
BGN_SAVE
|
||||||
str = fl_show_file_selector(a, b, c, d);
|
str = fl_show_file_selector(a, b, c, d);
|
||||||
|
END_SAVE
|
||||||
|
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
INCREF(None);
|
INCREF(None);
|
||||||
|
@ -26,6 +26,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||||||
|
|
||||||
#include "allobjects.h"
|
#include "allobjects.h"
|
||||||
#include "modsupport.h"
|
#include "modsupport.h"
|
||||||
|
#include "ceval.h"
|
||||||
|
|
||||||
extern int sginap(long);
|
extern int sginap(long);
|
||||||
|
|
||||||
@ -37,7 +38,9 @@ sgi_nap(self, args)
|
|||||||
long ticks;
|
long ticks;
|
||||||
if (!getargs(args, "l", &ticks))
|
if (!getargs(args, "l", &ticks))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
BGN_SAVE
|
||||||
sginap(ticks);
|
sginap(ticks);
|
||||||
|
END_SAVE
|
||||||
INCREF(None);
|
INCREF(None);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user