Branch: Tag:

2019-05-20

2019-05-20 10:33:29 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Thread.MutexKey: Added _sprintf().

Fixes PIKE-189 (#8189).

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: threads.c,v 1.259 2008/06/29 12:37:11 nilsson Exp $ + || $Id$   */      #include "global.h"
1544:    }   }    + static void f_mutex_key__sprintf(INT32 args) + { +  int c = 0; +  if(args>0 && TYPEOF(Pike_sp[-args]) == PIKE_T_INT) +  c = Pike_sp[-args].u.integer; +  pop_n_elems (args); +  if(c != 'O') { +  push_undefined(); +  return; +  } +  if (THIS_KEY->mutex_obj) { +  push_text("MutexKey(/* %O */)"); +  ref_push_object(THIS_KEY->mutex_obj); +  f_sprintf(2); +  } else { +  push_text("MutexKey()"); +  } + } +    /*! @endclass    */   
2283:    tObjIs_THREAD_ID, T_OBJECT, 0);    PIKE_MAP_VARIABLE("_mutex", mutex_key_offset + OFFSETOF(key_storage, mutex_obj),    tObjIs_THREAD_MUTEX, T_OBJECT, ID_PROTECTED|ID_PRIVATE); +  ADD_FUNCTION("_sprintf",f_mutex_key__sprintf,tFunc(tInt,tStr),ID_PROTECTED);    set_init_callback(init_mutex_key_obj);    set_exit_callback(exit_mutex_key_obj);    mutex_key=Pike_compiler->new_program;