[PD-cvs] pd/src g_array.c,1.1.1.3.2.9,1.1.1.3.2.10

Tim Blechmann timblech at users.sourceforge.net
Thu Sep 2 10:32:55 CEST 2004


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

Modified Files:
      Tag: devel_0_37
	g_array.c 
Log Message:
fixed array lock for msvc

Index: g_array.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/g_array.c,v
retrieving revision 1.1.1.3.2.9
retrieving revision 1.1.1.3.2.10
diff -C2 -d -r1.1.1.3.2.9 -r1.1.1.3.2.10
*** g_array.c	17 Jun 2004 21:03:54 -0000	1.1.1.3.2.9
--- g_array.c	2 Sep 2004 08:32:47 -0000	1.1.1.3.2.10
***************
*** 174,177 ****
--- 174,182 ----
      t_template *template;
      char *str;
+ 
+ #ifdef GARRAY_THREAD_LOCK	 /* TB: array lock */
+     pthread_mutexattr_t mutex_attr; 
+ #endif /* GARRAY_THREAD_LOCK */	
+ 
      if (s == &s_)
      {
***************
*** 224,228 ****
  #ifdef GARRAY_THREAD_LOCK    /* TB: array lock */
      x->x_mutex=getbytes(sizeof(pthread_mutex_t));
-     pthread_mutexattr_t mutex_attr; 
      pthread_mutexattr_init (&mutex_attr);
      pthread_mutexattr_settype(&mutex_attr,PTHREAD_MUTEX_RECURSIVE); 
--- 229,232 ----
***************
*** 315,318 ****
--- 319,323 ----
  static void garray_free(t_garray *x)
  {
+     t_pd *x2;
  #ifdef GARRAY_THREAD_LOCK
      garray_lock(x);/* TB: thread lock */
***************
*** 320,324 ****
      freebytes(x->x_mutex,sizeof(pthread_mutex_t));
  #endif
-     t_pd *x2;
      gfxstub_deleteforkey(x);
      pd_unbind(&x->x_gobj.g_pd, x->x_realname);
--- 325,328 ----
***************
*** 852,859 ****
  t_template *garray_template(t_garray *x)
  {
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     t_template *template = template_findbyname(x->x_templatesym);
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_unlock(x); 
--- 856,864 ----
  t_template *garray_template(t_garray *x)
  {
+ 	t_template *template;
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     template = template_findbyname(x->x_templatesym);
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_unlock(x); 
***************
*** 881,890 ****
  int garray_getfloatarray(t_garray *x, int *size, t_float **vec)
  {
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     t_template *template = garray_template(x);
!     int yonset, type;
!     t_symbol *arraytype;
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
--- 886,897 ----
  int garray_getfloatarray(t_garray *x, int *size, t_float **vec)
  {
+ 	t_template *template;
+     int yonset, type;
+     t_symbol *arraytype;
+ 
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     template = garray_template(x);
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
***************
*** 911,921 ****
  float garray_get(t_garray *x, t_symbol *s, t_int indx)
  {
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     t_template *template = garray_template(x);
!     int yonset, type;
!     t_symbol *arraytype;
!     float ret;
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
--- 918,930 ----
  float garray_get(t_garray *x, t_symbol *s, t_int indx)
  {
+ 	t_template *template;
+ 	int yonset, type;
+     t_symbol *arraytype;
+     float ret;
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
! 
! 	template = garray_template(x);    
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
***************
*** 953,962 ****
  static void garray_const(t_garray *x, t_floatarg g)
  {
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     t_template *template = garray_template(x);
!     int yonset, type, i;
!     t_symbol *arraytype;
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
--- 962,972 ----
  static void garray_const(t_garray *x, t_floatarg g)
  {
+     int yonset, type, i;
+     t_symbol *arraytype;
+ 	t_template *template;	
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     template = garray_template(x);
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
***************
*** 975,985 ****
      int nsin, t_float *vsin, int sineflag)
  {
! #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
!     garray_lock(x); 
! #endif
!     t_template *template = garray_template(x);
      int yonset, type, i, j;
      t_symbol *arraytype;
      double phase, phaseincr, fj;
      if (npoints == 0)
      	npoints = 512;	/* dunno what a good default would be... */
--- 985,996 ----
      int nsin, t_float *vsin, int sineflag)
  {
!     t_template *template;
      int yonset, type, i, j;
      t_symbol *arraytype;
      double phase, phaseincr, fj;
+ #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
+     garray_lock(x); 
+ #endif
+     template = garray_template(x);
      if (npoints == 0)
      	npoints = 512;	/* dunno what a good default would be... */
***************
*** 1015,1025 ****
  static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
  {
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     t_template *template = garray_template(x);
      
!     t_float *svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
!     int npoints, i;
      if (argc < 2)
      {
--- 1026,1038 ----
  static void garray_sinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
  {
+ 	t_template *template;
+     t_float *svec;
+     int npoints, i;
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     template = garray_template(x);
      
!     svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
      if (argc < 2)
      {
***************
*** 1046,1056 ****
  static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
  {
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     t_template *template = garray_template(x);
!     
!     t_float *svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
!     int npoints, i;
      if (argc < 2)
      {
--- 1059,1070 ----
  static void garray_cosinesum(t_garray *x, t_symbol *s, int argc, t_atom *argv)
  {
+     t_template *template;
+     t_float *svec;
+     int npoints, i;
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
!     template = garray_template(x);
!     svec = (t_float *)t_getbytes(sizeof(t_float) * argc);
      if (argc < 2)
      {
***************
*** 1078,1088 ****
  static void garray_normalize(t_garray *x, t_float f)
  {
! #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
!     garray_lock(x); 
! #endif
!     t_template *template = garray_template(x);
      int yonset, type, npoints, i;
      double maxv, renormer;
      t_symbol *arraytype;
      
      if (f <= 0)
--- 1092,1103 ----
  static void garray_normalize(t_garray *x, t_float f)
  {
!     t_template *template;
      int yonset, type, npoints, i;
      double maxv, renormer;
      t_symbol *arraytype;
+ #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
+     garray_lock(x); 
+ #endif
+     template = garray_template(x);
      
      if (f <= 0)
***************
*** 1123,1133 ****
  static void garray_list(t_garray *x, t_symbol *s, int argc, t_atom *argv)
  {
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
  
!     t_template *template = garray_template(x);
!     int yonset, type, i;
!     t_symbol *arraytype;
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
--- 1138,1149 ----
  static void garray_list(t_garray *x, t_symbol *s, int argc, t_atom *argv)
  {
+     t_template *template;
+     int yonset, type, i;
+     t_symbol *arraytype;
  #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
      garray_lock(x); 
  #endif
  
! 	template = garray_template(x);
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
***************
*** 1240,1252 ****
  static void garray_read(t_garray *x, t_symbol *filename)
  {
! #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
!     garray_lock(x); 
! #endif
!     int nelem = x->x_n, filedesc;
      FILE *fd;
      char buf[MAXPDSTRING], *bufptr;
!     t_template *template = garray_template(x);
      int yonset, type, i;
      t_symbol *arraytype;
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
--- 1256,1270 ----
  static void garray_read(t_garray *x, t_symbol *filename)
  {
!     int nelem, filedesc;
      FILE *fd;
      char buf[MAXPDSTRING], *bufptr;
!     t_template *template;
      int yonset, type, i;
      t_symbol *arraytype;
+ #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
+     garray_lock(x); 
+ #endif
+     nelem = x->x_n;
+     template = garray_template(x);
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
***************
*** 1302,1309 ****
      t_symbol *endian, t_floatarg fskip)
  {
- #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
-     garray_lock(x); 
- #endif
- 
      int skip = fskip, filedesc;
      int i, nelem;
--- 1320,1323 ----
***************
*** 1314,1317 ****
--- 1328,1334 ----
      int cpubig = garray_ambigendian(), swap = 0;
      char c = endian->s_name[0];
+ #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
+     garray_lock(x); 
+ #endif
      if (c == 'b')
      {
***************
*** 1381,1393 ****
  static void garray_write(t_garray *x, t_symbol *filename)
  {
- #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
-     garray_lock(x); 
- #endif
- 
      FILE *fd;
      char buf[MAXPDSTRING];
!     t_template *template = garray_template(x);
      int yonset, type, i;
      t_symbol *arraytype;
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
--- 1398,1411 ----
  static void garray_write(t_garray *x, t_symbol *filename)
  {
      FILE *fd;
      char buf[MAXPDSTRING];
!     t_template *template;
      int yonset, type, i;
      t_symbol *arraytype;
+ #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
+     garray_lock(x); 
+ #endif
+ 
+ 	template = garray_template(x);
      if (!template_find_field(template, gensym("y"), &yonset,
      	&type, &arraytype) || type != DT_FLOAT)
***************
*** 1444,1452 ****
  static void garray_write16(t_garray *x, t_symbol *filename, t_symbol *format)
  {
! #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
!     garray_lock(x); 
! #endif
! 
!     t_template *template = garray_template(x);
      int yonset, type, i;
      t_symbol *arraytype;
--- 1462,1466 ----
  static void garray_write16(t_garray *x, t_symbol *filename, t_symbol *format)
  {
!     t_template *template;
      int yonset, type, i;
      t_symbol *arraytype;
***************
*** 1456,1459 ****
--- 1470,1479 ----
      int swap = garray_ambigendian();	/* wave is only little endian */
      int intbuf;
+ 
+ #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
+     garray_lock(x); 
+ #endif
+ 
+     template = garray_template(x);
      strncpy(filenamebuf, filename->s_name, MAXPDSTRING-10);
      filenamebuf[MAXPDSTRING-10] = 0;
***************
*** 1537,1548 ****
  void garray_resize(t_garray *x, t_floatarg f)
  {
! #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
!     garray_lock(x); 
! #endif
!     int was = x->x_n, elemsize;
      t_glist *gl;
      int dspwas;
      int n = f;
      char *nvec;
      
      if (n < 1) n = 1;
--- 1557,1569 ----
  void garray_resize(t_garray *x, t_floatarg f)
  {
!     int was, elemsize;
      t_glist *gl;
      int dspwas;
      int n = f;
      char *nvec;
+ #ifdef GARRAY_THREAD_LOCK /* TB: array lock */
+     garray_lock(x); 
+ #endif
+     was = x->x_n;
      
      if (n < 1) n = 1;





More information about the Pd-cvs mailing list