Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
28b382b7
Kaydet (Commit)
28b382b7
authored
Tem 23, 2017
tarafından
Chris Sherlock
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
rtl: cleanup equality conditions in uuid.cxx
Change-Id: I8918cd97f9ab89f0a2f7f95cd59b706ca5a55e2b
üst
80cdd907
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
35 deletions
+38
-35
uuid.cxx
sal/rtl/uuid.cxx
+38
-35
No files found.
sal/rtl/uuid.cxx
Dosyayı görüntüle @
28b382b7
...
@@ -65,45 +65,49 @@ struct UUID
...
@@ -65,45 +65,49 @@ struct UUID
sal_uInt8
node
[
6
];
sal_uInt8
node
[
6
];
};
};
static
void
write_v3
(
sal_uInt8
*
pUuid
)
static
void
write_v3
(
sal_uInt8
*
pUuid
)
{
{
UUID
uuid
;
UUID
uuid
;
// copy to avoid alignment problems
// copy to avoid alignment problems
memcpy
(
&
uuid
,
pUuid
,
16
);
memcpy
(
&
uuid
,
pUuid
,
16
);
SWAP_NETWORK_TO_INT32
(
uuid
.
time_low
);
SWAP_NETWORK_TO_INT32
(
uuid
.
time_low
);
SWAP_NETWORK_TO_INT16
(
uuid
.
time_mid
);
SWAP_NETWORK_TO_INT16
(
uuid
.
time_mid
);
SWAP_NETWORK_TO_INT16
(
uuid
.
time_hi_and_version
);
SWAP_NETWORK_TO_INT16
(
uuid
.
time_hi_and_version
);
/* put in the variant and version bits */
/* put in the variant and version bits */
uuid
.
time_hi_and_version
&=
0x0FFF
;
uuid
.
time_hi_and_version
&=
0x0FFF
;
uuid
.
time_hi_and_version
|=
(
3
<<
12
);
uuid
.
time_hi_and_version
|=
(
3
<<
12
);
uuid
.
clock_seq_hi_and_reserved
&=
0x3F
;
uuid
.
clock_seq_hi_and_reserved
&=
0x3F
;
uuid
.
clock_seq_hi_and_reserved
|=
0x80
;
uuid
.
clock_seq_hi_and_reserved
|=
0x80
;
SWAP_INT32_TO_NETWORK
(
uuid
.
time_low
);
SWAP_INT32_TO_NETWORK
(
uuid
.
time_low
);
SWAP_INT16_TO_NETWORK
(
uuid
.
time_mid
);
SWAP_INT16_TO_NETWORK
(
uuid
.
time_mid
);
SWAP_INT16_TO_NETWORK
(
uuid
.
time_hi_and_version
);
SWAP_INT16_TO_NETWORK
(
uuid
.
time_hi_and_version
);
memcpy
(
pUuid
,
&
uuid
,
16
);
memcpy
(
pUuid
,
&
uuid
,
16
);
}
}
extern
"C"
void
SAL_CALL
rtl_createUuid
(
sal_uInt8
*
pTargetUUID
,
extern
"C"
void
SAL_CALL
rtl_createUuid
(
sal_uInt8
*
pTargetUUID
,
SAL_UNUSED_PARAMETER
const
sal_uInt8
*
,
SAL_UNUSED_PARAMETER
const
sal_uInt8
*
,
SAL_UNUSED_PARAMETER
sal_Bool
)
SAL_UNUSED_PARAMETER
sal_Bool
)
{
{
{
{
osl
::
MutexGuard
g
(
osl
::
Mutex
::
getGlobalMutex
());
osl
::
MutexGuard
g
(
osl
::
Mutex
::
getGlobalMutex
());
static
rtlRandomPool
pool
=
nullptr
;
static
rtlRandomPool
pool
=
nullptr
;
if
(
pool
==
nullptr
)
{
if
(
!
pool
)
{
pool
=
rtl_random_createPool
();
pool
=
rtl_random_createPool
();
if
(
pool
==
nullptr
)
{
if
(
!
pool
)
{
abort
();
abort
();
// only possible way to signal failure here (rtl_createUuid
// only possible way to signal failure here (rtl_createUuid
// being part of a fixed C API)
// being part of a fixed C API)
}
}
}
}
if
(
rtl_random_getBytes
(
pool
,
pTargetUUID
,
16
)
!=
rtl_Random_E_None
)
{
if
(
rtl_random_getBytes
(
pool
,
pTargetUUID
,
16
)
!=
rtl_Random_E_None
)
{
abort
();
abort
();
// only possible way to signal failure here (rtl_createUuid
// only possible way to signal failure here (rtl_createUuid
// being part of a fixed C API)
// being part of a fixed C API)
...
@@ -116,36 +120,36 @@ extern "C" void SAL_CALL rtl_createUuid( sal_uInt8 *pTargetUUID ,
...
@@ -116,36 +120,36 @@ extern "C" void SAL_CALL rtl_createUuid( sal_uInt8 *pTargetUUID ,
pTargetUUID
[
8
]
|=
0x80
;
pTargetUUID
[
8
]
|=
0x80
;
}
}
extern
"C"
void
SAL_CALL
rtl_createNamedUuid
(
sal_uInt8
*
pTargetUUID
,
extern
"C"
void
SAL_CALL
rtl_createNamedUuid
(
sal_uInt8
*
pTargetUUID
,
const
sal_uInt8
*
pNameSpaceUUID
,
const
sal_uInt8
*
pNameSpaceUUID
,
const
rtl_String
*
pName
)
const
rtl_String
*
pName
)
{
{
rtlDigest
digest
=
rtl_digest_createMD5
();
rtlDigest
digest
=
rtl_digest_createMD5
();
rtl_digest_updateMD5
(
digest
,
pNameSpaceUUID
,
16
);
rtl_digest_updateMD5
(
digest
,
pNameSpaceUUID
,
16
);
rtl_digest_updateMD5
(
digest
,
pName
->
buffer
,
pName
->
length
);
rtl_digest_updateMD5
(
digest
,
pName
->
buffer
,
pName
->
length
);
rtl_digest_getMD5
(
digest
,
pTargetUUID
,
16
);
rtl_digest_getMD5
(
digest
,
pTargetUUID
,
16
);
rtl_digest_destroyMD5
(
digest
);
rtl_digest_destroyMD5
(
digest
);
write_v3
(
pTargetUUID
);
write_v3
(
pTargetUUID
);
}
}
extern
"C"
sal_Int32
SAL_CALL
rtl_compareUuid
(
const
sal_uInt8
*
pUUID1
,
const
sal_uInt8
*
pUUID2
)
extern
"C"
sal_Int32
SAL_CALL
rtl_compareUuid
(
const
sal_uInt8
*
pUUID1
,
const
sal_uInt8
*
pUUID2
)
{
{
int
i
;
int
i
;
UUID
u1
;
UUID
u1
;
UUID
u2
;
UUID
u2
;
memcpy
(
&
u1
,
pUUID1
,
16
);
memcpy
(
&
u1
,
pUUID1
,
16
);
memcpy
(
&
u2
,
pUUID2
,
16
);
memcpy
(
&
u2
,
pUUID2
,
16
);
SWAP_NETWORK_TO_INT32
(
u1
.
time_low
);
SWAP_NETWORK_TO_INT32
(
u1
.
time_low
);
SWAP_NETWORK_TO_INT16
(
u1
.
time_mid
);
SWAP_NETWORK_TO_INT16
(
u1
.
time_mid
);
SWAP_NETWORK_TO_INT16
(
u1
.
time_hi_and_version
);
SWAP_NETWORK_TO_INT16
(
u1
.
time_hi_and_version
);
SWAP_NETWORK_TO_INT32
(
u2
.
time_low
);
SWAP_NETWORK_TO_INT32
(
u2
.
time_low
);
SWAP_NETWORK_TO_INT16
(
u2
.
time_mid
);
SWAP_NETWORK_TO_INT16
(
u2
.
time_mid
);
SWAP_NETWORK_TO_INT16
(
u2
.
time_hi_and_version
);
SWAP_NETWORK_TO_INT16
(
u2
.
time_hi_and_version
);
#define CHECK(f1, f2) if (f1 != f2) return f1 < f2 ? -1 : 1;
#define CHECK(f1, f2) if (f1 != f2) return f1 < f2 ? -1 : 1;
CHECK
(
u1
.
time_low
,
u2
.
time_low
);
CHECK
(
u1
.
time_low
,
u2
.
time_low
);
...
@@ -161,7 +165,6 @@ extern "C" sal_Int32 SAL_CALL rtl_compareUuid( const sal_uInt8 *pUUID1 , const s
...
@@ -161,7 +165,6 @@ extern "C" sal_Int32 SAL_CALL rtl_compareUuid( const sal_uInt8 *pUUID1 , const s
return
1
;
return
1
;
}
}
return
0
;
return
0
;
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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