mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
glthread: simplify printing safe_mul in gl_marshal.py
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4124>
This commit is contained in:
parent
01a50e2493
commit
4ded23a4ad
1 changed files with 8 additions and 8 deletions
|
|
@ -37,6 +37,14 @@ header = """
|
|||
#include "marshal.h"
|
||||
|
||||
#define COMPAT (ctx->API != API_OPENGL_CORE)
|
||||
|
||||
static inline int safe_mul(int a, int b)
|
||||
{
|
||||
if (a < 0 || b < 0) return -1;
|
||||
if (a == 0 || b == 0) return 0;
|
||||
if (a > INT_MAX / b) return -1;
|
||||
return a * b;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
|
|
@ -68,14 +76,6 @@ class PrintCode(gl_XML.gl_print_base):
|
|||
|
||||
def printRealHeader(self):
|
||||
print(header)
|
||||
print('static inline int safe_mul(int a, int b)')
|
||||
print('{')
|
||||
print(' if (a < 0 || b < 0) return -1;')
|
||||
print(' if (a == 0 || b == 0) return 0;')
|
||||
print(' if (a > INT_MAX / b) return -1;')
|
||||
print(' return a * b;')
|
||||
print('}')
|
||||
print()
|
||||
|
||||
def printRealFooter(self):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue