[BACK]Return to util.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / nm

Annotation of src/usr.bin/nm/util.h, Revision 1.3

1.3     ! guenther    1: /*     $OpenBSD: util.h,v 1.2 2004/10/09 22:11:11 millert Exp $        */
1.2       millert     2:
                      3: /*
                      4:  * Placed in the public domain by Todd C. Miller <Todd.Miller@courtesan.com>
                      5:  * on October 9, 2004.
                      6:  */
1.1       mickey      7:
                      8: #define        MMAP(ptr, len, prot, flags, fd, off)    do {            \
                      9:        if ((ptr = mmap(NULL, len, prot, flags, fd, off)) == MAP_FAILED) { \
                     10:                usemmap = 0;                                            \
                     11:                if (errno != EINVAL)                                    \
                     12:                        warn("mmap");                                   \
                     13:                else if ((ptr = malloc(len)) == NULL) {                 \
                     14:                        ptr = MAP_FAILED;                               \
                     15:                        warn("malloc");                                 \
                     16:                } else if (pread(fd, ptr, len, off) != len) {           \
                     17:                        free(ptr);                                      \
                     18:                        ptr = MAP_FAILED;                               \
                     19:                        warn("pread");                                  \
                     20:                }                                                       \
                     21:        }                                                               \
                     22: } while (0)
                     23:
                     24: #define MUNMAP(addr, len)      do {                                    \
                     25:        if (usemmap)                                                    \
                     26:                munmap(addr, len);                                      \
                     27:        else                                                            \
                     28:                free(addr);                                             \
                     29: } while (0)
                     30:
                     31: extern int usemmap;
1.3     ! guenther   32: extern int dynamic_only;