[PD-cvs] pd/src s_inter.c,1.5.4.10.2.25.2.20,1.5.4.10.2.25.2.21

Mathieu Bouchard matju at users.sourceforge.net
Tue Jul 10 18:53:12 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv536

Modified Files:
      Tag: desiredata
	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.20
retrieving revision 1.5.4.10.2.25.2.21
diff -C2 -d -r1.5.4.10.2.25.2.20 -r1.5.4.10.2.25.2.21
*** s_inter.c	9 Jul 2007 17:57:57 -0000	1.5.4.10.2.25.2.20
--- s_inter.c	10 Jul 2007 16:53:10 -0000	1.5.4.10.2.25.2.21
***************
*** 228,242 ****
  
  void sys_setalarm(int microsec) {
!     struct itimerval gonzo;
! #if 0
!     fprintf(stderr, "timer %d\n", microsec);
! #endif
!     gonzo.it_interval.tv_sec = 0;
!     gonzo.it_interval.tv_usec = 0;
!     gonzo.it_value.tv_sec = 0;
!     gonzo.it_value.tv_usec = microsec;
      if (microsec) sys_signal(SIGALRM, sys_alarmhandler);
      else sys_signal(SIGALRM, SIG_IGN);
!     setitimer(ITIMER_REAL, &gonzo, 0);
  }
  
--- 228,239 ----
  
  void sys_setalarm(int microsec) {
!     struct itimerval it;
!     it.it_interval.tv_sec = 0;
!     it.it_interval.tv_usec = 0;
!     it.it_value.tv_sec = 0;
!     it.it_value.tv_usec = microsec;
      if (microsec) sys_signal(SIGALRM, sys_alarmhandler);
      else sys_signal(SIGALRM, SIG_IGN);
!     setitimer(ITIMER_REAL, &it, 0);
  }
  
***************
*** 321,327 ****
      int nfd = sys_nfdpoll;
      int size = nfd * sizeof(t_fdpoll);
-     t_fdpoll *fp;
      sys_fdpoll = (t_fdpoll *)t_resizebytes(sys_fdpoll, size, size + sizeof(t_fdpoll));
!     fp = sys_fdpoll + nfd;
      fp->fdp_fd = fd;
      fp->fdp_fn = fn;
--- 318,323 ----
      int nfd = sys_nfdpoll;
      int size = nfd * sizeof(t_fdpoll);
      sys_fdpoll = (t_fdpoll *)t_resizebytes(sys_fdpoll, size, size + sizeof(t_fdpoll));
!     t_fdpoll *fp = sys_fdpoll + nfd;
      fp->fdp_fd = fd;
      fp->fdp_fn = fn;
***************
*** 334,339 ****
      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--) {
--- 330,335 ----
      int nfd = sys_nfdpoll;
      int i, size = nfd * sizeof(t_fdpoll);
!     t_fdpoll *fp = sys_fdpoll;
!     for (i = nfd; i--; fp++) {
          if (fp->fdp_fd == fd) {
              while (i--) {
***************
*** 341,346 ****
                  fp++;
              }
!             sys_fdpoll = (t_fdpoll *)t_resizebytes(sys_fdpoll, size,
!                 size - sizeof(t_fdpoll));
              sys_nfdpoll = nfd - 1;
              return;
--- 337,341 ----
                  fp++;
              }
!             sys_fdpoll = (t_fdpoll *)t_resizebytes(sys_fdpoll, size, size - sizeof(t_fdpoll));
              sys_nfdpoll = nfd - 1;
              return;
***************
*** 372,386 ****
  static int socketreceiver_doread(t_socketreceiver *x) {
      char messbuf[INBUFSIZE], *bp = messbuf;
-     int indx;
      int inhead = x->inhead;
      int intail = x->intail;
      char *inbuf = x->inbuf;
      if (intail == inhead) return 0;
!     for (indx = intail; indx != inhead; indx = (indx+1)&(INBUFSIZE-1)) {
          /* ";" not preceded by "\" is a message boundary in current syntax.
             in future syntax it might become more complex. */
!         char c = *bp++ = inbuf[indx];
!         if (c == ';' && (!indx || inbuf[indx-1] != '\\')) {
!             intail = (indx+1)&(INBUFSIZE-1);
              binbuf_text(inbinbuf, messbuf, bp - messbuf);
              x->inhead = inhead;
--- 367,380 ----
  static int socketreceiver_doread(t_socketreceiver *x) {
      char messbuf[INBUFSIZE], *bp = messbuf;
      int inhead = x->inhead;
      int intail = x->intail;
      char *inbuf = x->inbuf;
      if (intail == inhead) return 0;
!     for (int i=intail; i!=inhead; i=(i+1)&(INBUFSIZE-1)) {
          /* ";" not preceded by "\" is a message boundary in current syntax.
             in future syntax it might become more complex. */
!         char c = *bp++ = inbuf[i];
!         if (c == ';' && (!i || inbuf[i-1] != '\\')) {
!             intail = (i+1)&(INBUFSIZE-1);
              binbuf_text(inbinbuf, messbuf, bp - messbuf);
              x->inhead = inhead;
***************
*** 465,469 ****
  void sys_vgui(char *fmt, ...) {
      t_socketreceiver *self = sys_socketreceiver;
-     int msglen;
      va_list ap;
      va_start(ap, fmt);
--- 459,462 ----
***************
*** 476,480 ****
      if (self->ohead > self->osize - GUI_ALLOCCHUNK/2)
          sys_trytogetmoreguibuf(self,self->osize + GUI_ALLOCCHUNK);
!     msglen = vsnprintf(self->obuf+self->ohead, self->osize-self->ohead, fmt, ap);
      va_end(ap);
      if(msglen < 0) {
--- 469,473 ----
      if (self->ohead > self->osize - GUI_ALLOCCHUNK/2)
          sys_trytogetmoreguibuf(self,self->osize + GUI_ALLOCCHUNK);
!     int msglen = vsnprintf(self->obuf+self->ohead, self->osize-self->ohead, fmt, ap);
      va_end(ap);
      if(msglen < 0) {
***************
*** 498,504 ****
  
  static int sys_flushtogui(t_socketreceiver *self) {
!     int writesize = self->ohead-self->otail, nwrote = 0;
      if (!writesize) return 0;
!     nwrote = send(self->fd, self->obuf+self->otail, writesize, 0);
      if (nwrote < 0) {
          perror("pd-to-gui socket");
--- 491,497 ----
  
  static int sys_flushtogui(t_socketreceiver *self) {
!     int writesize = self->ohead-self->otail;
      if (!writesize) return 0;
!     int nwrote = send(self->fd, self->obuf+self->otail, writesize, 0);
      if (nwrote < 0) {
          perror("pd-to-gui socket");
***************
*** 574,578 ****
      inbinbuf = binbuf_new();
      sys_setsignals();
- 
      sys_netreceive = netreceive_new(&s_,sys_guisetportnumber,0);
  //    fprintf(stderr,"sys_netreceive=%p\n",sys_netreceive);
--- 567,570 ----
***************
*** 581,585 ****
  //    obj_connect(sys_netreceive,1,(t_text *)pd_new3("print right"),0);
      obj_connect(sys_netreceive,0,manager,0);
- 
  #if defined(__linux__) || defined(IRIX)
  /* now that we've spun off the child process we can promote our process's
--- 573,576 ----
***************
*** 592,596 ****
      if (sys_hipriority) sys_setpriority();
      setuid(getuid());
- 
      return 0;
  }
--- 583,586 ----
***************
*** 607,611 ****
  #if defined(__linux__) || defined(IRIX)
  #ifndef WATCHDOGTHREAD
!     int pipe9[2], watchpid;
      if (pipe(pipe9) < 0) {
          setuid(getuid());
--- 597,601 ----
  #if defined(__linux__) || defined(IRIX)
  #ifndef WATCHDOGTHREAD
!     int pipe9[2];
      if (pipe(pipe9) < 0) {
          setuid(getuid());
***************
*** 613,617 ****
          return 1;
      }
!     watchpid = fork();
      if (watchpid < 0) {
          setuid(getuid());
--- 603,607 ----
          return 1;
      }
!     int watchpid = fork();
      if (watchpid < 0) {
          setuid(getuid());
***************
*** 636,641 ****
          close(pipe9[0]);
          sys_watchfd = pipe9[1];
!         /* We also have to start the ping loop in the GUI;
!            this is done later when the socket is open. */
      }
  #else
--- 626,630 ----
          close(pipe9[0]);
          sys_watchfd = pipe9[1];
!         /* We also have to start the ping loop in the GUI; this is done later when the socket is open. */
      }
  #else
***************
*** 652,666 ****
          struct sched_param param;
          int policy = SCHED_RR;
-         int err;
          param.sched_priority = 80; /* adjust 0 : 100 */
!         err = pthread_setschedparam(pthread_self(), policy, &param);
          if (err) post("warning: high priority scheduling failed\n");
      }
  #endif /* __APPLE__ */
      if (!sys_nogui) {
!             /* here is where we start the pinging. */
  #if defined(__linux__) || defined(IRIX)
  #ifndef WATCHDOGTHREAD
!          if (sys_hipriority) sys_gui("pdtk_watchdog\n");
  #endif
  #endif
--- 641,654 ----
          struct sched_param param;
          int policy = SCHED_RR;
          param.sched_priority = 80; /* adjust 0 : 100 */
!         int err = pthread_setschedparam(pthread_self(), policy, &param);
          if (err) post("warning: high priority scheduling failed\n");
      }
  #endif /* __APPLE__ */
      if (!sys_nogui) {
!         /* here is where we start the pinging. */
  #if defined(__linux__) || defined(IRIX)
  #ifndef WATCHDOGTHREAD
!         if (sys_hipriority) sys_gui("pdtk_watchdog\n");
  #endif
  #endif
***************
*** 673,685 ****
  void sys_bail(int n) {
      static int reentered = 0;
!     if (!reentered) {
!         reentered = 1;
!         fprintf(stderr, "closing audio...\n");
!         sys_close_audio();
!         fprintf(stderr, "closing MIDI...\n");
!         sys_close_midi();
!         fprintf(stderr, "... done.\n");
!         exit(n);
!     } else _exit(1);
  }
  
--- 661,672 ----
  void sys_bail(int n) {
      static int reentered = 0;
!     if (reentered) _exit(1);
!     reentered = 1;
!     fprintf(stderr, "closing audio...\n");
!     sys_close_audio();
!     fprintf(stderr, "closing MIDI...\n");
!     sys_close_midi();
!     fprintf(stderr, "... done.\n");
!     exit(n);
  }
  
***************
*** 700,716 ****
  static int sys_start_watchdog_thread() {
  	pthread_attr_t w_attr;
- 	int status;
  	main_pd_thread = pthread_self();
  	pthread_attr_init(&w_attr);
  	pthread_attr_setschedpolicy(&w_attr, SCHED_FIFO); /* use rt scheduling */
! 	status = pthread_create(&watchdog_id, &w_attr, (void*(*)(void*)) watchdog_thread, NULL);
  	return status; /* what is this function supposed to return anyway? it tried returning void though declared as int */
  }
  
  #ifdef MSW
! int gettimeofday (struct timeval *tv, void* tz);
  #endif
  
! static t_int* watchdog_callback(t_int* dummy) {
  	/* signal the condition */
  	pthread_cond_signal(&watchdog_cond);
--- 687,702 ----
  static int sys_start_watchdog_thread() {
  	pthread_attr_t w_attr;
  	main_pd_thread = pthread_self();
  	pthread_attr_init(&w_attr);
  	pthread_attr_setschedpolicy(&w_attr, SCHED_FIFO); /* use rt scheduling */
! 	int status = pthread_create(&watchdog_id, &w_attr, (void*(*)(void*)) watchdog_thread, NULL);
  	return status; /* what is this function supposed to return anyway? it tried returning void though declared as int */
  }
  
  #ifdef MSW
! int gettimeofday (struct timeval *tv, void *tz);
  #endif
  
! static t_int* watchdog_callback(t_int *dummy) {
  	/* signal the condition */
  	pthread_cond_signal(&watchdog_cond);
***************
*** 724,728 ****
  */
  
! static void *watchdog_thread(void* dummy) {
  	sys_set_priority(1);
  	post("watchdog thread started");
--- 710,714 ----
  */
  
! static void *watchdog_thread(void *dummy) {
  	sys_set_priority(1);
  	post("watchdog thread started");





More information about the Pd-cvs mailing list