LCOV - code coverage report
Current view: top level - src - btree_kv.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 4 4 100.0 %
Date: 2015-01-12 15:17:13 Functions: 2 2 100.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
       2                 :            : /*
       3                 :            :  *     Copyright 2010 Couchbase, Inc
       4                 :            :  *
       5                 :            :  *   Licensed under the Apache License, Version 2.0 (the "License");
       6                 :            :  *   you may not use this file except in compliance with the License.
       7                 :            :  *   You may obtain a copy of the License at
       8                 :            :  *
       9                 :            :  *       http://www.apache.org/licenses/LICENSE-2.0
      10                 :            :  *
      11                 :            :  *   Unless required by applicable law or agreed to in writing, software
      12                 :            :  *   distributed under the License is distributed on an "AS IS" BASIS,
      13                 :            :  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14                 :            :  *   See the License for the specific language governing permissions and
      15                 :            :  *   limitations under the License.
      16                 :            :  */
      17                 :            : 
      18                 :            : #ifndef _JSAHN_BTREE_KV_H
      19                 :            : #define _JSAHN_BTREE_KV_H
      20                 :            : 
      21                 :            : #include <stdio.h>
      22                 :            : #include <stdint.h>
      23                 :            : #include "common.h"
      24                 :            : 
      25                 :            : #ifdef __cplusplus
      26                 :            : extern "C" {
      27                 :            : #endif
      28                 :            : 
      29                 :         50 : INLINE uint32_t deref32(const void *ptr)
      30                 :            : {
      31                 :            : #ifdef _ALIGN_MEM_ACCESS
      32                 :            :     // 4-byte align check (rightmost 2 bits must be '00')
      33                 :            :     if ( (size_t)ptr & 0x3 ) {
      34                 :            :         uint32_t value;
      35                 :            :         memcpy(&value, ptr, sizeof(uint32_t));
      36                 :            :         return value;
      37                 :            :     }
      38                 :            : #endif
      39                 :         50 :     return *(uint32_t*)ptr;
      40                 :            : }
      41                 :            : 
      42                 : 6576811896 : INLINE uint64_t deref64(const void *ptr)
      43                 :            : {
      44                 :            : #ifdef _ALIGN_MEM_ACCESS
      45                 :            :     // 8-byte align check (rightmost 3 bits must be '000')
      46                 :            :     // Not sure whether 8-byte integer should be aligned in
      47                 :            :     // 8-byte boundary or just 4-byte boundary.
      48                 :            :     if ( (size_t)ptr & 0x7 ) {
      49                 :            :         uint64_t value;
      50                 :            :         memcpy(&value, ptr, sizeof(uint64_t));
      51                 :            :         return value;
      52                 :            :     }
      53                 :            : #endif
      54                 : 6576811896 :     return *(uint64_t*)ptr;
      55                 :            : }
      56                 :            : 
      57                 :            : struct btree_kv_ops;
      58                 :            : struct btree_kv_ops * btree_kv_get_ku64_vu64();
      59                 :            : struct btree_kv_ops * btree_kv_get_ku32_vu64();
      60                 :            : struct btree_kv_ops * btree_kv_get_kb64_vb64(struct btree_kv_ops *kv_ops);
      61                 :            : struct btree_kv_ops * btree_kv_get_kb32_vb64(struct btree_kv_ops *kv_ops);
      62                 :            : 
      63                 :            : #ifdef __cplusplus
      64                 :            : }
      65                 :            : #endif
      66                 :            : 
      67                 :            : #endif

Generated by: LCOV version 1.11