Remove macros
htole{s,l,q}, letoh{s,l,q}, htobe{s,l,q}, betoh{s,l,q} and replace it with more standard byteorder macros in our system.
This commit is contained in:
parent
3d42c6d13a
commit
4d79445aaf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=150312
@ -36,7 +36,7 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/mchain.h>
|
#include <sys/endian.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -268,7 +268,7 @@ int
|
|||||||
mb_put_int64be(struct mbdata *mbp, int64_t x)
|
mb_put_int64be(struct mbdata *mbp, int64_t x)
|
||||||
{
|
{
|
||||||
MB_PUT(int64_t);
|
MB_PUT(int64_t);
|
||||||
*p = htobeq(x);
|
*p = htobe64(x);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ int
|
|||||||
mb_put_int64le(struct mbdata *mbp, int64_t x)
|
mb_put_int64le(struct mbdata *mbp, int64_t x)
|
||||||
{
|
{
|
||||||
MB_PUT(int64_t);
|
MB_PUT(int64_t);
|
||||||
*p = htoleq(x);
|
*p = htole64(x);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +367,7 @@ mb_get_uint16le(struct mbdata *mbp, u_int16_t *x)
|
|||||||
u_int16_t v;
|
u_int16_t v;
|
||||||
int error = mb_get_uint16(mbp, &v);
|
int error = mb_get_uint16(mbp, &v);
|
||||||
|
|
||||||
*x = letohs(v);
|
*x = le16toh(v);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +376,7 @@ mb_get_uint16be(struct mbdata *mbp, u_int16_t *x) {
|
|||||||
u_int16_t v;
|
u_int16_t v;
|
||||||
int error = mb_get_uint16(mbp, &v);
|
int error = mb_get_uint16(mbp, &v);
|
||||||
|
|
||||||
*x = betohs(v);
|
*x = be16toh(v);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +393,7 @@ mb_get_uint32be(struct mbdata *mbp, u_int32_t *x)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = mb_get_uint32(mbp, &v);
|
error = mb_get_uint32(mbp, &v);
|
||||||
*x = betohl(v);
|
*x = be32toh(v);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ mb_get_uint32le(struct mbdata *mbp, u_int32_t *x)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = mb_get_uint32(mbp, &v);
|
error = mb_get_uint32(mbp, &v);
|
||||||
*x = letohl(v);
|
*x = le32toh(v);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +421,7 @@ mb_get_int64be(struct mbdata *mbp, int64_t *x)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = mb_get_int64(mbp, &v);
|
error = mb_get_int64(mbp, &v);
|
||||||
*x = betohq(v);
|
*x = be64toh(v);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ mb_get_int64le(struct mbdata *mbp, int64_t *x)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = mb_get_int64(mbp, &v);
|
error = mb_get_int64(mbp, &v);
|
||||||
*x = letohq(v);
|
*x = le64toh(v);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,9 +31,13 @@
|
|||||||
*
|
*
|
||||||
* $Id: nb_name.c,v 1.2 2001/08/22 03:31:36 bp Exp $
|
* $Id: nb_name.c,v 1.2 2001/08/22 03:31:36 bp Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/endian.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/mchain.h> /* for endiand macros */
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
@ -139,7 +143,7 @@ nb_encname_len(const char *str)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NBENCODE(c) (htoles((u_short)(((u_char)(c) >> 4) | \
|
#define NBENCODE(c) (htole16((u_short)(((u_char)(c) >> 4) | \
|
||||||
(((u_char)(c) & 0xf) << 8)) + 0x4141))
|
(((u_char)(c) & 0xf) << 8)) + 0x4141))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
* This is very simple implementation of RAP protocol.
|
* This is very simple implementation of RAP protocol.
|
||||||
*/
|
*/
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/endian.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -45,8 +46,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sysexits.h>
|
#include <sysexits.h>
|
||||||
|
|
||||||
#include <sys/mchain.h>
|
|
||||||
|
|
||||||
#include <netsmb/smb_lib.h>
|
#include <netsmb/smb_lib.h>
|
||||||
#include <netsmb/smb_conn.h>
|
#include <netsmb/smb_conn.h>
|
||||||
#include <netsmb/smb_rap.h>
|
#include <netsmb/smb_rap.h>
|
||||||
@ -290,7 +289,7 @@ smb_rap_getNparam(struct smb_rap *rap, long *value)
|
|||||||
return error;
|
return error;
|
||||||
switch (ptype) {
|
switch (ptype) {
|
||||||
case 'h':
|
case 'h':
|
||||||
*value = letohs(*(u_int16_t*)rap->r_npbuf);
|
*value = le16toh(*(u_int16_t*)rap->r_npbuf);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
@ -320,8 +319,8 @@ smb_rap_request(struct smb_rap *rap, struct smb_ctx *ctx)
|
|||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
rp = (u_int16_t*)rap->r_pbuf;
|
rp = (u_int16_t*)rap->r_pbuf;
|
||||||
rap->r_result = letohs(*rp++);
|
rap->r_result = le16toh(*rp++);
|
||||||
conv = letohs(*rp++);
|
conv = le16toh(*rp++);
|
||||||
rap->r_npbuf = (char*)rp;
|
rap->r_npbuf = (char*)rp;
|
||||||
rap->r_entries = entries = 0;
|
rap->r_entries = entries = 0;
|
||||||
done = 0;
|
done = 0;
|
||||||
@ -329,7 +328,7 @@ smb_rap_request(struct smb_rap *rap, struct smb_ctx *ctx)
|
|||||||
ptype = *p;
|
ptype = *p;
|
||||||
switch (ptype) {
|
switch (ptype) {
|
||||||
case 'e':
|
case 'e':
|
||||||
rap->r_entries = entries = letohs(*(u_int16_t*)rap->r_npbuf);
|
rap->r_entries = entries = le16toh(*(u_int16_t*)rap->r_npbuf);
|
||||||
rap->r_npbuf += 2;
|
rap->r_npbuf += 2;
|
||||||
p++;
|
p++;
|
||||||
break;
|
break;
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
*
|
*
|
||||||
* $Id: view.c,v 1.9 2002/02/20 09:26:42 bp Exp $
|
* $Id: view.c,v 1.9 2002/02/20 09:26:42 bp Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include <sys/endian.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -44,8 +49,6 @@
|
|||||||
|
|
||||||
#include <cflib.h>
|
#include <cflib.h>
|
||||||
|
|
||||||
#include <sys/mchain.h>
|
|
||||||
|
|
||||||
#include <netsmb/smb_lib.h>
|
#include <netsmb/smb_lib.h>
|
||||||
#include <netsmb/smb_conn.h>
|
#include <netsmb/smb_conn.h>
|
||||||
#include <netsmb/smb_rap.h>
|
#include <netsmb/smb_rap.h>
|
||||||
@ -113,7 +116,7 @@ cmd_view(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
for (ep = rpbuf, i = 0; i < entries; i++, ep++) {
|
for (ep = rpbuf, i = 0; i < entries; i++, ep++) {
|
||||||
type = letohs(ep->shi1_type);
|
type = le16toh(ep->shi1_type);
|
||||||
|
|
||||||
cp = (char*)rpbuf + ep->shi1_remark;
|
cp = (char*)rpbuf + ep->shi1_remark;
|
||||||
printf("%-12s %-10s %s\n", ep->shi1_netname,
|
printf("%-12s %-10s %s\n", ep->shi1_netname,
|
||||||
|
@ -34,54 +34,6 @@
|
|||||||
#ifndef _SYS_MCHAIN_H_
|
#ifndef _SYS_MCHAIN_H_
|
||||||
#define _SYS_MCHAIN_H_
|
#define _SYS_MCHAIN_H_
|
||||||
|
|
||||||
#include <machine/endian.h>
|
|
||||||
|
|
||||||
#ifndef _KERNEL
|
|
||||||
/*
|
|
||||||
* This macros probably belongs to the endian.h
|
|
||||||
*/
|
|
||||||
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
|
||||||
|
|
||||||
#define htoles(x) ((u_int16_t)(x))
|
|
||||||
#define letohs(x) ((u_int16_t)(x))
|
|
||||||
#define htolel(x) ((u_int32_t)(x))
|
|
||||||
#define letohl(x) ((u_int32_t)(x))
|
|
||||||
#define htoleq(x) ((int64_t)(x))
|
|
||||||
#define letohq(x) ((int64_t)(x))
|
|
||||||
|
|
||||||
#define htobes(x) (__htons(x))
|
|
||||||
#define betohs(x) (__ntohs(x))
|
|
||||||
#define htobel(x) (__htonl(x))
|
|
||||||
#define betohl(x) (__ntohl(x))
|
|
||||||
|
|
||||||
static __inline int64_t
|
|
||||||
htobeq(int64_t x)
|
|
||||||
{
|
|
||||||
return (int64_t)__htonl((u_int32_t)(x >> 32)) |
|
|
||||||
(int64_t)__htonl((u_int32_t)(x & 0xffffffff)) << 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
static __inline int64_t
|
|
||||||
betohq(int64_t x)
|
|
||||||
{
|
|
||||||
return (int64_t)__ntohl((u_int32_t)(x >> 32)) |
|
|
||||||
(int64_t)__ntohl((u_int32_t)(x & 0xffffffff)) << 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else /* (BYTE_ORDER == LITTLE_ENDIAN) */
|
|
||||||
|
|
||||||
#error "Macros for Big-Endians are incomplete"
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define htoles(x) ((u_int16_t)(x))
|
|
||||||
#define letohs(x) ((u_int16_t)(x))
|
|
||||||
#define htolel(x) ((u_int32_t)(x))
|
|
||||||
#define letohl(x) ((u_int32_t)(x))
|
|
||||||
*/
|
|
||||||
#endif /* (BYTE_ORDER == LITTLE_ENDIAN) */
|
|
||||||
#endif /* _KERNEL */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user