LCOV - code coverage report
Current view: top level - lib - uuid.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 7 7 100.0 %
Date: 2016-09-14 01:02:56 Functions: 2 2 100.0 %
Branches: 6 8 75.0 %

           Branch data     Line data    Source code
       1                 :            : /* Copyright (c) 2008, 2009, 2010 Nicira, Inc.
       2                 :            :  *
       3                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
       4                 :            :  * you may not use this file except in compliance with the License.
       5                 :            :  * You may obtain a copy of the License at:
       6                 :            :  *
       7                 :            :  *     http://www.apache.org/licenses/LICENSE-2.0
       8                 :            :  *
       9                 :            :  * Unless required by applicable law or agreed to in writing, software
      10                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      11                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12                 :            :  * See the License for the specific language governing permissions and
      13                 :            :  * limitations under the License.
      14                 :            :  */
      15                 :            : 
      16                 :            : #ifndef UUID_H
      17                 :            : #define UUID_H 1
      18                 :            : 
      19                 :            : #include "openvswitch/uuid.h"
      20                 :            : 
      21                 :            : /* Formats a UUID as a string, in the conventional format.
      22                 :            :  *
      23                 :            :  * Example:
      24                 :            :  *   struct uuid uuid = ...;
      25                 :            :  *   printf("This UUID is "UUID_FMT"\n", UUID_ARGS(&uuid));
      26                 :            :  *
      27                 :            :  */
      28                 :            : #define UUID_LEN 36
      29                 :            : #define UUID_FMT "%08x-%04x-%04x-%04x-%04x%08x"
      30                 :            : #define UUID_ARGS(UUID)                             \
      31                 :            :     ((unsigned int) ((UUID)->parts[0])),            \
      32                 :            :     ((unsigned int) ((UUID)->parts[1] >> 16)),      \
      33                 :            :     ((unsigned int) ((UUID)->parts[1] & 0xffff)),   \
      34                 :            :     ((unsigned int) ((UUID)->parts[2] >> 16)),      \
      35                 :            :     ((unsigned int) ((UUID)->parts[2] & 0xffff)),   \
      36                 :            :     ((unsigned int) ((UUID)->parts[3]))
      37                 :            : 
      38                 :            : /* Returns a hash value for 'uuid'.  This hash value is the same regardless of
      39                 :            :  * whether we are running on a 32-bit or 64-bit or big-endian or little-endian
      40                 :            :  * architecture. */
      41                 :            : static inline size_t
      42                 :    2703624 : uuid_hash(const struct uuid *uuid)
      43                 :            : {
      44                 :    2703624 :     return uuid->parts[0];
      45                 :            : }
      46                 :            : 
      47                 :            : /* Returns true if 'a == b', false otherwise. */
      48                 :            : static inline bool
      49                 :    1150520 : uuid_equals(const struct uuid *a, const struct uuid *b)
      50                 :            : {
      51                 :    1150520 :     return (a->parts[0] == b->parts[0]
      52         [ +  - ]:    1077477 :             && a->parts[1] == b->parts[1]
      53         [ +  - ]:    1077477 :             && a->parts[2] == b->parts[2]
      54 [ +  + ][ +  + ]:    2227997 :             && a->parts[3] == b->parts[3]);
      55                 :            : }
      56                 :            : 
      57                 :            : void uuid_init(void);
      58                 :            : void uuid_generate(struct uuid *);
      59                 :            : void uuid_zero(struct uuid *);
      60                 :            : bool uuid_is_zero(const struct uuid *);
      61                 :            : int uuid_compare_3way(const struct uuid *, const struct uuid *);
      62                 :            : bool uuid_from_string(struct uuid *, const char *);
      63                 :            : bool uuid_from_string_prefix(struct uuid *, const char *);
      64                 :            : void uuid_set_bits_v4(struct uuid *);
      65                 :            : 
      66                 :            : #endif /* uuid.h */

Generated by: LCOV version 1.12