dtrace: Address KMSAN warnings in dtrace_disx86
[freebsd/src.git] / crypto / openssl / apps / vms_decc_init.c
blob21481e27bf936a0f820482403f4c81d810b2382c
1 /*
2 * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
10 #if defined( __VMS) && !defined( OPENSSL_NO_DECC_INIT) && \
11 defined( __DECC) && !defined( __VAX) && (__CRTL_VER >= 70301000)
12 # define USE_DECC_INIT 1
13 #endif
15 #ifdef USE_DECC_INIT
18 * ----------------------------------------------------------------------
19 * decc_init() On non-VAX systems, uses LIB$INITIALIZE to set a collection
20 * of C RTL features without using the DECC$* logical name method.
21 * ----------------------------------------------------------------------
24 # include <stdio.h>
25 # include <stdlib.h>
26 # include <unixlib.h>
28 /* Global storage. */
30 /* Flag to sense if decc_init() was called. */
32 int decc_init_done = -1;
34 /* Structure to hold a DECC$* feature name and its desired value. */
36 typedef struct {
37 char *name;
38 int value;
39 } decc_feat_t;
42 * Array of DECC$* feature names and their desired values. Note:
43 * DECC$ARGV_PARSE_STYLE is the urgent one.
46 decc_feat_t decc_feat_array[] = {
47 /* Preserve command-line case with SET PROCESS/PARSE_STYLE=EXTENDED */
48 {"DECC$ARGV_PARSE_STYLE", 1},
50 /* Preserve case for file names on ODS5 disks. */
51 {"DECC$EFS_CASE_PRESERVE", 1},
54 * Enable multiple dots (and most characters) in ODS5 file names, while
55 * preserving VMS-ness of ";version".
57 {"DECC$EFS_CHARSET", 1},
59 /* List terminator. */
60 {(char *)NULL, 0}
64 /* LIB$INITIALIZE initialization function. */
66 static void decc_init(void)
68 char *openssl_debug_decc_init;
69 int verbose = 0;
70 int feat_index;
71 int feat_value;
72 int feat_value_max;
73 int feat_value_min;
74 int i;
75 int sts;
77 /* Get debug option. */
78 openssl_debug_decc_init = getenv("OPENSSL_DEBUG_DECC_INIT");
79 if (openssl_debug_decc_init != NULL) {
80 verbose = strtol(openssl_debug_decc_init, NULL, 10);
81 if (verbose <= 0) {
82 verbose = 1;
86 /* Set the global flag to indicate that LIB$INITIALIZE worked. */
87 decc_init_done = 1;
89 /* Loop through all items in the decc_feat_array[]. */
91 for (i = 0; decc_feat_array[i].name != NULL; i++) {
92 /* Get the feature index. */
93 feat_index = decc$feature_get_index(decc_feat_array[i].name);
94 if (feat_index >= 0) {
95 /* Valid item. Collect its properties. */
96 feat_value = decc$feature_get_value(feat_index, 1);
97 feat_value_min = decc$feature_get_value(feat_index, 2);
98 feat_value_max = decc$feature_get_value(feat_index, 3);
100 /* Check the validity of our desired value. */
101 if ((decc_feat_array[i].value >= feat_value_min) &&
102 (decc_feat_array[i].value <= feat_value_max)) {
103 /* Valid value. Set it if necessary. */
104 if (feat_value != decc_feat_array[i].value) {
105 sts = decc$feature_set_value(feat_index,
106 1, decc_feat_array[i].value);
108 if (verbose > 1) {
109 fprintf(stderr, " %s = %d, sts = %d.\n",
110 decc_feat_array[i].name,
111 decc_feat_array[i].value, sts);
114 } else {
115 /* Invalid DECC feature value. */
116 fprintf(stderr,
117 " INVALID DECC$FEATURE VALUE, %d: %d <= %s <= %d.\n",
118 feat_value,
119 feat_value_min, decc_feat_array[i].name,
120 feat_value_max);
122 } else {
123 /* Invalid DECC feature name. */
124 fprintf(stderr,
125 " UNKNOWN DECC$FEATURE: %s.\n", decc_feat_array[i].name);
129 if (verbose > 0) {
130 fprintf(stderr, " DECC_INIT complete.\n");
134 /* Get "decc_init()" into a valid, loaded LIB$INITIALIZE PSECT. */
136 # pragma nostandard
139 * Establish the LIB$INITIALIZE PSECTs, with proper alignment and other
140 * attributes. Note that "nopic" is significant only on VAX.
142 # pragma extern_model save
144 # if __INITIAL_POINTER_SIZE == 64
145 # define PSECT_ALIGN 3
146 # else
147 # define PSECT_ALIGN 2
148 # endif
150 # pragma extern_model strict_refdef "LIB$INITIALIZ" PSECT_ALIGN, nopic, nowrt
151 const int spare[8] = { 0 };
153 # pragma extern_model strict_refdef "LIB$INITIALIZE" PSECT_ALIGN, nopic, nowrt
154 void (*const x_decc_init) () = decc_init;
156 # pragma extern_model restore
158 /* Fake reference to ensure loading the LIB$INITIALIZE PSECT. */
160 # pragma extern_model save
162 int LIB$INITIALIZE(void);
164 # pragma extern_model strict_refdef
165 int dmy_lib$initialize = (int)LIB$INITIALIZE;
167 # pragma extern_model restore
169 # pragma standard
171 #else /* def USE_DECC_INIT */
173 /* Dummy code to avoid a %CC-W-EMPTYFILE complaint. */
174 int decc_init_dummy(void);
176 #endif /* def USE_DECC_INIT */