diff options
Diffstat (limited to 'include/nvgpu/bug.h')
| -rw-r--r-- | include/nvgpu/bug.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/nvgpu/bug.h b/include/nvgpu/bug.h index 3d139b7..82d641b 100644 --- a/include/nvgpu/bug.h +++ b/include/nvgpu/bug.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved. |
| 3 | * | 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), | 5 | * copy of this software and associated documentation files (the "Software"), |
| @@ -24,6 +24,24 @@ | |||
| 24 | 24 | ||
| 25 | #ifdef __KERNEL__ | 25 | #ifdef __KERNEL__ |
| 26 | #include <linux/bug.h> | 26 | #include <linux/bug.h> |
| 27 | /* | ||
| 28 | * Define an assert macro that code within nvgpu can use. | ||
| 29 | * | ||
| 30 | * The goal of this macro is for debugging but what that means varies from OS | ||
| 31 | * to OS. On Linux wee don't want to BUG() for general driver misbehaving. BUG() | ||
| 32 | * is a very heavy handed tool - in fact there's probably no where within the | ||
| 33 | * nvgpu core code where it makes sense to use a BUG() when running under Linux. | ||
| 34 | * | ||
| 35 | * However, on QNX (and POSIX) BUG() will just kill the current process. This | ||
| 36 | * means we can use it for handling bugs in nvgpu. | ||
| 37 | * | ||
| 38 | * As a result this macro varies depending on platform. | ||
| 39 | */ | ||
| 40 | #define nvgpu_assert(cond) ((void) WARN_ON(!(cond))) | ||
| 41 | #define nvgpu_do_assert_print(g, fmt, arg...) \ | ||
| 42 | do { \ | ||
| 43 | nvgpu_err(g, fmt, ##arg); \ | ||
| 44 | } while (false) | ||
| 27 | #elif defined(__NVGPU_POSIX__) | 45 | #elif defined(__NVGPU_POSIX__) |
| 28 | #include <nvgpu/posix/bug.h> | 46 | #include <nvgpu/posix/bug.h> |
| 29 | #else | 47 | #else |
