Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
7d8c555e
Commit
7d8c555e
authored
Apr 06, 2011
by
Pieter Noordhuis
Browse files
Merge branch 'unstable' into unstable-zset
Conflicts: src/object.c
parents
04a10b1a
0b7f6d09
Changes
24
Show whitespace changes
Inline
Side-by-side
src/sha1.c
View file @
7d8c555e
...
...
@@ -28,55 +28,7 @@ A million repetitions of "a"
#include "solarisfixes.h"
#endif
#include "sha1.h"
#ifndef BYTE_ORDER
#if (BSD >= 199103)
# include <machine/endian.h>
#else
#if defined(linux) || defined(__linux__)
# include <endian.h>
#else
#define LITTLE_ENDIAN 1234
/* least-significant byte first (vax, pc) */
#define BIG_ENDIAN 4321
/* most-significant byte first (IBM, net) */
#define PDP_ENDIAN 3412
/* LSB first in word, MSW first in long (pdp)*/
#if defined(vax) || defined(ns32000) || defined(sun386) || defined(__i386__) || \
defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
defined(__alpha__) || defined(__alpha)
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
defined(apollo) || defined(__convex__) || defined(_CRAY) || \
defined(__hppa) || defined(__hp9000) || \
defined(__hp9000s300) || defined(__hp9000s700) || \
defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc)
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif
/* linux */
#endif
/* BSD */
#endif
/* BYTE_ORDER */
#if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
#define BYTE_ORDER LITTLE_ENDIAN
#else
#define BYTE_ORDER BIG_ENDIAN
#endif
#endif
#if !defined(BYTE_ORDER) || \
(BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
BYTE_ORDER != PDP_ENDIAN)
/* you must determine what the correct bit order is for
* your compiler - the next line is an intentional error
* which will force your compiles to bomb until you fix
* the above macros.
*/
#error "Undefined or invalid BYTE_ORDER"
#endif
#include "config.h"
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
...
...
src/syncio.c
View file @
7d8c555e
...
...
@@ -107,6 +107,7 @@ int syncReadLine(int fd, char *ptr, ssize_t size, int timeout) {
int
fwriteBulkString
(
FILE
*
fp
,
char
*
s
,
unsigned
long
len
)
{
char
cbuf
[
128
];
int
clen
;
cbuf
[
0
]
=
'$'
;
clen
=
1
+
ll2string
(
cbuf
+
1
,
sizeof
(
cbuf
)
-
1
,
len
);
cbuf
[
clen
++
]
=
'\r'
;
...
...
@@ -117,6 +118,19 @@ int fwriteBulkString(FILE *fp, char *s, unsigned long len) {
return
1
;
}
/* Write a multi bulk count in the form "*<count>\r\n" */
int
fwriteBulkCount
(
FILE
*
fp
,
char
prefix
,
int
count
)
{
char
cbuf
[
128
];
int
clen
;
cbuf
[
0
]
=
prefix
;
clen
=
1
+
ll2string
(
cbuf
+
1
,
sizeof
(
cbuf
)
-
1
,
count
);
cbuf
[
clen
++
]
=
'\r'
;
cbuf
[
clen
++
]
=
'\n'
;
if
(
fwrite
(
cbuf
,
clen
,
1
,
fp
)
==
0
)
return
0
;
return
1
;
}
/* Write a double value in bulk format $<count>\r\n<payload>\r\n */
int
fwriteBulkDouble
(
FILE
*
fp
,
double
d
)
{
char
buf
[
128
],
dbuf
[
128
];
...
...
src/ziplist.c
View file @
7d8c555e
...
...
@@ -68,6 +68,7 @@
#include <limits.h>
#include "zmalloc.h"
#include "ziplist.h"
#include "endian.h"
int
ll2string
(
char
*
s
,
size_t
len
,
long
long
value
);
...
...
@@ -207,6 +208,7 @@ static unsigned int zipPrevDecodeLength(unsigned char *p, unsigned int *lensize)
}
else
{
if
(
lensize
)
*
lensize
=
1
+
sizeof
(
len
);
memcpy
(
&
len
,
p
+
1
,
sizeof
(
len
));
memrev32ifbe
(
&
len
);
}
return
len
;
}
...
...
@@ -223,6 +225,7 @@ static unsigned int zipPrevEncodeLength(unsigned char *p, unsigned int len) {
}
else
{
p
[
0
]
=
ZIP_BIGLEN
;
memcpy
(
p
+
1
,
&
len
,
sizeof
(
len
));
memrev32ifbe
(
p
+
1
);
return
1
+
sizeof
(
len
);
}
}
...
...
@@ -234,6 +237,7 @@ static void zipPrevEncodeLengthForceLarge(unsigned char *p, unsigned int len) {
if
(
p
==
NULL
)
return
;
p
[
0
]
=
ZIP_BIGLEN
;
memcpy
(
p
+
1
,
&
len
,
sizeof
(
len
));
memrev32ifbe
(
p
+
1
);
}
/* Return the difference in number of bytes needed to store the new length
...
...
@@ -287,12 +291,15 @@ static void zipSaveInteger(unsigned char *p, int64_t value, unsigned char encodi
if
(
encoding
==
ZIP_INT_16B
)
{
i16
=
value
;
memcpy
(
p
,
&
i16
,
sizeof
(
i16
));
memrev16ifbe
(
p
);
}
else
if
(
encoding
==
ZIP_INT_32B
)
{
i32
=
value
;
memcpy
(
p
,
&
i32
,
sizeof
(
i32
));
memrev32ifbe
(
p
);
}
else
if
(
encoding
==
ZIP_INT_64B
)
{
i64
=
value
;
memcpy
(
p
,
&
i64
,
sizeof
(
i64
));
memrev64ifbe
(
p
);
}
else
{
assert
(
NULL
);
}
...
...
@@ -305,12 +312,15 @@ static int64_t zipLoadInteger(unsigned char *p, unsigned char encoding) {
int64_t
i64
,
ret
=
0
;
if
(
encoding
==
ZIP_INT_16B
)
{
memcpy
(
&
i16
,
p
,
sizeof
(
i16
));
memrev16ifbe
(
&
i16
);
ret
=
i16
;
}
else
if
(
encoding
==
ZIP_INT_32B
)
{
memcpy
(
&
i32
,
p
,
sizeof
(
i32
));
memrev16ifbe
(
&
i32
);
ret
=
i32
;
}
else
if
(
encoding
==
ZIP_INT_64B
)
{
memcpy
(
&
i64
,
p
,
sizeof
(
i64
));
memrev16ifbe
(
&
i64
);
ret
=
i64
;
}
else
{
assert
(
NULL
);
...
...
src/zipmap.c
View file @
7d8c555e
...
...
@@ -80,6 +80,7 @@
#include <string.h>
#include <assert.h>
#include "zmalloc.h"
#include "endian.h"
#define ZIPMAP_BIGLEN 254
#define ZIPMAP_END 255
...
...
@@ -108,6 +109,7 @@ static unsigned int zipmapDecodeLength(unsigned char *p) {
if
(
len
<
ZIPMAP_BIGLEN
)
return
len
;
memcpy
(
&
len
,
p
+
1
,
sizeof
(
unsigned
int
));
memrev32ifbe
(
&
len
);
return
len
;
}
...
...
@@ -123,6 +125,7 @@ static unsigned int zipmapEncodeLength(unsigned char *p, unsigned int len) {
}
else
{
p
[
0
]
=
ZIPMAP_BIGLEN
;
memcpy
(
p
+
1
,
&
len
,
sizeof
(
len
));
memrev32ifbe
(
p
+
1
);
return
1
+
sizeof
(
len
);
}
}
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment