From acf61c4f523e2e563468a8cfc591a0082f2750ad Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Thu, 17 Jul 2008 19:27:51 +0200 Subject: [PATCH] Include minimal definition of htonll and ntohll in compat.h; remove {hton,ntoh}ll.[ch] --- compat.h | 24 +++++++++++++------ htonll.c | 71 -------------------------------------------------------- htonll.h | 48 -------------------------------------- net.c | 31 ------------------------- ntohll.c | 71 -------------------------------------------------------- ntohll.h | 49 -------------------------------------- 6 files changed, 17 insertions(+), 277 deletions(-) delete mode 100644 htonll.c delete mode 100644 htonll.h delete mode 100644 ntohll.c delete mode 100644 ntohll.h diff --git a/compat.h b/compat.h index 4bd5c68..9a6d619 100644 --- a/compat.h +++ b/compat.h @@ -22,6 +22,23 @@ * backuppcd-bugs@psislidell.com */ +#ifndef HAVE_HTONLL +#include +#ifdef _BIG_ENDIAN +htonll(x) (x) +#else +#define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl(x >> 32)) +#endif +#endif + +#ifndef HAVE_NTOHLL +#include +#ifdef _BIG_ENDIAN +#define ntohll(x) (x) +#else +#define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl(x >> 32)) +#endif +#endif #ifndef RSK_COMPAT_H #define RSK_COMPAT_H @@ -105,13 +122,6 @@ typedef int socklen_t; #endif #endif -#ifndef HAVE_HTONLL -#include "htonll.h" -#endif - -#ifndef HAVE_NTOHLL -#include "ntohll.h" -#endif #ifndef HAVE_STRSEP #include "strsep.h" diff --git a/htonll.c b/htonll.c deleted file mode 100644 index 8a2f12e..0000000 --- a/htonll.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2005 Roy Keene - * - * 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 - * of the License, 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Author Information - * Roy Keene - * Planning Systems Inc - * Slidell, LA - * backuppcd-bugs@psislidell.com - */ - -#include "compat.h" - -#ifndef HAVE_HTONLL - -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_INTTYPES_H -#include -#endif -#ifdef HAVE_ENDIAN_H -#include -#endif - -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN 4321 -#endif -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN 1234 -#endif - -#ifndef __BYTE_ORDER -#ifdef WORDS_BIGENDIAN -#define __BYTE_ORDER __BIG_ENDIAN -#else -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif -#endif - -#include "htonll.h" - -uint64_t htonll(uint64_t n) { - uint64_t retval; - -#if __BYTE_ORDER == __BIG_ENDIAN - retval = n; -#else - retval = ((uint64_t) htonl(n & 0xFFFFFFFFLLU)) << 32; - retval |= htonl((n & 0xFFFFFFFF00000000LLU) >> 32); -#endif - return(retval); -} - -#endif diff --git a/htonll.h b/htonll.h deleted file mode 100644 index b70652d..0000000 --- a/htonll.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2005 Roy Keene - * - * 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 - * of the License, 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Author Information - * Roy Keene - * Planning Systems Inc - * Slidell, LA - * backuppcd-bugs@psislidell.com - */ - -#ifndef _RSK_HTONLL_H -#define _RSK_HTONLL_H - -#include "compat.h" - -#ifndef HAVE_HTONLL - -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_INTTYPES_H -#include -#endif -#ifdef HAVE_ENDIAN_H -#include -#endif - -uint64_t htonll(uint64_t n); - -#endif -#endif diff --git a/net.c b/net.c index 41b0afb..3fc41cc 100644 --- a/net.c +++ b/net.c @@ -47,37 +47,6 @@ #define SHUT_RDWR 2 #endif -#ifndef HAVE_HTONLL -uint64_t htonll(uint64_t n) { - uint64_t retval; - -#if __BYTE_ORDER == __BIG_ENDIAN - retval = n; -#else - retval = ((uint64_t) htonl(n & 0xFFFFFFFFLLU)) << 32; - retval |= htonl((n & 0xFFFFFFFF00000000LLU) >> 32); -#endif - return(retval); -} -#endif - -#ifndef HAVE_NTOHLL - -uint64_t ntohll(uint64_t n) { - uint64_t retval; - -#if __BYTE_ORDER == __BIG_ENDIAN - retval = n; -#else - retval = ((uint64_t) ntohl(n & 0xFFFFFFFFLLU)) << 32; - retval |= ntohl((n & 0xFFFFFFFF00000000LLU) >> 32); -#endif - return(retval); -} - -#endif - - /* Do things required for network access. */ static int net_init(void) { #ifdef _USE_WIN32_ diff --git a/ntohll.c b/ntohll.c deleted file mode 100644 index a42af8c..0000000 --- a/ntohll.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2005 Roy Keene - * - * 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 - * of the License, 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Author Information - * Roy Keene - * Planning Systems Inc - * Slidell, LA - * backuppcd-bugs@psislidell.com - */ - -#include "compat.h" - -#ifndef HAVE_NTOHLL - -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_INTTYPES_H -#include -#endif -#ifdef HAVE_ENDIAN_H -#include -#endif - -#ifndef __BIG_ENDIAN -#define __BIG_ENDIAN 4321 -#endif -#ifndef __LITTLE_ENDIAN -#define __LITTLE_ENDIAN 1234 -#endif - -#ifndef __BYTE_ORDER -#ifdef WORDS_BIGENDIAN -#define __BYTE_ORDER __BIG_ENDIAN -#else -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif -#endif - -#include "ntohll.h" - -uint64_t ntohll(uint64_t n) { - uint64_t retval; - -#if __BYTE_ORDER == __BIG_ENDIAN - retval = n; -#else - retval = ((uint64_t) ntohl(n & 0xFFFFFFFFLLU)) << 32; - retval |= ntohl((n & 0xFFFFFFFF00000000LLU) >> 32); -#endif - return(retval); -} - -#endif diff --git a/ntohll.h b/ntohll.h deleted file mode 100644 index 4f5c02f..0000000 --- a/ntohll.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005 Roy Keene - * - * 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 - * of the License, 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Author Information - * Roy Keene - * Planning Systems Inc - * Slidell, LA - * backuppcd-bugs@psislidell.com - */ - - -#ifndef _RSK_NTOHLL_H -#define _RSK_NTOHLL_H - -#include "compat.h" - -#ifndef HAVE_NTOHLL - -#ifdef HAVE_NETINET_IN_H -#include -#endif -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_INTTYPES_H -#include -#endif -#ifdef HAVE_ENDIAN_H -#include -#endif - -uint64_t ntohll(uint64_t n); - -#endif -#endif -- 2.39.5