~ubuntu-branches/ubuntu/saucy/libusbx/saucy-proposed

« back to all changes in this revision

Viewing changes to libusb/libusbi.h

  • Committer: Package Import Robot
  • Author(s): Aurelien Jarno
  • Date: 2013-05-06 17:31:43 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130506173143-wfbiltvcnn7pvdpa
Tags: 2:1.0.15-1
* New upstream version.
* Fix cross-build (closes: #694912, #705658).
* Add a -dbg package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#ifndef LIBUSBI_H
22
22
#define LIBUSBI_H
23
23
 
24
 
#include <config.h>
 
24
#include "config.h"
25
25
 
26
26
#include <stddef.h>
27
27
#include <stdint.h>
31
31
#include <poll.h>
32
32
#endif
33
33
 
34
 
#include <libusb.h>
 
34
#ifdef HAVE_MISSING_H
 
35
#include "missing.h"
 
36
#endif
 
37
#include "libusb.h"
35
38
#include "version.h"
36
39
 
37
40
/* Inside the libusbx code, mark all public functions as follows:
49
52
#define USB_MAXINTERFACES       32
50
53
#define USB_MAXCONFIG           8
51
54
 
 
55
/* Backend specific capabilities */
 
56
#define USBI_CAP_HAS_HID_ACCESS                                 0x00010000
 
57
#define USBI_CAP_SUPPORTS_DETACH_KERNEL_DRIVER  0x00020000
 
58
 
 
59
/* The following is used to silence warnings for unused variables */
 
60
#define UNUSED(var)                     do { (void)(var); } while(0)
 
61
 
52
62
struct list_head {
53
63
        struct list_head *prev, *next;
54
64
};
59
69
 *      member - the list_head element in "type"
60
70
 */
61
71
#define list_entry(ptr, type, member) \
62
 
        ((type *)((uintptr_t)(ptr) - (uintptr_t)(&((type *)0L)->member)))
 
72
        ((type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, member)))
63
73
 
64
74
/* Get each entry from a list
65
75
 *      pos - A structure pointer has a "member" element
108
118
{
109
119
        entry->next->prev = entry->prev;
110
120
        entry->prev->next = entry->next;
 
121
        entry->next = entry->prev = NULL;
111
122
}
112
123
 
113
124
static inline void *usbi_reallocf(void *ptr, size_t size)
188
199
#define IS_XFERIN(xfer) (0 != ((xfer)->endpoint & LIBUSB_ENDPOINT_IN))
189
200
#define IS_XFEROUT(xfer) (!IS_XFERIN(xfer))
190
201
 
191
 
/* Internal abstractions for thread synchronization and poll */
 
202
/* Internal abstraction for thread synchronization */
192
203
#if defined(THREADS_POSIX)
193
 
#include <os/threads_posix.h>
194
 
#elif defined(OS_WINDOWS)
 
204
#include "os/threads_posix.h"
 
205
#elif defined(OS_WINDOWS) || defined(OS_WINCE)
195
206
#include <os/threads_windows.h>
196
207
#endif
197
208
 
198
 
#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD)
199
 
#include <unistd.h>
200
 
#include <os/poll_posix.h>
201
 
#elif defined(OS_WINDOWS)
202
 
#include <os/poll_windows.h>
203
 
#endif
204
 
 
205
 
#if defined(OS_WINDOWS) && !defined(__GCC__)
206
 
#undef HAVE_GETTIMEOFDAY
207
 
int usbi_gettimeofday(struct timeval *tp, void *tzp);
208
 
#define LIBUSB_GETTIMEOFDAY_WIN32
209
 
#define HAVE_USBI_GETTIMEOFDAY
210
 
#else
211
 
#ifdef HAVE_GETTIMEOFDAY
212
 
#define usbi_gettimeofday(tv, tz) gettimeofday((tv), (tz))
213
 
#define HAVE_USBI_GETTIMEOFDAY
214
 
#endif
215
 
#endif
216
 
 
217
209
extern struct libusb_context *usbi_default_context;
218
210
 
219
211
struct libusb_context {
403
395
int usbi_get_config_index_by_value(struct libusb_device *dev,
404
396
        uint8_t bConfigurationValue, int *idx);
405
397
 
406
 
/* polling */
 
398
/* Internal abstraction for poll (needs struct usbi_transfer on Windows) */
 
399
#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(OS_OPENBSD)
 
400
#include <unistd.h>
 
401
#include "os/poll_posix.h"
 
402
#elif defined(OS_WINDOWS) || defined(OS_WINCE)
 
403
#include <os/poll_windows.h>
 
404
#endif
 
405
 
 
406
#if (defined(OS_WINDOWS) || defined(OS_WINCE)) && !defined(__GCC__)
 
407
#undef HAVE_GETTIMEOFDAY
 
408
int usbi_gettimeofday(struct timeval *tp, void *tzp);
 
409
#define LIBUSB_GETTIMEOFDAY_WIN32
 
410
#define HAVE_USBI_GETTIMEOFDAY
 
411
#else
 
412
#ifdef HAVE_GETTIMEOFDAY
 
413
#define usbi_gettimeofday(tv, tz) gettimeofday((tv), (tz))
 
414
#define HAVE_USBI_GETTIMEOFDAY
 
415
#endif
 
416
#endif
407
417
 
408
418
struct usbi_pollfd {
409
419
        /* must come first */
440
450
        /* A human-readable name for your backend, e.g. "Linux usbfs" */
441
451
        const char *name;
442
452
 
 
453
        /* Binary mask for backend specific capabilities */
 
454
        uint32_t caps;
 
455
 
443
456
        /* Perform initialization of your backend. You might use this function
444
457
         * to determine specific capabilities of the system, allocate required
445
458
         * data structures for later, etc.
902
915
extern const struct usbi_os_backend darwin_backend;
903
916
extern const struct usbi_os_backend openbsd_backend;
904
917
extern const struct usbi_os_backend windows_backend;
 
918
extern const struct usbi_os_backend wince_backend;
905
919
 
906
920
#endif