correct byte order conversions for size_t == 8 bytes
This commit was SVN r6577.
Этот коммит содержится в:
родитель
a4497238ad
Коммит
7010548c1b
@ -59,15 +59,65 @@ int mca_oob_tcp_init(void);
|
|||||||
*/
|
*/
|
||||||
int mca_oob_tcp_fini(void);
|
int mca_oob_tcp_fini(void);
|
||||||
|
|
||||||
|
#if SIZEOF_SIZE_T == 8
|
||||||
|
/*
|
||||||
|
* Convert a 64 bit value to network byte order.
|
||||||
|
*/
|
||||||
|
static inline uint64_t hton64(uint64_t val)
|
||||||
|
{
|
||||||
|
union { uint64_t ll;
|
||||||
|
uint32_t l[2];
|
||||||
|
} w, r;
|
||||||
|
|
||||||
|
/* platform already in network byte order? */
|
||||||
|
if(htonl(1) == 1L)
|
||||||
|
return val;
|
||||||
|
w.ll = val;
|
||||||
|
r.l[0] = htonl(w.l[1]);
|
||||||
|
r.l[1] = htonl(w.l[0]);
|
||||||
|
return r.ll;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert a 64 bit value from network to host byte order.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline uint64_t ntoh64(uint64_t val)
|
||||||
|
{
|
||||||
|
union { uint64_t ll;
|
||||||
|
uint32_t l[2];
|
||||||
|
} w, r;
|
||||||
|
|
||||||
|
/* platform already in network byte order? */
|
||||||
|
if(htonl(1) == 1L)
|
||||||
|
return val;
|
||||||
|
w.ll = val;
|
||||||
|
r.l[0] = ntohl(w.l[1]);
|
||||||
|
r.l[1] = ntohl(w.l[0]);
|
||||||
|
return r.ll;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert process name from host to network byte order.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
#define OMPI_PROCESS_NAME_HTON(n) \
|
||||||
|
n.cellid = hton64(n.cellid); \
|
||||||
|
n.jobid = hton64(n.jobid); \
|
||||||
|
n.vpid = hton64(n.vpid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert process name from network to host byte order.
|
* Convert process name from network to host byte order.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
#define OMPI_PROCESS_NAME_NTOH(n) \
|
#define OMPI_PROCESS_NAME_NTOH(n) \
|
||||||
n.cellid = ntohl(n.cellid); \
|
n.cellid = ntoh64(n.cellid); \
|
||||||
n.jobid = ntohl(n.jobid); \
|
n.jobid = ntoh64(n.jobid); \
|
||||||
n.vpid = ntohl(n.vpid);
|
n.vpid = ntoh64(n.vpid);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert process name from host to network byte order.
|
* Convert process name from host to network byte order.
|
||||||
@ -79,6 +129,16 @@ int mca_oob_tcp_fini(void);
|
|||||||
n.jobid = htonl(n.jobid); \
|
n.jobid = htonl(n.jobid); \
|
||||||
n.vpid = htonl(n.vpid);
|
n.vpid = htonl(n.vpid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert process name from network to host byte order.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
#define OMPI_PROCESS_NAME_HTON(n) \
|
||||||
|
n.cellid = ntohl(n.cellid); \
|
||||||
|
n.jobid = ntohl(n.jobid); \
|
||||||
|
n.vpid = ntohl(n.vpid);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two process names for equality.
|
* Compare two process names for equality.
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user