5 Pack/UnPack Library for UIUC Parallel Programming Lab
7 Orion Sky Lawlor, olawlor@uiuc.edu, 9/11/2000
9 This library allows you to easily pack an array, structure,
10 or object into a memory buffer or disk file, and then read
11 the object back later. The library will also handle translating
12 between different machine representations for integers and floats.
14 This is the C binding-- the main library is in C++.
15 From C, you can write a pup routine (the client part of the
16 library), but you can't make pup_er's (the system part).
18 Typically, the user has to write separate functions for buffer
19 sizing, pack to memory, unpack from memory, pack to disk, and
20 unpack from disk. These functions all perform the exact same function--
21 namely, they list the members of the array, struct, or object.
22 Further, all the functions must agree, or the unpacked data will
23 be garbage. This library allows the user to write *one* function,
24 which will perform all needed packing/unpacking.
34 void pup_foo(pup_er p,foo *f)
42 A more complex example is:
45 int nArr; <- Length of array below
46 double *arr; <- Heap-allocated array
49 void pup_bar(pup_er p,bar *b)
53 if (pup_isUnpacking(p))
54 b->arr=(double *)malloc(b->nArr*sizeof(double));
55 pup_doubles(p,b->arr,b->nArr);
60 #include "conv-config.h"
67 /*This is actually a PUP::er *, cast to void *.
68 From C++, you can pass "&p" as a pup_er.
73 #ifndef AMPI_INTERNAL_SKIP_FUNCTIONS
75 #define AMPI_CUSTOM_FUNC(return_type, function_name, ...) \
76 extern return_type function_name(__VA_ARGS__);
78 #include "pup_c_functions.h"
80 #undef AMPI_CUSTOM_FUNC
82 #endif /* !defined AMPI_INTERNAL_SKIP_FUNCTIONS */
85 /* These MUST match the sync declarations in pup.h */
87 pup_sync_builtin
=0x70000000, /* Built-in, standard sync codes begin here */
88 pup_sync_begin
=pup_sync_builtin
+0x01000000, /* Sync code at start of collection */
89 pup_sync_end
=pup_sync_builtin
+0x02000000, /* Sync code at end of collection */
90 pup_sync_last_system
=pup_sync_builtin
+0x09000000, /* Sync code at end of "system" portion of object */
91 pup_sync_array_m
=0x00100000, /* Linear-indexed (0..n) array-- use item to separate */
92 pup_sync_list_m
=0x00200000, /* Some other collection-- use index and item */
93 pup_sync_object_m
=0x00300000, /* Sync mask for general object */
95 pup_sync_begin_array
=pup_sync_begin
+pup_sync_array_m
,
96 pup_sync_begin_list
=pup_sync_begin
+pup_sync_list_m
,
97 pup_sync_begin_object
=pup_sync_begin
+pup_sync_object_m
,
99 pup_sync_end_array
=pup_sync_end
+pup_sync_array_m
,
100 pup_sync_end_list
=pup_sync_end
+pup_sync_list_m
,
101 pup_sync_end_object
=pup_sync_end
+pup_sync_object_m
,
103 pup_sync_item
=pup_sync_builtin
+0x00110000, /* Sync code for a list or array item */
104 pup_sync_index
=pup_sync_builtin
+0x00120000, /* Sync code for index of item in a list */