Skip to content

Commit

Permalink
Upgrade cloudlibc, argdata, etc. to the latest upstream version.
Browse files Browse the repository at this point in the history
This release makes some changes to argdata's iterator API. Accessing an
iterator and progressing it are now to separate operations, which now
makes it easier to copy them.

Also patch up existing consumers of the API.
  • Loading branch information
EdSchouten committed Jun 21, 2017
1 parent b4440dd commit 758bcea
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 71 deletions.
6 changes: 3 additions & 3 deletions packages/argdata/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def build(ctx):

package(
name='argdata',
version='0.3',
version='0.4',
homepage='https://github.com/NuxiNL/argdata',
lib_depends={'cloudlibc', 'libcxx', 'mstd'},
build_cmd=build,
)

distfile(
name='argdata/v0.3.tar.gz',
checksum='12e3cc43074e2d7b22a4ae81e7262c932a4b8144b5b03f59578c00aa8aea16f4',
name='argdata/v0.4.tar.gz',
checksum='8f7afec1c3d832cd559865a8125d47edf70b4368d2e97f79bc36473090378fae',
master_sites={'https://github.com/NuxiNL/argdata/archive/'},
)
6 changes: 3 additions & 3 deletions packages/cloudabi-utils/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def build(ctx):

package(
name='cloudabi-utils',
version='0.24',
version='0.25',
homepage='https://github.com/NuxiNL/cloudabi-utils',
lib_depends={'c-runtime'},
build_cmd=build,
replaces={'cloudabi-reexec'},
)

distfile(
name='cloudabi-utils/v0.24.tar.gz',
checksum='c98bc812969de1a4b56bd4155fe93669bb0273d729b5ab97779ee6c0b06fd742',
name='cloudabi-utils/v0.25.tar.gz',
checksum='213f545ae4d899fa2387137ad45074f8ca15b08e5d5996d54ad61c1ab9474878',
master_sites={'https://github.com/NuxiNL/cloudabi-utils/archive/'},
)
6 changes: 3 additions & 3 deletions packages/cloudlibc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ def build(ctx):

package(
name='cloudlibc',
version='0.76',
version='0.77',
homepage='https://github.com/NuxiNL/cloudlibc',
lib_depends={'cloudabi', 'compiler-rt'},
build_cmd=build,
)

distfile(
name='cloudlibc/v0.76.tar.gz',
checksum='f808148aeb4062de9a2f7482188313cbeaee119124d22a3e66981f4658ab50cb',
name='cloudlibc/v0.77.tar.gz',
checksum='4d11efa8b1f32a9e29ba7ba4aa89041d9870b291750475d82fbfda784e37d8e5',
master_sites={'https://github.com/NuxiNL/cloudlibc/archive/'},
)
2 changes: 1 addition & 1 deletion packages/compiler-rt/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def build(ctx):
root = ctx.extract('%(name)s-%(version)s.src')
headers = ctx.extract('cloudlibc/v0.76').path('src/include')
headers = ctx.extract('cloudlibc/v0.77').path('src/include')

sources = {
'absvdi2.c', 'absvsi2.c', 'absvti2.c', 'adddf3.c', 'addsf3.c',
Expand Down
7 changes: 4 additions & 3 deletions packages/memcached/patch-cloudabi-run
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
static bool _parse_slab_sizes(char *s, uint32_t *slab_sizes) {
char *b = NULL;
uint32_t size = 0;
@@ -5770,6 +5779,161 @@
@@ -5770,6 +5779,162 @@
slab_sizes[i] = 0;
return true;
}
Expand Down Expand Up @@ -117,7 +117,7 @@
+ argdata_map_iterator_t it;
+ argdata_map_iterate(ad, &it);
+ const argdata_t *key, *value;
+ while (argdata_map_next(&it, &key, &value)) {
+ while (argdata_map_get(&it, &key, &value)) {
+ const char *keystr;
+ if (argdata_get_str_c(key, &keystr) == 0) {
+ if (strcmp(keystr, "socket") == 0) {
Expand All @@ -135,6 +135,7 @@
+ }
+ }
+ }
+ argdata_map_next(&it);
+ }
+
+ if (settings.lru_maintainer_thread && settings.hot_lru_pct + settings.warm_lru_pct > 80) {
Expand Down Expand Up @@ -244,7 +245,7 @@

int main (int argc, char **argv) {
int c;
@@ -6641,3 +6805,5 @@
@@ -6641,3 +6806,5 @@

return retval;
}
Expand Down
104 changes: 52 additions & 52 deletions packages/python/Modules/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,64 @@ Py_ProgramMain(const argdata_t *ad)
PySys_ResetWarnOptions();

argdata_map_iterate(ad, &it);
while (argdata_map_next(&it, &key, &val)) {
while (argdata_map_get(&it, &key, &val)) {
const char *keystr;
if (argdata_get_str_c(key, &keystr) != 0)
continue;

if (strcmp(keystr, "bytescompare") == 0) {
Py_BytesWarningFlag++;
} else if (strcmp(keystr, "command") == 0) {
if (argdata_get_str_c(val, &command) != 0) {
fprintf(stderr, "Fatal Python error: "
"unable to decode the 'command' argument\n");
exit(1);
if (argdata_get_str_c(key, &keystr) == 0) {
if (strcmp(keystr, "bytescompare") == 0) {
Py_BytesWarningFlag++;
} else if (strcmp(keystr, "command") == 0) {
if (argdata_get_str_c(val, &command) != 0) {
fprintf(stderr, "Fatal Python error: "
"unable to decode the 'command' argument\n");
exit(1);
}
} else if (strcmp(keystr, "debug") == 0) {
Py_DebugFlag++;
} else if (strcmp(keystr, "dontwritebytecode") == 0) {
Py_DontWriteBytecodeFlag++;
} else if (strcmp(keystr, "inspect") == 0) {
Py_InspectFlag++;
Py_InteractiveFlag++;
} else if (strcmp(keystr, "optimize") == 0) {
Py_OptimizeFlag++;
} else if (strcmp(keystr, "script") == 0) {
int fd;
if (argdata_get_fd(val, &fd) != 0 ||
(script = fdopen(fd, "r")) == NULL) {
fprintf(stderr, "Fatal Python error: "
"unable to decode the 'script' argument\n");
exit(1);
}
} else if (strcmp(keystr, "stderr") == 0) {
int fd;
if (argdata_get_fd(val, &fd) == 0) {
FILE *fp = fdopen(fd, "w");
if (fp != NULL)
fswap(stderr, fp);
}
} else if (strcmp(keystr, "unbufferedstdio") == 0) {
Py_UnbufferedStdioFlag = 1;
} else if (strcmp(keystr, "verbose") == 0) {
Py_VerboseFlag++;
}
} else if (strcmp(keystr, "debug") == 0) {
Py_DebugFlag++;
} else if (strcmp(keystr, "dontwritebytecode") == 0) {
Py_DontWriteBytecodeFlag++;
} else if (strcmp(keystr, "inspect") == 0) {
Py_InspectFlag++;
Py_InteractiveFlag++;
} else if (strcmp(keystr, "optimize") == 0) {
Py_OptimizeFlag++;
} else if (strcmp(keystr, "script") == 0) {
int fd;
if (argdata_get_fd(val, &fd) != 0 ||
(script = fdopen(fd, "r")) == NULL) {
fprintf(stderr, "Fatal Python error: "
"unable to decode the 'script' argument\n");
exit(1);
}
} else if (strcmp(keystr, "stderr") == 0) {
int fd;
if (argdata_get_fd(val, &fd) == 0) {
FILE *fp = fdopen(fd, "w");
if (fp != NULL)
fswap(stderr, fp);
}
} else if (strcmp(keystr, "unbufferedstdio") == 0) {
Py_UnbufferedStdioFlag = 1;
} else if (strcmp(keystr, "verbose") == 0) {
Py_VerboseFlag++;
}
argdata_map_next(&it);
}

/*
* Extract the "path" key, so that PyInitialize() can
* install it as sys.path.
*/
argdata_map_iterate(ad, &itpath);
while (argdata_map_next(&itpath, &key, &val)) {
while (argdata_map_get(&itpath, &key, &val)) {
const char *keystr;
if (argdata_get_str_c(key, &keystr) != 0)
continue;

if (strcmp(keystr, "path") == 0) {
path_argdata = val;
break;
if (argdata_get_str_c(key, &keystr) == 0) {
if (strcmp(keystr, "path") == 0) {
path_argdata = val;
break;
}
}
argdata_map_next(&itpath);
}

Py_NoUserSiteDirectory = 1;
Expand All @@ -95,14 +95,14 @@ Py_ProgramMain(const argdata_t *ad)

/* Extract the "args" key and expose it as sys.argdata. */
argdata_map_iterate(ad, &it);
while (argdata_map_next(&it, &key, &val)) {
while (argdata_map_get(&it, &key, &val)) {
const char *keystr;
if (argdata_get_str_c(key, &keystr) != 0)
continue;

if (strcmp(keystr, "args") == 0) {
PySys_SetArgdata("argdata", val);
if (argdata_get_str_c(key, &keystr) == 0) {
if (strcmp(keystr, "args") == 0) {
PySys_SetArgdata("argdata", val);
}
}
argdata_map_next(&itpath);
}

if (Py_VerboseFlag) {
Expand Down
17 changes: 11 additions & 6 deletions packages/python/patch-tool-python
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
static PyObject *
makepathobject(const wchar_t *path, wchar_t delim)
{
@@ -2277,6 +2281,236 @@
@@ -2277,6 +2281,241 @@
PySys_SetArgvEx(argc, argv, Py_IsolatedFlag == 0);
}

Expand Down Expand Up @@ -239,12 +239,13 @@
+ /* Dictionaries. */
+ {
+ argdata_map_iterator_t it;
+ if (argdata_map_iterate(ad, &it) == 0) {
+ argdata_map_iterate(ad, &it);
+ if (it.index != ARGDATA_ITERATOR_INVALID) {
+ PyObject *v = PyDict_New();
+ if (v == NULL)
+ return NULL;
+ const argdata_t *key, *value;
+ while (argdata_map_next(&it, &key, &value)) {
+ while (argdata_map_get(&it, &key, &value)) {
+ PyObject *keyv = convertargdata(key, true);
+ if (keyv == NULL) {
+ Py_DECREF(v);
Expand All @@ -262,6 +263,7 @@
+ Py_DECREF(v);
+ return NULL;
+ }
+ argdata_map_next(&it);
+ }
+ return v;
+ }
Expand All @@ -270,14 +272,15 @@
+ /* Lists or tuples, depending on whether mutability is permitted. */
+ {
+ argdata_seq_iterator_t it;
+ if (argdata_seq_iterate(ad, &it) == 0) {
+ argdata_seq_iterate(ad, &it);
+ if (it.index != ARGDATA_ITERATOR_INVALID) {
+ if (immutable) {
+ PyObject *v = PyTuple_New(0);
+ if (v == NULL)
+ return NULL;
+ const argdata_t *value;
+ size_t i = 0;
+ while (argdata_seq_next(&it, &value)) {
+ while (argdata_seq_get(&it, &value)) {
+ PyObject *valuev = convertargdata(value, true);
+ if (valuev == NULL) {
+ Py_DECREF(v);
Expand All @@ -290,14 +293,15 @@
+ return NULL;
+ }
+ ++i;
+ argdata_seq_next(&it);
+ }
+ return v;
+ } else {
+ PyObject *v = PyList_New(0);
+ if (v == NULL)
+ return NULL;
+ const argdata_t *value;
+ while (argdata_seq_next(&it, &value)) {
+ while (argdata_seq_get(&it, &value)) {
+ PyObject *valuev = convertargdata(value, false);
+ if (valuev == NULL) {
+ Py_DECREF(v);
Expand All @@ -308,6 +312,7 @@
+ Py_DECREF(v);
+ return NULL;
+ }
+ argdata_seq_next(&it);
+ }
+ return v;
+ }
Expand Down

0 comments on commit 758bcea

Please sign in to comment.