/usr/share/slsh/local-packages/pvm.sl is in slang-pvm 0.1.5-12.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | %-*- mode: slang; mode: fold; -*-
import ("pvm");
#iffalse
require ("xpvm");
#ifexists xpvm_setup
% optionally support using XPVM for process tracing
xpvm_setup ();
#endif
#endif
public define pvm_psend () %{{{
{
variable objs = __pop_args (_NARGS-2);
variable msgid = ();
variable tid = ();
() = pvm_initsend (PvmDataDefault);
foreach (objs)
{
variable data = ();
pvm_pack (data.value);
}
pvm_send (tid, msgid);
}
%}}}
static define pack_item ();
static define unpack_item ();
static define unpack_strings (num) %{{{
{
if (num == 0)
return String_Type[0];
variable s = DataType_Type[num];
s[*] = String_Type;
return array_map (String_Type, &pvm_unpack, s);
}
%}}}
static define pack_strings (a) %{{{
{
if (length (a) > 0)
array_map (Void_Type, &pvm_pack, a);
}
%}}}
static define unpack_one_struct (i) %{{{
{
variable names, s;
names = unpack_item ();
if (typeof(names) != Array_Type)
names = [names];
eval (sprintf ("define __atos__(){return struct {%s};}",
strjoin (names, ",")));
s = eval ("__atos__()");
foreach (names)
{
variable n = ();
set_struct_field (s, n, unpack_item());
}
return s;
}
%}}}
static define pack_one_struct (s) %{{{
{
variable names, value;
names = get_struct_field_names (s);
pack_item (names);
foreach (names)
{
variable name = ();
value = get_struct_field (s, name);
pack_item (value);
}
}
%}}}
static define unpack_struct (num) %{{{
{
if (num == 0)
return Struct_Type[0];
return array_map (Struct_Type, &unpack_one_struct, [0:num-1]);
}
%}}}
static define pack_struct (a) %{{{
{
array_map (Void_Type, &pack_one_struct, a);
}
%}}}
static define unpack_one_assoc (num) %{{{
{
variable names = unpack_item ();
if (length(names) == 1)
names = [names];
variable a = Assoc_Type[];
foreach (names)
{
variable n = ();
a[n] = unpack_item ();
}
return a;
}
%}}}
static define pack_one_assoc (a) %{{{
{
variable names = assoc_get_keys (a);
pack_item (names);
foreach (names)
{
variable n = ();
pack_item (a[n]);
}
}
%}}}
static define unpack_assoc (len) %{{{
{
if (len == 0)
return Assoc_Type[];
return unpack_one_assoc (len);
}
%}}}
static define pack_assoc (a) %{{{
{
pack_one_assoc(a);
}
%}}}
static define unpack_item () %{{{
{
variable type, num, item;
type = __datatype(pvm_unpack (Int_Type, 1)[0]);
num = pvm_unpack (Int_Type, 1)[0];
switch (type)
{
case String_Type:
item = unpack_strings (num);
}
{
case Struct_Type:
item = unpack_struct (num);
}
{
case Assoc_Type:
item = unpack_assoc (num);
}
{
case Null_Type:
item = Null_Type[num];
}
{
% default
item = pvm_unpack (type, num);
}
if (num == 1 and type != Assoc_Type)
return item[0];
return item;
}
%}}}
static define pack_item (item) %{{{
{
variable type;
if (is_struct_type (item))
type = typeof (struct{x});
else
type = _typeof(item);
pvm_pack (__class_id(type));
pvm_pack (length(item));
switch (type)
{
case String_Type:
pack_strings (item);
}
{
case Struct_Type:
pack_struct (item);
}
{
case Assoc_Type:
pack_assoc (item);
}
{
case Null_Type:
return;
}
{
% default:
pvm_pack (item);
}
}
%}}}
public define pvm_send_obj () %{{{
{
variable objs = __pop_args (_NARGS-2);
variable msgid = ();
variable tid = ();
() = pvm_initsend (PvmDataDefault);
foreach (objs)
{
variable data = ();
pack_item (data.value);
}
pvm_send (tid, msgid);
}
%}}}
public define pvm_recv_obj () %{{{
{
return unpack_item ();
}
%}}}
public define pvm_addhosts () %{{{
{
variable args = __pop_args (_NARGS);
variable hosts = [__push_args (args)];
return array_map (Int_Type, &pvm_addhost, hosts);
}
%}}}
public define pvm_delhosts () %{{{
{
variable args = __pop_args (_NARGS);
variable hosts = [__push_args (args)];
array_map (Void_Type, &pvm_delhost, hosts);
}
%}}}
provide ("pvm");
#ifexists add_doc_file
$1 = path_concat (path_concat (path_dirname (__FILE__), "help"),
"pvm.hlp");
if (NULL != stat_file ($1))
add_doc_file ($1);
#endif
|