From owner-svn-src-head@FreeBSD.ORG Wed Mar 13 12:23:17 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 81EBB8C5; Wed, 13 Mar 2013 12:23:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 734F9DC3; Wed, 13 Mar 2013 12:23:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2DCNHTh016860; Wed, 13 Mar 2013 12:23:17 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2DCNELe016844; Wed, 13 Mar 2013 12:23:14 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201303131223.r2DCNELe016844@svn.freebsd.org> From: Hans Petter Selasky Date: Wed, 13 Mar 2013 12:23:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248236 - in head: lib/libusb usr.sbin/usbconfig X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Mar 2013 12:23:17 -0000 Author: hselasky Date: Wed Mar 13 12:23:14 2013 New Revision: 248236 URL: http://svnweb.freebsd.org/changeset/base/248236 Log: - Make the FreeBSD's USB library compile under Linux. - Fix a compile warning where the return value of a call to a write() function was ignored. - Remove redundant include files from userland USB header files. - Add some now needed include files to various C-files. Added: head/lib/libusb/libusb_global_linux.h (contents, props changed) Modified: head/lib/libusb/Makefile head/lib/libusb/libusb.h head/lib/libusb/libusb01.c head/lib/libusb/libusb10.c head/lib/libusb/libusb10.h head/lib/libusb/libusb10_desc.c head/lib/libusb/libusb10_io.c head/lib/libusb/libusb20.c head/lib/libusb/libusb20.h head/lib/libusb/libusb20_desc.c head/lib/libusb/libusb20_desc.h head/lib/libusb/libusb20_ugen20.c head/lib/libusb/usb.h head/usr.sbin/usbconfig/usbconfig.c Modified: head/lib/libusb/Makefile ============================================================================== --- head/lib/libusb/Makefile Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/Makefile Wed Mar 13 12:23:14 2013 (r248236) @@ -37,6 +37,19 @@ SRCS+= libusb10_io.c CFLAGS+= -DCOMPAT_32BIT .endif +# +# Cross platform support +# +# Examples: +# make LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h +# make COMPAT_32BIT=YES LIBUSB_GLOBAL_INCLUDE_FILE=libusb_global_linux.h +# +.if defined(LIBUSB_GLOBAL_INCLUDE_FILE) +CFLAGS+= -DLIBUSB_GLOBAL_INCLUDE_FILE=\"${LIBUSB_GLOBAL_INCLUDE_FILE}\" +CFLAGS+= -DUSB_GLOBAL_INCLUDE_FILE=\"${LIBUSB_GLOBAL_INCLUDE_FILE}\" +CFLAGS+= -I ../../sys +.endif + .include # LibUSB v1.0 Modified: head/lib/libusb/libusb.h ============================================================================== --- head/lib/libusb/libusb.h Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb.h Wed Mar 13 12:23:14 2013 (r248236) @@ -27,8 +27,11 @@ #ifndef __LIBUSB_H__ #define __LIBUSB_H__ +#ifndef LIBUSB_GLOBAL_INCLUDE_FILE +#include #include #include +#endif #ifdef __cplusplus extern "C" { Modified: head/lib/libusb/libusb01.c ============================================================================== --- head/lib/libusb/libusb01.c Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb01.c Wed Mar 13 12:23:14 2013 (r248236) @@ -28,11 +28,16 @@ * This file contains the emulation layer for LibUSB v0.1 from sourceforge. */ -#include - +#ifdef LIBUSB_GLOBAL_INCLUDE_FILE +#include LIBUSB_GLOBAL_INCLUDE_FILE +#else #include #include #include +#include +#include +#include +#endif #include "libusb20.h" #include "libusb20_desc.h" Modified: head/lib/libusb/libusb10.c ============================================================================== --- head/lib/libusb/libusb10.c Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb10.c Wed Mar 13 12:23:14 2013 (r248236) @@ -25,17 +25,23 @@ * SUCH DAMAGE. */ -#include -#include -#include - +#ifdef LIBUSB_GLOBAL_INCLUDE_FILE +#include LIBUSB_GLOBAL_INCLUDE_FILE +#else #include #include #include #include #include #include +#include #include +#include +#include +#include +#include +#include +#endif #define libusb_device_handle libusb20_device @@ -1331,7 +1337,7 @@ failure: /* make sure our event loop spins the done handler */ dummy = 0; - write(dev->ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); + err = write(dev->ctx->ctrl_pipe[1], &dummy, sizeof(dummy)); } /* The following function must be called unlocked */ Modified: head/lib/libusb/libusb10.h ============================================================================== --- head/lib/libusb/libusb10.h Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb10.h Wed Mar 13 12:23:14 2013 (r248236) @@ -27,7 +27,9 @@ #ifndef __LIBUSB10_H__ #define __LIBUSB10_H__ +#ifndef LIBUSB_GLOBAL_INCLUDE_FILE #include +#endif #define GET_CONTEXT(ctx) (((ctx) == NULL) ? usbi_default_context : (ctx)) #define UNEXPORTED __attribute__((__visibility__("hidden"))) Modified: head/lib/libusb/libusb10_desc.c ============================================================================== --- head/lib/libusb/libusb10_desc.c Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb10_desc.c Wed Mar 13 12:23:14 2013 (r248236) @@ -24,10 +24,15 @@ * SUCH DAMAGE. */ -#include - +#ifdef LIBUSB_GLOBAL_INCLUDE_FILE +#include LIBUSB_GLOBAL_INCLUDE_FILE +#else #include #include +#include +#include +#include +#endif #define libusb_device_handle libusb20_device Modified: head/lib/libusb/libusb10_io.c ============================================================================== --- head/lib/libusb/libusb10_io.c Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb10_io.c Wed Mar 13 12:23:14 2013 (r248236) @@ -24,15 +24,20 @@ * SUCH DAMAGE. */ -#include - +#ifdef LIBUSB_GLOBAL_INCLUDE_FILE +#include LIBUSB_GLOBAL_INCLUDE_FILE +#else #include #include #include #include #include +#include #include #include +#include +#include +#endif #define libusb_device_handle libusb20_device Modified: head/lib/libusb/libusb20.c ============================================================================== --- head/lib/libusb/libusb20.c Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb20.c Wed Mar 13 12:23:14 2013 (r248236) @@ -24,13 +24,17 @@ * SUCH DAMAGE. */ -#include - +#ifdef LIBUSB_GLOBAL_INCLUDE_FILE +#include LIBUSB_GLOBAL_INCLUDE_FILE +#else #include #include #include #include #include +#include +#include +#endif #include "libusb20.h" #include "libusb20_desc.h" Modified: head/lib/libusb/libusb20.h ============================================================================== --- head/lib/libusb/libusb20.h Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb20.h Wed Mar 13 12:23:14 2013 (r248236) @@ -29,13 +29,9 @@ #ifndef _LIBUSB20_H_ #define _LIBUSB20_H_ -#include -#include -#include - +#ifndef LIBUSB_GLOBAL_INCLUDE_FILE #include -#include -#include +#endif #ifdef __cplusplus extern "C" { Modified: head/lib/libusb/libusb20_desc.c ============================================================================== --- head/lib/libusb/libusb20_desc.c Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb20_desc.c Wed Mar 13 12:23:14 2013 (r248236) @@ -24,11 +24,15 @@ * SUCH DAMAGE. */ -#include - +#ifdef LIBUSB_GLOBAL_INCLUDE_FILE +#include LIBUSB_GLOBAL_INCLUDE_FILE +#else #include #include #include +#include +#include +#endif #include "libusb20.h" #include "libusb20_desc.h" Modified: head/lib/libusb/libusb20_desc.h ============================================================================== --- head/lib/libusb/libusb20_desc.h Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb20_desc.h Wed Mar 13 12:23:14 2013 (r248236) @@ -45,6 +45,10 @@ #ifndef _LIBUSB20_DESC_H_ #define _LIBUSB20_DESC_H_ +#ifndef LIBUSB_GLOBAL_INCLUDE_FILE +#include +#endif + #ifdef __cplusplus extern "C" { #endif Modified: head/lib/libusb/libusb20_ugen20.c ============================================================================== --- head/lib/libusb/libusb20_ugen20.c Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/libusb20_ugen20.c Wed Mar 13 12:23:14 2013 (r248236) @@ -24,24 +24,28 @@ * SUCH DAMAGE. */ -#include -#include - +#ifdef LIBUSB_GLOBAL_INCLUDE_FILE +#include LIBUSB_GLOBAL_INCLUDE_FILE +#else #include #include #include #include #include #include - -#include "libusb20.h" -#include "libusb20_desc.h" -#include "libusb20_int.h" +#include +#include +#include +#endif #include #include #include +#include "libusb20.h" +#include "libusb20_desc.h" +#include "libusb20_int.h" + static libusb20_init_backend_t ugen20_init_backend; static libusb20_open_device_t ugen20_open_device; static libusb20_close_device_t ugen20_close_device; Added: head/lib/libusb/libusb_global_linux.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libusb/libusb_global_linux.h Wed Mar 13 12:23:14 2013 (r248236) @@ -0,0 +1,69 @@ +/* $FreeBSD$ */ +/*- + * Copyright (c) 2013 Hans Petter Selasky. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _LIBUSB_GLOBAL_LINUX_H_ +#define _LIBUSB_GLOBAL_LINUX_H_ + +#define _XOPEN_SOURCE +#define _BSD_SOURCE +#define _POSIX_SOURCE +#define _POSIX_C_SOURCE 200809 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __aligned +#define __aligned(x) __attribute__((__aligned__(x))) +#endif + +#ifndef __packed +#define __packed __attribute__((__packed__)) +#endif + +#ifndef strlcpy +#define strlcpy(d,s,len) do { \ + strncpy(d,s,len); \ + ((char *)d)[(len) - 1] = 0; \ +} while (0) +#endif + +#endif /* _LIBUSB_GLOBAL_LINUX_H_ */ Modified: head/lib/libusb/usb.h ============================================================================== --- head/lib/libusb/usb.h Wed Mar 13 10:45:36 2013 (r248235) +++ head/lib/libusb/usb.h Wed Mar 13 12:23:14 2013 (r248236) @@ -27,10 +27,11 @@ #ifndef _LIBUSB20_COMPAT_01_H_ #define _LIBUSB20_COMPAT_01_H_ +#ifndef LIBUSB_GLOBAL_INCLUDE_FILE +#include #include #include - -#include +#endif /* USB interface class codes */ Modified: head/usr.sbin/usbconfig/usbconfig.c ============================================================================== --- head/usr.sbin/usbconfig/usbconfig.c Wed Mar 13 10:45:36 2013 (r248235) +++ head/usr.sbin/usbconfig/usbconfig.c Wed Mar 13 12:23:14 2013 (r248236) @@ -33,6 +33,7 @@ #include #include #include +#include #include #include