Example #1
0
Obj MPIerror_string( Obj self, Obj errorcode )
{ int resultlen;
  Obj str;
  str = NEW_STRING( 72 );
  MPI_Error_string( INT_INTOBJ(errorcode),
		    (char*)CSTR_STRING(str), &resultlen);
  ((char*)CSTR_STRING(str))[resultlen] = '\0';
  SET_LEN_STRING(str, resultlen);
  ResizeBag( str, SIZEBAG_STRINGLEN( GET_LEN_STRING(str) ) );
  return str;
}
Example #2
0
Obj MPIget_processor_name( Obj self )
{ int resultlen;
  Obj str;
  /* It was reported by Frank Celler that a value of 72 instead of 1024 below
     caused overwriting of the free block list on PC in GAP-3 */
  str = NEW_STRING( 1024 );
  MPI_Get_processor_name( (char*)CSTR_STRING(str), &resultlen);
  ((char*)CSTR_STRING(str))[resultlen] = '\0';
#ifndef PRE_GAP_4_3
  SET_LEN_STRING(str, resultlen);
  ResizeBag( str, SIZEBAG_STRINGLEN( GET_LEN_STRING(str) ) );
#endif
  return str;
}
Example #3
0
Obj FuncREAD_IOSTREAM_NOWAIT(Obj self, Obj stream, Obj len)
{
  Obj string;
  UInt pty = INT_INTOBJ(stream);
  Int ret;
  string = NEW_STRING(INT_INTOBJ(len));
  while (!PtyIOStreams[pty].inuse)
    pty = INT_INTOBJ(ErrorReturnObj("IOSTREAM %d is not in use",pty,0L,
                                    "you can replace stream number <num> via 'return <num>;'"));
  /* HandleChildStatusChanges(pty);   Omit this to allow picking up "trailing" bytes*/
  ret = ReadFromPty2(pty, CSTR_STRING(string), INT_INTOBJ(len), 0);
  if (ret == -1)
    return Fail;
  SET_LEN_STRING(string, ret);
  ResizeBag(string, SIZEBAG_STRINGLEN(ret));
  return string;
}
Example #4
0
Int GrowWPObj (
               Obj                 wp,
               UInt                need )
{
  UInt                plen;           /* new physical length             */
  UInt                good;           /* good new physical length        */

    /* find out how large the object should become                     */
    good = 5 * (SIZE_OBJ(wp)/sizeof(Obj)-1) / 4 + 4;

    /* but maybe we need more                                              */
    if ( need < good ) { plen = good; }
    else               { plen = need; }

    /* resize the plain list                                               */
    ResizeBag( wp, ((plen)+1)*sizeof(Obj) );

    /* return something (to please some C compilers)                       */
    return 0L;
}