summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2025-06-23 16:31:27 -0700
committerMarge Bot <marge-bot@fdo.invalid>2025-06-24 23:40:51 +0000
commit4916da381b68dfc0c7dd7e4a4d9143751aef5abe (patch)
tree0fbe4b2cf9233a01ee2ebc2b77239b68ec69f434
parent6a9b2f37bb6f9ee760f12edd066c12441a2fb1f7 (diff)
Revert "os: log: make LogVMessageVerb() signal safe"
This reverts commit 5962211612decdbe173a1389cc00c26d1a8a8724. Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2036>
-rw-r--r--include/os.h6
-rw-r--r--os/log.c32
2 files changed, 29 insertions, 9 deletions
diff --git a/include/os.h b/include/os.h
index 2f43e4eda..3949ff5aa 100644
--- a/include/os.h
+++ b/include/os.h
@@ -327,6 +327,9 @@ _X_ATTRIBUTE_PRINTF(2, 3);
extern _X_EXPORT void
LogMessageVerbSigSafe(MessageType type, int verb, const char *format, ...)
_X_ATTRIBUTE_PRINTF(3, 4);
+extern _X_EXPORT void
+LogVMessageVerbSigSafe(MessageType type, int verb, const char *format, va_list args)
+_X_ATTRIBUTE_PRINTF(3, 0);
extern _X_EXPORT void
LogVHdrMessageVerb(MessageType type, int verb,
@@ -376,9 +379,6 @@ xorg_backtrace(void);
typedef _sigset_t sigset_t;
#endif
-/* should not be used anymore, just for backwards compat with drivers */
-#define LogVMessageVerbSigSafe(...) LogVMessageVerb(__VA_ARGS__)
-
/* only for backwards compat with drivers that haven't kept up yet
(xf86-video-intel)
diff --git a/os/log.c b/os/log.c
index c901234fe..bcd07a0b9 100644
--- a/os/log.c
+++ b/os/log.c
@@ -680,17 +680,21 @@ static inline void writeLog(int verb, char *buf, int len)
LogSWrite(verb, buf, len, (buf[len - 1] == '\n'));
}
-/* signal safe */
void
LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
{
char buf[LOG_MSG_BUF_SIZE];
+ if (inSignalContext) {
+ LogVMessageVerbSigSafe(type, verb, format, args);
+ return;
+ }
+
size_t len = prepMsgHdr(type, verb, buf);
if (len == -1)
return;
- len += vpnprintf(&buf[len], sizeof(buf) - len, format, args);
+ len += Xvscnprintf(&buf[len], sizeof(buf) - len, format, args);
writeLog(verb, buf, len);
}
@@ -723,25 +727,41 @@ LogMessageVerbSigSafe(MessageType type, int verb, const char *format, ...)
{
va_list ap;
va_start(ap, format);
- LogVMessageVerb(type, verb, format, ap);
+ LogVMessageVerbSigSafe(type, verb, format, ap);
va_end(ap);
}
void
+LogVMessageVerbSigSafe(MessageType type, int verb, const char *format, va_list args)
+{
+ char buf[LOG_MSG_BUF_SIZE];
+
+ int len = prepMsgHdr(type, verb, buf);
+ if (len == -1)
+ return;
+
+ len += vpnprintf(&buf[len], sizeof(buf) - len, format, args);
+
+ writeLog(verb, buf, len);
+}
+
+void
LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
va_list msg_args, const char *hdr_format, va_list hdr_args)
{
char buf[LOG_MSG_BUF_SIZE];
+ int (*vprintf_func)(char *, int, const char* _X_RESTRICT_KYWD f, va_list args)
+ _X_ATTRIBUTE_PRINTF(3, 0) = (inSignalContext ? vpnprintf : Xvscnprintf);
size_t len = prepMsgHdr(type, verb, buf);
if (len == -1)
return;
if (hdr_format && sizeof(buf) - len > 1)
- len += vpnprintf(&buf[len], sizeof(buf) - len, hdr_format, hdr_args);
+ len += vprintf_func(&buf[len], sizeof(buf) - len, hdr_format, hdr_args);
if (msg_format && sizeof(buf) - len > 1)
- len += vpnprintf(&buf[len], sizeof(buf) - len, msg_format, msg_args);
+ len += vprintf_func(&buf[len], sizeof(buf) - len, msg_format, msg_args);
writeLog(verb, buf, len);
}
@@ -921,7 +941,7 @@ ErrorF(const char *f, ...)
void
VErrorFSigSafe(const char *f, va_list args)
{
- LogVMessageVerb(X_ERROR, -1, f, args);
+ LogVMessageVerbSigSafe(X_ERROR, -1, f, args);
}
void