1 /*******************************************************************************
2 * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.ctf
.core
.trace
;
15 import java
.util
.UUID
;
21 * @author Matthew Khouzam
22 * @author Simon Marchi
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
33 * CTF magic number. (sort of looks like CTF CTF CT)
35 public static final int CTF_MAGIC
= 0xC1FC1FC1;
38 * TSDL magic number. (sort of looks like TSDL LSDT)
40 public static final int TSDL_MAGIC
= 0x75D11D57;
43 * TSDL magic number length in bytes.
45 public static final int TSDL_MAGIC_LEN
= 4;
48 * Directory separator on the current platform.
50 public static final String SEPARATOR
= System
.getProperty("file.separator"); //$NON-NLS-1$
53 * Length in bytes of a UUID value.
55 public static final int UUID_LEN
= 16;
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
62 * Performs an unsigned long comparison on two unsigned long numbers.
64 * @note As Java does not support unsigned types and arithmetic, parameters
65 * are received encoded as a signed long (two-complement) but the
66 * operation is an unsigned comparator.
69 * Left operand of the comparator.
71 * Right operand of the comparator.
72 * @return -1 if left < right, 1 if left > right, 0 if left == right.
74 public static int unsignedCompare(long left
, long right
) {
76 * This method assumes that the arithmetic overflow on signed
77 * integer wrap on a circular domain (modulo arithmetic in
78 * two-complement), which is the defined behavior in Java.
80 * This idea is to rotate the domain by the length of the negative
81 * space, and then use the signed operator.
83 final long a
= left
+ Long
.MIN_VALUE
;
84 final long b
= right
+ Long
.MIN_VALUE
;
94 * Creates a UUID object from an array of 16 bytes.
98 * @return A UUID object.
100 public static UUID
makeUUID(byte bytes
[]) {
104 assert (bytes
.length
== Utils
.UUID_LEN
);
106 for (int i
= 0; i
< 8; i
++) {
107 low
= (low
<< 8) | (bytes
[i
+ 8] & 0xFF);
108 high
= (high
<< 8) | (bytes
[i
] & 0xFF);
111 UUID uuid
= new UUID(high
, low
);
This page took 0.033226 seconds and 5 git commands to generate.