Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7860
Modified Files: Tag: desiredata s_loader.c s_inter.c Log Message: cleanup
Index: s_inter.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_inter.c,v retrieving revision 1.5.4.10.2.25.2.16 retrieving revision 1.5.4.10.2.25.2.17 diff -C2 -d -r1.5.4.10.2.25.2.16 -r1.5.4.10.2.25.2.17 *** s_inter.c 28 Jun 2007 05:23:32 -0000 1.5.4.10.2.25.2.16 --- s_inter.c 28 Jun 2007 05:53:58 -0000 1.5.4.10.2.25.2.17 *************** *** 180,185 **** #define _WIN32_WINNT 0x0400 double end = sys_getrealtime() + (double)microsec * 1e-6; ! do ! { #ifdef MSW SwitchToThread(); --- 180,184 ---- #define _WIN32_WINNT 0x0400 double end = sys_getrealtime() + (double)microsec * 1e-6; ! do { #ifdef MSW SwitchToThread(); *************** *** 256,261 **** #endif
! void sys_set_priority(int higher) ! { #if (_POSIX_PRIORITY_SCHEDULING - 0) >= 200112L struct sched_param par; --- 255,259 ---- #endif
! void sys_set_priority(int higher) { #if (_POSIX_PRIORITY_SCHEDULING - 0) >= 200112L struct sched_param par; *************** *** 299,312 **** #endif
! void sys_set_priority(int higher) ! { #if (_POSIX_PRIORITY_SCHEDULING - 0) >= 200112L struct sched_param par; /* Bearing the table found in 'man realtime' in mind, I found it a */ /* good idea to use 192 as the priority setting for Pd. Any thoughts? */ ! if (higher) ! par.sched_priority = 250; /* priority for watchdog */ ! else ! par.sched_priority = 192; /* priority for pd (DSP) */ if (sched_setscheduler(0, SCHED_FIFO, &par) != -1) fprintf(stderr, "priority %d scheduling enabled.\n", par.sched_priority); --- 297,307 ---- #endif
! void sys_set_priority(int higher) { #if (_POSIX_PRIORITY_SCHEDULING - 0) >= 200112L struct sched_param par; /* Bearing the table found in 'man realtime' in mind, I found it a */ /* good idea to use 192 as the priority setting for Pd. Any thoughts? */ ! if (higher) par.sched_priority = 250; /* priority for watchdog */ ! else par.sched_priority = 192; /* priority for pd (DSP) */ if (sched_setscheduler(0, SCHED_FIFO, &par) != -1) fprintf(stderr, "priority %d scheduling enabled.\n", par.sched_priority); *************** *** 314,319 ****
#if (_POSIX_MEMLOCK - 0) >= 200112L ! if (mlockall(MCL_FUTURE) != -1) ! fprintf(stderr, "memory locking enabled.\n"); #endif } --- 309,313 ----
#if (_POSIX_MEMLOCK - 0) >= 200112L ! if (mlockall(MCL_FUTURE) != -1) fprintf(stderr, "memory locking enabled.\n"); #endif } *************** *** 323,335 **** /* ------------------ receiving incoming messages over sockets ------------- */
! void sys_sockerror(char *s) ! { #ifdef _WIN32 int err = WSAGetLastError(); if (err == 10054) return; ! else if (err == 10044) ! { ! fprintf(stderr, ! "Warning: you might not have TCP/IP "networking" turned on\n"); fprintf(stderr, "which is needed for Pd to talk to its GUI layer.\n"); } --- 317,326 ---- /* ------------------ receiving incoming messages over sockets ------------- */
! void sys_sockerror(char *s) { #ifdef _WIN32 int err = WSAGetLastError(); if (err == 10054) return; ! else if (err == 10044) { ! fprintf(stderr, "Warning: you might not have TCP/IP "networking" turned on\n"); fprintf(stderr, "which is needed for Pd to talk to its GUI layer.\n"); } *************** *** 340,345 **** }
! void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr) ! { int nfd = sys_nfdpoll; int size = nfd * sizeof(t_fdpoll); --- 331,335 ---- }
! void sys_addpollfn(int fd, t_fdpollfn fn, void *ptr) { int nfd = sys_nfdpoll; int size = nfd * sizeof(t_fdpoll); *************** *** 355,369 **** }
! void sys_rmpollfn(int fd) ! { int nfd = sys_nfdpoll; int i, size = nfd * sizeof(t_fdpoll); t_fdpoll *fp; ! for (i = nfd, fp = sys_fdpoll; i--; fp++) ! { ! if (fp->fdp_fd == fd) ! { ! while (i--) ! { fp[0] = fp[1]; fp++; --- 345,355 ---- }
! void sys_rmpollfn(int fd) { int nfd = sys_nfdpoll; int i, size = nfd * sizeof(t_fdpoll); t_fdpoll *fp; ! for (i = nfd, fp = sys_fdpoll; i--; fp++) { ! if (fp->fdp_fd == fd) { ! while (i--) { fp[0] = fp[1]; fp++; *************** *** 379,384 ****
t_socketreceiver *socketreceiver_new(t_pd *owner, int fd, t_socketnotifier notifier, ! t_socketreceivefn socketreceivefn, int udp) ! { t_socketreceiver *x = (t_socketreceiver *)getbytes(sizeof(*x)); x->inhead = x->intail = 0; --- 365,369 ----
t_socketreceiver *socketreceiver_new(t_pd *owner, int fd, t_socketnotifier notifier, ! t_socketreceivefn socketreceivefn, int udp) { t_socketreceiver *x = (t_socketreceiver *)getbytes(sizeof(*x)); x->inhead = x->intail = 0; *************** *** 470,475 **** }
! void sys_closesocket(int fd) ! { #ifdef UNISTD close(fd); --- 455,459 ---- }
! void sys_closesocket(int fd) { #ifdef UNISTD close(fd); *************** *** 559,564 ****
#ifdef __linux__ ! void glob_watchdog(t_pd *dummy) ! { #ifndef WATCHDOGTHREAD if (write(sys_watchfd, "\n", 1) < 1) { --- 543,547 ----
#ifdef __linux__ ! void glob_watchdog(t_pd *dummy) { #ifndef WATCHDOGTHREAD if (write(sys_watchfd, "\n", 1) < 1) {
Index: s_loader.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_loader.c,v retrieving revision 1.4.4.5.2.10.2.3 retrieving revision 1.4.4.5.2.10.2.4 diff -C2 -d -r1.4.4.5.2.10.2.3 -r1.4.4.5.2.10.2.4 *** s_loader.c 28 Jun 2007 05:23:32 -0000 1.4.4.5.2.10.2.3 --- s_loader.c 28 Jun 2007 05:53:58 -0000 1.4.4.5.2.10.2.4 *************** *** 22,26 **** #include <stdio.h>
! typedef void (*t_xxx)(void);
/* naming convention for externs. The names are kept distinct for those --- 22,26 ---- #include <stdio.h>
! typedef void (*t_xxx)();
/* naming convention for externs. The names are kept distinct for those *************** *** 54,62 ****
/* maintain list of loaded modules to avoid repeating loads */ ! typedef struct _loadedlist ! { ! struct _loadedlist *ll_next; t_symbol *ll_name; ! } t_loadlist;
static t_loadlist *sys_loaded; --- 54,61 ----
/* maintain list of loaded modules to avoid repeating loads */ ! struct t_loadlist { ! t_loadlist *ll_next; t_symbol *ll_name; ! };
static t_loadlist *sys_loaded; *************** *** 88,116 **** HINSTANCE ntdll; #endif ! if ((classname = strrchr(objectname, '/'))) ! classname++; else classname = objectname; ! if (sys_onloadlist(objectname)) ! { post("%s: already loaded", objectname); return 1; } ! for (i = 0, nameptr = classname; i < MAXPDSTRING-7 && *nameptr; nameptr++) ! { char c = *nameptr; ! if ((c>='0' && c<='9') || (c>='A' && c<='Z')|| ! (c>='a' && c<='z' )|| c == '_') ! { symname[i] = c; i++; } ! /* trailing tilde becomes "_tilde" */ ! else if (c == '~' && nameptr[1] == 0) ! { strcpy(symname+i, "_tilde"); i += strlen(symname+i); ! } ! else /* anything you can't put in a C symbol is sprintf'ed in hex */ ! { sprintf(symname+i, "0x%02x", c); i += strlen(symname+i); --- 87,107 ---- HINSTANCE ntdll; #endif ! if ((classname = strrchr(objectname, '/'))) classname++; else classname = objectname; ! if (sys_onloadlist(objectname)) { post("%s: already loaded", objectname); return 1; } ! for (i = 0, nameptr = classname; i < MAXPDSTRING-7 && *nameptr; nameptr++) { char c = *nameptr; ! if ((c>='0' && c<='9') || (c>='A' && c<='Z') || (c>='a' && c<='z' )|| c == '_') { symname[i] = c; i++; } ! /* trailing tilde becomes "_tilde" */ ! else if (c == '~' && nameptr[1] == 0) { strcpy(symname+i, "_tilde"); i += strlen(symname+i); ! } else { /* anything you can't put in a C symbol is sprintf'ed in hex */ sprintf(symname+i, "0x%02x", c); i += strlen(symname+i); *************** *** 119,141 **** } symname[i] = 0; ! if (hexmunge) ! { memmove(symname+6, symname, strlen(symname+1)); strncpy(symname, "setup_", 6); } else strcat(symname, "_setup"); - #if 0 fprintf(stderr, "lib: %s\n", classname); #endif ! /* try looking in the path for (objectname).(sys_dllextent) ... */ ! if ((fd = canvas_open(canvas, objectname, sys_dllextent, ! dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) ! goto gotone; ! /* same, with the more generic sys_dllextent2 */ ! if ((fd = canvas_open(canvas, objectname, sys_dllextent2, ! dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) ! goto gotone; ! /* next try (objectname)/(classname).(sys_dllextent) ... */ strncpy(filename, objectname, MAXPDSTRING); filename[MAXPDSTRING-2] = 0; --- 110,126 ---- } symname[i] = 0; ! if (hexmunge) { memmove(symname+6, symname, strlen(symname+1)); strncpy(symname, "setup_", 6); } else strcat(symname, "_setup"); #if 0 fprintf(stderr, "lib: %s\n", classname); #endif ! /* try looking in the path for (objectname).(sys_dllextent) ... */ ! if ((fd = canvas_open(canvas, objectname, sys_dllextent , dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; ! /* same, with the more generic sys_dllextent2 */ ! if ((fd = canvas_open(canvas, objectname, sys_dllextent2, dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; ! /* next try (objectname)/(classname).(sys_dllextent) ... */ strncpy(filename, objectname, MAXPDSTRING); filename[MAXPDSTRING-2] = 0; *************** *** 143,152 **** strncat(filename, classname, MAXPDSTRING-strlen(filename)); filename[MAXPDSTRING-1] = 0; ! if ((fd = canvas_open(canvas, filename, sys_dllextent, ! dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) ! goto gotone; ! if ((fd = canvas_open(canvas, filename, sys_dllextent2, ! dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) ! goto gotone; return 0; gotone: --- 128,133 ---- strncat(filename, classname, MAXPDSTRING-strlen(filename)); filename[MAXPDSTRING-1] = 0; ! if ((fd = canvas_open(canvas, filename, sys_dllextent , dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; ! if ((fd = canvas_open(canvas, filename, sys_dllextent2, dirbuf, &nameptr, MAXPDSTRING, 1)) >= 0) goto gotone; return 0; gotone: *************** *** 154,158 **** class_set_extern_dir(gensym(dirbuf));
! /* rebuild the absolute pathname */ strncpy(filename, dirbuf, MAXPDSTRING); filename[MAXPDSTRING-2] = 0; --- 135,139 ---- class_set_extern_dir(gensym(dirbuf));
! /* rebuild the absolute pathname */ strncpy(filename, dirbuf, MAXPDSTRING); filename[MAXPDSTRING-2] = 0; *************** *** 163,168 **** #ifdef DL_OPEN dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); ! if (!dlobj) ! { post("%s: %s", filename, dlerror()); class_set_extern_dir(&s_); --- 144,148 ---- #ifdef DL_OPEN dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL); ! if (!dlobj) { post("%s: %s", filename, dlerror()); class_set_extern_dir(&s_); *************** *** 174,193 **** sys_bashfilename(filename, filename); ntdll = LoadLibrary(filename); ! if (!ntdll) ! { post("%s: couldn't load", filename); class_set_extern_dir(&s_); return 0; } ! makeout = (t_xxx)GetProcAddress(ntdll, symname); #endif ! ! if (!makeout) ! { post("load_object: Symbol "%s" not found", symname); class_set_extern_dir(&s_); return 0; } ! (*makeout)(); class_set_extern_dir(&s_); sys_putonloadlist(objectname); --- 154,170 ---- sys_bashfilename(filename, filename); ntdll = LoadLibrary(filename); ! if (!ntdll) { post("%s: couldn't load", filename); class_set_extern_dir(&s_); return 0; } ! makeout = (t_xxx)GetProcAddress(ntdll, symname); #endif ! if (!makeout) { post("load_object: Symbol "%s" not found", symname); class_set_extern_dir(&s_); return 0; } ! makeout(); class_set_extern_dir(&s_); sys_putonloadlist(objectname); *************** *** 196,205 ****
/* callback type definition */ ! typedef int (*loader_t)(t_canvas *canvas, char *classname);
/* linked list of loaders */ ! typedef struct loader_queue { loader_t loader; ! struct loader_queue *next; } loader_queue_t;
--- 173,183 ----
/* callback type definition */ ! typedef int (*t_loader)(t_canvas *canvas, char *classname); ! typedef t_loader loader_t;
/* linked list of loaders */ ! typedef struct t_loader_queue { loader_t loader; ! t_loader_queue *next; } loader_queue_t;
*************** *** 207,219 ****
/* register class loader function */ ! void sys_register_loader(loader_t loader) ! { loader_queue_t *q = &loaders; ! while (1) ! { ! if (q->next) ! q = q->next; ! else ! { q->next = (loader_queue_t *)getbytes(sizeof(loader_queue_t)); q->next->loader = loader; --- 185,193 ----
/* register class loader function */ ! void sys_register_loader(loader_t loader) { loader_queue_t *q = &loaders; ! while (1) { ! if (q->next) q = q->next; ! else { q->next = (loader_queue_t *)getbytes(sizeof(loader_queue_t)); q->next->loader = loader; *************** *** 221,236 **** break; } ! } }
! int sys_load_lib(t_canvas *canvas, char *classname) ! { int dspstate = canvas_suspend_dsp(); int ok = 0; loader_queue_t *q; ! for(q = &loaders; q; q = q->next) ! if (ok = q->loader(canvas, classname)) break; canvas_resume_dsp(dspstate); return ok; } - --- 195,207 ---- break; } ! } }
! int sys_load_lib(t_canvas *canvas, char *classname) { int dspstate = canvas_suspend_dsp(); int ok = 0; loader_queue_t *q; ! for(q = &loaders; q; q = q->next) if ((ok = q->loader(canvas, classname))) break; canvas_resume_dsp(dspstate); return ok; }