Update of /cvsroot/pure-data/externals/grh/threadlib/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14711
Modified Files: callbacks.c join.c Makefile Makefile_darwin Makefile_mingw sleep.c threadlib.c threadlib.h Added Files: Makefile_msvc Log Message: version 0.1
Index: threadlib.h =================================================================== RCS file: /cvsroot/pure-data/externals/grh/threadlib/src/threadlib.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** threadlib.h 14 Nov 2005 21:14:12 -0000 1.2 --- threadlib.h 20 Nov 2005 21:28:39 -0000 1.3 *************** *** 29,32 **** --- 29,38 ---- #include "pthread.h"
+ #ifdef MSW + #define THREADLIB_EXTERN __declspec(dllexport) extern + #else + #define THREADLIB_EXTERN extern + #endif /* MSW */ +
// threadlib version string *************** *** 39,42 **** --- 45,50 ---- //#define DEBUG
+ // setup function + THREADLIB_EXTERN void threadlib_setup(void);
/* --------- lockfree FIFO of pd devel ----------- */ *************** *** 48,57 ****
/* function prototypes */ ! t_fifo * fifo_init(void); ! void fifo_destroy(t_fifo*);
/* fifo_put() and fifo_get are the only threadsafe functions!!! */ ! void fifo_put(t_fifo*, void*); ! void* fifo_get(t_fifo*);
--- 56,65 ----
/* function prototypes */ ! THREADLIB_EXTERN t_fifo * fifo_init(void); ! THREADLIB_EXTERN void fifo_destroy(t_fifo*);
/* fifo_put() and fifo_get are the only threadsafe functions!!! */ ! THREADLIB_EXTERN void fifo_put(t_fifo*, void*); ! THREADLIB_EXTERN void* fifo_get(t_fifo*);
*************** *** 66,69 **** --- 74,86 ---- */
+ /* register a new callback in FIFO */ + /* tb: to be called at idle time */ + /* Holzmann: idle callbacks of current PD are not reliable, so + it will be called by the clock-callbacks for now */ + THREADLIB_EXTERN void sys_callback(t_int (*callback) (t_int* argv), + t_int* argv, t_int argc); + + /* private: */ + /* set up callback fifo and start clock callback */ void h_init_callbacks(); *************** *** 72,81 **** void h_free_callbacks();
- /* tb: to be called at idle time */ - /* Holzmann: idle callbacks of current PD are not reliable, so - it will be called by the clock-callbacks for now */ - /* register a new callback in FIFO */ - void h_set_callback(t_int (*callback) (t_int* argv), t_int* argv, t_int argc); - - #endif // __PD_THREADLIB_H_ --- 89,91 ----
Index: Makefile_mingw =================================================================== RCS file: /cvsroot/pure-data/externals/grh/threadlib/src/Makefile_mingw,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile_mingw 14 Nov 2005 21:05:18 -0000 1.1 --- Makefile_mingw 20 Nov 2005 21:28:39 -0000 1.2 *************** *** 12,34 **** # --------------------------------------------------
! TARGET=threadlib.pd_linux
! OBJ=fifo.o callbacks.o threadlib.o sleep.o detach.o \ ! join.o threadedsf.o
CC = gcc LD = gcc ! INCLUDE=-I$(PDSCR) -I. ! LIB=$(PD-PATH)/bin/pd.dll ! CC_FLAGS = -DPD -DWINDOWS -c -mms-bitfields \ -Wall -Wno-parentheses -Wno-switch -O3 \ ! -funroll-loops -fomit-frame-pointer -pthread LD_FLAGS = --export-dynamic -shared -o
# --------------------------------------------------
! all: pd_linux
! pd_linux: $(TARGET)
$(TARGET): $(OBJ) --- 12,35 ---- # --------------------------------------------------
! TARGET=threadlib.dll
! OBJ=fifo.o callbacks.o threadlib.o \ ! sleep.o detach.o join.o
CC = gcc LD = gcc ! INCLUDE = -I$(PDSCR) -I. ! LIB = $(PDPATH)/bin/pd.dll \ ! c:/windows/system/pthreadGC.dll ! CC_FLAGS = -DPD -DMSW -c -mms-bitfields \ -Wall -Wno-parentheses -Wno-switch -O3 \ ! -funroll-loops -fomit-frame-pointer LD_FLAGS = --export-dynamic -shared -o
# --------------------------------------------------
! all: dll
! dll: $(TARGET)
$(TARGET): $(OBJ) *************** *** 55,61 **** $(CC) $(CC_FLAGS) $(INCLUDE) join.c
- threadedsf.o: threadlib.o callbacks.o threadedsf.c - $(CC) $(CC_FLAGS) $(INCLUDE) threadedsf.c - # --------------------------------------------------
--- 56,59 ----
Index: threadlib.c =================================================================== RCS file: /cvsroot/pure-data/externals/grh/threadlib/src/threadlib.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** threadlib.c 14 Nov 2005 21:05:18 -0000 1.1 --- threadlib.c 20 Nov 2005 21:28:39 -0000 1.2 *************** *** 34,38 **** static void threadlib_help(void) { ! post("\nthreadlib vers."VERSION", library for threaded patching\n" "2005, by Georg Holzmann grh@mur.at\n" "heavily based on pd_devel code by Tim Blechmann\n" --- 34,38 ---- static void threadlib_help(void) { ! post("\nthreadlib vers."VERSION", library for threaded patching and externals\n" "2005, by Georg Holzmann grh@mur.at\n" "heavily based on pd_devel code by Tim Blechmann\n" *************** *** 42,46 **** "\tjoin synchronize messages to pd's main thread\n" "\tsleep block system for specific time\n" - "\tthreadedsf threaded soundfiler from pd_devel_0.38\n"
"WARNING: this is very experimental and can crash your patches !\n"); --- 42,45 ---- *************** *** 56,63 **** void detach_setup(); void join_setup(); - void threadedsf_setup(); - void sys_start_sfthread();
! void threadlib_setup(void) { // call all the setup functions: --- 55,60 ---- void detach_setup(); void join_setup();
! void threadlib_setup(void) { // call all the setup functions: *************** *** 65,77 **** detach_setup(); join_setup(); - threadedsf_setup();
// init callback system h_init_callbacks(); - - // start global soundfiler helper thread - sys_start_sfthread();
! post("\nthreadlib vers."VERSION", library for threaded patching\n" "2005, by Georg Holzmann grh@mur.at\n" "heavily based on pd_devel code by Tim Blechmann\n" --- 62,70 ---- detach_setup(); join_setup();
// init callback system h_init_callbacks();
! post("\nthreadlib vers."VERSION", library for threaded patching and externals\n" "2005, by Georg Holzmann grh@mur.at\n" "heavily based on pd_devel code by Tim Blechmann\n" *************** *** 81,83 **** --- 74,78 ---- sizeof(t_threadlib), 0, 0); class_addmethod(threadlib_class, (t_method)threadlib_help, gensym("help"), 0); + + return 0; }
Index: Makefile =================================================================== RCS file: /cvsroot/pure-data/externals/grh/threadlib/src/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 14 Nov 2005 21:05:18 -0000 1.1 --- Makefile 20 Nov 2005 21:28:39 -0000 1.2 *************** *** 4,8 **** # this should point to the directory which contains # m_pd.h and g_canvas.h ! PDSCR=/home/holzi/pd-0.39-1test1/src
# this is the pd directory, here the files will be --- 4,8 ---- # this should point to the directory which contains # m_pd.h and g_canvas.h ! PDSCR=/home/holzi/pd-0.39-1/src
# this is the pd directory, here the files will be *************** *** 14,19 **** TARGET=threadlib.pd_linux
! OBJ=fifo.o callbacks.o threadlib.o sleep.o detach.o \ ! join.o threadedsf.o
CC = gcc --- 14,19 ---- TARGET=threadlib.pd_linux
! OBJ=fifo.o callbacks.o threadlib.o \ ! sleep.o detach.o join.o
CC = gcc *************** *** 55,61 **** $(CC) $(CC_FLAGS) $(INCLUDE) join.c
- threadedsf.o: threadlib.o callbacks.o threadedsf.c - $(CC) $(CC_FLAGS) $(INCLUDE) threadedsf.c - # --------------------------------------------------
--- 55,58 ----
Index: join.c =================================================================== RCS file: /cvsroot/pure-data/externals/grh/threadlib/src/join.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** join.c 14 Nov 2005 21:05:18 -0000 1.1 --- join.c 20 Nov 2005 21:28:39 -0000 1.2 *************** *** 50,54 **** argv[0] = (t_int)x->x_outlet;
! h_set_callback(join_bang_callback, argv, 1); }
--- 50,54 ---- argv[0] = (t_int)x->x_outlet;
! sys_callback(join_bang_callback, argv, 1); }
*************** *** 65,69 **** argv[1] = (t_int)gp;
! h_set_callback(join_pointer_callback, argv, 2); }
--- 65,69 ---- argv[1] = (t_int)gp;
! sys_callback(join_pointer_callback, argv, 2); }
*************** *** 80,84 **** argv[1] = (t_int)f;
! h_set_callback(join_float_callback, argv, 2); }
--- 80,84 ---- argv[1] = (t_int)f;
! sys_callback(join_float_callback, argv, 2); }
*************** *** 95,99 **** argv[1] = (t_int)s;
! h_set_callback(join_symbol_callback, argv, 2); }
--- 95,99 ---- argv[1] = (t_int)s;
! sys_callback(join_symbol_callback, argv, 2); }
*************** *** 114,118 **** argv[2] = (t_int)copied_argv;
! h_set_callback(join_list_callback, argv, 3); }
--- 114,118 ---- argv[2] = (t_int)copied_argv;
! sys_callback(join_list_callback, argv, 3); }
*************** *** 145,149 **** argv[2] = (t_int)copied_argv;
! h_set_callback(join_anything_callback, argv, 3); }
--- 145,149 ---- argv[2] = (t_int)copied_argv;
! sys_callback(join_anything_callback, argv, 3); }
Index: sleep.c =================================================================== RCS file: /cvsroot/pure-data/externals/grh/threadlib/src/sleep.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sleep.c 14 Nov 2005 21:05:18 -0000 1.1 --- sleep.c 20 Nov 2005 21:28:39 -0000 1.2 *************** *** 22,26 **** --- 22,33 ----
#include "threadlib.h" + + // include for sleep + #ifdef MSW + #include <windows.h> + #define sleep(t) Sleep(1000*(t)) + #else #include <unistd.h> + #endif
static t_class *sleep_class; *************** *** 42,48 **** { t_sleep *x = (t_sleep *)pd_new(sleep_class); - x->x_outlet = outlet_new(&x->x_obj,&s_float); - return (void *)x; } --- 49,53 ----
Index: Makefile_darwin =================================================================== RCS file: /cvsroot/pure-data/externals/grh/threadlib/src/Makefile_darwin,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile_darwin 14 Nov 2005 21:05:18 -0000 1.1 --- Makefile_darwin 20 Nov 2005 21:28:39 -0000 1.2 *************** *** 12,19 **** # --------------------------------------------------
! TARGET=threadlib.pd_linux
! OBJ=fifo.o callbacks.o threadlib.o sleep.o detach.o \ ! join.o threadedsf.o
CC = gcc --- 12,19 ---- # --------------------------------------------------
! TARGET=threadlib.pd_darwin
! OBJ=fifo.o callbacks.o threadlib.o \ ! sleep.o detach.o join.o
CC = gcc *************** *** 29,35 **** # --------------------------------------------------
! all: pd_linux
! pd_linux: $(TARGET)
$(TARGET): $(OBJ) --- 29,35 ---- # --------------------------------------------------
! all: pd_darwin
! pd_darwin: $(TARGET)
$(TARGET): $(OBJ) *************** *** 56,62 **** $(CC) $(CC_FLAGS) $(INCLUDE) join.c
- threadedsf.o: threadlib.o callbacks.o threadedsf.c - $(CC) $(CC_FLAGS) $(INCLUDE) threadedsf.c - # --------------------------------------------------
--- 56,59 ----
Index: callbacks.c =================================================================== RCS file: /cvsroot/pure-data/externals/grh/threadlib/src/callbacks.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** callbacks.c 14 Nov 2005 21:05:18 -0000 1.1 --- callbacks.c 20 Nov 2005 21:28:39 -0000 1.2 *************** *** 42,46 **** }
! void h_set_callback(t_int (*callback) (t_int* argv), t_int* argv, t_int argc) { t_sched_callback* new = (t_sched_callback*) getbytes --- 42,46 ---- }
! void sys_callback(t_int (*callback) (t_int* argv), t_int* argv, t_int argc) { t_sched_callback* new = (t_sched_callback*) getbytes
--- NEW FILE: Makefile_msvc --- # ------------------------------------------------- # adjust the next 3 pathes to your system:
# this should point to the directory which contains # m_pd.h and g_canvas.h PD_SCR = C:\pd\src
# this is the pd directory, here the files will be # installed PD_PATH = C:\pd
# path of the microsoft compiler VIS_CPP_PATH = "C:\Programme\Microsoft Visual Studio\Vc98"
# --------------------------------------------------
TARGET=threadlib.dll
OBJ=fifo.obj callbacks.obj threadlib.obj \ sleep.obj detach.obj join.obj threadedsf.obj
CC = cl.exe LD = link.exe INCLUDE = /I. /I$(PD_SCR) /I$(VIS_CPP_PATH)\include CC_FLAGS = /W3 /WX /DMSW /DPD /nologo /D_WINDOWS LD_FLAGS = /nologo /dll /export:threadlib_setup
#LDIR = $(VIS_CPP_PATH)\lib LIB = /NODEFAULTLIB:libc /NODEFAULTLIB:oldnames \ /NODEFAULTLIB:kernel /NODEFAULTLIB:uuid \ $(VIS_CPP_PATH)\lib\libc.lib \ $(VIS_CPP_PATH)\lib\oldnames.lib \ $(VIS_CPP_PATH)\lib\kernel32.lib \ $(PD_PATH)\bin\pd.lib \ $(PD_PATH)\bin\pthreadVC.lib
# --------------------------------------------------
all: dll
dll: $(TARGET)
$(TARGET): $(OBJ) $(LD) $(LD_FLAGS) /out:$(TARGET) $(OBJ) $(LIB)
threadlib.obj: threadlib.h threadlib.c $(CC) $(CC_FLAGS) $(INCLUDE) /c threadlib.c
fifo.obj: threadlib.obj fifo.c $(CC) $(CC_FLAGS) $(INCLUDE) /c fifo.c
callbacks.obj: fifo.obj threadlib.obj callbacks.c $(CC) $(CC_FLAGS) $(INCLUDE) /c callbacks.c
sleep.obj: threadlib.obj sleep.c $(CC) $(CC_FLAGS) $(INCLUDE) /c sleep.c
detach.obj: threadlib.obj fifo.obj detach.c $(CC) $(CC_FLAGS) $(INCLUDE) /c detach.c
join.obj: threadlib.obj callbacks.obj join.c $(CC) $(CC_FLAGS) $(INCLUDE) /c join.c
# --------------------------------------------------
clean: del $(OBJ) $(TARGET) *.lib *.exp
install: copy $(TARGET) $(PD_PATH)\extra copy help*.pd $(PD_PATH)\doc\5.reference