#include <stddef.h>
#include <sys/types.h>
#include "my_compiler.h"
#include "my_config.h"
#include "my_inttypes.h"
#include "my_macros.h"
 
Go to the source code of this file.
 | 
| void  | my_init_stacktrace () | 
|   | 
| void  | my_print_stacktrace (const uchar *stack_bottom, ulong thread_stack) | 
|   | 
| void  | my_safe_puts_stderr (const char *val, size_t max_len) | 
|   | 
| void  | my_write_core (int sig) | 
|   | 
| char *  | my_safe_itoa (int base, longlong val, char *buf) | 
|   | Async-signal-safe utility functions used by signal handler routines.  More...
  | 
|   | 
| char *  | my_safe_utoa (int base, ulonglong val, char *buf) | 
|   | Converts a ulonglong value to string.  More...
  | 
|   | 
| size_t  | my_safe_snprintf (char *to, size_t n, const char *fmt,...) | 
|   | A (very) limited version of snprintf.  More...
  | 
|   | 
| size_t  | my_safe_printf_stderr (const char *fmt,...) | 
|   | A (very) limited version of snprintf, which writes the result to STDERR.  More...
  | 
|   | 
| size_t  | my_write_stderr (const void *buf, size_t count) | 
|   | Writes up to count bytes from buffer to STDERR.  More...
  | 
|   | 
| void  | my_safe_print_system_time () | 
|   | Writes system time to STDERR without allocating new memory.  More...
  | 
|   | 
◆ HAVE_STACKTRACE
      
        
          | #define HAVE_STACKTRACE   1 | 
        
      
 
 
◆ my_init_stacktrace()
      
        
          | void my_init_stacktrace  | 
          ( | 
           | ) | 
           | 
        
      
 
 
◆ my_print_stacktrace()
      
        
          | void my_print_stacktrace  | 
          ( | 
          const uchar *  | 
          stack_bottom,  | 
        
        
           | 
           | 
          ulong  | 
          thread_stack  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ my_safe_itoa()
      
        
          | char * my_safe_itoa  | 
          ( | 
          int  | 
          base,  | 
        
        
           | 
           | 
          longlong  | 
          val,  | 
        
        
           | 
           | 
          char *  | 
          buf  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Async-signal-safe utility functions used by signal handler routines. 
Declared here in order to unit-test them. These are not general-purpose, but tailored to the signal handling routines. Converts a longlong value to string. 
- Parameters
 - 
  
    | base | 10 for decimal, 16 for hex values (0..9a..f)  | 
    | val | The value to convert  | 
    | buf | Assumed to point to the end of the buffer.  | 
  
   
- Returns
 - Pointer to the first character of the converted string. Negative values: for base-10 the return string will be prepended with '-' for base-16 the return string will contain 16 characters Implemented with simplicity, and async-signal-safety in mind. 
 
 
 
◆ my_safe_print_system_time()
      
        
          | void my_safe_print_system_time  | 
          ( | 
           | ) | 
           | 
        
      
 
Writes system time to STDERR without allocating new memory. 
 
 
◆ my_safe_printf_stderr()
      
        
          | size_t my_safe_printf_stderr  | 
          ( | 
          const char *  | 
          fmt,  | 
        
        
           | 
           | 
            | 
          ...  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
A (very) limited version of snprintf, which writes the result to STDERR. 
- See also
 - my_safe_snprintf Implemented with simplicity, and async-signal-safety in mind. 
 
- Note
 - Has an internal buffer capacity of 512 bytes, which should suffice for our signal handling routines. 
 
 
 
◆ my_safe_puts_stderr()
      
        
          | void my_safe_puts_stderr  | 
          ( | 
          const char *  | 
          val,  | 
        
        
           | 
           | 
          size_t  | 
          max_len  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ my_safe_snprintf()
      
        
          | size_t my_safe_snprintf  | 
          ( | 
          char *  | 
          to,  | 
        
        
           | 
           | 
          size_t  | 
          n,  | 
        
        
           | 
           | 
          const char *  | 
          fmt,  | 
        
        
           | 
           | 
            | 
          ...  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
A (very) limited version of snprintf. 
- Parameters
 - 
  
    | to | Destination buffer.  | 
    | n | Size of destination buffer.  | 
    | fmt | printf() style format string.  | 
  
   
- Returns
 - Number of bytes written, including terminating '\0' Supports 'd' 'i' 'u' 'x' 'p' 's' conversion. Supports 'l' and 'll' modifiers for integral types. Does not support any width/precision. Implemented with simplicity, and async-signal-safety in mind. 
 
 
 
◆ my_safe_utoa()
      
        
          | char * my_safe_utoa  | 
          ( | 
          int  | 
          base,  | 
        
        
           | 
           | 
          ulonglong  | 
          val,  | 
        
        
           | 
           | 
          char *  | 
          buf  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Converts a ulonglong value to string. 
- Parameters
 - 
  
    | base | 10 for decimal, 16 for hex values (0..9a..f)  | 
    | val | The value to convert  | 
    | buf | Assumed to point to the end of the buffer.  | 
  
   
- Returns
 - Pointer to the first character of the converted string. Implemented with simplicity, and async-signal-safety in mind. 
 
 
 
◆ my_write_core()
      
        
          | void my_write_core  | 
          ( | 
          int  | 
          sig | ) | 
           | 
        
      
 
 
◆ my_write_stderr()
      
        
          | size_t my_write_stderr  | 
          ( | 
          const void *  | 
          buf,  | 
        
        
           | 
           | 
          size_t  | 
          count  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Writes up to count bytes from buffer to STDERR. 
Implemented with simplicity, and async-signal-safety in mind. 
- Parameters
 - 
  
    | buf | Buffer containing data to be written.  | 
    | count | Number of bytes to write.  | 
  
   
- Returns
 - Number of bytes written.