Print this page
OS-5192 need faster clock_gettime
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Reviewed by: Ryan Zezeski <ryan@zinascii.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/rtld/common/external.c
          +++ new/usr/src/cmd/sgs/rtld/common/external.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright 2014 Garrett D'Amore <garrett@damore.org>
  25      - * Copyright 2015 Joyent, Inc.
       25 + * Copyright 2016 Joyent, Inc.
  26   26   */
  27   27  
  28   28  /*
  29   29   * Implementation of all external interfaces between ld.so.1 and libc.
  30   30   *
  31   31   * This file started as a set of routines that provided synchronization and
  32   32   * locking operations using calls to libthread.  libthread has merged with libc
  33   33   * under the Unified Process Model (UPM), and things have gotten a lot simpler.
  34   34   * This file continues to establish and redirect various events within ld.so.1
  35   35   * to interfaces within libc.
↓ open down ↓ 678 lines elided ↑ open up ↑
 714  714  {
 715  715          return ((isupper(c) || islower(c)) ? 1 : 0);
 716  716  }
 717  717  
 718  718  int
 719  719  isalnum(int c)
 720  720  {
 721  721          return ((isalpha(c) || isdigit(c)) ? 1 : 0);
 722  722  }
 723  723  
      724 +#if defined(__i386) || defined(__amd64)
 724  725  /*
      726 + * Instead of utilizing the comm page for clock_gettime, rtld uses the raw
      727 + * syscall instead.  Doing so decreases the surface of symbols needed from libc
      728 + * for a modest performance cost.
      729 + */
      730 +extern int __clock_gettime_sys(clockid_t, struct timespec *);
      731 +
      732 +int
      733 +__clock_gettime(clockid_t clock_id, struct timespec *tp)
      734 +{
      735 +        return (__clock_gettime_sys(clock_id, tp));
      736 +}
      737 +#endif /* defined(__i386) || defined(__amd64) */
      738 +
      739 +/*
 725  740   * In a similar vein to the is* functions above, we also have to define our own
 726  741   * version of strerror, as it is implemented in terms of the locale aware
 727  742   * strerror_l, and we'd rather not have the full set of libc symbols used here.
 728  743   */
 729  744  extern const char _sys_errs[];
 730  745  extern const int _sys_index[];
 731  746  extern int _sys_num_err;
 732  747  
 733  748  char *
 734  749  strerror(int errnum)
 735  750  {
 736  751          if (errnum < _sys_num_err && errnum >= 0) {
 737  752                  return (dgettext("SUNW_OST_OSLIB",
 738  753                      (char *)&_sys_errs[_sys_index[errnum]]));
 739  754          }
 740  755  
 741  756          errno = EINVAL;
 742  757          return (dgettext("SUNW_OST_OSLIB", "Unknown error"));
 743  758  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX