1
/* $Id: os.c 3841 2011-10-24 09:28:13Z ming $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
static int endianness_test32(void)
34
PJ_LOG(3,("", " Testing endianness.."));
38
#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN
39
PJ_LOG(3,("", " Library is set to little endian"));
41
# if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN
42
# error Error: Both PJ_IS_LITTLE_ENDIAN and PJ_IS_BIG_ENDIAN are set!
45
if ((t.u16[0] & 0xFFFF) != 0x3344 ||
46
(t.u16[1] & 0xFFFF) != 0x1122)
48
PJ_LOG(3,("", " Error: wrong 16bit values 0x%x and 0x%x",
49
(t.u16[0] & 0xFFFF), (t.u16[1] & 0xFFFF)));
53
if ((t.u8[0] & 0xFF) != 0x44 ||
54
(t.u8[1] & 0xFF) != 0x33 ||
55
(t.u8[2] & 0xFF) != 0x22 ||
56
(t.u8[3] & 0xFF) != 0x11)
58
PJ_LOG(3,("", " Error: wrong 8bit values"));
62
#elif defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN
63
PJ_LOG(3,("", " Library is set to big endian"));
65
if ((t.u16[0] & 0xFFFF) != 0x1122 ||
66
(t.u16[1] & 0xFFFF) != 0x3344)
68
PJ_LOG(3,("", " Error: wrong 16bit values 0x%x and 0x%x",
69
(t.u16[0] & 0xFFFF), (t.u16[1] & 0xFFFF)));
73
if ((t.u8[0] & 0xFF) != 0x11 ||
74
(t.u8[1] & 0xFF) != 0x22 ||
75
(t.u8[2] & 0xFF) != 0x33 ||
76
(t.u8[3] & 0xFF) != 0x44)
78
PJ_LOG(3,("", " Error: wrong 8bit values"));
82
# if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN
83
# error Error: Both PJ_IS_LITTLE_ENDIAN and PJ_IS_BIG_ENDIAN are set!
88
# error Error: Endianness is not set properly!
96
const pj_sys_info *si;
99
PJ_LOG(3,("", " Sys info:"));
100
si = pj_get_sys_info();
101
PJ_LOG(3,("", " machine: %s", si->machine.ptr));
102
PJ_LOG(3,("", " os_name: %s", si->os_name.ptr));
103
PJ_LOG(3,("", " os_ver: 0x%x", si->os_ver));
104
PJ_LOG(3,("", " sdk_name: %s", si->sdk_name.ptr));
105
PJ_LOG(3,("", " sdk_ver: 0x%x", si->sdk_ver));
106
PJ_LOG(3,("", " info: %s", si->info.ptr));
108
rc = endianness_test32();