1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <stdint.h> 20 #include <string.h> 21 22 #define UUCMP(u1, u2) if (u1 != u2) return u1 < u2 23 24 struct uuid { 25 uint32_t time_low; 26 uint16_t time_mid; 27 uint16_t time_hi_and_version; 28 uint8_t clock_seq_and_node[8]; 29 30 bool operator<(const struct uuid& rhs) const 31 { 32 UUCMP(time_low, rhs.time_low); 33 UUCMP(time_mid, rhs.time_mid); 34 UUCMP(time_hi_and_version, rhs.time_hi_and_version); 35 return memcmp(clock_seq_and_node, rhs.clock_seq_and_node, 8); 36 } 37 }; 38