LCOV - code coverage report
Current view: top level - dev/pci/drm - drm_mem_util.h (source / functions) Hit Total Coverage
Test: 6.4 Lines: 0 7 0.0 %
Date: 2018-10-19 03:25:38 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*      $OpenBSD: drm_mem_util.h,v 1.4 2015/04/18 14:47:34 jsg Exp $    */
       2             : /*
       3             :  * Copyright © 2008 Intel Corporation
       4             :  *
       5             :  * Permission is hereby granted, free of charge, to any person obtaining a
       6             :  * copy of this software and associated documentation files (the "Software"),
       7             :  * to deal in the Software without restriction, including without limitation
       8             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
       9             :  * and/or sell copies of the Software, and to permit persons to whom the
      10             :  * Software is furnished to do so, subject to the following conditions:
      11             :  *
      12             :  * The above copyright notice and this permission notice (including the next
      13             :  * paragraph) shall be included in all copies or substantial portions of the
      14             :  * Software.
      15             :  *
      16             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      17             :  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      18             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
      19             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      20             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      21             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
      22             :  * IN THE SOFTWARE.
      23             :  *
      24             :  * Authors:
      25             :  *     Jesse Barnes <jbarnes@virtuousgeek.org>
      26             :  *
      27             :  */
      28             : #ifndef _DRM_MEM_UTIL_H_
      29             : #define _DRM_MEM_UTIL_H_
      30             : 
      31             : #include <sys/types.h>
      32             : #include <sys/malloc.h>
      33             : 
      34           0 : static __inline__ void *drm_calloc_large(size_t nmemb, size_t size)
      35             : {
      36           0 :         return drm_calloc(nmemb, size);
      37             : #ifdef notyet
      38             :         if (size != 0 && nmemb > SIZE_MAX / size)
      39             :                 return NULL;
      40             : 
      41             :         if (size * nmemb <= PAGE_SIZE)
      42             :             return kcalloc(nmemb, size, GFP_KERNEL);
      43             : 
      44             :         return __vmalloc(size * nmemb,
      45             :                          GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
      46             : #endif
      47             : }
      48             : 
      49             : /* Modeled after cairo's malloc_ab, it's like calloc but without the zeroing. */
      50           0 : static __inline__ void *drm_malloc_ab(size_t nmemb, size_t size)
      51             : {
      52           0 :         return (mallocarray(nmemb, size, M_DRM, M_WAITOK | M_CANFAIL));
      53             : #ifdef notyet
      54             :         if (size != 0 && nmemb > SIZE_MAX / size)
      55             :                 return NULL;
      56             : 
      57             :         if (size * nmemb <= PAGE_SIZE)
      58             :             return kmalloc(nmemb * size, GFP_KERNEL);
      59             : 
      60             :         return __vmalloc(size * nmemb,
      61             :                          GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL);
      62             : #endif
      63             : }
      64             : 
      65           0 : static __inline void drm_free_large(void *ptr)
      66             : {
      67           0 :         free(ptr, M_DRM, 0);
      68             : #ifdef notyet
      69             :         if (!is_vmalloc_addr(ptr))
      70             :                 return kfree(ptr);
      71             : 
      72             :         vfree(ptr);
      73             : #endif
      74           0 : }
      75             : 
      76             : #endif

Generated by: LCOV version 1.13