resource C_externals() external getpid() returns int # UNIX system call returning process id # supported by C runtime library external which_bits_set(ref bits_are_set[*] : int; set_of_bits : int) returns int # user-defined C function var pid : int var num_bits_set : int var bits_are_set[32] : int pid := getpid() num_bits_set := which_bits_set(bits_are_set, pid) write("the pid is", pid, "and it has", num_bits_set, "bits set:") fa i := 1 to num_bits_set -> writes(" ", bits_are_set[i]) af; write() end C_externals /* ............... Example compile and run(s) % sr -v; sr -c C_externals.sr SR version 2.3, October 1994 % cc -c which_bits_set.c % srl -o C_ext_test which_bits_set.o C_externals % ./C_ext_test the pid is 28230 and it has 8 bits set: 1 2 6 9 10 11 13 14 % ./C_ext_test the pid is 28231 and it has 9 bits set: 0 1 2 6 9 10 11 13 14 % ./C_ext_test the pid is 28232 and it has 7 bits set: 3 6 9 10 11 13 14 */