mirror of
https://github.com/upa/mscp.git
synced 2026-02-04 03:24:58 +08:00
add htonll and ntohll
This commit is contained in:
@@ -91,11 +91,14 @@ endif()
|
||||
|
||||
|
||||
# Symbol check
|
||||
check_symbol_exists(strlcat string.h HAVE_STRLCAT)
|
||||
check_symbol_exists(htonll arpa/inet.h HAVE_HTONLL)
|
||||
check_symbol_exists(ntohll arpa/inet.h HAVE_NTOHLL)
|
||||
check_symbol_exists(strlcat string.h HAVE_STRLCAT)
|
||||
if (NOT HAVE_STRLCAT)
|
||||
list(APPEND OPENBSD_COMPAT_SRC src/openbsd-compat/strlcat.c)
|
||||
endif()
|
||||
|
||||
|
||||
# generate config.h in build dir
|
||||
configure_file(
|
||||
${mscp_SOURCE_DIR}/include/config.h.in
|
||||
|
||||
@@ -9,4 +9,17 @@
|
||||
/* Define to 1 if you have the strlcat function. */
|
||||
#cmakedefine HAVE_STRLCAT 1
|
||||
|
||||
/* Define to 1 if you have the htonll function. */
|
||||
#cmakedefine HAVE_HTONLL 1
|
||||
|
||||
/* Define to 1 if you have the ntohll function. */
|
||||
#cmakedefine HAVE_NTOHLL 1
|
||||
|
||||
/* Define to 1 if you have the bswap_64 function. */
|
||||
#cmakedefine HAVE_BSWAP_64 1
|
||||
|
||||
/* Define to 1 if you have the bswap64 function. */
|
||||
#cmakedefine HAVE_BSWAP64 1
|
||||
|
||||
|
||||
#endif /* _CONFIG_H_ */
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#error unsupported platform
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
#include <platform.h>
|
||||
#include <strerrno.h>
|
||||
#include <print.h>
|
||||
@@ -163,3 +164,5 @@ int sem_release(sem_t *sem)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int nr_cpus(void);
|
||||
int set_thread_affinity(pthread_t tid, int core);
|
||||
@@ -20,4 +21,28 @@ int setutimes(const char *path, struct timespec atime, struct timespec mtime);
|
||||
sem_t *sem_create(int value);
|
||||
int sem_release(sem_t *sem);
|
||||
|
||||
|
||||
#ifdef HAVE_HTONLL
|
||||
#include <arpa/inet.h> /* Apple has htonll and ntohll in arpa/inet.h */
|
||||
#endif
|
||||
|
||||
/* copied from libssh: libssh/include/libssh/priv.h*/
|
||||
#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
|
||||
|
||||
#endif /* _PLATFORM_H_ */
|
||||
|
||||
Reference in New Issue
Block a user