Print this page
use thread_local for ntoa buf

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/inet/inet_ntoa.c
          +++ new/usr/src/lib/libc/port/inet/inet_ntoa.c
↓ open down ↓ 102 lines elided ↑ open up ↑
 103  103   */
 104  104  
 105  105  /*
 106  106   * Convert network-format internet address
 107  107   * to base 256 d.d.d.d representation.
 108  108   *
 109  109   * Reentrant interface
 110  110   */
 111  111  
 112  112  #include "lint.h"
 113      -#include "thr_uberdata.h"
 114  113  
 115  114  #include <sys/types.h>
 116  115  
 117  116  #include <netinet/in.h>
 118  117  
 119  118  #include <ctype.h>
 120  119  #include <errno.h>
 121  120  #include <stdio.h>
 122  121  #include <stdlib.h>
      122 +#include <threads.h>
 123  123  
      124 +static thread_local char ntoa_buf[18];
      125 +
 124  126  char *
 125  127  inet_ntoa_r(struct in_addr in, char b[])
 126  128  {
 127  129          char    *p;
 128  130  
 129  131          p = (char *)&in;
 130  132  #define UC(b)   (((int)b)&0xff)
 131  133          (void) sprintf(b, "%d.%d.%d.%d",
 132  134              UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
 133  135          return (b);
 134  136  }
 135  137  
 136  138  char *
 137  139  inet_ntoa(struct in_addr in)
 138  140  {
 139      -        return (inet_ntoa_r(in, curthread->ul_ntoabuf));
      141 +        return (inet_ntoa_r(in, ntoa_buf));
 140  142  }
 141  143  
 142  144  /*
 143  145   * Check whether "cp" is a valid ascii representation
 144  146   * of an Internet address and convert to a binary address.
 145  147   * Returns 1 if the address is valid, 0 if not.
 146  148   * This replaces inet_addr, the return value from which
 147  149   * cannot distinguish between failure and a local broadcast address.
 148  150   */
 149  151  int
↓ open down ↓ 124 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX