--- old/usr/src/tools/smatch/src/smatch.h	Tue Jan  7 08:01:53 2020
+++ new/usr/src/tools/smatch/src/smatch.h	Tue Jan  7 08:01:53 2020
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <limits.h>
+#include <float.h>
 #include <sys/time.h>
 #include <sqlite3.h>
 #include "lib.h"
@@ -37,6 +38,9 @@
 	union {
 		long long value;
 		unsigned long long uvalue;
+		float fvalue;
+		double dvalue;
+		long double ldvalue;
 	};
 } sval_t;
 
@@ -206,6 +210,7 @@
 extern struct symbol *cur_func_sym;
 extern int option_debug;
 extern int local_debug;
+extern int debug_db;
 bool debug_implied(void);
 extern int option_info;
 extern int option_spammy;
@@ -240,7 +245,10 @@
  * sm_msg(): other message (please avoid using this)
  */
 
-#define sm_printf(msg...) do { if (final_pass || option_debug || local_debug) fprintf(sm_outfd, msg); } while (0)
+#define sm_printf(msg...) do {						\
+	if (final_pass || option_debug || local_debug || debug_db)	\
+		fprintf(sm_outfd, msg);					\
+} while (0)
 
 static inline void sm_prefix(void)
 {
@@ -254,7 +262,7 @@
 #define sm_print_msg(type, msg...) \
 do {                                                           \
 	print_implied_debug_msg();                             \
-	if (!final_pass && !option_debug && !local_debug)      \
+	if (!final_pass && !option_debug && !local_debug && !debug_db)	  \
 		break;                                         \
 	if (__silence_warnings_for_stmt && !option_debug && !local_debug) \
 		break;					       \
@@ -277,12 +285,6 @@
 
 #define sm_msg(msg...) do { sm_print_msg(0, msg); } while (0)
 
-#define local_debug(msg...)					\
-do {								\
-	if (local_debug)					\
-		sm_msg(msg);					\
-} while (0)
-
 extern char *implied_debug_msg;
 static inline void print_implied_debug_msg(void)
 {
@@ -297,6 +299,7 @@
 }
 
 #define sm_debug(msg...) do { if (option_debug) sm_printf(msg); } while (0)
+#define db_debug(msg...) do { if (option_debug || debug_db) sm_printf(msg); } while (0)
 
 #define sm_info(msg...) do {					\
 	if (option_debug || (option_info && final_pass)) {	\
@@ -438,6 +441,7 @@
 struct expression *get_last_expr_from_expression_stmt(struct expression *expr);
 int get_param_num_from_sym(struct symbol *sym);
 int get_param_num(struct expression *expr);
+struct symbol *get_param_sym_from_num(int num);
 int ms_since(struct timeval *start);
 int parent_is_gone_var_sym(const char *name, struct symbol *sym);
 int parent_is_gone(struct expression *expr);
@@ -806,8 +810,6 @@
 	RETURN_VALUE	= 1005,
 	DEREFERENCE	= 1006,
 	RANGE_CAP	= 1007,
-	LOCK_HELD	= 1008,
-	LOCK_RELEASED	= 1009,
 	ABSOLUTE_LIMITS	= 1010,
 	PARAM_ADD	= 1012,
 	PARAM_FREED	= 1013,
@@ -845,6 +847,10 @@
 	NO_OVERFLOW_SIMPLE = 8019,
 	LOCKED		= 8020,
 	UNLOCKED	= 8021,
+	HALF_LOCKED	= 9022,
+	LOCK_RESTORED	= 9023,
+	KNOWN_LOCKED	= 9024,
+	KNOWN_UNLOCKED 	= 9025,
 	SET_FS		= 8022,
 	ATOMIC_INC	= 8023,
 	ATOMIC_DEC	= 8024,
@@ -887,6 +893,7 @@
 const char *get_mtag_name_var_sym(const char *state_name, struct symbol *sym);
 const char *get_mtag_name_expr(struct expression *expr);
 char *get_data_info_name(struct expression *expr);
+char *sm_to_arg_name(struct expression *expr, struct sm_state *sm);
 int is_recursive_member(const char *param_name);
 
 char *escape_newlines(const char *str);
@@ -897,7 +904,7 @@
 	char sql_txt[1024];							\
 										\
 	sqlite3_snprintf(sizeof(sql_txt), sql_txt, sql);			\
-	sm_debug("debug: %s\n", sql_txt);					\
+	db_debug("debug: %s\n", sql_txt);					\
 	sql_exec(db, call_back, data, sql_txt);					\
 } while (0)
 
@@ -931,7 +938,7 @@
 			      ignore ? "or ignore " : "", #table);		\
 		p += snprintf(p, buf + sizeof(buf) - p, values);		\
 		p += snprintf(p, buf + sizeof(buf) - p, ");");			\
-		sm_debug("mem-db: %s\n", buf);					\
+		db_debug("mem-db: %s\n", buf);					\
 		rc = sqlite3_exec(_db, buf, NULL, NULL, &err);			\
 		if (rc != SQLITE_OK) {						\
 			sm_ierror("SQL error #2: %s", err);			\
@@ -1007,7 +1014,6 @@
 extern char *data_dir;
 extern int option_no_data;
 extern int option_full_path;
-extern int option_param_mapper;
 extern int option_call_tree;
 extern int num_checks;
 
@@ -1062,6 +1068,7 @@
 char *map_call_to_param_name_sym(struct expression *expr, struct symbol **sym);
 
 /* smatch_comparison.c */
+extern int comparison_id;
 #define UNKNOWN_COMPARISON 0
 #define IMPOSSIBLE_COMPARISON -1
 struct compare_data {
@@ -1117,8 +1124,11 @@
 sval_t *sval_alloc_permanent(sval_t sval);
 sval_t sval_blank(struct expression *expr);
 sval_t sval_type_val(struct symbol *type, long long val);
+sval_t sval_type_fval(struct symbol *type, long double fval);
 sval_t sval_from_val(struct expression *expr, long long val);
+sval_t sval_from_fval(struct expression *expr, long double fval);
 int sval_is_ptr(sval_t sval);
+bool sval_is_fp(sval_t sval);
 int sval_unsigned(sval_t sval);
 int sval_signed(sval_t sval);
 int sval_bits(sval_t sval);
@@ -1171,6 +1181,10 @@
 struct sm_state *stored_condition_implication_hook(struct expression *expr,
 			struct state_list **true_stack,
 			struct state_list **false_stack);
+/* smatch_parsed_conditions.c */
+struct sm_state *parsed_condition_implication_hook(struct expression *expr,
+			struct state_list **true_stack,
+			struct state_list **false_stack);
 
 /* check_string_len.c */
 int get_formatted_string_size(struct expression *call, int arg);
@@ -1272,6 +1286,14 @@
 		type->type == SYM_FN);
 }
 
+static inline bool type_is_fp(struct symbol *type)
+{
+	return type &&
+	       (type == &float_ctype ||
+		type == &double_ctype ||
+		type == &ldouble_ctype);
+}
+
 static inline int type_bits(struct symbol *type)
 {
 	if (!type)
@@ -1313,10 +1335,53 @@
 /*
  * Returns -1 if one is smaller, 0 if they are the same and 1 if two is larger.
  */
+
+static inline int fp_cmp(sval_t one, sval_t two)
+{
+	struct symbol *type;
+
+	if (sval_is_fp(one) && sval_is_fp(two))
+		type = type_bits(one.type) > type_bits(two.type) ? one.type : two.type;
+	else if (sval_is_fp(one))
+		type = one.type;
+	else
+		type = two.type;
+
+	one = sval_cast(type, one);
+	two = sval_cast(type, two);
+
+	if (one.type == &float_ctype) {
+		if (one.fvalue < two.fvalue)
+			return -1;
+		if (one.fvalue == two.fvalue)
+			return 0;
+		return 1;
+	}
+	if (one.type == &double_ctype) {
+		if (one.dvalue < two.dvalue)
+			return -1;
+		if (one.dvalue == two.dvalue)
+			return 0;
+		return 1;
+	}
+	if (one.type == &ldouble_ctype) {
+		if (one.ldvalue < two.ldvalue)
+			return -1;
+		if (one.ldvalue == two.ldvalue)
+			return 0;
+		return 1;
+	}
+	sm_perror("bad type in fp_cmp(): %s", type_to_str(type));
+	return 1;
+}
+
 static inline int sval_cmp(sval_t one, sval_t two)
 {
 	struct symbol *type;
 
+	if (sval_is_fp(one) || sval_is_fp(two))
+		return fp_cmp(one, two);
+
 	type = one.type;
 	if (sval_positive_bits(two) > sval_positive_bits(one))
 		type = two.type;
