asn1: Work around missing ENOTSUP (WIN32)

Sufficiently old CRTs on Windows lack ENOTSUP.  Use EINVAL instead then.
This commit is contained in:
Nicolas Williams
2021-11-23 18:11:48 -06:00
parent 92e5a4b7e5
commit 232c936ea3
3 changed files with 11 additions and 1 deletions

View File

@@ -273,6 +273,11 @@ init_generate (const char *filename, const char *base)
"#define ASN1CALL\n"
"#endif\n",
headerfile);
fputs("#ifndef ENOTSUP\n"
"/* Very old MSVC CRTs lack ENOTSUP */\n"
"#define ENOTSUP EINVAL\n"
"#endif\n",
headerfile);
fprintf (headerfile, "struct units;\n\n");
fprintf (headerfile, "#endif\n\n");
if (asprintf(&fn, "%s_files", base) < 0 || fn == NULL)

View File

@@ -38,6 +38,6 @@ generate_type_print_stub(const Symbol *s)
{
fprintf(codefile, "char * ASN1CALL\n"
"print_%s(const %s *data, int flags)\n"
"{ errno = ENOTSUP; return 0; }\n\n",
"{ errno = EINVAL; return 0; }\n\n",
s->gen_name, s->gen_name);
}

View File

@@ -38,6 +38,11 @@
#include <vis.h>
#include <vis-extras.h>
#ifndef ENOTSUP
/* Very old MSVC CRTs don't have ENOTSUP */
#define ENOTSUP EINVAL
#endif
struct asn1_type_func asn1_template_prim[A1T_NUM_ENTRY] = {
#define el(name, type) { \
(asn1_type_encode)der_put_##name, \