23 lines · 721 B · C
RawDownload
#pragma once /* FIXME(sigrid): s*_overflow_* can be more optimal */#define sadd_overflow_64(a, b, c) ( \  (b < 1) ? \  ((INT64_MAX-(b) <= (a)) ? ((*(c)=(a)+(b)), 0) : 1) : \  ((INT64_MAX-(b) >= (a)) ? ((*(c)=(a)+(b)), 0) : 1) \)#define smul_overflow_64(a, b, c) ( \        ((a)>0 ? ((b)>0 ? (a)>INT64_MAX/(b) : (b)<INT64_MIN/(a)) \               : ((b)>0 ? (a)<INT64_MIN/(b) : ((a)!=0 && (b)<INT64_MAX/(a)))) \        ? 1 \        : ((*(c)=(a)*(b)), 0) \)#if defined(BITS64)#define sadd_overflow(a, b, c) sadd_overflow_64(a, b, c)#else#define sadd_overflow(a, b, c) ( \  (b < 1) ? \  ((INT32_MAX-(b) <= (a)) ? ((*(c)=(a)+(b)), 0) : 1) : \  ((INT32_MAX-(b) >= (a)) ? ((*(c)=(a)+(b)), 0) : 1) \)#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t