int main(int argc,char** argv) { if(argc<3) { printf("usage %s <length> <num> \n",argv[0]); exit(-1); } FILE* bash=fopen("bash.dat","w+"); FILE* python=fopen("py.dat","w+"); int num=atoi(argv[2]); int length=atoi(argv[1]); set_exe_name(" bg_expr "); srand(time(NULL)); int i=0; for(;i<num;i++) { gen_value(buf_l,length); gen_value(buf_r,length); bash_write(bash," div "); python_write(python," / "); } fclose(bash); fclose(python); return 0; }
static ssize_t python_pwrite(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n, off_t offset) { struct pyfuncs *pf = handle->data; PyObject *pArgs, *pRet, *pValue; char *pydata; ssize_t s; if (!pf->pFuncPRead) { off_t original_pos; /* * Simulate pread with lseek and read (like the default implementation * does. */ if ((original_pos = python_lseek(handle, fsp, 0, SEEK_CUR)) == -1) return -1; if (python_lseek(handle, fsp, offset, SEEK_SET) == -1) return -1; s = python_write(handle, fsp, data, n); if (python_lseek(handle, fsp, original_pos, SEEK_SET) == -1) return -1; return s; } PY_TUPLE_NEW(3); PY_ADD_TO_TUPLE(fsp->fh->fd, PyInt_FromSsize_t, 0); if (!(pValue = PyString_FromStringAndSize(data, n))) { Py_DECREF(pArgs); errno = E_INTERNAL; return -1; } PyTuple_SetItem(pArgs, 1, pValue); PY_ADD_TO_TUPLE(offset, PyInt_FromSize_t, 2); PY_CALL_WITH_ARGS(PWrite); s = PyInt_AsSsize_t(pRet); Py_DECREF(pRet); return s; }