components/pigz/patches/named-threads.patch
changeset 2137 b1e25f951af0
equal deleted inserted replaced
2136:f1e602172275 2137:b1e25f951af0
       
     1 # HG changeset patch
       
     2 # User Michael Gerdts <[email protected]>
       
     3 # Date 1412623353 25200
       
     4 #      Mon Oct 06 12:22:33 2014 -0700
       
     5 # Node ID 0293c398eda727bf812a867600a25b7831928db7
       
     6 # Parent  b63f212d891d9cffbc8f4a0e2293532fe44aaa16
       
     7 name threads to improve observability - developed by Oracle
       
     8 Not submitted upstream: Uses feature first present in Solaris 12
       
     9 
       
    10 diff -r b63f212d891d -r 0293c398eda7 yarn.c
       
    11 --- a/yarn.c
       
    12 +++ b/yarn.c
       
    13 @@ -258,7 +258,12 @@
       
    14  
       
    15  /* not all POSIX implementations create threads as joinable by default, so that
       
    16     is made explicit here */
       
    17 +#ifdef HAVE_PTHREAD_SETNAME_NP
       
    18 +#undef launch
       
    19 +thread *launch(const char *probename, void (*probe)(void *), void *payload)
       
    20 +#else
       
    21  thread *launch(void (*probe)(void *), void *payload)
       
    22 +#endif
       
    23  {
       
    24      int ret;
       
    25      thread *th;
       
    26 @@ -284,7 +289,9 @@
       
    27          (ret = pthread_create(&(th->id), &attr, ignition, capsule)) ||
       
    28          (ret = pthread_attr_destroy(&attr)))
       
    29          fail(ret);
       
    30 -
       
    31 +#ifdef HAVE_PTHREAD_SETNAME_NP
       
    32 +    (void)pthread_setname_np(th->id, probename);
       
    33 +#endif
       
    34      /* put the thread in the threads list for join_all() */
       
    35      th->done = 0;
       
    36      th->next = threads;
       
    37 diff -r b63f212d891d -r 0293c398eda7 yarn.h
       
    38 --- a/yarn.h
       
    39 +++ b/yarn.h
       
    40 @@ -115,7 +115,12 @@
       
    41  void yarn_mem(void *(*)(size_t), void (*)(void *));
       
    42  
       
    43  typedef struct thread_s thread;
       
    44 +#ifdef HAVE_PTHREAD_SETNAME_NP
       
    45 +thread *launch(const char *, void (*)(void *), void *);
       
    46 +#define launch(p, a) launch(#p, p, a)
       
    47 +#else
       
    48  thread *launch(void (*)(void *), void *);
       
    49 +#endif
       
    50  void join(thread *);
       
    51  int join_all(void);
       
    52  void destruct(thread *);