aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/os/utils.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-07-04 10:41:31 +0200
committermarha <marha@users.sourceforge.net>2012-07-04 10:41:31 +0200
commitb3daaeb1467f3d3d52bef2f76413f3a063fc4f33 (patch)
tree4415e903a15dff8b36bba9fcce197d26a7790186 /xorg-server/os/utils.c
parente44d0067ca65d58f258e7f2ae1a240c9bfce5766 (diff)
parentfc8f37239f3af088819c18f5632b2608954af73a (diff)
downloadvcxsrv-b3daaeb1467f3d3d52bef2f76413f3a063fc4f33.tar.gz
vcxsrv-b3daaeb1467f3d3d52bef2f76413f3a063fc4f33.tar.bz2
vcxsrv-b3daaeb1467f3d3d52bef2f76413f3a063fc4f33.zip
Merge remote-tracking branch 'origin/released'
Conflicts: xorg-server/include/misc.h xorg-server/os/utils.c
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r--xorg-server/os/utils.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 47bc7b5c3..e94179518 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -204,6 +204,8 @@ int auditTrailLevel = 1;
char *SeatId = NULL;
+sig_atomic_t inSignalContext = FALSE;
+
#ifdef _MSC_VER
static HANDLE s_hSmartScheduleTimer = NULL;
static HANDLE s_hSmartScheduleTimerQueue = NULL;
@@ -1852,3 +1854,47 @@ xstrtokenize(const char *str, const char *separators)
free(list);
return NULL;
}
+
+/* Format a number into a string in a signal safe manner. The string should be
+ * at least 21 characters in order to handle all uint64_t values. */
+void
+FormatUInt64(uint64_t num, char *string)
+{
+ uint64_t divisor;
+ int len;
+ int i;
+
+ for (len = 1, divisor = 10;
+ len < 20 && num / divisor;
+ len++, divisor *= 10);
+
+ for (i = len, divisor = 1; i > 0; i--, divisor *= 10)
+ string[i - 1] = '0' + ((num / divisor) % 10);
+
+ string[len] = '\0';
+}
+
+/* Format a number into a hexadecimal string in a signal safe manner. The string
+ * should be at least 17 characters in order to handle all uint64_t values. */
+void
+FormatUInt64Hex(uint64_t num, char *string)
+{
+ uint64_t divisor;
+ int len;
+ int i;
+
+ for (len = 1, divisor = 0x10;
+ len < 16 && num / divisor;
+ len++, divisor *= 0x10);
+
+ for (i = len, divisor = 1; i > 0; i--, divisor *= 0x10) {
+ int val = (num / divisor) % 0x10;
+
+ if (val < 10)
+ string[i - 1] = '0' + val;
+ else
+ string[i - 1] = 'a' + val - 10;
+ }
+
+ string[len] = '\0';
+}