Changeset 1701


Ignore:
Timestamp:
Jan 23, 2007, 4:38:18 PM (16 years ago)
Author:
Sam Hocevar
Message:
  • Added DLL initialisation code for Win32.
Location:
zzuf/trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r1696 r1701  
    1515AC_PROG_LIBTOOL
    1616
    17 AC_CHECK_HEADERS(inttypes.h stdint.h getopt.h libc.h malloc.h dlfcn.h regex.h sys/socket.h sys/uio.h aio.h sys/mman.h sys/wait.h sys/resource.h)
     17case "${host_os}" in
     18  *mingw32*)
     19    WIN32DLL_LDFLAGS="-Wl,-l,imagehlp"
     20    ac_cv_func_recv=yes
     21    ac_cv_func_recvfrom=yes
     22    ac_cv_func_socket=yes
     23    ac_cv_func_accept=yes
     24    ;;
     25esac
     26AC_SUBST(WIN32DLL_LDFLAGS)
     27
     28AC_CHECK_HEADERS(windows.h winsock2.h inttypes.h stdint.h getopt.h libc.h malloc.h dlfcn.h regex.h sys/socket.h sys/uio.h aio.h sys/mman.h sys/wait.h sys/resource.h)
     29
    1830AC_CHECK_FUNCS(open64 lseek64 mmap64 fopen64 fseeko _IO_getc getline getdelim __getdelim fgetln __srefill map_fd memalign posix_memalign aio_read accept socket readv pread recv recvfrom recvmsg mmap valloc sigaction)
     31
    1932AC_CHECK_TYPES(sighandler_t, [], [],
    2033  [#define _GNU_SOURCE
  • zzuf/trunk/src/Makefile.am

    r1692 r1701  
    66zzuf_SOURCES = zzuf.c $(COMMON) opts.c opts.h md5.c md5.h timer.c timer.h
    77zzuf_CFLAGS = -DLIBDIR=\"$(libdir)/zzuf\"
    8 zzuf_LDFLAGS = @MATH_LIBS@
     8zzuf_LDFLAGS = $(MATH_LIBS)
    99
    1010pkglib_LTLIBRARIES = libzzuf.la
    11 libzzuf_la_SOURCES = libzzuf.c libzzuf.h $(COMMON) debug.c debug.h \
     11libzzuf_la_SOURCES = libzzuf.c libzzuf.h $(COMMON) debug.c debug.h sys.c sys.h \
    1212                     lib-fd.c lib-mem.c lib-signal.c lib-stream.c lib-load.h
    13 libzzuf_la_LDFLAGS = -avoid-version -no-undefined
    14 libzzuf_la_LIBADD = @GETOPT_LIBS@ @DL_LIBS@ @MATH_LIBS@
     13libzzuf_la_LDFLAGS = -avoid-version -no-undefined $(WIN32DLL_LDFLAGS)
     14libzzuf_la_LIBADD = $(GETOPT_LIBS) $(DL_LIBS) $(MATH_LIBS)
    1515
  • zzuf/trunk/src/lib-load.h

    r1699 r1701  
    1414
    1515/*
    16  *  lib-load.h: preloaded library functions
     16 *  lib-load.h: preload library functions
    1717 */
    1818
     
    2929#define STR(x) #x
    3030#define ORIG(x) x##_orig
    31 #ifdef HAVE_DLFCN_H
    32 #   define NEW(x) x
    33 #else
    34 #   define NEW(x) x##_new
    35 #endif
    3631
    37 /* TODO: do the Win32 part */
    3832#ifdef HAVE_DLFCN_H
    3933#   include <dlfcn.h>
     34#   define NEW(x) x
    4035#   define LOADSYM(x) \
    4136        do { \
     
    4641        } while(0)
    4742#else
     43#   define NEW(x) x##_new
    4844#   define LOADSYM(x) \
    4945        do { \
    50             if(!ORIG(x)) \
    51                 abort(); \
     46            /* Nothing to do */ \
    5247        } while(0)
    5348#endif
  • zzuf/trunk/src/libzzuf.c

    r1695 r1701  
    2525#   include <inttypes.h>
    2626#endif
     27#if defined HAVE_WINDOWS_H
     28#   include <windows.h>
     29#endif
    2730#include <stdio.h>
    2831#include <sys/types.h>
     
    3740#include "debug.h"
    3841#include "fd.h"
     42#include "sys.h"
    3943#include "fuzz.h"
     44
     45/* Library initialisation shit */
     46void _zz_init(void) __attribute__((constructor));
     47void _zz_fini(void) __attribute__((destructor));
     48#if defined HAVE_WINDOWS_H
     49BOOL WINAPI DllMain(HINSTANCE, DWORD, PVOID);
     50#endif
    4051
    4152/* Global variables */
     
    97108
    98109    _zz_fd_init();
     110    _zz_sys_init();
    99111
    100112    tmp = getenv("ZZUF_STDIN");
     
    113125}
    114126
     127#if defined HAVE_WINDOWS_H
     128BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, PVOID impLoad)
     129{
     130    (void)hinst;   /* unused */
     131    (void)impLoad; /* unused */
     132
     133    switch(reason)
     134    {
     135        case DLL_PROCESS_ATTACH:
     136            _zz_init();
     137            break;
     138        case DLL_PROCESS_DETACH:
     139            _zz_fini();
     140            break;
     141    }
     142
     143    return TRUE;
     144}
     145#endif
  • zzuf/trunk/src/libzzuf.h

    r1671 r1701  
    5454extern int _zz_autoinc;
    5555
    56 /* Library initialisation shit */
    57 extern void _zz_init(void) __attribute__((constructor));
    58 extern void _zz_fini(void) __attribute__((destructor));
    59 
  • zzuf/trunk/src/zzuf.c

    r1699 r1701  
    3333#   include <regex.h>
    3434#endif
     35#if defined HAVE_WINDOWS_H
     36#   include <windows.h>
     37#endif
    3538#if defined HAVE_WINSOCK2_H
    3639#   include <winsock2.h>
     40#   include <io.h>
    3741#endif
    3842#include <string.h>
Note: See TracChangeset for help on using the changeset viewer.