00001 #include "pup_cmialloc.h"
00002
00003 void PUP_cmiAllocSizer::bytes(void *,size_t n,size_t itemSize,PUP::dataType) {
00004 nBytes += n * itemSize;
00005 }
00006
00007 void PUP_toCmiAllocMem::bytes(void *p, size_t n, size_t itemSize,
00008 PUP::dataType t) {
00009
00010 n *= itemSize;
00011 memcpy((void *)buf, p, n);
00012 buf += n;
00013 }
00014
00015 void PUP_fromCmiAllocMem::bytes(void *p, size_t n, size_t itemSize,
00016 PUP::dataType t)
00017 {
00018 n*=itemSize;
00019 memcpy(p,(const void *)buf,n);
00020
00021 buf+= n;
00022 }
00023
00024 void PUP_cmiAllocSizer::pupCmiAllocBuf(void **msg) {
00025 CmiChunkHeader chnk_hdr = *(BLKSTART(*msg));
00026 pupCmiAllocBuf(msg, chnk_hdr.size);
00027 }
00028
00029 void PUP_cmiAllocSizer::pupCmiAllocBuf(void **msg, size_t msg_size) {
00030
00031
00032
00033 nBytes = ALIGN8(nBytes);
00034
00035 nBytes += sizeof(CmiChunkHeader);
00036
00037
00038 nBytes += msg_size;
00039 }
00040
00041
00042 void PUP_toCmiAllocMem::pupCmiAllocBuf(void **msg) {
00043 pupCmiAllocBuf(msg, SIZEFIELD(msg));
00044 }
00045
00046 void PUP_toCmiAllocMem::pupCmiAllocBuf(void **msg, size_t msg_size) {
00047
00048 CmiChunkHeader chnk_hdr;
00049
00050 buf = origBuf + ALIGN8_LONG(size());
00051
00052 chnk_hdr.size = msg_size;
00053 chnk_hdr.setRef(origBuf - (buf + sizeof(CmiChunkHeader)));
00054
00055
00056 memcpy(buf, &chnk_hdr, sizeof(CmiChunkHeader));
00057 buf += sizeof(CmiChunkHeader);
00058
00059
00060
00061
00062 memcpy(buf, *msg, msg_size);
00063 buf += msg_size;
00064 }
00065
00066 void PUP_fromCmiAllocMem::pupCmiAllocBuf(void **msg) {
00067
00068 buf = (PUP::myByte *)(intptr_t)ALIGN8_LONG((intptr_t)buf);
00069
00070
00071 CmiChunkHeader chnk_hdr;
00072
00073 memcpy(&chnk_hdr, buf, sizeof(CmiChunkHeader));
00074 buf += sizeof(CmiChunkHeader);
00075
00076
00077 *msg = buf;
00078
00079
00080 buf += chnk_hdr.size;
00081
00082
00083 REFFIELDINC(origBuf);
00084 }
00085
00086
00087
00088