Changeset 1543 for zzuf


Ignore:
Timestamp:
Jan 3, 2007, 10:09:41 AM (14 years ago)
Author:
Sam Hocevar
Message:
  • The whole crap now builds on OS X. Now if it only agreed to run, too...
Location:
zzuf/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r1513 r1543  
    2828
    2929AC_CHECK_HEADERS(inttypes.h stdint.h getopt.h)
     30AC_CHECK_FUNCS(open64 lseek64 fopen64 getline getdelim __getdelim)
     31AC_CHECK_TYPES(sighandler_t, [], [],
     32  [#define _GNU_SOURCE
     33   #include <signal.h>])
     34AC_CHECK_TYPES(sig_t, [], [],
     35  [#include <signal.h>])
    3036
    3137AC_CHECK_FUNCS(getopt_long,
  • zzuf/trunk/src/Makefile.am

    r1532 r1543  
    22bin_PROGRAMS = zzuf
    33zzuf_SOURCES = zzuf.c
    4 zzuf_CPPFLAGS = -DLIBDIR=\"$(libdir)/zzuf\"
     4AM_CPPFLAGS = -DLIBDIR=\"$(libdir)/zzuf\"
    55
    66pkglib_LTLIBRARIES = libzzuf.la
  • zzuf/trunk/src/load-fd.c

    r1535 r1543  
    2121/* Can't remember what that's for */
    2222#define _GNU_SOURCE
    23 /* Use this to get lseek64() */
     23/* Use this to get lseek64() on glibc systems */
    2424#define _LARGEFILE64_SOURCE
    2525
     
    4444/* Library functions that we divert */
    4545static int     (*open_orig)    (const char *file, int oflag, ...);
     46#ifdef HAVE_OPEN64
    4647static int     (*open64_orig)  (const char *file, int oflag, ...);
     48#endif
    4749static ssize_t (*read_orig)    (int fd, void *buf, size_t count);
    4850static off_t   (*lseek_orig)   (int fd, off_t offset, int whence);
     51#ifdef HAVE_LSEEK64
    4952static off64_t (*lseek64_orig) (int fd, off64_t offset, int whence);
     53#endif
    5054static int     (*close_orig)   (int fd);
    5155
     
    5357{
    5458    LOADSYM(open);
     59#ifdef HAVE_OPEN64
    5560    LOADSYM(open64);
     61#endif
    5662    LOADSYM(read);
    5763    LOADSYM(lseek);
     64#ifdef HAVE_LSEEK64
    5865    LOADSYM(lseek64);
     66#endif
    5967    LOADSYM(close);
    6068}
     
    98106}
    99107
     108#ifdef HAVE_OPEN64
    100109int open64(const char *file, int oflag, ...)
    101110{
    102111    int ret; OPEN(open64); return ret;
    103112}
     113#endif
    104114
    105115ssize_t read(int fd, void *buf, size_t count)
     
    121131
    122132    /* Sanity check, can be OK though (for instance with a character device) */
     133#ifdef HAVE_LSEEK64
    123134    if(lseek64_orig(fd, 0, SEEK_CUR) != _zz_getpos(fd))
     135#else
     136    if(lseek_orig(fd, 0, SEEK_CUR) != _zz_getpos(fd))
     137#endif
    124138        debug("warning: offset inconsistency");
    125139
     
    147161}
    148162
     163#ifdef HAVE_LSEEK64
    149164off64_t lseek64(int fd, off64_t offset, int whence)
    150165{
     
    153168    return ret;
    154169}
     170#endif
    155171
    156172int close(int fd)
  • zzuf/trunk/src/load-signal.c

    r1532 r1543  
    3838#include "load.h"
    3939
     40#if defined HAVE_SIGHANDLER_T
     41#   define SIG_T sighandler_t
     42#elif defined HAVE_SIG_T
     43#   define SIG_T sig_t
     44#endif
     45
    4046/* Library functions that we divert */
    41 static sighandler_t (*signal_orig)    (int signum, sighandler_t handler);
    42 static int          (*sigaction_orig) (int signum, const struct sigaction *act,
    43                                        struct sigaction *oldact);
     47static SIG_T (*signal_orig)    (int signum, SIG_T handler);
     48static int   (*sigaction_orig) (int signum, const struct sigaction *act,
     49                                struct sigaction *oldact);
    4450/* Local functions */
    4551static int isfatal(int signum);
     
    8288}
    8389
    84 sighandler_t signal(int signum, sighandler_t handler)
     90SIG_T signal(int signum, SIG_T handler)
    8591{
    86     sighandler_t ret;
     92    SIG_T ret;
    8793
    8894    if(!_zz_ready)
  • zzuf/trunk/src/load-stream.c

    r1527 r1543  
    3838/* Library functions that we divert */
    3939static FILE *  (*fopen_orig)   (const char *path, const char *mode);
     40#ifdef HAVE_FOPEN64
    4041static FILE *  (*fopen64_orig) (const char *path, const char *mode);
     42#endif
    4143static int     (*fseek_orig)   (FILE *stream, long offset, int whence);
    4244static size_t  (*fread_orig)   (void *ptr, size_t size, size_t nmemb,
     
    4951
    5052/* Additional GNUisms */
     53#ifdef HAVE_GETLINE
    5154static ssize_t (*getline_orig)    (char **lineptr, size_t *n, FILE *stream);
     55#endif
     56#ifdef HAVE_GETDELIM
    5257static ssize_t (*getdelim_orig)   (char **lineptr, size_t *n, int delim,
    5358                                   FILE *stream);
     59#endif
     60#ifdef HAVE___GETDELIM
    5461static ssize_t (*__getdelim_orig) (char **lineptr, size_t *n, int delim,
    5562                                   FILE *stream);
     63#endif
    5664
    5765void _zz_load_stream(void)
    5866{
    5967    LOADSYM(fopen);
     68#ifdef HAVE_FOPEN64
    6069    LOADSYM(fopen64);
     70#endif
    6171    LOADSYM(fseek);
    6272    LOADSYM(fread);
     
    6676    LOADSYM(ungetc);
    6777    LOADSYM(fclose);
    68 
     78#ifdef HAVE_GETLINE
    6979    LOADSYM(getline);
     80#endif
     81#ifdef HAVE_GETDELIM
    7082    LOADSYM(getdelim);
     83#endif
     84#ifdef HAVE___GETDELIM
    7185    LOADSYM(__getdelim);
     86#endif
    7287}
    7388
     
    95110}
    96111
     112#ifdef HAVE_FOPEN64
    97113FILE *fopen64(const char *path, const char *mode)
    98114{
    99115    FILE *ret; FOPEN(fopen64); return ret;
    100116}
     117#endif
    101118
    102119int fseek(FILE *stream, long offset, int whence)
     
    321338    } while(0)
    322339
     340#ifdef HAVE_GETLINE
    323341ssize_t getline(char **lineptr, size_t *n, FILE *stream)
    324342{
    325343    ssize_t ret; GETDELIM(getline, '\n', 0); return ret;
    326344}
    327 
     345#endif
     346
     347#ifdef HAVE_GETDELIM
    328348ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream)
    329349{
    330350    ssize_t ret; GETDELIM(getdelim, delim, 1); return ret;
    331351}
    332 
     352#endif
     353
     354#ifdef HAVE___GETDELIM
    333355ssize_t __getdelim(char **lineptr, size_t *n, int delim, FILE *stream)
    334356{
    335357    ssize_t ret; GETDELIM(__getdelim, delim, 1); return ret;
    336358}
    337 
     359#endif
     360
  • zzuf/trunk/src/zzuf.c

    r1540 r1543  
    4444static char *merge_regex(char *, char *);
    4545static char *merge_file(char *, char *);
    46 static void set_ld_preload(char const *);
     46static void set_environment(char const *);
    4747static void version(void);
    4848#if defined(HAVE_GETOPT_H)
     
    223223
    224224    /* Preload libzzuf.so */
    225     set_ld_preload(argv[0]);
     225    set_environment(argv[0]);
    226226
    227227    /* Create new argv */
     
    484484}
    485485
    486 static void set_ld_preload(char const *progpath)
     486static void set_environment(char const *progpath)
    487487{
    488488    char *libpath, *tmp;
    489489    int len = strlen(progpath);
     490#ifdef __APPLE__
     491    char const *preload = "DYLD_INSERT_LIBRARIES";
     492    setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
     493#else
     494    char const *preload = "LD_PRELOAD";
     495#endif
    490496
    491497    libpath = malloc(len + strlen("/.libs/libzzuf.so") + 1);
     
    494500    strcpy(tmp ? tmp + 1 : libpath, ".libs/libzzuf.so");
    495501    if(access(libpath, R_OK) == 0)
    496         setenv("LD_PRELOAD", libpath, 1);
     502        setenv(preload, libpath, 1);
    497503    else
    498         setenv("LD_PRELOAD", LIBDIR "/libzzuf.so", 1);
     504        setenv(preload, LIBDIR "/libzzuf.so", 1);
    499505    free(libpath);
    500506}
  • zzuf/trunk/test/fdcat.c

    r1521 r1543  
    5555        for(j = 0; j < 16; j++)
    5656            read(fd, data + lseek(fd, 0, SEEK_CUR), rand() % 4096);
     57#ifdef HAVE_LSEEK64
    5758        lseek64(fd, rand() % pos, SEEK_SET);
    5859        for(j = 0; j < 16; j++)
    5960            read(fd, data + lseek(fd, 0, SEEK_CUR), rand() % 4096);
     61#endif
    6062    }
    6163
Note: See TracChangeset for help on using the changeset viewer.