aboutsummaryrefslogtreecommitdiffstats
path: root/main/redis/fix-musl-stdint.patch
blob: 5914e5688bffd7441189502f9d921027e9d25de5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From 6056a76392b52a5b38e57aec2c7ca46b748df298 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 2 Apr 2015 08:27:16 +0200
Subject: [PATCH] sha1: use standard uint32_t integer type

Use the C99 standard uint32_t type instead of the implementation
specific u_int32_t.

This fixes the following compile error when building with musl libc:

  In file included from sha1.c:28:0:
  sha1.h:11:5: error: unknown type name 'u_int32_t'
       u_int32_t state[5];
       ^
---
 src/sha1.c | 14 +++++++-------
 src/sha1.h | 10 ++++++----
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/src/sha1.c b/src/sha1.c
index 7f73b40..e65b59b 100644
--- a/src/sha1.c
+++ b/src/sha1.c
@@ -23,7 +23,7 @@ A million repetitions of "a"
 
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>	/* for u_int*_t */
+#include <stdint.h>	/* for uint*_t */
 #include "solarisfixes.h"
 #include "sha1.h"
 #include "config.h"
@@ -53,12 +53,12 @@ A million repetitions of "a"
 
 /* Hash a single 512-bit block. This is the core of the algorithm. */
 
-void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64])
+void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
 {
-    u_int32_t a, b, c, d, e;
+    uint32_t a, b, c, d, e;
     typedef union {
         unsigned char c[64];
-        u_int32_t l[16];
+        uint32_t l[16];
     } CHAR64LONG16;
 #ifdef SHA1HANDSOFF
     CHAR64LONG16 block[1];  /* use array to appear as a pointer */
@@ -128,9 +128,9 @@ void SHA1Init(SHA1_CTX* context)
 
 /* Run your data through this. */
 
-void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len)
+void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len)
 {
-    u_int32_t i, j;
+    uint32_t i, j;
 
     j = context->count[0];
     if ((context->count[0] += len << 3) < j)
@@ -168,7 +168,7 @@ void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
 
     for (i = 0; i < 2; i++)
        {
-        u_int32_t t = context->count[i];
+        uint32_t t = context->count[i];
         int j;
 
         for (j = 0; j < 4; t >>= 8, j++)
diff --git a/src/sha1.h b/src/sha1.h
index 4c76d19..92e3528 100644
--- a/src/sha1.h
+++ b/src/sha1.h
@@ -7,15 +7,17 @@ By Steve Reid <steve@edmweb.com>
 100% Public Domain
 */
 
+#include <stdint.h>
+
 typedef struct {
-    u_int32_t state[5];
-    u_int32_t count[2];
+    uint32_t state[5];
+    uint32_t count[2];
     unsigned char buffer[64];
 } SHA1_CTX;
 
-void SHA1Transform(u_int32_t state[5], const unsigned char buffer[64]);
+void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
 void SHA1Init(SHA1_CTX* context);
-void SHA1Update(SHA1_CTX* context, const unsigned char* data, u_int32_t len);
+void SHA1Update(SHA1_CTX* context, const unsigned char* data, uint32_t len);
 void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
 
 #ifdef REDIS_TEST