Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix several arm7l portability issues #1023

Merged
merged 13 commits into from Apr 3, 2017
Merged
1 change: 1 addition & 0 deletions configure.ac
Expand Up @@ -76,6 +76,7 @@ AC_TYPE_SIZE_T
AX_COMPILE_CHECK_SIZEOF(int)
AX_COMPILE_CHECK_SIZEOF(long)
AX_COMPILE_CHECK_SIZEOF(long long)
AX_COMPILE_CHECK_SIZEOF(uintptr_t, [#include <stdint.h>])
AX_COMPILE_CHECK_SIZEOF(size_t, [#include <stdint.h>])


Expand Down
2 changes: 1 addition & 1 deletion src/bindings/lua/lua-affinity/lua-affinity.c
Expand Up @@ -36,7 +36,7 @@

#include "cpuset-str.h"

#define MAX_LUAINT (0xfffffffffffff0)
#define MAX_LUAINT ((1ULL<<(8*(sizeof(lua_Integer)-1)))-0x10)

static cpu_set_t * l_cpu_set_alloc (lua_State *L)
{
Expand Down
2 changes: 1 addition & 1 deletion src/broker/content-cache.c
Expand Up @@ -450,7 +450,7 @@ static void cache_store_continuation (flux_rpc_t *rpc, void *arg)
done:
if (respond_requests_raw (&e->store_requests, cache->h,
rc < 0 ? saved_errno : 0,
e->blobref, strlen (blobref) + 1) < 0)
e->blobref, strlen (e->blobref) + 1) < 0)
flux_log_error (cache->h, "%s: error responding to store requests",
__FUNCTION__);
flux_rpc_destroy (rpc);
Expand Down
2 changes: 1 addition & 1 deletion src/broker/test/attr.c
Expand Up @@ -174,7 +174,7 @@ int main (int argc, char **argv)
"attr_get on active uint32_t tracks value: %s", val);
b = UINT_MAX - 1;
ok (attr_get (attrs, "b", &val, NULL) == 0
&& strtol (val, NULL, 10) == UINT_MAX - 1,
&& strtoul (val, NULL, 10) == UINT_MAX - 1,
"attr_get on active uint32_t tracks value: %s", val);

ok (attr_set (attrs, "b", "0", false) == 0 && b == 0,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/flux-jstat.c
Expand Up @@ -203,7 +203,7 @@ static int handle_query_req (flux_t *h, int64_t j, const char *k, const char *n)
return -1;
}
jcb = Jfromstr (jcbstr);
fprintf (ctx->op, "Job Control Block: attribute %s for job %ld\n", k, j);
fprintf (ctx->op, "Job Control Block: attribute %s for job %"PRIi64"\n", k, j);
fprintf (ctx->op, "%s\n", jcb == NULL ? jcbstr :
json_object_to_json_string_ext (jcb, JSON_C_TO_STRING_PRETTY));
Jput (jcb);
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/flux-ping.c
Expand Up @@ -137,7 +137,7 @@ void ping_continuation (flux_rpc_t *rpc, void *arg)
if (flux_rpc_next (rpc) < 0) {
if (pdata->rpc_count) {
if (ctx->rank_count > 1) {
printf ("%s!%s pad=%lu seq=%d time=(%0.3f:%0.3f:%0.3f) ms "
printf ("%s!%s pad=%zu seq=%d time=(%0.3f:%0.3f:%0.3f) ms "
"stddev %0.3f\n",
ctx->rank, ctx->topic, strlen (ctx->pad), pdata->seq,
tstat_min (tstat), tstat_mean (tstat),
Expand Down Expand Up @@ -176,8 +176,8 @@ void send_ping (struct ping_ctx *ctx)
rpc = flux_rpcf_multi (ctx->h, ctx->topic, ctx->rank, 0,
"{s:i s:I s:I s:s}",
"seq", ctx->send_count,
"time.tv_sec", t0.tv_sec,
"time.tv_nsec", t0.tv_nsec,
"time.tv_sec", (uint64_t)t0.tv_sec,
"time.tv_nsec", (uint64_t)t0.tv_nsec,
"pad", ctx->pad);
if (!rpc)
log_err_exit ("flux_rpcf_multi");
Expand Down
6 changes: 6 additions & 0 deletions src/common/libflux/flog.c
Expand Up @@ -96,6 +96,12 @@ void flux_log_set_redirect (flux_t *h, flux_log_f fun, void *arg)

const char *flux_strerror (int errnum)
{
/* zeromq-4.2.1 reports EHOSTUNREACH as "Host unreachable",
* but "No route to host" is canonical on Linux and we have some
* tests that depend on it, so remap here.
*/
if (errnum == EHOSTUNREACH)
return "No route to host";
return zmq_strerror (errnum);
}

Expand Down
19 changes: 15 additions & 4 deletions src/common/libutil/coproc.c
Expand Up @@ -79,7 +79,13 @@ void coproc_destroy (coproc_t *c)

static void trampoline (const unsigned int high, const unsigned int low)
{
#if SIZEOF_UINTPTR_T == SIZEOF_INT
coproc_t *c = (coproc_t *)(uintptr_t)(high);
#elif SIZEOF_UINTPTR_T == 8 && SIZEOF_INT == 4
coproc_t *c = (coproc_t *)((((uintptr_t)high) << 32) | low);
#else
#error FIXME: unexpected pointer/integer size
#endif
assert (c->magic == COPROC_MAGIC);

c->rc = c->cb (c, c->arg);
Expand Down Expand Up @@ -156,10 +162,15 @@ int coproc_start (coproc_t *c, void *arg)
return -1;
}

const unsigned int high = ((uintptr_t)c) >> 32;
const unsigned int low = ((uintptr_t)c) & 0xffffffff;
makecontext (&c->uc, (void (*)(void))trampoline, 2, high, low);

#if SIZEOF_UINTPTR_T == SIZEOF_INT
makecontext (&c->uc, (void (*)(void))trampoline, 2,
(uintptr_t)c, 0);
#elif SIZEOF_UINTPTR_T == 8 && SIZEOF_INT == 4
makecontext (&c->uc, (void (*)(void))trampoline, 2,
((uintptr_t)c) >> 32, ((uintptr_t)c) & 0xffffffff);
#else
#error FIXME: unexpected pointer/integer size
#endif
c->arg = arg;
c->state = CS_RUNNING;
return swapcontext (&c->parent, &c->uc);
Expand Down
11 changes: 10 additions & 1 deletion src/common/libutil/log.c
Expand Up @@ -62,7 +62,16 @@ _verr (int errnum, const char *fmt, va_list ap)
{
char *msg = NULL;
char buf[128];
const char *s = zmq_strerror (errnum);
const char *s;

/* zeromq-4.2.1 reports EHOSTUNREACH as "Host unreachable",
* but "No route to host" is canonical on Linux and we have some
* tests that depend on it, so remap here.
*/
if (errnum == EHOSTUNREACH)
s = "No route to host";
else
s = zmq_strerror (errnum);

if (!prog)
log_init (NULL);
Expand Down
63 changes: 46 additions & 17 deletions src/common/libutil/test/coproc.c
Expand Up @@ -143,32 +143,61 @@ int main (int argc, char *argv[])
ok (pthread_join (t, NULL) == 0,
"pthread_join OK");

coproc_t *cps[10000];
for (i = 0; i < 10000; i++) {
if (!(cps[i] = coproc_create (bar_cb)))
// N.B. coproc_create allocates ~2mb per coproc
#define NUM_COPROCS 500
coproc_t *cps[NUM_COPROCS];
for (i = 0; i < NUM_COPROCS; i++) {
if (!(cps[i] = coproc_create (bar_cb))) {
diag ("coproc_create #%d failed: %s", i, strerror (errno));
break;
if (coproc_start (cps[i], NULL) < 0 || coproc_returned (cps[i], NULL))
}
if (coproc_start (cps[i], NULL) < 0) {
diag ("coproc_start #%d failed", i);
break;
}
if (coproc_returned (cps[i], NULL)) {
diag ("coproc_returned #%d returned true", i);
break;
}
}
ok (i == 10000,
"started 10000 coprocs that yielded");
for (i = 0; i < 10000; i++) {
if (coproc_resume (cps[i]) < 0 || coproc_returned (cps[i], NULL))
ok (i == NUM_COPROCS,
"started %d coprocs that yielded", NUM_COPROCS);
int num = i;
if (num != NUM_COPROCS)
diag ("continuing with %d procs", num);
for (i = 0; i < num; i++) {
if (coproc_resume (cps[i]) < 0) {
diag ("coproc_resume #%d failed", i);
break;
}
if (coproc_returned (cps[i], NULL)) {
diag ("coproc_returned #%d returned true", i);
break;
}
}
ok (i == 10000,
"resumed 10000 coprocs that yielded");
ok (i == num,
"resumed %d coprocs that yielded", num);
death = true;
for (i = 0; i < 10000; i++) {
if (coproc_resume (cps[i]) < 0 || !coproc_returned (cps[i], &rc)
|| rc != 0)
for (i = 0; i < num; i++) {
if (coproc_resume (cps[i]) < 0) {
diag ("coproc_resume #%d failed", i);
break;
}
if (!coproc_returned (cps[i], &rc)) {
diag ("coproc_returned #%d returned false", i);
break;
}
if (rc != 0) {
diag ("rc #%d == %d, wanted 0", i, rc);
break;
}
}
ok (i == 10000,
"resumed 10000 coprocs that exited with rc=0");
ok (i == num,
"resumed %d coprocs that exited with rc=0", num);

for (i = 0; i < 10000; i++)
coproc_destroy (cps[i]);
for (i = 0; i < num; i++)
if (cps[i])
coproc_destroy (cps[i]);

/* Test stack guard page(s)
*/
Expand Down
35 changes: 24 additions & 11 deletions src/modules/wreck/wrexecd.c
Expand Up @@ -149,6 +149,19 @@ struct prog_ctx {

int prog_ctx_remove_completion_ref (struct prog_ctx *ctx, const char *fmt, ...);
int prog_ctx_add_completion_ref (struct prog_ctx *ctx, const char *fmt, ...);
static void wlog_msg (struct prog_ctx *ctx, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
static void wlog_error_kvs (struct prog_ctx *ctx, int fatal, const char *fmt, ...)
__attribute__ ((format (printf, 3, 4)));
static void wlog_fatal (struct prog_ctx *ctx, int code, const char *format, ...)
__attribute__ ((format (printf, 3, 4)));
static int wlog_err (struct prog_ctx *ctx, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
static void wlog_msg (struct prog_ctx *ctx, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
static void wlog_debug (struct prog_ctx *ctx, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));


void *lsd_nomem_error (const char *file, int line, char *msg)
{
Expand Down Expand Up @@ -180,15 +193,13 @@ static flux_t *prog_ctx_flux_handle (struct prog_ctx *ctx)
return (t->f);
}

static void wlog_msg (struct prog_ctx *ctx, const char *fmt, ...);

static int archive_lwj (struct prog_ctx *ctx)
{
char *to = ctx->kvspath;
char *link = NULL;
int rc = -1;

wlog_msg (ctx, "archiving lwj %lu", ctx->id);
wlog_msg (ctx, "archiving lwj %" PRIi64, ctx->id);

if (asprintf (&link, "lwj-complete.%d.%"PRId64, ctx->epoch, ctx->id) < 0) {
flux_log_error (ctx->flux, "archive_lwj: asprintf");
Expand Down Expand Up @@ -247,8 +258,10 @@ static void wlog_fatal (struct prog_ctx *ctx, int code, const char *format, ...)
va_start (ap, format);
if ((ctx != NULL) && ((c = prog_ctx_flux_handle (ctx)) != NULL))
flux_vlog (c, LOG_EMERG, format, ap);
else
else {
vfprintf (stderr, format, ap);
putc ('\n', stderr);
}
va_end (ap);

/* Copy error to kvs if we're not in task context:
Expand Down Expand Up @@ -390,7 +403,7 @@ static void wreck_pmi_line (struct task_info *t, const char *line)
struct prog_ctx *ctx = t->ctx;
int rc;
if ((rc = pmi_simple_server_request (ctx->pmi, line, t)) < 0)
wlog_fatal (ctx, 1, "pmi_simple_server_request: %s\n",
wlog_fatal (ctx, 1, "pmi_simple_server_request: %s",
strerror (errno));
if (rc == 1)
wreck_pmi_close (t);
Expand Down Expand Up @@ -965,7 +978,7 @@ int prog_ctx_load_lwj_info (struct prog_ctx *ctx)
wlog_fatal (ctx, 1, "Failed to get resources for this node");
}
else if (kvsdir_get_int (ctx->kvs, "tasks-per-node", &ctx->nprocs) < 0)
ctx->nprocs = 1;
ctx->nprocs = 1;

if (ctx->nprocs <= 0) {
wlog_fatal (ctx, 0,
Expand All @@ -976,7 +989,7 @@ int prog_ctx_load_lwj_info (struct prog_ctx *ctx)
for (i = 0; i < ctx->nprocs; i++)
ctx->task[i] = task_info_create (ctx, i);

wlog_msg (ctx, "lwj %ld: node%d: nprocs=%d, nnodes=%d, cmdline=%s",
wlog_msg (ctx, "lwj %" PRIi64 ": node%d: nprocs=%d, nnodes=%d, cmdline=%s",
ctx->id, ctx->nodeid, ctx->nprocs, ctx->nnodes,
json_object_to_json_string (v));
free (json_str);
Expand Down Expand Up @@ -1645,7 +1658,7 @@ static int l_wreck_log_msg (lua_State *L)
return (2); /* error on stack from l_format_args */
if (!(msg = lua_tostring (L, 2)))
return lua_pusherror (L, "required arg to log_msg missing");
wlog_msg (ctx, msg);
wlog_msg (ctx, "%s", msg);
return (0);
}

Expand All @@ -1657,7 +1670,7 @@ static int wreck_log_error (lua_State *L, int fatal)
return (2); /* error on stack from l_format_args */
if (!(s = lua_tostring (L, 2)))
return lua_pusherror (L, "required arg to die missing");
wlog_error_kvs (ctx, fatal, s);
wlog_error_kvs (ctx, fatal, "%s", s);
return (0);
}

Expand Down Expand Up @@ -2095,7 +2108,7 @@ void ev_cb (flux_t *f, flux_msg_handler_t *mw,
int sig = 9;
if (json_object_object_get_ex (o, "signal", &ox))
sig = json_object_get_int (ox);
wlog_msg (ctx, "Killing jobid %lu with signal %d", ctx->id, sig);
wlog_msg (ctx, "Killing jobid %" PRIi64 " with signal %d", ctx->id, sig);
prog_ctx_signal (ctx, sig);
}
json_object_put (o);
Expand Down Expand Up @@ -2303,7 +2316,7 @@ int prog_ctx_get_id (struct prog_ctx *ctx, optparse_t *p)
char *end;

if (!optparse_getopt (p, "kvs-path", &kvspath))
wlog_fatal (ctx, 1, "Required arg --kvs-path missing\n");
wlog_fatal (ctx, 1, "Required arg --kvs-path missing");
ctx->kvspath = strdup (kvspath);

if (!optparse_getopt (p, "lwj-id", &id)) {
Expand Down
4 changes: 2 additions & 2 deletions t/t0007-ping.t
Expand Up @@ -13,7 +13,7 @@ invalid_rank() {
}

test_expect_success 'ping: 10K 1K byte echo requests' '
run_timeout 5 flux ping --pad 1024 --count 10240 --interval 0 0
run_timeout 10 flux ping --pad 1024 --count 10240 --interval 0 0
'

test_expect_success 'ping: 1K 10K byte echo requests' '
Expand All @@ -33,7 +33,7 @@ test_expect_success 'ping: 10 1M byte echo requests (batched)' '
'

test_expect_success 'ping: 1K 10K byte echo requests (batched)' '
run_timeout 5 flux ping --pad 10240 --count 1024 --batch --interval 0 0
run_timeout 20 flux ping --pad 10240 --count 1024 --batch --interval 0 0
'

test_expect_success 'ping --rank 1 works' '
Expand Down