1 1.2 rillig /* $NetBSD: platform_ilp32_long.c,v 1.2 2023/03/28 14:44:35 rillig Exp $ */ 2 1.1 rillig # 3 "platform_ilp32_long.c" 3 1.1 rillig 4 1.1 rillig /* 5 1.1 rillig * Test features that only apply to platforms that have 32-bit int, long and 6 1.1 rillig * pointer types and where size_t is unsigned long, not unsigned int. 7 1.1 rillig * 8 1.1 rillig * On these platforms, in portable mode (-p), the type 'int' is in some cases 9 1.1 rillig * assumed to be only 24 bits wide, in order to detect conversions from 10 1.1 rillig * 'long' (or more probably 'size_t') to 'int', which can lose accuracy. 11 1.1 rillig */ 12 1.1 rillig 13 1.1 rillig /* lint1-only-if: ilp32 long */ 14 1.2 rillig /* lint1-extra-flags: -c -h -a -p -b -r -z -X 351 */ 15 1.1 rillig 16 1.1 rillig int s32; 17 1.1 rillig unsigned int u32; 18 1.1 rillig long sl32; 19 1.1 rillig unsigned long ul32; 20 1.1 rillig 21 1.1 rillig void 22 1.1 rillig convert_between_int_and_long(void) 23 1.1 rillig { 24 1.1 rillig /* 25 1.1 rillig * Even though 'long' and 'int' have the same size on this platform, 26 1.1 rillig * the option '-p' enables additional portability checks that assume 27 1.1 rillig * a 24-bit int and a 32-bit long type, to proactively detect loss of 28 1.1 rillig * accuracy on potential other platforms. 29 1.1 rillig */ 30 1.1 rillig /* expect+1: warning: conversion from 'long' to 'int' may lose accuracy [132] */ 31 1.1 rillig s32 = sl32; 32 1.1 rillig sl32 = s32; 33 1.1 rillig u32 = ul32; 34 1.1 rillig ul32 = u32; 35 1.1 rillig } 36