ftdi: use "adapter usb location" instead of ftdi_location command
[fw/openocd] / src / helper / replacements.h
index bdd3ae7c0d7d7377c8cf0305f29403e2f6534be6..ac5009549a347166f035b4f71e32ffea1814d388 100644 (file)
  *   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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
-#ifndef REPLACEMENTS_H
-#define REPLACEMENTS_H
+#ifndef OPENOCD_HELPER_REPLACEMENTS_H
+#define OPENOCD_HELPER_REPLACEMENTS_H
+
+#include <stdint.h>
 
 /* MIN,MAX macros */
 #ifndef MIN
@@ -135,12 +135,9 @@ static inline unsigned usleep(unsigned int usecs)
 /* Windows specific */
 #ifdef _WIN32
 
-#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <time.h>
 
-#include <helper/types.h>
-
 /* Windows does not declare sockaddr_un */
 #define UNIX_PATH_LEN 108
 struct sockaddr_un {
@@ -204,6 +201,17 @@ static inline int close_socket(int sock)
 #endif
 }
 
+static inline void socket_block(int fd)
+{
+#ifdef _WIN32
+       unsigned long nonblock = 0;
+       ioctlsocket(fd, FIONBIO, &nonblock);
+#else
+       int oldopts = fcntl(fd, F_GETFL, 0);
+       fcntl(fd, F_SETFL, oldopts & ~O_NONBLOCK);
+#endif
+}
+
 static inline void socket_nonblock(int fd)
 {
 #ifdef _WIN32
@@ -230,8 +238,6 @@ static inline int socket_select(int max_fd,
 
 #ifndef HAVE_ELF_H
 
-#include <helper/types.h>
-
 typedef uint32_t Elf32_Addr;
 typedef uint16_t Elf32_Half;
 typedef uint32_t Elf32_Off;
@@ -283,4 +289,8 @@ typedef struct {
 
 #endif /* HAVE_ELF_H */
 
-#endif /* REPLACEMENTS_H */
+#if defined HAVE_LIBUSB1 && !defined HAVE_LIBUSB_ERROR_NAME
+const char *libusb_error_name(int error_code);
+#endif /* defined HAVE_LIBUSB1 && !defined HAVE_LIBUSB_ERROR_NAME */
+
+#endif /* OPENOCD_HELPER_REPLACEMENTS_H */