On 3/11/22 12:56 AM, Rolf Eike Beer wrote:
+ * Forward declaration of the functions in order to maintain
+ * the attributes.
+ * Chris Rapier <rapier@xxxxxxx> 2022-03-09 */
+
+static u_int32_t umac_get_u32_le(const void *)
+ __attribute__((__bounded__(__minbytes__, 1, 4)));
+
+static u_int32_t
+umac_get_u32_le(const void *vp)
You should be able to combine this into one statement if you write:
static __attribute__((__bounded__(__minbytes__, 1, 4)))
u_int32_t umac_get_u32_le(const void *)
{
Excellent! Thank you. I had it in one statement before but the order was
wrong so it kept throwing errors.
diff --git a/misc.c b/misc.c
index 0134d694..20a2a186 100644
--- a/misc.c
+++ b/misc.c
@@ -1533,20 +1533,6 @@ get_u32(const void *vp)
return (v);
}
-u_int32_t
-get_u32_le(const void *vp)
-{
- const u_char *p = (const u_char *)vp;
- u_int32_t v;
-
- v = (u_int32_t)p[0];
- v |= (u_int32_t)p[1] << 8;
- v |= (u_int32_t)p[2] << 16;
- v |= (u_int32_t)p[3] << 24;
-
- return (v);
-}
-
u_int16_t
get_u16(const void *vp)
{
@@ -1585,17 +1571,6 @@ put_u32(void *vp, u_int32_t v)
p[3] = (u_char)v & 0xff;
}
-void
-put_u32_le(void *vp, u_int32_t v)
-{
- u_char *p = (u_char *)vp;
-
- p[0] = (u_char)v & 0xff;
- p[1] = (u_char)(v >> 8) & 0xff;
- p[2] = (u_char)(v >> 16) & 0xff;
- p[3] = (u_char)(v >> 24) & 0xff;
-}
-
void
put_u16(void *vp, u_int16_t v)
{
diff --git a/misc.h b/misc.h
index 2e2dca54..b0c64270 100644
--- a/misc.h
+++ b/misc.h
@@ -154,12 +154,6 @@ void put_u32(void *, u_int32_t)
void put_u16(void *, u_int16_t)
__attribute__((__bounded__( __minbytes__, 1, 2)));
-/* Little-endian store/load, used by umac.c */
-u_int32_t get_u32_le(const void *)
- __attribute__((__bounded__(__minbytes__, 1, 4)));
-void put_u32_le(void *, u_int32_t)
- __attribute__((__bounded__(__minbytes__, 1, 4)));
-
struct bwlimit {
size_t buflen;
u_int64_t rate; /* desired rate in kbit/s */
diff --git a/umac.c b/umac.c
index e5ec19f0..81040b97 100644
--- a/umac.c
+++ b/umac.c
@@ -134,15 +134,48 @@ typedef unsigned int UWORD; /* Register */
/* --- Endian Conversion --- Forcing assembly on some platforms
*/
/*
---------------------------------------------------------------------- */
+
+/* Using local statically defined versions of the get/put functions
+ * found in misc.c allows them to be inlined. This improves throughput
+ * performance by 10% to 15% on well connected (10Gb/s+) systems.
+ * Chris Rapier <rapier@xxxxxxx> 2022-03-09 */
+
+static __attribute__((__bounded__(__minbytes__, 1, 4)))
+u_int32_t umac_get_u32_le(const void *vp)
+{
+ const u_char *p = (const u_char *)vp;
+ u_int32_t v;
+
+ v = (u_int32_t)p[0];
+ v |= (u_int32_t)p[1] << 8;
+ v |= (u_int32_t)p[2] << 16;
+ v |= (u_int32_t)p[3] << 24;
+
+ return (v);
+}
+
+#if (! __LITTLE_ENDIAN__) /* compile time warning thrown otherwise */
+static __attribute__((__bounded__(__minbytes__, 1, 4)));
+void umac_put_u32_le(void *vp, u_int32_t v)
+{
+ u_char *p = (u_char *)vp;
+
+ p[0] = (u_char)v & 0xff;
+ p[1] = (u_char)(v >> 8) & 0xff;
+ p[2] = (u_char)(v >> 16) & 0xff;
+ p[3] = (u_char)(v >> 24) & 0xff;
+}
+#endif
+
#if (__LITTLE_ENDIAN__)
#define LOAD_UINT32_REVERSED(p) get_u32(p)
#define STORE_UINT32_REVERSED(p,v) put_u32(p,v)
#else
-#define LOAD_UINT32_REVERSED(p) get_u32_le(p)
-#define STORE_UINT32_REVERSED(p,v) put_u32_le(p,v)
+#define LOAD_UINT32_REVERSED(p) umac_get_u32_le(p)
+#define STORE_UINT32_REVERSED(p,v) umac_put_u32_le(p,v)
#endif
-#define LOAD_UINT32_LITTLE(p) (get_u32_le(p))
+#define LOAD_UINT32_LITTLE(p) (umac_get_u32_le(p))
#define STORE_UINT32_BIG(p,v) put_u32(p, v)
/*
---------------------------------------------------------------------- */
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev