Merge remote-tracking branch 'upstream/master' into master-to-security
This commit is contained in:
commit
67c49235db
110 changed files with 2714 additions and 4540 deletions
|
|
@ -583,7 +583,7 @@ int double_to_dds_duration(dds_duration_t *dd, double d) {
|
|||
if (d < 0)
|
||||
return -1;
|
||||
double nanosec = d * 1e9;
|
||||
if(nanosec > INT64_MAX) {
|
||||
if(nanosec > (double)INT64_MAX) {
|
||||
*dd = DDS_INFINITY;
|
||||
} else {
|
||||
*dd = (int64_t) nanosec;
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ static enum tgprint_mode printmode = TGPM_FIELDS;
|
|||
static unsigned print_metadata = PM_STATE;
|
||||
static int printtype = 0;
|
||||
|
||||
#define T_SECOND ((int64_t) 1000000000)
|
||||
struct tstamp_t {
|
||||
int isabs;
|
||||
int64_t t;
|
||||
|
|
@ -351,7 +350,7 @@ static int read_int_w_tstamp(struct tstamp_t *tstamp, char *buf, int bufsize, in
|
|||
posoff = 1;
|
||||
}
|
||||
if (read_int(buf, bufsize, pos + posoff, 1))
|
||||
tstamp->t = atoi(buf + pos) * T_SECOND;
|
||||
tstamp->t = atoi(buf + pos) * DDS_NSECS_IN_SEC;
|
||||
else
|
||||
return 0;
|
||||
while ((c = getc(stdin)) != EOF && isspace((unsigned char) c))
|
||||
|
|
@ -411,7 +410,7 @@ static int read_value(char *command, int *key, struct tstamp_t *tstamp, char **a
|
|||
return 1;
|
||||
}
|
||||
break;
|
||||
case 'p': case 'S': case ':': case 'Q': {
|
||||
case 'p': case 'S': case 'C': case ':': case 'Q': {
|
||||
int i = 0;
|
||||
*command = (char) c;
|
||||
while ((c = getc(stdin)) != EOF && !isspace((unsigned char) c)) {
|
||||
|
|
@ -1165,6 +1164,53 @@ static void pub_do_auto(const struct writerspec *spec) {
|
|||
dds_free(handle);
|
||||
}
|
||||
|
||||
static void do_deafmute(const char *args)
|
||||
{
|
||||
const char *a = args;
|
||||
bool deaf = false;
|
||||
bool mute = false;
|
||||
dds_duration_t duration = 0;
|
||||
double durfloat;
|
||||
int pos;
|
||||
if (strncmp(a, "self", 4) == 0) {
|
||||
a += 4;
|
||||
} else {
|
||||
printf ("deafmute: invalid args: %s\n", args);
|
||||
return;
|
||||
}
|
||||
if (*a++ != ';') {
|
||||
printf ("deafmute: invalid args: %s\n", args);
|
||||
return;
|
||||
}
|
||||
while (*a && *a != ';') {
|
||||
switch (*a++) {
|
||||
case 'm': mute = true; break;
|
||||
case 'd': deaf = true; break;
|
||||
default: printf ("deafmute: invalid flags: %s\n", args); return;
|
||||
}
|
||||
}
|
||||
if (*a++ != ';') {
|
||||
printf ("deafmute: invalid args: %s\n", args);
|
||||
return;
|
||||
}
|
||||
if (strcmp(a, "inf") == 0) {
|
||||
duration = DDS_INFINITY;
|
||||
} else if (sscanf(a, "%lf%n", &durfloat, &pos) == 1 && a[pos] == 0) {
|
||||
if (durfloat <= 0.0) {
|
||||
printf ("deafmute: invalid duration (<= 0): %s\n", args);
|
||||
return;
|
||||
}
|
||||
if (durfloat > (double) (DDS_INFINITY / DDS_NSECS_IN_SEC))
|
||||
duration = DDS_INFINITY;
|
||||
else
|
||||
duration = (dds_duration_t) (durfloat * 1e9);
|
||||
} else {
|
||||
printf ("deafmute: invalid args: %s\n", args);
|
||||
return;
|
||||
}
|
||||
dds_domain_set_deafmute (dp, deaf, mute, duration);
|
||||
}
|
||||
|
||||
static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
||||
struct tstamp_t tstamp_spec = { .isabs = 0, .t = 0 };
|
||||
int result;
|
||||
|
|
@ -1210,7 +1256,7 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
|||
tstamp = dds_time();
|
||||
tstamp_spec.t += tstamp;
|
||||
}
|
||||
tstamp = (tstamp_spec.t % T_SECOND) + ((int) (tstamp_spec.t / T_SECOND) * DDS_NSECS_IN_SEC);
|
||||
tstamp = (tstamp_spec.t % DDS_NSECS_IN_SEC) + ((int) (tstamp_spec.t / DDS_NSECS_IN_SEC) * DDS_NSECS_IN_SEC);
|
||||
if ((result = fn(spec->wr, &d, tstamp)) != DDS_RETCODE_OK) {
|
||||
printf ("%s %d: error %d (%s)\n", get_write_operstr(command), k, (int) result, dds_err_str(result));
|
||||
if (flushflag) {
|
||||
|
|
@ -1279,6 +1325,9 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
|||
case 'Y': case 'B': case 'E': case 'W':
|
||||
non_data_operation(command, spec->wr);
|
||||
break;
|
||||
case 'C':
|
||||
do_deafmute(arg);
|
||||
break;
|
||||
case ':':
|
||||
break;
|
||||
default:
|
||||
|
|
@ -1311,7 +1360,7 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
|||
// command = *line++;
|
||||
// if (*line == '@') {
|
||||
// if (*++line == '=') { ++line; tstamp_spec.isabs = 1; }
|
||||
// tstamp_spec.t = T_SECOND * strtol(line, (char **) &line, 10);
|
||||
// tstamp_spec.t = DDS_NSECS_IN_SEC * strtol(line, (char **) &line, 10);
|
||||
// }
|
||||
// case '{': {
|
||||
// write_oper_t fn = get_write_oper(command);
|
||||
|
|
@ -1324,10 +1373,10 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
|||
// int diddodup = 0;
|
||||
// if (!tstamp_spec.isabs) {
|
||||
// DDS_DomainParticipant_get_current_time(dp, &tstamp);
|
||||
// tstamp_spec.t += tstamp.sec * T_SECOND + tstamp.nanosec;
|
||||
// tstamp_spec.t += tstamp.sec * DDS_NSECS_IN_SEC + tstamp.nanosec;
|
||||
// }
|
||||
// tstamp.sec = (int) (tstamp_spec.t / T_SECOND);
|
||||
// tstamp.nanosec = (unsigned) (tstamp_spec.t % T_SECOND);
|
||||
// tstamp.sec = (int) (tstamp_spec.t / DDS_NSECS_IN_SEC);
|
||||
// tstamp.nanosec = (unsigned) (tstamp_spec.t % DDS_NSECS_IN_SEC);
|
||||
// line = endp;
|
||||
// result = fn(spec->wr, arb, DDS_HANDLE_NIL, &tstamp);
|
||||
// if (result == DDS_RETCODE_OK && spec->dupwr) {
|
||||
|
|
@ -1363,6 +1412,10 @@ static char *pub_do_nonarb(const struct writerspec *spec, uint32_t *seq) {
|
|||
// case 'Y': case 'B': case 'E': case 'W':
|
||||
// non_data_operation(*line, spec->wr);
|
||||
// break;
|
||||
// case 'C':
|
||||
// do_deafmute(arg);
|
||||
// line = NULL;
|
||||
// break;
|
||||
// case 'S':
|
||||
// make_persistent_snapshot(line+1);
|
||||
// line = NULL;
|
||||
|
|
@ -2631,8 +2684,8 @@ int main(int argc, char *argv[]) {
|
|||
// }
|
||||
// tnow = dds_time();
|
||||
// if (m != 0 && tnow < tend) {
|
||||
// uint64_t tdelta = (tend-tnow) < T_SECOND/10 ? tend-tnow : T_SECOND/10;
|
||||
// os_time delay = { (os_timeSec) (tdelta / T_SECOND), (os_int32) (tdelta % T_SECOND)};
|
||||
// uint64_t tdelta = (tend-tnow) < DDS_NSECS_IN_SEC/10 ? tend-tnow : DDS_NSECS_IN_SEC/10;
|
||||
// os_time delay = { (os_timeSec) (tdelta / DDS_NSECS_IN_SEC), (os_int32) (tdelta % DDS_NSECS_IN_SEC)};
|
||||
// os_nanoSleep(delay);
|
||||
// tnow = dds_time();
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue