diff options
53 files changed, 174 insertions, 108 deletions
diff --git a/package/deps.mak b/package/deps.mak index 6210f29..580b8db 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -58,6 +58,7 @@ src/include/skalibs/unixonacid.h: src/include/skalibs/ancil.h src/include/skalib src/libdatastruct/avlnode-internal.h: src/include/skalibs/avlnode.h src/libdatastruct/genqdyn-internal.h: src/include/skalibs/genqdyn.h src/libenvexec/envdir-internal.h: src/include/skalibs/stralloc.h +src/libstdcrypto/blake2s-internal.h: src/include/skalibs/blake2s.h src/libstdcrypto/sha1-internal.h: src/include/skalibs/sha1.h src/libstdcrypto/sha256-internal.h: src/include/skalibs/sha256.h src/libstdcrypto/sha512-internal.h: src/include/skalibs/sha512.h @@ -177,6 +178,10 @@ src/librandom/random_uint32_from.o src/librandom/random_uint32_from.lo: src/libr src/librandom/random_unsort_from.o src/librandom/random_unsort_from.lo: src/librandom/random_unsort_from.c src/include/skalibs/random.h src/librandom/surf.o src/librandom/surf.lo: src/librandom/surf.c src/include/skalibs/surf.h src/include/skalibs/uint32.h src/librandom/surf_init.o src/librandom/surf_init.lo: src/librandom/surf_init.c src/include/skalibs/surf.h src/include/skalibs/uint32.h +src/libstdcrypto/blake2s_final.o src/libstdcrypto/blake2s_final.lo: src/libstdcrypto/blake2s_final.c src/libstdcrypto/blake2s-internal.h src/include/skalibs/blake2s.h src/include/skalibs/uint32.h +src/libstdcrypto/blake2s_init.o src/libstdcrypto/blake2s_init.lo: src/libstdcrypto/blake2s_init.c src/include/skalibs/blake2s.h +src/libstdcrypto/blake2s_transform.o src/libstdcrypto/blake2s_transform.lo: src/libstdcrypto/blake2s_transform.c src/libstdcrypto/blake2s-internal.h src/include/skalibs/blake2s.h src/include/skalibs/uint32.h +src/libstdcrypto/blake2s_update.o src/libstdcrypto/blake2s_update.lo: src/libstdcrypto/blake2s_update.c src/libstdcrypto/blake2s-internal.h src/include/skalibs/blake2s.h src/libstdcrypto/sha1_feed.o src/libstdcrypto/sha1_feed.lo: src/libstdcrypto/sha1_feed.c src/include/skalibs/bytestr.h src/libstdcrypto/sha1-internal.h src/include/skalibs/sha1.h src/libstdcrypto/sha1_final.o src/libstdcrypto/sha1_final.lo: src/libstdcrypto/sha1_final.c src/libstdcrypto/sha1-internal.h src/include/skalibs/sha1.h src/include/skalibs/uint32.h src/libstdcrypto/sha1_init.o src/libstdcrypto/sha1_init.lo: src/libstdcrypto/sha1_init.c src/include/skalibs/sha1.h @@ -499,15 +504,14 @@ src/libstddjb/socket_bind4.o src/libstddjb/socket_bind4.lo: src/libstddjb/socket src/libstddjb/socket_bind4r.o src/libstddjb/socket_bind4r.lo: src/libstddjb/socket_bind4r.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_bind6.o src/libstddjb/socket_bind6.lo: src/libstddjb/socket_bind6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_bind6r.o src/libstddjb/socket_bind6r.lo: src/libstddjb/socket_bind6r.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h -src/libstddjb/socket_conn4.o src/libstddjb/socket_conn4.lo: src/libstddjb/socket_conn4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h -src/libstddjb/socket_conn4_u32.o src/libstddjb/socket_conn4_u32.lo: src/libstddjb/socket_conn4_u32.c src/include/skalibs/socket.h src/include/skalibs/uint32.h -src/libstddjb/socket_conn6.o src/libstddjb/socket_conn6.lo: src/libstddjb/socket_conn6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h +src/libstddjb/socket_connect4.o src/libstddjb/socket_connect4.lo: src/libstddjb/socket_connect4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h +src/libstddjb/socket_connect4_u32.o src/libstddjb/socket_connect4_u32.lo: src/libstddjb/socket_connect4_u32.c src/include/skalibs/socket.h src/include/skalibs/uint32.h +src/libstddjb/socket_connect6.o src/libstddjb/socket_connect6.lo: src/libstddjb/socket_connect6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_connected.o src/libstddjb/socket_connected.lo: src/libstddjb/socket_connected.c src/include/skalibs/allreadwrite.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_deadlineconnstamp4.o src/libstddjb/socket_deadlineconnstamp4.lo: src/libstddjb/socket_deadlineconnstamp4.c src/include/skalibs/error.h src/include/skalibs/socket.h src/libstddjb/socket_deadlineconnstamp46.o src/libstddjb/socket_deadlineconnstamp46.lo: src/libstddjb/socket_deadlineconnstamp46.c src/include/skalibs/error.h src/include/skalibs/ip46.h src/include/skalibs/socket.h src/libstddjb/socket_deadlineconnstamp4_u32.o src/libstddjb/socket_deadlineconnstamp4_u32.lo: src/libstddjb/socket_deadlineconnstamp4_u32.c src/include/skalibs/socket.h src/include/skalibs/uint32.h src/libstddjb/socket_deadlineconnstamp6.o src/libstddjb/socket_deadlineconnstamp6.lo: src/libstddjb/socket_deadlineconnstamp6.c src/include/skalibs/error.h src/include/skalibs/socket.h -src/libstddjb/socket_delay.o src/libstddjb/socket_delay.lo: src/libstddjb/socket_delay.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_internal.o src/libstddjb/socket_internal.lo: src/libstddjb/socket_internal.c src/include/skalibs/djbunix.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/sysdeps.h src/libstddjb/socket_ioloop.o src/libstddjb/socket_ioloop.lo: src/libstddjb/socket_ioloop.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/socket.h src/libstddjb/socket_ioloop_send4.o src/libstddjb/socket_ioloop_send4.lo: src/libstddjb/socket_ioloop_send4.c src/include/skalibs/socket.h @@ -524,8 +528,9 @@ src/libstddjb/socket_send4.o src/libstddjb/socket_send4.lo: src/libstddjb/socket src/libstddjb/socket_send6.o src/libstddjb/socket_send6.lo: src/libstddjb/socket_send6.c src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/include/skalibs/uint16.h src/libstddjb/socket_tcp4.o src/libstddjb/socket_tcp4.lo: src/libstddjb/socket_tcp4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_tcp6.o src/libstddjb/socket_tcp6.lo: src/libstddjb/socket_tcp6.c src/include/skalibs/djbunix.h src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h +src/libstddjb/socket_tcpnodelay.o src/libstddjb/socket_tcpnodelay.lo: src/libstddjb/socket_tcpnodelay.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_timeoutconn.o src/libstddjb/socket_timeoutconn.lo: src/libstddjb/socket_timeoutconn.c src/include/skalibs/socket.h src/include/skalibs/tai.h -src/libstddjb/socket_tryr.o src/libstddjb/socket_tryr.lo: src/libstddjb/socket_tryr.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h +src/libstddjb/socket_tryreservein.o src/libstddjb/socket_tryreservein.lo: src/libstddjb/socket_tryreservein.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_udp4.o src/libstddjb/socket_udp4.lo: src/libstddjb/socket_udp4.c src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_udp6.o src/libstddjb/socket_udp6.lo: src/libstddjb/socket_udp6.c src/include/skalibs/djbunix.h src/include/skalibs/ip46.h src/include/skalibs/nonposix.h src/include/skalibs/socket.h src/libstddjb/socket_waitconn.o src/libstddjb/socket_waitconn.lo: src/libstddjb/socket_waitconn.c src/include/skalibs/allreadwrite.h src/include/skalibs/iopause.h src/include/skalibs/socket.h @@ -636,20 +641,22 @@ src/libstddjb/ucharn_scan_little.o src/libstddjb/ucharn_scan_little.lo: src/libs src/libstddjb/ucspi_get.o src/libstddjb/ucspi_get.lo: src/libstddjb/ucspi_get.c src/include/skalibs/env.h src/libstddjb/uint160_scan.o src/libstddjb/uint160_scan.lo: src/libstddjb/uint160_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/uint16_bswap.o src/libstddjb/uint16_bswap.lo: src/libstddjb/uint16_bswap.c src/include/skalibs/uint16.h +src/libstddjb/uint16_bswapn.o src/libstddjb/uint16_bswapn.lo: src/libstddjb/uint16_bswapn.c src/include/skalibs/uint16.h +src/libstddjb/uint16_bswapp.o src/libstddjb/uint16_bswapp.lo: src/libstddjb/uint16_bswapp.c src/include/skalibs/uint16.h src/libstddjb/uint16_fmtlist.o src/libstddjb/uint16_fmtlist.lo: src/libstddjb/uint16_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/uint16_pack.o src/libstddjb/uint16_pack.lo: src/libstddjb/uint16_pack.c src/include/skalibs/uint16.h src/libstddjb/uint16_pack_big.o src/libstddjb/uint16_pack_big.lo: src/libstddjb/uint16_pack_big.c src/include/skalibs/uint16.h -src/libstddjb/uint16_reverse.o src/libstddjb/uint16_reverse.lo: src/libstddjb/uint16_reverse.c src/include/skalibs/uint16.h src/libstddjb/uint16_scan.o src/libstddjb/uint16_scan.lo: src/libstddjb/uint16_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/include/skalibs/uint64.h src/libstddjb/uint16_scanlist.o src/libstddjb/uint16_scanlist.lo: src/libstddjb/uint16_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint16.h src/libstddjb/uint16_unpack.o src/libstddjb/uint16_unpack.lo: src/libstddjb/uint16_unpack.c src/include/skalibs/uint16.h src/libstddjb/uint16_unpack_big.o src/libstddjb/uint16_unpack_big.lo: src/libstddjb/uint16_unpack_big.c src/include/skalibs/uint16.h src/libstddjb/uint320_scan.o src/libstddjb/uint320_scan.lo: src/libstddjb/uint320_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/uint32_bswap.o src/libstddjb/uint32_bswap.lo: src/libstddjb/uint32_bswap.c src/include/skalibs/uint32.h +src/libstddjb/uint32_bswapn.o src/libstddjb/uint32_bswapn.lo: src/libstddjb/uint32_bswapn.c src/include/skalibs/uint32.h +src/libstddjb/uint32_bswapp.o src/libstddjb/uint32_bswapp.lo: src/libstddjb/uint32_bswapp.c src/include/skalibs/uint32.h src/libstddjb/uint32_fmtlist.o src/libstddjb/uint32_fmtlist.lo: src/libstddjb/uint32_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/uint32_pack.o src/libstddjb/uint32_pack.lo: src/libstddjb/uint32_pack.c src/include/skalibs/uint32.h src/libstddjb/uint32_pack_big.o src/libstddjb/uint32_pack_big.lo: src/libstddjb/uint32_pack_big.c src/include/skalibs/uint32.h -src/libstddjb/uint32_reverse.o src/libstddjb/uint32_reverse.lo: src/libstddjb/uint32_reverse.c src/include/skalibs/uint32.h src/libstddjb/uint32_scan.o src/libstddjb/uint32_scan.lo: src/libstddjb/uint32_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h src/libstddjb/uint32_scanlist.o src/libstddjb/uint32_scanlist.lo: src/libstddjb/uint32_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint32.h src/libstddjb/uint32_unpack.o src/libstddjb/uint32_unpack.lo: src/libstddjb/uint32_unpack.c src/include/skalibs/uint32.h @@ -658,12 +665,13 @@ src/libstddjb/uint640_fmt_generic.o src/libstddjb/uint640_fmt_generic.lo: src/li src/libstddjb/uint640_scan.o src/libstddjb/uint640_scan.lo: src/libstddjb/uint640_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/uint640_scan_base_max.o src/libstddjb/uint640_scan_base_max.lo: src/libstddjb/uint640_scan_base_max.c src/include/skalibs/fmtscan.h src/include/skalibs/uint64.h src/libstddjb/uint64_bswap.o src/libstddjb/uint64_bswap.lo: src/libstddjb/uint64_bswap.c src/include/skalibs/uint64.h +src/libstddjb/uint64_bswapn.o src/libstddjb/uint64_bswapn.lo: src/libstddjb/uint64_bswapn.c src/include/skalibs/uint64.h +src/libstddjb/uint64_bswapp.o src/libstddjb/uint64_bswapp.lo: src/libstddjb/uint64_bswapp.c src/include/skalibs/uint64.h src/libstddjb/uint64_fmt_generic.o src/libstddjb/uint64_fmt_generic.lo: src/libstddjb/uint64_fmt_generic.c src/include/skalibs/fmtscan.h src/include/skalibs/uint64.h src/libstddjb/uint64_fmtlist.o src/libstddjb/uint64_fmtlist.lo: src/libstddjb/uint64_fmtlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/uint64_fmtlist_generic.o src/libstddjb/uint64_fmtlist_generic.lo: src/libstddjb/uint64_fmtlist_generic.c src/include/skalibs/uint64.h src/libstddjb/uint64_pack.o src/libstddjb/uint64_pack.lo: src/libstddjb/uint64_pack.c src/include/skalibs/uint64.h src/libstddjb/uint64_pack_big.o src/libstddjb/uint64_pack_big.lo: src/libstddjb/uint64_pack_big.c src/include/skalibs/uint64.h -src/libstddjb/uint64_reverse.o src/libstddjb/uint64_reverse.lo: src/libstddjb/uint64_reverse.c src/include/skalibs/uint64.h src/libstddjb/uint64_scan.o src/libstddjb/uint64_scan.lo: src/libstddjb/uint64_scan.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h src/libstddjb/uint64_scan_base_max.o src/libstddjb/uint64_scan_base_max.lo: src/libstddjb/uint64_scan_base_max.c src/include/skalibs/fmtscan.h src/include/skalibs/uint64.h src/libstddjb/uint64_scanlist.o src/libstddjb/uint64_scanlist.lo: src/libstddjb/uint64_scanlist.c src/libstddjb/fmtscan-internal.h src/include/skalibs/uint64.h diff --git a/src/headers/bits-bendian b/src/headers/bits-bendian index 6caf1e7..ac1169f 100644 --- a/src/headers/bits-bendian +++ b/src/headers/bits-bendian @@ -1,6 +1,8 @@ -#define uint@BITS@_little_endian(s, n) uint@BITS@_reverse((s), (n)) -#define uint@BITS@_big_endian(s, n) - #define uint@BITS@_little(u) uint@BITS@_bswap(u) #define uint@BITS@_big(u) (u) +#define uint@BITS@_littlep(u) uint@BITS@_bswapp(u) +#define uint@BITS@_bigp(u) + +#define uint@BITS@_littlen(array, n) uint@BITS@_bswapn(array, n) +#define uint@BITS@_bign(array, n) diff --git a/src/headers/bits-lendian b/src/headers/bits-lendian index 7528d46..e2358d3 100644 --- a/src/headers/bits-lendian +++ b/src/headers/bits-lendian @@ -1,6 +1,9 @@ -#define uint@BITS@_little_endian(s, n) -#define uint@BITS@_big_endian(s, n) uint@BITS@_reverse((s), (n)) - #define uint@BITS@_little(u) (u) #define uint@BITS@_big(u) uint@BITS@_bswap(u) +#define uint@BITS@_littlep(u) +#define uint@BITS@_bigp(u) uint@BITS@_bswapp(u) + +#define uint@BITS@_littlen(array, n) +#define uint@BITS@_bign(array, n) uint@BITS@_bswapn(array, n) + diff --git a/src/headers/bits-template b/src/headers/bits-template index f6cde95..306076d 100644 --- a/src/headers/bits-template +++ b/src/headers/bits-template @@ -2,8 +2,9 @@ extern void uint@BITS@_pack (char *, uint@BITS@_t) ; extern void uint@BITS@_pack_big (char *, uint@BITS@_t) ; extern void uint@BITS@_unpack (char const *, uint@BITS@_t *) ; extern void uint@BITS@_unpack_big (char const *, uint@BITS@_t *) ; -extern void uint@BITS@_reverse (char *, size_t) ; extern uint@BITS@_t uint@BITS@_bswap (uint@BITS@_t) ; +extern void uint@BITS@_bswapp (uint@BITS@_t *) ; +extern void uint@BITS@_bswapn (uint@BITS@_t *, size_t) ; #define UINT@BITS@_FMT @DFMT@ #define UINT@BITS@_OFMT @OFMT@ diff --git a/src/headers/unsigned-template b/src/headers/unsigned-template index 8ef6db4..d7496a0 100644 --- a/src/headers/unsigned-template +++ b/src/headers/unsigned-template @@ -4,9 +4,12 @@ #define @type@_unpack uint@BITS@_unpack #define @type@_unpack_big uint@BITS@_unpack_big -#define @type@_reverse uint@BITS@_reverse -#define @type@_big_endian uint@BITS@_big_endian -#define @type@_little_endian uint@BITS@_little_endian +#define @type@_little uint@BITS@_little +#define @type@_big uint@BITS@_big +#define @type@_littlep uint@BITS@_littlep +#define @type@_bigp uint@BITS@_bigp +#define @type@_littlen uint@BITS@_littlen +#define @type@_bign uint@BITS@_bign #define @TYPE@_FMT UINT@BITS@_FMT #define @TYPE@_OFMT UINT@BITS@_OFMT @@ -39,4 +42,3 @@ #define @type@_bscan(s, u) @type@_scan_base(s, (u), 2) #define @type@0_bscan(s, u) @type@0_scan_base(s, (u), 2) - diff --git a/src/libstddjb/socket_accept4.c b/src/libstddjb/socket_accept4.c index 2016777..36f3dc2 100644 --- a/src/libstddjb/socket_accept4.c +++ b/src/libstddjb/socket_accept4.c @@ -2,6 +2,7 @@ #include <skalibs/sysdeps.h> #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> @@ -14,9 +15,9 @@ int socket_accept4_internal (int s, char *ip, uint16_t *port, unsigned int options) { + int fd ; struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; - int fd ; do #ifdef SKALIBS_HASACCEPT4 fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; @@ -34,6 +35,6 @@ int socket_accept4_internal (int s, char *ip, uint16_t *port, unsigned int optio } #endif memcpy(ip, &sa.sin_addr.s_addr, 4) ; - uint16_unpack_big((char *)&sa.sin_port, port) ; + *port = uint16_big(sa.sin_port) ; return fd ; } diff --git a/src/libstddjb/socket_accept6.c b/src/libstddjb/socket_accept6.c index f5156ca..2c18540 100644 --- a/src/libstddjb/socket_accept6.c +++ b/src/libstddjb/socket_accept6.c @@ -2,6 +2,7 @@ #include <skalibs/sysdeps.h> #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> @@ -17,9 +18,9 @@ int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int options) { + int fd ; struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; - int fd ; do #ifdef SKALIBS_HASACCEPT4 fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; @@ -37,7 +38,7 @@ int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int opti } #endif memcpy(ip6, sa.sin6_addr.s6_addr, 16) ; - uint16_unpack_big((char *)&sa.sin6_port, port) ; + *port = uint16_big(sa.sin6_port) ; return fd ; } diff --git a/src/libstddjb/socket_bind4.c b/src/libstddjb/socket_bind4.c index cc1a079..b654a61 100644 --- a/src/libstddjb/socket_bind4.c +++ b/src/libstddjb/socket_bind4.c @@ -1,9 +1,11 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <string.h> #include <netinet/in.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> @@ -12,8 +14,7 @@ int socket_bind4 (int s, char const *ip, uint16_t port) struct sockaddr_in sa ; memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; - uint16_big_endian((char *)&port, 1) ; - sa.sin_port = port ; + sa.sin_port = uint16_big(port) ; memcpy(&sa.sin_addr.s_addr, ip, 4) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } diff --git a/src/libstddjb/socket_bind4r.c b/src/libstddjb/socket_bind4r.c index 6c4b7e2..e46a4bb 100644 --- a/src/libstddjb/socket_bind4r.c +++ b/src/libstddjb/socket_bind4r.c @@ -1,7 +1,9 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> + #include <skalibs/socket.h> int socket_bind4_reuse (int s, char const *ip, uint16_t port) diff --git a/src/libstddjb/socket_bind6.c b/src/libstddjb/socket_bind6.c index ca14052..6090ad9 100644 --- a/src/libstddjb/socket_bind6.c +++ b/src/libstddjb/socket_bind6.c @@ -1,10 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> #include <skalibs/ip46.h> @@ -16,7 +18,7 @@ int socket_bind6 (int s, char const *ip6, uint16_t port) struct sockaddr_in6 sa ; memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; - uint16_pack_big((char *)&sa.sin6_port, port) ; + sa.sin6_port = uint16_big(port) ; memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; return bind(s, (struct sockaddr *)&sa, sizeof sa) ; } diff --git a/src/libstddjb/socket_bind6r.c b/src/libstddjb/socket_bind6r.c index e52876a..0854262 100644 --- a/src/libstddjb/socket_bind6r.c +++ b/src/libstddjb/socket_bind6r.c @@ -1,7 +1,9 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> + #include <skalibs/socket.h> int socket_bind6_reuse (int s, char const *ip6, uint16_t port) diff --git a/src/libstddjb/socket_conn4.c b/src/libstddjb/socket_connect4.c index ee9eacb..a6dcadf 100644 --- a/src/libstddjb/socket_conn4.c +++ b/src/libstddjb/socket_connect4.c @@ -1,21 +1,22 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <errno.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> int socket_connect4 (int s, char const *ip, uint16_t port) { - struct sockaddr_in sa ; int r ; + struct sockaddr_in sa ; memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; - uint16_big_endian((char *)&port, 1) ; - sa.sin_port = port ; + sa.sin_port = uint16_big(port) ; memcpy(&sa.sin_addr.s_addr, ip, 4) ; do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/socket_conn4_u32.c b/src/libstddjb/socket_connect4_u32.c index 6061e65..6061e65 100644 --- a/src/libstddjb/socket_conn4_u32.c +++ b/src/libstddjb/socket_connect4_u32.c diff --git a/src/libstddjb/socket_conn6.c b/src/libstddjb/socket_connect6.c index 612545d..f5186e0 100644 --- a/src/libstddjb/socket_conn6.c +++ b/src/libstddjb/socket_connect6.c @@ -1,10 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <errno.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> #include <skalibs/ip46.h> @@ -17,7 +19,7 @@ int socket_connect6 (int s, char const *ip6, uint16_t port) int r ; memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; - uint16_pack_big((char *)&sa.sin6_port,port) ; + sa.sin6_port = uint16_big(port) ; memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; do r = connect(s, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/socket_connected.c b/src/libstddjb/socket_connected.c index 58ca463..2768b4c 100644 --- a/src/libstddjb/socket_connected.c +++ b/src/libstddjb/socket_connected.c @@ -1,8 +1,10 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> + #include <skalibs/allreadwrite.h> #include <skalibs/socket.h> diff --git a/src/libstddjb/socket_internal.c b/src/libstddjb/socket_internal.c index 852f323..39c6e38 100644 --- a/src/libstddjb/socket_internal.c +++ b/src/libstddjb/socket_internal.c @@ -2,6 +2,7 @@ #include <skalibs/sysdeps.h> #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <fcntl.h> diff --git a/src/libstddjb/socket_ioloop.c b/src/libstddjb/socket_ioloop.c index aa674b0..2b0f90c 100644 --- a/src/libstddjb/socket_ioloop.c +++ b/src/libstddjb/socket_ioloop.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/error.h> #include <skalibs/iopause.h> #include <skalibs/socket.h> diff --git a/src/libstddjb/socket_local4.c b/src/libstddjb/socket_local4.c index 03628e1..2cc0e70 100644 --- a/src/libstddjb/socket_local4.c +++ b/src/libstddjb/socket_local4.c @@ -1,9 +1,11 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> @@ -11,9 +13,8 @@ int socket_local4 (int s, char *ip, uint16_t *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; - if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) - return -1 ; + if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; memcpy(ip, &sa.sin_addr.s_addr, 4) ; - uint16_unpack_big((char *)&sa.sin_port, port) ; + *port = uint16_big(sa.sin_port) ; return 0 ; } diff --git a/src/libstddjb/socket_local46.c b/src/libstddjb/socket_local46.c index aaf1da0..0fd2c5b 100644 --- a/src/libstddjb/socket_local46.c +++ b/src/libstddjb/socket_local46.c @@ -21,14 +21,14 @@ int socket_local46 (int s, ip46 *ip, uint16_t *port) { struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; memcpy(ip->ip, sa6->sin6_addr.s6_addr, 16) ; - uint16_unpack_big((char *)&sa6->sin6_port, port) ; + *port = uint16_big(sa6->sin6_port) ; ip->is6 = 1 ; } else if (sa.ss_family == AF_INET) { struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; memcpy(ip->ip, &sa4->sin_addr.s_addr, 4) ; - uint16_unpack_big((char *)&sa4->sin_port, port) ; + *port = uint16_big(sa4->sin_port) ; ip->is6 = 0 ; } else return (errno = EAFNOSUPPORT, -1) ; diff --git a/src/libstddjb/socket_local6.c b/src/libstddjb/socket_local6.c index 7f74943..e0dd162 100644 --- a/src/libstddjb/socket_local6.c +++ b/src/libstddjb/socket_local6.c @@ -1,9 +1,11 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> #include <skalibs/ip46.h> @@ -14,10 +16,9 @@ int socket_local6 (int s, char *ip, uint16_t *port) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; - if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) - return -1 ; + if (getsockname(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; memcpy(ip, sa.sin6_addr.s6_addr, 16) ; - uint16_unpack_big((char *)&sa.sin6_port, port) ; + *port = uint16_big(sa.sin6_port) ; return 0 ; } diff --git a/src/libstddjb/socket_recv4.c b/src/libstddjb/socket_recv4.c index 844cc0b..afaaa9a 100644 --- a/src/libstddjb/socket_recv4.c +++ b/src/libstddjb/socket_recv4.c @@ -1,22 +1,24 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <errno.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> ssize_t socket_recv4 (int s, char *buf, size_t len, char *ip, uint16_t *port) { + ssize_t r ; struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; - ssize_t r ; do r = recvfrom(s, buf, len, 0, (struct sockaddr *)&sa, &dummy) ; while ((r == -1) && (errno == EINTR)) ; if (r == -1) return -1 ; memcpy(ip, &sa.sin_addr, 4) ; - uint16_unpack_big((char *)&sa.sin_port, port) ; + *port = uint16_big(sa.sin_port) ; return r ; } diff --git a/src/libstddjb/socket_recv6.c b/src/libstddjb/socket_recv6.c index 2c9733f..fccb4f5 100644 --- a/src/libstddjb/socket_recv6.c +++ b/src/libstddjb/socket_recv6.c @@ -1,10 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <errno.h> #include <string.h> + #include <skalibs/uint16.h> #include <skalibs/ip46.h> #include <skalibs/socket.h> @@ -20,7 +22,7 @@ ssize_t socket_recv6 (int s, char *buf, size_t len, char *ip6, uint16_t *port) while ((r == -1) && (errno == EINTR)) ; if (r == -1) return -1 ; memcpy(ip6, sa.sin6_addr.s6_addr, 16) ; - uint16_unpack_big((char *)&sa.sin6_port, port) ; + *port = uint16_big(sa.sin6_port) ; return r ; } diff --git a/src/libstddjb/socket_remote4.c b/src/libstddjb/socket_remote4.c index 19b8756..7d8613b 100644 --- a/src/libstddjb/socket_remote4.c +++ b/src/libstddjb/socket_remote4.c @@ -1,9 +1,11 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> @@ -11,9 +13,8 @@ int socket_remote4 (int s, char *ip, uint16_t *port) { struct sockaddr_in sa ; socklen_t dummy = sizeof sa ; - if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) - return -1 ; + if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; memcpy(ip, &sa.sin_addr.s_addr, 4) ; - uint16_unpack_big((char *)&sa.sin_port, port) ; + *port = uint16_big(sa.sin_port) ; return 0 ; } diff --git a/src/libstddjb/socket_remote46.c b/src/libstddjb/socket_remote46.c index d0f1548..1a2d924 100644 --- a/src/libstddjb/socket_remote46.c +++ b/src/libstddjb/socket_remote46.c @@ -21,14 +21,14 @@ int socket_remote46 (int s, ip46 *ip, uint16_t *port) { struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)&sa ; memcpy(ip->ip, sa6->sin6_addr.s6_addr, 16) ; - uint16_unpack_big((char *)&sa6->sin6_port, port) ; + *port = uint16_big(sa6->sin6_port) ; ip->is6 = 1 ; } else if (sa.ss_family == AF_INET) { struct sockaddr_in *sa4 = (struct sockaddr_in *)&sa ; memcpy(ip->ip, &sa4->sin_addr.s_addr, 4) ; - uint16_unpack_big((char *)&sa4->sin_port, port) ; + *port = uint16_big(sa4->sin_port) ; ip->is6 = 0 ; } else return (errno = EAFNOSUPPORT, -1) ; diff --git a/src/libstddjb/socket_remote6.c b/src/libstddjb/socket_remote6.c index 6736581..411d222 100644 --- a/src/libstddjb/socket_remote6.c +++ b/src/libstddjb/socket_remote6.c @@ -1,10 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> + #include <skalibs/uint16.h> #include <skalibs/ip46.h> #include <skalibs/socket.h> @@ -15,10 +17,9 @@ int socket_remote6 (int s, char *ip, uint16_t *port) { struct sockaddr_in6 sa ; socklen_t dummy = sizeof sa ; - if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) - return -1 ; + if (getpeername(s, (struct sockaddr *)&sa, &dummy) == -1) return -1 ; memcpy(ip, sa.sin6_addr.s6_addr, 16) ; - uint16_unpack_big((char *)&sa.sin6_port, port) ; + *port = uint16_big(sa.sin6_port) ; return 0 ; } diff --git a/src/libstddjb/socket_send4.c b/src/libstddjb/socket_send4.c index cc358cf..81e991f 100644 --- a/src/libstddjb/socket_send4.c +++ b/src/libstddjb/socket_send4.c @@ -1,20 +1,22 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <errno.h> + #include <skalibs/uint16.h> #include <skalibs/socket.h> ssize_t socket_send4 (int s, char const *buf, size_t len, char const *ip, uint16_t port) { - struct sockaddr_in sa ; ssize_t r ; + struct sockaddr_in sa ; memset(&sa, 0, sizeof sa) ; sa.sin_family = AF_INET ; - uint16_pack_big((char *)&sa.sin_port, port) ; + sa.sin_port = uint16_big(port) ; memcpy(&sa.sin_addr, ip, 4) ; do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/socket_send6.c b/src/libstddjb/socket_send6.c index 807f2a0..6eb276b 100644 --- a/src/libstddjb/socket_send6.c +++ b/src/libstddjb/socket_send6.c @@ -1,10 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <string.h> #include <errno.h> #include <sys/socket.h> #include <netinet/in.h> + #include <skalibs/uint16.h> #include <skalibs/ip46.h> #include <skalibs/socket.h> @@ -13,11 +15,11 @@ ssize_t socket_send6 (int s, char const *buf, size_t len, char const *ip6, uint16_t port) { - struct sockaddr_in6 sa ; ssize_t r ; + struct sockaddr_in6 sa ; memset(&sa, 0, sizeof sa) ; sa.sin6_family = AF_INET6 ; - uint16_pack_big((char *)&sa.sin6_port, port) ; + sa.sin6_port = uint16_big(port) ; memcpy(sa.sin6_addr.s6_addr, ip6, 16) ; do r = sendto(s, buf, len, 0, (struct sockaddr *)&sa, sizeof sa) ; while ((r == -1) && (errno == EINTR)) ; diff --git a/src/libstddjb/socket_delay.c b/src/libstddjb/socket_tcpnodelay.c index 7d1a8db..5ea10b0 100644 --- a/src/libstddjb/socket_delay.c +++ b/src/libstddjb/socket_tcpnodelay.c @@ -1,9 +1,11 @@ /* ISC license. */ #include <skalibs/nonposix.h> + #include <sys/socket.h> #include <netinet/in.h> #include <netinet/tcp.h> + #include <skalibs/socket.h> int socket_tcpnodelay (int s) diff --git a/src/libstddjb/socket_tryr.c b/src/libstddjb/socket_tryreservein.c index 26c04b2..26c04b2 100644 --- a/src/libstddjb/socket_tryr.c +++ b/src/libstddjb/socket_tryreservein.c diff --git a/src/libstddjb/socket_waitconn.c b/src/libstddjb/socket_waitconn.c index a69fed8..9a8ac3d 100644 --- a/src/libstddjb/socket_waitconn.c +++ b/src/libstddjb/socket_waitconn.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/allreadwrite.h> #include <skalibs/iopause.h> #include <skalibs/socket.h> diff --git a/src/libstddjb/uint16_bswapn.c b/src/libstddjb/uint16_bswapn.c new file mode 100644 index 0000000..0d51e0b --- /dev/null +++ b/src/libstddjb/uint16_bswapn.c @@ -0,0 +1,10 @@ +/* ISC license. */ + +#include <stddef.h> + +#include <skalibs/uint16.h> + +void uint16_bswapn (uint16_t *x, size_t n) +{ + while (n--) uint16_bswapp(x++) ; +} diff --git a/src/libstddjb/uint16_bswapp.c b/src/libstddjb/uint16_bswapp.c new file mode 100644 index 0000000..5d235cb --- /dev/null +++ b/src/libstddjb/uint16_bswapp.c @@ -0,0 +1,8 @@ +/* ISC license. */ + +#include <skalibs/uint16.h> + +void uint16_bswapp (uint16_t *x) +{ + *x = uint16_bswap(*x) ; +} diff --git a/src/libstddjb/uint16_pack.c b/src/libstddjb/uint16_pack.c index e7ffe24..353c421 100644 --- a/src/libstddjb/uint16_pack.c +++ b/src/libstddjb/uint16_pack.c @@ -2,10 +2,11 @@ #include <stdint.h> #include <string.h> + #include <skalibs/uint16.h> void uint16_pack (char *s, uint16_t u) { - u = uint16_little(u) ; + uint16_littlep(u) ; memcpy(s, &u, sizeof(uint16_t)) ; } diff --git a/src/libstddjb/uint16_pack_big.c b/src/libstddjb/uint16_pack_big.c index c24f78f..68342ba 100644 --- a/src/libstddjb/uint16_pack_big.c +++ b/src/libstddjb/uint16_pack_big.c @@ -2,10 +2,11 @@ #include <stdint.h> #include <string.h> + #include <skalibs/uint16.h> void uint16_pack_big (char *s, uint16_t u) { - u = uint16_big(u) ; + uint16_bigp(&u) ; memcpy(s, &u, sizeof(uint16_t)) ; } diff --git a/src/libstddjb/uint16_reverse.c b/src/libstddjb/uint16_reverse.c deleted file mode 100644 index 4fa0a7b..0000000 --- a/src/libstddjb/uint16_reverse.c +++ /dev/null @@ -1,15 +0,0 @@ -/* ISC license. */ - -#include <string.h> -#include <skalibs/uint16.h> - -void uint16_reverse (char *s, size_t n) -{ - while (n--) - { - char c = s[0] ; - s[0] = s[1] ; - s[1] = c ; - s += 2 ; - } -} diff --git a/src/libstddjb/uint16_unpack.c b/src/libstddjb/uint16_unpack.c index ea31ebc..8c06b36 100644 --- a/src/libstddjb/uint16_unpack.c +++ b/src/libstddjb/uint16_unpack.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <string.h> + #include <skalibs/uint16.h> void uint16_unpack (char const *s, uint16_t *u) diff --git a/src/libstddjb/uint16_unpack_big.c b/src/libstddjb/uint16_unpack_big.c index 3f6f0df..b09abcd 100644 --- a/src/libstddjb/uint16_unpack_big.c +++ b/src/libstddjb/uint16_unpack_big.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <string.h> + #include <skalibs/uint16.h> void uint16_unpack_big (char const *s, uint16_t *u) diff --git a/src/libstddjb/uint32_bswapn.c b/src/libstddjb/uint32_bswapn.c new file mode 100644 index 0000000..faf731d --- /dev/null +++ b/src/libstddjb/uint32_bswapn.c @@ -0,0 +1,10 @@ +/* ISC license. */ + +#include <stddef.h> + +#include <skalibs/uint32.h> + +void uint32_bswapn (uint32_t *x, size_t n) +{ + while (n--) uint32_bswapp(x++) ; +} diff --git a/src/libstddjb/uint32_bswapp.c b/src/libstddjb/uint32_bswapp.c new file mode 100644 index 0000000..b18e80b --- /dev/null +++ b/src/libstddjb/uint32_bswapp.c @@ -0,0 +1,8 @@ +/* ISC license. */ + +#include <skalibs/uint32.h> + +void uint32_bswapp (uint32_t *x) +{ + *x = uint32_bswap(*x) ; +} diff --git a/src/libstddjb/uint32_pack.c b/src/libstddjb/uint32_pack.c index a06ccf1..b38bfeb 100644 --- a/src/libstddjb/uint32_pack.c +++ b/src/libstddjb/uint32_pack.c @@ -2,10 +2,11 @@ #include <stdint.h> #include <string.h> + #include <skalibs/uint32.h> void uint32_pack (char *s, uint32_t u) { - u = uint32_little(u) ; + uint32_littlep(u) ; memcpy(s, &u, sizeof(uint32_t)) ; } diff --git a/src/libstddjb/uint32_pack_big.c b/src/libstddjb/uint32_pack_big.c index e861e7e..33bf9da 100644 --- a/src/libstddjb/uint32_pack_big.c +++ b/src/libstddjb/uint32_pack_big.c @@ -2,10 +2,11 @@ #include <stdint.h> #include <string.h> + #include <skalibs/uint32.h> void uint32_pack_big (char *s, uint32_t u) { - u = uint32_big(u) ; + uint32_bigp(&u) ; memcpy(s, &u, sizeof(uint32_t)) ; } diff --git a/src/libstddjb/uint32_reverse.c b/src/libstddjb/uint32_reverse.c deleted file mode 100644 index 2d3f915..0000000 --- a/src/libstddjb/uint32_reverse.c +++ /dev/null @@ -1,17 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <string.h> -#include <skalibs/uint32.h> - -void uint32_reverse (char *s, size_t n) -{ - while (n--) - { - uint32_t x ; - memcpy(&x, s, sizeof(uint32_t)) ; - x = uint32_bswap(x) ; - memcpy(s, &x, sizeof(uint32_t)) ; - s += sizeof(uint32_t) ; - } -} diff --git a/src/libstddjb/uint32_unpack.c b/src/libstddjb/uint32_unpack.c index 78aca79..9d86ac3 100644 --- a/src/libstddjb/uint32_unpack.c +++ b/src/libstddjb/uint32_unpack.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <string.h> + #include <skalibs/uint32.h> void uint32_unpack (char const *s, uint32_t *u) diff --git a/src/libstddjb/uint32_unpack_big.c b/src/libstddjb/uint32_unpack_big.c index 307141f..f31540a 100644 --- a/src/libstddjb/uint32_unpack_big.c +++ b/src/libstddjb/uint32_unpack_big.c @@ -2,6 +2,7 @@ #include <stdint.h> #include <string.h> + #include <skalibs/uint32.h> void uint32_unpack_big (char const *s, uint32_t *u) diff --git a/src/libstddjb/uint64_bswapn.c b/src/libstddjb/uint64_bswapn.c new file mode 100644 index 0000000..afb7d1d --- /dev/null +++ b/src/libstddjb/uint64_bswapn.c @@ -0,0 +1,10 @@ +/* ISC license. */ + +#include <stddef.h> + +#include <skalibs/uint64.h> + +void uint64_bswapn (uint64_t *x, size_t n) +{ + while (n--) uint64_bswapp(x++) ; +} diff --git a/src/libstddjb/uint64_bswapp.c b/src/libstddjb/uint64_bswapp.c new file mode 100644 index 0000000..0afc549 --- /dev/null +++ b/src/libstddjb/uint64_bswapp.c @@ -0,0 +1,8 @@ +/* ISC license. */ + +#include <skalibs/uint64.h> + +void uint64_bswapp (uint64_t *x) +{ + *x = uint64_bswap(*x) ; +} diff --git a/src/libstddjb/uint64_pack.c b/src/libstddjb/uint64_pack.c index 18033da..5e8025c 100644 --- a/src/libstddjb/uint64_pack.c +++ b/src/libstddjb/uint64_pack.c @@ -1,10 +1,11 @@ /* ISC license. */ #include <string.h> + #include <skalibs/uint64.h> void uint64_pack (char *s, uint64_t u) { - u = uint64_little(u) ; + uint64_littlep(&u) ; memcpy(s, &u, sizeof(uint64_t)) ; } diff --git a/src/libstddjb/uint64_pack_big.c b/src/libstddjb/uint64_pack_big.c index c0bbcd7..811bd8f 100644 --- a/src/libstddjb/uint64_pack_big.c +++ b/src/libstddjb/uint64_pack_big.c @@ -1,10 +1,11 @@ /* ISC license. */ #include <string.h> + #include <skalibs/uint64.h> void uint64_pack_big (char *s, uint64_t u) { - u = uint64_big(u) ; + uint64_bigp(&u) ; memcpy(s, &u, sizeof(uint64_t)) ; } diff --git a/src/libstddjb/uint64_reverse.c b/src/libstddjb/uint64_reverse.c deleted file mode 100644 index a870b31..0000000 --- a/src/libstddjb/uint64_reverse.c +++ /dev/null @@ -1,16 +0,0 @@ -/* ISC license. */ - -#include <string.h> -#include <skalibs/uint64.h> - -void uint64_reverse (char *s, size_t n) -{ - while (n--) - { - uint64_t x ; - memcpy(&x, s, sizeof(uint64_t)) ; - x = uint64_bswap(x) ; - memcpy(s, &x, sizeof(uint64_t)) ; - s += sizeof(uint64_t) ; - } -} diff --git a/src/libstddjb/uint64_unpack.c b/src/libstddjb/uint64_unpack.c index ca7aad9..bea378a 100644 --- a/src/libstddjb/uint64_unpack.c +++ b/src/libstddjb/uint64_unpack.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <string.h> + #include <skalibs/uint64.h> void uint64_unpack (char const *s, uint64_t *u) diff --git a/src/libstddjb/uint64_unpack_big.c b/src/libstddjb/uint64_unpack_big.c index f4e7d52..43ea79e 100644 --- a/src/libstddjb/uint64_unpack_big.c +++ b/src/libstddjb/uint64_unpack_big.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <string.h> + #include <skalibs/uint64.h> void uint64_unpack_big (char const *s, uint64_t *u) diff --git a/tools/convert-leapsecs.c b/tools/convert-leapsecs.c index 78e0f73..86019f5 100644 --- a/tools/convert-leapsecs.c +++ b/tools/convert-leapsecs.c @@ -2,6 +2,7 @@ #include <sys/types.h> #include <time.h> + #include <skalibs/uint64.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> diff --git a/tools/gen-types.sh b/tools/gen-types.sh index 62d29e2..5dd408f 100755 --- a/tools/gen-types.sh +++ b/tools/gen-types.sh @@ -16,7 +16,7 @@ for i in short int long ; do tools/gen-types-internal.sh $i $I $bits < src/headers/signed-template done -for i in "$@" ; do +for i ; do un=un I=$(echo "$i" | tr a-z A-Z) bits=$(getbits "$sysdeps" $i) |