- /* Pack an argument into the message buffer. */
- inline void in (unsigned int count, enum __ioctl_datum type)
- {
- if (count > 0)
- {
- void *const p = &t[1];
- const size_t len = count * ((unsigned int) type << 1);
- *t = io2mach_type (count, type);
- memcpy (p, arg, len);
- arg += len;
- t = p + ((len + sizeof (*t) - 1) / sizeof (*t) * sizeof (*t));
- }
- }
-
- /* Unpack the message buffer into the argument location. */
- inline int out (unsigned int count, unsigned int type,
- void *store, void **update)
- {
- if (count > 0)
- {
- const size_t len = count * (type << 1);
- union { mach_msg_type_t t; int i; } ipctype;
- ipctype.t = io2mach_type (count, type);
- if (*(int *) t != ipctype.i)
- return 1;
- ++t;
- memcpy (store, t, len);
- if (update != NULL)
- *update += len;
- t = (void *) t + ((len + sizeof (*t) - 1) / sizeof (*t) * sizeof *t);
- }
- return 0;
- }
-