2014-11-02 :-)
_ [NetBSD][uint64_t]NetBSD/i386 の uint64_t
include/sys/types.h
#include <machine/types.h> #include <machine/ansi.h> #include <machine/int_types.h> #include <sys/ansi.h> #ifndef int8_t typedef __int8_t int8_t; #define int8_t __int8_t #endif #ifndef uint8_t typedef __uint8_t uint8_t; #define uint8_t __uint8_t #endif #ifndef int16_t typedef __int16_t int16_t; #define int16_t __int16_t #endif #ifndef uint16_t typedef __uint16_t uint16_t; #define uint16_t __uint16_t #endif #ifndef int32_t typedef __int32_t int32_t; #define int32_t __int32_t #endif #ifndef uint32_t typedef __uint32_t uint32_t; #define uint32_t __uint32_t #endif #ifndef int64_t typedef __int64_t int64_t; #define int64_t __int64_t #endif #ifndef uint64_t typedef __uint64_t uint64_t; #define uint64_t __uint64_t #endif
__uint64_t はここ。
include/machine/int_types.h
typedef signed char __int8_t; typedef unsigned char __uint8_t; typedef short int __int16_t; typedef unsigned short int __uint16_t; typedef int __int32_t; typedef unsigned int __uint32_t; #ifdef __COMPILER_INT64__ typedef __COMPILER_INT64__ __int64_t; typedef __COMPILER_UINT64__ __uint64_t; #else /* LONGLONG */ typedef long long int __int64_t; /* LONGLONG */ typedef unsigned long long int __uint64_t; #endif
_ [NetBSD][size_t]NetBSD/i386 の size_t
size_t 以外にもいろいろ定義されている。
include/sys/types.h
#ifdef _BSD_CLOCK_T_ typedef _BSD_CLOCK_T_ clock_t; #undef _BSD_CLOCK_T_ #endif #ifdef _BSD_PTRDIFF_T_ typedef _BSD_PTRDIFF_T_ ptrdiff_t; #undef _BSD_PTRDIFF_T_ #endif #ifdef _BSD_SIZE_T_ typedef _BSD_SIZE_T_ size_t; #define _SIZE_T #undef _BSD_SIZE_T_ #endif #ifdef _BSD_SSIZE_T_ typedef _BSD_SSIZE_T_ ssize_t; #undef _BSD_SSIZE_T_ #endif #ifdef _BSD_TIME_T_ typedef _BSD_TIME_T_ time_t; #undef _BSD_TIME_T_ #endif #ifdef _BSD_CLOCKID_T_ typedef _BSD_CLOCKID_T_ clockid_t; #undef _BSD_CLOCKID_T_ #endif #ifdef _BSD_TIMER_T_ typedef _BSD_TIMER_T_ timer_t; #undef _BSD_TIMER_T_ #endif #ifdef _BSD_SUSECONDS_T_ typedef _BSD_SUSECONDS_T_ suseconds_t; #undef _BSD_SUSECONDS_T_ #endif #ifdef _BSD_USECONDS_T_ typedef _BSD_USECONDS_T_ useconds_t; #undef _BSD_USECONDS_T_ #endif
_BSD_SIZE_T_ はここ
include/i386/ansi.h
#define _BSD_CLOCK_T_ unsigned long /* clock() */ #define _BSD_PTRDIFF_T_ int /* ptr1 - ptr2 */ #define _BSD_SIZE_T_ unsigned int /* sizeof() */ #define _BSD_SSIZE_T_ int /* byte count or error */ #define _BSD_TIME_T_ __int64_t /* time() */ #define _BSD_CLOCKID_T_ int /* clockid_t */ #define _BSD_TIMER_T_ int /* timer_t */ #define _BSD_SUSECONDS_T_ int /* suseconds_t */ #define _BSD_USECONDS_T_ unsigned int /* useconds_t */ #define _BSD_WCHAR_T_ int /* wchar_t */ #define _BSD_WINT_T_ int /* wint_t */
_ [NetBSD][printf]NetBSD の printf 指定子
man 嫁
printf(3) - NetBSD Manual Pages
Modifier d, i o, u, x, X n hh signed char unsigned char signed char * h short unsigned short short * l (ell) long unsigned long long * ll (ell ell) long long unsigned long long long long * j intmax_t uintmax_t intmax_t * t ptrdiff_t (see note) ptrdiff_t * z (see note) size_t (see note) q (deprecated) quad_t u_quad_t quad_t *
_ [NetBSD][malloc]NetBSD の malloc が SEGV る
以下 2 つの整数のうち大きい整数は malloc がちゃんとエラーハンドルして小さいほうがエラーにもならず SEGV る。
なんでやねんどないやねん (CV 野田順子)
% uname -msr NetBSD 7.99.1 i386
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <errno.h> 4 #include <limits.h> 5 6 #define HERE() do{ printf("%s %s(%d)\n",__FILE__, __func__, __LINE__ ); }while(0) 7 8 int main(int ac, char** av) 9 { 10 char* buf; 11 size_t a, b; 12 13 a = 4294967295u; 14 b = 4293918720u; <==== こっちのほうが小さい 15 16 printf("%zu (0x%x)\n", a, a ); 17 printf("%zu (0x%x)\n", b, b ); 18 19 HERE(); 20 buf = malloc( a ); <==== こっちは通過して 21 if(buf == NULL) printf("%s\n", strerror(errno)); 22 if(buf != NULL) free(buf); 23 24 HERE(); 25 buf = malloc( b ); <==== こっちで死ぬ 26 if(buf == NULL) printf("%s\n", strerror(errno)); 27 if(buf != NULL) free(buf); 28 29 return 0; 30 } 31
% ./a.out 4294967295 (0xffffffff) 4293918720 (0xfff00000) malloc0.c main(19) Cannot allocate memory malloc0.c main(24) zsh: segmentation fault ./a.out