source: git/MP/mp-pvm3/mp_pvm.c @ 678cfd

spielwiese
Last change on this file since 678cfd was 678cfd, checked in by Olaf Bachmann <obachman@…>, 27 years ago
This commit was generated by cvs2svn to compensate for changes in r337, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@338 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 * This is "mp_pvm.c". It contains all MP's utility routines associated with
3 * PVM. It is to be included with all applications that employ PVM to
4 * transport MP trees.
5 *
6 * Note:
7 *       mp_pvm_unpack() anticipates PvmNoData error from pvm_recv().
8 *       PVM defaults to printing an error message when encounter such
9 *       error. To disable printing of error message, use the following:
10 *
11 *              pvm_setopt(PvmAutoErr, 0);
12 *
13 *       See "PVM 3 User'sGuide and Reference Manual" for detail.
14 */
15
16/*********************************************************
17 * mp_pvm_pack(link, where, len)
18 * return: 0 if success, -1 if failure.
19 * arguments: link - can be anything, even NULL.
20 *            where - pointer to data to be packed.
21 *            len - number of bytes to be packed.
22 *********************************************************/
23int
24#ifdef _ANSIC_
25mp_pvm_pack(MP_Link_pt link, char *where, unsigned long len)
26#else
27mp_pvm_pack(link, where, len)
28MP_Link_pt link;
29char *where;
30unsigned long len;
31#endif
32{
33  int status;
34  status = pvm_pkbyte(where, len, 1);
35  if (status < 0) return(-1);
36  else return(len);
37}
38
39/*********************************************************
40 * mp_pvm_unpack(link, where, len)
41 * return: number of bytes actually unpacked. -1 if failure.
42 * arguments: link - can be anything, even NULL.
43 *            where - pointer to memory location to store unpacked data.
44 *            len - number of bytes to be packed.
45 *********************************************************/
46int
47#ifdef _ANSIC_
48mp_pvm_unpack(MP_Link_pt link, char *where, unsigned long len)
49#else
50mp_pvm_unpack(link, where, len)
51MP_Link_pt link;
52char *where;
53unsigned long len;
54#endif
55{
56  int status, bufid, actual_len, lenrecv, tid, msgtag;
57  actual_len = len;
58  status = pvm_upkbyte(where, actual_len, 1);
59  if (status == PvmNoData) {
60    bufid = pvm_recv(-1, -1);
61    if (bufid < 0) return(-1);
62    status = pvm_bufinfo(bufid, &lenrecv, &msgtag, &tid);
63    actual_len = (len < lenrecv) ? len : lenrecv;
64    status = pvm_upkbyte(where, actual_len, 1);
65  }
66 
67  if (status < 0) return(-1);
68  return(actual_len);
69}
Note: See TracBrowser for help on using the repository browser.