| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * poll_posix: poll compatibility wrapper for POSIX systems | ||
| * Copyright © 2013 RealVNC Ltd. | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| * | ||
| */ | ||
|
|
||
| #include <unistd.h> | ||
| #include <fcntl.h> | ||
| #include <errno.h> | ||
| #include <stdlib.h> | ||
|
|
||
| #include "libusbi.h" | ||
|
|
||
| int usbi_pipe(int pipefd[2]) | ||
| { | ||
| int ret = pipe(pipefd); | ||
| if (ret != 0) { | ||
| return ret; | ||
| } | ||
| ret = fcntl(pipefd[1], F_GETFL); | ||
| if (ret == -1) { | ||
| usbi_dbg("Failed to get pipe fd flags: %d", errno); | ||
| goto err_close_pipe; | ||
| } | ||
| ret = fcntl(pipefd[1], F_SETFL, ret | O_NONBLOCK); | ||
| if (ret != 0) { | ||
| usbi_dbg("Failed to set non-blocking on new pipe: %d", errno); | ||
| goto err_close_pipe; | ||
| } | ||
|
|
||
| return 0; | ||
|
|
||
| err_close_pipe: | ||
| usbi_close(pipefd[0]); | ||
| usbi_close(pipefd[1]); | ||
| return ret; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #ifndef LIBUSB_POLL_POSIX_H | ||
| #define LIBUSB_POLL_POSIX_H | ||
|
|
||
| #define usbi_write write | ||
| #define usbi_read read | ||
| #define usbi_close close | ||
| #define usbi_poll poll | ||
|
|
||
| int usbi_pipe(int pipefd[2]); | ||
|
|
||
| #endif /* LIBUSB_POLL_POSIX_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| /* | ||
| * Windows compat: POSIX compatibility wrapper | ||
| * Copyright © 2012-2013 RealVNC Ltd. | ||
| * Copyright © 2009-2010 Pete Batard <pete@akeo.ie> | ||
| * With contributions from Michael Plante, Orin Eman et al. | ||
| * Parts of poll implementation from libusb-win32, by Stephan Meyer et al. | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| * | ||
| */ | ||
| #pragma once | ||
|
|
||
| #if defined(_MSC_VER) | ||
| // disable /W4 MSVC warnings that are benign | ||
| #pragma warning(disable:4127) // conditional expression is constant | ||
| #endif | ||
|
|
||
| // Handle synchronous completion through the overlapped structure | ||
| #if !defined(STATUS_REPARSE) // reuse the REPARSE status code | ||
| #define STATUS_REPARSE ((LONG)0x00000104L) | ||
| #endif | ||
| #define STATUS_COMPLETED_SYNCHRONOUSLY STATUS_REPARSE | ||
| #if defined(_WIN32_WCE) | ||
| // WinCE doesn't have a HasOverlappedIoCompleted() macro, so attempt to emulate it | ||
| #define HasOverlappedIoCompleted(lpOverlapped) (((DWORD)(lpOverlapped)->Internal) != STATUS_PENDING) | ||
| #endif | ||
| #define HasOverlappedIoCompletedSync(lpOverlapped) (((DWORD)(lpOverlapped)->Internal) == STATUS_COMPLETED_SYNCHRONOUSLY) | ||
|
|
||
| #define DUMMY_HANDLE ((HANDLE)(LONG_PTR)-2) | ||
|
|
||
| enum windows_version { | ||
| WINDOWS_UNSUPPORTED, | ||
| WINDOWS_CE, | ||
| WINDOWS_XP, | ||
| WINDOWS_2003, // also includes XP 64 | ||
| WINDOWS_VISTA_AND_LATER, | ||
| }; | ||
| extern enum windows_version windows_version; | ||
|
|
||
| #define MAX_FDS 256 | ||
|
|
||
| #define POLLIN 0x0001 /* There is data to read */ | ||
| #define POLLPRI 0x0002 /* There is urgent data to read */ | ||
| #define POLLOUT 0x0004 /* Writing now will not block */ | ||
| #define POLLERR 0x0008 /* Error condition */ | ||
| #define POLLHUP 0x0010 /* Hung up */ | ||
| #define POLLNVAL 0x0020 /* Invalid request: fd not open */ | ||
|
|
||
| struct pollfd { | ||
| int fd; /* file descriptor */ | ||
| short events; /* requested events */ | ||
| short revents; /* returned events */ | ||
| }; | ||
|
|
||
| // access modes | ||
| enum rw_type { | ||
| RW_NONE, | ||
| RW_READ, | ||
| RW_WRITE, | ||
| }; | ||
|
|
||
| // fd struct that can be used for polling on Windows | ||
| typedef int cancel_transfer(struct usbi_transfer *itransfer); | ||
|
|
||
| struct winfd { | ||
| int fd; // what's exposed to libusb core | ||
| HANDLE handle; // what we need to attach overlapped to the I/O op, so we can poll it | ||
| OVERLAPPED* overlapped; // what will report our I/O status | ||
| struct usbi_transfer *itransfer; // Associated transfer, or NULL if completed | ||
| cancel_transfer *cancel_fn; // Function pointer to cancel transfer API | ||
| enum rw_type rw; // I/O transfer direction: read *XOR* write (NOT BOTH) | ||
| }; | ||
| extern const struct winfd INVALID_WINFD; | ||
|
|
||
| int usbi_pipe(int pipefd[2]); | ||
| int usbi_poll(struct pollfd *fds, unsigned int nfds, int timeout); | ||
| ssize_t usbi_write(int fd, const void *buf, size_t count); | ||
| ssize_t usbi_read(int fd, void *buf, size_t count); | ||
| int usbi_close(int fd); | ||
|
|
||
| void init_polling(void); | ||
| void exit_polling(void); | ||
| struct winfd usbi_create_fd(HANDLE handle, int access_mode, | ||
| struct usbi_transfer *transfer, cancel_transfer *cancel_fn); | ||
| void usbi_free_fd(struct winfd* winfd); | ||
| struct winfd fd_to_winfd(int fd); | ||
| struct winfd handle_to_winfd(HANDLE handle); | ||
| struct winfd overlapped_to_winfd(OVERLAPPED* overlapped); | ||
|
|
||
| /* | ||
| * Timeval operations | ||
| */ | ||
| #if defined(DDKBUILD) | ||
| #include <winsock.h> // defines timeval functions on DDK | ||
| #endif | ||
|
|
||
| #if !defined(TIMESPEC_TO_TIMEVAL) | ||
| #define TIMESPEC_TO_TIMEVAL(tv, ts) { \ | ||
| (tv)->tv_sec = (long)(ts)->tv_sec; \ | ||
| (tv)->tv_usec = (long)(ts)->tv_nsec / 1000; \ | ||
| } | ||
| #endif | ||
| #if !defined(timersub) | ||
| #define timersub(a, b, result) \ | ||
| do { \ | ||
| (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ | ||
| (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ | ||
| if ((result)->tv_usec < 0) { \ | ||
| --(result)->tv_sec; \ | ||
| (result)->tv_usec += 1000000; \ | ||
| } \ | ||
| } while (0) | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| /* | ||
| * libusbx synchronization using POSIX Threads | ||
| * | ||
| * Copyright © 2011 Vitali Lovich <vlovich@aliph.com> | ||
| * Copyright © 2011 Peter Stuge <peter@stuge.se> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| #if defined(__linux__) || defined(__OpenBSD__) | ||
| # if defined(__linux__) | ||
| # define _GNU_SOURCE | ||
| # else | ||
| # define _BSD_SOURCE | ||
| # endif | ||
| # include <unistd.h> | ||
| # include <sys/syscall.h> | ||
| #elif defined(__APPLE__) | ||
| # include <mach/mach.h> | ||
| #elif defined(__CYGWIN__) | ||
| # include <windows.h> | ||
| #endif | ||
|
|
||
| #include "threads_posix.h" | ||
|
|
||
| int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) | ||
| { | ||
| int err; | ||
| pthread_mutexattr_t stack_attr; | ||
| if (!attr) { | ||
| attr = &stack_attr; | ||
| err = pthread_mutexattr_init(&stack_attr); | ||
| if (err != 0) | ||
| return err; | ||
| } | ||
|
|
||
| /* mutexattr_settype requires _GNU_SOURCE or _XOPEN_SOURCE >= 500 on Linux */ | ||
| err = pthread_mutexattr_settype(attr, PTHREAD_MUTEX_RECURSIVE); | ||
| if (err != 0) | ||
| goto finish; | ||
|
|
||
| err = pthread_mutex_init(mutex, attr); | ||
|
|
||
| finish: | ||
| if (attr == &stack_attr) | ||
| pthread_mutexattr_destroy(&stack_attr); | ||
|
|
||
| return err; | ||
| } | ||
|
|
||
| int usbi_get_tid(void) | ||
| { | ||
| int ret = -1; | ||
| #if defined(__linux__) | ||
| ret = syscall(SYS_gettid); | ||
| #elif defined(__OpenBSD__) | ||
| /* The following only works with OpenBSD > 5.1 as it requires | ||
| real thread support. For 5.1 and earlier, -1 is returned. */ | ||
| ret = syscall(SYS_getthrid); | ||
| #elif defined(__APPLE__) | ||
| ret = mach_thread_self(); | ||
| mach_port_deallocate(mach_task_self(), ret); | ||
| #elif defined(__CYGWIN__) | ||
| ret = GetCurrentThreadId(); | ||
| #endif | ||
| /* TODO: NetBSD thread ID support */ | ||
| return ret; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * libusbx synchronization using POSIX Threads | ||
| * | ||
| * Copyright © 2010 Peter Stuge <peter@stuge.se> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| #ifndef LIBUSB_THREADS_POSIX_H | ||
| #define LIBUSB_THREADS_POSIX_H | ||
|
|
||
| #include <pthread.h> | ||
|
|
||
| #define usbi_mutex_static_t pthread_mutex_t | ||
| #define USBI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER | ||
| #define usbi_mutex_static_lock pthread_mutex_lock | ||
| #define usbi_mutex_static_unlock pthread_mutex_unlock | ||
|
|
||
| #define usbi_mutex_t pthread_mutex_t | ||
| #define usbi_mutex_init pthread_mutex_init | ||
| #define usbi_mutex_lock pthread_mutex_lock | ||
| #define usbi_mutex_unlock pthread_mutex_unlock | ||
| #define usbi_mutex_trylock pthread_mutex_trylock | ||
| #define usbi_mutex_destroy pthread_mutex_destroy | ||
|
|
||
| #define usbi_cond_t pthread_cond_t | ||
| #define usbi_cond_init pthread_cond_init | ||
| #define usbi_cond_wait pthread_cond_wait | ||
| #define usbi_cond_timedwait pthread_cond_timedwait | ||
| #define usbi_cond_broadcast pthread_cond_broadcast | ||
| #define usbi_cond_destroy pthread_cond_destroy | ||
| #define usbi_cond_signal pthread_cond_signal | ||
|
|
||
| extern int usbi_mutex_init_recursive(pthread_mutex_t *mutex, pthread_mutexattr_t *attr); | ||
|
|
||
| int usbi_get_tid(void); | ||
|
|
||
| #endif /* LIBUSB_THREADS_POSIX_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| /* | ||
| * libusbx synchronization on Microsoft Windows | ||
| * | ||
| * Copyright © 2010 Michael Plante <michael.plante@gmail.com> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| #include <config.h> | ||
| #include <objbase.h> | ||
| #include <errno.h> | ||
| #include <stdarg.h> | ||
|
|
||
| #include "libusbi.h" | ||
|
|
||
| extern const uint64_t epoch_time; | ||
|
|
||
| int usbi_mutex_init(usbi_mutex_t *mutex, | ||
| const usbi_mutexattr_t *attr) { | ||
| UNUSED(attr); | ||
| if(! mutex) return ((errno=EINVAL)); | ||
| *mutex = CreateMutex(NULL, FALSE, NULL); | ||
| if(!*mutex) return ((errno=ENOMEM)); | ||
| return 0; | ||
| } | ||
| int usbi_mutex_destroy(usbi_mutex_t *mutex) { | ||
| // It is not clear if CloseHandle failure is due to failure to unlock. | ||
| // If so, this should be errno=EBUSY. | ||
| if(!mutex || !CloseHandle(*mutex)) return ((errno=EINVAL)); | ||
| *mutex = NULL; | ||
| return 0; | ||
| } | ||
| int usbi_mutex_trylock(usbi_mutex_t *mutex) { | ||
| DWORD result; | ||
| if(!mutex) return ((errno=EINVAL)); | ||
| result = WaitForSingleObject(*mutex, 0); | ||
| if(result == WAIT_OBJECT_0 || result == WAIT_ABANDONED) | ||
| return 0; // acquired (ToDo: check that abandoned is ok) | ||
| if(result == WAIT_TIMEOUT) | ||
| return ((errno=EBUSY)); | ||
| return ((errno=EINVAL)); // don't know how this would happen | ||
| // so don't know proper errno | ||
| } | ||
| int usbi_mutex_lock(usbi_mutex_t *mutex) { | ||
| DWORD result; | ||
| if(!mutex) return ((errno=EINVAL)); | ||
| result = WaitForSingleObject(*mutex, INFINITE); | ||
| if(result == WAIT_OBJECT_0 || result == WAIT_ABANDONED) | ||
| return 0; // acquired (ToDo: check that abandoned is ok) | ||
| return ((errno=EINVAL)); // don't know how this would happen | ||
| // so don't know proper errno | ||
| } | ||
| int usbi_mutex_unlock(usbi_mutex_t *mutex) { | ||
| if(!mutex) return ((errno=EINVAL)); | ||
| if(!ReleaseMutex(*mutex)) return ((errno=EPERM )); | ||
| return 0; | ||
| } | ||
|
|
||
| int usbi_mutex_static_lock(usbi_mutex_static_t *mutex) { | ||
| if(!mutex) return ((errno=EINVAL)); | ||
| while (InterlockedExchange((LONG *)mutex, 1) == 1) { | ||
| SleepEx(0, TRUE); | ||
| } | ||
| return 0; | ||
| } | ||
| int usbi_mutex_static_unlock(usbi_mutex_static_t *mutex) { | ||
| if(!mutex) return ((errno=EINVAL)); | ||
| *mutex = 0; | ||
| return 0; | ||
| } | ||
|
|
||
| int usbi_cond_init(usbi_cond_t *cond, | ||
| const usbi_condattr_t *attr) { | ||
| UNUSED(attr); | ||
| if(!cond) return ((errno=EINVAL)); | ||
| list_init(&cond->waiters ); | ||
| list_init(&cond->not_waiting); | ||
| return 0; | ||
| } | ||
| int usbi_cond_destroy(usbi_cond_t *cond) { | ||
| // This assumes no one is using this anymore. The check MAY NOT BE safe. | ||
| struct usbi_cond_perthread *pos, *next_pos = NULL; | ||
| if(!cond) return ((errno=EINVAL)); | ||
| if(!list_empty(&cond->waiters)) return ((errno=EBUSY )); // (!see above!) | ||
| list_for_each_entry_safe(pos, next_pos, &cond->not_waiting, list, struct usbi_cond_perthread) { | ||
| CloseHandle(pos->event); | ||
| list_del(&pos->list); | ||
| free(pos); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| int usbi_cond_broadcast(usbi_cond_t *cond) { | ||
| // Assumes mutex is locked; this is not in keeping with POSIX spec, but | ||
| // libusb does this anyway, so we simplify by not adding more sync | ||
| // primitives to the CV definition! | ||
| int fail = 0; | ||
| struct usbi_cond_perthread *pos; | ||
| if(!cond) return ((errno=EINVAL)); | ||
| list_for_each_entry(pos, &cond->waiters, list, struct usbi_cond_perthread) { | ||
| if(!SetEvent(pos->event)) | ||
| fail = 1; | ||
| } | ||
| // The wait function will remove its respective item from the list. | ||
| return fail ? ((errno=EINVAL)) : 0; | ||
| } | ||
| int usbi_cond_signal(usbi_cond_t *cond) { | ||
| // Assumes mutex is locked; this is not in keeping with POSIX spec, but | ||
| // libusb does this anyway, so we simplify by not adding more sync | ||
| // primitives to the CV definition! | ||
| struct usbi_cond_perthread *pos; | ||
| if(!cond) return ((errno=EINVAL)); | ||
| if(list_empty(&cond->waiters)) return 0; // no one to wakeup. | ||
| pos = list_entry(&cond->waiters.next, struct usbi_cond_perthread, list); | ||
| // The wait function will remove its respective item from the list. | ||
| return SetEvent(pos->event) ? 0 : ((errno=EINVAL)); | ||
| } | ||
| __inline static int usbi_cond_intwait(usbi_cond_t *cond, | ||
| usbi_mutex_t *mutex, | ||
| DWORD timeout_ms) { | ||
| struct usbi_cond_perthread *pos; | ||
| int found = 0, r; | ||
| DWORD r2,tid = GetCurrentThreadId(); | ||
| if(!cond || !mutex) return ((errno=EINVAL)); | ||
| list_for_each_entry(pos, &cond->not_waiting, list, struct usbi_cond_perthread) { | ||
| if(tid == pos->tid) { | ||
| found = 1; | ||
| break; | ||
| } | ||
| } | ||
| if(!found) { | ||
| pos = (struct usbi_cond_perthread*) calloc(1, sizeof(struct usbi_cond_perthread)); | ||
| if(!pos) return ((errno=ENOMEM)); // This errno is not POSIX-allowed. | ||
| pos->tid = tid; | ||
| pos->event = CreateEvent(NULL, FALSE, FALSE, NULL); // auto-reset. | ||
| if(!pos->event) { | ||
| free(pos); | ||
| return ((errno=ENOMEM)); | ||
| } | ||
| list_add(&pos->list, &cond->not_waiting); | ||
| } | ||
|
|
||
| list_del(&pos->list); // remove from not_waiting list. | ||
| list_add(&pos->list, &cond->waiters); | ||
|
|
||
| r = usbi_mutex_unlock(mutex); | ||
| if(r) return r; | ||
| r2 = WaitForSingleObject(pos->event, timeout_ms); | ||
| r = usbi_mutex_lock(mutex); | ||
| if(r) return r; | ||
|
|
||
| list_del(&pos->list); | ||
| list_add(&pos->list, &cond->not_waiting); | ||
|
|
||
| if(r2 == WAIT_TIMEOUT) return ((errno=ETIMEDOUT)); | ||
|
|
||
| return 0; | ||
| } | ||
| // N.B.: usbi_cond_*wait() can also return ENOMEM, even though pthread_cond_*wait cannot! | ||
| int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex) { | ||
| return usbi_cond_intwait(cond, mutex, INFINITE); | ||
| } | ||
| int usbi_cond_timedwait(usbi_cond_t *cond, | ||
| usbi_mutex_t *mutex, | ||
| const struct timespec *abstime) { | ||
| FILETIME filetime; | ||
| ULARGE_INTEGER rtime; | ||
| struct timeval targ_time, cur_time, delta_time; | ||
| struct timespec cur_time_ns; | ||
| DWORD millis; | ||
|
|
||
| // GetSystemTimeAsFileTime() is not available on CE | ||
| SYSTEMTIME st; | ||
| GetSystemTime(&st); | ||
| SystemTimeToFileTime(&st, &filetime); | ||
| rtime.LowPart = filetime.dwLowDateTime; | ||
| rtime.HighPart = filetime.dwHighDateTime; | ||
| rtime.QuadPart -= epoch_time; | ||
| cur_time_ns.tv_sec = (long)(rtime.QuadPart / 10000000); | ||
| cur_time_ns.tv_nsec = (long)((rtime.QuadPart % 10000000)*100); | ||
| TIMESPEC_TO_TIMEVAL(&cur_time, &cur_time_ns); | ||
|
|
||
| TIMESPEC_TO_TIMEVAL(&targ_time, abstime); | ||
| timersub(&targ_time, &cur_time, &delta_time); | ||
| if(delta_time.tv_sec < 0) // abstime already passed? | ||
| millis = 0; | ||
| else { | ||
| millis = delta_time.tv_usec/1000; | ||
| millis += delta_time.tv_sec *1000; | ||
| if (delta_time.tv_usec % 1000) // round up to next millisecond | ||
| millis++; | ||
| } | ||
|
|
||
| return usbi_cond_intwait(cond, mutex, millis); | ||
| } | ||
|
|
||
| int usbi_get_tid(void) { | ||
| return GetCurrentThreadId(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * libusbx synchronization on Microsoft Windows | ||
| * | ||
| * Copyright © 2010 Michael Plante <michael.plante@gmail.com> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| #ifndef LIBUSB_THREADS_WINDOWS_H | ||
| #define LIBUSB_THREADS_WINDOWS_H | ||
|
|
||
| #define usbi_mutex_static_t volatile LONG | ||
| #define USBI_MUTEX_INITIALIZER 0 | ||
|
|
||
| #define usbi_mutex_t HANDLE | ||
|
|
||
| struct usbi_cond_perthread { | ||
| struct list_head list; | ||
| DWORD tid; | ||
| HANDLE event; | ||
| }; | ||
| struct usbi_cond_t_ { | ||
| // Every time a thread touches the CV, it winds up in one of these lists. | ||
| // It stays there until the CV is destroyed, even if the thread | ||
| // terminates. | ||
| struct list_head waiters; | ||
| struct list_head not_waiting; | ||
| }; | ||
| typedef struct usbi_cond_t_ usbi_cond_t; | ||
|
|
||
| // We *were* getting timespec from pthread.h: | ||
| #if (!defined(HAVE_STRUCT_TIMESPEC) && !defined(_TIMESPEC_DEFINED)) | ||
| #define HAVE_STRUCT_TIMESPEC 1 | ||
| #define _TIMESPEC_DEFINED 1 | ||
| struct timespec { | ||
| long tv_sec; | ||
| long tv_nsec; | ||
| }; | ||
| #endif /* HAVE_STRUCT_TIMESPEC | _TIMESPEC_DEFINED */ | ||
|
|
||
| // We *were* getting ETIMEDOUT from pthread.h: | ||
| #ifndef ETIMEDOUT | ||
| # define ETIMEDOUT 10060 /* This is the value in winsock.h. */ | ||
| #endif | ||
|
|
||
| #define usbi_mutexattr_t void | ||
| #define usbi_condattr_t void | ||
|
|
||
| // all Windows mutexes are recursive | ||
| #define usbi_mutex_init_recursive(mutex, attr) usbi_mutex_init((mutex), (attr)) | ||
|
|
||
| int usbi_mutex_static_lock(usbi_mutex_static_t *mutex); | ||
| int usbi_mutex_static_unlock(usbi_mutex_static_t *mutex); | ||
|
|
||
|
|
||
| int usbi_mutex_init(usbi_mutex_t *mutex, | ||
| const usbi_mutexattr_t *attr); | ||
| int usbi_mutex_lock(usbi_mutex_t *mutex); | ||
| int usbi_mutex_unlock(usbi_mutex_t *mutex); | ||
| int usbi_mutex_trylock(usbi_mutex_t *mutex); | ||
| int usbi_mutex_destroy(usbi_mutex_t *mutex); | ||
|
|
||
| int usbi_cond_init(usbi_cond_t *cond, | ||
| const usbi_condattr_t *attr); | ||
| int usbi_cond_destroy(usbi_cond_t *cond); | ||
| int usbi_cond_wait(usbi_cond_t *cond, usbi_mutex_t *mutex); | ||
| int usbi_cond_timedwait(usbi_cond_t *cond, | ||
| usbi_mutex_t *mutex, | ||
| const struct timespec *abstime); | ||
| int usbi_cond_broadcast(usbi_cond_t *cond); | ||
| int usbi_cond_signal(usbi_cond_t *cond); | ||
|
|
||
| int usbi_get_tid(void); | ||
|
|
||
| #endif /* LIBUSB_THREADS_WINDOWS_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| /* | ||
| * Windows CE backend for libusbx 1.0 | ||
| * Copyright © 2011-2013 RealVNC Ltd. | ||
| * Portions taken from Windows backend, which is | ||
| * Copyright © 2009-2010 Pete Batard <pbatard@gmail.com> | ||
| * With contributions from Michael Plante, Orin Eman et al. | ||
| * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer | ||
| * Major code testing contribution by Xiaofan Chen | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include "windows_common.h" | ||
|
|
||
| #include <windows.h> | ||
| #include "poll_windows.h" | ||
|
|
||
| #define MAX_DEVICE_COUNT 256 | ||
|
|
||
| // This is a modified dump of the types in the ceusbkwrapper.h library header | ||
| // with functions transformed into extern pointers. | ||
| // | ||
| // This backend dynamically loads ceusbkwrapper.dll and doesn't include | ||
| // ceusbkwrapper.h directly to simplify the build process. The kernel | ||
| // side wrapper driver is built using the platform image build tools, | ||
| // which makes it difficult to reference directly from the libusbx build | ||
| // system. | ||
| struct UKW_DEVICE_PRIV; | ||
| typedef struct UKW_DEVICE_PRIV *UKW_DEVICE; | ||
| typedef UKW_DEVICE *PUKW_DEVICE, *LPUKW_DEVICE; | ||
|
|
||
| typedef struct { | ||
| UINT8 bLength; | ||
| UINT8 bDescriptorType; | ||
| UINT16 bcdUSB; | ||
| UINT8 bDeviceClass; | ||
| UINT8 bDeviceSubClass; | ||
| UINT8 bDeviceProtocol; | ||
| UINT8 bMaxPacketSize0; | ||
| UINT16 idVendor; | ||
| UINT16 idProduct; | ||
| UINT16 bcdDevice; | ||
| UINT8 iManufacturer; | ||
| UINT8 iProduct; | ||
| UINT8 iSerialNumber; | ||
| UINT8 bNumConfigurations; | ||
| } UKW_DEVICE_DESCRIPTOR, *PUKW_DEVICE_DESCRIPTOR, *LPUKW_DEVICE_DESCRIPTOR; | ||
|
|
||
| typedef struct { | ||
| UINT8 bmRequestType; | ||
| UINT8 bRequest; | ||
| UINT16 wValue; | ||
| UINT16 wIndex; | ||
| UINT16 wLength; | ||
| } UKW_CONTROL_HEADER, *PUKW_CONTROL_HEADER, *LPUKW_CONTROL_HEADER; | ||
|
|
||
| // Collection of flags which can be used when issuing transfer requests | ||
| /* Indicates that the transfer direction is 'in' */ | ||
| #define UKW_TF_IN_TRANSFER 0x00000001 | ||
| /* Indicates that the transfer direction is 'out' */ | ||
| #define UKW_TF_OUT_TRANSFER 0x00000000 | ||
| /* Specifies that the transfer should complete as soon as possible, | ||
| * even if no OVERLAPPED structure has been provided. */ | ||
| #define UKW_TF_NO_WAIT 0x00000100 | ||
| /* Indicates that transfers shorter than the buffer are ok */ | ||
| #define UKW_TF_SHORT_TRANSFER_OK 0x00000200 | ||
| #define UKW_TF_SEND_TO_DEVICE 0x00010000 | ||
| #define UKW_TF_SEND_TO_INTERFACE 0x00020000 | ||
| #define UKW_TF_SEND_TO_ENDPOINT 0x00040000 | ||
| /* Don't block when waiting for memory allocations */ | ||
| #define UKW_TF_DONT_BLOCK_FOR_MEM 0x00080000 | ||
|
|
||
| /* Value to use when dealing with configuration values, such as UkwGetConfigDescriptor, | ||
| * to specify the currently active configuration for the device. */ | ||
| #define UKW_ACTIVE_CONFIGURATION -1 | ||
|
|
||
| DLL_DECLARE(WINAPI, HANDLE, UkwOpenDriver, ()); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwGetDeviceList, (HANDLE, LPUKW_DEVICE, DWORD, LPDWORD)); | ||
| DLL_DECLARE(WINAPI, void, UkwReleaseDeviceList, (HANDLE, LPUKW_DEVICE, DWORD)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwGetDeviceAddress, (UKW_DEVICE, unsigned char*, unsigned char*, unsigned long*)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwGetDeviceDescriptor, (UKW_DEVICE, LPUKW_DEVICE_DESCRIPTOR)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwGetConfigDescriptor, (UKW_DEVICE, DWORD, LPVOID, DWORD, LPDWORD)); | ||
| DLL_DECLARE(WINAPI, void, UkwCloseDriver, (HANDLE)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwCancelTransfer, (UKW_DEVICE, LPOVERLAPPED, DWORD)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwIssueControlTransfer, (UKW_DEVICE, DWORD, LPUKW_CONTROL_HEADER, LPVOID, DWORD, LPDWORD, LPOVERLAPPED)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwClaimInterface, (UKW_DEVICE, DWORD)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwReleaseInterface, (UKW_DEVICE, DWORD)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwSetInterfaceAlternateSetting, (UKW_DEVICE, DWORD, DWORD)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwClearHaltHost, (UKW_DEVICE, UCHAR)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwClearHaltDevice, (UKW_DEVICE, UCHAR)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwGetConfig, (UKW_DEVICE, PUCHAR)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwSetConfig, (UKW_DEVICE, UCHAR)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwResetDevice, (UKW_DEVICE)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwKernelDriverActive, (UKW_DEVICE, DWORD, PBOOL)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwAttachKernelDriver, (UKW_DEVICE, DWORD)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwDetachKernelDriver, (UKW_DEVICE, DWORD)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwIssueBulkTransfer, (UKW_DEVICE, DWORD, UCHAR, LPVOID, DWORD, LPDWORD, LPOVERLAPPED)); | ||
| DLL_DECLARE(WINAPI, BOOL, UkwIsPipeHalted, (UKW_DEVICE, UCHAR, LPBOOL)); | ||
|
|
||
| // Used to determine if an endpoint status really is halted on a failed transfer. | ||
| #define STATUS_HALT_FLAG 0x1 | ||
|
|
||
| struct wince_device_priv { | ||
| UKW_DEVICE dev; | ||
| UKW_DEVICE_DESCRIPTOR desc; | ||
| }; | ||
|
|
||
| struct wince_device_handle_priv { | ||
| // This member isn't used, but only exists to avoid an empty structure | ||
| // for private data for the device handle. | ||
| int reserved; | ||
| }; | ||
|
|
||
| struct wince_transfer_priv { | ||
| struct winfd pollable_fd; | ||
| uint8_t interface_number; | ||
| }; | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /* | ||
| * Windows backend common header for libusbx 1.0 | ||
| * | ||
| * This file brings together header code common between | ||
| * the desktop Windows and Windows CE backends. | ||
| * Copyright © 2012-2013 RealVNC Ltd. | ||
| * Copyright © 2009-2012 Pete Batard <pete@akeo.ie> | ||
| * With contributions from Michael Plante, Orin Eman et al. | ||
| * Parts of this code adapted from libusb-win32-v1 by Stephan Meyer | ||
| * Major code testing contribution by Xiaofan Chen | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| // Windows API default is uppercase - ugh! | ||
| #if !defined(bool) | ||
| #define bool BOOL | ||
| #endif | ||
| #if !defined(true) | ||
| #define true TRUE | ||
| #endif | ||
| #if !defined(false) | ||
| #define false FALSE | ||
| #endif | ||
|
|
||
| #define safe_free(p) do {if (p != NULL) {free((void*)p); p = NULL;}} while(0) | ||
| #define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0) | ||
| #define safe_min(a, b) min((size_t)(a), (size_t)(b)) | ||
| #define safe_strcp(dst, dst_max, src, count) do {memcpy(dst, src, safe_min(count, dst_max)); \ | ||
| ((char*)dst)[safe_min(count, dst_max)-1] = 0;} while(0) | ||
| #define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1) | ||
| #define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, dst_max - safe_strlen(dst) - 1)) | ||
| #define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1) | ||
| #define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2)) | ||
| #define safe_stricmp(str1, str2) _stricmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2)) | ||
| #define safe_strncmp(str1, str2, count) strncmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count) | ||
| #define safe_strlen(str) ((str==NULL)?0:strlen(str)) | ||
| #define safe_sprintf(dst, count, ...) do {_snprintf(dst, count, __VA_ARGS__); (dst)[(count)-1] = 0; } while(0) | ||
| #define safe_stprintf _sntprintf | ||
| #define safe_tcslen(str) ((str==NULL)?0:_tcslen(str)) | ||
| #define safe_unref_device(dev) do {if (dev != NULL) {libusb_unref_device(dev); dev = NULL;}} while(0) | ||
| #define wchar_to_utf8_ms(wstr, str, strlen) WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, strlen, NULL, NULL) | ||
| #ifndef ARRAYSIZE | ||
| #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) | ||
| #endif | ||
|
|
||
| #define ERR_BUFFER_SIZE 256 | ||
| #define TIMER_REQUEST_RETRY_MS 100 | ||
| #define MAX_TIMER_SEMAPHORES 128 | ||
|
|
||
|
|
||
| /* | ||
| * API macros - from libusb-win32 1.x | ||
| */ | ||
| #define DLL_DECLARE_PREFIXNAME(api, ret, prefixname, name, args) \ | ||
| typedef ret (api * __dll_##name##_t)args; \ | ||
| static __dll_##name##_t prefixname = NULL | ||
|
|
||
| #ifndef _WIN32_WCE | ||
| #define DLL_STRINGIFY(dll) #dll | ||
| #define DLL_GET_MODULE_HANDLE(dll) GetModuleHandleA(DLL_STRINGIFY(dll)) | ||
| #define DLL_LOAD_LIBRARY(dll) LoadLibraryA(DLL_STRINGIFY(dll)) | ||
| #else | ||
| #define DLL_STRINGIFY(dll) L#dll | ||
| #define DLL_GET_MODULE_HANDLE(dll) GetModuleHandle(DLL_STRINGIFY(dll)) | ||
| #define DLL_LOAD_LIBRARY(dll) LoadLibrary(DLL_STRINGIFY(dll)) | ||
| #endif | ||
|
|
||
| #define DLL_LOAD_PREFIXNAME(dll, prefixname, name, ret_on_failure) \ | ||
| do { \ | ||
| HMODULE h = DLL_GET_MODULE_HANDLE(dll); \ | ||
| if (!h) \ | ||
| h = DLL_LOAD_LIBRARY(dll); \ | ||
| if (!h) { \ | ||
| if (ret_on_failure) { return LIBUSB_ERROR_NOT_FOUND; } \ | ||
| else { break; } \ | ||
| } \ | ||
| prefixname = (__dll_##name##_t)GetProcAddress(h, \ | ||
| DLL_STRINGIFY(name)); \ | ||
| if (prefixname) break; \ | ||
| prefixname = (__dll_##name##_t)GetProcAddress(h, \ | ||
| DLL_STRINGIFY(name) DLL_STRINGIFY(A)); \ | ||
| if (prefixname) break; \ | ||
| prefixname = (__dll_##name##_t)GetProcAddress(h, \ | ||
| DLL_STRINGIFY(name) DLL_STRINGIFY(W)); \ | ||
| if (prefixname) break; \ | ||
| if(ret_on_failure) \ | ||
| return LIBUSB_ERROR_NOT_FOUND; \ | ||
| } while(0) | ||
|
|
||
| #define DLL_DECLARE(api, ret, name, args) DLL_DECLARE_PREFIXNAME(api, ret, name, name, args) | ||
| #define DLL_LOAD(dll, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll, name, name, ret_on_failure) | ||
| #define DLL_DECLARE_PREFIXED(api, ret, prefix, name, args) DLL_DECLARE_PREFIXNAME(api, ret, prefix##name, name, args) | ||
| #define DLL_LOAD_PREFIXED(dll, prefix, name, ret_on_failure) DLL_LOAD_PREFIXNAME(dll, prefix##name, name, ret_on_failure) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| /* | ||
| * libusb strerror code | ||
| * Copyright © 2013 Hans de Goede <hdegoede@redhat.com> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
| #include "config.h" | ||
|
|
||
| #include <locale.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
|
|
||
| #include "libusb.h" | ||
| #include "libusbi.h" | ||
|
|
||
| #if defined(_MSC_VER) | ||
| #define strncasecmp _strnicmp | ||
| #endif | ||
|
|
||
| static size_t usbi_locale = 0; | ||
|
|
||
| /** \ingroup misc | ||
| * How to add a new \ref libusb_strerror() translation: | ||
| * <ol> | ||
| * <li> Download the latest \c strerror.c from:<br> | ||
| * https://raw.github.com/libusbx/libusbx/master/libusb/sterror.c </li> | ||
| * <li> Open the file in an UTF-8 capable editor </li> | ||
| * <li> Add the 2 letter <a href="http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes">ISO 639-1</a> | ||
| * code for your locale at the end of \c usbi_locale_supported[]<br> | ||
| * Eg. for Chinese, you would add "zh" so that: | ||
| * \code... usbi_locale_supported[] = { "en", "nl", "fr" };\endcode | ||
| * becomes: | ||
| * \code... usbi_locale_supported[] = { "en", "nl", "fr", "zh" };\endcode </li> | ||
| * <li> Copy the <tt>{ / * English (en) * / ... }</tt> section and add it at the end of \c usbi_localized_errors<br> | ||
| * Eg. for Chinese, the last section of \c usbi_localized_errors could look like: | ||
| * \code | ||
| * }, { / * Chinese (zh) * / | ||
| * "Success", | ||
| * ... | ||
| * "Other error", | ||
| * } | ||
| * };\endcode </li> | ||
| * <li> Translate each of the English messages from the section you copied into your language </li> | ||
| * <li> Save the file (in UTF-8 format) and send it to \c libusbx-devel@lists.sourceforge.net </li> | ||
| * </ol> | ||
| */ | ||
|
|
||
| static const char* usbi_locale_supported[] = { "en", "nl", "fr" }; | ||
| static const char* usbi_localized_errors[ARRAYSIZE(usbi_locale_supported)][LIBUSB_ERROR_COUNT] = { | ||
| { /* English (en) */ | ||
| "Success", | ||
| "Input/Output Error", | ||
| "Invalid parameter", | ||
| "Access denied (insufficient permissions)", | ||
| "No such device (it may have been disconnected)", | ||
| "Entity not found", | ||
| "Resource busy", | ||
| "Operation timed out", | ||
| "Overflow", | ||
| "Pipe error", | ||
| "System call interrupted (perhaps due to signal)", | ||
| "Insufficient memory", | ||
| "Operation not supported or unimplemented on this platform", | ||
| "Other error", | ||
| }, { /* Dutch (nl) */ | ||
| "Gelukt", | ||
| "Invoer-/uitvoerfout", | ||
| "Ongeldig argument", | ||
| "Toegang geweigerd (onvoldoende toegangsrechten)", | ||
| "Apparaat bestaat niet (verbinding met apparaat verbroken?)", | ||
| "Niet gevonden", | ||
| "Apparaat of hulpbron is bezig", | ||
| "Bewerking verlopen", | ||
| "Waarde is te groot", | ||
| "Gebroken pijp", | ||
| "Onderbroken systeemaanroep", | ||
| "Onvoldoende geheugen beschikbaar", | ||
| "Bewerking wordt niet ondersteund", | ||
| "Andere fout", | ||
| }, { /* French (fr) */ | ||
| "Succès", | ||
| "Erreur d'entrée/sortie", | ||
| "Paramètre invalide", | ||
| "Accès refusé (permissions insuffisantes)", | ||
| "Périphérique introuvable (peut-être déconnecté)", | ||
| "Elément introuvable", | ||
| "Resource déjà occupée", | ||
| "Operation expirée", | ||
| "Débordement", | ||
| "Erreur de pipe", | ||
| "Appel système abandonné (peut-être à cause d’un signal)", | ||
| "Mémoire insuffisante", | ||
| "Opération non supportée or non implémentée sur cette plateforme", | ||
| "Autre erreur" | ||
| } | ||
| }; | ||
|
|
||
| /** \ingroup misc | ||
| * Set the language, and only the language, not the encoding! used for | ||
| * translatable libusb messages. | ||
| * | ||
| * This takes a locale string in the default setlocale format: lang[-region] | ||
| * or lang[_country_region][.codeset]. Only the lang part of the string is | ||
| * used, and only 2 letter ISO 639-1 codes are accepted for it, such as "de". | ||
| * The optional region, country_region or codeset parts are ignored. This | ||
| * means that functions which return translatable strings will NOT honor the | ||
| * specified encoding. | ||
| * All strings returned are encoded as UTF-8 strings. | ||
| * | ||
| * If libusb_setlocale() is not called, all messages will be in English. | ||
| * | ||
| * The following functions return translatable strings: libusb_strerror(). | ||
| * Note that the libusb log messages controlled through libusb_set_debug() | ||
| * are not translated, they are always in English. | ||
| * | ||
| * For POSIX UTF-8 environments if you want libusb to follow the standard | ||
| * locale settings, call libusb_setlocale(setlocale(LC_MESSAGES, NULL)), | ||
| * after your app has done its locale setup. | ||
| * | ||
| * \param locale locale-string in the form of lang[_country_region][.codeset] | ||
| * or lang[-region], where lang is a 2 letter ISO 639-1 code | ||
| * \returns LIBUSB_SUCCESS on success | ||
| * \returns LIBUSB_ERROR_INVALID_PARAM if the locale doesn't meet the requirements | ||
| * \returns LIBUSB_ERROR_NOT_FOUND if the requested language is not supported | ||
| * \returns a LIBUSB_ERROR code on other errors | ||
| */ | ||
|
|
||
| int API_EXPORTED libusb_setlocale(const char *locale) | ||
| { | ||
| size_t i; | ||
|
|
||
| if ( (locale == NULL) || (strlen(locale) < 2) | ||
| || ((strlen(locale) > 2) && (locale[2] != '-') && (locale[2] != '_') && (locale[2] != '.')) ) | ||
| return LIBUSB_ERROR_INVALID_PARAM; | ||
|
|
||
| for (i=0; i<ARRAYSIZE(usbi_locale_supported); i++) { | ||
| if (strncasecmp(usbi_locale_supported[i], locale, 2) == 0) | ||
| break; | ||
| } | ||
| if (i >= ARRAYSIZE(usbi_locale_supported)) { | ||
| return LIBUSB_ERROR_NOT_FOUND; | ||
| } | ||
|
|
||
| usbi_locale = i; | ||
|
|
||
| return LIBUSB_SUCCESS; | ||
| } | ||
|
|
||
| /** \ingroup misc | ||
| * Returns a constant string with a short description of the given error code, | ||
| * this description is intended for displaying to the end user and will be in | ||
| * the language set by libusb_setlocale(). | ||
| * | ||
| * The returned string is encoded in UTF-8. | ||
| * | ||
| * The messages always start with a capital letter and end without any dot. | ||
| * The caller must not free() the returned string. | ||
| * | ||
| * \param errcode the error code whose description is desired | ||
| * \returns a short description of the error code in UTF-8 encoding | ||
| */ | ||
| DEFAULT_VISIBILITY const char* LIBUSB_CALL libusb_strerror(enum libusb_error errcode) | ||
| { | ||
| int errcode_index = -errcode; | ||
|
|
||
| if ((errcode_index < 0) || (errcode_index >= LIBUSB_ERROR_COUNT)) { | ||
| /* "Other Error", which should always be our last message, is returned */ | ||
| errcode_index = LIBUSB_ERROR_COUNT - 1; | ||
| } | ||
|
|
||
| return usbi_localized_errors[usbi_locale][errcode_index]; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,307 @@ | ||
| /* | ||
| * Synchronous I/O functions for libusbx | ||
| * Copyright © 2007-2008 Daniel Drake <dsd@gentoo.org> | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| #include "config.h" | ||
| #include <errno.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
|
|
||
| #include "libusbi.h" | ||
|
|
||
| /** | ||
| * @defgroup syncio Synchronous device I/O | ||
| * | ||
| * This page documents libusbx's synchronous (blocking) API for USB device I/O. | ||
| * This interface is easy to use but has some limitations. More advanced users | ||
| * may wish to consider using the \ref asyncio "asynchronous I/O API" instead. | ||
| */ | ||
|
|
||
| static void LIBUSB_CALL sync_transfer_cb(struct libusb_transfer *transfer) | ||
| { | ||
| int *completed = transfer->user_data; | ||
| *completed = 1; | ||
| usbi_dbg("actual_length=%d", transfer->actual_length); | ||
| /* caller interprets result and frees transfer */ | ||
| } | ||
|
|
||
| static void sync_transfer_wait_for_completion(struct libusb_transfer *transfer) | ||
| { | ||
| int r, *completed = transfer->user_data; | ||
| struct libusb_context *ctx = HANDLE_CTX(transfer->dev_handle); | ||
|
|
||
| while (!*completed) { | ||
| r = libusb_handle_events_completed(ctx, completed); | ||
| if (r < 0) { | ||
| if (r == LIBUSB_ERROR_INTERRUPTED) | ||
| continue; | ||
| usbi_err(ctx, "libusb_handle_events failed: %s, cancelling transfer and retrying", | ||
| libusb_error_name(r)); | ||
| libusb_cancel_transfer(transfer); | ||
| continue; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** \ingroup syncio | ||
| * Perform a USB control transfer. | ||
| * | ||
| * The direction of the transfer is inferred from the bmRequestType field of | ||
| * the setup packet. | ||
| * | ||
| * The wValue, wIndex and wLength fields values should be given in host-endian | ||
| * byte order. | ||
| * | ||
| * \param dev_handle a handle for the device to communicate with | ||
| * \param bmRequestType the request type field for the setup packet | ||
| * \param bRequest the request field for the setup packet | ||
| * \param wValue the value field for the setup packet | ||
| * \param wIndex the index field for the setup packet | ||
| * \param data a suitably-sized data buffer for either input or output | ||
| * (depending on direction bits within bmRequestType) | ||
| * \param wLength the length field for the setup packet. The data buffer should | ||
| * be at least this size. | ||
| * \param timeout timeout (in millseconds) that this function should wait | ||
| * before giving up due to no response being received. For an unlimited | ||
| * timeout, use value 0. | ||
| * \returns on success, the number of bytes actually transferred | ||
| * \returns LIBUSB_ERROR_TIMEOUT if the transfer timed out | ||
| * \returns LIBUSB_ERROR_PIPE if the control request was not supported by the | ||
| * device | ||
| * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected | ||
| * \returns another LIBUSB_ERROR code on other failures | ||
| */ | ||
| int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle, | ||
| uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, | ||
| unsigned char *data, uint16_t wLength, unsigned int timeout) | ||
| { | ||
| struct libusb_transfer *transfer = libusb_alloc_transfer(0); | ||
| unsigned char *buffer; | ||
| int completed = 0; | ||
| int r; | ||
|
|
||
| if (!transfer) | ||
| return LIBUSB_ERROR_NO_MEM; | ||
|
|
||
| buffer = (unsigned char*) malloc(LIBUSB_CONTROL_SETUP_SIZE + wLength); | ||
| if (!buffer) { | ||
| libusb_free_transfer(transfer); | ||
| return LIBUSB_ERROR_NO_MEM; | ||
| } | ||
|
|
||
| libusb_fill_control_setup(buffer, bmRequestType, bRequest, wValue, wIndex, | ||
| wLength); | ||
| if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT) | ||
| memcpy(buffer + LIBUSB_CONTROL_SETUP_SIZE, data, wLength); | ||
|
|
||
| libusb_fill_control_transfer(transfer, dev_handle, buffer, | ||
| sync_transfer_cb, &completed, timeout); | ||
| transfer->flags = LIBUSB_TRANSFER_FREE_BUFFER; | ||
| r = libusb_submit_transfer(transfer); | ||
| if (r < 0) { | ||
| libusb_free_transfer(transfer); | ||
| return r; | ||
| } | ||
|
|
||
| sync_transfer_wait_for_completion(transfer); | ||
|
|
||
| if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN) | ||
| memcpy(data, libusb_control_transfer_get_data(transfer), | ||
| transfer->actual_length); | ||
|
|
||
| switch (transfer->status) { | ||
| case LIBUSB_TRANSFER_COMPLETED: | ||
| r = transfer->actual_length; | ||
| break; | ||
| case LIBUSB_TRANSFER_TIMED_OUT: | ||
| r = LIBUSB_ERROR_TIMEOUT; | ||
| break; | ||
| case LIBUSB_TRANSFER_STALL: | ||
| r = LIBUSB_ERROR_PIPE; | ||
| break; | ||
| case LIBUSB_TRANSFER_NO_DEVICE: | ||
| r = LIBUSB_ERROR_NO_DEVICE; | ||
| break; | ||
| case LIBUSB_TRANSFER_OVERFLOW: | ||
| r = LIBUSB_ERROR_OVERFLOW; | ||
| break; | ||
| case LIBUSB_TRANSFER_ERROR: | ||
| case LIBUSB_TRANSFER_CANCELLED: | ||
| r = LIBUSB_ERROR_IO; | ||
| break; | ||
| default: | ||
| usbi_warn(HANDLE_CTX(dev_handle), | ||
| "unrecognised status code %d", transfer->status); | ||
| r = LIBUSB_ERROR_OTHER; | ||
| } | ||
|
|
||
| libusb_free_transfer(transfer); | ||
| return r; | ||
| } | ||
|
|
||
| static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle, | ||
| unsigned char endpoint, unsigned char *buffer, int length, | ||
| int *transferred, unsigned int timeout, unsigned char type) | ||
| { | ||
| struct libusb_transfer *transfer = libusb_alloc_transfer(0); | ||
| int completed = 0; | ||
| int r; | ||
|
|
||
| if (!transfer) | ||
| return LIBUSB_ERROR_NO_MEM; | ||
|
|
||
| libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer, length, | ||
| sync_transfer_cb, &completed, timeout); | ||
| transfer->type = type; | ||
|
|
||
| r = libusb_submit_transfer(transfer); | ||
| if (r < 0) { | ||
| libusb_free_transfer(transfer); | ||
| return r; | ||
| } | ||
|
|
||
| sync_transfer_wait_for_completion(transfer); | ||
|
|
||
| *transferred = transfer->actual_length; | ||
| switch (transfer->status) { | ||
| case LIBUSB_TRANSFER_COMPLETED: | ||
| r = 0; | ||
| break; | ||
| case LIBUSB_TRANSFER_TIMED_OUT: | ||
| r = LIBUSB_ERROR_TIMEOUT; | ||
| break; | ||
| case LIBUSB_TRANSFER_STALL: | ||
| r = LIBUSB_ERROR_PIPE; | ||
| break; | ||
| case LIBUSB_TRANSFER_OVERFLOW: | ||
| r = LIBUSB_ERROR_OVERFLOW; | ||
| break; | ||
| case LIBUSB_TRANSFER_NO_DEVICE: | ||
| r = LIBUSB_ERROR_NO_DEVICE; | ||
| break; | ||
| case LIBUSB_TRANSFER_ERROR: | ||
| case LIBUSB_TRANSFER_CANCELLED: | ||
| r = LIBUSB_ERROR_IO; | ||
| break; | ||
| default: | ||
| usbi_warn(HANDLE_CTX(dev_handle), | ||
| "unrecognised status code %d", transfer->status); | ||
| r = LIBUSB_ERROR_OTHER; | ||
| } | ||
|
|
||
| libusb_free_transfer(transfer); | ||
| return r; | ||
| } | ||
|
|
||
| /** \ingroup syncio | ||
| * Perform a USB bulk transfer. The direction of the transfer is inferred from | ||
| * the direction bits of the endpoint address. | ||
| * | ||
| * For bulk reads, the <tt>length</tt> field indicates the maximum length of | ||
| * data you are expecting to receive. If less data arrives than expected, | ||
| * this function will return that data, so be sure to check the | ||
| * <tt>transferred</tt> output parameter. | ||
| * | ||
| * You should also check the <tt>transferred</tt> parameter for bulk writes. | ||
| * Not all of the data may have been written. | ||
| * | ||
| * Also check <tt>transferred</tt> when dealing with a timeout error code. | ||
| * libusbx may have to split your transfer into a number of chunks to satisfy | ||
| * underlying O/S requirements, meaning that the timeout may expire after | ||
| * the first few chunks have completed. libusbx is careful not to lose any data | ||
| * that may have been transferred; do not assume that timeout conditions | ||
| * indicate a complete lack of I/O. | ||
| * | ||
| * \param dev_handle a handle for the device to communicate with | ||
| * \param endpoint the address of a valid endpoint to communicate with | ||
| * \param data a suitably-sized data buffer for either input or output | ||
| * (depending on endpoint) | ||
| * \param length for bulk writes, the number of bytes from data to be sent. for | ||
| * bulk reads, the maximum number of bytes to receive into the data buffer. | ||
| * \param transferred output location for the number of bytes actually | ||
| * transferred. | ||
| * \param timeout timeout (in millseconds) that this function should wait | ||
| * before giving up due to no response being received. For an unlimited | ||
| * timeout, use value 0. | ||
| * | ||
| * \returns 0 on success (and populates <tt>transferred</tt>) | ||
| * \returns LIBUSB_ERROR_TIMEOUT if the transfer timed out (and populates | ||
| * <tt>transferred</tt>) | ||
| * \returns LIBUSB_ERROR_PIPE if the endpoint halted | ||
| * \returns LIBUSB_ERROR_OVERFLOW if the device offered more data, see | ||
| * \ref packetoverflow | ||
| * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected | ||
| * \returns another LIBUSB_ERROR code on other failures | ||
| */ | ||
| int API_EXPORTED libusb_bulk_transfer(struct libusb_device_handle *dev_handle, | ||
| unsigned char endpoint, unsigned char *data, int length, int *transferred, | ||
| unsigned int timeout) | ||
| { | ||
| return do_sync_bulk_transfer(dev_handle, endpoint, data, length, | ||
| transferred, timeout, LIBUSB_TRANSFER_TYPE_BULK); | ||
| } | ||
|
|
||
| /** \ingroup syncio | ||
| * Perform a USB interrupt transfer. The direction of the transfer is inferred | ||
| * from the direction bits of the endpoint address. | ||
| * | ||
| * For interrupt reads, the <tt>length</tt> field indicates the maximum length | ||
| * of data you are expecting to receive. If less data arrives than expected, | ||
| * this function will return that data, so be sure to check the | ||
| * <tt>transferred</tt> output parameter. | ||
| * | ||
| * You should also check the <tt>transferred</tt> parameter for interrupt | ||
| * writes. Not all of the data may have been written. | ||
| * | ||
| * Also check <tt>transferred</tt> when dealing with a timeout error code. | ||
| * libusbx may have to split your transfer into a number of chunks to satisfy | ||
| * underlying O/S requirements, meaning that the timeout may expire after | ||
| * the first few chunks have completed. libusbx is careful not to lose any data | ||
| * that may have been transferred; do not assume that timeout conditions | ||
| * indicate a complete lack of I/O. | ||
| * | ||
| * The default endpoint bInterval value is used as the polling interval. | ||
| * | ||
| * \param dev_handle a handle for the device to communicate with | ||
| * \param endpoint the address of a valid endpoint to communicate with | ||
| * \param data a suitably-sized data buffer for either input or output | ||
| * (depending on endpoint) | ||
| * \param length for bulk writes, the number of bytes from data to be sent. for | ||
| * bulk reads, the maximum number of bytes to receive into the data buffer. | ||
| * \param transferred output location for the number of bytes actually | ||
| * transferred. | ||
| * \param timeout timeout (in millseconds) that this function should wait | ||
| * before giving up due to no response being received. For an unlimited | ||
| * timeout, use value 0. | ||
| * | ||
| * \returns 0 on success (and populates <tt>transferred</tt>) | ||
| * \returns LIBUSB_ERROR_TIMEOUT if the transfer timed out | ||
| * \returns LIBUSB_ERROR_PIPE if the endpoint halted | ||
| * \returns LIBUSB_ERROR_OVERFLOW if the device offered more data, see | ||
| * \ref packetoverflow | ||
| * \returns LIBUSB_ERROR_NO_DEVICE if the device has been disconnected | ||
| * \returns another LIBUSB_ERROR code on other error | ||
| */ | ||
| int API_EXPORTED libusb_interrupt_transfer( | ||
| struct libusb_device_handle *dev_handle, unsigned char endpoint, | ||
| unsigned char *data, int length, int *transferred, unsigned int timeout) | ||
| { | ||
| return do_sync_bulk_transfer(dev_handle, endpoint, data, length, | ||
| transferred, timeout, LIBUSB_TRANSFER_TYPE_INTERRUPT); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* This file is parsed by m4 and windres and RC.EXE so please keep it simple. */ | ||
| #include "version_nano.h" | ||
| #ifndef LIBUSB_MAJOR | ||
| #define LIBUSB_MAJOR 1 | ||
| #endif | ||
| #ifndef LIBUSB_MINOR | ||
| #define LIBUSB_MINOR 0 | ||
| #endif | ||
| #ifndef LIBUSB_MICRO | ||
| #define LIBUSB_MICRO 16 | ||
| #endif | ||
| #ifndef LIBUSB_NANO | ||
| #define LIBUSB_NANO 0 | ||
| #endif | ||
| /* LIBUSB_RC is the release candidate suffix. Should normally be empty. */ | ||
| #ifndef LIBUSB_RC | ||
| #define LIBUSB_RC "" | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #define LIBUSB_NANO 10774 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,384 @@ | ||
| # Helper functions for option handling. -*- Autoconf -*- | ||
| # | ||
| # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, | ||
| # Inc. | ||
| # Written by Gary V. Vaughan, 2004 | ||
| # | ||
| # This file is free software; the Free Software Foundation gives | ||
| # unlimited permission to copy and/or distribute it, with or without | ||
| # modifications, as long as this notice is preserved. | ||
|
|
||
| # serial 7 ltoptions.m4 | ||
|
|
||
| # This is to help aclocal find these macros, as it can't see m4_define. | ||
| AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) | ||
|
|
||
|
|
||
| # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) | ||
| # ------------------------------------------ | ||
| m4_define([_LT_MANGLE_OPTION], | ||
| [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) | ||
|
|
||
|
|
||
| # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) | ||
| # --------------------------------------- | ||
| # Set option OPTION-NAME for macro MACRO-NAME, and if there is a | ||
| # matching handler defined, dispatch to it. Other OPTION-NAMEs are | ||
| # saved as a flag. | ||
| m4_define([_LT_SET_OPTION], | ||
| [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl | ||
| m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), | ||
| _LT_MANGLE_DEFUN([$1], [$2]), | ||
| [m4_warning([Unknown $1 option `$2'])])[]dnl | ||
| ]) | ||
|
|
||
|
|
||
| # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) | ||
| # ------------------------------------------------------------ | ||
| # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. | ||
| m4_define([_LT_IF_OPTION], | ||
| [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) | ||
|
|
||
|
|
||
| # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) | ||
| # ------------------------------------------------------- | ||
| # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME | ||
| # are set. | ||
| m4_define([_LT_UNLESS_OPTIONS], | ||
| [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), | ||
| [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), | ||
| [m4_define([$0_found])])])[]dnl | ||
| m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 | ||
| ])[]dnl | ||
| ]) | ||
|
|
||
|
|
||
| # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) | ||
| # ---------------------------------------- | ||
| # OPTION-LIST is a space-separated list of Libtool options associated | ||
| # with MACRO-NAME. If any OPTION has a matching handler declared with | ||
| # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about | ||
| # the unknown option and exit. | ||
| m4_defun([_LT_SET_OPTIONS], | ||
| [# Set options | ||
| m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), | ||
| [_LT_SET_OPTION([$1], _LT_Option)]) | ||
| m4_if([$1],[LT_INIT],[ | ||
| dnl | ||
| dnl Simply set some default values (i.e off) if boolean options were not | ||
| dnl specified: | ||
| _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no | ||
| ]) | ||
| _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no | ||
| ]) | ||
| dnl | ||
| dnl If no reference was made to various pairs of opposing options, then | ||
| dnl we run the default mode handler for the pair. For example, if neither | ||
| dnl `shared' nor `disable-shared' was passed, we enable building of shared | ||
| dnl archives by default: | ||
| _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) | ||
| _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) | ||
| _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) | ||
| _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], | ||
| [_LT_ENABLE_FAST_INSTALL]) | ||
| ]) | ||
| ])# _LT_SET_OPTIONS | ||
|
|
||
|
|
||
| ## --------------------------------- ## | ||
| ## Macros to handle LT_INIT options. ## | ||
| ## --------------------------------- ## | ||
|
|
||
| # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) | ||
| # ----------------------------------------- | ||
| m4_define([_LT_MANGLE_DEFUN], | ||
| [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) | ||
|
|
||
|
|
||
| # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) | ||
| # ----------------------------------------------- | ||
| m4_define([LT_OPTION_DEFINE], | ||
| [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl | ||
| ])# LT_OPTION_DEFINE | ||
|
|
||
|
|
||
| # dlopen | ||
| # ------ | ||
| LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes | ||
| ]) | ||
|
|
||
| AU_DEFUN([AC_LIBTOOL_DLOPEN], | ||
| [_LT_SET_OPTION([LT_INIT], [dlopen]) | ||
| AC_DIAGNOSE([obsolete], | ||
| [$0: Remove this warning and the call to _LT_SET_OPTION when you | ||
| put the `dlopen' option into LT_INIT's first parameter.]) | ||
| ]) | ||
|
|
||
| dnl aclocal-1.4 backwards compatibility: | ||
| dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) | ||
|
|
||
|
|
||
| # win32-dll | ||
| # --------- | ||
| # Declare package support for building win32 dll's. | ||
| LT_OPTION_DEFINE([LT_INIT], [win32-dll], | ||
| [enable_win32_dll=yes | ||
| case $host in | ||
| *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) | ||
| AC_CHECK_TOOL(AS, as, false) | ||
| AC_CHECK_TOOL(DLLTOOL, dlltool, false) | ||
| AC_CHECK_TOOL(OBJDUMP, objdump, false) | ||
| ;; | ||
| esac | ||
| test -z "$AS" && AS=as | ||
| _LT_DECL([], [AS], [1], [Assembler program])dnl | ||
| test -z "$DLLTOOL" && DLLTOOL=dlltool | ||
| _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl | ||
| test -z "$OBJDUMP" && OBJDUMP=objdump | ||
| _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl | ||
| ])# win32-dll | ||
|
|
||
| AU_DEFUN([AC_LIBTOOL_WIN32_DLL], | ||
| [AC_REQUIRE([AC_CANONICAL_HOST])dnl | ||
| _LT_SET_OPTION([LT_INIT], [win32-dll]) | ||
| AC_DIAGNOSE([obsolete], | ||
| [$0: Remove this warning and the call to _LT_SET_OPTION when you | ||
| put the `win32-dll' option into LT_INIT's first parameter.]) | ||
| ]) | ||
|
|
||
| dnl aclocal-1.4 backwards compatibility: | ||
| dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) | ||
|
|
||
|
|
||
| # _LT_ENABLE_SHARED([DEFAULT]) | ||
| # ---------------------------- | ||
| # implement the --enable-shared flag, and supports the `shared' and | ||
| # `disable-shared' LT_INIT options. | ||
| # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. | ||
| m4_define([_LT_ENABLE_SHARED], | ||
| [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl | ||
| AC_ARG_ENABLE([shared], | ||
| [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], | ||
| [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], | ||
| [p=${PACKAGE-default} | ||
| case $enableval in | ||
| yes) enable_shared=yes ;; | ||
| no) enable_shared=no ;; | ||
| *) | ||
| enable_shared=no | ||
| # Look at the argument we got. We use all the common list separators. | ||
| lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," | ||
| for pkg in $enableval; do | ||
| IFS="$lt_save_ifs" | ||
| if test "X$pkg" = "X$p"; then | ||
| enable_shared=yes | ||
| fi | ||
| done | ||
| IFS="$lt_save_ifs" | ||
| ;; | ||
| esac], | ||
| [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) | ||
| _LT_DECL([build_libtool_libs], [enable_shared], [0], | ||
| [Whether or not to build shared libraries]) | ||
| ])# _LT_ENABLE_SHARED | ||
|
|
||
| LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) | ||
| LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) | ||
|
|
||
| # Old names: | ||
| AC_DEFUN([AC_ENABLE_SHARED], | ||
| [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([AC_DISABLE_SHARED], | ||
| [_LT_SET_OPTION([LT_INIT], [disable-shared]) | ||
| ]) | ||
|
|
||
| AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) | ||
| AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) | ||
|
|
||
| dnl aclocal-1.4 backwards compatibility: | ||
| dnl AC_DEFUN([AM_ENABLE_SHARED], []) | ||
| dnl AC_DEFUN([AM_DISABLE_SHARED], []) | ||
|
|
||
|
|
||
|
|
||
| # _LT_ENABLE_STATIC([DEFAULT]) | ||
| # ---------------------------- | ||
| # implement the --enable-static flag, and support the `static' and | ||
| # `disable-static' LT_INIT options. | ||
| # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. | ||
| m4_define([_LT_ENABLE_STATIC], | ||
| [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl | ||
| AC_ARG_ENABLE([static], | ||
| [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], | ||
| [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], | ||
| [p=${PACKAGE-default} | ||
| case $enableval in | ||
| yes) enable_static=yes ;; | ||
| no) enable_static=no ;; | ||
| *) | ||
| enable_static=no | ||
| # Look at the argument we got. We use all the common list separators. | ||
| lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," | ||
| for pkg in $enableval; do | ||
| IFS="$lt_save_ifs" | ||
| if test "X$pkg" = "X$p"; then | ||
| enable_static=yes | ||
| fi | ||
| done | ||
| IFS="$lt_save_ifs" | ||
| ;; | ||
| esac], | ||
| [enable_static=]_LT_ENABLE_STATIC_DEFAULT) | ||
| _LT_DECL([build_old_libs], [enable_static], [0], | ||
| [Whether or not to build static libraries]) | ||
| ])# _LT_ENABLE_STATIC | ||
|
|
||
| LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) | ||
| LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) | ||
|
|
||
| # Old names: | ||
| AC_DEFUN([AC_ENABLE_STATIC], | ||
| [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) | ||
| ]) | ||
|
|
||
| AC_DEFUN([AC_DISABLE_STATIC], | ||
| [_LT_SET_OPTION([LT_INIT], [disable-static]) | ||
| ]) | ||
|
|
||
| AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) | ||
| AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) | ||
|
|
||
| dnl aclocal-1.4 backwards compatibility: | ||
| dnl AC_DEFUN([AM_ENABLE_STATIC], []) | ||
| dnl AC_DEFUN([AM_DISABLE_STATIC], []) | ||
|
|
||
|
|
||
|
|
||
| # _LT_ENABLE_FAST_INSTALL([DEFAULT]) | ||
| # ---------------------------------- | ||
| # implement the --enable-fast-install flag, and support the `fast-install' | ||
| # and `disable-fast-install' LT_INIT options. | ||
| # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. | ||
| m4_define([_LT_ENABLE_FAST_INSTALL], | ||
| [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl | ||
| AC_ARG_ENABLE([fast-install], | ||
| [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], | ||
| [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], | ||
| [p=${PACKAGE-default} | ||
| case $enableval in | ||
| yes) enable_fast_install=yes ;; | ||
| no) enable_fast_install=no ;; | ||
| *) | ||
| enable_fast_install=no | ||
| # Look at the argument we got. We use all the common list separators. | ||
| lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," | ||
| for pkg in $enableval; do | ||
| IFS="$lt_save_ifs" | ||
| if test "X$pkg" = "X$p"; then | ||
| enable_fast_install=yes | ||
| fi | ||
| done | ||
| IFS="$lt_save_ifs" | ||
| ;; | ||
| esac], | ||
| [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) | ||
| _LT_DECL([fast_install], [enable_fast_install], [0], | ||
| [Whether or not to optimize for fast installation])dnl | ||
| ])# _LT_ENABLE_FAST_INSTALL | ||
|
|
||
| LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) | ||
| LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) | ||
|
|
||
| # Old names: | ||
| AU_DEFUN([AC_ENABLE_FAST_INSTALL], | ||
| [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) | ||
| AC_DIAGNOSE([obsolete], | ||
| [$0: Remove this warning and the call to _LT_SET_OPTION when you put | ||
| the `fast-install' option into LT_INIT's first parameter.]) | ||
| ]) | ||
|
|
||
| AU_DEFUN([AC_DISABLE_FAST_INSTALL], | ||
| [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) | ||
| AC_DIAGNOSE([obsolete], | ||
| [$0: Remove this warning and the call to _LT_SET_OPTION when you put | ||
| the `disable-fast-install' option into LT_INIT's first parameter.]) | ||
| ]) | ||
|
|
||
| dnl aclocal-1.4 backwards compatibility: | ||
| dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) | ||
| dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) | ||
|
|
||
|
|
||
| # _LT_WITH_PIC([MODE]) | ||
| # -------------------- | ||
| # implement the --with-pic flag, and support the `pic-only' and `no-pic' | ||
| # LT_INIT options. | ||
| # MODE is either `yes' or `no'. If omitted, it defaults to `both'. | ||
| m4_define([_LT_WITH_PIC], | ||
| [AC_ARG_WITH([pic], | ||
| [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], | ||
| [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], | ||
| [lt_p=${PACKAGE-default} | ||
| case $withval in | ||
| yes|no) pic_mode=$withval ;; | ||
| *) | ||
| pic_mode=default | ||
| # Look at the argument we got. We use all the common list separators. | ||
| lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," | ||
| for lt_pkg in $withval; do | ||
| IFS="$lt_save_ifs" | ||
| if test "X$lt_pkg" = "X$lt_p"; then | ||
| pic_mode=yes | ||
| fi | ||
| done | ||
| IFS="$lt_save_ifs" | ||
| ;; | ||
| esac], | ||
| [pic_mode=default]) | ||
| test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) | ||
| _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl | ||
| ])# _LT_WITH_PIC | ||
|
|
||
| LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) | ||
| LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) | ||
|
|
||
| # Old name: | ||
| AU_DEFUN([AC_LIBTOOL_PICMODE], | ||
| [_LT_SET_OPTION([LT_INIT], [pic-only]) | ||
| AC_DIAGNOSE([obsolete], | ||
| [$0: Remove this warning and the call to _LT_SET_OPTION when you | ||
| put the `pic-only' option into LT_INIT's first parameter.]) | ||
| ]) | ||
|
|
||
| dnl aclocal-1.4 backwards compatibility: | ||
| dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) | ||
|
|
||
| ## ----------------- ## | ||
| ## LTDL_INIT Options ## | ||
| ## ----------------- ## | ||
|
|
||
| m4_define([_LTDL_MODE], []) | ||
| LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], | ||
| [m4_define([_LTDL_MODE], [nonrecursive])]) | ||
| LT_OPTION_DEFINE([LTDL_INIT], [recursive], | ||
| [m4_define([_LTDL_MODE], [recursive])]) | ||
| LT_OPTION_DEFINE([LTDL_INIT], [subproject], | ||
| [m4_define([_LTDL_MODE], [subproject])]) | ||
|
|
||
| m4_define([_LTDL_TYPE], []) | ||
| LT_OPTION_DEFINE([LTDL_INIT], [installable], | ||
| [m4_define([_LTDL_TYPE], [installable])]) | ||
| LT_OPTION_DEFINE([LTDL_INIT], [convenience], | ||
| [m4_define([_LTDL_TYPE], [convenience])]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- | ||
| # | ||
| # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. | ||
| # Written by Gary V. Vaughan, 2004 | ||
| # | ||
| # This file is free software; the Free Software Foundation gives | ||
| # unlimited permission to copy and/or distribute it, with or without | ||
| # modifications, as long as this notice is preserved. | ||
|
|
||
| # serial 6 ltsugar.m4 | ||
|
|
||
| # This is to help aclocal find these macros, as it can't see m4_define. | ||
| AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) | ||
|
|
||
|
|
||
| # lt_join(SEP, ARG1, [ARG2...]) | ||
| # ----------------------------- | ||
| # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their | ||
| # associated separator. | ||
| # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier | ||
| # versions in m4sugar had bugs. | ||
| m4_define([lt_join], | ||
| [m4_if([$#], [1], [], | ||
| [$#], [2], [[$2]], | ||
| [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) | ||
| m4_define([_lt_join], | ||
| [m4_if([$#$2], [2], [], | ||
| [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) | ||
|
|
||
|
|
||
| # lt_car(LIST) | ||
| # lt_cdr(LIST) | ||
| # ------------ | ||
| # Manipulate m4 lists. | ||
| # These macros are necessary as long as will still need to support | ||
| # Autoconf-2.59 which quotes differently. | ||
| m4_define([lt_car], [[$1]]) | ||
| m4_define([lt_cdr], | ||
| [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], | ||
| [$#], 1, [], | ||
| [m4_dquote(m4_shift($@))])]) | ||
| m4_define([lt_unquote], $1) | ||
|
|
||
|
|
||
| # lt_append(MACRO-NAME, STRING, [SEPARATOR]) | ||
| # ------------------------------------------ | ||
| # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. | ||
| # Note that neither SEPARATOR nor STRING are expanded; they are appended | ||
| # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). | ||
| # No SEPARATOR is output if MACRO-NAME was previously undefined (different | ||
| # than defined and empty). | ||
| # | ||
| # This macro is needed until we can rely on Autoconf 2.62, since earlier | ||
| # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. | ||
| m4_define([lt_append], | ||
| [m4_define([$1], | ||
| m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) | ||
|
|
||
|
|
||
|
|
||
| # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) | ||
| # ---------------------------------------------------------- | ||
| # Produce a SEP delimited list of all paired combinations of elements of | ||
| # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list | ||
| # has the form PREFIXmINFIXSUFFIXn. | ||
| # Needed until we can rely on m4_combine added in Autoconf 2.62. | ||
| m4_define([lt_combine], | ||
| [m4_if(m4_eval([$# > 3]), [1], | ||
| [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl | ||
| [[m4_foreach([_Lt_prefix], [$2], | ||
| [m4_foreach([_Lt_suffix], | ||
| ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, | ||
| [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) | ||
| # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) | ||
| # ----------------------------------------------------------------------- | ||
| # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited | ||
| # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. | ||
| m4_define([lt_if_append_uniq], | ||
| [m4_ifdef([$1], | ||
| [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], | ||
| [lt_append([$1], [$2], [$3])$4], | ||
| [$5])], | ||
| [lt_append([$1], [$2], [$3])$4])]) | ||
| # lt_dict_add(DICT, KEY, VALUE) | ||
| # ----------------------------- | ||
| m4_define([lt_dict_add], | ||
| [m4_define([$1($2)], [$3])]) | ||
| # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) | ||
| # -------------------------------------------- | ||
| m4_define([lt_dict_add_subkey], | ||
| [m4_define([$1($2:$3)], [$4])]) | ||
| # lt_dict_fetch(DICT, KEY, [SUBKEY]) | ||
| # ---------------------------------- | ||
| m4_define([lt_dict_fetch], | ||
| [m4_ifval([$3], | ||
| m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), | ||
| m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) | ||
| # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) | ||
| # ----------------------------------------------------------------- | ||
| m4_define([lt_if_dict_fetch], | ||
| [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], | ||
| [$5], | ||
| [$6])]) | ||
| # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) | ||
| # -------------------------------------------------------------- | ||
| m4_define([lt_dict_filter], | ||
| [m4_if([$5], [], [], | ||
| [lt_join(m4_quote(m4_default([$4], [[, ]])), | ||
| lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), | ||
| [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl | ||
| ]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # ltversion.m4 -- version numbers -*- Autoconf -*- | ||
| # | ||
| # Copyright (C) 2004 Free Software Foundation, Inc. | ||
| # Written by Scott James Remnant, 2004 | ||
| # | ||
| # This file is free software; the Free Software Foundation gives | ||
| # unlimited permission to copy and/or distribute it, with or without | ||
| # modifications, as long as this notice is preserved. | ||
|
|
||
| # @configure_input@ | ||
|
|
||
| # serial 3337 ltversion.m4 | ||
| # This file is part of GNU Libtool | ||
|
|
||
| m4_define([LT_PACKAGE_VERSION], [2.4.2]) | ||
| m4_define([LT_PACKAGE_REVISION], [1.3337]) | ||
|
|
||
| AC_DEFUN([LTVERSION_VERSION], | ||
| [macro_version='2.4.2' | ||
| macro_revision='1.3337' | ||
| _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) | ||
| _LT_DECL(, macro_revision, 0) | ||
| ]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- | ||
| # | ||
| # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. | ||
| # Written by Scott James Remnant, 2004. | ||
| # | ||
| # This file is free software; the Free Software Foundation gives | ||
| # unlimited permission to copy and/or distribute it, with or without | ||
| # modifications, as long as this notice is preserved. | ||
|
|
||
| # serial 5 lt~obsolete.m4 | ||
|
|
||
| # These exist entirely to fool aclocal when bootstrapping libtool. | ||
| # | ||
| # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) | ||
| # which have later been changed to m4_define as they aren't part of the | ||
| # exported API, or moved to Autoconf or Automake where they belong. | ||
| # | ||
| # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN | ||
| # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us | ||
| # using a macro with the same name in our local m4/libtool.m4 it'll | ||
| # pull the old libtool.m4 in (it doesn't see our shiny new m4_define | ||
| # and doesn't know about Autoconf macros at all.) | ||
| # | ||
| # So we provide this file, which has a silly filename so it's always | ||
| # included after everything else. This provides aclocal with the | ||
| # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything | ||
| # because those macros already exist, or will be overwritten later. | ||
| # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. | ||
| # | ||
| # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. | ||
| # Yes, that means every name once taken will need to remain here until | ||
| # we give up compatibility with versions before 1.7, at which point | ||
| # we need to keep only those names which we still refer to. | ||
|
|
||
| # This is to help aclocal find these macros, as it can't see m4_define. | ||
| AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) | ||
|
|
||
| m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) | ||
| m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) | ||
| m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) | ||
| m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) | ||
| m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) | ||
| m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) | ||
| m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) | ||
| m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) | ||
| m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) | ||
| m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) | ||
| m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) | ||
| m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) | ||
| m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) | ||
| m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) | ||
| m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) | ||
| m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) | ||
| m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) | ||
| m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) | ||
| m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) | ||
| m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) | ||
| m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) | ||
| m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) | ||
| m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) | ||
| m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) | ||
| m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) | ||
| m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) | ||
| m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) | ||
| m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) | ||
| m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) | ||
| m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) | ||
| m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) | ||
| m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) | ||
| m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) | ||
| m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) | ||
| m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) | ||
| m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) | ||
| m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) | ||
| m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) | ||
| m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) | ||
| m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) | ||
| m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) | ||
| m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) | ||
| m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) | ||
| m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) | ||
| m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) | ||
| m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) | ||
| m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) | ||
| m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) | ||
| m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) | ||
| m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) | ||
| m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) | ||
| m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) | ||
| m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) | ||
| m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) | ||
| m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) | ||
| m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) | ||
| m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) | ||
| m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) | ||
| m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) | ||
| m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) | ||
| m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,215 @@ | ||
| #! /bin/sh | ||
| # Common wrapper for a few potentially missing GNU programs. | ||
|
|
||
| scriptversion=2012-06-26.16; # UTC | ||
|
|
||
| # Copyright (C) 1996-2013 Free Software Foundation, Inc. | ||
| # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. | ||
|
|
||
| # This program is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation; either version 2, or (at your option) | ||
| # any later version. | ||
|
|
||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
|
|
||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| # As a special exception to the GNU General Public License, if you | ||
| # distribute this file as part of a program that contains a | ||
| # configuration script generated by Autoconf, you may include it under | ||
| # the same distribution terms that you use for the rest of that program. | ||
|
|
||
| if test $# -eq 0; then | ||
| echo 1>&2 "Try '$0 --help' for more information" | ||
| exit 1 | ||
| fi | ||
|
|
||
| case $1 in | ||
|
|
||
| --is-lightweight) | ||
| # Used by our autoconf macros to check whether the available missing | ||
| # script is modern enough. | ||
| exit 0 | ||
| ;; | ||
|
|
||
| --run) | ||
| # Back-compat with the calling convention used by older automake. | ||
| shift | ||
| ;; | ||
|
|
||
| -h|--h|--he|--hel|--help) | ||
| echo "\ | ||
| $0 [OPTION]... PROGRAM [ARGUMENT]... | ||
| Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due | ||
| to PROGRAM being missing or too old. | ||
| Options: | ||
| -h, --help display this help and exit | ||
| -v, --version output version information and exit | ||
| Supported PROGRAM values: | ||
| aclocal autoconf autoheader autom4te automake makeinfo | ||
| bison yacc flex lex help2man | ||
| Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and | ||
| 'g' are ignored when checking the name. | ||
| Send bug reports to <bug-automake@gnu.org>." | ||
| exit $? | ||
| ;; | ||
|
|
||
| -v|--v|--ve|--ver|--vers|--versi|--versio|--version) | ||
| echo "missing $scriptversion (GNU Automake)" | ||
| exit $? | ||
| ;; | ||
|
|
||
| -*) | ||
| echo 1>&2 "$0: unknown '$1' option" | ||
| echo 1>&2 "Try '$0 --help' for more information" | ||
| exit 1 | ||
| ;; | ||
|
|
||
| esac | ||
|
|
||
| # Run the given program, remember its exit status. | ||
| "$@"; st=$? | ||
|
|
||
| # If it succeeded, we are done. | ||
| test $st -eq 0 && exit 0 | ||
|
|
||
| # Also exit now if we it failed (or wasn't found), and '--version' was | ||
| # passed; such an option is passed most likely to detect whether the | ||
| # program is present and works. | ||
| case $2 in --version|--help) exit $st;; esac | ||
|
|
||
| # Exit code 63 means version mismatch. This often happens when the user | ||
| # tries to use an ancient version of a tool on a file that requires a | ||
| # minimum version. | ||
| if test $st -eq 63; then | ||
| msg="probably too old" | ||
| elif test $st -eq 127; then | ||
| # Program was missing. | ||
| msg="missing on your system" | ||
| else | ||
| # Program was found and executed, but failed. Give up. | ||
| exit $st | ||
| fi | ||
|
|
||
| perl_URL=http://www.perl.org/ | ||
| flex_URL=http://flex.sourceforge.net/ | ||
| gnu_software_URL=http://www.gnu.org/software | ||
|
|
||
| program_details () | ||
| { | ||
| case $1 in | ||
| aclocal|automake) | ||
| echo "The '$1' program is part of the GNU Automake package:" | ||
| echo "<$gnu_software_URL/automake>" | ||
| echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" | ||
| echo "<$gnu_software_URL/autoconf>" | ||
| echo "<$gnu_software_URL/m4/>" | ||
| echo "<$perl_URL>" | ||
| ;; | ||
| autoconf|autom4te|autoheader) | ||
| echo "The '$1' program is part of the GNU Autoconf package:" | ||
| echo "<$gnu_software_URL/autoconf/>" | ||
| echo "It also requires GNU m4 and Perl in order to run:" | ||
| echo "<$gnu_software_URL/m4/>" | ||
| echo "<$perl_URL>" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| give_advice () | ||
| { | ||
| # Normalize program name to check for. | ||
| normalized_program=`echo "$1" | sed ' | ||
| s/^gnu-//; t | ||
| s/^gnu//; t | ||
| s/^g//; t'` | ||
|
|
||
| printf '%s\n' "'$1' is $msg." | ||
|
|
||
| configure_deps="'configure.ac' or m4 files included by 'configure.ac'" | ||
| case $normalized_program in | ||
| autoconf*) | ||
| echo "You should only need it if you modified 'configure.ac'," | ||
| echo "or m4 files included by it." | ||
| program_details 'autoconf' | ||
| ;; | ||
| autoheader*) | ||
| echo "You should only need it if you modified 'acconfig.h' or" | ||
| echo "$configure_deps." | ||
| program_details 'autoheader' | ||
| ;; | ||
| automake*) | ||
| echo "You should only need it if you modified 'Makefile.am' or" | ||
| echo "$configure_deps." | ||
| program_details 'automake' | ||
| ;; | ||
| aclocal*) | ||
| echo "You should only need it if you modified 'acinclude.m4' or" | ||
| echo "$configure_deps." | ||
| program_details 'aclocal' | ||
| ;; | ||
| autom4te*) | ||
| echo "You might have modified some maintainer files that require" | ||
| echo "the 'automa4te' program to be rebuilt." | ||
| program_details 'autom4te' | ||
| ;; | ||
| bison*|yacc*) | ||
| echo "You should only need it if you modified a '.y' file." | ||
| echo "You may want to install the GNU Bison package:" | ||
| echo "<$gnu_software_URL/bison/>" | ||
| ;; | ||
| lex*|flex*) | ||
| echo "You should only need it if you modified a '.l' file." | ||
| echo "You may want to install the Fast Lexical Analyzer package:" | ||
| echo "<$flex_URL>" | ||
| ;; | ||
| help2man*) | ||
| echo "You should only need it if you modified a dependency" \ | ||
| "of a man page." | ||
| echo "You may want to install the GNU Help2man package:" | ||
| echo "<$gnu_software_URL/help2man/>" | ||
| ;; | ||
| makeinfo*) | ||
| echo "You should only need it if you modified a '.texi' file, or" | ||
| echo "any other file indirectly affecting the aspect of the manual." | ||
| echo "You might want to install the Texinfo package:" | ||
| echo "<$gnu_software_URL/texinfo/>" | ||
| echo "The spurious makeinfo call might also be the consequence of" | ||
| echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" | ||
| echo "want to install GNU make:" | ||
| echo "<$gnu_software_URL/make/>" | ||
| ;; | ||
| *) | ||
| echo "You might have modified some files without having the proper" | ||
| echo "tools for further handling them. Check the 'README' file, it" | ||
| echo "often tells you about the needed prerequisites for installing" | ||
| echo "this package. You may also peek at any GNU archive site, in" | ||
| echo "case some other package contains this missing '$1' program." | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| give_advice "$1" | sed -e '1s/^/WARNING: /' \ | ||
| -e '2,$s/^/ /' >&2 | ||
|
|
||
| # Propagate the correct exit status (expected to be 127 for a program | ||
| # not found, 63 for a program that failed due to version mismatch). | ||
| exit $st | ||
|
|
||
| # Local variables: | ||
| # eval: (add-hook 'write-file-hooks 'time-stamp) | ||
| # time-stamp-start: "scriptversion=" | ||
| # time-stamp-format: "%:y-%02m-%02d.%02H" | ||
| # time-stamp-time-zone: "UTC" | ||
| # time-stamp-end: "; # UTC" | ||
| # End: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| /* config.h. Manual config for MSVC. */ | ||
|
|
||
| #ifndef _MSC_VER | ||
| #warn "msvc/config.h shouldn't be included for your development environment." | ||
| #error "Please make sure the msvc/ directory is removed from your build path." | ||
| #endif | ||
|
|
||
| /* Disable: warning C4200: nonstandard extension used : zero-sized array in struct/union */ | ||
| #pragma warning(disable:4200) | ||
| /* Disable: warning C6258: Using TerminateThread does not allow proper thread clean up */ | ||
| #pragma warning(disable: 6258) | ||
| #if defined(_PREFAST_) | ||
| /* Disable "Banned API" errors when using the MS's WDK OACR/Prefast */ | ||
| #pragma warning(disable:28719) | ||
| /* Disable "The function 'InitializeCriticalSection' must be called from within a try/except block" */ | ||
| #pragma warning(disable:28125) | ||
| #endif | ||
|
|
||
| /* Default visibility */ | ||
| #define DEFAULT_VISIBILITY /**/ | ||
|
|
||
| /* Enable global message logging */ | ||
| #define ENABLE_LOGGING 1 | ||
|
|
||
| /* Uncomment to start with debug message logging enabled */ | ||
| // #define ENABLE_DEBUG_LOGGING 1 | ||
|
|
||
| /* type of second poll() argument */ | ||
| #define POLL_NFDS_TYPE unsigned int | ||
|
|
||
| /* Windows/WinCE backend */ | ||
| #if defined(_WIN32_WCE) | ||
| #define OS_WINCE 1 | ||
| #define HAVE_MISSING_H | ||
| #else | ||
| #define OS_WINDOWS 1 | ||
| #define HAVE_SIGNAL_H 1 | ||
| #define HAVE_SYS_TYPES_H 1 | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| @echo off | ||
| ::# default builds static library. | ||
| ::# you can pass the following arguments (case insensitive): | ||
| ::# - "DLL" to build a DLL instead of a static library | ||
| ::# - "/MT" to build a static library compatible with MSVC's /MT option (LIBCMT vs MSVCRT) | ||
|
|
||
| if Test%BUILD_ALT_DIR%==Test goto usage | ||
|
|
||
| ::# process commandline parameters | ||
| set TARGET=LIBRARY | ||
| set STATIC_LIBC= | ||
| set version=1.0 | ||
| set PWD=%~dp0 | ||
| set BUILD_CMD=build -bcwgZ -M2 | ||
|
|
||
| if "%1" == "" goto no_more_args | ||
| ::# /I for case insensitive | ||
| if /I Test%1==TestDLL set TARGET=DYNLINK | ||
| if /I Test%1==Test/MT set STATIC_LIBC=1 | ||
| :no_more_args | ||
|
|
||
| cd ..\libusb\os | ||
| echo TARGETTYPE=%TARGET% > target | ||
| copy target+..\..\msvc\libusb_sources sources >NUL 2>&1 | ||
| del target | ||
| @echo on | ||
| %BUILD_CMD% | ||
| @echo off | ||
| if errorlevel 1 goto builderror | ||
| cd ..\.. | ||
|
|
||
| set cpudir=i386 | ||
| set destType=Win32 | ||
| if %_BUILDARCH%==x86 goto isI386 | ||
| set cpudir=amd64 | ||
| set destType=x64 | ||
| :isI386 | ||
|
|
||
| set srcPath=libusb\os\obj%BUILD_ALT_DIR%\%cpudir% | ||
|
|
||
| set dstPath=%destType%\Debug | ||
| if %DDKBUILDENV%==chk goto isDebug | ||
| set dstPath=%destType%\Release | ||
| :isDebug | ||
|
|
||
| if exist %destType% goto md2 | ||
| mkdir %destType% | ||
| :md2 | ||
| if exist %dstPath% goto md3 | ||
| mkdir %dstPath% | ||
| :md3 | ||
| if exist %dstPath%\dll goto md4 | ||
| mkdir %dstPath%\dll | ||
| :md4 | ||
| if exist %dstPath%\lib goto md5 | ||
| md %dstPath%\lib | ||
| :md5 | ||
| if exist %dstPath%\examples goto md6 | ||
| md %dstPath%\examples | ||
| :md6 | ||
| @echo on | ||
|
|
||
| @if /I NOT Test%1==TestDLL goto copylib | ||
| copy %srcPath%\libusb-%version%.dll %dstPath%\dll | ||
| copy %srcPath%\libusb-%version%.pdb %dstPath%\dll | ||
| :copylib | ||
| copy %srcPath%\libusb-%version%.lib %dstPath%\lib | ||
|
|
||
| @echo off | ||
|
|
||
| if exist examples\listdevs_ddkbuild goto md7 | ||
| md examples\listdevs_ddkbuild | ||
| :md7 | ||
|
|
||
| cd examples\listdevs_ddkbuild | ||
| copy ..\..\msvc\listdevs_sources sources >NUL 2>&1 | ||
| @echo on | ||
| %BUILD_CMD% | ||
| @echo off | ||
| if errorlevel 1 goto builderror | ||
| cd ..\.. | ||
|
|
||
| set srcPath=examples\listdevs_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% | ||
| @echo on | ||
|
|
||
| copy %srcPath%\listdevs.exe %dstPath%\examples | ||
| copy %srcPath%\listdevs.pdb %dstPath%\examples | ||
|
|
||
| @echo off | ||
|
|
||
| if exist examples\xusb_ddkbuild goto md8 | ||
| md examples\xusb_ddkbuild | ||
| :md8 | ||
|
|
||
| cd examples\xusb_ddkbuild | ||
| copy ..\..\msvc\xusb_sources sources >NUL 2>&1 | ||
| @echo on | ||
| %BUILD_CMD% | ||
| @echo off | ||
| if errorlevel 1 goto builderror | ||
| cd ..\.. | ||
|
|
||
| set srcPath=examples\xusb_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% | ||
| @echo on | ||
|
|
||
| copy %srcPath%\xusb.exe %dstPath%\examples | ||
| copy %srcPath%\xusb.pdb %dstPath%\examples | ||
|
|
||
| @echo off | ||
|
|
||
| if exist examples\getopt\getopt_ddkbuild goto md9 | ||
| md examples\getopt\getopt_ddkbuild | ||
| :md9 | ||
|
|
||
| cd examples\getopt\getopt_ddkbuild | ||
| copy ..\..\..\msvc\getopt_sources sources >NUL 2>&1 | ||
| @echo on | ||
| %BUILD_CMD% | ||
| @echo off | ||
| if errorlevel 1 goto builderror | ||
| cd ..\..\.. | ||
|
|
||
| if exist examples\fxload_ddkbuild goto md10 | ||
| md examples\fxload_ddkbuild | ||
| :md10 | ||
|
|
||
| cd examples\fxload_ddkbuild | ||
| copy ..\..\msvc\fxload_sources sources >NUL 2>&1 | ||
| @echo on | ||
| %BUILD_CMD% | ||
| @echo off | ||
| if errorlevel 1 goto builderror | ||
| cd ..\.. | ||
|
|
||
| set srcPath=examples\fxload_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% | ||
| @echo on | ||
|
|
||
| copy %srcPath%\fxload.exe %dstPath%\examples | ||
| copy %srcPath%\fxload.pdb %dstPath%\examples | ||
|
|
||
| @echo off | ||
|
|
||
| if exist examples\hotplugtest_ddkbuild goto md11 | ||
| md examples\hotplugtest_ddkbuild | ||
| :md11 | ||
|
|
||
| cd examples\hotplugtest_ddkbuild | ||
| copy ..\..\msvc\hotplugtest_sources sources >NUL 2>&1 | ||
| @echo on | ||
| %BUILD_CMD% | ||
| @echo off | ||
| if errorlevel 1 goto builderror | ||
| cd ..\.. | ||
|
|
||
| set srcPath=examples\hotplugtest_ddkbuild\obj%BUILD_ALT_DIR%\%cpudir% | ||
| @echo on | ||
|
|
||
| copy %srcPath%\hotplugtest.exe %dstPath%\examples | ||
| copy %srcPath%\hotplugtest.pdb %dstPath%\examples | ||
|
|
||
| @echo off | ||
|
|
||
| cd msvc | ||
| goto done | ||
|
|
||
| :usage | ||
| echo ddk_build must be run in a WDK build environment | ||
| pause | ||
| goto done | ||
|
|
||
| :builderror | ||
| echo Build failed | ||
|
|
||
| :done | ||
| cd %PWD% |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* | ||
| * errno.h | ||
| * This file has no copyright assigned and is placed in the Public Domain. | ||
| * This file is a part of the mingw-runtime package. | ||
| * No warranty is given; refer to the file DISCLAIMER within the package. | ||
| * | ||
| * Error numbers and access to error reporting. | ||
| * | ||
| */ | ||
|
|
||
| #ifndef _ERRNO_H_ | ||
| #define _ERRNO_H_ | ||
|
|
||
| #include <crtdefs.h> | ||
|
|
||
| /* | ||
| * Error numbers. | ||
| * TODO: Can't be sure of some of these assignments, I guessed from the | ||
| * names given by strerror and the defines in the Cygnus errno.h. A lot | ||
| * of the names from the Cygnus errno.h are not represented, and a few | ||
| * of the descriptions returned by strerror do not obviously match | ||
| * their error naming. | ||
| */ | ||
| #define EPERM 1 /* Operation not permitted */ | ||
| #define ENOFILE 2 /* No such file or directory */ | ||
| #define ENOENT 2 | ||
| #define ESRCH 3 /* No such process */ | ||
| #define EINTR 4 /* Interrupted function call */ | ||
| #define EIO 5 /* Input/output error */ | ||
| #define ENXIO 6 /* No such device or address */ | ||
| #define E2BIG 7 /* Arg list too long */ | ||
| #define ENOEXEC 8 /* Exec format error */ | ||
| #define EBADF 9 /* Bad file descriptor */ | ||
| #define ECHILD 10 /* No child processes */ | ||
| #define EAGAIN 11 /* Resource temporarily unavailable */ | ||
| #define ENOMEM 12 /* Not enough space */ | ||
| #define EACCES 13 /* Permission denied */ | ||
| #define EFAULT 14 /* Bad address */ | ||
| /* 15 - Unknown Error */ | ||
| #define EBUSY 16 /* strerror reports "Resource device" */ | ||
| #define EEXIST 17 /* File exists */ | ||
| #define EXDEV 18 /* Improper link (cross-device link?) */ | ||
| #define ENODEV 19 /* No such device */ | ||
| #define ENOTDIR 20 /* Not a directory */ | ||
| #define EISDIR 21 /* Is a directory */ | ||
| #define EINVAL 22 /* Invalid argument */ | ||
| #define ENFILE 23 /* Too many open files in system */ | ||
| #define EMFILE 24 /* Too many open files */ | ||
| #define ENOTTY 25 /* Inappropriate I/O control operation */ | ||
| /* 26 - Unknown Error */ | ||
| #define EFBIG 27 /* File too large */ | ||
| #define ENOSPC 28 /* No space left on device */ | ||
| #define ESPIPE 29 /* Invalid seek (seek on a pipe?) */ | ||
| #define EROFS 30 /* Read-only file system */ | ||
| #define EMLINK 31 /* Too many links */ | ||
| #define EPIPE 32 /* Broken pipe */ | ||
| #define EDOM 33 /* Domain error (math functions) */ | ||
| #define ERANGE 34 /* Result too large (possibly too small) */ | ||
| /* 35 - Unknown Error */ | ||
| #define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */ | ||
| #define EDEADLK 36 | ||
| #if 0 | ||
| /* 37 - Unknown Error */ | ||
| #define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */ | ||
| #define ENOLCK 39 /* No locks available (46 in Cyg?) */ | ||
| #define ENOSYS 40 /* Function not implemented (88 in Cyg?) */ | ||
| #define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */ | ||
| #define EILSEQ 42 /* Illegal byte sequence */ | ||
| #endif | ||
|
|
||
| /* | ||
| * NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the | ||
| * sockets.h header provided with windows32api-0.1.2. | ||
| * You should go and put an #if 0 ... #endif around the whole block | ||
| * of errors (look at the comment above them). | ||
| */ | ||
|
|
||
| #ifndef RC_INVOKED | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /* | ||
| * Definitions of errno. For _doserrno, sys_nerr and * sys_errlist, see | ||
| * stdlib.h. | ||
| */ | ||
| #if defined(_UWIN) || defined(_WIN32_WCE) | ||
| #undef errno | ||
| extern int errno; | ||
| #else | ||
| _CRTIMP int* __cdecl _errno(void); | ||
| #define errno (*_errno()) | ||
| #endif | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* Not RC_INVOKED */ | ||
|
|
||
| #endif /* Not _ERRNO_H_ */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,295 @@ | ||
| /** | ||
| * This file has no copyright assigned and is placed in the Public Domain. | ||
| * This file was original part of the w64 mingw-runtime package. | ||
| */ | ||
|
|
||
| /* | ||
| * THIS SOFTWARE IS NOT COPYRIGHTED | ||
| * | ||
| * Modified for libusb/MSVC: Pete Batard <pbatard@gmail.com> | ||
| * | ||
| * This source code is offered for use in the public domain. You may | ||
| * use, modify or distribute it freely. | ||
| * | ||
| * This code is distributed in the hope that it will be useful but | ||
| * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY | ||
| * DISCLAIMED. This includes but is not limited to warranties of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| * | ||
| * Date: 2010-04-02 | ||
| */ | ||
|
|
||
| #ifndef _MSC_VER | ||
| #error This header should only be used with Microsoft compilers | ||
| #endif | ||
|
|
||
| /* 7.8 Format conversion of integer types <inttypes.h> */ | ||
|
|
||
| #ifndef _INTTYPES_H_ | ||
| #define _INTTYPES_H_ | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| typedef struct { | ||
| intmax_t quot; | ||
| intmax_t rem; | ||
| } imaxdiv_t; | ||
|
|
||
|
|
||
| /* 7.8.1 Macros for format specifiers | ||
| * | ||
| * MS runtime does not yet understand C9x standard "ll" | ||
| * length specifier. It appears to treat "ll" as "l". | ||
| * The non-standard I64 length specifier causes warning in GCC, | ||
| * but understood by MS runtime functions. | ||
| */ | ||
|
|
||
| /* fprintf macros for signed types */ | ||
| #define PRId8 "d" | ||
| #define PRId16 "d" | ||
| #define PRId32 "d" | ||
| #define PRId64 "I64d" | ||
|
|
||
| #define PRIdLEAST8 "d" | ||
| #define PRIdLEAST16 "d" | ||
| #define PRIdLEAST32 "d" | ||
| #define PRIdLEAST64 "I64d" | ||
|
|
||
| #define PRIdFAST8 "d" | ||
| #define PRIdFAST16 "d" | ||
| #define PRIdFAST32 "d" | ||
| #define PRIdFAST64 "I64d" | ||
|
|
||
| #define PRIdMAX "I64d" | ||
|
|
||
| #define PRIi8 "i" | ||
| #define PRIi16 "i" | ||
| #define PRIi32 "i" | ||
| #define PRIi64 "I64i" | ||
|
|
||
| #define PRIiLEAST8 "i" | ||
| #define PRIiLEAST16 "i" | ||
| #define PRIiLEAST32 "i" | ||
| #define PRIiLEAST64 "I64i" | ||
|
|
||
| #define PRIiFAST8 "i" | ||
| #define PRIiFAST16 "i" | ||
| #define PRIiFAST32 "i" | ||
| #define PRIiFAST64 "I64i" | ||
|
|
||
| #define PRIiMAX "I64i" | ||
|
|
||
| #define PRIo8 "o" | ||
| #define PRIo16 "o" | ||
| #define PRIo32 "o" | ||
| #define PRIo64 "I64o" | ||
|
|
||
| #define PRIoLEAST8 "o" | ||
| #define PRIoLEAST16 "o" | ||
| #define PRIoLEAST32 "o" | ||
| #define PRIoLEAST64 "I64o" | ||
|
|
||
| #define PRIoFAST8 "o" | ||
| #define PRIoFAST16 "o" | ||
| #define PRIoFAST32 "o" | ||
| #define PRIoFAST64 "I64o" | ||
|
|
||
| #define PRIoMAX "I64o" | ||
|
|
||
| /* fprintf macros for unsigned types */ | ||
| #define PRIu8 "u" | ||
| #define PRIu16 "u" | ||
| #define PRIu32 "u" | ||
| #define PRIu64 "I64u" | ||
|
|
||
|
|
||
| #define PRIuLEAST8 "u" | ||
| #define PRIuLEAST16 "u" | ||
| #define PRIuLEAST32 "u" | ||
| #define PRIuLEAST64 "I64u" | ||
|
|
||
| #define PRIuFAST8 "u" | ||
| #define PRIuFAST16 "u" | ||
| #define PRIuFAST32 "u" | ||
| #define PRIuFAST64 "I64u" | ||
|
|
||
| #define PRIuMAX "I64u" | ||
|
|
||
| #define PRIx8 "x" | ||
| #define PRIx16 "x" | ||
| #define PRIx32 "x" | ||
| #define PRIx64 "I64x" | ||
|
|
||
| #define PRIxLEAST8 "x" | ||
| #define PRIxLEAST16 "x" | ||
| #define PRIxLEAST32 "x" | ||
| #define PRIxLEAST64 "I64x" | ||
|
|
||
| #define PRIxFAST8 "x" | ||
| #define PRIxFAST16 "x" | ||
| #define PRIxFAST32 "x" | ||
| #define PRIxFAST64 "I64x" | ||
|
|
||
| #define PRIxMAX "I64x" | ||
|
|
||
| #define PRIX8 "X" | ||
| #define PRIX16 "X" | ||
| #define PRIX32 "X" | ||
| #define PRIX64 "I64X" | ||
|
|
||
| #define PRIXLEAST8 "X" | ||
| #define PRIXLEAST16 "X" | ||
| #define PRIXLEAST32 "X" | ||
| #define PRIXLEAST64 "I64X" | ||
|
|
||
| #define PRIXFAST8 "X" | ||
| #define PRIXFAST16 "X" | ||
| #define PRIXFAST32 "X" | ||
| #define PRIXFAST64 "I64X" | ||
|
|
||
| #define PRIXMAX "I64X" | ||
|
|
||
| /* | ||
| * fscanf macros for signed int types | ||
| * NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t | ||
| * (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have | ||
| * no length identifiers | ||
| */ | ||
|
|
||
| #define SCNd16 "hd" | ||
| #define SCNd32 "d" | ||
| #define SCNd64 "I64d" | ||
|
|
||
| #define SCNdLEAST16 "hd" | ||
| #define SCNdLEAST32 "d" | ||
| #define SCNdLEAST64 "I64d" | ||
|
|
||
| #define SCNdFAST16 "hd" | ||
| #define SCNdFAST32 "d" | ||
| #define SCNdFAST64 "I64d" | ||
|
|
||
| #define SCNdMAX "I64d" | ||
|
|
||
| #define SCNi16 "hi" | ||
| #define SCNi32 "i" | ||
| #define SCNi64 "I64i" | ||
|
|
||
| #define SCNiLEAST16 "hi" | ||
| #define SCNiLEAST32 "i" | ||
| #define SCNiLEAST64 "I64i" | ||
|
|
||
| #define SCNiFAST16 "hi" | ||
| #define SCNiFAST32 "i" | ||
| #define SCNiFAST64 "I64i" | ||
|
|
||
| #define SCNiMAX "I64i" | ||
|
|
||
| #define SCNo16 "ho" | ||
| #define SCNo32 "o" | ||
| #define SCNo64 "I64o" | ||
|
|
||
| #define SCNoLEAST16 "ho" | ||
| #define SCNoLEAST32 "o" | ||
| #define SCNoLEAST64 "I64o" | ||
|
|
||
| #define SCNoFAST16 "ho" | ||
| #define SCNoFAST32 "o" | ||
| #define SCNoFAST64 "I64o" | ||
|
|
||
| #define SCNoMAX "I64o" | ||
|
|
||
| #define SCNx16 "hx" | ||
| #define SCNx32 "x" | ||
| #define SCNx64 "I64x" | ||
|
|
||
| #define SCNxLEAST16 "hx" | ||
| #define SCNxLEAST32 "x" | ||
| #define SCNxLEAST64 "I64x" | ||
|
|
||
| #define SCNxFAST16 "hx" | ||
| #define SCNxFAST32 "x" | ||
| #define SCNxFAST64 "I64x" | ||
|
|
||
| #define SCNxMAX "I64x" | ||
|
|
||
| /* fscanf macros for unsigned int types */ | ||
|
|
||
| #define SCNu16 "hu" | ||
| #define SCNu32 "u" | ||
| #define SCNu64 "I64u" | ||
|
|
||
| #define SCNuLEAST16 "hu" | ||
| #define SCNuLEAST32 "u" | ||
| #define SCNuLEAST64 "I64u" | ||
|
|
||
| #define SCNuFAST16 "hu" | ||
| #define SCNuFAST32 "u" | ||
| #define SCNuFAST64 "I64u" | ||
|
|
||
| #define SCNuMAX "I64u" | ||
|
|
||
| #ifdef _WIN64 | ||
| #define PRIdPTR "I64d" | ||
| #define PRIiPTR "I64i" | ||
| #define PRIoPTR "I64o" | ||
| #define PRIuPTR "I64u" | ||
| #define PRIxPTR "I64x" | ||
| #define PRIXPTR "I64X" | ||
| #define SCNdPTR "I64d" | ||
| #define SCNiPTR "I64i" | ||
| #define SCNoPTR "I64o" | ||
| #define SCNxPTR "I64x" | ||
| #define SCNuPTR "I64u" | ||
| #else | ||
| #define PRIdPTR "d" | ||
| #define PRIiPTR "i" | ||
| #define PRIoPTR "o" | ||
| #define PRIuPTR "u" | ||
| #define PRIxPTR "x" | ||
| #define PRIXPTR "X" | ||
| #define SCNdPTR "d" | ||
| #define SCNiPTR "i" | ||
| #define SCNoPTR "o" | ||
| #define SCNxPTR "x" | ||
| #define SCNuPTR "u" | ||
| #endif | ||
|
|
||
| #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L | ||
| /* | ||
| * no length modifier for char types prior to C9x | ||
| * MS runtime scanf appears to treat "hh" as "h" | ||
| */ | ||
|
|
||
| /* signed char */ | ||
| #define SCNd8 "hhd" | ||
| #define SCNdLEAST8 "hhd" | ||
| #define SCNdFAST8 "hhd" | ||
|
|
||
| #define SCNi8 "hhi" | ||
| #define SCNiLEAST8 "hhi" | ||
| #define SCNiFAST8 "hhi" | ||
|
|
||
| #define SCNo8 "hho" | ||
| #define SCNoLEAST8 "hho" | ||
| #define SCNoFAST8 "hho" | ||
|
|
||
| #define SCNx8 "hhx" | ||
| #define SCNxLEAST8 "hhx" | ||
| #define SCNxFAST8 "hhx" | ||
|
|
||
| /* unsigned char */ | ||
| #define SCNu8 "hhu" | ||
| #define SCNuLEAST8 "hhu" | ||
| #define SCNuFAST8 "hhu" | ||
| #endif /* __STDC_VERSION__ >= 199901 */ | ||
|
|
||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* ndef _INTTYPES_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #TARGETTYPE is not defined, to allow selection between static lib or DLL with ddk_build | ||
| TARGETNAME=libusb-1.0 | ||
| DLLDEF=..\libusb-1.0.def | ||
|
|
||
| !IFNDEF MSC_WARNING_LEVEL | ||
| MSC_WARNING_LEVEL=/W3 | ||
| !ENDIF | ||
|
|
||
| !IFDEF STATIC_LIBC | ||
| USE_LIBCMT=1 | ||
| !ELSE | ||
| USE_MSVCRT=1 | ||
| !ENDIF | ||
|
|
||
| INCLUDES=..;..\..\msvc;$(DDK_INC_PATH) | ||
| C_DEFINES= $(C_DEFINES) $(LIBUSB_DEFINES) /DDDKBUILD | ||
|
|
||
| # http://jpassing.com/2009/10/21/ltcg-issues-with-the-win7amd64-environment-of-wdk-7600/ | ||
| # prevents the following error when using the 64 bit static lib with Visual Studio 2010: | ||
| # "fatal error C1001: An internal error has occurred in the compiler. | ||
| # (compiler file 'f:\dd\vctools\compiler\utc\src\p2\p2symtab.c', line 1823)" | ||
| # and the following with Visual Studio 2010: | ||
| # "fatal error C1047: The object or library file 'libusb-1.0.lib' was created with | ||
| # an older compiler than other objects; rebuild old objects and libraries" | ||
| USER_C_FLAGS=/GL- | ||
|
|
||
| TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib | ||
|
|
||
| SOURCES=..\core.c \ | ||
| ..\descriptor.c \ | ||
| ..\io.c \ | ||
| ..\strerror.c \ | ||
| ..\sync.c \ | ||
| ..\hotplug.c \ | ||
| threads_windows.c \ | ||
| poll_windows.c \ | ||
| windows_usb.c \ | ||
| ..\libusb-1.0.rc |