WASI's values for SEEK_CUR, SEEK_SET, and SEEK_END differ from musl's
values, so fix musl code that bakes in knowledge of these values.
This fixes src/functional/memstream.c.
errno = EINVAL;
return -1;
}
+#ifdef __wasilibc_unmodified_upstream // WASI's SEEK_* constants have different values.
base = (size_t [3]){0, c->pos, c->len}[whence];
+#else
+ base = (size_t [3]) {
+ [SEEK_SET] = 0,
+ [SEEK_CUR] = c->pos,
+ [SEEK_END] = c->len
+ }[whence];
+#endif
if (off < -base || off > (ssize_t)c->size-base) goto fail;
return c->pos = base+off;
}
errno = EINVAL;
return -1;
}
+#ifdef __wasilibc_unmodified_upstream // WASI's SEEK_* constants have different values.
base = (size_t [3]){0, c->pos, c->len}[whence];
+#else
+ base = (size_t [3]) {
+ [SEEK_SET] = 0,
+ [SEEK_CUR] = c->pos,
+ [SEEK_END] = c->len
+ }[whence];
+#endif
if (off < -base || off > SSIZE_MAX-base) goto fail;
return c->pos = base+off;
}
errno = EINVAL;
return -1;
}
+#ifdef __wasilibc_unmodified_upstream // WASI's SEEK_* constants have different values.
base = (size_t [3]){0, c->pos, c->len}[whence];
+#else
+ base = (size_t [3]) {
+ [SEEK_SET] = 0,
+ [SEEK_CUR] = c->pos,
+ [SEEK_END] = c->len
+ }[whence];
+#endif
if (off < -base || off > SSIZE_MAX/4-base) goto fail;
memset(&c->mbs, 0, sizeof c->mbs);
return c->pos = base+off;