1
1

misc: Use simpler macros for htonll and ntohll

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
Andreas Schneider 2016-11-07 09:39:19 +01:00
родитель 639dc3b5fd
Коммит 52efbc3a23
3 изменённых файлов: 18 добавлений и 26 удалений

Просмотреть файл

@ -33,15 +33,6 @@ int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2);
int ssh_is_ipaddr_v4(const char *str);
int ssh_is_ipaddr(const char *str);
#ifndef HAVE_NTOHLL
/* macro for byte ordering */
uint64_t ntohll(uint64_t);
#endif
#ifndef HAVE_HTONLL
#define htonll(x) ntohll((x))
#endif
/* list processing */
struct ssh_list {

Просмотреть файл

@ -361,6 +361,24 @@ int ssh_connector_remove_event(ssh_connector connector);
#define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0)
#ifndef HAVE_HTONLL
# ifdef WORDS_BIGENDIAN
# define htonll(x) (x)
# else
# define htonll(x) \
(((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
# endif
#endif
#ifndef HAVE_NTOHLL
# ifdef WORDS_BIGENDIAN
# define ntohll(x) (x)
# else
# define ntohll(x) \
(((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
# endif
#endif
void ssh_agent_state_free(void *data);
#endif /* _LIBSSH_PRIV_H */

Просмотреть файл

@ -290,23 +290,6 @@ int ssh_is_ipaddr(const char *str) {
#endif /* _WIN32 */
#ifndef HAVE_NTOHLL
uint64_t ntohll(uint64_t a) {
#ifdef WORDS_BIGENDIAN
return a;
#else /* WORDS_BIGENDIAN */
return (((uint64_t)(a) << 56) | \
(((uint64_t)(a) << 40) & 0xff000000000000ULL) | \
(((uint64_t)(a) << 24) & 0xff0000000000ULL) | \
(((uint64_t)(a) << 8) & 0xff00000000ULL) | \
(((uint64_t)(a) >> 8) & 0xff000000ULL) | \
(((uint64_t)(a) >> 24) & 0xff0000ULL) | \
(((uint64_t)(a) >> 40) & 0xff00ULL) | \
((uint64_t)(a) >> 56));
#endif /* WORDS_BIGENDIAN */
}
#endif /* HAVE_NTOHLL */
char *ssh_lowercase(const char* str) {
char *new, *p;