[Openais] [PATCH] Endian fixes
Patrick Caulfield
pcaulfie at redhat.com
Fri Apr 28 09:28:28 PDT 2006
Attached is a patch that (seems to) allow interoperability between bin & =
little-endian machines.
I've briefly tested it between and macmini (running OS/X) and and an =
Intel Linux box. It probably needs some eyes and more testing before =
being committed.
Included are a couple of #includes needed make it compile on Tiger.
Apologies in advance for using alloca() - if people don't like that I'll =
change them.
Patrick
-------------- next part --------------
Index: util.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- util.c (revision 1016)
+++ util.c (working copy)
@@ -36,6 +36,7 @@
#include <string.h>
#include <stdlib.h>
#include <errno.h>
+#include <pthread.h>
#include <sys/time.h>
=
#include "../include/saAis.h"
Index: service.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- service.c (revision 1016)
+++ service.c (working copy)
@@ -37,6 +37,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include <pthread.h>
=
#include "../lcr/lcr_ifact.h"
#include "service.h"
Index: ipc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- ipc.c (revision 1016)
+++ ipc.c (working copy)
@@ -532,7 +532,7 @@
conn_info->authenticated =3D 1;
}
if (conn_info->authenticated =3D=3D 0) {
- log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated because g=
id is %d, expecting %d\n", egid, gid_valid);
+ log_printf (LOG_LEVEL_SECURITY, "Connection not authenticated because g=
id is %d, expecting %d\n", egid, g_gid_valid);
}
#endif
}
Index: clm.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- clm.c (revision 1016)
+++ clm.c (working copy)
@@ -67,6 +67,7 @@
#include "main.h"
#include "mempool.h"
#include "service.h"
+#include "swab.h"
=
#define LOG_SERVICE LOG_SERVICE_CLM
#include "print.h"
@@ -563,6 +564,15 @@
=
static void exec_clm_nodejoin_endian_convert (void *msg)
{
+ struct req_exec_clm_nodejoin *node_join =3D msg;
+
+ node_join->clusterNode.nodeId =3D swab32(node_join->clusterNode.nodeId);
+ node_join->clusterNode.nodeAddress.family =3D swab32(node_join->clusterNo=
de.nodeAddress.family);
+ node_join->clusterNode.nodeAddress.length =3D swab16(node_join->clusterNo=
de.nodeAddress.length);
+ node_join->clusterNode.initialViewNumber =3D swab64(node_join->clusterNod=
e.initialViewNumber);
+
+// SaTimeT bootTimestamp; PJC TODO
+
}
=
static void message_handler_req_exec_clm_nodejoin (
Index: totemsrp.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- totemsrp.c (revision 1016)
+++ totemsrp.c (working copy)
@@ -2391,7 +2391,7 @@
=
addr =3D (struct totem_ip_address *)commit_token->end_of_commit_token;
memb_list =3D (struct memb_commit_token_memb_entry *)(addr + commit_token=
->addr_entries);
-
+ =
memb_index_this =3D (commit_token->memb_index + 1) % commit_token->addr_e=
ntries;
memcpy (&memb_list[memb_index_this].ring_id,
&instance->my_old_ring_id, sizeof (struct memb_ring_id));
@@ -3533,8 +3533,12 @@
=
static void memb_commit_token_endian_convert (struct memb_commit_token *in=
, struct memb_commit_token *out)
{
-#ifdef COMPILE_OUT
+//#ifdef COMPILE_OUT PJC
int i;
+ struct totem_ip_address *in_addr =3D (struct totem_ip_address *)in->end_o=
f_commit_token;
+ struct totem_ip_address *out_addr =3D (struct totem_ip_address *)out->end=
_of_commit_token;
+ struct memb_commit_token_memb_entry *in_memb_list;
+ struct memb_commit_token_memb_entry *out_memb_list;
=
out->header.type =3D in->header.type;
out->header.endian_detector =3D ENDIAN_LOCAL;
@@ -3545,24 +3549,27 @@
out->retrans_flg =3D swab32 (in->retrans_flg);
out->memb_index =3D swab32 (in->memb_index);
out->addr_entries =3D swab32 (in->addr_entries);
+
+ in_memb_list =3D (struct memb_commit_token_memb_entry *)(in_addr + out->a=
ddr_entries);
+ out_memb_list =3D (struct memb_commit_token_memb_entry *)(out_addr + out-=
>addr_entries);
for (i =3D 0; i < out->addr_entries; i++) {
- totemip_copy_endian_convert(&out->addr[i], &in->addr[i]);
+ totemip_copy_endian_convert(&out_addr[i], &in_addr[i]);
=
/*
* Only convert the memb entry if it has been set
*/
- if (in->memb_list[i].ring_id.rep.family !=3D 0) {
- totemip_copy_endian_convert(&out->memb_list[i].ring_id.rep,
- &in->memb_list[i].ring_id.rep);
+ if (in_memb_list[i].ring_id.rep.family !=3D 0) {
+ totemip_copy_endian_convert(&out_memb_list[i].ring_id.rep,
+ &in_memb_list[i].ring_id.rep);
=
- out->memb_list[i].ring_id.seq =3D
- swab64 (in->memb_list[i].ring_id.seq);
- out->memb_list[i].aru =3D swab32 (in->memb_list[i].aru);
- out->memb_list[i].high_delivered =3D swab32 (in->memb_list[i].high_deli=
vered);
- out->memb_list[i].received_flg =3D swab32 (in->memb_list[i].received_fl=
g);
+ out_memb_list[i].ring_id.seq =3D
+ swab64 (in_memb_list[i].ring_id.seq);
+ out_memb_list[i].aru =3D swab32 (in_memb_list[i].aru);
+ out_memb_list[i].high_delivered =3D swab32 (in_memb_list[i].high_delive=
red);
+ out_memb_list[i].received_flg =3D swab32 (in_memb_list[i].received_flg);
}
}
-#endif
+//#endif
}
=
static void orf_token_endian_convert (struct orf_token *in, struct orf_tok=
en *out)
@@ -3620,12 +3627,13 @@
int endian_conversion_needed)
{
struct memb_join *memb_join;
- struct memb_join memb_join_convert;
+ struct memb_join *memb_join_convert =3D alloca (msg_len);
int gather_entered;
=
if (endian_conversion_needed) {
- memb_join =3D &memb_join_convert;
- memb_join_endian_convert (msg, &memb_join_convert);
+ memb_join =3D memb_join_convert;
+ memb_join_endian_convert (msg, memb_join_convert);
+ =
} else {
memb_join =3D (struct memb_join *)msg;
}
@@ -3687,7 +3695,7 @@
int msg_len,
int endian_conversion_needed)
{
- struct memb_commit_token memb_commit_token_convert;
+ struct memb_commit_token *memb_commit_token_convert =3D alloca (msg_len);
struct memb_commit_token *memb_commit_token;
struct totem_ip_address sub[PROCESSOR_COUNT_MAX];
int sub_entries;
@@ -3696,7 +3704,7 @@
struct memb_commit_token_memb_entry *memb_list;
=
if (endian_conversion_needed) {
- memb_commit_token =3D &memb_commit_token_convert;
+ memb_commit_token =3D memb_commit_token_convert;
memb_commit_token_endian_convert (msg, memb_commit_token);
} else {
memb_commit_token =3D (struct memb_commit_token *)msg;
@@ -3800,7 +3808,12 @@
return;
}
=
- system_from->nodeid =3D message_header->nodeid;
+ if (message_header->endian_detector !=3D ENDIAN_LOCAL) {
+ system_from->nodeid =3D swab32(message_header->nodeid);
+ }
+ else {
+ system_from->nodeid =3D message_header->nodeid;
+ }
assert (system_from->nodeid !=3D 0);
=
/*
More information about the Openais
mailing list