summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-03-31 02:07:38 +0000
committerNick Mathewson <nickm@torproject.org>2004-03-31 02:07:38 +0000
commit6ea61d5e0dd7a5990ab2a5a8198cef425718f81f (patch)
tree7ed4d3dda872d0caa280242dfad8eda471f6d83c /src/common/util.h
parent670aeb6c8d894cb99a809fd7cc4f516cd0e54933 (diff)
downloadtor-6ea61d5e0dd7a5990ab2a5a8198cef425718f81f.tar.gz
tor-6ea61d5e0dd7a5990ab2a5a8198cef425718f81f.zip
Parse and generate service descriptors
svn:r1403
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/common/util.h b/src/common/util.h
index 862a657e72..072929abe3 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -49,13 +49,36 @@ void tor_strlower(char *s);
*/
#define get_uint16(cp) (*(uint16_t*)(cp))
#define get_uint32(cp) (*(uint32_t*)(cp))
-#define set_uint16(cp,v) do { *(uint16_t)(cp) = (v) } while (0)
-#define set_uint32(cp,v) do { *(uint32_t)(cp) = (v) } while (0)
+#define set_uint16(cp,v) do { *(uint16_t*)(cp) = (v); } while (0)
+#define set_uint32(cp,v) do { *(uint32_t*)(cp) = (v); } while (0)
#else
+#if 1
uint16_t get_uint16(char *cp);
uint32_t get_uint32(char *cp);
void set_uint16(char *cp, uint16_t v);
void set_uint32(char *cp, uint32_t v);
+#else
+#define get_uint16(cp) \
+ ( ((*(((uint8_t*)(cp))+0))<<8) + \
+ ((*(((uint8_t*)(cp))+1)) ) )
+#define get_uint32(cp) \
+ ( ((*(((uint8_t*)(cp))+0))<<24) + \
+ ((*(((uint8_t*)(cp))+1))<<16) + \
+ ((*(((uint8_t*)(cp))+2))<<8 ) + \
+ ((*(((uint8_t*)(cp))+3)) ) )
+#define set_uint16(cp,v) \
+ do { \
+ *(((uint8_t*)(cp))+0) = (v >> 8)&0xff; \
+ *(((uint8_t*)(cp))+1) = (v >> 0)&0xff; \
+ } while (0)
+#define set_uint32(cp,v) \
+ do { \
+ *(((uint8_t*)(cp))+0) = (v >> 24)&0xff; \
+ *(((uint8_t*)(cp))+1) = (v >> 16)&0xff; \
+ *(((uint8_t*)(cp))+2) = (v >> 8)&0xff; \
+ *(((uint8_t*)(cp))+3) = (v >> 0)&0xff; \
+ } while (0)
+#endif
#endif
typedef struct {