1 #pragma once
2 
3 #include <stdarg.h>
4 #include <stdint.h>
5 #include <stdio.h>
6 #include <string.h>
7 
8 #define UNTAG(x) (typeof((x) + 0))(((uintptr_t)(x)) & 0xffffffffffffff)
9 
10 __attribute__((no_sanitize("hwaddress")))
untag_printf(const char * fmt,...)11 int untag_printf(const char *fmt, ...) {
12   va_list ap;
13   va_start(ap, fmt);
14   int ret = vprintf(UNTAG(fmt), ap);
15   va_end(ap);
16   return ret;
17 }
18 
19 __attribute__((no_sanitize("hwaddress")))
untag_fprintf(FILE * stream,const char * fmt,...)20 int untag_fprintf(FILE *stream, const char *fmt, ...) {
21   va_list ap;
22   va_start(ap, fmt);
23   int ret = vfprintf(stream, UNTAG(fmt), ap);
24   va_end(ap);
25   return ret;
26 }
27 
untag_strcmp(const char * s1,const char * s2)28 int untag_strcmp(const char *s1, const char *s2) {
29   return strcmp(UNTAG(s1), UNTAG(s2));
30 }
31