URI: 
       tlib9: remove getcallerpc implementations - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 540caa5873bcc3bc2a0e1896119f5b53a0e8e630
   DIR parent 2897735523dd05a4ef21d25d3d99fa7fa0b24b44
  HTML Author: Russ Cox <rsc@swtch.com>
       Date:   Tue,  7 Jan 2020 15:31:01 -0500
       
       lib9: remove getcallerpc implementations
       
       These make no sense and are not really needed at all.
       Add a best-effort attempt to get at the gcc/clang macro
       in lib9.h, but if it fails, no big deal.
       
       Fixes #324.
       
       Diffstat:
         M include/libc.h                      |      25 ++++++++++++++-----------
         D src/lib9/getcallerpc-386.c          |       7 -------
         D src/lib9/getcallerpc-arm.c          |       8 --------
         D src/lib9/getcallerpc-arm64.c        |       8 --------
         D src/lib9/getcallerpc-mips.c         |       8 --------
         D src/lib9/getcallerpc-power.c        |      11 -----------
         D src/lib9/getcallerpc-sun4u.s        |       5 -----
         D src/lib9/getcallerpc-x86_64.c       |       7 -------
         M src/lib9/mkfile                     |       2 +-
       
       9 files changed, 15 insertions(+), 66 deletions(-)
       ---
   DIR diff --git a/include/libc.h b/include/libc.h
       t@@ -11,13 +11,13 @@
        #define _LIBC_H_ 1
        #if defined(__cplusplus)
        extern "C" {
       -#endif                                                                
       +#endif
        
        #include <utf.h>
        #include <fmt.h>
        
        /*
       - * Begin usual libc.h 
       + * Begin usual libc.h
         */
        
        #ifndef nil
       t@@ -361,7 +361,7 @@ enum
        extern        int        p9atexit(void(*)(void));
        extern        void        p9atexitdont(void(*)(void));
        extern        int        atnotify(int(*)(void*, char*), int);
       -/* 
       +/*
         * <stdlib.h>
        extern        double        atof(char*); <stdlib.h>
         */
       t@@ -385,6 +385,9 @@ extern        int        exitcode(char*);
        extern        void        exits(char*);
        extern        double        frexp(double, int*);
        extern        ulong        getcallerpc(void*);
       +#if defined(__GNUC__) || defined(__clang__)
       +#define getcallerpc(x) ((ulong)__builtin_return_address(0))
       +#endif
        extern        char*        p9getenv(char*);
        extern        int        p9putenv(char*, char*);
        extern        int        getfields(char*, char**, int, int, char*);
       t@@ -479,7 +482,7 @@ extern        void        lock(Lock*);
        extern        void        unlock(Lock*);
        extern        int        canlock(Lock*);
        extern        int        (*_lock)(Lock*, int, ulong);
       -extern        void        (*_unlock)(Lock*, ulong);        
       +extern        void        (*_unlock)(Lock*, ulong);
        
        typedef struct QLock QLock;
        struct QLock
       t@@ -670,15 +673,15 @@ extern        void                freenetconninfo(NetConnInfo*);
        
        enum
        {
       -        RFNAMEG                = (1<<0), 
       -        RFENVG                = (1<<1), 
       +        RFNAMEG                = (1<<0),
       +        RFENVG                = (1<<1),
                RFFDG                = (1<<2),
                RFNOTEG                = (1<<3),
                RFPROC                = (1<<4),
                RFMEM                = (1<<5),
                RFNOWAIT        = (1<<6),
       -        RFCNAMEG        = (1<<10), 
       -        RFCENVG                = (1<<11), 
       +        RFCNAMEG        = (1<<10),
       +        RFCENVG                = (1<<11),
                RFCFDG                = (1<<12)
        /*        RFREND                = (1<<13), */
        /*        RFNOMNT                = (1<<14) */
       t@@ -707,7 +710,7 @@ struct Dir {
                char        *uid;        /* owner name */
                char        *gid;        /* group name */
                char        *muid;        /* last modifier name */
       -        
       +
                /* 9P2000.u extensions */
                uint        uidnum;                /* numeric uid */
                uint        gidnum;                /* numeric gid */
       t@@ -750,7 +753,7 @@ extern        int        p9exec(char*, char*[]);
        extern        int        p9execl(char*, ...);
        /* extern        int        p9fork(void); */
        extern        int        p9rfork(int);
       -/* not implemented 
       +/* not implemented
        extern        int        fauth(int, char*);
        extern        int        fstat(int, uchar*, int);
        extern        int        fwstat(int, uchar*, int);
       t@@ -767,7 +770,7 @@ extern        int        notifyoff(char*);
        extern        int        p9open(char*, int);
        extern        int        fd2path(int, char*, int);
        extern        int        p9pipe(int*);
       -/* 
       +/*
         * use defs from <unistd.h>
        extern        long        pread(int, void*, long, vlong);
        extern        long        preadv(int, IOchunk*, int, vlong);
   DIR diff --git a/src/lib9/getcallerpc-386.c b/src/lib9/getcallerpc-386.c
       t@@ -1,7 +0,0 @@
       -#include <lib9.h>
       -
       -ulong
       -getcallerpc(void *x)
       -{
       -        return (((ulong*)(x))[-1]);
       -}
   DIR diff --git a/src/lib9/getcallerpc-arm.c b/src/lib9/getcallerpc-arm.c
       t@@ -1,8 +0,0 @@
       -#include <lib9.h>
       -
       -ulong
       -getcallerpc(void *x)
       -{
       -        return ((ulong*)x)[-2];
       -}
       -
   DIR diff --git a/src/lib9/getcallerpc-arm64.c b/src/lib9/getcallerpc-arm64.c
       t@@ -1,8 +0,0 @@
       -#include <lib9.h>
       -
       -ulong
       -getcallerpc(void *x)
       -{
       -        return ((ulong*)x)[-2];
       -}
       -
   DIR diff --git a/src/lib9/getcallerpc-mips.c b/src/lib9/getcallerpc-mips.c
       t@@ -1,8 +0,0 @@
       -#include <lib9.h>
       -
       -ulong
       -getcallerpc(void *x)
       -{
       -        return ((ulong*)x)[-2];
       -}
       -
   DIR diff --git a/src/lib9/getcallerpc-power.c b/src/lib9/getcallerpc-power.c
       t@@ -1,11 +0,0 @@
       -#include <lib9.h>
       -
       -ulong
       -getcallerpc(void *x)
       -{
       -        ulong *lp;
       -
       -        lp = x;
       -
       -        return lp[-1];
       -}
   DIR diff --git a/src/lib9/getcallerpc-sun4u.s b/src/lib9/getcallerpc-sun4u.s
       t@@ -1,5 +0,0 @@
       -.text
       -.globl getcallerpc
       -getcallerpc:
       -        retl
       -        or %o7, %r0, %o0
   DIR diff --git a/src/lib9/getcallerpc-x86_64.c b/src/lib9/getcallerpc-x86_64.c
       t@@ -1,7 +0,0 @@
       -#include <lib9.h>
       -
       -ulong
       -getcallerpc(void *x)
       -{
       -        return (((ulong*)(x))[-1]);
       -}
   DIR diff --git a/src/lib9/mkfile b/src/lib9/mkfile
       t@@ -104,7 +104,7 @@ LIB9OFILES=\
                fcallfmt.$O\
                frand.$O\
                get9root.$O\
       -        getcallerpc-$OBJTYPE.$O\
       +        getcallerpc.$O\
                getenv.$O\
                getfields.$O\
                getnetconn.$O\