summaryrefslogtreecommitdiff
path: root/security/trousers/files/patch-src-tcs-ps-tcsps.c
blob: df56d1883a7fd5ad350cb78c9cb17fdb7891cd35 (plain) (blame)
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
--- src/tcs/ps/tcsps.c.orig	2010-05-02 11:39:11.000000000 +0900
+++ src/tcs/ps/tcsps.c	2010-10-24 21:04:04.833559489 +0900
@@ -24,6 +24,11 @@
 #define LE_16 htole16
 #define LE_32 htole32
 #define LE_64 htole64
+#elif defined (HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h>
+#define LE_16 htole16
+#define LE_32 htole32
+#define LE_64 htole64
 #else
 #define LE_16(x) (x)
 #define LE_32(x) (x)
@@ -33,6 +38,26 @@
 #include <fcntl.h>
 #include <limits.h>
 
+#ifdef __sun
+#define LOCK_EX  F_LOCK 
+#define LOCK_UN  F_ULOCK 
+#define flock(fd, func) lockf(fd, func, 0)
+#endif
+
+#ifndef LOCK_SH
+#define   LOCK_SH   1    /* shared lock */
+#endif
+#ifndef LOCK_EX
+#define   LOCK_EX   2    /* exclusive lock */
+#endif
+#ifndef LOCK_NB
+#define   LOCK_NB   4    /* don't block when locking */
+#endif
+#ifndef LOCK_UN
+#define   LOCK_UN   8    /* unlock */
+#endif
+
+
 #include "trousers/tss.h"
 #include "trousers_types.h"
 #include "tcsps.h"
@@ -43,6 +68,25 @@
 #include "tcsd_wrap.h"
 #include "tcsd.h"
 
+#ifndef LE_16
+static UINT16 htole16(UINT16 x)
+{
+    BYTE *b = &x;
+    return (UINT16) (b[0] + (b[1] << 8));
+}
+#define LE_16 htole16
+#endif
+
+#ifndef LE_32
+static UINT32 htole32(UINT32 x)
+{
+    BYTE *b = &x;
+    return (UINT32) (b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24));
+}
+#define LE_32 htole32
+#endif
+
+
 int system_ps_fd = -1;
 MUTEX_DECLARE(disk_cache_lock);