#ifndef lint
static char *rcsid_sms_param_c = "$Header$";
-#endif lint
+#endif
#include <mit-copyright.h>
#include <sys/types.h>
#include <netinet/in.h>
#include "mr_private.h"
+#include <string.h>
+#include <stdlib.h>
/*
* GDB operations to send and recieve RPC requests and replies.
* write of the next bunch of data.
*/
+/*ARGSUSED*/
mr_cont_send(op, hcon, arg)
OPERATION op;
HALF_CONNECTION hcon;
* At least for now, each argument is a string, which is
* sent as a count of bytes followed by the bytes
* (including the trailing '\0'), padded
- * to a longword boundary.
+ * to a 32-bit boundary.
*/
- mr_size = 4 * sizeof(long);
+ mr_size = 4 * sizeof(int32);
argl = (int *)malloc((unsigned)(sizeof(int) * arg->mr_argc));
argl[i] = len = arg->mr_argl[i];
else
argl[i] = len = strlen(arg->mr_argv[i]) + 1;
- mr_size += sizeof(long) + len;
- /* Round up to next longword boundary.. */
- mr_size = sizeof(long) * howmany(mr_size, sizeof(long));
+ mr_size += sizeof(int32) + len;
+ /* Round up to next 32-bit boundary.. */
+ mr_size = sizeof(int32) * howmany(mr_size, sizeof(int32));
}
arg->mr_flattened = buf = malloc(mr_size);
- bzero(arg->mr_flattened, mr_size);
+ memset(arg->mr_flattened, 0, mr_size);
arg->mr_size = mr_size;
- /*
- * This is gross. Any better suggestions, anyone?
- * It should work on the RT's, since malloc is guaranteed to
- * return a pointer which is aligned correctly for any data.
- */
-
- ((long *)buf)[0] = htonl(mr_size);
- ((long *)buf)[1] = htonl(arg->mr_version_no);
- ((long *)buf)[2] = htonl(arg->mr_procno);
- ((long *)buf)[3] = htonl(arg->mr_argc);
+ ((int32 *)buf)[0] = htonl(mr_size);
+ ((int32 *)buf)[1] = htonl(arg->mr_version_no);
+ ((int32 *)buf)[2] = htonl(arg->mr_procno);
+ ((int32 *)buf)[3] = htonl(arg->mr_argc);
/*
* bp is a pointer into the point in the buffer to put
* the next argument.
*/
- bp = (char *)(((long *)buf) + 4);
+ bp = (char *)(((int32 *)buf) + 4);
for (i = 0; i<arg->mr_argc; ++i) {
len = argl[i];
- *((long *)bp) = htonl(len);
- bp += sizeof(long);
- bcopy(arg->mr_argv[i], bp, len);
- bp += sizeof(long) * howmany(len, sizeof(long));
+ *((int32 *)bp) = htonl(len);
+ bp += sizeof(int32);
+ memcpy(bp, arg->mr_argv[i], len);
+ bp += sizeof(int32) * howmany(len, sizeof(int32));
}
op->fcn.cont = mr_cont_send;
arg->mr_size = mr_size;
else return OP_RUNNING;
}
+/*ARGSUSED*/
mr_cont_recv(op, hcon, argp)
OPERATION op;
HALF_CONNECTION hcon;
case S_RECV_START:
arg->mr_state = S_RECV_DATA;
if (gdb_receive_data(hcon, (caddr_t)&arg->mr_size,
- sizeof(long)) == OP_COMPLETE)
+ sizeof(int32)) == OP_COMPLETE)
continue;
done = TRUE;
break;
}
arg->mr_flattened = malloc(arg->mr_size);
arg->mr_state = S_DECODE_DATA;
- bcopy((caddr_t)&arg->mr_size, arg->mr_flattened, sizeof(long));
+ memcpy(arg->mr_flattened, (caddr_t)&arg->mr_size, sizeof(int32));
if (gdb_receive_data(hcon,
- arg->mr_flattened + sizeof(long),
- arg->mr_size - sizeof(long))
+ arg->mr_flattened + sizeof(int32),
+ arg->mr_size - sizeof(int32))
== OP_COMPLETE)
continue;
done = TRUE;
for (i = 0; i<arg->mr_argc; ++i) {
u_short nlen = ntohl(* (int *) cp);
- cp += sizeof (long);
+ cp += sizeof (int32);
if (cp + nlen > arg->mr_flattened + arg->mr_size) {
free(arg->mr_flattened);
arg->mr_flattened = NULL;
return OP_CANCELLED;
}
arg->mr_argv[i] = (char *)malloc(nlen);
- bcopy(cp, arg->mr_argv[i], nlen);
+ memcpy(arg->mr_argv[i], cp, nlen);
arg->mr_argl[i]=nlen;
- cp += sizeof(long) * howmany(nlen, sizeof(long));
+ cp += sizeof(int32) * howmany(nlen, sizeof(int32));
}
free(arg->mr_flattened);
arg->mr_flattened = NULL;