]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Remove some safestack things that are no longer needed
authorMatt Caswell <matt@openssl.org>
Thu, 3 Sep 2020 16:09:18 +0000 (17:09 +0100)
committerMatt Caswell <matt@openssl.org>
Sun, 13 Sep 2020 10:11:32 +0000 (11:11 +0100)
... and add SKM_DEFINE_STACK_OF_INTERNAL

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12781)

include/openssl/safestack.h.in
util/perl/OpenSSL/ParseC.pm

index 943aa5861ec4dad1c3447ebdef82a8d8c260a0c2..a8e9d7abdaa6337cdcda926c03c4bbd1eadf34bb 100644 (file)
@@ -163,28 +163,6 @@ extern "C" {
 typedef char *OPENSSL_STRING;
 typedef const char *OPENSSL_CSTRING;
 
-# define DEFINE_STACK_OF_STRING() \
-        DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)
-# define DEFINE_STACK_OF_CSTRING() \
-        DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)
-
-/*
- * If we're building OpenSSL, or we have no-deprecated configured,
- * then we don't define the inline functions (see |SKM_DEFINE_STACK_OF|,
- * above), we just declare the stack datatypes. Otherwise, for compatibility
- * and to not remove the API's, we define the functions.  We have the
- * trailing semicolon so that uses of this never need it.
- */
-#if defined(OPENSSL_BUILDING_OPENSSL) || defined(OPENSSL_NO_DEPRECATED_3_0)
-# define DEFINE_OR_DECLARE_STACK_OF(s) STACK_OF(s);
-# define DEFINE_OR_DECLARE_STACK_OF_STRING() STACK_OF(OPENSSL_STRING);
-# define DEFINE_OR_DECLARE_STACK_OF_CSTRING() STACK_OF(OPENSSL_CSTRING);
-#else
-# define DEFINE_OR_DECLARE_STACK_OF(s) DEFINE_STACK_OF(s)
-# define DEFINE_OR_DECLARE_STACK_OF_STRING() DEFINE_STACK_OF_STRING()
-# define DEFINE_OR_DECLARE_STACK_OF_CSTRING() DEFINE_STACK_OF_CSTRING()
-#endif
-
 /*-
  * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but
  * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned
@@ -208,41 +186,6 @@ typedef void *OPENSSL_BLOCK;
 -}
 #endif
 
-/*
- * If called without higher optimization (min. -xO3) the Oracle Developer
- * Studio compiler generates code for the defined (static inline) functions
- * above.
- * This would later lead to the linker complaining about missing symbols when
- * this header file is included but the resulting object is not linked against
- * the Crypto library (openssl#6912).
- */
-# ifdef __SUNPRO_C
-#  pragma weak OPENSSL_sk_num
-#  pragma weak OPENSSL_sk_value
-#  pragma weak OPENSSL_sk_new
-#  pragma weak OPENSSL_sk_new_null
-#  pragma weak OPENSSL_sk_new_reserve
-#  pragma weak OPENSSL_sk_reserve
-#  pragma weak OPENSSL_sk_free
-#  pragma weak OPENSSL_sk_zero
-#  pragma weak OPENSSL_sk_delete
-#  pragma weak OPENSSL_sk_delete_ptr
-#  pragma weak OPENSSL_sk_push
-#  pragma weak OPENSSL_sk_unshift
-#  pragma weak OPENSSL_sk_pop
-#  pragma weak OPENSSL_sk_shift
-#  pragma weak OPENSSL_sk_pop_free
-#  pragma weak OPENSSL_sk_insert
-#  pragma weak OPENSSL_sk_set
-#  pragma weak OPENSSL_sk_find
-#  pragma weak OPENSSL_sk_find_ex
-#  pragma weak OPENSSL_sk_sort
-#  pragma weak OPENSSL_sk_is_sorted
-#  pragma weak OPENSSL_sk_dup
-#  pragma weak OPENSSL_sk_deep_copy
-#  pragma weak OPENSSL_sk_set_cmp_func
-# endif /* __SUNPRO_C */
-
 # ifdef  __cplusplus
 }
 # endif
index dd1da99f589ff82ac2ca3626d51ece4cadb49616..c5be9b8c2acb2ff22d2e50f17957adefc598629f 100644 (file)
@@ -357,6 +357,21 @@ static ossl_inline STACK_OF($1) *sk_$1_deep_copy(const STACK_OF($1) *sk,
                                                  sk_$1_freefunc freefunc);
 static ossl_inline sk_$1_compfunc sk_$1_set_cmp_func(STACK_OF($1) *sk,
                                                      sk_$1_compfunc compare);
+EOF
+      }
+    },
+    { regexp   => qr/SKM_DEFINE_STACK_OF_INTERNAL<<<\((.*),\s*(.*),\s*(.*)\)>>>/,
+      massager => sub {
+          return (<<"EOF");
+STACK_OF($1);
+typedef int (*sk_$1_compfunc)(const $3 * const *a, const $3 *const *b);
+typedef void (*sk_$1_freefunc)($3 *a);
+typedef $3 * (*sk_$1_copyfunc)(const $3 *a);
+static ossl_unused ossl_inline $2 *ossl_check_$1_type($2 *ptr);
+static ossl_unused ossl_inline const OPENSSL_STACK *ossl_check_const_$1_sk_type(const STACK_OF($1) *sk);
+static ossl_unused ossl_inline OPENSSL_sk_compfunc ossl_check_$1_compfunc_type(sk_$1_compfunc cmp);
+static ossl_unused ossl_inline OPENSSL_sk_copyfunc ossl_check_$1_copyfunc_type(sk_$1_copyfunc cpy);
+static ossl_unused ossl_inline OPENSSL_sk_freefunc ossl_check_$1_freefunc_type(sk_$1_freefunc fr);
 EOF
       }
     },
@@ -372,28 +387,6 @@ EOF
     { regexp   => qr/DEFINE_STACK_OF_CONST<<<\((.*)\)>>>/,
       massager => sub { return ("SKM_DEFINE_STACK_OF($1,const $1,$1)"); },
     },
-    { regexp   => qr/DEFINE_STACK_OF_STRING<<<\((.*?)\)>>>/,
-      massager => sub {
-          return ("DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)");
-      }
-    },
-    { regexp   => qr/DEFINE_STACK_OF_CSTRING<<<\((.*?)\)>>>/,
-      massager => sub {
-          return ("DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)");
-      }
-    },
-    # DEFINE_OR_DECLARE macro calls must be interpretted as DEFINE macro
-    # calls, because that's what they look like to the external apps.
-    # (if that ever changes, we must change the substitutions to STACK_OF)
-    { regexp   => qr/DEFINE_OR_DECLARE_STACK_OF<<<\((.*?)\)>>>/,
-      massager => sub { return ("DEFINE_STACK_OF($1)"); }
-    },
-    { regexp   => qr/DEFINE_OR_DECLARE_STACK_OF_STRING<<<\(\)>>>/,
-      massager => sub { return ("DEFINE_STACK_OF_STRING()"); },
-    },
-    { regexp   => qr/DEFINE_OR_DECLARE_STACK_OF_CSTRING<<<\(\)>>>/,
-      massager => sub { return ("DEFINE_STACK_OF_CSTRING()"); },
-    },
 
     #####
     # ASN1 stuff