diff --git a/android-tools-adb8/DESCR b/android-tools-adb8/DESCR new file mode 100644 index 0000000000..85bb74ed91 --- /dev/null +++ b/android-tools-adb8/DESCR @@ -0,0 +1,3 @@ +Android Debug Bridge (adb) is a versatile command line tool that +lets you communicate with an emulator instance or connected +Android-powered device. diff --git a/android-tools-adb8/Makefile b/android-tools-adb8/Makefile new file mode 100644 index 0000000000..cc96bf5307 --- /dev/null +++ b/android-tools-adb8/Makefile @@ -0,0 +1,39 @@ +# $NetBSD: Makefile,v 1.4 2015/03/07 21:39:40 tnn2 Exp $ + +MASTER_SITES= https://github.com/android/ +DISTNAME= ${GITHUB_PROJECT}-${GITHUB_TAG} +PKGNAME= android-tools-adb-8.0.0.r11 +CATEGORIES= devel +GITHUB_PROJECT= platform_system_core +GITHUB_TAG= android-8.0.0_r11 + +MAINTAINER= pkgsrc-users@NetBSD.org +HOMEPAGE= https://developer.android.com/tools/help/adb.html +COMMENT= Android debug bridge command line tool +LICENSE= apache-2.0 + +WRKSRC= ${WRKDIR}/${DISTNAME} +USE_LANGUAGES= c gnu++14 + +#CPPFLAGS+= -I${BUILDLINK_PREFIX.libusb1}/include/libusb-1.0 + +CPPFLAGS+= -I${BUILDLINK_PREFIX.boringssl}/bssl/include +CPPFLAGS+= -L${BUILDLINK_PREFIX.boringssl}/bssl + +CFLAGS=-DADB_REVISION=${PKGNAME_NOREV} + +INSTALLATION_DIRS+= bin + +post-extract: + ${CP} ${FILESDIR}/Makefile ${WRKSRC} + ${CP} ${FILESDIR}/adb-Makefile ${WRKSRC}/adb/Makefile + ${CP} ${FILESDIR}/adb-client-Makefile ${WRKSRC}/adb/client/Makefile + ${CP} ${FILESDIR}/libcutils-Makefile ${WRKSRC}/libcutils/Makefile + ${CP} ${FILESDIR}/base-Makefile ${WRKSRC}/base/Makefile + ${CP} ${FILESDIR}/stdatomic.h ${WRKSRC}/libcutils/include + + +.include "../../devel/libusb1/buildlink3.mk" +.include "../../wip/boringssl/buildlink3.mk" +.include "../../devel/googletest/buildlink3.mk" +.include "../../mk/bsd.pkg.mk" diff --git a/android-tools-adb8/PLIST b/android-tools-adb8/PLIST new file mode 100644 index 0000000000..9cbe66cbe1 --- /dev/null +++ b/android-tools-adb8/PLIST @@ -0,0 +1,2 @@ +@comment $NetBSD: PLIST,v 1.1 2015/02/28 18:09:32 tnn2 Exp $ +bin/adb diff --git a/android-tools-adb8/TODO b/android-tools-adb8/TODO new file mode 100644 index 0000000000..8580f12a4a --- /dev/null +++ b/android-tools-adb8/TODO @@ -0,0 +1,3 @@ +- Descend into adb/client (right now cd'ing and running 'make') +- Endless build errors +- XXXs in adb/client makefile diff --git a/android-tools-adb8/distinfo b/android-tools-adb8/distinfo new file mode 100644 index 0000000000..7724d60955 --- /dev/null +++ b/android-tools-adb8/distinfo @@ -0,0 +1,14 @@ +$NetBSD: distinfo,v 1.2 2015/03/07 16:28:33 tnn2 Exp $ + +SHA1 (platform_system_core-android-8.0.0_r11.tar.gz) = ef1b57388986847856551561def54e16176ab27c +RMD160 (platform_system_core-android-8.0.0_r11.tar.gz) = c7128987d8046f485eedc59d969fc110a4c5db3e +SHA512 (platform_system_core-android-8.0.0_r11.tar.gz) = d1c8757d9bc4d8f8b32b9353946a45de2bfea6349af733240b70dc3e29d75196ecb0d95fe9357bf804d0ddc8e160f218b352108341e81ed8d45503fcaf6f3106 +Size (platform_system_core-android-8.0.0_r11.tar.gz) = 5115425 bytes +SHA1 (patch-adb_adb.h) = ebe4534fda180cbe55be6476ebd3ae7cd4b0d4ff +SHA1 (patch-adb_adb__trace.h) = dc5454ae819159651d323e223c49def04c3897f4 +SHA1 (patch-adb_client_usb__libusb.cpp) = 97f99fad0a9b7660b42509562320223a66b4647f +SHA1 (patch-adb_shell__service.cpp) = 9f0b154117c71054f04aa7fa1fecde43599cc3fa +SHA1 (patch-adb_shell__service.h) = 2a81cf808092598d6c7e065ed14bf4c502b322c2 +SHA1 (patch-base_file.cpp) = b9e4afc690834990398461354f16a29b447d00c9 +SHA1 (patch-base_logging.cpp) = 9497504937cdad468c9438cce0327a05b105c434 +SHA1 (patch-sysdeps.h) = 5e4626599f8d5a0ca1d8151c0abee7bf376a95bc diff --git a/android-tools-adb8/files/Makefile b/android-tools-adb8/files/Makefile new file mode 100644 index 0000000000..c32639a825 --- /dev/null +++ b/android-tools-adb8/files/Makefile @@ -0,0 +1,3 @@ +SUBDIR= libcutils base adb + +.include diff --git a/android-tools-adb8/files/Makefile.old b/android-tools-adb8/files/Makefile.old new file mode 100644 index 0000000000..8945f2f7b1 --- /dev/null +++ b/android-tools-adb8/files/Makefile.old @@ -0,0 +1,75 @@ +SRCS+= adb.c +SRCS+= console.c +SRCS+= transport.c +SRCS+= transport_local.c +SRCS+= transport_usb.c +SRCS+= commandline.c +SRCS+= adb_client.c +SRCS+= adb_auth_host.c +SRCS+= sockets.c +SRCS+= services.c +SRCS+= file_sync_client.c +SRCS+= fdevent.c +SRCS+= get_my_path_linux.c +SRCS+= usb_linux.c +#SRCS+= usb_vendors.c +#SRCS+= utils.c + +VPATH+= ../libcutils +#SRCS+= abort_socket.c +SRCS+= socket_inaddr_any_server.c +SRCS+= socket_local_client.c +SRCS+= socket_local_server.c +SRCS+= socket_loopback_client.c +SRCS+= socket_loopback_server.c +SRCS+= socket_network_client.c + +VPATH+= ../libzipfile +SRCS+= centraldir.c +SRCS+= zipfile.c + +#VPATH+= ../../../external/zlib +#SRCS+= adler32.c +#SRCS+= compress.c +#SRCS+= crc32.c +#SRCS+= deflate.c +#SRCS+= infback.c +#SRCS+= inffast.c +#SRCS+= inflate.c +#SRCS+= inftrees.c +#SRCS+= trees.c +#SRCS+= uncompr.c +#SRCS+= zutil.c + +VPATH+=../libcutils +SRCS+=load_file.c + +CPPFLAGS+= -DADB_HOST=1 +CPPFLAGS+= -DHAVE_FORKEXEC=1 +CPPFLAGS+= -DHAVE_SYMLINKS +CPPFLAGS+= -DHAVE_TERMIO_H +CPPFLAGS+= -D_GNU_SOURCE +CPPFLAGS+= -D_XOPEN_SOURCE +CPPFLAGS+= -I. +CPPFLAGS+= -I../base/include +CPPFLAGS+= -I../libcutils/include +CPPFLAGS+= -I../libutils/include +#CPPFLAGS+= -I../../../external/zlib + +CFLAGS+= -O2 -g -Wall -Wno-unused-parameter +LDFLAGS= #-static +LIBS= -lrt -lpthread -lcrypto -lssl -lz + +TOOLCHAIN= +CC= $(TOOLCHAIN)gcc +LD= $(TOOLCHAIN)gcc + +OBJS= $(SRCS:.c=.o) + +all: adb + +adb: $(OBJS) + $(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) + +clean: + rm -rf $(OBJS) diff --git a/android-tools-adb8/files/adb-Makefile b/android-tools-adb8/files/adb-Makefile new file mode 100644 index 0000000000..c2473a9076 --- /dev/null +++ b/android-tools-adb8/files/adb-Makefile @@ -0,0 +1,49 @@ +SUBDIR= client +NOMAN= #defined + +.include + + +LIB= adb + +SRCS= adb.cpp adb_auth_host.cpp adb_client.cpp adb_io.cpp +SRCS+= adb_listeners.cpp adb_trace.cpp adb_utils.cpp +SRCS+= bugreport.cpp +SRCS+= commandline.cpp console.cpp diagnose_usb.cpp fdevent.cpp +SRCS+= jdwp_service.cpp line_printer.cpp services.cpp +SRCS+= socket_spec.cpp +SRCS+= sockets.cpp shell_service.cpp file_sync_client.cpp transport_usb.cpp +SRCS+= sysdeps_unix.cpp transport.cpp transport_local.cpp transport_mdns.cpp +SRCS+= client/main.cpp + + +CPPFLAGS+= -DADB_HOST=1 +CPPFLAGS+= -DHAVE_FORKEXEC=1 +CPPFLAGS+= -DHAVE_SYMLINKS +CPPFLAGS+= -DHAVE_TERMIO_H +CPPFLAGS+= -DADB_REVISION=11 +CPPFLAGS+= -I. +CPPFLAGS+= -I../include +CPPFLAGS+= -I../base/include +CPPFLAGS+= -I../libcutils/include +CPPFLAGS+= -I../libutils/include +CPPFLAGS+= -I../libcrypto_utils/include +CPPFLAGS+= -I../fs_mgr/include + +CFLAGS= -O2 -g -Wall +CXXFLAGS= -std=gnu++14 +#LIBS= -lrt -lpthread -lcrypto -lssl -lz + +DPADD+= ${.CURDIR}/../libcutils +DPADD+= ${.CURDIR}/../base + +LDADD+= -L${.CURDIR}/../libcutils -lcutils +LDADD+= -L${.CURDIR}/../base -lbase +LDADD+= -lssl -lcrypto -lpthread + +LDSTATIC= -static + +NOGCCERROR= #defined +NOCLANGERROR= #defined + +.include diff --git a/android-tools-adb8/files/adb-client-Makefile b/android-tools-adb8/files/adb-client-Makefile new file mode 100644 index 0000000000..16ec0fa3f6 --- /dev/null +++ b/android-tools-adb8/files/adb-client-Makefile @@ -0,0 +1,47 @@ +NOMAN= #defined + +.include + +PROG_CXX= adb + +SRCS= usb_libusb.cpp main.cpp + +PREFIX?= /usr/pkg + +CPPFLAGS+= -DADB_HOST=1 +CPPFLAGS+= -DHAVE_FORKEXEC=1 +CPPFLAGS+= -DHAVE_SYMLINKS +CPPFLAGS+= -DHAVE_TERMIO_H +CPPFLAGS+= -DADB_REVISION=11 +CPPFLAGS+= -I${PREFIX}/include +CPPFLAGS+= -I. +CPPFLAGS+= -I../daemon +CPPFLAGS+= -I../ +CPPFLAGS+= -I../../include +CPPFLAGS+= -I../../base/include +CPPFLAGS+= -I../../libcutils/include +CPPFLAGS+= -I../../libutils/include +CPPFLAGS+= -I../../libcrypto_utils/include +CPPFLAGS+= -I../../fs_mgr/include + +CFLAGS= -O2 -g -Wall +CXXFLAGS= -std=gnu++14 +#LIBS= -lrt -lpthread -lcrypto -lssl -lz + +DPADD+= ${.CURDIR}/../../libcutils +DPADD+= ${.CURDIR}/../../base +DPADD+= ${.CURDIR}/.. + +LDADD+= -L${.CURDIR}/../../libcutils -lcutils +LDADD+= -L${.CURDIR}/../../base -lbase +LDADD+= -L${.CURDIR}/../../adb -ladb +LDADD+= -L${PREFIX}/bssl/lib # XXX +LDADD+= -L${PREFIX}/lib #XXX! +LDADD+= -lssl -lcrypto -lpthread -lusb-1.0 -ldns_sd + +LDSTATIC= -static + +NOGCCERROR= #defined +NOCLANGERROR= #defined + +.include diff --git a/android-tools-adb8/files/base-Makefile b/android-tools-adb8/files/base-Makefile new file mode 100644 index 0000000000..25bbb982f7 --- /dev/null +++ b/android-tools-adb8/files/base-Makefile @@ -0,0 +1,27 @@ +NOMAN= #defined + +.include + +LIB= base +SRCS= parsenetaddress.cpp +SRCS+= file.cpp logging.cpp stringprintf.cpp strings.cpp quick_exit.cpp + +CPPFLAGS+= -DADB_HOST=1 +CPPFLAGS+= -DHAVE_FORKEXEC=1 +CPPFLAGS+= -DHAVE_SYMLINKS +CPPFLAGS+= -DHAVE_TERMIO_H +CPPFLAGS+= -DADB_REVISION=11 +CPPFLAGS+= -I. +CPPFLAGS+= -I../base/include +CPPFLAGS+= -Iinclude +CPPFLAGS+= -I../libutils/include +CPPFLAGS+= -I../libcrypto_utils/include + +CFLAGS= -O2 -g -Wall +CXXFLAGS= -std=gnu++14 +LIBS= -lrt -lpthread -lcrypto -lssl -lz + +NOGCCERROR= #defined +NOCLANGERROR= #defined + +.include diff --git a/android-tools-adb8/files/libcutils-Makefile b/android-tools-adb8/files/libcutils-Makefile new file mode 100644 index 0000000000..ba98d81442 --- /dev/null +++ b/android-tools-adb8/files/libcutils-Makefile @@ -0,0 +1,32 @@ +NOMAN= #defined + +.include + +LIB= cutils + +SRCS+= socket_inaddr_any_server_unix.c +SRCS+= socket_local_client_unix.c +SRCS+= socket_local_server_unix.c +SRCS+= socket_loopback_server_unix.c +SRCS+= socket_network_client_unix.c +SRCS+= load_file.c sockets.cpp + +CPPFLAGS+= -DADB_HOST=1 +CPPFLAGS+= -DHAVE_FORKEXEC=1 +CPPFLAGS+= -DHAVE_SYMLINKS +CPPFLAGS+= -DHAVE_TERMIO_H +CPPFLAGS+= -DADB_REVISION=11 +CPPFLAGS+= -I. +CPPFLAGS+= -I../base/include +CPPFLAGS+= -Iinclude +CPPFLAGS+= -I../libutils/include +CPPFLAGS+= -I../libcrypto_utils/include + +CFLAGS= -O2 -g -Wall +CXXFLAGS= -std=gnu++14 +LIBS= -lrt -lpthread -lcrypto -lssl -lz + +NOGCCERROR= #defined +NOCLANGERROR= #defined + +.include diff --git a/android-tools-adb8/files/stdatomic.h b/android-tools-adb8/files/stdatomic.h new file mode 100644 index 0000000000..263f34a978 --- /dev/null +++ b/android-tools-adb8/files/stdatomic.h @@ -0,0 +1,409 @@ +/*- + * Copyright (c) 2011 Ed Schouten + * David Chisnall + * 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. + * + * $FreeBSD$ + */ + +#ifndef _STDATOMIC_H_ +#define _STDATOMIC_H_ + +#include + +#if __GNUC_PREREQ__(4, 7) +#define __GNUC_ATOMICS +#elif defined(__GNUC__) +#define __CLANG_ATOMICS +#else +#error "stdatomic.h does not support your compiler" +#endif + +#define _Atomic(T) struct { T volatile __val; } + +/* + * 7.17.1 Atomic lock-free macros. + */ + +#ifdef __GCC_ATOMIC_BOOL_LOCK_FREE +#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR_LOCK_FREE +#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_SHORT_LOCK_FREE +#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_INT_LOCK_FREE +#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LONG_LOCK_FREE +#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_LLONG_LOCK_FREE +#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE +#endif +#ifdef __GCC_ATOMIC_POINTER_LOCK_FREE +#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE +#endif + +/* + * 7.17.2 Initialization. + */ + +#if defined(__CLANG_ATOMICS) +#define ATOMIC_VAR_INIT(value) (value) +#define atomic_init(obj, value) __c11_atomic_init(obj, value) +#endif + +/* + * Clang and recent GCC both provide predefined macros for the memory + * orderings. If we are using a compiler that doesn't define them, use the + * clang values - these will be ignored in the fallback path. + */ + +#ifndef __ATOMIC_RELAXED +#define __ATOMIC_RELAXED 0 +#endif +#ifndef __ATOMIC_CONSUME +#define __ATOMIC_CONSUME 1 +#endif +#ifndef __ATOMIC_ACQUIRE +#define __ATOMIC_ACQUIRE 2 +#endif +#ifndef __ATOMIC_RELEASE +#define __ATOMIC_RELEASE 3 +#endif +#ifndef __ATOMIC_ACQ_REL +#define __ATOMIC_ACQ_REL 4 +#endif +#ifndef __ATOMIC_SEQ_CST +#define __ATOMIC_SEQ_CST 5 +#endif + +/* + * 7.17.3 Order and consistency. + * + * The memory_order_* constants that denote the barrier behaviour of the + * atomic operations. + */ + +typedef enum { + memory_order_relaxed = __ATOMIC_RELAXED, + memory_order_consume = __ATOMIC_CONSUME, + memory_order_acquire = __ATOMIC_ACQUIRE, + memory_order_release = __ATOMIC_RELEASE, + memory_order_acq_rel = __ATOMIC_ACQ_REL, + memory_order_seq_cst = __ATOMIC_SEQ_CST +} memory_order; + +/* + * 7.17.4 Fences. + */ + +static __inline void +atomic_thread_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_thread_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_thread_fence(__order); +#else + __sync_synchronize(); +#endif +} + +static __inline void +atomic_signal_fence(memory_order __order __unused) +{ + +#ifdef __CLANG_ATOMICS + __c11_atomic_signal_fence(__order); +#elif defined(__GNUC_ATOMICS) + __atomic_signal_fence(__order); +#else + __asm volatile ("" ::: "memory"); +#endif +} + +/* + * 7.17.5 Lock-free property. + */ + +#if defined(_KERNEL) +/* Atomics in kernelspace are always lock-free. */ +#define atomic_is_lock_free(obj) \ + ((void)(obj), (bool)1) +#elif defined(__CLANG_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof(*(obj)), obj) +#elif defined(__GNUC_ATOMICS) +#define atomic_is_lock_free(obj) \ + __atomic_is_lock_free(sizeof((obj)->__val), &(obj)->__val) +#else +#define atomic_is_lock_free(obj) \ + ((void)(obj), sizeof((obj)->__val) <= sizeof(void *)) +#endif + +/* + * 7.17.6 Atomic integer types. + */ + +typedef _Atomic(bool) atomic_bool; +typedef _Atomic(char) atomic_char; +typedef _Atomic(signed char) atomic_schar; +typedef _Atomic(unsigned char) atomic_uchar; +typedef _Atomic(short) atomic_short; +typedef _Atomic(unsigned short) atomic_ushort; +typedef _Atomic(int) atomic_int; +typedef _Atomic(unsigned int) atomic_uint; +typedef _Atomic(long) atomic_long; +typedef _Atomic(unsigned long) atomic_ulong; +typedef _Atomic(long long) atomic_llong; +typedef _Atomic(unsigned long long) atomic_ullong; +typedef _Atomic(char16_t) atomic_char16_t; +typedef _Atomic(char32_t) atomic_char32_t; +typedef _Atomic(wchar_t) atomic_wchar_t; +typedef _Atomic(int_least8_t) atomic_int_least8_t; +typedef _Atomic(uint_least8_t) atomic_uint_least8_t; +typedef _Atomic(int_least16_t) atomic_int_least16_t; +typedef _Atomic(uint_least16_t) atomic_uint_least16_t; +typedef _Atomic(int_least32_t) atomic_int_least32_t; +typedef _Atomic(uint_least32_t) atomic_uint_least32_t; +typedef _Atomic(int_least64_t) atomic_int_least64_t; +typedef _Atomic(uint_least64_t) atomic_uint_least64_t; +typedef _Atomic(int_fast8_t) atomic_int_fast8_t; +typedef _Atomic(uint_fast8_t) atomic_uint_fast8_t; +typedef _Atomic(int_fast16_t) atomic_int_fast16_t; +typedef _Atomic(uint_fast16_t) atomic_uint_fast16_t; +typedef _Atomic(int_fast32_t) atomic_int_fast32_t; +typedef _Atomic(uint_fast32_t) atomic_uint_fast32_t; +typedef _Atomic(int_fast64_t) atomic_int_fast64_t; +typedef _Atomic(uint_fast64_t) atomic_uint_fast64_t; +typedef _Atomic(intptr_t) atomic_intptr_t; +typedef _Atomic(uintptr_t) atomic_uintptr_t; +typedef _Atomic(size_t) atomic_size_t; +typedef _Atomic(ptrdiff_t) atomic_ptrdiff_t; +typedef _Atomic(intmax_t) atomic_intmax_t; +typedef _Atomic(uintmax_t) atomic_uintmax_t; + +/* + * 7.17.7 Operations on atomic types. + */ + +/* + * Compiler-specific operations. + */ + +#if defined(__CLANG_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_strong(object, expected, desired, \ + success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __c11_atomic_compare_exchange_weak(object, expected, desired, \ + success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __c11_atomic_exchange(object, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __c11_atomic_fetch_add(object, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __c11_atomic_fetch_and(object, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __c11_atomic_fetch_or(object, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __c11_atomic_fetch_sub(object, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __c11_atomic_fetch_xor(object, operand, order) +#define atomic_load_explicit(object, order) \ + __c11_atomic_load(object, order) +#define atomic_store_explicit(object, desired, order) \ + __c11_atomic_store(object, desired, order) +#elif defined(__GNUC_ATOMICS) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 0, success, failure) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + __atomic_compare_exchange_n(&(object)->__val, expected, \ + desired, 1, success, failure) +#define atomic_exchange_explicit(object, desired, order) \ + __atomic_exchange_n(&(object)->__val, desired, order) +#define atomic_fetch_add_explicit(object, operand, order) \ + __atomic_fetch_add(&(object)->__val, operand, order) +#define atomic_fetch_and_explicit(object, operand, order) \ + __atomic_fetch_and(&(object)->__val, operand, order) +#define atomic_fetch_or_explicit(object, operand, order) \ + __atomic_fetch_or(&(object)->__val, operand, order) +#define atomic_fetch_sub_explicit(object, operand, order) \ + __atomic_fetch_sub(&(object)->__val, operand, order) +#define atomic_fetch_xor_explicit(object, operand, order) \ + __atomic_fetch_xor(&(object)->__val, operand, order) +#define atomic_load_explicit(object, order) \ + __atomic_load_n(&(object)->__val, order) +#define atomic_store_explicit(object, desired, order) \ + __atomic_store_n(&(object)->__val, desired, order) +#else +#define __atomic_apply_stride(object, operand) \ + (((__typeof__((object)->__val))0) + (operand)) +#define atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) __extension__ ({ \ + __typeof__(expected) __ep = (expected); \ + __typeof__(*__ep) __e = *__ep; \ + (void)(success); (void)(failure); \ + (bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \ + __e, desired)) == __e); \ +}) +#define atomic_compare_exchange_weak_explicit(object, expected, \ + desired, success, failure) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, success, failure) +#if __has_builtin(__sync_swap) +/* Clang provides a full-barrier atomic exchange - use it if available. */ +#define atomic_exchange_explicit(object, desired, order) \ + ((void)(order), __sync_swap(&(object)->__val, desired)) +#else +/* + * __sync_lock_test_and_set() is only an acquire barrier in theory (although in + * practice it is usually a full barrier) so we need an explicit barrier before + * it. + */ +#define atomic_exchange_explicit(object, desired, order) \ +__extension__ ({ \ + __typeof__(object) __o = (object); \ + __typeof__(desired) __d = (desired); \ + (void)(order); \ + __sync_synchronize(); \ + __sync_lock_test_and_set(&(__o)->__val, __d); \ +}) +#endif +#define atomic_fetch_add_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_and_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_and(&(object)->__val, operand)) +#define atomic_fetch_or_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_or(&(object)->__val, operand)) +#define atomic_fetch_sub_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_sub(&(object)->__val, \ + __atomic_apply_stride(object, operand))) +#define atomic_fetch_xor_explicit(object, operand, order) \ + ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand)) +#define atomic_load_explicit(object, order) \ + ((void)(order), __sync_fetch_and_add(&(object)->__val, 0)) +#define atomic_store_explicit(object, desired, order) \ + ((void)atomic_exchange_explicit(object, desired, order)) +#endif + +/* + * Convenience functions. + * + * Don't provide these in kernel space. In kernel space, we should be + * disciplined enough to always provide explicit barriers. + */ + +#ifndef _KERNEL +#define atomic_compare_exchange_strong(object, expected, desired) \ + atomic_compare_exchange_strong_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_compare_exchange_weak(object, expected, desired) \ + atomic_compare_exchange_weak_explicit(object, expected, \ + desired, memory_order_seq_cst, memory_order_seq_cst) +#define atomic_exchange(object, desired) \ + atomic_exchange_explicit(object, desired, memory_order_seq_cst) +#define atomic_fetch_add(object, operand) \ + atomic_fetch_add_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_and(object, operand) \ + atomic_fetch_and_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_or(object, operand) \ + atomic_fetch_or_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_sub(object, operand) \ + atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst) +#define atomic_fetch_xor(object, operand) \ + atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst) +#define atomic_load(object) \ + atomic_load_explicit(object, memory_order_seq_cst) +#define atomic_store(object, desired) \ + atomic_store_explicit(object, desired, memory_order_seq_cst) +#endif /* !_KERNEL */ + +/* + * 7.17.8 Atomic flag type and operations. + * + * XXX: Assume atomic_bool can be used as an atomic_flag. Is there some + * kind of compiler built-in type we could use? + */ + +typedef struct { + atomic_bool __flag; +} atomic_flag; + +#ifndef ATOMIC_FLAG_INIT +#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(0) } +#endif + +static __inline bool +atomic_flag_test_and_set_explicit(volatile atomic_flag *__object, + memory_order __order) +{ + return (atomic_exchange_explicit(&__object->__flag, 1, __order)); +} + +static __inline void +atomic_flag_clear_explicit(volatile atomic_flag *__object, memory_order __order) +{ + + atomic_store_explicit(&__object->__flag, 0, __order); +} + +#ifndef _KERNEL +static __inline bool +atomic_flag_test_and_set(volatile atomic_flag *__object) +{ + + return (atomic_flag_test_and_set_explicit(__object, + memory_order_seq_cst)); +} + +static __inline void +atomic_flag_clear(volatile atomic_flag *__object) +{ + + atomic_flag_clear_explicit(__object, memory_order_seq_cst); +} +#endif /* !_KERNEL */ + +#endif /* !_STDATOMIC_H_ */ diff --git a/android-tools-adb8/patches/patch-adb_adb.h b/android-tools-adb8/patches/patch-adb_adb.h new file mode 100644 index 0000000000..e95f021ca3 --- /dev/null +++ b/android-tools-adb8/patches/patch-adb_adb.h @@ -0,0 +1,14 @@ +$NetBSD$ + +--- adb/adb.h.orig 2017-06-27 22:39:52.000000000 +0000 ++++ adb/adb.h +@@ -201,9 +201,7 @@ ConnectionState connection_state(atransp + + extern const char* adb_device_banner; + +-#if !ADB_HOST + extern int SHELL_EXIT_NOTIFY_FD; +-#endif // !ADB_HOST + + #define CHUNK_SIZE (64*1024) + diff --git a/android-tools-adb8/patches/patch-adb_adb__trace.h b/android-tools-adb8/patches/patch-adb_adb__trace.h new file mode 100644 index 0000000000..7c2d98306d --- /dev/null +++ b/android-tools-adb8/patches/patch-adb_adb__trace.h @@ -0,0 +1,18 @@ +$NetBSD$ + +--- adb/adb_trace.h.orig 2017-06-27 22:39:52.000000000 +0000 ++++ adb/adb_trace.h +@@ -50,9 +50,12 @@ enum AdbTrace { + LOG(INFO) + + // You must define TRACE_TAG before using this macro. ++#ifdef ADB_HOST ++#define D(...) /*nothing*/ ++#else + #define D(...) \ + VLOG(TRACE_TAG) << android::base::StringPrintf(__VA_ARGS__) +- ++#endif + + extern int adb_trace_mask; + void adb_trace_init(char**); diff --git a/android-tools-adb8/patches/patch-adb_client_usb__libusb.cpp b/android-tools-adb8/patches/patch-adb_client_usb__libusb.cpp new file mode 100644 index 0000000000..6e2d61c1a7 --- /dev/null +++ b/android-tools-adb8/patches/patch-adb_client_usb__libusb.cpp @@ -0,0 +1,15 @@ +$NetBSD$ + +--- adb/client/usb_libusb.cpp.orig 2017-06-27 22:39:52.000000000 +0000 ++++ adb/client/usb_libusb.cpp +@@ -27,8 +27,9 @@ + #include + #include + #include ++#include + +-#include ++#include + + #include + #include diff --git a/android-tools-adb8/patches/patch-adb_shell__service.cpp b/android-tools-adb8/patches/patch-adb_shell__service.cpp new file mode 100644 index 0000000000..3128239f57 --- /dev/null +++ b/android-tools-adb8/patches/patch-adb_shell__service.cpp @@ -0,0 +1,28 @@ +$NetBSD$ + +--- adb/shell_service.cpp.orig 2017-06-27 22:39:52.000000000 +0000 ++++ adb/shell_service.cpp +@@ -83,9 +83,14 @@ + + #include + #include ++#if defined(__linux__) + #include ++#elif defined(__NetBSD__) ++#include ++#endif + #include + #include ++#include + #include + + #include +@@ -104,6 +109,8 @@ + #include "adb_utils.h" + #include "security_log_tags.h" + ++extern char **environ; ++ + namespace { + + // Reads from |fd| until close or failure. diff --git a/android-tools-adb8/patches/patch-adb_shell__service.h b/android-tools-adb8/patches/patch-adb_shell__service.h new file mode 100644 index 0000000000..cb28222f95 --- /dev/null +++ b/android-tools-adb8/patches/patch-adb_shell__service.h @@ -0,0 +1,13 @@ +$NetBSD$ + +--- adb/shell_service.h.orig 2017-06-27 22:39:52.000000000 +0000 ++++ adb/shell_service.h +@@ -125,7 +125,7 @@ class ShellProtocol { + DISALLOW_COPY_AND_ASSIGN(ShellProtocol); + }; + +-#if !ADB_HOST ++#if 1 //!ADB_HOST + + enum class SubprocessType { + kPty, diff --git a/android-tools-adb8/patches/patch-base_file.cpp b/android-tools-adb8/patches/patch-base_file.cpp new file mode 100644 index 0000000000..63f458ab5f --- /dev/null +++ b/android-tools-adb8/patches/patch-base_file.cpp @@ -0,0 +1,24 @@ +$NetBSD$ + +cstring for strerror. +recognise netbsd as having procfs + +--- base/file.cpp.orig 2017-06-27 22:39:52.000000000 +0000 ++++ base/file.cpp +@@ -26,6 +26,7 @@ + #include + #include + #include ++#include + #include + + #include "android-base/macros.h" // For TEMP_FAILURE_RETRY on Darwin. +@@ -235,7 +236,7 @@ bool Realpath(const std::string& path, s + #endif + + std::string GetExecutablePath() { +-#if defined(__linux__) ++#if defined(__linux__) || defined(__NetBSD__) + std::string path; + android::base::Readlink("/proc/self/exe", &path); + return path; diff --git a/android-tools-adb8/patches/patch-base_logging.cpp b/android-tools-adb8/patches/patch-base_logging.cpp new file mode 100644 index 0000000000..fdf8c7e636 --- /dev/null +++ b/android-tools-adb8/patches/patch-base_logging.cpp @@ -0,0 +1,12 @@ +$NetBSD$ + +--- base/logging.cpp.orig 2017-06-27 22:39:52.000000000 +0000 ++++ base/logging.cpp +@@ -35,6 +35,7 @@ + #include + #endif + ++#include + #include + #include + #include diff --git a/android-tools-adb8/patches/patch-get__my__path__freebsd.c b/android-tools-adb8/patches/patch-get__my__path__freebsd.c new file mode 100644 index 0000000000..81f6c41fa3 --- /dev/null +++ b/android-tools-adb8/patches/patch-get__my__path__freebsd.c @@ -0,0 +1,32 @@ +$NetBSD: patch-get__my__path__freebsd.c,v 1.1 2015/02/28 18:09:32 tnn2 Exp $ + +--- get_my_path_freebsd.c.orig 2014-10-22 00:46:49.000000000 +0000 ++++ get_my_path_freebsd.c +@@ -18,19 +18,18 @@ + */ + + #include ++#include + #include +-#include +-#include + + void + get_my_path(char *exe, size_t maxLen) + { +- char proc[64]; ++ int mib[4] = { ++ CTL_KERN, ++ KERN_PROC, ++ KERN_PROC_PATHNAME, ++ getpid() ++ }; + +- snprintf(proc, sizeof(proc), "/proc/%d/file", getpid()); +- +- int err = readlink(proc, exe, maxLen - 1); +- +- exe[err > 0 ? err : 0] = '\0'; ++ sysctl(mib, 4, exe, &maxLen, NULL, 0); + } +- diff --git a/android-tools-adb8/patches/patch-sysdeps.h b/android-tools-adb8/patches/patch-sysdeps.h new file mode 100644 index 0000000000..69c353e0ed --- /dev/null +++ b/android-tools-adb8/patches/patch-sysdeps.h @@ -0,0 +1,35 @@ +$NetBSD$ + +--- adb/sysdeps.h.orig 2017-06-27 22:39:52.000000000 +0000 ++++ adb/sysdeps.h +@@ -65,11 +65,16 @@ + #endif + #endif + +-#ifdef _WIN32 +- + // Clang-only nullability specifiers ++#ifndef _Nonnull + #define _Nonnull ++#endif ++ ++#ifndef _Nullable + #define _Nullable ++#endif ++ ++#ifdef _WIN32 + + #include + #include +@@ -710,8 +715,10 @@ static __inline__ void __attribute__((no + } + + static __inline__ int adb_thread_setname(const std::string& name) { +-#ifdef __APPLE__ ++#if defined(__APPLE__) + return pthread_setname_np(name.c_str()); ++#elif defined(__NetBSD__) ++ return pthread_setname_np(pthread_self(), name.c_str(), NULL); + #else + const char *s = name.c_str(); + diff --git a/android-tools-adb8/patches/patch-usb__libusb.c b/android-tools-adb8/patches/patch-usb__libusb.c new file mode 100644 index 0000000000..6d24334a8e --- /dev/null +++ b/android-tools-adb8/patches/patch-usb__libusb.c @@ -0,0 +1,64 @@ +$NetBSD: patch-usb__libusb.c,v 1.1 2015/02/28 18:09:32 tnn2 Exp $ + +--- usb_libusb.c.orig 2014-10-22 00:46:49.000000000 +0000 ++++ usb_libusb.c +@@ -37,7 +37,7 @@ + #define TRACE_TAG TRACE_USB + #include "adb.h" + +-static adb_mutex_t usb_lock = ADB_MUTEX_INITIALIZER; ++ADB_MUTEX_DEFINE( usb_lock ); + static libusb_context *ctx = NULL; + + struct usb_handle +@@ -246,8 +246,8 @@ void usb_kick(struct usb_handle *h) + } + + int +-check_usb_interface(libusb_interface *interface, +- libusb_device_descriptor *desc, ++check_usb_interface(struct libusb_interface *interface, ++ struct libusb_device_descriptor *desc, + struct usb_handle *uh) + { + int e; +@@ -257,7 +257,7 @@ check_usb_interface(libusb_interface *in + return -1; + } + +- libusb_interface_descriptor *idesc = &interface->altsetting[0]; ++ const struct libusb_interface_descriptor *idesc = &interface->altsetting[0]; + + if (idesc->bNumEndpoints != 2) { + D("check_usb_interface(): Interface have not 2 endpoints, ignoring\n"); +@@ -265,7 +265,7 @@ check_usb_interface(libusb_interface *in + } + + for (e = 0; e < idesc->bNumEndpoints; e++) { +- libusb_endpoint_descriptor *edesc = &idesc->endpoint[e]; ++ const struct libusb_endpoint_descriptor *edesc = &idesc->endpoint[e]; + + if (edesc->bmAttributes != LIBUSB_TRANSFER_TYPE_BULK) { + D("check_usb_interface(): Endpoint (%u) is not bulk (%u), ignoring\n", +@@ -304,8 +304,8 @@ check_usb_interface(libusb_interface *in + } + + int +-check_usb_interfaces(libusb_config_descriptor *config, +- libusb_device_descriptor *desc, struct usb_handle *uh) ++check_usb_interfaces(struct libusb_config_descriptor *config, ++ struct libusb_device_descriptor *desc, struct usb_handle *uh) + { + int i; + +@@ -382,8 +382,8 @@ check_device(libusb_device *dev) + int found = -1; + char serial[256] = {0}; + +- libusb_device_descriptor desc; +- libusb_config_descriptor *config = NULL; ++ struct libusb_device_descriptor desc; ++ struct libusb_config_descriptor *config = NULL; + + int r = libusb_get_device_descriptor(dev, &desc); +