diff options
author | marha <marha@users.sourceforge.net> | 2012-07-04 10:36:18 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-07-04 10:36:18 +0200 |
commit | fc8f37239f3af088819c18f5632b2608954af73a (patch) | |
tree | 012ded3d00546b7f2fa807f466643eadf6f815ba /xorg-server/os/utils.c | |
parent | fdef5bff99e6079f64bc6b91c91b42195c85adeb (diff) | |
download | vcxsrv-fc8f37239f3af088819c18f5632b2608954af73a.tar.gz vcxsrv-fc8f37239f3af088819c18f5632b2608954af73a.tar.bz2 vcxsrv-fc8f37239f3af088819c18f5632b2608954af73a.zip |
mesa xserver git update 4 Jul 2012
Diffstat (limited to 'xorg-server/os/utils.c')
-rw-r--r-- | xorg-server/os/utils.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c index 3a1ef9303..998c3ed4a 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; + #if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED) #define HAS_SAVED_IDS_AND_SETEUID #endif @@ -1791,3 +1793,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'; +} |